diff --git a/amarok/AUTHORS b/amarok/AUTHORS deleted file mode 100644 index 8b8c8f57..00000000 --- a/amarok/AUTHORS +++ /dev/null @@ -1,14 +0,0 @@ -# Note: Please keep this in sync with Mainpage.dox - -Bart Cerneels -Edward Toroshchin -Mark Kretschmann -Matěj Laitl -Myriam Schweingruber -Patrick von Reth -Ralf Engels -Rick W. Chen -Sam Lade -Sven Krohlas -Téo Mrnjavac -Valorie Zimmerman diff --git a/amarok/CMakeLists.txt b/amarok/CMakeLists.txt deleted file mode 100644 index 98079e79..00000000 --- a/amarok/CMakeLists.txt +++ /dev/null @@ -1,247 +0,0 @@ -project(Amarok) - -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules) - -message(STATUS "${CMAKE_MODULE_PATH}") - -option(WITH_UTILITIES "Enable building of utilities" ON) -option(WITH_PLAYER "Enable building of main Amarok player" ON) -option(WITH_MP3Tunes "Enable mp3tunes in the Amarok player, requires multiple extra dependencies" ON) -option(WITH_IPOD "Enable iPod support in Amarok" ON) -option(WITH_MYSQL_EMBEDDED "Build the embedded database library -- highly recommended" ON) -option(WITH_PLAYGROUND "Enable building of playground scripts and applets (WARNING: some of them might have legal issues!)" OFF) - -############### Taglib -set(TAGLIB_MIN_VERSION "1.7") -find_package(Taglib REQUIRED) - -# Check if TagLib is built with ASF and MP4 support -include(CheckCXXSourceCompiles) -set(CMAKE_REQUIRED_INCLUDES "${TAGLIB_INCLUDES}") -set(CMAKE_REQUIRED_LIBRARIES "${TAGLIB_LIBRARIES}") - -check_cxx_source_compiles("#include -int main() { TagLib::ASF::Tag tag; return 0;}" TAGLIB_ASF_FOUND) -if( NOT TAGLIB_ASF_FOUND ) - message(FATAL_ERROR "TagLib does not have ASF support compiled in.") -endif( NOT TAGLIB_ASF_FOUND ) - -check_cxx_source_compiles("#include -int main() { TagLib::MP4::Tag tag(0, 0); return 0;}" TAGLIB_MP4_FOUND) -if( NOT TAGLIB_MP4_FOUND ) - message(FATAL_ERROR "TagLib does not have MP4 support compiled in.") -endif( NOT TAGLIB_MP4_FOUND ) - -check_cxx_source_compiles("#include -#include -#include -#include -#include -using namespace TagLib; -int main() { char *s; Mod::Tag tag; Mod::File modfile(s); S3M::File s3mfile(s); -IT::File itfile(s); XM::File xmfile(s); return 0; }" TAGLIB_MOD_FOUND) - -check_cxx_source_compiles("#include -int main() { char *s; TagLib::Ogg::Opus::File opusfile(s); return 0;}" TAGLIB_OPUS_FOUND) - -set(CMAKE_REQUIRED_INCLUDES) -set(CMAKE_REQUIRED_LIBRARIES) - -set(TAGLIB-EXTRAS_MIN_VERSION "1.0") -find_package(Taglib-Extras) -set(TAGLIB_EXTRAS_FOUND ${TAGLIB-EXTRAS_FOUND}) # we need a c-compatible name for the include file - -include(CheckTagLibFileName) - -check_taglib_filename(COMPLEX_TAGLIB_FILENAME) -############### - - -# Needed to conditionally build tests and gui -if(KDE4_BUILD_TESTS) - add_definitions(-DDEBUG) -endif() - -if(WITH_DESKTOP_UI) - add_definitions(-DDESKTOP_UI) -endif() -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fmessage-length=0") -if (CMAKE_COMPILER_IS_GNUCXX) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fmessage-length=0") - if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--as-needed") - endif(${CMAKE_SYSTEM_NAME} MATCHES "Linux") -endif (CMAKE_COMPILER_IS_GNUCXX) - -include_directories( - ${CMAKE_CURRENT_SOURCE_DIR}/shared - ${CMAKE_CURRENT_BINARY_DIR}/shared -) - -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") # Require C++11 - -# WORKAROUND for Clang bug: http://llvm.org/bugs/show_bug.cgi?id=15651 -if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND WIN32) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-delayed-template-parsing") -endif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND WIN32) - - -include( MacroBoolTo01 ) -include( MacroLibrary ) -add_definitions( ${QT_DEFINITIONS} ${KDE4_DEFINITIONS} ) - -# QCA2 is required for the Script Updater -find_package( QCA2 ) - -macro_optional_find_package( LibLastFm ) -set( LIBLASTFM_MIN_VERSION ) -if( LIBLASTFM_FOUND ) - if("${LIBLASTFM_VERSION}" VERSION_LESS "1.0.0") - set(LIBLASTFM_FOUND FALSE) - endif() -endif( LIBLASTFM_FOUND ) -macro_bool_to_01( LIBLASTFM_FOUND HAVE_LIBLASTFM ) - -macro_optional_find_package( FFmpeg ) - -if( FFMPEG_FOUND ) - macro_optional_find_package( LibOFA ) - macro_bool_to_01( LIBOFA_FOUND HAVE_LIBOFA ) -endif( FFMPEG_FOUND ) - -string( TOLOWER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_TOLOWER ) -if( CMAKE_BUILD_TYPE_TOLOWER MATCHES debug ) - set( DEBUG_BUILD_TYPE ON ) - add_definitions(-Wall -Wextra) -endif( CMAKE_BUILD_TYPE_TOLOWER MATCHES debug ) - -# this needs to be here because also code in shared/ needs config.h. This is also the -# reason why various checks are above why they belong under if( WITH_PLAYER ) -configure_file( shared/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/shared/config.h ) - -add_subdirectory( data ) -add_subdirectory( images ) -add_subdirectory( shared ) - -if( WITH_PLAYER ) - include(MacroLogFeature) - - macro_log_feature( QT_QTOPENGL_FOUND "QtOpenGL" "Required for the spectrum analyzer" "http://qt-project.org" FALSE "" "" ) - - find_package(MySQLAmarok REQUIRED) - if( WITH_MYSQL_EMBEDDED ) - set( BUILD_MYSQLE_COLLECTION TRUE ) - macro_log_feature( MYSQL_EMBEDDED_FOUND "mysqld" "Embedded MySQL Libraries" "http://www.mysql.com" TRUE "" "" ) - else( WITH_MYSQL_EMBEDDED ) - add_definitions( "-DNO_MYSQL_EMBEDDED" ) - endif( WITH_MYSQL_EMBEDDED ) - macro_log_feature( MYSQL_FOUND "mysql" "MySQL Server Libraries" "http://www.mysql.com" TRUE "" "" ) - - # zlib is required for mysql embedded - find_package(ZLIB REQUIRED) - macro_log_feature( ZLIB_FOUND "zlib" "zlib" "" TRUE "" "" ) - - macro_log_feature( QCA2_FOUND "qca2" "Qt Cryptographic Architecture" "http://delta.affinix.com/qca/" FALSE "" "" ) - - # QJson is required for the PlaydarCollection - macro_optional_find_package(QJSON) - macro_log_feature( QJSON_FOUND "QJson" "Qt JSON Parser used for the Playdar Collection" "http://qjson.sourceforge.net/" FALSE "" "" ) - - # We tell users that we need 1.0.3, but we really check just >= 1.0.0. This is because - # upstream forgot to update version in lastfm/global.h, so it looks like 1.0.2. :-( - # will be fixed in liblastfm-1.0.4 - set( LIBLASTFM_MIN_VERSION "1.0.3" ) - macro_log_feature( LIBLASTFM_FOUND "liblastfm" "Enable Last.Fm service, including scrobbling, song submissions, and suggested song dynamic playlists" - "http://cdn.last.fm/client/liblastfm-${LIBLASTFM_MIN_VERSION}.tar.gz" FALSE ${LIBLASTFM_MIN_VERSION} "" ) - - macro_log_feature( FFMPEG_FOUND "ffmpeg" "Libraries and tools for handling multimedia data" "http://www.ffmpeg.org/" FALSE "0.7" "" ) - - if( FFMPEG_FOUND ) - macro_log_feature( LIBOFA_FOUND "libofa" "Enable MusicDNS service" "http://code.google.com/p/musicip-libofa/" FALSE "0.9.x" "" ) - endif( FFMPEG_FOUND ) - - ##gpodder Service - macro_optional_find_package( Mygpo-qt 1.0.7 QUIET ) - macro_log_feature( LIBMYGPO_QT_FOUND "libmygpo-qt" "Enable gpodder.net service" "http://wiki.gpodder.org/wiki/Libmygpo-qt" FALSE "1.0.7" "" ) - macro_bool_to_01( LIBMYGPO_QT_FOUND HAVE_LIBMYGPOQT ) - - if( WITH_IPOD ) - find_package(Ipod) - if( IPOD_FOUND AND NOT WIN32 ) - if("${IPOD_VERSION}" VERSION_LESS "0.8.2") - set(IPOD_FOUND FALSE) - endif() - endif( IPOD_FOUND AND NOT WIN32 ) - macro_log_feature( IPOD_FOUND "libgpod" "Support Apple iPod/iPad/iPhone audio devices" "http://sourceforge.net/projects/gtkpod/" FALSE ${IPOD_MIN_VERSION} "" ) - macro_optional_find_package(GDKPixBuf) - macro_log_feature( GDKPIXBUF_FOUND "GDK-PixBuf" "Support for artwork on iPod audio devices via GDK-PixBuf" "http://developer.gnome.org/arch/imaging/gdkpixbuf.html" FALSE "2.0.x" "" ) - endif( WITH_IPOD ) - - macro_optional_find_package(Mtp) - macro_log_feature( MTP_FOUND "libmtp" "Enable Support for portable media devices that use the media transfer protocol" "http://libmtp.sourceforge.net/" FALSE "1.0.0" "") - - if( WITH_MP3Tunes ) - find_package(CURL) - macro_log_feature( CURL_FOUND "curl" "cURL provides the necessary network libraries required by mp3tunes." "http://curl.haxx.se" FALSE "" "" ) - - find_package(LibXml2) - macro_log_feature( LIBXML2_FOUND "libxml2" "LibXML2 is an XML parser required by mp3tunes." "http://www.xmlsoft.org" FALSE "" "" ) - - macro_optional_find_package(OpenSSL) - macro_optional_find_package(Libgcrypt) - if ( OPENSSL_FOUND OR LIBGCRYPT_FOUND ) - set (_mp3tunes_crypto TRUE ) - else ( OPENSSL_FOUND OR LIBGCRYPT_FOUND ) - message( SEND_ERROR "Building with mp3tunes support REQUIRES either OpenSSL or GNU Libgcrypt" ) - endif ( OPENSSL_FOUND OR LIBGCRYPT_FOUND ) - macro_log_feature( _mp3tunes_crypto "openssl or libgcrypt" "OpenSSL or GNU Libgcrypt provides cryptographic functions required by mp3tunes." "http://www.openssl.org/ or http://www.gnupg.org/download/#libgcrypt" FALSE "" "" ) - - find_package(Loudmouth) - macro_log_feature( LOUDMOUTH_FOUND "loudmouth" "Loudmouth is the communication backend needed by mp3tunes for syncing." "http://www.loudmouth-project.org" FALSE "" "" ) - - include(CheckQtGlib) - macro_log_feature(QT4_GLIB_SUPPORT "Qt4 Glib support" "Qt4 must be compiled with glib support for mp3tunes" "http://www.trolltech.com" FALSE "" "") - endif( WITH_MP3Tunes ) - - if( WITH_IPOD OR WITH_MP3Tunes ) - find_package(GObject) - macro_log_feature( GOBJECT_FOUND "gobject" "Required by libgpod and mp3tunes." "http://www.gtk.org" FALSE "2.x" "" ) - find_package(GLIB2) - macro_log_feature( GLIB2_FOUND "glib2" "Required by libgpod and mp3tunes" "http://www.gtk.org" FALSE "2.x" "") - endif( WITH_IPOD OR WITH_MP3Tunes ) - - find_program( CLAMZ_FOUND clamz PATH ) - macro_log_feature( CLAMZ_FOUND "clamz" "Optional requirement to download songs from the Amazon MP3 store. Highly recommended on Linux, as the official downloader from Amazon is quite broken on many systems." "https://code.google.com/p/clamz/" FALSE ) - - find_package(PythonInterp) - macro_log_feature(PYTHONINTERP_FOUND "Python" "Required for generating the autocompletion file for the script console" "https://www.python.org" FALSE "2.x" "") - - include_directories( ${KDE4_INCLUDES} ) - - if( KDE4_BUILD_TESTS AND NOT WIN32 ) - ENABLE_TESTING() - add_subdirectory( tests ) - endif( KDE4_BUILD_TESTS AND NOT WIN32 ) - - add_subdirectory( src ) - - # Also display taglib in the feature log - macro_log_feature( TAGLIB_FOUND "taglib" "Support for Audio metadata." "http://developer.kde.org/~wheeler/taglib.html" TRUE "${TAGLIB_MIN_VERSION}" "Required for tag reading" ) - # following line is here (and not near TAGLIB_MOD_FOUND) because there may be no MacroLogFeature without kdelibs - macro_log_feature( TAGLIB_MOD_FOUND "taglib" "Additional support for Audio metadata of mod, s3m, it and xm files." "http://developer.kde.org/~wheeler/taglib.html" FALSE "1.8" "" ) - macro_log_feature( TAGLIB_OPUS_FOUND "taglib" "Additional support for Audio metadata of opus files." "http://developer.kde.org/~wheeler/taglib.html" FALSE "1.9" "" ) - -endif( WITH_PLAYER ) - -if( WITH_UTILITIES ) - set(EXEC_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX} CACHE PATH "Base directory for executables and libraries" FORCE) - set(BIN_INSTALL_DIR "${EXEC_INSTALL_PREFIX}/bin" CACHE PATH "The subdirectory to the binaries prefix (default prefix/bin)" FORCE) - add_subdirectory( utilities ) -endif( WITH_UTILITIES ) - -if( WITH_PLAYGROUND ) - add_subdirectory( playground ) - message(STATUS "Included playground subdirectory in configuration") -endif( WITH_PLAYGROUND ) - -include(CTest) diff --git a/amarok/COPYING b/amarok/COPYING deleted file mode 100644 index c9757972..00000000 --- a/amarok/COPYING +++ /dev/null @@ -1,340 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program 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 2 of the License, or - (at your option) any later version. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. diff --git a/amarok/COPYING.DOC b/amarok/COPYING.DOC deleted file mode 100644 index 4a0fe1c8..00000000 --- a/amarok/COPYING.DOC +++ /dev/null @@ -1,397 +0,0 @@ - GNU Free Documentation License - Version 1.2, November 2002 - - - Copyright (C) 2000,2001,2002 Free Software Foundation, Inc. - 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - -0. PREAMBLE - -The purpose of this License is to make a manual, textbook, or other -functional and useful document "free" in the sense of freedom: to -assure everyone the effective freedom to copy and redistribute it, -with or without modifying it, either commercially or noncommercially. -Secondarily, this License preserves for the author and publisher a way -to get credit for their work, while not being considered responsible -for modifications made by others. - -This License is a kind of "copyleft", which means that derivative -works of the document must themselves be free in the same sense. It -complements the GNU General Public License, which is a copyleft -license designed for free software. - -We have designed this License in order to use it for manuals for free -software, because free software needs free documentation: a free -program should come with manuals providing the same freedoms that the -software does. But this License is not limited to software manuals; -it can be used for any textual work, regardless of subject matter or -whether it is published as a printed book. We recommend this License -principally for works whose purpose is instruction or reference. - - -1. APPLICABILITY AND DEFINITIONS - -This License applies to any manual or other work, in any medium, that -contains a notice placed by the copyright holder saying it can be -distributed under the terms of this License. Such a notice grants a -world-wide, royalty-free license, unlimited in duration, to use that -work under the conditions stated herein. The "Document", below, -refers to any such manual or work. Any member of the public is a -licensee, and is addressed as "you". You accept the license if you -copy, modify or distribute the work in a way requiring permission -under copyright law. - -A "Modified Version" of the Document means any work containing the -Document or a portion of it, either copied verbatim, or with -modifications and/or translated into another language. - -A "Secondary Section" is a named appendix or a front-matter section of -the Document that deals exclusively with the relationship of the -publishers or authors of the Document to the Document's overall subject -(or to related matters) and contains nothing that could fall directly -within that overall subject. (Thus, if the Document is in part a -textbook of mathematics, a Secondary Section may not explain any -mathematics.) The relationship could be a matter of historical -connection with the subject or with related matters, or of legal, -commercial, philosophical, ethical or political position regarding -them. - -The "Invariant Sections" are certain Secondary Sections whose titles -are designated, as being those of Invariant Sections, in the notice -that says that the Document is released under this License. If a -section does not fit the above definition of Secondary then it is not -allowed to be designated as Invariant. The Document may contain zero -Invariant Sections. If the Document does not identify any Invariant -Sections then there are none. - -The "Cover Texts" are certain short passages of text that are listed, -as Front-Cover Texts or Back-Cover Texts, in the notice that says that -the Document is released under this License. A Front-Cover Text may -be at most 5 words, and a Back-Cover Text may be at most 25 words. - -A "Transparent" copy of the Document means a machine-readable copy, -represented in a format whose specification is available to the -general public, that is suitable for revising the document -straightforwardly with generic text editors or (for images composed of -pixels) generic paint programs or (for drawings) some widely available -drawing editor, and that is suitable for input to text formatters or -for automatic translation to a variety of formats suitable for input -to text formatters. A copy made in an otherwise Transparent file -format whose markup, or absence of markup, has been arranged to thwart -or discourage subsequent modification by readers is not Transparent. -An image format is not Transparent if used for any substantial amount -of text. A copy that is not "Transparent" is called "Opaque". - -Examples of suitable formats for Transparent copies include plain -ASCII without markup, Texinfo input format, LaTeX input format, SGML -or XML using a publicly available DTD, and standard-conforming simple -HTML, PostScript or PDF designed for human modification. Examples of -transparent image formats include PNG, XCF and JPG. Opaque formats -include proprietary formats that can be read and edited only by -proprietary word processors, SGML or XML for which the DTD and/or -processing tools are not generally available, and the -machine-generated HTML, PostScript or PDF produced by some word -processors for output purposes only. - -The "Title Page" means, for a printed book, the title page itself, -plus such following pages as are needed to hold, legibly, the material -this License requires to appear in the title page. For works in -formats which do not have any title page as such, "Title Page" means -the text near the most prominent appearance of the work's title, -preceding the beginning of the body of the text. - -A section "Entitled XYZ" means a named subunit of the Document whose -title either is precisely XYZ or contains XYZ in parentheses following -text that translates XYZ in another language. (Here XYZ stands for a -specific section name mentioned below, such as "Acknowledgements", -"Dedications", "Endorsements", or "History".) To "Preserve the Title" -of such a section when you modify the Document means that it remains a -section "Entitled XYZ" according to this definition. - -The Document may include Warranty Disclaimers next to the notice which -states that this License applies to the Document. These Warranty -Disclaimers are considered to be included by reference in this -License, but only as regards disclaiming warranties: any other -implication that these Warranty Disclaimers may have is void and has -no effect on the meaning of this License. - - -2. VERBATIM COPYING - -You may copy and distribute the Document in any medium, either -commercially or noncommercially, provided that this License, the -copyright notices, and the license notice saying this License applies -to the Document are reproduced in all copies, and that you add no other -conditions whatsoever to those of this License. You may not use -technical measures to obstruct or control the reading or further -copying of the copies you make or distribute. However, you may accept -compensation in exchange for copies. If you distribute a large enough -number of copies you must also follow the conditions in section 3. - -You may also lend copies, under the same conditions stated above, and -you may publicly display copies. - - -3. COPYING IN QUANTITY - -If you publish printed copies (or copies in media that commonly have -printed covers) of the Document, numbering more than 100, and the -Document's license notice requires Cover Texts, you must enclose the -copies in covers that carry, clearly and legibly, all these Cover -Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on -the back cover. Both covers must also clearly and legibly identify -you as the publisher of these copies. The front cover must present -the full title with all words of the title equally prominent and -visible. You may add other material on the covers in addition. -Copying with changes limited to the covers, as long as they preserve -the title of the Document and satisfy these conditions, can be treated -as verbatim copying in other respects. - -If the required texts for either cover are too voluminous to fit -legibly, you should put the first ones listed (as many as fit -reasonably) on the actual cover, and continue the rest onto adjacent -pages. - -If you publish or distribute Opaque copies of the Document numbering -more than 100, you must either include a machine-readable Transparent -copy along with each Opaque copy, or state in or with each Opaque copy -a computer-network location from which the general network-using -public has access to download using public-standard network protocols -a complete Transparent copy of the Document, free of added material. -If you use the latter option, you must take reasonably prudent steps, -when you begin distribution of Opaque copies in quantity, to ensure -that this Transparent copy will remain thus accessible at the stated -location until at least one year after the last time you distribute an -Opaque copy (directly or through your agents or retailers) of that -edition to the public. - -It is requested, but not required, that you contact the authors of the -Document well before redistributing any large number of copies, to give -them a chance to provide you with an updated version of the Document. - - -4. MODIFICATIONS - -You may copy and distribute a Modified Version of the Document under -the conditions of sections 2 and 3 above, provided that you release -the Modified Version under precisely this License, with the Modified -Version filling the role of the Document, thus licensing distribution -and modification of the Modified Version to whoever possesses a copy -of it. In addition, you must do these things in the Modified Version: - -A. Use in the Title Page (and on the covers, if any) a title distinct - from that of the Document, and from those of previous versions - (which should, if there were any, be listed in the History section - of the Document). You may use the same title as a previous version - if the original publisher of that version gives permission. -B. List on the Title Page, as authors, one or more persons or entities - responsible for authorship of the modifications in the Modified - Version, together with at least five of the principal authors of the - Document (all of its principal authors, if it has fewer than five), - unless they release you from this requirement. -C. State on the Title page the name of the publisher of the - Modified Version, as the publisher. -D. Preserve all the copyright notices of the Document. -E. Add an appropriate copyright notice for your modifications - adjacent to the other copyright notices. -F. Include, immediately after the copyright notices, a license notice - giving the public permission to use the Modified Version under the - terms of this License, in the form shown in the Addendum below. -G. Preserve in that license notice the full lists of Invariant Sections - and required Cover Texts given in the Document's license notice. -H. Include an unaltered copy of this License. -I. Preserve the section Entitled "History", Preserve its Title, and add - to it an item stating at least the title, year, new authors, and - publisher of the Modified Version as given on the Title Page. If - there is no section Entitled "History" in the Document, create one - stating the title, year, authors, and publisher of the Document as - given on its Title Page, then add an item describing the Modified - Version as stated in the previous sentence. -J. Preserve the network location, if any, given in the Document for - public access to a Transparent copy of the Document, and likewise - the network locations given in the Document for previous versions - it was based on. These may be placed in the "History" section. - You may omit a network location for a work that was published at - least four years before the Document itself, or if the original - publisher of the version it refers to gives permission. -K. For any section Entitled "Acknowledgements" or "Dedications", - Preserve the Title of the section, and preserve in the section all - the substance and tone of each of the contributor acknowledgements - and/or dedications given therein. -L. Preserve all the Invariant Sections of the Document, - unaltered in their text and in their titles. Section numbers - or the equivalent are not considered part of the section titles. -M. Delete any section Entitled "Endorsements". Such a section - may not be included in the Modified Version. -N. Do not retitle any existing section to be Entitled "Endorsements" - or to conflict in title with any Invariant Section. -O. Preserve any Warranty Disclaimers. - -If the Modified Version includes new front-matter sections or -appendices that qualify as Secondary Sections and contain no material -copied from the Document, you may at your option designate some or all -of these sections as invariant. To do this, add their titles to the -list of Invariant Sections in the Modified Version's license notice. -These titles must be distinct from any other section titles. - -You may add a section Entitled "Endorsements", provided it contains -nothing but endorsements of your Modified Version by various -parties--for example, statements of peer review or that the text has -been approved by an organization as the authoritative definition of a -standard. - -You may add a passage of up to five words as a Front-Cover Text, and a -passage of up to 25 words as a Back-Cover Text, to the end of the list -of Cover Texts in the Modified Version. Only one passage of -Front-Cover Text and one of Back-Cover Text may be added by (or -through arrangements made by) any one entity. If the Document already -includes a cover text for the same cover, previously added by you or -by arrangement made by the same entity you are acting on behalf of, -you may not add another; but you may replace the old one, on explicit -permission from the previous publisher that added the old one. - -The author(s) and publisher(s) of the Document do not by this License -give permission to use their names for publicity for or to assert or -imply endorsement of any Modified Version. - - -5. COMBINING DOCUMENTS - -You may combine the Document with other documents released under this -License, under the terms defined in section 4 above for modified -versions, provided that you include in the combination all of the -Invariant Sections of all of the original documents, unmodified, and -list them all as Invariant Sections of your combined work in its -license notice, and that you preserve all their Warranty Disclaimers. - -The combined work need only contain one copy of this License, and -multiple identical Invariant Sections may be replaced with a single -copy. If there are multiple Invariant Sections with the same name but -different contents, make the title of each such section unique by -adding at the end of it, in parentheses, the name of the original -author or publisher of that section if known, or else a unique number. -Make the same adjustment to the section titles in the list of -Invariant Sections in the license notice of the combined work. - -In the combination, you must combine any sections Entitled "History" -in the various original documents, forming one section Entitled -"History"; likewise combine any sections Entitled "Acknowledgements", -and any sections Entitled "Dedications". You must delete all sections -Entitled "Endorsements". - - -6. COLLECTIONS OF DOCUMENTS - -You may make a collection consisting of the Document and other documents -released under this License, and replace the individual copies of this -License in the various documents with a single copy that is included in -the collection, provided that you follow the rules of this License for -verbatim copying of each of the documents in all other respects. - -You may extract a single document from such a collection, and distribute -it individually under this License, provided you insert a copy of this -License into the extracted document, and follow this License in all -other respects regarding verbatim copying of that document. - - -7. AGGREGATION WITH INDEPENDENT WORKS - -A compilation of the Document or its derivatives with other separate -and independent documents or works, in or on a volume of a storage or -distribution medium, is called an "aggregate" if the copyright -resulting from the compilation is not used to limit the legal rights -of the compilation's users beyond what the individual works permit. -When the Document is included in an aggregate, this License does not -apply to the other works in the aggregate which are not themselves -derivative works of the Document. - -If the Cover Text requirement of section 3 is applicable to these -copies of the Document, then if the Document is less than one half of -the entire aggregate, the Document's Cover Texts may be placed on -covers that bracket the Document within the aggregate, or the -electronic equivalent of covers if the Document is in electronic form. -Otherwise they must appear on printed covers that bracket the whole -aggregate. - - -8. TRANSLATION - -Translation is considered a kind of modification, so you may -distribute translations of the Document under the terms of section 4. -Replacing Invariant Sections with translations requires special -permission from their copyright holders, but you may include -translations of some or all Invariant Sections in addition to the -original versions of these Invariant Sections. You may include a -translation of this License, and all the license notices in the -Document, and any Warranty Disclaimers, provided that you also include -the original English version of this License and the original versions -of those notices and disclaimers. In case of a disagreement between -the translation and the original version of this License or a notice -or disclaimer, the original version will prevail. - -If a section in the Document is Entitled "Acknowledgements", -"Dedications", or "History", the requirement (section 4) to Preserve -its Title (section 1) will typically require changing the actual -title. - - -9. TERMINATION - -You may not copy, modify, sublicense, or distribute the Document except -as expressly provided for under this License. Any other attempt to -copy, modify, sublicense or distribute the Document is void, and will -automatically terminate your rights under this License. However, -parties who have received copies, or rights, from you under this -License will not have their licenses terminated so long as such -parties remain in full compliance. - - -10. FUTURE REVISIONS OF THIS LICENSE - -The Free Software Foundation may publish new, revised versions -of the GNU Free Documentation License from time to time. Such new -versions will be similar in spirit to the present version, but may -differ in detail to address new problems or concerns. See -http://www.gnu.org/copyleft/. - -Each version of the License is given a distinguishing version number. -If the Document specifies that a particular numbered version of this -License "or any later version" applies to it, you have the option of -following the terms and conditions either of that specified version or -of any later version that has been published (not as a draft) by the -Free Software Foundation. If the Document does not specify a version -number of this License, you may choose any version ever published (not -as a draft) by the Free Software Foundation. - - -ADDENDUM: How to use this License for your documents - -To use this License in a document you have written, include a copy of -the License in the document and put the following copyright and -license notices just after the title page: - - Copyright (c) YEAR YOUR NAME. - Permission is granted to copy, distribute and/or modify this document - under the terms of the GNU Free Documentation License, Version 1.2 - or any later version published by the Free Software Foundation; - with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. - A copy of the license is included in the section entitled "GNU - Free Documentation License". - -If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts, -replace the "with...Texts." line with this: - - with the Invariant Sections being LIST THEIR TITLES, with the - Front-Cover Texts being LIST, and with the Back-Cover Texts being LIST. - -If you have Invariant Sections without Cover Texts, or some other -combination of the three, merge those two alternatives to suit the -situation. - -If your document contains nontrivial examples of program code, we -recommend releasing these examples in parallel under your choice of -free software license, such as the GNU General Public License, -to permit their use in free software. diff --git a/amarok/COPYING.LIB b/amarok/COPYING.LIB deleted file mode 100644 index 2d2d780e..00000000 --- a/amarok/COPYING.LIB +++ /dev/null @@ -1,510 +0,0 @@ - - GNU LESSER GENERAL PUBLIC LICENSE - Version 2.1, February 1999 - - Copyright (C) 1991, 1999 Free Software Foundation, Inc. - 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -[This is the first released version of the Lesser GPL. It also counts - as the successor of the GNU Library Public License, version 2, hence - the version number 2.1.] - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -Licenses are intended to guarantee your freedom to share and change -free software--to make sure the software is free for all its users. - - This license, the Lesser General Public License, applies to some -specially designated software packages--typically libraries--of the -Free Software Foundation and other authors who decide to use it. You -can use it too, but we suggest you first think carefully about whether -this license or the ordinary General Public License is the better -strategy to use in any particular case, based on the explanations -below. - - When we speak of free software, we are referring to freedom of use, -not price. Our General Public Licenses are designed to make sure that -you have the freedom to distribute copies of free software (and charge -for this service if you wish); that you receive source code or can get -it if you want it; that you can change the software and use pieces of -it in new free programs; and that you are informed that you can do -these things. - - To protect your rights, we need to make restrictions that forbid -distributors to deny you these rights or to ask you to surrender these -rights. These restrictions translate to certain responsibilities for -you if you distribute copies of the library or if you modify it. - - For example, if you distribute copies of the library, whether gratis -or for a fee, you must give the recipients all the rights that we gave -you. You must make sure that they, too, receive or can get the source -code. If you link other code with the library, you must provide -complete object files to the recipients, so that they can relink them -with the library after making changes to the library and recompiling -it. And you must show them these terms so they know their rights. - - We protect your rights with a two-step method: (1) we copyright the -library, and (2) we offer you this license, which gives you legal -permission to copy, distribute and/or modify the library. - - To protect each distributor, we want to make it very clear that -there is no warranty for the free library. Also, if the library is -modified by someone else and passed on, the recipients should know -that what they have is not the original version, so that the original -author's reputation will not be affected by problems that might be -introduced by others. - - Finally, software patents pose a constant threat to the existence of -any free program. We wish to make sure that a company cannot -effectively restrict the users of a free program by obtaining a -restrictive license from a patent holder. Therefore, we insist that -any patent license obtained for a version of the library must be -consistent with the full freedom of use specified in this license. - - Most GNU software, including some libraries, is covered by the -ordinary GNU General Public License. This license, the GNU Lesser -General Public License, applies to certain designated libraries, and -is quite different from the ordinary General Public License. We use -this license for certain libraries in order to permit linking those -libraries into non-free programs. - - When a program is linked with a library, whether statically or using -a shared library, the combination of the two is legally speaking a -combined work, a derivative of the original library. The ordinary -General Public License therefore permits such linking only if the -entire combination fits its criteria of freedom. The Lesser General -Public License permits more lax criteria for linking other code with -the library. - - We call this license the "Lesser" General Public License because it -does Less to protect the user's freedom than the ordinary General -Public License. It also provides other free software developers Less -of an advantage over competing non-free programs. These disadvantages -are the reason we use the ordinary General Public License for many -libraries. However, the Lesser license provides advantages in certain -special circumstances. - - For example, on rare occasions, there may be a special need to -encourage the widest possible use of a certain library, so that it -becomes a de-facto standard. To achieve this, non-free programs must -be allowed to use the library. A more frequent case is that a free -library does the same job as widely used non-free libraries. In this -case, there is little to gain by limiting the free library to free -software only, so we use the Lesser General Public License. - - In other cases, permission to use a particular library in non-free -programs enables a greater number of people to use a large body of -free software. For example, permission to use the GNU C Library in -non-free programs enables many more people to use the whole GNU -operating system, as well as its variant, the GNU/Linux operating -system. - - Although the Lesser General Public License is Less protective of the -users' freedom, it does ensure that the user of a program that is -linked with the Library has the freedom and the wherewithal to run -that program using a modified version of the Library. - - The precise terms and conditions for copying, distribution and -modification follow. Pay close attention to the difference between a -"work based on the library" and a "work that uses the library". The -former contains code derived from the library, whereas the latter must -be combined with the library in order to run. - - GNU LESSER GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any software library or other -program which contains a notice placed by the copyright holder or -other authorized party saying it may be distributed under the terms of -this Lesser General Public License (also called "this License"). -Each licensee is addressed as "you". - - A "library" means a collection of software functions and/or data -prepared so as to be conveniently linked with application programs -(which use some of those functions and data) to form executables. - - The "Library", below, refers to any such software library or work -which has been distributed under these terms. A "work based on the -Library" means either the Library or any derivative work under -copyright law: that is to say, a work containing the Library or a -portion of it, either verbatim or with modifications and/or translated -straightforwardly into another language. (Hereinafter, translation is -included without limitation in the term "modification".) - - "Source code" for a work means the preferred form of the work for -making modifications to it. For a library, complete source code means -all the source code for all modules it contains, plus any associated -interface definition files, plus the scripts used to control -compilation and installation of the library. - - Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running a program using the Library is not restricted, and output from -such a program is covered only if its contents constitute a work based -on the Library (independent of the use of the Library in a tool for -writing it). Whether that is true depends on what the Library does -and what the program that uses the Library does. - - 1. You may copy and distribute verbatim copies of the Library's -complete source code as you receive it, in any medium, provided that -you conspicuously and appropriately publish on each copy an -appropriate copyright notice and disclaimer of warranty; keep intact -all the notices that refer to this License and to the absence of any -warranty; and distribute a copy of this License along with the -Library. - - You may charge a fee for the physical act of transferring a copy, -and you may at your option offer warranty protection in exchange for a -fee. - - 2. You may modify your copy or copies of the Library or any portion -of it, thus forming a work based on the Library, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices - stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no - charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a - table of data to be supplied by an application program that uses - the facility, other than as an argument passed when the facility - is invoked, then you must make a good faith effort to ensure that, - in the event an application does not supply such function or - table, the facility still operates, and performs whatever part of - its purpose remains meaningful. - - (For example, a function in a library to compute square roots has - a purpose that is entirely well-defined independent of the - application. Therefore, Subsection 2d requires that any - application-supplied function or table used by this function must - be optional: if the application does not supply it, the square - root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Library, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Library, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote -it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Library. - -In addition, mere aggregation of another work not based on the Library -with the Library (or with a work based on the Library) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may opt to apply the terms of the ordinary GNU General Public -License instead of this License to a given copy of the Library. To do -this, you must alter all the notices that refer to this License, so -that they refer to the ordinary GNU General Public License, version 2, -instead of to this License. (If a newer version than version 2 of the -ordinary GNU General Public License has appeared, then you can specify -that version instead if you wish.) Do not make any other change in -these notices. - - Once this change is made in a given copy, it is irreversible for -that copy, so the ordinary GNU General Public License applies to all -subsequent copies and derivative works made from that copy. - - This option is useful when you wish to copy part of the code of -the Library into a program that is not a library. - - 4. You may copy and distribute the Library (or a portion or -derivative of it, under Section 2) in object code or executable form -under the terms of Sections 1 and 2 above provided that you accompany -it with the complete corresponding machine-readable source code, which -must be distributed under the terms of Sections 1 and 2 above on a -medium customarily used for software interchange. - - If distribution of object code is made by offering access to copy -from a designated place, then offering equivalent access to copy the -source code from the same place satisfies the requirement to -distribute the source code, even though third parties are not -compelled to copy the source along with the object code. - - 5. A program that contains no derivative of any portion of the -Library, but is designed to work with the Library by being compiled or -linked with it, is called a "work that uses the Library". Such a -work, in isolation, is not a derivative work of the Library, and -therefore falls outside the scope of this License. - - However, linking a "work that uses the Library" with the Library -creates an executable that is a derivative of the Library (because it -contains portions of the Library), rather than a "work that uses the -library". The executable is therefore covered by this License. -Section 6 states terms for distribution of such executables. - - When a "work that uses the Library" uses material from a header file -that is part of the Library, the object code for the work may be a -derivative work of the Library even though the source code is not. -Whether this is true is especially significant if the work can be -linked without the Library, or if the work is itself a library. The -threshold for this to be true is not precisely defined by law. - - If such an object file uses only numerical parameters, data -structure layouts and accessors, and small macros and small inline -functions (ten lines or less in length), then the use of the object -file is unrestricted, regardless of whether it is legally a derivative -work. (Executables containing this object code plus portions of the -Library will still fall under Section 6.) - - Otherwise, if the work is a derivative of the Library, you may -distribute the object code for the work under the terms of Section 6. -Any executables containing that work also fall under Section 6, -whether or not they are linked directly with the Library itself. - - 6. As an exception to the Sections above, you may also combine or -link a "work that uses the Library" with the Library to produce a -work containing portions of the Library, and distribute that work -under terms of your choice, provided that the terms permit -modification of the work for the customer's own use and reverse -engineering for debugging such modifications. - - You must give prominent notice with each copy of the work that the -Library is used in it and that the Library and its use are covered by -this License. You must supply a copy of this License. If the work -during execution displays copyright notices, you must include the -copyright notice for the Library among them, as well as a reference -directing the user to the copy of this License. Also, you must do one -of these things: - - a) Accompany the work with the complete corresponding - machine-readable source code for the Library including whatever - changes were used in the work (which must be distributed under - Sections 1 and 2 above); and, if the work is an executable linked - with the Library, with the complete machine-readable "work that - uses the Library", as object code and/or source code, so that the - user can modify the Library and then relink to produce a modified - executable containing the modified Library. (It is understood - that the user who changes the contents of definitions files in the - Library will not necessarily be able to recompile the application - to use the modified definitions.) - - b) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (1) uses at run time a - copy of the library already present on the user's computer system, - rather than copying library functions into the executable, and (2) - will operate properly with a modified version of the library, if - the user installs one, as long as the modified version is - interface-compatible with the version that the work was made with. - - c) Accompany the work with a written offer, valid for at least - three years, to give the same user the materials specified in - Subsection 6a, above, for a charge no more than the cost of - performing this distribution. - - d) If distribution of the work is made by offering access to copy - from a designated place, offer equivalent access to copy the above - specified materials from the same place. - - e) Verify that the user has already received a copy of these - materials or that you have already sent this user a copy. - - For an executable, the required form of the "work that uses the -Library" must include any data and utility programs needed for -reproducing the executable from it. However, as a special exception, -the materials to be distributed need not include anything that is -normally distributed (in either source or binary form) with the major -components (compiler, kernel, and so on) of the operating system on -which the executable runs, unless that component itself accompanies -the executable. - - It may happen that this requirement contradicts the license -restrictions of other proprietary libraries that do not normally -accompany the operating system. Such a contradiction means you cannot -use both them and the Library together in an executable that you -distribute. - - 7. You may place library facilities that are a work based on the -Library side-by-side in a single library together with other library -facilities not covered by this License, and distribute such a combined -library, provided that the separate distribution of the work based on -the Library and of the other library facilities is otherwise -permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work - based on the Library, uncombined with any other library - facilities. This must be distributed under the terms of the - Sections above. - - b) Give prominent notice with the combined library of the fact - that part of it is a work based on the Library, and explaining - where to find the accompanying uncombined form of the same work. - - 8. You may not copy, modify, sublicense, link with, or distribute -the Library except as expressly provided under this License. Any -attempt otherwise to copy, modify, sublicense, link with, or -distribute the Library is void, and will automatically terminate your -rights under this License. However, parties who have received copies, -or rights, from you under this License will not have their licenses -terminated so long as such parties remain in full compliance. - - 9. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Library or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Library (or any work based on the -Library), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Library or works based on it. - - 10. Each time you redistribute the Library (or any work based on the -Library), the recipient automatically receives a license from the -original licensor to copy, distribute, link with or modify the Library -subject to these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties with -this License. - - 11. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Library at all. For example, if a patent -license would not permit royalty-free redistribution of the Library by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply, and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 12. If the distribution and/or use of the Library is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library under this License -may add an explicit geographical distribution limitation excluding those -countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 13. The Free Software Foundation may publish revised and/or new -versions of the Lesser General Public License from time to time. -Such new versions will be similar in spirit to the present version, -but may differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Library -specifies a version number of this License which applies to it and -"any later version", you have the option of following the terms and -conditions either of that version or of any later version published by -the Free Software Foundation. If the Library does not specify a -license version number, you may choose any version ever published by -the Free Software Foundation. - - 14. If you wish to incorporate parts of the Library into other free -programs whose distribution conditions are incompatible with these, -write to the author to ask for permission. For software which is -copyrighted by the Free Software Foundation, write to the Free -Software Foundation; we sometimes make exceptions for this. Our -decision will be guided by the two goals of preserving the free status -of all derivatives of our free software and of promoting the sharing -and reuse of software generally. - - NO WARRANTY - - 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR -OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY -KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE -LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN -WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY -AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU -FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR -CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE -LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING -RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A -FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Libraries - - If you develop a new library, and you want it to be of the greatest -possible use to the public, we recommend making it free software that -everyone can redistribute and change. You can do so by permitting -redistribution under these terms (or, alternatively, under the terms -of the ordinary General Public License). - - To apply these terms, attach the following notices to the library. -It is safest to attach them to the start of each source file to most -effectively convey the exclusion of warranty; and each file should -have at least the "copyright" line and a pointer to where the full -notice is found. - - - - Copyright (C) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -Also add information on how to contact you by electronic and paper mail. - -You should also get your employer (if you work as a programmer) or -your school, if any, to sign a "copyright disclaimer" for the library, -if necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the - library `Frob' (a library for tweaking knobs) written by James - Random Hacker. - - , 1 April 1990 - Ty Coon, President of Vice - -That's all there is to it! - - diff --git a/amarok/CTestConfig.cmake b/amarok/CTestConfig.cmake deleted file mode 100644 index 9272f7a3..00000000 --- a/amarok/CTestConfig.cmake +++ /dev/null @@ -1,8 +0,0 @@ -set(CTEST_PROJECT_NAME "Amarok") -set(CTEST_NIGHTLY_START_TIME "00:00:00 EST") - -set(CTEST_DROP_METHOD "http") -set(CTEST_DROP_SITE "my.cdash.org") -set(CTEST_DROP_LOCATION "/submit.php?project=Amarok") -set(CTEST_DROP_SITE_CDASH TRUE) - diff --git a/amarok/ChangeLog b/amarok/ChangeLog deleted file mode 100644 index f1ff7ba1..00000000 --- a/amarok/ChangeLog +++ /dev/null @@ -1,5912 +0,0 @@ -Amarok ChangeLog -================ -(C) 2002-2014 the Amarok authors. - - -VERSION 2.8.1 - FEATURES: - * Database configuration dialog now has a "test connection" button. - * Add Service entries for directories. (BR 229708) - * Collection Browser scrolls back to its original position when the filter is cleared. - (BR 188074) - * Notification Center support on Mac OS X. - * Statistics synchronization between Amarok collections and - Amarok 1.4, Amarok 2.x, Apple iTunes, Banshee, Clementine, and - Rhythmbox track databases. - * Usability of the Organize Files dialog has been improved. - * Wikipedia can now be also used over SSL. - * New ASCII Analyzer option in the Analyzer widget. Patch provided by Matej Repinc - - CHANGES: - * "Import" button under Configure Amarok -> Local Collection no longer - serves to import statistics from Amarok 1.4 and iTunes, and has been - renamed to "Import batch file" to reflect the change. - * Configure Amarok -> Metadata tab includes new buttons to add and - reconfigure synchronization targets. - * When ffmpeg is not available, the Transcode dialog is no longer skipped; info message - is shown instead. Patch by Jai Luthra. (BR 317902) - * Amarok now uses some C++11 features. The subset used is defined by the - compilers currently supported by KDE. - - BUGFIXES: - * Fix a crash when searching the Icecast directory. (BR 334479) - * Correct wrong lowercase for FLAC and MP3. Patch provided by Duilio Felix (BR 339495) - * Collection Browser no longer excessively expands the tree. (BR 300557) - * Properly calculate and store Aft tags in mp4 files. Patch By Stefano - Pettini (BR 332811) - * Update Progress Slider when restoring from System Tray. Patch By Abhay - Sombanshi (BR 299883) - * Update Jamendo to use new website. Patch By Yash Ladia - (BR 331934) - * Allows CollectionBrowser filter to have length of almost 24 hours. (BR 291400) - * Prevent creation of video stream when transcoding to Opus. Patch by Martin Brodbeck. - * Fix crash when starting Amarok with an iPod mounted. (BR 329498) - * Also fetch cover art from xiph-comments with METADATA_BLOCK_PICTURE tag. - Patch by Martin Brodbeck . (BR 328451) - * Fix crash on quit when Amarok is in the middle of fadeout. (BR 325723) - * Prevent shared memory size errors for very large collections. (BR 327812) - * Fix OpenGL related crash. (BR 327150) - * Always show preview in Organize Files dialog, hide complicated options behind - a button. (BR 327201) - * Fix sound glitch with fade-out on pause and GStreamer. (BR 323729) - * Fix a bug in Organize Collection functionality that could lead to assertion failures - later on. (BR 322474) - * Fix an assertion failure when a track in Local Collection is replaced by another - already tracked one. (BR 323156) - * Fix failure to start embedded MySQL (with version 5.1 and MariaDB). (BR 323802) - * Fixed compilation with libc++ (used on OSX and FreeBSD). (BR 324075) - * Fixed crashes with Intel drivers due to Analyzer applet. (BR 323635) - * Fixed performance problem with large podcast feeds. - Patch by Frank Meerkoetter . (BR 283022) - * Fixed issue with Amarok sometimes not finding its plugins after an upgrade. - * Album Artist / Compilation / Disc Number tags are now read correctly - from APE tags. Patch by Bruno Léon . (BR 323735) - * Using Shuffle keyboard shortcut no longer causes Amarok to crash. - (BR 323614) - * Check for QtBindings at runtime instead. Disable scripts and display error message - if missing. (BR 325006) - * Print playlist download errors to the debug log. (BR 325120) - - -VERSION 2.8 - FEATURES: - * Tracks from Recently Played List widget can now directly be added to the - playlist. (BR 279263, BR 296090) - - CHANGES: - * The Jamendo service now uses a higher quality MP3 format instead of Ogg Vorbis. - * Added an option whether adding tracks to playlist should start playing. (BR 322428) - * Amarok now depends on Qt 4.8.3. - * Amarok now uses FindFFMpeg.cmake from kdelibs - - BUGFIXES: - * Don't reload Wikipedia applet content if artist/album have not changed. - Patch by Frank Meerkoetter . (BR 112044) - * Jamendo service: Albums are now downloaded directly instead of going via - BitTorrent. This is far more reliable and also supports on-the-fly transcoding. - (BR 299434) - * Work-around Solid UDisks2 backend bug that caused USB Mass Storage devices and iPods - not being recognized when connected before Amarok was started. Also fixes a bug where - blank devices would appear in Play Media dialog. (BR 322980) - * Definitely fix a bug where storing Last.fm credentials in plain-text isn't offered - when KWallet is disabled. (BR 315306) - * Radio streams from scripted services are now instantly playable. (BR 320718) - * Recently Played List widget now keeps its own time for tracks instead of relying on - the Last Played statistic. (BR 302485) - * Prevent hitting an assertion failure if just removed track from the Local Collection - is edited. (BR 322474) - * Fixed a regression introduced in 2.8 Beta where tracks in the Local Collection were - sometimes forgotten and then found again. (BR 322603) - * Fixed invalid SQL queries when you have files or folders with an apostrophe in - your collection. (BR 322415) - * Fixed organizing/copying/moving tracks to Local Collection on Windows. (BR 279560, - BR 302251) - * Various usability improvements for the applet toolbar. (BR 197948) - * Removed broken Apply button in applets' settings dialog. (BR 322015) - * Fix incorrect colors in Context View toolbar when switching themes. (BR 301305) - * Many fixes for various bugs with switching desktop color themes at runtime, - including OSD, spectrum analyzer, collection browser. - * Avoid updating the MPRIS2 Metadata between tracks. (BR 321602) - - -VERSION 2.8-Beta 1 - FEATURES: - * Ctrl+C copies the currently playing artist & title to the clipboard. (BR 228872) - Patch by fleissig fleissig . - * Volume fade-out is now also available for pause. - * The Files browser now has a Refresh button. (BR 213666) - * The active playlist item is animated with a soft glow effect. - * Added an audio analyzer visualization applet. - * Added a function for resetting the GUI layout back to default state. (BR 300753) - * Pressing enter when searching collections now adds found tracks to the playlist and - clears the search bar, this is a very convenient way to populate your playlist. - * Allow to transcode only certain (different format, playability) tracks when - transferring them to a collection; patch by Anmol Ahuja. (BR 312407) - * On-Screen-Display fades in/out smoothly. - * Added support for .asx playlists; patch by Tatjana Gornak. (BR 170207) - * Add Radio GFM radio streams to Cool Stream Script. (BR 317978) - * Added options to pause playback on system suspend and to inhibit automatic suspend - if playing a track (enabled by default); patch by Anmol Ahuja. - (BR 259862) (BR 222571) - * Playlist files are now read asynchronously when possible; patch and great deal of - refactoring by Tatjana Gornak. (BR 291934) - * Added support to filter tracks to scrobble to Last.fm by label. Patch by Vedant - Agarwala. (BR 140198) - * Added transcoding support for Opus codec if ffmpeg is compiled with support for the - libopus library, patch by Martin Brodbeck. - * Added keyboard shortcuts for small 2 s seeks (Ctrl + Left/Right) and long 1 minute - seeks (Shift + Left/Right) in addition to standard 10 s seeks. Durations are now - configurable in amarokrc, see Amarok Handbook. Patch by Anmol Ahuja. (BR 177258) - * Added support for files in Opus codec if Amarok is compiled against recent enough - TagLib (post 1.8), patch by Martin Brodbeck. (BR 312905) - * Added Ctrl+H shortcut to randomize playlist, patch by Harsh Gupta. (BR 208061) - - CHANGES: - * Removed LikeBack (a development feature in debug builds). (BR 312498) (BR 252323) - * Collection Browser: Artist level was renamed to Track Artist and replaced by Album - Artist by default. Various Artists item is no longer shown under Track Artist level. - * Removed the splash screen. - * Playlist-related actions were harmonized, double-clicking or pressing enter will - append tracks to playlist, using any "play media" action or middle-clicking will - prepend tracks to queue and immediately start playing. (BR 145468, BR 145490, - BR 194549) - * When a new collection plugin is enabled, its collections appear immediately without a - need for restart. - * Update the MusicBrainz tagger to MusicBrainz web service 2, make it show some more - good suggestions for tagging, and add some options to help choosing the best results. - * Add note about generating .mood files into Moodbar Options; patch by Harsh Gupta with - tweaks by Matěj Laitl. (BR 289483) - * Amarok now depends on Qt 4.8.2. - * Add prepareToQuit() signal to Amarok.Window script bindings; patch by Anmol Ahuja. - (BR 241066) - * Data CDs are now recognized in Amarok; patch by Anmol Ahuja. (BR 316128) - * On-Screen-Display now uses the system font instead of hardcoded sans-serif. - (BR 248707) - * Fancy behavior of some context menus showing different actions when Shift key is held - has been reverted. All entries are now shown all the time. - * The dynamic playlist behavior has changed. It will no longer generate "pretty good" - playlists that do not fulfill the given biases. Instead it might add no song at all - if given impossible-to-fulfill conditions. - * The "tracks have been hidden in the playlist" warning when filtering the playlist is - now displayed inside the playlist. (BR 260352) - * Update tag widget for Layout edit, filter edit, organize collection and guess tag - dialog. - * When fadeout and/or Replay Gain isn't possible, gray-out related UI elements in order - not to fool users. - - BUGFIXES: - * When you remove whole directories from the Local Collection and have Watch Folders - for Changes enabled, the tracks now disappear from Collection Browser. (BR 311078) - * Fix dynamic playlist bug: When "Automatically scroll playlist to current track" - was enabled, Amarok would keep scrolling to the bottom. (BR 284214) - * Fix a problem where ghost tracks would remain in the Local Collection until the - database is wiped. (BR 319084) - * Added missing CMake check for QtWebKit. (BR 321598) - * Definitely fix a bug where Local Collection wouldn't update in browser. (BR 262504) - * Fix crashed caused by race conditions at the end of the track scanning. (BR 319835) - * Fix crash when disabling the Free Music Charts script. (BR 321329) - * Albums having same name but different album artist won't be mixed together on the - playlist if sorting by album is enabled. - * Fix crash on startup with KDE 4.11. Patch by Hrvoje Senjan - . (BR 320855) - * Fix tracks not able to be dragged around when playlist is shuffled. (BR 320129) - * Prevent Last.fm scrobbles not being submitted until restart due to change in - liblastfm 1.0.7. (BR 320219) - * Resume Playback on Start will correctly restore paused state, instead - of always starting in playing state. (BR 313330) - * Optimize removal of tens of thousands of tracks from playlist. (BR 316242) - * Fix `amarok --queue` which didn't actually queue the tracks. (BR 317385) - * Fix suboptimal initial MusicBrainz tag dialog size by remembering it. (BR 269454) - * Fix file-browser becoming empty when a file was moved to trash. (BR 317944) - * Fix `amarok --play file.mp3` option didn't actually start playback. - * Reason why a particular track is not playable is now shown in playlist tooltip; patch - by Anmol Ahuja. (BR 313649) - * Pre-apmlifier in equalizer is now only enabled if it is actually supported; patch by - Harsh Gupta. (BR 301311) - * Fix Amarok crashed while doing "Organize Files" (BR 317980) - * Fix Amarok erroneously merges two albums. (BR 216759, BR 272802) - * Fix Crash on very long artist names. (BR 276894) - * Fix Move tracks to rubbish and the current track cover changes to the deleted cover. (BR 306735) - * Fix theoretical configwidget leak in services. (BR 301352) - * Fix "Local collection" text label is truncated with large font. (BR 282561) - * Fix crash by putting a broadcast in the playlist. (BR 313718) - * Fix Keyboard navigates context menu in collection will move two items. (BR 307794) - * Fix add track to playlist by double click on arrow in the collection. (BR 279513) - * Fix VFAT safe names missing a couple of idiosyncrasies. (BR 312574) - * Clarify message when Last.fm streams are not available. (BR 315771) - * Fix crash when Dynamic Playlist based on last.fm is aborted. (BR 314243) - * Fix Group by directory doesn't work in main playlist. (BR 265415) - * Don't remove common labels when editing the tags of multiple tracks. (BR 316043) - * Fix vertical positioning of On-Screen-Display. (BR 269788) - * Fix OSD sometimes misplaces the font and the font's shadow. (BR 257643) - * Prevent inability to save Last.fm password in corner cases. (BR 315306) - * Fix "Copy to Collection" window doesn't fit on small screens. (BR 283361) - * Fix crash when quitting Amarok with Statistics Synchronization open. (BR 315525) - * Fix items moving around when expanded in collection browser. (BR 305602) - * Fix Organize collection folder deletion going 'too far'. (BR 314348) - * Fix %albumartist% placeholder translates to some strange unicode symbol. (BR 314351) - * Fix bumpy fade-out when first used. (BR 312062) - * Fix crash when switching/removing organize collection presets. (BR 314344) - * Fix crash on start if a playlist source is unavailable. (BR 313460) - * Fix Copy/Move to collection picks up wrong destination path and fails silently. (BR 314460) - * Cleanup TrackOrganizer. (BR 305291) - * Fix Editing Playist Layout Editor. (BR 250594) - * Fix Display glitch for rating in verbose playlist. (BR 300118) - * Refactoring Ampache service, fix Albums with multiple disks not listed correctly. (BR 249857) - * Fix playlist sorting by type. (BR 249338) - * Fix subtle bugs when a long fade-out is initiated near the song end. - * Don't try to fade-out with phonon backends that don't support it. (vlc) - * Fix Can't edit & save an existing equalizer preset. (BR 241874) - * Clean up Equalizer Dialog. (BR 274972) - - -VERSION 2.7.1 - CHANGES: - * Problematic support for treating MusicBrainz ids as track unique ids was dropped; - should avoid surprising "Duplicate Tracks Found" errors. (BR 315329) - - BUGFIXES: - * Fix inability to reverse "Use Music Location" decision and inability to clear - database once all collection directories have been unset. (BR 316216) - * Fix frequent crashes on Linux when starting to play a track. (BR 319371) - * Fix compilation error on systems with gcc-4.2 (BR 314528) - * Fix inability to create database when home directory contains non-ASCII characters. - (BR 313914) - * Fix typo in Nepomuk query which did not let track numbers of Nepomuk Collection - tracks show up in Amarok. (BR 311847) - - -VERSION 2.7 - CHANGES: - * Files page has been made more intuitive by making Places the root view - and significantly improving breadcrumbs behaviour. - * Make dropping large directories into playlist more responsive by reading - track metadata asynchronously in a background thread. - * Harmonize keyboard, mouse and context menu behaviour of the Files pane - so that it matches Local Music and Saved Playlists panes. (BR 307386) - * Last.fm Skip button re-added after being removed in Beta by error. (BR 311733) - * Podcast episodes are now loaded asynchronously on startup to reduce delays. - * Removed alpha state and not really working spectrum analyzer applet. - - BUGFIXES: - * Fix a regression where stream metadata would be forgotten on start. (BR 305389) - * Fix scrobbling of plain files streamed over http. (BR 309976) - * Fix scrobble-before-play behaviour when playing Last.fm streams. - * Fix double-scrobbling when playing Last.fm streams. (BR 311852) - * Fix The size of rating stars should not change in inline editing (BR 209684) - * Various improvements that should result in more stable Audio CD playback - (modulo phonon-vlc BR 313046). (BR 305708, BR 308084, BR 311446) - * Fix queued track indicator overflow, patch by Riccardo Ferrazzo. (BR 253802) - * Fix Amarok crashes when selecting song with Enter [@ Playlist::PrettyListView::trackActivate] (BR 312439) - * Fix amarok starts at beginning of playlist if you previously stopped during a track (BR 312183) - * Audio CD: fix crash due to no composer being set. (BR 293698) - * Audio CD: fix track recreation on startup. (BR 312685) - * Fix incorrect display of folder names containing & (ampersand) in File - browser breadcrumbs. (BR 244817) - * Fix Media Sources pane growing in size when navigating in it. (BR 246029) - * Fix Media Sources breadcrumb items sometimes appearing as new windows. (BR 285712) - * Fix editability and drop-ability of playlist folders. - * Make track announcements via KDE Notifications instant. (BR 263952) - * Fix dynamic playlist progress bar. - * Fix Last played bias is ignored or doesn't work. (BR 311906) - * Fix amarok dynamic play list with biases EchoNest similar artist gives no - results. (BR 291162) - * Fix When I try to create a dynamic playlist by Last.fm similar songs - creation takes a lot time. (BR 301716) - * Fix updating of Amarok database playlists then track uid changes. (BR 312128) - * Fix hangs and inappropriate messages when trying to play a track from - a saved playlist that has been deleted in the mean time. (BR 308371) - * Fix existing files preventing complete transfer of tracks to collection. (BR 312001) - * Fix crash then doing Last.fm love with uninitialized Last.fm plugin. (BR 311857) - * Fix Last.fm streams not being correctly recreated on startup. (BR 305576) - * Fix Ampache albums & track not being shown, a recent regression. (BR 310862) - * Fix crash in Network Requests Viewer. (BR 311760) - * Definitely prevent crash when using File Browser breadcrumbs. (BR 265626) - * Prevent crash in ServiceBase::setModel triggered by Last.fm rewrite. (BR 311723) - * Fix incorrect display of Last.fm tags and other items. (BR 244555) - -VERSION 2.7-Beta 1 - FEATURES: - * Track dragging support in Unique Tracks tab of the Synchronize Statistics action; - allows you to do a "diff" between collections and transfer missing tracks. (BR 237266) - * Amarok now scrobbles tracks in streams if the stream correctly updates - meta-data. (BR 240732) - * When scrobbling to Last.fm, Amarok announces suggested tag corrections - (configurable). (BR 309697) - * Ability to scrobble recently played tracks from iPod (and the like) to Last.fm. - * Synchronization of labels and rating between Last.fm and Amarok collections; - play count can be synchronized one-way from Last.fm to Amarok. (BR 206249) - * Statistics synchronization between collections, supports rating, first / last - played time, play count and labels. - * New APG constraint: Specify a total file size for playlist. (BR 283618) - * Amazon store: Added support for Amazon MP3 in Italy and Spain. (BR 307981) - * Mark downloaded podcast episodes to keep, even when purge is enabled. (BR 261062) - * Nepomuk plugin: Play and manage tracks using the Nepomuk database. - * Support for reading and writing tags from/to mod, s3m, it and xm files. - Patch by Mathias Panzenböck. - * Amazon store: It is now possible to add items to your shopping cart using amarok:// URLs. - * Amazon store: Use the context info applet to show further infos about a selected item. - * New argument --debug-audio to enable Phonon debugging. - * Amazon store: We now ship a utility to handle downloads from Amazon. - - CHANGES: - * Dependencies raised, Amarok now depends on Qt >= 4.8 and kdelibs >= 4.8.4. - * When configuring Last.fm plug-in, the changes are now applied immediately - in most places. (BR 311331) - * If liblastfm is provided, it is strongly recommended to use version 1.0.3 or newer - for fixes of bugs that otherwise prevent iPod scrobbling and synchronization. - * Configure Amarok dialog gets new Metadata tab to grab some weight from the - Collection tab and to configure statistics synchronization. - * APG now saves its presets each time it's run, to lessen preset loss if - Amarok crashes. (BR 294743) - * APG playlists no longer limited to 100 tracks. (BR 301829) - * The confusing "Local Collection Backends" category of plugins was removed - from the Configure dialog. All backends are enabled from now on. - * Statistics of tracks outside of collections are only read/saved to file - tags (if enabled) instead of being kept in the database. - * Last.fm Skip button removed; Last.fm API no longer provides it. (BR 305576) - * Optional liblastfm dependency raised to 1.0.0. (BR 302597) - * Add composer button to wikipedia applet (BR 272982) - * New optional dependency for Amazon downloads: clamz. - - BUGFIXES: - * Fix empty collection when using DynamicCollection=false (BR 265419) - * Fix suboptimal KWallet usage in Last.fm plugin. (BR 292096) - * Fix crash in Last.fm plugin caused by sloppy KWallet usage. (BR 306134) - * Fix WMA files interpret Album as Album Artist (BR 276015) - * Fix after adding next slash previous one disappears in organize collection (BR 296136) - * Fix Dynamic Collection and other features not working if the database was - initially created by a very old Amaork version. (BR 302837) - * Fix incorrect "Stop after current" indicator behaviour in some cases. (BR 253822) - * Fix untranslatable texts in preset dynamic playlists. (BR 276023) - * Better Last.fm scrobbling behaviour and error reporting due to rewrite, - should fix long-standing problems. (BR 293320, BR 285820) - * Update stream meta-data correctly even with phonon-gstreamer back-end. (BR 300189) - * Fix available transcoding encoders detection with ffmpeg 1.0. (BR 309454) - * Fix playback resuming with phonon-gstreamer; raise phonon-vlc dependency - to at least 0.6.1 as a side-effect. (BR 290612) - * Create collections even for SD/MMC/etc. cards on PCI-connected slots. - * Fixed some incorrect logic in the PlaylistLength constraint, which was - causing the APG to create playlists that were shorter than expected. - (BR 293616) - * Improve Duplicate files found dialog. (BR 308762) - * Fix crashes in SqlRegistry because of its false thread-safety. (BR 230991) - * Fix crash on malformed DAAP reply. (BR 284186) - * Fix first & last played time not remembered for files outside of collection. - * Nepomuk plugin now makes Nepomuk ratings visible in Amarok. (BR 174630) - * Fix some track tag modifications not being updated until restart - (e.g. changing disc number from 1 to 0). - * Repeat playlist correctly with a single track playlist. (BR 290955) - * Don't append playlist when pressing enter while editing. (BR 305203) - * Fix track transfer to iPods in de (and perhaps other) locale. (BR 305134) - -VERSION 2.6 - BUGFIXES: - * Fix problems when sql server is not reachable (BR 298425) - * Fix crash with exporting playlists with invalid tracks (BR 303056, BR 302607, BR 297816) - -VERSION 2.6-RC - CHANGES: - * Show all audio and video files in file browser. (BR 303253) - * Remove codec install support. It's long ago been implemented in phonon. - * Prevent lags with large Saved playlists. (BR 301700) - * Increase minimal required ffmpeg version up to 0.7. - * Use audio-x-generic icon for bit rate, not a generic one. (BR 302753) - * Add Amarok.Playlist.playMediaList() script bindings for API symmetry. - * Building the spectrum analyzer applet can now be disabled with a CMake - argument. - - BUGFIXES: - * Fix a regression where play count would be increased by 2. (BR 299890) - * Don't loose statistics, labels and lyrics upon collection scan in some - circumstances, e.g. when disk holding colleciton is swapped. (BR 298275) - * Don't loose statistics, labels and lyrics when changing metadata of a - track (not tagged by afttagger) followed by moving it. (BR 292245) - * Fix Amarok.Playlist.{add,play}Media() and addMediaList() Qt script - bindings methods not being able to add playlists. (BR 232697) - * Add "Last Played" back to the Edit Filter dialog. (BR 302746) - * Correct rounding for rating in Track Details dialog. (BR 273363) - * Fix Context view not being fully formed on startup. (BR 292895) - * Fix memory leaks and a string zero termination issue in MP3tunes. - * Don't poll for mounts every second, solid notifies us. (BR 289462) - * Fix inconsistent Last.fm scrobbling in some cases with GStreamer - backend. - * Use colors from KDE style in Dynamic Playlist strip. (BR 301303) - * Finally fix crash on startup in addCollapseAnimation. (BR 258741) - * Don't hit "too many open files" when copying covers to iPod. (BR 301207) - * Don't crash if iPod's eject button is hit twice. (BR 301208) - * Don't crash even if the iPod is connected and quickly ejected. (BR 301166) - * Play the correct track when adding tracks to a sorted playlist. (BR 244595) - * Provide full-size covers via MPRIS1 if available. (BR 278550) - * Fix serving out of embedded images via MPRIS. (BR 301399) - -VERSION 2.6-Beta 1 - FEATURES: - * Amazon store: improved album search - * Support for transcoding when copying tracks to USB Mass Storage devices; - per-device transcoding preference can be saved, too. - * Provide Repopulate and Turn off link in "Dynamic Mode Enabled" bagde. - * Support for setting cover images for albums on USB Mass Storage devices. - * Support for setting and unsetting cover images for iPod albums, can - write back covers to file meta-data too, respects configuration. - * Amazon store: ability to check out an item directly without using the Amarok - shopping cart. (BR 288808) - * Amarok now includes the Free Music Charts service by default. - * The maximum dimensions for embedded covers are now configurable. (BR 279493) - * Small configuration dialog for iPods that shows troubleshooting information - and allows to change iPod name. - * Improved usability of iPod playlists: iPod collection automatically transfers - tracks dropped to iPod playlists to iPod when it is needed. - * Tracks can now be transcoded when transferring them to iPod. (BR 291722) - * A diagnostic dialog reporting versions of Amarok, Qt, KDE and phonon libraries - as well as the used phonon backend and status of plugins and scripts. - Patch by Andrzej Hunt. - * Ability to move track position bookmarks by dragging; patch by - Jasneet Bhatti. (BR 214721) - * Amarok can now remember whether and how to transcode tracks when - transferring them to a particular collection. (BR 264681) - * "Crop playlist" functionality implemented using drag & drop. (BR 267729, 211811) - * Added keyboard shortcut for "Edit Track Information..." (BR 173814) - Patch by Jasneet Bhatti. - * Support for embedded album covers in non-collection tracks and - in USB Mass Storage collection. - * Hold the Shift key when dragging tracks to collections to move them - instead of copying. - * New search filter for absolute date - * Named UMS collections - * Albums with same name but different album artist are now correctly - separated in USB Mass Storage, iPod and various online service collections. - * Support for detecting compilations in USB Mass Storage collection. - * Support embedded covers for ogg (read only) and flac files. (BR 288752) - * Track meta-data can be edited in USB Mass Storage collection. - * Support for album artists in USB Mass Storage collection. - * album artist (if differs from artist), BPM, labels, last played time and - bitrate are now shown in playlist track tooltip (if not already displayed - in playlist) - * Volume normalization: ReplayGain is now converted to iPod Sound Check and - vice versa. (BR 142579) - - CHANGES: - * Builds with ffmpeg 0.11. - * Database structure (lyrics table) was updated. Starting Amarok for the first - time after the upgrade may take up to one minute as the data is migrated. - * Amazon store: try to show a sensible default in the country selection. - * Only offer delete action when Shift key is pressed in Collection context menu. - * Only offer move action when Shift key is pressed in Collection context menu. - * Remove context view video applet. Unmaintained and broken. (BR 242793) - * Album cover images are written in background to prevent freezes. (BR 298332) - * Make keyboard & mouse behaviour of saved playlists browser same as of the - collection browser, including the delete key. - * Delete and Shift + Delete keys now work as expected in collection browser. - * Preserve statistics when copying or moving tracks to Local Collection. - * Common album actions such as Show cover, Show under Various Artists are now - available for all collections that support it, not just Local collection. - * When copying files to iPod, ensure target directories exist. - * When writing covers to files, all existing covers will be replaced. - * PulseAudio status in diagnostic dialog. - * optional libgpod dependency raised to 0.8.2 to support newest iPods. - * Amarok now prevents accidental unmounting of iPods in (small) time-frames - when iTunes database on iPod is not yet updated. - * Amarok detects when iPod is to be ejected from system and gracefully - disconnects it when it occurs. - * Hitting the eject button on iPod collection ejects it also from the system. - * iPod collection now detects whether iPod is safe to write and marks iPod - as read-only if not. This prevents "iPod shows 0 tracks" problem. - * Correct progress bar advancement when transferring tracks to iPod. (BR 139454) - * iPod Collection supports multiple simultaneous cancellable transfers. - (BR 219963) - * Improved dialog to initialize iPod. (BR 279797) - * Load tracks in playlists asynchronously using proxy tracks. (BR 295199) - * It is now possible to transcode tracks when moving them. (BR 280526) - * Drag & drop of tracks and playlists to Saved Playlists works in all cases. - * Don't show unmounted USB Mass Storage devices and make it clear when - the device is not "activated" yet. - * "Devices" in Amarok configuration -> Plugins is with other related strings - renamed to "Local Collection Backends" to reduce user confusion. - * Enable keyboard activation of PlaylistBrowser items. - * Don't use `mysql_config --variable=pkgincludedir`, find mysql include - directory manually by looking up mysql.h. - * Album artist is now guessed for tracks that do not belong into any - collection and tracks from USB Mass Storage collection. Guessing uses the - same algorithm as Local Collection. - * When hovering iPod, UMS or MTP collection in collection browser, - "1.2 GB free" is shown instead of "85% used"; thicker capacity bar. - - BUGFIXES: - * Fix crash on startup due to EngineController. (BR 300659) - * Fix problem building tests with google mock 1.6.0 on Ubuntu - * Fix dynamic playlist album play bias with MetaProxy::Tracks. - * Transcoding: fix compatibility with libav's ffmpeg. (BR 300551) - * Saved lyrics are preserved when the track is moved. (BR 242350) - * Lyrics, labels and album actions are correctly displayed for tracks - from main and saved playlists on Amarok startup. (BR 299150) - * Lyrics applet scrolls more intelligently. Patch by Alexander Potashev. - (BR 283601) - * Fix crash on startup related to ContextView. (BR 258741) - * Fix dragging of "No Labels" and "Various Artists" collection tree items. - * Don't add duplicates to playlist when dragging from collection. (BR 254411) - * Fix crash related to DAAP collection. (BR 280774) - * Fix crash on startup related to Audio CD collection. (BR 256585) - * When turning dynamic playlist on, immediately populate playlist and clear - any possible playlist sorting. (BR 220558) - * Fix transcoding with ffmpeg >= 0.10; patch by Julian Simioni. - * Fix crash on start when Qt is build with debugging assertions. (BR 285720) - * Fix URLs in MP3tunes, gpodder.net and Last.fm config dialogs. (BR 299088) - * Fix drag & drop in playlist layout editor, filename layout editor and - filter editor for non-english locales. (BR 215402) - * Fix bug where MySQL password could not be set to 'password'; patch by - Lachlan Dufton. (BR 272346) - * Detection and elimination of stale and orphaned iPod tracks now works - correctly; users are notified about these when iPod is plugged in. - * iPod playlists now work correctly. (BR 289304) - * Show correct error when transferring unsupported files to iPod. (BR 234876) - * Fix m4a tracks transferred as mp4 videos to iPods. (BR 268238) - * Combination of double click and context menu actions caused multiple - delete of downloaded podcast actions, etc. (BR 297092) - * Prevent merging tracks with same title but different track (disc) numbers; - patch by Alexey Neyman. - * Prevent crash on very quick drag and release of tracks. (BR 295275) - * Prevent occasional tag corruption on multi-byte UTF8 characters in tags. - * Do not double-transcode tracks when importing from an audio CD. (BR 263775) - * Fix resulting filetype when copying a track from Jamendo. (BR 296000) - * Playlists with a dot in name can now be saved to Playlist Files on Disk. (BR 290318) - * iPod playlists now appear even when plugged in while Amarok is running. (BR 289303) - * Show in Media Sources actions no longer reset the collection sorting to artist/album. (BR 231858) - * Don't mark audio-CD tracks as unplayable (greyed out). (BR 285885) - * Don't misbehave when track is dropped directly to saved playlist. (BR 293295) - * Don't report collection of USB Mass Storage tracks as None. - * When adding, changing and removing tracks in USB Mass Storage collection, - actually update the user interface to show it. - * Remove empty folders when deleting tracks from USB Mass Storage collection. - * Don't copy tracks to USB Mass Storage collection in move operation. - * Fix defunct aborting of transfers to USB Mass Storage collection. (BR 290448) - * Allow ripping of CD tracks with special characters in name tranks to - Björn Steinbrink. (BR 224437) - * Don't allow tracks to be dropped to their own collection and to - non-writable collections; indicate the fact visually. (BR 291068) - * Fix scrollarea following keyboard navigation. (BR 259791) - * Fix crash when trying to save custom equalizer presets. (BR 286227) - * Fix crash due to my silly method order error. (BR 291968) - * Fix favored random track playing picking recent played songs (BR 244442) - * Fix crashes with Bookmarks (BR 283753) thanks to Charles Reiss - * Fix memory leaks in USB Mass Storage collection where track objects were - never freed due to circular references. - * Fix rare APG solver crash. (BR 290533) - * Compilations are handled more consistently on iPods. (BR 232072) - * MPRIS2 compliance: don't use track ids that start with /org/mpris/ - * MPRIS2: be better about emitting the Seeked signal - * MPRIS2: fix the mpris:artUrl metadata property - * MPRIS2: make sure that the Seeked signal is sent out when the track time - moves backwards (eg: when the track changes) - -VERSION 2.5 - FEATURES: - * Now It's possible to use formated strings for prefix and suffix in - Playlist's layout items. - - BUGFIXES: - * Do not crash when iPod doesn't have a master playlist. (BR 288936) - * Fix Last.fm not finding KDE Wallet. (BR 286741) - * Put a border around bottom toolbars, visually separating them from - browser contents. (BR 277741) - * Align the bottom toolbars. - * Allow albums with empty name but nonempty artist in local collection. (BR 272471) - * Fix collection info display (track count, free space) for iPod and MTP - devices. (BR 232093) - * Fix crash at exit with Qt 4.8 - * Fix moving applets rightward in the context toolbar. - * Fix breadcrumbs not working properly for the file browser. - * Disable cover fetching action for tracks not in the collection to avoid - crash when trying to "save as" a cover. (BR 287604) - * Show default cover in tag dialog when track is not in the collection. - * Fix directory selection when opening album location in tag dialog. - * Fix crash in CoverFoundDialog if progress dialog is cancelled just - before fetch is done. - * Correctly parse disambiguation pages for songs in the English Wikipedia. (BR 270054) - * Fix wrong context view applets sizes on start up in some cases. - * Fix Amarok consuming CPU until main window is shown. (BR 278897) - * Fix last.fm 'scrobble composer' option's fallback to artist (BR 286215) - * Fix volume control from within Amarok. - * Fix slow startup because of imported playlists. (BR 284761) - * Fix audio CD detection on Amarok start. (BR 276032) - * Set a default filename scheme for USB Mass Storage (BR 285900) - * Fixed crash during MusicBrainz search. (BR 277475) - - CHANGES: - * Load Last.fm friend/neighbour avatars on demand. - * Update tracks in the recently played widget only when needed. - * Allow editing the SearchWidget during a search animation. - * Update the collection view while UMS is scanning. - * Don't block the UI while scanning UMS device. - * Allow going back and forward in Amazon store. Thanks to GCI student Nikola Miljkovic. - -VERSION 2.5.0-Beta 1 - FEATURES: - * New "equals" match in collection filter - e.g. label:=pop finds songs - with label "pop" but not songs with label "electro pop". (BR 260004) - * Enable dropping tracks on empty area in Saved Playlists to create new - playlist. - * Added a "create new playlist" action in the empty space of the Saved - Playlists. (BR202725) - * Add new type of optional tokens in format string (Collection Organizer) - (BR 264874) - * Compilations are properly marked as such when transferring music - to/from iPods. (BR 207880) - * Ctrl+F now activates collection browser and focuses the seach collection - bar. (BR 257381) - * Music store based on the Amazon catalogue. - * Podcast subscription synchronisation and podcast status synchronisation - with gpodder.net service. - * Possibility to browse through podcasts suggested by gpodder.net and - through gpodder.net top recommended podcasts. - * Made possible to make presets for TagGuesser. (BR 264632) - * Display current timestamp in tray tooltip. (BR 278445) - * Auto-save the playlist so that it is not lost if Amarok crashes. - - CHANGES: - * BPM (beats-per-minute) attribute is now kept when transferring tracks - to/from media devices. (including iPods) - * Better, shorter internet service descriptions. - * Both Delete and Move to Trash actions are now offered in the collection - browser context menu. (BR 286356) - * Amarok now depends on libmygpo-qt >= 1.0.5. - * New USB Mass Storage media-device plugin using the Amarok Collection Scanner. - * Browser widget backgrounds can now be enabled/disabled. - * Playlist: Don't group albums without name. (BR 243344) - * Make delete confirmation dialog text less confusing. Patch by Gilles Habran. - (BR 263693) - * Removed never-working right-mouse-button action to unset iPod album cover. - * Removed the confusing ability to edit the navigation breadcrumb. - * BPM is now read from/saved to media devices (e.g. iPod). - * Track last played date and time is now correctly read from/saved to iPods. - * Depend on KDE 4.6 - various bugs were caused by older versions. - * Total rewrite of Automated Playlist Generator algorithm. New algorithm - is far less complicated and crash-prone, but at the cost of taking - longer to converge when the constraint tree is complicated. (BR 240927, - BR 240301) - * Improved the playlist synchronisation feature. - * Make possible to get count tracks before the XSPF file is fully loaded. - * Stop fetching guitar- and bass-tabs from fretplay.com because the site is down. - * Mark unplayble tracks in the playlist. Patch by Sandeep Raghuraman. (BR 263640) - * Current track applet: show number of artists instead of genres. (BR 261077) - - BUGFIXES: - * Stability fixes for Dynamic playlist (BR 280056) - * Fixed crash in the Wikipedia Applet. (BR 279813) - * Don't crash with Qt debug builds when iPod is connected. (BR 279798) - * Fixed crash on exit while collection scanner is running. (BR 261421) - * Fixed collection browser tracks grouping after switching to Merged View. (BR 277015) - * Prefer track artist to album artist in Albums applet fiter. (BR 266682) - * Fixed the Metadata, CanGoPrevious, CanGoNext and CanSeek properties of the - MPRIS2 interface - * Fixed Wikipedia search field not accepting space character or cursor - keys. (BR 266591) - * Fixed SupportedMimeTypes method on the MPRIS2 D-Bus interface, so that it - no longer appends duplicate entries on every call. - * Do not use Album Artist as Artist for files without Artist metadata. (BR 281283) - * Fixed crash on decodeing currupted media during MusicDNS search. (BR 284895) - * Prevent crash on getting cover from MP4 files. Patch by Charles Reiss. - (BR 283675) - * Prevent several potential and one real media device crash. (BR 284838) - * Fixed iPod album covers not displayed in collection browser. (BR 263268) - * Do not crash when iPod is removed but some iPod tracks are still in - playlist. (BR 245852) - * Fixed several potential AmarokUrl related crashes. - * Rework iPod identification so that it is more reliable (BR 263288) - * iPhone 3G (and perhaps later models) should be correctly recognized by - Amarok now. (BR 281738) - * Automated Playlist Generator doesn't freeze anymore when it finishes. - (BR 277865) - * Use regular MusicBrainz search for tracks with MBID. (BR 280857) - * Always use English AND/OR in Collection Filter even if translations are - in effect. (BR 279559) - * Fixed errors in the saved playlists view when removing a playlist. (BR 273358) - * Fixed issue where the Context View wrench was not created when the - Context View had no applets. (BR 280382) - * Fixed off-by-one error in organize collection dialog. - * Fixed issue that made TagGuesser dialog to forget setings. (BR 280288) - * Fixed tags guessing from full file path. (BR 264302) - * Work around a Qt bug that crashed Amarok in various situations. (BR 207382, BR 269227) - * Fixed issue with TagDialog that brought to messed up digits order in numerical - fields (year, track, disk, score). (BR 277279) - * Made possible to store empty TagDialog's numerical fields. (BR 278921) - * Fixed issue with TagDialog's "Open Destination" button, now It opens - correct directory instead of parent. (BR 279147) - -VERSION 2.4.3 - BUGFIXES: - * Fix KWallet auth requests on every track change. (BR 278177) - * Display correct values for pretty times (playlist length) > 1 day. - * Update playlist length correctly after removing track. (BR 273407) - * Fix seek backward from dbus. (Thanks to Matthieu Bedouet) (BR 263287) - * Prevent dialog querying last.fm settings being displayed on startup if none set. - * Fix detection of smartphones in USB storage mode. (BR 277685) - * Fix crashes on expanding a newly cloned dynamic playlist (BR 277750) - * Don't block the UI while calculating the filename previews. (BR 233196) - * Make M3U & PLS playlist files editable from Saved Playlists. (BR 245963) - -VERSION 2.4.2 - * This version number was skipped. - -VERSION 2.4.2-Beta 1 - FEATURES: - * Made Amarok compile with the Clang LLVM frontend. - * Enable drag and drop on collections to copy/move within Local Music and - directly from the playlist. (BR 223400) - * Added KNotify scripting interface. (BR 260750) - * Make podcast episodes download filename configurable. Patch by - Sandeep Raghuraman. (BR 155075) - * Automatic scrolling in lyrics applet (Thanks to Jan Gerrit Marker) - * Option to scrobble composer as artist to Last.fm (Thanks to Nicholas Wilson) - * Option to hide the OSD if another window is taking the full screen - - CHANGES: - * Again write back ratings only if option is selected. - * Moved the queue-editor action to the main menu under playlist to save space. - Queue editor now has a shortcut: Meta+U. - * Removed the redo action from the playlist toolbar to make it less wide. - * Made some playlist toolbar actions collapse into a menu button for use on - small screens. - * Removed the statusbar. Moved progress info & messages to the Media Sources dock. - * Removed the preview button and checkbox from the organize collection dialog. - * General user interface cleanup (addition of browser widget backgrounds, - etc.) - * Removed the add button in the context toolbar. Applet explorer is opened on config. - * Easier to understand Dynamic playlists - * Made Amarok depend ffmpeg-0.6 or newer. - * Use KImageCache if possible (kdelibs 4.5.0 and later), which should - reduce the number of cache-related crashes. - - BUGFIXES: - * Make the Coverbling applet build again. (Patch by Manu Wagner) - * Don't let the album applet freeze Amarok for ages on track change. (BR260810, BR277021) - * Fixed cover fetching from Google Images. (BR 275265) - * Fixed a crash in the equalizer dialog when selecting "Off". - * Fix finalization of track copy process to media device collections. (BR238912) - Patch by Tommaso Falchi Delitala. - * Fixed crash on MusicBrainz search. (BR 274956) - * Avoid crash in ContextView when accessing Plasma::Applet::view(). - (BR 258741) - * Fixed playlist tooltip getting too tall for multiline comments. (BR 256038) - * Made equalizer keywords (dB,kHz,...) translatable. (BR 263572) - * Made equalizer preset names translatable. (BR 263596) - * Fixed runtime error reporting of scripts. (BR 207409) - * Fixed "Happy" moodbar theme. (BR 264432) - * Re-added old "Normal" moodbar theme. (BR 264432) - * Fixed crash for invalid scripts trying to be stopped by the manager. - (BR 268917) - * Fixed collection menu items ordering. (BR 207007) - * Fixed top level podcast location setting. (BR 263736) - * Fixed double-clicking in collection using left-handed mouse setting. - (BR 272360) - - -VERSION 2.4.1 - BUGFIXES: - * Fixed crash on saving playlist on ineligible device. (BR 266899) - * Fixed Photos applet crash on track metadata change. (BR 265395) - * Fixed crash on local collection search. (BR 270949) - * Fixed crash during iPod track removal. (BR 253088) - * Relative paths support for XSPF playlists. (BR 264147) - * Fixed incorrect handling of "Various Artists" node by Collection Browser, - now selection of this node returns "Various Artists" tracks instead of - whole collection. (BR: 263255, BR: 269717) - * Fixed song scrobbling if It was paused. (BR 267477) - * Screen escape characters in MusicBrainz request string. (BR 269455) - * Fixed detection of iPod devices. - * Fixed crash when the lyrics applet was removed and re-added while a - track was playing and the user pressed "ESC". - * Fixed cached lyrics were not displayed if no lyrics script was running. - * Fixed lyrics changes in the TagDialog were not "synchronized" to the - lyrics applet. - * Fixed reporting of playback status for MPRIS (both versions). - (BR 268282) - - -VERSION 2.4.1-Beta 1 - FEATURES: - * Remote NFS & SMB/CIFS collections now work! (BR 249760, BR 232976, - BR 171213, BR 187692) - * New "Preview" feature for the Organize Collection dialog. Patch by - Maximilian Güntner . - * String filtering in the albums applet. - * Ability to change text alignment in the lyrics applet. - * gpodder.net Service, a Podcast Directory displaying the most used Tags - from gpodder.net & the top Podcasts of these Tags - - CHANGES: - * The podcast directory service is now based on incremental parsing of OPML without - caching in the database. - * Plugins can now be optionally enabled in the config dialog. - * Script selector is moved from the menubar to the config dialog. - * Now all changes to Preset Formats in Organize Collection dialog get saved on close, - doesn't matter If dialog was accepted or rejected. - * Added "Update Preset" button to Organize Collection dialog, which updates currently - choosen scheme. - * Renewed FilterEditor dialog. - * Changed tokens syntax in FileNameLayoutDialog (TagGuesser, OrginizeCollection dialogs) - now tokens wrapped in percent signs (%token% instead of %token). - * Added ability to guess tags from whole track path. (TagGuesser dialog) - * Use KDirWatch to watch changes to collection. - * Do always store track rating as tags in files. Patch by Alan Ezusti - . (BR 259117) - * Added missing tooltip for animation settings. Patch by Bhargav Mangipudi - . (BR 248690) - - BUGFIXES: - * Fixed translation issue in MagnatuneSignupDialog. - Patch by Burkhard Lueck (lueck@hube-lueck.de) (BR: 239019) - * Fixed crash on loading unsupported format playlist. (BR: 265378) - * Ask delete confirmation for all contents of folder at once instead of each individually. - Affects "Saved Playlists" and "Podcasts" (BR 246117) - * Fixed unreadable text in lyrics applet in kde 4.6. (BR 265311) - * Fixed tag dialog crash when sorting by genre and then changing tags. - * Fixed track's statistics update in case of StopAfterCurrent playback mode - (prevent double statistics change). (BR 265654) - * Delete .mood files when tracks got removed from collection via Collection - view context menu, and move them to new destination during Organize Collection process. - (BR 261629) - * Fixed "Configure Amarok..." disappearing in tray menu. (BR 258226) - * Fixed crash when quitting Amarok. (BR 253676, BR 257407) - * Fixed empty folders removal after collection organization. (BR 190881) - * Fixed crash when trying to load cover for track/album without artist. (BR 263256) - * Fixed linking on Solaris 11 (and others?). (BR 264112) - * Fixed temporary podcast download filenames that were to long by using MD5 hash instead. - Thanks to Frank Steinmetzger for the patch. (BR 264813) - * Fixed issue with absentee toolbar on clear run (without config files). (BR 259615) - * Fixed CD copying functionality. (BR 264050) - * Fixed CUE tracks playback order. (BR 263237) - * Prevent crash on exit when using Phonon-VLC. - * Fixed crash in the queue editor when trying to show already - removed items of the playlist. (BR 263308) - * Fixed Mute button. (BR 253098) - * Fixed issue with Organize collection, which made amarok remove newly copied tracks. - (BR 263301) - * Fixed wrong "Configure amarok" action position in tray icon popup menu. (BR 263330) - * Fixed minor inconsistency in the Collection view. Patch by - Bhargav Mangipudi . (BR 260973) - * Fixed potential crash with the Similar Artists applet. Thanks to - Tuomas Nurmi for the patch. (BR 263145) - * Fixed 'Scale Font' option in OSD options for OSD preview widget. - (BR 254029) - * Fixed issue with playlist tooltips that was shown independetly from - "Show tooltip" option. (BR 263121) - * Fixed issues with multifiles cuesheet, when all tracks get metadata of - last track - in cuesheet, and each file defined in sheet gets all tracks of this sheet. - (BR 262668) (BR 209341) - * Fixed crash when trying to download a full size cover and the server - redirects the request. (BR 262902) - * Fixed issue when breadcrumbs stayed not updated after service insert/remove. - (BR 262780) - * Fixed issue with TagDialog that make metadata fields stay editable if multiple - streams opened. (BR 177400) - * Fixed missing equals-sign ('=') in filter string of bookmarks. (BR 245759) - - -VERSION 2.4.0 - CHANGES: - * New Splash Screen by Tomasz Dudzik . - * The "Playdar Collection" feature has been disabled until some technical - issues are resolved. - * Fixed some broken radio stream URLs. - - BUGFIXES: - * Fix crash on copying tracks between collection. (BR 261364) - * Fix fetching of script data. BBC, Free Music Charts and others should work again. - (BR 261839) - * Actually show the Splash Screen by default, as it was meant to work. - * Leave all pending files in case of error/conflict during tracks moving. (BR 257739) - * Fix crash when moving tracks between collections. (BR 253033) - * Fixed issue with UMS Collection that made amarok to delete original track - instead of newly copied one. (BR 238915) - * Fixed issue with Audio CDs that do not provide CDDB information. Patch by - Andriy Gapon . (BR 257818) - * Fixed issue with the Organize Files Dialog that prevented presets from being - loaded when in advanced mode. Patch by Philipp Schmidt . - (BR 255325) - - -VERSION 2.4-Beta 1 - FEATURES: - * New UPnP Collection detects and plays media on UPnP devices on the network. - * New transcoding feature which converts one or more tracks with a chosen encoder - when copying to the local collection. - * Added option to use Wikipedia Mobile. - * Added settings for writing statistics and album covers back to the file. - * Leave focus in playlist search widget when using up/down to scroll through - filtered results. Thanks to Thomas Karpiniec for the patch! - * LyricsApplet: The lyrics in are now updated when they were changed in a - different place, for example in the Tag Dialog. - * Permit the use of iPod Touch 3G and possibly newer devices. Thanks to - Aurélien Croc for the patch! - * Match space-separated search terms in the playlist filter var individually. Thanks - to Thomas Karpiniec for the patch! - * Added new context applet for displaying guitar and bass tab information. Thanks to - Rainer Sigle for the patch! - * Added ability to set/update Album Artist. - * Added map view and calendar in the upcoming events applet. - * Added support for all Wikipedia languages. (BR 220617) - * Added incremental search in the Wikipedia applet (press - '/' or global search key when in focus). - * Added "Favorite Venues" to the upcoming events applet. - * Read MusicBrainz IDs of MP4 files during scanning. - * Ability to hide and show the menu bar. Patch by - Valentyn Pavliuchenko . - * Size of the On-Screen-Display font is now configurable. (BR 195186) - * Musicbrainz-based mass tagging UI by Sergey Ivanov. - * New easy to use table-based UI for Ampache server configuration. (BR 200703) - * OPML export for podcast subscriptions. (BR 126120) - * New "Playlist Length" constraint for the APG, which allows you to specify - the number of tracks in the playlist. What was the "Playlist Length " - constraint is now called "Playlist Duration". - * MPRIS2 support for controlling Amarok over D-Bus. - * New "Playdar Collection" allows searching for and listening - to music provided by a running local Playdar service. - - CHANGES: - * Brought back collapsing animations of context applets. - * Added a "Donors" tab to the About dialog for our generous Roktober 2010 - donors who wish to be mentioned. - * Tracks might contain lyrics in the HTML format, where there's no user-visible - content in the HTML. Those lyrics are now regarded as "empty". - * LyricsApplet: changed the layout of the "Do you really want to refetch lyrics" - message. - * Current track applet: added "show in media sources" actions for current - track's artist, album, composer, genre, and year if available. - * Current track applet: added action to open the tag dialog. - * Improved appearance of current track applet when playback is stopped. - * Better scrolling in the applet explorer. - * The default moodbar style now uses system colors. - * Added tray icon context-menu action to open the preferences dialog. - * Show a progress bar while loading pages in the Wikipedia applet. - * Added option to right-align "year" in the albums applet. - * Improved alignment of tracks in the albums applet. - * Scroll to the current album and make its tracks visible in the albums - applet. (BR 187011) - * Added ability to expand/collapse/drag disc items in the albums applet. - (BR 249488) - * Improved appearance of similar artist, upcoming events, and Wikipedia - applets. - * Improved presentation of suggested lyrics (currently only 3rd party - scripts use). - * Now using QToolTip for playlist tooltips. - * Changed playlist delegate margins and inline editor formating. - * Added "Added This Hour" filter preset to the collection brower widget. - * Bumped KDE dependency to version 4.4., and Qt dependency to 4.6. - * Print message when a file can't be copied to a media player. - Patch by Sergey Ivanov <123kash@gmail.com>. (BR 203820) - * Improved the usability of device items in Media Sources by adding tooltips. - * Deleting items in the collection/file browser will move them to trash; - pressing SHIFT while clicking the action will bypass trash. - - BUGFIXES: - * Fixed white text on light blue background in tabs applet. (BR 258234) - * Fixed cover dialog crash pressing Ok when nothing is selected. (BR 258187) - * Title labels incorrectly used the text color from the plasma theme. - This caused trouble with the fixed plasma theme and light color schemes. - * Fixed a data-loss bug where the user could lose changes he made to the current - track's lyrics. (BR 207621) - * Fixed covers of Ampache tracks not available through DBus. - * Scanning stale and orphaned songs on iPod results in song duplication. (BR 235696) - * Applets' settings dialogs were partly untranslatable. (BR 255971) - * Fixed append&play action. Thanks Pieter van der Kloet for the patch. (BR 229706) - * Don't ignore the "use relative path" checkbox in the playlist export dialog. - (BR 250689) - * Fixed applet explorer getting stuck. (BR 253058) - * Fixed Wikipedia applet header layout issues. (BR 215171) - * Fixed truncated heading in albums applet. (BR 231001) - * Playlist sorting breadcrumb items have been untranslatable. - Patch by Alexander Potashev . (BR 189750) - * Dynamic Playlist criteria were not being saved properly. (BR 243562) - * Collection Browser should show Artist names for Compilation Albums. (BR - 252790) - * When Amarok starts and "Continue playing when Amarok is started" is selected, - the Current Track applet showed songs of the artist instead of the current - track info. Patch by Conrad Hübler. (BR 241641) - * Fixed crash on Windows when exporting playlist to any file type. Patch by - James Duncan . (BR 249376) - * If album keyword is empty, show "unknown album" in context window. (BR 205038) - * Ampache would not connect to servers placed in a subdirectory. - * Fixed an initialization bug which affected all context applets. - * Fixed bug where users could drag applets around indiscriminately. - * FLAC BPM tags could be read incorrectly. (BR 234166) - - -==BEGIN Qt 4.6 / KDE 4.4 DEPENDENCY== - - -VERSION 2.3.2 - CHANGES: - * Bumped libMTP dependency to version 1.0.0. - * Improved response of current track and albums applet on data updates. - * Use system date/time format for default name when saving user playlists. - - BUGFIXES: - * Fixed incorrect size of the VideoClip applet. (BR 247097) - * Comments embedded in files that contained newlines or tabs could be - skipped entirely. (BR 223502) - * The equalizer dialog did not discard changes when clicking "Cancel". - Patch by Anton Gritsay . (BR 242730) - * The Last.fm service did not work without KWallet. (BR 235861) - * Show actual KDE version in the "About Amarok" dialog, instead of the - version used at compile time. - * Fixed a crash when trying to save a playlist to a file where the format - of the playlist was unknown. (BR 246168) - * Also use podcast channel image for downloaded episodes. (BR 229391) - * Collection directories that were symlinks could end up storing the wrong - absolute path, causing those files to be removed during incremental - scans. - * Fixed playlist tooltips not showing up, even when enabled in the playlist - layout (BR 249086) - * Fixed potential crashes related to Applet loading. (BR 246756) - * Fixed possible crash in Labels Applet when playing new track. (BR 248538) - * Fixed incorrect layout of applets on startup. - * Fixed Collection Browser not properly updating after a full rescan, - necessitating Amarok to be closed and reopened. Fixes various bugs. - (BR 172542) - * Fixed cover found dialog closing when download failed or is cancelled. - * Fixed failure when fetching cddb info for audio CDs in localized Amarok. - * Fixed expanding items in collection browser by double-click, in - double-click mode. - * Fixed crash when adding new folders repeatedly in podcast/saved playlist - browsers. - * Fixed context menu actions acting on wrong indices in the playlist - browser. - * Fixed incorrect text about "rpath" argument to collection scanner. - (BR 236076) - * Fixed emission of MPRIS StatusChange signal when switching into or out - of random mode. - - -VERSION 2.3.2-Beta 1 - FEATURES: - * Podcasts can now be filtered on provider and grouped in folders. (BR 219519) - * Amarok 1.4 Database Importer: added support for importing labels. - Thanks to Matěj Laitl for the patch. (BR 218996) - * Shortcuts: Added "Replay current track" shortcut. (BR 217081) - * Edit filter dialog: added "added" and "last played" date filters. - * File browser: added forward and back buttons for accessing navigate history. - * Organize Dialog: added a way to save multiple file formats as presets. (BR 122672) - * Filtering: added default presets to the drop down menu of the collection - search widget. - * Filtering: track format can now be used as filter keyword in the - collection browser, e.g. "format:flac". - * Filtering: track file size can now be used as filter keyword in the - collection browser, e.g. "filesize:<12" for tracks under 12Mb; - "filesize:25" for tracks that are between 25 and 26Mb. - * Filtering: tracks that were added to the collection since/before a - certain time can now be filtered using, e.g. "added:<1w". - * Filtering: added ability to filter last played date in the collection - browser, e.g. "played:<3d". - - CHANGES: - * Let scripts access bpm property of tracks (read-only). (BR 245257) - * Remote Meta+P global shortcut to avoid future problems with new - keyboard drivers in notebooks. (BR 235204) - * Fix size of Slim toolbar time labels. Thanks to Tijl Coosemans for the patch. - * Amarok 1.4 Database Importer: only import tracks that actually belong in the - collection. Thanks to Matěj Laitl for the patch. (BR 218999) - * Refresh the albums context applet when the collection is updated. - * Don't allow the last visible playlist source in User Playlists to be hidden. - * "Play Media" dialog now remembers the last used directory. (BR 231092) - * Organize Dialog: tweaked the layout to fit better on smaller resolutions (BR 238000) - * Filtering: added year suffix for date filters in the collection browser. - * Last.fm features that require user authentication are now disabled - by default. - * Ignore "DJ" prefix when sorting in collection browser. (BR 181955) - Patch by Richard Longland . - - BUGFIXES: - * Tweaked fuzzy numerical comparisons in the APG. (BR 242281) - * Finally don't truncate the "Label:" label in TagDialog. (BR 235957) - * Fix crash when right clicking on children of "No labels". NoLabel item is - now a Data item. (BR 243825) - * Fix regression in Dynamic Collections. For files that were scanned when - Dynamic Collections wasn't working, you will need to rescan them to get - them associated with the proper device. - * Fix crash on exit with newer KDE versions. Patch by Martin Blumenstingl and Felix - Geyer. (BR 245513) - * Fixed playlist bottom toolbar getting to tall when using "Text only" - button style. (BR 228390) - * Fixed Amarok layout saving when minized to tray. (BR 244583) - * Make "No other participants" in the events applet translatable. - Patch by Jan Janssen. (BR 235311) - * Fixed track number on DAAP shares. Patch by Silvio Frischknecht. (BR 235030) - * Fixed filtering by rating in the playlist. (BR 240293) - * The scripts categories are now translatable. (BR 240563) - * Fixed Amarok 1.4 Database Importer not importing statistics and lyrics of - tracks that are not yet in database. Thanks to Matěj Laitl for the patch. - (see comments on BR 218996) - * Fixed always playing first track when adding tracks to empty playlist with - random mode on. Patch by Anton Gritsay (BR 240452) - * Directories that were once part of the collection but not anymore may not - have been properly removed, leading to files outside the collection being - scanned. (BR 243532) - * Fixed "genre" and other playlist groupings not working. (BR 243344) - * Removed track progress effect on TrayIcon as it caused several problems - (also caused by a bogus implementation of the KSNI class) - (BR 233506, BR 240463, BR 231539, BR 232578, BR 232312). - * Fixed track name in main window title incorrectly changing when editing - tag info for another track. Thanks to Anton Gritsay for - the patch (BR 220521) - * Splitted desktop so mime types can be allocated in a better way - (BR 242292). - * Fixed some tracks not being scanned when they had corrupted MusicBrainz - IDs. Thanks to Matěj Laitl for the patch. (BR 236227) - * Fixed crash when navigating using "Places" in the file browser. (BR 240338) - * Fixed error dialog popup if the stored directory is no longer accessible - when using the file browser. (BR 234286) - * Single clicking a file in the file browser now selects it instead of - appending to the playlist by default in single-click mode. (BR 233171) - * Fixed resizing and eliding issues with the file browser breadcrumbs. - (BR 231366 comment #5) - * Drop file icons in file browser breadcrumbs. (BR 231366) - * Fixed keyboard navigation in file browser. (BR 240668) - Patch thanks to Hannes Koller. - * Fixed dropping files to playlist from Konqueror. (BR 235722) - * Fixed keyboard shortcuts of actions from scripts lost after restart. - Thanks to Martin Blumenstingl . - (BR 223165) - * Fixed tracks not changing for "stop after this track" action. (BR 231209) - * Cleaned up some tooltips/what's this strings in the Organize dialog - to make it easier to read and, hopefully, understand. (BR 237857) - * Fixed organize dialog's handling of the year tag. If there is no year - then the %year token should be an empty string.(BR 237834) - * The "Ignore 'The'" option in the organize files dialog is now case - insensitive. (BR 237831) - * Fixed odd header name when showing "places" in the file browser. - (BR 238518) - * Filenames with dots (.) and other special RegEx characters will now be - parsed correctly when guessing tags from a filename. (BR 225743) - * Align track details dialog's labels to the right as per KDE4's HIG. - (BR 234555) - * The last.fm service will now only open the wallet on startup if the user - has enabled features that require authentication. (BR 230098) - * Correctly load the list of labels in tag dialog. (BR 238737) - Patch by Daniel Faust . - * Cover manager: fixed crash if closed shortly after opening. (BR 235796) - * Fixed Last.fm service browser not updating its view if it's open on - startup. (BR 231044) - * Fixed clicking on browser categories not honoring mouse settings. (BR 226533) - * Fixed usability issue with regards to context menu item order when right - clicking in the playlist widget. (BR 198650) - - -VERSION 2.3.1 - CHANGES: - * Improved responsiveness when expanding/collapsing items in the - collection browser when using single-click mode. - * The Collection scanner now runs with idle priority when invoked by - Amarok. Batch scan users can invoke it with the --idlepriority flag. - - BUGFIXES: - * Fixed regression in Ctrl+RightClick behaviour in playlist. (BR 241238) - * File browser: fixed sorting files by date. (BR 226941) - * Fixed issue with file browser bookmarks not working when the file browser - was showing "places". - * Fixed crash when right clicking in file browser while it is showing - "Places". (BR 237562) - * Fixed strange selection behaviour in the music sources pane (BR 222760). - * Fixed factor used when filtering lengths in collection browser. - * Fixed wrong value used when filtering comments in collection browser. - * Don't truncate the "Label:" label in the TagDialog. (BR 235957) - * Display extended characters properly in names of Last.fm streams. - (BR 222930) - * Cover fetcher: prevent automatic fetcher from setting album's cover if - it is done manually during the download. (BR 236839) - * File browser: show folders first, files afterwards. Patch by - . (BR 226599) - * Queued track's contextual menu entry about dequeueing was written wrong - and misleading. (BR 235047) - * Custom color setting in the On Screen Display was only applied after - restart. Patch by Frank Steinmetzger . - * Track Rating was not always displayed correctly in the On Screen - Display. Patch by Frank Steinmetzger . - * Improved layout for applet setting dialogs. Patch by Felix Geyer - . - * Made icons in applets react correctly in double-click environments. - Thanks to Felix Geyer . - * Several bug fixes for the bundled LyricWiki script. Patch by Oleg G - . (BR 233605) - * Better fix for pausing SHOUTcast streams, without advancing to the next - track after resume. (BR 192878) - - -VERSION 2.3.1-Beta 1 - FEATURES: - * Persistant Queue Saving: The playlist queue is now saved when Amarok - is closed and restored upon startup. (BR 215057) - * Automated Playlist Generator: allows smart creation of playlists that - match user-specified constraints. Combines the features of "Smart - Playlists" in Amarok 1.4 with the Bias system of Amarok 2.0. - * It's now possible to mark all episodes in a channel as old or new at once. - * New "Upcoming Events" applet, displays future concerts for the artist of - the currently playing track. The event info is fetched from Last.fm. - * New "Similar Artists" applet, displays a list of artists which are - similar to the one currently played. The list is fetched from Last.fm. - * The scripting system now offers a new function for detecting that a - track has finished. Patch by Michael MacDonald . - (BR 227312) - * New "CoverBling" applet, which allows to browse your collection in an - animated 3D view. Thanks to Manu Wagner . - * Support for the new System Tray technology from KDE SC 4.4. This adds - nice animations and a better looking popup menu to the System Tray. - Thanks to Aurelien Gateau for the patch. - * Allow playlist layouts to group tracks by directory. (BR 230594) - * Cover fetcher: The UI was improved. Now an icon view is used to display - results, with an informational sidebar that may show interesting bits - about an image. - * Cover fetcher: Added ability to enter custom queries via Yahoo!, - Google, or Discogs (in addition to Lasf.Fm). Note the source for - automatic cover fetching is still Last.fm only. - - CHANGES: - * Allow changing the number of recently added albums in the albums applet. - * Magnatune.com store: Added "Home" link to all artist and album pages leading - to the Magnatune.com front page. - * Magnatune.com store: Improved Magnatune.com front page. - * Magnatune.com store: Completely remove option to purhcase single albums as - this is no longer supported by Magnatune.com and the API for doing so will - be disabled in the future. - * The new file browser now supports "places". - * Added "up" and "home" buttons to the new filebrowser. - * Items in the breadcrumb navigation bar are now hidden if there is not enough - room to show all of them (similar to how it works in Dolphin) (BR 231497) - * Improved performance (dramatic in some cases) when filtering the Playlist - (231185). - * Remove information that is already displayed elsewhere in the playlist from - the playlist tooltips. - * Make showing the playlist tooltips a per playlist layout option. - * When bookmarking a view in the local collection, also store (and restore) - the setings for "Show Cover Art" and "Show Years". (BR 230562) - * Allow moodbar files witout the leading '.' (both ..mood - and .mood now work) - * Change example SQL command for setting up an external database to remove - (sometimes incorrect) host name and possibly fix some random regression in - some MySQL versions. (BR 225052) - - BUGFIXES: - * Fixed Youtube videoclip broken engine due to their recent change. - * Fixed Wikipedia no loading the css on KDE 4.4 (due to a regression in Qt 4.6.) - (BR 222875) - * Settings dialog could become too wide with translations. (BR 233752) - * Fixed re-mounting iPhoneOS devices after having been unplugged without being - unmounted. Thanks to Jeffrey Dodge . (BR 233305) - * Fixed connection to iPod Touch devices. Patch by Jeffrey Dodge - . (BR 233257) - * Fixed the deletion of empty directories after deleting, or organizing. - (BR 190881) - * Fixed a hang that would occur when organizing a track and the source - file was the same as the destination file. (BR 233181) - * Fixed the double delete confirmation dialog when organizing tracks. - (BR 233200) - * Fixed broken rendering of ratings in Current Track applet on startup. - * Fixed command type names shown in the Bookmark Manager not being translated. - (BR 226829) - * Fixed crash on startup for users of MySQL 5.5. Thanks to Bartosz Fabianowski - for figuring it out. (BR 231166) - * Readded missing hover info for the new filebrowser. - * Fixed missing images in the hover info shown for various browser categories. - * Fixed crash when running some Amarok urls on startup. (such as when passed on - the command line or cliked in another app) (BR 231626) - * Fixed crashes when Amarok is started and the Info applet is loaded with - certain version of Qt. (BR 227639) (BR 229756) - * Fixed organize collection dialog deleting tracks at new location - instead of old. (BR 217002) - * Fixed a broken podcast feed that had a minor compliance issue in date - format. (BR 231062) - * Fixed "files" bookmarks not storing the actual path shown in the file - browser (BR 231437) - * Fixed incorrectly displayed cover images for albums with the same name, - e.g. "Greatest Hits". (BR 170146) - * Fixed problems with new Main Toolbar and SHOUTcast streams: Since these - streams cannot be paused, we detect this now and stop them instead. - * Fixed permission errors with each file copied to an iPhone via iFuse. - Thanks to Colin Guthrie for the patch. (BR 231021) - * Fixed issues with using random navigators while filetering or searching the - Playlist. (BR 229226) (BR 222129) - * Fixed crash related to the new playlist tooltips. (BR 229696) - * Fixed some artist/album/track names not getting shown or getting shown - incorrectly in the Current Track applet because of html encoding. - (BR 222765) - * Fixed issue with the Albums applet not correctly updating when playing a - track by an artist not present in the local collection. - * Fixed Albums applet not getting updated if the artist of the currently - playing track was edited. (BR 210296) - * Fixed bad window title for the details edit dialog in the playlist layout - editor. (BR 227912) - * Fixed wrong track getting dragged from the Playlist when sorting and/or - filtering is active. (BR 226503) - * Fixed visual indication for "Stop After This Track" not getting shown - immediately when using the global shortcut. (BR 230569) - * Cover fetcher: Fixed a crash involving reappearing cover found dialogs - and pending cover fetches. (BR 230215) - * Display tooltips with applet names in the context toolbar. (BR 230736) - * File browser: "Add to Playlist" doesn't add playlist files to the playlist. - (BR 229290) - - -VERSION 2.3 - FEATURES: - * Podcast channels and episodes can be dragged to add them to other - providers. (BR 195704) - * Track action buttons are now available in the label for the current track. - * Bookmark button is now available in the Current Track applet. - - CHANGES: - * When a podcast episode is no longer shown because of the episode limit, - the downloaded file is also deleted from disk. (BR 227674) - * The visibility of columns in the new Files Browser is now configurable. - * Toolbar: "Skip icons", prev/next labels are aligned to the edges - * Volume Dial: Gradient indicator and pointing cursor hint above the dial ring - * Playlist layout editor: When copying a layout, set its current name as - the default one for the copy. Thanks to Jakub Wieczorek . - * Set Media Keys as default global shortcuts for playlist navigation. - (BR 194259) - * Deleting files from the File Browser is now asynchronous. - * Copy/Move/Organize operations now display detailed progress information. - * Copy/Move/Organize operations can now be canceled. - * Port Copy/Move to Collection actions to the new File Browser. - * Script-Updater: Only check for updates if 7 days have passed since the - last check. - - BUGFIXES: - * Fixed issue with applet icons with 2 lines of text getting cut off in the - applet explorer. (BR 227597) - * Fixed crash when setting a custom cover while Nepomuk is enabled on the system. - Thanks to Sebastian Trueg for the patch. (BR 197343) - * Fix crashes when scanning for orphaned tracks immediately after adding tracks - to an iPod. (BR 213097) - * Made cover urls for tracks from Jamendo, Magnatune and scripted services - available using DBus. - * When an Audio CD track is chosen manually, make it active in the playlist - and actually show the On-Screen-Display. - * Prevent a KDirLister error from appearing when running Amarok for the first time. - * Fixed cover art not properly updating in TrayIcon. (BR 228966) - * Fixed lyrics window size too small after edit. (BR 228922) - * Fixed odd behaviour when doing drag-and-drop from Collection browser. - (BR 222500) - * Show artist and title instead of raw track ID when copying/deleting - tracks on an MTP device. - * Fixed time labels getting truncated in the slim toolbar. (BR 195935) - * Fixed broken keyboard navigation in the playlist after activating a track. - (BR 225791) - * Workaround broken Jamendo url redirects. (BR 221922) - * MainToolbar labels: watch changes of metadata & queue (BR 227439 & BR 227362) - * MainToolbar labels: avoid empty strings (BR 228042) - * MainToolbar timelabel: show progressing time for stream (BR 227598) - * Playlist layout editor: Disable "rename" button for default playlist layouts. - Thanks to Jakub Wieczorek . - * Playlist layout editor: When reating a copy of a default layout, add copy - to layout list imediately. Thanks to Jakub Wieczorek . - * Compilations do not become normal albums when renaming them. (BR 192029) - * Fixed a bug where there would be no dynamic playlist biases available - with a clean startup. (BR 227797) - * Fixed a crash when pressing dynamic playlist "save" button on first - startup. (BR 227073) - * Fixed a bug when trying to drag files from another application into Amarok. - (BR 226167) - * Fixed a bug in podcast parsing that broke all feeds that do not include a - guid and possible overwrited data from other podcasts. Introduced in 2.3 beta. - (BR 227515) - * Correctly show progress description of last remaining job in the statusbar - after multiple jobs have been running. - * Fixed a regression that broke the playlist save button. - * Respect the podcast episode limit when new episodes are added during update. - (BR 220768) - * Fixed crash when right clicking on a header in "saved playlists". (BR 226290) - * Fixed bug that prevented files from being deleted from the Files browser - when performing a Move operation. - * Fixed bug in Organize Collection dialog that used the old "%theartist" - token instead of "%artist". - * Install amarokitpc.protocol for playing iTunes links in the web browser if - Amarok is not running. Thanks to Philippe Roubach. (BR 206615) - - -VERSION 2.3-Beta 1 - FEATURES: - * Added a configuration dialog for Local Podcasts. Update interval and base - download directory can now be configured. (BR 221398) - * Make it possible to go to next/previous track with horizontal mouse - wheel button on TrayIcon. (BR 225783) - * New main toolbar with completely redesigned look and new features. - Contributed by Thomas Luebking . - * Podcasts and Saved Playlists can now be grouped by provider like iPod, Local, - USB Mass Storage, etc. This can be toggled using a button in the relevant - Category. - * The playlist context menu now has a "Show in Media Sources" action for - many types of track. - * The collection scanner now also looks for cover images named - "folder.*". Apparently some applications use this convention. (BR 224692) - * It's now possible to automatically use a USB Mass Storage device as a - collection when it's connected. - * The progress bar tooltip now shows the position in the track that the - cursor is hovering, making it simple to jump to a specific position. - * D-Bus: Added StopAfterCurrent method for /Player. - * You can now elect to rescan specific folders. Right-click on a folder in - the collection setup dialog to rescan just that folder. This will only - work for folders that have previously been added to the collection, i.e. - you cannot check a folder and immediately rescan it. This will never be - recursive (as that defeats the point of scanning a specific folder!) - * Non collection files with a cue sheet will now load their tracks as - individual tracks in the playlist instead of as one big track with - bookmark markers. - * Dynamic Collection is back. (BR 171213) - * Searching covers from Last.fm using custom query in interactive mode. - - CHANGES: - * All move/copy operations to the local collection are asynchronous. - * Proper handling of disk full and permision errors for copy/move - operations to the local collection. - * A preview of the moving/copying operations is now shown in the Organize - dialog. - * Added an expander icon to the collection root items. - * The equalizer configuration is now a seperate tool window accessible - from the tool menu. - * Files with ogg and flac extensions can now be copied to UMS devices. - * The search/filter edit in the playlist is now cleared when pressing - enter. (BR 217159) - * Amarok now checks if the version of the "amarokcollectionscanner" tool - is correct. Some users had issues with having mutiple versions of it - installed, causing scanning to fail. - * First run: Let users decided on how to handle music location set - in standard desktop services. - * Improved cover fetching accuracy and speed. - * Usability: Better design of playback configuration dialog. - * Use millisecond accuracy for track bookmarks. Backwards compatible - with bookmarks stored in previos versions. (BR 215145) - * Loving a track for Last.fm via the global keyboard action also show a - message in the status bar. - * Improved usability of the playlist layout editor dialog. - * Duplicate unique file identifiers are now indicated in debug output, - along with the paths of the files, when found instead of being silently - ignored. This can help discover multiple copies of the same file or - files which incorrectly have the same MusicBrainz unique identifier. - - BUGFIXES: - * Prevent custom sliders from allocating a lot of pixmap resources (xrestop) - * Fix multiple busy indicators being shown in the Context View. (BR 208102) - * Corruption of guid strings by passing them as a KUrl caused podcast episodes - to be readded on each update. This issue has been solved. - If you have episodes that appear twice, remove the channel and add it again. - (BR 219516) - * Cleaned up the Organize dialog to make it more usable. (BR 199574) - * Made it harder to Move Files unintentionally. (BR 220716) - * Returned "Organize Files" to the collection's context menu. (BR 215902) - * Fixed Amarok Solid action for playing audio CDs working. (BR 209204) - * Fixed crash with moving applets in the Context View. (BR 191918) - * Fixed crash in KNotify. (BR 224673) - * Fixed queue management with mouse. (BR 217153) - * Fixed playback of some streams causing the progress slider to show - garbage track length and position values like -322:0-35:0-59. - * Prevent a crash when loading PLS playlists with invalid filepaths. - * Fixed scrolling crashes with the cover manager. (BR 224000) - * Fixed a bug that was deleting files when using "Move to collection" - from the file browser. (BR 217002) - * Allow fetching of album covers in the unified view. (BR 220873) - * Lyrics applet: Fixed scrollbar incorrectly displayed (and sometimes not - at all) for long lyrics under KDE 4.4. (BR 222260) - * Fixed bug in Photos applet that made it break with translated versions - of Amarok. Patch by Bellegarde Cédric . (BR 222566) - * Lyrics applet: Fixed saving and restoring font styles. (BR 222277) - * Lyrics applet: Fixed a bug where sometimes suggested URLs are not - cleared when switching tracks. - * Fixed playlist layout editor blocking control of Amarok. (BR 220825) - * Fixed moodbar in progress slider not correctly updating after moodbar - style change (BR 220695) - * Fixed progress slider not moving for many streams (and possible other - types of tracks) (BR 221747) - * Sort artists named like "The Foo" correctly in all cases. (BR 176670) - * Fixed behaviour when clearing the bookmark manager filter. - * Fixed track not being added to the playlist when playing a track from - the bookmark manager. - -VERSION 2.2.2 - CHANGES: - * The inline playlist editor now also allows resizing of auto sized items that - are invisible because fixed sized items already use up 100% width. - * Enhanced the playlist sorting breadcrumb items to separately highlight - the order inversion arrow on hover. (BR 209011) - * The automatic character set detection for tags has been disabled; it - caused too many problems with legitimate UTF-8 tags. It can be - re-enabled from Settings->Collection. (Many BRs) - * Dynamic mode is now automatically disabled when replacing the playlist. - (BR 214759) - * The collection search filter now also searches for file names as a - fallback. Patch by Andreas Hartmetz . - - BUGFIXES: - * Fixed crash with dangling pointer on trying to play a media device track - whose collection no longer exists. (BR 210477) - * Fixed loading MusicBrainz-tagged tracks in dynamic playlists. (BR 219902) - * Fixed MusicBrainz-tagged tracks not being restored in the playlist - upon restart. - * Fixed incorrect display of rich text in applet header text. (BR 220714) - * Fixed GUI freezing after mounting and during parse of media devices. - (BR 180520) - * Fixed occasional crash when custom biases go awry. (BR 219888) - * Fixed missing icons in the drag overlay menu. - * More reliable MimeType detection for music formats. Patch by Rafał - Rzepecki . (BR 219792) - * Fixed regression causing many scripted services, including the, shipped by - default, LibriVox service to not work at all. - * Fixed corner case that could prevent scans from being completed, - manifesting as a regression in 2.2.1. Huge thanks to Christian - Kreibichfor his patience and time in helping to debug this. - * Fixed removing multiple tracks from a saved playlist only removing the - first track. (BR 218527) - * Fixed cancel button not responding when loading thumbnails in the cover - manager. (BR 204882) - * Fixed crash when using the inline playlist editor to resize items containing - auto sized elements not shown becuase of all space already being used. - (BR 218167) - * Fixed relative links in wikipedia work. (BR 218512) - * Fixed multilevel playlist sorting by time since last played so it sorts - numerically rather than alphabetically. (BR 214761) - * Fixed crash with "Edit Track Details" dialog. (BR 217625) - * Fixed a number of cases where markers such as "current track", "stop after - this track" and others would get shown in both group header and the first - track in the group. (BR 197842) - * Fixed regression causing non default moodbar styles to not work. - * Jamendo.com service: Fixed track lengths not getting shown for most tracks. - For existing installs, this requires a redownload of the Jamendo database. - (BR 200531) - * Jamendo.com service: Fixed searches not working because of SQL errors. - * Jamendo.com service: Removed broken "Unknown" genre which would freeze - Amarok if expanded. For existing installs, this requires a redownload of - the Jamendo database. (BR 213165) - * Playback of Audio CD track now correctly stops if track is the last in the - playlist. (BR 216175) - * Fixed crash if user clicks rating widget on the current track applet - while no track is playing (which is possible since there is a slight - delay before the applet switches "mode"). (BR 215471) - * Made "Last.fm Love" (and potentially other global actions avaiable for all - tracks) correctly show up in the Current Track applet. - - -VERSION 2.2.2-beta1 - FEATURES - * Added Ctrl+O shortcut to open media files. (BR 219337) - * Dailymotion video can now be rendered within the applet in HQ if HQ is selected - in the video applet settings. - * Rewrote podcast feed parser to correctly parse XML. Now even RSS 1.0 and - Atom feeds are supported. Patches by Mathias Panzenböck. - * Rating of playlist items can now be filtered, using "rating:#" notation. - * When removing a podcast subscription, ask for confirmation and offer to delete the - downloaded episodes. Patch by Frank Meerkötter. - * Font of lyrics applet is configurable in the lyrics applet setting page. - * BPM editing, sorting, and filtering have been implemented. (BR 214056) - Patch by Pierre Dumuid . - * Made it possible to change a podcast channel's URL. (BR 195204) - * Also support feed:// urls for subscribing to podcasts. - * Limited the number of simultaneous podcast updates and downloads to four. - This can be configured separately in the "amarokrc" configuration file. - * Import podcast subscriptions from OPML. - * Show HTML info for podcast channels that support this. Patches by - Mathias Panzenböck. (BR 193357) - * Ampache Service now shows Service info from last.fm - * Moodbar support is back. Can be shown in progress bar or in the playlist. - The 4 visual styles from Amarok 1 (normal, angry, frozen and happy) are - all supported. This feature requires that moodbars files are already present. - * Cover images can now be fetched via HTTP. (BR 176899) - * Custom Labels has returned. Assign labels from the tag dialog, and - see them in the tag dialog or in the playlist. - * Fetch labels from last.fm for some tracks [UPDATE THIS ONCE WE FIGURE OUT WHEN TO DO SO] - * Pressing F2 when focused in the lyrics applet jumps into editing mode. - - CHANGES: - * Tracks in Albums applet are now sorted by track number. Patch by Lorenz - Röhrl . - * New menu to add applets to the context view. - * Added rating filter to collection browser's edit filter dialog. - * Added bitrate and sample rate filters to collection browser's text input area. - * Amarok now depends on KDElibs 4.3, and Qt 4.5. - * When downloading a podcast make sure the file is not on disk already. If it is the - download is stopped and the existing file is used instead. - * Last.fm friends and neighbors are now sorted alphabetically. - * Radically reduced memory consumption while downloading podcasts by writing direct to - disk. Patches by Frank Meerkoetter. (BR 209937) - * Podcast auto-update interval is now configurable in the rc-file. Default is 30 - minutes. (BR 212467) - * Magnatune.com store: Better status message when downloading albums. - * Moved the "Playlist Layout" button into the main menu, as the playlist - toolbar was becoming too crowded. - * New interface for repeat and random playback modes. Interface now correctly - represents the actual behaviour (ony one mode can be active at any time) - and is accessible directly from the playlist toolbar. - * Usability: Added tooltips all over the place, improved existing ones. - * Usability improvements for the Ampache service settings dialog. - * Length and size of queued tracks are now shown in the statusbar tooltip. (BR 144471) - * Improved Cover fetching. Changed Dialog so the user can select from - possible covers. - * Improved guessing tags from filename. Added preview to Dialog. - * Display frames around lyrics/video applets for indicating focus. - * Improved keyboard functions when editing lyrics from the applet. - * Improved automatic resizing of lyrics and suggestions in the context applet. - * The audio device is now closed when playback stops. This saves power in several ways - and frees it up for other applications. This also fixes the 100+ idle wakeups in - PowerTOP when using the Xine backend. - - BUGFIXES: - * Fixed two bookmark actions having the same text description. (BR 214716) - * Remove broken right click menu from the Info applet. (BR 206642) - * Fix several bugs handling changing compilations. Patch by Morten Sjøgren - -- thanks! - * Fixed bug with panel header icon size. (BR 208616) - * Fixed bug with OSD not being shown by dbus call. (BR 208424) - * Fixed bug with importing scores from Amarok 1.4. Patch by Michal Ziabkowski - . (BR 174444) - * Fixed wikipedia applet poorly showing wikipedia main page when a track - tag is empty. - * Magnatune.com store: Album cover is now correctly fetched when redownloading. - * Magnatune.com store: Fixed crash when redownloading album. (BR 217148) - * Fixed crash when doing "Edit Track Details" on media device. (BR 217143) - * Fixed layout resizing bug with Qt 4.6. (BR 213990) - * Fixed corrupted track lengths when copying to iPod. Patch by Christophe - Fergeau . (BR: 215124) - * Fixed videoclip applet going blank when switching from one video to - another. (BR 210332) - * Fixed dailymotion video file direct link retrieving not working. (BR 214168) - * Fixed wikipedia engine not parsing correctly URL containing ":". (BR 209397) - * Fixed several issues with loading and saving timecode tracks to and from - playlists. - * Fixed crash when copying tracks to MP3tunes music locker. (BR 214686) - Patch by Nicolas Lécureuil . - * Podcast downloads can now be properly canceled. Patch by Frank Meerkötter. - * Fixed any open menus or popus getting closed when the OSD is shown. - * Fixed copies of default layouts getting created even if just using the - inline editor to change track metadata. - * Fixed inline playlist editor saving values that had been edited but - where the value had not actually changed. - * Pressing enter now correctly applies changes in the playlist inline - editor. (BR 215924) - * The volume slider in the Slim Toolbar would sometimes work incorrectly - after startup. (BR 215185) - * Fixed popup for showing the progress of multiple tasks not working. - * Made dragging from podcast list to external program work. (BR 212343) - * Made dragging from the Last.fm service directly to the playlist work. - (BR 215494) - * Fixed crash during copying to collection with custom file naming schemes - where a component would be empty. (BR 211518) - * Magnatune.com store: Fixed incorrect download urls for non english - languages. (BR 212126) - * Magnatune.com store: Fixed membership type not remembered when running - a non-English Amarok. (BR 195427) - * Support for "title:" token in the collection search. Patch by Roberto - Bertolusso . (BR 211249) - * Fixed lots of memory leaks reported by Valgrind. - * Made lyrics applet colours presentable with bright and dark colour - styles. (BR 214930) - * Made sure random mode works if repeat is on. (BR 214559) - * Fixed random mode behaviour when "going back". (BR 208892) - * Made random mode work. (BR 212910) - * Fixed lyrics applet logic when saving, closing, and editing lyrics. - * Fixed graphic artifacts in the video applet. - - -VERSION 2.2.1 - FEATURES: - * Podcasts will only be automatically updated when there is a network - connection (using Solid). - * The SMB (Samba) protocol is now supported in the playlist. Patch by - Steven van der Vegt . (BR 178691) - * Podcasts have better indication of status with emblem icons. - (BR 209433) - * The information from the podcast feed can be written to the downloaded - files. Both manually and automatically. - * Track bookmarks can be removed directly by using the delete icon shown - in the popup when the mouse is over it. - * Add a menu allowing the creation of any known type of bookmark to the - Bookmark Manager. - * CTRL+SHIFT+F toggles full screen mode. Patch by Rick W. Chen - . - * Podcast episodes can now be marked as new/old manually. - * Podcasts can now be grouped in the playlist and show useful info in the - tag editor. - * Playlist files can be droped on the "Saved Playlist" category to - import them into Amarok. (BR 193476) - * Playlist files from the default playlist location are now loaded by - default. (BR 209596) - * Added view menu to menu bar for ease of use. - * Saved playlists and folders can now be deleted with the keyboard. - * Added "Copy on Write" when trying to edit a read only (one of the - default) playlist layouts. The changed layout is now simply saved under - a new name. - * Added context view bookmarks, allowing saving and restoring of applet - setups. - * Enhanced --debug feature: When a function takes very long to run (> 5s), - we print a special message (DELAY) that can be searched easily. - * Middle-clicking an item in the Collection Browser appends it to the - playlist. Patch by Felix Geyer . (BR 197423) - * Added feature for removing duplicates from the playlist. Patch by John - Atkinson . (BR 200445) - * Allow changing of playlist layout item sizes using the inline editor. - * Initial KNotify support. - * Show total playlist file size in a tooltip when hovering over the total - play list time. (BR 91640) - * Implemented "Jump To". Press Ctrl+J to focus the playlist search. - (BR 92400) - * Made Love/Skip/Ban/Enqueue/Dequeue available in Shortcuts configuration - dialog. (BR 136232, BR 187542) - * Added a function to automatically update the built-in scripts if newer - versions are available - - CHANGES: - * Do not automatically fetch the entire Jamendo database every time the Jamendo - service is started. - * Database now does consistency checks on a semi-regular basis, with full - checks upon full rescans. - * Removal of most SQL during scan result parsing means enormous speedups - during collection scanning. (BR 210201) - * Usability improvements for the Videoclip applet. - * Restore the proper custom bias when switching between saved biases (BR 209350). - * Don't crash when receiving bogus data from Last.Fm when asking for - recommended songs (BR 208173). - * UMS device plugin now checks MIME types of tracks both by content and - filename. Thanks to Aran Cox for the patch. - * Some optimization of SQL queries during scan to speed things up. (BR - 210201) - * Use an emblem for indicating a podcast episode is on disk. (BR 209433) - * Scanning speedups by getting rid of unnecessary code paths and - optimizing some queries. Patch by Egbert König . - (BR 209822) - * New main toolbar and renaming of ToolbarNG to Slim Toolbar. - * Huge performance improvements for the Cover Manager. Thanks to Michael - Reiher for the patch. (BR 210454) - * Improved usability and look of main control buttons. - * Multiple usability improvements for the Dynamic Playlist UI. - * Moved the Podcast category to the top level of the Content panel. - * Renamed "Browsers" panel to better suited "Media Sources". - * Improvements to the row heights in the playlist, making especially the - size of the rating stars more consistent. - * Usability improvements in the Context View's applet tab bar. - * Collection scanner won't scan a directory more than once if passed in - multiple times. Should significantly speed up certain incremental - scanning cases. - * When doing a recursive incremental scan, the scanner will no longer scan - subdirectories of changed directories if those subdirectories' mtimes - have not changed, for extremely large speedups in some cases. For very - flat collection trees, the difference is basically between a small - incremental scan and a near full rescan. - * Ask the user for confirmation before refetching lyrics and overwriting - cached ones. - * It is now possible to stop editing lyrics without saving changes in - the lyrics applet. - - BUGFIXES: - * Fix issue where data structures were loaded with wrong values. (BR - 212676) - * Videoclip applet didn't work correctly on some systems. Thanks for the - patch go to Jacopo De Simoi. - * Proportions of layout stay correct after window resizing. (BR 200527) - * The GUI layout is now crash persistant. (BR 211509) - * Ensure that ReplayGain float values are stored in the database with a - period, not a comma. (BR 212676) - * Fixed crashes with Icecast Directory script. (BR 206579) - * Enabled C++ exceptions handling in Amarok. This fixes various crashes - with liblastfm. (BR 212115) - * Reversed the priority of repeat and random modes. Repeat now always - takes precedence. (BR 178056) - * Fixed crash if closing amarok while the JamendoXmlParser is running. - (BR 208468) (BR 211015) - * Systray information now updates correctly for streams. (BR 211748) - * Made playlist layouts translatable. (BR 189751) - * Fixed issue with collection scanner seeing duplicate tracks if they - contained the default MusicBrainz UUID. Patch by Egbert König - . (BR 209822) - * Fixed issues with certain types of tracks not correctly getting grouped - together in the playlist when grouping by something other than album. - * Splash screen no longer hides KWallet on startup. (BR 210179) - * On Screen Display was not shown when cover image changed. (BR 195188) - * On Screen Display was not shown on automatic track change. (BR 209376) - * Automatic playlist scrolling was broken in some cases. (BR 193459) - * The On Screen Display now uses a sane font size with all display - resolutions. (BR 195186) - * Fix rare regression where inaccessible subfolders (due to permissions) - in the collection could not be picked up by an incremental scan when - permissions were fixed and their mtime updated, requiring a full rescan. - * When using a MySQL server with "Watch Folders For Changes" disabled, - very long periods of idle Amarok could allow the server to close the - local connection. This is now detected and should be worked around. - * Correctly set the lyrics applet's title when displaying HTML formatted lyrics - * Track selection is now correctly preserved when using Dynamic Playlists. - Patch by John Atkinson . (BR 208349) - * Cover Manager no longer stops when one cover cannot be fetched. Patch by - Tycho Andersen . (BR 205032) - * Magnatune.com store: Fixed problematic use of external unzip command - for unpacking downloaded album zip files. (BR 138499) - * Magnatune.com store: Download high quality covers when purchasing or - downloading albums. (BR 176177) - * Correctly modify the Lyrics Applet's title when its state changes. - - -VERSION 2.2 - CHANGES: - * The MusicBrainz ID of a track is now scrobbled to Last.fm, if it exists. - (BR 122281) - * More collection scanning speedups. - - BUGFIXES: - * Replay gain works on the Phonon Xine backend. - * Fadeout on track end works again. - * Fixed regression where the last album to be scanned would not have its - cover picked up by the collection scanner. - * Sorting by track length in the playlist is now possible. (BR 208689) - * Fixed track bookmarks not immediately getting removed from progress bar - when they are deleted from the bookmark manager. - * Fixed new track bookmarks not getting shown in the progress bar - immediately. - * Fixed track bookmarks not getting correctly repainted when resizing - progress bar. (BR 207091) - * Correct a logic bug during incremental scanning that could cause the - wrong tracks to be removed from the collection, requiring a full rescan. - Should fix bug 208403 and likely multiple others. (BR 208403) - * "Configure Amarok" dialog takes up less space, making it suitable for - small screens. - * Fixed photos applet not working after resuming playback. (BR 206829) - * Fixed regression where the genre field in the Tag Dialog would show the - composer of the track. (BR 208255) - * Don't reshuffle the playlist every time the active track changes when - * using a random sort order. - * Fixed the Various Artist node sometimes being shown in the Collection - Browser with nothing underneath it (or an empty "Unknown" album). - * Fixed some tracks' tags not being saved correctly to the database. - (BR 202021) - - -VERSION 2.2-rc1 - FEATURES: - * Import itpc:// podcast urls (BR 206615). - * Mark podcast episode as not-new when starting to play it. - * Reintroduced indicator icons for new podcast episodes. - * Added "subscribe" command line switch to add a podcast channel. - - CHANGES: - * Removed Shoutcast Directory service due to technical and other issues. - * Made audio CDs respect the "Automatically retrieve cover art" setting. - * TagLib 1.6 built with ASF and MP4 support is now required. This release - of TagLib fixes many, many bugs and contains new format support. - * TagLib-Extras 1.0.0 is now required. This release is compatible with the - new TagLib 1.6 release. - * Removed non working menu entry "rename" from the Bookmark Manager. This - functionality is no longer needed as inline renaming is possible. - * Improvements for volume widget in ToolbarNG. - * Added "Lock layout" option to the main window's context menu. - - BUGFIXES: - * Fix wikipedia engine refined search broken. (BR 208024) - * Crash in QTextCodec while scanning collection has been fixed. - Apparently. (BR 191447) - * A dialog with "Can not write playlist (/)" was displayed when using - saving from within a script. (BR 206659) - * Fixed playlist grouping mode not getting correctly applied on startup. - (BR 208087) - * Fixed track queue getting "lost" when switching between different track - navigators. (BR 205920) - * Implemented proper check for running instance options on the command - line. (BR 207988) - * Improved visibility of the Context View's menus. (BR 198221) - * Fixed crash when using the eject action on an audio CD collection while - a track from the CD is playing. Instead playback is now stopped before - the CD is ejected. - * Do not show the "load" context action in the Bookmark Manager when more - than 1 bookmark is selected. - * Fixed "Create timecode track" menu entry not showing up in the Bookmark - Managers context menu when exactly 2 bookmarks are selected. - * Fixed new track timecodes always getting shown at the very beginning of - the progress slider until the track was reloaded. - * Fixed some tracks not correctly loading timecodes due to url encoding - issues. - * Fixed bookmark database tables not correctly getting created on first - run, leading to frequent SQL errors. - * Fix the ends of the active track indicator getting stretched badly on - wide playlists - * Only one toolbar type will be enabled at any time (Toolbar or ToolbarNG). - Previously both could be enabled concurrently by accident. - * Multiple fixes for the Track Timecode popups. They are no longer truncated - if there is not enough space to the right and the issue with them getting - "stuck" has also been fixed. Thanks to Simon Bühler - for this patch. (BR 196924) - * Do not crash when removing a track with no album from the playlist while - the repeat album navigator is active. (BR 207427) - - -VERSION 2.2-beta2 - FEATURES: - * Added DBus methods Forward and Backward for relative seeking (BR 206028) - and PlayPause for toggling pause state (patches by Michael Zanetti - ). - - CHANGES: - * Grouping mode has been merged into the playlist layouts so each layout - sets its own. The default grouping mode for layout files that do not - have this value explicitly set is "Album". Thanks to Tim Bocek - for this set of patches. - - BUGFIXES: - * Default layouts should now be sane across all architectures. - * Fix genre tag in old MP4 files not being shown correctly (fixed in - Taglib-Extras-0.1.7, and upcoming TagLib-1.6). (BR 198238) - * Focus behavior is now consistent between the browsers filter widget and the - playlist filter widget. (BR 206776) - * OSX: Fixed crash when activating inline playlist editing. (BR 206576) - * Fixed dockwidget menu getting shown when right clicking on the progress - slider causing the slider to follow the mouse. (BR 206350) - * Use filename as track title for non collection files if no other title can be - found by reading metadata tags. (BR 206794) - * Update playlist filter, sort order and grouping when the metadata of a track - changes. (BR 206754) - * Do not crash if trying to load a completely empty playlist layout. - (BR 204236) - * Correctly show timecodes, if present, when starting playback of a new track. - (BR 191185 ??) - * The playlist sorting scheme is restored on startup. - * Fixed compilation of iPod collections without gdk-pixbuf.h. (BR 206347) - * Audio CDs are ejected properly. - * Media device eject/disconnect actions render properly when scrolling the - collection browser. (BR 204566) - * Fixed wikipedia applet not working when using a custom skin. Thanks to Stefan - Majewsky for the suggestion. (BR 205901) - * Fixed "Show in Service" action. - * Fixed extra empty rows sometimes getting added to the playlist layout xml - when using the playlist layout editor. (BR 205182) - * Fixed typo in D-Bus manifest, that resulted in incorrect function - invokation in IRKick. (BR 205729) - * Correctly mark playing track as active in the playlist after removing it - using the "clear playlist" button and later re-adding it. - * Fixed crash when removing an "albumless" track, like a podcast from the - playlist with the random album playback mode enabled. (BR 201476) - * Fixed track queuing when the playlist uses a random track progression. - (BR 194328) - * Fixed issue where files or folders with the same name but different case - sensitivity were not scanned and/or retained. (BR 197384) - - -VERSION 2.2-beta1 - FEATURES: - * Allow pasting an URL from clipboard to playlist with middle mouse click. - Patch by Felix Geyer . - * Support for copying aiff files to iPods. (BR 200820) - * Add openDesktop.org support to the About dialog to make it easier - to interact with the Amarok team. - * Add inline editing of track metadata in the playlist. - * The Playlist supports different grouping modes. - * The playlist can be partly or fully randomized (shuffled) by - selecting "random" as a sorting level. - * Info about the categories in the "Browsers" area is now shown in - the info applet on mouse over. - * Magnatune.com store: Add support for the personal recommendations - feature available to Magnatune.com members. - * Magnatune.com store: Add support for the membership "favorites" - feature. Albums can now be marked as favorites using a context - menu action, and the list of favorite albums is available in the - info applet. From here clicking links can add albums to the playlist, - navigate to the artist or album in the browser, remove an album from - favorites and (for download members) start a download. - * Add a dbus ShowOSD method to /Player. (BR 213532) - * Playlist layouts can now show simple inline playback controls and a - progress bar for the currently active track. This can be enabled on - a per layout basis in the playlist layout manager dialog. - * Show position in track of the mouse (the position in the track that - playback will jump to if pressing the mouse) when hovering over the - progress bar. - * Amarok File Tracking can now use MusicBrainz track identifiers as - embedded IDs. - * Allow sorting in the bookmark manager. - * Allow filtering in the bookmark manager. - * Add colums to the bookmark manger and make it possible to edit items - inline. - * Add a small bookmark menu to the browser breadcrumb bar allowing for - navigation to a bookmark, as well as creating a new bookmark based on - the current "view" or calling up the bookmark manager. - * Magnatune.com store: Allow re-downloads of any previous Magnatune.com - purchases by a given email, not just purchases made from a specific - installation of Amarok. - * Inline editing of lyrics from the context applet. (BR 201342) - * Ipod initialization support when failed to read an iPod database. - * Improvements to the "Show Cover" dialog. Resizes to match the image, auto - centers on screen, correctly handles images too large for the screen and - supports zooming using the mouse wheel. Patch thanks to Pascal Pollet - (BR 175901) - * Automatically expand collection browser search results and make the - results keyboard accessible. Patch thanks to Tuomas Nurmi - . (BR 172379) - * Audio CD support. Audio CDs now show up as a separate collection and - tracks from the CD can be freely mixed with any other tracks in the - playlist. Using the "Copy to Collection" menu its possible to copy (rip) - tracks directly to the local (or any other writable) collection. - * Sortable playlist. The playlist can now be hierarchical sorted using a - breadcrumb like interface to select sorting levels. Sorting can be - easily reverted. - * Improved media device support. - * Video applet to show videos from YouTube, Dailymotion and Vimeo. - The video can be appended to the playlist, and rendered within the applet. - * Photo applet to show images from Flickr, with customizable animations. - * Customizable user interface using dock widgets. - * Support for external MySQL database. See - http://amarok.kde.org/wiki/MySQL_Server. - * GHNS integration for downloading and installing Context applets. - * Support for Context applets to be written in QtScript. - * Custom Dynamic Playlists using Last.fm. - * Drag and Drop support for album cover image. (BR 91261) - * Upcoming and previous tracks count for dynamic playlist is now - configurable. (BR 177540) - - CHANGES: - * Imported playlists can be directly edited from within the "Saved Playlists" - category. The files on disk will be changed as well. - * Hueristics when deciding which album to use in a directory. See comments - in (BR 196559) - * The "Service Info" applet is now simply called "Info" to reflect that - it now shows info from other parts of Amarok as well. - * Remove the bookmark manager context applet and add a bookmark manager - dialog instead. - * Magnatune.com store: Add a link to purchase gift cards to the purchase - dialog. - * Reset playlist filter when using the "replace playlist" action. Patch - by John Atkinson (BR 200709) - * Track lyrics are exposed through the DBUS interface. - * The database connection and tables now enforce UTF-8 for the character - set and collation. - * The OSD registers itself as a notification window type on relevant - platforms. Patch thanks to Danny Baumann . - (BR 194517) - * Improvements to the Wikipedia applet. History, language settings - and more. - * Improvements to the Current applet. Text slides on mouse hover. - * New navigation style in the browser sidebar. - * Improvements to the Albums applet. Show individual track times and - highlight currently playing artist within compilation albums - * Removed PlayAudioCD from the scripting interface. It never worked - anyway, and audio CDs are just treated as a collection and not a - special case like they were in 1.4. - * Changed trackInserted and trackRemoved API signals. (BR 194220) - - BUGFIXES: - * Improved Amarok 1.4 import. Patch thanks to Michael Reiher . - * Improved performance and decreased memory usage when loading music shares - (DAAP collections). Patch thanks to Duns . (BR 173048) - * Changing Amarok's settings no longer removes album covers from playlist. - (BR 202258) - * Fixed crash on startup if another Amarok instance was still loading. - (BR 202713) - * Fixed some album art in a folder not getting picked up if a subfolder - contained any files. (BR 167158) - * Fixed broken selection in the "Saved Playlists" category. - * Fixed wrong Random Album mode behavior when playlists contains only - one album. (BR 194066) - * Fixed double playcount increase for last track in queue (BR 188330) - * Fixed track drag-and-drop problem when special characters are present - in file path. (BR 193878) - * Don't crash when trying to load an empty playlist folder. (BR 202643) - * Make using the mouse wheel over the progress slider correctly navigate - in the currently playing track. (BR 195913) - * Correctly strip all formatting from text pasted or dragged to the - comment field in the tag edit dialog. (BR 188270) - * Fix incorrect "current item" after deleting track(s) from the playlist - causing up and down buttons to not move selection to the expected row. - (BR 197203) - * Jamendo service: Fix destination filenames when using "copy to - collection". (BR 171839) - * Jamendo service: Make torrent downloads work again. (BR 198200) - * Remove the video stream from the context view when removing the video - applet during stream playback. (BR 201281) - * Fixed locales for Amazon cover fetching. (BR 188446) - * Fix crash on trying to edit a playlist layout with an invalid element - value in the xml file. (BR 197128) - * Fix DBUS xml parsing. Patch thanks to Ryan Bitanga - . - * Fix data caching issues causing incorrect values to be stored in the - database and in some cases to be written to tags. Fixes multiple bugs. - * Correctly enable/disable "Prefer Tracks" menu entry. Patch thanks to - Ralf Jung . (BR 191059) - * Do not show "%20" at the end of each filter value in the LibriVox - service. (BR 190704) - * Cached lyrics will now be shown when offline. (BR 197589) - * Fixed pressing play after reaching the end of the playlist not starting - the playlist from the top (or wherever the navigator thinks it should - start. (BR 176445) - * Fixed local playlists being renamed to blank when user hits cancel - * Fixed giant Edit Filter dialog with some translations. (BR 197566) - * Files browser remembers its view mode. (BR 197122) - * Fixed non-Latin UTF-8 encoding tags not being correctly decoded. - - -VERSION 2.1.1 - FEATURES: - * Compilations with more than 60 artists are supported. - * Option to hide the context view. - * Applets are now laid out according to two criteria: either fixed height - or flowing to fill the CV. No more slivers of applets visible at the - bottom. - * Load contents of an m3u file if specified when running amarok from the - command line. File must be local. - * Added large source emblem in current track applet. - - CHANGES: - * Removed option to purchase Magnatune.com albums using a Credit Card as - this is unfortunately no longer supported by Magnatune.com. It is still - possible to purchase albums using pre paid gift card codes, and all - membership features still work. - * Make it possible to delete multiple selected playlists at once from the - "My Playlists" category in the playlist browser. - * Show info box in CV if no applets are visible. - - BUGFIXES: - * Don't hide the "On/Off" button for Dynamic Playlists if the window is - not tall enough. (BR 195886) - * Make it possible to change the width of a playlist layout element if the - combined width of items in the row exceeds 100% (BR 195846) - * Keep width slider and width display from overlapping when setting - attributes on a playlist layout element. - * Don't overwrite cached lyrics when lyrics script returns a "Not found" - result. (BR 195213) - * Fixed the layout of the "Edit Track Details" dialog, which came up - broken under some circumstances. (BR 195081) - * Reset total playlist time when the playlist is cleared. (BR 153160) - * Don't crash when starting a collection scan after another scan had been - aborted. (BR 195242) - * Fixed non-UTF8 MPEG tag wrongly shown. - * Fix problem with supported filetypes not being copied over to MTP device - (BR 186835) - * Fix problem with playlist names containing '/' not being saved (BR 975995) - * Allow cancelling of rename input box in playlist layout dialog (BR 976409) - * Loading playlists from the command line works again. (BR 191347) - * Fixed formatting of the debug output when using the -d option. - * Detection of compilation cover during the scan works again. (BR 172953) - - -VERSION 2.1 - CHANGES: - * Removed the "Amarok Handbook" menu entry until the handbook actually - exists (work in progress). - * Single-click/double-click behavior in the Collection Browser now follows - the preference set in KDE System Settings. - * Automatically fetch the database for Jamendo/Opml on first load. - * Escape clears most search filters throughout Amarok. (BR 192254) - * Tracks of saved playlists are again shown in the playlistbrowser. They - can be added and sorted using drag and drop. (BR 187256, BR 184597) - - BUGFIXES: - * Fix incorrect scrobbling of tracks after only parts of them are played. - (BR 179503) - * Fix incorrect escaping of artist title in lyrics applet. - * Fix oddly capitalized format/extensions from being incorrectly - not recognized for copy of track to/from iPod. (BR 188249) - * Allow selecting directories from the "Add Media" dialog. (BR 192225) - * On Screen Display settings are now immediately applied, without - requiring an application restart. - * Fixed bug that variably caused Collection folders to be "forgotten", - lots of entries to show up in Amarok's config file, and some other - oddities. (BR 187126, BR 178973) - * Fixed large memleak when subsequent collection scans were performed. - (BR 186842) - * Fixed possible startup crash. (BR 187126) - * The context menu (right click) in the Current Track applet works again. - (BR 176169) - * After clicking on the Current Track applet, the menu bar at the top was - no longer working. (BR 190923) - * Fixed playlist sometimes becoming invisible when Amarok is restored from - the system tray. (BR 184714) - * Fix saving podcast episodes to the database when the metadata contains percent signs. - (BR 189104) - - -VERSION 2.1-beta2 - FEATURES: - * New Script method to get current track time in milliseconds. (BR 177073) - - CHANGES: - * Pressing the return key in the playlist search activates the selected - result. (BR 192126) - * Pressing the escape key in the playlist search clears it's contents. - (BR 192123) - * Optimizations to the insertion and removal of large numbers of tracks - from the playlist. Especially clearing a large playlist is now about - 300 times faster. - * Always scroll to newly inserted tracks in the Playlist. - * When removing upcoming tracks from an active dynamic playlist, add a - similar number of new ones to keep if from "drying up". - * Some action cleanup in the playlist context menu. - * When clearing the playlist, also reset the search/filter text. - * Podcast titles are stripped of unnecessary whitespace. (BR 177403) - - BUGFIXES: - * Fixed incorrect track counts in the collection. - * Fixed duplicate scanning of playlists during collection scan - * Fixed drag and drop to other applications. (BR 177415) - * Fixed the filter widget in the Files browser. (BR 176139) - * Fixed crash when using context menu after collection update. (BR 190056) - * Fixed problem with Amarok showing wrong track length for Last.fm - streams. Patch by Michael Quinn . (BR 188512) - * Fixed several memory leaks. - * Set the value of the slider to the actual scale when loading a fuzzy - Bias playlist, instead of 100% in every case - * Don't fetch all coverless albums automatically when opening the Cover - Manager. (BR 176170) - * Podcast episodes are loaded correctly when restoring a playlist on - startup. This means the local file will be played if downloaded. - (BR 189328) - * Next button in the main toolbar no longer has a clipped shadow. - (BR 176031) - * Fixed slider mouse events in RTL layouts. (BR 185465) - * Detect iPhones as iPods. (BR 184744) - * Clicking on "Stop after current track" disables the flag if it is - already enabled. - * Show a track marker when the "stop after current track" flag is set. - (BR 185888) - * Don't flash the OSD when opening the settings dialog. Patch thanks - to Andreas Heider . - * Podcast file formats are correctly displayed. - * Don't crash when pressing Delete on empty playlist. (BR 189021) - - -VERSION 2.1-beta1 - FEATURES: - * The collection scanner is now able to be run in batch mode, allowing for - automated scans of both full and incremental types. In addition, all - graphical dependencies have been removed, allowing for headless, remote - runs of collection scans. A wiki page detailing how to do this will be - made available shortly. - * Covers are shown and written for iPod collections. - * Phonon multimedia system can be configured directly from Amarok. - * Cover art can now be disabled in the collection browser. - * Scrobble tracks from streams that have title and artist metadata - * Add support for showing a stream with multiple alternative servers as a - single item in the playlist and add GUI for manually selecting prefered - source. - * Ampache service: Add support for Ampache 3.4.4 and 3.5.x. - * Auto timecoding (position bookmarking) now exists for tracks with length - greater than 10 minutes. (BR 148740) - * Add a animated "loading..." screen when dynamically fetching info about - an item to show in the service info applet. - * Deleting tracks from the local collection is now possible. (BR 170999) - * Add a filter-by-date-added to the collection browser. Use added:"today" - or added:<2m2d - * Add an advanced but user friendly playlist layout editor allowing users - to modify and create their own playlist layouts. - * The Playlist can now render itself using layouts defined in XML. A - number of default layouts are included and can be switched between. - * Option to automatically scroll the playlist to the active item on track - change. - * New QtScript methods for accessing the playlist: - Amarok.Playlist.selectedFilenames() & Amarok.Playlist.selectedIndexes(). - Patch by Mathias Panzenböck . - * New QtScript method for the Track prototype: imagePixmap( size ). Returns - a QPixmap of the given size, or the default if the size argument isn't - supplied. - * New QtScript class 'DataDownloader' that returns results as a QByteArray - instead of a string. Needed for image downloads. - * Cue Sheets are now supported as in Amarok 1.4, plus each cue entry - (usually a track) will be displayed as a timecode on the Progress Bar - with a nice onMouseOver popup. - * Ipod support now uses/depends on libgpod 0.7.0 - * Bookmarking specific positions within local tracks and downloaded local - podcast episodes, with a nice visual indicator on the progress bar. - * When the last.fm service is active, any track, from any collection or - service, can be loved from the browser , and there will always be a love - button for the currently playing track, no matter the source. - * Dbus methods added: VolumeUp, VolumeDown and Mute. (BR 181130) - * The feed url is displayed in the config dialog of a podcast channel. - By left clicking in the url it's copied to the clipboard. (BR 180853) - * The Playlist Browser can now show playlists from multiple sources, - including media devices. - * The Last.fm service now allows for the playing of all types of user - stations (personal, loved tracks, recommendations, and neighborhood). - * Arbitrary Tags can now be played in the last.fm service. (BR 139802) - * Replay Gain support for most file formats that Amarok can read tags from. - Reading Replay Gain tags from MP4 files requires libMP4v2. Musepack - (MPC) files are unsupported due to a limitation of TagLib. - * Bookmark Manager applet allowing for the creation, browsing, ordering and - deletion of Amarok urls of different kinds. (BR 173512) - * Amarok urls. Amarok can now load and generate "amarok urls" that allows - any "view" to be bookmarked and later retrieved. A protocol handler is - also installed that will launch amarok into the correct state, or make - amarok show the correct view, if already running, when such a url is - activated system wide. - * Customizable playlist layouts. The playlist is now rendered according to - an xml layout, allowing the playlist to assume a variety of different - looks and supply customizable information. - * Album cover art can be accessed via the scripting API. Patch thanks to - Simon Esneault . (BR 179732) - * New vertical Context View layout. - * New applet toolbar in the Context View to arrange, select, and add - applets. - - CHANGES: - * New splash screen by Wade Olson . - * Magnatune.com store: When downloading albums (either by purchasing or - free membership downloads) remember the file format and download - location for next time. - * Links in the lyrics applet are now clickable and open with the default - external web browser (BR 179396) - * Collection browser has been pimped. - * Bring back animations in the browsers if Qt 4.5 or later is detected. - * The collection scanner is now being provided in a separate package. - * The TagLib plugins formerly provided by Amarok are now being provided in - a separate package. It should be available in most distributions as - taglib-extras. - * Improvements to playlist searching and filtering. No longer reset view - to the top when clearing a search term. No longer scroll into the results - when the "show only matches" option is set. - * Improved implementation of volume muting. Mute state doesn't change - volume level any more. (BR 172392) - * Remove score, last played and play count from the current track applet - for tracks that does not have any of them (mainly streams). - * Don't pretend to be able to seek if the source isn't seekable. - * File Browser UI has been tweaked for better usability. - * The Bookmark Handler in the File Browser no longer causes a crash-on-exit, - so it has been re-enabled. (BR 173634) - * Performance optimisation when loading large playlists, and hence faster - application startup. - * Many small visual tweaks for greater consistency and better use of screen - space. - * Increased width of volume slider for greater precision. - * Use the speex, trueaudio and wavpack support in TagLib 1.5, rather than - our own plugins. - * Double click on a podcast channel appends all episodes to the playlist. - * Delete and download actions will only be shown when relevant to the - selected podcast episode. - * Major refactoring of the podcast model and view to allow custom actions - per podcasts source. - * Compilation fixed for OpenSolaris. - * Show the cover menu when right clicking on artwork in the Tag Dialog. - * Don't remove queued tracks from the playlist when repopulating dynamic - playlists. (BR 191285) - * Major last.fm UI overhaul. - * Progress indicator on system tray icon is back. - * Now using KSystemTrayIcon. - * QtScript: Importer.loadQtBinding returns a true or false depending on - success. - - BUGFIXES: - * Improvements to compilation detection during the collection scanning - phase. Thanks to Michael Quinn for laying the - groundwork. (BR 172953) - * Do not reset lyrics applet to the top when pausing and then unpausing a - track. (BR 182519) - * Automatically update lyrics applet if the user edits relevant track - metadata. (BR 185237) - * Fix tracks with some identical tags being detected as dupes and not - getting copied onto MTP device. - * Fix invisible and unintuitive selection in the playlist after deleting - one or more tracks. (BR 187871) - * Prevent playlist from showing a wrong playing song after adding tracks - above it. (BR 181947) - * Show the current playing song when resuming playback of a track not in - the collection. (BR 173912) - * Fix crash when using ctrl+mousewheel in the File Browser. Patch by Valentin - Rouet . (BR 175803) - * Fix actions choosen from context menu in a filtered playlist getting - applied to wrong track(s). (BR 186573) (BR 185054) - * Try to detect the charset of cue sheets. (BR 184769) - * Make opening an external webbrowser working on Windows, too. - * The File Browser now remembers its sort order. (BR 186444) - * When editing info for multiple tracks, do not write to the files if only - editing info that is stored in the db and not in the actual files (such - as ratings). (BR 184836) - * Render the lyrics applet correctly with dark color schemes. (BR 183037) - * When turning on a dynamic playlist, automatically populate the playlist if - it is empty. (BR 183968) - * Don't crash if using an invalid codec name AmarokLyricsScript conversion - functions. (BR 185540) - * Actually stop playback if we encounter too many errors. - * The collection scanner no longer sucks quite as much. - * A full rescan is no longer necessary after disconnecting/reconnecting an - external harddrive. - * Fix issue with files being deleted when Organize Collection is run - without selecting a collection root. (BR 184410) - * Dynamic playlist weight's are now saved correctly. (BR 184304) - * Fix using "Copy to Collection" to download Magnatune.com preview - tracks. (BR 183328) - * Correct behaviour when queuing in a filtered playlist. (BR 180477) - * Do not break up grouping in the playlist when editing (all but - album) tags. - * QtScript correctly writes the tags of tracks metadata it changes. - (BR 182667) - * Fix "Stop Playing After Track". (BR 180486) - * Fix switching tracks in random tracks mode. (BR 176019) - * Fix grouping of Stream and File meta objects. This affects many cases, - Such as when loading a playlist containing tracks from a scripted - service. - * Fixed crash on exit when collection scan has been aborted. (BR 176870) - * Fixed an infinite loop bug when using title case conversion in Guess Tags. - (BR 180164) - * Don't show the rating widget for tracks which are not in the collection. - (BR 180023) - * The negation operator works in the collection browser filter. - - -VERSION 2.0.2 - CHANGES: - * Show a statusbar message when loving a lastfm track. - * Show error message when Wikipedia information cannot be retrieved. - - BUGFIXES: - * Fix showing of book information from the LibriVox service. - * Don't crash if a script has uncaught exceptions. - * Open ogg files in Amarok when using Dolphin and other file managers. - Patch thanks to Lubos Lunak . (BR 180155) - * Fix podcast episodes not ordered right because of incorrect parsing of - pubdate. (BR 181338) - * Fix crash in tagdialog when editing tracks without an artist. (BR 183180) - * Statistics were not calculated properly in all instances. (BR 182025) - * Compilation fixes on Open Solaris. - * Trim URL before adding a new podcast. - * Add Ok button to the podcast configuration dialog to improve usability. - (BR 181339) - * Add tooltips to now playing widget icons. - * Fix not possible to download episodes from newly added podcast channel. - (BR 180851) - - -VERSION 2.0.1.1 - BUGFIX: - * Fix possible buffer overflows when parsing Audible .aa files. - - -VERSION 2.0.1 - FEATURES: - * Add advanced, configurable, searching and filtering to the playlist. - * Add "Stop after track" option to the playlist menu. - * Queue track functionality has returned. (BR 171939) - * Growl support on OS X. - * Add automatic recovery option to MySQL embedded server. - * Greatly improved Librivox.org service script. It now works for all books, - and dynamically fetches a summary of each book that is shown in the - service info applet. The script now also has a propper icon in the - service browser and its own emblem and default "album" cover for books. - * Sorting collection by Composer is now possible. (BR 177271) - * Service scripts can now dynamically fetch context info when items are - selected (info can still be applied statically to each item as well). - * Album items from a service script can now have custom covers. - * Items from a service script can now have a custom emblem. - * Service scripts can now set custom icons for the service browser. - * Add simple filtering to the service browser. - * Podcast channels are automatically refreshed once per hour if autoscan is - enabled. - - CHANGES: - * MTP devices can now delete multiple tracks at once. - * Status bar notification on copying or deleting tracks on Ipod. - * Don't fold the Collection Browser after editing or updating the - collection. (BR 166841) - * Replace the systray icon with a more modern logo. - * "Cool-Streams" radio service script is now enabled by default. - * Show more verbose output when copying tracks to the local collection. - * Custom Sorting in the Collection Browser has returned. - * Memory use optimizations. - * Playlist items now have tooltips. (BR 170844) - - BUGFIXES: - * The QtScript Qt binding generator has been updated to the latest. - This should complete some features such as Model/View in the QtScript API - and fix building with Qt 4.5. (BR 177863) - * The Files browser now remembers its settings, like the active directory. - (BR 173742) - * Fix problems with the collection scanner often missing a part of the - collection, or potentially failing altogether. (BR 176154) - * Fix Context View crash when quitting the application. (BR 179110) - * LibriVox: Don't crash when double clicking "Enter Query". (BR 177991) - * Files could be deleted when moving files to an unwritable destination. - (BR 178701) - * Don't override cached lyrics when fetching. (BR 178196) - * Show a warning when the collection scanner dies. (BR 176154) - * Set date correctly on MTP devices. (BR 171194) - * Ipod ratings are read/written/displayed. - * Ipod playcounts are read and displayed on Current Track Info applet. - * Lastfm Settings Dialog can now check to ensure username/password is - correct. (BR 144456) - * Don't delete files if an error occurs during transfer. (BR 178701) - * MPRIS GetMetadata() call returns arturl for last.fm streams. (BR 178695) - * Fix grouping of various artist albums in the playlist. (BR 175604) - * Update statistics properly on Windows and Mac versions. - * Fix progress indicator disapearing when skipping in last.fm streams. - * Write the discnumber field for mp3 tags. - * Don't start a fadeout when stopping paused media. (BR 178057) - * More accurate Amarok 1.4 database imports. - * Ipod tracks' sample rate is now shown correctly in Tag Dialog. - * Tracks did not always report that their editable status correctly. - (BR 177058) - * Gapless playback of MTP tracks one after another now works. - * Podcast with some unsafe characters in them caused database corruption. - (BR 172594) - * Amarok no longer stalls on large Ipod copy operations. (BR 173707) - * Fix switching between basic and advanced mode in the filename scheme - chooser. - * Fix MTP device attached on startup crashing. (BR 177201) - * Tracks with same tags as a track on Ipod are no longer copied. (BR 177198) - * When reaching the end of the playlist, actually show stopped state. - (BR 177782) - * Fixes in playing tracks in repeat modes. - * The wikipedia applet did not give a status update when an entry was not - found. (BR 173940) - * Add tooltips to icons in context view. (BR 174478) - * Fix icons and layout in Advanced Filter dialog. - - -VERSION 2.0 - FEATURES: - * Added read/write configuration APIs for QtScript. - - CHANGES: - * Removed the KBookmarks menu in the FileBrowser because it causes - crashes. - * The Organize Collection dialog has been improved. - * Last.Fm service now uses KIO for network access, respects desktop proxy - settings. - * Added icons to the filename scheme and organize collection dialogs. - * Added an OK button for the script manager. - - BUGFIXES: - * Don't try to squeeze text into wrongly tiny space, make the track label - in the tag dialog work again. (BR 176399) - * Collection setup directory chooser would incorrectly set some paths as - disabled. Patch thanks to Ben Boeckel . (BR 176569) - * Fix shadows around the cover in the current track applet (and potentially - other places as well) getting progresssively darker. - * Don't compare Solid and libmtp's serial number to connect. (BR 176403) - * Workaround a bug in the CurrentEngine class that makes the nocover image - look grainy in the currenttrack applet. - * Dragging and Dropping folders from the filebrowser into the playlist will - now result in the tracks being ordered correctly. (BR 176673) (BR 176156) - * Fixed deletion for downloaded podcast episodes (BR 176084) - * Show artists in Cover Manager sorted alphabetically. (BR 176178) - * Fix reading of windows playlists, recognise \ as directory separator. - (BR 93717) - * Fix crash when searching in collections. (BR 175094) - * Prevent disabled MP3tunes service from being initialized on first run. - * Elide text properly in applet chooser widget. (BR 175064) - * Fixed potential crash when playing streams. (BR 175886) - * Don't show wrong metadata for Last.fm radio. (BR 175435) - * Don't try to squeeze text into wrongly tiny space, make the track label - in the tag dialog work again. (BR 176399) - * Expand applets width when a complete column has been removed. - * Don't try to fetch another cover if there are no more albums to fetch - for. (BR 176364) - * Don't crash when trying to edit the details of a track without an artist - or album. (BR 173322) - * Magnatune.com store: Correctly show progress info when downloading. - * Magnatune.com store: Fix purchase/download of wrong album being initiated - when selecting "Purchase" or "Download" from the playlist context menu. - (BR 176171) - * Fix a bug that stopping a running script crashes amarok. (BR 175050) - * The context view could sometimes show the "stopped state" even when a - track was playing. - * Amarok 1.4 database importer would crash under some circumstances. - (BR 171784) - * Covers could not be fetched from Amazon Japan. (BR 176073) - * Fix a bug that the script manager deletes wrong entry after script - installation. (BR 173919) - * Make lyrics auto-display when applet is added while a song is playing. - * "Watch folders for changes" actually works now. - * Fix a bug that caused dynamic playlists not to repopulate. (BR 173776) - * Fixed potential issues with malformed XML breaking the collection scan. - (BR 170408) - * Focus of text fields no longer lost when changing tracks using the Next/ - Previous buttons in tag dialog. (BR 175524) - * Sort Podcasts in the right order. - - -VERSION 2.0-rc1 - FEATURES: - * Users' Recommended radio is now shown in the Last.Fm Service. - * Playlist browser items can be deleted and renamed using the keyboard. - (BR 175116) - * Basic and Advanced view when editing a filename scheme are synchronized. - * Added delete button to Advanced view for defining a filename scheme. - * Importer for iTunes libraries now allows you to import your statistics - from iTunes. - * The settings dialog now remembers the page that was last used. - * Track information can be edited from the file browser. (BR 172812) - - CHANGES: - * Video and Last.fm applet have been disabled. They are not ready for release. - * Ipods and MTP devices auto-connect again for usability. - * Ipod Collections can now delete multiple tracks at once. - * User playlists added from files are now updated on collection rescans, so - any changes in the file is reflected in the SQL playlist. - * Layout refactoring in the Organize Collection dialog. - * Enabled Last.fm scrobbling by default when Last.fm login is supplied. - * Amarok now allows opening of video files again. (BR 174267) - * "Show active track" has been moved from the playlist context menu to the - playlist toolbar. - - BUGFIXES: - * Last playing track on exit now selected on startup. (BR 168789) - * Update Collection works now correctly, only scanning the necessary dirs. - (BR 169602) - * In Organize Collection, the "Collection root" token is now fixed at the - beginning of the filename scheme. (BR 175376) - * Resize handle now appears in OS X. (BR 170199) - * Do not deselect album when right clicking on header. (BR 175527) - (BR 174584) - * Correctly sort tracks when dragging and dropping directly to the - playlist. (BR 175023) - * Clearing the playlist turns Dynamic Mode off. (BR 174514) - * Make sure user has edited a text field manually before overwriting that - tag. (BR 174878) - * Podcast episodes and channels can be dragged directly from the - playlistbrowser onto the playlist. (BR 175162) - * Multiple fixes and improvements for the Wikipedia applet. - * Playback no longer stops when Last.Fm service config is closed. (BR 174943) - * Fix issue with tracks from SQL playlists that were added from collection - scanning not having proper metadata until after a restart. - * Fix duplicate playlists being added on collection rescanning. (BR 173180) - * OSD timer resets when song changes. (BR 175030) - * Fix crash when dragging albums to the bottom of the playlist. (BR 174786) - * Fixed update of preview string in Organize Collection when switching - collections. - * Fix playlist behaviour when adding a track that is already playing - (BR 174634) - * Jamendo Service: Remove some sorting modes that caused the database to - choke as the result sets became too large. Will be revisisted post - 2.0.0. (BR 174851) - * Fixed possible crash with reading wav files. Patch by Peter van Fessem - . (BR 174819) - * Amarok 1.4 database importer would skip tracks in some collections. - (BR 174329) (BR 174444) - * OSD renders correctly on track changes. - * Podcasts are correctly stored to the database. (BR 172688) - * Lyrics aren't refetched when irrelevant track metadata is changed. - (BR 174678) - * Don't show transfer popups when copying tracks to a collection and - overwriting files. (BR 174533) - * When organising files, "Ignore The" logic was inverted. - * Do not reload scripts that are already active. (BR 174601) - * Pressing Stop while fade-out is running will no longer restart the - fading. (BR 173528) - * Fixed problem with Amarok sometimes not advancing to the next track. - * Wikipedia and Lyrics applets now update with streams. (BR 172715) - * Ampache Service: Do not crash if login is incorrect on startup. - * Playback control buttons now respects the current color theme. - (BR 169268) - * Fix scripted services not resetting content when filter is cleared. - * Dynamic playlist no longer locks up requiring a restart of the - application. (BR 173776) - * Correctly load m3u playlists. (BR 171595) - * Made the Load action start playback correctly like the Append action. - * Fixed metadata updating for Shoutcast streams. - - -VERSION 2.0-beta3 - FEATURES: - * More intelligent sorting of items in the collection browser, using - locale aware sorting and natural sorting for numbers. Patch by Nicholas - Wilson . (BR 154408) - * The playlist automatically scrolls when dragging tracks. (BR 171622) - * Import statistics from Amarok 1.4. - * Double clicking items in the Albums applet appends to playlist. - * Service scripts can now specify custom info for artist, album and friends - that will be shown in the playlist and other places, independetly of - their actual parent item in the service. This value is ignored if item - is not a level 0 item. Specifying these values is completely optional. - * Playlists can be added using the Add Media dialogs. - * Collection browser can once again sort by Year - Album. - * Albums applet shows disc number separators. - * Context menu and drag & drop support for the albums applet. - * Added tracks count and total playlist time to the status bar. - (BR 171652) - * You can now Copy To a collection, Append, and Load tracks from - the file browser's context menu. - - CHANGES: - * Improved usability for the collection configuration dialog. - * XSPF playlists will now attempt to apply any stored metadata to items - not owned by a service when loading. This will make many streams stored - on shutdown appear with correct metadata after a restart of Amarok. - * Scripted services are now able to set the infoHtml used in the - service info applet for individual tracks. - * The default lyrics script now uses the LyricWiki site, which is more - reliable and also faster than the old lyrics provider. - * Add script API function: Amarok.Collection.escape which escapes strings - for SQL statements. - * Some new and updated icons. - * Allow multiple items to be selected in the user playlist category. - * Statusbar rewrite: Messages are no longer shown as top-level windows. - * Added proper mouse over visuals to some places where it was missing. - * All services (or any other part of Amarok) can now add context - actions to any item in any collection. This is only used for the "play - similar artists from last.fm" currently, but it allows this kind of - action to be added without hardcoding it in the core. The immidiate - effect of this is that the last.fm action is now available for any - artist in any collection. - * New "playground" directory added for plugins and applets that are not - yet ready for prime time. - * Nonconsecutive items can now be selected and dragged around in the - playlist. - * Major overhaul of playlist subsystem, including a completely new view - (even though it looks a lot like to old one). Programmers should - review the SVN commit notes to learn about other changes. - * Selecting "Move to Collection" in the file browser's context menu - will now recursively include all directories within the selected items. - * Selecting "Move to Collection" in the file browser's context menu - will now delete the original source files as expected. - - BUGFIXES: - * Correct scrobbling for all tracks, even last.fm streams and loved tracks - in Last.Fm streams. (BR 164156) - * Files moved or organized into themselves are no longer deleted. - (BR 173341) - * Fix playlist scrollbar graphical errors with some styles. Patch by Huynh - Huu Long . (BR 173547) - * DBus MPRIS call GetMetadata returns the location field. (BR 173324) - * Amarok would not show all files it could play in the files browser - (BR 173333) - * Amarok now remembers its panel sizes over restarts. Patch by Gary - Steinert . (BR 172976) - * Automatic track score computation works now. - * Immediately remove the playlist drop visualiser from the playlist after - dropping an item. (BR 171382) - * Albums applet doesn't jumble up most recent albums listing. - * Fix problems with Amarok stopping playback after each track in some - cases. (BR 172897) - * Don't forget about downloaded images after doing a collection rescan. - * Fixed giant font in the Internet tab on some machines. (BR 172954) - * MPRIS Dbus interface Pause function conforms is a Play/Pause action. - (BR 173007) - * Script downloads using KNewStuff2 now correctly installs and uninstalls - scripts. - * Fix memleak in iPod handler. Thanks to Christophe Fergeau. - * Wikipedia applet: Fix infinite retry loop if no artist information is - found. (BR 171074) - * First track of an album in the playlist can now be dragged seperately - from the entire album. (BR 171331) - * Fix crash when searching in the shoutcast service. (BR 170681) - * Fix crash when adding multiple shoutcast stations. (BR 170247) - * Escape HTML characters from track metadata when showing the system tray - tooltip. Patch by Andrey Esin . (BR 172623) - * Only add one new folder when selecting "Add Folder" from the context - menu in the user playlist category. (BR 169666) - * Statusbar rewrite: Bring back the detailed progres operations view. - It is now possible again to get a list of all running operations and - to cancel each one individually. (BR 168380) - * Statusbar rewrite: The "cancel all" button now works. - * Statusbar rewrite: Don't hang on exit. (BR 171665) - * When searching in the collection, give keyboard focus to the results - after pressing Enter. (BR 172379) - * Do not set two different lyrics scripts as default. - * File sizes for non-collection local tracks are now determined properly. - * Track rating and score are now enabled for read-only files too. - * Play option from playlist context menu works now. (BR 172141) - * Cloud applet moved to playground as it still needs a lot of work. - (BR 170613) - * Playlist overhaul fixes a couple of bugs. (BR 167861) (BR 171048) - * Search queries with ' and \ now work fine. (BR 173330) - - -VERSION 2.0-beta2 - FEATURES: - * Add themable borders to album covers where ever they are shown (with - very few exceptions). - * Automatically check for collection changes on startup if monitoring - is enabled. - * Files can be moved into collections from the Filebrowser. (BR 170077) - * Clicking on the volume icon in the toolbar toggles mute. (BR 171017) - * Arrows to switch between containments directly. - * Scripted services can now show source info in the statusbar like most - other services. - * Scripts now able to access web via KDE-wide proxy. - * Middle click on playlist will append URLs from the clipboard. - * Numerous under-the-hood improvements to improve the stability of Amarok. - Rejoice! - * Incremental collection scanning support. (BR 169602) - * Playlists found during a collection scan are automatically added to - Amarok's Playlist Browser. - * Lyricwiki support. - * Chinese lyrics support from mp3.sogou.com - * Sidebars can be toggled with the keyboard: Ctrl+1..4 - * Now remembers visible/invisible state of browsers. (BR 168344) - * Add ability to play tracks directly off of MTP device. - * Add option to enable/disable automatic cover fetching. - - CHANGES: - * Add a new nice Service Info home page to the LibriVox script. Logo used with - Permision. - * Use custom stylesheets to ensure that html pages shown in the Wikipedia and - Service Info applets always have a nice white background. - * Jamendo service: Filter out genre names less than 3 characters long. This - gets rid of some uninformative genres like "3" and "07". All content is - likely still available under other genres. - * Switch from Sqlite to MySQL Embedded (libmysqld), resulting in faster - scanning and collection filtering times. - * When saving a new user playlist, the playlist browser immediately shows - the newly saved playlist and starts an edit operation on it. - * Many small visual and layout tweaks. - * Make the values for score, play count and time since last play appear in - tooltip when hovering over the icons in the current track applet. - * Make values for score, play count and time since last play in the current - track applet readable. - * The Librivox.org scripted service is back after a rather long, API-change - induced hiatus. - * Do not show the OSD if a stream repeatedly sends the same metadata. - * "Rescan Collection" was moved to the collection settings dialog. - * Do not always show status of cover fetching in the status bar. (BR 166946) - * The playlist drop visualiser respects system colours when drawn. - * Change the ordering of CurrentTrack applet information. - * The option for exporting playlists with relative urls has been moved - from the Amarok settings to the save file dialog. - * Show recently added albums on the albums applet when no track is playing - * The Love action in the Last.fm service is now available for all tracks, - not just Last.fm radio. - * Made album applets scrollable. - * Default the OSD to the middle top of the screen. - * New icons and layout for Context View navigation and applet manipulation - * Same default setting for proportional and fuzzy biases when filtering - by year. Patch by Andreas Mützel . - * Config is now written right after closing the settings dialog, making - it crash persistant. - * Improve Biased Playlist solver by using genetic algorithm. - * System tray tooltip is now translucent (if compositing is available). - * QtScript: Importer.include imports the file in the same context that it - is currently in. - * PodcastCategory now uses PopupDropper actions. - * Libgrypt is preferred over OpenSSL at build time, for licensing reasons. - - BUGFIXES: - * Fixed crash on startup when using --nofork option with a URL argument. - * Don't automatically refetch images after they have been removed. - (BR 169619) - * Fixed crash when playing certain podcasts. (BR 171890) - * Don't show the playcount and rating statistic twice in the system tray - tooltip. - * Files from a daap server can be played again. (BR 169565) - * Files copied from iPod devices had an incorrect file extension set. - * Don't crash when undoing an action which added tracks to an empty - playlist. - * Keyboard shortcut configuration is now remembered. (BR 170260) - * The playlist drop visualiser will snap to the end of the playlist if - required. (BR 171016) - * Enhanced keyboard navigation in the playlist. (BR 170489) - * Fix edit bookmark feature (BR 170008) - * Don't show scroll bars on the pixmap viewer when viewing a full sized - cover. - * Activate the SideBar tabs when dragging something over them. (BR 169712) - * Save composer and disc number correctly (BR 167184) - * Handle multidisc albums properly (BR 167238) - * Remove empty folders after organizing the collection. (BR 141555) - * Display rating (when present) in OSD. (BR: 167263) - * Make the currently playing track active in the playlist if it has been - removed and is later re added. (BR 167552) - * Detect Amarok 1.x style compilations when scanning the collection. - * Show the album year in the Collection Browser if requested. - * Make appending of podcasts to the playlist work. - * Fix text color of current track applet. (BR 168466) - * Lyrics applet is functional. - * Setting half ratings via global shortcuts was broken. - * Exporting of M3U and PLS playlists has been fixed. - * Make the PlayPause button actually switch icons again. (BR 169805) - * Add "Ignore field" token to the Guess tags dialog. (BR 161060) - * Only add supported file formats to the playlist. Patch by Andreas Mützel - . - * Clear the status bar when stopping playback. - * Albums applet no longer uses lots of CPU cycles. (BR 169586) - * Don't show the context menu in the Current Track applet if playback has - been stopped. - * Applets do not disappear if Context View is shrunk too much. (BR 169504) - * Fix last.fm events applet. - * The Current track applet now has tooltips for the icons on the right - hand side. (BR 168260) - * "Resume playback on start" now also restores the track position - correctly. (BR 168792) - * Fix layouting issues with tagging dialog. (BR 166837) - * Fix crash when closing last.fm settings while playing. (BR 168828) - * Make it possible to actually disable the audio fadeout. (BR 169022) - * Podcast Episode downloading doesn't crash anymore. (BR 168203) - * Dragging files to the playlist no longer appends, but drops in the - correct spot. - * Correctly order out-of-collection files dragged into the playlist. - (BR 169064) - * You can add directories from the Play and Add Media menus. (BR 166549) - * Allow statistics to be written out when we move to the next track, not - just when playback stops. - - -VERSION 2.0-beta1 - FEATURES: - * Inline editing of tracks in the Collection is now possible. - * Album moves can be undone - * Grouped albums can be moved in the playlist by draggin the album - header - * Track moves in the playlist can now be undone - * Gapless playback. - * New "fuzzy" bias type, which matches values loosely. - * Saving/loading dynamic playlists. - * Collection Setup automatically expands to show selected directories. - (BR 123637) - * Tag editing and file deletion for MTP devices - * Add toolbox to context view - * Allow selecting multiple playlist items. - * Implement "Move to collection" functionality in file browser. - * Saving/loading of biased playlists. - * Improved script console - * Set items in directory selector to partially checked when relevant. - patch by Sebastian Trueg - * Album is now added to the playlist when clicked in Albums applet. - * Trigger play/pause when middle-clicking systray icon. (BR 167162) - * New start flag --multipleinstances allows to run multiple instances of - Amarok. - * Full cover support for Nepomuk collection - * Search local collection for albums to show in the album applet when - playing non local content - * Context view state is saved on exit and restored on start up. - * New functions available to the scripting interface, under Amarok.Info. - - CHANGES: - * New filename scheme widget in the Organize Collection dialog. - * New laylout of the main toolbar using the new graphics. - * Greatly reduced memory usage when using dynamic playlists. - * Reworked layout and more intuitive interface in the Guess Tags from Filenames dialog. - * New artwork by Nuno Pinheiro and Wade Olson - - * Better zooming animation in the context view - * Better usage of the available space in the context view. - * Show url in the playlist if track has no name. patch by Edward Hades - (BR 167171) - - BUGFIXES: - * Fix crash when dragging media from an external source (or the file - browser) to the playlist (BR 169035) - * Fix crash when opening the setting dialog (BR 169215) - * Many fixes to the behavior of the playlist when dragging things around. - * Don't pop up multiple cover search dialogs when cancelling search in the - Cover Manager (BR 167462) - * Amarok would not respect the user's changes in the cover search dialog. - * Amarok would submit tracks to lastfm reguardless of whether the user chose to enable scrobbling. - * OSD translucency works now. (BR 166567) - * Use name based sorting of tracks without a track number (fixes - sorting in shoutcast and cool streams services) - * Don't try to scan the whole $HOME on first startup. - * Don't pop up the OSD after changing Amarok settings. (BR: 168197) - * Fix crash when exiting while collection scan was running. (BR 167872) - * Automatically re-authenticate connection if the Ampache server has - logged us out. (BR 166958) - * Status bar now allows shrinking main window beyond it's width and does - not enlarge main window by itself. Patch by Daniel Molkentin - (BR 166832) - * Submit tracks to Last.fm also when playing Last.fm Radio. (BR 164156) - * Check if the file is writable before allowing the tags to be edited in - SqlMeta. ( BR 122797 ) - * Properly insert items dragged from the collection view. (BR: 166609) - * Don't remove all the tracks in the group when removing the first. - (BR: 167251) - * Only increment playcount if we've played more than half of the song. - (BR 121587) - * Added protection against endless looping when a playlist contains only - unplayable tracks. - * Missing default playlist does not produce error message now. - (BR 167385) - * Fixed playlist bias drop-down box showing multiple empty and duplicate - entries. (BR 167153) - * Fixed the "Toggle Main Window" shortcut. (BR 167218) - * Script manager now could stop scripts which use qt bindings. - * Fix crash when calling GetCaps from the DBus Player interface - * Update album applet on track change. (BR 167256) - - -VERSION 2.0-alpha2 - FEATURES: - * New interface for extracting tags from filenames, now fully working. - * Context view applet to view albums. (BR 164005) - * Automatic detection of non-UTF-8 charsets for metadata. - * Dynamic/Biased playlists. - * QtBindings support for the scripts. Also add a GUI console demo script. - - CHANGES: - * Collection scanner now picks up bmp images too. (BR 167122) - * Update the DBus APIs. - * Update the QtScript APIs. - * Current track applet added to the Context View on startup. - * No more applets flashing between track changes. - * Current track applet now shows a message when no track is being played. - - BUGFIXES: - * Correctly save custom external browser setting. (BR 166979) - * Use default KDE crash handler again. - * Fix crash when switching tracks in the playlist. (BR 166964) - * Fix crash when trying to download a playlist from unreachable server. - * Script Manager now automatically restarts scripts on next startup. - * Correctly handle albums with the same name. (BR 164173) - * Various bugfixes for the systray tooltip. - * In the Wikipedia applet scrolling works properly now. - * Context menu separators are no longer shown as empty items. - * Make the filebrowser filter instantaneously display results for files. - * Add a path separator if required when constructing relative urls from M3U - playlists. (BR 166346) - * Rescan collection if the version is higher than we currently use - (downgrades). (BR 142712) - * Play the first track in the playlist if there is no active track. - (BR 166336) - * Do not use 100% cpu in the cover manager when changing view modes. - (BR 164112) - * Fix build on Debian. Patch by David Palacio . - (BR 166321) - * Fix bug with selection getting stuck in collection browser when selecting - multiple items when dragging over them. (BR 164960) - * Fix crash when removing collapsed album from the playlist. (BR 163653) - * Mp3tunes would load for users who had never used it before and prompt - them with an annoying login box. (BR 166332) - * Random album playback mode implemented. (BR 164623) - * Fix rendering glitches when double clicking tracks in dynamic mode. - (BR 166705) - * Make the rating widget on the current track hideable. - - -VERSION 2.0-alpha1 - FEATURES: - * Amarok defaults to using the standard music storage location of the - desktop environment. - * LastFM: Now using the new and improved 1.2 protocol. - * New Service Framework: Common framework for integrated services. A new - framework for adding the content of online services directly into Amarok - in a consistent and well integrated way. All services are plugins and can - be enabled or disabled form the new service config screen. Services that - are not loaded will not degrade performance or increase memory usage. - The service frameworks also offers for free, or makes it very simple to - add features such as cached albumcover downloads, searching and filtering - to the individual services. Services can also be track providers, meaning - that if amarok recieves a url that one of the services knows how to - handle, they will be presented with all the metadata that the servie can - provide. - * Magnatune.com store: Support for purchases using Magnatune gift cards - * Magnatune.com store: Support for the upcoming Magnatune.com stream and - download memberships, allowing uninterrupred streaming at higher quality - and free unlimited downloads respectively. - * Magnatune.com store: Add stream selection to the Magnatune service config, - allowing the selection of mp3, ogg or lo-fi mp3 streams, and make ogg the - default - * Jamendo.com service: Add new Jamendo service that allows for direct - streaming and (using the default bit torrent client) downloads. - * Mp3Tunes.com service: A service for streaming music from a personal - Mp3Tunes.com locker has been added. - * Ampache service: A new ampache plugin has been built on top of the service - framework. Together with a recent version of Ampache, this allows the - seamless integration of content from one or more Ampache servers directly - into Amarok - * OPML Directory service: A simple podcast directory service has been added - * Shoutcast service: The shoutcast list from previous versions of Amarok has - been reimplemented as a service. - * Scriptable Service Manager: Add support for writing simple services using - scripts. This allows quick prototyping of services as well as the - integration and distribution of community created services. The scripted - service can be started and stopped from the service manager. Also add 2 - simple demo scripts. - * Playlist Framework: The Playlist Browser can now contain - Playlists/Podcasts/Streams from any mediadevice/service/collection in - addition to local files. Playlists are accessible by any Amarok subsystem - and scripts. - - CHANGES: - * The context view was reimplemented with Plasma technology from KDE. - * The audio engine system was removed. Amarok now uses Phonon from KDE. - * Debugging output is now enabled with a runtime option (--debug). It's no - longer necessary to rebuild Amarok. - * Removed the amarok loader application. - * The custom color theme options have been removed. - * The player window (small XMMS like thingie) was removed. - * DCOP interface replaced with D-Bus. - * Dependencies lifted to KDE 4.1 and Qt 4.4. Refer to the README. - * Improved the startup time. - * The magnatune store is now implemented as a service, making it much more - seamlessly integrated with the rest of Amarok, and offering a number of - benefits such as propper filtering and sorting, automatic downloads and - caching of albums cover. - * Podcast fetching uses the new QXmlStreamReader with incremental parsing. - - -==BEGIN Qt 4.4 / KDE 4.1 DEPENDENCY== - -VERSION 1.4.8 - BUGFIXES: - * Make sure the localUrl of a PodcastEpisode is valid after a failed - download. (BR 147351) - * Fix off-by-one error causing Smart Playlists to not load tracks with a - rating >= 4.5. (BR 148916) - * Don't enable "Configure Podcasts" at the top-level Podcasts folder if - there is nothing beneath it. (BR 146504) - * Generic Media Device could copy some non-ASCII filenames to turn to - gibberish. Thanks to David Smith for the fix. - * Fixed possible GUI freeze when Amarok was showing the dialog for - installing mp3 support. Patch by Sascha Sommer . - (BR 147126) - * Amarok could needlessely reinitialize connections to MySQL databases - after a configuration change. Combined with a bug in MySQL libraries, - this could lead to a crash. - * Pressing Preveious Track in a Dynamic Playlist could cause undefined - behavior in certain edge conditions. Now it always plays the current - track. (BR 148317) - * Immediately after loading a dynamic playlist, you couldn't drag a - track to the top of the playlist. (BR 149263) - * Fix transferring files with UTF8 names to MTP devices. Thanks to Kevin - Becker for the fix. (BR 139722) - * Display warning that iPod sysinfo could not be written in the case of - incorrect file permissions. Patch by Christian Ober-Blöbaum - . (BR 148607) - * Fix Czech character conversion to ASCII for Generic Media Device. Patch - by Matěj Laitl . (BR 149125) - - -VERSION 1.4.7 - CHANGES: - * Updated the Cool Streams. - * Improved application icon. Thanks go to Pasi Lallinaho. - * Upgraded SQLite to 3.4.1 - * SQL improvements providing optimisations on intensive queries. Patch by - Gosta . (BR 142999) - - BUGFIXES: - * Wikipedia artist lookup would freeze Amarok if the artist was not found - and the locale was not English. (BR 142764) - * Cannot limit smart playlists to more than 1000 tracks. (BR 148084) - * Fixed the formatting in the "Extended Info" pane for podcasts. - * Don't show "Not Rated" for items rated with half a star. Patch by Tuomas - Nurmi . (BR 144675) - * Copy, don't move items from Cool Streams to folders. (BR 147404) - * Sometimes folders in the playlistbrowser could be lost. (BR 147404) - * NJB devices could have tags corrupted that contained Unicode characters. - Patch by Kun Xi . (BR 147223) - * Show OSD when changing song rating via shortcut. Patch by Tuomas Nurmi - -VERSION 1.4.6 - CHANGES: - * Improved icon theme, kindly provided by Landy DeField - . Big thanks! - * Playlist now sends notifications to scripts if items are added, removed, - reordered, or if the playlist is cleared. Useful for script authors. - Thanks to Miguel Angel Alvarez for the patch. - * iPod device plugin now handles RockBox devices. Thanks to Michael - Buesch for the patch. - * Organising files will only delete empty parent folders if the folder - is within the collection hierarchy. (BR 136757) - * The default cover image preview size has been increased to 130px. - * The "hide menubar" option has been removed. It's too dangerous and led - to countless support requests. - * Generic media device can now handle any KIO-compatible URL, including - obex and smb. Manage your bluetooth phone's music collection through - Amarok! - * Upgraded SQLite to 3.3.17. - * Append an album to the playlist by right-clicking on it from within - the Cover Manager. Patch by Doug Reich . - * Faster playlist handling. Patch by Ovy . (BR 142255) - * The moodbar process has been given a higher priority. (BR 136867) - * Allow for lyrics scripts to specifiy site, site_url, and add_url from - within the script. This will allow for "meta lyrics" scripts. Patch by - Sergio Pistone . (BR 141885) - * First rating star now lets you toggle between no rating, half a star, - and one full star. - - BUGFIXES: - * Uninstalling scripts would in some cases leave files behind. Patch by - Sergio Pistone . (BR 143716) - * Last.fm "Custom Station" stream works again. (BR 146020) - * Fix regression where the "Show Script Manager" button displayed on the - Lyrics tab of the Context Browser wouldn't actually show the Script - Manager. - * Don't show ratings from the previous track's rating change in the OSD on - playing the next track. - * The config dialog is now less tall and fits on widescreen displays. - * Making a dynamic playlist with the number of previously played tracks to - show set to zero and attempting to play the first track would cause a - crash. (BR 145157) - * If "Stop after current track" was used, the last track would not be - counted or rated in the user's statistics. (BR 140980) - * Generic media device wouldn't allow you to drop a folder on the - viewport, meaning you couldn't move subfolders to the top level of the - mount point. - * Made the settings dialog less tall. (BR 141250) - * Star ratings now update instantly in the Context Browser, OSD, and - Collection Browser. - * lyrc script did not work behind proxy due to a stray quote mark. Gentoo - -VERSION 1.4.5 - FEATURES: - * Added support for custom song labels. Labels can be managed - through the GUI or using new DCOP functions. (BR 89314) - * New DCOP functions to make it easier for scripts to use Amarok's - Dynamic Collection feature. - * Download songs from Shared Music (DAAP) directly into the collection. - * Fadeout for Helix engine when pressing Stop. - * Guided editing of the collection/playlist/devices filters. Patch by - Giovanni Venturi . (BR 139292) - * Added GUI options for fadeout and fadeout on exit. Both are now enabled - by default. - * Support for Speex (.spx), WavPack (.wv) and TrueAudio (.tta) files in - the collection thanks to taglib plugins by Lukáš Lalinský - . - * Search inside of lyrics, by using "/" on Context Browser. Patch by - Carles Pina i Estany . (BR 139210) - * "Automatically show context browser" feature makes a return, as per - popular request. It is however disabled by default. - * Improved keyboard navigation: Space key is now a shortcut for Play/Pause, - and cursor left/right seeks forward/backward. - * Cover images are shown in collection browser. Patch by Trever Fischer - . (BR 91044) - * Send cover art to MTP media devices if they support it. - * Elapsed time can be shown in OSD. Patch by Christian Engels - . (BR 120051) - * New redownload manager for the Magnatune.com store. Allows re-download - of any previous purchase free of charge (in any format). - * New items in the playlist are colorized, as a visual cue. - * Show rating as stars in flat collection view. Patch by Daniel Faust - . (BR 133797) - * Synchronize play count, last played time and date of modification to - iPods. Patch by Michael . (BR 136759) - * Propose list of composers in collection when editing the composer tag - from the playlist. (BR 137775) - * Greatly improved sound quality for the xine equalizer. Patch by Tobias - Knieper . (BR 127307) - * Fancy graphical volume slider for the OSD. Patch by Alexander Bechikov - . - * Shoutcast stream directory. Contributed by Adam Pigg . - * Support for %composer and %genre when guessing tags from filenames. - * Cached lyrics are now AFT-enabled, and will follow your files around as - you move and rename them. - - CHANGES: - * Added configure option to build without DAAP support. - * Album covers are now downloaded and added to album directory when - purchasing from the Magnatune.com store. (BR 136680) - * Update context browser when a change in the collection has been detected. - (BR 140588) - * Ignore leading 'The ' when sorting playlist by artist. (BR 139829) - * Smart Playlists now have 'does not start with' and 'does not end with' - options, as well as a dropdown for mount points. (BR 139552) - * Support for cue files not matching audio files' name. Patch by Dawid - Wróbel . (BR 128046) - * Script Manager now remembers if categories were open or closed. - * Restart collection scanner as long as not more than 5 % of the files - make it crash. (BR 106474) - * Ensure the first selected item in the Collection Browser stays visible - when the search field is cleared using the clear button. - * Duplicate filenames are now allowed on MTP media devices if the files are - in different folders. - * Save media device transfer queue when adding items or after transfers. - (BR 138885) - * Upgraded internal SQLite to 3.3.12. - * MTP media devices are not automatically connected on start-up. This - should solve slow loading times for those with large collections on an - MTP media device. Contributed by Mikko Seppälä. (BR 138409) - * Internationalize unknown artist/album/genre strings. Contributed by Mikko - Seppälä. (BR 138409) - * Don't assume that a device returning 0 tracks is invalid. It could just - have no tracks on. Contributed by Mikko Seppälä. (BR 138409) - * Magnatune store look now matches rest of Amarok much better. - * Album art is displayed on the Magnatune purchase dialog. - * Generic media device now has an option to force VFAT-safe filenames even - on non-VFAT filesystems. - * Double-clicked items in sidebar and urls passed on the command line - are treated equally: append them to playlist if not yet there and start - playing the first if nothing is playing. - * "Scan Changes" button was replaced with "Update Collection" menu entry. - * Consistent double-click behavior in sidebar. (BR 138125) - * Propose name of currently loaded playlist when saving current one. - * Remove support for older libmtp versions. We now require 0.0.15 or - newer. - * Deleting a playlist item on an MTP media device now results in it being - removed from the playlist. - * Magnatune store is lazy loaded to improve startup times. - * Dynamic mode logic has been rethought to provide a faster and better - user experience. - * When checking for duplicate files on a Rio Karma media device, use - track number in addition to artist, album & title. (BR 137152) - * The XMMS visualization interface has been removed. LibVisual supersedes - this feature. - * It is now possible to select the time unit for length-based smart - playlists. (BR 136841) - * Show shadowed cover images in the system tray tooltip. (BR 136589) - * Amarok won't crossfade if it was paused, and user started another - track. Patch by Tuomas Nurmi . - (BR 136428) - * Amarok now saves playlists with relative paths by default. - - BUGFIXES: - * Disable seeking in streams. (BR 140364) - * With the default theme, the playlist browser info pane would not show - the horizontal scrollbar if necessary. (BR 134221) - * Some .rm files would make Amarok crash. (BR 137695) - * Remember 'User Cover Art for Folder Icons' when organizing files. - (BR 138582) - * "Listening since..." has been changed to the more clear "First - Played..." Patch by Andrew Ash . (BR 131727) - * Fixed regression: the DEL key no longer worked in the - playlist after opening the File Browser context menu. (BR 140197) - * Smart playlists now work correctly with "is not" filters containing - numbers. Patch by Felix Rotthowe . - * Context browser would not display updated covers correctly. (BR 130518) - * The select custom cover dialog no longer starts in the wrong directory - for compilations. (BR 131776) - * Amarok's xine engine would cut off approximately the last second of an - audio file. (BR 135190) - * Cue sheet would remain enabled when switching to a stream. Patch - by Ted Percival . (BR 127683) - * Length of tracks wouldn't be shown correctly for some cue files. - Patch by Dawid Wróbel (BR 139707) - * Assume that all dots but the last in script executable files belong to - the script name. (BR 139460) - * Don't crash when quitting while initially loading the playlist. - (BR 136353) - * The same track could be queued multiple times for transferring to a - media device. (BR 129136) - * Migrate statistics for files moved from outside to the collection. - (BR 127776) - * Select All/Copy action would not copy from context browser. (BR 138635) - * Xine-engine: When a track was fading out (after pressing Stop), and you - started another track, Amarok could become unresponsive. - * Improved seeking with xine-engine. No longer jumps to 0 when you seek - too quickly. Patch by Alexander Bechikov . (BR 99808) - * Improved cover images handling for Various Artists. Patch by Tobias - Knieper . (BR 136833) - * Don't enable a mount point for devices that can't support them (mtp, - njb). - * With SQLite, the search in the collection browser was case-sensitive - with UTF-8. Patch by Stanislav Nikolov . (BR 138482) - * (Don't) Show Under Various Artists would not work when multiple albums - are selected. Patch by Tobias Knieper . - (BR 112422) - * Changed temp download location for Magnatune purchases. (BR 137912) - * Fixed potential double payment issues in the Magnatune store. - * Only synchronize already set values to media devices. (BR 138150) - * Correctly update total playlist play time when removing last.fm - streams. Patch by Modestas Vainius . (BR 134333) - * File organization jobs could not be canceled. Patch by Wenli Liu - . (BR 136527) - * Sending filenames to MTP media devices as UTF-8 caused problems, use - Latin-1 instead. - * It's now possible to delete a file from an MTP media device and - re-upload it without having to reconnect the device. - * Wikipedia links to edit sections are no longer shown. - * Metadata is read from Rio Karma media devices as UTF-8. - * Last.fm streams could be paused with DCOP or global shortcuts. - (BR 133013) - * Dynamic mode can still be used after a collection rescan. (BR 133269) - * Dynamic mode will repopulate from all available sources. (BR 137212) - * Dynamic mode no longer repeats songs often. (BR 107693) - * When transferring files to a Generic media device, having certain - characters (such as '#') in a tag field could cause a directory based on - that field to not be created. - * Editing lyrics from within the context browser no longer removes all - linebreaks. - * Read metadata from MTP media devices as UTF-8. - * Some shoutcast streams would show an empty title. (BR 127741) - * Pause would act as Play/Pause. (BR 116101) - * The same track would sometimes be shown twice in suggested songs. - (BR 129395) - * Detect VFAT partitioned devices on FreeBSD. Patch by Daniel - O'Connor . - * Favorite Tracks wouldn't be shown on Context Browser, and - Statistics Panel would be empty for SQLite users. (BR 136791) - * Volume slider in the player window would not react correctly to - the mouse wheel. (BR 136714) - * When using a proxy set by script, context browser wouldn't work - properly, and the application would crash when closing. (BR 112437) - * Proxy settings wouldn't be respected when downloading podcast - episodes. (BR 134028) - * Xine engine could hang when skipping through tracks quickly with - crossfade on. - * Fix crash when an MTP media device returned a playlist with an - invalid track ID. (BR 136552) - * The Install MP3 support script would be run regardless of what the - user answered to the shown dialog. (BR 136294) - * OSD wouldn't always show up-to-date ratings. Patch by Tuomas Nurmi - . (BR 125612) - - -VERSION 1.4.4 - FEATURES: - * Transfer .wav-files to iPods. (BR 131130) - * Xine and Helix engines now support three different crossfading modes: - always, on manual track changes only, or on automatic track changes - only. - * Manually specify local file for podcast episodes via right-click menu. - * Action menu entry for adding podcasts to Amarok. Based on .desktop files - by Harald Sitter and Fabio Bacigalupo . - * Open podcast items with external application from right-click menu. - * Synchronize listened flag for podcast between Amarok and iPods. - * Added integrated Magnatune.com music store. Includes artist and album - info and full previews of all tracks. - * Fade-out for xine-engine when pressing Stop. Patch by Tuomas Nurmi - . (BR 127316) - * Support downloading of files from an MTP device. - * Purged podcast episodes can be readded by increasing the purge number. - * Added rudimentary support for the Rio Karma. (BR 132713) - * Support creation and editing of playlists on MTP media devices. - * Undo/Redo functionality is now available over sessions. (BR 131072) - * Allow the creation of empty playlists in the playlist browser. Available - either from the Add button in the toolbar or the context menu of a - playlist folder. (BR 133543) - - CHANGES: - * Ignore leading "The " when sorting artists on media devices. (BR 136233) - * Improved handling of VFAT/ASCII files and paths when organizing the - collection and using the Generic media device. - * Enable playing audio CDs on CD insert. Patch by Will Stephenson - . (BR 136106) - * Bring Amarok main window to front when starting amarok again without - arguments. Patch by Lubos Lunak . (BR 135396) - * Don't switch to playlist browser after saving a playlist from files tab. - (BR 130189) - * Add .ape and .mpc to possible file types supported by a generic media - device. (BR 133491) - * Move button for saving current playlist from playlist browser toolbar to - playlist toolbar. (BR 129300) - * Run 'kdeeject -q devicenode' when no post-disconnect command has been - configured for media devices. - * Reduced memory usage for MTP media devices. (BR 134663) - * Faster searching on playlist and startup, due to some optimizing in - string usage. Patch by Ovidiu Gheorghioiu . - * Correctly translate media:, home:, ... style urls on KDE 3.5 and newer. - * When tracks are added to the collection and Playlist entries already - exist (as determined by the file tracking code), the corresponding - Playlist entries are updated to the new location and enabled if they - were previously disabled. - * When file tracking is updating Playlist entries, multiple entries of the - same song will now all be updated, instead of just one. - * When tracks are removed from the collection (deleted on disk or moved - outside of a collection folder) any corresponding entry in the Playlist - will be disabled. - * Dragging podcasts to to playlist will insert them in a chronological - order, so you can listen to the oldest first automatically! - * Improve application startup times dramaticaly by lazy loading podcast - episodes. - * Transferring tracks to an MTP device now shows a progress bar and - doesn't hang the rest of the UI. (only available for libmtp >= 0.0.15) - * Show a proper tag dialog when viewing information for DAAP music shares. - - BUGFIXES: - * Ipod Mode on Collection Browser would have duplicated headers. - * Multiple problems related to Amarok using wrong playlists on Dynamic Mode - fixed. - * Deleting files from generic media devices would not update the progress - bar, resulting in the progress staying at 0%. (BR 130009) - * If nothing at all existed on a generic device, the first item - transferred would incorrectly show that an error had occured during - transfer. (BR 133528) - * Synchronising a smart playlist to a device when it didn't exist before - would crash Amarok. (BR 135956) - * Proxies would not take into account certain settings in KDE's Proxy - control center modules for PAC files and more. (BR 123021) - * Generic media devices would not accept files with an extension that only - differs in case from a supported extension. (BR 135261) - * Xine-engine: Pausing during crossfade would not work properly. Patches by - Markus Kaufhold . (BR 122514 & 135285) - * Stop a running cross-fading operation before starting another one. Patch - by Markus Kaufhold . (BR 128629) - * Queuing again would dequeue. (BR 121206) - * In some cases, the Removal and Enqueue buttons in the queue manager would - have no icons. (BR 115895) - * Don't change length of position slider when navigating within a track. - (BR 122569) - * Direct copying of non-local items would result in wrong properties on - iPods. (BR 135681) - * Honor setting to show Amarok's menu in main toolbar. - * "Burn this album" would burn all albums of the same name. (BR 121963) - * Ignore double-clicks on tree item openers. (BR 125121) - * Visibility of sidebar tabs would depend on the current locale. (BR 135316) - * Ctrl-C for copying urls from the tag editor would not work when selected - with the mouse. (BR 123327) - * Check for some integral data types for improved DAAP portability. - (BR 132939) - * Take disc number into account when checking if a song is already on an - iPod. (BR 135643) - * Editing metadata in the playlist itself now matches possible alternatives - case-insensitively. (BR 135683) - * Fix loading directory in external browser in the tag editor when the path - contains parentheses. (BR 132961) - * Stop scripts using a proxy when it's disabled in KDE. Patch by Felix Geyer - . - * While playing Last.fm Streams, sometimes metadata wouldn't be updated - on track changes. Patch by Tom Kaitchuck . - * Speed patch to load playlist columns from statistic tables on population - of the playlist, makes adding to the playlist and starting up faster. - Thanks Ovy ! (BR 135324) - * Save MTP playlists when they are renamed so we don't lose changes. - * Prevent new podcastepisodes from showing up in the playlistbrowser twice - by opening it's parent before adding. (BR 134108) - * New iPods would not get initialized. - * Files that were detected as being added back to the collection would not - always be re-enabled in the Playlist. (BR 130359) - * Fix some spelling and layout issues. Part of a patch by Malcolm Parsons - . - * Correctly handle horizontal wheel events in position slider. (BR 119254) - * Don't rescan collection while transcoding. (BR 133423) - * Don't try to copy to collection from urls without kio slaves. - * Don't quit immediately if amarokrc was removed. (BR 134439) - * The DAAP client would crash Amarok under certain conditions when - kdelibs was compiled with asserts on. (BR 132851) - * Configuring the toolbar would disable the stop button. Patch by - Markus Kaufhold . (BR 132477) - * Changed tags of songs on iPods would not propagate to its database. - (BR 133842) - * Fixed playlist encoding problems. (BR 133613) - * Cover images for compilation albums can now be displayed full size in - the context browser. - * Dragging compilation albums from the collection browser or the playlist - would show multiple cover images in the tooltip. (BR 133916) - * Don't crash when calling repopulate dynamic mode from dcop. (BR 133716) - * Last.fm streams work with proxies. (BR 131137) - * Don't try to read m4a tags from apparently invalid files. (BR 133288) - * Some podcasts would insert line breaks in author/title information and - cause graphical errors. (BR 133591) - * File tracking could fail on files that were copies of each other but - with different ID3v1 or APE tags. - - -VERSION 1.4.3: - FEATURES: - * New DCOP: player trackCurrentTimeMs, returns the current track position - in milliseconds. - * Amarok File Tracking (formerly ATF) goes public! See - http://amarok.kde.org/wiki/Amarok_File_Tracking for more information. - * DAAP client now supports Zeroconf. With mDNSResponder properly setup - Amarok automatically shows local DAAP servers. - * DAAP client saves manually added computers between sessions. - - CHANGES: - * Performance with big playlists has been improved by a magnitude. This - also makes application shutdown faster. - * Remove the option to enable/disable history in dynamic mode. (BR 133076) - * Reduce the minimum available tracks to show to 0. (BR 131223) - * Change in file tracking behavior: IDs are no longer embedded into tags - but are calculated from a portion of the file data instead, letting - users with read-only music stores take advantage of it. - * Don't report "/dev/hd" style devices as new media devices. (BR 127831) - * Smart Playlists only load media from currently mounted devices. - - BUGFIXES: - * Dequeuing tracks whilst in dynamic mode might not work. (BR 133449) - * When marking podcast episodes as listened, update the channel icon if - necessary. (BR 133497) - * Don't always mark podcast channel icon as "listened" on rescan if. - (BR 133495) - * User added streams were not editable once saved. (BR 133483) - * Cover images were not displayed in some cases. (BR 133174) - * Fixed bug which prevented Amarok from creating the collection database - in rare circumstances using SQLite. (BR 133072) - * Collection scanner would only restart a maximum of 2 times instead of - 20. (fixed in SVN revision 578922) - * MTP media device support would not compile against libmtp versions >= - 0.0.12. (fixed in SVN revision 576121) - * AudioCD playback would stutter and sometimes freeze Amarok. (BR 133015) - * Dynamic Collection broke flat collection view when the Filename column - was added (BR 132874) - * DAAP client shows connection errors to the user and no longer says - "Loading" perpetually. After a failed connection, the user can now - try again. - * Don't empty media device transfer queue when canceling a transfer. - * Ctrl-C for copying urls from the tag editor would not work. (BR 123327) - * Delete covers from the filesystem when requested. - * Show context menu on right-click in empty area of media device - browser. (BR 127154) - * Sort numeric columns in flat collection view numerically. (BR 130667) - - -VERSION 1.4.2: - FEATURES: - * Handle itpc:// and pcast:// url protocols for adding podcast feeds. - (BR 128918) - * New DCOP call "collection: totalComposers" returns the number of - different composers in your collection. - * Synchronize playlists to media devices. - * Support for MTP/PlaysForSure media devices. (BR 128532) - * iPod plugin usable with iTunes phones. (BR 131487) - * Browse collection by composer. (BR 122452) - * New DCOP call "playlist: filenames" returns the filenames of the songs - currently in the playlist. Patch by Arash Abedinzadeh - - * Lyrics can be edited directly on Context Browser's Lyrics tab. - * Collection browse mode similar to that used by some portable players. - Patch by Joe Rabinoff . (BR 130586) - * BPM field. Patch by Alf B Lervåg and Aaron - VonderHaar . (BR 123142) - * Improved crossfading for xine-engine: Honours the 'Crossfade Length' - setting precisely, and uses a better mixing style profile. Patch by - Enrico Ros . - * Media and collection browser tabs now support dropping. - * Allow for deleting all the tracks on a playlist from iPods. (BR 127855) - * Ability to create custom last.fm station from the GUI. - * Ability to mark podcasts as listened. - * Show error messages when connecting to last.fm streams fails. - * A new media device implements a DAAP client. So Amarok can connect - to iTunes, Firefly Media Server etc. (BR 100513) - * Dynamic Collection: improved support for songs on removable external - harddisks, SMB and NFS shares - - CHANGES: - * Skip tracks that failed to transfer to media devices instead of stopping - transfer process. (BR 130008) - * libtunepimp 0.5.0 actually compiles successfully now. - * Lift size limit on pathnames and comments in collection databases not - managed by MySQL. (BR 130585) - * Generic media device plugin is improved. Users can configure supported - filetypes and get more control over the location of songs and podcasts - on disk (Patch by eute). - * Move composer tag to its own database table. - * Re-enable adding videos to iPods with recent libgpod-cvs. (BR 130117) - * Include Skip, Love and Ban in playlist right-click menu for last.fm - streams. - * Advanced Tag Features (ATF) deferred to 1.4.3: Public release delayed - pending some bug fixes in both Amarok and a dependency. It will be - automatically disabled the first time you run 1.4.2 if you had it enabled - from 1.4.2-beta1. (It will still be available in subversion snapshots.) - * Optionally finish transferring all queued tracks to media device after - pressing disconnect button. (BR 129716) - * It's now possible to edit scores and ratings for multiple tracks in - TagDialog. - * TagDialog won't make Amarok unresponsive while committing tags changes - to files anymore. - * Exact playtime as tooltip in statusbar. Patch by Markus Kaufhold - . (BR 130463) - * Suspend collection rescanning while organizing files. (BR 129885) - * Always use metadata from original file for transcoded files transfered - to media devices. (BR 131171) - * Enhancements to ATF/statistics to allow for better tracking of stats as - files are moved. - * Tag Editing Dialog is now ATF-enabled. - * In-line tag editing is now ATF-enabled. - * Previously, using ATF with MP3 files would wipe out existing UFID frames - from other applications. Now Amarok plays nicely and only touches its - own UFID frame. - * ATF no longer requires a restart to enable or disable it. - * ATF read-only functions are always enabled if a UID is found in the - file. Option in the configuration dialog now only controls whether new - UIDs are written to new files. - * ATF will now automatically run the rescan and clear the Playlist only on - the first time it is enabled. After that it will simply display an info - reminding users that they may need a rescan if their library has changed - since the last time it was enabled. - - BUGFIXES: - * DCOP calls to add and remove ATF tags are no longer allowed to run while - the collection is being scanned. - * Last.fm streams no longer freeze Amarok's GUI with xine-engine. - * Sometimes metadata wasn't updated with Last.fm streams. - * Update context browser on score and rating changes. (BR 132496) - * Double colons in the collection filter would lead to invalid queries. - (BR 132551) - * Handle changed semantics of MySQL 5.0.23+ (BR 132114) - * Do not try to detach() KURLs, as this would not work for non-ascii urls. - (BR 132355) - * Adding songs while at end of playlist could crash in dynamic mode. - Patch by Joe Rabinoff . (BR 128340) - * Don't update accessdate when setting songs rating or score. (BR 132274) - * Increasing or decreasing volume while muted would not correctly unmute. - (BR 132228) - * Better resize behavior in iPod collection view mode. Patch by Joe Rabinoff - (BR 132016) - * Make sure a track's compilation status is returned properly when running - with Postgresql. - * Check directory structure on iPods of unknown type in order to detect - iTunes phones. (BR 131910) - * Make 'Clear' individually translatable for playlists. (BR 131521) - * Retain column visibility for flat collection view. (BR 126685) - * Honour proxy exceptions for MusicBrainz lookups. Patch by N. Cat - . (BR 131377) - * Correctly pass links containing parentheses to external browsers. Patch - by Thomas Lindroth . (BR 131307) - * iPods would not show podcast descriptions. (BR 129824) - * Carry over rounding increments to next larger unit for fuzzy time - display. (BR 131383) - * If disabled, don't show splash screen - even on Kubuntu. (BR 125210) - * Correctly request last.fm similar artist information for artists - containing non-ASCII characters. Patch by Thomas Lindroth - . (BR 131254) - * Support non-chronologically ordered podcast feeds. (BR 119911) - * Support for libvisual 0.4.0 was fixed. Patch by Dennis Smit. - * Adding songs already on a media device to playlists would not work. - * Fix adding smart playlists to media devices. (BR 130540) - * Reverse check for mount point and device node when connecting to iPods - for better handling of device nodes pointed to by symlinks. (BR 129965) - * Make handling of filenames on iPods case-insensitive and thus fix - fix problems with too many orphaned and stale items. (BR 126431) - * Correct action of queueing current item in dynamic mode. (BR 130313) - * Double clicking in the filebrowser will append to playlist. (BR 117465) - * Fixed problems with last.fm streams containing spaces, e.g. "Hip Hop". - * When generic media devices were specified manually, transferred files - would not always get converted to VFAT-friendly names if they were on a - VFAT filesystem. - * When using ATF, tags in MP3 files would be written as ID3v2 only and - existing ID3v1 tags would be stripped, which could lead to media devices - and tagging libraries that were not ID3v2.4-aware to report that no tag - existed. Now both tags are written with identical data. - * Correct handling of filenames with special characters. (BR 132243) - - -VERSION 1.4.1: - FEATURES: - * Support for last.fm streams. (BR 111983) - * New playlist toolbar menu entry for adding streams to the playlist. - (BR 129349) - - CHANGES: - * Upgraded internal SQLite to 3.3.6. - * Inotify support disabled for now, due to stability issues. - * Tag editor is no longer modal. - * Provide warning dialog when deleting items from the playlistbrowser. - (BR 129313) - * GUI layout reverted to the classic Amarok layout. - * The Extended Info panel in the playlistbrowser is now resizeable. - - BUGFIXES: - * Pressing return in the search bar of the Collection Browser immediately - after typing a query no longer appends the wrong items to the playlist. - * Fix crash when pressing Back or Forward buttons multiple times quickly - in Artist tab. Patch by Thomas Lindroth . - * Fix problems where blanks would be added to data if SQLite was busy. - Patch by Thomas Lindroth . (BR 127608) - * Automatically refresh stream lyrics on new metadata. - * Set half star ratings on multiple selected tracks when clicking on an - item. (BR 129449) - * Only enable Show Extended Info in the Playlist Browser when information - is available. (BR 126590) - * Disable global shortcut for ratings when ratings are disabled. - (BR 129414) - * Autodetect button in Media Devices configuration dialog would not - properly signal changes, so that new devices were not always saved. - - -VERSION 1.4.1-beta1: - FEATURES: - * Much improved and completed custom icon theme by Vadim Petrunin - . - * LibVisual 0.4 supported and required. - * Support for custom scoring algorithms, via scripts. - * Creative Nomad Jukebox support (untested!). Submitted by Andres Oton - . (BR 103185) - * Inotify support. On kernels 2.6.13 and above with Inotify support - compiled in, the collection will automatically be rescanned and - updated as soon as a watched folder has changed. - - CHANGES: - * First-run wizard can no longer be restarted from the application menu. - However, it can still be invoked with "amarok --wizard". - * Astraweb lyrics script was removed for being crappy and unmaintained. If - you want to maintain it, grab it from SVN and release on kde-apps.org. - * "Append Count" option of dynamic playlists has been removed. It is - now always one. (BR 120044) - * Context browser can now play/queue specific discs of an album or - compilation. - * Automatically imported playlists go into a separate category. - * Block quitting amaroK until all on-going media device operations have - finished with a consistent state. - * Interface choice in wizard removed. - * MoodBar has been removed. The maintainer has not been updating it, and - it was causing crashes for many people. - * Usability improvements for the Script Manager, including a tree view. - * Use KMimeType for resolving file type for metadata acquisition before - falling back to extension based guessing. - * Removed the "detailed mode" in the playlist-browser. - * Also copy non-local URLs to collection when dropped onto collection - browser. - * Speed up connecting media devices with a lot of tracks to be submitted - to last.fm. - * For media without metadata, try to read metadata after transfer to - the iPod (e.g. when copying an audio CD via KIOslaves). - * Hint at starting a transcode script for transcoding while transferring - to media devices. (BR 127155) - * If a disc number is present, append it to the album's name when - organizing files. (BR 126867) - * Configure, which of fresh podcasts, newest & favorite albums are shown - in context browser home view. Patch by Patrick Muench . - (BR 127043) - * Dynamic mode no longer skips to the next song if you press play (via - dcop, for instance) while already playing a track. Instead it restarts - the current one. - * The Actions menu has been renamed the Engage menu. It's way cooler, - right? I mean, Star Trek is really cool, right? - * Multiple podcasts can be configured at once by selecting multiple channels - or by configuring the children of a folder. - - BUGFIXES: - * Allow dropping of tracks after non-existant items in the playlist. - * Make changes to the default dynamic playlists persistent. - * Send UTF-8 encoded requests to Wikipedia. Thanks to Thomas Lindroth - for the patch. (BR 127654) - * Correctly restore podcast channel title when fetching fails. - * Show error message when xine mp3 decoder isn't installed, don't just - play next track. - * Properly render and optimise playlist loading icons. - * Properly import and export XSPF playlist formats. - * Optimise addition of playlists to the playlistbrowser. - * In context browser, show localized date for podcasts. (BR 127853) - * Regression in dynamic mode caused it to skip the first track in the - playlist whenever it was started. (BR 127451) - * Stop Playing after Track: remember current track (BR 127312) - * Radio streams were broken for protocols other than HTTP. (BR 127848) - * Collection Browser would not set/unset/burn albums with ', The' in - their name. - * Prevent breakage when xine couldn't initialize the audio device. Patch - from Ilya Konstantinov . (BR 115960) - * Allow for recognition of the webdav protocol. Patch by Ilya - Konstantinov . (BR 126847) - * Setting a rating on an unplayed track would affect score generated. - Patch by Patrick Muench . (BR 127475) - * Stop tags with different capitalisation being treated as the same - when building the collection. - * Make database connections actually get closed when no longer used. - (BR 123113) - * xine engine would truncate the last seconds of a track, if no other - track followed in the playlist. - * Fixed AudioCD playback with xine-engine. Patch by Markus Kaufhold - . (BR 127388) - * If dynamic mode was turned on and then off, the previous random and - repeat modes would be forgotten. (BR 123743) - * Removing the current track through DCOP while editing a field of the - track in the playlist would cause a crash. (BR 119152) - * Make characters encoded with % (such as a forward slash, %2f) display - correctly. (BR 105266) - - -VERSION 1.4.0: - FEATURES: - * New DCOP call "player: version()". Returns the amaroK version. - * iFP has persistent settings when transferring tracks to the device. - * GStreamer-0.10 engine now supports Audio CDs. - * Context menus for entries in the statistics tool. (BR 124945) - - CHANGES: - * Composer, Disc Number and File Size columns in flat collection view. - * 'k' or 'm' suffixes for matching filesize in kibi or respectively mebi - bytes. - * Groupings when transferring files to media devices are now persistent. - (BR 127158) - * Transfer contents of smart playlists to media device without adding - them to a playlist. (BR 126997) - * Set %albumartist to Various Artists, but keep %artist as the track's - artist when organizing compilations. (BR 126936) - * Discard empty tokens surrounded by {} in custom organize file format. - (BR 124337) - * GStreamer-0.10 engine was disabled for this release (not yet stable). - * Only pick genres for Smart playlists that exist in your collection. - * VFAT plugin completely rewritten since 1.4beta3. Name is now changed to - "Generic Audio Player" to make it less needlessly technical. - * Don't limit the number of episodes shown with a new podcast, since the - user can limit the number shown afterwards by configuring the channel. - * Automatically populate the playlist with items if it is empty when a - dynamic playlist is loaded. (BR 126594) - * Unplayed/unrated tracks are no longer shown in the statistics dialog. - * Removed the option "Import Playlists". It's now always enabled. - * Show total track time in context browser (BR 126548) - * Derive filename for downloaded podcast episodes from their url in the - rss feed. (BR 125966) - * Only show albums/artists/genres with more than 3 tracks when listing - favourite albums/artists/genres. (BR 126435) - * libtunepimp 0.5 compiles successfully. - * Podcasts are automatically configured to be checked for updates. - * Show only 2 decimal places for scores in the statistics module. - * Replace 'Move to Collection' in file browser context menu by 'Organize - Files' for collection directories. (BR 125702) - * Removed the option "Show Status Bar". It's now always enabled. - * Tracks from a media device scan be submitted to last.fm immediately, - without waiting for tracks to be played in amaroK. Patch by Iain - Benson . (BR 125690) - * Any failed attempts to submit to last.fm are now automatically retried - in the background, without waiting for new tracks to be played. - * Smart playlists can be constructed using mixed ALL and ANY matches - (BR 124483) - * Configure media devices in global settings, disable media browser when - no media device is configured. - * Dynamic Playlist bar made more conspicuous. - * The Konqueror setting to show a 'delete' entry in the menu is now - respected, if the setting exists and KDE is version 3.4 or higher. - * Cover art from m4a files. Updated m4a taglib patch by Jochen Issing - and patch by Shane King - . (BR 125414) - - BUGFIXES: - * The playlist would incorrectly sort after using the queue manager in - dynamic mode. - * Sort disc numbers numerically (BR 127114) - * Smart Playlists using 'last played time' now filter correctly. - (BR 127145) - * If "Transcode Whenever Possible" was selected for transferring to media - devices, if the file was in the device's preferred format, transcoding - would not take place. Thanks to Ants Aasma for the patch. (BR 127109) - * Fix possible loss of database after changing settings. (BR 126880) - * Only include audio files when expanding directories. (BR 126765) - * Correctly handle 'Cancel' in confirmation dialog for deleting items - from media devices. (BR 126989) - * Smart-Playlist random mode was not 'sticking'. (BR 126877) - * Statusbar log files would only ever write to the first log after all - four logs had been filled. - * iFP: Don't pretend to add newly transferred files to wrong folders. - * Set a podcast as listened only when it really has been listened to. - * All tracks from a cuesheet will now submit correctly to last.fm. - (BR 114969) - * xine-engine will now correctly detect a change when only one of the - artist or album metadata changes. Patch by Kim Rasmussen - . (BR 126648) - * Less than and between criteria in a smart playlist for playcount, rating - or score of 0 now work. (BR 97046) - * Empty genres are no longer displayed in the collection browser. - (BR 126495) - * Fix regression causing drag and drop of playlist track items in the - playlistbrowser to be functionless. (BR 126387) - * Fix regression causing podcast purge property to be ignored. (BR 126194) - * Automatically convert MySql/PostgreSql passwords from 1.3 to 1.4 state. - * Popup Messages would flicker when being shown. - * Some 1.3 podcasts wouldn't get transferred to 1.4 settings. - * New podcasts didn't get a default save location. (BR 126196) - * Fixed encoding problems with lyrics scripts. - * Mark/unmark as compilation is now stored in the file tag so it is - remembered when the colection is rescanned. (BR 120428) - * Submissions from media devices are timestamped so as to be less likely - to conflict with submissions from another last.fm client. (BR 125367) - * The MySQL connection will no longer time out when idle. (BR 120198) - * Load manually configured media devices even after failed DCOP queries. - Patch by Iain Benson . (BR 125692) - * Copy/move to collection recurses into directories. (BR 125334) - * Amazon no longer tries to refetch invalid entries. (BR 125168) - * Skip hidden directories while scanning the collection. (BR 115478) - * Instead of cancelling collection organiziation operations when starting - new one append to running one. - * Correctly show & in playlist 'Burn' right-click submenu. Patch by - Laszlo Pandy . (BR 125117) - * Disable option to delete remote items in playlist right-click menu. - (BR 124745) - * Reload playlist browser podcasts when switching database engines. - * Podcast tables recreated on startup if they don't exist. - - -VERSION 1.4-beta3: - FEATURES: - * amaroK now supports multiple media devices of varying types (currently - iPods, UMS/VFAT, and iFP devices). - * Autodetection of iPods and UMS/VFAT devices (if KDE has HAL/DBUS support - compiled in). - * New DCOP call "devices: showDeviceList()" to show the Device Manager's - current device knowledge. - * amaroK now has a custom icon theme, and an option to switch back to the - system icons, if preferred (in the General settings section). - * Collection browser view is separated alphabetically. Patch by - Christian Hoenig . - * Ease navigation with track slider below playlist window by showing mood. - (BR 121715) - * Show context information for podcasts. - * Filebrowser: toolbar button to change to the directory of the currently - playing song. (BR 115479) - * Added "Play Audio CD" entry to the amaroK menu. (BR 103409) - * GStreamer-0.10 engine now supports visualizations. - * xine-engine: Show metadata for ogg vorbis streams. (BR 122505) - * Drag and drop podcast urls directly onto podcast folders for addition. - * Add media directly into directories for iRiver ifp devices. - * Button to directly edit lyrics from the context browser. (BR 123515) - * Support for SMIL playlists. (BR 121983) - * Support for WAX playlists. (BR 120980) - * Handle the Year tag when playing AudioCDs. Patch by Markus Kaufhold - . (BR 123428) - * Ignore 'The ' in artist names when sorting in the cover manager, as per - the collection browser. (BR 122858) - * Add autocompletion to the composer field in the tag dialog. (BR 123026) - - CHANGES: - * In context browser, show information about recently updated podcasts, - recently added and favourite albums when nothing is playing. - * Ratings can now have half stars: click again on the last star in the - rating to toggle it between a half and a full star. - * Improved handling of embedded cover art, utilizing the database. Patch - by Shane King . (BR 124563) - * Statistics tool has had numerous improvements. - * Optimise: Only rerender the CollectionBrowser when relevant. - * Disable detection of iPod model and thus solve g_object_get related - problems. (BR 121990) - * Don't block GUI when trying to transfer large numbers of items already - on media device. (BR 123570) - * Update playlist items when their location is changed during organizing - files. (BR 123752) - * Recursively add tracks when directories are dropped to the media browser - and the collection browser. (BR 123982) - * Visualizations now receive stereo data from amaroK. (BR 118765) - * Upgraded internal SQLite library to version 3.3.4. - * Podcast information is stored in the database. - * Improved password handling in the PostgreSQL config dialog. Patch by - Peter C. Ndikuwera . (BR 118304) - - BUGFIXES: - * Expand-By smart playlists were returning the wrong number of values. - * Fix display of media device transfer queues larger than 4 GB. (BR 125247) - * Fix duplicate detection when transferring to media device for tracks having - empty album tags. (BR 125203) - * Fix spuriously garbled collection scans. Patch by Shane King - . (BR 125114) - * Fix error with 'Back' link when browsing related artists. (BR 123227) - * Files with names containing '#' or '?' from smart playlists would not - get transferred to media device. (BR 122488) - * Stop Playing After Track option wouldn't be shown for the right tracks, - when there were queued tracks. Patch by Marcelo Penna Guerra - . (BR 124297) - * Don't submit podcast episodes to last.fm. (BR 118987) - * Accept system:/media/ urls into the playlist. (BR 120249) - * Fix leak of file descriptors with embedded cover art. Patch by Shane - King . (BR 123472) - * Stop collection folders being automatically removed. Instead, allow - user to remove non-existent folders by deselecting parent. (BR 123745) - * Stop delete key in playlist deleting last deselected item. (BR 123265) - * xine-engine: Show bitrate and samplerate for CD-Audio and WAV. Patch by - Markus Kaufhold . (BR 123625) - * Some podcasts would cause amaroK to hang. - * Check if directories still exist when showing Collection directories. - (BR 123834) - * Playlist popup menu had a visual glitch with Lipstik and (probably) - earlier versions of Plastik. - * Fixed a huge memory leak when using xine-engine with crossfading. - (BR 119230) - * Sometimes iRiver devices would crash upon disconnecting. (BR 123416) - * Adjust the Astraweb lyrics script for a layout change on the site. Patch - by Andrew Turner . (BR 123636) - * Directory selection would incorrectly highlight a directory in a - corner case. (BR 123635) - * Don't pretend to be able to uninstall default ContextBrowser themes. - (BR 123585) - * Fix preamp and frequency band scaling in the xine equalizer. Patch by - Tobias Knieper . (BR 116633) - * OSD text would not be stripped of empty lines. - * Playlist couldn't be shuffled if queued items existed. (BR 120221) - * Fixed renaming of Smart Playlists. (BR 122509) - * Fixed some bugs with PostgreSQL and Smart Playlists. Patch by Peter C. - Ndikuwera . (BR 123317) - * Escape invalid characters when transferring files to IFP devices. - (BR 123199) - * Escape newline characters when showing detailed information for podcast - items in the playlistbrowser. (BR 123109) - - -VERSION 1.4-beta2: - FEATURES: - * Equalizer for the GStreamer-0.10 engine. - * Crossfade in the helix engine! - * The build date is shown in the "About amaroK" dialog. - * Show album covers when dragging playlist items. Patch from Jonas - Hurrelmann . - - CHANGES: - * Summarize transfer failures to media devices instead of a message for each. - (BR 122491) - * Don't list the entry in the engine selection widget, when - it's not the active engine. Makes no sense to select this dummy engine. - * The aRts and GStreamer-0.8 engines have been removed for being obsolete. - * Automatically skip to the next track in the playlist when a track is - unplayable. (BR 116555) - * Don't check for collection changes on startup if Watch Folders is - disabled. (BR 116173) - - BUGFIXES: - * Handle .m4a files as audio when transferring to iPod video. (BR 122492) - * Smart playlists would not transfer to media devices. (BR 122838) - * Assume that .mp4 files are audio only when transferring to iPod. (BR 122591) - * Dereference symbolic links when transferring to iPod. (BR 123206) - * Correct domain for japanese wikipedia locale. (BR 122319) - * When deleting a downloaded podcast, the icon wouldn't be updated. - (BR 122440) - * Manage Files would create duplicates on collection. (BR 122519) - * On Statistics Dialog, Compilations would be shown with a random artist, - and dragging to playlist would add only the tracks by that artist. - (BR 122363) - * When editing current dynamic playlist, the adjusting of upcoming tracks - could be faulty. (BR 122401) - * Changing database on First-Run Wizard wouldn't work. - * When loading M3U playlists containing "." or "..", amaroK failed to - detect that the files are in the collection. Patch by Ted Percival - . (BR 121046) - * Konqueror sidebar would show garbage for people not using UTF-8 locales. - (BR 122395) - * "Open in External Browser" in the lyrics tab works now. - * Lyrc lyrics script handles tick characters correctly. - * Crash on startup when upgrading from 1.3, using MySQL. (BR 122042) - * No more crash on exit or deleting podcast. - * Handle metadata for .aac files as mpeg instead of mp4. (BR 121852) - - -VERSION 1.4-beta1: - FEATURES: - * AudioCD (CDDA) support for xine-engine, including CDDB lookup. Patch by - Alberto Griggio . (BR 121647) - * The Helix engine now supports direct alsa playback using Realplayer 10. - * New DCOP call "player: setVolumeRelative(int ticks)". - * Options for Random Mode to favor tracks with a higher rating, score, or - ones less recently played. - * Support for playing entire albums. This works just like normal, except - when choosing the next track, it'll go to the next track from the album - it finds in the playlist, or the first track of another album otherwise. - * Support for plain VFAT devices in the Media Device browser. - * You can now mousewheel over a track's queue label to change its position - in the queue. - * Added a time-filter to the CollectionBrowser. Now you can make it show - only those tracks, which have been added to your collection within the - last day, week, month or year. - * Fit to Width for the playlist columns is now optional (accessible in the - context menu for the column headers). - * On-the-fly transcoding when transferring to media devices, provided - that an appropriate transcoding script is running. - * Handle compilations as such on iPods. - * New DCOP calls "mediabrowser: ..." for interfacing with media devices. - * Multiple simultaneously connected media devices. - * Lyrics support is now scriptable. This allows to add support for any - lyrics site, and makes it possible to provide upgrades. (BR 94437) - * New DCOP call "contextbrowser: showLyrics(string)". - * New 'File Size' column in the playlist. - * Amarok now supports ASX playlist files. (BR 114051) - * New DCOP call "collection: isDirInCollection(const QString& path )". - * New DCOP call "playlist: removeByIndex(int)". (BR 119143) - * For mp3, aac/mp4, and ogg vorbis, it's possible to use Disc Number and - Composer tags. (BR 110675) (BR 90503) - * For xine-lib 1.1.1 and greater, xine engine has gapless playback. amaroK - is now "The Wall" compatible. (BR 77766) - * Option for selecting external web browser in amaroK. No longer requires - KDE-Base. (BR 106015) - * Press Enter in the Collection Browser filter to send all the visible - tracks to the playlist. - * Hold Ctrl while pressing Enter in the playlist's filter to apply to all - visible items instead of just the first, and Shift to only queue and not - play them. - * Tags can be edited inline in the playlist by clicking on a single selected - item. - * Switchable Wikipedia locale. (BR 104383) - * Initial port of GStreamer engine to GStreamer 0.10. - * Drag albums and compilations from context browser to media device and - playlist browser. - * Browse your collection and other related artists with context browser. - * Copy artwork to iPods capable of displaying it. - * Show extended podcast info on iPod. - * Optionally update playcount for items played on iPod and submit them - to last.fm and synchronize ratings between amaroK and iPod. - * Tracks can now be rated from 1-5 stars manually, in addition to the score - which amaroK calculates automatically based on your listening habits. You - can use the 'Rating' column and Win+1..5 to change the rating. - * Ability to copy items from iPod and from filebrowser to collection. - * New 'Last Played' column in the playlist, showing when the track was last - played. (Like in the Context Browser.) - * Browsers can be now accessed with keyboard shortcuts, Ctrl+1..5. - Also Ctrl+0 to close the current one, and Ctrl+Tab to switch the focus - between the playlist and the active browser. - * Downloaded podcast episodes can be deleted from the context menu. - * New DCOP call "player: osdEnabled". - * Add contents of smart amaroK playlists as playlist to media device. - * Mediabrowser support for the iRiver iFP series! - * New dcop call playlistbrowser loadPlaylist. (BR 110082) - * New Edit Track Information dialog. Lyrics can be edited there, comments - can have more than one line, some statistics and tag guessing from - filename. (BR 93982) - * Show/hide browsers via context menu. (BR 110823) - * Display disk space on media device. - * Copy standard and amaroK playlists to media device. - * Create playlist from items transferred to iPod. - * Edit dumb iPod playlists with media browser. - * Ability to read audible.com .aa file metadata and to transfer audiobooks - to iPod via file browser. - * Optionally add new podcasts to media device transfer queue on download - and remove podcasts already listened to on media device connect. - * Add podcast shows to the Podcast folder on iPods. - * Persistent media device transfer queue. - * Incremental update of media device view. - * Automatic scanning for stale and orphaned iPod items. - * Moodbar! - * configure: report not included extra features (BR 115057) - * Ability to uninstall context-browser themes. (BR 111449) - * More columns available in the Flat View of the Collection Browser. - * New Collection Scanner, running in an external process. No longer can - amaroK crash while scanning the Collection :) - * Statistics tool! - * Dragging external playlists into the playlist browser will add them. - * NMM engine now has a configure dialog. - * Collection scanner now supports WMA, MP4/AAC, and RealMedia (RA,RV,RM). - * You can now Organize Music from the Collection Browser, to move and - rename files to a logical place in your collection folders based on their - tags. - * Option to crossfade only on manual track changes. Useful for listening - to consecutive tracks on a single album. - - CHANGES: - * Dynamic Mode is now stateless, meaning there's no Dynamic Mode any more, - only loading and unloading of Dynamic Playlists. There's also now a nice - info bar above the playlist when a Dynamic Playlist is loaded. - * The major huge context menu used for hiding/showing columns in the - playlist has been replaced with a shorter one and a nice dialog. - * Elapsed time / length in the systray tooltip now updates in real time as - the song progresses. - * Tooltips in the playlist for truncated text are now shown directly above - the text, giving the effect of it being expanded to its full length. - * The option for restarting scripts automatically at startup is removed, as - it is now the default behaviour. - * Reduced memory usage for large playlists to under 30% of pre-1.4 versions. - (Measured as the difference in memory usage between an empty playlist and - loading the 'All Collection' smart playlist.) - * Import iTunes album art from directories. - * Media Devices (Apple iPod, iRiver iFP, ...) are now handled with plugins. - * New default image for albums with no cover art. - * When tabbing between cells while editing tags in the playlist, autosave - the contents of the previous tag you edited, so you don't have to - constantly go in and out of editing mode to edit lots of tags. - * When saving playlists, if there's already one with the same name, instead - of complaining about it, smartly append (2), (3), etc. to the end. - * 'Stop Playing After Track' now has a shortcut (Ctrl+Alt+V), and a global - shortcut for the currently playing track (Ctrl+Win+V). - * Various keyboard usability and focus tweaks so using amaroK with the - keyboard is nicer. - * Upgraded internal SQLite database library to version 3.2.7. - * Recoding mp3 tags has been removed due to many unjustified - complications. - * Viewing track information of remote media will show the url. - * "Update"-button is now hidden in the collection browser if "Watch - folders for changes" is enabled in the options. - * Playlist Browser now remembers which entries were open across startups. - * The tooltip and the menu from the queue icon in the statusbar now shows - the total length of the queued tracks. - * The Home tab has been merged into the Current tab, now called Music. - * New look for the current track marker in the playlist. Pimp my roK! - * When turning either random or dynamic mode on, turn the other off, - instead of completely disabling random mode when dynamic is on. - * libgpod from gtkpod replaces kio based iPod support for improved - compatibility with various iPod models. - * Podcast settings are hierarchical now, meaning you can set settings - for the category's, newly added podcasts take the settings from there parent category. - - BUGFIXES: - * Dragging text to a filter line edit would still show the "Filter - Here..." text in the background. (BR 108876) - * Don't show an empty playlist length holder in the statusbar. - * Allow for % and _ in tags, and filter them correctly. - * Do not copy files of types an iPod is not capable of playing to the - iPod. (BR 117486) - * Also take track number into account when comparing tags for checking - if a track is already present on iPod. (BR 117380) - * iPod nanos would not switch off during playing songs added with amaroK - because of their file size not being set. - * "Show Fullsize" now works for ID3 embedded cover images. (BR 114517) - * Fix possible bug when saving unencoded podcasts to strange file systems. - * OSD Preview did not update colours when toggling 'Use custom colours' - option. (BR 115965) - * Cached lyrics are not erased when rescanning. (BR 110489) - * No more "can't create amazon table" warnings. (BR 113930) - * Creating a new playlist via drag-and-drop no longer shows duplicates - of each song until amaroK is restarted. - - -VERSION 1.3.9: - FEATURES: - * Support for libtunepimp 0.4. (BR 94988) - - BUGFIXES: - * Fix leak of file descriptors with embedded cover art. Patch by Shane - King . (BR 123472) - * Playlist popup menu had a visual glitch with Lipstik and (probably) - earlier versions of Plastik. - * Fix preamp and frequency band scaling in the xine equalizer. Patch by - Tobias Knieper . (BR 116633) - * Fixed a huge memory leak when using xine-engine with crossfading. - (BR 119230) - * Fix memory leak in the helix engine when the player and playlist are - not visible. - * Stream with URLs containing "&" wouldn't be correctly saved. - (BR 121846) - * Playlist Browser would save invalid PLS Playlists. (BR 122875) - * Refresh All Podcasts wouldn't consider subfolders. (BR 122783) - * When using a folder as playlist, deleting the playlist would delete - the folder and all files inside it. (BR 122480) - * OSD was showing "No track playing" for tracks without metadata. - * Smart Playlists with playcount or score related conditions wouldn't - match all songs properly. (BR 97046) - * With enormous queues, stop menu would take a lot of time to show up. - (BR 120677) - - -VERSION 1.3.8: - BUGFIXES: - * NMM engine would crash when seeking after the playlist finished, - state Empty wasn't emitted. - * Fixed URL of the Nectarine radio stream. - * Fix crash after changing the alsa device in the helix configuration - dialog. - * When amaroK exits, send SIGTERM to running scripts. (BR 119159) - * Old error messages could be shown instead of current track lyrics. - * The equalizer in the helix engine now works properly at low sample - frequencies. - * Fixed some threading issues in loading XML playlists. - * Lyrics that are available on lyrc would be shown as "not found". - * The helix engine now includes protection so that misbehaving streams - do not cause the visualizations to leak memory. - - -VERSION 1.3.7: - CHANGES: - * In the tree view, sort tracks alphabetically first, unless one of the - categories is by album, then sort by track number first. (BR 112830) - * No longer delete Amazon covers every 90 days, instead relying on - RefreshImages to re-download covers every 80 days to comply with - the TOS of the Amazon web service. - - BUGFIXES: - * Fix weirdness when overwriting a playlist by dragging a file to the - browser. - * When using Year - Album on Collection Browser, if two albums had the - same year, the order would be pseudo-random. Patch by Xepo - . (BR 115584) - * Fix build issue on PCLinuxOS with "cpu_set undeclared". - * Fix crash in helix engine caused by improper reference counting - of the audiostreamresponse object. - * Helix engine no longer declares it is "empty" on a track change - (caused problems with context browser). - * Tag dialog doesn't delete year tags any more when editing multiple - tracks. - * amaroK would crash or hang when fetching similar artists information - from last.fm (BR 116399) - * Fix memory leak in the helix engine. (BR 116223) - * When changing the database type, the apply button wouldn't be enabled, - and it would be necessary to restart amaroK for it to work properly. - * Fix for regression in Qt 3.3.5, causing amaroK to crash when clearing - the playlist. (BR 116004) - * Zombie directories are removed automatically from the collection - scanner. (BR 115779) - * Dates wouldn't be properly loaded when editing Smart Playlists. - * Number of songs to add when using dynamic mode wouldn't be respected, - if the smartplaylist didn't have a ORDER BY statement. (BR 115860) - * Fix visibility related build problem on some distros. - - -VERSION 1.3.6: - BUGFIXES: - * Fix autoscan with PostgreSQL. (BR 111209) - * Fix problem with sequences in PostgreSQL support. (BR 115075) - * Fix potential crash at startup while accessing amazon.com. (BR 115838) - * Potential crash when loading media from the Collection. (BR 115234) - * Podcast apply to all button was faulty. - * last.fm queue wouldn't be saved to disk. Patch by John Patterson - . (BR 115212) - * Podcast download directory would only be effective next time the - application started. - * Don't crash when attempting to save an empty playlist from the Playlist - menu. - * Loading dynamic playlists with sources did not work properly. - * Fix build issue on some Linux kernel 2.4 distros. (BR 115068) - - -VERSION 1.3.5: - BUGFIXES: - * Fixed a build issue. - * Fixed potential crash at startup. (BR 114983) - - -VERSION 1.3.4: - FEATURES: - * Helix-engine supports ALSA (using RealPlayer 11). (BR 113909) - * Atom feed compatibility for podcasts. - * Statusbar messages are logged to a file, statusbar.log. (BR 99899) - * Podcast configuration now provides the ability to set the values for - all podcasts. (BR 114371) - * Downloading multiple podcasts will throw them into a queue, and - each will be downloaded sequentially. (BR 114370) - * Playlistbrowser items can be dragged into folders. - - CHANGES: - * Categories in the playlist browser are now always in the order of: - Playlists, Smart Playlists, Dynamic Playlists, Radio Streams, then - Podcasts, regardless of sorting options. (Items in the categories - are still sorted normally.) - * Reworked systray icon handling -- mostly under the hood, but it'll - now update properly - eg. when you change the cover. (BR 111014) - * Tooltip for the queue icon in the statusbar will now show the album - cover of the upcoming track. - * Totals in the collection browser will now reflect the visible items - if you set a filter. - * Podcast settings "download on request" and "stream on request" have - been merged. - * About button in script manager now uses a KAboutDialog and supports - rich text format in the README file. (BR 110961) - * After filtering the collection browser, if only a single item is left - visible, it will automatically be expanded. - * Added items for the Equalizer, Visualizations, and Queue Manager to - the context menus of the volume slider, analyzer, and statusbar queue - icon, respectively. - - BUGFIXES: - * If you queue an album from the context browser and then undo, the - queue icon in the statusbar is now updated properly (and hence - doesn't crash if you click on it). - * helix-engine no longer emits new metaData if only the bitrate of a - stream changes. (BR 114348) - * Fix amaroK attempting to destroy your computer, reach through the - monitor and violently strangle you if you attempt to exit while the - collection is being scanned. (BR 114597) (BR 114859) - * Postgresql code cleanup and fixed regression for manual collection - scanning. Autoscan still does not work. (BR 111209) - * File browser now sets to home if it was on a remote directory to prevent - annoying error messages. (BR 114498) - * Podcast settings would not add a trailing slash to podcast save - locations. (BR 114712) - * Workaround for stability issues with HyperThreading on Linux. - Added a configure check to deal with buggy GLIBC's. (BR 99199) - * xine-engine: Equalizer became inactive on trackchange when crossfading - was enabled. (BR 114492) - * Pausing a track would abort lyrics and wiki fetch jobs. (BR 114576) - * Dynamic mode did not respect repeat track mode. (BR 114585) - * The Script Manager no longer captures the script's stdout. - * Enqueuing files with amarok -e would not work for relative paths if the - working directories of the new and the running instance of amarok differ. - * Visualizations would only work when amarok was run as amarokapp. - (BR 99627) - * The number of podcasts items would be limited even when the user didn't - set it. (BR 114353) - * Switching system language wouldn't affect the root folder names on - Playlist Browser. - * On Context Browser, when showing a cached lyric, "add", "search", and - "open in external browser" buttons wouldn't work. "Open in External - Browser" is now disabled for cached lyrics. (BR 110812) - * Refreshing all podcasts when folder existed caused a crash. - * Multiple job statusbar widget was broken. (BR 114278) - * HTML in tags was getting interpreted in the context browser. - * Changing the podcast purge count could sometimes cause amaroK to hang. - * NMM-engine: Fixed crash after playing a song to the end, the trackEnd - signal was not emitted from the GUI thread. - * With Random Mode enabled and Repeat Playlist disabled, when it got to - the last track, it would play it a second time and then keep on playing - other tracks, instead of just stopping. - * Smart-Playlists were broken with PostgreSQL. Patch by Michael Landin - Hostbaek . (BR 114269) - * Collection scanner ignored files with non-ascii characters. (BR 114195) - * Don't show "Change Collection Setup"-box for non-local files. - * Fixed issue with loading playlists containing remote URL's. - * Dynamic mode history tracks would be forgotten if there was no current - track on startup. (BR 110160) - * Fixed problems with "Retrieve Similar Artists" feature in combination - with SQLite, which could lead to 100% CPU usage. (BR 104447) - * Tabbing between items and cells in the playlist while editing them now - works much nicer (goes in order and doesn't tab to invisible columns), - and you can also now use Alt+Up, Down, Left, Right to navigate between - cells as well. - * Podcast settings failed to remember the save location. (BR 114128) - * Tray icon would stop filling up and showing play/pause icon if show - player window was toggled. (BR 93711) - * If player window is toggled during playback, playlist window's caption - now correctly shows the current track's name. - * Crossfade length would be enabled in Playback options when "No - crossfading" was selected. - * If an engine does not support crossfading, "No crossfading" is now - selected in Playback options. - - -VERSION 1.3.3: - FEATURES: - * New DCOP call "contextbrowser: showHome". - * New DCOP call "contextbrowser: showCurrentTrack". - * New DCOP call "contextbrowser: showLyrics". - * New DCOP call "contextbrowser: showWiki". - * Saving a playlist will cleverly pick a default name if possible. - * Dragging an album cover into the playlist from the context browser - will append the album. - * Middle mouse button on the current track will toggle play/pause. - * Ctrl-Right click on a selection of tracks will queue all of them, not - just the track below the cursor. (BR 112841) - * CoverManager allows for downloads from Amazon Canada. (BR 113238) - * New DCOP call "playlistbrowser: addPlaylist". - * New DCOP call "playlistbrowser: scanPodcasts". Will check all podcasts - for new episodes. - * New DCOP call "playlistbrowser: addPodcast". - * New DCOP call "player: type". Returns the current track's file type. - * New DCOP call "collection: migrateFile". Updates the collection db for - changes made to filenames, keeping stats intact. - * Smartplaylist has Length property. (BR 113039) - * Added a mouse-over effect for the volume slider. - - CHANGES: - * Adding a playlistbrowser folder will automatically focus the lineedit - for renaming the item. - * Removing podcasts will delete all downloaded media. - * Playlists in the playlistbrowser can no longer be removed, only deleted. - * Removing tracks when in dynamic mode will only replace up to the minimum - upcoming tracks requirement. - * Playlist columns are automatically resized when adding or removing - columns. - * Added a warning dialog when HyperThreading is enabled. (BR 99199) - * Blacklisted GStreamer's autoaudiosink, which is really a crapsink. - * Added a context menu to the volume slider. - * When viewing covers in fullsize, the window has a maximum size, and - scrollbars are shown if necessary. The user can also scroll the cover - by dragging it. Patch by Eyal Lotem . (BR 103990) - - BUGFIXES: - * Patch fixing an almost-infinite directory-scanning problem while - building the Collection. Patch by Dirk Mueller . - * Cover Manager: Album view setting became out of sync. Patch by Michael - Pujos . (BR 113370) - * Starting the first track in the playlist when in dynamic mode would skip - it. (BR 110160) - * Position slider in player-window disappeared after 2 hours. (BR 97128) - * PlaylistBrowser duplicated items when overwriting playlists. (BR 108693) - * Podcast settings would forget about the purge items checkbox. - * The Stop button in the toolbar was always enabled at startup. - * GStreamer-Engine: Could not seek to position 00:00:00. (BR 106483) - * Don't crossfade the last track in the playlist. (BR 96478) - * If files were in the transfer queue before connecting the iPod they - would be uploaded without checking if they already exist on the device. - * Using dynamic mode's playlist shuffle would result in repeated tracks - tracks during a populate operation. - * Fixed Xine config options were disappearing on ESC key. (BR 113225) - * Fixed problems with visibility enabled compilers. Patch by Unai Garro - . (BR 113056) - * Fix regression causing dynamic mode playlist shuffle to break for - smart playlists which relied on ordering and limits. (BR 113121) - * Automatic podcast downloads did not do anything. (BR 113129) - * Playlist browser items were not properly saved on quit (with Qt 3.3.5). - Patch by Matthieu Bedouet . (BR 113020) - * amaroK could crash on startup, if on last exit sorting was enabled in - the playlist. (BR 113042) - * Adding entries to a playlist and saving it could duplicate some tracks, - if the playlist hadn't been expanded before. (BR 111579) - - -VERSION 1.3.2: - FEATURES: - * Tabs will open automatically when dragging files between tabs. - Patch by Christian Baumgart . - * Two new dcop calls which allow scripts to read many of amaroK's - configuration options. script readConfig(key) for strings, integers and - bools. script readListConfig(key) for lists. Note that these functions - aren't guaranteed to always return the latest settings (though many do). - * Added a right click menu for blank areas of the playlist, with options - to save, clear or shuffle the playlist and to "enable the dynamic - mode & repopulate". - * Playcount is shown in the tag dialog. - * New volume slider, both better looking and better working than - the old one. - * Podcasts can be saved to any location. (BR 111059) - * Added "Save as Playlist" option to the collection and file browser - context menus as well. - * Allow removing of items in the Media Device browser transfer - queue. - - CHANGES: - * Scroll wheel to switch tabs in context browser. - * Repopulate button is enabled or disabled together with dynamic mode. - * No warning dialog when starting if the directory File Browser is on - doesn't exist anymore. It just reverts to home. (BR 99208) - * Sorting on Collection Browser now shows "Unknown" items first, and - "Various Artists" last. Years are sorted descending now. - * When selecting 'Play' from the context menu on multiple items, - it'll now play the first and queue the rest. - - BUGFIXES: - * The Equalizer and QueueManager widgets were broken on window managers - other than KWin. - * "Year - Album" category in the Collection Browser didn't allow for - dragging tracks or fetching cover images. - * Xine engine no longer adds images to the playlist. - * The delete key for removing playlist items works even if the file - browser is open. (BR 100145) - * Filenames with XML entity codes were not playable in dynamic mode - and caused it to stop. (BR 108783) - * If the album or artist contained "&", cover fetching wouldn't work - properly. - * When restarting, Playlist Browser items used for playlist shuffle - wouldn't be properly marked, though they would be taken into account. - * Don't crash after changing Podcast options, or after manually deleting - its first item. - * When renaming a playlist, the "." would be removed from the filename. - Paych by Elliot Pahl . (BR 112204) - * When using next and previous on Tagdialog, after passing by a stream, - the fields would be always disabled. (BR 112060) - * Restarting track when in dynamic mode didn't work. - * Fix issues with the GStreamer engine and alsasink, and reenable it. - Patch by Vincent Tondellier . (BR 112103) - * Dynamic playlist shuffle had some incorrect smart playlist handling. - * Robustified the code for handling the '# of tracks in the playlist' - part of the statusbar, it should not ever get out of sync with - reality now. Nice side effect is you can see the track count - increase while a playlist is loading. - * "Last played - not in the last" smart playlists would only work for - sqlite. (BR 112248) - * Podcast and Dynamic subfolders are correctly restored on application - start. (BR 112162) - * Dropping tracks onto playlist browser folders will work correctly. - * Invalid podcasts are no longer discarded on quit. (BR 112116) - * Fixed playing of files that have special characters like '#' in - helix engine. - * Fixed issue where selecting multiple items after filtering the - playlist would cause all the other items 'between' them (but - invisible due to the filter) to also get selected. - - -VERSION 1.3.1: - FEATURES: - * Added 'Set as Playlist (Crop)' and 'Save as Playlist' options in the - playlist context menu. (BR 99932) - * Support for iPod shuffle devices. Patch by Guenter Schwann - . - * Media Device browser now has a connect button for connecting - your iPod after amaroK has already been started. Also includes - configurable mounting/unmounting options. - * Holding down the stop button (as opposed to just clicking it) pops - up a menu letting you stop either now, after the current track, or - after the end of the queue. - * Collection browser filter now fully supports the same Google-esque - syntax as the playlist filter, plus one extra: lyrics:"stuff to search - for" to search in cached lyrics. - * Pressing Shift+Enter after filtering the playlist will now queue - the first track. (BR 111054) - * Display short statistics in the collection browser depending on the - categorisation method. - * New DCOP call "collection: totalTracks". Returns the total number of - tracks in the collection. - * New DCOP call "collection: totalGenres". Returns the total number of - genres in the collection. - * New DCOP call "collection: totalCompilations". Returns the total number - of compilations in the collection. - * New DCOP call "collection: totalArtists". Returns the total number of - artists in the collection. - * New DCOP call "collection: totalAlbums". Returns the total number of - tracks in the collection. - * New DCOP call "collection: similarArtists(int artists)". Returns the - similar artists of the current track, results are limited by 'artists'. - * New DCOP call "playlist: repopulate". Repopulates the playlist with - tracks from dynamic mode. - * New DCOP call "player: showBrowser". Allows for showing of playlist - window browser, see the handbook for useage. - * New DCOP call "player: setLyricsByPath". Allows adding custom lyrics - for tracks. - * Add an icon in the statusbar displaying the number of queued tracks; - click on it to pop up a menu letting you jump to their locations in - the playlist. - - CHANGES: - * New "Blue Danna" splash screen. Created by Nenad Grujicic, modified by - Nathan Adolph. - * 'Stop after track' is now saved (and so remembered across amaroK - restarts). - * Ported playlist + filter-lineedit behaviour to collection browser as - well: you can move between the view and the filter with the up/down - buttons, and just typing into the view will set the filter. (BR 108656) - * Wiki Tab links use the color set for links, instead of "Selected - Background". Style Authors can use "AMAROK_LINKCOLOR" if they want that - color. (BR 111228) - * The Equalizer widget has been pimped. - * Pressing 'up' in the playlist filter will now take you to the end of - the playlist, in addition to down going to the beginning, as before. - * When jumping to the current track, it now gets centered instead of only - barely showing. - * GStreamer-engine was rewritten. The crossfading feature was removed for - now (it didn't work right with recent GStreamer versions). Improvements: - 1) Reduced CPU usage 2) Reduced latency 3) Increased stability - * No need to restart amaroK to use your iPod! - * Improved Konqueror Sidebar. - * The bundled "Shouter" AmarokScript (for radio stream serving) has been - updated and improved. - - BUGFIXES: - * amaroK wouldn't remember current track when restarting. (BR 110282) - * Some memory leaks found and fixed. - * Fix buzz and subsequent clicking when equalizer enabled in Helix and - GStreamer engines compiled with GCC 4.0.1. - * Burn option wouldn't show up for "Year - Album" items on Collection - Browser. - * Tray's tooltip would show things like 69:40 of 1:12:01. - * Wiki Tab wouldn't work for names that contained "/". (BR 111634) - * With KDE 3.4, the proper context menu wouldn't be shown for File - Browser. Patch by Christian Baumgart . - (BR 103305) - * Playcounter and Access Date wouldn't be updated properly for PostgreSQL. - Patch by Tonton . (BR 111519) - * Clicking twice on the uninstall button for the same script, would make - amaroK crash. - * Fixed an obscure crash when you emptied the playlist, had the focus on - it, and pressed up. - * No longer show dynamic info popup on application startup. Patch by - Christian Baumgart . - * Sometimes the system tray tooltip did not update on song change. - * Polishing for the collection browser and expanded item states. Patch - by Christian Baumgart . - * With xine-engine amaroK always treated remote media like radio streams. - * Selecting Classical equalizer preset prompted for name. - * Fixed konqueror sidebar compilation with kde <= 3.3 and gcc patched for - visibility. - * Konqueror sidebar can switch again between tabs. - * Fixed playing of oggs in helix engine. - * Fixed crash in helix engine when switching engines if helix/realplayer - not installed. - * Undo/Redo for the playlist was broken in some cases. - * On Collection Browser, when grouping by Genre/Artist/Year-Album it - wouldn't show the tracks. (BR 110890) - * SmartPlaylist Editor would reset "Match Any" to "Match All" when - editing. Patch by Kevin Henderson (BR 110918). - * Podcasts and playlist tracks would be sorted lexicographically - (BR 97297). - * Saved dynamic playlists were not removable. - * xine-engine: amaroK would get stuck on exit if the Equalizer was enabled - and the engine playing. (BR 110791) - * Dequeued items sometimes weren't being repainted properly. - - -VERSION 1.3: - FEATURES: - * The tyranny of deleting covers every 90 days is over. Instead, amaroK now - automatically downloads the covers every 80 days to comply with - Amazon.com requirements. - - CHANGES: - * Removed 'Apply' button from dynamic config, all config options are now - hot! (Automatically applied on alteration) - * Minimum score changed from 1 to 0. (BR 107944) - * Playlist item lengths now shown with hours when necessary. - - BUGFIXES: - * M3U playlists would be broken after editing. (BR 109774) - * When there's no artist tag, don't show tons of unrelated songs and - albums in Context Browser. (BR 110319) - * Advertisements were showing up in Lyrics Tab for some songs. - * When editing tags in Playlist Window, only try to write the new tag if - it's different from the old one. (BR 110299) - * Changes to the score in the Edit Track Information dialog should only be - applied after clicking on the "Save and Close" button. - * When only the score is changed, amaroK shouldn't complain if the file is - read-only. (BR 109054) - * Mark/Unmark as compilation wouldn't work with SQLite. (BR 109275) - * Album Covers whose name or artist contained "'" wouldn't show up when - fetched from Amazon. (BR 109700) - * Edit Track Information dialog wouldn't update collection database if - filename contained non latin1 characters. Patch by Andrey Yasniy - (BR 110030) - * SmartPlaylist category created in the PlaylistBrowser once the - collection has been built for the first time. - * Refresh the context browser as appropriate when editing tags. (BR 108884) - * Cover image shown if track has no title. - * Statusbar cancel button will terminate a podcast download. - * Don't show multiple popup messages when retrieving podcast information. - * Don't crash when adding podcasts. (BR 109982) - * Tracks with urls containg apostrophes would not cache lyrics. - * PostgreSQL compile problem (BR 110033) - - -VERSION 1.3-beta3: - FEATURES: - * New "not in the last" option for the date fields in Smart Playlists. - (BR 107725) - * New OSD tokens: %directory and %type (shows whether it's a stream, or - otherwise the extension). - * New DCOP call "player: lyrics" (BR 100306) and Lyrics Caching. (BR 97961) - * New DCOP call "player: transferDeviceFiles". Transfers queued files to - the Media Device. - * New DCOP call "player: queueForTransfer". Queues files for transfer to - the Media Device. - * Download your favourite podcasts and let amaroK manage them for you! - * 17 Equalizer presets. (BR 96302) - * xine-engine supports crossfading. Note: Your audio device must support - mixing. SBLive, dmix or ALSA 1.0.9 will do the trick. - * Shuffle the queue list in the queue manager. (BR 108861) - * The audio plugin (autodetect, ALSA, esd etc.) for xine-engine is now - configurable. - * Playlist-Browser now remembers the state and layout of its tree view. - * Show a stop icon next to the track to stop playing after. - * Miniature player window for the minimalists out there! (BR 85876) - * "Stop Playing After Track" now also works for queued tracks. - * "Open in External Browser" button for Lyrics Tab, patch from Nick - Tryon (Dhraakellian). - * Funky shadow effect for the album cover @ Context-Browser and OSD. - (BR 108334) - * Create playlists by dragging tracks onto the Playlist Category in the - PlaylistBrowser. (BR 75029) - * Show OSD when pausing and unpausing. (BR 104508) - * Make 'The' prefix of artists be transparent in the collection - browser and sort accordingly. (BR 85959) - - CHANGES: - * TagLib version 1.4 is required. - * Renamed "Track Name" column to "Filename", "Extension" to "Type". - * "Use hardware volume mixer" option has been removed. - * "Play AudioCD" gets disabled for engines that don't support KIO. - * The OSD (by default) and systray tooltip now show the same infos in - the same order as the columns in the playlist. - * xine-engine's configuration dialog has been reworked and simplified. - * xine-engine has been given the highest engine plugin rank. - * Systray tooltip now shows "elapsed time / total time" for the length. - - BUGFIXES: - * When playing, the text in the current track's columns wouldn't get - ellipsii added if the column was too short. - * Dragging 'All Collection' smart playlist made amaroK hang. - * Compilations reported incorrect number of tracks in the Context - Browser. (BR 109651) - * Track play icon remains even when stopped playing. (BR 107284) - * Sometimes valid tracks were not submitted to AudioScrobbler. (BR 100278) - * Current playlist is now being remembered when amaroK crashes. (BR 98689) - * Playlist-Browser saves its state after each change, so that no data - is lost when amaroK crashes. (BR 108814) - * Crash when trying to save Smart Playlists after creating a Collection - for the first time. - * Context menu of compilations was empty in context browser. - * Don't append albums and compilations when clicking on text in the - context browser. (BR 98797) - * xine-engine: pre-amp for the equalizer works now. (BR 104882) - * Crash when changing the number of minimum upcoming tracks right after - starting amaroK. (BR 108251) - - -VERSION 1.3-beta2: - FEATURES: - * New DCOP call "collection: scanCollectionChanges" Scans for changes made - to the collection. - * Support for "media:" URLs. Patch by Sergio Cambra - (BR 102668) - * Support for visualizations in the Helix engine. - * Queue manager to help organise your queued tracks. (BR 90594) - * Ability to create Smart Playlists based on file path. (BR 92467) - * Per track scripting via custom playlist context menu items. - * Added advanced, Google-esque syntax to the playlist filter. Lets you do - things like artist:sirenia, "pink floyd", artist:"pink floyd", or even - score:>50. When just typing words, it works as before. (BR 99312) - - CHANGES: - * Upgraded included SQLite library to version 3.2.2. - * Bumped GStreamer and GStreamer-plugins dependency to version 0.8.6. - * aKode-engine has been disabled (too buggy/incomplete). - * Repopulate upcoming tracks on demand when using dynamic mode. - * Remodel the playlist browser to incorporate dynamic mode more fully. - - BUGFIXES: - * Don't show textual URLs in Wikipedia Tab. (BR 108031) - * Don't refresh the collection view on update scans, if nothing changed. - * xine-engine: Don't pop up hundreds of error messages when something - goes wrong. Patch from John Lash (BR 101646) - * Automatic theme download with KNewStuff works now. (BR 107313) - * Clicking on "Lookup track at musicbrainz" use %2520 for spaces in URL. - (BR 107946) - * Crash when loading dynamic playlists without a collection. - * Crash when saving smart playlist without a collection. - * Do not call TagLib::MPEG::File for non-mpeg files - some FLAC files - would cause the CPU to start running in circles. (BR 107029) - * Many Helix engine improvements. - * Crash when dragging playlist items into Playlist Browser. (BR 107709) - * Improved context display when playing radio streams with xine-engine. - * Number of album tracks was incorrect when showing statistics by album. - (BR 107762) - * Massive performance speedup for the default analyzer (BlockAnalyzer). - * Dynamic mode will grab tracks from closed playlists. - * Covermanager tooltips were persistent even when window closed. Tooltips - have now been replaced with statusbar text. (BR 106976) - * Turning off dynamic mode when items were filtered only 're-enabled' the - visible items. - * Disable random mode on startup if dynamic mode is on. (BR 107311) - * The user is warned if saving tags failed. (BR 91568) - * Sub-Folders in Playlist Browser are correctly saved and restored. - * Crash after clicking on remove playlists in dynamic mode. - * Crash on Context Menu in dynamic mode. - - -VERSION 1.3-beta1: - FEATURES: - * Add Media dialog allows for multiple file selection. (BR 105903) - * The browser-sidebar has been redesigned for improved usability. - * Cue file sheet support. Patch from Martin Ehmke . - (BR 92271). - * New OSD text token, %playcount, will write the playcount. - * SmartPlaylists are editable. (BR 91036) - * PlaylistBrowser gets a makeover! - * New playlist column "Playcount" for track play counts. - * New playlist column "Extension" allows easy sorting of playlist for - compatible file types for portable media players. - * Ability to save streams to the PlaylistBrowser (BR 91075, BR 104139) - * New DCOP call "playlist: popupMessage" Displays a popup message box - in the playlist window.. - * New "year - album" - group by mode for collection browser. (BR 94845) - * New DCOP call "player: setScoreByPath(url, int)". Sets score of a track - specified by it's path. - * New DCOP call "player: setScore(int)". Sets score of the current track. - * New DCOP call "player: path()". Returns the path of the current track. - * New DCOP call "playlist: saveM3u(path, relativePaths)". - * New ScriptManager notification: "volumeChange: int". - * Tooltips for album covers in the CoverManager. (BR 103996) - * Automatic download of themes and scripts via KNewStuff. - * Different analyzers available for the playlist window. - * New DCOP call "player: enableRepeatTrack" sets repeat track on or - off. - * HelixPlayer-engine. - * 'Load' and 'Append' entries for smart playlist context menus. (BR 99213) - * Support for reading embedded images from ID3 tags. (BR 88492) - * Wikipedia tab in ContextBrowser allows for artist biography retrieval - and more, supporting 9 different languages! (BR 98050) (BR 104383) - * Show "title by artist" on playlists titlebar and taskbar. (BR 97670) - * Option to show stats in the Home tab by album. Patch from Cédric - Brégardis . - * New DCOP call "script: listRunningScripts()". Returns a list of all - currently running scripts. (BR 102649) - * New DCOP call "script: stopScript(name)". Stops a script. (BR 102649) - * New DCOP call "script: runScript(name)". Runs a script. (BR 102649) - * New form of playlist manipulation - Dynamic Mode. - * New DCOP call "player: enableRepeatPlaylist" sets repeat playlist on or - off. (BR 102754) - * Add Score widget into the tag editor. (BR 100084) - * Support for PostgreSQL as database backend. (BR 99863) - - CHANGES: - * "amarokscript" filename extension is now mandatory for script packages. - * Append Suggestions has been superceded by Dynamic Mode. - * Add a label (with shortcut) to the Playlist filter. - - BUGFIXES: - * Message box when saving of playlist failed (BR 105520) - * Avoid weird results when fetching lyrics with slow connections. - (BR 103561) (BR 101327) - * Compensate for reversed slider widget in reverse layout locales, such as - Hebrew and Arabic. Patch from Assaf Gillat . - (BR 102978) - * Playlist playMedia now works with streams. - * Context Browser is updated when current track's tags are changed. - (BR 102839) - * Clearing the playlist while playing a track does not lead to a confusing - interface anymore. (BR 103510) - - -==BEGIN KDE 3.3 DEPENDENCY== - -VERSION 1.2.4: - FEATURES: - * Queue selected tracks shortcut, Ctrl+D. (BR 83675) - - BUGFIXES: - * The first engine entry in the config dialog was always blank. - * If you filtered by more than one word in Collection Browser, adding - expandable items (eg: artists or albums) wouldn't work. (BR 100150) - * Updating the collection without any changes being made to it kept - the Update button disabled forever. - * Application freezes when switching shoutcast streams. (BR 103890) - * MusicBrainz lookup was not escaping quote characters. (BR 103740) - * Fixed crash when clicking the "clear" button in CoverManager's filter - widget. - * Update lyrics page on new radio stream metadata. (BR 99725) - * xine-engine was reporting bogus tracklengths for ogg vorbis. (BR 102547) - - -VERSION 1.2.3: - FEATURES: - * Graphequalizer script can now enable and disable the equalizer. - * New DCOP call "player: equalizerEnabled" returns whether or not - the equalizer is enabled. - * OSD notification for mute. - * Mute global shortcut, Win+M. - * Add %comment token for comment display in OSD. (BR 100944) - * View/Edit track entry into context menus of ContextBrowser and - CollectionBrowser. - * You can mark/unmark albums as compilations via CollectionBrowser's - right-click contextmenu. - * New DCOP call "collection: query(const QString& sql)". - Allows to make arbitrary queries on the Collection database. - * New DCOP call "playlist: removeCurrentTrack()". (BR 92973) - - CHANGES: - * Show "Artist - Title" for compilation discs in CollectionBrowser - and ContextBrowser. - * Upgraded internal SQLite database to 3.2.0. - * DCOP call saveCurrentPlaylist() now returns the path to current.xml. - - BUGFIXES: - * Appropriate context menu entry for changing queue status for multiple - playlist items. - * Fix regression preventing dequeuing multiple selected tracks. - * 'Show Toolbar' remembers its settings between sessions. (BR 98662) - * When doing Musicbrainz lookup from the Context browser, search for the - real track, not the whole album. - * Memleak when a radio stream stalled. (BR 102047) - * The Collection Scan finally checks for the right file modification time. - * Adding a compilation disc from ContextBrowser was broken. - * GStreamer-engine: Reduced the gap when switching to next track without - crossfading. - * GStreamer-engine: amaroK was swallowing the beginning of a track when - Fade-in was set to zero. (BR 94472) - * Use a better highlight color in the "Configure Collection" dialog. - (BR 102059) - * "Remove Duplicates / Missing" fixed. Removes dead entries correctly. - * Fix units for samplerate. (BR 101528) - * amaroK using 100% CPU on some systems. (BR 101524) - (a KHTML bug which got exposed by code in amaroK 1.2.2) - - -VERSION 1.2.2: - FEATURES: - * Context Browser CSS styles can now be installed and selected from the - appearance settings. - * Append Suggestions now has an icon in the statusbar. - * When selecting multiple files, the "View/Edit Meta Information" dialog - will show the tags that are common to all of them. (BR 100423) - * A line graph equalizer added as a script "graphequalizer." - - CHANGES: - * Add 25-track and 50-track smart-playlists. - * Update current-track icons to include greater padding. - * The contextbrowser now uses data:-URLs instead of temp image files, so - they cannot be left on disk when amaroK terminates unexpectedly, and the - Konqueror/Universal sidebar can show them when amaroK is not running. - - BUGFIXES: - * escape '&' char in contextmenu entry (BR 101276) - * Track is set as a number in the database, so shouldn't be added rounded - by quotes. (BR 101208) - * Rewrote the broken .pls playlist parser. - * Handle delay gap between songs properly with aRts engine. (BR 90404) - * Switched order of "Make playlist" and "Queue after current track" menus - to avoid playlist destruction. (BR 96164 part 1) - * Visualizations with LibVisual didn't work in some cases. (BR 99627) - * amaroK could fail to build if the whole kdeextragear-1 module was - compiled, due to conflicts with K3B on the MusicBrainz check. (BR 100906) - * Images shown on OSD where incorrect for action notifications. - * The handbook translations were not built when amaroK was installed from - the tarball. I've written a new release script in Ruby, which can - handle the new structure of kde-i18n. (BR 100498) - * GStreamer-engine can now play vorbis radio streams properly, with - full metadata support. (BR 89821) - * GStreamer-engine now uses the "decodebin" autoplugger, which fixes - the lag issues that some users had during crossfading. (BR 99570) - - -VERSION 1.2.1: - FIX: Made the Tag-Editor only operate on visible items. (BR 100268) - ADD: Database settings added to the first-run wizard. - FIX: playlist2html generates UTF-8 output now. (BR 100140) - FIX: Bitrate/length showed random values for untagged mp3 files. (BR 100200) - FIX: Crash when recoding stream MetaData without CODEC selected. (BR 100077) - CHG: Show an additional "Compilations with Artist" box in ContextBrowser. - ADD: Remember collapse-state of boxes in ContextBrowser. (BR 98664) - ADD: Display an error when unable to connect to MySQL. - ADD: Konqueror Sidebar now has full drag and drop support. - CHG: Replaced "Blue Wolf" icon with Nenad Grujicic's amaroK 1.1 - icon, due to legal issues. - ADD: Parameter "%score" shows the current song's score in OSD. - CHG: When you delete a song within amaroK, it gets removed from - the Collection automatically. - FIX: Directory column in the playlist was eating the first letter. - ADD: New DCOP call "playlist: setStopAfterCurrent(bool)". (BR 99944) - FIX: Coverfetcher: Do not crash when no cover was found. (BR 99942) - ADD: Support for amazon.co.jp cover fetching - CHG: Toolbar items reordered for optimal usability, as suggested by - Aaron "Tom Green" Seigo. - FIX: Show covers for albums containing chars '#' or '?'. (BR 96971 99780) - ADD: Help file for the playlist2html script. - ADD: New DCOP call "playlist: int getActiveIndex()". - ADD: New DCOP call "playlist: playByIndex(int)". - CHG: Upgraded internal SQLite database to 3.1.3. - FIX: Update the database after editing tags in playlist. (BR 99593) - ADD: New DCOP function "player: trackPlayCounter". (BR 99575) - ADD: .ram playlist support with code from Kaffeine. (BR 96101) - FIX: amaroK can now determine the correct track-length even for formats - unknown to TagLib. Makes it possible to seek e.g. in m4a tracks. - ADD: Can now pick from multiple Musicbrainz results. Patch from - Jonathan Halcrow . (BR 89701) - ADD: May now set a custom cover on multiple albums in the Cover-Manager. - ADD: Support relative path of tracks in writing playlists. (BR 91053) - FIX: Don't inline-edit tags for the whole playlist's selection. - FIX: Fix "Recode Tags" crash issues. (BR 95041) - ADD: "Set Custom Cover" can fetch remote images. (BR 90499) - -VERSION 1.2: - ADD: "Repeat Track" status is reflected by an icon in the playlist. - ADD: New icons from tightcode for statusbar and repeatTrack. - ADD: New Smart-Playlist "Ever Played". - CHG: Bumped GStreamer version requirement to 0.8.4. - CHG: Made it possible to use artsdsink with GStreamer again. - CHG: Don't read m3u files recursively when dropping a folder on the - playlist. No more doubled entries. - FIX: Shoutcast radio with GStreamer is improved, no more dropouts when - starting a stream. - ADD: The "Similar Artists" feature (using Audioscrobbler) can now be - switched off. (BR 95280) - FIX: Error in Shoutcast http-request, which made it impossible to play - many radio streams with GStreamer and aRts. (BR 97211, 98569) - CHG: Better default directory for selecting a custom cover. - FIX: ContextBrowser reloads after setting a custom cover. (BR 96548) - FIX: Cover-Manager's full-screen view works with Bughira (brushed metal). - ADD: Script-Manager can auto-run scripts on application startup. - ADD: aKode engine, depends on KDE 3.4. No configure check yet. - FIX: Don't add non-audio files to the Collection. - CHG: We now use the SqlLoader, which greatly improves the performance of - adding stuff to the playlist from SmartPlaylists and the Collection. - -VERSION 1.2-beta4: - ADD: It is now possible to select the right image if there are multiple - results from Amazon. Patch from Gregory Isabelli . - (BR 93287) - CHG: Reorganized the DCOP interface. We used to have all DCOP functions in the - "player" group. Now it's splitted up into several categories. Attention - script writers: Adjust your DCOP calls! - FIX: The loader is now more robust and should always find amarokapp. - CHG: The search-browser has been integrated into the file-browser. - CHG: OSD can have fake transparency and new fancy shadow. - ADD: DCOP function "shortStatusMessage", shows a temporary message on the - application's statusbar. - FIX: Frequent crashes when writing tags. (BR 95344) - FIX: CoverManager updates its status display correctly. - FIX: "isPlaying" DCOP function now works correctly. (BR 90894) - ADD: Automatic crash report generator, sends backtraces to amaroK HQ. - ADD: DCOP function "saveCurrentPlaylist". Writes the playlist to current.xml, - for scripts that need to access the playlist contents. - ADD: Playlist2html, a script for playlist exporting. (BR 96199) - ADD: Improved statusbar, with animated error notification widget. - ADD: New progress display system, can show multiple expandable progress - widgets in the statusbar. - ADD: Alarm script, starts playing music at specified alarm time. - ADD: Script-Manager for DCOP script extensions is now functional. Refer to the - amaroK Wiki for information on script writing. - ADD: Collection-Browser shows a help message in flat-mode when filter is - empty. (BR 97000) - CHG: It is possible to select the Database Engine (SQLite, MySQL) runtime, - without amaroK restart. New Database Engines can be added, they need to - inherit DbConnection and implement its' virtual methods (see - SqliteConnection and MySqlConnection). - CHG: New amaroK icon "Blue Wolf", made by Da-Flow. - FIX: Possible crash when enabling Player-Window. (BR 94668) - -VERSION 1.2-beta3: - ADD: Smart Playlists can have a random order or a score weighted random order - (BR 90861) - ADD: Show total length of selected songs in statusbar. (BR 90284) - ADD: Context-Browser now caches the tab widgets. Patch from Matias Costa - . (BR 95999) - FIX: RAND and REP buttons were always enabled at startup. (BR 95861) - ADD: Implemented "Append Suggestions" functionality. It means that when - enabled, amaroK will append a couple of suggested songs to playlist when - you play a track. This produces a continuous playlist, something similar - to listening to radio. - ADD: Implemented "Play Media..." functionality. - FIX: Playlist-Browser was appending to playlist when clicking "Load". Now it - replaces the current playlist again, as intended. - ADD: Profile for KDELIRC (Remote Controls). Patch by Dirk Ziegelmeier - . - ADD: Remove Duplicates now also removes dead entries from playlist. - FIX: Accept album-dragging from the ContextBrowser. (BR 86020) - FIX: Configure check was missing for the Konqueror Sidebar (depends on - KDE-Base). - FIX: Browser splitter was drawn incorrectly with some styles. (BR 95333) - ADD: DCOP call for relative seek. Patch by Andreas Pfaller. (BR 84989) - CHG: Bumped TagLib dependency to 1.3.1. (1.3 is too damn buggy) - FIX: CTRL-M can show the menubar again after hiding. (BR 94139) - ADD: Support for last.fm streams. - FIX: amaroK icon shows correctly in window decoration under GNOME. - ADD: Support for ID3v2 cover images. (Thanks to M. Thiesen!) (BR 88492) - ADD: DCOP calls for the status of Random Mode, Repeat Playlist and Repeat - Track. - ADD: DCOP call to return the sample rate. - ADD: DCOP call to return the track number. (BR 94825) - FIX: GStreamer-engine provides better scope synchronisation. - ADD: Save current track position and play queue on exit. (BR 90379) - FIX: Fix Directory column on playlist, show absolute directory path instead of - empty string. (BR 90361) - ADD: DCOP call to scan your collection. (BR 84621) - FIX: When an engine fails to load, respect the rank while choosing the next - engine. - -VERSION 1.2-beta2: - FIX: Classic amaroK theme looks better. - ADD: Context Browser has CSS styling. - FIX: Cover fetching improvements/fixes. - ADD: Last played: yesterday, etc. in ContextBrowser. - FIX: Big speedup for PlaylistLoader, when adding many items. - ADD: Show songs you once played, but didn't play for the longest time on - ContextBrowser's Home-page. (least played) (BR 89479) - FIX: Don't crash on song switch, when there's only one visible playlist item - and repeat-list is activated. (BR 94030) - CHG: Add and queue tracks after the current track. (BR 94121) - ADD: DCOP call to raise the equalizer configuration dialog. - ADD: Konqueror sidebar to view playing info and control amaroK. - ADD: DCOP call to clear the playlist. (BR 90149) - ADD: DCOP call to enable/disable the equalizer. - ADD: DCOP call to return the score of the currently playing track. - ADD: Audioscrobbler submit queue stored on disk. Tracks that are listened when - offline will be available for submitting later. - CHG: "Start Scan" button was renamed to "Update". Now it starts an incremental - scan instead of a full rescan. - FIX: Lyrics parsing failed for certain songs. (BR 94269) - ADD: xine-engine saves config, and implements crossfade, bug fixed too. - ADD: Player-Window can also show the BlockAnalyzer. - CHG: Run incremental scanning once a minute instead of every 30 seconds. - FIX: When collection scanning was interrupted with Cancel, incremental - scanning didn't work any longer. - CHG: Handle incremental file scanning in a thread. Now the GUI doesn't get - blocked every 30 seconds, anymore. (BR 93564) - ADD: CollectionBrowser now offers two operation modes: - The classical TreeView and a new FlatView (like the WinAmp Library). - FIX: Caching of local cover images was broken for non-unique filenames. - (BR 94068) - FIX: "Visualizations" menu entry was always disabled. - FIX: Play button was sometimes stuck in disabled state. - FIX: OSD was showing "%artist - %track" instead of "%artist - %title". - FIX: Forward command line option --engine to amarokapp. - FIX: CoverFetcher was always looking for "album - album". - -VERSION 1.2-beta1: - ADD: Full support for Audioscrobbler, including submission of tracks. - FIX: Arts engine resumes from position when session is restored. - ADD: Vorbis stream metadata support (GStreamer-engine). (BR 82378) - ADD: Cover image and lyric fetchers include filters for common extensions, - such as (Disc 1). (BR 90630) - ADD: Ability to choose from four different Amazon locales. (BR 90664) - ADD: OSD now draws gradient instead of solid colour. - ADD: 'Stop after current song' functionality. (BR 88652) - FIX: Queue function from context/collection browsers actually properly queues - tracks. (BR 90319) - ADD: MySQL database support. Patch by Andreas Mair . - Please refer to mailing list for detailed instructions. - ADD: Metadata history for streams in Context-Browser. (BR 89839) - ADD: Command line option --engine. - ADD: OSD text is now configurable, and it displays the album cover. - FIX: Remote folders are read recursively when dropped on the playlist. - FIX: Audiocd protocol in filebrowser had empty folders. - ADD: Cache system for current-track animation in playlist. Reduces CPU load - when the playlist is visible. - ADD: 10-band IIR equalizer for GStreamer and xine engines. - FIX: The background gradient effect in Context-Browser is now much faster. The - gradient also looks nicer. (BR 91276) - FIX: Password-protected streams did not work correctly. (BR 91184). Patch by - . - ADD: NMM-engine was rewritten and updated for the latest NMM release. Supports - audio and video playback. - ADD: Cover-Manager supports drag-and-drop. - ADD: Tags are now read from the Collection database if they are already - stored. This speeds up adding items to the playlist. (BR 90137) - ADD: Context-browser shows "Suggested Tracks", utilizing audioscrobbler. - FIX: Configure does no longer print "Good - Configure has finished" when a - dependency is missing. - ADD: Intelligent automatic resize for playlist columns - ADD: Shaded current-track marker in playlist. - ADD: Automatic song lyrics display. - CHG: Internal SQLite upgraded to 3.0.8. - -VERSION 1.1.1: - FIX: Crash when using GStreamer-engine on 64bit. (BR 90869) - CHG: New splash screen by Nenad Grujicic . - FIX: Crash when fetching 1 missing cover using the fetch button. (BR 90673) - REM: Unsupported option "Show Metadata in Playlist". - ADD: Menubar (optional). - FIX: GStreamer-engine now resumes playback at correct position. - ADD: iCandy for Context-Browser: Background gradient and toolbar. - CHG: Collection-Browser now has a toolbar instead of menubar. - FIX: With "Title Streaming" disabled GStreamer could not play streams. - FIX: Osssink is now the default sink for GStreamer. If sink initialization - fails, a dialog will ask to select another sink. - FIX: Pausing failed on some systems with GStreamer-engine. (BR 90417) - FIX: Never scan the same directory twice. - FIX: Disable CD-burning menu for streams. (BR 90336) - ADD: Open Cover-Manager from Context-Browser popup-menu and main menu. - FIX: Made amaroK build with --disable-amazon flag. - FIX: Docs translations were not installed correctly. (BR 90307) - FIX: GStreamer-engine refused to play some mp3 files. (BR 90317) - -VERSION 1.1: - FIX: Huge speedup for Context-Browser, makes changing tracks faster. - ADD: Progress display for Cover-Manager. - CHG: Systray animation is now optional. - CHG: Updated included sqlite to 3.0.7 (stable). - ADD: Tag editor can operate on multiple files (mass tagging). - FIX: Collection encoding broken for non-latin1 characters. (BR 89747) - ADD: Popup-menu for cover images in Context-Browser. - FIX: The first track to play is now random for random-mode. (BR 77055) - FIX: Show systray on startup. (BR 89661) - FIX: Let xine recognise tracks that have non lower-case extensions. - -VERSION 1.1-beta2: - ADD: K3B integration for burning CDs. (BR 88052) - ADD: Third category for Collection-Browser. (BR 83609) - ADD: Playlist search now supports categories. (BR 86296) - ADD: Support for MAS (Media Application Server). MAS-engine - is in experimental state. - ADD: Context-Browser shows information about radio streams. - ADD: Custom Smart Playlists with built-in editor. - ADD: Systray icon shows track progress and play status. - CHG: Imported SQLite3 and ported CollectionDB. - ADD: "Cool-Streams", a list of amaroK Squad recommended streams for - playlist-browser. - ADD: Detecting Sampler/VA discs in CollectionBrowser (shown as - "Various Artists"). (BR 81683) - ADD: Configuration GUI for xine-engine. - ADD: Next and previous track buttons for Tag-Editor. - ADD: Player-window adapts to current color scheme. - ADD: Crossfading and fade-in/out function for GStreamer-Engine. - ADD: Genre and Favorite Tracks by Artist smart playlist in the - Playlist-Browser. - ADD: IMMS-like rating system for songs. - FIX: aRts-engine has been ported to the new engine interface and is - available again (but not recommended). - FIX: Try to autodetect Sampler-Discs and show them properly in the - Contextbrowser. (BR 87182) - FIX: Multiple items can now be selected in the CoverManager. - Thanks John Hughes (BR 87584) - FIX: Various fixes for certain Artist/Album names, which had problems - with cover support. - FIX: Sorting the collection is now case-insensitive. (BR 84141) - CHG: Symlink infinite recursion check for collection scan. - FIX: Show all accessible cover images in the tooltip. (BR 87283) - FIX: Clicking an album in the ContextBrowser adds items in the correct - order, now. (BR 87733) - -VERSION 1.1-beta1: - ADD: Wizard for configuring amaroK on first startup. - CHG: Made it possible to use the next/previous buttons when amaroK is - not playing. - ADD: DCOP call to switch Random Mode on or off. (BR 84460) - ADD: DCOP call to retrieve current track's cover image. (BR 85364) - FIX: Problem with cover-saving for certain artist/album names. (BR 84171) - FIX: Show contextual information for songs, even if they are not in the - current collection instead of an ugly empty box. - ADD: GstEngine: Support for custom output plugin parameters. (BR 83949) - ADD: CoverManager - for downloading and managing album cover images. - CHG: Refactored engine plugin interface. Each engine can now provide specific - configuration GUIs. - ADD: As-you-type search for FileBrowser. - ADD: Seeking with mousewheel in playerwindow. - REM: Stream-Browser. - ADD: New meta-info dialog, with editable tags and MusicBrainz support. - ADD: Inline-tag editing auto-completion based on the Collection Database. - ADD: Deleting files physically from playlist context menu. (BR 75208) - ADD: Fadeouts for GStreamer-Engine. - ADD: New Playlist Browser, organizes multiple playlists, and offers smart - playlist functionality. - ADD: Support for redirected streams and streams with no specified port. - ADD: KIO support for GStreamer engine. Allows playing media via all - protocols supported by KIO (ftp, audiocd, fish, etc). - ADD: SearchBrowser operation can now be aborted. - ADD: Progressbar in CollectionBrowser informs about scan progress, and a - button was added for aborting the scan. (BR 83019) - ADD: Playlist sliders (volume and position) now move directly when clicked - outside of the handle. (BR 83611) - ADD: Untagged tracks now go into Collection too, listed as "unknown". - ADD: Automatic album cover fetching is back and improved. - ADD: Option for automatically switching to Context when playback is started. - CHG: Stream timeout value is now determined from KDE user settings. - ADD: Support for password-protected streams, by wef . - FIX: GStreamer engine must not allow non-audio filetypes in playlist. - ADD: Icon for "Menu" button in toolbar. Improves Usability. - -VERSION 1.0.2: - ADD: xine-engine plugin, audio only. - FIX: aRts-engine: Compatibility with newer aRts versions improved. - FIX: aRts-engine: Streams sometimes stopping shortly after playback was - started. (BR 84417) - CHG: Increased stream connect timeout to 12 seconds. - -VERSION 1.0.1: - FIX: Short dropouts after starting a stream with GStreamer. - FIX: amaroK starting invisible when systray icon is disabled. - FIX: Playlist analyzer looks freaky on some systems. (BR 83671) - FIX: Display filename in title column for wav files. (BR 83650) - FIX: Don't show crash dialog when no engine plugins are found. - FIX: Compile issue for KDE < 3.2.1 users. Sorry :( - -VERSION 1.0: - FIX: Plugin versions are validated. Prevents crashes with ancient plugins. - FIX: Configure now checks for gtk/gdk headers for the XMMSwrapper. - REM: Removed cover download feature for this release. - FIX: Do not crash if an unreadable dir is added to the collection. - FIX: Check database-sanity on startup and recreate broken tables (BR 83205). - FIX: CollectionBrowser was broken, when amaroK was running "localized". - FIX: TitleProxy hogging 100% CPU when unable to connect to server. - CHG: Bumped GStreamer requirement to 0.8.1. - ADD: Glowing player window icons. - ADD: amaroK finally remembers if it was hidden on exit. - ADD: OSDPreview now has snap to regions. - FIX: Newly shown columns in playlist can now be resized. - FIX: BR 82020: next/prev buttons disabled when they shouldn't be. - ADD: ToolbarAnalyzer remembers it's framerate, allowed fps: {50, 40, 30, 20}. - ADD: Full streaming audio support for GStreamer engine. - FIX: Don't allow user to get into a situation where there is no Menu. - ADD: Using Welcome-page power-links you can switch between XMMS and amaroK mode. - CHG: New icons and splash screen, by Roman Becker . - ADD: Allow the current GL analyzer to be detached/attached from the - main window with the 'd' key. - FIX: Filtering the collection now searches the second category, too (BR 81681). - FIX: Filter in playlist was only working for the first argument. - CHG: Collection-Monitor now processes removed dirs in a thread. - ADD: Added a switch to toggle OSD's text-shadow. (BR 82011). - ADD: More detailed track information dialog for Collection Browser. - FIX: Track length was always 0 for certain filetypes (e.g. mod, wav) (BR 82673). - FIX: Gst engine refusing to add certain filetypes to the playlist, when - the engine was idle (BR 82713). - FIX: Rare playlist redraw bug, which resulted in messed up items. - -VERSION 1.0-beta4: - ADD: CollectionDB now caches and rescales images. This binds cover art usage - in amaroK to the collection, but offers greatly improved speed for cover - retrieval and uses less memory. - FIX: Cover not shown in ContextBrowser, when song gets played for the first - time ever (BR 81241). - ADD: Cover art fetcher, downloads album cover images from amazon.com. - ADD: Configure->Playback->Device && default device option for audiosinks. - ADD: ContextBrowser now also shows your overall-favorites and the newest tracks - in your collection. Therefor I had to reset the statistics, sorry. - FIX: Decode %-encoded characters in filenames, like %2f for a slash. (BR 74576). - CHG: Songs you click in ContextBrowser will now directly start to play and won't - be added to the playlist, if they already are there. - FIX: "Start Scan" menu-entry gets disabled while scanning. (BR 81619). - FIX: Directories with non-ascii chars don't get scanned (CB) in multibyte locales. - CHG: Enhanced "Fill-Down" feature for track column (auto-increment) (BR 81194). - FIX: Closing xmms-visualizations freezes amaroK (BR 81326). - FIX: CollectionBrowser does not sort by tracknumber (BR 79600). - FIX: ContextBrowser's URLRequests need to be escaped. - FIX: Always show OSD (if enabled) on volume changes. - FIX: Filtering the collection using tokens with number(s) at the beginning - or end failed. (BR 81621). - FIX: FileBrowser didn't remember its current folder (BR 81816). - ADD: Expand/collapse items by doubleclicking in Collection (BR 81710). - FIX: Allow OSD still to be shown via shortcut when disabled (BR 80388). - FIX: Collection: live-monitoring dirs for changes works again. - FIX: Changing volume by mousewheel on systray icon works again. - ADD: Collection automatically rescans itself on startup. - ADD: "Add to Playlist" feature in CollectionBrowser, appends tracks to playlist. - ADD: Clear button for CollectionBrowser search. - FIX: Problem with invisible "Play next" marker in playlist. - FIX: Don't try to create sql-tables on every startup, but only on - sql-scheme (DATABASE_VERSION) changes. - FIX: Display splash screen on correct desktop with Xinerama. - CHG: CollectionBrowser filter now works in "search-as-you-type" mode. - FIX: Prevent TitleProxy from showing the same metadata over and over. - FIX: Compatibility bugfixes to TitleProxy, thanks to Daniel Molkentin - . I think we've now got 100% Shoutcast compatibility. - ADD: Allow changing volume by using the mousewheel anywhere on the toolbar. - FIX: Wheel-scrolling toolbar's volume slider doesn't change volume (BR 81155). - FIX: ContextBrowser is now shown in proper colors for every scheme. - CHG: Added track's physical location to the Meta Information dialog. - FIX: Show last playtime in localtime instead of UTC. - FIX: ContextBrowser not showing all items for current album. - FIX: Not all SQL queries were "string-escaped". - ADD: Added statistics database, which keeps track of how often and when you play - a specific song. - -VERSION 1.0-beta3: - ADD: Additional volume slider for playlist window. - ADD: ContextBrowser shows you images and information to the current song/artist. - It depends on the collection and is presented as an HTML widget. - CHG: Improved color handling and visual feedback in the GUI. - ADD: Global shortcut for play/pause action, as requested by multimedia-keyboard - users (BR 79541). - CHG: Small player-window can be switched off now. - FIX: CollectionBrowser out of order after scanning. - FIX: TitleProxy partly rewritten. Should be more compatible with many streams - and not be able to freeze the app any longer. - FIX: When playing a stream with title streaming activated, the track is not - marked as playing (BR 79999). - FIX: Invoking "Track Information" in Collection Browser sometimes crashed - the application (BR 80266). - FIX: In CollectionBrowser's folder setup dialog pressing cancel did not abort - (BR 80451). Thanks to Michael Pyne for patch. - ADD: Option for selecting sound output system (OSS/Alsa). Currently only - used with GStreamer engine. - CHG: Extended and updated handbook, thanks to Mike Diehl . - ADD: Context menu item "Make Playlist" in Collection Browser generates new - playlists on the fly, without the need for drag-and-drop. - CHG: Renamed several files and folders in the source code tree, resulting in - improved code accessibility. - -VERSION 1.0-beta2: - FIX: Crash on AMD64 due to assumption about pointer size. - CHG: SQLite library sourcecode now included with amaroK. - CHG: The collection-thread now inserts its data in a temporary database while - scanning, which allows us to safely use the collection in the meantime. - This is done by two concurrent sqlite-connections (thread-safe). Wrote a - new class named CollectionDB, which handles the database communication - for the collection. - ADD: URLDrag from Playlist, so you can drag and drop to xmms. Doesn't work with - the FileBrowser yet, but it will! - CHG: CollectionBrowser now fills the database inside of a thread, resulting in - improved performance. - ADD: Mini track-position slider in statusbar. - FIX: Don't try to crossfade with engines that do not support this feature. - ADD: XMMS visualization plugins can be configured with their GUI. - FIX: Collection filtering had some regressions - FIX: Loader on some systems not able to start amaroK. - FIX: Switching engines at runtime breaking volume control. - FIX: GstEngine skipping tracks directly after starting, when crossfading enabled. - CHG: Database system now works with linked tables. Saves hdd-space and cpu-time. - CHG: If you remove the current song from the playlist, we don't define the next - song anymore, but let it be randomly selected (only when random mode is on!) - CHG: Random Mode now respects the playlist filter and only picks items, which are - currently visible in the playlist. Also removed a crash situation. - CHG: Removed the search-token index. Searching now iterates through the playlist, - offering direct and specific access to the metadata. - FIX: Bug where fill-down would cause lots of extra tags to be written when a search is - in progress (BR 79482). - FIX: Defect in plugin framework code, leading to a crash on some systems - during engine plugin initialization. - FIX: Restoring current playlist on startup (BR 79436, BR 79439). - ADD: Searching the Collection with a filter. - FIX: BrowserWin's QLabels are painted white in amaroK's own color scheme. - -VERSION 1.0-beta1: - ADD: Search Browser - search stuff on your hdd - ADD: song count on playlist statusbar - ADD: support for XMMS visualization plugins - ADD: Collection Browser - a database powered music collection manager - ADD: Playlist toolbar is now configurable - ADD: toolbar analyzer in playlist window - ADD: use XML playlists internally within amaroK so tags don't have to be - loaded/reloaded all the time. Makes undo/redo much quicker. - FIX: non latin1 locale issues with loading directories and tags (thanks Leo Zhu) - ADD: clicking shuffle will sort the playlist by the nextQueue first, and - randomise the rest - ADD: Play Next can now handle several songs through a queue. The queue can be - manipulated by using the context menu or by CTRL+right clicking. - ADD: much improved gstreamer engine, now working with visualizations - CHG: GstEngine requires gstreamer-0.8 - FIX: Show move pointer instead of hand when moving preview OSD. - ADD: sorting by artist subsorts by album and track, sorting by album subsorts - by track, enjoy! - ADD: browserTabs float over the playlist when in set to not overlap - FIX: communication loader<-->amarok failing on FreeBSD - FIX: loader forgetting to close socket descriptors - FIX: FileBrowser remembers that state of its view between sessions - CHG: converted engines to plugins. they are now dynamically loaded at runtime - ADD: plugin framework - CHG: made amaroK aRts-independent. with the --without-arts configure switch - it's possible to build the app without aRts support, using only NMM or GST - ADD: Shift drag appends items to the end of the playlist. - FIX: startup notification icon staying on screen when amaroK started by loader - FIX: amaroK showing the "X" icon instead of the correct one - -VERSION 0.9: - CHG: playlistBrowser removed until next release - FIX: playerWidget font is now configurable, you need to start new track for the - scrolling marquee to get updated. Default font is used by default. - FIX: fixed several stability issues concerning stream-playback - ADD: whatsthis for all configurable options. - FIX: amaroK registering with dcop as "amarok-PID". it's back to just "amarok" now. - FIX: OSD not updating correctly when changing volume - -VERSION 0.9-beta3: - ADD: "Show Current Track" button in playlist. - ADD: Volume OSD when changing with mousewheel over trayicon. - CHG: software volume mixer uses a logarithmic function to make the scale more natural - ADD: Global shortcuts to display OSD and increase/decrease volume. - (Win+o and Win+KP_Add/KP_Subtract by default, respectively) - ADD: DCOP calls to control OSD and playback volume - ADD: ported config-GUI for audio decoders to new engine (works currently with - modplug_artsplugin) - FIX: show correct track-length when playing .mod or .sid with aRts-engine - ADD: loader application, starts and controls amaroK. it reduces the lag when handing - command line arguments to amaroK and makes the splash load faster - ADD: playlist items, which couldn't be opened / read (for some reason) will be marked - with a grey background color - ADD: pasting clipboard selection into playlist with MidButton, X11-style - CHG: refined on-screen-display with more polished look - FIX: skipping broken/non-existant tracks - CHG: If the current song is paused, the Play Button will resume, not restart it. - FIX: respect "hide playlist with main window" and playlist minimize/hide behaviour. - ADD: new OSD configuration options: bgcolor, screen position - -VERSION 0.9-beta2: - CHG: some look-and-feel polishing in the main player window - ADD: option to turn off analyzers - ADD: splash-screen shown during program startup (optional) - FIX: made stream playback with TitleProxy more stable (by using an unbuffered socket) - ADD: show stream metadata in on-screen-display - CHG: transformed "EQ" button into a togglebutton, which can also hide the effect browser - ADD: new OpenGL analyzer, contributed by Enrico Ros - FIX: FreeBSD compile fixes, contributed by Markus Brueffer - FIX: rewritten configure: checks properly for kdemultimedia presence, - and adds --without-opengl and --without-gstreamer arguments - -VERSION 0.9-beta1: - ADD: display warning when artsd is not running with realtime priority - ADD: Audioproperties are loaded as you scroll the playlist and get saved to playlist files - ADD: If trackname column is hidden, the title column will show the trackname until a title - tag can replace it. If no title tag is found the trackname stays. - CHG: Pressing "back" in Random Mode now works as expected and walks backwards - through the list of recently played songs. - ADD: TitleProxy searches for a free local port (contributed by Stefan Gehn) - CHG: Random Mode now stores the recently played songs in a buffer, which prevents - playing the same songs too often. - ADD: "Play Next" context menu option - ADD: selected aRts-effects will be remembered on next program start, including settings - FIX: sort numerical playlist columns in correct order - ADD: logarithmic fading algorithm makes crossfading smoother - ADD: Select a series of tracks, start inline tag-editing a tag and amaroK will prompt you to - edit that tag for all tracks one-by-one. Also available: fill-down. - ADD: improved crossfading: will fade out smoothly when the stop button is pressed - FIX: O(n) behavior for playlist scrolling fixed - ADD: setting to make playlist colours the KDE defaults - ADD: support for tag-editing directly in playlist - CHG: replaced old FileBrowser with the comfortable fileselector from KDevelop - CHG: analyzers now powered by a new, more flexible FFT routine - ADD: hide/show selected playlist columns - CHG: upgrade streambrowser to kderadiostation 0.5 - FIX: many streams not loading from browser and AddItem dialog - CHG: amaroK moved out of kdenonbeta. we are now member of KDE Extra Gear 1 - ADD: on-screen-display (OSD), shows an overlay with information on the currently playing track - CHG: use KMultiTabBar for browser selection - CHG: migrated settings system to KConfig XT - ADD: playlist columns for length and bitrate - ADD: merged new audio engine in. this provides a generic interface class, with multiple - backends. right now there is a backend for aRts and one for GStreamer (still rudimentary) - -==BEGIN KDE 3.2 DEPENDENCY== - -VERSION 0.8.3: - FIX: build issue - -VERSION 0.8.2: - ADD: added Hide/Show Playlist global shortcut (thanks gogo) - CHG: mousewheel over trayicon behaviour changed - CHG: search tokens can now be entered in random order - ("Presley Elvis" will find "Elvis Presley") - FIX: qt 3.1 compile issues - -VERSION 0.8.1: - FIX: compilation problem with KDE < 3.1.3 - -VERSION 0.8.0: - FIX: KDE 3.1 compatibility re-gained - ADD: hitting return in the search field of the playlist starts playback of the - first visible playlist entry (Qt >=3.2 only) - FIX: fixed crash bug in playlist searching - FIX: fixed crash bug when removing playlist-items - CHG: new layout has been adopted - ADD: added accepting files dropped onto systray icon - FIX: significant reduction in memory consumption for PlaylistItems - FIX: hardware mixer works again - CHG: replaced sliders with custom slider class, which fits better in our design - FIX: exchanged c32-app-amarok.png with the correct (active) version - FIX: amarok.desktop file. now we show up in the k-menu again. - FIX: crossfading aRts module. the fading is now much smoother than before - FIX: crossfading bug. before the fix amaroK sometimes mixed up the two xfade sources, - so it sort of faded in reverse (==crap) - ADD: tag reading in separate thread - ADD: re-added m_optCrossFade, so we don't lose the crossfade length on switching it on/off. - set default crossfade length to 2500. - CHG: "Title Streaming" on by default - CHG: integrated streambrowser into playlist window - ADD: added dcop implementation for url adding. Relevant diffs for mediacontrol are - available. - FIX: libamarokarts detection code - ADD: added long-awaited DCOP methods for manipulating the playback. This also adds - integration with kdeaddons/kicker-applets/mediacontrol. - CHG: moved DCOP handler to a separate class/file - ADD: threaded playlist insertion - FIX: removed bugs and waste code keyhandling in browser*, it mostly works as expected - now with various keypresses going to the correct places - FIX: cleaned the playlist class's public interface, also fixed some unreported bugs in - process (inconsistent recursive behavior), please keep the encapsulation, it's a - good thing (tm) - FIX: tweaked undo/redo behavior - CHG: exchanged old player icons with new ones made by - Alper Ayazoglu a.k.a. cubon - ADD: clicking on EQ button activates effect selection widget - ADD: KJanusWidget as a sidebar for filebrowser mode selection - FIX: pushing enter in lineedit goes up a level - ADD: a stream browser, can only DnD, separate window, not great yet - FIX: finally fixed the ancient "annoying-noise-when-pressing-pause" bug - FIX: should keep track of currently played item no matter what you do to the playlist, - has a nice side effect of remembering the last played song, too. - FIX: write undo for Shuffle - FIX: the expandbutton doesn't fire events when it has had its stack expanded - (behaviour a-la Winamp Classic) - FIX: crash when pressing right mouse button while stream is connecting - ADD: show bitrate for streams with icecast support - FIX: save stream names as #EXTINF in m3u files - ADD: bug report dialog - ADD: proxy for decoding shoutcast/icecast metadata (experimental!) - ADD: amaroK now in bugs.kde.org - ADD: configurable delay after each track. currently 0-10 seconds in 1 sec increments - but could easily be made to use finder increments if ppl want - piggz (www.piggz.co.uk) - ADD: viswidgetv2. it seems a lot smoother on my machine. - its quite easy to tweak the dynamics is needed. is accessible the same as the other - widgets, just click until it appears (though it looks the same as the original widget - it just acts differently) - piggz (www.piggz.co.uk) - ADD: combo with history and completion for dir/file chooser - ADD: in configure.in.in for checking the version of TagLib, if compiled from CVS, if not, - then show, that it uses bundled version of TagLib - Stormy - FIX: font dialog sizing issues - ADD: resume playback option. Using this means your track starts up again where you left it - last time you quit amaroK. Excellent feature for us developers :-) - -VERSION 0.7.0: - FIX: collection of fixes related to showing/raising/hiding the playlist - when showing/raising/hiding the mainWidget - FIX: by muesli: make playlist searches a bit faster at the expense of memory - FIX: (partial fix) bitrate/samplerate font overlap at large font sizes - change: less staccato loading of widgets - change: pause makes the analyser bars fall to zero rather than just vanish - ADD: xfade when starting tracks by doubleclick - FIX: global shortcuts can now be changed - FIX: tracks skipping randomly - change: "BrowserWin Enabled" on by default - change: "Save Playlist" on by default - change: "Show Metainfo" on by default - FIX: make loading playlist not block UI - FIX: on startup load playlist after UI is shown - change: "Software Mixer Only" on by default - FIX: make timedisplay also work for streams - FIX: volume slider adjusting - FIX: when dropping tracks to PL, order will stay the same as in FileBrowser - ADD: FileBrowser sortable by clicking on header - ADD: analyzer that distorts a bitmap - ADD: multiple analyzers now possible - ADD: "Software Mixer Only" option - Removed stale sigplay() - Cleaned a couple "deprecated" warnings - ADD: undo and redo playlist actions - FIX: rewritten config dialog and moved into separate file - ADD: started configurable colors - change: spectrum analyser bars now have dynamics, ie. they move smoothly between values - ADD: mouse wheel over systray icon changes the track, hold shift to change the volume - change: rearranged menu order for systray (quit = last) - change: moved volume slider to the right, lets see if this is better - ADD: started a font selection page in settings - FIX: Stream urls are now properly demangled/unescaped (%20 => space etc) - -VERSION 0.6.91: - FIX: ExpandButton submenu now slightly delayed - FIX: dropping items into playlist - ADD: drop-target indicator line in PlaylistWidget, providing visual feedback - ADD: tray menu - ADD: random mode - ADD: crossfading between tracks - ADD: vertical lines between columns in Playlist - ADD: alternating item colors in Playlist - ADD: column "directory" in PlaylistWidget (for Grue:) - ADD: sorting by clicking on column headers in PlaylistWidget - FIX: rewrote directory reading code in BrowserWidget.cpp. - code is now much more readable, and it also fixes a bug. - ADD: additional columns in playlist for tags - FIX: made metainfo reading algorithm faster - change: switched to TagLib for metainfo reading - ADD: button "play" in PlayerWidget.cpp is now a toggleButton - ADD: tray icon - FIX: playlist window is optionally hideable with main widget when iconified to tray - -VERSION 0.6.0: - Release :) - -VERSION 0.6.0-PRE5: - fixed: animated buttons don't get stuck anymore - fixed: invoking help - changed: MetaInfo reading now off by default. the slowdown was potentially - confusing to new users - added: documentation - fixed: cleaned up Makefile.am a bit - fixed: defined new APP_VERSION macro, since the old approach did not work - with CVS - changed: put amarok into KDE CVS (KDENONBETA) - added: applied Stormchaser's button patch. the AmarokButtons now work - in a more standard conform way. Thanks Stormchaser, blessed be :) - -VERSION 0.6.0-PRE4: - added: buttons in playlist window for play, pause, stop, next, prev. - a.k.a. stakker mode :) - removed: "load" button. this functionality is now provided by "Add item" - added: more sanity checks on pointers - fixed: when track in playlist does not exist, we now skip to the next track - fixed: all aRts references are freed correctly at program exit - fixed: effects will not be forgotten any more when EffectWidget is closed - -VERSION 0.6.0-PRE3: - fixed: crash when URLs were dropped onto filebrowser from other apps - fixed: URL dialog now accepts remote files - added: correct caption for ArtsConfigWidget - added: "amaroK Handbook" menu entry, calling KHelpCenter - changed: amarok gets installed into multimedia now - fixed: PlayObject configuration - -VERSION 0.6.0-PRE2: - changed: safety question at program exit now off by default - removed: button "sub" - it was useless - changed: clearing playlist does not stop playing anymore - for Grue ;) - fixed: potential crash at startup - added: menu option to configure PlayObject - fixed: crash when removing currently playing track - -VERSION 0.6.0-PRE1: - fixed: flicker in glowing item - fixed: another memory leak in analyzer (hopefully the last one!) - added: playlist widget can display metainfo instead of filenames - added: repeat track / repeat playlist - -VERSION 0.5.2 - 0.5.2-DEV6: - fixed: memory leak in analyzer code. - added: shortcut for copying current title to the clipboard - added: slider position can be changed by just clicking somewhere on the slider - added: icon - added: url can be entered directly above the filebrowser widget - changed: removed the "jump" widget. you can now enter a filter string - directly above the playlist widget - added: playlists (.m3u and .pls) can now directly be dragged into the playlist - added: support for .pls (audio/x-scpls) - added: amarok is now completely network-transparent. any kind of folder, - local as well as remote, can be browsed and played. - added: check for libamarokarts. amarok won't crash anymore if it's not found - added: the time display now has a mode for showing the remaining time, too - fixed: crash when clearing playlist, after playlist has played till the end. - clearing the playlist stops the playing now. - added: new gfx in playerwidget - fixed: progressbar sometimes not working, zero tracklength - fixed: font of bitrate/frequency display too big on some systems - added: command line options - added: timedisplay is now updated during seeks - added: saving window positions and size on exit - added: due to popular request, I finally changed the behaviour of the "play" - button. it's now possible to start a track on a fresh playlist without - double-clicking an item. - fixed: compile error on GCC 3.3.1 in visQueue.cpp. bugfix by thiago - added: completely rewrote drag-and-drop code. works recursively now (optionally). - plus dragging stuff from other applications into amaroK also works now. - -VERSION 0.5.1: - added a Tip of the Day at startup to explain the user interface a bit - added restarting of artsd on first program start to make sure it registers - the new mcopclasses - fixed possible compile error in viswidget.cpp - amaroK uses much less CPU now than it used to. This was mainly achieved by - using a new FFT-analyzer module, which I took from Noatuns "Winskin"-plugin, - and modified slightly to my needs. Also some other optimizations were made, - which improved the standby performance, when no song is playing. I'm still - not satisfied with overall performance, tho, but it seems that most of the - load is produced by the aRts code itself, so this will rather be difficult - to improve. - fixed crash when "next" or "previous" was pressed without a track - loaded - thanks to valgrind I was able to find and squish some serious bugs, - most of which were related to pointers. to sum it up: pointers are evil. - valgrind is great. - lots of UI-changes in the main widget. uses a background pixmap now, a - custom font and widget for the time-display, and generally looks better - fixed issues with the liquid skin. unfortunately, there seems to be no way - to display pushbuttons correctly with a black background under liquid. so, - until I find a solution for that, the expandbutton widget doesn't look quite - as cool as it used to. maybe I should ask mosfet about this.. - -VERSION 0.50: - renamed 0.15 to 0.50 - -VERSION 0.15: - playing streams now works! *yipeeee* - fixed tons of bugs in aRts playing code. i think i got it right now. - fixed loading and saving of playlists. can cope with all protocols now. - fixed a bug in EffectWidget.cpp, that gave a compile error on some systems. - Converting QString into std::string was not done correctly. Thanks to - Whitehawk Stormchaser for that one :) - changed project name to "amaroK" and built new project-file - -VERSION 0.14 (internal): - implemented use of arts-software-mixing, in case hardware-mixing - (/dev/mixer) doesn't work - fixed crash when play was pressed without selecting a file - changed the direction of the volume-slider. maximum is now at the top - added automatic saving of current playlist on exit - added previous/next track - added two radiobuttons in the playerwidget for toggling the - playlist/equalizer on and off. admitted, the equalizer doesn't yet exist, so - it's just a dummy button :P - added popup-menu for the playerwidget. opens on - right mouse button. this menu finally replaces the ugly menubar. - added some icons (from noatun) for the player-buttons instead of text - added pause function - changed most names in the source to comply with the - (unofficial?) KDE c++ coding standard (using the prefix "m_" for member - attributes and so on). This was real slave-work :/ - cleaned up code in several classes - fixed problem where subwidgets got keyboard focus and were drawn dark with - the liquid style. switched off focus completely, since it's not needed for - this type of application - -VERSION 0.13 (internal): - added cute animated pushbuttons with sub-menus - added saving playlists - added dragging items inside of playlist widget - added forward declarations in header files to reduce compile time - added saving of browserwin/splitter size - rewrote track information widget. used a html table for the text. looks much - nicer now :) - fixed sorting function - fixed jump widget. removed huge memory leaks in the widget - fixed flicker in analyzer widget - tons of bugfixes in playing code. partly rewritten. seems to be much more - stable now - -VERSION 0.12 (internal): - added ChangeLog and TODO - added grid under scope display - added saving of options, like current directory and playlist - added detection of mimetypes - added adjusting volume by mousewheel - added skipping to next track after playing - added loads of sanity/safety checks - bugfixes (tons of) in playlist code, partly rewritten - bugfixes in scope code - - -VERSION 0.1 - 0.11: - internal versions, no changelog - tried no less then 4 different sound interfaces: - mpg123, smpeg, alsaplayer, and finally aRts - -# vim: expandtab ts=2 sw=2 diff --git a/amarok/HACKING/OUTDATED-MediaDeviceFramework b/amarok/HACKING/OUTDATED-MediaDeviceFramework deleted file mode 100644 index 9badaddb..00000000 --- a/amarok/HACKING/OUTDATED-MediaDeviceFramework +++ /dev/null @@ -1,133 +0,0 @@ -**************************************************************************** -* BIG FAT WARNING: * -* Media Device Framework is outdated and is going to be removed as soon as * -* we rewrite MtpCollection and AudioCdColleciton not to use it anymore. * -**************************************************************************** - -Media Device Framework -====================== - -1. Solid Interface - -Solid is KDE's hardware detection library, and Amarok uses it to detect -all of the devices that it knows how to interface with. It does this -through two classes: - -MediaDeviceCache(singleton) - Talks directly to Solid, gets list of all -present media devices and external hard drives, even if Amarok does not -support them. - -MediaDeviceMonitor(singleton) - Talks to the MDC to see what devices are -available. Keeps track of the kind of devices that Amarok supports. -It does this by receiving and caching a single ConnectionAssistant -object from the MediaDeviceCollectionFactory of the particular device -type, so that as devices are detected, they can be tested for -compatibility with Amarok. - -2. Collection/Metadata - -Music-related data in Amarok is handled in Collections, themselves -consisting of metadata such as Tracks, Artists etc. The base classes -to set up collections are abstract, and several classes which provide -more media-device-specific methods are available to be subclassed. It -is some of these classes that must be subclassed to add support in -Amarok for a device. The heart of it all is MediaDeviceHandler, and -this class will be discussed in depth. - -NNTS = No Need To Subclass - -2.1 Connection - -ConnectionAssistant - Knows how to identify that a particular device -matches the type of this CA. Can also create MediaDeviceInfo. - -MediaDeviceInfo - Contains the device-specific information pertinent to -connection, such as mountpoint. - -2.2 Factory/Collection - -MediaDeviceCollectionFactory(NNTS) - Creates -MediaDeviceCollections. Provides ConnectionAssistant to register the -appropriate device type with the MDM. - -MediaDeviceCollection - Given a MediaDeviceInfo object, connects to the -device described by creating a MediaDeviceHandler. Provides a few -other rudimentary functions. - -MediaDeviceCollectionLocation(NNTS) - Receives/sends orders to add -tracks to Collection, remove them, copy them. move them. Forwards the -low-level work (the actual copying/deleting etc.) to the -MediaDeviceHandler. - -MediaDeviceMeta*(NNTS) - The actual metadata a Collection consists of: -Track, Album, Artist, Genre, Composer. No need to reimplement these, -as they are standard across all devices, and the interactions -concerning them are dealt with in the MediaDeviceHandler. - -2.3 Handler and Capabilities - -2.3.1 Handler - -MediaDeviceHandler - This is it. This is the beast that knows how to -do all the low-level tasks specific to a given device: connection, -parsing metadata, copying, deletion, changing of metadata, battery%, -device capacity, the whole lot of it. Since it is responsible for so -many pieces, and since these pieces vary greatly from device to device, -it actually relies on Capability-based classes that each know how to do -a particular job. - - Capabilities are similar to Java interfaces, and provide a standard -way for the MediaDeviceHandler class to ask the many subclasses of -MediaDeviceHandler for what they are capable of, and depending on that, -will make different requests. For instance, AudioCDs cannot -be written to, so they would have no use for WriteCapability, and don't -have to implement it. - - The MediaDeviceHandler has abstracted the logic so common to several -device implementations. The libraries libgpod and libmtp, for -instance, are based on a struct that is a linked list of metadata, in -particular tracks. The common way to parse the devices with these -libraries is to walk down this linked list until all metadata has been -read into the appropriate MediaDeviceMeta classes. This is exactly -what the Handler does, and the only differences are the names of the -linked list structs, and the functions called or member data read to -retrieve this data. It is these basic function calls that are then -called in the subclasses of the Capability classes, with the -top-level logic already standardized and done in the main -MediaDeviceHandler class. - -Note: To see the logic hereto referred, check the MediaDeviceHandler's -calls to the Capability classes, and the order of the function calls. -This helps to understand how best to map the functions of the -Capability interface, to function calls or member-data access using the -appropriate library. - -2.3.2 Capabilities - -ReadCapability - Maps the necessary functions to read the structs -specific to the device, with the goal of parsing the entire device's -metadata. Can also read the device's capacity, used and total. - -WriteCapability - Receives generic commands related to writing to -the device: find where to copy a new track onto the device, copy the -track, delete the track. Subclass this Capability also to provide a full -mapping onto the functions required to set the metadata on a newly -created track struct, and the higher logic of in what order to do this -is handled by the main Handler class. - -ArtworkCapability - Optional. If the device supports artwork, this -provides the interface for reading/writing that artwork. - -PlaylistCapability - Optional. If the device supports playlists, this -provides the interface for reading/writing playlists, parsing logic is -based again on a linked-list struct that is traversed in a standard -fashion. The subclass of this just maps to the appropriate functions -to walk the linked list. - - -3. Appendix/Notes - -- At the time of writing, there isn't a full implementation of Solid on -Windows or Mac, which limits support of devices mainly to Linux. Also, -libraries used to interface at the low level (libgpod, libmtp) are -Linux-specific. diff --git a/amarok/HACKING/amarokTables.svg b/amarok/HACKING/amarokTables.svg deleted file mode 100644 index c67e60b9..00000000 --- a/amarok/HACKING/amarokTables.svg +++ /dev/null @@ -1,4270 +0,0 @@ - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - Database Version 13 - - - - devices - - id: idType()type: textColumnType()label: textColumnType()lastmountpoint: textColumnType()uuid: textColumnType()servername: textColumnType(80)sharename: textColumnType(240) - - - INDEX: typeUNIQUE INDEX: uuidINDEX: servername, sharename - - - - - urls - - id: idType()deviceid: INTEGERrpath: exactIndexableTextColumnType NOT NULLdirectory: INTEGERuniqueid: exactTextColumnType(128) UNIQUE - - - UNIQUE INDEX: deviceid, rpathINDEX: uniqueidINDEX: directory - - - - - directories - - id: idType()deviceid: INTEGERdir: exactIndexableTextColumnType NOT NULLchangedate: INTEGER - - - INDEX: deviceid - - - - - artists - - id: idType()name: textColumnType() NOT NULL - - - UNIQUE INDEX: name - - - - - images - - id: idType()path: textColumnType() NOT NULL - - - UNIQUE INDEX: path - - - - - albums - - id: idType()name: textColumnType() NOT NULLartist: INTEGERimage: INTEGER - - - UNIQUE INDEX: name, artistINDEX: artistINDEX: imageINDEX: name - - - - - genres - - id: idType()name: textColumnType() NOT NULL - - - UNIQUE INDEX: name - - - - - composers - - id: idType()name: textColumnType() NOT NULL - - - UNIQUE INDEX: name - - - - - years - - id: idType()name: textColumnType() NOT NULL - - - UNIQUE INDEX: name - - - - - tracks - - id: idType()url: INTEGERartist: INTEGERalbum: INTEGERgenre: INTEGERcomposer: INTEGERyear: INTEGERtitle: textColumnType()comment: textColumnType()tracknumber: INTEGERdiscnumber: INTEGERbitrate: INTEGERlength: INTEGERsamplerate: INTEGERfilesize: INTEGERfiletype: INTEGERbpm: FLOATcreatedate: INTEGERmodifydate: INTEGERalbumgain: FLOATalbumpeakgain: FLOATtrackgain: FLOATtrackpeakgain: FLOAT - - - UNIQUE INDEX: urlINDEX: idINDEX: artistINDEX: albumINDEX: genreINDEX: composerINDEX: yearINDEX: titleINDEX: discnumberINDEX: createdateINDEX: lengthINDEX: bitrateINDEX: filesize - - - - - statistics - - id: idType()url: INTEGER NOT NULLcreatedate INTEGERaccessdate INTEGERscore: FLOATrating: INTEGER NOT NULL DEFAULT 0playcount: INTEGER NOT NULL DEFAULT 0deleted: BOOL - - - UNIQUE INDEX: urlINDEX: createdateINDEX: accessdateINDEX: scoreINDEX: ratingINDEX: playcount - - - - - - labels - - id: idType()label: textColumnType() - - - UNIQUE INDEX: label - - - - - - urls_labels - - url: INTEGERlabel: INTEGER - - - INDEX: urlINDEX: label - - - - - amazon - - asin: textColumnType(20)locale: textColumnType(2)filename: textColumnType(33)refetchdate: INTEGER - - - INDEX: refetchdate - - - - - lyrics - - id: idType()url: exactIndexableTextColumnType()lyrics: longTextColumnType() - - - UNIQUE INDEX url - - - - - - url: exactIndexableTextColumnType() NOT NULLfirstplayed: INTEGERlastplayed: INTEGERscore: FLOATrating: INTEGER DEFAULT 0playcount: INTEGER - - - UNIQUE INDEX: url - statistics_permanent - - - - - - name: textColumnType(108)artist: textColumnType(108)album: textColumnType(108)firstplayed: INTEGERlastplayed: INTEGERscore: FLOATrating: INTEGER DEFAULT 0playcount: INTEGER - - - UNIQUE INDEX: name, artist, album - statistics_tag - - - - - - - - - - - - - - - Database Version 14 - - - devices - - id: idType()type: textColumnType()label: textColumnType()lastmountpoint: textColumnType()uuid: textColumnType()servername: textColumnType(80)sharename: textColumnType(240) - - - INDEX: typeUNIQUE INDEX: uuidINDEX: servername, sharename - - - - - directories - - id: idType()deviceid: INTEGERdir: exactIndexableTextColumnType NOT NULLchangedate: INTEGER - - - INDEX: deviceid - - - - - albums - - id: idType()name: textColumnType() NOT NULLartist: INTEGERimage: INTEGER - - - UNIQUE INDEX: name, artistINDEX: artistINDEX: imageINDEX: name - - - - tracks - - id: idType()url: INTEGERartist: INTEGERalbum: INTEGERgenre: INTEGERcomposer: INTEGERyear: INTEGERtitle: textColumnType()comment: textColumnType()tracknumber: INTEGERdiscnumber: INTEGERbitrate: INTEGERlength: INTEGERsamplerate: INTEGERfilesize: INTEGERfiletype: INTEGERbpm: FLOATcreatedate: INTEGERmodifydate: INTEGERalbumgain: FLOATalbumpeakgain: FLOATtrackgain: FLOATtrackpeakgain: FLOAT - - - UNIQUE INDEX: urlINDEX: idINDEX: artistINDEX: albumINDEX: genreINDEX: composerINDEX: yearINDEX: titleINDEX: discnumberINDEX: createdateINDEX: lengthINDEX: bitrateINDEX: filesize - - - - urls_labels - - url: INTEGERlabel: INTEGER - - - INDEX: urlINDEX: label - - - - - amazon - - asin: textColumnType(20)locale: textColumnType(2)filename: textColumnType(33)refetchdate: INTEGER - - - INDEX: refetchdate - - - - - lyrics - - id: idType()url: exactIndexableTextColumnType()lyrics: longTextColumnType() - - - UNIQUE INDEX url - - - - - - url: exactIndexableTextColumnType() NOT NULLfirstplayed: INTEGERlastplayed: INTEGERscore: FLOATrating: INTEGER DEFAULT 0playcount: INTEGER - - - UNIQUE INDEX: url - statistics_permanent - - - - - - name: textColumnType(108)artist: textColumnType(108)album: textColumnType(108)firstplayed: INTEGERlastplayed: INTEGERscore: FLOATrating: INTEGER DEFAULT 0playcount: INTEGER - - - UNIQUE INDEX: name, artist, album - statistics_tag - - - - - - - - - - - textColumnType is varchar(255)exactTextColumnType is varchar(1000)exactIndexableTextColumnType is varchar(324) - textColumnType is varchar(255)exactTextColumnType is varchar(1000)exactIndexableTextColumnType is varchar(324) - - - - - tracks_labels - - track: INTEGERlabel: INTEGER - - - INDEX: track - - - - - tracks_composers - - track: INTEGERcomposer: INTEGER - - - INDEX: track - - - - - tracks_genres - - track: INTEGERgenre: INTEGER - - - INDEX: track - - - - - tracks_artists - - track: INTEGERartist: INTEGER - - - INDEX: track - - - - - - - - - tracks_albums - - track: INTEGERalbum: INTEGERtracknumber: INTEGERdiscnumber: INTEGER - - - INDEX: track - - - - statistics: INTEGERuniqueid: exactTextColumnType(255) - - modifydate: INTEGERdirectory: INTEGER - - statistic: INTEGER - - - - - - - - - urls - - id: idType()deviceid: INTEGERrpath: exactIndexableTextColumnType NOT NULLdirectory: INTEGER (the originating(parent)directory at the time of the scan)uniqueid: exactTextColumnType(128) UNIQUE - - - UNIQUE INDEX: deviceid, rpathINDEX: uniqueidINDEX: directory - - - - - modifydate: INTEGER - - - - statistic: INTEGERuniqueid: exactTextColumnType(255) - - - UNIQUE INDEX: uniqueid - statistics_id - statistic: INTEGER - - - - statistic: INTEGERurl: INTEGER - - - UNIQUE INDEX: url - statistics_device - These statistics objectsare used by the statisticsprovider. - - - - - artists - - id: idType()name: textColumnType() NOT NULL - - - UNIQUE INDEX: name - - - - - images - - id: idType()path: textColumnType() NOT NULL - - - UNIQUE INDEX: path - - - - - genres - - id: idType()name: textColumnType() NOT NULL - - - UNIQUE INDEX: name - - - - - composers - - id: idType()name: textColumnType() NOT NULL - - - UNIQUE INDEX: name - - - - - years - - id: idType()name: textColumnType() NOT NULL - - - UNIQUE INDEX: name - - - - - - labels - - id: idType()label: textColumnType() - - - UNIQUE INDEX: label - - - NOT NULL - url: INTEGER - - - - statistics - - id: idType()url: INTEGER NOT NULLcreatedate INTEGERaccessdate INTEGERscore: FLOATrating: INTEGER NOT NULL DEFAULT 0playcount: INTEGER NOT NULL DEFAULT 0deleted: BOOL - - - UNIQUE INDEX: urlINDEX: createdateINDEX: accessdateINDEX: scoreINDEX: ratingINDEX: playcount - - - - - - diff --git a/amarok/HACKING/architecture/Collections.txt b/amarok/HACKING/architecture/Collections.txt deleted file mode 100644 index 9f6c823a..00000000 --- a/amarok/HACKING/architecture/Collections.txt +++ /dev/null @@ -1,27 +0,0 @@ -Collection Architecture ------------------------ - -Collection is a container for a set of objects that collectively provider tracks to the application. -It does this by providing Meta::Base derieved objects via the QueryMaker (which every collection has). - -On plugin load a CollectionFactory is registered with CollectionManager which listens to the -newCollection() signal. CollectionManager is responsible for integrating the new Collection within -the rest of the application. Collection makes user visible strings, icons and other information -available for the UI to use. - -TrackProvider actually creates the Meta::Track objects using trackForUrl() which has a specially -formatted URL that is unique accross application settings. A collection has it's own URL protocol -which all uidUrl's of the collection's tracks start with. - -For getting tracks according to metadata or statistical information each Collection has a QueryMaker -implementation. Any component can get an instance of this specialized QueryMaker using Collection::queryMaker(). -CollectionManager has a special QueryMaker that will return results of all the registered collections -using their queryMaker(). Use this if you want a track resolved without caring about it's origin. - -TrackProvider and QueryMakers can be used seperatly from the collections. In practice though you'll -find only TrackProvider getting used by Services and the filesystem browser. If needing to combinine -it with a QueryMaker you are probably creating a Collection anyway. -Also note that Collection objects don't use shared pointers so they are not especially well protected -against getting removed. Holding the pointer to a QueryMaker for a prolonged amount of time -invites problems (e.g. when the usb device is removed. We had a number of bugs for this) - diff --git a/amarok/HACKING/architecture/Meta.txt b/amarok/HACKING/architecture/Meta.txt deleted file mode 100644 index 176247fd..00000000 --- a/amarok/HACKING/architecture/Meta.txt +++ /dev/null @@ -1,34 +0,0 @@ -Meta Architecture ------------------ - -The meta objects (located in src/core/meta) e.g. Meta::Track and the more -often used Meta::TrackPtr represent data connected to music related objects. - -There are classes for Tracks, Albums, Artists, Composers, Genres, Years and Labels. -These classes all derive from Meta::Base to facilitate their common methods (name -and sorting) and observer interaction. - -[Design decision] They are not QObjects to avoid the overhead of the Qt MetaObject -support variables. Collections are potentially millions of tracks where a significant -proportion of tracks (in the case of MemoryCollections: all tracks) could at any time -be loaded in memory. - -Meta::Observer is a virtual class that can be derived from by components that are -interested in changes to the tracks during application lifetime. It has -metadataChanged() methods for each of the Meta types and the ability to subscribe -to any Meta object. - -KSharedPtr is used for all functions returning a pointer in the Meta classes. It strong, -reference tracking smart pointer which will only delete an object once the last reference -holding KSharedPtr goes out of scope or is deleted. - -[Note] Playlists will be made part of Meta as well. They have a similar Observer -pattern but have been kept seperate because PlaylistObserver requires more functions. -Pollution of the Observer class could be avoided using a playlistChanged(enum Change, -QVariant value) type method. - -[Design decision] The list of meta objects contains Tracks, Albums, Artists, Composers, -Genres, Years and Labels because these are the categories that you can sort by in -the collection view and thus have to be returned by the QueryMaker and represented -in an item in the CollectionTreeItem. - diff --git a/amarok/HACKING/architecture/PlaybackQueue.txt b/amarok/HACKING/architecture/PlaybackQueue.txt deleted file mode 100644 index b01d62a2..00000000 --- a/amarok/HACKING/architecture/PlaybackQueue.txt +++ /dev/null @@ -1,14 +0,0 @@ -Playback Queue Architecture ---------------------------- - -Simple sequential list of upcoming tracks. The PlaybackController takes the first track on this list for playback. It does not include the currently playing track. -There are no modes (random, repeat, etc) affecting the playback order. The behavior of these modes are implemented using Playlists and playlist-tracking who change the actual content of the queue to get the same result. - -A QAbstractItemModel for the PlaybackQueue is exposed as the main interface. It's possible to insert and remove rows using the default methods and drag/drop of mime-data containing meta types is supported. It's a flat QModelIndex containing only tracks. For purposes of display it can be used with proxy models such as QtGroupingProxy to group by album/artist/composer. Sorting of the queue is possible but is one undoable QAction. How the new order is determined does not matter, but use a proxy models such as QSortFilterProxyModel is suggested because of it's well known semantics and uses within Amarok. -Using extra columns and data roles the PlaybackQueueModel gives info about certain queue-only information associated with a track. An example of this is whether a track is part of a tracked playlist or if a manual user interaction locked the track at it's current place. - -Playback history is not part of the PlaybackQueue. It has to be implemented separately using a PlaybackObserver. - -Old Playlist Queue Manager Behavior ------------------------------------ -Select in order and press Ctrl+U to move those tracks in selection order to the top of the queue. \ No newline at end of file diff --git a/amarok/HACKING/architecture/Playlists.txt b/amarok/HACKING/architecture/Playlists.txt deleted file mode 100644 index 135e00e2..00000000 --- a/amarok/HACKING/architecture/Playlists.txt +++ /dev/null @@ -1,88 +0,0 @@ -Playlist architecture ---------------------- -note: this is about the media sources playlist, *not* The Playlist as the playback queue has been called for historic reasons. - -A playlist is an ordered list of tracks. The creation method of this list determines the type (or category): -* When created by the user themselves and manually editable it's a User Playlist. - -* A Dynamic Playlist is generated based on some statistical rules. It's an amarok specific type that also reacts to changes made in the playback queue by the user. - -* A Smart Playlist is the result of a query of the Collections. It doesn't change unless it's being re-generated at startup or at the user's request. - -A Radio Channel has tracks that are not or only limited determined by the user but rather come in as a "stream" (high level). Implementation can be a single HTTP/RTSP URL like icecast or a pre-selected list of stream-able URLs such as with last.fm. The implementations can allow some control over track selection with functionality like last.fm's love/ban or tag selection like spotify. - -* Podcast Channels are also playlists that are generated by parsing a podcast feed (RSS or atom). They only contain tracks of the PodcastEpisode type. In amarok they are displayed separately from the other playlists but internally they use the same code such as the ItemModels, PlaylistManager and the synchronization support. - -[note] The Playlist base class currently lives in the Playlists:: namespace. It is to be moved to Meta::. - -Asynchronous Track Loading --------------------------- -The tracks() method will return immediately, possibly with a list of tracks that were already in memory. A call to the tracks() method might also do a triggerTrackLoad() which will start the asynchronous loading of tracks in the background. PlaylistObserver::trackAdded() will be called for each track that is added additionally to the playlist. trackRemoved() can also be called when the previous tracklist is affected. -[note] automatic loading and async depends on the implementation. - -PlaylistProvider ----------------- -The PlaylistProvider base class is registered with PlaylistManager so it can act as a central point to distribute playlist to other Amarok components. -Playlist loading can also be made asynchronous in the implementations. PlaylistProvider::playlistCount() can return -1 to indicate a full load is required to calculate this. After calling playlists(), which can return an empty list, playlistAdded() signals might be emitted while the asynchronous loading is going on. -PlaylistProviders can offer the UI QActions for the provider, a specific playlist or a specific track in a playlist. Playlist also has these last 2 methods which in the default implementation call the provider's implementations. It's recommended to implement playlist and track actions in the provider. - -Playlist Synchronization ------------------------- -It's possible to set up a link between playlists of the same category but from different PlaylistProviders. PlaylistManager will try to bring those playlists in the same state i.e. the same tracks in the same order. -The synchronization logic is implemented in SyncedPlaylist, a virtual class created with a factory pattern so other syncing algorithms can be applied at runtime. An example where this could be used: GPodderProvider's playlists are representations of the state of data on a web-service (gpodder.net). It has certain restrictions but also features that go beyond regular playlist synchronization. GPodderProvider can create a SyncedPlaylist class that specifically handles podcasts and keeps the limitations of the service and PodcastChannels in mind. -[note] currently podcast synchronization uses the special function Playlist::syncTrackStatus() which should be replaced by the above mechanism to avoid implementation-at-high-level-creep. - -A SynchronizedPlaylist will appear to the higher layers as one playlist which exists on multiple PlaylistProviders. In order to display the multiple copies to the user a QItemProxyModel is used by the UI. - -The synchronization algorithm uses only those functions that are also needed by the regular playlist use cases. In theory Playlist implementations don't need to think about synchronization. In practice synchronization will only properly work with fully functional PlaylistProvider and Playlist implementations, which are desirable anyway. - -PlaylistBrowserModel --------------------- -PlaylistBrowserModel is the base class for ItemModels used to display the various playlist types. Although all playlist can be displayed using this base class all categories have their own specialized implementation to implement setData(), dropMimeData() and category specific actions (ex. PodcastModel::refreshPodcasts()). Not that these are usually convenience version of Provider actions. -PlaylistBrowser model requests playlist for it's category from PlaylistManager who gathers them from the providers and group Synchronized playlists together in a SyncedPlaylist. PlaylistBrowserModel is a tree with playlist on the first level and tracks as it's children. In order to have playlists grouped by origin (i.e. PlaylistProvider) the PlaylistByProvider proxy. - -Playlist Tracking by PlaybackQueue ----------------------------------- -The PlaybackQueue can be made to track a single playlist's state. In general this just means that all current tracks of the playlist are appended to the queue and that it will act on trackAdded() signals. However, because the playback queue only has the upcoming tracks changes to tracks that have already been played are not possible. The distinction between a playlist and the queue has to be clear to the user. -Using playlist tracking it's possible to implement all modes of the old Playlist by creating categories implementing the behavior of the modes. - -User Playlists --------------- -File based: XSPFPlaylist, M3UPlaylist, PLSPlaylist -Database based: SqlPlaylist - -These playlists will load tracks using MetaProxy::Track which will start a worker thread to get a real track object using CollectionManager::trackForUrl(). It depends on the implementation and contents of the file which URL is used to resolve the track. -M3U and PLS by specification require their contents to be playable URLs. For most collections the playable URL and uidUrl won't match, so these tracks won't be playable until their "real" track is resolved. -XSPF does support storing of the uidUrl (identifier tag). Amarok always writes track's uidUrl to XSPF. The current playback queue state is also saved with XSPF to a dedicated file ($KDEHOME/share/apps/amarok/current.xspf). -The playlist implementation fills the proxy tracks with any tag information it has stored. This way a recently loaded playlist has usable content while loading tracks is done asynchronously. -If the playback queue is restored with invalid (empty) tracks, XSPFPlaylist, MetaProxy and CollectionManager::trackForUrl() are to be investigated. - -Dynamic Playlists ------------------ -Using a custom UI the settings for selecting tracks are configured. The Dynamic Playlist will select tracks and make them available from the tracks() method. These tracks can be displayed to the user as a preview of the settings but are mainly used in the playback queue. -Using the Selector/Bias system other components and plugins can add track selection conditions or statistical bias options to the dynamic playlist generator. -[note] current implementation does not derive from Playlists::Playlist nor does it use a PlaylistProvider. It's a mode of the playback queue, not a loadable playlist. - -Smart Playlists ---------------- -The basis of a Smart Playlist is a QueryMaker query and some additional limiters such as track count and total file size (useful to fill a media player). The list of tracks is not kept between sessions so a smart playlist is generated when first accessed. To avoid unneeded recalculation an active smart playlist will only be regenerated when the user requests it or when the synchronization of a playlist requires an up-to-date list. - -Podcast Channels ----------------- -This type is used for both the local (SQL based) PodcastProvider, some media device implementations and the gpodder web service. In the local collection the utility class PodcastReader is used to parse a podcast feed and update the PodcastChannel implementation. The base classes of PodcastMeta.cpp are used as intermediary data storage for new Channels and Episodes that have not been saved in the PodcastProvider yet. - -Radio Channels --------------- -The most common form of a radio channel is a HTTP stream. This implementation listens to signals from EngineController/PlaybackController/Phonon while playing the stream and determines when a metadata change represents a real track change. It will then push append the a new track with that metadata but the same url. This will not cause a real track change but rather a transition in the PlaybackController to the new playing track. It's a seamless progression in the PlaybackQueue as well. - -Services like last.fm and spotify also provider Radio Channels but it's implementation in possible user interaction is implementation specific. - -Random/Shuffle Playlist ------------------------ -This is a very simple randomizing playlist that takes the current play queue and shuffles the upcoming tracks at the start of a playing track. This way the user can see the next upcoming track already and change or remove them if desired. This playlist will respect the manual changes made to the playback order and not shuffle any of the tracks queued by the user. -The shuffling of tracks should be a visual animation to make it clear what is happening and be somewhat pleasing to watch. - -Old Playlist Queue Manager Behavior ------------------------------------ - -Implemented in PlaybackQueue. diff --git a/amarok/HACKING/building_amarok2_in_home.txt b/amarok/HACKING/building_amarok2_in_home.txt deleted file mode 100644 index 01ab5a79..00000000 --- a/amarok/HACKING/building_amarok2_in_home.txt +++ /dev/null @@ -1,92 +0,0 @@ -This document explains how to install Amarok 2 from git in your home directory - in an easy way :) -================================================================================================== - -A detailed blog post on how to make a local build can be found here: http://blogs.fsfe.org/myriam/2009/09/26/compiling-amarok-from-git-locally-full-summary/ - -* If you already have Amarok installed from your distro, uninstall it to prevent setting conflicts and similar. - -* Install git, the compiler and KDE 4 development packages: - - In Kubuntu, Debian, and all their derivatives: - sudo aptitude install git-core build-essential kdesdk kdelibs5-dev libkonq5-dev kdebase-workspace-dev - - In Archlinux: - sudo pacman -Sy git base-devel kdelibs kdebase-runtime - - In Gentoo: - sudo emerge -av dev-util/git kdelibs plasma-workspace - - In OpenSuSE: - sudo zypper install git - - In Fedora: - sudo yum install git kdelibs-devel - - -* Install ccache to speed up compilation - ccache -M 2G - -* Append the following to $HOME/.bashrc: - export PATH=$HOME/kde/bin:$PATH - export KDEDIR=$HOME/kde - export KDEDIRS=$KDEDIR - -* Reload your edited .bashrc: - source $HOME/.bashrc - - NOTE: if you are not using the bash shell, edit your proper shell config file (~/.zshrc or ~/.tcshrc or whatever it may be) - -* Make KDE aware of Amarok's plugin location: - echo 'export KDEDIR=$HOME/kde' >> $HOME/.kde/env/myenv.sh - echo 'export KDEDIRS=$KDEDIR' >> $HOME/.kde/env/myenv.sh - - Some distributions call the above folder $HOME/.kde4/... (OpenSuSE in particular). - -* Create folders: - mkdir $HOME/kde - mkdir $HOME/kde/src - mkdir -p $HOME/kde/build/amarok - -* Make sure you have all necessary dependencies - See the README file for the complete list of necessary dependencies. Make sure you have the development files of these packages. - For distribution specific requirements refer to http://community.kde.org/Amarok/Development/Development_HowTo - -* Check out Amarok: - cd $HOME/kde/src - git clone git://anongit.kde.org/amarok - -* Building: - cd $HOME/kde/build/amarok - cmake -DCMAKE_INSTALL_PREFIX=$HOME/kde -DCMAKE_BUILD_TYPE=debugfull $HOME/kde/src/amarok - make install - -* Enabling unit tests: - - If you are a regular Amarok contributor, please build with tests enabled. - - Install gmock from http://code.google.com/p/googlemock/ - Add the following flag to your cmake line: -DKDE4_BUILD_TESTS=ON - - Once compiled, jsut run the tests with 'make test' - - For more information about the test infrastructure, read the Qtestlib Manual: http://doc.trolltech.com/4.5/qtestlib-manual.html - -* Updating KDE Config: - kbuildsycoca4 --noincremental - - -Now you are ready to run Amarok 2, by typing "amarok" in the shell :) - -Please also refer to the following wiki page - http://techbase.kde.org/Getting_Started/Sources/KDE_git-tutorial - -NOTE: -If you have installed MySQL Embedded in non-default location (i.e. $HOME/usr), -Amarok may fail to start with error regarding libmysqlclient library. In this -case, add the following string to your ~/.bashrc: - export LD_LIBRARY_PATH=$HOME/usr/lib/mysql:$LD_LIBRARY_PATH - -where $HOME/usr is the path you've used in --prefix option. - - -Have fun :) diff --git a/amarok/HACKING/commit-template b/amarok/HACKING/commit-template deleted file mode 100644 index ace7bdd7..00000000 --- a/amarok/HACKING/commit-template +++ /dev/null @@ -1,23 +0,0 @@ - -# --[ Close bug in bugs.kde.org as fixed ]-----------------------------| -#BUG: -#FIXED-IN: -# -# --[ Add to release changelog optionally close wish in bugs.kde.org ]-| -#FEATURE: -#FIXED-IN: -# -# --[ Copy commit message to a bug or wish in bugs.kde.org ]-----------| -#CCBUG: -# -# --[ Copy commit message to an email address ]------------------------| -#CCMAIL: -# -# --[ Close a review on git.reviewboard.kde.org as submitted ]---------| -#REVIEW: -# -# --[ Notify documentation team of user visible changes ]--------------| -#GUI: -# -# --[ Notify Commit Digest team of something interesting ]-------------| -#DIGEST: diff --git a/amarok/HACKING/commitchecklist.txt b/amarok/HACKING/commitchecklist.txt deleted file mode 100644 index 4d5d21e7..00000000 --- a/amarok/HACKING/commitchecklist.txt +++ /dev/null @@ -1,21 +0,0 @@ -The following checklist is supposed to help you make sure you don't forget anything important in a commit. - -Before hacking: -* Does it fit Amarok's vision or at least not work against it? -* Who will maintain the code? - -Before committing: -* Does it conform to Amarok's coding style? -* Has it been added to the changelog in case of a bug, feature or UI change? -* Does it introduce new dependencies? -* Does the diff contain only the changes you made and files you added/removed? Does it contain all of them? -* Do existing regression tests still pass? -* Does it add new strings? Is Amarok in string freeze? -* Are you pushing a big change that does not fix a bug while Amarok is in beta? -* Is there a feature request, bug report or review request associated with it? (Please close them with the commit message.) - -Additionally for commits introducing new features: -* Is Amarok in feature freeze? -* Are new tests needed? -* Has it been reviewed by a usability person? -* Does user documentation exist? diff --git a/amarok/HACKING/const_correctness.txt b/amarok/HACKING/const_correctness.txt deleted file mode 100644 index 758b2383..00000000 --- a/amarok/HACKING/const_correctness.txt +++ /dev/null @@ -1,69 +0,0 @@ -=== Const Correctness === - -What is const correctness? - -It's a programming paradigm that helps writing correct code. In C++, const -correctness comprises a set of different techniques, you can read up about them -here [1]. In this article however I only want to focus on one form of const -correctness, that is object constness. - -Why should I care about const correctness? - -Because it increases type safety, makes your code more easy to understand, and -it helps making your code correct. - -Let's have an example, the following function: - -void printStruct( MyStruct* str ); - -Is it save to assume that MyStruct is unchanged? Can I give it a structure -that is allocated in a read-only memory location? -We can assume this (because of the name of the function) but we can't be sure. - -It get's even worse if you use a reference like this: - -void printStruct( MyStruct& str ); - -Now you can't even see in the calling code that something might go wrong since -a line like this: - -printStruct( str ); - -is not seen as dangerous. In C it is always a call-by-value. In C++ it isn't. - -The solution is easy. Just declare the function like this: - -void printStruct( const MyStruct& str ); - -Now nothing can go wrong. We get the benefit of a call-by-reference without -the danger. -Now one last problem. What if MyStruct is a class like this: - -class MyStruct { - void print(); -} - -How would the compiler know that calling "print" on the const MyStruct does -not change the object? -The compiler can't. We have to tell it like this: - - void print() const; - -Now everything is all right. Everybody is on the same page and we don't -have to look an hour which function might have changed our variables -in some unexpected place. - - -A last word about payoff. -Regardless if we are just programming for fun or professionally we should -think about payoff. - -Writing "const" all over the place is confusing, costs time and leads -to compile time errors. -So why the effort? -This does not really prevent many bugs. At least in my experience. -However it has one big benefit: It really helps searching bugs. Const- -correctness is really a nice thing since we are using more time searching -bugs than actually programming. - -[1] http://www.parashift.com/c++-faq-lite/const-correctness.html diff --git a/amarok/HACKING/git.txt b/amarok/HACKING/git.txt deleted file mode 100644 index 16c31a7f..00000000 --- a/amarok/HACKING/git.txt +++ /dev/null @@ -1,8 +0,0 @@ -This command is mandatory for all amarok developers: -git config branch.master.rebase true - -The result of this is that all "git pull" commands will do a rebase rather then a merge. -Your local commits will be rewritten (parented to origin/master). The prevents the log -to become unreadable because of all the merge commits. - -Note: rebasing can be dangerous. Check before pushing if something looks fishy. diff --git a/amarok/HACKING/intro_and_style.txt b/amarok/HACKING/intro_and_style.txt deleted file mode 100644 index 00f62351..00000000 --- a/amarok/HACKING/intro_and_style.txt +++ /dev/null @@ -1,383 +0,0 @@ -Hacking on Amarok ------------------ - -Have a look at the community wiki for further information. -Also have a look at the requirements for Amarok here: -http://community.kde.org/Amarok/Development/Requirements - -Join the irc channel. - -New requirements, bugfixes and every other patch goes to the -review board. -Try not to post patches in the bugs database or the mailing list. - -Please respect these guidelines when coding for Amarok, thanks! - -* Where this document isn't clear, refer to Amarok code. - - -This C++ FAQ is a life saver in many situations, so you want to keep it handy: - - http://www.parashift.com/c++-faq-lite/ - - -Formatting ----------- -* Spaces, not tabs -* Indentation is 4 spaces -* Lines should be limited to 90 characters -* Spaces between brackets and argument functions, except for template arguments -* For pointer and reference variable declarations put a space between the type - and the * or & and no space before the variable name. -* For if, else, while and similar statements put the brackets on the next line, - although brackets are not needed for single statements. -* Function and class definitions have their brackets on separate lines -* A function implementation's return type is on its own line. -* CamelCase.{cpp,h} style file names. -* Qt includes a foreach keyword which makes it very easy to iterate over all - elements of a container. - -Example: - - | bool - | MyClass::myMethod( QStringList list, const QString &name ) - | { - | if( list.isEmpty() ) - | return false; - | - | /* Define the temporary variable like this to restrict its scope - | * when you do not need it outside the loop. Let the compiler - | * optimise it. */ - | foreach( const QString &string, list ) - | debug() << "Current string is " << string << endl; - | - | switch( m_enumValue ) - | { - | case Something: - | return true; - | case SomethingElse: - | { - | int auxiliaryVariable; // needs scoping in case construct - | break; - | } - | } - | } - - -Using "astyle" for auto formatting ----------------------------------- -The program astyle can be used to automatically format source code, which can -be useful for badly formatted 3rd party patches. - -Use it like this to get (approximately) Amarok formatting style: - - "astyle -s4 -b -p -U -D -o source.cpp" - - -Class, Function & Variable Naming ---------------------------------- -*Use CamelCase for everything. -*Local variables should start out with a lowercase letter. -*Class names are captialized -*Prefix class member variables with m_, ex. m_trackList. -*Prefix static member variables with s_, ex s_instance -*Functions are named in the Qt style. It's like Java's, without the "get" - prefix. - *A getter is variable() - *If it's a getter for a boolean, prefix with 'is', so isCondition() - *A setter is setVariable( arg ). - - -Includes --------- -Header includes should be listed in the following order: - - Own Header - - Amarok includes, relative to src/ (or shared/) preferably - - KDE includes, is preferred to - - Qt includes - - other includes - -They should also be sorted alphabetically (case-sensitively: classes on same level before -folders), for ease of locating them. A small comment if applicable is also helpful. - -Includes in a header file should be kept to the absolute minimum, as to keep compile times -low. This can be achieved by using "forward declarations" instead of includes, like -"class QListView;" - -TIP: -Kate/KDevelop users can sort the headers automatically. Select the lines you want to sort, -then Tools -> Filter Selection Through Command -> "sort". - -In vim the same can be achieved by marking the block, and then doing ":sort". - -Example: - - | #include "MySuperWidget.h" - | - | #include "EngineController.h" - | #include "core/playlists/Playlist.h" - | #include "core/support/Debug.h" - | #include "core/support/Amarok.h" - | - | #include // baseclass - | #include // see function... - | - | #include - | #include - - -Comments --------- -Comment your code. Don't comment what the code does, comment on the purpose of the code. It's -good for others reading your code, and ultimately it's good for you too. - -Comments are essential when adding a strange hack, like the following example: - - | /** - | * Due to xine-lib, we have to make K3Process close all fds, otherwise we get "device - | * is busy" messages. Used by AmarokProcIO and AmarokProcess, exploiting commSetupDoneC(), - | * a virtual method that happens to be called in the forked process. - | * See bug #103750 for more information. - | */ - | class AmarokProcIO : public K3ProcIO - | { - | public: - | virtual int commSetupDoneC(); - | }; - - -Otherwise the comment is in the header. Use the Doxygen syntax. See: http://www.stack.nl/~dimitri/doxygen/ -You should be able to write this comment and explain the what the function does. -If you can't, go back to the code and think what you really wanted to do. -If the comment is getting to complicated or confusing, go back to the code and do better. - -Example: - - | /** - | * Start playback. - | * @param offset Start playing at @p msec position. - | * @return True for success. - | */ - | virtual bool play( uint offset = 0 ) = 0; - - -Header Formatting ------------------ -General rules apply here. Please keep header function definitions aligned nicely, -if possible. It helps greatly when looking through the code. Sorted methods, -either by name or by their function (ie, group all related methods together) is -great too. Access levels should be sorted in this order: public, protected, private. - - | #ifndef AMAROK_QUEUEMANAGER_H - | #define AMAROK_QUEUEMANAGER_H - | - | #include - | - | namespace MyNamespace { - | /** - | * View showing currently queued tracks. - | */ - | class QueueList : public QListView - | { - | Q_OBJECT - | - | public: - | explicit QueueList( QWidget *parent, const QString ̛&name = QString() ); - | ~QueueList(); - | - | public slots: - | void moveSelectedUp(); - | void moveSelectedDown(); - | - | private: - | int m_member; - | QHash m_names; - | }; - | } // namespace MyNamespace - | - | #endif /* AMAROK_QUEUEMANAGER_H */ - - -Associated .cpp file could look like (skipping license): - - | #define DEBUG_PREFIX "MyNamespace::QueueList" // only if you use debug(), warning()... - | - | #include "QueueList.h" - | - | using namespace MyNamespace; - | - | QueueList::QueueList( QWidget *parent, const QString ̛&name ) - | : QListView( parent ) - | , m_member( name.length() ) - | { - | } - - -0 vs NULL ---------- -The use of 0 to express a null pointer is preferred over the use of NULL. -0 is not a magic value, it's the defined value of the null pointer in C++. -NULL, on the other hand, is a preprocessor directive (#define) and not only is -it more typing than '0' but preprocessor directives are less elegant. - - | SomeClass *instance = 0; - - -Const Correctness ------------------ -Try to keep your code const correct. Declare methods const if they don't mutate the object, -and use const variables. It improves safety, and also makes it easier to understand the code. - -See: http://www.parashift.com/c++-faq-lite/const-correctness.html - const_correstness.txt - -Example: - - | bool - | MyClass::isValidFile( const QString &path ) const - | { - | const bool valid = QFile::exist( path ); - | return valid; - | } - - -Debugging ---------- -debug.h contains some handy functions for our debug console output. -Please use them instead of kDebug(). - -Usage: - - | #include "debug.h" - | - | debug() << "Something is happening"; - | warning() << "Something bad may happen"; - | error() << "Something bad did happen!"; - -Additionally, there are some macros for debugging functions: - -DEBUG_BLOCK -DEBUG_FUNC_INFO -DEBUG_LINE_INFO -DEBUG_INDENT -DEBUG_UNINDENT - -AMAROK_NOTIMPLEMENTED -AMAROK_DEPRECATED - -threadweaver.h has two additional macros: -DEBUG_THREAD_FUNC_INFO outputs the memory address of the current QThread or 'none' - if its the original GUI thread. -SHOULD_BE_GUI outputs a warning message if it occurs in a thread that isn't in - the original "GUI Thread", otherwise it is silent. Useful for documenting - functions and to prevent problems in the future. - - -Errors & Asserts ----------------- -*Use Q_ASSERT where appropriate. If you don't know what an assert is, look it up now. - -*Never use fatal(). There must be a better option than crashing a user's -application (its not uncommon for end-users to have debugging enabled). - -*KMessageBox is fine to use to prompt the user, but do not use it to display errors -or informational messages. Instead, KDE::StatusBar has a few handy methods. Refer to -amarok/src/statusbar/statusBarBase.h - - -Commenting Out Code -------------------- -Don't keep commented out code. It just causes confusion and makes the source -harder to read. Remember, the last revision before your change is always -availabe in Git. Hence no need for leaving cruft in the source. - -Wrong: - | myWidget->show(); - | //myWidget->rise(); // what is this good for? - -Correct: - | myWidget->show(); - - -Unit Tests and API Docs ------------------------ -Amarok uses the "Jenkins" system for doing automatic nightly builds, checking for -compile errors, and visualizing Unit Tests. You can see the results here: - -http://build.kde.org/view/EXTRAGEAR/job/amarok_master/ - -The API DOc for Amarok can be found here: - -http://api.kde.org/extragear-api/multimedia-apidocs/amarok/html/index.html - - -Tips & Tricks -------------- -A useful service is http://lxr.kde.org. Lxr is a cross reference of the entire -KDE SVN repository. You can for instance use it to search for example code -from other applications for a given KDElibs method. - - -Markey's .vimrc ---------------- - -let ruby_no_expensive = 1 -syntax on - -set shiftwidth=4 -set tabstop=4 -set expandtab -set hlsearch -set ruler -set smartindent -set nowrap - -set ignorecase -set smartcase - -set title -set showtabline=2 "Makes the status bar always show, also for just one tab - -autocmd FileType ruby set shiftwidth=2 tabstop=2 - - -Git and SVN aware prompt ----------------- -The following prompt shows the current git branch if sitting in a git repository. -Random crap courtesy of shell colours. -export PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\[\033[01;33m\]`git branch 2>/dev/null|cut -f2 -d\* -s`\[\033[00m\]\$ ' - -This is an even more colorful configuration for .bashrc that displays the -current git branch if sitting in a git repository and the current SVN revision -if sitting in an SVN checkout. -svn_prompt() { - SVNBRANCH=`svn info 2>/dev/null | grep Revision: | cut -f 2 -d " "` - if [ -n "$SVNBRANCH" ]; then - BRANCH=" (r$SVNBRANCH)"; - else - BRANCH=""; - fi - echo "$BRANCH" -} -export PS1='\[\e[0;32m\]\u@\h\[\e[m\] \[\e[1;34m\]\w\[\e[m\]\[\033[01;33m\]`__git_ps1`\[\e[m\]\[\e[01;35m\]`svn_prompt`\[\e[m\]\[\033[00m\] \[\e[1;32m\]\$ \[\e[m\]\[\e[1;37m\] ' - -Git KDE commit template ------------------------ - -HACKING/commit-template should be used so commits to KDE git servers are properly formatted and using the commit keywords. -configure git to use the template using: -git config commit.template HACKING/commmit-template - -Copyright ---------- -To comply with the GPL, add your name, email address & the year to the top of any file -that you edit. If you bring in code or files from elsewhere, make sure its -GPL-compatible and to put the authors name, email & copyright year to the top of -those files. - -Please note that it is not sufficient to write a pointer to the license (like a URL). -The complete license header needs to be written everytime. - - -Thanks, now have fun! - -- the Amarok developers diff --git a/amarok/HACKING/kconfig_guidelines.txt b/amarok/HACKING/kconfig_guidelines.txt deleted file mode 100644 index 6542e8de..00000000 --- a/amarok/HACKING/kconfig_guidelines.txt +++ /dev/null @@ -1,51 +0,0 @@ -Usage of Amarok::config() -------------------------- -We provide this method for convenience, but it is important to use it properly. By -inspection, we can see that we may produce very obscure bugs in the wrong case: - - | KConfig - | *config( const QString &group ) - | { - | //Slightly more useful config() that allows setting the group simultaneously - | KGlobal::config()->setGroup( group ); - | return KGlobal::config(); - | } - -Take the following example: - - | void - | f1() - | { - | KConfig *config = Amarok::config( "Group 2" ); - | config->writeEntry( "Group 2 Variable", true ); - | } - | - | void - | doStuff() - | { - | KConfig *config = Amarok::config( "Group 1" ); - | f1(); - | config->writeEntry( "Group 1 Variable", true ); - | } - -We would expect the following results: - - | [Group 1] - | Group 1 Variable = true - | - | [Group 2] - | Group 2 Variable = true - -However because the config group is changed before writing the entry: - | [Group 1] - | - | [Group 2] - | Group 1 Variable = true - | Group 2 Variable = true - -Which is clearly incorrect. And hard to see when your wondering why f1() is not -working. So do not store a value of Amarok::config, make it a habit to just -always call writeEntry or readEntry directly. - -Correct: - | amarok::config( "Group 1" )->writeEntry( "Group 1 Variable", true ); diff --git a/amarok/HACKING/memory_management_tips.txt b/amarok/HACKING/memory_management_tips.txt deleted file mode 100644 index 76f91161..00000000 --- a/amarok/HACKING/memory_management_tips.txt +++ /dev/null @@ -1,117 +0,0 @@ -TIPS FOR CORRECT MEMORY MANAGEMENT WITH C++ AND QT -================================================== - - -1) -Use of "Smart Pointers": -A smart pointer in C++ means (in its most simple incarnation) a -pointer that automatically sets itself to 0, when the object it points -to is being destroyed (deleted). - -Advantages: - -No risk of "dangling pointers". A dangling pointer is a pointer that -has been deleted, but still contains the memory address of the object -that has been destroyed. What happens if you delete this again is -called a "double-free", and almost always leads to a crash. With a -smart pointer, you can delete the object safely again, because -deleting a 0-pointer is defined as a safe (doing nothing) operation in -the C++ standard. - -Example: - -WRONG: - -QWidget* foo = new QWidget(); -delete foo; -delete foo; - - -RIGHT: - -QPointer foo = new QWidget(); -delete foo; -delete foo; - - - -2) -Always make sure not to dereference a 0-pointer: - -This is _the_ single most common crash cause in Amarok 2 currently. -It's easy to prevent, but unfortunately also easy to miss: - -Example: - -WRONG: - -Meta::TrackPtr foo; -debug() << foo->prettyUrl(); - - -RIGHT: - -Meta::TrackPtr foo; -if( foo ) - debug() << foo->prettyUrl(); - - -Also be aware that Amarok is multi-threaded. So somebody could -change pointers while you are looking away like here: - -WRONG: - -Meta::TrackPtr myTrack; -if( myTrack && myTrack->album() ) - debug() << myTrack->album()->name(); - - -RIGHT: - -Meta::TrackPtr myTrack; -Meta::AlbumPtr myAlbum = myTrack ? myTrack->album() : 0; -if( myAlbum ) - debug() << myAlbum->name(); - - -3) -Private d-pointer classes can be used in cases where the interfaces -of a library should remain stable but the size of members and their -inner working should change. -Qt is doing it. KDE is doing it. We are also doing it in some places -for no apparent reason and no benefit. - -However, if you are doing it, never, ever, use private d-pointer -classes in QObject derived subclasses: - -What can happen is that you do a "delete d;" in your destructor, and -then Qt goes ahead and auto-deletes other QObject pointers contained -in the private class again, through means of its automatic deleting of -QObjects with a parent Object. -> - -Read more about this topic in Michael Pyne's interesting blog article: - -http://www.purinchu.net/wp/2009/02/04/another-programming-tidbit/ - - -4) -Use Valgrind: - - -This is one of the most advanced memory debugging tools available, -it's free, and we even have found volunteers that run regular Valgrind -checks (both for memory access bugs and memory leaks) on Amarok trunk. -Reading the Valgrind logs correctly is a bit of an art in itself, but -I'm willing to explain this in another posting, if there is a demand. - - -Recommended reading on the topic of memory management is this page of -the excellent "C++ FAQ Lite": - -http://www.parashift.com/c++-faq-lite/freestore-mgmt.html - diff --git a/amarok/HACKING/mysql_database_schema.txt b/amarok/HACKING/mysql_database_schema.txt deleted file mode 100644 index f83c3b1e..00000000 --- a/amarok/HACKING/mysql_database_schema.txt +++ /dev/null @@ -1,616 +0,0 @@ - -Warning: outdated. -Look at HACKING/amarokTables.svg and keep it up to date. - - --- MySQL dump 10.13 Distrib 5.1.58, for debian-linux-gnu (x86_64) --- --- Host: localhost Database: amarok --- ------------------------------------------------------ --- Server version 5.1.58-1ubuntu1 - -/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; -/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; -/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; -/*!40101 SET NAMES utf8 */; -/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; -/*!40103 SET TIME_ZONE='+00:00' */; -/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; -/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; -/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; -/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; - --- --- Table structure for table `admin` --- - -DROP TABLE IF EXISTS `admin`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `admin` ( - `component` varchar(255) COLLATE utf8_bin DEFAULT NULL, - `version` int(11) DEFAULT NULL -) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `albums` --- - -DROP TABLE IF EXISTS `albums`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `albums` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(255) COLLATE utf8_bin NOT NULL, - `artist` int(11) DEFAULT NULL, - `image` int(11) DEFAULT NULL, - PRIMARY KEY (`id`), - UNIQUE KEY `albums_name_artist` (`name`,`artist`), - KEY `albums_name` (`name`), - KEY `albums_artist` (`artist`), - KEY `albums_image` (`image`) -) ENGINE=MyISAM AUTO_INCREMENT=547 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `amazon` --- - -DROP TABLE IF EXISTS `amazon`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `amazon` ( - `asin` varchar(20) COLLATE utf8_bin DEFAULT NULL, - `locale` varchar(2) COLLATE utf8_bin DEFAULT NULL, - `filename` varchar(33) COLLATE utf8_bin DEFAULT NULL, - `refetchdate` int(11) DEFAULT NULL, - KEY `amazon_date` (`refetchdate`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `artists` --- - -DROP TABLE IF EXISTS `artists`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `artists` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(255) COLLATE utf8_bin NOT NULL, - PRIMARY KEY (`id`), - UNIQUE KEY `artists_name` (`name`) -) ENGINE=MyISAM AUTO_INCREMENT=966 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `bookmark_groups` --- - -DROP TABLE IF EXISTS `bookmark_groups`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `bookmark_groups` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `parent_id` int(11) DEFAULT NULL, - `name` varchar(255) COLLATE utf8_bin DEFAULT NULL, - `description` varchar(255) COLLATE utf8_bin DEFAULT NULL, - `custom` varchar(255) COLLATE utf8_bin DEFAULT NULL, - PRIMARY KEY (`id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `bookmarks` --- - -DROP TABLE IF EXISTS `bookmarks`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `bookmarks` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `parent_id` int(11) DEFAULT NULL, - `name` varchar(255) COLLATE utf8_bin DEFAULT NULL, - `url` varchar(1000) COLLATE utf8_bin DEFAULT NULL, - `description` varchar(1000) COLLATE utf8_bin DEFAULT NULL, - `custom` varchar(255) COLLATE utf8_bin DEFAULT NULL, - PRIMARY KEY (`id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `composers` --- - -DROP TABLE IF EXISTS `composers`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `composers` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(255) COLLATE utf8_bin NOT NULL, - PRIMARY KEY (`id`), - UNIQUE KEY `composers_name` (`name`) -) ENGINE=MyISAM AUTO_INCREMENT=268 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `devices` --- - -DROP TABLE IF EXISTS `devices`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `devices` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `type` varchar(255) COLLATE utf8_bin DEFAULT NULL, - `label` varchar(255) COLLATE utf8_bin DEFAULT NULL, - `lastmountpoint` varchar(255) COLLATE utf8_bin DEFAULT NULL, - `uuid` varchar(255) COLLATE utf8_bin DEFAULT NULL, - `servername` varchar(80) COLLATE utf8_bin DEFAULT NULL, - `sharename` varchar(240) COLLATE utf8_bin DEFAULT NULL, - PRIMARY KEY (`id`), - UNIQUE KEY `devices_uuid` (`uuid`), - KEY `devices_type` (`type`), - KEY `devices_rshare` (`servername`,`sharename`) -) ENGINE=MyISAM AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `directories` --- - -DROP TABLE IF EXISTS `directories`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `directories` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `deviceid` int(11) DEFAULT NULL, - `dir` varchar(1000) COLLATE utf8_bin NOT NULL, - `changedate` int(11) DEFAULT NULL, - PRIMARY KEY (`id`), - KEY `directories_deviceid` (`deviceid`) -) ENGINE=MyISAM AUTO_INCREMENT=1051 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `genres` --- - -DROP TABLE IF EXISTS `genres`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `genres` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(255) COLLATE utf8_bin NOT NULL, - PRIMARY KEY (`id`), - UNIQUE KEY `genres_name` (`name`) -) ENGINE=MyISAM AUTO_INCREMENT=132 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `images` --- - -DROP TABLE IF EXISTS `images`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `images` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `path` varchar(255) COLLATE utf8_bin NOT NULL, - PRIMARY KEY (`id`), - UNIQUE KEY `images_name` (`path`) -) ENGINE=MyISAM AUTO_INCREMENT=356 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `labels` --- - -DROP TABLE IF EXISTS `labels`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `labels` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `label` varchar(255) COLLATE utf8_bin DEFAULT NULL, - PRIMARY KEY (`id`), - UNIQUE KEY `labels_label` (`label`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `lyrics` --- - -DROP TABLE IF EXISTS `lyrics`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `lyrics` ( - `url` int(11) NOT NULL, - `lyrics` text COLLATE utf8_bin, - PRIMARY KEY (`url`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `magnatune_albums` --- - -DROP TABLE IF EXISTS `magnatune_albums`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `magnatune_albums` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(255) COLLATE utf8_bin DEFAULT NULL, - `year` int(11) DEFAULT NULL, - `artist_id` int(11) DEFAULT NULL, - `album_code` varchar(255) COLLATE utf8_bin DEFAULT NULL, - `cover_url` varchar(1000) COLLATE utf8_bin DEFAULT NULL, - `description` varchar(1000) COLLATE utf8_bin DEFAULT NULL, - PRIMARY KEY (`id`), - KEY `magnatune_albums_name` (`name`), - KEY `magnatune_albums_artist_id` (`artist_id`) -) ENGINE=MyISAM AUTO_INCREMENT=1154 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `magnatune_artists` --- - -DROP TABLE IF EXISTS `magnatune_artists`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `magnatune_artists` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(255) COLLATE utf8_bin DEFAULT NULL, - `artist_page` varchar(1000) COLLATE utf8_bin DEFAULT NULL, - `description` varchar(255) COLLATE utf8_bin DEFAULT NULL, - `photo_url` varchar(1000) COLLATE utf8_bin DEFAULT NULL, - PRIMARY KEY (`id`), - KEY `magnatune_artists_name` (`name`) -) ENGINE=MyISAM AUTO_INCREMENT=500 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `magnatune_genre` --- - -DROP TABLE IF EXISTS `magnatune_genre`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `magnatune_genre` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(255) COLLATE utf8_bin DEFAULT NULL, - `album_id` int(11) DEFAULT NULL, - PRIMARY KEY (`id`), - KEY `magnatune_genre_name` (`name`), - KEY `magnatune_genre_album_id` (`album_id`) -) ENGINE=MyISAM AUTO_INCREMENT=2783 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `magnatune_moods` --- - -DROP TABLE IF EXISTS `magnatune_moods`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `magnatune_moods` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `track_id` int(11) DEFAULT NULL, - `mood` varchar(255) COLLATE utf8_bin DEFAULT NULL, - PRIMARY KEY (`id`) -) ENGINE=MyISAM AUTO_INCREMENT=2762 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `magnatune_tracks` --- - -DROP TABLE IF EXISTS `magnatune_tracks`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `magnatune_tracks` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(255) COLLATE utf8_bin DEFAULT NULL, - `track_number` int(11) DEFAULT NULL, - `length` int(11) DEFAULT NULL, - `album_id` int(11) DEFAULT NULL, - `artist_id` int(11) DEFAULT NULL, - `preview_lofi` varchar(1000) COLLATE utf8_bin DEFAULT NULL, - `preview_ogg` varchar(1000) COLLATE utf8_bin DEFAULT NULL, - `preview_url` varchar(1000) COLLATE utf8_bin DEFAULT NULL, - PRIMARY KEY (`id`), - KEY `magnatune_tracks_album_id` (`album_id`), - KEY `magnatune_tracks_artist_id` (`artist_id`) -) ENGINE=MyISAM AUTO_INCREMENT=14831 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `playlist_groups` --- - -DROP TABLE IF EXISTS `playlist_groups`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `playlist_groups` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `parent_id` int(11) DEFAULT NULL, - `name` varchar(255) COLLATE utf8_bin DEFAULT NULL, - `description` varchar(255) COLLATE utf8_bin DEFAULT NULL, - PRIMARY KEY (`id`), - KEY `parent_podchannel` (`parent_id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `playlist_tracks` --- - -DROP TABLE IF EXISTS `playlist_tracks`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `playlist_tracks` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `playlist_id` int(11) DEFAULT NULL, - `track_num` int(11) DEFAULT NULL, - `url` varchar(1000) COLLATE utf8_bin DEFAULT NULL, - `title` varchar(255) COLLATE utf8_bin DEFAULT NULL, - `album` varchar(255) COLLATE utf8_bin DEFAULT NULL, - `artist` varchar(255) COLLATE utf8_bin DEFAULT NULL, - `length` int(11) DEFAULT NULL, - `uniqueid` varchar(128) COLLATE utf8_bin DEFAULT NULL, - PRIMARY KEY (`id`), - KEY `parent_playlist_tracks` (`playlist_id`), - KEY `playlist_tracks_uniqueid` (`uniqueid`) -) ENGINE=MyISAM AUTO_INCREMENT=45 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `playlists` --- - -DROP TABLE IF EXISTS `playlists`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `playlists` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `parent_id` int(11) DEFAULT NULL, - `name` varchar(255) COLLATE utf8_bin DEFAULT NULL, - `description` varchar(255) COLLATE utf8_bin DEFAULT NULL, - `urlid` varchar(1000) COLLATE utf8_bin DEFAULT NULL, - PRIMARY KEY (`id`), - KEY `parent_playlist` (`parent_id`) -) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `podcastchannels` --- - -DROP TABLE IF EXISTS `podcastchannels`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `podcastchannels` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `url` text COLLATE utf8_bin, - `title` text COLLATE utf8_bin, - `weblink` text COLLATE utf8_bin, - `image` text COLLATE utf8_bin, - `description` text COLLATE utf8_bin, - `copyright` varchar(255) COLLATE utf8_bin DEFAULT NULL, - `directory` varchar(255) COLLATE utf8_bin DEFAULT NULL, - `labels` varchar(255) COLLATE utf8_bin DEFAULT NULL, - `subscribedate` varchar(255) COLLATE utf8_bin DEFAULT NULL, - `autoscan` tinyint(1) DEFAULT NULL, - `fetchtype` int(11) DEFAULT NULL, - `haspurge` tinyint(1) DEFAULT NULL, - `purgecount` int(11) DEFAULT NULL, - `writetags` tinyint(1) DEFAULT NULL, - `filenamelayout` varchar(1024) COLLATE utf8_bin DEFAULT NULL, - PRIMARY KEY (`id`), - FULLTEXT KEY `url_podchannel` (`url`) -) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `podcastepisodes` --- - -DROP TABLE IF EXISTS `podcastepisodes`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `podcastepisodes` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `url` text COLLATE utf8_bin, - `channel` int(11) DEFAULT NULL, - `localurl` text COLLATE utf8_bin, - `guid` varchar(1000) COLLATE utf8_bin DEFAULT NULL, - `title` text COLLATE utf8_bin, - `subtitle` text COLLATE utf8_bin, - `sequencenumber` int(11) DEFAULT NULL, - `description` text COLLATE utf8_bin, - `mimetype` varchar(255) COLLATE utf8_bin DEFAULT NULL, - `pubdate` varchar(255) COLLATE utf8_bin DEFAULT NULL, - `duration` int(11) DEFAULT NULL, - `filesize` int(11) DEFAULT NULL, - `isnew` tinyint(1) DEFAULT NULL, - PRIMARY KEY (`id`), - FULLTEXT KEY `url_podepisode` (`url`), - FULLTEXT KEY `localurl_podepisode` (`localurl`) -) ENGINE=MyISAM AUTO_INCREMENT=263 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `statistics` --- - -DROP TABLE IF EXISTS `statistics`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `statistics` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `url` int(11) NOT NULL, - `createdate` int(11) DEFAULT NULL, - `accessdate` int(11) DEFAULT NULL, - `score` float DEFAULT NULL, - `rating` int(11) NOT NULL DEFAULT '0', - `playcount` int(11) NOT NULL DEFAULT '0', - `deleted` tinyint(1) NOT NULL DEFAULT '0', - PRIMARY KEY (`id`), - UNIQUE KEY `statistics_url` (`url`), - KEY `statistics_createdate` (`createdate`), - KEY `statistics_accessdate` (`accessdate`), - KEY `statistics_score` (`score`), - KEY `statistics_rating` (`rating`), - KEY `statistics_playcount` (`playcount`) -) ENGINE=MyISAM AUTO_INCREMENT=6721 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `statistics_permanent` --- - -DROP TABLE IF EXISTS `statistics_permanent`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `statistics_permanent` ( - `url` varchar(324) COLLATE utf8_bin NOT NULL, - `firstplayed` datetime DEFAULT NULL, - `lastplayed` datetime DEFAULT NULL, - `score` float DEFAULT NULL, - `rating` int(11) DEFAULT '0', - `playcount` int(11) DEFAULT NULL, - UNIQUE KEY `stats_perm_url` (`url`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `statistics_tag` --- - -DROP TABLE IF EXISTS `statistics_tag`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `statistics_tag` ( - `name` varchar(108) COLLATE utf8_bin DEFAULT NULL, - `artist` varchar(108) COLLATE utf8_bin DEFAULT NULL, - `album` varchar(108) COLLATE utf8_bin DEFAULT NULL, - `firstplayed` datetime DEFAULT NULL, - `lastplayed` datetime DEFAULT NULL, - `score` float DEFAULT NULL, - `rating` int(11) DEFAULT '0', - `playcount` int(11) DEFAULT NULL, - UNIQUE KEY `stats_tag_name_artist_album` (`name`,`artist`,`album`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `tracks` --- - -DROP TABLE IF EXISTS `tracks`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `tracks` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `url` int(11) DEFAULT NULL, - `artist` int(11) DEFAULT NULL, - `album` int(11) DEFAULT NULL, - `genre` int(11) DEFAULT NULL, - `composer` int(11) DEFAULT NULL, - `year` int(11) DEFAULT NULL, - `title` varchar(255) COLLATE utf8_bin DEFAULT NULL, - `comment` text COLLATE utf8_bin, - `tracknumber` int(11) DEFAULT NULL, - `discnumber` int(11) DEFAULT NULL, - `bitrate` int(11) DEFAULT NULL, - `length` int(11) DEFAULT NULL, - `samplerate` int(11) DEFAULT NULL, - `filesize` int(11) DEFAULT NULL, - `filetype` int(11) DEFAULT NULL, - `bpm` float DEFAULT NULL, - `createdate` int(11) DEFAULT NULL, - `modifydate` int(11) DEFAULT NULL, - `albumgain` float DEFAULT NULL, - `albumpeakgain` float DEFAULT NULL, - `trackgain` float DEFAULT NULL, - `trackpeakgain` float DEFAULT NULL, - PRIMARY KEY (`id`), - UNIQUE KEY `tracks_url` (`url`), - KEY `tracks_id` (`id`), - KEY `tracks_artist` (`artist`), - KEY `tracks_album` (`album`), - KEY `tracks_genre` (`genre`), - KEY `tracks_composer` (`composer`), - KEY `tracks_year` (`year`), - KEY `tracks_title` (`title`), - KEY `tracks_discnumber` (`discnumber`), - KEY `tracks_createdate` (`createdate`), - KEY `tracks_length` (`length`), - KEY `tracks_bitrate` (`bitrate`), - KEY `tracks_filesize` (`filesize`) -) ENGINE=MyISAM AUTO_INCREMENT=6721 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `urls` --- - -DROP TABLE IF EXISTS `urls`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `urls` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `deviceid` int(11) DEFAULT NULL, - `rpath` varchar(324) COLLATE utf8_bin NOT NULL, - `directory` int(11) DEFAULT NULL, - `uniqueid` varchar(128) COLLATE utf8_bin DEFAULT NULL, - PRIMARY KEY (`id`), - UNIQUE KEY `uniqueid` (`uniqueid`), - UNIQUE KEY `urls_id_rpath` (`deviceid`,`rpath`), - KEY `urls_uniqueid` (`uniqueid`), - KEY `urls_directory` (`directory`) -) ENGINE=MyISAM AUTO_INCREMENT=6721 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `urls_labels` --- - -DROP TABLE IF EXISTS `urls_labels`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `urls_labels` ( - `url` int(11) DEFAULT NULL, - `label` int(11) DEFAULT NULL, - KEY `urlslabels_url` (`url`), - KEY `urlslabels_label` (`label`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `years` --- - -DROP TABLE IF EXISTS `years`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `years` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(255) COLLATE utf8_bin NOT NULL, - PRIMARY KEY (`id`), - UNIQUE KEY `years_name` (`name`) -) ENGINE=MyISAM AUTO_INCREMENT=73 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; -/*!40101 SET character_set_client = @saved_cs_client */; -/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; - -/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; -/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; -/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; -/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; -/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; -/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; -/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; - --- Dump completed on 2011-12-21 12:50:14 diff --git a/amarok/HACKING/smart_pointers.txt b/amarok/HACKING/smart_pointers.txt deleted file mode 100644 index 808cf9fd..00000000 --- a/amarok/HACKING/smart_pointers.txt +++ /dev/null @@ -1,40 +0,0 @@ -QWeakPointer -==================== -QWeakPointer is a guarded pointer for QObjects, so it automatically becomes 0 when -the data it points to is deleted. If you have a member variable that's a QObject -and are ever worried that it might be dangling, make it a QWeakPointer. There's -really no reason not to for variables that stick around, it adds little -overhead. - -KSharedPtr -==================== -Unlike QWeakPointer, KSharedPtr is dangerous and must be used carefully. - -== Undercounting == -KSharedPtr uses reference counting. When a KSharedPtr is in scope, it adds one -to the reference counter. When a KSharedPtr loses scope, it deletes one from the -reference count. When the reference count become 0 it deletes the object. So if -there were any normal pointers to that data and all the KSharedPtrs are deleted, -then the object is deleted and the normal pointers dangle. Segfaults ensue. - -The solution is to just make sure that any normal pointers are temporary and -everything else is a KSharedPtr if reference counting is required for your class. Even -if the pointer is temporary, but is then handed off to some other class that -might keep it around, thats a potentional crash now or in the future. - - -== Reference Cycles == -One issue with reference counting in general is the creation of a reference -cycle. If class A has a KSharedPtr property and class B has a KSharedPtr -property and two objects of A and B point to each other and the KSharedPtrs -loose scope, a reference cycle is created. Despite not being accessible from -anywhere in the program, the reference counter of KSharedPtr and -KSharedPtr will never go to 0. Memory leaks. The solution is to be careful. - -== Dreaded Diamonds == -Since the objects KSharedPtr point to must derive from QSharedData, it's not -uncommon for a "dreaded diamond" inheritance issue to arise. Basically if A and -B both inherit QSharedData and C inherits A and B, then C inherits QSharedData -twice. The solution is really easy, just add a 'virtual' keyword when A and B -inherit QSharedData. Eg class A : public virtual QSharedData. Details at: -http://www.parashift.com/c++-faq-lite/multiple-inheritance.html#faq-25.8 diff --git a/amarok/HACKING/static_variables.txt b/amarok/HACKING/static_variables.txt deleted file mode 100644 index 5da671c2..00000000 --- a/amarok/HACKING/static_variables.txt +++ /dev/null @@ -1,58 +0,0 @@ -Preface: -====== -You've probably noticed the epic struggle we've had with Amarok 2 -hanging on exit. After _months_ of tinkering I've now been able to -identify and fix this issue. This document explains how to prevent -such issues in the future. - -What is a static object? -================= -A static object is being initialized on program start, and will only -become instantiated once. It's conveniently used with the singleton -design pattern, e.g. in Amarok code. - -Example: - -static AmarokMenu s_menu; - -What is so dangerous about static objects? -================================ -A static object's destructor is called _after_ the QApplication -destructor has been executed. This is fine for plain old datatypes -(POD) like int, float, and pointers, as they do not have a destructor. -It's also fine for objects with a trivial destructor that does not -interfere with the rest of the program. - -The danger lies in using static objects that call other parts of the -application in their destructor. This is e.g. true for most QObjects, -which rely on the QApplication being intact. If the QApplication is -destroyed before the static QObject's destructor is run, _bad_ things -can happen. To name a few: Crashing, hanging, eating live kitten, or -forcing you to use XMMS. - -How can I prevent these problems? -========================== -Use K_GLOBAL_STATIC, and use qAddPostRoutine() to ensure that the -static object's destructor is called when QCoreApplication destructs. - -Example: - -class AmarokMenu : public QMenu -{ - AmarokMenu(); -}; -K_GLOBAL_STATIC( AmarokMenu, s_menu ) - -AmarokMenu::AmarokMenu() -{ - // K_GLOBAL_STATIC is cleaned up *after* Q(Core)Application is gone - // but we have to cleanup before -> use qAddPostRoutine - qAddPostRoutine( s_menu.destroy ); -} - -Further reading: -=========== -http://api.kde.org/4.0-api/kdelibs-apidocs/kdecore/html/group__KDEMacros.html - - -Thanks for reading, and happy hacking :) \ No newline at end of file diff --git a/amarok/HACKING/templates/Template.cpp b/amarok/HACKING/templates/Template.cpp deleted file mode 100644 index a1862585..00000000 --- a/amarok/HACKING/templates/Template.cpp +++ /dev/null @@ -1,33 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Foo Bar * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "Template.h" - -#include "Debug.h" - - -Template::Template() -{ - DEBUG_BLOCK -} - -Template::~Template() -{ - DEBUG_BLOCK -} - - -#include "moc_Template.cpp" diff --git a/amarok/HACKING/templates/Template.h b/amarok/HACKING/templates/Template.h deleted file mode 100644 index 64630e6e..00000000 --- a/amarok/HACKING/templates/Template.h +++ /dev/null @@ -1,44 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Foo Bar * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_TEMPLATE_H -#define AMAROK_TEMPLATE_H - -#include - -/** - * A class for blah - * - **/ -class /*AMAROK_EXPORT*/ Template : public QObject -{ - Q_OBJECT - - public: - Template(); - ~Template(); - - public Q_SLOTS: - - protected: - - private Q_SLOTS: - - private: -}; - - -#endif // end include guard diff --git a/amarok/HACKING/usability.txt b/amarok/HACKING/usability.txt deleted file mode 100644 index 8c1439cf..00000000 --- a/amarok/HACKING/usability.txt +++ /dev/null @@ -1,96 +0,0 @@ -=== USABILITY === - -This article was originally published here: - -http://amarok.kde.org/blog/archives/1132-Micro-Options,-Many-Options,-No-Options-A-practical-guide-to-help-you-decide..html - - - -Not very long ago, Aaron wrote an article about improving our user experience, stating that -"Micro-Options Suck". Coincidentally, an article appeared on dot.kde.org only a few hours later, stating the -following: "Choice Is Not A Usability Problem". - -Ardent readers will notice that there is possibly a contradiction here. In this -article I would like to explain why this is not really a contradiction, but -rather a misunderstanding. To get us started, let's make a jump back in time -(using Flux Capacitor technology): - -The year is 2004. It's cold. You are alone. There is a house in the north -(called "KDE"), and a house in the south ("GNOME"). Press "n" or "s". - -> n - -You have entered the house of KDE. It's a big house, full of obscure items. The -sheer number of items is highly impressive, but you get confused. It is too -much. What is your next step? Press "n" or "s". - -> s - -You have entered the house of GNOME. This house is neat, clean, but also kind of -empty. There are very few things to play with. You get confused. What is your -next step? - -> I give up. User reboots into Windows. - - -The gist of this little analogy: - -KDE was wrong. GNOME was wrong. Also - they both were right! - - -This is quite obviously another contradiction. Obviously this means that Mark is -not quite right in the head! Well, you're possibly right on both accounts, but -let me explain why it actually makes sense: The truth is somewhere in -between. - -KDE has historically been known for being "the nerd's desktop". Basically, we -were so proud of having our own desktop that we quickly determined that giving -everyone as much freedom as possible is ideal. After all, the competition -(Windows) did not offer this. Developer A came along, going "Hey, I have this -fancy idea. It's a bit weird, but let me show you!". Developer B was quick to -reply: "Hell yeah, why not? After all this is our own desktop. We can make all -of our dreams come true. Let's do it!" - -GNOME has historically been known for being very sparse with options. They did -this for a good reason: Someone smart realized that KDE was totally going -overboard with options. Too much is too much. Let me show you a classical -example: - -http://amarok.kde.org/blog/uploads/crypto_ssl.jpg - - -Now let me show you an example of the Dolphin settings dialog: - -http://amarok.kde.org/blog/uploads/dolphin_settings.png - - -Dolphin has won 2009's Akademy Award for "Best Application". The above -screenshot demonstrates one of our reasons for choosing it: Peter Penz realized -what generations of GUI developers (both in KDE and GNOME) got wrong: The true -secret to getting your settings right is choosing the essential ones, while -making good choices for defaults that don't need micro-options. - -Unfortunately, this is not easy, and it separates the good GUI designer from the -bad one. In fact making these choices is bloody damn hard, I kid you not. It -requires a lot of thought, experience, and taste. But in the end, you, as a -developer, are responsible for making these choices. Creating software is not -about giving the user a LEGO blocks game. If options get too complex, the users -might as well learn programming and do it all by themselves. That's because, if -you think about it, choosing an option is programming: You make the -program use one code path, or a different one. This is essentially the same as -an "if() {}; else() {};" block wrapped in GUI sugar. - -To sum it up: - -Before adding an option, think hard about it. Could the same be achieved with a -smarter algorithm? Often options are bad excuses for deciding between one bad -implementation and another bad one. Find a good one! - -Don't try to solve the problem by removing all options. Some options are very -useful, and they are actually needed. Finding out which of these are needed is -the developer's task. It's a hard task, but it can be done. - -Consider asking professionals. We have a KDE Usability team, comprised of real -experts on this topic. Among them is Celeste, a member of the KDE board. She -knows what she's talking about, and she's generally very helpful. Don't be shy, -ask them! diff --git a/amarok/INSTALL b/amarok/INSTALL deleted file mode 100644 index 97d8dc80..00000000 --- a/amarok/INSTALL +++ /dev/null @@ -1,7 +0,0 @@ -Installing Amarok -================= - -Build instructions can be found at - % http://community.kde.org/Amarok/Development/Compiling - % http://techbase.kde.org/Getting_Started/Build/KDE4 - diff --git a/amarok/MAINTAINERS b/amarok/MAINTAINERS deleted file mode 100644 index bd5dda2c..00000000 --- a/amarok/MAINTAINERS +++ /dev/null @@ -1,5 +0,0 @@ -Amarok does not have clear maintainers of all parts of the codebase. The current list of components and maintainers can be found here: http://community.kde.org/Amarok/Development/Components - -You are welcome to work on any part of it provided you coordinate with others working in that part. - -If you need to contact someone about a particular part it is best to contact the developer mailing list at amarok-devel@kde.org or the assignee of the corresponding component on http://bugs.kde.org directly. \ No newline at end of file diff --git a/amarok/Mainpage.dox b/amarok/Mainpage.dox deleted file mode 100644 index 8bbf3196..00000000 --- a/amarok/Mainpage.dox +++ /dev/null @@ -1,46 +0,0 @@ -/** @mainpage The Amarok Source Code Documentation - - - -@maintainers -Amarok does not have clear maintainers of any part of the codebase. You are welcome to work on any part of it provided you coordinate with others working in that part.
-If you need to contact someone about a particular part it is best to contact the developer mailing list at amarok-devel@kde.org or the assignee of the corresponding component on http://bugs.kde.org directly. - -@authors - -Bart Cerneels \
-Edward Toroshchin \
-Leo Franchi \
-Mark Kretschmann \
-Matěj Laitl \
-Myriam Schweingruber \
-Patrick von Reth \
-Ralf Engels \
-Rick W. Chen \
-Sam Lade \
-Sven Krohlas \
-Téo Mrnjavac \
-Valorie Zimmerman \
- -@licenses -@gpl (if not stated otherwise in the source file) - - -*/ - -// DOXYGEN_NAME = Amarok -// DOXYGEN_ENABLE = YES - -// vim:ts=4:sw=4:expandtab:filetype=doxygen diff --git a/amarok/Messages.sh b/amarok/Messages.sh deleted file mode 100755 index c0fc0251..00000000 --- a/amarok/Messages.sh +++ /dev/null @@ -1,3 +0,0 @@ -#! /bin/sh - -$XGETTEXT_QT utilities/collectionscanner/CollectionScanner.cpp -o $podir/amarokcollectionscanner_qt.pot diff --git a/amarok/README b/amarok/README deleted file mode 100644 index 32e48243..00000000 --- a/amarok/README +++ /dev/null @@ -1,178 +0,0 @@ -Amarok - the audio player for KDE -=================================== - -There are many media players around these days, it's true. What's missing from most -players is a user interface that doesn't get in the way of the user. How many -buttons do you have to press for simply adding some new tracks to the playlist? -Amarok tries to be a little different, providing a simple drag and drop interface -that really makes playlist handling easy. - - - FEATURES -========== - - * Quick and simple drag and drop playlist creation - * Music library - * Cross platform: Support for Unix, MacOS X and Windows - * Plays all audio formats known to man - * Cover art download using Last.fm services - * Automatic play-statistics generation (iRate style) - * Full lyrics download - * Learn about your music with integrated Wikipedia - * Full Last.fm support - * gpodder.net support - * Configurable on screen display for track changes - * Podcast support - * iPod support, as well as other media players - * Powerful scripting interface - * KDE integration - * Integration with multiple web sources including Magnatune, Jamendo, - Ampache, MP3tunes, and others. --------------------------------------------------------------------------------- - - - DEPENDENCIES -============== - -Required - * KDE-Libs 4.8.4 (or newer) + KDE-Base-runtime 4.8 (oxygen-icons) (or newer) - http://www.kde.org - - * Phonon backend, one of the following is strongly recommended - * phonon-gstreamer 4.6.3 (or newer) - * phonon-vlc 0.6.1 (or newer; as of 0.6.1 doesn't yet play Audio CDs, bug 313046) - - * Qt 4.8.3 (or newer) - http://qt-project.org - - * TagLib 1.7 (or newer) - (Metadata tagging library) - - * TagLib Extras 1.0.1 (or newer) - (Support for metadata reading of additional file types) - svn://anonsvn.kde.org/home/kde/trunk/kdesupport/taglib-extras - - * MySQL 5.0 (or newer) Embedded: libmysqld compiled with fPIC - (In-process database support) - - * QtScript Generator, Qt Bindings 0.1.0 - (Qt Bindings for QtScript for Amarok's scripting system) - http://code.google.com/p/qtscriptgenerator/ - http://qt.gitorious.org/qt-labs/qtscriptgenerator - - * LibQCA 2.0.2 (or newer) - (Qt Cryptographic Architecture) - http://delta.affinix.com/qca/ - -Optional - * Taglib 1.8 for support of MOD, IT, S3M and XM files - * Taglib 1.9 for support of Opus files - http://developer.kde.org/~wheeler/taglib.html - https://github.com/taglib/taglib - - * iPod support requires: - * libgpod 0.8.2 (or newer) - http://www.gtkpod.org/libgpod/ - * optional iPod album artwork support requires: - * libgpod built with GDKPixBuf support enabled - * GDKPixBuf 2.0 (or newer) itself - - * libmtp 1.0.0 (or newer) - (MTP device support) - http://libmtp.sourceforge.net/ - - * Spectrum analyzer requires: - * QtOpenGL - - * Mp3tunes.com integration (including syncronization) requires: - * OpenSSL http://www.openssl.org - * libxml2 http://xmlsoft.org - * libcurl http://curl.haxx.se - * Glib2 http://www.gtk.org - * Loudmouth, the Jabber library, http://www.loudmouth-project.org/ - * Qt must be compiled with Glib enabled - - * Liblastfm 1.0.3 (or newer) - (For scrobbling, internet radio, and artist info) - http://cdn.last.fm/client/liblastfm-1.0.3.tar.gz - https://github.com/eartle/liblastfm - - * QJson 0.7 (or newer) - (Qt JSON Parser for the Playdar Collection) - http://qjson.sourceforge.net/ - - * MySQL 5.0 (or newer) Server (external database support) - - * MusicBrainz-based audio fingerprint tag lookup requires: - * FFmpeg 0.7.0 (or newer) - http://ffmpeg.org/ - * libavcodec & libavformat specifically - * LibOFA - http://code.google.com/p/musicip-libofa/ - - * gpodder.net Podcast Provider & Service - * libmygpo-qt 1.0.7 (or newer) - - * Transcoding requires (at runtime): - * FFmpeg 0.7.0 (or newer) - http://ffmpeg.org/ - * For all supported encoders to be available in Amarok, FFmpeg needs to - support the following codecs: - * libfaac (NOT just "aac") - * alac - * flac - * libmp3lame (NOT just "mp3") - * libvorbis (NOT just "vorbis") - * wmav2 - - * CD support requires: - * audiocd-kio - http://www.kde.org/ (part of KDE multimedia) - - * Downloading songs from Amazon works best on non Windows systems using - * clamz - https://code.google.com/p/clamz/ - * The official downloader should work fine on Windows, too. But it's broken on many Linux systems. - - * Building tests require: - * gmock 1.4 (or newer) - http://code.google.com/p/googlemock/ - -Please note that if compiling from source you also need to install -dev/-devel -versions of these packages, depending on your distribution. --------------------------------------------------------------------------------- - - - IMPORTANT INSTALL INSTRUCTIONS -================================ - -To compile from source, please refer to the INSTALL file. - -Packages for popular distributions are available at http://amarok.kde.org --------------------------------------------------------------------------------- - - - FURTHER RESOURCES -=================== - -For answers to problems like "Amarok won't play any MP3s!" and "My MP3s skip -and stutter!" please visit: - - http://amarok.kde.org/ --------------------------------------------------------------------------------- - - - CONTRIBUTING -============== - -If you wish to contribute to Amarok, you should build it from Git and subscribe -to the amarok AT kde.org mailing list. The IRC channel is also a place where -it's nice to be. There you can talk to other developers easily, and you can see -instant notifications of commits to the Git master repository. For instant email -notification of commits, visit http://commitfilter.kde.org/ , and http://amarok.be/fisheye -provides a slightly-less-instant overview. - -More information at: -http://community.kde.org/Amarok/Development/Join - -See you on IRC! - --------------------------------------------------------------------------------- - -WWW: http://amarok.kde.org -MAIL: amarok@kde.org -IRC: irc.freenode.net - #amarok, #amarok.de, #amarok.es, #amarok.fr diff --git a/amarok/TODO b/amarok/TODO deleted file mode 100644 index accaf726..00000000 --- a/amarok/TODO +++ /dev/null @@ -1,2 +0,0 @@ -Open amarok bugs are listed here: - http://tinyurl.com/allamarokbugs diff --git a/amarok/amarok.kdev4 b/amarok/amarok.kdev4 deleted file mode 100644 index 63d9c558..00000000 --- a/amarok/amarok.kdev4 +++ /dev/null @@ -1,3 +0,0 @@ -[Project] -Manager=KDevCMakeManager -Name=amarok diff --git a/amarok/cmake/CMakeLists.txt b/amarok/cmake/CMakeLists.txt deleted file mode 100644 index 38a9971a..00000000 --- a/amarok/cmake/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ - -add_subdirectory(modules) - diff --git a/amarok/cmake/modules/CMakeLists.txt b/amarok/cmake/modules/CMakeLists.txt deleted file mode 100644 index c91c62cc..00000000 --- a/amarok/cmake/modules/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -# install the cmake files - -file(GLOB cmakeFiles "${CMAKE_CURRENT_SOURCE_DIR}/*.cmake") - -set(module_install_dir ${DATA_INSTALL_DIR}/cmake/modules ) - -install( FILES ${cmakeFiles} DESTINATION ${module_install_dir} ) - diff --git a/amarok/cmake/modules/COPYING-CMAKE-SCRIPTS b/amarok/cmake/modules/COPYING-CMAKE-SCRIPTS deleted file mode 100644 index d99eefb5..00000000 --- a/amarok/cmake/modules/COPYING-CMAKE-SCRIPTS +++ /dev/null @@ -1,23 +0,0 @@ -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -1. Redistributions of source code must retain the copyright - notice, this list of conditions and the following disclaimer. -2. Redistributions in binary form must reproduce the copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. -3. The name of the author may not be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - diff --git a/amarok/cmake/modules/CheckQtGlib.cmake b/amarok/cmake/modules/CheckQtGlib.cmake deleted file mode 100644 index 7ac29970..00000000 --- a/amarok/cmake/modules/CheckQtGlib.cmake +++ /dev/null @@ -1,14 +0,0 @@ -set(CMAKE_REQUIRED_INCLUDES ${QT_INCLUDES}) -set(CMAKE_REQUIRED_DEFINITIONS "") -set(CMAKE_REQUIRED_FLAGS "") -CHECK_CXX_SOURCE_COMPILES(" -#include -int main() -{ -#if defined(QT_NO_GLIBASDF) -#error \"Qt was compiled with Glib disabled\" -#endif -return 0; -}" -QT4_GLIB_SUPPORT) - diff --git a/amarok/cmake/modules/CheckTagLibFileName.cmake b/amarok/cmake/modules/CheckTagLibFileName.cmake deleted file mode 100644 index e5b3706c..00000000 --- a/amarok/cmake/modules/CheckTagLibFileName.cmake +++ /dev/null @@ -1,15 +0,0 @@ -# taglib changed filenames to be a char/wchar struct on some platforms, need to check for it -macro (CHECK_TAGLIB_FILENAME TAGLIB_FILENAME_COMPLEX) - include (CheckCXXSourceCompiles) - set (CMAKE_REQUIRED_FLAGS ${TAGLIB_CFLAGS}) - set (CMAKE_REQUIRED_INCLUDES ${TAGLIB_INCLUDES}) - set (CMAKE_REQUIRED_LIBRARIES ${TAGLIB_LIBRARIES}) - check_cxx_source_compiles( - "#include - int main() - { - TagLib::FileName fileName1(\"char\"); - TagLib::FileName fileName2(L\"wchar\"); - return 0; - }" ${TAGLIB_FILENAME_COMPLEX}) -endmacro (CHECK_TAGLIB_FILENAME) diff --git a/amarok/cmake/modules/FindGDKPixBuf.cmake b/amarok/cmake/modules/FindGDKPixBuf.cmake deleted file mode 100644 index 39bde1c3..00000000 --- a/amarok/cmake/modules/FindGDKPixBuf.cmake +++ /dev/null @@ -1,63 +0,0 @@ -# - Find GDK-PixBuf -# Find the GDK-PixBuf include directories and libraries -# -# This module defines -# GDKPIXBUF_FOUND - true if the following are found -# GDKPIXBUF_INCLUDE_DIR - GDK-PixBuf include directory -# GDKPIXBUF_LIBRARY - GDK-PixBuf library location - -find_package( PkgConfig ) -if( PKG_CONFIG_FOUND ) - # If pkg-config finds gdk-pixbuf-2.0, this will set: - # PC_GDKPIXBUF_FOUND (to TRUE) - # PC_GDKPIXBUF_INCLUDEDIR - # PC_GDKPIXBUF_INCLUDE_DIRS - # PC_GDKPIXBUF_LIBDIR - # PC_GDKPIXBUF_LIBRARY_DIRS - # These variables are then used as hints to find_path() - # and find_library() - pkg_search_module( PC_GDKPIXBUF gdk-pixbuf-2.0 ) -endif( PKG_CONFIG_FOUND ) - -find_path( GDKPIXBUF_INCLUDE_DIR gdk-pixbuf/gdk-pixbuf.h - HINTS - # Hints provided by pkg-config - ${PC_GDKPIXBUF_INCLUDEDIR} - ${PC_GDKPIXBUF_INCLUDEDIR}/* - ${PC_GDKPIXBUF_INCLUDE_DIRS} - PATHS - # Standard include directories - /usr/include/ - /sw/include/ - /usr/local/include/ - ${KDE4_INCLUDE_DIR} - # Search all subdirs of the above - /usr/include/* - /sw/include/* - /usr/local/include/* - ${KDE4_INCLUDE_DIR}/* - PATH_SUFFIXES - # Subdirectory hints - gdk-pixbuf-2.0 - gtk-2.0 -) - -find_library( GDKPIXBUF_LIBRARY gdk_pixbuf-2.0 - HINTS - # Hints provided by pkg-config - ${PC_GDKPIXBUF_LIBDIR} - ${PC_GDKPIXBUF_LIBRARY_DIRS} -) - -include( FindPackageHandleStandardArgs ) -# Sets GDKPIXBUF_FOUND to true if GDKPIXBUF_INCLUDE_DIR and -# GDKPIXBUF_LIBRARY are both set -find_package_handle_standard_args( GDKPixBuf DEFAULT_MSG - GDKPIXBUF_LIBRARY - GDKPIXBUF_INCLUDE_DIR -) -if( GDKPIXBUF_FOUND ) - message( STATUS "\tInclude directory: ${GDKPIXBUF_INCLUDE_DIR}" ) -endif( GDKPIXBUF_FOUND ) - -mark_as_advanced( GDKPIXBUF_INCLUDE_DIR GDKPIXBUF_LIBRARY ) diff --git a/amarok/cmake/modules/FindGTACFeat.cmake b/amarok/cmake/modules/FindGTACFeat.cmake deleted file mode 100644 index e69de29b..00000000 diff --git a/amarok/cmake/modules/FindGooglemock.cmake b/amarok/cmake/modules/FindGooglemock.cmake deleted file mode 100644 index b8ac8152..00000000 --- a/amarok/cmake/modules/FindGooglemock.cmake +++ /dev/null @@ -1,171 +0,0 @@ -# - Find Googlemock -# Find the google mock includes and the google mock libraries -# This module defines -# GOOGLEMOCK_INCLUDE_DIR, root google mock include dir -# GOOGLEMOCK_LIBRARY, the path to Google Mock library -# GOOGLEMOCK_LIBRARIES, the path to Google Mock and Google Test library -# GOOGLEMOCK_FOUND, whether Google Mock was found -# -# since google test and google mock is not supposed to be supplied pre-compiled -# we try to find the google mock sources as a fallback - -find_program(GMOCK-CONFIG_EXECUTABLE NAMES gmock-config PATHS - ${BIN_INSTALL_DIR} - /opt/local/bin - /usr/bin -) - -if(GMOCK-CONFIG_EXECUTABLE) -exec_program(${GMOCK-CONFIG_EXECUTABLE} ARGS --includedir OUTPUT_VARIABLE GOOGLEMOCK_INCLUDE_DIR) -exec_program(${GMOCK-CONFIG_EXECUTABLE} ARGS --ldflags OUTPUT_VARIABLE GOOGLEMOCK_LDFLAGS) -exec_program(${GMOCK-CONFIG_EXECUTABLE} ARGS --libs OUTPUT_VARIABLE GOOGLEMOCK_libs_tmp) -set(GOOGLEMOCK_LIBRARIES ${GOOGLEMOCK_LDFLAGS} ${GOOGLEMOCK_libs_tmp}) - -if(GOOGLEMOCK_INCLUDE_DIR AND GOOGLEMOCK_LIBRARIES) - set(GOOGLEMOCK_FOUND TRUE) - message(STATUS "Found libgmock: ${GOOGLEMOCK_INCLUDE_DIR}, ${GOOGLEMOCK_LIBRARIES}") -else(GOOGLEMOCK_INCLUDE_DIR AND GOOGLEMOCK_LIBRARIES) - set(GOOGLEMOCK_FOUND FALSE) - if (GOOGLEMOCK_FIND_REQUIRED) - message(FATAL_ERROR "Could NOT find required package Googlemock") - endif(GOOGLEMOCK_FIND_REQUIRED) -endif(GOOGLEMOCK_INCLUDE_DIR AND GOOGLEMOCK_LIBRARIES) - -else(GMOCK-CONFIG_EXECUTABLE) - -find_path(GOOGLEMOCK_INCLUDE_DIR NAMES gmock.h - HINTS - ~/usr/include - /opt/local/include - /usr/include - /usr/local/include - /opt/kde4/include - ${KDE4_INCLUDE_DIR} - PATH_SUFFIXES gmock -) - -find_library( GOOGLEMOCK_LIBRARY NAMES gmock - PATHS - ~/usr/lib - /opt/local/lib - /usr/lib - /usr/lib64 - /usr/local/lib - /opt/kde4/lib - ${KDE4_LIB_DIR} -) - -find_library( GOOGLEMOCK_DEP_GTEST_LIBRARY NAMES gtest - PATHS - ~/usr/lib - /opt/local/lib - /usr/lib - /usr/lib64 - /usr/local/lib - /opt/kde4/lib - ${KDE4_LIB_DIR} -) - -# google-mock >= 1.5 requires pthread -# see: http://code.google.com/p/googlemock/source/browse/trunk/CHANGES -if( NOT WIN32 AND GOOGLEMOCK_LIBRARY ) - find_library( GOOGLEMOCK_DEP_PTHREAD_LIBRARY NAMES pthread - PATHS - ~/usr/lib - /opt/local/lib - /usr/lib - /usr/lib64 - /usr/local/lib - /opt/kde4/lib - ${KDE4_LIB_DIR} - ) - -endif( NOT WIN32 AND GOOGLEMOCK_LIBRARY ) - -# Google recommends not to distribute a pre-build libary and ubuntu is following -# this advice with libgtest 1.6.0 -# However they are distributing sources, so we are looking if we at least have -# them available -if( NOT GOOGLEMOCK_DEP_GTEST_LIBRARY ) - find_path( GOOGLEMOCK_SOURCES NAMES gmock - PATHS /usr/src - NO_DEFAULT_PATH - NO_CMAKE_PATH - ) - - # found googlemock as sources. then we also have the gtest sources since they - # are included - if( GOOGLEMOCK_SOURCES ) - find_path( GOOGLEMOCK_DEP_GTEST_SOURCES NAMES gtest - PATHS "${GOOGLEMOCK_SOURCES}/gmock" - NO_DEFAULT_PATH - NO_CMAKE_PATH - ) - - # make sure that we use the gtest supplied with googlemock - set(GOOGLEMOCK_INCLUDE_DIR - "${GOOGLEMOCK_INCLUDE_DIR}" - "${GOOGLEMOCK_SOURCES}/gmock" - "${GOOGLEMOCK_DEP_GTEST_SOURCES}/gtest/include" - ) - - elseif( GOOGLEMOCK_SOURCES ) - find_path( GOOGLEMOCK_DEP_GTEST_SOURCES NAMES gtest - PATHS /usr/src - NO_DEFAULT_PATH - NO_CMAKE_PATH - ) - - # in this case we also have to use the static google mock library - set( OLD_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) - set( CMAKE_FIND_LIBRARY_SUFFIXES .a) - find_library( GOOGLEMOCK_LIBRARY_STATIC NAMES gmock - PATHS - ~/usr/lib - /opt/local/lib - /usr/lib - /usr/lib64 - /usr/local/lib - /opt/kde4/lib - ${KDE4_LIB_DIR} - ) - set( CMAKE_FIND_LIBRARY_SUFFIXES ${OLD_CMAKE_FIND_LIBRARY_SUFFIXES}) - endif( GOOGLEMOCK_SOURCES ) - -endif( NOT GOOGLEMOCK_DEP_GTEST_LIBRARY ) - -# -- googlemock and gtest library available -if(GOOGLEMOCK_INCLUDE_DIR AND GOOGLEMOCK_LIBRARY AND GOOGLEMOCK_DEP_GTEST_LIBRARY) - set(GOOGLEMOCK_FOUND TRUE) - set(GOOGLEMOCK_LIBRARIES ${GOOGLEMOCK_LIBRARY} ${GOOGLEMOCK_DEP_GTEST_LIBRARY} ${GOOGLEMOCK_DEP_PTHREAD_LIBRARY}) - message(STATUS "Found libgmock: ${GOOGLEMOCK_INCLUDE_DIR}, ${GOOGLEMOCK_LIBRARIES}") - - -# -- googlemock and gtest sources available -elseif(GOOGLEMOCK_INCLUDE_DIR AND GOOGLEMOCK_LIBRARY AND GOOGLEMOCK_DEP_GTEST_SOURCES) - set(GOOGLEMOCK_FOUND TRUE) - set(GOOGLEMOCK_LIBRARIES ${GOOGLEMOCK_LIBRARY_STATIC} gtest) - set(GOOGLEMOCK_GTEST_SOURCES "${GOOGLEMOCK_DEP_GTEST_SOURCES}/gtest" CACHE PATH "Path to the gtest sources") - message(STATUS "Found libgmock but need to build gtest: ${GOOGLEMOCK_INCLUDE_DIR}, ${GOOGLEMOCK_LIBRARIES} ${GOOGLEMOCK_DEP_GTEST_SOURCES}") - -# -- googlemock sources and gtest sources available -elseif(GOOGLEMOCK_SOURCES) - set(GOOGLEMOCK_FOUND TRUE) - set(GOOGLEMOCK_LIBRARIES gtest) - set(GOOGLEMOCK_SRCS "${GOOGLEMOCK_SOURCES}/gmock/src/gmock-all.cc" CACHE PATH "Google mock source file that needs to be added") - set(GOOGLEMOCK_SOURCES "${GOOGLEMOCK_SOURCES}/gmock" CACHE PATH "Path to the google-mock sources") - set(GOOGLEMOCK_GTEST_SOURCES "${GOOGLEMOCK_DEP_GTEST_SOURCES}/gtest" CACHE PATH "Path to the gtest sources") - message(STATUS "Found gmock and gtest but need to build both: ${GOOGLEMOCK_INCLUDE_DIR}, ${GOOGLEMOCK_DEP_GTEST_SOURCES}") - mark_as_advanced(GOOGLEMOCK_SRCS) - -# -- googlemock but no gtest -else(GOOGLEMOCK_INCLUDE_DIR AND GOOGLEMOCK_LIBRARY AND GOOGLEMOCK_DEP_GTEST_SOURCES) - set(GOOGLEMOCK_FOUND FALSE) - if (GOOGLEMOCK_FIND_REQUIRED) - message(FATAL_ERROR "Could NOT find required package Googlemock or gtest") - endif(GOOGLEMOCK_FIND_REQUIRED) -endif(GOOGLEMOCK_INCLUDE_DIR AND GOOGLEMOCK_LIBRARY AND GOOGLEMOCK_DEP_GTEST_LIBRARY) - -endif(GMOCK-CONFIG_EXECUTABLE) - -mark_as_advanced(GOOGLEMOCK_INCLUDE_DIR GOOGLEMOCK_LIBRARIES) diff --git a/amarok/cmake/modules/FindHUpnp.cmake b/amarok/cmake/modules/FindHUpnp.cmake deleted file mode 100644 index 4f238f53..00000000 --- a/amarok/cmake/modules/FindHUpnp.cmake +++ /dev/null @@ -1,22 +0,0 @@ -# - Find HUpnp -# HUpnp is a Universal Plug and Play (UPnP) library -# used by the UPnP collection. -# Defines: -# HUPNP_INCLUDE_DIR -# HUPNP_LIBRARIES -# HUPNP_FOUND - -find_path(HUPNP_INCLUDE_DIR HUpnp HINTS ${KDE4_INCLUDE_DIR}) - -find_library(HUPNP_LIBRARIES HUpnp PATHS ${KDE4_LIB_DIR}) - -if(HUPNP_INCLUDE_DIR AND HUPNP_LIBRARIES) - set(HUPNP_FOUND TRUE) - message(STATUS "Found HUpnp") -else(HUPNP_INCLUDE_DIR and HUPNP_LIBRARIES) - set(HUPNP_FOUND FALSE) - if(HUPNP_FIND_REQUIRED) - message(FATAL_ERROR "Could NOT find required package HUpnp: ") - endif(HUPNP_FIND_REQUIRED) -endif(HUPNP_INCLUDE_DIR AND HUPNP_LIBRARIES) - diff --git a/amarok/cmake/modules/FindIfp.cmake b/amarok/cmake/modules/FindIfp.cmake deleted file mode 100644 index ed990e28..00000000 --- a/amarok/cmake/modules/FindIfp.cmake +++ /dev/null @@ -1,24 +0,0 @@ -# - Find IFP library -# Find the native IFP includes and library -# This module defines -# IFP_INCLUDE_DIR, where to find ifp.h, etc. -# IFP_LIBRARIES, libraries to link against to use IFP. -# IFP_FOUND, If false, do NOT try to use IFP. -# also defined, but NOT for general use are -# IFP_LIBRARY, where to find the IFP library. - -if (IFP_INCLUDE_DIR) - # Already in cache, be silent - set(Ifp_FIND_QUIETLY TRUE) -endif (IFP_INCLUDE_DIR) - -FIND_PATH(IFP_INCLUDE_DIR ifp.h -) - -FIND_LIBRARY(IFP_LIBRARY ifp -) - -include(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(IFP DEFAULT_MSG IFP_LIBRARY IFP_INCLUDE_DIR) - -MARK_AS_ADVANCED(IFP_INCLUDE_DIR IFP_LIBRARY) diff --git a/amarok/cmake/modules/FindIpod.cmake b/amarok/cmake/modules/FindIpod.cmake deleted file mode 100644 index 0757347d..00000000 --- a/amarok/cmake/modules/FindIpod.cmake +++ /dev/null @@ -1,48 +0,0 @@ -# - Try to find the libgpod library -# Once done this will define -# -# IPOD_FOUND - system has libgpod -# IPOD_INCLUDE_DIRS - the libgpod include directory -# IPOD_LIBRARIES - Link these to use libgpod -# IPOD_CFLAGS - Compiler switches required for using libgpod -# IPOD_VERSION - Version number of libgpod -# - -if (IPOD_INCLUDE_DIRS AND IPOD_LIBRARIES) - - # in cache already - SET(IPOD_FOUND TRUE) - -else (IPOD_INCLUDE_DIRS AND IPOD_LIBRARIES) - if(NOT WIN32) - # use pkg-config to get the directories and then use these values - # in the FIND_PATH() and FIND_LIBRARY() calls - find_package(PkgConfig) - PKG_SEARCH_MODULE(IPOD libgpod-1.0) - else(NOT WIN32) - find_path(IPOD_INCLUDE_DIRS - NAMES - gpod/itdb.h - PATH_SUFFIXES gpod-1.0 - ) - - find_library(IPOD_LIBRARIES NAMES - gpod libgpod gpod-4 libgpod-4 - ) - if(IPOD_INCLUDE_DIRS AND IPOD_LIBRARIES) - set(IPOD_FOUND ON) - endif(IPOD_INCLUDE_DIRS AND IPOD_LIBRARIES) - endif(NOT WIN32) - IF (IPOD_FOUND) - IF (NOT IPOD_FIND_QUIETLY) - MESSAGE(STATUS "Found libgpod-1 ${IPOD_VERSION}") - ENDIF (NOT IPOD_FIND_QUIETLY) - ELSE (IPOD_FOUND) - IF (IPOD_FIND_REQUIRED) - MESSAGE(FATAL_ERROR "Could NOT find libgpod-1, check FindPkgConfig output above!") - ENDIF (IPOD_FIND_REQUIRED) - ENDIF (IPOD_FOUND) - - MARK_AS_ADVANCED(IPOD_INCLUDE_DIRS) - -endif (IPOD_INCLUDE_DIRS AND IPOD_LIBRARIES) diff --git a/amarok/cmake/modules/FindLibLastFm.cmake b/amarok/cmake/modules/FindLibLastFm.cmake deleted file mode 100644 index 58709b97..00000000 --- a/amarok/cmake/modules/FindLibLastFm.cmake +++ /dev/null @@ -1,54 +0,0 @@ -# - Find LibLastFM -# Find the liblastfm includes and the liblastfm libraries -# This module defines -# LIBLASTFM_FOUND, whether liblastfm was found. If it was, it further sets: -# LIBLASTFM_INCLUDE_DIR, root lastfm include dir -# LIBLASTFM_LIBRARY, the path to liblastfm -# LIBLASTFM_VERSION, version of found liblastfm as a string, e.g "0.3" - - -find_path(LIBLASTFM_INCLUDE_DIR NAMES global.h - HINTS - ~/usr/include - /opt/local/include - /usr/include - /usr/local/include - /opt/kde4/include - ${KDE4_INCLUDE_DIR} - PATH_SUFFIXES lastfm -) - -find_library( LIBLASTFM_LIBRARY NAMES lastfm - PATHS - ~/usr/lib - /opt/local/lib - /usr/lib - /usr/lib64 - /usr/local/lib - /opt/kde4/lib - ${KDE4_LIB_DIR} -) - - -if(LIBLASTFM_INCLUDE_DIR AND LIBLASTFM_LIBRARY) - set(LIBLASTFM_FOUND TRUE) -else(LIBLASTFM_INCLUDE_DIR AND LIBLASTFM_LIBRARY) - set(LIBLASTFM_FOUND FALSE) -endif(LIBLASTFM_INCLUDE_DIR AND LIBLASTFM_LIBRARY) - -if(LIBLASTFM_FOUND) - set(regex "#define LASTFM_VERSION_STRING \"(.*)\"") - file(STRINGS "${LIBLASTFM_INCLUDE_DIR}/global.h" LIBLASTFM_VERSION REGEX ${regex}) - if(${LIBLASTFM_VERSION} MATCHES ${regex}) - set(LIBLASTFM_VERSION ${CMAKE_MATCH_1}) - message(STATUS "Found liblastfm: ${LIBLASTFM_INCLUDE_DIR}, ${LIBLASTFM_LIBRARY}, version ${LIBLASTFM_VERSION}") - else(${LIBLASTFM_VERSION} MATCHES ${regex}) - message(WARNING "Found liblastfm: ${LIBLASTFM_INCLUDE_DIR} - but failed to parse version") - set(LIBLASTFM_FOUND FALSE) - unset(LIBLASTFM_INCLUDE_DIR) - unset(LIBLASTFM_LIBRARY) - endif(${LIBLASTFM_VERSION} MATCHES ${regex}) - unset(regex) -endif(LIBLASTFM_FOUND) - -mark_as_advanced(LIBLASTFM_INCLUDE_DIR LIBLASTFM_LIBRARY) diff --git a/amarok/cmake/modules/FindLibOFA.cmake b/amarok/cmake/modules/FindLibOFA.cmake deleted file mode 100644 index efdd9c4a..00000000 --- a/amarok/cmake/modules/FindLibOFA.cmake +++ /dev/null @@ -1,34 +0,0 @@ -find_path(LIBOFA_INCLUDE_DIR NAMES ofa.h - HINTS - ~/usr/include - /opt/local/include - /usr/include - /usr/local/include - /opt/kde4/include - ${KDE4_INCLUDE_DIR} - PATH_SUFFIXES ofa1 -) - -find_library(LIBOFA_LIBRARY NAMES ofa - PATHS - ~/usr/lib - /opt/local/lib - /usr/lib - /usr/lib64 - /usr/local/lib - /opt/kde4/lib - ${KDE4_LIB_DIR} -) - - -if(LIBOFA_INCLUDE_DIR AND LIBOFA_LIBRARY) - set(LIBOFA_FOUND TRUE) - message(STATUS "Found libofa: ${LIBOFA_INCLUDE_DIR}, ${LIBOFA_LIBRARY}") -else(LIBOFA_INCLUDE_DIR AND LIBOFA_LIBRARY) - set(LIBOFA_FOUND FALSE) - if (LIBOFA_FIND_REQUIRED) - message(FATAL_ERROR "Could NOT find required package LibOFA") - endif(LIBOFA_FIND_REQUIRED) -endif(LIBOFA_INCLUDE_DIR AND LIBOFA_LIBRARY) - -mark_as_advanced(LIBOFA_INCLUDE_DIR LIBOFA_LIBRARY) diff --git a/amarok/cmake/modules/FindLibgcrypt.cmake b/amarok/cmake/modules/FindLibgcrypt.cmake deleted file mode 100644 index 9ca56503..00000000 --- a/amarok/cmake/modules/FindLibgcrypt.cmake +++ /dev/null @@ -1,30 +0,0 @@ -# - Try to find the GNU Libgcrypt library -# Once done this will define -# -# LIBGCRYPT_FOUND - system has the Libgcrypt library -# LIBGCRYPT_LIBS - The libraries needed to use Libgcrypt - -# Copyright (c) 2006, Pino Toscano, -# Copyright (c) 2008, Modestas Vainius, -# -# Redistribution and use is allowed according to the terms of the BSD license. -# For details see the accompanying COPYING-CMAKE-SCRIPTS file. - -include(CheckIncludeFiles) - -check_include_files(gcrypt.h HAVE_GCRYPT_H) - -if (HAVE_GCRYPT_H) - set(LIBGCRYPT_HEADERS_FOUND TRUE) -endif (HAVE_GCRYPT_H) - -if (LIBGCRYPT_HEADERS_FOUND) - find_library(LIBGCRYPT_LIBS NAMES gcrypt ) -endif (LIBGCRYPT_HEADERS_FOUND) - -if (LIBGCRYPT_LIBS) - set(LIBGCRYPT_FOUND TRUE) - message(STATUS "Libgcrypt found: ${LIBGCRYPT_LIBS}") -elseif (Libgcrypt_FIND_REQUIRED) - message(FATAL_ERROR "Could not find Libgcrypt") -endif (LIBGCRYPT_LIBS) diff --git a/amarok/cmake/modules/FindLibmygpo-qt.cmake b/amarok/cmake/modules/FindLibmygpo-qt.cmake deleted file mode 100644 index fd686cd0..00000000 --- a/amarok/cmake/modules/FindLibmygpo-qt.cmake +++ /dev/null @@ -1,48 +0,0 @@ - -# - Find libmygpo-qt -# Find the libmygpo-qt includes and the libmygpo-qt libraries -# This module defines -# LIBMYGPO_QT_INCLUDE_DIR, root mygpo-qt include dir -# LIBMYGPO_QT_LIBRARY, the path to libmygpo-qt -# LIBMYGPO_QT_FOUND, whether libmygpo-qt was found - - -find_path(LIBMYGPO_QT_INCLUDE_DIR NAMES ApiRequest.h - HINTS - ~/usr/include - /opt/local/include - /usr/include - /usr/local/include - /opt/kde4/include - ~/kde/include - PATH_SUFFIXES mygpo-qt -) - -find_library( LIBMYGPO_QT_LIBRARY NAMES mygpo-qt - PATHS - ~/usr/lib - ~/usr/lib64 - /opt/local/lib - /opt/local/lib64 - /usr/lib - /usr/lib64 - /usr/local/lib - /usr/local/lib64 - /opt/kde4/lib - /opt/kde4/lib64 - ~/kde/lib - ~/kde/lib64 -) - - -if(LIBMYGPO_QT_INCLUDE_DIR AND LIBMYGPO_QT_LIBRARY) - set(LIBMYGPO_QT_FOUND TRUE) - message(STATUS "Found libmygpo-qt: ${LIBMYGPO_QT_INCLUDE_DIR}, ${LIBMYGPO_QT_LIBRARY}") -else(LIBMYGPO_QT_INCLUDE_DIR AND LIBMYGPO_QT_LIBRARY) - set(LIBMYGPO_QT_FOUND FALSE) - if (LIBMYGPO_QT_FIND_REQUIRED) - message(FATAL_ERROR "Could NOT find required package libmygpo-qt") - endif(LIBMYGPO_QT_FIND_REQUIRED) -endif(LIBMYGPO_QT_INCLUDE_DIR AND LIBMYGPO_QT_LIBRARY) - -mark_as_advanced(LIBMYGPO_QT_INCLUDE_DIR LIBMYGPO_QT_LIBRARY) diff --git a/amarok/cmake/modules/FindLoudmouth.cmake b/amarok/cmake/modules/FindLoudmouth.cmake deleted file mode 100644 index 30450a42..00000000 --- a/amarok/cmake/modules/FindLoudmouth.cmake +++ /dev/null @@ -1,46 +0,0 @@ -# - Try to find the loudmouth library -# Once done this will define -# -# LOUDMOUTH_FOUND - system has libgpod -# LOUDMOUTH_INCLUDE_DIRS - the libgpod include directory -# LOUDMOUTH_LIBRARIES - Link these to use libgpod -# LOUDMOUTH_DEFINITIONS - Compiler switches required for using libgpod -# - -if (LOUDMOUTH_INCLUDE_DIRS AND LOUDMOUTH_LIBRARIES) - - # in cache already - SET(LOUDMOUTH_FOUND TRUE) - -else (LOUDMOUTH_INCLUDE_DIRS AND LOUDMOUTH_LIBRARIES) - if(NOT WIN32) - # use pkg-config to get the directories and then use these values - # in the FIND_PATH() and FIND_LIBRARY() calls - find_package(PkgConfig) - PKG_SEARCH_MODULE(LOUDMOUTH loudmouth-1.0) - - else(NOT WIN32) - - FIND_PATH(LOUDMOUTH_INCLUDE_DIRS loudmouth/loudmouth.h /usr/include/loudmouth-1.0 - ${_LOUDMOUTHIncDir} - ) - - FIND_LIBRARY(LOUDMOUTH_LIBRARIES NAMES loudmouth-1 - PATHS - ${_LOUDMOUTHLinkDir} - ) - - endif(NOT WIN32) - - if (LOUDMOUTH_INCLUDE_DIRS AND LOUDMOUTH_LIBRARIES) - SET(LOUDMOUTH_FOUND TRUE) - else (LOUDMOUTH_INCLUDE_DIRS AND LOUDMOUTH_LIBRARIES) - SET(LOUDMOUTH_FOUND_FALSE) - endif (LOUDMOUTH_INCLUDE_DIRS AND LOUDMOUTH_LIBRARIES) - - include(FindPackageHandleStandardArgs) - FIND_PACKAGE_HANDLE_STANDARD_ARGS(Loudmouth DEFAULT_MSG LOUDMOUTH_INCLUDE_DIRS LOUDMOUTH_LIBRARIES ) - - MARK_AS_ADVANCED(LOUDMOUTH_INCLUDE_DIRS LOUDMOUTH_LIBRARIES) - -endif (LOUDMOUTH_INCLUDE_DIRS AND LOUDMOUTH_LIBRARIES) diff --git a/amarok/cmake/modules/FindMtp.cmake b/amarok/cmake/modules/FindMtp.cmake deleted file mode 100644 index a6b7a0ec..00000000 --- a/amarok/cmake/modules/FindMtp.cmake +++ /dev/null @@ -1,55 +0,0 @@ -# - Try to find the libmtp library -# Once done this will define -# -# MTP_FOUND - system has libmtp -# MTP_INCLUDE_DIR - the libmtp include directory -# MTP_LIBRARIES - Link these to use libmtp -# MTP_DEFINITIONS - Compiler switches required for using libmtp -# - -if (MTP_INCLUDE_DIR AND MTP_LIBRARIES AND MTP_VERSION_OKAY) - - # in cache already - SET(MTP_FOUND TRUE) - -else (MTP_INCLUDE_DIR AND MTP_LIBRARIES AND MTP_VERSION_OKAY) - if(NOT WIN32) - # use pkg-config to get the directories and then use these values - # in the FIND_PATH() and FIND_LIBRARY() calls - INCLUDE(FindPkgConfig) - - pkg_check_modules(_MTP libmtp) - - set(MTP_DEFINITIONS ${_MTP_CFLAGS}) - endif(NOT WIN32) - FIND_PATH(MTP_INCLUDE_DIR libmtp.h - ${_MTP_INCLUDE_DIRS} - ) - - FIND_LIBRARY(MTP_LIBRARIES NAMES mtp - PATHS - ${_MTP_LIBRARY_DIRS} - ) - - exec_program(${PKG_CONFIG_EXECUTABLE} ARGS --atleast-version=1.0.0 libmtp OUTPUT_VARIABLE _pkgconfigDevNull RETURN_VALUE MTP_VERSION_OKAY) - - if (MTP_INCLUDE_DIR AND MTP_LIBRARIES AND MTP_VERSION_OKAY STREQUAL "0") - set(MTP_FOUND TRUE) - endif (MTP_INCLUDE_DIR AND MTP_LIBRARIES AND MTP_VERSION_OKAY STREQUAL "0") - - if (MTP_FOUND) - if (NOT Mtp_FIND_QUIETLY) - message(STATUS "Found MTP: ${MTP_LIBRARIES}") - endif (NOT Mtp_FIND_QUIETLY) - else (MTP_FOUND) - if (MTP_INCLUDE_DIR AND MTP_LIBRARIES AND NOT MTP_VERSION_OKAY STREQUAL "0") - message(STATUS "Found MTP but version requirements not met") - endif (MTP_INCLUDE_DIR AND MTP_LIBRARIES AND NOT MTP_VERSION_OKAY STREQUAL "0") - if (Mtp_FIND_REQUIRED) - message(FATAL_ERROR "Could NOT find MTP") - endif (Mtp_FIND_REQUIRED) - endif (MTP_FOUND) - - MARK_AS_ADVANCED(MTP_INCLUDE_DIR MTP_LIBRARIES MTP_VERSION_OKAY) - -endif (MTP_INCLUDE_DIR AND MTP_LIBRARIES AND MTP_VERSION_OKAY) diff --git a/amarok/cmake/modules/FindMySQLAmarok.cmake b/amarok/cmake/modules/FindMySQLAmarok.cmake deleted file mode 100644 index dffce31d..00000000 --- a/amarok/cmake/modules/FindMySQLAmarok.cmake +++ /dev/null @@ -1,115 +0,0 @@ -# - Find MySQL / MySQL Embedded -# Find the MySQL includes and client library -# This module defines -# MYSQL_INCLUDE_DIR, where to find mysql.h -# MYSQL_LIBRARIES, the libraries needed to use MySQL. -# MYSQL_EMBEDDED_LIBRARIES, the libraries needed to use MySQL Embedded. -# MYSQL_FOUND, If false, do not try to use MySQL. -# MYSQL_EMBEDDED_FOUND, If false, do not try to use MySQL Embedded. - -# Copyright (c) 2006, Jaroslaw Staniek, -# -# Redistribution and use is allowed according to the terms of the BSD license. -# For details see the accompanying COPYING-CMAKE-SCRIPTS file. - -if(NOT WIN32) - find_program(MYSQLCONFIG_EXECUTABLE NAMES mysql_config mysql_config5 HINTS ${BIN_INSTALL_DIR}) -endif(NOT WIN32) - -find_path(MYSQL_INCLUDE_DIR mysql.h PATH_SUFFIXES mysql mysql5/mysql) - -if(MYSQLCONFIG_EXECUTABLE) - exec_program(${MYSQLCONFIG_EXECUTABLE} ARGS --cflags RETURN_VALUE _return_VALUE OUTPUT_VARIABLE MYSQL_CFLAGS) - exec_program(${MYSQLCONFIG_EXECUTABLE} ARGS --libs RETURN_VALUE _return_VALUE OUTPUT_VARIABLE MYSQL_LIBRARIES) - exec_program(${MYSQLCONFIG_EXECUTABLE} ARGS --libmysqld-libs RETURN_VALUE _return_VALUE OUTPUT_VARIABLE MYSQL_EMBEDDED_LIBSTEMP) - - set(MYSQL_EMBEDDED_CFLAGS ${MYSQL_CFLAGS}) - - if(MYSQL_EMBEDDED_LIBSTEMP) - set( HAVE_MYSQL_EMBEDDED true ) - endif(MYSQL_EMBEDDED_LIBSTEMP) - - find_library(MYSQLD_PIC_SEPARATE - mysqld_pic - PATH_SUFFIXES mysql - ) - - if(MYSQLD_PIC_SEPARATE) - string(REPLACE "lmysqld" "lmysqld_pic" MYSQL_EMBEDDED_LIBRARIES ${MYSQL_EMBEDDED_LIBSTEMP}) - # append link directory to variable as mysql_config is not always (since Ubuntu 12.04?) - # reporting this directory with when being called with --libs - get_filename_component(MYSQL_EMBEDDED_LIB_DIR_TMP "${MYSQLD_PIC_SEPARATE}" PATH) - set(MYSQL_EMBEDDED_LIBRARIES "${MYSQL_EMBEDDED_LIBRARIES} -L${MYSQL_EMBEDDED_LIB_DIR_TMP}") - else(MYSQLD_PIC_SEPARATE) - set(MYSQL_EMBEDDED_LIBRARIES ${MYSQL_EMBEDDED_LIBSTEMP}) - endif(MYSQLD_PIC_SEPARATE) - - if (UNIX) - # libmysqld wants -lpthread, but it is very likely it does not say that - # explicitly in --libmysqld-libs - find_package(Threads) - set(MYSQL_EMBEDDED_LIBRARIES "${MYSQL_EMBEDDED_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}") - endif(UNIX) - -else(MYSQLCONFIG_EXECUTABLE) - - if(WIN32) - set(MYSQL_CLIENT_LIBRARY_NAME libmysql) - else(WIN32) - set(MYSQL_CLIENT_LIBRARY_NAME mysqlclient) - endif(WIN32) - - find_library(MYSQL_LIBRARIES NAMES ${MYSQL_CLIENT_LIBRARY_NAME} - PATHS - ~/usr/lib/mysql - /opt/mysql/mysql/lib - usr/mysql/lib/mysql - opt/local/lib/mysql5/mysql - opt/mysqle/lib/mysql - usr/lib/mysql - usr/lib64/mysql - usr/lib64 - usr/local/lib/mysql - opt/local/lib/mysql - opt/ports/lib/mysql5/mysql - ) - - find_library(MYSQL_EMBEDDED_LIBRARIES NAMES mysqld_pic mysqld libmysqld - PATHS - ~/usr/lib/mysql - /opt/local/lib/mysql5/mysql - /opt/mysqle/lib/mysql - /usr/lib/mysql - /usr/lib64/mysql - /usr/local/lib/mysql - /opt/mysql/lib/mysql - /opt/local/lib/mysql - /opt/ports/lib/mysql5/mysql - ) - - macro_push_required_vars() - set( CMAKE_REQUIRED_INCLUDES ${MYSQL_INCLUDE_DIR} ) - set( CMAKE_REQUIRED_LIBRARIES ${MYSQL_EMBEDDED_LIBRARIES} ) - include_directories( ${MYSQL_INCLUDE_DIR} ) - check_cxx_source_compiles( "#if (defined(_WIN32) || defined(_WIN64))\n#define __LCC__\n#endif\n#include \nint main() { int i = MYSQL_OPT_USE_EMBEDDED_CONNECTION; }" HAVE_MYSQL_EMBEDDED ) - macro_pop_required_vars() - -endif(MYSQLCONFIG_EXECUTABLE) - -if(MYSQL_INCLUDE_DIR AND MYSQL_LIBRARIES) - set(MYSQL_FOUND TRUE) - message(STATUS "Found MySQL: ${MYSQL_INCLUDE_DIR}, ${MYSQL_LIBRARIES}") -else(MYSQL_INCLUDE_DIR AND MYSQL_LIBRARIES) - set(MYSQL_FOUND FALSE) - message(STATUS "MySQL not found.") -endif(MYSQL_INCLUDE_DIR AND MYSQL_LIBRARIES) - -if(MYSQL_INCLUDE_DIR AND MYSQL_EMBEDDED_LIBRARIES AND HAVE_MYSQL_EMBEDDED) - set(MYSQL_EMBEDDED_FOUND TRUE) - message(STATUS "Found MySQL Embedded: ${MYSQL_INCLUDE_DIR}, ${MYSQL_EMBEDDED_LIBRARIES}") -else(MYSQL_INCLUDE_DIR AND MYSQL_EMBEDDED_LIBRARIES AND HAVE_MYSQL_EMBEDDED) - set(MYSQL_EMBEDDED_FOUND FALSE) - message(STATUS "MySQL Embedded not found.") -endif(MYSQL_INCLUDE_DIR AND MYSQL_EMBEDDED_LIBRARIES AND HAVE_MYSQL_EMBEDDED) - -mark_as_advanced(MYSQL_INCLUDE_DIR MYSQL_LIBRARIES MYSQL_EMBEDDED_LIBRARIES) diff --git a/amarok/cmake/modules/FindNjb.cmake b/amarok/cmake/modules/FindNjb.cmake deleted file mode 100644 index 5c0c5d18..00000000 --- a/amarok/cmake/modules/FindNjb.cmake +++ /dev/null @@ -1,41 +0,0 @@ -# - Try to find the libnjb library -# Once done this will define -# -# NJB_FOUND - system has libnjb -# NJB_INCLUDE_DIR - the libnjb include directory -# NJB_LIBRARIES - Link these to use libnjb -# NJB_DEFINITIONS - Compiler switches required for using libnjb -# - -if (NJB_INCLUDE_DIR AND NJB_LIBRARIES) - - # in cache already - SET(NJB_FOUND TRUE) - -else (NJB_INCLUDE_DIR AND NJB_LIBRARIES) - if(NOT WIN32) - # use pkg-config to get the directories and then use these values - # in the FIND_PATH() and FIND_LIBRARY() calls - INCLUDE(FindPkgConfig) - - pkg_check_modules(_NJB libnjb) - - set(NJB_DEFINITIONS ${_NJB_CFLAGS}) - endif(NOT WIN32) - - FIND_PATH(NJB_INCLUDE_DIR libnjb.h - ${_NJB_INCLUDE_DIRS} - ) - - FIND_LIBRARY(NJB_LIBRARIES NAMES njb - PATHS - ${_NJB_LIBRARY_DIRS} - ) - - - include(FindPackageHandleStandardArgs) - FIND_PACKAGE_HANDLE_STANDARD_ARGS(Njb DEFAULT_MSG NJB_INCLUDE_DIR NJB_LIBRARIES ) - - MARK_AS_ADVANCED(NJB_INCLUDE_DIR NJB_LIBRARIES) - -endif (NJB_INCLUDE_DIR AND NJB_LIBRARIES) diff --git a/amarok/cmake/modules/FindQtScriptQtBindings.cmake b/amarok/cmake/modules/FindQtScriptQtBindings.cmake deleted file mode 100644 index bd24328e..00000000 --- a/amarok/cmake/modules/FindQtScriptQtBindings.cmake +++ /dev/null @@ -1,44 +0,0 @@ -## Ian Monroe Copyright 2009 -# released under public domain or: -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library 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 -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -# - -include(CheckCXXSourceRuns) - -if(NOT WIN32) - file( READ "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/bindingstest/QtScriptBindingsTest.cpp" source ) - message(STATUS "Checking if the QtScript Qt Bindings are installed.") - - - set(CMAKE_REQUIRED_DEFINTIONS ${QT_DEFINITIONS} ${KDE4_DEFINITIONS} ) - set(CMAKE_REQUIRED_INCLUDES ${QT_QTCORE_INCLUDE_DIR} ${QT_QTSCRIPT_INCLUDE_DIR} ${KDE4_INCLUDES}) - set(CMAKE_REQUIRED_LIBRARIES ${QT_QTSCRIPT_LIBRARY} ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} -L${KDE4_LIB_DIR} -lkdecore -lkdeui) - message( STATUS "includes ${CMAKE_REQUIRED_INCLUDES} libraries ${CMAKE_REQUIRED_LIBRARIES}" ) - CHECK_CXX_SOURCE_RUNS( "${source}" BINDINGS_RUN_RESULT) - - if(BINDINGS_RUN_RESULT EQUAL 1) - message( STATUS "QtBindings found") - set(QTSCRIPTQTBINDINGS_FOUND TRUE) - else(BINDINGS_RUN_RESULT EQUAL 1) - message( STATUS "QtBindings not found. run `cd cmake/modules/bindingstest; mkdir build; cd build; cmake ..; make; ./bindingstest; echo $?` If it prints '0' then you're actually fine.") - set(QTSCRIPTQTBINDINGS_FOUND FALSE) - endif(BINDINGS_RUN_RESULT EQUAL 1) - - set(CMAKE_REQUIRED_DEFINTIONS "" ) - set(CMAKE_REQUIRED_INCLUDES "") - set(CMAKE_REQUIRED_LIBRARIES "") -else(NOT WIN32) - set(QTSCRIPTQTBINDINGS_FOUND TRUE) -endif(NOT WIN32) diff --git a/amarok/cmake/modules/FindTaglib-Extras.cmake b/amarok/cmake/modules/FindTaglib-Extras.cmake deleted file mode 100644 index b96f705a..00000000 --- a/amarok/cmake/modules/FindTaglib-Extras.cmake +++ /dev/null @@ -1,135 +0,0 @@ -# - Try to find the Taglib-Extras library -# Once done this will define -# -# TAGLIB-EXTRAS_FOUND - system has the taglib library -# TAGLIB-EXTRAS_CFLAGS - the taglib cflags -# TAGLIB-EXTRAS_LIBRARIES - The libraries needed to use taglib - -# Copyright (c) 2006, Laurent Montel, -# -# Redistribution and use is allowed according to the terms of the BSD license. -# For details see the accompanying COPYING-CMAKE-SCRIPTS file. - -if(NOT TAGLIB-EXTRAS_MIN_VERSION) - set(TAGLIB-EXTRAS_MIN_VERSION "1.0") -endif(NOT TAGLIB-EXTRAS_MIN_VERSION) - -if(NOT WIN32) - find_program(TAGLIB-EXTRASCONFIG_EXECUTABLE NAMES taglib-extras-config PATHS - ${BIN_INSTALL_DIR} - ) -endif(NOT WIN32) - -#reset vars -set(TAGLIB-EXTRAS_LIBRARIES) -set(TAGLIB-EXTRAS_CFLAGS) - -# if taglib-extras-config has been found -if(TAGLIB-EXTRASCONFIG_EXECUTABLE) - - exec_program(${TAGLIB-EXTRASCONFIG_EXECUTABLE} ARGS --version RETURN_VALUE _return_VALUE OUTPUT_VARIABLE TAGLIB-EXTRAS_VERSION) - - if(TAGLIB-EXTRAS_VERSION STRLESS "${TAGLIB-EXTRAS_MIN_VERSION}") - message(STATUS "TagLib-Extras version too old: version searched :${TAGLIB-EXTRAS_MIN_VERSION}, found ${TAGLIB-EXTRAS_VERSION}") - set(TAGLIB-EXTRAS_FOUND FALSE) - else(TAGLIB-EXTRAS_VERSION STRLESS "${TAGLIB-EXTRAS_MIN_VERSION}") - - exec_program(${TAGLIB-EXTRASCONFIG_EXECUTABLE} ARGS --libs RETURN_VALUE _return_VALUE OUTPUT_VARIABLE TAGLIB-EXTRAS_LIBRARIES) - - exec_program(${TAGLIB-EXTRASCONFIG_EXECUTABLE} ARGS --cflags RETURN_VALUE _return_VALUE OUTPUT_VARIABLE TAGLIB-EXTRAS_CFLAGS) - - if(TAGLIB-EXTRAS_LIBRARIES AND TAGLIB-EXTRAS_CFLAGS) - set(TAGLIB-EXTRAS_FOUND TRUE) - endif(TAGLIB-EXTRAS_LIBRARIES AND TAGLIB-EXTRAS_CFLAGS) - string(REGEX REPLACE " *-I" ";" TAGLIB-EXTRAS_INCLUDES "${TAGLIB-EXTRAS_CFLAGS}") - endif(TAGLIB-EXTRAS_VERSION STRLESS "${TAGLIB-EXTRAS_MIN_VERSION}") - mark_as_advanced(TAGLIB-EXTRAS_CFLAGS TAGLIB-EXTRAS_LIBRARIES TAGLIB-EXTRAS_INCLUDES) - -else(TAGLIB-EXTRASCONFIG_EXECUTABLE) - - find_path(TAGLIB-EXTRAS_INCLUDES - NAMES - tfile_helper.h - PATH_SUFFIXES taglib-extras - PATHS - ${KDE4_INCLUDE_DIR} - ${INCLUDE_INSTALL_DIR} - ) - - IF(NOT WIN32) - # on non-win32 we don't need to take care about WIN32_DEBUG_POSTFIX - - FIND_LIBRARY(TAGLIB-EXTRAS_LIBRARIES tag-extras PATHS ${KDE4_LIB_DIR} ${LIB_INSTALL_DIR}) - - ELSE(NOT WIN32) - - # 1. get all possible libnames - SET(args PATHS ${KDE4_LIB_DIR} ${LIB_INSTALL_DIR}) - SET(newargs "") - SET(libnames_release "") - SET(libnames_debug "") - - LIST(LENGTH args listCount) - - # just one name - LIST(APPEND libnames_release "tag-extras") - LIST(APPEND libnames_debug "tag-extrasd") - - SET(newargs ${args}) - - # search the release lib - FIND_LIBRARY(TAGLIB-EXTRAS_LIBRARIES_RELEASE - NAMES ${libnames_release} - ${newargs} - ) - - # search the debug lib - FIND_LIBRARY(TAGLIB-EXTRAS_LIBRARIES_DEBUG - NAMES ${libnames_debug} - ${newargs} - ) - - IF(TAGLIB-EXTRAS_LIBRARIES_RELEASE AND TAGLIB-EXTRAS_LIBRARIES_DEBUG) - - # both libs found - SET(TAGLIB-EXTRAS_LIBRARIES optimized ${TAGLIB-EXTRAS_LIBRARIES_RELEASE} - debug ${TAGLIB-EXTRAS_LIBRARIES_DEBUG}) - - ELSE(TAGLIB-EXTRAS_LIBRARIES_RELEASE AND TAGLIB-EXTRAS_LIBRARIES_DEBUG) - - IF(TAGLIB-EXTRAS_LIBRARIES_RELEASE) - - # only release found - SET(TAGLIB-EXTRAS_LIBRARIES ${TAGLIB-EXTRAS_LIBRARIES_RELEASE}) - - ELSE(TAGLIB-EXTRAS_LIBRARIES_RELEASE) - - # only debug (or nothing) found - SET(TAGLIB-EXTRAS_LIBRARIES ${TAGLIB-EXTRAS_LIBRARIES_DEBUG}) - - ENDIF(TAGLIB-EXTRAS_LIBRARIES_RELEASE) - - ENDIF(TAGLIB-EXTRAS_LIBRARIES_RELEASE AND TAGLIB-EXTRAS_LIBRARIES_DEBUG) - - MARK_AS_ADVANCED(TAGLIB-EXTRAS_LIBRARIES_RELEASE) - MARK_AS_ADVANCED(TAGLIB-EXTRAS_LIBRARIES_DEBUG) - - ENDIF(NOT WIN32) - - INCLUDE(FindPackageMessage) - INCLUDE(FindPackageHandleStandardArgs) - FIND_PACKAGE_HANDLE_STANDARD_ARGS(Taglib-Extras DEFAULT_MSG TAGLIB-EXTRAS_INCLUDES TAGLIB-EXTRAS_LIBRARIES) - -endif(TAGLIB-EXTRASCONFIG_EXECUTABLE) - - -if(TAGLIB-EXTRAS_FOUND) - if(NOT Taglib-Extras_FIND_QUIETLY AND TAGLIB-EXTRASCONFIG_EXECUTABLE) - message(STATUS "Taglib-Extras found: ${TAGLIB-EXTRAS_LIBRARIES}") - endif(NOT Taglib-Extras_FIND_QUIETLY AND TAGLIB-EXTRASCONFIG_EXECUTABLE) -else(TAGLIB-EXTRAS_FOUND) - if(Taglib-Extras_FIND_REQUIRED) - message(FATAL_ERROR "Could not find Taglib-Extras") - endif(Taglib-Extras_FIND_REQUIRED) -endif(TAGLIB-EXTRAS_FOUND) - diff --git a/amarok/cmake/modules/bindingstest/CMakeLists.txt b/amarok/cmake/modules/bindingstest/CMakeLists.txt deleted file mode 100644 index 2df7a873..00000000 --- a/amarok/cmake/modules/bindingstest/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -cmake_minimum_required (VERSION 2.6) - -find_package( KDE4 REQUIRED ) - -add_definitions(${QT_DEFINITIONS} ${KDE4_DEFINITIONS}) -include_directories (${QT_QTCORE_INCLUDE_DIR} ${QT_QTSCRIPT_INCLUDE_DIR} ${KDE4_INCLUDES}) - -add_executable (bindingstest QtScriptBindingsTest.cpp) -target_link_libraries( bindingstest ${QT_QTSCRIPT_LIBRARY} ${KDE4_KDEUI_LIBS} ) - diff --git a/amarok/cmake/modules/bindingstest/QtScriptBindingsTest.cpp b/amarok/cmake/modules/bindingstest/QtScriptBindingsTest.cpp deleted file mode 100644 index 424556f3..00000000 --- a/amarok/cmake/modules/bindingstest/QtScriptBindingsTest.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2009 Ian Monroe - * released under public domain or: - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include -#include -#include -#include - -#define FAIL 0xA - -int main(int argc, char **argv) -{ - QApplication app( argc, argv, false ); - - QStringList allowedBindings; - allowedBindings << "qt.core" << "qt.gui" << "qt.sql" << "qt.xml" << "qt.network"; - QScriptEngine engine; - foreach( QString binding, allowedBindings ) - { - QScriptValue error = engine.importExtension( binding ); - if( error.isUndefined() ) - { // undefined indiciates success - continue; - } - - qDebug() << "Extension" << binding << "not found:" << error.toString(); - qDebug() << "Available extensions:" << engine.availableExtensions(); - return FAIL; - } - return 0; -} diff --git a/amarok/data/CMakeLists.txt b/amarok/data/CMakeLists.txt deleted file mode 100644 index eb6020a6..00000000 --- a/amarok/data/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -install( FILES amarok_homerc DESTINATION ${CONFIG_INSTALL_DIR} ) -install( FILES amarok.notifyrc DESTINATION ${DATA_INSTALL_DIR}/amarok ) - -install(FILES DefaultPlaylistLayouts.xml - first_run_jingle.ogg - DESTINATION ${DATA_INSTALL_DIR}/amarok/data) - diff --git a/amarok/data/DefaultPlaylistLayouts.xml b/amarok/data/DefaultPlaylistLayouts.xml deleted file mode 100644 index 70273194..00000000 --- a/amarok/data/DefaultPlaylistLayouts.xml +++ /dev/null @@ -1,124 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/amarok/data/amarok.notifyrc b/amarok/data/amarok.notifyrc deleted file mode 100644 index 0ec9e0be..00000000 --- a/amarok/data/amarok.notifyrc +++ /dev/null @@ -1,236 +0,0 @@ -[Global] -IconName=amarok -Comment=Amarok -Comment[bg]=Amarok -Comment[bs]=Amarok -Comment[ca]=Amarok -Comment[ca@valencia]=Amarok -Comment[cs]=Amarok -Comment[csb]=Amarok -Comment[da]=Amarok -Comment[de]=Amarok -Comment[el]=AmaroK -Comment[en_GB]=Amarok -Comment[eo]=Amarok -Comment[es]=Amarok -Comment[et]=Amarok -Comment[eu]=Amarok -Comment[fi]=Amarok -Comment[fr]=Amarok -Comment[ga]=Amarok -Comment[gl]=Amarok -Comment[hu]=Amarok -Comment[id]=Amarok -Comment[is]=Amarok -Comment[it]=Amarok -Comment[ja]=Amarok -Comment[km]=Amarok -Comment[ko]=Amarok -Comment[lt]=Amarok -Comment[lv]=Amarok -Comment[nb]=Amarok -Comment[nds]=Amarok -Comment[nl]=Amarok -Comment[pa]=ਅਮਰੋਕ -Comment[pl]=Amarok -Comment[pt]=Amarok -Comment[pt_BR]=Amarok -Comment[ro]=Amarok -Comment[ru]=Amarok -Comment[sk]=Amarok -Comment[sl]=Amarok -Comment[sr]=Амарок -Comment[sr@ijekavian]=Амарок -Comment[sr@ijekavianlatin]=Amarok -Comment[sr@latin]=Amarok -Comment[sv]=Amarok -Comment[th]=แอมอะร็อก -Comment[tr]=Amarok -Comment[ug]=Amarok -Comment[uk]=Amarok -Comment[x-test]=xxAmarokxx -Comment[zh_CN]=Amarok -Comment[zh_TW]=Amarok 影音播放器 - -[Event/trackChange] -Name=Track Change -Name[bg]=Прехвърляне запис -Name[bs]=Promjena numere -Name[ca]=Canvi de peça -Name[ca@valencia]=Canvi de peça -Name[cs]=Změna skladby -Name[da]=Sporskift -Name[de]=Stückwechsel -Name[el]=Αλλαγή κομματιού -Name[en_GB]=Track Change -Name[es]=Cambio de pista -Name[et]=Pala muutumine -Name[eu]=Pistaren aldaketa -Name[fi]=Kappaleen vaihdos -Name[fr]=Changement de piste -Name[ga]=Athrú Amhráin -Name[gl]=Cambio de pista -Name[hu]=Számváltás -Name[id]=Track Berubah -Name[is]=Skipt um lag -Name[it]=Cambiamento della traccia -Name[ja]=トラック変更 -Name[km]=ការ​ផ្លាស់​ប្ដូរ​បទ -Name[ko]=트랙 변경 -Name[lt]=Dainos pasikeitimas -Name[lv]=Celiņa maiņa -Name[nb]=Sporbytte -Name[nds]=Stückwessel -Name[nl]=Wijziging van track -Name[pa]=ਟਰੈਕ ਬਦਲਾ -Name[pl]=Zmiana utworu -Name[pt]=Mudança de Faixa -Name[pt_BR]=Alteração de faixa -Name[ro]=Schimbare pistă -Name[ru]=Смена дорожки -Name[sk]=Zmena skladby -Name[sl]=Sprememba skladbe -Name[sr]=Промена нумере -Name[sr@ijekavian]=Промјена нумере -Name[sr@ijekavianlatin]=Promjena numere -Name[sr@latin]=Promena numere -Name[sv]=Spårändring -Name[th]=แทร็กเปลี่ยน -Name[tr]=Parça Değişimi -Name[uk]=Зміна композиції -Name[x-test]=xxTrack Changexx -Name[zh_CN]=音轨更改 -Name[zh_TW]=曲目變更 -Comment=Amarok changed to a new track -Comment[bg]=Amarok прехвърли към друг запис -Comment[bs]=Amarok je prešao na novu numeru -Comment[ca]=L'Amarok ha canviat a una peça nova -Comment[ca@valencia]=L'Amarok ha canviat a una peça nova -Comment[cs]=Amarok přešel na novou skladbu -Comment[da]=Amarok skiftede til et nyt spor -Comment[de]=Amarok gibt ein neues Stück wieder -Comment[el]=Το Amarok άλλαξε σε νέο κομμάτι -Comment[en_GB]=Amarok changed to a new track -Comment[es]=Amarok cambió a una nueva pista -Comment[et]=Amarok võttis ette uue pala -Comment[eu]=Amarok pista berri batera aldatu da -Comment[fi]=Amarok vaihtoi kappaletta -Comment[fr]=Amarok lit une nouvelle piste -Comment[ga]=Thosaigh Amarok amhrán nua -Comment[gl]=Amarok cambiado a unha nova pista -Comment[hu]=Az Amarok átváltott egy új számra -Comment[id]=Amarok mengubah track menjadi baru -Comment[is]=Amarok skipti yfir í nýtt lag -Comment[it]=Amarok è passato a una nuova traccia -Comment[ja]=Amarok は新しいトラックに変更されました -Comment[km]=Amarok បាន​ផ្លាស់ប្ដូរ​ទៅ​បទ​ថ្មី -Comment[ko]=Amarok에서 새 트랙을 재생함 -Comment[lt]=Amarokas persijungė į naują dainą -Comment[lv]=Amarok sāka atskaņot jaunu celiņu -Comment[nb]=Amarok byttet til et nytt spor -Comment[nds]=Amarok hett na en nieg Stück wesselt -Comment[nl]=Amarok is naar een nieuwe track gegaan -Comment[pa]=ਅਮਰੋਕ ਨੇ ਨਵਾਂ ਟਰੈਕ ਬਦਲਿਆ -Comment[pl]=Utwór został zmieniony na nowy -Comment[pt]=O Amarok mudou para uma faixa nova -Comment[pt_BR]=O Amarok mudou para uma nova faixa -Comment[ro]=Amarok a trecut la altă piesă -Comment[ru]=Amarok перешёл на новую дорожку -Comment[sk]=Amarok zmenil skladbu na novú -Comment[sl]=Amarok je zamenjal skladbo -Comment[sr]=Амарок је прешао на нову нумеру -Comment[sr@ijekavian]=Амарок је прешао на нову нумеру -Comment[sr@ijekavianlatin]=Amarok je prešao na novu numeru -Comment[sr@latin]=Amarok je prešao na novu numeru -Comment[sv]=Amarok bytte till ett nytt spår -Comment[th]=แอมอะร็อกเปลี่ยนเป็นแทร็กใหม่ -Comment[tr]=Amarok yeni bir parçaya geçti -Comment[uk]=Композиція у Amarok змінилася -Comment[x-test]=xxAmarok changed to a new trackxx -Comment[zh_CN]=Amarok 更改到新音轨 -Comment[zh_TW]=Amarok 已變更至新的曲目 -Action=Popup - -[Event/message] -Name=Message -Name[bs]=Poruka -Name[ca]=Missatge -Name[ca@valencia]=Missatge -Name[cs]=Zpráva -Name[da]=Besked -Name[de]=Nachricht -Name[el]=Μήνυμα -Name[en_GB]=Message -Name[es]=Mensaje -Name[et]=Teade -Name[fi]=Viesti -Name[fr]=Message -Name[ga]=Teachtaireacht -Name[gl]=Mensaxe -Name[hu]=Üzenet -Name[id]=Pesan -Name[it]=Messaggio -Name[lt]=Pranešimas -Name[lv]=Ziņojums -Name[mr]=संदेश -Name[nb]=Melding -Name[nl]=Bericht -Name[pa]=ਸੁਨੇਹਾ -Name[pl]=Wiadomość -Name[pt]=Mensagem -Name[pt_BR]=Mensagem -Name[ro]=Mesaj -Name[ru]=Сообщение -Name[sk]=Správa -Name[sl]=Sporočilo -Name[sr]=Порука -Name[sr@ijekavian]=Порука -Name[sr@ijekavianlatin]=Poruka -Name[sr@latin]=Poruka -Name[sv]=Meddelande -Name[tr]=İleti -Name[ug]=ئۇچۇر -Name[uk]=Повідомлення -Name[x-test]=xxMessagexx -Name[zh_CN]=消息 -Name[zh_TW]=訊息 -Comment=Amarok issued an uncategorized text message -Comment[bs]=Amarok je izbacio nekategorizovanu tekstualnu poruku -Comment[ca]=L'Amarok ha emès un missatge de text sense categoria -Comment[ca@valencia]=L'Amarok ha emés un missatge de text sense categoria -Comment[cs]=Amarok vyvolal nezařazenou textovou zprávu -Comment[da]=Amarok udsendte en ikke-kategoriseret tekstmeddelelse -Comment[de]=Amarok hat eine nicht kategorisierte Textnachricht ausgegeben -Comment[el]=Το Amarok εξέδωσε ένα μη κατηγοριοποιημένο μήνυμα σε απλό κείμενο -Comment[en_GB]=Amarok issued an uncategorised text message -Comment[es]=Amarok emitió un mensaje de texto no clasificado -Comment[et]=Amarok andis liigitamata tekstiteate -Comment[fi]=Amarok lähetti luokittelemattoman tekstiviestin -Comment[fr]=Amarok a émis un message de texte sans catégorie -Comment[ga]=Chuir Amarok teachtaireacht téacs gan catagóir amach -Comment[gl]=Amarok enviou unha mensaxe de texto sen categoría. -Comment[hu]=Az Amarok egy kategorizálatlan szöveges üzenetet adott ki -Comment[id]=Amarok mengeluarkan pesan teks tidak berkategori -Comment[it]=Amarok ha generato un messaggio di testo non categorizzato -Comment[lt]=Amarok pateikė tekstinį pranešimą be kategorijos -Comment[lv]=Amarok izdeva teksta ziņojumu bez kategorijas -Comment[nb]=Amarok sendte en tekstmelding uten kategori -Comment[nl]=Amarok stuurde een niet gecategoriseerd tekstbericht -Comment[pl]=Amarok wystosował niekategoryzowaną wiadomość tekstową -Comment[pt]=O Amarok enviou uma mensagem de texto sem categoria -Comment[pt_BR]=O Amarok emitiu uma mensagem de texto não-categorizada -Comment[ro]=Amarok a emis un mesaj textual necategorizat -Comment[ru]=Сообщение от Amarok, не относящееся ни к какой из категорий -Comment[sk]=Amarok vydal nekategorizovanú textovú správu -Comment[sl]=Amarok je oddal nekategorizirano besedilno sporočilo -Comment[sr]=Амарок је издао општу текстуалну поруку -Comment[sr@ijekavian]=Амарок је издао општу текстуалну поруку -Comment[sr@ijekavianlatin]=Amarok je izdao opštu tekstualnu poruku -Comment[sr@latin]=Amarok je izdao opštu tekstualnu poruku -Comment[sv]=Amarok skickade ett okategoriserat textmeddelande -Comment[tr]=Amarok kategorilenmemiş bir metin iletisi oluşturdu -Comment[uk]=Програмою Amarok надіслано текстове повідомлення, що не належить до певної категорії -Comment[x-test]=xxAmarok issued an uncategorized text messagexx -Comment[zh_CN]=Amarok 发出了一条未分类文本消息 -Comment[zh_TW]=Amarok 發出了一個未分類的文字訊息 -Action=Popup diff --git a/amarok/data/amarok_homerc b/amarok/data/amarok_homerc deleted file mode 100644 index 4a5aa4b0..00000000 --- a/amarok/data/amarok_homerc +++ /dev/null @@ -1,3 +0,0 @@ -[Containment 0] -firstShowingApplet=0 -plugins=currenttrack,wikipedia,lyrics diff --git a/amarok/data/first_run_jingle.ogg b/amarok/data/first_run_jingle.ogg deleted file mode 100644 index cc5d0444..00000000 Binary files a/amarok/data/first_run_jingle.ogg and /dev/null differ diff --git a/amarok/images/CMakeLists.txt b/amarok/images/CMakeLists.txt deleted file mode 100644 index a5c5dfd2..00000000 --- a/amarok/images/CMakeLists.txt +++ /dev/null @@ -1,81 +0,0 @@ -add_subdirectory( icons ) - -########### install files ############### - -install(FILES - amarok_icon.svg - ball.png - default-theme-clean.svg - dot.png - emblem-amazon.png - emblem-default.png - emblem-jamendo.png - emblem-jamendo-scalable.svgz - emblem-lastfm.png - emblem-lastfm-scalable.svg - emblem-gpodder.png - emblem-gpodder-scalable.svgz - emblem-magnatune.png - emblem-mp3tunes.png - emblem-ampache.png - emblem-ampache-scalable.svgz - emblem-scripted.png - emblem-scripted-scalable.svgz - grid.png - lastfm-default-cover.png - echonest.png - lastfm.png - loading1.png - loading2.png - mb_aicon.png - mb_licon.png - mb_ticon.png - navigation_arrows.svg - nocover.png - playlist-bookmark-16.png - playlist-layouts-22.png - playlist-sorting-16.png - pud_items.svg - smallstar.png - star.png - volume_icon.png - volume_muted_icon.png - wirl1.png - wirl2.png - service_info_loading1.png - service_info_loading2.png - service_info_loading3.png - service_info_loading4.png - service_info_loading5.png - service_info_loading6.png - service_info_loading7.png - service_info_loading8.png - service_info_loading9.png - service_info_loading10.png - service_info_loading11.png - service_info_loading12.png - hover_info_collections.png - hover_info_dynamic_playlists.png - hover_info_files.png - hover_info_internet.png - hover_info_playlists.png - hover_info_user_playlists.png - hover_info_podcasts.png - opendesktop-22.png - - emblem-delicious.png - emblem-digg.png - emblem-facebook.png - emblem-identica.png - emblem-linkedin.png - emblem-myspace.png - emblem-reddit.png - emblem-stackoverflow.png - emblem-twitter.png - emblem-wikipedia.png - emblem-xing.png - - DESTINATION ${DATA_INSTALL_DIR}/amarok/images -) - -kde4_install_icons( ${ICON_INSTALL_DIR} ) diff --git a/amarok/images/amarok_icon.svg b/amarok/images/amarok_icon.svg deleted file mode 100644 index dd2f2185..00000000 --- a/amarok/images/amarok_icon.svg +++ /dev/null @@ -1,551 +0,0 @@ - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/amarok/images/amarok_icon_small.svg b/amarok/images/amarok_icon_small.svg deleted file mode 100644 index cfa96c96..00000000 --- a/amarok/images/amarok_icon_small.svg +++ /dev/null @@ -1,340 +0,0 @@ - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/amarok/images/amarok_logo.svg b/amarok/images/amarok_logo.svg deleted file mode 100644 index 191ef0e2..00000000 --- a/amarok/images/amarok_logo.svg +++ /dev/null @@ -1,2344 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - eJzdWwtv3MZ27h/gf2BRuJDSiJ73wykK7DPX9yq2YNmJgSAQqF1a4vVqueBypTi/vt8ZPlcrW3aa -Jm4hW1p+c+bMeZ8ZkvvkX8/OT0bL4jI7kQmLoydPJmWWVkX5LA5o/Hy12m2rkqCjV8cxZwkD0ei5 -u2gIf8zKbV6sn7VDc5p7dF5lt1n89+JyexwfbbJ8fXK3q0621W6ZF9tjkL3Oq1UGwvQmLYv38Tq7 -i29rTmKBT+/BOUnz41Yg4NO0wgQmEvwTjKlY8GdKx2+uSxCNi916ma+vxsWvoIm58rE1IlbaYvBv -+atsu0+RaM4skSXaCA1anijuPCaYxHgjMWtaLHY32bo6K4tFtt1OilVRbp/Fkw/pOv4hvcJIGsEQ -+mKerzJofZNWsSETjJ7Li0D9ZgsyzKDPBNuL5zdAzrOqgiDgRfZ69f14uAJJTz9HP7/KrvJgeej+ -y3Ewuqn5nmebtMbBCobHzxEG42n2Lt2tqnrBuKfCx+qYfPsf8csNAdswyZChmv/1D69/XAe0Pyec -/vVk98drVMQyVmGZs7MpLSFqSsNgV4yKZubD849IRLLd6+xms4Kzg6cUg69i4eGo4eeGEpYPVCdQ -5sS4WCsWWy7q0d6B2W2e3T2LXxTrrHbZqKzO89/gG2ddYhVDpAidcG98Pf5qt8rKN+u8IksR5GvL -/1Ass1UDBS7zVRocOdAr/K4JXqflVVYh+IrVrgpJ4lgz9GJ3c5p+yMp+gZebbP26+DFIeuIk/CA8 -p0jFB4SotyYWJnBHcCvRrcXb1YgBTW/5UuifId5elvlVvn7W2CgEkrw4SzdZ+SpbVMBd7ISKtbWw -Yzv+A0THJIydKHK+i2mIYvj7Ml/2IWwT5oyJXf8h6J+4wX/f/q8Vhc2qKlvX4T9bLyfFDblpS2mM -mF8jHVbFVT3WfQ4jWHa3qZUN1xfw6FmZr0mW6MUm4vF4PRj+vkyXOTijzLxZr9ObbBlfNVDMj6OH -QMgu4vEy+jn6z2g+n8/m0/lkPp6P5n7u5nZu5nqu5nIu5nzOZvPZbDadTWbj2WjmZ25mZ2amZ2om -Z2LGZ2w6n86m0+lkOp6Opn7qoqmdmqmeqqmciimfssl8MptMJ5PJeDKa+Imb2ImZ6ImayImY8Akb -z8ez8XQ8GY/Ho7Efu7Edm7Eeq7EcizEfs2g0H81G09FkNB6NRn7kRnZkRnqkRnIkRnzE/NzP/NRP -/NiPvPfOW0S49spLj9jyzM3dzE3dxI3dyHnnIqSDcdopJ51w3DE7tzM7tRM7tiPrrbPWGqutstIK -yy0zczMzUzMxYzNC2XTGGmO0UUYaYbhhkZ7rmZ7qiR7rkfbaaauN1lppqYXmmqm5mqmpmqixGimv -nLLKKK2Ukkoorpicy5mcyokcy5H00kXSSiO1VFJKIblkYi5mYiomYixGwgsnrEBBF0pIIQQXjM/5 -jE/5hI/5iHvuuOWGa6645IJzziIGRzL4go0ZDMagMzMMgjHwZhzp+l8Ri59cjEvEBKWcRsaxgJxH -Ty4GyHgb8fqqG+2uMTae1pGJoG7jsgOGcXxy8okA/z0TfD1CJa/6sMq20dN/rIu7dbiIn0VHPzdt -45fj+OkL5EP8bfT0PEcJzloSFr+M9lvE2xTAq2i/HbwdRYOLD7j4Oz78E9BdrOIf4p9/YfES6NtX -UeCxjJ6epRA1/i6Kn0II/A3iQr9e2Ec1PktXKEZZkOXs8p5I97toGHr7W3SAny0illinJMqUQB+o -5ydCyVCCEdlUvwRKKFQ/eoHdStNk79JqcU2FAxzOxp24rVRf4plTCDR0x4E1AsHvCQHO6qHzDzeX -xYrY/EsDg9E98IuZu4uz1S5U22K3eb5+V0RH9dbxjMp8uX4JF1XX8bjcba/j10Wxwo5wj6AZqrnQ -YFkNqT+5Bmg/zr9n9Lt4ny+CfA9x3h/quD8w45MrTNLVKkf32Vzni4eWeWC8W+tjcz+5IFpvmfU8 -wmX399PGCFGSb296GwyQ/vNHmJCL3uXrJYxzvsurrFexuNnQzjw+v8aOBPAB5WMxBtevsvVy27Gs -L3stT/PbFvw0M2QetvGDYAnobH2brYrNwGwdkkLun9Jyc/yJxGmSvN2M4hSDY8PF0/Ya5ZWu8gUV -orT8UF+//eH0Bbaa4eLo35YNLQr0eQXmV/HRrzerNQhO6BdtYo5RtZ9cPDx+m652DYGPnz7HmnvD -1YdNM/p0VJbpQxLcZFW6hOD/cwH47xPgNi3z9HJFR6ft1yDEXy7Dn2mF73qaxXW+WpbZuqG5F7YD -QtTBMr/cVSTot2Ho20Ndnm1T2mZQSvzJjv1slfYlpjmPi3n07+vtxWK3rYqb7z5CPJBZ/LluaHU4 -dEcYeHb7eeohDrdfq3Kkw7efE46/MwqgO8L1RTDIY7a6zMNNJ/71mWqoxWEwrIrF+2z5uH7rYv0x -K/yFurXS/29GwRfUgq85WT7TSPu6b9/d/WUdcLvKF/8v2l9Q5LzYlYss3Jv+KnXaF/nDoyKeWOcR -x6+ydPXVxPmHB7vdZ6hiPf/KVPn1IVXu8mV1/ag63EgnvzJ1GskPVbrO8qvrx3fZX6NOreiHSl0W -FbaEp9m7qr4j/7h68dMxjvRfjWqHCnwlDRb96P94f/3jmswfJPzgpgMhRmupG/uNnvs4LavLIi2X -8SLcBuVx2e63HqW8KrNWpEdpLzvn0S1993FS0QvwKOVAgEdpLw966yHZfnTReFWm6+0mhekXH7Bc -voy3+W8NH9YmNRFu6CkcBm92q3AnuiaRjLVFjYhe7qrNropfpdsqK/Pf6ke6/UPFRjy9N+eHbHv9 -yIz78aAaBaBTo5JtdVpu8uSe9Okq396DbtLt+0YB08qySZf9Pnz0PB7tqqKTq7UsqdvYjrP4Xf14 -EHYpA93Jbbao4IzLdJWuF4dW3JtS7KpVvs7iKvu1+jzKbVUW77P7utwjXqzyDZxNdyt+RaRd0TP0 -T8/YlNk2K2+zuLjNyg3dEdzeK+rvR8/P0hKFDDpuZzeX2XK0Ws0LEP4j+/Ap2vPd5TarAuU4WxV3 -AyvWRv8Y9SsKhI55a/RDOc7K4l2+yj5N+dN1vri+T/mwwGfTOd3mxeqX+SqvPklLhDDd9qNhul+n -z7PV39JqWixOi0W6otPsNow/VNM7WiiTlc+nQ8rh8Gu6wUartkMw66Iol9nyUKD46Yui2hvmw/xe -F73/43wdQqjYhvvf92tKd0M4PORGZVhnq/3Kcv7j9+TG2qF0g3mfSTNMhhiUhX4wuLZOvSZL+7Gz -Mlvkvc0HK87Wi2LZraX6gfBE6nXXPju1MRTumwdfbNLFA+PtCx6HI2dX7+6lFcC36eaQ8hynp06s -7w7d0D9L3L/zTi8V3H+NILwwETUvv3TvslgfC63pT/MQ9/QyOgqk9LjvdF3HV/XAHubN8ykio6a9 -AO13dXWg90UwdNzKdxGxmB6Zvr2rn7B+9vPHz33Kqr1LDMMcyUzCFT7cDDDhEnA3sfYCSyoXS2UT -bp2NtZOJhihSi8Q4xeNJNISckDY+jbRyCQ8YxozX9PYNT6S1sWI+EV6r+EcQaawsTCyYSpQXgiZq -nignVSxIBKUlFoSqUgDRJpGahAJPz8BcaJ9ABEcyQFDpGb0GoxMD+eNOGeFUwo3g8aHKi+jdw57a -azqL9jHUlh5DxTfYFQ38xOPR5iNPwD/TaaMIKtxF2jCooDTEkwkX3pNHWkwImQhnoYQwZHcTc+3q -99OU0wnzfoAsIqXgEq6HVLC7Y8r2nDqkWw/zOsyJxFsu4o6TQgTQ22/9eh2yiDqpOqzXpuV0qN8i -uvyCyEYQR8ohiqT2LQ8FG/WYNInjENBLKIG50sDznIIWanGPYOoQElkl2okBkbQJ08J2fHqgXQyz -WkwYj/gkRRs+2C0mXEKHbrEOgV1bkTqsk7pjdKgbhedBZGHxBEFuAplzUlKYtJiwrvaW5hDCSocc -sQmE4Y1YIWsahMTydXp3mPIca8ueUQt0q9GsBhKYrcEYPuQeJrE20cLDJBwIY6JHyNwsMXaPqlOk -4XOgGOm/i77ZUS3cfEGkGNQTiV+oSAycGEWJUSzhzA6w0wHGYXoWKpehtz0F5CQ6b1HgTiPokjgq -LgPMWJkwpchbKnFSq0AHw0hO5nQwgOYNP60p7wYY1mWenOOpTFoxlGVI1+rxENbpsYKVvnkTvQmh -8nYZGXpb8u1PsFxjuy9pH5QNxlEuaTKDgOUkKirTxvTYKTAEE2ssYpymNGeo4SgrUmvYA/6UXide -Wh0QZRBli6jHBKgsGIAXcgPLUjwZLETFxwczmwHiEI5O9wBYWZQTB9t1rEImU4+RHBILyqRGG/gT -zSdUnA5CNVJgRwIg/qxR4kGMWqH3eh+TFKmkKxD0J3xAWlvHbSCHy3lohpZZ3SxZy9Vip4d2/rgX -v9iHAvVLOV8b1DDq7AQZK2g9RJwzaCjox/QmHkTXaKsEQFHnqNWTUpR91HFR3jBLo+N6Rd3VNJq3 -PhUWvdRLNfQyaldiNbFqMfIIkp6Yk32QQT2CwuCZDS5tMQHfahUCDZDltB9AFHploRSHdspRBUaZ -dF4HxHGjev+RCCJhjOuhTwXqFjKWZsL4huoTEOYEUTkkE4ToEQtfNdpQfQuq1hA4YUtRa28EvdqK -cLIKWhgbKqmB8mFIMcRnh4AV7XgweUAlscEynGSyzXalQ9BnDdeC5nUYqaUczdOJYIKKpa09K7Bz -8qFwcVXvijAPMviQN2gH2ALx4C6P9h/Mzi1tqxyVflvThN6PeR0WdmEIu9MBBmFQ9EQQEBJTYaB9 -GCMLQSqrVI+QDORBqNpTQSrtGSEoYcG3rZhNwE4OY5jyg8fTKJRCRL1wtI+k+tQjqLSIleDekFOk -bKhc5Dmu0FE7pNZRMSMHVK2GZGVvrBvYhloSDzmBxii9q7s0dkEmbtenRkCvxcb3RVx8OrWnX5je -3gdTKlriBlconlRbWug04tSRHKf0QzBrKWKODIHgg4TkKJpGSzlMW46tHkc7GlAh77ElFF1NoO0k -d+Spto5gGsztGE1riSgK0AIGfByl15AzDIlNgmADkcLGNFQNRUFO+dwhkFYzQfW7w4aJzRBiflgA -BljXDIYYthqWIWfIhyHw2iU5nWVCx2kRKAiXC6H4gAplUNVxzxlqJ6dSpHnPmKwCj1LKUloJLWkS -NhlcUqKh/dOevEeQxE6bel6DDXQhxzhN2fsANtCvxyQczy22/7SrsGpgU2zckNFURwcKduHRUcFS -3qk60hDHnN5iRsA0XdpbSSlE5ykZNoKi3lp2wdhq2AG9gi000AWJ6xltmA+hQcukuN+/akP+D+yd -kMAxIfqIo1MxTjQhB0BNXxyiQouTf9s4kQn0bnl3TTUiwXnZdghHUDgsLNFzncHZFPbGNtGF/YM0 -9aa6CbsWwW4SNCI0TBFiG83L6GFPRfBx7oY5BVHDpr2DqO55qvYKNc4zGVtIIClCcA== - - - avGaU7FvIaqfOImHDS/2BooKIboag9GJD85xMvR/4+AhaoV62HApbPV+2OKTd9TjWi4BMpwOS3sQ -M6GDtt0Vuw64wIeWz1BIYoR18HrXNSUPpWPQWTkd4qTsoeZbXNTYOdW59tphu2JI7RagIKbvpiDw -6STAQq4jc3zCyNnwASq/D5tXqOjp9gEnnth546wrnXRhAwI6HXfRA4+DnUcjOwiotpFJ1DEZ2r51 -mvoYJJfMmx4ybVqgCxnaP3a8GFJQkki0n7AhvyABQgvpnahwhEQYCSoA9XWvdgvg+GJouyKoUPB+ -0Xtifax3vYl886m5//GlXaz7Vl19tnEwQDhmOeU66HQAYceFYzNlfj/zIayb+q4BWW17+vZHu4Y1 -PXTaQ+Fwx0XHjmY+hPVT39Un0/ptgO5weBM57cXwsHj04jj+piEjCaGRacm6632y7ljZcuuPmTWZ -xeYpHFRRpmnN7rp+zaIjw0ktnF1bsvZ6n6yRrT2PtrL159OGG+IqnFxbbu31PrfT/ssO4UYnve0c -vm72ukzzVVZGV9v0ll6RXhdVWmUbjNCTt21VlFm8vS7uCKEvgjbkT57MXs6j/wZ+BIAW - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/amarok/images/back_stars_grey.png b/amarok/images/back_stars_grey.png deleted file mode 100644 index 6d4a3cbd..00000000 Binary files a/amarok/images/back_stars_grey.png and /dev/null differ diff --git a/amarok/images/ball.png b/amarok/images/ball.png deleted file mode 100644 index 267aded8..00000000 Binary files a/amarok/images/ball.png and /dev/null differ diff --git a/amarok/images/default-theme-clean.svg b/amarok/images/default-theme-clean.svg deleted file mode 100644 index 6629da1a..00000000 --- a/amarok/images/default-theme-clean.svg +++ /dev/null @@ -1,11847 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - new_slider_bottom - - - new_slider_knob - - - - - - - new_slider_knob_active - - - - - - - - new_slider_top - - - new_slider_end - - new_slider_bottom - - - new_slider_top - - - - new_slider_top_played - - - new_slider_bottom - - - - - - - - - - - - - - - - - - - new_slider_knob_nuno - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - progress_slider_left - - - progress_slider_right - - - progress_slider_played_left - - - progress_slider_played_right - - - progress_slider_mid - - - progress_slider_played_mid - - - - - - - - - - - - - - - - - - - moodbar_end_left - - - moodbar_end_right - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - progress_slider_played_left - - - diff --git a/amarok/images/default-theme.svg b/amarok/images/default-theme.svg deleted file mode 100644 index af321c76..00000000 --- a/amarok/images/default-theme.svg +++ /dev/null @@ -1,8336 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - buttonbar - head - body - collapsed_head - active_overlay - playlist_items - collapse_button_grayed_out - expand_button - collapse_button - album_overlay - context_wallpaper - - - - - - - slider_background - - - volume_icon - - - amarok_logo - - context_background - - toolbar - - Sliders - track - alt_body - - - - - - - - - - - - - - Color codes - - - Service browser - service_list_item - Any occurence of the following colors in the elements will be replaced by thecorresponding color from the current color schemes palette666765 -- Window colore8e8e8 -- Slightly lighter than window color ( + 10% white )565755 -- Slightly darker than window color ( + 10% black )f0f0f0 -- Base color ( list / text background )e0e0e0 -- Alternate base color ( alternate list items )66ffff -- Highlight color ( bright color ) - - - - - - Sidebar - sidebar_button - - - - - - - - - - - - - - - - - 123456 -- Mix between window and highlight color - - - - - - - - - - - - - - - splitter_handle - - - splitter_handle - 010101 -- Default text color ( good for high contrast borders and shadows/highlights ) - - - - - - - alt_head - - alt_track - - - - - - - - - - - - - - - - - - - - - - - - - - - - - divider_top - divider_bottom - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Image border - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/amarok/images/dot.png b/amarok/images/dot.png deleted file mode 100644 index a70432e2..00000000 Binary files a/amarok/images/dot.png and /dev/null differ diff --git a/amarok/images/echonest.png b/amarok/images/echonest.png deleted file mode 100644 index 604cc12d..00000000 Binary files a/amarok/images/echonest.png and /dev/null differ diff --git a/amarok/images/emblem-amazon-scalable.svgz b/amarok/images/emblem-amazon-scalable.svgz deleted file mode 100644 index 49eb544a..00000000 Binary files a/amarok/images/emblem-amazon-scalable.svgz and /dev/null differ diff --git a/amarok/images/emblem-amazon.png b/amarok/images/emblem-amazon.png deleted file mode 100644 index 4cff09f7..00000000 Binary files a/amarok/images/emblem-amazon.png and /dev/null differ diff --git a/amarok/images/emblem-ampache-scalable.svgz b/amarok/images/emblem-ampache-scalable.svgz deleted file mode 100644 index 9474974c..00000000 Binary files a/amarok/images/emblem-ampache-scalable.svgz and /dev/null differ diff --git a/amarok/images/emblem-ampache.png b/amarok/images/emblem-ampache.png deleted file mode 100644 index 37c5441a..00000000 Binary files a/amarok/images/emblem-ampache.png and /dev/null differ diff --git a/amarok/images/emblem-default.png b/amarok/images/emblem-default.png deleted file mode 100644 index 64639ad5..00000000 Binary files a/amarok/images/emblem-default.png and /dev/null differ diff --git a/amarok/images/emblem-delicious.png b/amarok/images/emblem-delicious.png deleted file mode 100644 index f549c17b..00000000 Binary files a/amarok/images/emblem-delicious.png and /dev/null differ diff --git a/amarok/images/emblem-digg.png b/amarok/images/emblem-digg.png deleted file mode 100644 index 438a4ff0..00000000 Binary files a/amarok/images/emblem-digg.png and /dev/null differ diff --git a/amarok/images/emblem-facebook.png b/amarok/images/emblem-facebook.png deleted file mode 100644 index f34a148d..00000000 Binary files a/amarok/images/emblem-facebook.png and /dev/null differ diff --git a/amarok/images/emblem-gpodder-scalable.svgz b/amarok/images/emblem-gpodder-scalable.svgz deleted file mode 100644 index ac3c7ef3..00000000 Binary files a/amarok/images/emblem-gpodder-scalable.svgz and /dev/null differ diff --git a/amarok/images/emblem-gpodder.png b/amarok/images/emblem-gpodder.png deleted file mode 100644 index 0e267c01..00000000 Binary files a/amarok/images/emblem-gpodder.png and /dev/null differ diff --git a/amarok/images/emblem-identica.png b/amarok/images/emblem-identica.png deleted file mode 100644 index a2f6da2a..00000000 Binary files a/amarok/images/emblem-identica.png and /dev/null differ diff --git a/amarok/images/emblem-jamendo-scalable.svgz b/amarok/images/emblem-jamendo-scalable.svgz deleted file mode 100644 index 1d2df07a..00000000 Binary files a/amarok/images/emblem-jamendo-scalable.svgz and /dev/null differ diff --git a/amarok/images/emblem-jamendo.png b/amarok/images/emblem-jamendo.png deleted file mode 100644 index 69cf21a7..00000000 Binary files a/amarok/images/emblem-jamendo.png and /dev/null differ diff --git a/amarok/images/emblem-lastfm-scalable.svg b/amarok/images/emblem-lastfm-scalable.svg deleted file mode 100644 index 9012181e..00000000 --- a/amarok/images/emblem-lastfm-scalable.svg +++ /dev/null @@ -1,212 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/amarok/images/emblem-lastfm.png b/amarok/images/emblem-lastfm.png deleted file mode 100644 index fa11493c..00000000 Binary files a/amarok/images/emblem-lastfm.png and /dev/null differ diff --git a/amarok/images/emblem-linkedin.png b/amarok/images/emblem-linkedin.png deleted file mode 100644 index 76ba8c20..00000000 Binary files a/amarok/images/emblem-linkedin.png and /dev/null differ diff --git a/amarok/images/emblem-magnatune.png b/amarok/images/emblem-magnatune.png deleted file mode 100644 index 94ed9ff0..00000000 Binary files a/amarok/images/emblem-magnatune.png and /dev/null differ diff --git a/amarok/images/emblem-mp3tunes.png b/amarok/images/emblem-mp3tunes.png deleted file mode 100644 index d4fa8686..00000000 Binary files a/amarok/images/emblem-mp3tunes.png and /dev/null differ diff --git a/amarok/images/emblem-myspace.png b/amarok/images/emblem-myspace.png deleted file mode 100644 index 40895c96..00000000 Binary files a/amarok/images/emblem-myspace.png and /dev/null differ diff --git a/amarok/images/emblem-reddit.png b/amarok/images/emblem-reddit.png deleted file mode 100644 index c96c6277..00000000 Binary files a/amarok/images/emblem-reddit.png and /dev/null differ diff --git a/amarok/images/emblem-scripted-scalable.svgz b/amarok/images/emblem-scripted-scalable.svgz deleted file mode 100644 index 10fbef8e..00000000 Binary files a/amarok/images/emblem-scripted-scalable.svgz and /dev/null differ diff --git a/amarok/images/emblem-scripted.png b/amarok/images/emblem-scripted.png deleted file mode 100644 index 08273002..00000000 Binary files a/amarok/images/emblem-scripted.png and /dev/null differ diff --git a/amarok/images/emblem-stackoverflow.png b/amarok/images/emblem-stackoverflow.png deleted file mode 100644 index 3ed45fb7..00000000 Binary files a/amarok/images/emblem-stackoverflow.png and /dev/null differ diff --git a/amarok/images/emblem-twitter.png b/amarok/images/emblem-twitter.png deleted file mode 100644 index f4606f56..00000000 Binary files a/amarok/images/emblem-twitter.png and /dev/null differ diff --git a/amarok/images/emblem-wikipedia.png b/amarok/images/emblem-wikipedia.png deleted file mode 100644 index ec91d312..00000000 Binary files a/amarok/images/emblem-wikipedia.png and /dev/null differ diff --git a/amarok/images/emblem-xing.png b/amarok/images/emblem-xing.png deleted file mode 100644 index 7e70ac19..00000000 Binary files a/amarok/images/emblem-xing.png and /dev/null differ diff --git a/amarok/images/grid.png b/amarok/images/grid.png deleted file mode 100644 index 6db12494..00000000 Binary files a/amarok/images/grid.png and /dev/null differ diff --git a/amarok/images/hi128-app-amarok.png b/amarok/images/hi128-app-amarok.png deleted file mode 100644 index 7f4f2eb3..00000000 Binary files a/amarok/images/hi128-app-amarok.png and /dev/null differ diff --git a/amarok/images/hi16-app-amarok.png b/amarok/images/hi16-app-amarok.png deleted file mode 100644 index 29500b10..00000000 Binary files a/amarok/images/hi16-app-amarok.png and /dev/null differ diff --git a/amarok/images/hi22-app-amarok.png b/amarok/images/hi22-app-amarok.png deleted file mode 100644 index 28737325..00000000 Binary files a/amarok/images/hi22-app-amarok.png and /dev/null differ diff --git a/amarok/images/hi32-app-amarok.png b/amarok/images/hi32-app-amarok.png deleted file mode 100644 index 59f80e2c..00000000 Binary files a/amarok/images/hi32-app-amarok.png and /dev/null differ diff --git a/amarok/images/hi48-app-amarok.png b/amarok/images/hi48-app-amarok.png deleted file mode 100644 index 17f938b1..00000000 Binary files a/amarok/images/hi48-app-amarok.png and /dev/null differ diff --git a/amarok/images/hi64-app-amarok.png b/amarok/images/hi64-app-amarok.png deleted file mode 100644 index b24a50e2..00000000 Binary files a/amarok/images/hi64-app-amarok.png and /dev/null differ diff --git a/amarok/images/hover_info_collections.png b/amarok/images/hover_info_collections.png deleted file mode 100644 index 0821b4e1..00000000 Binary files a/amarok/images/hover_info_collections.png and /dev/null differ diff --git a/amarok/images/hover_info_dynamic_playlists.png b/amarok/images/hover_info_dynamic_playlists.png deleted file mode 100644 index 92fa3cb1..00000000 Binary files a/amarok/images/hover_info_dynamic_playlists.png and /dev/null differ diff --git a/amarok/images/hover_info_files.png b/amarok/images/hover_info_files.png deleted file mode 100644 index 8d21e88e..00000000 Binary files a/amarok/images/hover_info_files.png and /dev/null differ diff --git a/amarok/images/hover_info_internet.png b/amarok/images/hover_info_internet.png deleted file mode 100644 index 57ad7579..00000000 Binary files a/amarok/images/hover_info_internet.png and /dev/null differ diff --git a/amarok/images/hover_info_playlists.png b/amarok/images/hover_info_playlists.png deleted file mode 100644 index 395f2102..00000000 Binary files a/amarok/images/hover_info_playlists.png and /dev/null differ diff --git a/amarok/images/hover_info_podcasts.png b/amarok/images/hover_info_podcasts.png deleted file mode 100644 index fcdead5d..00000000 Binary files a/amarok/images/hover_info_podcasts.png and /dev/null differ diff --git a/amarok/images/hover_info_user_playlists.png b/amarok/images/hover_info_user_playlists.png deleted file mode 100644 index ae64b589..00000000 Binary files a/amarok/images/hover_info_user_playlists.png and /dev/null differ diff --git a/amarok/images/icons/CMakeLists.txt b/amarok/images/icons/CMakeLists.txt deleted file mode 100644 index 4ab1c030..00000000 --- a/amarok/images/icons/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -########### install files ############### - -kde4_install_icons( ${DATA_INSTALL_DIR}/amarok/icons ) - diff --git a/amarok/images/icons/hi128-status-audio-volume-high-amarok.png b/amarok/images/icons/hi128-status-audio-volume-high-amarok.png deleted file mode 100644 index 64820b2f..00000000 Binary files a/amarok/images/icons/hi128-status-audio-volume-high-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi128-status-audio-volume-low-amarok.png b/amarok/images/icons/hi128-status-audio-volume-low-amarok.png deleted file mode 100644 index 3f7dbb09..00000000 Binary files a/amarok/images/icons/hi128-status-audio-volume-low-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi128-status-audio-volume-medium-amarok.png b/amarok/images/icons/hi128-status-audio-volume-medium-amarok.png deleted file mode 100644 index 02a51ac4..00000000 Binary files a/amarok/images/icons/hi128-status-audio-volume-medium-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi128-status-audio-volume-muted-amarok.png b/amarok/images/icons/hi128-status-audio-volume-muted-amarok.png deleted file mode 100644 index 3e3466f6..00000000 Binary files a/amarok/images/icons/hi128-status-audio-volume-muted-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi16-action-amarok_artist.png b/amarok/images/icons/hi16-action-amarok_artist.png deleted file mode 100644 index fbd699af..00000000 Binary files a/amarok/images/icons/hi16-action-amarok_artist.png and /dev/null differ diff --git a/amarok/images/icons/hi16-action-amarok_cart_add.png b/amarok/images/icons/hi16-action-amarok_cart_add.png deleted file mode 100644 index ddb3561c..00000000 Binary files a/amarok/images/icons/hi16-action-amarok_cart_add.png and /dev/null differ diff --git a/amarok/images/icons/hi16-action-amarok_cart_remove.png b/amarok/images/icons/hi16-action-amarok_cart_remove.png deleted file mode 100644 index bfa5329b..00000000 Binary files a/amarok/images/icons/hi16-action-amarok_cart_remove.png and /dev/null differ diff --git a/amarok/images/icons/hi16-action-amarok_cart_view.png b/amarok/images/icons/hi16-action-amarok_cart_view.png deleted file mode 100644 index 1c922445..00000000 Binary files a/amarok/images/icons/hi16-action-amarok_cart_view.png and /dev/null differ diff --git a/amarok/images/icons/hi16-action-amarok_change_language.png b/amarok/images/icons/hi16-action-amarok_change_language.png deleted file mode 100644 index f8f51d27..00000000 Binary files a/amarok/images/icons/hi16-action-amarok_change_language.png and /dev/null differ diff --git a/amarok/images/icons/hi16-action-amarok_clock.png b/amarok/images/icons/hi16-action-amarok_clock.png deleted file mode 100644 index 49cb80ce..00000000 Binary files a/amarok/images/icons/hi16-action-amarok_clock.png and /dev/null differ diff --git a/amarok/images/icons/hi16-action-amarok_lyrics.png b/amarok/images/icons/hi16-action-amarok_lyrics.png deleted file mode 100644 index d68a48c5..00000000 Binary files a/amarok/images/icons/hi16-action-amarok_lyrics.png and /dev/null differ diff --git a/amarok/images/icons/hi16-action-amarok_playcount.png b/amarok/images/icons/hi16-action-amarok_playcount.png deleted file mode 100644 index a69f2e9b..00000000 Binary files a/amarok/images/icons/hi16-action-amarok_playcount.png and /dev/null differ diff --git a/amarok/images/icons/hi16-action-amarok_playlist.png b/amarok/images/icons/hi16-action-amarok_playlist.png deleted file mode 100644 index 10dfc793..00000000 Binary files a/amarok/images/icons/hi16-action-amarok_playlist.png and /dev/null differ diff --git a/amarok/images/icons/hi16-action-amarok_playlist_refresh.png b/amarok/images/icons/hi16-action-amarok_playlist_refresh.png deleted file mode 100644 index f7cffc83..00000000 Binary files a/amarok/images/icons/hi16-action-amarok_playlist_refresh.png and /dev/null differ diff --git a/amarok/images/icons/hi16-action-amarok_scripts.png b/amarok/images/icons/hi16-action-amarok_scripts.png deleted file mode 100644 index ed62d4ea..00000000 Binary files a/amarok/images/icons/hi16-action-amarok_scripts.png and /dev/null differ diff --git a/amarok/images/icons/hi16-action-amarok_track.png b/amarok/images/icons/hi16-action-amarok_track.png deleted file mode 100644 index c2f2cf4d..00000000 Binary files a/amarok/images/icons/hi16-action-amarok_track.png and /dev/null differ diff --git a/amarok/images/icons/hi16-action-collection-rescan-amarok.png b/amarok/images/icons/hi16-action-collection-rescan-amarok.png deleted file mode 100644 index fa2d9e9a..00000000 Binary files a/amarok/images/icons/hi16-action-collection-rescan-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi16-action-download-amarok.png b/amarok/images/icons/hi16-action-download-amarok.png deleted file mode 100644 index daed6dd7..00000000 Binary files a/amarok/images/icons/hi16-action-download-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi16-action-dynamic-amarok.png b/amarok/images/icons/hi16-action-dynamic-amarok.png deleted file mode 100644 index 5a30750b..00000000 Binary files a/amarok/images/icons/hi16-action-dynamic-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi16-action-favorite-genres-amarok.png b/amarok/images/icons/hi16-action-favorite-genres-amarok.png deleted file mode 100644 index b4bdd8f3..00000000 Binary files a/amarok/images/icons/hi16-action-favorite-genres-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi16-action-filename-album-amarok.png b/amarok/images/icons/hi16-action-filename-album-amarok.png deleted file mode 100644 index 6e7328e6..00000000 Binary files a/amarok/images/icons/hi16-action-filename-album-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi16-action-filename-artist-amarok.png b/amarok/images/icons/hi16-action-filename-artist-amarok.png deleted file mode 100644 index aea841bd..00000000 Binary files a/amarok/images/icons/hi16-action-filename-artist-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi16-action-filename-bpm-amarok.png b/amarok/images/icons/hi16-action-filename-bpm-amarok.png deleted file mode 100644 index 2a123c50..00000000 Binary files a/amarok/images/icons/hi16-action-filename-bpm-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi16-action-filename-comment-amarok.png b/amarok/images/icons/hi16-action-filename-comment-amarok.png deleted file mode 100644 index 4ca8780f..00000000 Binary files a/amarok/images/icons/hi16-action-filename-comment-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi16-action-filename-composer-amarok.png b/amarok/images/icons/hi16-action-filename-composer-amarok.png deleted file mode 100644 index c037dc57..00000000 Binary files a/amarok/images/icons/hi16-action-filename-composer-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi16-action-filename-dash-amarok.png b/amarok/images/icons/hi16-action-filename-dash-amarok.png deleted file mode 100644 index baf6806f..00000000 Binary files a/amarok/images/icons/hi16-action-filename-dash-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi16-action-filename-discnumber-amarok.png b/amarok/images/icons/hi16-action-filename-discnumber-amarok.png deleted file mode 100644 index 5aec94ea..00000000 Binary files a/amarok/images/icons/hi16-action-filename-discnumber-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi16-action-filename-dot-amarok.png b/amarok/images/icons/hi16-action-filename-dot-amarok.png deleted file mode 100644 index 0506e986..00000000 Binary files a/amarok/images/icons/hi16-action-filename-dot-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi16-action-filename-filetype-amarok.png b/amarok/images/icons/hi16-action-filename-filetype-amarok.png deleted file mode 100644 index 5f72431c..00000000 Binary files a/amarok/images/icons/hi16-action-filename-filetype-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi16-action-filename-genre-amarok.png b/amarok/images/icons/hi16-action-filename-genre-amarok.png deleted file mode 100644 index 16ab28e5..00000000 Binary files a/amarok/images/icons/hi16-action-filename-genre-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi16-action-filename-ignore-amarok.png b/amarok/images/icons/hi16-action-filename-ignore-amarok.png deleted file mode 100644 index 16fefb08..00000000 Binary files a/amarok/images/icons/hi16-action-filename-ignore-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi16-action-filename-initial-amarok.png b/amarok/images/icons/hi16-action-filename-initial-amarok.png deleted file mode 100644 index 4b333e3d..00000000 Binary files a/amarok/images/icons/hi16-action-filename-initial-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi16-action-filename-last-played.png b/amarok/images/icons/hi16-action-filename-last-played.png deleted file mode 100644 index 6083b7c1..00000000 Binary files a/amarok/images/icons/hi16-action-filename-last-played.png and /dev/null differ diff --git a/amarok/images/icons/hi16-action-filename-slash-amarok.png b/amarok/images/icons/hi16-action-filename-slash-amarok.png deleted file mode 100644 index 83442118..00000000 Binary files a/amarok/images/icons/hi16-action-filename-slash-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi16-action-filename-space-amarok.png b/amarok/images/icons/hi16-action-filename-space-amarok.png deleted file mode 100644 index 2e675991..00000000 Binary files a/amarok/images/icons/hi16-action-filename-space-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi16-action-filename-title-amarok.png b/amarok/images/icons/hi16-action-filename-title-amarok.png deleted file mode 100644 index c1205718..00000000 Binary files a/amarok/images/icons/hi16-action-filename-title-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi16-action-filename-track-amarok.png b/amarok/images/icons/hi16-action-filename-track-amarok.png deleted file mode 100644 index 6f1f4575..00000000 Binary files a/amarok/images/icons/hi16-action-filename-track-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi16-action-filename-underscore-amarok.png b/amarok/images/icons/hi16-action-filename-underscore-amarok.png deleted file mode 100644 index e55c1f84..00000000 Binary files a/amarok/images/icons/hi16-action-filename-underscore-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi16-action-filename-year-amarok.png b/amarok/images/icons/hi16-action-filename-year-amarok.png deleted file mode 100644 index 6f973f6a..00000000 Binary files a/amarok/images/icons/hi16-action-filename-year-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi16-action-label-amarok.png b/amarok/images/icons/hi16-action-label-amarok.png deleted file mode 100644 index 4739a477..00000000 Binary files a/amarok/images/icons/hi16-action-label-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi16-action-lastfm-mix-radio-amarok.png b/amarok/images/icons/hi16-action-lastfm-mix-radio-amarok.png deleted file mode 100644 index f37abfd3..00000000 Binary files a/amarok/images/icons/hi16-action-lastfm-mix-radio-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi16-action-lastfm-neighbour-radio-amarok.png b/amarok/images/icons/hi16-action-lastfm-neighbour-radio-amarok.png deleted file mode 100644 index f2ee386a..00000000 Binary files a/amarok/images/icons/hi16-action-lastfm-neighbour-radio-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi16-action-lastfm-personal-radio-amarok.png b/amarok/images/icons/hi16-action-lastfm-personal-radio-amarok.png deleted file mode 100644 index 490bef1f..00000000 Binary files a/amarok/images/icons/hi16-action-lastfm-personal-radio-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi16-action-lastfm-recommended-radio-amarok.png b/amarok/images/icons/hi16-action-lastfm-recommended-radio-amarok.png deleted file mode 100644 index d45d9ab7..00000000 Binary files a/amarok/images/icons/hi16-action-lastfm-recommended-radio-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi16-action-lastfm-tag-amarok.png b/amarok/images/icons/hi16-action-lastfm-tag-amarok.png deleted file mode 100644 index a6e9a357..00000000 Binary files a/amarok/images/icons/hi16-action-lastfm-tag-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi16-action-love-amarok.png b/amarok/images/icons/hi16-action-love-amarok.png deleted file mode 100644 index ba2bc228..00000000 Binary files a/amarok/images/icons/hi16-action-love-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi16-action-media-album-cover-manager-amarok.png b/amarok/images/icons/hi16-action-media-album-cover-manager-amarok.png deleted file mode 100644 index a92d1132..00000000 Binary files a/amarok/images/icons/hi16-action-media-album-cover-manager-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi16-action-media-album-repeat-amarok.png b/amarok/images/icons/hi16-action-media-album-repeat-amarok.png deleted file mode 100644 index bbc954b2..00000000 Binary files a/amarok/images/icons/hi16-action-media-album-repeat-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi16-action-media-playlist-repeat-amarok.png b/amarok/images/icons/hi16-action-media-playlist-repeat-amarok.png deleted file mode 100644 index 5b36419d..00000000 Binary files a/amarok/images/icons/hi16-action-media-playlist-repeat-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi16-action-media-random-albums-amarok.png b/amarok/images/icons/hi16-action-media-random-albums-amarok.png deleted file mode 100644 index d3fe3367..00000000 Binary files a/amarok/images/icons/hi16-action-media-random-albums-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi16-action-media-random-tracks-amarok.png b/amarok/images/icons/hi16-action-media-random-tracks-amarok.png deleted file mode 100644 index 15e0801a..00000000 Binary files a/amarok/images/icons/hi16-action-media-random-tracks-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi16-action-media-repeat-album-amarok.png b/amarok/images/icons/hi16-action-media-repeat-album-amarok.png deleted file mode 100644 index d42c5ff9..00000000 Binary files a/amarok/images/icons/hi16-action-media-repeat-album-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi16-action-media-repeat-playlist-amarok.png b/amarok/images/icons/hi16-action-media-repeat-playlist-amarok.png deleted file mode 100644 index e5dab1ec..00000000 Binary files a/amarok/images/icons/hi16-action-media-repeat-playlist-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi16-action-media-repeat-track-amarok.png b/amarok/images/icons/hi16-action-media-repeat-track-amarok.png deleted file mode 100644 index 4d05e521..00000000 Binary files a/amarok/images/icons/hi16-action-media-repeat-track-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi16-action-media-show-active-track-amarok.png b/amarok/images/icons/hi16-action-media-show-active-track-amarok.png deleted file mode 100644 index d450b809..00000000 Binary files a/amarok/images/icons/hi16-action-media-show-active-track-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi16-action-media-standard-track-progression-amarok.png b/amarok/images/icons/hi16-action-media-standard-track-progression-amarok.png deleted file mode 100644 index 18e552f3..00000000 Binary files a/amarok/images/icons/hi16-action-media-standard-track-progression-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi16-action-media-track-add-amarok.png b/amarok/images/icons/hi16-action-media-track-add-amarok.png deleted file mode 100644 index 86f40741..00000000 Binary files a/amarok/images/icons/hi16-action-media-track-add-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi16-action-media-track-edit-amarok.png b/amarok/images/icons/hi16-action-media-track-edit-amarok.png deleted file mode 100644 index eb7ea0ef..00000000 Binary files a/amarok/images/icons/hi16-action-media-track-edit-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi16-action-media-track-queue-amarok.png b/amarok/images/icons/hi16-action-media-track-queue-amarok.png deleted file mode 100644 index c0b4a45d..00000000 Binary files a/amarok/images/icons/hi16-action-media-track-queue-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi16-action-media-track-remove-amarok.png b/amarok/images/icons/hi16-action-media-track-remove-amarok.png deleted file mode 100644 index aca7bf2d..00000000 Binary files a/amarok/images/icons/hi16-action-media-track-remove-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi16-action-music-amarok.png b/amarok/images/icons/hi16-action-music-amarok.png deleted file mode 100644 index 0d62a09b..00000000 Binary files a/amarok/images/icons/hi16-action-music-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi16-action-playlist-generator.png b/amarok/images/icons/hi16-action-playlist-generator.png deleted file mode 100644 index e50fbcb5..00000000 Binary files a/amarok/images/icons/hi16-action-playlist-generator.png and /dev/null differ diff --git a/amarok/images/icons/hi16-action-podcast-amarok.png b/amarok/images/icons/hi16-action-podcast-amarok.png deleted file mode 100644 index 0803e937..00000000 Binary files a/amarok/images/icons/hi16-action-podcast-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi16-action-preferences-indicator-amarok.png b/amarok/images/icons/hi16-action-preferences-indicator-amarok.png deleted file mode 100644 index 014ea7b5..00000000 Binary files a/amarok/images/icons/hi16-action-preferences-indicator-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi16-action-preferences-media-playback-amarok.png b/amarok/images/icons/hi16-action-preferences-media-playback-amarok.png deleted file mode 100644 index b433895b..00000000 Binary files a/amarok/images/icons/hi16-action-preferences-media-playback-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi16-action-preferences-multimedia-player-amarok.png b/amarok/images/icons/hi16-action-preferences-multimedia-player-amarok.png deleted file mode 100644 index a19de8de..00000000 Binary files a/amarok/images/icons/hi16-action-preferences-multimedia-player-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi16-action-preferences-view-amarok.png b/amarok/images/icons/hi16-action-preferences-view-amarok.png deleted file mode 100644 index c5b874bf..00000000 Binary files a/amarok/images/icons/hi16-action-preferences-view-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi16-action-remove-amarok.png b/amarok/images/icons/hi16-action-remove-amarok.png deleted file mode 100644 index ce5c0054..00000000 Binary files a/amarok/images/icons/hi16-action-remove-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi16-action-view-importers-banshee-amarok.png b/amarok/images/icons/hi16-action-view-importers-banshee-amarok.png deleted file mode 100644 index 2d1e9875..00000000 Binary files a/amarok/images/icons/hi16-action-view-importers-banshee-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi16-action-view-importers-clementine-amarok.png b/amarok/images/icons/hi16-action-view-importers-clementine-amarok.png deleted file mode 100644 index cb66ad7f..00000000 Binary files a/amarok/images/icons/hi16-action-view-importers-clementine-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi16-action-view-importers-rhythmbox-amarok.png b/amarok/images/icons/hi16-action-view-importers-rhythmbox-amarok.png deleted file mode 100644 index 26bfc6f9..00000000 Binary files a/amarok/images/icons/hi16-action-view-importers-rhythmbox-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi16-action-view-services-amazon-amarok.png b/amarok/images/icons/hi16-action-view-services-amazon-amarok.png deleted file mode 100644 index 4cff09f7..00000000 Binary files a/amarok/images/icons/hi16-action-view-services-amazon-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi16-action-view-services-ampache-amarok.png b/amarok/images/icons/hi16-action-view-services-ampache-amarok.png deleted file mode 100644 index 27d93c29..00000000 Binary files a/amarok/images/icons/hi16-action-view-services-ampache-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi16-action-view-services-gpodder-amarok.png b/amarok/images/icons/hi16-action-view-services-gpodder-amarok.png deleted file mode 100644 index 0e267c01..00000000 Binary files a/amarok/images/icons/hi16-action-view-services-gpodder-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi16-action-view-services-jamendo-amarok.png b/amarok/images/icons/hi16-action-view-services-jamendo-amarok.png deleted file mode 100644 index 69cf21a7..00000000 Binary files a/amarok/images/icons/hi16-action-view-services-jamendo-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi16-action-view-services-lastfm-amarok.png b/amarok/images/icons/hi16-action-view-services-lastfm-amarok.png deleted file mode 100644 index fa11493c..00000000 Binary files a/amarok/images/icons/hi16-action-view-services-lastfm-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi16-action-view-services-librivox-amarok.png b/amarok/images/icons/hi16-action-view-services-librivox-amarok.png deleted file mode 100644 index 8b98ad22..00000000 Binary files a/amarok/images/icons/hi16-action-view-services-librivox-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi16-action-view-services-magnatune-amarok.png b/amarok/images/icons/hi16-action-view-services-magnatune-amarok.png deleted file mode 100644 index 94ed9ff0..00000000 Binary files a/amarok/images/icons/hi16-action-view-services-magnatune-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi16-action-view-services-mp3tunes-amarok.png b/amarok/images/icons/hi16-action-view-services-mp3tunes-amarok.png deleted file mode 100644 index 538ff46c..00000000 Binary files a/amarok/images/icons/hi16-action-view-services-mp3tunes-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi16-action-view-services-opml-amarok.png b/amarok/images/icons/hi16-action-view-services-opml-amarok.png deleted file mode 100644 index 655a4b8c..00000000 Binary files a/amarok/images/icons/hi16-action-view-services-opml-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi16-action-view-services-scripted-amarok.png b/amarok/images/icons/hi16-action-view-services-scripted-amarok.png deleted file mode 100644 index 08273002..00000000 Binary files a/amarok/images/icons/hi16-action-view-services-scripted-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi22-action-amarok_artist.png b/amarok/images/icons/hi22-action-amarok_artist.png deleted file mode 100644 index 8a4d8ab8..00000000 Binary files a/amarok/images/icons/hi22-action-amarok_artist.png and /dev/null differ diff --git a/amarok/images/icons/hi22-action-amarok_cart_add.png b/amarok/images/icons/hi22-action-amarok_cart_add.png deleted file mode 100644 index e17d7112..00000000 Binary files a/amarok/images/icons/hi22-action-amarok_cart_add.png and /dev/null differ diff --git a/amarok/images/icons/hi22-action-amarok_cart_remove.png b/amarok/images/icons/hi22-action-amarok_cart_remove.png deleted file mode 100644 index 50438252..00000000 Binary files a/amarok/images/icons/hi22-action-amarok_cart_remove.png and /dev/null differ diff --git a/amarok/images/icons/hi22-action-amarok_cart_view.png b/amarok/images/icons/hi22-action-amarok_cart_view.png deleted file mode 100644 index f8668b3c..00000000 Binary files a/amarok/images/icons/hi22-action-amarok_cart_view.png and /dev/null differ diff --git a/amarok/images/icons/hi22-action-amarok_change_language.png b/amarok/images/icons/hi22-action-amarok_change_language.png deleted file mode 100644 index 86bfb781..00000000 Binary files a/amarok/images/icons/hi22-action-amarok_change_language.png and /dev/null differ diff --git a/amarok/images/icons/hi22-action-amarok_clock.png b/amarok/images/icons/hi22-action-amarok_clock.png deleted file mode 100644 index daa5a561..00000000 Binary files a/amarok/images/icons/hi22-action-amarok_clock.png and /dev/null differ diff --git a/amarok/images/icons/hi22-action-amarok_lyrics.png b/amarok/images/icons/hi22-action-amarok_lyrics.png deleted file mode 100644 index c0bca6ec..00000000 Binary files a/amarok/images/icons/hi22-action-amarok_lyrics.png and /dev/null differ diff --git a/amarok/images/icons/hi22-action-amarok_playcount.png b/amarok/images/icons/hi22-action-amarok_playcount.png deleted file mode 100644 index c68c0ff7..00000000 Binary files a/amarok/images/icons/hi22-action-amarok_playcount.png and /dev/null differ diff --git a/amarok/images/icons/hi22-action-amarok_playlist.png b/amarok/images/icons/hi22-action-amarok_playlist.png deleted file mode 100644 index cab619c9..00000000 Binary files a/amarok/images/icons/hi22-action-amarok_playlist.png and /dev/null differ diff --git a/amarok/images/icons/hi22-action-amarok_playlist_refresh.png b/amarok/images/icons/hi22-action-amarok_playlist_refresh.png deleted file mode 100644 index e463bcaf..00000000 Binary files a/amarok/images/icons/hi22-action-amarok_playlist_refresh.png and /dev/null differ diff --git a/amarok/images/icons/hi22-action-amarok_scripts.png b/amarok/images/icons/hi22-action-amarok_scripts.png deleted file mode 100644 index f72bab5b..00000000 Binary files a/amarok/images/icons/hi22-action-amarok_scripts.png and /dev/null differ diff --git a/amarok/images/icons/hi22-action-amarok_track.png b/amarok/images/icons/hi22-action-amarok_track.png deleted file mode 100644 index b9092f41..00000000 Binary files a/amarok/images/icons/hi22-action-amarok_track.png and /dev/null differ diff --git a/amarok/images/icons/hi22-action-collection-rescan-amarok.png b/amarok/images/icons/hi22-action-collection-rescan-amarok.png deleted file mode 100644 index 68b08573..00000000 Binary files a/amarok/images/icons/hi22-action-collection-rescan-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi22-action-download-amarok.png b/amarok/images/icons/hi22-action-download-amarok.png deleted file mode 100644 index 339e2f61..00000000 Binary files a/amarok/images/icons/hi22-action-download-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi22-action-dynamic-amarok.png b/amarok/images/icons/hi22-action-dynamic-amarok.png deleted file mode 100644 index 5dd7f6e0..00000000 Binary files a/amarok/images/icons/hi22-action-dynamic-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi22-action-filename-bpm-amarok.png b/amarok/images/icons/hi22-action-filename-bpm-amarok.png deleted file mode 100644 index 229667df..00000000 Binary files a/amarok/images/icons/hi22-action-filename-bpm-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi22-action-internet-amarok.png b/amarok/images/icons/hi22-action-internet-amarok.png deleted file mode 100644 index 660c85cb..00000000 Binary files a/amarok/images/icons/hi22-action-internet-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi22-action-love-amarok.png b/amarok/images/icons/hi22-action-love-amarok.png deleted file mode 100644 index ffe34367..00000000 Binary files a/amarok/images/icons/hi22-action-love-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi22-action-media-album-cover-manager-amarok.png b/amarok/images/icons/hi22-action-media-album-cover-manager-amarok.png deleted file mode 100644 index d7f15ce8..00000000 Binary files a/amarok/images/icons/hi22-action-media-album-cover-manager-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi22-action-media-album-repeat-amarok.png b/amarok/images/icons/hi22-action-media-album-repeat-amarok.png deleted file mode 100644 index 30739f3c..00000000 Binary files a/amarok/images/icons/hi22-action-media-album-repeat-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi22-action-media-playlist-repeat-amarok.png b/amarok/images/icons/hi22-action-media-playlist-repeat-amarok.png deleted file mode 100644 index 60fc9fd2..00000000 Binary files a/amarok/images/icons/hi22-action-media-playlist-repeat-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi22-action-media-random-albums-amarok.png b/amarok/images/icons/hi22-action-media-random-albums-amarok.png deleted file mode 100644 index 716475c4..00000000 Binary files a/amarok/images/icons/hi22-action-media-random-albums-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi22-action-media-random-tracks-amarok.png b/amarok/images/icons/hi22-action-media-random-tracks-amarok.png deleted file mode 100644 index bc0f859e..00000000 Binary files a/amarok/images/icons/hi22-action-media-random-tracks-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi22-action-media-repeat-album-amarok.png b/amarok/images/icons/hi22-action-media-repeat-album-amarok.png deleted file mode 100644 index 8be5664c..00000000 Binary files a/amarok/images/icons/hi22-action-media-repeat-album-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi22-action-media-repeat-playlist-amarok.png b/amarok/images/icons/hi22-action-media-repeat-playlist-amarok.png deleted file mode 100644 index 23cf282a..00000000 Binary files a/amarok/images/icons/hi22-action-media-repeat-playlist-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi22-action-media-repeat-track-amarok.png b/amarok/images/icons/hi22-action-media-repeat-track-amarok.png deleted file mode 100644 index fcafcd93..00000000 Binary files a/amarok/images/icons/hi22-action-media-repeat-track-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi22-action-media-show-active-track-amarok.png b/amarok/images/icons/hi22-action-media-show-active-track-amarok.png deleted file mode 100644 index 9fc25626..00000000 Binary files a/amarok/images/icons/hi22-action-media-show-active-track-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi22-action-media-standard-track-progression-amarok.png b/amarok/images/icons/hi22-action-media-standard-track-progression-amarok.png deleted file mode 100644 index 2d980276..00000000 Binary files a/amarok/images/icons/hi22-action-media-standard-track-progression-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi22-action-media-track-add-amarok.png b/amarok/images/icons/hi22-action-media-track-add-amarok.png deleted file mode 100644 index ab7aed51..00000000 Binary files a/amarok/images/icons/hi22-action-media-track-add-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi22-action-media-track-edit-amarok.png b/amarok/images/icons/hi22-action-media-track-edit-amarok.png deleted file mode 100644 index d6e6f600..00000000 Binary files a/amarok/images/icons/hi22-action-media-track-edit-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi22-action-media-track-queue-amarok.png b/amarok/images/icons/hi22-action-media-track-queue-amarok.png deleted file mode 100644 index 30e878d1..00000000 Binary files a/amarok/images/icons/hi22-action-media-track-queue-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi22-action-media-track-remove-amarok.png b/amarok/images/icons/hi22-action-media-track-remove-amarok.png deleted file mode 100644 index 7960148f..00000000 Binary files a/amarok/images/icons/hi22-action-media-track-remove-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi22-action-music-amarok.png b/amarok/images/icons/hi22-action-music-amarok.png deleted file mode 100644 index 49f5fca9..00000000 Binary files a/amarok/images/icons/hi22-action-music-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi22-action-playlist-generator.png b/amarok/images/icons/hi22-action-playlist-generator.png deleted file mode 100644 index 3fe1dffd..00000000 Binary files a/amarok/images/icons/hi22-action-playlist-generator.png and /dev/null differ diff --git a/amarok/images/icons/hi22-action-podcast-amarok.png b/amarok/images/icons/hi22-action-podcast-amarok.png deleted file mode 100644 index 9e5eeda4..00000000 Binary files a/amarok/images/icons/hi22-action-podcast-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi22-action-preferences-indicator-amarok.png b/amarok/images/icons/hi22-action-preferences-indicator-amarok.png deleted file mode 100644 index feb3e8ef..00000000 Binary files a/amarok/images/icons/hi22-action-preferences-indicator-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi22-action-preferences-media-playback-amarok.png b/amarok/images/icons/hi22-action-preferences-media-playback-amarok.png deleted file mode 100644 index 551d8558..00000000 Binary files a/amarok/images/icons/hi22-action-preferences-media-playback-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi22-action-preferences-multimedia-player-amarok.png b/amarok/images/icons/hi22-action-preferences-multimedia-player-amarok.png deleted file mode 100644 index 5271f37a..00000000 Binary files a/amarok/images/icons/hi22-action-preferences-multimedia-player-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi22-action-preferences-view-amarok.png b/amarok/images/icons/hi22-action-preferences-view-amarok.png deleted file mode 100644 index 419bd3e9..00000000 Binary files a/amarok/images/icons/hi22-action-preferences-view-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi22-action-remove-amarok.png b/amarok/images/icons/hi22-action-remove-amarok.png deleted file mode 100644 index 69b8abe2..00000000 Binary files a/amarok/images/icons/hi22-action-remove-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi22-action-view-importers-banshee-amarok.png b/amarok/images/icons/hi22-action-view-importers-banshee-amarok.png deleted file mode 100644 index f990a01a..00000000 Binary files a/amarok/images/icons/hi22-action-view-importers-banshee-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi22-action-view-importers-clementine-amarok.png b/amarok/images/icons/hi22-action-view-importers-clementine-amarok.png deleted file mode 100644 index fcc36111..00000000 Binary files a/amarok/images/icons/hi22-action-view-importers-clementine-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi22-action-view-importers-rhythmbox-amarok.png b/amarok/images/icons/hi22-action-view-importers-rhythmbox-amarok.png deleted file mode 100644 index 4f4a0c4c..00000000 Binary files a/amarok/images/icons/hi22-action-view-importers-rhythmbox-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi22-action-view-services-amazon-amarok.png b/amarok/images/icons/hi22-action-view-services-amazon-amarok.png deleted file mode 100644 index ca403b5d..00000000 Binary files a/amarok/images/icons/hi22-action-view-services-amazon-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi22-action-view-services-gpodder-amarok.png b/amarok/images/icons/hi22-action-view-services-gpodder-amarok.png deleted file mode 100644 index d6af1a9d..00000000 Binary files a/amarok/images/icons/hi22-action-view-services-gpodder-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi22-action-view-services-jamendo-amarok.png b/amarok/images/icons/hi22-action-view-services-jamendo-amarok.png deleted file mode 100644 index 759d7291..00000000 Binary files a/amarok/images/icons/hi22-action-view-services-jamendo-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi22-action-view-services-lastfm-amarok.png b/amarok/images/icons/hi22-action-view-services-lastfm-amarok.png deleted file mode 100644 index 1895f8b9..00000000 Binary files a/amarok/images/icons/hi22-action-view-services-lastfm-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi22-action-view-services-librivox-amarok.png b/amarok/images/icons/hi22-action-view-services-librivox-amarok.png deleted file mode 100644 index bddeec29..00000000 Binary files a/amarok/images/icons/hi22-action-view-services-librivox-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi22-action-view-services-magnatune-amarok.png b/amarok/images/icons/hi22-action-view-services-magnatune-amarok.png deleted file mode 100644 index 77bde1db..00000000 Binary files a/amarok/images/icons/hi22-action-view-services-magnatune-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi22-action-view-services-mp3tunes-amarok.png b/amarok/images/icons/hi22-action-view-services-mp3tunes-amarok.png deleted file mode 100644 index f5f9c9ca..00000000 Binary files a/amarok/images/icons/hi22-action-view-services-mp3tunes-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi22-action-view-services-opml-amarok.png b/amarok/images/icons/hi22-action-view-services-opml-amarok.png deleted file mode 100644 index 6bdba3eb..00000000 Binary files a/amarok/images/icons/hi22-action-view-services-opml-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi22-action-view-services-scripted-amarok.png b/amarok/images/icons/hi22-action-view-services-scripted-amarok.png deleted file mode 100644 index 7644b728..00000000 Binary files a/amarok/images/icons/hi22-action-view-services-scripted-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi24-action-lastfm-my-friends-amarok.png b/amarok/images/icons/hi24-action-lastfm-my-friends-amarok.png deleted file mode 100644 index a2858868..00000000 Binary files a/amarok/images/icons/hi24-action-lastfm-my-friends-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi24-action-lastfm-my-neighbours-amarok.png b/amarok/images/icons/hi24-action-lastfm-my-neighbours-amarok.png deleted file mode 100644 index bb19252b..00000000 Binary files a/amarok/images/icons/hi24-action-lastfm-my-neighbours-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi24-action-lastfm-my-tags-amarok.png b/amarok/images/icons/hi24-action-lastfm-my-tags-amarok.png deleted file mode 100644 index 6f61d7c7..00000000 Binary files a/amarok/images/icons/hi24-action-lastfm-my-tags-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi32-action-amarok_artist.png b/amarok/images/icons/hi32-action-amarok_artist.png deleted file mode 100644 index 6b175302..00000000 Binary files a/amarok/images/icons/hi32-action-amarok_artist.png and /dev/null differ diff --git a/amarok/images/icons/hi32-action-amarok_cart_add.png b/amarok/images/icons/hi32-action-amarok_cart_add.png deleted file mode 100644 index bf0e082b..00000000 Binary files a/amarok/images/icons/hi32-action-amarok_cart_add.png and /dev/null differ diff --git a/amarok/images/icons/hi32-action-amarok_cart_remove.png b/amarok/images/icons/hi32-action-amarok_cart_remove.png deleted file mode 100644 index 3cf72c8e..00000000 Binary files a/amarok/images/icons/hi32-action-amarok_cart_remove.png and /dev/null differ diff --git a/amarok/images/icons/hi32-action-amarok_cart_view.png b/amarok/images/icons/hi32-action-amarok_cart_view.png deleted file mode 100644 index fefb6ac5..00000000 Binary files a/amarok/images/icons/hi32-action-amarok_cart_view.png and /dev/null differ diff --git a/amarok/images/icons/hi32-action-amarok_change_language.png b/amarok/images/icons/hi32-action-amarok_change_language.png deleted file mode 100644 index 45685ca5..00000000 Binary files a/amarok/images/icons/hi32-action-amarok_change_language.png and /dev/null differ diff --git a/amarok/images/icons/hi32-action-amarok_clock.png b/amarok/images/icons/hi32-action-amarok_clock.png deleted file mode 100644 index 639fbe70..00000000 Binary files a/amarok/images/icons/hi32-action-amarok_clock.png and /dev/null differ diff --git a/amarok/images/icons/hi32-action-amarok_lyrics.png b/amarok/images/icons/hi32-action-amarok_lyrics.png deleted file mode 100644 index 7314ccbf..00000000 Binary files a/amarok/images/icons/hi32-action-amarok_lyrics.png and /dev/null differ diff --git a/amarok/images/icons/hi32-action-amarok_playcount.png b/amarok/images/icons/hi32-action-amarok_playcount.png deleted file mode 100644 index 796e8842..00000000 Binary files a/amarok/images/icons/hi32-action-amarok_playcount.png and /dev/null differ diff --git a/amarok/images/icons/hi32-action-amarok_playlist.png b/amarok/images/icons/hi32-action-amarok_playlist.png deleted file mode 100644 index d80493d6..00000000 Binary files a/amarok/images/icons/hi32-action-amarok_playlist.png and /dev/null differ diff --git a/amarok/images/icons/hi32-action-amarok_playlist_refresh.png b/amarok/images/icons/hi32-action-amarok_playlist_refresh.png deleted file mode 100644 index 9ddaa340..00000000 Binary files a/amarok/images/icons/hi32-action-amarok_playlist_refresh.png and /dev/null differ diff --git a/amarok/images/icons/hi32-action-amarok_scripts.png b/amarok/images/icons/hi32-action-amarok_scripts.png deleted file mode 100644 index 3bb0ffa6..00000000 Binary files a/amarok/images/icons/hi32-action-amarok_scripts.png and /dev/null differ diff --git a/amarok/images/icons/hi32-action-amarok_track.png b/amarok/images/icons/hi32-action-amarok_track.png deleted file mode 100644 index f9e6cbb0..00000000 Binary files a/amarok/images/icons/hi32-action-amarok_track.png and /dev/null differ diff --git a/amarok/images/icons/hi32-action-audioscrobbler.png b/amarok/images/icons/hi32-action-audioscrobbler.png deleted file mode 100644 index ab670242..00000000 Binary files a/amarok/images/icons/hi32-action-audioscrobbler.png and /dev/null differ diff --git a/amarok/images/icons/hi32-action-collection-rescan-amarok.png b/amarok/images/icons/hi32-action-collection-rescan-amarok.png deleted file mode 100644 index a7c9b758..00000000 Binary files a/amarok/images/icons/hi32-action-collection-rescan-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi32-action-download-amarok.png b/amarok/images/icons/hi32-action-download-amarok.png deleted file mode 100644 index 8290733b..00000000 Binary files a/amarok/images/icons/hi32-action-download-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi32-action-dynamic-amarok.png b/amarok/images/icons/hi32-action-dynamic-amarok.png deleted file mode 100644 index 89a89809..00000000 Binary files a/amarok/images/icons/hi32-action-dynamic-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi32-action-filename-bpm-amarok.png b/amarok/images/icons/hi32-action-filename-bpm-amarok.png deleted file mode 100644 index 74589751..00000000 Binary files a/amarok/images/icons/hi32-action-filename-bpm-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi32-action-love-amarok.png b/amarok/images/icons/hi32-action-love-amarok.png deleted file mode 100644 index 32d3349e..00000000 Binary files a/amarok/images/icons/hi32-action-love-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi32-action-media-album-cover-manager-amarok.png b/amarok/images/icons/hi32-action-media-album-cover-manager-amarok.png deleted file mode 100644 index 58ea7d43..00000000 Binary files a/amarok/images/icons/hi32-action-media-album-cover-manager-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi32-action-media-album-cover.png b/amarok/images/icons/hi32-action-media-album-cover.png deleted file mode 100644 index a554f291..00000000 Binary files a/amarok/images/icons/hi32-action-media-album-cover.png and /dev/null differ diff --git a/amarok/images/icons/hi32-action-media-album-repeat-amarok.png b/amarok/images/icons/hi32-action-media-album-repeat-amarok.png deleted file mode 100644 index 4c180660..00000000 Binary files a/amarok/images/icons/hi32-action-media-album-repeat-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi32-action-media-album-track.png b/amarok/images/icons/hi32-action-media-album-track.png deleted file mode 100644 index 5fa7e3b3..00000000 Binary files a/amarok/images/icons/hi32-action-media-album-track.png and /dev/null differ diff --git a/amarok/images/icons/hi32-action-media-playlist-repeat-amarok.png b/amarok/images/icons/hi32-action-media-playlist-repeat-amarok.png deleted file mode 100644 index 200c34d6..00000000 Binary files a/amarok/images/icons/hi32-action-media-playlist-repeat-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi32-action-media-random-albums-amarok.png b/amarok/images/icons/hi32-action-media-random-albums-amarok.png deleted file mode 100644 index 54ee6007..00000000 Binary files a/amarok/images/icons/hi32-action-media-random-albums-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi32-action-media-random-tracks-amarok.png b/amarok/images/icons/hi32-action-media-random-tracks-amarok.png deleted file mode 100644 index d8603c5b..00000000 Binary files a/amarok/images/icons/hi32-action-media-random-tracks-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi32-action-media-repeat-album-amarok.png b/amarok/images/icons/hi32-action-media-repeat-album-amarok.png deleted file mode 100644 index 944adc51..00000000 Binary files a/amarok/images/icons/hi32-action-media-repeat-album-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi32-action-media-repeat-playlist-amarok.png b/amarok/images/icons/hi32-action-media-repeat-playlist-amarok.png deleted file mode 100644 index 803a7240..00000000 Binary files a/amarok/images/icons/hi32-action-media-repeat-playlist-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi32-action-media-repeat-track-amarok.png b/amarok/images/icons/hi32-action-media-repeat-track-amarok.png deleted file mode 100644 index ae4fa129..00000000 Binary files a/amarok/images/icons/hi32-action-media-repeat-track-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi32-action-media-show-active-track-amarok.png b/amarok/images/icons/hi32-action-media-show-active-track-amarok.png deleted file mode 100644 index d3f3f20a..00000000 Binary files a/amarok/images/icons/hi32-action-media-show-active-track-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi32-action-media-standard-track-progression-amarok.png b/amarok/images/icons/hi32-action-media-standard-track-progression-amarok.png deleted file mode 100644 index a067b67e..00000000 Binary files a/amarok/images/icons/hi32-action-media-standard-track-progression-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi32-action-media-track-add-amarok.png b/amarok/images/icons/hi32-action-media-track-add-amarok.png deleted file mode 100644 index 7a583208..00000000 Binary files a/amarok/images/icons/hi32-action-media-track-add-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi32-action-media-track-edit-amarok.png b/amarok/images/icons/hi32-action-media-track-edit-amarok.png deleted file mode 100644 index 672959cd..00000000 Binary files a/amarok/images/icons/hi32-action-media-track-edit-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi32-action-media-track-queue-amarok.png b/amarok/images/icons/hi32-action-media-track-queue-amarok.png deleted file mode 100644 index c6c2613f..00000000 Binary files a/amarok/images/icons/hi32-action-media-track-queue-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi32-action-media-track-remove-amarok.png b/amarok/images/icons/hi32-action-media-track-remove-amarok.png deleted file mode 100644 index 92b40e9d..00000000 Binary files a/amarok/images/icons/hi32-action-media-track-remove-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi32-action-music-amarok.png b/amarok/images/icons/hi32-action-music-amarok.png deleted file mode 100644 index 22198fae..00000000 Binary files a/amarok/images/icons/hi32-action-music-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi32-action-playlist-generator.png b/amarok/images/icons/hi32-action-playlist-generator.png deleted file mode 100644 index 798850f3..00000000 Binary files a/amarok/images/icons/hi32-action-playlist-generator.png and /dev/null differ diff --git a/amarok/images/icons/hi32-action-podcast-amarok.png b/amarok/images/icons/hi32-action-podcast-amarok.png deleted file mode 100644 index 900c5834..00000000 Binary files a/amarok/images/icons/hi32-action-podcast-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi32-action-preferences-indicator-amarok.png b/amarok/images/icons/hi32-action-preferences-indicator-amarok.png deleted file mode 100644 index 892a6f19..00000000 Binary files a/amarok/images/icons/hi32-action-preferences-indicator-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi32-action-preferences-media-playback-amarok.png b/amarok/images/icons/hi32-action-preferences-media-playback-amarok.png deleted file mode 100644 index ea71caab..00000000 Binary files a/amarok/images/icons/hi32-action-preferences-media-playback-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi32-action-preferences-multimedia-player-amarok.png b/amarok/images/icons/hi32-action-preferences-multimedia-player-amarok.png deleted file mode 100644 index c17166a0..00000000 Binary files a/amarok/images/icons/hi32-action-preferences-multimedia-player-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi32-action-preferences-view-amarok.png b/amarok/images/icons/hi32-action-preferences-view-amarok.png deleted file mode 100644 index cc7a000f..00000000 Binary files a/amarok/images/icons/hi32-action-preferences-view-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi32-action-remove-amarok.png b/amarok/images/icons/hi32-action-remove-amarok.png deleted file mode 100644 index 6e9974ce..00000000 Binary files a/amarok/images/icons/hi32-action-remove-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi32-action-view-importers-banshee-amarok.png b/amarok/images/icons/hi32-action-view-importers-banshee-amarok.png deleted file mode 100644 index 9aaba1a0..00000000 Binary files a/amarok/images/icons/hi32-action-view-importers-banshee-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi32-action-view-importers-clementine-amarok.png b/amarok/images/icons/hi32-action-view-importers-clementine-amarok.png deleted file mode 100644 index 099c111b..00000000 Binary files a/amarok/images/icons/hi32-action-view-importers-clementine-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi32-action-view-importers-rhythmbox-amarok.png b/amarok/images/icons/hi32-action-view-importers-rhythmbox-amarok.png deleted file mode 100644 index 237ad8ee..00000000 Binary files a/amarok/images/icons/hi32-action-view-importers-rhythmbox-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi32-action-view-services-amazon-amarok.png b/amarok/images/icons/hi32-action-view-services-amazon-amarok.png deleted file mode 100644 index 9ea8afba..00000000 Binary files a/amarok/images/icons/hi32-action-view-services-amazon-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi32-action-view-services-ampache-amarok.png b/amarok/images/icons/hi32-action-view-services-ampache-amarok.png deleted file mode 100644 index 384cc743..00000000 Binary files a/amarok/images/icons/hi32-action-view-services-ampache-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi32-action-view-services-gpodder-amarok.png b/amarok/images/icons/hi32-action-view-services-gpodder-amarok.png deleted file mode 100644 index f106a93c..00000000 Binary files a/amarok/images/icons/hi32-action-view-services-gpodder-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi32-action-view-services-jamendo-amarok.png b/amarok/images/icons/hi32-action-view-services-jamendo-amarok.png deleted file mode 100644 index ddf22b76..00000000 Binary files a/amarok/images/icons/hi32-action-view-services-jamendo-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi32-action-view-services-lastfm-amarok.png b/amarok/images/icons/hi32-action-view-services-lastfm-amarok.png deleted file mode 100644 index 4f937f84..00000000 Binary files a/amarok/images/icons/hi32-action-view-services-lastfm-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi32-action-view-services-magnatune-amarok.png b/amarok/images/icons/hi32-action-view-services-magnatune-amarok.png deleted file mode 100644 index 9c105ef4..00000000 Binary files a/amarok/images/icons/hi32-action-view-services-magnatune-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi32-action-view-services-mp3tunes-amarok.png b/amarok/images/icons/hi32-action-view-services-mp3tunes-amarok.png deleted file mode 100644 index f4fb0469..00000000 Binary files a/amarok/images/icons/hi32-action-view-services-mp3tunes-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi32-action-view-services-opml-amarok.png b/amarok/images/icons/hi32-action-view-services-opml-amarok.png deleted file mode 100644 index 02abea67..00000000 Binary files a/amarok/images/icons/hi32-action-view-services-opml-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi32-action-view-services-scripted-amarok.png b/amarok/images/icons/hi32-action-view-services-scripted-amarok.png deleted file mode 100644 index e50edd77..00000000 Binary files a/amarok/images/icons/hi32-action-view-services-scripted-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi48-action-amarok_artist.png b/amarok/images/icons/hi48-action-amarok_artist.png deleted file mode 100644 index 38e482b5..00000000 Binary files a/amarok/images/icons/hi48-action-amarok_artist.png and /dev/null differ diff --git a/amarok/images/icons/hi48-action-amarok_cart_add.png b/amarok/images/icons/hi48-action-amarok_cart_add.png deleted file mode 100644 index aa1ca360..00000000 Binary files a/amarok/images/icons/hi48-action-amarok_cart_add.png and /dev/null differ diff --git a/amarok/images/icons/hi48-action-amarok_cart_remove.png b/amarok/images/icons/hi48-action-amarok_cart_remove.png deleted file mode 100644 index 7c3e3002..00000000 Binary files a/amarok/images/icons/hi48-action-amarok_cart_remove.png and /dev/null differ diff --git a/amarok/images/icons/hi48-action-amarok_cart_view.png b/amarok/images/icons/hi48-action-amarok_cart_view.png deleted file mode 100644 index 9d36f6f5..00000000 Binary files a/amarok/images/icons/hi48-action-amarok_cart_view.png and /dev/null differ diff --git a/amarok/images/icons/hi48-action-amarok_change_language.png b/amarok/images/icons/hi48-action-amarok_change_language.png deleted file mode 100644 index feaf7b91..00000000 Binary files a/amarok/images/icons/hi48-action-amarok_change_language.png and /dev/null differ diff --git a/amarok/images/icons/hi48-action-amarok_clock.png b/amarok/images/icons/hi48-action-amarok_clock.png deleted file mode 100644 index a0d461eb..00000000 Binary files a/amarok/images/icons/hi48-action-amarok_clock.png and /dev/null differ diff --git a/amarok/images/icons/hi48-action-amarok_lyrics.png b/amarok/images/icons/hi48-action-amarok_lyrics.png deleted file mode 100644 index 81536795..00000000 Binary files a/amarok/images/icons/hi48-action-amarok_lyrics.png and /dev/null differ diff --git a/amarok/images/icons/hi48-action-amarok_playcount.png b/amarok/images/icons/hi48-action-amarok_playcount.png deleted file mode 100644 index ee013b78..00000000 Binary files a/amarok/images/icons/hi48-action-amarok_playcount.png and /dev/null differ diff --git a/amarok/images/icons/hi48-action-amarok_playlist.png b/amarok/images/icons/hi48-action-amarok_playlist.png deleted file mode 100644 index 3619b952..00000000 Binary files a/amarok/images/icons/hi48-action-amarok_playlist.png and /dev/null differ diff --git a/amarok/images/icons/hi48-action-amarok_playlist_refresh.png b/amarok/images/icons/hi48-action-amarok_playlist_refresh.png deleted file mode 100644 index e1f7f7a4..00000000 Binary files a/amarok/images/icons/hi48-action-amarok_playlist_refresh.png and /dev/null differ diff --git a/amarok/images/icons/hi48-action-amarok_scripts.png b/amarok/images/icons/hi48-action-amarok_scripts.png deleted file mode 100644 index 0b3f3ebb..00000000 Binary files a/amarok/images/icons/hi48-action-amarok_scripts.png and /dev/null differ diff --git a/amarok/images/icons/hi48-action-amarok_track.png b/amarok/images/icons/hi48-action-amarok_track.png deleted file mode 100644 index 8768d79d..00000000 Binary files a/amarok/images/icons/hi48-action-amarok_track.png and /dev/null differ diff --git a/amarok/images/icons/hi48-action-collection-rescan-amarok.png b/amarok/images/icons/hi48-action-collection-rescan-amarok.png deleted file mode 100644 index b4071212..00000000 Binary files a/amarok/images/icons/hi48-action-collection-rescan-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi48-action-current-track-amarok.png b/amarok/images/icons/hi48-action-current-track-amarok.png deleted file mode 100644 index 6483839a..00000000 Binary files a/amarok/images/icons/hi48-action-current-track-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi48-action-download-amarok.png b/amarok/images/icons/hi48-action-download-amarok.png deleted file mode 100644 index 2e1b54de..00000000 Binary files a/amarok/images/icons/hi48-action-download-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi48-action-dynamic-amarok.png b/amarok/images/icons/hi48-action-dynamic-amarok.png deleted file mode 100644 index 0e553040..00000000 Binary files a/amarok/images/icons/hi48-action-dynamic-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi48-action-filename-album-amarok.png b/amarok/images/icons/hi48-action-filename-album-amarok.png deleted file mode 100644 index 411a83af..00000000 Binary files a/amarok/images/icons/hi48-action-filename-album-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi48-action-filename-and-amarok.png b/amarok/images/icons/hi48-action-filename-and-amarok.png deleted file mode 100644 index a8be5904..00000000 Binary files a/amarok/images/icons/hi48-action-filename-and-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi48-action-filename-artist-amarok.png b/amarok/images/icons/hi48-action-filename-artist-amarok.png deleted file mode 100644 index fd5701db..00000000 Binary files a/amarok/images/icons/hi48-action-filename-artist-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi48-action-filename-bpm-amarok.png b/amarok/images/icons/hi48-action-filename-bpm-amarok.png deleted file mode 100644 index 4f7efb8d..00000000 Binary files a/amarok/images/icons/hi48-action-filename-bpm-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi48-action-filename-comment-amarok.png b/amarok/images/icons/hi48-action-filename-comment-amarok.png deleted file mode 100644 index 1ca003ad..00000000 Binary files a/amarok/images/icons/hi48-action-filename-comment-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi48-action-filename-composer-amarok.png b/amarok/images/icons/hi48-action-filename-composer-amarok.png deleted file mode 100644 index 2cd4ba1a..00000000 Binary files a/amarok/images/icons/hi48-action-filename-composer-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi48-action-filename-dash-amarok.png b/amarok/images/icons/hi48-action-filename-dash-amarok.png deleted file mode 100644 index 3d2a55ba..00000000 Binary files a/amarok/images/icons/hi48-action-filename-dash-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi48-action-filename-discnumber-amarok.png b/amarok/images/icons/hi48-action-filename-discnumber-amarok.png deleted file mode 100644 index e22947ed..00000000 Binary files a/amarok/images/icons/hi48-action-filename-discnumber-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi48-action-filename-divider.png b/amarok/images/icons/hi48-action-filename-divider.png deleted file mode 100644 index 65982a17..00000000 Binary files a/amarok/images/icons/hi48-action-filename-divider.png and /dev/null differ diff --git a/amarok/images/icons/hi48-action-filename-dot-amarok.png b/amarok/images/icons/hi48-action-filename-dot-amarok.png deleted file mode 100644 index 8f755295..00000000 Binary files a/amarok/images/icons/hi48-action-filename-dot-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi48-action-filename-filetype-amarok.png b/amarok/images/icons/hi48-action-filename-filetype-amarok.png deleted file mode 100644 index 9e35faa7..00000000 Binary files a/amarok/images/icons/hi48-action-filename-filetype-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi48-action-filename-genre-amarok.png b/amarok/images/icons/hi48-action-filename-genre-amarok.png deleted file mode 100644 index 12df61a7..00000000 Binary files a/amarok/images/icons/hi48-action-filename-genre-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi48-action-filename-group-length.png b/amarok/images/icons/hi48-action-filename-group-length.png deleted file mode 100644 index 79a151f1..00000000 Binary files a/amarok/images/icons/hi48-action-filename-group-length.png and /dev/null differ diff --git a/amarok/images/icons/hi48-action-filename-group-tracks.png b/amarok/images/icons/hi48-action-filename-group-tracks.png deleted file mode 100644 index 721e0289..00000000 Binary files a/amarok/images/icons/hi48-action-filename-group-tracks.png and /dev/null differ diff --git a/amarok/images/icons/hi48-action-filename-ignore-amarok.png b/amarok/images/icons/hi48-action-filename-ignore-amarok.png deleted file mode 100644 index 39287dd8..00000000 Binary files a/amarok/images/icons/hi48-action-filename-ignore-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi48-action-filename-initial-amarok.png b/amarok/images/icons/hi48-action-filename-initial-amarok.png deleted file mode 100644 index 565083f8..00000000 Binary files a/amarok/images/icons/hi48-action-filename-initial-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi48-action-filename-last-played.png b/amarok/images/icons/hi48-action-filename-last-played.png deleted file mode 100644 index e6625b5d..00000000 Binary files a/amarok/images/icons/hi48-action-filename-last-played.png and /dev/null differ diff --git a/amarok/images/icons/hi48-action-filename-moodbar.png b/amarok/images/icons/hi48-action-filename-moodbar.png deleted file mode 100644 index 693f8721..00000000 Binary files a/amarok/images/icons/hi48-action-filename-moodbar.png and /dev/null differ diff --git a/amarok/images/icons/hi48-action-filename-sample-rate.png b/amarok/images/icons/hi48-action-filename-sample-rate.png deleted file mode 100644 index 33c9b867..00000000 Binary files a/amarok/images/icons/hi48-action-filename-sample-rate.png and /dev/null differ diff --git a/amarok/images/icons/hi48-action-filename-slash-amarok.png b/amarok/images/icons/hi48-action-filename-slash-amarok.png deleted file mode 100644 index 071110ce..00000000 Binary files a/amarok/images/icons/hi48-action-filename-slash-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi48-action-filename-space-amarok.png b/amarok/images/icons/hi48-action-filename-space-amarok.png deleted file mode 100644 index 1400dcc4..00000000 Binary files a/amarok/images/icons/hi48-action-filename-space-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi48-action-filename-title-amarok.png b/amarok/images/icons/hi48-action-filename-title-amarok.png deleted file mode 100644 index 07eeddcf..00000000 Binary files a/amarok/images/icons/hi48-action-filename-title-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi48-action-filename-track-amarok.png b/amarok/images/icons/hi48-action-filename-track-amarok.png deleted file mode 100644 index 6b639ba4..00000000 Binary files a/amarok/images/icons/hi48-action-filename-track-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi48-action-filename-underscore-amarok.png b/amarok/images/icons/hi48-action-filename-underscore-amarok.png deleted file mode 100644 index 1113e37c..00000000 Binary files a/amarok/images/icons/hi48-action-filename-underscore-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi48-action-filename-year-amarok.png b/amarok/images/icons/hi48-action-filename-year-amarok.png deleted file mode 100644 index 712cb240..00000000 Binary files a/amarok/images/icons/hi48-action-filename-year-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi48-action-info-amarok.png b/amarok/images/icons/hi48-action-info-amarok.png deleted file mode 100644 index 16dafe09..00000000 Binary files a/amarok/images/icons/hi48-action-info-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi48-action-label-amarok.png b/amarok/images/icons/hi48-action-label-amarok.png deleted file mode 100644 index 2c3bc7c5..00000000 Binary files a/amarok/images/icons/hi48-action-label-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi48-action-love-amarok.png b/amarok/images/icons/hi48-action-love-amarok.png deleted file mode 100644 index ad32aac9..00000000 Binary files a/amarok/images/icons/hi48-action-love-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi48-action-media-album-cover-manager-amarok.png b/amarok/images/icons/hi48-action-media-album-cover-manager-amarok.png deleted file mode 100644 index 411a83af..00000000 Binary files a/amarok/images/icons/hi48-action-media-album-cover-manager-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi48-action-media-album-repeat-amarok.png b/amarok/images/icons/hi48-action-media-album-repeat-amarok.png deleted file mode 100644 index 0471190d..00000000 Binary files a/amarok/images/icons/hi48-action-media-album-repeat-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi48-action-media-playlist-repeat-amarok.png b/amarok/images/icons/hi48-action-media-playlist-repeat-amarok.png deleted file mode 100644 index c6e0225a..00000000 Binary files a/amarok/images/icons/hi48-action-media-playlist-repeat-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi48-action-media-random-albums-amarok.png b/amarok/images/icons/hi48-action-media-random-albums-amarok.png deleted file mode 100644 index ee2250ad..00000000 Binary files a/amarok/images/icons/hi48-action-media-random-albums-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi48-action-media-random-tracks-amarok.png b/amarok/images/icons/hi48-action-media-random-tracks-amarok.png deleted file mode 100644 index 189f5fa7..00000000 Binary files a/amarok/images/icons/hi48-action-media-random-tracks-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi48-action-media-repeat-album-amarok.png b/amarok/images/icons/hi48-action-media-repeat-album-amarok.png deleted file mode 100644 index c3082f7e..00000000 Binary files a/amarok/images/icons/hi48-action-media-repeat-album-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi48-action-media-repeat-playlist-amarok.png b/amarok/images/icons/hi48-action-media-repeat-playlist-amarok.png deleted file mode 100644 index ff3406af..00000000 Binary files a/amarok/images/icons/hi48-action-media-repeat-playlist-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi48-action-media-repeat-track-amarok.png b/amarok/images/icons/hi48-action-media-repeat-track-amarok.png deleted file mode 100644 index 35afb84c..00000000 Binary files a/amarok/images/icons/hi48-action-media-repeat-track-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi48-action-media-show-active-track-amarok.png b/amarok/images/icons/hi48-action-media-show-active-track-amarok.png deleted file mode 100644 index 033e5dbf..00000000 Binary files a/amarok/images/icons/hi48-action-media-show-active-track-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi48-action-media-standard-track-progression-amarok.png b/amarok/images/icons/hi48-action-media-standard-track-progression-amarok.png deleted file mode 100644 index 27ec941e..00000000 Binary files a/amarok/images/icons/hi48-action-media-standard-track-progression-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi48-action-media-track-add-amarok.png b/amarok/images/icons/hi48-action-media-track-add-amarok.png deleted file mode 100644 index 871d6f91..00000000 Binary files a/amarok/images/icons/hi48-action-media-track-add-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi48-action-media-track-edit-amarok.png b/amarok/images/icons/hi48-action-media-track-edit-amarok.png deleted file mode 100644 index f837fbbd..00000000 Binary files a/amarok/images/icons/hi48-action-media-track-edit-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi48-action-media-track-queue-amarok.png b/amarok/images/icons/hi48-action-media-track-queue-amarok.png deleted file mode 100644 index fb974f9e..00000000 Binary files a/amarok/images/icons/hi48-action-media-track-queue-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi48-action-media-track-remove-amarok.png b/amarok/images/icons/hi48-action-media-track-remove-amarok.png deleted file mode 100644 index 34337f19..00000000 Binary files a/amarok/images/icons/hi48-action-media-track-remove-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi48-action-music-amarok.png b/amarok/images/icons/hi48-action-music-amarok.png deleted file mode 100644 index 7dca557f..00000000 Binary files a/amarok/images/icons/hi48-action-music-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi48-action-photos-amarok.png b/amarok/images/icons/hi48-action-photos-amarok.png deleted file mode 100644 index 0f54c8e1..00000000 Binary files a/amarok/images/icons/hi48-action-photos-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi48-action-playlist-generator.png b/amarok/images/icons/hi48-action-playlist-generator.png deleted file mode 100644 index a13509ab..00000000 Binary files a/amarok/images/icons/hi48-action-playlist-generator.png and /dev/null differ diff --git a/amarok/images/icons/hi48-action-podcast-amarok.png b/amarok/images/icons/hi48-action-podcast-amarok.png deleted file mode 100644 index ca1445b6..00000000 Binary files a/amarok/images/icons/hi48-action-podcast-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi48-action-preferences-indicator-amarok.png b/amarok/images/icons/hi48-action-preferences-indicator-amarok.png deleted file mode 100644 index 70bc0aa7..00000000 Binary files a/amarok/images/icons/hi48-action-preferences-indicator-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi48-action-preferences-media-playback-amarok.png b/amarok/images/icons/hi48-action-preferences-media-playback-amarok.png deleted file mode 100644 index a3110dd6..00000000 Binary files a/amarok/images/icons/hi48-action-preferences-media-playback-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi48-action-preferences-multimedia-player-amarok.png b/amarok/images/icons/hi48-action-preferences-multimedia-player-amarok.png deleted file mode 100644 index 75a8d54b..00000000 Binary files a/amarok/images/icons/hi48-action-preferences-multimedia-player-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi48-action-preferences-view-amarok.png b/amarok/images/icons/hi48-action-preferences-view-amarok.png deleted file mode 100644 index 888a4deb..00000000 Binary files a/amarok/images/icons/hi48-action-preferences-view-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi48-action-remove-amarok.png b/amarok/images/icons/hi48-action-remove-amarok.png deleted file mode 100644 index 1202a3cd..00000000 Binary files a/amarok/images/icons/hi48-action-remove-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi48-action-similarartists-amarok.png b/amarok/images/icons/hi48-action-similarartists-amarok.png deleted file mode 100644 index 68bcdc6a..00000000 Binary files a/amarok/images/icons/hi48-action-similarartists-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi48-action-upcomingevents-amarok.png b/amarok/images/icons/hi48-action-upcomingevents-amarok.png deleted file mode 100644 index 06582ff6..00000000 Binary files a/amarok/images/icons/hi48-action-upcomingevents-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi48-action-videoclip-amarok.png b/amarok/images/icons/hi48-action-videoclip-amarok.png deleted file mode 100644 index f20fbe64..00000000 Binary files a/amarok/images/icons/hi48-action-videoclip-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi48-action-view-importers-banshee-amarok.png b/amarok/images/icons/hi48-action-view-importers-banshee-amarok.png deleted file mode 100644 index 307fc737..00000000 Binary files a/amarok/images/icons/hi48-action-view-importers-banshee-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi48-action-view-importers-clementine-amarok.png b/amarok/images/icons/hi48-action-view-importers-clementine-amarok.png deleted file mode 100644 index b80c44f8..00000000 Binary files a/amarok/images/icons/hi48-action-view-importers-clementine-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi48-action-view-importers-rhythmbox-amarok.png b/amarok/images/icons/hi48-action-view-importers-rhythmbox-amarok.png deleted file mode 100644 index a668a2d0..00000000 Binary files a/amarok/images/icons/hi48-action-view-importers-rhythmbox-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi48-action-view-media-analyzer-amarok.png b/amarok/images/icons/hi48-action-view-media-analyzer-amarok.png deleted file mode 100644 index 7d2285ef..00000000 Binary files a/amarok/images/icons/hi48-action-view-media-analyzer-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi48-action-view-services-amazon-amarok.png b/amarok/images/icons/hi48-action-view-services-amazon-amarok.png deleted file mode 100644 index 18aafdac..00000000 Binary files a/amarok/images/icons/hi48-action-view-services-amazon-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi48-action-view-services-ampache-amarok.png b/amarok/images/icons/hi48-action-view-services-ampache-amarok.png deleted file mode 100644 index d1c9e72e..00000000 Binary files a/amarok/images/icons/hi48-action-view-services-ampache-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi48-action-view-services-gpodder-amarok.png b/amarok/images/icons/hi48-action-view-services-gpodder-amarok.png deleted file mode 100644 index 02c57cb3..00000000 Binary files a/amarok/images/icons/hi48-action-view-services-gpodder-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi48-action-view-services-jamendo-amarok.png b/amarok/images/icons/hi48-action-view-services-jamendo-amarok.png deleted file mode 100644 index 11246744..00000000 Binary files a/amarok/images/icons/hi48-action-view-services-jamendo-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi48-action-view-services-lastfm-amarok.png b/amarok/images/icons/hi48-action-view-services-lastfm-amarok.png deleted file mode 100644 index 31f1ec39..00000000 Binary files a/amarok/images/icons/hi48-action-view-services-lastfm-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi48-action-view-services-magnatune-amarok.png b/amarok/images/icons/hi48-action-view-services-magnatune-amarok.png deleted file mode 100644 index c8085d92..00000000 Binary files a/amarok/images/icons/hi48-action-view-services-magnatune-amarok.png and /dev/null differ diff --git a/amarok/images/icons/hi48-action-view-services-mp3tunes-amarok.png b/amarok/images/icons/hi48-action-view-services-mp3tunes-amarok.png deleted file mode 100644 index ac85147e..00000000 Binary files a/amarok/images/icons/hi48-action-view-services-mp3tunes-amarok.png and /dev/null differ diff --git a/amarok/images/icons/svg/action-cart_add.svgz b/amarok/images/icons/svg/action-cart_add.svgz deleted file mode 100644 index c811175e..00000000 Binary files a/amarok/images/icons/svg/action-cart_add.svgz and /dev/null differ diff --git a/amarok/images/icons/svg/action-cart_remove.svgz b/amarok/images/icons/svg/action-cart_remove.svgz deleted file mode 100644 index 067f4cb1..00000000 Binary files a/amarok/images/icons/svg/action-cart_remove.svgz and /dev/null differ diff --git a/amarok/images/icons/svg/action-cart_view.svg b/amarok/images/icons/svg/action-cart_view.svg deleted file mode 100644 index f3786637..00000000 --- a/amarok/images/icons/svg/action-cart_view.svg +++ /dev/null @@ -1,864 +0,0 @@ - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/amarok/images/icons/svg/action-collection-amarok.svgz b/amarok/images/icons/svg/action-collection-amarok.svgz deleted file mode 100644 index 107cd4b7..00000000 Binary files a/amarok/images/icons/svg/action-collection-amarok.svgz and /dev/null differ diff --git a/amarok/images/icons/svg/action-favorite-genres-amarok.svgz b/amarok/images/icons/svg/action-favorite-genres-amarok.svgz deleted file mode 100644 index d008714f..00000000 Binary files a/amarok/images/icons/svg/action-favorite-genres-amarok.svgz and /dev/null differ diff --git a/amarok/images/icons/svg/action-internet-amarok.svgz b/amarok/images/icons/svg/action-internet-amarok.svgz deleted file mode 100644 index 2386b8df..00000000 Binary files a/amarok/images/icons/svg/action-internet-amarok.svgz and /dev/null differ diff --git a/amarok/images/icons/svg/action-love-amarok.svg b/amarok/images/icons/svg/action-love-amarok.svg deleted file mode 100644 index 7a5e1c5f..00000000 --- a/amarok/images/icons/svg/action-love-amarok.svg +++ /dev/null @@ -1,106 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/amarok/images/icons/svg/action-media-album-cover-manager-amarok.svgz b/amarok/images/icons/svg/action-media-album-cover-manager-amarok.svgz deleted file mode 100644 index 5054479e..00000000 Binary files a/amarok/images/icons/svg/action-media-album-cover-manager-amarok.svgz and /dev/null differ diff --git a/amarok/images/icons/svg/action-media-album-track.svgz b/amarok/images/icons/svg/action-media-album-track.svgz deleted file mode 100644 index 33d76b83..00000000 Binary files a/amarok/images/icons/svg/action-media-album-track.svgz and /dev/null differ diff --git a/amarok/images/icons/svg/action-media-playlist-shuffle-amarok.svgz b/amarok/images/icons/svg/action-media-playlist-shuffle-amarok.svgz deleted file mode 100644 index 604d8805..00000000 Binary files a/amarok/images/icons/svg/action-media-playlist-shuffle-amarok.svgz and /dev/null differ diff --git a/amarok/images/icons/svg/action-media-playlist-shuffle-off-amarok.svgz b/amarok/images/icons/svg/action-media-playlist-shuffle-off-amarok.svgz deleted file mode 100644 index eb71af0e..00000000 Binary files a/amarok/images/icons/svg/action-media-playlist-shuffle-off-amarok.svgz and /dev/null differ diff --git a/amarok/images/icons/svg/action-media-track-queue-amarok.svgz b/amarok/images/icons/svg/action-media-track-queue-amarok.svgz deleted file mode 100644 index 6f565817..00000000 Binary files a/amarok/images/icons/svg/action-media-track-queue-amarok.svgz and /dev/null differ diff --git a/amarok/images/icons/svg/action-view-services-amazon-amarok.svgz b/amarok/images/icons/svg/action-view-services-amazon-amarok.svgz deleted file mode 100644 index 6b0cda03..00000000 Binary files a/amarok/images/icons/svg/action-view-services-amazon-amarok.svgz and /dev/null differ diff --git a/amarok/images/icons/svg/action-view-services-ampache-amarok.svgz b/amarok/images/icons/svg/action-view-services-ampache-amarok.svgz deleted file mode 100644 index 9474974c..00000000 Binary files a/amarok/images/icons/svg/action-view-services-ampache-amarok.svgz and /dev/null differ diff --git a/amarok/images/icons/svg/action-view-services-gpodder-amarok.svgz b/amarok/images/icons/svg/action-view-services-gpodder-amarok.svgz deleted file mode 100644 index ac3c7ef3..00000000 Binary files a/amarok/images/icons/svg/action-view-services-gpodder-amarok.svgz and /dev/null differ diff --git a/amarok/images/icons/svg/action-view-services-jamendo-amarok.svgz b/amarok/images/icons/svg/action-view-services-jamendo-amarok.svgz deleted file mode 100644 index 1d2df07a..00000000 Binary files a/amarok/images/icons/svg/action-view-services-jamendo-amarok.svgz and /dev/null differ diff --git a/amarok/images/icons/svg/action-view-services-jamendo-black-amarok.svgz b/amarok/images/icons/svg/action-view-services-jamendo-black-amarok.svgz deleted file mode 100644 index 69e8b655..00000000 Binary files a/amarok/images/icons/svg/action-view-services-jamendo-black-amarok.svgz and /dev/null differ diff --git a/amarok/images/icons/svg/action-view-services-lastfm-amarok.svg b/amarok/images/icons/svg/action-view-services-lastfm-amarok.svg deleted file mode 100644 index 9012181e..00000000 --- a/amarok/images/icons/svg/action-view-services-lastfm-amarok.svg +++ /dev/null @@ -1,212 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/amarok/images/icons/svg/action-view-services-librivox-amarok.svgz b/amarok/images/icons/svg/action-view-services-librivox-amarok.svgz deleted file mode 100644 index eb0d6856..00000000 Binary files a/amarok/images/icons/svg/action-view-services-librivox-amarok.svgz and /dev/null differ diff --git a/amarok/images/icons/svg/action-view-services-opml-amarok.svgz b/amarok/images/icons/svg/action-view-services-opml-amarok.svgz deleted file mode 100644 index ade811db..00000000 Binary files a/amarok/images/icons/svg/action-view-services-opml-amarok.svgz and /dev/null differ diff --git a/amarok/images/icons/svg/action-view-services-scripted-amarok.svgz b/amarok/images/icons/svg/action-view-services-scripted-amarok.svgz deleted file mode 100644 index 10fbef8e..00000000 Binary files a/amarok/images/icons/svg/action-view-services-scripted-amarok.svgz and /dev/null differ diff --git a/amarok/images/icons/svg/hi16-action-filename-bpm-amarok.svgz b/amarok/images/icons/svg/hi16-action-filename-bpm-amarok.svgz deleted file mode 100644 index d3914376..00000000 Binary files a/amarok/images/icons/svg/hi16-action-filename-bpm-amarok.svgz and /dev/null differ diff --git a/amarok/images/icons/svg/hi16-action-filename-last-played.svgz b/amarok/images/icons/svg/hi16-action-filename-last-played.svgz deleted file mode 100644 index d4f7cf33..00000000 Binary files a/amarok/images/icons/svg/hi16-action-filename-last-played.svgz and /dev/null differ diff --git a/amarok/images/icons/svg/hi22-action-filename-bpm-amarok.svgz b/amarok/images/icons/svg/hi22-action-filename-bpm-amarok.svgz deleted file mode 100644 index bd71a2a9..00000000 Binary files a/amarok/images/icons/svg/hi22-action-filename-bpm-amarok.svgz and /dev/null differ diff --git a/amarok/images/icons/svg/hi32-action-filename-bpm-amarok.svgz b/amarok/images/icons/svg/hi32-action-filename-bpm-amarok.svgz deleted file mode 100644 index 0d65c147..00000000 Binary files a/amarok/images/icons/svg/hi32-action-filename-bpm-amarok.svgz and /dev/null differ diff --git a/amarok/images/icons/svg/hi48-action-filename-bpm-amarok.svgz b/amarok/images/icons/svg/hi48-action-filename-bpm-amarok.svgz deleted file mode 100644 index 1f213ef5..00000000 Binary files a/amarok/images/icons/svg/hi48-action-filename-bpm-amarok.svgz and /dev/null differ diff --git a/amarok/images/icons/svg/hi48-action-filename-divider.svgz b/amarok/images/icons/svg/hi48-action-filename-divider.svgz deleted file mode 100644 index 225763ba..00000000 Binary files a/amarok/images/icons/svg/hi48-action-filename-divider.svgz and /dev/null differ diff --git a/amarok/images/icons/svg/hi48-action-filename-group-length.svgz b/amarok/images/icons/svg/hi48-action-filename-group-length.svgz deleted file mode 100644 index 7b18b413..00000000 Binary files a/amarok/images/icons/svg/hi48-action-filename-group-length.svgz and /dev/null differ diff --git a/amarok/images/icons/svg/hi48-action-filename-group-tracks.svgz b/amarok/images/icons/svg/hi48-action-filename-group-tracks.svgz deleted file mode 100644 index 87913c41..00000000 Binary files a/amarok/images/icons/svg/hi48-action-filename-group-tracks.svgz and /dev/null differ diff --git a/amarok/images/icons/svg/hi48-action-filename-last-played.svgz b/amarok/images/icons/svg/hi48-action-filename-last-played.svgz deleted file mode 100644 index 4aab544f..00000000 Binary files a/amarok/images/icons/svg/hi48-action-filename-last-played.svgz and /dev/null differ diff --git a/amarok/images/icons/svg/hi48-action-filename-sample-rate.svgz b/amarok/images/icons/svg/hi48-action-filename-sample-rate.svgz deleted file mode 100644 index c9bf26b6..00000000 Binary files a/amarok/images/icons/svg/hi48-action-filename-sample-rate.svgz and /dev/null differ diff --git a/amarok/images/lastfm-default-cover.png b/amarok/images/lastfm-default-cover.png deleted file mode 100644 index 6ed843c5..00000000 Binary files a/amarok/images/lastfm-default-cover.png and /dev/null differ diff --git a/amarok/images/lastfm.png b/amarok/images/lastfm.png deleted file mode 100644 index 391ad468..00000000 Binary files a/amarok/images/lastfm.png and /dev/null differ diff --git a/amarok/images/loading1.png b/amarok/images/loading1.png deleted file mode 100644 index 5f236073..00000000 Binary files a/amarok/images/loading1.png and /dev/null differ diff --git a/amarok/images/loading2.png b/amarok/images/loading2.png deleted file mode 100644 index eb2c6e63..00000000 Binary files a/amarok/images/loading2.png and /dev/null differ diff --git a/amarok/images/mb_aicon.png b/amarok/images/mb_aicon.png deleted file mode 100644 index a414cc34..00000000 Binary files a/amarok/images/mb_aicon.png and /dev/null differ diff --git a/amarok/images/mb_licon.png b/amarok/images/mb_licon.png deleted file mode 100644 index 9c2a051e..00000000 Binary files a/amarok/images/mb_licon.png and /dev/null differ diff --git a/amarok/images/mb_ticon.png b/amarok/images/mb_ticon.png deleted file mode 100644 index 1aa9edc5..00000000 Binary files a/amarok/images/mb_ticon.png and /dev/null differ diff --git a/amarok/images/navigation_arrows.svg b/amarok/images/navigation_arrows.svg deleted file mode 100644 index 7c074b81..00000000 --- a/amarok/images/navigation_arrows.svg +++ /dev/null @@ -1,84 +0,0 @@ - - - - - - - - - - - image/svg+xml - - - - - - - - - - - diff --git a/amarok/images/nocover.png b/amarok/images/nocover.png deleted file mode 100644 index f1c811c7..00000000 Binary files a/amarok/images/nocover.png and /dev/null differ diff --git a/amarok/images/nocover.svg b/amarok/images/nocover.svg deleted file mode 100644 index ef721add..00000000 --- a/amarok/images/nocover.svg +++ /dev/null @@ -1,767 +0,0 @@ - - -image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/amarok/images/opendesktop-22.png b/amarok/images/opendesktop-22.png deleted file mode 100644 index 05049efd..00000000 Binary files a/amarok/images/opendesktop-22.png and /dev/null differ diff --git a/amarok/images/opendesktop-22.svgz b/amarok/images/opendesktop-22.svgz deleted file mode 100644 index 9c6b8a96..00000000 Binary files a/amarok/images/opendesktop-22.svgz and /dev/null differ diff --git a/amarok/images/playlist-bookmark-16.png b/amarok/images/playlist-bookmark-16.png deleted file mode 100644 index c2a04590..00000000 Binary files a/amarok/images/playlist-bookmark-16.png and /dev/null differ diff --git a/amarok/images/playlist-bookmark-16.svgz b/amarok/images/playlist-bookmark-16.svgz deleted file mode 100644 index 0e47f676..00000000 Binary files a/amarok/images/playlist-bookmark-16.svgz and /dev/null differ diff --git a/amarok/images/playlist-layouts-22.png b/amarok/images/playlist-layouts-22.png deleted file mode 100644 index 6b5d138c..00000000 Binary files a/amarok/images/playlist-layouts-22.png and /dev/null differ diff --git a/amarok/images/playlist-layouts-22.svgz b/amarok/images/playlist-layouts-22.svgz deleted file mode 100644 index bea89d75..00000000 Binary files a/amarok/images/playlist-layouts-22.svgz and /dev/null differ diff --git a/amarok/images/playlist-sorting-16.png b/amarok/images/playlist-sorting-16.png deleted file mode 100644 index 34c343f9..00000000 Binary files a/amarok/images/playlist-sorting-16.png and /dev/null differ diff --git a/amarok/images/playlist-sorting-16.svgz b/amarok/images/playlist-sorting-16.svgz deleted file mode 100644 index a0c32993..00000000 Binary files a/amarok/images/playlist-sorting-16.svgz and /dev/null differ diff --git a/amarok/images/pud_items.svg b/amarok/images/pud_items.svg deleted file mode 100644 index 21b82111..00000000 --- a/amarok/images/pud_items.svg +++ /dev/null @@ -1,8828 +0,0 @@ - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - delete_file - - - - - - - - - - - - - - - - - cart_in - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - cart_out - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - loading - - - - - - - diff --git a/amarok/images/service_info_loading1.png b/amarok/images/service_info_loading1.png deleted file mode 100644 index 60757e74..00000000 Binary files a/amarok/images/service_info_loading1.png and /dev/null differ diff --git a/amarok/images/service_info_loading10.png b/amarok/images/service_info_loading10.png deleted file mode 100644 index a17c3414..00000000 Binary files a/amarok/images/service_info_loading10.png and /dev/null differ diff --git a/amarok/images/service_info_loading11.png b/amarok/images/service_info_loading11.png deleted file mode 100644 index 3df9e1c7..00000000 Binary files a/amarok/images/service_info_loading11.png and /dev/null differ diff --git a/amarok/images/service_info_loading12.png b/amarok/images/service_info_loading12.png deleted file mode 100644 index fc2bb4ce..00000000 Binary files a/amarok/images/service_info_loading12.png and /dev/null differ diff --git a/amarok/images/service_info_loading2.png b/amarok/images/service_info_loading2.png deleted file mode 100644 index 19211fa7..00000000 Binary files a/amarok/images/service_info_loading2.png and /dev/null differ diff --git a/amarok/images/service_info_loading3.png b/amarok/images/service_info_loading3.png deleted file mode 100644 index cfec34a2..00000000 Binary files a/amarok/images/service_info_loading3.png and /dev/null differ diff --git a/amarok/images/service_info_loading4.png b/amarok/images/service_info_loading4.png deleted file mode 100644 index a9e30fb0..00000000 Binary files a/amarok/images/service_info_loading4.png and /dev/null differ diff --git a/amarok/images/service_info_loading5.png b/amarok/images/service_info_loading5.png deleted file mode 100644 index 03c47f7d..00000000 Binary files a/amarok/images/service_info_loading5.png and /dev/null differ diff --git a/amarok/images/service_info_loading6.png b/amarok/images/service_info_loading6.png deleted file mode 100644 index 00342378..00000000 Binary files a/amarok/images/service_info_loading6.png and /dev/null differ diff --git a/amarok/images/service_info_loading7.png b/amarok/images/service_info_loading7.png deleted file mode 100644 index d294cbc4..00000000 Binary files a/amarok/images/service_info_loading7.png and /dev/null differ diff --git a/amarok/images/service_info_loading8.png b/amarok/images/service_info_loading8.png deleted file mode 100644 index 7a3b7df0..00000000 Binary files a/amarok/images/service_info_loading8.png and /dev/null differ diff --git a/amarok/images/service_info_loading9.png b/amarok/images/service_info_loading9.png deleted file mode 100644 index 5aef081e..00000000 Binary files a/amarok/images/service_info_loading9.png and /dev/null differ diff --git a/amarok/images/smallstar.png b/amarok/images/smallstar.png deleted file mode 100644 index 0a6ea2ac..00000000 Binary files a/amarok/images/smallstar.png and /dev/null differ diff --git a/amarok/images/star.png b/amarok/images/star.png deleted file mode 100644 index c099c400..00000000 Binary files a/amarok/images/star.png and /dev/null differ diff --git a/amarok/images/volume_icon.png b/amarok/images/volume_icon.png deleted file mode 100644 index 5c8e0fe6..00000000 Binary files a/amarok/images/volume_icon.png and /dev/null differ diff --git a/amarok/images/volume_muted_icon.png b/amarok/images/volume_muted_icon.png deleted file mode 100644 index be05a3bb..00000000 Binary files a/amarok/images/volume_muted_icon.png and /dev/null differ diff --git a/amarok/images/wirl1.png b/amarok/images/wirl1.png deleted file mode 100644 index f2c095ed..00000000 Binary files a/amarok/images/wirl1.png and /dev/null differ diff --git a/amarok/images/wirl2.png b/amarok/images/wirl2.png deleted file mode 100644 index 29e51177..00000000 Binary files a/amarok/images/wirl2.png and /dev/null differ diff --git a/amarok/playground/CMakeLists.txt b/amarok/playground/CMakeLists.txt deleted file mode 100644 index aa1f7210..00000000 --- a/amarok/playground/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -include (KDE4Defaults) -include (MacroLibrary) - -include(CheckTypeSize) -include(MacroBoolTo01) -include(MacroLogFeature) - -set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} - ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules ) - -# Add a variable which points to amarok's source directory. -set( AMAROK_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../src/ ) - -include_directories (${CMAKE_CURRENT_SOURCE_DIR} ${AMAROK_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${KDE4_INCLUDES} ${TAGLIB_INCLUDES}) - -add_subdirectory( src ) - -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fmessage-length=0") -SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fmessage-length=0") diff --git a/amarok/playground/src/CMakeLists.txt b/amarok/playground/src/CMakeLists.txt deleted file mode 100644 index ed740ecf..00000000 --- a/amarok/playground/src/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -add_subdirectory( context ) -add_subdirectory( scripts ) diff --git a/amarok/playground/src/context/CMakeLists.txt b/amarok/playground/src/context/CMakeLists.txt deleted file mode 100644 index ad520910..00000000 --- a/amarok/playground/src/context/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -add_subdirectory( applets ) diff --git a/amarok/playground/src/context/applets/CMakeLists.txt b/amarok/playground/src/context/applets/CMakeLists.txt deleted file mode 100644 index bedf240f..00000000 --- a/amarok/playground/src/context/applets/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -add_subdirectory( coverbling ) -add_subdirectory( covergrid ) diff --git a/amarok/playground/src/context/applets/coverbling/CMakeLists.txt b/amarok/playground/src/context/applets/coverbling/CMakeLists.txt deleted file mode 100644 index 046adb6a..00000000 --- a/amarok/playground/src/context/applets/coverbling/CMakeLists.txt +++ /dev/null @@ -1,36 +0,0 @@ -project(context-coverbling) - -set(coverbling_SRCS -pictureflow.cpp -CoverBlingApplet.cpp -ImageLoader.cpp -PhotoBrowser.cpp -SearchBarTextItem.cpp -) - -include_directories( ../../.. - ../.. - ${KDE4_INCLUDE_DIR}/amarok ) # this way we don't need to prefix it with amarok/ (and it compiles this way too :) - -kde4_add_ui_files( coverbling_SRCS coverblingSettings.ui ) -kde4_add_plugin(amarok_context_applet_coverbling ${coverbling_SRCS}) - - -target_link_libraries(amarok_context_applet_coverbling - amarokcore - amaroklib - ${KDE4_PLASMA_LIBS} - ${KDE4_KIO_LIBS} -) - -install(TARGETS amarok_context_applet_coverbling DESTINATION ${PLUGIN_INSTALL_DIR}) -install(FILES amarok-context-applet-coverbling.desktop DESTINATION ${SERVICES_INSTALL_DIR}) -install(FILES blingfastback.png DESTINATION ${DATA_INSTALL_DIR}/amarok/images/ ) -install(FILES blingtofirst.png DESTINATION ${DATA_INSTALL_DIR}/amarok/images/ ) -install(FILES blingfastforward.png DESTINATION ${DATA_INSTALL_DIR}/amarok/images/ ) -install(FILES blingtolast.png DESTINATION ${DATA_INSTALL_DIR}/amarok/images/ ) -install(FILES blingdefaultcover.png DESTINATION ${DATA_INSTALL_DIR}/amarok/images/ ) -install(FILES blingfullscreen.png DESTINATION ${DATA_INSTALL_DIR}/amarok/images/ ) -install(FILES blingjumptoplaying.png DESTINATION ${DATA_INSTALL_DIR}/amarok/images/ ) -install(FILES blingsearchalbum.png DESTINATION ${DATA_INSTALL_DIR}/amarok/images/ ) -install(FILES blingsearchartist.png DESTINATION ${DATA_INSTALL_DIR}/amarok/images/ ) diff --git a/amarok/playground/src/context/applets/coverbling/CoverBling.cpp b/amarok/playground/src/context/applets/coverbling/CoverBling.cpp deleted file mode 100644 index 0861f1a9..00000000 --- a/amarok/playground/src/context/applets/coverbling/CoverBling.cpp +++ /dev/null @@ -1,269 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Mark Kretschmann * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "CoverBling" - -#include "CoverBling.h" - -#include "core/support/Debug.h" -#include "core-impl/collections/support/CollectionManager.h" -#include "core/meta/Meta.h" - -#include -#ifdef Q_WS_MAC -#include -#else -#include -#endif -#include -#include -#include - -#include - -#define TEXTURE_SIZE QSize( 256, 256 ) - - -CoverBling::CoverBling( QWidget* parent ) - : QGLWidget( QGLFormat(QGL::DepthBuffer|QGL::SampleBuffers|QGL::AlphaChannel|QGL::DoubleBuffer), parent ) - , m_xOffset( 0.0 ) - , m_zOffset( M_PI / 2 ) -{ - DEBUG_BLOCK - - setFixedHeight( 200 ); - - Collections::Collection *coll = CollectionManager::instance()->primaryCollection(); - QueryMaker *qm = coll->queryMaker(); - qm->setQueryType( QueryMaker::Album ); - qm->limitMaxResultSize( 10 ); - - connect( qm, SIGNAL(newResultReady(Meta::AlbumList)), this, SLOT(queryResult(Meta::AlbumList)) ); - - qm->run(); -} - -void -CoverBling::queryResult( Meta::AlbumList albums ) -{ - foreach( Meta::AlbumPtr album, albums ) - m_covers << album->image(); - - QTimer* timer = new QTimer( this ); - connect( timer, SIGNAL(timeout()), this, SLOT(updateGL()) ); - timer->start( 20 ); //50fps -} - -void -CoverBling::initializeGL() //reimplemented -{ - DEBUG_BLOCK - - //generate all textures - foreach( const QPixmap &p, m_covers ) { - QImage image = p.toImage(); - image = image.scaled( TEXTURE_SIZE, Qt::KeepAspectRatio, Qt::SmoothTransformation ); - m_textureIds << bindTexture( image ); - } - - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - glShadeModel(GL_SMOOTH); - qglClearColor( Qt::black ); - glEnable( GL_MULTISAMPLE ); //enable anti aliasing - glEnable( GL_DEPTH_TEST ); - glDepthMask( true ); - - //Display list for drawing a textured rectangle - m_texturedRectList = glGenLists( 1 ); - glNewList( m_texturedRectList, GL_COMPILE ); - glBegin (GL_QUADS); - glTexCoord2f (0.0, 0.0); - glColor3f( 1.0, 1.0, 1.0 ); - glVertex3f (-1.0, -1.0, -1.0); - glTexCoord2f (1.0, 0.0); - glColor3f( 0.1, 0.1, 0.1 ); - glVertex3f (1.0, -1.0, -1.0); - glTexCoord2f (1.0, 1.0); - glColor3f( 0.1, 0.1, 0.1 ); - glVertex3f (1.0, 1.0, -1.0); - glTexCoord2f (0.0, 1.0); - glColor3f( 1.0, 1.0, 1.0 ); - glVertex3f (-1.0, 1.0, -1.0); - glEnd (); - //glDisable( GL_DEPTH_TEST ); - glEndList(); - - //Display list for drawing reflection of the textured rectangle - m_texturedRectReflectedList = glGenLists( 1 ); - glNewList( m_texturedRectReflectedList, GL_COMPILE ); - glTranslatef( 0.0, -2.0, 0.0 ); - glScalef( 1.0, -1.0, 1.0 ); - - glEnable( GL_BLEND ); - //glBlendFunc( GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR ); - glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); - - glBegin (GL_QUADS); - glTexCoord2f (0.0, 0.0); - glColor4f( 1.0, 1.0, 1.0, 0.3 ); - glVertex3f (-1.0, -1.0, -1.0); - glColor4f( 1.0, 1.0, 1.0, 0.3 - 0.15 ); - glTexCoord2f (1.0, 0.0); - glVertex3f (1.0, -1.0, -1.0); - glColor4f( 1.0, 1.0, 1.0, 0.02 - 0.15 ); - glTexCoord2f (1.0, 1.0); - glVertex3f (1.0, 1.0, -1.0); - glColor4f( 1.0, 1.0, 1.0, 0.02 ); - glTexCoord2f (0.0, 1.0); - glVertex3f (-1.0, 1.0, -1.0); - glEnd (); - - glDisable( GL_BLEND ); - glEndList(); -} - -void -CoverBling::resizeGL( int width, int height ) //reimplemented -{ - DEBUG_BLOCK - - glViewport( 0, 0, (GLint)width, (GLint)height ); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - //glFrustum( -0.5f, 0.5f, -0.5f, 0.5f, 0.3f, 4.5f ); - setPerspective(); - glMatrixMode(GL_MODELVIEW); -} - -void -CoverBling::setPerspective() -{ - gluPerspective( 30, (double)width() / height(), 1.0, 20.0 ); -} - -void -CoverBling::paintGL() //reimplemented -{ - glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); - - const QPoint mousePos = mapFromGlobal( QCursor::pos() ); - draw( objectAtPosition( mousePos ) ); -} - -void -CoverBling::draw( GLuint selected ) -{ - GLuint objectName = 1; - - glMatrixMode( GL_MODELVIEW ); - glLoadIdentity(); - glRotatef( 10, 1.0, 0.0, 0.0 ); //Rotate whole scene around X axis; simulates camera tilt - glScalef( 1.0, 1.0, 6.0 ); - - //draw the ground - //glBegin( GL_POLYGON ); - // glColor3f( 0.0, 0.0, 0.5 ); - // glVertex3f (-3.0, -1.0, -2.0); - // glColor3f( 1.0, 0.0, 0.5 ); - // glVertex3f (3.0, -1.0, -2.0); - // glColor3f( 0.0, 1.0, 0.5 ); - // glVertex3f (3.0, -1.0, 2.0); - // glColor3f( 0.0, 0.0, 1.5 ); - // glVertex3f (-3.0, -1.0, 2.0); - //glEnd(); - - glColor3f( 1.0, 1.0, 1.0 ); //reset color - glEnable( GL_TEXTURE_2D); - - float xoffset = -5.5; - float yoffset = -0.6; - float zoffset = -1.1; - - foreach( GLuint id, m_textureIds ) { // krazy:exclude=foreach - glBindTexture( GL_TEXTURE_2D, id ); - glPushMatrix(); - //const float xsin = sin( xoffset ); - //const float zsin = sin( zoffset ); - xoffset += 1.0; - zoffset += 0.1; - glTranslatef( xoffset, yoffset, zoffset ); - glRotatef( 8, 0.0, 1.0, 0.0 ); - - //draw the cover - if( objectName == selected ) - glColor3f( 1.0, 0.0, 0.0 ); - glLoadName( objectName++ ); - glCallList( m_texturedRectList ); - glColor4f( 1.0, 1.0, 1.0, 1.0 ); - - //draw reflection on the ground - glLoadName( 0 ); - glPushMatrix(); - glCallList( m_texturedRectReflectedList ); - glPopMatrix(); - glPopMatrix(); - glColor4f( 1.0, 1.0, 1.0, 1.0 ); - } - - glDisable( GL_TEXTURE_2D); -} - -GLuint -CoverBling::objectAtPosition( const QPoint& pos ) -{ - // this is the same as in every OpenGL picking example - const int MaxSize = 512; // see below for an explanation on the buffer content - GLuint buffer[MaxSize]; - GLint viewport[4]; - - glGetIntegerv(GL_VIEWPORT, viewport); - glSelectBuffer(MaxSize, buffer); - // enter select mode - glRenderMode(GL_SELECT); - - glInitNames(); - glPushName(0); - - glMatrixMode(GL_PROJECTION); - glPushMatrix(); - glLoadIdentity(); - gluPickMatrix((GLdouble)pos.x(), (GLdouble)(viewport[3] - pos.y()), 5.0, 5.0, viewport); - setPerspective(); - draw(); - glMatrixMode(GL_PROJECTION); - glPopMatrix(); - - const int hits = glRenderMode( GL_RENDER ); - if ( !hits ) - return 0; - - //determine object with the lowest Z value - uint hitZValue = UINT_MAX; - uint hit = UINT_MAX; - for( int i = 0; i < hits; i++ ) { - if( buffer[(i*4)+1] < hitZValue ) { - hit = buffer[(i*4)+3]; - hitZValue = buffer[(i*4)+1]; - } - } - - // return the name of the clicked surface - return hit; -} - - -#include "moc_CoverBling.cpp" - diff --git a/amarok/playground/src/context/applets/coverbling/CoverBling.h b/amarok/playground/src/context/applets/coverbling/CoverBling.h deleted file mode 100644 index e814af62..00000000 --- a/amarok/playground/src/context/applets/coverbling/CoverBling.h +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Mark Kretschmann * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_COVERBLING_H -#define AMAROK_COVERBLING_H - -#include "core/meta/forward_declarations.h" - -#include - - -class CoverBling : public QGLWidget -{ - Q_OBJECT - - public: - CoverBling( QWidget* parent ); - - protected: - void initializeGL(); - void resizeGL( int width, int height ); - void setPerspective(); - void paintGL(); - void draw( GLuint selected = 0 ); - GLuint objectAtPosition( const QPoint& pos ); - - private slots: - void queryResult( Meta::AlbumList albums ); - - private: - QList m_covers; - QList m_textureIds; - GLuint m_texturedRectList; - GLuint m_texturedRectReflectedList; - float m_xOffset; - float m_zOffset; -}; - - -#endif /* AMAROK_COVERBLING_H */ - - diff --git a/amarok/playground/src/context/applets/coverbling/CoverBlingApplet.cpp b/amarok/playground/src/context/applets/coverbling/CoverBlingApplet.cpp deleted file mode 100644 index 51dea1de..00000000 --- a/amarok/playground/src/context/applets/coverbling/CoverBlingApplet.cpp +++ /dev/null @@ -1,486 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Emmanuel Wagner * - * Copyright (c) 2010 Mark Kretschmann * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "CoverBlingApplet" - -#include "CoverBlingApplet.h" - -#include "EngineController.h" -#include "context/ContextView.h" -#include "context/widgets/RatingWidget.h" -#include "context/widgets/TextScrollingWidget.h" -#include "core/collections/Collection.h" -#include "core/meta/Meta.h" -#include "core/meta/Statistics.h" -#include "core/support/Amarok.h" -#include "core/support/Debug.h" -#include "core-impl/collections/support/CollectionManager.h" -#include "playlist/PlaylistModelStack.h" -#include "SearchBarTextItem.h" -#include "playlist/PlaylistController.h" - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include - -CoverBlingApplet::CoverBlingApplet( QObject* parent, const QVariantList& args ) - : Context::Applet( parent, args ) -{ - DEBUG_BLOCK - - setHasConfigurationInterface( true ); -} - -void -CoverBlingApplet::init() -{ - // Call the base implementation. - Context::Applet::init(); - setBackgroundHints( Plasma::Applet::NoBackground ); - - m_fullsize = false; - - KConfigGroup config = Amarok::config( "CoverBling Applet" ); - m_coversize = config.readEntry( "CoverSize", 200 ); - int reflectioneffect = config.readEntry( "ReflectionEffect", 1 ); - if ( reflectioneffect == 0 ) - m_reflectionEffect = PictureFlow::NoReflection; - else if ( reflectioneffect == 1 ) - m_reflectionEffect = PictureFlow::PlainReflection; - else if ( reflectioneffect == 2 ) - m_reflectionEffect = PictureFlow::BlurredReflection; - m_autojump = config.readEntry( "AutoJump", false ); - m_animatejump = config.readEntry( "AnimateJump", true ); - m_layout = new QGraphicsProxyWidget( this ); - m_openGL = false; - //bool setting_opengl = config.readEntry( "OpenGL", false ); - //if (QGLFormat::hasOpenGL() && setting_opengl) m_openGL = true; - - m_pictureflow = new PhotoBrowser(0,m_openGL); - m_layout->setWidget( m_pictureflow ); - - m_pictureflow->setRenderHints( QPainter::HighQualityAntialiasing | QPainter::SmoothPixmapTransform ); - - m_pictureflow->show(); - - Collections::Collection *coll = CollectionManager::instance()->primaryCollection(); - Collections::QueryMaker *qm = coll->queryMaker(); - qm->setAutoDelete( true ); - qm->setQueryType( Collections::QueryMaker::Album ); - qm->orderBy( Meta::valArtist ); - - connect( qm, SIGNAL(newResultReady(Meta::AlbumList)), - this, SLOT(slotAlbumQueryResult(Meta::AlbumList)) ); - qm->run(); - - m_label = new QGraphicsSimpleTextItem( this ); - m_label->setBrush( QBrush( Qt::white ) ); - QFont labelFont; - QFont bigFont( labelFont ); - bigFont.setPointSize( bigFont.pointSize() + 4 ); - m_label->setFont( labelFont ); - - m_ratingWidget = new RatingWidget( this ); - m_ratingWidget->setRating( 0 ); - m_ratingWidget->setEnabled( false ); - - // Construct icon widgets - m_blingtofirst = new Plasma::IconWidget( this ); - m_blingtofirst->setIcon( KStandardDirs::locate( "data", "amarok/images/blingtofirst.png" ) ); - m_blingtofirst->setMaximumSize( 16.0, 16.0 ); - m_blingtofirst->setToolTip( i18n( "Jump to First" ) ); - - m_blingtolast = new Plasma::IconWidget( this ); - m_blingtolast->setIcon( KStandardDirs::locate( "data", "amarok/images/blingtolast.png" ) ); - m_blingtolast->setMaximumSize( 16.0, 16.0 ); - m_blingtolast->setToolTip( i18n( "Jump to Last" ) ); - - m_blingfastback = new Plasma::IconWidget( this ); - m_blingfastback->setIcon( KStandardDirs::locate( "data", "amarok/images/blingfastback.png" ) ); - m_blingfastback->setMaximumSize( 16.0, 16.0 ); - m_blingfastback->setToolTip( i18n( "Fast Backward" ) ); - - m_blingfastforward = new Plasma::IconWidget( this ); - m_blingfastforward->setIcon( KStandardDirs::locate( "data", "amarok/images/blingfastforward.png" ) ); - m_blingfastforward->setMaximumSize( 16.0, 16.0 ); - m_blingfastforward->setToolTip( i18n( "Fast Forward" ) ); - - m_fullscreen = new Plasma::IconWidget( this ); - m_fullscreen->setIcon( KStandardDirs::locate( "data", "amarok/images/blingfullscreen.png" ) ); - m_fullscreen->setMaximumSize( 16.0, 16.0 ); - m_fullscreen->setToolTip( i18n( "Maximize/Minimize" ) ); - - m_jumptoplaying = new Plasma::IconWidget( this ); - m_jumptoplaying->setIcon( KStandardDirs::locate( "data", "amarok/images/blingjumptoplaying.png" ) ); - m_jumptoplaying->setMaximumSize( 16.0, 16.0 ); - m_jumptoplaying->setToolTip( i18n( "Jump to Current" ) ); - - m_albumsearch = new Plasma::IconWidget( this ); - m_albumsearch->setIcon( KStandardDirs::locate( "data", "amarok/images/blingsearchalbum.png" ) ); - m_albumsearch->setMaximumSize( 18.0, 18.0 ); - m_albumsearch->setToolTip( i18n( "Toggle Album/Artist search" ) ); - m_editsearch = new SearchBarTextItem( this ); - m_editsearch->setTextInteractionFlags( Qt::TextEditorInteraction ); - labelFont.setItalic( true ); - m_editsearch->setFont( labelFont ); - m_editsearch->setDefaultTextColor( Qt::white ); - m_album_or_artist = true; - displaySearchName(); - - m_initrandompos = config.readEntry( "RandomPos", false ); - - if ( m_autojump ) - { - EngineController *engine = The::engineController(); - connect( engine, SIGNAL(trackPlaying(Meta::TrackPtr)), - this, SLOT(jumpToPlaying()) ); - } -} - -CoverBlingApplet::~CoverBlingApplet() -{ - delete m_ratingWidget; - delete m_label; - delete m_layout; - delete m_blingfastback; - delete m_blingfastforward; - delete m_blingtofirst; - delete m_blingtolast; - delete m_jumptoplaying; - delete m_albumsearch; - delete m_editsearch; -} - -void CoverBlingApplet::slotAlbumQueryResult( Meta::AlbumList albums ) //SLOT -{ - DEBUG_BLOCK - m_pictureflow->fillAlbums( albums ); - - connect( m_pictureflow, SIGNAL(centerIndexChanged(int)), this, SLOT(slideChanged(int)) ); - connect( m_pictureflow, SIGNAL(doubleClicked(int)), this, SLOT(slotDoubleClicked(int)) ); - connect( m_blingtofirst, SIGNAL(clicked()), this, SLOT(skipToFirst()) ); - connect( m_blingtolast, SIGNAL(clicked()), this, SLOT(skipToLast()) ); - connect( m_blingfastback, SIGNAL(clicked()), m_pictureflow, SLOT(fastBackward()) ); - connect( m_blingfastforward, SIGNAL(clicked()), m_pictureflow, SLOT(fastForward()) ); - connect( m_fullscreen, SIGNAL(clicked()), this, SLOT(toggleFullscreen()) ); - connect( m_jumptoplaying, SIGNAL(clicked()), this, SLOT(jumpToPlaying()) ); - connect( m_albumsearch, SIGNAL(clicked()), this, SLOT(switchSearchIcon()) ); - connect( m_editsearch, SIGNAL(editionValidated(QString)), this, SLOT(albumSearch(QString)) ); - if (m_initrandompos) - { - int nbAlbums = m_pictureflow->slideCount() -1; - int initial_pos = rand() % nbAlbums; - if ( m_animatejump ) - { - m_pictureflow->skipToSlide( initial_pos - 10 ); - m_pictureflow->showSlide( initial_pos ); - } - else - m_pictureflow->skipToSlide( initial_pos ); - slideChanged( initial_pos ); - } - constraintsEvent(); -} - -void CoverBlingApplet::slideChanged( int islideindex ) -{ - Meta::AlbumPtr album = m_pictureflow->album( islideindex ); - if ( album ) - { - Meta::ArtistPtr artist = album->albumArtist(); - QString label = album->prettyName(); - if ( artist ) label += " - " + artist->prettyName(); - m_label->setText( label ); - - //center the label - m_label->setPos( ( size().width() - m_label->boundingRect().width() ) / 2, m_label->y() ); - - m_label->show(); - int nbtracks = 0; - int rating = 0; - - foreach( Meta::TrackPtr track, album->tracks() ) - { - nbtracks++; - if ( track ) - rating += track->statistics()->rating(); - } - - if ( nbtracks ) - rating = rating / nbtracks; - - m_ratingWidget->setRating( rating ); - } -} - -void CoverBlingApplet::slotDoubleClicked( int islideindex ) -{ - Meta::AlbumPtr album = m_pictureflow->album( islideindex ); - if ( album ) - The::playlistController()->insertOptioned( album->tracks(), Playlist::OnDoubleClickOnSelectedItems ); -} - -void CoverBlingApplet::constraintsEvent( Plasma::Constraints constraints ) -{ - Q_UNUSED( constraints ) - - prepareGeometryChange(); - const int vertical_size = boundingRect().height(); - const int horizontal_size = boundingRect().width(); - QSize slideSize( vertical_size / 2, vertical_size / 2 ); - - if ( !m_fullsize ) - { - slideSize.setWidth( m_coversize ); - slideSize.setHeight( m_coversize ); - } - setMinimumHeight( 2 * m_coversize ); - m_pictureflow->setSlideSize( slideSize ); - m_pictureflow->setReflectionEffect( m_reflectionEffect ); - m_pictureflow->setAnimationTime( 10 ); - m_ratingWidget->setSpacing( 2 ); - m_ratingWidget->setPos( horizontal_size / 2 - 40, vertical_size - 30 ); - m_label ->setPos( horizontal_size / 2 - 40, vertical_size - 50 ); - - m_blingtofirst->setPos( 20, vertical_size - 30 ); - m_blingtolast->setPos( horizontal_size - 30, vertical_size - 30 ); - m_blingfastback->setPos( 50, vertical_size - 30 ); - m_blingfastforward->setPos( horizontal_size - 60, vertical_size - 30 ); - m_fullscreen->setPos( horizontal_size - 30, 30 ); - m_jumptoplaying->setPos( horizontal_size - 60, 30 ); - m_albumsearch->setPos( 20, 30 ); - m_editsearch->setPos( 38, 28 ); - m_pictureflow->resize( horizontal_size, vertical_size ); - - m_label->setPos( ( size().width() - m_label->boundingRect().width() ) / 2, m_label->y() ); -} - -void CoverBlingApplet::toggleFullscreen() -{ - if ( m_fullsize ) - { - resize( -1, -1 ); - } - else - { - //QDesktopWidget* desktop = QApplication::desktop(); - //if (desktop) - { - // QRect rect = desktop->screenGeometry(); - // resize(rect.width(),rect.height()); - resize( -1, 2 * m_coversize ); - } - } - updateConstraints(); - //constraintsEvent(); - m_fullsize = !m_fullsize; -} - -void CoverBlingApplet::createConfigurationInterface( KConfigDialog *parent ) -{ - KConfigGroup configuration = config(); - QWidget * const settings = new QWidget; - ui_Settings.setupUi( settings ); - - if ( m_reflectionEffect == PictureFlow::NoReflection ) - ui_Settings.reflectionEffectCombo->setCurrentIndex( 0 ); - else if ( m_reflectionEffect == PictureFlow::PlainReflection ) - ui_Settings.reflectionEffectCombo->setCurrentIndex( 1 ); - else if ( m_reflectionEffect == PictureFlow::BlurredReflection ) - ui_Settings.reflectionEffectCombo->setCurrentIndex( 2 ); - if ( m_coversize ) - ui_Settings.coversizeSpin->setValue( m_coversize ); - ui_Settings.autoJumpChk->setChecked( m_autojump ); - ui_Settings.animJumpChk->setChecked( m_animatejump ); - ui_Settings.randomPosChk->setChecked( m_initrandompos ); - //if (m_openGL) ui_Settings.renderingCombo->setCurrentIndex(1); - //else ui_Settings.renderingCombo->setCurrentIndex(0); - parent->addPage( settings, i18n( "Coverbling Settings" ), "preferences-system" ); - connect( parent, SIGNAL(accepted()), this, SLOT(saveSettings()) ); -} - -void CoverBlingApplet::saveSettings() -{ - m_coversize = ui_Settings.coversizeSpin->value(); - if ( ui_Settings.reflectionEffectCombo->currentIndex() == 0 ) - m_reflectionEffect = PictureFlow::NoReflection; - else if ( ui_Settings.reflectionEffectCombo->currentIndex() == 1 ) - m_reflectionEffect = PictureFlow::PlainReflection; - else if ( ui_Settings.reflectionEffectCombo->currentIndex() == 2 ) - m_reflectionEffect = PictureFlow::BlurredReflection; - //if (ui_Settings.renderingCombo->currentIndex()==1) - //m_openGL = true; - //else - //m_openGL = false; - m_autojump = ui_Settings.autoJumpChk->isChecked(); - m_animatejump = ui_Settings.animJumpChk->isChecked(); - m_initrandompos = ui_Settings.randomPosChk->isChecked(); - KConfigGroup config = Amarok::config( "CoverBling Applet" ); - config.writeEntry( "CoverSize", m_coversize ); - config.writeEntry( "ReflectionEffect", ( int ) m_reflectionEffect ); - config.writeEntry( "AutoJump", m_autojump ); - config.writeEntry( "AnimateJump", m_animatejump ); - config.writeEntry( "RandomPos", m_initrandompos ); - //config.writeEntry( "OpenGL", (int) m_openGL ); - - constraintsEvent(); -} - -void CoverBlingApplet::jumpToPlaying() -{ - Meta::TrackPtr track = The::engineController()->currentTrack(); - - if ( !track ) - return; - Meta::AlbumPtr album = track->album(); - if ( !album ) - return; - int center = m_pictureflow->centerIndex(); - if ( m_pictureflow->album( center ) == album ) - return; - int nbslides = m_pictureflow->slideCount(); - bool found = false; - int index = 0; - if ( nbslides > 0 ) - { - for ( int i = 0; i < nbslides;i++ ) - { - Meta::AlbumPtr current_album = m_pictureflow->album( i ); - if ( current_album == album ) - { - index = i; - found = true; - break; - } - } - if ( found ) - { - if ( m_animatejump ) - { - if ( center - index > 10 || index - center > 10 ) - { - if ( index > center ) - m_pictureflow->skipToSlide( index - 10 ); - else - m_pictureflow->skipToSlide( index + 10 ); - } - m_pictureflow->showSlide( index ); - } - else - m_pictureflow->skipToSlide( index ); - slideChanged( index ); - } - } -} -void CoverBlingApplet::skipToFirst() -{ - m_pictureflow->skipToSlide( 0 ); - slideChanged( 0 ); -} - -void CoverBlingApplet::skipToLast() -{ - int nbslides = m_pictureflow->slideCount(); - m_pictureflow->skipToSlide( nbslides - 1 ); - slideChanged( nbslides - 1 ); -} -void CoverBlingApplet::albumSearch( QString ialbumName ) -{ - QString album_name = ialbumName.remove( QChar( ' ' ) ); - int center = m_pictureflow->centerIndex(); - int nbslides = m_pictureflow->slideCount(); - bool found = false; - int index = 0; - if ( nbslides > 0 ) - { - for ( int i = 0; i < nbslides;i++ ) - { - Meta::AlbumPtr current_album = m_pictureflow->album( i ); - if ( !current_album ) continue; - QString current_name = ""; - if ( m_album_or_artist ) - { - current_name = current_album->prettyName(); - } - else - { - Meta::ArtistPtr artist = current_album->albumArtist(); - if ( artist ) current_name = artist->prettyName(); - } - current_name = current_name.remove( QChar( ' ' ) ); - if ( current_name.contains( album_name, Qt::CaseInsensitive ) ) - { - index = i; - found = true; - break; - } - } - if ( found ) - { - if ( m_animatejump ) - { - if ( center - index > 10 || index - center > 10 ) - { - if ( index > center ) - m_pictureflow->skipToSlide( index - 10 ); - else - m_pictureflow->skipToSlide( index + 10 ); - } - m_pictureflow->showSlide( index ); - } - else - m_pictureflow->skipToSlide( index ); - slideChanged( index ); - } - } - displaySearchName(); -} - -void CoverBlingApplet::switchSearchIcon() -{ - m_album_or_artist = !m_album_or_artist; - if ( m_album_or_artist ) - m_albumsearch->setIcon( KStandardDirs::locate( "data", "amarok/images/blingsearchalbum.png" ) ); - else - m_albumsearch->setIcon( KStandardDirs::locate( "data", "amarok/images/blingsearchartist.png" ) ); - displaySearchName(); -} -void CoverBlingApplet::displaySearchName() -{ - QString album_search_str = i18n( "Search for album..." ); - QString artist_search_str = i18n( "Search for artist..." ); - if ( m_album_or_artist) - m_editsearch->setPlainText( album_search_str ); - else - m_editsearch->setPlainText( artist_search_str ); -} -#include "moc_CoverBlingApplet.cpp" - diff --git a/amarok/playground/src/context/applets/coverbling/CoverBlingApplet.h b/amarok/playground/src/context/applets/coverbling/CoverBlingApplet.h deleted file mode 100644 index a29a40ab..00000000 --- a/amarok/playground/src/context/applets/coverbling/CoverBlingApplet.h +++ /dev/null @@ -1,94 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Simon Esneault * - * Copyright (c) 2010 Emmanuel Wagner * - * Copyright (c) 2010 Mark Kretschmann * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ -#ifndef COVERBLING_APPLET_H -#define COVERBLING_APPLET_H - -#include "context/Applet.h" -#include "context/DataEngine.h" -#include "PhotoBrowser.h" -#include "ui_coverblingSettings.h" - -class TextScrollingWidget; -class KConfigDialog; -class PhotosScrollWidget; -class QGraphicsSimpleTextItem; -class QGraphicsProxyWidget; -class RatingWidget; -class QGraphicsPixmapItem; -class SearchBarTextItem; - -namespace Plasma -{ - class IconWidget; -} - -class CoverBlingApplet : public Context::Applet -{ - Q_OBJECT - - public: - CoverBlingApplet( QObject* parent, const QVariantList& args ); - ~CoverBlingApplet(); - - void init(); - - public slots: - void slotAlbumQueryResult( Meta::AlbumList albums); - void slideChanged( int islideindex ); - void slotDoubleClicked( int islideindex ); - void toggleFullscreen(); - void jumpToPlaying(); - void saveSettings(); - void skipToFirst(); - void skipToLast(); - void albumSearch(QString ialbum); - void switchSearchIcon(); - void displaySearchName(); - protected : - virtual void constraintsEvent( Plasma::Constraints constraints = Plasma::AllConstraints ); - void createConfigurationInterface(KConfigDialog *parent); - - private: - PhotoBrowser * m_pictureflow; - QGraphicsProxyWidget * m_layout; - RatingWidget* m_ratingWidget; - QGraphicsSimpleTextItem* m_label; - - Plasma::IconWidget* m_blingtofirst; - Plasma::IconWidget* m_blingtolast; - Plasma::IconWidget* m_blingfastback; - Plasma::IconWidget* m_blingfastforward; - Plasma::IconWidget* m_fullscreen; - Plasma::IconWidget* m_jumptoplaying; - Plasma::IconWidget* m_albumsearch; - SearchBarTextItem* m_editsearch; - - bool m_fullsize; - bool m_autojump; - bool m_animatejump; - Ui::coverblingSettings ui_Settings; - int m_coversize; - PictureFlow::ReflectionEffect m_reflectionEffect; - bool m_openGL; - bool m_album_or_artist; - bool m_initrandompos; -}; - -AMAROK_EXPORT_APPLET( coverbling, CoverBlingApplet ) - -#endif /* COVERBLING_APPLET_H */ diff --git a/amarok/playground/src/context/applets/coverbling/ImageLoader.cpp b/amarok/playground/src/context/applets/coverbling/ImageLoader.cpp deleted file mode 100644 index 197efa00..00000000 --- a/amarok/playground/src/context/applets/coverbling/ImageLoader.cpp +++ /dev/null @@ -1,127 +0,0 @@ -/* PhotoFlow - animated image viewer for mobile devices - * - * Copyright (C) 2008 Ariya Hidayat (ariya.hidayat@gmail.com) - * Copyright (C) 2007 Ariya Hidayat (ariya.hidayat@gmail.com) - * - * This program 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 2 of the License, or (at your option) any later version. - * - * This library 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 this library; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA - * - */ - -#include "ImageLoader.h" - -#include "core/meta/Meta.h" - -#include -#include - -#include -// load and resize image - -ImageLoader::ImageLoader(): QThread(), - restart( false ), working( false ), idx( -1 ) -{ -} - -ImageLoader::~ImageLoader() -{ - mutex.lock(); - condition.wakeOne(); - mutex.unlock(); - wait(); -} - -bool ImageLoader::busy() const -{ - return isRunning() ? working : false; -} - -void ImageLoader::generate( int index, Meta::AlbumPtr iAlbum, QSize size ) -{ - mutex.lock(); - this->idx = index; - this->m_album = iAlbum; - this->size = size; - mutex.unlock(); - - if ( !isRunning() ) - start(); - else - { - // already running, wake up whenever ready - restart = true; - condition.wakeOne(); - } -} - -void ImageLoader::run() -{ - for ( ;; ) - { - // copy necessary data - mutex.lock(); - this->working = true; - Meta::AlbumPtr album_ptr = this->m_album; - QSize size = this->size; - mutex.unlock(); - - QImage image = PlainImageLoader::loadAndResize( album_ptr, size ); - - // let everyone knows it is ready - mutex.lock(); - this->working = false; - this->img = image; - mutex.unlock(); - - // put to sleep - mutex.lock(); - if ( !this->restart ) - condition.wait( &mutex ); - restart = false; - mutex.unlock(); - } -} - -PlainImageLoader::PlainImageLoader(): idx( -1 ) -{ -} - -void PlainImageLoader::generate( int index, Meta::AlbumPtr iAlbum, QSize size ) -{ - img = loadAndResize( iAlbum, size ); - idx = index; -} -QPixmap PlainImageLoader::GetPixmap(Meta::AlbumPtr iAlbum) -{ - QPixmap pixmap; - if ( iAlbum->hasImage() ) - { - pixmap = QPixmap::fromImage(iAlbum->image()); - } - else - { - pixmap = QPixmap( KStandardDirs::locate( "data", "amarok/images/blingdefaultcover.png" ) ); - } - return pixmap; -} -QImage PlainImageLoader::loadAndResize( Meta::AlbumPtr iAlbum, QSize size ) -{ - //qDebug() << <<"ImageLoader::loadAndresize()"; - QImage image; - QPixmap pixmap = GetPixmap(iAlbum); - image = pixmap.toImage(); - image = image.scaled( size, Qt::KeepAspectRatio, Qt::SmoothTransformation ); - return image; -} diff --git a/amarok/playground/src/context/applets/coverbling/ImageLoader.h b/amarok/playground/src/context/applets/coverbling/ImageLoader.h deleted file mode 100644 index 87880aed..00000000 --- a/amarok/playground/src/context/applets/coverbling/ImageLoader.h +++ /dev/null @@ -1,87 +0,0 @@ -/* PhotoFlow - animated image viewer for mobile devices - * - * Copyright (C) 2008 Ariya Hidayat (ariya.hidayat@gmail.com) - * Copyright (C) 2007 Ariya Hidayat (ariya.hidayat@gmail.com) - * - * This program 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 2 of the License, or (at your option) any later version. - * - * This library 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 this library; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA - * - */ - -#ifndef IMAGE_THUMBNAIL_H -#define IMAGE_THUMBNAIL_H - -#include "core/meta/forward_declarations.h" - -#include -#include -#include -#include - -#include -#include - -class ImageLoader : public QThread -{ -public: - ImageLoader(); - - ~ImageLoader(); - - // returns FALSE if worker is still busy and can't take the task - bool busy() const; - - void generate(int index, Meta::AlbumPtr iAlbum, QSize size); - - int index() const { return idx; } - - QImage result() const { return img; } - -protected: - void run(); - -private: - QMutex mutex; - QWaitCondition condition; - - bool restart; - bool working; - int idx; - Meta::AlbumPtr m_album; - QSize size; - QImage img; -}; - -class PlainImageLoader -{ -public: - PlainImageLoader(); - - bool busy() const { return false; } - - void generate(int index, Meta::AlbumPtr iAlbum, QSize size); - - int index() const { return idx; } - - QImage result() const { return img; } - - static QPixmap GetPixmap( Meta::AlbumPtr iAlbum); - static QImage loadAndResize( Meta::AlbumPtr iAlbum, QSize size ); -private: - int idx; - QImage img; -}; -#endif // IMAGE_THUMBNAIL_H - diff --git a/amarok/playground/src/context/applets/coverbling/PhotoBrowser.cpp b/amarok/playground/src/context/applets/coverbling/PhotoBrowser.cpp deleted file mode 100644 index 25f89879..00000000 --- a/amarok/playground/src/context/applets/coverbling/PhotoBrowser.cpp +++ /dev/null @@ -1,135 +0,0 @@ -/* PhotoFlow - animated image viewer for mobile devices - * - * Copyright (C) 2008 Ariya Hidayat (ariya.hidayat@gmail.com) - * Copyright (C) 2007 Ariya Hidayat (ariya.hidayat@gmail.com) - * - * This program 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 2 of the License, or (at your option) any later version. - * - * This library 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 this library; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA - * - */ - -#include "PhotoBrowser.h" - -#include "ImageLoader.h" -#include "pictureflow.h" - -#include -#include -#include -#include -#include "core/meta/Meta.h" - -#define ImageLoader PlainImageLoader - -class PhotoBrowser::Private -{ -public: - QString imagePath; - QTimer* updateTimer; - ImageLoader* worker; -}; - -PhotoBrowser::PhotoBrowser( QWidget* parent, bool enableOpenGL ): PictureFlow( parent,enableOpenGL) -{ - d = new Private; - - d->updateTimer = new QTimer; - connect( d->updateTimer, SIGNAL(timeout()), this, SLOT(updateImageData()) ); - d->worker = new ImageLoader; - connect( this, SIGNAL(centerIndexChanged(int)), this, SLOT(preload()) ); - m_opengl = enableOpenGL; -} - -PhotoBrowser::~PhotoBrowser() -{ - delete d->worker; - delete d->updateTimer; - delete d; -} -void PhotoBrowser::fillAlbums( Meta::AlbumList albums ) -{ - if (m_opengl) - setAlbums(albums); - else - { - foreach( Meta::AlbumPtr album, albums ) - { - addAlbum( album ); - addSlide( QImage() ); - } - setCenterIndex( 0 ); - preload(); - } -} -void PhotoBrowser::preload() -{ - d->updateTimer->start( 100 ); -} - -void PhotoBrowser::updateImageData() -{ - // can't do anything, wait for the next possibility - if ( d->worker->busy() ) - return; - - // set image of last one - if ( d->worker->index() >= 0 ) - setSlide( d->worker->index(), d->worker->result() ); - - // try to load only few images on the left and right side - // i.e. all visible ones plus some extra -#define COUNT 10 - int indexes[2*COUNT+1]; - int center = centerIndex(); - indexes[0] = center; - for ( int j = 0; j < COUNT; j++ ) - { - indexes[j*2+1] = center + j + 1; - indexes[j*2+2] = center - j - 1; - } - - for ( int c = 0; c < 2*COUNT + 1; c++ ) - { - int i = indexes[c]; - if (( i >= 0 ) && ( i < slideCount() ) ) - if ( slide( i ).isNull() ) - { - // schedule thumbnail generation - Meta::AlbumPtr iAlbum = m_album_list[i]; - d->worker->generate( i, iAlbum, slideSize() ); - return; - } - } - - // no need to generate anything? stop polling... - d->updateTimer->stop(); -} -void PhotoBrowser::fastForward() -{ - int nbslides = slideCount(); - int current = centerIndex(); - showSlide( current + nbslides / 10 ); -} -void PhotoBrowser::fastBackward() -{ - int nbslides = slideCount(); - int current = centerIndex(); - showSlide( current - nbslides / 10 ); -} -void PhotoBrowser::skipToSlide( int iSlide ) -{ - setCenterIndex( iSlide ); - preload(); -} diff --git a/amarok/playground/src/context/applets/coverbling/PhotoBrowser.h b/amarok/playground/src/context/applets/coverbling/PhotoBrowser.h deleted file mode 100644 index 569f8265..00000000 --- a/amarok/playground/src/context/applets/coverbling/PhotoBrowser.h +++ /dev/null @@ -1,53 +0,0 @@ -/* PhotoFlow - animated image viewer for mobile devices - * - * Copyright (C) 2008 Ariya Hidayat (ariya.hidayat@gmail.com) - * Copyright (C) 2007 Ariya Hidayat (ariya.hidayat@gmail.com) - * - * This program 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 2 of the License, or (at your option) any later version. - * - * This library 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 this library; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA - * - */ - -#ifndef PHOTO_BROWSER_H -#define PHOTO_BROWSER_H - -#include "pictureflow.h" -#include "core/meta/forward_declarations.h" - -class PhotoBrowser: public PictureFlow -{ - Q_OBJECT - -public: - explicit PhotoBrowser(QWidget* parent = 0, bool enableOpenGL = false); - virtual ~PhotoBrowser(); - - void fillAlbums(Meta::AlbumList albums); -public slots: - void fastForward(); - void fastBackward(); - void skipToSlide(int iSlide); - -private slots: - void preload(); - void updateImageData(); - -private: - class Private; - Private *d; -}; - -#endif // PHOTO_BROWSER_H - diff --git a/amarok/playground/src/context/applets/coverbling/SearchBarTextItem.cpp b/amarok/playground/src/context/applets/coverbling/SearchBarTextItem.cpp deleted file mode 100644 index 25d7ced7..00000000 --- a/amarok/playground/src/context/applets/coverbling/SearchBarTextItem.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Emmanuel Wagner * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - - -#include "SearchBarTextItem.h" -#include -#include - -SearchBarTextItem::SearchBarTextItem( QGraphicsItem* parent, QGraphicsScene* scene ) - - : QGraphicsTextItem( parent, scene ) -{ - QTextDocument* textDocument = document();//get document - if ( textDocument ) - textDocument->setMaximumBlockCount( 1 ); //i set max block count to 5 e.g. -} - -void SearchBarTextItem::keyPressEvent( QKeyEvent* Event ) - -{ - if ( Event ) - { - if ( Event->key() == Qt::Key_Return || Event->key() == Qt::Key_Enter ) - { - emit editionValidated( toPlainText() ); - } - } - QGraphicsTextItem::keyPressEvent( Event ); -} -void SearchBarTextItem::mousePressEvent ( QGraphicsSceneMouseEvent * event ) -{ - setPlainText( "" ); - QGraphicsTextItem::mousePressEvent( event ); -} diff --git a/amarok/playground/src/context/applets/coverbling/SearchBarTextItem.h b/amarok/playground/src/context/applets/coverbling/SearchBarTextItem.h deleted file mode 100644 index 1fbe03b4..00000000 --- a/amarok/playground/src/context/applets/coverbling/SearchBarTextItem.h +++ /dev/null @@ -1,33 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Emmanuel Wagner * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include -class QKeyEvent; - -class SearchBarTextItem : public QGraphicsTextItem - -{ - Q_OBJECT -public: - SearchBarTextItem( QGraphicsItem * parent = 0, QGraphicsScene * scene = 0 ); -signals: - void editionValidated( QString editioncontent ); -protected: - virtual void keyPressEvent( QKeyEvent* Event ); - virtual void mousePressEvent ( QGraphicsSceneMouseEvent * event ); -private: - QString m_content; -}; diff --git a/amarok/playground/src/context/applets/coverbling/amarok-context-applet-coverbling.desktop b/amarok/playground/src/context/applets/coverbling/amarok-context-applet-coverbling.desktop deleted file mode 100644 index 509e8d09..00000000 --- a/amarok/playground/src/context/applets/coverbling/amarok-context-applet-coverbling.desktop +++ /dev/null @@ -1,63 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Name=CoverBling -Name[bg]=CoverBling -Name[bs]=CoverBling -Name[ca]=CoverBling -Name[ca@valencia]=CoverBling -Name[cs]=CoverBling -Name[da]=CoverBling -Name[de]=CoverBling -Name[el]=CoverBling -Name[en_GB]=CoverBling -Name[es]=CoverBling -Name[et]=CoverBling -Name[eu]=Azal nabarmendua -Name[fi]=KansikuvaBling -Name[fr]=CoverBling -Name[ga]=CoverBling -Name[gl]=CoverBling -Name[hu]=Borítóböngésző -Name[id]=Sampul Polos -Name[is]=CoverBling -Name[it]=CoverBling -Name[ja]=CoverBling -Name[km]=CoverBling -Name[ko]=CoverBling -Name[lt]=CoverBling -Name[lv]=CoverBling -Name[nb]=CoverBling -Name[nds]=CoverBling -Name[nl]=CoverBling -Name[pl]=CoverBling -Name[pt]=Capas -Name[pt_BR]=Capas -Name[ro]=CoverBling -Name[ru]=Перелистывание обложек -Name[sk]=CoverBling -Name[sl]=CoverBling -Name[sr]=Омотација -Name[sr@ijekavian]=Омотација -Name[sr@ijekavianlatin]=Omotacija -Name[sr@latin]=Omotacija -Name[sv]=Omslagsutsmyckning -Name[tr]=CoverBling -Name[uk]=CoverBling -Name[x-test]=xxCoverBlingxx -Name[zh_CN]=封面闪烁 -Name[zh_TW]=CoverBling -Type=Service -ServiceTypes=Plasma/Applet - -X-KDE-Library=amarok_context_applet_coverbling -X-KDE-PluginInfo-Author=manuw2009 -X-KDE-PluginInfo-Email=manu.wagner@sfr.fr -X-KDE-PluginInfo-Name=coverbling -X-KDE-PluginInfo-Version=0.10 -X-KDE-PluginInfo-Website= -X-KDE-PluginInfo-Category= -X-KDE-PluginInfo-Depends= -X-KDE-PluginInfo-License=GPL -X-KDE-PluginInfo-EnabledByDefault=true -X-KDE-ParentApp=amarok -X-KDE-PluginInfo-Category=Current diff --git a/amarok/playground/src/context/applets/coverbling/blingdefaultcover.png b/amarok/playground/src/context/applets/coverbling/blingdefaultcover.png deleted file mode 100644 index 992575a4..00000000 Binary files a/amarok/playground/src/context/applets/coverbling/blingdefaultcover.png and /dev/null differ diff --git a/amarok/playground/src/context/applets/coverbling/blingfastback.png b/amarok/playground/src/context/applets/coverbling/blingfastback.png deleted file mode 100644 index 572a9a9b..00000000 Binary files a/amarok/playground/src/context/applets/coverbling/blingfastback.png and /dev/null differ diff --git a/amarok/playground/src/context/applets/coverbling/blingfastforward.png b/amarok/playground/src/context/applets/coverbling/blingfastforward.png deleted file mode 100644 index e4035cd8..00000000 Binary files a/amarok/playground/src/context/applets/coverbling/blingfastforward.png and /dev/null differ diff --git a/amarok/playground/src/context/applets/coverbling/blingfullscreen.png b/amarok/playground/src/context/applets/coverbling/blingfullscreen.png deleted file mode 100644 index 681b0263..00000000 Binary files a/amarok/playground/src/context/applets/coverbling/blingfullscreen.png and /dev/null differ diff --git a/amarok/playground/src/context/applets/coverbling/blingjumptoplaying.png b/amarok/playground/src/context/applets/coverbling/blingjumptoplaying.png deleted file mode 100644 index da1ea3ee..00000000 Binary files a/amarok/playground/src/context/applets/coverbling/blingjumptoplaying.png and /dev/null differ diff --git a/amarok/playground/src/context/applets/coverbling/blingsearchalbum.png b/amarok/playground/src/context/applets/coverbling/blingsearchalbum.png deleted file mode 100644 index f185f9ff..00000000 Binary files a/amarok/playground/src/context/applets/coverbling/blingsearchalbum.png and /dev/null differ diff --git a/amarok/playground/src/context/applets/coverbling/blingsearchartist.png b/amarok/playground/src/context/applets/coverbling/blingsearchartist.png deleted file mode 100644 index 8f0f3e00..00000000 Binary files a/amarok/playground/src/context/applets/coverbling/blingsearchartist.png and /dev/null differ diff --git a/amarok/playground/src/context/applets/coverbling/blingtofirst.png b/amarok/playground/src/context/applets/coverbling/blingtofirst.png deleted file mode 100644 index e9840069..00000000 Binary files a/amarok/playground/src/context/applets/coverbling/blingtofirst.png and /dev/null differ diff --git a/amarok/playground/src/context/applets/coverbling/blingtolast.png b/amarok/playground/src/context/applets/coverbling/blingtolast.png deleted file mode 100644 index e3f18115..00000000 Binary files a/amarok/playground/src/context/applets/coverbling/blingtolast.png and /dev/null differ diff --git a/amarok/playground/src/context/applets/coverbling/coverblingSettings.ui b/amarok/playground/src/context/applets/coverbling/coverblingSettings.ui deleted file mode 100644 index bdc01278..00000000 --- a/amarok/playground/src/context/applets/coverbling/coverblingSettings.ui +++ /dev/null @@ -1,122 +0,0 @@ - - - coverblingSettings - - - - 0 - 0 - 265 - 146 - - - - - - 20 - 20 - 101 - 31 - - - - Reflection effect - - - - - - 20 - 60 - 101 - 16 - - - - Cover size (pixels) - - - - - - 150 - 60 - 51 - 21 - - - - 10 - - - 500 - - - - - - 150 - 20 - 101 - 26 - - - - - None - - - - - Plain - - - - - Blurred - - - - - - - 20 - 90 - 141 - 16 - - - - Auto jump to playing - - - - - - 20 - 110 - 141 - 16 - - - - Animated jump - - - - - - 20 - 130 - 141 - 16 - - - - Random initial position - - - - - - diff --git a/amarok/playground/src/context/applets/coverbling/pictureflow.cpp b/amarok/playground/src/context/applets/coverbling/pictureflow.cpp deleted file mode 100644 index 8febe161..00000000 --- a/amarok/playground/src/context/applets/coverbling/pictureflow.cpp +++ /dev/null @@ -1,1173 +0,0 @@ -/* - PictureFlow - animated image show widget - http://pictureflow.googlecode.com - Copyright (C) 2010 Emmanuel Wagner (manu.wagner@sfr.fr) - Ariya's code modifications for amarok - Copyright (C) 2008 Ariya Hidayat (ariya@kde.org) - Copyright (C) 2007 Ariya Hidayat (ariya@kde.org) - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. -*/ - -#include "pictureflow.h" - -#include "core/meta/Meta.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -// for fixed-point arithmetic, we need minimum 32-bit long -// long long (64-bit) might be useful for multiplication and division -typedef long PFreal; -#define PFREAL_SHIFT 10 -#define PFREAL_ONE (1 << PFREAL_SHIFT) - -#define IANGLE_MAX 1024 -#define IANGLE_MASK 1023 - -inline PFreal fmul( PFreal a, PFreal b ) -{ - return (( long long )( a ) )*(( long long )( b ) ) >> PFREAL_SHIFT; -} - -inline PFreal fdiv( PFreal num, PFreal den ) -{ - long long p = ( long long )( num ) << ( PFREAL_SHIFT * 2 ); - long long q = p / ( long long )den; - long long r = q >> PFREAL_SHIFT; - - return r; -} - -inline PFreal fsin( int iangle ) -{ - // warning: regenerate the table if IANGLE_MAX and PFREAL_SHIFT are changed! - static const PFreal tab[] = - { - 3, 103, 202, 300, 394, 485, 571, 652, - 726, 793, 853, 904, 947, 980, 1004, 1019, - 1023, 1018, 1003, 978, 944, 901, 849, 789, - 721, 647, 566, 479, 388, 294, 196, 97, - -4, -104, -203, -301, -395, -486, -572, -653, - -727, -794, -854, -905, -948, -981, -1005, -1020, - -1024, -1019, -1004, -979, -945, -902, -850, -790, - -722, -648, -567, -480, -389, -295, -197, -98, - 3 - }; - - while ( iangle < 0 ) - iangle += IANGLE_MAX; - iangle &= IANGLE_MASK; - - int i = ( iangle >> 4 ); - PFreal p = tab[i]; - PFreal q = tab[( i+1 )]; - PFreal g = ( q - p ); - return p + g * ( iangle - i*16 ) / 16; -} - -inline PFreal fcos( int iangle ) -{ - return fsin( iangle + ( IANGLE_MAX >> 2 ) ); -} - -/* ---------------------------------------------------------- - -PictureFlowState stores the state of all slides, i.e. all the necessary -information to be able to render them. - -PictureFlowAnimator is responsible to move the slides during the -transition between slides, to achieve the effect similar to Cover Flow, -by changing the state. - -PictureFlowSoftwareRenderer (or PictureFlowOpenGLRenderer) is -the actual 3-d renderer. It should render all slides given the state -(an instance of PictureFlowState). - -Instances of all the above three classes are stored in -PictureFlowPrivate. - -------------------------------------------------------- */ - -struct SlideInfo -{ - int slideIndex; - int angle; - PFreal cx; - PFreal cy; - int blend; -}; - -class PictureFlowState -{ -public: - PictureFlowState(); - ~PictureFlowState(); - - void reposition(); - void reset(); - - QRgb backgroundColor; - int slideWidth; - int slideHeight; - PictureFlow::ReflectionEffect reflectionEffect; - QVector slideImages; - - int angle; - int spacing; - PFreal offsetX; - PFreal offsetY; - - SlideInfo centerSlide; - QVector leftSlides; - QVector rightSlides; - int centerIndex; -}; - -class PictureFlowAnimator -{ -public: - PictureFlowAnimator(); - PictureFlowState* state; - - void start( int slide ); - void stop( int slide ); - void update(); - - int target; - int step; - int frame; - QTimer animateTimer; - int animationDuration; -}; - -class PictureFlowAbstractRenderer -{ -public: - PictureFlowAbstractRenderer(): state( 0 ), dirty( false ), widget( 0 ) {} - virtual ~PictureFlowAbstractRenderer() {} - - PictureFlowState* state; - bool dirty; - QWidget* widget; - QPainter::RenderHints render_hints; - virtual void init() = 0; - virtual void paint() = 0; -}; - -class PictureFlowSoftwareRenderer: public PictureFlowAbstractRenderer -{ -public: - PictureFlowSoftwareRenderer(); - ~PictureFlowSoftwareRenderer(); - - virtual void init(); - virtual void paint(); - -private: - QSize size; - QRgb bgcolor; - int effect; - QImage buffer; - QVector rays; - QImage* blankSurface; - QCache surfaceCache; - QHash imageHash; - - void render(); - void renderSlides(); - QRect renderSlide( const SlideInfo &slide, int col1 = -1, int col2 = -1 ); - QImage* surface( int slideIndex ); -}; - -class PictureFlowOpenGLRenderer: public PictureFlowAbstractRenderer -{ -public: - PictureFlowOpenGLRenderer(); - ~PictureFlowOpenGLRenderer(); - void init(); - void paint(); -private : - QSize size; - QRgb bgcolor; - int effect; - QImage* blankSurface; -}; - -PictureFlowOpenGLRenderer::PictureFlowOpenGLRenderer(): - PictureFlowAbstractRenderer(), size( 0, 0 ), bgcolor( 0 ), effect( -1 ), blankSurface( 0 ) -{ -} -PictureFlowOpenGLRenderer::~PictureFlowOpenGLRenderer() -{ -} -void PictureFlowOpenGLRenderer::init() -{ -} -void PictureFlowOpenGLRenderer::paint() -{ -} -// ------------- PictureFlowState --------------------------------------- - -PictureFlowState::PictureFlowState(): - backgroundColor( 0 ), slideWidth( 150 ), slideHeight( 200 ), - reflectionEffect( PictureFlow::BlurredReflection ), centerIndex( 0 ) -{ -} - -PictureFlowState::~PictureFlowState() -{ - for ( int i = 0; i < ( int )slideImages.count(); i++ ) - delete slideImages[i]; -} - -// readjust the settings, call this when slide dimension is changed -void PictureFlowState::reposition() -{ - angle = 70 * IANGLE_MAX / 360; // approx. 70 degrees tilted - - offsetX = slideWidth / 2 * ( PFREAL_ONE - fcos( angle ) ); - offsetY = slideWidth / 2 * fsin( angle ); - offsetX += slideWidth * PFREAL_ONE; - offsetY += slideWidth * PFREAL_ONE / 4; - spacing = 40; -} - -// adjust slides so that they are in "steady state" position -void PictureFlowState::reset() -{ - centerSlide.angle = 0; - centerSlide.cx = 0; - centerSlide.cy = 0; - centerSlide.slideIndex = centerIndex; - centerSlide.blend = 256; - - leftSlides.resize( 6 ); - for ( int i = 0; i < ( int )leftSlides.count(); i++ ) - { - SlideInfo& si = leftSlides[i]; - si.angle = angle; - si.cx = -( offsetX + spacing * i * PFREAL_ONE ); - si.cy = offsetY; - si.slideIndex = centerIndex - 1 - i; - si.blend = 256; - if ( i == ( int )leftSlides.count() - 2 ) - si.blend = 128; - if ( i == ( int )leftSlides.count() - 1 ) - si.blend = 0; - } - - rightSlides.resize( 6 ); - for ( int i = 0; i < ( int )rightSlides.count(); i++ ) - { - SlideInfo& si = rightSlides[i]; - si.angle = -angle; - si.cx = offsetX + spacing * i * PFREAL_ONE; - si.cy = offsetY; - si.slideIndex = centerIndex + 1 + i; - si.blend = 256; - if ( i == ( int )rightSlides.count() - 2 ) - si.blend = 128; - if ( i == ( int )rightSlides.count() - 1 ) - si.blend = 0; - } -} - -// ------------- PictureFlowAnimator --------------------------------------- - -PictureFlowAnimator::PictureFlowAnimator(): - state( 0 ), target( 0 ), step( 0 ), frame( 0 ), animationDuration( 30 ) -{ -} - -void PictureFlowAnimator::start( int slide ) -{ - target = slide; - if ( !animateTimer.isActive() && state ) - { - step = ( target < state->centerSlide.slideIndex ) ? -1 : 1; - animateTimer.start( animationDuration ); - } -} - -void PictureFlowAnimator::stop( int slide ) -{ - step = 0; - target = slide; - frame = slide << 16; - animateTimer.stop(); -} - -void PictureFlowAnimator::update() -{ - if ( !animateTimer.isActive() ) - return; - if ( step == 0 ) - return; - if ( !state ) - return; - - int speed = 16384 / 4; - -#if 1 - // deaccelerate when approaching the target - const int max = 2 * 65536; - - int fi = frame; - fi -= ( target << 16 ); - if ( fi < 0 ) - fi = -fi; - fi = qMin( fi, max ); - - int ia = IANGLE_MAX * ( fi - max / 2 ) / ( max * 2 ); - speed = 512 + 16384 * ( PFREAL_ONE + fsin( ia ) ) / PFREAL_ONE; -#endif - - frame += speed * step; - - int index = frame >> 16; - int pos = frame & 0xffff; - int neg = 65536 - pos; - int tick = ( step < 0 ) ? neg : pos; - PFreal ftick = ( tick * PFREAL_ONE ) >> 16; - - if ( step < 0 ) - index++; - - if ( state->centerIndex != index ) - { - state->centerIndex = index; - frame = index << 16; - state->centerSlide.slideIndex = state->centerIndex; - for ( int i = 0; i < ( int )state->leftSlides.count(); i++ ) - state->leftSlides[i].slideIndex = state->centerIndex - 1 - i; - for ( int i = 0; i < ( int )state->rightSlides.count(); i++ ) - state->rightSlides[i].slideIndex = state->centerIndex + 1 + i; - } - - state->centerSlide.angle = ( step * tick * state->angle ) >> 16; - state->centerSlide.cx = -step * fmul( state->offsetX, ftick ); - state->centerSlide.cy = fmul( state->offsetY, ftick ); - - if ( state->centerIndex == target ) - { - stop( target ); - state->reset(); - return; - } - - for ( int i = 0; i < ( int )state->leftSlides.count(); i++ ) - { - SlideInfo& si = state->leftSlides[i]; - si.angle = state->angle; - si.cx = -( state->offsetX + state->spacing * i * PFREAL_ONE + step * state->spacing * ftick ); - si.cy = state->offsetY; - } - - for ( int i = 0; i < ( int )state->rightSlides.count(); i++ ) - { - SlideInfo& si = state->rightSlides[i]; - si.angle = -state->angle; - si.cx = state->offsetX + state->spacing * i * PFREAL_ONE - step * state->spacing * ftick; - si.cy = state->offsetY; - } - - if ( step > 0 ) - { - PFreal ftick = ( neg * PFREAL_ONE ) >> 16; - state->rightSlides[0].angle = -( neg * state->angle ) >> 16; - state->rightSlides[0].cx = fmul( state->offsetX, ftick ); - state->rightSlides[0].cy = fmul( state->offsetY, ftick ); - } - else - { - PFreal ftick = ( pos * PFREAL_ONE ) >> 16; - state->leftSlides[0].angle = ( pos * state->angle ) >> 16; - state->leftSlides[0].cx = -fmul( state->offsetX, ftick ); - state->leftSlides[0].cy = fmul( state->offsetY, ftick ); - } - - // must change direction ? - if ( target < index ) if ( step > 0 ) - step = -1; - if ( target > index ) if ( step < 0 ) - step = 1; - - // the first and last slide must fade in/fade out - int nleft = state->leftSlides.count(); - int nright = state->rightSlides.count(); - int fade = pos / 256; - - for ( int index = 0; index < nleft; index++ ) - { - int blend = 256; - if ( index == nleft - 1 ) - blend = ( step > 0 ) ? 0 : 128 - fade / 2; - if ( index == nleft - 2 ) - blend = ( step > 0 ) ? 128 - fade / 2 : 256 - fade / 2; - if ( index == nleft - 3 ) - blend = ( step > 0 ) ? 256 - fade / 2 : 256; - state->leftSlides[index].blend = blend; - } - for ( int index = 0; index < nright; index++ ) - { - int blend = ( index < nright - 2 ) ? 256 : 128; - if ( index == nright - 1 ) - blend = ( step > 0 ) ? fade / 2 : 0; - if ( index == nright - 2 ) - blend = ( step > 0 ) ? 128 + fade / 2 : fade / 2; - if ( index == nright - 3 ) - blend = ( step > 0 ) ? 256 : 128 + fade / 2; - state->rightSlides[index].blend = blend; - } - -} - -// ------------- PictureFlowSoftwareRenderer --------------------------------------- - -PictureFlowSoftwareRenderer::PictureFlowSoftwareRenderer(): - PictureFlowAbstractRenderer(), size( 0, 0 ), bgcolor( 0 ), effect( -1 ), blankSurface( 0 ) -{ -} - -PictureFlowSoftwareRenderer::~PictureFlowSoftwareRenderer() -{ - surfaceCache.clear(); - buffer = QImage(); - delete blankSurface; -} - -void PictureFlowSoftwareRenderer::paint() -{ - if ( !widget ) - return; - - if ( widget->size() != size ) - init(); - - if ( state->backgroundColor != bgcolor ) - { - bgcolor = state->backgroundColor; - surfaceCache.clear(); - } - - if (( int )( state->reflectionEffect ) != effect ) - { - effect = ( int )state->reflectionEffect; - surfaceCache.clear(); - } - - if ( dirty ) - render(); - - QPainter painter( widget ); - painter.setRenderHints( render_hints ); - painter.drawImage( QPoint( 0, 0 ), buffer ); -} - -void PictureFlowSoftwareRenderer::init() -{ - if ( !widget ) - return; - - surfaceCache.clear(); - blankSurface = 0; - - size = widget->size(); - int ww = size.width(); - int wh = size.height(); - int w = ( ww + 1 ) / 2; - int h = ( wh + 1 ) / 2; - - buffer = QImage( ww, wh, QImage::Format_RGB32 ); - buffer.fill( bgcolor ); - - rays.resize( w*2 ); - for ( int i = 0; i < w; i++ ) - { - PFreal gg = (( PFREAL_ONE >> 1 ) + i * PFREAL_ONE ) / ( 2 * h ); - rays[w-i-1] = -gg; - rays[w+i] = gg; - } - - dirty = true; -} - -// TODO: optimize this with lookup tables -static QRgb blendColor( QRgb c1, QRgb c2, int blend ) -{ - int r = qRed( c1 ) * blend / 256 + qRed( c2 ) * ( 256 - blend ) / 256; - int g = qGreen( c1 ) * blend / 256 + qGreen( c2 ) * ( 256 - blend ) / 256; - int b = qBlue( c1 ) * blend / 256 + qBlue( c2 ) * ( 256 - blend ) / 256; - return qRgb( r, g, b ); -} - - -static QImage* prepareSurface( const QImage* slideImage, int w, int h, QRgb bgcolor, - PictureFlow::ReflectionEffect reflectionEffect ) -{ - - Qt::TransformationMode mode = Qt::SmoothTransformation; - QImage img = slideImage->scaled( w, h, Qt::IgnoreAspectRatio, mode ); - - // slightly larger, to accommodate for the reflection - int hs = h * 2; - int hofs = h / 3; - - // offscreen buffer: black is sweet - QImage* result = new QImage( hs, w, QImage::Format_RGB32 ); - result->fill( bgcolor ); - - // transpose the image, this is to speed-up the rendering - // because we process one column at a time - // (and much better and faster to work row-wise, i.e in one scanline) - for ( int x = 0; x < w; x++ ) - for ( int y = 0; y < h; y++ ) - result->setPixel( hofs + y, x, img.pixel( x, y ) ); - - if ( reflectionEffect != PictureFlow::NoReflection ) - { - // create the reflection - int ht = hs - h - hofs; - int hte = ht; - for ( int x = 0; x < w; x++ ) - for ( int y = 0; y < ht; y++ ) - { - QRgb color = img.pixel( x, img.height() - y - 1 ); - result->setPixel( h + hofs + y, x, blendColor( color, bgcolor, 128*( hte - y ) / hte ) ); - } - - if ( reflectionEffect == PictureFlow::BlurredReflection ) - { - // blur the reflection everything first - // Based on exponential blur algorithm by Jani Huhtanen - QRect rect( hs / 2, 0, hs / 2, w ); - rect &= result->rect(); - - int r1 = rect.top(); - int r2 = rect.bottom(); - int c1 = rect.left(); - int c2 = rect.right(); - - int bpl = result->bytesPerLine(); - int rgba[4]; - unsigned char* p; - - // how many times blur is applied? - // for low-end system, limit this to only 1 loop - for ( int loop = 0; loop < 2; loop++ ) - { - for ( int col = c1; col <= c2; col++ ) - { - p = result->scanLine( r1 ) + col * 4; - for ( int i = 0; i < 3; i++ ) - rgba[i] = p[i] << 4; - - p += bpl; - for ( int j = r1; j < r2; j++, p += bpl ) - for ( int i = 0; i < 3; i++ ) - p[i] = ( rgba[i] += ((( p[i] << 4 ) - rgba[i] ) ) >> 1 ) >> 4; - } - - for ( int row = r1; row <= r2; row++ ) - { - p = result->scanLine( row ) + c1 * 4; - for ( int i = 0; i < 3; i++ ) - rgba[i] = p[i] << 4; - - p += 4; - for ( int j = c1; j < c2; j++, p += 4 ) - for ( int i = 0; i < 3; i++ ) - p[i] = ( rgba[i] += ((( p[i] << 4 ) - rgba[i] ) ) >> 1 ) >> 4; - } - - for ( int col = c1; col <= c2; col++ ) - { - p = result->scanLine( r2 ) + col * 4; - for ( int i = 0; i < 3; i++ ) - rgba[i] = p[i] << 4; - - p -= bpl; - for ( int j = r1; j < r2; j++, p -= bpl ) - for ( int i = 0; i < 3; i++ ) - p[i] = ( rgba[i] += ((( p[i] << 4 ) - rgba[i] ) ) >> 1 ) >> 4; - } - - for ( int row = r1; row <= r2; row++ ) - { - p = result->scanLine( row ) + c2 * 4; - for ( int i = 0; i < 3; i++ ) - rgba[i] = p[i] << 4; - - p -= 4; - for ( int j = c1; j < c2; j++, p -= 4 ) - for ( int i = 0; i < 3; i++ ) - p[i] = ( rgba[i] += ((( p[i] << 4 ) - rgba[i] ) ) >> 1 ) >> 4; - } - } - - // overdraw to leave only the reflection blurred (but not the actual image) - for ( int x = 0; x < w; x++ ) - for ( int y = 0; y < h; y++ ) - result->setPixel( hofs + y, x, img.pixel( x, y ) ); - } - } - - return result; -} - -QImage* PictureFlowSoftwareRenderer::surface( int slideIndex ) -{ - if ( !state ) - return 0; - if ( slideIndex < 0 ) - return 0; - if ( slideIndex >= ( int )state->slideImages.count() ) - return 0; - - int key = slideIndex; - - QImage* img = state->slideImages.at( slideIndex ); - bool empty = img ? img->isNull() : true; - if ( empty ) - { - surfaceCache.remove( key ); - imageHash.remove( slideIndex ); - if ( !blankSurface ) - { - int sw = state->slideWidth; - int sh = state->slideHeight; - - QImage img = QImage( sw, sh, QImage::Format_RGB32 ); - - QPainter painter( &img ); - painter.setRenderHints( render_hints ); - QPoint p1( sw*4 / 10, 0 ); - QPoint p2( sw*6 / 10, sh ); - QLinearGradient linearGrad( p1, p2 ); - linearGrad.setColorAt( 0, Qt::black ); - linearGrad.setColorAt( 1, Qt::white ); - painter.setBrush( linearGrad ); - painter.fillRect( 0, 0, sw, sh, QBrush( linearGrad ) ); - - painter.setPen( QPen( QColor( 64, 64, 64 ), 4 ) ); - painter.setBrush( QBrush() ); - painter.drawRect( 2, 2, sw - 3, sh - 3 ); - painter.end(); - - blankSurface = prepareSurface( &img, sw, sh, bgcolor, state->reflectionEffect ); - } - return blankSurface; - } - bool exist = imageHash.contains( slideIndex ); - if ( exist ) - if ( img == imageHash.find( slideIndex ).value() ) - if ( surfaceCache.contains( key ) ) - return surfaceCache[key]; - - QImage* sr = prepareSurface( img, state->slideWidth, state->slideHeight, bgcolor, state->reflectionEffect ); - surfaceCache.insert( key, sr ); - imageHash.insert( slideIndex, img ); - - return sr; -} - -// Renders a slide to offscreen buffer. Returns a rect of the rendered area. -// col1 and col2 limit the column for rendering. -QRect PictureFlowSoftwareRenderer::renderSlide( const SlideInfo &slide, int col1, int col2 ) -{ - int blend = slide.blend; - if ( !blend ) - return QRect(); - - QImage* src = surface( slide.slideIndex ); - if ( !src ) - return QRect(); - - QRect rect( 0, 0, 0, 0 ); - - int sw = src->height(); - int sh = src->width(); - int h = buffer.height(); - int w = buffer.width(); - - if ( col1 > col2 ) - { - int c = col2; - col2 = col1; - col1 = c; - } - - col1 = ( col1 >= 0 ) ? col1 : 0; - col2 = ( col2 >= 0 ) ? col2 : w - 1; - col1 = qMin( col1, w - 1 ); - col2 = qMin( col2, w - 1 ); - - int zoom = 100; - int distance = h * 100 / zoom; - PFreal sdx = fcos( slide.angle ); - PFreal sdy = fsin( slide.angle ); - PFreal xs = slide.cx - state->slideWidth * sdx / 2; - PFreal ys = slide.cy - state->slideWidth * sdy / 2; - PFreal dist = distance * PFREAL_ONE; - - int xi = qMax(( PFreal )0, (( w * PFREAL_ONE / 2 ) + fdiv( xs * h, dist + ys ) ) >> PFREAL_SHIFT ); - if ( xi >= w ) - return rect; - - bool flag = false; - rect.setLeft( xi ); - for ( int x = qMax( xi, col1 ); x <= col2; x++ ) - { - PFreal hity = 0; - PFreal fk = rays[x]; - if ( sdy ) - { - fk = fk - fdiv( sdx, sdy ); - hity = -fdiv(( rays[x] * distance - slide.cx + slide.cy * sdx / sdy ), fk ); - } - - dist = distance * PFREAL_ONE + hity; - if ( dist < 0 ) - continue; - - PFreal hitx = fmul( dist, rays[x] ); - PFreal hitdist = fdiv( hitx - slide.cx, sdx ); - - int column = sw / 2 + ( hitdist >> PFREAL_SHIFT ); - if ( column >= sw ) - break; - if ( column < 0 ) - continue; - - rect.setRight( x ); - if ( !flag ) - rect.setLeft( x ); - flag = true; - - int y1 = h / 2; - int y2 = y1 + 1; - QRgb* pixel1 = ( QRgb* )( buffer.scanLine( y1 ) ) + x; - QRgb* pixel2 = ( QRgb* )( buffer.scanLine( y2 ) ) + x; - QRgb pixelstep = pixel2 - pixel1; - - int center = ( sh / 2 ); - int dy = dist / h; - int p1 = center * PFREAL_ONE - dy / 2; - int p2 = center * PFREAL_ONE + dy / 2; - - const QRgb *ptr = ( const QRgb* )( src->scanLine( column ) ); - if ( blend == 256 ) - while (( y1 >= 0 ) && ( y2 < h ) && ( p1 >= 0 ) ) - { - *pixel1 = ptr[p1 >> PFREAL_SHIFT]; - *pixel2 = ptr[p2 >> PFREAL_SHIFT]; - p1 -= dy; - p2 += dy; - y1--; - y2++; - pixel1 -= pixelstep; - pixel2 += pixelstep; - } - else - while (( y1 >= 0 ) && ( y2 < h ) && ( p1 >= 0 ) ) - { - QRgb c1 = ptr[p1 >> PFREAL_SHIFT]; - QRgb c2 = ptr[p2 >> PFREAL_SHIFT]; - *pixel1 = blendColor( c1, bgcolor, blend ); - *pixel2 = blendColor( c2, bgcolor, blend ); - p1 -= dy; - p2 += dy; - y1--; - y2++; - pixel1 -= pixelstep; - pixel2 += pixelstep; - } - } - - rect.setTop( 0 ); - rect.setBottom( h - 1 ); - return rect; -} - -void PictureFlowSoftwareRenderer::renderSlides() -{ - int nleft = state->leftSlides.count(); - int nright = state->rightSlides.count(); - - QRect r = renderSlide( state->centerSlide ); - int c1 = r.left(); - int c2 = r.right(); - - for ( int index = 0; index < nleft; index++ ) - { - QRect rs = renderSlide( state->leftSlides[index], 0, c1 - 1 ); - if ( !rs.isEmpty() ) - c1 = rs.left(); - } - for ( int index = 0; index < nright; index++ ) - { - QRect rs = renderSlide( state->rightSlides[index], c2 + 1, buffer.width() ); - if ( !rs.isEmpty() ) - c2 = rs.right(); - } -} - -// Render the slides. Updates only the offscreen buffer. -void PictureFlowSoftwareRenderer::render() -{ - buffer.fill( state->backgroundColor ); - renderSlides(); - dirty = false; -} - -// ----------------------------------------- - -class PictureFlowPrivate -{ -public: - PictureFlowState* state; - PictureFlowAnimator* animator; - PictureFlowAbstractRenderer* renderer; - QTimer triggerTimer; -}; - - -PictureFlow::PictureFlow( QWidget* parent, bool enableOpenGL): QWidget( parent ) -{ - d = new PictureFlowPrivate; - m_opengl = enableOpenGL; - //m_openglwidget = 0; - d->state = new PictureFlowState; - d->state->reset(); - d->state->reposition(); - - if (!m_opengl) - { - d->renderer = new PictureFlowSoftwareRenderer; - d->renderer->widget = this; - } - else - { - d->renderer = new PictureFlowOpenGLRenderer; - //m_openglwidget = new CoverBling(0,m_album_list); - //m_openglwidget->setParent(this); - } - d->renderer->state = d->state; - d->renderer->init(); - - d->animator = new PictureFlowAnimator; - d->animator->state = d->state; - QObject::connect( &d->animator->animateTimer, SIGNAL(timeout()), this, SLOT(updateAnimation()) ); - - QObject::connect( &d->triggerTimer, SIGNAL(timeout()), this, SLOT(render()) ); - setAttribute( Qt::WA_StaticContents, true ); - setAttribute( Qt::WA_OpaquePaintEvent, true ); - setAttribute( Qt::WA_NoSystemBackground, true ); -} - -PictureFlow::~PictureFlow() -{ - delete d->renderer; - delete d->animator; - delete d->state; - delete d; -} -void PictureFlow::setOpenGLMode(bool activateOpenGL) -{ - m_opengl = activateOpenGL; -} -int PictureFlow::slideCount() const -{ - return d->state->slideImages.count(); -} - -QColor PictureFlow::backgroundColor() const -{ - return QColor( d->state->backgroundColor ); -} - -void PictureFlow::setBackgroundColor( const QColor& c ) -{ - d->state->backgroundColor = c.rgb(); - triggerRender(); -} - -QSize PictureFlow::slideSize() const -{ - return QSize( d->state->slideWidth, d->state->slideHeight ); -} - -void PictureFlow::setSlideSize( QSize size ) -{ - d->state->slideWidth = size.width(); - d->state->slideHeight = size.height(); - d->state->reposition(); - triggerRender(); -} - -PictureFlow::ReflectionEffect PictureFlow::reflectionEffect() const -{ - return d->state->reflectionEffect; -} - -void PictureFlow::setReflectionEffect( ReflectionEffect effect ) -{ - d->state->reflectionEffect = effect; - triggerRender(); -} -void PictureFlow::setRenderHints( QPainter::RenderHints iHints ) -{ - d->renderer->render_hints = iHints; - triggerRender(); -} -void PictureFlow::setAnimationTime( int iTime ) -{ - d->animator->animationDuration = iTime; -} -QImage PictureFlow::slide( int index ) const -{ - QImage* i = 0; - if (( index >= 0 ) && ( index < slideCount() ) ) - i = d->state->slideImages[index]; - return i ? QImage( *i ) : QImage(); -} - -void PictureFlow::addSlide( const QImage& image ) -{ - int c = d->state->slideImages.count(); - d->state->slideImages.resize( c + 1 ); - d->state->slideImages[c] = new QImage( image ); - triggerRender(); -} - -void PictureFlow::addSlide( const QPixmap& pixmap ) -{ - addSlide( pixmap.toImage() ); -} - -void PictureFlow::setSlide( int index, const QImage& image ) -{ - if (( index >= 0 ) && ( index < slideCount() ) ) - { - QImage* i = image.isNull() ? 0 : new QImage( image ); - delete d->state->slideImages[index]; - d->state->slideImages[index] = i; - triggerRender(); - } -} - -void PictureFlow::setSlide( int index, const QPixmap& pixmap ) -{ - setSlide( index, pixmap.toImage() ); -} -void PictureFlow::addAlbum( Meta::AlbumPtr iAlbum ) -{ - m_album_list.append( iAlbum ); - //QPixmap* no_cover_pix = new QPixmap( KStandardDirs::locate( "data", "amarok/images/blingdefaultcover.png" ) ); -} -void PictureFlow::setAlbums(Meta::AlbumList iAlbums) -{ - m_album_list = iAlbums; - //m_openglwidget->resize(-1,-1); - //d->renderer->widget = m_openglwidget; - //if (m_openglwidget) - //{ - //m_openglwidget->init(m_album_list,QSize(150,150)); - //m_openglwidget->show(); - - //} - -} -Meta::AlbumPtr PictureFlow::album( int index ) -{ - Meta::AlbumPtr album; - if (index < m_album_list.size() && index >= 0) - { - album = m_album_list[index]; - } - return album; -} -int PictureFlow::centerIndex() const -{ - return d->state->centerIndex; -} - -void PictureFlow::setCenterIndex( int index ) -{ - index = qMin( index, slideCount() - 1 ); - index = qMax( index, 0 ); - d->state->centerIndex = index; - d->state->reset(); - d->animator->stop( index ); - triggerRender(); -} - -void PictureFlow::clear() -{ - int c = d->state->slideImages.count(); - for ( int i = 0; i < c; i++ ) - delete d->state->slideImages[i]; - d->state->slideImages.resize( 0 ); - - d->state->reset(); - triggerRender(); -} - -void PictureFlow::render() -{ - d->renderer->dirty = true; - update(); -} - -void PictureFlow::triggerRender() -{ - d->triggerTimer.setSingleShot( true ); - d->triggerTimer.start( 0 ); -} - -void PictureFlow::showPrevious() -{ - int step = d->animator->step; - int center = d->state->centerIndex; - - if ( step > 0 ) - d->animator->start( center ); - - if ( step == 0 ) - if ( center > 0 ) - d->animator->start( center - 1 ); - - if ( step < 0 ) - d->animator->target = qMax( 0, center - 2 ); -} - -void PictureFlow::showNext() -{ - int step = d->animator->step; - int center = d->state->centerIndex; - - if ( step < 0 ) - d->animator->start( center ); - - if ( step == 0 ) - if ( center < slideCount() - 1 ) - d->animator->start( center + 1 ); - - if ( step > 0 ) - d->animator->target = qMin( center + 2, slideCount() - 1 ); -} - -void PictureFlow::showSlide( int index ) -{ - index = qMax( index, 0 ); - index = qMin( slideCount() - 1, index ); - if ( index == d->state->centerSlide.slideIndex ) - return; - - d->animator->start( index ); -} - -void PictureFlow::keyPressEvent( QKeyEvent* event ) -{ - if ( event->key() == Qt::Key_Left ) - { - if ( event->modifiers() == Qt::ControlModifier ) - showSlide( centerIndex() - 10 ); - else - showPrevious(); - event->accept(); - return; - } - - if ( event->key() == Qt::Key_Right ) - { - if ( event->modifiers() == Qt::ControlModifier ) - showSlide( centerIndex() + 10 ); - else - showNext(); - event->accept(); - return; - } - - event->ignore(); -} - -void PictureFlow::mousePressEvent( QMouseEvent* event ) -{ - if ( event->x() > ( width() / 2 + ( d->state->slideWidth ) / 2 ) ) - showNext(); - if ( event->x() < ( width() / 2 - ( d->state->slideWidth ) / 2 ) ) - showPrevious(); -} -void PictureFlow::mouseDoubleClickEvent( QMouseEvent* event ) -{ - if ((( event->x() <= ( width() / 2 + ( d->state->slideWidth ) / 2 ) ) && ( event->x() >= ( width() / 2 - ( d->state->slideWidth ) / 2 ) ) ) && (( event->y() <= ( height() / 2 + ( d->state->slideHeight ) / 2 ) ) && ( event->y() >= ( height() / 2 - ( d->state->slideHeight ) / 2 ) ) ) ) - emit doubleClicked( d->state->centerIndex ); -} -void PictureFlow::wheelEvent( QWheelEvent * event ) -{ - int numDegrees = event->delta() / 8; - int numSteps = numDegrees / 15; - bool forward = true; - if ( numSteps < 0 ) - { - forward = false; - numSteps = -numSteps; - } - for ( int i = 1;i <= numSteps;i++ ) - { - if ( forward ) showNext(); - else showPrevious(); - } -} -void PictureFlow::paintEvent( QPaintEvent* event ) -{ - Q_UNUSED( event ); - d->renderer->paint(); -} - -void PictureFlow::resizeEvent( QResizeEvent* event ) -{ - triggerRender(); - QWidget::resizeEvent( event ); -} - -void PictureFlow::updateAnimation() -{ - int old_center = d->state->centerIndex; - d->animator->update(); - triggerRender(); - if ( d->state->centerIndex != old_center ) - emit centerIndexChanged( d->state->centerIndex ); -} - -#include "moc_pictureflow.cpp" // to have actual (non-forward) declaration of Meta::* diff --git a/amarok/playground/src/context/applets/coverbling/pictureflow.h b/amarok/playground/src/context/applets/coverbling/pictureflow.h deleted file mode 100644 index 711cdb18..00000000 --- a/amarok/playground/src/context/applets/coverbling/pictureflow.h +++ /dev/null @@ -1,218 +0,0 @@ -/* - PictureFlow - animated image show widget - http://pictureflow.googlecode.com - Copyright (C) 2010 Emmanuel Wagner (manu.wagner@sfr.fr) - Ariya's code modifications for amarok - Copyright (C) 2008 Ariya Hidayat (ariya@kde.org) - Copyright (C) 2007 Ariya Hidayat (ariya@kde.org) - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. -*/ - -#ifndef PICTUREFLOW_H -#define PICTUREFLOW_H - -#include "core/meta/forward_declarations.h" - -#include -#include -#include -//#include "CoverBling.h" - -class PictureFlowPrivate; - -/*! - Class PictureFlow implements an image show widget with animation effect - like Apple's CoverFlow (in iTunes and iPod). Images are arranged in form - of slides, one main slide is shown at the center with few slides on - the left and right sides of the center slide. When the next or previous - slide is brought to the front, the whole slides flow to the right or - the right with smooth animation effect; until the new slide is finally - placed at the center. - - */ -class PictureFlow : public QWidget -{ -Q_OBJECT - - Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor) - Q_PROPERTY(QSize slideSize READ slideSize WRITE setSlideSize) - Q_PROPERTY(int slideCount READ slideCount) - Q_PROPERTY(int centerIndex READ centerIndex WRITE setCenterIndex) - -public: - - enum ReflectionEffect - { - NoReflection, - PlainReflection, - BlurredReflection - }; - - /*! - Creates a new PictureFlow widget. - */ - PictureFlow(QWidget* parent = 0, bool enableOpenGL = false); - - /*! - Destroys the widget. - */ - ~PictureFlow(); - - /*! - Returns the background color. - */ - QColor backgroundColor() const; - - /*! - Sets the background color. By default it is black. - */ - void setBackgroundColor(const QColor& c); - - void setOpenGLMode(bool activateOpenGL); - /*! - Returns the dimension of each slide (in pixels). - */ - QSize slideSize() const; - - /*! - Sets the dimension of each slide (in pixels). - */ - void setSlideSize(QSize size); - - /*! - Returns the total number of slides. - */ - int slideCount() const; - - /*! - Returns QImage of specified slide. - */ - QImage slide(int index) const; - - /*! - Returns the index of slide currently shown in the middle of the viewport. - */ - int centerIndex() const; - - /*! - Returns the effect applied to the reflection. - */ - ReflectionEffect reflectionEffect() const; - - /*! - Sets the effect applied to the reflection. The default is PlainReflection. - */ - void setReflectionEffect(ReflectionEffect effect); - - void setRenderHints(QPainter::RenderHints); - - void setAnimationTime(int iTime); - -public slots: - - Meta::AlbumPtr album(int index); - - void setAlbums(Meta::AlbumList iAlbums); - - void addAlbum(Meta::AlbumPtr iAlbum); - /*! - Adds a new slide. - */ - void addSlide(const QImage& image); - - /*! - Adds a new slide. - */ - void addSlide(const QPixmap& pixmap); - - /*! - Sets an image for specified slide. If the slide already exists, - it will be replaced. - */ - void setSlide(int index, const QImage& image); - - /*! - Sets a pixmap for specified slide. If the slide already exists, - it will be replaced. - */ - void setSlide(int index, const QPixmap& pixmap); - - /*! - Sets slide to be shown in the middle of the viewport. No animation - effect will be produced, unlike using showSlide. - */ - void setCenterIndex(int index); - - /*! - Clears all slides. - */ - void clear(); - - /*! - Shows previous slide using animation effect. - */ - void showPrevious(); - - /*! - Shows next slide using animation effect. - */ - void showNext(); - - /*! - Go to specified slide using animation effect. - */ - void showSlide(int index); - - /*! - Rerender the widget. Normally this function will be automatically invoked - whenever necessary, e.g. during the transition animation. - */ - void render(); - - /*! - Schedules a rendering update. Unlike render(), this function does not cause - immediate rendering. - */ - void triggerRender(); - -signals: - void centerIndexChanged(int index); - void doubleClicked(int index); -protected: - void paintEvent(QPaintEvent *event); - void keyPressEvent(QKeyEvent* event); - void mousePressEvent(QMouseEvent* event); - void resizeEvent(QResizeEvent* event); - void mouseDoubleClickEvent(QMouseEvent* event); - void wheelEvent(QWheelEvent * event); - Meta::AlbumList m_album_list; - bool m_opengl; -private slots: - void updateAnimation(); - -private: - PictureFlowPrivate* d; - - //CoverBling* m_openglwidget; - //QHBoxLayout* m_opengllayout; -}; - -#endif // PICTUREFLOW_H - diff --git a/amarok/playground/src/context/applets/covergrid/AlbumItem.cpp b/amarok/playground/src/context/applets/covergrid/AlbumItem.cpp deleted file mode 100644 index 18dbf127..00000000 --- a/amarok/playground/src/context/applets/covergrid/AlbumItem.cpp +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2011 Emmanuel Wagner * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "AlbumItem.h" - -#include "playlist/PlaylistModelStack.h" -#include "core/meta/Meta.h" -#include "playlist/PlaylistController.h" - -#include -#include -#include -#include -#include -#include - -#include - - -AlbumItem::AlbumItem( const QPixmap & pixmap, Meta::AlbumPtr album , QWidget * parent, Qt::WindowFlags f ) - - : QLabel( parent, f ) -{ - m_album = album; - m_pixmap = pixmap; - setPixmap( pixmap ); - m_size = pixmap.height(); - setMouseTracking( true ); - setDisabled( false ); - if( album ) - { - Meta::ArtistPtr artist = album->albumArtist(); - QString label = album->prettyName(); - if( artist ) label += " - " + artist->prettyName(); - setToolTip( label ); - } -} - -AlbumItem::~AlbumItem() -{ - // emit the destructor here where actual (non-forward) declaration of Meta::* is known -} - -Meta::AlbumPtr -AlbumItem::getAlbum() -{ - return m_album; -} - -void -AlbumItem::mousePressEvent( QMouseEvent *event ) -{ - Q_UNUSED( event ) -} - -void -AlbumItem::mouseDoubleClickEvent( QMouseEvent *event ) -{ - Q_UNUSED( event ) - The::playlistController()->insertOptioned( m_album->tracks(), Playlist::OnDoubleClickOnSelectedItems ); -} - -void -AlbumItem::leaveEvent( QEvent * ) -{ - setPixmap( m_pixmap ); -} - -void -AlbumItem::enterEvent( QEvent *event ) -{ - Q_UNUSED( event ) - QImage image = m_pixmap.toImage(); - QPixmap transparent( image.size() ); - transparent.fill( Qt::transparent ); - QPainter p; - p.begin( &transparent ); - p.setCompositionMode( QPainter::CompositionMode_Source ); - p.drawPixmap( 0, 0, QPixmap::fromImage( image ) ); - p.setCompositionMode( QPainter::CompositionMode_DestinationIn ); - p.fillRect( transparent.rect(), QColor( 0, 0, 0, 150 ) ); - p.end(); - setPixmap( transparent ); -} diff --git a/amarok/playground/src/context/applets/covergrid/AlbumItem.h b/amarok/playground/src/context/applets/covergrid/AlbumItem.h deleted file mode 100644 index 5f1fef64..00000000 --- a/amarok/playground/src/context/applets/covergrid/AlbumItem.h +++ /dev/null @@ -1,46 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2011 Emmanuel Wagner * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "core/meta/forward_declarations.h" - -#include - -class QMouseEvent; -class QStyleOptionGraphicsItem; -class QPaintEvent; -class QEvent; - -class AlbumItem : public QLabel -{ - Q_OBJECT - -public: - AlbumItem( const QPixmap & pixmap, Meta::AlbumPtr album, QWidget * parent = 0, Qt::WindowFlags f = 0 ); - ~AlbumItem(); - - Meta::AlbumPtr getAlbum(); - -protected : - void mousePressEvent( QMouseEvent * event ); - void leaveEvent( QEvent * event); - void enterEvent( QEvent * event); - void mouseDoubleClickEvent( QMouseEvent * event ); - -private: - Meta::AlbumPtr m_album; - int m_size; - QPixmap m_pixmap; -}; diff --git a/amarok/playground/src/context/applets/covergrid/CMakeLists.txt b/amarok/playground/src/context/applets/covergrid/CMakeLists.txt deleted file mode 100644 index 0f084545..00000000 --- a/amarok/playground/src/context/applets/covergrid/CMakeLists.txt +++ /dev/null @@ -1,25 +0,0 @@ -project(context-covergrid) - -set(covergrid_SRCS - CoverGridApplet.cpp - AlbumItem.cpp -) - -include_directories( ../../.. - ../.. - ${KDE4_INCLUDE_DIR}/amarok # this way we don't need to prefix it with amarok/ (and it compiles this way too :) -) - -kde4_add_ui_files( covergrid_SRCS CoverGridSettings.ui ) -kde4_add_plugin(amarok_context_applet_covergrid ${covergrid_SRCS}) - - -target_link_libraries(amarok_context_applet_covergrid - amarokcore - amaroklib - ${KDE4_PLASMA_LIBS} - ${KDE4_KIO_LIBS} -) - -install(TARGETS amarok_context_applet_covergrid DESTINATION ${PLUGIN_INSTALL_DIR}) -install(FILES amarok-context-applet-covergrid.desktop DESTINATION ${SERVICES_INSTALL_DIR}) diff --git a/amarok/playground/src/context/applets/covergrid/CoverGridApplet.cpp b/amarok/playground/src/context/applets/covergrid/CoverGridApplet.cpp deleted file mode 100644 index 417bb909..00000000 --- a/amarok/playground/src/context/applets/covergrid/CoverGridApplet.cpp +++ /dev/null @@ -1,171 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2011 Emmanuel Wagner * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "CoverGridApplet" - -#include "CoverGridApplet.h" - -#include "AlbumItem.h" -#include "core/support/Amarok.h" -#include "EngineController.h" -#include "core/support/Debug.h" -#include "context/ContextView.h" -#include "core/collections/Collection.h" -#include "core/meta/Meta.h" -#include "core-impl/collections/support/CollectionManager.h" -#include "playlist/PlaylistModelStack.h" -#include "playlist/PlaylistController.h" - -#include -#include -#include -#include -#include -#include "covermanager/CoverCache.h" -#include - -#include -#include - -#include -#include -#include -#include -#include - -CoverGridApplet::CoverGridApplet( QObject* parent, const QVariantList& args ) - : Context::Applet( parent, args ) -{ - DEBUG_BLOCK - - setHasConfigurationInterface( true ); -} - -void -CoverGridApplet::init() -{ - // Call the base implementation. - Context::Applet::init(); - setBackgroundHints( Plasma::Applet::NoBackground ); - - KConfigGroup config = Amarok::config( "CoverGrid Applet" ); - m_coversize = config.readEntry( "CoverSize", 70 ); - - QGraphicsLinearLayout* lay = new QGraphicsLinearLayout( Qt::Vertical ); - setLayout( lay ); - m_scroll = new Plasma::ScrollWidget( this ); - m_scroll->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); - m_scroll->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOn ); - m_scroll->show(); - - m_proxywidget = new QGraphicsProxyWidget( this ) ; - m_layout = new QGraphicsGridLayout( m_proxywidget ); - m_layout->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); - - setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); - // create a scroll Area - m_scroll->setWidget( m_proxywidget ); - lay->addItem( m_scroll ); - - Collections::Collection *coll = CollectionManager::instance()->primaryCollection(); - Collections::QueryMaker *qm = coll->queryMaker(); - qm->setAutoDelete( true ); - qm->setQueryType( Collections::QueryMaker::Album ); - qm->orderBy( Meta::valArtist ); - - connect( qm, SIGNAL(newResultReady(Meta::AlbumList)), - this, SLOT(slotAlbumQueryResult(Meta::AlbumList)) ); - qm->run(); -} - -CoverGridApplet::~CoverGridApplet() -{ - delete m_proxywidget; -} - -void CoverGridApplet::slotAlbumQueryResult( Meta::AlbumList albums ) //SLOT -{ - DEBUG_BLOCK - - m_album_list = albums; - prepareLayout(); -} - -void CoverGridApplet::createConfigurationInterface( KConfigDialog *parent ) -{ - KConfigGroup configuration = config(); - QWidget * const settings = new QWidget; - ui_Settings.setupUi( settings ); - if( m_coversize ) - ui_Settings.coversizeSpin->setValue( m_coversize ); - parent->addPage( settings, i18n( "Covergrid Settings" ), "preferences-system" ); - connect( parent, SIGNAL(accepted()), this, SLOT(saveSettings()) ); -} -bool -CoverGridApplet::hasHeightForWidth() const -{ - return false; -} -void CoverGridApplet::saveSettings() -{ - m_coversize = ui_Settings.coversizeSpin->value(); - KConfigGroup config = Amarok::config( "CoverGrid Applet" ); - config.writeEntry( "CoverSize", m_coversize ); - prepareLayout(); -} -void CoverGridApplet::prepareLayout() -{ - int nb_prev = m_layout->count(); - for( int i = nb_prev - 1; i >= 0; i-- ) m_layout->removeAt( i ); - m_layout->invalidate(); - - const int horizontal_size = boundingRect().width(); - int x_pos = 0; - int y_pos = 0; - int nb_albums = m_album_list.size(); - int nbcolumns = horizontal_size / m_coversize; - for( int index = 0; index < nb_albums; index++ ) - { - Meta::AlbumPtr album = m_album_list[index]; - QPixmap pixmap; - if( album->hasImage() ) - { - pixmap = The::coverCache()->getCover( album, m_coversize ); - } - else - { - pixmap = QPixmap( KStandardDirs::locate( "data", "amarok/images/nocover.png" ) ); - QImage image = pixmap.toImage(); - image = image.scaled( QSize( m_coversize, m_coversize ), Qt::KeepAspectRatio, Qt::SmoothTransformation ); - pixmap = QPixmap::fromImage( image ); - } - - QGraphicsProxyWidget* proxywidget = new QGraphicsProxyWidget( this ) ; - - AlbumItem *pixmap_widget = new AlbumItem( pixmap, album ); - proxywidget->setWidget( pixmap_widget ); - m_layout->addItem( proxywidget, y_pos, x_pos, 0 ); - x_pos ++; - - if( x_pos > nbcolumns ) - { - x_pos = 0; y_pos++; - } - } - m_layout->activate(); -} - -#include "moc_CoverGridApplet.cpp" diff --git a/amarok/playground/src/context/applets/covergrid/CoverGridApplet.h b/amarok/playground/src/context/applets/covergrid/CoverGridApplet.h deleted file mode 100644 index 7b7aa835..00000000 --- a/amarok/playground/src/context/applets/covergrid/CoverGridApplet.h +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2011 Emmanuel Wagner * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef COVERGRID_APPLET_H -#define COVERGRID_APPLET_H - -#include "context/Applet.h" -#include "ui_CoverGridSettings.h" -#include "core/meta/forward_declarations.h" - -class KConfigDialog; -class QGraphicsProxyWidget; -class QGraphicsGridLayout; - -namespace Plasma -{ - class ScrollWidget; -} - -class CoverGridApplet : public Context::Applet -{ - Q_OBJECT - - public: - CoverGridApplet( QObject* parent, const QVariantList& args ); - ~CoverGridApplet(); - - void init(); - bool hasHeightForWidth() const; - - public slots: - void slotAlbumQueryResult( Meta::AlbumList albums); - void saveSettings(); - - protected : - void createConfigurationInterface(KConfigDialog *parent); - - private: - void prepareLayout(); - - QGraphicsProxyWidget * m_proxywidget; - Plasma::ScrollWidget *m_scroll; - QGraphicsGridLayout * m_layout; - Meta::AlbumList m_album_list; - Ui::CoverGridSettings ui_Settings; - int m_coversize; -}; - -AMAROK_EXPORT_APPLET( covergrid, CoverGridApplet ) - -#endif /* COVERGRID_APPLET_H */ diff --git a/amarok/playground/src/context/applets/covergrid/CoverGridSettings.ui b/amarok/playground/src/context/applets/covergrid/CoverGridSettings.ui deleted file mode 100644 index 3d791725..00000000 --- a/amarok/playground/src/context/applets/covergrid/CoverGridSettings.ui +++ /dev/null @@ -1,45 +0,0 @@ - - - CoverGridSettings - - - - 0 - 0 - 265 - 66 - - - - - - 10 - 20 - 101 - 16 - - - - Cover size (pixels) - - - - - - 120 - 20 - 51 - 21 - - - - 10 - - - 500 - - - - - - diff --git a/amarok/playground/src/context/applets/covergrid/amarok-context-applet-covergrid.desktop b/amarok/playground/src/context/applets/covergrid/amarok-context-applet-covergrid.desktop deleted file mode 100644 index 1b193ab1..00000000 --- a/amarok/playground/src/context/applets/covergrid/amarok-context-applet-covergrid.desktop +++ /dev/null @@ -1,60 +0,0 @@ - -[Desktop Entry] -Encoding=UTF-8 -Name=CoverGrid -Name[bs]=CoverGrid -Name[ca]=CoverGrid -Name[ca@valencia]=CoverGrid -Name[cs]=CoverGrid -Name[da]=CoverGrid -Name[de]=CoverGrid -Name[el]=CoverGrid -Name[en_GB]=CoverGrid -Name[es]=CoverGrid -Name[et]=CoverGrid -Name[eu]=Azalen matrizea -Name[fi]=KansikuvaRuudukko -Name[fr]=CoverGrid -Name[ga]=CoverGrid -Name[gl]=CoverGrid -Name[hu]=Borítórács -Name[id]=Sampul Kisi -Name[it]=CoverGrid -Name[ja]=CoverGrid -Name[km]=CoverGrid -Name[lt]=CoverGrid -Name[lv]=CoverGrid -Name[nb]=Omslagsrute -Name[nl]=CoverGrid -Name[pl]=CoverGrid -Name[pt]=Grelha de Capas -Name[pt_BR]=Grade de capas -Name[ro]=CoverGrid -Name[ru]=Все обложки -Name[sk]=CoverGrid -Name[sl]=CoverGrid -Name[sr]=Омотоплет -Name[sr@ijekavian]=Омотоплет -Name[sr@ijekavianlatin]=Omotoplet -Name[sr@latin]=Omotoplet -Name[sv]=Omslagsrutnät -Name[tr]=CoverGrid -Name[uk]=CoverGrid -Name[x-test]=xxCoverGridxx -Name[zh_CN]=封面栅栏 -Name[zh_TW]=CoverGrid -Type=Service -ServiceTypes=Plasma/Applet - -X-KDE-Library=amarok_context_applet_covergrid -X-KDE-PluginInfo-Author=manuw2009 -X-KDE-PluginInfo-Email=manu.wagner@sfr.fr -X-KDE-PluginInfo-Name=covergrid -X-KDE-PluginInfo-Version=0.10 -X-KDE-PluginInfo-Website= -X-KDE-PluginInfo-Category= -X-KDE-PluginInfo-Depends= -X-KDE-PluginInfo-License=GPL -X-KDE-PluginInfo-EnabledByDefault=true -X-KDE-ParentApp=amarok -X-KDE-PluginInfo-Category=Current diff --git a/amarok/playground/src/scripts/CMakeLists.txt b/amarok/playground/src/scripts/CMakeLists.txt deleted file mode 100644 index b0ff1428..00000000 --- a/amarok/playground/src/scripts/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -add_subdirectory( bbc_service ) -add_subdirectory( copycover ) -add_subdirectory( danish_streams_service ) -add_subdirectory( encoding_fixer ) -add_subdirectory( npr_service ) -add_subdirectory( seeqpod_service ) diff --git a/amarok/playground/src/scripts/bbc_service/CMakeLists.txt b/amarok/playground/src/scripts/bbc_service/CMakeLists.txt deleted file mode 100644 index 30055671..00000000 --- a/amarok/playground/src/scripts/bbc_service/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -install( FILES - COPYING - README - main.js - script.spec - DESTINATION ${DATA_INSTALL_DIR}/amarok/scripts/bbc_service -) - diff --git a/amarok/playground/src/scripts/bbc_service/COPYING b/amarok/playground/src/scripts/bbc_service/COPYING deleted file mode 100644 index b74ec101..00000000 --- a/amarok/playground/src/scripts/bbc_service/COPYING +++ /dev/null @@ -1,340 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program 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 2 of the License, or - (at your option) any later version. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. diff --git a/amarok/playground/src/scripts/bbc_service/README b/amarok/playground/src/scripts/bbc_service/README deleted file mode 100644 index 9ab7802c..00000000 --- a/amarok/playground/src/scripts/bbc_service/README +++ /dev/null @@ -1,24 +0,0 @@ -
BBC open content
- -

-About:
-A script that allows you to browse and listen to free streams and podcasts from BBC -

- -

-Usage:
-Just run the script, and a new service will be created in the internet service browser. -

- -

-Dependencies:
-

    -
  • Amarok 2.0
  • -
-

- -

-Author:
-Nikolaj Hald Nielsen (nhnFreespirit@gmail.com) -

- diff --git a/amarok/playground/src/scripts/bbc_service/TODO b/amarok/playground/src/scripts/bbc_service/TODO deleted file mode 100644 index e69de29b..00000000 diff --git a/amarok/playground/src/scripts/bbc_service/main.js b/amarok/playground/src/scripts/bbc_service/main.js deleted file mode 100755 index bd4f3a74..00000000 --- a/amarok/playground/src/scripts/bbc_service/main.js +++ /dev/null @@ -1,299 +0,0 @@ -/*########################################################################### -# A script that lets you browse and listen to free content # -# From the BBC # -# # -# Copyright # -# (C) 2008 Nikolaj Hald Nielsen # -# (C) 2008 Peter ZHOU # -# (C) 2008 Sven Krohlas # -# # -# This program 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 2 of the License, or # -# (at your option) any later version. # -# # -# This program 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 this program; if not, write to the # -# Free Software Foundation, Inc., # -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # -###########################################################################*/ - -Importer.loadQtBinding( "qt.core" ); -Importer.loadQtBinding( "qt.xml" ); -Importer.loadQtBinding( "qt.network" ); - -service_name = "BBC"; -html = "BBC"; -globalFilter = ""; - - -xmlUrl = new QUrl( "http://open.bbc.co.uk/rad/uriplay/availablecontent" ); -http = new QHttp; -data = new QIODevice; -doc = new QDomDocument("doc"); -elt = new QDomElement; -elt2 = new QDomElement; -shows = new QDomNodeList; - -episodes = new Object(); -urls = new Object(); - -xmlFetched = 0; - - -function trimKey( key ) { - - newKey = key.replace("http://open.bbc.co.uk/rad/uriplay/content/", "" ); - /*index = newKey.indexOf( "/" ); - newKey = newKey.substring(index); - newKey = newKey.replace( "/", "" ); - newKey = newKey.replace( "-", "_" );*/ - - return newKey; -} - -String.prototype.trim = function() { - a = this.replace(/^\s+/, ''); - return a.replace(/\s+$/, ''); -} - - -/* Initialization of service */ -function BBCService() { - Amarok.debug( "creating bbc service..." ); - ScriptableServiceScript.call( this, "BBC", 2, "Freely available content from BBC", html, true ); - Amarok.debug( "done creating bbc service!" ); -} - - -/* Get info for shows */ -function xmlDownloadResult( reply ) { - Amarok.debug( "start bbc shows xml parsing..." ); - try { - doc.setContent( reply ); - - shows = doc.elementsByTagName( "po:Brand" ); - Amarok.debug ("got " + shows.length() + " shows!"); - - - //Amarok.debug ("building episode map..." ); - - - //build a map of all episodes keyed by their unique url - var episodeNodes = doc.elementsByTagName( "po:Episode" ); - - var j = 0; - for ( ; j < episodeNodes.length(); j++ ) { - - - elt = episodeNodes.at( j ); - - var key = trimKey( elt.toElement().attribute("rdf:about", "failed" ) ); - var data = "";; - - - - elt2 = elt.firstChildElement( "dc:title" ); - data += elt2.text(); - data += "\\"; - - elt2 = elt.firstChildElement( "dc:description" ); - data += elt2.text(); - data += "\\"; - - - elt2 = elt.lastChildElement( "rdfs:seeAlso" ); - data += elt2.attribute( "rdf:resource", "" ); - - //Amarok.debug ("url: " + item.playableUrl); - - //episodes[key] = item2; - episodes[key] = data; - //Amarok.debug ("item " + data + " inserted with key: " + key); - - } - - //build a map of download urls as these are in some cass spread out all over the place - var playNodes = doc.elementsByTagName( "play:Location" ); - - var k = 0; - for ( ; k < playNodes.length(); k++ ) { - - elt = playNodes.at( k ); - - var ulrKey = trimKey( elt.toElement().attribute("rdf:about", "failed" ) ); - - elt2 = elt.lastChildElement( "play:uri" ); - var url = elt2.attribute( "rdf:resource", "" ); - - //Amarok.debug ("url: " + item.playableUrl); - - //episodes[key] = item2; - urls[ulrKey] = url; - //Amarok.debug ("url " + url + " inserted with key: " + ulrKey); - - } - - //Amarok.debug ("got " + episodeNodes.length() + " episodes!"); - - } - catch( err ) { - Amarok.debug( err ); - } - xmlFetched == 1; - populateShows( globalFilter ); -} - - -function populateShows( filter ) { - - //Amarok.debug ("in populateShows"); - try { - - var showTitles = new Array( shows.length() ); - - var item = Amarok.StreamItem; - item.level = 1; - item.playableUrl = ""; - - var i = 0; - for ( ; i < shows.length(); i++ ) { - - elt = shows.at( i ); - elt2 = elt.firstChildElement( "dc:title" ); - item.itemName = elt2.text(); - - var lowerCaseTitle = item.itemName.toLowerCase(); - var lowerCaseFilter = filter.toLowerCase(); - - //Amarok.debug ("searching for filter " + lowerCaseFilter + " in title " + lowerCaseTitle); - - - if ( lowerCaseFilter != "" && lowerCaseTitle.indexOf(lowerCaseFilter) == -1 ) { - continue; - } - - - elt2 = elt.firstChildElement( "dc:description" ); - item.infoHtml = elt2.text(); - - // this is needed to identify the item when we need to expand - // it in onPopulate( level, -->callbackData<--, filter ) - item.callbackData = i; - script.insertItem( item ); - - - } - - } catch( err ) { - Amarok.debug( err ); - } - - script.donePopulating() - -} - - -/* Fill tree view in Amarok */ -function onPopulate( level, callbackData, filter ) { - var i = 0; - Amarok.debug( "populating bbc level: " + level ); - - filter = filter.replace( "%20", " " ); - filter = filter.trim(); - globalFilter = filter; - - if ( level == 1 ) { // the shows - - try { - - if ( shows.length() == 0 ) { - Amarok.debug( "fetching bbc xml..." ); - Amarok.Window.Statusbar.longMessage( "BBC

Fetching and parsing shows.
This might take some seconds, depending on the speed of your internet connection..." ); - qurl = new QUrl( xmlUrl ); - a = new Downloader( qurl, xmlDownloadResult ); - } else { - populateShows( filter ); - } - } catch( err ) { - Amarok.debug( err ); - } - - } - - else if ( level == 0 ) { // the tracks from each show - - var show = new QDomElement; - //Amarok.debug ("got " + shows.length() + " shows! ( only need one right now... )"); - - try { - - show = shows.at( callbackData ); - - elt = show.firstChildElement( "dc:title" ); - // Amarok.debug ("populating show: " + elt.text() ); - -/*for(att in episodes){ - Amarok.debug ("att: " + att + ", " + episodes[att].itemName) -}*/ - - - //for ( elt = show.firstChildElement( "po:Episode" ); /*!elt.isNull()*/ 1; elt = show.nextSiblingElement( "po:Episode" )) { - - elt = show.firstChildElement( "po:episode" ); - - while ( elt.isNull() == false ) { - - //Amarok.debug ("here!!: " + elt.isNull() ); - - var key = trimKey( elt.attribute( "rdf:resource", "failed" ) ); - - if ( key == "failed" ) { - //dig one deeper - elt2 = elt.firstChildElement( "po:Episode" ); - key = trimKey( elt2.attribute( "rdf:about", "failed" ) ); - - } - - //Amarok.debug ("using key: " + key ); - //Amarok.debug ("inserting item: " + episodes[key] ); - - - var item2 = Amarok.StreamItem; - item2.level = 0; - item2.callbackData = ""; - - var item_array=episodes[key].split("\\"); - - - item2.itemName = item_array[0]; - item2.infoHtml = item_array[1]; - - item2.playableUrl = urls[key + "main/main/main/"]; - - item2.artist = "BBC"; - - - script.insertItem( item2 ); - - elt = elt.nextSiblingElement( "po:episode" ) - - } - - } catch( err ) { - Amarok.debug( err ); - } - - - script.donePopulating(); - //Amarok.debug( "done populating bbc track level..." ); - } -} - -script = new BBCService(); -script.populate.connect( onPopulate ); diff --git a/amarok/playground/src/scripts/bbc_service/script.spec b/amarok/playground/src/scripts/bbc_service/script.spec deleted file mode 100644 index 3733996c..00000000 --- a/amarok/playground/src/scripts/bbc_service/script.spec +++ /dev/null @@ -1,17 +0,0 @@ -[Desktop Entry] -Icon=amarok -Type=script -ServiceTypes=KPluginInfo - -Name=BBC -Comment=Listen to free content from BBC - -X-KDE-PluginInfo-Author=Nikolaj Hald Nielsen -X-KDE-PluginInfo-Email=nhnFreespirit@gmail.com -X-KDE-PluginInfo-Name=BBC -X-KDE-PluginInfo-Version=1.0.0 -X-KDE-PluginInfo-Category=Scriptable Service -X-KDE-PluginInfo-Website=http://amarok.kde.org/ -X-KDE-PluginInfo-Depends=Amarok2.0 -X-KDE-PluginInfo-License=GPL -X-KDE-PluginInfo-EnabledByDefault=true diff --git a/amarok/playground/src/scripts/copycover/CMakeLists.txt b/amarok/playground/src/scripts/copycover/CMakeLists.txt deleted file mode 100644 index 5263c23b..00000000 --- a/amarok/playground/src/scripts/copycover/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -install( FILES - main.js - script.spec - copycover.ui - DESTINATION ${DATA_INSTALL_DIR}/amarok/scripts/copycover -) - diff --git a/amarok/playground/src/scripts/copycover/copycover.ui b/amarok/playground/src/scripts/copycover/copycover.ui deleted file mode 100644 index 2e6157c2..00000000 --- a/amarok/playground/src/scripts/copycover/copycover.ui +++ /dev/null @@ -1,107 +0,0 @@ - - - Dialog - - - - 0 - 0 - 300 - 111 - - - - Copy Cover Settings - - - - - 80 - 70 - 191 - 32 - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - 10 - 0 - 201 - 71 - - - - - - 0 - 10 - 151 - 23 - - - - Write cover.png - - - true - - - - - - 0 - 40 - 201 - 23 - - - - Write %artist-%album.png - - - - - - - - buttonBox - accepted() - Dialog - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - Dialog - reject() - - - 316 - 260 - - - 286 - 274 - - - - - diff --git a/amarok/playground/src/scripts/copycover/main.js b/amarok/playground/src/scripts/copycover/main.js deleted file mode 100644 index d23e2b53..00000000 --- a/amarok/playground/src/scripts/copycover/main.js +++ /dev/null @@ -1,186 +0,0 @@ -/************************************************************************** -* Copy Cover Script for Amarok 2.0 * -* * -* Copyright * -* (C) 2009 Sven Krohlas * -* (C) 2008 Simon Esneault * -* * -* This program 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 2 of the License, or * -* (at your option) any later version. * -* * -* This program 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 this program; if not, write to the * -* Free Software Foundation, Inc., * -* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * -**************************************************************************/ - - -Importer.loadQtBinding( "qt.core" ); -Importer.loadQtBinding( "qt.gui" ); -Importer.loadQtBinding( "qt.uitools" ); - -function copyCover() -{ - var TrackInfo = Amarok.Engine.currentTrack(); - if ( TrackInfo.isValid ) // if track is valid - { - var path_image=TrackInfo.imageUrl.substring( 7 ); - var image=new QImage( path_image ); - if ( !image.isNull() ) // if we have a cover - { - // Make a the correct path - var path=TrackInfo.path.substring( 0, TrackInfo.path.lastIndexOf( "/" ) + 1 ); - - if ( writeCover == true ) - { - var patha=path+"cover.png"; - - // try to load the image first, to prevent rewritting - var image2 = new QImage ( patha ); - if ( !image2.isNull() ) // if already an image - { - if ( image2 != image ) // and image are different - { - if( image.save( patha ) ) - Amarok.Window.Statusbar.shortMessage( "Copy-Cover has written " + patha ); - else - Amarok.Window.Statusbar.shortMessage( "Copy-Cover can not write " + patha ); - } - } - else - { - if( image.save( patha ) ) - Amarok.Window.Statusbar.shortMessage( "Copy-Cover has written " + patha ); - else - Amarok.Window.Statusbar.shortMessage( "Copy-Cover can not write " + patha ); - } - } - - if ( writeArtistAlbum == true ) - { - path+=TrackInfo.artist+"-"+TrackInfo.album+".png"; - - // try to load the image first, to prevent rewritting - var image2 = new QImage( path ); - if ( !image2.isNull() ) // if already an image - { - if ( image2 != image ) // and image are different - { - if( image.save(path ) ) - Amarok.Window.Statusbar.shortMessage( "Copy-Cover has written " + path ); - else - Amarok.Window.Statusbar.shortMessage( "Copy-Cover can not write " + path ); - } - } - else - { - - if( image.save( path ) ) - Amarok.Window.Statusbar.shortMessage( "Copy-Cover has written " + path ); - else - Amarok.Window.Statusbar.shortMessage( "Copy-Cover can not write " + path ); - } - } - } - else - Amarok.Window.Statusbar.shortMessage( "Copy-Cover can not read the image" ); - - } - else - { - Amarok.debug( "COPY-COVER -> Track not valid " ); - } -} - - -function saveConfiguration() -{ - //Pretty messy :S - if ( mainWindow.widget.checkBox.checked ) - { - Amarok.Script.writeConfig( "writeCover", "true" ); - writeCover = true; - } - else - { - Amarok.Script.writeConfig( "writeCover", "false" ); - writeCover = false; - } - if ( mainWindow.widget.checkBox_2.checked ) - { - Amarok.Script.writeConfig( "writeArtistAlbum", "true" ); - writeArtistAlbum = true; - } - else - { - Amarok.Script.writeConfig( "writeArtistAlbum", "false" ); - writeArtistAlbum = false; - } -} - -function readConfiguration() -{ - if ( Amarok.Script.readConfig( "writeCover", "true" ) == "true" ) - mainWindow.widget.checkBox.setChecked( true ); - else - mainWindow.widget.checkBox.setChecked( false ); - - if ( Amarok.Script.readConfig( "writeArtistAlbum", "false" ) == "false" ) - mainWindow.widget.checkBox_2.setChecked( false ); - else - mainWindow.widget.checkBox_2.setChecked( true ); - -} - -function openSettings() -{ - mainWindow.show(); - Amarok.debug( "COPY-COVER -> Show configuration" ); -} - -function init() -{ - try - { - // Ui stuff - var UIloader = new QUiLoader( this ); - var uifile = new QFile ( Amarok.Info.scriptPath() + "/copycover.ui" ); - uifile.open( QIODevice.ReadOnly ); - mainWindow = UIloader.load( uifile, this ); //load the ui file - uifile.close(); - - // read configuration - readConfiguration(); - - // connect the button ok/cancel to save/read config. - mainWindow.buttonBox.accepted.connect( saveConfiguration ); - mainWindow.buttonBox.rejected.connect( readConfiguration ); - - // Add tool menu, and a callback - Amarok.Window.addSettingsMenu( "copycov", "Copy Cover Settings", "amarok" ); - Amarok.Window.SettingsMenu.copycov['triggered()'].connect(openSettings ); - - // call every track changed - Amarok.Engine.trackChanged.connect( copyCover ) ; - } - catch( err ) - { - Amarok.debug( err ); - } -} - -var writeCover = true; -var writeArtistAlbum = false; -init(); - - - - - diff --git a/amarok/playground/src/scripts/copycover/script.spec b/amarok/playground/src/scripts/copycover/script.spec deleted file mode 100644 index b78e1c57..00000000 --- a/amarok/playground/src/scripts/copycover/script.spec +++ /dev/null @@ -1,17 +0,0 @@ -[Desktop Entry] -Icon=amarok -Type=script -ServiceTypes=KPluginInfo - -Name=Copy-cover -Comment=Copy cover image to local file - -X-KDE-PluginInfo-Author=Simon Esneault -X-KDE-PluginInfo-Email=simon.esneault@gmail.com -X-KDE-PluginInfo-Name=Copy-cover -X-KDE-PluginInfo-Version=1.0.0 -X-KDE-PluginInfo-Category=Generic -X-KDE-PluginInfo-Website=http://amarok.kde.org/ -X-KDE-PluginInfo-Depends=Amarok2.0 -X-KDE-PluginInfo-License=GPL -X-KDE-PluginInfo-EnabledByDefault=false diff --git a/amarok/playground/src/scripts/danish_streams_service/CMakeLists.txt b/amarok/playground/src/scripts/danish_streams_service/CMakeLists.txt deleted file mode 100644 index cd7c24ae..00000000 --- a/amarok/playground/src/scripts/danish_streams_service/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ - -install( FILES - script.spec - main.js - DESTINATION ${DATA_INSTALL_DIR}/amarok/scripts/danish_streams_service -) - diff --git a/amarok/playground/src/scripts/danish_streams_service/main.js b/amarok/playground/src/scripts/danish_streams_service/main.js deleted file mode 100755 index 9c8014b7..00000000 --- a/amarok/playground/src/scripts/danish_streams_service/main.js +++ /dev/null @@ -1,150 +0,0 @@ -/*######################################################################### -# # -# Simple script for testing the scriptable service browser # -# by creating a simple static browser with some cool radio # -# streams. URLs shamelessly stolen from Cool-Streams.xml. # -# # -# Copyright # -# (C) 2007, 2008 Nikolaj Hald Nielsen # -# (C) 2008 Peter ZHOU # -# (C) 2008 Mark Kretschmann # -# # -# This program 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 2 of the License, or # -# (at your option) any later version. # -# # -# This program 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 this program; if not, write to the # -# Free Software Foundation, Inc., # -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # -##########################################################################*/ - -function Station( name, url, description ) -{ - this.name = name; - this.url = url; - this.description = description; -} - - -categories = new Object; - - -var p4Desc = "P4 er den største og mest aflyttede danske radiokanal med et mix af landsdækkende og regionale programmer. Fra DRs 11 regioner følger P4 lytterne døgnet rundt med et alsidigt udbud af moderne public service radio.

Fra DRs 11 regioner hjælper vi dig igennem din dag med god musik; vi giver dig både de brede og de hurtige nyheder, og så kan vi hjælpe dig på vej i trafikken.

P4 - nærmest din egen radio."; - - -categories["Danmarks Radio"]= new Array ( - new Station( "P1", "http://wmscr1.dr.dk/e02ch01m?wmcontentbitrate=300000", "P1 er den moderne oplysningskanal med nyheder og samfundsstof, der skaber indsigt. Her sættes politik og hverdag til debat i interviews, analyser og reportager. P1 søger årsager og tendenser bag de aktuelle nyheder og sætter begivenhederne i perspektiv.

Man behøver ikke sidde stille og lytte i timevis for at få noget ud af P1. Vi går grundigt til værks og kommer godt i dybden, men der er mulighed for at stå af og på undervejs. Rigtig mange af P1s programmer kan downloades og høres som podcasting - hvor du vil og når du vil." ), - new Station( "P2", "http://wmscr1.dr.dk/e02ch02m?wmcontentbitrate=300000", "P2 er radiokanalen for dig som har musik og kultur som en vigtig del af dit liv, og som gerne vil opleve og følge med i alt det der sker.

P2 er for dig som elsker god musik, hvad enten den er klassisk, jazz, verdensmusik eller alt det spændende ind imellem.

På P2 bliver du hver eftermiddag i P2 Plus opdateret på alt det der sker i kulturen lige nu: film, litteratur, musik, teater, kunst og det du ikke anede eksisterede. I P2s magasinprogrammer i weekenden kan du gå mere i dybden med de dele af kulturen, der interesserer dig mest.

P2 kan du bruge både til fordybelse og som gå-til-og-fra-radio på din vej gennem dagen derhjemme eller på arbejdet, på pc'en, i bilen, i toget.." ), - new Station( "P3", "http://wmscr1.dr.dk/e02ch03m?wmcontentbitrate=300000", "P3 er radiokanalen for moderne unge og voksne, der kan lide at blive udfordret - både musikalsk og indholdsmæssigt.

Musikken på P3 er et alsidigt og varierende mix af ny spændende musik, morgendagens stjerner, nutidens hits og banebrydende klassikere.

Journalistisk sender P3 både P3 Nyheder klokken hel og uddybende interviews morgen og eftermiddag, ofte med usædvanlige vinkler på nutidige og aktuelle emner.

Satiren på P3 er ikke kun sjov og fis. P3s satire har vid og bid, og kradser i både aktuelle og klassiske emner som optager danskerne.

Sporten byder på intens og direkte dækning af de store begivenheder i både ind- og udland, samtidig med at der informeres bredt om mange idrætsgrene. " ), - new Station( "P4 Bornholm", "http://wmscr1.dr.dk/e04ch08m?wmcontentbitrate=300000", p4Desc ), - new Station( "P4 Fyn", "http://wmscr1.dr.dk/e04ch06m?wmcontentbitrate=300000", p4Desc ), - new Station( "P4 København", "http://wmscr1.dr.dk/e04ch09m?wmcontentbitrate=300000", p4Desc ), - new Station( "P4 Midt & Vest", "http://wmscr1.dr.dk/e04ch02m?wmcontentbitrate=300000", p4Desc ), - new Station( "P4 Nordjylland", "http://wmscr1.dr.dk/e04ch01m?wmcontentbitrate=300000", p4Desc ), - new Station( "P4 Sjælland", "http://wmscr1.dr.dk/e04ch07m?wmcontentbitrate=300000", p4Desc ), - new Station( "P4 Syd", "http://wmscr1.dr.dk/e04ch05m?wmcontentbitrate=300000", p4Desc ), - new Station( "P4 Trekanten", "http://wmscr1.dr.dk/e04ch04m?wmcontentbitrate=300000", p4Desc ), - new Station( "P4 Østjyllands Radio", "http://wmscr1.dr.dk/e04ch03m?wmcontentbitrate=300000", p4Desc ), - new Station( "P5", "http://wmscr1.dr.dk/e06ch01m?wmcontentbitrate=300000", "P5 byder på folkekære værter som Nis Boesdal, Jørgen de Mylius, Hans Otto Bisgaard, Søren Dahl, Karlo Staunskjær og Margaret Lindhardt.

Der er plads til både viser, dansktop, populærmusik og mulighed for at genhøre det bedste fra DR’s arkiver. Det sker i programmer som Dansktoppen, Gyldne Genhør, Giro 413, Eldorado, Nis på DAB og Cafe Hack." ), - new Station( "DR Allegro", "http://wmscr1.dr.dk/e06ch03m?wmcontentbitrate=300000", "På DR Allegro finder du velkendt og populær klassisk musik. Foruden orkestermusik, klavermusik og kendte operaarier finder du filmmusik, musicalmelodier og danske sange.

Danske komponister og danske musikere er også rigt repræsenteret på kanalen, som kan høres på enhver pc verden over." ), - new Station( "DR Barometer", "http://wmscr1.dr.dk/e02ch09m?wmcontentbitrate=300000", "DR Barometer - hangout for musikalske soulmates og postcentral for folk med noget på hjerte.

Med fokus på indierock, indietronica, alternativ country og elektronica præsenterer kanalen en perlerække af danske og internationale bands hentet fra universet omkring det legendariske radioprogram Det Elektriske Barometer på P3.

Kanalen spiller aktuelle Barometerhits blandet op med klassikere fra programmets 20 årige historie - alt sammen krydret med lytternes stemmer, ønsker og tanker fra tankevæggen, samt genudsendelser af nye og gamle Barometerudsendelser." ), - new Station( "DR MGP", "http://wmscr1.dr.dk/e06ch09m?wmcontentbitrate=300000", "DR MGP er kanalen hvor du kan høre alle sangene fra MGP - krydret med de andre sange som MGP stjernerne også har lavet. Mathias, Amalie, SEB, Nicolai og alle de andre på din egen MGP kanal." ), - new Station( "DR Boogieradio", "http://wmscr1.dr.dk/e02ch07m?wmcontentbitrate=300000", "DR Boogieradio spiller alle de hits du kender fra Boogie på tv og net. Søde Sys Bjerre og Jeppe \"fingerslap\" Voldum er dine værter, og ligesom musikken kan du altid høre dem lige her, 24 timer i døgnet! Du kan også genhøre ugens aktuelle Boogieliste og de bedste interviews fra tv." ), - new Station( "DR Country", "http://wmscr1.dr.dk/e06ch06m?wmcontentbitrate=300000", "DR Country er hjemsted for countrygenren i den klassiske forstand.

Genren fortolkes bredt på kanalen, så du finder eksempelvis også de relaterede genrer bluegrass, countryrock og singer/songwriters. DR Country indeholder en blanding af god ny country og genrens ældre klassikere. " ), - new Station( "DR Dansktop", "http://wmscr1.dr.dk/e02ch11m?wmcontentbitrate=300000", "DR Dansktop er kanalen for alle dem, der holder af dansktopmusik.

Hele døgnet sender DR Dansktop alle de bedste sange indenfor genren. Du kan høre dansktopmusikken, som den lyder i dag, men også høre ældre hits.

Selvom fire ud af fem sange på DR Dansktop er danske, kan du også høre svensk og tysk musik. Både nyere musik fra de to lande samt ældre numre, der har inspireret dansktoppens danske hits. " ), - new Station( "DR Electronica", "http://wmscr1.dr.dk/e06ch10m?wmcontentbitrate=300000", "DR Electronica er for lyttere med åbne ører, hang til elektroniske klange og rytmiske finurligheder. Både feinschmeckere, nybegyndere og nysgerrige kan være med i dette mindre kluborienterede univers.

DR Electronica er håndplukkede danske og internationale produktioner, der gør en forskel i dag og i fremtiden." ), - new Station( "DR Evergreen", "http://wmscr1.dr.dk/e06ch07m?wmcontentbitrate=300000", "DR Evergreen er for alle - unge som ældre - med en forkærlighed for den klassiske fortolkning af kendte populærmelodier - evergreens.

På kanalen finder du danske og udenlandske evergreens, primært inden for easy listening-genren , ofte fremført med sangsolist akkompagneret af orkester, strygere og kor. Nyere indspilninger med yngre kunstnere, som stilmæssigt passer ind i kanalen, er også repræsenteret på DR Evergreen." ), - new Station( "DR Folk", "http://wmscr1.dr.dk/e06ch11m?wmcontentbitrate=300000", "DR Folk er farverig og afvekslende musik, der spænder fra dansk og nordisk folkrock til songwriters og folkemusik fra de britiske øer og Nordamerika.

DR Folk har sine rødder i den vestlige folkemusik, og rummer hele den spændende udvikling fra 60’erne revival til de helt aktuelle udgivelser." ), - new Station( "DR Hiphop", "http://wmscr1.dr.dk/e02ch08m?wmcontentbitrate=300000", "DR Hip Hop spiller det bedste inden for genren - fra undergrund til mainstream. Med vægten på det nyeste fra dansk og U.S. Hip Hop, holder vi dig konstant opdateret og supplerer med de største klassikere gennem tiderne. Det hele blandet godt op med afstikkere til U.K., norden og resten af verden. Og så er det uden snak - kun det pureste Hip Hop...24/7!" ), - new Station( "DR Hit", "http://wmscr1.dr.dk/e04ch10m?wmcontentbitrate=300000", "DR Hit er blød popmusik med masser af gode hits og nyheder på hele timer.

DR Hit - Soundtracket til en lidt bedre dag." ), - new Station( "DR Jazz", "http://wmscr1.dr.dk/e02ch05m?wmcontentbitrate=300000", "DR Jazz er kanalen der kun sender jazzmusik - 24 timer i døgnet på DAB-radio og net.

DR Jazz favner bredt. Væsentligste kriterium er kvalitet med det bedste fra alle jazzens genrer og perioder; og selvfølgelig med særlig opmærksomhed på den danske jazz og DR Big Band.

Det er i mikset af musikken, vi skiller os ud fra andre jazzkanaler. Vi spiller det, du gerne vil høre, og så sørger vi også for, at du bliver glædelig overrasket og møder nye kunstnere og konstellationer, du ikke vidste, at du kunne lide eller kendte i forvejen.

DR Jazz genudsender også jazzredaktionens udsendelser fra DR P2" ), - new Station( "DR Klassisk", "http://wmscr1.dr.dk/e02ch06m?wmcontentbitrate=300000", "DR Klassisk på DAB, kabel og net er kanalen for den klassiske musikelsker.

DR Klassisk sender hele klassiske værker og hele koncerter - mest live-optagelser, nye eller fra arkivet. Musikken bliver kort og kompetent præsenteret af vore faste værter.

På DR Klassisk har den klassiske musik sit fulde udfoldelsesrum og afbrydes ikke af nyheder eller taleindslag.

DR Klassisk er dagen igennem det klassiske alternativ til P2, men vi genudsender også de flotte aften koncerter fra P2 - bl.a. torsdagskoncerterne. En mulighed for at høre eller genhøre.

DR Klassisk er den rene klassiske kanal på musikkens præmisser." ), - new Station( "DR Modern Rock", "http://wmscr2.dr.dk/e06ch02m?wmcontentbitrate=300000", "DR Modern Rock er kanalen for dig, hvis rockmusikken bare ikke kan blive nok udadvendt, tempofyldt, varieret, kantet, grænsesøgende, dynamisk og gennemslagskraftig.

Kanalen favner både genrens nyeste, hotteste og mest aktuelle hits fra ind- og udland, men er også stedet hvor du møder undergrundens myriader af unge, talentfulde - især danske - bands." ), - new Station( "DR Nyheder", "http://wmscr2.dr.dk/e04ch11m?wmcontentbitrate=300000", "Lyt til nyheder, når du har lyst. Hør de seneste nyheder - opdateret hver time - døgnet rundt. " ), - new Station( "DR Oline", "http://wmscr1.dr.dk/e04ch12m?wmcontentbitrate=300000", "Oline er radio for børn mellem 3-7 år. Klokken 7.00 og kl. 18.30 er der nyt på Oline hver dag.

Oline indeholder masser af historier og det er alt fra gamle klassiske eventyr til børnebøger der lige er udkommet.

Der er masser af børn der fortæller om stor og små ting i deres dagligdag - venskaber kæledyr og den nye cykel Sofus fik i fødselsdagsgave - og det er også på Oline du kan høre Anna og Lotte, Sigurds Bjørneradio og Kaj og Andrea i radioversionen.

Og så er der masser af musik for lige netop denne målgruppe på Oline. Her finder du den musik som er skrevet til børn - men også engang imellem musik som får en til at spærre ørerne op og blive overrasket. " ), - new Station( "DR P5000", "http://wmscr2.dr.dk/e06ch04m?wmcontentbitrate=300000", "P5000 er Mascha Vang, Anders Stjernholm og Anders Bonde. Blondinen, festaben og gammelsmølfen er holdet fra helvede. Mixet med sladdernyt og musikken du elsker.

Fredag og lørdag skruer vi ekstra op for festen, med top 25 på dancecharten plus to timer mixet af superstar-dj Morten Breum." ), - new Station( "DR Pop DK", "http://wmscr1.dr.dk/e02ch10m?wmcontentbitrate=300000", "" ), - new Station( "DR R&B", "http://wmscr1.dr.dk/e06ch08m?wmcontentbitrate=300000", "Er du til bløde toner, så spiller DR R&B musik for dig, der er til R&B og soulmusik. Kanalen indeholder overvejende ny musik, hvilket betyder, at det er her, du kan lytte til de nye hits, og hvad der måtte være på vej.

På kanalen kan du høre flere nye numre fra nye udgivelser - og ikke kun én single ad gangen. DR R&B er også klassikere inden for genren og ældre soulhits. Det er også her, du kan tjekke specielle remixes, white labels og meget mere. " ), - new Station( "DR Rock", "http://wmscr1.dr.dk/e02ch04m?wmcontentbitrate=300000", "DR Rock er rock uden stop - 24 timer i døgnet på DAB og nettet.

DR Rock er en rendyrket rockkanal med fokus på den klassiske rock fra 60'erne til i dag. Musikken er et mix af de store klassikere til de bedste albumtracks.

DR Rock er kanalen for alle rockelskere. De forskellige genrer inden for den populære rock og med de kunstnere der har defineret og ændret rocken gennem tiderne." ), - new Station( "DR Soft", "http://wmscr1.dr.dk/e06ch05m?wmcontentbitrate=300000", "DR Soft er til dig, der elsker en god popmelodi.

På DR Soft kan du både høre de nyeste hits og de gode gamle popklassikere fra stjerner som Phil Collins, George Michael og Eurythmics.

25 procent af den spillede musik er dansk, og der er masser af variation på playlisten.

Skriv til redaktionen:

Att: DR Soft
DR Musik og Medier
DR Byen
Emil Holms Kanal 20
0999 København C
Mail: dr-soft@dr.dk" ), - new Station( "DR Spillemand", "http://wmscr1.dr.dk/e04ch11m?wmcontentbitrate=300000", "DR Spillemand er farverig dansk, nordisk og irsk/skotsk folkemusik som den lyder i dag - spillet og sunget af musikere, der tager afsæt i gamle traditioner.

Rødder, fornyelse og nysgerrighed er kerneordene for kanalen, som især fokuserer på akustisk, nordisk musik. " ), - new Station( "DR World", "http://wmscr1.dr.dk/e06ch12m?wmcontentbitrate=300000", "DR World tilbyder som eneste danske radiokanal verdensmusik døgnet rundt. Her kan du høre det nyeste fra 'World Music Charts Europe' krydret med klassikerne fra alle verdensdele - det velkendte og det ukendte.

DR World afspejler storbykulturen og tager udgangspunkt i moderne fortolkning af traditionel musik fra hele kloden, inklusive den danske verdensmusikscene. Hovedparten af musikken, du hører her, er udgivet indenfor de seneste 10 år.

DR World er med dig - døgnet rundt - verden rundt." ) -); - -categories["Diverse"]= new Array ( - new Station( "Radio 2", "http://dix.media.webpartner.dk/radio2-96", "" ), - new Station( "The Voice", "http://dix.media.webpartner.dk/voice128", "" ), - new Station( "Radio 100FM", "http://onair.100fmlive.dk/100fm_live.mp3", "" ), - new Station( "Radio 100FM Soft", "http://onair.100fmlive.dk/soft_live.mp3", "" ), - new Station( "Cool FM", "http://stream2.coolfm.dk:80/CoolFM128", "" ), - new Station( "ANR Hit FM2", "mms://media.xstream.dk/Radio_Hit_FM", "" ), - new Station( "ANR Guld FM", "mms://media.xstream.dk/Radio_Guld_FM", "" ), - new Station( "Radio ABC", "mms://media.xstream.dk/Radio_ABC", "" ), - new Station( "ABC Solo FM", "mms://media.xstream.dk/Radio_Solo_FM ", "" ), - new Station( "Radio Alfa Østjylland", "mms://media.xstream.dk/Radio_Alfa", "" ), - new Station( "Radio Skive", "mms://media.xstream.dk/Radio_Skive", "" ), - new Station( "Radio Mojn", "mms://media.xstream.dk/Radio_Mojn", "" ), - new Station( "Radio 3", "mms://media.xstream.dk/Radio_3", "" ), - new Station( "Radio Sydhavsøerne", "mms://media.xstream.dk/Radio_Sydhavsoerene", "" ), - new Station( "NOVAfm", "mms://stream.ventelo.dk/FM5", "" ) -); - - -function DanishStreamsService() -{ - Amarok.debug( "creating Danish Radio Streams service..." ); - ScriptableServiceScript.call( this, "Danish Radio Streams", 2, "List of free online radio stations from Denmark", "List of free online radio stations from Denmark", false ); - Amarok.debug( "done." ); -} - -function onPopulating( level, callbackData, filter ) -{ - if ( level == 1 ) - { - for( att in categories ) - { - Amarok.debug ("att: " + att + ", " + categories[att].name) - - item = Amarok.StreamItem; - item.level = 1; - item.callbackData = att; - item.itemName = att; - item.playableUrl = ""; - item.infoHtml = ""; - script.insertItem( item ); - - } - script.donePopulating(); - - } - else if ( level == 0 ) - { - Amarok.debug( " Populating station level..." ); - //add the station streams as leaf nodes - - var stationArray = categories[callbackData]; - - for ( i = 0; i < stationArray.length; i++ ) - { - item = Amarok.StreamItem; - item.level = 0; - item.callbackData = ""; - item.itemName = stationArray[i].name; - item.playableUrl = stationArray[i].url; - item.infoHtml = stationArray[i].description; - item.artist = "Netradio"; - script.insertItem( item ); - } - script.donePopulating(); - } -} - -script = new DanishStreamsService(); -script.populate.connect( onPopulating ); diff --git a/amarok/playground/src/scripts/danish_streams_service/script.spec b/amarok/playground/src/scripts/danish_streams_service/script.spec deleted file mode 100644 index e69cb915..00000000 --- a/amarok/playground/src/scripts/danish_streams_service/script.spec +++ /dev/null @@ -1,16 +0,0 @@ -[Desktop Entry] -Icon=get-hot-new-stuff-amarok -Type=script -ServiceTypes=KPluginInfo - -Name=Danish Radio Streams -Comment=A script that sets up a service containing a list of freely available Danish online radio stations - -X-KDE-PluginInfo-Author=Nikolaj Hald Nielsen -X-KDE-PluginInfo-Email=nhnFreespirit@gmail.com -X-KDE-PluginInfo-Name=Danish Radio Streams -X-KDE-PluginInfo-Version=0.2 -X-KDE-PluginInfo-Category=Scriptable Service -X-KDE-PluginInfo-Depends=Amarok2.0 -X-KDE-PluginInfo-License=LGPL -X-KDE-PluginInfo-EnabledByDefault=false \ No newline at end of file diff --git a/amarok/playground/src/scripts/encoding_fixer/CMakeLists.txt b/amarok/playground/src/scripts/encoding_fixer/CMakeLists.txt deleted file mode 100644 index cd7a17d3..00000000 --- a/amarok/playground/src/scripts/encoding_fixer/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -install( FILES - script.spec - main.js - main.ui - DESTINATION ${DATA_INSTALL_DIR}/amarok/scripts/encoding_fixer -) - diff --git a/amarok/playground/src/scripts/encoding_fixer/main.js b/amarok/playground/src/scripts/encoding_fixer/main.js deleted file mode 100644 index e4f85b05..00000000 --- a/amarok/playground/src/scripts/encoding_fixer/main.js +++ /dev/null @@ -1,270 +0,0 @@ -/************************************************************************** -* Encoding Fixer Script for Amarok 2.0 * -* Last Modified: 22/11/2008 * -* * -* Copyright * -* (C) 2008 Peter ZHOU * -* * -* This program 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 2 of the License, or * -* (at your option) any later version. * -* * -* This program 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 this program; if not, write to the * -* Free Software Foundation, Inc., * -* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * -**************************************************************************/ - -Importer.loadQtBinding( "qt.core" ); -Importer.loadQtBinding( "qt.gui" ); -Importer.loadQtBinding( "qt.uitools" ); - -function checkerURL( encoding, webencoding, url, querystr ) -{ - this.encoding = encoding; - this.webencoding = webencoding; - this.url = url; - this.querystr = querystr; -} - -function fixencoding( encoding ) -{ -//Yes = 3, No = 4 - if ( Amarok.alert( "

the track might be encoded in " + encoding + ".

" - + "

Title: " + Amarok.Lyrics.QStringtoUtf8( Amarok.Engine.currentTrack().title, encoding ) + "

" - + "

Artist: " + Amarok.Lyrics.QStringtoUtf8( Amarok.Engine.currentTrack().artist, encoding ) + "

" -+ + "

Album: " + Amarok.Lyrics.QStringtoUtf8( Amarok.Engine.currentTrack().album, encoding ) + "

" - + "

Comment: " + Amarok.Lyrics.QStringtoUtf8( Amarok.Engine.currentTrack().comment, encoding ) + "

" - + "

Do you want to convert it to UTF-8?

", "questionYesNo" ) == 3 ) - { - Amarok.debug( "converting the track tag to " + encoding + "..." ); - Amarok.Engine.currentTrack().title = Amarok.Lyrics.QStringtoUtf8( Amarok.Engine.currentTrack().title, encoding ); - Amarok.Engine.currentTrack().artist = Amarok.Lyrics.QStringtoUtf8( Amarok.Engine.currentTrack().artist, encoding ); - Amarok.Engine.currentTrack().album = Amarok.Lyrics.QStringtoUtf8( Amarok.Engine.currentTrack().album, encoding ); - Amarok.Engine.currentTrack().comment = Amarok.Lyrics.QStringtoUtf8( Amarok.Engine.currentTrack().comment, encoding ); - } -} - -function checkGB18030( gb18030reply ) -{ - try - { - this.pageresult = gb18030reply; -// Amarok.debug( reply ); - Amarok.debug( "searching..." ); - this.resultPos = this.pageresult.search( /*/ ); - - if( this.resultPos > 0 ) - { - Amarok.debug( "found info at pos " + this.resultPos ); - Amarok.debug( "the encoding of the track might be: GB18030" ); - fixencoding( "GB18030" ); - } - else - { - Amarok.debug( "cannot find info using encoding: GB18030" ); - } - } - catch( err ) - { - Amarok.debug ( err ); - } -} - -function checkBig5( big5reply ) -{ - try - { - this.pageresult = big5reply; -// Amarok.debug( reply ); - Amarok.debug( "searching..." ); - this.resultPos = this.pageresult.search( /*/ ); - - if( this.resultPos > 0 ) - { - Amarok.debug( "found info at pos " + this.resultPos ); - Amarok.debug( "the encoding of the track might be: Big5" ); - fixencoding( "Big5" ); - } - else - { - Amarok.debug( "cannot find info using encoding: Big5" ); - } - } - catch( err ) - { - Amarok.debug ( err ); - } -} - -function checkKOI8R( koi8rreply ) -{ - try - { - this.pageresult = koi8rreply; -// Amarok.debug( reply ); - Amarok.debug( "searching..." ); - this.resultPos = this.pageresult.search( /style="margin-right: 30px;">*/ ); - - if( this.resultPos == 0 ) - { - Amarok.debug( "found info at pos " + this.resultPos ); - Amarok.debug( "the encoding of the track might be: KOI8-R" ); - fixencoding( "KOI8-R" ); - } - else - { - Amarok.debug( "cannot find info using encoding: KOI8-R" ); - } - } - catch( err ) - { - Amarok.debug ( err ); - } -} - -function urlGenerator( title, urlInfo ) -{ - try - { - Amarok.debug( "checking for track title: " + title ); - - Amarok.debug( "checking encoding candidate: " + urlInfo.encoding ); - this.info = Amarok.Lyrics.QStringtoUtf8( title, urlInfo.encoding ); - Amarok.debug( "trying: " + this.info ); - - this.encodedTitleKey = Amarok.Lyrics.fromUtf8( urlInfo.querystr, urlInfo.webencoding ); - this.encodedTitle = Amarok.Lyrics.fromUtf8( this.info, urlInfo.webencoding ); - this.url = new QUrl( urlInfo.url ); - this.url.addEncodedQueryItem( this.encodedTitleKey, this.encodedTitle ); - return this.url; - } - catch( err ) - { - Amarok.debug ( err ); - } - -} - -var urlInfo = new Array ( - new checkerURL( "GB18030", "GB2312", "http://mp3.sogou.com/gecisearch.so", "query" ), - new checkerURL( "Big5", "GB2312", "http://mp3.sogou.com/gecisearch.so", "query" ), - new checkerURL( "KOI8-R", "KOI8-R", "http://www.zvuki.ru/search/?what=song", "query" ) -// new checkerURL( "UTF-8", "", "", "" ) -); - -function doubleChecker() -{ - this.title = Amarok.Engine.currentTrack().title; - //checking gb18030 - if ( simpleChinese_Module ) - { - this.gb18030url = urlGenerator( this.title, this.urlInfo[0] ); - this.gb18030d = new Downloader( this.gb18030url, checkGB18030, urlInfo[0].webencoding ); - } - //checking big5 - if ( triditionalChinese_Module ) - { - this.big5url = urlGenerator( this.title, this.urlInfo[1] ); - this.big5d = new Downloader( this.big5url, checkBig5, urlInfo[1].webencoding ); - } - //checking KOI8-R - if ( Russian_Module ) - { - this.koi8rurl = urlGenerator( this.title, this.urlInfo[2] ); - this.koi8rd = new Downloader( this.koi8rurl, checkKOI8R, urlInfo[2].webencoding ); - } -} - -function saveConfiguration() -{ -//Pretty messy :S - if ( mainWindow.children()[1].children()[1].checked ) - { - Amarok.Script.writeConfig( "simple_Chinese", "true" ); - simpleChinese_Module = true; - } - else - { - Amarok.Script.writeConfig( "simple_Chinese", "false" ); - simpleChinese_Module = false; - } - if ( mainWindow.children()[1].children()[2].checked ) - { - Amarok.Script.writeConfig( "triditional_Chinese", "true" ); - triditionalChinese_Module = true; - } - else - { - Amarok.Script.writeConfig( "triditional_Chinese", "false" ); - triditionalChinese_Module = false; - } - if ( mainWindow.children()[1].children()[3].checked ) - { - Amarok.Script.writeConfig( "Russian", "true" ); - Russian_Module = true; - } - else - { - Amarok.Script.writeConfig( "Russian", "false" ); - Russian_Module = false; - } -} - -function readConfiguration() -{ - if ( Amarok.Script.readConfig( "simple_Chinese", "false" ) == "false" ) - mainWindow.children()[1].children()[1].checked = false; - else - mainWindow.children()[1].children()[1].checked = true; - if ( Amarok.Script.readConfig( "triditional_Chinese", "false" ) == "false" ) - mainWindow.children()[1].children()[2].checked = false; - else - mainWindow.children()[1].children()[2].checked = true; - if ( Amarok.Script.readConfig( "Russian", "false" ) == "false" ) - mainWindow.children()[1].children()[3].checked = false; - else - mainWindow.children()[1].children()[3].checked = true; -} - -function onConfigure() -{ - mainWindow.show(); -} - -function init() -{ - try - { - var UIloader = new QUiLoader( this ); - var uifile = new QFile ( Amarok.Info.scriptPath() + "/main.ui" ); - uifile.open( QIODevice.ReadOnly ); - mainWindow = UIloader.load( uifile, this); - uifile.close(); - readConfiguration(); - mainWindow.children()[0].accepted.connect( saveConfiguration ); - mainWindow.children()[0].rejected.connect( readConfiguration ); - - Amarok.Window.addToolsSeparator(); - Amarok.Window.addToolsMenu( "checkencoding", "Check Encodings" ); - Amarok.Window.addSettingsSeparator(); - Amarok.Window.addSettingsMenu( "configencoding", "Encoding Fixer Settings..." ); - Amarok.Window.ToolsMenu.checkencoding.triggered.connect( doubleChecker ); - Amarok.Window.SettingsMenu.configencoding.triggered.connect( onConfigure ); - } - catch( err ) - { - Amarok.debug ( err ); - } -} - -var simpleChinese_Module = false; -var triditionalChinese_Module = false; -var Russian_Module = false; -init(); \ No newline at end of file diff --git a/amarok/playground/src/scripts/encoding_fixer/main.ui b/amarok/playground/src/scripts/encoding_fixer/main.ui deleted file mode 100644 index fb41a1af..00000000 --- a/amarok/playground/src/scripts/encoding_fixer/main.ui +++ /dev/null @@ -1,120 +0,0 @@ - - mainDialog - - - - 0 - 0 - 342 - 273 - - - - Encoding Fixer - - - - - 140 - 230 - 181 - 32 - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - 10 - 50 - 318 - 171 - - - - - - - Simple Chinese (GB18030, GB2312, GBK) - - - - - - - Triditional Chinese (Big5, BIG5-HKSCS) - - - - - - - Russian (KOI8-R) - - - - - - - - - 20 - 20 - 261 - 22 - - - - - 10 - 50 - false - - - - Please enable the modules you need: - - - - - - - buttonBox - accepted() - mainDialog - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - mainDialog - reject() - - - 316 - 260 - - - 286 - 274 - - - - - diff --git a/amarok/playground/src/scripts/encoding_fixer/script.spec b/amarok/playground/src/scripts/encoding_fixer/script.spec deleted file mode 100644 index 56a0cf27..00000000 --- a/amarok/playground/src/scripts/encoding_fixer/script.spec +++ /dev/null @@ -1,16 +0,0 @@ -[Desktop Entry] -Icon=edit-find -Type=script -ServiceTypes=KPluginInfo - -Name=Encoding Fixer -Comment=Double Check and Fix non-UTF-8 mp3 id3v1 tags - -X-KDE-PluginInfo-Author=Peter ZHOU -X-KDE-PluginInfo-Email=peterzhoulei@gmail.com -X-KDE-PluginInfo-Name=Encoding Fixer -X-KDE-PluginInfo-Version=1.0 -X-KDE-PluginInfo-Category=Generic -X-KDE-PluginInfo-Depends=Amarok2.0 -X-KDE-PluginInfo-License=GPL -X-KDE-PluginInfo-EnabledByDefault=false diff --git a/amarok/playground/src/scripts/npr_service/CMakeLists.txt b/amarok/playground/src/scripts/npr_service/CMakeLists.txt deleted file mode 100644 index b1ab1499..00000000 --- a/amarok/playground/src/scripts/npr_service/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -install( FILES - COPYING - README - main.js - script.spec - DESTINATION ${DATA_INSTALL_DIR}/amarok/scripts/npr_service -) -#kde4_install_icons( ${DATA_INSTALL_DIR}/amarok/icons ) diff --git a/amarok/playground/src/scripts/npr_service/COPYING b/amarok/playground/src/scripts/npr_service/COPYING deleted file mode 100644 index b74ec101..00000000 --- a/amarok/playground/src/scripts/npr_service/COPYING +++ /dev/null @@ -1,340 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program 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 2 of the License, or - (at your option) any later version. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. diff --git a/amarok/playground/src/scripts/npr_service/README b/amarok/playground/src/scripts/npr_service/README deleted file mode 100644 index 90f34ccc..00000000 --- a/amarok/playground/src/scripts/npr_service/README +++ /dev/null @@ -1,27 +0,0 @@ -
NPR
- -

-About:
-A script that allows you to browse and listen to your favorite NPR content, including audio from most NPR programs dating back to 1995 as well as text, images and other web-only content from NPR and NPR member stations.
This archive consists of over 250,000 stories that are grouped into more than 5,000 different aggregations. -

-

-To see descriptions, images, and other supplemental (non-audio) content, add the "Service Info" applet to your Context View. -

- -

-Usage:
-Just run the script, and a new service will be created in the internet service browser. Don't forget to enable the "Service Info" applet. -

- -

-Dependencies:
-

    -
  • Amarok 2.0
  • -
-

- -

-Author:
-Casey Link (unnamedrambler@gmail.com) -

- diff --git a/amarok/playground/src/scripts/npr_service/TODO b/amarok/playground/src/scripts/npr_service/TODO deleted file mode 100644 index 54c48fbe..00000000 --- a/amarok/playground/src/scripts/npr_service/TODO +++ /dev/null @@ -1,7 +0,0 @@ -2008.11.03 - * Display more than 20 stories under a topic - * A "Get more stories" button? - * Sort content by Date! - * Put more stuff in the service info applet. - * Do context searches - * Now playing info: reviews, and interviews. diff --git a/amarok/playground/src/scripts/npr_service/main.js b/amarok/playground/src/scripts/npr_service/main.js deleted file mode 100755 index 8674f46d..00000000 --- a/amarok/playground/src/scripts/npr_service/main.js +++ /dev/null @@ -1,305 +0,0 @@ -/*########################################################################### -# A script that lets you browse content made available by the NPR # -# API. It also retrieves context specific content # -# # -# Copyright # -# (C) 2008 Casey Link # -# (C) 2008 Nikolaj Hald Nielsen # -# (C) 2008 Peter ZHOU # -# (C) 2008 Sven Krohlas # -# # -# This program 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 2 of the License, or # -# (at your option) any later version. # -# # -# This program 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 this program; if not, write to the # -# Free Software Foundation, Inc., # -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # -###########################################################################*/ - -Importer.loadQtBinding( "qt.core" ); -Importer.loadQtBinding( "qt.xml" ); -Importer.loadQtBinding( "qt.network" ); - -service_name = "NPR"; -html = "NPR"; - - -apikey = "MDAyMjI0OTQyMDEyMjU3MjgzNDM3ZDBjZg001"; -baseUrl = "http://api.npr.org/query?apikey="+apikey+"&id="; -artistsUrl = new QUrl( "http://api.npr.org/list?id=3009" ); -topicsUrl = new QUrl( "http://api.npr.org/list?id=3002" ); -genresUrl = new QUrl( "http://api.npr.org/list?id=3018" ); -programsUrl = new QUrl( "http://api.npr.org/list?id=3004" ); -biosUrl = new QUrl( "http://api.npr.org/list?id=3007" ); -columnsUrl = new QUrl( "http://api.npr.org/list?id=3003" ); -seriesUrl = new QUrl( "http://api.npr.org/list?id=3006" ); -doc = new QDomDocument("doc"); -elt = new QDomElement; -elt2 = new QDomElement; -topics = new QDomNodeList; -artists = new QDomNodeList; -initials = new QDomNodeList; -storyelements = new QDomNodeList; - -storiesNeedingUrls = new Array(); - -/* Initialization of service */ -function NPRService() { - Amarok.debug( "creating npr service..." ); - ScriptableServiceScript.call( this, "NPR", 3, "Content made available via the NPR API. Over 250,000 articles, stories, and reviews.", html, false ); - Amarok.debug( "done creating npr service!" ); -} - -/* Get info for topics */ -function topicsDownloadResult( reply ) { - Amarok.debug( "start npr topics xml parsing..." ); - try { - doc.setContent( reply ); - topics = doc.elementsByTagName( "item" ); - Amarok.debug ("got " + topics.length() + " topics!"); - - var item = Amarok.StreamItem; - item.level = 1; - item.playableUrl = ""; - - var i = 0; - var ids = ""; - for ( ; i < topics.length(); i++ ) { - elt = topics.at( i ); - elt2 = elt.firstChildElement( "title" ); - item.itemName = elt2.text(); - - elt2 = elt.firstChildElement( "additionalInfo" ); - item.infoHtml = elt2.text(); - var topicid = ""; - topicid = elt.toElement().attribute("id"); - Amarok.debug("got id " + topicid); - // this is needed to identify the item when we need to expand - // it in onPopulate( level, -->callbackData<--, filter ) - item.callbackData = topicid; // the field - script.insertItem( item ); - } - script.donePopulating() - } catch( err ) { - Amarok.debug( err ); - } -} -/*get info for artists*/ -function artistsDownloadResult( reply ) { - Amarok.debug( "start npr artists xml parsing..." ); - try { - doc.setContent( reply ); - initials = doc.elementsByTagName( "subcategory" ); - //Amarok.debug ("got " + topics.length() + " artists!"); - - var item = Amarok.StreamItem; - item.level = 1; - item.playableUrl = ""; - var j = 0; - for( ; j < initials.length(); j++ ) { - artists = initials.at(j).toElement().elementsByTagName( "item" ); - - var i = 0; - for ( ; i < artists.length(); i++ ) { - elt = artists.at( i ); - elt2 = elt.firstChildElement( "title" ); - item.itemName = elt2.text(); - item.infoHtml = ""; - - var artistid = ""; - artistid = elt.toElement().attribute("id"); - Amarok.debug("got id " + artistid); - // this is needed to identify the item when we need to expand - // it in onPopulate( level, -->callbackData<--, filter ) - item.callbackData = artistid; // the field - script.insertItem( item ); - } - } - script.donePopulating() - } catch( err ) { - Amarok.debug( err ); - } -} -/*get info for stories*/ -function storiesDownloadResult( reply ) { - Amarok.debug ("got stories..." ); - doc.setContent( reply ); - storyelements = doc.elementsByTagName( "story" ); - Amarok.debug ("got " + storyelements.length() + " stories!"); - try { - var j = 0; - for ( ; j < storyelements.length(); j++ ) { - elt = storyelements.at( j ); - - var id = elt.toElement().attribute("id", "" ); - - elt2 = elt.firstChildElement( "title" ); - var title = elt2.text(); - - elt2 = elt.firstChildElement( "teaser" ); - var teaser = elt2.text(); - - elt2 = elt.firstChildElement( "storyDate" ); - var datetime = elt2.text(); - var date = datetime.substring(0, datetime.indexOf(":") - 3); - if( date.length > 0 ) - title += " - " + date; -/* var date = new QDateTime; - title += " - " + date.fromString(elt2.text(), "ddd, dd MMM yyyy hh:mm:ss -0400").toString("ddd, dd MMM yyyy");*/ - - - elt2 = elt.firstChildElement( "audio" ); - elt2 = elt2.firstChildElement( "format" ); - elt2 = elt2.firstChildElement( "mp3" ); - var m3uurl = elt2.text(); - - elt2 = elt.firstChildElement( "byline" ); - elt2 = elt2.firstChildElement( "name" ); - var writer = elt2.text(); - //Amarok.debug ("url: " + item.playableUrl); - - Amarok.debug("Adding " + title + " by " + writer + " @ " + m3uurl); - var data = title + "\\" + m3uurl + "\\" + writer + "\\" + teaser; - storiesNeedingUrls.push(data); - } - Amarok.debug( " fetching playable urls " + storiesNeedingUrls.length); - if(storiesNeedingUrls.length > 0 ) { - var url = new QUrl( storiesNeedingUrls[storiesNeedingUrls.length-1].split("\\")[1] ) - a = new Downloader( url, playableUrlDownloadResult ); - } - } catch( err ) { - Amarok.debug( err ); - } - -} - -function playableUrlDownloadResult( reply ) { - Amarok.debug( "Got playable url result" ); - Amarok.debug(reply); - try { - html = reply; - urlrRx = new RegExp( "(http://.*\.mp3)" ); - Amarok.debug("made regex"); - var matches = html.match( urlrRx ); - var data = storiesNeedingUrls.pop().split("\\"); - if( matches ) { - var actualurl = matches[1]; - var item = Amarok.StreamItem; - item.level = 0; - item.callbackData = ""; - item.itemName = data[0]; - item.playableUrl = actualurl; - item.artist = "NPR"; - item.infoHtml = data[3]; - item.album = data[2]; - script.insertItem( item ); - } - if(storiesNeedingUrls.length > 0 ) { - var newurl = new QUrl( storiesNeedingUrls[storiesNeedingUrls.length-1].split("\\")[1] ); - Amarok.debug("fetching " + newurl + " with " + storiesNeedingUrls.length + " to go!!!"); - a = new Downloader( newurl, playableUrlDownloadResult ); - } - else // we're done getting urls - doneFetchingUrls(); - - } catch( err ) { - Amarok.debug( err ); - } -} -function doneFetchingUrls() -{ - storiesNeedingUrls = new Array(); - script.donePopulating() -} -/* Fill tree view in Amarok */ -function onPopulate( level, callbackData, filter ) { - var i = 0; - Amarok.debug( "populating npr level: " + level ); - if( level == 2 ) { - item = Amarok.StreamItem; - item.level = 2; - item.playableUrl = ""; - - item.callbackData = "stories_topic"; - item.itemName = "Topics"; - item.infoHtml = "Collection of NPR stories that represent a given topic or subject matter. (eg. Health Care, Interviews)"; - script.insertItem( item ); - - item.callbackData = "artist_stories"; - item.itemName = "Music Artists"; - item.infoHtml = "Collection of stories that are about music artists. Artists are sorted by letter. (eg. Bob Dylan, Death Cab For Cutie)"; - script.insertItem( item ); - - item.callbackData = "genre_stories"; - item.itemName = "Music Genres"; - item.infoHtml = "Collection of NPR stories that represent a given musical genre. (eg. Rock/Pop/Folk, Jazz)"; - script.insertItem( item ); - - item.callbackData = "program_stories"; - item.itemName = "Programs"; - item.infoHtml = "Collection of NPR stories that aired on an NPR program. (eg. All Things Considered, Tell Me More)"; - script.insertItem( item ); - - item.callbackData = "bios_stories"; - item.itemName = "Bios"; - item.infoHtml = "Collection of NPR stories as reported by an NPR personality. Personalities are sorted by letter. (eg. Nina Totenburg, Steve Inskeep)"; - script.insertItem( item ); - - item.callbackData = "columns_stories"; - item.itemName = "Columns"; - item.infoHtml = "Collection of stories containing opinions and perspectives of an NPR personality. (eg. Watching Washington, Song of the Day)"; - script.insertItem( item ); - - item.callbackData = "series_stories"; - item.itemName = "Series"; - item.infoHtml = "An ongoing collection of NPR stories on a topic. (eg. Climate Connections, Summer Books)"; - script.insertItem( item ); - - script.donePopulating(); - } else if ( level == 1 ) { // the shows - Amarok.debug( "fetching npr xml..." ); - Amarok.Window.Statusbar.longMessage( "NPR: Fetching and parsing stories. This might take a little bit, depending on the speed of your internet connection..." ); - try { - if( callbackData == "stories_topic" ) - a = new Downloader( topicsUrl, topicsDownloadResult ); - else if( callbackData == "artist_stories" ) - a = new Downloader( artistsUrl, artistsDownloadResult ); - else if( callbackData == "genre_stories" ) - a = new Downloader( genresUrl, topicsDownloadResult ); - else if( callbackData == "program_stories" ) - a = new Downloader( programsUrl, topicsDownloadResult ); - else if( callbackData == "columns_stories" ) - a = new Downloader( columnsUrl, topicsDownloadResult ); - else if( callbackData == "series_stories" ) - a = new Downloader( seriesUrl, topicsDownloadResult ); - else if( callbackData == "bios_stories" ) - a = new Downloader( biosUrl, artistsDownloadResult ); - - - } - catch( err ) { - Amarok.debug( err ); - } - - } else if ( level == 0 ) { // the stories from each topic - try { - url = new QUrl( baseUrl + callbackData + "&action=Or&fields=title,teaser,storyDate,audio&output=NPRML&numResults=20" ); - Amarok.debug("Fetching stories for topic: " + callbackData); - Amarok.debug(url); - a = new Downloader( url, storiesDownloadResult ); - } catch( err ) { - Amarok.debug( err ); - } - } -} - -script = new NPRService(); -script.populate.connect( onPopulate ); diff --git a/amarok/playground/src/scripts/npr_service/script.spec b/amarok/playground/src/scripts/npr_service/script.spec deleted file mode 100644 index 7d2392c7..00000000 --- a/amarok/playground/src/scripts/npr_service/script.spec +++ /dev/null @@ -1,17 +0,0 @@ -[Desktop Entry] -Icon=view-services-npr-amarok -Type=script -ServiceTypes=KPluginInfo - -Name=NPR -Comment=Listen to NPR's large archive of audio material. News, stories, reviews, and more! - -X-KDE-PluginInfo-Author=Casey Link -X-KDE-PluginInfo-Email=unnamedrambler@gmail.com -X-KDE-PluginInfo-Name=NPR -X-KDE-PluginInfo-Version=1.0.0 -X-KDE-PluginInfo-Category=Scriptable Service -X-KDE-PluginInfo-Website=http://amarok.kde.org/ -X-KDE-PluginInfo-Depends=Amarok2.0 -X-KDE-PluginInfo-License=GPL -X-KDE-PluginInfo-EnabledByDefault=true diff --git a/amarok/playground/src/scripts/seeqpod_service/CMakeLists.txt b/amarok/playground/src/scripts/seeqpod_service/CMakeLists.txt deleted file mode 100644 index 05804781..00000000 --- a/amarok/playground/src/scripts/seeqpod_service/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -install( FILES - script.spec - main.js - COPYING - README - SeeqpodService.html - DESTINATION ${DATA_INSTALL_DIR}/amarok/scripts/seeqpod_service - ) - diff --git a/amarok/playground/src/scripts/seeqpod_service/COPYING b/amarok/playground/src/scripts/seeqpod_service/COPYING deleted file mode 100644 index b74ec101..00000000 --- a/amarok/playground/src/scripts/seeqpod_service/COPYING +++ /dev/null @@ -1,340 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program 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 2 of the License, or - (at your option) any later version. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. diff --git a/amarok/playground/src/scripts/seeqpod_service/README b/amarok/playground/src/scripts/seeqpod_service/README deleted file mode 100644 index a9a3eafc..00000000 --- a/amarok/playground/src/scripts/seeqpod_service/README +++ /dev/null @@ -1,24 +0,0 @@ -
SeeqPod.com
- -

-About:
-A script that lets you seach for, and stream tracks from SeeqPod.com -

- -

-Usage:
-Just run the script, and a new service will be created in the internet browser -

- -

-Dependencies:
-

    -
  • Amarok 2.0.0 rc1
  • -
-

- -

-Author:
-Nikolaj Hald Nielsen (nhnFreespirit@gmail.com) -

- diff --git a/amarok/playground/src/scripts/seeqpod_service/SeeqpodService.html b/amarok/playground/src/scripts/seeqpod_service/SeeqpodService.html deleted file mode 100644 index 90d6ab62..00000000 --- a/amarok/playground/src/scripts/seeqpod_service/SeeqpodService.html +++ /dev/null @@ -1,27 +0,0 @@ - - - - - -
-

- SeeqPod.com -

- Welcome to the Amarok 2 SeeqPod.com scripted service. To search SeeqPod, simply type in your search in the search box in the service and expand the item that appears in the list. By default, this script will only return at most 100 matches, but by appending an #offset to your search, it will return further matches. For instance, typing in "Foobar" will return the first 100 matches, "Foobar#100" the next 100, and so on. -
- - \ No newline at end of file diff --git a/amarok/playground/src/scripts/seeqpod_service/main.js b/amarok/playground/src/scripts/seeqpod_service/main.js deleted file mode 100644 index d713f2c1..00000000 --- a/amarok/playground/src/scripts/seeqpod_service/main.js +++ /dev/null @@ -1,250 +0,0 @@ -/*######################################################################### -# Amarok script for interfacing with SeeqPod.com. # -# # -# Copyright # -# (C) 2007, 2008 Nikolaj Hald Nielsen # -# (C) 2008 Mark Kretschmann # -# # -# This program 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 2 of the License, or # -# (at your option) any later version. # -# # -# This program 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 this program; if not, write to the # -# Free Software Foundation, Inc., # -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # -#########################################################################*/ - - -Importer.loadQtBinding( "qt.core" ); -Importer.loadQtBinding( "qt.xml" ); -Importer.loadQtBinding( "qt.network" ); -Importer.loadQtBinding( "qt.gui" ); - -QByteArray.prototype.toString = function() -{ - ts = new QTextStream( this, QIODevice.ReadOnly ); - return ts.readAll(); -} - -function configure() -{ - print ("Seeqpod onConfigure"); - uid = ""; - - - uid = QInputDialog.getText( 0, "Seeqpod Script", "Please enter your uid", QLineEdit.Normal, "", 0 ); - - if ( uid != "" ) { - Amarok.debug ("got " + uid ); - Amarok.Script.writeConfig( "uid", uid ); - } - -} - -function Seeqpod() -{ - // onConfigure(); - print ("Seeqpod Seeqpod"); - - var currentDir = Amarok.Info.scriptPath(); - print( "got current dir: " + currentDir ); - - - //get config file ( if it exists, otherwise, ask for uid ) - readConfig(); - - - - var file = new QFile( currentDir + "/SeeqpodService.html" ); - file.open( QIODevice.OpenMode( QIODevice.ReadOnly, QIODevice.Text ) ); - - while ( !file.atEnd() ) { - html += file.readLine().toString(); - } - - Amarok.debug ("creating service..."); - Amarok.debug ("html: " + html ); - ScriptableServiceScript.call( this, "Seeqpod.com", 2, "Search and stream music from all over the web", html, true ); - Amarok.debug ("done creating service!"); -} - - - -function readConfig() -{ - print ("Seeqpod readConfig"); - - uid = Amarok.Script.readConfig( "uid", "" ); - if ( uid == "" ) - configure(); -} - - -function queryResult( reply ) -{ - - try - { - - doc.setContent( reply ); - - trackElements = doc.elementsByTagName( "track" ); - - Amarok.debug ("got " + trackElements.length() + " tracks!"); - - var titles = new Array( trackElements.length() ); - var links = new Array( trackElements.length() ); - var artists = new Array( trackElements.length() ); - var albums = new Array( trackElements.length() ); - - - var i = 0; - for ( ; i < trackElements.length(); i++ ) - { - - - elt = trackElements.at( i ); - elt2 = elt.firstChildElement( "title" ); - - titles[i] = elt2.text(); - - elt2 = elt.firstChildElement( "location" ); - links[i] = elt2.text(); - - elt2 = elt.firstChildElement( "album" ); - albums[i] = elt2.text(); - - elt2 = elt.firstChildElement( "creator" ); - artists[i] = elt2.text(); - - - } - - - for( i = 0; i < trackElements.length(); i++ ) - { - - title = titles[i] - link = links[i]; - album = albums[i]; - artist = artists[i] - - - item = Amarok.StreamItem; - item.level = 0; - item.callbackData = ""; - item.itemName = title; - item.artist = artist; - item.album = album; - item.playableUrl = link; - item.infoHtml = ""; - - script.insertItem( item ); - - } - - } - catch( err ) - { - Amarok.debug( err ); - } - - script.donePopulating(); - -} - -function onPopulate( level, callback, filter ) -{ - print ("Seeqpod onPopulate"); - Amarok.debug( "Seeqpod onPopulate, filter: " + filter ); - offset = 0; - - offsetMarker = filter.lastIndexOf("#"); - - if ( offsetMarker != -1 ) { - Amarok.debug( "non 0 marker at " + offsetMarker ); - offset = filter.substring( offsetMarker + 1, filter.length ) - Amarok.debug( "Got offset: " + offset ); - offset = offset.replace( "%20", " " ); - offset = parseInt( offset ); - - Amarok.debug( "Got offset: " + offset ); - //offset = offset.trim(); - - filter = filter.substring( 0, offsetMarker ); - - Amarok.debug( "Got final offset: " + offset ); - Amarok.debug( "Got filter: " + filter ); - } - - - if ( filter != "" ) - { - name = filter.replace( "%20", " " ); - } - else - { - name = "Enter Query..." - } - - if ( level == 1 ) { - - if ( offset > 0 ) - name = name + " ( " + offset + " - " + (offset + 100) + " )"; - - item = Amarok.StreamItem; - item.level = 1; - item.callbackData = "dummy"; - item.itemName = name; - item.playableUrl = ""; - item.infoHtml = html; - script.insertItem( item ); - - script.donePopulating(); - - } - else if ( level == 0 ) - { - Amarok.debug( " Populating result level..." ); - Amarok.debug( " url: " + callback ); - - try{ - - path = "http://www.seeqpod.com/api/v0.2//music/search///100"; - - path = path.replace( "", uid ) - path = path.replace( "", filter ) - path = path.replace( "", offset ); - qurl = new QUrl( path ); - - b = new Downloader( qurl, queryResult ); - } - catch( err ) - { - Amarok.debug( err ); - } - - } -} - - -http = new QHttp; -data = new QBuffer; -doc = new QDomDocument("doc"); -elt = new QDomElement; -elt2 = new QDomElement; -bookElements = new QDomNodeList; -html = ""; -uid = ""; - -script = new Seeqpod(); -script.populate.connect( onPopulate ); - - diff --git a/amarok/playground/src/scripts/seeqpod_service/script.spec b/amarok/playground/src/scripts/seeqpod_service/script.spec deleted file mode 100644 index 9aee194d..00000000 --- a/amarok/playground/src/scripts/seeqpod_service/script.spec +++ /dev/null @@ -1,16 +0,0 @@ -[Desktop Entry] -Icon=get-hot-new-stuff-amarok -Type=script -ServiceTypes=KPluginInfo - -Name=Seeqpod.com -Comment=A scripted service that lets you search and stream music from all over the web using the Seeqpod.com search engine. - -X-KDE-PluginInfo-Author=Nikolaj Hald Nielsen -X-KDE-PluginInfo-Email=nhnFreespirit@gmail.com -X-KDE-PluginInfo-Name=Seeqpod.com -X-KDE-PluginInfo-Version=1.0 -X-KDE-PluginInfo-Category=Scriptable Service -X-KDE-PluginInfo-Depends=Amarok2.0 -X-KDE-PluginInfo-License=GPL -X-KDE-PluginInfo-EnabledByDefault=false \ No newline at end of file diff --git a/amarok/playground/src/scripts/seeqpod_service/seeqpod_service_script.rb b/amarok/playground/src/scripts/seeqpod_service/seeqpod_service_script.rb deleted file mode 100755 index 04553894..00000000 --- a/amarok/playground/src/scripts/seeqpod_service/seeqpod_service_script.rb +++ /dev/null @@ -1,177 +0,0 @@ -#!/usr/bin/env ruby -########################################################################### -# Amarok script for interfacing with SeeqPod.com. # -# # -# Copyright # -# (C) 2007, 2008 Nikolaj Hald Nielsen # -# (C) 2008 Mark Kretschmann # -# # -# This program 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 2 of the License, or # -# (at your option) any later version. # -# # -# This program 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 this program; if not, write to the # -# Free Software Foundation, Inc., # -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # -########################################################################### - -require "net/http" -require "rexml/document" -begin - require "Qt4" -rescue LoadError - error = "Qt4-Ruby (Ruby bindings for Qt4) is required for the 'SeeqPod' script.\n\nsudo apt-get install libqt4-ruby" - `kdialog --sorry '#{error}'` - exit 1 -end -include REXML - - -def configure - ok = Qt::Boolean.new # Will become nil if the user presses Cancel - uid = Qt::InputDialog.getText( nil, "Configuration", "Please enter your SeeqPod API UID (check your SeeqPod profile):", Qt::LineEdit::Normal, "", ok ) - unless ok.nil? - @uid = uid - @settings.setValue( "uid", Qt::Variant.new( @uid ) ) - @settings.sync - end -end - - -app = Qt::Application.new(ARGV) -@settings = Qt::Settings.new( "./seeqpod_service_rc", Qt::Settings::IniFormat ) -@uid = @settings.contains( "uid" ) ? @settings.value( "uid" ).toString : "" -service_name = "SeeqPod.com" - - -#SeeqPod has given permission to use their background and logo in the html front page below! - -root_html = "" + -"" + -" " + -" " + -"
" + -"

" + -" \"SeeqPod.com\"" + -"

" + -" Welcome to the Amarok 2 SeeqPod.com scripted service. To search SeeqPod, simply type in your search in the search box in the service and expand the item that appears in the list. By default, this script will only return at most 100 matches, but by appending an #offset to your search, it will return further matches. For instance, typing in \"Foobar\" will return the first 100 matches, \"Foobar#100\" the next 100, and so on." + -"
" + -" " + -"" - - -loop do - message = gets - puts "script got message" + message - args = message.chomp.split(" ") - - case args[0] - when "configure" - configure - - when "init" - #2 levels, categories and stations - levels = "2" - short_description = "Search and stream from SeeqPod.com" - - # init new browser - system("qdbus", "org.kde.amarok", "/ScriptableServiceManager", "initService", service_name, levels, short_description, root_html, "true" ) - - when "populate" - configure if @uid.empty? - filter = "_none_" - - offset = 0; - - if args.length == 5 - callback = args[4].strip(); - callback_args = callback.chomp.split("#") - filter = callback_args[0]; - - if callback_args.length == 2 - offset = callback_args[1].to_i - end - - name = filter.gsub( "%20", " " ); - name = name.strip(); - - else - name = "Enter Query..." - end - - if args[1].strip() == "1" - puts " Populating main level..." - - html = "The results of your query for: " + filter; - - if offset > 0 - name = name + " ( " + offset.to_s + " - " + (offset + 100).to_s + " )" - end - - system("qdbus", "org.kde.amarok", "/ScriptableServiceManager", "insertItem", service_name, "1", "-1", name, html, filter, "" ) - - #tell service that all items has been added ( no parent since these are top level items ) - `qdbus org.kde.amarok /ScriptableServiceManager donePopulating "SeeqPod.com" "-1"` - - else if args[1].strip() == "0" - parent_id = args[2] - - url = "http://www.seeqpod.com/api/v0.2//music/search///100" - - url = url.gsub( "", @uid ) - url = url.gsub( "", filter ) - url = url.gsub( "", offset.to_s ); - - #fetch results - - data = Net::HTTP.get_response(URI.parse(url)).body - - #some brute force parsing.... - doc = REXML::Document.new(data) - titles = [] - links = [] - doc.elements.each('playlist/trackList/track/title') do |ele| - titles << ele.text - end - doc.elements.each('playlist/trackList/track/location') do |ele| - links << ele.text - end - - count = 0 - - titles.each_with_index do |title, idx| - link = links[idx] - - system("qdbus", "org.kde.amarok", "/ScriptableServiceManager", "insertItem", service_name, "0", parent_id, title, "", "", link ) - count = count + 1 - end - - #tell service that all items has been added to a parent item - system("qdbus", "org.kde.amarok", "/ScriptableServiceManager", "donePopulating", service_name, parent_id ) - - end - end - end -end - diff --git a/amarok/playground/src/scripts/seeqpod_service/seeqpod_service_script.spec b/amarok/playground/src/scripts/seeqpod_service/seeqpod_service_script.spec deleted file mode 100644 index a3b09bb4..00000000 --- a/amarok/playground/src/scripts/seeqpod_service/seeqpod_service_script.spec +++ /dev/null @@ -1,2 +0,0 @@ -name = SeeqPod.com -type = service diff --git a/amarok/shared/CMakeLists.txt b/amarok/shared/CMakeLists.txt deleted file mode 100644 index 7f48a594..00000000 --- a/amarok/shared/CMakeLists.txt +++ /dev/null @@ -1,54 +0,0 @@ -include_directories( - ${KDE4_INCLUDES} -) - -set( amarokshared_SRCS - FileType.cpp - FileTypeResolver.cpp - MetaReplayGain.cpp - MetaTagLib.cpp - TagsFromFileNameGuesser.cpp -) - -set( amarokshared_collectionscanner_SRCS - collectionscanner/Album.cpp - collectionscanner/BatchFile.cpp - collectionscanner/Directory.cpp - collectionscanner/Playlist.cpp - collectionscanner/ScanningState.cpp - collectionscanner/Track.cpp -) - - -set( amarokshared_tag_helpers_SRCS - tag_helpers/APETagHelper.cpp - tag_helpers/ASFTagHelper.cpp - tag_helpers/ID3v2TagHelper.cpp - tag_helpers/MP4TagHelper.cpp - tag_helpers/StringHelper.cpp - tag_helpers/TagHelper.cpp - tag_helpers/VorbisCommentTagHelper.cpp -) - -add_library( amarokshared SHARED - ${amarokshared_SRCS} - ${amarokshared_collectionscanner_SRCS} - ${amarokshared_tag_helpers_SRCS} ) - -include_directories( ${TAGLIB_INCLUDES} ) -add_definitions( ${TAGLIB_CFLAGS} ) -target_link_libraries( amarokshared ${TAGLIB_LIBRARIES} ) -if( TAGLIB-EXTRAS_FOUND ) - include_directories( ${TAGLIB-EXTRAS_INCLUDES} ) - add_definitions( ${TAGLIB-EXTRAS_CFLAGS} ) - target_link_libraries( amarokshared ${TAGLIB-EXTRAS_LIBRARIES} ) -endif( TAGLIB-EXTRAS_FOUND ) - -target_link_libraries( amarokshared - ${QT_QTCORE_LIBRARY} - ${QT_QTGUI_LIBRARY} # for QImage, ... - ${KDE4_KDECORE_LIBRARY} # for KMimeType, ... -) - -set_target_properties( amarokshared PROPERTIES VERSION 1.0.0 SOVERSION 1 ) -install( TARGETS amarokshared ${INSTALL_TARGETS_DEFAULT_ARGS} ) diff --git a/amarok/shared/FileType.cpp b/amarok/shared/FileType.cpp deleted file mode 100644 index 460b8c1d..00000000 --- a/amarok/shared/FileType.cpp +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Stefan Derkits * - * Copyright (c) 2010 Christian Wagner * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "FileType.h" - -using namespace Amarok; - -static QStringList s_fileTypeStrings = QStringList() - << QLatin1String( "" ) - << QLatin1String( "mp3" ) - << QLatin1String( "ogg" ) - << QLatin1String( "flac" ) - << QLatin1String( "mp4" ) - << QLatin1String( "wma" ) - << QLatin1String( "aiff" ) - << QLatin1String( "mpc" ) - << QLatin1String( "tta" ) - << QLatin1String( "wav" ) - << QLatin1String( "wv" ) - << QLatin1String( "m4a" ) - << QLatin1String( "m4v" ) - << QLatin1String( "mod" ) - << QLatin1String( "s3m" ) - << QLatin1String( "it" ) - << QLatin1String( "xm" ) - << QLatin1String( "spx" ) - << QLatin1String( "opus" ); - -QString -FileTypeSupport::toString( Amarok::FileType ft ) -{ - return s_fileTypeStrings.at( ft ); -} - -QStringList -FileTypeSupport::possibleFileTypes() -{ - return s_fileTypeStrings; -} - -Amarok::FileType -Amarok::FileTypeSupport::fileType( const QString &extension ) -{ - QString ext = extension.toLower(); - for( int i = 1; i < s_fileTypeStrings.size(); i++ ) - { - if( s_fileTypeStrings.at( i ).compare( ext ) == 0 ) - return Amarok::FileType( i ); - } - return Amarok::Unknown; -} diff --git a/amarok/shared/FileType.h b/amarok/shared/FileType.h deleted file mode 100644 index 136a62ca..00000000 --- a/amarok/shared/FileType.h +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Rick W. Chen * - * Copyright (c) 2010 Stefan Derkits * - * Copyright (c) 2010 Christian Wagner * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef SHARED_FILETYPE_H -#define SHARED_FILETYPE_H - -#include "amarokshared_export.h" - -#include -#include - -namespace Amarok -{ - //New FileTypes must also be added to s_fileTypeStrings in FileType.cpp - enum FileType - { - Unknown = 0, - Mp3 = 1, - Ogg = 2, // please use just for Ogg Vorbis - Flac = 3, - Mp4 = 4, // a file in MPEG-4 container that may or may not contain video - Wma = 5, - Aiff = 6, - Mpc = 7, - TrueAudio = 8, - Wav = 9, - WavPack = 10, - M4a = 11, // a file in MPEG-4 container that contains only audio - M4v = 12, // a file in MPEG-4 container that for sure contains video - Mod = 13, - S3M = 14, - IT = 15, - XM = 16, - Speex = 17, - Opus = 18 - }; - - class AMAROKSHARED_EXPORT FileTypeSupport - { - public: - /** - * Return preferred extension of given filetype - * - * TODO: rename to extension() - */ - static QString toString( Amarok::FileType ft ); - - /** - * Return a list of possible localized filetype strings. - * - * TODO: rename to possibleExtensions() - */ - static QStringList possibleFileTypes(); - - /** - * Return file type given file extension, which must exclude the leading dot. - * - * @return Amarok::FileType enum, Amarok::Unknown if no other suitable - * type is in the enum - */ - static Amarok::FileType fileType( const QString& extension ); - }; -} - -#endif /* SHARED_FILETYPE_H */ diff --git a/amarok/shared/FileTypeResolver.cpp b/amarok/shared/FileTypeResolver.cpp deleted file mode 100644 index 1a177acc..00000000 --- a/amarok/shared/FileTypeResolver.cpp +++ /dev/null @@ -1,198 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2005 Martin Aumueller * - * Copyright (c) 2011 Ralf Engels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "FileTypeResolver.h" - -#include - -#include - -#include -#include -#include - -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wnon-virtual-dtor" -#ifdef TAGLIB_EXTRAS_FOUND -#include -#include -#endif // TAGLIB_EXTRAS_FOUND -#include -#include -#include -#include -#include -#include -#include -#ifdef TAGLIB_OPUS_FOUND -#include -#endif // TAGLIB_OPUS_FOUND -#include -#include -#include -#include -#include -#include -#ifdef TAGLIB_MOD_FOUND -#include -#include -#include -#include -#endif // TAGLIB_MOD_FOUND -#pragma GCC diagnostic pop - -TagLib::File *Meta::Tag::FileTypeResolver::createFile(TagLib::FileName fileName, - bool readProperties, - TagLib::AudioProperties::ReadStyle propertiesStyle) const -{ - TagLib::File* result = 0; - - QString fn = QFile::decodeName( fileName ); - QString suffix = QFileInfo( fn ).suffix(); - KMimeType::Ptr mimetype = KMimeType::findByPath( fn ); - - // -- check by mime type - if( mimetype->is( QLatin1String("audio/mpeg") ) - || mimetype->is( QLatin1String("audio/x-mpegurl") ) - || mimetype->is( QLatin1String("audio/mpeg") )) - { - result = new TagLib::MPEG::File(fileName, readProperties, propertiesStyle); - } - else if( mimetype->is( QLatin1String("audio/mp4") ) - || mimetype->is( QLatin1String("video/mp4") ) ) - { - result = new TagLib::MP4::File(fileName, readProperties, propertiesStyle); - } - else if( mimetype->is( QLatin1String("audio/x-ms-wma") ) - || mimetype->is( QLatin1String("video/x-ms-asf") ) - || mimetype->is( QLatin1String("video/x-msvideo") ) - || mimetype->is( QLatin1String("video/x-ms-wmv") ) ) - { - result = new TagLib::ASF::File(fileName, readProperties, propertiesStyle); - } -#ifdef TAGLIB_EXTRAS_FOUND - else if( mimetype->is( QLatin1String("audio/vnd.rn-realaudio") ) - || mimetype->is( QLatin1String("audio/x-pn-realaudioplugin") ) - || mimetype->is( QLatin1String("audio/vnd.rn-realvideo") ) ) - { - result = new TagLibExtras::RealMedia::File(fileName, readProperties, propertiesStyle); - } -#endif -#ifdef TAGLIB_OPUS_FOUND - else if( mimetype->is( QLatin1String("audio/opus") ) - || mimetype->is( QLatin1String("audio/x-opus+ogg") ) ) - { - result = new TagLib::Ogg::Opus::File(fileName, readProperties, propertiesStyle); - } -#endif - else if( mimetype->is( QLatin1String("audio/vorbis") ) - || mimetype->is( QLatin1String("audio/x-vorbis+ogg") ) ) - { - result = new TagLib::Ogg::Vorbis::File(fileName, readProperties, propertiesStyle); - } - else if( mimetype->is( QLatin1String("audio/x-flac+ogg") ) ) - { - result = new TagLib::Ogg::FLAC::File(fileName, readProperties, propertiesStyle); - } - else if( mimetype->is( QLatin1String("audio/x-aiff") ) ) - { - result = new TagLib::RIFF::AIFF::File(fileName, readProperties, propertiesStyle); - } - else if( mimetype->is( QLatin1String("audio/x-flac") ) ) - { - result = new TagLib::FLAC::File(fileName, readProperties, propertiesStyle); - } - else if( mimetype->is( QLatin1String("audio/x-musepack") ) ) - { - result = new TagLib::MPC::File(fileName, readProperties, propertiesStyle); - } - else if( mimetype->is( QLatin1String("audio/x-wav") ) ) - { - result = new TagLib::RIFF::WAV::File(fileName, readProperties, propertiesStyle); - } - else if( mimetype->is( QLatin1String("audio/x-wavpack") ) ) - { - result = new TagLib::WavPack::File(fileName, readProperties, propertiesStyle); - } - else if( mimetype->is( QLatin1String("audio/x-tta") ) ) - { - result = new TagLib::TrueAudio::File(fileName, readProperties, propertiesStyle); - } - else if( mimetype->is( QLatin1String("audio/x-speex") ) - || mimetype->is( QLatin1String("audio/x-speex+ogg") ) ) - { - result = new TagLib::Ogg::Speex::File(fileName, readProperties, propertiesStyle); - } -#ifdef TAGLIB_MOD_FOUND - else if( mimetype->is( QLatin1String("audio/x-mod") ) ) - { - result = new TagLib::Mod::File(fileName, readProperties, propertiesStyle); - } - else if( mimetype->is( QLatin1String("audio/x-s3m") ) ) - { - result = new TagLib::S3M::File(fileName, readProperties, propertiesStyle); - } - else if( mimetype->is( QLatin1String("audio/x-it") ) ) - { - result = new TagLib::IT::File(fileName, readProperties, propertiesStyle); - } - else if( mimetype->is( QLatin1String("audio/x-xm") ) ) - { - result = new TagLib::XM::File(fileName, readProperties, propertiesStyle); - } -#endif - - // -- check by extension - else if( suffix == QLatin1String("m4a") - || suffix == QLatin1String("m4b") - || suffix == QLatin1String("m4p") - || suffix == QLatin1String("mp4") - || suffix == QLatin1String("m4v") - || suffix == QLatin1String("mp4v") ) - { - result = new TagLib::MP4::File(fileName, readProperties, propertiesStyle); - } - else if( suffix == QLatin1String("wav") ) - { - result = new TagLib::RIFF::WAV::File(fileName, readProperties, propertiesStyle); - } - else if( suffix == QLatin1String("wma") - || suffix == QLatin1String("asf") ) - { - result = new TagLib::ASF::File(fileName, readProperties, propertiesStyle); - } -#ifdef TAGLIB_OPUS_FOUND - // this is currently needed because shared-mime-info database doesn't have opus entry (2013-01) - else if( suffix == QLatin1String("opus") ) - { - result = new TagLib::Ogg::Opus::File(fileName, readProperties, propertiesStyle); - } -#endif - -#ifndef Q_WS_WIN - if( !result ) - qDebug() << QString( "FileTypeResolver: file %1 (mimetype %2) not recognized as " - "Amarok-compatible" ).arg( fileName, mimetype->name() ).toLocal8Bit().data(); -#endif - - if( result && !result->isValid() ) { - delete result; - result = 0; - } - - return result; -} diff --git a/amarok/shared/FileTypeResolver.h b/amarok/shared/FileTypeResolver.h deleted file mode 100644 index bf8b68d4..00000000 --- a/amarok/shared/FileTypeResolver.h +++ /dev/null @@ -1,46 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2005 Martin Aumueller * - * Copyright (c) 2011 Ralf Engels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_FILETYPERESOLVER_H -#define AMAROK_FILETYPERESOLVER_H - -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wnon-virtual-dtor" -#include -#pragma GCC diagnostic pop - -namespace Meta -{ - namespace Tag - { - /** A FileTypeResolver for taglib. - The resolver will look at the file and then return a proper TagLib::File as result. - This specific resolver will first look at the mime type and then at the extension. - */ - class FileTypeResolver : public TagLib::FileRef::FileTypeResolver - { - TagLib::File *createFile(TagLib::FileName fileName, - bool readAudioProperties, - TagLib::AudioProperties::ReadStyle audioPropertiesStyle) const; - - public: - virtual ~FileTypeResolver() {} - }; - } -} - -#endif diff --git a/amarok/shared/MetaReplayGain.cpp b/amarok/shared/MetaReplayGain.cpp deleted file mode 100644 index 8b45aef9..00000000 --- a/amarok/shared/MetaReplayGain.cpp +++ /dev/null @@ -1,350 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Alex Merry * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -// NOTE: this file is used by amarokcollectionscanner and CANNOT use any amaroklib -// code [this includes debug()] - -#include "MetaReplayGain.h" - -#include -#include - -// Taglib -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wnon-virtual-dtor" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#pragma GCC diagnostic pop - -// converts a peak value from the normal digital scale form to the more useful decibel form -// decibels are relative to the /adjusted/ waveform -static qreal peakToDecibels( qreal scaleVal ) -{ - if ( scaleVal > 0 ) - return 20 * log10( scaleVal ); - else - return 0; -} - -// NOTE: representation is taken to be a binary value with units in the first column, -// 1/2 in the second and so on. -static qreal readRVA2PeakValue( const TagLib::ByteVector &data, int bits, bool *ok ) -{ - qreal peak = 0.0; - // discarding digits at the end reduces precision, but doesn't otherwise change the value - if ( bits > 32 ) - bits = 32; - // the +7 makes sure we round up when we divide by 8 - unsigned int bytes = (bits + 7) / 8; - - // normalize appears not to write a peak at all, and hence sets bits to 0 - if ( bits == 0 ) - { - if ( ok ) - *ok = true; - } - else if ( bits >= 4 && data.size() >= bytes ) // fewer than 4 bits would just be daft - { - // excessBits is the number of bits we have to discard at the end - unsigned int excessBits = (8 * bytes) - bits; - // mask has 1s everywhere but the last /excessBits/ bits - quint32 mask = 0xffffffff << excessBits; - quint32 rawValue = 0; - for ( unsigned int i = 0; i < bytes; ++i ) - { - rawValue <<= 8; - rawValue += (unsigned char)data[i]; - } - rawValue &= mask; - peak = rawValue; - // amount we need to "shift" the value right to make the first digit the unit column - unsigned int rightShift = (8 * bytes) - 1; - peak /= (qreal)(1 << rightShift); - if ( ok ) - *ok = true; - } - else - { - if ( ok ) - *ok = false; - } - return peak; -} - -// adds the converted version of the scale value if it is a valid, non-negative float -static void maybeAddPeak( const TagLib::String &scaleVal, Meta::ReplayGainTag key, Meta::ReplayGainTagMap *map ) -{ - // scale value is >= 0, and typically not much bigger than 1 - QString value = TStringToQString( scaleVal ); - bool ok = false; - qreal peak = value.toFloat( &ok ); - if ( ok && peak >= 0 ) - (*map)[key] = peakToDecibels( peak ); -} - -static void maybeAddGain( const TagLib::String &input, Meta::ReplayGainTag key, Meta::ReplayGainTagMap *map ) -{ - QString value = TStringToQString( input ).remove( " dB" ); - bool ok = false; - qreal gain = value.toFloat( &ok ); - if (ok) - (*map)[key] = gain; -} - -static Meta::ReplayGainTagMap readID3v2Tags( TagLib::ID3v2::Tag *tag ) -{ - Meta::ReplayGainTagMap map; - { // ID3v2.4.0 native replay gain tag support (as written by Quod Libet, for example). - TagLib::ID3v2::FrameList frames = tag->frameListMap()["RVA2"]; - frames.append(tag->frameListMap()["XRVA"]); - if ( !frames.isEmpty() ) - { - for ( unsigned int i = 0; i < frames.size(); ++i ) - { - // we have to parse this frame ourselves - // ID3v2 frame header is 10 bytes, so skip that - TagLib::ByteVector data = frames[i]->render().mid( 10 ); - unsigned int offset = 0; - QString desc( data.data() ); - offset += desc.count() + 1; - unsigned int channel = data.mid( offset, 1 ).toUInt( true ); - // channel 1 is the main volume - the only one we care about - if ( channel == 1 ) - { - ++offset; - qint16 adjustment512 = data.mid( offset, 2 ).toShort( true ); - qreal adjustment = ( (qreal)adjustment512 ) / 512.0; - offset += 2; - unsigned int peakBits = data.mid( offset, 1 ).toUInt( true ); - ++offset; - bool ok = false; - qreal peak = readRVA2PeakValue( data.mid( offset ), peakBits, &ok ); - if ( ok ) - { - if ( desc.toLower() == "album" ) - { - map[Meta::ReplayGain_Album_Gain] = adjustment; - map[Meta::ReplayGain_Album_Peak] = peakToDecibels( peak ); - } - else if ( desc.toLower() == "track" || !map.contains( Meta::ReplayGain_Track_Gain ) ) - { - map[Meta::ReplayGain_Track_Gain] = adjustment; - map[Meta::ReplayGain_Track_Peak] = peakToDecibels( peak ); - } - } - } - } - if ( !map.isEmpty() ) - return map; - } - } - - { // Foobar2000-style ID3v2.3.0 tags - TagLib::ID3v2::FrameList frames = tag->frameListMap()["TXXX"]; - for ( TagLib::ID3v2::FrameList::Iterator it = frames.begin(); it != frames.end(); ++it ) { - TagLib::ID3v2::UserTextIdentificationFrame* frame = - dynamic_cast( *it ); - if ( frame && frame->fieldList().size() >= 2 ) - { - QString desc = TStringToQString( frame->description() ).toLower(); - if ( desc == "replaygain_album_gain" ) - maybeAddGain( frame->fieldList()[1], Meta::ReplayGain_Album_Gain, &map ); - if ( desc == "replaygain_album_peak" ) - maybeAddPeak( frame->fieldList()[1], Meta::ReplayGain_Album_Peak, &map ); - if ( desc == "replaygain_track_gain" ) - maybeAddGain( frame->fieldList()[1], Meta::ReplayGain_Track_Gain, &map ); - if ( desc == "replaygain_track_peak" ) - maybeAddPeak( frame->fieldList()[1], Meta::ReplayGain_Track_Peak, &map ); - } - } - } - return map; -} - -static Meta::ReplayGainTagMap readAPETags( TagLib::APE::Tag *tag ) -{ - Meta::ReplayGainTagMap map; - const TagLib::APE::ItemListMap &items = tag->itemListMap(); - if ( items.contains("REPLAYGAIN_TRACK_GAIN") ) - { - maybeAddGain( items["REPLAYGAIN_TRACK_GAIN"].values()[0], Meta::ReplayGain_Track_Gain, &map ); - if ( items.contains("REPLAYGAIN_TRACK_PEAK") ) - maybeAddPeak( items["REPLAYGAIN_TRACK_PEAK"].values()[0], Meta::ReplayGain_Track_Peak, &map ); - } - if ( items.contains("REPLAYGAIN_ALBUM_GAIN") ) - { - maybeAddGain( items["REPLAYGAIN_ALBUM_GAIN"].values()[0], Meta::ReplayGain_Album_Gain, &map ); - if ( items.contains("REPLAYGAIN_ALBUM_PEAK") ) - maybeAddPeak( items["REPLAYGAIN_ALBUM_PEAK"].values()[0], Meta::ReplayGain_Album_Peak, &map ); - } - return map; -} - -static Meta::ReplayGainTagMap readXiphTags( TagLib::Ogg::XiphComment *tag ) -{ - const TagLib::Ogg::FieldListMap &tagMap = tag->fieldListMap(); - Meta::ReplayGainTagMap outputMap; - - if ( !tagMap["REPLAYGAIN_TRACK_GAIN"].isEmpty() ) - { - maybeAddGain( tagMap["REPLAYGAIN_TRACK_GAIN"].front(), Meta::ReplayGain_Track_Gain, &outputMap ); - if ( !tagMap["REPLAYGAIN_TRACK_PEAK"].isEmpty() ) - maybeAddPeak( tagMap["REPLAYGAIN_TRACK_PEAK"].front(), Meta::ReplayGain_Track_Peak, &outputMap ); - } - - if ( !tagMap["REPLAYGAIN_ALBUM_GAIN"].isEmpty() ) - { - maybeAddGain( tagMap["REPLAYGAIN_ALBUM_GAIN"].front(), Meta::ReplayGain_Album_Gain, &outputMap ); - if ( !tagMap["REPLAYGAIN_ALBUM_PEAK"].isEmpty() ) - maybeAddPeak( tagMap["REPLAYGAIN_ALBUM_PEAK"].front(), Meta::ReplayGain_Album_Peak, &outputMap ); - } - - return outputMap; -} - -static Meta::ReplayGainTagMap readASFTags( TagLib::ASF::Tag *tag ) -{ - const TagLib::ASF::AttributeListMap &tagMap = tag->attributeListMap(); - Meta::ReplayGainTagMap outputMap; - - if ( !tagMap["REPLAYGAIN_TRACK_GAIN"].isEmpty() ) - { - maybeAddGain( tagMap["REPLAYGAIN_TRACK_GAIN"].front().toString(), Meta::ReplayGain_Track_Gain, &outputMap ); - if ( !tagMap["REPLAYGAIN_TRACK_PEAK"].isEmpty() ) - maybeAddPeak( tagMap["REPLAYGAIN_TRACK_PEAK"].front().toString(), Meta::ReplayGain_Track_Peak, &outputMap ); - } - - if ( !tagMap["REPLAYGAIN_ALBUM_GAIN"].isEmpty() ) - { - maybeAddGain( tagMap["REPLAYGAIN_ALBUM_GAIN"].front().toString(), Meta::ReplayGain_Album_Gain, &outputMap ); - if ( !tagMap["REPLAYGAIN_ALBUM_PEAK"].isEmpty() ) - maybeAddPeak( tagMap["REPLAYGAIN_ALBUM_PEAK"].front().toString(), Meta::ReplayGain_Album_Peak, &outputMap ); - } - - return outputMap; -} -// Bad news: ReplayGain in MP4 is not actually standardized in any way. Maybe reimplement at some point...maybe. See -// http://www.hydrogenaudio.org/forums/lofiversion/index.php/t14322.html -#ifdef DO_NOT_USE_THIS_UNTIL_FIXED -static Meta::ReplayGainTagMap readMP4Tags( TagLib::MP4::Tag *tag ) -{ - Meta::ReplayGainTagMap outputMap; - - if ( !tag->trackReplayGain().isNull() ) { - maybeAddGain( tag->trackReplayGain(), Meta::ReplayGain_Track_Gain, &outputMap ); - if ( !tag->trackReplayGainPeak().isNull() ) - maybeAddPeak( tag->trackReplayGainPeak(), Meta::ReplayGain_Track_Peak, &outputMap ); - } - - if ( !tag->albumReplayGain().isNull() ) { - maybeAddGain( tag->albumReplayGain(), Meta::ReplayGain_Album_Gain, &outputMap ); - if ( !tag->albumReplayGainPeak().isNull() ) - maybeAddPeak( tag->albumReplayGainPeak(), Meta::ReplayGain_Album_Peak, &outputMap ); - } - - return outputMap; -} -#endif - -Meta::ReplayGainTagMap -Meta::readReplayGainTags( const TagLib::FileRef &fileref ) -{ - Meta::ReplayGainTagMap map; - // NB: we can't get replay gain info from MPC files, since it's stored in some magic place - // and not in the APE tags, and taglib doesn't let us access the information (unless - // we want to parse the file ourselves). - // FIXME: should we try getting the info from the MPC APE tag just in case? - - if ( TagLib::MPEG::File *file = dynamic_cast( fileref.file() ) ) - { - if ( file->ID3v2Tag() ) - map = readID3v2Tags( file->ID3v2Tag() ); - if ( map.isEmpty() && file->APETag() ) - map = readAPETags( file->APETag() ); - } - else if ( TagLib::Ogg::Vorbis::File *file = dynamic_cast( fileref.file() ) ) - { - if ( file->tag() ) - map = readXiphTags( file->tag() ); - } - else if ( TagLib::FLAC::File *file = dynamic_cast( fileref.file() ) ) - { - if ( file->xiphComment() ) - map = readXiphTags( file->xiphComment() ); - if ( map.isEmpty() && file->ID3v2Tag() ) - map = readID3v2Tags( file->ID3v2Tag() ); - } - else if ( TagLib::Ogg::FLAC::File *file = dynamic_cast( fileref.file() ) ) - { - if ( file->tag() ) - map = readXiphTags( file->tag() ); - } - else if ( TagLib::WavPack::File *file = dynamic_cast( fileref.file() ) ) - { - if ( file->APETag() ) - map = readAPETags( file->APETag() ); - } - else if ( TagLib::TrueAudio::File *file = dynamic_cast( fileref.file() ) ) - { - if ( file->ID3v2Tag() ) - map = readID3v2Tags( file->ID3v2Tag() ); - } - else if ( TagLib::Ogg::Speex::File *file = dynamic_cast( fileref.file() ) ) - { - if ( file->tag() ) - map = readXiphTags( file->tag() ); - } - else if ( TagLib::MPC::File *file = dynamic_cast( fileref.file() ) ) - { - // This is NOT the correct way to get replay gain tags from MPC files, but - // taglib doesn't allow us access to the real information. - // This allows people to work around this issue by copying their replay gain - // information to the APE tag. - if ( file->APETag() ) - map = readAPETags( file->APETag() ); - } - else if ( TagLib::ASF::File *file = dynamic_cast( fileref.file() ) ) - { - if ( file->tag() ) - map = readASFTags( file->tag() ); - } -// See comment above -#ifdef DO_NOT_USE_THIS_UNTIL_FIXED - else if ( TagLib::MP4::File *file = dynamic_cast( fileref.file() ) ) - { - if ( file->tag() ) - map = readMP4Tags( file->getMP4Tag() ); - } -#endif - return map; -} - diff --git a/amarok/shared/MetaReplayGain.h b/amarok/shared/MetaReplayGain.h deleted file mode 100644 index f126d7cc..00000000 --- a/amarok/shared/MetaReplayGain.h +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Alex Merry * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_METAREPLAYGAIN_H -#define AMAROK_METAREPLAYGAIN_H - -#include "amarokshared_export.h" - -#include - -namespace TagLib { - class FileRef; -} - -/* This file exists (rather than putting the method in MetaUtility.h and - * MetaUtility.cpp) because we need to share the implementation between - * amaroklib and amarokcollectionscanner (which doesn't link to amaroklib). - */ -namespace Meta -{ - enum ReplayGainTag - { - ReplayGain_Track_Gain, - ReplayGain_Track_Peak, - ReplayGain_Album_Gain, - ReplayGain_Album_Peak - }; - - typedef QMap ReplayGainTagMap; - - /** - * Reads the replay gain tags from a taglib file. - */ - AMAROKSHARED_EXPORT ReplayGainTagMap readReplayGainTags( const TagLib::FileRef &fileref ); -} - -#endif // AMAROK_METAREPLAYGAIN_H diff --git a/amarok/shared/MetaTagLib.cpp b/amarok/shared/MetaTagLib.cpp deleted file mode 100644 index a595bc13..00000000 --- a/amarok/shared/MetaTagLib.cpp +++ /dev/null @@ -1,348 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2003-2005 Max Howell * - * (C) 2003-2010 Mark Kretschmann * - * (C) 2005-2007 Alexandre Oliveira * - * (C) 2008 Dan Meltzer * - * (C) 2008-2009 Jeff Mitchell * - * (C) 2010 Ralf Engels * - * (C) 2010 Sergey Ivanov <123kash@gmail.com> * - * * - * This program 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 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#include "MetaTagLib.h" - -#include "FileType.h" -#include "TagsFromFileNameGuesser.h" -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "FileTypeResolver.h" -#include "MetaReplayGain.h" -#include "tag_helpers/TagHelper.h" -#include "tag_helpers/StringHelper.h" - -//Taglib: -#include - -#ifdef TAGLIB_EXTRAS_FOUND -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wnon-virtual-dtor" -#include -#include -#pragma GCC diagnostic pop -#endif // TAGLIB_EXTRAS_FOUND - - -namespace Meta -{ - namespace Tag - { - QMutex s_mutex; - - static void addRandomness( QCryptographicHash *md5 ); - - /** Get a taglib fileref for a path */ - static TagLib::FileRef getFileRef( const QString &path ); - - /** Returns a byte vector that can be used to generate the unique id based on the tags. */ - static TagLib::ByteVector generatedUniqueIdHelper( const TagLib::FileRef &fileref ); - - static QString generateUniqueId( const QString &path ); - - } -} - -TagLib::FileRef -Meta::Tag::getFileRef( const QString &path ) -{ -#ifdef Q_OS_WIN32 - const wchar_t *encodedName = reinterpret_cast< const wchar_t * >( path.utf16() ); -#else -#ifdef COMPLEX_TAGLIB_FILENAME - const wchar_t *encodedName = reinterpret_cast< const wchar_t * >( path.utf16() ); -#else - QByteArray fileName = QFile::encodeName( path ); - const char *encodedName = fileName.constData(); // valid as long as fileName exists -#endif -#endif - - // Tests reveal the following: - // - // TagLib::AudioProperties Relative Time Taken - // - // No AudioProp Reading 1 - // Fast 1.18 - // Average Untested - // Accurate Untested - - return TagLib::FileRef( encodedName, true, TagLib::AudioProperties::Fast ); -} - - -// ----------------------- unique id ------------------------ - - -void -Meta::Tag::addRandomness( QCryptographicHash *md5 ) -{ - //md5 has size of file already added for some little extra randomness for the hash - qsrand( QTime::currentTime().msec() ); - md5->addData( QString::number( qrand() ).toAscii() ); - md5->addData( QString::number( qrand() ).toAscii() ); - md5->addData( QString::number( qrand() ).toAscii() ); - md5->addData( QString::number( qrand() ).toAscii() ); - md5->addData( QString::number( qrand() ).toAscii() ); - md5->addData( QString::number( qrand() ).toAscii() ); - md5->addData( QString::number( qrand() ).toAscii() ); -} - -TagLib::ByteVector -Meta::Tag::generatedUniqueIdHelper( const TagLib::FileRef &fileref ) -{ - TagLib::ByteVector bv; - - TagHelper *tagHelper = selectHelper( fileref ); - - if( tagHelper ) - { - bv = tagHelper->render(); - delete tagHelper; - } - - return bv; -} - -QString -Meta::Tag::generateUniqueId( const QString &path ) -{ - QCryptographicHash md5( QCryptographicHash::Md5 ); - QFile qfile( path ); - QByteArray size; - md5.addData( size.setNum( qfile.size() ) ); - - TagLib::FileRef fileref = getFileRef( path ); - TagLib::ByteVector bv = generatedUniqueIdHelper( fileref ); - md5.addData( bv.data(), bv.size() ); - - char databuf[16384]; - int readlen = 0; - QString returnval; - - if( qfile.open( QIODevice::ReadOnly ) ) - { - if( ( readlen = qfile.read( databuf, 16384 ) ) > 0 ) - { - md5.addData( databuf, readlen ); - qfile.close(); - } - else - { - qfile.close(); - addRandomness( &md5 ); - } - } - else - addRandomness( &md5 ); - - return QString( md5.result().toHex() ); -} - - -// --------- file type resolver ---------- - -/** Will ensure that we have our file type resolvers added */ -static void ensureFileTypeResolvers() -{ - static bool alreadyAdded = false; - if( !alreadyAdded ) { - alreadyAdded = true; - -#ifdef TAGLIB_EXTRAS_FOUND - TagLib::FileRef::addFileTypeResolver(new AudibleFileTypeResolver); - TagLib::FileRef::addFileTypeResolver(new RealMediaFileTypeResolver); -#endif - TagLib::FileRef::addFileTypeResolver(new Meta::Tag::FileTypeResolver()); - } -} - -// ----------------------- reading ------------------------ - -Meta::FieldHash -Meta::Tag::readTags( const QString &path, bool /*useCharsetDetector*/ ) -{ - Meta::FieldHash result; - - // we do not rely on taglib being thread safe especially when writing the same file from different threads. - QMutexLocker locker( &s_mutex ); - ensureFileTypeResolvers(); - - TagLib::FileRef fileref = getFileRef( path ); - - if( fileref.isNull() ) - return result; - - Meta::ReplayGainTagMap replayGainTags = Meta::readReplayGainTags( fileref ); - if( replayGainTags.contains( Meta::ReplayGain_Track_Gain ) ) - result.insert( Meta::valTrackGain, replayGainTags[Meta::ReplayGain_Track_Gain] ); - if( replayGainTags.contains( Meta::ReplayGain_Track_Peak ) ) - result.insert( Meta::valTrackGainPeak, replayGainTags[Meta::ReplayGain_Track_Peak] ); - - // strangely: the album gain defaults to the track gain - if( replayGainTags.contains( Meta::ReplayGain_Album_Gain ) ) - result.insert( Meta::valAlbumGain, replayGainTags[Meta::ReplayGain_Album_Gain] ); - else if( replayGainTags.contains( Meta::ReplayGain_Track_Gain ) ) - result.insert( Meta::valAlbumGain, replayGainTags[Meta::ReplayGain_Track_Gain] ); - if( replayGainTags.contains( Meta::ReplayGain_Album_Peak ) ) - result.insert( Meta::valAlbumGainPeak, replayGainTags[Meta::ReplayGain_Album_Peak] ); - else if( replayGainTags.contains( Meta::ReplayGain_Track_Peak ) ) - result.insert( Meta::valAlbumGainPeak, replayGainTags[Meta::ReplayGain_Track_Peak] ); - - TagHelper *tagHelper = selectHelper( fileref ); - if( tagHelper ) - { - if( 0/* useCharsetDetector */ ) - { - Meta::Tag::setCodecByName( "UTF-16" ); - } - - result.insert( Meta::valFormat, tagHelper->fileType() ); - result.unite( tagHelper->tags() ); - delete tagHelper; - } - - TagLib::AudioProperties *properties = fileref.audioProperties(); - if( properties ) - { - if( !result.contains( Meta::valBitrate ) && properties->bitrate() ) - result.insert( Meta::valBitrate, properties->bitrate() ); - if( !result.contains( Meta::valLength ) && properties->length() ) - result.insert( Meta::valLength, properties->length() * 1000 ); - if( !result.contains( Meta::valSamplerate ) && properties->sampleRate() ) - result.insert( Meta::valSamplerate, properties->sampleRate() ); - } - - //If tags doesn't contains title and artist, try to guess It from file name - if( !result.contains( Meta::valTitle ) || - result.value( Meta::valTitle ).toString().isEmpty() ) - result.unite( TagGuesser::guessTags( path ) ); - - //we didn't set a FileType till now, let's look it up via FileExtension - if( !result.contains( Meta::valFormat ) ) - { - QString ext = path.mid( path.lastIndexOf( '.' ) + 1 ); - result.insert( Meta::valFormat, Amarok::FileTypeSupport::fileType( ext ) ); - } - - QFileInfo fileInfo( path ); - result.insert( Meta::valFilesize, fileInfo.size() ); - result.insert( Meta::valModified, fileInfo.lastModified() ); - - if( !result.contains( Meta::valUniqueId ) ) - result.insert( Meta::valUniqueId, generateUniqueId( path ) ); - - // compute bitrate if it is not already set and we know length - if( !result.contains( Meta::valBitrate ) && result.contains( Meta::valLength ) ) - result.insert( Meta::valBitrate, ( fileInfo.size() * 8 * 1000 ) / - ( result.value( Meta::valLength ).toInt() * 1024 ) ); - - return result; -} - -QImage -Meta::Tag::embeddedCover( const QString &path ) -{ - // we do not rely on taglib being thread safe especially when writing the same file from different threads. - QMutexLocker locker( &s_mutex ); - - ensureFileTypeResolvers(); - TagLib::FileRef fileref = getFileRef( path ); - if( fileref.isNull() ) - return QImage(); - - QImage img; - TagHelper *tagHelper = selectHelper( fileref ); - if( tagHelper ) - { - img = tagHelper->embeddedCover(); - delete tagHelper; - } - return img; -} - -void -Meta::Tag::writeTags( const QString &path, const FieldHash &changes, bool writeStatistics ) -{ - FieldHash data = changes; - - if( !writeStatistics ) - { - data.remove( Meta::valFirstPlayed ); - data.remove( Meta::valLastPlayed ); - data.remove( Meta::valPlaycount ); - data.remove( Meta::valScore ); - data.remove( Meta::valRating ); - } - - // we do not rely on taglib being thread safe especially when writing the same file from different threads. - QMutexLocker locker( &s_mutex ); - - ensureFileTypeResolvers(); - TagLib::FileRef fileref = getFileRef( path ); - if( fileref.isNull() || data.isEmpty() ) - return; - - QScopedPointer tagHelper( selectHelper( fileref, true ) ); - if( !tagHelper ) - return; - - if( tagHelper->setTags( data ) ) - fileref.save(); -} - -void -Meta::Tag::setEmbeddedCover( const QString &path, const QImage &cover ) -{ - // we do not rely on taglib being thread safe especially when writing the same file from different threads. - QMutexLocker locker( &s_mutex ); - ensureFileTypeResolvers(); - - TagLib::FileRef fileref = getFileRef( path ); - - if( fileref.isNull() ) - return; - - TagHelper *tagHelper = selectHelper( fileref, true ); - if( !tagHelper ) - return; - - if( tagHelper->setEmbeddedCover( cover ) ) - fileref.save(); - - delete tagHelper; -} - -#undef Qt4QStringToTString diff --git a/amarok/shared/MetaTagLib.h b/amarok/shared/MetaTagLib.h deleted file mode 100644 index 2de3be2c..00000000 --- a/amarok/shared/MetaTagLib.h +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************************** - * Copyright (C) 2010 Ralf Engels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_METATAGLIB_H -#define AMAROK_METATAGLIB_H - -#include "MetaValues.h" -#include "amarokshared_export.h" - -#include - -/* This file exists because we need to share the implementation between - * amaroklib and amarokcollectionscanner (which doesn't link to amaroklib). - */ -namespace Meta -{ - namespace Tag - { - AMAROKSHARED_EXPORT Meta::FieldHash readTags( const QString &path, bool useCharsetDetector = true ); - - /** - * Writes tags stored in @param changes back to file. Respects - * AmarokConfig::writeBack() and AmarokConfig::writeBackStatistics(). - * - * If you are about to call this from the main thread, you should really think - * of using WriteTagsJob instead. - * - * Changed in 2.8: this method no longer checks AmarokConfig::writeBack() - * - * @param path path of the file to write the tags to - * @param changes Meta:val* key to value map of tags to write - * @param writeBackStatistics whether to include statistics-related tags when writing - * - * @see WriteTagsJob - */ - AMAROKSHARED_EXPORT void writeTags( const QString &path, - const Meta::FieldHash &changes, - bool writeStatistics ); - - // the utilities don't need to handle images - AMAROKSHARED_EXPORT QImage embeddedCover( const QString &path ); - - /** - * Writes embedded cover back to file. Overwrites any possible existing covers. - * This function doesn't take any configuration any account. - * - * If you are about to call this from the main thread, you should really think - * of using WriteTagsJob instead. - * - * @see WriteTagsJob - */ - AMAROKSHARED_EXPORT void setEmbeddedCover( const QString &path, const QImage &cover ); - } -} - -#endif // AMAROK_METATAGLIB_H diff --git a/amarok/shared/MetaValues.h b/amarok/shared/MetaValues.h deleted file mode 100644 index 94f18eec..00000000 --- a/amarok/shared/MetaValues.h +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Maximilian Kossick * - * Copyright (c) 2010 Ralf Engels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_METAVALUES_H -#define AMAROK_METAVALUES_H - -#include -#include - -/* This file exists because we need to share the implementation between - * amaroklib and amarokcollectionscanner (which doesn't link to amaroklib). - */ -namespace Meta -{ - /** This type can be used when a number of fields need to - * be given to some functions. - */ - typedef QHash FieldHash; - - // the following constants are used at a number of places, - // Most importantly the QueryMaker - // it's also used when reading and writing taglib tags - - // if something is added here: also updsate MetaConstants.cpp - - //track metadata - static const qint64 valUrl = 1LL << 0; - static const qint64 valTitle = 1LL << 1; - static const qint64 valArtist = 1LL << 2; - static const qint64 valAlbum = 1LL << 3; - static const qint64 valGenre = 1LL << 4; - static const qint64 valComposer = 1LL << 5; - static const qint64 valYear = 1LL << 6; - static const qint64 valComment = 1LL << 7; - static const qint64 valTrackNr = 1LL << 8; - static const qint64 valDiscNr = 1LL << 9; - static const qint64 valBpm = 1LL << 10; - //track data - static const qint64 valLength = 1LL << 11; - static const qint64 valBitrate = 1LL << 12; - static const qint64 valSamplerate = 1LL << 13; - static const qint64 valFilesize = 1LL << 14; - static const qint64 valFormat = 1LL << 15; // the file type a numeric value - static const qint64 valCreateDate = 1LL << 16; - //statistics - static const qint64 valScore = 1LL << 17; // value 0 to 100 - static const qint64 valRating = 1LL << 18; // value 0 to 10 (inclusive) - static const qint64 valFirstPlayed = 1LL << 19; - static const qint64 valLastPlayed = 1LL << 20; - static const qint64 valPlaycount = 1LL << 21; - static const qint64 valUniqueId = 1LL << 22; - //replay gain - static const qint64 valTrackGain = 1LL << 23; - static const qint64 valTrackGainPeak= 1LL << 24; - static const qint64 valAlbumGain = 1LL << 25; - static const qint64 valAlbumGainPeak= 1LL << 26; - - static const qint64 valAlbumArtist = 1LL << 27; - static const qint64 valLabel = 1LL << 28; - static const qint64 valModified = 1LL << 29; - - // currently only used for reading and writing tags. Not supported for queryMaker - // TODO: support for queryMaker - static const qint64 valCompilation = 1LL << 40; - static const qint64 valHasCover = (1LL << 40) + 1; - static const qint64 valImage = (1LL << 40) + 2; - static const qint64 valLyrics = (1LL << 40) + 3; - - // start for custom numbers - static const qint64 valCustom = 1LL << 60; -} - -#endif diff --git a/amarok/shared/README b/amarok/shared/README deleted file mode 100644 index 6df6f119..00000000 --- a/amarok/shared/README +++ /dev/null @@ -1 +0,0 @@ -This directory contains code shared between both the utilities and the player. diff --git a/amarok/shared/ScriptUpdaterStatic.h b/amarok/shared/ScriptUpdaterStatic.h deleted file mode 100644 index e1a6ef83..00000000 --- a/amarok/shared/ScriptUpdaterStatic.h +++ /dev/null @@ -1,37 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Jakob Kummerow * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_SCRIPTUPDATERSTATIC_H -#define AMAROK_SCRIPTUPDATERSTATIC_H - -#include - -// static configuration -static const QString updateBaseUrl = "http://amarok.kde.org:81/"; // must end with '/' -static const QString archiveFilename = "main.tar.bz2"; -static const QString versionFilename = "version"; -static const QString signatureFilename = "signature"; -static const QString publicKey = "-----BEGIN PUBLIC KEY-----\n" -"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuiTmOX5inpOpSIHDB5Je\n" -"W2R+YKINMdWW35rL0NKt7tCm1bl3Xdd9k7AdSHSCkJo4xnpXwLeisAhLEpNNCsUZ\n" -"n1GNJ1AouCfSlHOyES9uIc9ecLx3ByjfQ4XKBu0Jf1QmoAhzRgpvdoYtkR/gul8X\n" -"yfA1n6keL3ZQ+5YYqD/vU5rgYKaOloZlUhXVVohfJxCV9jvKRvfVsVlt5DQmYt1k\n" -"GfWjJAaJ6/XS+BlvxV8pgEYvnH4aVtspoD3GMIJLV8q+xK9FeQUNJZxlOoj5CyMc\n" -"BZmCyrPU1o4S4nvCSOFuAkEYtlnsSs4U/LmW3uKkVJET22wG2c/CPR8J9+X/pHZA\n" -"4QIDAQAB\n" -"-----END PUBLIC KEY-----\n"; - -#endif diff --git a/amarok/shared/TagsFromFileNameGuesser.cpp b/amarok/shared/TagsFromFileNameGuesser.cpp deleted file mode 100644 index 1152271b..00000000 --- a/amarok/shared/TagsFromFileNameGuesser.cpp +++ /dev/null @@ -1,143 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Sergey Ivanov <123kash@gmail.com> * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "TagsFromFileNameGuesser.h" - -#include - -const QStringList m_schemes( QStringList() - //01 Artist - Title.ext - << "^%track%\\W*-?\\W*%artist%\\W*-\\W*%title%\\.+(?:\\w{2,5})$" - //01 Title.ext - << "^%track%\\W*-?\\W*%title%\\.+?:\\w{2,5}$" - //Album - 01 - Artist - Title.ext - << "^%album%\\W*-\\W*%track%\\W*-\\W*%artist%\\W*-\\W*%title%\\.+(?:\\w{2,5})$" - //Artist - Album - 01 - Title.ext - << "^%artist%\\W*-\\W*%album%\\W*-\\W*%track%\\W*-\\W*%title%\\.+(?:\\w{2,5})$" - // Artist - Album - Title.ext - << "^%artist%\\W*-\\W*%album%\\W*-\\W*%title%\\.+(?:\\w{2,5})$" - //Artist - Title.ext - << "^%artist%\\W*-\\W*%title%\\.+(?:\\w{2,5})$" - //Title.ext - << "^%title%\\.+(?:\\w{2,5})$" -); - -const QRegExp m_digitalFields( "(%(?:discnumber|track|year)%)" ); -const QRegExp m_literalFields( "(%(?:album|albumartist|artist|comment|composer|genre|title)%)" ); - -quint64 -fieldName( const QString &field ) -{ - if( field == "album" ) - return Meta::valAlbum; - else if( field == "albumartist" ) - return Meta::valAlbumArtist; - else if( field == "artist" ) - return Meta::valArtist; - else if( field == "comment" ) - return Meta::valComment; - else if( field == "composer" ) - return Meta::valComposer; - else if( field == "discnumber" ) - return Meta::valDiscNr; - else if( field == "genre" ) - return Meta::valGenre; - else if( field == "title" ) - return Meta::valTitle; - else if( field == "track" ) - return Meta::valTrackNr; - else if( field == "year" ) - return Meta::valYear; - - return 0; -} - -QList< qint64 > -parseTokens( const QString &scheme ) -{ - QRegExp rxm( "%(\\w+)%" ); - QList< qint64 > tokens; - - int pos = 0; - qint64 field; - while( ( pos = rxm.indexIn( scheme, pos ) ) != -1 ) - { - field = fieldName( rxm.cap( 1 ) ); - if( field ) - tokens << field; - pos += rxm.matchedLength(); - } - - return tokens; -} - -Meta::FieldHash -Meta::Tag::TagGuesser::guessTagsByScheme( const QString &fileName, const QString &scheme, - bool cutTrailingSpaces, bool convertUnderscores, - bool isRegExp ) -{ - Meta::FieldHash metadata; - - QRegExp rx; - - QString m_fileName = fileName; - QString m_scheme = scheme; - - QList< qint64 > tokens = parseTokens( m_scheme ); - - // Screen all special symbols - if( !isRegExp ) - m_scheme = m_scheme.replace( QRegExp( "([~!\\^&*()\\-+\\[\\]{}\\\\:\"?\\.])" ),"\\\\1" ); - - QRegExp spaces( "(\\s+)" ); - rx.setPattern( m_scheme.replace( spaces, "\\s+" ) - .replace( m_digitalFields, "(\\d+)" ) - .replace( m_literalFields, "(.+)" ) - .replace( "%ignore%", "(?:.+)" ) ); - - if( !rx.exactMatch( m_fileName ) ) - return metadata; - - QString value; - for( int i = 0; i < tokens.count(); i++ ) - { - value = rx.cap( i + 1 ); - if( convertUnderscores ) - value.replace( '_', ' ' ); - if( cutTrailingSpaces ) - value = value.trimmed(); - metadata.insert( tokens[i], value ); - } - return metadata; -} - -Meta::FieldHash -Meta::Tag::TagGuesser::guessTags( const QString &fileName ) -{ - QString tmpStr = fileName; - int pos = 0; - if( ( pos = fileName.lastIndexOf( '/' ) ) != -1 ) - tmpStr = fileName.mid( pos + 1 ); - - foreach( const QString &scheme, m_schemes ) - { - Meta::FieldHash metadata = guessTagsByScheme( tmpStr, scheme, true, true, true ); - if( !metadata.isEmpty() ) - return metadata; - } - - return Meta::FieldHash(); -} diff --git a/amarok/shared/TagsFromFileNameGuesser.h b/amarok/shared/TagsFromFileNameGuesser.h deleted file mode 100644 index 0aa94c5b..00000000 --- a/amarok/shared/TagsFromFileNameGuesser.h +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Sergey Ivanov <123kash@gmail.com> * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - - -#ifndef TAGSFROMFILENAMEGUESSER_H -#define TAGSFROMFILENAMEGUESSER_H - -#include "amarokshared_export.h" -#include "MetaValues.h" - -namespace Meta -{ - namespace Tag - { - namespace TagGuesser - { - /** - * Try to guess metadata from file name, using common filename - * templates, can't work with full file path. - * @arg fileName file name, if fileName contains full path, It will be - * truckated. - * @returns guessed metadata. - */ - AMAROKSHARED_EXPORT Meta::FieldHash guessTags( const QString &fileName ); - - /** - * Try to guess metadata from fil name,using specified scheme. - * @arg fileName file path - * @arg scheme is a regular exprassion with tokens - * @arg cutTrailingSpaces - if true - force guesser to cut trailing spaces - * @arg convertUnderscores - if true - force guesser too replace all underscores with spaces - * @arg isRegExp - if true - prevents guesser from screening special symbols - * Available Tokens: %album%, %albumartist%, %artist%, %title%, %track%. - */ - AMAROKSHARED_EXPORT Meta::FieldHash guessTagsByScheme( const QString &fileName, - const QString &scheme, - bool cutTrailingSpaces = true, - bool convertUnderscores = true, - bool isRegExp = false ); - } - } -} - -#endif // TAGSFROMFILENAMEGUESSER_H diff --git a/amarok/shared/Version.h b/amarok/shared/Version.h deleted file mode 100644 index 712079e4..00000000 --- a/amarok/shared/Version.h +++ /dev/null @@ -1,23 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Mark Kretschmann * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_VERSION_H -#define AMAROK_VERSION_H - -/// Update this when necessary -#define AMAROK_VERSION "2.8-git" - -#endif // End include guard diff --git a/amarok/shared/amarokshared_export.h b/amarok/shared/amarokshared_export.h deleted file mode 100644 index 38250613..00000000 --- a/amarok/shared/amarokshared_export.h +++ /dev/null @@ -1,33 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2013 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROKSHARED_EXPORT_H -#define AMAROKSHARED_EXPORT_H - -/* needed for KDE_EXPORT and KDE_IMPORT macros */ -#include - -#ifndef AMAROKSHARED_EXPORT -# ifdef MAKE_AMAROKSHARED_LIB - /* We are building this library */ -# define AMAROKSHARED_EXPORT KDE_EXPORT -# else - /* We are using this library */ -# define AMAROKSHARED_EXPORT KDE_IMPORT -# endif -#endif // AMAROKSHARED_EXPORT - -#endif // AMAROKSHARED_EXPORT_H diff --git a/amarok/shared/collectionscanner/Album.cpp b/amarok/shared/collectionscanner/Album.cpp deleted file mode 100644 index dcfd7e8e..00000000 --- a/amarok/shared/collectionscanner/Album.cpp +++ /dev/null @@ -1,142 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2010 Ralf Engels * - * * - * This program 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 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#include "Album.h" - -#include "Track.h" - -#include -#include - -#include - -// constructor is needed to put albums in a hash -CollectionScanner::Album::Album() -{} - -CollectionScanner::Album::Album( const QString &name, const QString &artist ) - : m_name( name ) - , m_artist( artist ) -{} - -void -CollectionScanner::Album::addTrack( Track *track ) -{ - m_tracks.append( track ); -} - -QString -CollectionScanner::Album::name() const -{ - return m_name; -} - -QString -CollectionScanner::Album::artist() const -{ - return m_artist; -} - -void -CollectionScanner::Album::setArtist( const QString &artist ) -{ - m_artist = artist; -} - - -QString -CollectionScanner::Album::cover() const -{ - // we prefer covers included in tracks. - // At least we know exactly that they really belong to the album - foreach( Track *track, m_tracks ) - { - // IMPROVEMENT: skip covers that have a strange aspect ratio or are - // unrealistically small, or do not resolve to a valid image - if( track->hasCover() ) - return QLatin1String("amarok-sqltrackuid://") + track->uniqueid(); - } - - // ok. Now we have to figure out which of the cover images is - // the best. - QString bestCover; - int bestRating = -1; - qint64 bestSize = 0; - - foreach( const QString &cover, m_covers ) - { - int rating = 0; - - if( cover.contains( QLatin1String("front"), Qt::CaseInsensitive ) || - cover.contains( QObject::tr( "front", "Front cover of an album" ), Qt::CaseInsensitive ) ) - rating += 2; - - if( cover.contains( QLatin1String("cover"), Qt::CaseInsensitive ) || - cover.contains( QObject::tr( "cover", "(Front) Cover of an album" ), Qt::CaseInsensitive ) ) - rating += 2; - - //next: try "folder" (some applications apparently use this) - //using compare and not contains to not hit "Folder-Back" or something. - if( cover.compare( QLatin1String("folder"), Qt::CaseInsensitive ) == 0) - rating += 1; - - QFileInfo info( cover ); - if( (rating == bestRating && info.size() > bestSize) || - (rating > bestRating) ) - { - bestCover = cover; - bestRating = rating; - bestSize = info.size(); - } - } - - return bestCover; -} - -QStringList -CollectionScanner::Album::covers() const -{ - return m_covers; -} - -void -CollectionScanner::Album::setCovers( const QStringList &covers ) -{ - m_covers = covers; -} - - - -QList -CollectionScanner::Album::tracks() const -{ - return m_tracks; -} - -bool -CollectionScanner::Album::isNoCompilation() const -{ - foreach( CollectionScanner::Track *track, m_tracks ) - { - if( track->isNoCompilation() ) - return true; - } - - return false; -} diff --git a/amarok/shared/collectionscanner/Album.h b/amarok/shared/collectionscanner/Album.h deleted file mode 100644 index e1bb04f7..00000000 --- a/amarok/shared/collectionscanner/Album.h +++ /dev/null @@ -1,77 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2010 Ralf Engels * - * * - * This program 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 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#ifndef COLLECTIONSCANNER_ALBUM_H -#define COLLECTIONSCANNER_ALBUM_H - -#include "amarokshared_export.h" - -#include -#include -#include - -#include - -namespace CollectionScanner -{ -class Track; - -/** This album class is used by the ScanResultProcessor to sort tracks into albums. - @class Album - @short Represents a scanned album and it's contents - @author Ralf Engels -*/ -class AMAROKSHARED_EXPORT Album -{ -public: - Album(); - Album( const QString &name, const QString &artist ); - - /** Adds a track to this album. - The track must still be freed by the caller. - */ - void addTrack( Track *track ); - - QString name() const; - - /** Returns the artist of this album. */ - QString artist() const; - void setArtist( const QString &artist ); - - /** Returns the picture best suited as cover for this album */ - QString cover() const; - - /** Returns all covers added via addCovers() */ - QStringList covers() const; - void setCovers( const QStringList &covers ); - - QList tracks() const; - - bool isNoCompilation() const; - -private: - QString m_name; - QString m_artist; - QStringList m_covers; - QList m_tracks; -}; - -} - -#endif // COLLECTIONSCANNER_ALBUM_H diff --git a/amarok/shared/collectionscanner/BatchFile.cpp b/amarok/shared/collectionscanner/BatchFile.cpp deleted file mode 100644 index 7c396975..00000000 --- a/amarok/shared/collectionscanner/BatchFile.cpp +++ /dev/null @@ -1,155 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2010 Ralf Engels * - * * - * This program 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 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#include "BatchFile.h" - -#include "Version.h" // for AMAROK_VERSION - -#include -#include - -#include - -#include -CollectionScanner::BatchFile::BatchFile() -{ -} - -CollectionScanner::BatchFile::BatchFile( const QString &batchPath ) -{ - QFile batchFile( batchPath ); - - if( !batchFile.exists() || - !batchFile.open( QIODevice::ReadOnly ) ) - return; - - QString path; - uint mtime = 0; - bool haveMtime = false; - QXmlStreamReader reader( &batchFile ); - - // very simple parser - while (!reader.atEnd()) { - reader.readNext(); - - if( reader.isStartElement() ) - { - QStringRef name = reader.name(); - - if( name == QLatin1String("scanner") ) - { - ; // just recurse into the element - } - else if( name == QLatin1String("directory") ) - { - path.clear(); - mtime = 0; - haveMtime = false; - } - else if( name == QLatin1String("path") ) - path = reader.readElementText(QXmlStreamReader::SkipChildElements); - else if( name == QLatin1String("mtime") ) - { - mtime = reader.readElementText(QXmlStreamReader::SkipChildElements).toUInt(); - haveMtime = true; - } - else - { - reader.skipCurrentElement(); - } - } - else if( reader.isEndElement() ) - { - QStringRef name = reader.name(); - if( name == QLatin1String("directory") ) - { - if( !path.isEmpty() ) - { - if( haveMtime ) - m_timeDefinitions.append( TimeDefinition( path, mtime ) ); - else - m_directories.append( path ); - } - } - } - } - -} -const QStringList& -CollectionScanner::BatchFile::directories() const -{ - return m_directories; -} - -void -CollectionScanner::BatchFile::setDirectories( const QStringList &value ) -{ - m_directories = value; -} - -const QList& -CollectionScanner::BatchFile::timeDefinitions() const -{ - return m_timeDefinitions; -} - -void -CollectionScanner::BatchFile::setTimeDefinitions( const QList &value ) -{ - m_timeDefinitions = value; -} - -bool -CollectionScanner::BatchFile::write( const QString &batchPath ) -{ - QFile batchFile( batchPath ); - if( !batchFile.open( QIODevice::WriteOnly | QIODevice::Truncate ) ) - return false; - - QXmlStreamWriter writer( &batchFile ); - writer.setAutoFormatting( true ); - - writer.writeStartDocument(); - writer.writeStartElement( QLatin1String("scanner") ); - writer.writeComment("Batch file for amarokcollectionscanner " AMAROK_VERSION " created on "+QDateTime::currentDateTime().toString()); - - foreach( const QString &dir, m_directories ) - { - writer.writeStartElement( QLatin1String("directory") ); - writer.writeTextElement( QLatin1String("path"), dir ); - writer.writeEndElement(); - } - - foreach( const TimeDefinition &pair, m_timeDefinitions ) - { - QString path( pair.first ); - uint mtime = pair.second; - - writer.writeStartElement( QLatin1String("directory") ); - writer.writeTextElement( QLatin1String("path"), path ); - // note: some file systems return an mtime of 0 - writer.writeTextElement( QLatin1String("mtime"), QString::number( mtime ) ); - writer.writeEndElement(); - } - - writer.writeEndElement(); - writer.writeEndDocument(); - - return true; -} diff --git a/amarok/shared/collectionscanner/BatchFile.h b/amarok/shared/collectionscanner/BatchFile.h deleted file mode 100644 index 484583e5..00000000 --- a/amarok/shared/collectionscanner/BatchFile.h +++ /dev/null @@ -1,69 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2010 Ralf Engels * - * * - * This program 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 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#ifndef COLLECTIONSCANNER_BATCHFILE_H -#define COLLECTIONSCANNER_BATCHFILE_H - -#include "amarokshared_export.h" - -#include -#include -#include -#include - -namespace CollectionScanner -{ - - -/** - * @class BatchFile - * @short This class can be used to read and write batch files for the collection scanner. - */ - -class AMAROKSHARED_EXPORT BatchFile -{ -public: - /** Constructs and empty BatchFile */ - BatchFile(); - - /** Reads the BatchFile from the disk */ - BatchFile( const QString &path ); - - /** This type is a pair of directory path and modification time */ - typedef QPair TimeDefinition; - - /** Those are the directories that should be added to the scanning list */ - const QStringList &directories() const; - void setDirectories( const QStringList &value ); - - const QList &timeDefinitions() const; - void setTimeDefinitions( const QList &value ); - - /** Writes the BatchFile to the disk. - @returns true if writing was successful. - */ - bool write( const QString &path ); - -private: - QStringList m_directories; - QList m_timeDefinitions; -}; - -} -#endif // COLLECTIONSCANNER_BATCHFILE_H diff --git a/amarok/shared/collectionscanner/Directory.cpp b/amarok/shared/collectionscanner/Directory.cpp deleted file mode 100644 index 0fd4f729..00000000 --- a/amarok/shared/collectionscanner/Directory.cpp +++ /dev/null @@ -1,247 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2003-2005 Max Howell * - * (C) 2003-2010 Mark Kretschmann * - * (C) 2005-2007 Alexandre Oliveira * - * (C) 2008 Dan Meltzer * - * (C) 2008-2009 Jeff Mitchell * - * * - * This program 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 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#include "Directory.h" - -#include "collectionscanner/ScanningState.h" -#include "collectionscanner/Track.h" -#include "collectionscanner/utils.h" - -#include -#include -#include -#include -#include -#include -#include -#include - - -#include - -CollectionScanner::Directory::Directory( const QString &path, - CollectionScanner::ScanningState *state, - bool skip ) - : m_ignored( false ) -{ - m_path = path; - m_rpath = QDir::current().relativeFilePath( path ); - m_mtime = QFileInfo( path ).lastModified().toTime_t(); - m_skipped = skip; - - if( m_skipped ) - return; - - QDir dir( path ); - if( dir.exists( "fmps_ignore" ) ) - { - m_ignored = true; - return; - } - - QStringList validImages; - validImages << "jpg" << "png" << "gif" << "jpeg" << "bmp" << "svg" << "xpm"; - QStringList validPlaylists; - validPlaylists << "m3u" << "pls" << "xspf"; - - // --- check if we were restarted and failed at a file - QStringList badFiles; - - if( state->lastDirectory() == path ) - { - badFiles << state->badFiles(); - QString lastFile = state->lastFile(); - if( !lastFile.isEmpty() ) - { - badFiles << state->lastFile(); - state->setBadFiles( badFiles ); - } - } - else - state->setLastDirectory( path ); - state->setLastFile( QString() ); // reset so we don't add a leftover file - - dir.setFilter( QDir::NoDotAndDotDot | QDir::Files ); - QFileInfoList fileInfos = dir.entryInfoList(); - - foreach( const QFileInfo &fi, fileInfos ) - { - if( !fi.exists() ) - continue; - - const QFileInfo &f = fi.isSymLink() ? QFileInfo( fi.symLinkTarget() ) : fi; - - if( badFiles.contains( f.absoluteFilePath() ) ) - continue; - - const QString suffix = fi.suffix().toLower(); - const QString filePath = f.absoluteFilePath(); - - // -- cover image ? - if( validImages.contains( suffix ) ) - m_covers.append( filePath ); - - // -- playlist ? - else if( validPlaylists.contains( suffix ) ) - m_playlists.append( CollectionScanner::Playlist( filePath ) ); - - // -- audio track ? - else - { - // remember the last file before it get's dangerous. Before starting taglib - state->setLastFile( f.absoluteFilePath() ); - - CollectionScanner::Track *newTrack = new CollectionScanner::Track( filePath, this ); - if( newTrack->isValid() ) - m_tracks.append( newTrack ); - else - delete newTrack; - } - } -} - -CollectionScanner::Directory::Directory( QXmlStreamReader *reader ) - : m_mtime( 0 ) - , m_skipped( false ) - , m_ignored( false ) -{ - // improve scanner with skipCurrentElement as soon as Amarok requires Qt 4.6 - while (!reader->atEnd()) { - reader->readNext(); - - if( reader->isStartElement() ) - { - QStringRef name = reader->name(); - if( name == "path" ) - m_path = reader->readElementText(QXmlStreamReader::SkipChildElements); - else if( name == "rpath" ) - m_rpath = reader->readElementText(QXmlStreamReader::SkipChildElements); - else if( name == "mtime" ) - m_mtime = reader->readElementText(QXmlStreamReader::SkipChildElements).toUInt(); - else if( name == "cover" ) - m_covers.append(reader->readElementText(QXmlStreamReader::SkipChildElements)); - else if( name == "skipped" ) - { - m_skipped = true; - reader->skipCurrentElement(); - } - else if( name == "ignored" ) - { - m_ignored = true; - reader->skipCurrentElement(); - } - else if( name == "track" ) - m_tracks.append( new CollectionScanner::Track( reader, this ) ); - else if( name == "playlist" ) - m_playlists.append( CollectionScanner::Playlist( reader ) ); - else - { - qDebug() << "Unexpected xml start element"<skipCurrentElement(); - } - } - - else if( reader->isEndElement() ) - { - break; - } - } -} - -CollectionScanner::Directory::~Directory() -{ - foreach( CollectionScanner::Track *track, m_tracks ) - delete track; -} - -QString -CollectionScanner::Directory::path() const -{ - return m_path; -} - -QString -CollectionScanner::Directory::rpath() const -{ - return m_rpath; -} - -uint -CollectionScanner::Directory::mtime() const -{ - return m_mtime; -} - -bool -CollectionScanner::Directory::isSkipped() const -{ - return m_skipped; -} - -const QStringList& -CollectionScanner::Directory::covers() const -{ - return m_covers; -} - -const QList& -CollectionScanner::Directory::tracks() const -{ - return m_tracks; -} - -const QList& -CollectionScanner::Directory::playlists() const -{ - return m_playlists; -} - -void -CollectionScanner::Directory::toXml( QXmlStreamWriter *writer ) const -{ - writer->writeTextElement( "path", escapeXml10(m_path) ); - writer->writeTextElement( "rpath", escapeXml10(m_rpath) ); - writer->writeTextElement( "mtime", QString::number( m_mtime ) ); - if( m_skipped ) - writer->writeEmptyElement( "skipped" ); - if( m_ignored ) - writer->writeEmptyElement( "ignored" ); - - foreach( const QString &cover, m_covers ) - { - writer->writeTextElement( "cover", escapeXml10(cover) ); - } - foreach( CollectionScanner::Track *track, m_tracks ) - { - writer->writeStartElement( QLatin1String("track") ); - track->toXml( writer ); - writer->writeEndElement(); - } - - foreach( const CollectionScanner::Playlist &playlist, m_playlists ) - { - writer->writeStartElement( "playlist" ); - playlist.toXml( writer ); - writer->writeEndElement(); - } -} diff --git a/amarok/shared/collectionscanner/Directory.h b/amarok/shared/collectionscanner/Directory.h deleted file mode 100644 index fc5fb9d7..00000000 --- a/amarok/shared/collectionscanner/Directory.h +++ /dev/null @@ -1,103 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2010 Ralf Engels * - * * - * This program 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 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#ifndef COLLECTIONSCANNER_DIRECTORY_H -#define COLLECTIONSCANNER_DIRECTORY_H - -#include "Album.h" -#include "Playlist.h" -#include "amarokshared_export.h" - -#include -#include -#include - -#include - -namespace CollectionScanner -{ - -class Track; -class ScanningState; - -/** - * @class Directory - * @short Represents a scanned directory and it's contents - */ -class AMAROKSHARED_EXPORT Directory -{ -public: - /** - * This contructor actually scans the directory and is supposed only to be - * called by CollectionScanner directly. - */ - Directory( const QString &path, ScanningState *state, bool skip ); - - /** Reads a directory from an xml stream. - * @see toXml() - */ - Directory( QXmlStreamReader *reader ); - - ~Directory(); - - /** The absolute path to the file. - * Because of symbolic links the path could be outside the original scanning directories. - */ - QString path() const; - - /** Returns the relative path at the point of scanning */ - QString rpath() const; - - /** Returns the modification time of the directory. */ - uint mtime() const; - - /** Returns true if the directory was skipped and not scanned. - * Usually this is being done because the directory was unmodified in an - * Incremental scan. - */ - bool isSkipped() const; - - const QStringList& covers() const; - const QList& tracks() const; - const QList& playlists() const; - - /** Writes the contents of this object to an xml stream. - * Only the content is writen and no enclosing directory tags. - * This is done to make it mirror the constructor which does not read those - * tags either. - */ - void toXml( QXmlStreamWriter *writer ) const; - -private: - Q_DISABLE_COPY(Directory) - - QString m_path; - QString m_rpath; - uint m_mtime; - bool m_skipped; - bool m_ignored; // the directory was ingored e.g. because of "fmps_ignore" - - QStringList m_covers; - QList m_tracks; - QList m_playlists; -}; - -} - -#endif // COLLECTIONSCANNER_DIRECTORY_H diff --git a/amarok/shared/collectionscanner/Playlist.cpp b/amarok/shared/collectionscanner/Playlist.cpp deleted file mode 100644 index 6498037a..00000000 --- a/amarok/shared/collectionscanner/Playlist.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2010 Ralf Engels * - * * - * This program 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 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#include "Playlist.h" -#include "utils.h" - -#include - -#include - -CollectionScanner::Playlist::Playlist( const QString &path ) -{ - m_path = path; - m_rpath = QDir::current().relativeFilePath( path ); -} - -CollectionScanner::Playlist::Playlist( QXmlStreamReader *reader ) -{ - while (!reader->atEnd()) { - reader->readNext(); - - if( reader->isStartElement() ) - { - if( reader->name() == QLatin1String("path") ) - m_path = reader->readElementText(); - else if( reader->name() == QLatin1String("rpath") ) - m_rpath = reader->readElementText(); - else - reader->readElementText(); // just read over the element - } - - else if( reader->isEndElement() ) - { - break; - } - } -} - -QString -CollectionScanner::Playlist::path() const -{ - return m_path; -} - -QString -CollectionScanner::Playlist::rpath() const -{ - return m_rpath; -} - -void -CollectionScanner::Playlist::toXml( QXmlStreamWriter *writer ) const -{ - writer->writeTextElement( QLatin1String("path"), escapeXml10(m_path) ); - writer->writeTextElement( QLatin1String("rpath"), escapeXml10(m_rpath) ); -} diff --git a/amarok/shared/collectionscanner/Playlist.h b/amarok/shared/collectionscanner/Playlist.h deleted file mode 100644 index be3ba8da..00000000 --- a/amarok/shared/collectionscanner/Playlist.h +++ /dev/null @@ -1,66 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2010 Ralf Engels * - * * - * This program 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 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#ifndef COLLECTIONSCANNER_PLAYLIST_H -#define COLLECTIONSCANNER_PLAYLIST_H - -#include "amarokshared_export.h" - -#include - -#include - -namespace CollectionScanner -{ - -/** - * @class Playlist - * @short Represents a playlist - */ - -class AMAROKSHARED_EXPORT Playlist -{ -public: - Playlist( const QString &path ); - Playlist( QXmlStreamReader *reader ); - - /** The absolute path to the file. - * Because of symbolic links the path could be outside the original scanning directories. - */ - QString path() const; - - /** Returns the relative path at the point of scanning */ - QString rpath() const; - - - /** Writes the contents of this object to an xml stream. - * Only the content is writen and no enclosing directory tags. - * This is done to make it mirror the constructor which does not read those - * tags either. - */ - void toXml( QXmlStreamWriter *writer ) const; - -private: - QString m_path; - QString m_rpath; -}; - -} - -#endif // COLLECTIONSCANNER_PLAYLIST_H diff --git a/amarok/shared/collectionscanner/ScanningState.cpp b/amarok/shared/collectionscanner/ScanningState.cpp deleted file mode 100644 index 88755599..00000000 --- a/amarok/shared/collectionscanner/ScanningState.cpp +++ /dev/null @@ -1,181 +0,0 @@ -/**************************************************************************************** - * Copyright (C) 2003-2010 Mark Kretschmann * - * Copyright (C) 2008 Dan Meltzer * - * Copyright (C) 2008-2009 Jeff Mitchell * - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "ScanningState.h" - -#include -#include - -#ifdef Q_CC_MSVC -#define __PRETTY_FUNCTION__ __FUNCSIG__ -#endif - -using namespace CollectionScanner; - -ScanningState::ScanningState() - : m_sharedMemory( 0 ) - , m_lastFilePos( 0 ) -{ -} - -ScanningState::~ScanningState() -{ - delete m_sharedMemory; -} - -void -ScanningState::setKey( const QString &key ) -{ - delete m_sharedMemory; - m_sharedMemory = new QSharedMemory( key ); - m_sharedMemory->attach(); -} - -bool -ScanningState::isValid() const -{ - return m_sharedMemory && m_sharedMemory->isAttached(); -} - -QString -ScanningState::lastDirectory() const -{ - return m_lastDirectory; -} - -void -ScanningState::setLastDirectory( const QString &dir ) -{ - if( dir == m_lastDirectory ) - return; - - m_lastDirectory = dir; - writeFull(); -} - -QStringList -ScanningState::badFiles() const -{ - return m_badFiles; -} - -void -ScanningState::setBadFiles( const QStringList &badFiles ) -{ - if( badFiles == m_badFiles ) - return; - - m_badFiles = badFiles; - writeFull(); -} - -QString -ScanningState::lastFile() const -{ - return m_lastFile; -} - -void -ScanningState::setLastFile( const QString &file ) -{ - if( file == m_lastFile ) - return; - - m_lastFile = file; - - if( !isValid() ) - return; - - QBuffer buffer; - QDataStream out(&buffer); - - buffer.open(QBuffer::WriteOnly); - - out << m_lastFile; - int size = buffer.size(); - - if( size + m_lastFilePos < m_sharedMemory->size() ) - { - char *to = (char*)m_sharedMemory->data(); - const char *from = buffer.data().data(); - memcpy(to + m_lastFilePos, from, size); - } - else - { - qDebug() << __PRETTY_FUNCTION__ << "QSharedMemory is too small to hold the data."; - qDebug() << "It is of size" << m_sharedMemory->size() << "bytes but we need more than" - << size + m_lastFilePos << "bytes."; - } - - m_sharedMemory->unlock(); -} - -void -ScanningState::readFull() -{ - if( !isValid() ) - return; - - QBuffer buffer; - QDataStream in(&buffer); - - m_sharedMemory->lock(); - buffer.setData((char*)m_sharedMemory->constData(), m_sharedMemory->size()); - buffer.open(QBuffer::ReadOnly); - - in >> m_lastDirectory; - in >> m_badFiles; - m_lastFilePos = buffer.pos(); - in >> m_lastFile; - - m_sharedMemory->unlock(); -} - -void -ScanningState::writeFull() -{ - if( !isValid() ) - return; - - QBuffer buffer; - QDataStream out(&buffer); - buffer.open(QBuffer::WriteOnly); - - out << m_lastDirectory; - out << m_badFiles; - m_lastFilePos = buffer.pos(); - out << m_lastFile; - int size = buffer.size(); - - m_sharedMemory->lock(); - if( size < m_sharedMemory->size() ) - { - char *to = (char*)m_sharedMemory->data(); - const char *from = buffer.data().data(); - memcpy(to, from, size); - } - else - { - qDebug() << __PRETTY_FUNCTION__ << "QSharedMemory is too small to hold the data."; - qDebug() << "It is of size" << m_sharedMemory->size() << "bytes but we need more than" - << size << "bytes."; - } - - m_sharedMemory->unlock(); -} diff --git a/amarok/shared/collectionscanner/ScanningState.h b/amarok/shared/collectionscanner/ScanningState.h deleted file mode 100644 index ad9e03bc..00000000 --- a/amarok/shared/collectionscanner/ScanningState.h +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************************** - * Copyright (C) 2003-2010 Mark Kretschmann * - * Copyright (C) 2008 Dan Meltzer * - * Copyright (C) 2008-2009 Jeff Mitchell * - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef COLLECTIONSCANNER_SCANNINGSTATE_H -#define COLLECTIONSCANNER_SCANNINGSTATE_H - -#include "amarokshared_export.h" - -#include -#include -#include - -namespace CollectionScanner -{ - -/** A class used to store the current scanning state in a shared memory segment. - Storing the state of the scanner shouldn't cause a file access. - We are using a shared memory that the amarok process holds open until the scanning - is finished to store the state. - */ -class AMAROKSHARED_EXPORT ScanningState -{ - public: - ScanningState(); - ~ScanningState(); - - void setKey( const QString &key ); - bool isValid() const; - - QString lastDirectory() const; - void setLastDirectory( const QString &dir ); - - QStringList badFiles() const; - void setBadFiles( const QStringList &badFiles ); - - QString lastFile() const; - void setLastFile( const QString &file ); - - void readFull(); - void writeFull(); - - private: - QSharedMemory *m_sharedMemory; - - QString m_lastDirectory; - QStringList m_badFiles; - QString m_lastFile; - qint64 m_lastFilePos; -}; - -} - -#endif // COLLECTIONSCANNER_SCANNINGSTATE_H diff --git a/amarok/shared/collectionscanner/Track.cpp b/amarok/shared/collectionscanner/Track.cpp deleted file mode 100644 index 0543ee3c..00000000 --- a/amarok/shared/collectionscanner/Track.cpp +++ /dev/null @@ -1,530 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2003-2005 Max Howell * - * (C) 2003-2010 Mark Kretschmann * - * (C) 2005-2007 Alexandre Oliveira * - * (C) 2008 Dan Meltzer * - * (C) 2008-2009 Jeff Mitchell * - * * - * This program 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 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#include "Track.h" -#include "utils.h" - -#include "MetaTagLib.h" -#include "MetaReplayGain.h" - -#include -#include -#include -#include - -#include - -bool CollectionScanner::Track::s_useCharsetDetector = false; - - -CollectionScanner::Track::Track( const QString &path, CollectionScanner::Directory* directory ) - : m_valid( true ) - , m_directory( directory ) - , m_filetype( Amarok::Unknown ) - , m_compilation( false ) - , m_noCompilation( false ) - , m_hasCover( false ) - , m_year( -1 ) - , m_disc( -1 ) - , m_track( -1 ) - , m_bpm( -1.0 ) - , m_bitrate( -1 ) - , m_length( -1.0 ) - , m_samplerate( -1 ) - , m_filesize( -1 ) - - , m_trackGain( -1.0 ) - , m_trackPeakGain( -1.0 ) - , m_albumGain( -1.0 ) - , m_albumPeakGain( -1.0 ) - - , m_rating( -1.0 ) - , m_score( -1.0 ) - , m_playcount( -1.0 ) -{ - static const int MAX_SENSIBLE_LENGTH = 1023; // the maximum length for normal strings. - // in corner cases a longer string might cause problems see BUG:276894 - - // for the unit test. - // in a debug build a file called "crash_amarok_here.ogg" will crash the collection - // scanner - if( path.contains("crash_amarok_here.ogg") ) - { - qDebug() << "Crashing at"<atEnd()) { - reader->readNext(); - - if( reader->isStartElement() ) - { - QStringRef name = reader->name(); - if( name == QLatin1String("uniqueid") ) - m_uniqueid = reader->readElementText(QXmlStreamReader::SkipChildElements); - else if( name == QLatin1String("path") ) - m_path = reader->readElementText(QXmlStreamReader::SkipChildElements); - else if( name == QLatin1String("rpath") ) - m_rpath = reader->readElementText(QXmlStreamReader::SkipChildElements); - - else if( name == QLatin1String("filetype") ) - m_filetype = (Amarok::FileType)reader->readElementText(QXmlStreamReader::SkipChildElements).toInt(); - else if( name == QLatin1String("title") ) - m_title = reader->readElementText(QXmlStreamReader::SkipChildElements); - else if( name == QLatin1String("artist") ) - m_artist = reader->readElementText(QXmlStreamReader::SkipChildElements); - else if( name == QLatin1String("albumArtist") ) - m_albumArtist = reader->readElementText(QXmlStreamReader::SkipChildElements); - else if( name == QLatin1String("album") ) - m_album = reader->readElementText(); - else if( name == QLatin1String("compilation") ) - { - m_compilation = true; - reader->skipCurrentElement(); - } - else if( name == QLatin1String("noCompilation") ) - { - m_noCompilation = true; - reader->skipCurrentElement(); - } - else if( name == QLatin1String("hasCover") ) - { - m_hasCover = true; - reader->skipCurrentElement(); - } - else if( name == QLatin1String("comment") ) - m_comment = reader->readElementText(QXmlStreamReader::SkipChildElements); - else if( name == QLatin1String("genre") ) - m_genre = reader->readElementText(QXmlStreamReader::SkipChildElements); - else if( name == QLatin1String("year") ) - m_year = reader->readElementText(QXmlStreamReader::SkipChildElements).toInt(); - else if( name == QLatin1String("disc") ) - m_disc = reader->readElementText(QXmlStreamReader::SkipChildElements).toInt(); - else if( name == QLatin1String("track") ) - m_track = reader->readElementText(QXmlStreamReader::SkipChildElements).toInt(); - else if( name == QLatin1String("bpm") ) - m_bpm = reader->readElementText(QXmlStreamReader::SkipChildElements).toFloat(); - else if( name == QLatin1String("bitrate") ) - m_bitrate = reader->readElementText(QXmlStreamReader::SkipChildElements).toInt(); - else if( name == QLatin1String("length") ) - m_length = reader->readElementText(QXmlStreamReader::SkipChildElements).toLong(); - else if( name == QLatin1String("samplerate") ) - m_samplerate = reader->readElementText(QXmlStreamReader::SkipChildElements).toInt(); - else if( name == QLatin1String("filesize") ) - m_filesize = reader->readElementText(QXmlStreamReader::SkipChildElements).toLong(); - else if( name == QLatin1String("mtime") ) - m_modified = QDateTime::fromTime_t(reader->readElementText(QXmlStreamReader::SkipChildElements).toLong()); - - else if( name == QLatin1String("trackGain") ) - m_trackGain = reader->readElementText(QXmlStreamReader::SkipChildElements).toFloat(); - else if( name == QLatin1String("trackPeakGain") ) - m_trackPeakGain = reader->readElementText(QXmlStreamReader::SkipChildElements).toFloat(); - else if( name == QLatin1String("albumGain") ) - m_albumGain = reader->readElementText(QXmlStreamReader::SkipChildElements).toFloat(); - else if( name == QLatin1String("albumPeakGain") ) - m_albumPeakGain = reader->readElementText(QXmlStreamReader::SkipChildElements).toFloat(); - - else if( name == QLatin1String("composer") ) - m_composer = reader->readElementText(QXmlStreamReader::SkipChildElements); - - else if( name == QLatin1String("rating") ) - m_rating = reader->readElementText(QXmlStreamReader::SkipChildElements).toFloat(); - else if( name == QLatin1String("score") ) - m_score = reader->readElementText(QXmlStreamReader::SkipChildElements).toFloat(); - else if( name == QLatin1String("playcount") ) - m_playcount = reader->readElementText(QXmlStreamReader::SkipChildElements).toInt(); - - else - { - qDebug() << "Unexpected xml start element"<skipCurrentElement(); - } - } - - else if( reader->isEndElement() ) - { - break; - } - } -} - -void -CollectionScanner::Track::write( QXmlStreamWriter *writer, - const QString &tag, const QString &str ) const -{ - if( !str.isEmpty() ) - writer->writeTextElement( tag, escapeXml10(str) ); -} - - -void -CollectionScanner::Track::toXml( QXmlStreamWriter *writer ) const -{ - if( !m_valid ) - return; - - write( writer, QLatin1String("uniqueid"), m_uniqueid ); - write( writer, QLatin1String("path"), m_path ); - write( writer, QLatin1String("rpath"), m_rpath ); - - write(writer, QLatin1String("filetype"), QString::number( (int)m_filetype ) ); - - write( writer, QLatin1String("title"), m_title); - write( writer, QLatin1String("artist"), m_artist); - write( writer, QLatin1String("albumArtist"), m_albumArtist); - write( writer, QLatin1String("album"), m_album); - if( m_compilation ) - writer->writeEmptyElement( QLatin1String("compilation") ); - if( m_noCompilation ) - writer->writeEmptyElement( QLatin1String("noCompilation") ); - if( m_hasCover ) - writer->writeEmptyElement( QLatin1String("hasCover") ); - write( writer, QLatin1String("comment"), m_comment); - write( writer, QLatin1String("genre"), m_genre); - if( m_year != -1 ) - write(writer, QLatin1String("year"), QString::number( m_year ) ); - if( m_disc != -1 ) - write(writer, QLatin1String("disc"), QString::number( m_disc ) ); - if( m_track != -1 ) - write(writer, QLatin1String("track"), QString::number( m_track ) ); - if( m_bpm != -1 ) - write(writer, QLatin1String("bpm"), QString::number( m_bpm ) ); - if( m_bitrate != -1 ) - write(writer, QLatin1String("bitrate"), QString::number( m_bitrate ) ); - if( m_length != -1 ) - write(writer, QLatin1String("length"), QString::number( m_length ) ); - if( m_samplerate != -1 ) - write(writer, QLatin1String("samplerate"), QString::number( m_samplerate ) ); - if( m_filesize != -1 ) - write(writer, QLatin1String("filesize"), QString::number( m_filesize ) ); - if( m_modified.isValid() ) - write(writer, QLatin1String("mtime"), QString::number( m_modified.toTime_t() ) ); - - if( m_trackGain != 0 ) - write(writer, QLatin1String("trackGain"), QString::number( m_trackGain ) ); - if( m_trackPeakGain != 0 ) - write(writer, QLatin1String("trackPeakGain"), QString::number( m_trackPeakGain ) ); - if( m_albumGain != 0 ) - write(writer, QLatin1String("albumGain"), QString::number( m_albumGain ) ); - if( m_albumPeakGain != 0 ) - write(writer, QLatin1String("albumPeakGain"), QString::number( m_albumPeakGain ) ); - - write( writer, QLatin1String("composer"), m_composer); - - if( m_rating != -1 ) - write(writer, QLatin1String("rating"), QString::number( m_rating ) ); - if( m_score != -1 ) - write(writer, QLatin1String("score"), QString::number( m_score ) ); - if( m_playcount != -1 ) - write(writer, QLatin1String("playcount"), QString::number( m_playcount ) ); - -} - -bool -CollectionScanner::Track::isValid() const -{ - return m_valid; -} - -CollectionScanner::Directory* -CollectionScanner::Track::directory() const -{ - return m_directory; -} - -QString -CollectionScanner::Track::uniqueid() const -{ - return m_uniqueid; -} - -QString -CollectionScanner::Track::path() const -{ - return m_path; -} - -QString -CollectionScanner::Track::rpath() const -{ - return m_rpath; -} - -Amarok::FileType -CollectionScanner::Track::filetype() const -{ - return m_filetype; -} - -QString -CollectionScanner::Track::title() const -{ - return m_title; -} - -QString -CollectionScanner::Track::artist() const -{ - return m_artist; -} - -QString -CollectionScanner::Track::albumArtist() const -{ - return m_albumArtist; -} - -QString -CollectionScanner::Track::album() const -{ - return m_album; -} - -bool -CollectionScanner::Track::isCompilation() const -{ - return m_compilation; -} - -bool -CollectionScanner::Track::isNoCompilation() const -{ - return m_noCompilation; -} - - -bool -CollectionScanner::Track::hasCover() const -{ - return m_hasCover; -} - -QString -CollectionScanner::Track::comment() const -{ - return m_comment; -} - -QString -CollectionScanner::Track::genre() const -{ - return m_genre; -} - -int -CollectionScanner::Track::year() const -{ - return m_year; -} - -int -CollectionScanner::Track::disc() const -{ - return m_disc; -} - -int -CollectionScanner::Track::track() const -{ - return m_track; -} - -int -CollectionScanner::Track::bpm() const -{ - return m_bpm; -} - -int -CollectionScanner::Track::bitrate() const -{ - return m_bitrate; -} - -qint64 -CollectionScanner::Track::length() const -{ - return m_length; -} - -int -CollectionScanner::Track::samplerate() const -{ - return m_samplerate; -} - -qint64 -CollectionScanner::Track::filesize() const -{ - return m_filesize; -} - -QDateTime -CollectionScanner::Track::modified() const -{ - return m_modified; -} - - -QString -CollectionScanner::Track::composer() const -{ - return m_composer; -} - - -qreal -CollectionScanner::Track::replayGain( Meta::ReplayGainTag mode ) const -{ - switch( mode ) - { - case Meta::ReplayGain_Track_Gain: - return m_trackGain; - case Meta::ReplayGain_Track_Peak: - return m_trackPeakGain; - case Meta::ReplayGain_Album_Gain: - return m_albumGain; - case Meta::ReplayGain_Album_Peak: - return m_albumPeakGain; - } - return 0.0; -} - -qreal -CollectionScanner::Track::rating() const -{ - return m_rating; -} - -qreal -CollectionScanner::Track::score() const -{ - return m_score; -} - -int -CollectionScanner::Track::playcount() const -{ - return m_playcount; -} - -void -CollectionScanner::Track::setUseCharsetDetector( bool value ) -{ - s_useCharsetDetector = value; -} diff --git a/amarok/shared/collectionscanner/Track.h b/amarok/shared/collectionscanner/Track.h deleted file mode 100644 index 3cdc217d..00000000 --- a/amarok/shared/collectionscanner/Track.h +++ /dev/null @@ -1,161 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2010 Ralf Engels * - * * - * This program 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 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#ifndef COLLECTIONSCANNER_TRACK_H -#define COLLECTIONSCANNER_TRACK_H - -#include "FileType.h" -#include "MetaReplayGain.h" -#include "amarokshared_export.h" - -#include -#include - -#include - -namespace CollectionScanner -{ - -class Directory; - -/** - @class Track - @short Represents a scanned track - An empty QString or a negative int means that the value is unset. - */ -class AMAROKSHARED_EXPORT Track -{ -public: - /** Reads a track from the given path */ - Track( const QString &path, Directory* directory ); - - /** Tries to parse the track from the xml stream */ - Track( QXmlStreamReader *reader, Directory* directory ); - - /** Writes the contents of this object to an xml stream. - Only the content is writen and no enclosing directory tags. - This is done to make it mirror the constructor which does not read those - tags either. - */ - void toXml( QXmlStreamWriter *writer ) const; - - /** Returns true if this track is really a song. */ - bool isValid() const; - - /** Returns the directory this track was found in. */ - Directory* directory() const; - - QString uniqueid() const; - - /** The absolute path to the file. - Because of symbolic links the path could be outside the original scanning directories. - */ - QString path() const; - - /** Returns the relative path at the point of scanning */ - QString rpath() const; - - Amarok::FileType filetype() const; - QString title() const; - QString artist() const; - QString albumArtist() const; - QString album() const; - // if !isCompilation && !isNoCompilation then it's undefined - bool isCompilation() const; - bool isNoCompilation() const; - bool hasCover() const; - QString comment() const; - QString genre() const; - int year() const; - int disc() const; - int track() const; - int bpm() const; - int bitrate() const; - qint64 length() const; - int samplerate() const; - qint64 filesize() const; - QDateTime modified() const; - - QString composer() const; - - qreal replayGain( Meta::ReplayGainTag mode ) const; - - /** Rating is a value from 0.0 to 10.0 inclusive */ - qreal rating() const; - - /** Score is a value from 0.0 to 100.0 inclusive */ - qreal score() const; - - int playcount() const; - - /** Enable or disable the charset detector. - TODO: taglib should do that by itself. - */ - static void setUseCharsetDetector( bool value ); - -private: - Q_DISABLE_COPY(Track) - - void write( QXmlStreamWriter *writer, const QString &tag, const QString &str ) const; - bool m_valid; - - Directory* m_directory; - - QString m_uniqueid; - - QString m_path; - QString m_rpath; - - Amarok::FileType m_filetype; - QString m_title; - QString m_artist; - QString m_albumArtist; - QString m_album; - bool m_compilation; - bool m_noCompilation; - bool m_hasCover; - QString m_comment; - QString m_genre; - int m_year; - int m_disc; - int m_track; - qreal m_bpm; - int m_bitrate; - qint64 m_length; - int m_samplerate; - qint64 m_filesize; - QDateTime m_modified; - - qreal m_trackGain; - qreal m_trackPeakGain; - qreal m_albumGain; - qreal m_albumPeakGain; - - QString m_composer; - - qreal m_rating; - qreal m_score; - int m_playcount; - - static bool s_useCharsetDetector; -}; - -} - -#endif // COLLECTIONSCANNER_TRACK_H diff --git a/amarok/shared/collectionscanner/utils.h b/amarok/shared/collectionscanner/utils.h deleted file mode 100644 index e99b7d71..00000000 --- a/amarok/shared/collectionscanner/utils.h +++ /dev/null @@ -1,52 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2010 Ralf Engels * - * Copyright (C) 2012 Edward Toroshchin * - * * - * This program 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 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#ifndef COLLECTIONSCANNER_UTILS_H -#define COLLECTIONSCANNER_UTILS_H - -#include - -namespace CollectionScanner -{ - -/** Removes all characters not allowed by xml 1.0 specification. - We need this because the Qt 4.6 xml scanner is behaving very badly - when encountering such characters in the input. - ...and because Qt 4.whatever xml writer outputs such characters without - any remorse. - see http://en.wikipedia.org/wiki/Valid_Characters_in_XML - */ -inline QString -escapeXml10( QString str ) -{ - for( int i = 0; i < str.length(); ++i ) - { - ushort c = str.at(i).unicode(); - if( (c < 0x20 && c != 0x09 && c != 0x0A && c != 0x0D) || - (c > 0xD7FF && c < 0xE000) || - (c > 0xFFFD) ) - str[i] = '?'; - } - return str; -} - -} - -#endif // COLLECTIONSCANNER_UTILS_H diff --git a/amarok/shared/config.h.cmake b/amarok/shared/config.h.cmake deleted file mode 100644 index 5313384c..00000000 --- a/amarok/shared/config.h.cmake +++ /dev/null @@ -1,31 +0,0 @@ -/* config-amarok.h. Generated by cmake from config-amarok.h.cmake */ - -/* Whether TagLib::FileName is a struct supporting wide characters or just a typedef */ -#cmakedefine COMPLEX_TAGLIB_FILENAME 1 - -/* have TagLib-Extras */ -#cmakedefine TAGLIB_EXTRAS_FOUND 1 - -/* have module file format support in TagLib */ -#cmakedefine TAGLIB_MOD_FOUND 1 - -/* have opus file format support in TagLib */ -#cmakedefine TAGLIB_OPUS_FOUND 1 - -/* have QtCrypto the Qt crypto architecture */ -#cmakedefine QCA2_FOUND 1 - -/* have Qt bindings */ -#cmakedefine QTSCRIPTQTBINDINGS_FOUND 1 - -/* have QtOpenGL */ -#cmakedefine QT_QTOPENGL_FOUND 1 - -/* If liblastfm is found */ -#cmakedefine HAVE_LIBLASTFM 1 - -/* If libofa is found */ -#cmakedefine HAVE_LIBOFA 1 - -/* Whether cmake build type is debug */ -#cmakedefine DEBUG_BUILD_TYPE diff --git a/amarok/shared/tag_helpers/APETagHelper.cpp b/amarok/shared/tag_helpers/APETagHelper.cpp deleted file mode 100644 index eee34e05..00000000 --- a/amarok/shared/tag_helpers/APETagHelper.cpp +++ /dev/null @@ -1,116 +0,0 @@ -/**************************************************************************************** - * Copyright (C) 2003-2005 Max Howell * - * (C) 2003-2010 Mark Kretschmann * - * (C) 2005-2007 Alexandre Oliveira * - * (C) 2008 Dan Meltzer * - * (C) 2008-2009 Jeff Mitchell * - * (C) 2010 Ralf Engels * - * (c) 2010 Sergey Ivanov <123kash@gmail.com> * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "APETagHelper.h" - -#include "StringHelper.h" - -using namespace Meta::Tag; - -APETagHelper::APETagHelper( TagLib::Tag *tag, TagLib::APE::Tag *apeTag, Amarok::FileType fileType ) - : TagHelper( tag, fileType ) - , m_tag( apeTag ) -{ - m_fieldMap.insert( Meta::valAlbumArtist, TagLib::String( "ALBUM ARTIST" ) ); - m_fieldMap.insert( Meta::valBpm, TagLib::String( "BPM" ) ); - m_fieldMap.insert( Meta::valCompilation, TagLib::String( "COMPILATION" ) ); - m_fieldMap.insert( Meta::valComposer, TagLib::String( "Composer" ) ); - m_fieldMap.insert( Meta::valDiscNr, TagLib::String( "DISC" ) ); - m_fieldMap.insert( Meta::valPlaycount, TagLib::String( "FMPS_PLAYCOUNT" ) ); - m_fieldMap.insert( Meta::valRating, TagLib::String( "FMPS_RATING" ) ); - m_fieldMap.insert( Meta::valScore, TagLib::String( "FMPS_RATING_AMAROK_SCORE" ) ); - m_fieldMap.insert( Meta::valLyrics, TagLib::String( "UNSYNCED LYRICS" ) ); - - m_uidFieldMap.insert( UIDAFT, TagLib::String( "Amarok 2 AFTv1 - amarok.kde.org" ) ); -} - -Meta::FieldHash -APETagHelper::tags() const -{ - Meta::FieldHash data = TagHelper::tags(); - - TagLib::APE::ItemListMap map = m_tag->itemListMap(); - for( TagLib::APE::ItemListMap::ConstIterator it = map.begin(); it != map.end(); ++it ) - { - qint64 field; - QString value = TStringToQString( it->second.toString() ); - if( ( field = fieldName( it->first ) ) ) - { - if( field == Meta::valRating ) - data.insert( field, qRound( value.toFloat() * 10.0 ) ); - else if( field == Meta::valScore ) - data.insert( field, value.toFloat() * 100.0 ); - else if( field == Meta::valDiscNr ) { - int disc; - disc = splitDiscNr( value ).first; - data.insert( field, disc ); - } - else - data.insert( field, value ); - } - else if( it->first == uidFieldName( UIDAFT ) && isValidUID( value, UIDAFT ) ) - data.insert( Meta::valUniqueId, value ); - } - - return data; -} - -bool -APETagHelper::setTags( const Meta::FieldHash &changes ) -{ - bool modified = TagHelper::setTags( changes ); - - foreach( const qint64 key, changes.keys() ) - { - QVariant value = changes.value( key ); - TagLib::String field = fieldName( key ); - - if( !field.isNull() && !field.isEmpty() ) - { - if( key == Meta::valRating ) - m_tag->addValue( field, Qt4QStringToTString( QString::number( value.toFloat() / 10.0 ) ) ); - else if( key == Meta::valScore ) - m_tag->addValue( field, Qt4QStringToTString( QString::number( value.toFloat() / 100.0 ) ) ); - else - m_tag->addValue( field, Qt4QStringToTString( value.toString() ) ); - - modified = true; - } - else if( key == Meta::valUniqueId ) - { - QPair < UIDType, QString > uidPair = splitUID( value.toString() ); - if( uidPair.first == UIDInvalid ) - continue; - - m_tag->addValue( uidFieldName( uidPair.first ), Qt4QStringToTString( uidPair.second ) ); - modified = true; - } - } - - return modified; -} - -TagLib::ByteVector -APETagHelper::render() const -{ - return m_tag->render(); -} diff --git a/amarok/shared/tag_helpers/APETagHelper.h b/amarok/shared/tag_helpers/APETagHelper.h deleted file mode 100644 index 0147a7a7..00000000 --- a/amarok/shared/tag_helpers/APETagHelper.h +++ /dev/null @@ -1,44 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Sergey Ivanov <123kash@gmail.com> * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef APETAGHELPER_H -#define APETAGHELPER_H - -#include "TagHelper.h" - -#include - -namespace Meta -{ - namespace Tag - { - class AMAROKSHARED_EXPORT APETagHelper : public TagHelper - { - public: - APETagHelper( TagLib::Tag *tag, TagLib::APE::Tag *apeTag, Amarok::FileType fileType ); - - virtual Meta::FieldHash tags() const; - virtual bool setTags( const Meta::FieldHash &changes ); - - virtual TagLib::ByteVector render() const; - - private: - TagLib::APE::Tag *m_tag; - }; - } -} - -#endif // APETAGHELPER_H diff --git a/amarok/shared/tag_helpers/ASFTagHelper.cpp b/amarok/shared/tag_helpers/ASFTagHelper.cpp deleted file mode 100644 index b4b2273c..00000000 --- a/amarok/shared/tag_helpers/ASFTagHelper.cpp +++ /dev/null @@ -1,253 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Sergey Ivanov <123kash@gmail.com> * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - - -#include "ASFTagHelper.h" - -#include "StringHelper.h" - -#include -#include - -#include - -using namespace Meta::Tag; - -ASFTagHelper::ASFTagHelper( TagLib::Tag *tag, TagLib::ASF::Tag *asfTag, Amarok::FileType fileType ) - : TagHelper( tag, fileType ) - , m_tag( asfTag ) -{ - m_fieldMap.insert( Meta::valAlbumArtist, TagLib::String( "WM/AlbumArtist" ) ); - m_fieldMap.insert( Meta::valBpm, TagLib::String( "WM/BeatsPerMinute" ) ); - m_fieldMap.insert( Meta::valCompilation, TagLib::String( "Amarok/Compilation" ) ); //Not standatd tag - m_fieldMap.insert( Meta::valComposer, TagLib::String( "WM/Composer" ) ); - m_fieldMap.insert( Meta::valDiscNr, TagLib::String( "WM/PartOfSet" ) ); - m_fieldMap.insert( Meta::valHasCover, TagLib::String( "WM/Picture" ) ); - m_fieldMap.insert( Meta::valPlaycount, TagLib::String( "FMPS/Playcount" ) ); - m_fieldMap.insert( Meta::valRating, TagLib::String( "FMPS/Rating" ) ); - m_fieldMap.insert( Meta::valScore, TagLib::String( "FMPS/Rating_Amarok_Score" ) ); - m_fieldMap.insert( Meta::valLyrics, TagLib::String( "WM/Lyrics" ) ); - - m_uidFieldMap.insert( UIDAFT, TagLib::String( "Amarok/AFTv1" ) ); -} - -Meta::FieldHash -ASFTagHelper::tags() const -{ - Meta::FieldHash data = TagHelper::tags(); - - TagLib::ASF::AttributeListMap map = m_tag->attributeListMap(); - for( TagLib::ASF::AttributeListMap::ConstIterator it = map.begin(); it != map.end(); ++it ) - { - if( !it->second.size() ) - continue; - - qint64 field; - TagLib::ASF::Attribute value = it->second[0]; - QString strValue = TStringToQString( value.toString() ); - if( ( field = fieldName( it->first ) ) ) - { - if( field == Meta::valBpm || field == Meta::valPlaycount ) - data.insert( field, value.toUInt() ); - else if( field == Meta::valRating ) - data.insert( field, qRound( strValue.toFloat() * 10.0 ) ); - else if( field == Meta::valScore ) - data.insert( field, strValue.toFloat() * 100.0 ); - else if( field == Meta::valDiscNr ) - data.insert( field, value.toUInt() ); - else if( field == Meta::valCompilation ) - data.insert( field, value.toBool() ); - else if( field == Meta::valHasCover ) - { - for( TagLib::ASF::AttributeList::ConstIterator cover = it->second.begin(); cover != it->second.end(); ++cover ) - { - if( cover->type() != TagLib::ASF::Attribute::BytesType ) - continue; - - TagLib::ASF::Picture pict = cover->toPicture(); - if( ( pict.type() == TagLib::ASF::Picture::FrontCover || - pict.type() == TagLib::ASF::Picture::Other ) && - pict.dataSize() > MIN_COVER_SIZE ) - { - data.insert( field, true ); - break; - } - } - } - else - data.insert( field, strValue ); - } - else if( it->first == uidFieldName( UIDAFT ) && isValidUID( strValue, UIDAFT ) ) - data.insert( Meta::valUniqueId, strValue ); - } - - return data; -} - -bool -ASFTagHelper::setTags( const Meta::FieldHash &changes ) -{ - bool modified = TagHelper::setTags( changes ); - - foreach( const qint64 key, changes.keys() ) - { - QVariant value = changes.value( key ); - TagLib::String field = fieldName( key ); - - if( !field.isNull() && !field.isEmpty() ) - { - if( key == Meta::valHasCover ) - continue; - // http://gitorious.org/~jefferai/xdg-specs/jefferais-xdg-specs/blobs/mediaspecs/specifications/FMPSpecs/specification.txt sais that mp4 tags should be saved as strings - if( key == Meta::valHasCover ) - continue; - else if( key == Meta::valRating ) - m_tag->setAttribute( field, TagLib::ASF::Attribute( Qt4QStringToTString( QString::number( value.toFloat() / 10.0 ) ) ) ); - else if( key == Meta::valScore ) - m_tag->setAttribute( field, TagLib::ASF::Attribute( Qt4QStringToTString( QString::number( value.toFloat() / 100.0 ) ) ) ); - else if( key == Meta::valBpm || key == Meta::valDiscNr ) - m_tag->setAttribute( field, TagLib::ASF::Attribute( value.toUInt() ) ); - else if( key == Meta::valCompilation ) - m_tag->setAttribute( field, TagLib::ASF::Attribute( value.toBool() ) ); - else - m_tag->setAttribute( field, TagLib::ASF::Attribute( Qt4QStringToTString( value.toString() ) ) ); - - modified = true; - } - else if( key == Meta::valUniqueId ) - { - QPair < UIDType, QString > uidPair = splitUID( value.toString() ); - if( uidPair.first == UIDInvalid ) - continue; - - m_tag->setAttribute( uidFieldName( uidPair.first ), - TagLib::ASF::Attribute( Qt4QStringToTString( uidPair.second ) ) ); - modified = true; - } - } - - return modified; -} - -bool -ASFTagHelper::hasEmbeddedCover() const -{ - TagLib::ASF::AttributeListMap map = m_tag->attributeListMap(); - TagLib::String name = fieldName( Meta::valHasCover ); - for( TagLib::ASF::AttributeListMap::ConstIterator it = map.begin(); it != map.end(); ++it ) - { - if( it->first == name ) - { - TagLib::ASF::AttributeList coverList = it->second; - for( TagLib::ASF::AttributeList::ConstIterator cover = coverList.begin(); cover != coverList.end(); ++cover ) - { - if( cover->type() != TagLib::ASF::Attribute::BytesType ) - continue; - - TagLib::ASF::Picture pict = cover->toPicture(); - if( ( pict.type() == TagLib::ASF::Picture::FrontCover || - pict.type() == TagLib::ASF::Picture::Other ) && - pict.dataSize() > MIN_COVER_SIZE ) - { - return true; - } - } - } - } - - return false; -} - -QImage -ASFTagHelper::embeddedCover() const -{ - TagLib::ASF::AttributeListMap map = m_tag->attributeListMap(); - TagLib::String name = fieldName( Meta::valHasCover ); - - TagLib::ASF::Picture cover, otherCover; - bool hasCover = false, hasOtherCover = false; - - for( TagLib::ASF::AttributeListMap::ConstIterator it = map.begin(); it != map.end(); ++it ) - { - if( it->first == name ) - { - TagLib::ASF::AttributeList coverList = it->second; - for( TagLib::ASF::AttributeList::ConstIterator it = coverList.begin(); it != coverList.end(); ++it ) - { - if( it->type() != TagLib::ASF::Attribute::BytesType ) - continue; - - TagLib::ASF::Picture pict = it->toPicture(); - - if( pict.dataSize() < MIN_COVER_SIZE ) - continue; - - if( pict.type() == TagLib::ASF::Picture::FrontCover ) - { - cover = pict; - hasCover = true; - } - else if( pict.type() == TagLib::ASF::Picture::Other ) - { - otherCover = pict; - hasOtherCover = true; - } - } - } - } - - if( !hasCover && hasOtherCover ) - { - cover = otherCover; - hasCover = true; - } - - if( !hasCover ) - return QImage(); - - return QImage::fromData( ( uchar * ) cover.picture().data(), cover.picture().size() ); -} - -bool -ASFTagHelper::setEmbeddedCover( const QImage &cover ) -{ - QByteArray bytes; - QBuffer buffer( &bytes ); - - buffer.open( QIODevice::WriteOnly ); - - if( !cover.save( &buffer, "JPEG" ) ) - { - buffer.close(); - return false; - } - - buffer.close(); - - TagLib::String name = fieldName( Meta::valHasCover ); - - // remove all covers - m_tag->removeItem( name ); - - // add new cover - TagLib::ASF::Picture picture; - picture.setPicture( TagLib::ByteVector( bytes.data(), bytes.count() ) ); - picture.setType( TagLib::ASF::Picture::FrontCover ); - picture.setMimeType( "image/jpeg" ); - m_tag->addAttribute( name, TagLib::ASF::Attribute( picture.render() ) ); - - return true; -} diff --git a/amarok/shared/tag_helpers/ASFTagHelper.h b/amarok/shared/tag_helpers/ASFTagHelper.h deleted file mode 100644 index db6afaa9..00000000 --- a/amarok/shared/tag_helpers/ASFTagHelper.h +++ /dev/null @@ -1,47 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Sergey Ivanov <123kash@gmail.com> * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - - -#ifndef ASFTAGHELPER_H -#define ASFTAGHELPER_H - -#include "TagHelper.h" - -#include - -namespace Meta -{ - namespace Tag - { - class AMAROKSHARED_EXPORT ASFTagHelper : public TagHelper - { - public: - ASFTagHelper( TagLib::Tag *tag, TagLib::ASF::Tag *asfTag, Amarok::FileType fileType ); - - virtual Meta::FieldHash tags() const; - virtual bool setTags( const Meta::FieldHash &changes ); - - virtual bool hasEmbeddedCover() const; - virtual QImage embeddedCover() const; - virtual bool setEmbeddedCover(const QImage &cover); - - private: - TagLib::ASF::Tag *m_tag; - }; - } -} - -#endif // ASFTAGHELPER_H diff --git a/amarok/shared/tag_helpers/ID3v2TagHelper.cpp b/amarok/shared/tag_helpers/ID3v2TagHelper.cpp deleted file mode 100644 index 1b5a0716..00000000 --- a/amarok/shared/tag_helpers/ID3v2TagHelper.cpp +++ /dev/null @@ -1,443 +0,0 @@ -/**************************************************************************************** - * Copyright (C) 2003-2005 Max Howell * - * (C) 2003-2010 Mark Kretschmann * - * (C) 2005-2007 Alexandre Oliveira * - * (C) 2008 Dan Meltzer * - * (C) 2008-2009 Jeff Mitchell * - * (C) 2010 Ralf Engels * - * (c) 2010 Sergey Ivanov <123kash@gmail.com> * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "ID3v2TagHelper.h" - -#include "StringHelper.h" - -#include -#include - -#include -#include -#include -#include -#include - -const TagLib::ByteVector TXXX_Frame = "TXXX"; -const TagLib::ByteVector POPM_Frame = "POPM"; - -using namespace Meta::Tag; - -ID3v2TagHelper::ID3v2TagHelper( TagLib::Tag *tag, TagLib::ID3v2::Tag *id3v2Tag, Amarok::FileType fileType ) - : TagHelper( tag, fileType ) - , m_tag( id3v2Tag ) -{ - m_fieldMap.insert( Meta::valAlbumArtist, TagLib::String( "TPE2" ) ); - m_fieldMap.insert( Meta::valBpm, TagLib::String( "TBPM" ) ); - m_fieldMap.insert( Meta::valCompilation, TagLib::String( "TCMP" ) ); - m_fieldMap.insert( Meta::valComposer, TagLib::String( "TCOM" ) ); - m_fieldMap.insert( Meta::valDiscNr, TagLib::String( "TPOS" ) ); - m_fieldMap.insert( Meta::valHasCover, TagLib::String( "APIC" ) ); - m_fieldMap.insert( Meta::valUniqueId, TagLib::String( "UFID" ) ); - - m_fieldMap.insert( Meta::valLyrics, TagLib::String( "USLT" ) ); - - m_fmpsFieldMap.insert( FMPSPlayCount, TagLib::String( "FMPS_Playcount" ) ); - m_fmpsFieldMap.insert( FMPSRating, TagLib::String( "FMPS_Rating" ) ); - m_fmpsFieldMap.insert( FMPSScore, TagLib::String( "FMPS_Rating_Amarok_Score" ) ); - - m_uidFieldMap.insert( UIDAFT, TagLib::String( "Amarok 2 AFTv1 - amarok.kde.org" ) ); -} - -Meta::FieldHash -ID3v2TagHelper::tags() const -{ - Meta::FieldHash data = TagHelper::tags(); - - TagLib::ID3v2::FrameList list = m_tag->frameList(); - for( TagLib::ID3v2::FrameList::ConstIterator it = list.begin(); it != list.end(); ++it ) - { - qint64 field; - TagLib::String frameName = TagLib::String( ( *it )->frameID() ); - if( ( field = fieldName( frameName ) ) ) - { - if( field == Meta::valUniqueId ) - { - TagLib::ID3v2::UniqueFileIdentifierFrame *frame = - dynamic_cast< TagLib::ID3v2::UniqueFileIdentifierFrame * >( *it ); - - if( !frame ) - continue; - - QString identifier = TStringToQString( TagLib::String( frame->identifier() ) ); - - if( identifier.isEmpty() ) - continue; - - if( frame->owner() == uidFieldName( UIDAFT ) && isValidUID( identifier, UIDAFT ) ) - data.insert( Meta::valUniqueId, identifier ); - continue; - } - else if( field == Meta::valHasCover ) - { - TagLib::ID3v2::AttachedPictureFrame *frame = - dynamic_cast< TagLib::ID3v2::AttachedPictureFrame * >( *it ); - - if( !frame ) - continue; - - if( ( frame->type() == TagLib::ID3v2::AttachedPictureFrame::FrontCover || - frame->type() == TagLib::ID3v2::AttachedPictureFrame::Other ) && - frame->picture().size() > MIN_COVER_SIZE ) // must be at least 1kb - { - data.insert( Meta::valHasCover, true ); - } - continue; - } - else if( field == Meta::valLyrics ) - { - TagLib::ID3v2::UnsynchronizedLyricsFrame *lyricsFrame = - dynamic_cast( *it ); - if( lyricsFrame && !data.contains( Meta::valLyrics ) ) // only read the first frame for valLyrics - data.insert( Meta::valLyrics, TStringToQString( lyricsFrame->text() ) ); - continue; - } - - TagLib::ID3v2::TextIdentificationFrame *frame = - dynamic_cast< TagLib::ID3v2::TextIdentificationFrame * >( *it ); - - if( !frame ) - continue; - - QString value = TStringToQString( frame->fieldList().toString( '\n' ) ); - - if( field == Meta::valDiscNr ) - { - int disc; - if( ( disc = splitDiscNr( value ).first ) ) - data.insert( field, disc ); - } - else if( field == Meta::valBpm ) - data.insert( field, value.toFloat() ); - else - data.insert( field, value ); - } - else if( frameName == POPM_Frame ) - { - TagLib::ID3v2::PopularimeterFrame *frame = - dynamic_cast< TagLib::ID3v2::PopularimeterFrame * >( *it ); - - if( !frame ) - continue; - - if( TStringToQString( frame->email() ).isEmpty() ) // only read anonymous ratings - { - // FMPS tags have precedence - if( !data.contains( Meta::valRating ) && frame->rating() != 0 ) - data.insert( Meta::valRating, qRound( frame->rating() / 256.0 * 10.0 ) ); - if( !data.contains( Meta::valPlaycount ) && frame->counter() < 10000 ) - data.insert( Meta::valPlaycount, frame->counter() ); - } - } - else if( frameName == TXXX_Frame ) - { - TagLib::ID3v2::UserTextIdentificationFrame *frame = - dynamic_cast< TagLib::ID3v2::UserTextIdentificationFrame * >( *it ); - - if( !frame ) - continue; - - // the value of the user text frame is stored in the - // second and following fields. - TagLib::StringList fields = frame->fieldList(); - if( fields.size() >= 2 ) - { - QString value = TStringToQString( fields[1] ); - - if( fields[0] == fmpsFieldName( FMPSRating ) ) - data.insert( Meta::valRating, qRound( value.toFloat() * 10.0 ) ); - else if( fields[0] == fmpsFieldName( FMPSScore ) ) - data.insert( Meta::valScore, value.toFloat() * 100.0 ); - else if( fields[0] == fmpsFieldName( FMPSPlayCount ) ) - data.insert( Meta::valPlaycount, value.toFloat() ); - } - } - } - - return data; -} - -bool -ID3v2TagHelper::setTags( const Meta::FieldHash &changes ) -{ - bool modified = TagHelper::setTags( changes ); - - foreach( const qint64 key, changes.keys() ) - { - QVariant value = changes.value( key ); - TagLib::ByteVector field( fieldName( key ).toCString() ); - - if( !field.isNull() && !field.isEmpty() ) - { - if( key == Meta::valHasCover ) - continue; - else if( key == Meta::valUniqueId ) - { - QPair< UIDType, QString > uidPair = splitUID( value.toString() ); - if( uidPair.first == UIDInvalid ) - continue; - - TagLib::String owner = uidFieldName( uidPair.first ); - TagLib::ByteVector uid( uidPair.second.toAscii().data() ); - TagLib::ID3v2::FrameList list = m_tag->frameList(); - - for( TagLib::ID3v2::FrameList::ConstIterator it = list.begin(); it != list.end(); ++it ) - { - if( ( *it )->frameID() == field ) - { - TagLib::ID3v2::UniqueFileIdentifierFrame *frame = - dynamic_cast< TagLib::ID3v2::UniqueFileIdentifierFrame * >( *it ); - if( !frame ) - continue; - - if( frame->owner() == owner ) - { - m_tag->removeFrame( frame ); - modified = true; - break; - } - } - } - - if ( !uid.isEmpty() ) - { - m_tag->addFrame( new TagLib::ID3v2::UniqueFileIdentifierFrame( owner, uid ) ); - modified = true; - } - continue; - } - else if( key == Meta::valLyrics ) - { - if( !m_tag->frameList( field ).isEmpty() ) - { - m_tag->removeFrames( field ); - modified = true; - } - QString lyrics = changes.value( key ).toString(); - if( lyrics.isEmpty() ) - continue; - TagLib::ID3v2::UnsynchronizedLyricsFrame *frame = new TagLib::ID3v2::UnsynchronizedLyricsFrame( TagLib::String::UTF8 ); - frame->setText( Qt4QStringToTString( lyrics ) ); - m_tag->addFrame( frame ); - modified = true; - continue; - } - - TagLib::String tValue = Qt4QStringToTString( ( key == Meta::valCompilation ) - ? QString::number( value.toInt() ) - : value.toString() ); - if( tValue.isEmpty() ) - m_tag->removeFrames( field ); - else - { - TagLib::ID3v2::TextIdentificationFrame *frame = NULL; - if( !m_tag->frameListMap()[field].isEmpty() ) - frame = dynamic_cast< TagLib::ID3v2::TextIdentificationFrame * >( - m_tag->frameListMap()[field].front() - ); - if( !frame ) - { - frame = new TagLib::ID3v2::TextIdentificationFrame( field ); - m_tag->addFrame( frame ); - } - // note: TagLib is smart enough to automatically set UTF8 encoding if needed. - frame->setText( tValue ); - } - modified = true; - } - else if( key == Meta::valScore || key == Meta::valRating || key == Meta::valPlaycount ) - { - TagLib::String description; - TagLib::String tValue; - - if( key == Meta::valRating ) - { - description = fmpsFieldName( FMPSRating ); - tValue = Qt4QStringToTString( QString::number( value.toFloat() / 10.0 ) ); - } - else if( key == Meta::valScore ) - { - description = fmpsFieldName( FMPSScore ); - tValue = Qt4QStringToTString( QString::number( value.toFloat() / 100.0 ) ); - } - else if( key == Meta::valPlaycount ) - { - description = fmpsFieldName( FMPSPlayCount ); - tValue = Qt4QStringToTString( QString::number( value.toInt() ) ); - } - - if( key == Meta::valRating || key == Meta::valPlaycount ) - { - TagLib::ID3v2::PopularimeterFrame *popFrame = NULL; - if( !m_tag->frameListMap()[POPM_Frame].isEmpty() ) - popFrame = dynamic_cast< TagLib::ID3v2::PopularimeterFrame * >( m_tag->frameListMap()[POPM_Frame].front() ); - - if( !popFrame ) - { - popFrame = new TagLib::ID3v2::PopularimeterFrame( POPM_Frame ); - m_tag->addFrame( popFrame ); - } - - if( key == Meta::valRating ) - popFrame->setRating( qBound(0, int(qRound(value.toDouble() / 10.0 * 256)), 255) ); - else - popFrame->setCounter( value.toInt() ); - - modified = true; - } - - TagLib::ID3v2::FrameList list = m_tag->frameList(); - for( TagLib::ID3v2::FrameList::ConstIterator it = list.begin(); it != list.end(); ++it ) - { - if( ( *it )->frameID() == TXXX_Frame ) - { - TagLib::ID3v2::UserTextIdentificationFrame *frame = - dynamic_cast< TagLib::ID3v2::UserTextIdentificationFrame * >( *it ); - if( !frame ) - continue; - - if( frame->description() == description ) - { - m_tag->removeFrame( frame ); - modified = true; - break; - } - } - } - - if( value.toBool() ) - { - TagLib::ID3v2::UserTextIdentificationFrame *frame = - new TagLib::ID3v2::UserTextIdentificationFrame( TXXX_Frame ); - - frame->setDescription( description ); - frame->setText( tValue ); - m_tag->addFrame( frame ); - modified = true; - } - } - } - - return modified; -} - -TagLib::ByteVector -ID3v2TagHelper::render() const -{ - return m_tag->render(); -} - -bool -ID3v2TagHelper::hasEmbeddedCover() const -{ - TagLib::ID3v2::FrameList apicList = m_tag->frameListMap()[fieldName( Meta::valHasCover ).toCString()]; - - for( TagLib::ID3v2::FrameList::ConstIterator it = apicList.begin(); it != apicList.end(); ++it ) - { - TagLib::ID3v2::AttachedPictureFrame *currFrame = - dynamic_cast< TagLib::ID3v2::AttachedPictureFrame * >( *it ); - - if( currFrame->picture().size() < MIN_COVER_SIZE ) - continue; - - if( currFrame->type() == TagLib::ID3v2::AttachedPictureFrame::FrontCover || - currFrame->type() == TagLib::ID3v2::AttachedPictureFrame::Other ) - return true; - } - - return false; -} - -QImage -ID3v2TagHelper::embeddedCover() const -{ - TagLib::ID3v2::FrameList apicList = m_tag->frameListMap()[fieldName( Meta::valHasCover ).toCString()]; - TagLib::ID3v2::AttachedPictureFrame *cover = NULL; - TagLib::ID3v2::AttachedPictureFrame *otherCover = NULL; - - for( TagLib::ID3v2::FrameList::ConstIterator it = apicList.begin(); it != apicList.end(); ++it ) - { - TagLib::ID3v2::AttachedPictureFrame *currFrame = - dynamic_cast< TagLib::ID3v2::AttachedPictureFrame * >( *it ); - - if( currFrame->picture().size() < MIN_COVER_SIZE ) - continue; - - if( currFrame->type() == TagLib::ID3v2::AttachedPictureFrame::FrontCover ) - { - cover = currFrame; - } - else if( currFrame->type() == TagLib::ID3v2::AttachedPictureFrame::Other ) - { - otherCover = currFrame; - } - } - - if( !cover && otherCover ) - cover = otherCover; - - if( !cover ) - return QImage(); - - return QImage::fromData( ( uchar * )( cover->picture().data() ), cover->picture().size() ); -} - -bool -ID3v2TagHelper::setEmbeddedCover( const QImage &cover ) -{ - QByteArray bytes; - QBuffer buffer( &bytes ); - - buffer.open( QIODevice::WriteOnly ); - - if( !cover.save( &buffer, "JPEG" ) ) - { - buffer.close(); - return false; - } - - buffer.close(); - - TagLib::ByteVector field = fieldName( Meta::valHasCover ).toCString(); - TagLib::ID3v2::FrameList apicList = m_tag->frameListMap()[field]; - TagLib::ID3v2::AttachedPictureFrame *frontCover = NULL; - - // remove covers - TagLib::List backedUpPictures; - for( TagLib::ID3v2::FrameList::ConstIterator it = apicList.begin(); it != apicList.end(); ++it ) - { - TagLib::ID3v2::AttachedPictureFrame *currFrame = - dynamic_cast< TagLib::ID3v2::AttachedPictureFrame * >( *it ); - - m_tag->removeFrame( currFrame, false ); - } - - // add new cover - frontCover = new TagLib::ID3v2::AttachedPictureFrame( field ); - frontCover->setMimeType( "image/jpeg" ); - frontCover->setPicture( TagLib::ByteVector( bytes.data(), bytes.count() ) ); - frontCover->setType( TagLib::ID3v2::AttachedPictureFrame::FrontCover ); - m_tag->addFrame( frontCover ); - - return true; -} diff --git a/amarok/shared/tag_helpers/ID3v2TagHelper.h b/amarok/shared/tag_helpers/ID3v2TagHelper.h deleted file mode 100644 index a9c9ab9d..00000000 --- a/amarok/shared/tag_helpers/ID3v2TagHelper.h +++ /dev/null @@ -1,48 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Sergey Ivanov <123kash@gmail.com> * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef ID3V2TAGHELPER_H -#define ID3V2TAGHELPER_H - -#include "TagHelper.h" - -#include - -namespace Meta -{ - namespace Tag - { - class AMAROKSHARED_EXPORT ID3v2TagHelper : public TagHelper - { - public: - ID3v2TagHelper( TagLib::Tag *tag, TagLib::ID3v2::Tag *id3v2Tag, Amarok::FileType fileType ); - - virtual Meta::FieldHash tags() const; - virtual bool setTags( const Meta::FieldHash &changes ); - - virtual TagLib::ByteVector render() const; - - virtual bool hasEmbeddedCover() const; - virtual QImage embeddedCover() const; - virtual bool setEmbeddedCover( const QImage &cover ); - - private: - TagLib::ID3v2::Tag *m_tag; - }; - } -} - -#endif // ID3V2TAGHELPER_H diff --git a/amarok/shared/tag_helpers/MP4TagHelper.cpp b/amarok/shared/tag_helpers/MP4TagHelper.cpp deleted file mode 100644 index 7a28b447..00000000 --- a/amarok/shared/tag_helpers/MP4TagHelper.cpp +++ /dev/null @@ -1,206 +0,0 @@ -/**************************************************************************************** - * Copyright (C) 2003-2005 Max Howell * - * (C) 2003-2010 Mark Kretschmann * - * (C) 2005-2007 Alexandre Oliveira * - * (C) 2008 Dan Meltzer * - * (C) 2008-2009 Jeff Mitchell * - * (C) 2010 Ralf Engels * - * (c) 2010 Sergey Ivanov <123kash@gmail.com> * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - - -#include "MP4TagHelper.h" - -#include "StringHelper.h" - -#include -#include - -using namespace Meta::Tag; - -MP4TagHelper::MP4TagHelper( TagLib::Tag *tag, TagLib::MP4::Tag *mp4Tag, Amarok::FileType fileType ) - : TagHelper( tag, fileType ) - , m_tag( mp4Tag ) -{ - m_fieldMap.insert( Meta::valAlbumArtist, TagLib::String( "aART" ) ); - m_fieldMap.insert( Meta::valBpm, TagLib::String( "tmpo" ) ); - m_fieldMap.insert( Meta::valCompilation, TagLib::String( "cpil" ) ); - m_fieldMap.insert( Meta::valComposer, TagLib::String( "\xA9wrt" ) ); - m_fieldMap.insert( Meta::valDiscNr, TagLib::String( "disk" ) ); - m_fieldMap.insert( Meta::valHasCover, TagLib::String( "covr" ) ); - m_fieldMap.insert( Meta::valPlaycount, TagLib::String( "----:com.apple.iTunes:FMPS_Playcount" ) ); - m_fieldMap.insert( Meta::valRating, TagLib::String( "----:com.apple.iTunes:FMPS_Rating" ) ); - m_fieldMap.insert( Meta::valScore, TagLib::String( "----:com.apple.iTunes:FMPS_Rating_Amarok_Score" ) ); - m_fieldMap.insert( Meta::valLyrics, TagLib::String( "\xa9lyr" ) ); - - m_uidFieldMap.insert( UIDAFT, TagLib::String( "----:com.apple.iTunes:Amarok 2 AFTv1 - amarok.kde.org" ) ); -} - -Meta::FieldHash -MP4TagHelper::tags() const -{ - Meta::FieldHash data = TagHelper::tags(); - - TagLib::MP4::ItemListMap map = m_tag->itemListMap(); - for( TagLib::MP4::ItemListMap::ConstIterator it = map.begin(); it != map.end(); ++it ) - { - qint64 field; - QString value = TStringToQString( it->second.toStringList().toString( '\n' ) ); - if( ( field = fieldName( it->first ) ) ) - { - if( field == Meta::valHasCover ) - { - TagLib::MP4::CoverArtList coverList = it->second.toCoverArtList(); - for( TagLib::MP4::CoverArtList::ConstIterator it = coverList.begin(); it != coverList.end(); ++it ) - if( it->data().size() > MIN_COVER_SIZE ) - { - data.insert( field, true ); - break; - } - } - - // http://gitorious.org/~jefferai/xdg-specs/jefferais-xdg-specs/blobs/mediaspecs/specifications/FMPSpecs/specification.txt sais that mp4 tags should be saved as strings - else if( field == Meta::valPlaycount ) - data.insert( field, value.toInt() ); - else if( field == Meta::valRating ) - data.insert( field, qRound( value.toFloat() * 10.0 ) ); - else if( field == Meta::valScore ) - data.insert( field, value.toFloat() * 100.0 ); - - else if( field == Meta::valBpm ) - data.insert( field, it->second.toInt() ); - else if( field == Meta::valDiscNr ) - data.insert( field, it->second.toIntPair().first ); - - else if( field == Meta::valCompilation ) - data.insert( field, it->second.toBool() ); - else - data.insert( field, value ); - } - else if( it->first == uidFieldName( UIDAFT ) && isValidUID( value, UIDAFT ) ) - data.insert( Meta::valUniqueId, value ); - } - - return data; -} - -bool -MP4TagHelper::setTags( const Meta::FieldHash &changes ) -{ - bool modified = TagHelper::setTags( changes ); - - foreach( const qint64 key, changes.keys() ) - { - QVariant value = changes.value( key ); - TagLib::String field = fieldName( key ); - - if( !field.isNull() && !field.isEmpty() ) - { - // http://gitorious.org/~jefferai/xdg-specs/jefferais-xdg-specs/blobs/mediaspecs/specifications/FMPSpecs/specification.txt sais that mp4 tags should be saved as strings - if( key == Meta::valHasCover ) - continue; - else if( key == Meta::valRating ) - m_tag->itemListMap()[field] = TagLib::StringList( Qt4QStringToTString( QString::number( value.toFloat() / 10.0 ) ) ); - else if( key == Meta::valScore ) - m_tag->itemListMap()[field] = TagLib::StringList( Qt4QStringToTString( QString::number( value.toFloat() / 100.0 ) ) ); - else if( key == Meta::valBpm || key == Meta::valDiscNr ) - m_tag->itemListMap()[field] = TagLib::MP4::Item( value.toInt(), 0 ); - else if( key == Meta::valCompilation ) - m_tag->itemListMap()[field] = TagLib::MP4::Item( value.toBool() ); - else - m_tag->itemListMap()[field] = TagLib::StringList( Qt4QStringToTString( value.toString() ) ); - - modified = true; - } - else if( key == Meta::valUniqueId ) - { - QPair < UIDType, QString > uidPair = splitUID( value.toString() ); - if( uidPair.first == UIDInvalid ) - continue; - - m_tag->itemListMap()[uidFieldName( uidPair.first )] = TagLib::StringList( Qt4QStringToTString( uidPair.second ) ); - modified = true; - } - } - - return modified; -} - -bool -MP4TagHelper::hasEmbeddedCover() const -{ - TagLib::MP4::ItemListMap map = m_tag->itemListMap(); - TagLib::String name = fieldName( Meta::valHasCover ); - for( TagLib::MP4::ItemListMap::ConstIterator it = map.begin(); it != map.end(); ++it ) - { - if( it->first == name ) - { - TagLib::MP4::CoverArtList coverList = it->second.toCoverArtList(); - for( TagLib::MP4::CoverArtList::ConstIterator cover = coverList.begin(); cover != coverList.end(); ++cover ) - { - if( cover->data().size() > MIN_COVER_SIZE ) - return true; - } - } - } - - return false; -} - -QImage -MP4TagHelper::embeddedCover() const -{ - TagLib::MP4::ItemListMap map = m_tag->itemListMap(); - TagLib::String name = fieldName( Meta::valHasCover ); - for( TagLib::MP4::ItemListMap::ConstIterator it = map.begin(); it != map.end(); ++it ) - { - if( it->first == name ) - { - TagLib::MP4::CoverArtList coverList = it->second.toCoverArtList(); - for( TagLib::MP4::CoverArtList::Iterator cover = coverList.begin(); cover != coverList.end(); ++cover ) - { - if( cover->data().size() > MIN_COVER_SIZE ) - return QImage::fromData( ( uchar * ) cover->data().data(), cover->data().size() ); - } - } - } - - return QImage(); -} - -bool -MP4TagHelper::setEmbeddedCover( const QImage &cover ) -{ - QByteArray bytes; - QBuffer buffer( &bytes ); - - buffer.open( QIODevice::WriteOnly ); - - if( !cover.save( &buffer, "JPEG" ) ) - { - buffer.close(); - return false; - } - - buffer.close(); - - TagLib::MP4::CoverArtList covers; - - covers.append( TagLib::MP4::CoverArt( TagLib::MP4::CoverArt::JPEG, TagLib::ByteVector( bytes.data(), bytes.count() ) ) ); - - m_tag->itemListMap()[fieldName( Meta::valHasCover )] = TagLib::MP4::Item( covers ); - - return true; -} diff --git a/amarok/shared/tag_helpers/MP4TagHelper.h b/amarok/shared/tag_helpers/MP4TagHelper.h deleted file mode 100644 index 31dd5c75..00000000 --- a/amarok/shared/tag_helpers/MP4TagHelper.h +++ /dev/null @@ -1,47 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Sergey Ivanov <123kash@gmail.com> * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - - -#ifndef MP4TAGHELPER_H -#define MP4TAGHELPER_H - -#include "TagHelper.h" - -#include - -namespace Meta -{ - namespace Tag - { - class AMAROKSHARED_EXPORT MP4TagHelper : public TagHelper - { - public: - MP4TagHelper( TagLib::Tag *tag, TagLib::MP4::Tag *mp4Tag, Amarok::FileType fileType ); - - virtual Meta::FieldHash tags() const; - virtual bool setTags( const Meta::FieldHash &changes ); - - virtual bool hasEmbeddedCover() const; - virtual QImage embeddedCover() const; - virtual bool setEmbeddedCover( const QImage &cover ); - - private: - TagLib::MP4::Tag *m_tag; - }; - } -} - -#endif // MP4TAGHELPER_H diff --git a/amarok/shared/tag_helpers/StringHelper.cpp b/amarok/shared/tag_helpers/StringHelper.cpp deleted file mode 100644 index f803e757..00000000 --- a/amarok/shared/tag_helpers/StringHelper.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Sergey Ivanov <123kash@gmail.com> * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "StringHelper.h" -#include - -static QTextCodec *s_codec = QTextCodec::codecForName( "UTF-8" ); - -void -Meta::Tag::setCodec( QTextCodec *codec ) -{ - s_codec = codec; -} - -void -Meta::Tag::setCodecByName( QByteArray codecName ) -{ - s_codec = QTextCodec::codecForName( codecName ); -} - -TagLib::String -Meta::Tag::Qt4QStringToTString( const QString &str ) -{ - // Declare new var to prevent double call of trimmed func - QString val = str.trimmed(); - return val.isEmpty() ? TagLib::String::null : TagLib::String( val.toUtf8().data(), TagLib::String::UTF8 ); -} - -QString -Meta::Tag::TStringToQString( const TagLib::String &str ) -{ - return s_codec->toUnicode( str.toCString( true ) ).trimmed(); -} diff --git a/amarok/shared/tag_helpers/StringHelper.h b/amarok/shared/tag_helpers/StringHelper.h deleted file mode 100644 index 1ca8e103..00000000 --- a/amarok/shared/tag_helpers/StringHelper.h +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Sergey Ivanov <123kash@gmail.com> * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef STRINGHELPER_H -#define STRINGHELPER_H - -#include -#include - -#ifdef Qt4QStringToTString - #undef Qt4QStringToTString -#endif -#ifdef TStringToQString - #undef TStringToQString -#endif - -namespace Meta -{ - namespace Tag - { - /** - * Convert TString to QString, trimmes spaces in the begin and at the end - * and fixes encoding if needed. - */ - QString TStringToQString( const TagLib::String &str ); - - /** - * Convert QString to TString and trimmes spaces in the begin and at the end. - */ - TagLib::String Qt4QStringToTString( const QString &str ); - - /** - * Set codec for TStringToQString conversion. - */ - void setCodec( QTextCodec *codec ); - void setCodecByName( QByteArray codecName ); - } -} - -#endif // STRINGHELPER_H diff --git a/amarok/shared/tag_helpers/TagHelper.cpp b/amarok/shared/tag_helpers/TagHelper.cpp deleted file mode 100644 index 7528a772..00000000 --- a/amarok/shared/tag_helpers/TagHelper.cpp +++ /dev/null @@ -1,381 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Sergey Ivanov <123kash@gmail.com> * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "TagHelper.h" - -#include - -#include -#include -#include - -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wnon-virtual-dtor" -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef TAGLIB_OPUS_FOUND -#include -#endif -#include -#include -#include -#include -#include -#include -#include -#ifdef TAGLIB_MOD_FOUND -#include -#include -#include -#include -#endif -#pragma GCC diagnostic pop - -#include "APETagHelper.h" -#include "ASFTagHelper.h" -#include "ID3v2TagHelper.h" -#include "MP4TagHelper.h" -#include "VorbisCommentTagHelper.h" - -#include "StringHelper.h" - -using namespace Meta::Tag; - -TagHelper::TagHelper( TagLib::Tag *tag, Amarok::FileType fileType ) - : m_tag( tag ) - , m_fileType( fileType ) -{ -} - -TagHelper::TagHelper( TagLib::ID3v1::Tag *tag, Amarok::FileType fileType ) - : m_tag( tag ) - , m_fileType( fileType ) -{ -} - -TagHelper::~TagHelper() -{ -} - -Meta::FieldHash -TagHelper::tags() const -{ - Meta::FieldHash data; - - data.insert( Meta::valTitle, TStringToQString( m_tag->title() ) ); - data.insert( Meta::valArtist, TStringToQString( m_tag->artist() ) ); - data.insert( Meta::valAlbum, TStringToQString( m_tag->album() ) ); - data.insert( Meta::valTrackNr, m_tag->track() ); - data.insert( Meta::valYear, m_tag->year() ); - data.insert( Meta::valGenre, TStringToQString( m_tag->genre() ) ); - data.insert( Meta::valComment, TStringToQString( m_tag->comment() ) ); - - return data; -} - -bool -TagHelper::setTags( const Meta::FieldHash &changes ) -{ - bool modified = false; - - if( changes.contains( Meta::valTitle ) ) - { - m_tag->setTitle( Qt4QStringToTString( changes.value( Meta::valTitle ).toString() ) ); - modified = true; - } - if( changes.contains( Meta::valArtist ) ) - { - m_tag->setArtist( Qt4QStringToTString( changes.value( Meta::valArtist ).toString() ) ); - modified = true; - } - if( changes.contains( Meta::valAlbum ) ) - { - m_tag->setAlbum( Qt4QStringToTString( changes.value( Meta::valAlbum ).toString() ) ); - modified = true; - } - if( changes.contains( Meta::valTrackNr ) ) - { - m_tag->setTrack( changes.value( Meta::valTrackNr ).toUInt() ); - modified = true; - } - if( changes.contains( Meta::valYear ) ) - { - m_tag->setYear( changes.value( Meta::valYear ).toUInt() ); - modified = true; - } - if( changes.contains( Meta::valGenre ) ) - { - m_tag->setGenre( Qt4QStringToTString( changes.value( Meta::valGenre ).toString() ) ); - modified = true; - } - if( changes.contains( Meta::valComment ) ) - { - m_tag->setComment( Qt4QStringToTString( changes.value( Meta::valComment ).toString() ) ); - modified = true; - } - - return modified; -} - -TagLib::ByteVector -TagHelper::render() const -{ - QByteArray byteArray; - QDataStream stream( &byteArray, QIODevice::WriteOnly ); - stream << tags(); - return TagLib::ByteVector( byteArray.constData(), byteArray.size() ); -} - -bool -TagHelper::hasEmbeddedCover() const -{ - return false; -} - -QImage -TagHelper::embeddedCover() const -{ - return QImage(); -} - -bool -TagHelper::setEmbeddedCover( const QImage &cover ) -{ - Q_UNUSED( cover ) - return false; -} - -TagLib::String -TagHelper::fieldName( const qint64 field ) const -{ - return m_fieldMap.value( field ); -} - -qint64 -TagHelper::fieldName( const TagLib::String &field ) const -{ - return m_fieldMap.key( field ); -} - -QPair< TagHelper::UIDType, QString > -TagHelper::splitUID( const QString &uidUrl ) const -{ - TagHelper::UIDType type = UIDInvalid; - QString uid = uidUrl; - - if( uid.startsWith( "amarok-" ) ) - uid = uid.remove( QRegExp( "^(amarok-\\w+://).+$" ) ); - - if( isValidUID( uid, UIDAFT ) ) - type = UIDAFT; - - return qMakePair( type, uid ); -} - -QPair< int, int > -TagHelper::splitDiscNr( const QString &value ) const -{ - int disc; - int count = 0; - if( value.indexOf( '/' ) != -1 ) - { - QStringList list = value.split( '/', QString::SkipEmptyParts ); - disc = list.value( 0 ).toInt(); - count = list.value( 1 ).toInt(); - } - else if( value.indexOf( ':' ) != -1 ) - { - QStringList list = value.split( ':', QString::SkipEmptyParts ); - disc = list.value( 0 ).toInt(); - count = list.value( 1 ).toInt(); - } - else - disc = value.toInt(); - - return qMakePair( disc, count ); -} - -bool -TagHelper::isValidUID( const QString &uid, const TagHelper::UIDType type ) const -{ - if( uid.length() >= 127 ) // the database can't handle longer uids - return false; - - QRegExp regexp( "^$" ); - - if( type == UIDAFT ) - regexp.setPattern( "^[0-9a-fA-F]{32}$" ); - - return regexp.exactMatch( uid ); -} - -TagLib::String -TagHelper::uidFieldName( const TagHelper::UIDType type ) const -{ - return m_uidFieldMap.value( type ); -} - -TagLib::String -TagHelper::fmpsFieldName( const TagHelper::FMPS field ) const -{ - return m_fmpsFieldMap.value( field ); -} - -Amarok::FileType -TagHelper::fileType() const -{ - return m_fileType; -} - -QByteArray -TagHelper::testString() const -{ - TagLib::String string = m_tag->album() + m_tag->artist() + m_tag->comment() + - m_tag->genre() + m_tag->title(); - - return QByteArray( string.toCString( true ) ); -} - - -Meta::Tag::TagHelper * -Meta::Tag::selectHelper( const TagLib::FileRef fileref, bool forceCreation ) -{ - TagHelper *tagHelper = NULL; - - if( TagLib::MPEG::File *file = dynamic_cast< TagLib::MPEG::File * >( fileref.file() ) ) - { - if( file->ID3v2Tag( forceCreation ) ) - tagHelper = new ID3v2TagHelper( fileref.tag(), file->ID3v2Tag(), Amarok::Mp3 ); - else if( file->APETag() ) - tagHelper = new APETagHelper( fileref.tag(), file->APETag(), Amarok::Mp3 ); - else if( file->ID3v1Tag() ) - tagHelper = new TagHelper( fileref.tag(), Amarok::Mp3 ); - } - else if( TagLib::Ogg::Vorbis::File *file = dynamic_cast< TagLib::Ogg::Vorbis::File * >( fileref.file() ) ) - { - if( file->tag() ) - tagHelper = new VorbisCommentTagHelper( fileref.tag(), file->tag(), Amarok::Ogg ); - } - else if( TagLib::Ogg::FLAC::File *file = dynamic_cast< TagLib::Ogg::FLAC::File * >( fileref.file() ) ) - { - if( file->tag() ) - tagHelper = new VorbisCommentTagHelper( fileref.tag(), file->tag(), Amarok::Flac ); - } - else if( TagLib::Ogg::Speex::File *file = dynamic_cast< TagLib::Ogg::Speex::File * >( fileref.file() ) ) - { - if( file->tag() ) - tagHelper = new VorbisCommentTagHelper( fileref.tag(), file->tag(), Amarok::Speex ); - } -#ifdef TAGLIB_OPUS_FOUND - else if( TagLib::Ogg::Opus::File *file = dynamic_cast< TagLib::Ogg::Opus::File * >( fileref.file() ) ) - { - if( file->tag() ) - tagHelper = new VorbisCommentTagHelper( fileref.tag(), file->tag(), Amarok::Opus ); - } -#endif - else if( TagLib::FLAC::File *file = dynamic_cast< TagLib::FLAC::File * >( fileref.file() ) ) - { - if( file->xiphComment() ) - tagHelper = new VorbisCommentTagHelper( fileref.tag(), file->xiphComment(), Amarok::Flac, file ); - else if( file->ID3v2Tag() ) - tagHelper = new ID3v2TagHelper( fileref.tag(), file->ID3v2Tag(), Amarok::Flac ); - else if( file->ID3v1Tag() ) - tagHelper = new TagHelper( fileref.tag(), Amarok::Flac ); - } - else if( TagLib::MP4::File *file = dynamic_cast< TagLib::MP4::File * >( fileref.file() ) ) - { - TagLib::MP4::Tag *tag = dynamic_cast< TagLib::MP4::Tag * >( file->tag() ); - if( tag ) - { - Amarok::FileType specificType = Amarok::Mp4; - QString filename = QString( fileref.file()->name() ); - foreach( Amarok::FileType type, QList() << Amarok::M4a << Amarok::M4v ) - { - if( filename.endsWith( Amarok::FileTypeSupport::toString( type ), Qt::CaseInsensitive ) ) - specificType = type; - } - tagHelper = new MP4TagHelper( fileref.tag(), tag, specificType ); - } - } - else if( TagLib::MPC::File *file = dynamic_cast< TagLib::MPC::File * >( fileref.file() ) ) - { - if( file->APETag( forceCreation ) ) - tagHelper = new APETagHelper( fileref.tag(), file->APETag(), Amarok::Mpc ); - else if( file->ID3v1Tag() ) - tagHelper = new TagHelper( fileref.tag(), Amarok::Mpc ); - } - else if( TagLib::RIFF::AIFF::File *file = dynamic_cast< TagLib::RIFF::AIFF::File * >( fileref.file() ) ) - { - if( file->tag() ) - tagHelper = new ID3v2TagHelper( fileref.tag(), file->tag(), Amarok::Aiff ); - } - else if( TagLib::RIFF::WAV::File *file = dynamic_cast< TagLib::RIFF::WAV::File * >( fileref.file() ) ) - { - if( file->tag() ) - tagHelper = new ID3v2TagHelper( fileref.tag(), file->tag(), Amarok::Wav ); - } - else if( TagLib::ASF::File *file = dynamic_cast< TagLib::ASF::File * >( fileref.file() ) ) - { - TagLib::ASF::Tag *tag = dynamic_cast< TagLib::ASF::Tag * >( file->tag() ); - if( tag ) - tagHelper = new ASFTagHelper( fileref.tag(), tag, Amarok::Wma ); - } - else if( TagLib::TrueAudio::File *file = dynamic_cast< TagLib::TrueAudio::File * >( fileref.file() ) ) - { - if( file->ID3v2Tag( forceCreation ) ) - tagHelper = new ID3v2TagHelper( fileref.tag(), file->ID3v2Tag(), Amarok::TrueAudio ); - else if( file->ID3v1Tag() ) - tagHelper = new TagHelper( fileref.tag(), Amarok::TrueAudio ); - } - else if( TagLib::WavPack::File *file = dynamic_cast< TagLib::WavPack::File * >( fileref.file() ) ) - { - if( file->APETag( forceCreation ) ) - tagHelper = new APETagHelper( fileref.tag(), file->APETag(), Amarok::WavPack ); - else if( file->ID3v1Tag() ) - tagHelper = new TagHelper( fileref.tag(), Amarok::WavPack ); - } -#ifdef TAGLIB_MOD_FOUND - else if( TagLib::Mod::File *file = dynamic_cast< TagLib::Mod::File * >( fileref.file() ) ) - { - if( file->tag() ) - tagHelper = new TagHelper( fileref.tag(), Amarok::Mod ); - } - else if( TagLib::S3M::File *file = dynamic_cast< TagLib::S3M::File * >( fileref.file() ) ) - { - if( file->tag() ) - tagHelper = new TagHelper( fileref.tag(), Amarok::S3M ); - } - else if( TagLib::IT::File *file = dynamic_cast< TagLib::IT::File * >( fileref.file() ) ) - { - if( file->tag() ) - tagHelper = new TagHelper( fileref.tag(), Amarok::IT ); - } - else if( TagLib::XM::File *file = dynamic_cast< TagLib::XM::File * >( fileref.file() ) ) - { - if( file->tag() ) - tagHelper = new TagHelper( fileref.tag(), Amarok::XM ); - } -#endif - - return tagHelper; -} - diff --git a/amarok/shared/tag_helpers/TagHelper.h b/amarok/shared/tag_helpers/TagHelper.h deleted file mode 100644 index 8e4ba6f5..00000000 --- a/amarok/shared/tag_helpers/TagHelper.h +++ /dev/null @@ -1,151 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Sergey Ivanov <123kash@gmail.com> * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef TAGHELPER_H -#define TAGHELPER_H - -#define MIN_COVER_SIZE 1024 // Minimum size for an embedded cover to be loaded - -#include "MetaValues.h" -#include "FileType.h" -#include "amarokshared_export.h" - -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wnon-virtual-dtor" -#include -#include -#include -#pragma GCC diagnostic pop - -namespace Meta -{ - namespace Tag - { - class AMAROKSHARED_EXPORT TagHelper - { - public: - enum UIDType - { - UIDInvalid = 0, - UIDAFT = 3 - }; - - enum FMPS - { - FMPSPlayCount = 0, - FMPSRating = 1, - FMPSScore = 2 - }; - - TagHelper( TagLib::Tag *tag, Amarok::FileType fileType ); - explicit TagHelper( TagLib::ID3v1::Tag *tag, Amarok::FileType fileType ); - virtual ~TagHelper(); - - /** - * Read all supported tags from file. - */ - virtual Meta::FieldHash tags() const; - /** - * Write changed metadata to file. - * Return true if something writen. - */ - virtual bool setTags( const Meta::FieldHash &changes ); - - /** - * Render tags. Used in UID generator. - */ - virtual TagLib::ByteVector render() const; - - /** - * Check If file contains embedded cover. - */ - virtual bool hasEmbeddedCover() const; - - /** - * Read embedded cover from file. - */ - virtual QImage embeddedCover() const; - - /** - * Add or update cover in file. Will be set as FrontCover. - * Return true If something writen. - */ - virtual bool setEmbeddedCover( const QImage &cover ); - - /** - * Return file type. - */ - Amarok::FileType fileType() const; - - /** - * Returns combination of: - * title, album, artist, genre and comment fields. - * Used to encoding detection. - */ - QByteArray testString() const; - - protected: - /** - * Split UID url. - * @return Pair of uid type and uid. Uid type can be used to - * get field name where to write It (owner in case of ID3v2). - */ - QPair< UIDType, QString > splitUID( const QString &uidUrl ) const; - /** - * Check If @arg uid correct UID for specified @arg type. - */ - bool isValidUID( const QString &uid, const UIDType type ) const; - /** - * Returns field name for Meta::val* value. - */ - TagLib::String fieldName( const qint64 field ) const; - /** - * Returns Meta::val* value corresponds to field name. - */ - qint64 fieldName( const TagLib::String &field ) const; - /** - * Split DiscNr field on Disc number and Disc count. - */ - QPair< int, int > splitDiscNr( const QString &value ) const; - /** - * Returns field name for specified UID type. - */ - TagLib::String uidFieldName( const UIDType type ) const; - /** - * Returns field name for specified FMPS value. - */ - TagLib::String fmpsFieldName( const FMPS field ) const; - - QHash< quint64, TagLib::String > m_fieldMap; - QHash< FMPS, TagLib::String > m_fmpsFieldMap; - QHash< UIDType, TagLib::String > m_uidFieldMap; - - private: - TagLib::Tag *m_tag; - Amarok::FileType m_fileType; - }; - - /** - * Returns TagHelper for specified @arg fileref. - * @arg forceCreation If true: selector will force tag creation. - * @return TagHelper or NULL if file doesn't have tags. - * Should be deleted by user after use. - */ - AMAROKSHARED_EXPORT TagHelper *selectHelper( const TagLib::FileRef fileref, bool forceCreation = false ); - } -} - -#endif // TAGHELPER_H diff --git a/amarok/shared/tag_helpers/VorbisCommentTagHelper.cpp b/amarok/shared/tag_helpers/VorbisCommentTagHelper.cpp deleted file mode 100644 index f3ff542d..00000000 --- a/amarok/shared/tag_helpers/VorbisCommentTagHelper.cpp +++ /dev/null @@ -1,366 +0,0 @@ -/**************************************************************************************** - * Copyright (C) 2003-2005 Max Howell * - * (C) 2003-2010 Mark Kretschmann * - * (C) 2005-2007 Alexandre Oliveira * - * (C) 2008 Dan Meltzer * - * (C) 2008-2009 Jeff Mitchell * - * (C) 2010 Ralf Engels * - * (c) 2010 Sergey Ivanov <123kash@gmail.com> * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - - -#include "VorbisCommentTagHelper.h" - -#include "StringHelper.h" - -#include -#include - -#include - -using namespace Meta::Tag; - -static const TagLib::String VORBIS_PICTURE_TAG( "METADATA_BLOCK_PICTURE" ); - -VorbisCommentTagHelper::VorbisCommentTagHelper( TagLib::Tag *tag, TagLib::Ogg::XiphComment *commentsTag, Amarok::FileType fileType, TagLib::FLAC::File *file ) - : TagHelper( tag, fileType ) - , m_tag( commentsTag ) - , m_flacFile( file ) -{ - m_fieldMap.insert( Meta::valAlbumArtist, TagLib::String( "ALBUMARTIST" ) ); - m_fieldMap.insert( Meta::valBpm, TagLib::String( "BPM" ) ); - m_fieldMap.insert( Meta::valCompilation, TagLib::String( "COMPILATION" ) ); - m_fieldMap.insert( Meta::valComposer, TagLib::String( "COMPOSER" ) ); - m_fieldMap.insert( Meta::valDiscNr, TagLib::String( "DISCNUMBER" ) ); - m_fieldMap.insert( Meta::valHasCover, TagLib::String( "COVERART" ) ); // non-standard but frequently used - m_fieldMap.insert( Meta::valPlaycount, TagLib::String( "FMPS_PLAYCOUNT" ) ); - m_fieldMap.insert( Meta::valRating, TagLib::String( "FMPS_RATING" ) ); - m_fieldMap.insert( Meta::valScore, TagLib::String( "FMPS_RATING_AMAROK_SCORE" ) ); - m_fieldMap.insert( Meta::valLyrics, TagLib::String( "LYRICS" ) ); - - m_uidFieldMap.insert( UIDAFT, TagLib::String( "AMAROK 2 AFTV1 - AMAROK.KDE.ORG" ) ); -} - -static inline bool -isAlbumCover( const TagLib::FLAC::Picture* picture ) -{ - return ( picture->type() == TagLib::FLAC::Picture::FrontCover || - picture->type() == TagLib::FLAC::Picture::Other ) && - picture->data().size() > MIN_COVER_SIZE; // must be at least 1kb -} - -/** - * Extract the given FLAC Picture object to QImage picture. - * - * If the FLAC image is a front cover, store the result in cover and return true. - * Otherwise, if otherCover is null, store the image there and return false. - */ -static inline bool -flacPictureToQImage( const TagLib::FLAC::Picture* picture, QImage& cover, QImage& otherCover ) -{ - QByteArray image_data( picture->data().data(), picture->data().size() ); - - if( picture->type() == TagLib::FLAC::Picture::FrontCover ) - { - cover.loadFromData( image_data ); - return true; - } - else if( otherCover.isNull() ) - { - otherCover.loadFromData( image_data ); - } - return false; -} - -Meta::FieldHash -VorbisCommentTagHelper::tags() const -{ - Meta::FieldHash data = TagHelper::tags(); - - TagLib::Ogg::FieldListMap map = m_tag->fieldListMap(); - for( TagLib::Ogg::FieldListMap::ConstIterator it = map.begin(); it != map.end(); ++it ) - { - qint64 field; - QString value = TStringToQString( it->second.toString( '\n' ) ); - - if( ( field = fieldName( it->first ) ) ) - { - if( field == Meta::valDiscNr ) - { - int disc; - if( ( disc = splitDiscNr( value ).first ) ) - data.insert( field, disc ); - } - else if( field == Meta::valRating ) - data.insert( field, qRound( value.toFloat() * 10.0 ) ); - else if( field == Meta::valScore ) - data.insert( field, value.toFloat() * 100.0 ); - else if( field == Meta::valHasCover ) - data.insert( Meta::valHasCover, true ); - else - data.insert( field, value ); - } - else if( it->first == uidFieldName( UIDAFT ) && isValidUID( value, UIDAFT ) ) - data.insert( Meta::valUniqueId, value ); - else if( it->first == VORBIS_PICTURE_TAG ) - { - if( parsePictureBlock( it->second ) ) - data.insert( Meta::valHasCover, true ); - } - } - - if( m_flacFile ) - { - const TagLib::List picturelist = m_flacFile->pictureList(); - for( TagLib::List::ConstIterator it = picturelist.begin(); it != picturelist.end(); it++ ) - { - TagLib::FLAC::Picture* picture = *it; - - if( ( picture->type() == TagLib::FLAC::Picture::FrontCover || - picture->type() == TagLib::FLAC::Picture::Other ) && - picture->data().size() > MIN_COVER_SIZE ) // must be at least 1kb - { - data.insert( Meta::valHasCover, true ); - break; - } - } - } - - return data; -} - -bool -VorbisCommentTagHelper::setTags( const Meta::FieldHash &changes ) -{ - bool modified = TagHelper::setTags( changes ); - - foreach( const qint64 key, changes.keys() ) - { - QVariant value = changes.value( key ); - TagLib::String field = fieldName( key ); - - if( !field.isNull() && !field.isEmpty() ) - { - if( key == Meta::valHasCover ) - continue; - else if( key == Meta::valRating ) - m_tag->addField( field, Qt4QStringToTString( QString::number( value.toFloat() / 10.0 ) ) ); - else if( key == Meta::valScore ) - m_tag->addField( field, Qt4QStringToTString( QString::number( value.toFloat() / 100.0 ) ) ); - else - m_tag->addField( field, Qt4QStringToTString( value.toString() ) ); - - modified = true; - } - else if( key == Meta::valUniqueId ) - { - QPair < UIDType, QString > uidPair = splitUID( value.toString() ); - if( uidPair.first == UIDInvalid ) - continue; - - m_tag->addField( uidFieldName( uidPair.first ), Qt4QStringToTString( uidPair.second ) ); - modified = true; - } - } - - return modified; -} - -TagLib::ByteVector -VorbisCommentTagHelper::render() const -{ - return m_tag->render(); -} - -bool -VorbisCommentTagHelper::hasEmbeddedCover() const -{ - if( m_flacFile ) - { - const TagLib::List picturelist = m_flacFile->pictureList(); - for( TagLib::List::ConstIterator it = picturelist.begin(); it != picturelist.end(); it++ ) - { - const TagLib::FLAC::Picture *picture = *it; - - if( ( picture->type() == TagLib::FLAC::Picture::FrontCover || - picture->type() == TagLib::FLAC::Picture::Other ) && - picture->data().size() > MIN_COVER_SIZE ) // must be at least 1kb - { - return true; - } - } - } - else if( m_tag->fieldListMap().contains( VORBIS_PICTURE_TAG ) ) - { - return parsePictureBlock( m_tag->fieldListMap()[ VORBIS_PICTURE_TAG ] ); - } - else if( !fieldName( Meta::valHasCover ).isEmpty() ) - { - TagLib::ByteVector field = fieldName( Meta::valHasCover ).toCString(); - - return m_tag->fieldListMap().contains( field ); - } - - return false; -} - -QImage -VorbisCommentTagHelper::embeddedCover() const -{ - QImage cover; - - if( m_flacFile ) - { - QImage otherCover; - - const TagLib::List picturelist = m_flacFile->pictureList(); - for( TagLib::List::ConstIterator it = picturelist.begin(); it != picturelist.end(); it++ ) - { - const TagLib::FLAC::Picture *picture = *it; - - if( ( picture->type() == TagLib::FLAC::Picture::FrontCover || - picture->type() == TagLib::FLAC::Picture::Other ) && - picture->data().size() > MIN_COVER_SIZE ) // must be at least 1kb - { - QByteArray image_data( picture->data().data(), picture->data().size() ); - - if( picture->type() == TagLib::FLAC::Picture::FrontCover ) - { - cover.loadFromData( image_data ); - break; - } - else if( otherCover.isNull() ) - { - otherCover.loadFromData( image_data ); - } - } - } - - if( cover.isNull() && !otherCover.isNull() ) - cover = otherCover; - } - else if( m_tag->fieldListMap().contains( VORBIS_PICTURE_TAG ) ) - { - QImage resultCover; - parsePictureBlock( m_tag->fieldListMap()[ VORBIS_PICTURE_TAG ], &resultCover ); - if( cover.isNull() && !resultCover.isNull() ) - cover = resultCover; - } - else if( !fieldName( Meta::valHasCover ).isEmpty() ) - { - TagLib::ByteVector field = fieldName( Meta::valHasCover ).toCString(); - - if( !m_tag->fieldListMap().contains( field ) ) - return cover; - - TagLib::StringList coverList = m_tag->fieldListMap()[field]; - - for( uint i=0; iremovePictures(); - - // add new cover - TagLib::FLAC::Picture *newPicture = new TagLib::FLAC::Picture(); - newPicture->setData( TagLib::ByteVector( bytes.data(), bytes.size() ) ); - newPicture->setMimeType( "image/jpeg" ); - newPicture->setType( TagLib::FLAC::Picture::FrontCover ); - m_flacFile->addPicture( newPicture ); - - return true; - } - - return false; -} - -bool -VorbisCommentTagHelper::parsePictureBlock( const TagLib::StringList& block, QImage* result ) -{ - QImage otherCover; - // Here's what's happening: "block" may contain several FLAC picture entries. - // We need to find at least one that satisfies our needs. - for( TagLib::StringList::ConstIterator i = block.begin(); i != block.end(); ++i ) - { - QByteArray data( QByteArray::fromBase64( i->to8Bit().c_str() ) ); - TagLib::ByteVector tdata( data.data(), data.size() ); - TagLib::FLAC::Picture p; - - if(!p.parse(tdata)) - continue; - if(isAlbumCover(&p)) - { - if( result ) - { - // Now, if the image is a front cover, we just use it and quit - // Otherwise, we store it in otherCover and wait for a better one - if( flacPictureToQImage( &p, *result, otherCover ) ) - return true; - } - else - // We found some image, but we don't need best one here, so just leave - return true; - } - } - if(result) - { - // Now here we haven't found any front covers in the file - // So we just use otherCover and exit - *result = otherCover; - return !result->isNull(); - } - return false; -} diff --git a/amarok/shared/tag_helpers/VorbisCommentTagHelper.h b/amarok/shared/tag_helpers/VorbisCommentTagHelper.h deleted file mode 100644 index 6b920c3c..00000000 --- a/amarok/shared/tag_helpers/VorbisCommentTagHelper.h +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Sergey Ivanov <123kash@gmail.com> * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - - -#ifndef VORBISCOMMENTTAGHELPER_H -#define VORBISCOMMENTTAGHELPER_H - -#include "TagHelper.h" - -#include -#include - -class QImage; - -namespace Meta -{ - namespace Tag - { - class AMAROKSHARED_EXPORT VorbisCommentTagHelper : public TagHelper - { - public: - VorbisCommentTagHelper( TagLib::Tag *tag, TagLib::Ogg::XiphComment *commentsTag, Amarok::FileType fileType, TagLib::FLAC::File *file = 0 ); - - virtual Meta::FieldHash tags() const; - virtual bool setTags( const Meta::FieldHash &changes ); - - virtual TagLib::ByteVector render() const; - - virtual bool hasEmbeddedCover() const; - virtual QImage embeddedCover() const; - virtual bool setEmbeddedCover( const QImage &cover ); - - private: - static bool parsePictureBlock( const TagLib::StringList& block, QImage* result = 0 ); - TagLib::Ogg::XiphComment *m_tag; - TagLib::FLAC::File *m_flacFile; - }; - } -} - -#endif // VORBISCOMMENTTAGHELPER_H diff --git a/amarok/src/ActionClasses.cpp b/amarok/src/ActionClasses.cpp deleted file mode 100644 index 3f6a63e0..00000000 --- a/amarok/src/ActionClasses.cpp +++ /dev/null @@ -1,498 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2004 Max Howell * - * Copyright (c) 2008 Mark Kretschmann * - * Copyright (c) 2009 Artur Szymiec * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "ActionClasses" - -#include "ActionClasses.h" - - -#include "App.h" -#include "EngineController.h" -#include "MainWindow.h" -#include "amarokconfig.h" -#include -#include "core/support/Amarok.h" -#include "core/support/Debug.h" -#include "playlist/PlaylistActions.h" -#include "playlist/PlaylistModelStack.h" -#include "widgets/Osd.h" -#include "KNotificationBackend.h" - -#include -#include -#include -#include - -extern OcsData ocsData; - -namespace Amarok -{ - bool favorNone() { return AmarokConfig::favorTracks() == AmarokConfig::EnumFavorTracks::Off; } - bool favorScores() { return AmarokConfig::favorTracks() == AmarokConfig::EnumFavorTracks::HigherScores; } - bool favorRatings() { return AmarokConfig::favorTracks() == AmarokConfig::EnumFavorTracks::HigherRatings; } - bool favorLastPlay() { return AmarokConfig::favorTracks() == AmarokConfig::EnumFavorTracks::LessRecentlyPlayed; } - - - bool entireAlbums() { return AmarokConfig::trackProgression() == AmarokConfig::EnumTrackProgression::RepeatAlbum || - AmarokConfig::trackProgression() == AmarokConfig::EnumTrackProgression::RandomAlbum; } - - bool repeatEnabled() { return AmarokConfig::trackProgression() == AmarokConfig::EnumTrackProgression::RepeatTrack || - AmarokConfig::trackProgression() == AmarokConfig::EnumTrackProgression::RepeatAlbum || - AmarokConfig::trackProgression() == AmarokConfig::EnumTrackProgression::RepeatPlaylist; } - - bool randomEnabled() { return AmarokConfig::trackProgression() == AmarokConfig::EnumTrackProgression::RandomTrack || - AmarokConfig::trackProgression() == AmarokConfig::EnumTrackProgression::RandomAlbum; } -} - -using namespace Amarok; - -KHelpMenu *Menu::s_helpMenu = 0; - -static void -safePlug( KActionCollection *ac, const char *name, QWidget *w ) -{ - if( ac ) - { - KAction *a = (KAction*) ac->action( name ); - if( a && w ) w->addAction( a ); - } -} - - -////////////////////////////////////////////////////////////////////////////////////////// -// MenuAction && Menu -// KActionMenu doesn't work very well, so we derived our own -////////////////////////////////////////////////////////////////////////////////////////// - -MenuAction::MenuAction( KActionCollection *ac, QObject *parent ) - : KAction( parent ) -{ - setText(i18n( "Amarok Menu" )); - ac->addAction("amarok_menu", this); - setShortcutConfigurable ( false ); //FIXME disabled as it doesn't work, should use QCursor::pos() -} - - -Menu* Menu::s_instance = 0; - -Menu::Menu( QWidget* parent ) - : KMenu( parent ) -{ - s_instance = this; - - KActionCollection *ac = Amarok::actionCollection(); - - safePlug( ac, "repeat", this ); - safePlug( ac, "random_mode", this ); - - addSeparator(); - - safePlug( ac, "playlist_playmedia", this ); - - addSeparator(); - - safePlug( ac, "cover_manager", this ); - safePlug( ac, "queue_manager", this ); - safePlug( ac, "script_manager", this ); - - addSeparator(); - - safePlug( ac, "update_collection", this ); - safePlug( ac, "rescan_collection", this ); - -#ifndef Q_WS_MAC - addSeparator(); - - safePlug( ac, KStandardAction::name(KStandardAction::ShowMenubar), this ); -#endif - - addSeparator(); - - safePlug( ac, KStandardAction::name(KStandardAction::ConfigureToolbars), this ); - safePlug( ac, KStandardAction::name(KStandardAction::KeyBindings), this ); -// safePlug( ac, "options_configure_globals", this ); //we created this one - safePlug( ac, KStandardAction::name(KStandardAction::Preferences), this ); - - addSeparator(); - - addMenu( helpMenu( this ) ); - - addSeparator(); - - safePlug( ac, KStandardAction::name(KStandardAction::Quit), this ); -} - -Menu* -Menu::instance() -{ - return s_instance ? s_instance : new Menu( The::mainWindow() ); -} - -KMenu* -Menu::helpMenu( QWidget *parent ) //STATIC -{ - if ( s_helpMenu == 0 ) - s_helpMenu = new KHelpMenu( parent, KGlobal::mainComponent().aboutData(), Amarok::actionCollection() ); - - KMenu* menu = s_helpMenu->menu(); - - // "What's This" isn't currently defined for anything in Amarok, so let's remove it - s_helpMenu->action( KHelpMenu::menuWhatsThis )->setVisible( false ); - - // Hide the default "About App" dialog, as we replace it with a custom one - s_helpMenu->action( KHelpMenu::menuAboutApp )->setVisible( false ); - - return menu; -} - -////////////////////////////////////////////////////////////////////////////////////////// -// PlayPauseAction -////////////////////////////////////////////////////////////////////////////////////////// - -PlayPauseAction::PlayPauseAction( KActionCollection *ac, QObject *parent ) - : KToggleAction( parent ) -{ - - ac->addAction( "play_pause", this ); - setText( i18n( "Play/Pause" ) ); - setShortcut( Qt::Key_Space ); - setGlobalShortcut( KShortcut( Qt::Key_MediaPlay ) ); - - EngineController *engine = The::engineController(); - - if( engine->isPaused() ) - paused(); - else if( engine->isPlaying() ) - playing(); - else - stopped(); - - connect( this, SIGNAL(triggered()), - engine, SLOT(playPause()) ); - - connect( engine, SIGNAL(stopped(qint64,qint64)), - this, SLOT(stopped()) ); - connect( engine, SIGNAL(paused()), - this, SLOT(paused()) ); - connect( engine, SIGNAL(trackPlaying(Meta::TrackPtr)), - this, SLOT(playing()) ); -} - -void -PlayPauseAction::stopped() -{ - setChecked( false ); - setIcon( KIcon("media-playback-start-amarok") ); -} - -void -PlayPauseAction::paused() -{ - setChecked( true ); - setIcon( KIcon("media-playback-start-amarok") ); -} - -void -PlayPauseAction::playing() -{ - setChecked( false ); - setIcon( KIcon("media-playback-pause-amarok") ); -} - - -////////////////////////////////////////////////////////////////////////////////////////// -// ToggleAction -////////////////////////////////////////////////////////////////////////////////////////// - -ToggleAction::ToggleAction( const QString &text, void ( *f ) ( bool ), KActionCollection* const ac, const char *name, QObject *parent ) - : KToggleAction( parent ) - , m_function( f ) -{ - setText(text); - ac->addAction(name, this); -} - -void ToggleAction::setChecked( bool b ) -{ - const bool announce = b != isChecked(); - - m_function( b ); - KToggleAction::setChecked( b ); - AmarokConfig::self()->writeConfig(); //So we don't lose the setting when crashing - if( announce ) emit toggled( b ); //KToggleAction doesn't do this for us. How gay! -} - -void ToggleAction::setEnabled( bool b ) -{ - const bool announce = b != isEnabled(); - - KToggleAction::setEnabled( b ); - AmarokConfig::self()->writeConfig(); //So we don't lose the setting when crashing - if( announce ) emit QAction::triggered( b ); -} - -////////////////////////////////////////////////////////////////////////////////////////// -// SelectAction -////////////////////////////////////////////////////////////////////////////////////////// - -SelectAction::SelectAction( const QString &text, void ( *f ) ( int ), KActionCollection* const ac, const char *name, QObject *parent ) - : KSelectAction( parent ) - , m_function( f ) -{ - PERF_LOG( "In SelectAction" ); - setText(text); - ac->addAction(name, this); -} - -void SelectAction::setCurrentItem( int n ) -{ - const bool announce = n != currentItem(); - - debug() << "setCurrentItem: " << n; - - m_function( n ); - KSelectAction::setCurrentItem( n ); - AmarokConfig::self()->writeConfig(); //So we don't lose the setting when crashing - if( announce ) emit triggered( n ); -} - -void SelectAction::actionTriggered( QAction *a ) -{ - m_function( currentItem() ); - AmarokConfig::self()->writeConfig(); - KSelectAction::actionTriggered( a ); -} - -void SelectAction::setEnabled( bool b ) -{ - const bool announce = b != isEnabled(); - - KSelectAction::setEnabled( b ); - AmarokConfig::self()->writeConfig(); //So we don't lose the setting when crashing - if( announce ) emit QAction::triggered( b ); -} - -void SelectAction::setIcons( QStringList icons ) -{ - m_icons = icons; - foreach( QAction *a, selectableActionGroup()->actions() ) - { - a->setIcon( KIcon(icons.takeFirst()) ); - } -} - -QStringList SelectAction::icons() const { return m_icons; } - -QString SelectAction::currentIcon() const -{ - if( m_icons.count() ) - return m_icons.at( currentItem() ); - return QString(); -} - -QString SelectAction::currentText() const { - return KSelectAction::currentText() + "

" + i18n("Click to change"); -} - - -void -RandomAction::setCurrentItem( int n ) -{ - // Porting - //if( KAction *a = parentCollection()->action( "favor_tracks" ) ) - // a->setEnabled( n ); - SelectAction::setCurrentItem( n ); -} - -////////////////////////////////////////////////////////////////////////////////////////// -// ReplayGainModeAction -////////////////////////////////////////////////////////////////////////////////////////// -ReplayGainModeAction::ReplayGainModeAction( KActionCollection *ac, QObject *parent ) : - SelectAction( i18n( "&Replay Gain Mode" ), &AmarokConfig::setReplayGainMode, ac, "replay_gain_mode", parent ) -{ - setItems( QStringList() << i18nc( "Replay Gain state, as in, disabled", "&Off" ) - << i18nc( "Item, as in, music", "&Track" ) - << i18n( "&Album" ) ); - EngineController *engine = EngineController::instance(); - Q_ASSERT( engine ); - if( engine->supportsGainAdjustments() ) - setCurrentItem( AmarokConfig::replayGainMode() ); - else - { - // Note: it would be nice to set a tooltip that would explain why this is disabled - // to users, but tooltips aren't shown in meny anyway :-( - actions().at( 1 )->setEnabled( false ); - actions().at( 2 )->setEnabled( false ); - } -} - -////////////////////////////////////////////////////////////////////////////////////////// -// BurnMenuAction -////////////////////////////////////////////////////////////////////////////////////////// -BurnMenuAction::BurnMenuAction( KActionCollection *ac, QObject *parent ) - : KAction( parent ) -{ - setText(i18n( "Burn" )); - ac->addAction("burn_menu", this); -} - -QWidget* -BurnMenuAction::createWidget( QWidget *w ) -{ - KToolBar *bar = dynamic_cast(w); - - if( bar && KAuthorized::authorizeKAction( objectName() ) ) - { - //const int id = KAction::getToolButtonID(); - - //addContainer( bar, id ); - w->addAction( this ); - connect( bar, SIGNAL(destroyed()), SLOT(slotDestroyed()) ); - - //bar->insertButton( QString::null, id, true, i18n( "Burn" ), index ); - - //KToolBarButton* button = bar->getButton( id ); - //button->setPopup( Amarok::BurnMenu::instance() ); - //button->setObjectName( "toolbutton_burn_menu" ); - //button->setIcon( "k3b" ); - - //return associatedWidgets().count() - 1; - return 0; - } - //else return -1; - else return 0; -} - - -BurnMenu* BurnMenu::s_instance = 0; - -BurnMenu::BurnMenu( QWidget* parent ) - : KMenu( parent ) -{ - s_instance = this; - - addAction( i18n("Current Playlist"), this, SLOT(slotBurnCurrentPlaylist()) ); - addAction( i18n("Selected Tracks"), this, SLOT(slotBurnSelectedTracks()) ); - //TODO add "album" and "all tracks by artist" -} - -KMenu* -BurnMenu::instance() -{ - return s_instance ? s_instance : new BurnMenu( The::mainWindow() ); -} - -void -BurnMenu::slotBurnCurrentPlaylist() //SLOT -{ - //K3bExporter::instance()->exportCurrentPlaylist(); -} - -void -BurnMenu::slotBurnSelectedTracks() //SLOT -{ - //K3bExporter::instance()->exportSelectedTracks(); -} - - -////////////////////////////////////////////////////////////////////////////////////////// -// StopAction -////////////////////////////////////////////////////////////////////////////////////////// - -StopAction::StopAction( KActionCollection *ac, QObject *parent ) - : KAction( parent ) -{ - ac->addAction( "stop", this ); - setText( i18n( "Stop" ) ); - setIcon( KIcon("media-playback-stop-amarok") ); - setGlobalShortcut( KShortcut( Qt::Key_MediaStop ) ); - connect( this, SIGNAL(triggered()), this, SLOT(stop()) ); - - EngineController *engine = The::engineController(); - - if( engine->isStopped() ) - stopped(); - else - playing(); - - connect( engine, SIGNAL(stopped(qint64,qint64)), - this, SLOT(stopped()) ); - connect( engine, SIGNAL(trackPlaying(Meta::TrackPtr)), - this, SLOT(playing()) ); - -} - -void -StopAction::stopped() -{ - setEnabled( false ); -} - -void -StopAction::playing() -{ - setEnabled( true ); -} - -void -StopAction::stop() -{ - The::engineController()->stop(); -} - - -////////////////////////////////////////////////////////////////////////////////////////// -// StopPlayingAfterCurrentTrackAction -////////////////////////////////////////////////////////////////////////////////////////// - -StopPlayingAfterCurrentTrackAction::StopPlayingAfterCurrentTrackAction( KActionCollection *ac, QObject *parent ) -: KAction( parent ) -{ - ac->addAction( "stop_after_current", this ); - setText( i18n( "Stop after current Track" ) ); - setIcon( KIcon("media-playback-stop-amarok") ); - setGlobalShortcut( KShortcut( Qt::META + Qt::SHIFT + Qt::Key_V ) ); - connect( this, SIGNAL(triggered()), SLOT(stopPlayingAfterCurrentTrack()) ); -} - -void -StopPlayingAfterCurrentTrackAction::stopPlayingAfterCurrentTrack() -{ - QString text; - - quint64 activeTrack = Playlist::ModelStack::instance()->bottom()->activeId(); - if( activeTrack ) - { - if( The::playlistActions()->willStopAfterTrack( activeTrack ) ) - { - The::playlistActions()->stopAfterPlayingTrack( 0 ); - text = i18n( "Stop after current track: Off" ); - } - else - { - The::playlistActions()->stopAfterPlayingTrack( activeTrack ); - text = i18n( "Stop after current track: On" ); - } - } - else - text = i18n( "No track playing" ); - - Amarok::OSD::instance()->OSDWidget::show( text ); - if( Amarok::KNotificationBackend::instance()->isEnabled() ) - Amarok::KNotificationBackend::instance()->show( i18n( "Amarok" ), text ); -} diff --git a/amarok/src/ActionClasses.h b/amarok/src/ActionClasses.h deleted file mode 100644 index 96d93c27..00000000 --- a/amarok/src/ActionClasses.h +++ /dev/null @@ -1,176 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2004 Max Howell * - * Copyright (c) 2008 Mark Kretschmann * - * Copyright (c) 2009 Artur Szymiec * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_ACTIONCLASSES_H -#define AMAROK_ACTIONCLASSES_H - -#include -#include -#include -#include - -#include - -#include - -class KActionCollection; -class KHelpMenu; - - -namespace Amarok -{ - class Menu : public KMenu - { - Q_OBJECT - public: - Menu( QWidget* parent ); - static Menu *instance(); - static KMenu *helpMenu( QWidget *parent = 0 ); - - private: - static Menu *s_instance; - static KHelpMenu *s_helpMenu; - }; - - class MenuAction : public KAction - { - public: - MenuAction( KActionCollection*, QObject* ); - }; - - class PlayPauseAction : public KToggleAction - { - Q_OBJECT - - public: - PlayPauseAction( KActionCollection*, QObject* ); - - private slots: - void stopped(); - void paused(); - void playing(); - }; - - class ToggleAction : public KToggleAction - { - public: - ToggleAction( const QString &text, void ( *f ) ( bool ), KActionCollection* const ac, const char *name, QObject *parent ); - virtual void setChecked( bool b ); - virtual void setEnabled( bool b ); - - private: - void ( *m_function ) ( bool ); - }; - - class SelectAction : public KSelectAction - { - Q_OBJECT - - public: - SelectAction( const QString &text, void ( *f ) ( int ), KActionCollection* const ac, const char *name, QObject *parent ); - - virtual void setCurrentItem( int n ); - virtual void setEnabled( bool b ); - virtual void setIcons( QStringList icons ); - virtual QString currentText() const; - QStringList icons() const; - QString currentIcon() const; - - protected slots: - virtual void actionTriggered( QAction *a ); - - private: - void ( *m_function ) ( int ); - QStringList m_icons; - }; - - class RandomAction : public SelectAction - { - public: - RandomAction( KActionCollection *ac, QObject* ); - virtual void setCurrentItem( int n ); - }; - - class FavorAction : public SelectAction - { - public: - FavorAction( KActionCollection *ac, QObject* ); - }; - - class RepeatAction : public SelectAction - { - public: - RepeatAction( KActionCollection *ac, QObject* ); - }; - - class ReplayGainModeAction : public SelectAction - { - public: - ReplayGainModeAction( KActionCollection *ac, QObject* ); - }; - - class BurnMenu : public KMenu - { - Q_OBJECT - - public: - BurnMenu( QWidget* parent ); - static KMenu *instance(); - - private slots: - void slotBurnCurrentPlaylist(); - void slotBurnSelectedTracks(); - - private: - static BurnMenu* s_instance; - }; - - - class BurnMenuAction : public KAction - { - public: - BurnMenuAction( KActionCollection*, QObject* ); - virtual QWidget* createWidget( QWidget* ); - }; - - class StopAction : public KAction - { - Q_OBJECT - public: - StopAction( KActionCollection*, QObject* ); - - private slots: - void stopped(); - void playing(); - void stop(); - }; - - class StopPlayingAfterCurrentTrackAction : public KAction - { - Q_OBJECT - public: - StopPlayingAfterCurrentTrackAction( KActionCollection*, QObject* ); - - private slots: - void stopPlayingAfterCurrentTrack(); - }; -} /* namespace Amarok */ - - -#endif /* AMAROK_ACTIONCLASSES_H */ - diff --git a/amarok/src/AmarokMimeData.cpp b/amarok/src/AmarokMimeData.cpp deleted file mode 100644 index 02eed165..00000000 --- a/amarok/src/AmarokMimeData.cpp +++ /dev/null @@ -1,395 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "AmarokMimeData.h" - -#include "core/support/Debug.h" - -#include -#include -#include -#include - -const QString AmarokMimeData::TRACK_MIME = "application/x-amarok-tracks"; -const QString AmarokMimeData::PLAYLIST_MIME = "application/x-amarok-playlists"; -const QString AmarokMimeData::PLAYLISTBROWSERGROUP_MIME = "application/x-amarok-playlistbrowsergroup"; -const QString AmarokMimeData::PODCASTCHANNEL_MIME = "application/x-amarok-podcastchannel"; -const QString AmarokMimeData::PODCASTEPISODE_MIME = "application/x-amarok-podcastepisode"; -const QString AmarokMimeData::AMAROKURL_MIME = "application/x-amarok-amarokurl"; -const QString AmarokMimeData::BOOKMARKGROUP_MIME = "application/x-amarok-bookmarkgroup"; - - -class AmarokMimeData::Private -{ -public: - Private() : deleteQueryMakers( true ), completedQueries( 0 ) - {} - - ~Private() - { - if( deleteQueryMakers ) - qDeleteAll( queryMakers ); - } - - Meta::TrackList tracks; - Playlists::PlaylistList playlists; - QStringList playlistGroups; - Podcasts::PodcastChannelList m_podcastChannels; - Podcasts::PodcastEpisodeList m_podcastEpisodes; - QList queryMakers; - QMap trackMap; - QMap playlistMap; - BookmarkList bookmarks; - BookmarkGroupList bookmarkGroups; - - bool deleteQueryMakers; - int completedQueries; - -}; - -AmarokMimeData::AmarokMimeData() - : QMimeData() - , d( new Private() ) -{ - //nothing to do -} - -AmarokMimeData::~AmarokMimeData() -{ - delete d; -} - -QStringList -AmarokMimeData::formats() const -{ - QStringList formats( QMimeData::formats() ); - if( !d->tracks.isEmpty() || !d->queryMakers.isEmpty() || !d->playlistGroups.isEmpty() || !d->bookmarks.isEmpty() || !d->bookmarkGroups.isEmpty() ) - { - formats.append( TRACK_MIME ); - formats.append( PLAYLIST_MIME ); - formats.append( PLAYLISTBROWSERGROUP_MIME ); - formats.append( PODCASTCHANNEL_MIME ); - formats.append( PODCASTEPISODE_MIME ); - formats.append( BOOKMARKGROUP_MIME ); - formats.append( AMAROKURL_MIME ); - - if( !formats.contains( "text/uri-list" ) ) - formats.append( "text/uri-list" ); - if( !formats.contains( "text/plain" ) ) - formats.append( "text/plain" ); - } - - return formats; -} - -bool -AmarokMimeData::hasFormat( const QString &mimeType ) const -{ - if( mimeType == TRACK_MIME ) - return !d->tracks.isEmpty() || !d->queryMakers.isEmpty(); - else if( mimeType == PLAYLIST_MIME ) - return !d->playlists.isEmpty() || !d->queryMakers.isEmpty(); - else if( mimeType == PLAYLISTBROWSERGROUP_MIME ) - return !d->playlistGroups.isEmpty(); - else if( mimeType == PODCASTCHANNEL_MIME ) - return !d->m_podcastChannels.isEmpty(); - else if( mimeType == PODCASTEPISODE_MIME ) - return !d->m_podcastEpisodes.isEmpty(); - else if( mimeType == BOOKMARKGROUP_MIME ) - return !d->bookmarkGroups.isEmpty(); - else if( mimeType == AMAROKURL_MIME ) - return !d->bookmarks.isEmpty(); - else if( mimeType == "text/uri-list" || mimeType == "text/plain" ) - return !d->tracks.isEmpty() || !d->playlists.isEmpty() - || !d->m_podcastChannels.isEmpty() || !d->m_podcastEpisodes.isEmpty() - || !d->queryMakers.isEmpty(); - else - return QMimeData::hasFormat( mimeType ); -} - -Meta::TrackList -AmarokMimeData::tracks() const -{ - while( d->completedQueries < d->queryMakers.count() ) - { - QCoreApplication::instance()->processEvents( QEventLoop::ExcludeUserInputEvents ); - } - Meta::TrackList result = d->tracks; - foreach( Collections::QueryMaker *qm, d->queryMakers ) - { - if( d->trackMap.contains( qm ) ) - result << d->trackMap.value( qm ); - } - return result; -} - -void -AmarokMimeData::setTracks( const Meta::TrackList &tracks ) -{ - d->tracks = tracks; -} - -void -AmarokMimeData::addTracks( const Meta::TrackList &tracks ) -{ - d->tracks << tracks; -} - -void -AmarokMimeData::getTrackListSignal() const -{ - if( d->completedQueries < d->queryMakers.count() ) - { - QTimer::singleShot( 0, const_cast( this ), SLOT(getTrackListSignal()) ); - return; - } - else - { - Meta::TrackList result = d->tracks; - foreach( Collections::QueryMaker *qm, d->queryMakers ) - { - if( d->trackMap.contains( qm ) ) - result << d->trackMap.value( qm ); - } - emit trackListSignal( result ); - } -} - -Playlists::PlaylistList -AmarokMimeData::playlists() const -{ - while( d->completedQueries < d->queryMakers.count() ) - { - QCoreApplication::instance()->processEvents( QEventLoop::AllEvents ); - } - Playlists::PlaylistList result = d->playlists; - return result; -} - -void -AmarokMimeData::setPlaylists( const Playlists::PlaylistList &playlists ) -{ - d->playlists = playlists; -} - -void -AmarokMimeData::addPlaylists( const Playlists::PlaylistList &playlists ) -{ - d->playlists << playlists; -} - -QStringList -AmarokMimeData::playlistGroups() const -{ - return d->playlistGroups; -} - -void -AmarokMimeData::setPlaylistGroups( const QStringList &groups ) -{ - d->playlistGroups = groups; -} - -void -AmarokMimeData::addPlaylistGroup( const QString &group ) -{ - d->playlistGroups << group; -} - -Podcasts::PodcastChannelList -AmarokMimeData::podcastChannels() const -{ - return d->m_podcastChannels; -} - -void -AmarokMimeData::setPodcastChannels( const Podcasts::PodcastChannelList &channels ) -{ - d->m_podcastChannels = channels; -} - -void -AmarokMimeData::addPodcastChannels( const Podcasts::PodcastChannelList &channels ) -{ - d->m_podcastChannels << channels; -} - -Podcasts::PodcastEpisodeList -AmarokMimeData::podcastEpisodes() const -{ - return d->m_podcastEpisodes; -} - -void -AmarokMimeData::setPodcastEpisodes( const Podcasts::PodcastEpisodeList &episodes ) -{ - d->m_podcastEpisodes = episodes; -} - -void -AmarokMimeData::addPodcastEpisodes( const Podcasts::PodcastEpisodeList &episodes ) -{ - d->m_podcastEpisodes << episodes; -} - -QList -AmarokMimeData::queryMakers() -{ - d->deleteQueryMakers = false; - return d->queryMakers; -} - -void -AmarokMimeData::addQueryMaker( Collections::QueryMaker *queryMaker ) -{ - d->queryMakers.append( queryMaker ); -} - -void -AmarokMimeData::setQueryMakers( const QList &queryMakers ) -{ - d->queryMakers << queryMakers; -} - -BookmarkList AmarokMimeData::bookmarks() const -{ - return d->bookmarks; -} - -void AmarokMimeData::setBookmarks( const BookmarkList &bookmarks ) -{ - d->bookmarks = bookmarks; -} - -void AmarokMimeData::addBookmarks( const BookmarkList &bookmarks ) -{ - d->bookmarks << bookmarks; -} - -BookmarkGroupList AmarokMimeData::bookmarkGroups() const -{ - return d->bookmarkGroups; -} - -void AmarokMimeData::setBookmarkGroups( const BookmarkGroupList &groups ) -{ - d->bookmarkGroups = groups; -} - -void AmarokMimeData::addBookmarkGroups( const BookmarkGroupList &groups ) -{ - d->bookmarkGroups << groups; -} - -QVariant -AmarokMimeData::retrieveData( const QString &mimeType, QVariant::Type type ) const -{ - Meta::TrackList tracks = this->tracks(); - Playlists::PlaylistList playlists = this->playlists(); - Podcasts::PodcastChannelList channels = this->podcastChannels(); - Podcasts::PodcastEpisodeList episodes = this->podcastEpisodes(); - if( !tracks.isEmpty() ) - { - if( mimeType == "text/uri-list" && (type == QVariant::List || type == QVariant::ByteArray) ) - { - QList list; - foreach( Meta::TrackPtr track, tracks ) - { - list.append( QVariant( QUrl( track->playableUrl() ) ) ); - } - foreach( Podcasts::PodcastEpisodePtr episode, episodes ) - { - list.append( QVariant( QUrl( episode->playableUrl() ) ) ); - } - foreach( Playlists::PlaylistPtr playlist, playlists ) - { - list.append( QVariant( QUrl( playlist->uidUrl() ) ) ); - } - foreach( Podcasts::PodcastChannelPtr channel, channels ) - { - list.append( QVariant( QUrl( channel->url() ) ) ); - } - return QVariant( list ); - } - if( mimeType == "text/plain" && (type == QVariant::String || type == QVariant::ByteArray) ) - { - QString result; - foreach( Meta::TrackPtr track, tracks ) - { - if( !result.isEmpty() ) - result += '\n'; - result += track->artist()->prettyName(); - result += " - "; - result += track->prettyName(); - } - foreach( Podcasts::PodcastEpisodePtr episode, episodes ) - { - if( !result.isEmpty() ) - result += '\n'; - result += episode->prettyName(); - result += " - "; - result += episode->channel()->prettyName(); - } - foreach( Playlists::PlaylistPtr playlist, playlists ) - { - if( !result.isEmpty() ) - result += '\n'; - result += playlist->prettyName(); - } - foreach( Podcasts::PodcastChannelPtr channel, channels ) - { - if( !result.isEmpty() ) - result += '\n'; - result += channel->prettyName(); - } - return QVariant( result ); - } - } - return QMimeData::retrieveData( mimeType, type ); -} - -void -AmarokMimeData::startQueries() -{ - foreach( Collections::QueryMaker *qm, d->queryMakers ) - { - qm->setQueryType( Collections::QueryMaker::Track ); - connect( qm, SIGNAL(newResultReady(Meta::TrackList)), this, SLOT(newResultReady(Meta::TrackList)), Qt::QueuedConnection ); - connect( qm, SIGNAL(queryDone()), this, SLOT(queryDone()), Qt::QueuedConnection ); - qm->run(); - } -} - -void -AmarokMimeData::newResultReady( const Meta::TrackList &tracks ) -{ - Collections::QueryMaker *qm = dynamic_cast( sender() ); - if( qm ) - { - d->trackMap.insert( qm, tracks ); - } - else - d->tracks << tracks; -} - -void -AmarokMimeData::queryDone() -{ - d->completedQueries++; -} - - -#include "moc_AmarokMimeData.cpp" diff --git a/amarok/src/AmarokMimeData.h b/amarok/src/AmarokMimeData.h deleted file mode 100644 index 512308b2..00000000 --- a/amarok/src/AmarokMimeData.h +++ /dev/null @@ -1,113 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_AMAROKMIMEDATA_H -#define AMAROK_AMAROKMIMEDATA_H - -#include "amarok_export.h" -#include "amarokurls/BookmarkGroup.h" -#include "core/meta/forward_declarations.h" -#include "core/playlists/Playlist.h" -#include "core/podcasts/PodcastMeta.h" -#include "core/collections/QueryMaker.h" - -#include -#include -#include - -class AMAROK_EXPORT AmarokMimeData : public QMimeData -{ - Q_OBJECT - public: - static const QString TRACK_MIME; - static const QString PLAYLIST_MIME; - - static const QString PLAYLISTBROWSERGROUP_MIME; - - static const QString PODCASTCHANNEL_MIME; - static const QString PODCASTEPISODE_MIME; - - static const QString AMAROKURL_MIME; - static const QString BOOKMARKGROUP_MIME; - - AmarokMimeData(); - virtual ~AmarokMimeData(); - - virtual QStringList formats() const; - virtual bool hasFormat( const QString &mimeType ) const; - - Meta::TrackList tracks() const; - void setTracks( const Meta::TrackList &tracks ); - void addTracks( const Meta::TrackList &tracks ); - - Playlists::PlaylistList playlists() const; - void setPlaylists( const Playlists::PlaylistList &playlists ); - void addPlaylists( const Playlists::PlaylistList &playlists ); - - QStringList playlistGroups() const; - void setPlaylistGroups( const QStringList &groups ); - void addPlaylistGroup( const QString &group ); - - Podcasts::PodcastChannelList podcastChannels() const; - void setPodcastChannels( const Podcasts::PodcastChannelList &channels ); - void addPodcastChannels( const Podcasts::PodcastChannelList &channels ); - - Podcasts::PodcastEpisodeList podcastEpisodes() const; - void setPodcastEpisodes( const Podcasts::PodcastEpisodeList &episodes ); - void addPodcastEpisodes( const Podcasts::PodcastEpisodeList &episodes ); - - QList queryMakers(); - void addQueryMaker( Collections::QueryMaker *queryMaker ); - void setQueryMakers( const QList &queryMakers ); - - BookmarkList bookmarks() const; - void setBookmarks( const BookmarkList &bookmarks ); - void addBookmarks( const BookmarkList &bookmarks ); - - BookmarkGroupList bookmarkGroups() const; - void setBookmarkGroups( const BookmarkGroupList &groups ); - void addBookmarkGroups( const BookmarkGroupList &groups ); - - /** - There is a lot of time to run the queries while the user is dragging. - This method runs all queries passed to this object. It will do nothing if there - are no queries. - */ - void startQueries(); - - signals: - void trackListSignal( Meta::TrackList ) const; - - public slots: - void getTrackListSignal() const; - - protected: - virtual QVariant retrieveData( const QString &mimeType, QVariant::Type type ) const; - - private slots: - void newResultReady( const Meta::TrackList &tracks ); - void queryDone(); - - private: - class Private; - Private * const d; - - AmarokMimeData( const AmarokMimeData& ); - AmarokMimeData& operator=( const AmarokMimeData& ); -}; - - -#endif diff --git a/amarok/src/AmarokProcess.cpp b/amarok/src/AmarokProcess.cpp deleted file mode 100644 index 3b8f167b..00000000 --- a/amarok/src/AmarokProcess.cpp +++ /dev/null @@ -1,147 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Shane King * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "AmarokProcess.h" -#include "core/support/Debug.h" - -#include - -#include -#include -#include -#include - -AmarokProcess::AmarokProcess(QObject *parent) - : KProcess(parent), lowPriority(false) -{ - connect( this, SIGNAL(finished(int)), this, SLOT(finished()) ); - connect( this, SIGNAL(readyReadStandardOutput()), this, SLOT(readyReadStandardOutput()) ); - connect( this, SIGNAL(readyReadStandardError()), this, SLOT(readyReadStandardError()) ); -} - -/** - * Due to xine-lib, we have to make KProcess close all fds, otherwise we get "device is busy" messages - * exploiting setupChildProcess(), a virtual method that - * happens to be called in the forked process - * See bug #103750 for more information. - */ -void -AmarokProcess::setupChildProcess() -{ - KProcess::setupChildProcess(); - -#ifdef Q_OS_UNIX - // can't get at the fds that QProcess needs to keep around to do its status - // tracking , but fortunately it sets them to close on exec anyway, so if - // we do likewise to everything then we should be ok. - for(int i = sysconf(_SC_OPEN_MAX) - 1; i > 2; i--) - fcntl(i, F_SETFD, FD_CLOEXEC); - - if( lowPriority ) - setpriority( PRIO_PROCESS, 0, 19 ); -#endif -} - -void -AmarokProcess::start() -{ - KProcess::start(); - -#ifdef Q_OS_WIN32 - if( lowPriority ) - SetPriorityClass( QProcess::pid()->hProcess, IDLE_PRIORITY_CLASS ); -#endif -} - -void -AmarokProcess::finished() // SLOT -{ - emit processExited( this ); -} - -void -AmarokProcess::readyReadStandardOutput() // SLOT -{ - emit receivedStdout( this ); -} - -void -AmarokProcess::readyReadStandardError() // SLOT -{ - emit receivedStderr( this ); -} - -// AmarokProcIO -AmarokProcIO::AmarokProcIO ( QObject *parent ) - : AmarokProcess( parent ), codec( QTextCodec::codecForName( "UTF-8" ) ) -{ -} - -bool -AmarokProcIO::writeStdin (const QString &line) -{ - return write( codec->fromUnicode( line + '\n' ) ) > 0; -} - -int -AmarokProcIO::readln (QString &line) -{ - QByteArray bytes = readLine(); - if (bytes.length() == 0) - { - return -1; - } - else - { - // convert and remove \n - line = codec->toUnicode( bytes.data(), bytes.length() - 1); - return line.length(); - } -} - -void -AmarokProcIO::start() -{ - connect (this, SIGNAL (readyReadStandardOutput()), this, SLOT (readyReadStandardOutput())); - - KProcess::start (); -} - -void -AmarokProcIO::readyReadStandardOutput() -{ - if( canReadLine() ) - emit readReady( this ); -} - -// AmarokShellProcess -AmarokShellProcess & -AmarokShellProcess::operator<<(const QString& arg) -{ - if( program().isEmpty() ) - setShellCommand( arg ); - else - AmarokProcess::operator<<( arg ); - return *this; -} - -AmarokShellProcess & -AmarokShellProcess::operator<<(const QStringList& args) -{ - foreach( const QString &arg, args ) - *this << arg; - return *this; -} diff --git a/amarok/src/AmarokProcess.h b/amarok/src/AmarokProcess.h deleted file mode 100644 index bb9acac5..00000000 --- a/amarok/src/AmarokProcess.h +++ /dev/null @@ -1,101 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Shane King * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_PROCESS_H -#define AMAROK_PROCESS_H - -#include "amarok_export.h" - -#include - -class QTextCodec; - -// Classes needed to wrap some KProcess stuff to make it more like K3Process -// Also need to close fds on fork under unix - -//////////////////////////////////////////////////////////////////////////////// -// class Process -//////////////////////////////////////////////////////////////////////////////// - -class AMAROK_EXPORT AmarokProcess : public KProcess -{ - Q_OBJECT - - public: - explicit AmarokProcess(QObject *parent = 0); - - void setLowPriority(bool lowPriority) { this->lowPriority = lowPriority; } - - void start(); - - // for K3Process compat - Q_SIGNALS: - void processExited(AmarokProcess *proc); - void receivedStdout(AmarokProcess *proc); - void receivedStderr(AmarokProcess *proc); - - protected: - virtual void setupChildProcess(); - - private slots: - void finished(); - void readyReadStandardOutput(); - void readyReadStandardError(); - - private: - bool lowPriority; -}; - -//////////////////////////////////////////////////////////////////////////////// -// class ProcIO -//////////////////////////////////////////////////////////////////////////////// - -class AMAROK_EXPORT AmarokProcIO : public AmarokProcess -{ - Q_OBJECT - - public: - explicit AmarokProcIO(QObject *parent = 0); - - int readln (QString &line); - bool writeStdin(const QString &line); - - void start(); - - Q_SIGNALS: - void readReady(AmarokProcIO *pio); - - private slots: - void readyReadStandardOutput(); - - private: - QTextCodec *codec; -}; - -//////////////////////////////////////////////////////////////////////////////// -// class ShellProcess -//////////////////////////////////////////////////////////////////////////////// - -class AMAROK_EXPORT AmarokShellProcess : public AmarokProcess -{ - public: - explicit AmarokShellProcess(QObject *parent = 0) : AmarokProcess(parent) {} - - AmarokShellProcess &operator<<(const QString& arg); - AmarokShellProcess &operator<<(const QStringList& args); -}; - -#endif // AMAROK_PROCESS_H diff --git a/amarok/src/App.cpp b/amarok/src/App.cpp deleted file mode 100644 index 9e51cc08..00000000 --- a/amarok/src/App.cpp +++ /dev/null @@ -1,644 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2002 Mark Kretschmann * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "App.h" - -#include -#include "EngineController.h" -#include "KNotificationBackend.h" -#include "PluginManager.h" -#include "scripting/scriptmanager/ScriptManager.h" -#include "TrayIcon.h" -#include "amarokconfig.h" -#include "amarokurls/AmarokUrl.h" -#include "configdialog/ConfigDialog.h" -#include "configdialog/dialogs/PlaybackConfig.h" -#include "core/capabilities/SourceInfoCapability.h" -#include "core/interfaces/Logger.h" -#include "core/meta/Meta.h" -#include "core/meta/support/MetaConstants.h" -#include "core/meta/support/MetaUtility.h" -#include "core/playlists/Playlist.h" -#include "core/playlists/PlaylistFormat.h" -#include "core/podcasts/PodcastProvider.h" -#include "core/support/Amarok.h" -#include "core/support/Components.h" -#include "core/support/Debug.h" -#include "core/transcoding/TranscodingController.h" -#include "core-impl/collections/support/CollectionManager.h" -#include "core-impl/playlists/types/file/PlaylistFileSupport.h" -#include "core-impl/storage/StorageManager.h" -#include "covermanager/CoverCache.h" -#include "covermanager/CoverFetcher.h" -#include "dbus/CollectionDBusHandler.h" -#include "dbus/mpris1/PlayerHandler.h" -#include "dbus/mpris1/RootHandler.h" -#include "dbus/mpris1/TrackListHandler.h" -#include "dbus/mpris2/Mpris2.h" -#include "network/NetworkAccessManagerProxy.h" -#include "playlist/PlaylistActions.h" -#include "playlist/PlaylistController.h" -#include "playlist/PlaylistModelStack.h" -#include "playlistmanager/PlaylistManager.h" -#include "services/ServicePluginManager.h" -#include "scripting/scriptconsole/ScriptConsole.h" -#include "statemanagement/ApplicationController.h" -#include "statemanagement/DefaultApplicationController.h" -#include "statsyncing/Controller.h" -#include "widgets/Osd.h" - -#include - -#include -#include -#include //initCliArgs() -#include -#include //slotConfigToolbars() -#include -#include -#include -#include -#include -#include -#include //slotConfigShortcuts() -#include - -#include -#include -#include -#include -#include // for Qt::escape() -#include //showHyperThreadingWarning() -#include - -#ifdef Q_WS_MAC -#include -extern void setupEventHandler_mac(SRefCon); -#endif - -QStringList App::s_delayedAmarokUrls = QStringList(); -AMAROK_EXPORT OcsData ocsData( "opendesktop" ); - -App::App() - : KUniqueApplication() - , m_tray(0) -{ - DEBUG_BLOCK - PERF_LOG( "Begin Application ctor" ) - - // required for last.fm plugin to grab app version - setApplicationVersion( AMAROK_VERSION ); - - qRegisterMetaType(); - qRegisterMetaType(); - qRegisterMetaType(); - qRegisterMetaType(); - qRegisterMetaType(); - qRegisterMetaType(); - qRegisterMetaType(); - qRegisterMetaType(); - qRegisterMetaType(); - qRegisterMetaType(); - qRegisterMetaType(); - qRegisterMetaType(); - qRegisterMetaType(); - qRegisterMetaType(); - qRegisterMetaType(); - qRegisterMetaType(); - qRegisterMetaType(); - qRegisterMetaType(); - - -#ifdef Q_WS_MAC - // this is inspired by OpenSceneGraph: osgDB/FilePath.cpp - - // Start with the Bundle PlugIns directory. - - // Get the main bundle first. No need to retain or release it since - // we are not keeping a reference - CFBundleRef myBundle = CFBundleGetMainBundle(); - if( myBundle ) - { - // CFBundleGetMainBundle will return a bundle ref even if - // the application isn't part of a bundle, so we need to - // check - // if the path to the bundle ends in ".app" to see if it is - // a - // proper application bundle. If it is, the plugins path is - // added - CFURLRef urlRef = CFBundleCopyBundleURL(myBundle); - if(urlRef) - { - char bundlePath[1024]; - if( CFURLGetFileSystemRepresentation( urlRef, true, (UInt8 *)bundlePath, sizeof(bundlePath) ) ) - { - QByteArray bp( bundlePath ); - size_t len = bp.length(); - if( len > 4 && bp.right( 4 ) == ".app" ) - { - bp.append( "/Contents/MacOS" ); - QByteArray path = qgetenv( "PATH" ); - if( path.length() > 0 ) - { - path.prepend( ":" ); - } - path.prepend( bp ); - debug() << "setting PATH=" << path; - setenv("PATH", path, 1); - } - } - // docs say we are responsible for releasing CFURLRef - CFRelease(urlRef); - } - } - - setupEventHandler_mac(this); -#endif - - PERF_LOG( "Done App ctor" ) - - continueInit(); -} - -App::~App() -{ - DEBUG_BLOCK - - CollectionManager::instance()->stopScan(); - - // Hiding the OSD before exit prevents crash - Amarok::OSD::instance()->hide(); - - // This following can't go in the PlaylistModel destructor, because by the time that - // happens, the Config has already been written. - - // Use the bottom model because that provides the most dependable/invariable row - // number to save in an external file. - AmarokConfig::setLastPlaying( Playlist::ModelStack::instance()->bottom()->activeRow() ); - - if ( AmarokConfig::resumePlayback() ) - { - Meta::TrackPtr engineTrack = The::engineController()->currentTrack(); - if( engineTrack ) - { - AmarokConfig::setResumeTrack( engineTrack->playableUrl().prettyUrl() ); - AmarokConfig::setResumeTime( The::engineController()->trackPositionMs() ); - AmarokConfig::setResumePaused( The::engineController()->isPaused() ); - } - else - AmarokConfig::setResumeTrack( QString() ); //otherwise it'll play previous resume next time! - } - - The::engineController()->endSession(); //records final statistics - -#ifndef Q_WS_MAC - // do even if trayicon is not shown, it is safe - Amarok::config().writeEntry( "HiddenOnExit", mainWindow()->isHidden() ); - AmarokConfig::self()->writeConfig(); -#else - // for some reason on OS X the main window always reports being hidden - // this means if you have the tray icon enabled, amarok will always open minimized - Amarok::config().writeEntry( "HiddenOnExit", false ); - AmarokConfig::self()->writeConfig(); -#endif - - ScriptManager::destroy(); - - // this must be deleted before the connection to the Xserver is - // severed, or we risk a crash when the QApplication is exited, - // I asked Trolltech! *smug* - Amarok::OSD::destroy(); - Amarok::KNotificationBackend::destroy(); - - AmarokConfig::self()->writeConfig(); - - //mainWindow()->deleteBrowsers(); - delete mainWindow(); - - Playlist::Controller::destroy(); - Playlist::ModelStack::destroy(); - Playlist::Actions::destroy(); - PlaylistManager::destroy(); - CoverFetcher::destroy(); - CoverCache::destroy(); - ServicePluginManager::destroy(); - CollectionManager::destroy(); - StorageManager::destroy(); - NetworkAccessManagerProxy::destroy(); - Plugins::PluginManager::destroy(); - - //this should be moved to App::quit() I guess - Amarok::Components::applicationController()->shutdown(); - -#ifdef Q_WS_WIN - // work around for KUniqueApplication being not completely implemented on windows - QDBusConnectionInterface* dbusService; - if (QDBusConnection::sessionBus().isConnected() && (dbusService = QDBusConnection::sessionBus().interface())) - { - dbusService->unregisterService("org.mpris.amarok"); - dbusService->unregisterService("org.mpris.MediaPlayer2.amarok"); - } -#endif -} - -void -App::handleCliArgs() //static -{ - DEBUG_BLOCK - - KCmdLineArgs* const args = KCmdLineArgs::parsedArgs(); - - if( args->isSet( "cwd" ) ) - KCmdLineArgs::setCwd( args->getOption( "cwd" ).toLocal8Bit() ); - - bool haveArgs = true; // assume having args in first place - if( args->count() > 0 ) - { - KUrl::List list; - for( int i = 0; i < args->count(); i++ ) - { - KUrl url = args->url( i ); - //TODO:PORTME - if( Podcasts::PodcastProvider::couldBeFeed( url.url() ) ) - { - KUrl feedUrl = Podcasts::PodcastProvider::toFeedUrl( url.url() ); - The::playlistManager()->defaultPodcasts()->addPodcast( feedUrl ); - } - else if( url.protocol() == "amarok" ) - s_delayedAmarokUrls.append( url.url() ); - else - list << url; - } - - Playlist::AddOptions options; - if( args->isSet( "queue" ) ) - options = Playlist::OnQueueToPlaylistAction; - else if( args->isSet( "append" ) ) - options = Playlist::OnAppendToPlaylistAction; - else if( args->isSet( "load" ) ) - options = Playlist::OnReplacePlaylistAction; - else - options = Playlist::OnPlayMediaAction; - - The::playlistController()->insertOptioned( list, options ); - } - else if ( args->isSet( "cdplay" ) ) - The::mainWindow()->playAudioCd(); - - //we shouldn't let the user specify two of these since it is pointless! - //so we prioritise, pause > stop > play > next > prev - //thus pause is the least destructive, followed by stop as brakes are the most important bit of a car(!) - //then the others seemed sensible. Feel free to modify this order, but please leave justification in the cvs log - //I considered doing some sanity checks (eg only stop if paused or playing), but decided it wasn't worth it - else if ( args->isSet( "pause" ) ) - The::engineController()->pause(); - else if ( args->isSet( "stop" ) ) - The::engineController()->stop(); - else if ( args->isSet( "play-pause" ) ) - The::engineController()->playPause(); - else if ( args->isSet( "play" ) ) //will restart if we are playing - The::engineController()->play(); - else if ( args->isSet( "next" ) ) - The::playlistActions()->next(); - else if ( args->isSet( "previous" ) ) - The::playlistActions()->back(); - else // no args given - haveArgs = false; - - static bool firstTime = true; - - //allows debugging on OS X. Bundles have to be started with "open". Therefore it is not possible to pass an argument - const bool forceDebug = Amarok::config().readEntry( "Force Debug", false ); - - if( firstTime && !Debug::debugEnabled() && !forceDebug ) - { - qDebug() << "**********************************************************************************************"; - qDebug() << "** AMAROK WAS STARTED IN NORMAL MODE. IF YOU WANT TO SEE DEBUGGING INFORMATION, PLEASE USE: **"; - qDebug() << "** amarok --debug **"; - qDebug() << "**********************************************************************************************"; - } - - if( !firstTime && !haveArgs ) - { - // mainWindow() can be 0 if another instance is loading, see https://bugs.kde.org/show_bug.cgi?id=202713 - if( pApp->mainWindow() ) - pApp->mainWindow()->activate(); - } - - firstTime = false; - args->clear(); //free up memory -} - - -///////////////////////////////////////////////////////////////////////////////////// -// INIT -///////////////////////////////////////////////////////////////////////////////////// - -void -App::initCliArgs() //static -{ - // Update main.cpp (below KUniqueApplication::start() wrt instanceOptions) aswell if needed! - KCmdLineOptions options; - - options.add("+[URL(s)]", ki18n( "Files/URLs to open" )); - options.add("cdplay", ki18n("Immediately start playing an audio cd")); - options.add("r"); - options.add("previous", ki18n( "Skip backwards in playlist" )); - options.add("p"); - options.add("play", ki18n( "Start playing current playlist" )); - options.add("t"); - options.add("play-pause", ki18n( "Play if stopped, pause if playing" )); - options.add("pause", ki18n( "Pause playback" )); - options.add("s"); - options.add("stop", ki18n( "Stop playback" )); - options.add("f"); - options.add("next", ki18n( "Skip forwards in playlist" )); - options.add(":", ki18n("Additional options:")); - options.add("a"); - options.add("append", ki18n( "Append files/URLs to playlist" )); - options.add("queue", ki18n("Queue URLs after the currently playing track")); - options.add("l"); - options.add("load", ki18n("Load URLs, replacing current playlist")); - options.add("d"); - options.add("debug", ki18n("Print verbose debugging information")); - options.add("debug-audio", ki18n("Print verbose debugging information from the audio system")); - options.add("c"); - options.add("coloroff", ki18n("Disable colorization for debug output.")); - options.add("m"); - options.add("multipleinstances", ki18n("Allow running multiple Amarok instances")); - options.add("cwd ", ki18n( "Base for relative filenames/URLs" )); - - KCmdLineArgs::addCmdLineOptions( options ); //add our own options -} - - -///////////////////////////////////////////////////////////////////////////////////// -// METHODS -///////////////////////////////////////////////////////////////////////////////////// - - -//SLOT -void App::applySettings( bool firstTime ) -{ - ///Called when the configDialog is closed with OK or Apply - - DEBUG_BLOCK - - if( AmarokConfig::showTrayIcon() && ! m_tray ) - { - m_tray = new Amarok::TrayIcon( m_mainWindow.data() ); - } - else if( !AmarokConfig::showTrayIcon() && m_tray ) - { - delete m_tray; - m_tray = 0; - } - - if( !firstTime ) // prevent OSD from popping up during startup - Amarok::OSD::instance()->applySettings(); - - if( !firstTime ) - emit settingsChanged(); - - if( AmarokConfig::enableScriptConsole() && !m_scriptConsole ) - m_scriptConsole = ScriptConsoleNS::ScriptConsole::instance(); - else if( !AmarokConfig::enableScriptConsole() && m_scriptConsole ) - m_scriptConsole.data()->deleteLater(); -} - -//SLOT -void -App::continueInit() -{ - DEBUG_BLOCK - - PERF_LOG( "Begin App::continueInit" ) - const KCmdLineArgs* const args = KCmdLineArgs::parsedArgs(); - const bool restoreSession = args->count() == 0 || args->isSet( "append" ) - || args->isSet( "queue" ) - || Amarok::config().readEntry( "AppendAsDefault", false ); - - QTextCodec* utf8codec = QTextCodec::codecForName( "UTF-8" ); - QTextCodec::setCodecForCStrings( utf8codec ); //We need this to make CollectionViewItem showing the right characters. - - new Amarok::DefaultApplicationController( this ); - Amarok::Components::applicationController()->start(); - - // Instantiate statistics synchronization controller. Needs to be before creating - // MainWindow as MainWindow connects a signal to StatSyncing::Controller. - Amarok::Components::setStatSyncingController( new StatSyncing::Controller( this ) ); - - PERF_LOG( "Creating MainWindow" ) - m_mainWindow = new MainWindow(); - PERF_LOG( "Done creating MainWindow" ) - - if( AmarokConfig::showTrayIcon() ) - m_tray = new Amarok::TrayIcon( mainWindow() ); - - PERF_LOG( "Creating DBus handlers" ) - new Mpris1::RootHandler(); - new Mpris1::PlayerHandler(); - new Mpris1::TrackListHandler(); - QDBusConnection::sessionBus().registerService("org.mpris.amarok"); - new CollectionDBusHandler( this ); - new Amarok::Mpris2( this ); - PERF_LOG( "Done creating DBus handlers" ) - - //DON'T DELETE THIS NEXT LINE or the app crashes when you click the X (unless we reimplement closeEvent) - //Reason: in ~App we have to call the deleteBrowsers method or else we run afoul of refcount foobar in KHTMLPart - //But if you click the X (not Action->Quit) it automatically kills MainWindow because KMainWindow sets this - //for us as default (bad KMainWindow) - mainWindow()->setAttribute( Qt::WA_DeleteOnClose, false ); - //init playlist window as soon as the database is guaranteed to be usable - - // Create engine, show TrayIcon etc. - applySettings( true ); - - // Must be created _after_ MainWindow. - PERF_LOG( "Starting ScriptManager" ) - ScriptManager::instance(); - PERF_LOG( "ScriptManager started" ) - - The::engineController()->setVolume( AmarokConfig::masterVolume() ); - The::engineController()->setMuted( AmarokConfig::muteState() ); - - Amarok::KNotificationBackend::instance()->setEnabled( AmarokConfig::kNotifyEnabled() ); - Amarok::OSD::instance()->applySettings(); // Create after setting volume (don't show OSD for that) - - // Restore keyboard shortcuts etc from config - Amarok::actionCollection()->readSettings(); - - //on startup we need to show the window, but only if it wasn't hidden on exit - //and always if the trayicon isn't showing - if( !Amarok::config().readEntry( "HiddenOnExit", false ) || !AmarokConfig::showTrayIcon() ) - { - PERF_LOG( "showing main window again" ) - m_mainWindow.data()->show(); - PERF_LOG( "after showing mainWindow" ) - } - - //Instantiate the Transcoding::Controller, this fires up an asynchronous KProcess with - //FFmpeg which should not take more than ~200msec. - Amarok::Components::setTranscodingController( new Transcoding::Controller( this ) ); - - PERF_LOG( "App init done" ) - - // check that the amarok sql configuration is valid. - if( !StorageManager::instance()->getLastErrors().isEmpty() ) - { - KMessageBox::error( The::mainWindow(), i18n( "The amarok database reported " - "the following errors:\n%1\nIn most cases you will need to resolve " - "these errors before Amarok will run properly." ). - arg( StorageManager::instance()->getLastErrors().join( "\n" ) ), - i18n( "Database Error" )); - StorageManager::instance()->clearLastErrors(); - slotConfigAmarok( "DatabaseConfig" ); - } - else - { - handleFirstRun(); - } - - - if( AmarokConfig::resumePlayback() && restoreSession && !args->isSet( "stop" ) ) { - //restore session as long as the user didn't specify media to play etc. - //do this after applySettings() so OSD displays correctly - The::engineController()->restoreSession(); - } - //and now we can run any amarokurls provided on startup, as all components should be initialized by now! - foreach( const QString& urlString, s_delayedAmarokUrls ) - { - AmarokUrl aUrl( urlString ); - aUrl.run(); - } - s_delayedAmarokUrls.clear(); -} - -void App::slotConfigAmarok( const QString& page ) -{ - KConfigDialog *dialog = KConfigDialog::exists( "settings" ); - if( !dialog ) - { - //KConfigDialog didn't find an instance of this dialog, so lets create it : - dialog = new Amarok2ConfigDialog( mainWindow(), "settings", AmarokConfig::self() ); - connect( dialog, SIGNAL(settingsChanged(QString)), SLOT(applySettings()) ); - } - static_cast( dialog )->show( page ); -} - -void App::slotConfigShortcuts() -{ - KShortcutsDialog::configure( Amarok::actionCollection(), KShortcutsEditor::LetterShortcutsAllowed, mainWindow() ); - AmarokConfig::self()->writeConfig(); -} - -KIO::Job *App::trashFiles( const KUrl::List &files ) -{ - KIO::Job *job = KIO::trash( files ); - Amarok::Components::logger()->newProgressOperation( job, i18n("Moving files to trash") ); - connect( job, SIGNAL(result(KJob*)), this, SLOT(slotTrashResult(KJob*)) ); - return job; -} - -void App::slotTrashResult( KJob *job ) -{ - if( job->error() ) - job->uiDelegate()->showErrorMessage(); -} - -void App::quit() -{ - DEBUG_BLOCK - The::playlistManager()->completePodcastDownloads(); - - // Following signal is relayed to scripts, which may block quitting for a while - emit prepareToQuit(); - KApplication::quit(); -} - -bool App::event( QEvent *event ) -{ - switch( event->type() ) - { - //allows Amarok to open files from the finder on OS X - case QEvent::FileOpen: - { - QString file = static_cast( event )->file(); - The::playlistController()->insertOptioned( KUrl( file ), Playlist::OnPlayMediaAction ); - return true; - } - default: - return KUniqueApplication::event( event ); - } -} - -int App::newInstance() -{ - DEBUG_BLOCK - - static bool first = true; - if ( isSessionRestored() && first ) - { - first = false; - return 0; - } - - first = false; - - handleCliArgs(); - return 0; -} - -void App::handleFirstRun() -{ - KConfigGroup config = KGlobal::config()->group( "General" ); - if( !config.readEntry( "First Run", true ) ) - return; - - const KUrl musicUrl = QDesktopServices::storageLocation( QDesktopServices::MusicLocation ); - const QString musicDir = musicUrl.toLocalFile( KUrl::RemoveTrailingSlash ); - const QDir dir( musicDir ); - - int result = KMessageBox::No; - if( dir.exists() && dir.isReadable() ) - { - result = KMessageBox::questionYesNoCancel( mainWindow(), i18n( "A music path, " - "%1, is set in System Settings.\nWould you like to use that as a " - "collection folder?", musicDir ) ); - } - - switch( result ) - { - case KMessageBox::Yes: - { - Collections::Collection *coll = CollectionManager::instance()->primaryCollection(); - if( coll ) - { - coll->setProperty( "collectionFolders", QStringList() << musicDir ); - CollectionManager::instance()->startFullScan(); - } - break; - } - case KMessageBox::No: - slotConfigAmarok( "CollectionConfig" ); - break; - default: - break; - } - config.writeEntry( "First Run", false ); -} - -#include "moc_App.cpp" diff --git a/amarok/src/App.h b/amarok/src/App.h deleted file mode 100644 index 2d1493e5..00000000 --- a/amarok/src/App.h +++ /dev/null @@ -1,108 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2002 Mark Kretschmann * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_APP_H -#define AMAROK_APP_H - -#include "MainWindow.h" -#include "amarok_export.h" -#include -#include "aboutdialog/OcsData.h" - -#include -#include //baseclass -#include - -#include -#include -#include - -namespace Amarok { - class TrayIcon; -} - -namespace ScriptConsoleNS{ - class ScriptConsole; -} - -class OcsData; - -namespace KIO { class Job; } - -class KJob; -class MediaDeviceManager; - -class AMAROK_EXPORT App : public KUniqueApplication -{ - Q_OBJECT - - public: - App(); - ~App(); - - static App *instance() { return static_cast( kapp ); } - - void setUniqueInstance( bool isUnique ) { m_isUniqueInstance = isUnique; } - bool isNonUniqueInstance() const { return m_isUniqueInstance; } - - Amarok::TrayIcon* trayIcon() const { return m_tray; } - static void handleCliArgs(); - static void initCliArgs(); - - virtual int newInstance(); - - inline MainWindow *mainWindow() const { return m_mainWindow.data(); } - - // FRIENDS - friend class MainWindow; //requires access to applySettings() - - signals: - void prepareToQuit(); - void settingsChanged(); - - private slots: - void continueInit(); - - public slots: - void applySettings( bool firstTime = false ); - void slotConfigAmarok( const QString& page = QString() ); - void slotConfigShortcuts(); - KIO::Job *trashFiles( const KUrl::List &files ); - void quit(); - - protected: - virtual bool event( QEvent *event ); - - private slots: - void slotTrashResult( KJob *job ); - - private: - void handleFirstRun(); - - // ATTRIBUTES - bool m_isUniqueInstance; - QWeakPointer m_mainWindow; - Amarok::TrayIcon *m_tray; - MediaDeviceManager *m_mediaDeviceManager; - QWeakPointer m_scriptConsole; - - static QStringList s_delayedAmarokUrls; -}; - -#define pApp static_cast(kapp) - - -#endif // AMAROK_APP_H diff --git a/amarok/src/CMakeLists.txt b/amarok/src/CMakeLists.txt deleted file mode 100644 index 1c2e8d05..00000000 --- a/amarok/src/CMakeLists.txt +++ /dev/null @@ -1,934 +0,0 @@ -# Improves speed of string concatenation -add_definitions(-DQT_USE_FAST_CONCATENATION) -add_definitions(-DQT_USE_FAST_OPERATOR_PLUS) -if(NOT MSVC) - add_definitions(-DQT_STRICT_ITERATORS) -endif(NOT MSVC) - -include_directories( - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_BINARY_DIR} -) - -add_subdirectory( core ) -add_subdirectory( core-impl/collections ) -add_subdirectory( core-impl/storage/sql ) -#don't use our own libplasma anymore, but still pick up our applets/engines/containments -add_subdirectory( context ) -add_subdirectory( services ) -add_subdirectory( scripting/scripts ) -add_subdirectory( aboutdialog/libattica-ocsclient ) -add_subdirectory( transcoding ) -add_subdirectory( importers ) - -##################################################################### -# PROXYCOLLECTION -##################################################################### -set(aggregatecollection_SRCS - core-impl/collections/aggregate/AggregateCollection.cpp - core-impl/collections/aggregate/AggregateMeta.cpp - core-impl/collections/aggregate/AggregateQueryMaker.cpp -) - -##################################################################### -# MEDIADEVICEFRAMEWORK -##################################################################### -set(libmediadeviceframework_SRCS - core-impl/collections/mediadevicecollection/MediaDeviceCollection.cpp - core-impl/collections/mediadevicecollection/MediaDeviceCollectionLocation.cpp - core-impl/collections/mediadevicecollection/MediaDeviceMeta.cpp - core-impl/collections/mediadevicecollection/MediaDeviceTrackEditor.cpp - core-impl/collections/mediadevicecollection/handler/MediaDeviceHandler.cpp - core-impl/collections/mediadevicecollection/handler/MediaDeviceHandlerCapability.cpp - core-impl/collections/mediadevicecollection/handler/capabilities/ArtworkCapability.cpp - core-impl/collections/mediadevicecollection/handler/capabilities/PlaylistCapability.cpp - core-impl/collections/mediadevicecollection/handler/capabilities/PodcastCapability.cpp - core-impl/collections/mediadevicecollection/handler/capabilities/ReadCapability.cpp - core-impl/collections/mediadevicecollection/handler/capabilities/WriteCapability.cpp - core-impl/collections/mediadevicecollection/playlist/MediaDevicePlaylist.cpp - core-impl/collections/mediadevicecollection/playlist/MediaDeviceUserPlaylistProvider.cpp - core-impl/collections/mediadevicecollection/podcast/MediaDevicePodcastProvider.cpp - core-impl/collections/mediadevicecollection/support/ConnectionAssistant.cpp - core-impl/collections/mediadevicecollection/support/MediaDeviceInfo.cpp -) - -##################################################################### -# SERVICEFRAMEWORK -##################################################################### -set(libserviceframework_SRCS - services/DynamicServiceQueryMaker.cpp - services/InfoParserBase.cpp - services/ServiceAlbumCoverDownloader.cpp - services/ServiceBase.cpp - services/ServiceCapabilities.cpp - services/ServiceCollection.cpp - services/ServiceCollectionLocation.cpp - services/ServiceCollectionTreeView.cpp - services/ServiceMetaBase.cpp - services/ServicePluginManager.cpp - services/ServiceSqlCollection.cpp - services/ServiceSqlQueryMaker.cpp - services/ServiceSqlRegistry.cpp -) - -##################################################################### -# SERVICEBROWSER -##################################################################### -set(libservicebrowser_SRCS - browsers/servicebrowser/ServiceBrowser.cpp -) - -##################################################################### -# AMAROKURL -##################################################################### -set(libamarokurl_SRCS - amarokurls/AmarokUrl.cpp - amarokurls/AmarokUrlAction.cpp - amarokurls/AmarokUrlHandler.cpp - amarokurls/BookmarkCurrentButton.cpp - amarokurls/ContextUrlGenerator.cpp - amarokurls/ContextUrlRunner.cpp - amarokurls/NavigationUrlRunner.cpp - amarokurls/NavigationUrlGenerator.cpp - amarokurls/PlayUrlRunner.cpp - amarokurls/PlayUrlGenerator.cpp - amarokurls/BookmarkManager.cpp - amarokurls/BookmarkManagerWidget.cpp - amarokurls/BookmarkGroup.cpp - amarokurls/BookmarkModel.cpp - amarokurls/BookmarkTreeView.cpp - amarokurls/BookmarkMetaActions.cpp - ) - -##################################################################### -# SCRIPTABLESERVICE -##################################################################### -set(libscriptableservice_SRCS - services/scriptable/ScriptableService.cpp - services/scriptable/ScriptableServiceCollection.cpp - services/scriptable/ScriptableServiceCollectionTreeModel.cpp - services/scriptable/ScriptableServiceInfoParser.cpp - services/scriptable/ScriptableServiceManager.cpp - services/scriptable/ScriptableServiceMeta.cpp - services/scriptable/ScriptableServiceQueryMaker.cpp -) - -##################################################################### -# CONFIGDIALOG -##################################################################### -set(libconfigdialog_SRCS - configdialog/ConfigDialog.cpp - configdialog/ConfigDialogBase.cpp - configdialog/dialogs/CollectionConfig.cpp - configdialog/dialogs/ExcludedLabelsDialog.cpp - configdialog/dialogs/GeneralConfig.cpp - configdialog/dialogs/MetadataConfig.cpp - configdialog/dialogs/NotificationsConfig.cpp - configdialog/dialogs/PlaybackConfig.cpp - configdialog/dialogs/PluginsConfig.cpp - configdialog/dialogs/ScriptsConfig.cpp - configdialog/dialogs/ScriptSelector.cpp - configdialog/dialogs/DatabaseConfig.cpp - dialogs/CollectionConfig.ui - configdialog/dialogs/GeneralConfig.ui - configdialog/dialogs/MetadataConfig.ui - configdialog/dialogs/ExcludedLabelsDialog.ui - configdialog/dialogs/NotificationsConfig.ui - configdialog/dialogs/PlaybackConfig.ui - configdialog/dialogs/DatabaseConfig.ui - configdialog/dialogs/ScriptsConfig.ui -) - -set(libbrowserframework_SRCS - browsers/BrowserBreadcrumbItem.cpp - browsers/BrowserBreadcrumbWidget.cpp - browsers/BrowserCategory.cpp - browsers/BrowserCategoryList.cpp - browsers/BrowserCategoryListModel.cpp - browsers/BrowserCategoryListSortFilterProxyModel.cpp - browsers/BrowserDock.cpp - browsers/BrowserMessageArea.cpp - browsers/CollectionSortFilterProxyModel.cpp - browsers/CollectionTreeItem.cpp - browsers/CollectionTreeItemModel.cpp - browsers/CollectionTreeItemModelBase.cpp - browsers/CollectionTreeView.cpp - browsers/InfoProxy.cpp - browsers/SingleCollectionTreeItemModel.cpp -) - -##################################################################### -# COLLECTIONBROWSER -##################################################################### -set(libcollectionbrowser_SRCS - browsers/collectionbrowser/CollectionBrowserTreeView.cpp - browsers/collectionbrowser/CollectionWidget.cpp -) - -##################################################################### -# SYNCHRONIZATION -##################################################################### -set(libsynchronization_SRCS - synchronization/MasterSlaveSynchronizationJob.cpp - synchronization/OneWaySynchronizationJob.cpp - synchronization/SynchronizationBaseJob.cpp - synchronization/UnionJob.cpp -) - -##################################################################### -# STATUSBAR -##################################################################### -set(libstatusbar_SRCS - statusbar/ProgressBar.cpp - statusbar/KJobProgressBar.cpp - statusbar/NetworkProgressBar.cpp - statusbar/CompoundProgressBar.cpp - statusbar/PopupWidget.cpp - statusbar/LongMessageWidget.cpp -) - - -##################################################################### -# META -##################################################################### -set(libmetaimpl_SRCS - core-impl/playlists/providers/user/UserPlaylistProvider.cpp - core-impl/playlists/types/file/asx/ASXPlaylist.cpp - core-impl/playlists/types/file/m3u/M3UPlaylist.cpp - core-impl/playlists/types/file/pls/PLSPlaylist.cpp - core-impl/playlists/types/file/PlaylistFileLoaderJob.cpp - core-impl/playlists/types/file/PlaylistFileSupport.cpp - core-impl/playlists/types/file/xspf/XSPFPlaylist.cpp - core-impl/capabilities/AlbumActionsCapability.cpp - core-impl/capabilities/timecode/TimecodeBoundedPlaybackCapability.cpp - core-impl/capabilities/timecode/TimecodeLoadCapability.cpp - core-impl/capabilities/timecode/TimecodeWriteCapability.cpp - core-impl/capabilities/multisource/MultiSourceCapabilityImpl.cpp - core-impl/meta/file/File.cpp - core-impl/meta/file/FileTrackProvider.cpp - core-impl/meta/multi/MultiTrack.cpp - core-impl/meta/cue/CueFileSupport.cpp - core-impl/meta/proxy/MetaProxy.cpp - core-impl/meta/proxy/MetaProxyWorker.cpp - core-impl/meta/stream/Stream.cpp - core-impl/playlists/types/file/PlaylistFile.cpp - core-impl/support/PersistentStatisticsStore.cpp - core-impl/support/TagStatisticsStore.cpp - core-impl/support/UrlStatisticsStore.cpp -) - -##################################################################### -# COLLECTION -##################################################################### -set(collection_SRCS - core-impl/collections/support/jobs/WriteTagsJob.cpp - core-impl/collections/support/ArtistHelper.cpp - core-impl/collections/support/CollectionManager.cpp - core-impl/collections/support/CollectionLocationDelegateImpl.cpp - core-impl/collections/support/MemoryCustomValue.cpp - core-impl/collections/support/MemoryFilter.cpp - core-impl/collections/support/MemoryMatcher.cpp - core-impl/collections/support/MemoryMeta.cpp - core-impl/collections/support/MemoryQueryMaker.cpp - core-impl/collections/support/MemoryQueryMakerInternal.cpp - core-impl/collections/support/MemoryQueryMakerHelper.cpp - core-impl/collections/support/TrashCollectionLocation.cpp - core-impl/collections/support/XmlQueryReader.cpp - core-impl/collections/support/FileCollectionLocation.cpp - core-impl/collections/support/Expression.cpp - core-impl/collections/support/TextualQueryFilter.cpp -) - -##################################################################### -# STORAGE -##################################################################### -set(storage_SRCS - core-impl/storage/StorageManager.cpp -) - -##################################################################### -# SCANNER -##################################################################### -set( scanner_SRCS - scanner/GenericScanManager.cpp - scanner/GenericScannerJob.cpp - scanner/AbstractDirectoryWatcher.cpp - scanner/AbstractScanResultProcessor.cpp -) - -##################################################################### -# CONTEXT -##################################################################### -set( libcontextview_SRCS - context/Applet.cpp - context/Containment.cpp - context/ContextObserver.cpp - context/ContextScene.cpp - context/ContextDock.cpp - context/ContextView.cpp - context/LyricsManager.cpp - context/ToolbarView.cpp - context/toolbar/AppletItemOverlay.cpp - context/toolbar/AppletToolbar.cpp - context/toolbar/AppletToolbarAddItem.cpp - context/toolbar/AppletToolbarAppletItem.cpp - context/toolbar/AppletToolbarBase.cpp - context/toolbar/AppletToolbarConfigItem.cpp - context/widgets/AppletHeader.cpp - context/widgets/RatingWidget.cpp - context/widgets/TextScrollingWidget.cpp - context/widgets/DropPixmapItem.cpp - context/widgets/ToolBoxIcon.cpp - # context/widgets/ContainmentArrow.cpp - # context/widgets/ContainmentSelectionLayer.cpp - context/widgets/appletexplorer/AppletExplorer.cpp - context/widgets/appletexplorer/AppletIcon.cpp - context/widgets/RecentlyPlayedListWidget.cpp -) - -##################################################################### -# PODCASTS -##################################################################### -set(libpodcasts_SRCS - core-impl/podcasts/sql/SqlPodcastMeta.cpp - core-impl/podcasts/sql/SqlPodcastProvider.cpp - core-impl/podcasts/sql/PodcastSettingsDialog.cpp - core-impl/podcasts/sql/PodcastFilenameLayoutConfigDialog.cpp -) - -##################################################################### -# PLAYLISTBROWSER -##################################################################### -set(libplaylistbrowser_SRCS - browsers/playlistbrowser/APGCategory.cpp - browsers/playlistbrowser/DynamicCategory.cpp - browsers/playlistbrowser/DynamicBiasDelegate.cpp - browsers/playlistbrowser/DynamicBiasDialog.cpp - browsers/playlistbrowser/DynamicView.cpp - browsers/playlistbrowser/PlaylistBrowserFilterProxy.cpp - browsers/playlistbrowser/PlaylistBrowserModel.cpp - browsers/playlistbrowser/PlaylistBrowserCategory.cpp - browsers/playlistbrowser/QtGroupingProxy.cpp - browsers/playlistbrowser/PlaylistBrowser.cpp - browsers/playlistbrowser/PlaylistBrowserView.cpp - browsers/playlistbrowser/UserPlaylistCategory.cpp - browsers/playlistbrowser/PlaylistsInFoldersProxy.cpp - browsers/playlistbrowser/PlaylistsByProviderProxy.cpp - browsers/playlistbrowser/PodcastModel.cpp - browsers/playlistbrowser/PodcastCategory.cpp - browsers/playlistbrowser/UserPlaylistModel.cpp -) - -##################################################################### -# PLAYLISTMANAGER -##################################################################### -set(libplaylistmanager_SRCS - playlistmanager/PlaylistManager.cpp - playlistmanager/file/PlaylistFileProvider.cpp - playlistmanager/file/KConfigSyncRelStore.cpp - playlistmanager/sql/SqlUserPlaylistProvider.cpp - playlistmanager/sql/SqlPlaylist.cpp - playlistmanager/sql/SqlPlaylistGroup.cpp - playlistmanager/SyncedPlaylist.cpp - playlistmanager/SyncedPodcast.cpp - playlistmanager/SyncRelationStorage.cpp -) - -##################################################################### -# PLAYLIST -##################################################################### -set(libplaylist_SRCS - playlist/PlaylistActions.cpp - playlist/PlaylistBreadcrumbItem.cpp - playlist/PlaylistBreadcrumbItemSortButton.cpp - playlist/PlaylistBreadcrumbLevel.cpp - playlist/PlaylistDefines.cpp - playlist/PlaylistController.cpp - playlist/PlaylistInfoWidget.cpp - playlist/PlaylistItem.cpp - playlist/PlaylistModel.cpp - playlist/PlaylistModelStack.cpp - playlist/PlaylistRestorer.cpp - playlist/PlaylistQueueEditor.cpp - playlist/PlaylistSortWidget.cpp - playlist/PlaylistViewUrlGenerator.cpp - playlist/PlaylistViewUrlRunner.cpp - playlist/PlaylistDock.cpp - playlist/PlaylistToolBar.cpp - playlist/ProgressiveSearchWidget.cpp - playlist/UndoCommands.cpp - playlist/layouts/LayoutEditDialog.cpp - playlist/layouts/LayoutEditWidget.cpp - playlist/layouts/LayoutConfigAction.cpp - playlist/layouts/LayoutItemConfig.cpp - playlist/layouts/LayoutManager.cpp - playlist/layouts/PlaylistLayoutEditDialog.cpp - playlist/navigators/AlbumNavigator.cpp - playlist/navigators/DynamicTrackNavigator.cpp - playlist/navigators/FavoredRandomTrackNavigator.cpp - playlist/navigators/NavigatorConfigAction.cpp - playlist/navigators/NonlinearTrackNavigator.cpp - playlist/navigators/RandomAlbumNavigator.cpp - playlist/navigators/RandomTrackNavigator.cpp - playlist/navigators/RepeatAlbumNavigator.cpp - playlist/navigators/RepeatTrackNavigator.cpp - playlist/navigators/StandardTrackNavigator.cpp - playlist/navigators/TrackNavigator.cpp - playlist/view/PlaylistViewCommon.cpp - playlist/view/listview/InlineEditorWidget.cpp - playlist/view/listview/PrettyItemDelegate.cpp - playlist/view/listview/PrettyListView.cpp - playlist/view/listview/SourceSelectionPopup.cpp - playlist/proxymodels/GroupingProxy.cpp - playlist/proxymodels/ProxyBase.cpp - playlist/proxymodels/SortAlgorithms.cpp - playlist/proxymodels/SortFilterProxy.cpp - playlist/proxymodels/SortScheme.cpp - playlist/proxymodels/SearchProxy.cpp - playlist/PlaylistQueueEditor.ui -) - -##################################################################### -# DYNAMIC -##################################################################### -set(libdynamic_SRCS - dynamic/TrackSet.cpp - dynamic/BiasFactory.cpp - dynamic/BiasedPlaylist.cpp - dynamic/BiasSolver.cpp - dynamic/DynamicPlaylist.cpp - dynamic/DynamicModel.cpp - - # biases - dynamic/Bias.cpp - dynamic/biases/AlbumPlayBias.cpp - dynamic/biases/EchoNestBias.cpp - dynamic/biases/IfElseBias.cpp - dynamic/biases/PartBias.cpp - dynamic/biases/QuizPlayBias.cpp - dynamic/biases/TagMatchBias.cpp - dynamic/biases/SearchQueryBias.cpp -) - -##################################################################### -# DBUS -##################################################################### -set(dbus_SRCS - dbus/mpris1/RootHandler.cpp - dbus/mpris1/PlayerHandler.cpp - dbus/mpris1/TrackListHandler.cpp - dbus/mpris2/DBusAbstractAdaptor.cpp - dbus/mpris2/Mpris2.cpp - dbus/mpris2/MediaPlayer2.cpp - dbus/mpris2/MediaPlayer2Player.cpp - dbus/mpris2/MediaPlayer2AmarokExtensions.cpp - dbus/mpris2/DBusAmarokApp.cpp - dbus/CollectionDBusHandler.cpp - dbus/DBusQueryHelper.cpp -) - - -##################################################################### -# SCRIPTING INTERFACE -##################################################################### -set(scriptengine_SRCS - scripting/scriptengine/AmarokBookmarkScript.cpp - scripting/scriptengine/AmarokCollectionScript.cpp - scripting/scriptengine/AmarokCollectionViewScript.cpp - scripting/scriptengine/AmarokEngineScript.cpp - scripting/scriptengine/AmarokEqualizerScript.cpp - scripting/scriptengine/AmarokInfoScript.cpp - scripting/scriptengine/AmarokKNotifyScript.cpp - scripting/scriptengine/AmarokLyricsScript.cpp - scripting/scriptengine/AmarokNetworkScript.cpp - scripting/scriptengine/AmarokOSDScript.cpp - scripting/scriptengine/AmarokPlaylistManagerScript.cpp - scripting/scriptengine/AmarokPlaylistScript.cpp - scripting/scriptengine/AmarokScript.cpp - scripting/scriptengine/AmarokScriptConfig.cpp - scripting/scriptengine/AmarokScriptableServiceScript.cpp - scripting/scriptengine/AmarokServicePluginManagerScript.cpp - scripting/scriptengine/AmarokStatusbarScript.cpp - scripting/scriptengine/AmarokStreamItemScript.cpp - scripting/scriptengine/AmarokWindowScript.cpp - scripting/scriptengine/ScriptImporter.cpp - scripting/scriptengine/ScriptingDefines.cpp - scripting/scriptengine/exporters/CollectionTypeExporter.cpp - scripting/scriptengine/exporters/MetaTypeExporter.cpp - scripting/scriptengine/exporters/PlaylistExporter.cpp - scripting/scriptengine/exporters/PlaylistProviderExporter.cpp - scripting/scriptengine/exporters/QueryMakerExporter.cpp - scripting/scriptengine/exporters/ScriptableBiasExporter.cpp -) - -set(scriptconsole_SRCS - scripting/scriptconsole/CompletionModel.cpp - scripting/scriptconsole/ScriptConsole.cpp - scripting/scriptconsole/ScriptEditorDocument.cpp - scripting/scriptconsole/ScriptConsoleItem.cpp -) - -if (PYTHONINTERP_FOUND) - execute_process(COMMAND "${PYTHON_EXECUTABLE}" ${PROJECT_SOURCE_DIR}/src/scripting/scriptengine/PHAACG2.py - ${PROJECT_SOURCE_DIR}/src/scripting/scriptengine - ${CMAKE_BINARY_DIR}/scriptconsole) - install(FILES ${CMAKE_BINARY_DIR}/scriptconsole/AutoComplete.txt - DESTINATION ${DATA_INSTALL_DIR}/amarok/scriptconsole) -endif(PYTHONINTERP_FOUND) - -##################################################################### -# PLAYLIST GENERATOR -##################################################################### -set(apg_SRCS - playlistgenerator/Constraint.cpp - playlistgenerator/ConstraintGroup.cpp - playlistgenerator/ConstraintFactory.cpp - playlistgenerator/ConstraintNode.cpp - playlistgenerator/ConstraintSolver.cpp - playlistgenerator/Preset.cpp - playlistgenerator/PresetEditDialog.cpp - playlistgenerator/PresetModel.cpp - playlistgenerator/TreeController.cpp - playlistgenerator/TreeModel.cpp - playlistgenerator/constraints/Checkpoint.cpp - playlistgenerator/constraints/Matching.cpp - playlistgenerator/constraints/PlaylistDuration.cpp - playlistgenerator/constraints/PlaylistFileSize.cpp - playlistgenerator/constraints/PlaylistLength.cpp - playlistgenerator/constraints/PreventDuplicates.cpp - playlistgenerator/constraints/TagMatch.cpp - playlistgenerator/constraints/TagMatchSupport.cpp - playlistgenerator/constraints/TrackSpreader.cpp - playlistgenerator/ConstraintGroupEditWidget.ui - playlistgenerator/PresetEditDialog.ui - playlistgenerator/constraints/CheckpointEditWidget.ui - playlistgenerator/constraints/PlaylistDurationEditWidget.ui - playlistgenerator/constraints/PlaylistFileSizeEditWidget.ui - playlistgenerator/constraints/PlaylistLengthEditWidget.ui - playlistgenerator/constraints/PreventDuplicatesEditWidget.ui - playlistgenerator/constraints/TagMatchEditWidget.ui -) - -##################################################################### -# NETWORK ACCESS -##################################################################### -set(network_access_SRCS - network/NetworkAccessManagerProxy.cpp -) - -if( CMAKE_BUILD_TYPE_TOLOWER MATCHES debug ) - set(network_access_SRCS - ${network_access_SRCS} - network/NetworkAccessViewer.cpp - network/NetworkRequests.ui - ) -endif( CMAKE_BUILD_TYPE_TOLOWER MATCHES debug ) - -##################################################################### -# STATISTICS SYNCHRONIZATION -##################################################################### -set( statsyncing_SRCS - statsyncing/Config.cpp - statsyncing/Controller.cpp - statsyncing/Options.cpp - statsyncing/Process.cpp - statsyncing/Provider.cpp - statsyncing/ProviderFactory.cpp - statsyncing/ScrobblingService.cpp - statsyncing/SimpleTrack.cpp - statsyncing/SimpleWritableTrack.cpp - statsyncing/Track.cpp - statsyncing/TrackTuple.cpp - statsyncing/collection/CollectionProvider.cpp - statsyncing/collection/CollectionTrack.cpp - statsyncing/jobs/MatchTracksJob.cpp - statsyncing/jobs/SynchronizeTracksJob.cpp - statsyncing/models/CommonModel.cpp - statsyncing/models/MatchedTracksModel.cpp - statsyncing/models/ProvidersModel.cpp - statsyncing/models/SingleTracksModel.cpp - statsyncing/ui/ChooseProvidersPage.cpp - statsyncing/ui/CreateProviderDialog.cpp - statsyncing/ui/ConfigureProviderDialog.cpp - statsyncing/ui/MatchedTracksPage.cpp - statsyncing/ui/TrackDelegate.cpp - statsyncing/ui/ChooseProvidersPage.ui - statsyncing/ui/MatchedTracksPage.ui -) - -##################################################################### -# STATISTICS IMPORTERS -##################################################################### -set( importers_SRCS - importers/ImporterManager.cpp - importers/ImporterProvider.cpp - importers/ImporterSqlConnection.cpp - importers/SimpleImporterConfigWidget.cpp -) - -##################################################################### -# LIBAMAROK -##################################################################### -set(amaroklib_LIB_SRCS - ${libscriptableservice_SRCS} - ${libbrowserframework_SRCS} - ${libcontextview_SRCS} - ${libcollectionbrowser_SRCS} - ${libconfigdialog_SRCS} - ${libplaylist_SRCS} - ${libtooltip_SRCS} - ${aggregatecollection_SRCS} - ${libpodcasts_SRCS} - ${libmediadeviceframework_SRCS} - ${libserviceframework_SRCS} - ${libservicebrowser_SRCS} - ${libdynamic_SRCS} - ${libmetaimpl_SRCS} - ${core_interfaces_SRCS} - ${apg_SRCS} - ${collection_SRCS} - ${storage_SRCS} - ${scanner_SRCS} - ${mac_SRCS} - ${network_access_SRCS} - ${libplaylistbrowser_SRCS} - ${libqueuemanager_SRCS} - ${libplaylistmanager_SRCS} - ${dbus_SRCS} - ${scriptengine_SRCS} - ${scriptconsole_SRCS} - ${libstatusbar_SRCS} - ${libamarokurl_SRCS} - ${libsynchronization_SRCS} - ${statsyncing_SRCS} - ${importers_SRCS} - core-impl/logger/ProxyLogger.cpp - aboutdialog/AnimatedBarWidget.cpp - aboutdialog/AnimatedWidget.cpp - aboutdialog/ExtendedAboutDialog.cpp - aboutdialog/FramedLabel.cpp - aboutdialog/OcsData.cpp - aboutdialog/OcsPersonItem.cpp - aboutdialog/OcsPersonListWidget.cpp - ActionClasses.cpp - AmarokMimeData.cpp - AmarokProcess.cpp - App.cpp - CaseConverter.cpp - EngineController.cpp - KNotificationBackend.cpp - MainWindow.cpp - MediaDeviceCache.cpp - MediaDeviceMonitor.cpp - PluginManager.cpp - QStringx.cpp - scripting/scriptmanager/ScriptManager.cpp - scripting/scriptmanager/ScriptItem.cpp - scripting/scriptmanager/ScriptUpdater.cpp - SvgHandler.cpp - SvgTinter.cpp - TrayIcon.cpp - core-impl/meta/timecode/TimecodeObserver.cpp - core-impl/meta/timecode/TimecodeMeta.cpp - core-impl/meta/timecode/TimecodeTrackProvider.cpp - core-impl/support/TrackLoader.cpp - covermanager/CoverCache.cpp - covermanager/CoverFetcher.cpp - covermanager/CoverFetchingActions.cpp - covermanager/CoverFetchQueue.cpp - covermanager/CoverFetchUnit.cpp - covermanager/CoverFoundDialog.cpp - covermanager/CoverManager.cpp - covermanager/CoverViewDialog.cpp - databaseimporter/SqlBatchImporter.cpp - databaseimporter/SqlBatchImporterConfig.cpp - dialogs/CollectionSetup.cpp - dialogs/DatabaseImporterDialog.cpp - dialogs/DiagnosticDialog.cpp - dialogs/EditFilterDialog.cpp - dialogs/EqualizerDialog.cpp - dialogs/MusicBrainzTagger.cpp - dialogs/OrganizeCollectionDialog.cpp - dialogs/TrackOrganizer.cpp - dialogs/TagDialog.cpp - dialogs/TagGuesser.cpp - dialogs/TagGuesserDialog.cpp - dialogs/LabelListModel.cpp - equalizer/EqualizerPresets.cpp - browsers/filebrowser/DirPlaylistTrackFilterProxyModel.cpp - browsers/filebrowser/FileBrowser.cpp - browsers/filebrowser/FileView.cpp - musicbrainz/MusicBrainzFinder.cpp - musicbrainz/MusicBrainzTagsItem.cpp - musicbrainz/MusicBrainzTagsModel.cpp - musicbrainz/MusicBrainzTagsModelDelegate.cpp - musicbrainz/MusicBrainzTagsView.cpp - musicbrainz/MusicBrainzXmlParser.cpp - OpmlOutline.cpp - OpmlParser.cpp - OpmlWriter.cpp - PaletteHandler.cpp - PopupDropperFactory.cpp - playback/DelayedDoers.cpp - playback/EqualizerController.cpp - playback/Fadeouter.cpp - playback/PowerManager.cpp - statemanagement/ApplicationController.cpp - statemanagement/DefaultApplicationController.cpp - toolbar/CurrentTrackToolbar.cpp - toolbar/SlimToolbar.cpp - toolbar/VolumePopupButton.cpp - toolbar/MainToolbar.cpp - widgets/AlbumBreadcrumbWidget.cpp - widgets/AmarokDockWidget.cpp - widgets/AnimatedLabelStack.cpp - widgets/BreadcrumbItemButton.cpp - widgets/ClearSpinBox.cpp - widgets/CoverLabel.cpp - widgets/HintLineEdit.cpp - widgets/kdatecombo.cpp - widgets/TokenDropTarget.cpp - widgets/EditDeleteComboBoxView.cpp - widgets/EditDeleteDelegate.cpp - widgets/ElidingButton.cpp - widgets/FilenameLayoutWidget.cpp - widgets/FlowLayout.cpp - widgets/HorizontalDivider.cpp - widgets/IconButton.cpp - widgets/ComboBox.cpp - widgets/LineEdit.cpp - widgets/Osd.cpp - widgets/TimeLabel.cpp - widgets/PixmapViewer.cpp - widgets/PlayPauseButton.cpp - widgets/PrettyTreeView.cpp - widgets/PrettyTreeDelegate.cpp - widgets/ProgressWidget.cpp - widgets/SearchWidget.cpp - widgets/SliderWidget.cpp - widgets/StarManager.cpp - widgets/TokenPool.cpp - widgets/Token.cpp - widgets/TokenWithLayout.cpp - widgets/VolumeDial.cpp - widgets/TrackActionButton.cpp - widgets/BookmarkTriangle.cpp - widgets/BookmarkPopup.cpp - widgets/TrackSelectWidget.cpp - widgets/MetaQueryWidget.cpp - GlobalCollectionActions.cpp - GlobalCurrentTrackActions.cpp - moodbar/MoodbarManager.cpp - aboutdialog/OcsPersonItem.ui - dialogs/EditFilterDialog.ui - dialogs/EqualizerDialog.ui - dialogs/MusicBrainzTagger.ui - dialogs/TagDialogBase.ui - dialogs/TagGuessOptions.ui - dialogs/OrganizeCollectionOptions.ui - dialogs/OrganizeCollectionDialogBase.ui - playlist/layouts/PlaylistLayoutEditDialog.ui - core-impl/podcasts/sql/PodcastSettingsBase.ui - core-impl/podcasts/sql/SqlPodcastProviderSettingsWidget.ui - core-impl/podcasts/sql/PodcastFilenameLayoutConfigWidget.ui - browsers/playlistbrowser/PodcastCategoryBase.ui -) - -if( LIBMYGPO_QT_FOUND ) - set( EXTRA_LIBS ${LIBMYGPO_QT_LIBRARIES} ) - include_directories( ${LIBMYGPO_QT_INCLUDE_DIRS} ${LIBMYGPO_QT_INCLUDE_DIRS}/../ ) -endif( LIBMYGPO_QT_FOUND ) - -if( LIBLASTFM_FOUND ) - set(amaroklib_LIB_SRCS - ${amaroklib_LIB_SRCS} - LastfmReadLabelCapability.cpp - ) - include_directories( ${LIBLASTFM_INCLUDE_DIR}/.. ${LIBLASTFM_INCLUDE_DIR}) - set( EXTRA_LIBS ${LIBLASTFM_LIBRARY} ) -endif( LIBLASTFM_FOUND ) - -if( LIBOFA_FOUND ) - add_definitions( - ${AVCODEC_DEFINITIONS} - ${AVFORMAT_DEFINITIONS} - ${AVUTIL_DEFINITIONS} - ) - include_directories( - ${AVCODEC_INCLUDE_DIRS} - ${AVFORMAT_INCLUDE_DIRS} - ${AVUTIL_INCLUDE_DIRS} - ) - set( EXTRA_LIBS - ${EXTRA_LIBS} - ${LIBOFA_LIBRARY} - ${AVFORMAT_LIBRARIES} - ${AVCODEC_LIBRARIES} - ${AVUTIL_LIBRARIES} - ) - set( amaroklib_LIB_SRCS - ${amaroklib_LIB_SRCS} - musicbrainz/MusicDNSAudioDecoder.cpp - musicbrainz/MusicDNSFinder.cpp - musicbrainz/MusicDNSXmlParser.cpp - ) -endif( LIBOFA_FOUND ) - -qt4_add_dbus_adaptor( - AMAROK_MPRIS1_ADAPTOR_SRCS - dbus/mpris1/org.freedesktop.MediaPlayer.root.xml - dbus/mpris1/RootHandler.h - Mpris1::RootHandler - Mpris1RootAdaptor - Mpris1RootAdaptor ) -qt4_add_dbus_adaptor( - AMAROK_MPRIS1_ADAPTOR_SRCS - dbus/mpris1/org.freedesktop.MediaPlayer.player.xml - dbus/mpris1/PlayerHandler.h - Mpris1::PlayerHandler - Mpris1PlayerAdaptor - Mpris1PlayerAdaptor ) -qt4_add_dbus_adaptor( - AMAROK_MPRIS1_ADAPTOR_SRCS - dbus/mpris1/org.freedesktop.MediaPlayer.tracklist.xml - dbus/mpris1/TrackListHandler.h - Mpris1::TrackListHandler - Mpris1TrackListAdaptor - Mpris1TrackListAdaptor ) -qt4_add_dbus_adaptor( - AMAROK_MPRIS1_ADAPTOR_SRCS - dbus/org.kde.amarok.App.xml - dbus/mpris1/RootHandler.h - Mpris1::RootHandler - Mpris1AmarokAppAdaptor - Mpris1AmarokAppAdaptor ) -qt4_add_dbus_adaptor( - AMAROK_MPRIS1_ADAPTOR_SRCS - dbus/mpris1/org.kde.amarok.Mpris1Extensions.Player.xml - dbus/mpris1/PlayerHandler.h - Mpris1::PlayerHandler - Mpris1AmarokPlayerAdaptor - Mpris1AmarokPlayerAdaptor ) - -qt4_add_dbus_adaptor( - AMAROK_MPRIS1_ADAPTOR_SRCS - dbus/org.kde.amarok.Collection.xml - dbus/CollectionDBusHandler.h - CollectionDBusHandler - CollectionAdaptor - CollectionAdaptor ) - -# suppress deprecated methods warnings -if(NOT WIN32) - set_source_files_properties(${AMAROK_MPRIS1_ADAPTOR_SRCS} - PROPERTIES - COMPILE_FLAGS -Wno-deprecated-declarations) -endif(NOT WIN32) - -set( amaroklib_DEPENDS "amarokpud" ) -set( amaroklib_DEPENDS "amarokcore" ) -set( amaroklib_DEPENDS "amarok-transcoding" ) # depends on generated ui_*.h file - -kde4_add_kcfg_files(amaroklib_LIB_SRCS amarokconfig.kcfgc) -add_custom_target(amarokconfig_h DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/amarokconfig.h) - -add_library(amaroklib SHARED ${amaroklib_LIB_SRCS} ${AMAROK_MPRIS1_ADAPTOR_SRCS}) - -target_link_libraries(amaroklib - ${KDE4_KDEUI_LIBS} - ${KDE4_KFILE_LIBS} - ${KDE4_KNEWSTUFF3_LIBS} - ${KDE4_KNOTIFYCONFIG_LIBS} - ${KDE4_KCMUTILS_LIBS} - ${KDE4_PHONON_LIBRARY} - ${KDE4_PLASMA_LIBS} - ${KDE4_SOLID_LIBRARY} - ${KDE4_KTEXTEDITOR_LIBS} - ${KDE4_THREADWEAVER_LIBS} - ${QT_QTSCRIPT_LIBRARY} - ${QT_QTSCRIPTTOOLS_LIBRARY} - ${QT_QTSQL_LIBRARY} - ${CMAKE_DL_LIBS} - ${CMAKE_THREAD_LIBS_INIT} - ${EXTRA_LIBS} - amarokpud - amarokcore - amarokocsclient - amarok-transcoding - amarokshared -) - -include_directories(${TAGLIB_INCLUDES}) -add_definitions(${TAGLIB_CFLAGS}) -target_link_libraries(amaroklib ${TAGLIB_LIBRARIES}) -if( TAGLIB-EXTRAS_FOUND ) - include_directories(${TAGLIB-EXTRAS_INCLUDES}) - add_definitions(${TAGLIB-EXTRAS_CFLAGS}) - target_link_libraries(amaroklib ${TAGLIB-EXTRAS_LIBRARIES}) -endif( TAGLIB-EXTRAS_FOUND ) - -if( QCA2_FOUND ) - include_directories( ${QCA2_INCLUDE_DIR} ) - target_link_libraries(amaroklib ${QCA2_LIBRARIES}) -endif( QCA2_FOUND ) - - -if(ENABLE_TESTING) - target_link_libraries(amaroklib ${QT_QTTEST_LIBRARY}) -endif() - -set_target_properties(amaroklib PROPERTIES VERSION 1.0.0 SOVERSION 1 ) -install(TARGETS amaroklib ${INSTALL_TARGETS_DEFAULT_ARGS} ) - - -##################################################################### -# AMAROK -##################################################################### - -set( amarok_SRCS main.cpp ) - -find_package(X11) - -add_executable(amarok ${amarok_SRCS}) - -target_link_libraries(amarok ${KDE4_KDECORE_LIBS} ${KDE4_KDEUI_LIBS} amarokcore amaroklib ${X11_LIBRARIES}) -install(TARGETS amarok ${INSTALL_TARGETS_DEFAULT_ARGS}) - -########### install files ############### - -install(PROGRAMS amarok.desktop DESTINATION ${XDG_APPS_INSTALL_DIR} ) -install(PROGRAMS amarok_containers.desktop DESTINATION ${XDG_APPS_INSTALL_DIR} ) -install(FILES amarok.appdata.xml DESTINATION ${SHARE_INSTALL_PREFIX}/appdata) - -install(FILES amarok_plugin.desktop DESTINATION ${SERVICETYPES_INSTALL_DIR}) -install(FILES amarok_codecinstall.desktop DESTINATION ${SERVICETYPES_INSTALL_DIR}) -install(FILES amarok_append.desktop DESTINATION ${SERVICES_INSTALL_DIR}/ServiceMenus) -install(FILES amarok-play-audiocd.desktop DESTINATION ${DATA_INSTALL_DIR}/solid/actions) - -install(FILES amarok.knsrc DESTINATION ${CONFIG_INSTALL_DIR}) -install(FILES context/amarokapplets.knsrc DESTINATION ${CONFIG_INSTALL_DIR}) - -# protocol handlers -install(FILES amarokurls/amarok.protocol DESTINATION ${SERVICES_INSTALL_DIR}) -install(FILES amarokitpc.protocol DESTINATION ${SERVICES_INSTALL_DIR}) -#install(FILES amarokpcast.protocol DESTINATION ${SERVICES_INSTALL_DIR}) - -install(FILES context/servicetypes/amarok_context_applet.desktop - context/servicetypes/amarok_data_engine.desktop - DESTINATION ${SERVICETYPES_INSTALL_DIR} ) - -install(FILES amarokconfig.kcfg DESTINATION ${KCFG_INSTALL_DIR} ) -install(FILES dbus/mpris1/org.freedesktop.MediaPlayer.root.xml - dbus/mpris1/org.freedesktop.MediaPlayer.player.xml - dbus/mpris1/org.freedesktop.MediaPlayer.tracklist.xml - dbus/org.kde.amarok.App.xml - dbus/org.kde.amarok.Collection.xml - dbus/mpris1/org.kde.amarok.Mpris1Extensions.Player.xml - dbus/mpris2/org.kde.amarok.Mpris2Extensions.Player.xml - DESTINATION ${DBUS_INTERFACES_INSTALL_DIR}) - -install(FILES services/InfoParserLoading.html - browsers/hover_info_template.html - DESTINATION ${DATA_INSTALL_DIR}/amarok/data) - -kde4_install_icons( ${ICON_INSTALL_DIR} ) diff --git a/amarok/src/CaseConverter.cpp b/amarok/src/CaseConverter.cpp deleted file mode 100644 index 852a8e2c..00000000 --- a/amarok/src/CaseConverter.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Nicos Gollan * - * Copyright (c) 2008 Téo Mrnjavac * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "CaseConverter" - -#include "CaseConverter.h" - -#include "core/support/Debug.h" - -#include -#include -#include - -namespace Amarok -{ -const QString CaseConverter::s_MATCH_A_WORD( "\\b([\\w']+)\\b" ); -const QString CaseConverter::s_LITTLE_WORDS( "\\b(a|an|and|as|at|by|for|if|in|of|on|or|to|the)\\b" ); - -QString -CaseConverter::toTitleCase( const QString &s ) -{ - QString result = s; - debug() << "Original string: " << s; - - QRegExp wordRegExp( CaseConverter::s_MATCH_A_WORD ); - int i = wordRegExp.indexIn( result ); - QString match = wordRegExp.cap( 1 ); - bool first = true; - - QRegExp littleWordRegExp( CaseConverter::s_LITTLE_WORDS ); - while ( i > -1 ) - { - debug() << " Title case i=" << i << "; remaining: \"" << result.mid( i ) << "\""; - - // uppercase if: - // * no uppercase letters in partial AND first partial - // OR - // * no uppercase letters in partial AND not a "little" word - if ( match == match.toLower() && ( first || !littleWordRegExp.exactMatch( match ) ) ) - { - result[i] = result[i].toUpper(); - } - else - { - debug() << " partial will not be capitalized: \"" << match << "\""; - } - - i = wordRegExp.indexIn( result, i + match.length() ); - match = wordRegExp.cap( 1 ); - first = false; - } - - debug() << " Title case of \"" << s << "\" = \"" << result << "\""; - return result; -} - -QString -CaseConverter::toCapitalizedCase( const QString &s ) -{ - QString result = s; - QRegExp wordRegExp( CaseConverter::s_MATCH_A_WORD ); - int i = wordRegExp.indexIn( result ); - int ml = wordRegExp.cap( 1 ).length(); - while ( i > -1 ) - { - result[i] = result[i].toUpper(); - i = wordRegExp.indexIn( result, i + ml ); - ml = wordRegExp.cap( 1 ).length(); - } - return result; -} -} diff --git a/amarok/src/CaseConverter.h b/amarok/src/CaseConverter.h deleted file mode 100644 index d0dc32c6..00000000 --- a/amarok/src/CaseConverter.h +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Nicos Gollan * - * Copyright (c) 2008 Téo Mrnjavac * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef CASECONVERTER_H -#define CASECONVERTER_H - -#include - -namespace Amarok -{ -/** Case converter for tag formatting. - * - * Provides helper functions to achieve sane capitalization of tag - * information. - */ -class CaseConverter -{ -public: - /** Convert to "title case". - * - * Title case tries to conform to the common capitalization of titles, - * i.e. first letter of each word is capitalized, except for "small" - * words like "in", "of", etc. - * - * This implementation will also leave alone words that already have - * some kind of capitalization, assuming that those are properly - * formatted. - * - * @param s A string to be converted - * @return The converted string - */ - static QString toTitleCase( const QString &s ); - /** Convert to "capitalized case" - * - * Capitalizes the initial letter of each word. - * - * @param s A string to be converted - * @return The converted string - */ - static QString toCapitalizedCase( const QString &s ); -private: - /// regular expression for a word. - static const QString s_MATCH_A_WORD; - /** "small words" that ought not be capitalized. - * - * This is mostly English only. - */ - static const QString s_LITTLE_WORDS; -}; -} - -#endif //CASECONVERTER_H diff --git a/amarok/src/EngineController.cpp b/amarok/src/EngineController.cpp deleted file mode 100644 index 154142a2..00000000 --- a/amarok/src/EngineController.cpp +++ /dev/null @@ -1,1373 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2004 Frederik Holljen * - * Copyright (c) 2004,2005 Max Howell * - * Copyright (c) 2004-2013 Mark Kretschmann * - * Copyright (c) 2006,2008 Ian Monroe * - * Copyright (c) 2008 Jason A. Donenfeld * - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * Copyright (c) 2009 Artur Szymiec * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "EngineController" - -#include "EngineController.h" - -#include "MainWindow.h" -#include "amarokconfig.h" -#include "core-impl/collections/support/CollectionManager.h" -#include "core/capabilities/MultiPlayableCapability.h" -#include "core/capabilities/MultiSourceCapability.h" -#include "core/capabilities/SourceInfoCapability.h" -#include "core/interfaces/Logger.h" -#include "core/meta/Meta.h" -#include "core/meta/support/MetaConstants.h" -#include "core/meta/support/MetaUtility.h" -#include "core/support/Amarok.h" -#include "core/support/Components.h" -#include "core/support/Debug.h" -#include "playback/DelayedDoers.h" -#include "playback/Fadeouter.h" -#include "playback/PowerManager.h" -#include "playlist/PlaylistActions.h" - -#include - -#include -#include -#include -#include - -#include -#include // for Qt::escape -#include - -// for slotMetaDataChanged() -typedef QPair FieldPair; - -namespace The { - EngineController* engineController() { return EngineController::instance(); } -} - -EngineController * -EngineController::instance() -{ - return Amarok::Components::engineController(); -} - -EngineController::EngineController() - : m_boundedPlayback( 0 ) - , m_multiPlayback( 0 ) - , m_multiSource( 0 ) - , m_playWhenFetched( true ) - , m_volume( 0 ) - , m_currentAudioCdTrack( 0 ) - , m_pauseTimer( new QTimer( this ) ) - , m_lastStreamStampPosition( -1 ) - , m_ignoreVolumeChangeAction ( false ) - , m_ignoreVolumeChangeObserve ( false ) - , m_tickInterval( 0 ) - , m_lastTickPosition( -1 ) - , m_lastTickCount( 0 ) - , m_mutex( QMutex::Recursive ) -{ - DEBUG_BLOCK - // ensure this object is created in a main thread - Q_ASSERT( thread() == QCoreApplication::instance()->thread() ); - connect( this, SIGNAL(fillInSupportedMimeTypes()), SLOT(slotFillInSupportedMimeTypes()) ); - connect( this, SIGNAL(trackFinishedPlaying(Meta::TrackPtr,double)), - SLOT(slotTrackFinishedPlaying(Meta::TrackPtr,double)) ); - new PowerManager( this ); // deals with inhibiting suspend etc. - - m_pauseTimer->setSingleShot( true ); - connect( m_pauseTimer, SIGNAL(timeout()), SLOT(slotPause() ) ); - m_equalizerController = new EqualizerController( this ); -} - -EngineController::~EngineController() -{ - DEBUG_BLOCK //we like to know when singletons are destroyed - - // don't do any of the after-processing that normally happens when - // the media is stopped - that's what endSession() is for - if( m_media ) - { - m_media.data()->blockSignals(true); - m_media.data()->stop(); - } - - delete m_boundedPlayback; - m_boundedPlayback = 0; - delete m_multiPlayback; // need to get a new instance of multi if played again - m_multiPlayback = 0; - - delete m_media.data(); - delete m_audio.data(); - delete m_audioDataOutput.data(); -} - -void -EngineController::initializePhonon() -{ - DEBUG_BLOCK - - m_path.disconnect(); - m_dataPath.disconnect(); - - // QWeakPointers reset themselves to null if the object is deleted - delete m_media.data(); - delete m_controller.data(); - delete m_audio.data(); - delete m_audioDataOutput.data(); - delete m_preamp.data(); - delete m_fader.data(); - - using namespace Phonon; - PERF_LOG( "EngineController: loading phonon objects" ) - m_media = new MediaObject( this ); - - // Enable zeitgeist support on linux - //TODO: make this configurable by the user. - m_media.data()->setProperty( "PlaybackTracking", true ); - - m_audio = new AudioOutput( MusicCategory, this ); - m_audioDataOutput = new AudioDataOutput( this ); - m_audioDataOutput.data()->setDataSize( DATAOUTPUT_DATA_SIZE ); // The number of samples that Phonon sends per signal - - m_path = createPath( m_media.data(), m_audio.data() ); - - m_controller = new MediaController( m_media.data() ); - - m_equalizerController->initialize( m_path ); - - // we now try to create pre-amp unconditionally, however we check that it is valid. - // So now m_preamp is null equals not available at all - QScopedPointer preamp( new VolumeFaderEffect( this ) ); - if( preamp->isValid() ) - { - m_preamp = preamp.take(); - m_path.insertEffect( m_preamp.data() ); - } - - QScopedPointer fader( new VolumeFaderEffect( this ) ); - if( fader->isValid() ) - { - fader->setFadeCurve( VolumeFaderEffect::Fade9Decibel ); - m_fader = fader.take(); - m_path.insertEffect( m_fader.data() ); - m_dataPath = createPath( m_fader.data(), m_audioDataOutput.data() ); - } - else - m_dataPath = createPath( m_media.data(), m_audioDataOutput.data() ); - - m_media.data()->setTickInterval( 100 ); - m_tickInterval = m_media.data()->tickInterval(); - debug() << "Tick Interval (actual): " << m_tickInterval; - PERF_LOG( "EngineController: loaded phonon objects" ) - - // Get the next track when there is 2 seconds left on the current one. - m_media.data()->setPrefinishMark( 2000 ); - - connect( m_media.data(), SIGNAL(finished()), SLOT(slotFinished())); - connect( m_media.data(), SIGNAL(aboutToFinish()), SLOT(slotAboutToFinish()) ); - connect( m_media.data(), SIGNAL(metaDataChanged()), SLOT(slotMetaDataChanged()) ); - connect( m_media.data(), SIGNAL(stateChanged(Phonon::State,Phonon::State)), - SLOT(slotStateChanged(Phonon::State,Phonon::State)) ); - connect( m_media.data(), SIGNAL(tick(qint64)), SLOT(slotTick(qint64)) ); - connect( m_media.data(), SIGNAL(totalTimeChanged(qint64)), - SLOT(slotTrackLengthChanged(qint64)) ); - connect( m_media.data(), SIGNAL(currentSourceChanged(Phonon::MediaSource)), - SLOT(slotNewTrackPlaying(Phonon::MediaSource)) ); - connect( m_media.data(), SIGNAL(seekableChanged(bool)), - SLOT(slotSeekableChanged(bool)) ); - connect( m_audio.data(), SIGNAL(volumeChanged(qreal)), - SLOT(slotVolumeChanged(qreal)) ); - connect( m_audio.data(), SIGNAL(mutedChanged(bool)), - SLOT(slotMutedChanged(bool)) ); - connect( m_audioDataOutput.data(), - SIGNAL(dataReady(QMap >)), - SIGNAL(audioDataReady(QMap >)) - ); - - connect( m_controller.data(), SIGNAL(titleChanged(int)), - SLOT(slotTitleChanged(int)) ); - - // Read the volume from phonon - m_volume = qBound( 0, qRound(m_audio.data()->volume()*100), 100 ); - - if( m_currentTrack ) - { - unsubscribeFrom( m_currentTrack ); - m_currentTrack.clear(); - } - if( m_currentAlbum ) - { - unsubscribeFrom( m_currentAlbum ); - m_currentAlbum.clear(); - } -} - - -////////////////////////////////////////////////////////////////////////////////////////// -// PUBLIC -////////////////////////////////////////////////////////////////////////////////////////// - - -QStringList -EngineController::supportedMimeTypes() -{ - // this ensures that slotFillInSupportedMimeTypes() is called in the main thread. It - // will be called directly if we are called in the main thread (so that no deadlock - // can occur) and indirectly if we are called in non-main thread. - emit fillInSupportedMimeTypes(); - - // ensure slotFillInSupportedMimeTypes() called above has already finished: - m_supportedMimeTypesSemaphore.acquire(); - return m_supportedMimeTypes; -} - -void -EngineController::slotFillInSupportedMimeTypes() -{ - // we assume non-empty == already filled in - if( !m_supportedMimeTypes.isEmpty() ) - { - // unblock waiting for the semaphore in supportedMimeTypes(): - m_supportedMimeTypesSemaphore.release(); - return; - } - - QRegExp avFilter( "^(audio|video)/", Qt::CaseInsensitive ); - m_supportedMimeTypes = Phonon::BackendCapabilities::availableMimeTypes().filter( avFilter ); - - // Add whitelist hacks - // MP4 Audio Books have a different extension that KFileItem/Phonon don't grok - if( !m_supportedMimeTypes.contains( "audio/x-m4b" ) ) - m_supportedMimeTypes << "audio/x-m4b"; - - // technically, "audio/flac" is not a valid mimetype (not on IANA list), but some things expect it - if( m_supportedMimeTypes.contains( "audio/x-flac" ) && !m_supportedMimeTypes.contains( "audio/flac" ) ) - m_supportedMimeTypes << "audio/flac"; - - // technically, "audio/mp4" is the official mime type, but sometimes Phonon returns audio/x-m4a - if( m_supportedMimeTypes.contains( "audio/x-m4a" ) && !m_supportedMimeTypes.contains( "audio/mp4" ) ) - m_supportedMimeTypes << "audio/mp4"; - - // unblock waiting for the semaphore in supportedMimeTypes(). We can over-shoot - // resource number so that next call to supportedMimeTypes won't have to - // wait for main loop; this is however just an optimization and we could have safely - // released just one resource. Note that this code-path is reached only once, so - // overflow cannot happen. - m_supportedMimeTypesSemaphore.release( 100000 ); -} - -void -EngineController::restoreSession() -{ - //here we restore the session - //however, do note, this is always done, KDE session management is not involved - - if( AmarokConfig::resumePlayback() ) - { - const KUrl url = AmarokConfig::resumeTrack(); - Meta::TrackPtr track = CollectionManager::instance()->trackForUrl( url ); - - // Only give a resume time for local files, because resuming remote protocols can have weird side effects. - // See: http://bugs.kde.org/show_bug.cgi?id=172897 - if( url.isLocalFile() ) - play( track, AmarokConfig::resumeTime(), AmarokConfig::resumePaused() ); - else - play( track, 0, AmarokConfig::resumePaused() ); - } -} - -void -EngineController::endSession() -{ - //only update song stats, when we're not going to resume it - if ( !AmarokConfig::resumePlayback() && m_currentTrack ) - { - emit stopped( trackPositionMs(), m_currentTrack->length() ); - unsubscribeFrom( m_currentTrack ); - if( m_currentAlbum ) - unsubscribeFrom( m_currentAlbum ); - emit trackChanged( Meta::TrackPtr( 0 ) ); - } - emit sessionEnded( AmarokConfig::resumePlayback() && m_currentTrack ); -} - -EqualizerController* -EngineController::equalizerController() const -{ - return m_equalizerController; -} - -////////////////////////////////////////////////////////////////////////////////////////// -// PUBLIC SLOTS -////////////////////////////////////////////////////////////////////////////////////////// - -void -EngineController::play() //SLOT -{ - DEBUG_BLOCK - - if( isPlaying() ) - return; - - if( isPaused() ) - { - if( m_currentTrack && m_currentTrack->type() == "stream" ) - { - debug() << "This is a stream that cannot be resumed after pausing. Restarting instead."; - play( m_currentTrack ); - return; - } - else - { - m_pauseTimer->stop(); - if( supportsFadeout() ) - m_fader.data()->setVolume( 1.0 ); - m_media.data()->play(); - emit trackPlaying( m_currentTrack ); - return; - } - } - - The::playlistActions()->play(); -} - -void -EngineController::play( Meta::TrackPtr track, uint offset, bool startPaused ) -{ - DEBUG_BLOCK - - if( !track ) // Guard - return; - - // clear the current track without sending playbackEnded or trackChangeNotify yet - stop( /* forceInstant */ true, /* playingWillContinue */ true ); - - // we grant exclusive access to setting new m_currentTrack to newTrackPlaying() - m_nextTrack = track; - debug() << "play: bounded is "<name(); - m_boundedPlayback = track->create(); - m_multiPlayback = track->create(); - - track->prepareToPlay(); - m_nextUrl = track->playableUrl(); - - if( m_multiPlayback ) - { - connect( m_multiPlayback, SIGNAL(playableUrlFetched(KUrl)), - SLOT(slotPlayableUrlFetched(KUrl)) ); - m_multiPlayback->fetchFirst(); - } - else if( m_boundedPlayback ) - { - debug() << "Starting bounded playback of url " << track->playableUrl() << " at position " << m_boundedPlayback->startPosition(); - playUrl( track->playableUrl(), m_boundedPlayback->startPosition(), startPaused ); - } - else - { - debug() << "Just a normal, boring track... :-P"; - playUrl( track->playableUrl(), offset, startPaused ); - } -} - -void -EngineController::replay() // slot -{ - DEBUG_BLOCK - - seekTo( 0 ); - emit trackPositionChanged( 0, true ); -} - -void -EngineController::playUrl( const KUrl &url, uint offset, bool startPaused ) -{ - DEBUG_BLOCK - - m_media.data()->stop(); - - debug() << "URL: " << url << url.url(); - debug() << "Offset: " << offset; - - m_currentAudioCdTrack = 0; - if( url.protocol() == "audiocd" ) - { - QStringList pathItems = url.path().split( '/', QString::KeepEmptyParts ); - if( pathItems.count() != 3 ) - { - error() << __PRETTY_FUNCTION__ << url.url() << "is not in expected format"; - return; - } - bool ok = false; - int trackNumber = pathItems.at( 2 ).toInt( &ok ); - if( !ok || trackNumber <= 0 ) - { - error() << __PRETTY_FUNCTION__ << "failed to get positive track number from" << url.url(); - return; - } - QString device = url.queryItem( "device" ); - - m_media.data()->setCurrentSource( Phonon::MediaSource( Phonon::Cd, device ) ); - m_currentAudioCdTrack = trackNumber; - } - else - { - // keep in sync with setNextTrack(), slotPlayableUrlFetched() - if( url.isLocalFile() ) - m_media.data()->setCurrentSource( url.toLocalFile() ); - else - m_media.data()->setCurrentSource( url ); - } - - m_media.data()->clearQueue(); - - if( m_currentAudioCdTrack ) - { - // call to play() is asynchronous and ->setCurrentTitle() can be only called on - // playing, buffering or paused media. - m_media.data()->pause(); - DelayedTrackChanger *trackChanger = new DelayedTrackChanger( m_media.data(), - m_controller.data(), m_currentAudioCdTrack, offset, startPaused ); - connect( trackChanger, SIGNAL(trackPositionChanged(qint64,bool)), - SIGNAL(trackPositionChanged(qint64,bool)) ); - } - else if( offset ) - { - // call to play() is asynchronous and ->seek() can be only called on playing, - // buffering or paused media. Calling play() would lead to audible glitches, - // so call pause() that doesn't suffer from such problem. - m_media.data()->pause(); - DelayedSeeker *seeker = new DelayedSeeker( m_media.data(), offset, startPaused ); - connect( seeker, SIGNAL(trackPositionChanged(qint64,bool)), - SIGNAL(trackPositionChanged(qint64,bool)) ); - } - else - { - if( startPaused ) - { - m_media.data()->pause(); - } - else - { - m_pauseTimer->stop(); - if( supportsFadeout() ) - m_fader.data()->setVolume( 1.0 ); - m_media.data()->play(); - } - } -} - -void -EngineController::pause() //SLOT -{ - if( supportsFadeout() && AmarokConfig::fadeoutOnPause() ) - { - m_fader.data()->fadeOut( AmarokConfig::fadeoutLength() ); - m_pauseTimer->start( AmarokConfig::fadeoutLength() + 500 ); - return; - } - - slotPause(); -} - -void -EngineController::slotPause() -{ - if( supportsFadeout() && AmarokConfig::fadeoutOnPause() ) - { - // Reset VolumeFaderEffect to full volume - m_fader.data()->setVolume( 1.0 ); - - // Wait a bit before pausing the pipeline. Necessary for the new fader setting to take effect. - QTimer::singleShot( 1000, m_media.data(), SLOT(pause()) ); - } - else - { - m_media.data()->pause(); - } - - emit paused(); -} - -void -EngineController::stop( bool forceInstant, bool playingWillContinue ) //SLOT -{ - DEBUG_BLOCK - - /* Only do fade-out when all conditions are met: - * a) instant stop is not requested - * b) we aren't already in a fadeout - * c) we are currently playing (not paused etc.) - * d) Amarok is configured to fadeout at all - * e) configured fadeout length is positive - * f) Phonon fader to do it is actually available - */ - bool doFadeOut = !forceInstant - && !m_fadeouter - && m_media.data()->state() == Phonon::PlayingState - && AmarokConfig::fadeoutOnStop() - && AmarokConfig::fadeoutLength() > 0 - && m_fader; - - // let Amarok know that the previous track is no longer playing; if we will fade-out - // ::stop() is called after the fade by Fadeouter. - if( m_currentTrack && !doFadeOut ) - { - unsubscribeFrom( m_currentTrack ); - if( m_currentAlbum ) - unsubscribeFrom( m_currentAlbum ); - const qint64 pos = trackPositionMs(); - // updateStreamLength() intentionally not here, we're probably in the middle of a track - const qint64 length = trackLength(); - emit trackFinishedPlaying( m_currentTrack, pos / qMax( length, pos ) ); - - m_currentTrack = 0; - m_currentAlbum = 0; - if( !playingWillContinue ) - { - emit stopped( pos, length ); - emit trackChanged( m_currentTrack ); - } - } - - { - QMutexLocker locker( &m_mutex ); - delete m_boundedPlayback; - m_boundedPlayback = 0; - delete m_multiPlayback; // need to get a new instance of multi if played again - m_multiPlayback = 0; - m_multiSource.reset(); - - m_nextTrack.clear(); - m_nextUrl.clear(); - m_media.data()->clearQueue(); - } - - if( doFadeOut ) - { - m_fadeouter = new Fadeouter( m_media, m_fader, AmarokConfig::fadeoutLength() ); - // even though we don't pass forceInstant, doFadeOut will be false because - // m_fadeouter will be still valid - connect( m_fadeouter.data(), SIGNAL(fadeoutFinished()), SLOT(stop()) ); - } - else - { - m_media.data()->stop(); - m_media.data()->setCurrentSource( Phonon::MediaSource() ); - } -} - -bool -EngineController::isPaused() const -{ - return m_media.data()->state() == Phonon::PausedState; -} - -bool -EngineController::isPlaying() const -{ - return !isPaused() && !isStopped(); -} - -bool -EngineController::isStopped() const -{ - return - m_media.data()->state() == Phonon::StoppedState || - m_media.data()->state() == Phonon::LoadingState || - m_media.data()->state() == Phonon::ErrorState; -} - -void -EngineController::playPause() //SLOT -{ - DEBUG_BLOCK - debug() << "PlayPause: EngineController state" << m_media.data()->state(); - - if( isPlaying() ) - pause(); - else - play(); -} - -void -EngineController::seekTo( int ms ) //SLOT -{ - DEBUG_BLOCK - - if( m_media.data()->isSeekable() ) - { - - debug() << "seek to: " << ms; - int seekTo; - - if( m_boundedPlayback ) - { - seekTo = m_boundedPlayback->startPosition() + ms; - if( seekTo < m_boundedPlayback->startPosition() ) - seekTo = m_boundedPlayback->startPosition(); - else if( seekTo > m_boundedPlayback->startPosition() + trackLength() ) - seekTo = m_boundedPlayback->startPosition() + trackLength(); - } - else - seekTo = ms; - - m_media.data()->seek( static_cast( seekTo ) ); - emit trackPositionChanged( seekTo, true ); /* User seek */ - } - else - debug() << "Stream is not seekable."; -} - - -void -EngineController::seekBy( int ms ) //SLOT -{ - qint64 newPos = m_media.data()->currentTime() + ms; - seekTo( newPos <= 0 ? 0 : newPos ); -} - -int -EngineController::increaseVolume( int ticks ) //SLOT -{ - return setVolume( volume() + ticks ); -} - -int -EngineController::decreaseVolume( int ticks ) //SLOT -{ - return setVolume( volume() - ticks ); -} - -int -EngineController::setVolume( int percent ) //SLOT -{ - percent = qBound( 0, percent, 100 ); - m_volume = percent; - - const qreal volume = percent / 100.0; - if ( !m_ignoreVolumeChangeAction && m_audio.data()->volume() != volume ) - { - m_ignoreVolumeChangeObserve = true; - m_audio.data()->setVolume( volume ); - - AmarokConfig::setMasterVolume( percent ); - emit volumeChanged( percent ); - } - m_ignoreVolumeChangeAction = false; - - return percent; -} - -int -EngineController::volume() const -{ - return m_volume; -} - -bool -EngineController::isMuted() const -{ - return m_audio.data()->isMuted(); -} - -void -EngineController::setMuted( bool mute ) //SLOT -{ - m_audio.data()->setMuted( mute ); // toggle mute - if( !isMuted() ) - setVolume( m_volume ); - - AmarokConfig::setMuteState( mute ); - emit muteStateChanged( mute ); -} - -void -EngineController::toggleMute() //SLOT -{ - setMuted( !isMuted() ); -} - -Meta::TrackPtr -EngineController::currentTrack() const -{ - return m_currentTrack; -} - -qint64 -EngineController::trackLength() const -{ - //When starting a last.fm stream, Phonon still shows the old track's length--trust - //Meta::Track over Phonon - if( m_currentTrack && m_currentTrack->length() > 0 ) - return m_currentTrack->length(); - else - return m_media.data()->totalTime(); //may return -1 -} - -void -EngineController::setNextTrack( Meta::TrackPtr track ) -{ - DEBUG_BLOCK - if( !track ) - return; - - track->prepareToPlay(); - KUrl url = track->playableUrl(); - if( url.isEmpty() ) - return; - - QMutexLocker locker( &m_mutex ); - if( isPlaying() ) - { - m_media.data()->clearQueue(); - // keep in sync with playUrl(), slotPlayableUrlFetched() - if( url.isLocalFile() ) - m_media.data()->enqueue( url.toLocalFile() ); - else if( url.protocol() != "audiocd" ) // we don't support gapless for CD, bug 305708 - m_media.data()->enqueue( url ); - m_nextTrack = track; - m_nextUrl = url; - } - else - play( track ); -} - -bool -EngineController::isStream() -{ - Phonon::MediaSource::Type type = Phonon::MediaSource::Invalid; - if( m_media ) - // type is determined purely from the MediaSource constructor used in - // setCurrentSource(). For streams we use the KUrl one, see playUrl() - type = m_media.data()->currentSource().type(); - return type == Phonon::MediaSource::Url || type == Phonon::MediaSource::Stream; -} - -bool -EngineController::isSeekable() const -{ - if( m_media ) - return m_media.data()->isSeekable(); - return false; -} - -int -EngineController::trackPosition() const -{ - return trackPositionMs() / 1000; -} - -qint64 -EngineController::trackPositionMs() const -{ - return m_media.data()->currentTime(); -} - -bool -EngineController::supportsFadeout() const -{ - return m_fader; -} - -bool EngineController::supportsGainAdjustments() const -{ - return m_preamp; -} - -bool EngineController::supportsAudioDataOutput() const -{ - const Phonon::AudioDataOutput out; - return out.isValid(); -} - - -////////////////////////////////////////////////////////////////////////////////////////// -// PRIVATE SLOTS -////////////////////////////////////////////////////////////////////////////////////////// - -void -EngineController::slotTick( qint64 position ) -{ - if( m_boundedPlayback ) - { - qint64 newPosition = position; - emit trackPositionChanged( - static_cast( position - m_boundedPlayback->startPosition() ), - false - ); - - // Calculate a better position. Sometimes the position doesn't update - // with a good resolution (for example, 1 sec for TrueAudio files in the - // Xine-1.1.18 backend). This tick function, in those cases, just gets - // called multiple times with the same position. We count how many - // times this has been called prior, and adjust for it. - if( position == m_lastTickPosition ) - newPosition += ++m_lastTickCount * m_tickInterval; - else - m_lastTickCount = 0; - - m_lastTickPosition = position; - - //don't go beyond the stop point - if( newPosition >= m_boundedPlayback->endPosition() ) - { - slotAboutToFinish(); - } - } - else - { - m_lastTickPosition = position; - emit trackPositionChanged( static_cast( position ), false ); - } -} - -void -EngineController::slotAboutToFinish() -{ - DEBUG_BLOCK - - if( m_fadeouter ) - { - debug() << "slotAboutToFinish(): a fadeout is in progress, don't queue new track"; - return; - } - - if( m_multiPlayback ) - { - DEBUG_LINE_INFO - m_mutex.lock(); - m_playWhenFetched = false; - m_mutex.unlock(); - m_multiPlayback->fetchNext(); - debug() << "The queue has: " << m_media.data()->queue().size() << " tracks in it"; - } - else if( m_multiSource ) - { - debug() << "source finished, lets get the next one"; - KUrl nextSource = m_multiSource->nextUrl(); - - if( !nextSource.isEmpty() ) - { //more sources - m_mutex.lock(); - m_playWhenFetched = false; - m_mutex.unlock(); - debug() << "playing next source: " << nextSource; - slotPlayableUrlFetched( nextSource ); - } - else if( m_media.data()->queue().isEmpty() ) - { - debug() << "no more sources, skip to next track"; - m_multiSource.reset(); // don't cofuse slotFinished - The::playlistActions()->requestNextTrack(); - } - } - else if( m_boundedPlayback ) - { - debug() << "finished a track that consists of part of another track, go to next track even if this url is technically not done yet"; - - //stop this track, now, as the source track might go on and on, and - //there might not be any more tracks in the playlist... - stop( true ); - The::playlistActions()->requestNextTrack(); - } - else if( m_media.data()->queue().isEmpty() ) - The::playlistActions()->requestNextTrack(); -} - -void -EngineController::slotFinished() -{ - DEBUG_BLOCK - - // paranoia checking, m_currentTrack shouldn't really be null - if( m_currentTrack ) - { - debug() << "Track finished completely, updating statistics"; - unsubscribeFrom( m_currentTrack ); // don't bother with trackMetadataChanged() - stampStreamTrackLength(); // update track length in stream for accurate scrobbling - emit trackFinishedPlaying( m_currentTrack, 1.0 ); - subscribeTo( m_currentTrack ); - } - - if( !m_multiPlayback && !m_multiSource ) - { - // again. at this point the track is finished so it's trackPositionMs is 0 - if( !m_nextTrack && m_nextUrl.isEmpty() ) - emit stopped( m_currentTrack ? m_currentTrack->length() : 0, - m_currentTrack ? m_currentTrack->length() : 0 ); - unsubscribeFrom( m_currentTrack ); - if( m_currentAlbum ) - unsubscribeFrom( m_currentAlbum ); - m_currentTrack = 0; - m_currentAlbum = 0; - if( !m_nextTrack && m_nextUrl.isEmpty() ) // we will the trackChanged signal later - emit trackChanged( Meta::TrackPtr() ); - m_media.data()->setCurrentSource( Phonon::MediaSource() ); - } - - m_mutex.lock(); // in case setNextTrack is being handled right now. - - // Non-local urls are not enqueued so we must play them explicitly. - if( m_nextTrack ) - { - DEBUG_LINE_INFO - play( m_nextTrack ); - } - else if( !m_nextUrl.isEmpty() ) - { - DEBUG_LINE_INFO - playUrl( m_nextUrl, 0 ); - } - else - { - DEBUG_LINE_INFO - // possibly we are waiting for a fetch - m_playWhenFetched = true; - } - - m_mutex.unlock(); -} - -static const qreal log10over20 = 0.1151292546497022842; // ln(10) / 20 - -void -EngineController::slotNewTrackPlaying( const Phonon::MediaSource &source ) -{ - DEBUG_BLOCK - - if( source.type() == Phonon::MediaSource::Empty ) - { - debug() << "Empty MediaSource (engine stop)"; - return; - } - - if( m_currentTrack ) - { - unsubscribeFrom( m_currentTrack ); - if( m_currentAlbum ) - unsubscribeFrom( m_currentAlbum ); - } - // only update stats if we are called for something new, some phonon back-ends (at - // least phonon-gstreamer-4.6.1) call slotNewTrackPlaying twice with the same source - if( m_currentTrack && ( m_nextTrack || !m_nextUrl.isEmpty() ) ) - { - debug() << "Previous track finished completely, updating statistics"; - stampStreamTrackLength(); // update track length in stream for accurate scrobbling - emit trackFinishedPlaying( m_currentTrack, 1.0 ); - - if( m_multiSource ) - // advance source of a multi-source track - m_multiSource->setSource( m_multiSource->current() + 1 ); - } - m_nextUrl.clear(); - - if( m_nextTrack ) - { - // already unsubscribed - m_currentTrack = m_nextTrack; - m_nextTrack.clear(); - - m_multiSource.reset( m_currentTrack->create() ); - if( m_multiSource ) - { - debug() << "Got a MultiSource Track with" << m_multiSource->sources().count() << "sources"; - connect( m_multiSource.data(), SIGNAL(urlChanged(KUrl)), - SLOT(slotPlayableUrlFetched(KUrl)) ); - } - } - - if( m_currentTrack - && AmarokConfig::replayGainMode() != AmarokConfig::EnumReplayGainMode::Off ) - { - Meta::ReplayGainTag mode; - // gain is usually negative (but may be positive) - mode = ( AmarokConfig::replayGainMode() == AmarokConfig::EnumReplayGainMode::Track) - ? Meta::ReplayGain_Track_Gain - : Meta::ReplayGain_Album_Gain; - qreal gain = m_currentTrack->replayGain( mode ); - - // peak is usually positive and smaller than gain (but may be negative) - mode = ( AmarokConfig::replayGainMode() == AmarokConfig::EnumReplayGainMode::Track) - ? Meta::ReplayGain_Track_Peak - : Meta::ReplayGain_Album_Peak; - qreal peak = m_currentTrack->replayGain( mode ); - if( gain + peak > 0.0 ) - { - debug() << "Gain of" << gain << "would clip at absolute peak of" << gain + peak; - gain -= gain + peak; - } - - if( m_preamp ) - { - debug() << "Using gain of" << gain << "with relative peak of" << peak; - // we calculate the volume change ourselves, because m_preamp.data()->setVolumeDecibel is - // a little confused about minus signs - m_preamp.data()->setVolume( qExp( gain * log10over20 ) ); - } - else - warning() << "Would use gain of" << gain << ", but current Phonon backend" - << "doesn't seem to support pre-amplifier (VolumeFaderEffect)"; - } - else if( m_preamp ) - { - m_preamp.data()->setVolume( 1.0 ); - } - - bool useTrackWithinStreamDetection = false; - if( m_currentTrack ) - { - subscribeTo( m_currentTrack ); - Meta::AlbumPtr m_currentAlbum = m_currentTrack->album(); - if( m_currentAlbum ) - subscribeTo( m_currentAlbum ); - /** We only use detect-tracks-in-stream for tracks that have stream type - * (exactly, we purposely exclude stream/lastfm) *and* that don't have length - * already filled in. Bug 311852 */ - if( m_currentTrack->type() == "stream" && m_currentTrack->length() == 0 ) - useTrackWithinStreamDetection = true; - } - - m_lastStreamStampPosition = useTrackWithinStreamDetection ? 0 : -1; - emit trackChanged( m_currentTrack ); - emit trackPlaying( m_currentTrack ); -} - -void -EngineController::slotStateChanged( Phonon::State newState, Phonon::State oldState ) //SLOT -{ - debug() << "slotStateChanged from" << oldState << "to" << newState; - - static const int maxErrors = 5; - static int errorCount = 0; - - // Sanity checks: - if( newState == oldState ) - return; - - if( newState == Phonon::ErrorState ) // If media is borked, skip to next track - { - emit trackError( m_currentTrack ); - - warning() << "Phonon failed to play this URL. Error: " << m_media.data()->errorString(); - warning() << "Forcing phonon engine reinitialization."; - - /* In case of error Phonon MediaObject automatically switches to KioMediaSource, - which cause problems: runs StopAfterCurrentTrack mode, force PlayPause button to - reply the track (can't be paused). So we should reinitiate Phonon after each Error. - */ - initializePhonon(); - - errorCount++; - if ( errorCount >= maxErrors ) - { - // reset error count - errorCount = 0; - - Amarok::Components::logger()->longMessage( - i18n( "Too many errors encountered in playlist. Playback stopped." ), - Amarok::Logger::Warning - ); - error() << "Stopping playlist."; - } - else - // and start the next song, even if the current failed to start playing - The::playlistActions()->requestUserNextTrack(); - - } - else if( newState == Phonon::PlayingState ) - { - errorCount = 0; - emit playbackStateChanged(); - } - else if( newState == Phonon::StoppedState || - newState == Phonon::PausedState ) - { - emit playbackStateChanged(); - } -} - -void -EngineController::slotPlayableUrlFetched( const KUrl &url ) -{ - DEBUG_BLOCK - debug() << "Fetched url: " << url; - if( url.isEmpty() ) - { - DEBUG_LINE_INFO - The::playlistActions()->requestNextTrack(); - return; - } - - if( !m_playWhenFetched ) - { - DEBUG_LINE_INFO - m_mutex.lock(); - m_media.data()->clearQueue(); - // keep synced with setNextTrack(), playUrl() - if( url.isLocalFile() ) - m_media.data()->enqueue( url.toLocalFile() ); - else - m_media.data()->enqueue( url ); - m_nextTrack.clear(); - m_nextUrl = url; - debug() << "The next url we're playing is: " << m_nextUrl; - // reset this flag each time - m_playWhenFetched = true; - m_mutex.unlock(); - } - else - { - DEBUG_LINE_INFO - m_mutex.lock(); - playUrl( url, 0 ); - m_mutex.unlock(); - } -} - -void -EngineController::slotTrackLengthChanged( qint64 milliseconds ) -{ - debug() << "slotTrackLengthChanged(" << milliseconds << ")"; - emit trackLengthChanged( ( !m_multiPlayback || !m_boundedPlayback ) - ? trackLength() : milliseconds ); -} - -void -EngineController::slotMetaDataChanged() -{ - QVariantMap meta; - meta.insert( Meta::Field::URL, m_media.data()->currentSource().url() ); - static const QList fieldPairs = QList() - << FieldPair( Phonon::ArtistMetaData, Meta::Field::ARTIST ) - << FieldPair( Phonon::AlbumMetaData, Meta::Field::ALBUM ) - << FieldPair( Phonon::TitleMetaData, Meta::Field::TITLE ) - << FieldPair( Phonon::GenreMetaData, Meta::Field::GENRE ) - << FieldPair( Phonon::TracknumberMetaData, Meta::Field::TRACKNUMBER ) - << FieldPair( Phonon::DescriptionMetaData, Meta::Field::COMMENT ); - foreach( const FieldPair &pair, fieldPairs ) - { - QStringList values = m_media.data()->metaData( pair.first ); - if( !values.isEmpty() ) - meta.insert( pair.second, values.first() ); - } - - // note: don't rely on m_currentTrack here. At least some Phonon backends first emit - // totalTimeChanged(), then metaDataChanged() and only then currentSourceChanged() - // which currently sets correct m_currentTrack. - if( isInRecentMetaDataHistory( meta ) ) - { - // slotMetaDataChanged() triggered by phonon, but we've already seen - // exactly the same metadata recently. Ignoring for now. - return; - } - - // following is an implementation of song end (and length) within a stream detection. - // This normally fires minutes after the track has started playing so m_currentTrack - // should be accurate - if( m_currentTrack && m_lastStreamStampPosition >= 0 ) - { - stampStreamTrackLength(); - emit trackFinishedPlaying( m_currentTrack, 1.0 ); - - // update track length to 0 because length emitted by stampStreamTrackLength() - // is for the previous song - meta.insert( Meta::Field::LENGTH, 0 ); - } - - debug() << "slotMetaDataChanged(): new meta-data:" << meta; - emit currentMetadataChanged( meta ); -} - -void -EngineController::slotSeekableChanged( bool seekable ) -{ - emit seekableChanged( seekable ); -} - -void -EngineController::slotTitleChanged( int titleNumber ) -{ - DEBUG_BLOCK - if ( titleNumber != m_currentAudioCdTrack ) - { - The::playlistActions()->requestNextTrack(); - slotFinished(); - } -} - -void EngineController::slotVolumeChanged( qreal newVolume ) -{ - int percent = qBound( 0, qRound(newVolume * 100), 100 ); - - if ( !m_ignoreVolumeChangeObserve && m_volume != percent ) - { - m_ignoreVolumeChangeAction = true; - - m_volume = percent; - AmarokConfig::setMasterVolume( percent ); - emit volumeChanged( percent ); - } - else - m_volume = percent; - - m_ignoreVolumeChangeObserve = false; -} - -void EngineController::slotMutedChanged( bool mute ) -{ - AmarokConfig::setMuteState( mute ); - emit muteStateChanged( mute ); -} - -void -EngineController::slotTrackFinishedPlaying( Meta::TrackPtr track, double playedFraction ) -{ - Q_ASSERT( track ); - debug() << "slotTrackFinishedPlaying(" - << ( track->artist() ? track->artist()->name() : QString( "[no artist]" ) ) - << "-" << ( track->album() ? track->album()->name() : QString( "[no album]" ) ) - << "-" << track->name() - << "," << playedFraction << ")"; - track->finishedPlaying( playedFraction ); -} - -void -EngineController::metadataChanged( Meta::TrackPtr track ) -{ - Meta::AlbumPtr album = m_currentTrack->album(); - if( m_currentAlbum != album ) { - if( m_currentAlbum ) - unsubscribeFrom( m_currentAlbum ); - m_currentAlbum = album; - if( m_currentAlbum ) - subscribeTo( m_currentAlbum ); - } - emit trackMetadataChanged( track ); -} - -void -EngineController::metadataChanged( Meta::AlbumPtr album ) -{ - emit albumMetadataChanged( album ); -} - -QString EngineController::prettyNowPlaying( bool progress ) const -{ - Meta::TrackPtr track = currentTrack(); - - if( track ) - { - QString title = Qt::escape( track->name() ); - QString prettyTitle = Qt::escape( track->prettyName() ); - QString artist = track->artist() ? Qt::escape( track->artist()->name() ) : QString(); - QString album = track->album() ? Qt::escape( track->album()->name() ) : QString(); - - // ugly because of translation requirements - if( !title.isEmpty() && !artist.isEmpty() && !album.isEmpty() ) - title = i18nc( "track by artist on album", "%1 by %2 on %3", title, artist, album ); - else if( !title.isEmpty() && !artist.isEmpty() ) - title = i18nc( "track by artist", "%1 by %2", title, artist ); - else if( !album.isEmpty() ) - // we try for pretty title as it may come out better - title = i18nc( "track on album", "%1 on %2", prettyTitle, album ); - else - title = "" + prettyTitle + ""; - - if( title.isEmpty() ) - title = i18n( "Unknown track" ); - - QScopedPointer sic( track->create() ); - if( sic ) - { - QString source = sic->sourceName(); - if( !source.isEmpty() ) - title += ' ' + i18nc( "track from source", "from %1", source ); - } - - if( track->length() > 0 ) - { - QString length = Qt::escape( Meta::msToPrettyTime( track->length() ) ); - title += " ("; - if( progress ) - title+= Qt::escape( Meta::msToPrettyTime( m_lastTickPosition ) ) + '/'; - title += length + ')'; - } - - return title; - } - else - return i18n( "No track playing" ); -} - -bool -EngineController::isInRecentMetaDataHistory( const QVariantMap &meta ) -{ - // search for Metadata in history - for( int i = 0; i < m_metaDataHistory.size(); i++) - { - if( m_metaDataHistory.at( i ) == meta ) // we already had that one -> spam! - { - m_metaDataHistory.move( i, 0 ); // move spam to the beginning of the list - return true; - } - } - - if( m_metaDataHistory.size() == 12 ) - m_metaDataHistory.removeLast(); - - m_metaDataHistory.insert( 0, meta ); - return false; -} - -void -EngineController::stampStreamTrackLength() -{ - if( m_lastStreamStampPosition < 0 ) - return; - - qint64 currentPosition = trackPositionMs(); - debug() << "stampStreamTrackLength(): m_lastStreamStampPosition:" << m_lastStreamStampPosition - << "currentPosition:" << currentPosition; - if( currentPosition == m_lastStreamStampPosition ) - return; - qint64 length = qMax( currentPosition - m_lastStreamStampPosition, qint64( 0 ) ); - updateStreamLength( length ); - - m_lastStreamStampPosition = currentPosition; -} - -void -EngineController::updateStreamLength( qint64 length ) -{ - if( !m_currentTrack ) - { - warning() << __PRETTY_FUNCTION__ << "called with cull m_currentTrack"; - return; - } - - // Last.fm scrobbling needs to know track length before it can scrobble: - QVariantMap lengthMetaData; - // we cannot use m_media->currentSource()->url() here because it is already empty, bug 309976 - lengthMetaData.insert( Meta::Field::URL, QUrl( m_currentTrack->playableUrl() ) ); - lengthMetaData.insert( Meta::Field::LENGTH, length ); - debug() << "updateStreamLength(): emitting currentMetadataChanged(" << lengthMetaData << ")"; - emit currentMetadataChanged( lengthMetaData ); -} - -#include "moc_EngineController.cpp" // mention explicitly so that it knows full Meta::Track diff --git a/amarok/src/EngineController.h b/amarok/src/EngineController.h deleted file mode 100644 index 43db97a3..00000000 --- a/amarok/src/EngineController.h +++ /dev/null @@ -1,576 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2004 Frederik Holljen * - * Copyright (c) 2004,2005 Max Howell * - * Copyright (c) 2004-2013 Mark Kretschmann * - * Copyright (c) 2008 Jason A. Donenfeld * - * Copyright (c) 2009 Artur Szymiec * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_ENGINECONTROLLER_H -#define AMAROK_ENGINECONTROLLER_H - -#include "amarok_export.h" -#include "core/capabilities/BoundedPlaybackCapability.h" -#include "core/meta/Observer.h" -#include "playback/EqualizerController.h" - -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -class Fadeouter; -namespace Capabilities { class MultiPlayableCapability; class MultiSourceCapability; } -namespace Phonon { class AudioOutput; class MediaSource; class VolumeFaderEffect; } -class QTimer; - -/** - * A thin wrapper around Phonon that implements Amarok-specific functionality like - * replay gain, fade-out on stop and various track capabilities that affect - * playback. - */ -class AMAROK_EXPORT EngineController : public QObject, public Meta::Observer -{ - Q_OBJECT - -public: - static const uint DATAOUTPUT_DATA_SIZE = 512; - - /** - * Construct EngineController. Must be called from the main thread. - */ - EngineController(); - ~EngineController(); - - /** - * Returns the global EngineController instance - */ - static EngineController* instance(); - - /** - * Loads and plays the track that was playing when endSession() was last - * called (ie: when Amarok was quit) - */ - void restoreSession(); - - /** - * Saves the currently playing track and the playing/paused/stopped state - */ - void endSession(); - - /** - * Returns a list of backend supported mime types. This method is thread-safe. - */ - QStringList supportedMimeTypes(); - - /** @return track position (elapsed time) in seconds */ - int trackPosition() const; - - /** @return track position (elapsed time) in milliseconds */ - qint64 trackPositionMs() const; - - /** - * Returns the current track that is loaded into the engine. - * @return a Meta::TrackPtr which is either the track, or empty if phonon - * has a state of Phonon::ErrorState or Phonon::StoppedState - */ - Meta::TrackPtr currentTrack() const; - /** - * @return the length of the current track in milliseconds - */ - qint64 trackLength() const; - - /** - * Used to enqueue a track before it starts to play, for gapless playback. - * - * This will clear any tracks currently in the queue. If no track is playing, - * @p track will be played immediately. - */ - void setNextTrack( Meta::TrackPtr track ); - - /** - * Gets the volume - * @return the volume as a percentage - */ - int volume() const; - - /** - * @return @c true if sound output is disabled, @false otherwise - */ - bool isMuted() const; - - /** - * @return @c true if Amarok is paused, @c false if it is stopped or playing - */ - bool isPaused() const; - - /** - * @return @c true if Amarok is playing, @c false if it is stopped or pause - * Note: A fading out track is considered already stopped. - */ - bool isPlaying() const; - - /** - * @return @c true if Amarok is stopped, @c false if it is playing or pause - * Note: A fading out track is considered already stopped. - */ - bool isStopped() const; - - /** - * Streams sometimes have to be treated specially. - * For example, it is typically not possible to rewind a stream (at least, - * not without returning to the start of it). - * However for rewinding we have isSeekable(). - * Also for streams usually the meta data received by currentTrack() is only - * for the whole stream while the meta data received by currentMetaDataChanged - * will be more current (or contain advertisment) - * - * @return @c true if the current track is a stream, @c false otherwise - */ - bool isStream(); - - /** - * @return @c true if the current track is seekable, @c false otherwise - */ - bool isSeekable() const; - - /** - * Returns the associated EqualizerController object. - */ - EqualizerController *equalizerController() const; - - /** - * @return QString with a pretty name for the current track - * @param whether to include the playing progress (default false) - */ - QString prettyNowPlaying( bool progress = false ) const; - -public slots: - /** - * Plays the current track, if there is one - * This happens asynchronously. - */ - void play(); - - /** - * Plays the specified track - * This happens asynchronously. - */ - void play( Meta::TrackPtr track, uint offset = 0, bool startPaused = false ); - - /** - * Replays the current track - * - * This is a convenience method, calls seek( 0 ) actually - */ - void replay(); - - /** - * Pauses the current track - * This happens asynchronously. - */ - void pause(); - - /** - * Stops playing - * This happens asynchronously. - * - * @param forceInstant skip any fade-out effects - * @param playingWillContinue don't emit stopped() or trackChanged( 0 ) signals - */ - void stop( bool forceInstant = false, bool playingWillContinue = false ); - - /** - * Pauses if Amarok is currently playing, plays if Amarok is stopped or paused - * This happens asynchronously. - */ - void playPause(); //pauses if playing, plays if paused or stopped - - /** - * Seeks to a position in the track - * - * If the media is not seekable, or the state is something other than - * PlayingState, BufferingState or PausedState, has no effect. - * - * Deals correctly with tracks that have the BoundedPlayback capability. - * - * @param ms the position in milliseconds (counting from the start of the track) - */ - void seekTo( int ms ); - - /** - * Seeks forward or backward in the track - * - * If the media is not seekable, or the state is something other than - * PlayingState, BufferingState or PausedState, has no effect. - * - * Deals correctly with tracks that have the BoundedPlayback capability. - * - * A negative value seeks backwards, a positive value seeks forwards. - * - * If the value of @p ms would move the position to before the start of the track, - * the position is moved to the start of the track. - * - * @param ms the offset from the current position in milliseconds - */ - void seekBy( int ms ); - - /** - * Increases the volume - * - * @param ticks the amount to increase the volume by, given as a percentage of the - * maximum possible volume (ie: the same units as for setVolume()). - */ - int increaseVolume( int ticks = 100/25 ); - - /** - * Decreases the volume - * - * @param ticks the amount to decrease the volume by, given as a percentage of the - * maximum possible volume (ie: the same units as for setVolume()). - */ - int decreaseVolume( int ticks = 100/25 ); - - /** - * Sets the volume - * - * @param percent the new volume as a percentage of the maximum possible volume. - */ - // this amplifier does not go up to 11 - int setVolume( int percent ); - - /** - * Mutes or unmutes playback - * - * @param mute if @c true, audio output will be disabled; if @c false, audio output - * will be enabled. - */ - void setMuted( bool mute ); - - /** - * Toggles mute - * - * Works like setMuted( !isMuted() ); - */ - void toggleMute(); - - /** - * Return true if current Phonon back-end supports fade-out. - */ - bool supportsFadeout() const; - - /** - * Return true if current Phonon back-end supports our implementation of - * Replay Gain adjustment. - */ - bool supportsGainAdjustments() const; - - /** - * Return true if the current Phonon backend supports visualizations. - */ - bool supportsAudioDataOutput() const; - -Q_SIGNALS: - /** - * Emitted when the playback stops while playing a track. - * This signal is not emitted when the track pauses or the playback stopps because - * Amarok was closed and "resume at start" is configured. - * It is also not emitted if the playback continues with another track. In such - * a case you would just get another trackPlaying signal. - * Both parameters are in milli seconds. - */ - void stopped( qint64 /*ms*/ finalPosition, qint64 /*ms*/ trackLength ); - - /** - * Called when the playback is paused. - * When the playback is resumed a trackPlaying signal will be emitted. - * When the playback is stopped then a stopped signal will be emitted. - */ - void paused(); - - /** While trying to play the track an error occurred. - * This usually means that the engine will try to play the next track in - * the playlist until it gives up. - * So you will get a trackPlaying or stopped signal next. - */ - void trackError( Meta::TrackPtr track ); - - /** - * Called when a new track starts playing or an old track starts playing now. - * - * It also might be called several time in sequence - * with the same track in cases when e.g. you have - * a multi source track. - * - * Unlike trackChanged(), this is not called when playback stops. - */ - void trackPlaying( Meta::TrackPtr track ); - - /** - * Called when the current track changes - * - * Note that this is possibly only called once in case of a stream or on - * the other hand multiple times with the same track in cases when e.g. you have - * a multi source track. - * - * Unlike trackPlaying(), this is called when playback stops with Meta::TrackPtr( 0 ) for @p track. - * - * @param track The new track; may be null - */ - void trackChanged( Meta::TrackPtr track ); - - /** - * Emitted when the metadata of the current track changes. - * - * You might want to connect also to trackChanged() or trackPlaying() to get more - * changes because this signal is only emitted when the track metadata changes - * while it's playing, not when new track starts playing. This method now works - * correctly also for streams and is preferred to currentMetaDataChanged() because - * it providers somehow more filtered values. - */ - void trackMetadataChanged( Meta::TrackPtr track ); - - /** Emitted when the metadata of the current album changes. - */ - void albumMetadataChanged( Meta::AlbumPtr album ); - - /** - * Emitted then the information for the current changed. - * This signal contains data from Phonon about the meta data of the track or stream. - * This signal is expecially emitted when a stream changes it's metadata. - * This can happen e.g. in a ogg stream where the currentTrack data will probably - * not be updated. - * - * MetaStream::Track::Private in Stream_p.h will connect to this signal to update it's internal data - * and then itself trigger a trackMetadataChanged. - * @param metadata Contains the url, artist, album title, title, genre, tracknumber and length - */ - void currentMetadataChanged( QVariantMap metadata ); - - /** - * Called when the seekable value was changed - */ - void seekableChanged( bool seekable ); - - /** - * Called when the volume was changed - */ - void volumeChanged( int percent ); - - /** - * Called when audio output was enabled or disabled - * - * NB: if setMute() was called on the engine controller, but it didn't change the - * mute state, this will not be called - */ - void muteStateChanged( bool mute ); - - /** Called when the track position changes. - If the track just progresses you will get a notification every couple of milliseconds. - @parem position The current position in milliseconds - @param userSeek True if the position change was caused by the user - */ - void trackPositionChanged( qint64 position, bool userSeek ); - - /** - * Emitted when a track finished playing. You generally get this signal once per - * played track, but in case of a stream this may be emitted more than once when - * stream meta-data changes (which usually indicates that the next track started - * playing) - meta-data in the track are updated in this case. When you receive - * this signal, track score, play count etc. will be already updated. - * - * @param track track that has just finished playing - * @param playedFraction played/total length fraction, between 0 and 1 - */ - void trackFinishedPlaying( Meta::TrackPtr track, double playedFraction ); - - /** - Called when the track length changes, typically because the track has changed but - also when phonon manages to determine the full track length. - */ - void trackLengthChanged( qint64 milliseconds ); - - /** - * Called when Amarok is closed and we disconnect from Phonon. - * @param resumePlayback True if amarok will continue playback after a restart. - */ - void sessionEnded( bool resumePlayback ); - - /** - * Called when playback state changes to PlayingState, StoppedState or PausedState. - */ - void playbackStateChanged(); - - /** - * Is emitted when new audio Data is ready - * @param audioData The audio data that is available - */ - void audioDataReady( const QMap > &audioData ); - - /** - * A trick to call slotFillInSupportedMimeTypes() in a main thread, not to be used - * anywhere else than in supportedMimeTypes(). - */ - void fillInSupportedMimeTypes(); - -private slots: - /** - * Sets up the Phonon system - */ - void initializePhonon(); - /** This slot is connected to the phonon finished signal. - It is emitted when the queue is empty and the current media come to an end. - */ - void slotFinished(); - void slotAboutToFinish(); - void slotNewTrackPlaying( const Phonon::MediaSource &source); - void slotStateChanged( Phonon::State newState, Phonon::State oldState); - void slotPlayableUrlFetched( const KUrl &url ); - void slotTick( qint64 ); - void slotTrackLengthChanged( qint64 ); - void slotMetaDataChanged(); - void slotSeekableChanged( bool ); - void slotPause(); - - /** - * For volume/mute changes from the phonon side - */ - void slotVolumeChanged( qreal ); - void slotMutedChanged( bool ); - - /** - * Notify the engine that a new title has been reached when playing a cd. This - * is needed as a cd counts as basically one lone track, and we want to be able - * to play something else once one track has finished - */ - void slotTitleChanged( int titleNumber ); - - /** - * Fill in m_supportedMimeTypes list and release m_supportedMimeTypesSemaphore. This - * method must be called in the main thread so that there is no chance - * Phonon::BackendCapabilities::availableMimeTypes() is called in a non-gui thread - * for the first time. - */ - void slotFillInSupportedMimeTypes(); - - /** - * Calls track->finishedPlaying(), connected to trackFinishedPlaying() signal to - * reduce code duplication. - */ - void slotTrackFinishedPlaying( Meta::TrackPtr track, double playedFraction ); - -protected: - // reimplemented from Meta::Observer - using Observer::metadataChanged; - virtual void metadataChanged( Meta::TrackPtr track ); - virtual void metadataChanged( Meta::AlbumPtr album ); - -private: - /** - * Plays the media at a specified URL - * - * @param url the URL of the media - * @param offset the position in the media to start at in milliseconds - * @param startPaused if true, go to paused state. if false, go to playing state (default) - */ - void playUrl( const KUrl &url, uint offset, bool startPaused = false ); - - /** - * Try to detect MetaData spam in Streams etc. - * - * Some streams are doing advertisment in the metadata. We try to filter that - * out. Additionally, some Phonon back-ends emit more than one - * metadataChanged() signals per on track, so filter it all altogether. - */ - bool isInRecentMetaDataHistory( const QVariantMap &meta ); - - /** - * If m_lastStreamStampPosition is non-negative, update it to current position - * and update track length in current stream. - */ - void stampStreamTrackLength(); - - /** - * emit metadataChanged() with info so that MetaStream::Track that is - * currently listening updates its length. - * - * @param length new track length in milliseconds - */ - void updateStreamLength( qint64 length ); - - Q_DISABLE_COPY( EngineController ) - - EqualizerController *m_equalizerController; - QWeakPointer m_media; - QWeakPointer m_preamp; - QWeakPointer m_audio; - QWeakPointer m_audioDataOutput; - QWeakPointer m_controller; - Phonon::Path m_path; - Phonon::Path m_dataPath; - - QWeakPointer m_fadeouter; - QWeakPointer m_fader; - - Meta::TrackPtr m_currentTrack; - Meta::AlbumPtr m_currentAlbum; - Meta::TrackPtr m_nextTrack; - KUrl m_nextUrl; - Capabilities::BoundedPlaybackCapability* m_boundedPlayback; - Capabilities::MultiPlayableCapability* m_multiPlayback; - QScopedPointer m_multiSource; - bool m_playWhenFetched; - int m_volume; - int m_currentAudioCdTrack; - QTimer *m_pauseTimer; - - QList m_metaDataHistory; // against metadata spam - // last position (in ms) when the song changed (within the current stream) or -1 for non-stream - qint64 m_lastStreamStampPosition; - - /** - * Some flags to prevent feedback loops in volume updates - */ - bool m_ignoreVolumeChangeAction; - bool m_ignoreVolumeChangeObserve; - - // Used to get a more accurate estimate of the position for slotTick - int m_tickInterval; - qint64 m_lastTickPosition; - qint64 m_lastTickCount; - - QMutex m_mutex; - - // FIXME: this variable should be updated when - // Phonon::BackendCapabilities::notifier()'s capabilitiesChanged signal is emitted - QStringList m_supportedMimeTypes; - QSemaphore m_supportedMimeTypesSemaphore; -}; - -namespace The { - AMAROK_EXPORT EngineController* engineController(); -} - -#endif diff --git a/amarok/src/GlobalCollectionActions.cpp b/amarok/src/GlobalCollectionActions.cpp deleted file mode 100644 index ed158dcc..00000000 --- a/amarok/src/GlobalCollectionActions.cpp +++ /dev/null @@ -1,282 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "GlobalCollectionActions.h" -#include "core/meta/Meta.h" - - -namespace The -{ - static GlobalCollectionActions* s_GlobalCollectionActions_instance = 0; - - GlobalCollectionActions* globalCollectionActions() - { - if( !s_GlobalCollectionActions_instance ) - s_GlobalCollectionActions_instance = new GlobalCollectionActions(); - - return s_GlobalCollectionActions_instance; - } -} - -GlobalCollectionActions::GlobalCollectionActions() -{} - - -GlobalCollectionActions::~GlobalCollectionActions() -{} - -void -GlobalCollectionActions::addGenreAction( GlobalCollectionGenreAction * action ) -{ - m_genreActions.append( action ); -} - -void -GlobalCollectionActions::addArtistAction( GlobalCollectionArtistAction * action ) -{ - m_artistActions.append( action ); -} - -void -GlobalCollectionActions::addAlbumAction( GlobalCollectionAlbumAction * action ) -{ - m_albumActions.append( action ); -} - -void -GlobalCollectionActions::addTrackAction( GlobalCollectionTrackAction * action ) -{ - m_trackActions.append( action ); -} - -void -GlobalCollectionActions::addYearAction( GlobalCollectionYearAction * action ) -{ - m_yearActions.append( action ); -} - -void -GlobalCollectionActions::addComposerAction( GlobalCollectionComposerAction * action ) -{ - m_composerActions.append( action ); -} - -QList< QAction * > GlobalCollectionActions::actionsFor( Meta::DataPtr item ) -{ - - Meta::GenrePtr genrePtr = Meta::GenrePtr::dynamicCast( item ); - if ( genrePtr ) - return actionsFor( genrePtr ); - - Meta::ArtistPtr artistPtr = Meta::ArtistPtr::dynamicCast( item ); - if ( artistPtr ) - return actionsFor( artistPtr ); - - Meta::AlbumPtr albumPtr = Meta::AlbumPtr::dynamicCast( item ); - if ( albumPtr ) - return actionsFor( albumPtr ); - - Meta::TrackPtr trackPtr = Meta::TrackPtr::dynamicCast( item ); - if ( trackPtr ) - return actionsFor( trackPtr ); - - Meta::YearPtr yearPtr = Meta::YearPtr::dynamicCast( item ); - if ( yearPtr ) - return actionsFor( yearPtr ); - - Meta::ComposerPtr composerPtr = Meta::ComposerPtr::dynamicCast( item ); - if ( composerPtr ) - return actionsFor( composerPtr ); - - QList< QAction * > emptyList; - return emptyList; -} - - -QList< QAction * > -GlobalCollectionActions::actionsFor( Meta::GenrePtr genre ) -{ - QList< QAction * > returnList; - foreach( GlobalCollectionGenreAction * genreAction, m_genreActions ) - { - genreAction->setGenre( genre ); - returnList.append( genreAction ); - } - - return returnList; -} - -QList< QAction * > -GlobalCollectionActions::actionsFor( Meta::ArtistPtr artist ) -{ - QList< QAction * > returnList; - foreach( GlobalCollectionArtistAction * artistAction, m_artistActions ) - { - artistAction->setArtist( artist ); - returnList.append( artistAction ); - } - - return returnList; -} - -QList< QAction * > -GlobalCollectionActions::actionsFor( Meta::AlbumPtr album ) -{ - QList< QAction * > returnList; - foreach( GlobalCollectionAlbumAction * albumAction, m_albumActions ) - { - albumAction->setAlbum( album ); - returnList.append( albumAction ); - } - - return returnList; -} - -QList< QAction * > -GlobalCollectionActions::actionsFor( Meta::TrackPtr track ) -{ - QList< QAction * > returnList; - foreach( GlobalCollectionTrackAction * trackAction, m_trackActions ) - { - trackAction->setTrack( track ); - returnList.append( trackAction ); - } - - return returnList; -} - -QList< QAction * > -GlobalCollectionActions::actionsFor( Meta::YearPtr year ) -{ - QList< QAction * > returnList; - foreach( GlobalCollectionYearAction * yearAction, m_yearActions ) - { - yearAction->setYear( year ); - returnList.append( yearAction ); - } - - return returnList; -} - -QList< QAction * > -GlobalCollectionActions::actionsFor( Meta::ComposerPtr composer ) -{ - QList< QAction * > returnList; - foreach( GlobalCollectionComposerAction * composerAction, m_composerActions ) - { - composerAction->setComposer( composer ); - returnList.append( composerAction ); - } - - return returnList; -} - -GlobalCollectionAction::GlobalCollectionAction( const QString &text, QObject * parent ) - : QAction( text, parent ) -{} - -GlobalCollectionGenreAction::GlobalCollectionGenreAction( const QString &text, QObject * parent ) - : GlobalCollectionAction( text, parent ) -{} - -void -GlobalCollectionGenreAction::setGenre( Meta::GenrePtr genre ) -{ - m_currentGenre = genre; -} - -Meta::GenrePtr GlobalCollectionGenreAction::genre() -{ - return m_currentGenre; -} - -GlobalCollectionArtistAction::GlobalCollectionArtistAction( const QString &text, QObject * parent ) - : GlobalCollectionAction( text, parent ) -{} - -void -GlobalCollectionArtistAction::setArtist( Meta::ArtistPtr artist ) -{ - m_currentArtist = artist; -} - -Meta::ArtistPtr GlobalCollectionArtistAction::artist() -{ - return m_currentArtist; -} - -GlobalCollectionAlbumAction::GlobalCollectionAlbumAction( const QString &text, QObject * parent ) - : GlobalCollectionAction( text, parent ) -{} - -void GlobalCollectionAlbumAction::setAlbum( Meta::AlbumPtr album ) -{ - m_currentAlbum = album; -} - -Meta::AlbumPtr GlobalCollectionAlbumAction::album() -{ - return m_currentAlbum; -} - -GlobalCollectionTrackAction::GlobalCollectionTrackAction( const QString &text, QObject * parent ) - : GlobalCollectionAction( text, parent ) -{} - -void GlobalCollectionTrackAction::setTrack( Meta::TrackPtr track ) -{ - m_currentTrack = track; -} - -Meta::TrackPtr -GlobalCollectionTrackAction::track() -{ - return m_currentTrack; -} - -GlobalCollectionYearAction::GlobalCollectionYearAction( const QString &text, QObject * parent ) - : GlobalCollectionAction( text, parent ) -{} - -void -GlobalCollectionYearAction::setYear( Meta::YearPtr year ) -{ - m_currentYear = year; -} - -Meta::YearPtr -GlobalCollectionYearAction::year() -{ - return m_currentYear; -} - -GlobalCollectionComposerAction::GlobalCollectionComposerAction( const QString &text, QObject * parent ) - : GlobalCollectionAction( text, parent ) -{} - -void -GlobalCollectionComposerAction::setComposer(Meta::ComposerPtr composer) -{ - m_currentComposer = composer; -} - -Meta::ComposerPtr -GlobalCollectionComposerAction::composer() -{ - return m_currentComposer; -} - - diff --git a/amarok/src/GlobalCollectionActions.h b/amarok/src/GlobalCollectionActions.h deleted file mode 100644 index d1612300..00000000 --- a/amarok/src/GlobalCollectionActions.h +++ /dev/null @@ -1,166 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef GLOBALCOLLECTIONACTIONS_H -#define GLOBALCOLLECTIONACTIONS_H - -#include "amarok_export.h" -#include "core/meta/forward_declarations.h" -#include "core/support/SmartPointerList.h" - -#include - - -class AMAROK_EXPORT GlobalCollectionAction : public QAction -{ - public: - GlobalCollectionAction( const QString &text, QObject * parent ); -}; - - -class AMAROK_EXPORT GlobalCollectionGenreAction : public GlobalCollectionAction -{ - public: - - GlobalCollectionGenreAction( const QString &text, QObject * parent ); - void setGenre( Meta::GenrePtr genre ); - - protected: - Meta::GenrePtr genre(); - - private: - Meta::GenrePtr m_currentGenre; -}; - - -class AMAROK_EXPORT GlobalCollectionArtistAction : public GlobalCollectionAction -{ - public: - - GlobalCollectionArtistAction( const QString &text, QObject * parent ); - void setArtist( Meta::ArtistPtr artist ); - - protected: - Meta::ArtistPtr artist(); - - private: - Meta::ArtistPtr m_currentArtist; -}; - - -class AMAROK_EXPORT GlobalCollectionAlbumAction : public GlobalCollectionAction -{ - public: - - GlobalCollectionAlbumAction( const QString &text, QObject * parent ); - void setAlbum( Meta::AlbumPtr album ); - - protected: - Meta::AlbumPtr album(); - - private: - Meta::AlbumPtr m_currentAlbum; -}; - - -class AMAROK_EXPORT GlobalCollectionTrackAction : public GlobalCollectionAction -{ - public: - - GlobalCollectionTrackAction( const QString &text, QObject * parent ); - void setTrack( Meta::TrackPtr track ); - - protected: - Meta::TrackPtr track(); - - private: - Meta::TrackPtr m_currentTrack; - -}; - -class AMAROK_EXPORT GlobalCollectionYearAction : public GlobalCollectionAction -{ - public: - - GlobalCollectionYearAction( const QString &text, QObject * parent ); - void setYear( Meta::YearPtr year ); - - protected: - Meta::YearPtr year(); - - private: - Meta::YearPtr m_currentYear; - -}; - -class GlobalCollectionComposerAction : public GlobalCollectionAction -{ - public: - - GlobalCollectionComposerAction( const QString &text, QObject * parent ); - void setComposer( Meta::ComposerPtr composer ); - - protected: - Meta::ComposerPtr composer(); - - private: - Meta::ComposerPtr m_currentComposer; -}; - - -class GlobalCollectionActions; - -namespace The { - AMAROK_EXPORT GlobalCollectionActions* globalCollectionActions(); -} - -/** - This class keeps track of global context actions that should be added to all genre, artists or another meta type in all collections. -*/ -class AMAROK_EXPORT GlobalCollectionActions -{ - friend GlobalCollectionActions* The::globalCollectionActions(); - -public: - QList actionsFor( Meta::DataPtr item ); - - void addGenreAction( GlobalCollectionGenreAction * action ); - void addArtistAction( GlobalCollectionArtistAction * action ); - void addAlbumAction( GlobalCollectionAlbumAction * action ); - void addTrackAction( GlobalCollectionTrackAction * action ); - void addYearAction( GlobalCollectionYearAction * action ); - void addComposerAction( GlobalCollectionComposerAction * action ); - -private: - GlobalCollectionActions(); - ~GlobalCollectionActions(); - - QList actionsFor( Meta::GenrePtr genre ); - QList actionsFor( Meta::ArtistPtr artist ); - QList actionsFor( Meta::AlbumPtr album ); - QList actionsFor( Meta::TrackPtr track ); - QList actionsFor( Meta::YearPtr year ); - QList actionsFor( Meta::ComposerPtr composer ); - - SmartPointerList m_genreActions; - SmartPointerList m_artistActions; - SmartPointerList m_albumActions; - SmartPointerList m_trackActions; - SmartPointerList m_yearActions; - SmartPointerList m_composerActions; -}; - -#endif diff --git a/amarok/src/GlobalCurrentTrackActions.cpp b/amarok/src/GlobalCurrentTrackActions.cpp deleted file mode 100644 index e52af662..00000000 --- a/amarok/src/GlobalCurrentTrackActions.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "GlobalCurrentTrackActions.h" - - -namespace The -{ - static GlobalCurrentTrackActions* s_GlobalCurrentTrackActions_instance = 0; - - GlobalCurrentTrackActions* globalCurrentTrackActions() - { - if( !s_GlobalCurrentTrackActions_instance ) - s_GlobalCurrentTrackActions_instance = new GlobalCurrentTrackActions(); - - return s_GlobalCurrentTrackActions_instance; - } -} - - -GlobalCurrentTrackActions::GlobalCurrentTrackActions() -{} - - -GlobalCurrentTrackActions::~GlobalCurrentTrackActions() -{} - -void GlobalCurrentTrackActions::addAction( QAction * action ) -{ - m_actions.append( action ); -} - -QList< QAction * > GlobalCurrentTrackActions::actions() -{ - // Here we filter out dangling pointers to already destroyed QActions - - QList validActions; - - foreach( QAction* action, m_actions ) - validActions.append( action ); - - return validActions; -} - - diff --git a/amarok/src/GlobalCurrentTrackActions.h b/amarok/src/GlobalCurrentTrackActions.h deleted file mode 100644 index 77ae9548..00000000 --- a/amarok/src/GlobalCurrentTrackActions.h +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef GLOBALCURRENTTRACKACTIONS_H -#define GLOBALCURRENTTRACKACTIONS_H - -#include "amarok_export.h" -#include "core/meta/forward_declarations.h" -#include "core/support/SmartPointerList.h" - -#include - - -class GlobalCurrentTrackActions; - -namespace The { - AMAROK_EXPORT GlobalCurrentTrackActions* globalCurrentTrackActions(); -} - -/** -A global list of actions that is made available to all playing tracks. - - @author Nikolaj Hald Nielsen -*/ -class AMAROK_EXPORT GlobalCurrentTrackActions -{ - friend GlobalCurrentTrackActions* The::globalCurrentTrackActions(); - -public: - void addAction( QAction * action ); - QList actions(); - -private: - GlobalCurrentTrackActions(); - ~GlobalCurrentTrackActions(); - - SmartPointerList m_actions; -}; - -#endif diff --git a/amarok/src/KNotificationBackend.cpp b/amarok/src/KNotificationBackend.cpp deleted file mode 100644 index d10898e1..00000000 --- a/amarok/src/KNotificationBackend.cpp +++ /dev/null @@ -1,138 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009-2011 Kevin Funk * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "KNotificationBackend.h" - -#include "EngineController.h" -#include "SvgHandler.h" -#include "core/meta/Meta.h" -#include "core/support/Debug.h" - -#include -#include -#include -#include - -using namespace Amarok; - -KNotificationBackend * -KNotificationBackend::s_instance = 0; - -KNotificationBackend * -KNotificationBackend::instance() -{ - if( !s_instance ) - s_instance = new KNotificationBackend(); - return s_instance; -} - -void -KNotificationBackend::destroy() -{ - delete s_instance; - s_instance = 0; -} - -KNotificationBackend::KNotificationBackend() - : m_enabled( false ) -{ - EngineController *engine = The::engineController(); - connect( engine, SIGNAL(trackPlaying(Meta::TrackPtr)), SLOT(showCurrentTrack()) ); - connect( engine, SIGNAL(trackMetadataChanged(Meta::TrackPtr)), SLOT(showCurrentTrack()) ); - connect( engine, SIGNAL(albumMetadataChanged(Meta::AlbumPtr)), SLOT(showCurrentTrack()) ); - - if( engine->isPlaying() ) - showCurrentTrack(); -} - -KNotificationBackend::~KNotificationBackend() -{ - if( m_notify ) - m_notify.data()->close(); -} - -void -KNotificationBackend::setEnabled( bool enable ) -{ - m_enabled = enable; -} - -bool -KNotificationBackend::isEnabled() const -{ - return m_enabled; -} - -bool -KNotificationBackend::isFullscreenWindowActive() const -{ - // Get information of the active window. - KWindowInfo activeWindowInfo = KWindowSystem::windowInfo( KWindowSystem::activeWindow(), NET::WMState ); - - // Check if it is running in fullscreen mode. - return activeWindowInfo.hasState( NET::FullScreen ); -} - -void -KNotificationBackend::show( const QString &title, const QString &body, const QPixmap &pixmap ) -{ - QPixmap icon; - if( pixmap.isNull() ) - { - KIconLoader loader; - icon = loader.loadIcon( QString("amarok"), KIconLoader::Desktop ); - } - else - icon = pixmap; - - KNotification *notify = new KNotification( "message" ); - notify->setTitle( title ); - notify->setText( body ); - notify->setPixmap( icon ); - notify->sendEvent(); -} - -void -KNotificationBackend::showCurrentTrack( bool force ) -{ - if( !m_enabled && !force ) - return; - - EngineController *engine = The::engineController(); - Meta::TrackPtr track = engine->currentTrack(); - if( !track ) - { - warning() << __PRETTY_FUNCTION__ << "null track!"; - return; - } - - const QString title = i18n( "Now playing" ); - const QString text = engine->prettyNowPlaying(); - Meta::AlbumPtr album = track->album(); - const QPixmap pixmap = album ? The::svgHandler()->imageWithBorder( album, 80 ) : QPixmap(); - - KNotification *notify = m_notify.data(); - if( !notify ) - notify = new KNotification( "trackChange" ); - notify->setTitle( title ); - notify->setText( text ); - notify->setPixmap( pixmap ); - - if( m_notify ) // existing notification already shown - notify->update(); - notify->sendEvent(); // (re)start timeout in both cases - m_notify = notify; -} diff --git a/amarok/src/KNotificationBackend.h b/amarok/src/KNotificationBackend.h deleted file mode 100644 index 9f1b85da..00000000 --- a/amarok/src/KNotificationBackend.h +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009-2011 Kevin Funk * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_KNOTIFICATIONBACKEND_H -#define AMAROK_KNOTIFICATIONBACKEND_H - -#include "core/meta/forward_declarations.h" - -#include -#include - -class KNotification; - -namespace Amarok { - -/** - * Class for accessing KNotify in KDE - **/ -class KNotificationBackend : public QObject -{ - Q_OBJECT - -public: - static KNotificationBackend *instance(); - static void destroy(); - - void setEnabled( bool enabled ); - bool isEnabled() const; - - /** - * Checks if a fullscreen window is currently active. - */ - bool isFullscreenWindowActive() const; - -public slots: - - /** - * Shows a message. Warning, this method doesn't check isEnabled(), you - * should do it yourself. - */ - void show( const QString &title, const QString &body, const QPixmap &pixmap = QPixmap() ); - - /** - * @param force - if true, isEnabled() is not checked, otherwise it is - */ - void showCurrentTrack( bool force = false ); - -private: - KNotificationBackend(); - ~KNotificationBackend(); - - static KNotificationBackend *s_instance; - - bool m_enabled; - QWeakPointer m_notify; -}; - -} - -#endif diff --git a/amarok/src/LastfmReadLabelCapability.cpp b/amarok/src/LastfmReadLabelCapability.cpp deleted file mode 100644 index 3176560b..00000000 --- a/amarok/src/LastfmReadLabelCapability.cpp +++ /dev/null @@ -1,98 +0,0 @@ -/*************************************************************************************** -* Copyright (c) 2009 Dan Meltzer * -* * -* This program 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 2 of the License, or (at your option) any later * -* version. * -* * -* This program 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 * -* this program. If not, see . * -****************************************************************************************/ - -#include "LastfmReadLabelCapability.h" - -#include "core/support/Amarok.h" -#include "core/support/Debug.h" -#include "core/meta/Meta.h" - -#include -#include - -#include - -namespace Capabilities -{ -LastfmReadLabelCapability::LastfmReadLabelCapability( Meta::Track *track ) - : ReadLabelCapability() - , m_track( track ) -{ - DEBUG_BLOCK - fetchLabels(); -} - -void -LastfmReadLabelCapability::fetchGlobalLabels() -{ - DEBUG_BLOCK - AMAROK_NOTIMPLEMENTED -} - -void -LastfmReadLabelCapability::fetchLabels() -{ - DEBUG_BLOCK - QMap query; - query[ "method" ] = "track.getTopTags"; - query[ "track" ] = m_track->name(); - query[ "artist" ] = m_track->artist() ? m_track->artist()->name() : QString(); - query[ "api_key"] = Amarok::lastfmApiKey(); - m_job = lastfm::ws::post( query ); - - connect( m_job, SIGNAL(finished()), SLOT(onTagsFetched()) ); -} - - -void -LastfmReadLabelCapability::onTagsFetched() -{ - DEBUG_BLOCK - if( !m_job ) - { - debug() << "WARNING: GOT RESULT but no object"; - return; - } - - switch ( m_job->error() ) - { - case QNetworkReply::NoError: - { - lastfm::XmlQuery lfm; - lfm.parse(m_job->readAll()); - QList tags = lfm.children( "tag" ); - QStringList ret; - foreach( const lastfm::XmlQuery &child, tags ) - ret.append( child["name"].text() ); - m_labels = ret; - emit labelsFetched( ret ); - break; - } - default: - break; - } -} - - -QStringList -LastfmReadLabelCapability::labels() -{ - return m_labels; -} - -} - -#include "moc_LastfmReadLabelCapability.cpp" diff --git a/amarok/src/LastfmReadLabelCapability.h b/amarok/src/LastfmReadLabelCapability.h deleted file mode 100644 index 72fee354..00000000 --- a/amarok/src/LastfmReadLabelCapability.h +++ /dev/null @@ -1,51 +0,0 @@ -/*************************************************************************************** -* Copyright (c) 2009 Dan Meltzer * -* * -* This program 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 2 of the License, or (at your option) any later * -* version. * -* * -* This program 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 * -* this program. If not, see . * -****************************************************************************************/ - - -#ifndef LASTFMREADLABELCAPABILITY_H -#define LASTFMREADLABELCAPABILITY_H - -#include "core/meta/forward_declarations.h" -#include "core/capabilities/Capability.h" -#include "core/capabilities/ReadLabelCapability.h" - -#include - -class QNetworkReply; - -namespace Capabilities -{ - -class LastfmReadLabelCapability : public Capabilities::ReadLabelCapability -{ - Q_OBJECT - public: - LastfmReadLabelCapability( Meta::Track *track ); - virtual void fetchLabels(); - virtual void fetchGlobalLabels(); - virtual QStringList labels(); - - private: - QStringList m_labels; - Meta::TrackPtr m_track; - QNetworkReply *m_job; - - private slots: - void onTagsFetched(); -}; -} - -#endif // LASTFMREADLABELCAPABILITY_H diff --git a/amarok/src/MainWindow.cpp b/amarok/src/MainWindow.cpp deleted file mode 100644 index ae655110..00000000 --- a/amarok/src/MainWindow.cpp +++ /dev/null @@ -1,1387 +0,0 @@ - /**************************************************************************************** - * Copyright (c) 2002-2013 Mark Kretschmann * - * Copyright (c) 2002 Max Howell * - * Copyright (c) 2002 Gabor Lehel * - * Copyright (c) 2002 Nikolaj Hald Nielsen * - * Copyright (c) 2009 Artur Szymiec * - * Copyright (c) 2010 Téo Mrnjavac * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "MainWindow" - -#include "MainWindow.h" - -#include "ActionClasses.h" -#include "EngineController.h" //for actions in ctor -#include "KNotificationBackend.h" -#include "PaletteHandler.h" -#include "PluginManager.h" -#include "SvgHandler.h" -#include "amarokconfig.h" -#include "aboutdialog/ExtendedAboutDialog.h" -#include "aboutdialog/OcsData.h" -#include "amarokurls/AmarokUrlHandler.h" -#include "amarokurls/BookmarkManager.h" -#include "browsers/collectionbrowser/CollectionWidget.h" -#include "browsers/filebrowser/FileBrowser.h" -#include "browsers/playlistbrowser/PlaylistBrowser.h" -#include "browsers/playlistbrowser/PodcastCategory.h" -#include "browsers/servicebrowser/ServiceBrowser.h" -#include "context/ContextDock.h" -#include "core/meta/Statistics.h" -#include "core/support/Amarok.h" -#include "core/support/Components.h" -#include "core/support/Debug.h" -#include "core-impl/collections/support/CollectionManager.h" -#include "covermanager/CoverManager.h" // for actions -#include "dialogs/DiagnosticDialog.h" -#include "dialogs/EqualizerDialog.h" -#include "moodbar/MoodbarManager.h" -#include "network/NetworkAccessManagerProxy.h" -#ifdef DEBUG_BUILD_TYPE -#include "network/NetworkAccessViewer.h" -#endif // DEBUG_BUILD_TYPE -#include "playlist/PlaylistActions.h" -#include "playlist/PlaylistController.h" -#include "playlist/PlaylistModelStack.h" -#include "playlist/PlaylistDock.h" -#include "playlist/ProgressiveSearchWidget.h" -#include "playlist/layouts/LayoutConfigAction.h" -#include "playlistmanager/PlaylistManager.h" -#include "playlistmanager/file/PlaylistFileProvider.h" -#include "services/scriptable/ScriptableService.h" -#include "statsyncing/Controller.h" -#include "toolbar/MainToolbar.h" -#include "toolbar/SlimToolbar.h" -#include "widgets/Osd.h" - -#include //m_actionCollection -#include -#include //kapp -#include //openPlaylist() -#include //slotAddStream() -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#ifdef Q_WS_X11 -#include -#endif - -#ifdef Q_WS_MAC -#include "mac/GrowlInterface.h" -#ifdef HAVE_NOTIFICATION_CENTER -#include "mac/MacSystemNotify.h" -#endif -#endif - -#define AMAROK_CAPTION I18N_NOOP( "Amarok" ) - -extern OcsData ocsData; - -QWeakPointer MainWindow::s_instance; - -namespace The { - MainWindow* mainWindow() { return MainWindow::s_instance.data(); } -} - -MainWindow::MainWindow() - : KMainWindow( 0 ) - , m_showMenuBar( 0 ) - , m_lastBrowser( 0 ) - , m_waitingForCd( false ) -{ - DEBUG_BLOCK - - setObjectName( "MainWindow" ); - s_instance = this; - -#ifdef Q_WS_MAC - (void)new GrowlInterface( qApp->applicationName() ); -#ifdef HAVE_NOTIFICATION_CENTER - (void)new OSXNotify( qApp->applicationName() ); -#endif -#endif - - PERF_LOG( "Instantiate Collection Manager" ) - CollectionManager::instance(); - PERF_LOG( "Started Collection Manager instance" ) - - /* The PluginManager needs to be loaded before the playlist model - * (which gets started by "statusBar::connectPlaylist" below so that it can handle any - * tracks in the saved playlist that are associated with services. Eg, if - * the playlist has a Magnatune track in it when Amarok is closed, then the - * Magnatune service needs to be initialized before the playlist is loaded - * here. */ - PERF_LOG( "Instantiate Plugin Manager" ) - The::pluginManager(); - PERF_LOG( "Started Plugin Manager instance" ) - - createActions(); - PERF_LOG( "Created actions" ) - - The::paletteHandler()->setPalette( palette() ); - setWindowTitle( i18n( AMAROK_CAPTION ) ); - - init(); // We could as well move the code from init() here, but meh.. getting a tad long - - //restore active category ( as well as filters and levels and whatnot.. ) - const QString path = Amarok::config().readEntry( "Browser Path", QString() ); - if( !path.isEmpty() ) - m_browserDock.data()->list()->navigate( path ); - - setAutoSaveSettings(); - - m_showMenuBar->setChecked(!menuBar()->isHidden()); // workaround for bug #171080 - - EngineController *engine = The::engineController(); - connect( engine, SIGNAL(stopped(qint64,qint64)), - this, SLOT(slotStopped()) ); - connect( engine, SIGNAL(paused()), - this, SLOT(slotPaused()) ); - connect( engine, SIGNAL(trackPlaying(Meta::TrackPtr)), - this, SLOT(slotNewTrackPlaying()) ); - connect( engine, SIGNAL(trackMetadataChanged(Meta::TrackPtr)), - this, SLOT(slotMetadataChanged(Meta::TrackPtr)) ); - - KGlobal::locale()->insertCatalog( "libplasma" ); -} - -MainWindow::~MainWindow() -{ - DEBUG_BLOCK - - //save currently active category - Amarok::config().writeEntry( "Browser Path", m_browserDock.data()->list()->path() ); - -#ifdef DEBUG_BUILD_TYPE - delete m_networkViewer.data(); -#endif // DEBUG_BUILD_TYPE - delete The::svgHandler(); - delete The::paletteHandler(); -} - - -///////// public interface - -/** - * This function will initialize the main window. - */ -void -MainWindow::init() -{ - layout()->setContentsMargins( 0, 0, 0, 0 ); - layout()->setSpacing( 0 ); - - //create main toolbar - m_mainToolbar = new MainToolbar( 0 ); - m_mainToolbar.data()->setAllowedAreas( Qt::TopToolBarArea | Qt::BottomToolBarArea ); - m_mainToolbar.data()->setMovable ( true ); - addToolBar( Qt::TopToolBarArea, m_mainToolbar.data() ); - - //create slim toolbar - m_slimToolbar = new SlimToolbar( 0 ); - m_slimToolbar.data()->setAllowedAreas( Qt::TopToolBarArea | Qt::BottomToolBarArea ); - m_slimToolbar.data()->setMovable ( true ); - addToolBar( Qt::TopToolBarArea, m_slimToolbar.data() ); - m_slimToolbar.data()->hide(); - - //BEGIN Creating Widgets - PERF_LOG( "Create sidebar" ) - m_browserDock = new BrowserDock( this ); - m_browserDock.data()->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Ignored ); - - m_browserDock.data()->installEventFilter( this ); - PERF_LOG( "Sidebar created" ) - - PERF_LOG( "Create Playlist" ) - m_playlistDock = new Playlist::Dock( this ); - m_playlistDock.data()->installEventFilter( this ); - //HACK, need to connect after because of order in MainWindow() - connect( Amarok::actionCollection()->action( "playlist_edit_queue" ), - SIGNAL(triggered(bool)), m_playlistDock.data(), SLOT(slotEditQueue()) ); - PERF_LOG( "Playlist created" ) - - PERF_LOG( "Creating ContextWidget" ) - m_contextDock = new ContextDock( this ); - m_contextDock.data()->installEventFilter( this ); - - PERF_LOG( "ContextScene created" ) - //END Creating Widgets - - createMenus(); - - PERF_LOG( "Loading default contextScene" ) - - PERF_LOG( "Loaded default contextScene" ) - - setDockOptions( QMainWindow::AllowNestedDocks | QMainWindow::AllowTabbedDocks - | QMainWindow::AnimatedDocks | QMainWindow::VerticalTabs ); - - addDockWidget( Qt::LeftDockWidgetArea, m_browserDock.data() ); - addDockWidget( Qt::LeftDockWidgetArea, m_contextDock.data(), Qt::Horizontal ); - addDockWidget( Qt::LeftDockWidgetArea, m_playlistDock.data(), Qt::Horizontal ); - - setLayoutLocked( AmarokConfig::lockLayout() ); - - // - { - Debug::Block block( "Creating browsers. Please report long start times!" ); - - //TODO: parent these browsers? - PERF_LOG( "Creating CollectionWidget" ) - m_collectionBrowser = new CollectionWidget( "collections", 0 ); - //TODO: rename "Music Collections - m_collectionBrowser->setPrettyName( i18n( "Local Music" ) ); - m_collectionBrowser->setIcon( KIcon( "drive-harddisk" ) ); - m_collectionBrowser->setShortDescription( i18n( "Local sources of content" ) ); - m_browserDock.data()->list()->addCategory( m_collectionBrowser ); - PERF_LOG( "Created CollectionWidget" ) - - - PERF_LOG( "Creating ServiceBrowser" ) - ServiceBrowser *serviceBrowser = ServiceBrowser::instance(); - serviceBrowser->setParent( 0 ); - serviceBrowser->setPrettyName( i18n( "Internet" ) ); - serviceBrowser->setIcon( KIcon( "applications-internet" ) ); - serviceBrowser->setShortDescription( i18n( "Online sources of content" ) ); - m_browserDock.data()->list()->addCategory( serviceBrowser ); - PERF_LOG( "Created ServiceBrowser" ) - - PERF_LOG( "Creating PlaylistBrowser" ) - m_playlistBrowser = new PlaylistBrowserNS::PlaylistBrowser( "playlists", 0 ); - m_playlistBrowser->setPrettyName( i18n("Playlists") ); - m_playlistBrowser->setIcon( KIcon( "view-media-playlist-amarok" ) ); - m_playlistBrowser->setShortDescription( i18n( "Various types of playlists" ) ); - m_browserDock.data()->list()->addCategory( m_playlistBrowser ); - PERF_LOG( "CreatedPlaylsitBrowser" ) - - PERF_LOG( "Creating FileBrowser" ) - FileBrowser *fileBrowser = new FileBrowser( "files", 0 ); - fileBrowser->setPrettyName( i18n("Files") ); - fileBrowser->setIcon( KIcon( "folder-amarok" ) ); - fileBrowser->setShortDescription( i18n( "Browse local hard drive for content" ) ); - m_browserDock.data()->list()->addCategory( fileBrowser ); - PERF_LOG( "Created FileBrowser" ) - - serviceBrowser->setScriptableServiceManager( The::scriptableServiceManager() ); - PERF_LOG( "ScriptableServiceManager done" ) - - PERF_LOG( "Creating Podcast Category" ) - m_browserDock.data()->list()->addCategory( The::podcastCategory() ); - PERF_LOG( "Created Podcast Category" ) - - // If Amarok is started for the first time, set initial dock widget sizes - if( !Amarok::config( "MainWindow" ).hasKey( "State" ) ) - QTimer::singleShot( 0, this, SLOT(setDefaultDockSizes()) ); - - PERF_LOG( "finished MainWindow::init" ) - } - - The::amarokUrlHandler(); //Instantiate - The::coverFetcher(); //Instantiate - - // we must filter ourself to get mouseevents on the "splitter" - what is us, but filtered by the layouter - installEventFilter( this ); -} - -QMenu* -MainWindow::createPopupMenu() -{ - QMenu* menu = new QMenu( this ); - - // Show/hide menu bar - if (!menuBar()->isVisible()) - menu->addAction( m_showMenuBar ); - - menu->addSeparator(); - - addViewMenuItems(menu); - - return menu; -} - -void -MainWindow::addViewMenuItems(QMenu* menu) -{ - menu->setTitle( i18nc("@item:inmenu", "&View" ) ); - - // Layout locking: - QAction* lockAction = new QAction( i18n( "Lock Layout" ), this ); - lockAction->setCheckable( true ); - lockAction->setChecked( AmarokConfig::lockLayout() ); - connect( lockAction, SIGNAL(toggled(bool)), SLOT(setLayoutLocked(bool)) ); - menu->addAction( lockAction ); - - menu->addSeparator(); - - // Dock widgets: - QList dockwidgets = qFindChildren( this ); - - foreach( QDockWidget* dockWidget, dockwidgets ) - { - if( dockWidget->parentWidget() == this ) - menu->addAction( dockWidget->toggleViewAction() ); - } - - menu->addSeparator(); - - // Toolbars: - QList toolbars = qFindChildren( this ); - QActionGroup* toolBarGroup = new QActionGroup( this ); - toolBarGroup->setExclusive( true ); - - foreach( QToolBar* toolBar, toolbars ) - { - if( toolBar->parentWidget() == this ) - { - QAction* action = toolBar->toggleViewAction(); - connect( action, SIGNAL(toggled(bool)), toolBar, SLOT(setVisible(bool)) ); - toolBarGroup->addAction( action ); - menu->addAction( action ); - } - } - - menu->addSeparator(); - - QAction *resetAction = new QAction( i18n( "Reset Layout" ), this ); - connect( resetAction, SIGNAL( triggered() ), this, SLOT( resetLayout() ) ); - menu->addAction( resetAction ); -} - -void -MainWindow::showBrowser( const QString &name ) -{ - Q_UNUSED( name ); - // showBrowser( index ); // FIXME -} - -void -MainWindow::showDock( AmarokDockId dockId ) -{ - QString name; - switch( dockId ) - { - case AmarokDockNavigation: - name = m_browserDock.data()->windowTitle(); - break; - case AmarokDockContext: - name = m_contextDock.data()->windowTitle(); - break; - case AmarokDockPlaylist: - name = m_playlistDock.data()->windowTitle(); - break; - } - - QList < QTabBar * > tabList = findChildren < QTabBar * > (); - - foreach( QTabBar *bar, tabList ) - { - for( int i = 0; i < bar->count(); i++ ) - { - if( bar->tabText( i ) == name ) - { - bar->setCurrentIndex( i ); - break; - } - } - } -} - -void -MainWindow::closeEvent( QCloseEvent *e ) -{ -#ifdef Q_WS_MAC - Q_UNUSED( e ); - hide(); -#else - - //KDE policy states we should hide to tray and not quit() when the - //close window button is pushed for the main widget - if( AmarokConfig::showTrayIcon() && e->spontaneous() && !kapp->sessionSaving() ) - { - KMessageBox::information( this, - i18n( "Closing the main window will keep Amarok running in the System Tray. " - "Use Quit from the menu, or the Amarok tray icon to exit the application." ), - i18n( "Docking in System Tray" ), "hideOnCloseInfo" ); - - hide(); - e->ignore(); - return; - } - - e->accept(); - App::instance()->quit(); -#endif -} - -void -MainWindow::exportPlaylist() //SLOT -{ - DEBUG_BLOCK - - QScopedPointer fileDialog( new KFileDialog( KUrl("kfiledialog:///amarok-playlist-export"), QString(), this ) ); - QCheckBox *saveRelativeCheck = new QCheckBox( i18n("Use relative path for &saving") ); - saveRelativeCheck->setChecked( AmarokConfig::relativePlaylist() ); - - QStringList supportedMimeTypes; - - supportedMimeTypes << "video/x-ms-asf"; //ASX - supportedMimeTypes << "audio/x-mpegurl"; //M3U - supportedMimeTypes << "audio/x-scpls"; //PLS - supportedMimeTypes << "application/xspf+xml"; //XSPF - - fileDialog->setMimeFilter( supportedMimeTypes, supportedMimeTypes.first() ); - fileDialog->fileWidget()->setCustomWidget( saveRelativeCheck ); - fileDialog->setOperationMode( KFileDialog::Saving ); - fileDialog->setMode( KFile::File ); - fileDialog->setCaption( i18n("Save As") ); - fileDialog->setObjectName( "PlaylistExport" ); - - fileDialog->exec(); - - QString playlistPath = fileDialog->selectedFile(); - - if( !playlistPath.isEmpty() ) - The::playlist()->exportPlaylist( playlistPath, saveRelativeCheck->isChecked() ); -} - -void -MainWindow::slotShowActiveTrack() const -{ - m_playlistDock.data()->showActiveTrack(); -} - -void -MainWindow::slotEditTrackInfo() const -{ - m_playlistDock.data()->editTrackInfo(); -} - -void -MainWindow::slotShowCoverManager() //SLOT -{ - CoverManager::showOnce( QString(), this ); -} - -void -MainWindow::slotShowDiagnosticsDialog() -{ - DiagnosticDialog *dialog = new DiagnosticDialog( KGlobal::mainComponent().aboutData(), this ); - dialog->show(); -} - -void MainWindow::slotShowBookmarkManager() -{ - BookmarkManager::showOnce( this ); -} - -void MainWindow::slotShowEqualizer() -{ - EqualizerDialog::showOnce( this ); -} - -void -MainWindow::slotPlayMedia() //SLOT -{ - // Request location and immediately start playback - slotAddLocation( true ); -} - -void -MainWindow::slotAddLocation( bool directPlay ) //SLOT -{ - static KUrl lastDirectory; - - // open a file selector to add media to the playlist - KUrl::List files; - KFileDialog dlg( KUrl(QDesktopServices::storageLocation(QDesktopServices::MusicLocation) ), QString("*.*|"), this ); - - if( !lastDirectory.isEmpty() ) - dlg.setUrl( lastDirectory ); - - dlg.setCaption( directPlay ? i18n("Play Media (Files or URLs)") : i18n("Add Media (Files or URLs)") ); - dlg.setMode( KFile::Files | KFile::Directory ); - dlg.setObjectName( "PlayMedia" ); - dlg.exec(); - files = dlg.selectedUrls(); - - lastDirectory = dlg.baseUrl(); - - if( files.isEmpty() ) - return; - - Playlist::AddOptions options = directPlay ? Playlist::OnPlayMediaAction - : Playlist::OnAppendToPlaylistAction; - The::playlistController()->insertOptioned( files, options ); -} - -void -MainWindow::slotAddStream() //SLOT -{ - bool ok; - QString url = KInputDialog::getText( i18n( "Add Stream" ), i18n( "Enter Stream URL:" ), - QString(), &ok, this ); - if( !ok ) - return; - - The::playlistController()->insertOptioned( KUrl( url ), - Playlist::OnAppendToPlaylistAction | Playlist::RemotePlaylistsAreStreams ); -} - -void -MainWindow::slotFocusPlaylistSearch() -{ - showDock( AmarokDockPlaylist ); // ensure that the dock is visible if tabbed - m_playlistDock.data()->searchWidget()->focusInputLine(); -} - -void -MainWindow::slotFocusCollectionSearch() -{ - // ensure collection browser is activated within navigation dock: - browserDock()->list()->navigate( QString("collections") ); - showDock( AmarokDockNavigation ); // ensure that the dock is visible if tabbed - m_collectionBrowser->focusInputLine(); -} - -#ifdef DEBUG_BUILD_TYPE -void -MainWindow::showNetworkRequestViewer() //SLOT -{ - if( !m_networkViewer ) - { - m_networkViewer = new NetworkAccessViewer( this ); - The::networkAccessManager()->setNetworkAccessViewer( m_networkViewer.data() ); - - } - The::networkAccessManager()->networkAccessViewer()->show(); -} -#endif // DEBUG_BUILD_TYPE - -/** - * "Toggle Main Window" global shortcut connects to this slot - */ -void -MainWindow::showHide() //SLOT -{ - const KWindowInfo info = KWindowSystem::windowInfo( winId(), 0, 0 ); - const int currentDesktop = KWindowSystem::currentDesktop(); - - if( !isVisible() ) - { - setVisible( true ); - } - else - { - if( !isMinimized() ) - { - if( !isActiveWindow() ) // not minimised and without focus - { - KWindowSystem::setOnDesktop( winId(), currentDesktop ); - KWindowSystem::activateWindow( winId() ); - } - else // Amarok has focus - { - setVisible( false ); - } - } - else // Amarok is minimised - { - setWindowState( windowState() & ~Qt::WindowMinimized ); - KWindowSystem::setOnDesktop( winId(), currentDesktop ); - KWindowSystem::activateWindow( winId() ); - } - } -} - -void -MainWindow::showNotificationPopup() // slot -{ - if( Amarok::KNotificationBackend::instance()->isEnabled() - && !Amarok::OSD::instance()->isEnabled() ) - Amarok::KNotificationBackend::instance()->showCurrentTrack(); - else - Amarok::OSD::instance()->forceToggleOSD(); -} - -void -MainWindow::slotFullScreen() // slot -{ - setWindowState( windowState() ^ Qt::WindowFullScreen ); -} - -void -MainWindow::slotLoveTrack() -{ - emit loveTrack( The::engineController()->currentTrack() ); -} - -void -MainWindow::slotBanTrack() -{ - emit banTrack( The::engineController()->currentTrack() ); -} - -void -MainWindow::slotShufflePlaylist() -{ - m_playlistDock.data()->sortWidget()->trimToLevel(); - The::playlistActions()->shuffle(); -} - -void -MainWindow::slotSeekForwardShort() -{ - EngineController* ec = The::engineController(); - ec->seekBy( AmarokConfig::seekShort() * 1000 ); -} - -void -MainWindow::slotSeekForwardMedium() -{ - EngineController* ec = The::engineController(); - ec->seekBy( AmarokConfig::seekMedium() * 1000 ); -} - -void -MainWindow::slotSeekForwardLong() -{ - EngineController* ec = The::engineController(); - ec->seekBy( AmarokConfig::seekLong() * 1000 ); -} - -void -MainWindow::slotSeekBackwardShort() -{ - EngineController* ec = The::engineController(); - ec->seekBy( AmarokConfig::seekShort() * -1000 ); -} - -void -MainWindow::slotSeekBackwardMedium() -{ - EngineController* ec = The::engineController(); - ec->seekBy( AmarokConfig::seekMedium() * -1000 ); -} - -void -MainWindow::slotSeekBackwardLong() -{ - EngineController* ec = The::engineController(); - ec->seekBy( AmarokConfig::seekLong() * -1000 ); -} - -void MainWindow::slotPutCurrentTrackToClipboard() -{ - Meta::TrackPtr currentTrack = The::engineController()->currentTrack(); - if ( currentTrack ) - { - QString text; - Meta::ArtistPtr artist = currentTrack->artist(); - if( artist ) - text = artist->prettyName() + " - "; - text += currentTrack->prettyName(); - - QClipboard *clipboard = QApplication::clipboard(); - clipboard->setText( text ); - } -} - -void -MainWindow::activate() -{ -#ifdef Q_WS_X11 - const KWindowInfo info = KWindowSystem::windowInfo( winId(), 0, 0 ); - - if( KWindowSystem::activeWindow() != winId() ) - setVisible( true ); - else if( !info.isMinimized() ) - setVisible( true ); - if( !isHidden() ) - KWindowSystem::activateWindow( winId() ); -#else - setVisible( true ); -#endif -} - -void -MainWindow::createActions() -{ - KActionCollection* const ac = Amarok::actionCollection(); - const EngineController* const ec = The::engineController(); - const Playlist::Actions* const pa = The::playlistActions(); - const Playlist::Controller* const pc = The::playlistController(); - - KStandardAction::keyBindings( kapp, SLOT(slotConfigShortcuts()), ac ); - m_showMenuBar = KStandardAction::showMenubar(this, SLOT(slotShowMenuBar()), ac); - KStandardAction::preferences( kapp, SLOT(slotConfigAmarok()), ac ); - ac->action( KStandardAction::name( KStandardAction::KeyBindings ) )->setIcon( KIcon( "configure-shortcuts-amarok" ) ); - ac->action( KStandardAction::name( KStandardAction::Preferences ) )->setIcon( KIcon( "configure-amarok" ) ); - ac->action( KStandardAction::name( KStandardAction::Preferences ) )->setMenuRole(QAction::PreferencesRole); // Define OS X Prefs menu here, removes need for ifdef later - - KStandardAction::quit( App::instance(), SLOT(quit()), ac ); - - KAction *action = new KAction( KIcon( "document-open" ), i18n("&Add Media..."), this ); - ac->addAction( "playlist_add", action ); - connect( action, SIGNAL(triggered(bool)), this, SLOT(slotAddLocation()) ); - action->setGlobalShortcut( KShortcut( Qt::META + Qt::Key_A ) ); - - action = new KAction( KIcon( "edit-clear-list" ), i18nc( "clear playlist", "&Clear Playlist" ), this ); - connect( action, SIGNAL(triggered(bool)), pc, SLOT(clear()) ); - ac->addAction( "playlist_clear", action ); - - action = new KAction( KIcon( "format-list-ordered" ), - i18nc( "edit play queue of playlist", "Edit &Queue" ), this ); - //Qt::META+Qt::Key_Q is taken by Plasma as a global - action->setShortcut( KShortcut( Qt::META + Qt::Key_U ) ); - ac->addAction( "playlist_edit_queue", action );; - - action = new KAction( i18nc( "Remove duplicate and dead (unplayable) tracks from the playlist", "Re&move Duplicates" ), this ); - connect( action, SIGNAL(triggered(bool)), pc, SLOT(removeDeadAndDuplicates()) ); - ac->addAction( "playlist_remove_dead_and_duplicates", action ); - - action = new Playlist::LayoutConfigAction( this ); - ac->addAction( "playlist_layout", action ); - - action = new KAction( KIcon( "document-open-remote" ), i18n("&Add Stream..."), this ); - connect( action, SIGNAL(triggered(bool)), this, SLOT(slotAddStream()) ); - ac->addAction( "stream_add", action ); - - action = new KAction( KIcon( "document-export-amarok" ), i18n("&Export Playlist As..."), this ); - connect( action, SIGNAL(triggered(bool)), this, SLOT(exportPlaylist()) ); - ac->addAction( "playlist_export", action ); - - action = new KAction( KIcon( "bookmark-new" ), i18n( "Bookmark Media Sources View" ), this ); - ac->addAction( "bookmark_browser", action ); - connect( action, SIGNAL(triggered()), The::amarokUrlHandler(), SLOT(bookmarkCurrentBrowserView()) ); - - action = new KAction( KIcon( "bookmarks-organize" ), i18n( "Bookmark Manager" ), this ); - ac->addAction( "bookmark_manager", action ); - connect( action, SIGNAL(triggered(bool)), SLOT(slotShowBookmarkManager()) ); - - action = new KAction( KIcon( "view-media-equalizer" ), i18n( "Equalizer" ), this ); - ac->addAction( "equalizer_dialog", action ); - connect( action, SIGNAL(triggered(bool)), SLOT(slotShowEqualizer()) ); - - action = new KAction( KIcon( "bookmark-new" ), i18n( "Bookmark Playlist Setup" ), this ); - ac->addAction( "bookmark_playlistview", action ); - connect( action, SIGNAL(triggered()), The::amarokUrlHandler(), SLOT(bookmarkCurrentPlaylistView()) ); - - action = new KAction( KIcon( "bookmark-new" ), i18n( "Bookmark Context Applets" ), this ); - ac->addAction( "bookmark_contextview", action ); - connect( action, SIGNAL(triggered()), The::amarokUrlHandler(), SLOT(bookmarkCurrentContextView()) ); - - action = new KAction( KIcon( "media-album-cover-manager-amarok" ), i18n( "Cover Manager" ), this ); - connect( action, SIGNAL(triggered(bool)), SLOT(slotShowCoverManager()) ); - ac->addAction( "cover_manager", action ); - - action = new KAction( KIcon("document-open"), i18n("Play Media..."), this ); - ac->addAction( "playlist_playmedia", action ); - action->setShortcut( Qt::CTRL + Qt::Key_O ); - connect( action, SIGNAL(triggered(bool)), SLOT(slotPlayMedia()) ); - - action = new KAction( KIcon("media-track-edit-amarok"), i18n("Edit Details of Currently Selected Track"), this ); - ac->addAction( "trackdetails_edit", action ); - action->setShortcut( Qt::CTRL + Qt::Key_E ); - connect( action, SIGNAL(triggered(bool)), SLOT(slotEditTrackInfo()) ); - - action = new KAction( KIcon( "media-seek-forward-amarok" ), i18n( "Seek Forward by %1", - KGlobal::locale()->prettyFormatDuration( AmarokConfig::seekShort() * 1000 ) ), this ); - ac->addAction( "seek_forward_short", action ); - action->setShortcut( Qt::CTRL + Qt::Key_Right ); - connect( action, SIGNAL(triggered(bool)), SLOT(slotSeekForwardShort()) ); - - action = new KAction( KIcon( "media-seek-forward-amarok" ), i18n( "Seek Forward by %1", - KGlobal::locale()->prettyFormatDuration( AmarokConfig::seekMedium() * 1000 ) ), this ); - ac->addAction( "seek_forward_medium", action ); - action->setShortcut( Qt::Key_Right ); - action->setGlobalShortcut( KShortcut( Qt::META + Qt::SHIFT + Qt::Key_Plus ) ); - connect( action, SIGNAL(triggered(bool)), SLOT(slotSeekForwardMedium()) ); - - action = new KAction( KIcon( "media-seek-forward-amarok" ), i18n( "Seek Forward by %1", - KGlobal::locale()->prettyFormatDuration( AmarokConfig::seekLong() * 1000 ) ), this ); - ac->addAction( "seek_forward_long", action ); - action->setShortcut( Qt::SHIFT + Qt::Key_Right ); - connect( action, SIGNAL(triggered(bool)), SLOT(slotSeekForwardLong()) ); - - - action = new KAction( KIcon( "media-seek-backward-amarok" ), i18n( "Seek Backward by %1", - KGlobal::locale()->prettyFormatDuration( AmarokConfig::seekShort() * 1000 ) ), this ); - ac->addAction( "seek_backward_short", action ); - action->setShortcut( Qt::CTRL + Qt::Key_Left ); - connect( action, SIGNAL(triggered(bool)), SLOT(slotSeekBackwardShort()) ); - - action = new KAction( KIcon( "media-seek-backward-amarok" ), i18n( "Seek Backward by %1", - KGlobal::locale()->prettyFormatDuration( AmarokConfig::seekMedium() * 1000 ) ), this ); - ac->addAction( "seek_backward_medium", action ); - action->setShortcut( Qt::Key_Left ); - action->setGlobalShortcut( KShortcut( Qt::META + Qt::SHIFT + Qt::Key_Minus ) ); - connect( action, SIGNAL(triggered(bool)), SLOT(slotSeekBackwardMedium()) ); - - action = new KAction( KIcon( "media-seek-backward-amarok" ), i18n( "Seek Backward by %1", - KGlobal::locale()->prettyFormatDuration( AmarokConfig::seekLong() * 1000 ) ), this ); - ac->addAction( "seek_backward_long", action ); - action->setShortcut( Qt::SHIFT + Qt::Key_Left ); - connect( action, SIGNAL(triggered(bool)), SLOT(slotSeekBackwardLong()) ); - - PERF_LOG( "MainWindow::createActions 6" ) - action = new KAction( KIcon("view-refresh"), i18n( "Update Collection" ), this ); - connect ( action, SIGNAL(triggered(bool)), CollectionManager::instance(), SLOT(checkCollectionChanges()) ); - ac->addAction( "update_collection", action ); - - action = new KAction( KIcon( "amarok_playcount" ), i18n( "Synchronize Statistics..." ), this ); - ac->addAction( "synchronize_statistics", action ); - connect( action, SIGNAL(triggered(bool)), Amarok::Components::statSyncingController(), SLOT(synchronize()) ); - - action = new KAction( this ); - ac->addAction( "prev", action ); - action->setIcon( KIcon("media-skip-backward-amarok") ); - action->setText( i18n( "Previous Track" ) ); - action->setGlobalShortcut( KShortcut( Qt::Key_MediaPrevious ) ); - connect( action, SIGNAL(triggered(bool)), pa, SLOT(back()) ); - - action = new KAction( this ); - ac->addAction( "replay", action ); - action->setIcon( KIcon("media-playback-start") ); - action->setText( i18n( "Restart current track" ) ); - action->setGlobalShortcut( KShortcut() ); - connect( action, SIGNAL(triggered(bool)), ec, SLOT(replay()) ); - - action = new KAction( this ); - ac->addAction( "shuffle_playlist", action ); - action->setIcon( KIcon("media-playlist-shuffle") ); - action->setText( i18n( "Shuffle Playlist" ) ); - action->setShortcut( Qt::CTRL + Qt::Key_H ); - connect( action, SIGNAL(triggered(bool)), this, SLOT(slotShufflePlaylist()) ); - - action = new KAction( this ); - ac->addAction( "repopulate", action ); - action->setText( i18n( "Repopulate Playlist" ) ); - action->setIcon( KIcon("view-refresh-amarok") ); - connect( action, SIGNAL(triggered(bool)), pa, SLOT(repopulateDynamicPlaylist()) ); - - action = new KAction( this ); - ac->addAction( "disable_dynamic", action ); - action->setText( i18n( "Disable Dynamic Playlist" ) ); - action->setIcon( KIcon("edit-delete-amarok") ); - //this is connected inside the dynamic playlist category - - action = new KAction( KIcon("media-skip-forward-amarok"), i18n( "Next Track" ), this ); - ac->addAction( "next", action ); - action->setGlobalShortcut( KShortcut( Qt::Key_MediaNext ) ); - connect( action, SIGNAL(triggered(bool)), pa, SLOT(next()) ); - - action = new KAction( i18n( "Increase Volume" ), this ); - ac->addAction( "increaseVolume", action ); - action->setGlobalShortcut( KShortcut( Qt::META + Qt::Key_Plus ) ); - action->setShortcut( Qt::Key_Plus ); - connect( action, SIGNAL(triggered()), ec, SLOT(increaseVolume()) ); - - action = new KAction( i18n( "Decrease Volume" ), this ); - ac->addAction( "decreaseVolume", action ); - action->setGlobalShortcut( KShortcut( Qt::META + Qt::Key_Minus ) ); - action->setShortcut( Qt::Key_Minus ); - connect( action, SIGNAL(triggered()), ec, SLOT(decreaseVolume()) ); - - action = new KAction( i18n( "Toggle Main Window" ), this ); - ac->addAction( "toggleMainWindow", action ); - action->setGlobalShortcut( KShortcut() ); - connect( action, SIGNAL(triggered()), SLOT(showHide()) ); - - action = new KAction( i18n( "Toggle Full Screen" ), this ); - ac->addAction( "toggleFullScreen", action ); - action->setShortcut( KShortcut( Qt::CTRL + Qt::SHIFT + Qt::Key_F ) ); - connect( action, SIGNAL(triggered()), SLOT(slotFullScreen()) ); - - action = new KAction( i18n( "Search playlist" ), this ); - ac->addAction( "searchPlaylist", action ); - action->setShortcut( KShortcut( Qt::CTRL + Qt::Key_J ) ); - connect( action, SIGNAL(triggered()), SLOT(slotFocusPlaylistSearch()) ); - - action = new KAction( i18n( "Search collection" ), this ); - ac->addAction( "searchCollection", action ); - action->setShortcut( KShortcut( Qt::CTRL + Qt::Key_F ) ); - connect( action, SIGNAL(triggered()), SLOT(slotFocusCollectionSearch()) ); - - action = new KAction( KIcon( "music-amarok" ), i18n("Show active track"), this ); - ac->addAction( "show_active_track", action ); - connect( action, SIGNAL(triggered(bool)), SLOT(slotShowActiveTrack()) ); - - action = new KAction( i18n( "Show Notification Popup" ), this ); - ac->addAction( "showNotificationPopup", action ); - action->setGlobalShortcut( KShortcut( Qt::META + Qt::Key_O ) ); - connect( action, SIGNAL(triggered()), SLOT(showNotificationPopup()) ); - - action = new KAction( i18n( "Mute Volume" ), this ); - ac->addAction( "mute", action ); - action->setGlobalShortcut( KShortcut( Qt::META + Qt::Key_M ) ); - connect( action, SIGNAL(triggered()), ec, SLOT(toggleMute()) ); - - action = new KAction( i18n( "Last.fm: Love Current Track" ), this ); - ac->addAction( "loveTrack", action ); - action->setGlobalShortcut( KShortcut( Qt::META + Qt::Key_L ) ); - connect( action, SIGNAL(triggered()), SLOT(slotLoveTrack()) ); - - action = new KAction( i18n( "Last.fm: Ban Current Track" ), this ); - ac->addAction( "banTrack", action ); - //action->setGlobalShortcut( KShortcut( Qt::META + Qt::Key_B ) ); - connect( action, SIGNAL(triggered()), SLOT(slotBanTrack()) ); - - action = new KAction( i18n( "Last.fm: Skip Current Track" ), this ); - ac->addAction( "skipTrack", action ); - action->setGlobalShortcut( KShortcut( Qt::META + Qt::Key_S ) ); - connect( action, SIGNAL(triggered()), SIGNAL(skipTrack()) ); - - action = new KAction( KIcon( "media-track-queue-amarok" ), i18n( "Queue Track" ), this ); - ac->addAction( "queueTrack", action ); - action->setShortcut( KShortcut( Qt::CTRL + Qt::Key_D ) ); - connect( action, SIGNAL(triggered()), SIGNAL(switchQueueStateShortcut()) ); - - action = new KAction( i18n( "Put Artist - Title of the current track to the clipboard" ), this ); - ac->addAction("artistTitleClipboard", action); - action->setShortcut( KShortcut( Qt::CTRL + Qt::Key_C ) ); - connect( action, SIGNAL(triggered()), SLOT(slotPutCurrentTrackToClipboard()) ); - - action = new KAction( i18n( "Rate Current Track: 1" ), this ); - ac->addAction( "rate1", action ); - action->setGlobalShortcut( KShortcut( Qt::META + Qt::Key_1 ) ); - connect( action, SIGNAL(triggered()), SLOT(setRating1()) ); - - action = new KAction( i18n( "Rate Current Track: 2" ), this ); - ac->addAction( "rate2", action ); - action->setGlobalShortcut( KShortcut( Qt::META + Qt::Key_2 ) ); - connect( action, SIGNAL(triggered()), SLOT(setRating2()) ); - - action = new KAction( i18n( "Rate Current Track: 3" ), this ); - ac->addAction( "rate3", action ); - action->setGlobalShortcut( KShortcut( Qt::META + Qt::Key_3 ) ); - connect( action, SIGNAL(triggered()), SLOT(setRating3()) ); - - action = new KAction( i18n( "Rate Current Track: 4" ), this ); - ac->addAction( "rate4", action ); - action->setGlobalShortcut( KShortcut( Qt::META + Qt::Key_4 ) ); - connect( action, SIGNAL(triggered()), SLOT(setRating4()) ); - - action = new KAction( i18n( "Rate Current Track: 5" ), this ); - ac->addAction( "rate5", action ); - action->setGlobalShortcut( KShortcut( Qt::META + Qt::Key_5 ) ); - connect( action, SIGNAL(triggered()), SLOT(setRating5()) ); - -#ifdef DEBUG_BUILD_TYPE - action = new KAction( i18n( "Network Request Viewer" ), this ); - ac->addAction( "network_request_viewer", action ); - action->setIcon( KIcon( "utilities-system-monitor" ) ); - connect( action, SIGNAL(triggered()), SLOT(showNetworkRequestViewer()) ); -#endif // DEBUG_BUILD_TYPE - - action = KStandardAction::redo( pc, SLOT(redo()), this); - ac->addAction( "playlist_redo", action ); - action->setEnabled( false ); - action->setIcon( KIcon( "edit-redo" ) ); - connect( pc, SIGNAL(canRedoChanged(bool)), action, SLOT(setEnabled(bool)) ); - - action = KStandardAction::undo( pc, SLOT(undo()), this); - ac->addAction( "playlist_undo", action ); - action->setEnabled( false ); - action->setIcon( KIcon( "edit-undo" ) ); - connect( pc, SIGNAL(canUndoChanged(bool)), action, SLOT(setEnabled(bool)) ); - - action = new KAction( KIcon( "amarok" ), i18n( "&About Amarok" ), this ); - ac->addAction( "extendedAbout", action ); - connect( action, SIGNAL(triggered()), SLOT(showAbout()) ); - - action = new KAction ( KIcon( "info-amarok" ), i18n( "&Diagnostics" ), this ); - ac->addAction( "diagnosticDialog", action ); - connect( action, SIGNAL(triggered()), SLOT(slotShowDiagnosticsDialog()) ); - - action = new KAction( KIcon( "tools-report-bug" ), i18n("&Report Bug..."), this ); - ac->addAction( "reportBug", action ); - connect( action, SIGNAL(triggered()), SLOT(showReportBug()) ); - - PERF_LOG( "MainWindow::createActions 8" ) - new Amarok::MenuAction( ac, this ); - new Amarok::StopAction( ac, this ); - new Amarok::StopPlayingAfterCurrentTrackAction( ac, this ); - new Amarok::PlayPauseAction( ac, this ); - new Amarok::ReplayGainModeAction( ac, this ); - - ac->addAssociatedWidget( this ); - foreach( QAction* action, ac->actions() ) - action->setShortcutContext( Qt::WindowShortcut ); -} - -void -MainWindow::setRating( int n ) -{ - n *= 2; - - Meta::TrackPtr track = The::engineController()->currentTrack(); - if( track ) - { - Meta::StatisticsPtr statistics = track->statistics(); - // if we're setting an identical rating then we really must - // want to set the half-star below rating - if( statistics->rating() == n ) - n -= 1; - - statistics->setRating( n ); - Amarok::OSD::instance()->OSDWidget::ratingChanged( statistics->rating() ); - } -} - -void -MainWindow::createMenus() -{ - m_menubar = menuBar(); - - //BEGIN Actions menu - KMenu *actionsMenu = new KMenu( m_menubar.data() ); -#ifdef Q_WS_MAC - // Add these functions to the dock icon menu in OS X - //extern void qt_mac_set_dock_menu(QMenu *); - //qt_mac_set_dock_menu(actionsMenu); - // Change to avoid duplicate menu titles in OS X - actionsMenu->setTitle( i18n("&Music") ); -#else - actionsMenu->setTitle( i18n("&Amarok") ); -#endif - actionsMenu->addAction( Amarok::actionCollection()->action("playlist_playmedia") ); - actionsMenu->addSeparator(); - actionsMenu->addAction( Amarok::actionCollection()->action("prev") ); - actionsMenu->addAction( Amarok::actionCollection()->action("play_pause") ); - actionsMenu->addAction( Amarok::actionCollection()->action("stop") ); - actionsMenu->addAction( Amarok::actionCollection()->action("stop_after_current") ); - actionsMenu->addAction( Amarok::actionCollection()->action("next") ); - - -#ifndef Q_WS_MAC // Avoid duplicate "Quit" in OS X dock menu - actionsMenu->addSeparator(); - actionsMenu->addAction( Amarok::actionCollection()->action( KStandardAction::name( KStandardAction::Quit ) ) ); -#endif - //END Actions menu - - //BEGIN View menu - QMenu* viewMenu = new QMenu(this); - addViewMenuItems(viewMenu); - //END View menu - - //BEGIN Playlist menu - KMenu *playlistMenu = new KMenu( m_menubar.data() ); - playlistMenu->setTitle( i18n("&Playlist") ); - playlistMenu->addAction( Amarok::actionCollection()->action("playlist_add") ); - playlistMenu->addAction( Amarok::actionCollection()->action("stream_add") ); - //playlistMenu->addAction( Amarok::actionCollection()->action("playlist_save") ); //FIXME: See FIXME in PlaylistDock.cpp - playlistMenu->addAction( Amarok::actionCollection()->action( "playlist_export" ) ); - playlistMenu->addSeparator(); - playlistMenu->addAction( Amarok::actionCollection()->action("playlist_undo") ); - playlistMenu->addAction( Amarok::actionCollection()->action("playlist_redo") ); - playlistMenu->addSeparator(); - playlistMenu->addAction( Amarok::actionCollection()->action("playlist_clear") ); - playlistMenu->addAction( Amarok::actionCollection()->action("playlist_remove_dead_and_duplicates") ); - playlistMenu->addAction( Amarok::actionCollection()->action("playlist_layout") ); - playlistMenu->addAction( Amarok::actionCollection()->action("playlist_edit_queue") ); - //END Playlist menu - - //BEGIN Tools menu - m_toolsMenu = new KMenu( m_menubar.data() ); - m_toolsMenu.data()->setTitle( i18n("&Tools") ); - - m_toolsMenu.data()->addAction( Amarok::actionCollection()->action("bookmark_manager") ); - m_toolsMenu.data()->addAction( Amarok::actionCollection()->action("cover_manager") ); - m_toolsMenu.data()->addAction( Amarok::actionCollection()->action("equalizer_dialog") ); -#ifdef DEBUG_BUILD_TYPE - m_toolsMenu.data()->addAction( Amarok::actionCollection()->action("network_request_viewer") ); -#endif // DEBUG_BUILD_TYPE - m_toolsMenu.data()->addSeparator(); - m_toolsMenu.data()->addAction( Amarok::actionCollection()->action("update_collection") ); - m_toolsMenu.data()->addAction( Amarok::actionCollection()->action("synchronize_statistics") ); - //END Tools menu - - //BEGIN Settings menu - m_settingsMenu = new KMenu( m_menubar.data() ); - m_settingsMenu.data()->setTitle( i18n("&Settings") ); - - m_settingsMenu.data()->addAction( Amarok::actionCollection()->action( KStandardAction::name( KStandardAction::ShowMenubar ) ) ); - - m_settingsMenu.data()->addAction( Amarok::actionCollection()->action( KStandardAction::name( KStandardAction::KeyBindings ) ) ); - m_settingsMenu.data()->addAction( Amarok::actionCollection()->action( KStandardAction::name( KStandardAction::Preferences ) ) ); - //END Settings menu - - m_menubar.data()->addMenu( actionsMenu ); - m_menubar.data()->addMenu( viewMenu ); - m_menubar.data()->addMenu( playlistMenu ); - m_menubar.data()->addMenu( m_toolsMenu.data() ); - m_menubar.data()->addMenu( m_settingsMenu.data() ); - - KMenu *helpMenu = Amarok::Menu::helpMenu(); - helpMenu->insertAction( helpMenu->actions().last(), - Amarok::actionCollection()->action( "extendedAbout" ) ); - helpMenu->insertAction( helpMenu->actions().last(), - Amarok::actionCollection()->action( "diagnosticDialog" ) ); - - m_menubar.data()->addSeparator(); - m_menubar.data()->addMenu( helpMenu ); -} - -void -MainWindow::slotShowMenuBar() -{ - if (!m_showMenuBar->isChecked()) - { - //User have chosen to hide a menu. Lets warn him - if (KMessageBox::warningContinueCancel(this, - i18n("You have chosen to hide the menu bar.\n\nPlease remember that you can always use the shortcut \"%1\" to bring it back.", m_showMenuBar->shortcut().toString() ), - i18n("Hide Menu"), KStandardGuiItem::cont(), KStandardGuiItem::cancel(), "showMenubar") != KMessageBox::Continue) - { - //Cancel menu hiding. Revert menu item to checked state. - m_showMenuBar->setChecked(true); - return; - } - } - menuBar()->setVisible(m_showMenuBar->isChecked()); -} - -void -MainWindow::showAbout() -{ - ExtendedAboutDialog dialog( KGlobal::mainComponent().aboutData(), &ocsData ); - dialog.exec(); -} - -void -MainWindow::showReportBug() -{ - KBugReport * rbDialog = new KBugReport( this, true, KGlobal::mainComponent().aboutData() ); - rbDialog->setObjectName( "KBugReport" ); - rbDialog->exec(); -} - -void -MainWindow::changeEvent( QEvent *event ) -{ - if( event->type() == QEvent::PaletteChange ) - The::paletteHandler()->setPalette( palette() ); -} - -void -MainWindow::slotStopped() -{ - setWindowTitle( i18n( AMAROK_CAPTION ) ); -} - -void -MainWindow::slotPaused() -{ - setWindowTitle( i18n( "Paused :: %1", i18n( AMAROK_CAPTION ) ) ); -} - -void -MainWindow::slotNewTrackPlaying() -{ - slotMetadataChanged( The::engineController()->currentTrack() ); -} - -void -MainWindow::slotMetadataChanged( Meta::TrackPtr track ) -{ - if( track ) - setWindowTitle( i18n( "%1 - %2 :: %3", track->artist() ? track->artist()->prettyName() : i18n( "Unknown" ), track->prettyName(), i18n( AMAROK_CAPTION ) ) ); -} - -CollectionWidget * -MainWindow::collectionBrowser() -{ - return m_collectionBrowser; -} - -QString -MainWindow::activeBrowserName() -{ - if( m_browserDock.data()->list()->activeCategory() ) - return m_browserDock.data()->list()->activeCategory()->name(); - else - return QString(); -} - -void -MainWindow::setLayoutLocked( bool locked ) -{ - DEBUG_BLOCK - - if( locked ) - { - m_browserDock.data()->setMovable( false ); - m_contextDock.data()->setMovable( false ); - m_playlistDock.data()->setMovable( false ); - - m_slimToolbar.data()->setFloatable( false ); - m_slimToolbar.data()->setMovable( false ); - - m_mainToolbar.data()->setFloatable( false ); - m_mainToolbar.data()->setMovable( false ); - } - else - { - m_browserDock.data()->setMovable( true ); - m_contextDock.data()->setMovable( true ); - m_playlistDock.data()->setMovable( true ); - - m_slimToolbar.data()->setFloatable( true ); - m_slimToolbar.data()->setMovable( true ); - - m_mainToolbar.data()->setFloatable( true ); - m_mainToolbar.data()->setMovable( true ); - } - - AmarokConfig::setLockLayout( locked ); - AmarokConfig::self()->writeConfig(); -} - -void -MainWindow::resetLayout() -{ - // Store current state, so that we can undo the operation - const QByteArray state = saveState(); - - // Remove all dock widgets, then add them again. This resets their state completely. - removeDockWidget( m_browserDock.data() ); - removeDockWidget( m_contextDock.data() ); - removeDockWidget( m_playlistDock.data() ); - - addDockWidget( Qt::LeftDockWidgetArea, m_browserDock.data() ); - addDockWidget( Qt::LeftDockWidgetArea, m_contextDock.data(), Qt::Horizontal ); - addDockWidget( Qt::LeftDockWidgetArea, m_playlistDock.data(), Qt::Horizontal ); - - m_browserDock.data()->setFloating( false ); - m_contextDock.data()->setFloating( false ); - m_playlistDock.data()->setFloating( false ); - - m_browserDock.data()->show(); - m_contextDock.data()->show(); - m_playlistDock.data()->show(); - - // Now set Amarok's default dockwidget sizes - setDefaultDockSizes(); - - if( KMessageBox::warningContinueCancel( this, i18n( "Apply this layout change?" ), i18n( "Reset Layout" ) ) == KMessageBox::Cancel ) - restoreState( state ); -} - -void -MainWindow::setDefaultDockSizes() // SLOT -{ - int totalWidgetWidth = contentsRect().width(); - - //get the width of the splitter handles, we need to subtract these... - const int splitterHandleWidth = style()->pixelMetric( QStyle::PM_DockWidgetSeparatorExtent, 0, 0 ); - - totalWidgetWidth -= ( splitterHandleWidth * 2 ); - - const int widgetWidth = totalWidgetWidth / 3; - const int leftover = totalWidgetWidth - 3 * widgetWidth; - - //We need to set fixed widths initially, just until the main window has been properly laid out. As soon as this has - //happened, we will unlock these sizes again so that the elements can be resized by the user. - const int mins[3] = { m_browserDock.data()->minimumWidth(), m_contextDock.data()->minimumWidth(), m_playlistDock.data()->minimumWidth() }; - const int maxs[3] = { m_browserDock.data()->maximumWidth(), m_contextDock.data()->maximumWidth(), m_playlistDock.data()->maximumWidth() }; - - m_browserDock.data()->setFixedWidth( widgetWidth * 0.65 ); - m_contextDock.data()->setFixedWidth( widgetWidth * 1.7 + leftover ); - m_playlistDock.data()->setFixedWidth( widgetWidth * 0.65 ); - - // Important: We need to activate the layout we have just set - layout()->activate(); - - m_browserDock.data()->setMinimumWidth( mins[0] ); m_browserDock.data()->setMaximumWidth( maxs[0] ); - m_contextDock.data()->setMinimumWidth( mins[1] ); m_contextDock.data()->setMaximumWidth( maxs[1] ); - m_playlistDock.data()->setMinimumWidth( mins[2] ); m_playlistDock.data()->setMaximumWidth( maxs[2] ); -} - -bool -MainWindow::playAudioCd() -{ - DEBUG_BLOCK - //drop whatever we are doing and play auidocd - - QList collections = CollectionManager::instance()->viewableCollections(); - - // Search a non-empty MemoryCollection with the id: AudioCd - foreach( Collections::Collection *collection, collections ) - { - if( collection->collectionId() == "AudioCd" ) - { - - debug() << "got audiocd collection"; - - Collections::MemoryCollection * cdColl = dynamic_cast( collection ); - - if( !cdColl || cdColl->trackMap().count() == 0 ) - { - debug() << "cd collection not ready yet (track count = 0 )"; - m_waitingForCd = true; - return false; - } - - The::playlistController()->insertOptioned( cdColl->trackMap().values(), Playlist::OnPlayMediaAction ); - m_waitingForCd = false; - return true; - } - } - - debug() << "waiting for cd..."; - m_waitingForCd = true; - return false; -} - -bool -MainWindow::isWaitingForCd() const -{ - DEBUG_BLOCK - debug() << "waiting?: " << m_waitingForCd; - return m_waitingForCd; -} - -bool -MainWindow::isOnCurrentDesktop() const -{ -#ifdef Q_WS_X11 - return KWindowSystem::windowInfo( winId(), NET::WMDesktop ).desktop() == KWindowSystem::currentDesktop(); -#else - return true; -#endif -} - - -#include "moc_MainWindow.cpp" diff --git a/amarok/src/MainWindow.h b/amarok/src/MainWindow.h deleted file mode 100644 index 2ad3501e..00000000 --- a/amarok/src/MainWindow.h +++ /dev/null @@ -1,220 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2002-2013 Mark Kretschmann * - * Copyright (c) 2002 Max Howell * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef MAINWINDOW_H -#define MAINWINDOW_H - -#include - -#include "amarok_export.h" -#include "core/meta/forward_declarations.h" -#include "browsers/BrowserDock.h" - -#include -#include -#include - -#include - -class CollectionWidget; -class SlimToolbar; -class MainToolbar; -class MainWindow; -#ifdef DEBUG_BUILD_TYPE -class NetworkAccessViewer; -#endif // DEBUG_BUILD_TYPE -class PlaylistFileProvider; - -namespace PlaylistBrowserNS { class PlaylistBrowser; } -namespace Playlist { class Dock; } -class ContextDock; - - -class KMenu; -class KAction; -class QMenuBar; -class QSplitter; -class QTimer; - -namespace The { - AMAROK_EXPORT MainWindow* mainWindow(); -} - -//This should only change if docks or toolbars are added or removed -#define LAYOUT_VERSION 3 - -/** - * @class MainWindow - * @short The MainWindow widget class. - * - * This is the main window widget. - */ -class AMAROK_EXPORT MainWindow : public KMainWindow -{ - friend MainWindow* The::mainWindow(); - - Q_OBJECT - - public: - enum AmarokDockId { - AmarokDockNavigation, - AmarokDockContext, - AmarokDockPlaylist - }; - - MainWindow(); - ~MainWindow(); - - void activate(); - - //allows us to switch browsers from within other browsers etc - void showBrowser( const QString& name ); - - //ensures the dock widget is visible in case it is tabbed - void showDock( AmarokDockId dockId ); - - BrowserDock *browserDock() const { return m_browserDock.data(); } - KMenu *ToolsMenu() const { return m_toolsMenu.data(); } - KMenu *SettingsMenu() const { return m_settingsMenu.data(); } - Playlist::Dock *playlistDock() const { return m_playlistDock.data(); } - void deleteBrowsers(); - - /* Reimplemented from QMainWindow to allow only one active toolbar at any time */ - virtual QMenu* createPopupMenu(); - - void addViewMenuItems(QMenu* menu); - - QString activeBrowserName(); - - CollectionWidget * collectionBrowser(); - - bool isLayoutLocked() const; - - /** - * If an audiocd collection is present. Stop current playback, clear playlist, - * add cd to playlist and start playback - */ - bool playAudioCd(); - - bool isWaitingForCd() const; - - /** - * @return Whether the application is on the currently active virtual desktop. On non-X11 systems - this is always true. - */ - bool isOnCurrentDesktop() const; - - signals: - void loveTrack( Meta::TrackPtr track ); - void banTrack( Meta::TrackPtr track ); - void skipTrack(); - void switchQueueStateShortcut(); - - public slots: - void showHide(); - void slotFullScreen(); - void showNotificationPopup(); - void setLayoutLocked( bool locked ); - void resetLayout(); - void showAbout(); - void showReportBug(); - - private slots: - void setDefaultDockSizes(); - - void slotLoveTrack(); - void slotBanTrack(); - - void slotStopped(); - void slotPaused(); - void slotNewTrackPlaying(); - void slotMetadataChanged( Meta::TrackPtr track ); - - void exportPlaylist(); - void slotShowActiveTrack() const; - void slotEditTrackInfo() const; - void slotShowBookmarkManager(); - void slotShowEqualizer(); - void slotShowCoverManager(); - void slotShowDiagnosticsDialog(); - void slotShowMenuBar(); - void slotPlayMedia(); - void slotAddLocation( bool directPlay = false ); - void slotAddStream(); - void slotFocusPlaylistSearch(); - void slotFocusCollectionSearch(); - void slotShufflePlaylist(); - void slotSeekForwardShort(); - void slotSeekForwardMedium(); - void slotSeekForwardLong(); - void slotSeekBackwardShort(); - void slotSeekBackwardMedium(); - void slotSeekBackwardLong(); - void slotPutCurrentTrackToClipboard(); - -#ifdef DEBUG_BUILD_TYPE - void showNetworkRequestViewer(); -#endif // DEBUG_BUILD_TYPE - - protected: - virtual void closeEvent( QCloseEvent* ); - virtual void changeEvent( QEvent *event ); - - private slots: - void setRating1() { setRating( 1 ); } - void setRating2() { setRating( 2 ); } - void setRating3() { setRating( 3 ); } - void setRating4() { setRating( 4 ); } - void setRating5() { setRating( 5 ); } - - private: - void init(); - void setRating( int n ); - - CollectionWidget * m_collectionBrowser; - PlaylistBrowserNS::PlaylistBrowser * m_playlistBrowser; - - QWeakPointer m_menubar; - QWeakPointer m_toolsMenu; - QWeakPointer m_settingsMenu; -#ifdef DEBUG_BUILD_TYPE - QWeakPointer m_networkViewer; -#endif // DEBUG_BUILD_TYPE - - QWeakPointer m_browserDock; - QWeakPointer m_contextDock; - QWeakPointer m_playlistDock; - - QWeakPointer m_slimToolbar; - QWeakPointer m_mainToolbar; - - void createActions(); - void createMenus(); - - KAction* m_showMenuBar; - - int m_lastBrowser; - int m_searchField; - - static QWeakPointer s_instance; - - bool m_waitingForCd; -}; - - -#endif //AMAROK_PLAYLISTWINDOW_H - diff --git a/amarok/src/MediaDeviceCache.cpp b/amarok/src/MediaDeviceCache.cpp deleted file mode 100644 index 4fe7c03e..00000000 --- a/amarok/src/MediaDeviceCache.cpp +++ /dev/null @@ -1,377 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Jeff Mitchell * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "MediaDeviceCache" - -#include "MediaDeviceCache.h" - -#include "core/support/Amarok.h" -#include "core/support/Debug.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include - -#include -#include -#include - -MediaDeviceCache* MediaDeviceCache::s_instance = 0; - -MediaDeviceCache::MediaDeviceCache() : QObject() - , m_type() - , m_name() - , m_volumes() -{ - DEBUG_BLOCK - s_instance = this; - connect( Solid::DeviceNotifier::instance(), SIGNAL(deviceAdded(QString)), - this, SLOT(slotAddSolidDevice(QString)) ); - connect( Solid::DeviceNotifier::instance(), SIGNAL(deviceRemoved(QString)), - this, SLOT(slotRemoveSolidDevice(QString)) ); -} - -MediaDeviceCache::~MediaDeviceCache() -{ - s_instance = 0; -} - -void -MediaDeviceCache::refreshCache() -{ - DEBUG_BLOCK - m_type.clear(); - m_name.clear(); - QList deviceList = Solid::Device::listFromType( Solid::DeviceInterface::PortableMediaPlayer ); - foreach( const Solid::Device &device, deviceList ) - { - if( device.as() ) - { - debug() << "Found Solid PMP that is also a StorageDrive, skipping"; - continue; - } - debug() << "Found Solid::DeviceInterface::PortableMediaPlayer with udi = " << device.udi(); - debug() << "Device name is = " << device.product() << " and was made by " << device.vendor(); - m_type[device.udi()] = MediaDeviceCache::SolidPMPType; - m_name[device.udi()] = device.vendor() + " - " + device.product(); - } - deviceList = Solid::Device::listFromType( Solid::DeviceInterface::StorageAccess ); - foreach( const Solid::Device &device, deviceList ) - { - debug() << "Found Solid::DeviceInterface::StorageAccess with udi = " << device.udi(); - debug() << "Device name is = " << device.product() << " and was made by " << device.vendor(); - - const Solid::StorageAccess* ssa = device.as(); - - if( ssa ) - { - if( !m_volumes.contains( device.udi() ) ) - { - connect( ssa, SIGNAL(accessibilityChanged(bool,QString)), - this, SLOT(slotAccessibilityChanged(bool,QString)) ); - m_volumes.append( device.udi() ); - } - if( ssa->isAccessible() ) - { - m_type[device.udi()] = MediaDeviceCache::SolidVolumeType; - m_name[device.udi()] = ssa->filePath(); - m_accessibility[ device.udi() ] = true; - } - else - { - m_accessibility[ device.udi() ] = false; - debug() << "Solid device is not accessible, will wait until it is to consider it added."; - } - } - } - deviceList = Solid::Device::listFromType( Solid::DeviceInterface::StorageDrive ); - foreach( const Solid::Device &device, deviceList ) - { - debug() << "Found Solid::DeviceInterface::StorageDrive with udi = " << device.udi(); - debug() << "Device name is = " << device.product() << " and was made by " << device.vendor(); - - if( device.as() ) - { - m_type[device.udi()] = MediaDeviceCache::SolidGenericType; - m_name[device.udi()] = device.vendor() + " - " + device.product(); - } - } - deviceList = Solid::Device::listFromType( Solid::DeviceInterface::OpticalDisc ); - foreach( const Solid::Device &device, deviceList ) - { - debug() << "Found Solid::DeviceInterface::OpticalDisc with udi = " << device.udi(); - debug() << "Device name is = " << device.product() << " and was made by " << device.vendor(); - - const Solid::OpticalDisc * opt = device.as(); - - if ( opt && opt->availableContent() & Solid::OpticalDisc::Audio ) - { - debug() << "device is an Audio CD"; - m_type[device.udi()] = MediaDeviceCache::SolidAudioCdType; - m_name[device.udi()] = device.vendor() + " - " + device.product(); - } - } - KConfigGroup config = Amarok::config( "PortableDevices" ); - const QStringList manualDeviceKeys = config.entryMap().keys(); - foreach( const QString &udi, manualDeviceKeys ) - { - if( udi.startsWith( "manual" ) ) - { - debug() << "Found manual device with udi = " << udi; - m_type[udi] = MediaDeviceCache::ManualType; - m_name[udi] = udi.split( '|' )[1]; - } - } -} - -void -MediaDeviceCache::slotAddSolidDevice( const QString &udi ) -{ - DEBUG_BLOCK - Solid::Device device( udi ); - debug() << "Found new Solid device with udi = " << device.udi(); - debug() << "Device name is = " << device.product() << " and was made by " << device.vendor(); - Solid::StorageAccess *ssa = device.as(); - - Solid::OpticalDisc * opt = device.as(); - - if ( opt && opt->availableContent() & Solid::OpticalDisc::Audio ) - { - debug() << "device is an Audio CD"; - m_type[udi] = MediaDeviceCache::SolidAudioCdType; - m_name[udi] = device.vendor() + " - " + device.product(); - } - else if( ssa ) - { - debug() << "volume is generic storage"; - if( !m_volumes.contains( device.udi() ) ) - { - connect( ssa, SIGNAL(accessibilityChanged(bool,QString)), - this, SLOT(slotAccessibilityChanged(bool,QString)) ); - m_volumes.append( device.udi() ); - } - if( ssa->isAccessible() ) - { - m_type[udi] = MediaDeviceCache::SolidVolumeType; - m_name[udi] = ssa->filePath(); - } - else - { - debug() << "storage volume is not accessible right now, not adding."; - return; - } - } - else if( device.is() ) - { - debug() << "device is a Storage drive, still need a volume"; - m_type[udi] = MediaDeviceCache::SolidGenericType; - m_name[udi] = device.vendor() + " - " + device.product(); - } - else if( device.is() ) - { - debug() << "device is a PMP"; - m_type[udi] = MediaDeviceCache::SolidPMPType; - m_name[udi] = device.vendor() + " - " + device.product(); - } - else if( const Solid::GenericInterface *generic = device.as() ) - { - const QMap properties = generic->allProperties(); - /* At least iPod touch 3G and iPhone 3G do not advertise AFC (Apple File - * Connection) capabilities. Therefore we have to white-list them so that they are - * still recognised ad iPods - * - * @see IpodConnectionAssistant::identify() for a quirk that is currently also - * needed for proper identification of iPhone-like devices. - */ - if ( !device.product().contains("iPod") && !device.product().contains("iPhone")) - { - if( !properties.contains("info.capabilities") ) - { - debug() << "udi " << udi << " does not describe a portable media player or storage volume"; - return; - } - - const QStringList capabilities = properties["info.capabilities"].toStringList(); - if( !capabilities.contains("afc") ) - { - debug() << "udi " << udi << " does not describe a portable media player or storage volume"; - return; - } - } - - debug() << "udi" << udi << "is AFC cabable (Apple mobile device)"; - m_type[udi] = MediaDeviceCache::SolidGenericType; - m_name[udi] = device.vendor() + " - " + device.product(); - } - else - { - debug() << "udi " << udi << " does not describe a portable media player or storage volume"; - return; - } - emit deviceAdded( udi ); -} - -void -MediaDeviceCache::slotRemoveSolidDevice( const QString &udi ) -{ - DEBUG_BLOCK - debug() << "udi is: " << udi; - Solid::Device device( udi ); - if( m_volumes.contains( udi ) ) - { - disconnect( device.as(), SIGNAL(accessibilityChanged(bool,QString)), - this, SLOT(slotAccessibilityChanged(bool,QString)) ); - m_volumes.removeAll( udi ); - emit deviceRemoved( udi ); - } - if( m_type.contains( udi ) ) - { - m_type.remove( udi ); - m_name.remove( udi ); - emit deviceRemoved( udi ); - return; - } - debug() << "Odd, got a deviceRemoved at udi " << udi << " but it did not seem to exist in the first place..."; - emit deviceRemoved( udi ); -} - -void -MediaDeviceCache::slotAccessibilityChanged( bool accessible, const QString &udi ) -{ - debug() << "accessibility of device " << udi << " has changed to accessible = " << (accessible ? "true":"false"); - if( accessible ) - { - Solid::Device device( udi ); - m_type[udi] = MediaDeviceCache::SolidVolumeType; - Solid::StorageAccess *ssa = device.as(); - if( ssa ) - m_name[udi] = ssa->filePath(); - emit deviceAdded( udi ); - return; - } - else - { - if( m_type.contains( udi ) ) - { - m_type.remove( udi ); - m_name.remove( udi ); - emit deviceRemoved( udi ); - return; - } - debug() << "Got accessibility changed to false but was not there in the first place..."; - } - - emit accessibilityChanged( accessible, udi ); -} - -MediaDeviceCache::DeviceType -MediaDeviceCache::deviceType( const QString &udi ) const -{ - if( m_type.contains( udi ) ) - { - return m_type[udi]; - } - return MediaDeviceCache::InvalidType; -} - -const QString -MediaDeviceCache::deviceName( const QString &udi ) const -{ - if( m_name.contains( udi ) ) - { - return m_name[udi]; - } - return "ERR_NO_NAME"; //Should never happen! -} - -const QString -MediaDeviceCache::device( const QString &udi ) const -{ - DEBUG_BLOCK - Solid::Device device( udi ); - Solid::Device parent( device.parent() ); - if( !parent.isValid() ) - { - debug() << udi << "has no parent, returning null string."; - return QString(); - } - - Solid::Block* sb = parent.as(); - if( !sb ) - { - debug() << parent.udi() << "failed to convert to Block, returning null string."; - return QString(); - } - - return sb->device(); -} - -bool -MediaDeviceCache::isGenericEnabled( const QString &udi ) const -{ - DEBUG_BLOCK - if( m_type[udi] != MediaDeviceCache::SolidVolumeType ) - { - debug() << "Not SolidVolumeType, returning false"; - return false; - } - Solid::Device device( udi ); - Solid::StorageAccess* ssa = device.as(); - if( !ssa || !ssa->isAccessible() ) - { - debug() << "Not able to convert to StorageAccess or not accessible, returning false"; - return false; - } - if( device.parent().as() ) - { - debug() << "Could convert parent to PortableMediaPlayer, returning true"; - return true; - } - if( QFile::exists( ssa->filePath() + QDir::separator() + ".is_audio_player" ) ) - { - return true; - } - return false; -} - -const QString -MediaDeviceCache::volumeMountPoint( const QString &udi ) const -{ - DEBUG_BLOCK - Solid::Device device( udi ); - Solid::StorageAccess* ssa = device.as(); - if( !ssa || !ssa->isAccessible() ) - { - debug() << "Not able to convert to StorageAccess or not accessible, returning empty"; - return QString(); - } - return ssa->filePath(); -} - -#include "moc_MediaDeviceCache.cpp" - diff --git a/amarok/src/MediaDeviceCache.h b/amarok/src/MediaDeviceCache.h deleted file mode 100644 index 2d5288ad..00000000 --- a/amarok/src/MediaDeviceCache.h +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Jeff Mitchell * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_MEDIADEVICECACHE_H -#define AMAROK_MEDIADEVICECACHE_H - -#include "amarok_export.h" - -#include -#include -#include -#include -#include - -namespace Solid { - class Device; -} - -class AMAROK_EXPORT MediaDeviceCache : public QObject -{ - Q_OBJECT - - public: - - enum DeviceType { SolidPMPType, SolidVolumeType, ManualType, SolidAudioCdType, SolidGenericType, InvalidType }; - - static MediaDeviceCache* instance() { return s_instance ? s_instance : new MediaDeviceCache(); } - - /** - * Creates a new MediaDeviceCache. - * - */ - MediaDeviceCache(); - ~MediaDeviceCache(); - - void refreshCache(); - const QStringList getAll() const { return m_type.keys(); } - MediaDeviceCache::DeviceType deviceType( const QString &udi ) const; - const QString deviceName( const QString &udi ) const; - const QString device( const QString & udi ) const; - bool isGenericEnabled( const QString &udi ) const; - const QString volumeMountPoint( const QString &udi ) const; - - signals: - void deviceAdded( const QString &udi ); - void deviceRemoved( const QString &udi ); - void accessibilityChanged( bool accessible, const QString &udi ); - - public slots: - void slotAddSolidDevice( const QString &udi ); - void slotRemoveSolidDevice( const QString &udi ); - void slotAccessibilityChanged( bool accessible, const QString &udi ); - - private: - QMap m_type; - QMap m_name; - QMap m_accessibility; - QStringList m_volumes; - static MediaDeviceCache* s_instance; -}; - -#endif /* AMAROK_MEDIADEVICECACHE_H */ - diff --git a/amarok/src/MediaDeviceMonitor.cpp b/amarok/src/MediaDeviceMonitor.cpp deleted file mode 100644 index a912ab7d..00000000 --- a/amarok/src/MediaDeviceMonitor.cpp +++ /dev/null @@ -1,202 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Alejandro Wainzinger * - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "MediaDeviceMonitor" - -#include "MediaDeviceMonitor.h" - -#include "MediaDeviceCache.h" - -#include -#include -#include -#include -#include -#include -#include - -#include - -MediaDeviceMonitor* MediaDeviceMonitor::s_instance = 0; - -MediaDeviceMonitor::MediaDeviceMonitor() : QObject() - , m_udiAssistants() - , m_assistants() - , m_waitingassistants() - , m_nextassistant( 0 ) - // NOTE: commented out, needs porting to new device framework - //, m_currentCdId( QString() ) -{ - DEBUG_BLOCK - s_instance = this; - init(); -} - -MediaDeviceMonitor::~MediaDeviceMonitor() -{ - s_instance = 0; -} - -void -MediaDeviceMonitor::init() -{ - DEBUG_BLOCK - - // connect to device cache so new devices are tested too - connect( MediaDeviceCache::instance(), SIGNAL(deviceAdded(QString)), - SLOT(deviceAdded(QString)) ); - connect( MediaDeviceCache::instance(), SIGNAL(deviceRemoved(QString)), - SLOT(slotDeviceRemoved(QString)) ); - connect( MediaDeviceCache::instance(), SIGNAL(accessibilityChanged(bool,QString)), - SLOT(slotAccessibilityChanged(bool,QString)) ); -} - -QStringList -MediaDeviceMonitor::getDevices() -{ - DEBUG_BLOCK - /* get list of devices */ - MediaDeviceCache::instance()->refreshCache(); - return MediaDeviceCache::instance()->getAll(); - -} - -void MediaDeviceMonitor::checkDevice(const QString& udi) -{ - DEBUG_BLOCK - - // First let the higher priority devices check - - foreach( ConnectionAssistant* assistant, m_assistants ) - { - checkOneDevice( assistant, udi ); - } - - // Then let the assistants that can wait check - - foreach( ConnectionAssistant* assistant, m_waitingassistants ) - { - checkOneDevice( assistant, udi ); - } - -} - -void MediaDeviceMonitor::checkOneDevice( ConnectionAssistant* assistant, const QString& udi ) -{ - // Ignore already identified devices - if( m_udiAssistants.keys().contains( udi ) ) - { - debug() << "Device already identified with udi: " << udi; - return; - } - - if( assistant->identify( udi ) ) - { - debug() << "Device identified with udi: " << udi; - // keep track of which assistant deals with which device - m_udiAssistants.insert( udi, assistant ); - // inform factory of new device identified - assistant->tellIdentified( udi ); - return; - } -} - -void MediaDeviceMonitor::checkDevicesFor( ConnectionAssistant* assistant ) -{ - DEBUG_BLOCK - - QStringList udiList = getDevices(); - - foreach( const QString &udi, udiList ) - { - checkOneDevice( assistant, udi ); - } - -} - -void -MediaDeviceMonitor::registerDeviceType( ConnectionAssistant* assistant ) -{ - DEBUG_BLOCK - - // If the device wants to wait and give other device types - // a chance to recognize devices, put it in a queue for - // later device checking - - if ( assistant->wait() ) - { - // keep track of this type of device from now on - m_waitingassistants << assistant; - - QTimer::singleShot( 1000, this, SLOT(slotDequeueWaitingAssistant()) ); - } - else - { - // keep track of this type of device from now on - m_assistants << assistant; - - // start initial check for devices of this type - checkDevicesFor( assistant ); - } - -} - -void -MediaDeviceMonitor::deviceAdded( const QString &udi ) -{ - DEBUG_BLOCK - - // check if device is a known device - checkDevice( udi ); -} - -void -MediaDeviceMonitor::slotDeviceRemoved( const QString &udi ) -{ - DEBUG_BLOCK - - if ( m_udiAssistants.contains( udi ) ) - { - - m_udiAssistants.value( udi )->tellDisconnected( udi ); - - m_udiAssistants.remove( udi ); - } - - -// emit deviceRemoved( udi ); -} - -void -MediaDeviceMonitor::slotAccessibilityChanged( bool accessible, const QString & udi) -{ - // TODO: build a hack to force a device to become accessible or not - // This means auto-mounting of Ipod, and ejecting of it too - - DEBUG_BLOCK - debug() << "Accessibility changed to: " << ( accessible ? "true":"false" ); - if ( !accessible ) - deviceRemoved( udi ); - else - deviceAdded( udi ); -} - -void -MediaDeviceMonitor::slotDequeueWaitingAssistant() -{ - checkDevicesFor( m_waitingassistants.at( m_nextassistant++ ) ); -} diff --git a/amarok/src/MediaDeviceMonitor.h b/amarok/src/MediaDeviceMonitor.h deleted file mode 100644 index 4de98db6..00000000 --- a/amarok/src/MediaDeviceMonitor.h +++ /dev/null @@ -1,131 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Alejandro Wainzinger * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -/* - -Description: - -The MediaDeviceMonitor connects to the MediaDeviceCache, monitoring the connection and disconnection of devices. It tests -for devices known to Amarok, and if it finds them, sends a signal that the appropriate CollectionFactory is connected to, -which triggers the creation of the associated Collection. Similar behaviour for when a device is disconnected. - -All new MediaDeviceCollection-type classes must register their ConnectionAssistant of their device with this class, and have -it connect to the right signals to properly build/delete the associated Collection. An example of this is seen in the -IpodCollectionFactory. - -*/ - -#ifndef AMAROK_MEDIADEVICEMONITOR_H -#define AMAROK_MEDIADEVICEMONITOR_H - -//#include "MediaDeviceInfo.h" - -#include "amarok_export.h" -#include "core-impl/collections/mediadevicecollection/support/ConnectionAssistant.h" -#include "core/support/Debug.h" - -#include -#include -#include - -class ConnectionAssistant; -class MediaDeviceInfo; - -class QStringList; - -class AMAROK_EXPORT MediaDeviceMonitor : public QObject -{ - Q_OBJECT - - public: - - static MediaDeviceMonitor* instance() { return s_instance ? s_instance : new MediaDeviceMonitor(); } - - MediaDeviceMonitor(); - ~MediaDeviceMonitor(); - - void init(); // connect to MediaDeviceCache - - QStringList getDevices(); // get list of devices - - /// Get assistant for a given udi - ConnectionAssistant *getUdiAssistant( const QString &udi ) - { - return m_udiAssistants[ udi ]; - } - - /** - - registerDeviceType adds the device type described by @param assistant to the list - of known device types by the MDM, and then checks the list of known devices - for a match with this type - - */ - void registerDeviceType( ConnectionAssistant *assistant ); - - public slots: - - /** - - checkDevice checks if @param udi is a known device - and if so attempts to connect it - - checkOneDevice runs an identify check using the given - assistant and udi - - checkDevicesFor checks if the device type described - by @param assistant matches any of the udi's in the - MediaDeviceCache, and if so, attempts to connect to - it - - */ - - void checkDevice( const QString &udi ); - void checkOneDevice( ConnectionAssistant* assistant, const QString& udi ); - void checkDevicesFor( ConnectionAssistant* assistant ); - - - signals: - void deviceDetected( const MediaDeviceInfo &deviceinfo ); - void deviceRemoved( const QString &udi ); - - - private slots: - - void deviceAdded( const QString &udi ); - void slotDeviceRemoved( const QString &udi ); - void slotAccessibilityChanged( bool accessible, const QString & udi ); - - void slotDequeueWaitingAssistant(); - - - private: - static MediaDeviceMonitor *s_instance; - - // keeps track of which CA to contact for which udi - QHash m_udiAssistants; - // holds all registered assistants - QList m_assistants; - // holds all waiting assistants - QList m_waitingassistants; - // holds index of next waiting assistant to check - // devices with, during initialization of device - // factories - int m_nextassistant; -}; - -#endif /* AMAROK_MEDIADEVICEMONITOR_H */ - diff --git a/amarok/src/Messages.sh b/amarok/src/Messages.sh deleted file mode 100755 index 42cee3a9..00000000 --- a/amarok/src/Messages.sh +++ /dev/null @@ -1,8 +0,0 @@ -#! /bin/sh -$EXTRACTRC `find . -name "*.rc" -o -name "*.ui" -o -name "*.kcfg"` >> rc.cpp -$EXTRACTATTR --attr=layout,name ../data/DefaultPlaylistLayouts.xml >> rc.cpp -LIST=`find . -name \*.h -o -name \*.cpp` -if test -n "$LIST"; then - $XGETTEXT $LIST -o $podir/amarok.pot -fi -rm -f rc.cpp diff --git a/amarok/src/OpmlOutline.cpp b/amarok/src/OpmlOutline.cpp deleted file mode 100644 index bb97efb6..00000000 --- a/amarok/src/OpmlOutline.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Nikolaj Hald Nielsen * - * Copyright (c) 2009-2010 Bart Cerneels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "OpmlOutline.h" - -OpmlOutline::OpmlOutline( OpmlOutline *parent ) - : m_parent( parent ) - , m_hasChildren( false ) -{ -} - -OpmlNodeType -OpmlOutline::opmlNodeType() const -{ - if( !attributes().contains( "text" ) ) - return InvalidNode; - - if( !attributes().contains( "type") ) - return RegularNode; - - if( attributes()["type"] == "rss" ) - return RssUrlNode; - - if( attributes()["type"] == "include" ) - return IncludeNode; - - return UnknownNode; - -} diff --git a/amarok/src/OpmlOutline.h b/amarok/src/OpmlOutline.h deleted file mode 100644 index 57332640..00000000 --- a/amarok/src/OpmlOutline.h +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Nikolaj Hald Nielsen * - * Copyright (c) 2009-2010 Bart Cerneels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef OPMLOUTLINE_H -#define OPMLOUTLINE_H - -#include "amarok_export.h" - -#include -#include - -enum OpmlNodeType -{ - InvalidNode, - UnknownNode, - RssUrlNode, //leaf node that link to an RSS - IncludeNode, //URL to an OPML file that will be loaded as a sub-tree upon expansion - RegularNode //plain sub-tree which can be represented as a folder. -}; - -class AMAROK_EXPORT OpmlOutline -{ - public: - OpmlOutline( OpmlOutline *parent = 0 ); - ~OpmlOutline() {} - - OpmlOutline *parent() const { return m_parent; } - void setParent( OpmlOutline *parent ) { m_parent = parent; } - bool isRootItem() const { return m_parent == 0; } - - QMap attributes() const { return m_attributes; } - - /** @return a modifiable reference to the attributes */ - QMap &mutableAttributes() { return m_attributes; } - void addAttribute( const QString &key, const QString &value ) - { m_attributes.insert( key, value ); } - - QList children() const { return m_children; } - - /** @return a modifiable reference to the children */ - QList &mutableChildren() { return m_children; } - void setHasChildren( bool hasChildren ) { m_hasChildren = hasChildren; } - bool hasChildren() const { return m_hasChildren; } - void addChild( OpmlOutline *outline ) { m_children << outline; } - void addChildren( QList outlineList ) - { m_children << outlineList; } - - OpmlNodeType opmlNodeType() const; - - private: - OpmlOutline *m_parent; - QMap m_attributes; - - bool m_hasChildren; - QList m_children; -}; - -#endif // OPMLOUTLINE_H diff --git a/amarok/src/OpmlParser.cpp b/amarok/src/OpmlParser.cpp deleted file mode 100644 index 7bfc94eb..00000000 --- a/amarok/src/OpmlParser.cpp +++ /dev/null @@ -1,429 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Bart Cerneels * - * 2009 Mathias Panzenböck * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "OpmlParser.h" - -#include "core/support/Amarok.h" -#include "core/support/Debug.h" - -#include -#include - -#include -#include - -const QString OpmlParser::OPML_MIME = "text/x-opml+xml"; - -const OpmlParser::StaticData OpmlParser::sd; - -OpmlParser::OpmlParser( const KUrl &url ) - : ThreadWeaver::Job() - , QXmlStreamReader() - , m_url( url ) -{ -} - -OpmlParser::~OpmlParser() -{ -} - -void -OpmlParser::run() -{ - read( m_url ); -} - -bool -OpmlParser::read( const KUrl &url ) -{ - m_url = url; - if( m_url.isLocalFile() ) - { - //read directly from local file - QFile localFile( m_url.toLocalFile() ); - if( !localFile.open( QIODevice::ReadOnly ) ) - { - debug() << "failed to open local OPML file " << m_url.url(); - return false; - } - - return read( &localFile ); - } - - m_transferJob = KIO::get( m_url, KIO::Reload, KIO::HideProgressInfo ); - - connect( m_transferJob, SIGNAL(data(KIO::Job*,QByteArray)), - SLOT(slotAddData(KIO::Job*,QByteArray)) ); - - connect( m_transferJob, SIGNAL(result(KJob*)), - SLOT(downloadResult(KJob*)) ); - - // parse data - return read(); -} - -bool -OpmlParser::read( QIODevice *device ) -{ - setDevice( device ); - return read(); -} - -void -OpmlParser::slotAddData( KIO::Job *job, const QByteArray &data ) -{ - Q_UNUSED( job ) - - QXmlStreamReader::addData( data ); - - // parse more data - continueRead(); -} - -void -OpmlParser::downloadResult( KJob *job ) -{ - // parse more data - continueRead(); - - KIO::TransferJob *transferJob = dynamic_cast( job ); - if( job->error() || ( transferJob && transferJob->isErrorPage() ) ) - { - QString errorMessage = - i18n( "Reading OPML podcast from %1 failed with error:\n", m_url.url() ); - errorMessage = errorMessage.append( job->errorString() ); - -// emit statusBarSorryMessage( errorMessage ); - } - - m_transferJob = 0; -} - -void -OpmlParser::slotAbort() -{ - DEBUG_BLOCK -} - -void -OpmlParser::Action::begin( OpmlParser *opmlParser ) const -{ - if( m_begin ) - (( *opmlParser ).*m_begin )(); -} - -void -OpmlParser::Action::end( OpmlParser *opmlParser ) const -{ - if( m_end ) - (( *opmlParser ).*m_end )(); -} - -void -OpmlParser::Action::characters( OpmlParser *opmlParser ) const -{ - if( m_characters ) - (( *opmlParser ).*m_characters )(); -} - -// initialization of the feed parser automata: -OpmlParser::StaticData::StaticData() - : startAction( rootMap ) - , docAction( - docMap, - 0, - &OpmlParser::endDocument ) - , skipAction( skipMap ) - , noContentAction( - noContentMap, - &OpmlParser::beginNoElement, - 0, - &OpmlParser::readNoCharacters ) - , opmlAction( - opmlMap, - &OpmlParser::beginOpml ) - , headAction( - headMap, - 0, - &OpmlParser::endHead ) - , titleAction( - textMap, - &OpmlParser::beginText, - &OpmlParser::endTitle, - &OpmlParser::readCharacters ) - , bodyAction( bodyMap ) - , outlineAction( - outlineMap, - &OpmlParser::beginOutline, - &OpmlParser::endOutline ) -{ - // known elements: - knownElements[ "opml" ] = Opml; - knownElements[ "html" ] = Html; - knownElements[ "HTML" ] = Html; - knownElements[ "head" ] = Head; - knownElements[ "title" ] = Title; - knownElements[ "dateCreated" ] = DateCreated; - knownElements[ "dateModified" ] = DateModified; - knownElements[ "ownerName" ] = OwnerName; - knownElements[ "ownerEmail" ] = OwnerEmail; - knownElements[ "ownerId" ] = OwnerId; - knownElements[ "docs" ] = Docs; - knownElements[ "expansionState" ] = ExpansionState; - knownElements[ "vertScrollState" ] = VertScrollState; - knownElements[ "windowTop" ] = WindowTop; - knownElements[ "windowLeft" ] = WindowLeft; - knownElements[ "windowBottom" ] = WindowBottom; - knownElements[ "windowRight" ] = WindowRight; - knownElements[ "body" ] = Body; - knownElements[ "outline" ] = Outline; - - // before start document/after end document - rootMap.insert( Document, &docAction ); - - // parse document - docMap.insert( Opml, &opmlAction ); -// docMap.insert( Html, &htmlAction ); - - // parse - opmlMap.insert( Head, &headAction ); - opmlMap.insert( Body, &bodyAction ); - - // parse - headMap.insert( Title, &titleAction ); - headMap.insert( DateCreated, &skipAction ); - headMap.insert( DateModified, &skipAction ); - headMap.insert( OwnerName, &skipAction ); - headMap.insert( OwnerEmail, &skipAction ); - headMap.insert( OwnerId, &skipAction ); - headMap.insert( Docs, &skipAction ); - headMap.insert( ExpansionState, &skipAction ); - headMap.insert( VertScrollState, &skipAction ); - headMap.insert( WindowTop, &skipAction ); - headMap.insert( WindowLeft, &skipAction ); - headMap.insert( WindowBottom, &skipAction ); - headMap.insert( WindowRight, &skipAction ); - - // parse - bodyMap.insert( Outline, &outlineAction ); - - // parse in case of sub-elements - outlineMap.insert( Outline, &outlineAction ); - - // skip elements - skipMap.insert( Any, &skipAction ); - -} - -OpmlParser::ElementType -OpmlParser::elementType() const -{ - if( isEndDocument() || isStartDocument() ) - return Document; - - if( isCDATA() || isCharacters() ) - return CharacterData; - - ElementType elementType = sd.knownElements[ QXmlStreamReader::name().toString()]; - - return elementType; -} - -bool -OpmlParser::read() -{ - m_buffer.clear(); - m_actionStack.clear(); - m_actionStack.push( &( OpmlParser::sd.startAction ) ); - setNamespaceProcessing( false ); - - return continueRead(); -} - -bool -OpmlParser::continueRead() -{ - // this is some kind of pushdown automata - // with this it should be possible to parse feeds in parallel - // without using threads - DEBUG_BLOCK - - while( !atEnd() && error() != CustomError ) - { - TokenType token = readNext(); - - if( error() == PrematureEndOfDocumentError && m_transferJob ) - return true; - - if( hasError() ) - { - emit doneParsing(); - return false; - } - - if( m_actionStack.isEmpty() ) - { - debug() << "expected element on stack!"; - return false; - } - - const Action* action = m_actionStack.top(); - const Action* subAction = 0; - - switch( token ) - { - case Invalid: - { - debug() << "invalid token received at line " << lineNumber(); - debug() << "Error:\n" << errorString(); - return false; - } - - case StartDocument: - case StartElement: - subAction = action->actionMap()[ elementType() ]; - - if( !subAction ) - subAction = action->actionMap()[ Any ]; - - if( !subAction ) - subAction = &( OpmlParser::sd.skipAction ); - - m_actionStack.push( subAction ); - - subAction->begin( this ); - break; - - case EndDocument: - case EndElement: - action->end( this ); - - if( m_actionStack.pop() != action ) - { - debug() << "popped other element than expected!"; - } - break; - - case Characters: - if( !isWhitespace() || isCDATA() ) - { - action->characters( this ); - } - - // ignoreable whitespaces - case Comment: - case EntityReference: - case ProcessingInstruction: - case DTD: - case NoToken: - // ignore - break; - } - } - - return !hasError(); -} - -void -OpmlParser::stopWithError( const QString &message ) -{ - raiseError( message ); - - if( m_transferJob ) - { - m_transferJob->kill( KJob::EmitResult ); - m_transferJob = 0; - } - - emit doneParsing(); -} - -void -OpmlParser::beginOpml() -{ - m_outlineStack.clear(); -} - -void -OpmlParser::beginText() -{ - m_buffer.clear(); -} - -void -OpmlParser::beginOutline() -{ - OpmlOutline *parent = m_outlineStack.empty() ? 0 : m_outlineStack.top(); - OpmlOutline *outline = new OpmlOutline( parent ); - //adding outline to stack - m_outlineStack.push( outline ); - if( parent ) - { - parent->setHasChildren( true ); - parent->addChild( outline ); - } - - foreach( const QXmlStreamAttribute &attribute, attributes() ) - outline->addAttribute( attribute.name().toString(), attribute.value().toString() ); - - emit outlineParsed( outline ); -} - -void -OpmlParser::beginNoElement() -{ - debug() << "no element expected here, but got element: " << QXmlStreamReader::name(); -} - -void -OpmlParser::endDocument() -{ - emit doneParsing(); -} - -void -OpmlParser::endHead() -{ - emit headerDone(); -} - -void -OpmlParser::endTitle() -{ - m_headerData.insert( "title", m_buffer.trimmed() ); -} - -void -OpmlParser::endOutline() -{ - OpmlOutline *outline = m_outlineStack.pop(); - if( m_outlineStack.isEmpty() ) - m_outlines << outline; -} - -void -OpmlParser::readCharacters() -{ - m_buffer += text(); -} - -void -OpmlParser::readNoCharacters() -{ - DEBUG_BLOCK - debug() << "no characters expected here"; -} diff --git a/amarok/src/OpmlParser.h b/amarok/src/OpmlParser.h deleted file mode 100644 index e1e5b8e7..00000000 --- a/amarok/src/OpmlParser.h +++ /dev/null @@ -1,271 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Nikolaj Hald Nielsen * - * Copyright (c) 2009 Bart Cerneels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef OPMLPARSER_H -#define OPMLPARSER_H - -#include "amarok_export.h" -#include "OpmlOutline.h" - -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -namespace KIO -{ - class Job; - class TransferJob; -} - -/** -* Parser for OPML files. -*/ -class AMAROK_EXPORT OpmlParser : public ThreadWeaver::Job, public QXmlStreamReader -{ - Q_OBJECT - -public: - static const QString OPML_MIME; - /** - * Constructor - * @param fileName The file to parse - * @return Pointer to new object - */ - OpmlParser( const KUrl &url ); - - /** - * Destructor - * @return none - */ - ~OpmlParser(); - - /** - * The function that starts the actual work. Inherited from ThreadWeaver::Job - * Note the work is performed in a separate thread - * @return Returns true on success and false on failure - */ - void run(); - - bool read( const KUrl &url ); - bool read( QIODevice *device ); - - /** @return the URL of the OPML being parsed. - */ - KUrl url() const { return m_url; } - - QMap headerData() { return m_headerData; } - - /** - * Get the result of the parsing as a list of OpmlOutlines. - * This list contains only root outlines that can be found in the of the OPML. - * The rest are children of these root items. - * - * The user is responsible for deleting the results. - */ - QList results() const { return m_outlines; } - -signals: - - /** - * Emitted when has been completely parsed. - */ - void headerDone(); - - /** - * Signal emmited when parsing is complete. - * The data is complete now and accessible via results(). - * Children of all the outlines are available via OpmlOutline::children(). - */ - void doneParsing(); - - /** - * Emitted when a new outline item is available. - * Emitted after the attributes have been read but before any of the children are available. - * Each child will be reported in a separate signal. - */ - void outlineParsed( OpmlOutline *outline ); - -public slots: - virtual void slotAbort(); - -private slots: - void slotAddData( KIO::Job *, const QByteArray &data ); - - void downloadResult( KJob * ); - -private: - enum ElementType - { - Unknown = 0, - Any, - Document, - CharacterData, - Opml, - Html, - Head, - Title, - DateCreated, - DateModified, - OwnerName, - OwnerEmail, - OwnerId, - Docs, - ExpansionState, - VertScrollState, - WindowTop, - WindowLeft, - WindowBottom, - WindowRight, - Body, - Outline - }; - - class Action; - typedef void (OpmlParser::*ActionCallback)(); - typedef QHash ActionMap; - - class Action - { - public: - Action( ActionMap &actionMap ) - : m_actionMap( actionMap ) - , m_begin( 0 ) - , m_end( 0 ) - , m_characters( 0 ) {} - - Action(ActionMap &actionMap, ActionCallback begin) - : m_actionMap( actionMap ) - , m_begin( begin ) - , m_end( 0 ) - , m_characters( 0 ) {} - - Action(ActionMap &actionMap, ActionCallback begin, ActionCallback end) - : m_actionMap( actionMap ) - , m_begin( begin ) - , m_end( end ) - , m_characters( 0 ) {} - - Action(ActionMap &actionMap, ActionCallback begin, - ActionCallback end, ActionCallback characters) - : m_actionMap( actionMap ) - , m_begin( begin ) - , m_end( end ) - , m_characters( characters ) {} - - void begin( OpmlParser *opmlParser ) const; - void end( OpmlParser *opmlParser ) const; - void characters( OpmlParser *opmlParser ) const; - - const ActionMap &actionMap() const { return m_actionMap; } - - private: - ActionMap &m_actionMap; - ActionCallback m_begin; - ActionCallback m_end; - ActionCallback m_characters; - }; - - ElementType elementType() const; - bool read(); - bool continueRead(); - - // callback methods for parsing - void beginOpml(); - void beginText(); - void beginOutline(); - void beginNoElement(); - - void endDocument(); - void endHead(); - void endTitle(); - void endOutline(); - - void readCharacters(); - void readNoCharacters(); - - void stopWithError( const QString &message ); - - class StaticData { - public: - StaticData(); - - // This here basically builds an automata. - // This way feed parsing can be paused after any token, - // thus enabling parallel download and parsing of multiple - // feeds without the need for threads. - - QHash knownElements; - - //Actions - Action startAction; - - Action docAction; - Action skipAction; - Action noContentAction; - - Action opmlAction; - - Action headAction; - Action titleAction; -// Action dateCreatedAction; -// Action dateModifiedAction; -// Action ownerNameAction; -// Action ownerEmailAction; -// Action ownerIdAction; -// Action docsAction; -// Action expansionStateAction; - Action bodyAction; - Action outlineAction; - - ActionMap rootMap; - ActionMap skipMap; - ActionMap noContentMap; - ActionMap xmlMap; - - ActionMap docMap; - ActionMap opmlMap; - ActionMap headMap; - ActionMap bodyMap; - ActionMap outlineMap; - ActionMap textMap; - }; - - static const StaticData sd; - - QStack m_actionStack; - - QString m_buffer; - - QMap m_headerData; - // the top level outlines of . - QList m_outlines; - - // currently processing outlines so we can do nested outlines. - QStack m_outlineStack; - - KUrl m_url; - KIO::TransferJob *m_transferJob; -}; - -#endif diff --git a/amarok/src/OpmlWriter.cpp b/amarok/src/OpmlWriter.cpp deleted file mode 100644 index e70ad562..00000000 --- a/amarok/src/OpmlWriter.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Bart Cerneels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "OpmlWriter.h" -#include "core/support/Debug.h" - -#include - -OpmlWriter::OpmlWriter( const QList rootOutlines, - const QMap headerData, - QIODevice *device ) - : ThreadWeaver::Job() - , m_rootOutlines( rootOutlines ) - , m_headerData( headerData ) -{ - m_xmlWriter = new QXmlStreamWriter( device ); -} - -void -OpmlWriter::run() -{ -#define _x m_xmlWriter - _x->setAutoFormatting( true ); - _x->writeStartDocument(); - _x->writeStartElement( "opml" ); - _x->writeAttribute( "version", "2.0" ); - _x->writeStartElement( "head" ); - QMapIterator ai( m_headerData ); //attributesIterator - while( ai.hasNext() ) - { - ai.next(); - _x->writeTextElement( ai.key(), ai.value() ); - } - _x->writeEndElement(); // head - _x->writeStartElement( "body" ); - foreach( const OpmlOutline *childOutline, m_rootOutlines ) - writeOutline( childOutline ); - _x->writeEndDocument(); //implicitly closes all open tags (opml & body) - emit result( 0 ); -} - -void -OpmlWriter::writeOutline( const OpmlOutline *outline ) -{ - bool hasChildren = outline->children().count() != 0; - if( hasChildren && ( outline->opmlNodeType() != IncludeNode ) ) - _x->writeStartElement( "outline" ); - else - _x->writeEmptyElement( "outline" ); - QMapIterator ai( outline->attributes() ); // attributesIterator - while( ai.hasNext() ) - { - ai.next(); - _x->writeAttribute( ai.key(), ai.value() ); - } - - // children of expanded include nodes should not be saved. - if( hasChildren && ( outline->opmlNodeType() != IncludeNode ) ) - { - foreach( const OpmlOutline *childOutline, outline->children() ) - writeOutline( childOutline ); - _x->writeEndElement(); // outline - } -} diff --git a/amarok/src/OpmlWriter.h b/amarok/src/OpmlWriter.h deleted file mode 100644 index ca3ddf26..00000000 --- a/amarok/src/OpmlWriter.h +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Bart Cerneels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef OPMLWRITER_H -#define OPMLWRITER_H - -#include "OpmlOutline.h" - -#include -#include - -#include - -class AMAROK_EXPORT OpmlWriter : public ThreadWeaver::Job -{ - Q_OBJECT - public: - /** OpmlWriter will write the OPML outline objects as XML text. - * @arg rootOutlines the of the OPML - * @arg headerData these fields are put in the of the OPML - * @arg device QIODevice to write to - * The children of IncludeNodes will not be written. Remove the type="include" attribute - * from the include node to force a save of those child nodes. - */ - OpmlWriter( const QList rootOutlines, - const QMap headerData, - QIODevice *device ); - - void setHeaderData( const QMap data ) { m_headerData = data; } - /** - * The function that starts the actual work. Inherited from ThreadWeaver::Job - * Note the work is performed in a separate thread - * @return Returns true on success and false on failure - */ - void run(); - - QIODevice *device() { return m_xmlWriter->device(); } - - signals: - /** - * Signal emmited when writing is complete. - */ - void result( int error ); - - private: - void writeOutline( const OpmlOutline *outline ); - QList m_rootOutlines; - QMap m_headerData; - - KUrl m_fileUrl; - QXmlStreamWriter *m_xmlWriter; -}; - -#endif // OPMLWRITER_H diff --git a/amarok/src/PaletteHandler.cpp b/amarok/src/PaletteHandler.cpp deleted file mode 100644 index 7ab11c77..00000000 --- a/amarok/src/PaletteHandler.cpp +++ /dev/null @@ -1,154 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "PaletteHandler" - -#include "PaletteHandler.h" - -#include - -#include - - -namespace The { - static PaletteHandler* s_PaletteHandler_instance = 0; - - PaletteHandler* paletteHandler() - { - if( !s_PaletteHandler_instance ) - s_PaletteHandler_instance = new PaletteHandler(); - - return s_PaletteHandler_instance; - } -} - - -PaletteHandler::PaletteHandler( QObject* parent ) - : QObject( parent ) -{} - - -PaletteHandler::~PaletteHandler() -{ - The::s_PaletteHandler_instance = 0; -} - -void -PaletteHandler::setPalette( const QPalette & palette ) -{ - m_palette = palette; - emit( newPalette( m_palette ) ); -} - -void -PaletteHandler::updateItemView( QAbstractItemView * view ) -{ - QPalette p = m_palette; - QColor c; - - // Widgets with keyboard focus become slightly transparent - c = p.color( QPalette::Active, QPalette::AlternateBase ); - c.setAlpha( 95 ); - p.setColor( QPalette::Active, QPalette::AlternateBase, c ); - - // For widgets that don't have keyboard focus reduce the opacity further - c = p.color( QPalette::Inactive, QPalette::AlternateBase ); - c.setAlpha( 75 ); - p.setColor( QPalette::Inactive, QPalette::AlternateBase, c ); - - // Base color is used during the expand/shrink animation. We set it - // to transparent so that it won't interfere with our custom colors. - p.setColor( QPalette::Active, QPalette::Base, Qt::transparent ); - p.setColor( QPalette::Inactive, QPalette::Base, Qt::transparent ); - - view->setPalette( p ); - - if ( QWidget *vp = view->viewport() ) - { - // don't paint background - do NOT use Qt::transparent etc. - vp->setAutoFillBackground( false ); - vp->setBackgroundRole( QPalette::Window ); - vp->setForegroundRole( QPalette::WindowText ); - // erase custom viewport palettes, shall be "transparent" - vp->setPalette(QPalette()); - } -} - -QColor -PaletteHandler::foregroundColor( const QPainter *p, bool selected ) -{ - QPalette pal; - QPalette::ColorRole fg = QPalette::WindowText; - if ( p->device() && p->device()->devType() == QInternal::Widget) - { - QWidget *w = static_cast( p->device() ); - fg = w->foregroundRole(); - pal = w->palette(); - } - else - pal = palette(); - - if( !selected ) - return pal.color( QPalette::Active, fg ); - - return pal.color( QPalette::Active, QPalette::HighlightedText ); -} - -QPalette -PaletteHandler::palette() const -{ - return m_palette; -} - -QColor -PaletteHandler::highlightColor( qreal saturationPercent, qreal valuePercent ) -{ - QColor highlight = The::paletteHandler()->palette().color( QPalette::Active, QPalette::Highlight ); - qreal saturation = highlight.saturationF(); - saturation *= saturationPercent; - qreal value = highlight.valueF(); - value *= valuePercent; - if( value > 1.0 ) - value = 1.0; - highlight.setHsvF( highlight.hueF(), saturation, value, highlight.alphaF() ); - - return highlight; -} - -QColor -PaletteHandler::backgroundColor() -{ - QColor base = The::paletteHandler()->palette().color( QPalette::Active, QPalette::Base ); - base.setHsvF( highlightColor().hueF(), base.saturationF(), base.valueF() ); - return base; -} - -QColor -PaletteHandler::alternateBackgroundColor() -{ - const QColor alternate = The::paletteHandler()->palette().color( QPalette::Active, QPalette::AlternateBase ); - const QColor window = The::paletteHandler()->palette().color( QPalette::Active, QPalette::Window ); - const QColor base = backgroundColor(); - - const int alternateDist = abs( alternate.value() - base.value() ); - const int windowDist = abs( window.value() - base.value() ); - - QColor result = alternateDist > windowDist ? alternate : window; - result.setHsvF( highlightColor().hueF(), highlightColor().saturationF(), result.valueF() ); - return result; -} - -#include "moc_PaletteHandler.cpp" diff --git a/amarok/src/PaletteHandler.h b/amarok/src/PaletteHandler.h deleted file mode 100644 index 9c1517db..00000000 --- a/amarok/src/PaletteHandler.h +++ /dev/null @@ -1,93 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef PALETTEHANDLER_H -#define PALETTEHANDLER_H - -#include "amarok_export.h" - -#include -#include - -class PaletteHandler; - -namespace The { - AMAROK_EXPORT PaletteHandler* paletteHandler(); -} - -/** -A small singleton class to handle propagating palette change notifications and hold some utility functions for updating certain widgets - - @author Nikolaj Hald Nielsen -*/ -class AMAROK_EXPORT PaletteHandler : public QObject -{ - Q_OBJECT - -friend PaletteHandler* The::paletteHandler(); - -public: - ~PaletteHandler(); - - QPalette palette() const; - - void setPalette( const QPalette & palette ); - - /** Gives the item view a special darker palette and transparent background. - You need to connect to the newPalette signal afterwards because this - darker palette does not automatically update. - */ - void updateItemView( QAbstractItemView * view ); - - /** - * Returns the foreground color for the painter by checking the painting QWidget::foregroundRole() and falling back to - * QPalette::WindowText (or QPalette::HighlightedText if @param selected) - * Uses the widgets palette or the application palette as fallback - */ - QColor foregroundColor( const QPainter *p, bool selected = false ); - - /** - * Returns the highlight color which should be used instead of the color from KDE. - * @param percentSaturation Decimal percentage to saturate the highlight color. Will - * reduce (or magnify) the saturation in HSV representation of the color. - * Defaults to 50% - * @param percentValue Decimal percentage to multiply the value of the HSV color with. - * Defaults to 100%. - * @return Highlight color, which is the KDE highlight color, with reduced saturation - * (less contrast). - */ - static QColor highlightColor( qreal percentSaturation = 0.5, qreal percentValue = 1.0 ); - - /** - * Returns the background color used in context applets. - */ - static QColor backgroundColor(); - - /** - * Returns the alternate background color used in context applets. - */ - static QColor alternateBackgroundColor(); - -signals: - void newPalette( const QPalette & palette ); - -private: - PaletteHandler( QObject* parent = 0 ); - - QPalette m_palette; -}; - -#endif diff --git a/amarok/src/PluginManager.cpp b/amarok/src/PluginManager.cpp deleted file mode 100644 index 9e0e8ec6..00000000 --- a/amarok/src/PluginManager.cpp +++ /dev/null @@ -1,304 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2004-2013 Mark Kretschmann * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "PluginManager" - -#include "PluginManager.h" - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include - - -/** Defines the used plugin version number. - * - * This must match the desktop files. - */ -const int Plugins::PluginManager::s_pluginFrameworkVersion = 72; -Plugins::PluginManager* Plugins::PluginManager::s_instance = 0; - -Plugins::PluginManager* -Plugins::PluginManager::instance() -{ - return s_instance ? s_instance : new PluginManager(); -} - -void -Plugins::PluginManager::destroy() -{ - if( s_instance ) - { - delete s_instance; - s_instance = 0; - } -} - -Plugins::PluginManager::PluginManager( QObject *parent ) - : QObject( parent ) -{ - DEBUG_BLOCK - setObjectName( "PluginManager" ); - s_instance = this; - - PERF_LOG( "Initialising Plugin Manager" ) - init(); - PERF_LOG( "Initialised Plugin Manager" ) -} - -Plugins::PluginManager::~PluginManager() -{ - // tell the managers to get rid of their current factories - QList emptyFactories; - - StatSyncing::Controller *controller = Amarok::Components::statSyncingController(); - if( controller ) - controller->setFactories( emptyFactories ); - ServicePluginManager::instance()->setFactories( emptyFactories ); - CollectionManager::instance()->setFactories( emptyFactories ); - StorageManager::instance()->setFactories( emptyFactories ); -} - -void -Plugins::PluginManager::init() -{ - checkPluginEnabledStates(); -} - -KPluginInfo::List -Plugins::PluginManager::plugins( Type type ) const -{ - return m_pluginInfosByType.value( type ); -} - -QList -Plugins::PluginManager::factories( Type type ) const -{ - return m_factoriesByType.value( type ); -} - -void -Plugins::PluginManager::checkPluginEnabledStates() -{ - // re-create all the member infos. - m_pluginInfos.clear(); - m_pluginInfosByType.clear(); - m_factoriesByType.clear(); - - m_pluginInfos = findPlugins(); // reload all the plugins plus their enabled state - if( m_pluginInfos.isEmpty() ) // try it a second time with syscoca - handleNoPluginsFound(); - - QList allFactories; - - // sort the plugin infos by type - foreach( const KPluginInfo &pluginInfo, m_pluginInfos ) - { - Type type; - if( pluginInfo.category() == QLatin1String("Storage") ) - type = Storage; - else if( pluginInfo.category() == QLatin1String("Collection") ) - type = Collection; - else if( pluginInfo.category() == QLatin1String("Service") ) - type = Service; - else if( pluginInfo.category() == QLatin1String("Importer") ) - type = Importer; - else { - warning() << pluginInfo.pluginName() << " has unknown category"; - continue; - } - m_pluginInfosByType[ type ] << pluginInfo; - - // create the factories and sort them by type - PluginFactory *factory = createFactory( pluginInfo ); - if( factory ) - { - m_factoriesByType[ type ] << factory; - allFactories << factory; - } - } - - // the setFactories functions should: - // - filter out factories not usefull (e.g. services when setting collections) - // - handle the new list of factories, disabling old ones and enabling new ones. - - PERF_LOG( "Loading storage plugins" ) - StorageManager::instance()->setFactories( m_factoriesByType.value( Storage ) ); - PERF_LOG( "Loaded storage plugins" ) - - PERF_LOG( "Loading collection plugins" ) - CollectionManager::instance()->setFactories( m_factoriesByType.value( Collection ) ); - PERF_LOG( "Loaded collection plugins" ) - - PERF_LOG( "Loading service plugins" ) - ServicePluginManager::instance()->setFactories( m_factoriesByType.value( Service ) ); - PERF_LOG( "Loaded service plugins" ) - - PERF_LOG( "Loading importer plugins" ) - StatSyncing::Controller *controller = Amarok::Components::statSyncingController(); - if( controller ) - controller->setFactories( m_factoriesByType.value( Importer ) ); - PERF_LOG( "Loaded importer plugins" ) - - // init all new factories - // do this after they were added to the sub-manager so that they - // have a chance to connect to signals - // - // we need to init by type and the storages need to go first - foreach( PluginFactory* factory, m_factoriesByType[ Storage ] ) - factory->init(); - foreach( PluginFactory* factory, m_factoriesByType[ Collection ] ) - factory->init(); - foreach( PluginFactory* factory, m_factoriesByType[ Service ] ) - factory->init(); - foreach( PluginFactory* factory, m_factoriesByType[ Importer ] ) - factory->init(); -} - - -bool -Plugins::PluginManager::isPluginEnabled( const KPluginInfo &pluginInfo ) const -{ - // mysql storage and collection are vital. They need to be loaded always - if( pluginInfo.property("X-KDE-Amarok-vital").toBool() ) - { - return true; - } - else - { - const QString pluginName = pluginInfo.pluginName(); - const bool enabledByDefault = pluginInfo.isPluginEnabledByDefault(); - return Amarok::config( "Plugins" ).readEntry( pluginName + "Enabled", enabledByDefault ); - } -} - - -Plugins::PluginFactory* -Plugins::PluginManager::createFactory( const KPluginInfo &pluginInfo ) -{ - if( !isPluginEnabled( pluginInfo ) ) - return 0; - - // check if we already created this factory - // note: old factories are not deleted. - // We can't very well just destroy a factory being - // currently used. - const QString name = pluginInfo.pluginName(); - if( m_factoryCreated.contains(name) ) - return m_factoryCreated.value(name); - - - KService::Ptr service = pluginInfo.service(); - KPluginLoader loader( *( service.constData() ) ); - KPluginFactory *pluginFactory( loader.factory() ); - - if( !pluginFactory ) - { - warning() << QString( "Failed to get factory '%1' from KPluginLoader: %2" ) - .arg( name, loader.errorString() ); - return 0; - } - - // create the factory with this object as owner - PluginFactory *factory = 0; - if( !(factory = pluginFactory->create( this )) ) - { - warning() << "Failed to create plugin" << name << loader.errorString(); - return 0; - } - - m_factoryCreated[ pluginInfo.pluginName() ] = factory; - return factory; -} - - -KPluginInfo::List -Plugins::PluginManager::findPlugins() -{ - QString query = QString::fromLatin1( "[X-KDE-Amarok-framework-version] == %1" - " and [X-KDE-Amarok-rank] > 0" ) - .arg( s_pluginFrameworkVersion ); - - KConfigGroup pluginsConfig = Amarok::config(QLatin1String("Plugins")); - KService::List services = KServiceTypeTrader::self()->query( "Amarok/Plugin", query ); - KPluginInfo::List plugins = KPluginInfo::fromServices( services, pluginsConfig ); - - // load the plugins - foreach( KPluginInfo info, plugins ) - { - info.load( pluginsConfig ); // load the enabled state of plugin - debug() << "found plugin:" << info.pluginName() - << "enabled:" << info.isPluginEnabled(); - } - debug() << plugins.count() << "plugins in total"; - - return plugins; -} - -void -Plugins::PluginManager::handleNoPluginsFound() -{ - DEBUG_BLOCK - - debug() << "No Amarok plugins found, running kbuildsycoca4."; - - // Run kbuildsycoca4 in a blocking fashion - KProcess::execute( KStandardDirs::findExe( "kbuildsycoca4" ), QStringList( "--noincremental" ) ); - - // Wait a bit (3 sec) until ksycoca has fully updated - for( int i = 0; i < 30; i++ ) { - QThread::currentThread()->wait( 100 ); - QApplication::processEvents(); - } - - debug() << "Second attempt at finding plugins"; - - m_pluginInfos = findPlugins(); - if( m_pluginInfos.isEmpty() ) - { - if( QApplication::type() != QApplication::Tty ) - { - KMessageBox::error( 0, i18n( "Amarok could not find any plugins. This indicates an installation problem." ) ); - } - else - { - warning() << "Amarok could not find any plugins. Bailing out."; - } - // don't use QApplication::exit, as the eventloop may not have started yet - std::exit( EXIT_SUCCESS ); - } -} - -int -Plugins::PluginManager::pluginFrameworkVersion() -{ - return s_pluginFrameworkVersion; -} - -#include "moc_PluginManager.cpp" diff --git a/amarok/src/PluginManager.h b/amarok/src/PluginManager.h deleted file mode 100644 index 8ec84dcb..00000000 --- a/amarok/src/PluginManager.h +++ /dev/null @@ -1,126 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2004-2013 Mark Kretschmann * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_PLUGINMANAGER_H -#define AMAROK_PLUGINMANAGER_H - -#include "amarok_export.h" -#include "core/support/PluginFactory.h" - -class ServicePluginManager; - -namespace Plugins { - -class AMAROK_EXPORT PluginManager : public QObject -{ - Q_OBJECT - Q_ENUMS( Type ) - Q_PROPERTY( int pluginFrameworkVersion READ pluginFrameworkVersion ) - - public: - /** Type of the plugin. - * - * Will be determined by the KPluginInfo::category - */ - enum Type - { - Collection = 1, ///< the plugin implements a CollectionFactory - Service = 2, ///< this is a service plugin - Importer = 3, ///< this plugin implements importer functionity - Storage = 4 ///< the plugin implements a StorageFactory - }; - - ~PluginManager(); - - static PluginManager *instance(); - - /** Destroys the instance of the PluginManager. - * - * The order of the destruction is somewhat important. - * The PluginManager needs to be destroyed after all collections - * have been removed and before the CollectionManager, - * the ServicePluginManager and the StatSyncing::Controller are destroyed. - */ - static void destroy(); - static int pluginFrameworkVersion(); - - /** - * Load any services that are configured to be loaded - */ - void init(); - - /** Returns plugin factories for the given plugin type */ - KPluginInfo::List plugins( Type type ) const; - - /** Returns enabled plugin factories for the given plugin type. - * - * This function will only return enable factories. - * - * Owner of the PluginFactory pointers is the PluginManager - * and the pointers will only be valid while the PluginManager exists. - */ - QList factories( Type type ) const; - - /** Check if any services were disabled and needs to be removed, or any - * that are hidden needs to be enabled - * - * This function will call the sub plugin managers (like CollectionManager) - * setFactories function. - */ - void checkPluginEnabledStates(); - - private: - /** Tries finding Amarok plugins */ - KPluginInfo::List findPlugins(); - - /** Does additional effort to find plugins. - * - * Starts kbuildsycoca4 thingie - * Stops Amarok if it still can't find plugins - */ - void handleNoPluginsFound(); - - /** Returns true if the plugin is enabled. - * This function will theck the default enabled state, - * the Amarok configuration state and the primary collection. - * - * @returns true if the plugin is enabled. - */ - bool isPluginEnabled( const KPluginInfo &factory ) const; - - /** Creates a factories for an info */ - PluginFactory* createFactory( const KPluginInfo &plugin ); - - /// contains the names of all KPluginInfos that have factories created - QHash m_factoryCreated; - QHash > m_factoriesByType; - KPluginInfo::List m_pluginInfos; - QHash m_pluginInfosByType; - - static const int s_pluginFrameworkVersion; - static PluginManager *s_instance; - - PluginManager( QObject *parent = 0 ); -}; - -} // namespace Plugins - -namespace The -{ - inline Plugins::PluginManager *pluginManager() { return Plugins::PluginManager::instance(); } -} - -#endif /* AMAROK_PLUGINMANAGER_H */ diff --git a/amarok/src/PopupDropperFactory.cpp b/amarok/src/PopupDropperFactory.cpp deleted file mode 100644 index 39decea2..00000000 --- a/amarok/src/PopupDropperFactory.cpp +++ /dev/null @@ -1,138 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "PopupDropperFactory.h" - -#include "MainWindow.h" -#include "PaletteHandler.h" -#include "SvgHandler.h" -#include "core/support/Debug.h" -#include "context/popupdropper/libpud/PopupDropperItem.h" -#include "context/ContextView.h" - -#include - -#include - - -namespace The -{ - static PopupDropperFactory* s_PopupDropperFactory_instance = 0; - - PopupDropperFactory* popupDropperFactory() - { - if( !s_PopupDropperFactory_instance ) - s_PopupDropperFactory_instance = new PopupDropperFactory( The::mainWindow() ); - - return s_PopupDropperFactory_instance; - } -} - - -PopupDropperFactory::PopupDropperFactory( QObject* parent ) - : QObject( parent ) -{} - - -PopupDropperFactory::~PopupDropperFactory() -{ - DEBUG_BLOCK -} - - -PopupDropper * PopupDropperFactory::createPopupDropper( QWidget * parent, bool ignoreEmptyParent ) -{ - DEBUG_BLOCK - - // Lazy loading of widgets not currently shown in layout means that parent could be zero - // if this happens, it pops up in its own window -- so detect this - // ignoreEmptyParent is for creating submenus, where you set the initial parent to zero - if( !parent && !ignoreEmptyParent ) - return 0; - - PopupDropper* pd = new PopupDropper( parent ); - if( !pd ) - return 0; - - pd->setSvgRenderer( The::svgHandler()->getRenderer( "amarok/images/pud_items.svg" ) ); - pd->setQuitOnDragLeave( false ); - pd->setFadeInTime( 500 ); - pd->setFadeOutTime( 300 ); - //QColor origWindowColor( The::paletteHandler()->palette().color( QPalette::Window ) ); - //QColor windowColor; - //windowColor.setRed( 255 - origWindowColor.red() ); - //windowColor.setBlue( 255 - origWindowColor.blue() ); - //windowColor.setGreen( 255 - origWindowColor.green() ); - QColor windowColor( The::paletteHandler()->palette().color( QPalette::Base ) ); - windowColor.setAlpha( 176 ); - QColor textColor( The::paletteHandler()->palette().color( QPalette::Link ) ); - QColor highlightedTextColor( The::paletteHandler()->palette().color( QPalette::LinkVisited ) ); - QColor borderColor( The::paletteHandler()->palette().color( QPalette::Text ) ); - QColor fillColor( borderColor ); - fillColor.setAlpha( 48 ); - pd->setColors( windowColor, textColor, highlightedTextColor, borderColor, fillColor ); - - return pd; -} - -PopupDropper * PopupDropperFactory::createPopupDropper() -{ - return createPopupDropper( Context::ContextView::self() ); -} - -PopupDropperItem * PopupDropperFactory::createItem( QAction * action ) -{ - PopupDropperItem* pdi = new PopupDropperItem(); - pdi->setAction( action ); - QString text = pdi->text(); - text.remove( QChar('&') ); - pdi->setText( text ); - adjustItem( pdi ); - return pdi; -} - -void PopupDropperFactory::adjustItem( PopupDropperItem *item ) -{ - if( !item ) - return; - QFont font; - font.setPointSize( 16 ); - font.setBold( true ); - item->setFont( font ); - item->setHoverMsecs( 800 ); - QColor hoverIndicatorFillColor( The::paletteHandler()->palette().color( QPalette::Highlight ) ); - hoverIndicatorFillColor.setAlpha( 96 ); - QBrush brush = item->hoverIndicatorFillBrush(); - brush.setColor( hoverIndicatorFillColor ); - item->setHoverIndicatorFillBrush( brush ); - - if( item->isSubmenuTrigger() ) - item->setHoverIndicatorShowStyle( PopupDropperItem::OnHover ); - -} - -void PopupDropperFactory::adjustItems( PopupDropper* pud ) -{ - if( !pud ) - return; - pud->forEachItem( adjustItemCallback ); -} - -void PopupDropperFactory::adjustItemCallback( void *pdi ) -{ - The::popupDropperFactory()->adjustItem( (PopupDropperItem*)pdi ); -} - diff --git a/amarok/src/PopupDropperFactory.h b/amarok/src/PopupDropperFactory.h deleted file mode 100644 index d3efd2e4..00000000 --- a/amarok/src/PopupDropperFactory.h +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef POPUPDROPPERFACTORY_H -#define POPUPDROPPERFACTORY_H - -#include "amarok_export.h" -#include "context/popupdropper/libpud/PopupDropper.h" - -/** -A central place for creating a Pud that matches system colors - - @author Nikolaj Hald Nielsen -*/ -class PopupDropperFactory; - -namespace The { - AMAROK_EXPORT PopupDropperFactory* popupDropperFactory(); -} - -class AMAROK_EXPORT PopupDropperFactory : public QObject -{ - Q_OBJECT - - friend PopupDropperFactory* The::popupDropperFactory(); - - public: - /** - * Create a new PopupDropper with correct system colors. This function creates it on top of the context viev - * @return The newly created PopupDropper - */ - PopupDropper * createPopupDropper(); - - /** - * Overloaded function for creating a new PopupDropper with a custom parent - * @param parent The widget to act as the parent - * @param ignoreEmptyParent Whether to ignore if the parent is null - use this when creating submenus where the parent is 0 - * @return The newly created PopupDropper - */ - PopupDropper * createPopupDropper( QWidget * parent, bool ignoreEmptyParent = false ); - - PopupDropperItem* createItem( QAction * action ); - void adjustItems( PopupDropper *pud ); - void adjustItem( PopupDropperItem *item ); - static void adjustItemCallback( void *pdi ); - - private: - PopupDropperFactory( QObject* parent ); - ~PopupDropperFactory(); - }; - - -#endif diff --git a/amarok/src/QStringx.cpp b/amarok/src/QStringx.cpp deleted file mode 100644 index 92592e2b..00000000 --- a/amarok/src/QStringx.cpp +++ /dev/null @@ -1,361 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2004 Shintaro Matsuoka * - * Copyright (c) 2006 Martin Aumueller * - * Copyright (c) 2011 Sergey Ivanov <123kash@gmail.com> * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "QStringx.h" - -Amarok::QStringx::QStringx() -{ -} - -Amarok::QStringx::QStringx( QChar ch ) - : QString( ch ) -{ -} - -Amarok::QStringx::QStringx( const QString &s ) - : QString( s ) -{ -} - -Amarok::QStringx::QStringx( const QByteArray &ba ) - : QString( ba ) -{ -} - -Amarok::QStringx::QStringx( const QChar *unicode, uint length ) - : QString( unicode, length ) -{ -} - -Amarok::QStringx::QStringx( const char *str ) - : QString( str ) -{ -} - -Amarok::QStringx::~QStringx() -{ -} - -QString -Amarok::QStringx::args( const QStringList &args ) const -{ - const QStringList text = (*this).split( QRegExp( "%\\d+" ), QString::KeepEmptyParts ); - - QList::ConstIterator itrText = text.constBegin(); - QList::ConstIterator itrArgs = args.constBegin(); - QList::ConstIterator endText = text.constEnd(); - QList::ConstIterator endArgs = args.constEnd(); - QString merged = (*itrText); - ++itrText; - while( itrText != endText && itrArgs != endArgs ) - { - merged += (*itrArgs) + (*itrText); - ++itrText; - ++itrArgs; - } - - Q_ASSERT( itrText == text.end() || itrArgs == args.end() ); - - return merged; -} - -QString -Amarok::QStringx::namedArgs( const QMap &args, bool opt ) const -{ - // Screen all kindes of brackets and format string with namedOptArgs. - QString formatString = *this; - formatString.replace( QRegExp( "([\\[\\]{}])" ),"\\\\1" ); - - // Legacy code returned empty string if any token was empty, so do the same - if( opt ) - formatString = QLatin1Char( '{' ) + formatString + QLatin1Char( '}' ); - - QStringx fmtx( formatString ); - return fmtx.namedOptArgs( args ); -} - -QString -Amarok::QStringx::namedOptArgs( const QMap &args ) const -{ - int pos = 0; - return parse( &pos, args ); -} - -Amarok::QStringx::CharType -Amarok::QStringx::testChar( int *pos ) const -{ - if( *pos >= length() ) - return CTNone; - - QChar c = this->at( *pos ); - - if( c == QLatin1Char( '\\' ) ) - { - ( *pos )++; - return ( *pos >= length() ) ? CTNone : CTRegular; - } - - if( c == QLatin1Char( '{' ) ) - return CTBraceOpen; - - if( c == QLatin1Char( '}' ) ) - return CTBraceClose; - - if( c == QLatin1Char( '[' ) ) - return CTBracketOpen; - - if( c == QLatin1Char( ':' ) ) - return CTBracketSeparator; - - if( c == QLatin1Char( ']' ) ) - return CTBracketClose; - - if( c == QLatin1Char( '%' ) ) - return CTToken; - - return CTRegular; -} - -QString -Amarok::QStringx::parseToken( int *pos, const QMap &dict ) const -{ - if( testChar( pos ) != CTToken ) - return QString(); - - ( *pos )++; - - CharType ct = testChar( pos ); - QString key; - - while( ct == CTRegular ) - { - key += this->at( *pos ); - ( *pos )++; - ct = testChar( pos ); - } - - if( ct == CTToken ) - { - ( *pos )++; - return dict.value( key ); - } - - *pos -= key.length(); - - return QLatin1String( "%" ); -} - -QString -Amarok::QStringx::parseBraces( int *pos, const QMap &dict ) const -{ - if( testChar( pos ) != CTBraceOpen ) - return QString(); - - ( *pos )++; - - int retPos = *pos; - QString result; - bool isPritable = true; - CharType ct = testChar( pos ); - - while( ct != CTNone && ct != CTBraceClose ) - { - switch( ct ) - { - case CTBraceOpen: - { - result += parseBraces( pos, dict ); - break; - } - case CTBracketOpen: - { - result += parseBrackets( pos, dict ); - break; - } - case CTToken: - { - QString part = parseToken( pos, dict ); - if( part.isEmpty() ) - isPritable = false; - - result += part; - break; - } - - default: - { - result += this->at( *pos ); - ( *pos )++; - } - } - - ct = testChar( pos ); - } - - if( ct == CTBraceClose ) - { - ( *pos )++; - if( isPritable ) - return result; - - return QString(); - } - - *pos = retPos; - return QLatin1String( "{" ); -} - -QString -Amarok::QStringx::parseBrackets( int *pos, const QMap &dict ) const -{ - if( testChar( pos ) != CTBracketOpen ) - return QString(); - - ( *pos )++; - - // Check if next char is % - if( testChar( pos ) != CTToken ) - return QLatin1String( "[" ); - - int retPos = *pos; - - ( *pos )++; - - // Parse token manuly (not by calling parseToken), because we need token name. - CharType ct = testChar( pos ); - QString key; - - while( ct == CTRegular ) - { - key += this->at( *pos ); - ( *pos )++; - ct = testChar( pos ); - } - - if( ct != CTToken || key.isEmpty() ) - { - *pos = retPos; - return QLatin1String( "[" ); - } - - ( *pos )++; - - QString replacement; - - // Parse replacement string if we have one - if( testChar( pos ) == CTBracketSeparator ) - { - ( *pos )++; - - ct = testChar( pos ); - - while( ct != CTNone && ct != CTBracketClose ) - { - switch( ct ) - { - case CTBraceOpen: - { - replacement += parseBraces( pos, dict ); - break; - } - case CTBracketOpen: - { - replacement += parseBrackets( pos, dict ); - break; - } - case CTToken: - { - replacement += parseToken( pos, dict );; - break; - } - - default: - { - replacement += this->at( *pos ); - ( *pos )++; - } - } - - ct = testChar( pos ); - } - - if( ct == CTNone ) - { - *pos = retPos; - return QLatin1String( "[" ); - } - } - - if( testChar( pos ) == CTBracketClose ) - { - ( *pos )++; - - if( !dict.value( key ).isEmpty() ) - return dict.value( key ); - - if( !replacement.isEmpty() ) - return replacement; - - if( !dict.value( QLatin1String( "default_" ) + key ).isEmpty() ) - return dict.value( QLatin1String( "default_" ) + key ); - - return QLatin1String( "Unknown " ) + key; - } - - *pos = retPos; - return QLatin1String( "[" ); -} - -QString -Amarok::QStringx::parse( int *pos, const QMap &dict ) const -{ - CharType ct = testChar( pos ); - QString result; - - while( ct != CTNone ) - { - switch( ct ) - { - case CTBraceOpen: - { - result += parseBraces( pos, dict ); - break; - } - case CTBracketOpen: - { - result += parseBrackets( pos, dict ); - break; - } - case CTToken: - { - result += parseToken( pos, dict ); - break; - } - - default: - { - result += this->at( *pos ); - ( *pos )++; - } - } - - ct = testChar( pos ); - } - - return result; -} diff --git a/amarok/src/QStringx.h b/amarok/src/QStringx.h deleted file mode 100644 index c60e95cd..00000000 --- a/amarok/src/QStringx.h +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2004 Shintaro Matsuoka * - * Copyright (c) 2006 Martin Aumueller * - * Copyright (c) 2011 Sergey Ivanov <123kash@gmail.com> * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_QSTRINGX_H -#define AMAROK_QSTRINGX_H - -#include -#include -#include -#include -#include - -namespace Amarok -{ - -class QStringx : public QString -{ -public: - QStringx(); - QStringx( QChar ch ); - QStringx( const QString &s ); - QStringx( const QByteArray &ba ); - QStringx( const QChar *unicode, uint length ); - QStringx( const char *str ); - virtual ~QStringx(); - - // the numbers following % obviously are not taken into account - QString args( const QStringList& args ) const; - - // %something% gets replaced by the value corresponding to key "something" in args - // if opt is true: return empty string if it has empty tokens - QString namedArgs( const QMap &args, bool opt = false ) const; - - // %something% gets replaced by the value corresponding to key "something" in args, - // however, if key "something" is not available, - // then replace everything within surrounding { } by an empty string - QString namedOptArgs( const QMap &args ) const; - -private: - enum CharType - { - CTRegular, - CTToken, - CTBraceOpen, - CTBraceClose, - CTBracketOpen, - CTBracketSeparator, - CTBracketClose, - CTNone - }; - - CharType testChar( int *pos ) const; - QString parseToken( int *pos, const QMap &dict ) const; - QString parseBraces( int *pos, const QMap &dict ) const; - QString parseBrackets( int *pos, const QMap &dict ) const; - QString parse( int *pos, const QMap &dict ) const; -}; - -} // namespace Amarok - -#endif // AMAROK_QSTRINGX_H diff --git a/amarok/src/SvgHandler.cpp b/amarok/src/SvgHandler.cpp deleted file mode 100644 index b528f999..00000000 --- a/amarok/src/SvgHandler.cpp +++ /dev/null @@ -1,474 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Nikolaj Hald Nielsen * - * Copyright (c) 2008 Jeff Mitchell * - * Copyright (c) 2009-2013 Mark Kretschmann * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "SvgHandler" - -#include "SvgHandler.h" - -#include "App.h" -#include "EngineController.h" -#include "MainWindow.h" -#include "PaletteHandler.h" -#include "SvgTinter.h" -#include "core/meta/Meta.h" -#include "core/support/Debug.h" -#include "covermanager/CoverCache.h" -#include "moodbar/MoodbarManager.h" - -#include -#include -#include - -#include -#include -#include - -#include -#include - - -namespace The { - static SvgHandler* s_SvgHandler_instance = 0; - - SvgHandler* svgHandler() - { - if( !s_SvgHandler_instance ) - s_SvgHandler_instance = new SvgHandler(); - - return s_SvgHandler_instance; - } -} - -SvgHandler::SvgHandler( QObject* parent ) - : QObject( parent ) - , m_cache( new KImageCache( "Amarok-pixmaps", 20 * 1024 ) ) - , m_themeFile( "amarok/images/default-theme-clean.svg" ) // //use default theme - , m_customTheme( false ) -{ - DEBUG_BLOCK - connect( The::paletteHandler(), SIGNAL(newPalette(QPalette)), this, SLOT(discardCache()) ); -} - -SvgHandler::~SvgHandler() -{ - DEBUG_BLOCK - delete m_cache; - qDeleteAll( m_renderers ); - m_renderers.clear(); - - The::s_SvgHandler_instance = 0; -} - - -bool SvgHandler::loadSvg( const QString& name ) -{ - const QString &svgFilename = !m_customTheme ? KStandardDirs::locate( "data", name ) : name; - QSvgRenderer *renderer = new QSvgRenderer( The::svgTinter()->tint( svgFilename ) ); - - if ( !renderer->isValid() ) - { - debug() << "Bluddy 'ell mateys, aye canna' load ya Ess Vee Gee at " << svgFilename; - delete renderer; - return false; - } - QWriteLocker writeLocker( &m_lock ); - - if( m_renderers[name] ) - delete m_renderers[name]; - - m_renderers[name] = renderer; - return true; -} - -QSvgRenderer* SvgHandler::getRenderer( const QString& name ) -{ - QReadLocker readLocker( &m_lock ); - if( ! m_renderers[name] ) - { - readLocker.unlock(); - if( !loadSvg( name ) ) - { - QWriteLocker writeLocker( &m_lock ); - m_renderers[name] = new QSvgRenderer(); - } - readLocker.relock(); - } - return m_renderers[name]; -} - -QSvgRenderer * SvgHandler::getRenderer() -{ - return getRenderer( m_themeFile ); -} - -QPixmap SvgHandler::renderSvg( const QString &name, - const QString& keyname, - int width, - int height, - const QString& element, - bool skipCache, - const qreal opacity ) -{ - QString key; - if( !skipCache ) - { - key = QString("%1:%2x%3") - .arg( keyname ) - .arg( width ) - .arg( height ); - } - - QPixmap pixmap; - if( skipCache || !m_cache->findPixmap( key, &pixmap ) ) - { - pixmap = QPixmap( width, height ); - pixmap.fill( Qt::transparent ); - - QReadLocker readLocker( &m_lock ); - if( ! m_renderers[name] ) - { - readLocker.unlock(); - if( !loadSvg( name ) ) - { - return pixmap; - } - readLocker.relock(); - } - - QPainter pt( &pixmap ); - pt.setOpacity( opacity ); - - if ( element.isEmpty() ) - m_renderers[name]->render( &pt, QRectF( 0, 0, width, height ) ); - else - m_renderers[name]->render( &pt, element, QRectF( 0, 0, width, height ) ); - - if( !skipCache ) - m_cache->insertPixmap( key, pixmap ); - } - - return pixmap; -} - -QPixmap SvgHandler::renderSvg(const QString & keyname, int width, int height, const QString & element, bool skipCache, const qreal opacity ) -{ - return renderSvg( m_themeFile, keyname, width, height, element, skipCache, opacity ); -} - -QPixmap SvgHandler::renderSvgWithDividers(const QString & keyname, int width, int height, const QString & element) -{ - const QString key = QString("%1:%2x%3-div") - .arg( keyname ) - .arg( width ) - .arg( height ); - - QPixmap pixmap; - if ( !m_cache->findPixmap( key, &pixmap ) ) { -// debug() << QString("svg %1 not in cache...").arg( key ); - - pixmap = QPixmap( width, height ); - pixmap.fill( Qt::transparent ); - - QString name = m_themeFile; - - QReadLocker readLocker( &m_lock ); - if( ! m_renderers[name] ) - { - readLocker.unlock(); - if( ! loadSvg( name ) ) - { - return pixmap; - } - readLocker.relock(); - } - - QPainter pt( &pixmap ); - if ( element.isEmpty() ) - m_renderers[name]->render( &pt, QRectF( 0, 0, width, height ) ); - else - m_renderers[name]->render( &pt, element, QRectF( 0, 0, width, height ) ); - - - //add dividers. 5% spacing on each side - int margin = width / 20; - - m_renderers[name]->render( &pt, "divider_top", QRectF( margin, 0 , width - 1 * margin, 1 ) ); - m_renderers[name]->render( &pt, "divider_bottom", QRectF( margin, height - 1 , width - 2 * margin, 1 ) ); - - m_cache->insertPixmap( key, pixmap ); - } - - return pixmap; -} - - -void SvgHandler::reTint() -{ - The::svgTinter()->init(); - if ( !loadSvg( m_themeFile )) - warning() << "Unable to load theme file: " << m_themeFile; - emit retinted(); -} - -QString SvgHandler::themeFile() -{ - return m_themeFile; -} - -void SvgHandler::setThemeFile( const QString & themeFile ) -{ - DEBUG_BLOCK - debug() << "got new theme file: " << themeFile; - m_themeFile = themeFile; - m_customTheme = true; - discardCache(); -} - -void SvgHandler::discardCache() -{ - //redraw entire app.... - reTint(); - m_cache->clear(); - App::instance()->mainWindow()->update(); -} - -QPixmap -SvgHandler::imageWithBorder( Meta::AlbumPtr album, int size, int borderWidth ) -{ - const int imageSize = size - ( borderWidth * 2 ); - const QString &loc = album->imageLocation( imageSize ).url(); - const QString &key = !loc.isEmpty() ? loc : album->name(); - return addBordersToPixmap( The::coverCache()->getCover( album, imageSize ), borderWidth, key ); -} - -QPixmap SvgHandler::addBordersToPixmap( const QPixmap &orgPixmap, int borderWidth, const QString &name, bool skipCache ) -{ - int newWidth = orgPixmap.width() + borderWidth * 2; - int newHeight = orgPixmap.height() + borderWidth *2; - - QString key; - if( !skipCache ) - { - key = QString("%1:%2x%3b%4") - .arg( name ) - .arg( newWidth ) - .arg( newHeight ) - .arg( borderWidth ); - } - - QPixmap pixmap; - if( skipCache || !m_cache->findPixmap( key, &pixmap ) ) - { - // Cache miss! We need to create the pixmap - // if skipCache is true, we might actually already have fetched the image, including borders from the cache.... - // so we really need to create a blank pixmap here as well, to not pollute the cached pixmap - pixmap = QPixmap( newWidth, newHeight ); - pixmap.fill( Qt::transparent ); - - QReadLocker readLocker( &m_lock ); - if( !m_renderers[m_themeFile] ) - { - readLocker.unlock(); - if( !loadSvg( m_themeFile ) ) - { - return pixmap; - } - readLocker.relock(); - } - - QPainter pt( &pixmap ); - - pt.drawPixmap( borderWidth, borderWidth, orgPixmap.width(), orgPixmap.height(), orgPixmap ); - - m_renderers[m_themeFile]->render( &pt, "cover_border_topleft", QRectF( 0, 0, borderWidth, borderWidth ) ); - m_renderers[m_themeFile]->render( &pt, "cover_border_top", QRectF( borderWidth, 0, orgPixmap.width(), borderWidth ) ); - m_renderers[m_themeFile]->render( &pt, "cover_border_topright", QRectF( newWidth - borderWidth , 0, borderWidth, borderWidth ) ); - m_renderers[m_themeFile]->render( &pt, "cover_border_right", QRectF( newWidth - borderWidth, borderWidth, borderWidth, orgPixmap.height() ) ); - m_renderers[m_themeFile]->render( &pt, "cover_border_bottomright", QRectF( newWidth - borderWidth, newHeight - borderWidth, borderWidth, borderWidth ) ); - m_renderers[m_themeFile]->render( &pt, "cover_border_bottom", QRectF( borderWidth, newHeight - borderWidth, orgPixmap.width(), borderWidth ) ); - m_renderers[m_themeFile]->render( &pt, "cover_border_bottomleft", QRectF( 0, newHeight - borderWidth, borderWidth, borderWidth ) ); - m_renderers[m_themeFile]->render( &pt, "cover_border_left", QRectF( 0, borderWidth, borderWidth, orgPixmap.height() ) ); - - if( !skipCache ) - m_cache->insertPixmap( key, pixmap ); - } - - return pixmap; -} - -#if 0 -void SvgHandler::paintCustomSlider( QPainter *p, int x, int y, int width, int height, qreal percentage, bool active ) -{ - int knobSize = height - 4; - int sliderRange = width - ( knobSize + 4 ); - int knobRelPos = x + sliderRange * percentage + 2; - int knobY = y + ( height - knobSize ) / 2 + 1; - - int sliderY = y + ( height / 2 ) - 1; - - - //first draw the played part - p->drawPixmap( x, sliderY, - renderSvg( - "new_slider_top_played", - width, 2, - "new_slider_top_played" ), - 0, 0, knobRelPos - x, 2 ); - - //and then the unplayed part - p->drawPixmap( knobRelPos + 1, sliderY, - renderSvg( - "new_slider_top", - width, 2, - "new_slider_top" ), - knobRelPos + 1 - x, 0, -1, 2 ); - - //and then the bottom - p->drawPixmap( x, sliderY + 2, - renderSvg( - "new_slider_bottom", - width, 2, - "new_slider_bottom" ) ); - - //draw end markers - p->drawPixmap( x, y, - renderSvg( - "new_slider_end", - 2, height, - "new_slider_end" ) ); - - p->drawPixmap( x + width - 2, y, - renderSvg( - "new_slider_end", - 2, height, - "new_slider_endr" ) ); - - - if ( active ) - p->drawPixmap( knobRelPos, knobY, - renderSvg( - "new_slider_knob_active", - knobSize, knobSize, - "new_slider_knob_active" ) ); - else - p->drawPixmap( knobRelPos, knobY, - renderSvg( - "new_slider_knob", - knobSize, knobSize, - "new_slider_knob" ) ); -} -#endif - -QRect SvgHandler::sliderKnobRect( const QRect &slider, qreal percent, bool inverse ) const -{ - if ( inverse ) - percent = 1.0 - percent; - const int knobSize = slider.height() - 4; - QRect ret( 0, 0, knobSize, knobSize ); - ret.moveTo( slider.x() + qRound( ( slider.width() - knobSize ) * percent ), slider.y() + 1 ); - return ret; -} - -// Experimental, using a mockup from Nuno Pinheiro (new_slider_nuno) -void SvgHandler::paintCustomSlider( QPainter *p, QStyleOptionSlider *slider, qreal percentage, bool paintMoodbar ) -{ - int sliderHeight = slider->rect.height() - 6; - const bool inverse = ( slider->orientation == Qt::Vertical ) ? slider->upsideDown : - ( (slider->direction == Qt::RightToLeft) != slider->upsideDown ); - QRect knob = sliderKnobRect( slider->rect, percentage, inverse ); - QPoint pt = slider->rect.topLeft() + QPoint( 0, 2 ); - - //debug() << "rel: " << knobRelPos << ", width: " << width << ", height:" << height << ", %: " << percentage; - - //if we should paint moodbar, paint this as the bottom layer - bool moodbarPainted = false; - if ( paintMoodbar ) - { - Meta::TrackPtr currentTrack = The::engineController()->currentTrack(); - if ( currentTrack ) - { - if( The::moodbarManager()->hasMoodbar( currentTrack ) ) - { - QPixmap moodbar = The::moodbarManager()->getMoodbar( currentTrack, slider->rect.width() - sliderHeight, sliderHeight, inverse ); - p->drawPixmap( pt, renderSvg( "moodbar_end_left", sliderHeight / 2, sliderHeight, "moodbar_end_left" ) ); - - pt.rx() += sliderHeight / 2; - p->drawPixmap( pt, moodbar ); - - pt.rx() += slider->rect.width() - sliderHeight; - p->drawPixmap( pt, renderSvg( "moodbar_end_right", sliderHeight / 2, sliderHeight, "moodbar_end_right" ) ); - - moodbarPainted = true; - } - } - } - - if( !moodbarPainted ) - { - // Draw the slider background in 3 parts - - p->drawPixmap( pt, renderSvg( "progress_slider_left", sliderHeight, sliderHeight, "progress_slider_left" ) ); - - pt.rx() += sliderHeight; - QRect midRect(pt, QSize(slider->rect.width() - sliderHeight * 2, sliderHeight) ); - p->drawTiledPixmap( midRect, renderSvg( "progress_slider_mid", 32, sliderHeight, "progress_slider_mid" ) ); - - pt = midRect.topRight() + QPoint( 1, 0 ); - p->drawPixmap( pt, renderSvg( "progress_slider_right", sliderHeight, sliderHeight, "progress_slider_right" ) ); - - //draw the played background. - - int playedBarHeight = sliderHeight - 6; - - int sizeOfLeftPlayed = qBound( 0, inverse ? slider->rect.right() - knob.right() + 2 : - knob.x() - 2, playedBarHeight ); - - if( sizeOfLeftPlayed > 0 ) - { - QPoint tl, br; - if ( inverse ) - { - tl = knob.topRight() + QPoint( -5, 5 ); // 5px x padding to avoid a "gap" between it and the top and bottom of the round knob. - br = slider->rect.topRight() + QPoint( -3, 5 + playedBarHeight - 1 ); - QPixmap rightEnd = renderSvg( "progress_slider_played_right", playedBarHeight, playedBarHeight, "progress_slider_played_right" ); - p->drawPixmap( br.x() - rightEnd.width() + 1, tl.y(), rightEnd, qMax(0, rightEnd.width() - (sizeOfLeftPlayed + 3)), 0, sizeOfLeftPlayed + 3, playedBarHeight ); - br.rx() -= playedBarHeight; - } - else - { - tl = slider->rect.topLeft() + QPoint( 3, 5 ); - br = QPoint( knob.x() + 5, tl.y() + playedBarHeight - 1 ); - QPixmap leftEnd = renderSvg( "progress_slider_played_left", playedBarHeight, playedBarHeight, "progress_slider_played_left" ); - p->drawPixmap( tl.x(), tl.y(), leftEnd, 0, 0, sizeOfLeftPlayed + 3, playedBarHeight ); - tl.rx() += playedBarHeight; - } - if ( sizeOfLeftPlayed == playedBarHeight ) - p->drawTiledPixmap( QRect(tl, br), renderSvg( "progress_slider_played_mid", 32, playedBarHeight, "progress_slider_played_mid" ) ); - - } - } - - if ( slider->state & QStyle::State_Enabled ) - { // Draw the knob (handle) - const char *string = ( slider->activeSubControls & QStyle::SC_SliderHandle ) ? - "slider_knob_200911_active" : "slider_knob_200911"; - p->drawPixmap( knob.topLeft(), renderSvg( string, knob.width(), knob.height(), string ) ); - } -} - -#include "moc_SvgHandler.cpp" diff --git a/amarok/src/SvgHandler.h b/amarok/src/SvgHandler.h deleted file mode 100644 index e0679d6e..00000000 --- a/amarok/src/SvgHandler.h +++ /dev/null @@ -1,167 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Nikolaj Hald Nielsen * - * Copyright (c) 2008 Jeff Mitchell * - * Copyright (c) 2009-2013 Mark Kretschmann * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef SVGHANDLER_H -#define SVGHANDLER_H - -#include "amarok_export.h" -#include "core/meta/forward_declarations.h" - -#include -#include -#include - -#include -#include -#include - -class SvgHandler; -class QStyleOptionSlider; - -namespace The { - AMAROK_EXPORT SvgHandler* svgHandler(); -} - -/** -A class to abstract out some common operations of users of tinted svgs -*/ -class AMAROK_EXPORT SvgHandler : public QObject -{ - Q_OBJECT - - friend SvgHandler* The::svgHandler(); - - public: - ~SvgHandler(); - - QSvgRenderer* getRenderer( const QString &name ); - QSvgRenderer* getRenderer(); - QPixmap renderSvg( const QString &name, const QString& keyname, int width, int height, const QString& element = QString(), bool skipCache = false, const qreal opacity = 1.0 ); - - /** - * Overloaded function that uses the current theme - * @param keyname the name of the key to save in the cache - * @param width Width of the resulting pixmap - * @param height Height of the resulting pixmap - * @param element The theme element to render ( if none the entire svg is rendered ) - * @param skipCache If true, the pixmap will always get rendered and never fetched from the cache. - * @param opacity The opacity used for rendering. Range 0.0 to 1.0. - * @return The svg element/file rendered into a pixmap - */ - QPixmap renderSvg( const QString& keyname, int width, int height, const QString& element = QString(), bool skipCache = false, const qreal opacity = 1.0 ); - - /** - * Yet another overloaded function. This one renders the svg element and adds half a divider element to the top and the bottom - * so it looks sane when multiple elements with the same width are stacked. - * - * @param keyname the name of the key to save in the cache. - * @param width Width of the resulting pixmap. - * @param height Height of the resulting pixmap. - * @param element The theme element to render ( if none the entire svg is rendered ) - * @return The svg element/file rendered into a pixmap. - */ - QPixmap renderSvgWithDividers( const QString& keyname, int width, int height, const QString& element = QString() ); - - /** - * Take an album and extract the pixmap for sending to addBordersToPixmap. - * - * @param album The AlbumPtr - * @param size The size of the resulting image (border included) - * @borderWidth The desired width of the border - */ - QPixmap imageWithBorder( Meta::AlbumPtr album, int size = 1, int borderWidth = 5 ); - - /** - * Add nice borders to a pixmap. The function will create and return a new - * Pixmal that is the size of the old one plus twice the border width in - * each dimension. - * - * @param orgPixmap The original pixmap. - * @param borderWidth The pixel width of the borders to add to the pixmap. - * @param name A name for use as the basis of the cache key that for caching the completed image plus borders. - * @param skipCache If true, the pixmap will always get rendered and never fetched from the cache. - */ - QPixmap addBordersToPixmap( const QPixmap &orgPixmap, int borderWidth, const QString &name, bool skipCache =false ); - - /** - * Paint a custom slider using the specified painter. The slider consists - * of a background part, a "knob" that moves along it to show the current - * position, and 2 end markers to clearly mark the ends of the slider. - * The background part before the knob, is painted in a different color than the - * part after (and under) the knob. - * @param p The painter to use. - * @param x The x position to begin painting at. - * @param y The y position to begin painting at. - * @param width The width of the slider to paint. - * @param height The height of the slider. The background part does not scale in height, it will always be a relatively thin line, but the knob and end markers do. - * @param percentage The percentange of the slider that the knob is positioned at. - * @param active Specifies whether the slider should be painted "active" using the current palettes active colors, to specify that it currently has mouse focus or hover. - */ - void paintCustomSlider( QPainter *p, QStyleOptionSlider *slider, qreal percentage, bool paintMoodbar = false ); - - /** - * Calculate the visual slider knob rect from its value, use it instead the QStyle functions - * QStyle::sliderPositionFromValue() and QStyle::subControlRect(); - */ - QRect sliderKnobRect( const QRect &slider, qreal percent, bool inverse ) const; - - /** - * Get the path of the currently used svg theme file. - * - * @return the path of the currently used theme file. - */ - QString themeFile(); - - /** - * Change the currently used svg theme file. This function also - * clears the pixmap cache as all svg elements have potentially changed - * and should be re-rendered. - * - * @param themeFile The path of the new theme file to use. - */ - void setThemeFile( const QString & themeFile ); - - public slots: - void reTint(); - - signals: - void retinted(); - - private slots: - void discardCache(); - - private: - SvgHandler( QObject* parent = 0 ); - - bool loadSvg( const QString& name ); - - QPixmap sliderHandle( const QColor &color, bool pressed, int size ); - QColor calcLightColor(const QColor &color) const; - QColor calcDarkColor(const QColor &color) const; - bool lowThreshold(const QColor &color) const; - - KImageCache * m_cache; - - QHash m_renderers; - QReadWriteLock m_lock; - - QString m_themeFile; - bool m_customTheme; -}; - -#endif diff --git a/amarok/src/SvgTinter.cpp b/amarok/src/SvgTinter.cpp deleted file mode 100644 index 365f272c..00000000 --- a/amarok/src/SvgTinter.cpp +++ /dev/null @@ -1,138 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * Copyright (c) 2007 Mark Kretschmann * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "SvgTinter.h" - -#include "App.h" -#include "core/support/Debug.h" - -#include -#include - -SvgTinter * SvgTinter::s_instance = 0; - -SvgTinter::SvgTinter() - : m_firstRun( true ) -{ - init(); - m_firstRun = false; -} - - -SvgTinter::~SvgTinter() -{} - -QByteArray -SvgTinter::tint( const QString &filename) -{ - QFile file( filename ); - if ( !file.open( QIODevice::ReadOnly ) ) - { - error() << "Unable to open file: " << filename; - return QByteArray(); - } - - QByteArray svg_source( file.readAll() ); - - // Copied from KSvgrenderer.cpp as we don't load it directly. - if (!svg_source.startsWith("open(QIODevice::ReadOnly)) - { - delete flt; - return QByteArray(); - } - svg_source = flt->readAll(); - delete flt; - } - - // QString svg_string( svg_source ); - QHashIterator tintIter( m_tintMap ); - while( tintIter.hasNext() ) - { - tintIter.next(); - svg_source.replace( tintIter.key(), tintIter.value().toLocal8Bit() ); - } - return svg_source; -} - -void -SvgTinter::init() -{ - if ( m_lastPalette != App::instance()->palette() || m_firstRun ) { - m_tintMap.insert( "#666765", App::instance()->palette().window().color().name() ); - //insert a color for bright ( highlight color ) - m_tintMap.insert( "#66ffff", App::instance()->palette().highlight().color().name() ); - //a slightly lighter than window color: - m_tintMap.insert( "#e8e8e8", blendColors( App::instance()->palette().window().color(), "#ffffff", 90 ).name() ); - //a slightly darker than window color: - m_tintMap.insert( "#565755", blendColors( App::instance()->palette().window().color(), "#000000", 90 ).name() ); - - //list background: - #ifdef Q_WS_MAC - m_tintMap.insert( "#f0f0f0", blendColors( App::instance()->palette().window().color(), "#000000", 90 ).name() ); - m_tintMap.insert( "#ffffff", blendColors( App::instance()->palette().window().color(), "#000000", 98 ).name() ); - #else - m_tintMap.insert( "#f0f0f0", App::instance()->palette().base().color().name() ); - #endif - - //alternate list background: - m_tintMap.insert( "#e0e0e0", App::instance()->palette().alternateBase().color().name() ); - - //highlight/window mix: - m_tintMap.insert( "#123456", blendColors( App::instance()->palette().window().color(), App::instance()->palette().highlight().color().name(), 80 ).name() ); - - //text color, useful for adding contrast - m_tintMap.insert( "#010101", App::instance()->palette().text().color().name() ); - - m_lastPalette = App::instance()->palette(); - } -} - -QColor -SvgTinter::blendColors( const QColor& color1, const QColor& color2, int percent ) -{ - const float factor1 = ( float ) percent / 100; - const float factor2 = ( 100 - ( float ) percent ) / 100; - - const int r = static_cast( color1.red() * factor1 + color2.red() * factor2 ); - const int g = static_cast( color1.green() * factor1 + color2.green() * factor2 ); - const int b = static_cast( color1.blue() * factor1 + color2.blue() * factor2 ); - - QColor result; - result.setRgb( r, g, b ); - - return result; -} - -namespace The { - SvgTinter* - svgTinter() - { - if ( SvgTinter::s_instance == 0 ) - SvgTinter::s_instance = new SvgTinter(); - - return SvgTinter::s_instance; - } -} - - - diff --git a/amarok/src/SvgTinter.h b/amarok/src/SvgTinter.h deleted file mode 100644 index e0be7ecc..00000000 --- a/amarok/src/SvgTinter.h +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * Copyright (c) 2007 Mark Kretschmann * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef SVGTINTER_H -#define SVGTINTER_H - -#include "amarok_export.h" - -#include -#include -#include -#include -#include - -class SvgTinter; - -namespace The { - AMAROK_EXPORT SvgTinter* svgTinter(); -} - -/** -This singleton class is used to tint the svg artwork to attempt to better match the users color scheme. - - @author Nikolaj Hald Nielsen -*/ -class SvgTinter -{ - friend SvgTinter* The::svgTinter(); - - public: - ~SvgTinter(); - - QByteArray AMAROK_EXPORT tint( const QString &filename ); - void AMAROK_EXPORT init(); - - QColor blendColors( const QColor& color1, const QColor& color2, int percent ); - - private: - SvgTinter(); - - static SvgTinter * s_instance; - QHash m_tintMap; - - QPalette m_lastPalette; - bool m_firstRun; -}; - -#endif diff --git a/amarok/src/TrayIcon.cpp b/amarok/src/TrayIcon.cpp deleted file mode 100644 index 0ee29355..00000000 --- a/amarok/src/TrayIcon.cpp +++ /dev/null @@ -1,322 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2003 Stanislav Karchebny * - * Copyright (c) 2003 Max Howell * - * Copyright (c) 2004 Enrico Ros * - * Copyright (c) 2006 Ian Monroe * - * Copyright (c) 2009-2011 Kevin Funk * - * Copyright (c) 2009 Mark Kretschmann * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "TrayIcon.h" - -#include "EngineController.h" -#include "GlobalCurrentTrackActions.h" -#include "SvgHandler.h" -#include "amarokconfig.h" -#include "core/capabilities/ActionsCapability.h" -#include "core/capabilities/BookmarkThisCapability.h" -#include "core/meta/Meta.h" -#include "core/meta/Statistics.h" -#include "core/support/Amarok.h" -#include "playlist/PlaylistActions.h" - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#ifdef Q_WS_MAC - extern void qt_mac_set_dock_menu(QMenu *); -#endif - -Amarok::TrayIcon::TrayIcon( QObject *parent ) - : KStatusNotifierItem( parent ) - , m_track( The::engineController()->currentTrack() ) -{ - PERF_LOG( "Beginning TrayIcon Constructor" ); - KActionCollection* const ac = Amarok::actionCollection(); - - setStatus( KStatusNotifierItem::Active ); - - // Remove the "Configure Amarok..." action, as it makes no sense in the tray menu - const QString preferences = KStandardAction::name( KStandardAction::Preferences ); - contextMenu()->removeAction( ac->action( preferences ) ); - - PERF_LOG( "Before adding actions" ); - -#ifdef Q_WS_MAC - // Add these functions to the dock icon menu in OS X - qt_mac_set_dock_menu( contextMenu() ); - contextMenu()->addAction( ac->action( "playlist_playmedia" ) ); - contextMenu()->addSeparator(); -#endif - - contextMenu()->addAction( ac->action( "prev" ) ); - contextMenu()->addAction( ac->action( "play_pause" ) ); - contextMenu()->addAction( ac->action( "stop" ) ); - contextMenu()->addAction( ac->action( "next" ) ); - - contextMenu()->addSeparator(); - - contextMenu()->setObjectName( "TrayIconContextMenu" ); - - PERF_LOG( "Initializing system tray icon" ); - - setIconByName( "amarok" ); - updateOverlayIcon(); - updateToolTipIcon(); - updateMenu(); - - const EngineController* engine = The::engineController(); - connect( engine, SIGNAL(trackPlaying(Meta::TrackPtr)), - this, SLOT(trackPlaying(Meta::TrackPtr)) ); - connect( engine, SIGNAL(stopped(qint64,qint64)), - this, SLOT(stopped()) ); - connect( engine, SIGNAL(paused()), - this, SLOT(paused()) ); - - connect( engine, SIGNAL(trackMetadataChanged(Meta::TrackPtr)), - this, SLOT(metadataChanged(Meta::TrackPtr)) ); - - connect( engine, SIGNAL(albumMetadataChanged(Meta::AlbumPtr)), - this, SLOT(metadataChanged(Meta::AlbumPtr)) ); - - connect( engine, SIGNAL(volumeChanged(int)), - this, SLOT(updateToolTip()) ); - - connect( engine, SIGNAL(muteStateChanged(bool)), - this, SLOT(updateToolTip()) ); - - connect( engine, SIGNAL(playbackStateChanged()), - this, SLOT(updateOverlayIcon()) ); - - connect( this, SIGNAL(scrollRequested(int,Qt::Orientation)), - SLOT(slotScrollRequested(int,Qt::Orientation)) ); - connect( this, SIGNAL(secondaryActivateRequested(QPoint)), - The::engineController(), SLOT(playPause()) ); -} - -void -Amarok::TrayIcon::updateToolTipIcon() -{ - updateToolTip(); // the normal update - - if( m_track ) - { - if( m_track->album() && m_track->album()->hasImage() ) - { - QPixmap image = The::svgHandler()->imageWithBorder( m_track->album(), KIconLoader::SizeLarge, 5 ); - setToolTipIconByPixmap( image ); - } - else - { - setToolTipIconByName( "amarok" ); - } - } - else - { - setToolTipIconByName( "amarok" ); - } -} - - -void -Amarok::TrayIcon::updateToolTip() -{ - if( m_track ) - { - setToolTipTitle( The::engineController()->prettyNowPlaying( false ) ); - - QStringList tooltip; - - QString volume; - if ( The::engineController()->isMuted() ) - { - volume = i18n( "Muted" ); - } - else - { - volume = i18n( "%1%", The::engineController()->volume() ); - } - tooltip << i18n( "Volume: %1", volume ); - - Meta::StatisticsPtr statistics = m_track->statistics(); - const float score = statistics->score(); - if( score > 0.f ) - { - tooltip << i18n( "Score: %1", QString::number( score, 'f', 2 ) ); - } - - const int rating = statistics->rating(); - if( rating > 0 ) - { - QString stars; - for( int i = 0; i < rating / 2; ++i ) - stars += QString( "" ) - .arg( KStandardDirs::locate( "data", "amarok/images/star.png" ) ) - .arg( QFontMetrics( QToolTip::font() ).height() ) - .arg( QFontMetrics( QToolTip::font() ).height() ); - if( rating % 2 ) - stars += QString( "" ) - .arg( KStandardDirs::locate( "data", "amarok/images/smallstar.png" ) ) - .arg( QFontMetrics( QToolTip::font() ).height() ) - .arg( QFontMetrics( QToolTip::font() ).height() ); - - tooltip << i18n( "Rating: %1", stars ); - } - - const int count = statistics->playCount(); - if( count > 0 ) - { - tooltip << i18n( "Play count: %1", count ); - } - - const QDateTime lastPlayed = statistics->lastPlayed(); - tooltip << i18n( "Last played: %1", Amarok::verboseTimeSince( lastPlayed ) ); - - setToolTipSubTitle( tooltip.join("
") ); - } - else - { - setToolTipTitle( KCmdLineArgs::aboutData()->programName() ); - setToolTipSubTitle( The::engineController()->prettyNowPlaying( false ) ); - } -} - -void -Amarok::TrayIcon::trackPlaying( Meta::TrackPtr track ) -{ - m_track = track; - - updateMenu(); - updateToolTipIcon(); -} - -void -Amarok::TrayIcon::paused() -{ - updateToolTipIcon(); - -} - -void -Amarok::TrayIcon::stopped() -{ - m_track = 0; - updateMenu(); // remove custom track actions on stop - updateToolTipIcon(); -} - -void -Amarok::TrayIcon::metadataChanged( Meta::TrackPtr track ) -{ - Q_UNUSED( track ) - - updateToolTip(); - updateMenu(); -} - -void -Amarok::TrayIcon::metadataChanged( Meta::AlbumPtr album ) -{ - Q_UNUSED( album ) - - updateToolTipIcon(); - updateMenu(); -} - -void -Amarok::TrayIcon::slotScrollRequested( int delta, Qt::Orientation orientation ) -{ - Q_UNUSED( orientation ) - - The::engineController()->increaseVolume( delta / Amarok::VOLUME_SENSITIVITY ); -} - -void -Amarok::TrayIcon::updateMenu() -{ - foreach( QAction* action, m_extraActions ) - { - contextMenu()->removeAction( action ); - // -- delete actions without parent (e.g. the ones from the capabilities) - if( action && !action->parent() ) - { - delete action; - } - } - m_extraActions.clear(); - - contextMenu()->removeAction( m_separator.data() ); - - delete m_separator.data(); - - if( m_track ) - { - foreach( QAction *action, The::globalCurrentTrackActions()->actions() ) - m_extraActions.append( action ); - - QScopedPointer ac( m_track->create() ); - if( ac ) - { - QList actions = ac->actions(); - foreach( QAction *action, actions ) - m_extraActions.append( action ); - } - - QScopedPointer btc( m_track->create() ); - if( btc ) - { - m_extraActions.append( btc->bookmarkAction() ); - } - } - - // second statement checks if the menu has already been populated (first startup), if not: do it - if( m_extraActions.count() > 0 || - contextMenu()->actions().last() != actionCollection()->action( "file_quit" ) ) - { - // remove the 2 bottom items, so we can push them to the bottom again - contextMenu()->removeAction( actionCollection()->action( "file_quit" ) ); - contextMenu()->removeAction( actionCollection()->action( "minimizeRestore" ) ); - - foreach( QAction* action, m_extraActions ) - contextMenu()->addAction( action ); - - m_separator = contextMenu()->addSeparator(); - // readd - contextMenu()->addAction( actionCollection()->action( "minimizeRestore" ) ); - contextMenu()->addAction( actionCollection()->action( "file_quit" ) ); - } -} - -void -Amarok::TrayIcon::updateOverlayIcon() -{ - if( The::engineController()->isPlaying() ) - setOverlayIconByName( "media-playback-start" ); - else if( The::engineController()->isPaused() ) - setOverlayIconByName( "media-playback-pause" ); - else - setOverlayIconByName( QString() ); -} - -#include "moc_TrayIcon.cpp" diff --git a/amarok/src/TrayIcon.h b/amarok/src/TrayIcon.h deleted file mode 100644 index 3a0d9a21..00000000 --- a/amarok/src/TrayIcon.h +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2003 Stanislav Karchebny * - * Copyright (c) 2009 Mark Kretschmann * - * Copyright (c) 2009-2011 Kevin Funk * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_TRAYICON_H -#define AMAROK_TRAYICON_H - -#include // baseclass - -#include "core/meta/forward_declarations.h" -#include "core/support/SmartPointerList.h" - -#include -#include - -namespace Amarok { - -class TrayIcon : public KStatusNotifierItem -{ - Q_OBJECT - -public: - TrayIcon( QObject *parent ); - -private slots: - void updateOverlayIcon(); - void updateToolTipIcon(); - void updateToolTip(); - void updateMenu(); - - void trackPlaying( Meta::TrackPtr track ); - void stopped(); - void paused(); - void metadataChanged( Meta::TrackPtr track ); - void metadataChanged( Meta::AlbumPtr album ); - - void slotScrollRequested( int delta, Qt::Orientation orientation ); - -private: - Meta::TrackPtr m_track; - - SmartPointerList m_extraActions; - QWeakPointer m_separator; -}; - -} - -#endif // AMAROK_TRAYICON_H diff --git a/amarok/src/aboutdialog/AnimatedBarWidget.cpp b/amarok/src/aboutdialog/AnimatedBarWidget.cpp deleted file mode 100644 index 7698f84a..00000000 --- a/amarok/src/aboutdialog/AnimatedBarWidget.cpp +++ /dev/null @@ -1,201 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Téo Mrnjavac * - * Copyright (c) 2012 Lachlan Dufton * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "AnimatedBarWidget.h" - -#include - -#include -#include -#include - -AnimatedBarWidget::AnimatedBarWidget( const QIcon &icon, const QString &text, const QString &animatedIconName, QWidget *parent ) - : QAbstractButton( parent ) -{ - setIconSize( QSize( 22, 22 ) ); - setIcon( icon ); - setText( text ); - m_animating = false; - m_animatedWidget = new AnimatedWidget( animatedIconName, this ); - m_animatedWidget->setFixedSize( 22, 22 ); - m_animatedWidget->hide(); - m_animatedWidget->setAutoFillBackground( false ); - - setFocusPolicy( Qt::NoFocus ); - m_hoverHint = false; - - // Need to change the size policy to allow for wrapping - QSizePolicy poli( QSizePolicy::Preferred, QSizePolicy::Preferred ); - poli.setHeightForWidth( true ); - setSizePolicy( poli ); -} - -AnimatedBarWidget::~AnimatedBarWidget() -{} - -void -AnimatedBarWidget::animate() -{ - m_animating = true; - m_animatedWidget->show(); - m_animatedWidget->start(); - update(); -} - -void -AnimatedBarWidget::stop() -{ - m_animating = false; - m_animatedWidget->stop(); - m_animatedWidget->hide(); - update(); -} - -void -AnimatedBarWidget::fold() -{ - hide(); -} - -//protected: - - - -void -AnimatedBarWidget::setHoverHintEnabled( bool enable ) -{ - m_hoverHint = enable; - update(); -} - -bool -AnimatedBarWidget::isHoverHintEnabled() const -{ - return m_hoverHint; -} - -void -AnimatedBarWidget::enterEvent( QEvent* event ) -{ - QWidget::enterEvent( event ); - setHoverHintEnabled( true ); - update(); -} - -void -AnimatedBarWidget::leaveEvent( QEvent* event ) -{ - QWidget::leaveEvent( event ); - setHoverHintEnabled( false ); - update(); -} - -void -AnimatedBarWidget::paintEvent( QPaintEvent* event ) -{ - Q_UNUSED(event); - - QPainter painter(this); - - const int buttonHeight = height(); - int buttonWidth = width(); - - drawHoverBackground(&painter); - - int left, top, right, bottom; - getContentsMargins ( &left, &top, &right, &bottom ); - const int padding = 2; - const int iconWidth = iconSize().width(); - const int iconHeight = iconSize().height(); - const int iconTop = ( (buttonHeight - top - bottom) - iconHeight ) / 2; - - if( !m_animating ) - { - const QRect iconRect( left + padding, iconTop, iconWidth, iconHeight ); - painter.drawPixmap( iconRect, icon().pixmap( iconSize() ) ); - } - else - m_animatedWidget->move( left + padding, iconTop ); - - const QRect textRect( left + (padding * 3) + iconWidth, top, - buttonWidth - (left + padding * 3 + iconWidth) - padding, buttonHeight); - QFontMetrics fm( font() ); - painter.drawText( textRect, Qt::AlignVCenter | Qt::TextWordWrap, text() ); -} - - -void -AnimatedBarWidget::drawHoverBackground(QPainter* painter) -{ - const bool isHovered = isHoverHintEnabled(); - if( isHovered ) - { - QStyleOptionViewItemV4 option; - option.initFrom(this); - option.state = QStyle::State_Enabled | QStyle::State_Selected; - option.viewItemPosition = QStyleOptionViewItemV4::OnlyOne; - style()->drawPrimitive( QStyle::PE_PanelItemViewItem, &option, painter, this ); - } - else - { - QStyleOptionViewItemV4 option; - option.initFrom(this); - option.state = QStyle::State_Enabled | QStyle::State_MouseOver; - option.viewItemPosition = QStyleOptionViewItemV4::OnlyOne; - style()->drawPrimitive( QStyle::PE_PanelItemViewItem, &option, painter, this ); - } -} - -QColor -AnimatedBarWidget::foregroundColor() const -{ - const bool isHighlighted = isHoverHintEnabled(); - - QColor foregroundColor = palette().color( foregroundRole() ); - if( !isHighlighted ) - foregroundColor.setAlpha( 60 ); - - return foregroundColor; -} - - -QSize -AnimatedBarWidget::sizeHint() const -{ - QSize size = QAbstractButton::sizeHint(); - size.setHeight( iconSize().height() + 8 ); - return size; -} - -/** - * Find the height required to fit the widget with wrapped text - * and the icon, plus padding - */ -int -AnimatedBarWidget::heightForWidth(int w) const -{ - const int hPadding = 2; - const int vPadding = 4; - // Padding to the left and right of both the icon and text - const QRect bound( 0, 0, (w - hPadding * 4 - iconSize().width()), 0 ); - QFontMetrics fm( font() ); - int fontHeight = fm.boundingRect( bound, Qt::TextWordWrap, text() ).height(); - if( fontHeight < iconSize().height() ) - return iconSize().height() + 2 * vPadding; - - return fontHeight + 2 * vPadding; -} diff --git a/amarok/src/aboutdialog/AnimatedBarWidget.h b/amarok/src/aboutdialog/AnimatedBarWidget.h deleted file mode 100644 index 2c67ae86..00000000 --- a/amarok/src/aboutdialog/AnimatedBarWidget.h +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Téo Mrnjavac * - * Copyright (c) 2012 Lachlan Dufton * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_ANIMATEDBARWIDGET_H -#define AMAROK_ANIMATEDBARWIDGET_H - -#include "AnimatedWidget.h" - -#include -#include - -class AnimatedBarWidget : public QAbstractButton -{ - Q_OBJECT -public: - AnimatedBarWidget( const QIcon &icon, const QString &text, const QString &animatedIconName = "process-working", QWidget *parent = 0 ); - ~AnimatedBarWidget(); - - bool isAnimating() const { return m_animating; } - - virtual QSize sizeHint() const; - virtual int heightForWidth(int w) const; - -public slots: - void animate(); - void stop(); - void fold(); - -protected: - void setHoverHintEnabled( bool enable); - bool isHoverHintEnabled() const; - - virtual void enterEvent(QEvent* event); - virtual void leaveEvent(QEvent* event); - - virtual void paintEvent(QPaintEvent* event); - void drawHoverBackground(QPainter* painter); - - //! Returns the foreground color by respecting the current display hint. - QColor foregroundColor() const; - -private: - void init(); - bool m_hoverHint; - AnimatedWidget *m_animatedWidget; - QString *m_text; - bool m_animating; - QIcon m_icon; -}; - - - -#endif //AMAROK_ANIMATEDBARWIDGET_H diff --git a/amarok/src/aboutdialog/AnimatedWidget.cpp b/amarok/src/aboutdialog/AnimatedWidget.cpp deleted file mode 100644 index 012de5c4..00000000 --- a/amarok/src/aboutdialog/AnimatedWidget.cpp +++ /dev/null @@ -1,110 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Pino Toscano * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "AnimatedWidget.h" - -#include -#include - -#include - -AnimatedWidget::AnimatedWidget( const QString& iconName, QWidget *parent ) - : QWidget( parent ), m_icon( iconName ), m_frames( 0 ), m_currentFrame( 0 ), - m_size( 0 ) -{ - setAutoFillBackground( false ); - - hide(); -} - -AnimatedWidget::~AnimatedWidget() -{ -} - -void AnimatedWidget::start() -{ - if ( m_timer.isActive() ) - return; - - if ( !m_frames ) - { - load(); - if ( !m_frames ) - return; - } - - m_timer.start( 1000 / m_frames, this ); - show(); -} - -void AnimatedWidget::stop() -{ - m_timer.stop(); - m_currentFrame = 0; - hide(); -} - -void AnimatedWidget::paintEvent( QPaintEvent *event ) -{ - Q_UNUSED( event ); - - const int row_size = m_pixmap.width() / m_size; - const int row = m_currentFrame / row_size; - const int column = m_currentFrame % row_size; - - QPainter p( this ); - p.fillRect( rect(), Qt::transparent ); - p.drawPixmap( 0, 0, m_pixmap, column * m_size, row * m_size, m_size, m_size ); -} - -void AnimatedWidget::resizeEvent( QResizeEvent *event ) -{ - Q_UNUSED( event ); - - m_timer.stop(); - load(); -} - -void AnimatedWidget::timerEvent( QTimerEvent *event ) -{ - if ( event->timerId() == m_timer.timerId() ) - { - m_currentFrame++; - if ( m_currentFrame == m_frames ) - m_currentFrame = 0; - update(); - } - QWidget::timerEvent( event ); -} - -void AnimatedWidget::load() -{ - // FIXME implement a better logic for the animation size - m_size = 22; - const QString path = KIconLoader::global()->iconPath( m_icon, -m_size ); - QPixmap pix( path ); - if ( pix.isNull() ) - return; - - if ( ( pix.width() % m_size != 0 ) || ( pix.height() % m_size != 0 ) ) - return; - - m_frames = ( pix.height() / m_size ) * ( pix.width() / m_size ); - m_pixmap = pix; - m_currentFrame = 0; -} - -#include "moc_AnimatedWidget.cpp" diff --git a/amarok/src/aboutdialog/AnimatedWidget.h b/amarok/src/aboutdialog/AnimatedWidget.h deleted file mode 100644 index c2f8c8df..00000000 --- a/amarok/src/aboutdialog/AnimatedWidget.h +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Pino Toscano * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef ANIMATEDWIDGET_H -#define ANIMATEDWIDGET_H - -#include -#include -#include - -class AnimatedWidget : public QWidget -{ - Q_OBJECT - - public: - explicit AnimatedWidget( const QString& iconName, QWidget *parent = 0 ); - virtual ~AnimatedWidget(); - - public slots: - void start(); - void stop(); - - protected: - void paintEvent( QPaintEvent *event ); - void resizeEvent( QResizeEvent *event ); - void timerEvent( QTimerEvent *event ); - - private: - void load(); - - QString m_icon; - QPixmap m_pixmap; - int m_frames; - int m_currentFrame; - int m_size; - QBasicTimer m_timer; -}; - -#endif diff --git a/amarok/src/aboutdialog/ExtendedAboutDialog.cpp b/amarok/src/aboutdialog/ExtendedAboutDialog.cpp deleted file mode 100644 index 0ffd0564..00000000 --- a/amarok/src/aboutdialog/ExtendedAboutDialog.cpp +++ /dev/null @@ -1,415 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Urs Wolfer * - * Copyright (c) 2008 Friedrich W. H. Kossebau * - * Copyright (c) 2009 Téo Mrnjavac * - * * - * Parts of this class have been take from the KAboutApplication class, which was * - * Copyright (c) 2000 Waldo Bastian (bastian@kde.org) and Espen Sand (espen@kde.org) * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "ExtendedAboutDialog.h" - -#include "core/support/Amarok.h" -#include "core/support/Debug.h" -#include "OcsPersonItem.h" -#include "libattica-ocsclient/providerinitjob.h" - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -class ExtendedAboutDialog::Private -{ -public: - Private(ExtendedAboutDialog *parent) - : q(parent), - aboutData(0) - {} - - void _k_showLicense( const QString &number ); - - ExtendedAboutDialog *q; - - const KAboutData *aboutData; -}; - -ExtendedAboutDialog::ExtendedAboutDialog(const KAboutData *aboutData, const OcsData *ocsData, QWidget *parent) - : KDialog(parent) - , d(new Private(this)) -{ - DEBUG_BLOCK - if (aboutData == 0) - aboutData = KGlobal::mainComponent().aboutData(); - - d->aboutData = aboutData; - - if (!aboutData) { - QLabel *errorLabel = new QLabel(i18n("No information available.
" - "The supplied KAboutData object does not exist.
"), this); - - errorLabel->setTextInteractionFlags(Qt::TextBrowserInteraction); - setMainWidget(errorLabel); - return; - } - if( !ocsData ) - { - QLabel *errorLabel = new QLabel(i18n("No information available.
" - "The supplied OcsData object does not exist.
"), this); - - errorLabel->setTextInteractionFlags(Qt::TextBrowserInteraction); - setMainWidget(errorLabel); - return; - } - m_ocsData = *ocsData; - - setWindowTitle(i18n("About %1", aboutData->programName())); - setButtons(KDialog::Close); - setDefaultButton(KDialog::Close); - setModal(false); - - - //Set up the title widget... - KTitleWidget *titleWidget = new KTitleWidget(this); - - QIcon windowIcon; - if (!aboutData->programIconName().isEmpty()) { - windowIcon = KIcon(aboutData->programIconName()); - } else { - windowIcon = qApp->windowIcon(); - } - titleWidget->setPixmap(windowIcon.pixmap(64, 64), KTitleWidget::ImageLeft); - if (aboutData->programLogo().canConvert()) - titleWidget->setPixmap(aboutData->programLogo().value(), KTitleWidget::ImageLeft); - else if (aboutData->programLogo().canConvert()) - titleWidget->setPixmap(QPixmap::fromImage(aboutData->programLogo().value()), KTitleWidget::ImageLeft); - - titleWidget->setText(i18n("%1
Version %2
Using KDE %3", - aboutData->programName(), aboutData->version(), KDE::versionString())); - - - //Now let's add the tab bar... - QTabWidget *tabWidget = new QTabWidget; - tabWidget->setUsesScrollButtons(false); - - - //Set up the first page... - QString aboutPageText = aboutData->shortDescription() + '\n'; - - if (!aboutData->otherText().isEmpty()) - aboutPageText += '\n' + aboutData->otherText() + '\n'; - - if (!aboutData->copyrightStatement().isEmpty()) - aboutPageText += '\n' + aboutData->copyrightStatement() + '\n'; - - if (!aboutData->homepage().isEmpty()) - aboutPageText += '\n' + QString("%1").arg(aboutData->homepage()) + '\n'; - aboutPageText = aboutPageText.trimmed(); - - QLabel *aboutLabel = new QLabel; - aboutLabel->setWordWrap(true); - aboutLabel->setOpenExternalLinks(true); - aboutLabel->setText(aboutPageText.replace('\n', "
")); - aboutLabel->setTextInteractionFlags(Qt::TextBrowserInteraction); - - QVBoxLayout *aboutLayout = new QVBoxLayout; - aboutLayout->addStretch(); - aboutLayout->addWidget(aboutLabel); - - const int licenseCount = aboutData->licenses().count(); - debug()<< "About to show license stuff"; - debug()<< "License count is"<licenses().at(i); - - QLabel *showLicenseLabel = new QLabel; - showLicenseLabel->setText(QString("%2").arg(QString::number(i), - i18n("License: %1", - license.name(KAboutData::FullName)))); - showLicenseLabel->setTextInteractionFlags(Qt::TextBrowserInteraction); - connect(showLicenseLabel, SIGNAL(linkActivated(QString)), this, SLOT(_k_showLicense(QString))); - - aboutLayout->addWidget(showLicenseLabel); - } - debug()<<"License widget added"; - - aboutLayout->addStretch(); - - QWidget *aboutWidget = new QWidget(this); - aboutWidget->setLayout(aboutLayout); - - tabWidget->addTab(aboutWidget, i18n("&About")); - - - //Stuff needed by both Authors and Credits pages: - QPixmap openDesktopPixmap = QPixmap( KStandardDirs::locate( "data", "amarok/images/opendesktop-22.png" ) ); - QIcon openDesktopIcon = QIcon( openDesktopPixmap ); - - - //And now, the Authors page: - const int authorCount = d->aboutData->authors().count(); - - if (authorCount) - { - m_authorWidget = new QWidget( this ); - QVBoxLayout *authorLayout = new QVBoxLayout( m_authorWidget.data() ); - - m_showOcsAuthorButton = new AnimatedBarWidget( openDesktopIcon, - i18n( "Get data from openDesktop.org to learn more about the team" ), - "process-working", m_authorWidget.data() ); - connect( m_showOcsAuthorButton.data(), SIGNAL(clicked()), this, SLOT(switchToOcsWidgets()) ); - authorLayout->addWidget( m_showOcsAuthorButton.data() ); - - if (!aboutData->customAuthorTextEnabled() || !aboutData->customAuthorRichText().isEmpty()) - { - QLabel *bugsLabel = new QLabel( m_authorWidget.data() ); - bugsLabel->setContentsMargins( 4, 2, 0, 4 ); - if (!aboutData->customAuthorTextEnabled()) - { - if (aboutData->bugAddress().isEmpty() || aboutData->bugAddress() == "submit@bugs.kde.org") - bugsLabel->setText( i18n("Please use http://bugs.kde.org to report bugs.\n") ); - else - { - if(aboutData->authors().count() == 1 && (aboutData->authors().first().emailAddress() == aboutData->bugAddress())) - { - bugsLabel->setText( i18n("Please report bugs to %2.\n", - aboutData->authors().first().emailAddress(), - aboutData->authors().first().emailAddress())); - } - else - { - bugsLabel->setText( i18n("Please report bugs to %2.\n", - aboutData->bugAddress(), aboutData->bugAddress())); - } - } - } - else - bugsLabel->setText( aboutData->customAuthorRichText() ); - authorLayout->addWidget( bugsLabel ); - } - - m_authorListWidget = new OcsPersonListWidget( d->aboutData->authors(), m_ocsData.authors(), OcsPersonItem::Author, m_authorWidget.data() ); - connect( m_authorListWidget.data(), SIGNAL(switchedToOcs()), m_showOcsAuthorButton.data(), SLOT(stop()) ); - connect( m_authorListWidget.data(), SIGNAL(switchedToOcs()), m_showOcsAuthorButton.data(), SLOT(fold()) ); - - authorLayout->addWidget( m_authorListWidget.data() ); - authorLayout->setMargin( 0 ); - authorLayout->setSpacing( 2 ); - m_authorWidget.data()->setLayout( authorLayout ); - - m_authorPageTitle = ( authorCount == 1 ) ? i18n("A&uthor") : i18n("A&uthors"); - tabWidget->addTab(m_authorWidget.data(), m_authorPageTitle); - m_isOfflineAuthorWidget = true; //is this still used? - } - - //Then the Credits page: - const int creditCount = aboutData->credits().count(); - - if (creditCount) - { - m_creditWidget = new QWidget( this ); - QVBoxLayout *creditLayout = new QVBoxLayout( m_creditWidget.data() ); - - m_showOcsCreditButton = new AnimatedBarWidget( openDesktopIcon, - i18n( "Get data from openDesktop.org to learn more about contributors" ), - "process-working", m_creditWidget.data() ); - connect( m_showOcsCreditButton.data(), SIGNAL(clicked()), this, SLOT(switchToOcsWidgets()) ); - creditLayout->addWidget( m_showOcsCreditButton.data() ); - - m_creditListWidget = new OcsPersonListWidget( d->aboutData->credits(), m_ocsData.credits(), OcsPersonItem::Contributor, m_creditWidget.data() ); - connect( m_creditListWidget.data(), SIGNAL(switchedToOcs()), m_showOcsCreditButton.data(), SLOT(stop()) ); - connect( m_creditListWidget.data(), SIGNAL(switchedToOcs()), m_showOcsCreditButton.data(), SLOT(fold()) ); - - creditLayout->addWidget( m_creditListWidget.data() ); - creditLayout->setMargin( 0 ); - creditLayout->setSpacing( 2 ); - m_creditWidget.data()->setLayout( creditLayout ); - - tabWidget->addTab( m_creditWidget.data(), i18n("&Contributors")); - m_isOfflineCreditWidget = true; //is this still used? - } - - //Finally, the Donors page: - const int donorCount = ocsData->donors()->count(); - - if (donorCount) - { - m_donorWidget = new QWidget( this ); - QVBoxLayout *donorLayout = new QVBoxLayout( m_donorWidget.data() ); - - m_showOcsDonorButton = new AnimatedBarWidget( openDesktopIcon, - i18n( "Get data from openDesktop.org to learn more about our generous donors" ), - "process-working", m_donorWidget.data() ); - connect( m_showOcsDonorButton.data(), SIGNAL(clicked()), this, SLOT(switchToOcsWidgets()) ); - donorLayout->addWidget( m_showOcsDonorButton.data() ); - - QList< KAboutPerson > donors; - for( QList< QPair< QString, KAboutPerson > >::const_iterator it = m_ocsData.donors()->constBegin(); - it != m_ocsData.donors()->constEnd(); ++it ) - { - donors << ( *it ).second; - } - m_donorListWidget = new OcsPersonListWidget( donors , m_ocsData.donors(), OcsPersonItem::Contributor, m_donorWidget.data() ); - connect( m_donorListWidget.data(), SIGNAL(switchedToOcs()), m_showOcsDonorButton.data(), SLOT(stop()) ); - connect( m_donorListWidget.data(), SIGNAL(switchedToOcs()), m_showOcsDonorButton.data(), SLOT(fold()) ); - - donorLayout->addWidget( m_donorListWidget.data() ); - donorLayout->setMargin( 0 ); - donorLayout->setSpacing( 2 ); - QLabel *roktoberLabel = - new QLabel(i18n("

Each year in October the Amarok team organizes a funding " - "drive called Roktober.

" - "

If you want your name mentioned on this list " - " donate " - "during Roktober and opt-in.

")); - roktoberLabel->setOpenExternalLinks(true); - donorLayout->addWidget(roktoberLabel); - m_donorWidget.data()->setLayout( donorLayout ); - - tabWidget->addTab( m_donorWidget.data(), i18n("&Donors")); - m_isOfflineDonorWidget = true; - } - - - //And the translators: - QPalette transparentBackgroundPalette; - transparentBackgroundPalette.setColor( QPalette::Base, Qt::transparent ); - transparentBackgroundPalette.setColor( QPalette::Text, transparentBackgroundPalette.color( QPalette::WindowText ) ); - - - const QList translatorList = aboutData->translators(); - - if(translatorList.count() > 0) { - QString translatorPageText; - - QList::ConstIterator it; - for(it = translatorList.begin(); it != translatorList.end(); ++it) { - translatorPageText += QString("

%1

").arg((*it).name()); - if (!(*it).emailAddress().isEmpty()) - translatorPageText += QString("

%1

").arg((*it).emailAddress()); - translatorPageText += "

 

"; - } - - translatorPageText += KAboutData::aboutTranslationTeam(); - - KTextBrowser *translatorTextBrowser = new KTextBrowser; - translatorTextBrowser->setFrameStyle(QFrame::NoFrame); - translatorTextBrowser->setPalette(transparentBackgroundPalette); - translatorTextBrowser->setHtml(translatorPageText); - tabWidget->addTab(translatorTextBrowser, i18n("T&ranslation")); - } - - //Jam everything together in a layout: - QVBoxLayout *mainLayout = new QVBoxLayout; - mainLayout->addWidget(titleWidget); - mainLayout->addWidget(tabWidget); - mainLayout->setMargin(0); - - QWidget *mainWidget = new QWidget; - mainWidget->setLayout(mainLayout); - setMainWidget(mainWidget); - setInitialSize( QSize( 480, 460 ) ); -} - -ExtendedAboutDialog::~ExtendedAboutDialog() -{ - delete d; -} - -void ExtendedAboutDialog::Private::_k_showLicense( const QString &number ) -{ - KDialog *dialog = new KDialog(q); - - dialog->setCaption(i18n("License Agreement")); - dialog->setButtons(KDialog::Close); - dialog->setDefaultButton(KDialog::Close); - - const QFont font = KGlobalSettings::fixedFont(); - QFontMetrics metrics(font); - - const QString licenseText = aboutData->licenses().at(number.toInt()).text(); - KTextBrowser *licenseBrowser = new KTextBrowser; - licenseBrowser->setFont(font); - licenseBrowser->setLineWrapMode(QTextEdit::NoWrap); - licenseBrowser->setText(licenseText); - - dialog->setMainWidget(licenseBrowser); - - // try to set up the dialog such that the full width of the - // document is visible without horizontal scroll-bars being required - const qreal idealWidth = licenseBrowser->document()->idealWidth() + (2 * dialog->marginHint()) - + licenseBrowser->verticalScrollBar()->width() * 2; - - // try to allow enough height for a reasonable number of lines to be shown - const int idealHeight = metrics.height() * 30; - - dialog->setInitialSize(dialog->sizeHint().expandedTo(QSize((int)idealWidth,idealHeight))); - dialog->show(); -} - -void -ExtendedAboutDialog::switchToOcsWidgets() -{ - if( !( Solid::Networking::status() == Solid::Networking::Connected || - Solid::Networking::status() == Solid::Networking::Unknown ) ) - { - KMessageBox::error( this, i18n( "Internet connection not available" ), i18n( "Network error" ) ); - return; - } - - if( m_showOcsAuthorButton ) - m_showOcsAuthorButton.data()->animate(); - if( m_showOcsCreditButton ) - m_showOcsCreditButton.data()->animate(); - if( m_showOcsDonorButton ) - m_showOcsDonorButton.data()->animate(); - AmarokAttica::ProviderInitJob *providerJob = AmarokAttica::Provider::byId( m_ocsData.providerId() ); - connect( providerJob, SIGNAL(result(KJob*)), this, SLOT(onProviderFetched(KJob*)) ); -} - -void -ExtendedAboutDialog::onProviderFetched( KJob *job ) -{ - AmarokAttica::ProviderInitJob *providerJob = qobject_cast< AmarokAttica::ProviderInitJob * >( job ); - if( providerJob->error() == 0 ) - { - debug()<<"Successfully fetched OCS provider"<< providerJob->provider().name(); - debug()<<"About to request OCS data"; - if( m_authorListWidget ) - m_authorListWidget.data()->switchToOcs( providerJob->provider() ); - if( m_creditListWidget ) - m_creditListWidget.data()->switchToOcs( providerJob->provider() ); - if( m_donorListWidget ) - m_donorListWidget.data()->switchToOcs( providerJob->provider() ); - } - else - warning() << "OCS provider fetch failed"; -} - -#include "moc_ExtendedAboutDialog.cpp" diff --git a/amarok/src/aboutdialog/ExtendedAboutDialog.h b/amarok/src/aboutdialog/ExtendedAboutDialog.h deleted file mode 100644 index 13fa6995..00000000 --- a/amarok/src/aboutdialog/ExtendedAboutDialog.h +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Urs Wolfer * - * Copyright (c) 2008 Friedrich W. H. Kossebau * - * Copyright (c) 2009 Téo Mrnjavac * - * * - * Parts of this class have been take from the KAboutApplication class, which was * - * Copyright (c) 2000 Waldo Bastian (bastian@kde.org) and Espen Sand (espen@kde.org) * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_EXTENDEDABOUTDIALOG_H -#define AMAROK_EXTENDEDABOUTDIALOG_H - -#include "core/support/Amarok.h" -#include "amarok_export.h" -#include "App.h" -#include "OcsPersonListWidget.h" -#include "AnimatedBarWidget.h" - -#include -#include -#include - -class AMAROK_EXPORT ExtendedAboutDialog : public KDialog -{ - Q_OBJECT -public: - explicit ExtendedAboutDialog( const KAboutData *aboutData, const OcsData *ocsData, QWidget *parent = 0 ); - virtual ~ExtendedAboutDialog(); - -private slots: - void switchToOcsWidgets(); - void onProviderFetched( KJob *job ); - -private: - class Private; - Private* const d; - - Q_PRIVATE_SLOT( d, void _k_showLicense(const QString&) ) - - Q_DISABLE_COPY( ExtendedAboutDialog ) - - OcsData m_ocsData; - -//Authors: - QString m_authorPageTitle; - QWeakPointer m_showOcsAuthorButton; - QWeakPointer m_authorWidget; - QWeakPointer m_authorListWidget; - bool m_isOfflineAuthorWidget; - -//Contributors: - QWeakPointer m_showOcsCreditButton; - QWeakPointer m_creditWidget; - QWeakPointer m_creditListWidget; - bool m_isOfflineCreditWidget; - -//Donors: - QWeakPointer m_showOcsDonorButton; - QWeakPointer m_donorWidget; - QWeakPointer m_donorListWidget; - bool m_isOfflineDonorWidget; - -}; - -#endif //AMAROK_EXTENDEDABOUTDIALOG_H diff --git a/amarok/src/aboutdialog/FramedLabel.cpp b/amarok/src/aboutdialog/FramedLabel.cpp deleted file mode 100644 index 3e8c1bb5..00000000 --- a/amarok/src/aboutdialog/FramedLabel.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Téo Mrnjavac * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "FramedLabel.h" - -#include -#include -#include - -FramedLabel::FramedLabel( QWidget *parent, Qt::WindowFlags f ) - : QLabel( parent, f ) -{} - -FramedLabel::FramedLabel( const QString &text, QWidget *parent, Qt::WindowFlags f ) - : QLabel( text, parent, f ) -{} - -FramedLabel::~FramedLabel() -{} - -void -FramedLabel::paintEvent( QPaintEvent *event ) -{ - Q_UNUSED( event ) - if( frameShape() == QFrame::StyledPanel ) - { - QPainter painter( this ); - QStyleOptionViewItemV4 option; - option.initFrom( this ); - option.state = QStyle::State_Enabled | QStyle::State_MouseOver; - option.viewItemPosition = QStyleOptionViewItemV4::OnlyOne; - style()->drawPrimitive( QStyle::PE_PanelItemViewItem, &option, &painter, this ); - } - QRect cr = contentsRect(); - QPaintEvent *e = new QPaintEvent( cr ); - QLabel::paintEvent( e ); -} diff --git a/amarok/src/aboutdialog/FramedLabel.h b/amarok/src/aboutdialog/FramedLabel.h deleted file mode 100644 index 8921e5cb..00000000 --- a/amarok/src/aboutdialog/FramedLabel.h +++ /dev/null @@ -1,40 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Téo Mrnjavac * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_FRAMEDLABEL_H -#define AMAROK_FRAMEDLABEL_H - -#include - -/** - * A simple subclass of QLabel that unlike a QLabel under Oxygen, actually obeys setting - * the shape to QFrame::StyledPanel. - * @author Téo Mrnjavac - */ -class FramedLabel : public QLabel -{ - Q_OBJECT - -public: - explicit FramedLabel( QWidget *parent = 0, Qt::WindowFlags f = 0 ); - explicit FramedLabel( const QString &text, QWidget *parent = 0, Qt::WindowFlags f = 0 ); - ~FramedLabel(); - -protected: - virtual void paintEvent( QPaintEvent *event ); -}; - -#endif //AMAROK_FRAMEDLABEL_H diff --git a/amarok/src/aboutdialog/OcsData.cpp b/amarok/src/aboutdialog/OcsData.cpp deleted file mode 100644 index d4e937de..00000000 --- a/amarok/src/aboutdialog/OcsData.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Téo Mrnjavac * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "OcsData.h" - -OcsData::OcsData( const QByteArray &providerId ) -{ - m_providerId = QString::fromUtf8( providerId ); -} - -OcsData::~OcsData() -{} - -void -OcsData::addAuthor( const QString &username, const KAboutPerson &person ) -{ - m_authors.append( QPair< QString, KAboutPerson >( username, person ) ); -} - -void -OcsData::addCredit( const QString &username, const KAboutPerson &person ) -{ - m_credits.append( QPair< QString, KAboutPerson >( username, person ) ); -} - -void -OcsData::addDonor( const QString &username, const KAboutPerson &person ) -{ - m_donors.append( QPair< QString, KAboutPerson >( username, person) ); -} diff --git a/amarok/src/aboutdialog/OcsData.h b/amarok/src/aboutdialog/OcsData.h deleted file mode 100644 index e60a376e..00000000 --- a/amarok/src/aboutdialog/OcsData.h +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Téo Mrnjavac * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_OCSDATA_H -#define AMAROK_OCSDATA_H - -#include "core/support/Amarok.h" -#include "amarok_export.h" - -#include "kaboutdata.h" - -#include -#include -#include - -class AMAROK_EXPORT OcsData -{ -public: - typedef QList< QPair< QString, KAboutPerson > > OcsPersonList; - - OcsData( const QByteArray &providerId = "opendesktop" ); - virtual ~OcsData(); - void addAuthor( const QString &username, const KAboutPerson &person ); - void addCredit( const QString &username, const KAboutPerson &person ); - void addDonor( const QString &username, const KAboutPerson &person ); - - const OcsPersonList * authors() const { return &m_authors; } - const OcsPersonList * credits() const { return &m_credits; } - const OcsPersonList * donors() const { return &m_donors; } - const QString providerId() const { return m_providerId; } - -private: - QList< QPair< QString, KAboutPerson > > m_authors; - QList< QPair< QString, KAboutPerson > > m_credits; - QList< QPair< QString, KAboutPerson > > m_donors; - QString m_providerId; -}; - -#endif //AMAROK_OCSDATA_H diff --git a/amarok/src/aboutdialog/OcsPersonItem.cpp b/amarok/src/aboutdialog/OcsPersonItem.cpp deleted file mode 100644 index d239c2cf..00000000 --- a/amarok/src/aboutdialog/OcsPersonItem.cpp +++ /dev/null @@ -1,352 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Téo Mrnjavac * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "OcsPersonItem.h" - -#include "core/support/Debug.h" -#include "libattica-ocsclient/provider.h" -#include "libattica-ocsclient/providerinitjob.h" -#include "libattica-ocsclient/personjob.h" - -#include -#include -#include - -#include -#include -#include -#include - -OcsPersonItem::OcsPersonItem( const KAboutPerson &person, const QString ocsUsername, PersonStatus status, QWidget *parent ) - : QWidget( parent ) - , m_status( status ) - , m_state( Offline ) -{ - m_person = &person; - m_ocsUsername = ocsUsername; - - setupUi( this ); - init(); - - m_avatar->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ); - - //TODO: Add favorite artists! - -} - -void -OcsPersonItem::init() -{ - m_textLabel->setTextInteractionFlags( Qt::TextBrowserInteraction ); - m_textLabel->setOpenExternalLinks( true ); - m_textLabel->setContentsMargins( 5, 0, 0, 2 ); - m_verticalLayout->setSpacing( 0 ); - - m_vertLine->hide(); - m_initialSpacer->changeSize( 0, 40, QSizePolicy::Fixed, QSizePolicy::Fixed ); - layout()->invalidate(); - - m_aboutText.append( "" + m_person->name() + "" ); - if( !m_person->task().isEmpty() ) - m_aboutText.append( "
" + m_person->task() ); - - m_iconsBar = new KToolBar( this, false, false ); - m_snBar = new KToolBar( this, false, false ); - - m_iconsBar->setIconSize( QSize( 22, 22 ) ); - m_iconsBar->setContentsMargins( 0, 0, 0, 0 ); - m_iconsBar->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ); - - if( m_status == Author ) - { - QHBoxLayout *iconsLayout = new QHBoxLayout( this ); - iconsLayout->setMargin( 0 ); - iconsLayout->setSpacing( 0 ); - m_verticalLayout->insertLayout( m_verticalLayout->count() - 1, iconsLayout ); - iconsLayout->addWidget( m_iconsBar ); - iconsLayout->addWidget( m_snBar ); - iconsLayout->addStretch( 0 ); - - m_snBar->setIconSize( QSize( 16, 16 ) ); - m_snBar->setContentsMargins( 0, 0, 0, 0 ); - m_snBar->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ); - } - else - { - layout()->addWidget( m_iconsBar ); - m_snBar->hide(); - } - - if( !m_person->emailAddress().isEmpty() ) - { - KAction *email = new KAction( KIcon( "internet-mail" ), i18n("Email contributor"), this ); - email->setToolTip( m_person->emailAddress() ); - email->setData( QString( "mailto:" + m_person->emailAddress() ) ); - m_iconsBar->addAction( email ); - } - - if( !m_person->webAddress().isEmpty() ) - { - KAction *homepage = new KAction( KIcon( "applications-internet" ), i18n("Visit contributor's homepage"), this ); - homepage->setToolTip( m_person->webAddress() ); - homepage->setData( m_person->webAddress() ); - m_iconsBar->addAction( homepage ); - } - - connect( m_iconsBar, SIGNAL(actionTriggered(QAction*)), this, SLOT(launchUrl(QAction*)) ); - connect( m_snBar, SIGNAL(actionTriggered(QAction*)), this, SLOT(launchUrl(QAction*)) ); - m_textLabel->setText( m_aboutText ); -} - -OcsPersonItem::~OcsPersonItem() -{} - -QString -OcsPersonItem::name() -{ - return m_person->name(); -} - -void -OcsPersonItem::launchUrl( QAction *action ) //SLOT -{ - KUrl url = KUrl( action->data().toString() ); - KRun::runUrl( url, "text/html", 0, false ); -} - -void -OcsPersonItem::switchToOcs( const AmarokAttica::Provider &provider ) -{ - if( m_state == Online ) - return; - m_avatar->setFixedWidth( 56 ); - m_vertLine->show(); - m_initialSpacer->changeSize( 5, 40, QSizePolicy::Fixed, QSizePolicy::Fixed ); - layout()->invalidate(); - - if( !m_ocsUsername.isEmpty() ) - { - AmarokAttica::PersonJob *personJob; - if( m_ocsUsername == QString( "%%category%%" ) ) //TODO: handle grouping - return; - - personJob = provider.requestPerson( m_ocsUsername ); - connect( personJob, SIGNAL(result(KJob*)), this, SLOT(onJobFinished(KJob*)) ); - emit ocsFetchStarted(); - m_state = Online; - } -} - -void -OcsPersonItem::onJobFinished( KJob *job ) -{ - AmarokAttica::PersonJob *personJob = qobject_cast< AmarokAttica::PersonJob * >( job ); - if( personJob->error() == 0 ) - { - fillOcsData( personJob->person() ); - } - emit ocsFetchResult( personJob->error() ); -} - -void -OcsPersonItem::fillOcsData( const AmarokAttica::Person &ocsPerson ) -{ - if( !( ocsPerson.avatar().isNull() ) ) - { - m_avatar->setFixedSize( 56, 56 ); - m_avatar->setFrameShape( QFrame::StyledPanel ); //this is a FramedLabel, otherwise oxygen wouldn't paint the frame - m_avatar->setPixmap( ocsPerson.avatar() ); - m_avatar->setAlignment( Qt::AlignCenter ); - } - - if( !ocsPerson.country().isEmpty() ) - { - m_aboutText.append( "
" ); - if( !ocsPerson.city().isEmpty() ) - m_aboutText.append( i18nc( "A person's location: City, Country", "%1, %2", ocsPerson.city(), ocsPerson.country() ) ); - else - m_aboutText.append( ocsPerson.country() ); - } - - if( m_status == Author ) - { - if( !ocsPerson.extendedAttribute( "ircchannels" ).isEmpty() ) - { - QString channelsString = ocsPerson.extendedAttribute( "ircchannels" ); - //We extract the channel names from the string provided by OCS: - QRegExp channelrx = QRegExp( "#+[\\w\\.\\-\\/!()+]+([\\w\\-\\/!()+]?)", Qt::CaseInsensitive ); - QStringList channels; - int pos = 0; - while( ( pos = channelrx.indexIn( channelsString, pos ) ) != -1 ) - { - channels << channelrx.cap( 0 ); - pos += channelrx.matchedLength(); - } - - m_aboutText.append( "
" + i18n("IRC channels: ") ); - QString link; - foreach( const QString &channel, channels ) - { - const QString channelName = QString( channel ).remove( '#' ); - link = QString( "irc://irc.freenode.org/%1" ).arg( channelName ); - m_aboutText.append( QString( "%2" ).arg( link, channel ) + " " ); - } - } - if( !ocsPerson.extendedAttribute( "favouritemusic" ).isEmpty() ) - { - QStringList artists = ocsPerson.extendedAttribute( "favouritemusic" ).split( ", " ); - //TODO: make them clickable - m_aboutText.append( "
" + i18n( "Favorite music: " ) + artists.join( ", " ) ); - } - } - - KAction *visitProfile = new KAction( KIcon( QPixmap( KStandardDirs::locate( "data", - "amarok/images/opendesktop-22.png" ) ) ), i18n( "Visit %1's openDesktop.org profile", ocsPerson.firstName() ), this ); - - visitProfile->setToolTip( i18n( "Visit %1's profile on openDesktop.org", ocsPerson.firstName() ) ); - - visitProfile->setData( ocsPerson.extendedAttribute( "profilepage" ) ); - m_iconsBar->addAction( visitProfile ); - - if( m_status == Author ) - { - QList< QPair< QString, QString > > ocsHomepages; - ocsHomepages.append( QPair< QString, QString >( ocsPerson.extendedAttribute( "homepagetype" ), ocsPerson.homepage() ) ); - - debug() << "USER HOMEPAGE DATA STARTS HERE"; - debug() << ocsHomepages.last().first << " :: " << ocsHomepages.last().second; - - for( int i = 2; i <= 10; i++ ) //OCS supports 10 total homepages as of 2/oct/2009 - { - QString type = ocsPerson.extendedAttribute( QString( "homepagetype%1" ).arg( i ) ); - ocsHomepages.append( QPair< QString, QString >( ( type == " " ) ? "" : type, - ocsPerson.extendedAttribute( QString( "homepage%1" ).arg( i ) ) ) ); - debug() << ocsHomepages.last().first << " :: " << ocsHomepages.last().second; - } - - bool fillHomepageFromOcs = m_person->webAddress().isEmpty(); //We check if the person already has a homepage in KAboutPerson. - - for( QList< QPair< QString, QString > >::const_iterator entry = ocsHomepages.constBegin(); - entry != ocsHomepages.constEnd(); ++entry ) - { - QString type = (*entry).first; - QString url = (*entry).second; - KIcon icon; - QString text; - - if( type == "Blog" ) - { - icon = KIcon( "kblogger" ); - text = i18n( "Visit contributor's blog" ); - } - else if( type == "delicious" ) - { - icon = KIcon( QPixmap( KStandardDirs::locate( "data", "amarok/images/emblem-delicious.png" ) ) ); - text = i18n( "Visit contributor's del.icio.us profile" ); - } - else if( type == "Digg" ) - { - icon = KIcon( QPixmap( KStandardDirs::locate( "data", "amarok/images/emblem-digg.png" ) ) ); - text = i18n( "Visit contributor's Digg profile" ); - } - else if( type == "Facebook" ) - { - icon = KIcon( QPixmap( KStandardDirs::locate( "data", "amarok/images/emblem-facebook.png" ) ) ); - text = i18n( "Visit contributor's Facebook profile" ); - } - else if( type == "Homepage" || type == "other" || ( type.isEmpty() && !url.isEmpty() ) ) - { - if( fillHomepageFromOcs ) - { - KAction *homepage = new KAction( KIcon( "applications-internet" ), i18n("Visit contributor's homepage"), this ); - homepage->setToolTip( url ); - homepage->setData( url ); - m_iconsBar->addAction( homepage ); - fillHomepageFromOcs = false; - continue; - } - if( type == "other" && url.contains( "last.fm/" ) ) //HACK: assign a last.fm icon if the URL contains last.fm - { - icon = KIcon( QPixmap( KStandardDirs::locate( "data", "amarok/images/emblem-lastfm.png" ) ) ); - text = i18n( "Visit contributor's Last.fm profile" ); - } - else - continue; - } - else if( type == "LinkedIn" ) - { - icon = KIcon( QPixmap( KStandardDirs::locate( "data", "amarok/images/emblem-linkedin.png" ) ) ); - text = i18n( "Visit contributor's LinkedIn profile" ); - } - else if( type == "MySpace" ) - { - icon = KIcon( QPixmap( KStandardDirs::locate( "data", "amarok/images/emblem-myspace.png" ) ) ); - text = i18n( "Visit contributor's MySpace homepage" ); - } - else if( type == "Reddit" ) - { - icon = KIcon( QPixmap( KStandardDirs::locate( "data", "amarok/images/emblem-reddit.png" ) ) ); - text = i18n( "Visit contributor's Reddit profile" ); - } - else if( type == "YouTube" ) - { - icon = KIcon( "dragonplayer" ); //FIXME: icon - text = i18n( "Visit contributor's YouTube profile" ); - } - else if( type == "Twitter" ) - { - icon = KIcon( QPixmap( KStandardDirs::locate( "data", "amarok/images/emblem-twitter.png" ) ) ); - text = i18n( "Visit contributor's Twitter feed" ); - } - else if( type == "Wikipedia" ) - { - icon = KIcon( QPixmap( KStandardDirs::locate( "data", "amarok/images/emblem-wikipedia.png" ) ) ); - text = i18n( "Visit contributor's Wikipedia profile" ); - } - else if( type == "Xing" ) - { - icon = KIcon( QPixmap( KStandardDirs::locate( "data", "amarok/images/emblem-xing.png" ) ) ); - text = i18n( "Visit contributor's Xing profile" ); - } - else if( type == "identi.ca" ) - { - icon = KIcon( QPixmap( KStandardDirs::locate( "data", "amarok/images/emblem-identica.png" ) ) ); - text = i18n( "Visit contributor's identi.ca feed" ); - } - else if( type == "libre.fm" ) - { - icon = KIcon( "juk" ); //FIXME: icon - text = i18n( "Visit contributor's libre.fm profile" ); - } - else if( type == "StackOverflow" ) - { - icon = KIcon( QPixmap( KStandardDirs::locate( "data", "amarok/images/emblem-stackoverflow.png" ) ) ); - text = i18n( "Visit contributor's StackOverflow profile" ); - } - else - break; - KAction *action = new KAction( icon, text, this ); - action->setToolTip( url ); - action->setData( url ); - m_snBar->addAction( action ); - } - - debug() << "END USER HOMEPAGE DATA"; - } - - m_textLabel->setText( m_aboutText ); -} - diff --git a/amarok/src/aboutdialog/OcsPersonItem.h b/amarok/src/aboutdialog/OcsPersonItem.h deleted file mode 100644 index 6420c588..00000000 --- a/amarok/src/aboutdialog/OcsPersonItem.h +++ /dev/null @@ -1,93 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Téo Mrnjavac * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_OCSPERSONITEM_H -#define AMAROK_OCSPERSONITEM_H - -#include "ui_OcsPersonItem.h" - -#include "libattica-ocsclient/person.h" -#include "libattica-ocsclient/provider.h" -#include "OcsData.h" - -#include -#include - -#include - -class OcsPersonItem : public QWidget, private Ui::OcsPersonItem -{ - Q_OBJECT - -public: - enum PersonStatus - { - Author = 0, - Contributor = 1 - }; - enum State - { - Offline = 0, - Online = 1 - }; - - OcsPersonItem( const KAboutPerson &person, const QString ocsUsername, PersonStatus status, QWidget *parent = 0 ); - - virtual ~OcsPersonItem(); - - QString name(); - - void switchToOcs( const AmarokAttica::Provider &provider ); - -signals: - void ocsFetchStarted(); - void ocsFetchResult( int err ); - -private slots: - void launchUrl( QAction *action ); - void onJobFinished( KJob *job ); - -private: - void init(); - void fillOcsData( const AmarokAttica::Person &ocsPerson ); - const KAboutPerson *m_person; - QString m_ocsUsername; - QString m_aboutText; - KToolBar *m_iconsBar; //!< holds the icons for email, homepage and oD.o profile - KToolBar *m_snBar; //!< holds any other icons for social network profiles - PersonStatus m_status; - State m_state; -/* - Frank - Test - developer - opendesktop.org - opendesktop.org - http://www.KDE-Look.org/CONTENT/user-pics/0/Frank.jpg - 1 - http://www.KDE-Look.org/CONTENT/user-bigpics/0/Frank.jpg - 1 - Stuttgart - Germany - karli - kde-dev, plasma - irc://irc.freenode.org/kde-dev - irc://irc.freenode.org/plasma - http://www.KDE-Look.org/usermanager/search.php?username=Frank - */ -}; - -#endif //AMAROK_OCSPERSONITEM_H diff --git a/amarok/src/aboutdialog/OcsPersonItem.ui b/amarok/src/aboutdialog/OcsPersonItem.ui deleted file mode 100644 index 0a27f20d..00000000 --- a/amarok/src/aboutdialog/OcsPersonItem.ui +++ /dev/null @@ -1,173 +0,0 @@ - - - OcsPersonItem - - - - 0 - 0 - 491 - 43 - - - - - 0 - 0 - - - - - 0 - 10 - - - - - 0 - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 5 - 40 - - - - - - - - - - Qt::Vertical - - - - 20 - 1 - - - - - - - - - 0 - 0 - - - - - 0 - 1 - - - - QFrame::NoFrame - - - - - - - - - - Qt::Vertical - - - - 20 - 1 - - - - - - - - - - QFrame::VLine - - - QFrame::Raised - - - - - - - QLayout::SetDefaultConstraint - - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 20 - 5 - - - - - - - - - 0 - 0 - - - - Name - - - true - - - - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 20 - 5 - - - - - - - - - - - FramedLabel - QLabel -
aboutdialog/FramedLabel.h
-
-
- - -
diff --git a/amarok/src/aboutdialog/OcsPersonListWidget.cpp b/amarok/src/aboutdialog/OcsPersonListWidget.cpp deleted file mode 100644 index 052a4803..00000000 --- a/amarok/src/aboutdialog/OcsPersonListWidget.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Téo Mrnjavac * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "OcsPersonListWidget.h" - -#include "core/support/Debug.h" - -#include - - -OcsPersonListWidget::OcsPersonListWidget( const QList< KAboutPerson > &persons, - const OcsData::OcsPersonList *ocsPersons, - OcsPersonItem::PersonStatus status, - QWidget *parent ) - : QWidget( parent ) - , m_status( status ) - , m_fetchCount( 0 ) -{ - //Set up the layouts... - QHBoxLayout *scrollLayout = new QHBoxLayout( this ); - scrollLayout->setMargin( 1 ); - setLayout( scrollLayout ); - QScrollArea *personsScrollArea = new QScrollArea( this ); - scrollLayout->addWidget( personsScrollArea ); - personsScrollArea->setFrameStyle( QFrame::NoFrame ); - m_personsArea = new QWidget( personsScrollArea ); - m_areaLayout = new QVBoxLayout( m_personsArea ); - m_areaLayout->setMargin( 0 ); - m_personsArea->setLayout( m_areaLayout ); - m_personsArea->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ); - - - personsScrollArea->setWidgetResizable( true ); - personsScrollArea->setWidget( m_personsArea ); - m_personsArea->show(); - - //Populate the scroll area... - for( int i = 0; i < persons.count(); ++i ) //TODO: really ugly and inefficient, fix this - { - OcsPersonItem *item = new OcsPersonItem( persons.at( i ), ocsPersons->at( i ).first, status, m_personsArea ); - m_areaLayout->addWidget( item ); - connect( item, SIGNAL(ocsFetchStarted()), this, SLOT(onOcsFetchStarted()) ); - connect( item, SIGNAL(ocsFetchResult(int)), this, SLOT(onOcsDataFetched(int)) ); - } -} - -void -OcsPersonListWidget::switchToOcs( const AmarokAttica::Provider &provider ) -{ - for( int i = 0; i < m_areaLayout->count(); ++i ) - { - OcsPersonItem *item = qobject_cast< OcsPersonItem * >( m_areaLayout->itemAt( i )->widget() ); - item->switchToOcs( provider ); - } -} - -void -OcsPersonListWidget::onOcsFetchStarted() //SLOT -{ - m_fetchCount++; -} - -void -OcsPersonListWidget::onOcsDataFetched( int err ) //SLOT -{ - m_fetchCount--; - debug()< * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_OCSPERSONLISTWIDGET_H -#define AMAROK_OCSPERSONLISTWIDGET_H - -#include "OcsPersonItem.h" -#include "OcsData.h" -#include "libattica-ocsclient/provider.h" - -class OcsPersonListWidget : public QWidget -{ - Q_OBJECT - -public: - OcsPersonListWidget( const QList< KAboutPerson > &persons, - const OcsData::OcsPersonList *ocsPersons, - OcsPersonItem::PersonStatus status = OcsPersonItem::Author, - QWidget *parent = 0 ); - -public slots: - void switchToOcs( const AmarokAttica::Provider &provider ); - void onOcsFetchStarted(); - void onOcsDataFetched( int err ); - -signals: - void switchedToOcs(); - -private: - QWidget *m_personsArea; - QVBoxLayout *m_areaLayout; - OcsPersonItem::PersonStatus m_status; - int m_fetchCount; -}; - -#endif //AMAROK_OCSPERSONLISTWIDGET_H diff --git a/amarok/src/aboutdialog/libattica-ocsclient/CMakeLists.txt b/amarok/src/aboutdialog/libattica-ocsclient/CMakeLists.txt deleted file mode 100644 index 3e12e977..00000000 --- a/amarok/src/aboutdialog/libattica-ocsclient/CMakeLists.txt +++ /dev/null @@ -1,42 +0,0 @@ -set(ocsclient_SRCS - providerinitjob.cpp - eventjob.cpp - eventlistjob.cpp - eventparser.cpp - event.cpp - activity.cpp - activityparser.cpp - activitylistjob.cpp - person.cpp - personparser.cpp - personjob.cpp - personlistjob.cpp - provider.cpp - postjob.cpp - folder.cpp - folderlistjob.cpp - folderparser.cpp - message.cpp - messagelistjob.cpp - messageparser.cpp - category.cpp - categorylistjob.cpp - categoryparser.cpp - content.cpp - contentjob.cpp - contentlistjob.cpp - contentparser.cpp - knowledgebase.cpp - knowledgebasejob.cpp - knowledgebaselistjob.cpp - knowledgebaseparser.cpp - ) - - - -add_library(amarokocsclient SHARED ${ocsclient_SRCS}) -set_target_properties(amarokocsclient PROPERTIES VERSION ${GENERIC_LIB_VERSION} SOVERSION ${GENERIC_LIB_SOVERSION}) - -target_link_libraries(amarokocsclient ${KDE4_KDEUI_LIBS} ${KDE4_KIO_LIBS} ${KDE4_KABC_LIBS}) - -install(TARGETS amarokocsclient ${INSTALL_TARGETS_DEFAULT_ARGS}) diff --git a/amarok/src/aboutdialog/libattica-ocsclient/TODO b/amarok/src/aboutdialog/libattica-ocsclient/TODO deleted file mode 100644 index cca6e2ea..00000000 --- a/amarok/src/aboutdialog/libattica-ocsclient/TODO +++ /dev/null @@ -1,2 +0,0 @@ -- Combine List job with single item job? - diff --git a/amarok/src/aboutdialog/libattica-ocsclient/activity.cpp b/amarok/src/aboutdialog/libattica-ocsclient/activity.cpp deleted file mode 100644 index 5d8a3314..00000000 --- a/amarok/src/aboutdialog/libattica-ocsclient/activity.cpp +++ /dev/null @@ -1,106 +0,0 @@ -/* - This file is part of KDE. - - Copyright (c) 2008 Cornelius Schumacher - - This program 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 2 of the License, or - (at your option) any later version. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - -#include "activity.h" - -#include - - -using namespace AmarokAttica; - -class Activity::Private : public QSharedData { - public: - QString m_id; - QString m_user; - QDateTime m_timestamp; - QString m_message; - QString m_link; -}; - -Activity::Activity() : d(new Private) -{ -} - -Activity::Activity(const AmarokAttica::Activity& other) - : d(other.d) -{ -} - -Activity& Activity::operator=(const AmarokAttica::Activity & other) -{ - d = other.d; - return *this; -} - -Activity::~Activity() -{ -} - - -void Activity::setId( const QString &id ) -{ - d->m_id = id; -} - -QString Activity::id() const -{ - return d->m_id; -} - -void Activity::setUser( const QString &u ) -{ - d->m_user = u; -} - -QString Activity::user() const -{ - return d->m_user; -} - -void Activity::setTimestamp( const QDateTime &date ) -{ - d->m_timestamp = date; -} - -QDateTime Activity::timestamp() const -{ - return d->m_timestamp; -} - -void Activity::setMessage( const QString &c ) -{ - d->m_message = c; -} - -QString Activity::message() const -{ - return d->m_message; -} - -void Activity::setLink( const QString &v ) -{ - d->m_link = v; -} - -QString Activity::link() const -{ - return d->m_link; -} diff --git a/amarok/src/aboutdialog/libattica-ocsclient/activity.h b/amarok/src/aboutdialog/libattica-ocsclient/activity.h deleted file mode 100644 index d9d7ebb9..00000000 --- a/amarok/src/aboutdialog/libattica-ocsclient/activity.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - This file is part of KDE. - - Copyright (c) 2008 Cornelius Schumacher - - This program 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 2 of the License, or - (at your option) any later version. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ -#ifndef ATTICA_ACTIVITY_H -#define ATTICA_ACTIVITY_H - -#include -#include - -#include "atticaclient_export.h" - - -class QDateTime; - -namespace AmarokAttica { - - -class ATTICA_EXPORT Activity -{ - public: - typedef QList List; - - Activity(); - Activity(const Activity& other); - Activity& operator=(const Activity& other); - ~Activity(); - - void setId( const QString & ); - QString id() const; - - void setUser( const QString & ); - QString user() const; - - void setTimestamp( const QDateTime & ); - QDateTime timestamp() const; - - void setMessage( const QString & ); - QString message() const; - - void setLink( const QString & ); - QString link() const; - - private: - class Private; - QSharedDataPointer d; -}; - -} - -#endif diff --git a/amarok/src/aboutdialog/libattica-ocsclient/activitylistjob.cpp b/amarok/src/aboutdialog/libattica-ocsclient/activitylistjob.cpp deleted file mode 100644 index eee82697..00000000 --- a/amarok/src/aboutdialog/libattica-ocsclient/activitylistjob.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/* - This file is part of KDE. - - Copyright (c) 2008 Cornelius Schumacher - - This program 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 2 of the License, or - (at your option) any later version. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - -#include "activitylistjob.h" - -#include "activityparser.h" - -#include -#include - -#include -#include - - -using namespace AmarokAttica; - -ActivityListJob::ActivityListJob() - : m_job( 0 ) -{ -} - -void ActivityListJob::setUrl( const KUrl &url ) -{ - m_url = url; -} - -void ActivityListJob::start() -{ - QTimer::singleShot( 0, this, SLOT(doWork()) ); -} - -Activity::List ActivityListJob::ActivityList() const -{ - return m_activityList; -} - -void ActivityListJob::doWork() -{ - qDebug() << m_url; - - m_job = KIO::get( m_url, KIO::NoReload, KIO::HideProgressInfo ); - connect( m_job, SIGNAL(result(KJob*)), - SLOT(slotJobResult(KJob*)) ); - connect( m_job, SIGNAL(data(KIO::Job*,QByteArray)), - SLOT(slotJobData(KIO::Job*,QByteArray)) ); -} - -void ActivityListJob::slotJobResult( KJob *job ) -{ - m_job = 0; - - if ( job->error() ) { - setError( job->error() ); - setErrorText( job->errorText() ); - - emitResult(); - } else { - // qDebug() << m_data; - m_activityList = ActivityParser().parseList( - QString::fromUtf8( m_data.data() ) ); - - emitResult(); - } -} - -void ActivityListJob::slotJobData( KIO::Job *, const QByteArray &data ) -{ - m_data.append( data ); -} diff --git a/amarok/src/aboutdialog/libattica-ocsclient/activitylistjob.h b/amarok/src/aboutdialog/libattica-ocsclient/activitylistjob.h deleted file mode 100644 index 8f41b9ae..00000000 --- a/amarok/src/aboutdialog/libattica-ocsclient/activitylistjob.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - This file is part of KDE. - - Copyright (c) 2008 Cornelius Schumacher - - This program 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 2 of the License, or - (at your option) any later version. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ -#ifndef ATTICA_ACTIVITYLISTJOB_H -#define ATTICA_ACTIVITYLISTJOB_H - -#include -#include - -#include "activity.h" - - -namespace KIO { -class Job; -} - -namespace AmarokAttica { - -class ATTICA_EXPORT ActivityListJob : public KJob -{ - Q_OBJECT - public: - ActivityListJob(); - - void setUrl( const KUrl & ); - - void start(); - - Activity::List ActivityList() const; - - protected slots: - void doWork(); - - void slotJobResult( KJob *job ); - void slotJobData( KIO::Job *job, const QByteArray &data ); - - private: - KUrl m_url; - KIO::Job *m_job; - QByteArray m_data; - - Activity::List m_activityList; -}; - -} - -#endif diff --git a/amarok/src/aboutdialog/libattica-ocsclient/activityparser.cpp b/amarok/src/aboutdialog/libattica-ocsclient/activityparser.cpp deleted file mode 100644 index f22702fb..00000000 --- a/amarok/src/aboutdialog/libattica-ocsclient/activityparser.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/* - This file is part of KDE. - - Copyright (c) 2008 Cornelius Schumacher - - This program 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 2 of the License, or - (at your option) any later version. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - -#include "activityparser.h" - -#include -#include -#include - - -using namespace AmarokAttica; - -ActivityParser::ActivityParser() -{ -} - -Activity::List ActivityParser::parseList( const QString &xmlString ) -{ - Activity::List activityList; - - QXmlStreamReader xml( xmlString ); - - while ( !xml.atEnd() ) { - xml.readNext(); - - if ( xml.isStartElement() && xml.name() == "activity" ) { - Activity activity; - - while ( !xml.atEnd() ) { - xml.readNext(); - - if ( xml.isStartElement() ) { - if ( xml.name() == "id" ) { - activity.setId( xml.readElementText() ); - } else if ( xml.name() == "personid" ) { - activity.setUser( xml.readElementText() ); - } else if ( xml.name() == "timestamp" ) { - QString timestampString = xml.readElementText(); - timestampString.remove( QRegExp("\\+.*$") ); - QDateTime timestamp = QDateTime::fromString( timestampString, - Qt::ISODate ); - activity.setTimestamp( timestamp ); - } else if ( xml.name() == "message" ) { - activity.setMessage( xml.readElementText() ); - } else if ( xml.name() == "link" ) { - activity.setLink( xml.readElementText() ); - } - } - - if ( xml.isEndElement() && xml.name() == "activity" ) break; - } - - activityList.append( activity ); - } - } - - return activityList; -} diff --git a/amarok/src/aboutdialog/libattica-ocsclient/activityparser.h b/amarok/src/aboutdialog/libattica-ocsclient/activityparser.h deleted file mode 100644 index e2a2c61a..00000000 --- a/amarok/src/aboutdialog/libattica-ocsclient/activityparser.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - This file is part of KDE. - - Copyright (c) 2008 Cornelius Schumacher - - This program 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 2 of the License, or - (at your option) any later version. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ -#ifndef ATTICA_ACTIVITYPARSER_H -#define ATTICA_ACTIVITYPARSER_H - -#include "activity.h" - - -namespace AmarokAttica { - -class ActivityParser -{ - public: - ActivityParser(); - - Activity::List parseList( const QString &xml ); -}; - -} - -#endif diff --git a/amarok/src/aboutdialog/libattica-ocsclient/atticaclient_export.h b/amarok/src/aboutdialog/libattica-ocsclient/atticaclient_export.h deleted file mode 100644 index 519ab2fa..00000000 --- a/amarok/src/aboutdialog/libattica-ocsclient/atticaclient_export.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - Copyright (c) 2008 Dirk Mueller - - This program 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 2 of the License, or - (at your option) any later version. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ -#ifndef ATTICA_EXPORT_H -#define ATTICA_EXPORT_H - -/* needed for KDE_EXPORT and KDE_IMPORT macros */ -#include - -#ifndef ATTICA_EXPORT -# if defined(MAKE_AMAROKOCSCLIENT_LIB) - /* We are building this library */ -# define ATTICA_EXPORT KDE_EXPORT -# else - /* We are using this library */ -# define ATTICA_EXPORT KDE_IMPORT -# endif -#endif - -#endif diff --git a/amarok/src/aboutdialog/libattica-ocsclient/category.cpp b/amarok/src/aboutdialog/libattica-ocsclient/category.cpp deleted file mode 100644 index d28d73ae..00000000 --- a/amarok/src/aboutdialog/libattica-ocsclient/category.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/* - This file is part of KDE. - - Copyright (c) 2008 Cornelius Schumacher - - This program 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 2 of the License, or - (at your option) any later version. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - -#include "category.h" - -#include - - -using namespace AmarokAttica; - -class Category::Private : public QSharedData { - public: - QString m_id; - QString m_name; -}; - - -Category::Category() : d(new Private) -{ -} - -Category::Category(const AmarokAttica::Category& other) - : d(other.d) -{ -} - -Category& Category::operator=(const AmarokAttica::Category & other) -{ - d = other.d; - return *this; -} - -Category::~Category() -{ -} - - -void Category::setId( const QString &u ) -{ - d->m_id = u; -} - -QString Category::id() const -{ - return d->m_id; -} - -void Category::setName( const QString &name ) -{ - d->m_name = name; -} - -QString Category::name() const -{ - return d->m_name; -} diff --git a/amarok/src/aboutdialog/libattica-ocsclient/category.h b/amarok/src/aboutdialog/libattica-ocsclient/category.h deleted file mode 100644 index f2ad7f3f..00000000 --- a/amarok/src/aboutdialog/libattica-ocsclient/category.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - This file is part of KDE. - - Copyright (c) 2008 Cornelius Schumacher - - This program 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 2 of the License, or - (at your option) any later version. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ -#ifndef ATTICA_CATEGORY_H -#define ATTICA_CATEGORY_H - -#include -#include - -#include "atticaclient_export.h" - - -namespace AmarokAttica { - - -class ATTICA_EXPORT Category -{ - public: - typedef QList List; - - Category(); - Category(const Category& other); - Category& operator=(const Category& other); - ~Category(); - - void setId( const QString & ); - QString id() const; - - void setName( const QString & ); - QString name() const; - - private: - class Private; - QSharedDataPointer d; -}; - -} - -#endif diff --git a/amarok/src/aboutdialog/libattica-ocsclient/categorylistjob.cpp b/amarok/src/aboutdialog/libattica-ocsclient/categorylistjob.cpp deleted file mode 100644 index 0ef87d69..00000000 --- a/amarok/src/aboutdialog/libattica-ocsclient/categorylistjob.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/* - This file is part of KDE. - - Copyright (c) 2008 Cornelius Schumacher - - This program 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 2 of the License, or - (at your option) any later version. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - -#include "categorylistjob.h" - -#include "categoryparser.h" - -#include -#include - -#include -#include - - -using namespace AmarokAttica; - -CategoryListJob::CategoryListJob() - : m_job( 0 ) -{ -} - -void CategoryListJob::setUrl( const KUrl &url ) -{ - m_url = url; -} - -void CategoryListJob::start() -{ - QTimer::singleShot( 0, this, SLOT(doWork()) ); -} - -Category::List CategoryListJob::categoryList() const -{ - return m_categoryList; -} - -void CategoryListJob::doWork() -{ - qDebug() << m_url; - - m_job = KIO::get( m_url, KIO::NoReload, KIO::HideProgressInfo ); - connect( m_job, SIGNAL(result(KJob*)), - SLOT(slotJobResult(KJob*)) ); - connect( m_job, SIGNAL(data(KIO::Job*,QByteArray)), - SLOT(slotJobData(KIO::Job*,QByteArray)) ); -} - -void CategoryListJob::slotJobResult( KJob *job ) -{ - m_job = 0; - - if ( job->error() ) { - setError( job->error() ); - setErrorText( job->errorText() ); - - emitResult(); - } else { - qDebug() << m_data; - m_categoryList = CategoryParser().parseList( - QString::fromUtf8( m_data.data() ) ); - - emitResult(); - } -} - -void CategoryListJob::slotJobData( KIO::Job *, const QByteArray &data ) -{ - m_data.append( data ); -} diff --git a/amarok/src/aboutdialog/libattica-ocsclient/categorylistjob.h b/amarok/src/aboutdialog/libattica-ocsclient/categorylistjob.h deleted file mode 100644 index 72dcf10b..00000000 --- a/amarok/src/aboutdialog/libattica-ocsclient/categorylistjob.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - This file is part of KDE. - - Copyright (c) 2008 Cornelius Schumacher - - This program 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 2 of the License, or - (at your option) any later version. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ -#ifndef ATTICA_CATEGORYLISTJOB_H -#define ATTICA_CATEGORYLISTJOB_H - -#include "category.h" - -#include -#include - -namespace KIO { -class Job; -} - -namespace AmarokAttica { - -class ATTICA_EXPORT CategoryListJob : public KJob -{ - Q_OBJECT - public: - CategoryListJob(); - - void setUrl( const KUrl & ); - - void start(); - - Category::List categoryList() const; - - protected slots: - void doWork(); - - void slotJobResult( KJob *job ); - void slotJobData( KIO::Job *job, const QByteArray &data ); - - private: - KUrl m_url; - KIO::Job *m_job; - QByteArray m_data; - - Category::List m_categoryList; -}; - -} - -#endif diff --git a/amarok/src/aboutdialog/libattica-ocsclient/categoryparser.cpp b/amarok/src/aboutdialog/libattica-ocsclient/categoryparser.cpp deleted file mode 100644 index 8e71c4d2..00000000 --- a/amarok/src/aboutdialog/libattica-ocsclient/categoryparser.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/* - This file is part of KDE. - - Copyright (c) 2008 Cornelius Schumacher - - This program 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 2 of the License, or - (at your option) any later version. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - -#include "categoryparser.h" - -#include - -using namespace AmarokAttica; - -CategoryParser::CategoryParser() -{ -} - -Category::List CategoryParser::parseList( const QString &xmlString ) -{ - Category::List categoryList; - - QXmlStreamReader xml( xmlString ); - - while ( !xml.atEnd() ) { - xml.readNext(); - - if ( xml.isStartElement() && xml.name() == "category" ) { - Category category; - - while ( !xml.atEnd() ) { - xml.readNext(); - - if ( xml.isStartElement() ) { - if ( xml.name() == "id" ) { - category.setId( xml.readElementText() ); - } else if ( xml.name() == "name" ) { - category.setName( xml.readElementText() ); - } - } - - if ( xml.isEndElement() && xml.name() == "category" ) break; - } - - categoryList.append( category ); - } - } - - return categoryList; -} diff --git a/amarok/src/aboutdialog/libattica-ocsclient/categoryparser.h b/amarok/src/aboutdialog/libattica-ocsclient/categoryparser.h deleted file mode 100644 index c3fce943..00000000 --- a/amarok/src/aboutdialog/libattica-ocsclient/categoryparser.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - This file is part of KDE. - - Copyright (c) 2008 Cornelius Schumacher - - This program 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 2 of the License, or - (at your option) any later version. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ -#ifndef ATTICA_CATEGORYPARSER_H -#define ATTICA_CATEGORYPARSER_H - -#include "category.h" - - -namespace AmarokAttica { - -class CategoryParser -{ - public: - CategoryParser(); - - Category::List parseList( const QString &xml ); -}; - -} - -#endif diff --git a/amarok/src/aboutdialog/libattica-ocsclient/content.cpp b/amarok/src/aboutdialog/libattica-ocsclient/content.cpp deleted file mode 100644 index a9b15050..00000000 --- a/amarok/src/aboutdialog/libattica-ocsclient/content.cpp +++ /dev/null @@ -1,142 +0,0 @@ -/* - This file is part of KDE. - - Copyright (c) 2008 Cornelius Schumacher - - This program 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 2 of the License, or - (at your option) any later version. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - -#include "content.h" - -#include - - -using namespace AmarokAttica; - -class Content::Private : public QSharedData { - public: - QDateTime m_created; - int m_downloads; - QString m_id; - QString m_name; - int m_rating; - QDateTime m_updated; - - QMap m_extendedAttributes; - - Private() - : m_downloads(0), - m_rating(0) - { - } -}; - - -Content::Content() - : d(new Private) -{ -} - -Content::Content(const AmarokAttica::Content& other) - : d(other.d) -{ -} - -Content& Content::operator=(const AmarokAttica::Content & other) -{ - d = other.d; - return *this; -} - -Content::~Content() -{ -} - - -void Content::setId( const QString &u ) -{ - d->m_id = u; -} - -QString Content::id() const -{ - return d->m_id; -} - -void Content::setName( const QString &name ) -{ - d->m_name = name; -} - -QString Content::name() const -{ - return d->m_name; -} - -void Content::setRating( int v ) -{ - d->m_rating = v; -} - -int Content::rating() const -{ - return d->m_rating; -} - -void Content::setDownloads( int v ) -{ - d->m_downloads = v; -} - -int Content::downloads() const -{ - return d->m_downloads; -} - -void Content::setCreated( const QDateTime &date ) -{ - d->m_created = date; -} - -QDateTime Content::created() const -{ - return d->m_created; -} - -void Content::setUpdated( const QDateTime &date ) -{ - d->m_updated = date; -} - -QDateTime Content::updated() const -{ - return d->m_updated; -} - -void Content::addExtendedAttribute( const QString &key, const QString &value ) -{ - d->m_extendedAttributes.insert( key, value ); -} - -QString Content::extendedAttribute( const QString &key ) const -{ - return d->m_extendedAttributes.value( key ); -} - -QMap Content::extendedAttributes() const -{ - return d->m_extendedAttributes; -} diff --git a/amarok/src/aboutdialog/libattica-ocsclient/content.h b/amarok/src/aboutdialog/libattica-ocsclient/content.h deleted file mode 100644 index bc66fdac..00000000 --- a/amarok/src/aboutdialog/libattica-ocsclient/content.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - This file is part of KDE. - - Copyright (c) 2008 Cornelius Schumacher - - This program 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 2 of the License, or - (at your option) any later version. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ -#ifndef ATTICA_CONTENT_H -#define ATTICA_CONTENT_H - -#include -#include -#include - -#include "atticaclient_export.h" - - -class QDateTime; - -namespace AmarokAttica { - -class ATTICA_EXPORT Content -{ - public: - typedef QList List; - - Content(); - Content(const Content& other); - Content& operator=(const Content& other); - ~Content(); - - void setId( const QString & ); - QString id() const; - - void setName( const QString & ); - QString name() const; - - void setRating( int ); - int rating() const; - - void setDownloads( int ); - int downloads() const; - - void setCreated( const QDateTime & ); - QDateTime created() const; - - void setUpdated( const QDateTime & ); - QDateTime updated() const; - - void addExtendedAttribute( const QString &key, const QString &value ); - QString extendedAttribute( const QString &key ) const; - - QMap extendedAttributes() const; - - private: - class Private; - QSharedDataPointer d; -}; - -} - -#endif diff --git a/amarok/src/aboutdialog/libattica-ocsclient/contentjob.cpp b/amarok/src/aboutdialog/libattica-ocsclient/contentjob.cpp deleted file mode 100644 index 40211c13..00000000 --- a/amarok/src/aboutdialog/libattica-ocsclient/contentjob.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/* - This file is part of KDE. - - Copyright (c) 2008 Cornelius Schumacher - - This program 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 2 of the License, or - (at your option) any later version. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - -#include "contentjob.h" - -#include "contentparser.h" - -#include -#include - -#include -#include - - -using namespace AmarokAttica; - -ContentJob::ContentJob() - : m_job( 0 ) -{ -} - -void ContentJob::setUrl( const KUrl &url ) -{ - m_url = url; -} - -void ContentJob::start() -{ - QTimer::singleShot( 0, this, SLOT(doWork()) ); -} - -Content ContentJob::content() const -{ - return m_content; -} - -void ContentJob::doWork() -{ - qDebug() << m_url; - - m_job = KIO::get( m_url, KIO::NoReload, KIO::HideProgressInfo ); - connect( m_job, SIGNAL(result(KJob*)), - SLOT(slotJobResult(KJob*)) ); - connect( m_job, SIGNAL(data(KIO::Job*,QByteArray)), - SLOT(slotJobData(KIO::Job*,QByteArray)) ); -} - -void ContentJob::slotJobResult( KJob *job ) -{ - m_job = 0; - - if ( job->error() ) { - setError( job->error() ); - setErrorText( job->errorText() ); - } else { - qDebug() << m_data; - m_content = ContentParser().parse( QString::fromUtf8( m_data.data() ) ); - } - - emitResult(); -} - -void ContentJob::slotJobData( KIO::Job *, const QByteArray &data ) -{ - m_data.append( data ); -} diff --git a/amarok/src/aboutdialog/libattica-ocsclient/contentjob.h b/amarok/src/aboutdialog/libattica-ocsclient/contentjob.h deleted file mode 100644 index a9db7d74..00000000 --- a/amarok/src/aboutdialog/libattica-ocsclient/contentjob.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - This file is part of KDE. - - Copyright (c) 2008 Cornelius Schumacher - - This program 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 2 of the License, or - (at your option) any later version. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. - */ -#ifndef ATTICA_CONTENTJOB_H -#define ATTICA_CONTENTJOB_H - -#include "content.h" - -#include -#include - -namespace KIO { -class Job; -} - -namespace AmarokAttica { - -class ATTICA_EXPORT ContentJob : public KJob -{ - Q_OBJECT - public: - ContentJob(); - - void setUrl( const KUrl & ); - - void start(); - - Content content() const; - - protected slots: - void doWork(); - - void slotJobResult( KJob *job ); - void slotJobData( KIO::Job *job, const QByteArray &data ); - - private: - KUrl m_url; - KIO::Job *m_job; - QByteArray m_data; - - Content m_content; -}; - -} - -#endif diff --git a/amarok/src/aboutdialog/libattica-ocsclient/contentlistjob.cpp b/amarok/src/aboutdialog/libattica-ocsclient/contentlistjob.cpp deleted file mode 100644 index 36e6bd65..00000000 --- a/amarok/src/aboutdialog/libattica-ocsclient/contentlistjob.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/* - This file is part of KDE. - - Copyright (c) 2008 Cornelius Schumacher - - This program 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 2 of the License, or - (at your option) any later version. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - -#include "contentlistjob.h" - -#include "contentparser.h" - -#include -#include - -#include -#include - - -using namespace AmarokAttica; - -ContentListJob::ContentListJob() - : m_job( 0 ) -{ -} - -void ContentListJob::setUrl( const KUrl &url ) -{ - m_url = url; -} - -void ContentListJob::start() -{ - QTimer::singleShot( 0, this, SLOT(doWork()) ); -} - -Content::List ContentListJob::contentList() const -{ - return m_contentList; -} - -void ContentListJob::doWork() -{ - qDebug() << m_url; - - m_job = KIO::get( m_url, KIO::NoReload, KIO::HideProgressInfo ); - connect( m_job, SIGNAL(result(KJob*)), - SLOT(slotJobResult(KJob*)) ); - connect( m_job, SIGNAL(data(KIO::Job*,QByteArray)), - SLOT(slotJobData(KIO::Job*,QByteArray)) ); -} - -void ContentListJob::slotJobResult( KJob *job ) -{ - m_job = 0; - - if ( job->error() ) { - setError( job->error() ); - setErrorText( job->errorText() ); - - emitResult(); - } else { - qDebug() << m_data; - m_contentList = ContentParser().parseList( - QString::fromUtf8( m_data.data() ) ); - - emitResult(); - } -} - -void ContentListJob::slotJobData( KIO::Job *, const QByteArray &data ) -{ - m_data.append( data ); -} diff --git a/amarok/src/aboutdialog/libattica-ocsclient/contentlistjob.h b/amarok/src/aboutdialog/libattica-ocsclient/contentlistjob.h deleted file mode 100644 index 600201fc..00000000 --- a/amarok/src/aboutdialog/libattica-ocsclient/contentlistjob.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - This file is part of KDE. - - Copyright (c) 2008 Cornelius Schumacher - - This program 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 2 of the License, or - (at your option) any later version. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. - */ -#ifndef ATTICA_CONTENTLISTJOB_H -#define ATTICA_CONTENTLISTJOB_H - -#include "content.h" - -#include -#include - -namespace KIO { -class Job; -} - -namespace AmarokAttica { - -class ATTICA_EXPORT ContentListJob : public KJob -{ - Q_OBJECT - public: - ContentListJob(); - - void setUrl( const KUrl & ); - - void start(); - - Content::List contentList() const; - - protected slots: - void doWork(); - - void slotJobResult( KJob *job ); - void slotJobData( KIO::Job *job, const QByteArray &data ); - - private: - KUrl m_url; - KIO::Job *m_job; - QByteArray m_data; - - Content::List m_contentList; -}; - -} - -#endif diff --git a/amarok/src/aboutdialog/libattica-ocsclient/contentparser.cpp b/amarok/src/aboutdialog/libattica-ocsclient/contentparser.cpp deleted file mode 100644 index a480382f..00000000 --- a/amarok/src/aboutdialog/libattica-ocsclient/contentparser.cpp +++ /dev/null @@ -1,100 +0,0 @@ -/* - This file is part of KDE. - - Copyright (c) 2008 Cornelius Schumacher - - This program 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 2 of the License, or - (at your option) any later version. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - -#include "contentparser.h" - -#include -#include - -using namespace AmarokAttica; - -ContentParser::ContentParser() -{ -} - -Content::List ContentParser::parseList( const QString &xmlString ) -{ - Content::List contentList; - - QXmlStreamReader xml( xmlString ); - - while ( !xml.atEnd() ) { - xml.readNext(); - - if ( xml.isStartElement() && xml.name() == "content" ) { - Content content = parseContent( xml ); - contentList.append( content ); - } - } - - return contentList; -} - -Content ContentParser::parse( const QString &xmlString ) -{ - Content content; - - QXmlStreamReader xml( xmlString ); - - while ( !xml.atEnd() ) { - xml.readNext(); - - if ( xml.isStartElement() && xml.name() == "content" ) { - content = parseContent( xml ); - } - } - - return content; -} - -Content ContentParser::parseContent( QXmlStreamReader &xml ) -{ - Content content; - - while ( !xml.atEnd() ) { - xml.readNext(); - - if ( xml.isStartElement() ) { - if ( xml.name() == "id" ) { - content.setId( xml.readElementText() ); - } else if ( xml.name() == "name" ) { - content.setName( xml.readElementText() ); - } else if ( xml.name() == "score" ) { - content.setRating( xml.readElementText().toInt() ); - } else if ( xml.name() == "downloads" ) { - content.setDownloads( xml.readElementText().toInt() ); - } else if ( xml.name() == "created" ) { - content.setCreated( QDateTime::fromString( xml.readElementText(), - Qt::ISODate ) ); - } else if ( xml.name() == "updated" ) { - content.setUpdated( QDateTime::fromString( xml.readElementText(), - Qt::ISODate ) ); - } else { - content.addExtendedAttribute( xml.name().toString(), - xml.readElementText() ); - } - } - - if ( xml.isEndElement() && xml.name() == "content" ) break; - } - - return content; -} diff --git a/amarok/src/aboutdialog/libattica-ocsclient/contentparser.h b/amarok/src/aboutdialog/libattica-ocsclient/contentparser.h deleted file mode 100644 index 76bb41d8..00000000 --- a/amarok/src/aboutdialog/libattica-ocsclient/contentparser.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - This file is part of KDE. - - Copyright (c) 2008 Cornelius Schumacher - - This program 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 2 of the License, or - (at your option) any later version. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ -#ifndef ATTICA_CONTENTPARSER_H -#define ATTICA_CONTENTPARSER_H - -#include "content.h" - -#include - -namespace AmarokAttica { - -class ContentParser -{ - public: - ContentParser(); - - Content parse( const QString &xml ); - Content::List parseList( const QString &xml ); - - protected: - Content parseContent( QXmlStreamReader &xml ); -}; - -} - -#endif diff --git a/amarok/src/aboutdialog/libattica-ocsclient/event.cpp b/amarok/src/aboutdialog/libattica-ocsclient/event.cpp deleted file mode 100644 index c1de98d8..00000000 --- a/amarok/src/aboutdialog/libattica-ocsclient/event.cpp +++ /dev/null @@ -1,168 +0,0 @@ -/* - This file is part of KDE. - - Copyright (c) 2009 Eckhart Wörner - - This program 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 2 of the License, or - (at your option) any later version. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - -#include "event.h" - - -using namespace AmarokAttica; - - -Event::Event() - : m_latitude(0), m_longitude(0) -{ -} - - -void Event::setId(const QString& id) -{ - m_id = id; -} - -QString Event::id() const -{ - return m_id; -} - - -void Event::setName(const QString& name) -{ - m_name = name; -} - -QString Event::name() const -{ - return m_name; -} - - -void Event::setDescription(const QString& text) -{ - m_description = text; -} - -QString Event::description() const -{ - return m_description; -} - - -void Event::setUser(const QString& id) -{ - m_user = id; -} - -QString Event::user() const -{ - return m_user; -} - - -void Event::setStartDate(const QDate& date) -{ - m_startDate = date; -} - -QDate Event::startDate() const -{ - return m_startDate; -} - - -void Event::setEndDate(const QDate& date) -{ - m_endDate = date; -} - -QDate Event::endDate() const -{ - return m_endDate; -} - - -void Event::setLatitude(qreal lat) -{ - m_latitude = lat; -} - -qreal Event::latitude() const -{ - return m_latitude; -} - - -void Event::setLongitude(qreal lon) -{ - m_longitude = lon; -} - -qreal Event::longitude() const -{ - return m_longitude; -} - - -void Event::setHomepage(const QString& url) -{ - m_homepage = url; -} - -QString Event::homepage() const -{ - return m_homepage; -} - - -void Event::setCountry(const QString& country) -{ - m_country = country; -} - -QString Event::country() const -{ - return m_country; -} - - -void Event::setCity(const QString& city) -{ - m_city = city; -} - -QString Event::city() const -{ - return m_city; -} - - -void Event::addExtendedAttribute(const QString& key, const QString& value) -{ - m_extendedAttributes.insert(key, value); -} - -QString Event::extendedAttribute(const QString& key) const -{ - return m_extendedAttributes.value(key); -} - -QMap Event::extendedAttributes() const -{ - return m_extendedAttributes; -} diff --git a/amarok/src/aboutdialog/libattica-ocsclient/event.h b/amarok/src/aboutdialog/libattica-ocsclient/event.h deleted file mode 100644 index c8d0c93f..00000000 --- a/amarok/src/aboutdialog/libattica-ocsclient/event.h +++ /dev/null @@ -1,96 +0,0 @@ -/* - This file is part of KDE. - - Copyright (c) 2009 Eckhart Wörner - - This program 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 2 of the License, or - (at your option) any later version. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - -#ifndef ATTICA_EVENT_H -#define ATTICA_EVENT_H - -#include "atticaclient_export.h" - -#include -#include -#include - - -namespace AmarokAttica { - -class ATTICA_EXPORT Event -{ - public: - typedef QList List; - - Event(); - - void setId(const QString& id); - QString id() const; - - void setName(const QString& name); - QString name() const; - - void setDescription(const QString& text); - QString description() const; - - void setUser(const QString& id); - QString user() const; - - void setStartDate(const QDate& date); - QDate startDate() const; - - void setEndDate(const QDate& date); - QDate endDate() const; - - void setLatitude(qreal lat); - qreal latitude() const; - - void setLongitude(qreal lon); - qreal longitude() const; - - void setHomepage(const QString& url); - QString homepage() const; - - void setCountry(const QString& country); - QString country() const; - - void setCity(const QString& city); - QString city() const; - - void addExtendedAttribute(const QString& key, const QString& value); - QString extendedAttribute(const QString& key) const; - QMap extendedAttributes() const; - - private: - QString m_id; - QString m_name; - QString m_description; - QString m_user; - QDate m_startDate; - QDate m_endDate; - qreal m_latitude; - qreal m_longitude; - QString m_homepage; - QString m_country; - QString m_city; - QMap m_extendedAttributes; -}; - -} - - -#endif diff --git a/amarok/src/aboutdialog/libattica-ocsclient/eventjob.cpp b/amarok/src/aboutdialog/libattica-ocsclient/eventjob.cpp deleted file mode 100644 index 4ea93398..00000000 --- a/amarok/src/aboutdialog/libattica-ocsclient/eventjob.cpp +++ /dev/null @@ -1,92 +0,0 @@ -/* - This file is part of KDE. - - Copyright (c) 2009 Eckhart Wörner - - This program 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 2 of the License, or - (at your option) any later version. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - -#include "eventjob.h" - -#include - -#include - -#include "eventparser.h" - - -using namespace AmarokAttica; - - -EventJob::EventJob() - : m_job(0) -{ -} - - -void EventJob::setUrl(const KUrl& url) -{ - m_url = url; -} - - -void EventJob::start() -{ - QTimer::singleShot(0, this, SLOT(doWork())); -} - - -Event EventJob::event() const -{ - return m_event; -} - - -void EventJob::doWork() -{ - m_job = KIO::get(m_url, KIO::NoReload, KIO::HideProgressInfo); - connect(m_job, SIGNAL(result(KJob*)), SLOT(slotJobResult(KJob*))); - connect(m_job, SIGNAL(data(KIO::Job*,QByteArray)), - SLOT(slotJobData(KIO::Job*,QByteArray))); -} - - -void EventJob::slotJobResult(KJob* job) -{ - m_job = 0; - - if (job->error()) { - setError(job->error()); - setErrorText(job->errorText()); - - emitResult(); - } else { - m_event = EventParser().parse(QString::fromUtf8(m_data.data())); - - emitResult(); - } -} - - -void EventJob::slotJobData(KIO::Job* job, const QByteArray& data) -{ - Q_UNUSED(job); - - m_data.append(data); -} - - -#include "moc_eventjob.cpp" diff --git a/amarok/src/aboutdialog/libattica-ocsclient/eventjob.h b/amarok/src/aboutdialog/libattica-ocsclient/eventjob.h deleted file mode 100644 index d0c05b6d..00000000 --- a/amarok/src/aboutdialog/libattica-ocsclient/eventjob.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - This file is part of KDE. - - Copyright (c) 2009 Eckhart Wörner - - This program 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 2 of the License, or - (at your option) any later version. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - -#ifndef ATTICA_EVENTJOB_H -#define ATTICA_EVENTJOB_H - -#include -#include - -#include "atticaclient_export.h" -#include "event.h" - - -namespace KIO { - class Job; -} - -namespace AmarokAttica { - -class ATTICA_EXPORT EventJob : public KJob -{ - Q_OBJECT - - public: - EventJob(); - - void setUrl(const KUrl& url); - - void start(); - - Event event() const; - using QObject::event; // Unhide QObject's event() - - protected slots: - void doWork(); - - void slotJobResult(KJob* job); - void slotJobData(KIO::Job* job, const QByteArray& data); - - private: - KUrl m_url; - KIO::Job* m_job; - QByteArray m_data; - - Event m_event; -}; - -} - - -#endif diff --git a/amarok/src/aboutdialog/libattica-ocsclient/eventlistjob.cpp b/amarok/src/aboutdialog/libattica-ocsclient/eventlistjob.cpp deleted file mode 100644 index 6f83cd2c..00000000 --- a/amarok/src/aboutdialog/libattica-ocsclient/eventlistjob.cpp +++ /dev/null @@ -1,92 +0,0 @@ -/* - This file is part of KDE. - - Copyright (c) 2009 Eckhart Wörner - - This program 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 2 of the License, or - (at your option) any later version. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - -#include "eventlistjob.h" - -#include - -#include - -#include "eventparser.h" - - -using namespace AmarokAttica; - - -EventListJob::EventListJob() - : m_job(0) -{ -} - - -void EventListJob::setUrl(const KUrl& url) -{ - m_url = url; -} - - -void EventListJob::start() -{ - QTimer::singleShot(0, this, SLOT(doWork())); -} - - -Event::List EventListJob::eventList() const -{ - return m_eventList; -} - - -void EventListJob::doWork() -{ - m_job = KIO::get(m_url, KIO::NoReload, KIO::HideProgressInfo); - connect(m_job, SIGNAL(result(KJob*)), SLOT(slotJobResult(KJob*))); - connect(m_job, SIGNAL(data(KIO::Job*,QByteArray)), - SLOT(slotJobData(KIO::Job*,QByteArray))); -} - - -void EventListJob::slotJobResult(KJob* job) -{ - m_job = 0; - - if (job->error()) { - setError(job->error()); - setErrorText(job->errorText()); - - emitResult(); - } else { - m_eventList = EventParser().parseList(QString::fromUtf8(m_data.data())); - - emitResult(); - } -} - - -void EventListJob::slotJobData(KIO::Job* job, const QByteArray& data) -{ - Q_UNUSED(job); - - m_data.append(data); -} - - -#include "moc_eventlistjob.cpp" diff --git a/amarok/src/aboutdialog/libattica-ocsclient/eventlistjob.h b/amarok/src/aboutdialog/libattica-ocsclient/eventlistjob.h deleted file mode 100644 index 94157ff3..00000000 --- a/amarok/src/aboutdialog/libattica-ocsclient/eventlistjob.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - This file is part of KDE. - - Copyright (c) 2009 Eckhart Wörner - - This program 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 2 of the License, or - (at your option) any later version. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - -#ifndef ATTICA_EVENTLISTJOB_H -#define ATTICA_EVENTLISTJOB_H - -#include -#include - -#include "atticaclient_export.h" -#include "event.h" - - -namespace KIO { - class Job; -} - -namespace AmarokAttica { - -class ATTICA_EXPORT EventListJob : public KJob -{ - Q_OBJECT - - public: - EventListJob(); - - void setUrl(const KUrl& url); - - void start(); - - Event::List eventList() const; - - protected slots: - void doWork(); - - void slotJobResult(KJob* job); - void slotJobData(KIO::Job* job, const QByteArray& data); - - private: - KUrl m_url; - KIO::Job* m_job; - QByteArray m_data; - - Event::List m_eventList; -}; - -} - - -#endif diff --git a/amarok/src/aboutdialog/libattica-ocsclient/eventparser.cpp b/amarok/src/aboutdialog/libattica-ocsclient/eventparser.cpp deleted file mode 100644 index 5c58f8aa..00000000 --- a/amarok/src/aboutdialog/libattica-ocsclient/eventparser.cpp +++ /dev/null @@ -1,112 +0,0 @@ -/* - This file is part of KDE. - - Copyright (c) 2009 Eckhart Wörner - - This program 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 2 of the License, or - (at your option) any later version. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - -#include "eventparser.h" - -#include -#include - - -using namespace AmarokAttica; - -EventParser::EventParser() -{ -} - - -Event EventParser::parse(const QString& xmlString) -{ - Event event; - - QXmlStreamReader xml(xmlString); - - while (!xml.atEnd()) { - xml.readNext(); - - if (xml.isStartElement() && xml.name() == "event") { - event = parseEvent(xml); - } - } - - return event; -} - - -Event::List AmarokAttica::EventParser::parseList(const QString& xmlString) -{ - Event::List eventList; - - QXmlStreamReader xml(xmlString); - - while (!xml.atEnd()) { - xml.readNext(); - - if (xml.isStartElement() && xml.name() == "event") { - eventList.append(parseEvent(xml)); - } - } - - return eventList; -} - - -Event EventParser::parseEvent(QXmlStreamReader& xml) -{ - Event event; - - while (!xml.atEnd()) { - xml.readNext(); - - if (xml.isStartElement()) { - if (xml.name() == "id") { - event.setId(xml.readElementText()); - } else if (xml.name() == "name") { - event.setName(xml.readElementText()); - } else if (xml.name() == "description") { - event.setDescription(xml.readElementText()); - } else if (xml.name() == "user") { - event.setUser(xml.readElementText()); - } else if (xml.name() == "startdate") { - QString date = xml.readElementText().remove(QRegExp("\\+.*$")); - event.setStartDate(QDate::fromString(date, Qt::ISODate)); - } else if (xml.name() == "enddate") { - QString date = xml.readElementText().remove(QRegExp("\\+.*$")); - event.setEndDate(QDate::fromString(date, Qt::ISODate)); - } else if (xml.name() == "latitude") { - event.setLatitude(xml.readElementText().toFloat()); - } else if (xml.name() == "longitude") { - event.setLongitude(xml.readElementText().toFloat()); - } else if (xml.name() == "homepage") { - event.setHomepage(xml.readElementText()); - } else if (xml.name() == "country") { - event.setCountry(xml.readElementText()); - } else if (xml.name() == "city") { - event.setCity(xml.readElementText()); - } else { - event.addExtendedAttribute(xml.name().toString(), xml.readElementText()); - } - } - else if (xml.isEndElement() && xml.name() == "event") { - break; - } - } - return event; -} diff --git a/amarok/src/aboutdialog/libattica-ocsclient/eventparser.h b/amarok/src/aboutdialog/libattica-ocsclient/eventparser.h deleted file mode 100644 index b42628de..00000000 --- a/amarok/src/aboutdialog/libattica-ocsclient/eventparser.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - This file is part of KDE. - - Copyright (c) 2009 Eckhart Wörner - - This program 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 2 of the License, or - (at your option) any later version. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - -#ifndef ATTICA_EVENTPARSER_H -#define ATTICA_EVENTPARSER_H - -#include "event.h" - -#include - -namespace AmarokAttica { - -class EventParser -{ - public: - EventParser(); - - Event parse(const QString& xml); - Event::List parseList(const QString& xml); - - private: - Event parseEvent(QXmlStreamReader& xml); -}; - -} - - -#endif diff --git a/amarok/src/aboutdialog/libattica-ocsclient/folder.cpp b/amarok/src/aboutdialog/libattica-ocsclient/folder.cpp deleted file mode 100644 index 25958973..00000000 --- a/amarok/src/aboutdialog/libattica-ocsclient/folder.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/* - This file is part of KDE. - - Copyright (c) 2008 Cornelius Schumacher - - This program 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 2 of the License, or - (at your option) any later version. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - -#include "folder.h" - -using namespace AmarokAttica; - -Folder::Folder() - : m_messageCount( 0 ) -{ -} - -void Folder::setId( const QString &u ) -{ - m_id = u; -} - -QString Folder::id() const -{ - return m_id; -} - -void Folder::setName( const QString &d ) -{ - m_name = d; -} - -QString Folder::name() const -{ - return m_name; -} - -void Folder::setMessageCount( int c ) -{ - m_messageCount = c; -} - -int Folder::messageCount() const -{ - return m_messageCount; -} - -void Folder::setType( const QString &v ) -{ - m_type = v; -} - -QString Folder::type() const -{ - return m_type; -} diff --git a/amarok/src/aboutdialog/libattica-ocsclient/folder.h b/amarok/src/aboutdialog/libattica-ocsclient/folder.h deleted file mode 100644 index bf4b621a..00000000 --- a/amarok/src/aboutdialog/libattica-ocsclient/folder.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - This file is part of KDE. - - Copyright (c) 2008 Cornelius Schumacher - - This program 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 2 of the License, or - (at your option) any later version. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ -#ifndef ATTICA_FOLDER_H -#define ATTICA_FOLDER_H - -#include "atticaclient_export.h" -#include -#include -namespace AmarokAttica { - -class ATTICA_EXPORT Folder -{ - public: - typedef QList List; - - Folder(); - - void setId( const QString & ); - QString id() const; - - void setName( const QString & ); - QString name() const; - - void setMessageCount( int ); - int messageCount() const; - - void setType( const QString & ); - QString type() const; - - private: - QString m_id; - QString m_name; - int m_messageCount; - QString m_type; -}; - -} - -#endif diff --git a/amarok/src/aboutdialog/libattica-ocsclient/folderlistjob.cpp b/amarok/src/aboutdialog/libattica-ocsclient/folderlistjob.cpp deleted file mode 100644 index 06487a8f..00000000 --- a/amarok/src/aboutdialog/libattica-ocsclient/folderlistjob.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/* - This file is part of KDE. - - Copyright (c) 2008 Cornelius Schumacher - - This program 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 2 of the License, or - (at your option) any later version. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - -#include "folderlistjob.h" - -#include "folderparser.h" - -#include -#include -#include -#include - -using namespace AmarokAttica; - -FolderListJob::FolderListJob() - : m_job( 0 ) -{ -} - -void FolderListJob::setUrl( const KUrl &url ) -{ - m_url = url; -} - -void FolderListJob::start() -{ - QTimer::singleShot( 0, this, SLOT(doWork()) ); -} - -Folder::List FolderListJob::folderList() const -{ - return m_folderList; -} - -void FolderListJob::doWork() -{ - qDebug() << m_url; - - m_job = KIO::get( m_url, KIO::NoReload, KIO::HideProgressInfo ); - connect( m_job, SIGNAL(result(KJob*)), - SLOT(slotJobResult(KJob*)) ); - connect( m_job, SIGNAL(data(KIO::Job*,QByteArray)), - SLOT(slotJobData(KIO::Job*,QByteArray)) ); -} - -void FolderListJob::slotJobResult( KJob *job ) -{ - m_job = 0; - - if ( job->error() ) { - setError( job->error() ); - setErrorText( job->errorText() ); - - emitResult(); - } else { - qDebug() << m_data; - m_folderList = FolderParser().parseList( - QString::fromUtf8( m_data.data() ) ); - - emitResult(); - } -} - -void FolderListJob::slotJobData( KIO::Job *, const QByteArray &data ) -{ - m_data.append( data ); -} diff --git a/amarok/src/aboutdialog/libattica-ocsclient/folderlistjob.h b/amarok/src/aboutdialog/libattica-ocsclient/folderlistjob.h deleted file mode 100644 index bfdbf2ee..00000000 --- a/amarok/src/aboutdialog/libattica-ocsclient/folderlistjob.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - This file is part of KDE. - - Copyright (c) 2008 Cornelius Schumacher - - This program 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 2 of the License, or - (at your option) any later version. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ -#ifndef ATTICA_FOLDERLISTJOB_H -#define ATTICA_FOLDERLISTJOB_H - -#include "folder.h" - -#include -#include - -namespace KIO { -class Job; -} - -namespace AmarokAttica { - -class ATTICA_EXPORT FolderListJob : public KJob -{ - Q_OBJECT - public: - FolderListJob(); - - void setUrl( const KUrl & ); - - void start(); - - Folder::List folderList() const; - - protected slots: - void doWork(); - - void slotJobResult( KJob *job ); - void slotJobData( KIO::Job *job, const QByteArray &data ); - - private: - KUrl m_url; - KIO::Job *m_job; - QByteArray m_data; - - Folder::List m_folderList; -}; - -} - -#endif diff --git a/amarok/src/aboutdialog/libattica-ocsclient/folderparser.cpp b/amarok/src/aboutdialog/libattica-ocsclient/folderparser.cpp deleted file mode 100644 index f83010b1..00000000 --- a/amarok/src/aboutdialog/libattica-ocsclient/folderparser.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/* - This file is part of KDE. - - Copyright (c) 2008 Cornelius Schumacher - - This program 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 2 of the License, or - (at your option) any later version. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - -#include "folderparser.h" - -#include - -using namespace AmarokAttica; - -FolderParser::FolderParser() -{ -} - -Folder::List FolderParser::parseList( const QString &xmlString ) -{ - Folder::List folderList; - - QXmlStreamReader xml( xmlString ); - - while ( !xml.atEnd() ) { - xml.readNext(); - - if ( xml.isStartElement() && xml.name() == "folder" ) { - Folder folder; - - while ( !xml.atEnd() ) { - xml.readNext(); - - if ( xml.isStartElement() ) { - if ( xml.name() == "id" ) { - folder.setId( xml.readElementText() ); - } else if ( xml.name() == "name" ) { - folder.setName( xml.readElementText() ); - } else if ( xml.name() == "messagecount" ) { - folder.setMessageCount( xml.readElementText().toInt() ); - } else if ( xml.name() == "type" ) { - folder.setType( xml.readElementText() ); - } - } - - if ( xml.isEndElement() && xml.name() == "folder" ) break; - } - - folderList.append( folder ); - } - } - - return folderList; -} diff --git a/amarok/src/aboutdialog/libattica-ocsclient/folderparser.h b/amarok/src/aboutdialog/libattica-ocsclient/folderparser.h deleted file mode 100644 index e6e4be40..00000000 --- a/amarok/src/aboutdialog/libattica-ocsclient/folderparser.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - This file is part of KDE. - - Copyright (c) 2008 Cornelius Schumacher - - This program 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 2 of the License, or - (at your option) any later version. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ -#ifndef ATTICA_FOLDERPARSER_H -#define ATTICA_FOLDERPARSER_H - -#include "folder.h" - - -namespace AmarokAttica { - -class FolderParser -{ - public: - FolderParser(); - - Folder::List parseList( const QString &xml ); -}; - -} - -#endif diff --git a/amarok/src/aboutdialog/libattica-ocsclient/knowledgebase.cpp b/amarok/src/aboutdialog/libattica-ocsclient/knowledgebase.cpp deleted file mode 100644 index 0758507b..00000000 --- a/amarok/src/aboutdialog/libattica-ocsclient/knowledgebase.cpp +++ /dev/null @@ -1,156 +0,0 @@ -/*************************************************************************** - * This file is part of KDE. * - * Copyright (C) 2009 Marco Martin * - * * - * This program 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 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * - ***************************************************************************/ - - - -#include "knowledgebase.h" - -using namespace AmarokAttica; - -KnowledgeBase::KnowledgeBase() - : m_contentId(0), - m_comments(0) -{ -} - - -void KnowledgeBase::setId(QString id) -{ - m_id = id; -} - -QString KnowledgeBase::id() const -{ - return m_id; -} - - -void KnowledgeBase::setContentId(int id) -{ - m_contentId = id; -} - -int KnowledgeBase::contentId() const -{ - return m_contentId; -} - - -void KnowledgeBase::setUser(const QString &user) -{ - m_user = user; -} - -QString KnowledgeBase::user() const -{ - return m_user; -} - - -void KnowledgeBase::setStatus(const QString status) -{ - m_status = status; -} - -QString KnowledgeBase::status() const -{ - return m_status; -} - - -void KnowledgeBase::setChanged(const QDateTime &changed) -{ - m_changed = changed; -} - -QDateTime KnowledgeBase::changed() const -{ - return m_changed; -} - - -void KnowledgeBase::setName(const QString &name) -{ - m_name = name; -} - -QString KnowledgeBase::name() const -{ - return m_name; -} - - -void KnowledgeBase::setDescription(const QString &description) -{ - m_description = description; -} - -QString KnowledgeBase::description() const -{ - return m_description; -} - - -void KnowledgeBase::setAnswer(const QString &answer) -{ - m_answer = answer; -} - -QString KnowledgeBase::answer() const -{ - return m_answer; -} - - -void KnowledgeBase::setComments(int comments) -{ - m_comments = comments; -} - -int KnowledgeBase::comments() const -{ - return m_comments; -} - - -void KnowledgeBase::setDetailPage(const KUrl &detailPage) -{ - m_detailPage = detailPage; -} - -KUrl KnowledgeBase::detailPage() const -{ - return m_detailPage; -} - -void KnowledgeBase::addExtendedAttribute( const QString &key, const QString &value ) -{ - m_extendedAttributes.insert( key, value ); -} - -QString KnowledgeBase::extendedAttribute( const QString &key ) const -{ - return m_extendedAttributes.value( key ); -} - -QMap KnowledgeBase::extendedAttributes() const -{ - return m_extendedAttributes; -} diff --git a/amarok/src/aboutdialog/libattica-ocsclient/knowledgebase.h b/amarok/src/aboutdialog/libattica-ocsclient/knowledgebase.h deleted file mode 100644 index a6afb564..00000000 --- a/amarok/src/aboutdialog/libattica-ocsclient/knowledgebase.h +++ /dev/null @@ -1,99 +0,0 @@ -/*************************************************************************** - * This file is part of KDE. * - * Copyright (C) 2009 Marco Martin * - * * - * This program 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 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * - ***************************************************************************/ - -#ifndef ATTICA_KNOWLEDGEBASE_H -#define ATTICA_KNOWLEDGEBASE_H - -#include "atticaclient_export.h" - -#include -#include - -namespace AmarokAttica -{ - -class ATTICA_EXPORT KnowledgeBase -{ - public: - typedef QList List; - struct Metadata - { - QString status; - QString message; - int totalItems; - int itemsPerPage; - }; - - KnowledgeBase(); - - void setId(QString id); - QString id() const; - - void setContentId(int id); - int contentId() const; - - void setUser(const QString &user); - QString user() const; - - void setStatus(const QString status); - QString status() const; - - void setChanged(const QDateTime &changed); - QDateTime changed() const; - - void setName(const QString &name); - QString name() const; - - void setDescription(const QString &description); - QString description() const; - - void setAnswer(const QString &answer); - QString answer() const; - - void setComments(int comments); - int comments() const; - - void setDetailPage(const KUrl &detailPage); - KUrl detailPage() const; - - void addExtendedAttribute( const QString &key, const QString &value ); - QString extendedAttribute( const QString &key ) const; - - QMap extendedAttributes() const; - - private: - QString m_id; - int m_contentId; - QString m_user; - QString m_status; - QDateTime m_changed; - QString m_name; - QString m_description; - QString m_answer; - int m_comments; - KUrl m_detailPage; - - QMap m_extendedAttributes; -}; - -} - -#endif - diff --git a/amarok/src/aboutdialog/libattica-ocsclient/knowledgebasejob.cpp b/amarok/src/aboutdialog/libattica-ocsclient/knowledgebasejob.cpp deleted file mode 100644 index 0d7460b0..00000000 --- a/amarok/src/aboutdialog/libattica-ocsclient/knowledgebasejob.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/* - This file is part of KDE. - - Copyright (c) 2008 Cornelius Schumacher - Copyright (c) 2009 Marco Martin - - This program 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 2 of the License, or - (at your option) any later version. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - -#include "knowledgebasejob.h" - -#include "knowledgebaseparser.h" - -#include -#include -#include -#include - -using namespace AmarokAttica; - -KnowledgeBaseJob::KnowledgeBaseJob() - : m_job( 0 ) -{ -} - -void KnowledgeBaseJob::setUrl( const KUrl &url ) -{ - m_url = url; -} - -void KnowledgeBaseJob::start() -{ - QTimer::singleShot( 0, this, SLOT(doWork()) ); -} - -KnowledgeBase KnowledgeBaseJob::knowledgeBase() const -{ - return m_knowledgeBase; -} - -KnowledgeBase::Metadata KnowledgeBaseJob::metadata() const -{ - return m_metadata; -} - -void KnowledgeBaseJob::doWork() -{ - qDebug() << m_url; - - m_job = KIO::get( m_url, KIO::NoReload, KIO::HideProgressInfo ); - connect( m_job, SIGNAL(result(KJob*)), - SLOT(slotJobResult(KJob*)) ); - connect( m_job, SIGNAL(data(KIO::Job*,QByteArray)), - SLOT(slotJobData(KIO::Job*,QByteArray)) ); -} - -void KnowledgeBaseJob::slotJobResult( KJob *job ) -{ - m_job = 0; - - if ( job->error() ) { - setError( job->error() ); - setErrorText( job->errorText() ); - } else { - qDebug() << m_data; - KnowledgeBaseParser parser; - m_knowledgeBase = parser.parse( QString::fromUtf8( m_data.data() ) ); - m_metadata = parser.lastMetadata(); - } - - emitResult(); -} - -void KnowledgeBaseJob::slotJobData( KIO::Job *, const QByteArray &data ) -{ - m_data.append( data ); -} - diff --git a/amarok/src/aboutdialog/libattica-ocsclient/knowledgebasejob.h b/amarok/src/aboutdialog/libattica-ocsclient/knowledgebasejob.h deleted file mode 100644 index dfa11941..00000000 --- a/amarok/src/aboutdialog/libattica-ocsclient/knowledgebasejob.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - This file is part of KDE. - - Copyright (c) 2008 Cornelius Schumacher - Copyright (c) 2009 Marco Martin - - This program 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 2 of the License, or - (at your option) any later version. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. - */ -#ifndef ATTICA_KNOWLEDGEBASEJOB_H -#define ATTICA_KNOWLEDGEBASEJOB_H - -#include "knowledgebase.h" - -#include - -namespace KIO { -class Job; -} - -namespace AmarokAttica { - -class ATTICA_EXPORT KnowledgeBaseJob : public KJob -{ - Q_OBJECT - public: - KnowledgeBaseJob(); - - void setUrl( const KUrl & ); - - void start(); - - KnowledgeBase knowledgeBase() const; - KnowledgeBase::Metadata metadata() const; - - protected slots: - void doWork(); - - void slotJobResult( KJob *job ); - void slotJobData( KIO::Job *job, const QByteArray &data ); - - private: - KUrl m_url; - KIO::Job *m_job; - QByteArray m_data; - - KnowledgeBase m_knowledgeBase; - KnowledgeBase::Metadata m_metadata; -}; - -} - -#endif diff --git a/amarok/src/aboutdialog/libattica-ocsclient/knowledgebaselistjob.cpp b/amarok/src/aboutdialog/libattica-ocsclient/knowledgebaselistjob.cpp deleted file mode 100644 index c685a714..00000000 --- a/amarok/src/aboutdialog/libattica-ocsclient/knowledgebaselistjob.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/* - This file is part of KDE. - - Copyright (c) 2008 Cornelius Schumacher - Copyright (c) 2009 Marco Martin - - This program 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 2 of the License, or - (at your option) any later version. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - -#include "knowledgebaselistjob.h" - -#include "knowledgebaseparser.h" - -#include -#include -#include -#include - -using namespace AmarokAttica; - -KnowledgeBaseListJob::KnowledgeBaseListJob() - : m_job( 0 ) -{ -} - -void KnowledgeBaseListJob::setUrl( const KUrl &url ) -{ - m_url = url; -} - -void KnowledgeBaseListJob::start() -{ - QTimer::singleShot( 0, this, SLOT(doWork()) ); -} - -KnowledgeBase::List KnowledgeBaseListJob::knowledgeBaseList() const -{ - return m_knowledgeBaseList; -} - -KnowledgeBase::Metadata KnowledgeBaseListJob::metadata() const -{ - return m_metadata; -} - -void KnowledgeBaseListJob::doWork() -{ - qDebug() << m_url; - - m_job = KIO::get( m_url, KIO::NoReload, KIO::HideProgressInfo ); - connect( m_job, SIGNAL(result(KJob*)), - SLOT(slotJobResult(KJob*)) ); - connect( m_job, SIGNAL(data(KIO::Job*,QByteArray)), - SLOT(slotJobData(KIO::Job*,QByteArray)) ); -} - -void KnowledgeBaseListJob::slotJobResult( KJob *job ) -{ - m_job = 0; - - if ( job->error() ) { - setError( job->error() ); - setErrorText( job->errorText() ); - - emitResult(); - } else { - qDebug() << m_data; - KnowledgeBaseParser parser; - m_knowledgeBaseList = parser.parseList( - QString::fromUtf8( m_data.data() ) ); - m_metadata = parser.lastMetadata(); - - emitResult(); - } -} - -void KnowledgeBaseListJob::slotJobData( KIO::Job *, const QByteArray &data ) -{ - m_data.append( data ); -} diff --git a/amarok/src/aboutdialog/libattica-ocsclient/knowledgebaselistjob.h b/amarok/src/aboutdialog/libattica-ocsclient/knowledgebaselistjob.h deleted file mode 100644 index 49125a9c..00000000 --- a/amarok/src/aboutdialog/libattica-ocsclient/knowledgebaselistjob.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - This file is part of KDE. - - Copyright (c) 2008 Cornelius Schumacher - Copyright (c) 2009 Marco Martin - - This program 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 2 of the License, or - (at your option) any later version. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. - */ -#ifndef ATTICA_KNOWLEDGEBASELISTJOB_H -#define ATTICA_KNOWLEDGEBASELISTJOB_H - -#include "knowledgebase.h" - -#include -#include - -namespace KIO { -class Job; -} - -namespace AmarokAttica { - -class ATTICA_EXPORT KnowledgeBaseListJob : public KJob -{ - Q_OBJECT - public: - KnowledgeBaseListJob(); - - void setUrl( const KUrl & ); - - void start(); - - KnowledgeBase::List knowledgeBaseList() const; - KnowledgeBase::Metadata metadata() const; - - protected slots: - void doWork(); - - void slotJobResult( KJob *job ); - void slotJobData( KIO::Job *job, const QByteArray &data ); - - private: - KUrl m_url; - KIO::Job *m_job; - QByteArray m_data; - - KnowledgeBase::List m_knowledgeBaseList; - KnowledgeBase::Metadata m_metadata; -}; - -} - -#endif diff --git a/amarok/src/aboutdialog/libattica-ocsclient/knowledgebaseparser.cpp b/amarok/src/aboutdialog/libattica-ocsclient/knowledgebaseparser.cpp deleted file mode 100644 index aa620b57..00000000 --- a/amarok/src/aboutdialog/libattica-ocsclient/knowledgebaseparser.cpp +++ /dev/null @@ -1,152 +0,0 @@ -/* - This file is part of KDE. - - Copyright (c) 2008 Cornelius Schumacher - Copyright (c) 2009 Marco Martin - - This program 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 2 of the License, or - (at your option) any later version. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - -#include "knowledgebaseparser.h" - -#include - -using namespace AmarokAttica; - -KnowledgeBaseParser::KnowledgeBaseParser() -{ -} - -KnowledgeBase::List KnowledgeBaseParser::parseList( const QString &xmlString ) -{ - KnowledgeBase::List KnowledgeBaseList; - - QXmlStreamReader xml( xmlString ); - - m_lastMetadata = parseMetadata(xml); - - while ( !xml.atEnd() ) { - xml.readNext(); - - if ( xml.isStartElement() && xml.name() == "content" ) { - KnowledgeBase KnowledgeBase = parseKnowledgeBase( xml ); - KnowledgeBaseList.append( KnowledgeBase ); - } - } - - return KnowledgeBaseList; -} - -KnowledgeBase KnowledgeBaseParser::parse( const QString &xmlString ) -{ - KnowledgeBase knowledgeBase; - - QXmlStreamReader xml( xmlString ); - - m_lastMetadata = parseMetadata(xml); - - while ( !xml.atEnd() ) { - xml.readNext(); - - if ( xml.isStartElement() && xml.name() == "knowledgebase" ) { - knowledgeBase = parseKnowledgeBase( xml ); - } - } - - return knowledgeBase; -} - -KnowledgeBase::Metadata KnowledgeBaseParser::lastMetadata() -{ - return m_lastMetadata; -} - -KnowledgeBase::Metadata KnowledgeBaseParser::parseMetadata( QXmlStreamReader &xml ) -{ - KnowledgeBase::Metadata meta; - meta.status.clear(); - meta.message.clear(); - meta.totalItems = 0; - meta.itemsPerPage = 0; - - while ( !xml.atEnd() ) { - xml.readNext(); - if (xml.isStartElement() && xml.name() == "meta") { - while ( !xml.atEnd() ) { - xml.readNext(); - if (xml.isEndElement() && xml.name() == "meta") { - break; - } else if (xml.isStartElement()) { - if (xml.name() == "status") { - meta.status = xml.readElementText(); - } else if (xml.name() == "message") { - meta.message = xml.readElementText(); - } else if (xml.name() == "totalitems") { - meta.totalItems = xml.readElementText().toInt(); - } else if (xml.name() == "itemsperpage") { - meta.itemsPerPage = xml.readElementText().toInt(); - } - } - } - break; - } - } - - return meta; -} - -KnowledgeBase KnowledgeBaseParser::parseKnowledgeBase( QXmlStreamReader &xml ) -{ - KnowledgeBase knowledgeBase; - - while ( !xml.atEnd() ) { - xml.readNext(); - - if ( xml.isStartElement() ) { - if ( xml.name() == "id" ) { - knowledgeBase.setId( xml.readElementText() ); - } else if ( xml.name() == "status" ) { - knowledgeBase.setStatus( xml.readElementText() ); - } else if ( xml.name() == "contentId" ) { - knowledgeBase.setContentId( xml.readElementText().toInt() ); - } else if ( xml.name() == "user" ) { - knowledgeBase.setUser( xml.readElementText() ); - } else if ( xml.name() == "changed" ) { - knowledgeBase.setChanged( QDateTime::fromString( xml.readElementText(), - Qt::ISODate ) ); - } else if ( xml.name() == "description" ) { - knowledgeBase.setDescription( xml.readElementText() ); - } else if ( xml.name() == "answer" ) { - knowledgeBase.setAnswer( xml.readElementText() ); - } else if ( xml.name() == "comments" ) { - knowledgeBase.setComments( xml.readElementText().toInt() ); - } else if ( xml.name() == "detailpage" ) { - knowledgeBase.setDetailPage( KUrl(xml.readElementText()) ); - } else if ( xml.name() == "contentid" ) { - knowledgeBase.setContentId( xml.readElementText().toInt() ); - } else if ( xml.name() == "name" ) { - knowledgeBase.setName( xml.readElementText() ); - } else { - knowledgeBase.addExtendedAttribute( xml.name().toString(), - xml.readElementText() ); - } - } - - if ( xml.isEndElement() && xml.name() == "content" ) break; - } - - return knowledgeBase; -} diff --git a/amarok/src/aboutdialog/libattica-ocsclient/knowledgebaseparser.h b/amarok/src/aboutdialog/libattica-ocsclient/knowledgebaseparser.h deleted file mode 100644 index 9badab14..00000000 --- a/amarok/src/aboutdialog/libattica-ocsclient/knowledgebaseparser.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - This file is part of KDE. - - Copyright (c) 2008 Cornelius Schumacher - Copyright (c) 2009 Marco Martin - - This program 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 2 of the License, or - (at your option) any later version. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ -#ifndef ATTICA_KNOWLEDGEBASEPARSER_H -#define ATTICA_KNOWLEDGEBASEPARSER_H - -#include "knowledgebase.h" - -#include - -namespace AmarokAttica { - -class KnowledgeBaseParser -{ - public: - KnowledgeBaseParser(); - - KnowledgeBase parse( const QString &xml ); - KnowledgeBase::List parseList( const QString &xml ); - KnowledgeBase::Metadata lastMetadata(); - - protected: - KnowledgeBase parseKnowledgeBase( QXmlStreamReader &xml ); - KnowledgeBase::Metadata parseMetadata( QXmlStreamReader &xml ); - - private: - KnowledgeBase::Metadata m_lastMetadata; -}; - -} - -#endif diff --git a/amarok/src/aboutdialog/libattica-ocsclient/message.cpp b/amarok/src/aboutdialog/libattica-ocsclient/message.cpp deleted file mode 100644 index f747b45b..00000000 --- a/amarok/src/aboutdialog/libattica-ocsclient/message.cpp +++ /dev/null @@ -1,109 +0,0 @@ -/* - This file is part of KDE. - - Copyright (c) 2008 Cornelius Schumacher - - This program 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 2 of the License, or - (at your option) any later version. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - -#include "message.h" - -using namespace AmarokAttica; - -Message::Message() - : m_status( Unread ) -{ -} - -void Message::setId( const QString &u ) -{ - m_id = u; -} - -QString Message::id() const -{ - return m_id; -} - -void Message::setFrom( const QString &n ) -{ - m_from = n; -} - -QString Message::from() const -{ - return m_from; -} - -void Message::setTo( const QString &n ) -{ - m_to = n; -} - -QString Message::to() const -{ - return m_to; -} - -void Message::setSent( const QDateTime &d ) -{ - m_sent = d; -} - -QDateTime Message::sent() const -{ - return m_sent; -} - -void Message::setStatus( Message::Status s ) -{ - m_status = s; -} - -Message::Status Message::status() const -{ - return m_status; -} - -void Message::setStatusText( const QString &c ) -{ - m_statusText = c; -} - -QString Message::statusText() const -{ - return m_statusText; -} - -void Message::setSubject( const QString &subject ) -{ - m_subject = subject; -} - -QString Message::subject() const -{ - return m_subject; -} - -void Message::setBody( const QString &body ) -{ - m_body = body; -} - -QString Message::body() const -{ - return m_body; -} diff --git a/amarok/src/aboutdialog/libattica-ocsclient/message.h b/amarok/src/aboutdialog/libattica-ocsclient/message.h deleted file mode 100644 index 9ce64096..00000000 --- a/amarok/src/aboutdialog/libattica-ocsclient/message.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - This file is part of KDE. - - Copyright (c) 2008 Cornelius Schumacher - - This program 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 2 of the License, or - (at your option) any later version. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ -#ifndef ATTICA_MESSAGE_H -#define ATTICA_MESSAGE_H - -#include -#include - -#include "atticaclient_export.h" - - -namespace AmarokAttica { - -class ATTICA_EXPORT Message -{ - public: - typedef QList List; - - enum Status { Unread = 0, Read = 1 }; - - Message(); - - void setId( const QString & ); - QString id() const; - - void setFrom( const QString & ); - QString from() const; - - void setTo( const QString & ); - QString to() const; - - void setSent( const QDateTime & ); - QDateTime sent() const; - - void setStatus( Status ); - Status status() const; - - void setStatusText( const QString & ); - QString statusText() const; - - void setSubject( const QString & ); - QString subject() const; - - void setBody( const QString & ); - QString body() const; - - private: - QString m_id; - QString m_from; - QString m_to; - QDateTime m_sent; - Status m_status; - QString m_statusText; - QString m_subject; - QString m_body; -}; - -} - -#endif diff --git a/amarok/src/aboutdialog/libattica-ocsclient/messagelistjob.cpp b/amarok/src/aboutdialog/libattica-ocsclient/messagelistjob.cpp deleted file mode 100644 index 6eeddc52..00000000 --- a/amarok/src/aboutdialog/libattica-ocsclient/messagelistjob.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/* - This file is part of KDE. - - Copyright (c) 2008 Cornelius Schumacher - - This program 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 2 of the License, or - (at your option) any later version. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - -#include "messagelistjob.h" - -#include "messageparser.h" - -#include -#include - -#include -#include - - -using namespace AmarokAttica; - -MessageListJob::MessageListJob() - : m_job( 0 ) -{ -} - -void MessageListJob::setUrl( const KUrl &url ) -{ - m_url = url; -} - -void MessageListJob::start() -{ - QTimer::singleShot( 0, this, SLOT(doWork()) ); -} - -Message::List MessageListJob::messageList() const -{ - return m_messageList; -} - -void MessageListJob::doWork() -{ - qDebug() << m_url; - - m_job = KIO::get( m_url, KIO::NoReload, KIO::HideProgressInfo ); - connect( m_job, SIGNAL(result(KJob*)), - SLOT(slotJobResult(KJob*)) ); - connect( m_job, SIGNAL(data(KIO::Job*,QByteArray)), - SLOT(slotJobData(KIO::Job*,QByteArray)) ); -} - -void MessageListJob::slotJobResult( KJob *job ) -{ - m_job = 0; - - if ( job->error() ) { - setError( job->error() ); - setErrorText( job->errorText() ); - - emitResult(); - } else { - qDebug() << m_data; - m_messageList = MessageParser().parseList( - QString::fromUtf8( m_data.data() ) ); - - emitResult(); - } -} - -void MessageListJob::slotJobData( KIO::Job *, const QByteArray &data ) -{ - m_data.append( data ); -} diff --git a/amarok/src/aboutdialog/libattica-ocsclient/messagelistjob.h b/amarok/src/aboutdialog/libattica-ocsclient/messagelistjob.h deleted file mode 100644 index de006900..00000000 --- a/amarok/src/aboutdialog/libattica-ocsclient/messagelistjob.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - This file is part of KDE. - - Copyright (c) 2008 Cornelius Schumacher - - This program 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 2 of the License, or - (at your option) any later version. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ -#ifndef ATTICA_MESSAGELISTJOB_H -#define ATTICA_MESSAGELISTJOB_H - -#include "message.h" - -#include -#include - -namespace KIO { -class Job; -} - -namespace AmarokAttica { - -class ATTICA_EXPORT MessageListJob : public KJob -{ - Q_OBJECT - public: - MessageListJob(); - - void setUrl( const KUrl & ); - - void start(); - - Message::List messageList() const; - - protected slots: - void doWork(); - - void slotJobResult( KJob *job ); - void slotJobData( KIO::Job *job, const QByteArray &data ); - - private: - KUrl m_url; - KIO::Job *m_job; - QByteArray m_data; - - Message::List m_messageList; -}; - -} - -#endif diff --git a/amarok/src/aboutdialog/libattica-ocsclient/messageparser.cpp b/amarok/src/aboutdialog/libattica-ocsclient/messageparser.cpp deleted file mode 100644 index 8b7900e5..00000000 --- a/amarok/src/aboutdialog/libattica-ocsclient/messageparser.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/* - This file is part of KDE. - - Copyright (c) 2008 Cornelius Schumacher - - This program 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 2 of the License, or - (at your option) any later version. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - -#include "messageparser.h" - -#include - -using namespace AmarokAttica; - -MessageParser::MessageParser() -{ -} - -Message::List MessageParser::parseList( const QString &xmlString ) -{ - Message::List messageList; - - QXmlStreamReader xml( xmlString ); - - while ( !xml.atEnd() ) { - xml.readNext(); - - if ( xml.isStartElement() && xml.name() == "data" ) { - while ( !xml.atEnd() ) { - xml.readNext(); - - if ( xml.isEndElement() && xml.name() == "data" ) break; - - if ( xml.isStartElement() && xml.name() == "message" ) { - Message message; - - while ( !xml.atEnd() ) { - xml.readNext(); - - if ( xml.isStartElement() ) { - if ( xml.name() == "id" ) { - message.setId( xml.readElementText() ); - } else if ( xml.name() == "messagefrom" ) { - message.setFrom( xml.readElementText() ); - } else if ( xml.name() == "messageto" ) { - message.setTo( xml.readElementText() ); - } else if ( xml.name() == "senddate" ) { - message.setSent( QDateTime::fromString( xml.readElementText(), - Qt::ISODate ) ); - } else if ( xml.name() == "status" ) { - message.setStatus( - Message::Status( xml.readElementText().toInt() ) ); - } else if ( xml.name() == "statustext" ) { - message.setStatusText( xml.readElementText() ); - } else if ( xml.name() == "subject" ) { - message.setSubject( xml.readElementText() ); - } else if ( xml.name() == "body" ) { - message.setBody( xml.readElementText() ); - } - } - - if ( xml.isEndElement() && xml.name() == "message" ) break; - } - - messageList.append( message ); - } - } - } - } - - return messageList; -} diff --git a/amarok/src/aboutdialog/libattica-ocsclient/messageparser.h b/amarok/src/aboutdialog/libattica-ocsclient/messageparser.h deleted file mode 100644 index 848d2836..00000000 --- a/amarok/src/aboutdialog/libattica-ocsclient/messageparser.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - This file is part of KDE. - - Copyright (c) 2008 Cornelius Schumacher - - This program 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 2 of the License, or - (at your option) any later version. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ -#ifndef ATTICA_MESSAGEPARSER_H -#define ATTICA_MESSAGEPARSER_H - -#include "message.h" - - -namespace AmarokAttica { - -class MessageParser -{ - public: - MessageParser(); - - Message::List parseList( const QString &xml ); -}; - -} - -#endif diff --git a/amarok/src/aboutdialog/libattica-ocsclient/person.cpp b/amarok/src/aboutdialog/libattica-ocsclient/person.cpp deleted file mode 100644 index 286340e4..00000000 --- a/amarok/src/aboutdialog/libattica-ocsclient/person.cpp +++ /dev/null @@ -1,154 +0,0 @@ -/* - This file is part of KDE. - - Copyright (c) 2008 Cornelius Schumacher - - This program 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 2 of the License, or - (at your option) any later version. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - -#include "person.h" - -using namespace AmarokAttica; - -Person::Person() - : m_latitude( 0 ), m_longitude( 0 ) -{ -} - -void Person::setId( const QString &u ) -{ - m_id = u; -} - -QString Person::id() const -{ - return m_id; -} - -void Person::setFirstName( const QString &name ) -{ - m_firstName = name; -} - -QString Person::firstName() const -{ - return m_firstName; -} - -void Person::setLastName( const QString &name ) -{ - m_lastName = name; -} - -QString Person::lastName() const -{ - return m_lastName; -} - -void Person::setBirthday( const QDate &d ) -{ - m_birthday = d; -} - -QDate Person::birthday() const -{ - return m_birthday; -} - -void Person::setCountry( const QString &c ) -{ - m_country = c; -} - -QString Person::country() const -{ - return m_country; -} - -void Person::setLatitude( qreal l ) -{ - m_latitude = l; -} - -qreal Person::latitude() const -{ - return m_latitude; -} - -void Person::setLongitude( qreal l ) -{ - m_longitude = l; -} - -qreal Person::longitude() const -{ - return m_longitude; -} - -void Person::setAvatarUrl( const KUrl &url ) -{ - m_avatarUrl = url; -} - -KUrl Person::avatarUrl() const -{ - return m_avatarUrl; -} - -void Person::setAvatar( const QPixmap &p ) -{ - m_avatar = p; -} - -QPixmap Person::avatar() const -{ - return m_avatar; -} - -void Person::setHomepage( const QString &h ) -{ - m_homepage = h; -} - -QString Person::homepage() const -{ - return m_homepage; -} - -void Person::setCity( const QString &h ) -{ - m_city = h; -} - -QString Person::city() const -{ - return m_city; -} - -void Person::addExtendedAttribute( const QString &key, const QString &value ) -{ - m_extendedAttributes.insert( key, value ); -} - -QString Person::extendedAttribute( const QString &key ) const -{ - return m_extendedAttributes.value( key ); -} - -QMap Person::extendedAttributes() const -{ - return m_extendedAttributes; -} diff --git a/amarok/src/aboutdialog/libattica-ocsclient/person.h b/amarok/src/aboutdialog/libattica-ocsclient/person.h deleted file mode 100644 index d33f0e2d..00000000 --- a/amarok/src/aboutdialog/libattica-ocsclient/person.h +++ /dev/null @@ -1,98 +0,0 @@ -/* - This file is part of KDE. - - Copyright (c) 2008 Cornelius Schumacher - - This program 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 2 of the License, or - (at your option) any later version. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ -#ifndef ATTICA_PERSON_H -#define ATTICA_PERSON_H - -#include -#include -#include - -#include - -#include "atticaclient_export.h" - - -namespace AmarokAttica { - -class ATTICA_EXPORT Person -{ - public: - typedef QList List; - - Person(); - - void setId( const QString & ); - QString id() const; - - void setFirstName( const QString & ); - QString firstName() const; - - void setLastName( const QString & ); - QString lastName() const; - - void setBirthday( const QDate & ); - QDate birthday() const; - - void setCountry( const QString & ); - QString country() const; - - void setLatitude( qreal ); - qreal latitude() const; - - void setLongitude( qreal ); - qreal longitude() const; - - void setAvatarUrl( const KUrl & ); - KUrl avatarUrl() const; - - void setAvatar( const QPixmap & ); - QPixmap avatar() const; - - void setHomepage( const QString & ); - QString homepage() const; - - void setCity( const QString & ); - QString city() const; - - void addExtendedAttribute( const QString &key, const QString &value ); - QString extendedAttribute( const QString &key ) const; - - QMap extendedAttributes() const; - - private: - QString m_id; - QString m_firstName; - QString m_lastName; - QDate m_birthday; - QString m_country; - qreal m_latitude; - qreal m_longitude; - KUrl m_avatarUrl; - QPixmap m_avatar; - QString m_homepage; - QString m_city; - - QMap m_extendedAttributes; -}; - -} - -#endif diff --git a/amarok/src/aboutdialog/libattica-ocsclient/personjob.cpp b/amarok/src/aboutdialog/libattica-ocsclient/personjob.cpp deleted file mode 100644 index 6cc755c0..00000000 --- a/amarok/src/aboutdialog/libattica-ocsclient/personjob.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/* - This file is part of KDE. - - Copyright (c) 2008 Cornelius Schumacher - - This program 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 2 of the License, or - (at your option) any later version. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - -#include "personjob.h" - -#include "personparser.h" - -#include -#include - -#include -#include - - -using namespace AmarokAttica; - -PersonJob::PersonJob() - : m_job( 0 ) -{ -} - -void PersonJob::setUrl( const KUrl &url ) -{ - m_url = url; -} - -void PersonJob::start() -{ - QTimer::singleShot( 0, this, SLOT(doWork()) ); -} - -Person PersonJob::person() const -{ - return m_person; -} - -void PersonJob::doWork() -{ - qDebug() << m_url; - - m_job = KIO::get( m_url, KIO::NoReload, KIO::HideProgressInfo ); - connect( m_job, SIGNAL(result(KJob*)), - SLOT(slotUserJobResult(KJob*)) ); - connect( m_job, SIGNAL(data(KIO::Job*,QByteArray)), - SLOT(slotUserJobData(KIO::Job*,QByteArray)) ); -} - -void PersonJob::slotUserJobResult( KJob *job ) -{ - m_job = 0; - - if ( job->error() ) { - setError( job->error() ); - setErrorText( job->errorText() ); - - emitResult(); - } else { - // qDebug() << m_userData; - m_person = PersonParser().parse( m_userData ); - - if (!m_person.avatarUrl().isEmpty()) { - qDebug() << "Getting avatar from" << m_person.avatarUrl(); - - m_job = KIO::get( m_person.avatarUrl(), KIO::NoReload, - KIO::HideProgressInfo ); - connect( m_job, SIGNAL(result(KJob*)), - SLOT(slotAvatarJobResult(KJob*)) ); - connect( m_job, SIGNAL(data(KIO::Job*,QByteArray)), - SLOT(slotAvatarJobData(KIO::Job*,QByteArray)) ); - } else { - emitResult(); - } - } -} - -void PersonJob::slotUserJobData( KIO::Job *, const QByteArray &data ) -{ - m_userData.append( QString::fromUtf8( data.data(), data.size() + 1 ) ); -} - -void PersonJob::slotAvatarJobResult( KJob *job ) -{ - m_job = 0; - - if ( job->error() ) { - qWarning() << "Error retrieving Avatar:" << job->errorText(); - } else { - QPixmap pic; - if ( pic.loadFromData( m_avatarData ) ) { - m_person.setAvatar( pic ); - } - } - - emitResult(); -} - -void PersonJob::slotAvatarJobData( KIO::Job *, const QByteArray &data ) -{ - m_avatarData.append( data ); -} diff --git a/amarok/src/aboutdialog/libattica-ocsclient/personjob.h b/amarok/src/aboutdialog/libattica-ocsclient/personjob.h deleted file mode 100644 index ce4091ec..00000000 --- a/amarok/src/aboutdialog/libattica-ocsclient/personjob.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - This file is part of KDE. - - Copyright (c) 2008 Cornelius Schumacher - - This program 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 2 of the License, or - (at your option) any later version. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. - */ -#ifndef ATTICA_PERSONJOB_H -#define ATTICA_PERSONJOB_H - -#include "person.h" - -#include - -namespace KIO { -class Job; -} - -namespace AmarokAttica { - -class ATTICA_EXPORT PersonJob : public KJob -{ - Q_OBJECT - public: - PersonJob(); - - void setUrl( const KUrl & ); - - void start(); - - Person person() const; - - protected slots: - void doWork(); - - void slotUserJobResult( KJob *job ); - void slotUserJobData( KIO::Job *job, const QByteArray &data ); - - void slotAvatarJobResult( KJob *job ); - void slotAvatarJobData( KIO::Job *job, const QByteArray &data ); - - private: - KUrl m_url; - KIO::Job *m_job; - QString m_userData; - QByteArray m_avatarData; - - Person m_person; -}; - -} - -#endif diff --git a/amarok/src/aboutdialog/libattica-ocsclient/personlistjob.cpp b/amarok/src/aboutdialog/libattica-ocsclient/personlistjob.cpp deleted file mode 100644 index 1637f7e1..00000000 --- a/amarok/src/aboutdialog/libattica-ocsclient/personlistjob.cpp +++ /dev/null @@ -1,120 +0,0 @@ -/* - This file is part of KDE. - - Copyright (c) 2008 Cornelius Schumacher - - This program 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 2 of the License, or - (at your option) any later version. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - -#include "personlistjob.h" - -#include "personparser.h" - -#include -#include - -#include -#include - - -using namespace AmarokAttica; - -PersonListJob::PersonListJob() - : m_job( 0 ) -{ -} - -void PersonListJob::setUrl( const KUrl &url ) -{ - m_url = url; -} - -void PersonListJob::start() -{ - QTimer::singleShot( 0, this, SLOT(doWork()) ); -} - -Person::List PersonListJob::personList() const -{ - return m_personList; -} - -void PersonListJob::doWork() -{ - qDebug() << m_url; - - m_job = KIO::get( m_url, KIO::NoReload, KIO::HideProgressInfo ); - connect( m_job, SIGNAL(result(KJob*)), - SLOT(slotUserJobResult(KJob*)) ); - connect( m_job, SIGNAL(data(KIO::Job*,QByteArray)), - SLOT(slotUserJobData(KIO::Job*,QByteArray)) ); -} - -void PersonListJob::slotUserJobResult( KJob *job ) -{ - m_job = 0; - - if ( job->error() ) { - setError( job->error() ); - setErrorText( job->errorText() ); - - emitResult(); - } else { - // qDebug() << m_userData; - m_personList = PersonParser().parseList( m_userData ); - -#if 0 - m_job = KIO::get( m_person.avatarUrl(), KIO::NoReload, - KIO::HideProgressInfo ); - connect( m_job, SIGNAL(result(KJob*)), - SLOT(slotAvatarJobResult(KJob*)) ); - connect( m_job, SIGNAL(data(KIO::Job*,QByteArray)), - SLOT(slotAvatarJobData(KIO::Job*,QByteArray)) ); -#else - emitResult(); -#endif - } -} - -void PersonListJob::slotUserJobData( KIO::Job *, const QByteArray &data ) -{ - m_userData.append( QString::fromUtf8( data.data(), data.size() + 1 ) ); -} - -void PersonListJob::slotAvatarJobResult( KJob *job ) -{ - m_job = 0; - - if ( job->error() ) { - setError( job->error() ); - setErrorText( job->errorText() ); - } else { - QPixmap pic; - if ( !pic.loadFromData( m_avatarData ) ) { - setError( UserDefinedError ); - setErrorText( i18n("Unable to parse avatar image data.") ); - } else { -// m_person.setAvatar( pic ); - } - } - - emitResult(); -} - -void PersonListJob::slotAvatarJobData( KIO::Job *, const QByteArray &data ) -{ - m_avatarData.append( data ); -} diff --git a/amarok/src/aboutdialog/libattica-ocsclient/personlistjob.h b/amarok/src/aboutdialog/libattica-ocsclient/personlistjob.h deleted file mode 100644 index ab42a871..00000000 --- a/amarok/src/aboutdialog/libattica-ocsclient/personlistjob.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - This file is part of KDE. - - Copyright (c) 2008 Cornelius Schumacher - - This program 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 2 of the License, or - (at your option) any later version. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. - */ -#ifndef ATTICA_PERSONLISTJOB_H -#define ATTICA_PERSONLISTJOB_H - -#include "person.h" - -#include - -namespace KIO { -class Job; -} - -namespace AmarokAttica { - -class ATTICA_EXPORT PersonListJob : public KJob -{ - Q_OBJECT - public: - PersonListJob(); - - void setUrl( const KUrl & ); - - void start(); - - Person::List personList() const; - - protected slots: - void doWork(); - - void slotUserJobResult( KJob *job ); - void slotUserJobData( KIO::Job *job, const QByteArray &data ); - - void slotAvatarJobResult( KJob *job ); - void slotAvatarJobData( KIO::Job *job, const QByteArray &data ); - - private: - KUrl m_url; - KIO::Job *m_job; - QString m_userData; - QByteArray m_avatarData; - - Person::List m_personList; -}; - -} - -#endif diff --git a/amarok/src/aboutdialog/libattica-ocsclient/personparser.cpp b/amarok/src/aboutdialog/libattica-ocsclient/personparser.cpp deleted file mode 100644 index 6fc7d687..00000000 --- a/amarok/src/aboutdialog/libattica-ocsclient/personparser.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/* - This file is part of KDE. - - Copyright (c) 2008 Cornelius Schumacher - - This program 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 2 of the License, or - (at your option) any later version. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - -#include "personparser.h" - -#include - -using namespace AmarokAttica; - -PersonParser::PersonParser() -{ -} - -Person::List PersonParser::parseList( const QString &xmlString ) -{ - Person::List personList; - - QXmlStreamReader xml( xmlString ); - - while ( !xml.atEnd() ) { - xml.readNext(); - - if ( xml.isStartElement() && - ( xml.name() == "person" || xml.name() == "user" ) ) { - Person person = parsePerson( xml ); - personList.append( person ); - } - } - - return personList; -} - -Person PersonParser::parse( const QString &xmlString ) -{ - Person person; - - QXmlStreamReader xml( xmlString ); - - while ( !xml.atEnd() ) { - xml.readNext(); - - if ( xml.isStartElement() && xml.name() == "person" ) { - person = parsePerson( xml ); - } - } - - return person; -} - -Person PersonParser::parsePerson( QXmlStreamReader &xml ) -{ - Person person; - bool hasAvatarPic = false; - - while ( !xml.atEnd() ) { - xml.readNext(); - - if ( xml.isStartElement() ) { - if ( xml.name() == "personid" ) { - person.setId( xml.readElementText() ); - } else if ( xml.name() == "firstname" ) { - person.setFirstName( xml.readElementText() ); - } else if ( xml.name() == "lastname" ) { - person.setLastName( xml.readElementText() ); - } else if ( xml.name() == "homepage" ) { - person.setHomepage( xml.readElementText() ); - } else if ( xml.name() == "avatarpic" ) { - person.setAvatarUrl( xml.readElementText() ); - } else if ( xml.name() == "avatarpicfound" ) { - QString value = xml.readElementText(); - if (value.toInt()) { - hasAvatarPic = true; - } - } else if ( xml.name() == "birthday" ) { - person.setBirthday( QDate::fromString( xml.readElementText(), - Qt::ISODate ) ); - } else if ( xml.name() == "city" ) { - person.setCity( xml.readElementText() ); - } else if ( xml.name() == "country" ) { - person.setCountry( xml.readElementText() ); - } else if ( xml.name() == "latitude" ) { - person.setLatitude( xml.readElementText().toFloat() ); - } else if ( xml.name() == "longitude" ) { - person.setLongitude( xml.readElementText().toFloat() ); - } else { - person.addExtendedAttribute( xml.name().toString(), - xml.readElementText() ); - } - } - - if ( xml.isEndElement() && - ( xml.name() == "person" || xml.name() == "user" ) ) break; - } - - if (!hasAvatarPic) { - person.setAvatarUrl(QString()); - } - - return person; -} diff --git a/amarok/src/aboutdialog/libattica-ocsclient/personparser.h b/amarok/src/aboutdialog/libattica-ocsclient/personparser.h deleted file mode 100644 index c6280277..00000000 --- a/amarok/src/aboutdialog/libattica-ocsclient/personparser.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - This file is part of KDE. - - Copyright (c) 2008 Cornelius Schumacher - - This program 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 2 of the License, or - (at your option) any later version. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ -#ifndef ATTICA_PERSONPARSER_H -#define ATTICA_PERSONPARSER_H - -#include "person.h" - -#include - -namespace AmarokAttica { - -class PersonParser -{ - public: - PersonParser(); - - Person parse( const QString &xml ); - Person::List parseList( const QString &xml ); - - protected: - Person parsePerson( QXmlStreamReader &xml ); -}; - -} - -#endif diff --git a/amarok/src/aboutdialog/libattica-ocsclient/postjob.cpp b/amarok/src/aboutdialog/libattica-ocsclient/postjob.cpp deleted file mode 100644 index c1ef89e7..00000000 --- a/amarok/src/aboutdialog/libattica-ocsclient/postjob.cpp +++ /dev/null @@ -1,128 +0,0 @@ -/* - This file is part of KDE. - - Copyright (c) 2008 Cornelius Schumacher - - This program 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 2 of the License, or - (at your option) any later version. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - -#include "postjob.h" - -#include -#include - -#include -#include -#include -using namespace AmarokAttica; - -PostJob::PostJob() - : m_job( 0 ) -{ -} - -void PostJob::setUrl( const KUrl &url ) -{ - m_url = url; -} - -void PostJob::setData( const QString &name, const QString &value ) -{ - m_data.insert( name, value ); -} - -void PostJob::start() -{ - QTimer::singleShot( 0, this, SLOT(doWork()) ); -} - -QString PostJob::status() const -{ - return m_status; -} - -QString PostJob::statusMessage() const -{ - return m_statusMessage; -} - -void PostJob::doWork() -{ - QString postData; - - const QStringList dataKeys = m_data.keys(); - foreach( const QString &name, dataKeys ) { - m_url.addQueryItem( name, m_data.value( name ) ); - } - - qDebug() << m_url; - - m_job = KIO::http_post( m_url, postData.toUtf8(), KIO::HideProgressInfo ); - connect( m_job, SIGNAL(result(KJob*)), - SLOT(slotJobResult(KJob*)) ); - connect( m_job, SIGNAL(data(KIO::Job*,QByteArray)), - SLOT(slotJobData(KIO::Job*,QByteArray)) ); -} - -void PostJob::slotJobResult( KJob *job ) -{ - m_job = 0; - - qDebug() << "RESPONSE" << m_responseData; - - if ( job->error() ) { - setError( job->error() ); - setErrorText( job->errorText() ); - } else { - qDebug() << "No error "; - - QXmlStreamReader xml( m_responseData ); - - while ( !xml.atEnd() ) { - xml.readNext(); - - if ( xml.isStartElement() && xml.name() == "meta" ) { - while ( !xml.atEnd() ) { - xml.readNext(); - - if ( xml.isStartElement() ) { - if ( xml.name() == "status" ) { - m_status = xml.readElementText(); - } else if ( xml.name() == "message" ) { - m_statusMessage = xml.readElementText(); - } - } - - if ( xml.isEndElement() && xml.name() == "meta" ) break; - } - } - } - - qDebug() << "STATUS:" << m_status; - - if ( m_status != "ok" ) { - setError( KJob::UserDefinedError ); - setErrorText( m_status + ": " + m_statusMessage ); - } - } - - emitResult(); -} - -void PostJob::slotJobData( KIO::Job *, const QByteArray &data ) -{ - m_responseData.append( QString::fromUtf8( data.data(), data.size() + 1 ) ); -} diff --git a/amarok/src/aboutdialog/libattica-ocsclient/postjob.h b/amarok/src/aboutdialog/libattica-ocsclient/postjob.h deleted file mode 100644 index 9fc30f4e..00000000 --- a/amarok/src/aboutdialog/libattica-ocsclient/postjob.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - This file is part of KDE. - - Copyright (c) 2008 Cornelius Schumacher - - This program 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 2 of the License, or - (at your option) any later version. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. - */ -#ifndef ATTICA_POSTJOB_H -#define ATTICA_POSTJOB_H - -#include "atticaclient_export.h" - -#include -#include - -namespace KIO { -class Job; -} - -namespace AmarokAttica { - -class ATTICA_EXPORT PostJob : public KJob -{ - Q_OBJECT - public: - PostJob(); - - void setUrl( const KUrl & ); - void setData( const QString &name, const QString &value ); - - void start(); - - QString status() const; - QString statusMessage() const; - - protected slots: - void doWork(); - - void slotJobResult( KJob *job ); - void slotJobData( KIO::Job *, const QByteArray & ); - - private: - KUrl m_url; - QMap m_data; - KIO::Job *m_job; - QString m_responseData; - - QString m_status; - QString m_statusMessage; -}; - -} - -#endif diff --git a/amarok/src/aboutdialog/libattica-ocsclient/provider.cpp b/amarok/src/aboutdialog/libattica-ocsclient/provider.cpp deleted file mode 100644 index a57fb5a5..00000000 --- a/amarok/src/aboutdialog/libattica-ocsclient/provider.cpp +++ /dev/null @@ -1,437 +0,0 @@ -/* - This file is part of KDE. - - Copyright (c) 2008 Cornelius Schumacher - - This program 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 2 of the License, or - (at your option) any later version. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - -#include "provider.h" - -#include -#include - -#include "activitylistjob.h" -#include "categorylistjob.h" -#include "contentjob.h" -#include "contentlistjob.h" -#include "eventjob.h" -#include "eventlistjob.h" -#include "folderlistjob.h" -#include "knowledgebasejob.h" -#include "knowledgebaselistjob.h" -#include "messagelistjob.h" -#include "personjob.h" -#include "personlistjob.h" -#include "postjob.h" -#include "providerinitjob.h" - - -using namespace AmarokAttica; - - -class Provider::Private : public QSharedData { - public: - KUrl m_baseUrl; - QString m_id; - QString m_name; - Private(const Private& other) - : QSharedData(other), m_baseUrl(other.m_baseUrl), m_id(other.m_id), m_name(other.m_name) - { - } - Private(const QString& id, const KUrl& baseUrl, const QString name) - : m_baseUrl(baseUrl), m_id(id), m_name(name) - { - } -}; - - -ProviderInitJob* Provider::byId(const QString& id) -{ - ProviderInitJob* job = new ProviderInitJob(id); - job->start(); - return job; -} - - -Provider::Provider() - : d(new Private(QString(), KUrl(), QString())) -{ -} - -Provider::Provider(const Provider& other) - : d(other.d) -{ -} - -Provider::Provider(const QString& id, const KUrl& baseUrl, const QString& name) - : d(new Private(id, baseUrl, name)) -{ -} - -Provider& Provider::operator=(const AmarokAttica::Provider & other) -{ - d = other.d; - return *this; -} - -Provider::~Provider() -{ -} - - -QString Provider::id() const -{ - return d->m_id; -} - - -QString Provider::name() const -{ - return d->m_name; -} - - -PersonJob* Provider::requestPerson(const QString& id) const -{ - KUrl url = createUrl( "person/data/" + id ); - return doRequestPerson( url ); -} - -PersonJob* Provider::requestPersonSelf() -{ - KUrl url = createUrl( "person/self" ); - return doRequestPerson( url ); -} - -PersonListJob* Provider::requestPersonSearchByName(const QString& name) -{ - KUrl url = createUrl( "person/data"); - url.addQueryItem("name", name); - return doRequestPersonList( url ); -} - -PersonListJob* Provider::requestPersonSearchByLocation(qreal latitude, qreal longitude, qreal distance, int page, int pageSize) -{ - KUrl url = createUrl( "person/data" ); - url.addQueryItem("latitude", QString::number(latitude)); - url.addQueryItem("longitude", QString::number(longitude)); - url.addQueryItem("distance", QString::number(distance)); - url.addQueryItem("page", QString::number(page)); - url.addQueryItem("pagesize", QString::number(pageSize)); - - qDebug() << "Location-based search:" << latitude << longitude << distance; - qDebug() << "URL:" << url; - return doRequestPersonList( url ); -} - -PersonListJob* Provider::requestFriend(const QString& id, int page, int pageSize) -{ - KUrl url = createUrl( "friend/data/" + id ); - url.addQueryItem("page", QString::number(page)); - url.addQueryItem("pagesize", QString::number(pageSize)); - kDebug() << "URL:" << url; - return doRequestPersonList( url ); -} - -ActivityListJob* Provider::requestActivity() -{ - KUrl url = createUrl( "activity" ); - return doRequestActivityList( url ); -} - -PostJob* Provider::postActivity(const QString& message) -{ - PostJob *job = new PostJob(); - - KUrl url = createUrl( "activity" ); - job->setUrl( url ); - job->setData( "message", message ); - - job->start(); - return job; -} - -PostJob* Provider::postInvitation(const QString& to, const QString& message) -{ - PostJob *job = new PostJob(); - - KUrl url = createUrl( "friend/outbox/" + to ); - job->setUrl( url ); - job->setData( "message", message ); - - job->start(); - return job; -} - -PostJob* Provider::postLocation(qreal latitude, qreal longitude, const QString& city, const QString& country) -{ - PostJob *job = new PostJob(); - - KUrl url = createUrl( "person/self" ); - - job->setUrl( url ); - - job->setData( "latitude", QString("%1").arg(latitude) ); - job->setData( "longitude", QString("%1").arg(longitude) ); - job->setData( "city", city ); - job->setData( "country", country ); - - job->start(); - return job; -} - - -FolderListJob* Provider::requestFolders() -{ - return doRequestFolderList( createUrl( "message" ) ); -} - -MessageListJob* Provider::requestMessages(const QString& folderId) -{ - return doRequestMessageList( createUrl( "message/" + folderId ) ); -} - -PostJob* Provider::postMessage( const Message &message ) -{ - PostJob *job = new PostJob(); - - KUrl url = createUrl( "message/2" ); - job->setUrl( url ); - job->setData( "message", message.body() ); - job->setData( "subject", message.subject() ); - job->setData( "to", message.to() ); - - job->start(); - return job; -} - -CategoryListJob* Provider::requestCategories() -{ - CategoryListJob *job = new CategoryListJob(); - - KUrl url = createUrl( "content/categories" ); - job->setUrl( url ); - - job->start(); - return job; -} - -ContentListJob* Provider::requestContent(const Category::List& categories, const QString& search, SortMode sortMode) -{ - ContentListJob *job = new ContentListJob(); - - KUrl url = createUrl( "content/data" ); - - QStringList categoryIds; - foreach( const Category &category, categories ) { - categoryIds.append( category.id() ); - } - url.addQueryItem( "categories", categoryIds.join( "x" ) ); - - url.addQueryItem( "search", search ); - QString sortModeString; - switch ( sortMode ) { - case Newest: - sortModeString = "new"; - break; - case Alphabetical: - sortModeString = "alpha"; - break; - case Rating: - sortModeString = "high"; - break; - case Downloads: - sortModeString = "down"; - break; - } - if ( !sortModeString.isEmpty() ) { - url.addQueryItem( "sortmode", sortModeString ); - } - - job->setUrl( url ); - - job->start(); - return job; -} - -ContentJob* Provider::requestContent(const QString& id) -{ - ContentJob *job = new ContentJob(); - - KUrl url = createUrl( "content/data/" + id ); - job->setUrl( url ); - - job->start(); - return job; -} - -KnowledgeBaseJob* Provider::requestKnowledgeBase(const QString& id) -{ - KnowledgeBaseJob *job = new KnowledgeBaseJob(); - - KUrl url = createUrl( "knowledgebase/data/" + id ); - job->setUrl( url ); - - job->start(); - return job; -} - -KnowledgeBaseListJob* Provider::requestKnowledgeBase(int content, const QString& search, Provider::SortMode sortMode, int page, int pageSize) -{ - KnowledgeBaseListJob *job = new KnowledgeBaseListJob(); - - KUrl url = createUrl( "knowledgebase/data" ); - - if (content) { - url.addQueryItem("content", QString::number(content)); - } - - url.addQueryItem( "search", search ); - QString sortModeString; - switch ( sortMode ) { - case Newest: - sortModeString = "new"; - break; - case Alphabetical: - sortModeString = "alpha"; - break; - case Rating: - sortModeString = "high"; - break; - //FIXME: knowledge base doesn't have downloads - case Downloads: - sortModeString = "new"; - break; - } - if ( !sortModeString.isEmpty() ) { - url.addQueryItem( "sortmode", sortModeString ); - } - - url.addQueryItem( "page", QString::number(page) ); - url.addQueryItem( "pagesize", QString::number(pageSize) ); - - job->setUrl( url ); - - job->start(); - return job; -} - -EventJob* Provider::requestEvent(const QString& id) -{ - EventJob* job = new EventJob(); - - job->setUrl(createUrl("event/data/" + id)); - - job->start(); - return job; -} - -EventListJob* Provider::requestEvent(const QString& country, const QString& search, const QDate& startAt, Provider::SortMode mode, int page, int pageSize) -{ - EventListJob* job = new EventListJob(); - - KUrl url = createUrl("event/data"); - - if (!search.isEmpty()) { - url.addQueryItem("search", search); - } - - QString sortModeString; - switch (mode) { - case Newest: - sortModeString = "new"; - break; - case Alphabetical: - sortModeString = "alpha"; - break; - default: - break; - } - if (!sortModeString.isEmpty()) { - url.addQueryItem("sortmode", sortModeString); - } - - if (!country.isEmpty()) { - url.addQueryItem("country", country); - } - - url.addQueryItem("startat", startAt.toString(Qt::ISODate)); - - url.addQueryItem("page", QString::number(page)); - url.addQueryItem("pagesize", QString::number(pageSize)); - - job->setUrl(url); - - job->start(); - return job; - -} - -KUrl Provider::createUrl(const QString& path) const -{ - KUrl url(d->m_baseUrl); - url.addPath( path ); - return url; -} - -PersonJob* Provider::doRequestPerson(const KUrl& url) const -{ - PersonJob *job = new PersonJob(); - - job->setUrl( url ); - - job->start(); - return job; -} - -PersonListJob* Provider::doRequestPersonList(const KUrl& url) -{ - PersonListJob *job = new PersonListJob(); - - job->setUrl( url ); - - job->start(); - return job; -} - -ActivityListJob* Provider::doRequestActivityList(const KUrl& url) -{ - ActivityListJob *job = new ActivityListJob(); - - job->setUrl( url ); - - job->start(); - return job; -} - -FolderListJob* Provider::doRequestFolderList(const KUrl& url) -{ - FolderListJob *job = new FolderListJob(); - - job->setUrl( url ); - job->start(); - return job; -} - -MessageListJob* Provider::doRequestMessageList(const KUrl& url) -{ - MessageListJob *job = new MessageListJob(); - - job->setUrl( url ); - job->start(); - return job; -} diff --git a/amarok/src/aboutdialog/libattica-ocsclient/provider.h b/amarok/src/aboutdialog/libattica-ocsclient/provider.h deleted file mode 100644 index effb3ffa..00000000 --- a/amarok/src/aboutdialog/libattica-ocsclient/provider.h +++ /dev/null @@ -1,132 +0,0 @@ -/* - This file is part of KDE. - - Copyright (c) 2008 Cornelius Schumacher - - This program 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 2 of the License, or - (at your option) any later version. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - -#ifndef ATTICA_PROVIDER_H -#define ATTICA_PROVIDER_H - -#include -#include - -#include "atticaclient_export.h" -#include "category.h" - -class KUrl; -class QDate; - -namespace AmarokAttica { - -class ActivityListJob; -class CategoryListJob; -class ContentJob; -class ContentListJob; -class EventJob; -class EventListJob; -class FolderListJob; -class KnowledgeBaseJob; -class KnowledgeBaseListJob; -class Message; -class MessageListJob; -class PersonJob; -class PersonListJob; -class PostJob; -class ProviderInitJob; - -/** - Open Collaboration Services API. -*/ -class ATTICA_EXPORT Provider -{ - public: - Provider(); - Provider(const Provider& other); - Provider(const QString& id, const KUrl& baseUrl, const QString& name); - Provider& operator=(const Provider& other); - ~Provider(); - - QString name() const; - QString id() const; - - enum SortMode { - Newest, - Alphabetical, - Rating, - Downloads - }; - - static ProviderInitJob* byId(const QString& id); - - // Person part of OCS - - PersonJob* requestPerson(const QString& id) const; - PersonJob* requestPersonSelf(); - PersonListJob* requestPersonSearchByName(const QString& name); - PersonListJob* requestPersonSearchByLocation(qreal latitude, qreal longitude, qreal distance, int page = 0, int pageSize = 100); - PostJob* postLocation(qreal latitude, qreal longitude, const QString& city = QString(), const QString& country = QString()); - - // Friend part of OCS - - PersonListJob* requestFriend(const QString& id, int page = 0, int pageSize = 100); - PostJob* postInvitation(const QString& to, const QString& message); - - // Message part of OCS - - FolderListJob* requestFolders(); - MessageListJob* requestMessages(const QString& folderId); - PostJob* postMessage(const Message& message); - - // Activity part of OCS - - ActivityListJob* requestActivity(); - PostJob* postActivity(const QString& message); - - // Content part of OCS - - CategoryListJob* requestCategories(); - ContentListJob* requestContent(const Category::List& categories, const QString& search, SortMode mode); - ContentJob* requestContent(const QString& id); - - // KnowledgeBase part of OCS - - KnowledgeBaseJob* requestKnowledgeBase(const QString& id); - KnowledgeBaseListJob* requestKnowledgeBase(int content, const QString& search, SortMode, int page, int pageSize); - - // Event part of OCS - - EventJob* requestEvent(const QString& id); - EventListJob* requestEvent(const QString& country, const QString& search, const QDate& startAt, SortMode mode, int page, int pageSize); - - protected: - KUrl createUrl(const QString& path) const; - - PersonJob* doRequestPerson(const KUrl& url) const; - PersonListJob* doRequestPersonList(const KUrl& url); - ActivityListJob* doRequestActivityList(const KUrl& url); - FolderListJob* doRequestFolderList(const KUrl& url); - MessageListJob* doRequestMessageList(const KUrl& url); - - private: - class Private; - QExplicitlySharedDataPointer d; -}; - -} - -#endif diff --git a/amarok/src/aboutdialog/libattica-ocsclient/providerinitjob.cpp b/amarok/src/aboutdialog/libattica-ocsclient/providerinitjob.cpp deleted file mode 100644 index 06761d35..00000000 --- a/amarok/src/aboutdialog/libattica-ocsclient/providerinitjob.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/* - This file is part of KDE. - - Copyright (c) 2009 Eckhart Wörner - - This program 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 2 of the License, or - (at your option) any later version. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - -#include "providerinitjob.h" - -#include - -#include - - -using namespace AmarokAttica; - - -ProviderInitJob::ProviderInitJob(const QString& id, QObject* parent) - : KJob(parent), m_id(id) -{ -} - - -void ProviderInitJob::start() -{ - QTimer::singleShot(0, this, SLOT(doWork())); -} - - -void ProviderInitJob::doWork() -{ - if (m_id == "opendesktop") { - m_provider = Provider(m_id, KUrl("https://api.opendesktop.org/v1/"), "OpenDesktop.org"); - } - emitResult(); -} - - -Provider ProviderInitJob::provider() const -{ - return m_provider; -} - - -#include "moc_providerinitjob.cpp" diff --git a/amarok/src/aboutdialog/libattica-ocsclient/providerinitjob.h b/amarok/src/aboutdialog/libattica-ocsclient/providerinitjob.h deleted file mode 100644 index 917522ab..00000000 --- a/amarok/src/aboutdialog/libattica-ocsclient/providerinitjob.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - This file is part of KDE. - - Copyright (c) 2009 Eckhart Wörner - - This program 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 2 of the License, or - (at your option) any later version. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - -#ifndef PROVIDERINITJOB_H -#define PROVIDERINITJOB_H - -#include - -#include "atticaclient_export.h" -#include "provider.h" - -namespace AmarokAttica { - -class ATTICA_EXPORT ProviderInitJob : public KJob -{ - Q_OBJECT - - public: - ProviderInitJob(const QString& id, QObject* parent = 0); - - void start(); - - Provider provider() const; - - private slots: - void doWork(); - - private: - const QString m_id; - Provider m_provider; -}; - -} - - -#endif diff --git a/amarok/src/amarok-play-audiocd.desktop b/amarok/src/amarok-play-audiocd.desktop deleted file mode 100644 index 35c119f0..00000000 --- a/amarok/src/amarok-play-audiocd.desktop +++ /dev/null @@ -1,69 +0,0 @@ -[Desktop Entry] -X-KDE-Solid-Predicate=OpticalDisc.availableContent & 'Audio' -Type=Service -Actions=Play; -X-KDE-Priority=TopLevel - -[Desktop Action Play] -Name=Play Audio CD with Amarok -Name[be]=Граць аўдыё кампакт-дыск у Amarok -Name[bg]=Изпълнение на компактдиск с Amarok -Name[bs]=Pusti audio CD Amarokom -Name[ca]=Reprodueix el CD d'àudio amb l'Amarok -Name[ca@valencia]=Reprodueix el CD d'àudio amb l'Amarok -Name[cs]=Přehrát v Amaroku audio CD -Name[csb]=Grôj aùdio CD w Amarokù -Name[da]=Afspil lyd-cd med Amarok -Name[de]=Audio-CD mit Amarok wiedergeben -Name[el]=Αναπαραγωγή CD ήχου με το Amarok -Name[en_GB]=Play Audio CD with Amarok -Name[eo]=Ludi sonan KD per Amarok -Name[es]=Reproducir CD de audio con Amarok -Name[et]=Esita audio-CD Amarokis -Name[eu]=Erreproduzitu Audio CDa Amarok-ekin -Name[fi]=Toista musiikki-cd Amarokilla -Name[fr]=Écouter un CD Audio avec Amarok -Name[ga]=Seinn Dlúthdhiosca Fuaime le hAmarok -Name[gl]=Reproducir un CD de música con Amarok -Name[he]=נגן תקליטור שמע ב־Amarok -Name[hne]=अमाराक के साथ आडियो सीडी बजाव -Name[hr]=Sviraj zvučni CD s Amarokom -Name[hu]=Hang-CD lejátszása az Amarokkal -Name[id]=Mainkan Audio CD dengan Amarok -Name[is]=Spila hljóðdisk með Amarok -Name[it]=Riproduci CD audio con Amarok -Name[ja]=Amarok でオーディオ CD を再生 -Name[km]=ចាក់​ស៊ីឌី​អូឌីយ៉ូ​ជា​មួយ Amarok -Name[ko]=Amarok으로 오디오 CD 재생하기 -Name[ku]=CD ya muzîkê bi Amarok lê bide -Name[lt]=Groti audio CD su Amarok -Name[lv]=Atskaņot audio CD ar Amarok -Name[ms]=Main CD Audio dengan Amarok -Name[nb]=Spill lyd-CD med Amarok -Name[nds]=Audio-CD mit Amarok afspelen -Name[ne]=अमारोकसँग अडियो सीडी बजाउनुहोस् -Name[nl]=Audio-cd met Amarok afspelen -Name[nn]=Spel lyd-CD med Amarok -Name[pa]=ਆਡੀਓ CD ਅਮਰੋਕ ਨਾਲ ਚਲਾਓ -Name[pl]=Odtwórz Audio CD za pomocą Amarok -Name[pt]=Tocar o CD de Áudio com o Amarok -Name[pt_BR]=Reproduzir CD de áudio com o Amarok -Name[ro]=Redare CD audio cu Amarok -Name[ru]=Воспроизвести Audio CD в Amarok -Name[sk]=Prehrať Audio CD pomocou Amarok -Name[sl]=Predvajaj glasbeni CD z Amarokom -Name[sr]=Пусти аудио ЦД Амароком -Name[sr@ijekavian]=Пусти аудио ЦД Амароком -Name[sr@ijekavianlatin]=Pusti audio CD Amarokom -Name[sr@latin]=Pusti audio CD Amarokom -Name[sv]=Spela musik-cd med Amarok -Name[th]=เล่นแผ่นซีดีเสียงด้วยแอมอะร็อก -Name[tr]=Ses CD'sini Amarok ile Çal -Name[ug]=قويۇشCD -Name[uk]=Відтворити аудіо-КД за допомогою Amarok -Name[wa]=Djouwer plake lazer odio avou Amarok -Name[x-test]=xxPlay Audio CD with Amarokxx -Name[zh_CN]=用 Amarok 播放音频 CD -Name[zh_TW]=使用 Amarok 播放音樂 CD -Icon=amarok -Exec=amarok --cdplay %f diff --git a/amarok/src/amarok.appdata.xml b/amarok/src/amarok.appdata.xml deleted file mode 100644 index d1fa6a30..00000000 --- a/amarok/src/amarok.appdata.xml +++ /dev/null @@ -1,277 +0,0 @@ - - - amarok.desktop - CC0-1.0 - Amarok - Amarok - Amarok - Amarok - Amarok - Amarok - Amarok - Amarok - Amarok - Amarok - Amarok - Amarok - Amarok - ਅਮਰੋਕ - Amarok - Amarok - Amarok - Amarok - Amarok - Амарок - Amarok - Амарок - Amarok - Amarok - Amarok - xxAmarokxx - -

Amarok is a free, versatile and powerful music player.

-

L'Amarok és un reproductor de música lliure, versàtil i potent.

-

Amarok je svobodný, univerzální a mocný přehrávač hudby.

-

Amarok er en fri, alsidig og kraftfuld musikafspiller.

-

Amarok ist eine freie, vielfältige und leistungsfähige Anwendung zur Musikwiedergabe.

-

Το Amarok είναι ένας πολλαπλών χρήσεων, πανίσχυρος αναπαραγωγέας μουσικής.

-

Amarok is a free, versatile and powerful music player.

-

Amarok es un potente y versátil reproductor de música libre.

-

Amarok on vapaa, monipuolinen ja tehokas musiikkisoitin.

-

Amarok adalah bebas, serbaguna dan player musik perkasa.

-

Amarok è un lettore musicale libero, versatile e potente.

-

Amarok은 강력한 자유 소프트웨어 음악 재생기입니다.

-

Amarok is een vrije, veelzijdige en krachtige muziekspeler.

-

ਅਮਰੋਕ ਮੁਫ਼ਤ, ਲਚਕੀਲਾ ਤੇ ਮਜ਼ਬੂਤ ਸੰਗੀਤ ਪਲੇਅਰ ਹੈ।

-

Amarok jest darmowym, wszechstronnym i zaawansowanym odtwarzaczem muzyki.

-

O Amarok é um leitor multimédia gratuito, versátil e poderoso.

-

Amarok é um reprodutor de músicas livre, versátil e poderoso.

-

Amarok je slobodný, univerzálny a silný prehrávač hudby.

-

Amarok je prost, vsestranski in zmogljiv predvajalnik glasbe.

-

Амарок је слободан, свестран и моћан музички плејер.

-

Amarok je slobodan, svestran i moćan muzički plejer.

-

Амарок је слободан, свестран и моћан музички плејер.

-

Amarok je slobodan, svestran i moćan muzički plejer.

-

Amarok är en fri, mångsidig och kraftfull musikspelare.

-

Amarok — вільна, універсальна та потужна програма для відтворення звукових даних.

-

xxAmarok is a free, versatile and powerful music player.xx

-

Features:

-

Característiques:

-

Vlastnosti:

-

Funktioner:

-

Funktionen:

-

Χαρακτηριστικά:

-

Features:

-

Funciones:

-

Ominaisuudet:

-

Ciri yang khas:

-

Funzionalità:

-

기능:

-

Mogelijkheden:

-

ਲੱਛਣ:

-

Możliwości:

-

Características:

-

Funcionalidades:

-

Funkcie:

-

Zmožnosti:

-

Могућности:

-

Mogućnosti:

-

Могућности:

-

Mogućnosti:

-

Funktioner:

-

Можливості:

-

xxFeatures:xx

-
    -
  • Dynamic playlists matching different criteria
  • -
  • Llistes de reproducció dinàmiques coincidint amb diferents criteris
  • -
  • Dynamické seznamy skladeb odpovídající různým požadavkům
  • -
  • Dynamiske spillelister som matcher forskellige kriterier
  • -
  • Dynamische Wiedergabelisten nach verschiedenen Kriterien
  • -
  • Δυναμικές λίστες αναπαραγωγής που ανταποκρίνονται σε διαφορετικά κριτήρια
  • -
  • Dynamic playlists matching different criteria
  • -
  • Listas de reproducción dinámicas según distintos criterios
  • -
  • Eri ehtoja vastaavat dynaamiset soittolistat
  • -
  • Playlist dinamis menyesuaikan kriteria yang berbeda
  • -
  • Scalette dinamiche che verificano diversi criteri
  • -
  • 조건에 따른 동적 재생 목록
  • -
  • Dynamische afspeellijsten die voldoen aan verschillende criteria
  • -
  • Dynamiczne listy odtwarzania spełniające różne warunki
  • -
  • Listas dinâmicas que correspondem a diferentes critérios
  • -
  • Listas de músicas dinâmicas que correspondem a diferentes critérios
  • -
  • Dynamické zoznamy skladieb sledujúce rôzne kritériá
  • -
  • Dinamični seznami predvajanja temelječi na raznolikih pogojih
  • -
  • Динамичке листе нумера по различитим критеријумима.
  • -
  • Dinamičke liste numera po različitim kriterijumima.
  • -
  • Динамичке листе нумера по различитим критеријумима.
  • -
  • Dinamičke liste numera po različitim kriterijumima.
  • -
  • Dynamiska spellistor som motsvarar olika kriterier
  • -
  • динамічні списки відтворення на основі різних критеріїв;
  • -
  • xxDynamic playlists matching different criteriaxx
  • -
  • Collection managing with rating support
  • -
  • Gestió de les col·leccions amb implementació per a les qualificacions
  • -
  • Správa sbírek s podporou hodnocení
  • -
  • Samlingshåndtering med understøttelse af vurderinger
  • -
  • Verwaltung von Sammlungen wit Unterstützung durch Bewertungen
  • -
  • Διαχείριση συλλογών με υποστήριξη αξιολόγησης
  • -
  • Collection managing with rating support
  • -
  • Gestión de colección con uso de puntuaciones
  • -
  • Kokoelmanhallinta arviointituella
  • -
  • Mengelola koleksi dengan dukungan peringkat
  • -
  • Gestione della collezione con supporto per la valutazione
  • -
  • 별점 기능이 있는 모음집 관리
  • -
  • Beheer van verzamelingen met ondersteuning van waardering
  • -
  • Zarządzanie zbiorem wraz z obsługą ocen
  • -
  • Gestão da colecção com o suporte para classificações
  • -
  • Gerenciamento de coleções com suporte a avaliação
  • -
  • Správa zbierok s podporou hodnotení
  • -
  • Upravljanje zbirk s podporo ocenam
  • -
  • Управљање збирком и подршка за оцењивање.
  • -
  • Upravljanje zbirkom i podrška za ocenjivanje.
  • -
  • Управљање збирком и подршка за оцењивање.
  • -
  • Upravljanje zbirkom i podrška za ocenjivanje.
  • -
  • Samlingshantering med betygsstöd
  • -
  • керування збіркою з підтримкою оцінок;
  • -
  • xxCollection managing with rating supportxx
  • -
  • Support for basic iPod, MTP and UMS music player devices
  • -
  • Implementació pels dispositius de reproducció de música bàsics com iPod, MTP i UMS
  • -
  • Podpora pro zařízení iPod, MTP a UMS
  • -
  • Understøttelse af basale iPod-, MTP- og UMS-musikafspillere
  • -
  • Unterstützung für Wiedergabegeräte wie iPod, MTP und UMS
  • -
  • Υποστήριξη για τις βασικές συσκευές iPod, MTP και UMS αναπαραγωγής μουσικής
  • -
  • Support for basic iPod, MTP and UMS music player devices
  • -
  • Implementación básica de dispositivos de reproducción de música como iPod y los que usan los protocolos MTP y UMS
  • -
  • Tuki tavallisille iPod-, MTP- ja UMS-musiikkisoitinlaitteille
  • -
  • Terutama mendukung perangkat player musik iPod, MTP dan UMS
  • -
  • Supporto per i lettori musicali iPod, MTP e UMS
  • -
  • iPod, MTP, UMS 음악 재생기 장치 지원
  • -
  • Ondersteuning voor basis iPod, MTP en UMS muziekspelerapparaten
  • -
  • Obsługa dla podstawowych urządzeń odtwarzających muzykę takich jak iPod, MTP oraz UMS
  • -
  • Suporte para os dispositivos leitores multimédia básicos de iPod, MTP e UMS
  • -
  • Suporte a dispositivos básicos para reprodução de música iPod, MTP e UMS
  • -
  • Podpora pre základné prehrávacie zariadenia iPod, MTP a UMS
  • -
  • Podpora osnovnim napravam za predvajanje glasbe: iPod, MTP in UMS
  • -
  • Подршка за основне МТП и УМС музичке плејере, и и‑под.
  • -
  • Podrška za osnovne MTP i UMS muzičke plejere, i iPod.
  • -
  • Подршка за основне МТП и УМС музичке плејере, и и‑под.
  • -
  • Podrška za osnovne MTP i UMS muzičke plejere, i iPod.
  • -
  • Stöd för grundläggande iPod-, MTP- och UMS-musikspelare
  • -
  • підтримка базової роботи з пристроями відтворення, що працюють за протоколами iPod, MTP та UMS;
  • -
  • xxSupport for basic iPod, MTP and UMS music player devicesxx
  • -
  • Integrated Internet services: last.fm, Magnatune, Jamendo, Ampache, mp3tunes and more.
  • -
  • Serveis integrats d'Internet: last.fm, Magnatune, Jamendo, Ampache, mp3tunes i més
  • -
  • Integrované internetové služby: last.fm, Magnatune, Jamendo, Ampache, mp3tunes a další.
  • -
  • Integrerede internettjenester: last.fm, Magnatune, Jamendo, Ampache, mp3tunes og andre.
  • -
  • Integrierte Internet-Dienste: last.fm, Magnatune, Jamendo, Ampache, mp3tunes und weitere.
  • -
  • Ενσωματωμένες Διαδικτυακές υπηρεσίες: last.fm, Magnatune, Jamendo, Ampache, mp3tunes και άλλα.
  • -
  • Integrated Internet services: last.fm, Magnatune, Jamendo, Ampache, mp3tunes and more.
  • -
  • Servicios de Internet integrados: last.fm, Magnatune, Jamendo, Ampache, mp3tunes y más.
  • -
  • Sisäänrakennetut internetpalvelut: Last.fm, Magnatune, Jamendo, Ampache, mp3tunes ja muita.
  • -
  • Layanan Internet terpadu: last.fm, Magnatune, Jamendo, Ampache, mp3tunes dan lebih banyak lagi.
  • -
  • Servizi Internet integrati: last.fm, Magnatune, Jamendo, Ampache, mp3tunes e altri.
  • -
  • last.fm, Magnatune, Jamendo, Ampache, mp3tunes 등 온라인 서비스 지원
  • -
  • Geïntegreerde internetservices: last.fm, Magnatune, Jamendo, Ampache, mp3tunes en meer.
  • -
  • Zintegrowane usługi internetowe: last.fm, Magnatune, Jamendo, Ampache, mp3tunes i więcej.
  • -
  • Serviços da Internet integrados: last.fm, Magnatune, Jamendo, Ampache, mp3tunes entre outros.
  • -
  • Serviços de Internet integrados: last.fm, Magnatune, Jamendo, Ampache, mp3tunes entre outros.
  • -
  • Integrované internetové služby: last.fm, Magnatune, Jamendo, Ampache, mp3tunes a viac.
  • -
  • Vgrajene internetne storitve: last.fm, Magnatune, Jamendo, Ampache, mp3tunes in več.
  • -
  • Уклопљени интернет сервиси: ЛастФМ, Магнатјун, Џамендо, Ампач, МП3‑тјунс, и други.
  • -
  • Uklopljeni internet servisi: last.fm, Magnatune, Jamendo, Ampache, MP3Tunes, i drugi.
  • -
  • Уклопљени интернет сервиси: ЛастФМ, Магнатјун, Џамендо, Ампач, МП3‑тјунс, и други.
  • -
  • Uklopljeni internet servisi: last.fm, Magnatune, Jamendo, Ampache, MP3Tunes, i drugi.
  • -
  • Integrerade Internet-tjänster: last.fm, Magnatune, Jamendo, Ampache, mp3tunes med flera.
  • -
  • інтеграція з інтернет-службами: last.fm, Magnatune, Jamendo, Ampache, mp3tunes тощо;
  • -
  • xxIntegrated Internet services: last.fm, Magnatune, Jamendo, Ampache, mp3tunes and more.xx
  • -
  • Scripting support
  • -
  • Implementació per a la creació d'scripts
  • -
  • Podpora pro skripty
  • -
  • Understøttelse af scripts
  • -
  • Skript-Unterstützung
  • -
  • Υποστήριξη συγγραφής σεναρίων
  • -
  • Scripting support
  • -
  • Uso de guiones
  • -
  • Skriptaustuki
  • -
  • Dukungan skrip
  • -
  • Supporto per la creazione di script
  • -
  • 스크립팅 지원
  • -
  • Ondersteuning voor scripting
  • -
  • Obsługa skryptów
  • -
  • Suporte para a programação
  • -
  • Suporte a scripts
  • -
  • Podpora skriptovania
  • -
  • Podpora skriptom
  • -
  • Подршка за скриптовање.
  • -
  • Podrška za skriptovanje.
  • -
  • Подршка за скриптовање.
  • -
  • Podrška za skriptovanje.
  • -
  • Stöd för skript
  • -
  • підтримка роботи зі скриптами;
  • -
  • xxScripting supportxx
  • -
  • Cover manager
  • -
  • Gestor de cobertes
  • -
  • Správce obalů
  • -
  • Omslagshåndtering
  • -
  • Cover-Verwaltung
  • -
  • Διαχειριστής εξωφύλλων
  • -
  • Cover manager
  • -
  • Gestor de carátulas
  • -
  • Kansikuvien hallinta
  • -
  • Manajer sampul
  • -
  • Gestore delle copertine
  • -
  • 커버 관리자
  • -
  • Hoesbeheerder
  • -
  • Zarządzanie okładkami
  • -
  • Gestor de capas
  • -
  • Gerenciador de capas
  • -
  • Správca obalov
  • -
  • Upravljalnik ovitkov
  • -
  • Менаџер омота.
  • -
  • Menadžer omota.
  • -
  • Менаџер омота.
  • -
  • Menadžer omota.
  • -
  • Omslagshanterare
  • -
  • засіб керування збіркою зображень обкладинок;
  • -
  • xxCover managerxx
  • -
  • Replay gain support
  • -
  • Implementació de la repetició de guany
  • -
  • Podpora Replay gain
  • -
  • Replay Gain-understøttelse
  • -
  • Unterstützung für Lautstärkeanpassung
  • -
  • Υποστήριξη κανονικοποίησης ακουστότητας
  • -
  • Replay gain support
  • -
  • Implementación de normalización de audio
  • -
  • Voimakkuudentasauksen tuki
  • -
  • Dukungan gain mainkan lagi
  • -
  • Supporto del guadagno di riproduzione
  • -
  • 리플레이게인 지원
  • -
  • Ondersteuning van Replay gain
  • -
  • Obsługa trybu replay gain
  • -
  • Suporte para o ganho de reprodução
  • -
  • Suporte a ajuste de ganho
  • -
  • Podpora replay gain
  • -
  • Podpora jakosti predvajanja
  • -
  • Подршка за поновљиво појачање.
  • -
  • Podrška za ponovljivo pojačanje.
  • -
  • Подршка за поновљиво појачање.
  • -
  • Podrška za ponovljivo pojačanje.
  • -
  • Stöd för uppspelningsnivå
  • -
  • підтримка вирівнювання гучності.
  • -
  • xxReplay gain supportxx
  • -
-
- http://amarok.kde.org - https://bugs.kde.org/enter_bug.cgi?format=guided&product=amarok - http://docs.kde.org/development/en/extragear-multimedia/amarok/index.html - - - http://kde.org/images/screenshots/amarok.png - - - https://amarok.kde.org/files/Amarok2.7screenie.png - - - KDE - - amarok - -
diff --git a/amarok/src/amarok.desktop b/amarok/src/amarok.desktop deleted file mode 100644 index d8277252..00000000 --- a/amarok/src/amarok.desktop +++ /dev/null @@ -1,235 +0,0 @@ -[Desktop Entry] -Type=Application -Version=1.0 -Name=Amarok -Name[be]=Amarok -Name[bg]=Amarok -Name[bs]=Amarok -Name[ca]=Amarok -Name[ca@valencia]=Amarok -Name[cs]=Amarok -Name[csb]=Amarok -Name[da]=Amarok -Name[de]=Amarok -Name[el]=AmaroK -Name[en_GB]=Amarok -Name[eo]=Amarok -Name[es]=Amarok -Name[et]=Amarok -Name[eu]=Amarok -Name[fi]=Amarok -Name[fr]=Amarok -Name[ga]=Amarok -Name[gl]=Amarok -Name[he]=Amarok -Name[hi]=अमारॉक -Name[hne]=अमाराक -Name[hu]=Amarok -Name[id]=Amarok -Name[is]=Amarok -Name[it]=Amarok -Name[ja]=Amarok -Name[km]=Amarok -Name[ko]=Amarok -Name[ku]=Amarok -Name[lt]=Amarok -Name[lv]=Amarok -Name[ms]=Amarok -Name[nb]=Amarok -Name[nds]=Amarok -Name[ne]=अमारोक -Name[nl]=Amarok -Name[nn]=Amarok -Name[oc]=Amarok -Name[pa]=ਅਮਰੋਕ -Name[pl]=Amarok -Name[pt]=Amarok -Name[pt_BR]=Amarok -Name[ro]=Amarok -Name[ru]=Amarok -Name[sk]=Amarok -Name[sl]=Amarok -Name[sq]=Amarok -Name[sr]=Амарок -Name[sr@ijekavian]=Амарок -Name[sr@ijekavianlatin]=Amarok -Name[sr@latin]=Amarok -Name[sv]=Amarok -Name[th]=แอมอะร็อก -Name[tr]=Amarok -Name[ug]=Amarok -Name[uk]=Amarok -Name[wa]=Amarok -Name[x-test]=xxAmarokxx -Name[zh_CN]=Amarok -Name[zh_TW]=Amarok -GenericName=Audio Player -GenericName[be]=Аўдыёпрайгравальнік -GenericName[bg]=Аудио плеър -GenericName[bs]=Audio plejer -GenericName[ca]=Reproductor d'àudio -GenericName[ca@valencia]=Reproductor d'àudio -GenericName[cs]=Zvukový přehrávač -GenericName[csb]=Grôcz aùdio -GenericName[da]=Lydafspiller -GenericName[de]=Audio-Wiedergabe -GenericName[el]=Αναπαραγωγή ήχου -GenericName[en_GB]=Audio Player -GenericName[eo]=Sonludilo -GenericName[es]=Reproductor de audio -GenericName[et]=Helifailide mängija -GenericName[eu]=Audio erreproduzigailua -GenericName[fi]=Musiikkisoitin -GenericName[fr]=Lecteur audio -GenericName[ga]=Seinnteoir Fuaime -GenericName[gl]=Reprodutor de audio -GenericName[he]=נגן שמע -GenericName[hne]=आडियो प्लेयर -GenericName[hu]=Zenelejátszó -GenericName[id]=Player Audio -GenericName[is]=Tónlistarspilari -GenericName[it]=Lettore audio -GenericName[ja]=オーディオプレーヤー -GenericName[km]=កម្មវិធី​ចាក់​អូឌីយ៉ូ -GenericName[ko]=오디오 재생기 -GenericName[ku]=Lêdarê Muzîkê -GenericName[lt]=Muzikos grotuvas -GenericName[lv]=Audio atskaņotājs -GenericName[mai]=आडियो प्लेयर -GenericName[ms]=Pemain Audio -GenericName[nb]=Lydavspiller -GenericName[nds]=Klangafspeler -GenericName[ne]=अडियो प्लेयर -GenericName[nl]=Audiospeler -GenericName[nn]=Musikkspelar -GenericName[pa]=ਆਡੀਓ ਪਲੇਅਰ -GenericName[pl]=Odtwarzacz dźwięku -GenericName[pt]=Leitor de Áudio -GenericName[pt_BR]=Reprodutor de áudio -GenericName[ro]=Redare audio -GenericName[ru]=Аудиопроигрыватель -GenericName[sk]=Audio prehrávač -GenericName[sl]=Predvajalnik glasbe -GenericName[sq]=Lexues audio -GenericName[sr]=Аудио плејер -GenericName[sr@ijekavian]=Аудио плејер -GenericName[sr@ijekavianlatin]=Audio plejer -GenericName[sr@latin]=Audio plejer -GenericName[sv]=Musikspelare -GenericName[th]=เครื่องเล่นเสียง -GenericName[tr]=Müzik Çalar -GenericName[ug]=ئۈن قويغۇچ -GenericName[uk]=Аудіопрогравач -GenericName[wa]=Djouweu d' son -GenericName[x-test]=xxAudio Playerxx -GenericName[zh_CN]=音频播放器 -GenericName[zh_TW]=音效播放器 -Exec=amarok --icon '%i' --caption '%c' %U -Comment=Amarok - Rediscover Your Music! -Comment[be]=Amarok - адкрыйце для сябе сваю музыку! -Comment[bg]=Amarok - преоткрийте музиката! -Comment[bs]=Amarok — otkrijte svoju muziku! -Comment[ca]=Amarok - Redescobreix la teva música! -Comment[ca@valencia]=Amarok - Redescobreix la teva música! -Comment[cs]=AmaroK - znovu objevte svou hudbu. -Comment[csb]=Amarok - òdrëjë znowa swòją mùzykã -Comment[da]=Amarok - Genopdag din musik! -Comment[de]=Amarok – Musik neu erleben! -Comment[el]=Amarok - Ανακαλύψτε ξανά τη μουσική σας! -Comment[en_GB]=Amarok - Rediscover Your Music! -Comment[eo]=Amarok - Remalkovru vian muzikon! -Comment[es]=Amarok - ¡Vuelve a descubrir tu música! -Comment[et]=Amarok - naudi oma muusikat! -Comment[eu]=Amarok - Aurkitu berriro zure musika! -Comment[fi]=Amarok – löydä musiikkisi uudelleen -Comment[fr]=Amarok - Redécouvrez votre musique ! -Comment[ga]=Amarok - Athaimsigh do chuid Ceoil! -Comment[gl]=Amarok - Descubra de novo a música! -Comment[he]=Amarok - גלה מחדש את המוזיקה -Comment[hne]=अमाराक - अपन संगीत ल फिर से खोजव! -Comment[hu]=Amarok - fedezze fel a zenéjét -Comment[id]=Amarok - Temukan Kembali Musik Anda! -Comment[is]=Amarok - Enduruppgötvaðu tónlistina þína! -Comment[it]=Amarok - Riscopri la tua musica! -Comment[ja]=Amarok - あなたの音楽を再発見 -Comment[km]=Amarok - រក​ឃើញ​តន្ត្រី​របស់​អ្នក​ឡើង​វិញ ! -Comment[ko]=Amarok - 음악의 재발견! -Comment[ku]=Amarok - muzîkê ji nû ve keşif bike -Comment[lt]=Amarok – atraskite savo muziką iš naujo! -Comment[lv]=Amarok - atklāj savu mūziku! -Comment[ms]=Amarok - Temui Muzik Anda! -Comment[nb]=Amarok – Oppdag musikken din på nytt! -Comment[nds]=Amarok - Beleev Dien Musik nieg! -Comment[ne]=अमारोक - आफ्नो बाजा फेरि पत्ता लगाउनुहोस्! -Comment[nl]=Amarok - Herontdek uw muziek! -Comment[nn]=Amarok – gjenoppdag musikken din! -Comment[pa]=ਅਮਰੋਕ - ਆਪਣਾ ਸੰਗੀਤ ਮੁੜ ਲੱਭੋ! -Comment[pl]=Amarok - odkryj na nowo swoją muzykę! -Comment[pt]=Amarok - Descubra de Novo a sua Música! -Comment[pt_BR]=Amarok - Redescubra suas músicas! -Comment[ro]=Amarok - Redescoperă-ți muzica! -Comment[ru]=Amarok - посмотрите на музыку по-другому -Comment[sk]=Amarok - Znova objavte svoju hudbu! -Comment[sl]=Amarok - Znova odkrijte svojo glasbo! -Comment[sr]=Амарок — откријте своју музику! -Comment[sr@ijekavian]=Амарок — откријте своју музику! -Comment[sr@ijekavianlatin]=Amarok — otkrijte svoju muziku! -Comment[sr@latin]=Amarok — otkrijte svoju muziku! -Comment[sv]=Amarok - Återupptäck din musik! -Comment[th]=แอมอะร็อก - ค้นพบมิติใหม่ในดนตรีของคุณ ! -Comment[tr]=Amarok - Müziğinizi yeniden keşfedin! -Comment[ug]=Amarok - مۇزىكىلىرىڭىزنى قايتا بايقايسىز -Comment[uk]=Amarok — відкрийте свою музику знову! -Comment[wa]=Amarok - Ridiscovroz vosse muzike! -Comment[x-test]=xxAmarok - Rediscover Your Music!xx -Comment[zh_CN]=Amarok - 重新探索您的音乐! -Comment[zh_TW]=Amarok - 重新探索您的音樂世界! -Icon=amarok -# Add pure audio formats here, for other formats see amarok_*.desktop files -# See bug 242292 -MimeType=audio/aac;audio/mp4;audio/mpeg;audio/mpegurl;audio/vnd.rn-realaudio;audio/vorbis;audio/x-flac;audio/x-mp3;audio/x-mpegurl;audio/x-ms-wma;audio/x-musepack;audio/x-oggflac;audio/x-pn-realaudio;audio/x-scpls;audio/x-speex;audio/x-vorbis;audio/x-wav;application/x-ogm-audio;audio/x-vorbis+ogg;audio/ogg; -X-DocPath=amarok/index.html -X-KDE-Keywords=music,podcast -X-KDE-Keywords[bs]=muzika,podemisija -X-KDE-Keywords[ca]=música,podcast -X-KDE-Keywords[ca@valencia]=música,podcast -X-KDE-Keywords[cs]=hudba,podcast -X-KDE-Keywords[da]=musik,podcast -X-KDE-Keywords[de]=Musik,Podcast -X-KDE-Keywords[el]=μουσική,podcast -X-KDE-Keywords[en_GB]=music,podcast -X-KDE-Keywords[es]=música,podcast -X-KDE-Keywords[et]=muusika,podcast -X-KDE-Keywords[fi]=musiikki,podcast -X-KDE-Keywords[fr]=musique, podcast -X-KDE-Keywords[ga]=ceol,podchraoladh -X-KDE-Keywords[gl]=música,podcast -X-KDE-Keywords[hu]=zene,podcast -X-KDE-Keywords[id]=musik,podcast -X-KDE-Keywords[it]=musica,podcast -X-KDE-Keywords[ja]=music,podcast -X-KDE-Keywords[km]=តន្ត្រី ផតខាស់ -X-KDE-Keywords[lt]=muzika,prenumerata -X-KDE-Keywords[lv]=mūzika,podraide -X-KDE-Keywords[nb]=musikk,podkasting -X-KDE-Keywords[nl]=muziek,podcast -X-KDE-Keywords[pl]=muzyka,podcast -X-KDE-Keywords[pt]=música,podcast -X-KDE-Keywords[pt_BR]=música,podcast -X-KDE-Keywords[ro]=muzică,podcast -X-KDE-Keywords[ru]=music,podcast,музыка,подкаст -X-KDE-Keywords[sk]=hudba,podcast -X-KDE-Keywords[sl]=glasba,podcast -X-KDE-Keywords[sr]=music,podcast,музика,подемисија -X-KDE-Keywords[sr@ijekavian]=music,podcast,музика,подемисија -X-KDE-Keywords[sr@ijekavianlatin]=music,podcast,muzika,podemisija -X-KDE-Keywords[sr@latin]=music,podcast,muzika,podemisija -X-KDE-Keywords[sv]=musik,podsändning -X-KDE-Keywords[tr]=müzik,podcast -X-KDE-Keywords[uk]=music,podcast,музика,трансляція,подкаст -X-KDE-Keywords[x-test]=xxmusicxx,xxpodcastxx -X-KDE-Keywords[zh_CN]=music,podcast,音乐,播客 -X-KDE-Keywords[zh_TW]=music,podcast -X-KDE-Protocols=http -Terminal=false -Categories=Qt;KDE;AudioVideo;Audio;Player; diff --git a/amarok/src/amarok.knsrc b/amarok/src/amarok.knsrc deleted file mode 100644 index 4e0792ae..00000000 --- a/amarok/src/amarok.knsrc +++ /dev/null @@ -1,5 +0,0 @@ -[KNewStuff3] -ProvidersUrl=http://download.kde.org/ocs/providers.xml -Categories=Amarok 2.0 Script -Uncompress=always -TargetDir=amarok/scripts diff --git a/amarok/src/amarok_addaspodcast.desktop b/amarok/src/amarok_addaspodcast.desktop deleted file mode 100644 index dd78f9f1..00000000 --- a/amarok/src/amarok_addaspodcast.desktop +++ /dev/null @@ -1,64 +0,0 @@ -[Desktop Entry] -ServiceTypes=text/html,application/xml,application/xml,application/rss+xml,text/rdf -Actions=addAsPodcast; -[Desktop Action addAsPodcast] -Name=Add as Podcast to Amarok -Name[be]=Дадаць як подкаст у Amarok -Name[bg]=Добавяне като подкаст в Amarok -Name[bs]=Dodaj kao podemisiju u Amarok -Name[ca]=Afegeix com a podcast a l'Amarok -Name[ca@valencia]=Afig com a podcast a l'Amarok -Name[cs]=Přidat do Amaroku jako podcast -Name[csb]=Dodôj jakno podcast do Amaroka -Name[da]=Tilføj som podcast til Amarok -Name[de]=Als Podcast zu Amarok hinzufügen -Name[el]=Προσθήκη ως εκπομπή Pod στο Amarok -Name[en_GB]=Add as Podcast to Amarok -Name[eo]=Aldoni kiel podkaston al Amarok -Name[es]=Añadir como podcast a Amarok -Name[et]=Lisa Podcastina Amarokile -Name[eu]=Gehitu Amarok-en podcast gisa -Name[fi]=Lisää Amarokiin podcastina -Name[fr]=Ajouter en tant que podcast dans Amarok -Name[ga]=Cuir le hAmarok mar Phodchraoladh -Name[gl]=Engadir un Podcast en Amarok -Name[he]=הוסף ל־Amarok כפודקאסט -Name[hne]=पोस्टकार्ड के रुप मं अमाराक ल जोड़व -Name[hu]=Betevés az Amarokba podcast-ként -Name[id]=Tambah sebagai Podcast ke Amarok -Name[is]=Bæta við sem podcast hlaðvarpi í Amarok -Name[it]=Aggiungi come podcast in Amarok -Name[ja]=ポッドキャストとして Amarok に追加 -Name[km]=បន្ថែម​ជា​ផតខាស់​ទៅ Amarok -Name[ko]=Amarok에 팟캐스트로 추가하기 -Name[ku]=Wekî Podcast lê Amarok zêde bike -Name[lt]=Įterpti podcast į Amarok grojaraštį -Name[lv]=Pievienot Amarok kā podraidi -Name[ms]=Tambah sebagai Podcast ke Amarok -Name[nb]=Legg til som podcast i Amarok -Name[nds]=As Podcast na Amarok tofögen -Name[ne]=अमारोकमा पोडकास्टको रूपमा थप्नुहोस् -Name[nl]=Als Podcast aan Amarok toevoegen -Name[nn]=Legg til som podkast i Amarok -Name[pa]=ਇੱਕ ਪੋਡਕਾਸਟ ਅਮਰੋਕ ਵਿੱਚ ਸ਼ਾਮਲ -Name[pl]=Dodaj jako podcast do Amaroka -Name[pt]=Adicionar como 'Podcast' ao Amarok -Name[pt_BR]=Adicionar como Podcast ao Amarok -Name[ro]=Adaugă ca podcast la Amarok -Name[ru]=Добавить подкаст в Amarok -Name[sk]=Pridať ako Podcast do Amarok -Name[sl]=Dodaj v Amarok kot podcast -Name[sr]=Додај као подемисију у Амарок -Name[sr@ijekavian]=Додај као подемисију у Амарок -Name[sr@ijekavianlatin]=Dodaj kao podemisiju u Amarok -Name[sr@latin]=Dodaj kao podemisiju u Amarok -Name[sv]=Lägg till som podradiosändning i Amarok -Name[th]=เพิ่มเป็นพ็อดแคสต์ไปยังแอมอะร็อก -Name[tr]=Amarok'a Podcast olarak Ekle -Name[uk]=Додати в Amarok як радіотрансляцію -Name[wa]=Radjouter come Podcast a Amarok -Name[x-test]=xxAdd as Podcast to Amarokxx -Name[zh_CN]=作为播客添加到 Amarok -Name[zh_TW]=新增為 Podcast 到 Amaork 中 -Icon=amarok -Exec=qdbus org.kde.amarok /PlaylistBrowser addPodcast %u diff --git a/amarok/src/amarok_append.desktop b/amarok/src/amarok_append.desktop deleted file mode 100644 index 049869dd..00000000 --- a/amarok/src/amarok_append.desktop +++ /dev/null @@ -1,254 +0,0 @@ -[Desktop Entry] -ServiceTypes=KonqPopupMenu/Plugin,audio/*,inode/directory -Actions=appendToPlaylist;appendAndPlay;queueTrack; -Type=Service -X-KDE-Submenu=Amarok -X-KDE-Submenu[be]=Amarok -X-KDE-Submenu[bg]=Amarok -X-KDE-Submenu[bs]=Amarok -X-KDE-Submenu[ca]=Amarok -X-KDE-Submenu[ca@valencia]=Amarok -X-KDE-Submenu[cs]=Amarok -X-KDE-Submenu[csb]=Amarok -X-KDE-Submenu[da]=Amarok -X-KDE-Submenu[de]=Amarok -X-KDE-Submenu[el]=AmaroK -X-KDE-Submenu[en_GB]=Amarok -X-KDE-Submenu[eo]=Amarok -X-KDE-Submenu[es]=Amarok -X-KDE-Submenu[et]=Amarok -X-KDE-Submenu[eu]=Amarok -X-KDE-Submenu[fi]=Amarok -X-KDE-Submenu[fr]=Amarok -X-KDE-Submenu[ga]=Amarok -X-KDE-Submenu[gl]=Amarok -X-KDE-Submenu[he]=Amarok -X-KDE-Submenu[hi]=अमारॉक -X-KDE-Submenu[hne]=अमाराक -X-KDE-Submenu[hu]=Amarok -X-KDE-Submenu[id]=Amarok -X-KDE-Submenu[is]=Amarok -X-KDE-Submenu[it]=Amarok -X-KDE-Submenu[ja]=Amarok -X-KDE-Submenu[km]=Amarok -X-KDE-Submenu[ko]=Amarok -X-KDE-Submenu[ku]=Amarok -X-KDE-Submenu[lt]=Amarok -X-KDE-Submenu[lv]=Amarok -X-KDE-Submenu[mr]=अमारॉक -X-KDE-Submenu[ms]=Amarok -X-KDE-Submenu[nb]=Amarok -X-KDE-Submenu[nds]=Amarok -X-KDE-Submenu[ne]=अमारोक -X-KDE-Submenu[nl]=Amarok -X-KDE-Submenu[nn]=Amarok -X-KDE-Submenu[oc]=Amarok -X-KDE-Submenu[pa]=ਅਮਰੋਕ -X-KDE-Submenu[pl]=Amarok -X-KDE-Submenu[pt]=Amarok -X-KDE-Submenu[pt_BR]=Amarok -X-KDE-Submenu[ro]=Amarok -X-KDE-Submenu[ru]=Amarok -X-KDE-Submenu[sk]=Amarok -X-KDE-Submenu[sl]=Amarok -X-KDE-Submenu[sq]=Amarok -X-KDE-Submenu[sr]=Амарок -X-KDE-Submenu[sr@ijekavian]=Амарок -X-KDE-Submenu[sr@ijekavianlatin]=Amarok -X-KDE-Submenu[sr@latin]=Amarok -X-KDE-Submenu[sv]=Amarok -X-KDE-Submenu[th]=แอมอะร็อก -X-KDE-Submenu[tr]=Amarok -X-KDE-Submenu[ug]=Amarok -X-KDE-Submenu[uk]=Amarok -X-KDE-Submenu[wa]=Amarok -X-KDE-Submenu[x-test]=xxAmarokxx -X-KDE-Submenu[zh_CN]=Amarok -X-KDE-Submenu[zh_TW]=Amarok - -[Desktop Action appendToPlaylist] -Name=Append to Playlist -Name[be]=Дадаць у спіс прайгравання -Name[bg]=Добавяне към списъка със записи -Name[bs]=Dodaј u listu numera -Name[ca]=Afegeix a la llista de reproducció -Name[ca@valencia]=Afig a la llista de reproducció -Name[cs]=Přidat do seznamu skladeb -Name[csb]=Dodôj do lëstë graniô -Name[da]=Føj til spilleliste -Name[de]=An Wiedergabeliste anhängen -Name[el]=Προσθήκη στη λίστα αναπαραγωγής -Name[en_GB]=Append to Playlist -Name[eo]=Aligi al la ludlisto -Name[es]=Añadir a la lista de reproducción -Name[et]=Lisa esitusnimekirja -Name[eu]=Erantsi zerrendara -Name[fi]=Lisää soittolistaan -Name[fr]=Ajouter à la liste de lecture -Name[ga]=Iarcheangail le Seinmliosta -Name[gl]=Engadir á lista de reprodución -Name[hi]=गीत-सूची के अंत में जोड़ें -Name[hne]=गीत-सूची के आखरी मं जोड़व -Name[hu]=Hozzáfűzés a lejátszólistához -Name[id]=Bubuhkan ke Playlist -Name[is]=Bæta við lagalista -Name[it]=Aggiungi alla scaletta -Name[ja]=プレイリストに追加 -Name[km]=បន្ថែម​ទៅ​ខាង​ចុង​បញ្ជី​ចាក់ -Name[ko]=재생 목록에 덧붙이기 -Name[ku]=Bixe ser lîsteya lêdanê -Name[lt]=Papildyti grojaraštį -Name[lv]=Pievienot repertuāram -Name[ms]=Tambah ke Senaraimain -Name[nb]=Legg til i spilleliste -Name[nds]=Na Afspeellist tofögen -Name[ne]=बजाउने सूचीमा थप्नुहोस् -Name[nl]=Toevoegen aan afspeellijst -Name[nn]=Legg til speleliste -Name[pa]=ਪਲੇਅਲਿਸਟ ਵਿੱਚ ਸ਼ਾਮਲ -Name[pl]=Dołącz do listy odtwarzania -Name[pt]=Adicionar à Lista de Reprodução -Name[pt_BR]=Anexar à lista de músicas -Name[ro]=Anexare la lista de redare -Name[ru]=Добавить в список воспроизведения -Name[sk]=Pridať do zoznamu skladieb -Name[sl]=Dodaj na seznam predvajanja -Name[sr]=Додај у листу нумера -Name[sr@ijekavian]=Додај у листу нумера -Name[sr@ijekavianlatin]=Dodaj u listu numera -Name[sr@latin]=Dodaj u listu numera -Name[sv]=Lägg till i spellistan -Name[th]=เพิ่มเข้าไปในรายการเล่น -Name[tr]=Parça Listesine Ekle -Name[uk]=Додати до списку композицій -Name[wa]=Mete dins l' djivêye a djouwer -Name[x-test]=xxAppend to Playlistxx -Name[zh_CN]=追加到播放列表 -Name[zh_TW]=添加到清單中 -Icon=amarok -Exec=amarok -a %U - -[Desktop Action appendAndPlay] -Name=Append & Play -Name[be]=Дадаць і граць -Name[bg]=Добавяне и изпълнение -Name[bs]=Dodaj i pusti -Name[ca]=Afegeix i reprodueix -Name[ca@valencia]=Afig i reprodueix -Name[cs]=Připojit a hrát -Name[csb]=Dodôj ë grôj -Name[da]=Tilføj og afspil -Name[de]=An Wiedergabeliste anhängen und wiedergeben -Name[el]=Προσθήκη & αναπαραγωγή -Name[en_GB]=Append & Play -Name[eo]=Aligi kaj ludi -Name[es]=Añadir y reproducir -Name[et]=Lisa ja esita -Name[eu]=Erantsi eta erreproduzitu -Name[fi]=Lisää soittolistaan ja soita -Name[fr]=Ajouter & Lire -Name[ga]=Iarcheangail agus Seinn -Name[gl]=Engadir e reproducir -Name[hi]=अंत में जोड़ें व बजाएँ -Name[hne]=आखरी मं जोड़व अउ बजाव -Name[hu]=Hozzáfűzés és lejátszás -Name[id]=Bubuhkan & Mainkan -Name[is]=Bæta við & spila -Name[it]=Aggiungi e riproduci -Name[ja]=追加して再生 -Name[km]=បន្ថែម​ខាង​ចុង និង​ចាក់ -Name[ko]=덧붙이고 재생하기 -Name[ku]=Bixe & Lê bide -Name[lt]=Papildyti ir groti -Name[lv]=Pievienot un atskaņot -Name[ms]=Tambah & Main -Name[nb]=Legg til & spill av -Name[nds]=Tofögen un afspelen -Name[ne]=थप्नुहोस् र बजाउनुहोस् -Name[nl]=Toevoegen en afspelen -Name[nn]=Legg til og spel -Name[pa]=ਸ਼ਾਮਲ ਕਰੋ ਅਤੇ ਚਲਾਓ -Name[pl]=Dołącz i odtwórz -Name[pt]=Adicionar e Tocar -Name[pt_BR]=Anexar e reproduzir -Name[ro]=Anexează și redă -Name[ru]=Добавить и воспроизвести -Name[sk]=Pridať a prehrať -Name[sl]=Dodaj in predvajaj -Name[sr]=Додај и пусти -Name[sr@ijekavian]=Додај и пусти -Name[sr@ijekavianlatin]=Dodaj i pusti -Name[sr@latin]=Dodaj i pusti -Name[sv]=Lägg till och spela -Name[th]=เพิ่มและเล่น -Name[tr]=Parça Listesine Ekle ve Çal -Name[uk]=Додати і відтворити -Name[wa]=Mete dins l' djivêye eyet djouwer -Name[x-test]=xxAppend & Playxx -Name[zh_CN]=追加并播放 -Name[zh_TW]=添加並播放 -Icon=amarok -Exec=amarok --append %U --play - -[Desktop Action queueTrack] -Name=Queue Track -Name[be]=Дадаць у чаргу -Name[bg]=На опашката -Name[bs]=Stavi numeru u red -Name[ca]=Encua la peça -Name[ca@valencia]=Encua la peça -Name[cs]=Zařadit skladbu -Name[csb]=Dodôj do rédżi -Name[da]=Sæt spor i kø -Name[de]=In Warteschlange einstellen -Name[el]=Εισαγωγή κομματιού στην αναμονή -Name[en_GB]=Queue Track -Name[eo]=Envicigi la trakon -Name[es]=Encolar pista -Name[et]=Sea pala järjekorda -Name[eu]=Ilaratu pista -Name[fi]=Lisää jonoon -Name[fr]=Ajouter à la file d'attente -Name[ga]=Ciúáil Amhrán -Name[gl]=Pór a pista en espera -Name[he]=הוסף רצועה לתור -Name[hi]=ट्रैक कतार में लगाएं -Name[hne]=ट्रैक कतार मं लगाव -Name[hu]=Szám betevése a sorba -Name[id]=Antrian Track -Name[is]=Setja í biðröð -Name[it]=Accoda traccia -Name[ja]=トラックをキュー -Name[km]=តម្រៀប​បទ​ជា​ជួរ -Name[ko]=대기열에 추가하기 -Name[ku]=Rêza Stranan -Name[lt]=Pridėti į eilę -Name[lv]=Pievienot rindai -Name[ms]=Trek Giliran -Name[nb]=Legg spor i kø -Name[nds]=Stück inregen -Name[ne]=लाम ट्रयाक -Name[nl]=Track in wachtrij plaatsen -Name[nn]=Legg spor i kø -Name[pa]=ਟਰੈਕ ਕਤਾਰ 'ਚ -Name[pl]=Wstaw utwór do kolejki -Name[pt]=Colocar a Faixa na Fila -Name[pt_BR]=Colocar faixa na fila -Name[ro]=Pune în coadă -Name[ru]=Поставить в очередь -Name[sk]=Zaradiť do frontu -Name[sl]=Dodaj skladbo v vrsto -Name[sr]=Стави нумеру у ред -Name[sr@ijekavian]=Стави нумеру у ред -Name[sr@ijekavianlatin]=Stavi numeru u red -Name[sr@latin]=Stavi numeru u red -Name[sv]=Köa spår -Name[th]=ส่งแทร็กเข้าคิวรอเล่น -Name[tr]=Parçayı Kuyruğa Ekle -Name[uk]=Поставити композицію в чергу -Name[wa]=Mete boket el cawêye -Name[x-test]=xxQueue Trackxx -Name[zh_CN]=音轨排队 -Name[zh_TW]=佇列曲目 -Icon=amarok -Exec=amarok --queue %U diff --git a/amarok/src/amarok_codecinstall.desktop b/amarok/src/amarok_codecinstall.desktop deleted file mode 100644 index e740319c..00000000 --- a/amarok/src/amarok_codecinstall.desktop +++ /dev/null @@ -1,14 +0,0 @@ -[Desktop Entry] -Type=ServiceType -X-KDE-ServiceType=Amarok/CodecInstall - -# The unplayable codec -[PropertyDef::X-KDE-Amarok-codec] -Type=QString - -[PropertyDef::X-KDE-Amarok-engine] -Type=QString - -# If true, Amarok will show a warning dialog about the experimental nature of this plugin. -[PropertyDef::Exec] -Type=QString diff --git a/amarok/src/amarok_containers.desktop b/amarok/src/amarok_containers.desktop deleted file mode 100644 index 82a35ec6..00000000 --- a/amarok/src/amarok_containers.desktop +++ /dev/null @@ -1,234 +0,0 @@ -[Desktop Entry] -Type=Application -Version=1.0 -Name=Amarok -Name[be]=Amarok -Name[bg]=Amarok -Name[bs]=Amarok -Name[ca]=Amarok -Name[ca@valencia]=Amarok -Name[cs]=Amarok -Name[csb]=Amarok -Name[da]=Amarok -Name[de]=Amarok -Name[el]=AmaroK -Name[en_GB]=Amarok -Name[eo]=Amarok -Name[es]=Amarok -Name[et]=Amarok -Name[eu]=Amarok -Name[fi]=Amarok -Name[fr]=Amarok -Name[ga]=Amarok -Name[gl]=Amarok -Name[he]=Amarok -Name[hi]=अमारॉक -Name[hne]=अमाराक -Name[hu]=Amarok -Name[id]=Amarok -Name[is]=Amarok -Name[it]=Amarok -Name[ja]=Amarok -Name[km]=Amarok -Name[ko]=Amarok -Name[ku]=Amarok -Name[lt]=Amarok -Name[lv]=Amarok -Name[ms]=Amarok -Name[nb]=Amarok -Name[nds]=Amarok -Name[ne]=अमारोक -Name[nl]=Amarok -Name[nn]=Amarok -Name[oc]=Amarok -Name[pa]=ਅਮਰੋਕ -Name[pl]=Amarok -Name[pt]=Amarok -Name[pt_BR]=Amarok -Name[ro]=Amarok -Name[ru]=Amarok -Name[sk]=Amarok -Name[sl]=Amarok -Name[sq]=Amarok -Name[sr]=Амарок -Name[sr@ijekavian]=Амарок -Name[sr@ijekavianlatin]=Amarok -Name[sr@latin]=Amarok -Name[sv]=Amarok -Name[th]=แอมอะร็อก -Name[tr]=Amarok -Name[ug]=Amarok -Name[uk]=Amarok -Name[wa]=Amarok -Name[x-test]=xxAmarokxx -Name[zh_CN]=Amarok -Name[zh_TW]=Amarok -GenericName=Audio Player -GenericName[be]=Аўдыёпрайгравальнік -GenericName[bg]=Аудио плеър -GenericName[bs]=Audio plejer -GenericName[ca]=Reproductor d'àudio -GenericName[ca@valencia]=Reproductor d'àudio -GenericName[cs]=Zvukový přehrávač -GenericName[csb]=Grôcz aùdio -GenericName[da]=Lydafspiller -GenericName[de]=Audio-Wiedergabe -GenericName[el]=Αναπαραγωγή ήχου -GenericName[en_GB]=Audio Player -GenericName[eo]=Sonludilo -GenericName[es]=Reproductor de audio -GenericName[et]=Helifailide mängija -GenericName[eu]=Audio erreproduzigailua -GenericName[fi]=Musiikkisoitin -GenericName[fr]=Lecteur audio -GenericName[ga]=Seinnteoir Fuaime -GenericName[gl]=Reprodutor de audio -GenericName[he]=נגן שמע -GenericName[hne]=आडियो प्लेयर -GenericName[hu]=Zenelejátszó -GenericName[id]=Player Audio -GenericName[is]=Tónlistarspilari -GenericName[it]=Lettore audio -GenericName[ja]=オーディオプレーヤー -GenericName[km]=កម្មវិធី​ចាក់​អូឌីយ៉ូ -GenericName[ko]=오디오 재생기 -GenericName[ku]=Lêdarê Muzîkê -GenericName[lt]=Muzikos grotuvas -GenericName[lv]=Audio atskaņotājs -GenericName[mai]=आडियो प्लेयर -GenericName[ms]=Pemain Audio -GenericName[nb]=Lydavspiller -GenericName[nds]=Klangafspeler -GenericName[ne]=अडियो प्लेयर -GenericName[nl]=Audiospeler -GenericName[nn]=Musikkspelar -GenericName[pa]=ਆਡੀਓ ਪਲੇਅਰ -GenericName[pl]=Odtwarzacz dźwięku -GenericName[pt]=Leitor de Áudio -GenericName[pt_BR]=Reprodutor de áudio -GenericName[ro]=Redare audio -GenericName[ru]=Аудиопроигрыватель -GenericName[sk]=Audio prehrávač -GenericName[sl]=Predvajalnik glasbe -GenericName[sq]=Lexues audio -GenericName[sr]=Аудио плејер -GenericName[sr@ijekavian]=Аудио плејер -GenericName[sr@ijekavianlatin]=Audio plejer -GenericName[sr@latin]=Audio plejer -GenericName[sv]=Musikspelare -GenericName[th]=เครื่องเล่นเสียง -GenericName[tr]=Müzik Çalar -GenericName[ug]=ئۈن قويغۇچ -GenericName[uk]=Аудіопрогравач -GenericName[wa]=Djouweu d' son -GenericName[x-test]=xxAudio Playerxx -GenericName[zh_CN]=音频播放器 -GenericName[zh_TW]=音效播放器 -Exec=amarok --icon '%i' --caption '%c' %U -Comment=Amarok - Rediscover Your Music! -Comment[be]=Amarok - адкрыйце для сябе сваю музыку! -Comment[bg]=Amarok - преоткрийте музиката! -Comment[bs]=Amarok — otkrijte svoju muziku! -Comment[ca]=Amarok - Redescobreix la teva música! -Comment[ca@valencia]=Amarok - Redescobreix la teva música! -Comment[cs]=AmaroK - znovu objevte svou hudbu. -Comment[csb]=Amarok - òdrëjë znowa swòją mùzykã -Comment[da]=Amarok - Genopdag din musik! -Comment[de]=Amarok – Musik neu erleben! -Comment[el]=Amarok - Ανακαλύψτε ξανά τη μουσική σας! -Comment[en_GB]=Amarok - Rediscover Your Music! -Comment[eo]=Amarok - Remalkovru vian muzikon! -Comment[es]=Amarok - ¡Vuelve a descubrir tu música! -Comment[et]=Amarok - naudi oma muusikat! -Comment[eu]=Amarok - Aurkitu berriro zure musika! -Comment[fi]=Amarok – löydä musiikkisi uudelleen -Comment[fr]=Amarok - Redécouvrez votre musique ! -Comment[ga]=Amarok - Athaimsigh do chuid Ceoil! -Comment[gl]=Amarok - Descubra de novo a música! -Comment[he]=Amarok - גלה מחדש את המוזיקה -Comment[hne]=अमाराक - अपन संगीत ल फिर से खोजव! -Comment[hu]=Amarok - fedezze fel a zenéjét -Comment[id]=Amarok - Temukan Kembali Musik Anda! -Comment[is]=Amarok - Enduruppgötvaðu tónlistina þína! -Comment[it]=Amarok - Riscopri la tua musica! -Comment[ja]=Amarok - あなたの音楽を再発見 -Comment[km]=Amarok - រក​ឃើញ​តន្ត្រី​របស់​អ្នក​ឡើង​វិញ ! -Comment[ko]=Amarok - 음악의 재발견! -Comment[ku]=Amarok - muzîkê ji nû ve keşif bike -Comment[lt]=Amarok – atraskite savo muziką iš naujo! -Comment[lv]=Amarok - atklāj savu mūziku! -Comment[ms]=Amarok - Temui Muzik Anda! -Comment[nb]=Amarok – Oppdag musikken din på nytt! -Comment[nds]=Amarok - Beleev Dien Musik nieg! -Comment[ne]=अमारोक - आफ्नो बाजा फेरि पत्ता लगाउनुहोस्! -Comment[nl]=Amarok - Herontdek uw muziek! -Comment[nn]=Amarok – gjenoppdag musikken din! -Comment[pa]=ਅਮਰੋਕ - ਆਪਣਾ ਸੰਗੀਤ ਮੁੜ ਲੱਭੋ! -Comment[pl]=Amarok - odkryj na nowo swoją muzykę! -Comment[pt]=Amarok - Descubra de Novo a sua Música! -Comment[pt_BR]=Amarok - Redescubra suas músicas! -Comment[ro]=Amarok - Redescoperă-ți muzica! -Comment[ru]=Amarok - посмотрите на музыку по-другому -Comment[sk]=Amarok - Znova objavte svoju hudbu! -Comment[sl]=Amarok - Znova odkrijte svojo glasbo! -Comment[sr]=Амарок — откријте своју музику! -Comment[sr@ijekavian]=Амарок — откријте своју музику! -Comment[sr@ijekavianlatin]=Amarok — otkrijte svoju muziku! -Comment[sr@latin]=Amarok — otkrijte svoju muziku! -Comment[sv]=Amarok - Återupptäck din musik! -Comment[th]=แอมอะร็อก - ค้นพบมิติใหม่ในดนตรีของคุณ ! -Comment[tr]=Amarok - Müziğinizi yeniden keşfedin! -Comment[ug]=Amarok - مۇزىكىلىرىڭىزنى قايتا بايقايسىز -Comment[uk]=Amarok — відкрийте свою музику знову! -Comment[wa]=Amarok - Ridiscovroz vosse muzike! -Comment[x-test]=xxAmarok - Rediscover Your Music!xx -Comment[zh_CN]=Amarok - 重新探索您的音乐! -Comment[zh_TW]=Amarok - 重新探索您的音樂世界! -Icon=amarok -# Add container formats here -MimeType=video/x-ms-asf;application/ogg; -NoDisplay=true -X-KDE-Keywords=music,podcast -X-KDE-Keywords[bs]=muzika,podemisija -X-KDE-Keywords[ca]=música,podcast -X-KDE-Keywords[ca@valencia]=música,podcast -X-KDE-Keywords[cs]=hudba,podcast -X-KDE-Keywords[da]=musik,podcast -X-KDE-Keywords[de]=Musik,Podcast -X-KDE-Keywords[el]=μουσική,podcast -X-KDE-Keywords[en_GB]=music,podcast -X-KDE-Keywords[es]=música,podcast -X-KDE-Keywords[et]=muusika,podcast -X-KDE-Keywords[fi]=musiikki,podcast -X-KDE-Keywords[fr]=musique, podcast -X-KDE-Keywords[ga]=ceol,podchraoladh -X-KDE-Keywords[gl]=música,podcast -X-KDE-Keywords[hu]=zene,podcast -X-KDE-Keywords[id]=musik,podcast -X-KDE-Keywords[it]=musica,podcast -X-KDE-Keywords[ja]=music,podcast -X-KDE-Keywords[km]=តន្ត្រី ផតខាស់ -X-KDE-Keywords[lt]=muzika,prenumerata -X-KDE-Keywords[lv]=mūzika,podraide -X-KDE-Keywords[nb]=musikk,podkasting -X-KDE-Keywords[nl]=muziek,podcast -X-KDE-Keywords[pl]=muzyka,podcast -X-KDE-Keywords[pt]=música,podcast -X-KDE-Keywords[pt_BR]=música,podcast -X-KDE-Keywords[ro]=muzică,podcast -X-KDE-Keywords[ru]=music,podcast,музыка,подкаст -X-KDE-Keywords[sk]=hudba,podcast -X-KDE-Keywords[sl]=glasba,podcast -X-KDE-Keywords[sr]=music,podcast,музика,подемисија -X-KDE-Keywords[sr@ijekavian]=music,podcast,музика,подемисија -X-KDE-Keywords[sr@ijekavianlatin]=music,podcast,muzika,podemisija -X-KDE-Keywords[sr@latin]=music,podcast,muzika,podemisija -X-KDE-Keywords[sv]=musik,podsändning -X-KDE-Keywords[tr]=müzik,podcast -X-KDE-Keywords[uk]=music,podcast,музика,трансляція,подкаст -X-KDE-Keywords[x-test]=xxmusicxx,xxpodcastxx -X-KDE-Keywords[zh_CN]=music,podcast,音乐,播客 -X-KDE-Keywords[zh_TW]=music,podcast -X-KDE-Protocols=http -Terminal=false -Categories=Qt;KDE;AudioVideo;Audio;Player; diff --git a/amarok/src/amarok_export.h b/amarok/src/amarok_export.h deleted file mode 100644 index bbdb03bb..00000000 --- a/amarok/src/amarok_export.h +++ /dev/null @@ -1,35 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 David Faure * - * Copyright (c) 2010 Patrick von Reth * - * Copyright (c) 2013 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_EXPORT_H -#define AMAROK_EXPORT_H - -/* needed for KDE_EXPORT and KDE_IMPORT macros */ -#include - -#ifndef AMAROK_EXPORT -# ifdef MAKE_AMAROKLIB_LIB - /* We are building this library */ -# define AMAROK_EXPORT KDE_EXPORT -# else - /* We are using this library */ -# define AMAROK_EXPORT KDE_IMPORT -# endif // MAKE_AMAROKLIB_LIB -#endif // AMAROK_EXPORT - -#endif // AMAROK_EXPORT_H diff --git a/amarok/src/amarok_plugin.desktop b/amarok/src/amarok_plugin.desktop deleted file mode 100644 index a2f78015..00000000 --- a/amarok/src/amarok_plugin.desktop +++ /dev/null @@ -1,99 +0,0 @@ -[Desktop Entry] -Type=ServiceType -X-KDE-ServiceType=Amarok/Plugin -Comment=Plugin for Amarok -Comment[be]=Утулка для Amarok -Comment[bg]=Приставка за Amarok -Comment[bs]=Priključak za Amarok -Comment[ca]=Connector per l'Amarok -Comment[ca@valencia]=Connector per l'Amarok -Comment[cs]=Modul pro AmaroK -Comment[csb]=Wtëkôcz dlô Amaroka -Comment[da]=Plugin til Amarok -Comment[de]=Erweiterungsmodul für Amarok -Comment[el]=Πρόσθετο για το AmaroK -Comment[en_GB]=Plugin for Amarok -Comment[eo]=Kromaĵo por Amarok -Comment[es]=Complemento para Amarok -Comment[et]=Amaroki plugin -Comment[eu]=Amarok-en plugina -Comment[fa]=وصله برای آماروک -Comment[fi]=Amarok-liitännäinen -Comment[fr]=Module externe pour Amarok -Comment[ga]=Breiseán Amarok -Comment[gl]=Extensión de Amarok -Comment[he]=תוסף ל־Amarok -Comment[hne]=अमाराक बर प्लगइन -Comment[hu]=Bővítőmodul az Amarokhoz -Comment[id]=Plugin untuk Amarok -Comment[is]=Íforrit fyrir Amarok -Comment[it]=Estensione per Amarok -Comment[ja]=Amarok のためのプラグイン -Comment[km]=កម្មវិធី​ជំនួយ​សម្រាប់ Amarok -Comment[ko]=Amarok 플러그인 -Comment[ku]=Pêvek ji bo Amarok -Comment[lt]=Amarok papildinys -Comment[lv]=Amarok spraudnis -Comment[nb]=Programtillegg for Amarok -Comment[nds]=Moduul för Amarok -Comment[ne]=अमारोकका लागि प्लगइन -Comment[nl]=Plugin voor Amarok -Comment[nn]=Programtillegg til Amarok -Comment[pa]=ਅਮਰੋਕ ਲਈ ਪਲੱਗਿਨ -Comment[pl]=Wtyczka dla Amaroka -Comment[pt]='Plugin' para o Amarok -Comment[pt_BR]=Plugin para o Amarok -Comment[ro]=Modul pentru Amarok -Comment[ru]=Модуль для Amarok -Comment[sk]=Modul pre Amarok -Comment[sl]=Vstavek za Amarok -Comment[sr]=Прикључак за Амарок -Comment[sr@ijekavian]=Прикључак за Амарок -Comment[sr@ijekavianlatin]=Priključak za Amarok -Comment[sr@latin]=Priključak za Amarok -Comment[sv]=Insticksprogram för Amarok -Comment[th]=ส่วนเสริมของแอมอะร็อก -Comment[tr]=Amarok için eklenti -Comment[uk]=Додаток для Amarok -Comment[wa]=Tchôke-divins pos Amarok -Comment[x-test]=xxPlugin for Amarokxx -Comment[zh_CN]=Amarok 插件 -Comment[zh_TW]=Amarok 的外掛程式 - -# Type of plugin, e.g. "engine". -[PropertyDef::X-KDE-Amarok-plugintype] -Type=QString - -# Internal name for identification, not translated. -[PropertyDef::X-KDE-Amarok-name] -Type=QString - -# List of authors. -[PropertyDef::X-KDE-Amarok-authors] -Type=QStringList - -# List of author's email addresses. -[PropertyDef::X-KDE-Amarok-email] -Type=QStringList - -# Priority of the plugin. When KTrader returns multiple offers, the one with the highest rank is chosen. -# Range: 0 (disabled) - 255 (highest) -[PropertyDef::X-KDE-Amarok-rank] -Type=int - -# Version of the plugin. -[PropertyDef::X-KDE-Amarok-version] -Type=int - -# Version of the framework this plugin is compatible with. -# Must be bumped after making binary incompatible changes. -[PropertyDef::X-KDE-Amarok-framework-version] -Type=int - -# If true, Amarok will show a warning dialog about the experimental nature of this plugin. -[PropertyDef::X-KDE-Amarok-experimental] -Type=bool - -# If true, Amarok will always initialize this plugin indepenent of the configuration -[PropertyDef::X-KDE-Amarok-vital] -Type=bool diff --git a/amarok/src/amarokconfig.kcfg b/amarok/src/amarokconfig.kcfg deleted file mode 100644 index c35140c1..00000000 --- a/amarok/src/amarokconfig.kcfg +++ /dev/null @@ -1,630 +0,0 @@ - - - -qdir.h - - - - - - - Set this to display a second time label to the left of the seek slider in the player window. - true - - - - Set this to display remaining track time instead of past track time in the player window. - false - - - - Tracks or albums with the chosen property will be more likely to be chosen in Random Mode. - - - - - - - Off - - - - Determines how amarok will progress through the tracks in the playlist - - - - - - - - - - Normal - - - - If set, dynamic mode will be on, and tracks will be added according to the dynamic playlist specified. - false - - - - If set, tracks added in the dynamic mode are allowed to have duplicates. - false - - - - Number of tracks to leave in the playlist before the active track. - 5 - - - - Number of tracks to load into the playlist after the active track. - 10 - - - - Enable/Disable tray icon for Amarok. - true - - - - Enable/Disable context view in Amarok. - false - - - - The number of undo levels in the playlist. - 30 - - - - If set, Amarok's manually saved playlists will contain a relative path to each track, not an absolute path. - true - - - - xdg-open - - - - false - - - - true - - - - true - - - - true - - - - true - - - - true - - - - If set, context applets will collapse using animations. - false - - - - - - - If set, Organize files will overwrite any existing destination. - false - - - - If set, Organize files will move The in artist names to the end as in "Beatles, The". - true - - - - If set, Organize files will replace spaces in filenames with underscores. - false - - - - If set, Organize files will use cover art as folder icons. - true - - - - The path of the collection folder destination for Organize files. - - - - - If set, Organize files will replace characters that are not compatible with vfat filesystems (such as ':', '*' and '?'). - true - - - - If set, Organize files will replace characters that are not compatible with the 7-bit ASCII character set. - false - - - - If set, Organize files will rename files according to a custom format string. - false - - - - If the custom filename scheme is enabled, then Organize files will rename files according to this format string. - %artist%/%album%/%track%_-_%title% - - - - Organize files will replace substrings matching this regular expression. - - - - - Organize files will replace matching substrings with this string. - - - - - In basic mode graphical drag/droppable tokens are used to create a filename scheme, in advanced mode the images are replaced with text. - Basic - - - - A list of preset formats (token schemas). - Default#DELIM#%artist%/%album%/%track%_-_%title%#DELIM#selected - - - - - - - The Amarok master volume, a value between 0 and 100. - 80 - 0 - 100 - - - - Mute/Unmute sound. - false - - - - Enable/Disable fadeout. - true - - - - Enable/Disable fadeout. - true - - - - The length of the fadeout in milliseconds. - 2000 - 400 - - - - When enabled, an equalizer plugin filters the audio stream. - false - - - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - - - - - - - - - - - Whether to adjust the volume of tracks to make them sound the same volume, and if so whether to make the adjustments per-track or per-album. - - - - - - - - - - - - Track - - - - 2 - 1 - - - - 10 - 1 - - - - 60 - 1 - - - - false - - - - true - - - - true - - - - - - - Determines which Amazon server cover images should be retrieved from. - us - - - - - - - Determines in which language the information is retrieved from Wikipedia. - en - - - - - - - false - - - - - - - Enable/Disable the On-Screen Display. - true - - - - Enable/Disable use of Growl for notifications. - false - - - - Make the background of the OSD translucent. - true - - - - You can use custom colors for the OSD if you set this true. - false - - - - The color of the OSD text. The color is specified in RGB, a comma-separated list containing three integers between 0 and 255. - #ffff00 - - - - The scaling multiplier for the OSD font, in percent-of-normal. 100 is “normal size”. - 115 - 0 - 1000 - - - - The time in milliseconds to show the OSD. A value of 0 means never hide. The default value is 5000 ms. - 5000 - 0 - - - - The Y position of the OSD relative to the chosen screen and OSD alignment. If Top alignment is chosen the Y offset is the space between the upper part of the OSD and the top of the screen. If Bottom alignment is chosen the Y offset is the space between the bottom part of the OSD and the bottom of the screen. - 50 - 0 - 10000 - - - - The screen that should display the OSD. For single-headed environments this setting should be 0. - 0 - - - - The relative position of the OSD. Possible choices are Left, Middle, Right and Center. - - - - - - - Middle - - - - Do not show the On-Screen-Display if another application is focused and running in fullscreen mode. - false - - - - - - - - If set, Amarok resumes playback of the last played track on startup. - false - - - - Internal: URL of the track to resume on startup. - - - - false - - - - Internal: Playback position in the track to resume on startup. - - - - - - - -1 - - - - - - - - - - true - - - - true - - - - true - - - - false - - - - false - - - - 400 - - - - - - - true - - - - true - - - - false - - - - - - - Whether played songs are submitted to Audioscrobbler - true - - - - The username to use for connecting to Audioscrobbler - - - - - The password to use for connecting to Audioscrobbler - - - - - Use composer data in Last.fm as artist - false - - - - Whether similar songs are retrieved from Audioscrobbler - false - - - - - - - The type of media device. - - - - The mount point used for the media device connection. - - - - The mount command used for the media device connection. - - - - The umount command used for the media device connection. - - - - Whether podcast shows already played are automatically deleted when media device is connected. - - - - Whether Amarok statistics should be synchronized with play count/ratings on device and whether tracks played should be submitted to Last.fm. - - - - - - - Music Sharing servers added by the user. - - - - Passwords stored by hostname. - - - - - - - true - - - - true - - - - true - - - - false - - - - false - - - - false - - - - false - - - - - - - Default - - - - - - - false - - - - localhost - - - - 3306 - - - - amarokdb - - - - amarokuser - - - - password - - - - 0 - - - - - - - Enable/Disable Amarok's scripting module. - false - - - - Enable/Disable automatic update for built-in scripts. - true - - - - Whether to enable the script console. - false - - - - Whether to display a warning about scripts accessing deprecated APIs. - true - - - - - - - Whether to save the current session on exit. - false - - - - - - - Enable/Disable showing moodbar, if available, in the progress slider. - false - - - - 0 - - - - - - - A value between 0 and 10 that controls whether the Automated Playlist Generator tries to optimize for speed (0) or accuracy (10). - 7 - - - diff --git a/amarok/src/amarokconfig.kcfgc b/amarok/src/amarokconfig.kcfgc deleted file mode 100644 index 4462064d..00000000 --- a/amarok/src/amarokconfig.kcfgc +++ /dev/null @@ -1,8 +0,0 @@ -# Code generation options for kconfig_compiler -File=amarokconfig.kcfg -ClassName=AmarokConfig -Singleton=true -Mutators=true -MemberVariables=private -Visibility=AMAROK_EXPORT -IncludeFiles=amarok_export.h diff --git a/amarok/src/amarokitpc.protocol b/amarok/src/amarokitpc.protocol deleted file mode 100644 index 6ea5041a..00000000 --- a/amarok/src/amarokitpc.protocol +++ /dev/null @@ -1,11 +0,0 @@ -[Protocol] -exec=amarok "%u" -protocol=itpc -input=none -output=none -helper=true -listing= -reading=false -writing=false -makedir=false -deleting=false diff --git a/amarok/src/amarokpcast.protocol b/amarok/src/amarokpcast.protocol deleted file mode 100644 index 46666d5f..00000000 --- a/amarok/src/amarokpcast.protocol +++ /dev/null @@ -1,11 +0,0 @@ -[Protocol] -exec=amarok "%u" -protocol=pcast -input=none -output=none -helper=true -listing= -reading=false -writing=false -makedir=false -deleting=false diff --git a/amarok/src/amarokurls/AmarokUrl.cpp b/amarok/src/amarokurls/AmarokUrl.cpp deleted file mode 100644 index 29815128..00000000 --- a/amarok/src/amarokurls/AmarokUrl.cpp +++ /dev/null @@ -1,245 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "AmarokUrl.h" - -#include "AmarokUrlHandler.h" -#include "BookmarkGroup.h" -#include "core-impl/storage/StorageManager.h" -#include "core/support/Debug.h" -#include - -#include - -AmarokUrl::AmarokUrl() - : m_id( -1 ) - , m_parent( 0 ) -{} - -AmarokUrl::AmarokUrl( const QString & urlString, BookmarkGroupPtr parent ) - : m_id( -1 ) - , m_parent( parent ) -{ - initFromString( urlString ); -} - -AmarokUrl::AmarokUrl( const QStringList & resultRow, BookmarkGroupPtr parent ) - : m_parent( parent ) -{ - m_id = resultRow[0].toInt(); - m_name = resultRow[2]; - const QString urlString = resultRow[3]; - m_description = resultRow[4]; - m_customValue = resultRow[5]; - - initFromString( urlString ); -} - -AmarokUrl::~AmarokUrl() -{} - -void AmarokUrl::initFromString( const QString & urlString ) -{ - //first, strip amarok:// - QString strippedUrlString = urlString; - strippedUrlString = strippedUrlString.replace( "amarok://", "" ); - - //separate path from arguments - QStringList parts = strippedUrlString.split( '?' ); - - QString commandAndPath = parts.at( 0 ); - - QString argumentsString; - if ( parts.size() == 2 ) - argumentsString = parts.at( 1 ); - - if ( !argumentsString.isEmpty() ) - { - parts = argumentsString.split( '&' ); - - foreach( const QString &argument, parts ) - { - - QStringList argParts = argument.split( '=' ); - debug() << "argument: " << argument << " unescaped: " << unescape( argParts.at( 1 ) ); - setArg( argParts.at( 0 ), unescape( argParts.at( 1 ) ) ); - } - } - - //get the command - - parts = commandAndPath.split( '/' ); - m_command = parts.takeFirst(); - - m_path = parts.join( "/" ); - - m_path = unescape( m_path ); - -} - -void AmarokUrl::setCommand( const QString & command ) -{ - m_command = command; -} - -QString AmarokUrl::command() const -{ - return m_command; -} - -QString -AmarokUrl::prettyCommand() const -{ - return The::amarokUrlHandler()->prettyCommand( command() ); -} - -QMap AmarokUrl::args() const -{ - return m_arguments; -} - -void AmarokUrl::setArg( const QString &name, const QString &value ) -{ - m_arguments.insert( name, value ); -} - -bool AmarokUrl::run() -{ - DEBUG_BLOCK - return The::amarokUrlHandler()->run( *this ); -} - -QString AmarokUrl::url() const -{ - QUrl url; - url.setScheme( "amarok" ); - url.setHost( m_command ); - url.setPath( m_path ); - - foreach( const QString &argName, m_arguments.keys() ) - url.addQueryItem( argName, m_arguments[argName] ); - - return url.toEncoded(); -} - -bool AmarokUrl::saveToDb() -{ - DEBUG_BLOCK - - if ( isNull() ) - return false; - - const int parentId = m_parent ? m_parent->id() : -1; - - SqlStorage * sql = StorageManager::instance()->sqlStorage(); - - if( m_id != -1 ) - { - //update existing - debug() << "Updating bookmark"; - QString query = "UPDATE bookmarks SET parent_id=%1, name='%2', url='%3', description='%4', custom='%5' WHERE id=%6;"; - query = query.arg( QString::number( parentId ) ).arg( sql->escape( m_name ), sql->escape( url() ), sql->escape( m_description ), sql->escape( m_customValue ) , QString::number( m_id ) ); - StorageManager::instance()->sqlStorage()->query( query ); - } - else - { - //insert new - debug() << "Creating new bookmark in the db"; - QString query = "INSERT INTO bookmarks ( parent_id, name, url, description, custom ) VALUES ( %1, '%2', '%3', '%4', '%5' );"; - query = query.arg( QString::number( parentId ), sql->escape( m_name ), sql->escape( url() ), sql->escape( m_description ), sql->escape( m_customValue ) ); - m_id = StorageManager::instance()->sqlStorage()->insert( query, NULL ); - } - - return true; -} - -void AmarokUrl::setName( const QString & name ) -{ - m_name = name; -} - -QString AmarokUrl::name() const -{ - return m_name; -} - -void AmarokUrl::setDescription( const QString & description ) -{ - m_description = description; -} - -QString AmarokUrl::description() const -{ - return m_description; -} - -void AmarokUrl::removeFromDb() -{ - QString query = "DELETE FROM bookmarks WHERE id=%1"; - query = query.arg( QString::number( m_id ) ); - StorageManager::instance()->sqlStorage()->query( query ); -} - -void AmarokUrl::rename( const QString &name ) -{ - m_name = name; - if ( m_id != -1 ) - saveToDb(); -} - -void AmarokUrl::reparent( BookmarkGroupPtr parent ) -{ - m_parent = parent; - saveToDb(); -} - -void AmarokUrl::setCustomValue( const QString & custom ) -{ - m_customValue = custom; -} - -QString AmarokUrl::customValue() const -{ - return m_customValue; -} - -QString AmarokUrl::escape( const QString & in ) -{ - return QUrl::toPercentEncoding( in.toUtf8() ); -} - -QString AmarokUrl::unescape( const QString & in ) -{ - return QUrl::fromPercentEncoding( in.toUtf8() ); -} - -bool AmarokUrl::isNull() const -{ - return m_command.isEmpty(); -} - -QString AmarokUrl::path() const -{ - return m_path; -} - -void AmarokUrl::setPath( const QString &path ) -{ - m_path = path; -} - - - diff --git a/amarok/src/amarokurls/AmarokUrl.h b/amarok/src/amarokurls/AmarokUrl.h deleted file mode 100644 index 4e9f3857..00000000 --- a/amarok/src/amarokurls/AmarokUrl.h +++ /dev/null @@ -1,95 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROKURL_H -#define AMAROKURL_H - -#include "amarok_export.h" -#include "BookmarkViewItem.h" -#include "BookmarkGroup.h" - -#include -#include - - -class AMAROK_EXPORT AmarokUrl : public BookmarkViewItem -{ -public: - AmarokUrl(); - explicit AmarokUrl( const QString & urlString, BookmarkGroupPtr parent = BookmarkGroupPtr() ); - explicit AmarokUrl( const QStringList & resultRow, BookmarkGroupPtr parent = BookmarkGroupPtr() ); - - ~AmarokUrl(); - - void reparent( BookmarkGroupPtr parent ); - void initFromString( const QString & urlString ); - - QString command() const; - QString prettyCommand() const; - QString path() const; - QMap args() const; - - void setCommand( const QString &command ); - void setPath( const QString &path ); - - /** - * Sets the url argument named @param name to @param value. Overrides any possible - * previous value. - */ - void setArg( const QString &name, const QString &value ); - - void setName( const QString &name ); - void setDescription( const QString &description ); - - void setCustomValue( const QString &custom ); - QString customValue() const; - - bool run(); - - QString url() const; - - bool saveToDb(); - - void setId( int id ) { m_id = id; } - int id() const { return m_id; } - - bool isNull() const; - - virtual QString name() const; - virtual QString description() const; - virtual BookmarkGroupPtr parent() const { return m_parent; } - virtual void removeFromDb(); - virtual void rename( const QString &name ); - - static QString escape( const QString &in ); - static QString unescape( const QString &in ); - -private: - - QString m_command; - QString m_path; - QMap m_arguments; - - int m_id; - BookmarkGroupPtr m_parent; - QString m_description; - QString m_name; - - //this value is used for storing application specific inoformation that should not be made user visible. - QString m_customValue; -}; - -#endif diff --git a/amarok/src/amarokurls/AmarokUrlAction.cpp b/amarok/src/amarokurls/AmarokUrlAction.cpp deleted file mode 100644 index 0cc39112..00000000 --- a/amarok/src/amarokurls/AmarokUrlAction.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "AmarokUrlAction.h" -#include "AmarokUrlHandler.h" - -AmarokUrlAction::AmarokUrlAction( const QIcon & icon, AmarokUrlPtr url, QObject * parent ) - : QAction( icon, url->name(), parent ) - , m_url( url ) -{ - if ( !url->description().isEmpty() ) - setToolTip( url->description() ); - - connect( this, SIGNAL(triggered(bool)), this, SLOT(run()) ); -} - -AmarokUrlAction::AmarokUrlAction( AmarokUrlPtr url, QObject * parent ) - : QAction(url->name(), parent ) - , m_url( url ) -{ - if ( !url->description().isEmpty() ) - setToolTip( url->description() ); - - setIcon( The::amarokUrlHandler()->iconForCommand( url->command() ) ); - connect( this, SIGNAL(triggered(bool)), this, SLOT(run()) ); -} - - -void AmarokUrlAction::run() -{ - m_url->run(); -} diff --git a/amarok/src/amarokurls/AmarokUrlAction.h b/amarok/src/amarokurls/AmarokUrlAction.h deleted file mode 100644 index b35a6a65..00000000 --- a/amarok/src/amarokurls/AmarokUrlAction.h +++ /dev/null @@ -1,41 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROKURLACTION_H -#define AMAROKURLACTION_H - -#include "AmarokUrl.h" -#include "BookmarkGroup.h" - - -#include - - -class AmarokUrlAction : public QAction -{ - Q_OBJECT -public: - AmarokUrlAction( const QIcon & icon, AmarokUrlPtr url, QObject * parent ); - AmarokUrlAction( AmarokUrlPtr url, QObject * parent ); - -private slots: - void run(); - -private: - AmarokUrlPtr m_url; -}; - -#endif // AMAROKURLACTION_H diff --git a/amarok/src/amarokurls/AmarokUrlGenerator.h b/amarok/src/amarokurls/AmarokUrlGenerator.h deleted file mode 100644 index a3d5dd19..00000000 --- a/amarok/src/amarokurls/AmarokUrlGenerator.h +++ /dev/null @@ -1,45 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ -#ifndef AMAROKURLGENERATOR_H -#define AMAROKURLGENERATOR_H - -#include "AmarokUrl.h" - -#include - -class AmarokUrlGenerator -{ - -public: - virtual ~AmarokUrlGenerator() {}; - - /** - Get the user visible description of what the createUrl() function will actualy bookmarks. - */ - virtual QString description() = 0; - - /** - Get the icon for the type of bookmarks created. - */ - virtual KIcon icon() = 0; - - /** - Cretate the default url for this generator. - */ - virtual AmarokUrl createUrl() = 0; -}; - -#endif // AMAROKURLGENERATOR_H diff --git a/amarok/src/amarokurls/AmarokUrlHandler.cpp b/amarok/src/amarokurls/AmarokUrlHandler.cpp deleted file mode 100644 index d416a2a7..00000000 --- a/amarok/src/amarokurls/AmarokUrlHandler.cpp +++ /dev/null @@ -1,229 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "AmarokUrlHandler.h" - -#include "GlobalCurrentTrackActions.h" -#include "amarokurls/BookmarkMetaActions.h" -#include "amarokurls/BookmarkModel.h" -#include "amarokurls/ContextUrlGenerator.h" -#include "amarokurls/NavigationUrlGenerator.h" -#include "amarokurls/NavigationUrlRunner.h" -#include "amarokurls/PlayUrlGenerator.h" -#include "amarokurls/PlayUrlRunner.h" -#include -#include "core/meta/Meta.h" -#include "core/support/Debug.h" -#include "core-impl/storage/StorageManager.h" -#include "core-impl/meta/timecode/TimecodeObserver.h" -#include "playlist/PlaylistViewUrlGenerator.h" - -#include -#include - -namespace The { - static AmarokUrlHandler* s_AmarokUrlHandler_instance = 0; - - AmarokUrlHandler* amarokUrlHandler() - { - if( !s_AmarokUrlHandler_instance ) - s_AmarokUrlHandler_instance = new AmarokUrlHandler(); - - return s_AmarokUrlHandler_instance; - } -} - -AmarokUrlHandler::AmarokUrlHandler() - : QObject() - , m_navigationRunner( 0 ) - , m_playRunner ( 0 ) - , m_timecodeObserver( 0 ) -{ - DEBUG_BLOCK - - //init the bookmark model to make sure that db tables are created/updated if needed. - BookmarkModel::instance(); - - //we init some of the default runners here. - m_navigationRunner = new NavigationUrlRunner(); - m_playlistViewRunner = new Playlist::ViewUrlRunner(); - m_playRunner = new PlayUrlRunner(); - m_timecodeObserver = new TimecodeObserver( this ); - registerRunner( m_navigationRunner, m_navigationRunner->command() ); - registerRunner( m_playRunner, m_playRunner->command() ); - registerRunner( m_playlistViewRunner, m_playlistViewRunner->command() ); - - registerGenerator( ContextUrlGenerator::instance() ); - registerGenerator( NavigationUrlGenerator::instance() ); - registerGenerator( Playlist::ViewUrlGenerator::instance() ); - registerGenerator( PlayUrlGenerator::instance() ); -} - - -AmarokUrlHandler::~AmarokUrlHandler() -{ - delete m_navigationRunner; - delete m_playlistViewRunner; -} - -void AmarokUrlHandler::registerRunner( AmarokUrlRunnerBase * runner, const QString & command ) -{ - m_registeredRunners.insert( command, runner ); -} - -void AmarokUrlHandler::unRegisterRunner( AmarokUrlRunnerBase * runner ) -{ - //get the key of the runner - QString key = m_registeredRunners.key( runner, QString() ); - - if ( !key.isEmpty() ) - m_registeredRunners.remove( key ); -} - -void AmarokUrlHandler::registerGenerator( AmarokUrlGenerator * generator ) -{ - if( !m_registeredGenerators.contains( generator ) ) - m_registeredGenerators.append( generator ); -} - -void AmarokUrlHandler::unRegisterGenerator( AmarokUrlGenerator * generator ) -{ - m_registeredGenerators.removeAll( generator ); -} - -bool AmarokUrlHandler::run( AmarokUrl url ) -{ - - DEBUG_BLOCK - - QString command = url.command(); - - debug() << "command: " << command; - debug() << "registered commands: " << m_registeredRunners.keys(); - - if ( m_registeredRunners.contains( command ) ) - return m_registeredRunners.value( command )->run( url ); - else - return false; - -} - -void AmarokUrlHandler::bookmarkAlbum( Meta::AlbumPtr album ) //slot -{ - NavigationUrlGenerator::instance()->urlFromAlbum( album ).saveToDb(); - BookmarkModel::instance()->reloadFromDb(); -} - -void AmarokUrlHandler::bookmarkArtist( Meta::ArtistPtr artist ) //slot -{ - NavigationUrlGenerator::instance()->urlFromArtist( artist ).saveToDb(); - BookmarkModel::instance()->reloadFromDb(); -} - -BookmarkList AmarokUrlHandler::urlsByCommand( const QString &command ) -{ - DEBUG_BLOCK - - QString query = "SELECT id, parent_id, name, url, description, custom FROM bookmarks where url like 'amarok://%1%' ORDER BY name;"; - query = query.arg( command ); - QStringList result = StorageManager::instance()->sqlStorage()->query( query ); - - debug() << "Result: " << result; - int resultRows = result.count() / 6; - - BookmarkList resultList; - for( int i = 0; i < resultRows; i++ ) - { - QStringList row = result.mid( i*6, 6 ); - resultList << AmarokUrlPtr( new AmarokUrl( row ) ); - } - - return resultList; -} - -AmarokUrl -AmarokUrlHandler::createBrowserViewBookmark() -{ - return NavigationUrlGenerator::instance()->CreateAmarokUrl();; -} - -AmarokUrl -AmarokUrlHandler::createPlaylistViewBookmark() -{ - return Playlist::ViewUrlGenerator::instance()->createUrl(); -} - -AmarokUrl -AmarokUrlHandler::createContextViewBookmark() -{ - return ContextUrlGenerator::instance()->createContextBookmark(); -} - -void AmarokUrlHandler::bookmarkCurrentBrowserView() -{ - AmarokUrl url = createBrowserViewBookmark(); - url.saveToDb(); - BookmarkModel::instance()->reloadFromDb(); -} - -void -AmarokUrlHandler::bookmarkCurrentPlaylistView() -{ - AmarokUrl url = createPlaylistViewBookmark(); - url.saveToDb(); - BookmarkModel::instance()->reloadFromDb(); -} - -void -AmarokUrlHandler::bookmarkCurrentContextView() -{ - AmarokUrl url = createContextViewBookmark(); - url.saveToDb(); - BookmarkModel::instance()->reloadFromDb(); -} - -KIcon -AmarokUrlHandler::iconForCommand( const QString &command ) -{ - if( m_registeredRunners.keys().contains( command ) ) - return m_registeredRunners.value( command )->icon(); - - return KIcon( "unknown" ); -} - -void AmarokUrlHandler::updateTimecodes(const QString* BookmarkName) -{ - emit timecodesUpdated( BookmarkName ); -} - -void -AmarokUrlHandler::paintNewTimecode( const QString &name, int pos ) -{ - emit timecodeAdded( name, pos ); -} - -QString -AmarokUrlHandler::prettyCommand( const QString &command ) -{ - if( m_registeredRunners.keys().contains( command ) ) - return m_registeredRunners.value( command )->prettyCommand(); - - return i18nc( "The command type of this url is not known", "Unknown" ); -} - - - -#include "moc_AmarokUrlHandler.cpp" diff --git a/amarok/src/amarokurls/AmarokUrlHandler.h b/amarok/src/amarokurls/AmarokUrlHandler.h deleted file mode 100644 index 0d79b763..00000000 --- a/amarok/src/amarokurls/AmarokUrlHandler.h +++ /dev/null @@ -1,103 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROKURLHANDLER_H -#define AMAROKURLHANDLER_H - -#include "amarok_export.h" -#include "AmarokUrlGenerator.h" -#include "AmarokUrlRunnerBase.h" -#include "core/meta/forward_declarations.h" -#include "playlist/PlaylistViewUrlRunner.h" - -#include - -#include - - -class TimecodeObserver; -class AmarokUrlHandler; -class NavigationUrlRunner; -class PlayUrlRunner; - -namespace The -{ - AMAROK_EXPORT AmarokUrlHandler* amarokUrlHandler(); -} - -/** -A singleton class for handling and delegating all amarok:// urls - - @author Nikolaj Hald Nielsen -*/ -class AMAROK_EXPORT AmarokUrlHandler : public QObject -{ - Q_OBJECT - friend AmarokUrlHandler* The::amarokUrlHandler(); - -public: - - void registerRunner( AmarokUrlRunnerBase * runner, const QString & command ); - void unRegisterRunner( AmarokUrlRunnerBase * runner ); - - void registerGenerator( AmarokUrlGenerator * generator ); - void unRegisterGenerator( AmarokUrlGenerator * generator ); - - bool run( AmarokUrl url ); - - BookmarkList urlsByCommand( const QString &command ); - KIcon iconForCommand( const QString &command ); - - void updateTimecodes( const QString * BookmarkName = 0 ); - void paintNewTimecode( const QString &name, int pos ); - - QList generators() { return m_registeredGenerators; } - - AmarokUrl createBrowserViewBookmark(); - AmarokUrl createPlaylistViewBookmark(); - AmarokUrl createContextViewBookmark(); - - QString prettyCommand( const QString &command ); - - -public slots: - void bookmarkAlbum( Meta::AlbumPtr album ); - void bookmarkArtist( Meta::ArtistPtr artist ); - - void bookmarkCurrentBrowserView(); - void bookmarkCurrentPlaylistView(); - void bookmarkCurrentContextView(); - -signals: - void timecodesUpdated( const QString * BookmarkName ); - void timecodeAdded( const QString &name, int pos ); - -private: - - AmarokUrlHandler(); - ~AmarokUrlHandler(); - - QMap m_registeredRunners; - QList m_registeredGenerators; - - NavigationUrlRunner * m_navigationRunner; - Playlist::ViewUrlRunner * m_playlistViewRunner; - PlayUrlRunner * m_playRunner; - TimecodeObserver * m_timecodeObserver; - -}; - -#endif diff --git a/amarok/src/amarokurls/AmarokUrlRunnerBase.h b/amarok/src/amarokurls/AmarokUrlRunnerBase.h deleted file mode 100644 index 13a78d39..00000000 --- a/amarok/src/amarokurls/AmarokUrlRunnerBase.h +++ /dev/null @@ -1,43 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROKURLRUNNERBASE_H -#define AMAROKURLRUNNERBASE_H - -#include "AmarokUrl.h" - -#include - -#include - -/** -Virtual base class for all classes that wants to be able to register to handle a particular type of amarok url - - @author Nikolaj Hald Nielsen -*/ -class AmarokUrlRunnerBase -{ -public: - virtual QString command() const = 0; - virtual QString prettyCommand() const = 0; - virtual bool run( AmarokUrl url ) = 0; - virtual KIcon icon() const = 0; - -protected: - virtual ~AmarokUrlRunnerBase() {}; -}; - -#endif diff --git a/amarok/src/amarokurls/BookmarkCurrentButton.cpp b/amarok/src/amarokurls/BookmarkCurrentButton.cpp deleted file mode 100644 index 0549a264..00000000 --- a/amarok/src/amarokurls/BookmarkCurrentButton.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "BookmarkCurrentButton.h" - -#include "AmarokUrlHandler.h" -#include "BookmarkModel.h" - -#include -#include - -#include -#include - -BookmarkCurrentButton::BookmarkCurrentButton( QWidget *parent ) - : QToolButton( parent ) -{ - setIcon( KIcon( "bookmark-new" ) ); - setText( i18n( "New Bookmark" ) ); - setToolButtonStyle( Qt::ToolButtonTextBesideIcon ); - connect( this, SIGNAL(clicked(bool)), this, SLOT(showMenu()) ); -} - -BookmarkCurrentButton::~BookmarkCurrentButton() -{ -} - -void BookmarkCurrentButton::showMenu() -{ - QPoint pos( 0, height() ); - generateMenu( mapToGlobal( pos ) ); -} - -void BookmarkCurrentButton::generateMenu( const QPoint &pos ) -{ - - QList generators = The::amarokUrlHandler()->generators(); - - QMenu menu; - - QMap generatorMap; - - foreach( AmarokUrlGenerator * generator, generators ) - { - generatorMap.insert( menu.addAction( generator->icon() ,generator->description() ), generator ); - } - - QAction * action = menu.exec( pos ); - - if( action && generatorMap.contains( action ) ) - { - AmarokUrl url = generatorMap.value( action )->createUrl(); - url.saveToDb(); - BookmarkModel::instance()->reloadFromDb(); - } -} - -#include "moc_BookmarkCurrentButton.cpp" diff --git a/amarok/src/amarokurls/BookmarkCurrentButton.h b/amarok/src/amarokurls/BookmarkCurrentButton.h deleted file mode 100644 index 45eb87c9..00000000 --- a/amarok/src/amarokurls/BookmarkCurrentButton.h +++ /dev/null @@ -1,35 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef BOOKMARKCURRENTBUTTON_H -#define BOOKMARKCURRENTBUTTON_H - -#include - -class BookmarkCurrentButton : public QToolButton -{ - Q_OBJECT -public: - BookmarkCurrentButton( QWidget *parent ); - virtual ~BookmarkCurrentButton(); - - protected slots: - void showMenu(); - void generateMenu( const QPoint &pos ); -}; - -#endif // BOOKMARKCURRENTBUTTON_H - diff --git a/amarok/src/amarokurls/BookmarkGroup.cpp b/amarok/src/amarokurls/BookmarkGroup.cpp deleted file mode 100644 index a0543023..00000000 --- a/amarok/src/amarokurls/BookmarkGroup.cpp +++ /dev/null @@ -1,246 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "BookmarkGroup.h" - -#include "AmarokUrl.h" -#include "core-impl/storage/StorageManager.h" -#include "core/support/Debug.h" -#include - -#include - -BookmarkGroup::BookmarkGroup( const QStringList & dbResultRow, BookmarkGroupPtr parent ) - : BookmarkViewItem() - , m_parent( parent ) - , m_customType() - , m_hasFetchedChildGroups( false ) - , m_hasFetchedChildPlaylists( false ) -{ - m_dbId = dbResultRow[0].toInt(); - m_name = dbResultRow[2]; - m_description = dbResultRow[3]; -} - -BookmarkGroup::BookmarkGroup( const QString & name, BookmarkGroupPtr parent ) - : BookmarkViewItem() - , m_dbId( -1 ) - , m_parent( parent ) - , m_name( name ) - , m_description() - , m_customType() - , m_hasFetchedChildGroups( false ) - , m_hasFetchedChildPlaylists( false ) -{ -} - -BookmarkGroup::BookmarkGroup( const QString &name, const QString &customType ) - : BookmarkViewItem() -{ - DEBUG_BLOCK; - - m_parent = BookmarkGroupPtr(); - m_hasFetchedChildGroups = false; - m_hasFetchedChildPlaylists = false; - m_customType = customType; - - debug() << "custom type: " << customType << " named '" << name << "'"; - //check if this custom group already exists and if so, just load that data. - QString query = "SELECT id, parent_id, name, description FROM bookmark_groups where custom='%1';"; - query = query.arg( customType ); - QStringList result = StorageManager::instance()->sqlStorage()->query( query ); - - if ( result.count() == 4 ) - { - debug() << "already exists, loading..." << result; - m_dbId = result[0].toInt(); - m_name = result[2]; - m_description = result[3]; - debug() << "id: " << m_dbId; - } - else - { - debug() << "creating new"; - //create new and store - m_name = name; - m_dbId = -1; - save(); - } -} - - -BookmarkGroup::~BookmarkGroup() -{ - //DEBUG_BLOCK - //debug() << "deleting " << m_name; - clear(); -} - -void BookmarkGroup::save() -{ - DEBUG_BLOCK - - int parentId = -1; - if ( m_parent ) - parentId = m_parent->id(); - - if ( m_dbId != -1 ) { - //update existing - QString query = "UPDATE bookmark_groups SET parent_id=%1, name='%2', description='%3', custom='%4%' WHERE id=%5;"; - query = query.arg( QString::number( parentId ) ).arg( m_name ).arg( m_description ).arg( m_customType ).arg( QString::number( m_dbId ) ); - StorageManager::instance()->sqlStorage()->query( query ); - } - else - { - //insert new - QString query = "INSERT INTO bookmark_groups ( parent_id, name, description, custom) VALUES ( %1, '%2', '%3', '%4' );"; - query = query.arg( QString::number( parentId ) ).arg( m_name ).arg( m_description ).arg( m_customType ); - m_dbId = StorageManager::instance()->sqlStorage()->insert( query, NULL ); - - } -} - -BookmarkGroupList BookmarkGroup::childGroups() const -{ - //DEBUG_BLOCK - if ( !m_hasFetchedChildGroups ) - { - - QString query = "SELECT id, parent_id, name, description FROM bookmark_groups where parent_id=%1 ORDER BY name;"; - query = query.arg( QString::number( m_dbId ) ); - QStringList result = StorageManager::instance()->sqlStorage()->query( query ); - - - int resultRows = result.count() / 4; - - for( int i = 0; i < resultRows; i++ ) - { - QStringList row = result.mid( i*4, 4 ); - BookmarkGroup* mutableThis = const_cast( this ); - m_childGroups << BookmarkGroupPtr( new BookmarkGroup( row, BookmarkGroupPtr( mutableThis ) ) ); - } - - m_hasFetchedChildGroups = true; - - } - - return m_childGroups; -} - -BookmarkList BookmarkGroup::childBookmarks() const -{ - //DEBUG_BLOCK - //debug() << "my name: " << m_name << " my pointer: " << this; - if ( !m_hasFetchedChildPlaylists ) { - QString query = "SELECT id, parent_id, name, url, description, custom FROM bookmarks where parent_id=%1 ORDER BY name;"; - query = query.arg( QString::number( m_dbId ) ); - QStringList result = StorageManager::instance()->sqlStorage()->query( query ); - - //debug() << "Result: " << result; - int resultRows = result.count() / 6; - - for( int i = 0; i < resultRows; i++ ) - { - QStringList row = result.mid( i*6, 6 ); - BookmarkGroup* mutableThis = const_cast( this ); - m_childBookmarks << AmarokUrlPtr( new AmarokUrl( row, BookmarkGroupPtr( mutableThis ) ) ); - } - m_hasFetchedChildPlaylists = true; - } - - return m_childBookmarks; -} - -int BookmarkGroup::id() const -{ - return m_dbId; -} - -QString BookmarkGroup::name() const -{ - return m_name; -} - -QString BookmarkGroup::description() const -{ - return m_description; -} - -int BookmarkGroup::childCount() const -{ - //DEBUG_BLOCK - return childGroups().count() + childBookmarks().count(); -} - -void BookmarkGroup::clear() -{ - //DEBUG_BLOCK -//m_childBookmarks, m_childGroups are KSharedPtrs, so we should be able to just clear the list -//and the playlistptrs will delete themselves - m_childGroups.clear(); - m_childBookmarks.clear(); - - m_hasFetchedChildGroups = false; - m_hasFetchedChildPlaylists = false; -} - -void BookmarkGroup::rename(const QString & name) -{ - m_name = name; - save(); -} - -void BookmarkGroup::setDescription( const QString &description ) -{ - m_description = description; - save(); -} - -void BookmarkGroup::deleteChild( BookmarkViewItemPtr item ) -{ - if ( typeid( * item ) == typeid( BookmarkGroup ) ) - { - BookmarkGroupPtr group = BookmarkGroupPtr::staticCast( item ); - m_childGroups.removeAll( group ); - } - else if ( typeid( * item ) == typeid( AmarokUrl ) ) - { - AmarokUrlPtr bookmark = AmarokUrlPtr::staticCast( item ); - m_childBookmarks.removeAll( bookmark ); - } -} - -void BookmarkGroup::removeFromDb() -{ - DEBUG_BLOCK - - foreach( BookmarkGroupPtr group, m_childGroups ) - group->removeFromDb(); - foreach( AmarokUrlPtr bookmark, m_childBookmarks ) - bookmark->removeFromDb(); - - QString query = QString( "DELETE FROM bookmark_groups where id=%1;").arg( QString::number( m_dbId ) ); - debug() << "query: " << query; - QStringList result = StorageManager::instance()->sqlStorage()->query( query ); -} - -void BookmarkGroup::reparent( BookmarkGroupPtr parent ) -{ - m_parent = parent; - save(); -} - - diff --git a/amarok/src/amarokurls/BookmarkGroup.h b/amarok/src/amarokurls/BookmarkGroup.h deleted file mode 100644 index f145a13a..00000000 --- a/amarok/src/amarokurls/BookmarkGroup.h +++ /dev/null @@ -1,92 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef BOOKMARKGROUP_H -#define BOOKMARKGROUP_H - -#include "AmarokUrl.h" -#include "BookmarkViewItem.h" - -#include -#include -#include - -#include - -class BookmarkGroup; -class AmarokUrl; - -typedef KSharedPtr AmarokUrlPtr; -typedef KSharedPtr BookmarkGroupPtr; -typedef QList BookmarkList; -typedef QList BookmarkGroupList; - - -/** -A class for allowing a "folder structure" in the bookmark browser and the database. Takes care of reading and writing itself to the database. -*/ -class BookmarkGroup : public BookmarkViewItem -{ - public: - BookmarkGroup( const QStringList &dbResultRow, BookmarkGroupPtr parent ); - explicit BookmarkGroup( const QString &name, BookmarkGroupPtr parent = BookmarkGroupPtr() ); - - BookmarkGroup( const QString &name, const QString &customType ); - - ~BookmarkGroup(); - - int id() const; - QString name() const; - QString description() const; - - virtual int childCount() const; - - virtual BookmarkGroupPtr parent() const { return m_parent; } - - virtual void rename( const QString &name ); - virtual void setDescription( const QString &description ); - - void save(); - BookmarkGroupList childGroups() const; - BookmarkList childBookmarks() const; - - void reparent( BookmarkGroupPtr parent ); - - void clear(); - - void deleteChild( BookmarkViewItemPtr item ); - virtual void removeFromDb(); - - private: - int m_dbId; - BookmarkGroupPtr m_parent; - QString m_name; - QString m_description; - QString m_customType; - - mutable BookmarkGroupList m_childGroups; - mutable BookmarkList m_childBookmarks; - - mutable bool m_hasFetchedChildGroups; - mutable bool m_hasFetchedChildPlaylists; -}; - -Q_DECLARE_METATYPE( BookmarkGroupPtr ) -Q_DECLARE_METATYPE( AmarokUrlPtr ) -Q_DECLARE_METATYPE( BookmarkList ) -Q_DECLARE_METATYPE( BookmarkGroupList ) - -#endif diff --git a/amarok/src/amarokurls/BookmarkManager.cpp b/amarok/src/amarokurls/BookmarkManager.cpp deleted file mode 100644 index e612a784..00000000 --- a/amarok/src/amarokurls/BookmarkManager.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "BookmarkManager.h" - -#include "core/support/Amarok.h" - -#include -#include -#include - -#include - -BookmarkManager * BookmarkManager::s_instance = 0; - -BookmarkManager::BookmarkManager( QWidget* parent ) - : QDialog( parent ) -{ - // Sets caption and icon correctly (needed e.g. for GNOME) - kapp->setTopWidget( this ); - setWindowTitle( KDialog::makeStandardCaption( i18n("Bookmark Manager") ) ); - setAttribute( Qt::WA_DeleteOnClose ); - setObjectName( "BookmarkManager" ); - - QHBoxLayout *layout = new QHBoxLayout( this ); - m_widget = new BookmarkManagerWidget( this ); - layout->addWidget( m_widget ); - layout->setContentsMargins( 0, 0, 0, 0 ); - setLayout( layout ); - - const QSize winSize = Amarok::config( "Bookmark Manager" ).readEntry( "Window Size", QSize( 600, 400 ) ); - resize( winSize ); -} - -BookmarkManager::~BookmarkManager() -{ - Amarok::config( "Bookmark Manager" ).writeEntry( "Window Size", size() ); - s_instance = 0; -} - -void BookmarkManager::showOnce( QWidget* parent ) -{ - if( s_instance == 0 ) - s_instance = new BookmarkManager( parent ); - - s_instance->activateWindow(); - s_instance->show(); - s_instance->raise(); -} - diff --git a/amarok/src/amarokurls/BookmarkManager.h b/amarok/src/amarokurls/BookmarkManager.h deleted file mode 100644 index 601cb27b..00000000 --- a/amarok/src/amarokurls/BookmarkManager.h +++ /dev/null @@ -1,41 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef BOOKMARKMANAGER_H -#define BOOKMARKMANAGER_H - -#include "BookmarkManagerWidget.h" - -#include - -class BookmarkManager : public QDialog -{ -public: - - static BookmarkManager * instance(); - ~BookmarkManager(); - - static void showOnce( QWidget* parent = 0 ); - -private: - - BookmarkManager( QWidget* parent = 0 ); - - static BookmarkManager *s_instance; - BookmarkManagerWidget * m_widget; -}; - -#endif // BOOKMARKMANAGER_H diff --git a/amarok/src/amarokurls/BookmarkManagerWidget.cpp b/amarok/src/amarokurls/BookmarkManagerWidget.cpp deleted file mode 100644 index 6e6b05da..00000000 --- a/amarok/src/amarokurls/BookmarkManagerWidget.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008, 2009 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "BookmarkManagerWidget.h" - -#include "amarokurls/AmarokUrl.h" -#include "amarokurls/BookmarkModel.h" -#include "amarokurls/BookmarkCurrentButton.h" -#include "amarokurls/NavigationUrlGenerator.h" -#include "amarokurls/PlayUrlGenerator.h" -#include "widgets/ProgressWidget.h" - -#include -#include -#include -#include - -#include - -BookmarkManagerWidget::BookmarkManagerWidget( QWidget * parent ) - : KVBox( parent ) -{ - - setContentsMargins( 0,0,0,0 ); - - KHBox * topLayout = new KHBox( this ); - - m_toolBar = new QToolBar( topLayout ); - m_toolBar->setToolButtonStyle( Qt::ToolButtonTextBesideIcon ); - - KAction * addGroupAction = new KAction( KIcon("media-track-add-amarok" ), i18n( "Add Group" ), this ); - m_toolBar->addAction( addGroupAction ); - connect( addGroupAction, SIGNAL(triggered(bool)), BookmarkModel::instance(), SLOT(createNewGroup()) ); - - /*KAction * addBookmarkAction = new KAction( KIcon("bookmark-new" ), i18n( "New Bookmark" ), this ); - m_toolBar->addAction( addBookmarkAction ); - connect( addBookmarkAction, SIGNAL(triggered(bool)), BookmarkModel::instance(), SLOT(createNewBookmark()) );*/ - - m_toolBar->addWidget( new BookmarkCurrentButton( 0 ) ); - - m_searchEdit = new Amarok::LineEdit( topLayout ); - m_searchEdit->setClickMessage( i18n( "Filter bookmarks" ) ); - m_searchEdit->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); - m_searchEdit->setClearButtonShown( true ); - m_searchEdit->setFrame( true ); - m_searchEdit->setToolTip( i18n( "Start typing to progressively filter the bookmarks" ) ); - m_searchEdit->setFocusPolicy( Qt::ClickFocus ); // Without this, the widget goes into text input mode directly on startup - - m_bookmarkView = new BookmarkTreeView( this ); - - m_proxyModel = new QSortFilterProxyModel( this ); - m_proxyModel->setSourceModel( BookmarkModel::instance() ); - m_proxyModel->setFilterCaseSensitivity( Qt::CaseInsensitive ); - m_proxyModel->setSortCaseSensitivity( Qt::CaseInsensitive ); - m_proxyModel->setDynamicSortFilter( true ); - m_proxyModel->setFilterKeyColumn ( -1 ); //filter on all columns - - m_bookmarkView->setModel( m_proxyModel ); - m_bookmarkView->setProxy( m_proxyModel ); - m_bookmarkView->setSortingEnabled( true ); - m_bookmarkView->resizeColumnToContents( 0 ); - - connect( BookmarkModel::instance(), SIGNAL(editIndex(QModelIndex)), m_bookmarkView, SLOT(slotEdit(QModelIndex)) ); - connect( m_searchEdit, SIGNAL(textChanged(QString)), m_proxyModel, SLOT(setFilterFixedString(QString)) ); - - m_currentBookmarkId = -1; - -} - -BookmarkManagerWidget::~BookmarkManagerWidget() -{ -} - - -BookmarkTreeView * BookmarkManagerWidget::treeView() -{ - return m_bookmarkView; -} - -#include "moc_BookmarkManagerWidget.cpp" - - - diff --git a/amarok/src/amarokurls/BookmarkManagerWidget.h b/amarok/src/amarokurls/BookmarkManagerWidget.h deleted file mode 100644 index a00f381a..00000000 --- a/amarok/src/amarokurls/BookmarkManagerWidget.h +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008, 2009 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef BOOKMARKMANAGERWIDGET_H -#define BOOKMARKMANAGERWIDGET_H - -#include "amarok_export.h" -#include "amarokurls/BookmarkTreeView.h" -#include "widgets/LineEdit.h" - -#include - -#include -#include -#include -#include - - -/** -A widget for managing amarok:// bookmark urls - - @author Nikolaj Hald Nielsen -*/ -class AMAROK_EXPORT BookmarkManagerWidget : public KVBox -{ - Q_OBJECT -public: - BookmarkManagerWidget( QWidget * parent = 0); - ~BookmarkManagerWidget(); - - BookmarkTreeView * treeView(); - -private: - - QToolBar * m_toolBar; - Amarok::LineEdit * m_searchEdit; - BookmarkTreeView * m_bookmarkView; - - int m_currentBookmarkId; - QString m_lastFilter; - - QSortFilterProxyModel * m_proxyModel; - -}; - -#endif diff --git a/amarok/src/amarokurls/BookmarkMetaActions.cpp b/amarok/src/amarokurls/BookmarkMetaActions.cpp deleted file mode 100644 index 5d750ce5..00000000 --- a/amarok/src/amarokurls/BookmarkMetaActions.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "BookmarkMetaActions.h" - -#include "EngineController.h" -#include "SvgHandler.h" -#include "amarokurls/AmarokUrlHandler.h" -#include "amarokurls/BookmarkModel.h" -#include "core/meta/Meta.h" -#include "core-impl/capabilities/timecode/TimecodeWriteCapability.h" -#include "widgets/ProgressWidget.h" - -#include -#include - -BookmarkAlbumAction::BookmarkAlbumAction( QObject *parent, Meta::AlbumPtr album ) - : QAction( i18n( "Bookmark this Album" ), parent ) - , m_album( album ) -{ - connect( this, SIGNAL(triggered(bool)), SLOT(slotTriggered()) ); - setIcon( KIcon("bookmark-new") ); - setProperty( "popupdropper_svg_id", "lastfm" ); -} - -void -BookmarkAlbumAction::slotTriggered() -{ - The::amarokUrlHandler()->bookmarkAlbum( m_album ); -} - - -BookmarkArtistAction::BookmarkArtistAction( QObject *parent, Meta::ArtistPtr artist ) - : QAction( i18n( "Bookmark this Artist" ), parent ) - , m_artist( artist ) -{ - connect( this, SIGNAL(triggered(bool)), SLOT(slotTriggered()) ); - setIcon( KIcon("bookmark-new") ); - setProperty( "popupdropper_svg_id", "lastfm" ); -} - -void -BookmarkArtistAction::slotTriggered() -{ - The::amarokUrlHandler()->bookmarkArtist( m_artist ); -} - -BookmarkCurrentTrackPositionAction::BookmarkCurrentTrackPositionAction( QObject * parent ) - : QAction( i18n( "Add Position Marker" ), parent ) -{ - connect( this, SIGNAL(triggered(bool)), SLOT(slotTriggered()) ); - setIcon( KIcon("flag-amarok") ); -} - -void -BookmarkCurrentTrackPositionAction::slotTriggered() -{ - DEBUG_BLOCK - - Meta::TrackPtr track = The::engineController()->currentTrack(); - const qint64 miliseconds = The::engineController()->trackPositionMs(); - - if ( track && track->has() ) - { - debug() << " has WriteTimecode "; - QScopedPointer tcw( track->create() ); - tcw->writeTimecode( miliseconds ); - } -} - -#include "moc_BookmarkMetaActions.cpp" - - diff --git a/amarok/src/amarokurls/BookmarkMetaActions.h b/amarok/src/amarokurls/BookmarkMetaActions.h deleted file mode 100644 index bbd3b08c..00000000 --- a/amarok/src/amarokurls/BookmarkMetaActions.h +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef BOOKMARKMETAACTIONS_H -#define BOOKMARKMETAACTIONS_H - -#include "amarok_export.h" -#include "core/meta/forward_declarations.h" - -#include - - -class AMAROK_EXPORT BookmarkAlbumAction : public QAction -{ - Q_OBJECT - -public: - BookmarkAlbumAction( QObject *parent, Meta::AlbumPtr album ); - - private slots: - void slotTriggered(); - - private: - Meta::AlbumPtr m_album; -}; - - -class AMAROK_EXPORT BookmarkArtistAction : public QAction -{ - Q_OBJECT - - public: - BookmarkArtistAction( QObject *parent, Meta::ArtistPtr artist ); - - private slots: - void slotTriggered(); - - private: - Meta::ArtistPtr m_artist; -}; - - -class AMAROK_EXPORT BookmarkCurrentTrackPositionAction : public QAction -{ - Q_OBJECT - - public: - explicit BookmarkCurrentTrackPositionAction( QObject *parent ); - - private slots: - void slotTriggered(); -}; - -#endif diff --git a/amarok/src/amarokurls/BookmarkModel.cpp b/amarok/src/amarokurls/BookmarkModel.cpp deleted file mode 100644 index b9c77830..00000000 --- a/amarok/src/amarokurls/BookmarkModel.cpp +++ /dev/null @@ -1,705 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Nikolaj Hald Nielsen * - * Copyright (c) 2008 Ian Monroe * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "BookmarkModel.h" - -#include "AmarokMimeData.h" -#include "AmarokUrl.h" -#include "BookmarkGroup.h" -#include "AmarokUrlHandler.h" -#include "core/support/Debug.h" -#include -#include - -#include - -#include -#include - -#include - -static const int BOOKMARK_DB_VERSION = 4; -static const QString key("AMAROK_BOOKMARKS"); - -BookmarkModel * BookmarkModel::s_instance = 0; - -BookmarkModel * BookmarkModel::instance() -{ - if ( s_instance == 0 ) - s_instance = new BookmarkModel(); - - return s_instance; -} - - -BookmarkModel::BookmarkModel() - : QAbstractItemModel() -{ - checkTables(); - - m_root = BookmarkGroupPtr( new BookmarkGroup( "root", BookmarkGroupPtr() ) ); -} - - -BookmarkModel::~BookmarkModel() -{ -} - -QVariant -BookmarkModel::data( const QModelIndex & index, int role ) const -{ - - if ( !index.isValid() ) - return QVariant(); - - BookmarkViewItemPtr item = m_viewItems.value( index.internalId() ); - - if( role == 0xf00d ) - return QVariant::fromValue( item ); - else if( role == Qt::DisplayRole || role == Qt::EditRole ) - { - switch( index.column() ) - { - case Name: - return item->name(); - break; - case Command: - { - AmarokUrl * url = dynamic_cast( item.data() ); - if ( url ) - return url->prettyCommand(); - else - return i18n( "Group" ); - break; - } - case Url: - { - AmarokUrl * url = dynamic_cast( item.data() ); - if ( url ) - return url->url(); - else - return QString(); - break; - } - case Description: - { - return item->description(); - break; - } - default: - break; - } - } - else if( role == Qt::DecorationRole ) - { - if( index.column() == Name ) - { - if ( typeid( * item ) == typeid( BookmarkGroup ) ) - return QVariant( KIcon( "folder-bookmark" ) ); - else if ( typeid( * item ) == typeid( AmarokUrl ) ) - { - AmarokUrl * url = static_cast( item.data() ); - return The::amarokUrlHandler()->iconForCommand( url->command() ); - } - } - } - - return QVariant(); -} - - -QModelIndex -BookmarkModel::createIndex( int row, int column, const BookmarkViewItemPtr &item ) const -{ - quint32 index = qHash( item.data() ); - if( !m_viewItems.contains( index ) ) - m_viewItems[ index ] = item; - QModelIndex ret = QAbstractItemModel::createIndex( row, column, index ); -// debug() << "created " << ret << " with " << ret.parent().internalId(); - return ret; -} - -QModelIndex -BookmarkModel::index( int row, int column, const QModelIndex & parent ) const -{ - //DEBUG_BLOCK - - //debug() << "row: " << row << ", column: " <childGroups().count(); - if ( row < noOfGroups ) - { - return createIndex( row, column, BookmarkViewItemPtr::staticCast( m_root->childGroups().at( row ) ) ); - } - else - { - //debug() << "Root playlist"; - return createIndex( row, column, BookmarkViewItemPtr::staticCast( m_root->childBookmarks().at( row - noOfGroups ) ) ); - } - } - else - { - BookmarkGroupPtr playlistGroup = BookmarkGroupPtr::staticCast( m_viewItems.value( parent.internalId() ) ); - int noOfGroups = playlistGroup->childGroups().count(); - - if ( row < noOfGroups ) - { - return createIndex( row, column, BookmarkViewItemPtr::staticCast( playlistGroup->childGroups().at(row) ) ); - } - else - { - return createIndex( row, column, BookmarkViewItemPtr::staticCast( playlistGroup->childBookmarks().at(row - noOfGroups) ) ); - } - } -} - -QModelIndex -BookmarkModel::parent( const QModelIndex & index ) const -{ - //DEBUG_BLOCK - - if (!index.isValid()) - return QModelIndex(); - BookmarkViewItemPtr item = m_viewItems.value( index.internalId() ); - - BookmarkGroupPtr parent = item->parent(); - - //debug() << "parent: " << parent; - - if ( parent && parent->parent() ) - { - int row = parent->parent()->childGroups().indexOf( parent ); - return createIndex( row , 0, BookmarkViewItemPtr::staticCast( parent ) ); - } - else { - return QModelIndex(); - } -} - -int -BookmarkModel::rowCount( const QModelIndex & parent ) const -{ - //DEBUG_BLOCK - - if ( parent.column() > 0 ) { - // debug() << "bad column"; - return 0; - } - - if (!parent.isValid()) { - - //debug() << "top level item has" << m_root->childCount(); - - return m_root->childCount(); - - } - BookmarkViewItemPtr item = m_viewItems.value( parent.internalId() ); - //debug() << "row: " << parent.row(); - //debug() << "address: " << item; - //debug() << "count: " << item->childCount(); - - return item->childCount(); -} - -int -BookmarkModel::columnCount(const QModelIndex & /*parent*/) const -{ - //name, command, url, description - return 4; -} - - -Qt::ItemFlags -BookmarkModel::flags( const QModelIndex & index ) const -{ - - if (!index.isValid()) - return Qt::ItemIsEnabled | Qt::ItemIsDropEnabled; - BookmarkViewItemPtr item = BookmarkViewItemPtr::staticCast( m_viewItems.value( index.internalId() ) ); - - if ( typeid( * item ) == typeid( BookmarkGroup ) ) - { - if ( index.column() != Command ) - return Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsDropEnabled | Qt::ItemIsDragEnabled; - else - return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsDropEnabled | Qt::ItemIsDragEnabled; - } - else - { - if ( index.column() != Command ) - return Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsDragEnabled; - else - return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsDragEnabled; - } -} - -QVariant -BookmarkModel::headerData(int section, Qt::Orientation orientation, int role) const -{ - if (orientation == Qt::Horizontal && role == Qt::DisplayRole) { - switch( section ) - { - case Name: return i18n("Name"); - case Command: return i18n("Type"); - case Url: return i18n("URL"); - case Description: return i18n("Description"); - default: return QVariant(); - } - } - - return QVariant(); -} - -bool BookmarkModel::setData( const QModelIndex & index, const QVariant & value, int role ) -{ - if (role != Qt::EditRole) - return false; - if ( index.column() == Command ) - return false; - - BookmarkViewItemPtr item = m_viewItems.value( index.internalId() ); - - switch( index.column() ) - { - case Name: - item->rename( value.toString() ); - emit dataChanged( index, index ); - break; - case Url: - { - AmarokUrl * url = dynamic_cast( item.data() ); - if ( url ) - { - debug() << "writing " << value.toString() << " as new url!"; - url->initFromString( value.toString() ); - url->saveToDb(); - - emit dataChanged( index, index ); - } - break; - } - case Description: - { - item->setDescription( value.toString() ); - - AmarokUrl * url = dynamic_cast( item.data() ); - if ( url ) - { - url->saveToDb(); - emit dataChanged( index, index ); - } - - break; - } - } - return true; - -} - -QStringList -BookmarkModel::mimeTypes() const -{ - DEBUG_BLOCK - QStringList ret; - ret << AmarokMimeData::BOOKMARKGROUP_MIME; - ret << AmarokMimeData::AMAROKURL_MIME; - return ret; -} - -QMimeData* -BookmarkModel::mimeData( const QModelIndexList &indexes ) const -{ - DEBUG_BLOCK - AmarokMimeData* mime = new AmarokMimeData(); - - BookmarkGroupList groups; - BookmarkList bookmarks; - - foreach( const QModelIndex &index, indexes ) { - - BookmarkViewItemPtr item = m_viewItems.value( index.internalId() ); - - if ( typeid( * item ) == typeid( BookmarkGroup ) ) { - BookmarkGroupPtr playlistGroup = BookmarkGroupPtr::staticCast( item ); - groups << playlistGroup; - } - else - { - AmarokUrlPtr bookmark = AmarokUrlPtr::dynamicCast( item ); - if( bookmark ) - bookmarks << bookmark; - } - } - - debug() << "adding " << groups.count() << " groups and " << bookmarks.count() << " bookmarks"; - - mime->setBookmarkGroups( groups ); - mime->setBookmarks( bookmarks ); - - return mime; -} - - -bool -BookmarkModel::dropMimeData ( const QMimeData * data, Qt::DropAction action, int row, int column, const QModelIndex & parent ) //reimplemented -{ - DEBUG_BLOCK - - Q_UNUSED( column ); - Q_UNUSED( row ); - if( action == Qt::IgnoreAction ) - return true; - - BookmarkGroupPtr parentGroup; - if ( !parent.isValid() ) - { - parentGroup = m_root; - } - else - { - parentGroup = BookmarkGroupPtr::staticCast( m_viewItems.value( parent.internalId() ) ); - } - - if( data->hasFormat( AmarokMimeData::BOOKMARKGROUP_MIME ) ) - { - debug() << "Found playlist group mime type"; - - const AmarokMimeData* bookmarkGroupDrag = dynamic_cast( data ); - if( bookmarkGroupDrag ) - { - - BookmarkGroupList groups = bookmarkGroupDrag->bookmarkGroups(); - - foreach( BookmarkGroupPtr group, groups ) { - group->reparent( parentGroup ); - } - - reloadFromDb(); - - return true; - } - } - else if( data->hasFormat( AmarokMimeData::AMAROKURL_MIME ) ) - { - debug() << "Found amarokurl mime type"; - - const AmarokMimeData* dragList = dynamic_cast( data ); - if( dragList ) - { - BookmarkList bookmarks = dragList->bookmarks(); - - foreach( AmarokUrlPtr bookmarkPtr, bookmarks ) { - bookmarkPtr->reparent( parentGroup ); - } - - reloadFromDb(); - - return true; - } - } - - return false; -} - -void BookmarkModel::createTables() -{ - DEBUG_BLOCK - - SqlStorage *sqlStorage = StorageManager::instance()->sqlStorage(); - if( !sqlStorage ) - return; - - sqlStorage->query( QString( "CREATE TABLE bookmark_groups (" - " id " + sqlStorage->idType() + - ", parent_id INTEGER" - ", name " + sqlStorage->textColumnType() + - ", description " + sqlStorage->textColumnType() + - ", custom " + sqlStorage->textColumnType() + " ) ENGINE = MyISAM;" ) ); - - sqlStorage->query( QString( "CREATE TABLE bookmarks (" - " id " + sqlStorage->idType() + - ", parent_id INTEGER" - ", name " + sqlStorage->textColumnType() + - ", url " + sqlStorage->exactTextColumnType() + - ", description " + sqlStorage->exactTextColumnType() + - ", custom " + sqlStorage->textColumnType() + " ) ENGINE = MyISAM;" ) ); - -} - -void BookmarkModel::deleteTables() -{ - - DEBUG_BLOCK - - SqlStorage *sqlStorage = StorageManager::instance()->sqlStorage(); - if( !sqlStorage ) - return; - - sqlStorage->query( "DROP TABLE IF EXISTS bookmark_groups;" ); - sqlStorage->query( "DROP TABLE IF EXISTS bookmarks;" ); - -} - -void BookmarkModel::checkTables() -{ - - DEBUG_BLOCK - - SqlStorage *sqlStorage = StorageManager::instance()->sqlStorage(); - if( !sqlStorage ) - return; - - QStringList values = sqlStorage->query( QString("SELECT version FROM admin WHERE component = '%1';").arg(sqlStorage->escape( key ) ) ); - - //also check if the db version is correct but the table is simply missing... can happen due to a bug in 2.2.0 beta1 and beta2 - QStringList values2 = sqlStorage->query( "show tables like 'bookmarks';"); - - if( values.isEmpty() || values2.isEmpty() ) - { - debug() << "creating Playlist Tables"; - createTables(); - sqlStorage->query( "INSERT INTO admin(component,version) " - "VALUES('" + key + "'," + QString::number( BOOKMARK_DB_VERSION ) + ");" ); - } - else if ( values.at( 0 ).toInt() < 4 ) - { - upgradeTables( values.at( 0 ).toInt() ); - sqlStorage->query( "UPDATE admin SET version=" + QString::number( BOOKMARK_DB_VERSION ) + " WHERE component=" + key + ';' ); - } -} - -void -BookmarkModel::reloadFromDb() -{ - DEBUG_BLOCK; - m_root->clear(); - reset(); - -} - -void -BookmarkModel::editBookmark( int id ) -{ - - //for now, assume that the newly added playlist is in the top level: - int row = m_root->childGroups().count() - 1; - foreach ( AmarokUrlPtr bookmark, m_root->childBookmarks() ) { - row++; - if ( bookmark->id() == id ) { - emit editIndex( createIndex( row , 0, BookmarkViewItemPtr::staticCast( bookmark ) ) ); - } - } -} - -void -BookmarkModel::createNewGroup() -{ - DEBUG_BLOCK - - BookmarkGroup * group = new BookmarkGroup( i18n("New Group"), m_root ); - group->save(); - int id = group->id(); - delete group; - - reloadFromDb(); - - int row = 0; - foreach ( BookmarkGroupPtr childGroup, m_root->childGroups() ) { - if ( childGroup->id() == id ) - { - debug() << "emitting edit for " << childGroup->name() << " id " << childGroup->id() << " in row " << row; - emit editIndex( createIndex( row , 0, BookmarkViewItemPtr::staticCast( childGroup ) ) ); - } - row++; - } - -} - -void -BookmarkModel::createNewBookmark() -{ - DEBUG_BLOCK - AmarokUrl * url = new AmarokUrl(); - url->reparent( m_root ); - url->setName( i18n( "New Bookmark" ) ); - url->setCommand( i18n( "none" ) ); - url->saveToDb(); - int id = url->id(); - delete url; - - reloadFromDb(); - debug() << "id of new bookmark: " << id; - int row = m_root->childGroups().count(); - foreach ( AmarokUrlPtr childBookmark, m_root->childBookmarks() ) { - debug() << id << " == " << childBookmark->id() << " ? "; - if ( childBookmark->id() == id ) - { - debug() << "emitting edit for " << childBookmark->name() << " id " << childBookmark->id() << " in row " << row; - emit editIndex( createIndex( row , 0, BookmarkViewItemPtr::staticCast( childBookmark ) ) ); - } - row++; - } - -} - -void -BookmarkModel::setBookmarkArg( const QString &name, const QString &key, const QString &value ) -{ - if( setBookmarkArgRecursively( m_root, name, key, value ) ) - { - reloadFromDb(); - The::amarokUrlHandler()->updateTimecodes(); - } - else - { - warning() << "Cannot set argument" << key << "of the bookmark" << name - << "to value" << value << "- bookmark not found."; - } -} - -void -BookmarkModel::deleteBookmark( const QString& name ) -{ - DEBUG_BLOCK - - debug() << "Name: " << name; - - if( deleteBookmarkRecursively( m_root, name ) ) - { - debug() << "Deleted!"; - reloadFromDb(); - The::amarokUrlHandler()->updateTimecodes(); - } - else - debug() << "No such bookmark found!"; -} - -void -BookmarkModel::renameBookmark( const QString& oldName, const QString& newName ) -{ - DEBUG_BLOCK - - debug() << "OldName: " << oldName << " NewName: " << newName; - - if( renameBookmarkRecursively( m_root, oldName, newName ) ) - { - debug() << "Renamed!!"; - reloadFromDb(); - const QString* name = &newName; - The::amarokUrlHandler()->updateTimecodes( name ); - } - else - debug() << "No such bookmark found!"; -} - -bool -BookmarkModel::setBookmarkArgRecursively( BookmarkGroupPtr group, const QString& name, const QString& key, const QString &value ) -{ - foreach( AmarokUrlPtr item, group->childBookmarks() ) - { - if( item->name() == name ) - { - item->setArg( key, value ); - item->saveToDb(); - return true; - } - } - - //if not found, recurse through child groups - foreach( BookmarkGroupPtr childGroup, group->childGroups() ) - { - if( setBookmarkArgRecursively( childGroup, name, key, value ) ) - return true; - } - - return false; - -} - -bool -BookmarkModel::deleteBookmarkRecursively( BookmarkGroupPtr group, const QString& name ) -{ - foreach( AmarokUrlPtr item, group->childBookmarks() ) - { - debug() << "item->name(): " << item->name(); - if( item->name() == name ) - { - debug() << "Deleting Bookmark: " << name; - item->removeFromDb(); - return true; - } - } - - //if not found, recurse through child groups - foreach( BookmarkGroupPtr childGroup, group->childGroups() ) - { - if( deleteBookmarkRecursively( childGroup, name ) ) - return true; - } - - return false; - -} - -bool -BookmarkModel::renameBookmarkRecursively( BookmarkGroupPtr group, const QString& oldName, const QString& newName ) -{ - foreach( AmarokUrlPtr item, group->childBookmarks() ) - { - debug() << "item->name(): " << item->name(); - if( item->name() == oldName) - { - debug() << "Renaming Bookmark: " << oldName; - item->rename(newName); - return true; - } - } - - //if not found, recurse through child groups - foreach( BookmarkGroupPtr childGroup, group->childGroups() ) - { - if( renameBookmarkRecursively( childGroup, oldName, newName ) ) - return true; - } - - return false; - -} - -void BookmarkModel::upgradeTables( int from ) -{ - SqlStorage *sqlStorage = StorageManager::instance()->sqlStorage(); - if( !sqlStorage ) - return; - - if ( from == 2 ) { - sqlStorage->query( "ALTER TABLE bookmarks ADD custom " + sqlStorage->textColumnType() + ';' ); - } - - sqlStorage->query( "ALTER TABLE bookmark_groups ADD custom " + sqlStorage->textColumnType() + ';' ); -} - - - - - -#include "moc_BookmarkModel.cpp" diff --git a/amarok/src/amarokurls/BookmarkModel.h b/amarok/src/amarokurls/BookmarkModel.h deleted file mode 100644 index 46408593..00000000 --- a/amarok/src/amarokurls/BookmarkModel.h +++ /dev/null @@ -1,135 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef BOOKMARKMODEL_H -#define BOOKMARKMODEL_H - -#include "BookmarkViewItem.h" - -#include - -#include -#include -#include - - -class BookmarkGroup; - -typedef KSharedPtr BookmarkViewItemPtr; - -class BookmarkGroup; -typedef KSharedPtr BookmarkGroupPtr; -typedef QList BookmarkGroupList; - - -//#define BOOKMARK_DB_VERSION 1 - - -/** - @author Nikolaj Hald Nielsen -*/ - -class BookmarkModel : public QAbstractItemModel -{ - Q_OBJECT -public: - - enum Column - { - Name = 0, - Command, - Url, - Description - }; - - static BookmarkModel * instance(); - - ~BookmarkModel(); - - virtual QVariant data( const QModelIndex &index, int role ) const; - virtual Qt::ItemFlags flags( const QModelIndex &index ) const; - virtual QVariant headerData( int section, Qt::Orientation orientation, - int role = Qt::DisplayRole ) const; - virtual QModelIndex index( int row, int column, - const QModelIndex &parent = QModelIndex() ) const; - virtual QModelIndex parent( const QModelIndex &index ) const; - virtual int rowCount( const QModelIndex &parent = QModelIndex() ) const; - virtual int columnCount( const QModelIndex &parent = QModelIndex() ) const; - virtual bool setData( const QModelIndex &index, const QVariant &value, int role = Qt::EditRole ); - - virtual Qt::DropActions supportedDropActions() const - { - return Qt::MoveAction; - } - - virtual QStringList mimeTypes() const; - QMimeData* mimeData( const QModelIndexList &indexes ) const; - bool dropMimeData( const QMimeData * data, Qt::DropAction action, int row, int column, const QModelIndex &parent ); - - void reloadFromDb(); - void editBookmark( int id ); - - QModelIndex createIndex( int row, int column, const BookmarkViewItemPtr &item ) const; - //only use the above method - QModelIndex createIndex( int, int, void * ptr = 0 ) const - { - Q_UNUSED( ptr ); - Q_ASSERT( 0 ); - return QModelIndex(); - } - - QModelIndex createIndex( int, int, quint32 ) const - { - Q_ASSERT( 0 ); - return QModelIndex(); - } - -public slots: - void createNewGroup(); - void createNewBookmark(); - void deleteBookmark( const QString &name ); - void renameBookmark( const QString &oldName , const QString &newName ); - - /** - * Sets the bookmark's (whose name is @param name) url argument named @param key - * to @param value. Overrides any possible previous value. - */ - void setBookmarkArg(const QString &name, const QString &key, const QString &value); - -signals: - void editIndex( const QModelIndex &index ); - -private: - BookmarkModel(); - - void checkTables(); - void createTables(); - void deleteTables(); - void upgradeTables( int from ); - - bool setBookmarkArgRecursively( BookmarkGroupPtr group, const QString &name, const QString &key, const QString &value ); - bool deleteBookmarkRecursively( BookmarkGroupPtr group, const QString &name ); - bool renameBookmarkRecursively( BookmarkGroupPtr group, const QString &oldName, const QString &newName ); - - static BookmarkModel * s_instance; - - BookmarkGroupPtr m_root; - mutable QHash m_viewItems; ///the hash of the pointer mapped to the KSharedPtr - -}; - - -#endif diff --git a/amarok/src/amarokurls/BookmarkTreeView.cpp b/amarok/src/amarokurls/BookmarkTreeView.cpp deleted file mode 100644 index 181e1f39..00000000 --- a/amarok/src/amarokurls/BookmarkTreeView.cpp +++ /dev/null @@ -1,441 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "BookmarkTreeView.h" - -#include "BookmarkModel.h" -#include "dialogs/TagDialog.h" -#include "PaletteHandler.h" -#include "AmarokUrl.h" -#include "AmarokUrlHandler.h" -#include "BookmarkGroup.h" -#include "playlist/PlaylistController.h" -#include "SvgHandler.h" -#include "core-impl/meta/timecode/TimecodeMeta.h" - -#include -#include - -#include -#include - -#include - -#include -#include -#include - -#include - -BookmarkTreeView::BookmarkTreeView( QWidget *parent ) - : QTreeView( parent ) - , m_loadAction( 0 ) - , m_deleteAction( 0 ) - , m_createTimecodeTrackAction( 0 ) - , m_addGroupAction( 0 ) -{ - - setEditTriggers( QAbstractItemView::SelectedClicked ); - setSelectionMode( QAbstractItemView::ExtendedSelection ); - - setDragEnabled( true ); - setAcceptDrops( true ); - setAlternatingRowColors( true ); - setDropIndicatorShown( true ); - - connect( header(), SIGNAL(sectionCountChanged(int,int)), - this, SLOT(slotSectionCountChanged(int,int)) ); -} - - -BookmarkTreeView::~BookmarkTreeView() -{ -} - -void BookmarkTreeView::mouseDoubleClickEvent( QMouseEvent * event ) -{ - QModelIndex index = m_proxyModel->mapToSource( indexAt( event->pos() ) ); - - if( index.isValid() ) - { - BookmarkViewItemPtr item = BookmarkModel::instance()->data( index, 0xf00d ).value(); - - if ( typeid( *item ) == typeid( AmarokUrl ) ) { - AmarokUrl * bookmark = static_cast< AmarokUrl* >( item.data() ); - bookmark->run(); - } - } -} - - -void -BookmarkTreeView::keyPressEvent( QKeyEvent *event ) -{ - switch( event->key() ) - { - case Qt::Key_Delete: - slotDelete(); - return; - - case Qt::Key_F2: - slotRename(); - return; - } - QTreeView::keyPressEvent( event ); -} - -QList -BookmarkTreeView::createCommonActions( QModelIndexList indices ) -{ - DEBUG_BLOCK - - //there are 4 columns, so for each selected row we get 4 indices... - int selectedRowCount = indices.count() / 4; - - QList< KAction * > actions; - if ( m_loadAction == 0 ) - { - m_loadAction = new KAction( KIcon( "folder-open" ), i18nc( "Load the view represented by this bookmark", "&Load" ), this ); - connect( m_loadAction, SIGNAL(triggered()), this, SLOT(slotLoad()) ); - } - - if ( m_deleteAction == 0 ) - { - m_deleteAction = new KAction( KIcon( "media-track-remove-amarok" ), i18n( "&Delete" ), this ); - connect( m_deleteAction, SIGNAL(triggered()), this, SLOT(slotDelete()) ); - } - - if ( m_createTimecodeTrackAction == 0 ) - { - debug() << "creating m_createTimecodeTrackAction"; - m_createTimecodeTrackAction = new KAction( KIcon( "media-track-edit-amarok" ), i18n( "&Create timecode track" ), this ); - connect( m_createTimecodeTrackAction, SIGNAL(triggered()), this, SLOT(slotCreateTimecodeTrack()) ); - } - - if ( selectedRowCount == 1 ) - actions << m_loadAction; - - if ( selectedRowCount > 0 ) - actions << m_deleteAction; - - if ( selectedRowCount == 2 ) { - debug() << "adding m_createTimecodeTrackAction"; - actions << m_createTimecodeTrackAction; - } - - return actions; -} - -void BookmarkTreeView::slotLoad() -{ - DEBUG_BLOCK - foreach( BookmarkViewItemPtr item, selectedItems() ) - { - if( typeid( * item ) == typeid( AmarokUrl ) ) - { - AmarokUrlPtr bookmark = AmarokUrlPtr::staticCast( item ); - bookmark->run(); - } - } -} - -void BookmarkTreeView::slotDelete() -{ - DEBUG_BLOCK - - //TODO FIXME Confirmation of delete - - foreach( BookmarkViewItemPtr item, selectedItems() ) - { - debug() << "deleting " << item->name(); - item->removeFromDb(); - item->parent()->deleteChild( item ); - } - BookmarkModel::instance()->reloadFromDb(); - The::amarokUrlHandler()->updateTimecodes(); -} - -void BookmarkTreeView::slotRename() -{ - DEBUG_BLOCK - if ( selectionModel()->hasSelection() ) - edit( selectionModel()->selectedIndexes().first() ); -} - -void BookmarkTreeView::contextMenuEvent( QContextMenuEvent * event ) -{ - DEBUG_BLOCK - - QModelIndexList indices = selectionModel()->selectedIndexes(); - - KMenu* menu = new KMenu( this ); - - QList actions = createCommonActions( indices ); - - foreach( KAction * action, actions ) - menu->addAction( action ); - - if( indices.count() == 0 ) - menu->addAction( m_addGroupAction ); - - menu->exec( event->globalPos() ); -} - -void BookmarkTreeView::resizeEvent( QResizeEvent *event ) -{ - QHeaderView *headerView = header(); - - const int oldWidth = event->oldSize().width(); - const int newWidth = event->size().width(); - - if( oldWidth == newWidth || oldWidth < 0 || newWidth < 0 ) - return; - - disconnect( headerView, SIGNAL(sectionResized(int,int,int)), - this, SLOT(slotSectionResized(int,int,int)) ); - - QMap::const_iterator i = m_columnsSize.constBegin(); - while( i != m_columnsSize.constEnd() ) - { - const BookmarkModel::Column col = i.key(); - if( col != BookmarkModel::Command && col != BookmarkModel::Description ) - headerView->resizeSection( col, static_cast( i.value() * newWidth ) ); - ++i; - } - - connect( headerView, SIGNAL(sectionResized(int,int,int)), - this, SLOT(slotSectionResized(int,int,int)) ); - - QWidget::resizeEvent( event ); -} - -bool BookmarkTreeView::viewportEvent( QEvent *event ) -{ - if( event->type() == QEvent::ToolTip ) - { - QHelpEvent *he = static_cast( event ); - QModelIndex idx = indexAt( he->pos() ); - - if( idx.isValid() ) - { - QRect vr = visualRect( idx ); - QSize shr = itemDelegate( idx )->sizeHint( viewOptions(), idx ); - - if( shr.width() > vr.width() ) - QToolTip::showText( he->globalPos(), idx.data( Qt::DisplayRole ).toString() ); - } - else - { - QToolTip::hideText(); - event->ignore(); - } - return true; - } - return QTreeView::viewportEvent( event ); -} - -QSet -BookmarkTreeView::selectedItems() const -{ - DEBUG_BLOCK - QSet selected; - foreach( const QModelIndex &index, selectionModel()->selectedIndexes() ) - { - QModelIndex sourceIndex = m_proxyModel->mapToSource( index ); - if( sourceIndex.isValid() && sourceIndex.internalPointer() && sourceIndex.column() == 0 ) - { - debug() << "inserting item " << sourceIndex.data( Qt::DisplayRole ).toString(); - selected.insert( BookmarkModel::instance()->data( sourceIndex, 0xf00d ).value() ); - } - } - return selected; -} - -void BookmarkTreeView::setNewGroupAction( KAction * action ) -{ - m_addGroupAction = action; -} - -void BookmarkTreeView::selectionChanged( const QItemSelection & selected, const QItemSelection & deselected ) -{ - DEBUG_BLOCK - Q_UNUSED( deselected ) - QModelIndexList indexes = selected.indexes(); - debug() << indexes.size() << " items selected"; - foreach( const QModelIndex &index, indexes ) - { - const QModelIndex sourceIndex = m_proxyModel->mapToSource( index ); - if( sourceIndex.column() == 0 ) - { - BookmarkViewItemPtr item = BookmarkModel::instance()->data( sourceIndex, 0xf00d ).value(); - - if ( typeid( * item ) == typeid( AmarokUrl ) ) { - debug() << "a url was selected..."; - AmarokUrl bookmark = *static_cast< AmarokUrl* >( item.data() ); - emit( bookmarkSelected( bookmark ) ); - } - } - } - -} - -KMenu* BookmarkTreeView::contextMenu( const QPoint& point ) -{ - DEBUG_BLOCK - KMenu* menu = new KMenu( 0 ); - - debug() << "getting menu for point:" << point; - QModelIndex index = m_proxyModel->mapToSource( indexAt( point ) ); - if( index.isValid() ) - { - - debug() << "got valid index"; - - QModelIndexList indices = selectionModel()->selectedIndexes(); - - QList actions = createCommonActions( indices ); - - foreach( KAction * action, actions ) - menu->addAction( action ); - - if( indices.count() == 0 ) - menu->addAction( m_addGroupAction ); - - } - - return menu; -} - -void BookmarkTreeView::slotCreateTimecodeTrack() const -{ - - //TODO: Factor into separate class - QList list = selectedItems().toList(); - if ( list.count() != 2 ) - return; - - const AmarokUrl * url1 = dynamic_cast( list.at( 0 ).data() ); - - if ( url1 == 0 ) - return; - if ( url1->command() != "play" ) - return; - - const AmarokUrl * url2 = dynamic_cast( list.at( 1 ).data() ); - - if ( url2 == 0 ) - return; - if ( url2->command() != "play" ) - return; - - if ( url1->path() != url2->path() ) - return; - - //ok, so we actually have to timecodes from the same base url, not get the - //minimum and maximum time: - qreal pos1 = 0; - qreal pos2 = 0; - - if ( url1->args().keys().contains( "pos" ) ) - { - pos1 = url1->args().value( "pos" ).toDouble(); - } - - if ( url2->args().keys().contains( "pos" ) ) - { - pos2 = url2->args().value( "pos" ).toDouble(); - } - - if ( pos1 == pos2 ) - return; - - qint64 start = qMin( pos1, pos2 ) * 1000; - qint64 end = qMax( pos1, pos2 ) * 1000; - - //Now we really should pop up a menu to get the user to enter some info about this - //new track, but for now, just fake it as this is just for testing anyway - - QString url = QUrl::fromEncoded ( QByteArray::fromBase64 ( url1->path().toUtf8() ) ).toString(); - Meta::TimecodeTrackPtr track = Meta::TimecodeTrackPtr( new Meta::TimecodeTrack( i18n( "New Timecode Track" ), url, start, end ) ); - Meta::TimecodeAlbumPtr album = Meta::TimecodeAlbumPtr( new Meta::TimecodeAlbum( i18n( "Unknown" ) ) ); - Meta::TimecodeArtistPtr artist = Meta::TimecodeArtistPtr( new Meta::TimecodeArtist( i18n( "Unknown" ) ) ); - Meta::TimecodeGenrePtr genre = Meta::TimecodeGenrePtr( new Meta::TimecodeGenre( i18n( "Unknown" ) ) ); - - album->addTrack( track ); - artist->addTrack( track ); - genre->addTrack( track ); - - track->setAlbum( album ); - track->setArtist( artist ); - track->setGenre( genre ); - - album->setAlbumArtist( artist ); - - //make the user give us some info about this item... - - Meta::TrackList tl; - tl.append( Meta::TrackPtr::staticCast( track ) ); - TagDialog *dialog = new TagDialog( tl, 0 ); - dialog->show(); - - //now add it to the playlist - The::playlistController()->insertOptioned( Meta::TrackPtr::staticCast( track ) ); -} - -void BookmarkTreeView::setProxy( QSortFilterProxyModel *proxy ) -{ - m_proxyModel = proxy; -} - -void BookmarkTreeView::slotEdit( const QModelIndex &index ) -{ - - //translate to proxy terms - edit( m_proxyModel->mapFromSource( index ) ); -} - -void BookmarkTreeView::slotSectionResized( int logicalIndex, int oldSize, int newSize ) -{ - Q_UNUSED( oldSize ) - BookmarkModel::Column col = BookmarkModel::Column( logicalIndex ); - m_columnsSize[ col ] = static_cast( newSize ) / header()->length(); -} - -void BookmarkTreeView::slotSectionCountChanged( int oldCount, int newCount ) -{ - Q_UNUSED( oldCount ) - - const QHeaderView *headerView = header(); - for( int i = 0; i < newCount; ++i ) - { - const int index = headerView->logicalIndex( i ); - const int width = columnWidth( index ); - const qreal ratio = static_cast( width ) / headerView->length(); - - const BookmarkModel::Column col = BookmarkModel::Column( index ); - - if( col == BookmarkModel::Command ) - header()->setResizeMode( index, QHeaderView::ResizeToContents ); - - m_columnsSize[ col ] = ratio; - } -} - - -#include "moc_BookmarkTreeView.cpp" - - - diff --git a/amarok/src/amarokurls/BookmarkTreeView.h b/amarok/src/amarokurls/BookmarkTreeView.h deleted file mode 100644 index ade11d84..00000000 --- a/amarok/src/amarokurls/BookmarkTreeView.h +++ /dev/null @@ -1,91 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef BOOKMARKTREEVIEW_H -#define BOOKMARKTREEVIEW_H - -#include "amarok_export.h" -#include "AmarokUrl.h" -#include "BookmarkModel.h" -#include "BookmarkViewItem.h" -#include "widgets/PrettyTreeView.h" - -#include - -class KMenu; - -class PopupDropper; -class QAction; - -class KAction; - -class AMAROK_EXPORT BookmarkTreeView : public QTreeView -{ - Q_OBJECT - -public: - BookmarkTreeView( QWidget *parent = 0 ); - ~BookmarkTreeView(); - - void setNewGroupAction( KAction * action ); - KMenu* contextMenu( const QPoint& point ); - - void setProxy( QSortFilterProxyModel *proxy ); - -protected: - void keyPressEvent( QKeyEvent *event ); - void mouseDoubleClickEvent( QMouseEvent *event ); - void contextMenuEvent( QContextMenuEvent *event ); - void resizeEvent( QResizeEvent *event ); - bool viewportEvent( QEvent *event ); - -protected slots: - void slotLoad(); - void slotDelete(); - void slotRename(); - - void slotEdit( const QModelIndex &index ); - - //for testing... - void slotCreateTimecodeTrack() const; - - void slotSectionResized( int logicalIndex, int oldSize, int newSize ); - void slotSectionCountChanged( int oldCount, int newCount ); - - void selectionChanged ( const QItemSelection & selected, const QItemSelection & deselected ); - -signals: - void bookmarkSelected( AmarokUrl bookmark ); - void showMenu( KMenu*, const QPointF& ); - -private: - QSet selectedItems() const; - QList createCommonActions( QModelIndexList indices ); - - KAction *m_loadAction; - KAction *m_deleteAction; - - //for testing... - KAction *m_createTimecodeTrackAction; - - KAction *m_addGroupAction; - - QMap m_columnsSize; - - QSortFilterProxyModel * m_proxyModel; -}; - -#endif diff --git a/amarok/src/amarokurls/BookmarkViewItem.h b/amarok/src/amarokurls/BookmarkViewItem.h deleted file mode 100644 index 786b907e..00000000 --- a/amarok/src/amarokurls/BookmarkViewItem.h +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef BOOKMARKVIEWITEM_H -#define BOOKMARKVIEWITEM_H - -#include "core/support/Debug.h" - -#include -#include -class BookmarkGroup; - -typedef KSharedPtr BookmarkGroupPtr; -typedef QList BookmarkGroupList; - -/** - @author Nikolaj Hald Nielsen -*/ - -class BookmarkViewItem; -typedef KSharedPtr BookmarkViewItemPtr; - -class BookmarkViewItem : public virtual QSharedData -{ - public: - BookmarkViewItem() : QSharedData() {} - - virtual ~BookmarkViewItem() { DEBUG_BLOCK }; - - virtual BookmarkGroupPtr parent() const = 0; - virtual int childCount() const { return 0; } - virtual QString name() const = 0; - virtual QString description() const = 0; - virtual void rename( const QString &name ) = 0; - virtual void setDescription( const QString &description ) = 0; - virtual void removeFromDb() = 0; - -}; - -Q_DECLARE_METATYPE( BookmarkViewItemPtr ) - -#endif diff --git a/amarok/src/amarokurls/ContextUrlGenerator.cpp b/amarok/src/amarokurls/ContextUrlGenerator.cpp deleted file mode 100644 index f0c0165d..00000000 --- a/amarok/src/amarokurls/ContextUrlGenerator.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 Pulic License for more details. * - * * - * You should have received a copy of the GNU General Public License along with * - * this program. If not, see . * - ****************************************************************************************/ - -#include "ContextUrlGenerator.h" - -#include "AmarokUrl.h" -#include "AmarokUrlHandler.h" -#include "context/ContextView.h" - -#include - - -ContextUrlGenerator * ContextUrlGenerator::s_instance = 0; - -ContextUrlGenerator * ContextUrlGenerator::instance() -{ - if( s_instance == 0 ) - s_instance = new ContextUrlGenerator(); - - return s_instance; -} - -ContextUrlGenerator::ContextUrlGenerator() -{ -} - -ContextUrlGenerator::~ContextUrlGenerator() -{ - The::amarokUrlHandler()->unRegisterGenerator( this ); -} - -AmarokUrl -ContextUrlGenerator::createContextBookmark() -{ - QStringList pluginNames = Context::ContextView::self()->currentApplets(); - QStringList appletNames = Context::ContextView::self()->currentAppletNames(); - - AmarokUrl url; - - url.setCommand( "context" ); - url.setArg( "applets", pluginNames.join( "," ) ); - - url.setName( i18n( "Context: %1", appletNames.join( "," ) ) ); - - return url; -} - - -QString -ContextUrlGenerator::description() -{ - return i18n( "Bookmark Context View Applets" ); -} - -KIcon ContextUrlGenerator::icon() -{ - return KIcon( "x-media-podcast-amarok" ); -} - -AmarokUrl -ContextUrlGenerator::createUrl() -{ - return createContextBookmark(); -} diff --git a/amarok/src/amarokurls/ContextUrlGenerator.h b/amarok/src/amarokurls/ContextUrlGenerator.h deleted file mode 100644 index 8c7d064f..00000000 --- a/amarok/src/amarokurls/ContextUrlGenerator.h +++ /dev/null @@ -1,45 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 Pulic License for more details. * - * * - * You should have received a copy of the GNU General Public License along with * - * this program. If not, see . * - ****************************************************************************************/ - - -#ifndef CONTEXTURLGENERATOR_H -#define CONTEXTURLGENERATOR_H - -#include "AmarokUrlGenerator.h" - -class AmarokUrl; - -class ContextUrlGenerator : public AmarokUrlGenerator -{ -public: - - static ContextUrlGenerator * instance(); - - AmarokUrl createContextBookmark(); - - QString description(); - KIcon icon(); - AmarokUrl createUrl(); - -private: - ContextUrlGenerator(); - virtual ~ContextUrlGenerator(); - - static ContextUrlGenerator * s_instance; - -}; - -#endif // CONTEXTURLGENERATOR_H diff --git a/amarok/src/amarokurls/ContextUrlRunner.cpp b/amarok/src/amarokurls/ContextUrlRunner.cpp deleted file mode 100644 index 5c7d96c2..00000000 --- a/amarok/src/amarokurls/ContextUrlRunner.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 Pulic License for more details. * - * * - * You should have received a copy of the GNU General Public License along with * - * this program. If not, see . * - ****************************************************************************************/ - -#include "ContextUrlRunner.h" - -#include "MainWindow.h" -#include "AmarokUrlHandler.h" -#include "context/ContextView.h" - -#include - -ContextUrlRunner::ContextUrlRunner() -{} - -ContextUrlRunner::~ContextUrlRunner() -{ - The::amarokUrlHandler()->unRegisterRunner ( this ); -} - -KIcon ContextUrlRunner::icon() const -{ - return KIcon( "x-media-podcast-amarok" ); -} - -bool ContextUrlRunner::run( AmarokUrl url ) -{ - DEBUG_BLOCK - - if( url.isNull() ) - return false; - - if( url.command() != command() ) - return false; - - - QString appletsString = url.args().value( "applets" ); - debug() << "applet string: " << appletsString; - QStringList appletList = appletsString.split( ',' ); - - Context::ContextView::self()->clearNoSave(); - Context::Containment* cont = dynamic_cast< Context::Containment* >( Context::ContextView::self()->containment() ); - if( cont ) - { - foreach( const QString &appletPluginName, appletList ) - { - cont->addApplet( appletPluginName, -1 ); - } - } - - The::mainWindow()->showDock( MainWindow::AmarokDockContext ); - - return true; -} - -QString ContextUrlRunner::command() const -{ - return "context"; -} - -QString ContextUrlRunner::prettyCommand() const -{ - return i18nc( "A type of command that affects the context view", "Context" ); -} - diff --git a/amarok/src/amarokurls/ContextUrlRunner.h b/amarok/src/amarokurls/ContextUrlRunner.h deleted file mode 100644 index 1381cb43..00000000 --- a/amarok/src/amarokurls/ContextUrlRunner.h +++ /dev/null @@ -1,41 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 Pulic License for more details. * - * * - * You should have received a copy of the GNU General Public License along with * - * this program. If not, see . * - ****************************************************************************************/ - - -#ifndef CONTEXTURLRUNNER_H -#define CONTEXTURLRUNNER_H - -#include "amarok_export.h" -#include "AmarokUrlRunnerBase.h" - -class AmarokUrl; -class KIcon; -class QString; - - -class AMAROK_EXPORT ContextUrlRunner : public AmarokUrlRunnerBase -{ -public: - ContextUrlRunner(); - ~ContextUrlRunner(); - - virtual KIcon icon() const; - virtual bool run(AmarokUrl url); - virtual QString command() const; - virtual QString prettyCommand() const; -}; - -#endif // CONTEXTURLRUNNER_H diff --git a/amarok/src/amarokurls/NavigationUrlGenerator.cpp b/amarok/src/amarokurls/NavigationUrlGenerator.cpp deleted file mode 100644 index 0456976f..00000000 --- a/amarok/src/amarokurls/NavigationUrlGenerator.cpp +++ /dev/null @@ -1,264 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "NavigationUrlGenerator.h" - -#include "MainWindow.h" -#include "amarokconfig.h" -#include "amarokurls/AmarokUrl.h" -#include "amarokurls/AmarokUrlHandler.h" -#include "browsers/CollectionTreeItemModelBase.h" -#include "browsers/collectionbrowser/CollectionWidget.h" -#include "browsers/filebrowser/FileBrowser.h" -#include "browsers/playlistbrowser/PlaylistBrowser.h" -#include "browsers/servicebrowser/ServiceBrowser.h" -#include "core/support/Debug.h" -#include "core/capabilities/SourceInfoCapability.h" -#include "core-impl/collections/db/sql/SqlMeta.h" -#include "playlistmanager/PlaylistManager.h" - -NavigationUrlGenerator * NavigationUrlGenerator::s_instance = 0; - -NavigationUrlGenerator * NavigationUrlGenerator::instance() -{ - if( s_instance == 0 ) - s_instance = new NavigationUrlGenerator(); - - return s_instance; -} - -NavigationUrlGenerator::NavigationUrlGenerator() -{ -} - -NavigationUrlGenerator::~NavigationUrlGenerator() -{ - The::amarokUrlHandler()->unRegisterGenerator( this ); -} - -AmarokUrl NavigationUrlGenerator::CreateAmarokUrl() -{ - DEBUG_BLOCK - - AmarokUrl url; - url.setCommand( "navigate" ); - - //get the path - QString path = The::mainWindow()->browserDock()->list()->path(); - - QStringList pathParts = path.split( '/' ); - - //we don't use the "Home" part in navigation urls - if ( pathParts.at( 0 ) == "root list" ) - pathParts.removeFirst(); - - url.setPath( pathParts.join( "/" ) ); - - - QString filter = The::mainWindow()->browserDock()->list()->activeCategoryRecursive()->filter(); - - if ( !filter.isEmpty() ) - url.setArg( "filter", filter ); - - QList levels = The::mainWindow()->browserDock()->list()->activeCategoryRecursive()->levels(); - QString sortMode; - - foreach( CategoryId::CatMenuId level, levels ) { - switch( level ) { - case CategoryId::Genre: - sortMode += "genre-"; - break; - case CategoryId::Artist: - sortMode += "artist-"; - break; - case CategoryId::Album: - sortMode += "album-"; - break; - case CategoryId::AlbumArtist: - sortMode += "albumartist-"; - break; - case CategoryId::Composer: - sortMode += "composer-"; - break; - case CategoryId::Year: - sortMode += "year-"; - break; - default: - break; - } - } - - //we have left a trailing '-' in there, get rid of it! - if ( sortMode.size() > 0 ) - sortMode = sortMode.left( sortMode.size() - 1 ); - - if ( !sortMode.isEmpty() ) - url.setArg( "levels", sortMode ); - - - //if in the local collection view, also store "show covers" and "show years" - if( url.path().endsWith( "collections", Qt::CaseInsensitive ) ) - { - debug() << "bookmarking in local collection"; - - if( AmarokConfig::showAlbumArt() ) - url.setArg( "show_cover", "true" ); - else - url.setArg( "show_cover", "false" ); - - if( AmarokConfig::showYears() ) - url.setArg( "show_years", "true" ); - else - url.setArg( "show_years", "false" ); - } - - //come up with a default name for this url.. - QString name = The::mainWindow()->browserDock()->list()->activeCategoryRecursive()->prettyName(); - - //if in the file browser, also store the file path - if( url.path().endsWith( "files", Qt::CaseInsensitive ) ) - { - - //Give a proper name since it will return "/" as that is what is used in the breadcrumb. - name = i18n( "Files" ); - - FileBrowser * fileBrowser = dynamic_cast( The::mainWindow()->browserDock()->list()->activeCategory() ); - if( fileBrowser ) - { - url.setArg( "path", fileBrowser->currentDir() ); - name = i18n( "Files (%1)", fileBrowser->currentDir() ); - } - } - - url.setName( name ); - - return url; - -} - -AmarokUrl NavigationUrlGenerator::urlFromAlbum( Meta::AlbumPtr album ) -{ - AmarokUrl url; - - QScopedPointer btc( album->create() ); - if( btc ) - { - if( btc->isBookmarkable() ) { - - QString albumName = album->prettyName(); - - url.setCommand( "navigate" ); - - QString path = btc->browserName(); - if ( !btc->collectionName().isEmpty() ) - path += ( '/' + btc->collectionName() ); - url.setPath( path ); - - QString filter; - if ( btc->simpleFiltering() ) { - filter = "\"" + albumName + "\""; - } - else - { - url.setArg( "levels", "album" ); - - QString artistName; - if ( album->albumArtist() ) - artistName = album->albumArtist()->prettyName(); - - filter = "album:\"" + albumName + "\""; - if ( !artistName.isEmpty() ) - filter += ( " AND artist:\"" + artistName + "\"" ); - } - - url.setArg( "filter", filter ); - - if ( !btc->collectionName().isEmpty() ) - url.setName( i18n( "Album \"%1\" from %2", albumName, btc->collectionName() ) ); - else - url.setName( i18n( "Album \"%1\"", albumName ) ); - - } - } - - //debug() << "got url: " << url.url(); - return url; -} - -AmarokUrl NavigationUrlGenerator::urlFromArtist( Meta::ArtistPtr artist ) -{ - DEBUG_BLOCK - - AmarokUrl url; - - QScopedPointer btc( artist->create() ); - if( btc ) - { - if( btc->isBookmarkable() ) { - - QString artistName = artist->prettyName(); - - url.setCommand( "navigate" ); - - QString path = btc->browserName(); - if ( !btc->collectionName().isEmpty() ) - path += ( '/' + btc->collectionName() ); - url.setPath( path ); - - //debug() << "Path: " << url.path(); - - QString filter; - if ( btc->simpleFiltering() ) { - //for services only supporting simple filtering, do not try to set the sorting mode - filter = "\"" + artistName + "\""; - } - else - { - url.setArg( "levels", "artist-album" ); - filter = ( "artist:\"" + artistName + "\"" ); - } - - url.setArg( "filter", filter ); - - if ( !btc->collectionName().isEmpty() ) - url.setName( i18n( "Artist \"%1\" from %2", artistName, btc->collectionName() ) ); - else - url.setName( i18n( "Artist \"%1\"", artistName ) ); - - } - } - - return url; - -} - -QString -NavigationUrlGenerator::description() -{ - return i18n( "Bookmark Media Sources View" ); -} - -KIcon NavigationUrlGenerator::icon() -{ - return KIcon( "flag-amarok" ); -} - -AmarokUrl -NavigationUrlGenerator::createUrl() -{ - return CreateAmarokUrl(); -} - diff --git a/amarok/src/amarokurls/NavigationUrlGenerator.h b/amarok/src/amarokurls/NavigationUrlGenerator.h deleted file mode 100644 index 61b7d800..00000000 --- a/amarok/src/amarokurls/NavigationUrlGenerator.h +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef NAVIGATIONURLGENERATOR_H -#define NAVIGATIONURLGENERATOR_H - -#include "amarok_export.h" -#include "AmarokUrlGenerator.h" -#include "core/meta/forward_declarations.h" - -class AmarokUrl; - -/** -A class used to generate navigation urls. - - @author Nikolaj Hald Nielsen -*/ -class AMAROK_EXPORT NavigationUrlGenerator : public AmarokUrlGenerator -{ -public: - - static NavigationUrlGenerator * instance(); - - AmarokUrl CreateAmarokUrl(); - - AmarokUrl urlFromAlbum( Meta::AlbumPtr album ); - AmarokUrl urlFromArtist( Meta::ArtistPtr artist ); - - QString description(); - KIcon icon(); - AmarokUrl createUrl(); - -private: - NavigationUrlGenerator(); - virtual ~NavigationUrlGenerator(); - - static NavigationUrlGenerator * s_instance; - -}; - -#endif diff --git a/amarok/src/amarokurls/NavigationUrlRunner.cpp b/amarok/src/amarokurls/NavigationUrlRunner.cpp deleted file mode 100644 index bde18e5c..00000000 --- a/amarok/src/amarokurls/NavigationUrlRunner.cpp +++ /dev/null @@ -1,138 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "NavigationUrlRunner.h" - -#include "MainWindow.h" -#include "amarokconfig.h" -#include "amarokurls/AmarokUrlHandler.h" -#include "browsers/CollectionTreeItemModelBase.h" -#include "browsers/collectionbrowser/CollectionWidget.h" -#include "browsers/filebrowser/FileBrowser.h" -#include "browsers/playlistbrowser/PlaylistBrowser.h" -#include "browsers/servicebrowser/ServiceBrowser.h" -#include "core/support/Debug.h" -#include "playlistmanager/PlaylistManager.h" -#include "services/ServiceBase.h" - -NavigationUrlRunner::NavigationUrlRunner() - : AmarokUrlRunnerBase() -{} - - -NavigationUrlRunner::~NavigationUrlRunner() -{ - The::amarokUrlHandler()->unRegisterRunner( this ); -} - -bool -NavigationUrlRunner::run( AmarokUrl url ) -{ - DEBUG_BLOCK; - - //get to the correct category - debug() << "Navigate to path: " << url.path(); - The::mainWindow()->browserDock()->list()->navigate( url.path() ); - - BrowserCategory * active = The::mainWindow()->browserDock()->list()->activeCategoryRecursive(); - - QMap args = url.args(); - - if ( args.keys().contains( "levels" ) ) - { - QString levelsString = args.value( "levels" ); - QList levels; - - QStringList levelsStringList = levelsString.split( '-' ); - - foreach( const QString &levelString, levelsStringList ) { - if( levelString == "genre" ) - levels.append( CategoryId::Genre ); - else if( levelString == "artist" ) - levels.append( CategoryId::Artist ); - else if( levelString == "album" ) - levels.append( CategoryId::Album ); - else if( levelString == "albumartist" ) - levels.append( CategoryId::AlbumArtist ); - else if( levelString == "composer" ) - levels.append( CategoryId::Composer ); - else if( levelString == "year" ) - levels.append( CategoryId::Year ); - } - - active->setLevels( levels ); - - } - - - //if we are activating the local collection, check if we need to restore "show cover" and "show year" - //if in the local collection view, also store "show covers" and "show years" - if( url.path().endsWith( "collections", Qt::CaseInsensitive ) ) - { - if ( args.keys().contains( "show_cover" ) ) - { - if( args.value( "show_cover" ).compare( "true", Qt::CaseInsensitive ) == 0 ) - AmarokConfig::setShowAlbumArt( true ); - else if( args.value( "show_cover" ).compare( "false", Qt::CaseInsensitive ) == 0 ) - AmarokConfig::setShowAlbumArt( false ); - } - - if ( args.keys().contains( "show_years" ) ) - { - if( args.value( "show_years" ).compare( "true", Qt::CaseInsensitive ) == 0 ) - AmarokConfig::setShowYears( true ); - else if( args.value( "show_years" ).compare( "false", Qt::CaseInsensitive ) == 0 ) - AmarokConfig::setShowYears( false ); - } - } - - //also set the correct path if we are navigating to the file browser - if( url.path().endsWith( "files", Qt::CaseInsensitive ) ) - { - FileBrowser * fileBrowser = dynamic_cast( The::mainWindow()->browserDock()->list()->activeCategory() ); - if( fileBrowser ) - { - if( args.keys().contains( "path" ) ) - { - fileBrowser->setDir( args.value( "path" ) ); - } - } - } - - if ( args.keys().contains( "filter" ) ) - active->setFilter( QUrl::fromPercentEncoding(args.value( "filter" ).toUtf8()) ); - - The::mainWindow()->showDock( MainWindow::AmarokDockNavigation ); - - return true; -} - -QString NavigationUrlRunner::command() const -{ - return "navigate"; -} - -QString NavigationUrlRunner::prettyCommand() const -{ - return i18nc( "A type of command that affects the view in the browser category", "Navigate" ); -} - -KIcon NavigationUrlRunner::icon() const -{ - return KIcon( "flag-amarok" ); -} - - diff --git a/amarok/src/amarokurls/NavigationUrlRunner.h b/amarok/src/amarokurls/NavigationUrlRunner.h deleted file mode 100644 index 54a49ede..00000000 --- a/amarok/src/amarokurls/NavigationUrlRunner.h +++ /dev/null @@ -1,39 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef NAVIGATIONURLRUNNER_H -#define NAVIGATIONURLRUNNER_H - -#include "AmarokUrl.h" -#include "AmarokUrlRunnerBase.h" - -#include - - -class NavigationUrlRunner : public AmarokUrlRunnerBase -{ -public: - NavigationUrlRunner(); - - virtual ~NavigationUrlRunner(); - - virtual QString command() const; - virtual QString prettyCommand() const; - virtual KIcon icon() const; - virtual bool run( AmarokUrl url ); -}; - -#endif diff --git a/amarok/src/amarokurls/PlayUrlGenerator.cpp b/amarok/src/amarokurls/PlayUrlGenerator.cpp deleted file mode 100644 index 16841ee4..00000000 --- a/amarok/src/amarokurls/PlayUrlGenerator.cpp +++ /dev/null @@ -1,116 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Casey Link * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "PlayUrlGenerator.h" - -#include "AmarokUrl.h" -#include "AmarokUrlHandler.h" -#include "core/meta/Meta.h" -#include "core/meta/support/MetaUtility.h" -#include "core/support/Debug.h" -#include "EngineController.h" -#include "BookmarkModel.h" - -#include - -PlayUrlGenerator * PlayUrlGenerator::s_instance = 0; - -PlayUrlGenerator * PlayUrlGenerator::instance() -{ - if( s_instance == 0) - s_instance = new PlayUrlGenerator(); - - return s_instance; -} - -PlayUrlGenerator::PlayUrlGenerator() -{ -} - - -PlayUrlGenerator::~PlayUrlGenerator() -{ - The::amarokUrlHandler()->unRegisterGenerator( this ); -} - -AmarokUrl -PlayUrlGenerator::createCurrentTrackBookmark() -{ - Meta::TrackPtr track = The::engineController()->currentTrack(); - const qint64 miliseconds = The::engineController()->trackPositionMs(); - - return createTrackBookmark( track, miliseconds ); -} - -AmarokUrl -PlayUrlGenerator::createTrackBookmark( Meta::TrackPtr track, qint64 miliseconds, QString name ) -{ - DEBUG_BLOCK - - const int seconds = miliseconds / 1000; - const qreal accurateSeconds = (qreal) miliseconds / 1000.0; - QString secondsString = QString::number( accurateSeconds ); - - AmarokUrl url; - if( !track ) - return url; - - const QString trackUrl = track->playableUrl().toEncoded().toBase64(); - url.setCommand( "play" ); - url.setPath( trackUrl ); - url.setArg( "pos", secondsString ); - - if( name.isEmpty() ) - url.setName( track->prettyName() + " - " + Meta::secToPrettyTime( seconds ) ); - else - url.setName( name + " - " + Meta::secToPrettyTime( seconds ) ); - - debug() << "concocted url: " << url.url(); - debug() << "pos: " << accurateSeconds; - return url; -} - -void -PlayUrlGenerator::moveTrackBookmark( Meta::TrackPtr track, qint64 newMiliseconds, QString name ) -{ - qreal seconds = qreal ( newMiliseconds ) / 1000; - QString trackPosition; - trackPosition.setNum( seconds ); - - QString trackName = track->prettyName(); - QString newName = ( trackName + " - " + Meta::msToPrettyTime( newMiliseconds ) ); - - BookmarkModel::instance()->setBookmarkArg( name, "pos", trackPosition ); - BookmarkModel::instance()->renameBookmark( name, newName ); -} - -QString -PlayUrlGenerator::description() -{ - return i18n( "Bookmark Track Position" ); -} - -KIcon PlayUrlGenerator::icon() -{ - return KIcon( "x-media-podcast-amarok" ); -} - -AmarokUrl -PlayUrlGenerator::createUrl() -{ - return createCurrentTrackBookmark(); -} - diff --git a/amarok/src/amarokurls/PlayUrlGenerator.h b/amarok/src/amarokurls/PlayUrlGenerator.h deleted file mode 100644 index edb9e6ca..00000000 --- a/amarok/src/amarokurls/PlayUrlGenerator.h +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Casey Link * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef PLAYURLGENERATOR_H -#define PLAYURLGENERATOR_H - -#include "amarok_export.h" -#include "AmarokUrlGenerator.h" -#include "core/meta/forward_declarations.h" - -#include - -class AmarokUrl; - -/** - * A class used to generate and modify amarok://play/ urls. - * - * The format of a 'play' amarokurl is: - * amarok://play// - */ -class AMAROK_EXPORT PlayUrlGenerator : public AmarokUrlGenerator -{ -public: - - static PlayUrlGenerator * instance(); - - AmarokUrl createCurrentTrackBookmark(); - AmarokUrl createTrackBookmark( Meta::TrackPtr track, qint64 miliseconds, QString name = QString() ); - - /** - * Updates the position of the bookmark named @param name to @param newMiliseconds - * for the track @param track. - * - * The name should be a valid bookmark name and should include the trailing "- mm:ss". - * Bookmark is renamed according to track title and new position, too. - */ - void moveTrackBookmark( Meta::TrackPtr track, qint64 newMiliseconds, QString name ); - - QString description(); - KIcon icon(); - AmarokUrl createUrl(); - -private: - PlayUrlGenerator(); - ~PlayUrlGenerator(); - - static PlayUrlGenerator * s_instance; -}; - -#endif // PLAYURLGENERATOR_H diff --git a/amarok/src/amarokurls/PlayUrlRunner.cpp b/amarok/src/amarokurls/PlayUrlRunner.cpp deleted file mode 100644 index 3bce2580..00000000 --- a/amarok/src/amarokurls/PlayUrlRunner.cpp +++ /dev/null @@ -1,124 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Casey Link * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "PlayUrlRunner.h" - -#include "core/support/Debug.h" -#include "amarokconfig.h" -#include "AmarokUrl.h" -#include "AmarokUrlHandler.h" -#include "core-impl/storage/StorageManager.h" -#include "core-impl/collections/support/CollectionManager.h" -#include "EngineController.h" -#include "playlist/PlaylistController.h" -#include "playlist/PlaylistModelStack.h" -#include "playlist/proxymodels/AbstractModel.h" -#include -#include "core/meta/Meta.h" - -PlayUrlRunner::PlayUrlRunner() : AmarokUrlRunnerBase() -{ -} - -PlayUrlRunner::~PlayUrlRunner() -{ - The::amarokUrlHandler()->unRegisterRunner ( this ); -} - -bool PlayUrlRunner::run ( AmarokUrl url ) -{ - DEBUG_BLOCK - if ( url.isNull() ) - return false; - - QUrl track_url = QUrl::fromEncoded ( QByteArray::fromBase64 ( url.path().toUtf8() ) ); - debug() << "decoded track url: " << track_url.toString(); - - //get the position - qint64 pos = 0; - if ( url.args().keys().contains( "pos" ) ) - { - pos = (qint64) ( url.args().value( "pos" ).toDouble() * 1000.0 ); - } - - debug() << "seek pos: " << pos; - Meta::TrackPtr track = CollectionManager::instance()->trackForUrl( track_url ); - if ( !track ) - return false; - - The::engineController()->play ( track, pos ); - - Playlist::AbstractModel *model = The::playlist(); - - int row = model->firstRowForTrack( track ); - if( row != -1 ) - model->setActiveRow( row ); - else - { - row = AmarokConfig::dynamicMode() ? model->activeRow() + 1 : model->qaim()->rowCount(); - The::playlistController()->insertTrack( row, track ); - model->setActiveRow( row ); - } - - return true; -} - -QString PlayUrlRunner::command() const -{ - return "play"; -} - -QString PlayUrlRunner::prettyCommand() const -{ - return i18nc( "A type of command that starts playing at a specific position in a track", "Play" ); -} - -BookmarkList PlayUrlRunner::bookmarksFromUrl( KUrl url ) -{ - BookmarkList list; - - //See PlayUrlGenerator for the description of a 'play' amarokurl - QString track_encoded = url.toEncoded().toBase64(); - - // The last character of a base64 encoded string is always '=', which - // chokes the SQL. Since we are using a substring like text comparison - // and every url in the database will have the '=', just chop it off. - - // some tracks even seem to have multiple '='s at the end... chop them all off! - while( track_encoded.endsWith( '=' ) ) - track_encoded.chop ( 1 ); - - // Queries the database for bookmarks where the url field contains - // the base64 encoded url (minus the '='). - QString query = "SELECT id, parent_id, name, url, description, custom FROM bookmarks WHERE url LIKE '%%1%'"; - query = query.arg ( track_encoded ); - QStringList result = StorageManager::instance()->sqlStorage()->query ( query ); - - int resultRows = result.count() / 6; - - for ( int i = 0; i < resultRows; i++ ) - { - QStringList row = result.mid ( i*6, 6 ); - list << AmarokUrlPtr ( new AmarokUrl ( row ) ); - } - return list; -} - -KIcon PlayUrlRunner::icon() const -{ - return KIcon( "x-media-podcast-amarok" ); -} - diff --git a/amarok/src/amarokurls/PlayUrlRunner.h b/amarok/src/amarokurls/PlayUrlRunner.h deleted file mode 100644 index fb9800ca..00000000 --- a/amarok/src/amarokurls/PlayUrlRunner.h +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Casey Link * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef PLAYURLRUNNER_H -#define PLAYURLRUNNER_H - -#include "amarok_export.h" -#include "AmarokUrlRunnerBase.h" - -#include -/** - * The Runner that handles urls that plays tracks. - * @author Casey Link - */ -class AMAROK_EXPORT PlayUrlRunner : public AmarokUrlRunnerBase -{ -public: - PlayUrlRunner (); - - virtual ~PlayUrlRunner (); - - virtual QString command () const; - virtual QString prettyCommand() const; - virtual bool run ( AmarokUrl url ); - virtual KIcon icon () const; - - /** - * This function takes a url for a track, and returns a list - * of bookmarks (represented by play amarokurls) for the track. - * The definition of a play amarokurl is in PlayUrlGenerator - * - * @param url the playableUrl() of a Meta::Track - * @return a list of bookmarks. the list is empty if no bookmarks exist. - * @see PlayUrlGenerator - */ - static BookmarkList bookmarksFromUrl( KUrl url ); - -}; - -#endif // PLAYURLRUNNER_H diff --git a/amarok/src/amarokurls/amarok.protocol b/amarok/src/amarokurls/amarok.protocol deleted file mode 100644 index 502ffdb2..00000000 --- a/amarok/src/amarokurls/amarok.protocol +++ /dev/null @@ -1,11 +0,0 @@ -[Protocol] -exec=amarok "%u" -protocol=amarok -input=none -output=none -helper=true -listing= -reading=false -writing=false -makedir=false -deleting=false diff --git a/amarok/src/amarokurls/test_urls.html b/amarok/src/amarokurls/test_urls.html deleted file mode 100644 index 9c87c6a8..00000000 --- a/amarok/src/amarokurls/test_urls.html +++ /dev/null @@ -1,45 +0,0 @@ - - - Services

- amarok://navigate/internet -
- amarok://navigate/service/Magnatune.com -
- amarok://navigate/service/Magnatune.com/artist-album -
- amarok://navigate/service/Magnatune.com//Artist:"Brad Sucks" -
- amarok://navigate/service/Magnatune.com/genre-artist/ -
- amarok://navigate/service/Magnatune.com/artist-album/Artist:"Brad Sucks" -

- amarok://navigate/service/Librivox.org -
- amarok://navigate/service/Librivox.org//Jules Verne -

- amarok://navigate/service/DummyService -

Collections

- amarok://navigate/collection -
- amarok://navigate/collection/sql//"John Wesley" -
- amarok://navigate/collection/sql/artist/"John Wesley -

Playlists

- amarok://navigate/playlists -
- amarok://navigate/playlists/dynamic category -
-

Escape Test

- amarok://navigate/service/Magnatune.com/album/album:%22Handshake%20Smiles%22%20AND%20artist:%22Arthur%20Yoria%22' -

Magnatune stuff

- amarok://service_magnatune/show_favorites
- amarok://service_magnatune/show_home - amarok://service_magnatune/purchase/blinddivine-queen -

Broken stuff ( must not crash )

- amarok://navidfgate/collection -
- amarok://navigate/colljection/sql//"John Wesley" -
- amarok://navigate/collection/sqlh/arhtist/"John Wesley - - diff --git a/amarok/src/app_mac.cpp b/amarok/src/app_mac.cpp deleted file mode 100644 index 0fce03b7..00000000 --- a/amarok/src/app_mac.cpp +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Benjamin Reed * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include - -#include "amarokurls/AmarokUrl.h" -#include "core-impl/collections/support/CollectionManager.h" -#include "core/support/Debug.h" -#include "core-impl/support/TrackLoader.h" -#include "core/meta/Meta.h" -#include "core/playlists/Playlist.h" -#include "core-impl/playlists/types/file/PlaylistFileSupport.h" -#include "playlist/PlaylistController.h" - - - -#include - -#include - -static AEEventHandlerUPP appleEventProcessorUPP = 0; -static AEEventHandlerUPP macCallbackUrlHandlerUPP = 0; - -OSStatus -appleEventProcessor(const AppleEvent *ae, AppleEvent *, long /*handlerRefCon*/) -{ - OSType aeID = typeWildCard; - OSType aeClass = typeWildCard; - AEGetAttributePtr(ae, keyEventClassAttr, typeType, 0, &aeClass, sizeof(aeClass), 0); - AEGetAttributePtr(ae, keyEventIDAttr, typeType, 0, &aeID, sizeof(aeID), 0); - - if(aeClass == kCoreEventClass) - { - if(aeID == kAEReopenApplication) - { -#if 0 - if( PlaylistWindow::self() ) - PlaylistWindow::self()->show(); -#endif - } - return noErr; - } - return eventNotHandledErr; -} - -OSStatus -macCallbackUrlHandler( const AppleEvent *ae, AppleEvent *, long /*handlerRefCon*/) -{ - DEBUG_BLOCK - OSErr error = noErr; - Size actualSize = 0; - DescType descType = typeUTF8Text; - if( ( error = AESizeOfParam( ae, keyDirectObject, &descType, &actualSize ) ) == noErr ) - { - QByteArray ba; - ba.resize( actualSize + 1 ); - error = AEGetParamPtr( ae, keyDirectObject, typeUTF8Text, 0, ba.data(), actualSize, &actualSize ); - if( error == noErr ) - { - KUrl url( QString::fromUtf8( ba.data() ) ); - if( url.protocol() == "amarok" ) - { - AmarokUrl aUrl( url.url() ); - aUrl.run(); - } else - { - TrackLoader *loader = new TrackLoader(); - // FIXME: this has no effect, one has to connect to finished() signal - loader->init( url ); - } - } - } - return error; -} - -void -setupEventHandler_mac(SRefCon handlerRef) -{ - appleEventProcessorUPP = AEEventHandlerUPP(appleEventProcessor); - AEInstallEventHandler(kCoreEventClass, kAEReopenApplication, appleEventProcessorUPP, handlerRef, true); - macCallbackUrlHandlerUPP = AEEventHandlerUPP(macCallbackUrlHandler); - AEInstallEventHandler(kInternetEventClass, kAEGetURL, macCallbackUrlHandlerUPP, handlerRef, false); -} - diff --git a/amarok/src/browsers/BrowserBreadcrumbItem.cpp b/amarok/src/browsers/BrowserBreadcrumbItem.cpp deleted file mode 100644 index b33d6f74..00000000 --- a/amarok/src/browsers/BrowserBreadcrumbItem.cpp +++ /dev/null @@ -1,174 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "BrowserBreadcrumbItem.h" - -#include "browsers/BrowserCategoryList.h" -#include "browsers/filebrowser/FileBrowser.h" -#include "core/support/Debug.h" -#include "widgets/BreadcrumbItemButton.h" - -#include -#include - -#include -#include - -BrowserBreadcrumbItem::BrowserBreadcrumbItem( BrowserCategory *category, QWidget *parent ) - : KHBox( parent ) - , m_menuButton( 0 ) -{ - //figure out if we want to add a menu to this item. A menu allows you to select - //any of the _sibling_ items. (yes, I know, this is different from how Dolphin - //does it, but I find the Dolphin way amazingly unintuitive and I always get it - //wrong when using it...) - - BrowserCategoryList * parentList = category->parentList(); - if( parentList ) - { - m_menuButton = new BreadcrumbItemMenuButton( this ); - QMenu *menu = new QMenu( this ); //see QMenu docs: it's still a top-level widget. - //parent is only for memory management. - QMap siblingMap = parentList->categories(); - - QStringList siblingNames = siblingMap.keys(); - - foreach( const QString &siblingName, siblingNames ) - { - //no point in adding ourselves to this menu - if ( siblingName == category->name() ) - continue; - - BrowserCategory *siblingCategory = siblingMap.value( siblingName ); - - QAction *action = menu->addAction( siblingCategory->icon(), siblingCategory->prettyName() ); - connect( action, SIGNAL(triggered()), siblingMap.value( siblingName ), SLOT(activate()) ); - } - - m_menuButton->setMenu( menu ); - } - - m_mainButton = new BreadcrumbItemButton( category->icon(), category->prettyName(), this ); - - if( category->prettyName().isEmpty() ) - { - // root item - m_mainButton->setToolTip( i18n( "Media Sources Home" ) ); - m_mainButton->setIcon( KIcon( "user-home" ) ); - } - - connect( m_mainButton, SIGNAL(sizePolicyChanged()), this, SLOT(updateSizePolicy()) ); - - //if this is a list, make cliking on this item cause us - //to navigate to its home. - BrowserCategoryList *list = qobject_cast( category ); - if ( list ) - { - connect( m_mainButton, SIGNAL(clicked(bool)), list, SLOT(home()) ); - } - else - { - connect( m_mainButton, SIGNAL(clicked(bool)), category, SLOT(reActivate()) ); - } - - adjustSize(); - m_nominalWidth = width(); - - hide(); - - updateSizePolicy(); -} - -BrowserBreadcrumbItem::BrowserBreadcrumbItem( const QString &name, const QString &callback, - const BreadcrumbSiblingList &childItems, FileBrowser *handler, QWidget *parent ) - : KHBox( parent ) - , m_menuButton( 0 ) - , m_callback( callback ) -{ - if ( !childItems.isEmpty() ) - { - m_menuButton = new BreadcrumbItemMenuButton( this ); - QMenu *menu = new QMenu( this ); - - int i = 0; - foreach( const BreadcrumbSibling &sibling, childItems ) - { - QString visibleName = sibling.name; - visibleName.replace( '&', "&&" ); // prevent bug 244817 - QAction *action = menu->addAction( sibling.icon, visibleName ); - action->setProperty( "callback", sibling.callback ); - - // the current action should be bolded - if( sibling.name == name ) - { - QFont font = action->font(); - font.setBold( true ); - action->setFont( font ); - } - connect( action, SIGNAL(triggered()), this, SLOT(activateSibling()) ); - i++; - } - m_menuButton->setMenu( menu ); - } - - m_mainButton = new BreadcrumbItemButton( name, this ); - connect( m_mainButton, SIGNAL(sizePolicyChanged()), this, SLOT(updateSizePolicy()) ); - connect( m_mainButton, SIGNAL(clicked(bool)), this, SLOT(activate()) ); - connect( this, SIGNAL(activated(QString)), handler, SLOT(addItemActivated(QString)) ); - - adjustSize(); - m_nominalWidth = width(); - - hide(); - updateSizePolicy(); -} - -BrowserBreadcrumbItem::~BrowserBreadcrumbItem() -{ -} - -void -BrowserBreadcrumbItem::setActive( bool active ) -{ - m_mainButton->setActive( active ); -} - -QSizePolicy BrowserBreadcrumbItem::sizePolicy() const -{ - return m_mainButton->sizePolicy(); -} - -void BrowserBreadcrumbItem::updateSizePolicy() -{ - setSizePolicy( m_mainButton->sizePolicy() ); -} - -void BrowserBreadcrumbItem::activate() -{ - emit activated( m_callback ); -} - -void BrowserBreadcrumbItem::activateSibling() -{ - QAction *action = qobject_cast( sender() ); - if( action ) - emit activated( action->property( "callback" ).toString() ); -} - -int BrowserBreadcrumbItem::nominalWidth() const -{ - return m_nominalWidth; -} diff --git a/amarok/src/browsers/BrowserBreadcrumbItem.h b/amarok/src/browsers/BrowserBreadcrumbItem.h deleted file mode 100644 index 98b08af6..00000000 --- a/amarok/src/browsers/BrowserBreadcrumbItem.h +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef BROWSERBREADCRUMBITEM_H -#define BROWSERBREADCRUMBITEM_H - -#include - -#include - -class FileBrowser; -class BrowserCategory; -class BreadcrumbItemButton; -class BreadcrumbItemMenuButton; - -struct BreadcrumbSibling { - BreadcrumbSibling( const QIcon &icon_, const QString &name_, const QString &callback_ ) - : icon( icon_ ), name( name_ ), callback( callback_ ) {} - - QIcon icon; - QString name; - QString callback; -}; -typedef QList BreadcrumbSiblingList; - -/** - * A widget representing a single "breadcrumb" item - * It has a mainButton and optionally a menuButton - * - * @author Nikolaj Hald Nielsen - */ - -class BrowserBreadcrumbItem : public KHBox -{ - Q_OBJECT -public: - BrowserBreadcrumbItem( BrowserCategory* category, QWidget* parent = 0 ); - - /** - * Overloaded constructor for creating breadcrumb items not bound to a particular BrowserCategory - */ - BrowserBreadcrumbItem( const QString &name, const QString &callback, - const BreadcrumbSiblingList &childItems, FileBrowser *handler, - QWidget *parent = 0 ); - ~BrowserBreadcrumbItem(); - - void setActive( bool active ); - - QSizePolicy sizePolicy () const; - - int nominalWidth() const; - -signals: - - void activated( const QString &callback ); - -protected slots: - void updateSizePolicy(); - void activate(); - void activateSibling(); - -private: - BreadcrumbItemMenuButton *m_menuButton; - BreadcrumbItemButton *m_mainButton; - - QString m_callback; - int m_nominalWidth; -}; - -#endif diff --git a/amarok/src/browsers/BrowserBreadcrumbWidget.cpp b/amarok/src/browsers/BrowserBreadcrumbWidget.cpp deleted file mode 100644 index 1b1eb6fe..00000000 --- a/amarok/src/browsers/BrowserBreadcrumbWidget.cpp +++ /dev/null @@ -1,240 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "BrowserBreadcrumbWidget" - -#include "BrowserBreadcrumbWidget.h" - -#include "amarokurls/AmarokUrl.h" -#include "BrowserBreadcrumbItem.h" -#include "BrowserCategoryList.h" -#include "browsers/filebrowser/FileBrowser.h" -#include "MainWindow.h" -#include "widgets/BreadcrumbItemButton.h" - -#include - -#include -#include -#include - -BrowserBreadcrumbWidget::BrowserBreadcrumbWidget( QWidget * parent ) - : KHBox( parent) - , m_rootList( 0 ) - , m_childMenuButton( 0 ) -{ - setFixedHeight( 28 ); - setContentsMargins( 3, 0, 3, 0 ); - setSpacing( 0 ); - - m_breadcrumbArea = new KHBox( this ); - m_breadcrumbArea->setContentsMargins( 0, 0, 0, 0 ); - m_breadcrumbArea->setSpacing( 0 ); - setStretchFactor( m_breadcrumbArea, 10 ); - - new BreadcrumbUrlMenuButton( "navigate", this ); - - m_spacer = new QWidget( 0 ); -} - -BrowserBreadcrumbWidget::~BrowserBreadcrumbWidget() -{ - clearCrumbs(); -} - -void -BrowserBreadcrumbWidget::clearCrumbs() -{ - foreach( BrowserBreadcrumbItem *item, m_items ) - { - item->hide(); - item->deleteLater(); - } - m_items.clear(); - - //if we have a final menu button, also delete it. - delete m_childMenuButton; - m_childMenuButton = 0; -} - -void -BrowserBreadcrumbWidget::setRootList( BrowserCategoryList * rootList ) -{ - m_rootList = rootList; - - //update the breadcrumbs every time the view changes. - connect( m_rootList, SIGNAL(viewChanged()), this, SLOT(updateBreadcrumbs()) ); - - updateBreadcrumbs(); -} - -void -BrowserBreadcrumbWidget::updateBreadcrumbs() -{ - if( !m_rootList ) - return; - - clearCrumbs(); - m_spacer->setParent( 0 ); - - addLevel( m_rootList ); - m_spacer->setParent( m_breadcrumbArea ); - - showAsNeeded(); -} - -void -BrowserBreadcrumbWidget::addLevel( BrowserCategoryList *list ) -{ - BrowserBreadcrumbItem *item = list->breadcrumb(); - addBreadCrumbItem( item ); - m_items.append( item ); - - BrowserCategory *childCategory = list->activeCategory(); - - if( childCategory ) - { - item->setActive( false ); - - //check if this is also a list - BrowserCategoryList *childList = qobject_cast( childCategory ); - if( childList ) - { - addLevel( childList ); - } - else - { - BrowserBreadcrumbItem *leaf = childCategory->breadcrumb(); - addBreadCrumbItem( leaf ); - m_items.append( leaf ); - - const QList additionalItems = childCategory->additionalItems(); - //no children, but check if there are additional breadcrumb levels (for internal navigation in the category) that should be added anyway. - foreach( BrowserBreadcrumbItem *addItem, additionalItems ) - { - //hack to ensure that we have not already added it to the front of the breadcrumb... - addBreadCrumbItem( addItem ); - } - - if( !additionalItems.isEmpty() ) - additionalItems.last()->setActive( true ); - else - leaf->setActive( true ); - } - } - else - { - //if this item has children, add a menu button for selecting these. - BrowserCategoryList *childList = qobject_cast( list ); - if( childList ) - { - m_childMenuButton = new BreadcrumbItemMenuButton( m_breadcrumbArea ); - - QMenu *menu = new QMenu( item ); - menu->hide(); - - QMap childMap = childList->categories(); - - QStringList childNames = childMap.keys(); - - foreach( const QString &siblingName, childNames ) - { - //no point in adding ourselves to this menu - if ( siblingName == list->name() ) - continue; - - BrowserCategory * siblingCategory = childMap.value( siblingName ); - - QAction * action = menu->addAction( siblingCategory->icon(), siblingCategory->prettyName() ); - connect( action, SIGNAL(triggered()), childMap.value( siblingName ), SLOT(activate()) ); - - } - - m_childMenuButton->setMenu( menu ); - - //do a little magic to line up items in the menu with the current item - int offset = 6; - menu->setContentsMargins( offset, 1, 1, 2 ); - - } - item->setActive( true ); - } -} - -void -BrowserBreadcrumbWidget::addBreadCrumbItem( BrowserBreadcrumbItem *item ) -{ - item->hide(); - item->setParent( 0 ); // may be already shown, we want it to be last, so reparent - item->setParent( m_breadcrumbArea ); -} - -void BrowserBreadcrumbWidget::resizeEvent( QResizeEvent *event ) -{ - Q_UNUSED( event ) - // we need to postpone the call, because hideAsNeeded() itself may trigger resizeEvent - QTimer::singleShot( 0 , this, SLOT(showAsNeeded()) ); -} - -void BrowserBreadcrumbWidget::showAsNeeded() -{ - /* we need to check if there is enough space for all items, if not, we start hiding - * items from the left (excluding the home item) until they fit (we never hide the - * rightmost item) we also add the hidden levels to the drop down menu of the last - * item so they are accessible. - */ - - //make a temp list that includes both regular items and add items - QList allItems; - - allItems.append( m_items ); - if( m_rootList->activeCategory() ) - allItems.append( m_rootList->activeCategory()->additionalItems() ); - - // filter-out leftover items not parented to m_breadcrumbArea (bug 285712): - QMutableListIterator it( allItems ); - while( it.hasNext() ) - { - if( it.next()->parent() != m_breadcrumbArea ) - it.remove(); - } - - int sizeOfFirst = allItems.first()->nominalWidth(); - int sizeOfLast = allItems.last()->nominalWidth(); - - int spaceLeft = width() - ( sizeOfFirst + sizeOfLast + 28 ); - allItems.first()->show(); - allItems.last()->show(); - - int numberOfItems = allItems.count(); - - for( int i = numberOfItems - 2; i > 0; i-- ) - { - if( allItems.at( i )->nominalWidth() <= spaceLeft ) - { - allItems.at( i )->show(); - spaceLeft -= allItems.at( i )->nominalWidth(); - } - else - { - //set spaceLeft to 0 so no items further to the left are shown - spaceLeft = 0; - allItems.at( i )->hide(); - } - } -} - -#include "moc_BrowserBreadcrumbWidget.cpp" diff --git a/amarok/src/browsers/BrowserBreadcrumbWidget.h b/amarok/src/browsers/BrowserBreadcrumbWidget.h deleted file mode 100644 index 887941cf..00000000 --- a/amarok/src/browsers/BrowserBreadcrumbWidget.h +++ /dev/null @@ -1,116 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef BROWSERBREADCRUMBWIDGET_H -#define BROWSERBREADCRUMBWIDGET_H - -#include -#include - -#include -#include -#include -#include - -class BreadcrumbItemMenuButton; -class BrowserBreadcrumbItem; -class BrowserCategoryList; - -/** - * A widget for displaying the current state of and navigating the category dig down interface. - * - * @author Nikolaj Hald Nielsen - */ -class BrowserBreadcrumbWidget : public KHBox -{ - Q_OBJECT -public: - - /** - * Constructor - * @param parent the parent widget - */ - BrowserBreadcrumbWidget( QWidget * parent ); - - /** - * Destructor - * @param parent the parent widget - */ - ~BrowserBreadcrumbWidget(); - - /** - * Set the BrowserCategoryList which acts as the "root" of the breadcrumb widget. - * A root breadcrumb item is created that represents the lowest level, and the categories - * in the list are added to the items dropdown menu. - * @param rootList the BrowserCategoryList representing the lowest level in the navigation hirachy - */ - void setRootList( BrowserCategoryList *rootList ); - -signals: - /** - * Signal emitted when the root breadcrumb item is clicked. - */ - void toHome(); - -public slots: - /** - * Rebuild the list of breadcrumb items corrosponding to the current location in the hirachy. - * This also allows for categories that add additional breadcrumb items (such as the file browser) to update the - * breadcrumbs when their internal state changes. - */ - void updateBreadcrumbs(); - -protected: - virtual void resizeEvent( QResizeEvent * event ); - -private slots: - /** - * Goes through all breadcrumb items and shows the most relevant ones based on - * available size. (always shows home icon and the last item) - */ - void showAsNeeded(); - -private: - /** - * Remove all breadcrumb items - */ - void clearCrumbs(); - - /** - * Recursive function that traverses the tree of BrowserCategoryList's - * and adds each one as a level in the breadcrumb. - * @param level the root level BrowserCategoryList. - */ - void addLevel( BrowserCategoryList *list ); - - /** - * Helper function for addLevel() that first hides BrowserBreadcrumbItem, adds it to - * to breadcrumb area. - */ - void addBreadCrumbItem( BrowserBreadcrumbItem *item ); - - //QStringList m_currentPath; - BrowserCategoryList * m_rootList; - - QList m_items; - QWidget *m_spacer; - KHBox *m_breadcrumbArea; - - BreadcrumbItemMenuButton *m_childMenuButton; - -}; - -#endif diff --git a/amarok/src/browsers/BrowserCategory.cpp b/amarok/src/browsers/BrowserCategory.cpp deleted file mode 100644 index 138c7596..00000000 --- a/amarok/src/browsers/BrowserCategory.cpp +++ /dev/null @@ -1,181 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "BrowserCategory.h" - -#include "App.h" -#include "amarokconfig.h" -#include "BrowserBreadcrumbItem.h" -#include "BrowserCategoryList.h" -#include "PaletteHandler.h" - -#include "core/support/Debug.h" - -#include - -BrowserCategory::BrowserCategory( const QString &name, QWidget *parent ) - : KVBox( parent ) - , m_name( name ) - , m_parentList( 0 ) -{ - setObjectName( name ); - setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); - setFrameShape( QFrame::NoFrame ); - - connect( App::instance(), SIGNAL(settingsChanged()), SLOT(slotSettingsChanged()) ); - connect( The::paletteHandler(), SIGNAL(newPalette(QPalette)), SLOT(slotSettingsChanged()) ); -} - -BrowserCategory::~BrowserCategory() -{ -} - -QString -BrowserCategory::name() const -{ - return m_name; -} - -void -BrowserCategory::setPrettyName( const QString &prettyName ) -{ - m_prettyName = prettyName; -} - -QString -BrowserCategory::prettyName() const -{ - return m_prettyName; -} - -void -BrowserCategory::setShortDescription( const QString &shortDescription ) -{ - m_shortDescription = shortDescription; -} - -QString -BrowserCategory::shortDescription() const -{ - return m_shortDescription; -} - -void -BrowserCategory::setLongDescription( const QString &longDescription ) -{ - m_longDescription = longDescription; -} - -QString -BrowserCategory::longDescription() const -{ - return m_longDescription; -} - -void -BrowserCategory::setIcon( const QIcon & icon ) -{ - m_icon = icon; -} - -QIcon -BrowserCategory::icon() const -{ - return m_icon; -} - -void -BrowserCategory::setBackgroundImage(const QString& path) -{ - if ( path.isEmpty() || !KUrl(path).isLocalFile() ) { - setStyleSheet( QString() ); - return; - } - - // Hack alert: Use the class name of the most derived object (using polymorphism) for CSS - // This is required to limit the style to this specific class only (avoiding cascading) - // \sa http://doc.qt.nokia.com/latest/stylesheet-syntax.html#widgets-inside-c-namespaces - const QString escapedClassName = QString( metaObject()->className() ).replace( "::", "--" ); - setStyleSheet( QString("%1 { background-image: url(\"%2\"); \ - background-repeat: no-repeat; \ - background-attachment: fixed; \ - background-position: center; }").arg( escapedClassName, path ) - ); -} - -void BrowserCategory::slotSettingsChanged() -{ - setBackgroundImage( AmarokConfig::showBrowserBackgroundImage() ? m_imagePath : QString() ); -} - -void BrowserCategory::setParentList( BrowserCategoryList * parent ) -{ - m_parentList = parent; -} - -BrowserCategoryList * BrowserCategory::parentList() const -{ - return m_parentList; -} - -void BrowserCategory::activate() -{ - DEBUG_BLOCK - if ( parentList() ) - parentList()->setActiveCategory( this ); -} - -BrowserBreadcrumbItem *BrowserCategory::breadcrumb() -{ - return new BrowserBreadcrumbItem( this ); -} - -void BrowserCategory::setImagePath( const QString & path ) -{ - m_imagePath = path; -} - -QString BrowserCategory::imagePath() const -{ - return m_imagePath; -} - -void -BrowserCategory::addAdditionalItem( BrowserBreadcrumbItem * item ) -{ - m_additionalItems.append( item ); -} - -void -BrowserCategory::clearAdditionalItems() -{ - foreach( BrowserBreadcrumbItem *item, m_additionalItems ) - { - m_additionalItems.removeAll( item ); - /* deleting immediatelly isn't safe, this method may be called from an inner - * QEventLoop inside QMenu::exec() of another breadcrumb item, which could - * then leas to crash bug 265626 */ - item->deleteLater(); - } -} - -QList -BrowserCategory::additionalItems() -{ - return m_additionalItems; -} - -#include "moc_BrowserCategory.cpp" diff --git a/amarok/src/browsers/BrowserCategory.h b/amarok/src/browsers/BrowserCategory.h deleted file mode 100644 index 5b8fa6bf..00000000 --- a/amarok/src/browsers/BrowserCategory.h +++ /dev/null @@ -1,181 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef BROWSERCATEGORY_H -#define BROWSERCATEGORY_H - -#include "amarok_export.h" -#include "BrowserDefines.h" - -#include - -#include - -class BrowserBreadcrumbItem; -class BrowserCategoryList; - -/** - * The base class of browsers, services, categories or any other widget that can be inserted into a CategoryList - * - * @author Nikolaj Hald Nielsen -*/ -class AMAROK_EXPORT BrowserCategory : public KVBox -{ - Q_OBJECT - -public: - - /** - * Constructor. - * - * @param name The internal name of the category, used for generating Amarok urls. This should never be translated. - * @param parent The parent widget. - */ - BrowserCategory( const QString &name, QWidget *parent = 0 ); - - /** - * Destructor. - */ - ~BrowserCategory(); - - /** - * Get the internal name of this category. - * - * @return The name. - */ - QString name() const; - - /** - * Set the user visible name of this category - * @param prettyName The user visible name. - */ - void setPrettyName( const QString &prettyName ); - - /** - * Get the user visible name of this category. - * @return The name of the service. - */ - virtual QString prettyName() const; - - /** - * Set a short description string for this category. This string is used to describe the category in the category browser. - * @param shortDescription The description. - */ - void setShortDescription( const QString &shortDescription ); - - /** - * Get the short description of this category. - * @return The short description. - */ - QString shortDescription() const; - - /** - * Set a long description of the category. This is for allowing users to get more detailed info a about a category. - * @param longDescription The long description. - */ - void setLongDescription( const QString &longDescription ); - - /** - * Get the long description of this category. - * @return The long description. - */ - QString longDescription() const; - - /** - * Set the icon that will be used to identify this category. - * @param icon The icon to use. - */ - void setIcon( const QIcon &icon ); - - /** - * Get the icon of this category. - * @return The icon - */ - QIcon icon() const; - - /** - * Set the background image of this browser widget - * - * \param path Fully qualified path (e.g. looked up with KStandardDirs::locate) - */ - void setBackgroundImage( const QString &path ); - - /** - * Set the path of the imaged used in the presentation of this category. - * @param path The path of the image to use. - */ - void setImagePath( const QString &path ); - - /** - * Get the path of the image used in the presentation of this category. - * @return The path of the image. - */ - QString imagePath() const; - - BrowserCategoryList * parentList() const; - void setParentList( BrowserCategoryList * parent ); - - /** - * Returns an item that will be added to the breadcrumb widget - * if this category is selected. - * - * The caller will have to free the returned item. - */ - BrowserBreadcrumbItem* breadcrumb(); - - virtual void polish() {} - virtual void setupAddItems() {} - - //These 2 functions are forwarded to simplifiy the creation of urls - //even though they might not be needed in many cases. - virtual QString filter() const { return QString(); } - virtual QList levels() const { return QList(); } - - virtual void setFilter( const QString &filter ) { Q_UNUSED( filter ) }; - virtual void setLevels( const QList &levels ) { Q_UNUSED( levels ) }; - - /** - * Add an additional category-specific item to breadcrumbs. This BrowserCategory - * takes ownership of the item. - */ - void addAdditionalItem( BrowserBreadcrumbItem *item ); - void clearAdditionalItems(); - - QList additionalItems(); - -public slots: - void activate(); - - //Called if this category itself is re-clicked in the breadcrumb - virtual void reActivate() {} - -private slots: - void slotSettingsChanged(); - -private: - QString m_name; - QString m_prettyName; - QString m_shortDescription; - QString m_longDescription; - QIcon m_icon; - QString m_imagePath; - BrowserCategoryList * m_parentList; - - QList m_additionalItems; - -}; - -#endif diff --git a/amarok/src/browsers/BrowserCategoryList.cpp b/amarok/src/browsers/BrowserCategoryList.cpp deleted file mode 100644 index ceb04d30..00000000 --- a/amarok/src/browsers/BrowserCategoryList.cpp +++ /dev/null @@ -1,421 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "BrowserCategoryList" - -#include "BrowserCategoryList.h" - -#include "App.h" -#include "context/ContextView.h" -#include "core/support/Debug.h" -#include "InfoProxy.h" -#include "PaletteHandler.h" -#include "widgets/PrettyTreeView.h" -#include "widgets/PrettyTreeDelegate.h" -#include "widgets/SearchWidget.h" - -#include -#include - -#include -#include - -#include - -BrowserCategoryList::BrowserCategoryList( const QString &name, QWidget* parent, bool sort ) - : BrowserCategory( name, parent ) - , m_categoryListModel( new BrowserCategoryListModel( this ) ) - , m_sorting( sort ) -{ - // -- the widget stack - m_widgetStack = new QStackedWidget( this ); - - QWidget* mainWidget = new QWidget( m_widgetStack ); - QVBoxLayout* vLayout = new QVBoxLayout( mainWidget ); - mainWidget->setLayout( vLayout ); - - // -- the search widget - m_searchWidget = new SearchWidget( this, false ); - m_searchWidget->setClickMessage( i18n( "Filter Music Sources" ) ); - vLayout->addWidget( m_searchWidget ); - - connect( m_searchWidget, SIGNAL(filterChanged(QString)), SLOT(setFilter(QString)) ); - - // -- the main list view - m_categoryListView = new Amarok::PrettyTreeView(); - m_categoryListView->setFrameShape( QFrame::NoFrame ); - - m_proxyModel = new BrowserCategoryListSortFilterProxyModel( this ); - m_proxyModel->setSourceModel( m_categoryListModel ); - - m_categoryListView->setItemDelegate( new PrettyTreeDelegate( m_categoryListView ) ); - m_categoryListView->setHeaderHidden( true ); - m_categoryListView->setRootIsDecorated( false ); - m_categoryListView->setModel( m_proxyModel ); - m_categoryListView->setMouseTracking ( true ); - - if( sort ) - { - m_proxyModel->setSortRole( Qt::DisplayRole ); - m_categoryListView->setSortingEnabled( true ); - m_categoryListView->sortByColumn( 0 ); - } - - connect( m_categoryListView, SIGNAL(activated(QModelIndex)), - SLOT(categoryActivated(QModelIndex)) ); - - connect( m_categoryListView, SIGNAL(entered(QModelIndex)), - SLOT(categoryEntered(QModelIndex)) ); - - vLayout->addWidget( m_categoryListView ); - m_widgetStack->addWidget( mainWidget ); -} - -BrowserCategoryList::~BrowserCategoryList() -{ } - - -void -BrowserCategoryList::categoryActivated( const QModelIndex &index ) -{ - DEBUG_BLOCK - BrowserCategory * category = 0; - - if( index.data( CustomCategoryRoles::CategoryRole ).canConvert() ) - category = index.data( CustomCategoryRoles::CategoryRole ).value(); - else - return; - - if( category ) - { - debug() << "Show service: " << category->name(); - setActiveCategory( category ); - } -} - -void -BrowserCategoryList::home() -{ - DEBUG_BLOCK - if( activeCategory() ) - { - BrowserCategoryList *childList = qobject_cast( activeCategory() ); - if( childList ) - childList->home(); - - activeCategory()->clearAdditionalItems(); - m_widgetStack->setCurrentIndex( 0 ); - - emit( viewChanged() ); - } -} - - -QMap -BrowserCategoryList::categories() -{ - return m_categories; -} - -void -BrowserCategoryList::addCategory( BrowserCategory *category ) -{ - Q_ASSERT( category ); - - category->setParentList( this ); - - //insert service into service map - category->setParent( this ); - m_categories[category->name()] = category; - m_categoryListModel->addCategory( category ); - m_widgetStack->addWidget( category ); - - //if this is also a category list, watch it for changes as we need to report - //these down the tree - - BrowserCategoryList *childList = qobject_cast( category ); - if ( childList ) - connect( childList, SIGNAL(viewChanged()), this, SLOT(childViewChanged()) ); - - category->polish(); // service categories do an additional construction in polish - - if( m_sorting ) - { - m_proxyModel->sort( 0 ); - } - emit( viewChanged() ); -} - - -void -BrowserCategoryList::removeCategory( BrowserCategory *category ) -{ - Q_ASSERT( category ); - - if( m_widgetStack->indexOf( category ) == -1 ) - return; // no such category - - if( m_widgetStack->currentWidget() == category ) - home(); - - m_categories.remove( category->name() ); - m_categoryListModel->removeCategory( category ); - m_widgetStack->removeWidget( category ); - delete category; - - m_categoryListView->reset(); - - emit( viewChanged() ); -} - -BrowserCategory* -BrowserCategoryList::activeCategory() const -{ - return qobject_cast(m_widgetStack->currentWidget()); -} - -void BrowserCategoryList::setActiveCategory( BrowserCategory* category ) -{ - DEBUG_BLOCK; - - if( m_widgetStack->indexOf( category ) == -1 ) - return; // no such category - - if( !category || activeCategory() == category ) - return; // nothing to do - - if( activeCategory() ) - activeCategory()->clearAdditionalItems(); - category->setupAddItems(); - - m_widgetStack->setCurrentWidget( category ); - - emit( viewChanged() ); -} - -void BrowserCategoryList::back() -{ - DEBUG_BLOCK - - BrowserCategoryList *childList = qobject_cast( activeCategory() ); - if( childList ) - { - if( childList->activeCategory() != 0 ) - { - childList->back(); - return; - } - } - - home(); -} - -void BrowserCategoryList::childViewChanged() -{ - DEBUG_BLOCK - emit( viewChanged() ); -} - -QString BrowserCategoryList::navigate( const QString & target ) -{ - DEBUG_BLOCK - debug() << "target: " << target; - QStringList categories = target.split( '/' ); - if ( categories.size() == 0 ) - return QString(); - - //remove our own name if present, before passing on... - if ( categories.at( 0 ) == name() ) - { - debug() << "removing own name (" << categories.at( 0 ) << ") from path"; - categories.removeFirst(); - - if ( categories.size() == 0 ) - { - //nothing else left, make sure this category is visible - home(); - return QString(); - } - } - - QString childName = categories.at( 0 ); - debug() << "looking for child category " << childName; - if ( !m_categories.contains( childName ) ) - return target; - - - debug() << "got it!"; - setActiveCategory( m_categories[childName] ); - - //check if this category is also BrowserCategoryList.target - BrowserCategoryList *childList = qobject_cast( activeCategory() ); - - if ( childList == 0 ) - { - debug() << "child is not a list..."; - if ( categories.size() > 1 ) - { - categories.removeFirst(); - QString leftover = categories.join( "/" ); - return leftover; - } - return QString(); - - } - - //check if there are more arguments in the navigate string. - if ( categories.size() == 1 ) - { - debug() << "Child is a list but path ends here..."; - //only one name, but since the category we switched to is also - //a category list, make sure that it is reset to home - childList->home(); - return QString(); - } - - categories.removeFirst(); - debug() << "passing remaining path to child: " << categories.join( "/" ); - return childList->navigate( categories.join( "/" ) ); - -} - -QString BrowserCategoryList::path() -{ - DEBUG_BLOCK - QString pathString = name(); - - BrowserCategoryList *childList = qobject_cast( activeCategory() ); - - if( childList ) - pathString += '/' + childList->path(); - else if( activeCategory() ) - pathString += '/' + activeCategory()->name(); - - debug() << "path: " << pathString; - return pathString; -} - -void BrowserCategoryList::categoryEntered( const QModelIndex & index ) -{ - //get the long description for this item and pass it it to info proxy. - - BrowserCategory *category = 0; - - if ( index.data( CustomCategoryRoles::CategoryRole ).canConvert() ) - category = index.data( CustomCategoryRoles::CategoryRole ).value(); - else - return; - - if( category ) - { - - //instead of just throwing out raw text, let's format the long description and the - //icon into a nice html page. - - if ( m_infoHtmlTemplate.isEmpty() ) - { - - KUrl dataUrl( KStandardDirs::locate( "data", "amarok/data/" ) ); - QString dataPath = dataUrl.path(); - - //load html - QString htmlPath = dataPath + "hover_info_template.html"; - QFile file( htmlPath ); - if ( !file.open( QIODevice::ReadOnly | QIODevice::Text) ) - { - debug() << "error opening file. Error: " << file.error(); - return; - } - m_infoHtmlTemplate = file.readAll(); - file.close(); - - m_infoHtmlTemplate.replace( "{background_color}",PaletteHandler::highlightColor().lighter( 150 ).name() ); - m_infoHtmlTemplate.replace( "{border_color}", PaletteHandler::highlightColor().lighter( 150 ).name() ); - m_infoHtmlTemplate.replace( "{text_color}", App::instance()->palette().brush( QPalette::Text ).color().name() ); - QColor highlight( App::instance()->palette().highlight().color() ); - highlight.setHsvF( highlight.hueF(), 0.3, .95, highlight.alphaF() ); - m_infoHtmlTemplate.replace( "{header_background_color}", highlight.name() ); - - } - - QString currentHtml = m_infoHtmlTemplate; - - currentHtml.replace( "%%NAME%%", category->prettyName() ); - currentHtml.replace( "%%DESCRIPTION%%", category->longDescription() ); - currentHtml.replace( "%%IMAGE_PATH%%", "file://" + category->imagePath() ); - - QVariantMap variantMap; - variantMap["main_info"] = QVariant( currentHtml ); - The::infoProxy()->setInfo( variantMap ); - } -} - -QString BrowserCategoryList::css() -{ - QString style = - ""; - - return style; -} - -BrowserCategory *BrowserCategoryList::activeCategoryRecursive() -{ - BrowserCategory *category = activeCategory(); - - if( !category ) - return this; - - BrowserCategoryList *childList = qobject_cast( category ); - if( childList ) - return childList->activeCategoryRecursive(); - - return category; -} - -void BrowserCategoryList::setFilter( const QString &filter ) -{ - m_proxyModel->setFilterFixedString( filter ); -} - -#include "moc_BrowserCategoryList.cpp" diff --git a/amarok/src/browsers/BrowserCategoryList.h b/amarok/src/browsers/BrowserCategoryList.h deleted file mode 100644 index fdc3e317..00000000 --- a/amarok/src/browsers/BrowserCategoryList.h +++ /dev/null @@ -1,154 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * Copyright (c) 2011 Ralf Engels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROKBROWSERCATEGORYLIST_H -#define AMAROKBROWSERCATEGORYLIST_H - -#include "BrowserCategory.h" -#include "BrowserCategoryListModel.h" -#include "BrowserCategoryListSortFilterProxyModel.h" - -#include - -namespace Amarok { - class PrettyTreeView; -} -class SearchWidget; - -class QStackedWidget; - -/** - * This is a browser category that can contain other sub-categories - * The main (home/root) category is such a BrowserCategoryList - * - * @author Nikolaj Hald Nielsen - */ -class BrowserCategoryList : public BrowserCategory -{ - Q_OBJECT - - public: - /** - * Constructor - * @param parent The parent widget. - * @param name The name of this widget. - */ - BrowserCategoryList( const QString& name, QWidget* parent = 0, bool sort = false ); - - /** - * Destructor. - */ - ~BrowserCategoryList(); - - /** - * Get a map of the categories. - * @return the map of categories. - */ - QMap categories(); - - BrowserCategory *activeCategory() const; - - /** - * Show a category. Hide any other active category if needed. - */ - void setActiveCategory( BrowserCategory *category ); - - /** - * Recursively navigate to a specific category. - * @param target This is a / delimited string of category names. - * This list will take the first category name, and if a child category with - * this name exists, it will switch to it. If there are are more category names - * in the target string, and the category activcated is itself a category list, - * it will strip the first category name and / from the targe string and pass - * the rest to the navigate() method of the active category list. - * - * @return this method will navigate as far as the target makes sense. Any parts - * of the target that does not match up with child categories will be returned - * as this might be additional arguments that are usable elsewhere. - */ - QString navigate( const QString &target ); - - - QString path(); - - BrowserCategory *activeCategoryRecursive(); - - signals: - void viewChanged(); - - public slots: - - /** - * Add a category. - * This category will take ownership of the new sub-category. - * @param category The category to add. - */ - void addCategory( BrowserCategory *category ); - - /** - * Remove a named category from the list and delete it. - * @param category The category to remove. - */ - void removeCategory( BrowserCategory *category ); - - - /** - * Slot called when the active category should be hidden the category selection list shown again. - */ - void home(); - - /** - * Slot called when the we need to move up one level. Forwarded to child lists as needed - */ - void back(); - - void childViewChanged(); - - private slots: - /** Sets the current filter value and updates the content */ - virtual void setFilter( const QString &filter ); - - private: - - SearchWidget *m_searchWidget; - QStackedWidget *m_widgetStack; - Amarok::PrettyTreeView *m_categoryListView; - - QMap m_categories; - - BrowserCategoryListModel *m_categoryListModel; - BrowserCategoryListSortFilterProxyModel* m_proxyModel; - - QString m_infoHtmlTemplate; - - bool m_sorting; - - private slots: - /** - * Slot called when an item in the list has been activated and the - * corrosponding category should be shown. - * @param index The index that was activated - */ - void categoryActivated( const QModelIndex &index ); - - void categoryEntered( const QModelIndex &index ); - - QString css(); -}; - - -#endif diff --git a/amarok/src/browsers/BrowserCategoryListDelegate.h b/amarok/src/browsers/BrowserCategoryListDelegate.h deleted file mode 100644 index bf8d2a41..00000000 --- a/amarok/src/browsers/BrowserCategoryListDelegate.h +++ /dev/null @@ -1,45 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * Copyright (c) 2008 Mark Kretschmann * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef BROWSERCATEGORYLISTDELEGATE_H -#define BROWSERCATEGORYLISTDELEGATE_H - -#include "SvgHandler.h" - -#include -#include -#include - - -/** A delegate for displaying a nice overview of a service */ - -class BrowserCategoryListDelegate : public QStyledItemDelegate -{ -public: - BrowserCategoryListDelegate( QTreeView *view ); - ~BrowserCategoryListDelegate(); - - void paint( QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index ) const; - QSize sizeHint( const QStyleOptionViewItem & option, const QModelIndex & index ) const; - -private: - QTreeView *m_view; - QFont m_bigFont; - QFont m_smallFont; -}; - -#endif diff --git a/amarok/src/browsers/BrowserCategoryListModel.cpp b/amarok/src/browsers/BrowserCategoryListModel.cpp deleted file mode 100644 index 724278f8..00000000 --- a/amarok/src/browsers/BrowserCategoryListModel.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "BrowserCategoryListModel.h" -#include "BrowserCategory.h" -#include "core/support/Debug.h" - -#include "widgets/PrettyTreeRoles.h" - -BrowserCategoryListModel::BrowserCategoryListModel( QObject* parent ) - : QAbstractListModel( parent ) -{ -} - -BrowserCategoryListModel::~BrowserCategoryListModel() -{ - qDeleteAll( m_categories ); -} - -int -BrowserCategoryListModel::rowCount( const QModelIndex & parent ) const -{ - Q_UNUSED( parent ); - return m_categories.count(); -} - -QVariant -BrowserCategoryListModel::data( const QModelIndex &index, int role ) const -{ - //DEBUG_BLOCK - if( !index.isValid() || m_categories.count() <= index.row() ) - return QVariant(); - - switch( role ) - { - case Qt::DisplayRole: - return QVariant( m_categories[index.row()]->prettyName() ); - - case Qt::DecorationRole: - return QVariant( m_categories[index.row()]->icon() ); - - case PrettyTreeRoles::SortRole: - case PrettyTreeRoles::ByLineRole: - return QVariant( m_categories[index.row()]->shortDescription() ); - - case Qt::ToolTipRole: - return QVariant( m_categories[index.row()]->longDescription() ); - - case CustomCategoryRoles::CategoryRole: - return qVariantFromValue( m_categories[index.row()] ); - - default: - return QVariant(); - } -} - -void -BrowserCategoryListModel::addCategory( BrowserCategory *category ) -{ - if( !category ) - { - debug() << "Trying to add a nonexistent service to the BrowserCategoryListModel!"; - return; - } - beginInsertRows ( QModelIndex(), m_categories.count(), m_categories.count() ); - m_categories.push_back( category ); - endInsertRows(); -} - -void -BrowserCategoryListModel::removeCategory( BrowserCategory *category ) -{ - if( !category ) - { - debug() << "Trying to remove a nonexistent service from the BrowserCategoryListModel!"; - return; - } - int index = m_categories.indexOf( category ); - beginRemoveRows ( QModelIndex(), index, index ); - m_categories.removeAt( index ); - endRemoveRows(); -} - diff --git a/amarok/src/browsers/BrowserCategoryListModel.h b/amarok/src/browsers/BrowserCategoryListModel.h deleted file mode 100644 index 161a7457..00000000 --- a/amarok/src/browsers/BrowserCategoryListModel.h +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef BROWSERCATEGORYLISTMODEL_H -#define BROWSERCATEGORYLISTMODEL_H - -#include - -#include - -class BrowserCategory; -Q_DECLARE_METATYPE( BrowserCategory * ) - -namespace CustomCategoryRoles -{ - enum CustomCategoryRolesId { - CategoryRole = Qt::UserRole + 31, - }; -} - -/** -A very simple model to hold the available categories - - @author Nikolaj Hald Nielsen -*/ -class BrowserCategoryListModel : public QAbstractListModel -{ -public: - BrowserCategoryListModel( QObject *parent = 0 ); - ~BrowserCategoryListModel(); - - int rowCount( const QModelIndex & parent = QModelIndex() ) const; - QVariant data( const QModelIndex & index, int role = Qt::DisplayRole ) const; - - /** - * Adds a new sub-category to this list. - * This object will take ownership of the new category. - */ - void addCategory( BrowserCategory* category ); - void removeCategory( BrowserCategory* category ); - -private: - QList m_categories; -}; - -#endif diff --git a/amarok/src/browsers/BrowserCategoryListSortFilterProxyModel.cpp b/amarok/src/browsers/BrowserCategoryListSortFilterProxyModel.cpp deleted file mode 100644 index d8d5a97c..00000000 --- a/amarok/src/browsers/BrowserCategoryListSortFilterProxyModel.cpp +++ /dev/null @@ -1,32 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Mark Kretschmann * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "BrowserCategoryListSortFilterProxyModel.h" -#include "widgets/PrettyTreeRoles.h" - -BrowserCategoryListSortFilterProxyModel::BrowserCategoryListSortFilterProxyModel( QObject *parent ) - : QSortFilterProxyModel( parent ) -{ - setSortLocaleAware( true ); - setSortCaseSensitivity( Qt::CaseInsensitive ); - setSortRole( PrettyTreeRoles::SortRole ); - - setDynamicSortFilter( true ); -} - -BrowserCategoryListSortFilterProxyModel::~BrowserCategoryListSortFilterProxyModel() -{} - diff --git a/amarok/src/browsers/BrowserCategoryListSortFilterProxyModel.h b/amarok/src/browsers/BrowserCategoryListSortFilterProxyModel.h deleted file mode 100644 index accd4ebe..00000000 --- a/amarok/src/browsers/BrowserCategoryListSortFilterProxyModel.h +++ /dev/null @@ -1,31 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Mark Kretschmann * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef BROWSERCATEGORYLISTSORTFILTERPROXYMODEL_H -#define BROWSERCATEGORYLISTSORTFILTERPROXYMODEL_H - -#include - -#include "core/meta/forward_declarations.h" - -class BrowserCategoryListSortFilterProxyModel : public QSortFilterProxyModel -{ - public: - BrowserCategoryListSortFilterProxyModel( QObject * parent = 0 ); - virtual ~BrowserCategoryListSortFilterProxyModel(); -}; - -#endif diff --git a/amarok/src/browsers/BrowserDefines.h b/amarok/src/browsers/BrowserDefines.h deleted file mode 100644 index 8e0f2585..00000000 --- a/amarok/src/browsers/BrowserDefines.h +++ /dev/null @@ -1,44 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef BROWSERDEFINES_H -#define BROWSERDEFINES_H - -#include - -namespace CategoryId -{ - /** - * Categories for collection browser levels. - * - * Beware, the numeric values get written to config files, change them only if - * you know what you're doing. - */ - enum CatMenuId { - None = 0, - Album = 1, - Artist = 8, // used to be 2, transitioned to 8 to allow for transition pre Amarok 2.8 - AlbumArtist = 3, - Composer = 4, - Genre = 5, - Year = 6, - Label = 7 - }; -} - -Q_DECLARE_METATYPE( CategoryId::CatMenuId ) - -#endif // BROWSERDEFINES_H diff --git a/amarok/src/browsers/BrowserDock.cpp b/amarok/src/browsers/BrowserDock.cpp deleted file mode 100644 index 347d2ee3..00000000 --- a/amarok/src/browsers/BrowserDock.cpp +++ /dev/null @@ -1,122 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * Copyright (c) 2009 Mark Kretschmann * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "BrowserDock.h" - -#include "core/interfaces/Logger.h" -#include "core/support/Amarok.h" -#include "core/support/Components.h" -#include "core/support/Debug.h" -#include "core-impl/logger/ProxyLogger.h" -#include "PaletteHandler.h" -#include "widgets/HorizontalDivider.h" - -#include -#include -#include - -#include - -BrowserDock::BrowserDock( QWidget *parent ) - : AmarokDockWidget( i18n( "&Media Sources" ), parent ) -{ - setObjectName( "Media Sources dock" ); - setAllowedAreas( Qt::AllDockWidgetAreas ); - - //we have to create this here as it is used when setting up the - //categories (unless of course we move that to polish as well...) - m_mainWidget = new KVBox( this ); - setWidget( m_mainWidget ); - m_mainWidget->setContentsMargins( 0, 0, 0, 0 ); - m_mainWidget->setFrameShape( QFrame::NoFrame ); - m_mainWidget->setMinimumWidth( 200 ); - m_mainWidget->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Ignored ); - m_mainWidget->setFocus( Qt::ActiveWindowFocusReason ); - - m_breadcrumbWidget = new BrowserBreadcrumbWidget( m_mainWidget ); - new HorizontalDivider( m_mainWidget ); - m_categoryList = new BrowserCategoryList( "root list", m_mainWidget ); - m_breadcrumbWidget->setRootList( m_categoryList.data() ); - - m_messageArea = new BrowserMessageArea( m_mainWidget ); - m_messageArea->setAutoFillBackground( true ); - m_messageArea->setFixedHeight( 36 ); - - Amarok::Logger *logger = Amarok::Components::logger(); - ProxyLogger *proxy = dynamic_cast( logger ); - if( proxy ) - proxy->setLogger( m_messageArea ); - else - error() << "Was not able to register BrowserDock as logger"; - - ensurePolish(); -} - -BrowserDock::~BrowserDock() -{} - -void BrowserDock::polish() -{ - m_categoryList.data()->setIcon( KIcon( "user-home" ) ); - - m_categoryList.data()->setMinimumSize( 100, 300 ); - - connect( m_breadcrumbWidget, SIGNAL(toHome()), this, SLOT(home()) ); - - // Keyboard shortcut for going back one level - KAction *action = new KAction( KIcon( "go-up" ), i18n( "Go Up in Media Sources Pane" ), - m_mainWidget ); - Amarok::actionCollection()->addAction( "browser_previous", action ); - connect( action, SIGNAL(triggered(bool)), m_categoryList.data(), SLOT(back()) ); - action->setShortcut( KShortcut( Qt::Key_Backspace ) ); - - paletteChanged( palette() ); - - connect( The::paletteHandler(), SIGNAL(newPalette(QPalette)), SLOT(paletteChanged(QPalette)) ); -} - -BrowserCategoryList *BrowserDock::list() const -{ - return m_categoryList.data(); -} - -void -BrowserDock::navigate( const QString &target ) -{ - m_categoryList.data()->navigate( target ); -} - -void -BrowserDock::home() -{ - m_categoryList.data()->home(); -} - -void -BrowserDock::paletteChanged( const QPalette &palette ) -{ - m_messageArea->setStyleSheet( - QString( "QFrame#BrowserMessageArea { border: 1px ridge %1; " \ - "background-color: %2; color: %3; border-radius: 3px; }" \ - "QLabel { color: %3; }" ) - .arg( palette.color( QPalette::Active, QPalette::Window ).name() ) - .arg( The::paletteHandler()->highlightColor().name() ) - .arg( palette.color( QPalette::Active, QPalette::HighlightedText ).name() ) - ); -} - -#include "moc_BrowserDock.cpp" diff --git a/amarok/src/browsers/BrowserDock.h b/amarok/src/browsers/BrowserDock.h deleted file mode 100644 index e0e88224..00000000 --- a/amarok/src/browsers/BrowserDock.h +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * Copyright (c) 2009 Mark Kretschmann * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef BROWSERWIDGET_H -#define BROWSERWIDGET_H - -#include "BrowserBreadcrumbWidget.h" -#include "BrowserCategoryList.h" -#include "BrowserMessageArea.h" -#include "widgets/AmarokDockWidget.h" - -#include - -#include - -/** -The base widget that contains all other browsers, organized in a dig down interface -*/ -class BrowserDock : public AmarokDockWidget -{ - Q_OBJECT - -public: - BrowserDock( QWidget *parent ); - - ~BrowserDock(); - - BrowserCategoryList *list() const; - void navigate( const QString &target ); - void polish(); - -private slots: - void home(); - void paletteChanged( const QPalette &palette ); - -private: - BrowserBreadcrumbWidget *m_breadcrumbWidget; - QWeakPointer m_categoryList; - KVBox *m_mainWidget; - BrowserMessageArea *m_messageArea; -}; - -#endif diff --git a/amarok/src/browsers/BrowserMessageArea.cpp b/amarok/src/browsers/BrowserMessageArea.cpp deleted file mode 100644 index 13e6dd34..00000000 --- a/amarok/src/browsers/BrowserMessageArea.cpp +++ /dev/null @@ -1,170 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2011 Bart Cerneels . * - ****************************************************************************************/ - -#include "BrowserMessageArea.h" - -#include "statusbar/KJobProgressBar.h" -#include "statusbar/LongMessageWidget.h" -#include "statusbar/NetworkProgressBar.h" - -#define SHORT_MESSAGE_DURATION 5000 -#define POPUP_MESSAGE_DURATION 5000 - -BrowserMessageArea::BrowserMessageArea( QWidget *parent ) - : QFrame( parent ) - , m_busy( false ) -{ - setObjectName( "BrowserMessageArea" ); - - setLayout( new QVBoxLayout( this ) ); - - m_progressBar = new CompoundProgressBar( this ); - connect( m_progressBar, SIGNAL(allDone()), this, SLOT(hideProgress()) ); - layout()->addWidget( m_progressBar ); - m_progressBar->hide(); - - m_messageLabel = new QLabel( this ); - m_messageLabel->setAlignment( Qt::AlignCenter ); - m_messageLabel->setWordWrap( true ); - layout()->addWidget( m_messageLabel ); - m_messageLabel->hide(); - - m_shortMessageTimer = new QTimer( this ); - m_shortMessageTimer->setSingleShot( true ); - connect( m_shortMessageTimer, SIGNAL(timeout()), SLOT(nextShortMessage()) ); - - //register to carry MessageType across threads - qRegisterMetaType( "MessageType" ); - connect( this, SIGNAL(signalLongMessage(QString,MessageType)), - this, SLOT(slotLongMessage(QString,MessageType)), - Qt::QueuedConnection ); -} - -void -BrowserMessageArea::shortMessage( const QString &text ) -{ - if( !m_busy ) - { - m_busy = true; - m_messageLabel->setText( text ); - m_messageLabel->show(); - m_shortMessageTimer->start( SHORT_MESSAGE_DURATION ); - } - else - { - m_shortMessageQueue.append( text ); - } -} - -void -BrowserMessageArea::longMessage( const QString &text, MessageType type ) -{ - // The purpose of this emit is to make the operation thread safe. If this - // method is called from a non-GUI thread, the "emit" relays it over the - // event loop to the GUI thread, so that we can safely create widgets. - emit signalLongMessage( text, type ); -} - -void -BrowserMessageArea::newProgressOperation( KJob *job, const QString &text, QObject *obj, - const char *slot, Qt::ConnectionType type ) -{ - KJobProgressBar *newBar = new KJobProgressBar( 0, job ); - newBar->setDescription( text ); - connect( job, SIGNAL(destroyed(QObject*)), m_progressBar, - SLOT(endProgressOperation(QObject*)) ); - newBar->setAbortSlot( obj, slot, type ); - m_progressBar->addProgressBar( newBar, job ); - m_progressBar->show(); - - m_busy = true; -} - -void -BrowserMessageArea::newProgressOperation( QNetworkReply *reply, const QString &text, QObject *obj, - const char *slot, Qt::ConnectionType type ) -{ - NetworkProgressBar *newBar = new NetworkProgressBar( 0, reply ); - newBar->setDescription( text ); - newBar->setAbortSlot( reply, SLOT(deleteLater()) ); - connect( reply, SIGNAL(destroyed(QObject*)), m_progressBar, - SLOT(endProgressOperation(QObject*)) ); - newBar->setAbortSlot( obj, slot, type ); - m_progressBar->addProgressBar( newBar, reply ); - m_progressBar->show(); - - m_busy = true; -} - -void -BrowserMessageArea::newProgressOperation( QObject *sender, const QString &text, int maximum, - QObject *obj, const char *slot, Qt::ConnectionType type ) -{ - ProgressBar *newBar = new ProgressBar( 0 ); - newBar->setDescription( text ); - newBar->setMaximum( maximum ); - connect( sender, SIGNAL(destroyed(QObject*)), m_progressBar, - SLOT(endProgressOperation(QObject*)), Qt::QueuedConnection ); - connect( sender, SIGNAL(endProgressOperation(QObject*)), m_progressBar, - SLOT(endProgressOperation(QObject*)), Qt::QueuedConnection ); - connect( sender, SIGNAL(incrementProgress()), m_progressBar, - SLOT(slotIncrementProgress()), Qt::QueuedConnection ); - connect( sender, SIGNAL(totalSteps(int)), newBar, SLOT(slotTotalSteps(int)) ); - newBar->setAbortSlot( obj, slot, type ); - m_progressBar->addProgressBar( newBar, sender ); - m_progressBar->show(); - - m_busy = true; -} - -void -BrowserMessageArea::hideProgress() //SLOT -{ - m_progressBar->hide(); - m_busy = false; - - nextShortMessage(); -} - -void -BrowserMessageArea::nextShortMessage() -{ - if( m_shortMessageQueue.count() > 0 ) - { - m_busy = true; - m_messageLabel->setText( m_shortMessageQueue.takeFirst() ); - m_messageLabel->show(); - m_shortMessageTimer->start( SHORT_MESSAGE_DURATION ); - } - else - { - m_messageLabel->hide(); - m_busy = false; - } -} - -void -BrowserMessageArea::hideLongMessage() -{ - sender()->deleteLater(); -} - -void -BrowserMessageArea::slotLongMessage( const QString &text, MessageType type ) -{ - LongMessageWidget *message = new LongMessageWidget( this, text, type ); - connect( message, SIGNAL(closed()), this, SLOT(hideLongMessage()) ); -} diff --git a/amarok/src/browsers/BrowserMessageArea.h b/amarok/src/browsers/BrowserMessageArea.h deleted file mode 100644 index bd98a676..00000000 --- a/amarok/src/browsers/BrowserMessageArea.h +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2011 Bart Cerneels . * - ****************************************************************************************/ - -#ifndef BROWSERMESSAGEAREA_H -#define BROWSERMESSAGEAREA_H - -#include "core-impl/logger/ProxyLogger.h" -#include "statusbar/CompoundProgressBar.h" - -#include -#include - -class BrowserMessageArea : public QFrame, public Amarok::Logger -{ - Q_OBJECT - -public: - BrowserMessageArea( QWidget *parent ); - - ~BrowserMessageArea() - { - } - - /* Amarok::Logger virtual methods */ - virtual void shortMessage( const QString &text ); - virtual void longMessage( const QString &text, MessageType type ); - - virtual void newProgressOperation( KJob *job, const QString &text, QObject *obj, - const char *slot, Qt::ConnectionType type ); - - virtual void newProgressOperation( QNetworkReply *reply, const QString &text, QObject *obj, - const char *slot, Qt::ConnectionType type ); - - virtual void newProgressOperation( QObject *sender, const QString &text, int maximum, - QObject *obj, const char *slot, Qt::ConnectionType type ); -signals: - void signalLongMessage( const QString & text, MessageType type ); - -private slots: - void hideProgress(); - void nextShortMessage(); - void hideLongMessage(); - void slotLongMessage( const QString &text, MessageType type = Information ); - -private: - CompoundProgressBar *m_progressBar; - QLabel *m_messageLabel; - - bool m_busy; - QTimer *m_shortMessageTimer; - QList m_shortMessageQueue; -}; - -#endif // BROWSERMESSAGEAREA_H diff --git a/amarok/src/browsers/CollectionSortFilterProxyModel.cpp b/amarok/src/browsers/CollectionSortFilterProxyModel.cpp deleted file mode 100644 index 660ea116..00000000 --- a/amarok/src/browsers/CollectionSortFilterProxyModel.cpp +++ /dev/null @@ -1,206 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * Copyright (c) 2008 Seb Ruiz * - * Copyright (c) 2013 Ralf Engels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "CollectionSortFilterProxyModel.h" - -#include "amarokconfig.h" -#include "browsers/CollectionTreeItem.h" -#include "core/meta/Meta.h" -#include "core/support/Debug.h" -#include "widgets/PrettyTreeRoles.h" - -#include - -#include -#include - -CollectionSortFilterProxyModel::CollectionSortFilterProxyModel( QObject * parent ) - : QSortFilterProxyModel( parent ) -{ - setSortLocaleAware( true ); - - setSortRole( PrettyTreeRoles::SortRole ); - setFilterRole( PrettyTreeRoles::FilterRole ); - setSortCaseSensitivity( Qt::CaseInsensitive ); - setFilterCaseSensitivity( Qt::CaseInsensitive ); - - setDynamicSortFilter( true ); -} - - -CollectionSortFilterProxyModel::~CollectionSortFilterProxyModel() -{ -} - -bool -CollectionSortFilterProxyModel::hasChildren(const QModelIndex & parent) const -{ - QModelIndex sourceParent = mapToSource(parent); - return sourceModel()->hasChildren(sourceParent); -} - -bool -CollectionSortFilterProxyModel::lessThan( const QModelIndex &left, const QModelIndex &right ) const -{ - CollectionTreeItem *leftItem = treeItem( left ); - CollectionTreeItem *rightItem = treeItem( right ); - - // various artists and no label items are always at the top - if( !leftItem || leftItem->isVariousArtistItem() || leftItem->isNoLabelItem() ) - return true; - if( !rightItem || rightItem->isVariousArtistItem() || rightItem->isNoLabelItem() ) - return false; - - if( leftItem->isTrackItem() && rightItem->isTrackItem() ) - return lessThanTrack( left, right ); - - if( leftItem->isAlbumItem() && rightItem->isAlbumItem() ) - return lessThanAlbum( left, right ); - - if( leftItem->isDataItem() && rightItem->isDataItem() ) - return lessThanItem( left, right ); - - return QSortFilterProxyModel::lessThan( left, right ); -} - -bool -CollectionSortFilterProxyModel::lessThanTrack( const QModelIndex &left, const QModelIndex &right ) const -{ - const Meta::TrackPtr leftTrack = Meta::TrackPtr::dynamicCast( treeItem(left)->data() ); - const Meta::TrackPtr rightTrack = Meta::TrackPtr::dynamicCast( treeItem(right)->data() ); - if( !leftTrack || !rightTrack ) - { - DEBUG_BLOCK - error() << "Should never have compared these two indexes" - << left.data(Qt::DisplayRole) << "and" << right.data(Qt::DisplayRole); - return QSortFilterProxyModel::lessThan( left, right ); - } - - if( AmarokConfig::showTrackNumbers() ) - { - //First compare by disc number - if ( leftTrack->discNumber() < rightTrack->discNumber() ) - return true; - if ( leftTrack->discNumber() > rightTrack->discNumber() ) - return false; - - //Disc #'s are equal, compare by track number - if( leftTrack->trackNumber() < rightTrack->trackNumber() ) - return true; - if( leftTrack->trackNumber() > rightTrack->trackNumber() ) - return false; - } - - // compare by name - { - int comp = KStringHandler::naturalCompare( leftTrack->sortableName(), rightTrack->sortableName(), Qt::CaseInsensitive ); - if( comp < 0 ) - return true; - if( comp > 0 ) - return false; - } - - return leftTrack.data() < rightTrack.data(); // prevent expanded tracks from switching places (if that ever happens) -} - -bool -CollectionSortFilterProxyModel::lessThanAlbum( const QModelIndex &left, const QModelIndex &right ) const -{ - Meta::AlbumPtr leftAlbum = Meta::AlbumPtr::dynamicCast( treeItem(left)->data() ); - Meta::AlbumPtr rightAlbum = Meta::AlbumPtr::dynamicCast( treeItem(right)->data() ); - - if( !leftAlbum || !rightAlbum ) - { - DEBUG_BLOCK - error() << "Should never have compared these two indexes" - << left.data(Qt::DisplayRole) << "and" << right.data(Qt::DisplayRole); - return QSortFilterProxyModel::lessThan( left, right ); - } - - // compare by year - if( AmarokConfig::showYears() ) - { - int leftYear = albumYear( leftAlbum ); - int rightYear = albumYear( rightAlbum ); - - if( leftYear < rightYear ) - return false; // left album is newer - if( leftYear > rightYear ) - return true; - } - - // compare by name - { - int comp = KStringHandler::naturalCompare( leftAlbum->sortableName(), rightAlbum->sortableName(), Qt::CaseInsensitive ); - if( comp < 0 ) - return true; - if( comp > 0 ) - return false; - } - - return leftAlbum.data() < rightAlbum.data(); // prevent expanded albums from switching places -} - -bool -CollectionSortFilterProxyModel::lessThanItem( const QModelIndex &left, const QModelIndex &right ) const -{ - Meta::DataPtr leftData = Meta::DataPtr::dynamicCast( treeItem(left)->data() ); - Meta::DataPtr rightData = Meta::DataPtr::dynamicCast( treeItem(right)->data() ); - - if( !leftData || !rightData ) - { - DEBUG_BLOCK - error() << "Should never have compared these two indexes" - << left.data(Qt::DisplayRole) << "and" << right.data(Qt::DisplayRole); - return QSortFilterProxyModel::lessThan( left, right ); - } - - // compare by name - { - int comp = KStringHandler::naturalCompare( leftData->sortableName(), rightData->sortableName(), Qt::CaseInsensitive ); - if( comp < 0 ) - return true; - if( comp > 0 ) - return false; - } - - return leftData.data() < rightData.data(); // prevent expanded data from switching places -} - -inline CollectionTreeItem* -CollectionSortFilterProxyModel::treeItem( const QModelIndex &index ) const -{ - return static_cast( index.internalPointer() ); -} - -int -CollectionSortFilterProxyModel::albumYear( Meta::AlbumPtr album ) const -{ - if( album->name().isEmpty() ) // an unnamed album has no year - return 0; - - Meta::TrackList tracks = album->tracks(); - if( !tracks.isEmpty() ) - { - Meta::YearPtr year = tracks.first()->year(); - if( year && (year->year() != 0) ) - return year->year(); - } - return 0; -} - diff --git a/amarok/src/browsers/CollectionSortFilterProxyModel.h b/amarok/src/browsers/CollectionSortFilterProxyModel.h deleted file mode 100644 index a3412881..00000000 --- a/amarok/src/browsers/CollectionSortFilterProxyModel.h +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * Copyright (c) 2008 Seb Ruiz * - * Copyright (c) 2013 Ralf Engels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef COLLECTIONSORTFILTERPROXYMODEL_H -#define COLLECTIONSORTFILTERPROXYMODEL_H - -#include "core/meta/forward_declarations.h" - -#include - -class CollectionTreeItem; - -/** - This is a custom QSortFilterProxyModel that gives special sort orders for - our meta objects. - e.g. it sorts tracks by disc number and track number. - - @author Nikolaj Hald Nielsen -*/ -class CollectionSortFilterProxyModel : public QSortFilterProxyModel -{ - public: - CollectionSortFilterProxyModel( QObject * parent = 0 ); - - virtual ~CollectionSortFilterProxyModel(); - - bool hasChildren(const QModelIndex &parent) const; - - protected: - virtual bool lessThan( const QModelIndex &left, const QModelIndex &right ) const; - - private: - /** Tries to compute a year for the album using the track years. */ - int albumYear( Meta::AlbumPtr album ) const; - - CollectionTreeItem* treeItem( const QModelIndex &index ) const; - bool lessThanTrack( const QModelIndex &left, const QModelIndex &right ) const; - bool lessThanAlbum( const QModelIndex &left, const QModelIndex &right ) const; - bool lessThanItem( const QModelIndex &left, const QModelIndex &right ) const; -}; - -#endif diff --git a/amarok/src/browsers/CollectionTreeItem.cpp b/amarok/src/browsers/CollectionTreeItem.cpp deleted file mode 100644 index 09978bc4..00000000 --- a/amarok/src/browsers/CollectionTreeItem.cpp +++ /dev/null @@ -1,403 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Alexandre Pereira de Oliveira * - * Copyright (c) 2007-2009 Maximilian Kossick * - * Copyright (c) 2009 Seb Ruiz * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "CollectionTreeItem.h" - -#include "amarokconfig.h" -#include "browsers/CollectionTreeItemModelBase.h" -#include "core/capabilities/ActionsCapability.h" -#include "core/meta/Meta.h" -#include "core/support/Debug.h" -#include "widgets/PrettyTreeRoles.h" - -#include -#include - -Q_DECLARE_METATYPE( QAction* ) -Q_DECLARE_METATYPE( QList ) - -CollectionTreeItem::CollectionTreeItem( CollectionTreeItemModelBase *model ) -: m_data( 0 ) - , m_parent( 0 ) - , m_model( model ) - , m_parentCollection( 0 ) - , m_updateRequired( false ) - , m_trackCount( -1 ) - , m_type( Root ) - //, m_name( "Root" ) - , m_isCounting( false ) -{ -} - -CollectionTreeItem::CollectionTreeItem( Meta::DataPtr data, CollectionTreeItem *parent, CollectionTreeItemModelBase *model ) - : m_data( data ) - , m_parent( parent ) - , m_model( model ) - , m_parentCollection( 0 ) - , m_updateRequired( true ) - , m_trackCount( -1 ) - , m_type( Data ) - //, m_name( data ? data->name() : "NullData" ) - , m_isCounting( false ) -{ - if ( m_parent ) - m_parent->appendChild( this ); -} - -CollectionTreeItem::CollectionTreeItem( Collections::Collection *parentCollection, CollectionTreeItem *parent, CollectionTreeItemModelBase *model ) - : m_data( 0 ) - , m_parent( parent ) - , m_model( model ) - , m_parentCollection( parentCollection ) - , m_updateRequired( true ) - , m_trackCount( -1 ) - , m_type( Collection ) - //, m_name( parentCollection ? parentCollection->collectionId() : "NullColl" ) - , m_isCounting( false ) -{ - if ( m_parent ) - m_parent->appendChild( this ); - - connect( parentCollection, SIGNAL(updated()), SLOT(collectionUpdated()) ); -} - -CollectionTreeItem::CollectionTreeItem( Type type, const Meta::DataList &data, CollectionTreeItem *parent, CollectionTreeItemModelBase *model ) - : m_data( 0 ) - , m_parent( parent ) - , m_model( model ) - , m_parentCollection( 0 ) - , m_updateRequired( false ) //the node already has all children - , m_trackCount( -1 ) - , m_type( type ) - , m_isCounting( false ) -{ - if( m_parent ) - m_parent->m_childItems.insert( 0, this ); - - foreach( Meta::DataPtr datap, data ) - new CollectionTreeItem( datap, this, m_model ); -} - -CollectionTreeItem::~CollectionTreeItem() -{ - qDeleteAll( m_childItems ); -} - -void -CollectionTreeItem::appendChild(CollectionTreeItem *child) -{ - m_childItems.append(child); -} - -void -CollectionTreeItem::removeChild( int index ) -{ - CollectionTreeItem *child = m_childItems[index]; - m_childItems.removeAt( index ); - child->prepareForRemoval(); - child->deleteLater(); -} - -void -CollectionTreeItem::prepareForRemoval() -{ - m_parent = 0; - m_model->itemAboutToBeDeleted( this ); - foreach( CollectionTreeItem *item, m_childItems ) - { - item->prepareForRemoval(); - } -} - -CollectionTreeItem* -CollectionTreeItem::child( int row ) -{ - return m_childItems.value( row ); -} - -QVariant -CollectionTreeItem::data( int role ) const -{ - if( isNoLabelItem() ) - { - switch( role ) - { - case Qt::DisplayRole: - return i18nc( "No labels are assigned to the given item are any of its subitems", "No Labels" ); - case Qt::DecorationRole: - return KIcon( "label-amarok" ); - } - return QVariant(); - } - else if( m_parentCollection ) - { - static const QString counting = i18n( "Counting..." ); - switch( role ) - { - case Qt::DisplayRole: - case PrettyTreeRoles::FilterRole: - case PrettyTreeRoles::SortRole: - return m_parentCollection->prettyName(); - case Qt::DecorationRole: - return m_parentCollection->icon(); - case PrettyTreeRoles::ByLineRole: - if( m_isCounting ) - return counting; - if( m_trackCount < 0 ) - { - m_isCounting = true; - - Collections::QueryMaker *qm = m_parentCollection->queryMaker(); - connect( qm, SIGNAL(newResultReady(QStringList)), - SLOT(tracksCounted(QStringList)) ); - - qm->setAutoDelete( true ) - ->setQueryType( Collections::QueryMaker::Custom ) - ->addReturnFunction( Collections::QueryMaker::Count, Meta::valUrl ) - ->run(); - - return counting; - } - return i18np( "1 track", "%1 tracks", m_trackCount ); - case PrettyTreeRoles::HasCapacityRole: - return m_parentCollection->hasCapacity(); - case PrettyTreeRoles::UsedCapacityRole: - return m_parentCollection->usedCapacity(); - case PrettyTreeRoles::TotalCapacityRole: - return m_parentCollection->totalCapacity(); - case PrettyTreeRoles::DecoratorRoleCount: - return decoratorActions().size(); - case PrettyTreeRoles::DecoratorRole: - QVariant v; - v.setValue( decoratorActions() ); - return v; - } - } - return QVariant(); -} - -QList -CollectionTreeItem::decoratorActions() const -{ - QList decoratorActions; - QScopedPointer dc( m_parentCollection->create() ); - if( dc ) - decoratorActions = dc->actions(); - return decoratorActions; -} - -void -CollectionTreeItem::tracksCounted( QStringList res ) -{ - if( !res.isEmpty() ) - m_trackCount = res.first().toInt(); - else - m_trackCount = 0; - m_isCounting = false; - emit dataUpdated(); -} - -void -CollectionTreeItem::collectionUpdated() -{ - m_trackCount = -1; -} - -int -CollectionTreeItem::row() const -{ - if( m_parent ) - { - const QList &children = m_parent->m_childItems; - if( !children.isEmpty() && children.contains( const_cast(this) ) ) - return children.indexOf( const_cast(this) ); - else - return -1; - } - return 0; -} - -int -CollectionTreeItem::level() const -{ - if( m_parent ) - return m_parent->level() + 1; - return -1; -} - -bool -CollectionTreeItem::isDataItem() const -{ - return m_type == Data; -} - -bool -CollectionTreeItem::isVariousArtistItem() const -{ - return m_type == CollectionTreeItem::VariousArtist; -} - -bool -CollectionTreeItem::isNoLabelItem() const -{ - return m_type == CollectionTreeItem::NoLabel; -} - -bool -CollectionTreeItem::isAlbumItem() const -{ - return m_type == Data && !Meta::AlbumPtr::dynamicCast( m_data ).isNull(); -} - -bool -CollectionTreeItem::isTrackItem() const -{ - return m_type == Data && !Meta::TrackPtr::dynamicCast( m_data ).isNull(); -} - -Collections::QueryMaker* -CollectionTreeItem::queryMaker() const -{ - Collections::Collection* coll = parentCollection(); - if( coll ) - return coll->queryMaker(); - return 0; -} - -void -CollectionTreeItem::addMatch( Collections::QueryMaker *qm, CategoryId::CatMenuId levelCategory ) const -{ - if( !qm ) - return; - - if( isVariousArtistItem() ) - qm->setAlbumQueryMode( Collections::QueryMaker::OnlyCompilations ); - if( isNoLabelItem() ) - qm->setLabelQueryMode( Collections::QueryMaker::OnlyWithoutLabels ); - else if( Meta::TrackPtr track = Meta::TrackPtr::dynamicCast( m_data ) ) - qm->addMatch( track ); - else if( Meta::ArtistPtr artist = Meta::ArtistPtr::dynamicCast( m_data ) ) - { - Collections::QueryMaker::ArtistMatchBehaviour behaviour = - ( levelCategory == CategoryId::AlbumArtist ) ? Collections::QueryMaker::AlbumArtists : - Collections::QueryMaker::TrackArtists; - qm->addMatch( artist, behaviour ); - } - else if( Meta::AlbumPtr album = Meta::AlbumPtr::dynamicCast( m_data ) ) - qm->addMatch( album ); - else if( Meta::ComposerPtr composer = Meta::ComposerPtr::dynamicCast( m_data ) ) - qm->addMatch( composer ); - else if( Meta::GenrePtr genre = Meta::GenrePtr::dynamicCast( m_data ) ) - qm->addMatch( genre ); - else if( Meta::YearPtr year = Meta::YearPtr::dynamicCast( m_data ) ) - qm->addMatch( year ); - else if( Meta::LabelPtr label = Meta::LabelPtr::dynamicCast( m_data ) ) - qm->addMatch( label ); -} - - -KUrl::List -CollectionTreeItem::urls() const -{ - /*QueryBuilder qb = queryBuilder(); - qb.addReturnValue( QueryBuilder::tabSong, QueryBuilder::valURL ); - QStringList values = qb.run(); - KUrl::List list; - foreach( QString s, values ) { - list += KUrl( s ); - } - return list;*/ - KUrl::List list; - return list; -} - -bool -CollectionTreeItem::operator<( const CollectionTreeItem& other ) const -{ - if( isVariousArtistItem() ) - return true; - return m_data->sortableName() < other.m_data->sortableName(); -} - -const Meta::DataPtr -CollectionTreeItem::data() const -{ - return m_data; -} - -Meta::TrackList -CollectionTreeItem::descendentTracks() -{ - QList descendentTracks; - Meta::TrackPtr track; - if( isDataItem() ) - track = Meta::TrackPtr::dynamicCast( m_data ); - - if( !track.isNull() ) - descendentTracks << track; - else - { - foreach( CollectionTreeItem *child, m_childItems ) - descendentTracks << child->descendentTracks(); - } - return descendentTracks; -} - -bool -CollectionTreeItem::allDescendentTracksLoaded() const -{ - if( isTrackItem() ) - return true; - - if( requiresUpdate() ) - return false; - - foreach( CollectionTreeItem *item, m_childItems ) - { - if( !item->allDescendentTracksLoaded() ) - return false; - } - return true; -} - -void -CollectionTreeItem::setRequiresUpdate( bool updateRequired ) -{ - m_updateRequired = updateRequired; -} - -bool -CollectionTreeItem::requiresUpdate() const -{ - return m_updateRequired; -} - -CollectionTreeItem::Type -CollectionTreeItem::type() const -{ - return m_type; -} - -QList -CollectionTreeItem::children() const -{ - return m_childItems; -} - -#include "moc_CollectionTreeItem.cpp" - diff --git a/amarok/src/browsers/CollectionTreeItem.h b/amarok/src/browsers/CollectionTreeItem.h deleted file mode 100644 index 2af93b60..00000000 --- a/amarok/src/browsers/CollectionTreeItem.h +++ /dev/null @@ -1,137 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Alexandre Pereira de Oliveira * - * Copyright (c) 2007-2009 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef COLLECTIONTREEITEM_H -#define COLLECTIONTREEITEM_H - -#include "amarok_export.h" -#include "browsers/BrowserDefines.h" -#include "core/collections/Collection.h" -#include "core/meta/forward_declarations.h" - -#include -#include - -class CollectionTreeItemModelBase; -class QAction; - -class AMAROK_EXPORT CollectionTreeItem : public QObject -{ - Q_OBJECT - Q_ENUMS( Type ) - - public: - enum Type - { - Root, - Collection, - VariousArtist, - NoLabel, - Data - }; - - CollectionTreeItem( CollectionTreeItemModelBase *model ); //root node - CollectionTreeItem( Meta::DataPtr data, CollectionTreeItem *parent, CollectionTreeItemModelBase *model ); //data node - CollectionTreeItem( Collections::Collection *parentCollection, CollectionTreeItem *parent, CollectionTreeItemModelBase *model ); //collection node - //this ctor creates a "Various Artists" and "No Labels" nodes. do not use it for anything else - CollectionTreeItem( Type type, const Meta::DataList &data, CollectionTreeItem *parent, CollectionTreeItemModelBase *model ); //various artist node - - ~CollectionTreeItem(); - - CollectionTreeItem* parent() const { return m_parent; } - - void appendChild( CollectionTreeItem *child ); - void removeChild( int index ); - - CollectionTreeItem* child( int row ); - - int childCount() const { return m_childItems.count(); } - int columnCount() const { return 1; } - QList children() const; - - QVariant data( int role ) const; - - int row() const; - - int level() const; - - bool isDataItem() const; - bool isAlbumItem() const; - bool isTrackItem() const; - bool isVariousArtistItem() const; - bool isNoLabelItem() const; - - Collections::QueryMaker* queryMaker() const; - - /** - * Call addMatch for this objects data and it's query maker. Handles VariousArtist - * item and NoLabel item, too. - * - * @param qm QueryMaker to add match to - * @param levelCategory category for level this item is in, one of the values from - * CategoryId::CatMenuId enum. Used only for distinction between Artist and - * AlbumArtist. - */ - void addMatch( Collections::QueryMaker *qm, CategoryId::CatMenuId levelCategory ) const; - - bool operator<( const CollectionTreeItem &other ) const; - - const Meta::DataPtr data() const; - Collections::Collection* parentCollection() const { return m_parentCollection ? m_parentCollection : (m_parent ? m_parent->parentCollection() : 0); } - - KUrl::List urls() const; - Meta::TrackList descendentTracks(); - - bool allDescendentTracksLoaded() const; - - //required to mark a tree item as dirty if the model has to requiry its childre - - Type type() const; - bool requiresUpdate() const; - void setRequiresUpdate( bool updateRequired ); - - signals: - void dataUpdated(); - - private slots: - void tracksCounted( QStringList res ); - void collectionUpdated(); - - private: - /** Returns a list of collection actions. - Collection actions are shown on top of the collection tree item as icons (decorations) - */ - QList decoratorActions() const; - void prepareForRemoval(); - - Meta::DataPtr m_data; - CollectionTreeItem *m_parent; - CollectionTreeItemModelBase *m_model; - Collections::Collection *m_parentCollection; - - QList m_childItems; - bool m_updateRequired; - int m_trackCount; - Type m_type; - //QString m_name; - mutable bool m_isCounting; -}; - -Q_DECLARE_METATYPE( CollectionTreeItem* ) -Q_DECLARE_METATYPE( QList ) - -#endif diff --git a/amarok/src/browsers/CollectionTreeItemModel.cpp b/amarok/src/browsers/CollectionTreeItemModel.cpp deleted file mode 100644 index c6437067..00000000 --- a/amarok/src/browsers/CollectionTreeItemModel.cpp +++ /dev/null @@ -1,247 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Alexandre Pereira de Oliveira * - * Copyright (c) 2007-2009 Maximilian Kossick * - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "CollectionTreeItemModel" - -#include "CollectionTreeItemModel.h" - -#include -#include "AmarokMimeData.h" -#include "CollectionTreeItem.h" -#include "core/support/Debug.h" -#include "core/support/Amarok.h" -#include "core/collections/Collection.h" -#include "core/collections/CollectionLocation.h" -#include "core/collections/QueryMaker.h" -#include "core/meta/Meta.h" -#include "core-impl/collections/support/CollectionManager.h" -#include "core-impl/collections/support/FileCollectionLocation.h" - -#include - -#include -#include - -CollectionTreeItemModel::CollectionTreeItemModel( const QList &levelType ) - : CollectionTreeItemModelBase() -{ - m_rootItem = new CollectionTreeItem( this ); - CollectionManager *collMgr = CollectionManager::instance(); - connect( collMgr, SIGNAL(collectionAdded(Collections::Collection*)), this, SLOT(collectionAdded(Collections::Collection*)), Qt::QueuedConnection ); - connect( collMgr, SIGNAL(collectionRemoved(QString)), this, SLOT(collectionRemoved(QString)) ); - - QList collections = CollectionManager::instance()->viewableCollections(); - foreach( Collections::Collection *coll, collections ) - { - connect( coll, SIGNAL(updated()), this, SLOT(slotFilter()) ) ; - m_collections.insert( coll->collectionId(), CollectionRoot( coll, new CollectionTreeItem( coll, m_rootItem, this ) ) ); - } - - setLevels( levelType ); -} - -Qt::ItemFlags -CollectionTreeItemModel::flags( const QModelIndex &idx ) const -{ - if( !idx.isValid() ) - return 0; - - Qt::ItemFlags flags = CollectionTreeItemModelBase::flags( idx ); - if( idx.parent().isValid() ) - return flags; // has parent -> not a collection -> no drops - - // we depend on someone (probably CollectionTreeView) to call - // CollectionTreeItemModelBase::setDragSourceCollections() every time a drag is - // initiated or enters collection browser widget - CollectionTreeItem *item = static_cast( idx.internalPointer() ); - Q_ASSERT(item->type() == CollectionTreeItem::Collection); - if( m_dragSourceCollections.contains( item->parentCollection() ) ) - return flags; // attempt to drag tracks from the same collection, don't allow this (bug 291068) - - if( !item->parentCollection()->isWritable() ) - return flags; // not writeable, disallow drops - - // all paranoid checks passed, tracks can be dropped to this item - return flags | Qt::ItemIsDropEnabled; -} - -QVariant -CollectionTreeItemModel::data(const QModelIndex &index, int role) const -{ - if (!index.isValid()) - return QVariant(); - - CollectionTreeItem *item = static_cast(index.internalPointer()); - // subtract one here because there is a collection level for this model - return dataForItem( item, role, item->level() - 1 ); -} - -bool -CollectionTreeItemModel::dropMimeData( const QMimeData *data, Qt::DropAction action, - int row, int column, const QModelIndex &parent ) -{ - Q_UNUSED(row) - Q_UNUSED(column) - //no drops on empty areas - if( !parent.isValid() ) - return false; - - CollectionTreeItem *item = static_cast( parent.internalPointer() ); - Q_ASSERT(item->type() == CollectionTreeItem::Collection); - - Collections::Collection *targetCollection = item->parentCollection(); - Q_ASSERT(targetCollection); - - //TODO: accept external drops. - const AmarokMimeData *mimeData = qobject_cast( data ); - Q_ASSERT(mimeData); - - //TODO: optimize for copy from same provider. - Meta::TrackList tracks = mimeData->tracks(); - QMap collectionTrackMap; - - foreach( Meta::TrackPtr track, tracks ) - { - Collections::Collection *sourceCollection = track->collection(); - collectionTrackMap.insertMulti( sourceCollection, track ); - } - - foreach( Collections::Collection *sourceCollection, collectionTrackMap.uniqueKeys() ) - { - if( sourceCollection == targetCollection ) - continue; // should be already caught by ...Model::flags(), but hey - - Collections::CollectionLocation *sourceLocation; - if( sourceCollection ) - { - sourceLocation = sourceCollection->location(); - Q_ASSERT(sourceLocation); - } - else - { - sourceLocation = new Collections::FileCollectionLocation(); - } - - // we need to create target collection location per each source colleciton location - // -- prepareSomething() takes ownership of the pointer. - Collections::CollectionLocation *targetLocation = targetCollection->location(); - Q_ASSERT(targetLocation); - - if( action == Qt::CopyAction ) - { - sourceLocation->prepareCopy( collectionTrackMap.values( sourceCollection ), - targetLocation ); - } - else if( action == Qt::MoveAction ) - { - sourceLocation->prepareMove( collectionTrackMap.values( sourceCollection ), - targetLocation ); - } - } - - return true; -} - - -bool -CollectionTreeItemModel::canFetchMore( const QModelIndex &parent ) const -{ - if ( !parent.isValid() ) - return false; //children of the root item are the collections, and they are always known - - CollectionTreeItem *item = static_cast( parent.internalPointer() ); - return item->level() <= m_levelType.count() && item->requiresUpdate(); -} - -void -CollectionTreeItemModel::fetchMore( const QModelIndex &parent ) -{ - if ( !parent.isValid() ) - return; - - CollectionTreeItem *item = static_cast( parent.internalPointer() ); - ensureChildrenLoaded( item ); -} - -Qt::DropActions -CollectionTreeItemModel::supportedDropActions() const -{ - // this also causes supportedDragActions() to contain move action - return CollectionTreeItemModelBase::supportedDropActions() | Qt::MoveAction; -} - -void -CollectionTreeItemModel::collectionAdded( Collections::Collection *newCollection ) -{ - if( !newCollection ) - return; - - connect( newCollection, SIGNAL(updated()), this, SLOT(slotFilter()) ) ; - - QString collectionId = newCollection->collectionId(); - if( m_collections.contains( collectionId ) ) - return; - - //inserts new collection at the end. - beginInsertRows( QModelIndex(), m_rootItem->childCount(), m_rootItem->childCount() ); - m_collections.insert( collectionId, CollectionRoot( newCollection, new CollectionTreeItem( newCollection, m_rootItem, this ) ) ); - endInsertRows(); - - if( m_collections.count() == 1 ) - QTimer::singleShot( 0, this, SLOT(requestCollectionsExpansion()) ); -} - -void -CollectionTreeItemModel::collectionRemoved( const QString &collectionId ) -{ - int count = m_rootItem->childCount(); - for( int i = 0; i < count; i++ ) - { - CollectionTreeItem *item = m_rootItem->child( i ); - if( item && !item->isDataItem() && item->parentCollection()->collectionId() == collectionId ) - { - beginRemoveRows( QModelIndex(), i, i ); - m_rootItem->removeChild( i ); - m_collections.remove( collectionId ); - m_expandedCollections.remove( item->parentCollection() ); - endRemoveRows(); - } - } -} - -void -CollectionTreeItemModel::filterChildren() -{ - int count = m_rootItem->childCount(); - for ( int i = 0; i < count; i++ ) - { - markSubTreeAsDirty( m_rootItem->child( i ) ); - ensureChildrenLoaded( m_rootItem->child( i ) ); - } -} - -void -CollectionTreeItemModel::requestCollectionsExpansion() -{ - for( int i = 0, count = m_rootItem->childCount(); i < count; i++ ) - { - emit expandIndex( itemIndex( m_rootItem->child( i ) ) ); - } -} - -#include "moc_CollectionTreeItemModel.cpp" diff --git a/amarok/src/browsers/CollectionTreeItemModel.h b/amarok/src/browsers/CollectionTreeItemModel.h deleted file mode 100644 index 886ddc41..00000000 --- a/amarok/src/browsers/CollectionTreeItemModel.h +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Alexandre Pereira de Oliveira * - * Copyright (c) 2007-2009 Maximilian Kossick * - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef COLLECTIONTREEITEMMODEL_H -#define COLLECTIONTREEITEMMODEL_H - -#include "CollectionTreeItemModelBase.h" -#include "core/meta/forward_declarations.h" - -#include "core/collections/Collection.h" - -#include -#include - -class CollectionTreeItem; - -class CollectionTreeItemModel: public CollectionTreeItemModelBase -{ - Q_OBJECT - - public: - CollectionTreeItemModel( const QList &levelType ); - - /* QAbstractItemModel methods */ - virtual Qt::ItemFlags flags( const QModelIndex &index ) const; - virtual QVariant data( const QModelIndex &index, int role ) const; - virtual bool dropMimeData( const QMimeData *data, Qt::DropAction action, int row, - int column, const QModelIndex &parent ); - virtual bool canFetchMore( const QModelIndex &parent ) const; - virtual void fetchMore( const QModelIndex &parent ); - virtual Qt::DropActions supportedDropActions() const; - - public slots: - virtual void collectionAdded( Collections::Collection *newCollection ); - virtual void collectionRemoved( const QString &collectionId ); - - protected: - virtual void filterChildren(); - virtual int levelModifier() const { return 0; } - - private slots: - void requestCollectionsExpansion(); -}; - -#endif diff --git a/amarok/src/browsers/CollectionTreeItemModelBase.cpp b/amarok/src/browsers/CollectionTreeItemModelBase.cpp deleted file mode 100644 index a6037201..00000000 --- a/amarok/src/browsers/CollectionTreeItemModelBase.cpp +++ /dev/null @@ -1,1217 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Alexandre Pereira de Oliveira * - * Copyright (c) 2007-2009 Maximilian Kossick * - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "CollectionTreeItemModelBase" - -#include "CollectionTreeItemModelBase.h" - -#include "AmarokMimeData.h" -#include "FileType.h" -#include "SvgHandler.h" -#include "amarokconfig.h" -#include "browsers/CollectionTreeItem.h" -#include "core/collections/Collection.h" -#include "core/collections/QueryMaker.h" -#include "core/meta/TrackEditor.h" -#include "core/meta/support/MetaConstants.h" -#include "core/support/Amarok.h" -#include "core/support/Debug.h" -#include "core-impl/collections/support/TextualQueryFilter.h" -#include "widgets/PrettyTreeRoles.h" - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -using namespace Meta; - - -inline uint qHash( const Meta::DataPtr &data ) -{ - return qHash( data.data() ); -} - -/** - * This set determines which collection browser levels should have shown Various Artists - * item under them. AlbumArtist is certain, (Track)Artist is questionable. - */ -static const QSet variousArtistCategories = - QSet() << CategoryId::AlbumArtist; - -CollectionTreeItemModelBase::CollectionTreeItemModelBase( ) - : QAbstractItemModel() - , m_rootItem( 0 ) - , m_animFrame( 0 ) - , m_loading1( QPixmap( KStandardDirs::locate("data", "amarok/images/loading1.png" ) ) ) - , m_loading2( QPixmap( KStandardDirs::locate("data", "amarok/images/loading2.png" ) ) ) - , m_currentAnimPixmap( m_loading1 ) - , m_autoExpand( false ) -{ - m_timeLine = new QTimeLine( 10000, this ); - m_timeLine->setFrameRange( 0, 20 ); - m_timeLine->setLoopCount ( 0 ); - connect( m_timeLine, SIGNAL(frameChanged(int)), this, SLOT(loadingAnimationTick()) ); -} - -CollectionTreeItemModelBase::~CollectionTreeItemModelBase() -{ - KConfigGroup config = Amarok::config( "Collection Browser" ); - QList levelNumbers; - foreach( CategoryId::CatMenuId category, levels() ) - levelNumbers.append( category ); - config.writeEntry( "TreeCategory", levelNumbers ); - - if( m_rootItem ) - m_rootItem->deleteLater(); -} - -Qt::ItemFlags CollectionTreeItemModelBase::flags(const QModelIndex & index) const -{ - Qt::ItemFlags flags = 0; - if( index.isValid() ) - { - flags = Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEditable; - } - return flags; - -} - -bool -CollectionTreeItemModelBase::setData( const QModelIndex &index, const QVariant &value, int role ) -{ - Q_UNUSED( role ) - - if( !index.isValid() ) - return false; - CollectionTreeItem *item = static_cast( index.internalPointer() ); - - Meta::DataPtr data = item->data(); - - if( Meta::TrackPtr track = Meta::TrackPtr::dynamicCast( data ) ) - { - Meta::TrackEditorPtr ec = track->editor(); - if( ec ) - { - ec->setTitle( value.toString() ); - emit dataChanged( index, index ); - return true; - } - } - else if( Meta::AlbumPtr album = Meta::AlbumPtr::dynamicCast( data ) ) - { - Meta::TrackList tracks = album->tracks(); - if( !tracks.isEmpty() ) - { - foreach( Meta::TrackPtr track, tracks ) - { - Meta::TrackEditorPtr ec = track->editor(); - if( ec ) - ec->setAlbum( value.toString() ); - } - emit dataChanged( index, index ); - return true; - } - } - else if( Meta::ArtistPtr artist = Meta::ArtistPtr::dynamicCast( data ) ) - { - Meta::TrackList tracks = artist->tracks(); - if( !tracks.isEmpty() ) - { - foreach( Meta::TrackPtr track, tracks ) - { - Meta::TrackEditorPtr ec = track->editor(); - if( ec ) - ec->setArtist( value.toString() ); - } - emit dataChanged( index, index ); - return true; - } - } - else if( Meta::GenrePtr genre = Meta::GenrePtr::dynamicCast( data ) ) - { - Meta::TrackList tracks = genre->tracks(); - if( !tracks.isEmpty() ) - { - foreach( Meta::TrackPtr track, tracks ) - { - Meta::TrackEditorPtr ec = track->editor(); - if( ec ) - ec->setGenre( value.toString() ); - } - emit dataChanged( index, index ); - return true; - } - } - else if( Meta::YearPtr year = Meta::YearPtr::dynamicCast( data ) ) - { - Meta::TrackList tracks = year->tracks(); - if( !tracks.isEmpty() ) - { - foreach( Meta::TrackPtr track, tracks ) - { - Meta::TrackEditorPtr ec = track->editor(); - if( ec ) - ec->setYear( value.toInt() ); - } - emit dataChanged( index, index ); - return true; - } - } - else if( Meta::ComposerPtr composer = Meta::ComposerPtr::dynamicCast( data ) ) - { - Meta::TrackList tracks = composer->tracks(); - if( !tracks.isEmpty() ) - { - foreach( Meta::TrackPtr track, tracks ) - { - Meta::TrackEditorPtr ec = track->editor(); - if( ec ) - ec->setComposer( value.toString() ); - } - emit dataChanged( index, index ); - return true; - } - } - return false; -} - -QVariant -CollectionTreeItemModelBase::dataForItem( CollectionTreeItem *item, int role, int level ) const -{ - if( level == -1 ) - level = item->level(); - - if( item->isTrackItem() ) - { - Meta::TrackPtr track = Meta::TrackPtr::dynamicCast( item->data() ); - switch( role ) - { - case Qt::DisplayRole: - case Qt::ToolTipRole: - case PrettyTreeRoles::FilterRole: - { - QString name = track->prettyName(); - Meta::AlbumPtr album = track->album(); - Meta::ArtistPtr artist = track->artist(); - - if( album && artist && album->isCompilation() ) - name.prepend( QString("%1 - ").arg(artist->prettyName()) ); - - if( AmarokConfig::showTrackNumbers() ) - { - int trackNum = track->trackNumber(); - if( trackNum > 0 ) - name.prepend( QString("%1 - ").arg(trackNum) ); - } - - // Check empty after track logic and before album logic - if( name.isEmpty() ) - name = i18nc( "The Name is not known", "Unknown" ); - return name; - } - - case Qt::DecorationRole: - return KIcon( "media-album-track" ); - case PrettyTreeRoles::SortRole: - return track->sortableName(); - } - } - else if( item->isAlbumItem() ) - { - Meta::AlbumPtr album = Meta::AlbumPtr::dynamicCast( item->data() ); - switch( role ) - { - case Qt::DisplayRole: - case Qt::ToolTipRole: - { - QString name = album->prettyName(); - // add years for named albums (if enabled) - if( AmarokConfig::showYears() && !album->name().isEmpty() ) - { - Meta::TrackList tracks = album->tracks(); - if( !tracks.isEmpty() ) - { - Meta::YearPtr year = tracks.first()->year(); - if( year && (year->year() != 0) ) - name.prepend( QString("%1 - ").arg( year->name() ) ); - } - } - return name; - } - - case Qt::DecorationRole: - if( AmarokConfig::showAlbumArt() ) - { - QStyle *style = QApplication::style(); - const int largeIconSize = style->pixelMetric( QStyle::PM_LargeIconSize ); - - return The::svgHandler()->imageWithBorder( album, largeIconSize, 2 ); - } - else - return iconForLevel( level ); - - case PrettyTreeRoles::SortRole: - return album->sortableName(); - - case PrettyTreeRoles::HasCoverRole: - return AmarokConfig::showAlbumArt(); - } - } - else if( item->isDataItem() ) - { - switch( role ) - { - case Qt::DisplayRole: - case Qt::ToolTipRole: - case PrettyTreeRoles::FilterRole: - { - QString name = item->data()->prettyName(); - if( name.isEmpty() ) - name = i18nc( "The Name is not known", "Unknown" ); - return name; - } - - case Qt::DecorationRole: - { - if( m_childQueries.values().contains( item ) ) - { - if( level < m_levelType.count() ) - return m_currentAnimPixmap; - } - return iconForLevel( level ); - } - - case PrettyTreeRoles::SortRole: - return item->data()->sortableName(); - } - } - else if( item->isVariousArtistItem() ) - { - switch( role ) - { - case Qt::DecorationRole: - return KIcon( "similarartists-amarok" ); - case Qt::DisplayRole: - return i18n( "Various Artists" ); - case PrettyTreeRoles::SortRole: - return QString(); // so that we can compare it against other strings - } - } - - // -- all other roles are handled by item - return item->data( role ); -} - -QVariant -CollectionTreeItemModelBase::headerData(int section, Qt::Orientation orientation, int role) const -{ - if (orientation == Qt::Horizontal && role == Qt::DisplayRole) - { - if (section == 0) - return m_headerText; - } - return QVariant(); -} - -QModelIndex -CollectionTreeItemModelBase::index(int row, int column, const QModelIndex & parent) const -{ - //ensure sanity of parameters - //we are a tree model, there are no columns - if( row < 0 || column != 0 ) - return QModelIndex(); - - CollectionTreeItem *parentItem; - - if (!parent.isValid()) - parentItem = m_rootItem; - else - parentItem = static_cast(parent.internalPointer()); - - CollectionTreeItem *childItem = parentItem->child(row); - if( childItem ) - return createIndex(row, column, childItem); - else - return QModelIndex(); -} - -QModelIndex -CollectionTreeItemModelBase::parent(const QModelIndex & index) const -{ - if( !index.isValid() ) - return QModelIndex(); - - CollectionTreeItem *childItem = static_cast(index.internalPointer()); - CollectionTreeItem *parentItem = childItem->parent(); - - return itemIndex( parentItem ); -} - -int -CollectionTreeItemModelBase::rowCount(const QModelIndex & parent) const -{ - CollectionTreeItem *parentItem; - - if( !parent.isValid() ) - parentItem = m_rootItem; - else - parentItem = static_cast(parent.internalPointer()); - - return parentItem->childCount(); -} - -int CollectionTreeItemModelBase::columnCount(const QModelIndex & parent) const -{ - Q_UNUSED( parent ) - return 1; -} - -QStringList -CollectionTreeItemModelBase::mimeTypes() const -{ - QStringList types; - types << AmarokMimeData::TRACK_MIME; - return types; -} - -QMimeData* -CollectionTreeItemModelBase::mimeData( const QModelIndexList &indices ) const -{ - if ( indices.isEmpty() ) - return 0; - - // first, filter out duplicate entries that may arise when both parent and child are selected - QSet indexSet = QSet::fromList( indices ); - QMutableSetIterator it( indexSet ); - while( it.hasNext() ) - { - it.next(); - // we go up in parent hierarchy searching whether some parent indices are already in set - QModelIndex parentIndex = it.value(); - while( parentIndex.isValid() ) // leave the root (top, invalid) index intact - { - parentIndex = parentIndex.parent(); // yes, we start from the parent of current index - if( indexSet.contains( parentIndex ) ) - { - it.remove(); // parent already in selected set, remove child - break; // no need to continue inner loop, already deleted - } - } - } - - QList items; - foreach( const QModelIndex &index, indexSet ) - { - if( index.isValid() ) - items << static_cast( index.internalPointer() ); - } - - return mimeData( items ); -} - -QMimeData* -CollectionTreeItemModelBase::mimeData( const QList &items ) const -{ - if ( items.isEmpty() ) - return 0; - - Meta::TrackList tracks; - QList queries; - - foreach( CollectionTreeItem *item, items ) - { - if( item->allDescendentTracksLoaded() ) { - tracks << item->descendentTracks(); - } - else - { - Collections::QueryMaker *qm = item->queryMaker(); - for( CollectionTreeItem *tmp = item; tmp; tmp = tmp->parent() ) - tmp->addMatch( qm, levelCategory( tmp->level() - 1 ) ); - Collections::addTextualFilter( qm, m_currentFilter ); - queries.append( qm ); - } - } - - qStableSort( tracks.begin(), tracks.end(), Meta::Track::lessThan ); - - AmarokMimeData *mimeData = new AmarokMimeData(); - mimeData->setTracks( tracks ); - mimeData->setQueryMakers( queries ); - mimeData->startQueries(); - return mimeData; -} - -bool -CollectionTreeItemModelBase::hasChildren ( const QModelIndex & parent ) const -{ - if( !parent.isValid() ) - return true; // must be root item! - - CollectionTreeItem *item = static_cast(parent.internalPointer()); - //we added the collection level so we have to be careful with the item level - return !item->isDataItem() || item->level() + levelModifier() <= m_levelType.count(); - -} - -void -CollectionTreeItemModelBase::ensureChildrenLoaded( CollectionTreeItem *item ) -{ - //only start a query if necessary and we are not querying for the item's children already - if ( item->requiresUpdate() && !m_runningQueries.contains( item ) ) - { - listForLevel( item->level() + levelModifier(), item->queryMaker(), item ); - } -} - -CollectionTreeItem * -CollectionTreeItemModelBase::treeItem( const QModelIndex &index ) const -{ - if( !index.isValid() || index.model() != this ) - return 0; - - return static_cast( index.internalPointer() ); -} - -QModelIndex -CollectionTreeItemModelBase::itemIndex( CollectionTreeItem *item ) const -{ - if( !item || item == m_rootItem ) - return QModelIndex(); - - return createIndex( item->row(), 0, item ); -} - -void CollectionTreeItemModelBase::listForLevel(int level, Collections::QueryMaker * qm, CollectionTreeItem * parent) -{ - if( qm && parent ) - { - // this check should not hurt anyone... needs to check if single... needs it - if( m_runningQueries.contains( parent ) ) - return; - - // following special cases are handled extra - right when the parent is added - if( level > m_levelType.count() || - parent->isVariousArtistItem() || - parent->isNoLabelItem() ) - { - qm->deleteLater(); - return; - } - - // - the last level are always the tracks - if ( level == m_levelType.count() ) - qm->setQueryType( Collections::QueryMaker::Track ); - - // - all other levels are more complicate - else - { - Collections::QueryMaker::QueryType nextLevel; - if( level + 1 >= m_levelType.count() ) - nextLevel = Collections::QueryMaker::Track; - else - nextLevel = mapCategoryToQueryType( m_levelType.value( level + 1 ) ); - - qm->setQueryType( mapCategoryToQueryType( m_levelType.value( level ) ) ); - - CategoryId::CatMenuId category = m_levelType.value( level ); - if( category == CategoryId::Album ) - { - // restrict query to normal albums if the previous level - // was the AlbumArtist category. In that case we handle compilations below - if( levelCategory( level - 1 ) == CategoryId::AlbumArtist ) - qm->setAlbumQueryMode( Collections::QueryMaker::OnlyNormalAlbums ); - } - else if( variousArtistCategories.contains( category ) ) - // we used to handleCompilations() only if nextLevel is Album, but I cannot - // tell any reason why we should have done this --- strohel - handleCompilations( nextLevel, parent ); - else if( category == CategoryId::Label ) - handleTracksWithoutLabels( nextLevel, parent ); - } - - for( CollectionTreeItem *tmp = parent; tmp; tmp = tmp->parent() ) - tmp->addMatch( qm, levelCategory( tmp->level() - 1 ) ); - Collections::addTextualFilter( qm, m_currentFilter ); - addQueryMaker( parent, qm ); - m_childQueries.insert( qm, parent ); - qm->run(); - - //some very quick queries may be done so fast that the loading - //animation creates an unnecessary flicker, therefore delay it for a bit - QTimer::singleShot( 150, this, SLOT(startAnimationTick()) ); - } -} - -void -CollectionTreeItemModelBase::setLevels( const QList &levelType ) -{ - if( m_levelType == levelType ) - return; - - m_levelType = levelType; - updateHeaderText(); - m_expandedItems.clear(); - m_expandedSpecialNodes.clear(); - m_runningQueries.clear(); - m_childQueries.clear(); - m_compilationQueries.clear(); - filterChildren(); -} - -Collections::QueryMaker::QueryType -CollectionTreeItemModelBase::mapCategoryToQueryType( int levelType ) const -{ - Collections::QueryMaker::QueryType type; - switch( levelType ) - { - case CategoryId::Album: - type = Collections::QueryMaker::Album; - break; - case CategoryId::Artist: - type = Collections::QueryMaker::Artist; - break; - case CategoryId::AlbumArtist: - type = Collections::QueryMaker::AlbumArtist; - break; - case CategoryId::Composer: - type = Collections::QueryMaker::Composer; - break; - case CategoryId::Genre: - type = Collections::QueryMaker::Genre; - break; - case CategoryId::Label: - type = Collections::QueryMaker::Label; - break; - case CategoryId::Year: - type = Collections::QueryMaker::Year; - break; - default: - type = Collections::QueryMaker::None; - break; - } - - return type; -} - -void -CollectionTreeItemModelBase::addQueryMaker( CollectionTreeItem* item, - Collections::QueryMaker *qm ) const -{ - connect( qm, SIGNAL(newResultReady(Meta::TrackList)), SLOT(newResultReady(Meta::TrackList)), Qt::QueuedConnection ); - connect( qm, SIGNAL(newResultReady(Meta::ArtistList)), SLOT(newResultReady(Meta::ArtistList)), Qt::QueuedConnection ); - connect( qm, SIGNAL(newResultReady(Meta::AlbumList)), SLOT(newResultReady(Meta::AlbumList)), Qt::QueuedConnection ); - connect( qm, SIGNAL(newResultReady(Meta::GenreList)), SLOT(newResultReady(Meta::GenreList)), Qt::QueuedConnection ); - connect( qm, SIGNAL(newResultReady(Meta::ComposerList)), SLOT(newResultReady(Meta::ComposerList)), Qt::QueuedConnection ); - connect( qm, SIGNAL(newResultReady(Meta::YearList)), SLOT(newResultReady(Meta::YearList)), Qt::QueuedConnection ); - connect( qm, SIGNAL(newResultReady(Meta::LabelList)), SLOT(newResultReady(Meta::LabelList)), Qt::QueuedConnection ); - connect( qm, SIGNAL(newResultReady(Meta::DataList)), SLOT(newResultReady(Meta::DataList)), Qt::QueuedConnection ); - connect( qm, SIGNAL(queryDone()), SLOT(queryDone()), Qt::QueuedConnection ); - m_runningQueries.insert( item, qm ); -} - -void -CollectionTreeItemModelBase::queryDone() -{ - Collections::QueryMaker *qm = qobject_cast( sender() ); - if( !qm ) - return; - - CollectionTreeItem* item = 0; - if( m_childQueries.contains( qm ) ) - item = m_childQueries.take( qm ); - else if( m_compilationQueries.contains( qm ) ) - item = m_compilationQueries.take( qm ); - else if( m_noLabelsQueries.contains( qm ) ) - item = m_noLabelsQueries.take( qm ); - - if( item ) - m_runningQueries.remove( item, qm ); - - //reset icon for this item - if( item && item != m_rootItem ) - { - emit dataChanged( itemIndex( item ), itemIndex( item ) ); - } - - //stop timer if there are no more animations active - if( m_runningQueries.isEmpty() ) - { - emit allQueriesFinished( m_autoExpand ); - m_autoExpand = false; // reset to default value - m_timeLine->stop(); - } - qm->deleteLater(); -} - -// TODO - -/** Small helper function to convert a list of e.g. tracks to a list of DataPtr */ -template -static Meta::DataList -convertToDataList( const ListType& list ) -{ - Meta::DataList data; - foreach( PointerType p, list ) - data << Meta::DataPtr::staticCast( p ); - - return data; -} - -void -CollectionTreeItemModelBase::newResultReady( Meta::TrackList res ) -{ - newResultReady( convertToDataList( res ) ); -} - -void -CollectionTreeItemModelBase::newResultReady( Meta::ArtistList res ) -{ - newResultReady( convertToDataList( res ) ); -} - -void -CollectionTreeItemModelBase::newResultReady( Meta::AlbumList res ) -{ - newResultReady( convertToDataList( res ) ); -} - -void -CollectionTreeItemModelBase::newResultReady( Meta::GenreList res ) -{ - newResultReady( convertToDataList( res ) ); -} - -void -CollectionTreeItemModelBase::newResultReady( Meta::ComposerList res ) -{ - newResultReady( convertToDataList( res ) ); -} - -void -CollectionTreeItemModelBase::newResultReady( Meta::YearList res ) -{ - newResultReady( convertToDataList( res ) ); -} - -void -CollectionTreeItemModelBase::newResultReady( Meta::LabelList res ) -{ - newResultReady( convertToDataList( res ) ); -} - -void -CollectionTreeItemModelBase::newResultReady( Meta::DataList data ) -{ - //if we are expanding an item, we'll find the sender in childQueries - //otherwise we are filtering all collections - Collections::QueryMaker *qm = qobject_cast( sender() ); - if( !qm ) - return; - - if( m_childQueries.contains( qm ) ) - handleNormalQueryResult( qm, data ); - - else if( m_compilationQueries.contains( qm ) ) - handleSpecialQueryResult( CollectionTreeItem::VariousArtist, qm, data ); - - else if( m_noLabelsQueries.contains( qm ) ) - handleSpecialQueryResult( CollectionTreeItem::NoLabel, qm, data ); -} - -void -CollectionTreeItemModelBase::handleSpecialQueryResult( CollectionTreeItem::Type type, Collections::QueryMaker *qm, const Meta::DataList &dataList ) -{ - CollectionTreeItem *parent = 0; - - if( type == CollectionTreeItem::VariousArtist ) - parent = m_compilationQueries.value( qm ); - - else if( type == CollectionTreeItem::NoLabel ) - parent = m_noLabelsQueries.value( qm ); - - if( parent ) - { - QModelIndex parentIndex = itemIndex( parent ); - - //if the special query did not return a result we have to remove the - //the special node itself - if( dataList.isEmpty() ) - { - for( int i = 0; i < parent->childCount(); i++ ) - { - CollectionTreeItem *cti = parent->child( i ); - if( cti->type() == type ) - { - //found the special node - beginRemoveRows( parentIndex, cti->row(), cti->row() ); - cti = 0; //will be deleted; - parent->removeChild( i ); - endRemoveRows(); - break; - } - } - //we have removed the special node if it existed - return; - } - - CollectionTreeItem *specialNode = 0; - if( parent->childCount() == 0 ) - { - //we only insert the special node - beginInsertRows( parentIndex, 0, 0 ); - specialNode = new CollectionTreeItem( type, dataList, parent, this ); - //set requiresUpdate, otherwise we will query for the children of specialNode again! - specialNode->setRequiresUpdate( false ); - endInsertRows(); - } - else - { - for( int i = 0; i < parent->childCount(); i++ ) - { - CollectionTreeItem *cti = parent->child( i ); - if( cti->type() == type ) - { - //found the special node - specialNode = cti; - break; - } - } - if( !specialNode ) - { - //we only insert the special node - beginInsertRows( parentIndex, 0, 0 ); - specialNode = new CollectionTreeItem( type, dataList, parent, this ); - //set requiresUpdate, otherwise we will query for the children of specialNode again! - specialNode->setRequiresUpdate( false ); - endInsertRows(); - } - else - { - //only call populateChildren for the special node if we have not - //created it in this method call. The special node ctor takes care - //of that itself - populateChildren( dataList, specialNode, itemIndex( specialNode ) ); - } - //populate children will call setRequiresUpdate on vaNode - //but as the special query is based on specialNode's parent, - //we have to call setRequiresUpdate on the parent too - //yes, this will mean we will call setRequiresUpdate twice - parent->setRequiresUpdate( false ); - - for( int count = specialNode->childCount(), i = 0; i < count; ++i ) - { - CollectionTreeItem *item = specialNode->child( i ); - if ( m_expandedItems.contains( item->data() ) ) //item will always be a data item - { - listForLevel( item->level() + levelModifier(), item->queryMaker(), item ); - } - } - } - - //if the special node exists, check if it has to be expanded - if( specialNode ) - { - if( m_expandedSpecialNodes.contains( parent->parentCollection() ) ) - { - emit expandIndex( createIndex( 0, 0, specialNode ) ); //we have just inserted the vaItem at row 0 - } - } - } -} - -void -CollectionTreeItemModelBase::handleNormalQueryResult( Collections::QueryMaker *qm, const Meta::DataList &dataList ) -{ - CollectionTreeItem *parent = m_childQueries.value( qm ); - if( parent ) { - QModelIndex parentIndex = itemIndex( parent ); - populateChildren( dataList, parent, parentIndex ); - - if ( parent->isDataItem() ) - { - if ( m_expandedItems.contains( parent->data() ) ) - emit expandIndex( parentIndex ); - else - //simply insert the item, nothing will change if it is already in the set - m_expandedItems.insert( parent->data() ); - } - } -} - -void -CollectionTreeItemModelBase::populateChildren( const DataList &dataList, CollectionTreeItem *parent, const QModelIndex &parentIndex ) -{ - CategoryId::CatMenuId childCategory = levelCategory( parent->level() ); - - // add new rows after existing ones here (which means all artists nodes - // will be inserted after the "Various Artists" node) - // figure out which children of parent have to be removed, - // which new children have to be added, and preemptively emit dataChanged for the rest - // have to check how that influences performance... - const QSet dataSet = dataList.toSet(); - QSet childrenSet; - foreach( CollectionTreeItem *child, parent->children() ) - { - // we don't add null children, these are special-cased below - if( !child->data() ) - continue; - - childrenSet.insert( child->data() ); - } - const QSet dataToBeAdded = dataSet - childrenSet; - const QSet dataToBeRemoved = childrenSet - dataSet; - - // first remove all rows that have to be removed - // walking through the cildren in reverse order does not screw up the order - for( int i = parent->childCount() - 1; i >= 0; i-- ) - { - CollectionTreeItem *child = parent->child( i ); - - // should this child be removed? - bool toBeRemoved; - - if( child->isDataItem() ) - toBeRemoved = dataToBeRemoved.contains( child->data() ); - else if( child->isVariousArtistItem() ) - toBeRemoved = !variousArtistCategories.contains( childCategory ); - else if( child->isNoLabelItem() ) - toBeRemoved = childCategory != CategoryId::Label; - else - { - warning() << "Unknown child type encountered in populateChildren(), removing"; - toBeRemoved = true; - } - - if( toBeRemoved ) - { - beginRemoveRows( parentIndex, i, i ); - parent->removeChild( i ); - endRemoveRows(); - } - else - { - // the remainging child items may be dirty, so refresh them - if( child->isDataItem() && child->data() && m_expandedItems.contains( child->data() ) ) - ensureChildrenLoaded( child ); - - // tell the view that the existing children may have changed - QModelIndex idx = index( i, 0, parentIndex ); - emit dataChanged( idx, idx ); - } - } - - // add the new rows - if( !dataToBeAdded.isEmpty() ) - { - int lastRow = parent->childCount() - 1; - //the above check ensures that Qt does not crash on beginInsertRows ( because lastRow+1 > lastRow+0) - beginInsertRows( parentIndex, lastRow + 1, lastRow + dataToBeAdded.count() ); - foreach( Meta::DataPtr data, dataToBeAdded ) - { - new CollectionTreeItem( data, parent, this ); - } - endInsertRows(); - } - - parent->setRequiresUpdate( false ); -} - -void -CollectionTreeItemModelBase::updateHeaderText() -{ - m_headerText.clear(); - for( int i=0; i< m_levelType.count(); ++i ) - m_headerText += nameForLevel( i ) + " / "; - - m_headerText.chop( 3 ); -} - -QIcon -CollectionTreeItemModelBase::iconForCategory( CategoryId::CatMenuId category ) -{ - switch( category ) - { - case CategoryId::Album : - return KIcon( "media-optical-amarok" ); - case CategoryId::Artist : - return KIcon( "view-media-artist-amarok" ); - case CategoryId::AlbumArtist : - return KIcon( "view-media-artist-amarok" ); - case CategoryId::Composer : - return KIcon( "filename-composer-amarok" ); - case CategoryId::Genre : - return KIcon( "favorite-genres-amarok" ); - case CategoryId::Year : - return KIcon( "clock" ); - case CategoryId::Label : - return KIcon( "label-amarok" ); - case CategoryId::None: - default: - return KIcon( "image-missing" ); - } - -} - -QIcon -CollectionTreeItemModelBase::iconForLevel( int level ) const -{ - return iconForCategory( m_levelType.value( level ) ); -} - -QString -CollectionTreeItemModelBase::nameForCategory( CategoryId::CatMenuId category, bool showYears ) -{ - switch( category ) - { - case CategoryId::Album: - return showYears ? i18n( "Year - Album" ) : i18n( "Album" ); - case CategoryId::Artist: - return i18n( "Track Artist" ); - case CategoryId::AlbumArtist: - return i18n( "Album Artist" ); - case CategoryId::Composer: - return i18n( "Composer" ); - case CategoryId::Genre: - return i18n( "Genre" ); - case CategoryId::Year: - return i18n( "Year" ); - case CategoryId::Label: - return i18n( "Label" ); - case CategoryId::None: - return i18n( "None" ); - default: - return QString(); - } -} - -QString -CollectionTreeItemModelBase::nameForLevel( int level ) const -{ - return nameForCategory( m_levelType.value( level ), AmarokConfig::showYears() ); -} - -void -CollectionTreeItemModelBase::handleCompilations( Collections::QueryMaker::QueryType queryType, CollectionTreeItem *parent ) const -{ - // this method will be called when we retrieve a list of artists from the database. - // we have to query for all compilations, and then add a "Various Artists" node if at least - // one compilation exists - Collections::QueryMaker *qm = parent->queryMaker(); - qm->setQueryType( queryType ); - qm->setAlbumQueryMode( Collections::QueryMaker::OnlyCompilations ); - for( CollectionTreeItem *tmp = parent; tmp; tmp = tmp->parent() ) - tmp->addMatch( qm, levelCategory( tmp->level() - 1 ) ); - - Collections::addTextualFilter( qm, m_currentFilter ); - addQueryMaker( parent, qm ); - m_compilationQueries.insert( qm, parent ); - qm->run(); -} - -void -CollectionTreeItemModelBase::handleTracksWithoutLabels( Collections::QueryMaker::QueryType queryType, CollectionTreeItem *parent ) const -{ - Collections::QueryMaker *qm = parent->queryMaker(); - qm->setQueryType( queryType ); - qm->setLabelQueryMode( Collections::QueryMaker::OnlyWithoutLabels ); - for( CollectionTreeItem *tmp = parent; tmp; tmp = tmp->parent() ) - tmp->addMatch( qm, levelCategory( tmp->level() - 1 ) ); - - Collections::addTextualFilter( qm, m_currentFilter ); - addQueryMaker( parent, qm ); - m_noLabelsQueries.insert( qm, parent ); - qm->run(); -} - - -void CollectionTreeItemModelBase::startAnimationTick() -{ - //start animation - if( ( m_timeLine->state() != QTimeLine::Running ) && !m_runningQueries.isEmpty() ) - m_timeLine->start(); -} - -void CollectionTreeItemModelBase::loadingAnimationTick() -{ - if ( m_animFrame == 0 ) - m_currentAnimPixmap = m_loading2; - else - m_currentAnimPixmap = m_loading1; - - m_animFrame = 1 - m_animFrame; - - //trigger an update of all items being populated at the moment; - - QList< CollectionTreeItem * > items = m_runningQueries.uniqueKeys(); - foreach ( CollectionTreeItem* item, items ) - { - if( item == m_rootItem ) - continue; - emit dataChanged( itemIndex( item ), itemIndex( item ) ); - } -} - -QString -CollectionTreeItemModelBase::currentFilter() const -{ - return m_currentFilter; -} - -void -CollectionTreeItemModelBase::setCurrentFilter( const QString &filter ) -{ - m_currentFilter = filter; - slotFilter( /* autoExpand */ true ); -} - -void -CollectionTreeItemModelBase::slotFilter( bool autoExpand ) -{ - m_autoExpand = autoExpand; - filterChildren(); - - // following is not auto-expansion, it is restoring the state before filtering - foreach( Collections::Collection *expanded, m_expandedCollections ) - { - CollectionTreeItem *expandedItem = m_collections.value( expanded->collectionId() ).second; - if( expandedItem ) - emit expandIndex( itemIndex( expandedItem ) ); - } -} - -void -CollectionTreeItemModelBase::slotCollapsed( const QModelIndex &index ) -{ - if ( index.isValid() ) //probably unnecessary, but let's be safe - { - CollectionTreeItem *item = static_cast( index.internalPointer() ); - - switch( item->type() ) - { - case CollectionTreeItem::Root: - break; // nothing to do - - case CollectionTreeItem::Collection: - m_expandedCollections.remove( item->parentCollection() ); - break; - - case CollectionTreeItem::VariousArtist: - case CollectionTreeItem::NoLabel: - m_expandedSpecialNodes.remove( item->parentCollection() ); - break; - case CollectionTreeItem::Data: - m_expandedItems.remove( item->data() ); - break; - } - } -} - -void -CollectionTreeItemModelBase::slotExpanded( const QModelIndex &index ) -{ - if( !index.isValid() ) - return; - - CollectionTreeItem *item = static_cast( index.internalPointer() ); - // we are really only interested in the special nodes here. - // we have to remember whether the user expanded a various artists/no labels node or not. - // otherwise we won't be able to automatically expand the special node after filtering again - // there is exactly one special node per type per collection, so use the collection to store that information - - // we also need to store collection expansion state here as they are no longer - // added to th expanded set in handleNormalQueryResult() - switch( item->type() ) - { - case CollectionTreeItem::VariousArtist: - case CollectionTreeItem::NoLabel: - m_expandedSpecialNodes.insert( item->parentCollection() ); - break; - case CollectionTreeItem::Collection: - m_expandedCollections.insert( item->parentCollection() ); - default: - break; - } -} - -void CollectionTreeItemModelBase::markSubTreeAsDirty( CollectionTreeItem *item ) -{ - //tracks are the leaves so they are never dirty - if( !item->isTrackItem() ) - item->setRequiresUpdate( true ); - for( int i = 0; i < item->childCount(); i++ ) - { - markSubTreeAsDirty( item->child( i ) ); - } -} - -void CollectionTreeItemModelBase::itemAboutToBeDeleted( CollectionTreeItem *item ) -{ - // also all the children will be deleted - foreach( CollectionTreeItem *child, item->children() ) - itemAboutToBeDeleted( child ); - - if( !m_runningQueries.contains( item ) ) - return; - // TODO: replace this hack with QWeakPointer now than we depend on Qt >= 4.8 - foreach(Collections::QueryMaker *qm, m_runningQueries.values( item )) - { - m_childQueries.remove( qm ); - m_compilationQueries.remove( qm ); - m_noLabelsQueries.remove( qm ); - m_runningQueries.remove(item, qm); - - //Disconnect all signals from the QueryMaker so we do not get notified about the results - qm->disconnect(); - qm->abortQuery(); - //Nuke it - qm->deleteLater(); - } -} - -void -CollectionTreeItemModelBase::setDragSourceCollections( const QSet &collections ) -{ - m_dragSourceCollections = collections; -} - -bool -CollectionTreeItemModelBase::hasRunningQueries() const -{ - return !m_runningQueries.isEmpty(); -} - -CategoryId::CatMenuId -CollectionTreeItemModelBase::levelCategory( const int level ) const -{ - const int actualLevel = level + levelModifier(); - if( actualLevel >= 0 && actualLevel < m_levelType.count() ) - return m_levelType.at( actualLevel ); - - return CategoryId::None; -} - -#include "moc_CollectionTreeItemModelBase.cpp" diff --git a/amarok/src/browsers/CollectionTreeItemModelBase.h b/amarok/src/browsers/CollectionTreeItemModelBase.h deleted file mode 100644 index 804d501a..00000000 --- a/amarok/src/browsers/CollectionTreeItemModelBase.h +++ /dev/null @@ -1,201 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Alexandre Pereira de Oliveira * - * Copyright (c) 2007-2009 Maximilian Kossick * - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef COLLECTIONTREEITEMMODELBASE_H -#define COLLECTIONTREEITEMMODELBASE_H - -#include "amarok_export.h" - -#include "core/collections/QueryMaker.h" -#include "core/meta/forward_declarations.h" -#include "CollectionTreeItem.h" - -#include -#include -#include -#include -#include -#include - -namespace Collections -{ - class Collection; -} -class CollectionTreeItem; -class QTimeLine; - -typedef QPair CollectionRoot; - -/** - @author Nikolaj Hald Nielsen -*/ -class AMAROK_EXPORT CollectionTreeItemModelBase : public QAbstractItemModel -{ - Q_OBJECT - - public: - CollectionTreeItemModelBase(); - virtual ~CollectionTreeItemModelBase(); - - virtual Qt::ItemFlags flags(const QModelIndex &index) const; - virtual QVariant headerData(int section, Qt::Orientation orientation, - int role = Qt::DisplayRole) const; - virtual QModelIndex index(int row, int column, - const QModelIndex &parent = QModelIndex()) const; - virtual QModelIndex parent(const QModelIndex &index) const; - virtual int rowCount(const QModelIndex &parent = QModelIndex()) const; - virtual int columnCount(const QModelIndex &parent = QModelIndex()) const; - virtual bool hasChildren ( const QModelIndex & parent = QModelIndex() ) const; - - // Writable.. - virtual bool setData( const QModelIndex &index, const QVariant &value, int role = Qt::EditRole ); - - virtual QStringList mimeTypes() const; - virtual QMimeData* mimeData( const QModelIndexList &indices ) const; - virtual QMimeData* mimeData( const QList &items ) const; - - virtual void listForLevel( int level, Collections::QueryMaker *qm, CollectionTreeItem* parent ); - - virtual void setLevels( const QList &levelType ); - virtual QList levels() const { return m_levelType; } - virtual CategoryId::CatMenuId levelCategory( const int level ) const; - - QString currentFilter() const; - void setCurrentFilter( const QString &filter ); - - void itemAboutToBeDeleted( CollectionTreeItem *item ); - - /** - * This should be called every time a drag enters collection browser - */ - void setDragSourceCollections( const QSet &collections ); - - /** - * Return true if there are any queries still running. If this returns true, - * you can expect allQueriesFinished(bool) signal in some time. - */ - bool hasRunningQueries() const; - - static QIcon iconForCategory( CategoryId::CatMenuId category ); - static QString nameForCategory( CategoryId::CatMenuId category, bool showYears = false ); - - void ensureChildrenLoaded( CollectionTreeItem *item ); - - /** - * Get a pointer to colleciton tree item given its index. It is not safe to - * cache this pointer unless QWeakPointer is used. - */ - CollectionTreeItem *treeItem( const QModelIndex &index ) const; - - /** - * Get (create) index for a collection tree item. The caller must ensure this - * item is in this model. Invalid model index is returned on null or root item. - */ - QModelIndex itemIndex( CollectionTreeItem *item ) const; - - signals: - void expandIndex( const QModelIndex &index ); - void allQueriesFinished( bool autoExpand ); - - public slots: - virtual void queryDone(); - void newResultReady( Meta::TrackList ); - void newResultReady( Meta::ArtistList ); - void newResultReady( Meta::AlbumList ); - void newResultReady( Meta::GenreList ); - void newResultReady( Meta::ComposerList ); - void newResultReady( Meta::YearList ); - void newResultReady( Meta::LabelList ); - virtual void newResultReady( Meta::DataList data ); - - /** - * Apply the current filter. - * - * @param autoExpand whether to trigger automatic expansion of the tree after - * filtering is done. This should be set to true only if filter is run after - * user has actually just typed something and defaults to false. - */ - void slotFilter( bool autoExpand = false ); - - void slotCollapsed( const QModelIndex &index ); - void slotExpanded( const QModelIndex &index ); - - private: - void handleSpecialQueryResult( CollectionTreeItem::Type type, Collections::QueryMaker *qm, const Meta::DataList &dataList ); - void handleNormalQueryResult( Collections::QueryMaker *qm, const Meta::DataList &dataList ); - - Collections::QueryMaker::QueryType mapCategoryToQueryType( int levelType ) const; - - protected: - /** Adds the query maker to the running queries and connects the slots */ - void addQueryMaker( CollectionTreeItem* item, - Collections::QueryMaker *qm ) const; - - virtual void populateChildren(const Meta::DataList &dataList, CollectionTreeItem *parent, const QModelIndex &parentIndex ); - virtual void updateHeaderText(); - - virtual QIcon iconForLevel( int level ) const; - virtual QString nameForLevel( int level ) const; - - virtual int levelModifier() const = 0; - virtual QVariant dataForItem( CollectionTreeItem *item, int role, int level = -1 ) const; - - virtual void filterChildren() = 0; - - void markSubTreeAsDirty( CollectionTreeItem *item ); - - /** Initiates a special search for albums without artists */ - void handleCompilations( Collections::QueryMaker::QueryType queryType, CollectionTreeItem *parent ) const; - - /** Initiates a special search for tracks without label */ - void handleTracksWithoutLabels( Collections::QueryMaker::QueryType queryType, CollectionTreeItem *parent ) const; - - QString m_headerText; - CollectionTreeItem *m_rootItem; - QList m_levelType; - - QTimeLine *m_timeLine; - int m_animFrame; - QPixmap m_loading1, m_loading2, m_currentAnimPixmap; //icons for loading animation - - QString m_currentFilter; - QSet m_expandedItems; - QSet m_expandedCollections; - QSet m_expandedSpecialNodes; - - /** - * Contents of this set are undefined if there is no active drag 'n drop operation. - * Additionally, you may _never_ dereference pointers in this set, just compare - * them with other pointers - */ - QSet m_dragSourceCollections; - - QHash m_collections; //I'll concide this one... :-) - mutable QHash m_childQueries; - mutable QHash m_compilationQueries; - mutable QHash m_noLabelsQueries; - mutable QMultiHash m_runningQueries; - bool m_autoExpand; // whether to expand tree after queries are done - - protected slots: - void startAnimationTick(); - void loadingAnimationTick(); -}; - - -#endif diff --git a/amarok/src/browsers/CollectionTreeView.cpp b/amarok/src/browsers/CollectionTreeView.cpp deleted file mode 100644 index dde9723e..00000000 --- a/amarok/src/browsers/CollectionTreeView.cpp +++ /dev/null @@ -1,1404 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Alexandre Pereira de Oliveira * - * Copyright (c) 2007 Ian Monroe * - * * - * This program 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 2 of the License, or (at your option) version 3 or * - * any later version accepted by the membership of KDE e.V. (or its successor approved * - * by the membership of KDE e.V.), which shall act as a proxy defined in Section 14 of * - * version 3 of the license. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "CollectionTreeView" - -#include "CollectionTreeView.h" - -#include "AmarokMimeData.h" -#include "GlobalCollectionActions.h" -#include "PopupDropperFactory.h" -#include "SvgHandler.h" -#include "browsers/CollectionSortFilterProxyModel.h" -#include "browsers/CollectionTreeItemModel.h" -#include "context/ContextView.h" -#include "context/popupdropper/libpud/PopupDropper.h" -#include "context/popupdropper/libpud/PopupDropperItem.h" -#include "core/capabilities/ActionsCapability.h" -#include "core/capabilities/BookmarkThisCapability.h" -#include "core/collections/CollectionLocation.h" -#include "core/collections/MetaQueryMaker.h" -#include "core/collections/QueryMaker.h" -#include "core/meta/Meta.h" -#include "core/support/Amarok.h" -#include "core/support/Debug.h" -#include "core-impl/collections/support/CollectionManager.h" -#include "core-impl/collections/support/TextualQueryFilter.h" -#include "core-impl/collections/support/TrashCollectionLocation.h" -#include "dialogs/TagDialog.h" -#include "playlist/PlaylistModelStack.h" -#include "scripting/scriptengine/AmarokCollectionViewScript.h" - -#include -#include -#include -#include -#include -#include // NOTE: for delete dialog, will move to CollectionCapability later - -#include -#include - -#include -#include - -using namespace Collections; - -/** - * RAII class to perform restoring of the scroll position once all queries are - * finished. DelayedScroller auto-deletes itself once its job is over (ot if it finds - * it is useless). - */ -class DelayedScroller : public QObject -{ - Q_OBJECT - - public: - DelayedScroller( CollectionTreeView *treeView, - CollectionTreeItemModelBase *treeModel, - const QModelIndex &treeModelScrollToIndex, int topOffset ) - : QObject( treeView ) - , m_treeView( treeView ) - , m_treeModel( treeModel ) - , m_topOffset( topOffset ) - { - connect( treeModel, SIGNAL(destroyed(QObject*)), SLOT(deleteLater()) ); - connect( treeModel, SIGNAL(allQueriesFinished(bool)), SLOT(slotScroll()) ); - - m_scrollToItem = m_treeModel->treeItem( treeModelScrollToIndex ); - if( m_scrollToItem ) - connect( m_scrollToItem, SIGNAL(destroyed(QObject*)), SLOT(deleteLater()) ); - else - deleteLater(); // nothing to do - } - - private slots: - void slotScroll() - { - deleteLater(); - QModelIndex idx = m_treeModel->itemIndex( m_scrollToItem ); - QSortFilterProxyModel *filterModel = m_treeView->filterModel(); - idx = filterModel ? filterModel->mapFromSource( idx ) : QModelIndex(); - QScrollBar *scrollBar = m_treeView->verticalScrollBar(); - if( !idx.isValid() || !scrollBar ) - return; - - int newTopOffset = m_treeView->visualRect( idx ).top(); - scrollBar->setValue( scrollBar->value() + (newTopOffset - m_topOffset) ); - } - - private: - CollectionTreeView *m_treeView; - CollectionTreeItemModelBase *m_treeModel; - CollectionTreeItem *m_scrollToItem; - int m_topOffset; -}; - -CollectionTreeView::CollectionTreeView( QWidget *parent) - : Amarok::PrettyTreeView( parent ) - , m_filterModel( 0 ) - , m_treeModel( 0 ) - , m_pd( 0 ) - , m_appendAction( 0 ) - , m_loadAction( 0 ) - , m_editAction( 0 ) - , m_organizeAction( 0 ) - , m_ongoingDrag( false ) -{ - setSortingEnabled( true ); - setFocusPolicy( Qt::StrongFocus ); - sortByColumn( 0, Qt::AscendingOrder ); - setSelectionMode( QAbstractItemView::ExtendedSelection ); - setSelectionBehavior( QAbstractItemView::SelectRows ); - setEditTriggers( EditKeyPressed ); - - setDragDropMode( QAbstractItemView::DragDrop ); - - connect( this, SIGNAL(collapsed(QModelIndex)), - SLOT(slotCollapsed(QModelIndex)) ); - connect( this, SIGNAL(expanded(QModelIndex)), - SLOT(slotExpanded(QModelIndex)) ); -} - -void -CollectionTreeView::setModel( QAbstractItemModel *model ) -{ - if( m_treeModel ) - disconnect( m_treeModel, 0, this, 0); - - m_treeModel = qobject_cast( model ); - if( !m_treeModel ) - return; - - connect( m_treeModel, SIGNAL(allQueriesFinished(bool)), SLOT(slotCheckAutoExpand(bool)) ); - connect( m_treeModel, SIGNAL(expandIndex(QModelIndex)), - SLOT(slotExpandIndex(QModelIndex)) ); - - if( m_filterModel ) - m_filterModel->deleteLater(); - m_filterModel = new CollectionSortFilterProxyModel( this ); - m_filterModel->setSourceModel( model ); - - QTreeView::setModel( m_filterModel ); - - QTimer::singleShot( 0, this, SLOT(slotCheckAutoExpand()) ); -} - -CollectionTreeView::~CollectionTreeView() -{ - // we don't own m_treeModel pointer - // m_filterModel will get deleted by QObject parentship -} - -void -CollectionTreeView::setLevels( const QList &levels ) -{ - if( m_treeModel ) - m_treeModel->setLevels( levels ); -} - -QList -CollectionTreeView::levels() const -{ - if( m_treeModel ) - return m_treeModel->levels(); - return QList(); -} - -void -CollectionTreeView::setLevel( int level, CategoryId::CatMenuId type ) -{ - if( !m_treeModel ) - return; - QList levels = m_treeModel->levels(); - if( type == CategoryId::None ) - { - while( levels.count() >= level ) - levels.removeLast(); - } - else - { - levels.removeAll( type ); - levels[level] = type; - } - setLevels( levels ); -} - -QSortFilterProxyModel * -CollectionTreeView::filterModel() const -{ - return m_filterModel; -} - -void -CollectionTreeView::contextMenuEvent( QContextMenuEvent *event ) -{ - if( !m_treeModel ) - return; - - QModelIndex index = indexAt( event->pos() ); - if( !index.isValid() ) - { - Amarok::PrettyTreeView::contextMenuEvent( event ); - return; - } - - QModelIndexList indices = selectedIndexes(); - - // if previously selected indices do not contain the index of the item - // currently under the mouse when context menu is invoked. - if( !indices.contains( index ) ) - { - indices.clear(); - indices << index; - setCurrentIndex( index ); - } - - //TODO: get rid of this, it's a hack. - // Put remove actions in model so we don't need access to the internal pointer in view - if( m_filterModel ) - { - QModelIndexList tmp; - foreach( const QModelIndex &idx, indices ) - { - tmp.append( m_filterModel->mapToSource( idx ) ); - } - indices = tmp; - } - - // Abort if nothing is selected - if( indices.isEmpty() ) - return; - - m_currentItems.clear(); - foreach( const QModelIndex &index, indices ) - { - if( index.isValid() && index.internalPointer() ) - m_currentItems.insert( - static_cast( index.internalPointer() ) - ); - } - - KMenu menu( this ); - - // Destroy the menu when the model is reset (collection update), so that we don't - // operate on invalid data. see BUG 190056 - connect( m_treeModel, SIGNAL(modelReset()), &menu, SLOT(deleteLater()) ); - - // create basic actions - QActionList actions = createBasicActions( indices ); - foreach( QAction *action, actions ) { - menu.addAction( action ); - } - menu.addSeparator(); - actions.clear(); - - QActionList albumActions = createCustomActions( indices ); - KMenu menuAlbum( i18n( "Album" ) ); - foreach( QAction *action, albumActions ) - { - if( !action->parent() ) - action->setParent( &menuAlbum ); - } - - if( albumActions.count() > 1 ) - { - menuAlbum.addActions( albumActions ); - menuAlbum.setIcon( KIcon( "filename-album-amarok" ) ); - menu.addMenu( &menuAlbum ); - menu.addSeparator(); - } - else if( albumActions.count() == 1 ) - { - menu.addActions( albumActions ); - } - - QActionList collectionActions = createCollectionActions( indices ); - KMenu menuCollection( i18n( "Collection" ) ); - foreach( QAction *action, collectionActions ) - { - if( !action->parent() ) - action->setParent( &menuCollection ); - } - - if( collectionActions.count() > 1 ) - { - menuCollection.setIcon( KIcon( "drive-harddisk" ) ); - menuCollection.addActions( collectionActions ); - menu.addMenu( &menuCollection ); - menu.addSeparator(); - } - else if( collectionActions.count() == 1 ) - { - menu.addActions( collectionActions ); - } - - m_currentCopyDestination = getCopyActions( indices ); - m_currentMoveDestination = getMoveActions( indices ); - - if( !m_currentCopyDestination.empty() ) - { - KMenu *copyMenu = new KMenu( i18n( "Copy to Collection" ), &menu ); - copyMenu->setIcon( KIcon( "edit-copy" ) ); - copyMenu->addActions( m_currentCopyDestination.keys() ); - menu.addMenu( copyMenu ); - } - - //Move = copy + delete from source - if( !m_currentMoveDestination.empty() ) - { - KMenu *moveMenu = new KMenu( i18n( "Move to Collection" ), &menu ); - moveMenu->setIcon( KIcon( "go-jump" ) ); - moveMenu->addActions( m_currentMoveDestination.keys() ); - menu.addMenu( moveMenu ); - } - - // create trash and delete actions - if( onlyOneCollection( indices ) ) - { - Collection *collection = getCollection( indices.first() ); - if( collection && collection->isWritable() ) - { - //TODO: don't recreate action - KAction *trashAction = new KAction( KIcon( "user-trash" ), - i18n( "Move Tracks to Trash" ), - &menu ); - trashAction->setProperty( "popupdropper_svg_id", "delete" ); - // key shortcut is only for display purposes here, actual one is - // determined by View in Model/View classes - trashAction->setShortcut( Qt::Key_Delete ); - connect( trashAction, SIGNAL(triggered(Qt::MouseButtons,Qt::KeyboardModifiers)), - SLOT(slotTrashTracks(Qt::MouseButtons,Qt::KeyboardModifiers)) ); - menu.addAction( trashAction ); - - KAction *deleteAction = new KAction( KIcon( "remove-amarok" ), - i18n( "Delete Tracks" ), - &menu ); - deleteAction->setProperty( "popupdropper_svg_id", "delete" ); - // key shortcut is only for display purposes here, actual one is - // determined by View in Model/View classes - deleteAction->setShortcut( Qt::SHIFT + Qt::Key_Delete ); - connect( deleteAction, SIGNAL(triggered(bool)), SLOT(slotDeleteTracks()) ); - menu.addAction( deleteAction ); - } - } - - // add extended actions - menu.addSeparator(); - actions += createExtendedActions( indices ); - foreach( QAction *action, actions ) { - menu.addAction( action ); - } - AmarokScript::AmarokCollectionViewScript::createScriptedActions( menu, indices ); - - menu.exec( event->globalPos() ); -} - -void -CollectionTreeView::mouseDoubleClickEvent( QMouseEvent *event ) -{ - if( event->button() == Qt::MidButton ) - { - event->accept(); - return; - } - - QModelIndex index = indexAt( event->pos() ); - if( !index.isValid() ) - { - event->accept(); - return; - } - - // code copied in PlaylistBrowserView::mouseDoubleClickEvent(), keep in sync - // mind bug 279513 - bool isExpandable = model()->hasChildren( index ); - bool wouldExpand = !visualRect( index ).contains( event->pos() ) || // clicked outside item, perhaps on expander icon - ( isExpandable && !KGlobalSettings::singleClick() ); // we're in doubleClick - if( event->button() == Qt::LeftButton && - event->modifiers() == Qt::NoModifier && - !wouldExpand ) - { - CollectionTreeItem *item = getItemFromIndex( index ); - playChildTracks( item, Playlist::OnDoubleClickOnSelectedItems ); - event->accept(); - return; - } - - PrettyTreeView::mouseDoubleClickEvent( event ); -} - -void -CollectionTreeView::mouseReleaseEvent( QMouseEvent *event ) -{ - if( m_pd ) - { - connect( m_pd, SIGNAL(fadeHideFinished()), m_pd, SLOT(deleteLater()) ); - m_pd->hide(); - m_pd = 0; - } - - QModelIndex index = indexAt( event->pos() ); - if( !index.isValid() ) - { - PrettyTreeView::mouseReleaseEvent( event ); - return; - } - - if( event->button() == Qt::MidButton ) - { - CollectionTreeItem *item = getItemFromIndex( index ); - playChildTracks( item, Playlist::OnMiddleClickOnSelectedItems ); - event->accept(); - return; - } - - PrettyTreeView::mouseReleaseEvent( event ); -} - -CollectionTreeItem * -CollectionTreeView::getItemFromIndex( QModelIndex &index ) -{ - QModelIndex filteredIndex; - if( m_filterModel ) - filteredIndex = m_filterModel->mapToSource( index ); - else - filteredIndex = index; - - if( !filteredIndex.isValid() ) - { - return 0; - } - - return static_cast( filteredIndex.internalPointer() ); -} - -void -CollectionTreeView::keyPressEvent( QKeyEvent *event ) -{ - QModelIndexList indices = selectedIndexes(); - if( indices.isEmpty() ) - { - Amarok::PrettyTreeView::keyPressEvent( event ); - return; - } - - if( m_filterModel ) - { - QModelIndexList tmp; - foreach( const QModelIndex &idx, indices ) - tmp.append( m_filterModel->mapToSource( idx ) ); - indices = tmp; - } - - m_currentItems.clear(); - foreach( const QModelIndex &index, indices ) - { - if( index.isValid() && index.internalPointer() ) - { - m_currentItems.insert( - static_cast( index.internalPointer() ) ); - } - } - - QModelIndex current = currentIndex(); - switch( event->key() ) - { - case Qt::Key_Enter: - case Qt::Key_Return: - playChildTracks( m_currentItems, Playlist::OnReturnPressedOnSelectedItems ); - return; - case Qt::Key_Delete: - if( !onlyOneCollection( indices ) ) - break; - removeTracks( m_currentItems, !( event->modifiers() & Qt::ShiftModifier ) ); - return; - case Qt::Key_Up: - if( current.parent() == QModelIndex() && current.row() == 0 ) - { - emit leavingTree(); - return; - } - break; - case Qt::Key_Down: - break; - // L and R should magically work when we get a patched version of qt - case Qt::Key_Right: - case Qt::Key_Direction_R: - expand( current ); - return; - case Qt::Key_Left: - case Qt::Key_Direction_L: - collapse( current ); - return; - default: - break; - } - Amarok::PrettyTreeView::keyPressEvent( event ); -} - -void -CollectionTreeView::dragEnterEvent( QDragEnterEvent *event ) -{ - // We want to indicate to the user that dropping to the same collection is not possible. - // CollectionTreeItemModel therefore needs to know what collection the drag originated - // so that is can play with Qt::ItemIsDropEnabled in flags() - const AmarokMimeData *mimeData = - qobject_cast( event->mimeData() ); - if( mimeData ) // drag from within Amarok - { - QSet srcCollections; - foreach( Meta::TrackPtr track, mimeData->tracks() ) - { - srcCollections.insert( track->collection() ); - } - m_treeModel->setDragSourceCollections( srcCollections ); - } - QAbstractItemView::dragEnterEvent( event ); -} - -void -CollectionTreeView::dragMoveEvent( QDragMoveEvent *event ) -{ - // this mangling is not needed for Copy/Move distinction to work, it is only needed - // for mouse cursor changing to work - if( (event->keyboardModifiers() & Qt::ShiftModifier) - && (event->possibleActions() & Qt::MoveAction) ) - { - event->setDropAction( Qt::MoveAction ); - } - else if( event->possibleActions() & Qt::CopyAction ) - { - event->setDropAction( Qt::CopyAction ); - } - - QTreeView::dragMoveEvent( event ); -} - -void -CollectionTreeView::startDrag(Qt::DropActions supportedActions) -{ - DEBUG_BLOCK - - // Make sure that the left mouse button is actually pressed. Otherwise we're prone to - // mis-detecting clicks as dragging - if( !( QApplication::mouseButtons() & Qt::LeftButton ) ) - return; - - QModelIndexList indices = selectedIndexes(); - if( indices.isEmpty() ) - return; - - // When a parent item is dragged, startDrag() is called a bunch of times. Here we - // prevent that: - if( m_ongoingDrag ) - return; - m_ongoingDrag = true; - - if( !m_pd ) - m_pd = The::popupDropperFactory()->createPopupDropper( Context::ContextView::self() ); - - if( m_pd && m_pd->isHidden() ) - { - if( m_filterModel ) - { - QModelIndexList tmp; - foreach( const QModelIndex &idx, indices ) - { - tmp.append( m_filterModel->mapToSource( idx ) ); - } - indices = tmp; - } - - QActionList actions = createBasicActions( indices ); - - QFont font; - font.setPointSize( 16 ); - font.setBold( true ); - - foreach( QAction * action, actions ) - m_pd->addItem( The::popupDropperFactory()->createItem( action ) ); - - m_currentCopyDestination = getCopyActions( indices ); - m_currentMoveDestination = getMoveActions( indices ); - - m_currentItems.clear(); - foreach( const QModelIndex &index, indices ) - { - if( index.isValid() && index.internalPointer() ) - { - m_currentItems.insert( - static_cast( index.internalPointer() ) ); - } - } - - PopupDropperItem *subItem; - - actions = createExtendedActions( indices ); - - PopupDropper *morePud = 0; - if( actions.count() > 1 ) - { - morePud = The::popupDropperFactory()->createPopupDropper( 0, true ); - - foreach( QAction *action, actions ) - morePud->addItem( The::popupDropperFactory()->createItem( action ) ); - } - else - m_pd->addItem( The::popupDropperFactory()->createItem( actions[0] ) ); - - //TODO: Keep bugging i18n team about problems with 3 dots - if ( actions.count() > 1 ) - { - subItem = m_pd->addSubmenu( &morePud, i18n( "More..." ) ); - The::popupDropperFactory()->adjustItem( subItem ); - } - - m_pd->show(); - } - - QTreeView::startDrag( supportedActions ); - debug() << "After the drag!"; - - if( m_pd ) - { - debug() << "clearing PUD"; - connect( m_pd, SIGNAL(fadeHideFinished()), m_pd, SLOT(clear()) ); - m_pd->hide(); - } - - m_ongoingDrag = false; -} - -void -CollectionTreeView::selectionChanged( const QItemSelection &selected, - const QItemSelection &deselected ) -{ - QModelIndexList indexes = selected.indexes(); - - QModelIndexList changedIndexes = indexes; - changedIndexes << deselected.indexes(); - foreach( const QModelIndex &index, changedIndexes ) - update( index ); - - if( indexes.count() < 1 ) - return; - - QModelIndex index; - if( m_filterModel ) - index = m_filterModel->mapToSource( indexes[0] ); - else - index = indexes[0]; - - CollectionTreeItem *item = - static_cast( index.internalPointer() ); - emit( itemSelected ( item ) ); -} - -void -CollectionTreeView::slotCollapsed( const QModelIndex &index ) -{ - if( !m_treeModel ) - return; - if( m_filterModel ) - m_treeModel->slotCollapsed( m_filterModel->mapToSource( index ) ); - else - m_treeModel->slotCollapsed( index ); -} - -void -CollectionTreeView::slotExpanded( const QModelIndex &index ) -{ - if( !m_treeModel ) - return; - if( m_filterModel ) - m_treeModel->slotExpanded( m_filterModel->mapToSource( index )); - else - m_treeModel->slotExpanded( index ); -} - -void -CollectionTreeView::slotExpandIndex( const QModelIndex &index ) -{ - if( !m_treeModel ) - return; - if( m_filterModel ) - expand( m_filterModel->mapFromSource( index ) ); -} - -void -CollectionTreeView::slotCheckAutoExpand( bool reallyExpand ) -{ - if( !m_filterModel || !reallyExpand ) - return; - - // Cases where root is not collections but - // for example magnatunes's plethora of genres, don't expand by default - if( m_filterModel->rowCount() > 6 ) - return; - - QModelIndexList indicesToCheck; - for( int i = 0; i < m_filterModel->rowCount(); i++ ) //need something to start for'ing with - indicesToCheck += m_filterModel->index( i, 0 ); //lowest level is fine for that - - QModelIndex current; - for( int j = 0; j < indicesToCheck.size(); j++) - { - current = indicesToCheck.at( j ); - if( m_filterModel->rowCount( current ) < 4 ) - { //don't expand if many results - expand( current ); - for( int i = 0; i < m_filterModel->rowCount( current ); i++ ) - indicesToCheck += m_filterModel->index( i, 0, current ); - } - } -} - -void -CollectionTreeView::playChildTracks( CollectionTreeItem *item, Playlist::AddOptions insertMode ) -{ - QSet items; - items.insert( item ); - - playChildTracks( items, insertMode ); -} - -void -CollectionTreeView::playChildTracks( const QSet &items, - Playlist::AddOptions insertMode ) -{ - if( !m_treeModel ) - return; - //Ensure that if a parent and child are both selected we ignore the child - QSet parents( cleanItemSet( items ) ); - - //Store the type of playlist insert to be done and cause a slot to be invoked when the tracklist has been generated. - AmarokMimeData *mime = dynamic_cast( - m_treeModel->mimeData( QList::fromSet( parents ) ) ); - m_playChildTracksMode.insert( mime, insertMode ); - connect( mime, SIGNAL(trackListSignal(Meta::TrackList)), this, - SLOT(playChildTracksSlot(Meta::TrackList)) ); - mime->getTrackListSignal(); -} - -void -CollectionTreeView::playChildTracksSlot( Meta::TrackList list ) //slot -{ - AmarokMimeData *mime = dynamic_cast( sender() ); - - Playlist::AddOptions insertMode = m_playChildTracksMode.take( mime ); - - qStableSort( list.begin(), list.end(), Meta::Track::lessThan ); - The::playlistController()->insertOptioned( list, insertMode ); - - mime->deleteLater(); -} - -void -CollectionTreeView::organizeTracks( const QSet &items ) const -{ - DEBUG_BLOCK - if( !items.count() ) - return; - - //Create query based upon items, ensuring that if a parent and child are both - //selected we ignore the child - Collections::QueryMaker *qm = createMetaQueryFromItems( items, true ); - if( !qm ) - return; - - CollectionTreeItem *item = items.toList().first(); - while( item->isDataItem() ) - item = item->parent(); - - Collection *coll = item->parentCollection(); - CollectionLocation *location = coll->location(); - if( !location->isOrganizable() ) - { - debug() << "Collection not organizable"; - //how did we get here?? - delete location; - delete qm; - return; - } - location->prepareMove( qm, coll->location() ); -} - -void -CollectionTreeView::copySelectedToLocalCollection() -{ - DEBUG_BLOCK - - // Get the local collection - Collections::Collection *collection = 0; - const QList collections = CollectionManager::instance()->collections().keys(); - - foreach( collection, collections ) - { - if ( collection->collectionId() == "localCollection" ) - break; - } - - if( !collection ) - return; - - // Get selected items - QModelIndexList indexes = selectedIndexes(); - if( m_filterModel ) - { - QModelIndexList tmp; - foreach( const QModelIndex &idx, indexes ) - tmp.append( m_filterModel->mapToSource( idx ) ); - indexes = tmp; - } - - m_currentItems.clear(); - foreach( const QModelIndex &index, indexes ) - { - if( index.isValid() && index.internalPointer() ) - m_currentItems.insert( static_cast( index.internalPointer() ) ); - } - - copyTracks( m_currentItems, collection, false ); -} - -void -CollectionTreeView::copyTracks( const QSet &items, - Collection *destination, bool removeSources ) const -{ - DEBUG_BLOCK - - if( !destination ) - { - warning() << "collection is not writable (0-pointer)! Aborting"; - return; - } - if( !destination->isWritable() ) - { - warning() << "collection " << destination->prettyName() << " is not writable! Aborting"; - return; - } - //copied from organizeTracks. create a method for this somewhere - if( !items.count() ) - { - warning() << "No items to copy! Aborting"; - return; - } - - //Create query based upon items, ensuring that if a parent and child are both selected we ignore the child - Collections::QueryMaker *qm = createMetaQueryFromItems( items, true ); - if( !qm ) - { - warning() << "could not get qm!"; - return; - } - - CollectionTreeItem *item = items.toList().first(); - while( item->isDataItem() ) - { - item = item->parent(); - } - Collection *coll = item->parentCollection(); - CollectionLocation *source = coll->location(); - CollectionLocation *dest = destination->location(); - if( removeSources ) - { - if( !source->isWritable() ) //error - { - warning() << "We can not write to ze source!!! OMGooses!"; - delete dest; - delete source; - delete qm; - return; - } - - debug() << "starting source->prepareMove"; - source->prepareMove( qm, dest ); - } - else - { - debug() << "starting source->prepareCopy"; - source->prepareCopy( qm, dest ); - } -} - -void -CollectionTreeView::removeTracks( const QSet &items, - bool useTrash ) const -{ - DEBUG_BLOCK - - //copied from organizeTracks. create a method for this somewhere - if( !items.count() ) - return; - - //Create query based upon items, ensuring that if a parent and child are both selected we ignore the child - Collections::QueryMaker *qm = createMetaQueryFromItems( items, true ); - if( !qm ) - return; - - CollectionTreeItem *item = items.toList().first(); - while( item->isDataItem() ) - item = item->parent(); - Collection *coll = item->parentCollection(); - - CollectionLocation *source = coll->location(); - if( !source->isWritable() ) //error - { - warning() << "We can not write to ze source!!! OMGooses!"; - delete source; - delete qm; - return; - } - - if( useTrash ) - { - TrashCollectionLocation *trash = new TrashCollectionLocation(); - source->prepareMove( qm, trash ); - } - else - source->prepareRemove( qm ); -} - -void -CollectionTreeView::editTracks( const QSet &items ) const -{ - //Create query based upon items, ensuring that if a parent and child are both - //selected we ignore the child - Collections::QueryMaker *qm = createMetaQueryFromItems( items, true ); - if( !qm ) - return; - - (void)new TagDialog( qm ); //the dialog will show itself automatically as soon as it is ready -} - -void -CollectionTreeView::slotSetFilter( const QString &filter ) -{ - QString currentFilter = m_treeModel ? m_treeModel->currentFilter() : QString(); - if( !m_filterModel || !m_treeModel || filter == currentFilter ) - return; - - // special case: transitioning from non-empty to empty buffer - // -> trigger later restoring of the scroll position - if( filter.isEmpty() ) // currentFilter must not be empty then (see earlier check) - { - // take first item, descending to leaf ones if expanded. There may be better - // ways to determine what item should stay "fixed". - QModelIndex scrollToIndex = m_filterModel->index( 0, 0 ); - while( isExpanded( scrollToIndex ) && m_filterModel->rowCount( scrollToIndex ) > 0 ) - scrollToIndex = scrollToIndex.child( 0, 0 ); - int topOffset = visualRect( scrollToIndex ).top(); - - QModelIndex bottomIndex = m_filterModel->mapToSource( scrollToIndex ); - // if we have somewhere to scroll to after filter is cleared... - if( bottomIndex.isValid() ) - // auto-destroys itself - new DelayedScroller( this, m_treeModel, bottomIndex, topOffset ); - } - m_treeModel->setCurrentFilter( filter ); -} - -void -CollectionTreeView::slotAddFilteredTracksToPlaylist() -{ - if( !m_treeModel ) - return; - - // disconnect any possible earlier connection we've done - disconnect( m_treeModel, SIGNAL(allQueriesFinished(bool)), - this, SLOT(slotAddFilteredTracksToPlaylist()) ); - - if( m_treeModel->hasRunningQueries() ) - // wait for the queries to finish - connect( m_treeModel, SIGNAL(allQueriesFinished(bool)), - this, SLOT(slotAddFilteredTracksToPlaylist()) ); - else - { - // yay, we can add the tracks now - QSet items; - for( int row = 0; row < m_treeModel->rowCount(); row++ ) - { - QModelIndex idx = m_treeModel->index( row, 0 ); - CollectionTreeItem *item = idx.isValid() - ? static_cast( idx.internalPointer() ) : 0; - if( item ) - items.insert( item ); - } - if( !items.isEmpty() ) - playChildTracks( items, Playlist::OnAppendToPlaylistAction ); - emit addingFilteredTracksDone(); - } -} - -QActionList -CollectionTreeView::createBasicActions( const QModelIndexList &indices ) -{ - QActionList actions; - - if( !indices.isEmpty() ) - { - if( m_appendAction == 0 ) - { - m_appendAction = new QAction( KIcon( "media-track-add-amarok" ), - i18n( "&Add to Playlist" ), this ); - m_appendAction->setProperty( "popupdropper_svg_id", "append" ); - connect( m_appendAction, SIGNAL(triggered()), this, SLOT(slotAppendChildTracks()) ); - } - - actions.append( m_appendAction ); - - if( m_loadAction == 0 ) - { - m_loadAction = new QAction( - i18nc( "Replace the currently loaded tracks with these", - "&Replace Playlist" ), this ); - m_loadAction->setProperty( "popupdropper_svg_id", "load" ); - connect( m_loadAction, SIGNAL(triggered()), - this, SLOT(slotReplacePlaylistWithChildTracks()) ); - } - - actions.append( m_loadAction ); - } - - return actions; -} - -QActionList -CollectionTreeView::createExtendedActions( const QModelIndexList &indices ) -{ - QActionList actions; - - if( !indices.isEmpty() ) - { - { //keep the scope of item minimal - CollectionTreeItem *item = - static_cast( indices.first().internalPointer() ); - while( item->isDataItem() ) - item = item->parent(); - - Collection *collection = item->parentCollection(); - CollectionLocation* location = collection->location(); - - if( location->isOrganizable() ) - { - bool onlyOneCollection = true; - foreach( const QModelIndex &index, indices ) - { - Q_UNUSED( index ) - CollectionTreeItem *item = static_cast( - indices.first().internalPointer() ); - while( item->isDataItem() ) - item = item->parent(); - - onlyOneCollection = item->parentCollection() == collection; - if( !onlyOneCollection ) - break; - } - - if( onlyOneCollection ) - { - if( m_organizeAction == 0 ) - { - m_organizeAction = new QAction( KIcon("folder-open" ), - i18nc( "Organize Files", "Organize Files" ), this ); - m_organizeAction->setProperty( "popupdropper_svg_id", "organize" ); - connect( m_organizeAction, SIGNAL(triggered()), - this, SLOT(slotOrganize()) ); - } - actions.append( m_organizeAction ); - } - } - delete location; - } - - //hmmm... figure out what kind of item we are dealing with.... - - if( indices.size() == 1 ) - { - debug() << "checking for global actions"; - CollectionTreeItem *item = static_cast( - indices.first().internalPointer() ); - - QActionList gActions = The::globalCollectionActions()->actionsFor( item->data() ); - foreach( QAction *action, gActions ) - { - if( action ) // Can become 0-pointer, see http://bugs.kde.org/show_bug.cgi?id=183250 - { - actions.append( action ); - debug() << "Got global action: " << action->text(); - } - } - } - - if( m_editAction == 0 ) - { - m_editAction = new QAction( KIcon( "media-track-edit-amarok" ), - i18n( "&Edit Track Details" ), this ); - setProperty( "popupdropper_svg_id", "edit" ); - connect( m_editAction, SIGNAL(triggered()), this, SLOT(slotEditTracks()) ); - } - actions.append( m_editAction ); - } - else - debug() << "invalid index or null internalPointer"; - - return actions; -} - -QActionList -CollectionTreeView::createCustomActions( const QModelIndexList &indices ) -{ - QActionList actions; - if( indices.count() == 1 ) - { - if( indices.first().isValid() && indices.first().internalPointer() ) - { - Meta::DataPtr data = static_cast( - indices.first().internalPointer() )->data(); - if( data ) - { - QScopedPointer ac( - data->create() ); - if( ac ) - { - QActionList cActions = ac->actions(); - - foreach( QAction *action, cActions ) - { - Q_ASSERT( action ); - actions.append( action ); - debug() << "Got custom action: " << action->text(); - } - } - - //check if this item can be bookmarked... - QScopedPointer btc( - data->create() ); - if( btc && btc->isBookmarkable() && btc->bookmarkAction() ) - actions.append( btc->bookmarkAction() ); - } - } - } - return actions; -} - -QActionList -CollectionTreeView::createCollectionActions( const QModelIndexList &indices ) -{ - QActionList actions; - // Extract collection whose constituent was selected - - CollectionTreeItem *item = - static_cast( indices.first().internalPointer() ); - - // Don't return any collection actions for non collection items - if( item->isDataItem() ) - return actions; - - Collection *collection = item->parentCollection(); - - // Generate CollectionCapability, test for existence - - QScopedPointer cc( - collection->create() ); - - if( cc ) - actions = cc->actions(); - - return actions; -} - - -QHash -CollectionTreeView::getCopyActions( const QModelIndexList &indices ) -{ - QHash currentCopyDestination; - - if( onlyOneCollection( indices ) ) - { - Collection *collection = getCollection( indices.first() ); - QList writableCollections; - QHash hash = - CollectionManager::instance()->collections(); - QHash::const_iterator it = - hash.constBegin(); - while( it != hash.constEnd() ) - { - Collection *coll = it.key(); - if( coll && coll->isWritable() && coll != collection ) - writableCollections.append( coll ); - ++it; - } - if( !writableCollections.isEmpty() ) - { - foreach( Collection *coll, writableCollections ) - { - QAction *action = new QAction( coll->icon(), coll->prettyName(), 0 ); - action->setProperty( "popupdropper_svg_id", "collection" ); - connect( action, SIGNAL(triggered()), this, SLOT(slotCopyTracks()) ); - - currentCopyDestination.insert( action, coll ); - } - } - } - return currentCopyDestination; -} - -QHash -CollectionTreeView::getMoveActions( const QModelIndexList &indices ) -{ - QHash currentMoveDestination; - - if( onlyOneCollection( indices ) ) - { - Collection *collection = getCollection( indices.first() ); - QList writableCollections; - QHash hash = - CollectionManager::instance()->collections(); - QHash::const_iterator it = - hash.constBegin(); - while( it != hash.constEnd() ) - { - Collection *coll = it.key(); - if( coll && coll->isWritable() && coll != collection ) - writableCollections.append( coll ); - ++it; - } - if( !writableCollections.isEmpty() ) - { - if( collection->isWritable() ) - { - foreach( Collection *coll, writableCollections ) - { - QAction *action = new QAction( coll->icon(), coll->prettyName(), 0 ); - action->setProperty( "popupdropper_svg_id", "collection" ); - connect( action, SIGNAL(triggered()), this, SLOT(slotMoveTracks()) ); - currentMoveDestination.insert( action, coll ); - } - } - } - } - return currentMoveDestination; -} - -bool CollectionTreeView::onlyOneCollection( const QModelIndexList &indices ) -{ - if( !indices.isEmpty() ) - { - Collection *collection = getCollection( indices.first() ); - foreach( const QModelIndex &index, indices ) - { - Collection *currentCollection = getCollection( index ); - if( collection != currentCollection ) - return false; - } - } - - return true; -} - -Collection * -CollectionTreeView::getCollection( const QModelIndex &index ) -{ - Collection *collection = 0; - if( index.isValid() ) - { - CollectionTreeItem *item = - static_cast( index.internalPointer() ); - while( item->isDataItem() ) - item = item->parent(); - collection = item->parentCollection(); - } - - return collection; -} - -void -CollectionTreeView::slotReplacePlaylistWithChildTracks() -{ - playChildTracks( m_currentItems, Playlist::OnReplacePlaylistAction ); -} - -void -CollectionTreeView::slotAppendChildTracks() -{ - playChildTracks( m_currentItems, Playlist::OnAppendToPlaylistAction ); -} - -void -CollectionTreeView::slotQueueChildTracks() -{ - playChildTracks( m_currentItems, Playlist::OnQueueToPlaylistAction ); -} - -void -CollectionTreeView::slotEditTracks() -{ - editTracks( m_currentItems ); -} - -void -CollectionTreeView::slotCopyTracks() -{ - if( !sender() ) - return; - if( QAction *action = dynamic_cast( sender() ) ) - copyTracks( m_currentItems, m_currentCopyDestination[ action ], false ); -} - -void -CollectionTreeView::slotMoveTracks() -{ - if( !sender() ) - return; - if ( QAction *action = dynamic_cast( sender() ) ) - copyTracks( m_currentItems, m_currentMoveDestination[ action ], true ); -} - -void -CollectionTreeView::slotTrashTracks( Qt::MouseButtons, Qt::KeyboardModifiers modifiers ) -{ - bool useTrash = !modifiers.testFlag( Qt::ShiftModifier ); - removeTracks( m_currentItems, useTrash ); -} - -void -CollectionTreeView::slotDeleteTracks() -{ - removeTracks( m_currentItems, false /* do not use trash */ ); -} - -void -CollectionTreeView::slotOrganize() -{ - if( sender() ) - { - if( QAction *action = dynamic_cast( sender() ) ) - { - Q_UNUSED( action ) - organizeTracks( m_currentItems ); - } - } -} - -QSet -CollectionTreeView::cleanItemSet( const QSet &items ) -{ - QSet parents; - foreach( CollectionTreeItem *item, items ) - { - CollectionTreeItem *tmpItem = item; - while( tmpItem ) - { - if( items.contains( tmpItem->parent() ) ) - tmpItem = tmpItem->parent(); - else - { - parents.insert( tmpItem ); - break; - } - } - } - return parents; -} - -Collections::QueryMaker * -CollectionTreeView::createMetaQueryFromItems( const QSet &items, - bool cleanItems ) const -{ - if( !m_treeModel ) - return 0; - - QSet parents = cleanItems ? cleanItemSet( items ) : items; - - QList queryMakers; - foreach( CollectionTreeItem *item, parents ) - { - Collections::QueryMaker *qm = item->queryMaker(); - for( CollectionTreeItem *tmp = item; tmp; tmp = tmp->parent() ) - tmp->addMatch( qm, m_treeModel->levelCategory( tmp->level() - 1 ) ); - Collections::addTextualFilter( qm, m_treeModel->currentFilter() ); - queryMakers.append( qm ); - } - return new Collections::MetaQueryMaker( queryMakers ); -} - -#include "CollectionTreeView.moc" // Q_OBJECTs defined in CollectionTreeView.cpp -#include "moc_CollectionTreeView.cpp" // Q_OBJECTs defined in CollectionTreeView.h diff --git a/amarok/src/browsers/CollectionTreeView.h b/amarok/src/browsers/CollectionTreeView.h deleted file mode 100644 index 1ccbde38..00000000 --- a/amarok/src/browsers/CollectionTreeView.h +++ /dev/null @@ -1,164 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Alexandre Pereira de Oliveira * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef COLLECTIONTREEVIEW_H -#define COLLECTIONTREEVIEW_H - -#include "amarok_export.h" -#include "BrowserDefines.h" -#include "widgets/PrettyTreeView.h" -#include "core/meta/forward_declarations.h" -#include "playlist/PlaylistController.h" - -#include -#include -#include - -class AmarokMimeData; -class CollectionSortFilterProxyModel; -class CollectionTreeItemModelBase; -class CollectionTreeItem; -class PopupDropper; -namespace Collections { - class Collection; - class QueryMaker; -} -class QAction; -class QSortFilterProxyModel; - -typedef QList QActionList; - -class CollectionTreeView: public Amarok::PrettyTreeView -{ - Q_OBJECT - - public: - explicit CollectionTreeView( QWidget *parent = 0 ); - ~CollectionTreeView(); - - QSortFilterProxyModel* filterModel() const; - - AMAROK_EXPORT void setLevels( const QList &levels ); - QList levels() const; - - void setLevel( int level, CategoryId::CatMenuId type ); - - void setModel( QAbstractItemModel *model ); - - //Helper function to remove children if their parent is already present - static QSet cleanItemSet( const QSet &items ); - static bool onlyOneCollection( const QModelIndexList &indices ); - static Collections::Collection *getCollection( const QModelIndex &index ); - Collections::QueryMaker* createMetaQueryFromItems( const QSet &items, bool cleanItems=true ) const; - - /** - * Copies all selected tracks to the local collection. The user can also - * choose to do on-the-fly transcoding. - */ - AMAROK_EXPORT void copySelectedToLocalCollection(); - - public slots: - void slotSetFilter( const QString &filter ); - - /** - * This should append all currently visible tracks to the playlist. Takes - * care to ensure that the tracks are added only after any pending searches - * are finished. - */ - void slotAddFilteredTracksToPlaylist(); - - void playChildTracksSlot( Meta::TrackList list ); - - signals: - /** - * This signal is emitted when slotAddFilteredTracksToPlaylist() has done its - * work. - */ - void addingFilteredTracksDone(); - - protected: - void contextMenuEvent( QContextMenuEvent *event ); - void mouseDoubleClickEvent( QMouseEvent *event ); - void mouseReleaseEvent( QMouseEvent *event ); - void keyPressEvent( QKeyEvent *event ); - void dragEnterEvent( QDragEnterEvent *event ); - void dragMoveEvent( QDragMoveEvent *event ); - void startDrag( Qt::DropActions supportedActions ); - - protected slots: - virtual void selectionChanged ( const QItemSelection & selected, const QItemSelection & deselected ); - void slotCollapsed( const QModelIndex &index ); - void slotExpanded( const QModelIndex &index ); - void slotExpandIndex( const QModelIndex &index ); - - void slotCheckAutoExpand( bool reallyExpand = true ); - - void slotReplacePlaylistWithChildTracks(); - void slotAppendChildTracks(); - void slotQueueChildTracks(); - void slotEditTracks(); - void slotCopyTracks(); - void slotMoveTracks(); - void slotTrashTracks( Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers ); - void slotDeleteTracks(); - void slotOrganize(); - - private: - // Utility function to play all items - // that have this as a parent.. - void playChildTracks( CollectionTreeItem *item, Playlist::AddOptions insertMode ); - void playChildTracks( const QSet &items, Playlist::AddOptions insertMode ); - void editTracks( const QSet &items ) const; - void organizeTracks( const QSet &items ) const; - void copyTracks( const QSet &items, Collections::Collection *destination, - bool removeSources) const; - void removeTracks( const QSet &items, bool useTrash ) const; - - // creates different actions from the different objects. - // note: you should not delete the created actions. - QActionList createBasicActions( const QModelIndexList &indcies ); - QActionList createExtendedActions( const QModelIndexList &indcies ); - QActionList createCollectionActions( const QModelIndexList &indices ); - QActionList createCustomActions( const QModelIndexList &indices ); - - QHash getCopyActions( const QModelIndexList &indcies ); - QHash getMoveActions( const QModelIndexList &indcies ); - - CollectionTreeItem* getItemFromIndex( QModelIndex &index ); - - CollectionSortFilterProxyModel *m_filterModel; - CollectionTreeItemModelBase *m_treeModel; - PopupDropper* m_pd; - QAction* m_appendAction; - QAction* m_loadAction; - QAction* m_editAction; - QAction* m_organizeAction; - - QHash m_currentCopyDestination; - QHash m_currentMoveDestination; - - QMap m_playChildTracksMode; - - QSet m_currentItems; - - bool m_ongoingDrag; - - signals: - void itemSelected( CollectionTreeItem * item ); - void leavingTree(); -}; - -#endif diff --git a/amarok/src/browsers/InfoObserver.h b/amarok/src/browsers/InfoObserver.h deleted file mode 100644 index 66550108..00000000 --- a/amarok/src/browsers/InfoObserver.h +++ /dev/null @@ -1,35 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef INFOOBSERVER_H -#define INFOOBSERVER_H - -#include "amarok_export.h" - -#include - -/** -An abstract base class for observers that wants to be notified when here is new contex information available about an active service - - @author Nikolaj Hald Nielsen -*/ -class AMAROK_EXPORT InfoObserver{ -public: - virtual void infoChanged( QVariantMap infoMap ) = 0; - virtual ~InfoObserver() {}; -}; - -#endif diff --git a/amarok/src/browsers/InfoProxy.cpp b/amarok/src/browsers/InfoProxy.cpp deleted file mode 100644 index 1785878a..00000000 --- a/amarok/src/browsers/InfoProxy.cpp +++ /dev/null @@ -1,174 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "InfoProxy.h" - -#include "App.h" -#include "core/support/Debug.h" -#include "PaletteHandler.h" - -#include - -#include - -InfoProxy * InfoProxy::m_instance = 0; - -InfoProxy * InfoProxy::instance() -{ - if ( m_instance == 0 ) - m_instance = new InfoProxy(); - - return m_instance; -} - -InfoProxy::InfoProxy() -{ - DEBUG_BLOCK; - //for testing - - QList strings; - QList weights; - - strings << "This" << "is" << "just" << "a" << "very" << "small" << "and" << "quite" << "silly" << "defalt" << "text" - << "as" << "I" << "currently" << "have" << "nothing" << "better" << "to" << "show"; - - weights << 10 << 4 << 8 << 2 << 6 << 5 << 10 << 9 << 3 << 1 << 3 << 5 << 7 << 9 << 3 << 2 << 10 << 6 << 4; - - m_storedCloud["cloud_name"] = QVariant( "test cloud" ); - m_storedCloud["cloud_strings"] = QVariant( strings ); - m_storedCloud["cloud_weights"] = QVariant( weights ); - - loadHomePage(); -} - -InfoProxy::~InfoProxy() -{ -} - - -void -InfoProxy::subscribe( InfoObserver * observer ) -{ - DEBUG_BLOCK; - if( observer ) - { - m_observers.insert( observer ); - observer->infoChanged( m_storedInfo ); - } -} - -void -InfoProxy::subscribeForCloud( InfoObserver * observer ) -{ - DEBUG_BLOCK; - if( observer ) - { - m_cloudObservers.insert( observer ); - observer->infoChanged( m_storedCloud ); - } -} - -void -InfoProxy::unsubscribe( InfoObserver * observer ) -{ - m_observers.remove( observer ); - m_cloudObservers.remove( observer ); -} - -void -InfoProxy::notifyObservers( const QVariantMap &infoMap ) const -{ - foreach( InfoObserver *observer, m_observers ) - observer->infoChanged( infoMap ); -} - -void -InfoProxy::notifyCloudObservers( const QVariantMap &cloudMap ) const -{ - foreach( InfoObserver *observer, m_cloudObservers ) - observer->infoChanged( cloudMap ); -} - -void -InfoProxy::setInfo( const QVariantMap &infoMap ) -{ - m_storedInfo = infoMap; - notifyObservers( m_storedInfo ); -} - -void -InfoProxy::setCloud( const QVariantMap &cloudMap ) -{ - m_storedCloud = cloudMap; - notifyCloudObservers( m_storedCloud ); -} - -QVariantMap -InfoProxy::info() -{ - return m_storedInfo; -} - -QVariantMap -InfoProxy::cloud() -{ - return m_storedCloud; -} - -void -InfoProxy::loadHomePage() -{ - DEBUG_BLOCK - - KUrl dataUrl( KStandardDirs::locate( "data", "amarok/data/" ) ); - QString dataPath = dataUrl.path(); - - //load html - - QString htmlPath = dataPath + "info_frontpage.html"; - QFile file( htmlPath ); - if ( !file.open( QIODevice::ReadOnly | QIODevice::Text) ) - { - debug() << "error opening file. Error: " << file.error(); - return; - } - - QString html = file.readAll(); - - KUrl imageUrl( KStandardDirs::locate( "data", "amarok/images/" ) ); - QString imagePath = imageUrl.url(); - - html.replace( "_PATH_", imagePath ); - - html.replace( "{background_color}",PaletteHandler::highlightColor().lighter( 150 ).name() ); - html.replace( "{border_color}", PaletteHandler::highlightColor().lighter( 150 ).name() ); - html.replace( "{text_color}", App::instance()->palette().brush( QPalette::Text ).color().name() ); - QColor highlight( App::instance()->palette().highlight().color() ); - highlight.setHsvF( highlight.hueF(), 0.3, .95, highlight.alphaF() ); - html.replace( "{header_background_color}", highlight.name() ); - - - m_storedInfo["service_name"] = i18n( "Home" ); - m_storedInfo["main_info"] = html; - - notifyObservers( m_storedInfo ); -} - - -namespace The { - AMAROK_EXPORT InfoProxy* infoProxy() { return InfoProxy::instance(); } -} - diff --git a/amarok/src/browsers/InfoProxy.h b/amarok/src/browsers/InfoProxy.h deleted file mode 100644 index 722e5e8f..00000000 --- a/amarok/src/browsers/InfoProxy.h +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef INFOPROXY_H -#define INFOPROXY_H - -#include "amarok_export.h" -#include "InfoObserver.h" - -#include -#include - -class InfoProxy; - -namespace The { - AMAROK_EXPORT InfoProxy* infoProxy(); -} - -/** -A proxy class for relaying information from the currently active service to the ServiceEngine so it can be displayed in a plasma applet in the context view. It is a singleton and included in the "The" namespace for easy access - - @author Nikolaj Hald Nielsen -*/ -class AMAROK_EXPORT InfoProxy -{ - friend InfoProxy* infoProxy(); - - public: - static InfoProxy * instance(); - ~InfoProxy(); - - void subscribe( InfoObserver *observer ); - void subscribeForCloud( InfoObserver *observer ); - void unsubscribe( InfoObserver *observer ); - - void setInfo( const QVariantMap &infoMap ); - void setCloud( const QVariantMap &cloudMap ); - - void loadHomePage(); - - QVariantMap info(); // info about the service - QVariantMap cloud(); //cloud view for the service - - private slots: - void paletteChanged( const QPalette & palette ); - - private: - InfoProxy(); - void notifyObservers( const QVariantMap &infoMap ) const; - void notifyCloudObservers( const QVariantMap &cloudMap ) const; - QSet m_observers; - QSet m_cloudObservers; - - static InfoProxy * m_instance; - - QVariantMap m_storedInfo; - QVariantMap m_storedCloud; -}; - -#endif diff --git a/amarok/src/browsers/SingleCollectionTreeItemModel.cpp b/amarok/src/browsers/SingleCollectionTreeItemModel.cpp deleted file mode 100644 index 0584cc33..00000000 --- a/amarok/src/browsers/SingleCollectionTreeItemModel.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Alexandre Pereira de Oliveira * - * Copyright (c) 2007 Maximilian Kossick * - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "SingleCollectionTreeItemModel" - -#include "SingleCollectionTreeItemModel.h" - -#include "amarokconfig.h" -#include "browsers/CollectionTreeItem.h" -#include "core/collections/Collection.h" -#include "core/meta/Meta.h" -#include "core/support/Amarok.h" -#include "core/support/Debug.h" - -#include - -SingleCollectionTreeItemModel::SingleCollectionTreeItemModel( Collections::Collection *collection, - const QList &levelType ) - : m_collection( collection ) -{ - m_rootItem = new CollectionTreeItem( m_collection, 0, this ); - connect( collection, SIGNAL(updated()), this, SLOT(slotFilter()) ) ; - m_collections.insert( m_collection->collectionId(), CollectionRoot( m_collection, m_rootItem ) ); - //we only have one collection that, by its very nature, is always expanded - m_expandedCollections.insert( m_collection ); - - setLevels( levelType ); -} - -QVariant -SingleCollectionTreeItemModel::data(const QModelIndex &index, int role) const -{ - if( !index.isValid() ) - return QVariant(); - - CollectionTreeItem *item = static_cast( index.internalPointer() ); - return dataForItem( item, role ); -} - -Qt::ItemFlags -SingleCollectionTreeItemModel::flags(const QModelIndex &index) const -{ - Qt::ItemFlags f = CollectionTreeItemModelBase::flags( index ); - return ( f &= ~Qt::ItemIsEditable ); -} - -bool -SingleCollectionTreeItemModel::canFetchMore( const QModelIndex &parent ) const -{ - if ( !parent.isValid() ) - return m_rootItem->requiresUpdate(); - - CollectionTreeItem *item = static_cast( parent.internalPointer() ); - return item->level() < m_levelType.count() && item->requiresUpdate(); -} - -void -SingleCollectionTreeItemModel::fetchMore( const QModelIndex &parent ) -{ - CollectionTreeItem *item; - if ( parent.isValid() ) - item = static_cast( parent.internalPointer() ); - else - item = m_rootItem; - - ensureChildrenLoaded( item ); -} - -void -SingleCollectionTreeItemModel::filterChildren() -{ - markSubTreeAsDirty( m_rootItem ); - ensureChildrenLoaded( m_rootItem ); -} - -#include "moc_SingleCollectionTreeItemModel.cpp" diff --git a/amarok/src/browsers/SingleCollectionTreeItemModel.h b/amarok/src/browsers/SingleCollectionTreeItemModel.h deleted file mode 100644 index 0c2f12f9..00000000 --- a/amarok/src/browsers/SingleCollectionTreeItemModel.h +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Alexandre Pereira de Oliveira * - * Copyright (c) 2007 Maximilian Kossick * - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef SINGLECOLLECTIONTREEITEMMODEL_H -#define SINGLECOLLECTIONTREEITEMMODEL_H - -#include "amarok_export.h" -#include "CollectionTreeItemModelBase.h" -#include "core/meta/forward_declarations.h" - -#include -#include -#include - -class CollectionTreeItem; -class Collection; -//typedef QPair CollectionRoot; - - -class AMAROK_EXPORT SingleCollectionTreeItemModel: public CollectionTreeItemModelBase -{ - Q_OBJECT - - public: - SingleCollectionTreeItemModel( Collections::Collection *collection, - const QList &levelType ); - - virtual QVariant data(const QModelIndex &index, int role) const; - virtual bool canFetchMore( const QModelIndex &parent ) const; - virtual void fetchMore( const QModelIndex &parent ); - virtual Qt::ItemFlags flags(const QModelIndex &index) const; - - protected: - virtual void filterChildren(); - virtual int levelModifier() const { return 1; } - - private: - - Collections::Collection* m_collection; -}; - -#endif diff --git a/amarok/src/browsers/collectionbrowser/CollectionBrowserTreeView.cpp b/amarok/src/browsers/collectionbrowser/CollectionBrowserTreeView.cpp deleted file mode 100644 index 664d57b0..00000000 --- a/amarok/src/browsers/collectionbrowser/CollectionBrowserTreeView.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * Copyright (c) 2009 Seb Ruiz * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "CollectionBrowserTreeView.h" - -CollectionBrowserTreeView::CollectionBrowserTreeView( QWidget *parent ) - : CollectionTreeView( parent ) -{ - setMouseTracking( true ); // we want to highlight some icons if the mouse moves over it. -} - -CollectionBrowserTreeView::~CollectionBrowserTreeView() -{ -} diff --git a/amarok/src/browsers/collectionbrowser/CollectionBrowserTreeView.h b/amarok/src/browsers/collectionbrowser/CollectionBrowserTreeView.h deleted file mode 100644 index 1c6e2d3a..00000000 --- a/amarok/src/browsers/collectionbrowser/CollectionBrowserTreeView.h +++ /dev/null @@ -1,33 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * Copyright (c) 2009 Seb Ruiz * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef COLLECTIONBROWSERTREEVIEW_H -#define COLLECTIONBROWSERTREEVIEW_H - -#include "browsers/CollectionTreeView.h" - -/** - * Specialized CollectionTreeView that handles actions to top level items ( collections ) in a custom way. - */ -class CollectionBrowserTreeView : public CollectionTreeView -{ - public: - explicit CollectionBrowserTreeView( QWidget *parent = 0 ); - ~CollectionBrowserTreeView(); -}; - -#endif diff --git a/amarok/src/browsers/collectionbrowser/CollectionWidget.cpp b/amarok/src/browsers/collectionbrowser/CollectionWidget.cpp deleted file mode 100644 index d487f1b5..00000000 --- a/amarok/src/browsers/collectionbrowser/CollectionWidget.cpp +++ /dev/null @@ -1,480 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Ian Monroe * - * Copyright (c) 2008-2009 Dan Meltzer * - * Copyright (c) 2011 Ralf Engels * - * * - * This program 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 2 of the License, or (at your option) version 3 or * - * any later version accepted by the membership of KDE e.V. (or its successor approved * - * by the membership of KDE e.V.), which shall act as a proxy defined in Section 14 of * - * version 3 of the license. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "CollectionWidget" - -#include "CollectionWidget.h" - -#include "amarokconfig.h" -#include "browsers/CollectionTreeItemModel.h" -#include "browsers/CollectionTreeItemModelBase.h" -#include "browsers/SingleCollectionTreeItemModel.h" -#include "browsers/collectionbrowser/CollectionBrowserTreeView.h" -#include "core/meta/support/MetaConstants.h" -#include "core/support/Amarok.h" -#include "core/support/Debug.h" -#include "core-impl/collections/aggregate/AggregateCollection.h" -#include "core-impl/collections/support/CollectionManager.h" -#include "widgets/SearchWidget.h" -#include "widgets/PrettyTreeDelegate.h" - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -CollectionWidget *CollectionWidget::s_instance = 0; - -#define CATEGORY_LEVEL_COUNT 3 - -Q_DECLARE_METATYPE( QList ) // needed to QAction payload - -class CollectionWidget::Private -{ -public: - Private() - : treeView( 0 ) - , singleTreeView( 0 ) - , viewMode( CollectionWidget::NormalCollections ) {} - ~Private() {} - - CollectionBrowserTreeView *view( CollectionWidget::ViewMode mode ); - - CollectionBrowserTreeView *treeView; - CollectionBrowserTreeView *singleTreeView; - QStackedWidget *stack; - SearchWidget *searchWidget; - CollectionWidget::ViewMode viewMode; - - QMenu *menuLevel[CATEGORY_LEVEL_COUNT]; - QActionGroup *levelGroups[CATEGORY_LEVEL_COUNT]; -}; - -CollectionBrowserTreeView * -CollectionWidget::Private::view( CollectionWidget::ViewMode mode ) -{ - CollectionBrowserTreeView *v(0); - - switch( mode ) - { - case CollectionWidget::NormalCollections: - if( !treeView ) - { - v = new CollectionBrowserTreeView( stack ); - v->setAlternatingRowColors( true ); - v->setFrameShape( QFrame::NoFrame ); - v->setRootIsDecorated( false ); - connect( v, SIGNAL(leavingTree()), searchWidget->comboBox(), SLOT(setFocus()) ); - PrettyTreeDelegate *delegate = new PrettyTreeDelegate( v ); - v->setItemDelegate( delegate ); - CollectionTreeItemModelBase *multiModel = new CollectionTreeItemModel( QList() ); - multiModel->setParent( stack ); - v->setModel( multiModel ); - treeView = v; - } - else - { - v = treeView; - } - break; - - case CollectionWidget::UnifiedCollection: - if( !singleTreeView ) - { - v = new CollectionBrowserTreeView( stack ); - v->setAlternatingRowColors( true ); - v->setFrameShape( QFrame::NoFrame ); - Collections::AggregateCollection *aggregateColl = new Collections::AggregateCollection(); - connect( CollectionManager::instance(), - SIGNAL(collectionAdded(Collections::Collection*,CollectionManager::CollectionStatus)), - aggregateColl, - SLOT(addCollection(Collections::Collection*,CollectionManager::CollectionStatus))); - connect( CollectionManager::instance(), SIGNAL(collectionRemoved(QString)), - aggregateColl, SLOT(removeCollection(QString))); - foreach( Collections::Collection* coll, CollectionManager::instance()->viewableCollections() ) - { - aggregateColl->addCollection( coll, CollectionManager::CollectionViewable ); - } - CollectionTreeItemModelBase *singleModel = new SingleCollectionTreeItemModel( aggregateColl, QList() ); - singleModel->setParent( stack ); - v->setModel( singleModel ); - singleTreeView = v; - } - else - { - v = singleTreeView; - } - break; - } - return v; -} - -CollectionWidget::CollectionWidget( const QString &name , QWidget *parent ) - : BrowserCategory( name, parent ) - , d( new Private ) -{ - s_instance = this; - setObjectName( name ); - setMargin( 0 ); - setSpacing( 0 ); - //TODO: we have a really nice opportunity to make these info blurbs both helpful and pretty - setLongDescription( i18n( "This is where you will find your local music, as well as music from mobile audio players and CDs." ) ); - setImagePath( KStandardDirs::locate( "data", "amarok/images/hover_info_collections.png" ) ); - - // set background - if( AmarokConfig::showBrowserBackgroundImage() ) - setBackgroundImage( imagePath() ); - - // --- the box for the UI elements. - KHBox *hbox = new KHBox( this ); - d->stack = new QStackedWidget( this ); - - // -- read the current view mode from the configuration - const QMetaObject *mo = metaObject(); - const QMetaEnum me = mo->enumerator( mo->indexOfEnumerator( "ViewMode" ) ); - const QString &value = Amarok::config( "Collection Browser" ).readEntry( "View Mode" ); - int enumValue = me.keyToValue( value.toLocal8Bit().constData() ); - enumValue == -1 ? d->viewMode = NormalCollections : d->viewMode = (ViewMode) enumValue; - - // -- the search widget - d->searchWidget = new SearchWidget( hbox ); - d->searchWidget->setClickMessage( i18n( "Search collection" ) ); - - // Filter presets. UserRole is used to store the actual syntax. - KComboBox *combo = d->searchWidget->comboBox(); - const KIcon icon = KStandardGuiItem::find().icon(); - combo->addItem( icon, i18nc("@item:inlistbox Collection widget filter preset", "Added This Hour"), - QString(Meta::shortI18nForField( Meta::valCreateDate ) + ":<1h") ); - combo->addItem( icon, i18nc("@item:inlistbox Collection widget filter preset", "Added Today"), - QString(Meta::shortI18nForField( Meta::valCreateDate ) + ":<1d") ); - combo->addItem( icon, i18nc("@item:inlistbox Collection widget filter preset", "Added This Week"), - QString(Meta::shortI18nForField( Meta::valCreateDate ) + ":<1w") ); - combo->addItem( icon, i18nc("@item:inlistbox Collection widget filter preset", "Added This Month"), - QString(Meta::shortI18nForField( Meta::valCreateDate ) + ":<1m") ); - combo->insertSeparator( combo->count() ); - - QMenu *filterMenu = new QMenu( 0 ); - - using namespace CategoryId; - static const QList > levelPresets = QList >() - << ( QList() << CategoryId::AlbumArtist << CategoryId::Album ) - << ( QList() << CategoryId::Album << CategoryId::Artist ) // album artist has no sense here - << ( QList() << CategoryId::Genre << CategoryId::AlbumArtist ) - << ( QList() << CategoryId::Genre << CategoryId::AlbumArtist << CategoryId::Album ); - foreach( const QList &levels, levelPresets ) - { - QStringList categoryLabels; - foreach( CatMenuId category, levels ) - categoryLabels << CollectionTreeItemModelBase::nameForCategory( category ); - QAction *action = filterMenu->addAction( categoryLabels.join( i18nc( - "separator between collection browser level categories, i.e. the ' / ' " - "in 'Artist / Album'", " / " ) ) ); - action->setData( QVariant::fromValue( levels ) ); - } - // following catches all actions in the filter menu - connect( filterMenu, SIGNAL(triggered(QAction*)), SLOT(sortByActionPayload(QAction*)) ); - filterMenu->addSeparator(); - - // -- read the view level settings from the configuration - QList levels = readLevelsFromConfig(); - if ( levels.isEmpty() ) - levels << levelPresets.at( 0 ); // use first preset as default - - // -- generate the level menus - d->menuLevel[0] = filterMenu->addMenu( i18n( "First Level" ) ); - d->menuLevel[1] = filterMenu->addMenu( i18n( "Second Level" ) ); - d->menuLevel[2] = filterMenu->addMenu( i18n( "Third Level" ) ); - - // - fill the level menus - static const QList levelChoices = QList() - << CategoryId::AlbumArtist - << CategoryId::Artist - << CategoryId::Album - << CategoryId::Genre - << CategoryId::Composer - << CategoryId::Label; - for( int i = 0; i < CATEGORY_LEVEL_COUNT; i++ ) - { - QList usedLevelChoices = levelChoices; - QActionGroup *actionGroup = new QActionGroup( this ); - if( i > 0 ) // skip first submenu - usedLevelChoices.prepend( CategoryId::None ); - - QMenu *menuLevel = d->menuLevel[i]; - foreach( CatMenuId level, usedLevelChoices ) - { - QAction *action = menuLevel->addAction( CollectionTreeItemModelBase::nameForCategory( level ) ); - action->setData( QVariant::fromValue( level ) ); - action->setCheckable( true ); - action->setChecked( ( levels.count() > i ) ? ( levels[i] == level ) - : ( level == CategoryId::None ) ); - actionGroup->addAction( action ); - } - - d->levelGroups[i] = actionGroup; - connect( menuLevel, SIGNAL(triggered(QAction*)), SLOT(sortLevelSelected(QAction*)) ); - } - - // -- create the checkboxesh - filterMenu->addSeparator(); - QAction *showYears = filterMenu->addAction( i18n( "Show Years" ) ); - showYears->setCheckable( true ); - showYears->setChecked( AmarokConfig::showYears() ); - connect( showYears, SIGNAL(toggled(bool)), SLOT(slotShowYears(bool)) ); - - QAction *showTrackNumbers = filterMenu->addAction( i18nc("@action:inmenu", "Show Track Numbers") ); - showTrackNumbers->setCheckable( true ); - showTrackNumbers->setChecked( AmarokConfig::showTrackNumbers() ); - connect( showTrackNumbers, SIGNAL(toggled(bool)), SLOT(slotShowTrackNumbers(bool)) ); - - QAction *showCovers = filterMenu->addAction( i18n( "Show Cover Art" ) ); - showCovers->setCheckable( true ); - showCovers->setChecked( AmarokConfig::showAlbumArt() ); - connect( showCovers, SIGNAL(toggled(bool)), SLOT(slotShowCovers(bool)) ); - - - d->searchWidget->toolBar()->addSeparator(); - - KAction *toggleAction = new KAction( KIcon( "view-list-tree" ), i18n( "Merged View" ), this ); - toggleAction->setCheckable( true ); - toggleAction->setChecked( d->viewMode == CollectionWidget::UnifiedCollection ); - toggleView( d->viewMode == CollectionWidget::UnifiedCollection ); - connect( toggleAction, SIGNAL(triggered(bool)), SLOT(toggleView(bool)) ); - d->searchWidget->toolBar()->addAction( toggleAction ); - - KAction *searchMenuAction = new KAction( KIcon( "preferences-other" ), i18n( "Sort Options" ), this ); - searchMenuAction->setMenu( filterMenu ); - d->searchWidget->toolBar()->addAction( searchMenuAction ); - - QToolButton *tbutton = qobject_cast( d->searchWidget->toolBar()->widgetForAction( searchMenuAction ) ); - if( tbutton ) - tbutton->setPopupMode( QToolButton::InstantPopup ); - - setLevels( levels ); -} - -CollectionWidget::~CollectionWidget() -{ - delete d; -} - - -void -CollectionWidget::focusInputLine() -{ - return d->searchWidget->comboBox()->setFocus(); -} - -void -CollectionWidget::sortLevelSelected( QAction *action ) -{ - Q_UNUSED( action ); - - QList levels; - for( int i = 0; i < CATEGORY_LEVEL_COUNT; i++ ) - { - const QAction *action = d->levelGroups[i]->checkedAction(); - if( action ) - { - CategoryId::CatMenuId category = action->data().value(); - if( category != CategoryId::None ) - levels << category; - } - } - setLevels( levels ); -} - -void -CollectionWidget::sortByActionPayload( QAction *action ) -{ - QList levels = action->data().value >(); - if( !levels.isEmpty() ) - setLevels( levels ); -} - -void -CollectionWidget::slotShowYears( bool checked ) -{ - AmarokConfig::setShowYears( checked ); - setLevels( levels() ); -} - -void -CollectionWidget::slotShowTrackNumbers( bool checked ) -{ - AmarokConfig::setShowTrackNumbers( checked ); - setLevels( levels() ); -} - -void -CollectionWidget::slotShowCovers(bool checked) -{ - AmarokConfig::setShowAlbumArt( checked ); - setLevels( levels() ); -} - -QString -CollectionWidget::filter() const -{ - return d->searchWidget->currentText(); -} - -void CollectionWidget::setFilter( const QString &filter ) -{ - d->searchWidget->setSearchString( filter ); -} - -QList -CollectionWidget::levels() const -{ - // return const_cast( this )->view( d->viewMode )->levels(); - return d->view( d->viewMode )->levels(); -} - -void CollectionWidget::setLevels( const QList &levels ) -{ - // -- select the corrrect menu entries - QSet encounteredLevels; - for( int i = 0; i < CATEGORY_LEVEL_COUNT; i++ ) - { - CategoryId::CatMenuId category; - if( levels.count() > i ) - category = levels[i]; - else - category = CategoryId::None; - - foreach( QAction *action, d->levelGroups[i]->actions() ) - { - CategoryId::CatMenuId actionCategory = action->data().value(); - if( actionCategory == category ) - action->setChecked( true ); // unchecks other actions in the same group - action->setEnabled( !encounteredLevels.contains( actionCategory ) ); - } - - if( category != CategoryId::None ) - encounteredLevels << category; - } - - // -- set the levels in the view - d->view( d->viewMode )->setLevels( levels ); - debug() << "Sort levels:" << levels; -} - -void CollectionWidget::toggleView( bool merged ) -{ - CollectionWidget::ViewMode newMode = merged ? UnifiedCollection : NormalCollections; - CollectionBrowserTreeView *oldView = d->view( d->viewMode ); - - if( oldView ) - { - d->searchWidget->disconnect( oldView ); - oldView->disconnect( d->searchWidget ); - } - - CollectionBrowserTreeView *newView = d->view( newMode ); - connect( d->searchWidget, SIGNAL(filterChanged(QString)), - newView, SLOT(slotSetFilter(QString)) ); - connect( d->searchWidget, SIGNAL(returnPressed()), - newView, SLOT(slotAddFilteredTracksToPlaylist()) ); - // reset search string after successful adding of filtered items to playlist - connect( newView, SIGNAL(addingFilteredTracksDone()), - d->searchWidget, SLOT(setSearchString()) ); - - if( d->stack->indexOf( newView ) == -1 ) - d->stack->addWidget( newView ); - d->stack->setCurrentWidget( newView ); - const QString &filter = d->searchWidget->currentText(); - if( !filter.isEmpty() ) - { - typedef CollectionTreeItemModelBase CTIMB; - CTIMB *model = qobject_cast( newView->filterModel()->sourceModel() ); - model->setCurrentFilter( filter ); - } - - d->viewMode = newMode; - if( oldView ) - setLevels( oldView->levels() ); - - const QMetaObject *mo = metaObject(); - const QMetaEnum me = mo->enumerator( mo->indexOfEnumerator( "ViewMode" ) ); - Amarok::config( "Collection Browser" ).writeEntry( "View Mode", me.valueToKey( d->viewMode ) ); -} - -QList -CollectionWidget::readLevelsFromConfig() const -{ - QList levelNumbers = Amarok::config( "Collection Browser" ).readEntry( "TreeCategory", QList() ); - QList levels; - - // we changed "Track Artist" to "Album Artist" default before Amarok 2.8. Migrate user - // config mentioning Track Artist to Album Artist where it makes sense: - static const int OldArtistValue = 2; - bool albumOrAlbumArtistEncountered = false; - foreach( int levelNumber, levelNumbers ) - { - CategoryId::CatMenuId category; - if( levelNumber == OldArtistValue ) - { - if( albumOrAlbumArtistEncountered ) - category = CategoryId::Artist; - else - category = CategoryId::AlbumArtist; - } - else - category = CategoryId::CatMenuId( levelNumber ); - - levels << category; - if( category == CategoryId::Album || category == CategoryId::AlbumArtist ) - albumOrAlbumArtistEncountered = true; - } - - return levels; -} - -CollectionBrowserTreeView* -CollectionWidget::currentView() -{ - return d->view( d->viewMode ); -} - -CollectionWidget::ViewMode -CollectionWidget::viewMode() const -{ - return d->viewMode; -} - -SearchWidget* -CollectionWidget::searchWidget() -{ - return d->searchWidget; -} - -#include "moc_CollectionWidget.cpp" diff --git a/amarok/src/browsers/collectionbrowser/CollectionWidget.h b/amarok/src/browsers/collectionbrowser/CollectionWidget.h deleted file mode 100644 index 71f93207..00000000 --- a/amarok/src/browsers/collectionbrowser/CollectionWidget.h +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Ian Monroe * - * * - * This program 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 2 of the License, or (at your option) version 3 or * - * any later version accepted by the membership of KDE e.V. (or its successor approved * - * by the membership of KDE e.V.), which shall act as a proxy defined in Section 14 of * - * version 3 of the license. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_COLLECTION_WIDGET -#define AMAROK_COLLECTION_WIDGET - -#include "browsers/BrowserCategory.h" - -class QAction; -class CollectionBrowserTreeView; -class SearchWidget; - -class CollectionWidget : public BrowserCategory -{ - Q_OBJECT - Q_ENUMS( ViewMode ) - - public: - enum ViewMode - { - UnifiedCollection, - NormalCollections - }; - - CollectionWidget( const QString &name , QWidget *parent ); - ~CollectionWidget(); - static CollectionWidget *instance() { return s_instance; } - - - QString filter() const; - - /** - * Apply a filter to the tree view. - * @param filter The filter to apply. - */ - void setFilter( const QString &filter ); - - /** Return the current views selected levels */ - QList levels() const; - - /** Set the current views selected levels */ - void setLevels( const QList &levels ); - - void focusInputLine(); - CollectionBrowserTreeView *currentView(); - SearchWidget *searchWidget(); - ViewMode viewMode() const; - - public slots: - void sortLevelSelected( QAction * ); - void sortByActionPayload( QAction * ); - void slotShowYears( bool checked ); - void slotShowTrackNumbers( bool checked ); - void slotShowCovers( bool checked ); - - void toggleView( bool merged ); - - private: - QList readLevelsFromConfig() const; - - class Private; - Private *const d; - static CollectionWidget *s_instance; - - CollectionWidget( const CollectionWidget& ); - CollectionWidget& operator=( const CollectionWidget& ); -}; - -#endif diff --git a/amarok/src/browsers/filebrowser/DirPlaylistTrackFilterProxyModel.cpp b/amarok/src/browsers/filebrowser/DirPlaylistTrackFilterProxyModel.cpp deleted file mode 100644 index b3c4eec0..00000000 --- a/amarok/src/browsers/filebrowser/DirPlaylistTrackFilterProxyModel.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Casey Link * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "DirPlaylistTrackFilterProxyModel.h" - -#include "core/playlists/PlaylistFormat.h" -#include "core-impl/meta/file/File.h" - -#include -#include - -DirPlaylistTrackFilterProxyModel::DirPlaylistTrackFilterProxyModel( QObject *parent ) - : KDirSortFilterProxyModel( parent ) -{ -} - -bool -DirPlaylistTrackFilterProxyModel::filterAcceptsRow( int source_row, - const QModelIndex& source_parent ) const -{ - QModelIndex index = sourceModel()->index( source_row, 0, source_parent ); - - QVariant qvar = index.data( KDirModel::FileItemRole ); - if( !qvar.canConvert() ) - return false; - - KFileItem item = qvar.value(); - - if( item.name() == "." ) - return false; - - if( item.isDir() || - Playlists::isPlaylist( item.url() ) || - MetaFile::Track::isTrack( item.url() ) ) - { - return QSortFilterProxyModel::filterAcceptsRow( source_row, source_parent ); - } - - return false; -} diff --git a/amarok/src/browsers/filebrowser/DirPlaylistTrackFilterProxyModel.h b/amarok/src/browsers/filebrowser/DirPlaylistTrackFilterProxyModel.h deleted file mode 100644 index c88e06e4..00000000 --- a/amarok/src/browsers/filebrowser/DirPlaylistTrackFilterProxyModel.h +++ /dev/null @@ -1,38 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Casey Link * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef DIRPLAYLISTTRACKFILTERPROXYMODEL_H -#define DIRPLAYLISTTRACKFILTERPROXYMODEL_H - -#include - -/** - * A proxy model to filter out KFileItems that aren't either directories, playlists or - * tracks. Filters the "." directory, too. Designed to be used with KDirOperator as - * it uses KDirModel::FileItemRole to retrieve the KFileItem - */ -class DirPlaylistTrackFilterProxyModel : public KDirSortFilterProxyModel -{ - Q_OBJECT - - public: - explicit DirPlaylistTrackFilterProxyModel( QObject *parent = 0 ); - - protected: - virtual bool filterAcceptsRow( int source_row, const QModelIndex &source_parent ) const; -}; - -#endif // DIRPLAYLISTTRACKFILTERPROXYMODEL_H diff --git a/amarok/src/browsers/filebrowser/FileBrowser.cpp b/amarok/src/browsers/filebrowser/FileBrowser.cpp deleted file mode 100644 index 46281cd9..00000000 --- a/amarok/src/browsers/filebrowser/FileBrowser.cpp +++ /dev/null @@ -1,630 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Nikolaj Hald Nielsen * - * Copyright (c) 2010 Casey Link * - * Copyright (c) 2010 Téo Mrnjavac * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "FileBrowser" - -#include "FileBrowser.h" -#include "FileBrowser_p.h" -#include "moc_FileBrowser_p.cpp" - -#include "amarokconfig.h" -#include "EngineController.h" -#include "core/support/Amarok.h" -#include "core/support/Components.h" -#include "core/support/Debug.h" -#include "core-impl/meta/file/File.h" -#include "browsers/BrowserBreadcrumbItem.h" -#include "browsers/BrowserCategoryList.h" -#include "browsers/filebrowser/DirPlaylistTrackFilterProxyModel.h" -#include "browsers/filebrowser/FileView.h" -#include "playlist/PlaylistController.h" -#include "widgets/SearchWidget.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -static const QString placesString( "places://" ); -static const KUrl placesUrl( placesString ); - -FileBrowser::Private::Private( FileBrowser *parent ) - : placesModel( 0 ) - , q( parent ) -{ - KHBox *topHBox = new KHBox( q ); - - KToolBar *navigationToolbar = new KToolBar( topHBox ); - navigationToolbar->setToolButtonStyle( Qt::ToolButtonIconOnly ); - navigationToolbar->setIconDimensions( 16 ); - - backAction = KStandardAction::back( q, SLOT(back()), topHBox ); - forwardAction = KStandardAction::forward( q, SLOT(forward()), topHBox ); - backAction->setEnabled( false ); - forwardAction->setEnabled( false ); - - upAction = KStandardAction::up( q, SLOT(up()), topHBox ); - homeAction = KStandardAction::home( q, SLOT(home()), topHBox ); - refreshAction = new KAction( KIcon("view-refresh"), i18n( "Refresh" ), topHBox ); - QObject::connect( refreshAction, SIGNAL(triggered(bool)), q, SLOT(refresh()) ); - - navigationToolbar->addAction( backAction ); - navigationToolbar->addAction( forwardAction ); - navigationToolbar->addAction( upAction ); - navigationToolbar->addAction( homeAction ); - navigationToolbar->addAction( refreshAction ); - - searchWidget = new SearchWidget( topHBox, false ); - searchWidget->setClickMessage( i18n( "Filter Files" ) ); - - fileView = new FileView( q ); -} - -FileBrowser::Private::~Private() -{ - writeConfig(); -} - -void -FileBrowser::Private::readConfig() -{ - const KUrl homeUrl( QDir::homePath() ); - const KUrl savedUrl = Amarok::config( "File Browser" ).readEntry( "Current Directory", homeUrl ); - bool useHome( true ); - // fall back to $HOME if the saved dir has since disappeared or is a remote one - if( savedUrl.isLocalFile() ) - { - QDir dir( savedUrl.path() ); - if( dir.exists() ) - useHome = false; - } - else if( KIO::NetAccess::exists( savedUrl, KIO::NetAccess::DestinationSide, 0 ) ) - { - useHome = false; - } - currentPath = useHome ? homeUrl : savedUrl; -} - -void -FileBrowser::Private::writeConfig() -{ - Amarok::config( "File Browser" ).writeEntry( "Current Directory", kdirModel->dirLister()->url() ); -} - -BreadcrumbSiblingList -FileBrowser::Private::siblingsForDir( const KUrl &path ) -{ - BreadcrumbSiblingList siblings; - if( path.protocol() == "places" ) - { - for( int i = 0; i < placesModel->rowCount(); i++ ) - { - QModelIndex idx = placesModel->index( i, 0 ); - - QString name = idx.data( Qt::DisplayRole ).toString(); - QString url = idx.data( KFilePlacesModel::UrlRole ).toString(); - if( url.isEmpty() ) - // the place perhaps needs mounting, use places url instead - url = placesString + name; - siblings << BreadcrumbSibling( idx.data( Qt::DecorationRole ).value(), - name, url ); - } - } - else if( path.isLocalFile() ) - { - QDir dir( path.toLocalFile() ); - dir.cdUp(); - foreach( const QString &item, dir.entryList( QDir::Dirs | QDir::NoDotAndDotDot ) ) - { - siblings << BreadcrumbSibling( KIcon( "folder-amarok" ), item, - dir.absoluteFilePath( item ) ); - } - } - - return siblings; -} - -void -FileBrowser::Private::updateNavigateActions() -{ - backAction->setEnabled( !backStack.isEmpty() ); - forwardAction->setEnabled( !forwardStack.isEmpty() ); - upAction->setEnabled( currentPath != placesUrl ); -} - -void -FileBrowser::Private::restoreDefaultHeaderState() -{ - fileView->hideColumn( 3 ); - fileView->hideColumn( 4 ); - fileView->hideColumn( 5 ); - fileView->hideColumn( 6 ); - fileView->sortByColumn( 0, Qt::AscendingOrder ); -} - -void -FileBrowser::Private::restoreHeaderState() -{ - QFile file( Amarok::saveLocation() + "file_browser_layout" ); - if( !file.open( QIODevice::ReadOnly ) ) - { - restoreDefaultHeaderState(); - return; - } - if( !fileView->header()->restoreState( file.readAll() ) ) - { - warning() << "invalid header state saved, unable to restore. Restoring defaults"; - restoreDefaultHeaderState(); - return; - } -} - -void -FileBrowser::Private::saveHeaderState() -{ - //save the state of the header (column size and order). Yay, another QByteArray thingie... - KSaveFile file( Amarok::saveLocation() + "file_browser_layout" ); - if( !file.open( QIODevice::WriteOnly ) ) - { - warning() << "unable to save header state"; - return; - } - if( file.write( fileView->header()->saveState() ) < 0 ) - { - warning() << "unable to save header state, writing failed"; - return; - } - if( !file.finalize() ) - { - warning() << "failed to write header state"; - return; - } -} - -void -FileBrowser::Private::updateHeaderState() -{ - // this slot is triggered right after model change, when currentPath is not yet updated - if( fileView->model() == mimeFilterProxyModel && currentPath == placesUrl ) - // we are transitioning from places to files - restoreHeaderState(); -} - -FileBrowser::FileBrowser( const char *name, QWidget *parent ) - : BrowserCategory( name, parent ) - , d( new FileBrowser::Private( this ) ) -{ - setLongDescription( i18n( "The file browser lets you browse files anywhere on your system, " - "regardless of whether these files are part of your local collection. " - "You can then add these files to the playlist as well as perform basic " - "file operations." ) - ); - setImagePath( KStandardDirs::locate( "data", "amarok/images/hover_info_files.png" ) ); - - // set background - if( AmarokConfig::showBrowserBackgroundImage() ) - setBackgroundImage( imagePath() ); - - initView(); -} - -void -FileBrowser::initView() -{ - d->bottomPlacesModel = new FilePlacesModel( this ); - connect( d->bottomPlacesModel, SIGNAL(setupDone(QModelIndex,bool)), - SLOT(setupDone(QModelIndex,bool)) ); - d->placesModel = new QSortFilterProxyModel( this ); - d->placesModel->setSourceModel( d->bottomPlacesModel ); - d->placesModel->setSortRole( -1 ); - d->placesModel->setDynamicSortFilter( true ); - d->placesModel->setFilterRole( KFilePlacesModel::HiddenRole ); - // HiddenRole is bool, but QVariant( false ).toString() gives "false" - d->placesModel->setFilterFixedString( "false" ); - d->placesModel->setObjectName( "PLACESMODEL"); - - d->kdirModel = new DirBrowserModel( this ); - d->mimeFilterProxyModel = new DirPlaylistTrackFilterProxyModel( this ); - d->mimeFilterProxyModel->setSourceModel( d->kdirModel ); - d->mimeFilterProxyModel->setSortCaseSensitivity( Qt::CaseInsensitive ); - d->mimeFilterProxyModel->setFilterCaseSensitivity( Qt::CaseInsensitive ); - d->mimeFilterProxyModel->setDynamicSortFilter( true ); - connect( d->searchWidget, SIGNAL(filterChanged(QString)), - d->mimeFilterProxyModel, SLOT(setFilterFixedString(QString)) ); - - d->fileView->setModel( d->mimeFilterProxyModel ); - d->fileView->header()->setContextMenuPolicy( Qt::ActionsContextMenu ); - d->fileView->header()->setVisible( true ); - d->fileView->setDragEnabled( true ); - d->fileView->setSortingEnabled( true ); - d->fileView->setSelectionMode( QAbstractItemView::ExtendedSelection ); - d->readConfig(); - d->restoreHeaderState(); - - setDir( d->currentPath ); - - for( int i = 0, columns = d->fileView->model()->columnCount(); i < columns ; ++i ) - { - QAction *action = - new QAction( d->fileView->model()->headerData( i, Qt::Horizontal ).toString(), - d->fileView->header() - ); - d->fileView->header()->addAction( action ); - d->columnActions.append( action ); - action->setCheckable( true ); - if( !d->fileView->isColumnHidden( i ) ) - action->setChecked( true ); - connect( action, SIGNAL(toggled(bool)), this, SLOT(toggleColumn(bool)) ); - } - - connect( d->fileView->header(), SIGNAL(geometriesChanged()), - SLOT(updateHeaderState()) ); - connect( d->fileView, SIGNAL(navigateToDirectory(QModelIndex)), - SLOT(slotNavigateToDirectory(QModelIndex)) ); - connect( d->fileView, SIGNAL(refreshBrowser()), - SLOT(refresh()) ); -} - -FileBrowser::~FileBrowser() -{ - if( d->fileView->model() == d->mimeFilterProxyModel && d->currentPath != placesUrl ) - d->saveHeaderState(); - delete d; -} - -void -FileBrowser::toggleColumn( bool toggled ) -{ - int index = d->columnActions.indexOf( qobject_cast< QAction* >( sender() ) ); - if( index != -1 ) - { - if( toggled ) - d->fileView->showColumn( index ); - else - d->fileView->hideColumn( index ); - } -} - -QString -FileBrowser::currentDir() const -{ - if( d->currentPath.isLocalFile() ) - return d->currentPath.toLocalFile(); - else - return d->currentPath.url(); -} - -void -FileBrowser::slotNavigateToDirectory( const QModelIndex &index ) -{ - if( d->currentPath == placesUrl ) - { - QString url = index.data( KFilePlacesModel::UrlRole ).value(); - - if( !url.isEmpty() ) - { - d->backStack.push( d->currentPath ); - d->forwardStack.clear(); // navigating resets forward stack - setDir( KUrl( url ) ); - } - else - { - //check if this url needs setup/mounting - if( index.data( KFilePlacesModel::SetupNeededRole ).value() ) - { - d->bottomPlacesModel->requestSetup( d->placesModel->mapToSource( index ) ); - } - else - warning() << __PRETTY_FUNCTION__ << "empty places url that doesn't need setup?"; - } - } - else - { - KFileItem file = index.data( KDirModel::FileItemRole ).value(); - - if( file.isDir() ) - { - d->backStack.push( d->currentPath ); - d->forwardStack.clear(); // navigating resets forward stack - setDir( file.url() ); - } - else - warning() << __PRETTY_FUNCTION__ << "called for non-directory"; - } -} - - -void -FileBrowser::addItemActivated( const QString &callbackString ) -{ - if( callbackString.isEmpty() ) - return; - - KUrl newPath; - // we have been called with a places name, it means that we'll probably have to mount - // the place - if( callbackString.startsWith( placesString ) ) - { - QString name = callbackString.mid( placesString.length() ); - for( int i = 0; i < d->placesModel->rowCount(); i++ ) - { - QModelIndex idx = d->placesModel->index( i, 0 ); - if( idx.data().toString() == name ) - { - if( idx.data( KFilePlacesModel::SetupNeededRole ).toBool() ) - { - d->bottomPlacesModel->requestSetup( d->placesModel->mapToSource( idx ) ); - return; - } - newPath = idx.data( KFilePlacesModel::UrlRole ).toString(); - break; - } - } - if( newPath.isEmpty() ) - { - warning() << __PRETTY_FUNCTION__ << "name" << name << "not found under Places"; - return; - } - } - else - newPath = callbackString; - - d->backStack.push( d->currentPath ); - d->forwardStack.clear(); // navigating resets forward stack - setDir( KUrl( newPath ) ); -} - -void -FileBrowser::setupAddItems() -{ - clearAdditionalItems(); - - if( d->currentPath == placesUrl ) - return; // no more items to add - - QString workingUrl = d->currentPath.prettyUrl( KUrl::RemoveTrailingSlash ); - int currentPosition = 0; - - QString name; - QString callback; - BreadcrumbSiblingList siblings; - - // find QModelIndex of the NON-HIDDEN closestItem - QModelIndex placesIndex; - KUrl tempUrl = d->currentPath; - do - { - placesIndex = d->bottomPlacesModel->closestItem( tempUrl ); - if( !placesIndex.isValid() ) - break; // no valid index even in the bottom model - placesIndex = d->placesModel->mapFromSource( placesIndex ); - if( placesIndex.isValid() ) - break; // found shown placesindex, good! - - if( tempUrl.upUrl() == tempUrl ) - break; // prevent infinite loop - tempUrl = tempUrl.upUrl(); - } while( true ); - - // special handling for the first additional item - if( placesIndex.isValid() ) - { - name = placesIndex.data( Qt::DisplayRole ).toString(); - callback = placesIndex.data( KFilePlacesModel::UrlRole ).toString(); - - KUrl currPlaceUrl = d->placesModel->data( placesIndex, KFilePlacesModel::UrlRole ).toUrl(); - currentPosition = currPlaceUrl.url( KUrl::AddTrailingSlash ).length(); - } - else - { - QRegExp threeSlashes( "^[^/]*/[^/]*/[^/]*/" ); - if( workingUrl.indexOf( threeSlashes ) == 0 ) - currentPosition = threeSlashes.matchedLength(); - else - currentPosition = workingUrl.length(); - - callback = workingUrl.left( currentPosition ); - name = callback; - if( name == "file:///" ) - name = '/'; // just niceness - else - name.remove( QRegExp( "/$" ) ); - } - /* always provide siblings for places, regardless of what first item is; this also - * work-arounds bug 312639, where creating KUrl with accented chars crashes */ - siblings = d->siblingsForDir( placesUrl ); - addAdditionalItem( new BrowserBreadcrumbItem( name, callback, siblings, this ) ); - - // other additional items - while( !workingUrl.midRef( currentPosition ).isEmpty() ) - { - int nextPosition = workingUrl.indexOf( '/', currentPosition ) + 1; - if( nextPosition <= 0 ) - nextPosition = workingUrl.length(); - - name = workingUrl.mid( currentPosition, nextPosition - currentPosition ); - name.remove( QRegExp( "/$" ) ); - callback = workingUrl.left( nextPosition ); - - siblings = d->siblingsForDir( callback ); - addAdditionalItem( new BrowserBreadcrumbItem( name, callback, siblings, this ) ); - - currentPosition = nextPosition; - } - - if( parentList() ) - parentList()->childViewChanged(); // emits viewChanged() which causes breadCrumb update -} - -void -FileBrowser::reActivate() -{ - d->backStack.push( d->currentPath ); - d->forwardStack.clear(); // navigating resets forward stack - setDir( placesUrl ); -} - -void -FileBrowser::setDir( const KUrl &dir ) -{ - if( dir == placesUrl ) - { - if( d->currentPath != placesUrl ) - { - d->saveHeaderState(); - d->fileView->setModel( d->placesModel ); - d->fileView->setSelectionMode( QAbstractItemView::SingleSelection ); - d->fileView->header()->setVisible( false ); - d->fileView->setDragEnabled( false ); - } - } - else - { - // if we are currently showing "places" we need to remember to change the model - // back to the regular file model - if( d->currentPath == placesUrl ) - { - d->fileView->setModel( d->mimeFilterProxyModel ); - d->fileView->setSelectionMode( QAbstractItemView::ExtendedSelection ); - d->fileView->setDragEnabled( true ); - d->fileView->header()->setVisible( true ); - } - - d->kdirModel->dirLister()->openUrl( dir ); - } - - d->currentPath = dir; - d->updateNavigateActions(); - setupAddItems(); - // set the first item as current so that keyboard navigation works - new DelayedActivator( d->fileView ); -} - -void -FileBrowser::back() -{ - if( d->backStack.isEmpty() ) - return; - - d->forwardStack.push( d->currentPath ); - setDir( d->backStack.pop() ); -} - -void -FileBrowser::forward() -{ - if( d->forwardStack.isEmpty() ) - return; - - d->backStack.push( d->currentPath ); - // no clearing forward stack here! - setDir( d->forwardStack.pop() ); -} - -void -FileBrowser::up() -{ - if( d->currentPath == placesUrl ) - return; // nothing to do, we consider places as the root view - - KUrl upUrl = d->currentPath.upUrl(); - if( upUrl == d->currentPath ) // apparently, we cannot go up withn url - upUrl = placesUrl; - - d->backStack.push( d->currentPath ); - d->forwardStack.clear(); // navigating resets forward stack - setDir( upUrl ); -} - -void -FileBrowser::home() -{ - d->backStack.push( d->currentPath ); - d->forwardStack.clear(); // navigating resets forward stack - setDir( KUrl( QDir::homePath() ) ); -} - -void -FileBrowser::refresh() -{ - setDir( d->currentPath ); -} - -void -FileBrowser::setupDone( const QModelIndex &index, bool success ) -{ - if( success ) - { - QString url = index.data( KFilePlacesModel::UrlRole ).value(); - if( !url.isEmpty() ) - { - d->backStack.push( d->currentPath ); - d->forwardStack.clear(); // navigating resets forward stack - setDir( url ); - } - } -} - -DelayedActivator::DelayedActivator( QAbstractItemView *view ) - : QObject( view ) - , m_view( view ) -{ - QAbstractItemModel *model = view->model(); - if( !model ) - { - deleteLater(); - return; - } - - // short-cut for already-filled models - if( model->rowCount() > 0 ) - { - slotRowsInserted( QModelIndex(), 0 ); - return; - } - - connect( model, SIGNAL(rowsInserted(QModelIndex,int,int)), - SLOT(slotRowsInserted(QModelIndex,int)) ); - - connect( model, SIGNAL(destroyed(QObject*)), SLOT(deleteLater()) ); - connect( model, SIGNAL(layoutChanged()), SLOT(deleteLater()) ); - connect( model, SIGNAL(modelReset()), SLOT(deleteLater()) ); -} - -void -DelayedActivator::slotRowsInserted( const QModelIndex &parent, int start ) -{ - QAbstractItemModel *model = m_view->model(); - if( model ) - { - // prevent duplicate calls, deleteLater() may fire REAL later - disconnect( model, 0, this, 0 ); - QModelIndex idx = model->index( start, 0, parent ); - m_view->selectionModel()->setCurrentIndex( idx, QItemSelectionModel::NoUpdate ); - } - deleteLater(); -} - -#include "moc_FileBrowser.cpp" diff --git a/amarok/src/browsers/filebrowser/FileBrowser.h b/amarok/src/browsers/filebrowser/FileBrowser.h deleted file mode 100644 index 9870154d..00000000 --- a/amarok/src/browsers/filebrowser/FileBrowser.h +++ /dev/null @@ -1,122 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef FILEBROWSERMKII_H -#define FILEBROWSERMKII_H - -#include "browsers/BrowserCategory.h" - -#include - -class QAbstractItemView; -class QModelIndex; - -class FileBrowser : public BrowserCategory -{ - Q_OBJECT - -public: - FileBrowser( const char *name, QWidget *parent ); - ~FileBrowser(); - - virtual void setupAddItems(); - - /** - * Navigate to a specific directory - */ - void setDir( const KUrl &dir ); - - /** - * Return the path of the currently shown dir. - */ - QString currentDir() const; - -protected slots: - void slotNavigateToDirectory( const QModelIndex &index ); - - void addItemActivated( const QString &callback ); - - virtual void reActivate(); - - /** - * Shows/hides the columns as selected in the context menu of the header of the - * file view. - * @param toggled the visibility state of a column in the context menu. - */ - void toggleColumn( bool toggled ); - - /** - * Go backward in history - */ - void back(); - - /** - * Go forward in history - */ - void forward(); - - /** - * Navigates up one level in the path shown - */ - void up(); - - /** - * Navigates to home directory - */ - void home(); - - /* - * Refreshes current directory - */ - void refresh(); - - /** - * Handle results of tryiong to setup an item in "places" that needed mouting or other - * special setup. - * @param index the index that we tried to setup - * @param success did the setup succeed? - */ - void setupDone( const QModelIndex &index, bool success ); - -private slots: - void initView(); - -private: - class Private; - Private *const d; - - Q_PRIVATE_SLOT( d, void updateHeaderState() ) -}; - -/** - * Helper class that calls setCurrentIndex on a model view as soon as the model - * adds a row and then it auto-deletes itself. - */ -class DelayedActivator : public QObject -{ - Q_OBJECT - - public: - explicit DelayedActivator( QAbstractItemView *view ); - - private slots: - void slotRowsInserted( const QModelIndex &parent, int start ); - - private: - QAbstractItemView *m_view; -}; - -#endif // FILEBROWSERMKII_H diff --git a/amarok/src/browsers/filebrowser/FileBrowser_p.h b/amarok/src/browsers/filebrowser/FileBrowser_p.h deleted file mode 100644 index b5545cf6..00000000 --- a/amarok/src/browsers/filebrowser/FileBrowser_p.h +++ /dev/null @@ -1,162 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Nikolaj Hald Nielsen * - * Copyright (c) 2010 Casey Link * - * Copyright (c) 2010 Téo Mrnjavac * - * Copyright (c) 2010 Rick W. Chen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_FILEBROWSER_P_H -#define AMAROK_FILEBROWSER_P_H - -#include "FileBrowser.h" - -#include "browsers/BrowserBreadcrumbItem.h" - -#include -#include -#include - -#include -#include - -class QSortFilterProxyModel; -class DirBrowserModel; -class SearchWidget; -class FileView; -class KAction; -class KFilePlacesModel; -class DirPlaylistTrackFilterProxyModel; - -template -class UniqueStack : public QStack -{ - public: - inline void push( const T &t ) - { - if( QStack::isEmpty() || t != QStack::top() ) - QStack::push( t ); - } -}; - -class FileBrowser::Private -{ -public: - Private( FileBrowser *parent ); - ~Private(); - - void readConfig(); - void writeConfig(); - void restoreHeaderState(); - void saveHeaderState(); - - void updateNavigateActions(); - BreadcrumbSiblingList siblingsForDir( const KUrl &path ); - - void updateHeaderState(); - - QList columnActions; //!< Maintains the mapping action<->column - - KFilePlacesModel *bottomPlacesModel; - QSortFilterProxyModel *placesModel; - - DirBrowserModel *kdirModel; - DirPlaylistTrackFilterProxyModel *mimeFilterProxyModel; - - SearchWidget *searchWidget; - - KUrl currentPath; - FileView *fileView; - - KAction *upAction; - KAction *homeAction; - KAction *refreshAction; - - KAction *backAction; - KAction *forwardAction; - - UniqueStack backStack; - UniqueStack forwardStack; - -private: - void restoreDefaultHeaderState(); - - FileBrowser *const q; -}; - -class DirBrowserModel : public KDirModel -{ - Q_OBJECT - -public: - DirBrowserModel( QObject *parent = 0 ) : KDirModel( parent ) - { - updateRowHeight(); - connect( KGlobalSettings::self(), SIGNAL(appearanceChanged()), SLOT(updateRowHeight()) ); - } - - virtual ~DirBrowserModel() {} - - virtual QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const - { - if( role == Qt::SizeHintRole ) - return QSize( 1, rowHeight ); - else - return KDirModel::data( index, role ); - } - -private slots: - void updateRowHeight() - { - QFont font; - rowHeight = QFontMetrics( font ).height() + 4; - } - -private: - int rowHeight; -}; - -class FilePlacesModel : public KFilePlacesModel -{ - Q_OBJECT - -public: - FilePlacesModel( QObject *parent = 0 ) : KFilePlacesModel( parent ) - { - updateRowHeight(); - connect( KGlobalSettings::self(), SIGNAL(appearanceChanged()), SLOT(updateRowHeight()) ); - } - - virtual ~FilePlacesModel() {} - - virtual QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const - { - if( role == Qt::SizeHintRole ) - return QSize( 1, rowHeight ); - else - return KFilePlacesModel::data( index, role ); - } - -private slots: - void updateRowHeight() - { - QFont font; - rowHeight = QFontMetrics( font ).height() + 4; - } - -private: - int rowHeight; -}; - -#endif /* AMAROK_FILEBROWSER_P_H */ diff --git a/amarok/src/browsers/filebrowser/FileView.cpp b/amarok/src/browsers/filebrowser/FileView.cpp deleted file mode 100644 index 20f06418..00000000 --- a/amarok/src/browsers/filebrowser/FileView.cpp +++ /dev/null @@ -1,613 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Nikolaj Hald Nielsen * - * Copyright (c) 2010 Casey Link * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "FileView" - -#include "FileView.h" - -#include "EngineController.h" -#include "PaletteHandler.h" -#include "PopupDropperFactory.h" -#include "SvgHandler.h" -#include "context/ContextView.h" -#include "context/popupdropper/libpud/PopupDropper.h" -#include "context/popupdropper/libpud/PopupDropperItem.h" -#include "core/playlists/PlaylistFormat.h" -#include "core/support/Debug.h" -#include "core-impl/collections/support/CollectionManager.h" -#include "core-impl/collections/support/FileCollectionLocation.h" -#include "core-impl/meta/file/File.h" -#include "core-impl/playlists/types/file/PlaylistFileSupport.h" -#include "core-impl/support/TrackLoader.h" -#include "dialogs/TagDialog.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -FileView::FileView( QWidget *parent ) - : Amarok::PrettyTreeView( parent ) - , m_appendAction( 0 ) - , m_loadAction( 0 ) - , m_editAction( 0 ) - , m_moveToTrashAction( 0 ) - , m_deleteAction( 0 ) - , m_pd( 0 ) - , m_ongoingDrag( false ) -{ - setFrameStyle( QFrame::NoFrame ); - setItemsExpandable( false ); - setRootIsDecorated( false ); - setAlternatingRowColors( true ); - setUniformRowHeights( true ); - setEditTriggers( EditKeyPressed ); - - The::paletteHandler()->updateItemView( this ); - connect( The::paletteHandler(), SIGNAL(newPalette(QPalette)), - SLOT(newPalette(QPalette)) ); -} - -void -FileView::contextMenuEvent( QContextMenuEvent *e ) -{ - if( !model() ) - return; - - //trying to do fancy stuff while showing places only leads to tears! - if( model()->objectName() == "PLACESMODEL" ) - { - e->accept(); - return; - } - - QModelIndexList indices = selectedIndexes(); - // Abort if nothing is selected - if( indices.isEmpty() ) - return; - - KMenu menu; - foreach( QAction *action, actionsForIndices( indices, PlaylistAction ) ) - menu.addAction( action ); - menu.addSeparator(); - - // Create Copy/Move to menu items - // ported from old filebrowser - QList writableCollections; - QHash hash = - CollectionManager::instance()->collections(); - QHash::const_iterator it = - hash.constBegin(); - while( it != hash.constEnd() ) - { - Collections::Collection *coll = it.key(); - if( coll && coll->isWritable() ) - writableCollections.append( coll ); - ++it; - } - if( !writableCollections.isEmpty() ) - { - QMenu *copyMenu = new QMenu( i18n( "Copy to Collection" ), &menu ); - copyMenu->setIcon( KIcon( "edit-copy" ) ); - foreach( Collections::Collection *coll, writableCollections ) - { - CollectionAction *copyAction = new CollectionAction( coll, &menu ); - connect( copyAction, SIGNAL(triggered()), this, SLOT(slotPrepareCopyTracks()) ); - copyMenu->addAction( copyAction ); - } - menu.addMenu( copyMenu ); - - QMenu *moveMenu = new QMenu( i18n( "Move to Collection" ), &menu ); - moveMenu->setIcon( KIcon( "go-jump" ) ); - foreach( Collections::Collection *coll, writableCollections ) - { - CollectionAction *moveAction = new CollectionAction( coll, &menu ); - connect( moveAction, SIGNAL(triggered()), this, SLOT(slotPrepareMoveTracks()) ); - moveMenu->addAction( moveAction ); - } - menu.addMenu( moveMenu ); - } - foreach( QAction *action, actionsForIndices( indices, OrganizeAction ) ) - menu.addAction( action ); - menu.addSeparator(); - - foreach( QAction *action, actionsForIndices( indices, EditAction ) ) - menu.addAction( action ); - - menu.exec( e->globalPos() ); -} - -void -FileView::mouseReleaseEvent( QMouseEvent *event ) -{ - QModelIndex index = indexAt( event->pos() ); - if( !index.isValid() ) - { - PrettyTreeView::mouseReleaseEvent( event ); - return; - } - - if( state() == QAbstractItemView::NoState && event->button() == Qt::MidButton ) - { - addIndexToPlaylist( index, Playlist::OnMiddleClickOnSelectedItems ); - event->accept(); - return; - } - - KFileItem file = index.data( KDirModel::FileItemRole ).value(); - if( state() == QAbstractItemView::NoState && - event->button() == Qt::LeftButton && - event->modifiers() == Qt::NoModifier && - KGlobalSettings::singleClick() && - ( file.isDir() || file.isNull() ) ) - { - emit navigateToDirectory( index ); - event->accept(); - return; - } - - PrettyTreeView::mouseReleaseEvent( event ); -} - -void -FileView::mouseDoubleClickEvent( QMouseEvent *event ) -{ - QModelIndex index = indexAt( event->pos() ); - if( !index.isValid() ) - { - event->accept(); - return; - } - - // swallow middle-button double-clicks - if( event->button() == Qt::MidButton ) - { - event->accept(); - return; - } - - if( event->button() == Qt::LeftButton ) - { - KFileItem file = index.data( KDirModel::FileItemRole ).value(); - KUrl url = file.url(); - if( !file.isNull() && ( Playlists::isPlaylist( url ) || MetaFile::Track::isTrack( url ) ) ) - addIndexToPlaylist( index, Playlist::OnDoubleClickOnSelectedItems ); - else - emit navigateToDirectory( index ); - - event->accept(); - return; - } - - PrettyTreeView::mouseDoubleClickEvent( event ); -} - -void -FileView::keyPressEvent( QKeyEvent *event ) -{ - QModelIndex index = currentIndex(); - if( !index.isValid() ) - return; - - switch( event->key() ) - { - case Qt::Key_Enter: - case Qt::Key_Return: - { - KFileItem file = index.data( KDirModel::FileItemRole ).value(); - KUrl url = file.url(); - if( !file.isNull() && ( Playlists::isPlaylist( url ) || MetaFile::Track::isTrack( url ) ) ) - // right, we test the current item, but then add the selection to playlist - addSelectionToPlaylist( Playlist::OnReturnPressedOnSelectedItems ); - else - emit navigateToDirectory( index ); - - return; - } - case Qt::Key_Delete: - slotMoveToTrash( Qt::NoButton, event->modifiers() ); - break; - case Qt::Key_F5: - emit refreshBrowser(); - break; - default: - break; - } - - QTreeView::keyPressEvent( event ); -} - -void -FileView::slotAppendToPlaylist() -{ - addSelectionToPlaylist( Playlist::OnAppendToPlaylistAction ); -} - -void -FileView::slotReplacePlaylist() -{ - addSelectionToPlaylist( Playlist::OnReplacePlaylistAction ); -} - -void -FileView::slotEditTracks() -{ - Meta::TrackList tracks = tracksForEdit(); - if( !tracks.isEmpty() ) - { - TagDialog *dialog = new TagDialog( tracks, this ); - dialog->show(); - } -} - -void -FileView::slotPrepareMoveTracks() -{ - if( m_moveDestinationCollection ) - return; - - CollectionAction *action = dynamic_cast( sender() ); - if( !action ) - return; - - m_moveDestinationCollection = action->collection(); - - const KFileItemList list = selectedItems(); - if( list.isEmpty() ) - return; - - // prevent bug 313003, require full metadata - TrackLoader* dl = new TrackLoader( TrackLoader::FullMetadataRequired ); // auto-deletes itself - connect( dl, SIGNAL(finished(Meta::TrackList)), SLOT(slotMoveTracks(Meta::TrackList)) ); - dl->init( list.urlList() ); -} - -void -FileView::slotPrepareCopyTracks() -{ - if( m_copyDestinationCollection ) - return; - - CollectionAction *action = dynamic_cast( sender() ); - if( !action ) - return; - - m_copyDestinationCollection = action->collection(); - - const KFileItemList list = selectedItems(); - if( list.isEmpty() ) - return; - - // prevent bug 313003, require full metadata - TrackLoader* dl = new TrackLoader( TrackLoader::FullMetadataRequired ); // auto-deletes itself - connect( dl, SIGNAL(finished(Meta::TrackList)), SLOT(slotCopyTracks(Meta::TrackList)) ); - dl->init( list.urlList() ); -} - -void -FileView::slotCopyTracks( const Meta::TrackList& tracks ) -{ - if( !m_copyDestinationCollection ) - return; - - QSet collections; - foreach( const Meta::TrackPtr &track, tracks ) - { - collections.insert( track->collection() ); - } - - if( collections.count() == 1 ) - { - Collections::Collection *sourceCollection = collections.values().first(); - Collections::CollectionLocation *source; - if( sourceCollection ) - source = sourceCollection->location(); - else - source = new Collections::FileCollectionLocation(); - - Collections::CollectionLocation *destination = m_copyDestinationCollection.data()->location(); - source->prepareCopy( tracks, destination ); - } - else - warning() << "Cannot handle copying tracks from multiple collections, doing nothing to be safe"; - - m_copyDestinationCollection.clear(); -} - -void -FileView::slotMoveTracks( const Meta::TrackList& tracks ) -{ - if( !m_moveDestinationCollection ) - return; - - QSet collections; - foreach( const Meta::TrackPtr &track, tracks ) - { - collections.insert( track->collection() ); - } - - if( collections.count() == 1 ) - { - Collections::Collection *sourceCollection = collections.values().first(); - Collections::CollectionLocation *source; - if( sourceCollection ) - source = sourceCollection->location(); - else - source = new Collections::FileCollectionLocation(); - - Collections::CollectionLocation *destination = m_moveDestinationCollection.data()->location(); - source->prepareMove( tracks, destination ); - } - else - warning() << "Cannot handle moving tracks from multiple collections, doing nothing to be safe"; - - m_moveDestinationCollection.clear(); -} - -QList -FileView::actionsForIndices( const QModelIndexList &indices, ActionType type ) -{ - QList actions; - - if( indices.isEmpty() ) - return actions; // get out of here! - - if( !m_appendAction ) - { - m_appendAction = new QAction( KIcon( "media-track-add-amarok" ), i18n( "&Add to Playlist" ), - this ); - m_appendAction->setProperty( "popupdropper_svg_id", "append" ); - connect( m_appendAction, SIGNAL(triggered()), this, SLOT(slotAppendToPlaylist()) ); - } - if( type & PlaylistAction ) - actions.append( m_appendAction ); - - if( !m_loadAction ) - { - m_loadAction = new QAction( i18nc( "Replace the currently loaded tracks with these", - "&Replace Playlist" ), this ); - m_loadAction->setProperty( "popupdropper_svg_id", "load" ); - connect( m_loadAction, SIGNAL(triggered()), this, SLOT(slotReplacePlaylist()) ); - } - if( type & PlaylistAction ) - actions.append( m_loadAction ); - - if( !m_moveToTrashAction ) - { - m_moveToTrashAction = new KAction( KIcon( "user-trash" ), i18n( "&Move to Trash" ), this ); - m_moveToTrashAction->setProperty( "popupdropper_svg_id", "delete_file" ); - // key shortcut is only for display purposes here, actual one is determined by View in Model/View classes - m_moveToTrashAction->setShortcut( Qt::Key_Delete ); - connect( m_moveToTrashAction, SIGNAL(triggered(Qt::MouseButtons,Qt::KeyboardModifiers)), - this, SLOT(slotMoveToTrash(Qt::MouseButtons,Qt::KeyboardModifiers)) ); - } - if( type & OrganizeAction ) - actions.append( m_moveToTrashAction ); - - if( !m_deleteAction ) - { - m_deleteAction = new KAction( KIcon( "remove-amarok" ), i18n( "&Delete" ), this ); - m_deleteAction->setProperty( "popupdropper_svg_id", "delete_file" ); - // key shortcut is only for display purposes here, actual one is determined by View in Model/View classes - m_deleteAction->setShortcut( Qt::SHIFT + Qt::Key_Delete ); - connect( m_deleteAction, SIGNAL(triggered(bool)), SLOT(slotDelete()) ); - } - if( type & OrganizeAction ) - actions.append( m_deleteAction ); - - if( !m_editAction ) - { - m_editAction = new QAction( KIcon( "media-track-edit-amarok" ), - i18n( "&Edit Track Details" ), this ); - m_editAction->setProperty( "popupdropper_svg_id", "edit" ); - connect( m_editAction, SIGNAL(triggered()), this, SLOT(slotEditTracks()) ); - } - if( type & EditAction ) - { - actions.append( m_editAction ); - Meta::TrackList tracks = tracksForEdit(); - m_editAction->setVisible( !tracks.isEmpty() ); - } - - return actions; -} - -void -FileView::addSelectionToPlaylist( Playlist::AddOptions options ) -{ - addIndicesToPlaylist( selectedIndexes(), options ); -} - -void -FileView::addIndexToPlaylist( const QModelIndex &idx, Playlist::AddOptions options ) -{ - addIndicesToPlaylist( QModelIndexList() << idx, options ); -} - -void -FileView::addIndicesToPlaylist( QModelIndexList indices, Playlist::AddOptions options ) -{ - if( indices.isEmpty() ) - return; - - // let tracks & playlists appear in playlist as they are shown in the view: - qSort( indices ); - - QList urls; - foreach( const QModelIndex &index, indices ) - { - KFileItem file = index.data( KDirModel::FileItemRole ).value(); - KUrl url = file.url(); - if( file.isDir() || Playlists::isPlaylist( url ) || MetaFile::Track::isTrack( url ) ) - { - urls << file.url(); - } - } - - The::playlistController()->insertOptioned( urls, options ); -} - -void -FileView::startDrag( Qt::DropActions supportedActions ) -{ - //setSelectionMode( QAbstractItemView::NoSelection ); - // When a parent item is dragged, startDrag() is called a bunch of times. Here we prevent that: - m_dragMutex.lock(); - if( m_ongoingDrag ) - { - m_dragMutex.unlock(); - return; - } - m_ongoingDrag = true; - m_dragMutex.unlock(); - - if( !m_pd ) - m_pd = The::popupDropperFactory()->createPopupDropper( Context::ContextView::self() ); - - if( m_pd && m_pd->isHidden() ) - { - QModelIndexList indices = selectedIndexes(); - - QList actions = actionsForIndices( indices ); - - QFont font; - font.setPointSize( 16 ); - font.setBold( true ); - - foreach( QAction *action, actions ) - m_pd->addItem( The::popupDropperFactory()->createItem( action ) ); - - m_pd->show(); - } - - QTreeView::startDrag( supportedActions ); - - if( m_pd ) - { - connect( m_pd, SIGNAL(fadeHideFinished()), m_pd, SLOT(clear()) ); - m_pd->hide(); - } - - m_dragMutex.lock(); - m_ongoingDrag = false; - m_dragMutex.unlock(); -} - -KFileItemList -FileView::selectedItems() const -{ - KFileItemList items; - QModelIndexList indices = selectedIndexes(); - if( indices.isEmpty() ) - return items; - - foreach( const QModelIndex& index, indices ) - { - KFileItem item = index.data( KDirModel::FileItemRole ).value(); - items << item; - } - return items; -} - -Meta::TrackList -FileView::tracksForEdit() const -{ - Meta::TrackList tracks; - - QModelIndexList indices = selectedIndexes(); - if( indices.isEmpty() ) - return tracks; - - foreach( const QModelIndex &index, indices ) - { - KFileItem item = index.data( KDirModel::FileItemRole ).value(); - Meta::TrackPtr track = CollectionManager::instance()->trackForUrl( item.url() ); - if( track ) - tracks << track; - } - return tracks; -} - -void -FileView::slotMoveToTrash( Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers ) -{ - Q_UNUSED( buttons ) - DEBUG_BLOCK - - QModelIndexList indices = selectedIndexes(); - if( indices.isEmpty() ) - return; - - const bool deleting = modifiers.testFlag( Qt::ShiftModifier ); - QString caption; - QString labelText; - if( deleting ) - { - caption = i18nc( "@title:window", "Confirm Delete" ); - labelText = i18np( "Are you sure you want to delete this item?", - "Are you sure you want to delete these %1 items?", - indices.count() ); - } - else - { - caption = i18nc( "@title:window", "Confirm Move to Trash" ); - labelText = i18np( "Are you sure you want to move this item to trash?", - "Are you sure you want to move these %1 items to trash?", - indices.count() ); - } - - KUrl::List urls; - QStringList filepaths; - foreach( const QModelIndex& index, indices ) - { - KFileItem file = index.data( KDirModel::FileItemRole ).value(); - filepaths << file.localPath(); - urls << file.url(); - } - - KGuiItem confirmButton = deleting ? KStandardGuiItem::del() : KStandardGuiItem::remove(); - - if( KMessageBox::warningContinueCancelList( this, labelText, filepaths, caption, confirmButton ) != KMessageBox::Continue ) - return; - - if( deleting ) - { - KIO::del( urls, KIO::HideProgressInfo ); - return; - } - - KIO::trash( urls, KIO::HideProgressInfo ); -} - -void -FileView::slotDelete() -{ - slotMoveToTrash( Qt::NoButton, Qt::ShiftModifier ); -} diff --git a/amarok/src/browsers/filebrowser/FileView.h b/amarok/src/browsers/filebrowser/FileView.h deleted file mode 100644 index 96ef4c1b..00000000 --- a/amarok/src/browsers/filebrowser/FileView.h +++ /dev/null @@ -1,121 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Nikolaj Hald Nielsen * - * Copyright (c) 2010 Casey Link * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_FILEVIEW_H -#define AMAROK_FILEVIEW_H - -#include "core/collections/Collection.h" -#include "core/meta/forward_declarations.h" -#include "playlist/PlaylistController.h" -#include "widgets/PrettyTreeView.h" - -#include - -#include -#include -#include -#include - -class PopupDropper; - -/** -* Stores a collection associated with an action for move/copy to collection -*/ -class CollectionAction : public QAction -{ - public: - explicit CollectionAction( Collections::Collection *coll, QObject *parent = 0 ) - : QAction( parent ) - , m_collection( coll ) - { - setText( m_collection->prettyName() ); - } - - Collections::Collection *collection() const - { - return m_collection; - } - - private: - Collections::Collection *m_collection; -}; - - -class FileView : public Amarok::PrettyTreeView -{ - Q_OBJECT - -public: - FileView( QWidget *parent ); - -signals: - void navigateToDirectory( const QModelIndex &index ); - void refreshBrowser(); - -protected slots: - void slotAppendToPlaylist(); - void slotReplacePlaylist(); - void slotEditTracks(); - void slotPrepareMoveTracks(); - void slotPrepareCopyTracks(); - void slotMoveTracks( const Meta::TrackList &tracks ); - void slotCopyTracks( const Meta::TrackList &tracks ); - void slotMoveToTrash( Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers ); - void slotDelete(); - -protected: - enum ActionType { - PlaylistAction = 1, - OrganizeAction = 2, - EditAction = 4, - AllActions = PlaylistAction | OrganizeAction | EditAction - }; - QList actionsForIndices( const QModelIndexList &indices, ActionType type = AllActions ); - void addSelectionToPlaylist( Playlist::AddOptions options ); - - /** - * Convenience. - */ - void addIndexToPlaylist( const QModelIndex &idx, Playlist::AddOptions options ); - void addIndicesToPlaylist( QModelIndexList indices, Playlist::AddOptions options ); - - virtual void contextMenuEvent( QContextMenuEvent *e ); - virtual void mouseReleaseEvent( QMouseEvent *event ); - virtual void mouseDoubleClickEvent( QMouseEvent *event ); - - virtual void keyPressEvent( QKeyEvent *event ); - - virtual void startDrag( Qt::DropActions supportedActions ); - KFileItemList selectedItems() const; - -private: - Meta::TrackList tracksForEdit() const; - - QAction *m_appendAction; - QAction *m_loadAction; - QAction *m_editAction; - QAction *m_moveToTrashAction; - QAction *m_deleteAction; - - PopupDropper *m_pd; - QMutex m_dragMutex; - bool m_ongoingDrag; - QWeakPointer m_moveDestinationCollection; - QWeakPointer m_copyDestinationCollection; -}; - -#endif // end include guard diff --git a/amarok/src/browsers/hover_info_template.html b/amarok/src/browsers/hover_info_template.html deleted file mode 100644 index 31eb5c2a..00000000 --- a/amarok/src/browsers/hover_info_template.html +++ /dev/null @@ -1,69 +0,0 @@ - - - - - -

- %%NAME%% -
-
- %%DESCRIPTION%% -
-
- - diff --git a/amarok/src/browsers/playlistbrowser/APGCategory.cpp b/amarok/src/browsers/playlistbrowser/APGCategory.cpp deleted file mode 100644 index d7abfb57..00000000 --- a/amarok/src/browsers/playlistbrowser/APGCategory.cpp +++ /dev/null @@ -1,152 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008-2012 Soren Harward * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "APGCategory.h" - -#include "amarokconfig.h" -#include "playlistgenerator/ConstraintSolver.h" -#include "playlistgenerator/PresetModel.h" -#include "widgets/PrettyTreeView.h" - -#include -#include -#include - -#include -#include -#include -#include -#include - -PlaylistBrowserNS::APGCategory::APGCategory( QWidget* ) - : BrowserCategory ( "APG", 0 ) -{ - m_qualityFactor = AmarokConfig::qualityFactorAPG(); - - setPrettyName( i18n( "Automated Playlist Generator" ) ); - setShortDescription( i18n("Create playlists by specifying criteria") ); - setIcon( KIcon( "playlist-generator" ) ); - - // set background - if( AmarokConfig::showBrowserBackgroundImage() ) - setBackgroundImage( imagePath() ); - - setLongDescription( i18n("Create playlists by specifying criteria") ); - - setContentsMargins( 0, 0, 0, 0 ); - - APG::PresetModel* presetmodel = APG::PresetModel::instance(); - connect( presetmodel, SIGNAL(lock(bool)), this, SLOT(setDisabled(bool)) ); - - /* Create the toolbar -- Qt's Designer doesn't let us put a toolbar - * anywhere except in a MainWindow, so we've got to create it by hand here. */ - QToolBar* toolBar_Actions = new QToolBar( this ); - toolBar_Actions->setMovable( false ); - toolBar_Actions->setFloatable( false ); - toolBar_Actions->setIconSize( QSize( 22, 22 ) ); - toolBar_Actions->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Preferred ); - - QAction* a; - a = toolBar_Actions->addAction( KIcon( "list-add-amarok" ), i18n("Add new preset") ); - connect( a, SIGNAL(triggered(bool)), presetmodel, SLOT(addNew()) ); - - a = toolBar_Actions->addAction( KIcon( "document-properties-amarok" ), i18n("Edit selected preset") ); - a->setEnabled( false ); - connect( a, SIGNAL(triggered(bool)), presetmodel, SLOT(edit()) ); - connect( this, SIGNAL(validIndexSelected(bool)), a, SLOT(setEnabled(bool)) ); - - a = toolBar_Actions->addAction( KIcon( "list-remove-amarok" ), i18n("Delete selected preset") ); - a->setEnabled( false ); - connect( a, SIGNAL(triggered(bool)), presetmodel, SLOT(removeActive()) ); - connect( this, SIGNAL(validIndexSelected(bool)), a, SLOT(setEnabled(bool)) ); - - a = toolBar_Actions->addAction( KIcon( "document-import-amarok" ), i18n("Import a new preset") ); - a->setEnabled( true ); - connect( a, SIGNAL(triggered(bool)), presetmodel, SLOT(import()) ); - - a = toolBar_Actions->addAction( KIcon( "document-export-amarok" ), i18n("Export the selected preset") ); - a->setEnabled( false ); - connect( a, SIGNAL(triggered(bool)), presetmodel, SLOT(exportActive()) ); - connect( this, SIGNAL(validIndexSelected(bool)), a, SLOT(setEnabled(bool)) ); - - toolBar_Actions->addSeparator(); - - a = toolBar_Actions->addAction( KIcon( "go-next-amarok" ), i18n("Run APG with selected preset") ); - a->setEnabled( false ); - connect( a, SIGNAL(triggered(bool)), this, SLOT(runGenerator()) ); - connect( this, SIGNAL(validIndexSelected(bool)), a, SLOT(setEnabled(bool)) ); - - /* Create the preset list view */ - QLabel* label_Title = new QLabel( i18n("APG Presets"), this ); - label_Title->setAlignment( Qt::AlignCenter ); - - Amarok::PrettyTreeView* listView = new Amarok::PrettyTreeView( this ); - listView->setHeaderHidden( true ); - listView->setRootIsDecorated( false ); - listView->setModel( presetmodel ); - listView->setSelectionMode( QAbstractItemView::SingleSelection ); - listView->setFrameShape( QFrame::NoFrame ); - listView->setAutoFillBackground( false ); - connect( listView->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(activeChanged(QModelIndex)) ); - connect( listView, SIGNAL(doubleClicked(QModelIndex)), presetmodel, SLOT(editPreset(QModelIndex)) ); - - // Speed/Quality tradeoff slider - QLabel* label_Tradeoff = new QLabel( i18n("Generator Optimization"), this ); - label_Tradeoff->setAlignment( Qt::AlignCenter ); - - QFrame* qual_Frame = new QFrame( this ); - QLabel* label_Speed = new QLabel( i18n("Speed"), qual_Frame ); - QSlider* qual_Slider = new QSlider( Qt::Horizontal, qual_Frame ); - qual_Slider->setRange( 0, APG::ConstraintSolver::QUALITY_RANGE ); - qual_Slider->setValue( m_qualityFactor ); - connect( qual_Slider, SIGNAL(sliderMoved(int)), this, SLOT (setQualityFactor(int)) ); - QLabel* label_Quality = new QLabel( i18n("Accuracy"), qual_Frame ); - - QLayout* qf_Layout = new QHBoxLayout( qual_Frame ); - qf_Layout->addWidget( label_Speed ); - qf_Layout->addWidget( qual_Slider ); - qf_Layout->addWidget( label_Quality ); - qual_Frame->setLayout( qf_Layout ); - - QMetaObject::connectSlotsByName( this ); -} - -PlaylistBrowserNS::APGCategory::~APGCategory() -{ - APG::PresetModel::destroy(); - AmarokConfig::setQualityFactorAPG( m_qualityFactor ); - AmarokConfig::self()->writeConfig(); -} - -void -PlaylistBrowserNS::APGCategory::activeChanged( const QModelIndex& index ) -{ - APG::PresetModel::instance()->setActivePreset( index ); - emit validIndexSelected( index.isValid() ); -} - -void -PlaylistBrowserNS::APGCategory::setQualityFactor( int f ) -{ - m_qualityFactor = f; -} - -void -PlaylistBrowserNS::APGCategory::runGenerator() -{ - APG::PresetModel::instance()->savePresetsToXml(); - APG::PresetModel::instance()->runGenerator( m_qualityFactor ); -} diff --git a/amarok/src/browsers/playlistbrowser/APGCategory.h b/amarok/src/browsers/playlistbrowser/APGCategory.h deleted file mode 100644 index 674130fe..00000000 --- a/amarok/src/browsers/playlistbrowser/APGCategory.h +++ /dev/null @@ -1,49 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008-2011 Soren Harward * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef APGCATEGORY_H -#define APGCATEGORY_H - -#include "browsers/BrowserCategory.h" - -#include - -namespace PlaylistBrowserNS { - - /* Playlist Browser toolbox item for the Automatic Playlist Generator */ - class APGCategory : public BrowserCategory - { - Q_OBJECT - - public: - APGCategory( QWidget* parent ); - ~APGCategory(); - - signals: - void validIndexSelected( bool ); - - private slots: - void activeChanged( const QModelIndex& ); - void setQualityFactor( int ); - void runGenerator(); - - private: - int m_qualityFactor; - }; - -} - -#endif diff --git a/amarok/src/browsers/playlistbrowser/DynamicBiasDelegate.cpp b/amarok/src/browsers/playlistbrowser/DynamicBiasDelegate.cpp deleted file mode 100644 index ba876448..00000000 --- a/amarok/src/browsers/playlistbrowser/DynamicBiasDelegate.cpp +++ /dev/null @@ -1,108 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Daniel Caleb Jones * - * Copyright (c) 2011 Ralf Engels * - * * - * This program 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 2 of the License, or (at your option) version 3 or * - * any later version accepted by the membership of KDE e.V. (or its successor approved * - * by the membership of KDE e.V.), which shall act as a proxy defined in Section 14 of * - * version 3 of the license. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "DynamicBiasDelegate.h" -#include "dynamic/DynamicModel.h" - -#include "App.h" -// #include "Bias.h" -// #include "core/support/Debug.h" - -#include -#include - -PlaylistBrowserNS::DynamicBiasDelegate::DynamicBiasDelegate( QWidget* parent ) - : QStyledItemDelegate( parent ) -{ - m_smallFont.setPointSize( m_smallFont.pointSize() - 1 ); - - m_normalFm = new QFontMetrics( m_normalFont ); - m_smallFm = new QFontMetrics( m_smallFont ); -} - -PlaylistBrowserNS::DynamicBiasDelegate::~DynamicBiasDelegate() -{ - delete m_normalFm; - delete m_smallFm; -} - -void -PlaylistBrowserNS::DynamicBiasDelegate::paint( QPainter* painter, - const QStyleOptionViewItem& option, - const QModelIndex& index ) const -{ - Dynamic::AbstractBias* bias = 0; - QVariant v; - if( index.isValid() ) { - v = index.model()->data( index, Dynamic::DynamicModel::BiasRole ); - if( v.isValid() ) - bias = qobject_cast(v.value() ); - } - - // for a bias paint the operator (e.g. a small progress bar for the part bias) in front of it - if( bias ) - { - QModelIndex parentIndex = index.parent(); - Dynamic::AbstractBias* parentBias = 0; - - const bool isRTL = QApplication::isRightToLeft(); - Q_UNUSED( isRTL ); - - v = parentIndex.model()->data( parentIndex, Dynamic::DynamicModel::BiasRole ); - if( v.isValid() ) - parentBias = qobject_cast(v.value() ); - - if( parentBias ) - { - // sub-biases have a operator drawn in front of them. - const int operatorWidth = m_smallFm->boundingRect( "mmmm" ).width(); - - // draw the selection - QApplication::style()->drawPrimitive( QStyle::PE_PanelItemViewItem, &option, painter ); - - // TODO: isRTL - - // -- paint the operator - QRect operatorRect( option.rect.x(), option.rect.y(), - operatorWidth, option.rect.height() ); - painter->setFont( m_smallFont ); - parentBias->paintOperator( painter, operatorRect, bias ); - - // -- paint the normal text - QRect textRect( option.rect.x() + operatorWidth, option.rect.y(), - option.rect.width() - operatorWidth, option.rect.height() ); - painter->setFont( m_normalFont ); - const QString text = index.data( Qt::DisplayRole ).toString(); - painter->drawText( textRect, Qt::TextWordWrap, text ); - } - else - { - QStyledItemDelegate::paint( painter, option, index ); - } - - } - else - { - QStyledItemDelegate::paint( painter, option, index ); - } - -} - - - diff --git a/amarok/src/browsers/playlistbrowser/DynamicBiasDelegate.h b/amarok/src/browsers/playlistbrowser/DynamicBiasDelegate.h deleted file mode 100644 index 2ad107b9..00000000 --- a/amarok/src/browsers/playlistbrowser/DynamicBiasDelegate.h +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Daniel Caleb Jones * - * Copyright (c) 2011 Ralf Engels * - * * - * This program 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 2 of the License, or (at your option) version 3 or * - * any later version accepted by the membership of KDE e.V. (or its successor approved * - * by the membership of KDE e.V.), which shall act as a proxy defined in Section 14 of * - * version 3 of the license. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_DYNAMICBIASDELEGATE -#define AMAROK_DYNAMICBIASDELEGATE - -#include - -namespace PlaylistBrowserNS -{ - -/** A special delegate for the dynamic playlists. - It will paint an additional operator hint in front of a bias. - e.g. a small progress bar or a "If" text. -*/ -class DynamicBiasDelegate : public QStyledItemDelegate -{ - public: - DynamicBiasDelegate( QWidget* parent = 0 ); - ~DynamicBiasDelegate(); - - void paint( QPainter* painter, - const QStyleOptionViewItem& option, - const QModelIndex& index ) const; - - private: - QFont m_normalFont; - QFont m_smallFont; - - QFontMetrics *m_normalFm; - QFontMetrics *m_smallFm; - -}; - -} - -#endif diff --git a/amarok/src/browsers/playlistbrowser/DynamicBiasDialog.cpp b/amarok/src/browsers/playlistbrowser/DynamicBiasDialog.cpp deleted file mode 100644 index cc1e78d9..00000000 --- a/amarok/src/browsers/playlistbrowser/DynamicBiasDialog.cpp +++ /dev/null @@ -1,204 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Daniel Caleb Jones * - * Copyright (c) 2009 Mark Kretschmann * - * Copyright (c) 2010,2011 Ralf Engels * - * * - * This program 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 2 of the License, or (at your option) version 3 or * - * any later version accepted by the membership of KDE e.V. (or its successor approved * - * by the membership of KDE e.V.), which shall act as a proxy defined in Section 14 of * - * version 3 of the license. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "DynamicBiasDialog.h" - -#include "core/support/Debug.h" -#include "dynamic/Bias.h" -#include "dynamic/BiasFactory.h" - -#include -#include - -#include -#include -#include -#include - -PlaylistBrowserNS::BiasDialog::BiasDialog( Dynamic::BiasPtr bias, QWidget* parent ) - : QDialog( parent ) - , m_mainLayout( 0 ) - , m_biasLayout( 0 ) - , m_descriptionLabel( 0 ) - , m_biasWidget( 0 ) - , m_origBias( bias ) - , m_bias( bias->clone() ) // m_bias is a clone -{ - setWindowTitle( i18nc( "Bias dialog window title", "Edit bias" ) ); - m_mainLayout = new QVBoxLayout( this ); - - - // -- the bias selection combo - QLabel* selectionLabel = new QLabel( i18nc("Bias selection label in bias view.", "Match Type:" ) ); - m_biasSelection = new KComboBox(); - QHBoxLayout *selectionLayout = new QHBoxLayout(); - selectionLabel->setBuddy( m_biasSelection ); - selectionLayout->addWidget( selectionLabel ); - selectionLayout->addWidget( m_biasSelection ); - selectionLayout->addStretch( 1 ); - m_mainLayout->addLayout( selectionLayout ); - - // -- bias itself - m_descriptionLabel = new QLabel( "" ); - m_descriptionLabel->setWordWrap( true ); - m_mainLayout->addWidget( m_descriptionLabel ); - - m_biasLayout = new QVBoxLayout(); - m_mainLayout->addLayout( m_biasLayout ); - - // -- button box - QDialogButtonBox* buttonBox = new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel ); - m_mainLayout->addWidget( buttonBox ); - - factoriesChanged(); - biasReplaced( Dynamic::BiasPtr(), m_bias ); - - connect( Dynamic::BiasFactory::instance(), SIGNAL(changed()), - this, SLOT(factoriesChanged()) ); - connect( m_biasSelection, SIGNAL(activated(int)), - this, SLOT(selectionChanged(int)) ); - connect(buttonBox, SIGNAL(accepted()), - this, SLOT(accept())); - connect(buttonBox, SIGNAL(rejected()), - this, SLOT(reject())); -} - -void PlaylistBrowserNS::BiasDialog::accept() -{ - // use the newly edited bias - m_origBias->replace( m_bias ); // tell the old bias it has just been replaced - QDialog::accept(); -} - -void PlaylistBrowserNS::BiasDialog::reject() -{ - // do nothing. - QDialog::reject(); -} - -PlaylistBrowserNS::BiasDialog::~BiasDialog() -{ } - -void -PlaylistBrowserNS::BiasDialog::factoriesChanged() -{ - m_biasSelection->clear(); - - disconnect( Dynamic::BiasFactory::instance(), SIGNAL(changed()), - this, SLOT(factoriesChanged()) ); - - // -- add all the bias types to the list - bool factoryFound = false; - QList factories = Dynamic::BiasFactory::factories(); - for( int i = 0; i < factories.count(); i++ ) - { - Dynamic::AbstractBiasFactory* factory = factories.at( i ); - m_biasSelection->addItem( factory->i18nName(), QVariant( factory->name() ) ); - - // -- set the current index if we have found our own factory - if( m_bias && factory->name() == m_bias->name() ) - { - factoryFound = true; - m_biasSelection->setCurrentIndex( i ); - m_descriptionLabel->setText( factory->i18nDescription() ); - } - } - - // -- In cases of replacement bias - if( !factoryFound ) - { - m_biasSelection->addItem( m_bias->name() ); - m_biasSelection->setCurrentIndex( m_biasSelection->count() - 1 ); - m_descriptionLabel->setText( i18n( "This bias is a replacement for another bias\n" - "which is currently not loaded or deactivated.\n" - "The original bias name was %1.", m_bias->name() ) ); - } - - connect( Dynamic::BiasFactory::instance(), SIGNAL(changed()), - this, SLOT(factoriesChanged()) ); -} - -void -PlaylistBrowserNS::BiasDialog::selectionChanged( int index ) -{ - DEBUG_BLOCK; - Q_ASSERT( m_biasSelection ); - - QString biasName = m_biasSelection->itemData( index ).toString(); - - Dynamic::BiasPtr oldBias( m_bias ); - Dynamic::BiasPtr newBias( Dynamic::BiasFactory::fromName( biasName ) ); - if( !newBias ) - { - warning() << "Could not create bias with name:"<toString() << "with" << newBias->toString(); - m_bias->replace( newBias ); // tell the old bias it has just been replaced -debug() << "replaced"; - - // -- if the new bias is AndBias, try to add the old biase(s) into it - Dynamic::AndBias *oldABias = qobject_cast(oldBias.data()); - Dynamic::AndBias *newABias = qobject_cast(newBias.data()); - if( newABias ) { - if( oldABias ) { - for( int i = 0; i < oldABias->biases().count(); i++ ) - { - newABias->appendBias( oldABias->biases()[i] ); - } - } - else - { - newABias->appendBias( oldBias ); - } - } -} - -void -PlaylistBrowserNS::BiasDialog::biasReplaced( Dynamic::BiasPtr oldBias, Dynamic::BiasPtr newBias ) -{ - Q_UNUSED( oldBias ); - - if( m_biasWidget ) - { - m_biasLayout->removeWidget( m_biasWidget ); - m_biasWidget->deleteLater(); - m_biasWidget = 0; - } - - m_bias = newBias; - if( !newBias ) - return; - - connect( newBias.data(), SIGNAL(replaced(Dynamic::BiasPtr,Dynamic::BiasPtr)), - this, SLOT(biasReplaced(Dynamic::BiasPtr,Dynamic::BiasPtr)) ); - - m_biasWidget = newBias->widget( 0 ); - if( !m_biasWidget ) - m_biasWidget = new QLabel( i18n("This bias has no settings.") ); - m_biasLayout->addWidget( m_biasWidget ); - - factoriesChanged(); // update the bias description and select the new combo entry -} - - - -#include "moc_DynamicBiasDialog.cpp" diff --git a/amarok/src/browsers/playlistbrowser/DynamicBiasDialog.h b/amarok/src/browsers/playlistbrowser/DynamicBiasDialog.h deleted file mode 100644 index edeffe30..00000000 --- a/amarok/src/browsers/playlistbrowser/DynamicBiasDialog.h +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Daniel Caleb Jones * - * Copyright (c) 2009 Mark Kretschmann * - * Copyright (c) 2010,2011 Ralf Engels * - * * - * This program 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 2 of the License, or (at your option) version 3 or * - * any later version accepted by the membership of KDE e.V. (or its successor approved * - * by the membership of KDE e.V.), which shall act as a proxy defined in Section 14 of * - * version 3 of the license. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_DYNAMICBIASWIDGETS_H -#define AMAROK_DYNAMICBIASWIDGETS_H - -#include "amarok_export.h" -#include "dynamic/Bias.h" - -#include - -class QVBoxLayout; -class QLabel; -class KComboBox; - -namespace PlaylistBrowserNS -{ - class BiasWidget; - - /** A dialog that contains the widget from a bias and allows to edit it. - */ - class BiasDialog : public QDialog - { - Q_OBJECT - - public: - BiasDialog( Dynamic::BiasPtr bias, QWidget* parent = 0 ); - virtual ~BiasDialog(); - - public slots: - void accept(); - void reject(); - - protected slots: - /** Updates the list of biases in the bias type selection list */ - void factoriesChanged(); - /** Called when a new bias type has been selected */ - void selectionChanged( int index ); - void biasReplaced( Dynamic::BiasPtr oldBias, Dynamic::BiasPtr newBias ); - - protected: - - QVBoxLayout* m_mainLayout; - QVBoxLayout* m_biasLayout; - - KComboBox* m_biasSelection; - QLabel *m_descriptionLabel; - QWidget *m_biasWidget; - - Dynamic::BiasPtr m_origBias; - - /** A copy of the bias given when constructing this object. - * - * We edit only in the copy so that we can discard it if needed. - */ - Dynamic::BiasPtr m_bias; - }; - -} - -#endif diff --git a/amarok/src/browsers/playlistbrowser/DynamicCategory.cpp b/amarok/src/browsers/playlistbrowser/DynamicCategory.cpp deleted file mode 100644 index 4a2bc728..00000000 --- a/amarok/src/browsers/playlistbrowser/DynamicCategory.cpp +++ /dev/null @@ -1,254 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Daniel Jones * - * Copyright (c) 2009-2010 Leo Franchi * - * Copyright (c) 2009 Mark Kretschmann * - * Copyright (c) 2010-2011 Ralf Engels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "DynamicCategory.h" -#include "DynamicView.h" - -#include "amarokconfig.h" -#include "core/support/Amarok.h" -#include "core/support/Debug.h" -#include "playlist/PlaylistActions.h" -#include "playlist/PlaylistModelStack.h" -#include "dynamic/DynamicModel.h" -#include "dynamic/BiasedPlaylist.h" - -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - - -PlaylistBrowserNS::DynamicCategory::DynamicCategory( QWidget* parent ) - : BrowserCategory( "dynamic category", parent ) -{ - setPrettyName( i18n( "Dynamic Playlists" ) ); - setShortDescription( i18n( "Dynamically updating parameter based playlists" ) ); - setIcon( KIcon( "dynamic-amarok" ) ); - - setLongDescription( i18n( "With a dynamic playlist, Amarok becomes your own personal dj, automatically selecting tracks for you, based on a number of parameters that you select." ) ); - - setImagePath( KStandardDirs::locate( "data", "amarok/images/hover_info_dynamic_playlists.png" ) ); - - // set background - if( AmarokConfig::showBrowserBackgroundImage() ) - setBackgroundImage( imagePath() ); - - bool enabled = AmarokConfig::dynamicMode(); - - setContentsMargins( 0, 0, 0, 0 ); - - KHBox* controls2Layout = new KHBox( this ); - - QLabel *label; - label = new QLabel( i18n( "Previous:" ), controls2Layout ); - label->setAlignment( Qt::AlignRight | Qt::AlignVCenter ); - - m_previous = new QSpinBox( controls2Layout ); - m_previous->setMinimum( 0 ); - m_previous->setToolTip( i18n( "Number of previous tracks to remain in the playlist." ) ); - m_previous->setValue( AmarokConfig::previousTracks() ); - QObject::connect( m_previous, SIGNAL(valueChanged(int)), this, SLOT(setPreviousTracks(int)) ); - - label = new QLabel( i18n( "Upcoming:" ), controls2Layout ); - // label->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding ); - label->setAlignment( Qt::AlignRight | Qt::AlignVCenter ); - - m_upcoming = new QSpinBox( controls2Layout ); - m_upcoming->setMinimum( 1 ); - m_upcoming->setToolTip( i18n( "Number of upcoming tracks to add to the playlist." ) ); - m_upcoming->setValue( AmarokConfig::upcomingTracks() ); - QObject::connect( m_upcoming, SIGNAL(valueChanged(int)), this, SLOT(setUpcomingTracks(int)) ); - - - QObject::connect( (const QObject*)Amarok::actionCollection()->action( "playlist_clear" ), SIGNAL(triggered(bool)), this, SLOT(playlistCleared()) ); - QObject::connect( (const QObject*)Amarok::actionCollection()->action( "disable_dynamic" ), SIGNAL(triggered(bool)), this, SLOT(playlistCleared()), Qt::DirectConnection ); - - - // -- the tool bar - - KHBox* presetLayout = new KHBox( this ); - KToolBar* presetToolbar = new KToolBar( presetLayout ); - presetToolbar->setIconSize( QSize( 22, 22 ) ); - - presetToolbar->setToolButtonStyle( Qt::ToolButtonIconOnly ); - presetToolbar->setMovable( false ); - presetToolbar->setFloatable( false ); - presetToolbar->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Preferred ); - - m_onOffButton = new QToolButton( presetToolbar ); - m_onOffButton->setText( i18nc( "Turn dynamic mode on", "On") ); - m_onOffButton->setCheckable( true ); - m_onOffButton->setIcon( KIcon( "dynamic-amarok" ) ); - m_onOffButton->setToolTip( i18n( "Turn dynamic mode on." ) ); - presetToolbar->addWidget( m_onOffButton ); - - m_duplicateButton = new QToolButton( presetToolbar ); - m_duplicateButton->setText( i18n("Duplicates") ); - m_duplicateButton->setCheckable( true ); - m_duplicateButton->setChecked( allowDuplicates() ); - m_duplicateButton->setIcon( KIcon( "edit-copy" ) ); - m_duplicateButton->setToolTip( i18n( "Allow duplicate songs in result" ) ); - presetToolbar->addWidget( m_duplicateButton ); - - m_addButton = new QToolButton( presetToolbar ); - m_addButton->setText( i18n("New") ); - m_addButton->setIcon( KIcon( "document-new" ) ); - m_addButton->setToolTip( i18n( "New playlist" ) ); - presetToolbar->addWidget( m_addButton ); - - m_editButton = new QToolButton( presetToolbar ); - m_editButton->setText( i18n("Edit") ); - m_editButton->setIcon( KIcon( "document-properties-amarok" ) ); - m_editButton->setToolTip( i18n( "Edit the selected playlist or bias" ) ); - presetToolbar->addWidget( m_editButton ); - - m_deleteButton = new QToolButton( presetToolbar ); - m_deleteButton->setText( i18n("Delete") ); - m_deleteButton->setEnabled( false ); - m_deleteButton->setIcon( KIcon( "edit-delete" ) ); - m_deleteButton->setToolTip( i18n( "Delete the selected playlist or bias") ); - presetToolbar->addWidget( m_deleteButton ); - - m_repopulateButton = new QPushButton( presetLayout ); - m_repopulateButton->setText( i18n("Repopulate") ); - m_repopulateButton->setToolTip( i18n("Replace the upcoming tracks with fresh ones.") ); - m_repopulateButton->setIcon( KIcon( "view-refresh-amarok" ) ); - m_repopulateButton->setEnabled( enabled ); - // m_repopulateButton->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) ); - QObject::connect( m_repopulateButton, SIGNAL(clicked(bool)), The::playlistActions(), SLOT(repopulateDynamicPlaylist()) ); - - - // -- the tree view - - m_tree = new DynamicView( this ); - connect( m_tree->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), - this, SLOT(selectionChanged()) ); - - connect( m_onOffButton, SIGNAL(toggled(bool)), The::playlistActions(), SLOT(enableDynamicMode(bool)) ); - connect( m_duplicateButton, SIGNAL(toggled(bool)), this, SLOT(setAllowDuplicates(bool)) ); - - connect( m_addButton, SIGNAL(clicked(bool)), m_tree, SLOT(addPlaylist()) ); - connect( m_editButton, SIGNAL(clicked(bool)), m_tree, SLOT(editSelected()) ); - connect( m_deleteButton, SIGNAL(clicked(bool)), m_tree, SLOT(removeSelected()) ); - - navigatorChanged(); - selectionChanged(); - - connect( The::playlistActions(), SIGNAL(navigatorChanged()), - this, SLOT(navigatorChanged()) ); -} - - -PlaylistBrowserNS::DynamicCategory::~DynamicCategory() -{ } - -void -PlaylistBrowserNS::DynamicCategory::navigatorChanged() -{ - m_onOffButton->setChecked( AmarokConfig::dynamicMode() ); - m_repopulateButton->setEnabled( AmarokConfig::dynamicMode() ); -} - -void -PlaylistBrowserNS::DynamicCategory::selectionChanged() -{ - DEBUG_BLOCK; - - QModelIndexList indexes = m_tree->selectionModel()->selectedIndexes(); - - if( indexes.isEmpty() ) - { - m_addButton->setEnabled( true ); - m_editButton->setEnabled( false ); - m_deleteButton->setEnabled( false ); - return; - } - - QVariant v = m_tree->model()->data( indexes.first(), Dynamic::DynamicModel::PlaylistRole ); - if( v.isValid() ) - { - m_addButton->setEnabled( true ); - m_editButton->setEnabled( true ); - m_deleteButton->setEnabled( true ); - return; - } - - v = m_tree->model()->data( indexes.first(), Dynamic::DynamicModel::BiasRole ); - if( v.isValid() ) - { - m_addButton->setEnabled( true ); - m_editButton->setEnabled( true ); - m_deleteButton->setEnabled( false ); // TODO - return; - } -} - -bool -PlaylistBrowserNS::DynamicCategory::allowDuplicates() const -{ - return AmarokConfig::dynamicDuplicates(); -} - - -void -PlaylistBrowserNS::DynamicCategory::playlistCleared() // SLOT -{ - The::playlistActions()->enableDynamicMode( false ); -} - -void -PlaylistBrowserNS::DynamicCategory::setUpcomingTracks( int n ) // SLOT -{ - if( n >= 1 ) - AmarokConfig::setUpcomingTracks( n ); -} - -void -PlaylistBrowserNS::DynamicCategory::setPreviousTracks( int n ) // SLOT -{ - if( n >= 0 ) - AmarokConfig::setPreviousTracks( n ); -} - -void -PlaylistBrowserNS::DynamicCategory::setAllowDuplicates( bool value ) // SLOT -{ - if( AmarokConfig::dynamicDuplicates() == value ) - return; - - AmarokConfig::setDynamicDuplicates( value ); - AmarokConfig::self()->writeConfig(); - - m_duplicateButton->setChecked( value ); -} - - -#include "moc_DynamicCategory.cpp" - diff --git a/amarok/src/browsers/playlistbrowser/DynamicCategory.h b/amarok/src/browsers/playlistbrowser/DynamicCategory.h deleted file mode 100644 index bf7c48b3..00000000 --- a/amarok/src/browsers/playlistbrowser/DynamicCategory.h +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Daniel Jones * - * Copyright (c) 2009-2010 Leo Franchi * - * Copyright (c) 2009 Mark Kretschmann * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef DYNAMICCATEGORY_H -#define DYNAMICCATEGORY_H - -#include "browsers/BrowserCategory.h" - -class QCheckBox; -class QPushButton; -class QToolButton; -class QStandardItemModel; -class QSpinBox; - -namespace PlaylistBrowserNS { - - class DynamicView; - class DynamicBiasDelegate; - - /** - */ - class DynamicCategory : public BrowserCategory - { - Q_OBJECT - public: - DynamicCategory( QWidget* parent ); - ~DynamicCategory(); - - bool allowDuplicates() const; - - private slots: - void navigatorChanged(); - void selectionChanged(); - void playlistCleared(); - void setUpcomingTracks( int ); - void setPreviousTracks( int ); - - void setAllowDuplicates( bool value ); - - private: - QToolButton *m_onOffButton; - QToolButton *m_duplicateButton; - QToolButton *m_addButton; - QToolButton *m_editButton; - QToolButton *m_deleteButton; - QPushButton *m_repopulateButton; - - DynamicView *m_tree; - - QSpinBox *m_previous, *m_upcoming; - }; - -} - -#endif diff --git a/amarok/src/browsers/playlistbrowser/DynamicView.cpp b/amarok/src/browsers/playlistbrowser/DynamicView.cpp deleted file mode 100644 index 596ec304..00000000 --- a/amarok/src/browsers/playlistbrowser/DynamicView.cpp +++ /dev/null @@ -1,293 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Nikolaj Hald Nielsen * - * Copyright (c) 2010 Bart Cerneels * - * Copyright (c) 2011 Ralf Engels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "DynamicView" - -#include "DynamicView.h" -#include "DynamicBiasDelegate.h" -#include "DynamicBiasDialog.h" - -#include "core/support/Debug.h" -#include "dynamic/Bias.h" -#include "dynamic/DynamicModel.h" -#include "dynamic/DynamicPlaylist.h" -#include "dynamic/biases/SearchQueryBias.h" -#include "playlist/PlaylistActions.h" - -#include "PopupDropperFactory.h" -#include "context/popupdropper/libpud/PopupDropperItem.h" -#include "context/popupdropper/libpud/PopupDropper.h" - -#include "PaletteHandler.h" - -#include - -#include -#include -#include - -#include -#include - -#include -#include - -PlaylistBrowserNS::DynamicView::DynamicView( QWidget *parent ) - : Amarok::PrettyTreeView( parent ) -{ - DEBUG_BLOCK - setHeaderHidden( true ); - setSelectionMode( QAbstractItemView::SingleSelection ); - setModel( Dynamic::DynamicModel::instance() ); - setItemDelegate( new PlaylistBrowserNS::DynamicBiasDelegate(this) ); - - setSelectionBehavior( QAbstractItemView::SelectItems ); - setDragDropMode( QAbstractItemView::DragDrop /*| QAbstractItemView::InternalMove*/ ); - setDragEnabled( true ); - setAcceptDrops( true ); - setDropIndicatorShown( true ); - - setEditTriggers( QAbstractItemView::SelectedClicked | QAbstractItemView::EditKeyPressed ); - - // -- expanding the playlist should expand the whole tree - connect( this, SIGNAL(expanded(QModelIndex)), - this, SLOT(expandRecursive(QModelIndex)) ); - connect( this, SIGNAL(collapsed(QModelIndex)), - this, SLOT(collapseRecursive(QModelIndex)) ); -} - -PlaylistBrowserNS::DynamicView::~DynamicView() -{ -} - -void -PlaylistBrowserNS::DynamicView::addPlaylist() -{ - DEBUG_BLOCK; - QModelIndex newIndex = Dynamic::DynamicModel::instance()->newPlaylist(); - selectionModel()->select( newIndex, QItemSelectionModel::ClearAndSelect ); -} - -void -PlaylistBrowserNS::DynamicView::addToSelected() -{ - DEBUG_BLOCK; - QModelIndexList indexes = selectionModel()->selectedIndexes(); - if( indexes.isEmpty() ) - return; - - QModelIndex newIndex = Dynamic::DynamicModel::instance()->insertBias( 0, indexes.first(), Dynamic::BiasPtr( new Dynamic::SearchQueryBias() ) ); - selectionModel()->select( newIndex, QItemSelectionModel::ClearAndSelect ); -} - -void -PlaylistBrowserNS::DynamicView::cloneSelected() -{ - DEBUG_BLOCK; - QModelIndexList indexes = selectionModel()->selectedIndexes(); - if( indexes.isEmpty() ) - return; - - QModelIndex newIndex = Dynamic::DynamicModel::instance()->cloneAt( indexes.first() ); - selectionModel()->select( newIndex, QItemSelectionModel::ClearAndSelect ); -} - -void -PlaylistBrowserNS::DynamicView::editSelected() -{ - DEBUG_BLOCK; - - QModelIndexList indexes = selectionModel()->selectedIndexes(); - if( indexes.isEmpty() ) - return; - - QVariant v = model()->data( indexes.first(), Dynamic::DynamicModel::PlaylistRole ); - if( v.isValid() ) - { - edit( indexes.first() ); // call the normal editor - return; - } - - v = model()->data( indexes.first(), Dynamic::DynamicModel::BiasRole ); - if( v.isValid() ) - { - Dynamic::AbstractBias* bias = qobject_cast(v.value() ); - PlaylistBrowserNS::BiasDialog dialog( Dynamic::BiasPtr(bias), this); - dialog.exec(); - return; - } -} - -void -PlaylistBrowserNS::DynamicView::removeSelected() -{ - DEBUG_BLOCK; - - QModelIndexList indexes = selectionModel()->selectedIndexes(); - - if( indexes.isEmpty() ) - return; - - Dynamic::DynamicModel::instance()->removeAt( indexes.first() ); -} - -void -PlaylistBrowserNS::DynamicView::expandRecursive(const QModelIndex &index) -{ - for( int i = 0; i < index.model()->rowCount( index ); i++ ) - expand( index.model()->index( i, 0, index ) ); -} - -void -PlaylistBrowserNS::DynamicView::collapseRecursive(const QModelIndex &index) -{ - for( int i = 0; i < index.model()->rowCount( index ); i++ ) - collapse( index.model()->index( i, 0, index ) ); -} - - -void -PlaylistBrowserNS::DynamicView::keyPressEvent( QKeyEvent *event ) -{ - switch( event->key() ) - { - case Qt::Key_Delete: - removeSelected(); - return; - case Qt::Key_Enter: - case Qt::Key_Return: - editSelected(); - return; - } - Amarok::PrettyTreeView::keyPressEvent( event ); -} - -void -PlaylistBrowserNS::DynamicView::mouseDoubleClickEvent( QMouseEvent *event ) -{ - QModelIndex index = indexAt( event->pos() ); - if( index.isValid() ) - { - // if the click was on a playlist - QVariant v = model()->data( index, Dynamic::DynamicModel::PlaylistRole ); - if( v.isValid() ) - { - Dynamic::DynamicModel *model = Dynamic::DynamicModel::instance(); - model->setActivePlaylist( model->playlistIndex( qobject_cast(v.value() ) ) ); - The::playlistActions()->enableDynamicMode( true ); - event->accept(); - return; - } - - // if the click was on a bias - v = model()->data( index, Dynamic::DynamicModel::BiasRole ); - if( v.isValid() ) - { - editSelected(); - event->accept(); - return; - } - } - - Amarok::PrettyTreeView::mouseDoubleClickEvent( event ); -} - -void -PlaylistBrowserNS::DynamicView::contextMenuEvent( QContextMenuEvent *event ) -{ - QModelIndex index = indexAt( event->pos() ); - if( !index.isValid() ) - return; - - QList actions; - - // if the click was on a playlist - QVariant v = model()->data( index, Dynamic::DynamicModel::PlaylistRole ); - if( v.isValid() ) - { - Dynamic::DynamicPlaylist* playlist = qobject_cast(v.value() ); - Q_UNUSED( playlist ); - QAction* action; - - action = new KAction( KIcon( "document-properties-amarok" ), i18n( "&Rename playlist" ), this ); - connect( action, SIGNAL(triggered(bool)), this, SLOT(editSelected()) ); - actions.append( action ); - - action = new KAction( KIcon( "document-new" ), i18n( "&Add new Bias" ), this ); - connect( action, SIGNAL(triggered(bool)), this, SLOT(addToSelected()) ); - actions.append( action ); - - action = new KAction( KIcon( "edit-copy" ), i18n( "&Clone Playlist" ), this ); - connect( action, SIGNAL(triggered(bool)), this, SLOT(cloneSelected()) ); - actions.append( action ); - - action = new KAction( KIcon( "edit-delete" ), i18n( "&Delete playlist" ), this ); - connect( action, SIGNAL(triggered(bool)), this, SLOT(removeSelected()) ); - actions.append( action ); - } - - // if the click was on a bias - v = model()->data( index, Dynamic::DynamicModel::BiasRole ); - if( v.isValid() ) - { - Dynamic::AbstractBias* bias = qobject_cast(v.value() ); - Q_UNUSED( bias ); - Dynamic::AndBias* aBias = qobject_cast(v.value() ); - QAction* action; - - action = new KAction( KIcon( "document-properties-amarok" ), i18n( "&Edit bias..." ), this ); - connect( action, SIGNAL(triggered(bool)), this, SLOT(editSelected()) ); - actions.append( action ); - - action = new KAction( KIcon( "edit-copy" ), i18n( "&Clone bias" ), this ); - connect( action, SIGNAL(triggered(bool)), this, SLOT(cloneSelected()) ); - actions.append( action ); - - // don't allow deleting a top bias unless it'a an and-bias containing at least one - // other bias - QModelIndex parentIndex = index.parent(); - QVariant parentV = model()->data( parentIndex, Dynamic::DynamicModel::PlaylistRole ); - if( !parentV.isValid() || (aBias && aBias->biases().count() > 0) ) - { - action = new KAction( KIcon( "edit-delete" ), i18n( "&Delete bias" ), this ); - connect( action, SIGNAL(triggered(bool)), this, SLOT(removeSelected()) ); - actions.append( action ); - } - - if( aBias ) - { - action = new KAction( KIcon( "document-new" ), i18n( "&Add new bias" ), this ); - connect( action, SIGNAL(triggered(bool)), this, SLOT(addToSelected()) ); - actions.append( action ); - } - } - - if( actions.isEmpty() ) - return; - - KMenu menu; - foreach( QAction *action, actions ) - { - if( action ) - menu.addAction( action ); - } - - menu.exec( mapToGlobal( event->pos() ) ); -} - -#include "moc_DynamicView.cpp" diff --git a/amarok/src/browsers/playlistbrowser/DynamicView.h b/amarok/src/browsers/playlistbrowser/DynamicView.h deleted file mode 100644 index 649c6957..00000000 --- a/amarok/src/browsers/playlistbrowser/DynamicView.h +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Nikolaj Hald Nielsen * - * Copyright (c) 2010 Bart Cerneels * - * Copyright (c) 2011 Ralf Engels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef DYNAMICVIEW_H -#define DYNAMICVIEW_H - -#include "widgets/PrettyTreeView.h" - -#include - -class PopupDropper; -class KAction; -class QKeyEvent; -class QMouseEvent; -class QContextMenuEvent; - -namespace PlaylistBrowserNS { - -class DynamicView : public Amarok::PrettyTreeView -{ -Q_OBJECT -public: - explicit DynamicView( QWidget *parent = 0 ); - ~DynamicView(); - -signals: - void currentItemChanged( const QModelIndex ¤t ); - -public slots: - void addPlaylist(); - void addToSelected(); - void cloneSelected(); - void editSelected(); - void removeSelected(); - -protected slots: - void expandRecursive(const QModelIndex &index); - void collapseRecursive(const QModelIndex &index); - -protected: - virtual void keyPressEvent( QKeyEvent *event ); - virtual void mouseDoubleClickEvent( QMouseEvent *event ); - - virtual void contextMenuEvent( QContextMenuEvent* event ); -}; - -} // namespace PlaylistBrowserNS - -#endif // DYNAMICVIEW_H diff --git a/amarok/src/browsers/playlistbrowser/PlaylistBrowser.cpp b/amarok/src/browsers/playlistbrowser/PlaylistBrowser.cpp deleted file mode 100644 index 96d15c3b..00000000 --- a/amarok/src/browsers/playlistbrowser/PlaylistBrowser.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Bart Cerneels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "PlaylistBrowser.h" - -#include "browsers/playlistbrowser/APGCategory.h" -#include "browsers/playlistbrowser/DynamicCategory.h" -#include "browsers/playlistbrowser/UserPlaylistCategory.h" -#include "core/playlists/Playlist.h" -#include "core/support/Amarok.h" -#include "core/support/Debug.h" -#include "playlistmanager/PlaylistManager.h" - -#include -#include - -#include -#include - -PlaylistBrowserNS::PlaylistBrowser::PlaylistBrowser( const QString &name, QWidget *parent ) - : BrowserCategoryList( name, parent ) -{ - setMargin( 0 ); - setContentsMargins(0,0,0,0); - - addCategory( new DynamicCategory( 0 ) ); - addCategory( new UserPlaylistCategory( 0 ) ); - addCategory( new APGCategory( 0 ) ); - - setLongDescription( i18n( "The playlist browser contains your list of imported and saved playlists. It is also where you can specify powerful dynamic playlists and manage your podcast subscriptions and episodes." ) ); - - setImagePath( KStandardDirs::locate( "data", "amarok/images/hover_info_playlists.png" ) ); -} - -PlaylistBrowserNS::PlaylistBrowser::~PlaylistBrowser() -{ -} - -#include "moc_PlaylistBrowser.cpp" diff --git a/amarok/src/browsers/playlistbrowser/PlaylistBrowser.h b/amarok/src/browsers/playlistbrowser/PlaylistBrowser.h deleted file mode 100644 index d5a1738e..00000000 --- a/amarok/src/browsers/playlistbrowser/PlaylistBrowser.h +++ /dev/null @@ -1,45 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Bart Cerneels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef PLAYLISTBROWSERNSPLAYLISTBROWSER_H -#define PLAYLISTBROWSERNSPLAYLISTBROWSER_H - -#include "browsers/BrowserCategoryList.h" - -#include - -class PodcastCollection; - -namespace PlaylistBrowserNS { - -class PodcastCategory; - -/** - @author Bart Cerneels -*/ -class PlaylistBrowser : public BrowserCategoryList -{ - Q_OBJECT - public: - PlaylistBrowser( const QString &name, QWidget *parent = 0 ); - ~PlaylistBrowser(); - - private: - QMap m_categoryIndexMap; - }; -} - -#endif diff --git a/amarok/src/browsers/playlistbrowser/PlaylistBrowserCategory.cpp b/amarok/src/browsers/playlistbrowser/PlaylistBrowserCategory.cpp deleted file mode 100644 index 4353697a..00000000 --- a/amarok/src/browsers/playlistbrowser/PlaylistBrowserCategory.cpp +++ /dev/null @@ -1,306 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009-2010 Bart Cerneels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "PlaylistBrowserCategory" - -#include "PlaylistBrowserCategory.h" - -#include "amarokconfig.h" -#include "core/support/Debug.h" -#include "PaletteHandler.h" -#include "PlaylistBrowserModel.h" -#include "playlist/PlaylistModel.h" -#include "playlistmanager/PlaylistManager.h" -#include "PlaylistsInFoldersProxy.h" -#include "PlaylistsByProviderProxy.h" -#include "PlaylistBrowserFilterProxy.h" -#include "SvgHandler.h" -#include "PlaylistBrowserView.h" -#include "widgets/PrettyTreeDelegate.h" - -#include -#include -#include -#include -#include - -#include -#include - -#include - -using namespace PlaylistBrowserNS; - -QString PlaylistBrowserCategory::s_mergeViewKey( "Merged View" ); - -PlaylistBrowserCategory::PlaylistBrowserCategory( int playlistCategory, - const QString &categoryName, - const QString &configGroup, - PlaylistBrowserModel *model, - QWidget *parent ) : - BrowserCategory( categoryName, parent ), - m_configGroup( configGroup ), - m_playlistCategory( playlistCategory ) -{ - setContentsMargins( 0, 0, 0, 0 ); - setImagePath( KStandardDirs::locate( "data", "amarok/images/hover_info_podcasts.png" ) ); - - // set background - if( AmarokConfig::showBrowserBackgroundImage() ) - setBackgroundImage( imagePath() ); - - m_toolBar = new KToolBar( this, false, false ); - m_toolBar->setToolButtonStyle( Qt::ToolButtonTextBesideIcon ); - - //a QWidget with minimumExpanding makes the next button right aligned. - QWidget *spacerWidget = new QWidget( this ); - spacerWidget->setSizePolicy( QSizePolicy::MinimumExpanding, - QSizePolicy::MinimumExpanding ); - // add a separator so subclasses can add their actions before it - m_separator = m_toolBar->addWidget( spacerWidget ); - - m_toolBar->addSeparator(); - - m_addFolderAction = new KAction( KIcon( "folder-new" ), i18n( "Add Folder" ), this ); - m_addFolderAction->setPriority( QAction::LowPriority ); - m_toolBar->addAction( m_addFolderAction ); - connect( m_addFolderAction, SIGNAL(triggered(bool)), SLOT(createNewFolder()) ); - - m_providerMenu = new KActionMenu( KIcon( "checkbox" ), i18n( "Visible Sources"), this ); - m_providerMenu->setDelayed( false ); - m_providerMenu->setPriority( QAction::HighPriority ); - m_toolBar->addAction( m_providerMenu ); - - KAction *toggleAction = new KAction( KIcon( "view-list-tree" ), i18n( "Merged View" ), - m_toolBar ); - toggleAction->setCheckable( true ); - toggleAction->setChecked( Amarok::config( m_configGroup ).readEntry( s_mergeViewKey, false ) ); - toggleAction->setPriority( QAction::LowPriority ); - m_toolBar->addAction( toggleAction ); - connect( toggleAction, SIGNAL(triggered(bool)), SLOT(toggleView(bool)) ); - - m_toolBar->addSeparator(); - - m_byProviderProxy = new PlaylistsByProviderProxy( m_playlistCategory, this ); - m_byProviderProxy->setSourceModel( model ); - m_byProviderProxy->setGroupedColumn( PlaylistBrowserModel::ProviderColumn ); - m_byFolderProxy = new PlaylistsInFoldersProxy( model ); - - m_filterProxy = new PlaylistBrowserFilterProxy( this ); - //no need to setModel on filterProxy since it will be done in toggleView anyway. - m_filterProxy->setDynamicSortFilter( true ); - m_filterProxy->setFilterKeyColumn( PlaylistBrowserModel::ProviderColumn ); - - m_playlistView = new PlaylistBrowserView( m_filterProxy, this ); - m_defaultItemDelegate = m_playlistView->itemDelegate(); - m_byProviderDelegate = new PrettyTreeDelegate( m_playlistView ); - - toggleView( toggleAction->isChecked() ); - - m_playlistView->setFrameShape( QFrame::NoFrame ); - m_playlistView->setContentsMargins( 0, 0, 0, 0 ); - m_playlistView->setAlternatingRowColors( true ); - m_playlistView->header()->hide(); - //hide all columns except the first. - for( int i = 1; i < m_playlistView->model()->columnCount(); i++ ) - m_playlistView->hideColumn( i ); - - m_playlistView->setDragEnabled( true ); - m_playlistView->setAcceptDrops( true ); - m_playlistView->setDropIndicatorShown( true ); - - foreach( const Playlists::PlaylistProvider *provider, - The::playlistManager()->providersForCategory( m_playlistCategory ) ) - { - createProviderButton( provider ); - } - - connect( The::playlistManager(), SIGNAL(providerAdded(Playlists::PlaylistProvider*,int)), - SLOT(slotProviderAdded(Playlists::PlaylistProvider*,int)) ); - connect( The::playlistManager(), SIGNAL(providerRemoved(Playlists::PlaylistProvider*,int)), - SLOT(slotProviderRemoved(Playlists::PlaylistProvider*,int)) ); - - connect( The::paletteHandler(), SIGNAL(newPalette(QPalette)), - SLOT(newPalette(QPalette)) ); -} - -PlaylistBrowserCategory::~PlaylistBrowserCategory() -{ -} - -QString -PlaylistBrowserCategory::filter() const -{ - return QUrl::toPercentEncoding( m_filterProxy->filterRegExp().pattern() ); -} - -void -PlaylistBrowserCategory::setFilter( const QString &filter ) -{ - debug() << "Setting filter " << filter; - m_filterProxy->setFilterRegExp( QRegExp( QUrl::fromPercentEncoding( filter.toUtf8() ) ) ); - //disable all other provider-buttons - foreach( QAction * const providerAction, m_providerActions ) - { - const Playlists::PlaylistProvider *provider = - providerAction->data().value(); - if( provider ) - providerAction->setChecked( - m_filterProxy->filterRegExp().exactMatch( provider->prettyName() ) ); - } -} - -QTreeView * -PlaylistBrowserCategory::playlistView() -{ - return m_playlistView; -} - -void -PlaylistBrowserCategory::toggleView( bool merged ) -{ - if( merged ) - { - m_filterProxy->setSourceModel( m_byFolderProxy ); - m_playlistView->setItemDelegate( m_defaultItemDelegate ); - m_playlistView->setRootIsDecorated( true ); - m_addFolderAction->setHelpText( m_addFolderAction->text() ); - } - else - { - m_filterProxy->setSourceModel( m_byProviderProxy ); - m_playlistView->setItemDelegate( m_byProviderDelegate ); - m_playlistView->setRootIsDecorated( false ); - m_addFolderAction->setHelpText( i18n( "Folders are only shown in merged view." ) ); - } - - //folders don't make sense in per-provider view - m_addFolderAction->setEnabled( merged ); - - Amarok::config( m_configGroup ).writeEntry( s_mergeViewKey, merged ); -} - -void -PlaylistBrowserCategory::slotProviderAdded( Playlists::PlaylistProvider *provider, int category ) -{ - if( category != m_playlistCategory ) - return; //ignore - - if( !m_providerActions.keys().contains( provider ) ) - createProviderButton( provider ); - - if( provider->playlistCount() != 0 ) - toggleView( false ); // set view to non-merged if new provider has some tracks - - slotToggleProviderButton(); -} - -void -PlaylistBrowserCategory::slotProviderRemoved( Playlists::PlaylistProvider *provider, int category ) -{ - Q_UNUSED( category ) - - if( m_providerActions.keys().contains( provider ) ) - { - QAction *providerToggle = m_providerActions.take( provider ); - m_providerMenu->removeAction( providerToggle ); - } -} - -void -PlaylistBrowserCategory::createProviderButton( const Playlists::PlaylistProvider *provider ) -{ - QAction *providerToggle = new QAction( provider->icon(), provider->prettyName(), this ); - providerToggle->setCheckable( true ); - providerToggle->setChecked( true ); - providerToggle->setData( QVariant::fromValue( provider ) ); - connect( providerToggle, SIGNAL(toggled(bool)), SLOT(slotToggleProviderButton()) ); - m_providerMenu->addAction( providerToggle ); - - //if there is only one provider the button needs to be disabled. - //When a second is added we can enable the first. - if( m_providerActions.count() == 0 ) - providerToggle->setEnabled( false ); - else if( m_providerActions.count() == 1 ) - m_providerActions.values().first()->setEnabled( true ); - - m_providerActions.insert( provider, providerToggle ); -} - -void -PlaylistBrowserCategory::slotToggleProviderButton() -{ - QString filter; - QActionList checkedActions; - foreach( const Playlists::PlaylistProvider *p, m_providerActions.keys() ) - { - QAction *action = m_providerActions.value( p ); - if( action->isChecked() ) - { - QString escapedName = QRegExp::escape( p->prettyName() ).replace( ' ', "\\ " ); - filter += QString( filter.isEmpty() ? "%1" : "|%1" ).arg( escapedName ); - checkedActions << action; - action->setEnabled( true ); - } - } - //if all are enabled the filter can be completely disabled. - if( checkedActions.count() == m_providerActions.count() ) - filter.clear(); - - m_filterProxy->setFilterRegExp( filter ); - - //don't allow the last visible provider to be hidden - if( checkedActions.count() == 1 ) - checkedActions.first()->setEnabled( false ); -} - -void -PlaylistBrowserCategory::createNewFolder() -{ - QString name = i18nc( "default name for new folder", "New Folder" ); - const QModelIndex &rootIndex = m_byFolderProxy->index(0,0); - QModelIndexList folderIndices = m_byFolderProxy->match( rootIndex, Qt::DisplayRole, name, -1 ); - QString groupName = name; - if( !folderIndices.isEmpty() ) - { - int folderCount( 0 ); - foreach( const QModelIndex &folder, folderIndices ) - { - QRegExp regex( name + " \\((\\d+)\\)" ); - int matchIndex = regex.indexIn( folder.data( Qt::DisplayRole ).toString() ); - if (matchIndex != -1) - { - int newNumber = regex.cap( 1 ).toInt(); - if (newNumber > folderCount) - folderCount = newNumber; - } - } - groupName += QString( " (%1)" ).arg( folderCount + 1 ); - } - QModelIndex idx = m_filterProxy->mapFromSource( m_byFolderProxy->createNewFolder( groupName ) ); - m_playlistView->setCurrentIndex( idx ); - m_playlistView->edit( idx ); -} - -void -PlaylistBrowserCategory::newPalette( const QPalette &palette ) -{ - Q_UNUSED( palette ) - - The::paletteHandler()->updateItemView( m_playlistView ); -} - -#include "moc_PlaylistBrowserCategory.cpp" diff --git a/amarok/src/browsers/playlistbrowser/PlaylistBrowserCategory.h b/amarok/src/browsers/playlistbrowser/PlaylistBrowserCategory.h deleted file mode 100644 index 2c48a6c9..00000000 --- a/amarok/src/browsers/playlistbrowser/PlaylistBrowserCategory.h +++ /dev/null @@ -1,112 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009-2010 Bart Cerneels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef PLAYLISTBROWSERCATEGORY_H -#define PLAYLISTBROWSERCATEGORY_H - -#include "browsers/BrowserCategory.h" - -#include - -namespace Amarok { - class PrettyTreeView; -} - -class QAbstractItemDelegate; -class QTreeView; - -class KAction; -class KActionMenu; -class KLineEdit; -class KToolBar; - -class PlaylistsInFoldersProxy; -class PlaylistsByProviderProxy; -class PlaylistBrowserFilterProxy; - -namespace Playlists { - class PlaylistProvider; -} - -namespace PlaylistBrowserNS { - -class PlaylistBrowserModel; - -class PlaylistBrowserCategory : public BrowserCategory -{ - Q_OBJECT - -public: - static QString s_mergeViewKey; - - explicit PlaylistBrowserCategory( int playlistCategory, - const QString &categoryName, - const QString &configGroup, - PlaylistBrowserModel *model, - QWidget *parent ); - ~PlaylistBrowserCategory(); - - virtual QString filter() const; - virtual void setFilter( const QString &filter ); - -protected: - KToolBar *m_toolBar; - - /** - * A separator in between the add-folder action and visible-source, - * merged-view actions. Subclasses can use it to insert their specialized - * actions at a suitable place, thus keeping the generic actions in order. - */ - QAction *m_separator; - - QTreeView *playlistView(); - -private slots: - void toggleView( bool mergedView ); - void slotProviderAdded( Playlists::PlaylistProvider *provider, int category ); - void slotProviderRemoved( Playlists::PlaylistProvider *provider, int category ); - void slotToggleProviderButton(); - - void createNewFolder(); - - void newPalette( const QPalette &palette ); - -private: - void createProviderButton( const Playlists::PlaylistProvider *provider ); - - KActionMenu *m_providerMenu; - QMap m_providerActions; - - Amarok::PrettyTreeView *m_playlistView; - - KAction *m_addFolderAction; - - QAbstractItemDelegate *m_byProviderDelegate; - QAbstractItemDelegate *m_defaultItemDelegate; - PlaylistsInFoldersProxy *m_byFolderProxy; - PlaylistsByProviderProxy *m_byProviderProxy; - PlaylistBrowserFilterProxy *m_filterProxy; - - QString m_configGroup; - int m_playlistCategory; -}; - -} //namespace PlaylistBrowserNS - -//for saving it in a QVariant -Q_DECLARE_METATYPE( const Playlists::PlaylistProvider * ) - -#endif // PLAYLISTBROWSERCATEGORY_H diff --git a/amarok/src/browsers/playlistbrowser/PlaylistBrowserFilterProxy.cpp b/amarok/src/browsers/playlistbrowser/PlaylistBrowserFilterProxy.cpp deleted file mode 100644 index ba2acbf4..00000000 --- a/amarok/src/browsers/playlistbrowser/PlaylistBrowserFilterProxy.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2011 Bart Cerneels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "PlaylistBrowserFilterProxy.h" - -#include "core/support/Debug.h" - -PlaylistBrowserFilterProxy::PlaylistBrowserFilterProxy( QObject *parent ) : - QSortFilterProxyModel( parent ) -{ -} - -void -PlaylistBrowserFilterProxy::setSourceModel( QAbstractItemModel *model ) -{ - if( sourceModel() ) - sourceModel()->disconnect(); - - QSortFilterProxyModel::setSourceModel( model ); - connect( sourceModel(), SIGNAL(renameIndex(QModelIndex)), - SLOT(slotRenameIndex(QModelIndex)) ); -} - -void -PlaylistBrowserFilterProxy::slotRenameIndex( const QModelIndex &sourceIdx ) -{ - const QModelIndex &idx = mapFromSource( sourceIdx ); - if( idx.isValid() ) - emit renameIndex( idx ); -} diff --git a/amarok/src/browsers/playlistbrowser/PlaylistBrowserFilterProxy.h b/amarok/src/browsers/playlistbrowser/PlaylistBrowserFilterProxy.h deleted file mode 100644 index f0e1a724..00000000 --- a/amarok/src/browsers/playlistbrowser/PlaylistBrowserFilterProxy.h +++ /dev/null @@ -1,43 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2011 Bart Cerneels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef PLAYLISTBROWSERFILTERPROXY_H -#define PLAYLISTBROWSERFILTERPROXY_H - -#include - -class PlaylistBrowserFilterProxy : public QSortFilterProxyModel -{ - Q_OBJECT - public: - /** simple reimplementation of QSortFilterProxyModel to allow editing call from down the - * modelstack. - */ - explicit PlaylistBrowserFilterProxy( QObject *parent = 0 ); - ~PlaylistBrowserFilterProxy() {} - - // QSortFilterProxyModel methods - virtual void setSourceModel( QAbstractItemModel *sourceModel ); - - signals: - void renameIndex( const QModelIndex &index ); - - private slots: - void slotRenameIndex( const QModelIndex &index ); - -}; - -#endif // PLAYLISTBROWSERFILTERPROXY_H diff --git a/amarok/src/browsers/playlistbrowser/PlaylistBrowserModel.cpp b/amarok/src/browsers/playlistbrowser/PlaylistBrowserModel.cpp deleted file mode 100644 index 32d3d8b0..00000000 --- a/amarok/src/browsers/playlistbrowser/PlaylistBrowserModel.cpp +++ /dev/null @@ -1,736 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009-2010 Bart Cerneels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "PlaylistBrowserModel" - -#include "PlaylistBrowserModel.h" - -#include "AmarokMimeData.h" -#include "playlistmanager/PlaylistManager.h" -#include "playlist/PlaylistController.h" -#include "playlist/PlaylistModel.h" -#include "core/support/Debug.h" -#include "widgets/PrettyTreeRoles.h" - -#include - -#include - -using namespace PlaylistBrowserNS; - -// to be used with qSort. -static bool -lessThanPlaylistTitles( const Playlists::PlaylistPtr &lhs, const Playlists::PlaylistPtr &rhs ) -{ - return lhs->prettyName().toLower() < rhs->prettyName().toLower(); -} - -PlaylistBrowserModel::PlaylistBrowserModel( int playlistCategory ) - : m_playlistCategory( playlistCategory ) -{ - connect( The::playlistManager(), SIGNAL(updated(int)), SLOT(slotUpdate(int)) ); - - connect( The::playlistManager(), SIGNAL(playlistAdded(Playlists::PlaylistPtr,int)), - SLOT(slotPlaylistAdded(Playlists::PlaylistPtr,int)) ); - connect( The::playlistManager(), SIGNAL(playlistRemoved(Playlists::PlaylistPtr,int)), - SLOT(slotPlaylistRemoved(Playlists::PlaylistPtr,int)) ); - connect( The::playlistManager(), SIGNAL(playlistUpdated(Playlists::PlaylistPtr,int)), - SLOT(slotPlaylistUpdated(Playlists::PlaylistPtr,int)) ); - - connect( The::playlistManager(), SIGNAL(renamePlaylist(Playlists::PlaylistPtr)), - SLOT(slotRenamePlaylist(Playlists::PlaylistPtr)) ); - - m_playlists = loadPlaylists(); -} - -QVariant -PlaylistBrowserModel::data( const QModelIndex &index, int role ) const -{ - int row = REMOVE_TRACK_MASK(index.internalId()); - Playlists::PlaylistPtr playlist = m_playlists.value( row ); - - QString name; - KIcon icon; - int playlistCount = 0; - QList providerActions; - QList providers = - The::playlistManager()->getProvidersForPlaylist( playlist ); - Playlists::PlaylistProvider *provider = providers.count() == 1 ? providers.first() : 0; - Meta::TrackPtr track; - - switch( index.column() ) - { - case PlaylistBrowserModel::PlaylistItemColumn: //playlist or track data - { - if( IS_TRACK(index) ) - { - track = playlist->tracks()[index.row()]; - name = track->prettyName(); - icon = KIcon( "amarok_track" ); - } - else - { - name = playlist->prettyName(); - icon = KIcon( "amarok_playlist" ); - } - break; - } - case PlaylistBrowserModel::LabelColumn: //group - { - if( !playlist->groups().isEmpty() ) - { - name = playlist->groups().first(); - icon = KIcon( "folder" ); - } - break; - } - - case PlaylistBrowserModel::ProviderColumn: //source - { - if( providers.count() > 1 ) - { - QVariantList nameData; - QVariantList iconData; - QVariantList playlistCountData; - QVariantList providerActionsData; - foreach( Playlists::PlaylistProvider *provider, providers ) - { - name = provider->prettyName(); - nameData << name; - icon = provider->icon(); - iconData << QVariant( icon ); - playlistCount = provider->playlists().count(); - if( playlistCount >= 0 ) - playlistCountData << i18ncp( - "number of playlists from one source", - "One Playlist", "%1 playlists", - playlistCount ); - else - playlistCountData << i18nc( - "normally number of playlists, but they are still loading", - "Loading..." ); - providerActions << provider->providerActions(); - providerActionsData << QVariant::fromValue( providerActions ); - } - switch( role ) - { - case Qt::DisplayRole: - case Qt::EditRole: - case Qt::ToolTipRole: - return nameData; - case Qt::DecorationRole: - return iconData; - case PrettyTreeRoles::ByLineRole: - return playlistCountData; - case PrettyTreeRoles::DecoratorRoleCount: - return providerActions.count(); - case PrettyTreeRoles::DecoratorRole: - return providerActionsData; - } - } - else if( provider ) - { - name = provider->prettyName(); - icon = provider->icon(); - playlistCount = provider->playlistCount(); - providerActions << provider->providerActions(); - } - - break; - } - - default: break; - } - - - switch( role ) - { - case Qt::DisplayRole: - case Qt::EditRole: - case Qt::ToolTipRole: - return name; - case Qt::DecorationRole: - return QVariant( icon ); - case PrettyTreeRoles::ByLineRole: - if( IS_TRACK(index) ) - return QVariant(); - else - return i18ncp( "number of playlists from one source", "One playlist", - "%1 playlists", playlistCount ); - case PlaylistBrowserModel::ProviderRole: - return provider ? QVariant::fromValue( provider ) : QVariant(); - case PlaylistBrowserModel::PlaylistRole: - return playlist ? QVariant::fromValue( playlist ) : QVariant(); - case PlaylistBrowserModel::TrackRole: - return track ? QVariant::fromValue( track ) : QVariant(); - - default: - return QVariant(); - } -} - -bool -PlaylistBrowserModel::setData( const QModelIndex &idx, const QVariant &value, int role ) -{ - - if( !idx.isValid() ) - return false; - - switch( idx.column() ) - { - case ProviderColumn: - { - if( role == Qt::DisplayRole || role == Qt::EditRole ) - { - Playlists::PlaylistProvider *provider = getProviderByName( value.toString() ); - if( !provider ) - return false; - - if( IS_TRACK( idx ) ) - { - Meta::TrackPtr track = trackFromIndex( idx ); - if( !track ) - return false; - debug() << QString( "Copy track \"%1\" to \"%2\"." ) - .arg( track->prettyName() ).arg( provider->prettyName() ); - // return !provider->addTrack( track ).isNull(); - provider->addTrack( track ); //ignore result since UmsPodcastProvider returns NULL - return true; - } - else - { - Playlists::PlaylistPtr playlist = playlistFromIndex( idx ); - if( !playlist || ( playlist->provider() == provider ) ) - return false; - - foreach( Playlists::PlaylistPtr tempPlaylist , provider->playlists() ) - { - if ( tempPlaylist->name() == playlist->name() ) - return false; - } - - debug() << QString( "Copy playlist \"%1\" to \"%2\"." ) - .arg( playlist->prettyName() ).arg( provider->prettyName() ); - - return !provider->addPlaylist( playlist ).isNull(); - } - } - - //return true even for the data we didn't handle to get QAbstractItemModel::setItemData to work - //TODO: implement setItemData() - return true; - } - case LabelColumn: - { - debug() << "changing group of item " << idx.internalId() << " to " << value.toString(); - Playlists::PlaylistPtr item = m_playlists.value( idx.internalId() ); - item->setGroups( value.toStringList() ); - - return true; - } - } - - return false; -} - -QModelIndex -PlaylistBrowserModel::index( int row, int column, const QModelIndex &parent) const -{ - if( !parent.isValid() ) - { - if( row >= 0 && row < m_playlists.count() ) - return createIndex( row, column, row ); - } - else //if it has a parent it is a track - { - //but check if the playlist indeed has that track - Playlists::PlaylistPtr playlist = m_playlists.value( parent.row() ); - if( row < playlist->tracks().count() ) - return createIndex( row, column, SET_TRACK_MASK(parent.row()) ); - } - - return QModelIndex(); -} - -QModelIndex -PlaylistBrowserModel::parent( const QModelIndex &index ) const -{ - if( IS_TRACK(index) ) - { - int row = REMOVE_TRACK_MASK(index.internalId()); - return this->index( row, index.column(), QModelIndex() ); - } - - return QModelIndex(); -} - -bool -PlaylistBrowserModel::hasChildren( const QModelIndex &parent ) const -{ - if( parent.column() > 0 ) - return false; - if( !parent.isValid() ) - { - return !m_playlists.isEmpty(); - } - else if( !IS_TRACK(parent) ) - { - Playlists::PlaylistPtr playlist = m_playlists.value( parent.internalId() ); - return playlist->trackCount() != 0; //-1 might mean there are tracks, but not yet loaded. - } - - return false; -} - -int -PlaylistBrowserModel::rowCount( const QModelIndex &parent ) const -{ - if( parent.column() > 0 ) - return 0; - - if( !parent.isValid() ) - { - return m_playlists.count(); - } - else if( !IS_TRACK(parent) ) - { - Playlists::PlaylistPtr playlist = m_playlists.value( parent.internalId() ); - return playlist->trackCount(); - } - - return 0; -} - -int -PlaylistBrowserModel::columnCount( const QModelIndex &parent ) const -{ - if( !parent.isValid() ) //for playlists (children of root) - return 3; //name, group and provider - - //for tracks - return 1; //only name -} - -bool -PlaylistBrowserModel::canFetchMore( const QModelIndex &parent ) const -{ - if( parent.column() > 0 ) - return false; - - if( !parent.isValid() ) - { - return false; - } - else if( !IS_TRACK(parent) ) - { - Playlists::PlaylistPtr playlist = m_playlists.value( parent.internalId() ); - //TODO: imeplement incremental loading of tracks by checking for == - if( playlist->trackCount() != playlist->tracks().count() ) - return true; //tracks still need to be loaded. - } - - return false; -} - -void -PlaylistBrowserModel::fetchMore ( const QModelIndex &parent ) -{ - if( parent.column() > 0 ) - return; - - //TODO: load playlists dynamically from provider - if( !parent.isValid() ) - return; - - if( !IS_TRACK(parent) ) - { - Playlists::PlaylistPtr playlist = m_playlists.value( parent.internalId() ); - // TODO: following doesn't seem to be needed, PlaylistBrowserModel seems to be able to cope with async track loading fine - playlist->makeLoadingSync(); - playlist->triggerTrackLoad(); - } -} - -Qt::ItemFlags -PlaylistBrowserModel::flags( const QModelIndex &idx ) const -{ - //Both providers and groups can be empty. QtGroupingProxy makes empty groups from the data in - //the rootnode (here an invalid QModelIndex). - //TODO: editable only if provider is writable. - if( idx.column() == PlaylistBrowserModel::ProviderColumn ) - return Qt::ItemIsEnabled | Qt::ItemIsEditable; - - if( idx.column() == PlaylistBrowserModel::LabelColumn ) - return Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsDropEnabled; - - if( !idx.isValid() ) - return Qt::ItemIsDropEnabled; - - if( IS_TRACK(idx) ) - return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsDragEnabled; - - //item is a playlist - return Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | - Qt::ItemIsDropEnabled; -} - -QVariant -PlaylistBrowserModel::headerData( int section, Qt::Orientation orientation, int role ) const -{ - if( orientation == Qt::Horizontal && role == Qt::DisplayRole ) - { - switch( section ) - { - case PlaylistBrowserModel::PlaylistItemColumn: return i18n("Name"); - case PlaylistBrowserModel::LabelColumn: return i18n("Group"); - case PlaylistBrowserModel::ProviderColumn: return i18n("Source"); - default: return QVariant(); - } - } - - return QVariant(); -} - -QStringList -PlaylistBrowserModel::mimeTypes() const -{ - QStringList ret; - ret << AmarokMimeData::PLAYLIST_MIME; - ret << AmarokMimeData::TRACK_MIME; - return ret; -} - -QMimeData* -PlaylistBrowserModel::mimeData( const QModelIndexList &indices ) const -{ - AmarokMimeData* mime = new AmarokMimeData(); - - Playlists::PlaylistList playlists; - Meta::TrackList tracks; - - foreach( const QModelIndex &index, indices ) - { - if( IS_TRACK(index) ) - tracks << trackFromIndex( index ); - else - playlists << m_playlists.value( index.internalId() ); - } - - mime->setPlaylists( playlists ); - mime->setTracks( tracks ); - - return mime; -} - -bool -PlaylistBrowserModel::dropMimeData( const QMimeData *data, Qt::DropAction action, int row, int column, - const QModelIndex &parent ) -{ - DEBUG_BLOCK - debug() << "Dropped on" << parent << "row" << row << "column" << column << "action" << action; - if( action == Qt::IgnoreAction ) - return true; - - //drop on track is not possible - if( IS_TRACK(parent) ) - return false; - - const AmarokMimeData* amarokMime = dynamic_cast( data ); - if( !amarokMime ) - return false; - - if( data->hasFormat( AmarokMimeData::PLAYLIST_MIME ) ) - { - // TODO: is this ever called???? - Playlists::PlaylistList playlists = amarokMime->playlists(); - - foreach( Playlists::PlaylistPtr playlist, playlists ) - { - if( !m_playlists.contains( playlist ) ) - debug() << "Unknown playlist dragged in: " << playlist->prettyName(); - } - - return true; - } - else if( data->hasFormat( AmarokMimeData::TRACK_MIME ) ) - { - Meta::TrackList tracks = amarokMime->tracks(); - if( !parent.isValid() && row == -1 && column == -1 ) - { - debug() << "Dropped tracks on empty area: create new playlist in a default provider"; - The::playlistManager()->save( tracks, Amarok::generatePlaylistName( tracks ) ); - return true; - } - else if( !parent.isValid() ) - { - warning() << "Dropped tracks between root items, this is not supported!"; - return false; - } - else - { - debug() << "Dropped tracks on " << parent << " at row: " << row; - - Playlists::PlaylistPtr playlist = playlistFromIndex( parent ); - if( !playlist ) - return false; - - foreach( Meta::TrackPtr track, tracks ) - playlist->addTrack( track, ( row >= 0 ) ? row++ : -1 ); // increment only if positive - - return true; - } - } - - return false; -} - -void -PlaylistBrowserModel::metadataChanged( Playlists::PlaylistPtr playlist ) -{ - int indexNumber = m_playlists.indexOf( playlist ); - if( indexNumber == -1 ) - { - error() << "This playlist is not in the list of this model."; - return; - } - QModelIndex playlistIdx = index( indexNumber, 0 ); - emit dataChanged( playlistIdx, playlistIdx ); -} - -void -PlaylistBrowserModel::trackAdded( Playlists::PlaylistPtr playlist, Meta::TrackPtr track, - int position ) -{ - Q_UNUSED( track ); - int indexNumber = m_playlists.indexOf( playlist ); - if( indexNumber == -1 ) - { - error() << "This playlist is not in the list of this model."; - return; - } - QModelIndex playlistIdx = index( indexNumber, 0, QModelIndex() ); - beginInsertRows( playlistIdx, position, position ); - endInsertRows(); -} - -void -PlaylistBrowserModel::trackRemoved( Playlists::PlaylistPtr playlist, int position ) -{ - int indexNumber = m_playlists.indexOf( playlist ); - if( indexNumber == -1 ) - { - error() << "This playlist is not in the list of this model."; - return; - } - QModelIndex playlistIdx = index( indexNumber, 0, QModelIndex() ); - beginRemoveRows( playlistIdx, position, position ); - endRemoveRows(); -} - -void -PlaylistBrowserModel::slotRenamePlaylist( Playlists::PlaylistPtr playlist ) -{ - if( !playlist->provider() || playlist->provider()->category() != m_playlistCategory ) - return; - - int row = 0; - foreach( Playlists::PlaylistPtr p, m_playlists ) - { - if( p == playlist ) - { - emit renameIndex( index( row, 0 ) ); - break; - } - row++; - } -} - -void -PlaylistBrowserModel::slotUpdate( int category ) -{ - if( category != m_playlistCategory ) - return; - - beginResetModel(); - - foreach( Playlists::PlaylistPtr playlist, m_playlists ) - unsubscribeFrom( playlist ); - - m_playlists.clear(); - m_playlists = loadPlaylists(); - - endResetModel(); -} - -Playlists::PlaylistList -PlaylistBrowserModel::loadPlaylists() -{ - Playlists::PlaylistList playlists = - The::playlistManager()->playlistsOfCategory( m_playlistCategory ); - QListIterator i( playlists ); - - debug() << playlists.count() << " playlists for category " << m_playlistCategory; - - while( i.hasNext() ) - { - Playlists::PlaylistPtr playlist = i.next(); - subscribeTo( playlist ); - } - - qSort( playlists.begin(), playlists.end(), lessThanPlaylistTitles ); - - return playlists; -} - -void -PlaylistBrowserModel::slotPlaylistAdded( Playlists::PlaylistPtr playlist, int category ) -{ - //ignore playlists of a different category - if( category != m_playlistCategory ) - return; - - subscribeTo( playlist ); - int i; - for( i = 0; i < m_playlists.count(); i++ ) - { - if( lessThanPlaylistTitles( playlist, m_playlists[i] ) ) - break; - } - - beginInsertRows( QModelIndex(), i, i ); - m_playlists.insert( i, playlist ); - endInsertRows(); -} - -void -PlaylistBrowserModel::slotPlaylistRemoved( Playlists::PlaylistPtr playlist, int category ) -{ - if( category != m_playlistCategory ) - return; - - int position = m_playlists.indexOf( playlist ); - if( position == -1 ) - { - error() << "signal received for removed playlist not in m_playlists"; - return; - } - - beginRemoveRows( QModelIndex(), position, position ); - m_playlists.removeAt( position ); - endRemoveRows(); -} - -void -PlaylistBrowserModel::slotPlaylistUpdated( Playlists::PlaylistPtr playlist, int category ) -{ - if( category != m_playlistCategory ) - return; - - int position = m_playlists.indexOf( playlist ); - if( position == -1 ) - { - error() << "signal received for updated playlist not in m_playlists"; - return; - } - - //TODO: this should work by signaling a change in the model data, but QtGroupingProxy doesn't - //work like that ATM -// const QModelIndex &idx = index( position, 0 ); -// emit dataChanged( idx, idx ); - - //HACK: remove and readd so QtGroupingProxy can put it in the correct groups. - beginRemoveRows( QModelIndex(), position, position ); - endRemoveRows(); - - beginInsertRows( QModelIndex(), position, position ); - endInsertRows(); -} - -Meta::TrackList -PlaylistBrowserModel::tracksFromIndexes( const QModelIndexList &list ) const -{ - Meta::TrackList tracks; - foreach( const QModelIndex &index, list ) - { - if( IS_TRACK(index) ) - tracks << trackFromIndex( index ); - else if( Playlists::PlaylistPtr playlist = playlistFromIndex( index ) ) - { - playlist->makeLoadingSync(); - //first trigger a load of the tracks or we'll end up with an empty list - playlist->triggerTrackLoad(); - tracks << playlist->tracks(); - } - } - return tracks; -} - -Meta::TrackPtr -PlaylistBrowserModel::trackFromIndex( const QModelIndex &idx ) const -{ - if( !idx.isValid() || !IS_TRACK(idx) ) - return Meta::TrackPtr(); - - int playlistRow = REMOVE_TRACK_MASK(idx.internalId()); - if( playlistRow >= m_playlists.count() ) - return Meta::TrackPtr(); - - Playlists::PlaylistPtr playlist = m_playlists.value( playlistRow ); - if( playlist.isNull() || playlist->tracks().count() <= idx.row() ) - return Meta::TrackPtr(); - - return playlist->tracks()[idx.row()]; -} - -Playlists::PlaylistPtr -PlaylistBrowserModel::playlistFromIndex( const QModelIndex &index ) const -{ - if( !index.isValid() ) - return Playlists::PlaylistPtr(); - - return m_playlists.value( index.internalId() ); -} - -Playlists::PlaylistProvider * -PlaylistBrowserModel::providerForIndex( const QModelIndex &idx ) const -{ - if( !idx.isValid() ) - return 0; - - int playlistRow; - if( IS_TRACK( idx ) ) - playlistRow = REMOVE_TRACK_MASK( idx.internalId() ); - else - playlistRow = idx.row(); - - if( playlistRow >= m_playlists.count() ) - return 0; - - return m_playlists.at( playlistRow )->provider(); -} - -Playlists::PlaylistProvider * -PlaylistBrowserModel::getProviderByName( const QString &name ) -{ - QList providers = - The::playlistManager()->providersForCategory( m_playlistCategory ); - foreach( Playlists::PlaylistProvider *provider, providers ) - { - if( provider->prettyName() == name ) - return provider; - } - return 0; -} diff --git a/amarok/src/browsers/playlistbrowser/PlaylistBrowserModel.h b/amarok/src/browsers/playlistbrowser/PlaylistBrowserModel.h deleted file mode 100644 index 0a7c51ec..00000000 --- a/amarok/src/browsers/playlistbrowser/PlaylistBrowserModel.h +++ /dev/null @@ -1,123 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009-2010 Bart Cerneels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_PLAYLISTBROWSERMODEL_H -#define AMAROK_PLAYLISTBROWSERMODEL_H - -#include "core/playlists/Playlist.h" -#include "core/playlists/PlaylistProvider.h" - -#include - -//Playlist & Track index differentiator macros -//QModelIndex::intenalId() is a qint64 to support 64-bit pointers in a union with the ID -#define TRACK_MASK (0x1<<31) -#define IS_TRACK(x) ((x.internalId()) & (TRACK_MASK))?true:false -#define SET_TRACK_MASK(x) ((x) | (TRACK_MASK)) -#define REMOVE_TRACK_MASK(x) ((x) & ~(TRACK_MASK)) - -class QAction; - -Q_DECLARE_METATYPE( QAction* ) -Q_DECLARE_METATYPE( QActionList ) - -namespace PlaylistBrowserNS { - -/** - @author Bart Cerneels -*/ -class PlaylistBrowserModel : public QAbstractItemModel, public Playlists::PlaylistObserver -{ - Q_OBJECT - public: - enum { - PlaylistItemColumn = 0, //Data form the playlist itself or it's tracks - LabelColumn, //Data from the labels. Can be used as foldernames in the view. - ProviderColumn, //data from the PlaylistProvider - CustomColumOffset //first column that can be used by subclasses for their own data - }; - - enum - { - ProviderRole = Qt::UserRole + 21, // pointer to associated PlaylistProvider - PlaylistRole = Qt::UserRole + 22, // PlaylistPtr for associated playlist or null - TrackRole = Qt::UserRole + 23, // TrackPtr for associated track or null - EpisodeIsNewRole = Qt::UserRole + 24, // for podcast episodes, supports setting, type: bool - CustomRoleOffset = Qt::UserRole + 25 //first role that can be used by sublasses for their own data - }; - - PlaylistBrowserModel( int PlaylistCategory ); - virtual ~PlaylistBrowserModel() {} - - /* QAbstractItemModel methods */ - virtual QVariant data( const QModelIndex &index, int role ) const; - virtual bool setData( const QModelIndex &idx, const QVariant &value, int role ); - virtual Qt::ItemFlags flags( const QModelIndex &index ) const; - virtual QVariant headerData( int section, Qt::Orientation orientation, - int role = Qt::DisplayRole ) const; - virtual QModelIndex index( int row, int column, - const QModelIndex &parent = QModelIndex() ) const; - virtual QModelIndex parent( const QModelIndex &index ) const; - - virtual bool hasChildren( const QModelIndex &parent = QModelIndex() ) const; - virtual int rowCount( const QModelIndex &parent = QModelIndex() ) const; - virtual int columnCount( const QModelIndex &parent = QModelIndex() ) const; - - virtual bool canFetchMore( const QModelIndex &parent ) const; - virtual void fetchMore( const QModelIndex &parent ); - - virtual QStringList mimeTypes() const; - virtual QMimeData* mimeData( const QModelIndexList &indexes ) const; - virtual bool dropMimeData( const QMimeData *data, Qt::DropAction action, int row, - int column, const QModelIndex &parent ); - - /* Playlists::PlaylistObserver methods */ - virtual void metadataChanged( Playlists::PlaylistPtr playlist ); - virtual void trackAdded( Playlists::PlaylistPtr playlist, Meta::TrackPtr track, int position ); - virtual void trackRemoved( Playlists::PlaylistPtr playlist, int position ); - - public slots: - void slotRenamePlaylist( Playlists::PlaylistPtr playlist ); - void slotUpdate( int category ); - - signals: - void renameIndex( const QModelIndex &index ); - - protected: - virtual Playlists::PlaylistList loadPlaylists(); - - Meta::TrackList tracksFromIndexes( const QModelIndexList &list ) const; - Meta::TrackPtr trackFromIndex( const QModelIndex &index ) const; - Playlists::PlaylistPtr playlistFromIndex( const QModelIndex &index ) const; - Playlists::PlaylistProvider *providerForIndex( const QModelIndex &index ) const; - - Playlists::PlaylistList m_playlists; - QMap m_playlistTracksLoaded; - - Playlists::PlaylistProvider *getProviderByName( const QString &name ); - - private slots: - void slotPlaylistAdded( Playlists::PlaylistPtr playlist, int category ); - void slotPlaylistRemoved( Playlists::PlaylistPtr playlist, int category ); - void slotPlaylistUpdated( Playlists::PlaylistPtr playlist, int category ); - - private: - int m_playlistCategory; -}; - -} - -#endif //AMAROK_PLAYLISTBROWSERMODEL_H diff --git a/amarok/src/browsers/playlistbrowser/PlaylistBrowserView.cpp b/amarok/src/browsers/playlistbrowser/PlaylistBrowserView.cpp deleted file mode 100644 index 16079556..00000000 --- a/amarok/src/browsers/playlistbrowser/PlaylistBrowserView.cpp +++ /dev/null @@ -1,582 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Nikolaj Hald Nielsen * - * Copyright (c) 2010 Bart Cerneels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "PlaylistBrowserView" - -#include "PlaylistBrowserView.h" - -#include "PaletteHandler.h" -#include "PopupDropperFactory.h" -#include "SvgHandler.h" -#include "amarokconfig.h" -#include "browsers/playlistbrowser/PlaylistBrowserModel.h" -#include "browsers/playlistbrowser/PlaylistsByProviderProxy.h" -#include "browsers/playlistbrowser/PlaylistsInFoldersProxy.h" -#include "context/ContextView.h" -#include "context/popupdropper/libpud/PopupDropperItem.h" -#include "context/popupdropper/libpud/PopupDropper.h" -#include "core/support/Debug.h" -#include "core-impl/playlists/types/file/PlaylistFileSupport.h" -#include "playlist/PlaylistModel.h" -#include "playlistmanager/PlaylistManager.h" -#include "widgets/PrettyTreeRoles.h" - -#include -#include -#include - -#include - -#include -#include - -Q_DECLARE_METATYPE( QModelIndexList ) - -using namespace PlaylistBrowserNS; - -PlaylistBrowserNS::PlaylistBrowserView::PlaylistBrowserView( QAbstractItemModel *model, - QWidget *parent ) - : Amarok::PrettyTreeView( parent ) - , m_pd( 0 ) - , m_ongoingDrag( false ) -{ - DEBUG_BLOCK - setModel( model ); - setSelectionMode( QAbstractItemView::ExtendedSelection ); - setSelectionBehavior( QAbstractItemView::SelectItems ); - setDragDropMode( QAbstractItemView::DragDrop ); - setAcceptDrops( true ); - setEditTriggers( QAbstractItemView::EditKeyPressed ); - setMouseTracking( true ); // needed for highlighting provider action icons - - m_createEmptyPlaylistAction = new QAction( KIcon( "media-track-add-amarok" ), - i18n( "Create an Empty Playlist" ), this ); - connect( m_createEmptyPlaylistAction, SIGNAL(triggered()), SLOT(slotCreateEmptyPlaylist()) ); - - m_appendAction = new QAction( KIcon( "media-track-add-amarok" ), - i18n( "&Add to Playlist" ), this ); - m_appendAction->setProperty( "popupdropper_svg_id", "append" ); - connect( m_appendAction, SIGNAL(triggered()), this, SLOT(slotAppend()) ); - - m_loadAction = new QAction( KIcon( "folder-open" ), i18nc( "Replace the currently " - "loaded tracks with these", "&Replace Playlist" ), this ); - m_loadAction->setProperty( "popupdropper_svg_id", "load" ); - connect( m_loadAction, SIGNAL(triggered()), this, SLOT(slotLoad()) ); - - m_setNewAction = new QAction( KIcon( "rating" ), i18nc( "toggle the \"new\" status " - " of this podcast episode", "&New" ), this ); - m_setNewAction->setProperty( "popupdropper_svg_id", "new" ); - m_setNewAction->setCheckable( true ); - connect( m_setNewAction, SIGNAL(triggered(bool)), SLOT(slotSetNew(bool)) ); - - m_renamePlaylistAction = new QAction( KIcon( "media-track-edit-amarok" ), - i18n( "&Rename..." ), this ); - m_renamePlaylistAction->setProperty( "popupdropper_svg_id", "edit" ); - // key shortcut is only for display purposes here, actual one is determined by View in Model/View classes - m_renamePlaylistAction->setShortcut( Qt::Key_F2 ); - connect( m_renamePlaylistAction, SIGNAL(triggered()), this, SLOT(slotRename()) ); - - m_deletePlaylistAction = new QAction( KIcon( "media-track-remove-amarok" ), - i18n( "&Delete..." ), this ); - m_deletePlaylistAction->setProperty( "popupdropper_svg_id", "delete" ); - // key shortcut is only for display purposes here, actual one is determined by View in Model/View classes - m_deletePlaylistAction->setShortcut( Qt::Key_Delete ); - connect( m_deletePlaylistAction, SIGNAL(triggered()), SLOT(slotDelete()) ); - - m_removeTracksAction = new QAction( KIcon( "media-track-remove-amarok" ), - QString( "" ), this ); - m_removeTracksAction->setProperty( "popupdropper_svg_id", "delete" ); - // key shortcut is only for display purposes here, actual one is determined by View in Model/View classes - m_removeTracksAction->setShortcut( Qt::Key_Delete ); - connect( m_removeTracksAction, SIGNAL(triggered()), SLOT(slotRemoveTracks()) ); - - m_exportAction = new QAction( KIcon( "document-export-amarok" ), - i18n( "&Export As..." ), this ); - connect( m_exportAction, SIGNAL(triggered()), this, SLOT(slotExport()) ); - - m_separatorAction = new QAction( this ); - m_separatorAction->setSeparator( true ); -} - -void -PlaylistBrowserNS::PlaylistBrowserView::setModel( QAbstractItemModel *model ) -{ - if( this->model() ) - disconnect( this->model(), 0, this, 0 ); - Amarok::PrettyTreeView::setModel( model ); - - connect( this->model(), SIGNAL(renameIndex(QModelIndex)), SLOT(edit(QModelIndex)) ); -} - -void -PlaylistBrowserNS::PlaylistBrowserView::mouseReleaseEvent( QMouseEvent *event ) -{ - if( m_pd ) - { - connect( m_pd, SIGNAL(fadeHideFinished()), m_pd, SLOT(deleteLater()) ); - m_pd->hide(); - m_pd = 0; - } - - QModelIndex index = indexAt( event->pos() ); - if( !index.isValid() ) - { - PrettyTreeView::mouseReleaseEvent( event ); - return; - } - - if( event->button() == Qt::MidButton ) - { - insertIntoPlaylist( index, Playlist::OnMiddleClickOnSelectedItems ); - event->accept(); - return; - } - - PrettyTreeView::mouseReleaseEvent( event ); -} - -void PlaylistBrowserNS::PlaylistBrowserView::startDrag( Qt::DropActions supportedActions ) -{ - // Waah? when a parent item is dragged, startDrag is called a bunch of times - if( m_ongoingDrag ) - return; - m_ongoingDrag = true; - - if( !m_pd ) - m_pd = The::popupDropperFactory()->createPopupDropper( Context::ContextView::self() ); - - if( m_pd && m_pd->isHidden() ) - { - QActionList actions = actionsFor( selectedIndexes() ); - foreach( QAction *action, actions ) - m_pd->addItem( The::popupDropperFactory()->createItem( action ) ); - - m_pd->show(); - } - - QTreeView::startDrag( supportedActions ); - - // We keep the items that the actions need to be applied to. - // Clear the data from all actions now that the PUD has executed. - resetActionTargets(); - - if( m_pd ) - { - connect( m_pd, SIGNAL(fadeHideFinished()), m_pd, SLOT(clear()) ); - m_pd->hide(); - } - m_ongoingDrag = false; -} - -void -PlaylistBrowserNS::PlaylistBrowserView::keyPressEvent( QKeyEvent *event ) -{ - QModelIndexList indices = selectedIndexes(); - // mind bug 305203 - if( indices.isEmpty() || state() != QAbstractItemView::NoState ) - { - Amarok::PrettyTreeView::keyPressEvent( event ); - return; - } - - switch( event->key() ) - { - //activated() only works for current index, not all selected - case Qt::Key_Enter: - case Qt::Key_Return: - insertIntoPlaylist( indices, Playlist::OnReturnPressedOnSelectedItems ); - return; - case Qt::Key_Delete: - { - QActionList actions = actionsFor( indices ); // sets action targets - if( actions.contains( m_removeTracksAction ) ) - m_removeTracksAction->trigger(); - else if( actions.contains( m_deletePlaylistAction ) ) - m_deletePlaylistAction->trigger(); - resetActionTargets(); - return; - } - default: - break; - } - Amarok::PrettyTreeView::keyPressEvent( event ); -} - -void -PlaylistBrowserNS::PlaylistBrowserView::mouseDoubleClickEvent( QMouseEvent *event ) -{ - if( event->button() == Qt::MidButton ) - { - event->accept(); - return; - } - - QModelIndex index = indexAt( event->pos() ); - if( !index.isValid() ) - { - event->accept(); - return; - } - - // code copied in CollectionTreeView::mouseDoubleClickEvent(), keep in sync - // mind bug 279513 - bool isExpandable = model()->hasChildren( index ); - bool wouldExpand = !visualRect( index ).contains( event->pos() ) || // clicked outside item, perhaps on expander icon - ( isExpandable && !KGlobalSettings::singleClick() ); // we're in doubleClick - if( event->button() == Qt::LeftButton && - event->modifiers() == Qt::NoModifier && - !wouldExpand ) - { - insertIntoPlaylist( index, Playlist::OnDoubleClickOnSelectedItems ); - event->accept(); - return; - } - - PrettyTreeView::mouseDoubleClickEvent( event ); -} - -void PlaylistBrowserNS::PlaylistBrowserView::contextMenuEvent( QContextMenuEvent *event ) -{ - QModelIndex clickedIdx = indexAt( event->pos() ); - - QModelIndexList indices; - if( clickedIdx.isValid() && selectedIndexes().contains( clickedIdx ) ) - indices << selectedIndexes(); - else if( clickedIdx.isValid() ) - indices << clickedIdx; - - QActionList actions = actionsFor( indices ); - if( actions.isEmpty() ) - { - resetActionTargets(); - return; - } - - KMenu menu; - foreach( QAction *action, actions ) - menu.addAction( action ); - menu.exec( mapToGlobal( event->pos() ) ); - - // We keep the items that the action need to be applied to. - // Clear the data from all actions now that the context menu has executed. - resetActionTargets(); -} - -QList -PlaylistBrowserNS::PlaylistBrowserView::actionsFor( const QModelIndexList &indexes ) -{ - resetActionTargets(); - if( indexes.isEmpty() ) - return QActionList(); - - using namespace Playlists; - QSet providers, writableProviders; - QActionList actions; - QModelIndexList newPodcastEpisodes, oldPodcastEpisodes; - foreach( const QModelIndex &idx, indexes ) - { - // direct provider actions: - actions << idx.data( PrettyTreeRoles::DecoratorRole ).value(); - - PlaylistProvider *provider = idx.data( PlaylistBrowserModel::ProviderRole ).value(); - if( provider ) - providers << provider; - bool isWritable = provider ? provider->isWritable() : false; - if( isWritable ) - writableProviders |= provider; - Meta::TrackPtr track = idx.data( PlaylistBrowserModel::TrackRole ).value(); - PlaylistPtr playlist = idx.data( PlaylistBrowserModel::PlaylistRole ).value(); - if( !track && playlist ) // a playlist (must check it is not a track) - { - m_actionPlaylists << playlist; - if( isWritable ) - m_writableActionPlaylists << playlist; - } - if( track ) - { - m_actionTracks.insert( playlist, idx.row() ); - if( isWritable ) - m_writableActionTracks.insert( playlist, idx.row() ); - } - - QVariant episodeIsNew = idx.data( PlaylistBrowserModel::EpisodeIsNewRole ); - if( episodeIsNew.type() == QVariant::Bool ) - { - if( episodeIsNew.toBool() ) - newPodcastEpisodes << idx; - else - oldPodcastEpisodes << idx; - } - } - // all actions taking provider have only sense with one provider - if( writableProviders.count() == 1 ) - m_writableActionProvider = writableProviders.toList().first(); - - // process per-provider actions - foreach( PlaylistProvider *provider, providers ) - { - // prepare arguments and get relevant actions - PlaylistList providerPlaylists; - foreach( const PlaylistPtr &playlist, m_actionPlaylists ) - { - if( playlist->provider() == provider ) - providerPlaylists << playlist; - } - actions << provider->playlistActions( providerPlaylists ); - - QMultiHash playlistTracks; - QHashIterator it( m_actionTracks ); - while( it.hasNext() ) - { - it.next(); - if( it.key()->provider() == provider ) - playlistTracks.insert( it.key(), it.value() ); - } - actions << provider->trackActions( playlistTracks ); - } - - // separate model actions from standard actions we provide (at the top) - QActionList standardActions; - if( m_actionPlaylists.isEmpty() && m_actionTracks.isEmpty() && m_writableActionProvider ) - standardActions << m_createEmptyPlaylistAction; - if( !m_actionPlaylists.isEmpty() || !m_actionTracks.isEmpty() ) - standardActions << m_appendAction << m_loadAction; - if( !newPodcastEpisodes.isEmpty() || !oldPodcastEpisodes.isEmpty() ) - { - m_setNewAction->setChecked( oldPodcastEpisodes.isEmpty() ); - m_setNewAction->setData( QVariant::fromValue( newPodcastEpisodes + oldPodcastEpisodes ) ); - standardActions << m_setNewAction; - } - if( m_writableActionPlaylists.count() == 1 && m_actionTracks.isEmpty() ) - standardActions << m_renamePlaylistAction; - if( !m_writableActionPlaylists.isEmpty() && m_actionTracks.isEmpty() ) - standardActions << m_deletePlaylistAction; - if( m_actionPlaylists.isEmpty() && !m_writableActionTracks.isEmpty() ) - { - const int actionTrackCount = m_writableActionTracks.count(); - const int playlistCount = m_writableActionTracks.uniqueKeys().count(); - if( playlistCount > 1 ) - m_removeTracksAction->setText( i18ncp( "Number of playlists is >= 2", - "Remove a Track From %2 Playlists", "Remove %1 Tracks From %2 Playlists", - actionTrackCount, playlistCount ) ); - else - m_removeTracksAction->setText( i18ncp( "%2 is saved playlist name", - "Remove a Track From %2", "Remove %1 Tracks From %2", actionTrackCount, - m_writableActionTracks.uniqueKeys().first()->prettyName() ) ); - standardActions << m_removeTracksAction; - } - if( m_actionPlaylists.count() == 1 && m_actionTracks.isEmpty() ) - standardActions << m_exportAction; - standardActions << m_separatorAction; - - return standardActions + actions; -} - -void -PlaylistBrowserView::resetActionTargets() -{ - m_writableActionProvider = 0; - m_actionPlaylists.clear(); - m_writableActionPlaylists.clear(); - m_actionTracks.clear(); - m_writableActionTracks.clear(); -} - -void -PlaylistBrowserNS::PlaylistBrowserView::currentChanged( const QModelIndex ¤t, - const QModelIndex &previous ) -{ - Q_UNUSED( previous ) - emit currentItemChanged( current ); - Amarok::PrettyTreeView::currentChanged( current, previous ); -} - -void -PlaylistBrowserView::slotCreateEmptyPlaylist() -{ - // m_actionProvider may be null, which is fine - The::playlistManager()->save( Meta::TrackList(), Amarok::generatePlaylistName( - Meta::TrackList() ), m_writableActionProvider ); -} - -void -PlaylistBrowserView::slotAppend() -{ - insertIntoPlaylist( Playlist::OnAppendToPlaylistAction ); -} - -void -PlaylistBrowserView::slotLoad() -{ - insertIntoPlaylist( Playlist::OnReplacePlaylistAction ); -} - -void -PlaylistBrowserView::slotSetNew( bool newState ) -{ - QModelIndexList indices = m_setNewAction->data().value(); - foreach( const QModelIndex &idx, indices ) - model()->setData( idx, newState, PlaylistBrowserModel::EpisodeIsNewRole ); -} - -void -PlaylistBrowserView::slotRename() -{ - if( m_writableActionPlaylists.count() != 1 ) - { - warning() << __PRETTY_FUNCTION__ << "m_writableActionPlaylists.count() is not 1"; - return; - } - Playlists::PlaylistPtr playlist = m_writableActionPlaylists.at( 0 ); - - // TODO: this makes a rather complicated round-trip and ends up in edit(QModelIndex) - // here -- simplify that - The::playlistManager()->rename( playlist ); -} - -void -PlaylistBrowserView::slotDelete() -{ - if( m_writableActionPlaylists.isEmpty() ) - return; - - using namespace Playlists; - QHash providerPlaylists; - foreach( const PlaylistPtr &playlist, m_writableActionPlaylists ) - { - if( playlist->provider() ) - providerPlaylists[ playlist->provider() ] << playlist; - } - QStringList providerNames; - foreach( const PlaylistProvider *provider, providerPlaylists.keys() ) - providerNames << provider->prettyName(); - - KDialog dialog; - dialog.setCaption( i18n( "Confirm Playlist Deletion" ) ); - dialog.setButtons( KDialog::Ok | KDialog::Cancel ); - QLabel *label = new QLabel( i18np( "Are you sure you want to delete this playlist?", - "Are you sure you want to delete these %1 playlists?", - m_writableActionPlaylists.count() ), &dialog ); - // TODO: include a text area with all the names of the playlists - dialog.setButtonText( KDialog::Ok, i18nc( "%1 is playlist provider pretty name", - "Yes, delete from %1.", providerNames.join( ", " ) ) ); - dialog.setMainWidget( label ); - if( dialog.exec() == QDialog::Accepted ) - { - foreach( PlaylistProvider *provider, providerPlaylists.keys() ) - provider->deletePlaylists( providerPlaylists.value( provider ) ); - } -} - -void -PlaylistBrowserView::slotRemoveTracks() -{ - foreach( Playlists::PlaylistPtr playlist, m_writableActionTracks.uniqueKeys() ) - { - QList trackIndices = m_writableActionTracks.values( playlist ); - qSort( trackIndices ); - int removed = 0; - foreach( int trackIndex, trackIndices ) - { - playlist->removeTrack( trackIndex - removed /* account for already removed */ ); - removed++; - } - } -} - -void -PlaylistBrowserView::slotExport() -{ - if( m_actionPlaylists.count() != 1 ) - { - warning() << __PRETTY_FUNCTION__ << "m_actionPlaylists.count() is not 1"; - return; - } - Playlists::PlaylistPtr playlist = m_actionPlaylists.at( 0 ); - - // --- display save location dialog - // compare with MainWindow::exportPlaylist - // TODO: have this code only once - QCheckBox *saveRelativeCheck = new QCheckBox( i18n("Use relative path for &saving") ); - saveRelativeCheck->setChecked( AmarokConfig::relativePlaylist() ); - KFileDialog fileDialog( KUrl( "kfiledialog:///amarok-playlist-export" ), QString(), 0, saveRelativeCheck ); - - QStringList supportedMimeTypes; - supportedMimeTypes << "video/x-ms-asf"; // ASX - supportedMimeTypes << "audio/x-mpegurl"; // M3U - supportedMimeTypes << "audio/x-scpls"; // PLS - supportedMimeTypes << "application/xspf+xml"; // XSPF - - fileDialog.setSelection( playlist->name() ); - fileDialog.setMimeFilter( supportedMimeTypes, supportedMimeTypes.value( 1 ) ); - fileDialog.setOperationMode( KFileDialog::Saving ); - fileDialog.setMode( KFile::File ); - fileDialog.setCaption( i18n("Save As") ); - fileDialog.setObjectName( "PlaylistExport" ); - - fileDialog.exec(); - QString playlistPath = fileDialog.selectedFile(); - - // --- actually save the playlist - if( !playlistPath.isEmpty() ) - Playlists::exportPlaylistFile( playlist->tracks(), playlistPath, saveRelativeCheck->isChecked() ); -} - -void -PlaylistBrowserView::insertIntoPlaylist( const QModelIndex &index, Playlist::AddOptions options ) -{ - insertIntoPlaylist( QModelIndexList() << index, options ); -} - -void -PlaylistBrowserView::insertIntoPlaylist( const QModelIndexList &list, Playlist::AddOptions options ) -{ - actionsFor( list ); // sets action targets - insertIntoPlaylist( options ); - resetActionTargets(); -} - -void -PlaylistBrowserView::insertIntoPlaylist( Playlist::AddOptions options ) -{ - Meta::TrackList tracks; - - // add tracks for fully-selected playlists: - foreach( Playlists::PlaylistPtr playlist, m_actionPlaylists ) - { - tracks << playlist->tracks(); - } - - // filter-out tracks from playlists that are selected, add lone tracks: - foreach( Playlists::PlaylistPtr playlist, m_actionTracks.uniqueKeys() ) - { - if( m_actionPlaylists.contains( playlist ) ) - continue; - - Meta::TrackList playlistTracks = playlist->tracks(); - QList positions = m_actionTracks.values( playlist ); - qSort( positions ); - foreach( int position, positions ) - { - if( position >= 0 && position < playlistTracks.count() ) - tracks << playlistTracks.at( position ); - } - } - - if( !tracks.isEmpty() ) - The::playlistController()->insertOptioned( tracks, options ); -} diff --git a/amarok/src/browsers/playlistbrowser/PlaylistBrowserView.h b/amarok/src/browsers/playlistbrowser/PlaylistBrowserView.h deleted file mode 100644 index e5eb057a..00000000 --- a/amarok/src/browsers/playlistbrowser/PlaylistBrowserView.h +++ /dev/null @@ -1,106 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Nikolaj Hald Nielsen * - * Copyright (c) 2010 Bart Cerneels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef PLAYLISTBROWSERVIEW_H -#define PLAYLISTBROWSERVIEW_H - -#include "core/playlists/Playlist.h" -#include "playlist/PlaylistController.h" -#include "widgets/PrettyTreeView.h" - -#include - -class PopupDropper; -class QKeyEvent; -class QMouseEvent; -class QContextMenuEvent; - -namespace PlaylistBrowserNS { - -class PlaylistBrowserView : public Amarok::PrettyTreeView -{ -Q_OBJECT -public: - explicit PlaylistBrowserView( QAbstractItemModel *model, QWidget *parent = 0 ); - - virtual void setModel( QAbstractItemModel *model ); - -signals: - void currentItemChanged( const QModelIndex ¤t ); - -protected: - // TODO: re-implement QWidget::dragEnterEvent() to show drop-not-allowed indicator - - virtual void keyPressEvent( QKeyEvent *event ); - virtual void mouseDoubleClickEvent( QMouseEvent *event ); - virtual void mouseReleaseEvent( QMouseEvent *event ); - virtual void startDrag( Qt::DropActions supportedActions ); - - virtual void contextMenuEvent( QContextMenuEvent *event ); - -protected slots: - /** reimplemented to emit a signal */ - void currentChanged( const QModelIndex ¤t, const QModelIndex &previous ); - -private slots: - // these are connected to m_*Actions: - void slotCreateEmptyPlaylist(); - void slotAppend(); - void slotLoad(); - void slotSetNew( bool newState ); - void slotRename(); - void slotDelete(); - void slotRemoveTracks(); - void slotExport(); - -private: - void insertIntoPlaylist( const QModelIndex &index, Playlist::AddOptions options ); - void insertIntoPlaylist( const QModelIndexList &list, Playlist::AddOptions options ); - void insertIntoPlaylist( Playlist::AddOptions options ); - - /** - * Gets action for a list of indices and sets internal action targets to these. - * - * After you have processed/triggered the actions, you should call - * resetActionTargets() to prevent stale targets laying around. - */ - QList actionsFor( const QModelIndexList &indexes ); - void resetActionTargets(); - - PopupDropper* m_pd; - - QAction *m_createEmptyPlaylistAction; - QAction *m_appendAction; - QAction *m_loadAction; - QAction *m_setNewAction; // for podcasts - QAction *m_renamePlaylistAction; - QAction *m_deletePlaylistAction; - QAction *m_removeTracksAction; - QAction *m_exportAction; - QAction *m_separatorAction; - bool m_ongoingDrag; - - Playlists::PlaylistProvider *m_writableActionProvider; - Playlists::PlaylistList m_actionPlaylists; - Playlists::PlaylistList m_writableActionPlaylists; - QMultiHash m_actionTracks; // maps playlists to track positions - QMultiHash m_writableActionTracks; -}; - -} // namespace PlaylistBrowserNS - -#endif // PLAYLISTBROWSERVIEW_H diff --git a/amarok/src/browsers/playlistbrowser/PlaylistViewItem.h b/amarok/src/browsers/playlistbrowser/PlaylistViewItem.h deleted file mode 100644 index e3934d89..00000000 --- a/amarok/src/browsers/playlistbrowser/PlaylistViewItem.h +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Nikolaj Hald Nielsen * - * Copyright (c) 2008 Bart Cerneels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef PLAYLISTVIEWITEM_H -#define PLAYLISTVIEWITEM_H - -#include "core/meta/PlaylistGroup.h" - -#include -#include - -/** - @author Nikolaj Hald Nielsen -*/ - -class PlaylistViewItem; -typedef KSharedPtr PlaylistViewItemPtr; - -class PlaylistViewItem : public virtual QSharedData -{ - public: - PlaylistViewItem() : QSharedData() {} - - virtual ~PlaylistViewItem() {}; - - virtual Meta::PlaylistGroupPtr parent() const = 0; - virtual int childCount() const { return 0; } - virtual QString name() const = 0; - virtual QString description() const = 0; - virtual void rename( const QString &name ) = 0; - -}; - -Q_DECLARE_METATYPE( PlaylistViewItemPtr ) - -#endif diff --git a/amarok/src/browsers/playlistbrowser/PlaylistsByProviderProxy.cpp b/amarok/src/browsers/playlistbrowser/PlaylistsByProviderProxy.cpp deleted file mode 100644 index 1caafb06..00000000 --- a/amarok/src/browsers/playlistbrowser/PlaylistsByProviderProxy.cpp +++ /dev/null @@ -1,282 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Bart Cerneels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "PlaylistsByProviderProxy.h" - -#include "AmarokMimeData.h" -#include "PlaylistBrowserModel.h" - -#include "core/playlists/PlaylistProvider.h" -#include "core/support/Debug.h" -#include "playlistmanager/PlaylistManager.h" -#include "widgets/PrettyTreeRoles.h" - -#include - -#include - -PlaylistsByProviderProxy::PlaylistsByProviderProxy( int playlistCategory, QObject *parent ) - : QtGroupingProxy( parent ) - , m_playlistCategory( playlistCategory ) -{ - // we need this to track providers with no playlists - connect( The::playlistManager(), SIGNAL(providerAdded(Playlists::PlaylistProvider*,int)), - this, SLOT(slotProviderAdded(Playlists::PlaylistProvider*,int)) ); - connect( The::playlistManager(), SIGNAL(providerRemoved(Playlists::PlaylistProvider*,int)), - this, SLOT(slotProviderRemoved(Playlists::PlaylistProvider*,int)) ); -} - -//TODO: remove this contructor -PlaylistsByProviderProxy::PlaylistsByProviderProxy( QAbstractItemModel *model, int column, int playlistCategory ) - : QtGroupingProxy( model, QModelIndex(), column ) - , m_playlistCategory( playlistCategory ) -{ - setSourceModel( model ); - - // we need this to track providers with no playlists - connect( The::playlistManager(), SIGNAL(providerAdded(Playlists::PlaylistProvider*,int)), - this, SLOT(slotProviderAdded(Playlists::PlaylistProvider*,int)) ); - connect( The::playlistManager(), SIGNAL(providerRemoved(Playlists::PlaylistProvider*,int)), - this, SLOT(slotProviderRemoved(Playlists::PlaylistProvider*,int)) ); -} - -QVariant -PlaylistsByProviderProxy::data( const QModelIndex &idx, int role ) const -{ - //TODO: actions for empty providers - - //TODO: filter out actions not from the provider, possibly using QAction separators marking - // the source of the actions (makes sense in the UI as well. - - //Turn the QVariantList of the source into a comma separated string, but only for the real items - if( !isGroup( idx ) && idx.column() == PlaylistBrowserNS::PlaylistBrowserModel::ProviderColumn - && role == Qt::DisplayRole ) - { - QVariant indexData = QtGroupingProxy::data( idx, role ); - if( indexData.type() != QVariant::List ) - return indexData; - - QString providerString = indexData.toStringList().join( ", " ); - return QVariant( providerString ); - } - - return QtGroupingProxy::data( idx, role ); -} - -Qt::ItemFlags -PlaylistsByProviderProxy::flags( const QModelIndex &idx ) const -{ - //TODO: check if provider supports addPlaylist for DropEnabled - if( isGroup( idx ) ) - return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsDropEnabled; - - return QtGroupingProxy::flags( idx ); -} - -bool -PlaylistsByProviderProxy::removeRows( int row, int count, const QModelIndex &parent ) -{ - DEBUG_BLOCK - bool result; - debug() << "in parent " << parent << "remove " << count << " starting at row " << row; - QModelIndex originalIdx = mapToSource( parent ); - result = sourceModel()->removeRows( row, count, originalIdx ); - if( result ) - { - beginRemoveRows( parent, row, row + count - 1 ); - endRemoveRows(); - } - return result; -} - -//TODO: move the next 3 implementation to QtGroupingProxy -QStringList -PlaylistsByProviderProxy::mimeTypes() const -{ - //nothing to add - return sourceModel()->mimeTypes(); -} - -QMimeData * -PlaylistsByProviderProxy::mimeData( const QModelIndexList &indexes ) const -{ - DEBUG_BLOCK - QModelIndexList sourceIndexes; - foreach( const QModelIndex &idx, indexes ) - { - if( isGroup( idx ) ) - continue; // drags not enabled for playlist providers - QModelIndex originalIdx = mapToSource( idx ); - if( originalIdx.isValid() ) - sourceIndexes << originalIdx; - } - - if( sourceIndexes.isEmpty() ) - return 0; - return sourceModel()->mimeData( sourceIndexes ); -} - -bool -PlaylistsByProviderProxy::dropMimeData( const QMimeData *data, Qt::DropAction action, - int row, int column, const QModelIndex &parent ) -{ - DEBUG_BLOCK - debug() << "Dropped on" << parent << "row" << row << "column" << column << "action" << action; - if( action == Qt::IgnoreAction ) - return true; - - if( !isGroup( parent ) ) // drops on empty space fall here, it is okay - { - QModelIndex sourceIndex = mapToSource( parent ); - return sourceModel()->dropMimeData( data, action, row, column, sourceIndex ); - } - - const AmarokMimeData *amarokData = dynamic_cast( data ); - if( !amarokData ) - { - debug() << __PRETTY_FUNCTION__ << "supports only drag & drop originating in Amarok."; - return false; - } - - Playlists::PlaylistProvider *provider = - parent.data( PlaylistBrowserNS::PlaylistBrowserModel::ProviderRole ) - .value(); - if( !provider ) - { - warning() << "Dropped tracks to a group with no (or multiple) providers!"; - return false; - } - - if( amarokData->hasFormat( AmarokMimeData::PLAYLIST_MIME ) ) - { - debug() << "Dropped playlists to provider" << provider->prettyName(); - foreach( Playlists::PlaylistPtr pl, amarokData->playlists() ) - { - // few PlaylistProviders implement addPlaylist(), use save() instead: - The::playlistManager()->save( pl->tracks(), pl->name(), provider, false /* editName */ ); - } - return true; - } - if( amarokData->hasFormat( AmarokMimeData::TRACK_MIME ) ) - { - debug() << "Dropped tracks to provider" << provider->prettyName(); - Meta::TrackList tracks = amarokData->tracks(); - QString playlistName = Amarok::generatePlaylistName( tracks ); - return The::playlistManager()->save( tracks, playlistName, provider ); - } - - debug() << __PRETTY_FUNCTION__ << "Unsupported drop mime-data:" << data->formats(); - return false; -} - -Qt::DropActions -PlaylistsByProviderProxy::supportedDropActions() const -{ - //always add CopyAction because playlists can copied to a Provider - return sourceModel()->supportedDropActions() | Qt::CopyAction; -} - -Qt::DropActions -PlaylistsByProviderProxy::supportedDragActions() const -{ - //always add CopyAction because playlists can be put into a different group - return sourceModel()->supportedDragActions() | Qt::CopyAction; -} - -void -PlaylistsByProviderProxy::setSourceModel( QAbstractItemModel *model ) -{ - if( sourceModel() ) - sourceModel()->disconnect(); - - QtGroupingProxy::setSourceModel( model ); - - connect( sourceModel(), SIGNAL(renameIndex(QModelIndex)), - SLOT(slotRenameIndex(QModelIndex)) ); -} - -void -PlaylistsByProviderProxy::buildTree() -{ - //clear that data anyway since provider can disappear and should no longer be listed. - m_groupMaps.clear(); - - //add the empty providers at the top of the list - PlaylistProviderList providerList = - The::playlistManager()->providersForCategory( m_playlistCategory ); - - foreach( Playlists::PlaylistProvider *provider, providerList ) - { - slotProviderAdded( provider, provider->category() ); - } - - QtGroupingProxy::buildTree(); -} - -void -PlaylistsByProviderProxy::slotRenameIndex( const QModelIndex &sourceIdx ) -{ - QModelIndex idx = mapFromSource( sourceIdx ); - if( idx.isValid() ) - emit renameIndex( idx ); -} - -void -PlaylistsByProviderProxy::slotProviderAdded( Playlists::PlaylistProvider *provider, int category ) -{ - DEBUG_BLOCK - if( category != m_playlistCategory ) - return; - - if( provider->playlistCount() > 0 - || ( provider->playlistCount() < 0 /* not counted */ - && !provider->playlists().isEmpty() ) ) - return; // non-empty providers are handled by PlaylistBrowserModel - - ItemData itemData; - itemData.insert( Qt::DisplayRole, provider->prettyName() ); - itemData.insert( Qt::DecorationRole, provider->icon() ); - itemData.insert( PrettyTreeRoles::DecoratorRole, QVariant::fromValue( provider->providerActions() ) ); - itemData.insert( PrettyTreeRoles::DecoratorRoleCount, provider->providerActions().count() ); - - itemData.insert( PlaylistBrowserNS::PlaylistBrowserModel::ProviderRole, - QVariant::fromValue( provider ) ); - RowData rowData; - rowData.insert( PlaylistBrowserNS::PlaylistBrowserModel::PlaylistItemColumn, itemData ); - //Provider column is used for filtering. - rowData.insert( PlaylistBrowserNS::PlaylistBrowserModel::ProviderColumn, itemData ); - - addEmptyGroup( rowData ); -} - -void -PlaylistsByProviderProxy::slotProviderRemoved( Playlists::PlaylistProvider *provider, int category ) -{ - DEBUG_BLOCK - if( category != m_playlistCategory ) - return; - - for( int i = 0; i < rowCount(); i++ ) - { - QModelIndex idx = index( i, PlaylistBrowserNS::PlaylistBrowserModel::PlaylistItemColumn ); - Playlists::PlaylistProvider *rowProvider = data( idx, PlaylistBrowserNS::PlaylistBrowserModel::ProviderRole ) - .value(); - if( rowProvider != provider ) - continue; - - removeGroup( idx ); - } -} diff --git a/amarok/src/browsers/playlistbrowser/PlaylistsByProviderProxy.h b/amarok/src/browsers/playlistbrowser/PlaylistsByProviderProxy.h deleted file mode 100644 index 78888ae6..00000000 --- a/amarok/src/browsers/playlistbrowser/PlaylistsByProviderProxy.h +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Bart Cerneels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ -#ifndef PLAYLISTSBYPROVIDERPROXY_H -#define PLAYLISTSBYPROVIDERPROXY_H - -#include "QtGroupingProxy.h" -#include "PlaylistBrowserModel.h" - -#include - -class PlaylistsByProviderProxy : public QtGroupingProxy -{ - Q_OBJECT - public: - explicit PlaylistsByProviderProxy( int playlistCategory, QObject *parent = 0 ); - PlaylistsByProviderProxy( QAbstractItemModel *model, int column, int playlistCategory ); - ~PlaylistsByProviderProxy() {} - - /* QtGroupingProxy methods */ - /* reimplement to handle tracks with multiple providers (synced) */ - virtual QVariant data( const QModelIndex &idx, int role ) const; - - /* reimplemented to prevent changing providers name */ - virtual Qt::ItemFlags flags( const QModelIndex &idx ) const; - - /* QAbstractModel methods */ - virtual bool removeRows( int row, int count, - const QModelIndex &parent = QModelIndex() ); - virtual QStringList mimeTypes() const; - virtual QMimeData *mimeData( const QModelIndexList &indexes ) const; - virtual bool dropMimeData( const QMimeData *data, Qt::DropAction action, - int row, int column, const QModelIndex &parent ); - - virtual Qt::DropActions supportedDropActions() const; - virtual Qt::DropActions supportedDragActions() const; - - // re-implement to connect renameIndex signal - virtual void setSourceModel( QAbstractItemModel *sourceModel ); - - signals: - void renameIndex( const QModelIndex &idx ); - - protected slots: - //re-implemented to add empty providers - virtual void buildTree(); - - private slots: - void slotRenameIndex( const QModelIndex &index ); - void slotProviderAdded( Playlists::PlaylistProvider *provider, int category ); - void slotProviderRemoved( Playlists::PlaylistProvider *provider, int category ); - - private: - int m_playlistCategory; -}; - -#endif // PLAYLISTSBYPROVIDERPROXY_H diff --git a/amarok/src/browsers/playlistbrowser/PlaylistsInFoldersProxy.cpp b/amarok/src/browsers/playlistbrowser/PlaylistsInFoldersProxy.cpp deleted file mode 100644 index ebb7002d..00000000 --- a/amarok/src/browsers/playlistbrowser/PlaylistsInFoldersProxy.cpp +++ /dev/null @@ -1,378 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Bart Cerneels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "PlaylistsInFoldersProxy.h" - -#include "AmarokMimeData.h" -#include "core/support/Debug.h" -#include "core/playlists/Playlist.h" -#include "SvgHandler.h" -#include "UserPlaylistModel.h" -#include "playlist/PlaylistModelStack.h" -#include "widgets/PrettyTreeRoles.h" - -#include -#include -#include - -#include - -PlaylistsInFoldersProxy::PlaylistsInFoldersProxy( QAbstractItemModel *model ) - : QtGroupingProxy( model, QModelIndex(), PlaylistBrowserNS::UserModel::LabelColumn ) -{ - m_renameFolderAction = new QAction( KIcon( "media-track-edit-amarok" ), - i18n( "&Rename Folder..." ), this ); - m_renameFolderAction->setProperty( "popupdropper_svg_id", "edit_group" ); - connect( m_renameFolderAction, SIGNAL(triggered()), this, - SLOT(slotRenameFolder()) ); - - m_deleteFolderAction = new QAction( KIcon( "media-track-remove-amarok" ), - i18n( "&Delete Folder" ), this ); - m_deleteFolderAction->setProperty( "popupdropper_svg_id", "delete_group" ); - m_deleteFolderAction->setObjectName( "deleteAction" ); - connect( m_deleteFolderAction, SIGNAL(triggered()), this, - SLOT(slotDeleteFolder()) ); - - connect( sourceModel(), SIGNAL(renameIndex(QModelIndex)), - SLOT(slotRenameIndex(QModelIndex)) ); -} - -PlaylistsInFoldersProxy::~PlaylistsInFoldersProxy() -{ -} - -QVariant -PlaylistsInFoldersProxy::data( const QModelIndex &idx, int role ) const -{ - - //Turn the QVariantList of the source into a comma separated string, but only for the real items - if( !isGroup( idx ) && idx.column() == PlaylistBrowserNS::PlaylistBrowserModel::ProviderColumn - && role == Qt::DisplayRole ) - { - QVariant indexData = QtGroupingProxy::data( idx, role ); - if( indexData.type() != QVariant::List ) - return indexData; - - QString providerString = indexData.toStringList().join( ", " ); - return QVariant( providerString ); - } - - if( idx.column() == 0 && isGroup( idx ) && - role == PrettyTreeRoles::DecoratorRole ) - { - //whether we use the list from m_deleteFolderAction or m_renameFolderAction does not matter - //they are the same anyway - QPersistentModelIndexList actionList = - m_deleteFolderAction->data().value(); - - //make a persistant modelindex since the location of the groups can change while executing - //actions. - actionList << QPersistentModelIndex( idx ); - QVariant value = QVariant::fromValue( actionList ); - m_deleteFolderAction->setData( value ); - m_renameFolderAction->setData( value ); - - QList actions; - actions << m_renameFolderAction << m_deleteFolderAction; - return QVariant::fromValue( actions ); - } - - if( idx.column() == 0 && isGroup( idx ) && - role == PrettyTreeRoles::DecoratorRoleCount ) - return 2; // 2 actions, see above - - return QtGroupingProxy::data( idx, role ); -} - -bool -PlaylistsInFoldersProxy::removeRows( int row, int count, const QModelIndex &parent ) -{ - DEBUG_BLOCK - bool result; - debug() << "in parent " << parent << "remove " << count << " starting at row " << row; - if( !parent.isValid() ) - { - QModelIndex folderIdx = index( row, 0, QModelIndex() ); - if( isGroup( folderIdx ) ) - { - deleteFolder( folderIdx ); - return true; - } - - //is a playlist not in a folder - QModelIndex childIdx = mapToSource( index( row, 0, m_rootIndex ) ); - result = sourceModel()->removeRows( childIdx.row(), count, m_rootIndex ); - if( result ) - { - beginRemoveRows( parent, row, row + count - 1 ); - endRemoveRows(); - } - return result; - } - - if( isGroup( parent ) ) - { - result = true; - for( int i = row; i < row + count; i++ ) - { - QModelIndex childIdx = mapToSource( index( i, 0, parent ) ); - //set success to false if removeRows returns false - result = sourceModel()->removeRow( childIdx.row(), QModelIndex() ) ? result : false; - } - return result; - } - - //removing a track from a playlist - beginRemoveRows( parent, row, row + count - 1 ); - QModelIndex originalIdx = mapToSource( parent ); - result = sourceModel()->removeRows( row, count, originalIdx ); - endRemoveRows(); - - return result; -} - -QStringList -PlaylistsInFoldersProxy::mimeTypes() const -{ - QStringList mimeTypes = sourceModel()->mimeTypes(); - mimeTypes << AmarokMimeData::PLAYLISTBROWSERGROUP_MIME; - return mimeTypes; -} - -QMimeData * -PlaylistsInFoldersProxy::mimeData( const QModelIndexList &indexes ) const -{ - DEBUG_BLOCK - AmarokMimeData* mime = new AmarokMimeData(); - QModelIndexList sourceIndexes; - foreach( const QModelIndex &idx, indexes ) - { - debug() << idx; - if( isGroup( idx ) ) - { - debug() << "is a group, add mimeData of all children"; - } - else - { - debug() << "is original item, add mimeData from source model"; - sourceIndexes << mapToSource( idx ); - } - } - - if( !sourceIndexes.isEmpty() ) - return sourceModel()->mimeData( sourceIndexes ); - - return mime; -} - -bool -PlaylistsInFoldersProxy::dropMimeData( const QMimeData *data, Qt::DropAction action, - int row, int column, const QModelIndex &parent ) -{ - DEBUG_BLOCK - Q_UNUSED( row ); - Q_UNUSED( column ); - debug() << "dropped on " << QString("row: %1, column: %2, parent:").arg( row ).arg( column ); - debug() << parent; - if( action == Qt::IgnoreAction ) - { - debug() << "ignored"; - return true; - } - - if( data->hasFormat( AmarokMimeData::PLAYLIST_MIME ) || - data->hasFormat( AmarokMimeData::PLAYLISTBROWSERGROUP_MIME ) ) - { - debug() << "has amarok mime data"; - const AmarokMimeData *amarokMime = dynamic_cast(data); - if( amarokMime == 0 ) - { - error() << "could not cast to amarokMimeData"; - return false; - } - - if( !parent.isValid() ) - { - debug() << "dropped on the root"; - Playlists::PlaylistList playlists = amarokMime->playlists(); - foreach( Playlists::PlaylistPtr playlist, playlists ) - playlist->setGroups( QStringList() ); - buildTree(); - return true; - } - - if( isGroup( parent ) ) - { - debug() << "dropped on a group"; - if( data->hasFormat( AmarokMimeData::PLAYLIST_MIME ) ) - { - debug() << "playlist dropped on group"; - if( parent.row() < 0 || parent.row() >= rowCount( QModelIndex() ) ) - { - debug() << "ERROR: something went seriously wrong in " << __FILE__ << __LINE__; - return false; - } - //apply the new groupname to the source index - QString groupName = parent.data( Qt::DisplayRole ).toString(); - //TODO: apply the new groupname to the source index - Playlists::PlaylistList playlists = amarokMime->playlists(); - foreach( Playlists::PlaylistPtr playlist, playlists ) - playlist->setGroups( QStringList( groupName ) ); - buildTree(); - return true; - } - else if( data->hasFormat( AmarokMimeData::PLAYLISTBROWSERGROUP_MIME ) ) - { - debug() << "playlistgroup dropped on group"; - //TODO: multilevel group support - debug() << "ignore drop until we have multilevel group support"; - return false; - } - } - } - else - { - QModelIndex sourceIndex = mapToSource( parent ); - return sourceModel()->dropMimeData( data, action, row, column, - sourceIndex ); - } - - return false; -} - -Qt::DropActions -PlaylistsInFoldersProxy::supportedDropActions() const -{ - //always add MoveAction because playlists can be put into a different group - return sourceModel()->supportedDropActions() | Qt::MoveAction; -} - -Qt::DropActions -PlaylistsInFoldersProxy::supportedDragActions() const -{ - //always add MoveAction because playlists can be put into a different group - return sourceModel()->supportedDragActions() | Qt::MoveAction; -} - -void -PlaylistsInFoldersProxy::setSourceModel( QAbstractItemModel *model ) -{ - if( sourceModel() ) - sourceModel()->disconnect(); - - QtGroupingProxy::setSourceModel( model ); - - connect( sourceModel(), SIGNAL(renameIndex(QModelIndex)), - SLOT(slotRenameIndex(QModelIndex)) ); -} - -void -PlaylistsInFoldersProxy::slotRenameIndex( const QModelIndex &sourceIdx ) -{ - QModelIndex idx = mapFromSource( sourceIdx ); - if( idx.isValid() ) - emit renameIndex( idx ); -} - -void -PlaylistsInFoldersProxy::slotDeleteFolder() -{ - QAction *action = qobject_cast( QObject::sender() ); - if( action == 0 ) - return; - - QPersistentModelIndexList indexes = action->data().value(); - - foreach( const QModelIndex &groupIdx, indexes ) - deleteFolder( groupIdx ); -} - -void -PlaylistsInFoldersProxy::slotRenameFolder() -{ - QAction *action = qobject_cast( QObject::sender() ); - if( action == 0 ) - return; - - QPersistentModelIndexList indexes = action->data().value(); - - if( indexes.isEmpty() ) - return; - - //get the name for this new group - //inline rename is handled by the view using setData() - QModelIndex folder = indexes.first(); - QString folderName = folder.data( Qt::DisplayRole ).toString(); - bool ok; - const QString newName = KInputDialog::getText( i18n("New name"), - i18nc("Enter a new name for a folder that already exists", - "Enter new folder name:"), - folderName, - &ok ); - if( !ok || newName == folderName ) - return; - - setData( folder, newName ); -} - -void -PlaylistsInFoldersProxy::deleteFolder( const QModelIndex &groupIdx ) -{ - int childCount = rowCount( groupIdx ); - if( childCount > 0 ) - { - KDialog dialog; - dialog.setCaption( i18n( "Confirm Delete" ) ); - dialog.setButtons( KDialog::Ok | KDialog::Cancel ); - QLabel label( i18n( "Are you sure you want to delete this folder and its contents?" ) - , &dialog - ); - //TODO:include a text area with all the names of the playlists - dialog.setButtonText( KDialog::Ok, i18n( "Yes, delete folder." ) ); - dialog.setMainWidget( &label ); - if( dialog.exec() != QDialog::Accepted ) - return; - - removeRows( 0, childCount, groupIdx ); - } - removeGroup( groupIdx ); - //force a rebuild because groupHash might be incorrect - //TODO: make QtGroupingProxy adjust groupHash keys - buildTree(); -} - -QModelIndex -PlaylistsInFoldersProxy::createNewFolder( const QString &groupName ) -{ - RowData data; - ItemData roleData; - roleData.insert( Qt::DisplayRole, groupName ); - roleData.insert( Qt::DecorationRole, QVariant( KIcon( "folder" ) ) ); - roleData.insert( Qt::EditRole, groupName ); - data.insert( 0, roleData ); - return addEmptyGroup( data ); -} - -Qt::ItemFlags PlaylistsInFoldersProxy::flags(const QModelIndex &idx) const -{ - if( isGroup(idx) && idx.column() == 0) - return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable | - Qt::ItemIsDropEnabled; - - return QtGroupingProxy::flags(idx); -} - -#include "moc_PlaylistsInFoldersProxy.cpp" diff --git a/amarok/src/browsers/playlistbrowser/PlaylistsInFoldersProxy.h b/amarok/src/browsers/playlistbrowser/PlaylistsInFoldersProxy.h deleted file mode 100644 index a0a07209..00000000 --- a/amarok/src/browsers/playlistbrowser/PlaylistsInFoldersProxy.h +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Bart Cerneels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef PLAYLISTSINFOLDERSPROXY_H -#define PLAYLISTSINFOLDERSPROXY_H - -#include "QtGroupingProxy.h" -#include "PlaylistBrowserModel.h" - -#include - -class QAction; - -typedef QList QPersistentModelIndexList; - -class PlaylistsInFoldersProxy : public QtGroupingProxy -{ - Q_OBJECT - public: - PlaylistsInFoldersProxy( QAbstractItemModel *model ); - ~PlaylistsInFoldersProxy(); - - /* PlaylistInGroupsProxy methods */ - QModelIndex createNewFolder( const QString &groupName ); - - /* QtGroupingProxy methods */ - //re-implemented to make folder name (== label) editable. - virtual Qt::ItemFlags flags(const QModelIndex &idx) const; - virtual QVariant data( const QModelIndex &idx, int role ) const; - - /* QAbstractModel methods */ - virtual bool removeRows( int row, int count, - const QModelIndex &parent = QModelIndex() ); - virtual QStringList mimeTypes() const; - virtual QMimeData *mimeData( const QModelIndexList &indexes ) const; - virtual bool dropMimeData( const QMimeData *data, Qt::DropAction action, - int row, int column, const QModelIndex &parent ); - - virtual Qt::DropActions supportedDropActions() const; - virtual Qt::DropActions supportedDragActions() const; - - // re-implement to connect renameIndex signal - virtual void setSourceModel( QAbstractItemModel *sourceModel ); - - signals: - void renameIndex( const QModelIndex &idx ); - - private slots: - void slotRenameIndex( const QModelIndex &idx ); - - void slotDeleteFolder(); - void slotRenameFolder(); - - private: - QList createGroupActions(); - void deleteFolder( const QModelIndex &groupIdx ); - - QAction *m_renameFolderAction; - QAction *m_deleteFolderAction; -}; - -Q_DECLARE_METATYPE(QPersistentModelIndexList); - -#endif //PLAYLISTSINFOLDERSPROXY_H diff --git a/amarok/src/browsers/playlistbrowser/PodcastCategory.cpp b/amarok/src/browsers/playlistbrowser/PodcastCategory.cpp deleted file mode 100644 index 9ef9acb8..00000000 --- a/amarok/src/browsers/playlistbrowser/PodcastCategory.cpp +++ /dev/null @@ -1,284 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007-2010 Bart Cerneels * - * Copyright (c) 2007-2008 Nikolaj Hald Nielsen * - * Copyright (c) 2007 Henry de Valence * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "PodcastCategory" - -#include "PodcastCategory.h" - -#include "amarokconfig.h" -#include "amarokurls/AmarokUrl.h" -#include "App.h" -#include "browsers/InfoProxy.h" -#include "core/support/Debug.h" -#include "core/meta/support/MetaUtility.h" -#include "PaletteHandler.h" -#include "PodcastModel.h" -#include "PlaylistBrowserView.h" -#include "widgets/PrettyTreeRoles.h" - -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -namespace The -{ - PlaylistBrowserNS::PodcastCategory* podcastCategory() - { - return PlaylistBrowserNS::PodcastCategory::instance(); - } -} - -using namespace PlaylistBrowserNS; - -QString PodcastCategory::s_configGroup( "Podcast View" ); - -PodcastCategory* PodcastCategory::s_instance = 0; - -PodcastCategory* -PodcastCategory::instance() -{ - return s_instance ? s_instance : new PodcastCategory( 0 ); -} - -void -PodcastCategory::destroy() -{ - if( s_instance ) - { - delete s_instance; - s_instance = 0; - } -} - -PodcastCategory::PodcastCategory( QWidget *parent ) - : PlaylistBrowserCategory( Playlists::PodcastChannelPlaylist, - "podcasts", - s_configGroup, - The::podcastModel(), - parent ) -{ - setPrettyName( i18n( "Podcasts" ) ); - setShortDescription( i18n( "List of podcast subscriptions and episodes" ) ); - setIcon( KIcon( "podcast-amarok" ) ); - - setLongDescription( i18n( "Manage your podcast subscriptions and browse individual episodes. " - "Downloading episodes to the disk is also done here, or you can tell " - "Amarok to do this automatically." ) ); - - setImagePath( KStandardDirs::locate( "data", "amarok/images/hover_info_podcasts.png" ) ); - - // set background - if( AmarokConfig::showBrowserBackgroundImage() ) - setBackgroundImage( imagePath() ); - - QAction *addPodcastAction = new QAction( KIcon( "list-add-amarok" ), i18n("&Add Podcast"), - m_toolBar ); - addPodcastAction->setPriority( QAction::NormalPriority ); - m_toolBar->insertAction( m_separator, addPodcastAction ); - connect( addPodcastAction, SIGNAL(triggered(bool)), The::podcastModel(), SLOT(addPodcast()) ); - - QAction *updateAllAction = new QAction( KIcon("view-refresh-amarok"), QString(), m_toolBar ); - updateAllAction->setToolTip( i18n("&Update All") ); - updateAllAction->setPriority( QAction::LowPriority ); - m_toolBar->insertAction( m_separator, updateAllAction ); - connect( updateAllAction, SIGNAL(triggered(bool)), - The::podcastModel(), SLOT(refreshPodcasts()) ); - - - QAction *importOpmlAction = new QAction( KIcon("document-import") - , i18n( "Import OPML File" ) - , m_toolBar - ); - importOpmlAction->setToolTip( i18n( "Import OPML File" ) ); - importOpmlAction->setPriority( QAction::LowPriority ); - m_toolBar->addAction( importOpmlAction ); - connect( importOpmlAction, SIGNAL(triggered()), SLOT(slotImportOpml()) ); - - PlaylistBrowserView *view = static_cast( playlistView() ); - connect( view, SIGNAL(currentItemChanged(QModelIndex)), SLOT(showInfo(QModelIndex)) ); - - //transparency -// QPalette p = m_podcastTreeView->palette(); -// QColor c = p.color( QPalette::Base ); -// c.setAlpha( 0 ); -// p.setColor( QPalette::Base, c ); -// -// c = p.color( QPalette::AlternateBase ); -// c.setAlpha( 77 ); -// p.setColor( QPalette::AlternateBase, c ); -// -// m_podcastTreeView->setPalette( p ); -// -// QSizePolicy sizePolicy1(QSizePolicy::MinimumExpanding, QSizePolicy::Expanding); -// sizePolicy1.setHorizontalStretch(0); -// sizePolicy1.setVerticalStretch(0); -// sizePolicy1.setHeightForWidth(m_podcastTreeView->sizePolicy().hasHeightForWidth()); -// m_podcastTreeView->setSizePolicy(sizePolicy1); -} - -PodcastCategory::~PodcastCategory() -{ -} - -void -PodcastCategory::showInfo( const QModelIndex &index ) -{ - if( !index.isValid() ) - return; - - const int row = index.row(); - QString description; - QString title( index.data( Qt::DisplayRole ).toString() ); - QString subtitle( index.sibling( row, SubtitleColumn ).data( Qt::DisplayRole ).toString() ); - KUrl imageUrl( qvariant_cast( - index.sibling( row, ImageColumn ).data( Qt::DisplayRole ) - ) ); - QString author( index.sibling( row, AuthorColumn ).data( Qt::DisplayRole ).toString() ); - QStringList keywords( qvariant_cast( - index.sibling( row, KeywordsColumn ).data( Qt::DisplayRole ) - ) ); - bool isEpisode = index.sibling( row, IsEpisodeColumn ).data( Qt::DisplayRole ).toBool(); - QString authorAndPubDate; - - if( !author.isEmpty() ) - { - authorAndPubDate = QString( "%1 %2 " ) - .arg( i18n( "By" ) ) - .arg( Qt::escape( author ) ); - } - - if( !subtitle.isEmpty() ) - { - description += QString( "

%1

" ) - .arg( Qt::escape( subtitle ) ); - } - - if( !imageUrl.isEmpty() ) - { - description += QString( "

" ) - .arg( Qt::escape( imageUrl.url() ) ); - } - - if( isEpisode ) - { - QDateTime pubDate( index.sibling( row, DateColumn ).data( Qt::DisplayRole ).toDateTime() ); - - if( pubDate.isValid() ) - { - authorAndPubDate += QString( "%1 %2" ) - .arg( i18nc( "Podcast published on date", "On" ) ) - .arg( KGlobal::locale()->formatDateTime( pubDate, KLocale::FancyShortDate ) ); - } - } - - if( !authorAndPubDate.isEmpty() ) - { - description += QString( "

%1

" ) - .arg( authorAndPubDate ); - } - - if( isEpisode ) - { - int fileSize = index.sibling( row, FilesizeColumn ).data( Qt::DisplayRole ).toInt(); - - if( fileSize != 0 ) - { - description += QString( "

%1 %2

" ) - .arg( i18n( "File Size:" ) ) - .arg( Meta::prettyFilesize( fileSize ) ); - } - - } - else - { - QDate subsDate( index.sibling( row, DateColumn ).data( Qt::DisplayRole ).toDate() ); - - if( subsDate.isValid() ) - { - description += QString( "

%1 %2

" ) - .arg( i18n( "Subscription Date:" ) ) - .arg( KGlobal::locale()->formatDate( subsDate, KLocale::FancyShortDate ) ); - } - } - - if( !keywords.isEmpty() ) - { - description += QString( "

%1 %2

" ) - .arg( i18n( "Keywords:" ) ) - .arg( Qt::escape( keywords.join( ", " ) ) ); - } - - description += index.data( PrettyTreeRoles::ByLineRole ).toString(); - - description = QString( - "" - " " - " %1" - " " - " " - " " - "

%1

" - " %2" - " " - "") - .arg( Qt::escape( title ) ) - .arg( description ) - .arg( App::instance()->palette().brush( QPalette::Text ).color().name() ) - .arg( PaletteHandler::highlightColor().name() ); - - QVariantMap map; - map["service_name"] = title; - map["main_info"] = description; - The::infoProxy()->setInfo( map ); -} - -void -PodcastCategory::slotImportOpml() -{ - AmarokUrl( "amarok://service-podcastdirectory/addOpml" ).run(); -} - -#include "moc_PodcastCategory.cpp" diff --git a/amarok/src/browsers/playlistbrowser/PodcastCategory.h b/amarok/src/browsers/playlistbrowser/PodcastCategory.h deleted file mode 100644 index 4e160914..00000000 --- a/amarok/src/browsers/playlistbrowser/PodcastCategory.h +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007-2010 Bart Cerneels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef PODCASTCATEGORY_H -#define PODCASTCATEGORY_H - -#include "PlaylistBrowserCategory.h" - -class QModelIndex; - -namespace PlaylistBrowserNS { - -/** - @author Bart Cerneels -*/ -class PodcastCategory : public PlaylistBrowserCategory -{ - Q_OBJECT - public: - static PodcastCategory *instance(); - static void destroy(); - - private: - static PodcastCategory* s_instance; - static QString s_configGroup; - static QString s_mergedViewKey; - - PodcastCategory( QWidget *parent ); - ~PodcastCategory(); - - private slots: - void showInfo( const QModelIndex &index ); - void slotImportOpml(); -}; - -} // namespace PlaylistBrowserNS - -namespace The { - PlaylistBrowserNS::PodcastCategory *podcastCategory(); -} - -#endif diff --git a/amarok/src/browsers/playlistbrowser/PodcastCategoryBase.ui b/amarok/src/browsers/playlistbrowser/PodcastCategoryBase.ui deleted file mode 100644 index ddbdaee6..00000000 --- a/amarok/src/browsers/playlistbrowser/PodcastCategoryBase.ui +++ /dev/null @@ -1,123 +0,0 @@ - - PodcastCategoryBase - - - - 0 - 0 - 339 - 574 - - - - - 0 - 0 - - - - - - - - - Add Podcast... - - - add podcast... - - - ../images/icons/hi16-action-amarok_add_playlist.png - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Refresh All Podcasts - - - ../images/icons/hi16-action-amarok_refresh.png - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Configure Podcasts... - - - Configure Podcasts... - - - ../images/icons/hi16-action-amarok_configure.png - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Scan Interval... - - - ../images/icons/hi16-action-amarok_configure.png - - - - - - - - - - 0 - 0 - - - - - - - - - - diff --git a/amarok/src/browsers/playlistbrowser/PodcastModel.cpp b/amarok/src/browsers/playlistbrowser/PodcastModel.cpp deleted file mode 100644 index a66f1164..00000000 --- a/amarok/src/browsers/playlistbrowser/PodcastModel.cpp +++ /dev/null @@ -1,376 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007-2010 Bart Cerneels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "PodcastModel.h" - -#include "AmarokMimeData.h" -#include "context/popupdropper/libpud/PopupDropper.h" -#include "context/popupdropper/libpud/PopupDropperItem.h" -#include "core/podcasts/PodcastImageFetcher.h" -#include "core/podcasts/PodcastMeta.h" -#include "core/support/Debug.h" -#include "playlistmanager/PlaylistManager.h" -#include "playlistmanager/SyncedPodcast.h" -#include "PodcastCategory.h" -#include "SvgHandler.h" -#include -#include "widgets/PrettyTreeRoles.h" - -#include - -#include -#include -#include -#include - -using namespace Podcasts; - -namespace The -{ - PlaylistBrowserNS::PodcastModel* podcastModel() - { - return PlaylistBrowserNS::PodcastModel::instance(); - } -} - -PlaylistBrowserNS::PodcastModel* PlaylistBrowserNS::PodcastModel::s_instance = 0; - -PlaylistBrowserNS::PodcastModel* -PlaylistBrowserNS::PodcastModel::instance() -{ - return s_instance ? s_instance : new PodcastModel(); -} - -void -PlaylistBrowserNS::PodcastModel::destroy() -{ - if ( s_instance ) - { - delete s_instance; - s_instance = 0; - } -} - -PlaylistBrowserNS::PodcastModel::PodcastModel() - : PlaylistBrowserModel( PlaylistManager::PodcastChannel ) -{ - s_instance = this; -} - -bool -PlaylistBrowserNS::PodcastModel::isOnDisk( PodcastEpisodePtr episode ) const -{ - bool isOnDisk = false; - KUrl episodeFile( episode->localUrl() ); - - if( !episodeFile.isEmpty() ) - { - isOnDisk = QFileInfo( episodeFile.toLocalFile() ).exists(); - // reset localUrl because the file is not there. - // FIXME: changing a podcast in innoncent-looking getter method is convoluted - if( !isOnDisk ) - episode->setLocalUrl( KUrl() ); - } - - return isOnDisk; -} - -QVariant -PlaylistBrowserNS::PodcastModel::icon( const PodcastChannelPtr &channel ) const -{ - QStringList emblems; - //TODO: only check visible episodes. For now those are all returned by episodes(). - foreach( const Podcasts::PodcastEpisodePtr ep, channel->episodes() ) - { - if( ep->isNew() ) - { - emblems << "rating"; - break; - } - } - - if( channel->hasImage() ) - { - QSize size( channel->image().size() ); - QPixmap pixmap( 32, 32 ); - pixmap.fill( Qt::transparent ); - - size.scale( 32, 32, Qt::KeepAspectRatio ); - - int x = 32 / 2 - size.width() / 2; - int y = 32 / 2 - size.height() / 2; - - QPainter p( &pixmap ); - p.drawPixmap( x, y, QPixmap::fromImage( channel->image().scaled( size, - Qt::KeepAspectRatio, Qt::SmoothTransformation ) ) ); - - // if it's a new episode draw the overlay: - if( !emblems.isEmpty() ) - // draw the overlay the same way KIconLoader does: - p.drawPixmap( 2, 32 - 16 - 2, KIcon( "rating" ).pixmap( 16, 16 ) ); - p.end(); - - return pixmap; - } - else - return KIcon( "podcast-amarok", 0, emblems ).pixmap( 32, 32 ); -} - -QVariant -PlaylistBrowserNS::PodcastModel::icon( const PodcastEpisodePtr &episode ) const -{ - QStringList emblems; - if( isOnDisk( episode ) ) - emblems << "go-down"; - - if( episode->isNew() ) - return KIcon( "rating", 0, emblems ).pixmap( 24, 24 ); - else - return KIcon( "podcast-amarok", 0, emblems ).pixmap( 24, 24 ); -} - -QVariant -PlaylistBrowserNS::PodcastModel::data( const QModelIndex &idx, int role ) const -{ - if( !idx.isValid() ) - return PlaylistBrowserModel::data( idx, role ); - - if( IS_TRACK(idx) ) - return episodeData( episodeForIndex( idx ), idx, role ); - else - return channelData( channelForIndex( idx ), idx, role ); -} - -QVariant -PlaylistBrowserNS::PodcastModel::channelData( const PodcastChannelPtr &channel, - const QModelIndex &idx, int role ) const -{ - if( !channel ) - return QVariant(); - - switch( role ) - { - case Qt::DisplayRole: - case Qt::ToolTipRole: - switch( idx.column() ) - { - case PlaylistBrowserModel::PlaylistItemColumn: - return channel->title(); - case SubtitleColumn: - return channel->subtitle(); - case AuthorColumn: - return channel->author(); - case KeywordsColumn: - return channel->keywords(); - case ImageColumn: - { - KUrl imageUrl( PodcastImageFetcher::cachedImagePath( channel ) ); - if( !QFile( imageUrl.toLocalFile() ).exists() ) - imageUrl = channel->imageUrl(); - return imageUrl; - } - case DateColumn: - channel->subscribeDate(); - case IsEpisodeColumn: - return false; - } - break; - case PrettyTreeRoles::ByLineRole: - if( idx.column() == PlaylistBrowserModel::ProviderColumn ) - { - Playlists::PlaylistProvider *provider = providerForIndex( idx ); - if( provider ) - return i18ncp( "number of podcasts from one source", - "One Channel", "%1 channels", - provider->playlists().count() ); - } - if( idx.column() == PlaylistBrowserModel::PlaylistItemColumn ) - return channel->description(); - break; - case PrettyTreeRoles::HasCoverRole: - return idx.column() == PlaylistBrowserModel::PlaylistItemColumn; - case Qt::DecorationRole: - if( idx.column() == PlaylistBrowserModel::PlaylistItemColumn ) - return icon( channel ); - break; - } - - return PlaylistBrowserModel::data( idx, role ); -} - -QVariant -PlaylistBrowserNS::PodcastModel::episodeData( const PodcastEpisodePtr &episode, - const QModelIndex &idx, int role ) const -{ - if( !episode ) - return QVariant(); - - switch( role ) - { - case Qt::DisplayRole: - case Qt::ToolTipRole: - switch( idx.column() ) - { - case PlaylistBrowserModel::PlaylistItemColumn: - return episode->title(); - case SubtitleColumn: - return episode->subtitle(); - case AuthorColumn: - return episode->author(); - case KeywordsColumn: - return episode->keywords(); - case FilesizeColumn: - return episode->filesize(); - case DateColumn: - return episode->pubDate(); - case IsEpisodeColumn: - return true; - } - break; - case PrettyTreeRoles::ByLineRole: - if( idx.column() == PlaylistBrowserModel::ProviderColumn ) - { - Playlists::PlaylistProvider *provider = providerForIndex( idx ); - if( provider ) - return i18ncp( "number of podcasts from one source", - "One Channel", "%1 channels", - provider->playlists().count() ); - } - if( idx.column() == PlaylistBrowserModel::PlaylistItemColumn ) - return episode->description(); - break; - case PrettyTreeRoles::HasCoverRole: - return ( idx.column() == PlaylistBrowserModel::PlaylistItemColumn ); - case Qt::DecorationRole: - if( idx.column() == PlaylistBrowserModel::PlaylistItemColumn ) - return icon( episode ); - break; - case EpisodeIsNewRole: - return episode->isNew(); - } - - return PlaylistBrowserModel::data( idx, role ); -} - -bool -PlaylistBrowserNS::PodcastModel::setData( const QModelIndex &idx, const QVariant &value, int role ) -{ - PodcastEpisodePtr episode = episodeForIndex( idx ); - if( !episode || !value.canConvert() || role != EpisodeIsNewRole ) - { - return PlaylistBrowserModel::setData( idx, value, role ); - } - - bool checked = value.toBool(); - episode->setNew( checked ); - if( checked ) - emit episodeMarkedAsNew( episode ); - emit dataChanged( idx, idx ); - return true; -} - -int -PlaylistBrowserNS::PodcastModel::columnCount( const QModelIndex &parent ) const -{ - Q_UNUSED( parent ) - return ColumnCount; -} - -QVariant -PlaylistBrowserNS::PodcastModel::headerData( int section, Qt::Orientation orientation, - int role) const -{ - if( orientation == Qt::Horizontal && role == Qt::DisplayRole ) - { - switch( section ) - { - case 0: return i18n("Type"); - case 1: return i18n("Title"); - case 2: return i18n("Summary"); - default: return QVariant(); - } - } - - return QVariant(); -} - -void -PlaylistBrowserNS::PodcastModel::addPodcast() -{ - debug() << "adding Podcast"; - - //TODO: request the user to which PodcastProvider he wants to add it in case - // of multiple (enabled) Podcast Providers. - Podcasts::PodcastProvider *podcastProvider = The::playlistManager()->defaultPodcasts(); - if( podcastProvider ) - { - bool ok; - QString url = QInputDialog::getText( 0, - i18n("Add Podcast"), - i18n("Enter RSS 1.0/2.0 or Atom feed URL:"), - QLineEdit::Normal, - QString(), - &ok ); - if( ok && !url.isEmpty() ) - { - // user entered something and pressed OK - podcastProvider->addPodcast( Podcasts::PodcastProvider::toFeedUrl( url.trimmed() ) ); - } - else - { - // user entered nothing or pressed Cancel - debug() << "invalid input or cancel"; - } - } - else - { - debug() << "PodcastChannel provider is null"; - } - -} - -void -PlaylistBrowserNS::PodcastModel::refreshPodcasts() -{ - foreach( Playlists::PlaylistProvider *provider, - The::playlistManager()->providersForCategory( PlaylistManager::PodcastChannel ) ) - { - PodcastProvider *podcastProvider = dynamic_cast( provider ); - if( podcastProvider ) - podcastProvider->updateAll(); - } -} - -Podcasts::PodcastChannelPtr -PlaylistBrowserNS::PodcastModel::channelForIndex( const QModelIndex &idx ) const -{ - return Podcasts::PodcastChannelPtr::dynamicCast( playlistFromIndex( idx ) ); -} - -Podcasts::PodcastEpisodePtr -PlaylistBrowserNS::PodcastModel::episodeForIndex( const QModelIndex &idx ) const -{ - return Podcasts::PodcastEpisodePtr::dynamicCast( trackFromIndex( idx ) ); -} - -Meta::TrackList -PlaylistBrowserNS::PodcastModel::podcastEpisodesToTracks( Podcasts::PodcastEpisodeList episodes ) -{ - Meta::TrackList tracks; - foreach( Podcasts::PodcastEpisodePtr episode, episodes ) - tracks << Meta::TrackPtr::staticCast( episode ); - return tracks; -} diff --git a/amarok/src/browsers/playlistbrowser/PodcastModel.h b/amarok/src/browsers/playlistbrowser/PodcastModel.h deleted file mode 100644 index 4706298d..00000000 --- a/amarok/src/browsers/playlistbrowser/PodcastModel.h +++ /dev/null @@ -1,111 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007-2010 Bart Cerneels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef PLAYLISTBROWSERNSPODCASTMODEL_H -#define PLAYLISTBROWSERNSPODCASTMODEL_H - -#include "core/podcasts/PodcastMeta.h" -#include "core/podcasts/PodcastProvider.h" - -#include "PlaylistBrowserModel.h" -#include "playlist/PlaylistModelStack.h" - -#include -#include - -#include - -namespace PlaylistBrowserNS { - -/* TODO: these should be replaced with custom roles for PlaylistColumn so all data of a playlist can - be fetched at once with itemData() */ -enum -{ - SubtitleColumn = PlaylistBrowserModel::CustomColumOffset, - AuthorColumn, - KeywordsColumn, - FilesizeColumn, // episode only - ImageColumn, // channel only (for now) - DateColumn, - IsEpisodeColumn, - ColumnCount -}; - -/** - * @author Bart Cerneels - */ -class PodcastModel : public PlaylistBrowserModel -{ - Q_OBJECT - - public: - static PodcastModel *instance(); - static void destroy(); - - /* QAbstractItemModel methods */ - virtual QVariant data(const QModelIndex &index, int role) const; - virtual bool setData( const QModelIndex &index, const QVariant &value, - int role = Qt::EditRole ); - virtual QVariant headerData(int section, Qt::Orientation orientation, - int role = Qt::DisplayRole) const; - virtual int columnCount(const QModelIndex &parent = QModelIndex()) const; - - virtual Qt::DropActions supportedDropActions() const { - return Qt::CopyAction | Qt::MoveAction; - } - - virtual Qt::DropActions supportedDragActions() const { - return Qt::MoveAction | Qt::CopyAction; - } - - signals: - void episodeMarkedAsNew( Podcasts::PodcastEpisodePtr ); - - public slots: - void addPodcast(); - void refreshPodcasts(); - - private: - static PodcastModel *s_instance; - PodcastModel(); - - QVariant channelData( const Podcasts::PodcastChannelPtr &channel, - const QModelIndex &idx, int role ) const; - QVariant episodeData( const Podcasts::PodcastEpisodePtr &episode, - const QModelIndex &idx, int role ) const; - - Podcasts::PodcastChannelPtr channelForIndex( const QModelIndex &index ) const; - Podcasts::PodcastEpisodePtr episodeForIndex( const QModelIndex &index ) const; - - Q_DISABLE_COPY( PodcastModel ) - - /** - * A convenience function to convert a PodcastEpisodeList into a TrackList. - */ - static Meta::TrackList podcastEpisodesToTracks( Podcasts::PodcastEpisodeList episodes ); - - bool isOnDisk( Podcasts::PodcastEpisodePtr episode ) const; - QVariant icon( const Podcasts::PodcastChannelPtr &channel ) const; - QVariant icon( const Podcasts::PodcastEpisodePtr &episode ) const; -}; - -} - -namespace The { - AMAROK_EXPORT PlaylistBrowserNS::PodcastModel* podcastModel(); -} - -#endif diff --git a/amarok/src/browsers/playlistbrowser/QtGroupingProxy.cpp b/amarok/src/browsers/playlistbrowser/QtGroupingProxy.cpp deleted file mode 100644 index b04e118a..00000000 --- a/amarok/src/browsers/playlistbrowser/QtGroupingProxy.cpp +++ /dev/null @@ -1,897 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007-2011 Bart Cerneels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "QtGroupingProxy.h" - -#include -#include -#include -#include - -/*! - \class QtGroupingProxy - \brief The QtGroupingProxy class will group source model rows by adding a new top tree-level. - The source model can be flat or tree organized, but only the original top level rows are used - for determining the grouping. - \ingroup model-view -*/ - - -QtGroupingProxy::QtGroupingProxy( QObject *parent ) - : QAbstractProxyModel( parent ) -{ -} - -QtGroupingProxy::QtGroupingProxy( QAbstractItemModel *model, QModelIndex rootIndex, - int groupedColumn, QObject *parent ) - : QAbstractProxyModel( parent ) - , m_rootIndex( rootIndex ) - , m_groupedColumn( 0 ) -{ - setSourceModel( model ); - - if( groupedColumn != -1 ) - setGroupedColumn( groupedColumn ); -} - -QtGroupingProxy::~QtGroupingProxy() -{ -} - -void -QtGroupingProxy::setSourceModel( QAbstractItemModel *sourceModel ) -{ - QAbstractProxyModel::setSourceModel( sourceModel ); - // signal proxies - connect( sourceModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), - SLOT(modelDataChanged(QModelIndex,QModelIndex)) ); - connect( sourceModel, SIGNAL(rowsInserted(QModelIndex,int,int)), - SLOT(modelRowsInserted(QModelIndex,int,int)) ); - connect( sourceModel, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)), - SLOT(modelRowsAboutToBeInserted(QModelIndex,int,int))); - connect( sourceModel, SIGNAL(rowsRemoved(QModelIndex,int,int)), - SLOT(modelRowsRemoved(QModelIndex,int,int)) ); - connect( sourceModel, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)), - SLOT(modelRowsAboutToBeRemoved(QModelIndex,int,int)) ); - connect( sourceModel, SIGNAL(layoutChanged()), SLOT(buildTree()) ); - connect( sourceModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), - SLOT(modelDataChanged(QModelIndex,QModelIndex)) ); - //set invalid index from source as root index - m_rootIndex = sourceModel->index( -1, -1 ); -} - -void -QtGroupingProxy::setRootIndex( const QModelIndex &rootIndex ) -{ - if( m_rootIndex == rootIndex ) - return; - - m_rootIndex = rootIndex; - //TODO: invalidate tree so buildTree() can be called later. -} - -void -QtGroupingProxy::setGroupedColumn( int groupedColumn ) -{ - m_groupedColumn = groupedColumn; - //TODO: invalidate tree so buildTree() can be called later. - buildTree(); -} - -/** Maps to what groups the source row belongs by returning the data of those groups. - * - * @returns a list of data for the rows the argument belongs to. In common cases this list will - * contain only one entry. An empty list means that the source item will be placed in the root of - * this proxyModel. There is no support for hiding source items. - * - * Group data can be pre-loaded in the return value so it's added to the cache maintained by this - * class. This is required if you want to have data that is not present in the source model. - */ -QList -QtGroupingProxy::belongsTo( const QModelIndex &idx ) -{ - //qDebug() << __FILE__ << __FUNCTION__; - QList rowDataList; - - //get all the data for this index from the model - ItemData itemData = sourceModel()->itemData( idx ); - QMapIterator i( itemData ); - while( i.hasNext() ) - { - i.next(); - int role = i.key(); - QVariant variant = i.value(); - // qDebug() << "role " << role << " : (" << variant.typeName() << ") : "<< variant; - if( variant.type() == QVariant::List ) - { - //a list of variants get's expanded to multiple rows - QVariantList list = variant.toList(); - for( int i = 0; i < list.length(); i++ ) - { - //take an existing row data or create a new one - RowData rowData = (rowDataList.count() > i) ? rowDataList.takeAt( i ) - : RowData(); - - //we only gather data for the first column - ItemData indexData = rowData.contains( 0 ) ? rowData.take( 0 ) : ItemData(); - indexData.insert( role, list.value( i ) ); - rowData.insert( 0, indexData ); - //for the grouped column the data should not be gathered from the children - //this will allow filtering on the content of this column with a - //QSortFilterProxyModel - rowData.insert( m_groupedColumn, indexData ); - rowDataList.insert( i, rowData ); - } - } - else if( !variant.isNull() ) - { - //it's just a normal item. Copy all the data and break this loop. - RowData rowData; - rowData.insert( 0, itemData ); - rowDataList << rowData; - break; - } - } - - return rowDataList; -} - -/* m_groupHash layout -* key : index of the group in m_groupMaps -* value : a QList of the original rows in sourceModel() for the children of this group -* -* key = -1 contains a QList of the non-grouped indexes -* -* TODO: sub-groups -*/ -void -QtGroupingProxy::buildTree() -{ - if( !sourceModel() ) - return; - - beginResetModel(); - - m_groupHash.clear(); - //don't clear the data maps since most of it will probably be needed again. - m_parentCreateList.clear(); - - int max = sourceModel()->rowCount( m_rootIndex ); - //qDebug() << QString("building tree with %1 leafs.").arg( max ); - //WARNING: these have to be added in order because the addToGroups function is optimized for - //modelRowsInserted(). Failure to do so will result in wrong data shown in the view at best. - for( int row = 0; row < max; row++ ) - { - QModelIndex idx = sourceModel()->index( row, m_groupedColumn, m_rootIndex ); - addSourceRow( idx ); - } -// dumpGroups(); - - endResetModel(); -} - -QList -QtGroupingProxy::addSourceRow( const QModelIndex &idx ) -{ - QList updatedGroups; - - QList groupData = belongsTo( idx ); - - //an empty list here means it's supposed to go in root. - if( groupData.isEmpty() ) - { - updatedGroups << -1; - if( !m_groupHash.keys().contains( -1 ) ) - m_groupHash.insert( -1, QList() ); //add an empty placeholder - } - - //an item can be in multiple groups - foreach( RowData data, groupData ) - { - int updatedGroup = -1; - if( !data.isEmpty() ) - { -// qDebug() << QString("index %1 belongs to group %2").arg( row ) -// .arg( data[0][Qt::DisplayRole].toString() ); - - foreach( const RowData &cachedData, m_groupMaps ) - { - //when this matches the index belongs to an existing group - if( data[0][Qt::DisplayRole] == cachedData[0][Qt::DisplayRole] ) - { - data = cachedData; - break; - } - } - - updatedGroup = m_groupMaps.indexOf( data ); - //-1 means not found - if( updatedGroup == -1 ) - { - QModelIndex newGroupIdx = addEmptyGroup( data ); - updatedGroup = newGroupIdx.row(); - } - - if( !m_groupHash.keys().contains( updatedGroup ) ) - m_groupHash.insert( updatedGroup, QList() ); //add an empty placeholder - } - - if( !updatedGroups.contains( updatedGroup ) ) - updatedGroups << updatedGroup; - } - - - //update m_groupHash to the new source-model layout (one row added) - QMutableHashIterator > i( m_groupHash ); - while( i.hasNext() ) - { - i.next(); - QList &groupList = i.value(); - int insertedProxyRow = groupList.count(); - for( ; insertedProxyRow > 0 ; insertedProxyRow-- ) - { - int &rowValue = groupList[insertedProxyRow-1]; - if( idx.row() <= rowValue ) - { - //increment the rows that come after the new row since they moved one place up. - rowValue++; - } - else - { - break; - } - } - - if( updatedGroups.contains( i.key() ) ) - { - //the row needs to be added to this group - beginInsertRows( index( i.key() ), insertedProxyRow, insertedProxyRow ); - groupList.insert( insertedProxyRow, idx.row() ); - endInsertRows(); - } - } - - return updatedGroups; -} - -/** Each ModelIndex has in it's internalId a position in the parentCreateList. - * struct ParentCreate are the instructions to recreate the parent index. - * It contains the proxy row number of the parent and the postion in this list of the grandfather. - * This function creates the ParentCreate structs and saves them in a list. - */ -int -QtGroupingProxy::indexOfParentCreate( const QModelIndex &parent ) const -{ - if( !parent.isValid() ) - return -1; - - struct ParentCreate pc; - for( int i = 0 ; i < m_parentCreateList.size() ; i++ ) - { - pc = m_parentCreateList[i]; - if( pc.parentCreateIndex == parent.internalId() && pc.row == parent.row() ) - return i; - } - //there is no parentCreate yet for this index, so let's create one. - pc.parentCreateIndex = parent.internalId(); - pc.row = parent.row(); - m_parentCreateList << pc; - - //dumpParentCreateList(); -// qDebug() << QString( "m_parentCreateList: (%1)" ).arg( m_parentCreateList.size() ); -// for( int i = 0 ; i < m_parentCreateList.size() ; i++ ) -// { -// qDebug() << i << " : " << m_parentCreateList[i].parentCreateIndex << -// " | " << m_parentCreateList[i].row; -// } - - return m_parentCreateList.size() - 1; -} - -QModelIndex -QtGroupingProxy::index( int row, int column, const QModelIndex &parent ) const -{ -// qDebug() << "index requested for: (" << row << "," << column << "), " << parent; - if( !hasIndex(row, column, parent) ) - return QModelIndex(); - - if( parent.column() > 0 ) - return QModelIndex(); - - /* We save the instructions to make the parent of the index in a struct. - * The place of the struct in the list is stored in the internalId - */ - int parentCreateIndex = indexOfParentCreate( parent ); - - return createIndex( row, column, parentCreateIndex ); -} - -QModelIndex -QtGroupingProxy::parent( const QModelIndex &index ) const -{ - //qDebug() << "parent: " << index; - if( !index.isValid() ) - return QModelIndex(); - - int parentCreateIndex = index.internalId(); - //qDebug() << "parentCreateIndex: " << parentCreateIndex; - if( parentCreateIndex == -1 || parentCreateIndex >= m_parentCreateList.count() ) - return QModelIndex(); - - struct ParentCreate pc = m_parentCreateList[parentCreateIndex]; - //qDebug() << "parentCreate: (" << pc.parentCreateIndex << "," << pc.row << ")"; - //only items at column 0 have children - return createIndex( pc.row, 0, pc.parentCreateIndex ); -} - -int -QtGroupingProxy::rowCount( const QModelIndex &index ) const -{ - //qDebug() << "rowCount: " << index; - if( !index.isValid() ) - { - //the number of top level groups + the number of non-grouped playlists - int rows = m_groupMaps.count() + m_groupHash.value( -1 ).count(); - //qDebug() << rows << " in root group"; - return rows; - } - - //TODO:group in group support. - if( isGroup( index ) ) - { - qint64 groupIndex = index.row(); - int rows = m_groupHash.value( groupIndex ).count(); - //qDebug() << rows << " in group " << m_groupMaps[groupIndex]; - return rows; - } - - QModelIndex originalIndex = mapToSource( index ); - int rowCount = sourceModel()->rowCount( originalIndex ); - //qDebug() << "original item: rowCount == " << rowCount; - return rowCount; -} - -int -QtGroupingProxy::columnCount( const QModelIndex &index ) const -{ - if( !index.isValid() ) - return sourceModel()->columnCount( m_rootIndex ); - - if( index.column() != 0 ) - return 0; - - return sourceModel()->columnCount( mapToSource( index ) ); -} - -QVariant -QtGroupingProxy::data( const QModelIndex &index, int role ) const -{ - if( !index.isValid() ) - return sourceModel()->data( m_rootIndex, role ); //rootNode could have useful data - - //qDebug() << __FUNCTION__ << index << " role: " << role; - int row = index.row(); - int column = index.column(); - if( isGroup( index ) ) - { - //qDebug() << __FUNCTION__ << "is a group"; - //use cached or precalculated data - if( m_groupMaps[row][column].contains( role ) ) - { - //qDebug() << "Using cached data"; - return m_groupMaps[row][column].value( role ); - } - - //for column 0 we gather data from the grouped column instead - if( column == 0 ) - column = m_groupedColumn; - - //map all data from children to columns of group to allow grouping one level up - QVariantList variantsOfChildren; - int childCount = m_groupHash.value( row ).count(); - if( childCount == 0 ) - return QVariant(); - - //qDebug() << __FUNCTION__ << "childCount: " << childCount; - //Need a parentIndex with column == 0 because only those have children. - QModelIndex parentIndex = this->index( row, 0, index.parent() ); - for( int childRow = 0; childRow < childCount; childRow++ ) - { - QModelIndex childIndex = this->index( childRow, column, parentIndex ); - QVariant data = mapToSource( childIndex ).data( role ); - //qDebug() << __FUNCTION__ << data << QVariant::typeToName(data.type()); - if( data.isValid() && !variantsOfChildren.contains( data ) ) - variantsOfChildren << data; - } - //qDebug() << "gathered this data from children: " << variantsOfChildren; - //saving in cache - ItemData roleMap = m_groupMaps[row].value( column ); - foreach( const QVariant &variant, variantsOfChildren ) - { - if( roleMap[ role ] != variant ) - roleMap.insert( role, variantsOfChildren ); - } - - //qDebug() << QString("roleMap[%1]:").arg(role) << roleMap[role]; - //only one unique variant? No need to return a list - if( variantsOfChildren.count() == 1 ) - return variantsOfChildren.first(); - - if( variantsOfChildren.count() == 0 ) - return QVariant(); - - return variantsOfChildren; - } - - return mapToSource( index ).data( role ); -} - -bool -QtGroupingProxy::setData( const QModelIndex &idx, const QVariant &value, int role ) -{ - if( !idx.isValid() ) - return false; - - //no need to set data to exactly the same value - if( idx.data( role ) == value ) - return false; - - if( isGroup( idx ) ) - { - ItemData columnData = m_groupMaps[idx.row()][idx.column()]; - - columnData.insert( role, value ); - //QItemDelegate will always use Qt::EditRole - if( role == Qt::EditRole ) - columnData.insert( Qt::DisplayRole, value ); - - //and make sure it's stored in the map - m_groupMaps[idx.row()].insert( idx.column(), columnData ); - - int columnToChange = idx.column() ? idx.column() : m_groupedColumn; - foreach( int originalRow, m_groupHash.value( idx.row() ) ) - { - QModelIndex childIdx = sourceModel()->index( originalRow, columnToChange, - m_rootIndex ); - if( childIdx.isValid() ) - sourceModel()->setData( childIdx, value, role ); - } - //TODO: we might need to reload the data from the children at this point - - emit dataChanged( idx, idx ); - return true; - } - - return sourceModel()->setData( mapToSource( idx ), value, role ); -} - -bool -QtGroupingProxy::isGroup( const QModelIndex &index ) const -{ - int parentCreateIndex = index.internalId(); - if( parentCreateIndex == -1 && index.row() < m_groupMaps.count() ) - return true; - return false; -} - -QModelIndex -QtGroupingProxy::mapToSource( const QModelIndex &index ) const -{ - //qDebug() << "mapToSource: " << index; - if( !index.isValid() ) - return m_rootIndex; - - if( isGroup( index ) ) - { - //qDebug() << "is a group: " << index.data( Qt::DisplayRole ).toString(); - return m_rootIndex; - } - - QModelIndex proxyParent = index.parent(); - //qDebug() << "parent: " << proxyParent; - QModelIndex originalParent = mapToSource( proxyParent ); - //qDebug() << "originalParent: " << originalParent; - int originalRow = index.row(); - if( originalParent == m_rootIndex ) - { - int indexInGroup = index.row(); - if( !proxyParent.isValid() ) - indexInGroup -= m_groupMaps.count(); - //qDebug() << "indexInGroup" << indexInGroup; - QList childRows = m_groupHash.value( proxyParent.row() ); - if( childRows.isEmpty() || indexInGroup >= childRows.count() || indexInGroup < 0 ) - return QModelIndex(); - - originalRow = childRows.at( indexInGroup ); - //qDebug() << "originalRow: " << originalRow; - } - return sourceModel()->index( originalRow, index.column(), originalParent ); -} - -QModelIndexList -QtGroupingProxy::mapToSource( const QModelIndexList& list ) const -{ - QModelIndexList originalList; - foreach( const QModelIndex &index, list ) - { - QModelIndex originalIndex = mapToSource( index ); - if( originalIndex.isValid() ) - originalList << originalIndex; - } - return originalList; -} - -QModelIndex -QtGroupingProxy::mapFromSource( const QModelIndex &idx ) const -{ - if( !idx.isValid() ) - return QModelIndex(); - - QModelIndex proxyParent; - QModelIndex sourceParent = idx.parent(); - //qDebug() << "sourceParent: " << sourceParent; - int proxyRow = idx.row(); - int sourceRow = idx.row(); - - if( sourceParent.isValid() && ( sourceParent != m_rootIndex ) ) - { - //idx is a child of one of the items in the source model - proxyParent = mapFromSource( sourceParent ); - } - else - { - //idx is an item in the top level of the source model (child of the rootnode) - int groupRow = -1; - QHashIterator > iterator( m_groupHash ); - while( iterator.hasNext() ) - { - iterator.next(); - if( iterator.value().contains( sourceRow ) ) - { - groupRow = iterator.key(); - break; - } - } - - if( groupRow != -1 ) //it's in a group, let's find the correct row. - { - proxyParent = this->index( groupRow, 0, QModelIndex() ); - proxyRow = m_groupHash.value( groupRow ).indexOf( sourceRow ); - } - else - { - proxyParent = QModelIndex(); - // if the proxy item is not in a group it will be below the groups. - int groupLength = m_groupMaps.count(); - //qDebug() << "groupNames length: " << groupLength; - int i = m_groupHash.value( -1 ).indexOf( sourceRow ); - //qDebug() << "index in hash: " << i; - proxyRow = groupLength + i; - } - } - - //qDebug() << "proxyParent: " << proxyParent; - //qDebug() << "proxyRow: " << proxyRow; - return this->index( proxyRow, 0, proxyParent ); -} - -Qt::ItemFlags -QtGroupingProxy::flags( const QModelIndex &idx ) const -{ - if( !idx.isValid() ) - { - Qt::ItemFlags rootFlags = sourceModel()->flags( m_rootIndex ); - if( rootFlags.testFlag( Qt::ItemIsDropEnabled ) ) - return Qt::ItemFlags( Qt::ItemIsDropEnabled ); - - return 0; - } - //only if the grouped column has the editable flag set allow the - //actions leading to setData on the source (edit & drop) -// qDebug() << idx; - if( isGroup( idx ) ) - { -// dumpGroups(); - Qt::ItemFlags defaultFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable ); - bool groupIsEditable = true; - - //it's possible to have empty groups - if( m_groupHash.value( idx.row() ).count() == 0 ) - { - //check the flags of this column with the root node - QModelIndex originalRootNode = sourceModel()->index( m_rootIndex.row(), m_groupedColumn, - m_rootIndex.parent() ); - groupIsEditable = originalRootNode.flags().testFlag( Qt::ItemIsEditable ); - } - else - { - foreach( int originalRow, m_groupHash.value( idx.row() ) ) - { - QModelIndex originalIdx = sourceModel()->index( originalRow, m_groupedColumn, - m_rootIndex ); -// qDebug() << "originalIdx: " << originalIdx; - groupIsEditable = groupIsEditable - ? originalIdx.flags().testFlag( Qt::ItemIsEditable ) - : false; - if( !groupIsEditable ) //all children need to have an editable grouped column - break; - } - } - - if( groupIsEditable ) - return ( defaultFlags | Qt::ItemIsEditable | Qt::ItemIsDropEnabled ); - return defaultFlags; - } - - QModelIndex originalIdx = mapToSource( idx ); - Qt::ItemFlags originalItemFlags = sourceModel()->flags( originalIdx ); - - //check the source model to see if the grouped column is editable; - QModelIndex groupedColumnIndex = - sourceModel()->index( originalIdx.row(), m_groupedColumn, originalIdx.parent() ); - bool groupIsEditable = sourceModel()->flags( groupedColumnIndex ).testFlag( Qt::ItemIsEditable ); - if( groupIsEditable ) - return originalItemFlags | Qt::ItemIsDragEnabled; - - return originalItemFlags; -} - -QModelIndex -QtGroupingProxy::buddy( const QModelIndex &index ) const -{ - /* We need to override this method in case of groups. Otherwise, at least editing - * of groups is prevented, following sequence occurs: - * - * #0 QtGroupingProxy::mapToSource (this=0x15ad8a0, index=...) at /home/strohel/projekty/amarok/src/browsers/playlistbrowser/QtGroupingProxy.cpp:492 - * #1 0x00007ffff609d7b6 in QAbstractProxyModel::buddy (this=0x15ad8a0, index=...) at itemviews/qabstractproxymodel.cpp:306 - * #2 0x00007ffff609ed25 in QSortFilterProxyModel::buddy (this=0x15ae730, index=...) at itemviews/qsortfilterproxymodel.cpp:2015 - * #3 0x00007ffff6012a2c in QAbstractItemView::edit (this=0x15aec30, index=..., trigger=QAbstractItemView::AllEditTriggers, event=0x0) at itemviews/qabstractitemview.cpp:2569 - * #4 0x00007ffff6f9aa9f in Amarok::PrettyTreeView::edit (this=0x15aec30, index=..., trigger=QAbstractItemView::AllEditTriggers, event=0x0) - * at /home/strohel/projekty/amarok/src/widgets/PrettyTreeView.cpp:58 - * #5 0x00007ffff6007f1e in QAbstractItemView::edit (this=0x15aec30, index=...) at itemviews/qabstractitemview.cpp:1138 - * #6 0x00007ffff6dc86e4 in PlaylistBrowserNS::PlaylistBrowserCategory::createNewFolder (this=0x159bf90) - * at /home/strohel/projekty/amarok/src/browsers/playlistbrowser/PlaylistBrowserCategory.cpp:298 - * - * but we return invalid index in mapToSource() for group index. - */ - if( index.isValid() && isGroup( index ) ) - return index; - return QAbstractProxyModel::buddy( index ); -} - -QVariant -QtGroupingProxy::headerData( int section, Qt::Orientation orientation, int role ) const -{ - return sourceModel()->headerData( section, orientation, role ); -} - -bool -QtGroupingProxy::canFetchMore( const QModelIndex &parent ) const -{ - if( !parent.isValid() ) - return false; - - if( isGroup( parent ) ) - return false; - - return sourceModel()->canFetchMore( mapToSource( parent ) ); -} - -void -QtGroupingProxy::fetchMore ( const QModelIndex & parent ) -{ - if( !parent.isValid() ) - return; - - if( isGroup( parent ) ) - return; - - return sourceModel()->fetchMore( mapToSource( parent ) ); -} - -QModelIndex -QtGroupingProxy::addEmptyGroup( const RowData &data ) -{ - int newRow = m_groupMaps.count(); - beginInsertRows( QModelIndex(), newRow, newRow ); - m_groupMaps << data; - endInsertRows(); - return index( newRow, 0, QModelIndex() ); -} - -bool -QtGroupingProxy::removeGroup( const QModelIndex &idx ) -{ - beginRemoveRows( idx.parent(), idx.row(), idx.row() ); - m_groupHash.remove( idx.row() ); - m_groupMaps.removeAt( idx.row() ); - m_parentCreateList.removeAt( idx.internalId() ); - endRemoveRows(); - - //TODO: only true if all data could be unset. - return true; -} - -bool -QtGroupingProxy::hasChildren( const QModelIndex &parent ) const -{ - if( !parent.isValid() ) - return true; - - if( isGroup( parent ) ) - return !m_groupHash.value( parent.row() ).isEmpty(); - - return sourceModel()->hasChildren( mapToSource( parent ) ); -} - -void -QtGroupingProxy::modelRowsAboutToBeInserted( const QModelIndex &parent, int start, int end ) -{ - if( parent != m_rootIndex ) - { - //an item will be added to an original index, remap and pass it on - QModelIndex proxyParent = mapFromSource( parent ); - beginInsertRows( proxyParent, start, end ); - } -} - -void -QtGroupingProxy::modelRowsInserted( const QModelIndex &parent, int start, int end ) -{ - if( parent == m_rootIndex ) - { - //top level of the model changed, these new rows need to be put in groups - for( int modelRow = start; modelRow <= end ; modelRow++ ) - { - addSourceRow( sourceModel()->index( modelRow, m_groupedColumn, m_rootIndex ) ); - } - } - else - { - //beginInsertRows had to be called in modelRowsAboutToBeInserted() - endInsertRows(); - } -} - -void -QtGroupingProxy::modelRowsAboutToBeRemoved( const QModelIndex &parent, int start, int end ) -{ - if( parent == m_rootIndex ) - { - QHash >::const_iterator i; - //HACK, we are going to call beginRemoveRows() multiple times without - // endRemoveRows() if a source index is in multiple groups. - // This can be a problem for some views/proxies, but Q*Views can handle it. - // TODO: investigate a queue for applying proxy model changes in the correct order - for( i = m_groupHash.constBegin(); i != m_groupHash.constEnd(); ++i ) - { - int groupIndex = i.key(); - const QList &groupList = i.value(); - QModelIndex proxyParent = index( groupIndex, 0 ); - foreach( int originalRow, groupList ) - { - if( originalRow >= start && originalRow <= end ) - { - int proxyRow = groupList.indexOf( originalRow ); - if( groupIndex == -1 ) //adjust for non-grouped (root level) original items - proxyRow += m_groupMaps.count(); - //TODO: optimize for continues original rows in the same group - beginRemoveRows( proxyParent, proxyRow, proxyRow ); - } - } - } - } - else - { - //child item(s) of an original item will be removed, remap and pass it on -// qDebug() << parent; - QModelIndex proxyParent = mapFromSource( parent ); -// qDebug() << proxyParent; - beginRemoveRows( proxyParent, start, end ); - } -} - -void -QtGroupingProxy::modelRowsRemoved( const QModelIndex &parent, int start, int end ) -{ - if( parent == m_rootIndex ) - { - //TODO: can be optimised by iterating over m_groupHash and checking start <= r < end - - //rather than increasing i we change the stored sourceRows in-place and reuse argument start - //X-times (where X = end - start). - for( int i = start; i <= end; i++ ) - { - //HACK: we are going to iterate the hash in reverse so calls to endRemoveRows() - // are matched up with the beginRemoveRows() in modelRowsAboutToBeRemoved() - //NOTE: easier to do reverse with java style iterator - QMutableHashIterator > it( m_groupHash ); - it.toBack(); - while( it.hasPrevious() ) - { - it.previous(); - int groupIndex = it.key(); - //has to be a modifiable reference for remove and replace operations - QList &groupList = it.value(); - int rowIndex = groupList.indexOf( start ); - if( rowIndex != -1 ) - { - QModelIndex proxyParent = index( groupIndex, 0 ); - groupList.removeAt( rowIndex ); - } - //Now decrement all source rows that are after the removed row - for( int j = 0; j < groupList.count(); j++ ) - { - int sourceRow = groupList.at( j ); - if( sourceRow > start ) - groupList.replace( j, sourceRow-1 ); - } - if( rowIndex != -1) - endRemoveRows(); //end remove operation only after group was updated. - } - } - - return; - } - - //beginRemoveRows had to be called in modelRowsAboutToBeRemoved(); - endRemoveRows(); -} - -void -QtGroupingProxy::modelDataChanged( const QModelIndex &topLeft, const QModelIndex &bottomRight ) -{ - //TODO: need to look in the groupedColumn and see if it changed and changed grouping accordingly - QModelIndex proxyTopLeft = mapFromSource( topLeft ); - if( !proxyTopLeft.isValid() ) - return; - - if( topLeft == bottomRight ) - { - emit dataChanged( proxyTopLeft, proxyTopLeft ); - } - else - { - QModelIndex proxyBottomRight = mapFromSource( bottomRight ); - emit dataChanged( proxyTopLeft, proxyBottomRight ); - } -} - -bool -QtGroupingProxy::isAGroupSelected( const QModelIndexList& list ) const -{ - foreach( const QModelIndex &index, list ) - { - if( isGroup( index ) ) - return true; - } - return false; -} - -void -QtGroupingProxy::dumpGroups() const -{ - qDebug() << "m_groupHash: "; - for( int groupIndex = -1; groupIndex < m_groupHash.keys().count() - 1; groupIndex++ ) - { - qDebug() << groupIndex << " : " << m_groupHash.value( groupIndex ); - } - - qDebug() << "m_groupMaps: "; - for( int groupIndex = 0; groupIndex < m_groupMaps.count(); groupIndex++ ) - qDebug() << m_groupMaps[groupIndex] << ": " << m_groupHash.value( groupIndex ); - qDebug() << m_groupHash.value( -1 ); -} diff --git a/amarok/src/browsers/playlistbrowser/QtGroupingProxy.h b/amarok/src/browsers/playlistbrowser/QtGroupingProxy.h deleted file mode 100644 index ff0808ce..00000000 --- a/amarok/src/browsers/playlistbrowser/QtGroupingProxy.h +++ /dev/null @@ -1,129 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007-2010 Bart Cerneels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef GROUPINGPROXY_H -#define GROUPINGPROXY_H - -#include -#include -#include -#include -#include - -typedef QMap ItemData; -typedef QMap RowData; - - -class QtGroupingProxy : public QAbstractProxyModel -{ - Q_OBJECT - public: - explicit QtGroupingProxy( QObject *parent = 0 ); - QtGroupingProxy( QAbstractItemModel *model, QModelIndex rootIndex = QModelIndex(), - int groupedColumn = -1, QObject *parent = 0 ); - ~QtGroupingProxy(); - - /* QtGroupingProxy methods */ - void setRootIndex( const QModelIndex &rootIndex ); - void setGroupedColumn( int groupedColumn ); - virtual QModelIndex addEmptyGroup( const RowData &data ); - virtual bool removeGroup( const QModelIndex &idx ); - - /* QAbstractProxyModel methods */ - //re-implemented to connect to source signals - virtual void setSourceModel( QAbstractItemModel *sourceModel ); - virtual QModelIndex index( int row, int column = 0, - const QModelIndex& parent = QModelIndex() ) const; - virtual Qt::ItemFlags flags( const QModelIndex &idx ) const; - virtual QModelIndex buddy( const QModelIndex &index ) const; - virtual QModelIndex parent( const QModelIndex &idx ) const; - virtual int rowCount( const QModelIndex &idx = QModelIndex() ) const; - virtual int columnCount( const QModelIndex &idx ) const; - virtual QModelIndex mapToSource( const QModelIndex &idx ) const; - virtual QModelIndexList mapToSource( const QModelIndexList &list ) const; - virtual QModelIndex mapFromSource( const QModelIndex &idx ) const; - virtual QVariant data( const QModelIndex &idx, int role ) const; - virtual bool setData( const QModelIndex &index, const QVariant &value, - int role = Qt::EditRole ); - virtual QVariant headerData ( int section, Qt::Orientation orientation, - int role ) const; - virtual bool canFetchMore( const QModelIndex &parent ) const; - virtual void fetchMore( const QModelIndex &parent ); - virtual bool hasChildren( const QModelIndex &parent = QModelIndex() ) const; - - protected slots: - virtual void buildTree(); - - private slots: - void modelDataChanged( const QModelIndex &, const QModelIndex & ); - void modelRowsInserted( const QModelIndex &, int, int ); - void modelRowsAboutToBeInserted( const QModelIndex &, int ,int ); - void modelRowsRemoved( const QModelIndex &, int, int ); - void modelRowsAboutToBeRemoved( const QModelIndex &, int ,int ); - - protected: - /** Maps an item to a group. - * The return value is a list because an item can put in multiple groups. - * Inside the list is a 2 dimensional map. - * Mapped to column-number is another map of role-number to QVariant. - * This data prepolulates the group-data cache. The rest is gathered on demand - * from the children of the group. - */ - virtual QList belongsTo( const QModelIndex &idx ); - - /** - * calls belongsTo(), checks cached data and adds the index to existing or new groups. - * @returns the groups this index was added to where -1 means it was added to the root. - */ - QList addSourceRow( const QModelIndex &idx ); - - bool isGroup( const QModelIndex &index ) const; - bool isAGroupSelected( const QModelIndexList &list ) const; - - /** Maintains the group -> sourcemodel row mapping - * The reason a QList is use instead of a QMultiHash is that the values have to be - * reordered when rows are inserted or removed. - * TODO:use some auto-incrementing container class (steveire's?) for the list - */ - QHash > m_groupHash; - /** The data cache of the groups. - * This can be pre-loaded with data in belongsTo() - */ - QList m_groupMaps; - - /** "instuctions" how to create an item in the tree. - * This is used by parent( QModelIndex ) - */ - struct ParentCreate - { - int parentCreateIndex; - int row; - }; - mutable QList m_parentCreateList; - /** @returns index of the "instructions" to recreate the parent. Will create new if it doesn't exist yet. - */ - int indexOfParentCreate( const QModelIndex &parent ) const; - - QModelIndexList m_selectedGroups; - - QModelIndex m_rootIndex; - int m_groupedColumn; - - /* debug function */ - void dumpGroups() const; -}; - -#endif //GROUPINGPROXY_H diff --git a/amarok/src/browsers/playlistbrowser/UserPlaylistCategory.cpp b/amarok/src/browsers/playlistbrowser/UserPlaylistCategory.cpp deleted file mode 100644 index 78debd0c..00000000 --- a/amarok/src/browsers/playlistbrowser/UserPlaylistCategory.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Nikolaj Hald Nielsen * - * Copyright (c) 2009 Bart Cerneels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "UserPlaylistCategory.h" - -#include "core-impl/collections/support/CollectionManager.h" -#include "core/support/Debug.h" -#include "PaletteHandler.h" -#include "playlist/PlaylistModel.h" -#include "playlistmanager/PlaylistManager.h" -#include "PlaylistsInFoldersProxy.h" -#include "PlaylistsByProviderProxy.h" -#include "SvgHandler.h" - -#include "UserPlaylistModel.h" - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -using namespace PlaylistBrowserNS; - -QString UserPlaylistCategory::s_configGroup( "Saved Playlists View" ); - -UserPlaylistCategory::UserPlaylistCategory( QWidget * parent ) - : PlaylistBrowserCategory( Playlists::UserPlaylist, - "user playlists", s_configGroup, - The::userPlaylistModel(), parent ) -{ - setPrettyName( i18n( "Saved Playlists" ) ); - setShortDescription( i18n( "User generated and imported playlists" ) ); - setIcon( KIcon( "amarok_playlist" ) ); - - setLongDescription( i18n( "Create, edit, organize and load playlists. " - "Amarok automatically adds any playlists found when scanning your collection, " - "and any playlists that you save are also shown here." ) ); - - setImagePath( KStandardDirs::locate( "data", "amarok/images/hover_info_user_playlists.png" ) ); -} - -UserPlaylistCategory::~UserPlaylistCategory() -{ -} diff --git a/amarok/src/browsers/playlistbrowser/UserPlaylistCategory.h b/amarok/src/browsers/playlistbrowser/UserPlaylistCategory.h deleted file mode 100644 index 6bbefb34..00000000 --- a/amarok/src/browsers/playlistbrowser/UserPlaylistCategory.h +++ /dev/null @@ -1,48 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef USERPLAYLISTCATEGORY_H -#define USERPLAYLISTCATEGORY_H - -#include "PlaylistBrowserCategory.h" - -#include - -#include -#include -#include - -namespace PlaylistBrowserNS { - -/** -The widget that displays playlists in the playlist browser - - @author Nikolaj Hald Nielsen -*/ -class UserPlaylistCategory : public PlaylistBrowserCategory -{ -Q_OBJECT -public: - static QString s_configGroup; - - UserPlaylistCategory( QWidget *parent ); - - ~UserPlaylistCategory(); -}; - -} - -#endif //USERPLAYLISTCATEGORY_H diff --git a/amarok/src/browsers/playlistbrowser/UserPlaylistModel.cpp b/amarok/src/browsers/playlistbrowser/UserPlaylistModel.cpp deleted file mode 100644 index 3bf34a55..00000000 --- a/amarok/src/browsers/playlistbrowser/UserPlaylistModel.cpp +++ /dev/null @@ -1,185 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Nikolaj Hald Nielsen * - * Copyright (c) 2008 Ian Monroe * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "UserPlaylistModel.h" -#include "playlistmanager/PlaylistManager.h" -#include "core/playlists/PlaylistProvider.h" - -#include "AmarokMimeData.h" -#include "core-impl/collections/support/CollectionManager.h" -#include "core/support/Debug.h" -#include "SvgHandler.h" - -#include - -#include - -#include - -//Playlist & Track index differentiator macros -//QModelIndex::intenalId() is a qint64 to support 64-bit pointers in a union with the ID -#define TRACK_MASK (0x1<<31) -#define IS_TRACK(x) ((x.internalId()) & (TRACK_MASK))?true:false -#define SET_TRACK_MASK(x) ((x) | (TRACK_MASK)) -#define REMOVE_TRACK_MASK(x) ((x) & ~(TRACK_MASK)) - -namespace The -{ - PlaylistBrowserNS::UserModel* userPlaylistModel() - { - return PlaylistBrowserNS::UserModel::instance(); - } -} - -PlaylistBrowserNS::UserModel *PlaylistBrowserNS::UserModel::s_instance = 0; - -PlaylistBrowserNS::UserModel *PlaylistBrowserNS::UserModel::instance() -{ - if( s_instance == 0 ) - s_instance = new UserModel(); - - return s_instance; -} - -void -PlaylistBrowserNS::UserModel::destroy() -{ - if( s_instance ) - { - delete s_instance; - s_instance = 0; - } -} - -PlaylistBrowserNS::UserModel::UserModel() - : PlaylistBrowserModel( PlaylistManager::UserPlaylist ) -{ - s_instance = this; -} - -PlaylistBrowserNS::UserModel::~UserModel() -{ -} - -bool -PlaylistBrowserNS::UserModel::setData( const QModelIndex &idx, const QVariant &value, int role ) -{ - Q_UNUSED( role ) - - switch( idx.column() ) - { - case PlaylistBrowserModel::PlaylistItemColumn: - { - QString newName = value.toString().trimmed(); - if( newName.isEmpty() ) - return false; - Playlists::PlaylistPtr playlist = m_playlists.value( idx.internalId() ); - // we emit dataChanged signals later - return The::playlistManager()->rename( playlist, newName ); - } - case PlaylistBrowserModel::LabelColumn: - { - debug() << "changing group of item " << idx.internalId() << " to " << value.toString(); - Playlists::PlaylistPtr item = m_playlists.value( idx.internalId() ); - item->setGroups( value.toStringList() ); - // we emit dataChanged signals later - return true; - } - default: - return false; - } - - return true; -} - -bool -PlaylistBrowserNS::UserModel::removeRows( int row, int count, const QModelIndex &parent ) -{ - if( row < 0 || row > rowCount( parent ) ) - return false; - - if( !parent.isValid() ) - { - Playlists::PlaylistList playlistToRemove; - for( int i = row; i < row + count; i++ ) - { - if( m_playlists.count() > i ) - { - Playlists::PlaylistPtr playlist = m_playlists[i]; - debug() << "Removing " << playlist->name(); - playlistToRemove << playlist; - } - } - if( playlistToRemove.isEmpty() ) - return false; - - return The::playlistManager()->deletePlaylists( playlistToRemove ); - } - int playlistRow = REMOVE_TRACK_MASK(parent.internalId()); - - //don't try to get a playlist beyond the last item in the list - if( playlistRow >= m_playlists.count() ) - { - error() << "Tried to remove from non existing playlist:"; - error() << playlistRow << " while there are only " << m_playlists.count(); - return false; - } - - Playlists::PlaylistPtr playlist = m_playlists.value( playlistRow ); - - //if we are trying to delete more tracks then what the playlist has, return. - //count will be at least 1 to delete one track - if( row + count - 1 >= playlist->tracks().count() ) - { - error() << "Tried to remove a track using an index that is not there:"; - error() << "row: " << row << " count: " << count << " number of tracks: " - << playlist->tracks().count(); - return false; - } - - beginRemoveRows( parent, row, row + count - 1 ); - //ignore notifications while removing tracks - unsubscribeFrom( playlist ); - for( int i = row; i < row + count; i++ ) - //deleting a track moves the next track up, so use the same row number each time - playlist->removeTrack( row ); - subscribeTo( playlist ); - endRemoveRows(); - - return true; -} - -bool -PlaylistBrowserNS::UserModel::dropMimeData ( const QMimeData *data, Qt::DropAction action, int row, - int column, const QModelIndex &parent ) //reimplemented -{ - Q_UNUSED( column ) - - //let the base class handle the regular actions. - if( PlaylistBrowserModel::dropMimeData( data, action, row, column, parent ) ) - return true; - - if( data->hasUrls() ) - { - foreach( const QUrl &url, data->urls() ) - The::playlistManager()->import( url.toString() ); - } - - return false; -} - -#include "moc_UserPlaylistModel.cpp" diff --git a/amarok/src/browsers/playlistbrowser/UserPlaylistModel.h b/amarok/src/browsers/playlistbrowser/UserPlaylistModel.h deleted file mode 100644 index e775181e..00000000 --- a/amarok/src/browsers/playlistbrowser/UserPlaylistModel.h +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef USERPLAYLISTMODEL_H -#define USERPLAYLISTMODEL_H - -#include "amarok_export.h" -#include "browsers/playlistbrowser/PlaylistBrowserModel.h" -#include "core/meta/forward_declarations.h" -#include "core/playlists/Playlist.h" - -#include -#include -#include -#include - -#define PLAYLIST_DB_VERSION 1 - -namespace PlaylistBrowserNS { - -/** - @author Nikolaj Hald Nielsen -*/ -class UserModel : public PlaylistBrowserModel -{ - Q_OBJECT - public: - static UserModel * instance(); - static void destroy(); - - ~UserModel(); - - virtual bool setData( const QModelIndex &index, const QVariant &value, int role = Qt::EditRole ); - virtual bool removeRows( int row, int count, const QModelIndex & parent = QModelIndex() ); - - virtual Qt::DropActions supportedDropActions() const { - return Qt::CopyAction | Qt::MoveAction; - } - - virtual Qt::DropActions supportedDragActions() const { - return Qt::MoveAction | Qt::CopyAction; - } - - bool dropMimeData ( const QMimeData * data, Qt::DropAction action, int row, int column, const QModelIndex & parent ); - - private: - UserModel(); - static UserModel * s_instance; -}; - -} - -namespace The { - AMAROK_EXPORT PlaylistBrowserNS::UserModel* userPlaylistModel(); -} -#endif diff --git a/amarok/src/browsers/servicebrowser/ServiceBrowser.cpp b/amarok/src/browsers/servicebrowser/ServiceBrowser.cpp deleted file mode 100644 index 67cd5d71..00000000 --- a/amarok/src/browsers/servicebrowser/ServiceBrowser.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "ServiceBrowser.h" - -#include "core/support/Debug.h" - -#include - -ServiceBrowser * ServiceBrowser::s_instance = 0; - -ServiceBrowser * ServiceBrowser::instance() -{ - if ( s_instance == 0 ) - s_instance = new ServiceBrowser( "internet" ); - - return s_instance; -} - - -ServiceBrowser::ServiceBrowser( const QString& name, QWidget* parent ) - : BrowserCategoryList( name, parent, true ) -{ - debug() << "ServiceBrowser starting..."; - - setLongDescription( i18n( "The Internet browser lets you browse online sources of content that integrates directly into Amarok. Amarok ships with a number of these sources, but many more can be added using scripts." ) ); - - setImagePath( KStandardDirs::locate( "data", "amarok/images/hover_info_internet.png" ) ); -} - - -ServiceBrowser::~ServiceBrowser() -{ - DEBUG_BLOCK -} - -//TODO: This should be moved to the ScriptableServiceManager instead -void -ServiceBrowser::setScriptableServiceManager( ScriptableServiceManager * scriptableServiceManager ) -{ - m_scriptableServiceManager = scriptableServiceManager; - m_scriptableServiceManager->setParent( this ); - connect ( m_scriptableServiceManager, SIGNAL(addService(ServiceBase*)), this, SLOT(addService(ServiceBase*)) ); -} - -void -ServiceBrowser::resetService( const QString &name ) -{ - //What in the world is this for... - - //Currently unused, but needed, in the future, for resetting a service based on config changes - //or the user choosing to reset the state of the service somehow. - Q_UNUSED( name ); -} - -void ServiceBrowser::addService( ServiceBase * service ) -{ - DEBUG_BLOCK - addCategory( service ); -} - -#include "moc_ServiceBrowser.cpp" - diff --git a/amarok/src/browsers/servicebrowser/ServiceBrowser.h b/amarok/src/browsers/servicebrowser/ServiceBrowser.h deleted file mode 100644 index 0249efc9..00000000 --- a/amarok/src/browsers/servicebrowser/ServiceBrowser.h +++ /dev/null @@ -1,92 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROKSERVICEBROWSER_H -#define AMAROKSERVICEBROWSER_H - - - -#include "browsers/BrowserCategoryList.h" -#include "services/scriptable/ScriptableServiceManager.h" -#include "services/ServiceBase.h" - -#include - -#include -#include -#include - - -/** - * A browser for selecting and displaying a service in the style of the first - * imbedded Magnatune store from a list of available services. Allows - * many services to be shown as a single category. - * Implemented as a singleton. - * - * @author Nikolaj Hald Nielsen - */ -class ServiceBrowser : public BrowserCategoryList -{ - Q_OBJECT - - public: - /** - * Get the ServiceBrowser instance. Create it if it does not exist yet. ( Singleton pattern ). - * @return The ServiceBrowser instance. - */ - static ServiceBrowser *instance(); - - /** - * Destructor. - */ - ~ServiceBrowser(); - - /** - * Reset a service and make it reload configuration. Not fully implemented.. - * @param name The name of the service to reset. - */ - void resetService( const QString &name ); - - public slots: - - /** - * Set a scriptable service manager to handle scripted services. - * @param scriptableServiceManager The scriptable service manager to set. - */ - void setScriptableServiceManager( ScriptableServiceManager *scriptableServiceManager ); - - void addService ( ServiceBase * ); - - private: - /** - * Private constructor ( Singleton pattern ) - * @param parent The parent widget. - * @param name The name of this widget. - */ - ServiceBrowser( const QString& name, QWidget *parent = 0 ); - - static ServiceBrowser *s_instance; - - ScriptableServiceManager *m_scriptableServiceManager; - - QTimer m_filterTimer; - - QString m_currentFilter; - -}; - - -#endif diff --git a/amarok/src/configdialog/ConfigDialog.cpp b/amarok/src/configdialog/ConfigDialog.cpp deleted file mode 100644 index fbcb4621..00000000 --- a/amarok/src/configdialog/ConfigDialog.cpp +++ /dev/null @@ -1,218 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2004-2008 Mark Kretschmann * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "ConfigDialog" - -#include "ConfigDialog.h" - -#include "amarokconfig.h" -#include "configdialog/dialogs/CollectionConfig.h" -#include "configdialog/dialogs/DatabaseConfig.h" -#include "configdialog/dialogs/GeneralConfig.h" -#include "configdialog/dialogs/MetadataConfig.h" -#include "configdialog/dialogs/NotificationsConfig.h" -#include "configdialog/dialogs/PlaybackConfig.h" -#include "configdialog/dialogs/PluginsConfig.h" -#include "configdialog/dialogs/ScriptsConfig.h" -#include "core/support/Amarok.h" -#include "core/support/Debug.h" - -#include - -QString Amarok2ConfigDialog::s_currentPage = "GeneralConfig"; - -////////////////////////////////////////////////////////////////////////////////////////// -// PUBLIC -////////////////////////////////////////////////////////////////////////////////////////// - -Amarok2ConfigDialog::Amarok2ConfigDialog( QWidget *parent, const char* name, KConfigSkeleton *config ) - : KConfigDialog( parent, name, config ) -{ - DEBUG_BLOCK - setAttribute( Qt::WA_DeleteOnClose ); - - ConfigDialogBase *general = new GeneralConfig( this ); - ConfigDialogBase *collection = new CollectionConfig( this ); - ConfigDialogBase *metadata = new MetadataConfig( this ); - ConfigDialogBase *playback = new PlaybackConfig( this ); - ConfigDialogBase *notify = new NotificationsConfig( this ); - ConfigDialogBase *database = new DatabaseConfig( this, config ); - ConfigDialogBase *plugins = new PluginsConfig( this ); - ConfigDialogBase *scripts = new ScriptsConfig( this ); - - //ConfigDialogBase* mediadevice = new MediadeviceConfig( this ); - - addPage( general, i18nc( "Miscellaneous settings", "General" ), "preferences-other-amarok", i18n( "Configure General Options" ) ); - addPage( collection, i18n( "Local Collection" ), "drive-harddisk", i18n( "Configure Local Collection" ) ); - addPage( metadata, i18n( "Metadata" ), "amarok_playcount", i18n( "Configure Metadata Handling" ) ); - addPage( playback, i18n( "Playback" ), "preferences-media-playback-amarok", i18n( "Configure Playback" ) ); - addPage( notify, i18n( "Notifications" ), "preferences-indicator-amarok", i18n( "Configure Notifications" ) ); - addPage( database, i18n( "Database" ), "server-database", i18n( "Configure Database" ) ); - addPage( plugins, i18n( "Plugins" ), "preferences-plugin", i18n( "Configure Plugins" ) ); - addPage( scripts, i18n( "Scripts" ), "preferences-plugin-script", i18n( "Configure Scripts" ) ); - //addPage( mediadevice, i18n( "Media Devices" ), "preferences-multimedia-player-amarok", i18n( "Configure Portable Player Support" ) ); - - setButtons( Help | Ok | Apply | Cancel ); - restoreDialogSize( Amarok::config( "ConfigDialog" ) ); -} - -Amarok2ConfigDialog::~Amarok2ConfigDialog() -{ - DEBUG_BLOCK - - KPageWidgetItem* pageItem = currentPage(); - - foreach( ConfigDialogBase *configPage, m_pageList ) - { - if( m_pageMap[configPage] == pageItem ) - { - s_currentPage = configPage->metaObject()->className(); - break; - } - } - - KConfigGroup config = Amarok::config( "ConfigDialog" ); - saveDialogSize( config ); - AmarokConfig::self()->writeConfig(); -} - -void Amarok2ConfigDialog::updateButtons() //SLOT -{ - DEBUG_BLOCK - - enableButtonApply( hasChanged() ); -} - -/** Reimplemented from KConfigDialog */ -void Amarok2ConfigDialog::addPage( ConfigDialogBase *page, const QString &itemName, const QString &pixmapName, const QString &header, bool manage ) -{ - connect( page, SIGNAL(settingsChanged(QString)), this, SIGNAL(settingsChanged(QString)) ); - - // Add the widget pointer to our list, for later reference - m_pageList << page; - KPageWidgetItem *pageWidget = KConfigDialog::addPage( page, itemName, pixmapName, header, manage ); - m_pageMap.insert( page, pageWidget ); -} - -void Amarok2ConfigDialog::show( QString page ) -{ - if( page.isNull() ) - { - page = s_currentPage; - } - - foreach( ConfigDialogBase *configPage, m_pageList ) - { - if( configPage->metaObject()->className() == page ) - { - KPageWidgetItem *pageItem = m_pageMap[configPage]; - KConfigDialog::setCurrentPage( pageItem ); - break; - } - } - - KConfigDialog::show(); - raise(); - activateWindow(); -} - -////////////////////////////////////////////////////////////////////////////////////////// -// PROTECTED SLOTS -////////////////////////////////////////////////////////////////////////////////////////// - -/** - * Update the settings from the dialog. - * Example use: User clicks Ok or Apply button in a configure dialog. - * REIMPLEMENTED - */ -void Amarok2ConfigDialog::updateSettings() -{ - foreach( ConfigDialogBase* page, m_pageList ) - page->updateSettings(); -} - -/** - * Update the configuration-widgets in the dialog based on Amarok's current settings. - * Example use: Initialisation of dialog. - * Example use: User clicks Reset button in a configure dialog. - * REIMPLEMENTED - */ -void Amarok2ConfigDialog::updateWidgets() -{ - foreach( ConfigDialogBase* page, m_pageList ) - page->updateWidgets(); -} - -/** - * Update the configuration-widgets in the dialog based on the default values for Amarok's settings. - * Example use: User clicks Defaults button in a configure dialog. - * REIMPLEMENTED - */ -void Amarok2ConfigDialog::updateWidgetsDefault() -{ - foreach( ConfigDialogBase* page, m_pageList ) - page->updateWidgetsDefault(); -} - - -////////////////////////////////////////////////////////////////////////////////////////// -// PROTECTED -////////////////////////////////////////////////////////////////////////////////////////// - -/** - * @return true if any configuration items we are managing changed from Amarok's stored settings - * We manage the engine combo box and some of the OSD settings - * REIMPLEMENTED - */ -bool Amarok2ConfigDialog::hasChanged() -{ - DEBUG_BLOCK - - bool changed = false; - - foreach( ConfigDialogBase* page, m_pageList ) - if( page->hasChanged() ) { - changed = true; - debug() << "Changed: " << page->metaObject()->className(); - } - - return changed; -} - -/** REIMPLEMENTED */ -bool Amarok2ConfigDialog::isDefault() -{ - bool def = false; - - foreach( ConfigDialogBase* page, m_pageList ) - if( page->isDefault() ) - def = true; - - return def; -} - - -////////////////////////////////////////////////////////////////////////////////////////// -// PRIVATE SLOTS -////////////////////////////////////////////////////////////////////////////////////////// - - -////////////////////////////////////////////////////////////////////////////////////////// -// PRIVATE -////////////////////////////////////////////////////////////////////////////////////////// - - -#include "moc_ConfigDialog.cpp" diff --git a/amarok/src/configdialog/ConfigDialog.h b/amarok/src/configdialog/ConfigDialog.h deleted file mode 100644 index 8e049183..00000000 --- a/amarok/src/configdialog/ConfigDialog.h +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2004-2008 Mark Kretschmann * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK2CONFIGDIALOG_H -#define AMAROK2CONFIGDIALOG_H - -#include "ConfigDialogBase.h" - -#include - - -class Amarok2ConfigDialog : public KConfigDialog -{ - Q_OBJECT - - public: - Amarok2ConfigDialog( QWidget *parent, const char* name, KConfigSkeleton *config ); - ~Amarok2ConfigDialog(); - - void addPage( ConfigDialogBase *page, const QString &itemName, const QString &pixmapName, - const QString &header = QString(), bool manage = true ); - - public slots: - /** - * Shows the config dialog and sets the current page to "page" - * - * @param page (class name of the dialog). - */ - void show( QString page ); - - /** - * Updates the state of the Apply button. Useful for widgets that are not managed by KConfigXT. - */ - void updateButtons(); - - protected slots: - void updateSettings(); - void updateWidgets(); - void updateWidgetsDefault(); - - private slots: - - protected: - bool hasChanged(); - bool isDefault(); - - private: - QList m_pageList; - QMap m_pageMap; - - static QString s_currentPage; -}; - - -#endif // AMAROK2CONFIGDIALOG_H diff --git a/amarok/src/configdialog/ConfigDialogBase.cpp b/amarok/src/configdialog/ConfigDialogBase.cpp deleted file mode 100644 index 387a4bdf..00000000 --- a/amarok/src/configdialog/ConfigDialogBase.cpp +++ /dev/null @@ -1,19 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2004-2007 Mark Kretschmann * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "ConfigDialogBase.h" -#include "moc_ConfigDialogBase.cpp" - diff --git a/amarok/src/configdialog/ConfigDialogBase.h b/amarok/src/configdialog/ConfigDialogBase.h deleted file mode 100644 index d35b3fe2..00000000 --- a/amarok/src/configdialog/ConfigDialogBase.h +++ /dev/null @@ -1,44 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2004-2007 Mark Kretschmann * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef CONFIGDIALOGBASE_H -#define CONFIGDIALOGBASE_H - -#include - - -class ConfigDialogBase : public QWidget -{ - Q_OBJECT - - signals: - void settingsChanged( const QString& ); - - public: - virtual void updateSettings() = 0; - virtual void updateWidgets() {} - virtual void updateWidgetsDefault() {} - - virtual bool hasChanged() = 0; - virtual bool isDefault() = 0; - - protected: - ConfigDialogBase( QWidget* parent ) : QWidget( parent ) {} -}; - - -#endif - diff --git a/amarok/src/configdialog/dialogs/CollectionConfig.cpp b/amarok/src/configdialog/dialogs/CollectionConfig.cpp deleted file mode 100644 index 5a7376f6..00000000 --- a/amarok/src/configdialog/dialogs/CollectionConfig.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2004-2007 Mark Kretschmann * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "CollectionConfig.h" - -#include "amarokconfig.h" -#include -#include "core/support/Amarok.h" -#include "core-impl/collections/db/sql/SqlCollection.h" -#include "dialogs/CollectionSetup.h" - -CollectionConfig::CollectionConfig( QWidget* parent ) - : ConfigDialogBase( parent ) -{ - m_collectionSetup = new CollectionSetup( this ); - connect( m_collectionSetup, SIGNAL(changed()), parent, SLOT(updateButtons()) ); - - QVBoxLayout *layout = new QVBoxLayout(); - layout->addWidget( m_collectionSetup ); - setLayout( layout ); - - KConfigGroup transcodeGroup = Amarok::config( Collections::SQL_TRANSCODING_GROUP_NAME ); - m_collectionSetup->transcodingConfig()->fillInChoices( Transcoding::Configuration::fromConfigGroup( transcodeGroup ) ); - connect( m_collectionSetup->transcodingConfig(), SIGNAL(currentIndexChanged(int)), parent, SLOT(updateButtons()) ); -} - -CollectionConfig::~CollectionConfig() -{} - - -/////////////////////////////////////////////////////////////// -// REIMPLEMENTED METHODS from ConfigDialogBase -/////////////////////////////////////////////////////////////// - -bool -CollectionConfig::hasChanged() -{ - DEBUG_BLOCK - - return m_collectionSetup->hasChanged() || m_collectionSetup->transcodingConfig()->hasChanged(); -} - -bool -CollectionConfig::isDefault() -{ - return false; -} - -void -CollectionConfig::updateSettings() -{ - m_collectionSetup->writeConfig(); - - KConfigGroup transcodeGroup = Amarok::config( Collections::SQL_TRANSCODING_GROUP_NAME ); - m_collectionSetup->transcodingConfig()->currentChoice().saveToConfigGroup( transcodeGroup ); -} - -#include "moc_CollectionConfig.cpp" diff --git a/amarok/src/configdialog/dialogs/CollectionConfig.h b/amarok/src/configdialog/dialogs/CollectionConfig.h deleted file mode 100644 index d2d999bf..00000000 --- a/amarok/src/configdialog/dialogs/CollectionConfig.h +++ /dev/null @@ -1,44 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2004-2007 Mark Kretschmann * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef COLLECTIONCONFIG_H -#define COLLECTIONCONFIG_H - -#include "configdialog/ConfigDialogBase.h" - -class CollectionSetup; - - -class CollectionConfig : public ConfigDialogBase -{ - Q_OBJECT - - public: - CollectionConfig( QWidget* parent ); - virtual ~CollectionConfig(); - - virtual bool hasChanged(); - virtual bool isDefault(); - virtual void updateSettings(); - - private: - CollectionSetup* m_collectionSetup; -}; - - -#endif - - diff --git a/amarok/src/configdialog/dialogs/DatabaseConfig.cpp b/amarok/src/configdialog/dialogs/DatabaseConfig.cpp deleted file mode 100644 index b6c340b5..00000000 --- a/amarok/src/configdialog/dialogs/DatabaseConfig.cpp +++ /dev/null @@ -1,178 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 John Atkinson * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 Pulic License for more details. * - * * - * You should have received a copy of the GNU General Public License along with * - * this program. If not, see . * - ****************************************************************************************/ - -#include "DatabaseConfig.h" - -#include -#include -#include - -#include -#include -#include - - -DatabaseConfig::DatabaseConfig( QWidget* parent, KConfigSkeleton *config ) - : ConfigDialogBase( parent ) - , m_configManager( new KConfigDialogManager( this, config ) ) -{ - setupUi( this ); - - // Fix some weird tab orderness - setTabOrder( kcfg_Host, kcfg_Port ); // host to port - setTabOrder( kcfg_Port, kcfg_User ); // port to username - setTabOrder( kcfg_User, kcfg_Password ); // username to password - setTabOrder( kcfg_Password, kcfg_Database ); // password to database - - // enable the test button if one of the plugin factories has a correct testSettings slot - // get all storage factories - QList factories; - factories = Plugins::PluginManager::instance()->factories( Plugins::PluginManager::Storage ); - bool testFunctionAvailable = false; - foreach( Plugins::PluginFactory* factory, factories ) - { - // check the meta object if there is a testSettings slot available - if( factory->metaObject()-> - indexOfMethod( QMetaObject::normalizedSignature("testSettings(QString, QString, QString, int, QString)" ) ) >= 0 ) - testFunctionAvailable = true; - } - button_Test->setEnabled( testFunctionAvailable ); - - // connect slots - connect( kcfg_UseServer, SIGNAL(stateChanged(int)), SLOT(toggleExternalConfigAvailable(int)) ); - - connect( kcfg_Database, SIGNAL(textChanged(QString)), SLOT(updateSQLQuery()) ); - connect( kcfg_User, SIGNAL(textChanged(QString)), SLOT(updateSQLQuery()) ); - connect( button_Test, SIGNAL(clicked(bool)), SLOT(testDatabaseConnection())); - - toggleExternalConfigAvailable( kcfg_UseServer->checkState() ); - - updateSQLQuery(); - - m_configManager->addWidget( this ); -} - -DatabaseConfig::~DatabaseConfig() -{} - -void -DatabaseConfig::toggleExternalConfigAvailable( const int checkBoxState ) //SLOT -{ - group_Connection->setEnabled( checkBoxState == Qt::Checked ); -} - -void -DatabaseConfig::testDatabaseConnection() //SLOT -{ - // get all storage factories - QList factories; - factories = Plugins::PluginManager::instance()->factories( Plugins::PluginManager::Storage ); - - // try if they have a testSettings slot that we can call - bool tested = false; - foreach( Plugins::PluginFactory* factory, factories ) - { - bool callSucceeded = false; - QStringList connectionErrors; - - callSucceeded = QMetaObject::invokeMethod( factory, - "testSettings", - Q_RETURN_ARG( QStringList, connectionErrors ), - Q_ARG( QString, kcfg_Host->text() ), - Q_ARG( QString, kcfg_User->text() ), - Q_ARG( QString, kcfg_Password->text() ), - Q_ARG( int, kcfg_Port->text().toInt() ), - Q_ARG( QString, kcfg_Database->text() ) - ); - - if( callSucceeded ) - { - tested = true; - if( connectionErrors.isEmpty() ) - KMessageBox::messageBox( this, KMessageBox::Information, - i18n( "Amarok was able to establish a successful connection to the database." ), - i18n( "Success" ) ); - else - KMessageBox::error( this, i18n( "The amarok database reported " - "the following errors:\n%1\nIn most cases you will need to resolve " - "these errors before Amarok will run properly." ). - arg( connectionErrors.join( "\n" ) ), - i18n( "Database Error" )); - } - } -} - -/////////////////////////////////////////////////////////////// -// REIMPLEMENTED METHODS from ConfigDialogBase -/////////////////////////////////////////////////////////////// - -bool -DatabaseConfig::hasChanged() -{ - return false; -} - -bool -DatabaseConfig::isDefault() -{ - return false; -} - -void -DatabaseConfig::updateSettings() -{ - if( m_configManager->hasChanged() ) - KMessageBox::messageBox( 0, KMessageBox::Information, - i18n( "Changes to database settings only take\neffect after Amarok is restarted." ), - i18n( "Database settings changed" ) ); -} - - -/////////////////////////////////////////////////////////////// -// PRIVATE METHODS -/////////////////////////////////////////////////////////////// - -void -DatabaseConfig::updateSQLQuery() //SLOT -{ - QString query; - - if( isSQLInfoPresent() ) - { - // Query template: - // GRANT ALL ON amarokdb.* TO 'amarokuser'@'localhost' IDENTIFIED BY 'mypassword'; FLUSH PRIVILEGES; - - // Don't print the actual password! - const QString examplePassword = i18nc( "A default password for insertion into an example SQL command (so as not to print the real one). To be manually replaced by the user.", "password" ); - query = QString( "CREATE DATABASE %1;\nGRANT ALL PRIVILEGES ON %1.* TO '%2' IDENTIFIED BY '%3'; FLUSH PRIVILEGES;" ) - .arg( kcfg_Database->text() ) - .arg( kcfg_User->text() ) - .arg( examplePassword ); - } - text_SQL->setPlainText( query ); -} - - -inline bool -DatabaseConfig::isSQLInfoPresent() const -{ - return !kcfg_Database->text().isEmpty() && !kcfg_User->text().isEmpty() && !kcfg_Host->text().isEmpty(); -} - - -#include "moc_DatabaseConfig.cpp" - - diff --git a/amarok/src/configdialog/dialogs/DatabaseConfig.h b/amarok/src/configdialog/dialogs/DatabaseConfig.h deleted file mode 100644 index baff2df6..00000000 --- a/amarok/src/configdialog/dialogs/DatabaseConfig.h +++ /dev/null @@ -1,60 +0,0 @@ - -/**************************************************************************************** - * Copyright (c) 2009 John Atkinson * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 Pulic License for more details. * - * * - * You should have received a copy of the GNU General Public License along with * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef DATABASECONFIG_H -#define DATABASECONFIG_H - -#include "ui_DatabaseConfig.h" -#include "configdialog/ConfigDialogBase.h" - -class KConfigDialogManager; -class KConfigSkeleton; - -class DatabaseConfig : public ConfigDialogBase, public Ui_DatabaseConfig -{ - Q_OBJECT - - public: - DatabaseConfig( QWidget* parent, KConfigSkeleton *config ); - virtual ~DatabaseConfig(); - - virtual bool hasChanged(); - virtual bool isDefault(); - virtual void updateSettings(); - - public slots: - void toggleExternalConfigAvailable( int checkBoxState ); - void testDatabaseConnection(); - - private Q_SLOTS: - void updateSQLQuery(); - - private: - /** Returns true if the configuration is complete. - * - * Complete menas that the database, user and host are filled out. - */ - bool isSQLInfoPresent() const; - - KConfigDialogManager* m_configManager; - -}; - - -#endif - - diff --git a/amarok/src/configdialog/dialogs/DatabaseConfig.ui b/amarok/src/configdialog/dialogs/DatabaseConfig.ui deleted file mode 100644 index 0d198e37..00000000 --- a/amarok/src/configdialog/dialogs/DatabaseConfig.ui +++ /dev/null @@ -1,262 +0,0 @@ - - - DatabaseConfig - - - - 0 - 0 - 339 - 500 - - - - - - - Check to enable the use of an external database. By default there is already an embedded MySQL database running. - - - Check to enable the use of an external database. By default there is already an embedded MySQL database running. - - - Use &external MySQL database - - - - - - - Connection Settings - - - - - - - - &Server: - - - Qt::AutoText - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - kcfg_Host - - - - - - - Enter the name of the existing MySQL server - - - - - - - - - - - - 0 - 0 - - - - P&ort: - - - Qt::AutoText - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - 2 - - - kcfg_Port - - - - - - - Enter the port number to access the server. Default is port 3306. - - - - 65535 - - - - - - - &Username: - - - Qt::AutoText - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - kcfg_User - - - - - - - Enter the password for the default user. - - - - - - - - - - QLineEdit::Password - - - - - - - &Password: - - - Qt::AutoText - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - kcfg_Password - - - - - - - Enter the username to access the database with full access privileges. - - - - - - - - - - - &Database: - - - Qt::AutoText - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - kcfg_Database - - - - - - - Enter the name of the database. Default preset is amarokdb. - - - - - - - - - - - Test database connection - - - - - - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - - - Amarok expects the above database and user account to already exist. This user also requires full access to the database. Changes only take effect after Amarok is restarted. - - - true - - - - - - - If your database is not already set up, you can use the following S&QL commands (after replacing the password with the correct one): - - - true - - - text_SQL - - - - - - - ArrowCursor - - - false - - - true - - - - - - - - - - Qt::Vertical - - - - 0 - 0 - - - - - - - - - - - - diff --git a/amarok/src/configdialog/dialogs/ExcludedLabelsDialog.cpp b/amarok/src/configdialog/dialogs/ExcludedLabelsDialog.cpp deleted file mode 100644 index 3d0375aa..00000000 --- a/amarok/src/configdialog/dialogs/ExcludedLabelsDialog.cpp +++ /dev/null @@ -1,120 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "ExcludedLabelsDialog.h" - -#include "core/meta/Meta.h" -#include "core/collections/QueryMaker.h" -#include "core-impl/collections/support/CollectionManager.h" -#include "statsyncing/Config.h" - -#include -#include - -#include -#include -#include -#include - -ExcludedLabelsDialog::ExcludedLabelsDialog( StatSyncing::Config *config, QWidget *parent, - Qt::WFlags flags ) - : KDialog( parent, flags ) - , m_statSyncingConfig( config ) -{ - Q_ASSERT( m_statSyncingConfig ); - setupUi( mainWidget() ); - setButtons( Ok | Cancel ); - setCaption( i18n( "Excluded Labels" ) ); - - addLabels( config->excludedLabels(), true ); - Collections::QueryMaker *qm = CollectionManager::instance()->queryMaker(); - qm->setQueryType( Collections::QueryMaker::Label ); - qm->setAutoDelete( true ); - connect( qm, SIGNAL(newResultReady(Meta::LabelList)), - SLOT(slowNewResultReady(Meta::LabelList)) ); - qm->run(); - - connect( addButton, SIGNAL(clicked(bool)), SLOT(slotAddExcludedLabel()) ); - connect( addLabelLine, SIGNAL(returnPressed(QString)), SLOT(slotAddExcludedLabel()) ); - connect( this, SIGNAL(okClicked()), SLOT(slotSaveToConfig()) ); -} - -void -ExcludedLabelsDialog::slowNewResultReady( const Meta::LabelList &labels ) -{ - foreach( const Meta::LabelPtr &label, labels ) - addLabel( label->name() ); -} - -void -ExcludedLabelsDialog::slotAddExcludedLabel() -{ - addLabel( addLabelLine->text(), true ); - addLabelLine->setText( QString() ); -} - -void -ExcludedLabelsDialog::slotSaveToConfig() -{ - QSet excluded; - foreach( const QListWidgetItem *item, listWidget->selectedItems() ) - { - excluded.insert( item->text() ); - } - m_statSyncingConfig->setExcludedLabels( excluded ); -} - -void -ExcludedLabelsDialog::addLabel( const QString &label, bool selected ) -{ - int count = listWidget->count(); - for( int i = 0; i <= count; i++ ) - { - QModelIndex idx; - if( i == count ) - { - // reached end of the list - listWidget->addItem( label ); - idx = listWidget->model()->index( i, 0 ); - } - else if( listWidget->item( i )->text() == label ) - { - // already in list - return; - } - else if( QString::localeAwareCompare( listWidget->item( i )->text(), label ) > 0 ) - { - listWidget->insertItem( i, label ); - idx = listWidget->model()->index( i, 0 ); - } - // else continue to next iteration - - // just inserted - if( idx.isValid() && selected ) - listWidget->selectionModel()->select( idx, QItemSelectionModel::Select ); - if( idx.isValid() ) - return; - } -} - -void -ExcludedLabelsDialog::addLabels( const QSet &labels, bool selected ) -{ - foreach( const QString &label, labels ) - { - addLabel( label, selected ); - } -} diff --git a/amarok/src/configdialog/dialogs/ExcludedLabelsDialog.h b/amarok/src/configdialog/dialogs/ExcludedLabelsDialog.h deleted file mode 100644 index 3f11e88b..00000000 --- a/amarok/src/configdialog/dialogs/ExcludedLabelsDialog.h +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef EXCLUDEDLABELSDIALOG_H -#define EXCLUDEDLABELSDIALOG_H - -#include "ui_ExcludedLabelsDialog.h" -#include "core/meta/forward_declarations.h" - -#include - -namespace StatSyncing { - class Config; -} -class KLineEdit; -class QGridLayout; -class QListWidget; - -class ExcludedLabelsDialog : public KDialog, private Ui_ExcludedLabelsDialog -{ - Q_OBJECT - - public: - explicit ExcludedLabelsDialog( StatSyncing::Config *config, QWidget *parent = 0, - Qt::WFlags flags = 0 ); - - private slots: - void slowNewResultReady( const Meta::LabelList &labels ); - void slotAddExcludedLabel(); - void slotSaveToConfig(); - - private: - void addLabel( const QString &label, bool selected = false ); - void addLabels( const QSet &labels, bool selected = false ); - - StatSyncing::Config *m_statSyncingConfig; -}; - -#endif // EXCLUDEDLABELSDIALOG_H diff --git a/amarok/src/configdialog/dialogs/ExcludedLabelsDialog.ui b/amarok/src/configdialog/dialogs/ExcludedLabelsDialog.ui deleted file mode 100644 index 588d0c54..00000000 --- a/amarok/src/configdialog/dialogs/ExcludedLabelsDialog.ui +++ /dev/null @@ -1,65 +0,0 @@ - - - ExcludedLabelsDialog - - - - 0 - 0 - 400 - 300 - - - - - - - Add this label to the list of excluded labels - - - - - - - - - - true - - - Add Label to Exclude - - - - - - - QAbstractItemView::MultiSelection - - - - - - - Selected labels won't be touched by statistics synchronization - - - Qt::AlignJustify|Qt::AlignVCenter - - - true - - - - - - - - KLineEdit - QLineEdit -
klineedit.h
-
-
- - -
diff --git a/amarok/src/configdialog/dialogs/GeneralConfig.cpp b/amarok/src/configdialog/dialogs/GeneralConfig.cpp deleted file mode 100644 index 87061222..00000000 --- a/amarok/src/configdialog/dialogs/GeneralConfig.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2004-2007 Mark Kretschmann * - * Copyright (c) 2005 Ian Monroe * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "GeneralConfig.h" - -GeneralConfig::GeneralConfig( QWidget* parent ) - : ConfigDialogBase( parent ) -{ - setupUi( this ); -} - -GeneralConfig::~GeneralConfig() -{} - -/////////////////////////////////////////////////////////////// -// REIMPLEMENTED METHODS from ConfigDialogBase -/////////////////////////////////////////////////////////////// - -bool -GeneralConfig::hasChanged() -{ - return false; -} - -bool -GeneralConfig::isDefault() -{ - return false; -} - -void -GeneralConfig::updateSettings() //SLOT -{ -} - -#include "moc_GeneralConfig.cpp" diff --git a/amarok/src/configdialog/dialogs/GeneralConfig.h b/amarok/src/configdialog/dialogs/GeneralConfig.h deleted file mode 100644 index 6a7135b5..00000000 --- a/amarok/src/configdialog/dialogs/GeneralConfig.h +++ /dev/null @@ -1,36 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2004-2007 Mark Kretschmann * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef GENERALCONFIG_H -#define GENERALCONFIG_H - -#include "ui_GeneralConfig.h" -#include "configdialog/ConfigDialogBase.h" - -class GeneralConfig : public ConfigDialogBase, public Ui_GeneralConfig -{ - Q_OBJECT - - public: - GeneralConfig( QWidget* parent ); - virtual ~GeneralConfig(); - - virtual bool hasChanged(); - virtual bool isDefault(); - virtual void updateSettings(); -}; - -#endif diff --git a/amarok/src/configdialog/dialogs/GeneralConfig.ui b/amarok/src/configdialog/dialogs/GeneralConfig.ui deleted file mode 100644 index 5cef064f..00000000 --- a/amarok/src/configdialog/dialogs/GeneralConfig.ui +++ /dev/null @@ -1,190 +0,0 @@ - - - GeneralConfig - - - - 0 - 0 - 440 - 420 - - - - - 0 - 340 - - - - - - - General Options - - - - - - Check to enable the Amarok system tray icon. - - - Check to enable the Amarok system tray icon. - - - Show tray &icon - - - - - - - Check to enable the automatic retrieval of cover art from the Internet. - - - Check to enable the automatic retrieval of cover art from the Internet. - - - Automatically retrieve cover art - - - - - - - Check to enable animations when context applets collapse. - - - Check to enable animations when context applets collapse. - - - Enable context applets collapse animations - - - - - - - Show background images in the browser panel - - - - - - - - - - Playlist Options - - - - - - Check to make the playlist scroll so the current track is always visible. - - - Automatically scroll playlist to current track - - - - - - - - - - Moodbar Options - - - - - - <b>Note</b>: Mood files must be generated manually. For more information, visit <a href="http://userbase.kde.org/Amarok/Manual/Various/Moodbar">related article on KDE UserBase</a>. - - - true - - - true - - - - - - - The Moodbar makes it possible to navigate in your music visually. -Please note that this feature requires the external "Moodbar Generator" tool. - - - Show Moodbar in Progress Slider - - - - - - - Moodbar style - - - - - - - Choose the mood display style - - - Choose the mood display style - - - - Default (System colours) - - - - - Angry - - - - - Frozen - - - - - Happy - - - - - Normal - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - kcombobox.h - klineedit.h - - - - diff --git a/amarok/src/configdialog/dialogs/MetadataConfig.cpp b/amarok/src/configdialog/dialogs/MetadataConfig.cpp deleted file mode 100644 index af2643e5..00000000 --- a/amarok/src/configdialog/dialogs/MetadataConfig.cpp +++ /dev/null @@ -1,312 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "MetadataConfig.h" - -#include "amarokconfig.h" -#include "configdialog/dialogs/ExcludedLabelsDialog.h" -#include "core/meta/support/MetaConstants.h" -#include "core/support/Components.h" -#include "core/support/Debug.h" -#include "statsyncing/Config.h" -#include "statsyncing/Controller.h" - -#include "MetaValues.h" - -#include - -MetadataConfig::MetadataConfig( QWidget *parent ) - : ConfigDialogBase( parent ) -{ - connect( this, SIGNAL(changed()), parent, SLOT(updateButtons()) ); - - setupUi( this ); - - m_writeBackCoverDimensions->addItem( - i18nc("Maximum cover size option", "Small (200 px)" ), QVariant( 200 ) ); - m_writeBackCoverDimensions->addItem( - i18nc("Maximum cover size option", "Medium (400 px)" ), QVariant( 400 ) ); - m_writeBackCoverDimensions->addItem( - i18nc("Maximum cover size option", "Large (800 px)" ), QVariant( 800 ) ); - m_writeBackCoverDimensions->addItem( - i18nc("Maximum cover size option", "Huge (1600 px)" ), QVariant( 1600 ) ); - - m_writeBack->setChecked( AmarokConfig::writeBack() ); - m_writeBack->setVisible( false ); // probably not a usecase - m_writeBackStatistics->setChecked( AmarokConfig::writeBackStatistics() ); - m_writeBackStatistics->setEnabled( m_writeBack->isChecked() ); - m_writeBackCover->setChecked( AmarokConfig::writeBackCover() ); - m_writeBackCover->setEnabled( m_writeBack->isChecked() ); - if( m_writeBackCoverDimensions->findData( AmarokConfig::writeBackCoverDimensions() ) != -1 ) - m_writeBackCoverDimensions->setCurrentIndex( m_writeBackCoverDimensions->findData( AmarokConfig::writeBackCoverDimensions() ) ); - else - m_writeBackCoverDimensions->setCurrentIndex( 1 ); // medium - m_writeBackCoverDimensions->setEnabled( m_writeBackCover->isEnabled() && m_writeBackCover->isChecked() ); - m_useCharsetDetector->setChecked( AmarokConfig::useCharsetDetector() ); - connect( m_writeBack, SIGNAL(toggled(bool)), this, SIGNAL(changed()) ); - connect( m_writeBackStatistics, SIGNAL(toggled(bool)), this, SIGNAL(changed()) ); - connect( m_writeBackCover, SIGNAL(toggled(bool)), this, SIGNAL(changed()) ); - connect( m_writeBackCoverDimensions, SIGNAL(currentIndexChanged(int)), this, SIGNAL(changed()) ); - connect( m_useCharsetDetector, SIGNAL(toggled(bool)), this, SIGNAL(changed()) ); - - StatSyncing::Controller *controller = Amarok::Components::statSyncingController(); - StatSyncing::Config *config = controller ? controller->config() : 0; - m_statSyncingConfig = config; - m_statSyncingProvidersView->setModel( config ); - m_synchronizeButton->setIcon( KIcon( "amarok_playcount" ) ); - m_configureTargetButton->setIcon( KIcon( "configure" ) ); - connect( config, SIGNAL(dataChanged(QModelIndex,QModelIndex)), SIGNAL(changed()) ); - connect( config, SIGNAL(rowsInserted(QModelIndex,int,int)), SIGNAL(changed()) ); - connect( config, SIGNAL(rowsRemoved(QModelIndex,int,int)), SIGNAL(changed()) ); - connect( config, SIGNAL(modelReset()), SIGNAL(changed()) ); - - // Add target button - m_addTargetButton->setEnabled( controller && controller->hasProviderFactories() ); - connect( m_addTargetButton, SIGNAL(clicked(bool)), SLOT(slotCreateProviderDialog()) ); - - // Configure target button - m_configureTargetButton->setEnabled( false ); - connect( m_statSyncingProvidersView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), - SLOT(slotUpdateProviderConfigureButton()) ); - connect( m_configureTargetButton, SIGNAL(clicked(bool)), SLOT(slotConfigureProvider()) ); - - // Forget target button - connect( m_statSyncingProvidersView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), - SLOT(slotUpdateForgetButton()) ); - connect( m_forgetTargetsButton, SIGNAL(clicked(bool)), SLOT(slotForgetCollections()) ); - - // Synchronize button - if( controller ) - connect( m_synchronizeButton, SIGNAL(clicked(bool)), controller, SLOT(synchronize()) ); - else - m_synchronizeButton->setEnabled( false ); - - slotUpdateForgetButton(); - - const qint64 checkedFields = config ? config->checkedFields() : 0; - QMap i18nSyncLabels; // to avoid word puzzles, bug 334561 - i18nSyncLabels.insert( Meta::valRating, i18nc( "Statistics sync checkbox label", - "Synchronize Ratings" ) ); - i18nSyncLabels.insert( Meta::valFirstPlayed, i18nc( "Statistics sync checkbox label", - "Synchronize First Played Times" ) ); - i18nSyncLabels.insert( Meta::valLastPlayed, i18nc( "Statistics sync checkbox label", - "Synchronize Last Played Times" ) ); - i18nSyncLabels.insert( Meta::valPlaycount, i18nc( "Statistics sync checkbox label", - "Synchronize Playcounts" ) ); - i18nSyncLabels.insert( Meta::valLabel, i18nc( "Statistics sync checkbox label", - "Synchronize Labels" ) ); - - foreach( qint64 field, StatSyncing::Controller::availableFields() ) - { - QString name = i18nSyncLabels.value( field ); - if( name.isEmpty() ) - { - name = i18nc( "%1 is field name such as Play Count (this string is only used " - "as a fallback)", "Synchronize %1", Meta::i18nForField( field ) ); - warning() << Q_FUNC_INFO << "no explicit traslation for" << name << "using fallback"; - } - QCheckBox *checkBox = new QCheckBox( name ); - - if( field == Meta::valLabel ) // special case, we want plural: - { - QHBoxLayout *lineLayout = new QHBoxLayout(); - QLabel *button = new QLabel(); - button->setObjectName( "configureLabelExceptions" ); - connect( button, SIGNAL(linkActivated(QString)), - SLOT(slotConfigureExcludedLabels()) ); - - lineLayout->addWidget( checkBox ); - lineLayout->addWidget( button ); - lineLayout->addItem( new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum ) ); - m_statSyncingFieldsLayout->addLayout( lineLayout ); - - slotUpdateConfigureExcludedLabelsLabel(); - } - else - { - m_statSyncingFieldsLayout->addWidget( checkBox ); - } - checkBox->setCheckState( ( field & checkedFields ) ? Qt::Checked : Qt::Unchecked ); - checkBox->setProperty( "field", field ); - connect( checkBox, SIGNAL(stateChanged(int)), SIGNAL(changed()) ); - } -} - -MetadataConfig::~MetadataConfig() -{ - if( m_statSyncingConfig ) - m_statSyncingConfig.data()->read(); // reset unsaved changes -} - -bool -MetadataConfig::isDefault() -{ - return false; -} - -bool -MetadataConfig::hasChanged() -{ - // a bit hacky, but updating enabled status here does the trick - m_writeBackStatistics->setEnabled( m_writeBack->isChecked() ); - m_writeBackCover->setEnabled( m_writeBack->isChecked() ); - m_writeBackCoverDimensions->setEnabled( m_writeBackCover->isEnabled() && m_writeBackCover->isChecked() ); - - return - m_writeBack->isChecked() != AmarokConfig::writeBack() || - m_writeBackStatistics->isChecked() != AmarokConfig::writeBackStatistics() || - m_writeBackCover->isChecked() != AmarokConfig::writeBackCover() || - writeBackCoverDimensions() != AmarokConfig::writeBackCoverDimensions() || - m_useCharsetDetector->isChecked() != AmarokConfig::useCharsetDetector() || - ( m_statSyncingConfig.data() ? ( checkedFields() != m_statSyncingConfig.data()->checkedFields() ) : false ) || - ( m_statSyncingConfig.data() ? m_statSyncingConfig.data()->hasChanged() : false ); -} - -void -MetadataConfig::updateSettings() -{ - AmarokConfig::setWriteBack( m_writeBack->isChecked() ); - AmarokConfig::setWriteBackStatistics( m_writeBackStatistics->isChecked() ); - AmarokConfig::setWriteBackCover( m_writeBackCover->isChecked() ); - if( writeBackCoverDimensions() > 0 ) - AmarokConfig::setWriteBackCoverDimensions( writeBackCoverDimensions() ); - AmarokConfig::setUseCharsetDetector( m_useCharsetDetector->isChecked() ); - if( m_statSyncingConfig ) - { - m_statSyncingConfig.data()->setCheckedFields( checkedFields() ); - m_statSyncingConfig.data()->save(); - } -} - -void -MetadataConfig::slotForgetCollections() -{ - if( !m_statSyncingConfig ) - return; - foreach( const QModelIndex &idx, m_statSyncingProvidersView->selectionModel()->selectedIndexes() ) - { - QString id = idx.data( StatSyncing::Config::ProviderIdRole ).toString(); - m_statSyncingConfig.data()->forgetProvider( id ); - } -} - -void -MetadataConfig::slotUpdateForgetButton() -{ - QItemSelectionModel *selectionModel = m_statSyncingProvidersView->selectionModel(); - // note: hasSelection() and selection() gives false positives! - m_forgetTargetsButton->setEnabled( !selectionModel->selectedIndexes().isEmpty() ); -} - -void -MetadataConfig::slotUpdateConfigureExcludedLabelsLabel() -{ - QLabel *label = findChild( "configureLabelExceptions" ); - if( !label || !m_statSyncingConfig ) - { - warning() << __PRETTY_FUNCTION__ << "label or m_statSyncingConfig is null!"; - return; - } - int exceptions = m_statSyncingConfig.data()->excludedLabels().count(); - QString begin = ""; - QString end = ""; - label->setText( i18np( "(%2one exception%3)", "(%2%1 exceptions%3)", exceptions, - begin, end ) ); -} - -void -MetadataConfig::slotConfigureExcludedLabels() -{ - ExcludedLabelsDialog dialog( m_statSyncingConfig.data(), this ); - if( dialog.exec() == QDialog::Accepted ) - { - slotUpdateConfigureExcludedLabelsLabel(); - emit changed(); - } -} - -void -MetadataConfig::slotConfigureProvider() -{ - StatSyncing::Controller *controller = Amarok::Components::statSyncingController(); - if( controller ) - { - QModelIndexList selected = m_statSyncingProvidersView->selectionModel()->selectedIndexes(); - if( selected.size() == 1 ) - { - const QString id = selected.front().data( StatSyncing::Config::ProviderIdRole ).toString(); - - QWidget *dialog = controller->providerConfigDialog( id ); - if( dialog ) - { - dialog->show(); - dialog->activateWindow(); - dialog->raise(); - } - } - } -} - -void -MetadataConfig::slotUpdateProviderConfigureButton() -{ - QModelIndexList selected = m_statSyncingProvidersView->selectionModel()->selectedIndexes(); - StatSyncing::Controller *controller = Amarok::Components::statSyncingController(); - - if( selected.size() != 1 || !controller ) - { - m_configureTargetButton->setEnabled( false ); - } - else - { - const QString id = selected.front().data( StatSyncing::Config::ProviderIdRole ).toString(); - m_configureTargetButton->setEnabled( controller->providerIsConfigurable( id ) ); - } -} - -void -MetadataConfig::slotCreateProviderDialog() -{ - StatSyncing::Controller *controller = Amarok::Components::statSyncingController(); - if( controller ) - { - QWidget *dialog = controller->providerCreationDialog(); - if( dialog ) - { - dialog->show(); - dialog->activateWindow(); - dialog->raise(); - } - } -} - -int -MetadataConfig::writeBackCoverDimensions() const -{ - return m_writeBackCoverDimensions->itemData( m_writeBackCoverDimensions->currentIndex() ).toInt(); -} - -qint64 -MetadataConfig::checkedFields() const -{ - qint64 ret = 0; - foreach( QCheckBox *checkBox, m_statSyncingFieldsLayout->parentWidget()->findChildren() ) - { - if( checkBox->isChecked() && checkBox->property( "field" ).canConvert() ) - ret |= checkBox->property( "field" ).value(); - } - return ret; -} diff --git a/amarok/src/configdialog/dialogs/MetadataConfig.h b/amarok/src/configdialog/dialogs/MetadataConfig.h deleted file mode 100644 index 05c90ee0..00000000 --- a/amarok/src/configdialog/dialogs/MetadataConfig.h +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef METADATACONFIG_H -#define METADATACONFIG_H - -#include "ui_MetadataConfig.h" -#include "configdialog/ConfigDialogBase.h" - -namespace StatSyncing { - class Config; -} - -class MetadataConfig : public ConfigDialogBase, private Ui_MetadataConfig -{ - Q_OBJECT - - public: - MetadataConfig( QWidget *parent ); - virtual ~MetadataConfig(); - - virtual bool isDefault(); - virtual bool hasChanged(); - virtual void updateSettings(); - - signals: - void changed(); - - private slots: - void slotForgetCollections(); - void slotUpdateForgetButton(); - void slotUpdateConfigureExcludedLabelsLabel(); - void slotConfigureExcludedLabels(); - void slotConfigureProvider(); - void slotUpdateProviderConfigureButton(); - void slotCreateProviderDialog(); - - private: - int writeBackCoverDimensions() const; - qint64 checkedFields() const; - - QWeakPointer m_statSyncingConfig; - -}; - -#endif // METADATACONFIG_H diff --git a/amarok/src/configdialog/dialogs/MetadataConfig.ui b/amarok/src/configdialog/dialogs/MetadataConfig.ui deleted file mode 100644 index 8bdf6cfb..00000000 --- a/amarok/src/configdialog/dialogs/MetadataConfig.ui +++ /dev/null @@ -1,191 +0,0 @@ - - - MetadataConfig - - - - 0 - 0 - 602 - 542 - - - - - - - File Tags - - - - - - Write meta data changes (including 'stars' rating) back to the original file. -You can also prevent writing back by write protecting the file. -This might be a good idea if you are currently -sharing those files via the Internet. - - - Write metadata to file - - - - - - - Write play-changing statistics (e.g. score, lastplayed, playcount) -as tags back to the file. - - - Write statistics to file - - - - - - - - - Write changed covers back to the file. -This will replace existing embedded covers. - - - Write covers to file, maximum size: - - - - - - - Scale covers down if necessary. - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - If selected, Amarok will use Mozilla's -Character Set Detector to attempt to automatically guess the -character sets used in ID3 tags. - - - &Enable character set detection in ID3 tags - - - - - - - - - - Statistics Synchronization - - - - - - <b>Check collections to keep them synchronized.</b> This includes scrobbling of tracks played on iPods if you have Last.fm plugin configured - - - true - - - - - - - QAbstractItemView::ExtendedSelection - - - - 32 - 32 - - - - - - - - - - Forget - - - - - - - - - - Configure… - - - - - - - Add… - - - - - - - - - - Synchronize… - - - - - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - KComboBox - QComboBox -
kcombobox.h
-
-
- - -
diff --git a/amarok/src/configdialog/dialogs/NotificationsConfig.cpp b/amarok/src/configdialog/dialogs/NotificationsConfig.cpp deleted file mode 100644 index 4fc70934..00000000 --- a/amarok/src/configdialog/dialogs/NotificationsConfig.cpp +++ /dev/null @@ -1,186 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2004-2007 Mark Kretschmann * - * Copyright (c) 2004 Frederik Holljen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "NotificationsConfig.h" - -#include "amarokconfig.h" -#include "core/support/Debug.h" -#include "KNotificationBackend.h" - -#include - -#include - -NotificationsConfig::NotificationsConfig( QWidget* parent ) - : ConfigDialogBase( parent ) - , m_oldAlignment( static_cast( AmarokConfig::osdAlignment() ) ) - , m_oldYOffset( AmarokConfig::osdYOffset() ) -{ - setupUi( this ); - - connect( this, SIGNAL(changed()), parent, SLOT(updateButtons()) ); - - m_osdPreview = new OSDPreviewWidget( this ); //must be child!!! - m_osdPreview->setAlignment( static_cast( AmarokConfig::osdAlignment() ) ); - m_osdPreview->setYOffset( AmarokConfig::osdYOffset() ); - m_osdPreview->setFontScale( AmarokConfig::osdFontScaling() ); - m_osdPreview->setTranslucent( AmarokConfig::osdUseTranslucency() ); - - #ifdef Q_WS_MAC - QCheckBox* growl = new QCheckBox( i18n( "Use Growl for notifications" ), this ); - growl->setChecked( AmarokConfig::growlEnabled() ); - gridLayout_5->addWidget( growl, 2, 0, 1, 1 ); - connect( growl, SIGNAL(toggled(bool)), - this, SLOT(setGrowlEnabled(bool)) ); - #endif - - // Enable/disable the translucency option depending on availablity of desktop compositing - kcfg_OsdUseTranslucency->setEnabled( KWindowSystem::compositingActive() ); - - connect( m_osdPreview, SIGNAL(positionChanged()), SLOT(slotPositionChanged()) ); - - const int screenCount = QApplication::desktop()->screenCount(); - for( int i = 0; i < screenCount; i++ ) - kcfg_OsdScreen->addItem( QString::number( i ) ); - - connect( kcfg_OsdTextColor, SIGNAL(changed(QColor)), - m_osdPreview, SLOT(setTextColor(QColor)) ); - connect( kcfg_OsdUseCustomColors, SIGNAL(toggled(bool)), - this, SLOT(useCustomColorsToggled(bool)) ); - connect( kcfg_OsdScreen, SIGNAL(activated(int)), - m_osdPreview, SLOT(setScreen(int)) ); - connect( kcfg_OsdEnabled, SIGNAL(toggled(bool)), - m_osdPreview, SLOT(setVisible(bool)) ); - connect( kcfg_OsdUseTranslucency, SIGNAL(toggled(bool)), - m_osdPreview, SLOT(setTranslucent(bool)) ); - connect( kcfg_OsdFontScaling, SIGNAL(valueChanged(int)), - m_osdPreview, SLOT(setFontScale(int)) ); - - /* - Amarok::QStringx text = i18n( - "

Tags Displayed in OSD

" - "You can use the following tokens:" - "
    " - "
  • Title - %1" - "
  • Album - %2" - "
  • Artist - %3" - "
  • Genre - %4" - "
  • Bitrate - %5" - "
  • Year - %6" - "
  • Track Length - %7" - "
  • Track Number - %8" - "
  • Filename - %9" - "
  • Directory - %10" - "
  • Type - %11" - "
  • Comment - %12" - "
  • Score - %13" - "
  • Playcount - %14" - "
  • Disc Number - %15" - "
  • Rating - %16" - "
  • Elapsed Time - %17" - "
" - "If you surround sections of text that contain a token with curly-braces, that section will be hidden if the token is empty, for example:" - "
%18
" - "Will not show Score: %score if the track has no score." ); - */ -} - -NotificationsConfig::~NotificationsConfig() -{} - - -/////////////////////////////////////////////////////////////// -// REIMPLEMENTED METHODS from ConfigDialogBase -/////////////////////////////////////////////////////////////// - -bool -NotificationsConfig::hasChanged() -{ - DEBUG_BLOCK - - return ( m_osdPreview->alignment() != m_oldAlignment ) || ( m_osdPreview->yOffset() != m_oldYOffset ); -} - -bool -NotificationsConfig::isDefault() -{ - return false; -} - -void -NotificationsConfig::updateSettings() -{ - DEBUG_BLOCK - - AmarokConfig::setOsdAlignment( m_osdPreview->alignment() ); - AmarokConfig::setOsdYOffset( m_osdPreview->yOffset() ); - AmarokConfig::setOsdUseTranslucency( kcfg_OsdUseTranslucency->isChecked() ); - - Amarok::OSD::instance()->setEnabled( kcfg_OsdEnabled->isChecked() ); - - Amarok::KNotificationBackend::instance()->setEnabled( kcfg_KNotifyEnabled->isChecked() ); - - emit settingsChanged( QString() ); -} - - -/////////////////////////////////////////////////////////////// -// PRIVATE METHODS -/////////////////////////////////////////////////////////////// - -void -NotificationsConfig::slotPositionChanged() -{ - DEBUG_BLOCK - - kcfg_OsdScreen->blockSignals( true ); - kcfg_OsdScreen->setCurrentIndex( m_osdPreview->screen() ); - kcfg_OsdScreen->blockSignals( false ); - - // Update button states (e.g. "Apply") - emit changed(); -} - -void -NotificationsConfig::hideEvent( QHideEvent* ) -{ - m_osdPreview->hide(); -} - -void -NotificationsConfig::showEvent( QShowEvent* ) -{ - useCustomColorsToggled( kcfg_OsdUseCustomColors->isChecked() ); - - m_osdPreview->setScreen( kcfg_OsdScreen->currentIndex() ); - m_osdPreview->setVisible( kcfg_OsdEnabled->isChecked() ); -} - -void -NotificationsConfig::setGrowlEnabled( bool enable ) -{ - DEBUG_BLOCK - AmarokConfig::setGrowlEnabled( enable ); -} - -void -NotificationsConfig::useCustomColorsToggled( bool on ) -{ - m_osdPreview->setUseCustomColors( on, kcfg_OsdTextColor->color() ); -} - -#include "moc_NotificationsConfig.cpp" diff --git a/amarok/src/configdialog/dialogs/NotificationsConfig.h b/amarok/src/configdialog/dialogs/NotificationsConfig.h deleted file mode 100644 index 31548162..00000000 --- a/amarok/src/configdialog/dialogs/NotificationsConfig.h +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2004-2007 Mark Kretschmann * - * Copyright (c) 2004 Frederik Holljen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef NOTIFICATIONSCONFIG_H -#define NOTIFICATIONSCONFIG_H - -#include "ui_NotificationsConfig.h" -#include "configdialog/ConfigDialogBase.h" -#include "widgets/Osd.h" - -class OSDPreviewWidget; - -class NotificationsConfig : public ConfigDialogBase, public Ui_NotificationsConfig -{ - Q_OBJECT - - public: - NotificationsConfig( QWidget* parent ); - virtual ~NotificationsConfig(); - - virtual bool hasChanged(); - virtual bool isDefault(); - virtual void updateSettings(); - - signals: - void changed(); - - private slots: - void slotPositionChanged(); - void useCustomColorsToggled( bool ); - void setGrowlEnabled( bool ); - - private: - OSDPreviewWidget* m_osdPreview; - - OSDWidget::Alignment m_oldAlignment; - uint m_oldYOffset; - - void hideEvent( QHideEvent* ); - void showEvent( QShowEvent* ); -}; - -#endif diff --git a/amarok/src/configdialog/dialogs/NotificationsConfig.ui b/amarok/src/configdialog/dialogs/NotificationsConfig.ui deleted file mode 100644 index fc80596a..00000000 --- a/amarok/src/configdialog/dialogs/NotificationsConfig.ui +++ /dev/null @@ -1,318 +0,0 @@ - - - NotificationsConfig - - - - 0 - 0 - 596 - 424 - - - - - - - General - - - - - - Check to enable the On-Screen-Display. The OSD briefly displays track data when a new track is played. - - - Check to enable the On-Screen-Display. The OSD briefly displays track data when a new track is played. - - - Use &On-Screen-Display - - - true - - - true - - - - - - - - &Duration: - - - false - - - kcfg_OsdDuration - - - - - - - - 2 - 0 - - - - The time in milliseconds for which to show the OSD. The value must be between 500 ms and 10000 ms. - - - The time in milliseconds for which to show the OSD. The value must be between 500 ms and 10000 ms. - - - QAbstractSpinBox::UpDownArrows - - - Forever - - - ms - - - 0 - - - 600000 - - - 1000 - - - 5000 - - - - - - - Sc&reen: - - - false - - - kcfg_OsdScreen - - - - - - - - 2 - 0 - - - - The screen that should display the OSD. - - - The screen that should display the OSD. - - - - - - - - - true - - - - 0 - 0 - - - - Check to enable custom colors for the On-Screen-Display. - - - Check to enable custom colors for the On-Screen-Display. - - - Use &custom colors - - - true - - - true - - - - - - - 1 - 0 - - - - - 59 - 0 - - - - The color of the OSD text. - - - Text color: - - - false - - - - - - - - 2 - 0 - - - - - 72 - 0 - - - - Click to select the color of the OSD text. - - - The color of the OSD text. - - - - - - - 255 - 0 - 0 - - - - - - - - - - - If checked, enables translucency if supported by your desktop system. - - - &Translucent - - - - - - - 0 - - - - - Font scale: - - - - - - - % - - - 1000 - - - 115 - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - Do not show the On-Screen-Display if another application is focused and running in fullscreen mode. - - - Don't show when a fullscreen application is active - - - - - - - - - - Check to use the system notification. - - - Use &system notifications - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - KComboBox - QComboBox -
kcombobox.h
-
- - KColorButton - QPushButton -
kcolorbutton.h
-
-
- - widgets/Osd.h - ktextedit.h - knuminput.h - - - -
diff --git a/amarok/src/configdialog/dialogs/PlaybackConfig.cpp b/amarok/src/configdialog/dialogs/PlaybackConfig.cpp deleted file mode 100644 index 01fef14f..00000000 --- a/amarok/src/configdialog/dialogs/PlaybackConfig.cpp +++ /dev/null @@ -1,109 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2004-2009 Mark Kretschmann * - * Copyright (c) 2009 Artur Szymiec * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "PlaybackConfig.h" - -#include "amarokconfig.h" -#include "core/support/Amarok.h" -#include "ActionClasses.h" -#include "EngineController.h" -#include "core/support/Debug.h" - -#include -#include - - -PlaybackConfig::PlaybackConfig( QWidget* parent ) - : ConfigDialogBase( parent ) -{ - setupUi( this ); - - EngineController *engine = EngineController::instance(); - Q_ASSERT( engine ); - if( !engine->supportsFadeout() ) - { - const QString toolTip = i18n( "Current Phonon backend does not support volume fading" ); - kcfg_FadeoutOnStop->setEnabled( false ); - kcfg_FadeoutOnStop->setToolTip( toolTip ); - kcfg_FadeoutOnPause->setEnabled( false ); - kcfg_FadeoutOnPause->setToolTip( toolTip ); - fadeoutLengthLabel->setEnabled( false ); - fadeoutLengthLabel->setToolTip( toolTip ); - kcfg_FadeoutLength->setEnabled( false ); - kcfg_FadeoutLength->setToolTip( toolTip ); - } - - connect( findChild( "pushButtonPhonon" ), SIGNAL(clicked()), SLOT(configurePhonon()) ); - connect( kcfg_FadeoutOnStop, SIGNAL(toggled(bool)), SLOT(setFadeoutState()) ); - connect( kcfg_FadeoutOnPause, SIGNAL(toggled(bool)), SLOT(setFadeoutState()) ); -} - -PlaybackConfig::~PlaybackConfig() -{} - - -/////////////////////////////////////////////////////////////// -// REIMPLEMENTED METHODS from ConfigDialogBase -/////////////////////////////////////////////////////////////// - -bool -PlaybackConfig::hasChanged() -{ - return false; -} - -bool -PlaybackConfig::isDefault() -{ - return false; -} - -void -PlaybackConfig::updateSettings() -{} - - -/////////////////////////////////////////////////////////////// -// PRIVATE METHODS -/////////////////////////////////////////////////////////////// - -void -PlaybackConfig::configurePhonon() //SLOT -{ - DEBUG_BLOCK - - KCMultiDialog KCM; - - KCM.setWindowTitle( i18n( "Sound System - Amarok" ) ); - KCM.addModule( "kcm_phonon" ); - KCM.exec(); -} - -void -PlaybackConfig::setFadeoutState() //SLOT -{ - if( !EngineController::instance()->supportsFadeout() ) - return; - - const bool enabled = kcfg_FadeoutOnPause->isChecked() || kcfg_FadeoutOnStop->isChecked(); - - fadeoutLengthLabel->setEnabled( enabled ); - kcfg_FadeoutLength->setEnabled( enabled ); -} - - -#include "moc_PlaybackConfig.cpp" diff --git a/amarok/src/configdialog/dialogs/PlaybackConfig.h b/amarok/src/configdialog/dialogs/PlaybackConfig.h deleted file mode 100644 index 61c75768..00000000 --- a/amarok/src/configdialog/dialogs/PlaybackConfig.h +++ /dev/null @@ -1,41 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2004-2009 Mark Kretschmann * - * Copyright (c) 2009 Artur Szymiec * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef PLAYBACKCONFIG_H -#define PLAYBACKCONFIG_H - -#include "ui_PlaybackConfig.h" -#include "configdialog/ConfigDialogBase.h" - -class PlaybackConfig : public ConfigDialogBase, public Ui_PlaybackConfig -{ - Q_OBJECT - - public: - PlaybackConfig( QWidget* parent ); - virtual ~PlaybackConfig(); - - virtual bool hasChanged(); - virtual bool isDefault(); - virtual void updateSettings(); - - private Q_SLOTS: - void configurePhonon(); - void setFadeoutState(); -}; - -#endif diff --git a/amarok/src/configdialog/dialogs/PlaybackConfig.ui b/amarok/src/configdialog/dialogs/PlaybackConfig.ui deleted file mode 100644 index fb0b95ad..00000000 --- a/amarok/src/configdialog/dialogs/PlaybackConfig.ui +++ /dev/null @@ -1,267 +0,0 @@ - - - PlaybackConfig - - - - 0 - 0 - 404 - 412 - - - - - - - General - - - - - - If checked, Amarok will<br>resume playback from where you left it the previous session -- just like a tape-player. - - - If checked, Amarok will<br>resume playback from where you left it the previous session -- just like a tape-player. - - - &Resume playback on start - - - - - - - <html>Enable this option to start playing whenever a track or more are added to the playlist using mouse, pressing Enter or when the playlist is replaced. Does nothing if something is already playing.</html> - - - <html>Enable this option to start playing whenever a track or more are added to the playlist using mouse, pressing Enter or when the playlist is replaced. Does nothing if something is already playing.</html> - - - Start playing when tracks are added to playlist - - - - - - - - - - Volume Fading - - - - - - Fadeout on stop - - - - - - - Fadeout on pause - - - - - - - - - Qt::Horizontal - - - QSizePolicy::Minimum - - - - 30 - 20 - - - - - - - - - - true - - - &Duration: - - - kcfg_FadeoutLength - - - - - - - true - - - The length of the fadeout, in milliseconds. - - - The length of the fadeout, in milliseconds. - - - ms - - - 100 - - - 99999999 - - - 100 - - - 100 - - - - - - - Qt::Horizontal - - - - 13 - 20 - - - - - - - - - - - - - - - System Suspend Options - - - - - - If enabled, Amarok will prevent the system from automatically suspending if it is playing a track - - - If enabled, Amarok will prevent the system from automatically suspending if it is playing a track - - - &Inhibit automatic suspend if playing - - - - - - - If enabled, Amarok will pause the currently playing track on suspend - - - If enabled, Amarok will pause the currently playing track on suspend - - - &Pause playback on suspend - - - - - - - - - - Sound System Configuration - - - - - - - - - - Qt::Horizontal - - - - 165 - 20 - - - - - - - - - 0 - 0 - - - - Phonon is the audio system used by Amarok. - - - Phonon is the audio system used by Amarok. - - - Configure Phonon - - - - - - - Qt::Horizontal - - - - 165 - 20 - - - - - - - - - - - - - - - Qt::Vertical - - - - 20 - 1 - - - - - - - - kcfg_FadeoutLength - - - - diff --git a/amarok/src/configdialog/dialogs/PluginsConfig.cpp b/amarok/src/configdialog/dialogs/PluginsConfig.cpp deleted file mode 100644 index a7ffb97b..00000000 --- a/amarok/src/configdialog/dialogs/PluginsConfig.cpp +++ /dev/null @@ -1,89 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "PluginsConfig" - -#include "PluginsConfig.h" - -#include "core/support/Debug.h" -#include "services/ServiceBase.h" -#include "PluginManager.h" - -#include -#include - -#include - -PluginsConfig::PluginsConfig( QWidget *parent ) - : ConfigDialogBase( parent ) - , m_configChanged( false ) -{ - DEBUG_BLOCK - m_selector = new KPluginSelector( this ); - m_selector->setSizePolicy( QSizePolicy:: Expanding, QSizePolicy::Expanding ); - - QVBoxLayout *layout = new QVBoxLayout( this ); - layout->setMargin( 0 ); - layout->addWidget( m_selector ); - - m_selector->addPlugins( The::pluginManager()->plugins( Plugins::PluginManager::Collection ), - KPluginSelector::ReadConfigFile, i18n("Collections"), "Collection" ); - - m_selector->addPlugins( The::pluginManager()->plugins( Plugins::PluginManager::Service ), - KPluginSelector::ReadConfigFile, i18n("Internet Services"), "Service" ); - - m_selector->addPlugins( The::pluginManager()->plugins( Plugins::PluginManager::Importer ), - KPluginSelector::ReadConfigFile, i18n("Statistics importers"), "Importer" ); - - connect( m_selector, SIGNAL(changed(bool)), SLOT(slotConfigChanged(bool)) ); - connect( m_selector, SIGNAL(changed(bool)), parent, SLOT(updateButtons()) ); -} - -PluginsConfig::~PluginsConfig() -{} - -void PluginsConfig::updateSettings() -{ - DEBUG_BLOCK - if( m_configChanged ) - { - debug() << "config changed"; - m_selector->save(); - - // check if any services were disabled and needs to be removed, or any - // that are hidden needs to be enabled - The::pluginManager()->checkPluginEnabledStates(); - } -} - -bool PluginsConfig::hasChanged() -{ - return m_configChanged; -} - -bool PluginsConfig::isDefault() -{ - return false; -} - -void PluginsConfig::slotConfigChanged( bool changed ) -{ - m_configChanged = changed; - if( changed ) - debug() << "config changed"; -} - -#include "moc_PluginsConfig.cpp" diff --git a/amarok/src/configdialog/dialogs/PluginsConfig.h b/amarok/src/configdialog/dialogs/PluginsConfig.h deleted file mode 100644 index eb7161ad..00000000 --- a/amarok/src/configdialog/dialogs/PluginsConfig.h +++ /dev/null @@ -1,47 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_PLUGINSCONFIG_H -#define AMAROK_PLUGINSCONFIG_H - -#include "configdialog/ConfigDialogBase.h" - -class KPluginSelector; - -/** - * A widget that allows configuration of plugins - */ -class PluginsConfig : public ConfigDialogBase -{ - Q_OBJECT - -public: - PluginsConfig( QWidget *parent ); - virtual ~PluginsConfig(); - - virtual void updateSettings(); - virtual bool hasChanged(); - virtual bool isDefault(); - -public slots: - void slotConfigChanged( bool changed ); - -private: - bool m_configChanged; - KPluginSelector *m_selector; -}; - -#endif // AMAROK_PLUGINSCONFIG_H diff --git a/amarok/src/configdialog/dialogs/ScriptSelector.cpp b/amarok/src/configdialog/dialogs/ScriptSelector.cpp deleted file mode 100644 index 6aeb2ba3..00000000 --- a/amarok/src/configdialog/dialogs/ScriptSelector.cpp +++ /dev/null @@ -1,120 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Peter ZHOU * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "ScriptSelector.h" - -#include "core/support/Debug.h" - -#include -#include -#include -#include -#include -#include - -// uber-hacky, this whole thing, make our own script selector? -ScriptSelector::ScriptSelector( QWidget * parent ) - : KPluginSelector( parent ) - , m_scriptCount( 0 ) -{ - m_lineEdit = this->findChild(); - if( m_lineEdit ) - { - m_lineEdit->setClickMessage( i18n( "Search Scripts" ) ); - connect( m_lineEdit, SIGNAL(textChanged(QString)), SLOT(slotFiltered(QString)) ); - } - - m_listView = this->findChild(); -} - -ScriptSelector::~ScriptSelector() -{} - -void -ScriptSelector::setVerticalPosition( int position ) -{ - m_listView->verticalScrollBar()->setSliderPosition( position ); -} - -int -ScriptSelector::verticalPosition() -{ - return m_listView->verticalScrollBar()->sliderPosition(); -} - -QString -ScriptSelector::filter() -{ - return m_lineEdit->text(); -} - -void -ScriptSelector::setFilter( const QString &filter ) -{ - m_lineEdit->setText( filter ); -} - -void -ScriptSelector::addScripts( QList pluginInfoList, - PluginLoadMethod pluginLoadMethod, - const QString &categoryName, - const QString &categoryKey, - const KSharedConfig::Ptr &config ) -{ - DEBUG_BLOCK - - qSort( pluginInfoList.begin(), pluginInfoList.end() - , []( const KPluginInfo &left, const KPluginInfo &right ){ return left.name() < right.name(); } ); - addPlugins( pluginInfoList, pluginLoadMethod, categoryName, categoryKey, config ); - foreach( const KPluginInfo &plugin, pluginInfoList ) - { - m_scriptCount++; - m_scripts[m_scriptCount] = plugin.pluginName(); - } -} - -QString -ScriptSelector::currentItem() const -{ - DEBUG_BLOCK - - QItemSelectionModel *selModel = m_listView->selectionModel(); - const QModelIndexList selIndexes = selModel->selectedIndexes(); - - if( !selIndexes.isEmpty() ) - { - QModelIndex currentIndex = selIndexes[0]; - if( currentIndex.isValid() ) - { - debug() << "row: " << currentIndex.row() + 1; //the index start from 1 - debug() << "name: "<< m_scripts[currentIndex.row() + 1]; - return m_scripts[currentIndex.row() + 1]; - } - } - - return QString(); -} - -void -ScriptSelector::slotFiltered( const QString &filter ) -{ - if( filter.isEmpty() ) - emit filtered( false ); - else - emit filtered( true ); -} - -#include "moc_ScriptSelector.cpp" diff --git a/amarok/src/configdialog/dialogs/ScriptSelector.h b/amarok/src/configdialog/dialogs/ScriptSelector.h deleted file mode 100644 index 886b7f6d..00000000 --- a/amarok/src/configdialog/dialogs/ScriptSelector.h +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Peter ZHOU * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef SCRIPTSELECTOR_H -#define SCRIPTSELECTOR_H - -#include -#include - -class KCategorizedView; -class KLineEdit; -class KPluginInfo; -class QScrollBar; - -class ScriptSelector : public KPluginSelector -{ - Q_OBJECT - - public: - ScriptSelector( QWidget * parent ); - ~ScriptSelector(); - - QString currentItem() const; - void addScripts( QList pluginInfoList, - PluginLoadMethod pluginLoadMethod = ReadConfigFile, - const QString &categoryName = QString(), - const QString &categoryKey = QString(), - const KSharedConfig::Ptr &config = KSharedConfig::Ptr() ); - int verticalPosition(); - void setVerticalPosition( int position ); - QString filter(); - void setFilter( const QString &filter ); - - private: - KCategorizedView *m_listView; - QMap m_scripts; - int m_scriptCount; - KLineEdit *m_lineEdit; - - private slots: - void slotFiltered( const QString &filter ); - - signals: - void filtered(bool); -}; - -#endif diff --git a/amarok/src/configdialog/dialogs/ScriptsConfig.cpp b/amarok/src/configdialog/dialogs/ScriptsConfig.cpp deleted file mode 100644 index 7a1328f1..00000000 --- a/amarok/src/configdialog/dialogs/ScriptsConfig.cpp +++ /dev/null @@ -1,285 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Rick W. Chen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "ScriptsConfig" - -#include "ScriptsConfig.h" - -#include "amarokconfig.h" -#include "core/support/Amarok.h" -#include "core/support/Debug.h" -#include "scripting/scriptmanager/ScriptManager.h" -#include "ScriptSelector.h" -#include "ui_ScriptsConfig.h" - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -ScriptsConfig::ScriptsConfig( QWidget *parent ) - : ConfigDialogBase( parent ) - , m_configChanged( false ) - , m_parent( parent ) - , m_oldSelector( 0 ) -{ - DEBUG_BLOCK - Ui::ScriptsConfig gui; - gui.setupUi( this ); - - m_uninstallButton = gui.uninstallButton; - m_timer = new QTimer(this); - connect( m_timer, SIGNAL(timeout()), this, SLOT(slotUpdateScripts()) ); - m_timer->setInterval( 200 ); - - // Load config - gui.kcfg_AutoUpdateScripts->setChecked( AmarokConfig::autoUpdateScripts() ); - connect( gui.installButton, SIGNAL(clicked(bool)), SLOT(installLocalScript()) ); - - m_selector = gui.scriptSelector; - m_verticalLayout = gui.verticalLayout; - slotReloadScriptSelector(); - - connect( gui.reloadButton, SIGNAL(clicked(bool)), m_timer, SLOT(start()) ); - connect( gui.uninstallButton, SIGNAL(clicked(bool)), this, SLOT(slotUninstallScript()) ); - - connect( ScriptManager::instance(), SIGNAL(scriptsChanged()), SLOT(slotReloadScriptSelector()) ); - - this->setEnabled( AmarokConfig::enableScripts() ); -} - -ScriptsConfig::~ScriptsConfig() -{} - -void -ScriptsConfig::updateSettings() -{ - DEBUG_BLOCK - if( m_configChanged ) - { - m_selector->save(); - ScriptManager::instance()->configChanged( true ); - } -} - -bool -ScriptsConfig::hasChanged() -{ - return m_configChanged; -} - -bool -ScriptsConfig::isDefault() -{ - return false; -} - -void -ScriptsConfig::slotConfigChanged( bool changed ) -{ - m_configChanged = changed; - if( changed ) - debug() << "config changed"; -} - -void -ScriptsConfig::installLocalScript() -{ - DEBUG_BLOCK - // where's this config stored anyway, use amarokconfig instead? - // the script can actually be updated if you get the folder name right - int response = KMessageBox::warningContinueCancel( this, i18n( "Manually installed scripts " - "cannot be automatically updated, continue?" ), QString(), KStandardGuiItem::cont() - , KStandardGuiItem::cancel(), "manualScriptInstallWarning" ); - if( response == KMessageBox::Cancel ) - return; - - QString filePath = KFileDialog::getOpenFileName( KUrl(), QString(), this, i18n( "Select Archived Script" ) ); - if( filePath.isEmpty() ) - return; - - QString fileName = QFileInfo( filePath ).fileName(); - KMimeType::Ptr mimeType = KMimeType::findByPath( filePath ); - QScopedPointer archive; - if( mimeType->is( "application/zip" ) ) - archive.reset( new KZip( filePath ) ); - else - archive.reset( new KTar( filePath ) ); - - if( !archive || !archive->open( QIODevice::ReadOnly ) ) - { - KMessageBox::error( this, i18n( "Invalid Archive" ) ); - return; - } - - QString destination = KGlobal::dirs()->saveLocation( "data", QString("amarok/scripts/") + fileName + "/" , false ); - const KArchiveDirectory* const archiveDir = archive->directory(); - const QDir dir( destination ); - const KArchiveFile *specFile = findSpecFile( archiveDir ); - if( !specFile ) - { - KMessageBox::error( this, i18n( "Invalid Script File" ) ); - return; - } - - QTemporaryFile tempFile; - tempFile.open(); - QIODevice *device = specFile->createDevice(); - tempFile.write( device->readAll() ); - delete device; - tempFile.close(); - - KPluginInfo newScriptInfo( tempFile.fileName() ); - if( !newScriptInfo.isValid() ) - { - KMessageBox::error( this, i18n( "Invalid Script File" ) ); - return; - } - - if( ScriptManager::instance()->m_scripts.contains( newScriptInfo.pluginName() ) ) - { - QString existingVersion = ScriptManager::instance()->m_scripts[ newScriptInfo.pluginName() ]->info().version(); - QString message = i18n( "Another script with the name %1 already exists\nExisting Script's " - "Version: %1\nSelected Script's Version: %2", newScriptInfo.version() - , existingVersion, newScriptInfo.version() ); - KMessageBox::error( this, message ); - return; - } - - for( int i = 1; dir.exists( destination ); ++i ) - destination += i; - dir.mkpath( destination ); - archiveDir->copyTo( destination ); - KMessageBox::information( this, i18n( "The script %1 was successfully installed", newScriptInfo.name() ) ); - m_timer->start(); -} - -void -ScriptsConfig::slotReloadScriptSelector() -{ - DEBUG_BLOCK - m_oldSelector = m_selector; - m_selector = new ScriptSelector( this ); - QString key = QLatin1String( "Generic" ); - m_selector->addScripts( ScriptManager::instance()->scripts( key ), - KPluginSelector::ReadConfigFile, i18n("Generic"), key ); - - key = QLatin1String( "Lyrics" ); - m_selector->addScripts( ScriptManager::instance()->scripts( key ), - KPluginSelector::ReadConfigFile, i18n("Lyrics"), key ); - - key = QLatin1String( "Scriptable Service" ); - m_selector->addScripts( ScriptManager::instance()->scripts( key ), - KPluginSelector::ReadConfigFile, i18n("Scriptable Service"), key ); - connect( m_selector, SIGNAL(changed(bool)), SLOT(slotConfigChanged(bool)) ); - connect( m_selector, SIGNAL(changed(bool)), m_parent, SLOT(updateButtons()) ); - connect( m_selector, SIGNAL(filtered(bool)), m_uninstallButton, SLOT(setDisabled(bool)) ); - m_verticalLayout->insertWidget( 0, m_selector ); - m_verticalLayout->removeWidget( m_oldSelector ); - m_selector->setFilter( m_oldSelector->filter() ); - QTimer::singleShot( 0, this, SLOT(restoreScrollBar()) ); -} - -void -ScriptsConfig::restoreScrollBar() -{ - if( !m_oldSelector ) - return; - m_selector->setVerticalPosition( m_oldSelector->verticalPosition() ); - m_oldSelector->deleteLater(); -} - -void -ScriptsConfig::slotUpdateScripts() -{ - m_timer->stop(); - ScriptManager::instance()->updateAllScripts(); -} - -void -ScriptsConfig::slotUninstallScript() -{ - DEBUG_BLOCK - if( !ScriptManager::instance()->m_scripts.contains( m_selector->currentItem() ) ) - return; - - ScriptItem *item = ScriptManager::instance()->m_scripts.value( m_selector->currentItem() ); - int response = KMessageBox::warningContinueCancel( this, i18n( "You are advised to only uninstall manually " - "installed scripts using this button." ) ); - if( response == KMessageBox::Cancel ) - return; - - QRegExp regex( "(.*apps/amarok/scripts/.+/).*script.spec" ); - regex.indexIn( item->info().entryPath() ); - qDebug() << "About to remove folder " << regex.cap( 1 ); - removeDir( regex.cap( 1 ) ); - m_timer->start(); -} - -const KArchiveFile* -ScriptsConfig::findSpecFile( const KArchiveDirectory *dir ) const -{ - foreach( const QString &entry, dir->entries() ) - { - if( dir->entry( entry )->isFile() ) - { - if( entry == "script.spec" ) - return static_cast( dir->entry( entry ) ); - } - else - { - if( entry != "." && entry != ".." ) - { - const KArchiveDirectory *subDir = static_cast( dir->entry( entry ) ); - if( subDir ) - { - const KArchiveFile *file = findSpecFile( subDir ); - if( !file ) - continue; - return file; - } - } - } - } - return 0; -} - -void -ScriptsConfig::removeDir( const QString &dirPath ) const -{ - QDir dir( dirPath ); - if( dir.exists( dirPath ) ) - { - foreach( const QFileInfo &info, dir.entryInfoList( QDir::NoDotAndDotDot | QDir::System | QDir::Hidden | QDir::AllDirs | QDir::Files ) ) - { - if( info.isDir() ) - removeDir( info.absoluteFilePath() ); - else - QFile::remove( info.absoluteFilePath() ); - } - dir.rmdir( dirPath ); - } -} - -#include "moc_ScriptsConfig.cpp" diff --git a/amarok/src/configdialog/dialogs/ScriptsConfig.h b/amarok/src/configdialog/dialogs/ScriptsConfig.h deleted file mode 100644 index c1e545ed..00000000 --- a/amarok/src/configdialog/dialogs/ScriptsConfig.h +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Rick W. Chen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_SCRIPTSCONFIG_H -#define AMAROK_SCRIPTSCONFIG_H - -#include "configdialog/ConfigDialogBase.h" - -#include - -class KArchiveDirectory; -class KArchiveFile; -class ScriptSelector; -class QPushButton; -class QVBoxLayout; - -/** - * A widget that allows configuration of scripts - */ -class ScriptsConfig : public ConfigDialogBase -{ - Q_OBJECT - -public: - ScriptsConfig( QWidget *parent ); - virtual ~ScriptsConfig(); - - virtual void updateSettings(); - virtual bool hasChanged(); - virtual bool isDefault(); - -public slots: - void slotConfigChanged( bool changed ); - -private slots: - void installLocalScript(); - void slotReloadScriptSelector(); - void slotUpdateScripts(); - void slotUninstallScript(); - void restoreScrollBar(); - -private: - const KArchiveFile *findSpecFile( const KArchiveDirectory *dir ) const; - void removeDir( const QString &dirPath ) const; - - bool m_configChanged; - ScriptSelector *m_selector; - QTimer *m_timer; - QVBoxLayout *m_verticalLayout; - QPushButton *m_uninstallButton; - QObject *m_parent; - ScriptSelector *m_oldSelector; -}; - -#endif // AMAROK_SCRIPTSCONFIG_H diff --git a/amarok/src/configdialog/dialogs/ScriptsConfig.ui b/amarok/src/configdialog/dialogs/ScriptsConfig.ui deleted file mode 100644 index 7bde64b3..00000000 --- a/amarok/src/configdialog/dialogs/ScriptsConfig.ui +++ /dev/null @@ -1,144 +0,0 @@ - - - Peter Zhou and Ian Monroe - ScriptsConfig - - - - 0 - 0 - 590 - 141 - - - - - 0 - 0 - - - - - - - - 0 - 0 - - - - - - - - - - Uninstall Script - - - - - - - Install Local Script - - - - - - - - - - - Automatically download and install updates for the built-in scripts from the Amarok website if available - - - Automatically download and install updates for the built-in scripts from the Amarok website if available - - - Automatically update built-in scripts - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 0 - 0 - - - - Reload - - - - - - - - - - - - - - Script Console - - - - - - true - - - Enable the script console. - - - Enable the script console. - - - Enable Script Console - - - - - - - - - - - - - KPushButton - QPushButton -
kpushbutton.h
-
- - ScriptSelector - QWidget -
configdialog/dialogs/ScriptSelector.h
- 1 -
-
- - kdialog.h - - - -
diff --git a/amarok/src/context/Applet.cpp b/amarok/src/context/Applet.cpp deleted file mode 100644 index 5ba61aed..00000000 --- a/amarok/src/context/Applet.cpp +++ /dev/null @@ -1,374 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007-2009 Leo Franchi * - * Copyright (c) 2009 Riccardo Iaconelli * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "Context::Applet" - -#include "Applet.h" - -#include "amarokconfig.h" -#include "Containment.h" -#include "PaletteHandler.h" -#include "context/ContextView.h" -#include "core/support/Debug.h" -#include "context/widgets/AppletHeader.h" - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -namespace Context -{ - -} // Context namespace - -Context::Applet::Applet( QObject * parent, const QVariantList& args ) - : Plasma::Applet( parent, args ) - , m_canAnimate( !KServiceTypeTrader::self()->query("Plasma/Animator", QString()).isEmpty() ) - , m_heightCollapseOff( 0 ) - , m_header( 0 ) - , m_transient( 0 ) - , m_standardPadding( 6.0 ) -{ - setBackgroundHints( NoBackground ); -} - -Context::Applet::~Applet() -{ -} - -QFont -Context::Applet::shrinkTextSizeToFit( const QString& text, const QRectF& bounds ) -{ - Q_UNUSED( text ); - - int size = 13; // start here, shrink if needed - QFont font( QString(), size, QFont::Light ); - font.setStyleHint( QFont::SansSerif ); - font.setStyleStrategy( QFont::PreferAntialias ); - - QFontMetrics fm( font ); - while( fm.height() > bounds.height() + 4 ) - { - if( size < 0 ) - { - size = 5; - break; - } - size--; - fm = QFontMetrics( QFont( QString(), size ) ); - } - - // for aesthetics, we make it one smaller - size--; - - QFont returnFont( QString(), size, QFont::Light ); - font.setStyleHint( QFont::SansSerif ); - font.setStyleStrategy( QFont::PreferAntialias ); - - return QFont( returnFont ); -} - -QString -Context::Applet::truncateTextToFit( const QString &text, const QFont& font, const QRectF& bounds ) -{ - QFontMetrics fm( font ); - return fm.elidedText ( text, Qt::ElideRight, (int)bounds.width() ); -} - -void -Context::Applet::paintInterface( QPainter *p, - const QStyleOptionGraphicsItem *option, - const QRect &contentsRect ) -{ - Plasma::Applet::paintInterface( p, option, contentsRect ); - addGradientToAppletBackground( p ); -} - -void -Context::Applet::addGradientToAppletBackground( QPainter* p ) -{ - // tint the whole applet - // draw non-gradient backround. going for elegance and style - const QRectF roundRect = boundingRect().adjusted( 0, 1, -1, -1 ); - - p->save(); - p->setRenderHint( QPainter::Antialiasing ); - QPainterPath path; - path.addRoundedRect( roundRect, 4, 4 ); - QColor highlight = PaletteHandler::highlightColor( 0.4, 1.05 ); - highlight.setAlphaF( highlight.alphaF() * 0.5 ); - p->fillPath( path, highlight ); - p->restore(); - - p->save(); - p->setRenderHint( QPainter::Antialiasing ); - p->translate( 0.5, 0.5 ); - QColor col = PaletteHandler::highlightColor( 0.3, 0.5 ); - col.setAlphaF( col.alphaF() * 0.7 ); - p->setPen( col ); - p->drawRoundedRect( roundRect, 4, 4 ); - p->restore(); -} - -qreal -Context::Applet::standardPadding() -{ - return m_standardPadding; -} - -void -Context::Applet::destroy() -{ - if ( Plasma::Applet::immutability() != Plasma::Mutable || m_transient ) { - return; //don't double delete - } - m_transient = true; - cleanUpAndDelete(); -} - -void -Context::Applet::cleanUpAndDelete() -{ - QGraphicsWidget *parent = dynamic_cast( parentItem() ); - //it probably won't matter, but right now if there are applethandles, *they* are the parent. - //not the containment. - - //is the applet in a containment and is the containment have a layout? if yes, we remove the applet in the layout - if ( parent && parent->layout() ) - { - QGraphicsLayout *l = parent->layout(); - for ( int i = 0; i < l->count(); ++i ) - { - if ( this == l->itemAt( i ) ) - { - l->removeAt( i ); - break; - } - } - } - - if ( Plasma::Applet::configScheme() ) { - Plasma::Applet::configScheme()->setDefaults(); - } - Plasma::Applet::scene()->removeItem( this ); - Plasma::Applet::deleteLater(); -} - -Plasma::IconWidget* -Context::Applet::addAction( QGraphicsItem *parent, QAction *action, const int size ) -{ - if( !action ) - return 0; - - Plasma::IconWidget *tool = new Plasma::IconWidget( parent ); - tool->setAction( action ); - tool->setText( QString() ); - tool->setToolTip( action->text() ); - tool->setDrawBackground( false ); - tool->setOrientation( Qt::Horizontal ); - const QSizeF iconSize = tool->sizeFromIconSize( size ); - tool->setMinimumSize( iconSize ); - tool->setMaximumSize( iconSize ); - tool->resize( iconSize ); - tool->setZValue( zValue() + 1 ); - - return tool; -} - -void -Context::Applet::enableHeader( bool enable ) -{ - if( m_header ) - { - delete m_header; - m_header = 0; - } - - if( enable ) - { - m_header = new AppletHeader( this ); - m_header->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); - } -} - -Plasma::IconWidget * -Context::Applet::addLeftHeaderAction( QAction *action ) -{ - if( !m_header ) - return 0; - - Plasma::IconWidget *icon = addAction( 0, action ); - m_header->addIcon( icon, Qt::AlignLeft ); - return icon; -} - -Plasma::IconWidget * -Context::Applet::addRightHeaderAction( QAction *action ) -{ - if( !m_header ) - return 0; - - Plasma::IconWidget *icon = addAction( 0, action ); - m_header->addIcon( icon, Qt::AlignRight ); - return icon; -} - -QString -Context::Applet::headerText() const -{ - if( !m_header ) - return QString(); - return m_header->titleText(); -} - -void -Context::Applet::setHeaderText( const QString &text ) -{ - if( !m_header ) - return; - m_header->setTitleText( text ); -} - -bool -Context::Applet::isAnimating() const -{ - QSharedPointer anim = m_animation.toStrongRef(); - if( anim ) - return (anim->state() == QAbstractAnimation::Running); - return false; -} - -bool -Context::Applet::isCollapsed() const -{ - return m_heightCollapseOn == preferredHeight(); -} - -void -Context::Applet::setCollapseOn() -{ - collapse( true ); -} - -void -Context::Applet::setCollapseOff() -{ - collapse( false ); -} - -void -Context::Applet::collapse( bool on ) -{ - qreal finalHeight = ( on ) ? m_heightCollapseOn : m_heightCollapseOff; - const qreal maxHeight = containment()->size().height(); - if( (finalHeight > maxHeight) || (finalHeight < 0) ) - finalHeight = maxHeight; - - prepareGeometryChange(); - // warning: view() currently can return pointer to ToolbarView, not the ContextView - ContextView *v = ContextView::self(); // may return null - // Plasma::Applet::view() might return 0, if the widget is not yet constructed, etc. - // \sa https://bugs.kde.org/show_bug.cgi?id=258741. If view is not available - // yet, regardless of the animation setting the preferred size is set - // straight away. - if( !v || !AmarokConfig::animateAppletCollapse() ) - { - setPreferredHeight( finalHeight ); - emit sizeHintChanged( Qt::PreferredSize ); - updateGeometry(); - return; - } - - if( finalHeight == size().height() ) - return; - - // debug() << pluginName() << (on ? "collapsing to" : "uncollapsing to") << finalHeight; - QPropertyAnimation *pan = m_animation.data(); - if( !pan ) - pan = new QPropertyAnimation( this, "preferredSize" ); - if( pan->state() == QAbstractAnimation::Running ) - pan->stop(); - pan->setDuration( 600 ); - pan->setEasingCurve( QEasingCurve::InQuad ); - pan->setStartValue( size() ); - pan->setEndValue( QSizeF(size().width(), finalHeight) ); - connect( pan, SIGNAL(finished()), SLOT(collapseAnimationFinished()) ); - m_animation = pan; - pan->setDirection( QAbstractAnimation::Forward ); - - v->addCollapseAnimation( pan ); -} - -int -Context::Applet::collapseHeight() const -{ - return m_heightCollapseOn; -} - -int -Context::Applet::collapseOffHeight() const -{ - return m_heightCollapseOff; -} - -void -Context::Applet::collapseAnimationFinished() -{ - emit sizeHintChanged( Qt::PreferredSize ); - updateConstraints(); - update(); -} - -void -Context::Applet::setCollapseHeight( int h ) -{ - m_heightCollapseOn = h; -} - -void -Context::Applet::setCollapseOffHeight( int h ) -{ - m_heightCollapseOff = h; -} - -bool Context::Applet::canAnimate() -{ - return m_canAnimate; -} - -void -Context::Applet::showWarning( const QString &message, const char *slot ) -{ - int ret = KMessageBox::warningYesNo( 0, message ); - Plasma::MessageButton button = (ret == KMessageBox::Yes) ? Plasma::ButtonYes : Plasma::ButtonNo; - QByteArray sig = QMetaObject::normalizedSignature( slot ); - sig.remove( 0, 1 ); // remove method type - QMetaMethod me = metaObject()->method( metaObject()->indexOfSlot(sig) ); - QGenericArgument arg1 = Q_ARG( const Plasma::MessageButton, button ); - if( !me.invoke( this, arg1 ) ) - warning() << "invoking failed:" << sig; -} - -#include "moc_Applet.cpp" diff --git a/amarok/src/context/Applet.h b/amarok/src/context/Applet.h deleted file mode 100644 index aab5b48a..00000000 --- a/amarok/src/context/Applet.h +++ /dev/null @@ -1,210 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Leo Franchi * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_APPLET_H -#define AMAROK_APPLET_H - -#include "amarok_export.h" - -#include -#include - -#include -#include -#include -#include - -class QPainter; -class QPropertyAnimation; - -namespace Plasma -{ - class IconWidget; -} - -namespace Context -{ - -class AppletHeader; - -class AMAROK_EXPORT Applet : public Plasma::Applet -{ - Q_OBJECT - Q_PROPERTY( int collapseHeight READ collapseHeight WRITE setCollapseHeight ) - Q_PROPERTY( int collapseOffHeight READ collapseOffHeight WRITE setCollapseOffHeight ) - Q_PROPERTY( QString headerText READ headerText WRITE setHeaderText ) - - public: - explicit Applet( QObject* parent, const QVariantList& args = QVariantList() ); - ~Applet(); - - /** - * Return a QFont that will allow the given text to fit within the rect. - */ - QFont shrinkTextSizeToFit( const QString& text, const QRectF& bounds ); - - /** - * Truncate the text by adding an ellipsis at the end in order to make the text with the given font - * rit in the bounding rect. - */ - QString truncateTextToFit( const QString &text, const QFont& font, const QRectF& bounds ); - - void paintInterface( QPainter *p, const QStyleOptionGraphicsItem *option, const QRect &contentsRect ); - - /** - * Returns a standard CV-wide padding that applets can use for consistency. - */ - qreal standardPadding(); - - /** - * Creates a header for showing title text and icon widgets, if enabled. - */ - void enableHeader( bool enable = true ); - - /** - * Adds an action on the left of the header text. A header needs to be - * created by enableHeader() first. - * @param action Action to add - * @return An icon widget created for the action - */ - Plasma::IconWidget *addLeftHeaderAction( QAction *action ); - - /** - * Adds an action on the right of the header text. A header needs to be - * created by enableHeader() first. - * @param action Action to add - * @return An icon widget created for the action - */ - Plasma::IconWidget *addRightHeaderAction( QAction *action ); - - /** - * Returns the current header text. If no header exists this will return - * an empty string. - */ - QString headerText() const; - - /** - * Sets the text shown in the header. If no header exists this method - * does nothing. - */ - void setHeaderText( const QString &text ); - - /** - * Set the preferred applet height when collapsed. - * The actual height when collapsed will be constrained by the applet's - * minimum and maximum heights, as well as the current available height - * from the containment. - */ - void setCollapseHeight( int ); - - /** - * Set the preferred applet height when uncollapsed. - * The actual height when collapsed will be constrained by the applet's - * minimum and maximum heights, as well as the current available height - * from the containment. Depending on the vertical size policy, the - * other applets currently showing, and the aforementioned constraints, - * the actual height when collapse is off may be different. This is so - * that, for example, the applet may take up the rest of the space when - * the size policy is set to Expanding. Setting this height to -1 will - * tell the layout to give the applet the rest of the available space. - */ - void setCollapseOffHeight( int ); - - /** - * Preferred applet height when collapsed. - */ - int collapseHeight() const; - - /** - * Preferred applet height when uncollapsed. - */ - int collapseOffHeight() const; - - /** - * Whether a collapse animation is currently running. - */ - bool isAnimating() const; - - /** - * Whether the applet is currently collapsed to collapseHeight(). - */ - bool isCollapsed() const; - - /** - * Shows a warning dialog which blocks access to the applet. - * This gives the user the message and a "Yes" and a "No" button. - * NOTE: Only one message/warning can be shown at a time. - * - * @param message The warning message. - * @param slot The slot which is called after either "Yes" or "No" has been clicked. - */ - void showWarning( const QString &message, const char *slot ); - - public Q_SLOTS: - virtual void destroy(); - - /** - * Collapse to collapseHeight(). - */ - void setCollapseOn(); - - /** - * Collapse to collapseOffHeight(). - */ - void setCollapseOff(); - - protected: - /** - * Paint the background of an applet, so it fits with all the other applets. - * Background is *no longer a gradient*. However, please use this to - * stay consistent with other applets. - */ - void addGradientToAppletBackground( QPainter* p ); - - Plasma::IconWidget* addAction( QGraphicsItem *parent, QAction *action, const int size = 16 ); - bool canAnimate(); - - bool m_canAnimate; - int m_heightCurrent; - int m_heightCollapseOn; - int m_heightCollapseOff; - - AppletHeader *m_header; - - - private slots: - void collapseAnimationFinished(); - void collapse( bool on ); - - private: - void cleanUpAndDelete(); - - bool m_transient; - qreal m_standardPadding; - QWeakPointer m_animation; -}; - -} // Context namespace - -/** - * Register an applet when it is contained in a loadable module - */ -#define AMAROK_EXPORT_APPLET(libname, classname) \ -K_PLUGIN_FACTORY(factory, registerPlugin();) \ -K_EXPORT_PLUGIN(factory("amarok_context_applet_" #libname))\ -K_EXPORT_PLUGIN_VERSION(PLASMA_VERSION) - -#endif // multiple inclusion guard diff --git a/amarok/src/context/CMakeLists.txt b/amarok/src/context/CMakeLists.txt deleted file mode 100644 index 27d01eb4..00000000 --- a/amarok/src/context/CMakeLists.txt +++ /dev/null @@ -1,36 +0,0 @@ -add_subdirectory( applets ) -add_subdirectory( engines ) -add_subdirectory( containments ) -add_subdirectory( tools ) - -include_directories( ${CMAKE_CURRENT_SOURCE_DIR} - .. - ${CMAKE_CURRENT_BINARY_DIR}/..) - -########### next target ############### - -set(amarokpud_LIB_SRCS - popupdropper/libpud/PopupDropper.cpp - popupdropper/libpud/PopupDropperItem.cpp - popupdropper/libpud/PopupDropperView.cpp -) - -QT4_AUTOMOC( - popupdropper/libpud/PopupDropper.cpp - popupdropper/libpud/PopupDropperItem.cpp - popupdropper/libpud/PopupDropperView.cpp -) - -ADD_LIBRARY(amarokpud SHARED ${amarokpud_LIB_SRCS}) - -SET_TARGET_PROPERTIES( amarokpud PROPERTIES DEFINE_SYMBOL MAKE_POPUPDROPPER_LIB ) - -target_link_libraries(amarokpud - ${QT_QTCORE_LIBRARY} - ${QT_QTGUI_LIBRARY} - ${QT_QTSVG_LIBRARY} -) - -set_target_properties(amarokpud PROPERTIES VERSION 1.0.0 SOVERSION 1) -install(TARGETS amarokpud ${INSTALL_TARGETS_DEFAULT_ARGS} ) - diff --git a/amarok/src/context/Containment.cpp b/amarok/src/context/Containment.cpp deleted file mode 100644 index 969944d5..00000000 --- a/amarok/src/context/Containment.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Leo Franchi * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "Containment.h" - -#include "core/support/Debug.h" - -#include - - -namespace Context -{ - -Containment::Containment( QGraphicsItem* parent, const QString& serviceId, uint containmentId ) - : Plasma::Containment( parent, serviceId, containmentId ) -{} - -Containment::Containment( QObject* parent, const QVariantList& args ) - : Plasma::Containment( parent, args ) -{} - -Containment::~Containment() -{ - DEBUG_BLOCK -} - - -} // namespace Context -#include "moc_Containment.cpp" - diff --git a/amarok/src/context/Containment.h b/amarok/src/context/Containment.h deleted file mode 100644 index cf920dce..00000000 --- a/amarok/src/context/Containment.h +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Leo Franchi * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_CONTAINMENT_H -#define AMAROK_CONTAINMENT_H - -#include "amarok_export.h" - -#include - -#include -#include - -namespace Context -{ - -class ContextView; - -class AMAROK_EXPORT Containment : public Plasma::Containment -{ - Q_OBJECT -public: - explicit Containment(QGraphicsItem* parent = 0, - const QString& serviceId = QString(), - uint containmentId = 0); - - Containment(QObject* parent, const QVariantList& args); - - ~Containment(); - - virtual void saveToConfig( KConfigGroup &conf ) = 0; - virtual void loadConfig( const KConfigGroup &conf ) = 0; - - virtual void setView( ContextView *newView ) = 0; - - virtual ContextView *view() = 0; - -public slots: - void showApplet( Plasma::Applet* ) {} - void moveApplet( Plasma::Applet*, int, int ) {} - virtual void addApplet( const QString& pluginName, const int ) = 0; -}; - -} // Context namespace -#endif diff --git a/amarok/src/context/Context.h b/amarok/src/context/Context.h deleted file mode 100644 index 9a6f0653..00000000 --- a/amarok/src/context/Context.h +++ /dev/null @@ -1,35 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Leo Franchi * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef CONTEXT_H -#define CONTEXT_H - -#include - -/** - * add the ContextState (which we need) - */ -namespace Context -{ - -enum ContextState { Home = 0 /**< Currently showing the home screen */, - Current, /**< Showing Current Track screen. NB: a Current message is sent every time the track changes */ - Service /**< User is browsing a service */ -}; - -} // Context namespace - -#endif // multiple inclusion guard diff --git a/amarok/src/context/ContextDock.cpp b/amarok/src/context/ContextDock.cpp deleted file mode 100644 index 884196f3..00000000 --- a/amarok/src/context/ContextDock.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "ContextDock" - -#include "ContextDock.h" - -#include "amarokconfig.h" -#include "context/ContextScene.h" -#include "context/ContextView.h" -#include "context/ToolbarView.h" -#include "core/support/Debug.h" - -#include - -ContextDock::ContextDock( QWidget *parent ) - : AmarokDockWidget( i18n( "&Context" ), parent ) -{ - setObjectName( "Context dock" ); - setAllowedAreas( Qt::AllDockWidgetAreas ); - setMinimumWidth( 50 ); - setContentsMargins( 0, 0, 0, 0 ); - - m_mainWidget = new KVBox( this ); - m_mainWidget->setMinimumWidth( 400 ); - m_mainWidget->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); - m_mainWidget->setSpacing( 0 ); - m_mainWidget->setContentsMargins( 0, 0, 0, 0 ); - m_mainWidget->setFrameShape( QFrame::NoFrame ); - setWidget( m_mainWidget ); - - m_corona = new Context::ContextScene( this ); - connect( m_corona.data(), SIGNAL(containmentAdded(Plasma::Containment*)), - this, SLOT(createContextView(Plasma::Containment*)) ); - - m_corona.data()->loadDefaultSetup(); // this method adds our containment to the scene -} - -void ContextDock::polish() -{ -} - -void -ContextDock::createContextView( Plasma::Containment *containment ) -{ - disconnect( m_corona.data(), SIGNAL(containmentAdded(Plasma::Containment*)), - this, SLOT(createContextView(Plasma::Containment*)) ); - - debug() << "Creating context view on containmend" << containment->name(); - PERF_LOG( "Creating ContexView" ) - m_contextView = new Context::ContextView( containment, m_corona.data(), m_mainWidget ); - m_contextView.data()->setFrameShape( QFrame::NoFrame ); - m_contextToolbarView = new Context::ToolbarView( containment, m_corona.data(), m_mainWidget ); - PERF_LOG( "Created ContexToolbarView" ) - - connect( m_corona.data(), SIGNAL(sceneRectChanged(QRectF)), m_contextView.data(), SLOT(updateSceneRect(QRectF)) ); - connect( m_contextToolbarView.data(), SIGNAL(hideAppletExplorer()), m_contextView.data(), SLOT(hideAppletExplorer()) ); - connect( m_contextToolbarView.data(), SIGNAL(showAppletExplorer()), m_contextView.data(), SLOT(showAppletExplorer()) ); - m_contextView.data()->showHome(); - PERF_LOG( "ContexView created" ) -} - - -#include "moc_ContextDock.cpp" diff --git a/amarok/src/context/ContextDock.h b/amarok/src/context/ContextDock.h deleted file mode 100644 index 18e731af..00000000 --- a/amarok/src/context/ContextDock.h +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef CONTEXTDOCK_H -#define CONTEXTDOCK_H - -#include "widgets/AmarokDockWidget.h" - -#include - -class KVBox; -class QResizeEvent; - -namespace Context { - class ContextScene; - class ContextView; - class ToolbarView; -} - -namespace Plasma { class Containment; } - -class ContextDock : public AmarokDockWidget -{ - Q_OBJECT - -public: - ContextDock( QWidget *parent ); - - void polish(); - -protected slots: - void createContextView( Plasma::Containment *containment ); - -private: - KVBox * m_mainWidget; - - QWeakPointer m_corona; - QWeakPointer m_contextView; - QWeakPointer m_contextToolbarView; -}; - -#endif // CONTEXTDOCK_H diff --git a/amarok/src/context/ContextObserver.cpp b/amarok/src/context/ContextObserver.cpp deleted file mode 100644 index a2f717b6..00000000 --- a/amarok/src/context/ContextObserver.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Leo Franchi * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "ContextObserver.h" - -#include "core/support/Debug.h" - -////////////////////////////////////////////////////////////// -////// CLASS ContextObserver -////////////////////////////////////////////////////////////// - -ContextObserver::ContextObserver() - : m_subject( 0 ) -{} - -ContextObserver::ContextObserver( ContextSubject *s ) - : m_subject( s ) -{ - m_subject->attach( this ); -} - -ContextObserver::~ContextObserver() -{ - DEBUG_BLOCK - - if( m_subject ) - m_subject->detach( this ); -} - -//////////////////////////////////////////////////////////////// -//// CLASS ContextSubject -/////////////////////////////////////////////////////////////// - -ContextSubject::ContextSubject() -{ - DEBUG_BLOCK -} - -ContextSubject::~ContextSubject() -{ - DEBUG_BLOCK -} - -void ContextSubject::messageNotify( const Context::ContextState& message ) -{ - /*DEBUG_BLOCK - if( message == Context::Home ) - debug() << "notifying with Home"; - else if( message == Context::Current ) - debug() << "notifying with Current"; */ - foreach( ContextObserver* obs, m_observers ) - obs->message( message ); -} - -void ContextSubject::attach( ContextObserver *obs ) -{ - if( !obs ) - return; - - m_observers.insert( obs ); -} - -void ContextSubject::detach( ContextObserver *obs ) -{ - DEBUG_BLOCK - - if( obs ) - m_observers.remove( obs ); -} - diff --git a/amarok/src/context/ContextObserver.h b/amarok/src/context/ContextObserver.h deleted file mode 100644 index e5afcc71..00000000 --- a/amarok/src/context/ContextObserver.h +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Leo Franchi * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef CONTEXT_OBSERVER_H -#define CONTEXT_OBSERVER_H - -#include "amarok_export.h" -#include "Context.h" - -#include - - -class ContextSubject; - -class AMAROK_EXPORT ContextObserver -{ -public: - virtual void message( const Context::ContextState& ) {} - -protected: - ContextObserver(); - ContextObserver( ContextSubject* ); - virtual ~ContextObserver(); - -private: - ContextSubject *m_subject; -}; - -class ContextSubject -{ -public: - void attach( ContextObserver *observer ); - void detach( ContextObserver *observer ); - -protected: - ContextSubject(); - virtual ~ContextSubject(); - - void messageNotify( const Context::ContextState& message ); - -private: - QSet m_observers; -}; - -#endif diff --git a/amarok/src/context/ContextScene.cpp b/amarok/src/context/ContextScene.cpp deleted file mode 100644 index 84891c7c..00000000 --- a/amarok/src/context/ContextScene.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Leo Franchi * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "ContextScene" - -#include "ContextScene.h" - -#include "core/support/Amarok.h" -#include "amarokconfig.h" -#include "core/support/Debug.h" - -#include -#include -#include - -#include - - -namespace Context -{ - -ContextScene::ContextScene( QObject * parent ) - : Plasma::Corona( parent ) -{ - DEBUG_BLOCK - setBackgroundBrush( Qt::NoBrush ); -} - -ContextScene::~ContextScene() -{ - DEBUG_BLOCK -} - -void ContextScene::loadDefaultSetup() -{ - Plasma::Containment* c = addContainment( "amarok_containment_vertical" ); - c->setScreen( -1 ); - c->setFormFactor( Plasma::Planar ); -} - -} // Context namespace - -#include "moc_ContextScene.cpp" - diff --git a/amarok/src/context/ContextScene.h b/amarok/src/context/ContextScene.h deleted file mode 100644 index d1346dcf..00000000 --- a/amarok/src/context/ContextScene.h +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Leo Franchi * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_CONTEXT_SCENE_H -#define AMAROK_CONTEXT_SCENE_H - -#include "amarok_export.h" -#include "Applet.h" -#include "Context.h" - -#include - -#include - -namespace Context -{ - -/** - * The ContextScene is a very simple QGraphicsScene, it does the same thing as a Plasma::Corona. - * The only bit that is important is that it controls what the default containtainment to be loaded should be. - */ -class AMAROK_EXPORT ContextScene : public Plasma::Corona -{ - Q_OBJECT -public: - explicit ContextScene(QObject * parent = 0); - ~ContextScene(); - - void loadDefaultSetup(); - -signals: - void appletRemoved( QObject *object ); - -}; - -} // Context namespace - -#endif diff --git a/amarok/src/context/ContextView.cpp b/amarok/src/context/ContextView.cpp deleted file mode 100644 index 7bb575b5..00000000 --- a/amarok/src/context/ContextView.cpp +++ /dev/null @@ -1,396 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007-2008 Leo Franchi * - * Copyright (c) 2008 William Viana Soares * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "ContextView" - -/* - Significant parts of this code is inspired and/or copied from KDE plasma sources, - available at kdebase/workspace/plasma -*/ - -#include "ContextView.h" - -#include - -#include "Context.h" -#include "ContextScene.h" -#include "Svg.h" -#include "Theme.h" -#include "amarokconfig.h" -#include "amarokurls/AmarokUrlHandler.h" -#include "amarokurls/ContextUrlRunner.h" -#include "core/support/Amarok.h" -#include "core/support/Debug.h" -#include "core/meta/Meta.h" -#include "EngineController.h" - -#include - -#include -#include -#include -#include - -namespace Context -{ - -ContextView* ContextView::s_self = 0; - - -ContextView::ContextView( Plasma::Containment *cont, Plasma::Corona *corona, QWidget* parent ) - : Plasma::View( cont, parent ) - , m_curState( Home ) - , m_urlRunner(0) - , m_appletExplorer(0) - , m_collapseAnimations(0) - , m_queuedAnimations(0) - , m_collapseGroupTimer(0) -{ - Q_UNUSED( corona ) - DEBUG_BLOCK - - // using QGraphicsScene::BspTreeIndex leads to crashes in some Qt versions - scene()->setItemIndexMethod( QGraphicsScene::NoIndex ); - //TODO: Figure out a way to use rubberband and ScrollHandDrag - //setDragMode( QGraphicsView::RubberBandDrag ); - setTransformationAnchor( QGraphicsView::NoAnchor ); - setCacheMode( QGraphicsView::CacheBackground ); - setInteractive( true ); - setAcceptDrops( true ); - setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); - // setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); - - //make background transparent - QPalette p = palette(); - QColor c = p.color( QPalette::Base ); - c.setAlpha( 0 ); - p.setColor( QPalette::Base, c ); - setPalette( p ); - - contextScene()->setAppletMimeType( "text/x-amarokappletservicename" ); - - cont->setPos( 0, 0 ); - cont->updateConstraints(); - Containment* amarokContainment = qobject_cast( cont ); - if( amarokContainment ) - amarokContainment->setView( this ); - - m_urlRunner = new ContextUrlRunner(); - The::amarokUrlHandler()->registerRunner( m_urlRunner, "context" ); - - m_queuedAnimations = new QSequentialAnimationGroup( this ); - m_collapseAnimations = new QParallelAnimationGroup( this ); - connect( m_collapseAnimations, SIGNAL(finished()), - this, SLOT(slotCollapseAnimationsFinished()) ); - - m_collapseGroupTimer = new QTimer( this ); - m_collapseGroupTimer->setSingleShot( true ); - connect( m_collapseGroupTimer, SIGNAL(timeout()), SLOT(slotStartCollapseAnimations()) ); - - EngineController* const engine = The::engineController(); - - connect( engine, SIGNAL(trackChanged(Meta::TrackPtr)), - this, SLOT(slotTrackChanged(Meta::TrackPtr)) ); - connect( engine, SIGNAL(trackMetadataChanged(Meta::TrackPtr)), - this, SLOT(slotMetadataChanged(Meta::TrackPtr)) ); - - // keep this assignment at bottom so that premature usage of ::self() asserts out - s_self = this; -} - -ContextView::~ContextView() -{ - DEBUG_BLOCK - - // Unload and destroy all Amarok plasma-engines - const QStringList engines = Plasma::DataEngineManager::self()->listAllEngines( "Amarok" ); - - // Assert added for tracing crash on exit, see BUG 187384 - Q_ASSERT_X( !engines.isEmpty(), "Listing loaded Plasma engines", "List is empty (no engines loaded!?)" ); - - foreach( const QString &engine, engines ) - { - debug() << "Unloading plasma engine: " << engine; - - // PlasmaDataEngineManager uses refcounting for the engines, so we need to unload until the refcount reaches 0 - while( Plasma::DataEngineManager::self()->engine( engine )->isValid() ) - Plasma::DataEngineManager::self()->unloadEngine( engine ); - } - - clear( m_curState ); - //this should be done to prevent a crash on exit - clearFocus(); - - delete m_urlRunner; -} - - -void -ContextView::clear( const ContextState& state ) -{ - Q_UNUSED( state ) - DEBUG_BLOCK - - const QString name = "amarok_homerc"; - // now we save the state, remembering the column info etc - KConfig appletConfig( name ); - // erase previous config - foreach( const QString& group, appletConfig.groupList() ) - appletConfig.deleteGroup( group ); - - const int numContainments = contextScene()->containments().size(); - for( int i = 0; i < numContainments; i++ ) - { - DEBUG_LINE_INFO - Containment* containment = qobject_cast< Containment* >( contextScene()->containments()[i] ); - KConfigGroup cg( &appletConfig, QString( "Containment %1" ).arg( i ) ); - if( containment ) - containment->saveToConfig( cg ); - } - contextScene()->clearContainments(); -} - -void ContextView::clearNoSave() -{ - contextScene()->clearContainments(); -} - - -void ContextView::slotTrackChanged( Meta::TrackPtr track ) -{ - if( track ) - messageNotify( Current ); - else - messageNotify( Home ); -} - - -void -ContextView::slotMetadataChanged( Meta::TrackPtr track ) -{ - DEBUG_BLOCK - - // if we are listening to a stream, take the new metadata as a "new track" - if( track && The::engineController()->isStream() ) - messageNotify( Current ); -} - -void ContextView::showHome() -{ - DEBUG_BLOCK - - m_curState = Home; - loadConfig(); - messageNotify( m_curState ); -} - - -// loads applets onto the ContextScene from saved data, using m_curState -void -ContextView::loadConfig() -{ - contextScene()->clearContainments(); - - PERF_LOG( "Start to load config" ); - int numContainments = contextScene()->containments().size(); - KConfig conf( "amarok_homerc", KConfig::FullConfig ); - for( int i = 0; i < numContainments; i++ ) - { - Containment* containment = qobject_cast< Containment* >( contextScene()->containments()[i] ); - if( containment ) - { - KConfigGroup cg( &conf, QString( "Containment %1" ).arg( i ) ); -#ifdef QT_QTOPENGL_FOUND - // Special case: If this is the first time that the user runs an Amarok version - // containing the Analyzer applet, modify the user's config so that the applet - // will become active. We do this for discoverability and prettiness. - // Remove this code in a future Amarok release (possibly 3.0) - const bool firstTimeWithAnalyzer = Amarok::config( "Context View" ).readEntry( "firstTimeWithAnalyzer", true ); - if( firstTimeWithAnalyzer ) - { - QStringList plugins = cg.readEntry( "plugins", QStringList() ); - if( EngineController::instance()->supportsAudioDataOutput() && !plugins.contains( "analyzer" ) ) - { - Amarok::config( "Context View" ).writeEntry( "firstTimeWithAnalyzer", false ); - - // Put the Analyzer applet at position #2, which is most likely below the Currenttrack applet. - if( !plugins.empty() ) - plugins.insert( 1, "analyzer" ); - - cg.writeEntry( "plugins", plugins ); - } - } -#endif - containment->loadConfig( cg ); - } - } - PERF_LOG( "Done loading config" ); -} - -void -ContextView::addCollapseAnimation( QAbstractAnimation *anim ) -{ - if( !anim ) - { - debug() << "failed to add collapsing animation"; - return; - } - - if( m_collapseAnimations->state() == QAbstractAnimation::Running || - m_collapseGroupTimer->isActive() ) - { - m_queuedAnimations->addAnimation( anim ); - } - else - { - m_collapseAnimations->addAnimation( anim ); - m_collapseGroupTimer->start( 0 ); - } -} - -void -ContextView::slotCollapseAnimationsFinished() -{ - m_collapseGroupTimer->stop(); - m_collapseAnimations->clear(); - - while( m_queuedAnimations->animationCount() > 0 ) - { - if( QAbstractAnimation *anim = m_queuedAnimations->takeAnimation(0) ) - m_collapseAnimations->addAnimation( anim ); - } - - if( m_collapseAnimations->animationCount() > 0 ) - m_collapseGroupTimer->start( 0 ); -} - -void -ContextView::slotStartCollapseAnimations() -{ - if( m_collapseAnimations->animationCount() > 0 ) - m_collapseAnimations->start( QAbstractAnimation::KeepWhenStopped ); -} - -void -ContextView::hideAppletExplorer() -{ - if( m_appletExplorer ) - m_appletExplorer->hide(); -} - -void -ContextView::showAppletExplorer() -{ - if( !m_appletExplorer ) - { - Context::Containment *cont = qobject_cast( containment() ); - m_appletExplorer = new AppletExplorer( cont ); - m_appletExplorer->setContainment( cont ); - m_appletExplorer->setZValue( m_appletExplorer->zValue() + 1000 ); - m_appletExplorer->setFlag( QGraphicsItem::ItemIsSelectable ); - - connect( m_appletExplorer, SIGNAL(addAppletToContainment(QString,int)), - cont, SLOT(addApplet(QString,int)) ); - connect( m_appletExplorer, SIGNAL(appletExplorerHid()), SIGNAL(appletExplorerHid()) ); - connect( m_appletExplorer, SIGNAL(geometryChanged()), SLOT(slotPositionAppletExplorer()) ); - - qreal height = m_appletExplorer->effectiveSizeHint( Qt::PreferredSize ).height(); - m_appletExplorer->resize( rect().width() - 2, height ); - m_appletExplorer->setPos( 0, rect().height() - height - 2 ); - } - m_appletExplorer->show(); -} - -void -ContextView::slotPositionAppletExplorer() -{ - if( !m_appletExplorer ) - return; - qreal height = m_appletExplorer->effectiveSizeHint( Qt::PreferredSize ).height(); - m_appletExplorer->setPos( 0, rect().height() - height - 2 ); -} - - -ContextScene* -ContextView::contextScene() -{ - return static_cast( scene() ); -} - -void -ContextView::resizeEvent( QResizeEvent* event ) -{ - Plasma::View::resizeEvent( event ); - if( testAttribute( Qt::WA_PendingResizeEvent ) ) - return; // lets not do this more than necessary, shall we? - - QRectF rect( pos(), maximumViewportSize() ); - containment()->setGeometry( rect ); - scene()->setSceneRect( rect ); - scene()->update( rect ); - - if( m_appletExplorer ) - { - qreal height = m_appletExplorer->effectiveSizeHint( Qt::PreferredSize ).height(); - m_appletExplorer->resize( rect.width() - 2, height ); - m_appletExplorer->setPos( 0, rect.height() - height - 2 ); - } -} - -void -ContextView::wheelEvent( QWheelEvent* event ) -{ - if( event->orientation() != Qt::Horizontal ) - Plasma::View::wheelEvent( event ); -} - -QStringList -ContextView::currentApplets() -{ - DEBUG_BLOCK - QStringList appletNames; - - Applet::List applets = containment()->applets(); - foreach( Plasma::Applet * applet, applets ) - { - appletNames << applet->pluginName(); - } - - debug() << "current applets: " << appletNames; - - return appletNames; -} - -QStringList ContextView::currentAppletNames() -{ - DEBUG_BLOCK - QStringList appletNames; - - Applet::List applets = containment()->applets(); - foreach( Plasma::Applet * applet, applets ) - { - appletNames << applet->name(); - } - - debug() << "current applets: " << appletNames; - - return appletNames; -} - -} // Context namespace - -#include "moc_ContextView.cpp" diff --git a/amarok/src/context/ContextView.h b/amarok/src/context/ContextView.h deleted file mode 100644 index 7a784df9..00000000 --- a/amarok/src/context/ContextView.h +++ /dev/null @@ -1,139 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Leo Franchi * - * Copyright (c) 2008 William Viana Soares * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -/* - Significant parts of this code is inspired and/or copied from KDE Plasma sources, - available at kdebase/workspace/libs/plasma -*/ - -#ifndef AMAROK_CONTEXT_VIEW_H -#define AMAROK_CONTEXT_VIEW_H - -#include "Context.h" -#include "ContextObserver.h" -#include "ContextScene.h" -#include "EngineController.h" -#include "Svg.h" -#include "amarok_export.h" -#include "widgets/ContainmentArrow.h" -#include "widgets/appletexplorer/AppletExplorer.h" - -#include -#include - -#include -#include -#include -#include - -class QPixmap; -class ContextUrlRunner; -class QParallelAnimationGroup; - -namespace Context -{ - -class ContextScene; -class ControlBox; - -class AMAROK_EXPORT ContextView : public Plasma::View, public ContextSubject -{ - Q_OBJECT - -public: - ContextView( Plasma::Containment *containment, Plasma::Corona *corona, QWidget* parent = 0 ); - ~ContextView(); - - /** - * Singleton pattern accessor. May return 0 if the view was not yet constructed. - */ - static ContextView *self() { return s_self; } - - /** - Returns the context scene that this view is attached to. - */ - ContextScene* contextScene(); - - /** - Clears the context scene of all items, but first saves the current state of the scene into the - config file using as a key the string parameter. - */ - void clear( const ContextState& name ); - - void clearNoSave(); - - /** - Shows the home state. Loads applets from config file. - */ - void showHome(); - - /** - Get the plugin names, in order, of the applets currently in the contextView. - */ - QStringList currentApplets(); - - /** - Get the user visible applet names, in order, of the applets currently in the contextView. - */ - QStringList currentAppletNames(); - - /** - Adds a collapse animation - This object will take ownership of the animation. - */ - void addCollapseAnimation( QAbstractAnimation *anim ); - -public slots: - /** - * Convenience methods to show and hide the applet explorer. - */ - void hideAppletExplorer(); - void showAppletExplorer(); - -signals: - void appletExplorerHid(); - -protected: - void resizeEvent(QResizeEvent *event); - void wheelEvent(QWheelEvent *event); - -private slots: - void slotTrackChanged( Meta::TrackPtr track ); - void slotMetadataChanged( Meta::TrackPtr track ); - void slotPositionAppletExplorer(); - void slotStartCollapseAnimations(); - void slotCollapseAnimationsFinished(); - -private: - static ContextView* s_self; - - void loadConfig(); - - // holds what is currently being shown - ContextState m_curState; - - ContextUrlRunner * m_urlRunner; - - AppletExplorer *m_appletExplorer; - QParallelAnimationGroup *m_collapseAnimations; - QAnimationGroup *m_queuedAnimations; - QTimer *m_collapseGroupTimer; -}; - -} // Context namespace - -#endif diff --git a/amarok/src/context/DataEngine.h b/amarok/src/context/DataEngine.h deleted file mode 100644 index 0cdd86f4..00000000 --- a/amarok/src/context/DataEngine.h +++ /dev/null @@ -1,33 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Leo Franchi * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_DATA_ENGINE_H -#define AMAROK_DATA_ENGINE_H - -#include - -namespace Context -{ - typedef Plasma::DataEngine DataEngine; - -} // context namespace - -#define AMAROK_EXPORT_DATAENGINE(libname, classname) \ -K_PLUGIN_FACTORY(factory, registerPlugin();) \ -K_EXPORT_PLUGIN(factory("amarok_data_engine_" #libname))\ -K_EXPORT_PLUGIN_VERSION(PLASMA_VERSION) -#endif - diff --git a/amarok/src/context/DataSource.h b/amarok/src/context/DataSource.h deleted file mode 100644 index a6273ce3..00000000 --- a/amarok/src/context/DataSource.h +++ /dev/null @@ -1,29 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Leo Franchi * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_DATA_SOURCE_H -#define AMAROK_DATA_SOURCE_H - -#include - -namespace Context -{ - typedef Plasma::DataSource DataSource; -}; - -} // context namespace - -#endif diff --git a/amarok/src/context/LyricsManager.cpp b/amarok/src/context/LyricsManager.cpp deleted file mode 100644 index 66f88b0e..00000000 --- a/amarok/src/context/LyricsManager.cpp +++ /dev/null @@ -1,272 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Leo Franchi * - * Copyright (c) 2009 Seb Ruiz * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "LyricsManager" - -#include "LyricsManager.h" - -#include "EngineController.h" -#include "core/meta/Meta.h" -#include "core/support/Debug.h" -#include "core-impl/collections/support/CollectionManager.h" - -#include - -#include -#include -#include - -//////////////////////////////////////////////////////////////// -//// CLASS LyricsObserver -/////////////////////////////////////////////////////////////// - -LyricsObserver::LyricsObserver() - : m_subject( 0 ) -{ - qRegisterMetaType("LyricsData"); -} - -LyricsObserver::LyricsObserver( LyricsSubject *s ) - : m_subject( s ) -{ - m_subject->attach( this ); -} - -LyricsObserver::~LyricsObserver() -{ - if( m_subject ) - m_subject->detach( this ); -} - -//////////////////////////////////////////////////////////////// -//// CLASS LyricsSubject -/////////////////////////////////////////////////////////////// - -void LyricsSubject::sendNewLyrics( const LyricsData &lyrics ) -{ - DEBUG_BLOCK - foreach( LyricsObserver* obs, m_observers ) - { - obs->newLyrics( lyrics ); - } -} - -void LyricsSubject::sendNewSuggestions( const QVariantList &sug ) -{ - DEBUG_BLOCK - foreach( LyricsObserver* obs, m_observers ) - { - obs->newSuggestions( sug ); - } -} - -void LyricsSubject::sendLyricsMessage( const QString &key, const QString &val ) -{ - DEBUG_BLOCK - foreach( LyricsObserver* obs, m_observers ) - { - obs->lyricsMessage( key, val ); - } -} - -void LyricsSubject::attach( LyricsObserver *obs ) -{ - if( !obs || m_observers.indexOf( obs ) != -1 ) - return; - m_observers.append( obs ); -} - -void LyricsSubject::detach( LyricsObserver *obs ) -{ - int index = m_observers.indexOf( obs ); - if( index != -1 ) m_observers.removeAt( index ); -} - -//////////////////////////////////////////////////////////////// -//// CLASS LyricsManager -/////////////////////////////////////////////////////////////// - -LyricsManager* LyricsManager::s_self = 0; - -void -LyricsManager::lyricsResult( const QString& lyricsXML, bool cached ) //SLOT -{ - DEBUG_BLOCK - Q_UNUSED( cached ); - - QXmlStreamReader xml( lyricsXML ); - while( xml.readNextStartElement() ) - { - if( xml.name() == QLatin1String("lyric") ) - { - Meta::TrackPtr currentTrack = The::engineController()->currentTrack(); - if( !currentTrack ) - return; - - QString lyrics( xml.readElementText() ); - if( !isEmpty( lyrics ) ) - { - // overwrite cached lyrics (as either there were no lyircs available previously OR - // the user exlicitly agreed to overwrite the lyrics) - debug() << "setting cached lyrics..."; - currentTrack->setCachedLyrics( lyrics ); // TODO: setLyricsByPath? - } - else if( !isEmpty( currentTrack->cachedLyrics() ) ) - { - // we found nothing, so if we have cached lyrics, use it! - debug() << "using cached lyrics..."; - lyrics = currentTrack->cachedLyrics(); - } - else - { - lyricsError( i18n("Retrieved lyrics is empty") ); - return; - } - - QString artist = currentTrack->artist() ? currentTrack->artist()->name() : QString(); - LyricsData data = { lyrics, currentTrack->name(), artist, KUrl() }; - sendNewLyrics( data ); - return; - } - else if( xml.name() == QLatin1String("suggestions") ) - { - QVariantList suggestions; - while( xml.readNextStartElement() ) - { - if( xml.name() != QLatin1String("suggestion") ) - continue; - - const QXmlStreamAttributes &a = xml.attributes(); - - QString artist = a.value( QLatin1String("artist") ).toString(); - QString title = a.value( QLatin1String("title") ).toString(); - QString url = a.value( QLatin1String("url") ).toString(); - - if( !url.isEmpty() ) - suggestions << ( QStringList() << title << artist << url ); - xml.skipCurrentElement(); - } - - debug() << "got" << suggestions.size() << "suggestions"; - if( suggestions.isEmpty() ) - sendLyricsMessage( "notFound", "notfound" ); - else - sendNewSuggestions( suggestions ); - return; - } - xml.skipCurrentElement(); - } - - if( xml.hasError() ) - { - warning() << "errors occurred during reading lyrics xml result:" << xml.errorString(); - lyricsError( i18n("Lyrics data could not be parsed") ); - } -} - -void -LyricsManager::lyricsResultHtml( const QString& lyricsHTML, bool cached ) -{ - DEBUG_BLOCK - Q_UNUSED( cached ) - - // we don't need to deal with suggestions here, because - // we assume the script has called showLyrics if they could - // be suggestions. this is for HTML display only - - Meta::TrackPtr currentTrack = The::engineController()->currentTrack(); - if( currentTrack && !isEmpty( lyricsHTML ) ) - { - QString artist = currentTrack->artist() ? currentTrack->artist()->name() : QString(); - LyricsData data = { lyricsHTML, currentTrack->name(), artist, KUrl() }; - sendNewLyrics( data ); - - // overwrite cached lyrics (as either there were no lyircs available previously OR - // the user exlicitly agreed to overwrite the lyrics) - currentTrack->setCachedLyrics( lyricsHTML ); - } -} - -void -LyricsManager::lyricsError( const QString &error ) -{ - DEBUG_BLOCK - if( !showCached() ) - { - sendLyricsMessage( "error", error ); - } -} - - -void -LyricsManager::lyricsNotFound( const QString& notfound ) -{ - DEBUG_BLOCK - if( !showCached() ) - sendLyricsMessage( "notfound", notfound ); -} - - -bool LyricsManager::showCached() -{ - DEBUG_BLOCK - //if we have cached lyrics there is absolutely no point in not showing these.. - Meta::TrackPtr currentTrack = The::engineController()->currentTrack(); - if( currentTrack && !isEmpty( currentTrack->cachedLyrics() ) ) - { - // TODO: add some sort of feedback that we could not fetch new ones - // so we are showing a cached result - debug() << "showing cached lyrics!"; - - QString lyrics = currentTrack->cachedLyrics(); - QString artist = currentTrack->artist() ? currentTrack->artist()->name() : QString(); - LyricsData data = { lyrics, currentTrack->name(), artist, KUrl() }; - sendNewLyrics( data ); - return true; - } - return false; -} - -void LyricsManager::setLyricsForTrack( const QString &trackUrl, const QString &lyrics ) const -{ - DEBUG_BLOCK - - Meta::TrackPtr track = CollectionManager::instance()->trackForUrl( KUrl( trackUrl ) ); - - if( track ) - track->setCachedLyrics( lyrics ); - else - debug() << QString("could not find a track for the given URL (%1) - ignoring.").arg( trackUrl ); -} - -bool LyricsManager::isEmpty( const QString &lyrics ) const -{ - QGraphicsTextItem testItem; - - // Set the text of the TextItem. - if( Qt::mightBeRichText( lyrics ) ) - testItem.setHtml( lyrics ); - else - testItem.setPlainText( lyrics ); - - // Get the plaintext content. - // We use toPlainText() to strip all Html formatting, - // so we can test if there's any text given. - QString testText = testItem.toPlainText().trimmed(); - - return testText.isEmpty(); -} diff --git a/amarok/src/context/LyricsManager.h b/amarok/src/context/LyricsManager.h deleted file mode 100644 index 940fb780..00000000 --- a/amarok/src/context/LyricsManager.h +++ /dev/null @@ -1,132 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Leo Franchi * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef LYRICS_MANAGER_H -#define LYRICS_MANAGER_H - -#include "amarok_export.h" - -#include - -#include -#include -#include -#include - -class LyricsSubject; - -struct LyricsData -{ - QString text; - QString title; - QString artist; - KUrl site; - - void clear() - { - text.clear(); - title.clear(); - artist.clear(); - site.clear(); - } -}; - -class AMAROK_EXPORT LyricsObserver -{ - public: - LyricsObserver(); - LyricsObserver( LyricsSubject* ); - virtual ~LyricsObserver(); - - /** - * A lyrics script has returned new lyrics. - */ - virtual void newLyrics( const LyricsData &lyrics ) { Q_UNUSED( lyrics ); } - /** - * A lyrics script has returned a list of suggested URLs for correct lyrics. - */ - virtual void newSuggestions( const QVariantList &suggestions ) { Q_UNUSED( suggestions ); } - /** - * A lyrics script has returned some generic message that they want to be displayed. - */ - virtual void lyricsMessage( const QString& key, const QString &val ) { Q_UNUSED( key ); Q_UNUSED( val ); } - - private: - LyricsSubject *m_subject; -}; - -class LyricsSubject -{ - public: - void attach( LyricsObserver *observer ); - void detach( LyricsObserver *observer ); - - protected: - LyricsSubject() {} - virtual ~LyricsSubject() {} - - void sendNewLyrics( const LyricsData &lyrics ); - void sendNewSuggestions( const QVariantList &suggestions ); - void sendLyricsMessage( const QString &key, const QString &val ); - - private: - QList m_observers; -}; - -class AMAROK_EXPORT LyricsManager : public LyricsSubject -{ - public: - static LyricsManager* self() - { - if( !s_self ) - s_self = new LyricsManager(); - - return s_self; - } - - void lyricsResult( const QString& lyrics, bool cached = false ); - void lyricsResultHtml( const QString& lyrics, bool cached = false ); - void lyricsError( const QString &error ); - void lyricsNotFound( const QString& notfound ); - - /** - * Sets the given lyrics for the track with the given URL. - * - * @param trackUrl The URL of the track. - * @param lyrics The new lyrics. - */ - void setLyricsForTrack( const QString &trackUrl, const QString &lyrics ) const; - - /** - * Tests if the given lyrics are empty. - * - * @param lyrics The lyrics which will be tested. - * - * @return true if the given lyrics are empty, otherwise false. - */ - bool isEmpty( const QString &lyrics ) const; - - private: - LyricsManager() : LyricsSubject() { s_self = this; } - - bool showCached(); - - static LyricsManager* s_self; -}; - -Q_DECLARE_METATYPE( LyricsData ); - -#endif diff --git a/amarok/src/context/Svg.h b/amarok/src/context/Svg.h deleted file mode 100644 index d7017238..00000000 --- a/amarok/src/context/Svg.h +++ /dev/null @@ -1,32 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Leo Franchi * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_SVG_H -#define AMAROK_SVG_H - -#include "amarok_export.h" - -#include - -namespace Context -{ - - typedef Plasma::Svg Svg; - - -} // context namespace - -#endif diff --git a/amarok/src/context/Theme.h b/amarok/src/context/Theme.h deleted file mode 100644 index caa93d01..00000000 --- a/amarok/src/context/Theme.h +++ /dev/null @@ -1,28 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Leo Franchi * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_THEME_H -#define AMAROK_THEME_H - -#include - -namespace Context -{ - typedef Plasma::Theme Theme; - -} // context namespace - -#endif diff --git a/amarok/src/context/ToolbarView.cpp b/amarok/src/context/ToolbarView.cpp deleted file mode 100644 index eaebeb23..00000000 --- a/amarok/src/context/ToolbarView.cpp +++ /dev/null @@ -1,268 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Leo Franchi * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "ToolbarView.h" - -#include "Containment.h" -#include "core/support/Debug.h" -#include "PaletteHandler.h" -#include "toolbar/AppletItemOverlay.h" -#include "toolbar/AppletToolbarAppletItem.h" -#include "toolbar/AppletToolbar.h" - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#define TOOLBAR_X_OFFSET 2000 -#define TOOLBAR_SCENE_PADDING 2 - -Context::ToolbarView::ToolbarView( Plasma::Containment* containment, QGraphicsScene* scene, QWidget* parent ) - : QGraphicsView( scene, parent ) - , m_height( 36 ) - , m_cont( containment ) -{ - setObjectName( "ContextToolbarView" ); - - setFixedHeight( m_height ); - setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Fixed ); - setAutoFillBackground( true ); - setContentsMargins( 0, 0, 0, 0 ); - - setFrameStyle( QFrame::NoFrame ); - applyStyleSheet(); - - connect( The::paletteHandler(), SIGNAL(newPalette(QPalette)), SLOT(applyStyleSheet()) ); - - //Padding required to prevent view scrolling, probably caused by the 1px ridge - setSceneRect( TOOLBAR_X_OFFSET, 0, size().width()-TOOLBAR_SCENE_PADDING, - size().height()-TOOLBAR_SCENE_PADDING ); - - setInteractive( true ); - setAcceptDrops( true ); - setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); - setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); - - // now we create the toolbar - m_toolbar = new AppletToolbar(0); - scene->addItem(m_toolbar.data()); - m_toolbar.data()->setContainment( qobject_cast(containment) ); - m_toolbar.data()->setZValue( m_toolbar.data()->zValue() + 1000 ); - m_toolbar.data()->setPos( TOOLBAR_X_OFFSET, 0 ); - - connect( m_toolbar.data(), SIGNAL(configModeToggled()), SLOT(toggleConfigMode()) ); - connect( m_toolbar.data(), SIGNAL(hideAppletExplorer()), SIGNAL(hideAppletExplorer()) ); - connect( m_toolbar.data(), SIGNAL(showAppletExplorer()), SIGNAL(showAppletExplorer()) ); - - Context::Containment* cont = dynamic_cast< Context::Containment* >( containment ); - if( cont ) - { - connect( cont, SIGNAL(appletAdded(Plasma::Applet*,int)), m_toolbar.data(), SLOT(appletAdded(Plasma::Applet*,int)) ); - connect( m_toolbar.data(), SIGNAL(appletAddedToToolbar(Plasma::Applet*,int)), this, SLOT(appletAdded(Plasma::Applet*,int)) ); - connect( cont, SIGNAL(appletRemoved(Plasma::Applet*)), this, SLOT(appletRemoved(Plasma::Applet*)) ); - connect( m_toolbar.data(), SIGNAL(showApplet(Plasma::Applet*)), cont, SLOT(showApplet(Plasma::Applet*)) ); - connect( m_toolbar.data(), SIGNAL(moveApplet(Plasma::Applet*,int,int)), cont, SLOT(moveApplet(Plasma::Applet*,int,int)) ); - } - -} - -Context::ToolbarView::~ToolbarView() -{ - delete m_toolbar.data(); -} - -void -Context::ToolbarView::resizeEvent( QResizeEvent *event ) -{ - Q_UNUSED( event ) - - setSceneRect( TOOLBAR_X_OFFSET, 0, size().width()-TOOLBAR_SCENE_PADDING, - size().height()-TOOLBAR_SCENE_PADDING ); - - if( m_toolbar ) - m_toolbar.data()->setGeometry( sceneRect() ); -} - -void -Context::ToolbarView::dragEnterEvent( QDragEnterEvent *event ) -{ - Q_UNUSED( event ) -} - -void -Context::ToolbarView::dragMoveEvent( QDragMoveEvent *event ) -{ - Q_UNUSED( event ) -} - -void -Context::ToolbarView::dragLeaveEvent( QDragLeaveEvent *event ) -{ - Q_UNUSED( event ) -} - -void -Context::ToolbarView::applyStyleSheet() // SLOT -{ - DEBUG_BLOCK - - const QPalette palette = QApplication::palette(); - - setStyleSheet( QString( "QFrame#ContextToolbarView { border: 1px ridge %1; " \ - "background-color: %2; color: %3; border-radius: 3px; }" \ - "QLabel { color: %3; }" ) - .arg( palette.color( QPalette::Active, QPalette::Window ).name() ) - .arg( The::paletteHandler()->highlightColor().name() ) - .arg( palette.color( QPalette::Active, QPalette::HighlightedText ).name() ) - ); -} - -void -Context::ToolbarView::toggleConfigMode() -{ - DEBUG_BLOCK - if( m_toolbar.data()->configEnabled() ) // set up config stuff - { - debug() << "got config enabled, creating all the move overlays"; - // now add the overlays that handle the drag-n-dropping - QColor overlayColor( Plasma::Theme::defaultTheme()->color( Plasma::Theme::BackgroundColor ) ); - QBrush overlayBrush( overlayColor ); - QPalette p( palette() ); - p.setBrush( QPalette::Window, overlayBrush ); - /* for( int i = 0; i < m_toolbar->appletLayout()->count(); i++ ) - { - debug() << "item" << i << "has geometry:" << m_toolbar->appletLayout()->itemAt( i )->geometry(); - Context::AppletToolbarAddItem* item = dynamic_cast< Context::AppletToolbarAddItem* >( m_toolbar->appletLayout()->itemAt( i ) ); - if( item ) - debug() << "add item has boundingRect:" << item->boundingRect() << "and geom:" << item->geometry() << "and sizehint" << item->effectiveSizeHint( Qt::PreferredSize ); - } */ - - for( int i = 0; i < m_toolbar.data()->appletLayout()->count(); i++ ) - { - debug() << "creating a move overlay"; - Context::AppletToolbarAppletItem* item = dynamic_cast< Context::AppletToolbarAppletItem* >( m_toolbar.data()->appletLayout()->itemAt( i ) ); - if( item ) - { - Context::AppletItemOverlay *moveOverlay = new Context::AppletItemOverlay( item, m_toolbar.data()->appletLayout(), this ); - connect( moveOverlay, SIGNAL(moveApplet(Plasma::Applet*,int,int)), m_cont, SLOT(moveApplet(Plasma::Applet*,int,int)) ); - connect( moveOverlay, SIGNAL(moveApplet(Plasma::Applet*,int,int)), this, SLOT(refreshOverlays()) ); - connect( moveOverlay, SIGNAL(deleteApplet(Plasma::Applet*)), this, SLOT(appletRemoved(Plasma::Applet*)) ); - moveOverlay->setPalette( p ); - moveOverlay->show(); - moveOverlay->raise(); - m_moveOverlays << moveOverlay; - debug() << moveOverlay << moveOverlay->geometry(); - } - - } - } else - { - debug() << "removing all the move overlays"; - foreach( Context::AppletItemOverlay *moveOverlay, m_moveOverlays ) - moveOverlay->deleteLater(); - m_moveOverlays.clear(); - } - -} - -void -Context::ToolbarView::appletRemoved( Plasma::Applet* applet ) -{ - DEBUG_BLOCK - foreach( Context::AppletItemOverlay* overlay, m_moveOverlays ) - { - if( overlay->applet()->applet() == applet ) - { - m_moveOverlays.removeAll( overlay ); - debug() << "got an overlay to remove"; - } - } - m_toolbar.data()->appletRemoved( applet ); - applet->deleteLater(); -} - -void -Context::ToolbarView::appletAdded( Plasma::Applet* applet, int loc ) -{ - DEBUG_BLOCK - Q_UNUSED( applet ) - Q_UNUSED( loc ) - - if( m_toolbar.data()->configEnabled() ) - recreateOverlays(); -} - - -void -Context::ToolbarView::refreshOverlays() -{ -} - -void -Context::ToolbarView::recreateOverlays() -{ - DEBUG_BLOCK - foreach( Context::AppletItemOverlay *moveOverlay, m_moveOverlays ) - moveOverlay->deleteLater(); - - m_moveOverlays.clear(); - - QColor overlayColor( Plasma::Theme::defaultTheme()->color( Plasma::Theme::BackgroundColor ) ); - QBrush overlayBrush( overlayColor ); - QPalette p( palette() ); - p.setBrush( QPalette::Window, overlayBrush ); - for( int i = 0; i < m_toolbar.data()->appletLayout()->count(); i++ ) - { - debug() << "creating a move overlay"; - Context::AppletToolbarAppletItem* item = dynamic_cast< Context::AppletToolbarAppletItem* >( m_toolbar.data()->appletLayout()->itemAt( i ) ); - if( item ) - { - Context::AppletItemOverlay *moveOverlay = new Context::AppletItemOverlay( item, m_toolbar.data()->appletLayout(), this ); - connect( moveOverlay, SIGNAL(moveApplet(Plasma::Applet*,int,int)), m_cont, SLOT(moveApplet(Plasma::Applet*,int,int)) ); - connect( moveOverlay, SIGNAL(moveApplet(Plasma::Applet*,int,int)), this, SLOT(refreshOverlays()) ); - connect( moveOverlay, SIGNAL(deleteApplet(Plasma::Applet*)), this, SLOT(appletRemoved(Plasma::Applet*)) ); - moveOverlay->setPalette( p ); - moveOverlay->show(); - moveOverlay->raise(); - m_moveOverlays << moveOverlay; - debug() << moveOverlay << moveOverlay->geometry(); - } - - } -} - -void -Context::ToolbarView::refreshSycoca() -{ - QDBusInterface dbus("org.kde.kded", "/kbuildsycoca", "org.kde.kbuildsycoca"); - dbus.call(QDBus::Block, "recreate"); - - recreateOverlays(); -} - -#include "moc_ToolbarView.cpp" diff --git a/amarok/src/context/ToolbarView.h b/amarok/src/context/ToolbarView.h deleted file mode 100644 index d7dd6515..00000000 --- a/amarok/src/context/ToolbarView.h +++ /dev/null @@ -1,82 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Leo Franchi * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_CONTEXT_TOOLBAR_VIEW -#define AMAROK_CONTEXT_TOOLBAR_VIEW - -#include -#include - -class QGraphicsScene; -class QWidget; - -namespace Plasma -{ - class Applet; - class Containment; -} - -namespace Context -{ - -class AppletToolbar; -class AppletToolbarAppletItem; -class AppletItemOverlay; - -/** - * The applet toolbar is a separate QGV on the same QGS that the ContextView uses. This is because we want to be able to show - * the add applet menu in the main CV, but we also want to manage the toolbar differently. So the toolbar is actually in the - * same scene as the applets but shifted a few thousand pixels so it is invisible in the main CV. The ToolbarView however is - * positioned directly above the toolbar in the scene. - */ -class ToolbarView : public QGraphicsView -{ - Q_OBJECT - - public: - explicit ToolbarView( Plasma::Containment* cont, QGraphicsScene* scene, QWidget* parent = 0 ); - ~ToolbarView(); - - signals: - void hideAppletExplorer(); - void showAppletExplorer(); - - protected: - void resizeEvent( QResizeEvent * event ); - void dragEnterEvent(QDragEnterEvent *event); - void dragMoveEvent(QDragMoveEvent *event); - void dragLeaveEvent(QDragLeaveEvent *event); - - private slots: - void applyStyleSheet(); - void toggleConfigMode(); - void appletRemoved( Plasma::Applet* ); - void appletAdded( Plasma::Applet*, int); - void refreshOverlays(); - void recreateOverlays(); - void refreshSycoca(); - - private: - int m_height; - QWeakPointer m_toolbar; - QList< AppletItemOverlay* > m_moveOverlays; - Plasma::Containment* m_cont; -}; - -} - - -#endif diff --git a/amarok/src/context/amarokapplets.knsrc b/amarok/src/context/amarokapplets.knsrc deleted file mode 100644 index e91bbfb4..00000000 --- a/amarok/src/context/amarokapplets.knsrc +++ /dev/null @@ -1,5 +0,0 @@ -[KNewStuff2] -ProvidersUrl=http://download.kde.org/khotnewstuff/amarokapplets-providers.xml -StandardResource=tmp -InstallationCommand=amarokpkg -i %f -UninstallCommand=amarokpkg -r %f diff --git a/amarok/src/context/applets/CMakeLists.txt b/amarok/src/context/applets/CMakeLists.txt deleted file mode 100644 index f4d5456d..00000000 --- a/amarok/src/context/applets/CMakeLists.txt +++ /dev/null @@ -1,18 +0,0 @@ -add_subdirectory( albums ) -add_subdirectory( currenttrack ) -add_subdirectory( info ) -add_subdirectory( labels ) -add_subdirectory( lyrics ) -add_subdirectory( photos ) -add_subdirectory( tabs ) -add_subdirectory( wikipedia ) - -if( QT_QTOPENGL_FOUND ) - add_subdirectory( analyzer ) -endif() - -if( LIBLASTFM_FOUND ) - add_subdirectory( upcomingevents ) - add_subdirectory( similarartists ) -endif() - diff --git a/amarok/src/context/applets/albums/AlbumItem.cpp b/amarok/src/context/applets/albums/AlbumItem.cpp deleted file mode 100644 index 0d90b60d..00000000 --- a/amarok/src/context/applets/albums/AlbumItem.cpp +++ /dev/null @@ -1,141 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Seb Ruiz * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "AlbumItem.h" - -#include "SvgHandler.h" -#include "context/applets/albums/AlbumsDefs.h" -#include "core/meta/Meta.h" -#include "core/meta/support/MetaUtility.h" - -#include -#include - -#include -#include - -AlbumItem::AlbumItem() - : QStandardItem() - , m_iconSize( 40 ) - , m_showArtist( false ) -{ - setEditable( false ); -} - -AlbumItem::~AlbumItem() -{ - if( m_album ) - unsubscribeFrom( m_album ); -} - -void -AlbumItem::setAlbum( Meta::AlbumPtr albumPtr ) -{ - if( m_album ) - unsubscribeFrom( m_album ); - m_album = albumPtr; - subscribeTo( m_album ); - update(); -} - -void -AlbumItem::setIconSize( const int iconSize ) -{ - static const int padding = 5; - - m_iconSize = iconSize; - - QSize size = sizeHint(); - size.setHeight( iconSize + padding*2 ); - setSizeHint( size ); -} - -void -AlbumItem::setShowArtist( const bool showArtist ) -{ - if( showArtist != m_showArtist ) - { - m_showArtist = showArtist; - metadataChanged( m_album ); - } -} - -void -AlbumItem::metadataChanged( Meta::AlbumPtr album ) -{ - Q_UNUSED( album ); - QMetaObject::invokeMethod(this, "update", Qt::QueuedConnection); -} - -void -AlbumItem::update() -{ - if( !m_album ) - return; - - Meta::TrackList tracks = m_album->tracks(); - if( !tracks.isEmpty() ) - { - Meta::TrackPtr first = tracks.first(); - Meta::YearPtr year = first->year(); - if( year ) - setData( year->year(), AlbumYearRole ); - } - - QString albumName = m_album->name(); - albumName = albumName.isEmpty() ? i18n("Unknown") : albumName; - QString name = ( m_showArtist && m_album->hasAlbumArtist() ) - ? QString( "%1 - %2" ).arg( m_album->albumArtist()->name(), albumName ) - : albumName; - setData( name, NameRole ); - - qint64 totalTime = 0; - foreach( Meta::TrackPtr item, tracks ) - totalTime += item->length(); - - QString trackCount = i18np( "%1 track", "%1 tracks", tracks.size() ); - QString lengthText = QString( "%1, %2" ).arg( trackCount, Meta::msToPrettyTime( totalTime ) ); - setData( lengthText, AlbumLengthRole ); - - QPixmap cover = The::svgHandler()->imageWithBorder( m_album, m_iconSize, 3 ); - setIcon( QIcon( cover ) ); -} - -int -AlbumItem::type() const -{ - return AlbumType; -} - -bool -AlbumItem::operator<( const QStandardItem &other ) const -{ - // compare the opposite for descending year order - int yearA = data( AlbumYearRole ).toInt(); - int yearB = other.data( AlbumYearRole ).toInt(); - if( yearA > yearB ) - return true; - else if( yearA == yearB ) - { - const QString nameA = data( NameRole ).toString(); - const QString nameB = other.data( NameRole ).toString(); - return KStringHandler::naturalCompare( nameA, nameB, Qt::CaseInsensitive ) < 0; - } - else - return false; -} - -#include "moc_AlbumItem.cpp" diff --git a/amarok/src/context/applets/albums/AlbumItem.h b/amarok/src/context/applets/albums/AlbumItem.h deleted file mode 100644 index 62e81423..00000000 --- a/amarok/src/context/applets/albums/AlbumItem.h +++ /dev/null @@ -1,82 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Seb Ruiz * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_ALBUMITEM_H -#define AMAROK_ALBUMITEM_H - -#include "core/meta/Observer.h" - -#include -#include -#include - -class AlbumItem : public QObject, public QStandardItem, public Meta::Observer -{ - Q_OBJECT - - public: - AlbumItem(); - ~AlbumItem(); - - /** - * Sets the AlbumPtr for this item to associate with - * - * @arg album pointer to associate with - */ - void setAlbum( Meta::AlbumPtr albumPtr ); - - /** - * @return the album pointer associated with this item - */ - Meta::AlbumPtr album() const { return m_album; } - - /** - * Sets the size of the album art to display - */ - void setIconSize( const int iconSize ); - - /** - * @return the size of the album art - */ - int iconSize() const { return m_iconSize; } - - /** - * Setter to determine whether the item should show the Artist as well as the - * album name. Used for 'recent albums' listing. - */ - void setShowArtist( const bool showArtist ); - - // overloaded from Meta::Observer - using Observer::metadataChanged; - virtual void metadataChanged( Meta::AlbumPtr album ); - - virtual int type() const; - - virtual bool operator<( const QStandardItem &other ) const; - - private Q_SLOTS: - /** Updates the item after metadataChanged was called. - We need this indirection to get executed by the UI thread. - */ - void update(); - - private: - Meta::AlbumPtr m_album; - int m_iconSize; - bool m_showArtist; -}; - -#endif // multiple inclusion guard diff --git a/amarok/src/context/applets/albums/Albums.cpp b/amarok/src/context/applets/albums/Albums.cpp deleted file mode 100644 index 8fdc2505..00000000 --- a/amarok/src/context/applets/albums/Albums.cpp +++ /dev/null @@ -1,372 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Seb Ruiz * - * Copyright (c) 2008 William Viana Soares * - * Copyright (c) 2009 simon.esneault * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "Albums" - -#include "Albums.h" - -#include "AlbumItem.h" -#include "AlbumsView.h" -#include "core/collections/Collection.h" -#include "core/meta/Meta.h" -#include "core/support/Amarok.h" -#include "core/support/Debug.h" -#include "core-impl/collections/support/CollectionManager.h" -#include "context/widgets/AppletHeader.h" -#include "TrackItem.h" - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -Albums::Albums( QObject* parent, const QVariantList& args ) - : Context::Applet( parent, args ) - , m_recentCount( Amarok::config("Albums Applet").readEntry("RecentlyAdded", 5) ) - , m_rightAlignLength( Amarok::config("Albums Applet").readEntry("RightAlignLength", false) ) - , m_albumsView( 0 ) -{ - setHasConfigurationInterface( true ); -} - -Albums::~Albums() -{ -} - -void Albums::init() -{ - DEBUG_BLOCK - - // Call the base implementation. - Context::Applet::init(); - - enableHeader( true ); - setHeaderText( i18n( "Recently Added Albums" ) ); - - setCollapseOffHeight( -1 ); - setCollapseHeight( m_header->height() ); - setMinimumHeight( collapseHeight() ); - - QAction *settingsAction = new QAction( this ); - settingsAction->setIcon( KIcon( "preferences-system" ) ); - settingsAction->setEnabled( true ); - settingsAction->setToolTip( i18n( "Settings" ) ); - addRightHeaderAction( settingsAction ); - connect( settingsAction, SIGNAL(triggered()), this, SLOT(showConfigurationInterface()) ); - - QAction *filterAction = new QAction( this ); - filterAction->setIcon( KIcon( "view-filter" ) ); - filterAction->setEnabled( true ); - filterAction->setToolTip( i18n( "Filter Albums" ) ); - m_filterIcon = addLeftHeaderAction( filterAction ); - connect( filterAction, SIGNAL(triggered()), this, SLOT(showFilterBar()) ); - - m_albumsView = new AlbumsView( this ); - m_albumsView->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); - if( m_rightAlignLength ) - m_albumsView->setLengthAlignment( Qt::AlignRight ); - - QGraphicsLinearLayout *layout = new QGraphicsLinearLayout( Qt::Vertical ); - layout->addItem( m_header ); - layout->addItem( m_albumsView ); - setLayout( layout ); - - dataEngine( "amarok-current" )->connectSource( "albums", this ); - connect( CollectionManager::instance(), SIGNAL(collectionDataChanged(Collections::Collection*)), - this, SLOT(collectionDataChanged(Collections::Collection*)) ); - - updateConstraints(); -} - -void Albums::showFilterBar() -{ - m_filterIcon->setEnabled( false ); - AlbumsFilterBar *bar = new AlbumsFilterBar( this ); - bar->setContentsMargins( 0, 0, 0, 0 ); - QGraphicsLinearLayout *l = static_cast( layout() ); - l->setItemSpacing( 1, 0 ); - l->addItem( bar ); - connect( bar, SIGNAL(filterTextChanged(QString)), this, SLOT(filterTextChanged(QString)) ); - connect( bar, SIGNAL(closeRequested()), this, SLOT(closeFilterBar()) ); - bar->focusEditor(); -} - -void Albums::closeFilterBar() -{ - filterTextChanged( QString() ); - AlbumsFilterBar *bar = static_cast( sender() ); - QGraphicsLinearLayout *l = static_cast( layout() ); - l->removeItem( bar ); - bar->deleteLater(); - m_filterIcon->setEnabled( true ); -} - -void Albums::filterTextChanged( const QString &text ) -{ - m_albumsView->setFilterPattern( text ); -} - -void Albums::dataUpdated( const QString &name, const Plasma::DataEngine::Data &data ) -{ - if( name != QLatin1String("albums") ) - return; - - Meta::AlbumList albums = data[ "albums" ].value(); - Meta::TrackPtr track = data[ "currentTrack" ].value(); - QString headerText = data[ "headerText" ].toString(); - setHeaderText( headerText.isEmpty() ? i18n("Albums") : headerText ); - - //Don't keep showing the albums for the artist of the last track that had album in the collection - if( (m_currentTrack == track) && (m_albums == albums) ) - return; - - if( albums.isEmpty() ) - { - debug() << "received albums is empty"; - setCollapseOn(); - m_albums.clear(); - m_albumsView->clear(); - return; - } - - setCollapseOff(); - - m_albums = albums; - m_currentTrack = track; - m_albumsView->clear(); - m_albumsView->setMode( track ? AlbumsProxyModel::SortByYear : AlbumsProxyModel::SortByCreateDate ); - QStandardItem *currentItem( 0 ); - - foreach( Meta::AlbumPtr albumPtr, albums ) - { - // do not show all tracks without an album from the collection, this takes ages - // TODO: show all tracks from this artist that are not part of an album - if( albumPtr->name().isEmpty() ) - continue; - - Meta::TrackList tracks = albumPtr->tracks(); - if( tracks.isEmpty() ) - continue; - - AlbumItem *albumItem = new AlbumItem(); - albumItem->setIconSize( 50 ); - albumItem->setAlbum( albumPtr ); - albumItem->setShowArtist( !m_currentTrack ); - - int numberOfDiscs = 0; - int childRow = 0; - - qStableSort( tracks.begin(), tracks.end(), Meta::Track::lessThan ); - - QMultiHash< int, TrackItem* > trackItems; // hash of tracks items for each disc - foreach( Meta::TrackPtr trackPtr, tracks ) - { - if( numberOfDiscs < trackPtr->discNumber() ) - numberOfDiscs = trackPtr->discNumber(); - - TrackItem *trackItem = new TrackItem(); - trackItem->setTrack( trackPtr ); - - // bold the current track to make it more visible - if( m_currentTrack && *m_currentTrack == *trackPtr ) - { - currentItem = trackItem; - trackItem->bold(); - } - - // If compilation and same artist, then highlight, but only if there's a current track - if( m_currentTrack - && m_currentTrack->artist() && trackPtr->artist() - && (*m_currentTrack->artist() == *trackPtr->artist()) - && albumPtr->isCompilation() ) - { - trackItem->italicise(); - } - trackItems.insert( trackPtr->discNumber(), trackItem ); - } - - for( int i = 0; i <= numberOfDiscs; ++i ) - { - QList items = trackItems.values( i ); - if( !items.isEmpty() ) - { - const TrackItem *item = items.first(); - QStandardItem *discItem( 0 ); - if( numberOfDiscs > 1 ) - { - discItem = new QStandardItem( i18n("Disc %1", item->track()->discNumber()) ); - albumItem->setChild( childRow++, discItem ); - int discChildRow = 0; - foreach( TrackItem *trackItem, items ) - discItem->setChild( discChildRow++, trackItem ); - } - else - { - foreach( TrackItem *trackItem, items ) - albumItem->setChild( childRow++, trackItem ); - } - } - } - m_albumsView->appendAlbum( albumItem ); - } - - m_albumsView->sort(); - if( currentItem ) - { - m_albumsView->setRecursiveExpanded( currentItem, true ); - m_albumsView->scrollTo( currentItem ); - } - - updateConstraints(); -} - -void Albums::createConfigurationInterface( KConfigDialog *parent ) -{ - parent->setButtons( KDialog::Ok | KDialog::Cancel ); - - QSpinBox *spinBox = new QSpinBox; - spinBox->setRange( 1, 100 ); - spinBox->setValue( m_recentCount ); - connect( spinBox, SIGNAL(valueChanged(int)), SLOT(setRecentCount(int)) ); - - QCheckBox *checkBox = new QCheckBox( i18n( "Right align track lengths" ) ); - checkBox->setCheckState( m_rightAlignLength ? Qt::Checked : Qt::Unchecked ); - connect( checkBox, SIGNAL(stateChanged(int)), SLOT(setRightAlignLength(int)) ); - - QFormLayout *formLayout = new QFormLayout; - formLayout->addRow( i18n("Number of recently added albums:"), spinBox ); - formLayout->addRow( checkBox ); - - QWidget *config = new QWidget; - config->setLayout( formLayout ); - - parent->addPage( config, i18n( "Albums Applet Settings" ), "preferences-system"); - connect( parent, SIGNAL(accepted()), this, SLOT(saveConfiguration()) ); -} - -void Albums::keyPressEvent( QKeyEvent *event ) -{ - if( event->key() == Qt::Key_Slash || event->matches( QKeySequence::Find ) ) - { - if( m_filterIcon->isEnabled() ) - { - showFilterBar(); - event->accept(); - return; - } - } - Context::Applet::keyPressEvent( event ); -} - -void Albums::setRecentCount( int val ) -{ - m_recentCount = val; -} - -void Albums::setRightAlignLength( int state ) -{ - m_rightAlignLength = (state == Qt::Checked ); - m_albumsView->setLengthAlignment( m_rightAlignLength ? Qt::AlignRight : Qt::AlignLeft ); -} - -void Albums::saveConfiguration() -{ - Amarok::config("Albums Applet").writeEntry( "RecentlyAdded", QString::number( m_recentCount ) ); - Amarok::config("Albums Applet").writeEntry( "RightAlignLength", m_rightAlignLength ); - - // clear to force an update - m_albums.clear(); - - Plasma::DataEngine::Data data = dataEngine( "amarok-current" )->query( "albums" ); - dataUpdated( QLatin1String("albums"), data ); -} - -void Albums::collectionDataChanged( Collections::Collection *collection ) -{ - Q_UNUSED( collection ) - - DEBUG_BLOCK -} - -AlbumsFilterBar::AlbumsFilterBar( QGraphicsItem *parent, Qt::WindowFlags wFlags ) - : QGraphicsWidget( parent, wFlags ) - , m_editor( new KLineEdit ) - , m_closeIcon( new Plasma::IconWidget( KIcon("dialog-close"), QString(), this ) ) -{ - QGraphicsProxyWidget *editProxy = new QGraphicsProxyWidget( this ); - editProxy->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred ); - editProxy->setWidget( m_editor ); - - m_editor->installEventFilter( this ); - m_editor->setAttribute( Qt::WA_NoSystemBackground ); - m_editor->setAutoFillBackground( true ); - m_editor->setClearButtonShown( true ); - m_editor->setClickMessage( i18n( "Filter Albums" ) ); - m_editor->setContentsMargins( 0, 0, 0, 0 ); - - QSizeF iconSize = m_closeIcon->sizeFromIconSize( 16 ); - m_closeIcon->setMaximumSize( iconSize ); - m_closeIcon->setMinimumSize( iconSize ); - - QGraphicsLinearLayout *layout = new QGraphicsLinearLayout( Qt::Horizontal, this ); - layout->setSpacing( 1 ); - layout->addItem( editProxy ); - layout->addItem( m_closeIcon ); - layout->setStretchFactor( editProxy, 100 ); - layout->setAlignment( editProxy, Qt::AlignCenter ); - layout->setAlignment( m_closeIcon, Qt::AlignCenter ); - layout->setContentsMargins( 0, 2, 0, 0 ); - - m_closeIcon->setToolTip( i18n( "Close" ) ); - connect( m_closeIcon, SIGNAL(clicked()), SIGNAL(closeRequested()) ); - connect( m_editor, SIGNAL(textChanged(QString)), SIGNAL(filterTextChanged(QString)) ); -} - -bool -AlbumsFilterBar::eventFilter( QObject *obj, QEvent *e ) -{ - if( obj == m_editor ) - { - if( e->type() == QEvent::KeyPress ) - { - QKeyEvent *kev = static_cast( e ); - if( kev->key() == Qt::Key_Escape ) - { - kev->accept(); - emit closeRequested(); - return true; - } - } - } - return QGraphicsWidget::eventFilter( obj, e ); -} - -void -AlbumsFilterBar::focusEditor() -{ - m_editor->setFocus( Qt::PopupFocusReason ); -} - -#include "moc_Albums.cpp" diff --git a/amarok/src/context/applets/albums/Albums.h b/amarok/src/context/applets/albums/Albums.h deleted file mode 100644 index f4074c38..00000000 --- a/amarok/src/context/applets/albums/Albums.h +++ /dev/null @@ -1,92 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Seb Ruiz * - * Copyright (c) 2008 William Viana Soares * - * Copyright (c) 2009 simon.esneault * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef ALBUMS_APPLET_H -#define ALBUMS_APPLET_H - -#include "context/Applet.h" -#include "context/DataEngine.h" -#include "core/meta/forward_declarations.h" - -#include - -class AlbumsView; -class KLineEdit; -namespace Collections { - class Collection; -} -namespace Plasma { - class IconWidget; -} - -class Albums : public Context::Applet -{ - Q_OBJECT -public: - Albums( QObject* parent, const QVariantList& args ); - ~Albums(); - -public slots: - virtual void init(); - void dataUpdated( const QString& name, const Plasma::DataEngine::Data &data ); - -protected: - void createConfigurationInterface( KConfigDialog *parent ); - void keyPressEvent( QKeyEvent *event ); - -private slots: - void collectionDataChanged( Collections::Collection *collection ); - void saveConfiguration(); - void setRecentCount( int val ); - void setRightAlignLength( int state ); - void showFilterBar(); - void closeFilterBar(); - void filterTextChanged( const QString &text ); - -private: - int m_recentCount; - bool m_rightAlignLength; - AlbumsView *m_albumsView; - Meta::AlbumList m_albums; - Meta::TrackPtr m_currentTrack; - Plasma::IconWidget *m_filterIcon; -}; - -class AlbumsFilterBar : public QGraphicsWidget -{ - Q_OBJECT - -public: - AlbumsFilterBar( QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0 ); - ~AlbumsFilterBar() {} - - bool eventFilter( QObject *obj, QEvent *e ); - void focusEditor(); - -signals: - void closeRequested(); - void filterTextChanged( const QString &text ); - -private: - KLineEdit *m_editor; - Plasma::IconWidget *m_closeIcon; -}; - -AMAROK_EXPORT_APPLET( albums, Albums ) - -#endif diff --git a/amarok/src/context/applets/albums/AlbumsDefs.h b/amarok/src/context/applets/albums/AlbumsDefs.h deleted file mode 100644 index 7263779b..00000000 --- a/amarok/src/context/applets/albums/AlbumsDefs.h +++ /dev/null @@ -1,40 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Rick W. Chen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_ALBUMSDEFS_H -#define AMAROK_ALBUMSDEFS_H - -#include - -enum AlbumsModelItemTypes -{ - AlbumType = QStandardItem::UserType, - TrackType -}; - -enum AlbumsModelCustomRoles -{ - NameRole = Qt::UserRole + 1, - AlbumCompilationRole, - AlbumMaxTrackNumberRole, - AlbumLengthRole, - AlbumYearRole, - TrackArtistRole, - TrackNumberRole, - TrackLengthRole -}; - -#endif /* AMAROK_ALBUMSDEFS_H */ diff --git a/amarok/src/context/applets/albums/AlbumsModel.cpp b/amarok/src/context/applets/albums/AlbumsModel.cpp deleted file mode 100644 index 7f662345..00000000 --- a/amarok/src/context/applets/albums/AlbumsModel.cpp +++ /dev/null @@ -1,187 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Andreas Muetzel * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "AlbumsModel" - -#include "AlbumsModel.h" -#include "AlbumsDefs.h" -#include "AlbumItem.h" -#include "AmarokMimeData.h" -#include "core/support/Debug.h" -#include "TrackItem.h" - -#include -#include - -#include - -AlbumsModel::AlbumsModel( QObject *parent ) - : QStandardItemModel( parent ) - , m_rowHeight( 0 ) -{ - connect( KGlobalSettings::self(), SIGNAL(appearanceChanged()), SLOT(updateRowHeight()) ); - updateRowHeight(); -} - -int -AlbumsModel::rowHeight() const -{ - return m_rowHeight; -} - -void -AlbumsModel::updateRowHeight() -{ - QFont font; - m_rowHeight = QFontMetrics( font ).height(); -} - -QVariant -AlbumsModel::data( const QModelIndex &index, int role ) const -{ - if( !index.isValid() ) - return QVariant(); - - if( role == Qt::SizeHintRole ) - { - const QStandardItem *item = itemFromIndex( index ); - int h = 4; - h += (item->type() != AlbumType) ? m_rowHeight : static_cast( item )->iconSize(); - return QSize( -1, h ); - } - return itemFromIndex( index )->data( role ); -} - -QMimeData* -AlbumsModel::mimeData( const QModelIndexList &indices ) const -{ - DEBUG_BLOCK - if( indices.isEmpty() ) - return 0; - - Meta::TrackList tracks; - foreach( const QModelIndex &index, indices ) - tracks << tracksForIndex( index ); - tracks = tracks.toSet().toList(); - - // http://doc.trolltech.com/4.4/qabstractitemmodel.html#mimeData - // If the list of indexes is empty, or there are no supported MIME types, - // 0 is returned rather than a serialized empty list. - if( tracks.isEmpty() ) - return 0; - - AmarokMimeData *mimeData = new AmarokMimeData(); - mimeData->setTracks( tracks ); - return mimeData; -} - -Meta::TrackList -AlbumsModel::tracksForIndex( const QModelIndex &index ) const -{ - Meta::TrackList tracks; - if( !index.isValid() ) - return tracks; - - if( hasChildren( index ) ) - { - for( int i = 0, rows = rowCount( index ); i < rows; ++i ) - tracks << tracksForIndex( index.child( i, 0 ) ); - } - else if( QStandardItem *item = itemFromIndex( index ) ) - { - if( item->type() == TrackType ) - { - TrackItem* trackItem = static_cast( item ); - if( trackItem ) - tracks << trackItem->track(); - } - } - return tracks; -} - -QStringList -AlbumsModel::mimeTypes() const -{ - QStringList types; - types << AmarokMimeData::TRACK_MIME; - return types; -} - -AlbumsProxyModel::AlbumsProxyModel( QObject *parent ) - : QSortFilterProxyModel( parent ) - , m_mode( SortByCreateDate ) -{} - -bool -AlbumsProxyModel::lessThan( const QModelIndex &left, const QModelIndex &right ) const -{ - const QStandardItemModel *model = static_cast( sourceModel() ); - const QStandardItem *leftItem = model->itemFromIndex( left ); - int type = leftItem->type(); - if( type == AlbumType && m_mode == SortByCreateDate ) - { - const AlbumItem *leftAlbum = static_cast( leftItem ); - const AlbumItem *rightAlbum = static_cast( model->itemFromIndex( right ) ); - QDateTime leftMaxCreateDate, rightMaxCreateDate; - foreach( Meta::TrackPtr track, leftAlbum->album()->tracks() ) - if( track->createDate() > leftMaxCreateDate ) - leftMaxCreateDate = track->createDate(); - foreach( Meta::TrackPtr track, rightAlbum->album()->tracks() ) - if( track->createDate() > rightMaxCreateDate ) - rightMaxCreateDate = track->createDate(); - return leftMaxCreateDate > rightMaxCreateDate; - } - else if( type == AlbumType || type == TrackType ) - return leftItem->operator<( *model->itemFromIndex( right ) ); - else - return KStringHandler::naturalCompare( leftItem->text(), model->itemFromIndex(right)->text() ) < 0; -} - -bool -AlbumsProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex &sourceParent ) const -{ - const QStandardItemModel *model = static_cast( sourceModel() ); - const QModelIndex &srcIndex = sourceModel()->index( sourceRow, 0, sourceParent ); - const QStandardItem *item = model->itemFromIndex( srcIndex ); - - if( item->data( NameRole ).toString().contains( filterRegExp() ) ) - return true; - - if( item->type() == AlbumType ) - { - for( int i = 0, count = model->rowCount( srcIndex ); i < count; ++i ) - { - const QModelIndex &kid = srcIndex.child( i, 0 ); - if( kid.data( NameRole ).toString().contains( filterRegExp() ) ) - return true; - } - } - return false; -} - -AlbumsProxyModel::Mode -AlbumsProxyModel::mode() const -{ - return m_mode; -} - -void -AlbumsProxyModel::setMode( Mode mode ) -{ - m_mode = mode; -} - -#include "moc_AlbumsModel.cpp" diff --git a/amarok/src/context/applets/albums/AlbumsModel.h b/amarok/src/context/applets/albums/AlbumsModel.h deleted file mode 100644 index 872cfd60..00000000 --- a/amarok/src/context/applets/albums/AlbumsModel.h +++ /dev/null @@ -1,82 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Andreas Muetzel * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_ALBUMSMODEL_H -#define AMAROK_ALBUMSMODEL_H - -#include "core/meta/forward_declarations.h" - -#include -#include - -/** - * This Model is used to get the right mime type/data for entries in the albums treeview - */ -class AlbumsModel : public QStandardItemModel -{ - Q_OBJECT - -public: - AlbumsModel( QObject *parent = 0 ); - virtual ~AlbumsModel() {} - virtual QVariant data( const QModelIndex &index, int role ) const; - virtual QMimeData* mimeData( const QModelIndexList &indices ) const; - virtual QStringList mimeTypes() const; - int rowHeight() const; - -private slots: - void updateRowHeight(); - -private: - Meta::TrackList tracksForIndex( const QModelIndex &index ) const; - int m_rowHeight; -}; - -class AlbumsProxyModel : public QSortFilterProxyModel -{ - Q_OBJECT - Q_PROPERTY( Mode mode READ mode WRITE setMode ) - Q_ENUMS( Mode ) - -public: - AlbumsProxyModel( QObject *parent ); - ~AlbumsProxyModel() {} - - enum Mode { SortByCreateDate, SortByYear }; - - Mode mode() const; - void setMode( Mode mode ); - -protected: - /** - * Determine if album @param left is less than album @param right. - * - * If @param left and @param right both reference albums and @c m_mode - * is set to @c SortByCreateDate, @c lessThan will return @c true if - * and only the album referenced by @param left has a track that was - * added more recently than all of the tracks in the album - * referenced by @param right. - */ - bool lessThan( const QModelIndex &left, const QModelIndex &right ) const; - - bool filterAcceptsRow( int sourceRow, const QModelIndex &sourceParent ) const; - -private: - Mode m_mode; -}; - - -#endif diff --git a/amarok/src/context/applets/albums/AlbumsView.cpp b/amarok/src/context/applets/albums/AlbumsView.cpp deleted file mode 100644 index e55521f8..00000000 --- a/amarok/src/context/applets/albums/AlbumsView.cpp +++ /dev/null @@ -1,614 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 William Viana Soares * - * Copyright (c) 2008 Seb Ruiz * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "AlbumsView" - -#include "AlbumsView.h" - -#include "AlbumItem.h" -#include "AlbumsDefs.h" -#include "SvgHandler.h" -#include "TrackItem.h" -#include "core/capabilities/ActionsCapability.h" -#include "core/meta/Meta.h" -#include "core/meta/support/MetaUtility.h" -#include "core/support/Debug.h" -#include "dialogs/TagDialog.h" -#include "playlist/PlaylistController.h" -#include "widgets/PrettyTreeView.h" - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -// Subclassed to override the access level of some methods. -// The AlbumsTreeView and the AlbumsView are so highly coupled that this is acceptable, imo. -class AlbumsTreeView : public Amarok::PrettyTreeView -{ - public: - AlbumsTreeView( QWidget *parent = 0 ) - : Amarok::PrettyTreeView( parent ) - { - setAttribute( Qt::WA_NoSystemBackground ); - viewport()->setAutoFillBackground( false ); - - setHeaderHidden( true ); - setIconSize( QSize(60,60) ); - setDragDropMode( QAbstractItemView::DragOnly ); - setSelectionMode( QAbstractItemView::ExtendedSelection ); - setSelectionBehavior( QAbstractItemView::SelectItems ); - if( KGlobalSettings::graphicEffectsLevel() != KGlobalSettings::NoEffects ) - setAnimated( true ); - setRootIsDecorated( false ); - setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); - setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); - setVerticalScrollMode( QAbstractItemView::ScrollPerPixel ); // see wheelEvent() - setItemDelegate( new AlbumsItemDelegate( this ) ); - setFrameStyle( QFrame::NoFrame ); - } - - // Override access level to make it public. Only visible to the AlbumsView. - // Used for context menu methods. - QModelIndexList selectedIndexes() const { return PrettyTreeView::selectedIndexes(); } - - protected: - void wheelEvent( QWheelEvent *e ) - { - // scroll per pixel doesn't work when using delegates with big height (QTBUG-7232). - // This is a work around for scrolling with smaller steps. - AlbumsProxyModel *proxyModel = static_cast( model() ); - AlbumsModel *albumsModel = static_cast( proxyModel->sourceModel() ); - verticalScrollBar()->setSingleStep( albumsModel->rowHeight() ); - Amarok::PrettyTreeView::wheelEvent( e ); - } -}; - -AlbumsView::AlbumsView( QGraphicsWidget *parent ) - : QGraphicsWidget( parent ) -{ - Plasma::Svg *borderSvg = new Plasma::Svg( this ); - borderSvg->setImagePath( "widgets/scrollwidget" ); - - m_topBorder = new Plasma::SvgWidget( this ); - m_topBorder->setSvg( borderSvg ); - m_topBorder->setElementID( "border-top" ); - m_topBorder->setZValue( 900 ); - m_topBorder->resize( -1, 10.0 ); - m_topBorder->show(); - - m_bottomBorder = new Plasma::SvgWidget( this ); - m_bottomBorder->setSvg( borderSvg ); - m_bottomBorder->setElementID( "border-bottom" ); - m_bottomBorder->setZValue( 900 ); - m_bottomBorder->resize( -1, 10.0 ); - m_bottomBorder->show(); - - m_treeProxy = new QGraphicsProxyWidget( this ); - m_treeView = new AlbumsTreeView( 0 ); - connect( m_treeView, SIGNAL(clicked(QModelIndex)), this, SLOT(itemClicked(QModelIndex)) ); - connect( m_treeView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(slotDoubleClicked()) ); - m_treeProxy->setWidget( m_treeView ); - - m_model = new AlbumsModel( this ); - m_model->setColumnCount( 1 ); - m_proxyModel = new AlbumsProxyModel( this ); - m_proxyModel->setFilterCaseSensitivity( Qt::CaseInsensitive ); - m_proxyModel->setSortLocaleAware( true ); - m_proxyModel->setDynamicSortFilter( true ); - m_proxyModel->setSourceModel( m_model ); - m_proxyModel->setFilterRole( NameRole ); - m_treeView->setModel( m_proxyModel ); - - QScrollBar *treeScrollBar = m_treeView->verticalScrollBar(); - m_scrollBar = new Plasma::ScrollBar( this ); - m_scrollBar->setFocusPolicy( Qt::NoFocus ); - - // synchronize scrollbars - connect( treeScrollBar, SIGNAL(rangeChanged(int,int)), SLOT(slotScrollBarRangeChanged(int,int)) ); - connect( treeScrollBar, SIGNAL(valueChanged(int)), m_scrollBar, SLOT(setValue(int)) ); - connect( m_scrollBar, SIGNAL(valueChanged(int)), treeScrollBar, SLOT(setValue(int)) ); - m_scrollBar->setRange( treeScrollBar->minimum(), treeScrollBar->maximum() ); - m_scrollBar->setPageStep( treeScrollBar->pageStep() ); - m_scrollBar->setSingleStep( treeScrollBar->singleStep() ); - - QGraphicsLinearLayout *layout = new QGraphicsLinearLayout( Qt::Horizontal ); - layout->addItem( m_treeProxy ); - layout->addItem( m_scrollBar ); - layout->setSpacing( 2 ); - layout->setContentsMargins( 0, 0, 0, 0 ); - setLayout( layout ); - setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); - updateScrollBarVisibility(); -} - -AlbumsView::~AlbumsView() -{ -} - -void -AlbumsView::appendAlbum( QStandardItem *album ) -{ - m_model->appendRow( album ); -} - -void -AlbumsView::sort() -{ - m_proxyModel->sort( 0 ); -} - -void -AlbumsView::scrollTo( QStandardItem *album ) -{ - const QModelIndex &proxyIndex = m_proxyModel->mapFromSource( album->index() ); - m_treeView->scrollTo( proxyIndex, QAbstractItemView::EnsureVisible ); -} - -QString -AlbumsView::filterPattern() const -{ - return m_proxyModel->filterRegExp().pattern(); -} - -void -AlbumsView::setFilterPattern( const QString &pattern ) -{ - m_proxyModel->setFilterRegExp( QRegExp(pattern, Qt::CaseInsensitive) ); -} - -void -AlbumsView::clear() -{ - qDeleteAll( m_model->findItems( QLatin1String( "*" ), Qt::MatchWildcard ) ); - m_model->clear(); -} - -AlbumsProxyModel::Mode -AlbumsView::mode() const -{ - return m_proxyModel->mode(); -} - -void -AlbumsView::setMode( AlbumsProxyModel::Mode mode ) -{ - m_proxyModel->setMode( mode ); -} - -Qt::Alignment -AlbumsView::lengthAlignment() const -{ - return static_cast( m_treeView->itemDelegate() )->lengthAlignment(); -} - -void -AlbumsView::setLengthAlignment( Qt::Alignment alignment ) -{ - static_cast( m_treeView->itemDelegate() )->setLengthAlignment( alignment ); -} - -void -AlbumsView::itemClicked( const QModelIndex &index ) -{ - if( !m_treeView->model()->hasChildren( index ) ) - return; - - bool expanded = m_treeView->isExpanded( index ); - if( expanded ) - m_treeView->setExpanded( index, !expanded ); - else - setRecursiveExpanded( index, !expanded ); -} - -void -AlbumsView::contextMenuEvent( QGraphicsSceneContextMenuEvent *event ) -{ - const QModelIndex index = m_treeView->indexAt( event->pos().toPoint() ); - if( !index.isValid() ) - { - QGraphicsWidget::contextMenuEvent( event ); - return; - } - - KMenu menu; - KAction *appendAction = new KAction( KIcon( "media-track-add-amarok" ), i18n( "&Add to Playlist" ), &menu ); - KAction *loadAction = new KAction( KIcon( "folder-open" ), i18nc( "Replace the currently loaded tracks with these", "&Replace Playlist" ), &menu ); - KAction *queueAction = new KAction( KIcon( "media-track-queue-amarok" ), i18n( "&Queue" ), &menu ); - KAction *editAction = new KAction( KIcon( "media-track-edit-amarok" ), i18n( "Edit Track Details" ), &menu ); - - menu.addAction( appendAction ); - menu.addAction( loadAction ); - menu.addAction( queueAction ); - menu.addAction( editAction ); - - connect( appendAction, SIGNAL(triggered()), this, SLOT(slotAppendSelected()) ); - connect( loadAction , SIGNAL(triggered()), this, SLOT(slotReplaceWithSelected()) ); - connect( queueAction , SIGNAL(triggered()), this, SLOT(slotQueueSelected()) ); - connect( editAction , SIGNAL(triggered()), this, SLOT(slotEditSelected()) ); - - KMenu menuCover( i18n( "Album" ), &menu ); - const QStandardItem *item = m_model->itemFromIndex( m_proxyModel->mapToSource(index) ); - if( item->type() == AlbumType ) - { - Meta::AlbumPtr album = static_cast( item )->album(); - QScopedPointer ac( album->create() ); - if( ac ) - { - QList actions = ac->actions(); - if( !actions.isEmpty() ) - { - // ensure that the actions are cleaned up afterwards - foreach( QAction *action, actions ) - { - if( !action->parent() ) - action->setParent( &menuCover ); - } - - menuCover.addActions( actions ); - menuCover.setIcon( KIcon( "filename-album-amarok" ) ); - menu.addMenu( &menuCover ); - } - } - } - menu.exec( event->screenPos() ); -} - -void -AlbumsView::resizeEvent( QGraphicsSceneResizeEvent *event ) -{ - QGraphicsWidget::resizeEvent( event ); - if( m_topBorder ) - { - m_topBorder->resize( event->newSize().width(), m_topBorder->size().height() ); - m_bottomBorder->resize( event->newSize().width(), m_bottomBorder->size().height() ); - m_topBorder->setPos( m_treeProxy->pos() ); - QPointF bottomPoint = m_treeProxy->boundingRect().bottomLeft(); - bottomPoint.ry() -= m_bottomBorder->size().height(); - m_bottomBorder->setPos( bottomPoint ); - } -} - -void AlbumsView::slotDoubleClicked() -{ - Meta::TrackList selected = getSelectedTracks(); - The::playlistController()->insertOptioned( selected, Playlist::OnDoubleClickOnSelectedItems ); -} - -void -AlbumsView::slotAppendSelected() -{ - Meta::TrackList selected = getSelectedTracks(); - The::playlistController()->insertOptioned( selected, Playlist::OnAppendToPlaylistAction ); -} - -void -AlbumsView::slotReplaceWithSelected() -{ - Meta::TrackList selected = getSelectedTracks(); - The::playlistController()->insertOptioned( selected, Playlist::OnReplacePlaylistAction ); -} - -void -AlbumsView::slotQueueSelected() -{ - Meta::TrackList selected = getSelectedTracks(); - The::playlistController()->insertOptioned( selected, Playlist::OnQueueToPlaylistAction ); -} - -void -AlbumsView::slotEditSelected() -{ - Meta::TrackList selected = getSelectedTracks(); - if( !selected.isEmpty() ) - { - TagDialog *dialog = new TagDialog( selected ); - dialog->show(); - } -} - -void -AlbumsView::slotScrollBarRangeChanged( int min, int max ) -{ - m_scrollBar->setRange( min, max ); - m_scrollBar->setPageStep( m_treeView->verticalScrollBar()->pageStep() ); - m_scrollBar->setSingleStep( m_treeView->verticalScrollBar()->singleStep() ); - updateScrollBarVisibility(); -} - -void -AlbumsView::updateScrollBarVisibility() -{ - QGraphicsLinearLayout *lo = static_cast( layout() ); - if( m_scrollBar->maximum() == 0 ) - { - if( lo->count() > 1 && lo->itemAt(1) == m_scrollBar ) - { - lo->removeAt( 1 ); - m_scrollBar->hide(); - } - } - else if( lo->count() == 1 ) - { - lo->addItem( m_scrollBar ); - m_scrollBar->show(); - } -} - -Meta::TrackList -AlbumsView::getSelectedTracks() const -{ - Meta::TrackList selected; - - QModelIndexList indexes = static_cast( m_treeView )->selectedIndexes(); - foreach( const QModelIndex &index, indexes ) - { - if( index.isValid() ) - { - const QModelIndex &srcIndex = m_proxyModel->mapToSource( index ); - const QStandardItem *item = m_model->itemFromIndex( srcIndex ); - if( item->type() == AlbumType ) - { - selected << static_cast( item )->album()->tracks(); - } - else if( item->type() == TrackType ) - { - selected << static_cast( item )->track(); - } - else if( m_model->hasChildren( srcIndex ) ) // disc type - { - for( int i = m_model->rowCount( srcIndex ) - 1; i >= 0; --i ) - { - const QStandardItem *trackItem = m_model->itemFromIndex( srcIndex.child(i, 0) ); - selected << static_cast( trackItem )->track(); - } - } - } - } - - return selected; -} - -void -AlbumsView::setRecursiveExpanded( QStandardItem *item, bool expanded ) -{ - setRecursiveExpanded( m_proxyModel->mapFromSource( item->index() ), expanded ); -} - -void -AlbumsView::setRecursiveExpanded( const QModelIndex &index, bool expanded ) -{ - if( m_proxyModel->hasChildren( index ) ) - { - for( int i = 0, count = m_proxyModel->rowCount( index ); i < count; ++i ) - m_treeView->setExpanded( index.child( i, 0 ), expanded ); - } - m_treeView->setExpanded( index, expanded ); -} - -AlbumsItemDelegate::AlbumsItemDelegate( QObject *parent ) - : QStyledItemDelegate( parent ) - , m_lengthAlignment( Qt::AlignLeft ) -{} - -/* - * Customize the painting of items in the tree view. - * - * AlbumItems: The album items' displayed text has the format - * "artist - album (year)\ntracks, time", i.e. the album info is shown in two - * lines. When resizing the context view, the string is elided if the available - * width is less than the text width. That ellipsis is done on the whole string - * however, so the second line disappears. A solution is to do the eliding - * ourselves. - * - * TrackItems: The track number and length gets special treatment. They are - * painted at the beginning and end of the string, respectively. The track - * numbers are right aligned and a suitable width is used to make the numbers - * align for all the tracks in the album. The track name and artist (the latter - * is included if the album is a compilation), are placed in between the track - * number and length; it is elided if necessary. Thus the track number and - * length are always shown, even during eliding. - */ -void -AlbumsItemDelegate::paint( QPainter *p, - const QStyleOptionViewItem &option, - const QModelIndex &index ) const -{ - QStyleOptionViewItem sepOption = option; - QStyledItemDelegate::paint( p, sepOption, index ); - const QAbstractProxyModel *xyModel = qobject_cast( index.model() ); - const QStandardItemModel *stdModel = qobject_cast( xyModel->sourceModel() ); - const QStandardItem *item = stdModel->itemFromIndex( xyModel->mapToSource(index) ); - if( item->type() == AlbumType ) - { - // draw the text ourselves. The superclass will skip painting the - // text since the text in Qt::DisplayRole is not actually set. - QStyleOptionViewItemV4 vopt( option ); - initStyleOption( &vopt, index ); - const AlbumItem *albumItem = static_cast( item ); - int iconSize = albumItem->iconSize(); - QSize coverSize = albumItem->album()->image( iconSize ).size(); - coverSize.rwidth() += 6; // take into account of svg borders - coverSize.rheight() += 6; - qreal aspectRatio = static_cast( coverSize.width() ) / coverSize.height(); - const int margin = vopt.widget->style()->pixelMetric( QStyle::PM_FocusFrameHMargin ) + 1; - const int offset = qMin( int(iconSize * aspectRatio), iconSize ) + margin; - if( option.direction == Qt::RightToLeft ) - vopt.rect.adjust( 0, 0, -offset, 0 ); - else - vopt.rect.adjust( offset, 0, 0, 0 ); - drawAlbumText( p, vopt ); - } - else if( item->type() == TrackType ) - { - QStyleOptionViewItemV4 vopt( option ); - initStyleOption( &vopt, index ); - if( option.direction == Qt::RightToLeft ) - vopt.rect.adjust( 2, 0, 0, 0 ); - else - vopt.rect.adjust( 0, 0, -2, 0 ); - drawTrackText( p, vopt ); - } -} - -void -AlbumsItemDelegate::drawAlbumText( QPainter *p, const QStyleOptionViewItemV4 &vopt ) const -{ - const QModelIndex &index = vopt.index; - const QRect &textRect = vopt.rect.adjusted( 4, 0, -4, 0 ); - - p->save(); - p->setClipRect( textRect ); - applyCommonStyle( p, vopt ); - - QString name = index.data( NameRole ).toString(); - int year = index.data( AlbumYearRole ).toInt(); - - QStringList texts; - texts << ((year > 0) ? QString( "%1 (%2)" ).arg( name, QString::number(year) ) : name); - texts << index.data( AlbumLengthRole ).toString(); - - // elide each line according to available width - QFontMetrics fm = vopt.fontMetrics; - QMutableStringListIterator it( texts ); - while( it.hasNext() ) - { - const QString &text = it.next(); - if( fm.width( text ) > textRect.width() ) - it.setValue( fm.elidedText( text, Qt::ElideRight, textRect.width() ) ); - } - - p->drawText( textRect, Qt::AlignLeft | Qt::AlignVCenter, texts.join("\n") ); - p->restore(); -} - -void -AlbumsItemDelegate::drawTrackText( QPainter *p, const QStyleOptionViewItemV4 &vopt ) const -{ - const QModelIndex &index = vopt.index; - - int trackDigitCount = index.data( AlbumMaxTrackNumberRole ).toString().length(); - bool isCompilation = index.data( AlbumCompilationRole ).toBool(); - const QString &name = index.data( NameRole ).toString(); - const QString &artist = index.data( TrackArtistRole ).toString(); - QString length = " (" + Meta::msToPrettyTime( index.data( TrackLengthRole ).toInt() ) + ')'; - QString number = index.data( TrackNumberRole ).toString() + ". "; - QString middle = isCompilation ? QString( "%1 - %2" ).arg( artist, name ) : name; - - // use boldface font metrics for measuring track numbers - QFont boldFont = vopt.font; - boldFont.setBold( true ); - QFontMetrics boldFm( boldFont, p->device() ); - QFontMetrics fm( vopt.fontMetrics ); - - int numberFillWidth = boldFm.width( QChar('0') ) * ( trackDigitCount - number.length() + 2 ); - int numberRectWidth = 0; - if( number != QLatin1String("0. ") ) - numberRectWidth = numberFillWidth + boldFm.width( number ) + 2; - int lengthRectWidth = boldFm.width( length ); - int availableWidth = vopt.rect.width() - numberRectWidth - lengthRectWidth; - if( availableWidth < fm.width( middle ) ) - middle = fm.elidedText( middle, Qt::ElideRight, availableWidth ); - - p->save(); - p->setClipRect( vopt.rect ); - p->setBackground( vopt.backgroundBrush ); - p->setLayoutDirection( vopt.direction ); - p->setFont( vopt.font ); - applyCommonStyle( p, vopt ); - int textRectWidth = (m_lengthAlignment == Qt::AlignLeft) ? fm.width( middle ) : availableWidth; - - QRect numberRect; - QRect textRect; - QRect lengthRect; - if( vopt.direction == Qt::RightToLeft ) - { - QPoint corner = vopt.rect.topRight(); - corner.rx() -= numberRectWidth; - numberRect = QRect( corner, QSize( numberRectWidth, vopt.rect.height() ) ); - - corner = numberRect.topLeft(); - corner.rx() -= textRectWidth; - textRect = QRect( corner, QSize( textRectWidth, vopt.rect.height() ) ); - - corner = textRect.topLeft(); - corner.rx() -= lengthRectWidth; - lengthRect = QRect( corner, QSize( lengthRectWidth, vopt.rect.height() ) ); - } - else - { - numberRect = QRect( vopt.rect.topLeft(), QSize( numberRectWidth, vopt.rect.height() ) ); - textRect = QRect( numberRect.topRight(), QSize( textRectWidth, vopt.rect.height() ) ); - lengthRect = QRect( textRect.topRight(), QSize( lengthRectWidth, vopt.rect.height() ) ); - } - - if( number != QLatin1String("0. ") ) - p->drawText( numberRect, Qt::AlignRight | Qt::AlignVCenter, number ); - p->drawText( textRect, Qt::AlignVCenter, middle ); - p->drawText( lengthRect, m_lengthAlignment | Qt::AlignVCenter, length ); - p->restore(); -} - -void -AlbumsItemDelegate::applyCommonStyle( QPainter *p, const QStyleOptionViewItemV4 &vopt ) const -{ - // styling code from QCommonStyle. These aren't actually used right - // now, but will be needed if something like inline tag editing is - // implemented. - QPalette::ColorGroup cg = vopt.state & QStyle::State_Enabled - ? QPalette::Normal : QPalette::Disabled; - if (cg == QPalette::Normal && !(vopt.state & QStyle::State_Active)) - cg = QPalette::Inactive; - - if (vopt.state & QStyle::State_Selected) { - p->setPen(vopt.palette.color(cg, QPalette::HighlightedText)); - } else { - p->setPen(vopt.palette.color(cg, QPalette::Text)); - } - if (vopt.state & QStyle::State_Editing) { - p->setPen(vopt.palette.color(cg, QPalette::Text)); - p->drawRect(vopt.rect.adjusted(0, 0, -1, -1)); - } -} - -Qt::Alignment -AlbumsItemDelegate::lengthAlignment() const -{ - return m_lengthAlignment; -} - -void -AlbumsItemDelegate::setLengthAlignment( Qt::Alignment a ) -{ - if( a != Qt::AlignLeft && a != Qt::AlignRight ) - a = Qt::AlignLeft; - m_lengthAlignment = a; -} - -#include "moc_AlbumsView.cpp" diff --git a/amarok/src/context/applets/albums/AlbumsView.h b/amarok/src/context/applets/albums/AlbumsView.h deleted file mode 100644 index ac9341aa..00000000 --- a/amarok/src/context/applets/albums/AlbumsView.h +++ /dev/null @@ -1,115 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 William Viana Soares * - * Copyright (c) 2008 Seb Ruiz * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_ALBUMSVIEW_H -#define AMAROK_ALBUMSVIEW_H - -#include "core/meta/forward_declarations.h" -#include "AlbumsModel.h" - -#include -#include - -class QAbstractItemModel; -class QGraphicsSceneContextMenuEvent; -class QGraphicsProxyWidget; -class QStandardItem; -class QTreeView; -namespace Plasma -{ - class SvgWidget; - class ScrollBar; -} - -class AlbumsView : public QGraphicsWidget -{ - Q_OBJECT - Q_PROPERTY( AlbumsProxyModel::Mode mode READ mode WRITE setMode ) - Q_PROPERTY( Qt::Alignment lengthAlignment READ lengthAlignment WRITE setLengthAlignment ) - Q_PROPERTY( QString filterPattern READ filterPattern WRITE setFilterPattern ) - -public: - explicit AlbumsView( QGraphicsWidget *parent = 0 ); - ~AlbumsView(); - - void appendAlbum( QStandardItem *album ); - void scrollTo( QStandardItem *album ); - - AlbumsProxyModel::Mode mode() const; - void setMode( AlbumsProxyModel::Mode mode ); - - Qt::Alignment lengthAlignment() const; - void setLengthAlignment( Qt::Alignment alignment ); - - QString filterPattern() const; - void setFilterPattern( const QString &pattern ); - - void clear(); - -public slots: - void setRecursiveExpanded( QStandardItem *item, bool expanded ); - void sort(); - -protected: - void contextMenuEvent( QGraphicsSceneContextMenuEvent *event ); - void resizeEvent( QGraphicsSceneResizeEvent *event ); - -private slots: - void itemClicked( const QModelIndex &index ); - void slotDoubleClicked(); - void slotAppendSelected(); - void slotEditSelected(); - void slotReplaceWithSelected(); - void slotQueueSelected(); - void slotScrollBarRangeChanged( int min, int max ); - -private: - void updateScrollBarVisibility(); - void setRecursiveExpanded( const QModelIndex &index, bool expanded ); - - Meta::TrackList getSelectedTracks() const; - AlbumsModel *m_model; - AlbumsProxyModel *m_proxyModel; - QTreeView *m_treeView; - QGraphicsProxyWidget *m_treeProxy; - Plasma::SvgWidget *m_topBorder; - Plasma::SvgWidget *m_bottomBorder; - Plasma::ScrollBar *m_scrollBar; -}; - -class AlbumsItemDelegate : public QStyledItemDelegate -{ - Q_OBJECT - Q_PROPERTY( Qt::Alignment lengthAlignment READ lengthAlignment WRITE setLengthAlignment ) - -public: - AlbumsItemDelegate( QObject *parent = 0 ); - ~AlbumsItemDelegate() {} - - Qt::Alignment lengthAlignment() const; - void setLengthAlignment( Qt::Alignment alignment ); - - void paint( QPainter *p, const QStyleOptionViewItem &option, const QModelIndex &index ) const; - -private: - void drawAlbumText( QPainter *p, const QStyleOptionViewItemV4 &option ) const; - void drawTrackText( QPainter *p, const QStyleOptionViewItemV4 &option ) const; - void applyCommonStyle( QPainter *p, const QStyleOptionViewItemV4 &option ) const; - Qt::Alignment m_lengthAlignment; -}; - -#endif // multiple inclusion guard diff --git a/amarok/src/context/applets/albums/CMakeLists.txt b/amarok/src/context/applets/albums/CMakeLists.txt deleted file mode 100644 index b954956d..00000000 --- a/amarok/src/context/applets/albums/CMakeLists.txt +++ /dev/null @@ -1,22 +0,0 @@ -project(context-albums) - -set(albums_SRCS Albums.cpp AlbumsView.cpp AlbumItem.cpp TrackItem.cpp AlbumsModel.cpp) - -include_directories( - ../.. - ../../.. - ) - -kde4_add_plugin(amarok_context_applet_albums ${albums_SRCS}) -if(APPLE) - SET_TARGET_PROPERTIES(amarok_context_applet_albums PROPERTIES LINK_FLAGS "-undefined dynamic_lookup") -endif(APPLE) -target_link_libraries(amarok_context_applet_albums - amarokcore - amaroklib - ${KDE4_PLASMA_LIBS} -) - -install(TARGETS amarok_context_applet_albums DESTINATION ${PLUGIN_INSTALL_DIR}) -install(FILES amarok-context-applet-albums.desktop DESTINATION ${SERVICES_INSTALL_DIR}) -install(FILES amarok-albums.svg DESTINATION ${DATA_INSTALL_DIR}/desktoptheme/default/widgets/ ) diff --git a/amarok/src/context/applets/albums/TrackItem.cpp b/amarok/src/context/applets/albums/TrackItem.cpp deleted file mode 100644 index 33ca532f..00000000 --- a/amarok/src/context/applets/albums/TrackItem.cpp +++ /dev/null @@ -1,120 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Seb Ruiz * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "TrackItem.h" - -#include "context/applets/albums/AlbumsDefs.h" -#include "core/meta/Meta.h" -#include "core/meta/support/MetaUtility.h" - -#include - -#include -#include - -TrackItem::TrackItem() - : QStandardItem() -{ - setEditable( false ); -} - -TrackItem::~TrackItem() -{ - QMutexLocker locker( &m_mutex ); - if( m_track ) - unsubscribeFrom( m_track ); -} - -void -TrackItem::setTrack( Meta::TrackPtr trackPtr ) -{ - if( m_track ) - unsubscribeFrom( m_track ); - m_track = trackPtr; - subscribeTo( m_track ); - - metadataChanged( m_track ); -} - -void -TrackItem::metadataChanged( Meta::TrackPtr track ) -{ - QMutexLocker locker( &m_mutex ); - if( !track ) - return; - - Meta::ArtistPtr artist = track->artist(); - Meta::AlbumPtr album = track->album(); - - setData( track->prettyName(), NameRole ); - setData( track->trackNumber(), TrackNumberRole ); - setData( track->length(), TrackLengthRole ); - - if( artist ) - setData( artist->prettyName(), TrackArtistRole ); - - if( album ) - { - setData( album->isCompilation(), AlbumCompilationRole ); - int num = 0; - foreach( const Meta::TrackPtr &track, album->tracks() ) - { - if( num < track->trackNumber() ) - num = track->trackNumber(); - } - setData( num, AlbumMaxTrackNumberRole ); - } - setToolTip( QString( "%1 (%2)" ).arg( track->name(), Meta::msToPrettyTime(track->length()) ) ); -} - -void -TrackItem::italicise() -{ - QFont f = font(); - f.setItalic( true ); - setFont( f ); -} - -void -TrackItem::bold() -{ - QFont f = font(); - f.setBold( true ); - setFont( f ); -} - -int -TrackItem::type() const -{ - return TrackType; -} - -bool -TrackItem::operator<( const QStandardItem &other ) const -{ - int trackA = data( TrackNumberRole ).toInt(); - int trackB = other.data( TrackNumberRole ).toInt(); - if( trackA < trackB ) - return true; - else if( trackA == trackB ) - { - const QString nameA = data( NameRole ).toString(); - const QString nameB = other.data( NameRole ).toString(); - return KStringHandler::naturalCompare( nameA, nameB, Qt::CaseInsensitive ) < 0; - } - else - return false; -} diff --git a/amarok/src/context/applets/albums/TrackItem.h b/amarok/src/context/applets/albums/TrackItem.h deleted file mode 100644 index 57ffbb55..00000000 --- a/amarok/src/context/applets/albums/TrackItem.h +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Seb Ruiz * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_TRACKITEM_H -#define AMAROK_TRACKITEM_H - -#include "core/meta/Observer.h" - -#include -#include - -class TrackItem : public QStandardItem, public Meta::Observer -{ - public: - TrackItem(); - ~TrackItem(); - - /** - * Sets the TrackPtr for this item to associate with - * - * @arg track pointer to associate with - */ - void setTrack( Meta::TrackPtr trackPtr ); - - /** - * @return the track pointer associated with this item - */ - Meta::TrackPtr track() const { return m_track; } - - /** - * Applies an italic style if the track is the currently - * playing track - */ - void italicise(); - - /** - * Applies a bold style if the track is owned by the currently - * playing artist - */ - void bold(); - - // overloaded from Meta::Observer - using Observer::metadataChanged; - virtual void metadataChanged( Meta::TrackPtr track ); - - virtual int type() const; - - virtual bool operator<( const QStandardItem &other ) const; - - private: - Meta::TrackPtr m_track; - QMutex m_mutex; -}; - -#endif // multiple inclusion guard diff --git a/amarok/src/context/applets/albums/amarok-albums.svg b/amarok/src/context/applets/albums/amarok-albums.svg deleted file mode 100644 index 91646e21..00000000 --- a/amarok/src/context/applets/albums/amarok-albums.svg +++ /dev/null @@ -1,252 +0,0 @@ - - -image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/amarok/src/context/applets/albums/amarok-context-applet-albums.desktop b/amarok/src/context/applets/albums/amarok-context-applet-albums.desktop deleted file mode 100644 index c9cc7297..00000000 --- a/amarok/src/context/applets/albums/amarok-context-applet-albums.desktop +++ /dev/null @@ -1,78 +0,0 @@ -[Desktop Entry] -Name=Albums -Name[be]=Альбомы -Name[bg]=Албуми -Name[bs]=Albumi -Name[ca]=Àlbums -Name[ca@valencia]=Àlbums -Name[cs]=Alba -Name[csb]=Albùmë -Name[da]=Albummer -Name[de]=Alben -Name[el]=Άλμπουμ -Name[en_GB]=Albums -Name[es]=Álbumes -Name[et]=Albumid -Name[eu]=Albumak -Name[fa]=آلبومها -Name[fi]=Albumit -Name[fr]=Albums -Name[ga]=Albaim -Name[gl]=Albuns -Name[he]=אלבומים -Name[hne]=एल्बम -Name[hu]=Albumok -Name[id]=Album -Name[is]=Plötur -Name[it]=Album -Name[ja]=アルバム -Name[km]=អាល់ប៊ុម -Name[ko]=앨범 -Name[ku]=Albûm -Name[lt]=Albumai -Name[lv]=Albūmi -Name[mr]=अल्बम्स -Name[ms]=Album -Name[nb]=Album -Name[nds]=Alben -Name[nl]=Albums -Name[nn]=Album -Name[oc]=Albums -Name[pa]=ਐਲਬਮ -Name[pl]=Albumy -Name[pt]=Álbuns -Name[pt_BR]=Álbuns -Name[ro]=Albume -Name[ru]=Альбомы -Name[sk]=Albumy -Name[sl]=Albumi -Name[sq]=Albumet -Name[sr]=Албуми -Name[sr@ijekavian]=Албуми -Name[sr@ijekavianlatin]=Albumi -Name[sr@latin]=Albumi -Name[sv]=Album -Name[th]=อัลบั้มต่าง ๆ -Name[tr]=Albümler -Name[ug]=ئالبوملار -Name[uk]=Альбоми -Name[wa]=Alboms -Name[x-test]=xxAlbumsxx -Name[zh_CN]=专辑 -Name[zh_TW]=專輯 -Type=Service -Icon=media-album-cover-manager-amarok -ServiceTypes=Plasma/Applet - -X-KDE-Library=amarok_context_applet_albums -X-KDE-PluginInfo-Author=Seb Ruiz -X-KDE-PluginInfo-Email=ruiz@kde.org -X-KDE-PluginInfo-Name=albums -X-KDE-PluginInfo-Version=pre0.1 -X-KDE-PluginInfo-Website= -X-KDE-PluginInfo-Depends= -X-KDE-PluginInfo-License=GPL -X-KDE-PluginInfo-EnabledByDefault=true -X-KDE-ParentApp=amarok -X-KDE-PluginInfo-Category=Current - diff --git a/amarok/src/context/applets/analyzer/ASCIIAnalyzer.cpp b/amarok/src/context/applets/analyzer/ASCIIAnalyzer.cpp deleted file mode 100644 index 280c8b21..00000000 --- a/amarok/src/context/applets/analyzer/ASCIIAnalyzer.cpp +++ /dev/null @@ -1,252 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2014 Matej Repinc * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 Pulic License for more details. * - * * - * You should have received a copy of the GNU General Public License along with * - * this program. If not, see . * - ****************************************************************************************/ - -#include "ASCIIAnalyzer.h" - -#include "PaletteHandler.h" - -#include - -#include -#include - - -ASCIIAnalyzer* ASCIIAnalyzer::instance = 0; - -ASCIIAnalyzer::ASCIIAnalyzer( QWidget *parent ) - : Analyzer::Base( parent ) - , m_columns( 0 ) //int - , m_rows( 0 ) //int -{ - instance = this; - setObjectName( "ASCII" ); - - setMaximumWidth( MAX_COLUMNS * ( BLOCK_WIDTH + 1 ) - 1 ); - setFps( 30 ); -} - -void -ASCIIAnalyzer::initializeGL() -{ - // Disable depth test (all is drawn on a 2d plane) - glDisable( GL_DEPTH_TEST ); -} - -void -ASCIIAnalyzer::resizeGL( int w, int h ) -{ - glViewport( 0, 0, (GLint)w, (GLint)h ); - - // Set up a 2D projection matrix - glMatrixMode( GL_PROJECTION ); - glLoadIdentity(); - glOrtho( 0.0, (GLdouble)w, (GLdouble)h, 0.0, 0.0, 1.0 ); - - const int oldRows = m_rows; - - // Rounded up so that the last column/line is covered if partially visible - m_columns = std::min( std::floor( (double)width() / ( BLOCK_WIDTH + 1 ) ), (double)MAX_COLUMNS ); - m_rows = std::ceil( (double)height() / ( BLOCK_HEIGHT + 1 ) ); - - m_scope.resize( m_columns ); - m_store.resize( m_columns ); - - if( m_rows != oldRows ) - { - m_barPixmap = QPixmap( BLOCK_WIDTH, m_rows * ( BLOCK_HEIGHT + 1 ) ); - - m_yscale.resize( m_rows + 1 ); - - const float PRE = 1, PRO = 1; //PRE and PRO allow us to restrict the range somewhat - - for( int z = 0; z < m_rows; ++z ) - m_yscale[z] = 1 - ( log10( PRE + z ) / log10( PRE + m_rows + PRO ) ); - - m_yscale[m_rows] = 0; - - determineStep(); - paletteChange( palette() ); - } - - drawBackground(); - analyze( m_scope ); -} - -void -ASCIIAnalyzer::determineStep() -{ - // Based on Mark Kretschmann's work in BlockAnalyzer - // falltime is dependent on rowcount due to our digital resolution (ie we have boxes/blocks of pixels) - // I calculated the value 50 based on some trial and error - - const double fallTime = 50 * m_rows; - m_step = double( m_rows * 80 ) / fallTime; //80 = ~milliseconds between signals with audio data -} - -void -ASCIIAnalyzer::transform( QVector &s ) //pure virtual -{ - // Based on Mark Kretschmann's work in BlockAnalyzer - for( int x = 0; x < s.size(); ++x ) - s[x] *= 2; - - float *front = static_cast( &s.front() ); - - m_fht->spectrum( front ); - m_fht->scale( front, 1.0 / 20 ); - - //the second half is pretty dull, so only show it if the user has a large analyzer - //by setting to m_scope.size() if large we prevent interpolation of large analyzers, this is good! - s.resize( m_scope.size() <= MAX_COLUMNS / 2 ? MAX_COLUMNS / 2 : m_scope.size() ); -} - -void -ASCIIAnalyzer::analyze( const QVector &s ) -{ - interpolate( s, m_scope ); -} - -void -ASCIIAnalyzer::paintGL() -{ - // Based largely on Mark Kretschmann's work in BlockAnalyzer, - // however a bit simplified since we don't need fancy transitions - // and textures. - // y = 2 3 2 1 0 2 - // . . . . # . - // . . . # # . - // # . # # # # - // # # # # # # - // - // visual aid for how this analyzer works. - // y represents the number of blanks - // y starts from the top and increases in units of blocks - - // m_yscale looks similar to: { 0.7, 0.5, 0.25, 0.15, 0.1, 0 } - // if it contains 6 elements there are 5 rows in the analyzer - - glMatrixMode( GL_MODELVIEW ); - glLoadIdentity(); - - // Paint the background - drawTexture( m_background.data(), 0, 0, 0, 0 ); - - for( uint y, x = 0; x < (uint)m_scope.size(); ++x ) - { - // determine y - for( y = 0; m_scope[x] < m_yscale[y]; ++y ) - ; - - // the higher the y, the lower the bar physically is. - if( ( float )y > m_store[x] ) - y = uint( m_store[x] += m_step ); - else - m_store[x] = y; - - // Don't draw top two #'s - y += 2; - - int xpos = x * ( BLOCK_WIDTH + 1 ); - // REMEMBER: y is a number from 0 to m_rows, 0 means all blocks are glowing, m_rows means none are - drawTexture( m_barTexture.data(), xpos, y * ( BLOCK_HEIGHT + 1 ), 0, y * ( BLOCK_HEIGHT + 1 ) ); - - // Draw second top bar to "ease" transition - int top_ypos = int( m_store[x] ) * ( BLOCK_HEIGHT + 1 ); - drawTexture( m_topSecondBarTexture.data(), xpos, top_ypos + BLOCK_HEIGHT + 1, 0, 0 ); - - // Draw top bar - drawTexture( m_topBarTexture.data(), xpos, top_ypos, 0, 0 ); - } -} - -void -ASCIIAnalyzer::drawTexture( Texture* texture, int x, int y, int sx, int sy ) -{ - const GLfloat xf = x; - const GLfloat yf = y; - const GLfloat wf = texture->size.width() - sx; - const GLfloat hf = texture->size.height() - sy; - const GLfloat sxf = (GLfloat)sx / texture->size.width(); - const GLfloat syf = (GLfloat)sy / texture->size.height(); - - glEnable( GL_TEXTURE_2D ); - glBindTexture( GL_TEXTURE_2D, texture->id ); - - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); - - // Draw a textured quad - glBegin(GL_QUADS); - glTexCoord2f( sxf, syf ); glVertex2f( xf, yf ); - glTexCoord2f( sxf, 1.0 ); glVertex2f( xf, yf + hf ); - glTexCoord2f( 1.0, 1.0 ); glVertex2f( xf + wf, yf + hf ); - glTexCoord2f( 1.0, syf ); glVertex2f( xf + wf, yf ); - glEnd(); - - glDisable( GL_TEXTURE_2D ); -} - -void -ASCIIAnalyzer::paletteChange( const QPalette& ) //virtual -{ - const QColor bg = palette().background().color(); - const QFont font ("Cantarell", 10); - - QPixmap topBar( BLOCK_WIDTH, BLOCK_HEIGHT ); - topBar.fill( bg ); - QPainter tbp ( &topBar ); - tbp.setPen(Qt::red); - tbp.setBackground(palette().background().color()); - tbp.setFont(font); - tbp.drawText(topBar.rect(), Qt::AlignCenter, "."); - m_topBarTexture = QSharedPointer( new Texture( topBar ) ); - - QPixmap topSecondBar( BLOCK_WIDTH, BLOCK_HEIGHT ); - // red on top, black on bottom - QLinearGradient gradient (BLOCK_WIDTH/2, 0, BLOCK_WIDTH/2, BLOCK_HEIGHT); - gradient.setColorAt(0.3, Qt::red); - gradient.setColorAt(1.0, Qt::darkGreen); - topSecondBar.fill( bg ); - QPainter tsbp ( &topSecondBar ); - tsbp.setPen( QPen(gradient, BLOCK_WIDTH) ); - tsbp.setBrush( gradient ); - tsbp.setFont(font); - tsbp.drawText(topSecondBar.rect(), Qt::AlignCenter, "o"); - m_topSecondBarTexture = QSharedPointer( new Texture( topSecondBar ) ); - - m_barPixmap.fill( bg ); - QPainter p( &m_barPixmap ); - p.setPen(Qt::darkGreen); - p.setFont(font); - - for( int y = 0; y < m_rows; ++y ) { - QRect rect (0, y * ( BLOCK_HEIGHT + 1 ), BLOCK_WIDTH, BLOCK_HEIGHT); - p.drawText(rect, Qt::AlignCenter, "#"); - } - - m_barTexture = QSharedPointer( new Texture( m_barPixmap ) ); - drawBackground(); -} - -void -ASCIIAnalyzer::drawBackground() -{ - const QColor bg = palette().background().color(); - QPixmap background( size() ); - background.fill( bg ); - - m_background = QSharedPointer( new Texture( background ) ); -} diff --git a/amarok/src/context/applets/analyzer/ASCIIAnalyzer.h b/amarok/src/context/applets/analyzer/ASCIIAnalyzer.h deleted file mode 100644 index d35b1769..00000000 --- a/amarok/src/context/applets/analyzer/ASCIIAnalyzer.h +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2014 Matej Repinc * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 Pulic License for more details. * - * * - * You should have received a copy of the GNU General Public License along with * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef ASCIIANALYZER_H -#define ASCIIANALYZER_H - -#include "AnalyzerBase.h" - -#include -#include -#include -#include - -class QMouseEvent; -class QPalette; -class QResizeEvent; - -class ASCIIAnalyzer : public Analyzer::Base -{ -public: - ASCIIAnalyzer( QWidget* ); - - static GLuint createTexture( const QImage &image ) { return instance->bindTexture( image ); } - static void freeTexture( GLuint id ) { instance->deleteTexture( id ); } - - // Signed ints because most of what we compare them against are ints - static const int BLOCK_HEIGHT = 12; - static const int BLOCK_WIDTH = 12; - static const int MIN_ROWS = 30; //arbitrary - static const int MIN_COLUMNS = 32; //arbitrary - static const int MAX_COLUMNS = 128; //must be 2**n - static const int FADE_SIZE = 90; - -protected: - virtual void initializeGL(); - virtual void paintGL(); - virtual void resizeGL( int w, int h ); - virtual void transform( QVector& ); - virtual void analyze( const QVector& ); - virtual void paletteChange( const QPalette& ); - - void drawBackground(); - void determineStep(); - -private: - struct Texture - { - Texture( const QPixmap &pixmap ) : - id( ASCIIAnalyzer::createTexture( pixmap.toImage().mirrored() ) ), // Flip texture vertically for OpenGL bottom-left coordinate system - size( pixmap.size() ) - {} - Texture( const Texture& texture ) - { - id = texture.id; - size = texture.size; - } - ~Texture() - { - ASCIIAnalyzer::freeTexture( id ); - } - - GLuint id; - QSize size; - }; - - void drawTexture( Texture* texture, int x, int y, int sx, int sy ); - - static ASCIIAnalyzer* instance; - - int m_columns, m_rows; //number of rows and columns of blocks - QPixmap m_barPixmap; - QVector m_scope; //so we don't create a vector every frame - QVector m_store; //current bar heights - QVector m_yscale; - - QSharedPointer m_barTexture; - QSharedPointer m_topBarTexture; - QSharedPointer m_topSecondBarTexture; - QSharedPointer m_background; - - float m_step; //rows to fall per frame -}; - -#endif diff --git a/amarok/src/context/applets/analyzer/AnalyzerApplet.cpp b/amarok/src/context/applets/analyzer/AnalyzerApplet.cpp deleted file mode 100644 index 3a62ad0e..00000000 --- a/amarok/src/context/applets/analyzer/AnalyzerApplet.cpp +++ /dev/null @@ -1,202 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2013 Mark Kretschmann * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "AnalyzerApplet" - -#include "AnalyzerApplet.h" - -#include "core/support/Amarok.h" - -#include "BallsAnalyzer.h" -#include "BlockAnalyzer.h" -#include "DiscoAnalyzer.h" -#include "ASCIIAnalyzer.h" - -#include -#include -#include - - -AnalyzerApplet::AnalyzerApplet( QObject* parent, const QVariantList& args ) - : Context::Applet( parent, args ) - , m_analyzer( 0 ) -{ - setHasConfigurationInterface( false ); - - connect( this, SIGNAL(geometryChanged()), SLOT(newGeometry()) ); -} - -AnalyzerApplet::~AnalyzerApplet() -{ - KConfigGroup config = Amarok::config( "Analyzer Applet" ); - config.writeEntry( "Height", (int)m_currentHeight ); - config.writeEntry( "Current Analyzer", m_analyzerName ); -} - -void -AnalyzerApplet::init() -{ - // Call the base implementation. - Context::Applet::init(); - - m_analyzerNames["Balls"] = i18nc( "Analyzer name", "Balls" ); - m_analyzerNames["Blocky"] = i18nc( "Analyzer name", "Blocky" ); - m_analyzerNames["Disco"] = i18nc( "Analyzer name", "Disco" ); - m_analyzerNames["ASCII"] = i18nc( "Analyzer name", "ASCII" ); - - KConfigGroup config = Amarok::config( "Analyzer Applet" ); - setNewHeight( (WidgetHeight)config.readEntry( "Height", int() ) ); - - setCurrentAnalyzer( config.readEntry( "Current Analyzer", "Blocky" ) ); -} - -void -AnalyzerApplet::newGeometry() // SLOT -{ - if( !m_analyzer ) - return; - - // Use the applet's geometry for showing the analyzer widget at the same position - QRect analyzerGeometry = geometry().toRect(); - - // Adjust widget geometry to keep the applet border intact - analyzerGeometry.adjust( +3, +3, -3, -3 ); - - m_analyzer->setGeometry( analyzerGeometry ); -} - -void -AnalyzerApplet::hideEvent( QHideEvent* ) -{ - m_analyzer->hide(); -} - -void -AnalyzerApplet::showEvent( QShowEvent* ) -{ - m_analyzer->show(); -} - -QList -AnalyzerApplet::contextualActions () -{ - QList actions; - QAction *action; - - QMenu *heightMenu = new QMenu( i18n( "Height" ), view() ); - actions << heightMenu->menuAction(); - - QActionGroup *heightActions = new QActionGroup( this ); - - action = heightMenu->addAction( i18nc( "Height of the Analyzer applet", "Tiny" ) ); - action->setCheckable( true ); - action->setChecked( m_currentHeight == Tiny ); - action->setActionGroup( heightActions ); - action->setData( (int)Tiny ); - connect( action, SIGNAL(triggered()), SLOT(heightActionTriggered()) ); - - action = heightMenu->addAction( i18nc( "Height of the Analyzer applet", "Small" ) ); - action->setCheckable( true ); - action->setChecked( m_currentHeight == Small ); - action->setActionGroup( heightActions ); - action->setData( (int)Small ); - connect( action, SIGNAL(triggered()), SLOT(heightActionTriggered()) ); - - action = heightMenu->addAction( i18nc( "Height of the Analyzer applet", "Medium" ) ); - action->setCheckable( true ); - action->setChecked( m_currentHeight == Medium ); - action->setActionGroup( heightActions ); - action->setData( (int)Medium ); - connect( action, SIGNAL(triggered()), SLOT(heightActionTriggered()) ); - - action = heightMenu->addAction( i18nc( "Height of the Analyzer applet", "Tall" ) ); - action->setCheckable( true ); - action->setChecked( m_currentHeight == Tall ); - action->setActionGroup( heightActions ); - action->setData( (int)Tall ); - connect( action, SIGNAL(triggered()), SLOT(heightActionTriggered()) ); - - action = new QAction( this ); - action->setSeparator( true ); - actions << action; - - QActionGroup *analyzerActions = new QActionGroup( this ); - connect( analyzerActions, SIGNAL(triggered(QAction*)), SLOT( analyzerAction(QAction*)) ); - - QMap::const_iterator i = m_analyzerNames.constBegin(); - while ( i != m_analyzerNames.constEnd() ) { - action = new QAction( i.value(), this ); - action->setData( i.key() ); - action->setCheckable( true ); - action->setChecked( m_analyzerName == i.key() ); - action->setActionGroup( analyzerActions ); - actions << action; - i++; - } - - return actions; -} - -void -AnalyzerApplet::setNewHeight( WidgetHeight height ) -{ - if( !( height == Tiny || height == Small || height == Medium || height == Tall ) ) - height = Default; - - setMinimumHeight( (int)height ); - m_currentHeight = height; -} - -void -AnalyzerApplet::heightActionTriggered() // SLOT -{ - QAction *action = static_cast( sender() ); - setNewHeight( static_cast( action->data().toInt() ) ); -} - -void -AnalyzerApplet::analyzerAction( QAction *action ) // SLOT -{ - setCurrentAnalyzer( action->data().toString() ); -} - -void -AnalyzerApplet::setCurrentAnalyzer( const QString &name ) -{ - if( m_analyzerName == name ) - return; - - delete m_analyzer; - - if( name == "Balls" ) - m_analyzer = new BallsAnalyzer( view()->viewport() ); - else if( name == "Disco" ) - m_analyzer = new DiscoAnalyzer( view()->viewport() ); - else if( name == "ASCII" ) - m_analyzer = new ASCIIAnalyzer( view()->viewport() ); - else - m_analyzer = new BlockAnalyzer( view()->viewport() ); // The default - - m_analyzerName = m_analyzer->objectName(); - m_analyzer->setToolTip( i18n( "Right-click to configure" ) ); - - connect( this, SIGNAL(appletDestroyed(Plasma::Applet*)), m_analyzer, SLOT(deleteLater()) ); - - newGeometry(); - m_analyzer->show(); -} - -#include "moc_AnalyzerApplet.cpp" diff --git a/amarok/src/context/applets/analyzer/AnalyzerApplet.h b/amarok/src/context/applets/analyzer/AnalyzerApplet.h deleted file mode 100644 index 886c014d..00000000 --- a/amarok/src/context/applets/analyzer/AnalyzerApplet.h +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2013 Mark Kretschmann * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef ANALYZER_APPLET_H -#define ANALYZER_APPLET_H - -#include "context/Applet.h" -#include "context/DataEngine.h" - - -class AnalyzerApplet : public Context::Applet -{ - Q_OBJECT - -public: - enum WidgetHeight { Tiny = 80, Small = 120, Medium = 170, Tall = 220, Default = Small }; - - AnalyzerApplet( QObject* parent, const QVariantList& args ); - virtual ~AnalyzerApplet(); - -public slots: - virtual void init(); - -private slots: - void newGeometry(); - void heightActionTriggered(); - void analyzerAction( QAction* ); - -private: - void hideEvent( QHideEvent* ); - void showEvent( QShowEvent* ); - void setNewHeight( WidgetHeight height ); - void setCurrentAnalyzer( const QString &name ); - QList contextualActions(); - - QWidget *m_analyzer; - QString m_analyzerName; - QMap m_analyzerNames; - WidgetHeight m_currentHeight; -}; - -AMAROK_EXPORT_APPLET( analyzer, AnalyzerApplet ) - -#endif diff --git a/amarok/src/context/applets/analyzer/AnalyzerBase.cpp b/amarok/src/context/applets/analyzer/AnalyzerBase.cpp deleted file mode 100644 index c3d94e29..00000000 --- a/amarok/src/context/applets/analyzer/AnalyzerBase.cpp +++ /dev/null @@ -1,229 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2003 Max Howell * - * Copyright (c) 2009 Martin Sandsmark * - * Copyright (c) 2013 Mark Kretschmann * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "AnalyzerBase.h" - -#include "core/support/Debug.h" -#include "EngineController.h" -#include "MainWindow.h" - -#include // interpolate() - -#include - -#include - - -// INSTRUCTIONS -// 1. reimplement analyze() -// 2. if you want to manipulate the scope, reimplement transform() - - -Analyzer::Base::Base( QWidget *parent ) - : QGLWidget( parent ) - , m_fht( new FHT( log2( EngineController::DATAOUTPUT_DATA_SIZE ) ) ) - , m_renderTimer( new QTimer( this ) ) - , m_demoTimer( new QTimer( this ) ) -{ - connect( EngineController::instance(), SIGNAL( playbackStateChanged() ), this, SLOT( playbackStateChanged() ) ); - - setFps( 60 ); // Default unless changed by subclass - m_demoTimer->setInterval( 33 ); // ~30 fps - - enableDemo( !EngineController::instance()->isPlaying() ); - -#ifdef Q_WS_X11 - connect( KWindowSystem::self(), SIGNAL( currentDesktopChanged( int ) ), this, SLOT( currentDesktopChanged() ) ); -#endif - - connect( m_renderTimer, SIGNAL( timeout() ), this, SLOT( updateGL() ) ); - - //initialize openGL context before managing GL calls - makeCurrent(); - - connectSignals(); -} - - -Analyzer::Base::~Base() -{ - delete m_fht; -} - -void -Analyzer::Base::connectSignals() -{ - DEBUG_BLOCK - - if( m_renderTimer->isActive() ) - return; - - connect( EngineController::instance(), SIGNAL( audioDataReady( const QMap > & ) ), - this, SLOT( processData( const QMap > & ) ) ); - connect( m_demoTimer, SIGNAL( timeout() ), this, SLOT( demo() ) ); - m_renderTimer->start(); -} - -void -Analyzer::Base::disconnectSignals() -{ - DEBUG_BLOCK - - disconnect( EngineController::instance(), SIGNAL( audioDataReady( const QMap > & ) ), - this, SLOT( processData( const QMap > & ) ) ); - m_demoTimer->disconnect( this ); - m_renderTimer->stop(); -} - -void -Analyzer::Base::currentDesktopChanged() -{ - // Optimization for X11/Linux desktops: - // Don't update the analyzer if Amarok is not on the active virtual desktop. - - if( The::mainWindow()->isOnCurrentDesktop() ) - connectSignals(); - else - disconnectSignals(); -} - -void -Analyzer::Base::playbackStateChanged() -{ - enableDemo( !EngineController::instance()->isPlaying() ); -} - -void -Analyzer::Base::enableDemo( bool enable ) -{ - enable ? m_demoTimer->start() : m_demoTimer->stop(); -} - -void -Analyzer::Base::hideEvent( QHideEvent * ) -{ - QTimer::singleShot( 0, this, SLOT( disconnectSignals() ) ); -} - -void -Analyzer::Base::showEvent( QShowEvent * ) -{ - QTimer::singleShot( 0, this, SLOT( connectSignals() ) ); -} - -void -Analyzer::Base::transform( QVector &scope ) //virtual -{ - //this is a standard transformation that should give - //an FFT scope that has bands for pretty analyzers - - float *front = static_cast( &scope.front() ); - - float* f = new float[ m_fht->size() ]; - m_fht->copy( &f[0], front ); - m_fht->logSpectrum( front, &f[0] ); - m_fht->scale( front, 1.0 / 20 ); - - scope.resize( m_fht->size() / 2 ); //second half of values are rubbish - delete [] f; -} - -void -Analyzer::Base::processData( const QMap > &thescope ) -{ - if( thescope.isEmpty() || thescope[Phonon::AudioDataOutput::LeftChannel].size() != m_fht->size() ) - return; - - QVector scope( m_fht->size() ); - - for( uint x = 0; ( int )x < m_fht->size(); ++x ) - { - if( thescope.size() == 1 ) // Mono - { - scope[x] = double( thescope[Phonon::AudioDataOutput::LeftChannel][x] ); - } - else // Anything > Mono is treated as Stereo - { - scope[x] = double( thescope[Phonon::AudioDataOutput::LeftChannel][x] - + thescope[Phonon::AudioDataOutput::RightChannel][x] ) - / ( 2 * ( 1 << 15 ) ); // Average between the channels - } - } - - transform( scope ); - analyze( scope ); -} - -void -Analyzer::Base::demo() //virtual -{ - static int t = 201; - - if( t > 300 ) - t = 1; //0 = wasted calculations - - if( t < 201 ) - { - QVector s( 512 ); - - const double dt = double( t ) / 200; - for( int i = 0; i < s.size(); ++i ) - s[i] = dt * ( sin( M_PI + ( i * M_PI ) / s.size() ) + 1.0 ); - - analyze( s ); - } - else - analyze( QVector( 1, 0 ) ); - - ++t; -} - -void -Analyzer::Base::interpolate( const QVector &inVec, QVector &outVec ) const -{ - double pos = 0.0; - const double step = ( double )inVec.size() / outVec.size(); - - for( int i = 0; i < outVec.size(); ++i, pos += step ) - { - const double error = pos - std::floor( pos ); - const unsigned long offset = ( unsigned long )pos; - - long indexLeft = offset + 0; - - if( indexLeft >= inVec.size() ) - indexLeft = inVec.size() - 1; - - long indexRight = offset + 1; - - if( indexRight >= inVec.size() ) - indexRight = inVec.size() - 1; - - outVec[i] = inVec[indexLeft ] * ( 1.0 - error ) + - inVec[indexRight] * error; - } -} - -void -Analyzer::Base::setFps( int fps ) -{ - m_renderTimer->setInterval( 1000 / fps ); -} - - -#include "moc_AnalyzerBase.cpp" diff --git a/amarok/src/context/applets/analyzer/AnalyzerBase.h b/amarok/src/context/applets/analyzer/AnalyzerBase.h deleted file mode 100644 index 0a2a81b1..00000000 --- a/amarok/src/context/applets/analyzer/AnalyzerBase.h +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2004 Max Howell * - * Copyright (c) 2009 Martin Sandsmark * - * Copyright (c) 2013 Mark Kretschmann * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef ANALYZERBASE_H -#define ANALYZERBASE_H - -#ifdef __FreeBSD__ -#include -#endif - -#include "fht.h" //stack allocated - -#include - -#include //included for convenience - -#include - - -namespace Analyzer -{ - -class Base : public QGLWidget -{ - Q_OBJECT - -protected: - Base( QWidget* ); - ~Base(); - - void interpolate( const QVector&, QVector& ) const; - - virtual void transform( QVector& ); - virtual void analyze( const QVector& ) = 0; - - void setFps( int fps ); - - FHT *m_fht; - QTimer *m_renderTimer; - -protected slots: - virtual void demo(); - -private slots: - void connectSignals(); - void disconnectSignals(); - void currentDesktopChanged(); - void processData( const QMap > &thescope ); - void playbackStateChanged(); - -private: - void enableDemo( bool enable ); - void hideEvent( QHideEvent* ); - void showEvent( QShowEvent* ); - - QTimer *m_demoTimer; -}; - - -} //END namespace Analyzer - - -#endif diff --git a/amarok/src/context/applets/analyzer/BallsAnalyzer.cpp b/amarok/src/context/applets/analyzer/BallsAnalyzer.cpp deleted file mode 100644 index 6b4512f4..00000000 --- a/amarok/src/context/applets/analyzer/BallsAnalyzer.cpp +++ /dev/null @@ -1,447 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2004 Enrico Ros * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "BallsAnalyzer.h" - -#include - -#include - -#include -#include -#include - - -inline float myfabsf( float f ) -{ - return f < 0.f ? -f : f; -} - - -class Ball -{ -public: - Ball() : x( drand48() - drand48() ), y( 1 - 2.0 * drand48() ), - z( drand48() ), vx( 0.0 ), vy( 0.0 ), vz( 0.0 ), - mass( 0.01 + drand48() / 10.0 ) - //,color( (float[3]) { 0.0, drand48()*0.5, 0.7 + drand48() * 0.3 } ) - { - //this is because GCC < 3.3 can't compile the above line, we aren't sure why though - color[0] = 0.0; color[1] = drand48() * 0.5; color[2] = 0.7 + drand48() * 0.3; - }; - - float x, y, z, vx, vy, vz, mass; - float color[3]; - - void updatePhysics( float dT ) - { - x += vx * dT; // position - y += vy * dT; // position - z += vz * dT; // position - if( y < -0.8 ) vy = myfabsf( vy ); - if( y > 0.8 ) vy = -myfabsf( vy ); - if( z < 0.1 ) vz = myfabsf( vz ); - if( z > 0.9 ) vz = -myfabsf( vz ); - vx += ( ( x > 0 ) ? 4.94 : -4.94 ) * dT; // G-force - vx *= ( 1 - 2.9 * dT ); // air friction - vy *= ( 1 - 2.9 * dT ); // air friction - vz *= ( 1 - 2.9 * dT ); // air friction - } -}; - -class Paddle -{ -public: - Paddle( float xPos ) : onLeft( xPos < 0 ), mass( 1.0 ), - X( xPos ), x( xPos ), vx( 0.0 ) {}; - - void updatePhysics( float dT ) - { - x += vx * dT; // posision - vx += ( 1300 * ( X - x ) / mass ) * dT; // elasticity - vx *= ( 1 - 4.0 * dT ); // air friction - } - - void renderGL() - { - glBegin( GL_TRIANGLE_STRIP ); - glColor3f( 0.0f, 0.1f, 0.3f ); - glVertex3f( x, -1.0f, 0.0 ); - glVertex3f( x, 1.0f, 0.0 ); - glColor3f( 0.1f, 0.2f, 0.6f ); - glVertex3f( x, -1.0f, 1.0 ); - glVertex3f( x, 1.0f, 1.0 ); - glEnd(); - } - - void bounce( Ball * ball ) - { - if( onLeft && ball->x < x ) - { - ball->vx = vx * mass / ( mass + ball->mass ) + myfabsf( ball->vx ); - ball->vy = ( drand48() - drand48() ) * 1.8; - ball->vz = ( drand48() - drand48() ) * 0.9; - ball->x = x; - } - else if( !onLeft && ball->x > x ) - { - ball->vx = vx * mass / ( mass + ball->mass ) - myfabsf( ball->vx ); - ball->vy = ( drand48() - drand48() ) * 1.8; - ball->vz = ( drand48() - drand48() ) * 0.9; - ball->x = x; - } - } - - void impulse( float strength ) - { - if( ( onLeft && strength > vx ) || ( !onLeft && strength < vx ) ) - vx += strength; - } - -private: - bool onLeft; - float mass, X, x, vx; -}; - - -BallsAnalyzer::BallsAnalyzer( QWidget *parent ): - Analyzer::Base( parent ) -{ - setObjectName( "Balls" ); - - m_ballTexture = bindTexture( QImage( KStandardDirs::locate( "data", "amarok/images/ball.png" ) ) ); - m_gridTexture = bindTexture( QImage( KStandardDirs::locate( "data", "amarok/images/grid.png" ) ) ); - - m_leftPaddle = new Paddle( -1.0 ); - m_rightPaddle = new Paddle( 1.0 ); - for( int i = 0; i < NUMBER_OF_BALLS; i++ ) - m_balls.append( new Ball() ); - - m_show.colorK = 0.0; - m_show.gridScrollK = 0.0; - m_show.gridEnergyK = 0.0; - m_show.camRot = 0.0; - m_show.camRoll = 0.0; - m_show.peakEnergy = 1.0; - m_frame.silence = true; - m_frame.energy = 0.0; - m_frame.dEnergy = 0.0; -} - -BallsAnalyzer::~BallsAnalyzer() -{ - deleteTexture( m_ballTexture ); - deleteTexture( m_gridTexture ); - delete m_leftPaddle; - delete m_rightPaddle; - - qDeleteAll( m_balls ); -} - -void BallsAnalyzer::initializeGL() -{ - // Set a smooth shade model - glShadeModel( GL_SMOOTH ); - - // Disable depth test (all is drawn 'z-sorted') - glDisable( GL_DEPTH_TEST ); - - // Set blending function (Alpha addition) - glBlendFunc( GL_SRC_ALPHA, GL_ONE ); - - // Clear frame with a black background - glClearColor( 0.0f, 0.0f, 0.0f, 1.0f ); -} - -void BallsAnalyzer::resizeGL( int w, int h ) -{ - // Setup screen. We're going to manually do the perspective projection - glViewport( 0, 0, ( GLint )w, ( GLint )h ); - glMatrixMode( GL_PROJECTION ); - glLoadIdentity(); - glFrustum( -0.5f, 0.5f, -0.5f, 0.5f, 0.5f, 4.5f ); - - // Get the aspect ratio of the screen to draw 'circular' particles - float ratio = ( float )w / ( float )h; - if( ratio >= 1.0 ) - { - m_unitX = 0.34 / ratio; - m_unitY = 0.34; - } - else - { - m_unitX = 0.34; - m_unitY = 0.34 * ratio; - } - - // Get current timestamp. - timeval tv; - gettimeofday( &tv, NULL ); - m_show.timeStamp = ( double )tv.tv_sec + ( double )tv.tv_usec / 1000000.0; -} - -void BallsAnalyzer::analyze( const QVector &s ) -{ - // compute the dTime since the last call - timeval tv; - gettimeofday( &tv, NULL ); - double currentTime = ( double )tv.tv_sec + ( double )tv.tv_usec / 1000000.0; - m_show.dT = currentTime - m_show.timeStamp; - m_show.timeStamp = currentTime; - - // compute energy integrating frame's spectrum - if( !s.empty() ) - { - int bands = s.size(); - float currentEnergy = 0, - maxValue = 0; - // integrate spectrum -> energy - for( int i = 0; i < bands; i++ ) - { - float value = s[i]; - currentEnergy += value; - if( value > maxValue ) - maxValue = value; - } - currentEnergy *= 100.0 / ( float )bands; - // emulate a peak detector: currentEnergy -> peakEnergy (3tau = 30 seconds) - m_show.peakEnergy = 1.0 + ( m_show.peakEnergy - 1.0 ) * exp( - m_show.dT / 10.0 ); - if( currentEnergy > m_show.peakEnergy ) - m_show.peakEnergy = currentEnergy; - // check for silence - m_frame.silence = currentEnergy < 0.001; - // normalize frame energy against peak energy and compute frame stats - currentEnergy /= m_show.peakEnergy; - m_frame.dEnergy = currentEnergy - m_frame.energy; - m_frame.energy = currentEnergy; - } - else - m_frame.silence = true; - - // limit max dT to 0.05 and update color and scroll constants - if( m_show.dT > 0.05 ) - m_show.dT = 0.05; - m_show.colorK += m_show.dT * 0.4; - if( m_show.colorK > 3.0 ) - m_show.colorK -= 3.0; - m_show.gridScrollK += 0.2 * m_show.peakEnergy * m_show.dT; - - // Roll camera up/down handling the beat - m_show.camRot += m_show.camRoll * m_show.dT; // posision - m_show.camRoll -= 400 * m_show.camRot * m_show.dT; // elasticity - m_show.camRoll *= ( 1 - 2.0 * m_show.dT ); // friction - if( !m_frame.silence && m_frame.dEnergy > 0.4 ) - m_show.camRoll += m_show.peakEnergy * 2.0; - - if( ( m_show.gridEnergyK > 0.05 ) || ( !m_frame.silence && m_frame.dEnergy < -0.3 ) ) - { - m_show.gridEnergyK *= exp( -m_show.dT / 0.1 ); - if( -m_frame.dEnergy > m_show.gridEnergyK ) - m_show.gridEnergyK = -m_frame.dEnergy * 2.0; - } - - foreach( Ball * ball, m_balls ) - { - ball->updatePhysics( m_show.dT ); - if( ball->x < 0 ) - m_leftPaddle->bounce( ball ); - else - m_rightPaddle->bounce( ball ); - } - - // Update physics of paddles - m_leftPaddle->updatePhysics( m_show.dT ); - m_rightPaddle->updatePhysics( m_show.dT ); - if( !m_frame.silence ) - { - m_leftPaddle->impulse( m_frame.energy * 3.0 + m_frame.dEnergy * 6.0 ); - m_rightPaddle->impulse( -m_frame.energy * 3.0 - m_frame.dEnergy * 6.0 ); - } -} - -void BallsAnalyzer::paintGL() -{ - // Switch to MODEL matrix and clear screen - glMatrixMode( GL_MODELVIEW ); - glLoadIdentity(); - glClear( GL_COLOR_BUFFER_BIT ); - - // Draw scrolling grid - float gridColor[4] = { 0.0, 1.0, 0.6, m_show.gridEnergyK }; - drawScrollGrid( m_show.gridScrollK, gridColor ); - - glRotatef( m_show.camRoll / 2.0, 1, 0, 0 ); - - // Translate the drawing plane - glTranslatef( 0.0f, 0.0f, -1.8f ); - - // Draw upper/lower planes and paddles - drawHFace( -1.0 ); - drawHFace( 1.0 ); - m_leftPaddle->renderGL(); - m_rightPaddle->renderGL(); - - // Draw Balls - if( m_ballTexture ) - { - glEnable( GL_TEXTURE_2D ); - glBindTexture( GL_TEXTURE_2D, m_ballTexture ); - } - else - glDisable( GL_TEXTURE_2D ); - - glEnable( GL_BLEND ); - - foreach( Ball * ball, m_balls ) - { - float color[3], - angle = m_show.colorK; - // Rotate the color based on 'angle' value [0,3) - if( angle < 1.0 ) - { - color[ 0 ] = ball->color[ 0 ] * ( 1 - angle ) + ball->color[ 1 ] * angle; - color[ 1 ] = ball->color[ 1 ] * ( 1 - angle ) + ball->color[ 2 ] * angle; - color[ 2 ] = ball->color[ 2 ] * ( 1 - angle ) + ball->color[ 0 ] * angle; - } - else if( angle < 2.0 ) - { - angle -= 1.0; - color[ 0 ] = ball->color[ 1 ] * ( 1 - angle ) + ball->color[ 2 ] * angle; - color[ 1 ] = ball->color[ 2 ] * ( 1 - angle ) + ball->color[ 0 ] * angle; - color[ 2 ] = ball->color[ 0 ] * ( 1 - angle ) + ball->color[ 1 ] * angle; - } - else - { - angle -= 2.0; - color[ 0 ] = ball->color[ 2 ] * ( 1 - angle ) + ball->color[ 0 ] * angle; - color[ 1 ] = ball->color[ 0 ] * ( 1 - angle ) + ball->color[ 1 ] * angle; - color[ 2 ] = ball->color[ 1 ] * ( 1 - angle ) + ball->color[ 2 ] * angle; - } - // Draw the dot and update its physics also checking at bounces - glColor3fv( color ); - drawDot3s( ball->x, ball->y, ball->z, 1.0 ); - } - glDisable( GL_BLEND ); - glDisable( GL_TEXTURE_2D ); -} - -void BallsAnalyzer::drawDot3s( float x, float y, float z, float size ) -{ - // Circular XY dot drawing functions - float sizeX = size * m_unitX, - sizeY = size * m_unitY, - pXm = x - sizeX, - pXM = x + sizeX, - pYm = y - sizeY, - pYM = y + sizeY; - // Draw the Dot - glBegin( GL_QUADS ); - glTexCoord2f( 0, 0 ); // Bottom Left - glVertex3f( pXm, pYm, z ); - glTexCoord2f( 0, 1 ); // Top Left - glVertex3f( pXm, pYM, z ); - glTexCoord2f( 1, 1 ); // Top Right - glVertex3f( pXM, pYM, z ); - glTexCoord2f( 1, 0 ); // Bottom Right - glVertex3f( pXM, pYm, z ); - glEnd(); - - // Shadow XZ drawing functions - float sizeZ = size / 10.0, - pZm = z - sizeZ, - pZM = z + sizeZ, - currentColor[4]; - glGetFloatv( GL_CURRENT_COLOR, currentColor ); - float alpha = currentColor[3], - topSide = ( y + 1 ) / 4, - bottomSide = ( 1 - y ) / 4; - // Draw the top shadow - currentColor[3] = topSide * topSide * alpha; - glColor4fv( currentColor ); - glBegin( GL_QUADS ); - glTexCoord2f( 0, 0 ); // Bottom Left - glVertex3f( pXm, 1, pZm ); - glTexCoord2f( 0, 1 ); // Top Left - glVertex3f( pXm, 1, pZM ); - glTexCoord2f( 1, 1 ); // Top Right - glVertex3f( pXM, 1, pZM ); - glTexCoord2f( 1, 0 ); // Bottom Right - glVertex3f( pXM, 1, pZm ); - glEnd(); - // Draw the bottom shadow - currentColor[3] = bottomSide * bottomSide * alpha; - glColor4fv( currentColor ); - glBegin( GL_QUADS ); - glTexCoord2f( 0, 0 ); // Bottom Left - glVertex3f( pXm, -1, pZm ); - glTexCoord2f( 0, 1 ); // Top Left - glVertex3f( pXm, -1, pZM ); - glTexCoord2f( 1, 1 ); // Top Right - glVertex3f( pXM, -1, pZM ); - glTexCoord2f( 1, 0 ); // Bottom Right - glVertex3f( pXM, -1, pZm ); - glEnd(); -} - -void BallsAnalyzer::drawHFace( float y ) -{ - glBegin( GL_TRIANGLE_STRIP ); - glColor3f( 0.0f, 0.1f, 0.2f ); - glVertex3f( -1.0f, y, 0.0 ); - glVertex3f( 1.0f, y, 0.0 ); - glColor3f( 0.1f, 0.6f, 0.5f ); - glVertex3f( -1.0f, y, 2.0 ); - glVertex3f( 1.0f, y, 2.0 ); - glEnd(); -} - -void BallsAnalyzer::drawScrollGrid( float scroll, float color[4] ) -{ - if( !m_gridTexture ) - return; - glMatrixMode( GL_TEXTURE ); - glLoadIdentity(); - glTranslatef( 0.0, -scroll, 0.0 ); - glMatrixMode( GL_MODELVIEW ); - float backColor[4] = { 1.0, 1.0, 1.0, 0.0 }; - for( int i = 0; i < 3; i++ ) - backColor[ i ] = color[ i ]; - glEnable( GL_TEXTURE_2D ); - glBindTexture( GL_TEXTURE_2D, m_gridTexture ); - glEnable( GL_BLEND ); - glBegin( GL_TRIANGLE_STRIP ); - glColor4fv( color ); // top face - glTexCoord2f( 0.0f, 1.0f ); - glVertex3f( -1.0f, 1.0f, -1.0f ); - glTexCoord2f( 1.0f, 1.0f ); - glVertex3f( 1.0f, 1.0f, -1.0f ); - glColor4fv( backColor ); // central points - glTexCoord2f( 0.0f, 0.0f ); - glVertex3f( -1.0f, 0.0f, -3.0f ); - glTexCoord2f( 1.0f, 0.0f ); - glVertex3f( 1.0f, 0.0f, -3.0f ); - glColor4fv( color ); // bottom face - glTexCoord2f( 0.0f, 1.0f ); - glVertex3f( -1.0f, -1.0f, -1.0f ); - glTexCoord2f( 1.0f, 1.0f ); - glVertex3f( 1.0f, -1.0f, -1.0f ); - glEnd(); - glDisable( GL_BLEND ); - glDisable( GL_TEXTURE_2D ); - glMatrixMode( GL_TEXTURE ); - glLoadIdentity(); - glMatrixMode( GL_MODELVIEW ); -} diff --git a/amarok/src/context/applets/analyzer/BallsAnalyzer.h b/amarok/src/context/applets/analyzer/BallsAnalyzer.h deleted file mode 100644 index f7d7365a..00000000 --- a/amarok/src/context/applets/analyzer/BallsAnalyzer.h +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2004 Enrico Ros * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef BALLS_ANALYZER_H -#define BALLS_ANALYZER_H - -#include "AnalyzerBase.h" - - -class QWidget; -class Ball; -class Paddle; - -class BallsAnalyzer : public Analyzer::Base -{ -public: - BallsAnalyzer( QWidget * ); - ~BallsAnalyzer(); - void analyze( const QVector & ); - -protected: - void initializeGL(); - void resizeGL( int w, int h ); - void paintGL(); - -private: - struct ShowProperties - { - double timeStamp; - double dT; - float colorK; - float gridScrollK; - float gridEnergyK; - float camRot; - float camRoll; - float peakEnergy; - } m_show; - - struct FrameProperties - { - bool silence; - float energy; - float dEnergy; - } m_frame; - - static const int NUMBER_OF_BALLS = 16; - - QList m_balls; - Paddle * m_leftPaddle, * m_rightPaddle; - float m_unitX, m_unitY; - GLuint m_ballTexture; - GLuint m_gridTexture; - - void drawDot3s( float x, float y, float z, float size ); - void drawHFace( float y ); - void drawScrollGrid( float scroll, float color[4] ); -}; - -#endif diff --git a/amarok/src/context/applets/analyzer/BlockAnalyzer.cpp b/amarok/src/context/applets/analyzer/BlockAnalyzer.cpp deleted file mode 100644 index b5f43065..00000000 --- a/amarok/src/context/applets/analyzer/BlockAnalyzer.cpp +++ /dev/null @@ -1,288 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2003-2005 Max Howell * - * Copyright (c) 2005-2013 Mark Kretschmann * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 Pulic License for more details. * - * * - * You should have received a copy of the GNU General Public License along with * - * this program. If not, see . * - ****************************************************************************************/ - -#include "BlockAnalyzer.h" - -#include "PaletteHandler.h" - -#include - -#include -#include - - -BlockAnalyzer* BlockAnalyzer::instance = 0; - -static inline uint myMax( uint v1, uint v2 ) -{ - return v1 > v2 ? v1 : v2; -} - -BlockAnalyzer::BlockAnalyzer( QWidget *parent ) - : Analyzer::Base( parent ) - , m_columns( 0 ) //int - , m_rows( 0 ) //int - , m_fade_bars( FADE_SIZE ) //vector - , m_fade_pos( MAX_COLUMNS, 50 ) //vector - , m_fade_intensity( MAX_COLUMNS, 32 ) //vector -{ - instance = this; - setObjectName( "Blocky" ); - - setMaximumWidth( MAX_COLUMNS * ( BLOCK_WIDTH + 1 ) - 1 ); - setFps( 50 ); -} - -void -BlockAnalyzer::initializeGL() -{ - // Disable depth test (all is drawn on a 2d plane) - glDisable( GL_DEPTH_TEST ); -} - -void -BlockAnalyzer::resizeGL( int w, int h ) -{ - glViewport( 0, 0, (GLint)w, (GLint)h ); - - // Set up a 2D projection matrix - glMatrixMode( GL_PROJECTION ); - glLoadIdentity(); - glOrtho( 0.0, (GLdouble)w, (GLdouble)h, 0.0, 0.0, 1.0 ); - - const int oldRows = m_rows; - - // Rounded up so that the last column/line is covered if partially visible - m_columns = std::min( std::ceil( (double)width() / ( BLOCK_WIDTH + 1 ) ), (double)MAX_COLUMNS ); - m_rows = std::ceil( (double)height() / ( BLOCK_HEIGHT + 1 ) ); - - m_scope.resize( m_columns ); - m_store.resize( m_columns ); - - if( m_rows != oldRows ) - { - m_barPixmap = QPixmap( BLOCK_WIDTH, m_rows * ( BLOCK_HEIGHT + 1 ) ); - - m_yscale.resize( m_rows + 1 ); - - const float PRE = 1, PRO = 1; //PRE and PRO allow us to restrict the range somewhat - - for( int z = 0; z < m_rows; ++z ) - m_yscale[z] = 1 - ( log10( PRE + z ) / log10( PRE + m_rows + PRO ) ); - - m_yscale[m_rows] = 0; - - determineStep(); - paletteChange( palette() ); - } - - drawBackground(); - analyze( m_scope ); -} - -void -BlockAnalyzer::determineStep() -{ - // falltime is dependent on rowcount due to our digital resolution (ie we have boxes/blocks of pixels) - // I calculated the value 30 based on some trial and error - - const double fallTime = 30 * m_rows; - m_step = double( m_rows * 80 ) / fallTime; //80 = ~milliseconds between signals with audio data -} - -void -BlockAnalyzer::transform( QVector &s ) //pure virtual -{ - for( int x = 0; x < s.size(); ++x ) - s[x] *= 2; - - float *front = static_cast( &s.front() ); - - m_fht->spectrum( front ); - m_fht->scale( front, 1.0 / 20 ); - - //the second half is pretty dull, so only show it if the user has a large analyzer - //by setting to m_scope.size() if large we prevent interpolation of large analyzers, this is good! - s.resize( m_scope.size() <= MAX_COLUMNS / 2 ? MAX_COLUMNS / 2 : m_scope.size() ); -} - -void -BlockAnalyzer::analyze( const QVector &s ) -{ - interpolate( s, m_scope ); -} - -void -BlockAnalyzer::paintGL() -{ - // y = 2 3 2 1 0 2 - // . . . . # . - // . . . # # . - // # . # # # # - // # # # # # # - // - // visual aid for how this analyzer works. - // y represents the number of blanks - // y starts from the top and increases in units of blocks - - // m_yscale looks similar to: { 0.7, 0.5, 0.25, 0.15, 0.1, 0 } - // if it contains 6 elements there are 5 rows in the analyzer - - glMatrixMode( GL_MODELVIEW ); - glLoadIdentity(); - - // Paint the background - drawTexture( m_background.data(), 0, 0, 0, 0 ); - - for( uint y, x = 0; x < (uint)m_scope.size(); ++x ) - { - // determine y - for( y = 0; m_scope[x] < m_yscale[y]; ++y ) - ; - - // this is opposite to what you'd think, higher than y - // means the bar is lower than y (physically) - if( ( float )y > m_store[x] ) - y = uint( m_store[x] += m_step ); - else - m_store[x] = y; - - // if y is lower than m_fade_pos, then the bar has exceeded the height of the fadeout - // if the fadeout is quite faded now, then display the new one - if( y <= m_fade_pos[x] /*|| m_fade_intensity[x] < FADE_SIZE / 3*/ ) - { - m_fade_pos[x] = y; - m_fade_intensity[x] = FADE_SIZE; - } - - if( m_fade_intensity[x] > 0 ) - { - const uint offset = --m_fade_intensity[x]; - const uint y = m_fade_pos[x] * ( BLOCK_HEIGHT + 1 ); - if( y < (uint)height() ) - drawTexture( m_fade_bars[offset].data(), x * ( BLOCK_WIDTH + 1 ), y, 0, 0 ); - } - - if( m_fade_intensity[x] == 0 ) - m_fade_pos[x] = m_rows; - - // REMEMBER: y is a number from 0 to m_rows, 0 means all blocks are glowing, m_rows means none are - drawTexture( m_barTexture.data(), x * ( BLOCK_WIDTH + 1 ), y * ( BLOCK_HEIGHT + 1 ), 0, y * ( BLOCK_HEIGHT + 1 ) ); - - // Draw top bar - drawTexture( m_topBarTexture.data(), x * ( BLOCK_WIDTH + 1 ), int( m_store[x] ) * ( BLOCK_HEIGHT + 1 ), 0, 0 ); - } -} - -void -BlockAnalyzer::drawTexture( Texture* texture, int x, int y, int sx, int sy ) -{ - const GLfloat xf = x; - const GLfloat yf = y; - const GLfloat wf = texture->size.width() - sx; - const GLfloat hf = texture->size.height() - sy; - const GLfloat sxf = (GLfloat)sx / texture->size.width(); - const GLfloat syf = (GLfloat)sy / texture->size.height(); - - glEnable( GL_TEXTURE_2D ); - glBindTexture( GL_TEXTURE_2D, texture->id ); - - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); - - // Draw a textured quad - glBegin(GL_QUADS); - glTexCoord2f( sxf, syf ); glVertex2f( xf, yf ); - glTexCoord2f( sxf, 1.0 ); glVertex2f( xf, yf + hf ); - glTexCoord2f( 1.0, 1.0 ); glVertex2f( xf + wf, yf + hf ); - glTexCoord2f( 1.0, syf ); glVertex2f( xf + wf, yf ); - glEnd(); - - glDisable( GL_TEXTURE_2D ); -} - -void -BlockAnalyzer::paletteChange( const QPalette& ) //virtual -{ - QPainter p( &m_barPixmap ); - - const QColor bg = The::paletteHandler()->backgroundColor(); - const QColor fg = palette().color( QPalette::Active, QPalette::Highlight ); - - QPixmap topBar( BLOCK_WIDTH, BLOCK_HEIGHT ); - topBar.fill( fg ); - m_topBarTexture = QSharedPointer( new Texture( topBar ) ); - - const double dr = 15 * double( bg.red() - fg.red() ) / ( m_rows * 16 ); - const double dg = 15 * double( bg.green() - fg.green() ) / ( m_rows * 16 ); - const double db = 15 * double( bg.blue() - fg.blue() ) / ( m_rows * 16 ); - const int r = fg.red(), g = fg.green(), b = fg.blue(); - - m_barPixmap.fill( bg ); - - for( int y = 0; y < m_rows; ++y ) - //graduate the fg color - p.fillRect( 0, y * ( BLOCK_HEIGHT + 1 ), BLOCK_WIDTH, BLOCK_HEIGHT, QColor( r + int( dr * y ), g + int( dg * y ), b + int( db * y ) ) ); - - { - const QColor bg = palette().color( QPalette::Active, QPalette::Window ).dark( 112 ); - - //make a complimentary fadebar colour - //TODO dark is not always correct, dumbo! - int h, s, v; palette().color( QPalette::Active, QPalette::Window ).dark( 150 ).getHsv( &h, &s, &v ); - const QColor fg = QColor::fromHsv( h + 60, s, v ); - - const double dr = fg.red() - bg.red(); - const double dg = fg.green() - bg.green(); - const double db = fg.blue() - bg.blue(); - const int r = bg.red(), g = bg.green(), b = bg.blue(); - - // Precalculate all fade-bar pixmaps - for( int y = 0; y < FADE_SIZE; ++y ) - { - QPixmap fadeBar( BLOCK_WIDTH, m_rows * ( BLOCK_HEIGHT + 1 ) ); - - fadeBar.fill( palette().color( QPalette::Active, QPalette::Window ) ); - const double Y = 1.0 - ( log10( ( FADE_SIZE ) - y ) / log10( ( FADE_SIZE ) ) ); - QPainter f( &fadeBar ); - for( int z = 0; z < m_rows; ++z ) - f.fillRect( 0, z * ( BLOCK_HEIGHT + 1 ), BLOCK_WIDTH, BLOCK_HEIGHT, QColor( r + int( dr * Y ), g + int( dg * Y ), b + int( db * Y ) ) ); - - m_fade_bars[y] = QSharedPointer( new Texture( fadeBar ) ); - } - } - - m_barTexture = QSharedPointer( new Texture( m_barPixmap ) ); - drawBackground(); -} - -void -BlockAnalyzer::drawBackground() -{ - const QColor bg = palette().color( QPalette::Active, QPalette::Window ); - const QColor bgdark = bg.dark( 112 ); - - QPixmap background( size() ); - background.fill( bg ); - - QPainter p( &background ); - for( int x = 0; x < m_columns; ++x ) - for( int y = 0; y < m_rows; ++y ) - p.fillRect( x * ( BLOCK_WIDTH + 1 ), y * ( BLOCK_HEIGHT + 1 ), BLOCK_WIDTH, BLOCK_HEIGHT, bgdark ); - - m_background = QSharedPointer( new Texture( background ) ); -} diff --git a/amarok/src/context/applets/analyzer/BlockAnalyzer.h b/amarok/src/context/applets/analyzer/BlockAnalyzer.h deleted file mode 100644 index df0506bb..00000000 --- a/amarok/src/context/applets/analyzer/BlockAnalyzer.h +++ /dev/null @@ -1,101 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2003-2005 Max Howell * - * Copyright (c) 2005-2013 Mark Kretschmann * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 Pulic License for more details. * - * * - * You should have received a copy of the GNU General Public License along with * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef BLOCKANALYZER_H -#define BLOCKANALYZER_H - -#include "AnalyzerBase.h" - -#include -#include -#include -#include - -class QMouseEvent; -class QPalette; -class QResizeEvent; - -class BlockAnalyzer : public Analyzer::Base -{ -public: - BlockAnalyzer( QWidget* ); - - static GLuint createTexture( const QImage &image ) { return instance->bindTexture( image ); } - static void freeTexture( GLuint id ) { instance->deleteTexture( id ); } - - // Signed ints because most of what we compare them against are ints - static const int BLOCK_HEIGHT = 2; - static const int BLOCK_WIDTH = 4; - static const int MIN_ROWS = 30; //arbitrary - static const int MIN_COLUMNS = 32; //arbitrary - static const int MAX_COLUMNS = 256; //must be 2**n - static const int FADE_SIZE = 90; - -protected: - virtual void initializeGL(); - virtual void paintGL(); - virtual void resizeGL( int w, int h ); - virtual void transform( QVector& ); - virtual void analyze( const QVector& ); - virtual void paletteChange( const QPalette& ); - - void drawBackground(); - void determineStep(); - -private: - struct Texture - { - Texture( const QPixmap &pixmap ) : - id( BlockAnalyzer::createTexture( pixmap.toImage().mirrored() ) ), // Flip texture vertically for OpenGL bottom-left coordinate system - size( pixmap.size() ) - {} - Texture( const Texture& texture ) - { - id = texture.id; - size = texture.size; - } - ~Texture() - { - BlockAnalyzer::freeTexture( id ); - } - - GLuint id; - QSize size; - }; - - void drawTexture( Texture* texture, int x, int y, int sx, int sy ); - - static BlockAnalyzer* instance; - - int m_columns, m_rows; //number of rows and columns of blocks - QPixmap m_barPixmap; - QVector m_scope; //so we don't create a vector every frame - QVector m_store; //current bar heights - QVector m_yscale; - - QSharedPointer m_barTexture; - QSharedPointer m_topBarTexture; - QSharedPointer m_background; - QVector> m_fade_bars; - - QVector m_fade_pos; - QVector m_fade_intensity; - - float m_step; //rows to fall per frame -}; - -#endif diff --git a/amarok/src/context/applets/analyzer/CMakeLists.txt b/amarok/src/context/applets/analyzer/CMakeLists.txt deleted file mode 100644 index 8f1bd0c4..00000000 --- a/amarok/src/context/applets/analyzer/CMakeLists.txt +++ /dev/null @@ -1,33 +0,0 @@ -project(context-analyzer) - -find_package(OpenGL REQUIRED) - -set(analyzer_SRCS - AnalyzerApplet.cpp - AnalyzerBase.cpp - BallsAnalyzer.cpp - BlockAnalyzer.cpp - DiscoAnalyzer.cpp - ASCIIAnalyzer.cpp - fht.cpp -) - -include_directories(${OPENGL_INCLUDE_DIR}) - -kde4_add_plugin(amarok_context_applet_analyzer ${analyzer_SRCS}) - -if(APPLE) - SET_TARGET_PROPERTIES(amarok_context_applet_analyzer PROPERTIES LINK_FLAGS "-undefined dynamic_lookup") -endif(APPLE) - - -target_link_libraries(amarok_context_applet_analyzer - amarokcore - amaroklib - ${KDE4_PLASMA_LIBS} - ${QT_QTOPENGL_LIBRARY} - ${OPENGL_gl_LIBRARY} -) - -install(TARGETS amarok_context_applet_analyzer DESTINATION ${PLUGIN_INSTALL_DIR}) -install(FILES amarok-context-applet-analyzer.desktop DESTINATION ${SERVICES_INSTALL_DIR}) diff --git a/amarok/src/context/applets/analyzer/DiscoAnalyzer.cpp b/amarok/src/context/applets/analyzer/DiscoAnalyzer.cpp deleted file mode 100644 index a81cde47..00000000 --- a/amarok/src/context/applets/analyzer/DiscoAnalyzer.cpp +++ /dev/null @@ -1,314 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2004 Enrico Ros * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "DiscoAnalyzer.h" - -#include -#include - -#include -#include -#include - - -DiscoAnalyzer::DiscoAnalyzer( QWidget *parent ): - Analyzer::Base( parent ) -{ - setObjectName( "Disco" ); - - m_dotTexture = bindTexture( QImage( KStandardDirs::locate( "data", "amarok/images/dot.png" ) ) ); - m_w1Texture = bindTexture( QImage( KStandardDirs::locate( "data", "amarok/images/wirl1.png" ) ) ); - m_w2Texture = bindTexture( QImage( KStandardDirs::locate( "data", "amarok/images/wirl2.png" ) ) ); - - m_show.paused = true; - m_show.pauseTimer = 0.0; - m_show.rotDegrees = 0.0; - m_frame.rotDegrees = 0.0; -} - -DiscoAnalyzer::~DiscoAnalyzer() -{ - deleteTexture( m_dotTexture ); - deleteTexture( m_w1Texture ); - deleteTexture( m_w2Texture ); -} - -void DiscoAnalyzer::demo() -{ - static int t = 0; - static bool forward = true; - - QVector s( 200 ); - const double dt = double( t ) / 200; - - for( int i = 0; i < s.size(); ++i ) - s[i] = dt * ( sin( M_PI + ( i * M_PI ) / s.size() ) + 1.0 ); - - analyze( s ); - - if( t == 0 ) - forward = true; - if( t == 200 ) - forward = false; - - t = forward ? t + 2 : t - 2; -} - -void DiscoAnalyzer::initializeGL() -{ - // Set a smooth shade model - glShadeModel( GL_SMOOTH ); - - // Disable depth test (all is drawn on a 2d plane) - glDisable( GL_DEPTH_TEST ); - - // Set blend parameters for 'composting alpha' - glBlendFunc( GL_SRC_ALPHA, GL_ONE ); //superpose - //glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); //fade - glEnable( GL_BLEND ); - - // Clear frame with a black background - glClearColor( 0.0f, 0.0f, 0.0f, 1.0f ); - glClear( GL_COLOR_BUFFER_BIT ); -} - -void DiscoAnalyzer::resizeGL( int w, int h ) -{ - // Setup screen. We're going to manually do the perspective projection - glViewport( 0, 0, ( GLint )w, ( GLint )h ); - glMatrixMode( GL_PROJECTION ); - glLoadIdentity(); - glOrtho( -10.0f, 10.0f, -10.0f, 10.0f, -5.0f, 5.0f ); - - // Get the aspect ratio of the screen to draw 'cicular' particles - const float ratio = ( float )w / ( float )h, - eqPixH = 60, - eqPixW = 80; - if( ratio >= ( 4.0 / 3.0 ) ) - { - m_unitX = 10.0 / ( eqPixH * ratio ); - m_unitY = 10.0 / eqPixH; - } - else - { - m_unitX = 10.0 / eqPixW; - m_unitY = 10.0 / ( eqPixW / ratio ); - } - - // Get current timestamp. - timeval tv; - gettimeofday( &tv, NULL ); - m_show.timeStamp = ( double )tv.tv_sec + ( double )tv.tv_usec / 1000000.0; -} - -void DiscoAnalyzer::analyze( const QVector &s ) -{ - bool haveNoData = s.empty(); - - // if we're going into pause mode, clear timers. - if( !m_show.paused && haveNoData ) - m_show.pauseTimer = 0.0; - - // if we have got data, interpolate it (asking myself why I'm doing it here..) - if( !( m_show.paused = haveNoData ) ) - { - int bands = s.size(), - lowbands = bands / 4, - hibands = bands / 3, - midbands = bands - lowbands - hibands; Q_UNUSED( midbands ); - float currentEnergy = 0, - currentMeanBand = 0, - maxValue = 0; - for( int i = 0; i < bands; i++ ) - { - float value = s[i]; - currentEnergy += value; - currentMeanBand += ( float )i * value; - if( value > maxValue ) - maxValue = value; - } - m_frame.silence = currentEnergy < 0.001; - if( !m_frame.silence ) - { - m_frame.meanBand = 100.0 * currentMeanBand / ( currentEnergy * bands ); - currentEnergy = 100.0 * currentEnergy / ( float )bands; - m_frame.dEnergy = currentEnergy - m_frame.energy; - m_frame.energy = currentEnergy; -// printf( "%d [%f :: %f ]\t%f \n", bands, frame.energy, frame.meanBand, maxValue ); - } - else - m_frame.energy = 0.0; - } -} - -void DiscoAnalyzer::paintGL() -{ - // Compute the dT since the last call to paintGL and update timings - timeval tv; - gettimeofday( &tv, NULL ); - double currentTime = ( double )tv.tv_sec + ( double )tv.tv_usec / 1000000.0; - m_show.dT = currentTime - m_show.timeStamp; - m_show.timeStamp = currentTime; - - // Clear frame - glClear( GL_COLOR_BUFFER_BIT ); - - // Shitch to MODEL matrix and reset it to default - glMatrixMode( GL_MODELVIEW ); - glLoadIdentity(); - - // Fade the previous drawings. - /* glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); - glBegin( GL_TRIANGLE_STRIP ); - glColor4f( 0.0f, 0.0f, 0.0f, 0.2f ); - glVertex2f( 10.0f, 10.0f ); - glVertex2f( -10.0f, 10.0f ); - glVertex2f( 10.0f, -10.0f ); - glVertex2f( -10.0f, -10.0f ); - glEnd();*/ - - glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); - glEnable( GL_TEXTURE_2D ); - float alphaN = m_show.paused ? 0.2 : ( m_frame.energy / 10.0 ), - alphaP = m_show.paused ? 1.0 : ( 1 - m_frame.energy / 20.0 ); - if( alphaN > 1.0 ) - alphaN = 1.0; - if( alphaP < 0.1 ) - alphaP = 0.1; - glBindTexture( GL_TEXTURE_2D, m_w2Texture ); - setTextureMatrix( m_show.rotDegrees, 0.707 * alphaP ); - glColor4f( 1.0f, 1.0f, 1.0f, 1.0f ); - glBegin( GL_TRIANGLE_STRIP ); - glTexCoord2f( 1.0, 1.0 ); - glVertex2f( 10.0f, 10.0f ); - glTexCoord2f( 0.0, 1.0 ); - glVertex2f( -10.0f, 10.0f ); - glTexCoord2f( 1.0, 0.0 ); - glVertex2f( 10.0f, -10.0f ); - glTexCoord2f( 0.0 , 0.0 ); - glVertex2f( -10.0f, -10.0f ); - glEnd(); - glBindTexture( GL_TEXTURE_2D, m_w1Texture ); - setTextureMatrix( -m_show.rotDegrees * 2, 0.707 ); - glColor4f( 1.0f, 1.0f, 1.0f, alphaN ); - glBegin( GL_TRIANGLE_STRIP ); - glTexCoord2f( 1.0, 1.0 ); - glVertex2f( 10.0f, 10.0f ); - glTexCoord2f( 0.0, 1.0 ); - glVertex2f( -10.0f, 10.0f ); - glTexCoord2f( 1.0, 0.0 ); - glVertex2f( 10.0f, -10.0f ); - glTexCoord2f( 0.0 , 0.0 ); - glVertex2f( -10.0f, -10.0f ); - glEnd(); - setTextureMatrix( 0.0, 0.0 ); - glDisable( GL_TEXTURE_2D ); - glBlendFunc( GL_SRC_ALPHA, GL_ONE ); - - // Here begins the real draw loop - // some updates to the showStruct - m_show.rotDegrees += 40.0 * m_show.dT; - m_frame.rotDegrees += 80.0 * m_show.dT; - - // handle the 'pause' status - if( m_show.paused ) - { - if( m_show.pauseTimer > 0.5 ) - { - if( m_show.pauseTimer > 0.6 ) - m_show.pauseTimer -= 0.6; - drawFullDot( 0.0f, 0.4f, 0.8f, 1.0f ); - drawFullDot( 0.0f, 0.4f, 0.8f, 1.0f ); - } - m_show.pauseTimer += m_show.dT; - return; - } - - if( m_dotTexture ) - { - glEnable( GL_TEXTURE_2D ); - glBindTexture( GL_TEXTURE_2D, m_dotTexture ); - } - else - glDisable( GL_TEXTURE_2D ); - - glLoadIdentity(); -// glRotatef( -frame.rotDegrees, 0,0,1 ); - glBegin( GL_QUADS ); -// Particle * particle = particleList.first(); -// for (; particle; particle = particleList.next()) - { - glColor4f( 0.0f, 1.0f, 0.0f, 1.0f ); - drawDot( 0, 0, qMax( 10.0, ( 10.0 * m_frame.energy ) ) ); - glColor4f( 1.0f, 0.0f, 0.0f, 1.0f ); - drawDot( 6, 0, qMax( 10.0, ( 5.0 * m_frame.energy ) ) ); - glColor4f( 0.0f, 0.4f, 1.0f, 1.0f ); - drawDot( -6, 0, qMax( 10.0, ( 5.0 * m_frame.energy ) ) ); - } - glEnd(); -} - -void DiscoAnalyzer::drawDot( float x, float y, float size ) -{ - float sizeX = size * m_unitX, - sizeY = size * m_unitY, - pLeft = x - sizeX, - pTop = y + sizeY, - pRight = x + sizeX, - pBottom = y - sizeY; - glTexCoord2f( 0, 0 ); // Bottom Left - glVertex2f( pLeft, pBottom ); - glTexCoord2f( 0, 1 ); // Top Left - glVertex2f( pLeft, pTop ); - glTexCoord2f( 1, 1 ); // Top Right - glVertex2f( pRight, pTop ); - glTexCoord2f( 1, 0 ); // Bottom Right - glVertex2f( pRight, pBottom ); -} - -void DiscoAnalyzer::drawFullDot( float r, float g, float b, float a ) -{ - glBindTexture( GL_TEXTURE_2D, m_dotTexture ); - glEnable( GL_TEXTURE_2D ); - glColor4f( r, g, b, a ); - glBegin( GL_TRIANGLE_STRIP ); - glTexCoord2f( 1.0, 1.0 ); - glVertex2f( 10.0f, 10.0f ); - glTexCoord2f( 0.0, 1.0 ); - glVertex2f( -10.0f, 10.0f ); - glTexCoord2f( 1.0, 0.0 ); - glVertex2f( 10.0f, -10.0f ); - glTexCoord2f( 0.0 , 0.0 ); - glVertex2f( -10.0f, -10.0f ); - glEnd(); - glDisable( GL_TEXTURE_2D ); -} - - -void DiscoAnalyzer::setTextureMatrix( float rot, float scale ) -{ - glMatrixMode( GL_TEXTURE ); - glLoadIdentity(); - if( rot != 0.0 || scale != 0.0 ) - { - glTranslatef( 0.5f, 0.5f, 0.0f ); - glRotatef( rot, 0.0f, 0.0f, 1.0f ); - glScalef( scale, scale, 1.0f ); - glTranslatef( -0.5f, -0.5f, 0.0f ); - } - glMatrixMode( GL_MODELVIEW ); -} - diff --git a/amarok/src/context/applets/analyzer/DiscoAnalyzer.h b/amarok/src/context/applets/analyzer/DiscoAnalyzer.h deleted file mode 100644 index d41b46ce..00000000 --- a/amarok/src/context/applets/analyzer/DiscoAnalyzer.h +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2004 Enrico Ros * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef DISCO_ANALYZER_H -#define DISCO_ANALYZER_H - - -#include "AnalyzerBase.h" - - -class QPaintEvent; - -class DiscoAnalyzer : public Analyzer::Base -{ -public: - DiscoAnalyzer( QWidget * ); - ~DiscoAnalyzer(); - void analyze( const QVector& ); - -protected: - void demo(); - void initializeGL(); - void resizeGL( int w, int h ); - void paintGL(); - -private: - struct ShowProperties - { - bool paused; - double timeStamp; - double dT; - double pauseTimer; - float rotDegrees; - } m_show; - - struct FrameProperties - { - float energy; - float dEnergy; - float meanBand; - float rotDegrees; - bool silence; - } m_frame; - - GLuint m_dotTexture; - GLuint m_w1Texture; - GLuint m_w2Texture; - float m_unitX, m_unitY; - - void drawDot( float x, float y, float size ); - void drawFullDot( float r, float g, float b, float a ); - void setTextureMatrix( float rot, float scale ); -}; - -#endif diff --git a/amarok/src/context/applets/analyzer/amarok-context-applet-analyzer.desktop b/amarok/src/context/applets/analyzer/amarok-context-applet-analyzer.desktop deleted file mode 100644 index 550c7451..00000000 --- a/amarok/src/context/applets/analyzer/amarok-context-applet-analyzer.desktop +++ /dev/null @@ -1,52 +0,0 @@ -[Desktop Entry] -Name=Analyzer -Name[bs]=Analizator -Name[ca]=Analitzador -Name[ca@valencia]=Analitzador -Name[cs]=Analyzátor -Name[da]=Analysator -Name[de]=Analysator -Name[el]=Αναλυτής -Name[en_GB]=Analyser -Name[es]=Analizador -Name[fi]=Analysaattori -Name[fr]=Analyseur -Name[gl]=Analizador -Name[hu]=Elemző -Name[id]=Analizer -Name[it]=Analizzatore -Name[lt]=Analizatorius -Name[lv]=Analizators -Name[nb]=Analysator -Name[nl]=Analysator -Name[pl]=Analizator -Name[pt]=Analisador -Name[pt_BR]=Analisador -Name[ro]=Analizator -Name[sk]=Analyzátor -Name[sl]=Preučevalnik -Name[sr]=Анализатор -Name[sr@ijekavian]=Анализатор -Name[sr@ijekavianlatin]=Analizator -Name[sr@latin]=Analizator -Name[sv]=Analysator -Name[tr]=Çözümleyici -Name[uk]=Аналізатор -Name[x-test]=xxAnalyzerxx -Name[zh_TW]=分析器 -Type=Service -Icon=view-media-analyzer-amarok -ServiceTypes=Plasma/Applet - -X-KDE-Library=amarok_context_applet_analyzer -X-KDE-PluginInfo-Author=Mark Kretschmann -X-KDE-PluginInfo-Email=kretschmann@kde.org -X-KDE-PluginInfo-Name=analyzer -X-KDE-PluginInfo-Version=1.0 -X-KDE-PluginInfo-Website= -X-KDE-PluginInfo-Depends= -X-KDE-PluginInfo-License=GPL -X-KDE-PluginInfo-EnabledByDefault=true -X-KDE-ParentApp=amarok -X-KDE-PluginInfo-Category=Current - diff --git a/amarok/src/context/applets/analyzer/fht.cpp b/amarok/src/context/applets/analyzer/fht.cpp deleted file mode 100644 index 7500261b..00000000 --- a/amarok/src/context/applets/analyzer/fht.cpp +++ /dev/null @@ -1,253 +0,0 @@ -// FHT - Fast Hartley Transform Class -// -// Copyright (C) 2004 Melchior FRANZ - mfranz@kde.org -// -// This program 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 2 of the -// License, or (at your option) any later version. -// -// This program 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 this program; if not, write to the Free Software -// Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -// -// $Id: fht.cpp 871912 2008-10-16 02:27:10Z mitchell $ - - -#include "fht.h" - -#include -#include - -FHT::FHT( int n ) : - m_buf( 0 ), - m_tab( 0 ), - m_log( 0 ) -{ - if( n < 3 ) - { - m_num = 0; - m_exp2 = -1; - return; - } - m_exp2 = n; - m_num = 1 << n; - if( n > 3 ) - { - m_buf = new float[m_num]; - m_tab = new float[m_num * 2]; - makeCasTable(); - } -} - - -FHT::~FHT() -{ - delete[] m_buf; - delete[] m_tab; - delete[] m_log; -} - - -void FHT::makeCasTable( void ) -{ - float d, *costab, *sintab; - int ul, ndiv2 = m_num / 2; - - for( costab = m_tab, sintab = m_tab + m_num / 2 + 1, ul = 0; ul < m_num; ul++ ) - { - d = M_PI * ul / ndiv2; - *costab = *sintab = cos( d ); - - costab += 2, sintab += 2; - if( sintab > m_tab + m_num * 2 ) - sintab = m_tab + 1; - } -} - - -float* FHT::copy( float *d, float *s ) -{ - return ( float * )memcpy( d, s, m_num * sizeof( float ) ); -} - - -float* FHT::clear( float *d ) -{ - return ( float * )memset( d, 0, m_num * sizeof( float ) ); -} - - -void FHT::scale( float *p, float d ) -{ - for( int i = 0; i < ( m_num / 2 ); i++ ) - *p++ *= d; -} - - -void FHT::ewma( float *d, float *s, float w ) -{ - for( int i = 0; i < ( m_num / 2 ); i++, d++, s++ ) - *d = *d * w + *s * ( 1 - w ); -} - - -void FHT::logSpectrum( float *out, float *p ) -{ - int n = m_num / 2, i, j, k, *r; - if( !m_log ) - { - m_log = new int[n]; - float f = n / log10( ( double )n ); - for( i = 0, r = m_log; i < n; i++, r++ ) - { - j = int( rint( log10( i + 1.0 ) * f ) ); - *r = j >= n ? n - 1 : j; - } - } - semiLogSpectrum( p ); - *out++ = *p = *p / 100; - for( k = i = 1, r = m_log; i < n; ++i ) - { - j = *r++; - if( i == j ) - *out++ = p[i]; - else - { - float base = p[k - 1]; - float step = ( p[j] - base ) / ( j - ( k - 1 ) ); - for( float corr = 0; k <= j; k++, corr += step ) - * out++ = base + corr; - } - } -} - - -void FHT::semiLogSpectrum( float *p ) -{ - float e; - power2( p ); - for( int i = 0; i < ( m_num / 2 ); i++, p++ ) - { - e = 10.0 * log10( sqrt( *p * .5 ) ); - *p = e < 0 ? 0 : e; - } -} - - -void FHT::spectrum( float *p ) -{ - power2( p ); - for( int i = 0; i < ( m_num / 2 ); i++, p++ ) - *p = ( float )sqrt( *p * .5 ); -} - - -void FHT::power( float *p ) -{ - power2( p ); - for( int i = 0; i < ( m_num / 2 ); i++ ) - *p++ *= .5; -} - - -void FHT::power2( float *p ) -{ - int i; - float *q; - _transform( p, m_num, 0 ); - - *p = ( *p * *p ), *p += *p, p++; - - for( i = 1, q = p + m_num - 2; i < ( m_num / 2 ); i++, --q ) - *p = ( *p * *p ) + ( *q * *q ), p++; -} - - -void FHT::transform( float *p ) -{ - if( m_num == 8 ) - transform8( p ); - else - _transform( p, m_num, 0 ); -} - - -void FHT::transform8( float *p ) -{ - float a, b, c, d, e, f, g, h, b_f2, d_h2; - float a_c_eg, a_ce_g, ac_e_g, aceg, b_df_h, bdfh; - - a = *p++, b = *p++, c = *p++, d = *p++; - e = *p++, f = *p++, g = *p++, h = *p; - b_f2 = ( b - f ) * M_SQRT2; - d_h2 = ( d - h ) * M_SQRT2; - - a_c_eg = a - c - e + g; - a_ce_g = a - c + e - g; - ac_e_g = a + c - e - g; - aceg = a + c + e + g; - - b_df_h = b - d + f - h; - bdfh = b + d + f + h; - - *p = a_c_eg - d_h2; - *--p = a_ce_g - b_df_h; - *--p = ac_e_g - b_f2; - *--p = aceg - bdfh; - *--p = a_c_eg + d_h2; - *--p = a_ce_g + b_df_h; - *--p = ac_e_g + b_f2; - *--p = aceg + bdfh; -} - - -void FHT::_transform( float *p, int n, int k ) -{ - if( n == 8 ) - { - transform8( p + k ); - return; - } - - int i, j, ndiv2 = n / 2; - float a, *t1, *t2, *t3, *t4, *ptab, *pp; - - for( i = 0, t1 = m_buf, t2 = m_buf + ndiv2, pp = &p[k]; i < ndiv2; i++ ) - *t1++ = *pp++, *t2++ = *pp++; - - memcpy( p + k, m_buf, sizeof( float ) * n ); - - _transform( p, ndiv2, k ); - _transform( p, ndiv2, k + ndiv2 ); - - j = m_num / ndiv2 - 1; - t1 = m_buf; - t2 = t1 + ndiv2; - t3 = p + k + ndiv2; - ptab = m_tab; - pp = p + k; - - a = *ptab++ * *t3++; - a += *ptab * *pp; - ptab += j; - - *t1++ = *pp + a; - *t2++ = *pp++ - a; - - for( i = 1, t4 = p + k + n; i < ndiv2; i++, ptab += j ) - { - a = *ptab++ * *t3++; - a += *ptab * *--t4; - - *t1++ = *pp + a; - *t2++ = *pp++ - a; - } - memcpy( p + k, m_buf, sizeof( float ) * n ); -} - diff --git a/amarok/src/context/applets/analyzer/fht.h b/amarok/src/context/applets/analyzer/fht.h deleted file mode 100644 index 9516f7ad..00000000 --- a/amarok/src/context/applets/analyzer/fht.h +++ /dev/null @@ -1,125 +0,0 @@ -// FHT - Fast Hartley Transform Class -// -// Copyright (C) 2004 Melchior FRANZ - mfranz@kde.org -// -// This program 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 2 of the -// License, or (at your option) any later version. -// -// This program 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 this program; if not, write to the Free Software -// Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -// -// $Id: fht.h 668973 2007-05-28 08:55:15Z mkossick $ - -#ifndef FHT_H -#define FHT_H - -/** - * Implementation of the Hartley Transform after Bracewell's discrete - * algorithm. The algorithm is subject to US patent No. 4,646,256 (1987) - * but was put into public domain by the Board of Trustees of Stanford - * University in 1994 and is now freely available[1]. - * - * [1] Computer in Physics, Vol. 9, No. 4, Jul/Aug 1995 pp 373-379 - */ -class FHT -{ - int m_exp2; - int m_num; - float *m_buf; - float *m_tab; - int *m_log; - - /** - * Create a table of "cas" (cosine and sine) values. - * Has only to be done in the constructor and saves from - * calculating the same values over and over while transforming. - */ - void makeCasTable(); - - /** - * Recursive in-place Hartley transform. For internal use only! - */ - void _transform( float *, int, int ); - -public: - /** - * Prepare transform for data sets with @f$2^n@f$ numbers, whereby @f$n@f$ - * should be at least 3. Values of more than 3 need a trigonometry table. - * @see makeCasTable() - */ - FHT( int ); - - ~FHT(); - inline int sizeExp() const - { - return m_exp2; - } - inline int size() const - { - return m_num; - } - float *copy( float *, float * ); - float *clear( float * ); - void scale( float *, float ); - - /** - * Exponentially Weighted Moving Average (EWMA) filter. - * @param d is the filtered data. - * @param s is fresh input. - * @param w is the weighting factor. - */ - void ewma( float *d, float *s, float w ); - - /** - * Logarithmic audio spectrum. Maps semi-logarithmic spectrum - * to logarithmic frequency scale, interpolates missing values. - * A logarithmic index map is calculated at the first run only. - * @param p is the input array. - * @param out is the spectrum. - */ - void logSpectrum( float *out, float *p ); - - /** - * Semi-logarithmic audio spectrum. - */ - void semiLogSpectrum( float * ); - - /** - * Fourier spectrum. - */ - void spectrum( float * ); - - /** - * Calculates a mathematically correct FFT power spectrum. - * If further scaling is applied later, use power2 instead - * and factor the 0.5 in the final scaling factor. - * @see FHT::power2() - */ - void power( float * ); - - /** - * Calculates an FFT power spectrum with doubled values as a - * result. The values need to be multiplied by 0.5 to be exact. - * Note that you only get @f$2^{n-1}@f$ power values for a data set - * of @f$2^n@f$ input values. This is the fastest transform. - * @see FHT::power() - */ - void power2( float * ); - - /** - * Discrete Hartley transform of data sets with 8 values. - */ - void transform8( float * ); - - void transform( float * ); -}; - -#endif diff --git a/amarok/src/context/applets/currenttrack/CMakeLists.txt b/amarok/src/context/applets/currenttrack/CMakeLists.txt deleted file mode 100644 index 55b208b5..00000000 --- a/amarok/src/context/applets/currenttrack/CMakeLists.txt +++ /dev/null @@ -1,28 +0,0 @@ -project(context-currenttrack) - -include_directories( - ${Amarok_SOURCE_DIR}/src/context/widgets - ${Amarok_SOURCE_DIR}/src/core-impl/collections/support - ${Amarok_SOURCE_DIR}/src - ) - -set(currenttrack_SRCS - CurrentTrack.cpp - ${Amarok_SOURCE_DIR}/src/context/widgets/RecentlyPlayedListWidget.cpp - ${Amarok_SOURCE_DIR}/src/widgets/PixmapViewer.cpp - currentTrackSettings.ui -) - -kde4_add_plugin(amarok_context_applet_currenttrack ${currenttrack_SRCS}) -if(APPLE) - SET_TARGET_PROPERTIES(amarok_context_applet_currenttrack PROPERTIES LINK_FLAGS "-undefined dynamic_lookup") -endif(APPLE) -target_link_libraries(amarok_context_applet_currenttrack - amarokcore - amaroklib - ${KDE4_PLASMA_LIBS} -) - -install(TARGETS amarok_context_applet_currenttrack DESTINATION ${PLUGIN_INSTALL_DIR}) -install(FILES amarok-context-applet-currenttrack.desktop DESTINATION ${SERVICES_INSTALL_DIR}) -install(FILES amarok-currenttrack.svg DESTINATION ${DATA_INSTALL_DIR}/desktoptheme/default/widgets/ ) diff --git a/amarok/src/context/applets/currenttrack/CurrentTrack.cpp b/amarok/src/context/applets/currenttrack/CurrentTrack.cpp deleted file mode 100644 index 4ec96e53..00000000 --- a/amarok/src/context/applets/currenttrack/CurrentTrack.cpp +++ /dev/null @@ -1,920 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007-2009 Leo Franchi * - * Copyright (c) 2008 William Viana Soares * - * Copyright (c) 2009 simon.esneault * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "CurrentTrack" - -#include "CurrentTrack.h" - -#include "App.h" -#include "EngineController.h" -#include "GlobalCurrentTrackActions.h" -#include "MainWindow.h" -#include "PaletteHandler.h" -#include "PluginManager.h" -#include "SvgHandler.h" -#include "amarokurls/AmarokUrl.h" -#include "context/widgets/RatingWidget.h" -#include "context/widgets/TextScrollingWidget.h" -#include "context/widgets/DropPixmapItem.h" -#include "context/widgets/RecentlyPlayedListWidget.h" -#include "core/capabilities/ActionsCapability.h" -#include "core/capabilities/BookmarkThisCapability.h" -#include "core/capabilities/FindInSourceCapability.h" -#include "core/support/Amarok.h" -#include "core/support/Debug.h" -#include "core/meta/Meta.h" -#include "core/meta/Statistics.h" -#include "core/meta/TrackEditor.h" -#include "core/meta/support/MetaUtility.h" -#include "core-impl/collections/support/CollectionManager.h" -#include "covermanager/CoverViewDialog.h" -#include "dialogs/TagDialog.h" - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -CurrentTrack::CurrentTrack( QObject* parent, const QVariantList& args ) - : Context::Applet( parent, args ) - , m_actionsLayout( 0 ) - , m_findInSourceSignalMapper( 0 ) - , m_rating( -1 ) - , m_score( 0 ) - , m_trackLength( 0 ) - , m_playCount( 0 ) - , m_trackCount( 0 ) - , m_albumCount( 0 ) - , m_artistCount( 0 ) - , m_isStopped( true ) - , m_coverKey( 0 ) - , m_view( Stopped ) - , m_showEditTrackDetailsAction( true ) - , m_albumWidth( 135 ) -{ - setHasConfigurationInterface( true ); - setBackgroundHints( Plasma::Applet::NoBackground ); -} - -CurrentTrack::~CurrentTrack() -{ - clearTrackActions(); - delete m_albumCover; -} - -void -CurrentTrack::init() -{ - DEBUG_BLOCK - PERF_LOG( "Begin init" ); - - // Call the base implementation. - Context::Applet::init(); - - setToolTip( i18n( "Right-click to configure" ) ); - - m_ratingWidget = new RatingWidget( this ); - m_ratingWidget->setSpacing( 2 ); - m_ratingWidget->setMinimumSize( m_albumWidth + 10, 30 ); - m_ratingWidget->setMaximumSize( m_albumWidth + 10, 30 ); - connect( m_ratingWidget, SIGNAL(ratingChanged(int)), SLOT(trackRatingChanged(int)) ); - - QLabel *collectionLabel = new QLabel( i18n( "Local Collection" ) ); - collectionLabel->setAttribute( Qt::WA_NoSystemBackground ); - collectionLabel->setAlignment( Qt::AlignCenter ); - m_collectionLabel = new QGraphicsProxyWidget( this ); - m_collectionLabel->setWidget( collectionLabel ); - - m_title = new TextScrollingWidget( this ); - m_artist = new TextScrollingWidget( this ); - m_album = new TextScrollingWidget( this ); - m_byText = new QGraphicsSimpleTextItem( i18nc( "What artist is this track by", "By" ), this ); - m_onText = new QGraphicsSimpleTextItem( i18nc( "What album is this track on", "On" ), this ); - - m_recentWidget = new RecentlyPlayedListWidget( this ); - m_recentHeader = new TextScrollingWidget( this ); - m_recentHeader->setDrawBackground( true ); - m_recentHeader->setAlignment( Qt::AlignLeft ); - QFont recentHeaderFont; - recentHeaderFont.setPointSize( recentHeaderFont.pointSize() + 2 ); - m_recentHeader->setFont( recentHeaderFont ); - - m_title->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); - m_artist->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); - m_album->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); - m_collectionLabel->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); - m_recentHeader->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); - m_recentWidget->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); - m_recentWidget->setMinimumHeight( 10 ); - - m_albumCover = new DropPixmapLayoutItem( this ); - m_albumCover->setPreferredSize( QSizeF( m_albumWidth, m_albumWidth ) ); - connect( m_albumCover, SIGNAL(imageDropped(QPixmap)), SLOT(coverDropped(QPixmap)) ); - - const QBrush brush = normalBrush(); - m_title->setBrush( brush ); - m_artist->setBrush( brush ); - m_album->setBrush( brush ); - m_byText->setBrush( brush ); - m_onText->setBrush( brush ); - - const QFont tinyFont = KGlobalSettings::smallestReadableFont(); - m_byText->setFont( tinyFont ); - m_onText->setFont( tinyFont ); - - m_actionsLayout = new QGraphicsLinearLayout; - m_actionsLayout->setMinimumWidth( 10 ); - m_actionsLayout->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); - QGraphicsLinearLayout *titlesLayout = new QGraphicsLinearLayout( Qt::Vertical ); - titlesLayout->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); - titlesLayout->setMinimumWidth( 10 ); - titlesLayout->setSpacing( 2 ); - titlesLayout->addItem( m_title ); - titlesLayout->addItem( m_artist ); - titlesLayout->addItem( m_album ); - titlesLayout->addItem( m_actionsLayout ); - titlesLayout->setItemSpacing( 2, 4 ); // a bit more spacing for the actions row - - const qreal pad = standardPadding(); - QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout( this ); - l->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); - l->addCornerAnchors( m_ratingWidget, Qt::BottomLeftCorner, l, Qt::BottomLeftCorner ); - l->addCornerAnchors( m_ratingWidget, Qt::BottomLeftCorner, m_collectionLabel, Qt::BottomLeftCorner ); - l->addCornerAnchors( m_ratingWidget, Qt::TopRightCorner, m_collectionLabel, Qt::TopRightCorner ); - l->addCornerAnchors( m_recentHeader, Qt::TopRightCorner, l, Qt::TopRightCorner ); - l->addAnchor( m_albumCover, Qt::AnchorBottom, m_ratingWidget, Qt::AnchorTop )->setSpacing( 4 ); - l->addAnchor( m_albumCover, Qt::AnchorHorizontalCenter, m_ratingWidget, Qt::AnchorHorizontalCenter ); - l->addAnchor( titlesLayout, Qt::AnchorTop, l, Qt::AnchorTop )->setSpacing( 18 ); - l->addAnchor( titlesLayout, Qt::AnchorRight, l, Qt::AnchorRight )->setSpacing( pad ); - l->addAnchors( m_recentWidget, m_recentHeader, Qt::Horizontal ); - l->addAnchor( m_recentWidget, Qt::AnchorTop, m_recentHeader, Qt::AnchorBottom ); - l->addAnchor( m_recentWidget, Qt::AnchorRight, m_recentHeader, Qt::AnchorRight ); - l->addAnchor( m_recentWidget, Qt::AnchorLeft, m_ratingWidget, Qt::AnchorRight )->setSpacing( pad * 2 ); - l->addAnchor( m_recentWidget, Qt::AnchorBottom, m_albumCover, Qt::AnchorBottom )->setSpacing( 20 ); - qreal midSpacing = qMax( m_byText->boundingRect().width(), m_onText->boundingRect().width() ) + pad; - l->addAnchor( titlesLayout, Qt::AnchorLeft, m_ratingWidget, Qt::AnchorRight )->setSpacing( midSpacing ); - l->anchor( m_recentHeader, Qt::AnchorTop, l, Qt::AnchorTop )->setSpacing( 2 ); - - // Read config - KConfigGroup config = Amarok::config("Current Track Applet"); - const QString fontDesc = config.readEntry( "Font", QString() ); - QFont font; - if( !fontDesc.isEmpty() ) - font.fromString( fontDesc ); - else - font.setPointSize( font.pointSize() + 3 ); - - m_showEditTrackDetailsAction = config.readEntry( "ShowEditTrackAction", true ); - - m_title->setFont( font ); - m_artist->setFont( font ); - m_album->setFont( font ); - - m_title->setAlignment( Qt::AlignLeft ); - m_artist->setAlignment( Qt::AlignLeft ); - m_album->setAlignment( Qt::AlignLeft ); - - dataEngine( "amarok-current" )->setProperty( "coverWidth", m_albumWidth ); - dataEngine( "amarok-current" )->connectSource( "current", this ); - connect( The::paletteHandler(), SIGNAL(newPalette(QPalette)), SLOT(paletteChanged(QPalette)) ); - connect( CollectionManager::instance(), SIGNAL(collectionDataChanged(Collections::Collection*)), - this, SLOT(queryCollection()), Qt::QueuedConnection ); - queryCollection(); - setView( Stopped ); - - PERF_LOG( "Finished init" ); -} - -void -CurrentTrack::trackRatingChanged( int rating ) -{ - Meta::TrackPtr track = The::engineController()->currentTrack(); - if( !track ) - return; - - track->statistics()->setRating( rating ); -} - -QList -CurrentTrack::contextualActions() -{ - DEBUG_BLOCK - QList actions; - Meta::TrackPtr track = The::engineController()->currentTrack(); - if( !track ) - return actions; - - if( !m_contextActions.isEmpty() ) - return m_contextActions; - - Meta::AlbumPtr album = track->album(); - if( !album ) - return actions; - - QScopedPointer ac( album->create() ); - if( ac ) - { - m_contextActions << ac->actions(); - actions.append( m_contextActions ); - } - return actions; -} - -void -CurrentTrack::mousePressEvent( QGraphicsSceneMouseEvent *event ) -{ - if( !m_isStopped - && event->modifiers() == Qt::NoModifier - && event->button() == Qt::LeftButton ) - { - QGraphicsView *view = scene()->views().first(); - QGraphicsItem *item = view->itemAt( view->mapFromScene(event->scenePos()) ); - if( item == m_albumCover->graphicsItem() ) - { - Meta::AlbumPtr album = The::engineController()->currentTrack()->album(); - if( album ) - ( new CoverViewDialog( album, The::mainWindow() ) )->show(); - return; - } - } - Context::Applet::mousePressEvent( event ); -} - -void -CurrentTrack::constraintsEvent( Plasma::Constraints constraints ) -{ - Context::Applet::constraintsEvent( constraints ); - - prepareGeometryChange(); - m_byText->setPos( m_artist->pos() ); - m_onText->setPos( m_album->pos() ); - m_byText->setX( m_byText->x() - m_byText->boundingRect().width() - 4 ); - m_onText->setX( m_onText->x() - m_onText->boundingRect().width() - 4 ); - alignBaseLineToFirst( m_artist, m_byText ); - alignBaseLineToFirst( m_album, m_onText ); - - update(); // ensure the stats bg is repainted with correct geometry - if( m_isStopped ) - { - m_recentHeader->setScrollingText( i18n("Recently Played Tracks") ); - return; - } - - QString artist = handleUnknown( m_artist->text(), m_artist, UNKNOWN_ARTIST.toString() ); - QString album = handleUnknown( m_album->text(), m_album, UNKNOWN_ALBUM.toString() ); - m_title->setScrollingText( m_title->text() ); - m_artist->setScrollingText( artist ); - m_album->setScrollingText( album ); -} - -QSizeF -CurrentTrack::sizeHint( Qt::SizeHint which, const QSizeF &constraint ) const -{ - // figure out the size we want to be, in order to be able to squeeze in all - // that we want depends on the current font size, basically height should - // be increased for larger point sizes. here, the layout works correctly - // with size 8, which has the fontMetrics height of 13 a size too big, like - // font size 12, has a fontMetrics height of 19. So we add some height if - // it's too big - int height = ( QApplication::fontMetrics().height() - 13 ) * 2 + 180; - return QSizeF( Context::Applet::sizeHint(which, constraint).width(), height ); -} - -void -CurrentTrack::dataUpdated( const QString& name, const Plasma::DataEngine::Data& data ) -{ - if( data.isEmpty() || name != QLatin1String("current") ) - return; - - if( data.contains( QLatin1String("notrack" ) ) ) - { - if( m_view != Stopped ) - setView( Stopped ); - return; - } - - const QPixmap &cover = data[ "albumart" ].value(); - const QVariantMap ¤tInfo = data[ QLatin1String("current") ].toMap(); - bool updateCover = ( m_coverKey != cover.cacheKey() ); - if( (m_currentInfo == currentInfo) && !updateCover ) - return; - - if( m_view != Playing ) - setView( Playing ); - - QString title = currentInfo.value( Meta::Field::TITLE ).toString(); - QString artist = currentInfo.value( Meta::Field::ARTIST ).toString(); - QString album = currentInfo.value( Meta::Field::ALBUM ).toString(); - artist = handleUnknown( artist, m_artist, UNKNOWN_ARTIST.toString() ); - album = handleUnknown( album, m_album, UNKNOWN_ALBUM.toString() ); - - if( title != m_currentInfo.value(Meta::Field::TITLE) ) - m_title->setScrollingText( title ); - if( artist != m_currentInfo.value(Meta::Field::ARTIST) ) - m_artist->setScrollingText( artist ); - if( album != m_currentInfo.value(Meta::Field::ALBUM) ) - m_album->setScrollingText( album ); - - m_rating = currentInfo[ Meta::Field::RATING ].toInt(); - m_trackLength = currentInfo[ Meta::Field::LENGTH ].toInt(); - m_score = currentInfo[ Meta::Field::SCORE ].toInt(); - m_lastPlayed = currentInfo[ Meta::Field::LAST_PLAYED ].toDateTime(); - m_playCount = currentInfo[ Meta::Field::PLAYCOUNT ].toInt(); - - m_ratingWidget->setRating( m_rating ); - - if( updateCover ) - { - m_coverKey = cover.cacheKey(); - resizeCover( cover, m_albumWidth ); - } - m_currentInfo = currentInfo; - m_sourceEmblemPath = data[ "source_emblem" ].toString(); - clearTrackActions(); - setupLayoutActions( The::engineController()->currentTrack() ); - updateConstraints(); -} - -void -CurrentTrack::editTrack() -{ - Meta::TrackPtr track = The::engineController()->currentTrack(); - new TagDialog( track, scene()->views().first() ); -} - -void -CurrentTrack::paintInterface( QPainter *p, - const QStyleOptionGraphicsItem *option, - const QRect &contentsRect ) -{ - Context::Applet::paintInterface( p, option, contentsRect ); - drawSourceEmblem( p, contentsRect ); - drawStatsBackground( p, contentsRect ); - drawStatsTexts( p, contentsRect ); -} - -void -CurrentTrack::drawStatsBackground( QPainter *const p, const QRect &rect ) -{ - // draw the complete outline. lots of little steps :) at each corner, leave - // a 6x6 box. draw a quad bezier curve from the two ends of the lines, - // through the original corner - - const qreal leftEdge = m_ratingWidget->boundingRect().right() + standardPadding(); - const qreal rightEdge = rect.right() - standardPadding() / 2; - const qreal ratingWidgetX = m_ratingWidget->pos().x(); - const qreal ratingWidgetY = m_ratingWidget->pos().y(); - const qreal ratingWidgetH = m_ratingWidget->boundingRect().height(); - QColor topColor = The::paletteHandler()->palette().color( QPalette::Base ); - QColor bottomColor = topColor; - topColor.setAlpha( 200 ); - bottomColor.setAlpha( 100 ); - - QPainterPath statsPath; - statsPath.moveTo( leftEdge + 6, ratingWidgetY - ratingWidgetH + 8 ); // top left position of the rect, right below the album - statsPath.lineTo( rightEdge - 6, ratingWidgetY - ratingWidgetH + 8 ); // go right to margin - statsPath.quadTo( rightEdge, ratingWidgetY - ratingWidgetH + 8, - rightEdge, ratingWidgetY - ratingWidgetH + 8 + 6 ); - statsPath.lineTo( rightEdge, ratingWidgetY + ratingWidgetH - 6 ); // go down to bottom right corner - statsPath.quadTo( rightEdge, ratingWidgetY + ratingWidgetH, - rightEdge - 6, ratingWidgetY + ratingWidgetH ); - statsPath.lineTo( ratingWidgetX + 6, ratingWidgetY + ratingWidgetH ); // way bottom left corner - statsPath.quadTo( ratingWidgetX, ratingWidgetY + ratingWidgetH, - ratingWidgetX, ratingWidgetY + ratingWidgetH - 6 ); - statsPath.lineTo( ratingWidgetX, ratingWidgetY + 6 ); // top left of rating widget - statsPath.quadTo( ratingWidgetX, ratingWidgetY, - ratingWidgetX + 6, ratingWidgetY ); - statsPath.lineTo( leftEdge - 6, ratingWidgetY ); // joining of two rects - statsPath.quadTo( leftEdge, ratingWidgetY, - leftEdge, ratingWidgetY - 6 ); - statsPath.lineTo( leftEdge, ratingWidgetY - ratingWidgetH + 8 + 6 ); // back to start - statsPath.quadTo( leftEdge, ratingWidgetY - ratingWidgetH + 8, - leftEdge + 6, ratingWidgetY - ratingWidgetH + 8 ); - - // draw just the overlay which is the "header" row, to emphasize that we have 2 rows here - QPainterPath headerPath; - headerPath.moveTo( leftEdge + 6, ratingWidgetY - ratingWidgetH + 8 ); // top left position of the rect, right below the album - headerPath.lineTo( rightEdge - 6, ratingWidgetY - ratingWidgetH + 8 ); // go right to margin - headerPath.quadTo( rightEdge, ratingWidgetY - ratingWidgetH + 8, - rightEdge, ratingWidgetY - ratingWidgetH + 8 + 6 ); - headerPath.lineTo( rightEdge, ratingWidgetY ); // middle of the right side - headerPath.lineTo( leftEdge - 6, ratingWidgetY ); // join spot, before quad curve - headerPath.quadTo( leftEdge, ratingWidgetY, - leftEdge, ratingWidgetY - 6 ); - headerPath.lineTo( leftEdge, ratingWidgetY - ratingWidgetH + 8 + 6 ); // curve back through start - headerPath.quadTo( leftEdge, ratingWidgetY - ratingWidgetH + 8, - leftEdge + 6, ratingWidgetY - ratingWidgetH + 8 ); - - p->save(); - p->setRenderHint( QPainter::Antialiasing ); - p->fillPath( statsPath, bottomColor ); - p->fillPath( headerPath, topColor ); - p->restore(); - -} - -void -CurrentTrack::drawStatsTexts( QPainter *const p, const QRect &contentsRect ) -{ - const qreal leftEdge = m_ratingWidget->boundingRect().right() + standardPadding(); - const qreal maxTextWidth = contentsRect.right() - standardPadding() * 2 - leftEdge; - const QString column1Label = m_isStopped ? i18n( "Tracks" ) : i18n( "Play Count" ); - const QString column2Label = m_isStopped ? i18n( "Albums" ) : i18n( "Score" ); - const QString column3Label = m_isStopped ? i18n( "Artists" ) : i18n( "Last Played" ); - - //Align labels taking into account the string widths for each label - QFontMetricsF fm( font() ); - qreal totalWidth = fm.width( column1Label ) + fm.width( column2Label ) + fm.width( column3Label ); - qreal factor, prevFactor; - factor = fm.width( column1Label ) / totalWidth; - prevFactor = factor; - - QRectF rect( leftEdge, // align vertically with track info text - m_ratingWidget->pos().y() - m_ratingWidget->boundingRect().height() + 8, // align bottom horizontally with top of rating rounded rect - maxTextWidth * factor, - m_ratingWidget->boundingRect().height() - 4 ); // just the "first" row, so go halfway down - - p->save(); - p->setRenderHint( QPainter::Antialiasing ); - p->setPen( normalBrush().color() ); - - // labels - QString playCountLabel = fm.elidedText( column1Label, Qt::ElideRight, rect.width() ); - p->drawText( rect, Qt::AlignCenter | Qt::TextSingleLine, playCountLabel ); - - factor = fm.width( column2Label ) / totalWidth; - rect.setWidth( maxTextWidth * factor ); - rect.moveLeft( rect.topLeft().x() + maxTextWidth * prevFactor ); - prevFactor = factor; - - QString scoreLabel = fm.elidedText( column2Label, Qt::ElideRight, rect.width() ); - p->drawText( rect, Qt::AlignCenter | Qt::TextSingleLine, scoreLabel ); - - factor = fm.width( column3Label ) / totalWidth; - rect.setWidth( maxTextWidth * factor ); - rect.moveLeft( rect.topLeft().x() + maxTextWidth * prevFactor ); - - QString lastPlayedLabel = fm.elidedText( column3Label, Qt::ElideRight, rect.width() ); - p->drawText( rect, Qt::AlignCenter | Qt::TextSingleLine, lastPlayedLabel ); - - // stats - - const int column1Stat = m_isStopped ? m_trackCount : m_playCount; - const int column2Stat = m_isStopped ? m_albumCount : m_score; - - factor = fm.width( column1Label ) / totalWidth; - prevFactor = factor; - rect.setX( leftEdge ); - rect.setY( m_ratingWidget->pos().y() + 3 ); - rect.setWidth( maxTextWidth * factor); - rect.setHeight( m_ratingWidget->boundingRect().height() - 4 ); - p->drawText( rect, Qt::AlignCenter | Qt::TextSingleLine, QString::number(column1Stat) ); - - factor = fm.width( column2Label ) / totalWidth; - rect.setWidth( maxTextWidth * factor ); - rect.moveLeft( rect.topLeft().x() + maxTextWidth * prevFactor ); - prevFactor = factor; - - p->drawText( rect, Qt::AlignCenter | Qt::TextSingleLine, QString::number(column2Stat) ); - - factor = fm.width( column3Label ) / totalWidth; - rect.setWidth( maxTextWidth * factor ); - rect.moveLeft( rect.topLeft().x() + maxTextWidth * prevFactor ); - - const QString column3Stat = ( m_isStopped ) - ? QString::number( m_artistCount ) - : fm.elidedText( Amarok::verboseTimeSince(m_lastPlayed), Qt::ElideRight, rect.width() ); - p->drawText( rect, Qt::AlignCenter | Qt::TextSingleLine, column3Stat ); - - p->restore(); -} - -void -CurrentTrack::drawSourceEmblem( QPainter *const p, const QRect &contentsRect ) -{ - if( m_isStopped ) - return; - - p->save(); - p->setOpacity( 0.19 ); - - if( m_sourceEmblemPath.isEmpty() ) - { - QPixmap logo = Amarok::semiTransparentLogo( m_albumWidth ); - QRect rect = logo.rect(); - int y = standardPadding(); - int x = contentsRect.right() - rect.width() - y; - rect.moveTo( x, y ); - QRectF clipRect( rect ); - qreal clipY = m_ratingWidget->pos().y() - m_ratingWidget->boundingRect().height() + 8; - clipRect.setBottom( clipY ); - p->setClipRect( clipRect ); - p->drawPixmap( rect, logo ); - } - else - { - QSvgRenderer svg( m_sourceEmblemPath ); - // paint the emblem half as tall as the applet, anchored at the top-right - // assume it is a square emblem - qreal height = boundingRect().height() / 2; - int y = standardPadding(); - int x = contentsRect.right() - y - height; - QRectF rect( x, y, height, height ); - svg.render( p, rect ); - } - p->restore(); -} - -void -CurrentTrack::clearTrackActions() -{ - prepareGeometryChange(); - int actionCount = m_actionsLayout->count(); - while( --actionCount >= 0 ) - { - QGraphicsLayoutItem *child = m_actionsLayout->itemAt( 0 ); - m_actionsLayout->removeItem( child ); - delete child; - } - qDeleteAll( m_customActions ); - qDeleteAll( m_contextActions ); - m_customActions.clear(); - m_contextActions.clear(); -} - -void -CurrentTrack::resizeCover( const QPixmap &cover, qreal width ) -{ - QPixmap coverWithBorders; - if( !cover.isNull() ) - { - const int borderWidth = 5; - width -= borderWidth * 2; - qreal pixmapRatio = (qreal)cover.width() / width; - - //center the cover : if the cover is not squared, we get the missing pixels and center - coverWithBorders = ( cover.height() / pixmapRatio > width ) - ? cover.scaledToHeight( width, Qt::SmoothTransformation ) - : cover.scaledToWidth( width, Qt::SmoothTransformation ); - - coverWithBorders = The::svgHandler()->addBordersToPixmap( coverWithBorders, - borderWidth, - m_album->text(), - true ); - } - m_albumCover->setPixmap( coverWithBorders ); - m_albumCover->graphicsItem()->setAcceptDrops( true ); -} - -void -CurrentTrack::settingsAccepted() -{ - QFont font = ui_Settings.fontRequester->font(); - m_showEditTrackDetailsAction = (ui_Settings.editTrackDetailsCheckBox->checkState() == Qt::Checked); - - m_title->setFont( font ); - m_artist->setFont( font ); - m_album->setFont( font ); - - KConfigGroup config = Amarok::config("Current Track Applet"); - config.writeEntry( "Font", font.toString() ); - config.writeEntry( "ShowEditTrackAction", m_showEditTrackDetailsAction ); - - clearTrackActions(); - setupLayoutActions( The::engineController()->currentTrack() ); -} - -void -CurrentTrack::queryCollection() -{ - Collections::QueryMaker *qmTracks = CollectionManager::instance()->queryMaker(); - Collections::QueryMaker *qmAlbums = CollectionManager::instance()->queryMaker(); - Collections::QueryMaker *qmArtists = CollectionManager::instance()->queryMaker(); - connect( qmTracks, SIGNAL(newResultReady(QStringList)), - this, SLOT(tracksCounted(QStringList)) ); - connect( qmAlbums, SIGNAL(newResultReady(QStringList)), - this, SLOT(albumsCounted(QStringList)) ); - connect( qmArtists, SIGNAL(newResultReady(QStringList)), - this, SLOT(artistsCounted(QStringList)) ); - - qmTracks->setAutoDelete( true ) - ->setQueryType( Collections::QueryMaker::Custom ) - ->addReturnFunction( Collections::QueryMaker::Count, Meta::valUrl ) - ->run(); - qmAlbums->setAutoDelete( true ) - ->setQueryType( Collections::QueryMaker::Custom ) - ->addReturnFunction( Collections::QueryMaker::Count, Meta::valAlbum ) - ->run(); - qmArtists->setAutoDelete( true ) - ->setQueryType( Collections::QueryMaker::Custom ) - ->addReturnFunction( Collections::QueryMaker::Count, Meta::valArtist ) - ->run(); -} - -void -CurrentTrack::tracksCounted( QStringList results ) -{ - m_trackCount = !results.isEmpty() ? results.first().toInt() : 0; - update(); -} - -void -CurrentTrack::albumsCounted( QStringList results ) -{ - m_albumCount = !results.isEmpty() ? results.first().toInt() : 0; - update(); -} - -void -CurrentTrack::artistsCounted( QStringList results ) -{ - m_artistCount = !results.isEmpty() ? results.first().toInt() : 0; - update(); -} - -void -CurrentTrack::createConfigurationInterface( KConfigDialog *parent ) -{ - parent->setButtons( KDialog::Ok | KDialog::Cancel ); - - KConfigGroup configuration = config(); - QWidget *settings = new QWidget; - ui_Settings.setupUi( settings ); - ui_Settings.fontRequester->setFont( m_title->font() ); - ui_Settings.editTrackDetailsCheckBox->setCheckState( m_showEditTrackDetailsAction ? Qt::Checked : Qt::Unchecked ); - - parent->addPage( settings, i18n( "Current Track Settings" ), "preferences-system"); - - connect( parent, SIGNAL(accepted()), this, SLOT(settingsAccepted()) ); -} - -void -CurrentTrack::coverDropped( const QPixmap &cover ) -{ - DEBUG_BLOCK - Meta::TrackPtr track = The::engineController()->currentTrack(); - if( !track ) - return; - - Meta::AlbumPtr album = track->album(); - if( !album ) - return; - - if ( !cover.isNull() ) - album->setImage( cover.toImage() ); -} - -void -CurrentTrack::paletteChanged( const QPalette &palette ) -{ - m_title->setBrush( palette.text() ); - m_artist->setBrush( palette.text() ); - m_album->setBrush( palette.text() ); - m_byText->setBrush( palette.text() ); - m_onText->setBrush( palette.text() ); -} - -void -CurrentTrack::alignBaseLineToFirst( TextScrollingWidget *a, QGraphicsSimpleTextItem *b ) -{ - qreal guideY = a->pos().y() + QFontMetricsF( a->font() ).ascent(); - qreal newY = guideY - QFontMetricsF( b->font() ).ascent(); - b->setPos( b->x(), newY ); -} - -QBrush -CurrentTrack::normalBrush() const -{ - return The::paletteHandler()->palette().brush( QPalette::Active, QPalette::Text ); -} - -QBrush -CurrentTrack::unknownBrush() const -{ - return The::paletteHandler()->palette().brush( QPalette::Disabled, QPalette::Text ); -} - -QString -CurrentTrack::handleUnknown( const QString &original, - TextScrollingWidget *widget, - const QString &replacement ) -{ - if( original.isEmpty() ) - { - widget->setBrush( unknownBrush() ); - return replacement; - } - else - { - widget->setBrush( normalBrush() ); - return original; - } -} - -void -CurrentTrack::setupLayoutActions( Meta::TrackPtr track ) -{ - if( !track ) - return; - - PERF_LOG( "Begin actions layout setup" ); - //first, add any global CurrentTrackActions (iow, actions that are shown for all tracks) - QList actions = The::globalCurrentTrackActions()->actions(); - - using namespace Capabilities; - - QScopedPointer ac( track->create() ); - if( ac ) - { - QList trackActions = ac->actions(); - // ensure that the actions get deleted afterwards - foreach( QAction* action, trackActions ) - { - if( !action->parent() ) - action->setParent( this ); - actions << action; - } - } - - QScopedPointer btc( track->create() ); - if( btc && btc->bookmarkAction() ) - { - actions << btc->bookmarkAction(); - } - - if( m_showEditTrackDetailsAction && track->editor() ) - { - QAction *editAction = new QAction( KIcon("media-track-edit-amarok"), - i18n("Edit Track Details"), this ); - connect( editAction, SIGNAL(triggered()), SLOT(editTrack()) ); - m_customActions << editAction; - } - - if( track->has() ) - { - if( !m_findInSourceSignalMapper ) - { - m_findInSourceSignalMapper = new QSignalMapper( this ); - connect( m_findInSourceSignalMapper, SIGNAL(mapped(QString)), SLOT(findInSource(QString)) ); - } - - Meta::AlbumPtr album = track->album(); - Meta::ArtistPtr artist = track->artist(); - Meta::ComposerPtr composer = track->composer(); - Meta::GenrePtr genre = track->genre(); - Meta::YearPtr year = track->year(); - QAction *act( 0 ); - - if( album && !album->name().isEmpty() ) - { - act = new QAction( KIcon("current-track-amarok"), i18n("Show Album in Media Sources"), this ); - connect( act, SIGNAL(triggered()), m_findInSourceSignalMapper, SLOT(map()) ); - m_findInSourceSignalMapper->setMapping( act, QLatin1String("album") ); - m_customActions << act; - } - if( artist && !artist->name().isEmpty() ) - { - act = new QAction( KIcon("filename-artist-amarok"), i18n("Show Artist in Media Sources"), this ); - connect( act, SIGNAL(triggered()), m_findInSourceSignalMapper, SLOT(map()) ); - m_findInSourceSignalMapper->setMapping( act, QLatin1String("artist") ); - m_customActions << act; - - // show a special action if the amazon plugin is enabled - KPluginInfo::List services = The::pluginManager()->plugins( Plugins::PluginManager::Service ); - foreach( const KPluginInfo &service, services ) - { - if( service.pluginName() == QLatin1String("amarok_service_amazonstore") ) - { - if( service.isPluginEnabled() ) - { - act = new QAction( KIcon("view-services-amazon-amarok"), - i18n("Search for Artist in the MP3 Music Store"), this ); - connect( act, SIGNAL(triggered()), this, SLOT(findInStore()) ); - m_customActions << act; - } - break; - } - } - } - if( composer && !composer->name().isEmpty() && (composer->name() != i18n("Unknown Composer")) ) - { - act = new QAction( KIcon("filename-composer-amarok"), i18n("Show Composer in Media Sources"), this ); - connect( act, SIGNAL(triggered()), m_findInSourceSignalMapper, SLOT(map()) ); - m_findInSourceSignalMapper->setMapping( act, QLatin1String("composer") ); - m_customActions << act; - } - if( genre && !genre->name().isEmpty() ) - { - act = new QAction( KIcon("filename-genre-amarok"), i18n("Show Genre in Media Sources"), this ); - connect( act, SIGNAL(triggered()), m_findInSourceSignalMapper, SLOT(map()) ); - m_findInSourceSignalMapper->setMapping( act, QLatin1String("genre") ); - m_customActions << act; - } - if( year && !year->name().isEmpty() ) - { - act = new QAction( KIcon("filename-year-amarok"), i18n("Show Year in Media Sources"), this ); - connect( act, SIGNAL(triggered()), m_findInSourceSignalMapper, SLOT(map()) ); - m_findInSourceSignalMapper->setMapping( act, QLatin1String("year") ); - m_customActions << act; - } - } - - actions << m_customActions; - foreach( QAction* action, actions ) - { - Plasma::IconWidget *icon = addAction( this, action, 24 ); - icon->setText( QString() ); - m_actionsLayout->addItem( icon ); - } - PERF_LOG( "Finished actions layout setup" ); -} - -void -CurrentTrack::findInSource( const QString &name ) -{ - using namespace Capabilities; - Meta::TrackPtr track = The::engineController()->currentTrack(); - QScopedPointer fis( track->create() ); - if( !fis ) - return; - - if( name == QLatin1String("album") ) - fis->findInSource( FindInSourceCapability::Album ); - else if( name == QLatin1String("artist") ) - fis->findInSource( FindInSourceCapability::Artist ); - else if( name == QLatin1String("composer") ) - fis->findInSource( FindInSourceCapability::Composer ); - else if( name == QLatin1String("genre") ) - fis->findInSource( FindInSourceCapability::Genre ); - else if( name == QLatin1String("year") ) - fis->findInSource( FindInSourceCapability::Year ); -} - -void -CurrentTrack::findInStore() -{ - Meta::TrackPtr track = The::engineController()->currentTrack(); - AmarokUrl url( "amarok://navigate/internet/MP3%20Music%20Store/?filter=\"" + AmarokUrl::escape( track.data()->artist().data()->name() ) + '\"' ); - url.run(); -} - -void -CurrentTrack::setView( CurrentTrack::View mode ) -{ - m_view = mode; - m_isStopped = ( mode == CurrentTrack::Stopped ); - if( m_isStopped ) - { - m_coverKey = 0; - m_currentInfo.clear(); - m_sourceEmblemPath.clear(); - m_albumCover->setPixmap( Amarok::semiTransparentLogo(m_albumWidth) ); - m_albumCover->graphicsItem()->setAcceptDrops( false ); - m_albumCover->graphicsItem()->unsetCursor(); - clearTrackActions(); - updateConstraints(); - } - else - { - m_albumCover->graphicsItem()->setCursor( Qt::PointingHandCursor ); - } - - m_collectionLabel->setVisible( m_isStopped ); - m_recentWidget->setVisible( m_isStopped ); - m_recentHeader->setVisible( m_isStopped ); - - m_ratingWidget->setVisible( !m_isStopped ); - m_byText->setVisible( !m_isStopped ); - m_onText->setVisible( !m_isStopped ); - m_title->setVisible( !m_isStopped ); - m_artist->setVisible( !m_isStopped ); - m_album->setVisible( !m_isStopped ); -} - -#include "moc_CurrentTrack.cpp" diff --git a/amarok/src/context/applets/currenttrack/CurrentTrack.h b/amarok/src/context/applets/currenttrack/CurrentTrack.h deleted file mode 100644 index aad233d1..00000000 --- a/amarok/src/context/applets/currenttrack/CurrentTrack.h +++ /dev/null @@ -1,142 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007-2009 Leo Franchi * - * Copyright (c) 2008 William Viana Soares * - * Copyright (c) 2009 simon.esneault * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef CURRENT_TRACK_APPLET_H -#define CURRENT_TRACK_APPLET_H - -#include "context/Applet.h" -#include "core/meta/forward_declarations.h" -#include "ui_currentTrackSettings.h" - -#include - -class TextScrollingWidget; -class DropPixmapLayoutItem; -class RatingWidget; -class RecentlyPlayedListWidget; -class QAction; -class QGraphicsLinearLayout; -class QGraphicsProxyWidget; -class QGraphicsSceneMouseEvent; -class QSignalMapper; - -static const KLocalizedString UNKNOWN_ARTIST = ki18n("Unknown Artist"); -static const KLocalizedString UNKNOWN_ALBUM = ki18n("Unknown Album"); - -class CurrentTrack : public Context::Applet -{ - Q_OBJECT - -public: - CurrentTrack( QObject* parent, const QVariantList& args ); - ~CurrentTrack(); - - virtual void paintInterface( QPainter *painter, - const QStyleOptionGraphicsItem *option, - const QRect &contentsRect ); - -public slots: - virtual void init(); - void dataUpdated( const QString& name, const Plasma::DataEngine::Data &data ); - -protected: - virtual void mousePressEvent( QGraphicsSceneMouseEvent *event ); - virtual void constraintsEvent( Plasma::Constraints constraints = Plasma::AllConstraints ); - virtual QSizeF sizeHint( Qt::SizeHint which, const QSizeF &constraint = QSizeF() ) const; - void createConfigurationInterface( KConfigDialog *parent ); - -private slots: - void trackRatingChanged( int rating ); - void paletteChanged( const QPalette &palette ); - void settingsAccepted(); - void coverDropped( const QPixmap &cover ); - void tracksCounted( QStringList results ); - void albumsCounted( QStringList results ); - void artistsCounted( QStringList results ); - void findInSource( const QString &name ); - void findInStore(); - void queryCollection(); - void editTrack(); - -private: - QList contextualActions(); - - void clearTrackActions(); - void drawStatsBackground( QPainter *const p, const QRect &rect ); - void drawStatsTexts( QPainter *const p, const QRect &rect ); - void drawSourceEmblem( QPainter *const p, const QRect &rect ); - void resizeCover( const QPixmap &cover, qreal width ); - void setupLayoutActions( Meta::TrackPtr track ); - - // aligns the second QGI to be at the same level as the first (the font baseline) - void alignBaseLineToFirst( TextScrollingWidget *a, QGraphicsSimpleTextItem *b ); - - QBrush normalBrush() const; - QBrush unknownBrush() const; - /** - * Bug 205038 - * We check if original is an 'invalid' value - * In that case we return replacement and - * set widget's brush to unknownBrush() - * - * If original is 'valid', widget brush is set - * to normalBrush() and original is returned - */ - QString handleUnknown( const QString &original, - TextScrollingWidget *widget, - const QString &replacement ); - - QGraphicsProxyWidget *m_collectionLabel; - RecentlyPlayedListWidget *m_recentWidget; - RatingWidget *m_ratingWidget; - DropPixmapLayoutItem *m_albumCover; - TextScrollingWidget *m_recentHeader; - TextScrollingWidget *m_title; - TextScrollingWidget *m_artist; - TextScrollingWidget *m_album; - QGraphicsSimpleTextItem *m_byText; - QGraphicsSimpleTextItem *m_onText; - QGraphicsLinearLayout *m_actionsLayout; - QSignalMapper *m_findInSourceSignalMapper; - QList m_customActions; // for storing non global actions - QList m_contextActions; - - int m_rating; - int m_score; - int m_trackLength; - int m_playCount; - int m_trackCount; - int m_albumCount; - int m_artistCount; - QDateTime m_lastPlayed; - QString m_sourceEmblemPath; - bool m_isStopped; - QVariantMap m_currentInfo; - qint64 m_coverKey; - - enum View { Stopped, Playing } m_view; - void setView( View mode ); - - Ui::currentTrackSettings ui_Settings; - bool m_showEditTrackDetailsAction; - const int m_albumWidth; -}; - -AMAROK_EXPORT_APPLET( currenttrack, CurrentTrack ) - -#endif diff --git a/amarok/src/context/applets/currenttrack/amarok-context-applet-currenttrack.desktop b/amarok/src/context/applets/currenttrack/amarok-context-applet-currenttrack.desktop deleted file mode 100644 index bdb3b9fa..00000000 --- a/amarok/src/context/applets/currenttrack/amarok-context-applet-currenttrack.desktop +++ /dev/null @@ -1,70 +0,0 @@ -[Desktop Entry] -Name=Current Track -Name[bg]=Текущ запис -Name[bs]=Trenutna numera -Name[ca]=Peça actual -Name[ca@valencia]=Peça actual -Name[cs]=Aktuální stopa -Name[csb]=Biéżny sztëczk -Name[da]=Aktuelt spor -Name[de]=Aktuelles Stück -Name[el]=Τρέχον κομμάτι -Name[en_GB]=Current Track -Name[es]=Pista actual -Name[et]=Aktiivne pala -Name[eu]=Uneko pista -Name[fa]=شیار جاری -Name[fi]=Soiva kappale -Name[fr]=Piste courante -Name[ga]=An tAmhrán Reatha -Name[gl]=Pista actual -Name[hu]=Jelenlegi szám -Name[id]=Track Saat Ini -Name[is]=Núverandi lag -Name[it]=Traccia attuale -Name[ja]=現在のトラック -Name[km]=​បទ​បច្ចុប្បន្ន -Name[ko]=현재 곡 -Name[lt]=Dabartinė daina -Name[lv]=Aktīvais celiņš -Name[nb]=Gjeldende spor -Name[nds]=Aktuell Stück -Name[nl]=Huidige track -Name[nn]=Gjeldande spor -Name[pa]=ਮੌਜੂਦਾ ਟਰੈਕ -Name[pl]=Bieżący utwór -Name[pt]=Faixa Actual -Name[pt_BR]=Faixa atual -Name[ro]=Piesa curentă -Name[ru]=Текущая дорожка -Name[sk]=Aktuálna skladba -Name[sl]=Trenutna skladba -Name[sr]=Текућа нумера -Name[sr@ijekavian]=Текућа нумера -Name[sr@ijekavianlatin]=Tekuća numera -Name[sr@latin]=Tekuća numera -Name[sv]=Aktuellt spår -Name[th]=แทร็กปัจจุบัน -Name[tr]=Mevcut Parça -Name[ug]=نۆۋەتتىكى نەغمە -Name[uk]=Поточна композиція -Name[wa]=Boket do moumint -Name[x-test]=xxCurrent Trackxx -Name[zh_CN]=当前音轨 -Name[zh_TW]=現在的曲目 -Type=Service -Icon=current-track-amarok -ServiceTypes=Plasma/Applet - -X-KDE-Library=amarok_context_applet_currenttrack -X-KDE-PluginInfo-Author=Leo Franchi -X-KDE-PluginInfo-Email=lfranchi@gmail.com -X-KDE-PluginInfo-Name=currenttrack -X-KDE-PluginInfo-Version=pre0.1 -X-KDE-PluginInfo-Website= -X-KDE-PluginInfo-Depends= -X-KDE-PluginInfo-License=GPL -X-KDE-PluginInfo-EnabledByDefault=true -X-KDE-ParentApp=amarok -X-KDE-PluginInfo-Category=Current - diff --git a/amarok/src/context/applets/currenttrack/amarok-currenttrack.svg b/amarok/src/context/applets/currenttrack/amarok-currenttrack.svg deleted file mode 100644 index 143467e9..00000000 --- a/amarok/src/context/applets/currenttrack/amarok-currenttrack.svg +++ /dev/null @@ -1,3184 +0,0 @@ - - -image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/amarok/src/context/applets/currenttrack/currentTrackSettings.ui b/amarok/src/context/applets/currenttrack/currentTrackSettings.ui deleted file mode 100644 index c0063840..00000000 --- a/amarok/src/context/applets/currenttrack/currentTrackSettings.ui +++ /dev/null @@ -1,81 +0,0 @@ - - - currentTrackSettings - - - - 0 - 0 - 184 - 156 - - - - - 0 - 0 - - - - Current Track Settings - - - - - - - 0 - 0 - - - - Show Actions - - - - - - Edit Track Details - - - - - - - - - - - 0 - 0 - - - - Fonts - - - - - - - 0 - 0 - - - - - - - - - - - - KFontRequester - QWidget -
kfontrequester.h
-
-
- - -
diff --git a/amarok/src/context/applets/info/CMakeLists.txt b/amarok/src/context/applets/info/CMakeLists.txt deleted file mode 100644 index 1808b097..00000000 --- a/amarok/src/context/applets/info/CMakeLists.txt +++ /dev/null @@ -1,26 +0,0 @@ -project(context-info) - -set(info_SRCS -InfoApplet.cpp ) - -include_directories( - ../.. - ../../.. - ) - -kde4_add_plugin(amarok_context_applet_info ${info_SRCS}) -if(APPLE) - SET_TARGET_PROPERTIES(amarok_context_applet_info PROPERTIES LINK_FLAGS "-undefined dynamic_lookup") -endif(APPLE) -target_link_libraries(amarok_context_applet_info - amarokcore - amaroklib - ${KDE4_PLASMA_LIBS} - ${KDE4_KDEWEBKIT_LIBS} - ${QT_QTWEBKIT_LIBRARY} - ) - -install(TARGETS amarok_context_applet_info DESTINATION ${PLUGIN_INSTALL_DIR}) -install(FILES amarok-context-applet-info.desktop DESTINATION ${SERVICES_INSTALL_DIR}) -install(FILES amarok-info-applet.svg DESTINATION ${DATA_INSTALL_DIR}/desktoptheme/default/widgets/ ) -install(FILES InfoAppletCustomStyle.css DESTINATION ${DATA_INSTALL_DIR}/amarok/data ) diff --git a/amarok/src/context/applets/info/InfoApplet.cpp b/amarok/src/context/applets/info/InfoApplet.cpp deleted file mode 100644 index 01ccc015..00000000 --- a/amarok/src/context/applets/info/InfoApplet.cpp +++ /dev/null @@ -1,139 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Leo Franchi * - * Copyright (c) 2008 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "InfoApplet" - -#include "InfoApplet.h" - -#include "App.h" -#include "amarokurls/AmarokUrl.h" -#include "core/support/Amarok.h" -#include "core/support/Debug.h" -#include "PaletteHandler.h" -#include "playlist/PlaylistController.h" - -#include -#include - -#include -#include -#include - -QString InfoApplet::s_defaultHtml = "" - " " - " " - " " - " " - " %%SUBJECT_NAME%%" - " " - ""; - -InfoApplet::InfoApplet( QObject* parent, const QVariantList& args ) - : Context::Applet( parent, args ) - , m_webView( 0 ) - , m_initialized( false ) -{ - setHasConfigurationInterface( false ); -} - -InfoApplet::~InfoApplet() -{ - delete m_webView; -} - - -void InfoApplet::init() -{ - // Call the base implementation. - Context::Applet::init(); - - dataEngine( "amarok-info" )->connectSource( "info", this ); - - m_webView = new KGraphicsWebView( this ); - - QPalette p = m_webView->palette(); - p.setColor( QPalette::Dark, QColor( 255, 255, 255, 0) ); - p.setColor( QPalette::Window, QColor( 255, 255, 255, 0) ); - m_webView->setPalette( p ); - - QGraphicsLinearLayout *layout = new QGraphicsLinearLayout( Qt::Vertical, this ); - layout->addItem( m_webView ); - - connect( m_webView->page(), SIGNAL(linkClicked(QUrl)), SLOT(linkClicked(QUrl)) ); - - updateConstraints(); -} - -void InfoApplet::constraintsEvent( Plasma::Constraints constraints ) -{ - Q_UNUSED( constraints ) - m_initialized = true; -} - -void InfoApplet::dataUpdated( const QString& name, const Plasma::DataEngine::Data& data ) -{ - Q_UNUSED( name ); - - if( data.isEmpty() ) - return; - - if( m_initialized ) - { - QString currentHtml = data[ "main_info" ].toString(); - if ( !currentHtml.isEmpty() ) - { - QColor highlight( App::instance()->palette().highlight().color() ); - highlight.setHsvF( highlight.hueF(), 0.3, .95, highlight.alphaF() ); - currentHtml = currentHtml.replace( "{text_color}", App::instance()->palette().brush( QPalette::Text ).color().name() ); - currentHtml = currentHtml.replace( "{content_background_color}", highlight.name() ); - currentHtml = currentHtml.replace( "{background_color}", PaletteHandler::highlightColor().lighter( 150 ).name()); - currentHtml = currentHtml.replace( "{border_color}", PaletteHandler::highlightColor().lighter( 150 ).name() ); - - m_webView->setHtml( currentHtml, KUrl( QString() ) ); - } - else - { - currentHtml = s_defaultHtml; - currentHtml = currentHtml.replace( "%%SUBJECT_NAME%%", data[ "subject_name" ].toString() ); - m_webView->setHtml( currentHtml ); - } - - m_webView->page()->setLinkDelegationPolicy( QWebPage::DelegateAllLinks ); - updateConstraints(); - } -} - -void InfoApplet::linkClicked( const QUrl & url ) -{ - DEBUG_BLOCK - debug() << "Link clicked: " << url.toString(); - - if ( url.toString().startsWith( "amarok://", Qt::CaseInsensitive ) ) - { - AmarokUrl aUrl( url.toString() ); - aUrl.run(); - } - else if ( url.toString().contains( ".xspf", Qt::CaseInsensitive ) ) - { - // FIXME: this doesn't work (triggerTrackLoad is not called) and leaks the playlist instance - new Playlists::XSPFPlaylist( url, 0, Playlists::XSPFPlaylist::AppendToPlaylist ); - } - else - QDesktopServices::openUrl( url.toString() ); -} - -#include "moc_InfoApplet.cpp" diff --git a/amarok/src/context/applets/info/InfoApplet.h b/amarok/src/context/applets/info/InfoApplet.h deleted file mode 100644 index da893033..00000000 --- a/amarok/src/context/applets/info/InfoApplet.h +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Leo Franchi * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef SERVICE_INFO_APPLET_H -#define SERVICE_INFO_APPLET_H - -#include "context/Applet.h" -#include "context/DataEngine.h" -#include "context/Svg.h" -#include "core-impl/playlists/types/file/xspf/XSPFPlaylist.h" -#include "core/playlists/Playlist.h" - -#include - -#include - -class KGraphicsWebView; - -class InfoApplet : public Context::Applet -{ - Q_OBJECT - -public: - InfoApplet( QObject* parent, const QVariantList& args ); - virtual ~InfoApplet(); - - void constraintsEvent( Plasma::Constraints constraints = Plasma::AllConstraints ); - -public slots: - virtual void init(); - void dataUpdated( const QString& name, const Plasma::DataEngine::Data &data ); - -private slots: - void linkClicked( const QUrl & url ); - -private: - KGraphicsWebView *m_webView; - bool m_initialized; - - static QString s_defaultHtml; -}; - -AMAROK_EXPORT_APPLET( info, InfoApplet ) - -#endif diff --git a/amarok/src/context/applets/info/InfoAppletCustomStyle.css b/amarok/src/context/applets/info/InfoAppletCustomStyle.css deleted file mode 100644 index afc0b2db..00000000 --- a/amarok/src/context/applets/info/InfoAppletCustomStyle.css +++ /dev/null @@ -1,6 +0,0 @@ - diff --git a/amarok/src/context/applets/info/amarok-context-applet-info.desktop b/amarok/src/context/applets/info/amarok-context-applet-info.desktop deleted file mode 100644 index 3f78ac6d..00000000 --- a/amarok/src/context/applets/info/amarok-context-applet-info.desktop +++ /dev/null @@ -1,72 +0,0 @@ -[Desktop Entry] -Name=Info -Name[bg]=Данни -Name[bs]=Podaci -Name[ca]=Informació -Name[ca@valencia]=Informació -Name[cs]=Informace -Name[csb]=Wëdowiédzô -Name[da]=Info -Name[de]=Information -Name[el]=Πληροφορίες -Name[en_GB]=Info -Name[es]=Información -Name[et]=Teave -Name[eu]=Informazioa -Name[fa]=اطلاعات -Name[fi]=Info -Name[fr]=Informations -Name[ga]=Eolas -Name[gl]=Información -Name[hu]=Információ -Name[id]=Info -Name[is]=Upplýsingar -Name[it]=Informazioni -Name[ja]=情報 -Name[km]=ព័ត៌មាន -Name[ko]=정보 -Name[lt]=Informacija -Name[lv]=Informācija -Name[mai]=सूचना -Name[mr]=माहिती -Name[nb]=Info -Name[nds]=Info -Name[nl]=Info -Name[nn]=Info -Name[pa]=ਜਾਣਕਾਰੀ -Name[pl]=Informacja -Name[pt]=Informação -Name[pt_BR]=Informações -Name[ro]=Informații -Name[ru]=Сведения -Name[sk]=Informácie -Name[sl]=Podatki -Name[sq]=Info -Name[sr]=Подаци -Name[sr@ijekavian]=Подаци -Name[sr@ijekavianlatin]=Podaci -Name[sr@latin]=Podaci -Name[sv]=Information -Name[th]=ข้อมูล -Name[tr]=Bilgiler -Name[ug]=ئۇچۇر -Name[uk]=Інформація -Name[x-test]=xxInfoxx -Name[zh_CN]=信息 -Name[zh_TW]=資訊 -Type=Service -Icon=info-amarok -ServiceTypes=Plasma/Applet - -X-KDE-Library=amarok_context_applet_info -X-KDE-PluginInfo-Author=Nikolaj Hald Nielsen -X-KDE-PluginInfo-Email=nhnFreespirit@gmail.com -X-KDE-PluginInfo-Name=info -X-KDE-PluginInfo-Version=1.0 -X-KDE-PluginInfo-Website= -X-KDE-PluginInfo-Depends= -X-KDE-PluginInfo-License=GPL -X-KDE-PluginInfo-EnabledByDefault=true -X-KDE-ParentApp=amarok -X-KDE-PluginInfo-Category=Current - diff --git a/amarok/src/context/applets/info/amarok-info-applet.svg b/amarok/src/context/applets/info/amarok-info-applet.svg deleted file mode 100644 index 406beeba..00000000 --- a/amarok/src/context/applets/info/amarok-info-applet.svg +++ /dev/null @@ -1,74 +0,0 @@ - - - - - - - image/svg+xml - - - - - - - - - - - - diff --git a/amarok/src/context/applets/labels/CMakeLists.txt b/amarok/src/context/applets/labels/CMakeLists.txt deleted file mode 100644 index de3fe021..00000000 --- a/amarok/src/context/applets/labels/CMakeLists.txt +++ /dev/null @@ -1,23 +0,0 @@ -project(context-labels) - -set(labels_SRCS - LabelsApplet.cpp - LabelGraphicsItem.cpp - LabelOverlayButton.cpp - labelsGeneralSettings.ui - labelsBlacklistSettings.ui - labelsReplacementSettings.ui -) - -include_directories( ../.. - ../../.. ) - -kde4_add_plugin(amarok_context_applet_labels ${labels_SRCS}) -target_link_libraries(amarok_context_applet_labels - amarokcore - amaroklib - ${KDE4_PLASMA_LIBS} -) - -install(TARGETS amarok_context_applet_labels DESTINATION ${PLUGIN_INSTALL_DIR}) -install(FILES amarok-context-applet-labels.desktop DESTINATION ${SERVICES_INSTALL_DIR}) diff --git a/amarok/src/context/applets/labels/LabelGraphicsItem.cpp b/amarok/src/context/applets/labels/LabelGraphicsItem.cpp deleted file mode 100644 index 17ce06db..00000000 --- a/amarok/src/context/applets/labels/LabelGraphicsItem.cpp +++ /dev/null @@ -1,396 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Daniel Faust * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "LabelGraphicsItem.h" -#include "LabelOverlayButton.h" - -// Amarok -#include "PaletteHandler.h" - -// KDE -#include - -// Qt -#include -#include -#include - -#include -#include -#include -#include - - -LabelGraphicsItem::LabelGraphicsItem( const QString &text, qreal deltaPointSize, QGraphicsItem *parent ) - : QGraphicsObject( parent ), - m_selected( false ) -{ - setAcceptHoverEvents( true ); - - m_hoverColor = PaletteHandler::highlightColor( 0.7, 1.0 ); - - m_hoverValueAnimation = new QPropertyAnimation( this, "hoverValue", this ); - m_hoverValueAnimation.data()->setEasingCurve( QEasingCurve::InOutQuad ); - - m_textItem = new QGraphicsTextItem( text, this ); - m_textItem->setZValue( 10 ); - m_textItem->setPos( qRound( m_textItem->boundingRect().height() / 4 ), 0 ); - - m_backgroundItem = new QGraphicsPixmapItem( this ); - m_backgroundItem->setZValue( 0 ); - m_backgroundItem->setOpacity( 0.7 ); - m_backgroundBlurEffect = new QGraphicsBlurEffect( this ); - m_backgroundBlurEffect->setBlurRadius( 4.0 ); - m_backgroundItem->setGraphicsEffect( m_backgroundBlurEffect ); - - { - KIconLoader iconLoader; - m_addLabelItem = new LabelOverlayButton( this ); - m_addLabelItem.data()->setZValue( 20 ); - m_addLabelItem.data()->setPixmap( iconLoader.loadIcon( "list-add", KIconLoader::NoGroup, KIconLoader::SizeSmallMedium ) ); - m_addLabelItem.data()->setToolTip( i18n( "Add label" ) ); - m_addLabelItem.data()->setOpacity( 0.0 ); - m_removeLabelItem = new LabelOverlayButton( this ); - m_removeLabelItem.data()->setZValue( 20 ); - m_removeLabelItem.data()->setPixmap( iconLoader.loadIcon( "list-remove", KIconLoader::NoGroup, KIconLoader::SizeSmallMedium ) ); - m_removeLabelItem.data()->setToolTip( i18n( "Remove label" ) ); - m_removeLabelItem.data()->setOpacity( 0.0 ); - m_listLabelItem = new LabelOverlayButton( this ); - m_listLabelItem.data()->setZValue( 20 ); - m_listLabelItem.data()->setPixmap( iconLoader.loadIcon( "edit-find", KIconLoader::NoGroup, KIconLoader::SizeSmallMedium ) ); - m_listLabelItem.data()->setToolTip( i18n( "Show in Media Sources" ) ); - m_listLabelItem.data()->setOpacity( 0.0 ); - m_blacklistLabelItem = new LabelOverlayButton( this ); - m_blacklistLabelItem.data()->setZValue( 20 ); - m_blacklistLabelItem.data()->setPixmap( iconLoader.loadIcon( "flag-black", KIconLoader::NoGroup, KIconLoader::SizeSmallMedium ) ); - m_blacklistLabelItem.data()->setToolTip( i18n( "Add to blacklist" ) ); - m_blacklistLabelItem.data()->setOpacity( 0.0 ); - } - - m_addLabelAnimation = new QPropertyAnimation( m_addLabelItem.data(), "opacity", this ); - m_addLabelAnimation.data()->setEasingCurve( QEasingCurve::InOutQuad ); - m_removeLabelAnimation = new QPropertyAnimation( m_removeLabelItem.data(), "opacity", this ); - m_removeLabelAnimation.data()->setEasingCurve( QEasingCurve::InOutQuad ); - m_listLabelAnimation = new QPropertyAnimation( m_listLabelItem.data(), "opacity", this ); - m_listLabelAnimation.data()->setEasingCurve( QEasingCurve::InOutQuad ); - m_blacklistLabelAnimation = new QPropertyAnimation( m_blacklistLabelItem.data(), "opacity", this ); - m_blacklistLabelAnimation.data()->setEasingCurve( QEasingCurve::InOutQuad ); - - setDeltaPointSize( deltaPointSize ); -} - -LabelGraphicsItem::~LabelGraphicsItem() -{} - -QString -LabelGraphicsItem::text() -{ - return m_textItem->toPlainText(); -} - -void -LabelGraphicsItem::setText(const QString& text) -{ - m_textItem->setPlainText( text ); -} - -void -LabelGraphicsItem::setDeltaPointSize( qreal deltaPointSize ) -{ - QFont f = qApp->font(); - f.setPointSize( f.pointSizeF() + deltaPointSize ); - f.setBold( m_selected ); - m_textItem->setFont( f ); - updateGeometry(); -} - -void -LabelGraphicsItem::setSelected( bool selected ) -{ - m_selected = selected; - QFont f = m_textItem->font(); - f.setBold( m_selected ); - m_textItem->setFont( f ); - setHoverValue( (float)isUnderMouse() ); - updateGeometry(); -} - -void -LabelGraphicsItem::setSelectedColor( QColor color ) -{ - m_selectedColor = color; - setSelected( m_selected ); - update(); -} - -void -LabelGraphicsItem::setBackgroundColor( QColor color ) -{ - m_backgroundColor = color; - update(); -} - -void -LabelGraphicsItem::showBlacklistButton( bool enabled ) -{ - m_showBlacklistButton = enabled; -} - -void -LabelGraphicsItem::updateGeometry() -{ - const QSizeF size = boundingRect().size(); - - m_textItem->setPos( qRound( size.height() / 4 ), 0 ); - - const qreal radius = size.height() / 4; - - QPixmap pixmap( size.width(), size.height() ); - pixmap.fill( Qt::transparent ); - { - QPainter painter( &pixmap ); - painter.setRenderHint( QPainter::Antialiasing ); - painter.setPen( QPen(m_backgroundColor) ); - painter.setBrush( QBrush(m_backgroundColor) ); - painter.drawRoundedRect( QRectF(2,2,size.width()-4,size.height()-4), radius, radius ); - } - m_backgroundItem->setPixmap( pixmap ); - -// int iconsCount = m_selected ? 2 : 3; // don't show the blacklist flag for selected labels - int iconsCount = m_showBlacklistButton ? 3 : 2; - const int maxHeight = size.height() * 2 / 3; - // minimum space between icnos is 2 pixels (number of spaces is iconsCount - 1) - int maxWidth = ( size.width() - ( iconsCount - 1 ) * 2 ) / iconsCount; - // minimum icon size is 14 pixels, hide icons until the remaining icons fit - while( maxWidth < 14 && iconsCount > 0 ) - { - iconsCount--; - maxWidth = ( size.width() - ( iconsCount - 1 ) * 2 ) / iconsCount; - } - const int iconsSize = qMin( maxHeight, maxWidth ); - // maximum space between icons left - const int iconsSpaceA = ( size.width() - iconsSize * iconsCount ) / ( iconsCount - 1 ); - // optimal space - const int iconsSpaceB = iconsSize / 2; - const int iconsSpace = qMin( iconsSpaceA, iconsSpaceB ); - // if there's enough space left, start the icons at the same position as the text - // align buttons left -// const int offset = qRound( qMin( ( size.width() - iconsSize * iconsCount - iconsSpace * ( iconsCount - 1 ) ) / 2, m_textItem->boundingRect().height() / 4 ) ); - // align buttons centered - const int offset = qRound( ( size.width() - iconsSize * iconsCount - iconsSpace * ( iconsCount - 1 ) ) / 2 ); - - m_addLabelItem.data()->setSize( iconsSize ); - m_addLabelItem.data()->setPos( offset, ( size.height() - iconsSize ) / 2 ); - m_removeLabelItem.data()->setSize( iconsSize ); - m_removeLabelItem.data()->setPos( offset, ( size.height() - iconsSize ) / 2 ); - m_listLabelItem.data()->setSize( iconsSize ); - m_listLabelItem.data()->setPos( offset + iconsSize + iconsSpace, ( size.height() - iconsSize ) / 2 ); - m_listLabelItem.data()->setEnabled( iconsCount >= 2 ); - m_blacklistLabelItem.data()->setSize( iconsSize ); - m_blacklistLabelItem.data()->setPos( offset + iconsSize * 2 + iconsSpace * 2, ( size.height() - iconsSize ) / 2 ); - m_blacklistLabelItem.data()->setEnabled( iconsCount >= 3 ); - - updateHoverStatus(); -} - -void -LabelGraphicsItem::updateHoverStatus() -{ - if( m_addLabelAnimation.data()->state() != QAbstractAnimation::Stopped ) - m_addLabelAnimation.data()->stop(); - if( m_removeLabelAnimation.data()->state() != QAbstractAnimation::Stopped ) - m_removeLabelAnimation.data()->stop(); - if( m_listLabelAnimation.data()->state() != QAbstractAnimation::Stopped ) - m_listLabelAnimation.data()->stop(); - if( m_blacklistLabelAnimation.data()->state() != QAbstractAnimation::Stopped ) - m_blacklistLabelAnimation.data()->stop(); - - if( isUnderMouse() ) - { - if( m_selected ) - { - m_addLabelItem.data()->setOpacity( 0.0 ); - m_removeLabelItem.data()->setOpacity( 1.0 ); - m_removeLabelItem.data()->updateHoverStatus(); - } - else - { - m_addLabelItem.data()->setOpacity( 1.0 ); - m_addLabelItem.data()->updateHoverStatus(); - m_removeLabelItem.data()->setOpacity( 0.0 ); - } - - if( m_listLabelItem.data()->isEnabled() ) - { - m_listLabelItem.data()->setOpacity( 1.0 ); - m_listLabelItem.data()->updateHoverStatus(); - } - - if( m_blacklistLabelItem.data()->isEnabled() ) - { - m_blacklistLabelItem.data()->setOpacity( 1.0 ); - m_blacklistLabelItem.data()->updateHoverStatus(); - } - - setHoverValue( 1.0 ); - } - else - { - m_addLabelItem.data()->setOpacity( 0.0 ); - m_removeLabelItem.data()->setOpacity( 0.0 ); - m_listLabelItem.data()->setOpacity( 0.0 ); - m_blacklistLabelItem.data()->setOpacity( 0.0 ); - - setHoverValue( 0.0 ); - } -} - -void -LabelGraphicsItem::hoverEnterEvent( QGraphicsSceneHoverEvent *event ) -{ - Q_UNUSED( event ) - - m_hoverValueAnimation.data()->setEndValue( 1.0 ); - m_hoverValueAnimation.data()->start(); - - if( m_addLabelAnimation.data()->state() != QAbstractAnimation::Stopped ) - m_addLabelAnimation.data()->stop(); - if( m_removeLabelAnimation.data()->state() != QAbstractAnimation::Stopped ) - m_removeLabelAnimation.data()->stop(); - if( m_listLabelAnimation.data()->state() != QAbstractAnimation::Stopped ) - m_listLabelAnimation.data()->stop(); - if( m_blacklistLabelAnimation.data()->state() != QAbstractAnimation::Stopped ) - m_blacklistLabelAnimation.data()->stop(); - - if( m_selected ) - { - m_removeLabelAnimation.data()->setEndValue( 1.0 ); - m_removeLabelAnimation.data()->start(); - } - else - { - m_addLabelAnimation.data()->setEndValue( 1.0 ); - m_addLabelAnimation.data()->start(); - } - - if( m_listLabelItem.data()->isEnabled() ) - { - m_listLabelAnimation.data()->setEndValue( 1.0 ); - m_listLabelAnimation.data()->start(); - } - - if( m_blacklistLabelItem.data()->isEnabled() ) - { - m_blacklistLabelAnimation.data()->setEndValue( 1.0 ); - m_blacklistLabelAnimation.data()->start(); - } - - update(); -} - -void -LabelGraphicsItem::hoverLeaveEvent( QGraphicsSceneHoverEvent *event ) -{ - Q_UNUSED( event ) - - if( m_addLabelAnimation.data()->state() != QAbstractAnimation::Stopped ) - m_addLabelAnimation.data()->stop(); - if( m_removeLabelAnimation.data()->state() != QAbstractAnimation::Stopped ) - m_removeLabelAnimation.data()->stop(); - if( m_listLabelAnimation.data()->state() != QAbstractAnimation::Stopped ) - m_listLabelAnimation.data()->stop(); - if( m_blacklistLabelAnimation.data()->state() != QAbstractAnimation::Stopped ) - m_blacklistLabelAnimation.data()->stop(); - - if( m_selected ) - { - m_removeLabelAnimation.data()->setEndValue( 0.0 ); - m_removeLabelAnimation.data()->start(); - } - else - { - m_addLabelAnimation.data()->setEndValue( 0.0 ); - m_addLabelAnimation.data()->start(); - } - - if( m_listLabelItem.data()->isEnabled() ) - { - m_listLabelAnimation.data()->setEndValue( 0.0 ); - m_listLabelAnimation.data()->start(); - } - - if( m_blacklistLabelItem.data()->isEnabled() ) - { - m_blacklistLabelAnimation.data()->setEndValue( 0.0 ); - m_blacklistLabelAnimation.data()->start(); - } - - m_hoverValueAnimation.data()->setEndValue( 0.0 ); - m_hoverValueAnimation.data()->start(); - - update(); -} - -void -LabelGraphicsItem::mousePressEvent( QGraphicsSceneMouseEvent *event ) -{ - if( m_addLabelItem.data()->boundingRect().contains( mapToItem( m_addLabelItem.data(), event->pos() ) ) || - m_removeLabelItem.data()->boundingRect().contains( mapToItem( m_removeLabelItem.data(), event->pos() ) ) ) - emit toggled( m_textItem->toPlainText() ); - else if( m_listLabelItem.data()->isEnabled() && m_listLabelItem.data()->boundingRect().contains( mapToItem( m_listLabelItem.data(), event->pos() ) ) ) - emit list( m_textItem->toPlainText() ); - else if( m_blacklistLabelItem.data()->isEnabled() && m_blacklistLabelItem.data()->boundingRect().contains( mapToItem( m_blacklistLabelItem.data(), event->pos() ) ) ) - emit blacklisted( m_textItem->toPlainText() ); -} - -qreal -LabelGraphicsItem::hoverValue() -{ - return m_hoverValue; -} - -void -LabelGraphicsItem::setHoverValue( qreal value ) -{ - m_hoverValue = value; - const QPalette p; - const QColor c = p.color( QPalette::WindowText ); - const QColor defaultColor = m_selected ? m_selectedColor : c; - - const int red = defaultColor.red() + ( m_hoverColor.red() - defaultColor.red() ) * m_hoverValue; - const int green = defaultColor.green() + ( m_hoverColor.green() - defaultColor.green() ) * m_hoverValue; - const int blue = defaultColor.blue() + ( m_hoverColor.blue() - defaultColor.blue() ) * m_hoverValue; - - m_textItem->setDefaultTextColor( QColor( red, green, blue ) ); -} - -QRectF -LabelGraphicsItem::boundingRect() const -{ - QRectF rect = m_textItem->boundingRect(); - rect.setWidth( rect.width() + qRound( rect.height() / 2 ) ); - return rect; -} - -void -LabelGraphicsItem::paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget ) -{ - Q_UNUSED( painter ) - Q_UNUSED( option ) - Q_UNUSED( widget ) -} - - diff --git a/amarok/src/context/applets/labels/LabelGraphicsItem.h b/amarok/src/context/applets/labels/LabelGraphicsItem.h deleted file mode 100644 index d0461ff8..00000000 --- a/amarok/src/context/applets/labels/LabelGraphicsItem.h +++ /dev/null @@ -1,96 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Daniel Faust * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef LABEL_GRAPHICS_ITEM_H -#define LABEL_GRAPHICS_ITEM_H - -#include "context/Applet.h" - -#include -#include - -class LabelOverlayButton; -class QGraphicsBlurEffect; -class QGraphicsPixmapItem; -class QGraphicsSceneHoverEvent; -class QGraphicsSceneMouseEvent; -class QGraphicsTextItem; -class QPropertyAnimation; - -class LabelGraphicsItem : public QGraphicsObject -{ - Q_OBJECT - Q_PROPERTY( qreal hoverValue READ hoverValue WRITE setHoverValue ) - Q_PROPERTY( QPointF pos READ pos WRITE setPos ) - -public: - LabelGraphicsItem( const QString& text, qreal deltaPointSize, QGraphicsItem *parent ); - ~LabelGraphicsItem(); - - QString text(); - void setText( const QString& text ); - void setDeltaPointSize( qreal deltaPointSize ); - void setSelected( bool selected ); - void setSelectedColor( QColor color ); - void setBackgroundColor( QColor color ); - void showBlacklistButton( bool enabled ); - - void updateHoverStatus(); - - QRectF boundingRect() const; - void paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget ); - -protected: - virtual void hoverLeaveEvent( QGraphicsSceneHoverEvent *event ); - virtual void hoverEnterEvent( QGraphicsSceneHoverEvent *event ); - virtual void mousePressEvent( QGraphicsSceneMouseEvent *event ); - -private: - qreal hoverValue(); - void setHoverValue( qreal value ); - void updateGeometry(); - - QGraphicsTextItem *m_textItem; - QGraphicsPixmapItem *m_backgroundItem; - QGraphicsBlurEffect *m_backgroundBlurEffect; - QColor m_backgroundColor; - - qreal m_hoverValue; - QColor m_hoverColor; - QWeakPointer m_hoverValueAnimation; - bool m_selected; - QColor m_selectedColor; - - bool m_showBlacklistButton; - - QWeakPointer m_addLabelItem; - QWeakPointer m_removeLabelItem; - QWeakPointer m_listLabelItem; - QWeakPointer m_blacklistLabelItem; - - QWeakPointer m_addLabelAnimation; - QWeakPointer m_removeLabelAnimation; - QWeakPointer m_listLabelAnimation; - QWeakPointer m_blacklistLabelAnimation; - -signals: - void toggled( const QString &label ); - void blacklisted( const QString &label ); - void list( const QString &label ); -}; - -#endif - diff --git a/amarok/src/context/applets/labels/LabelOverlayButton.cpp b/amarok/src/context/applets/labels/LabelOverlayButton.cpp deleted file mode 100644 index e3a95e98..00000000 --- a/amarok/src/context/applets/labels/LabelOverlayButton.cpp +++ /dev/null @@ -1,115 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Daniel Faust * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "LabelOverlayButton.h" - -#include -#include - -#include - - -LabelOverlayButton::LabelOverlayButton( QGraphicsItem *parent ) - : QGraphicsItem( parent ), - m_iconEffect( 0 ), - m_size( 8 ) -{ - setAcceptHoverEvents( true ); - - m_iconEffect = new KIconEffect(); -} - -LabelOverlayButton::~LabelOverlayButton() -{ - if( m_iconEffect ) - delete m_iconEffect; -} - -void -LabelOverlayButton::setPixmap( const QPixmap& pixmap ) -{ - m_pixmap = pixmap; - - if( isUnderMouse() ) - m_scaledPixmap = m_iconEffect->apply( m_pixmap.scaledToHeight( m_size, Qt::SmoothTransformation ), KIconLoader::Desktop, KIconLoader::ActiveState ); - else - m_scaledPixmap = m_pixmap.scaledToHeight( m_size, Qt::SmoothTransformation ); -} - -QPixmap -LabelOverlayButton::pixmap() -{ - return m_pixmap; -} - -void -LabelOverlayButton::setSize( int size ) -{ - m_size = size; - - if( isUnderMouse() ) - m_scaledPixmap = m_iconEffect->apply( m_pixmap.scaledToHeight( m_size, Qt::SmoothTransformation ), KIconLoader::Desktop, KIconLoader::ActiveState ); - else - m_scaledPixmap = m_pixmap.scaledToHeight( m_size, Qt::SmoothTransformation ); -} - -int -LabelOverlayButton::size() -{ - return m_size; -} - -void -LabelOverlayButton::updateHoverStatus() -{ - if( isUnderMouse() ) - m_scaledPixmap = m_iconEffect->apply( m_pixmap.scaledToHeight( m_size, Qt::SmoothTransformation ), KIconLoader::Desktop, KIconLoader::ActiveState ); - else - m_scaledPixmap = m_pixmap.scaledToHeight( m_size, Qt::SmoothTransformation ); -} - -void -LabelOverlayButton::hoverEnterEvent( QGraphicsSceneHoverEvent *event ) -{ - Q_UNUSED( event ) - - m_scaledPixmap = m_iconEffect->apply( m_pixmap.scaledToHeight( m_size, Qt::SmoothTransformation ), KIconLoader::Desktop, KIconLoader::ActiveState ); - update(); -} - -void -LabelOverlayButton::hoverLeaveEvent( QGraphicsSceneHoverEvent *event ) -{ - Q_UNUSED( event ) - - m_scaledPixmap = m_pixmap.scaledToHeight( m_size, Qt::SmoothTransformation ); - update(); -} - -QRectF -LabelOverlayButton::boundingRect() const -{ - return QRectF( QPointF( 0, 0 ), m_scaledPixmap.size() ); -} - -void -LabelOverlayButton::paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget ) -{ - Q_UNUSED( option ) - Q_UNUSED( widget ) - - painter->drawPixmap( 0, 0, m_scaledPixmap ); -} diff --git a/amarok/src/context/applets/labels/LabelOverlayButton.h b/amarok/src/context/applets/labels/LabelOverlayButton.h deleted file mode 100644 index f4ebf6f4..00000000 --- a/amarok/src/context/applets/labels/LabelOverlayButton.h +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Daniel Faust * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef LABEL_OVERLAY_BUTTON_H -#define LABEL_OVERLAY_BUTTON_H - -#include -#include - -class KIconEffect; -class QGraphicsSceneHoverEvent; -class QGraphicsSceneMouseEvent; -class QPainter; -class QStyleOptionGraphicsItem; -class QWidget; - -class LabelOverlayButton : public QObject, public QGraphicsItem -{ - Q_OBJECT - Q_INTERFACES( QGraphicsItem ) - Q_PROPERTY( qreal opacity READ opacity WRITE setOpacity ) - -public: - LabelOverlayButton( QGraphicsItem *parent ); - ~LabelOverlayButton(); - - void setPixmap( const QPixmap& pixmap ); - QPixmap pixmap(); - void setSize( int size ); - int size(); - void updateHoverStatus(); - - QRectF boundingRect() const; - void paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget ); - -protected: - virtual void hoverEnterEvent( QGraphicsSceneHoverEvent *event ); - virtual void hoverLeaveEvent( QGraphicsSceneHoverEvent *event ); - -private: - KIconEffect *m_iconEffect; - QPixmap m_pixmap; - QPixmap m_scaledPixmap; - int m_size; - -}; - -#endif diff --git a/amarok/src/context/applets/labels/LabelsApplet.cpp b/amarok/src/context/applets/labels/LabelsApplet.cpp deleted file mode 100644 index 69dccbbe..00000000 --- a/amarok/src/context/applets/labels/LabelsApplet.cpp +++ /dev/null @@ -1,875 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Leo Franchi * - * Copyright (c) 2009 simon.esneault * - * Copyright (c) 2010 Daniel Faust * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "LabelsApplet" - -#include "LabelsApplet.h" - -#include "App.h" -#include "EngineController.h" -#include "PaletteHandler.h" -#include "amarokurls/AmarokUrl.h" -#include "context/Theme.h" -#include "context/applets/labels/LabelGraphicsItem.h" -#include "context/widgets/AppletHeader.h" -#include "core/meta/Meta.h" -#include "core/support/Debug.h" - -#include -#include - -#include -#include -#include - -#include -#include -#include - -#define LabelsAppletMaxLabelLength 40 // if a downloaded label is longer than this, don't show it - -LabelsApplet::LabelsApplet( QObject *parent, const QVariantList &args ) - : Context::Applet( parent, args ), - m_lastLabelSize( QSizeF(0,0) ), - m_lastLabelBottomAdded( false ) -{ - setHasConfigurationInterface( true ); -} - -LabelsApplet::~LabelsApplet() -{ - DEBUG_BLOCK - qDeleteAll( m_labelItems ); - m_labelItems.clear(); - qDeleteAll( m_labelAnimations ); - m_labelAnimations.clear(); - qDeleteAll( m_labelItemsToDelete ); - m_labelItemsToDelete.clear(); - qDeleteAll( m_labelAnimationsToDelete ); - m_labelAnimationsToDelete.clear(); - - if( m_reloadIcon ) - delete m_reloadIcon.data(); - if( m_settingsIcon ) - delete m_settingsIcon.data(); -} - -void -LabelsApplet::init() -{ - DEBUG_BLOCK - - // Call the base implementation. - Context::Applet::init(); - - setBackgroundHints( Plasma::Applet::NoBackground ); - - // properly set the size, asking for the whole cv size. - resize( 500, -1 ); - - // this applet has to be on top of the applet below, otherwise the completion list of the combobox will shine through the other applet - setZValue( zValue() + 100 ); - - // Create the title label - enableHeader( true ); - setHeaderText( i18n( "Labels" ) ); - - setCollapseHeight( m_header->height() ); - setMinimumHeight( collapseHeight() ); - - // reload icon - QAction *reloadAction = new QAction( this ); - reloadAction->setIcon( KIcon( "view-refresh" ) ); - reloadAction->setVisible( true ); - reloadAction->setEnabled( true ); - reloadAction->setText( i18n( "Reload" ) ); - m_reloadIcon = addLeftHeaderAction( reloadAction ); - m_reloadIcon.data()->setEnabled( false ); - connect( m_reloadIcon.data(), SIGNAL(clicked()), this, SLOT(reload()) ); - - // settings icon - QAction *settingsAction = new QAction( this ); - settingsAction->setIcon( KIcon( "preferences-system" ) ); - settingsAction->setVisible( true ); - settingsAction->setEnabled( true ); - settingsAction->setText( i18n( "Settings" ) ); - m_settingsIcon = addRightHeaderAction( settingsAction ); - connect( m_settingsIcon.data(), SIGNAL(clicked()), this, SLOT(showConfigurationInterface()) ); - - QGraphicsLinearLayout *layout = new QGraphicsLinearLayout( Qt::Vertical, this ); - layout->addItem( m_header ); - - m_addLabelProxy = new QGraphicsProxyWidget( this ); - m_addLabelProxy.data()->setAttribute( Qt::WA_NoSystemBackground ); - m_addLabel = new KComboBox( this ); - m_addLabel.data()->setAttribute( Qt::WA_NoSystemBackground ); - m_addLabel.data()->setAutoFillBackground( false ); - QPalette p = m_addLabel.data()->palette(); - QColor c = p.color( QPalette::Base ); - c.setAlphaF( 0.4 ); - p.setColor( QPalette::Base, c ); - m_addLabel.data()->setPalette( p ); - m_addLabel.data()->completionObject()->setIgnoreCase( true ); - m_addLabel.data()->setCompletionMode( KGlobalSettings::CompletionPopup ); - connect( m_addLabel.data(), SIGNAL(returnPressed()), this, SLOT(addLabelPressed()) ); - m_addLabelProxy.data()->setWidget( m_addLabel.data() ); - - // Read config - KConfigGroup config = Amarok::config("Labels Applet"); - m_minCount = config.readEntry( "MinCount", 30 ); - m_numLabels = config.readEntry( "NumLabels", 10 ); - m_personalCount = config.readEntry( "PersonalCount", 70 ); - m_autoAdd = config.readEntry( "AutoAdd", false ); - m_minAutoAddCount = config.readEntry( "MinAutoAddCount", 60 ); - m_selectedColor = config.readEntry( "SelectedColor", PaletteHandler::highlightColor( 2.0, 0.7 ) ); - const QPalette pal; - m_backgroundColor = config.readEntry( "BackgroundColor", pal.color( QPalette::Base ) ); - - m_matchArtist = config.readEntry( "MatchArtist", true ); - m_matchTitle = config.readEntry( "MatchTitle", true ); - m_matchAlbum = config.readEntry( "MatchAlbum", true ); - m_blacklist = config.readEntry( "Blacklist", QStringList() ); - - const QStringList replacementList = config.readEntry( "ReplacementList", QStringList() ); - foreach( const QString &replacement, replacementList ) - { - const QStringList parts = replacement.split( '|' ); - QString label = parts.at(0); - label = label.replace( "%s", "|" ); - label = label.replace( "%p", "%" ); - QString replacementValue = parts.at(1); - replacementValue = replacementValue.replace( "%s", "|" ); - replacementValue = replacementValue.replace( "%p", "%" ); - m_replacementMap.insert( label, replacementValue ); - } - - m_stoppedstate = false; // force an update - setStoppedState( true ); - - connectSource( "labels" ); - connect( dataEngine( "amarok-labels" ), SIGNAL(sourceAdded(QString)), - this, SLOT(connectSource(QString)) ); -} - -void -LabelsApplet::setStoppedState( bool stopped ) -{ - if( stopped == m_stoppedstate ) - return; - - m_stoppedstate = stopped; - - m_userLabels.clear(); - m_webLabels.clear(); - - if( !stopped ) - { - m_reloadIcon.data()->setEnabled( true ); - m_titleText = i18n( "Labels" ); - m_addLabelProxy.data()->show(); - m_addLabel.data()->show(); - m_addLabel.data()->clearEditText(); - // not needed at the moment, since setStoppedState(false) is only called in dataUpdated() and we know that the engine never sends state=started without the user labels; - // so the minimum size is set in constraintsEvent() -// setCollapseOffHeight( m_header->height() + m_addLabelProxy.data()->size().height() + 2 * standardPadding() ); -// setCollapseOff(); - } - else - { - m_reloadIcon.data()->setEnabled( false ); - m_titleText = i18n( "Labels: No track playing" ); - m_addLabelProxy.data()->hide(); - m_addLabel.data()->hide(); - setBusy( false ); - qDeleteAll( m_labelItems ); - m_labelItems.clear(); - qDeleteAll( m_labelAnimations ); - m_labelAnimations.clear(); - setMinimumHeight( collapseHeight() ); - setCollapseOn(); - } -} - -void -LabelsApplet::reload() -{ - DEBUG_BLOCK - if( !m_stoppedstate ) - dataEngine( "amarok-labels" )->query( QString( "reload" ) ); -} - -void -LabelsApplet::animationFinished() -{ - if( QObject::sender() == 0 ) - return; - - for( int i=0; iupdateHoverStatus(); - m_labelAnimations.at(i)->setEasingCurve( QEasingCurve::InOutQuad ); - return; - } - } - - prepareGeometryChange(); - for( int i=0; i tempLabelsMap; - QMap < QString, int > finalLabelsMap; - // holds all counts of web labels that are added to the final list - QList < int > webCounts; - - // add the user assigned labels directly to the final map - for( int i = 0; i < m_userLabels.count(); i++ ) - { - finalLabelsMap.insert( m_userLabels.at( i ), m_personalCount ); - } - // add the downloaded labels to the temp map first (if they aren't already in the final map / update value in final map if necessary) - QMapIterator < QString, QVariant > it_infos ( m_webLabels ); - while( it_infos.hasNext() ) - { - it_infos.next(); - if( !finalLabelsMap.contains( it_infos.key() ) - && it_infos.value().toInt() >= m_minCount - && QString(it_infos.key()).length() <= LabelsAppletMaxLabelLength - && !m_blacklist.contains( it_infos.key() ) - && !( m_matchArtist && QString(it_infos.key()).toLower() == m_artist.toLower() ) - && !( m_matchTitle && QString(it_infos.key()).toLower() == m_title.toLower() ) - && !( m_matchAlbum && QString(it_infos.key()).toLower() == m_album.toLower() ) ) - { - tempLabelsMap.insert( it_infos.key(), it_infos.value().toInt() ); - } - else if( finalLabelsMap.contains( it_infos.key() ) - && it_infos.value().toInt() > finalLabelsMap[ it_infos.key() ] ) - { - finalLabelsMap[ it_infos.key() ] = it_infos.value().toInt(); - webCounts += it_infos.value().toInt(); - } - } - // then sort the values of the temp map - QList < int > tempLabelsValues = tempLabelsMap.values(); - qSort( tempLabelsValues.begin(), tempLabelsValues.end(), qGreater < int > () ); - // and copy the highest rated labels to the final map until max. number is reached - // if there are multiple items with equal low rating, move them to minList, sort it and add to the final map until max. number is reached - const int additionalNum = m_numLabels - finalLabelsMap.count(); - if( additionalNum > 0 && tempLabelsValues.count() > 0 ) - { - int minCount; - QStringList minList; - if( additionalNum <= tempLabelsValues.count() ) - minCount = tempLabelsValues.at( additionalNum - 1 ); - else - minCount = tempLabelsValues.last(); - QMapIterator < QString, int > it_temp ( tempLabelsMap ); - while( it_temp.hasNext() ) - { - it_temp.next(); - if( it_temp.value() > minCount ) - { - finalLabelsMap.insert( it_temp.key(), it_temp.value() ); - webCounts += it_temp.value(); - } - else if( it_temp.value() == minCount ) - { - minList += it_temp.key(); - } - } - minList.sort(); - while( minList.count() > 0 && finalLabelsMap.count() < m_numLabels ) - { - finalLabelsMap.insert( minList.first(), minCount ); - webCounts += minCount; - minList.takeFirst(); - } - } - // now make the label cloud nicer by determinating the quality of the web labels - // a lot of different values (73,68,51) is good, equal values (66,66,33) look suspicious - // 0.7 / 0.3 is a pretty moderate choice; 0.5 / 0.5 would be more extreme - const float qualityFactor = ( webCounts.count() > 0 ) ? 0.7 + 0.3 * webCounts.toSet().count()/webCounts.count() : 1.0; - // delete all unneeded label items - for( int i=0; itext() ) ) - { - m_labelAnimations.at(i)->setEndValue( QPointF( size().width(), m_labelItems.at(i)->pos().y() ) ); - m_labelAnimations.at(i)->setEasingCurve( QEasingCurve::InQuad ); - m_labelAnimations.at(i)->start(); - m_labelItemsToDelete.append( m_labelItems.at(i) ); - m_labelAnimationsToDelete.append( m_labelAnimations.at(i) ); - m_labelItems.removeAt(i); - m_labelAnimations.removeAt(i); - i--; - } - } - - // and finally create the LabelGraphicsItems - // add them to a temp list first, so they are in the same order as the final label items map (sorted alphabetically) - QList < LabelGraphicsItem * > tempLabelItems; - QList < QPropertyAnimation * > tempLabelAnimations; - QMapIterator < QString, int > it_final ( finalLabelsMap ); - while( it_final.hasNext() ) - { - it_final.next(); - - if( it_final.key().isEmpty() ) // empty labels don't make sense but they cause a freeze - continue; - - // quality of web labels adjusted value - int adjustedCount = qualityFactor * it_final.value(); - if( m_userLabels.contains( it_final.key() ) && adjustedCount < m_personalCount ) - adjustedCount = m_personalCount; - - const qreal f_size = qMax( adjustedCount / 10.0 - 5.0, -2.0 ); - - LabelGraphicsItem *labelGraphics = 0; - QPropertyAnimation *labelAnimation = 0; - for( int i=0; itext() == it_final.key() ) - { - labelGraphics = m_labelItems.at(i); - labelGraphics->setDeltaPointSize( f_size ); - labelGraphics->setSelected( m_userLabels.contains( it_final.key() ) ); - if( !m_lastLabelSize.isEmpty() && m_lastLabelName == m_labelItems.at(i)->text() ) - { - const qreal x = labelGraphics->pos().x() - ( labelGraphics->boundingRect().width() - m_lastLabelSize.width() ) / 2; - const qreal y = labelGraphics->pos().y() - ( labelGraphics->boundingRect().height() - m_lastLabelSize.height() ) / 2; - labelGraphics->setPos( x, y ); - m_lastLabelSize = QSizeF( 0, 0 ); - m_lastLabelName.clear(); - } - labelAnimation = m_labelAnimations.at(i); - break; - } - } - if( !labelGraphics ) - { - labelGraphics = new LabelGraphicsItem( it_final.key(), f_size, this ); - labelGraphics->setSelectedColor( m_selectedColor ); - labelGraphics->setBackgroundColor( m_backgroundColor ); - labelGraphics->showBlacklistButton( !m_allLabels.contains(it_final.key()) ); - labelGraphics->setSelected( m_userLabels.contains( it_final.key() ) ); - if( m_lastLabelBottomAdded ) - { - labelGraphics->setPos( m_addLabelProxy.data()->pos().x(), m_addLabelProxy.data()->pos().y() + m_addLabelProxy.data()->size().height()/2 - labelGraphics->boundingRect().height()/2 ); - m_lastLabelBottomAdded = false; - } - connect( labelGraphics, SIGNAL(toggled(QString)), SLOT(toggleLabel(QString)) ); - connect( labelGraphics, SIGNAL(list(QString)), SLOT(listLabel(QString)) ); - connect( labelGraphics, SIGNAL(blacklisted(QString)), SLOT(blacklistLabel(QString)) ); - - labelAnimation = new QPropertyAnimation( labelGraphics, "pos" ); - labelAnimation->setEasingCurve( QEasingCurve::OutQuad ); - connect( labelAnimation, SIGNAL(finished()), this, SLOT(animationFinished()) ); - } - tempLabelItems.append( labelGraphics ); - tempLabelAnimations.append( labelAnimation ); - } - // copy the temp list to the final list - m_labelItems = tempLabelItems; - m_labelAnimations = tempLabelAnimations; - - // should be unnecessary, but better safe than sorry - m_lastLabelName.clear(); - m_lastLabelSize = QSizeF( 0, 0 ); - m_lastLabelBottomAdded = false; - - constraintsEvent(); // don't use updateConstraints() in order to avoid labels displayed at pos. 0,0 for a moment -} - -void -LabelsApplet::constraintsEvent( Plasma::Constraints constraints ) -{ - Context::Applet::constraintsEvent( constraints ); - - setHeaderText( m_titleText ); - - if( !m_stoppedstate ) - { - const qreal horzontalPadding = standardPadding() / 2; - const qreal verticalPadding = standardPadding() / 2; - qreal x_pos; - qreal y_pos = m_header->boundingRect().bottom() + 1.5 * standardPadding(); - qreal width = 0; - qreal height = 0; - int start_index = 0; - int end_index = -1; - qreal max_width = size().width() - 2 * standardPadding(); - for( int i = 0; i < m_labelItems.count(); i++ ) - { - QRectF l_size = m_labelItems.at(i)->boundingRect(); - if( width + l_size.width() + horzontalPadding <= max_width || i == 0 ) - { - width += l_size.width(); - if( i != 0 ) - width += horzontalPadding; - if( l_size.height() > height ) - height = l_size.height(); - end_index = i; - } - else - { - x_pos = ( max_width - width ) / 2 + standardPadding(); - for( int j = start_index; j <= end_index; j++ ) - { - const QRectF c_size = m_labelItems.at(j)->boundingRect(); - const QPointF pos = QPointF( x_pos, y_pos + (height-c_size.height())/2 ); - if( m_labelItems.at(j)->pos() == QPointF(0,0) ) - m_labelItems.at(j)->setPos( -c_size.width(), pos.y() ); - m_labelAnimations.at(j)->setEndValue( pos ); - if( m_labelAnimations.at(j)->state() != QAbstractAnimation::Running ) - m_labelAnimations.at(j)->start(); - m_labelItems.at(j)->updateHoverStatus(); - x_pos += c_size.width() + horzontalPadding; - } - y_pos += height + verticalPadding; - width = l_size.width(); - height = l_size.height(); - start_index = i; - end_index = i; - } - } - x_pos = ( max_width - width ) / 2 + standardPadding(); - for( int j = start_index; j <= end_index; j++ ) - { - const QRectF c_size = m_labelItems.at(j)->boundingRect(); - const QPointF pos = QPointF( x_pos, y_pos + (height-c_size.height())/2 ); - if( m_labelItems.at(j)->pos() == QPointF(0,0) ) - m_labelItems.at(j)->setPos( -c_size.width(), pos.y() ); - m_labelAnimations.at(j)->setEndValue( pos ); - if( m_labelAnimations.at(j)->state() != QAbstractAnimation::Running ) - m_labelAnimations.at(j)->start(); - m_labelItems.at(j)->updateHoverStatus(); - x_pos += c_size.width() + horzontalPadding; - } - if( m_labelItems.count() > 0 ) - y_pos += height + standardPadding(); - - const qreal addLabelProxyWidth = qMin( size().width() - 2 * standardPadding(), (qreal)300.0 ); - m_addLabelProxy.data()->setPos( ( size().width() - addLabelProxyWidth ) / 2, y_pos ); - m_addLabelProxy.data()->setMinimumWidth( addLabelProxyWidth ); - m_addLabelProxy.data()->setMaximumWidth( addLabelProxyWidth ); - y_pos += m_addLabelProxy.data()->size().height() + standardPadding(); - - setMinimumHeight( y_pos ); - - setCollapseOffHeight( y_pos ); - setCollapseOff(); - } -} - -void -LabelsApplet::connectSource( const QString &source ) -{ - if( source == "labels" ) - dataEngine( "amarok-labels" )->connectSource( "labels", this ); -} - -void -LabelsApplet::dataUpdated( const QString &name, const Plasma::DataEngine::Data &data ) // SLOT -{ - Q_UNUSED( name ) - - if( data.isEmpty() ) - return; - - if( data.contains( "state" ) && data["state"].toString().contains("started") ) - setStoppedState( false ); - else if( data.contains( "state" ) && data["state"].toString().contains("stopped") ) - setStoppedState( true ); - - if( data.contains( "message" ) && data["message"].toString().contains("fetching") ) - { - m_titleText = i18n( "Labels: Fetching..." ); - if ( !data.contains( "user" ) ) // avoid calling update twice - { - constraintsEvent(); // don't use updateConstraints() in order to avoid labels displayed at pos. 0,0 for a moment - } - if( canAnimate() ) - setBusy( true ); - } - else if( data.contains( "message" ) ) - { - m_titleText = i18n( "Labels: %1", data[ "message" ].toString() ); - if( !data.contains( "user" ) ) // avoid calling update twice - { - constraintsEvent(); // don't use updateConstraints() in order to avoid labels displayed at pos. 0,0 for a moment - } - setBusy( false ); - } - - if( data.contains( "artist" ) ) - m_artist = data[ "artist" ].toString(); - - if( data.contains( "title" ) ) - m_title = data[ "title" ].toString(); - - if( data.contains( "album" ) ) - m_album = data[ "album" ].toString(); - - if( data.contains( "all" ) ) - { - m_allLabels = data[ "all" ].toStringList(); - m_allLabels.sort(); - - const QString saveText = m_addLabel.data()->lineEdit()->text(); - m_addLabel.data()->clear(); - m_addLabel.data()->insertItems( 0, m_allLabels ); - m_addLabel.data()->completionObject()->setItems( m_allLabels ); - m_addLabel.data()->lineEdit()->setText( saveText ); - } - - if( data.contains( "user" ) ) - { -// debug() << "new user labels:" << data[ "user" ].toStringList().join(", "); - if( !m_stoppedstate ) // otherwise there's been an error - { - m_userLabels = data[ "user" ].toStringList(); - m_webLabels.clear(); // we can saftly clear the web labels because user labels will never be updated without the web labels - - if( !data.contains( "web" ) ) // avoid calling updateLabels twice - updateLabels(); - } - } - - if( data.contains( "web" ) ) - { -// debug() << "new web labels:" << QStringList(data[ "web" ].toMap().keys()).join(", "); - if( !m_stoppedstate ) // otherwise there's been an error - { - if( !data.contains( "message" ) ) - m_titleText = i18n( "Labels for %1 by %2", m_title, m_artist ); - - setBusy( false ); - - m_webLabels = data[ "web" ].toMap(); - - // rename/merge web labels if they are present in the replacement map - QMap < QString, QVariant >::iterator it = m_webLabels.begin(); - while( it != m_webLabels.end() ) - { - if( m_replacementMap.contains(it.key()) ) - { - const QString replacement = m_replacementMap.value( it.key() ); - if( m_webLabels.contains(replacement) ) // we have to merge - { - m_webLabels[replacement] = qMin( 100, it.value().toInt() + m_webLabels.value(replacement).toInt() ); - it = m_webLabels.erase( it ); - } - else // just replace - { - const int count = it.value().toInt(); - it = m_webLabels.erase( it ); - m_webLabels.insert( replacement, count ); - } - } - else - { - ++it; - } - } - - // auto add labels if needed - if( m_userLabels.isEmpty() && m_autoAdd ) - { - QMapIterator < QString, QVariant > it ( m_webLabels ); - while( it.hasNext() ) - { - it.next(); - if( it.value().toInt() >= m_minAutoAddCount - && QString(it.key()).length() <= LabelsAppletMaxLabelLength - && !m_blacklist.contains( it.key() ) - && !( m_matchArtist && QString(it.key()).toLower() == m_artist.toLower() ) - && !( m_matchTitle && QString(it.key()).toLower() == m_title.toLower() ) - && !( m_matchAlbum && QString(it.key()).toLower() == m_album.toLower() ) ) - toggleLabel( it.key() ); - } - } - - updateLabels(); - } - } -} - -void -LabelsApplet::addLabelPressed() -{ - const QString label = m_addLabel.data()->currentText(); - - if( label.isEmpty() ) - return; - - if( !m_userLabels.contains( label ) ) - { - toggleLabel( label ); - m_addLabel.data()->clearEditText(); - } -} - -void -LabelsApplet::toggleLabel( const QString &label ) -{ - DEBUG_BLOCK - - if( label.isEmpty() ) - return; - - Meta::TrackPtr track = The::engineController()->currentTrack(); - if( !track ) - return; - - Meta::LabelPtr labelPtr; - - foreach( const Meta::LabelPtr &labelIt, track->labels() ) - { - if( label == labelIt->name() ) - { - labelPtr = labelIt; - break; - } - } - - for( int i=0; itext() == label ) - { - m_lastLabelSize = m_labelItems.at(i)->boundingRect().size(); - m_lastLabelName = label; - break; - } - } - - if( m_userLabels.contains( label ) ) - { - track->removeLabel( labelPtr ); - m_userLabels.removeAll( label ); - debug() << "removing label: " << label; - } - else - { - track->addLabel( label ); - m_userLabels.append( label ); - debug() << "adding label: " << label; - m_lastLabelBottomAdded = true; - } - - if( !m_allLabels.contains( label ) ) - { - m_allLabels.append( label ); - m_allLabels.sort(); - - const QString saveText = m_addLabel.data()->lineEdit()->text(); - m_addLabel.data()->clear(); - m_addLabel.data()->insertItems( 0, m_allLabels ); - m_addLabel.data()->completionObject()->setItems( m_allLabels ); - m_addLabel.data()->lineEdit()->setText( saveText ); - } - - // usuallay the engine keeps track of label changes of the playing track - // (except if the lables get auto added, this is why we have to keep m_userLabels up to date) - // but it doesn't work alway, so we update - updateLabels(); -} - -void -LabelsApplet::listLabel( const QString &label ) -{ - AmarokUrl bookmark( "amarok://navigate/collections?filter=label:" + AmarokUrl::escape( "=" ) + "%22" + AmarokUrl::escape( label ) + "%22" ); - bookmark.run(); -} - -void -LabelsApplet::blacklistLabel( const QString &label ) -{ - if( m_userLabels.contains( label ) ) - toggleLabel( label ); - - m_blacklist << label; - KConfigGroup config = Amarok::config("Labels Applet"); - config.writeEntry( "Blacklist", m_blacklist ); - - updateLabels(); -} - -void -LabelsApplet::createConfigurationInterface( KConfigDialog *parent ) -{ - DEBUG_BLOCK - - parent->setButtons( KDialog::Ok | KDialog::Cancel ); - - KConfigGroup configuration = config(); - QWidget *generalSettings = new QWidget; - ui_GeneralSettings.setupUi( generalSettings ); - ui_GeneralSettings.resetColorsPushButton->setIcon( KIcon("fill-color") ); - QWidget *blacklistSettings = new QWidget; - ui_BlacklistSettings.setupUi( blacklistSettings ); - QWidget *replacementSettings = new QWidget; - ui_ReplacementSettings.setupUi( replacementSettings ); - ui_ReplacementSettings.addPushButton->setIcon( KIcon("list-add") ); - ui_ReplacementSettings.removePushButton->setIcon( KIcon("list-remove") ); - - parent->addPage( generalSettings, i18n( "General Settings" ), "preferences-system" ); - parent->addPage( blacklistSettings, i18n( "Blacklist Settings" ), "flag-black" ); - parent->addPage( replacementSettings, i18n( "Replacement Settings" ), "system-search" ); - - ui_GeneralSettings.minCountSpinBox->setValue( m_minCount ); - ui_GeneralSettings.numLabelsSpinBox->setValue( m_numLabels ); - ui_GeneralSettings.personalCountSpinBox->setValue( m_personalCount ); - ui_GeneralSettings.autoAddCheckBox->setChecked( m_autoAdd ); - ui_GeneralSettings.minAutoAddCountSpinBox->setValue( m_minAutoAddCount ); - ui_GeneralSettings.selectedColorButton->setColor( m_selectedColor ); - ui_GeneralSettings.backgroundColorButton->setColor( m_backgroundColor ); - - ui_BlacklistSettings.matchArtistCheckBox->setChecked( m_matchArtist ); - ui_BlacklistSettings.matchTitleCheckBox->setChecked( m_matchTitle ); - ui_BlacklistSettings.matchAlbumCheckBox->setChecked( m_matchAlbum ); - ui_BlacklistSettings.blacklistEditListBox->insertStringList( m_blacklist ); - - QHashIterator < QString, QString > it ( m_replacementMap ); - while( it.hasNext() ) - { - it.next(); - new QTreeWidgetItem( ui_ReplacementSettings.replacementTreeWidget, QStringList() << it.key() << it.value() ); - } - - connect( ui_GeneralSettings.resetColorsPushButton, SIGNAL(clicked()), this, SLOT(settingsResetColors()) ); - connect( ui_ReplacementSettings.addPushButton, SIGNAL(clicked()), this, SLOT(settingsAddReplacement()) ); - connect( ui_ReplacementSettings.removePushButton, SIGNAL(clicked()), this, SLOT(settingsRemoveReplacement()) ); - connect( parent, SIGNAL(accepted()), this, SLOT(saveSettings()) ); -} - -void -LabelsApplet::saveSettings() -{ - DEBUG_BLOCK - KConfigGroup config = Amarok::config("Labels Applet"); - - m_minCount = ui_GeneralSettings.minCountSpinBox->value(); - m_numLabels = ui_GeneralSettings.numLabelsSpinBox->value(); - m_personalCount = ui_GeneralSettings.personalCountSpinBox->value(); - m_autoAdd = ui_GeneralSettings.autoAddCheckBox->checkState() == Qt::Checked; - m_minAutoAddCount = ui_GeneralSettings.minAutoAddCountSpinBox->value(); - m_selectedColor = ui_GeneralSettings.selectedColorButton->color(); - m_backgroundColor = ui_GeneralSettings.backgroundColorButton->color(); - - m_matchArtist = ui_BlacklistSettings.matchArtistCheckBox->checkState() == Qt::Checked; - m_matchTitle = ui_BlacklistSettings.matchTitleCheckBox->checkState() == Qt::Checked; - m_matchAlbum = ui_BlacklistSettings.matchAlbumCheckBox->checkState() == Qt::Checked; - m_blacklist = ui_BlacklistSettings.blacklistEditListBox->items(); - - m_replacementMap.clear(); - for( int i=0; itopLevelItemCount(); i++ ) - { - QTreeWidgetItem *item = ui_ReplacementSettings.replacementTreeWidget->topLevelItem( i ); - m_replacementMap.insert( item->text(0), item->text(1) ); - } - - config.writeEntry( "NumLabels", m_numLabels ); - config.writeEntry( "MinCount", m_minCount ); - config.writeEntry( "PersonalCount", m_personalCount ); - config.writeEntry( "AutoAdd", m_autoAdd ); - config.writeEntry( "MinAutoAddCount", m_minAutoAddCount ); - config.writeEntry( "SelectedColor", m_selectedColor ); - config.writeEntry( "BackgroundColor", m_backgroundColor ); - - config.writeEntry( "MatchArtist", m_matchArtist ); - config.writeEntry( "MatchTitle", m_matchTitle ); - config.writeEntry( "MatchAlbum", m_matchAlbum ); - config.writeEntry( "Blacklist", m_blacklist ); - - QStringList replacementList; - QHashIterator < QString, QString > it ( m_replacementMap ); - while( it.hasNext() ) - { - it.next(); - QString label = it.key(); - label = label.replace( '%', "%p" ); - label = label.replace( '|', "%s" ); - QString replacement = it.value(); - replacement = replacement.replace( '%', "%p" ); - replacement = replacement.replace( '|', "%s" ); - replacementList.append( label + '|' + replacement ); - } - config.writeEntry( "ReplacementList", replacementList ); - - for( int i=0; isetSelectedColor( m_selectedColor ); - m_labelItems.at(i)->setBackgroundColor( m_backgroundColor ); - } - - reload(); -} - -void -LabelsApplet::settingsResetColors() -{ - ui_GeneralSettings.selectedColorButton->setColor( PaletteHandler::highlightColor( 2.0, 0.7 ) ); - const QPalette pal; - ui_GeneralSettings.backgroundColorButton->setColor( pal.color( QPalette::Base ) ); -} - -void -LabelsApplet::settingsAddReplacement() -{ - const QString label = ui_ReplacementSettings.labelLineEdit->text(); - const QString replacement = ui_ReplacementSettings.replacementLineEdit->text(); - - if( label.isEmpty() || replacement.isEmpty() ) - return; - - new QTreeWidgetItem( ui_ReplacementSettings.replacementTreeWidget, QStringList() << label << replacement ); - ui_ReplacementSettings.labelLineEdit->clear(); - ui_ReplacementSettings.replacementLineEdit->clear(); -} - -void -LabelsApplet::settingsRemoveReplacement() -{ - for( int i=0; itopLevelItemCount(); i++ ) - { - QTreeWidgetItem *item = ui_ReplacementSettings.replacementTreeWidget->topLevelItem( i ); - if( item->isSelected() ) - { - ui_ReplacementSettings.replacementTreeWidget->takeTopLevelItem( i ); - i--; - } - } -} - - -#include "moc_LabelsApplet.cpp" diff --git a/amarok/src/context/applets/labels/LabelsApplet.h b/amarok/src/context/applets/labels/LabelsApplet.h deleted file mode 100644 index 6f651ac7..00000000 --- a/amarok/src/context/applets/labels/LabelsApplet.h +++ /dev/null @@ -1,124 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Leo Franchi * - * Copyright (c) 2009 simon.esneault * - * Copyright (c) 2010 Daniel Faust * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef LABELS_APPLET_H -#define LABELS_APPLET_H - -#include "context/Applet.h" -#include "context/DataEngine.h" - -#include -#include -#include - -#include - -class LabelGraphicsItem; -class KComboBox; -class QGraphicsProxyWidget; - - -class LabelsApplet : public Context::Applet -{ - Q_OBJECT - -public: - LabelsApplet( QObject *parent, const QVariantList &args ); - ~LabelsApplet(); - - void constraintsEvent( Plasma::Constraints constraints = Plasma::AllConstraints ); - -public slots: - virtual void init(); - void dataUpdated( const QString &name, const Plasma::DataEngine::Data &data ); - void connectSource( const QString &source ); - void toggleLabel( const QString &label ); - void listLabel( const QString &label ); - void blacklistLabel( const QString &label ); - void addLabelPressed(); - void saveSettings(); - -protected: - void createConfigurationInterface( KConfigDialog *parent ); - -private: - void updateLabels(); - void setStoppedState( bool stopped ); - - QWeakPointer m_reloadIcon; - QWeakPointer m_settingsIcon; - QString m_titleText; - QWeakPointer m_addLabelProxy; - QWeakPointer m_addLabel; - - // all labels currently used by the user in the collection (used for the combobox at the bottom) - QStringList m_allLabels; - // labels assigned to the current track - QStringList m_userLabels; - // labels received through last.fm - QMap < QString, QVariant > m_webLabels; - - // the list of the active label items and their animations - both lists have to be in sync - QList < LabelGraphicsItem * > m_labelItems; - QList < QPropertyAnimation * > m_labelAnimations; - - // the list of the label items that are about to be delete and are "flying out" and their animations - both lists have to be in sync - QList < LabelGraphicsItem * > m_labelItemsToDelete; - QList < QPropertyAnimation * > m_labelAnimationsToDelete; - - // configuration values - int m_numLabels; - int m_minCount; - int m_personalCount; - bool m_autoAdd; - int m_minAutoAddCount; - bool m_matchArtist; - bool m_matchTitle; - bool m_matchAlbum; - QStringList m_blacklist; - QColor m_selectedColor; - QColor m_backgroundColor; - - QHash < QString, QString > m_replacementMap; - - bool m_stoppedstate; - QString m_artist; - QString m_title; - QString m_album; - - // some information about the last label that the user interacted with so we can optimize the view - QString m_lastLabelName; // the label name in order to find it if it got toggled - QSizeF m_lastLabelSize; // if the user toggles a label it should be realigned because it's size will change - bool m_lastLabelBottomAdded; // if the user adds a label through the combobox the animation should start at the combobox - - Ui::labelsGeneralSettings ui_GeneralSettings; - Ui::labelsBlacklistSettings ui_BlacklistSettings; - Ui::labelsReplacementSettings ui_ReplacementSettings; - -private slots: - void reload(); - void animationFinished(); - void settingsResetColors(); - void settingsAddReplacement(); - void settingsRemoveReplacement(); - -}; - -AMAROK_EXPORT_APPLET( labels, LabelsApplet ) - -#endif diff --git a/amarok/src/context/applets/labels/amarok-context-applet-labels.desktop b/amarok/src/context/applets/labels/amarok-context-applet-labels.desktop deleted file mode 100644 index 470afcec..00000000 --- a/amarok/src/context/applets/labels/amarok-context-applet-labels.desktop +++ /dev/null @@ -1,67 +0,0 @@ -[Desktop Entry] -Name=Labels -Name[bg]=Етикети -Name[bs]=Oznake -Name[ca]=Etiquetes -Name[ca@valencia]=Etiquetes -Name[cs]=Popisky -Name[da]=Etiketter -Name[de]=Stichwörter -Name[el]=Ετικέτες -Name[en_GB]=Labels -Name[es]=Etiquetas -Name[et]=Märgendid -Name[eu]=Etiketak -Name[fa]=برچسبها -Name[fi]=Nimikkeet -Name[fr]=Étiquettes -Name[ga]=Lipéid -Name[gl]=Etiquetas -Name[hu]=Címkék -Name[id]=Label -Name[it]=Etichette -Name[ja]=ラベル -Name[km]=ស្លាក -Name[ko]=레이블 -Name[lt]=Etiketės -Name[lv]=Uzraksti -Name[mai]=लेबल -Name[mr]=लेबले -Name[nb]=Etiketter -Name[nds]=Slötelwöör -Name[nl]=Labels -Name[pa]=ਲੇਬਲ -Name[pl]=Etykiety -Name[pt]=Legendas -Name[pt_BR]=Rótulos -Name[ro]=Etichete -Name[ru]=Метки -Name[sk]=Popisy -Name[sl]=Oznake -Name[sr]=Етикете -Name[sr@ijekavian]=Етикете -Name[sr@ijekavianlatin]=Etikete -Name[sr@latin]=Etikete -Name[sv]=Etiketter -Name[tr]=Etiketler -Name[ug]=ئەنلەر -Name[uk]=Мітки -Name[x-test]=xxLabelsxx -Name[zh_CN]=标签 -Name[zh_TW]=標籤 -Type=Service -Icon=label-amarok -ServiceTypes=Plasma/Applet - -X-KDE-Library=amarok_context_applet_labels -X-KDE-PluginInfo-Author=Daniel Faust -X-KDE-PluginInfo-Email=hessijames@gmail.com -X-KDE-PluginInfo-Name=labels -X-KDE-PluginInfo-Version=0.3 -X-KDE-PluginInfo-Website= -X-KDE-PluginInfo-Depends= -X-KDE-PluginInfo-License=GPL -X-KDE-PluginInfo-EnabledByDefault=true -X-KDE-ParentApp=amarok -X-KDE-PluginInfo-Category=Current - diff --git a/amarok/src/context/applets/labels/labelsBlacklistSettings.ui b/amarok/src/context/applets/labels/labelsBlacklistSettings.ui deleted file mode 100644 index 2c5ddd35..00000000 --- a/amarok/src/context/applets/labels/labelsBlacklistSettings.ui +++ /dev/null @@ -1,92 +0,0 @@ - - - labelsBlacklistSettings - - - - 0 - 0 - 414 - 306 - - - - - - - Do not show the following labels: - - - - - - - Labels matching the artist - - - - - - - Labels matching the title - - - - - - - Labels matching the album - - - - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 20 - 10 - - - - - - - - Blacklist: - - - - - - - - - - - - - KEditListWidget::Add|KEditListWidget::Remove - - - - - - - - - - - KEditListWidget - QWidget -
keditlistwidget.h
-
-
- - -
diff --git a/amarok/src/context/applets/labels/labelsGeneralSettings.ui b/amarok/src/context/applets/labels/labelsGeneralSettings.ui deleted file mode 100644 index 20db0f52..00000000 --- a/amarok/src/context/applets/labels/labelsGeneralSettings.ui +++ /dev/null @@ -1,363 +0,0 @@ - - - labelsGeneralSettings - - - - 0 - 0 - 386 - 322 - - - - - 0 - 0 - - - - Labels Settings - - - - - - 0 - - - - - - 0 - 0 - - - - Minimum label score: - - - - - - - - 0 - 0 - - - - - 100 - 0 - - - - Show only labels that are rated at least that high. - - - % - - - 100 - - - - - - - - 0 - 0 - - - - Maximum labels to show: - - - - - - - - 0 - 0 - - - - - 100 - 0 - - - - Do not show more than this many labels. -Note that personal labels will always be shown. - - - - - - - - 0 - 0 - - - - Show personal labels with score: - - - - - - - - 0 - 0 - - - - - 100 - 0 - - - - Affects the font size of the personal labels. - - - % - - - 100 - - - 1 - - - - - - - - - Automatically add downloaded labels if none are assigned - - - - - - - 30 - - - 0 - - - - - false - - - - 0 - 0 - - - - Minimum label score: - - - - - - - false - - - - 100 - 0 - - - - Add only labels that are rated at least that high. - - - % - - - 100 - - - - - - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 20 - 20 - - - - - - - - 0 - - - - - - 0 - 0 - - - - Color for assigned labels: - - - - - - - - 100 - 0 - - - - - - - - - - 0 - - - - - - 0 - 0 - - - - Color for labels background: - - - - - - - - 100 - 0 - - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 100 - 0 - - - - Sets the label colors according to the current color scheme. - - - Reset colors - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - KColorButton - QPushButton -
kcolorbutton.h
-
-
- - - - autoAddCheckBox - toggled(bool) - minAutoAddCountSpinBox - setEnabled(bool) - - - 201 - 108 - - - 308 - 137 - - - - - autoAddCheckBox - toggled(bool) - minAutoAddCountLabel - setEnabled(bool) - - - 201 - 108 - - - 124 - 137 - - - - -
diff --git a/amarok/src/context/applets/labels/labelsReplacementSettings.ui b/amarok/src/context/applets/labels/labelsReplacementSettings.ui deleted file mode 100644 index 2218a41d..00000000 --- a/amarok/src/context/applets/labels/labelsReplacementSettings.ui +++ /dev/null @@ -1,152 +0,0 @@ - - - labelsReplacementSettings - - - - 0 - 0 - 461 - 334 - - - - - - - - - Replace downloaded label - - - - - - - - 80 - 0 - - - - - - - - with - - - - - - - - 80 - 0 - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 10 - 10 - - - - - - - - Add - - - - - - - - - This will help you keep your label collection clean by replacing downloaded labels according to your preferences. -Eg. "hip hop" -> "hip-hop" - - - QAbstractItemView::ExtendedSelection - - - false - - - true - - - 200 - - - 100 - - - - Downloaded label - - - - - Replacement - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Remove selected - - - - - - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 20 - 60 - - - - - - - - - diff --git a/amarok/src/context/applets/lyrics/CMakeLists.txt b/amarok/src/context/applets/lyrics/CMakeLists.txt deleted file mode 100644 index 62f50f57..00000000 --- a/amarok/src/context/applets/lyrics/CMakeLists.txt +++ /dev/null @@ -1,21 +0,0 @@ -project(context-currenttrack) - -set(lyrics_SRCS - LyricsApplet.cpp - LyricsBrowser.cpp - LyricsSuggestionsListWidget.cpp - lyricsSettings.ui -) - -include_directories( ../.. - ../../.. ) - -kde4_add_plugin(amarok_context_applet_lyrics ${lyrics_SRCS}) -target_link_libraries(amarok_context_applet_lyrics - amarokcore - amaroklib - ${KDE4_PLASMA_LIBS} -) - -install(TARGETS amarok_context_applet_lyrics DESTINATION ${PLUGIN_INSTALL_DIR}) -install(FILES amarok-context-applet-lyrics.desktop DESTINATION ${SERVICES_INSTALL_DIR}) diff --git a/amarok/src/context/applets/lyrics/LyricsApplet.cpp b/amarok/src/context/applets/lyrics/LyricsApplet.cpp deleted file mode 100644 index ad856b56..00000000 --- a/amarok/src/context/applets/lyrics/LyricsApplet.cpp +++ /dev/null @@ -1,738 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Leo Franchi * - * Copyright (c) 2009 simon.esneault * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "LyricsApplet" - -#include "LyricsApplet.h" - -#include "EngineController.h" -#include "context/widgets/AppletHeader.h" -#include "core/meta/Meta.h" -#include "core/support/Amarok.h" -#include "core/support/Debug.h" -#include "context/LyricsManager.h" -#include "LyricsBrowser.h" -#include "LyricsSuggestionsListWidget.h" -#include "scripting/scriptmanager/ScriptManager.h" - -#include -#include -#include - -#include - -#include -#include -#include -#include - -class LyricsAppletPrivate -{ -public: - LyricsAppletPrivate( LyricsApplet *parent ) - : saveIcon( 0 ) - , editIcon( 0 ) - , autoScrollIcon( 0 ) - , reloadIcon( 0 ) - , closeIcon( 0 ) - , settingsIcon( 0 ) - , browser( 0 ) - , suggestView( 0 ) - , currentTrack( 0 ) - , alignment( Qt::AlignLeft ) - , hasLyrics( false ) - , showBrowser( false ) - , showSuggestions( false ) - , isShowingUnsavedWarning( false ) - , userAutoScrollOffset( 0 ) - , oldSliderPosition( 0 ) - , q_ptr( parent ) {} - ~LyricsAppletPrivate() {} - - // member functions - void setEditing( bool isEditing ); - void determineActionIconsState(); - void refetchLyrics(); - void showLyrics( const QString &text ); - void showSuggested( const QVariantList &suggestions ); - void showUnsavedChangesWarning( Meta::TrackPtr ); - - // private slots - void _editLyrics(); - void _changeLyricsAlignment(); - void _changeLyricsFont(); - void _closeLyrics(); - void _saveLyrics(); - void _toggleAutoScroll(); - void _suggestionChosen( const LyricsSuggestion &suggestion ); - void _unsetCursor(); - void _trackDataChanged( Meta::TrackPtr ); - void _trackPositionChanged( qint64 position, bool userSeek ); - - void _lyricsChangedMessageButtonPressed( const Plasma::MessageButton button ); - void _refetchMessageButtonPressed( const Plasma::MessageButton button ); - - Plasma::IconWidget *saveIcon; - Plasma::IconWidget *editIcon; - Plasma::IconWidget *autoScrollIcon; - Plasma::IconWidget *reloadIcon; - Plasma::IconWidget *closeIcon; - Plasma::IconWidget *settingsIcon; - - LyricsBrowser *browser; - LyricsSuggestionsListWidget *suggestView; - - Ui::lyricsSettings ui_settings; - - Meta::TrackPtr currentTrack; - Meta::TrackPtr modifiedTrack; - QString modifiedLyrics; - - Qt::Alignment alignment; - - bool hasLyrics; - bool showBrowser; - bool autoScroll; - bool showSuggestions; - bool isShowingUnsavedWarning; - int userAutoScrollOffset; - int oldSliderPosition; - -private: - LyricsApplet *const q_ptr; - Q_DECLARE_PUBLIC( LyricsApplet ) -}; - -void -LyricsAppletPrivate::setEditing( bool isEditing ) -{ - browser->setReadOnly( !isEditing ); -} - -void -LyricsAppletPrivate::determineActionIconsState() -{ - bool isEditing = !browser->isReadOnly(); - - editIcon->action()->setEnabled( !isEditing ); - closeIcon->action()->setEnabled( isEditing ); - saveIcon->action()->setEnabled( isEditing ); - autoScrollIcon->action()->setEnabled( !isEditing ); - reloadIcon->action()->setEnabled( !isEditing ); -} - -void -LyricsAppletPrivate::showLyrics( const QString &text ) -{ - browser->clear(); - browser->setLyrics( text ); - showSuggestions = false; - showBrowser = true; - determineActionIconsState(); -} - -void -LyricsAppletPrivate::showSuggested( const QVariantList &suggestions ) -{ - editIcon->action()->setEnabled( false ); - closeIcon->action()->setEnabled( false ); - saveIcon->action()->setEnabled( false ); - - suggestView->clear(); - foreach( const QVariant &suggestion, suggestions ) - { - QStringList s( suggestion.toStringList() ); - QString title( s.at(0) ); - QString artist( s.at(1) ); - KUrl url( s.at(2) ); - LyricsSuggestion lyricsSuggestion = { url, title, artist }; - suggestView->add( lyricsSuggestion ); - } - showSuggestions = true; -} - -void -LyricsAppletPrivate::refetchLyrics() -{ - DEBUG_BLOCK - ScriptManager::instance()->notifyFetchLyrics( currentTrack->artist()->name(), - currentTrack->name(), "", currentTrack ); -} - -void -LyricsAppletPrivate::showUnsavedChangesWarning( Meta::TrackPtr newTrack ) -{ - Q_Q( LyricsApplet ); - - // Set the track which was modified and store the current - // lyircs from the UI. - modifiedTrack = currentTrack; - modifiedLyrics = browser->lyrics(); - - QString artistName = modifiedTrack->artist() ? modifiedTrack->artist()->name() : i18nc( "Used if the current track has no artist.", "Unknown" ); - QString warningMessage; - - // Check if the track has changed. - if( newTrack != modifiedTrack ) - { - // Show a warning that the track has changed while the user was editing the lyrics for the current track. - warningMessage = i18n( "While you were editing the lyrics of %1 - %2 the track has changed. Do you want to save your changes?", - artistName, - modifiedTrack->prettyName() ); - } - else - { - // Show a warning that the lyrics for the track were modified (for example by a script). - warningMessage = i18n( "The lyrics of %1 - %2 changed while you were editing them. Do you want to save your changes?", - artistName, - modifiedTrack->prettyName() ); - } - - // Show the warning message. - q->showWarning( warningMessage, SLOT(_lyricsChangedMessageButtonPressed(Plasma::MessageButton)) ); - - // Make the contents readonly again. - // Since the applet is now blocked the user can not enable this again. - // Thus we can make sure that we won't overwrite modifiedTrack. - setEditing( false ); - - isShowingUnsavedWarning = false; -} - -void LyricsAppletPrivate::_refetchMessageButtonPressed( const Plasma::MessageButton button ) -{ - DEBUG_BLOCK - // Check if the user pressed "Yes". - if( button == Plasma::ButtonYes ) - // Refetch the lyrics. - refetchLyrics(); -} - -void LyricsAppletPrivate::_lyricsChangedMessageButtonPressed( const Plasma::MessageButton button ) -{ - DEBUG_BLOCK - // Check if the user pressed "Yes". - if( button == Plasma::ButtonYes ) - // Update the lyrics of the track. - modifiedTrack->setCachedLyrics( modifiedLyrics ); - - modifiedLyrics.clear(); -} - -void -LyricsAppletPrivate::_changeLyricsAlignment() -{ - if( ui_settings.alignLeft->isChecked() ) - alignment = Qt::AlignLeft; - else if( ui_settings.alignCenter->isChecked() ) - alignment = Qt::AlignCenter; - else if( ui_settings.alignRight->isChecked() ) - alignment = Qt::AlignRight; - Amarok::config("Lyrics Applet").writeEntry( "Alignment", int(alignment) ); - browser->setAlignment( alignment ); -} - -void -LyricsAppletPrivate::_changeLyricsFont() -{ - QFont font = ui_settings.fontChooser->font(); - browser->nativeWidget()->setFont( font ); - KConfigGroup config = Amarok::config("Lyrics Applet"); - config.writeEntry( "Font", font.toString() ); - debug() << "Setting Lyrics Applet font: " << font.family() << " " << font.pointSize(); -} - -void -LyricsAppletPrivate::_editLyrics() -{ - if( !hasLyrics ) - browser->clear(); - - Q_Q( LyricsApplet ); - if( q->isCollapsed() ) - q->setCollapseOff(); - - // disable autoscroll when starting editing - if (autoScroll) - _toggleAutoScroll(); - - if( !browser->isVisible() ) - { - browser->show(); - suggestView->hide(); - suggestView->clear(); - QGraphicsLinearLayout *lo = static_cast( q->layout() ); - lo->removeItem( suggestView ); - lo->addItem( browser ); - } - - browser->setAlignment( Qt::AlignLeft ); - setEditing( true ); - determineActionIconsState(); - browser->nativeWidget()->ensureCursorVisible(); -} - -void -LyricsAppletPrivate::_closeLyrics() -{ - if( hasLyrics ) - { - QScrollBar *vbar = browser->nativeWidget()->verticalScrollBar(); - int savedPosition = vbar->isVisible() ? vbar->value() : vbar->minimum(); - - showLyrics( currentTrack->cachedLyrics() ); - vbar->setSliderPosition( savedPosition ); - // emit sizeHintChanged(Qt::MaximumSize); - } - else - { - browser->clear(); - } - - setEditing( false ); - browser->setAlignment( alignment ); - determineActionIconsState(); -} - -void -LyricsAppletPrivate::_saveLyrics() -{ - if( currentTrack ) - { - if( !LyricsManager::self()->isEmpty( browser->nativeWidget()->toPlainText() ) ) - { - currentTrack->setCachedLyrics( browser->lyrics() ); - hasLyrics = true; - } - else - { - currentTrack->setCachedLyrics( QString() ); - hasLyrics = false; - } - // emit sizeHintChanged(Qt::MaximumSize); - } - - setEditing( false ); - browser->setAlignment( alignment ); - determineActionIconsState(); -} - -void -LyricsAppletPrivate::_toggleAutoScroll() -{ - Q_Q( LyricsApplet ); - Plasma::IconWidget *icon = qobject_cast(q->sender()); - DEBUG_ASSERT( icon, return ) // that should not happen - - autoScroll = !autoScroll; - icon->setPressed( autoScroll ); - Amarok::config( "Lyrics Applet" ).writeEntry( "AutoScroll", autoScroll ); -} - -void -LyricsAppletPrivate::_suggestionChosen( const LyricsSuggestion &suggestion ) -{ - DEBUG_BLOCK - KUrl url = suggestion.url; - if( !url.isValid() ) - return; - - QString title = suggestion.title; - QString artist = suggestion.artist; - - Q_Q( LyricsApplet ); - debug() << "clicked suggestion" << url; - ScriptManager::instance()->notifyFetchLyrics( artist, title, url.url(), Meta::TrackPtr() ); - suggestView->setCursor( Qt::BusyCursor ); - QTimer::singleShot( 10000, q, SLOT(_unsetCursor()) ); -} - -void -LyricsAppletPrivate::_unsetCursor() -{ - if( suggestView->hasCursor() ) - suggestView->unsetCursor(); -} - -void -LyricsAppletPrivate::_trackDataChanged( Meta::TrackPtr track ) -{ - userAutoScrollOffset = 0; - oldSliderPosition = 0; - - // Check if we previously had a track. - // If the lyrics currently shown in the browser (which - // additionally is in edit mode) are different from the - // lyrics of the track we have to show a warning. - if( !isShowingUnsavedWarning && currentTrack && - !browser->isReadOnly() && - (currentTrack->cachedLyrics() != browser->lyrics()) ) - { - isShowingUnsavedWarning = true; - showUnsavedChangesWarning( track ); - } - - // Update the current track. - currentTrack = track; -} - -void -LyricsAppletPrivate::_trackPositionChanged( qint64 position, bool userSeek ) -{ - Q_UNUSED( userSeek ); - EngineController *engine = The::engineController(); - QScrollBar *vbar = browser->nativeWidget()->verticalScrollBar(); - if( engine->trackPositionMs() != 0 && !vbar->isSliderDown() && autoScroll ) - { - userAutoScrollOffset = userAutoScrollOffset + vbar->value() - oldSliderPosition; - - //prevent possible devision by 0 (example streams). - if( engine->trackLength() == 0 ) - return; - // Scroll to try and keep the current position in the lyrics centred. - int newSliderPosition = - position * (vbar->maximum() + vbar->pageStep()) / engine->trackLength() - - vbar->pageStep() / 2 + userAutoScrollOffset; - vbar->setSliderPosition( newSliderPosition ); - - oldSliderPosition = vbar->value(); - } -} - - -LyricsApplet::LyricsApplet( QObject* parent, const QVariantList& args ) - : Context::Applet( parent, args ) - , d_ptr( new LyricsAppletPrivate( this ) ) -{ - setHasConfigurationInterface( true ); - setBackgroundHints( Plasma::Applet::NoBackground ); -} - -LyricsApplet::~LyricsApplet() -{ - delete d_ptr; -} - -void -LyricsApplet::init() -{ - DEBUG_BLOCK - - Q_D( LyricsApplet ); - - // Call the base implementation. - Context::Applet::init(); - - enableHeader( true ); - setHeaderText( i18n( "Lyrics" ) ); - - setCollapseOffHeight( -1 ); - setCollapseHeight( m_header->height() ); - setMinimumHeight( collapseHeight() ); - setPreferredHeight( collapseHeight() ); - - QAction* editAction = new QAction( this ); - editAction->setIcon( KIcon( "document-edit" ) ); - editAction->setEnabled( false ); - editAction->setText( i18n( "Edit Lyrics" ) ); - d->editIcon = addLeftHeaderAction( editAction ); - connect( d->editIcon, SIGNAL(clicked()), this, SLOT(_editLyrics()) ); - - QAction* saveAction = new QAction( this ); - saveAction->setIcon( KIcon( "document-save" ) ); - saveAction->setEnabled( false ); - saveAction->setText( i18n( "Save Lyrics" ) ); - d->saveIcon = addLeftHeaderAction( saveAction ); - connect( d->saveIcon, SIGNAL(clicked()), this, SLOT(_saveLyrics()) ); - - QAction* closeAction = new QAction( this ); - closeAction->setIcon( KIcon( "document-close" ) ); - closeAction->setEnabled( false ); - closeAction->setText( i18n( "Close" ) ); - d->closeIcon = addLeftHeaderAction( closeAction ); - connect( d->closeIcon, SIGNAL(clicked()), this, SLOT(_closeLyrics()) ); - - QAction* autoScrollAction = new QAction( this ); - autoScrollAction->setIcon( KIcon( QPixmap( KStandardDirs::locate( "data", "amarok/images/playlist-sorting-16.png" ) ) ) ); - autoScrollAction->setEnabled( true ); - autoScrollAction->setText( i18n( "Scroll automatically" ) ); - d->autoScrollIcon = addRightHeaderAction( autoScrollAction ); - connect( d->autoScrollIcon, SIGNAL(clicked()), this, SLOT(_toggleAutoScroll()) ); - - QAction* reloadAction = new QAction( this ); - reloadAction->setIcon( KIcon( "view-refresh" ) ); - reloadAction->setEnabled( true ); - reloadAction->setText( i18n( "Reload Lyrics" ) ); - d->reloadIcon = addRightHeaderAction( reloadAction ); - connect( d->reloadIcon, SIGNAL(clicked()), this, SLOT(refreshLyrics()) ); - - QAction* settingsAction = new QAction( this ); - settingsAction->setIcon( KIcon( "preferences-system" ) ); - settingsAction->setEnabled( true ); - settingsAction->setText( i18n( "Settings" ) ); - d->settingsIcon = addRightHeaderAction( settingsAction ); - connect( d->settingsIcon, SIGNAL(clicked()), this, SLOT(showConfigurationInterface()) ); - - d->browser = new LyricsBrowser( this ); - d->browser->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); - d->browser->hide(); - - d->suggestView = new LyricsSuggestionsListWidget( this ); - d->suggestView->hide(); - - QGraphicsLinearLayout *layout = new QGraphicsLinearLayout( Qt::Vertical ); - layout->addItem( m_header ); - layout->addItem( d->browser ); - setLayout( layout ); - - // Read config - const KConfigGroup &lyricsConfig = Amarok::config("Lyrics Applet"); - d->alignment = Qt::Alignment( lyricsConfig.readEntry("Alignment", int(Qt::AlignLeft)) ); - d->browser->setAlignment( d->alignment ); - d->autoScroll = lyricsConfig.readEntry( "AutoScroll", true ); - d->autoScrollIcon->setPressed( d->autoScroll ); - - QFont font; - if( font.fromString( lyricsConfig.readEntry("Font", QString()) ) ) - d->browser->setFont( font ); - - EngineController* engine = The::engineController(); - - connect( engine, SIGNAL(trackChanged(Meta::TrackPtr)), this, SLOT(_trackDataChanged(Meta::TrackPtr)) ); - connect( engine, SIGNAL(trackMetadataChanged(Meta::TrackPtr)), this, SLOT(_trackDataChanged(Meta::TrackPtr)) ); - connect( engine, SIGNAL(trackPositionChanged(qint64,bool)), this, SLOT(_trackPositionChanged(qint64,bool)) ); - connect( d->suggestView, SIGNAL(selected(LyricsSuggestion)), SLOT(_suggestionChosen(LyricsSuggestion)) ); - connect( dataEngine("amarok-lyrics"), SIGNAL(sourceAdded(QString)), this, SLOT(connectSource(QString)) ); - - // This is needed as a track might be playing when the lyrics applet - // is added to the ContextView. - d->_trackDataChanged( engine->currentTrack() ); - d->_trackPositionChanged( engine->trackPositionMs(), false ); - - d->determineActionIconsState(); - connectSource( "lyrics" ); -} - -void -LyricsApplet::connectSource( const QString& source ) -{ - if( source == "lyrics" ) - { - dataEngine( "amarok-lyrics" )->connectSource( source, this ); - refreshLyrics(); // get data initially - } - else if( source == "suggested" ) - { - dataEngine( "amarok-lyrics" )->connectSource( source, this ); - dataUpdated( source, dataEngine("amarok-lyrics" )->query( "suggested" ) ); - } -} - -void -LyricsApplet::dataUpdated( const QString& name, const Plasma::DataEngine::Data& data ) -{ - Q_D( LyricsApplet ); - - if( name != QLatin1String("lyrics") ) - return; - - unsetCursor(); - d->hasLyrics = false; - d->showSuggestions = false; - d->showBrowser = false; - setBusy( false ); - QString titleText; - - if( data.contains( "noscriptrunning" ) ) - { - titleText = i18n( "Lyrics: No script is running" ); - setCollapseOn(); - } - else if( data.contains( "stopped" ) ) - { - titleText = i18n( "Lyrics" ); - setCollapseOn(); - } - else if( data.contains( "fetching" ) ) - { - if( canAnimate() ) - setBusy( true ); - titleText = i18n( "Lyrics: Fetching ..." ); - } - else if( data.contains( "error" ) ) - { - titleText = i18n( "Lyrics: Fetch error" ); - setCollapseOn(); - } - else if( data.contains( "suggested" ) ) - { - QVariantList suggested = data[ "suggested" ].toList(); - titleText = i18n( "Lyrics: Suggested URLs" ); - d->showSuggested( suggested ); - setCollapseOff(); - } - else if( data.contains( "html" ) || data.contains( "lyrics" ) ) - { - const bool isHtml = data.contains( QLatin1String("html") ); - const QString key = isHtml ? QLatin1String("html") : QLatin1String("lyrics"); - const QVariant var = data.value( key ); - if( var.canConvert() ) - { - d->hasLyrics = true; - d->browser->setRichText( isHtml ); - LyricsData lyrics = var.value(); - QString trimmed = lyrics.text.trimmed(); - - if( trimmed != d->browser->lyrics() ) - { - d->showLyrics( trimmed ); - } - else // lyrics are the same, make sure browser is showing - { - d->showSuggestions = false; - d->showBrowser = true; - } - - titleText = i18nc( "Lyrics: - ", "Lyrics: %1 - %2", lyrics.artist, lyrics.title ); - setCollapseOff(); - } - } - else if( data.contains( "notfound" ) || data.contains( "notFound" ) ) - { - titleText = i18n( "Lyrics: Not found" ); - setCollapseOn(); - } - else - { - warning() << "should not be here:" << data; - titleText = headerText(); - } - - setHeaderText( titleText ); - - QGraphicsLinearLayout *lo = static_cast<QGraphicsLinearLayout*>( layout() ); - d->showSuggestions ? lo->insertItem( 1, d->suggestView ) : lo->removeItem( d->suggestView ); - d->showBrowser ? lo->addItem( d->browser ) : lo->removeItem( d->browser ); - - d->suggestView->setVisible( d->showSuggestions ); - d->browser->setVisible( d->showBrowser ); - - if( !d->showSuggestions ) - d->suggestView->clear(); - - d->determineActionIconsState(); -} - -bool -LyricsApplet::hasHeightForWidth() const -{ - return false; -} - -void -LyricsApplet::refreshLyrics() -{ - Q_D( LyricsApplet ); - if( !d->currentTrack || !d->currentTrack->artist() ) - return; - - if( d->hasLyrics ) - { - // Ask the user if he really wants to refetch the lyrics. - const QString text( i18nc( "@info", "Do you really want to refetch lyrics for this track? All changes you may have made will be lost.") ); - showWarning( text, SLOT(_refetchMessageButtonPressed(Plasma::MessageButton)) ); - } - else - { - // As we don't have lyrics yet we will - // refetch without asking the user. - d->refetchLyrics(); - } -} - -void -LyricsApplet::createConfigurationInterface( KConfigDialog *parent ) -{ - Q_D( LyricsApplet ); - - parent->setButtons( KDialog::Ok | KDialog::Cancel ); - - KConfigGroup configuration = config(); - QWidget *settings = new QWidget; - d->ui_settings.setupUi( settings ); - d->ui_settings.fontChooser->setFont( d->browser->nativeWidget()->currentFont() ); - - switch( d->alignment ) - { - default: - case Qt::AlignLeft: - d->ui_settings.alignLeft->setChecked( true ); - break; - - case Qt::AlignRight: - d->ui_settings.alignRight->setChecked( true ); - break; - - case Qt::AlignCenter: - d->ui_settings.alignCenter->setChecked( true ); - break; - } - - parent->addPage( settings, i18n( "Lyrics Settings" ), "preferences-system" ); - - connect( parent, SIGNAL(accepted()), this, SLOT(_changeLyricsFont()) ); - connect( parent, SIGNAL(accepted()), this, SLOT(_changeLyricsAlignment()) ); - connect( parent, SIGNAL(applyClicked()), this, SLOT(_changeLyricsFont()) ); - connect( parent, SIGNAL(applyClicked()), this, SLOT(_changeLyricsAlignment()) ); -} - -void -LyricsApplet::keyPressEvent( QKeyEvent *e ) -{ - Q_D( LyricsApplet ); - if( d->browser->nativeWidget()->isVisible() ) - { - bool propagate( true ); - switch( e->key() ) - { - case Qt::Key_Escape : - d->_closeLyrics(); - propagate = false; - break; - - case Qt::Key_F2 : - d->_editLyrics(); - propagate = false; - break; - } - - if( e->matches( QKeySequence::Save ) ) - { - d->_saveLyrics(); - propagate = false; - } - - if( !propagate ) - { - e->accept(); - return; - } - } - Context::Applet::keyPressEvent( e ); -} - -#include "moc_LyricsApplet.cpp" diff --git a/amarok/src/context/applets/lyrics/LyricsApplet.h b/amarok/src/context/applets/lyrics/LyricsApplet.h deleted file mode 100644 index 20c71d89..00000000 --- a/amarok/src/context/applets/lyrics/LyricsApplet.h +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Leo Franchi <lfranchi@gmail.com> * - * Copyright (c) 2009 simon.esneault <simon.esneault@gmail.com> * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see <http://www.gnu.org/licenses/>. * - ****************************************************************************************/ - -#ifndef LYRICS_APPLET_H -#define LYRICS_APPLET_H - -#include "context/Applet.h" -#include "context/DataEngine.h" - -#include <ui_lyricsSettings.h> - -class LyricsAppletPrivate; - -class LyricsApplet : public Context::Applet -{ - Q_OBJECT - -public: - LyricsApplet( QObject* parent, const QVariantList& args ); - ~LyricsApplet(); - - bool hasHeightForWidth() const; - -public slots: - virtual void init(); - void connectSource( const QString& source ); - void dataUpdated( const QString& name, const Plasma::DataEngine::Data& data ); - void refreshLyrics(); - -protected: - void createConfigurationInterface( KConfigDialog *parent ); - void keyPressEvent( QKeyEvent *e ); - -private: - LyricsAppletPrivate *const d_ptr; - Q_DECLARE_PRIVATE( LyricsApplet ) - - Q_PRIVATE_SLOT( d_ptr, void _editLyrics() ) - Q_PRIVATE_SLOT( d_ptr, void _changeLyricsFont() ) - Q_PRIVATE_SLOT( d_ptr, void _changeLyricsAlignment() ) - Q_PRIVATE_SLOT( d_ptr, void _closeLyrics() ) - Q_PRIVATE_SLOT( d_ptr, void _saveLyrics() ) - Q_PRIVATE_SLOT( d_ptr, void _toggleAutoScroll() ) - Q_PRIVATE_SLOT( d_ptr, void _suggestionChosen(LyricsSuggestion) ) - Q_PRIVATE_SLOT( d_ptr, void _unsetCursor() ) - Q_PRIVATE_SLOT( d_ptr, void _trackDataChanged( Meta::TrackPtr ) ) - Q_PRIVATE_SLOT( d_ptr, void _trackPositionChanged( qint64 position, bool userSeek ) ) - Q_PRIVATE_SLOT( d_ptr, void _lyricsChangedMessageButtonPressed(const Plasma::MessageButton) ) - Q_PRIVATE_SLOT( d_ptr, void _refetchMessageButtonPressed(const Plasma::MessageButton) ) -}; - -AMAROK_EXPORT_APPLET( lyrics, LyricsApplet ) - -#endif diff --git a/amarok/src/context/applets/lyrics/LyricsBrowser.cpp b/amarok/src/context/applets/lyrics/LyricsBrowser.cpp deleted file mode 100644 index c85a3181..00000000 --- a/amarok/src/context/applets/lyrics/LyricsBrowser.cpp +++ /dev/null @@ -1,162 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2011 Rick W. Chen <stuffcorpse@archlinux.us> * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see <http://www.gnu.org/licenses/>. * - ****************************************************************************************/ - -#include "LyricsBrowser.h" - -#include "PaletteHandler.h" - -#include <QApplication> -#include <QtGui/qtextobject.h> -#include <KTextBrowser> -#include <Plasma/Svg> -#include <Plasma/SvgWidget> - -#include <QtGui/qgraphicssceneevent.h> - -LyricsBrowser::LyricsBrowser( QGraphicsWidget *parent ) - : Plasma::TextBrowser( parent ) - , m_isRichText( true ) - , m_alignment( Qt::AlignLeft ) - , m_topBorder( new Plasma::SvgWidget( this ) ) - , m_bottomBorder( new Plasma::SvgWidget( this ) ) -{ - KTextBrowser *native = nativeWidget(); - native->setOpenExternalLinks( true ); - native->setUndoRedoEnabled( true ); - native->setAutoFillBackground( false ); - native->setReadOnly( false ); - native->setWordWrapMode( QTextOption::WordWrap ); - native->setCursorWidth( 0 ); - native->document()->setDocumentMargin( 10 ); - native->viewport()->setAutoFillBackground( true ); - native->setTextInteractionFlags( Qt::TextBrowserInteraction | Qt::TextSelectableByKeyboard ); - - Plasma::Svg *borderSvg = new Plasma::Svg( this ); - borderSvg->setImagePath( QLatin1String("widgets/scrollwidget") ); - - m_topBorder->setSvg( borderSvg ); - m_topBorder->setElementID( QLatin1String("border-top") ); - m_topBorder->setZValue( 900 ); - - m_bottomBorder->setSvg( borderSvg ); - m_bottomBorder->setElementID( QLatin1String("border-bottom") ); - m_bottomBorder->setZValue( 900 ); - - connect( The::paletteHandler(), SIGNAL(newPalette(QPalette)), SLOT(paletteChanged(QPalette)) ); - paletteChanged( The::paletteHandler()->palette() ); -} - -LyricsBrowser::~LyricsBrowser() -{} - -Qt::Alignment LyricsBrowser::alignment() const -{ - return m_alignment; -} - -bool LyricsBrowser::isReadOnly() const -{ - return nativeWidget()->isReadOnly(); -} - -bool LyricsBrowser::isRichText() const -{ - return m_isRichText; -} - -QString LyricsBrowser::lyrics() const -{ - return m_isRichText ? nativeWidget()->toHtml() : nativeWidget()->toPlainText(); -} - -void LyricsBrowser::clear() -{ - nativeWidget()->clear(); -} - -void LyricsBrowser::setAlignment( Qt::Alignment alignment ) -{ - if( m_alignment == alignment ) - return; - - m_alignment = alignment; - updateAlignment(); -} - -void LyricsBrowser::setLyrics( const QString &lyrics ) -{ - KTextBrowser *w = nativeWidget(); - m_isRichText ? w->setHtml( lyrics ) : w->setPlainText( lyrics ); - updateAlignment(); -} - -void LyricsBrowser::setReadOnly( bool readOnly ) -{ - QPalette::ColorRole bg = readOnly ? QPalette::Base : QPalette::AlternateBase; - nativeWidget()->viewport()->setBackgroundRole( bg ); - nativeWidget()->setReadOnly( readOnly ); - nativeWidget()->setCursorWidth( !readOnly ? 1 : 0 ); -} - -void LyricsBrowser::setRichText( bool richText ) -{ - m_isRichText = richText; -} - -void LyricsBrowser::paletteChanged( const QPalette &palette ) -{ - QPalette p = palette; - // set text color using app theme instead of plasma theme - p.setColor( QPalette::Text, qApp->palette().text().color() ); - - QPalette::ColorRole bg = isReadOnly() ? QPalette::Base : QPalette::AlternateBase; - nativeWidget()->viewport()->setBackgroundRole( bg ); - nativeWidget()->setPalette( p ); -} - -void LyricsBrowser::updateAlignment() -{ - QTextCursor it( nativeWidget()->document()->firstBlock() ); - if( !it.block().isValid() ) - return; - - do - { - QTextBlockFormat fmt = it.blockFormat(); - fmt.setAlignment( m_alignment ); - it.setBlockFormat( fmt ); - } while ( it.movePosition(QTextCursor::NextBlock, QTextCursor::KeepAnchor) ); -} - -void LyricsBrowser::resizeEvent( QGraphicsSceneResizeEvent *event ) -{ - Plasma::TextBrowser::resizeEvent( event ); - if( event->newSize() == event->oldSize() ) - return; - - if( m_topBorder && m_topBorder->isVisible() ) - { - qreal newWidth = event->newSize().width(); - m_topBorder->resize( newWidth, m_topBorder->size().height() ); - m_bottomBorder->resize( newWidth, m_bottomBorder->size().height() ); - m_topBorder->setPos( boundingRect().topLeft() ); - QPointF bottomPoint = boundingRect().bottomLeft(); - bottomPoint.ry() -= m_bottomBorder->size().height(); - m_bottomBorder->setPos( bottomPoint ); - } -} - -#include "moc_LyricsBrowser.cpp" diff --git a/amarok/src/context/applets/lyrics/LyricsBrowser.h b/amarok/src/context/applets/lyrics/LyricsBrowser.h deleted file mode 100644 index 49f7f2fe..00000000 --- a/amarok/src/context/applets/lyrics/LyricsBrowser.h +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2011 Rick W. Chen <stuffcorpse@archlinux.us> * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see <http://www.gnu.org/licenses/>. * - ****************************************************************************************/ - -#ifndef LYRICS_BROWSER_H -#define LYRICS_BROWSER_H - -#include <Plasma/TextBrowser> - -namespace Plasma { - class SvgWidget; -} - -class LyricsBrowser : public Plasma::TextBrowser -{ - Q_OBJECT - Q_PROPERTY( Qt::Alignment alignment READ alignment WRITE setAlignment ) - Q_PROPERTY( bool isReadOnly READ isReadOnly WRITE setReadOnly ) - Q_PROPERTY( bool isRichText READ isRichText WRITE setRichText ) - Q_PROPERTY( QString lyrics READ lyrics WRITE setLyrics ) - -public: - explicit LyricsBrowser( QGraphicsWidget *parent = 0 ); - ~LyricsBrowser(); - - Qt::Alignment alignment() const; - bool isReadOnly() const; - bool isRichText() const; - QString lyrics() const; - - void clear(); - - void setAlignment( Qt::Alignment alignment ); - void setLyrics( const QString &lyrics ); - void setReadOnly( bool readOnly ); - void setRichText( bool richText ); - -protected: - void resizeEvent( QGraphicsSceneResizeEvent *event ); - -private slots: - void paletteChanged( const QPalette &palette ); - void updateAlignment(); - -private: - bool m_isRichText; - Qt::Alignment m_alignment; - Plasma::SvgWidget *m_topBorder; - Plasma::SvgWidget *m_bottomBorder; -}; - -#endif // LYRICS_BROWSER_H diff --git a/amarok/src/context/applets/lyrics/LyricsSuggestionsListWidget.cpp b/amarok/src/context/applets/lyrics/LyricsSuggestionsListWidget.cpp deleted file mode 100644 index 989db818..00000000 --- a/amarok/src/context/applets/lyrics/LyricsSuggestionsListWidget.cpp +++ /dev/null @@ -1,119 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2011 Rick W. Chen <stuffcorpse@archlinux.us> * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see <http://www.gnu.org/licenses/>. * - ****************************************************************************************/ - -#define DEBUG_PREFIX "LyricsSuggestionsListWidget" - -#include "LyricsSuggestionsListWidget.h" - -#include "core/support/Amarok.h" -#include "core/support/Debug.h" - -#include <KIcon> -#include <KSqueezedTextLabel> -#include <Plasma/IconWidget> -#include <Plasma/Label> -#include <Plasma/Separator> - -#include <QGraphicsGridLayout> -#include <QGraphicsLinearLayout> -#include <QGraphicsProxyWidget> - -LyricsSuggestionsListWidget::LyricsSuggestionsListWidget( QGraphicsWidget *parent ) - : Plasma::ScrollWidget( parent ) -{ - QGraphicsWidget *viewport = new QGraphicsWidget( this ); - m_layout = new QGraphicsLinearLayout( Qt::Vertical, viewport ); - setWidget( viewport ); -} - -LyricsSuggestionsListWidget::~LyricsSuggestionsListWidget() -{} - -void -LyricsSuggestionsListWidget::add( const LyricsSuggestion &suggestion ) -{ - QGraphicsWidget *sep = new Plasma::Separator; - LyricsSuggestionItem *item = new LyricsSuggestionItem( suggestion ); - item->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Maximum ); - m_layout->addItem( item ); - m_layout->addItem( sep ); - m_items.append( item ); - m_separators.append( sep ); - connect( item, SIGNAL(selected(LyricsSuggestion)), SIGNAL(selected(LyricsSuggestion)) ); -} - -void -LyricsSuggestionsListWidget::clear() -{ - qDeleteAll( m_items ); - qDeleteAll( m_separators ); - m_items.clear(); - m_separators.clear(); -} - -LyricsSuggestionItem::LyricsSuggestionItem( const LyricsSuggestion &suggestion, QGraphicsItem *parent ) - : QGraphicsWidget( parent ) - , m_data( suggestion ) -{ - QGraphicsProxyWidget *titleProxy = new QGraphicsProxyWidget( this ); - KSqueezedTextLabel *titleLabel = new KSqueezedTextLabel( m_data.title ); - titleLabel->setTextElideMode( Qt::ElideRight ); - titleLabel->setAttribute( Qt::WA_NoSystemBackground ); - titleLabel->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred ); - titleProxy->setWidget( titleLabel ); - QFont font = titleLabel->font(); - font.setBold( true ); - titleLabel->setFont( font ); - - const KUrl &url = m_data.url; - QString urlText = QString("<a href=\"%1\">%2</a>").arg(url.url(), url.host()); - Plasma::Label *urlLabel = new Plasma::Label( this ); - urlLabel->setText( urlText ); - urlLabel->setSizePolicy( QSizePolicy::Maximum, QSizePolicy::Preferred ); - urlLabel->nativeWidget()->setOpenExternalLinks( true ); - urlLabel->nativeWidget()->setTextInteractionFlags( Qt::TextBrowserInteraction ); - urlLabel->nativeWidget()->setToolTip( url.url() ); - - QString artist = i18n( "artist: %1", m_data.artist ); - QGraphicsProxyWidget *artistProxy = new QGraphicsProxyWidget( this ); - KSqueezedTextLabel *artistLabel = new KSqueezedTextLabel( artist ); - artistLabel->setTextElideMode( Qt::ElideRight ); - artistLabel->setAttribute( Qt::WA_NoSystemBackground ); - artistLabel->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred ); - artistProxy->setWidget( artistLabel ); - - Plasma::IconWidget *lyricsIcon( new Plasma::IconWidget(KIcon("amarok_lyrics"), QString(), this) ); - lyricsIcon->setDrawBackground( true ); - connect( lyricsIcon, SIGNAL(clicked()), SLOT(onClicked()) ); - - QGraphicsGridLayout *layout = new QGraphicsGridLayout( this ); - layout->setVerticalSpacing( 0 ); - layout->addItem( lyricsIcon, 0, 0, 3, 1, Qt::AlignCenter ); - layout->addItem( titleProxy, 0, 1, Qt::AlignLeft ); - layout->addItem( artistProxy, 1, 1, Qt::AlignLeft ); - layout->addItem( urlLabel, 2, 1, Qt::AlignLeft ); -} - -LyricsSuggestionItem::~LyricsSuggestionItem() -{} - -void -LyricsSuggestionItem::onClicked() -{ - emit selected( m_data ); -} - -#include "moc_LyricsSuggestionsListWidget.cpp" diff --git a/amarok/src/context/applets/lyrics/LyricsSuggestionsListWidget.h b/amarok/src/context/applets/lyrics/LyricsSuggestionsListWidget.h deleted file mode 100644 index db8ee872..00000000 --- a/amarok/src/context/applets/lyrics/LyricsSuggestionsListWidget.h +++ /dev/null @@ -1,92 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2011 Rick W. Chen <stuffcorpse@archlinux.us> * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see <http://www.gnu.org/licenses/>. * - ****************************************************************************************/ - -#ifndef LYRICS_SUGGESTIONS_LIST_WIDGET_H -#define LYRICS_SUGGESTIONS_LIST_WIDGET_H - -#include <KUrl> -#include <Plasma/ScrollWidget> - -class LyricsSuggestionItem; -class QGraphicsLinearLayout; - -struct LyricsSuggestion -{ - KUrl url; - QString title; - QString artist; -}; - -class LyricsSuggestionsListWidget : public Plasma::ScrollWidget -{ - Q_OBJECT - -public: - explicit LyricsSuggestionsListWidget( QGraphicsWidget *parent = 0 ); - ~LyricsSuggestionsListWidget(); - - void add( const LyricsSuggestion &suggestion ); - - void clear(); - -signals: - void selected( const LyricsSuggestion &suggestion ); - -private: - QList<LyricsSuggestionItem*> m_items; - QList<QGraphicsWidget*> m_separators; - QGraphicsLinearLayout *m_layout; - Q_DISABLE_COPY( LyricsSuggestionsListWidget ) -}; - -class LyricsSuggestionItem : public QGraphicsWidget -{ - Q_OBJECT - Q_PROPERTY( KUrl url READ url ) - Q_PROPERTY( QString title READ title ) - Q_PROPERTY( QString artist READ artist ) - -public: - LyricsSuggestionItem( const LyricsSuggestion &suggestion, QGraphicsItem *parent = 0 ); - ~LyricsSuggestionItem(); - - QString artist() const; - QString title() const; - KUrl url() const; - -signals: - void selected( const LyricsSuggestion &suggestion ); - -private slots: - void onClicked(); - -private: - LyricsSuggestion m_data; - Q_DISABLE_COPY( LyricsSuggestionItem ) -}; - -inline QString LyricsSuggestionItem::title() const -{ return m_data.title; } - -inline QString LyricsSuggestionItem::artist() const -{ return m_data.artist; } - -inline KUrl LyricsSuggestionItem::url() const -{ return m_data.url; } - -Q_DECLARE_METATYPE( LyricsSuggestion ) - -#endif // LYRICS_SUGGESTIONS_LIST_WIDGET_H diff --git a/amarok/src/context/applets/lyrics/amarok-context-applet-lyrics.desktop b/amarok/src/context/applets/lyrics/amarok-context-applet-lyrics.desktop deleted file mode 100644 index 66ecd42b..00000000 --- a/amarok/src/context/applets/lyrics/amarok-context-applet-lyrics.desktop +++ /dev/null @@ -1,72 +0,0 @@ -[Desktop Entry] -Name=Lyrics -Name[bg]=Текстове -Name[bs]=Stihovi -Name[ca]=Lletres -Name[ca@valencia]=Lletres -Name[cs]=Texty písní -Name[csb]=Tekstë -Name[da]=Sangtekster -Name[de]=Liedtext -Name[el]=Στίχοι -Name[en_GB]=Lyrics -Name[es]=Letras -Name[et]=Sõnad -Name[eu]=Hitzak -Name[fa]=ترانه -Name[fi]=Sanat -Name[fr]=Paroles -Name[ga]=Liricí -Name[gl]=Letras de cancións -Name[hu]=Dalszöveg -Name[id]=Lirik -Name[is]=Lagatextar -Name[it]=Testi -Name[ja]=歌詞 -Name[km]=ទំនុក​ -Name[ko]=가사 -Name[lt]=Tekstai -Name[lv]=Dziesmu vārdi -Name[mr]=गाण्याचे बोल -Name[nb]=Sangtekst -Name[nds]=Leedtexten -Name[nl]=Liedteksten -Name[nn]=Songtekst -Name[pa]=ਬੋਲ -Name[pl]=Słowa -Name[pt]=Letras Musicais -Name[pt_BR]=Letras -Name[ro]=Versuri -Name[ru]=Текст песни -Name[sk]=Texty piesní -Name[sl]=Besedilo -Name[sq]=Lirikat -Name[sr]=Стихови -Name[sr@ijekavian]=Стихови -Name[sr@ijekavianlatin]=Stihovi -Name[sr@latin]=Stihovi -Name[sv]=Sångtext -Name[th]=เนื้อร้อง -Name[tr]=Şarkı Sözleri -Name[ug]=ناخشا سۆزى -Name[uk]=Текст пісні -Name[wa]=Paroles -Name[x-test]=xxLyricsxx -Name[zh_CN]=歌词 -Name[zh_TW]=歌詞 -Type=Service -Icon=amarok_lyrics -ServiceTypes=Plasma/Applet - -X-KDE-Library=amarok_context_applet_lyrics -X-KDE-PluginInfo-Author=Leo Franchi -X-KDE-PluginInfo-Email=lfranchi@gmail.com -X-KDE-PluginInfo-Name=lyrics -X-KDE-PluginInfo-Version=pre0.1 -X-KDE-PluginInfo-Website= -X-KDE-PluginInfo-Depends= -X-KDE-PluginInfo-License=GPL -X-KDE-PluginInfo-EnabledByDefault=true -X-KDE-ParentApp=amarok -X-KDE-PluginInfo-Category=Current - diff --git a/amarok/src/context/applets/lyrics/lyricsSettings.ui b/amarok/src/context/applets/lyrics/lyricsSettings.ui deleted file mode 100644 index 4b21a39a..00000000 --- a/amarok/src/context/applets/lyrics/lyricsSettings.ui +++ /dev/null @@ -1,76 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>lyricsSettings</class> - <widget class="QWidget" name="lyricsSettings"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>195</width> - <height>131</height> - </rect> - </property> - <property name="windowTitle"> - <string>Lyrics Settings</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout_2"> - <item> - <widget class="QGroupBox" name="fontGroup"> - <property name="title"> - <string>Font</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <widget class="KFontRequester" name="fontChooser"/> - </item> - </layout> - </widget> - </item> - <item> - <widget class="KButtonGroup" name="alignmentGroup"> - <property name="title"> - <string>Alignment</string> - </property> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <widget class="QRadioButton" name="alignLeft"> - <property name="text"> - <string comment="Left alignment">Left</string> - </property> - </widget> - </item> - <item> - <widget class="QRadioButton" name="alignCenter"> - <property name="text"> - <string comment="Center alignment">Center</string> - </property> - </widget> - </item> - <item> - <widget class="QRadioButton" name="alignRight"> - <property name="text"> - <string>Right</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - <customwidgets> - <customwidget> - <class>KFontRequester</class> - <extends>QWidget</extends> - <header>kfontrequester.h</header> - </customwidget> - <customwidget> - <class>KButtonGroup</class> - <extends>QGroupBox</extends> - <header>kbuttongroup.h</header> - <container>1</container> - </customwidget> - </customwidgets> - <resources/> - <connections/> -</ui> diff --git a/amarok/src/context/applets/photos/CMakeLists.txt b/amarok/src/context/applets/photos/CMakeLists.txt deleted file mode 100644 index 10289356..00000000 --- a/amarok/src/context/applets/photos/CMakeLists.txt +++ /dev/null @@ -1,21 +0,0 @@ -include_directories( - ${Amarok_SOURCE_DIR}/src - ${Amarok_SOURCE_DIR}/src/network -) - -set(photos_applet_SRCS - DragPixmapItem.cpp - PhotosApplet.cpp - PhotosScrollWidget.cpp - photosSettings.ui -) - -kde4_add_plugin(amarok_context_applet_photos ${photos_applet_SRCS}) -target_link_libraries( amarok_context_applet_photos - amarokcore - amaroklib - ${KDE4_PLASMA_LIBS} -) - -install( TARGETS amarok_context_applet_photos DESTINATION ${PLUGIN_INSTALL_DIR} ) -install( FILES amarok-context-applet-photos.desktop DESTINATION ${SERVICES_INSTALL_DIR} ) diff --git a/amarok/src/context/applets/photos/DragPixmapItem.cpp b/amarok/src/context/applets/photos/DragPixmapItem.cpp deleted file mode 100644 index 60953d4a..00000000 --- a/amarok/src/context/applets/photos/DragPixmapItem.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Simon Esneault <simon.esneault@gmail.com> * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see <http://www.gnu.org/licenses/>. * - ****************************************************************************************/ - -#define DEBUG_PREFIX "DragPixmapItem" - -#include "DragPixmapItem.h" - -#include "core/support/Debug.h" - -#include <KIcon> -#include <KLocale> - -#include <QApplication> -#include <QDesktopServices> -#include <QDrag> -#include <QtGui/qgraphicssceneevent.h> -#include <QMimeData> -#include <QPoint> - -DragPixmapItem::DragPixmapItem( QGraphicsItem* parent ) - : QGraphicsPixmapItem( parent ) - , m_dragPos( QPoint() ) -{ - setAcceptDrops( true ); - setCursor( Qt::PointingHandCursor ); -} - -void DragPixmapItem::SetClickableUrl( const KUrl &url ) -{ - m_url = url; -} - -void DragPixmapItem::mousePressEvent(QGraphicsSceneMouseEvent* event) -{ -// DEBUG_BLOCK - - if (event->button() == Qt::LeftButton) - m_dragPos = event->pos().toPoint(); -} - -void DragPixmapItem::mouseReleaseEvent(QGraphicsSceneMouseEvent* event) -{ - DEBUG_BLOCK - - if ( event->button() == Qt::LeftButton ) - { - if ( !m_url.isEmpty() ) - { - QDesktopServices::openUrl( m_url ); - debug() << "DragPixmapItem: clicked photos url "<<m_url; - } - } -} - -void DragPixmapItem::mouseMoveEvent( QGraphicsSceneMouseEvent* event ) -{ - if ( !( event->buttons() & Qt::LeftButton ) ) - return; - if ( ( event->pos().toPoint() - m_dragPos ).manhattanLength() < QApplication::startDragDistance() ) - return; - - QMimeData *data = new QMimeData; - data->setImageData( this->pixmap().toImage() ); - - QDrag *drag = new QDrag( event->widget() ); - drag->setMimeData( data ); - drag->setPixmap( pixmap().scaledToWidth( 140 ) ); - drag->setDragCursor( KIcon( "insert-image" ).pixmap( 24, 24 ), Qt::CopyAction ); - drag->exec( Qt::CopyAction ); -} - -#include "moc_DragPixmapItem.cpp" diff --git a/amarok/src/context/applets/photos/DragPixmapItem.h b/amarok/src/context/applets/photos/DragPixmapItem.h deleted file mode 100644 index dc5d6233..00000000 --- a/amarok/src/context/applets/photos/DragPixmapItem.h +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Simon Esneault <simon.esneault@gmail.com> * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see <http://www.gnu.org/licenses/>. * - ****************************************************************************************/ - -#ifndef DRAGPIXMAPITEM_H -#define DRAGPIXMAPITEM_H - -#include "amarok_export.h" - -#include <KUrl> - -#include <QtGui/qgraphicsitem.h> - -//forward -class QGraphicsSceneMouseEvent; - -/** -* \brief A drag-able QGraphicsPixmapItem -* -* Display a pixmap which is draggable and clickable. -* -* \sa QGraphicsPixmapItem -* -* \author Simon Esneault <simon.esneault@gmail.com> -*/ - -class DragPixmapItem : public QObject, public QGraphicsPixmapItem -{ - Q_OBJECT - public: - DragPixmapItem( QGraphicsItem* parent = 0 ); - - void SetClickableUrl( const KUrl &url ); - - protected slots: - /** - * Reimplement mouse event - */ - virtual void mousePressEvent( QGraphicsSceneMouseEvent * ); - virtual void mouseMoveEvent( QGraphicsSceneMouseEvent * ); - virtual void mouseReleaseEvent( QGraphicsSceneMouseEvent * ); - - private: - QPoint m_dragPos; - KUrl m_url; -}; - -#endif // DROPPIXMAPITEM_H diff --git a/amarok/src/context/applets/photos/PhotosApplet.cpp b/amarok/src/context/applets/photos/PhotosApplet.cpp deleted file mode 100644 index 11153f04..00000000 --- a/amarok/src/context/applets/photos/PhotosApplet.cpp +++ /dev/null @@ -1,250 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Simon Esneault <simon.esneault@gmail.com> * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see <http://www.gnu.org/licenses/>. * - ****************************************************************************************/ - -#define DEBUG_PREFIX "PhotosApplet" - -#include "PhotosApplet.h" -#include "PhotosScrollWidget.h" - -// Amarok -#include "core/support/Amarok.h" -#include "core/support/Debug.h" -#include "context/ContextView.h" -#include "context/engines/photos/PhotosInfo.h" -#include "context/widgets/AppletHeader.h" - -// KDE -#include <KAction> -#include <KColorScheme> -#include <KConfigDialog> -#include <KGlobalSettings> -#include <Plasma/BusyWidget> -#include <Plasma/IconWidget> -#include <Plasma/Theme> - -// Qt -#include <QGraphicsLinearLayout> -#include <QGraphicsProxyWidget> -#include <QtGui/qgraphicsitem.h> -#include <QGraphicsWidget> - -PhotosApplet::PhotosApplet( QObject* parent, const QVariantList& args ) - : Context::Applet( parent, args ) - , m_settingsIcon( 0 ) -{ - DEBUG_BLOCK - setHasConfigurationInterface( true ); -} - -void -PhotosApplet::init() -{ - DEBUG_BLOCK - - // Call the base implementation. - Context::Applet::init(); - - // Create label - enableHeader( true ); - setHeaderText( i18n( "Photos" ) ); - - // Set the collapse size - setCollapseHeight( m_header->height() ); - setCollapseOffHeight( 220 ); - setMaximumHeight( 220 ); - setMinimumHeight( collapseHeight() ); - setPreferredHeight( collapseHeight() ); - - // Icon - QAction* settingsAction = new QAction( this ); - settingsAction->setIcon( KIcon( "preferences-system" ) ); - settingsAction->setVisible( true ); - settingsAction->setEnabled( true ); - settingsAction->setText( i18n( "Settings" ) ); - m_settingsIcon = addRightHeaderAction( settingsAction ); - connect( m_settingsIcon, SIGNAL(clicked()), this, SLOT(showConfigurationInterface()) ); - - m_widget = new PhotosScrollWidget( this ); - m_widget->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); - m_widget->setContentsMargins( 0, 0, 0, 0 ); - connect( m_widget, SIGNAL(photoAdded()), SLOT(photoAdded()) ); - - QGraphicsLinearLayout *layout = new QGraphicsLinearLayout( Qt::Vertical, this ); - layout->addItem( m_header ); - layout->addItem( m_widget ); - - // Read config and inform the engine. - KConfigGroup config = Amarok::config("Photos Applet"); - m_nbPhotos = config.readEntry( "NbPhotos", "10" ).toInt(); - m_Animation = config.readEntry( "Animation", "Fading" ); - m_KeyWords = config.readEntry( "KeyWords", QStringList() ); - - if( m_Animation == i18nc( "animation type", "Automatic" ) ) - m_widget->setMode( 0 ); - else if( m_Animation == i18n( "Interactive" ) ) - m_widget->setMode( 1 ); - else // fading - m_widget->setMode( 2 ); - - Plasma::DataEngine *engine = dataEngine( "amarok-photos" ); - engine->setProperty( "fetchSize", m_nbPhotos ); - engine->setProperty( "keywords", m_KeyWords ); - engine->connectSource( "photos", this ); -} - -PhotosApplet::~PhotosApplet() -{ - DEBUG_BLOCK -} - -void -PhotosApplet::stopped() -{ - DEBUG_BLOCK - setHeaderText( i18n( "Photos: No Track Playing" ) ); - m_widget->clear(); - m_widget->hide(); - setBusy( false ); - setMinimumHeight( m_header->height() ); - setCollapseHeight( m_header->height() ); - setCollapseOn(); - updateConstraints(); -} - -void -PhotosApplet::photoAdded() -{ - setBusy( false ); - setHeaderText( i18ncp( "@title:window Number of photos of artist", - "1 Photo: %2", - "%1 Photos: %2", - m_widget->count(), - m_currentArtist ) ); -} - -void -PhotosApplet::dataUpdated( const QString& name, const Plasma::DataEngine::Data& data ) // SLOT -{ - if( name != QLatin1String("photos") || data.isEmpty() ) - return; - - QString text; - - if( data.contains( "message" ) ) - { - text = data["message"].toString(); - if( text.contains( QLatin1String("Fetching") ) ) - { - debug() << "received message: Fetching"; - setHeaderText( i18n( "Photos: %1", text ) ); - setMinimumHeight( m_header->height() ); - setCollapseHeight( m_header->height() ); - setCollapseOn(); - m_widget->clear(); - m_widget->hide(); - if( canAnimate() ) - setBusy( true ); - } - else if( text.contains( QLatin1String("stopped") ) ) - { - debug() << "received message: stopped"; - stopped(); - } - else - { - debug() << "received message:" << text; - setHeaderText( i18n( "Photos: %1", text ) ); - m_widget->hide(); - setMinimumHeight( m_header->height() ); - setCollapseHeight( m_header->height() ); - setCollapseOn(); - setBusy( false ); - } - } - else if( data.contains( "data" ) ) - { - m_widget->clear(); - m_currentArtist = text = data["artist"].toString(); - PhotosInfo::List photos = data["data"].value< PhotosInfo::List >(); - debug() << "received data for:" << text << photos.count(); - setHeaderText( i18n( "Photos: %1", text ) ); - if( photos.isEmpty() ) - { - setBusy( false ); - setMinimumHeight( m_header->height() ); - setCollapseHeight( m_header->height() ); - setCollapseOn(); - return; - } - setBusy( true ); - m_widget->setPhotosInfoList( photos ); - setMinimumHeight( 220 ); - setCollapseOff(); - m_widget->show(); - layout()->invalidate(); - } - else - { - setMinimumHeight( m_header->height() ); - setCollapseHeight( m_header->height() ); - setCollapseOn(); - m_widget->clear(); - m_widget->hide(); - setBusy( false ); - } - updateConstraints(); -} - -void -PhotosApplet::createConfigurationInterface( KConfigDialog *parent ) -{ - parent->setButtons( KDialog::Ok | KDialog::Cancel ); - - KConfigGroup configuration = config(); - QWidget *settings = new QWidget; - ui_Settings.setupUi( settings ); - - parent->addPage( settings, i18n( "Photos Settings" ), "preferences-system"); - - ui_Settings.animationComboBox->setCurrentIndex( ui_Settings.animationComboBox->findText( m_Animation ) ); - ui_Settings.photosSpinBox->setValue( m_nbPhotos ); - ui_Settings.additionalkeywordsLineEdit->setText( m_KeyWords.join(", ") ); - connect( parent, SIGNAL(accepted()), this, SLOT(saveSettings()) ); -} - -void -PhotosApplet::saveSettings() -{ - DEBUG_BLOCK - KConfigGroup config = Amarok::config("Photos Applet"); - - m_nbPhotos = ui_Settings.photosSpinBox->value(); - m_Animation = ui_Settings.animationComboBox->currentText(); - m_KeyWords = ui_Settings.additionalkeywordsLineEdit->text().split(", "); - config.writeEntry( "NbPhotos", m_nbPhotos ); - config.writeEntry( "Animation", m_Animation ); - config.writeEntry( "KeyWords", m_KeyWords ); - - m_widget->setMode( ui_Settings.animationComboBox->currentIndex() ); - m_widget->clear(); - - Plasma::DataEngine *engine = dataEngine( "amarok-photos" ); - engine->setProperty( "fetchSize", m_nbPhotos ); - engine->setProperty( "keywords", m_KeyWords ); - engine->query( QLatin1String( "photos:forceUpdate" ) ); -} - -#include "moc_PhotosApplet.cpp" diff --git a/amarok/src/context/applets/photos/PhotosApplet.h b/amarok/src/context/applets/photos/PhotosApplet.h deleted file mode 100644 index 66977132..00000000 --- a/amarok/src/context/applets/photos/PhotosApplet.h +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Simon Esneault <simon.esneault@gmail.com> * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see <http://www.gnu.org/licenses/>. * - ****************************************************************************************/ - -//Plasma applet for showing photos from flickr - -#ifndef PHOTOS_APPLET_H -#define PHOTOS_APPLET_H - -#include "context/Applet.h" -#include "context/DataEngine.h" - -#include <ui_photosSettings.h> - -class KConfigDialog; -class PhotosScrollWidget; -class QGraphicsSimpleTextItem; - -namespace Plasma -{ - class IconWidget; -} - - /** PhotosApplet will display photos from the Internet, relative to the current playing song - */ -class PhotosApplet : public Context::Applet -{ - Q_OBJECT - - public: - PhotosApplet( QObject* parent, const QVariantList& args ); - ~PhotosApplet(); - - public slots: - virtual void init(); - void dataUpdated( const QString& name, const Plasma::DataEngine::Data& data ); - void saveSettings(); - - protected slots: - void stopped(); - - protected: - void createConfigurationInterface(KConfigDialog *parent); - - private slots: - void photoAdded(); - - private: - PhotosScrollWidget *m_widget; - - int m_nbPhotos; - - QString m_currentArtist; - QString m_Animation; - QStringList m_KeyWords; - - Ui::photosSettings ui_Settings; - Plasma::IconWidget *m_settingsIcon; -}; - -AMAROK_EXPORT_APPLET( photos, PhotosApplet ) - -#endif /* Photos_APPLET_H */ diff --git a/amarok/src/context/applets/photos/PhotosScrollWidget.cpp b/amarok/src/context/applets/photos/PhotosScrollWidget.cpp deleted file mode 100644 index 8211914a..00000000 --- a/amarok/src/context/applets/photos/PhotosScrollWidget.cpp +++ /dev/null @@ -1,513 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Simon Esneault <simon.esneault@gmail.com> * - * 2009 Nikolaj Hald Nielsen <nhn@kde.org> * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see <http://www.gnu.org/licenses/>. * - ****************************************************************************************/ - -#define DEBUG_PREFIX "PhotosScrollWidget" - -#include "PhotosScrollWidget.h" -#include "DragPixmapItem.h" - -// Amarok -#include "core/support/Amarok.h" -#include "core/support/Debug.h" -#include "SvgHandler.h" - -// QT -#include <QGraphicsItem> -#include <QtGui/qgraphicssceneevent.h> -#include <QList> -#include <QPixmap> -#include <QPixmapCache> -#include <QTimer> -#include <QPropertyAnimation> - -PhotosScrollWidget::PhotosScrollWidget( QGraphicsItem* parent ) - : QGraphicsWidget( parent ) - , m_speed( 1. ) - , m_margin( 5 ) - , m_scrollmax( 0 ) - , m_actualpos( 0 ) - , m_currentPix( 0 ) - , m_lastPix( 0 ) - , m_interval( 3500 ) - , m_mode( PHOTOS_MODE_INTERACTIVE ) - , m_delta( 0 ) - , m_animation( new QPropertyAnimation( this, "animValue" ) ) -{ - - setAcceptHoverEvents( true ); - setFlag(QGraphicsItem::ItemClipsChildrenToShape, true); - - // prepare the timer for the fading effect - m_timer = new QTimer( this ); - m_timer->setSingleShot( true ); - connect(m_timer, SIGNAL(timeout()), this, SLOT(automaticAnimBegin()) ); - - m_animation->setEasingCurve( QEasingCurve::Linear ); - m_animation->setStartValue( 0.0 ); - m_animation->setEndValue( 1.0 ); - - // connect the end of the animation - connect( m_animation, SIGNAL(finished()), this, SLOT(automaticAnimEnd()) ); -} - -PhotosScrollWidget::~PhotosScrollWidget() -{ - clear(); -} - -void PhotosScrollWidget::clear() -{ - // DEBUG_BLOCK - if( m_animation->state() == QAbstractAnimation::Running ) - m_animation->stop(); - - // stop the timer for animation - if( m_timer->isActive() ) - m_timer->stop(); - - //delete!!! - // debug() << "Going to delete " << m_pixmaplist.count() << " items"; - - qDeleteAll( m_pixmaplist ); - - m_pixmaplist.clear(); - m_currentlist.clear(); - m_scrollmax = 0; - m_actualpos = 0; - m_currentPix = 0; - m_lastPix = 0; -} - -int PhotosScrollWidget::count() const -{ - return m_pixmaplist.count(); -} - -void PhotosScrollWidget::setMode( int mode ) -{ - DEBUG_BLOCK - m_mode = mode; - PhotosInfo::List tmp = m_currentlist; - clear(); - setPhotosInfoList( tmp ); - tmp.clear(); -} - -void PhotosScrollWidget::setPhotosInfoList( const PhotosInfo::List &list ) -{ - DEBUG_BLOCK - // if the list is the same, nothing happen. - if( list == m_currentlist ) - return; - - PhotosInfo::List toAddList; - foreach( const PhotosInfoPtr &item, list ) - { - if( m_currentlist.contains( item ) ) - continue; - - KUrl url = item->urlphoto; - if( url.isValid() ) - { - QPixmap pixmap; - if( QPixmapCache::find( url.url(), &pixmap ) ) - { - addPhoto( item, pixmap ); - } - else - { - m_infoHash[ url ] = item; - The::networkAccessManager()->getData( url, this, - SLOT(photoFetched(KUrl,QByteArray,NetworkAccessManagerProxy::Error)) ); - } - toAddList << item; - } - } - debug() << "adding" << toAddList.count() << "new photos"; - m_currentlist = toAddList; -} - -void PhotosScrollWidget::photoFetched( const KUrl &url, QByteArray data, NetworkAccessManagerProxy::Error e ) -{ - if( !m_infoHash.contains( url ) ) - return; - - PhotosInfoPtr info = m_infoHash.take( url ); - if( e.code != QNetworkReply::NoError ) - { - debug() << "Error fetching photo" << e.description; - return; - } - - QPixmap pixmap; - if( pixmap.loadFromData( data ) ) - { - QPixmapCache::insert( url.url(), pixmap ); - addPhoto( info, pixmap ); - } -} - -void PhotosScrollWidget::addPhoto( const PhotosInfoPtr &item, const QPixmap &photo ) -{ - if( photo.isNull() ) - return; - - qreal height = 180.0 - 2 * m_margin; - QPixmap pixmap = photo.scaledToHeight( height , Qt::SmoothTransformation ); - pixmap = The::svgHandler()->addBordersToPixmap( pixmap, 5, QString(), true ); - - switch( m_mode ) - { - case PHOTOS_MODE_INTERACTIVE: - { - if( m_animation->state() == QAbstractAnimation::Running ) // careful we're animating - m_animation->stop(); - - DragPixmapItem *dragpix = new DragPixmapItem( this ); - dragpix->setPixmap( pixmap ); - dragpix->setPos( m_actualpos, 0 ); - dragpix->SetClickableUrl( item->urlpage ); - dragpix->show(); - - m_pixmaplist << dragpix; - - int delta = dragpix->boundingRect().width() + m_margin; - m_scrollmax += delta; - m_actualpos += delta; - emit photoAdded(); - break; - } - - case PHOTOS_MODE_AUTOMATIC: - { - DragPixmapItem *dragpix = new DragPixmapItem( this ); - dragpix->setPixmap( pixmap ); - dragpix->SetClickableUrl( item->urlpage ); - - // only pos and show if no animation, otherwise it will be set at the end automatically - if( m_animation->state() != QAbstractAnimation::Running ) - { - if( !m_pixmaplist.isEmpty() ) - { - int x = m_pixmaplist.last()->boundingRect().width(); - x += m_pixmaplist.last()->pos().x() + m_margin; - dragpix->setPos( x , 0 ) ; - dragpix->show(); - } - else - { - m_actualpos = 0; - dragpix->setPos( m_actualpos, 0 ) ; - dragpix->show(); - } - } - - m_pixmaplist << dragpix; - - // set a timer after and launch - QTimer::singleShot( m_interval, this, SLOT(automaticAnimBegin()) ); - emit photoAdded(); - break; - } - - case PHOTOS_MODE_FADING: - { - DragPixmapItem *dragpix = new DragPixmapItem( this ); - dragpix->setPixmap( pixmap ); - dragpix->setPos( (size().width() - dragpix->boundingRect().width()) / 2, 0 ); - dragpix->SetClickableUrl( item->urlpage ); - dragpix->hide(); - m_pixmaplist << dragpix; - if( m_pixmaplist.size() == 1 ) - { - dragpix->show(); - m_timer->start( m_interval ); - } - emit photoAdded(); - break; - } - } -} - -void PhotosScrollWidget::hoverEnterEvent(QGraphicsSceneHoverEvent*) -{ -// DEBUG_BLOCK - switch ( m_mode ) - { - case PHOTOS_MODE_AUTOMATIC : - { - if( m_animation->state() == QAbstractAnimation::Running ) - { - m_animation->stop(); - if ( m_currentPix != 0 ) - m_currentPix--; - } - break; - } - } -} - -void PhotosScrollWidget::hoverLeaveEvent(QGraphicsSceneHoverEvent*) -{ -// DEBUG_BLOCK - switch ( m_mode ) - { - case PHOTOS_MODE_INTERACTIVE : - { - if( m_animation->state() == QAbstractAnimation::Running ) - m_animation->stop(); - break; - } - - case PHOTOS_MODE_AUTOMATIC : - { - if( m_animation->state() == QAbstractAnimation::Running ) - QTimer::singleShot( 0, this, SLOT(automaticAnimBegin()) ); - break; - } - } -} - -void PhotosScrollWidget::hoverMoveEvent(QGraphicsSceneHoverEvent* event) -{ -// DEBUG_BLOCK - switch ( m_mode ) - { - case PHOTOS_MODE_INTERACTIVE : - { - m_speed = ( event->pos().x() - ( size().width() / 2 ) ) / size().width(); - m_speed *= 20; - - if( m_animation->state() == QAbstractAnimation::Running ) - { - m_animation->pause(); - m_animation->setDuration( m_scrollmax*10 ); - m_animation->resume(); - } else { - m_animation->setDuration( m_scrollmax*10 ); - m_animation->start(); - } - } - default: - break; - } -} - -void PhotosScrollWidget::resize(qreal wid, qreal hei) -{ - switch( m_mode ) - { - case PHOTOS_MODE_FADING: - { - foreach(DragPixmapItem *item, m_pixmaplist) - { - if( !item->pixmap().isNull() ) - { - if( size().height() != hei ) - item->setPixmap( item->pixmap().scaledToHeight( (int) hei - 2 * m_margin, Qt::SmoothTransformation ) ); - if( size().width() != wid ) - item->setPos( ( wid - item->boundingRect().width() ) / 2, 0 ); - } - } - break; - } - } - - QGraphicsWidget::resize( wid, hei ); -} - -void PhotosScrollWidget::automaticAnimBegin() -{ - if ( m_pixmaplist.size() > 1 && m_animation->state() != QAbstractAnimation::Running ) // only start if m_pixmaplist >= 2 - { - m_lastPix = m_currentPix; - m_currentPix = ( m_currentPix + 1 ) % ( m_pixmaplist.count() ); - - switch( m_mode ) - { - case PHOTOS_MODE_AUTOMATIC: - { - m_delta = m_pixmaplist.at( m_currentPix )->boundingRect().width() + m_margin; - if( m_animation->state() == QAbstractAnimation::Running ) - m_animation->stop(); - - m_animation->setDuration( m_delta*20 ); - m_animation->start(); - break; - } - - case PHOTOS_MODE_FADING: - { - if( m_animation->state() == QAbstractAnimation::Running ) - m_animation->stop(); - - m_animation->setDuration( 1200 ); - m_animation->start(); - break; - } - default: - break; - } - } -} - -void PhotosScrollWidget::automaticAnimEnd() -{ - switch( m_mode ) - { - case PHOTOS_MODE_AUTOMATIC: - { - // DEBUG_BLOCK - - /*if ( !m_pixmaplist.empty() && m_currentPix != 0 ) - { - - DragPixmapItem * orgCurrentPix = m_pixmaplist.at( m_currentPix ); - - m_pixmaplist << m_pixmaplist.takeAt( m_lastPix ); - - //update index of current pic - m_currentPix = m_pixmaplist.indexOf( orgCurrentPix ); - m_lastPix = m_pixmaplist.count() - 1; //update to point at same pic at new position at the end of the list - }*/ - - QTimer::singleShot( m_interval, this, SLOT(automaticAnimBegin()) ); - break; - } - case PHOTOS_MODE_FADING: - { - // DEBUG_BLOCK; - if ( !m_pixmaplist.empty() && m_currentPix != 0 ) - { - m_pixmaplist.at( m_lastPix )->hide(); - } - - m_timer->start( m_interval ); - break; - } - default : - break; - } -} - -qreal PhotosScrollWidget::animValue() const -{ - // Just a stub - return m_delta; -} - -void PhotosScrollWidget::animate( qreal anim ) -{ - // DEBUG_BLOCK - switch ( m_mode ) - { - case PHOTOS_MODE_INTERACTIVE : - { - // If we're are near the border and still asking to go higher ! - if ( !childItems().isEmpty() && ( ( childItems().first()->pos().x() + childItems().first()->boundingRect().width() + 10 ) > boundingRect().width() ) && ( m_speed < 0 ) ) - { - if( m_animation->state() == QAbstractAnimation::Running ) - m_animation->stop(); - return; - } - // If we're are near the border and still asking to go down - if ( !childItems().isEmpty() && ( ( childItems().last()->pos().x() - 10 ) < 0 ) && ( m_speed > 0 ) ) - { - if( m_animation->state() == QAbstractAnimation::Running ) - m_animation->stop(); - return; - } - - int right = 0; - foreach( QGraphicsItem *it, this->childItems() ) - { - qreal x = it->pos().x() - m_speed; - it->setPos( x, it->pos().y() ); - it->update(); - if ( x > right ) - right = x + it->boundingRect().width() + m_margin; - } - m_actualpos = right; - break; - } - case PHOTOS_MODE_AUTOMATIC : - { - if ( !m_pixmaplist.empty() ) // just for prevention, this should never appears - { - - if ( ( m_pixmaplist.at( m_currentPix )->pos().x() ) <= ( m_margin / 2 - 1) ) - { - m_actualpos = m_margin / 2 - 1; - automaticAnimEnd(); - return; - } - - m_actualpos--; - - //this is not totally obvious, but we already made the number two visual image the current one, - //so if we draw this as the first one, there will be no animation... - int a = m_lastPix; - - int last = a - 1; - if( last < 0 ) last = m_pixmaplist.count() - 1; - bool first = true; - int previousIndex = -1; - - while( true ) - { - int offset = m_margin; - if( first ) - { - //we just need to move the very first image and the rest will fall in line! - offset += m_actualpos; - first = false; - } - else - { - offset += m_pixmaplist.at( previousIndex )->pos().x() + m_pixmaplist.at( previousIndex )->boundingRect().width(); - } - - m_pixmaplist.at( a )->setPos( offset, m_pixmaplist.at( a )->pos().y() ); - m_pixmaplist.at( a )->show(); - - if( a == last ) - break; - - previousIndex = a; - a = ( a + 1 ) % ( m_pixmaplist.size() ); - - } - } - - break; - } - - case PHOTOS_MODE_FADING : - { - if ( !m_pixmaplist.empty() ) // just for prevention, this should never appears - { - m_pixmaplist.at( m_lastPix )->setOpacity( 1 - anim ); - m_pixmaplist.at( m_currentPix )->setOpacity( anim ); - m_pixmaplist.at( m_currentPix )->show(); - } - - break; - } - } -} - -#include "moc_PhotosScrollWidget.cpp" diff --git a/amarok/src/context/applets/photos/PhotosScrollWidget.h b/amarok/src/context/applets/photos/PhotosScrollWidget.h deleted file mode 100644 index 11baae86..00000000 --- a/amarok/src/context/applets/photos/PhotosScrollWidget.h +++ /dev/null @@ -1,114 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Simon Esneault <simon.esneault@gmail.com> * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see <http://www.gnu.org/licenses/>. * - ****************************************************************************************/ - -#ifndef PHOTOSSCROLLWIDGET_H -#define PHOTOSSCROLLWIDGET_H - -#include "context/engines/photos/PhotosInfo.h" -#include "NetworkAccessManagerProxy.h" - -#include <QGraphicsWidget> - -#define PHOTOS_MODE_AUTOMATIC 0 -#define PHOTOS_MODE_INTERACTIVE 1 -#define PHOTOS_MODE_FADING 2 - -//forward -class QPixmap; -class QPropertyAnimation; -class QGraphicsSceneHoverEvent; -class DragPixmapItem; - -/** -* \brief A widget to present the photos -* 3 possible animation : -* - Interactive : the sliding is done on mouse hover -* - Automatic : the photos are presented in an infinite loop, always scrolling -* - Fading, the photos are presented one by one, fading ... -* \sa QGraphicsWidget -* -* \author Simon Esneault <simon.esneault@gmail.com> -*/ - -class PhotosScrollWidget : public QGraphicsWidget -{ - Q_OBJECT - Q_PROPERTY(qreal animValue READ animValue WRITE animate) - public: - - PhotosScrollWidget( QGraphicsItem* parent = 0 ); - ~PhotosScrollWidget(); - - void setPhotosInfoList( const PhotosInfo::List &list ); - - void setMode( int ); - - void clear(); - - int count() const; - - qreal animValue() const; - bool isAnimating() const; - - public slots: - void animate( qreal anim ); - void automaticAnimBegin(); - void automaticAnimEnd(); - - /** - * Reimplement resize in order to correctly repositioned the stack of pixmap - */ - virtual void resize( qreal, qreal ); - - signals: - void photoAdded(); - - protected: - - /** - * Reimplement mouse interaction event - */ - virtual void hoverMoveEvent(QGraphicsSceneHoverEvent* event); - virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent* event); - virtual void hoverEnterEvent(QGraphicsSceneHoverEvent* event); - //virtual void keyPressEvent(QKeyEvent* event); - //virtual void wheelEvent(QGraphicsSceneWheelEvent* event); - - private slots: - void photoFetched( const KUrl&, QByteArray, NetworkAccessManagerProxy::Error ); - - private: - void addPhoto( const PhotosInfoPtr &item, const QPixmap &photo ); - - float m_speed; // if negative, go to left, if positive go to right, - int m_margin; // margin between the photos - int m_scrollmax; // length of the whole stack - int m_actualpos; // - int m_currentPix; // index of the current pix - int m_lastPix; // index of the lat pix - int m_interval; // time in ms between to change - int m_mode; // - int m_delta; - int m_deltastart; - QHash<KUrl, PhotosInfoPtr> m_infoHash; - QPropertyAnimation *m_animation; // animation - QList<int> m_timerlist; - PhotosInfo::List m_currentlist; // contain the list of the current PhotosItem in the widget - QList<DragPixmapItem *> m_pixmaplist; // contain the list of dragpixmap item - QTimer *m_timer; // our magnificent timer -}; - -#endif // PHOTOSSCROLLWIDGET_H diff --git a/amarok/src/context/applets/photos/amarok-context-applet-photos.desktop b/amarok/src/context/applets/photos/amarok-context-applet-photos.desktop deleted file mode 100644 index 603b5767..00000000 --- a/amarok/src/context/applets/photos/amarok-context-applet-photos.desktop +++ /dev/null @@ -1,71 +0,0 @@ -[Desktop Entry] -Name=Photos -Name[bg]=Снимки -Name[bs]=Fotografije -Name[ca]=Fotos -Name[ca@valencia]=Fotos -Name[cs]=Fotky -Name[csb]=Òdjimczi -Name[da]=Fotos -Name[de]=Fotos -Name[el]=Φωτογραφίες -Name[en_GB]=Photos -Name[es]=Fotos -Name[et]=Fotod -Name[eu]=Argazkiak -Name[fa]=عکسها -Name[fi]=Valokuvat -Name[fr]=Photos -Name[ga]=Grianghraif -Name[gl]=Fotos -Name[hu]=Fotók -Name[id]=Foto -Name[is]=Ljósmyndir -Name[it]=Fotografie -Name[ja]=写真 -Name[km]=រូប​ថត -Name[ko]=사진 -Name[lt]=Nuotraukos -Name[lv]=Fotogrāfijas -Name[mai]=फोटो -Name[mr]=फोटो -Name[nb]=Fotoer -Name[nds]=Fotos -Name[nl]=Foto's -Name[nn]=Bilete -Name[pa]=ਫੋਟੋ -Name[pl]=Zdjęcia -Name[pt]=Fotografias -Name[pt_BR]=Fotos -Name[ro]=Fotografii -Name[ru]=Фотографии -Name[sk]=Fotografie -Name[sl]=Fotografije -Name[sq]=Fotografitë -Name[sr]=Фотографије -Name[sr@ijekavian]=Фотографије -Name[sr@ijekavianlatin]=Fotografije -Name[sr@latin]=Fotografije -Name[sv]=Foton -Name[th]=ภาพถ่าย -Name[tr]=Fotoğraflar -Name[ug]=سۈرەتلەر -Name[uk]=Фотографії -Name[x-test]=xxPhotosxx -Name[zh_CN]=照片 -Name[zh_TW]=Photos -Type=Service -Icon=photos-amarok -ServiceTypes=Plasma/Applet -X-KDE-Library=amarok_context_applet_photos -X-KDE-PluginInfo-Author=Simon Esneault -X-KDE-PluginInfo-Email=simon.esneault@gmail.com -X-KDE-PluginInfo-Name=photos -X-KDE-PluginInfo-Version=1 -X-KDE-PluginInfo-Website= -X-KDE-PluginInfo-Depends= -X-KDE-PluginInfo-License=GPL -X-KDE-PluginInfo-EnabledByDefault=true -X-KDE-ParentApp=amarok -X-KDE-PluginInfo-Category=Current - diff --git a/amarok/src/context/applets/photos/photosSettings.ui b/amarok/src/context/applets/photos/photosSettings.ui deleted file mode 100644 index 814ec15f..00000000 --- a/amarok/src/context/applets/photos/photosSettings.ui +++ /dev/null @@ -1,113 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>photosSettings</class> - <widget class="QWidget" name="photosSettings"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>388</width> - <height>165</height> - </rect> - </property> - <layout class="QFormLayout" name="formLayout"> - <property name="labelAlignment"> - <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> - </property> - <item row="0" column="0"> - <widget class="QLabel" name="animationLabel"> - <property name="text"> - <string>Animation</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="KComboBox" name="animationComboBox"> - <property name="currentIndex"> - <number>0</number> - </property> - <item> - <property name="text"> - <string comment="animation type">Automatic</string> - </property> - </item> - <item> - <property name="text"> - <string>Interactive</string> - </property> - </item> - <item> - <property name="text"> - <string>Fading</string> - </property> - </item> - </widget> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="numberofphotosLabel"> - <property name="text"> - <string>Number of photos</string> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="KIntSpinBox" name="photosSpinBox"> - <property name="minimum"> - <number>5</number> - </property> - <property name="maximum"> - <number>100</number> - </property> - <property name="singleStep"> - <number>5</number> - </property> - <property name="value"> - <number>10</number> - </property> - </widget> - </item> - <item row="2" column="0"> - <widget class="QLabel" name="additionalkeywordsLabel"> - <property name="text"> - <string>Additional key words:</string> - </property> - </widget> - </item> - <item row="2" column="1"> - <widget class="KLineEdit" name="additionalkeywordsLineEdit"> - <property name="clickMessage"> - <string>Ex: band live 1977</string> - </property> - </widget> - </item> - <item row="3" column="0" colspan="2"> - <widget class="QLabel" name="addsomemorekeynwordstothequerywithaspaceseparatorLabel"> - <property name="text"> - <string>Add some more key words to the Flickr.com -query, with a space separator. -For example: band live 1977 </string> - </property> - </widget> - </item> - </layout> - </widget> - <customwidgets> - <customwidget> - <class>KIntSpinBox</class> - <extends>QSpinBox</extends> - <header>knuminput.h</header> - </customwidget> - <customwidget> - <class>KLineEdit</class> - <extends>QLineEdit</extends> - <header>klineedit.h</header> - </customwidget> - <customwidget> - <class>KComboBox</class> - <extends>QComboBox</extends> - <header>kcombobox.h</header> - </customwidget> - </customwidgets> - <resources/> - <connections/> -</ui> diff --git a/amarok/src/context/applets/playlistinfo/CMakeLists.txt b/amarok/src/context/applets/playlistinfo/CMakeLists.txt deleted file mode 100644 index 3a52f962..00000000 --- a/amarok/src/context/applets/playlistinfo/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -project(context-currenttrack) - -set(currenttrack_SRCS CurrentTrack.cpp ) - -include_directories( ../../ - ../../.. ) - -kde4_add_plugin(amarok_context_applet_currenttrack ${currenttrack_SRCS}) -target_link_libraries(amarok_context_applet_currenttrack - amarokcore - amaroklib - ${KDE4_PLASMA_LIBS} -) - -install(TARGETS amarok_context_applet_currenttrack DESTINATION ${PLUGIN_INSTALL_DIR}) -install(FILES amarok-context-applet-currenttrack.desktop DESTINATION ${SERVICES_INSTALL_DIR}) -install(FILES amarok-currenttrack.svg DESTINATION ${DATA_INSTALL_DIR}/desktoptheme/default/widgets/ ) diff --git a/amarok/src/context/applets/playlistinfo/PlaylistInfo.cpp b/amarok/src/context/applets/playlistinfo/PlaylistInfo.cpp deleted file mode 100644 index 47d735e4..00000000 --- a/amarok/src/context/applets/playlistinfo/PlaylistInfo.cpp +++ /dev/null @@ -1,197 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Leo Franchi <lfranchi@gmail.com> * - * Copyright (c) 2007 Jeff Mitchell <kde-dev@emailgoeshere.com> * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see <http://www.gnu.org/licenses/>. * - ****************************************************************************************/ - -#include "PlaylistInfo.h" - -#include "core/support/Amarok.h" -#include "core/support/Debug.h" -#include "context/Svg.h" - -#include <QPainter> -#include <QBrush> -#include <QSpinBox> -#include <QLabel> - -PlaylistInfo::PlaylistInfo( QObject* parent, const QStringList& args ) - : Plasma::Applet( parent, args ) - , m_config( 0 ) - , m_configLayout( 0 ) - , m_width( 0 ) - , m_aspectRatio( 0.0 ) - , m_size( QSizeF() ) - , m_rating( -1 ) - , m_trackLength( 0 ) -{ - DEBUG_BLOCK - - setHasConfigurationInterface( true ); - - dataEngine( "amarok-current" )->connectSource( "current", this ); - - m_theme = new Context::Svg( this ); - m_theme->setImagePath( "widgets/amarok-playlistinfo" ); - m_theme->setContentType( Context::Svg::SingleImage ); - m_width = globalConfig().readEntry( "width", 500 ); - - m_totalTracks = new QGraphicsSimpleTextItem( this ); - m_totalTime = new QGraphicsSimpleTextItem( this ); - m_totalSize = new QGraphicsSimpleTextItem( this ); - - m_totalTracks->setBrush( QBrush( Qt::white ) ); - m_totalTime->setBrush( QBrush( Qt::white ) ); - m_totalSize->setBrush( QBrush( Qt::white ) ); - - // get natural aspect ratio, so we can keep it on resize - m_theme->resize(); - m_aspectRatio = (qreal)m_theme->size().height() / (qreal)m_theme->size().width(); - resize( m_width, m_aspectRatio ); - - constraintsEvent(); -} - -PlaylistInfo::~PlaylistInfo() -{ - DEBUG_BLOCK -} - -void PlaylistInfo::constraintsEvent() -{ - prepareGeometryChange(); - // here we put all of the text items into the correct locations - m_title->setPos( m_theme->elementRect( "track" ).topLeft() ); - m_artist->setPos( m_theme->elementRect( "artist" ).topLeft() ); - m_album->setPos( m_theme->elementRect( "album" ).topLeft() ); - m_score->setPos( m_theme->elementRect( "score" ).topLeft() ); - m_numPlayed->setPos( m_theme->elementRect( "numplayed" ).topLeft() ); - m_playedLast->setPos( m_theme->elementRect( "playedlast" ).topLeft() ); - m_albumCover->setPos( m_theme->elementRect( "albumart" ).topLeft() ); - - QPixmap cover = m_albumCover->pixmap(); - cover = cover.scaledToWidth( m_theme->elementRect( "albumart" ).size().width(), Qt::SmoothTransformation ); - m_albumCover->setPixmap( cover ); -// debug() << "changing pixmap size from " << m_albumCover->pixmap().width() << " to " << cover.width(); - - dataEngine( "amarok-current" )->setProperty( "coverWidth", m_theme->elementRect( "albumart" ).size().width() ); -} - -void PlaylistInfo::dataUpdated( const QString& name, const Plasma::DataEngine::Data& data ) -{ - DEBUG_BLOCK - Q_UNUSED( name ); - - if( data.size() == 0 ) return; - - QVariantList currentInfo = data[ "current" ].toList(); - kDebug() << "got data from engine: " << currentInfo; - m_title->setText( currentInfo[ 1 ].toString() ); - m_artist->setText( currentInfo[ 0 ].toString() ); - m_album->setText( currentInfo[ 2 ].toString() ); -// m_rating = currentInfo[ 3 ].toInt(); - // TODO i can't add ratings... so hardcoding to test - m_rating = 6; - m_score->setText( currentInfo[ 4 ].toString() ); - m_trackLength = currentInfo[ 5 ].toInt(); -// m_playedLast->setText( Amarok::verboseTimeSince( currentInfo[ 6 ].toInt() ) ); - - // scale pixmap on demand - QPixmap cover = m_albumCover->pixmap(); - cover = cover.scaledToWidth( m_theme->elementRect( "albumart" ).size().width(), Qt::SmoothTransformation ); - m_albumCover->setPixmap( cover ); -// debug() << "changing pixmap size from " << m_albumCover->pixmap().width() << " to " << cover.width(); - - m_numPlayed->setText( currentInfo[ 7 ].toString() ); - m_albumCover->setPixmap( data[ "albumart" ].value<QPixmap>() ); - -} - -void PlaylistInfo::paintInterface( QPainter *p, const QStyleOptionGraphicsItem *option, const QRect &contentsRect ) -{ - Q_UNUSED( option ); - - p->save(); - m_theme->paint( p, contentsRect, "background" ); - p->restore(); - - p->save(); - int stars = m_rating / 2; - for( int i = 1; i <= stars; i++ ) - { - p->translate( m_theme->elementSize( "star" ).width(), 0 ); - m_theme->paint( p, m_theme->elementRect( "star" ), "star" ); - } // - if( m_rating % 2 != 0 ) - { // paint a half star too - m_theme->paint( p, m_theme->elementRect( "half-star" ), "half-star" ); - } - p->restore(); - - // TODO get, and then paint, album pixmap - -} - -void PlaylistInfo::showConfigurationInterface() -{ - if (m_config == 0) - { - m_config = new KDialog(); - m_config->setCaption( i18n( "Configure Playlist Info Applet" ) ); - - QWidget* widget = new QWidget( m_config ); - m_config->setButtons( KDialog::Ok | KDialog::Cancel | KDialog::Apply ); - connect( m_config, SIGNAL(applyClicked()), this, SLOT(configAccepted()) ); - connect( m_config, SIGNAL(okClicked()), this, SLOT(configAccepted()) ); - - m_configLayout = new QHBoxLayout( widget ); - m_spinWidth = new QSpinBox(); - m_spinWidth->setRange( 200, 700 ); - m_spinWidth->setValue( m_width ); - - QLabel *labelWidth = new QLabel(i18n("Width")); - m_configLayout->addWidget( labelWidth ); - m_configLayout->addWidget( m_spinWidth ); - - } - - m_config->show(); -} - -void PlaylistInfo::configAccepted() // SLOT -{ - KConfigGroup cg = globalConfig(); - - m_width = m_spinWidth->value(); - resize( m_width, m_aspectRatio ); - - cg.writeEntry( "width", m_width ); - - cg.sync(); - constraintsEvent(); -} - -void PlaylistInfo::resize( qreal newWidth, qreal aspectRatio ) -{ - qreal height = aspectRatio * newWidth; - m_size.setWidth( newWidth ); - m_size.setHeight( height ); - - m_theme->resize( m_size ); - kDebug() << "set new size: " << m_size; - constraintsEvent(); -} - -#include "moc_PlaylistInfo.cpp" - diff --git a/amarok/src/context/applets/playlistinfo/PlaylistInfo.h b/amarok/src/context/applets/playlistinfo/PlaylistInfo.h deleted file mode 100644 index 1003daaf..00000000 --- a/amarok/src/context/applets/playlistinfo/PlaylistInfo.h +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Leo Franchi <lfranchi@gmail.com> * - * Copyright (c) 2007 Jeff Mitchell <kde-dev@emailgoeshere.com> * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see <http://www.gnu.org/licenses/>. * - ****************************************************************************************/ - -#ifndef PLAYLIST_INFO_APPLET_H -#define PLAYLIST_INFO_APPLET_H - -#include <context/Applet.h> -#include <context/DataEngine.h> -#include <context/Svg.h> - -#include <KDialog> - -class QGraphicsPixmapItem; -class QLabel; -class QHBoxLayout; -class QSpinBox; -class QCheckBox; - -class PlaylistInfo : public Context::Applet -{ - Q_OBJECT -public: - PlaylistInfo( QObject* parent, const QStringList& args ); - ~PlaylistInfo(); - - void paintInterface( QPainter *painter, const QStyleOptionGraphicsItem *option, const QRect &contentsRect ); - - void constraintsEvent(); - QSizeF contentSizeHint() const { return m_size; } - -public slots: - void dataUpdated( const QString& name, const Plasma::DataEngine::Data &data ); - void showConfigurationInterface(); - - -private slots: - void configAccepted(); - -private: - void resize( qreal newWidth, qreal aspectRatio ); - - KDialog* m_config; - QHBoxLayout* m_configLayout; - QSpinBox* m_spinWidth; - int m_width; - - qreal m_aspectRatio; - - Context::Svg* m_theme; - QSizeF m_size; - - QGraphicsSimpleTextItem* m_totalTracks; - QGraphicsSimpleTextItem* m_totalTime; - QGraphicsSimpleTextItem* m_totalSize; - - int m_rating; - int m_trackLength; - - QGraphicsPixmapItem* m_albumCover; - -}; - -AMAROK_EXPORT_APPLET( playlistinfo, PlaylistInfo ) - -#endif diff --git a/amarok/src/context/applets/playlistinfo/amarok-context-applet-playlistinfo.desktop b/amarok/src/context/applets/playlistinfo/amarok-context-applet-playlistinfo.desktop deleted file mode 100644 index 82767a79..00000000 --- a/amarok/src/context/applets/playlistinfo/amarok-context-applet-playlistinfo.desktop +++ /dev/null @@ -1,71 +0,0 @@ -[Desktop Entry] -Name=Playlist Information -Name[bg]=Информация за списъка -Name[bs]=Podaci o listi numera -Name[ca]=Informació de la llista de reproducció -Name[ca@valencia]=Informació de la llista de reproducció -Name[cs]=Informace o seznamu skladeb -Name[csb]=Wëdowiédza ò lësce graniô -Name[da]=Spillelisteinformation -Name[de]=Wiedergabelisten-Information -Name[el]=Πληροφορίες λίστας αναπαραγωγής -Name[en_GB]=Playlist Information -Name[eo]=Ludlista informo -Name[es]=Información de la lista de reproducción -Name[et]=Esitusnimekirja info -Name[eu]=Zerrendaren informazioa -Name[fa]=اطلاعات فهرست‌پخش -Name[fi]=Soittolistan tiedot -Name[fr]=Informations sur la liste de lecture -Name[ga]=Eolas faoin Seinmliosta -Name[gl]=Información da lista de temas -Name[he]=מידע על רשימת־ההשמעה -Name[hne]=गीतसूची जानकारी -Name[hu]=Lejátszólista-információ -Name[id]=Informasi Playlist -Name[is]=Upplýsingar um lagalista -Name[it]=Informazioni sulla scaletta -Name[ja]=プレイリスト情報 -Name[km]=ព័ត៌មាន​បញ្ជី​ចាក់ -Name[ko]=재생 목록 정보 -Name[ku]=Agahiya Lîsteya Lêdanê -Name[lt]=Grojaraščio informacija -Name[lv]=Repertuāra informācija -Name[nb]=Spillelisteinformasjon -Name[nds]=Afspeellist-Informatschoon -Name[nl]=Afspeellijstinformatie -Name[nn]=Spelelisteinformasjon -Name[pa]=ਪਲੇਅਲਿਸਟ ਜਾਣਕਾਰੀ -Name[pl]=Informacja o liście odtwarzania -Name[pt]=Informação da Lista de Reprodução -Name[pt_BR]=Informações de lista de músicas -Name[ro]=Informație listă de redare -Name[ru]=Сведения списка воспроизведения -Name[sk]=Informácie zoznamu skladieb -Name[sl]=Podrobnosti o seznamu predvajanja -Name[sr]=Подаци о листи нумера -Name[sr@ijekavian]=Подаци о листи нумера -Name[sr@ijekavianlatin]=Podaci o listi numera -Name[sr@latin]=Podaci o listi numera -Name[sv]=Information om spellista -Name[th]=ข้อมูลรายละเอียดของรายการเล่น -Name[tr]=Çalma Listesi Bilgisi -Name[uk]=Інформація про список композицій -Name[wa]=Pondants et djondants del djivêye a djouwer -Name[x-test]=xxPlaylist Informationxx -Name[zh_CN]=播放列表信息 -Name[zh_TW]=播放清單資訊 -Type=Service -ServiceTypes=Plasma/Applet - -X-KDE-Library=amarok_context_applet_playlistinfo -X-KDE-PluginInfo-Author=Jeff Mitchell -X-KDE-PluginInfo-Email=kde-dev@emailgoeshere.com -X-KDE-PluginInfo-Name=playlistinfo -X-KDE-PluginInfo-Version=pre0.1 -X-KDE-PluginInfo-Website= -X-KDE-PluginInfo-Depends= -X-KDE-PluginInfo-License=GPL -X-KDE-PluginInfo-EnabledByDefault=true -X-KDE-ParentApp=amarok -X-KDE-PluginInfo-Category=Current diff --git a/amarok/src/context/applets/playlistinfo/amarok-playlistinfo.svg b/amarok/src/context/applets/playlistinfo/amarok-playlistinfo.svg deleted file mode 100644 index a8edccab..00000000 --- a/amarok/src/context/applets/playlistinfo/amarok-playlistinfo.svg +++ /dev/null @@ -1,711 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<!-- Created with Inkscape (http://www.inkscape.org/) --> -<svg - xmlns:dc="http://purl.org/dc/elements/1.1/" - xmlns:cc="http://creativecommons.org/ns#" - xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" - xmlns:svg="http://www.w3.org/2000/svg" - xmlns="http://www.w3.org/2000/svg" - xmlns:xlink="http://www.w3.org/1999/xlink" - xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" - xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" - version="1.0" - width="506.50198" - height="161.99736" - id="svg2581" - sodipodi:version="0.32" - inkscape:version="0.46" - sodipodi:docname="amarok-playlistinfo.svg" - inkscape:output_extension="org.inkscape.output.svg.inkscape" - sodipodi:docbase="/home/hydrogen/kde/src/amarok/src/context/applets/playlistinfo"> - <metadata - id="metadata138"> - <rdf:RDF> - <cc:Work - rdf:about=""> - <dc:format>image/svg+xml</dc:format> - <dc:type - rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> - </cc:Work> - </rdf:RDF> - </metadata> - <sodipodi:namedview - inkscape:window-height="567" - inkscape:window-width="722" - inkscape:pageshadow="2" - inkscape:pageopacity="0.0" - guidetolerance="10.0" - gridtolerance="10.0" - objecttolerance="10.0" - borderopacity="1.0" - bordercolor="#666666" - pagecolor="#ffffff" - id="base" - inkscape:zoom="1.247774" - inkscape:cx="251.9451" - inkscape:cy="63.196274" - inkscape:window-x="724" - inkscape:window-y="184" - inkscape:current-layer="svg2581" /> - <defs - id="defs2583"> - <linearGradient - id="linearGradient9189"> - <stop - id="stop9191" - style="stop-color:#ffffff;stop-opacity:1" - offset="0" /> - <stop - id="stop9193" - style="stop-color:#ffffff;stop-opacity:0" - offset="1" /> - </linearGradient> - <linearGradient - id="linearGradient1563"> - <stop - id="stop1565" - style="stop-color:#ffffff;stop-opacity:1" - offset="0" /> - <stop - id="stop1567" - style="stop-color:#ffffff;stop-opacity:0" - offset="1" /> - </linearGradient> - <linearGradient - id="linearGradient12948"> - <stop - id="stop12950" - style="stop-color:#ffffff;stop-opacity:1" - offset="0" /> - <stop - id="stop12952" - style="stop-color:#c0c0c0;stop-opacity:0" - offset="1" /> - </linearGradient> - <linearGradient - id="linearGradient3638"> - <stop - id="stop3640" - style="stop-color:#ffffff;stop-opacity:0" - offset="0" /> - <stop - id="stop3661" - style="stop-color:#ffffff;stop-opacity:1" - offset="0.06868132" /> - <stop - id="stop3659" - style="stop-color:#ffffff;stop-opacity:1" - offset="0.5" /> - <stop - id="stop3642" - style="stop-color:#ffffff;stop-opacity:0" - offset="1" /> - </linearGradient> - <linearGradient - id="linearGradient3273"> - <stop - id="stop3275" - style="stop-color:#ffffff;stop-opacity:0.55035973" - offset="0" /> - <stop - id="stop3277" - style="stop-color:#ffffff;stop-opacity:0" - offset="1" /> - </linearGradient> - <linearGradient - id="linearGradient3290"> - <stop - id="stop3292" - style="stop-color:#ffff00;stop-opacity:1" - offset="0" /> - <stop - id="stop3294" - style="stop-color:#ffb66d;stop-opacity:1" - offset="1" /> - </linearGradient> - <linearGradient - id="linearGradient3291"> - <stop - id="stop3293" - style="stop-color:#000000;stop-opacity:1" - offset="0" /> - <stop - id="stop3295" - style="stop-color:#000000;stop-opacity:0" - offset="1" /> - </linearGradient> - <linearGradient - id="linearGradient3765"> - <stop - id="stop3767" - style="stop-color:#ffffff;stop-opacity:1" - offset="0" /> - <stop - id="stop3769" - style="stop-color:#ffffff;stop-opacity:0" - offset="1" /> - </linearGradient> - <radialGradient - inkscape:collect="always" - xlink:href="#linearGradient3765" - id="radialGradient4109" - gradientUnits="userSpaceOnUse" - gradientTransform="matrix(0.291857,2.4900758e-2,-9.631583e-2,1.0789699,194.04072,-17.723217)" - cx="23.662739" - cy="95.898506" - fx="24.26058" - fy="96.778763" - r="2.7939141" /> - <linearGradient - inkscape:collect="always" - xlink:href="#linearGradient1563" - id="linearGradient4114" - gradientUnits="userSpaceOnUse" - gradientTransform="matrix(0.1966504,0,0,0.1922527,187.05702,67.90089)" - x1="98.291809" - y1="-44.01474" - x2="44.242641" - y2="101.45739" /> - <linearGradient - inkscape:collect="always" - xlink:href="#linearGradient1563" - id="linearGradient4117" - gradientUnits="userSpaceOnUse" - gradientTransform="matrix(0.1966504,0,0,0.1922527,187.05702,67.90089)" - x1="98.291809" - y1="-44.01474" - x2="44.242641" - y2="101.45739" /> - <linearGradient - inkscape:collect="always" - xlink:href="#linearGradient1563" - id="linearGradient4120" - gradientUnits="userSpaceOnUse" - gradientTransform="matrix(0.1966504,0,0,0.1922527,187.05702,67.90089)" - x1="98.291809" - y1="-126.7503" - x2="44.242641" - y2="101.45739" /> - <radialGradient - inkscape:collect="always" - xlink:href="#linearGradient12948" - id="radialGradient4123" - gradientUnits="userSpaceOnUse" - gradientTransform="matrix(-0.3427491,-0.2044579,-8.708638e-2,0.2251442,224.32432,68.025257)" - cx="23.190451" - cy="59.379417" - fx="22.471308" - fy="59.354759" - r="2.1082227" /> - <linearGradient - inkscape:collect="always" - xlink:href="#linearGradient3638" - id="linearGradient4126" - gradientUnits="userSpaceOnUse" - gradientTransform="matrix(0.1966504,0,0,0.1922527,187.057,67.900855)" - x1="57.287113" - y1="1.1597457" - x2="144.2531" - y2="16.876789" /> - <linearGradient - inkscape:collect="always" - xlink:href="#linearGradient3638" - id="linearGradient4129" - gradientUnits="userSpaceOnUse" - gradientTransform="matrix(0.1966504,0,0,0.1922527,187.057,67.900855)" - x1="57.287113" - y1="1.1597457" - x2="144.2531" - y2="16.876789" /> - <linearGradient - inkscape:collect="always" - xlink:href="#linearGradient3638" - id="linearGradient4132" - gradientUnits="userSpaceOnUse" - gradientTransform="matrix(0.1966504,0,0,0.1922527,187.057,67.900855)" - x1="57.287113" - y1="1.1597457" - x2="144.2531" - y2="16.876789" /> - <radialGradient - inkscape:collect="always" - xlink:href="#linearGradient3291" - id="radialGradient4135" - gradientUnits="userSpaceOnUse" - gradientTransform="matrix(-0.1917545,0,0,1.5844996e-2,211.9676,89.787719)" - cx="63.912209" - cy="115.70919" - fx="63.975182" - fy="116.88514" - r="63.912209" /> - <linearGradient - inkscape:collect="always" - xlink:href="#linearGradient3290" - id="linearGradient4138" - gradientUnits="userSpaceOnUse" - gradientTransform="matrix(0.1966504,0,0,0.1922527,187.057,67.900855)" - x1="84.634949" - y1="116.10083" - x2="89.72541" - y2="-15.33666" /> - <linearGradient - inkscape:collect="always" - xlink:href="#linearGradient3273" - id="linearGradient4140" - gradientUnits="userSpaceOnUse" - gradientTransform="matrix(0.188777,0,0,0.1845553,187.52024,68.530591)" - spreadMethod="reflect" - x1="80.100487" - y1="44.807674" - x2="77.714729" - y2="101.4734" /> - <radialGradient - inkscape:collect="always" - xlink:href="#linearGradient3765" - id="radialGradient4161" - gradientUnits="userSpaceOnUse" - gradientTransform="matrix(0.1552247,1.3243414e-2,-5.1225759e-2,0.5738478,222.28638,27.94052)" - cx="23.662739" - cy="95.898506" - fx="24.26058" - fy="96.778763" - r="2.7939141" /> - <linearGradient - inkscape:collect="always" - xlink:href="#linearGradient1563" - id="linearGradient4166" - gradientUnits="userSpaceOnUse" - gradientTransform="matrix(0.1045889,0,0,0.1022492,218.57208,73.479518)" - x1="98.291809" - y1="-44.01474" - x2="44.242641" - y2="101.45739" /> - <linearGradient - inkscape:collect="always" - xlink:href="#linearGradient1563" - id="linearGradient4169" - gradientUnits="userSpaceOnUse" - gradientTransform="matrix(0.1045889,0,0,0.1022492,218.57208,73.479518)" - x1="98.291809" - y1="-44.01474" - x2="44.242641" - y2="101.45739" /> - <linearGradient - inkscape:collect="always" - xlink:href="#linearGradient1563" - id="linearGradient4172" - gradientUnits="userSpaceOnUse" - gradientTransform="matrix(0.1045889,0,0,0.1022492,218.57208,73.479518)" - x1="98.291809" - y1="-126.7503" - x2="44.242641" - y2="101.45739" /> - <radialGradient - inkscape:collect="always" - xlink:href="#linearGradient12948" - id="radialGradient4175" - gradientUnits="userSpaceOnUse" - gradientTransform="matrix(-0.1822918,-0.1087405,-4.6317058e-2,0.1197424,238.39277,73.545662)" - cx="23.190451" - cy="59.379417" - fx="22.471308" - fy="59.354759" - r="2.1082227" /> - <linearGradient - inkscape:collect="always" - xlink:href="#linearGradient3638" - id="linearGradient4178" - gradientUnits="userSpaceOnUse" - gradientTransform="matrix(0.1045889,0,0,0.1022492,218.57207,73.479499)" - x1="57.287113" - y1="1.1597457" - x2="144.2531" - y2="16.876789" /> - <linearGradient - inkscape:collect="always" - xlink:href="#linearGradient3638" - id="linearGradient4181" - gradientUnits="userSpaceOnUse" - gradientTransform="matrix(0.1045889,0,0,0.1022492,218.57207,73.479499)" - x1="57.287113" - y1="1.1597457" - x2="144.2531" - y2="16.876789" /> - <linearGradient - inkscape:collect="always" - xlink:href="#linearGradient3638" - id="linearGradient4184" - gradientUnits="userSpaceOnUse" - gradientTransform="matrix(0.1045889,0,0,0.1022492,218.57207,73.479499)" - x1="57.287113" - y1="1.1597457" - x2="144.2531" - y2="16.876789" /> - <radialGradient - inkscape:collect="always" - xlink:href="#linearGradient3291" - id="radialGradient4187" - gradientUnits="userSpaceOnUse" - gradientTransform="matrix(-0.101985,0,0,8.4271267e-3,231.82082,85.119981)" - cx="63.912209" - cy="115.70919" - fx="63.975182" - fy="116.88514" - r="63.912209" /> - <linearGradient - inkscape:collect="always" - xlink:href="#linearGradient3290" - id="linearGradient4190" - gradientUnits="userSpaceOnUse" - gradientTransform="matrix(0.1045889,0,0,0.1022492,218.57207,73.479499)" - x1="84.634949" - y1="116.10083" - x2="89.72541" - y2="-15.33666" /> - <linearGradient - inkscape:collect="always" - xlink:href="#linearGradient3273" - id="linearGradient4192" - gradientUnits="userSpaceOnUse" - gradientTransform="matrix(0.1004014,0,0,9.8155332e-2,218.81845,73.814422)" - spreadMethod="reflect" - x1="80.100487" - y1="44.807674" - x2="77.714729" - y2="101.4734" /> - <linearGradient - inkscape:collect="always" - xlink:href="#linearGradient9189" - id="linearGradient2325" - gradientUnits="userSpaceOnUse" - gradientTransform="matrix(0.8870436,0,0,0.9257885,-30.434573,-379.49418)" - x1="133.57143" - y1="417.00504" - x2="137.14287" - y2="558.43359" /> - </defs> - <g - id="albumart"> - <rect - width="161.11676" - height="149.17079" - x="6.7626796" - y="6.5079145" - id="rect6163" - style="opacity:0;fill:#2e3436;fill-opacity:1;fill-rule:evenodd;stroke:#fff9f9;stroke-width:0.91351575;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" /> - <rect - width="16.628111" - height="149.80359" - x="6.459518" - y="6.1914954" - id="rect7219" - style="opacity:0;fill:#2e3436;fill-opacity:1;fill-rule:evenodd;stroke:#fff9f9;stroke-width:0.29409412;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" /> - <g - transform="matrix(0.8870436,0,0,0.9316402,-30.434573,-382.17114)" - id="g6239" - style="opacity:0"> - <rect - width="17.288054" - height="159.45242" - x="42.338238" - y="417.72528" - id="rect6165" - style="opacity:0.75;fill:#2e3436;fill-opacity:1;fill-rule:evenodd;stroke:#fff9f9;stroke-width:0.30938008;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" /> - <rect - width="2.4870424" - height="159.28152" - x="42.239185" - y="417.63211" - id="rect6167" - style="opacity:0.75;fill:#2e3436;fill-opacity:1;fill-rule:evenodd;stroke:#fff9f9;stroke-width:0.11728111;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" /> - <rect - width="2.4870424" - height="159.28152" - x="44.757221" - y="417.63211" - id="rect6169" - style="opacity:0.75;fill:#2e3436;fill-opacity:1;fill-rule:evenodd;stroke:#fff9f9;stroke-width:0.11728111;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" /> - <rect - width="2.4870424" - height="159.28152" - x="47.275299" - y="417.63211" - id="rect6171" - style="opacity:0.75;fill:#2e3436;fill-opacity:1;fill-rule:evenodd;stroke:#fff9f9;stroke-width:0.11728111;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" /> - <g - transform="matrix(1.0491991,0,0,0.990034,18.646399,359.10462)" - id="g6178"> - <rect - width="2.37042" - height="160.88492" - x="29.557537" - y="59.062572" - id="rect6180" - style="opacity:0.75;fill:#2e3436;fill-opacity:1;fill-rule:evenodd;stroke:#fff9f9;stroke-width:0.11507317;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" /> - <rect - width="2.37042" - height="160.88492" - x="31.9575" - y="59.062572" - id="rect6182" - style="opacity:0.75;fill:#2e3436;fill-opacity:1;fill-rule:evenodd;stroke:#fff9f9;stroke-width:0.11507317;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" /> - <rect - width="2.37042" - height="160.88492" - x="34.357498" - y="59.062572" - id="rect6184" - style="opacity:0.75;fill:#2e3436;fill-opacity:1;fill-rule:evenodd;stroke:#fff9f9;stroke-width:0.11507317;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" /> - </g> - <rect - width="2.4870424" - height="159.28152" - x="57.137772" - y="417.63211" - id="rect6189" - style="opacity:0.75;fill:#2e3436;fill-opacity:1;fill-rule:evenodd;stroke:#fff9f9;stroke-width:0.11728111;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" /> - </g> - <rect - width="145.41177" - height="149.44872" - x="23.104843" - y="6.5642843" - id="rect8190" - style="opacity:0;fill:url(#linearGradient2325);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" /> - </g> - <g - id="background"> - <rect - y="0.10906799" - x="-0.80142719" - height="161.88829" - width="507.30341" - id="rect4371" - style="opacity:0;fill:#ffffff;fill-opacity:1;stroke-width:3.76300001;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:3.763, 3.763;stroke-dashoffset:0" /> - <g - id="g4407"> - <rect - style="opacity:0;fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" - id="track" - y="29.916864" - x="229.66367" - height="14.456263" - width="279.31619" /> - <rect - style="opacity:0;fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" - id="artist" - y="10.064564" - x="229.27518" - height="16.059116" - width="280.09314" /> - <rect - style="opacity:0;fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" - id="album" - y="52.451874" - x="233.22128" - height="12.853409" - width="270.70819" /> - <rect - style="opacity:0;fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" - id="numplayed" - y="123.89265" - x="269.45197" - height="10.752309" - width="234.47754" /> - <rect - style="opacity:0;fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" - id="score" - y="104.84178" - x="230.05215" - height="11.804454" - width="273.87732" /> - <rect - style="opacity:0;fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" - id="playedlast" - y="142.94353" - x="261.2937" - height="9.4677944" - width="242.6358" /> - <text - x="174.7462" - y="115.93441" - transform="scale(1.0247278,0.9758689)" - id="text3816" - xml:space="preserve" - style="font-size:12.85346985px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#888a85;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - sodipodi:linespacing="125%"><tspan - x="174.7462" - y="115.93441" - id="tspan3818">Score: </tspan></text> - <text - x="174.51402" - y="134.513" - transform="scale(1.0277362,0.9730124)" - id="text3820" - xml:space="preserve" - style="font-size:10.79622936px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#888a85;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - sodipodi:linespacing="125%"><tspan - x="174.51402" - y="134.513" - id="tspan3822">Times Played: </tspan></text> - <text - x="172.32352" - y="155.09834" - transform="scale(1.0319621,0.9690278)" - id="text3824" - xml:space="preserve" - style="font-size:11.3621006px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#888a85;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - sodipodi:linespacing="125%"><tspan - x="172.32352" - y="155.09834" - id="tspan3826">Played Last: </tspan></text> - <text - x="174.97635" - y="22.507437" - transform="scale(1.0247278,0.9758689)" - id="text3828" - xml:space="preserve" - style="font-size:11.85803413px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#888a85;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - sodipodi:linespacing="125%"><tspan - x="174.97635" - y="22.507437" - id="tspan3830">Artist: </tspan></text> - <text - x="174.97136" - y="42.804947" - transform="scale(1.0247278,0.9758689)" - id="text3832" - xml:space="preserve" - style="font-size:12.87862682px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#888a85;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - sodipodi:linespacing="125%"><tspan - x="174.97136" - y="42.804947" - id="tspan3834">Track: </tspan></text> - <text - x="174.97481" - y="61.793442" - transform="scale(1.0247278,0.9758689)" - id="text3836" - xml:space="preserve" - style="font-size:12.17633915px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#888a85;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - sodipodi:linespacing="125%"><tspan - x="174.97481" - y="61.793442" - id="tspan3838">Album: </tspan></text> - </g> - </g> - <g - id="half-star"> - <path - style="fill:url(#linearGradient4190);fill-opacity:1;fill-rule:nonzero;stroke:url(#linearGradient4192);stroke-width:0.70351464;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:4;stroke-opacity:1" - id="path3978" - d="M 225.35129,74.518295 C 225.32661,74.534469 225.19389,74.599861 225.04019,74.778987 C 224.85804,74.991271 224.65277,75.311526 224.44763,75.650841 C 224.24249,75.990165 224.03701,76.351922 223.83729,76.664623 C 223.63757,76.977344 223.46757,77.238417 223.20324,77.420629 C 222.93892,77.602841 222.62647,77.671948 222.25811,77.750828 C 221.88975,77.829727 221.47472,77.896024 221.07891,77.970961 C 220.68309,78.045916 220.30466,78.129416 220.03895,78.225871 C 219.81062,78.308742 219.70471,78.408054 219.68342,78.422828 C 219.68353,78.423028 219.68329,78.425448 219.68342,78.425724 C 219.69081,78.44587 219.70899,78.590886 219.84044,78.796483 C 219.99067,79.031447 220.24038,79.323506 220.50708,79.619099 C 220.77379,79.914693 221.05863,80.21443 221.30112,80.496754 C 221.54362,80.779078 221.74773,81.020186 221.84331,81.322266 C 221.9389,81.624337 221.91003,81.934428 221.87294,82.301291 C 221.83586,82.668163 221.77421,83.074518 221.72481,83.465699 C 221.72163,83.490856 221.71849,83.515965 221.71543,83.540979 C 221.67091,83.905031 221.63977,84.2523 221.65073,84.511354 C 221.66098,84.753605 221.72794,84.884465 221.73369,84.905288 C 221.75558,84.904621 221.90192,84.929206 222.14255,84.870529 C 222.41756,84.803451 222.77698,84.665085 223.14695,84.508458 C 223.51692,84.351822 223.89953,84.17744 224.24912,84.039216 C 224.59871,83.900992 224.89457,83.78563 225.21796,83.790116 C 225.54136,83.794584 225.83248,83.917433 226.17791,84.065287 C 226.52335,84.213131 226.90295,84.399563 227.26823,84.566392 C 227.63352,84.733211 227.98784,84.879864 228.26077,84.954525 C 228.49961,85.01985 228.64755,84.999713 228.66965,85.000866 C 228.67592,84.980167 228.7472,84.851698 228.76445,84.609837 C 228.78418,84.333409 228.76103,83.956583 228.72298,83.564192 C 228.68492,83.171782 228.63089,82.761741 228.60446,82.393983 C 228.57802,82.026234 228.55942,81.717162 228.66372,81.417845 C 228.76801,81.118546 228.97904,80.882315 229.22962,80.60682 C 229.48019,80.331316 229.77516,80.040419 230.05032,79.752341 C 230.32548,79.464254 230.57776,79.177814 230.73473,78.947099 C 230.86963,78.748836 230.89787,78.60606 230.90657,78.582141 C 230.90671,78.581865 230.90644,78.579436 230.90657,78.579246 C 230.88552,78.563938 230.77985,78.462759 230.554,78.373591 C 230.29119,78.269821 229.91939,78.175605 229.5259,78.089724 C 229.13241,78.003843 228.71855,77.923886 228.35262,77.834833 C 227.98671,77.74577 227.67531,77.670919 227.41638,77.481449 C 227.15744,77.291997 226.99661,77.023294 226.80604,76.705183 C 226.61546,76.387071 226.42054,76.02178 226.22532,75.676912 C 226.03009,75.332044 225.83239,75.007826 225.65646,74.79057 C 225.50252,74.600481 225.36854,74.532002 225.35129,74.518295 z " /> - <path - style="opacity:0.38139535;fill:url(#radialGradient4187);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:4;stroke-opacity:1" - id="path3980" - d="M 218.78465,86.095078 C 218.78465,86.392537 221.70289,86.633675 225.30273,86.633675 C 228.90257,86.633675 231.82082,86.392537 231.82082,86.095078 C 231.82082,85.797619 228.90257,85.556481 225.30273,85.556481 C 221.70289,85.556481 218.78465,85.797619 218.78465,86.095078 L 218.78465,86.095078 z " /> - <path - style="fill:none;fill-opacity:1;fill-rule:evenodd;stroke:url(#linearGradient4184);stroke-width:0.05240173;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.5813008" - id="path3982" - d="M 224.35237,74.577639 C 224.48347,74.355648 224.9751,73.61837 225.37125,73.624038 C 226.09092,73.634649 227.30643,76.66249 227.87486,77.003062 C 228.57455,77.422286 231.11479,77.719184 231.57698,78.077579" /> - <path - style="fill:none;fill-opacity:1;fill-rule:evenodd;stroke:url(#linearGradient4181);stroke-width:0.10341241;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.43089432" - id="path3984" - d="M 224.34917,74.632362 C 224.48028,74.410372 224.97675,73.640345 225.37284,73.649061 C 226.0848,73.664702 227.28134,76.698648 227.86686,77.028076 C 228.57811,77.428268 231.12155,77.750037 231.58375,78.108432" /> - <path - style="fill:none;fill-opacity:1;fill-rule:evenodd;stroke:url(#linearGradient4178);stroke-width:0.20682482;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.43089432" - id="path3986" - d="M 224.34599,74.738409 C 224.47709,74.516419 224.99603,73.687715 225.37284,73.698955 C 226.02748,73.718692 227.29729,76.798446 227.85728,77.07798 C 228.58817,77.442823 231.2364,77.843606 231.61565,78.192646" /> - <path - style="opacity:0.70232556;fill:url(#radialGradient4175);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.89999998;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:4;stroke-opacity:1" - id="path3988" - d="M 231.03075,77.904911 C 230.97671,78.04432 231.10505,78.260064 231.31737,78.386714 C 231.52968,78.513364 231.74552,78.502928 231.79937,78.363409 C 231.85341,78.224001 231.72506,78.008256 231.51275,77.881606 C 231.30043,77.754957 231.0846,77.765392 231.03075,77.904911 z " /> - <path - style="fill:url(#linearGradient4172);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:6.80299997;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:4;stroke-opacity:1" - id="path3990" - d="M 225.35075,74.517981 C 225.32607,74.534155 225.19395,74.600881 225.04026,74.779987 C 224.8581,74.99229 224.65381,75.312983 224.44867,75.652308 C 224.24354,75.991632 224.03721,76.352503 223.83749,76.665214 C 223.63777,76.977925 223.46774,77.237093 223.20342,77.419295 C 222.93908,77.601517 222.62721,77.672719 222.25884,77.751609 C 221.89049,77.830508 221.47477,77.897139 221.07895,77.972085 C 220.68314,78.047031 220.30531,78.128064 220.03961,78.224518 C 219.81126,78.307399 219.70462,78.407854 219.68335,78.422619 C 219.68334,78.422886 219.68336,78.425486 219.68335,78.42581 C 219.69073,78.445956 219.70878,78.590876 219.84023,78.796473 C 219.99046,79.031437 220.24027,79.322068 220.50699,79.617661 C 220.70805,79.840509 220.91914,80.067147 221.11491,80.28547 C 223.5074,80.531388 226.05355,81.398756 228.58648,81.816017 C 228.59485,81.678508 228.61967,81.546457 228.66492,81.416606 C 228.76921,81.117298 228.97977,80.883696 229.23035,80.608192 C 229.48093,80.332707 229.77556,80.039952 230.05072,79.751865 C 230.32588,79.463778 230.57684,79.177357 230.73381,78.946642 C 230.86872,78.748389 230.89834,78.606307 230.90704,78.582389 C 230.90704,78.582122 230.90706,78.579531 230.90704,78.579188 C 230.88599,78.563891 230.7799,78.463864 230.55405,78.374696 C 230.29125,78.270926 229.91799,78.176186 229.52451,78.090315 C 229.13102,78.004443 228.71707,77.923753 228.35115,77.83468 C 227.98523,77.745627 227.67532,77.669481 227.41639,77.48001 C 227.15744,77.290559 226.99577,77.024866 226.80519,76.706754 C 226.61462,76.388633 226.42191,76.022733 226.22669,75.677864 C 226.03147,75.332996 225.83392,75.006826 225.65798,74.789589 C 225.50404,74.59949 225.368,74.531688 225.35075,74.517981 z " /> - <path - style="opacity:0.41393445;fill:url(#linearGradient4169);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:6.80299997;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:4;stroke-opacity:1" - id="path3992" - d="M 225.35075,74.517981 C 225.32607,74.534155 225.19395,74.600881 225.04026,74.779987 C 224.8581,74.99229 224.65381,75.312983 224.44867,75.652308 C 224.24354,75.991632 224.03721,76.352503 223.83749,76.665214 C 223.63777,76.977925 223.46774,77.237093 223.20342,77.419295 C 222.93908,77.601517 222.62721,77.672719 222.25884,77.751609 C 221.89049,77.830508 221.47477,77.897139 221.07895,77.972085 C 220.68314,78.047031 220.30531,78.128064 220.03961,78.224518 C 219.81126,78.307399 219.70462,78.407854 219.68335,78.422619 C 219.68334,78.422886 219.68336,78.425486 219.68335,78.42581 C 219.69073,78.445956 219.70878,78.590876 219.84023,78.796473 C 219.99046,79.031437 220.24027,79.322068 220.50699,79.617661 C 220.70805,79.840509 220.91914,80.067147 221.11491,80.28547 C 221.26552,80.300949 221.41742,80.319648 221.56921,80.339794 C 222.99921,79.269249 224.92417,77.8955 226.78559,76.674797 C 226.60152,76.364658 226.4151,76.010693 226.22669,75.677864 C 226.03147,75.332996 225.83392,75.006826 225.65798,74.789589 C 225.50404,74.59949 225.368,74.531688 225.35075,74.517981 z M 228.96234,77.968884 C 227.64994,78.937707 226.49912,80.014757 225.50111,81.157781 C 226.52429,81.40428 227.55644,81.646341 228.58648,81.816017 C 228.59485,81.678508 228.61967,81.546457 228.66492,81.416606 C 228.76921,81.117298 228.97977,80.883696 229.23035,80.608192 C 229.48093,80.332707 229.77556,80.039952 230.05072,79.751865 C 230.32588,79.463778 230.57684,79.177357 230.73381,78.946642 C 230.86872,78.748389 230.89834,78.606307 230.90704,78.582389 C 230.90704,78.582122 230.90706,78.579531 230.90704,78.579188 C 230.88599,78.563891 230.7799,78.463864 230.55405,78.374696 C 230.29125,78.270926 229.91799,78.176186 229.52451,78.090315 C 229.33943,78.049917 229.14933,78.008396 228.96234,77.968884 z " /> - <path - style="opacity:0.34836067;fill:url(#linearGradient4166);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:6.80299997;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:4;stroke-opacity:1" - id="path3994" - d="M 225.35075,74.517981 C 225.32607,74.534155 225.19395,74.600881 225.04026,74.779987 C 224.8581,74.99229 224.65381,75.312983 224.44867,75.652308 C 224.24354,75.991632 224.03721,76.352503 223.83749,76.665214 C 223.63777,76.977925 223.46774,77.237093 223.20342,77.419295 C 222.93908,77.601517 222.62721,77.672719 222.25884,77.751609 C 221.89049,77.830508 221.47477,77.897139 221.07895,77.972085 C 220.68314,78.047031 220.30531,78.128064 220.03961,78.224518 C 219.81126,78.307399 219.70462,78.407854 219.68335,78.422619 C 219.68334,78.422886 219.68336,78.425486 219.68335,78.42581 C 219.69073,78.445956 219.70878,78.590876 219.84023,78.796473 C 219.99046,79.031437 224.92417,77.8955 226.78559,76.674797 C 226.60152,76.364658 226.4151,76.010693 226.22669,75.677864 C 226.03147,75.332996 225.83392,75.006826 225.65798,74.789589 C 225.50404,74.59949 225.368,74.531688 225.35075,74.517981 z M 228.96234,77.968884 C 225.73332,80.380039 227.55644,81.646341 228.58648,81.816017 C 228.59485,81.678508 228.61967,81.546457 228.66492,81.416606 C 228.76921,81.117298 228.97977,80.883696 229.23035,80.608192 C 229.48093,80.332707 229.77556,80.039952 230.05072,79.751865 C 230.32588,79.463778 230.57684,79.177357 230.73381,78.946642 C 230.86872,78.748389 230.89834,78.606307 230.90704,78.582389 C 230.90704,78.582122 230.90706,78.579531 230.90704,78.579188 C 230.88599,78.563891 230.7799,78.463864 230.55405,78.374696 C 230.29125,78.270926 229.91799,78.176186 229.52451,78.090315 C 229.33943,78.049917 229.14933,78.008396 228.96234,77.968884 z " /> - <path - style="opacity:0.17000002;fill:#2e3436;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:14.80892944;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:4;stroke-opacity:1" - id="path4002" - d="M 231.78313,78.177387 C 231.91525,79.002442 229.55969,80.727822 229.28933,81.503669 C 229.01283,82.297195 229.84305,85.180849 229.14225,85.663932 C 228.44147,86.147014 225.9403,84.416861 225.08291,84.404993 C 224.22552,84.393115 221.67736,86.054398 220.99086,85.552103 C 220.95836,85.528318 220.93151,85.496512 220.90588,85.46264 C 220.94713,85.596396 221.0069,85.701395 221.09545,85.766178 C 221.78196,86.268482 224.3301,84.607199 225.18749,84.619077 C 226.04487,84.630955 228.54606,86.364299 229.24685,85.881216 C 229.94763,85.398134 229.11742,82.51447 229.39393,81.720953 C 229.67042,80.927437 232.12804,79.137998 231.87465,78.337147 C 231.85698,78.2813 231.82636,78.226957 231.78313,78.177387 z M 218.72912,78.576788 C 219.05144,79.39347 220.51888,80.648275 220.96144,81.385449 C 220.75766,80.755465 219.24105,79.479723 218.72912,78.576788 z " /> - <path - style="opacity:0.17000002;fill:#2e3436;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:14.80892944;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:4;stroke-opacity:1" - id="path4004" - d="M 231.86811,78.324364 C 231.93598,79.16144 229.63791,80.852843 229.37104,81.618707 C 229.09455,82.412224 229.92476,85.295888 229.22396,85.77897 C 228.52319,86.262053 226.02527,84.528709 225.16788,84.516821 C 224.31049,84.504953 221.75907,86.169427 221.07258,85.667123 C 220.96862,85.591062 220.90358,85.458925 220.8634,85.290087 C 220.8992,85.509467 220.97111,85.67842 221.09545,85.769378 C 221.78196,86.271673 224.3301,84.607199 225.18749,84.619077 C 226.04487,84.630955 228.54607,86.364299 229.24685,85.881216 C 229.94763,85.398134 229.11742,82.51447 229.39393,81.720953 C 229.67042,80.927437 232.12803,79.137998 231.87465,78.337147 C 231.87324,78.332689 231.86969,78.328774 231.86811,78.324364 z M 218.6703,78.362704 C 218.77934,79.236196 220.836,80.86857 221.0693,81.605915 C 221.07214,81.614897 221.07328,81.625194 221.07585,81.634682 C 221.06872,81.586692 221.05871,81.542475 221.04643,81.503669 C 220.822,80.794376 218.91261,79.25618 218.6703,78.362704 z " /> - <path - style="opacity:0.55327866;fill:url(#radialGradient4161);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" - id="path4006" - d="M 221.19604,81.681775 C 221.24271,82.758397 220.87876,84.313091 220.89785,84.876673 L 221.14834,84.899992 C 221.35416,83.877493 221.50237,82.836211 221.51807,81.75174 L 221.19604,81.681775 z " /> - <path - style="opacity:0.62000002;fill:#2e3436;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:14.80892944;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:4;stroke-opacity:1" - id="path4008" - d="M 218.66572,78.292416 C 218.6653,79.145895 220.83157,80.848385 221.07127,81.605915 C 221.09501,81.681004 221.10822,81.773077 221.11375,81.880714 C 221.10922,81.761208 221.09705,81.655485 221.07127,81.573976 C 220.83428,80.825001 218.71318,79.154972 218.66572,78.292416 z M 231.89294,78.46815 C 231.83063,79.327459 229.65511,80.945078 229.39588,81.689005 C 229.35912,81.794471 229.34089,81.9388 229.33705,82.107581 C 229.34219,81.951841 229.36132,81.820142 229.39588,81.720953 C 229.6583,80.967844 231.88334,79.318839 231.89294,78.46815 z M 225.18945,84.587119 C 224.33205,84.57525 221.78391,86.239725 221.0974,85.73743 C 220.94723,85.627554 220.87175,85.40362 220.84574,85.114352 C 220.8692,85.418775 220.94188,85.655587 221.0974,85.769378 C 221.78391,86.271673 224.33205,84.607199 225.18945,84.619077 C 226.04684,84.630955 228.54802,86.364299 229.2488,85.881216 C 229.42903,85.756976 229.50405,85.473385 229.52662,85.107951 C 229.50159,85.458658 229.424,85.728485 229.2488,85.849268 C 228.54802,86.33235 226.04684,84.599007 225.18945,84.587119 z " /> - </g> - <g - id="star"> - <path - style="fill:#e3ad00;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:14.80892944;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:4;stroke-opacity:1" - id="path4234" - d="M 207.1575,91.212212 C 205.83986,92.120519 201.13959,88.861956 199.52751,88.839627 C 197.91542,88.817298 193.12261,91.944371 191.83182,90.999936 C 190.54104,90.0555 192.25855,84.678293 191.78211,83.172493 C 191.30567,81.666693 186.78255,78.176713 187.30244,76.684713 C 187.82232,75.192713 193.58407,75.127978 194.9017,74.219671 C 196.21933,73.311365 198.21671,68.027365 199.82879,68.049694 C 201.44088,68.072023 203.28433,73.409222 204.57512,74.353658 C 205.8659,75.298094 211.62345,75.522382 212.09989,77.028182 C 212.57634,78.533982 207.95391,81.897288 207.43402,83.389288 C 206.91414,84.881288 208.47513,90.303905 207.1575,91.212212 z " /> - <path - style="fill:url(#linearGradient4138);fill-opacity:1;fill-rule:nonzero;stroke:url(#linearGradient4140);stroke-width:1.32276928;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:4;stroke-opacity:1" - id="path4236" - d="M 199.80343,69.854038 C 199.75704,69.88445 199.50748,70.007402 199.21851,70.344201 C 198.87602,70.743345 198.49005,71.3455 198.10435,71.983493 C 197.71865,72.621503 197.3323,73.301692 196.95678,73.889644 C 196.58126,74.477632 196.26162,74.968511 195.76463,75.311114 C 195.26765,75.653716 194.68017,75.783653 193.98757,75.931966 C 193.29498,76.080315 192.51463,76.20497 191.7704,76.345868 C 191.02618,76.486803 190.31463,76.643802 189.81506,76.82516 C 189.38574,76.980978 189.1866,77.167708 189.14657,77.195487 C 189.14679,77.195863 189.14633,77.200411 189.14657,77.200931 C 189.16048,77.238811 189.19466,77.511474 189.44181,77.898045 C 189.72428,78.339837 190.19379,78.888969 190.69525,79.444759 C 191.19671,80.00055 191.73228,80.564122 192.18822,81.094955 C 192.64417,81.625798 193.02794,82.079133 193.20766,82.647116 C 193.38737,83.215079 193.33309,83.798122 193.26337,84.487916 C 193.19365,85.177719 193.07774,85.941764 192.98483,86.67728 C 192.97886,86.724583 192.97297,86.771791 192.96721,86.818819 C 192.88351,87.503326 192.82496,88.156275 192.84555,88.643359 C 192.86482,89.098846 192.99074,89.344897 193.00154,89.384047 C 193.04269,89.38279 193.31785,89.429017 193.7703,89.318693 C 194.28737,89.192567 194.96315,88.932408 195.65879,88.63791 C 196.35441,88.343403 197.07381,88.015518 197.7311,87.755626 C 198.38842,87.495734 198.9447,87.278821 199.55275,87.28726 C 200.16082,87.295662 200.70818,87.526644 201.35766,87.804644 C 202.00718,88.082625 202.72089,88.433161 203.4077,88.746843 C 204.09453,89.060506 204.76073,89.336248 205.2739,89.476625 C 205.72297,89.599455 206.00115,89.561592 206.04269,89.563754 C 206.05447,89.524842 206.1885,89.283287 206.22095,88.828533 C 206.25804,88.308778 206.21452,87.600257 206.14295,86.862474 C 206.07139,86.124643 205.96982,85.353673 205.92011,84.662203 C 205.87041,83.970742 205.83544,83.389614 206.03153,82.826823 C 206.22763,82.264079 206.62442,81.819908 207.09556,81.301905 C 207.5667,80.783893 208.12129,80.236942 208.63866,79.695288 C 209.15603,79.153614 209.63036,78.615037 209.9255,78.181239 C 210.17915,77.808459 210.23224,77.540005 210.2486,77.495032 C 210.24886,77.494513 210.24836,77.489947 210.2486,77.489588 C 210.20903,77.460806 210.01033,77.270565 209.58568,77.102909 C 209.09154,76.907797 208.39248,76.730648 207.65263,76.569171 C 206.91279,76.407694 206.13464,76.257357 205.4466,76.089915 C 204.75861,75.922456 204.17311,75.781719 203.68626,75.425469 C 203.19939,75.069256 202.897,74.564031 202.53869,73.965906 C 202.18036,73.367781 201.81387,72.680947 201.44681,72.032513 C 201.07974,71.384078 200.70801,70.774473 200.37723,70.36598 C 200.08778,70.008566 199.83586,69.879811 199.80343,69.854038 z " /> - <path - style="opacity:0.38139535;fill:url(#radialGradient4135);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:4;stroke-opacity:1" - id="path4238" - d="M 187.45669,91.621132 C 187.45669,92.180425 192.94365,92.633822 199.71215,92.633822 C 206.48065,92.633822 211.9676,92.180425 211.9676,91.621132 C 211.9676,91.061839 206.48065,90.608442 199.71215,90.608442 C 192.94365,90.608442 187.45669,91.061839 187.45669,91.621132 L 187.45669,91.621132 z " /> - <path - style="fill:none;fill-opacity:1;fill-rule:evenodd;stroke:url(#linearGradient4132);stroke-width:0.09852729;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.5813008" - id="path4240" - d="M 197.92524,69.965618 C 198.17175,69.548224 199.09611,68.161965 199.84096,68.172622 C 201.19411,68.192574 203.47953,73.885632 204.54832,74.525989 C 205.86389,75.31423 210.6401,75.872469 211.50913,76.546336" /> - <path - style="fill:none;fill-opacity:1;fill-rule:evenodd;stroke:url(#linearGradient4129);stroke-width:0.1944391;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.43089432" - id="path4242" - d="M 197.91923,70.068512 C 198.16574,69.651117 199.09922,68.203284 199.84396,68.219672 C 201.1826,68.24908 203.43236,73.953619 204.53327,74.573021 C 205.87057,75.325477 210.6528,75.93048 211.52185,76.604347" /> - <path - style="fill:none;fill-opacity:1;fill-rule:evenodd;stroke:url(#linearGradient4126);stroke-width:0.3888782;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.43089432" - id="path4244" - d="M 197.91324,70.267904 C 198.15975,69.85051 199.13547,68.292351 199.84396,68.313484 C 201.07483,68.350595 203.46235,74.141263 204.51527,74.666852 C 205.88949,75.352844 210.86875,76.10641 211.58182,76.76269" /> - <path - style="opacity:0.70232556;fill:url(#radialGradient4123);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.89999998;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:4;stroke-opacity:1" - id="path4246" - d="M 210.48209,76.22168 C 210.38048,76.483802 210.6218,76.889452 211.021,77.127584 C 211.4202,77.365716 211.82601,77.346094 211.92727,77.083766 C 212.02887,76.821644 211.78755,76.415993 211.38835,76.177862 C 210.98916,75.93973 210.58334,75.959352 210.48209,76.22168 z " /> - <path - style="fill:url(#linearGradient4120);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:6.80299997;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:4;stroke-opacity:1" - id="path4248" - d="M 199.80243,69.853447 C 199.75602,69.883858 199.5076,70.009319 199.21863,70.346082 C 198.87612,70.745262 198.49201,71.34824 198.10631,71.986251 C 197.72063,72.624261 197.33266,73.302785 196.95715,73.890755 C 196.58163,74.478725 196.26195,74.966022 195.76495,75.308606 C 195.26794,75.651226 194.68156,75.785104 193.98894,75.933435 C 193.29636,76.081784 192.51471,76.207066 191.77049,76.347982 C 191.02627,76.488898 190.31586,76.641259 189.81629,76.822616 C 189.38695,76.978453 189.18644,77.167331 189.14644,77.195092 C 189.14642,77.195594 189.14646,77.200484 189.14644,77.201092 C 189.16032,77.238972 189.19426,77.511456 189.44141,77.898028 C 189.72388,78.339818 190.19358,78.886274 190.69507,79.442054 C 191.07311,79.861059 191.47001,80.287198 191.83809,80.697697 C 196.33651,81.160081 201.12383,82.790931 205.88631,83.575484 C 205.90205,83.316935 205.94871,83.068645 206.03379,82.824498 C 206.22988,82.261726 206.62579,81.822499 207.09694,81.304486 C 207.56807,80.786512 208.12204,80.236066 208.63941,79.694392 C 209.15678,79.152719 209.62864,78.614179 209.92377,78.180382 C 210.17743,77.807617 210.23311,77.54047 210.24947,77.495498 C 210.24947,77.494997 210.24951,77.490126 210.24947,77.489481 C 210.20991,77.460717 210.01042,77.272643 209.58579,77.104987 C 209.09165,76.909874 208.38986,76.731741 207.65001,76.570282 C 206.91017,76.408822 206.13185,76.257106 205.44383,76.089628 C 204.75582,75.922187 204.17313,75.779014 203.68628,75.422765 C 203.19941,75.066552 202.89543,74.566986 202.53709,73.968861 C 202.17878,73.370717 201.81643,72.682738 201.44938,72.034304 C 201.08232,71.385869 200.71089,70.772592 200.38009,70.364135 C 200.09063,70.006704 199.83486,69.879219 199.80243,69.853447 z " /> - <path - style="opacity:0.41393445;fill:url(#linearGradient4117);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:6.80299997;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:4;stroke-opacity:1" - id="path4250" - d="M 199.80243,69.853447 C 199.75602,69.883858 199.5076,70.009319 199.21863,70.346082 C 198.87612,70.745262 198.49201,71.34824 198.10631,71.986251 C 197.72063,72.624261 197.33266,73.302785 196.95715,73.890755 C 196.58163,74.478725 196.26195,74.966022 195.76495,75.308606 C 195.26794,75.651226 194.68156,75.785104 193.98894,75.933435 C 193.29636,76.081784 192.51471,76.207066 191.77049,76.347982 C 191.02627,76.488898 190.31586,76.641259 189.81629,76.822616 C 189.38695,76.978453 189.18644,77.167331 189.14644,77.195092 C 189.14642,77.195594 189.14646,77.200484 189.14644,77.201092 C 189.16032,77.238972 189.19426,77.511456 189.44141,77.898028 C 189.72388,78.339818 190.19358,78.886274 190.69507,79.442054 C 191.07311,79.861059 191.47001,80.287198 191.83809,80.697697 C 192.12128,80.726797 192.40688,80.761956 192.69229,80.799838 C 195.38101,78.786961 199.00035,76.203985 202.50023,73.908772 C 202.15414,73.325638 201.80363,72.6601 201.44938,72.034304 C 201.08232,71.385869 200.71089,70.772592 200.38009,70.364135 C 200.09063,70.006704 199.83486,69.879219 199.80243,69.853447 z M 206.59302,76.341964 C 204.12541,78.163579 201.96162,80.188686 200.08513,82.337844 C 202.00893,82.801323 203.9496,83.256458 205.88631,83.575484 C 205.90205,83.316935 205.94871,83.068645 206.03379,82.824498 C 206.22988,82.261726 206.62579,81.822499 207.09694,81.304486 C 207.56807,80.786512 208.12204,80.236066 208.63941,79.694392 C 209.15678,79.152719 209.62864,78.614179 209.92377,78.180382 C 210.17743,77.807617 210.23311,77.54047 210.24947,77.495498 C 210.24947,77.494997 210.24951,77.490126 210.24947,77.489481 C 210.20991,77.460717 210.01042,77.272643 209.58579,77.104987 C 209.09165,76.909874 208.38986,76.731741 207.65001,76.570282 C 207.30203,76.494325 206.94459,76.416255 206.59302,76.341964 z " /> - <path - style="opacity:0.34836067;fill:url(#linearGradient4114);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:6.80299997;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:4;stroke-opacity:1" - id="path4252" - d="M 199.80243,69.853447 C 199.75602,69.883858 199.5076,70.009319 199.21863,70.346082 C 198.87612,70.745262 198.49201,71.34824 198.10631,71.986251 C 197.72063,72.624261 197.33266,73.302785 196.95715,73.890755 C 196.58163,74.478725 196.26195,74.966022 195.76495,75.308606 C 195.26794,75.651226 194.68156,75.785104 193.98894,75.933435 C 193.29636,76.081784 192.51471,76.207066 191.77049,76.347982 C 191.02627,76.488898 190.31586,76.641259 189.81629,76.822616 C 189.38695,76.978453 189.18644,77.167331 189.14644,77.195092 C 189.14642,77.195594 189.14646,77.200484 189.14644,77.201092 C 189.16032,77.238972 189.19426,77.511456 189.44141,77.898028 C 189.72388,78.339818 199.00035,76.203985 202.50023,73.908772 C 202.15414,73.325638 201.80363,72.6601 201.44938,72.034304 C 201.08232,71.385869 200.71089,70.772592 200.38009,70.364135 C 200.09063,70.006704 199.83486,69.879219 199.80243,69.853447 z M 206.59302,76.341964 C 200.52174,80.875508 203.9496,83.256458 205.88631,83.575484 C 205.90205,83.316935 205.94871,83.068645 206.03379,82.824498 C 206.22988,82.261726 206.62579,81.822499 207.09694,81.304486 C 207.56807,80.786512 208.12204,80.236066 208.63941,79.694392 C 209.15678,79.152719 209.62864,78.614179 209.92377,78.180382 C 210.17743,77.807617 210.23311,77.54047 210.24947,77.495498 C 210.24947,77.494997 210.24951,77.490126 210.24947,77.489481 C 210.20991,77.460717 210.01042,77.272643 209.58579,77.104987 C 209.09165,76.909874 208.38986,76.731741 207.65001,76.570282 C 207.30203,76.494325 206.94459,76.416255 206.59302,76.341964 z " /> - <path - style="opacity:0.17000002;fill:#2e3436;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:14.80892944;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:4;stroke-opacity:1" - id="path4260" - d="M 211.89672,76.733997 C 212.14513,78.285295 207.71617,81.52942 207.20783,82.988193 C 206.68795,84.48021 208.24894,89.902164 206.93129,90.810481 C 205.61366,91.718789 200.9109,88.46569 199.29881,88.443372 C 197.68674,88.421044 192.89563,91.544644 191.60487,90.600217 C 191.54375,90.555495 191.49326,90.495694 191.44507,90.431997 C 191.52262,90.683497 191.63502,90.880922 191.80151,91.002723 C 193.0923,91.94718 197.88338,88.82357 199.49546,88.845907 C 201.10753,88.868235 205.8103,92.127334 207.12795,91.219027 C 208.44559,90.31071 206.8846,84.888746 207.40449,83.396739 C 207.92437,81.904741 212.54523,78.540176 212.06879,77.034385 C 212.03559,76.929378 211.978,76.827202 211.89672,76.733997 z M 187.35228,77.484968 C 187.95831,79.020525 190.71744,81.379852 191.54953,82.765917 C 191.16638,81.5814 188.31482,79.182696 187.35228,77.484968 z " /> - <path - style="opacity:0.17000002;fill:#2e3436;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:14.80892944;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:4;stroke-opacity:1" - id="path4262" - d="M 212.0565,77.01035 C 212.18411,78.584251 207.86324,81.764489 207.36146,83.204497 C 206.8416,84.696494 208.40257,90.118468 207.08492,91.026775 C 205.76731,91.935083 201.07067,88.675993 199.45859,88.653637 C 197.8465,88.631318 193.04927,91.760929 191.75851,90.816473 C 191.56304,90.673467 191.44076,90.425015 191.36521,90.107561 C 191.43252,90.52005 191.56773,90.837714 191.80151,91.008743 C 193.0923,91.953171 197.88338,88.82357 199.49546,88.845907 C 201.10753,88.868235 205.81034,92.127334 207.12795,91.219027 C 208.44559,90.31071 206.8846,84.888746 207.40449,83.396739 C 207.92437,81.904741 212.54522,78.540176 212.06879,77.034385 C 212.06616,77.026004 212.05947,77.018642 212.0565,77.01035 z M 187.24168,77.082438 C 187.44669,78.724808 191.31368,81.794056 191.75234,83.180445 C 191.75769,83.197333 191.75983,83.216689 191.76465,83.23453 C 191.75126,83.144305 191.73243,83.061158 191.70934,82.988193 C 191.28737,81.654556 187.69727,78.762386 187.24168,77.082438 z " /> - <path - style="opacity:0.55327866;fill:url(#radialGradient4109);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" - id="path4264" - d="M 191.99064,83.323079 C 192.0784,85.347386 191.39408,88.270581 191.42998,89.330247 L 191.90095,89.374093 C 192.28794,87.451546 192.56662,85.493687 192.59613,83.454625 L 191.99064,83.323079 z " /> - <path - style="opacity:0.62000002;fill:#2e3436;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:14.80892944;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:4;stroke-opacity:1" - id="path4266" - d="M 187.23307,76.95028 C 187.23228,78.555026 191.30535,81.756106 191.75604,83.180445 C 191.80068,83.321631 191.82553,83.494746 191.83591,83.697133 C 191.8274,83.472428 191.80451,83.273651 191.75604,83.120387 C 191.31045,81.712137 187.32231,78.572087 187.23307,76.95028 z M 212.10321,77.280702 C 211.98603,78.896409 207.89557,81.937918 207.40815,83.336672 C 207.33905,83.534972 207.30477,83.806352 207.29756,84.123692 C 207.30721,83.83087 207.34317,83.583237 207.40815,83.396739 C 207.90158,81.980716 212.08514,78.880196 212.10321,77.280702 z M 199.49915,88.785812 C 197.88704,88.763503 193.09597,91.893104 191.80517,90.948676 C 191.52283,90.742079 191.3809,90.321026 191.33199,89.777133 C 191.3761,90.349526 191.51277,90.794793 191.80517,91.008743 C 193.09597,91.953171 197.88704,88.82357 199.49915,88.845907 C 201.11123,88.868235 205.814,92.127334 207.13161,91.219027 C 207.4705,90.985425 207.61154,90.452201 207.65399,89.765103 C 207.60693,90.42451 207.46105,90.931854 207.13161,91.15895 C 205.814,92.067267 201.11123,88.808168 199.49915,88.785812 z " /> - </g> -</svg> diff --git a/amarok/src/context/applets/similarartists/ArtistWidget.cpp b/amarok/src/context/applets/similarartists/ArtistWidget.cpp deleted file mode 100644 index bcc41a5b..00000000 --- a/amarok/src/context/applets/similarartists/ArtistWidget.cpp +++ /dev/null @@ -1,707 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009-2010 Joffrey Clavel <jclavel@clabert.info> * - * Copyright (c) 2010 Alexandre Mendes <alex.mendes1988@gmail.com> * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see <http://www.gnu.org/licenses/>. * - ****************************************************************************************/ - -#define DEBUG_PREFIX "ArtistWidget" - -#include "ArtistWidget.h" - -//Amarok -#include "PaletteHandler.h" -#include "SvgHandler.h" -#include "amarokurls/AmarokUrl.h" -#include "core/collections/Collection.h" -#include "core/collections/QueryMaker.h" -#include "core/meta/Meta.h" -#include "core/support/Amarok.h" -#include "core/support/Debug.h" -#include "core-impl/collections/support/CollectionManager.h" -#include "playlist/PlaylistController.h" - -//KDE -#include <KColorUtils> -#include <KGlobalSettings> -#include <KIcon> -#include <Plasma/PushButton> -#include <Plasma/Separator> - -//Qt -#include <QDesktopServices> -#include <QtGui/qfontmetrics.h> -#include <QGraphicsGridLayout> -#include <QGraphicsLinearLayout> -#include <QLabel> -#include <QPainter> -#include <QPixmapCache> -#include <QSignalMapper> -#include <QTextDocument> -#include <QTimer> - -#include <cmath> - -ArtistWidget::ArtistWidget( const SimilarArtistPtr &artist, - QGraphicsWidget *parent, Qt::WindowFlags wFlags ) - : QGraphicsWidget( parent, wFlags ) - , m_artist( artist ) -{ - setAttribute( Qt::WA_NoSystemBackground, true ); - - m_image = new QLabel; - m_image->setAttribute( Qt::WA_NoSystemBackground, true ); - m_image->setFixedSize( 128, 128 ); - m_image->setCursor( Qt::PointingHandCursor ); - QGraphicsProxyWidget *imageProxy = new QGraphicsProxyWidget( this ); - imageProxy->setWidget( m_image ); - m_image->installEventFilter( this ); - - m_nameLabel = new QLabel; - m_match = new QLabel; - m_tagsLabel = new QLabel; - m_topTrackLabel = new QLabel; - m_bio = new QGraphicsWidget( this ); - - QGraphicsProxyWidget *nameProxy = new QGraphicsProxyWidget( this ); - QGraphicsProxyWidget *matchProxy = new QGraphicsProxyWidget( this ); - QGraphicsProxyWidget *topTrackProxy = new QGraphicsProxyWidget( this ); - QGraphicsProxyWidget *tagsProxy = new QGraphicsProxyWidget( this ); - nameProxy->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred ); - matchProxy->setSizePolicy( QSizePolicy::Maximum, QSizePolicy::Preferred ); - topTrackProxy->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred ); - tagsProxy->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred ); - imageProxy->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred ); - - nameProxy->setWidget( m_nameLabel ); - matchProxy->setWidget( m_match ); - topTrackProxy->setWidget( m_topTrackLabel ); - tagsProxy->setWidget( m_tagsLabel ); - - m_nameLabel->setAttribute( Qt::WA_NoSystemBackground ); - m_match->setAttribute( Qt::WA_NoSystemBackground ); - m_topTrackLabel->setAttribute( Qt::WA_NoSystemBackground ); - m_tagsLabel->setAttribute( Qt::WA_NoSystemBackground ); - - m_image->setAlignment( Qt::AlignCenter ); - m_match->setAlignment( Qt::AlignRight | Qt::AlignVCenter ); - m_nameLabel->setAlignment( Qt::AlignLeft | Qt::AlignVCenter ); - m_topTrackLabel->setAlignment( Qt::AlignLeft | Qt::AlignVCenter ); - m_tagsLabel->setAlignment( Qt::AlignLeft | Qt::AlignVCenter ); - - m_nameLabel->setWordWrap( false ); - m_match->setWordWrap( false ); - m_topTrackLabel->setWordWrap( false ); - m_tagsLabel->setWordWrap( false ); - - m_match->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred ); - m_topTrackLabel->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred ); - m_match->setMinimumWidth( 10 ); - m_topTrackLabel->setMinimumWidth( 10 ); - m_nameLabel->setMinimumWidth( 10 ); - m_tagsLabel->setMinimumWidth( 10 ); - - QFontMetricsF fm( font() ); - m_bio->setMinimumHeight( fm.lineSpacing() * 5 ); - m_bio->setMaximumHeight( fm.lineSpacing() * 5 ); - m_bio->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred ); - m_bioLayout.setCacheEnabled( true ); - - QFont artistFont; - artistFont.setPointSize( artistFont.pointSize() + 2 ); - artistFont.setBold( true ); - m_nameLabel->setFont( artistFont ); - m_topTrackLabel->setFont( KGlobalSettings::smallestReadableFont() ); - m_tagsLabel->setFont( KGlobalSettings::smallestReadableFont() ); - m_match->setFont( KGlobalSettings::smallestReadableFont() ); - - m_navigateButton = new Plasma::PushButton( this ); - m_navigateButton->setMaximumSize( QSizeF( 22, 22 ) ); - m_navigateButton->setIcon( KIcon( "edit-find" ) ); - m_navigateButton->setToolTip( i18n( "Show in Media Sources" ) ); - connect( m_navigateButton, SIGNAL(clicked()), this, SLOT(navigateToArtist()) ); - - m_lastfmStationButton = new Plasma::PushButton( this ); - m_lastfmStationButton->setMaximumSize( QSizeF( 22, 22 ) ); - m_lastfmStationButton->setIcon( KIcon("view-services-lastfm-amarok") ); - m_lastfmStationButton->setToolTip( i18n( "Add Last.fm artist station to the Playlist" ) ); - connect( m_lastfmStationButton, SIGNAL(clicked()), this, SLOT(addLastfmArtistStation()) ); - - m_topTrackButton = new Plasma::PushButton( this ); - m_topTrackButton->setMaximumSize( QSizeF( 22, 22 ) ); - m_topTrackButton->setIcon( KIcon( "media-track-add-amarok" ) ); - m_topTrackButton->setToolTip( i18n( "Add top track to the Playlist" ) ); - m_topTrackButton->hide(); - connect( m_topTrackButton, SIGNAL(clicked()), this, SLOT(addTopTrackToPlaylist()) ); - - m_similarArtistButton = new Plasma::PushButton( this ); - m_similarArtistButton->setMaximumSize( QSizeF( 22, 22 ) ); - m_similarArtistButton->setIcon( KIcon( "similarartists-amarok" ) ); - m_similarArtistButton->setToolTip( i18n( "Show Similar Artists to %1", m_artist->name() ) ); - connect( m_similarArtistButton, SIGNAL(clicked()), this, SIGNAL(showSimilarArtists()) ); - - QGraphicsLinearLayout *buttonsLayout = new QGraphicsLinearLayout( Qt::Horizontal ); - buttonsLayout->setSizePolicy( QSizePolicy::Maximum, QSizePolicy::Preferred ); - buttonsLayout->addItem( m_topTrackButton ); - buttonsLayout->addItem( m_navigateButton ); - buttonsLayout->addItem( m_lastfmStationButton ); - - QString artistUrl = m_artist->url().url(); - if( !artistUrl.isEmpty() ) - { - m_urlButton = new Plasma::PushButton( this ); - m_urlButton->setMaximumSize( QSizeF( 22, 22 ) ); - m_urlButton->setIcon( KIcon("applications-internet") ); - m_urlButton->setToolTip( i18n( "Open Last.fm webpage for this artist" ) ); - connect( m_urlButton, SIGNAL(clicked()), this, SLOT(openArtistUrl()) ); - buttonsLayout->addItem( m_urlButton ); - } - - buttonsLayout->addItem( m_similarArtistButton ); - - // the image display is extended on two row - m_layout = new QGraphicsGridLayout( this ); - m_layout->addItem( imageProxy, 0, 0, 4, 1 ); - m_layout->addItem( nameProxy, 0, 1 ); - m_layout->addItem( buttonsLayout, 0, 2, Qt::AlignRight ); - m_layout->addItem( topTrackProxy, 1, 1 ); - m_layout->addItem( matchProxy, 1, 2, Qt::AlignRight ); - m_layout->addItem( tagsProxy, 2, 1, 1, 2 ); - m_layout->addItem( m_bio, 3, 1, 1, 2 ); - - m_match->setText( i18n( "Match: %1%", QString::number( m_artist->match() ) ) ); - m_nameLabel->setText( m_artist->name() ); - - QTimer::singleShot( 0, this, SLOT(updateInfo()) ); -} - -void -ArtistWidget::updateInfo() -{ - fetchPhoto(); - fetchInfo(); - fetchTopTrack(); -} - -ArtistWidget::~ArtistWidget() -{ - clear(); -} - -bool -ArtistWidget::eventFilter( QObject *obj, QEvent *event ) -{ - if( obj == m_image ) - { - if( event->type() == QEvent::MouseButtonPress ) - { - emit showBio(); - event->accept(); - return true; - } - } - return QGraphicsWidget::eventFilter( obj, event ); -} - -void -ArtistWidget::fetchPhoto() -{ - // display a message for the user while the fetch of the picture - m_image->clear(); - - QPixmap image; - if( QPixmapCache::find( m_artist->urlImage().url(), &image ) ) - { - m_image->setPixmap( image ); - return; - } - m_image->setPixmap( Amarok::semiTransparentLogo( 120 ) ); - - if( m_artist->urlImage().isEmpty() ) - return; - - The::networkAccessManager()->getData( m_artist->urlImage(), this, - SLOT(photoFetched(KUrl,QByteArray,NetworkAccessManagerProxy::Error)) ); -} - -void -ArtistWidget::fetchInfo() -{ - // we genere the url for the demand on the lastFM Api - KUrl url; - url.setScheme( "http" ); - url.setHost( "ws.audioscrobbler.com" ); - url.setPath( "/2.0/" ); - url.addQueryItem( "method", "artist.getInfo" ); - url.addQueryItem( "api_key", Amarok::lastfmApiKey() ); - url.addQueryItem( "artist", m_artist->name() ); - - The::networkAccessManager()->getData( url, this, - SLOT(parseInfo(KUrl,QByteArray,NetworkAccessManagerProxy::Error)) ); -} - -void -ArtistWidget::fetchTopTrack() -{ - // we genere the url for the demand on the lastFM Api - KUrl url; - url.setScheme( "http" ); - url.setHost( "ws.audioscrobbler.com" ); - url.setPath( "/2.0/" ); - url.addQueryItem( "method", "artist.getTopTracks" ); - url.addQueryItem( "api_key", Amarok::lastfmApiKey() ); - url.addQueryItem( "artist", m_artist->name() ); - - The::networkAccessManager()->getData( url, this, - SLOT(parseTopTrack(KUrl,QByteArray,NetworkAccessManagerProxy::Error)) ); -} - -void -ArtistWidget::photoFetched( const KUrl &url, QByteArray data, NetworkAccessManagerProxy::Error e ) -{ - if( url != m_artist->urlImage() ) - return; - - if( e.code != QNetworkReply::NoError ) - { - m_image->clear(); - m_image->setText( i18n( "Unable to fetch the picture: %1", e.description ) ); - return; - } - - QPixmap image; - if( image.loadFromData( data ) ) - { - image = image.scaled( 116, 116, Qt::KeepAspectRatio, Qt::SmoothTransformation ); - image = The::svgHandler()->addBordersToPixmap( image, 6, QString(), true ); - m_image->setToolTip( i18nc( "@info:tooltip Artist biography", "Show Biography" ) ); - m_image->setPixmap( image ); - QPixmapCache::insert( url.url(), image ); - } -} - -void -ArtistWidget::parseInfo( const KUrl &url, QByteArray data, NetworkAccessManagerProxy::Error e ) -{ - Q_UNUSED( url ) - if( e.code != QNetworkReply::NoError ) - return; - - if( data.isEmpty() ) - return; - - QXmlStreamReader xml( data ); - xml.readNextStartElement(); // lfm - if( xml.attributes().value(QLatin1String("status")) != QLatin1String("ok") ) - { - setBioSummary( QString() ); - return; - } - - QString summary; - xml.readNextStartElement(); // artist - while( xml.readNextStartElement() ) - { - if( xml.name() == QLatin1String("tags") ) - { - m_tags.clear(); - while( xml.readNextStartElement() ) - { - if( xml.name() != QLatin1String("tag") ) - continue; - - while( xml.readNextStartElement() ) - { - if( xml.name() == QLatin1String("name") ) - m_tags << xml.readElementText(); - else - xml.skipCurrentElement(); - } - } - } - else if( xml.name() == QLatin1String("bio") ) - { - while( xml.readNextStartElement() ) - { - if( xml.name() == QLatin1String("published") ) - m_fullBio.first = KDateTime::fromString( xml.readElementText(), "%a, %d %b %Y %H:%M:%S" ); - else if( xml.name() == QLatin1String("summary") ) - summary = xml.readElementText().simplified(); - else if( xml.name() == QLatin1String("content") ) - m_fullBio.second = xml.readElementText().replace( QRegExp("\n+"), QLatin1String("<br>") ); - else - xml.skipCurrentElement(); - } - } - else - xml.skipCurrentElement(); - } - setBioSummary( summary ); - setTags(); -} - -void -ArtistWidget::parseTopTrack( const KUrl &url, QByteArray data, NetworkAccessManagerProxy::Error e ) -{ - Q_UNUSED( url ) - if( e.code != QNetworkReply::NoError ) - return; - - if( data.isEmpty() ) - return; - - QXmlStreamReader xml( data ); - xml.readNextStartElement(); // lfm - if( xml.attributes().value(QLatin1String("status")) != QLatin1String("ok") ) - { - setTopTrack( QString() ); - return; - } - - QString topTrack; - xml.readNextStartElement(); // toptracks - while( xml.readNextStartElement() ) - { - if( xml.name() != QLatin1String("track") ) - { - xml.skipCurrentElement(); - continue; - } - - while( xml.readNextStartElement() ) - { - if( xml.name() != QLatin1String("name") ) - { - xml.skipCurrentElement(); - continue; - } - topTrack = xml.readElementText(); - break; - } - - if( !topTrack.isEmpty() ) - break; - } - setTopTrack( topTrack ); -} - -SimilarArtistPtr -ArtistWidget::artist() const -{ - return m_artist; -} - -void -ArtistWidget::clear() -{ - m_image->clear(); - m_nameLabel->clear(); - m_match->clear(); - m_topTrackLabel->clear(); -} - -void -ArtistWidget::openArtistUrl() -{ - // somehow Last.fm decides to supply this url without the scheme - KUrl artistUrl = QString( "http://%1" ).arg( m_artist->url().url() ); - if( artistUrl.isValid() ) - QDesktopServices::openUrl( artistUrl ); -} - -void -ArtistWidget::setBioSummary( const QString &bio ) -{ - if( bio.isEmpty() ) - { - m_bioLayout.clearLayout(); - m_bioLayout.setText( i18n( "No description available." ) ); - } - else - { - QTextDocument doc; - doc.setHtml( bio ); - QString plain = doc.toPlainText(); - m_bioLayout.setText( plain ); - } - layoutBio(); -} - -void -ArtistWidget::setTags() -{ - QString tags = m_tags.isEmpty() ? i18n( "none" ) : m_tags.join( QLatin1String(", ") ); - QString label = i18nc( "@label:textbox", "Tags: %1", tags ); - m_tagsLabel->setText( label ); -} - -void -ArtistWidget::setTopTrack( const QString &topTrack ) -{ - if( topTrack.isEmpty() ) - { - m_topTrackLabel->setText( i18n("Top track not found") ); - m_topTrackButton->hide(); - } - else - { - m_topTrackTitle = topTrack; - m_topTrackLabel->setText( i18n("Top track: %1", topTrack) ); - - Collections::QueryMaker *qm = CollectionManager::instance()->queryMaker(); - - qm->setQueryType( Collections::QueryMaker::Track ); - qm->beginAnd(); - qm->addFilter( Meta::valArtist, m_nameLabel->text() ); - qm->addFilter( Meta::valTitle, m_topTrackTitle ); - qm->endAndOr(); - qm->limitMaxResultSize( 1 ); - qm->setAutoDelete( true ); - - connect( qm, SIGNAL(newResultReady(Meta::TrackList)), - SLOT(resultReady(Meta::TrackList)) ); - - qm->run(); - } -} - -void -ArtistWidget::resizeEvent( QGraphicsSceneResizeEvent *event ) -{ - QGraphicsWidget::resizeEvent( event ); - layoutBio(); - QFontMetrics fm( m_match->font() ); - m_match->setMaximumWidth( fm.width( m_match->text() ) ); -} - -void -ArtistWidget::paint( QPainter *p, const QStyleOptionGraphicsItem *option, QWidget *widget ) -{ - QGraphicsWidget::paint( p, option, widget ); - - p->save(); - QFontMetricsF fm( m_bio->font() ); - QPointF pos = m_bio->geometry().topLeft(); - const int maxLines = floor( m_bio->size().height() / fm.lineSpacing() ); - for( int i = 0, lines = m_bioLayout.lineCount(); i < lines; ++i ) - { - const QTextLine &line = m_bioLayout.lineAt( i ); - if( m_bioCropped && (i == (maxLines - 1)) ) - { - // fade out the last bit of text if not all of the bio is shown - QLinearGradient alphaGradient( 0, 0, 1, 0 ); - alphaGradient.setCoordinateMode( QGradient::ObjectBoundingMode ); - const QColor &textColor = The::paletteHandler()->palette().text().color(); - alphaGradient.setColorAt( 0, textColor ); - alphaGradient.setColorAt( 0.85, textColor ); - alphaGradient.setColorAt( 1, Qt::transparent ); - QPen pen = p->pen(); - pen.setBrush( alphaGradient ); - p->setPen( pen ); - } - line.draw( p, pos ); - pos.ry() += line.leading(); - } - p->restore(); -} - -void -ArtistWidget::layoutBio() -{ - QFontMetricsF fm( m_bio->font() ); - QRectF geom = m_bio->geometry(); - int maxLines = floor( m_bio->size().height() / fm.lineSpacing() ); - int leading = fm.leading(); - qreal height = 0; - m_bioCropped = true; - m_bioLayout.clearLayout(); - m_bioLayout.beginLayout(); - while( m_bioLayout.lineCount() < maxLines ) - { - QTextLine line = m_bioLayout.createLine(); - if( !line.isValid() ) - { - m_bioCropped = false; - break; - } - - line.setLineWidth( geom.width() ); - height += leading; - line.setPosition( QPointF(0, height) ); - height += line.height(); - } - m_bioLayout.endLayout(); - update(); -} - -KDateTime -ArtistWidget::bioPublished() const -{ - return m_fullBio.first; -} - -QString -ArtistWidget::fullBio() const -{ - return m_fullBio.second; -} - -void -ArtistWidget::addTopTrackToPlaylist() -{ - The::playlistController()->insertOptioned( m_topTrack, Playlist::OnAppendToPlaylistAction ); -} - -void -ArtistWidget::navigateToArtist() -{ - AmarokUrl url; - url.setCommand( "navigate" ); - url.setPath( "collections" ); - url.setArg( "filter", "artist:\"" + AmarokUrl::escape( m_artist->name() ) + '\"' ); - url.run(); -} - -void -ArtistWidget::addLastfmArtistStation() -{ - const QString url = "lastfm://artist/" + m_artist->name() + "/similarartists"; - Meta::TrackPtr lastfmtrack = CollectionManager::instance()->trackForUrl( KUrl( url ) ); - The::playlistController()->insertOptioned( lastfmtrack, Playlist::OnAppendToPlaylistAction ); -} - -ArtistsListWidget::ArtistsListWidget( QGraphicsWidget *parent ) - : Plasma::ScrollWidget( parent ) - , m_separatorCount( 0 ) -{ - QGraphicsWidget *content = new QGraphicsWidget( this ); - m_layout = new QGraphicsLinearLayout( Qt::Vertical, content ); - setWidget( content ); - - m_showArtistsSigMapper = new QSignalMapper( this ); - connect( m_showArtistsSigMapper, SIGNAL(mapped(QString)), SIGNAL(showSimilarArtists(QString)) ); - - m_showBioSigMapper = new QSignalMapper( this ); - connect( m_showBioSigMapper, SIGNAL(mapped(QString)), SIGNAL(showBio(QString)) ); -} - -ArtistsListWidget::~ArtistsListWidget() -{ - clear(); -} - -int -ArtistsListWidget::count() const -{ - return m_layout->count() - m_separatorCount; -} - -void -ArtistsListWidget::addArtist( const SimilarArtistPtr &artist ) -{ - if( !m_widgets.isEmpty() ) - addSeparator(); - ArtistWidget *widget = new ArtistWidget( artist ); - const QString &name = artist->name(); - connect( widget, SIGNAL(showSimilarArtists()), m_showArtistsSigMapper, SLOT(map()) ); - m_showArtistsSigMapper->setMapping( widget, name ); - connect( widget, SIGNAL(showBio()), m_showBioSigMapper, SLOT(map()) ); - m_showBioSigMapper->setMapping( widget, name ); - m_layout->addItem( widget ); - m_widgets << widget; -} - -void -ArtistsListWidget::addArtists( const SimilarArtist::List &artists ) -{ - foreach( const SimilarArtistPtr &artist, artists ) - addArtist( artist ); - updateGeometry(); -} - -void -ArtistsListWidget::addSeparator() -{ - m_layout->addItem( new Plasma::Separator ); - ++m_separatorCount; -} - -void -ArtistsListWidget::clear() -{ - qDeleteAll( m_widgets ); - m_widgets.clear(); - int count = m_layout->count(); - if( count > 0 ) - { - while( --count >= 0 ) - { - QGraphicsLayoutItem *child = m_layout->itemAt( 0 ); - m_layout->removeItem( child ); - delete child; - } - m_separatorCount = 0; - } - m_layout->invalidate(); - updateGeometry(); -} - -QSizeF -ArtistsListWidget::sizeHint( Qt::SizeHint which, const QSizeF &constraint ) const -{ - QSizeF sz = Plasma::ScrollWidget::sizeHint( which, constraint ); - if( count() == 0 ) - sz.rheight() = 0; - return sz; -} - -bool -ArtistsListWidget::isEmpty() const -{ - return count() == 0; -} - -QString -ArtistsListWidget::name() const -{ - return m_name; -} - -void -ArtistsListWidget::setName( const QString &name ) -{ - m_name = name; -} - -ArtistWidget * -ArtistsListWidget::widget( const QString &artistName ) -{ - foreach( ArtistWidget *widget, m_widgets ) - { - if( widget->artist()->name() == artistName ) - return widget; - } - return 0; -} - -void -ArtistWidget::resultReady( const Meta::TrackList &tracks ) -{ - if( !tracks.isEmpty() ) - { - m_topTrack = tracks.first(); - m_topTrackButton->show(); - } -} - -#include "moc_ArtistWidget.cpp" diff --git a/amarok/src/context/applets/similarartists/ArtistWidget.h b/amarok/src/context/applets/similarartists/ArtistWidget.h deleted file mode 100644 index c819d06d..00000000 --- a/amarok/src/context/applets/similarartists/ArtistWidget.h +++ /dev/null @@ -1,309 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009-2010 Joffrey Clavel <jclavel@clabert.info> * - * Copyright (c) 2010 Alexandre Mendes <alex.mendes1988@gmail.com> * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see <http://www.gnu.org/licenses/>. * - ****************************************************************************************/ - -#ifndef ARTIST_WIDGET_H -#define ARTIST_WIDGET_H - -#include "core/meta/forward_declarations.h" -#include "network/NetworkAccessManagerProxy.h" -#include "SimilarArtist.h" - -#include <KUrl> -#include <KDateTime> -#include <Plasma/ScrollWidget> - -#include <QTextLayout> - -class QGraphicsGridLayout; -class QGraphicsLinearLayout; -class QSignalMapper; -class QLabel; - -namespace Plasma { - class PushButton; -} - -/** - * A widget for display an artist with some details - * @author Joffrey Clavel - * @version 0.2 - */ -class ArtistWidget : public QGraphicsWidget -{ - Q_OBJECT - Q_PROPERTY( KDateTime bioPublished READ bioPublished ) - Q_PROPERTY( QString fullBio READ fullBio ) - -public: - /** - * ArtistWidget constructor - * @param parent The widget parent - */ - ArtistWidget( const SimilarArtistPtr &artist, - QGraphicsWidget *parent = 0, Qt::WindowFlags wFlags = 0 ); - - /** - * ArtistWidget destructor - */ - ~ArtistWidget(); - - virtual void paint( QPainter *p, const QStyleOptionGraphicsItem *option, QWidget *widget = 0 ); - - /** - * Pointer to the similar artist this widget is associated with - */ - SimilarArtistPtr artist() const; - - /** - * Clean the widget => the content of the QLabel is empty - */ - void clear(); - - /** - * The date/time the bio was published - * @return date/time - */ - KDateTime bioPublished() const; - - /** - * Complete bio of artist on last.fm - * @return bio of artist - */ - QString fullBio() const; - - /** - * Change the most known track of this artist - * @param topTrack the top track of this artist - */ - void setTopTrack( const QString &topTrack ); - - bool eventFilter( QObject *obj, QEvent *event ); - -signals: - /** - * Show similar artists to the artist associated with this widget - */ - void showSimilarArtists(); - - /** - * Show full bio of artist - */ - void showBio(); - -protected: - void resizeEvent( QGraphicsSceneResizeEvent *event ); - -private: - void fetchPhoto(); //!< Fetch the photo of the artist - void fetchInfo(); //!< Fetch the artist info - void fetchTopTrack(); //!< Fetch the artist'stop track - - /** - * Set the artist bio summary - * @param bio The bio of this artist - */ - void setBioSummary( const QString &bio ); - - /** - * Set arist tags - */ - void setTags(); - - /** - * Layout the text for artist's bio summary - */ - void layoutBio(); - - /** - * Layout for the formatting of the widget contents - */ - QGraphicsGridLayout *m_layout; - - /** - * Image of the artist - */ - QLabel *m_image; - - /** - * Label showing the name of the artist - */ - QLabel *m_nameLabel; - - /** - * Similarity match percentage - */ - QLabel *m_match; - - /** - * Title of the top track - */ - QString m_topTrackTitle; - - /** - * Label showing the title of the top track of the artist - */ - QLabel *m_topTrackLabel; - - /** - * Label showing artist tags - */ - QLabel *m_tagsLabel; - - /** - * Meta::LabelPtr to the top track, if it's in a collection - */ - Meta::TrackPtr m_topTrack; - - /** - * Button to add the top track to the playlist - */ - Plasma::PushButton *m_topTrackButton; - - /** - * Button to add the last.fm simmilar artist station for this artist to the playlist - */ - Plasma::PushButton *m_lastfmStationButton; - - /** - * Button to navigate to the artit in the local collection - */ - Plasma::PushButton *m_navigateButton; - - /** - * Button to open Last.fm's artist webpage using external browser - */ - Plasma::PushButton *m_urlButton; - - /** - * Button to show similar artists to the artist associated with this widget - */ - Plasma::PushButton *m_similarArtistButton; - - /** - * Bio summary of the artist - */ - QGraphicsWidget *m_bio; - - /** - * Text layout for the artist bio - */ - QTextLayout m_bioLayout; - - /** - * Whether all of artist bio is shown - */ - bool m_bioCropped; - - /** - * The complete bio with its published date - */ - QPair<KDateTime, QString> m_fullBio; - - /** - * List of artist tags - */ - QStringList m_tags; - - const SimilarArtistPtr m_artist; - -private slots: - /** - * Handle artist photo retrieved from Last.fm - */ - void photoFetched( const KUrl &url, QByteArray data, NetworkAccessManagerProxy::Error e ); - - /** - * Parse the xml fetched on the lastFM API for the artist info. - * Launched when the download of the data are finished and for each similarArtists. - */ - void parseInfo( const KUrl &url, QByteArray data, NetworkAccessManagerProxy::Error e ); - - /** - * Parse the xml fetched on the lastFM API for the similarArtist most known track. - * Launched when the download of the data are finished and for each similarArtists. - */ - void parseTopTrack( const KUrl &url, QByteArray data, NetworkAccessManagerProxy::Error e ); - - /** - * Open an URL - * @param url The URL of the artist - */ - void openArtistUrl(); - - /** - * Add top track to the playlist - */ - void addTopTrackToPlaylist(); - - /** - * Navigate to this artist in the local collection - */ - void navigateToArtist(); - - /** - * Add this artists last.fm similar artist stream - */ - void addLastfmArtistStation(); - - /** - * Get results from the query maker - */ - void resultReady( const Meta::TrackList &tracks ); - - void updateInfo(); -}; - -class ArtistsListWidget : public Plasma::ScrollWidget -{ - Q_OBJECT - Q_PROPERTY( QString name READ name WRITE setName ) - -public: - explicit ArtistsListWidget( QGraphicsWidget *parent = 0 ); - ~ArtistsListWidget(); - - int count() const; - bool isEmpty() const; - - void addArtists( const SimilarArtist::List &artists ); - - QString name() const; - void setName( const QString &name ); - - void clear(); - - ArtistWidget *widget( const QString &artistName ); - - QSizeF sizeHint( Qt::SizeHint which, const QSizeF &constraint = QSizeF() ) const; - -signals: - void showSimilarArtists( const QString &artist ); - void showBio( const QString &artist ); - -private: - void addArtist( const SimilarArtistPtr &artist ); - void addSeparator(); - int m_separatorCount; - QString m_name; - QGraphicsLinearLayout *m_layout; - QSignalMapper *m_showArtistsSigMapper; - QSignalMapper *m_showBioSigMapper; - QList<ArtistWidget*> m_widgets; - Q_DISABLE_COPY( ArtistsListWidget ) -}; - -#endif // ARTIST_WIDGET_H diff --git a/amarok/src/context/applets/similarartists/CMakeLists.txt b/amarok/src/context/applets/similarartists/CMakeLists.txt deleted file mode 100644 index 679274b3..00000000 --- a/amarok/src/context/applets/similarartists/CMakeLists.txt +++ /dev/null @@ -1,25 +0,0 @@ -# project(context-similarartists) - -include_directories( - ../.. - ../../.. - ${CMAKE_SOURCE_DIR}/src - ) - -set(similarArtists_SRCS - SimilarArtist.cpp - ArtistWidget.cpp - SimilarArtistsApplet.cpp - similarArtistsSettings.ui -) - -kde4_add_plugin(amarok_context_applet_similarArtists ${similarArtists_SRCS}) -target_link_libraries(amarok_context_applet_similarArtists - amarokcore - amaroklib - ${KDE4_PLASMA_LIBS} - ${KDE4_KDEUI_LIBS} -) - -install(TARGETS amarok_context_applet_similarArtists DESTINATION ${PLUGIN_INSTALL_DIR}) -install(FILES amarok-context-applet-similarArtists.desktop DESTINATION ${SERVICES_INSTALL_DIR}) diff --git a/amarok/src/context/applets/similarartists/SimilarArtist.cpp b/amarok/src/context/applets/similarartists/SimilarArtist.cpp deleted file mode 100644 index 4ff4a8aa..00000000 --- a/amarok/src/context/applets/similarartists/SimilarArtist.cpp +++ /dev/null @@ -1,131 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009-2010 Joffrey Clavel <jclavel@clabert.info> * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see <http://www.gnu.org/licenses/>. * - ****************************************************************************************/ - -#include "SimilarArtist.h" - -#include <QtCore/qxmlstream.h> - -SimilarArtist::SimilarArtist() {} - -SimilarArtist::SimilarArtist( const QString &name, const int match, const KUrl &url, - const KUrl &urlImage, const QString &similarTo ) - : m_name( name ) - , m_match( match ) - , m_url( url ) - , m_urlImage( urlImage ) - , m_similarTo( similarTo ) -{ - - static bool metaTypeRegistered = false; - if ( !metaTypeRegistered ) - { - qRegisterMetaType<SimilarArtist>( "SimilarArtists" ); - metaTypeRegistered = true; - } -} - -SimilarArtist::SimilarArtist( const SimilarArtist &other ) - : QSharedData( other ) - , m_name( other.m_name ) - , m_match( other.m_match ) - , m_url( other.m_url ) - , m_urlImage( other.m_urlImage ) - , m_similarTo( other.m_similarTo ) -{ -} - -QString -SimilarArtist::name() const -{ - return m_name; -} - -int -SimilarArtist::match() const -{ - return m_match; -} - -KUrl -SimilarArtist::url() const -{ - return m_url; -} - -KUrl -SimilarArtist::urlImage() const -{ - return m_urlImage; -} - -QString -SimilarArtist::similarTo() const -{ - return m_similarTo; -} - -void -SimilarArtist::setSimilarTo( const QString &artist ) -{ - m_similarTo = artist; -} - -SimilarArtist::List -SimilarArtist::listFromXml( QXmlStreamReader &xml ) -{ - SimilarArtist::List saList; - xml.readNextStartElement(); // lfm - if( xml.attributes().value(QLatin1String("status")) != QLatin1String("ok") ) - return saList; - - QString similarTo; - xml.readNextStartElement(); // similarartists - if( xml.attributes().hasAttribute(QLatin1String("artist")) ) - similarTo = xml.attributes().value(QLatin1String("artist")).toString(); - - while( xml.readNextStartElement() ) - { - if( xml.name() == QLatin1String("artist") ) - { - QString name; - KUrl artistUrl; - KUrl imageUrl; - float match( 0.0 ); - while( xml.readNextStartElement() ) - { - const QStringRef &n = xml.name(); - const QXmlStreamAttributes &a = xml.attributes(); - if( n == QLatin1String("name") ) - name = xml.readElementText(); - else if( n == QLatin1String("match") ) - match = xml.readElementText().toFloat() * 100.0; - else if( n == QLatin1String("url") ) - artistUrl = KUrl( xml.readElementText() ); - else if( n == QLatin1String("image") - && a.hasAttribute(QLatin1String("size")) - && a.value(QLatin1String("size")) == QLatin1String("large") ) - imageUrl = KUrl( xml.readElementText() ); - else - xml.skipCurrentElement(); - } - SimilarArtistPtr artist( new SimilarArtist( name, match, artistUrl, imageUrl, similarTo ) ); - saList.append( artist ); - } - else - xml.skipCurrentElement(); - } - return saList; -} diff --git a/amarok/src/context/applets/similarartists/SimilarArtist.h b/amarok/src/context/applets/similarartists/SimilarArtist.h deleted file mode 100644 index 47b36899..00000000 --- a/amarok/src/context/applets/similarartists/SimilarArtist.h +++ /dev/null @@ -1,125 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009-2010 Joffrey Clavel <jclavel@clabert.info> * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see <http://www.gnu.org/licenses/>. * - ****************************************************************************************/ - -#ifndef SIMILAR_ARTIST_H -#define SIMILAR_ARTIST_H - -//Kde -#include <KSharedPtr> -#include <KUrl> - -//Qt -#include <QSharedData> -#include <QString> -#include <QtCore/qxmlstream.h> - -class SimilarArtist; -typedef KSharedPtr<SimilarArtist> SimilarArtistPtr; - -/** - * Represents a similar artist to another - * @author Joffrey Clavel - * @version 0.1 - */ -class SimilarArtist : public QSharedData -{ -public: - typedef QList<SimilarArtistPtr> List; - - /** - * Create an empty similar artist - */ - SimilarArtist(); - - /** - * Create a similar artist with data - * @param name The name of this similar artist - * @param match The match pourcent (between 0 and 100) of the similarity - * between this artist and the artist similarTo - * @param url A url of this artist on the web, for example on last.fm - * @param urlImage A url of an image of this artist, for example on last.fm - * @param similarTo The name of the artist similar to this artist - */ - SimilarArtist( const QString &name, const int match, const KUrl &url, - const KUrl &urlImage, const QString &similarTo ); - - SimilarArtist( const SimilarArtist &other ); - - /** - * @return The name of this artist - */ - QString name() const; - - /** - * @return the pourcent of match of this artist, betwwen 0 and 100 - */ - int match() const; - - /** - * @return a url on the web for this artist, for example on last.fm - */ - KUrl url() const; - - /** - * @return a url on the web for an image oh this artist, for example on last.fm - */ - KUrl urlImage() const; - - /** - * @return the artist this similar artist is related to - */ - QString similarTo() const; - - /** - * Set the artist this similar artist is related to - * @param artist artist name - */ - void setSimilarTo( const QString &artist ); - - static SimilarArtist::List listFromXml( QXmlStreamReader &xml ); - -private: - /** - * The name of this artist - */ - QString m_name; - - /** - * The match of this artist to the artist similarTo, between 0 and 100 - */ - int m_match; - - /** - * A url of this artist on the web - */ - KUrl m_url; - - /** - * A image url of this artist on the web - */ - KUrl m_urlImage; - - /** - * The name of the artist similar to this artist - */ - QString m_similarTo; -}; - -Q_DECLARE_METATYPE( SimilarArtist ) -Q_DECLARE_METATYPE( SimilarArtistPtr ) -Q_DECLARE_METATYPE( SimilarArtist::List ) - -#endif // SIMILAR_ARTIST_H diff --git a/amarok/src/context/applets/similarartists/SimilarArtistsApplet.cpp b/amarok/src/context/applets/similarartists/SimilarArtistsApplet.cpp deleted file mode 100644 index 7d3c083b..00000000 --- a/amarok/src/context/applets/similarartists/SimilarArtistsApplet.cpp +++ /dev/null @@ -1,315 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009-2010 Joffrey Clavel <jclavel@clabert.info> * - * Copyright (c) 2009 Oleksandr Khayrullin <saniokh@gmail.com> * - * Copyright (c) 2010 Alexandre Mendes <alex.mendes1988@gmail.com> * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see <http://www.gnu.org/licenses/>. * - ****************************************************************************************/ - -#define DEBUG_PREFIX "SimilarArtistsApplet" - -#include "SimilarArtistsApplet.h" - -#include "App.h" -#include "EngineController.h" -#include "PaletteHandler.h" -#include "context/Svg.h" -#include "context/ContextView.h" -#include "context/widgets/AppletHeader.h" -#include "core/support/Amarok.h" -#include "core/support/Debug.h" -#include "core/meta/Meta.h" - -#include <KConfigDialog> -#include <KStandardDirs> -#include <KTextBrowser> -#include <Plasma/TextBrowser> -#include <Plasma/Theme> -#include <plasma/widgets/iconwidget.h> - -#include <QDesktopServices> -#include <QTextEdit> -#include <QGraphicsLinearLayout> -#include <QGraphicsProxyWidget> -#include <QScrollArea> -#include <QVBoxLayout> -#include <QScrollBar> - -SimilarArtistsApplet::SimilarArtistsApplet( QObject *parent, const QVariantList& args ) - : Context::Applet( parent, args ) - , m_scroll( 0 ) - , m_settingsIcon( 0 ) -{ - setHasConfigurationInterface( true ); -} - -SimilarArtistsApplet::~SimilarArtistsApplet() -{ -} - -void -SimilarArtistsApplet::init() -{ - DEBUG_BLOCK - - // Call the base implementation. - Context::Applet::init(); - - enableHeader( true ); - setHeaderText( i18n( "Similar Artists" ) ); - - QAction* backwardAction = new QAction( this ); - backwardAction->setIcon( KIcon( "go-previous" ) ); - backwardAction->setEnabled( false ); - backwardAction->setText( i18n( "Back" ) ); - m_backwardIcon = addLeftHeaderAction( backwardAction ); - connect( m_backwardIcon, SIGNAL(clicked()), this, SLOT(goBackward()) ); - - QAction* forwardAction = new QAction( this ); - forwardAction->setIcon( KIcon( "go-next" ) ); - forwardAction->setEnabled( false ); - forwardAction->setText( i18n( "Forward" ) ); - m_forwardIcon = addLeftHeaderAction( forwardAction ); - connect( m_forwardIcon, SIGNAL(clicked()), this, SLOT(goForward()) ); - - QAction *currentAction = new QAction( this ); - currentAction->setIcon( KIcon( "filename-artist-amarok" ) ); - currentAction->setEnabled( true ); - currentAction->setText( i18n( "Show Similar Artists for Currently Playing Track" ) ); - m_currentArtistIcon = addRightHeaderAction( currentAction ); - connect( m_currentArtistIcon, SIGNAL(clicked()), this, SLOT(queryForCurrentTrack()) ); - - QAction* settingsAction = new QAction( this ); - settingsAction->setIcon( KIcon( "preferences-system" ) ); - settingsAction->setEnabled( true ); - settingsAction->setText( i18n( "Settings" ) ); - m_settingsIcon = addRightHeaderAction( settingsAction ); - connect( m_settingsIcon, SIGNAL(clicked()), this, SLOT(configure()) ); - - setCollapseOffHeight( -1 ); - setCollapseHeight( m_header->height() ); - setMinimumHeight( collapseHeight() ); - setPreferredHeight( collapseHeight() ); - - // create a scrollarea - m_scroll = new ArtistsListWidget( this ); - m_scroll->hide(); - connect( m_scroll, SIGNAL(showSimilarArtists(QString)), SLOT(showSimilarArtists(QString)) ); - connect( m_scroll, SIGNAL(showBio(QString)), SLOT(showArtistBio(QString)) ); - - m_layout = new QGraphicsLinearLayout( Qt::Vertical, this ); - m_layout->addItem( m_header ); - m_layout->addItem( m_scroll ); - setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); - - // Read config and inform the engine. - KConfigGroup config = Amarok::config( "SimilarArtists Applet" ); - m_maxArtists = config.readEntry( "maxArtists", "5" ).toInt(); - - Plasma::DataEngine *engine = dataEngine( "amarok-similarArtists" ); - connect( engine, SIGNAL(sourceAdded(QString)), SLOT(connectSource(QString)) ); - engine->setProperty( "maximumArtists", m_maxArtists ); - engine->query( "similarArtists" ); -} - -void -SimilarArtistsApplet::connectSource( const QString &source ) -{ - if( source == QLatin1String("similarArtists") ) - dataEngine( "amarok-similarArtists" )->connectSource( source, this ); -} - -void -SimilarArtistsApplet::dataUpdated( const QString &source, const Plasma::DataEngine::Data &data ) -{ - DEBUG_BLOCK - QString artist = data[ "artist" ].toString(); - if( source == "similarArtists" ) - { - setBusy( false ); - if( !artist.isEmpty() ) - { - m_artist = artist; - SimilarArtist::List list = data[ "similar" ].value<SimilarArtist::List>(); - if( m_similars != list ) - { - m_similars = list; - updateNavigationIcons(); - artistsUpdate(); - } - } - else - { - setHeaderText( i18n( "Similar Artists" ) ); - m_scroll->clear(); - m_scroll->hide(); - setCollapseOn(); - } - } -} - -void -SimilarArtistsApplet::configure() -{ - showConfigurationInterface(); -} - -void -SimilarArtistsApplet::createConfigurationInterface( KConfigDialog *parent ) -{ - parent->setButtons( KDialog::Ok | KDialog::Cancel ); - - KConfigGroup config = Amarok::config( "SimilarArtists Applet" ); - QWidget *settings = new QWidget(); - ui_Settings.setupUi( settings ); - - ui_Settings.spinBox->setValue( m_maxArtists ); - - parent->addPage( settings, i18n( "Similar Artists Settings" ), "preferences-system" ); - - connect( parent, SIGNAL(okClicked()), SLOT(saveSettings()) ); -} - -void -SimilarArtistsApplet::saveSettings() -{ - DEBUG_BLOCK - m_maxArtists = ui_Settings.spinBox->value(); - Amarok::config( "SimilarArtists Applet" ).writeEntry( "maxArtists", m_maxArtists ); - dataEngine( "amarok-similarArtists" )->setProperty( "maximumArtists", m_maxArtists ); - dataEngine( "amarok-similarArtists" )->query( "similarArtists:forceUpdate" ); -} - -void -SimilarArtistsApplet::artistsUpdate() -{ - DEBUG_BLOCK - if( !m_scroll->isEmpty() ) - m_scroll->clear(); - - if( !m_similars.isEmpty() ) - { - setHeaderText( i18n( "Similar Artists to %1", m_artist ) ); - m_scroll->addArtists( m_similars ); - m_scroll->show(); - setCollapseOff(); - } - else // No similar artist found - { - setHeaderText( i18n( "Similar Artists: Not Found" ) ); - m_scroll->hide(); - setCollapseOn(); - } -} - -void -SimilarArtistsApplet::showSimilarArtists( const QString &name ) -{ - if( m_artist != name ) - m_historyBack.push( m_artist ); - m_historyForward.clear(); - queryArtist( name ); - updateNavigationIcons(); - setBusy( true ); -} - -void -SimilarArtistsApplet::showArtistBio( const QString &name ) -{ - const ArtistWidget *widget = m_scroll->widget( name ); - if( !widget || widget->fullBio().isEmpty() ) - return; - - Plasma::TextBrowser *tb = new Plasma::TextBrowser( 0 ); - tb->nativeWidget()->setFrameShape( QFrame::StyledPanel ); - tb->nativeWidget()->setOpenExternalLinks( true ); - tb->nativeWidget()->setAutoFormatting( QTextEdit::AutoAll ); - tb->nativeWidget()->viewport()->setAutoFillBackground( true ); - tb->nativeWidget()->viewport()->setBackgroundRole( QPalette::AlternateBase ); - - QPalette p = tb->palette(); - p.setColor( QPalette::Text, qApp->palette().text().color() ); - tb->setPalette( p ); - - QString bio = widget->fullBio(); - KDateTime pub = widget->bioPublished(); - if( pub.isValid() ) - { - QString pubDate = i18nc( "@item:intext Artist biography published date", - "Published: %1", pub.toString( KDateTime::LocalDate ) ); - bio = QString( "%1<hr>%2" ).arg( pubDate, bio ); - } - tb->nativeWidget()->setHtml( bio ); - - QGraphicsLinearLayout *l = new QGraphicsLinearLayout( Qt::Vertical ); - l->setContentsMargins( 1, 1, 1, 1 ); - l->addItem( tb ); - qreal width = m_scroll->boundingRect().width() * 3 / 5; - qreal height = m_scroll->boundingRect().height() * 3 / 5; - QRectF rect( 0, 0, width, height ); - rect.moveCenter( m_scroll->boundingRect().center() ); - QGraphicsWidget *w = new QGraphicsWidget( 0, Qt::Window ); - w->setGeometry( rect ); - w->setLayout( l ); - scene()->addItem( w ); -} - -void -SimilarArtistsApplet::queryArtist( const QString &name ) -{ - dataEngine( "amarok-similarArtists" )->setProperty( "artist", name ); - dataEngine( "amarok-similarArtists" )->query( "similarArtists:artist" ); -} - -void -SimilarArtistsApplet::queryForCurrentTrack() -{ - Meta::TrackPtr track = The::engineController()->currentTrack(); - if( !track ) - return; - if( Meta::ArtistPtr artist = track->artist() ) - queryArtist( artist->name() ); -} - -void -SimilarArtistsApplet::goBackward() -{ - if( !m_historyBack.isEmpty() ) - { - m_historyForward.push( m_artist ); - m_artist = m_historyBack.pop(); - queryArtist( m_artist ); - updateNavigationIcons(); - } -} - -void -SimilarArtistsApplet::goForward() -{ - if( !m_historyForward.isEmpty() ) - { - m_historyBack.push( m_artist ); - m_artist = m_historyForward.pop(); - queryArtist( m_artist ); - updateNavigationIcons(); - } -} - -void -SimilarArtistsApplet::updateNavigationIcons() -{ - m_forwardIcon->action()->setEnabled( !m_historyForward.isEmpty() ); - m_backwardIcon->action()->setEnabled( !m_historyBack.isEmpty() ); -} - -#include "moc_SimilarArtistsApplet.cpp" diff --git a/amarok/src/context/applets/similarartists/SimilarArtistsApplet.h b/amarok/src/context/applets/similarartists/SimilarArtistsApplet.h deleted file mode 100644 index c3b8433a..00000000 --- a/amarok/src/context/applets/similarartists/SimilarArtistsApplet.h +++ /dev/null @@ -1,141 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009-2010 Joffrey Clavel <jclavel@clabert.info> * - * Copyright (c) 2009 Oleksandr Khayrullin <saniokh@gmail.com> * - * Copyright (c) 2010 Alexandre Mendes <alex.mendes1988@gmail.com> * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see <http://www.gnu.org/licenses/>. * - ****************************************************************************************/ - -#ifndef SIMILAR_ARTISTS_APPLET_H -#define SIMILAR_ARTISTS_APPLET_H - - -#include "ArtistWidget.h" -#include "SimilarArtist.h" -#include "context/Applet.h" -#include "context/DataEngine.h" - -#include <ui_similarArtistsSettings.h> - -#include <QStack> - -class KConfigDialog; -class QGraphicsLinearLayout; - -namespace Plasma -{ -class IconWidget; -} - -/** - * SimilarArtists will display similar artists from the Internet, relative to the current playing artist. - * @author Joffrey Clavel - * @author Oleksandr Khayrullin - * @version 0.1 - */ -class SimilarArtistsApplet : public Context::Applet -{ - Q_OBJECT - -public: - - /** - * SimilarArtistsApplet constructor - * @param parent The widget parent - * @param args List of strings containing two entries: the service id - * and the applet id - */ - SimilarArtistsApplet( QObject* parent, const QVariantList& args ); - - /** - * SimilarArtistsApplet destructor - */ - ~SimilarArtistsApplet(); - -protected: - void createConfigurationInterface( KConfigDialog *parent ); - -public slots: - /** - * Initialization of the applet's display, creation of the layout, scrolls - */ - virtual void init(); - - /** - * Update the current artist and his similar artists - */ - void dataUpdated( const QString &source, const Plasma::DataEngine::Data &data ); - -private slots: - void goBackward(); - void goForward(); - void updateNavigationIcons(); - void queryArtist( const QString &name ); - void queryForCurrentTrack(); - -private: - - /** - * Update the display of the artists according to the lists m_similars - */ - void artistsUpdate(); - - /** - * This scrollArea contents the artists widgets - */ - ArtistsListWidget *m_scroll; - - /** - * The list of similar artists to display - */ - SimilarArtist::List m_similars; - - /** - * Artist which you want to see artists like - */ - QString m_artist; - - QStack<QString> m_historyBack; - QStack<QString> m_historyForward; - Plasma::IconWidget *m_backwardIcon; - Plasma::IconWidget *m_forwardIcon; - Plasma::IconWidget *m_currentArtistIcon; - Plasma::IconWidget *m_settingsIcon; - QGraphicsLinearLayout *m_layout; - Ui::similarArtistsSettings ui_Settings; - - /** - * The max number artists - */ - int m_maxArtists; - -private slots: - - /** - * Allows the connection to the lastfm's api - */ - void connectSource( const QString &source ); - - /** - * Show the settings windows - */ - void configure(); - void saveSettings(); - - void showSimilarArtists( const QString &name ); - void showArtistBio( const QString &name ); -}; - -AMAROK_EXPORT_APPLET( similarArtists, SimilarArtistsApplet ) - -#endif // SIMILARARTISTSAPPLET_H diff --git a/amarok/src/context/applets/similarartists/amarok-context-applet-similarArtists.desktop b/amarok/src/context/applets/similarartists/amarok-context-applet-similarArtists.desktop deleted file mode 100644 index 03a38f85..00000000 --- a/amarok/src/context/applets/similarartists/amarok-context-applet-similarArtists.desktop +++ /dev/null @@ -1,65 +0,0 @@ -[Desktop Entry] -Name=Similar Artists -Name[bg]=Подобни изпълнители -Name[bs]=Slični izvođači -Name[ca]=Artistes semblants -Name[ca@valencia]=Artistes semblants -Name[cs]=Podobní umělci -Name[da]=Lignende kunstnere -Name[de]=Ähnliche Interpreten -Name[el]=Παρόμοιοι καλλιτέχνες -Name[en_GB]=Similar Artists -Name[es]=Artistas similares -Name[et]=Sarnased esitajad -Name[eu]=Antzeko artistak -Name[fa]=هنرمندان مشابه‌ -Name[fi]=Samankaltaiset artistit -Name[fr]=Artistes similaires -Name[ga]=Ealaíontóirí Cosúil Leis/Léi -Name[gl]=Artistas similares -Name[hu]=Hasonló előadók -Name[id]=Artis Serupa -Name[is]=Líkir flytjendur -Name[it]=Artisti simili -Name[ja]=類似アーティスト -Name[km]=សិល្បករ​ស្រដៀង​គ្នា -Name[ko]=비슷한 가수 -Name[lt]=Panašūs atlikėjai -Name[lv]=Līdzīgi mākslinieki -Name[nb]=Liknende artister -Name[nds]=Lieke Künstlers -Name[nl]=Vergelijkbare artiesten -Name[pa]=ਰਲਦੇ ਕਲਾਕਾਰ -Name[pl]=Podobni wykonawcy -Name[pt]=Artistas Semelhantes -Name[pt_BR]=Artistas parecidos -Name[ro]=Interpreți asemănători -Name[ru]=Схожие исполнители -Name[sk]=Podobní interpreti -Name[sl]=Podobni izvajalci -Name[sr]=Слични извођачи -Name[sr@ijekavian]=Слични извођачи -Name[sr@ijekavianlatin]=Slični izvođači -Name[sr@latin]=Slični izvođači -Name[sv]=Liknande artister -Name[tr]=Benzer Sanatçılar -Name[uk]=Подібні виконавці -Name[x-test]=xxSimilar Artistsxx -Name[zh_CN]=相似艺人 -Name[zh_TW]=相似的演出者 -Type=Service -ServiceTypes=Plasma/Applet -Icon=similarartists-amarok - -X-KDE-Library=amarok_context_applet_similarArtists -X-KDE-PluginInfo-Author=Joffrey Clavel -X-KDE-PluginInfo-Email=jclavel@clabert.info -X-KDE-PluginInfo-Name=similarArtists -X-KDE-PluginInfo-Version=0.1 -X-KDE-PluginInfo-Website= -X-KDE-PluginInfo-Depends= -X-KDE-PluginInfo-License=GPL -X-KDE-PluginInfo-EnabledByDefault=true -X-KDE-ParentApp=amarok -X-KDE-PluginInfo-Category=Current - diff --git a/amarok/src/context/applets/similarartists/similarArtistsSettings.ui b/amarok/src/context/applets/similarartists/similarArtistsSettings.ui deleted file mode 100644 index 89afdb9c..00000000 --- a/amarok/src/context/applets/similarartists/similarArtistsSettings.ui +++ /dev/null @@ -1,42 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>similarArtistsSettings</class> - <widget class="QWidget" name="similarArtistsSettings"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>237</width> - <height>33</height> - </rect> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <layout class="QFormLayout" name="formLayout"> - <item row="0" column="0"> - <widget class="QLabel" name="label"> - <property name="text"> - <string>Maximum number of artists to show:</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QSpinBox" name="spinBox"> - <property name="minimum"> - <number>1</number> - </property> - <property name="maximum"> - <number>50</number> - </property> - <property name="value"> - <number>5</number> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> diff --git a/amarok/src/context/applets/songkick/CMakeLists.txt b/amarok/src/context/applets/songkick/CMakeLists.txt deleted file mode 100644 index 9e036c97..00000000 --- a/amarok/src/context/applets/songkick/CMakeLists.txt +++ /dev/null @@ -1,15 +0,0 @@ -project(context-currenttrack) - -set(songkick_SRCS SongkickApplet.cpp ) - -include_directories( ../.. - ../../.. ) - -kde4_add_plugin(amarok_context_applet_songkick ${songkick_SRCS}) -if(APPLE) - SET_TARGET_PROPERTIES(amarok_context_applet_songkick PROPERTIES LINK_FLAGS "-undefined dynamic_lookup") -endif(APPLE) -target_link_libraries(amarok_context_applet_songkick amarokcore amaroklib ${KDE4_PLASMA_LIBS} ${KDE4_KIO_LIBS}) - -install(TARGETS amarok_context_applet_songkick DESTINATION ${PLUGIN_INSTALL_DIR}) -install(FILES amarok-context-applet-songkick.desktop DESTINATION ${SERVICES_INSTALL_DIR}) diff --git a/amarok/src/context/applets/songkick/SongkickApplet.cpp b/amarok/src/context/applets/songkick/SongkickApplet.cpp deleted file mode 100644 index 4738bee5..00000000 --- a/amarok/src/context/applets/songkick/SongkickApplet.cpp +++ /dev/null @@ -1,267 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Jeff Mitchell <mitchell@kde.org> * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see <http://www.gnu.org/licenses/>. * - ****************************************************************************************/ - -#include "SongkickApplet.h" - -#include "core/support/Amarok.h" -#include "App.h" -#include "core/support/Debug.h" -#include "EngineController.h" -#include "scripting/scriptmanager/ScriptManager.h" -#include "core/meta/Meta.h" -#include "PaletteHandler.h" -#include "Theme.h" - -#include <KGlobalSettings> -#include <KStandardDirs> - -#include <QAction> -#include <QtGui/qgraphicsitem.h> -#include <QGraphicsProxyWidget> -#include <QtGui/qbrush.h> -#include <QTextBrowser> -#include <QPainter> -#include <QPoint> - -SongkickApplet::SongkickApplet( QObject* parent, const QVariantList& args ) - : Context::Applet( parent, args ) - , m_titleText( i18n("Songkick Concert Information") ) - , m_titleLabel( 0 ) - , m_reloadIcon( 0 ) - , m_songkick( 0 ) - , m_songkickProxy( 0 ) -{ - setHasConfigurationInterface( false ); - setBackgroundHints( Plasma::Applet::NoBackground ); -} - -SongkickApplet::~ SongkickApplet() -{ - delete m_songkickProxy; -} - -void SongkickApplet::init() -{ - // Call the base implementation. - Context::Applet::init(); - - QColor highlight = PaletteHandler::highlightColor().darker( 300 ); - - m_titleLabel = new QGraphicsSimpleTextItem( i18n("Concerts"), this ); - QFont bigger = m_titleLabel->font(); - bigger.setPointSize( bigger.pointSize() + 2 ); - m_titleLabel->setFont( bigger ); - m_titleLabel->setZValue( m_titleLabel->zValue() + 100 ); - m_titleLabel->setDrawBackground( true ); - - QAction* reloadAction = new QAction( i18n("Reload Songkick"), this ); - reloadAction->setIcon( KIcon( "view-refresh" ) ); - reloadAction->setVisible( true ); - reloadAction->setEnabled( true ); - m_reloadIcon = addAction( reloadAction ); - - connect( m_reloadIcon, SIGNAL(clicked()), dataEngine( "amarok-songkick" ), SLOT(update()) ); - - m_songkickProxy = new QGraphicsProxyWidget( this ); - m_songkick = new QTextBrowser; - m_songkick->setAttribute( Qt::WA_NoSystemBackground ); - m_songkick->setReadOnly( true ); - m_songkick->setOpenExternalLinks( true ); - m_songkick->setTextInteractionFlags( Qt::TextBrowserInteraction | Qt::TextSelectableByKeyboard ); - m_songkickProxy->setWidget( m_songkick ); - QPalette pal; - QBrush brush( PaletteHandler::highlightColor().lighter( 170 ) ); - brush.setStyle( Qt::SolidPattern ); - pal.setBrush( QPalette::Active, QPalette::Base, brush ); - pal.setBrush( QPalette::Inactive, QPalette::Base, brush ); - pal.setBrush( QPalette::Disabled, QPalette::Base, brush ); - pal.setBrush( QPalette::Window, brush ); - m_songkick->setPalette( pal ); - m_songkickProxy->setPalette( pal ); - m_songkick->setStyleSheet( QString( "QTextBrowser { background-color: %1; border-width: 0px; border-radius: 0px; color: %2; }" ) - .arg( PaletteHandler::highlightColor().lighter( 150 ).name() ) - .arg( PaletteHandler::highlightColor().darker( 400 ).name() ) ); - - connect( dataEngine( "amarok-songkick" ), SIGNAL(sourceAdded(QString)), this, SLOT(connectSource(QString)) ); - connect( The::paletteHandler(), SIGNAL(newPalette(QPalette)), SLOT(paletteChanged(QPalette)) ); - - constraintsEvent(); - connectSource( "ontour" ); - connectSource( "dates" ); -} - -void SongkickApplet::connectSource( const QString& source ) -{ - if( source == "ontour" ) - { - dataEngine( "amarok-songkick" )->connectSource( source, this ); - dataUpdated( source, dataEngine("amarok-songkick" )->query( "ontour" ) ); - } - else if( source == "dates" ) - { - dataEngine( "amarok-songkick" )->connectSource( source, this ); - dataUpdated( source, dataEngine("amarok-songkick" )->query( "dates" ) ); - } -} - -void SongkickApplet::constraintsEvent( Plasma::Constraints constraints ) -{ - Q_UNUSED( constraints ); - - prepareGeometryChange(); - - QRectF rect = boundingRect(); - rect.setWidth( rect.width() - 30 ); - m_titleLabel->setText( truncateTextToFit( m_titleText, m_titleLabel->font(), rect ) ); - m_titleLabel->setPos( (size().width() - m_titleLabel->boundingRect().width() ) / 2, standardPadding() + 2 ); - - m_reloadIcon->setPos( size().width() - m_reloadIcon->size().width() - standardPadding(), standardPadding() ); - m_reloadIcon->show(); - - //m_songkickProxy->setPos( 0, m_reloadIcon->size().height() ); - m_songkickProxy->setPos( standardPadding(), m_titleLabel->pos().y() + m_titleLabel->boundingRect().height() + standardPadding() ); - QSize songkickSize( size().width() - 2 * standardPadding(), boundingRect().height() - m_songkickProxy->pos().y() - standardPadding() ); - m_songkickProxy->setMinimumSize( songkickSize ); - m_songkickProxy->setMaximumSize( songkickSize ); -} - -void SongkickApplet::dataUpdated( const QString& name, const Plasma::DataEngine::Data& data ) -{ - DEBUG_BLOCK - if( data.size() == 0 ) return; - - debug() << "songkick applet got name:" << name << "and data: " << data; - - m_titleLabel->show(); - if( data.contains( "fetching" ) ) - { - m_songkick->show(); - m_songkick->setPlainText( i18n("Concert information is being fetched.") ); - } - else if( data.contains( "error" ) ) - { - m_songkick->show(); - m_songkick->setPlainText( i18n( "Songkick was not able to be downloaded. Please check your Internet connection: %1", data["error"].toString() ) ); - } - else if( data.contains( "suggested" ) ) - { - m_songkick->hide(); - QVariantList suggested = data[ "suggested" ].toList(); - // build simple HTML to show - // a list - QString html = QString( "<br><br>" ); - foreach( const QVariant &suggestion, suggested ) - { - QString sug = suggestion.toString(); - //debug() << "parsing suggestion:" << sug; - QStringList pieces = sug.split( " - " ); - const QString link = QString( "<a href=\"%1|%2|%3\">%4 - %5</a><br>" ) - .arg( pieces[0] ) - .arg( pieces[1] ) - .arg( pieces[2] ) - .arg( pieces[1] ) - .arg( pieces[0] ); - html += link; - } - //debug() << "setting html: " << html; - //m_suggested->setHtml( html ); - //m_suggested->show(); - } - else if( data.contains( "html" ) ) - { - // show pure html in the text area - m_songkick->setHtml( data[ "html" ].toString() ); - m_songkick->show(); - } - else if( data.contains( "lyrics" ) ) - { - m_songkick->show(); - QVariantList lyrics = data[ "lyrics" ].toList(); - - m_titleText = QString( "Songkick: %1 - %2" ).arg( lyrics[0].toString() ) - .arg( lyrics[1].toString() ); - // need padding for title - m_songkick->setPlainText( lyrics[ 3 ].toString().trimmed() ); - } - else if( data.contains( "notfound" ) ) - { - m_songkick->show(); - m_songkick->setPlainText( i18n("There was no information found for this track" )); - } - setPreferredSize( (int)size().width(), (int)size().height() ); - updateConstraints(); - update(); -} - -bool SongkickApplet::hasHeightForWidth() const -{ - return false; -} - -void -SongkickApplet::paintInterface( QPainter *p, const QStyleOptionGraphicsItem *option, const QRect &contentsRect ) -{ - Q_UNUSED( option ); - Q_UNUSED( contentsRect ); - - // tint the whole applet - addGradientToAppletBackground( p ); - - //draw background of lyrics text - p->save(); - QColor highlight( App::instance()->palette().highlight().color() ); - highlight.setHsvF( highlight.hueF(), 0.07, 1, highlight.alphaF() ); - - QRectF songkickRect = m_songkickProxy->boundingRect(); - songkickRect.moveTopLeft( m_songkickProxy->pos() ); - QPainterPath path; - path.addRoundedRect( songkickRect, 5, 5 ); - p->fillPath( path , highlight ); - p->restore(); - -} - -QSizeF SongkickApplet::sizeHint(Qt::SizeHint which, const QSizeF & constraint) const -{ - Q_UNUSED( which ); - - /* if( m_songkick ) - { - debug() << "returning sizehint height of" << m_songkick->sizeHint().height(); - // return QSizeF( constraint.width(), m_songkickProxy->sizeHint().height() ); - if( m_textHeight > 0 ) - return QGraphicsWidget::sizeHint( which, constraint ); - - } else - return QGraphicsWidget::sizeHint( which, constraint ); */ - return QSizeF( QGraphicsWidget::sizeHint( which, constraint ).width(), 500 ); -} - -void -SongkickApplet::paletteChanged( const QPalette & palette ) -{ - Q_UNUSED( palette ) - - QColor highlight = PaletteHandler::highlightColor().darker( 200 ); - if( m_songkick ) - m_songkick->setStyleSheet( - QString( "QTextBrowser { background-color: %1; border-width: 0px; border-radius: 0px; color: %2; }" ) - .arg( PaletteHandler::highlightColor().lighter( 150 ).name() ) - .arg( PaletteHandler::highlightColor().darker( 400 ).name() ) - ); -} - -#include "moc_SongkickApplet.cpp" diff --git a/amarok/src/context/applets/songkick/SongkickApplet.h b/amarok/src/context/applets/songkick/SongkickApplet.h deleted file mode 100644 index 4ffb8dd1..00000000 --- a/amarok/src/context/applets/songkick/SongkickApplet.h +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Leo Franchi <lfranchi@gmail.com> * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see <http://www.gnu.org/licenses/>. * - ****************************************************************************************/ - -#ifndef SONGKICK_APPLET_H -#define SONGKICK_APPLET_H - -#include "context/Applet.h" -#include "context/DataEngine.h" -#include "context/Svg.h" - -#include <plasma/widgets/iconwidget.h> - - -class QGraphicsSimpleTextItem; -class QGraphicsProxyWidget; -class QTextBrowser; - -class SongkickApplet : public Context::Applet -{ - Q_OBJECT - -public: - SongkickApplet( QObject* parent, const QVariantList& args ); - ~SongkickApplet(); - - bool hasHeightForWidth() const; - - void constraintsEvent( Plasma::Constraints constraints = Plasma::AllConstraints ); - - void paintInterface( QPainter *painter, const QStyleOptionGraphicsItem* option, const QRect& contentsRect ); - - virtual QSizeF sizeHint( Qt::SizeHint which, const QSizeF & constraint) const; - -public slots: - virtual void init(); - void connectSource( const QString& source ); - void dataUpdated( const QString& name, const Plasma::DataEngine::Data& data ); - -private slots: - void paletteChanged( const QPalette & palette ); - -private: - void calculateHeight(); - - QString m_titleText; - QGraphicsSimpleTextItem* m_titleLabel; - Plasma::IconWidget* m_reloadIcon; - - // holds main body - QGraphicsProxyWidget *m_songkickProxy; - QTextBrowser* m_songkick; -}; - -AMAROK_EXPORT_APPLET( songkick, SongkickApplet ) - -#endif diff --git a/amarok/src/context/applets/songkick/amarok-context-applet-songkick.desktop b/amarok/src/context/applets/songkick/amarok-context-applet-songkick.desktop deleted file mode 100644 index bd13a60b..00000000 --- a/amarok/src/context/applets/songkick/amarok-context-applet-songkick.desktop +++ /dev/null @@ -1,69 +0,0 @@ -[Desktop Entry] -Name=Songkick -Name[bg]=Songkick -Name[bs]=Songkick -Name[ca]=Songkick -Name[ca@valencia]=Songkick -Name[cs]=Songkick -Name[csb]=Songkick -Name[da]=Songkick -Name[de]=Songkick -Name[el]=Songkick -Name[en_GB]=Songkick -Name[eo]=Songkick -Name[es]=Songkick -Name[et]=Songkick -Name[eu]=Songkick -Name[fi]=Songkick -Name[fr]=Songkick -Name[ga]=Songkick -Name[gl]=Songkick -Name[hu]=Songkick -Name[id]=Songkick -Name[is]=Songkick -Name[it]=Songkick -Name[ja]=Songkick -Name[km]=Songkick -Name[ko]=Songkick -Name[lt]=Songkick -Name[lv]=Songkick -Name[nb]=Songkick -Name[nds]=Songkick -Name[nl]=Songkick -Name[nn]=Songkick -Name[pa]=ਸਾਂਗਕਿਕ -Name[pl]=Songkick -Name[pt]=Songkick -Name[pt_BR]=Songkick -Name[ro]=Songkick -Name[ru]=Songkick -Name[sk]=Songkick -Name[sl]=Songkick -Name[sq]=Songkick -Name[sr]=Сонгкик -Name[sr@ijekavian]=Сонгкик -Name[sr@ijekavianlatin]=Songkick -Name[sr@latin]=Songkick -Name[sv]=Songkick -Name[th]=ซองคิก -Name[tr]=Songkick -Name[uk]=Songkick -Name[wa]=Songkick -Name[x-test]=xxSongkickxx -Name[zh_CN]=Songkick -Name[zh_TW]=Songkick -Type=Service -ServiceTypes=Plasma/Applet - -X-KDE-Library=amarok_context_applet_songkick -X-KDE-PluginInfo-Author=Jeff Mitchell -X-KDE-PluginInfo-Email=mitchell@kde.org -X-KDE-PluginInfo-Name=songkick -X-KDE-PluginInfo-Version=pre0.1 -X-KDE-PluginInfo-Website= -X-KDE-PluginInfo-Depends= -X-KDE-PluginInfo-License=GPL -X-KDE-PluginInfo-EnabledByDefault=true -X-KDE-ParentApp=amarok -X-KDE-PluginInfo-Category=Current - diff --git a/amarok/src/context/applets/tabs/CMakeLists.txt b/amarok/src/context/applets/tabs/CMakeLists.txt deleted file mode 100644 index dbc3a692..00000000 --- a/amarok/src/context/applets/tabs/CMakeLists.txt +++ /dev/null @@ -1,18 +0,0 @@ -include_directories( ../.. - ../../..) - -set( tabs_applet_SRCS TabsApplet.cpp TabsView.cpp TabsItem.cpp TabsSettings.ui ReloadEditDialog.ui ) -kde4_add_plugin( amarok_context_applet_tabs ${tabs_applet_SRCS} ) -target_link_libraries( amarok_context_applet_tabs - amarokcore - amaroklib - ${KDE4_PLASMA_LIBS} - ${KDE4_KIO_LIBS} -) - -install( TARGETS amarok_context_applet_tabs DESTINATION ${PLUGIN_INSTALL_DIR} ) -install( FILES amarok-context-applet-tabs.desktop DESTINATION ${SERVICES_INSTALL_DIR} ) -install( FILES amarok-tabs-guitar.png DESTINATION ${DATA_INSTALL_DIR}/amarok/images/ ) -install( FILES amarok-tabs-bass.png DESTINATION ${DATA_INSTALL_DIR}/amarok/images/ ) -install( FILES amarok-tabs-drum.png DESTINATION ${DATA_INSTALL_DIR}/amarok/images/ ) -install( FILES amarok-tabs-piano.png DESTINATION ${DATA_INSTALL_DIR}/amarok/images/ ) diff --git a/amarok/src/context/applets/tabs/ReloadEditDialog.ui b/amarok/src/context/applets/tabs/ReloadEditDialog.ui deleted file mode 100644 index e4f45674..00000000 --- a/amarok/src/context/applets/tabs/ReloadEditDialog.ui +++ /dev/null @@ -1,98 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>ReloadEditDialog</class> - <widget class="QWidget" name="ReloadEditDialog"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>300</width> - <height>100</height> - </rect> - </property> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize"> - <size> - <width>200</width> - <height>60</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>16777215</width> - <height>16777215</height> - </size> - </property> - <property name="windowTitle"> - <string>Reload tabs</string> - </property> - <property name="sizeGripEnabled" stdset="0"> - <bool>false</bool> - </property> - <layout class="QVBoxLayout" name="verticalLayout_2"> - <item> - <layout class="QVBoxLayout" name="verticalLayout" stretch="0,0"> - <item> - <widget class="QLabel" name="label"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Minimum"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize"> - <size> - <width>0</width> - <height>15</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>16777215</width> - <height>20</height> - </size> - </property> - <property name="text"> - <string>Reload tabs with the following title and artist</string> - </property> - <property name="alignment"> - <set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set> - </property> - </widget> - </item> - <item> - <layout class="QGridLayout" name="artistTitleLayout" rowstretch="0,0" columnstretch="0,0"> - <item row="0" column="0"> - <widget class="QLabel" name="artistLabel"> - <property name="text"> - <string>Artist</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QLineEdit" name="artistLineEdit"/> - </item> - <item row="1" column="1"> - <widget class="QLineEdit" name="titleLineEdit"/> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="titleLabel"> - <property name="text"> - <string>Title</string> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> diff --git a/amarok/src/context/applets/tabs/TabsApplet.cpp b/amarok/src/context/applets/tabs/TabsApplet.cpp deleted file mode 100644 index 55e80e5f..00000000 --- a/amarok/src/context/applets/tabs/TabsApplet.cpp +++ /dev/null @@ -1,338 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Rainer Sigle <rainer.sigle@web.de> * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. if not, see <http://www.gnu.org/licenses/>. * - ****************************************************************************************/ - -#define DEBUG_PREFIX "TabsApplet" - -#include "TabsApplet.h" - -#include "TabsItem.h" -#include "TabsView.h" -#include "core/support/Amarok.h" -#include "core/support/Debug.h" -#include "context/ContextView.h" -#include "context/widgets/AppletHeader.h" - -#include <KConfigDialog> -#include <KConfigGroup> -#include <KDialog> -#include <Plasma/IconWidget> -#include <Plasma/Label> - -/** - * \brief Constructor - * - * TabsApplet constructor - * - * \param parent : the TabsApplet parent (used by Context::Applet) - * \param args : (used by Context::Applet) - */ -TabsApplet::TabsApplet( QObject* parent, const QVariantList& args ) - : Context::Applet( parent, args ) - , m_tabsView( 0 ) - , m_currentState( InitState ) - , m_layout( 0 ) - , m_fetchGuitar( true ) - , m_fetchBass( true ) - , m_showTabBrowser( false ) -{ - DEBUG_BLOCK - setHasConfigurationInterface( true ); - - EngineController *engine = The::engineController(); - connect( engine, SIGNAL(stopped(qint64,qint64)), this, SLOT(stopped()) ); -} - -TabsApplet::~TabsApplet() -{ - DEBUG_BLOCK - delete m_tabsView; - if( m_reloadIcon ) - delete m_reloadIcon.data(); -} - -/** - * \brief Initialization - * - * Initializes the TabsApplet with default parameters - */ -void -TabsApplet::init() -{ - // applet base initialization - Context::Applet::init(); - - // create the header label - enableHeader( true ); - setHeaderText( i18nc( "Guitar tablature", "Tabs" ) ); - - // creates the tab view - m_tabsView = new TabsView( this ); - - // Set the collapse size - setCollapseOffHeight( -1 ); - setCollapseHeight( m_header->height() ); - setMinimumHeight( collapseHeight() ); - setPreferredHeight( collapseHeight() ); - - // create the reload icon - QAction* reloadAction = new QAction( this ); - reloadAction->setIcon( KIcon( "view-refresh" ) ); - reloadAction->setVisible( true ); - reloadAction->setEnabled( true ); - reloadAction->setText( i18nc( "Guitar tablature", "Reload tabs" ) ); - m_reloadIcon = addLeftHeaderAction( reloadAction ); - m_reloadIcon.data()->setEnabled( false ); - connect( m_reloadIcon.data(), SIGNAL(clicked()), this, SLOT(reloadTabs()) ); - - // create the settings icon - QAction* settingsAction = new QAction( this ); - settingsAction->setIcon( KIcon( "preferences-system" ) ); - settingsAction->setEnabled( true ); - settingsAction->setText( i18n( "Settings" ) ); - QWeakPointer<Plasma::IconWidget> settingsIcon = addRightHeaderAction( settingsAction ); - connect( settingsIcon.data(), SIGNAL(clicked()), this, SLOT(showConfigurationInterface()) ); - - m_layout = new QGraphicsLinearLayout( Qt::Vertical ); - m_layout->addItem( m_header ); - m_layout->addItem( m_tabsView ); - setLayout( m_layout ); - - // read configuration data and update the engine. - KConfigGroup config = Amarok::config("Tabs Applet"); - m_fetchGuitar = config.readEntry( "FetchGuitar", true ); - m_fetchBass = config.readEntry( "FetchBass", true ); - - Plasma::DataEngine *engine = dataEngine( "amarok-tabs" ); - engine->setProperty( "fetchGuitarTabs", m_fetchGuitar ); - engine->setProperty( "fetchBassTabs", m_fetchBass ); - engine->connectSource( "tabs", this ); - - updateInterface( InitState ); -} - -void -TabsApplet::stopped() -{ - setHeaderText( i18nc( "Guitar tablature", "Tabs" ) ); - updateInterface( StoppedState ); -} - -void -TabsApplet::dataUpdated( const QString& name, const Plasma::DataEngine::Data& data ) -{ - DEBUG_BLOCK - Q_UNUSED( name ) - - // remove previously fetched stuff - m_tabsView->clear(); - m_tabsView->clearTabBrowser(); - setBusy( false ); - - if( data.empty() ) - { - setHeaderText( i18nc( "Guitar tablature", "Tabs" ) ); - updateInterface( InitState ); - return; - } - - const QString state = data[ "state" ].toString(); - const QString artistName = data[ "artist" ].toString(); - const QString titleName = data[ "title" ].toString(); - if( data.contains( "state" ) && state.contains( "Fetching" ) ) - { - if( canAnimate() ) - setBusy( true ); - setHeaderText( i18nc( "Guitar tablature", "Tabs: Fetching..." ) ); - updateInterface( FetchingState ); - return; - } - else if( data.contains( "state" ) && state.contains( "Stopped" ) ) - { - stopped(); - return; - } - else if( data.contains( "state" ) && state.contains( "noTabs") ) - { - // no tabs for the current track - setHeaderText( i18nc( "Guitar tablature", "No Tabs for %1 by %2", titleName, artistName ) ); - updateInterface( NoTabsState ); - return; - } - else if( data.contains( "state" ) && state.contains( "FetchError") ) - { - setHeaderText( i18nc( "Guitar tablature", "Tabs: Fetch Error" ) ); - updateInterface( NoTabsState ); - return; - } - - // getting the tab-data from the engine - bool tabFound = false; - for( int i = 0; i < data.size(); i++ ) - { - const QString tabId = QString( "tabs:" ).append( QString::number( i ) ); - if( data.contains( tabId ) ) - { - TabsInfo *item = data[ tabId ].value<TabsInfo *>() ; - if( item ) - { - TabsItem *tabsItem = new TabsItem(); - tabsItem->setTab( item ); - - m_tabsView->appendTab( tabsItem ); - if( !tabFound ) - { - // update the applet and display the first tab in list - m_tabsView->showTab( tabsItem ); - - // update artist and title in the headerlabel - setHeaderText( i18nc( "Guitar tablature", "Tabs: %1 - %2", titleName, artistName ) ); - updateInterface( TabState ); - tabFound = true; - } - } - } - } -} - -void -TabsApplet::updateInterface( const AppletState appletState ) -{ - // return if state has not changed (except for init state) - if( m_currentState == appletState && appletState != InitState ) - return; - - debug() << "updating interface from state " << m_currentState << " to " << appletState; - m_currentState = appletState; - bool collapse = false; - - switch( m_currentState ) - { - case InitState: - case StoppedState: - m_reloadIcon.data()->setEnabled( false ); - m_showTabBrowser = false; - collapse = true; - break; - case NoTabsState: - m_reloadIcon.data()->setEnabled( true ); - m_showTabBrowser = false; - collapse = true; - break; - case FetchingState: - m_reloadIcon.data()->setEnabled( false ); - m_showTabBrowser = false; - break; - case TabState: - m_reloadIcon.data()->setEnabled( true ); - m_showTabBrowser = true; - break; - } - - QGraphicsLinearLayout *lo = static_cast<QGraphicsLinearLayout*>( layout() ); - - m_showTabBrowser ? lo->addItem( m_tabsView ) : lo->removeItem( m_tabsView ); - m_showTabBrowser ? m_tabsView->show() : m_tabsView->hide(); - - collapse ? setCollapseOn() : setCollapseOff(); - - updateConstraints(); - update(); -} - -void -TabsApplet::createConfigurationInterface( KConfigDialog *parent ) -{ - parent->setButtons( KDialog::Ok | KDialog::Cancel ); - - QWidget *settings = new QWidget; - ui_Settings.setupUi( settings ); - - if( m_fetchGuitar ) - ui_Settings.cbFetchGuitar->setChecked( true ); - if( m_fetchBass ) - ui_Settings.cbFetchBass->setChecked( true ); - - parent->addPage( settings, i18nc( "Guitar tablature settings", "Tabs Settings" ), "preferences-system" ); - connect( parent, SIGNAL(accepted()), this, SLOT(saveSettings()) ); -} - -void -TabsApplet::saveSettings() -{ - DEBUG_BLOCK - KConfigGroup config = Amarok::config("Tabs Applet"); - - bool fetchGuitar = ui_Settings.cbFetchGuitar->isChecked(); - bool fetchBass = ui_Settings.cbFetchBass->isChecked(); - - // check if any setting has changed - bool forceUpdate = false; - if( m_fetchGuitar != fetchGuitar || m_fetchBass != fetchBass ) - forceUpdate = true; - - if( forceUpdate ) - { - m_fetchGuitar = fetchGuitar; - m_fetchBass = fetchBass; - - config.writeEntry( "FetchGuitar", m_fetchGuitar ); - config.writeEntry( "FetchBass", m_fetchBass ); - - Plasma::DataEngine *engine = dataEngine( "amarok-tabs" ); - engine->setProperty( "fetchGuitarTabs", m_fetchGuitar ); - engine->setProperty( "fetchBassTabs", m_fetchBass ); - engine->query( QLatin1String( "tabs:forceUpdate" ) ); - } -} - -void -TabsApplet::reloadTabs() -{ - DEBUG_BLOCK - KDialog reloadDialog; - QWidget *reloadWidget = new QWidget( &reloadDialog ); - - Ui::ReloadEditDialog *reloadUI = new Ui::ReloadEditDialog(); - reloadUI->setupUi( reloadWidget ); - - reloadDialog.setCaption( i18nc( "Guitar tablature", "Reload Tabs" ) ); - reloadDialog.setButtons( KDialog::Ok|KDialog::Cancel ); - reloadDialog.setDefaultButton( KDialog::Ok ); - reloadDialog.setMainWidget( reloadWidget ); - - // query engine for current artist and title - Plasma::DataEngine *engine = dataEngine( "amarok-tabs" ); - QString artistName = engine->property( "artistName" ).toString(); - QString titleName = engine->property( "titleName" ).toString(); - - // update ui - reloadUI->artistLineEdit->setText( artistName ); - reloadUI->titleLineEdit->setText( titleName ); - - if( reloadDialog.exec() == KDialog::Accepted ) - { - QString newArtist = reloadUI->artistLineEdit->text(); - QString newTitle = reloadUI->titleLineEdit->text(); - if ( newArtist != artistName || newTitle != titleName ) - { - engine->setProperty( "artistName", newArtist ); - engine->setProperty( "titleName", newTitle ); - engine->query( QLatin1String( "tabs:forceUpdateSpecificTitleArtist" ) ); - } - } -} - -#include "moc_TabsApplet.cpp" diff --git a/amarok/src/context/applets/tabs/TabsApplet.h b/amarok/src/context/applets/tabs/TabsApplet.h deleted file mode 100644 index e1bc39d3..00000000 --- a/amarok/src/context/applets/tabs/TabsApplet.h +++ /dev/null @@ -1,93 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Rainer Sigle <rainer.sigle@web.de> * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see <http://www.gnu.org/licenses/>. * - ****************************************************************************************/ - -#ifndef TABS_APPLET_H -#define TABS_APPLET_H - -// Amarok -#include "context/engines/tabs/TabsInfo.h" -#include "context/Applet.h" -#include "context/DataEngine.h" - -#include <ui_TabsSettings.h> -#include <ui_ReloadEditDialog.h> - -// Qt -#include <QGraphicsLinearLayout> -#include <QtCore/qsharedpointer.h> - -class TabsView; - -namespace Plasma -{ - class IconWidget; - class Label; -} - -class KConfigDialog; - - -/** Amarok context view applet to display tab-related information - * for the currently playing song - */ -class TabsApplet : public Context::Applet -{ - Q_OBJECT - public: - TabsApplet( QObject* parent, const QVariantList& args ); - ~TabsApplet(); - - public slots: - - virtual void init(); - void dataUpdated( const QString& name, const Plasma::DataEngine::Data& data ); - - /** - * Saves the settings from the configuration dialog - */ - void saveSettings(); - - protected: - void createConfigurationInterface( KConfigDialog *parent ); - - private slots: - void reloadTabs(); - void stopped(); - - private: - TabsView *m_tabsView; - - enum AppletState { InitState, StoppedState, FetchingState, TabState, NoTabsState }; - AppletState m_currentState; - void updateInterface( const AppletState appletState ); - - /** - * Layout for the formatting of the applet contents - */ - QGraphicsLinearLayout *m_layout; - QWeakPointer<Plasma::IconWidget> m_reloadIcon; - - bool m_fetchGuitar; - bool m_fetchBass; - - bool m_showTabBrowser; - Ui::TabsSettings ui_Settings; -}; - -AMAROK_EXPORT_APPLET( tabs, TabsApplet ) -Q_DECLARE_METATYPE ( TabsInfo *) - -#endif /* Tabs_APPLET_H */ diff --git a/amarok/src/context/applets/tabs/TabsItem.cpp b/amarok/src/context/applets/tabs/TabsItem.cpp deleted file mode 100644 index 7d8467fb..00000000 --- a/amarok/src/context/applets/tabs/TabsItem.cpp +++ /dev/null @@ -1,119 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Rainer Sigle <rainer.sigle@web.de> * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see <http://www.gnu.org/licenses/>. * - ****************************************************************************************/ - -#include "TabsItem.h" -#include "SvgHandler.h" - -#include <KStandardDirs> - -#include <QIcon> -#include <QPixmap> -#include <QSize> - -TabsItem::TabsItem() - : QStandardItem() - , m_iconSize( 0 ) - , m_tabsInfo( 0 ) -{ - m_tabsInfo = new TabsInfo(); - setEditable( false ); - setText( "" ); - setIconSize( 36 ); -} - -void -TabsItem::setTab( TabsInfo *tab ) -{ - if( tab ) - { - m_tabsInfo = tab; - setTabIcon( tab->tabType ); - setToolTip( m_tabsInfo->title ); - } -} - -void -TabsItem::setIconSize( const int iconSize ) -{ - static const int padding = 5; - - m_iconSize = iconSize; - - QSize size = sizeHint(); - size.setHeight( iconSize + padding * 2 ); - setSizeHint( size ); -} - -void -TabsItem::setTabIcon( TabsInfo::TabType tabtype ) -{ - QPixmap pix; - switch( tabtype ) - { - case TabsInfo::GUITAR: - pix = QPixmap( KStandardDirs::locate( "data", "amarok/images/amarok-tabs-guitar.png" ) ); - break; - case TabsInfo::BASS: - pix = QPixmap( KStandardDirs::locate( "data", "amarok/images/amarok-tabs-bass.png" ) ); - break; - case TabsInfo::DRUM: - pix = QPixmap( KStandardDirs::locate( "data", "amarok/images/amarok-tabs-drum.png" ) ); - break; - case TabsInfo::PIANO: - pix = QPixmap( KStandardDirs::locate( "data", "amarok/images/amarok-tabs-piano.png" ) ); - break; - } - - QPixmap pixwithBorder( The::svgHandler()->addBordersToPixmap( pix, 3, "Thumbnail", true ) ) ; - setIcon( QIcon( pixwithBorder ) ); -} - -const QString -TabsItem::getTabData() -{ - if( m_tabsInfo ) - return m_tabsInfo->tabs; - else - return QString(); -} - -const QString -TabsItem::getTabTitle() -{ - if( m_tabsInfo ) - return m_tabsInfo->title; - else - return QString(); -} - -const QString -TabsItem::getTabUrl() -{ - if( m_tabsInfo ) - return m_tabsInfo->url.url(); - else - return QString(); -} - - -const QString -TabsItem::getTabSource() -{ - if( m_tabsInfo ) - return m_tabsInfo->source; - else - return QString(); -} diff --git a/amarok/src/context/applets/tabs/TabsItem.h b/amarok/src/context/applets/tabs/TabsItem.h deleted file mode 100644 index 3f7344a8..00000000 --- a/amarok/src/context/applets/tabs/TabsItem.h +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Rainer Sigle <rainer.sigle@web.de> * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see <http://www.gnu.org/licenses/>. * - ****************************************************************************************/ - -#ifndef AMAROK_TABS_ITEM_H -#define AMAROK_TABS_ITEM_H - -#include "context/engines/tabs/TabsInfo.h" - -#include <QtGui/qstandarditemmodel.h> - -class TabsItem : public QStandardItem -{ - public: - TabsItem(); - ~TabsItem() { } - - /** - * Sets the tab-data for this specific tab-item - * - * @arg TabsInfo pointer to associate with - */ - void setTab( TabsInfo * ); - - /** - * defines the size of the tab-icons to display - */ - void setIconSize( const int iconSize ); - void setTabIcon( TabsInfo::TabType tabtype ); - - const QString getTabData(); - const QString getTabTitle(); - const QString getTabUrl(); - const QString getTabSource(); - - private: - int m_iconSize; - TabsInfo *m_tabsInfo; -}; - -#endif // multiple inclusion guard diff --git a/amarok/src/context/applets/tabs/TabsSettings.ui b/amarok/src/context/applets/tabs/TabsSettings.ui deleted file mode 100644 index 5e8d370c..00000000 --- a/amarok/src/context/applets/tabs/TabsSettings.ui +++ /dev/null @@ -1,74 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>TabsSettings</class> - <widget class="QWidget" name="TabsSettings"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>363</width> - <height>103</height> - </rect> - </property> - <property name="sizePolicy"> - <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize"> - <size> - <width>0</width> - <height>0</height> - </size> - </property> - <property name="windowTitle"> - <string>Current Track Settings</string> - </property> - <layout class="QFormLayout" name="formLayout"> - <property name="fieldGrowthPolicy"> - <enum>QFormLayout::ExpandingFieldsGrow</enum> - </property> - <property name="labelAlignment"> - <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> - </property> - <item row="0" column="0" colspan="2"> - <widget class="QGroupBox" name="gbFetchTabs"> - <property name="title"> - <string>Fetch tabs for</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <widget class="QCheckBox" name="cbFetchGuitar"> - <property name="layoutDirection"> - <enum>Qt::LeftToRight</enum> - </property> - <property name="text"> - <string>Guitar</string> - </property> - <property name="checked"> - <bool>false</bool> - </property> - </widget> - </item> - <item> - <widget class="QCheckBox" name="cbFetchBass"> - <property name="layoutDirection"> - <enum>Qt::LeftToRight</enum> - </property> - <property name="text"> - <string>Bass</string> - </property> - <property name="checked"> - <bool>false</bool> - </property> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> diff --git a/amarok/src/context/applets/tabs/TabsView.cpp b/amarok/src/context/applets/tabs/TabsView.cpp deleted file mode 100644 index 456fca95..00000000 --- a/amarok/src/context/applets/tabs/TabsView.cpp +++ /dev/null @@ -1,241 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Rainer Sigle <rainer.sigle@web.de> * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see <http://www.gnu.org/licenses/>. * - ****************************************************************************************/ - -#include "TabsView.h" -#include "TabsItem.h" -#include "core/support/Debug.h" -#include "PaletteHandler.h" -#include "widgets/PrettyTreeView.h" - -#include <KTextBrowser> -#include <Plasma/ScrollBar> -#include <Plasma/TextBrowser> - -#include <QGraphicsLinearLayout> - -// Subclassed to override the access level of some methods. -// The TabsTreeView and the TabsView are so highly coupled that this is acceptable, imo. -class TabsTreeView : public Amarok::PrettyTreeView -{ - public: - TabsTreeView( QWidget *parent = 0 ) - : Amarok::PrettyTreeView( parent ) - { - setAttribute( Qt::WA_NoSystemBackground ); - viewport()->setAutoFillBackground( false ); - - setHeaderHidden( true ); - setIconSize( QSize( 36, 36 ) ); - setDragDropMode( QAbstractItemView::DragOnly ); - setSelectionMode( QAbstractItemView::SingleSelection ); - setSelectionBehavior( QAbstractItemView::SelectItems ); - setAnimated( true ); - setRootIsDecorated( false ); - setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); - setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); - setFixedWidth( 48 ); - - } - protected: - - // Override access level to make it public. Only visible to the TabsView. - // Used for context menu methods. - QModelIndexList selectedIndexes() const { return PrettyTreeView::selectedIndexes(); } -}; - - -TabsView::TabsView( QGraphicsWidget *parent ) - : QGraphicsProxyWidget( parent ) -{ - // tree view which holds the collection of fetched tabs - m_treeView = new TabsTreeView( 0 ); - connect( m_treeView, SIGNAL(clicked(QModelIndex)), - this, SLOT(itemClicked(QModelIndex)) ); - - m_model = new QStandardItemModel(); - m_model->setColumnCount( 1 ); - m_treeView->setModel( m_model ); - - m_treeProxy = new QGraphicsProxyWidget( this ); - m_treeProxy->setWidget( m_treeView ); - - // the textbrowser widget to display the tabs - m_tabTextBrowser = new Plasma::TextBrowser( ); - KTextBrowser *browserWidget = m_tabTextBrowser->nativeWidget(); - browserWidget->setFrameShape( QFrame::StyledPanel ); - browserWidget->setAttribute( Qt::WA_NoSystemBackground ); - browserWidget->setOpenExternalLinks( true ); - browserWidget->setUndoRedoEnabled( true ); - browserWidget->setAutoFillBackground( false ); - browserWidget->setWordWrapMode( QTextOption::NoWrap ); - browserWidget->viewport()->setAutoFillBackground( true ); - browserWidget->viewport()->setAttribute( Qt::WA_NoSystemBackground ); - browserWidget->setTextInteractionFlags( Qt::TextBrowserInteraction | Qt::TextSelectableByKeyboard ); - - QScrollBar *treeScrollBar = m_treeView->verticalScrollBar(); - m_scrollBar = new Plasma::ScrollBar( this ); - m_scrollBar->setFocusPolicy( Qt::NoFocus ); - - // synchronize scrollbars - connect( treeScrollBar, SIGNAL(rangeChanged(int,int)), SLOT(slotScrollBarRangeChanged(int,int)) ); - connect( treeScrollBar, SIGNAL(valueChanged(int)), m_scrollBar, SLOT(setValue(int)) ); - connect( m_scrollBar, SIGNAL(valueChanged(int)), treeScrollBar, SLOT(setValue(int)) ); - m_scrollBar->setRange( treeScrollBar->minimum(), treeScrollBar->maximum() ); - m_scrollBar->setPageStep( treeScrollBar->pageStep() ); - m_scrollBar->setSingleStep( treeScrollBar->singleStep() ); - - // arrange textbrowser and treeview in a horizontal layout - QGraphicsLinearLayout *layout = new QGraphicsLinearLayout( Qt::Horizontal ); - layout->addItem( m_treeProxy ); - layout->addItem( m_scrollBar ); - layout->addItem( m_tabTextBrowser ); - layout->setSpacing( 2 ); - layout->setContentsMargins( 0, 0, 0, 0 ); - setLayout( layout ); - setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); - updateScrollBarVisibility(); -} - -TabsView::~TabsView() -{ - delete m_model; - delete m_treeProxy; -} - -void -TabsView::appendTab( TabsItem *tabsItem ) -{ - if( tabsItem ) - m_model->appendRow( tabsItem ); -} - -void -TabsView::clear() -{ - qDeleteAll( m_model->findItems(QLatin1String("*"), Qt::MatchWildcard) ); - m_model->clear(); -} - -void -TabsView::clearTabBrowser() -{ - m_tabTextBrowser->nativeWidget()->clear(); -} - -void -TabsView::showTab( TabsItem *tab ) -{ - if( tab ) - { - QString tabText = tab->getTabData(); - if( tabText.length() > 0 ) - { - tabText.replace( '\n', "<br></br>", Qt::CaseInsensitive ); - - QFont tabFont( "monospace"); - tabFont.setStyleHint( QFont::Courier ); - tabFont.setStyleStrategy( QFont::PreferAntialias ); - tabFont.setWeight( QFont::Normal ); - tabFont.setPointSize( QFont().pointSize() ); - - QFont headingFont( "sans-serif" ); - headingFont.setPointSize( tabFont.pointSize() + 2 ); - headingFont.setStyleHint( QFont::SansSerif ); - headingFont.setStyleStrategy( QFont::PreferAntialias ); - headingFont.setWeight( QFont::Black ); - QString linkColor = The::paletteHandler()->palette().link().color().name(); - QString textColor = The::paletteHandler()->palette().text().color().name(); - int headingWeight = 600; - - QString htmlData = "<html>"; - htmlData += "<body style=\"font-family:'" + tabFont.family() + "';"; - htmlData += "font-size:" + QString::number( tabFont.pointSize() ) + "pt;"; - htmlData += "font-weight:" + QString::number( tabFont.weight() ) + ';'; - htmlData += "color:" + textColor + ";\">"; - - // tab heading + tab source - htmlData += "<p><span style=\"font-family:'" + headingFont.family() + "';"; - htmlData += "font-size:" + QString::number( headingFont.pointSize() ) + "pt;"; - htmlData += "font-weight:" + QString::number( headingWeight ) + ";\">"; - htmlData += tab->getTabTitle(); - htmlData += " (" + i18nc( "Guitar tablature", "tab provided from: " ) + "<a href=\"" + tab->getTabUrl() + "\">"; - htmlData += "<span style=\"text-decoration: underline; color:" + linkColor + ";\">"; - htmlData += tab->getTabSource() + "</a>"; - htmlData += ")</span></p>"; - - // tab data - htmlData += tabText + "</body></html>"; - - // backup current scrollbar position - QScrollBar *vbar = m_tabTextBrowser->nativeWidget()->verticalScrollBar(); - int scrollPosition = vbar->isVisible() ? vbar->value() : vbar->minimum(); - - m_tabTextBrowser->nativeWidget()->setHtml( htmlData ); - - // re-apply scrollbar position - vbar->setSliderPosition( scrollPosition ); - } - } -} - -void -TabsView::itemClicked( const QModelIndex &index ) -{ - const QStandardItemModel *itemModel = static_cast<QStandardItemModel*>( m_treeView->model() ); - - QStandardItem *item = itemModel->itemFromIndex( index ); - TabsItem *tab = dynamic_cast<TabsItem*>( item ); - if( tab ) - showTab( tab ); -} - -void -TabsView::resizeEvent( QGraphicsSceneResizeEvent *event ) -{ - QGraphicsWidget::resizeEvent( event ); -} - -void -TabsView::slotScrollBarRangeChanged( int min, int max ) -{ - m_scrollBar->setRange( min, max ); - m_scrollBar->setPageStep( m_treeView->verticalScrollBar()->pageStep() ); - m_scrollBar->setSingleStep( m_treeView->verticalScrollBar()->singleStep() ); - updateScrollBarVisibility(); -} - -void -TabsView::updateScrollBarVisibility() -{ - QGraphicsLinearLayout *lo = static_cast<QGraphicsLinearLayout*>( layout() ); - if( m_scrollBar->maximum() == 0 ) - { - if( lo->count() > 2 && lo->itemAt( 1 ) == m_scrollBar ) - { - lo->removeAt( 1 ); - m_scrollBar->hide(); - } - } - else if( lo->count() == 2 ) - { - lo->insertItem( 1, m_scrollBar ); - m_scrollBar->show(); - } -} - - -#include "moc_TabsView.cpp" - diff --git a/amarok/src/context/applets/tabs/TabsView.h b/amarok/src/context/applets/tabs/TabsView.h deleted file mode 100644 index 758fcf4e..00000000 --- a/amarok/src/context/applets/tabs/TabsView.h +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Rainer Sigle <rainer.sigle@web.de> * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see <http://www.gnu.org/licenses/>. * - ****************************************************************************************/ - -#ifndef AMAROK_TabsVIEW_H -#define AMAROK_TabsVIEW_H - -#include <QGraphicsProxyWidget> -#include <QStandardItemModel> - -class TabsItem; -class TabsTreeView; - -class QModelIndex; -namespace Plasma -{ - class ScrollBar; - class TextBrowser; -} - -class TabsView : public QGraphicsProxyWidget -{ - Q_OBJECT - -public: - explicit TabsView( QGraphicsWidget *parent = 0 ); - ~TabsView(); - - void appendTab( TabsItem *tabsItem ); - void clear(); - void clearTabBrowser(); - -public slots: - void showTab( TabsItem *tab ); - -protected: - void resizeEvent( QGraphicsSceneResizeEvent *event ); - -private slots: - void itemClicked( const QModelIndex &index ); - void slotScrollBarRangeChanged( int min, int max ); - -private: - Plasma::TextBrowser *m_tabTextBrowser; - TabsTreeView *m_treeView; - QGraphicsProxyWidget *m_treeProxy; - QStandardItemModel *m_model; - - void updateScrollBarVisibility(); - Plasma::ScrollBar *m_scrollBar; -}; - -#endif // multiple inclusion guard diff --git a/amarok/src/context/applets/tabs/amarok-context-applet-tabs.desktop b/amarok/src/context/applets/tabs/amarok-context-applet-tabs.desktop deleted file mode 100644 index 6aca3e53..00000000 --- a/amarok/src/context/applets/tabs/amarok-context-applet-tabs.desktop +++ /dev/null @@ -1,64 +0,0 @@ -[Desktop Entry] -Name=Tabs -Name[bg]=Подпрозорци -Name[bs]=Kartice -Name[ca]=Pestanyes -Name[ca@valencia]=Pestanyes -Name[cs]=Tabulatura -Name[da]=Tabulaturer -Name[de]=Gitarrengriffe -Name[el]=Παρτιτούρες -Name[en_GB]=Tabs -Name[es]=Tablaturas -Name[et]=Tabulatuur -Name[eu]=Fitxak -Name[fa]=برگه‌ها -Name[fi]=Tabulatuurit -Name[fr]=Tablatures -Name[ga]=Cluaisíní -Name[gl]=Tablaturas -Name[hu]=Tabok -Name[id]=Tab -Name[it]=Tablature -Name[ja]=タブ -Name[km]=ផ្ទាំង -Name[lt]=Kortelės -Name[lv]=Cilnes -Name[mr]=टॅब्स -Name[nb]=Tablaturer -Name[nds]=Paneels -Name[nl]=Tabbladen -Name[pa]=ਟੈਬO -Name[pl]=Tabulatury -Name[pt]=Tablaturas -Name[pt_BR]=Tablaturas -Name[ro]=File -Name[ru]=Табулатуры -Name[sk]=Karty -Name[sl]=Zavihki -Name[sr]=Таблатуре -Name[sr@ijekavian]=Таблатуре -Name[sr@ijekavianlatin]=Tablature -Name[sr@latin]=Tablature -Name[sv]=Flikar -Name[tr]=Akorlar -Name[ug]=بەتكۈچلەر -Name[uk]=Акорди -Name[x-test]=xxTabsxx -Name[zh_CN]=吉他谱 -Name[zh_TW]=Tabs -Type=Service -Icon=filename-genre-amarok -ServiceTypes=Plasma/Applet -X-KDE-Library=amarok_context_applet_tabs -X-KDE-PluginInfo-Author=Rainer Sigle -X-KDE-PluginInfo-Email=rainer.sigle@web.de -X-KDE-PluginInfo-Name=tabs -X-KDE-PluginInfo-Version=0.1 -X-KDE-PluginInfo-Website= -X-KDE-PluginInfo-Depends= -X-KDE-PluginInfo-License=GPL -X-KDE-PluginInfo-EnabledByDefault=true -X-KDE-ParentApp=amarok -X-KDE-PluginInfo-Category=Current - diff --git a/amarok/src/context/applets/tabs/amarok-tabs-bass.png b/amarok/src/context/applets/tabs/amarok-tabs-bass.png deleted file mode 100644 index c8dfe0fa..00000000 Binary files a/amarok/src/context/applets/tabs/amarok-tabs-bass.png and /dev/null differ diff --git a/amarok/src/context/applets/tabs/amarok-tabs-drum.png b/amarok/src/context/applets/tabs/amarok-tabs-drum.png deleted file mode 100644 index e6d38098..00000000 Binary files a/amarok/src/context/applets/tabs/amarok-tabs-drum.png and /dev/null differ diff --git a/amarok/src/context/applets/tabs/amarok-tabs-guitar.png b/amarok/src/context/applets/tabs/amarok-tabs-guitar.png deleted file mode 100644 index a48f8f08..00000000 Binary files a/amarok/src/context/applets/tabs/amarok-tabs-guitar.png and /dev/null differ diff --git a/amarok/src/context/applets/tabs/amarok-tabs-piano.png b/amarok/src/context/applets/tabs/amarok-tabs-piano.png deleted file mode 100644 index b8171c54..00000000 Binary files a/amarok/src/context/applets/tabs/amarok-tabs-piano.png and /dev/null differ diff --git a/amarok/src/context/applets/upcomingevents/CMakeLists.txt b/amarok/src/context/applets/upcomingevents/CMakeLists.txt deleted file mode 100644 index a22ac5ef..00000000 --- a/amarok/src/context/applets/upcomingevents/CMakeLists.txt +++ /dev/null @@ -1,36 +0,0 @@ -project(context-upcomingevents) - -include_directories( - ${Amarok_SOURCE_DIR}/src/context/widgets - ${Amarok_SOURCE_DIR}/src/network - ${Amarok_SOURCE_DIR}/src - ) - -set(upcomingEvents_SRCS - LastFmEvent.cpp - LastFmEventXmlParser.cpp - UpcomingEventsApplet.cpp - UpcomingEventsWidget.cpp - UpcomingEventsStack.cpp - UpcomingEventsStackItem.cpp - UpcomingEventsMapWidget.cpp - UpcomingEventsCalendarWidget.cpp - upcomingEventsGeneralSettings.ui - upcomingEventsVenueSettings.ui -) - -kde4_add_plugin(amarok_context_applet_upcomingEvents ${upcomingEvents_SRCS}) - -target_link_libraries(amarok_context_applet_upcomingEvents - amarokcore - amaroklib - ${KDE4_PLASMA_LIBS} - ${KDE4_KDEUI_LIBS} - ${KDE4_KDEWEBKIT_LIBS} - ${QT_QTNETWORK_LIBRARY} - ${QT_QTWEBKIT_LIBRARY} -) - -install(TARGETS amarok_context_applet_upcomingEvents DESTINATION ${PLUGIN_INSTALL_DIR}) -install(FILES amarok-context-applet-upcomingEvents.desktop DESTINATION ${SERVICES_INSTALL_DIR}) -install(FILES upcoming-events-map.html DESTINATION ${DATA_INSTALL_DIR}/amarok/data) diff --git a/amarok/src/context/applets/upcomingevents/LastFmEvent.cpp b/amarok/src/context/applets/upcomingevents/LastFmEvent.cpp deleted file mode 100644 index de0df93e..00000000 --- a/amarok/src/context/applets/upcomingevents/LastFmEvent.cpp +++ /dev/null @@ -1,144 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Nathan Sala <sala.nathan@gmail.com> * - * Copyright (c) 2009-2010 Ludovic Deveaux <deveaux.ludovic31@gmail.com> * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see <http://www.gnu.org/licenses/>. * - ****************************************************************************************/ - -#include "LastFmEvent.h" - - -LastFmEvent::LastFmEvent() -{ - static bool metaTypeRegistered = false; - if (!metaTypeRegistered) - { - qRegisterMetaType<LastFmEvent>("LastFmEvent"); - metaTypeRegistered = true; - } -} - -LastFmEvent::LastFmEvent( const LastFmEvent& event) - : QSharedData( event ) - , m_attendance( event.m_attendance ) - , m_cancelled( event.m_cancelled ) - , m_date( event.m_date ) - , m_url( event.m_url ) - , m_imageUrls( event.m_imageUrls ) - , m_description( event.m_description ) - , m_name( event.m_name ) - , m_headliner( event.m_headliner ) - , m_participants( event.m_participants ) - , m_tags( event.m_tags ) - , m_venue( event.m_venue ) -{} - -LastFmEvent::~LastFmEvent() {} - -QStringList LastFmEvent::artists() const -{ - return QStringList() << m_headliner << m_participants; -} - -KDateTime LastFmEvent::date() const -{ - return m_date; -} - -QString LastFmEvent::name() const -{ - return m_name; -} - -KUrl LastFmEvent::url() const -{ - return m_url; -} - -void LastFmEvent::setDate( const KDateTime &date ) -{ - m_date = date; -} - -void LastFmEvent::setName( const QString &name ) -{ - m_name = name; -} - -void LastFmEvent::setUrl( const KUrl &url ) -{ - m_url = url; -} - -QString -LastFmEvent::imageSizeToString( ImageSize size ) -{ - switch( size ) - { - default: - case Small: return QString("small"); - case Medium: return QString("medium"); - case Large: return QString("large"); - case ExtraLarge: return QString("extralarge"); - case Mega: return QString("maga"); - } -} - -LastFmEvent::ImageSize -LastFmEvent::stringToImageSize( const QString &string ) -{ - if( string == "small" ) - return Small; - if( string == "medium" ) - return Medium; - if( string == "large" ) - return Large; - if( string == "extralarge" ) - return ExtraLarge; - if( string == "mega" ) - return Mega; - return Small; -} - -LastFmLocation::LastFmLocation() -{} - -LastFmLocation::~LastFmLocation() -{} - -LastFmLocation::LastFmLocation( const LastFmLocation &cpy ) - : QSharedData( cpy ) - , city( cpy.city ) - , country( cpy.country ) - , street( cpy.street ) - , postalCode( cpy.postalCode ) - , latitude( cpy.latitude ) - , longitude( cpy.longitude ) -{} - -LastFmVenue::LastFmVenue() -{} - -LastFmVenue::~LastFmVenue() -{} - -LastFmVenue::LastFmVenue( const LastFmVenue &cpy ) - : QSharedData( cpy ) - , id( cpy.id ) - , name( cpy.name ) - , url( cpy.url ) - , website( cpy.website ) - , phoneNumber( cpy.phoneNumber ) - , imageUrls( cpy.imageUrls ) - , location( cpy.location ) -{} diff --git a/amarok/src/context/applets/upcomingevents/LastFmEvent.h b/amarok/src/context/applets/upcomingevents/LastFmEvent.h deleted file mode 100644 index 50c06bc8..00000000 --- a/amarok/src/context/applets/upcomingevents/LastFmEvent.h +++ /dev/null @@ -1,290 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Nathan Sala <sala.nathan@gmail.com> * - * Copyright (c) 2009-2010 Ludovic Deveaux <deveaux.ludovic31@gmail.com> * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see <http://www.gnu.org/licenses/>. * - ****************************************************************************************/ - -#ifndef LASTFMEVENT_H -#define LASTFMEVENT_H - -#include <KDateTime> -#include <KSharedPtr> -#include <KUrl> - -#include <QSharedData> -#include <QStringList> - -class LastFmEvent; -class LastFmLocation; -class LastFmVenue; - -typedef KSharedPtr<LastFmEvent> LastFmEventPtr; -typedef KSharedPtr<LastFmVenue> LastFmVenuePtr; -typedef KSharedPtr<LastFmLocation> LastFmLocationPtr; - -/** - * A class to store an event fetched from the last.fm API - * by the request artist.getEvents - */ -class LastFmEvent : public QSharedData -{ -public: - enum ImageSize - { - Small = 0, - Medium = 1, - Large = 2, - ExtraLarge = 3, - Mega = 4 - }; - - typedef QList< LastFmEventPtr > List; - typedef QHash<ImageSize, KUrl> ImageUrls; - - /** - * Creates an empty LastFmEvent - */ - LastFmEvent(); - - /** - * Creates a copy of a LastFmEvent - * @param event the event to be copied from - */ - LastFmEvent( const LastFmEvent& ); - - /** - * Destroys a LastFmEvent instance - */ - ~LastFmEvent(); - - /** - * A getter for the artists list. - * It consists of the headliner + participants. - * @return the list of all artists participating the event - */ - QStringList artists() const; - - /** - * The number of people attending the event - * @return number of people attending the event - */ - int attendance() const - { return m_attendance; } - - /** - * A getter for the event's date - * @return the event's date - */ - KDateTime date() const; - - /** - * The event's description - * @return event's description - */ - QString description() const - { return m_description; } - - /** - * The event's headlining artist - * @return event's headlining artist - */ - QString headliner() const - { return m_headliner; } - - /** - * Gets the URL for the event's event at \p size; - * @param size size of the image - * @return image URL - */ - KUrl imageUrl( ImageSize size ) const - { return m_imageUrls.value(size); } - - /** - * Whether the event is cancelled - * @return true if the event is cancelled - */ - bool isCancelled() const - { return m_cancelled; } - - /** - * A getter for the event's name - * @return the event's name - */ - QString name() const; - - /** - * The list of participating artists (excluding the headliner) - * @return list of participating artists (excluding the headliner) - */ - QStringList participants() const - { return m_participants; } - - /** - * The List of Last.fm tags - * @return list of Last.fm tags - */ - QStringList tags() const - { return m_tags; } - - /** - * A getter for the event's page - * @return the URL to the event's page - */ - KUrl url() const; - - /** - * Get the venue associated with this event - * @return the venue - */ - LastFmVenuePtr venue() const - { return m_venue; } - - /** - * Set the number of attendance - * @param number the number of attendance - */ - void setAttendance( int number ) - { m_attendance = number; } - - /** - * Set whether the event has been cancelled - * @param isCancelled whether the event has been cancelled - */ - void setCancelled( bool isCancelled ) - { m_cancelled = isCancelled; } - - /** - * Sets the event's date - * @param date the event's date - */ - void setDate( const KDateTime &date ); - - /** - * Sets the event's description - * @param text the event's description - */ - void setDescription( const QString &text ) - { m_description = text; } - - /** - * Sets the headlining artist for this event - * @param headliner the headlining artist for this event - */ - void setHeadliner( const QString &headliner ) - { m_headliner = headliner; } - - /** - * Sets the \p url for the event's image at \p size - * @param size size of the image - * @param url url of the image - */ - void setImageUrl( ImageSize size, const KUrl &url ) - { m_imageUrls[size] = url; } - - /** - * Sets the event's name - * @param name the event's name - */ - void setName( const QString &name ); - - /** - * Sets the participating artists (excluding headliner) at this event - * @param participants artists participating at this event - */ - void setParticipants( const QStringList &participants ) - { m_participants = participants; } - - /** - * Sets the tags for this event - * @param tags the tags for this event - */ - void setTags( const QStringList &tags ) - { m_tags = tags; } - - /** - * Sets the event's page - * @param url the URL to the event's page - */ - void setUrl( const KUrl &url ); - - /** - * Sets the venue of this event - * @param venue the venue of this event - */ - void setVenue( LastFmVenuePtr venue ) { m_venue = venue; } - - /** - * Convert an ImageSize to a QString - */ - static QString imageSizeToString( ImageSize size ); - - /** - * Convert a QString to an ImageSize - */ - static ImageSize stringToImageSize( const QString &string ); - -private: - int m_attendance; //!< Number of the event's attendance - bool m_cancelled; //!< Whether the event has been cancelled - KDateTime m_date; //!< The event's start date - KUrl m_url; //!< The URL to the event's page - ImageUrls m_imageUrls; //!< URLs to the event's image - QString m_description; //!< Description of the event - QString m_name; //!< The event's name - QString m_headliner; //!< The headline artist of this event - QStringList m_participants; //!< Other artists participating in the event - QStringList m_tags; //!< Contextual tags - LastFmVenuePtr m_venue; //!< Venue info -}; - -class LastFmLocation : public QSharedData -{ -public: - LastFmLocation(); - ~LastFmLocation(); - LastFmLocation( const LastFmLocation &cpy ); - - QString city; - QString country; - QString street; - QString postalCode; - double latitude; - double longitude; -}; - -class LastFmVenue : public QSharedData -{ -public: - LastFmVenue(); - ~LastFmVenue(); - LastFmVenue( const LastFmVenue &cpy ); - - int id; - QString name; - KUrl url; - KUrl website; - QString phoneNumber; - QHash<LastFmEvent::ImageSize, KUrl> imageUrls; - LastFmLocationPtr location; -}; - -Q_DECLARE_METATYPE(LastFmEvent) -Q_DECLARE_METATYPE(LastFmEventPtr) -Q_DECLARE_METATYPE(LastFmEvent::List) -Q_DECLARE_METATYPE(LastFmLocation) -Q_DECLARE_METATYPE(LastFmLocationPtr) -Q_DECLARE_METATYPE(LastFmVenue) -Q_DECLARE_METATYPE(LastFmVenuePtr) - -#endif // LASTFMEVENT_H diff --git a/amarok/src/context/applets/upcomingevents/LastFmEventXmlParser.cpp b/amarok/src/context/applets/upcomingevents/LastFmEventXmlParser.cpp deleted file mode 100644 index 6535bb85..00000000 --- a/amarok/src/context/applets/upcomingevents/LastFmEventXmlParser.cpp +++ /dev/null @@ -1,231 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Rick W. Chen <stuffcorpse@archlinux.us> * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see <http://www.gnu.org/licenses/>. * - ****************************************************************************************/ - -#include "LastFmEventXmlParser.h" - - -LastFmEventXmlParser::LastFmEventXmlParser( QXmlStreamReader &reader ) - : m_xml( reader ) -{ -} - -LastFmEventXmlParser::~LastFmEventXmlParser() -{} - -bool -LastFmEventXmlParser::read() -{ - while( !m_xml.atEnd() && !m_xml.hasError() ) - { - m_xml.readNext(); - if( m_xml.isStartElement() && m_xml.name() == "event" ) - { - QHash<QString, QString> artists; - LastFmEventPtr event( new LastFmEvent ); - while( !m_xml.atEnd() ) - { - m_xml.readNext(); - const QStringRef &n = m_xml.name(); - if( m_xml.isEndElement() && n == "event" ) - break; - - if( m_xml.isStartElement() ) - { - const QXmlStreamAttributes &a = m_xml.attributes(); - if( n == "title" ) - event->setName( m_xml.readElementText() ); - else if( n == "artists" ) - artists = readEventArtists(); - else if( n == "venue" ) - { - LastFmVenueXmlParser venueParser( m_xml ); - if( venueParser.read() ) - event->setVenue( venueParser.venue() ); - } - else if( n == "startDate" ) - event->setDate( KDateTime::fromString( m_xml.readElementText(), "%a, %d %b %Y %H:%M:%S" ) ); - else if( n == "image" && a.hasAttribute("size") ) - event->setImageUrl( LastFmEvent::stringToImageSize(a.value("size").toString()), KUrl( m_xml.readElementText() ) ); - else if( n == "url" ) - event->setUrl( KUrl( m_xml.readElementText() ) ); - else if( n == "attendance" ) - event->setAttendance( m_xml.readElementText().toInt() ); - else if( n == "cancelled" ) - event->setCancelled( bool( m_xml.readElementText().toInt() ) ); - else if( n == "tags" ) - event->setTags( readEventTags() ); - else - m_xml.skipCurrentElement(); - } - } - event->setHeadliner( artists.value("headliner") ); - event->setParticipants( artists.values("artist") ); - m_events << event; - } - } - return !m_xml.error(); -} - -QStringList -LastFmEventXmlParser::readEventTags() -{ - QStringList tags; - while( !m_xml.atEnd() ) - { - m_xml.readNext(); - if( m_xml.isEndElement() && m_xml.name() == "tags" ) - break; - - if( m_xml.isStartElement() ) - { - if( m_xml.name() == "tag" ) - tags << m_xml.readElementText(); - else - m_xml.skipCurrentElement(); - } - } - return tags; -} - -QHash<QString, QString> -LastFmEventXmlParser::readEventArtists() -{ - QHash<QString, QString> artists; - while( !m_xml.atEnd() ) - { - m_xml.readNext(); - if( m_xml.isEndElement() && m_xml.name() == "artists" ) - break; - - if( m_xml.isStartElement() ) - { - if( m_xml.name() == "artist" ) - artists.insertMulti( "artist", m_xml.readElementText() ); - else if( m_xml.name() == "headliner" ) - artists.insert( "headliner", m_xml.readElementText() ); - else - m_xml.skipCurrentElement(); - } - } - return artists; -} - - -LastFmVenueXmlParser::LastFmVenueXmlParser( QXmlStreamReader &reader ) - : m_xml( reader ) -{} - -bool -LastFmVenueXmlParser::read() -{ - m_venue = new LastFmVenue; - while( !m_xml.atEnd() && !m_xml.hasError() ) - { - m_xml.readNext(); - const QStringRef &n = m_xml.name(); - if( m_xml.isEndElement() && n == "venue" ) - break; - - if( m_xml.isStartElement() ) - { - const QXmlStreamAttributes &a = m_xml.attributes(); - if( n == "id" ) - m_venue->id = m_xml.readElementText().toInt(); - else if( n == "name" ) - m_venue->name = m_xml.readElementText(); - else if( n == "location" ) - { - LastFmLocationXmlParser locationParser( m_xml ); - if( locationParser.read() ) - m_venue->location = locationParser.location(); - } - else if( n == "url" ) - m_venue->url = KUrl( m_xml.readElementText() ); - else if( n == "website" ) - m_venue->website = KUrl( m_xml.readElementText() ); - else if( n == "phonenumber" ) - m_venue->phoneNumber = m_xml.readElementText(); - else if( n == "image" && a.hasAttribute("size") ) - { - LastFmEvent::ImageSize size = LastFmEvent::stringToImageSize( a.value("size").toString() ); - m_venue->imageUrls[ size ] = KUrl( m_xml.readElementText() ); - } - else - m_xml.skipCurrentElement(); - } - } - return !m_xml.error(); -} - -LastFmVenueXmlParser::~LastFmVenueXmlParser() -{} - -LastFmLocationXmlParser::LastFmLocationXmlParser( QXmlStreamReader &reader ) - : m_xml( reader ) -{} - -bool -LastFmLocationXmlParser::read() -{ - m_location = new LastFmLocation; - while( !m_xml.atEnd() && !m_xml.hasError() ) - { - m_xml.readNext(); - if( m_xml.isEndElement() && m_xml.name() == "location" ) - break; - - if( m_xml.isStartElement() ) - { - if( m_xml.name() == "city" ) - m_location->city = m_xml.readElementText(); - else if( m_xml.name() == "country" ) - m_location->country = m_xml.readElementText(); - else if( m_xml.name() == "street" ) - m_location->street = m_xml.readElementText(); - else if( m_xml.name() == "postalcode" ) - m_location->postalCode = m_xml.readElementText(); - else if( m_xml.prefix() == "geo" && m_xml.name() == "point" ) - readGeoPoint(); - else - m_xml.skipCurrentElement(); - } - } - return !m_xml.error(); -} - -LastFmLocationXmlParser::~LastFmLocationXmlParser() -{} - -void -LastFmLocationXmlParser::readGeoPoint() -{ - while( !m_xml.atEnd() && !m_xml.hasError() ) - { - m_xml.readNext(); - if( m_xml.isEndElement() && m_xml.name() == "point" ) - break; - - if( m_xml.isStartElement() ) - { - if( m_xml.name() == "lat" ) - m_location->latitude = m_xml.readElementText().toDouble(); - else if( m_xml.name() == "long" ) - m_location->longitude = m_xml.readElementText().toDouble(); - else - m_xml.skipCurrentElement(); - } - } -} diff --git a/amarok/src/context/applets/upcomingevents/LastFmEventXmlParser.h b/amarok/src/context/applets/upcomingevents/LastFmEventXmlParser.h deleted file mode 100644 index 8f2e109a..00000000 --- a/amarok/src/context/applets/upcomingevents/LastFmEventXmlParser.h +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Rick W. Chen <stuffcorpse@archlinux.us> * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see <http://www.gnu.org/licenses/>. * - ****************************************************************************************/ - -#ifndef AMAROK_LASTFMEVENTXMLPARSER_H -#define AMAROK_LASTFMEVENTXMLPARSER_H - -#include "LastFmEvent.h" - -#include <QString> -#include <QtCore/qxmlstream.h> - -class LastFmEventXmlParser -{ -public: - LastFmEventXmlParser( QXmlStreamReader &reader ); - ~LastFmEventXmlParser(); - - bool read(); - LastFmEvent::List events() const { return m_events; } - LastFmEvent::List events() { return m_events; } - -private: - QHash<QString, QString> readEventArtists(); - QStringList readEventTags(); - - QXmlStreamReader &m_xml; - LastFmEvent::List m_events; - Q_DISABLE_COPY( LastFmEventXmlParser ) -}; - -class LastFmVenueXmlParser -{ -public: - LastFmVenueXmlParser( QXmlStreamReader &reader ); - ~LastFmVenueXmlParser(); - - bool read(); - LastFmVenuePtr venue() const { return m_venue; } - LastFmVenuePtr venue() { return m_venue; } - -private: - LastFmVenuePtr m_venue; - QXmlStreamReader &m_xml; - Q_DISABLE_COPY( LastFmVenueXmlParser ) -}; - -class LastFmLocationXmlParser -{ -public: - LastFmLocationXmlParser( QXmlStreamReader &reader ); - ~LastFmLocationXmlParser(); - - bool read(); - - LastFmLocationPtr location() const { return m_location; } - LastFmLocationPtr location() { return m_location; } - -private: - void readGeoPoint(); - - LastFmLocationPtr m_location; - QXmlStreamReader &m_xml; - Q_DISABLE_COPY( LastFmLocationXmlParser ) -}; - -#endif /* AMAROK_LASTFMEVENTXMLPARSER_H */ diff --git a/amarok/src/context/applets/upcomingevents/UpcomingEventsApplet.cpp b/amarok/src/context/applets/upcomingevents/UpcomingEventsApplet.cpp deleted file mode 100644 index 39427c93..00000000 --- a/amarok/src/context/applets/upcomingevents/UpcomingEventsApplet.cpp +++ /dev/null @@ -1,657 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Joffrey Clavel <jclavel@clabert.info> * - * Copyright (c) 2009 Oleksandr Khayrullin <saniokh@gmail.com> * - * Copyright (c) 2009-2010 Ludovic Deveaux <deveaux.ludovic31@gmail.com> * - * Copyright (c) 2010 Hormiere Guillaume <hormiere.guillaume@gmail.com> * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see <http://www.gnu.org/licenses/>. * - ****************************************************************************************/ - -#define DEBUG_PREFIX "UpcomingEventsApplet" - -#include "UpcomingEventsApplet.h" - -#include "amarokurls/AmarokUrl.h" -#include "context/applets/upcomingevents/LastFmEvent.h" -#include "context/widgets/AppletHeader.h" -#include "core/support/Amarok.h" -#include "core/support/Debug.h" -#include "SvgHandler.h" -#include "LastFmEventXmlParser.h" -#include "UpcomingEventsMapWidget.h" -#include "UpcomingEventsCalendarWidget.h" -#include "UpcomingEventsStack.h" -#include "UpcomingEventsStackItem.h" - -#include <KConfigDialog> -#include <KGlobalSettings> -#include <Plasma/IconWidget> -#include <Plasma/Theme> -#include <Plasma/Svg> - -#include <QDesktopServices> -#include <QGraphicsLinearLayout> -#include <QtCore/qxmlstream.h> - -UpcomingEventsApplet::UpcomingEventsApplet( QObject* parent, const QVariantList& args ) - : Context::Applet( parent, args ) - , m_groupVenues( false ) - , m_stack( 0 ) -{ - setHasConfigurationInterface( true ); - setBackgroundHints( Plasma::Applet::NoBackground ); -} - -UpcomingEventsApplet::~UpcomingEventsApplet() -{ -} - -void -UpcomingEventsApplet::init() -{ - DEBUG_BLOCK - - Context::Applet::init(); - - enableHeader( true ); - setHeaderText( i18n( "Upcoming Events" ) ); - - m_stack = new UpcomingEventsStack( this ); - m_stack->setContentsMargins( 0, 0, 0, 0 ); - - connect( m_stack, SIGNAL(collapseStateChanged()), SLOT(collapseStateChanged()) ); - connect( this, SIGNAL(listWidgetRemoved(UpcomingEventsListWidget*)), - m_stack, SLOT(cleanupListWidgets()) ); - - QAction *calendarAction = new QAction( this ); - calendarAction->setIcon( KIcon( "view-calendar" ) ); - calendarAction->setToolTip( i18n( "View Events Calendar" ) ); - Plasma::IconWidget *calendarIcon = addLeftHeaderAction( calendarAction ); - connect( calendarIcon, SIGNAL(clicked()), this, SLOT(viewCalendar()) ); - - QAction* settingsAction = new QAction( this ); - settingsAction->setIcon( KIcon( "preferences-system" ) ); - settingsAction->setToolTip( i18n( "Settings" ) ); - settingsAction->setEnabled( true ); - Plasma::IconWidget *settingsIcon = addRightHeaderAction( settingsAction ); - connect( settingsIcon, SIGNAL(clicked()), this, SLOT(configure()) ); - - m_artistStackItem = m_stack->create( QLatin1String("currentartistevents") ); - m_artistEventsList = new UpcomingEventsListWidget( m_artistStackItem ); - m_artistStackItem->setTitle( i18nc( "@title:group", "No track is currently playing" ) ); - m_artistStackItem->setWidget( m_artistEventsList ); - m_artistStackItem->setCollapsed( true ); - m_artistStackItem->setIcon( KIcon("filename-artist-amarok") ); - connect( m_artistEventsList, SIGNAL(mapRequested(QObject*)), SLOT(handleMapRequest(QObject*)) ); - - QGraphicsLinearLayout *layout = new QGraphicsLinearLayout( Qt::Vertical ); - layout->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); - layout->addItem( m_header ); - layout->addItem( m_stack ); - setLayout( layout ); - - // Read config and inform the engine. - enableVenueGrouping( Amarok::config("UpcomingEvents Applet").readEntry( "groupVenues", false ) ); - QStringList venueData = Amarok::config("UpcomingEvents Applet").readEntry( "favVenues", QStringList() ); - m_favoriteVenues = venueStringToDataList( venueData ); - - Plasma::DataEngine *engine = dataEngine( "amarok-upcomingEvents" ); - connect( engine, SIGNAL(sourceAdded(QString)), SLOT(engineSourceAdded(QString)) ); - engine->query( "artistevents" ); - engine->query( "venueevents" ); - - updateConstraints(); -} - -void -UpcomingEventsApplet::engineSourceAdded( const QString &source ) -{ - if( source == "artistevents" || source == "venueevents" ) - dataEngine( "amarok-upcomingEvents" )->connectSource( source, this ); -} - -void -UpcomingEventsApplet::constraintsEvent( Plasma::Constraints constraints ) -{ - Context::Applet::constraintsEvent( constraints ); - prepareGeometryChange(); - setHeaderText( i18n( "Upcoming Events" ) ); - update(); -} - -void -UpcomingEventsApplet::dataUpdated( const QString &source, const Plasma::DataEngine::Data &data ) -{ - const LastFmEvent::List &events = data[ "events" ].value< LastFmEvent::List >(); - if( source == "artistevents" ) - { - QString artistName = data[ "artist" ].toString(); - m_artistEventsList->clear(); - m_artistEventsList->setName( artistName ); - addToStackItem( m_artistStackItem, events, artistName ); - if( !m_artistStackItem->action( "showinmediasources" ) ) - { - QAction *act = new QAction( KIcon("edit-find"), QString(), m_artistStackItem ); - act->setToolTip( i18n( "Show in Media Sources" ) ); - connect( act, SIGNAL(triggered()), this, SLOT(navigateToArtist()) ); - m_artistStackItem->addAction( "showinmediasources", act ); - } - m_artistStackItem->setCollapsed( events.isEmpty() ); - } - else if( source == "venueevents" ) - { - if( !events.isEmpty() ) - { - LastFmVenuePtr venue = data[ "venue" ].value<LastFmVenuePtr>(); - if( m_groupVenues && m_stack->hasItem("favoritevenuesgroup") ) - { - QString title = i18n( "Favorite Venues" ); - addToStackItem( m_stack->item("favoritevenuesgroup"), events, title ); - } - else - { - UpcomingEventsStackItem *stackItem( 0 ); - UpcomingEventsListWidget *listWidget( 0 ); - LastFmEvent::List newEvents; - if( !m_stack->hasItem( venue->name ) ) - { - stackItem = m_stack->create( venue->name ); - listWidget = new UpcomingEventsListWidget( stackItem ); - listWidget->setName( venue->name ); - stackItem->setWidget( listWidget ); - stackItem->setCollapsed( true ); - stackItem->setIcon( KIcon("favorites") ); - stackItem->showCloseButton(); - connect( listWidget, SIGNAL(mapRequested(QObject*)), SLOT(handleMapRequest(QObject*)) ); - connect( listWidget, SIGNAL(destroyed(QObject*)), SLOT(listWidgetDestroyed(QObject*)) ); - emit listWidgetAdded( listWidget ); - newEvents = events; - } - else - { - stackItem = m_stack->item( venue->name ); - typedef UpcomingEventsListWidget UELW; - UELW *widget = static_cast<UELW*>( stackItem->widget() ); - newEvents = events.toSet().subtract( widget->events().toSet() ).toList(); - } - addToStackItem( stackItem, newEvents, venue->name ); - } - update(); - } - else if( m_groupVenues && m_stack->hasItem( QLatin1String("favoritevenuesgroup") ) ) - { - m_stack->remove( QLatin1String("favoritevenuesgroup" ) ); - } - else - { - // remove all venue lists - const QRegExp pattern( QLatin1String("^(?!(currentartistevents|venuemapview|calendar)).*$") ); - QList<UpcomingEventsStackItem*> eventItems = m_stack->items( pattern ); - qDeleteAll( eventItems ); - } - } -} - -void -UpcomingEventsApplet::clearVenueItems() -{ - m_stack->remove( QLatin1String("favoritevenuesgroup" ) ); - m_stack->remove( QLatin1String("venuemapview" ) ); -} - -void -UpcomingEventsApplet::addToStackItem( UpcomingEventsStackItem *item, - const LastFmEvent::List &events, - const QString &name ) -{ - UpcomingEventsListWidget *listWidget = static_cast<UpcomingEventsListWidget*>( item->widget() ); - listWidget->addEvents( events ); - - QString title; - int added = listWidget->count(); - if( added == 0 ) - { - title = name.isEmpty() ? i18n( "No upcoming events" ) : i18n( "%1: No upcoming events", name ); - } - else - { - title = name.isEmpty() - ? i18ncp( "@title:group Number of upcoming events", "1 event", "%1 events", added ) - : i18ncp( "@title:group Number of upcoming events", "%1: 1 event", "%1: %2 events", name, added ); - } - item->setTitle( title ); - item->layout()->invalidate(); -} - -void -UpcomingEventsApplet::paintInterface( QPainter *p, const QStyleOptionGraphicsItem *option, const QRect &contentsRect ) -{ - Q_UNUSED( option ) - Q_UNUSED( contentsRect ) - addGradientToAppletBackground( p ); -} - -void -UpcomingEventsApplet::configure() -{ - DEBUG_BLOCK - showConfigurationInterface(); -} - -void -UpcomingEventsApplet::createConfigurationInterface( KConfigDialog *parent ) -{ - QWidget *generalSettings = new QWidget; - QWidget *venueSettings = new QWidget; - ui_GeneralSettings.setupUi( generalSettings ); - ui_VenueSettings.setupUi( venueSettings ); - - // TODO bad, it's done manually ... - QString timeSpan = Amarok::config("UpcomingEvents Applet").readEntry( "timeSpan", "AllEvents" ); - if( timeSpan == "AllEvents" ) - ui_GeneralSettings.filterComboBox->setCurrentIndex( 0 ); - else if( timeSpan == "ThisWeek" ) - ui_GeneralSettings.filterComboBox->setCurrentIndex( 1 ); - else if( timeSpan == "ThisMonth" ) - ui_GeneralSettings.filterComboBox->setCurrentIndex( 2 ); - else if( timeSpan == "ThisYear" ) - ui_GeneralSettings.filterComboBox->setCurrentIndex( 3 ); - - connect( ui_VenueSettings.searchLineEdit, SIGNAL(returnPressed(QString)), SLOT(searchVenue(QString)) ); - connect( ui_VenueSettings.searchResultsList, SIGNAL(itemClicked(QListWidgetItem*)), SLOT(showVenueInfo(QListWidgetItem*)) ); - connect( ui_VenueSettings.selectedVenuesList, SIGNAL(itemClicked(QListWidgetItem*)), SLOT(showVenueInfo(QListWidgetItem*)) ); - connect( ui_VenueSettings.searchResultsList, SIGNAL(itemDoubleClicked(QListWidgetItem*)), SLOT(venueResultDoubleClicked(QListWidgetItem*)) ); - connect( ui_VenueSettings.selectedVenuesList, SIGNAL(itemDoubleClicked(QListWidgetItem*)), SLOT(selectedVenueDoubleClicked(QListWidgetItem*)) ); - connect( ui_VenueSettings.urlValue, SIGNAL(leftClickedUrl(QString)), SLOT(openUrl(QString)) ); - connect( ui_VenueSettings.urlValue, SIGNAL(rightClickedUrl(QString)), SLOT(openUrl(QString)) ); - connect( ui_VenueSettings.websiteValue, SIGNAL(leftClickedUrl(QString)), SLOT(openUrl(QString)) ); - connect( ui_VenueSettings.websiteValue, SIGNAL(rightClickedUrl(QString)), SLOT(openUrl(QString)) ); - connect( parent, SIGNAL(okClicked()), SLOT(saveSettings()) ); - - ui_VenueSettings.photoLabel->hide(); - ui_VenueSettings.infoGroupBox->setFont( KGlobalSettings::smallestReadableFont() ); - ui_GeneralSettings.groupVenueCheckBox->setCheckState( m_groupVenues ? Qt::Checked : Qt::Unchecked ); - - ui_VenueSettings.countryCombo->insertSeparator( 1 ); - const QStringList &countryCodes = KGlobal::locale()->allCountriesList(); - foreach( const QString &code, countryCodes ) - ui_VenueSettings.countryCombo->addItem( KGlobal::locale()->countryCodeToName(code), code ); - - foreach( const VenueData &data, m_favoriteVenues ) - { - QListWidgetItem *item = new QListWidgetItem; - item->setData( VenueIdRole, data.id ); - item->setData( VenueCityRole, data.city ); - item->setData( VenueNameRole, data.name ); - item->setText( QString( "%1, %2" ) - .arg( item->data( VenueNameRole ).toString() ) - .arg( item->data( VenueCityRole ).toString() ) ); - ui_VenueSettings.selectedVenuesList->addItem( item ); - } - - parent->addPage( generalSettings, i18n( "Upcoming Events Settings" ), "preferences-system"); - parent->addPage( venueSettings, i18n( "Favorite Venues" ), "favorites" ); -} - -void -UpcomingEventsApplet::venueResultDoubleClicked( QListWidgetItem *item ) -{ - if( !item ) - return; - - int row = ui_VenueSettings.searchResultsList->row( item ); - QListWidgetItem *moveItem = ui_VenueSettings.searchResultsList->takeItem( row ); - ui_VenueSettings.searchResultsList->clearSelection(); - ui_VenueSettings.selectedVenuesList->addItem( moveItem ); - ui_VenueSettings.selectedVenuesList->setCurrentItem( moveItem ); -} - -void -UpcomingEventsApplet::selectedVenueDoubleClicked( QListWidgetItem *item ) -{ - if( !item ) - return; - - int row = ui_VenueSettings.selectedVenuesList->row( item ); - QListWidgetItem *moveItem = ui_VenueSettings.selectedVenuesList->takeItem( row ); - ui_VenueSettings.selectedVenuesList->clearSelection(); - ui_VenueSettings.searchResultsList->addItem( moveItem ); - ui_VenueSettings.searchResultsList->setCurrentItem( moveItem ); -} - -void -UpcomingEventsApplet::showVenueInfo( QListWidgetItem *item ) -{ - if( !item ) - return; - - const QString &name = item->data( VenueNameRole ).toString(); - const QString &city = item->data( VenueCityRole ).toString(); - const QString &country = item->data( VenueCountryRole ).toString(); - const QString &street = item->data( VenueStreetRole ).toString(); - const KUrl &url = item->data( VenueUrlRole ).value<KUrl>(); - const KUrl &website = item->data( VenueWebsiteRole ).value<KUrl>(); - const KUrl &photoUrl = item->data( VenuePhotoUrlRole ).value<KUrl>(); - - ui_VenueSettings.nameValue->setText( name ); - ui_VenueSettings.cityValue->setText( city ); - ui_VenueSettings.countryValue->setText( country ); - ui_VenueSettings.streetValue->setText( street ); - - if( url.isValid() ) - { - ui_VenueSettings.urlValue->setText( i18nc("@label:textbox Url label", "link") ); - ui_VenueSettings.urlValue->setTipText( url.url() ); - ui_VenueSettings.urlValue->setUrl( url.url() ); - } - else - ui_VenueSettings.urlValue->clear(); - - if( website.isValid() ) - { - ui_VenueSettings.websiteValue->setText( i18nc("@label:textbox Url label", "link") ); - ui_VenueSettings.websiteValue->setTipText( website.url() ); - ui_VenueSettings.websiteValue->setUrl( website.url() ); - } - else - ui_VenueSettings.websiteValue->clear(); - - if( photoUrl.isValid() ) - { - The::networkAccessManager()->getData( photoUrl, this, - SLOT(venuePhotoResult(KUrl,QByteArray,NetworkAccessManagerProxy::Error)) ); - } - else - { - ui_VenueSettings.photoLabel->hide(); - ui_VenueSettings.photoLabel->clear(); - } -} - -void -UpcomingEventsApplet::searchVenue( const QString &text ) -{ - KUrl url; - url.setScheme( "http" ); - url.setHost( "ws.audioscrobbler.com" ); - url.setPath( "/2.0/" ); - url.addQueryItem( "method", "venue.search" ); - url.addQueryItem( "api_key", Amarok::lastfmApiKey() ); - url.addQueryItem( "venue", text ); - int currentCountryIndex = ui_VenueSettings.countryCombo->currentIndex(); - const QString &countryCode = ui_VenueSettings.countryCombo->itemData( currentCountryIndex ).toString(); - if( !countryCode.isEmpty() ) - url.addQueryItem( "country", countryCode ); - The::networkAccessManager()->getData( url, this, - SLOT(venueResults(KUrl,QByteArray,NetworkAccessManagerProxy::Error)) ); -} - -void -UpcomingEventsApplet::venueResults( const KUrl &url, QByteArray data, NetworkAccessManagerProxy::Error e ) -{ - Q_UNUSED( url ) - if( e.code != QNetworkReply::NoError ) - { - debug() << "Failed to get venue results:" << e.description; - return; - } - - ui_VenueSettings.searchResultsList->clear(); - QXmlStreamReader xml( data ); - while( !xml.atEnd() ) - { - xml.readNext(); - if( xml.isStartElement() && xml.name() == "venue" ) - { - LastFmVenueXmlParser venueParser( xml ); - if( venueParser.read() ) - { - QListWidgetItem *item = new QListWidgetItem; - - LastFmVenuePtr venue = venueParser.venue(); - item->setData( VenueIdRole, venue->id ); - item->setData( VenueNameRole, venue->name ); - item->setData( VenuePhotoUrlRole, venue->imageUrls[LastFmEvent::Large] ); - item->setData( VenueUrlRole, venue->url ); - item->setData( VenueWebsiteRole, venue->website ); - - LastFmLocationPtr location = venue->location; - item->setData( VenueCityRole, location->city ); - item->setData( VenueCountryRole, location->country ); - item->setData( VenueStreetRole, location->street ); - - item->setText( QString( "%1, %2" ) - .arg( item->data( VenueNameRole ).toString() ) - .arg( item->data( VenueCityRole ).toString() ) ); - ui_VenueSettings.searchResultsList->addItem( item ); - } - } - } -} - -void -UpcomingEventsApplet::venuePhotoResult( const KUrl &url, QByteArray data, NetworkAccessManagerProxy::Error e ) -{ - Q_UNUSED( url ) - if( e.code != QNetworkReply::NoError ) - { - debug() << "Failed to get venue photo:" << e.description; - return; - } - - QPixmap photo; - if( photo.loadFromData( data ) ) - { - photo = photo.scaled( 140, 140, Qt::KeepAspectRatio, Qt::SmoothTransformation ); - photo = The::svgHandler()->addBordersToPixmap( photo, 5, QString(), true ); - ui_VenueSettings.photoLabel->setPixmap( photo ); - ui_VenueSettings.photoLabel->show(); - } -} - -QList<UpcomingEventsApplet::VenueData> -UpcomingEventsApplet::venueStringToDataList( const QStringList &list ) -{ - // config qstringlist is stored as format: QString(id;name;city), QString(id;name;city), ... - QList<VenueData> dataList; - foreach( const QString &item, list ) - { - const QStringList &frag = item.split( QChar(';') ); - VenueData data = { frag.at( 0 ).toInt(), frag.at( 1 ), frag.at( 2 ) }; - dataList << data; - } - return dataList; -} - -void -UpcomingEventsApplet::openUrl( const QString &url ) -{ - QDesktopServices::openUrl( QUrl(url) ); -} - -UpcomingEventsMapWidget * -UpcomingEventsApplet::mapView() -{ - if( m_stack->hasItem("venuemapview") ) - { - UpcomingEventsStackItem *item = m_stack->item( "venuemapview" ); - return static_cast<UpcomingEventsMapWidget*>( item->widget() ); - } - - UpcomingEventsStackItem *stackItem = m_stack->create( QLatin1String("venuemapview") ); - UpcomingEventsMapWidget *view = new UpcomingEventsMapWidget( stackItem ); - stackItem->setIcon( KIcon( "edit-find" ) ); - stackItem->setTitle( i18n( "Map View" ) ); - stackItem->setWidget( view ); - stackItem->setMinimumWidth( 50 ); - stackItem->showCloseButton(); - m_stack->setMinimumWidth( 50 ); - const QRegExp pattern( QLatin1String("^(?!(venuemapview|calendar)).*$") ); - QList<UpcomingEventsStackItem*> eventItems = m_stack->items( pattern ); - foreach( UpcomingEventsStackItem *item, eventItems ) - { - typedef UpcomingEventsListWidget LW; - if( item ) - view->addEventsListWidget( qgraphicsitem_cast<LW*>( item->widget() ) ); - } - connect( this, SIGNAL(listWidgetAdded(UpcomingEventsListWidget*)), - view, SLOT(addEventsListWidget(UpcomingEventsListWidget*)) ); - connect( this, SIGNAL(listWidgetRemoved(UpcomingEventsListWidget*)), - view, SLOT(removeEventsListWidget(UpcomingEventsListWidget*)) ); - return view; -} - -void -UpcomingEventsApplet::collapseStateChanged() -{ - emit sizeHintChanged( Qt::PreferredSize ); -} - -void -UpcomingEventsApplet::viewCalendar() -{ - if( m_stack->hasItem("calendar") ) - { - m_stack->item("calendar")->setCollapsed( false ); - return; - } - - UpcomingEventsStackItem *stackItem = m_stack->create( QLatin1String("calendar") ); - UpcomingEventsCalendarWidget *calendar = new UpcomingEventsCalendarWidget( stackItem ); - stackItem->setIcon( KIcon( "view-calendar" ) ); - stackItem->setTitle( i18n( "Events Calendar" ) ); - stackItem->setWidget( calendar ); - stackItem->setMinimumWidth( 50 ); - stackItem->showCloseButton(); - stackItem->addAction( "jumptotoday", calendar->todayAction() ); - const QRegExp pattern( QLatin1String("^(?!(venuemapview|calendar)).*$") ); - QList<UpcomingEventsStackItem*> eventItems = m_stack->items( pattern ); - foreach( UpcomingEventsStackItem *item, eventItems ) - { - typedef UpcomingEventsListWidget LW; - if( item ) - calendar->addEvents( qgraphicsitem_cast<LW*>( item->widget() )->events() ); - } -} - -QString -UpcomingEventsApplet::currentTimeSpan() -{ - QString span = ui_GeneralSettings.filterComboBox->currentText(); - if( span == i18n("This week") ) - return "ThisWeek"; - else if( span == i18n("This month") ) - return "ThisMonth"; - else if( span == i18n("This year") ) - return "ThisYear"; - else - return "AllEvents"; -} - -void -UpcomingEventsApplet::navigateToArtist() -{ - if( m_artistEventsList->name().isEmpty() ) - return; - - AmarokUrl url; - url.setCommand( "navigate" ); - url.setPath( "collections" ); - url.setArg( "filter", "artist:\"" + m_artistEventsList->name() + "\"" ); - url.run(); -} - -void -UpcomingEventsApplet::handleMapRequest( QObject *widget ) -{ - if( !mapView()->isLoaded() ) - { - UpcomingEventsWidget *eventWidget = static_cast<UpcomingEventsWidget*>( widget ); - LastFmVenuePtr venue = eventWidget->eventPtr()->venue(); - mapView()->centerAt( venue ); - m_stack->maximizeItem( QLatin1String("venuemapview") ); - } -} - -void -UpcomingEventsApplet::listWidgetDestroyed( QObject *obj ) -{ - UpcomingEventsListWidget *widget = static_cast<UpcomingEventsListWidget*>( obj ); - emit listWidgetRemoved( widget ); -} - -void -UpcomingEventsApplet::saveTimeSpan() -{ - DEBUG_BLOCK - Amarok::config("UpcomingEvents Applet").writeEntry( "timeSpan", currentTimeSpan() ); - dataEngine( "amarok-upcomingEvents" )->query( QString( "timespan:update" ) ); -} - -void -UpcomingEventsApplet::saveSettings() -{ - clearVenueItems(); - saveTimeSpan(); - - // save venue settings - QStringList venueConfig; - m_favoriteVenues.clear(); - for( int i = 0, count = ui_VenueSettings.selectedVenuesList->count() ; i < count; ++i ) - { - int itemId = ui_VenueSettings.selectedVenuesList->item( i )->data( VenueIdRole ).toString().toInt(); - QString itemCity = ui_VenueSettings.selectedVenuesList->item( i )->data( VenueCityRole ).toString(); - QString itemName = ui_VenueSettings.selectedVenuesList->item( i )->data( VenueNameRole ).toString(); - VenueData data = { itemId, itemName, itemCity }; - m_favoriteVenues << data; - venueConfig << (QStringList() << QString::number(itemId) << itemName << itemCity).join( QChar(';') ); - } - Amarok::config("UpcomingEvents Applet").writeEntry( "favVenues", venueConfig ); - - enableVenueGrouping( ui_GeneralSettings.groupVenueCheckBox->checkState() == Qt::Checked ); - Amarok::config("UpcomingEvents Applet").writeEntry( "groupVenues", m_groupVenues ); - - if( !m_favoriteVenues.isEmpty() ) - dataEngine( "amarok-upcomingEvents" )->query( "venueevents:update" ); -} - -void -UpcomingEventsApplet::enableVenueGrouping( bool enable ) -{ - m_groupVenues = enable; - if( enable ) - { - if( !m_stack->hasItem("favoritevenuesgroup") ) - { - UpcomingEventsStackItem *item = m_stack->create( QLatin1String("favoritevenuesgroup") ); - UpcomingEventsListWidget *listWidget = new UpcomingEventsListWidget( item ); - listWidget->setName( i18nc( "@title:group", "Favorite Venues" ) ); - QString title = i18ncp("@title:group Number of upcoming events", - "%1: 1 event", "%1: %2 events", - listWidget->name(), listWidget->count()); - item->setTitle( title ); - item->setIcon( "favorites" ); - item->setWidget( listWidget ); - connect( listWidget, SIGNAL(mapRequested(QObject*)), SLOT(handleMapRequest(QObject*)) ); - connect( listWidget, SIGNAL(destroyed(QObject*)), SLOT(listWidgetDestroyed(QObject*)) ); - emit listWidgetAdded( listWidget ); - } - } - else - { - m_stack->remove( QLatin1String("favoritevenuesgroup" ) ); - } - updateConstraints(); -} - -#include "moc_UpcomingEventsApplet.cpp" diff --git a/amarok/src/context/applets/upcomingevents/UpcomingEventsApplet.h b/amarok/src/context/applets/upcomingevents/UpcomingEventsApplet.h deleted file mode 100644 index 8f9bb941..00000000 --- a/amarok/src/context/applets/upcomingevents/UpcomingEventsApplet.h +++ /dev/null @@ -1,224 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Joffrey Clavel <jclavel@clabert.info> * - * Copyright (c) 2009 Oleksandr Khayrullin <saniokh@gmail.com> * - * Copyright (c) 2009-2010 Ludovic Deveaux <deveaux.ludovic31@gmail.com> * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see <http://www.gnu.org/licenses/>. * - ****************************************************************************************/ - -#ifndef UPCOMING_EVENTS_APPLET_H -#define UPCOMING_EVENTS_APPLET_H - -// Includes -#include "context/Applet.h" -#include "context/DataEngine.h" -#include "network/NetworkAccessManagerProxy.h" -#include "UpcomingEventsWidget.h" -#include "ui_upcomingEventsGeneralSettings.h" -#include "ui_upcomingEventsVenueSettings.h" - -class KConfigDialog; -class QGraphicsLinearLayout; -class QListWidgetItem; -class QXmlStreamReader; -class UpcomingEventsMapWidget; -class UpcomingEventsStackItem; -class UpcomingEventsStack; - -namespace Plasma -{ - class WebView; -} - - /** - * \class UpcomingEventsApplet UpcomingEventsApplet.h UpcomingEventsApplet.cpp - * \brief The base class of the Upcoming Events applet. - * - * UpcomingEventsApplet displays the upcoming events of the current artist from LastFm. - */ -class UpcomingEventsApplet : public Context::Applet -{ - Q_OBJECT - -public: - /** - * \brief Constructor - * - * UpcomingEventsApplet constructor - * - * \param parent : the UpcomingEventsApplet parent (used by Context::Applet) - * \param args : (used by Context::Applet) - */ - UpcomingEventsApplet( QObject* parent, const QVariantList& args ); - - virtual ~UpcomingEventsApplet(); - - /** - * \brief Paints the interface - * - * This method is called when the interface should be painted - * - * \param painter : the QPainter to use to do the paintiner - * \param option : the style options object - * \param contentsRect : the rect to paint within; automatically adjusted for - * the background, if any - */ - void paintInterface( QPainter *painter, const QStyleOptionGraphicsItem* option, const QRect& contentsRect ); - - /** - * Called when any of the geometry constraints have been updated. - * - * This is always called prior to painting and should be used as an - * opportunity to layout the widget, calculate sizings, etc. - * - * Do not call update() from this method; an update() will be triggered - * at the appropriate time for the applet. - * - * \param constraints : the type of constraints that were updated - */ - void constraintsEvent( Plasma::Constraints constraints = Plasma::AllConstraints ); - -signals: - void listWidgetAdded( UpcomingEventsListWidget *widget ); - void listWidgetRemoved( UpcomingEventsListWidget *widget ); - -protected: - /** - * Reimplement this method so provide a configuration interface, - * parented to the supplied widget. Ownership of the widgets is passed - * to the parent widget. - * - * \param parent : the dialog which is the parent of the configuration - * widgets - */ - void createConfigurationInterface(KConfigDialog *parent); - -public slots: - /** - * \brief Initialization - * - * Initializes the UpcomingEventsApplet with default parameters - */ - virtual void init(); - - /** - * Updates the data from the Upcoming Events engine - * - * \param name : the name - * \param data : the engine from where the data are received - */ - void dataUpdated( const QString& name, const Plasma::DataEngine::Data& data ); - -private: - /** - * The UI of the general settings page - */ - Ui::upcomingEventsGeneralSettings ui_GeneralSettings; - - /** - * The UI of the sticky venue settings page - */ - Ui::upcomingEventsVenueSettings ui_VenueSettings; - - /** - * The stack item for the upcoming events for the current playing artist - */ - UpcomingEventsStackItem *m_artistStackItem; - - /** - * The list widget presenting upcoming events - */ - UpcomingEventsListWidget *m_artistEventsList; - -private slots: - /** - * Connects the source to the Upcoming Events engine - * and calls the dataUpdated function - */ - void engineSourceAdded( const QString &source ); - - /** - * Show the settings windows - */ - void configure(); - - /** - * Returns the current time span - */ - QString currentTimeSpan(); - - /** - * Save the time span chosen by the user - */ - void saveTimeSpan(); - - /** - * Save all the upcoming events settings - */ - void saveSettings(); - - /** - * Show in media sources slot - */ - void navigateToArtist(); - -private: - enum VenueItemRoles - { - VenueIdRole = Qt::UserRole, - VenueNameRole, - VenueCityRole, - VenueCountryRole, - VenueStreetRole, - VenuePhotoUrlRole, - VenueUrlRole, - VenueWebsiteRole - }; - - struct VenueData - { - int id; - QString name; - QString city; - }; - - void clearVenueItems(); - void addToStackItem( UpcomingEventsStackItem *item, - const LastFmEvent::List &events, - const QString &name ); - QList<VenueData> venueStringToDataList( const QStringList &list ); - QList<VenueData> m_favoriteVenues; - - void enableVenueGrouping( bool enable ); - bool m_groupVenues; - - UpcomingEventsStack *m_stack; - UpcomingEventsMapWidget *mapView(); - -private slots: - void searchVenue( const QString &text ); - void venueResults( const KUrl &url, QByteArray data, NetworkAccessManagerProxy::Error e ); - void venuePhotoResult( const KUrl &url, QByteArray data, NetworkAccessManagerProxy::Error e ); - void showVenueInfo( QListWidgetItem *item ); - void venueResultDoubleClicked( QListWidgetItem *item ); - void selectedVenueDoubleClicked( QListWidgetItem *item ); - void handleMapRequest( QObject *widget ); - void listWidgetDestroyed( QObject *obj ); - void openUrl( const QString &url ); - void collapseStateChanged(); - void viewCalendar(); -}; - -AMAROK_EXPORT_APPLET( upcomingEvents, UpcomingEventsApplet ) - -#endif // UPCOMINGEVENTSAPPLET_H diff --git a/amarok/src/context/applets/upcomingevents/UpcomingEventsCalendarWidget.cpp b/amarok/src/context/applets/upcomingevents/UpcomingEventsCalendarWidget.cpp deleted file mode 100644 index f462e37a..00000000 --- a/amarok/src/context/applets/upcomingevents/UpcomingEventsCalendarWidget.cpp +++ /dev/null @@ -1,180 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Rick W. Chen <stuffcorpse@archlinux.us> * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see <http://www.gnu.org/licenses/>. * - ****************************************************************************************/ - -#include "UpcomingEventsCalendarWidget.h" -#include "PaletteHandler.h" - -#include <KColorUtils> -#include <KDateTime> -#include <KGlobal> -#include <KIcon> -#include <KLocale> -#include <KSystemTimeZones> - -#include <QAction> -#include <QCalendarWidget> -#include <QtGui/qtextformat.h> -#include <QTimer> - -class UpcomingEventsCalendarWidgetPrivate -{ -public: - UpcomingEventsCalendarWidgetPrivate( UpcomingEventsCalendarWidget* parent ) - : todayAction( 0 ) - , q_ptr( parent ) - { - calendar = new QCalendarWidget; - calendar->setGridVisible( true ); - calendar->setNavigationBarVisible( true ); - calendar->setFirstDayOfWeek( Qt::DayOfWeek(KGlobal::locale()->weekStartDay()) ); - } - - ~UpcomingEventsCalendarWidgetPrivate() {} - - void addEvent( const LastFmEventPtr &e ) - { - events << e; - QDate dt = e->date().date(); - QTextCharFormat format = calendar->dateTextFormat( dt ); - format.setFontUnderline( true ); - format.setToolTip( e->name() ); - format.setBackground( eventBackground ); - calendar->setDateTextFormat( dt, format ); - } - - void addEvents( const LastFmEvent::List &e ) - { - QSet<LastFmEventPtr> newEvents = e.toSet().subtract( events ); - foreach( const LastFmEventPtr &event, newEvents ) - addEvent( event ); - } - - void _updateToday() - { - Q_Q( UpcomingEventsCalendarWidget ); - QDateTime now = QDateTime::currentDateTime(); - int updateIn = (24 * 60 * 60) - (now.toTime_t() + KSystemTimeZones::local().currentOffset()) % (24 * 60 * 60); - QTimer::singleShot( updateIn * 1000, q, SLOT(_updateToday()) ); - - if( !todayDate.isNull() ) - { - QTextCharFormat format = calendar->dateTextFormat( todayDate ); - format.setFontWeight( QFont::Normal ); - calendar->setDateTextFormat( todayDate, format ); - } - - todayDate = now.date(); - QTextCharFormat format = calendar->dateTextFormat( todayDate ); - format.setFontWeight( QFont::Bold ); - calendar->setDateTextFormat( todayDate, format ); - } - - void _jumpToToday() - { - calendar->showToday(); - calendar->setSelectedDate( todayDate ); - } - - void _paletteChanged( const QPalette &palette ) - { - QColor base = palette.color( QPalette::Base ); - QColor high = palette.color( QPalette::Highlight ); - eventBackground = QBrush( KColorUtils::tint( base, high, 0.4 ) ); - - QList<QDate> eventDates; - foreach( const LastFmEventPtr &event, events ) - eventDates << event->date().date(); - - foreach( const QDate &date, eventDates ) - { - QTextCharFormat format = calendar->dateTextFormat( date ); - format.setBackground( eventBackground ); - calendar->setDateTextFormat( date, format ); - } - } - - QAction *todayAction; - QDate todayDate; - QBrush eventBackground; - QCalendarWidget *calendar; - QSet<LastFmEventPtr> events; - -private: - UpcomingEventsCalendarWidget *const q_ptr; - Q_DECLARE_PUBLIC( UpcomingEventsCalendarWidget ) -}; - -UpcomingEventsCalendarWidget::UpcomingEventsCalendarWidget( QGraphicsItem *parent, Qt::WindowFlags wFlags ) - : QGraphicsProxyWidget( parent, wFlags ) - , d_ptr( new UpcomingEventsCalendarWidgetPrivate( this ) ) -{ - Q_D( UpcomingEventsCalendarWidget ); - setWidget( d->calendar ); - QColor base = The::paletteHandler()->palette().color( QPalette::Base ); - QColor high = The::paletteHandler()->palette().color( QPalette::Highlight ); - d->eventBackground = QBrush( KColorUtils::tint( base, high, 0.4 ) ); - d->_updateToday(); - connect( The::paletteHandler(), SIGNAL(newPalette(QPalette)), SLOT(_paletteChanged(QPalette)) ); -} - -UpcomingEventsCalendarWidget::~UpcomingEventsCalendarWidget() -{ - delete d_ptr; -} - -void -UpcomingEventsCalendarWidget::clear() -{ - Q_D( UpcomingEventsCalendarWidget ); - d->calendar->setDateTextFormat( QDate(), QTextCharFormat() ); - d->events.clear(); -} - -LastFmEvent::List -UpcomingEventsCalendarWidget::events() const -{ - Q_D( const UpcomingEventsCalendarWidget ); - return d->events.toList(); -} - -QAction * -UpcomingEventsCalendarWidget::todayAction() -{ - Q_D( UpcomingEventsCalendarWidget ); - if( !d->todayAction ) - { - d->todayAction = new QAction( KIcon("go-jump-today"), QString(), this ); - d->todayAction->setToolTip( i18nc( "@info:tooltip Calendar action", "Jump to Today" ) ); - connect( d->todayAction, SIGNAL(triggered()), SLOT(_jumpToToday()) ); - } - return d->todayAction; -} - -void -UpcomingEventsCalendarWidget::addEvent( const LastFmEventPtr &event ) -{ - Q_D( UpcomingEventsCalendarWidget ); - d->addEvent( event ); -} - -void -UpcomingEventsCalendarWidget::addEvents( const LastFmEvent::List &events ) -{ - Q_D( UpcomingEventsCalendarWidget ); - d->addEvents( events ); -} - -#include "moc_UpcomingEventsCalendarWidget.cpp" diff --git a/amarok/src/context/applets/upcomingevents/UpcomingEventsCalendarWidget.h b/amarok/src/context/applets/upcomingevents/UpcomingEventsCalendarWidget.h deleted file mode 100644 index 5d5fc052..00000000 --- a/amarok/src/context/applets/upcomingevents/UpcomingEventsCalendarWidget.h +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Rick W. Chen <stuffcorpse@archlinux.us> * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see <http://www.gnu.org/licenses/>. * - ****************************************************************************************/ - -#ifndef AMAROK_UPCOMINGEVENTSCALENDARWIDGET_H -#define AMAROK_UPCOMINGEVENTSCALENDARWIDGET_H - -#include "LastFmEvent.h" - -#include <QGraphicsProxyWidget> - -class UpcomingEventsCalendarWidgetPrivate; - -class UpcomingEventsCalendarWidget : public QGraphicsProxyWidget -{ - Q_OBJECT - Q_PROPERTY( LastFmEvent::List events READ events ) - Q_PROPERTY( QAction* todayAction READ todayAction ) - -public: - UpcomingEventsCalendarWidget( QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0 ); - ~UpcomingEventsCalendarWidget(); - - void clear(); - LastFmEvent::List events() const; - QAction *todayAction(); - -public slots: - void addEvent( const LastFmEventPtr &event ); - void addEvents( const LastFmEvent::List &events ); - -private: - UpcomingEventsCalendarWidgetPrivate *const d_ptr; - Q_DECLARE_PRIVATE( UpcomingEventsCalendarWidget ) - Q_DISABLE_COPY( UpcomingEventsCalendarWidget ) - - Q_PRIVATE_SLOT( d_ptr, void _paletteChanged(QPalette) ) - Q_PRIVATE_SLOT( d_ptr, void _jumpToToday() ) - Q_PRIVATE_SLOT( d_ptr, void _updateToday() ) -}; - -#endif /* AMAROK_UPCOMINGEVENTSCALENDARWIDGET_H */ diff --git a/amarok/src/context/applets/upcomingevents/UpcomingEventsMapWidget.cpp b/amarok/src/context/applets/upcomingevents/UpcomingEventsMapWidget.cpp deleted file mode 100644 index 52ea65d4..00000000 --- a/amarok/src/context/applets/upcomingevents/UpcomingEventsMapWidget.cpp +++ /dev/null @@ -1,356 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Rick W. Chen <stuffcorpse@archlinux.us> * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see <http://www.gnu.org/licenses/>. * - ****************************************************************************************/ - -#include "UpcomingEventsMapWidget.h" -#include "UpcomingEventsWidget.h" -#include "network/NetworkAccessManagerProxy.h" - -#include <KLocale> -#include <KStandardDirs> - -#include <QDesktopServices> -#include <QFile> -#include <QFileInfo> -#include <QTimer> -#include <QWebView> -#include <QWebFrame> - -class UpcomingEventsMapWidgetPrivate -{ -public: - UpcomingEventsMapWidgetPrivate( UpcomingEventsMapWidget *parent ); - ~UpcomingEventsMapWidgetPrivate(); - - void addEvent( const LastFmEventPtr &event ); - void addMarker( const LastFmEventPtr &event ); - QString createInfoString( const LastFmEventPtr &event ) const; - KUrl eventForMapIcon( const LastFmEventPtr &event ) const; - void removeEvent( const LastFmEventPtr &event ); - void removeMarker( const LastFmEventPtr &event ); - - void _init(); - void _linkClicked( const QUrl &url ); - void _loadFinished( bool success ); - void _centerAt( QObject *obj ); - - LastFmEvent::List events; - LastFmEvent::List eventQueue; - QSet<UpcomingEventsListWidget*> listWidgets; - QPointF centerWhenLoaded; - bool isLoaded; - -private: - UpcomingEventsMapWidget *const q_ptr; - Q_DECLARE_PUBLIC( UpcomingEventsMapWidget ) -}; - -UpcomingEventsMapWidgetPrivate::UpcomingEventsMapWidgetPrivate( UpcomingEventsMapWidget *parent ) - : isLoaded( false ) - , q_ptr( parent ) -{ -} - -UpcomingEventsMapWidgetPrivate::~UpcomingEventsMapWidgetPrivate() -{ -} - -void -UpcomingEventsMapWidgetPrivate::addEvent( const LastFmEventPtr &event ) -{ - if( !isLoaded ) - { - eventQueue << event; - return; - } - events << event; - addMarker( event ); -} - -void -UpcomingEventsMapWidgetPrivate::addMarker( const LastFmEventPtr &event ) -{ - Q_Q( UpcomingEventsMapWidget ); - LastFmLocationPtr loc = event->venue()->location; - QString js = QString( "javascript:addMarker(%1,%2,'%3','%4')" ) - .arg( QString::number( loc->latitude ) ) - .arg( QString::number( loc->longitude ) ) - .arg( eventForMapIcon(event).url() ) - .arg( createInfoString(event) ); - q->page()->mainFrame()->evaluateJavaScript( js ); -} - -void -UpcomingEventsMapWidgetPrivate::removeEvent( const LastFmEventPtr &event ) -{ - eventQueue.removeAll( event ); - if( isLoaded ) - { - events.removeAll( event ); - removeMarker( event ); - } -} - -void -UpcomingEventsMapWidgetPrivate::removeMarker( const LastFmEventPtr &event ) -{ - Q_Q( UpcomingEventsMapWidget ); - LastFmLocationPtr loc = event->venue()->location; - QString js = QString( "javascript:removeMarker(%1,%2)" ) - .arg( QString::number( loc->latitude ) ) - .arg( QString::number( loc->longitude ) ); - q->page()->mainFrame()->evaluateJavaScript( js ); -} - -QString -UpcomingEventsMapWidgetPrivate::createInfoString( const LastFmEventPtr &event ) const -{ - QString name = event->name(); - if( event->isCancelled() ) - name = i18nc( "@label:textbox Title for a canceled upcoming event", "<s>%1</s> (Canceled)", name ); - - QStringList artists = event->artists(); - artists.removeDuplicates(); - - QString desc = event->description(); - KDateTime dt = event->date(); - QStringList tags = event->tags(); - LastFmVenuePtr venue = event->venue(); - QString venueWebsite = venue->website.url(); - QString venueLastFmUrl = venue->url.url(); - QString location = venue->location->city; - if( !venue->location->street.isEmpty() ) - location.prepend( venue->location->street + ", " ); - - QString html = QString( - "<div><img src=\"%1\" alt=\"\" style=\"float:right;margin:5px;clear:right\"/></div>" \ - "<div><img src=\"%2\" alt=\"\" style=\"float:right;margin:5px;clear:right\"/></div>" \ - "<div id=\"bodyContent\">" \ - "<small>" \ - "<b>Event:</b> %3<br/>" \ - "<b>Artists:</b> %4<br/>" \ - "<b>Time:</b> %5<br/>" \ - "<b>Date:</b> %6<br/>" \ - "<b>Venue:</b> %7<br/>" \ - "<b>Location:</b> %8<br/>" \ - "<b>Description:</b> %9<br/>" \ - "<b>Tags:</b> %10<br/>" \ - "<b>Event Website:</b> <a href=\"%11\">Last.fm</a><br/>" \ - "<b>Venue Website:</b> <a href=\"%12\">URL</a>, <a href=\"%13\">Last.fm</a><br/>" \ - "</small>" \ - "</div>") - .arg( event->imageUrl(LastFmEvent::Medium).url() ) - .arg( venue->imageUrls[LastFmEvent::Medium].url() ) - .arg( name ) - .arg( artists.join(", ") ) - .arg( KGlobal::locale()->formatTime( dt.time() ) ) - .arg( KGlobal::locale()->formatDate( dt.date(), KLocale::FancyShortDate ) ) - .arg( venue->name ) - .arg( location ) - .arg( desc.isEmpty() ? i18n("none") : desc ) - .arg( tags.isEmpty() ? i18n("none") : tags.join(", ") ) - .arg( event->url().url() ) - .arg( venueWebsite.isEmpty() ? i18n("none") : venueWebsite ) - .arg( venueLastFmUrl.isEmpty() ? i18n("none") : venueLastFmUrl ); - return html; -} - -KUrl -UpcomingEventsMapWidgetPrivate::eventForMapIcon( const LastFmEventPtr &event ) const -{ - // Thanks a whole bunch to Nicolas Mollet, Matthias Stasiak at google-maps-icons - // pack (http://code.google.com/p/google-maps-icons/wiki/CultureIcons) - const QStringList &tags = event->tags(); - QString name; - if( tags.contains( "festival", Qt::CaseInsensitive ) ) - name = "festival.png"; - else if( !tags.filter( QRegExp("rock|metal") ).isEmpty() ) - name = "music-rock.png"; - else if( !tags.filter( QRegExp("hip.?hop|rap") ).isEmpty() ) - name = "music-hiphop.png"; - else if( !tags.filter( QRegExp("orchest.*|classical|symphon.*") ).isEmpty() ) - name = "music-classical.png"; - else if( !tags.filter( QRegExp("choir|chorus|choral") ).isEmpty() ) - name = "choral.png"; - else if( !tags.filter( QRegExp("danc(e|ing)|disco|electronic") ).isEmpty() ) - name = "dancinghall.png"; - else - name = "music-live.png"; - return KUrl( "http://google-maps-icons.googlecode.com/files/" + name ); -} - -void -UpcomingEventsMapWidgetPrivate::_centerAt( QObject *obj ) -{ - Q_Q( UpcomingEventsMapWidget ); - UpcomingEventsWidget *widget = static_cast<UpcomingEventsWidget*>( obj ); - LastFmVenuePtr venue = widget->eventPtr()->venue(); - q->centerAt( venue ); -} - -void -UpcomingEventsMapWidgetPrivate::_init() -{ - Q_Q( UpcomingEventsMapWidget ); - q->connect( q, SIGNAL(loadFinished(bool)), q, SLOT(_loadFinished(bool)) ); - QFile mapHtml( KStandardDirs::locate( "data", "amarok/data/upcoming-events-map.html" ) ); - if( mapHtml.open( QIODevice::ReadOnly | QIODevice::Text ) ) - q->setHtml( mapHtml.readAll() ); -} - -void -UpcomingEventsMapWidgetPrivate::_linkClicked( const QUrl &url ) -{ - QDesktopServices::openUrl( url ); -} - -void -UpcomingEventsMapWidgetPrivate::_loadFinished( bool success ) -{ - if( !success ) - return; - - Q_Q( UpcomingEventsMapWidget ); - isLoaded = true; - LastFmEvent::List queue = eventQueue; - eventQueue.clear(); - - foreach( const LastFmEventPtr &event, queue ) - addEvent( event ); - - if( !centerWhenLoaded.isNull() ) - { - q->centerAt( centerWhenLoaded.y(), centerWhenLoaded.x() ); - centerWhenLoaded *= 0.0; - } -} - -UpcomingEventsMapWidget::UpcomingEventsMapWidget( QGraphicsItem *parent ) - : KGraphicsWebView( parent ) - , d_ptr( new UpcomingEventsMapWidgetPrivate( this ) ) -{ - page()->setLinkDelegationPolicy( QWebPage::DelegateAllLinks ); - page()->setNetworkAccessManager( The::networkAccessManager() ); - connect( page(), SIGNAL(linkClicked(QUrl)), this, SLOT(_linkClicked(QUrl)) ); - QTimer::singleShot( 0, this, SLOT(_init()) ); -} - -UpcomingEventsMapWidget::~UpcomingEventsMapWidget() -{ - delete d_ptr; -} - -void -UpcomingEventsMapWidget::addEvent( const LastFmEventPtr &event ) -{ - Q_D( UpcomingEventsMapWidget ); - d->addEvent( event ); -} - -void -UpcomingEventsMapWidget::addEvents( const LastFmEvent::List &events ) -{ - foreach( const LastFmEventPtr &event, events ) - addEvent( event ); -} - -void -UpcomingEventsMapWidget::addEventsListWidget( UpcomingEventsListWidget *widget ) -{ - Q_D( UpcomingEventsMapWidget ); - if( widget ) - { - d->listWidgets << widget; - addEvents( widget->events() ); - connect( widget, SIGNAL(eventAdded(LastFmEventPtr)), this, SLOT(addEvent(LastFmEventPtr)) ); - connect( widget, SIGNAL(eventRemoved(LastFmEventPtr)), this, SLOT(removeEvent(LastFmEventPtr)) ); - connect( widget, SIGNAL(mapRequested(QObject*)), this, SLOT(_centerAt(QObject*)) ); - } -} - -void -UpcomingEventsMapWidget::removeEventsListWidget( UpcomingEventsListWidget *widget ) -{ - Q_D( UpcomingEventsMapWidget ); - if( d->listWidgets.contains( widget ) ) - { - foreach( const LastFmEventPtr &event, widget->events() ) - removeEvent( event ); - d->listWidgets.remove( widget ); - widget->disconnect( this ); - } -} - -void -UpcomingEventsMapWidget::removeEvent( const LastFmEventPtr &event ) -{ - Q_D( UpcomingEventsMapWidget ); - d->removeEvent( event ); -} - -bool -UpcomingEventsMapWidget::isLoaded() const -{ - Q_D( const UpcomingEventsMapWidget ); - return d->isLoaded; -} - -int -UpcomingEventsMapWidget::eventCount() const -{ - Q_D( const UpcomingEventsMapWidget ); - return d->events.count(); -} - -LastFmEvent::List -UpcomingEventsMapWidget::events() const -{ - Q_D( const UpcomingEventsMapWidget ); - return d->events; -} - -void -UpcomingEventsMapWidget::centerAt( double latitude, double longitude ) -{ - Q_D( UpcomingEventsMapWidget ); - if( !d->isLoaded ) - { - QPointF geo( longitude, latitude ); - d->centerWhenLoaded = geo; - return; - } - - QString lat( QString::number( latitude ) ); - QString lng( QString::number( longitude ) ); - QString js = QString( "javascript:centerAt(%1,%2)" ).arg( lat ).arg( lng ); - page()->mainFrame()->evaluateJavaScript( js ); -} - -void -UpcomingEventsMapWidget::centerAt( const LastFmVenuePtr &venue ) -{ - LastFmLocationPtr loc = venue->location; - centerAt( loc->latitude, loc->longitude ); -} - -void -UpcomingEventsMapWidget::clear() -{ - Q_D( UpcomingEventsMapWidget ); - d->events.clear(); - page()->mainFrame()->evaluateJavaScript( "javascript:clearMarkers()" ); -} - -#include "moc_UpcomingEventsMapWidget.cpp" diff --git a/amarok/src/context/applets/upcomingevents/UpcomingEventsMapWidget.h b/amarok/src/context/applets/upcomingevents/UpcomingEventsMapWidget.h deleted file mode 100644 index 99e55b20..00000000 --- a/amarok/src/context/applets/upcomingevents/UpcomingEventsMapWidget.h +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Rick W. Chen <stuffcorpse@archlinux.us> * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see <http://www.gnu.org/licenses/>. * - ****************************************************************************************/ - -#ifndef AMAROK_UPCOMING_EVENTS_MAP_WIDGET_H -#define AMAROK_UPCOMING_EVENTS_MAP_WIDGET_H - -#include "LastFmEvent.h" - -#include <KGraphicsWebView> - -class QGraphicsItem; -class UpcomingEventsListWidget; -class UpcomingEventsMapWidgetPrivate; - -class UpcomingEventsMapWidget : public KGraphicsWebView -{ - Q_OBJECT - Q_PROPERTY( int eventCount READ eventCount ) - Q_PROPERTY( bool isLoaded READ isLoaded ) - Q_PROPERTY( LastFmEvent::List events READ events ) - -public: - UpcomingEventsMapWidget( QGraphicsItem *parent = 0 ); - ~UpcomingEventsMapWidget(); - - bool isLoaded() const; - int eventCount() const; - LastFmEvent::List events() const; - - void addEvents( const LastFmEvent::List &events ); - - void clear(); - -public slots: - void addEvent( const LastFmEventPtr &event ); - void removeEvent( const LastFmEventPtr &event ); - void addEventsListWidget( UpcomingEventsListWidget *widget ); - void removeEventsListWidget( UpcomingEventsListWidget *widget ); - void centerAt( double latitude, double longitude ); - void centerAt( const LastFmVenuePtr &venue ); - -private: - UpcomingEventsMapWidgetPrivate *const d_ptr; - Q_DECLARE_PRIVATE( UpcomingEventsMapWidget ) - Q_DISABLE_COPY( UpcomingEventsMapWidget ) - - Q_PRIVATE_SLOT( d_ptr, void _centerAt(QObject*)) - Q_PRIVATE_SLOT( d_ptr, void _linkClicked(QUrl) ) - Q_PRIVATE_SLOT( d_ptr, void _loadFinished(bool) ) - Q_PRIVATE_SLOT( d_ptr, void _init() ) -}; - -#endif // AMAROK_UPCOMING_EVENTS_MAP_WIDGET_H diff --git a/amarok/src/context/applets/upcomingevents/UpcomingEventsStack.cpp b/amarok/src/context/applets/upcomingevents/UpcomingEventsStack.cpp deleted file mode 100644 index 0d1a9b1a..00000000 --- a/amarok/src/context/applets/upcomingevents/UpcomingEventsStack.cpp +++ /dev/null @@ -1,192 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Rick W. Chen <stuffcorpse@archlinux.us> * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see <http://www.gnu.org/licenses/>. * - ****************************************************************************************/ - -#define DEBUG_PREFIX "UpcomingEventsStack" - -#include "UpcomingEventsStack.h" -#include "UpcomingEventsStackItem.h" -#include "core/support/Debug.h" - -#include <QGraphicsLinearLayout> -#include <QSet> -#include <QtCore/qsharedpointer.h> - -class UpcomingEventsStackPrivate -{ -private: - UpcomingEventsStack *const q_ptr; - Q_DECLARE_PUBLIC( UpcomingEventsStack ) - -public: - UpcomingEventsStackPrivate( UpcomingEventsStack *parent ); - ~UpcomingEventsStackPrivate(); - - QGraphicsLinearLayout *layout; - QHash< QString, QWeakPointer<UpcomingEventsStackItem> > items; - - void _itemDestroyed() - { - QHashIterator< QString, QWeakPointer<UpcomingEventsStackItem> > i(items); - while( i.hasNext() ) - { - i.next(); - if( i.value().isNull() ) - items.remove( i.key() ); - } - } -}; - -UpcomingEventsStackPrivate::UpcomingEventsStackPrivate( UpcomingEventsStack *parent ) - : q_ptr( parent ) - , layout( 0 ) -{ -} - -UpcomingEventsStackPrivate::~UpcomingEventsStackPrivate() -{ -} - -UpcomingEventsStack::UpcomingEventsStack( QGraphicsItem *parent, Qt::WindowFlags wFlags ) - : QGraphicsWidget( parent, wFlags ) - , d_ptr( new UpcomingEventsStackPrivate( this ) ) -{ - Q_D( UpcomingEventsStack ); - d->layout = new QGraphicsLinearLayout( Qt::Vertical, this ); - d->layout->setContentsMargins( 0, 0, 0, 0 ); - setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); -} - -UpcomingEventsStack::~UpcomingEventsStack() -{ - delete d_ptr; -} - -int -UpcomingEventsStack::count() const -{ - Q_D( const UpcomingEventsStack ); - return d->layout->count(); -} - -void -UpcomingEventsStack::clear() -{ - prepareGeometryChange(); - Q_D( UpcomingEventsStack ); - int itemCount = d->layout->count(); - while( --itemCount >= 0 ) - { - QGraphicsLayoutItem *child = d->layout->itemAt( 0 ); - d->layout->removeItem( child ); - } - foreach( QWeakPointer<UpcomingEventsStackItem> item, d->items ) - item.data()->deleteLater(); - d->items.clear(); -} - -bool -UpcomingEventsStack::isEmpty() const -{ - Q_D( const UpcomingEventsStack ); - return d->items.isEmpty(); -} - -bool -UpcomingEventsStack::hasItem( const QString &name ) const -{ - Q_D( const UpcomingEventsStack ); - if( d->items.value( name ) ) - return true; - else - return false; -} - -UpcomingEventsStackItem * -UpcomingEventsStack::item( const QString &name ) const -{ - Q_D( const UpcomingEventsStack ); - Q_ASSERT( d->items.contains( name ) ); - return d->items.value( name ).data(); -} - -QList<UpcomingEventsStackItem *> -UpcomingEventsStack::items( const QRegExp &pattern ) const -{ - Q_D( const UpcomingEventsStack ); - QList<UpcomingEventsStackItem *> matched; - QHashIterator< QString, QWeakPointer<UpcomingEventsStackItem> > i( d->items ); - while( i.hasNext() ) - { - i.next(); - if( i.key().contains( pattern ) ) - matched << i.value().data(); - } - return matched; -} - -UpcomingEventsStackItem * -UpcomingEventsStack::create( const QString &name ) -{ - if( hasItem( name ) ) - return 0; - - Q_D( UpcomingEventsStack ); - QWeakPointer<UpcomingEventsStackItem> item = new UpcomingEventsStackItem( name, this ); - d->layout->addItem( item.data() ); - d->items.insert( name, item ); - connect( item.data(), SIGNAL(destroyed()), SLOT(_itemDestroyed()) ); - connect( item.data(), SIGNAL(collapseChanged(bool)), SIGNAL(collapseStateChanged()) ); - return item.data(); -} - -void -UpcomingEventsStack::remove( const QString &name ) -{ - Q_D( UpcomingEventsStack ); - d->items.take( name ).data()->deleteLater(); -} - -void -UpcomingEventsStack::maximizeItem( const QString &name ) -{ - if( hasItem( name ) ) - { - Q_D( UpcomingEventsStack ); - d->items.value( name ).data()->setCollapsed( false ); - QHashIterator< QString, QWeakPointer<UpcomingEventsStackItem> > i( d->items ); - while( i.hasNext() ) - { - i.next(); - if( i.value().data()->name() != name ) - i.value().data()->setCollapsed( true ); - } - } -} - -void -UpcomingEventsStack::cleanupListWidgets() -{ - Q_D( UpcomingEventsStack ); - QHashIterator< QString, QWeakPointer<UpcomingEventsStackItem> > i( d->items ); - while( i.hasNext() ) - { - i.next(); - if( i.value().isNull() ) - d->items.remove( i.key() ); - } -} - -#include "moc_UpcomingEventsStack.cpp" diff --git a/amarok/src/context/applets/upcomingevents/UpcomingEventsStack.h b/amarok/src/context/applets/upcomingevents/UpcomingEventsStack.h deleted file mode 100644 index 590c444e..00000000 --- a/amarok/src/context/applets/upcomingevents/UpcomingEventsStack.h +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Rick W. Chen <stuffcorpse@archlinux.us> * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see <http://www.gnu.org/licenses/>. * - ****************************************************************************************/ - -#ifndef UPCOMINGEVENTSSTACK_H -#define UPCOMINGEVENTSSTACK_H - -#include <QGraphicsWidget> -#include <QIcon> - -class UpcomingEventsStackItem; -class UpcomingEventsStackPrivate; - -class UpcomingEventsStack : public QGraphicsWidget -{ - Q_OBJECT - Q_PROPERTY( int count READ count ) - Q_PROPERTY( bool empty READ isEmpty ) - -public: - explicit UpcomingEventsStack( QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0 ); - ~UpcomingEventsStack(); - - int count() const; ///< number of list widgets in the stack widget - - void clear(); ///< clears the stack widget - - bool isEmpty() const; ///< whether the stack is empty - - bool hasItem( const QString &name ) const; - - UpcomingEventsStackItem *item( const QString &name ) const; - QList<UpcomingEventsStackItem *> items( const QRegExp &pattern ) const; - - UpcomingEventsStackItem *create( const QString &name ); ///< creates a new stack item - void remove( const QString &name ); ///< remove stack item with name - -public slots: - void maximizeItem( const QString &name ); ///< expand item with name and collapse all else - void cleanupListWidgets(); - -signals: - void collapseStateChanged(); - -private: - UpcomingEventsStackPrivate *const d_ptr; - Q_DECLARE_PRIVATE( UpcomingEventsStack ) - Q_DISABLE_COPY( UpcomingEventsStack ) - - Q_PRIVATE_SLOT( d_ptr, void _itemDestroyed() ) -}; - -#endif /* UPCOMINGEVENTSSTACK_H */ diff --git a/amarok/src/context/applets/upcomingevents/UpcomingEventsStackItem.cpp b/amarok/src/context/applets/upcomingevents/UpcomingEventsStackItem.cpp deleted file mode 100644 index 5ab98276..00000000 --- a/amarok/src/context/applets/upcomingevents/UpcomingEventsStackItem.cpp +++ /dev/null @@ -1,507 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Rick W. Chen <stuffcorpse@archlinux.us> * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see <http://www.gnu.org/licenses/>. * - ****************************************************************************************/ - -#define DEBUG_PREFIX "UpcomingEventsStackItem" - -#include "UpcomingEventsStackItem.h" -#include "UpcomingEventsStack.h" -#include "core/support/Debug.h" -#include "context/widgets/TextScrollingWidget.h" - -#include <KIconLoader> -#include <Plasma/FrameSvg> -#include <Plasma/IconWidget> -#include <Plasma/Label> -#include <Plasma/PushButton> -#include <Plasma/Theme> - -#include <QAction> -#include <QFontMetrics> -#include <QGraphicsLinearLayout> -#include <QtGui/qgraphicssceneevent.h> -#include <QLabel> -#include <QPainter> -#include <QSignalMapper> -#include <QtGui/qstyleoption.h> -#include <QtCore/qsharedpointer.h> - -class UpcomingEventsStackItemToolBox : public QGraphicsWidget -{ -public: - UpcomingEventsStackItemToolBox( QGraphicsWidget *parent ) - : QGraphicsWidget( parent ) - , m_background( new Plasma::FrameSvg(this) ) - { - m_background->setImagePath( "widgets/extender-dragger" ); - setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); - updateTheme(); - } - - qreal iconSize() - { - return m_iconSize; - } - - void paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget * ) - { - m_background->paintFrame( painter, option->exposedRect, option->exposedRect ); - } - - void updateTheme() - { - //Read the preferred icon size hint, look at the font size, and calculate the desired title bar - //icon height. - m_background->resize(); - QSizeF size = m_background->elementSize( "hint-preferred-icon-size" ); - size = size.expandedTo( QSizeF(KIconLoader::SizeSmall,KIconLoader::SizeSmall) ); - - Plasma::Theme *theme = Plasma::Theme::defaultTheme(); - QFont font = theme->font( Plasma::Theme::DefaultFont ); - QFontMetrics fm( font ); - m_iconSize = qMax( size.height(), (qreal) fm.height() ); - } - - void setBackgroundPrefix( const QString &string ) - { - if( string.isEmpty() || m_background->hasElementPrefix(string) ) - { - m_background->setElementPrefix( string ); - update(); - } - } - - const QString backgroundPrefix() const - { - return m_background->prefix(); - } - -protected: - void resizeEvent( QGraphicsSceneResizeEvent *event ) - { - Q_UNUSED( event ) - m_background->resizeFrame( size() ); - } - -private: - Plasma::FrameSvg *m_background; - QString m_prefix; - qreal m_iconSize; -}; - -class UpcomingEventsStackItemPrivate -{ -private: - UpcomingEventsStackItem *const q_ptr; - Q_DECLARE_PUBLIC( UpcomingEventsStackItem ) - -public: - UpcomingEventsStackItemPrivate( UpcomingEventsStackItem *parent ); - ~UpcomingEventsStackItemPrivate(); - - Plasma::IconWidget *collapseButton; - Plasma::IconWidget *destroyButton; - bool destroyButtonEnabled; - QHash<QString, QAction*> actions; - QSignalMapper *maximizeSignalMapper; - - bool collapsed; - QGraphicsLinearLayout *layout; - QGraphicsLinearLayout *toolboxLayout; - QString name; - QString title; - QString iconName; - QWeakPointer<QGraphicsWidget> widget; - TextScrollingWidget *titleLabel; - UpcomingEventsStack *stack; - UpcomingEventsStackItemToolBox *toolbox; - - void _themeChanged(); - void _toggleCollapse(); - void _updateToolbox(); -}; - -UpcomingEventsStackItemPrivate::UpcomingEventsStackItemPrivate( UpcomingEventsStackItem *parent ) - : q_ptr( parent ) - , collapseButton( 0 ) - , destroyButton( 0 ) - , destroyButtonEnabled( false ) - , maximizeSignalMapper( 0 ) - , collapsed( false ) - , layout( 0 ) - , toolboxLayout( 0 ) - , titleLabel( 0 ) - , stack( 0 ) - , toolbox( 0 ) -{ -} - -UpcomingEventsStackItemPrivate::~UpcomingEventsStackItemPrivate() -{ -} - -void -UpcomingEventsStackItemPrivate::_themeChanged() -{ - toolbox->updateTheme(); -} - -void -UpcomingEventsStackItemPrivate::_toggleCollapse() -{ - Q_Q( UpcomingEventsStackItem ); - q->setCollapsed( !q->isCollapsed() ); -} - -void -UpcomingEventsStackItemPrivate::_updateToolbox() -{ - Q_ASSERT( toolbox ); - Q_ASSERT( toolboxLayout ); - Q_Q( UpcomingEventsStackItem ); - const int startingIndex = 2; // collapse item is index 0, title label is 1 - const QSizeF widgetSize = collapseButton->sizeFromIconSize( toolbox->iconSize() ); - titleLabel->setText( title ); - - QHash<QAction *, QGraphicsWidget *> actionWidgets; - for( int index = startingIndex; index < toolboxLayout->count(); ++index) - { - QGraphicsWidget *widget = dynamic_cast<QGraphicsWidget*>( toolboxLayout->itemAt(index) ); - QAction *widgetAction = 0; - - if( !widget ) - continue; - else if( qobject_cast<Plasma::IconWidget*>(widget) ) - widgetAction = static_cast<Plasma::IconWidget*>( widget )->action(); - else if( qobject_cast<Plasma::PushButton*>(widget) ) - widgetAction = static_cast<Plasma::PushButton*>( widget )->action(); - else - { - toolboxLayout->removeAt(index); - widget->deleteLater(); - } - - if( widget != destroyButton ) - actionWidgets.insert( widgetAction, widget ); - } - - // ensure the collapseButton is the correct size. - collapseButton->setMinimumSize( widgetSize ); - collapseButton->setMaximumSize( widgetSize ); - - // add the actions that are actually set to visible. - foreach( QAction *action, actions.values() ) - { - if( action->isVisible() ) - { - Plasma::IconWidget *icon = qobject_cast<Plasma::IconWidget*>( actionWidgets.value(action) ); - Plasma::PushButton *button = qobject_cast<Plasma::PushButton*>( actionWidgets.value(action) ); - - if( action->icon().isNull() && !action->text().isNull() ) - { - if( !button ) - { - button = new Plasma::PushButton; - button->setAction( action ); - } - button->setMinimumHeight( widgetSize.height() ); - button->setMaximumHeight( widgetSize.height() ); - button->setCursor( Qt::ArrowCursor ); - toolboxLayout->insertItem( startingIndex, button ); - } - else - { - if( !icon ) - { - icon = new Plasma::IconWidget; - icon->setAction( action ); - } - if( action->icon().isNull() ) - icon->setText( action->text() ); - - icon->setMinimumSize( widgetSize ); - icon->setMaximumSize( widgetSize ); - icon->setCursor( Qt::ArrowCursor ); - toolboxLayout->insertItem( startingIndex, icon ); - } - } - } - - // add destroy button last - if( destroyButtonEnabled ) - { - if( !destroyButton ) - { - QAction *closeAction = new QAction( q ); - destroyButton = new Plasma::IconWidget( toolbox ); - destroyButton->setAction( closeAction ); - destroyButton->setSvg( QLatin1String("widgets/configuration-icons"), QLatin1String("close") ); - destroyButton->setMinimumSize( widgetSize ); - destroyButton->setMaximumSize( widgetSize ); - destroyButton->setCursor( Qt::ArrowCursor ); - QObject::connect( closeAction, SIGNAL(triggered()), q, SLOT(deleteLater()) ); - } - toolboxLayout->addItem( destroyButton ); - } - toolboxLayout->invalidate(); -} - -UpcomingEventsStackItem::UpcomingEventsStackItem( const QString &name, - UpcomingEventsStack *parent) - : QGraphicsWidget( parent ) - , d_ptr( new UpcomingEventsStackItemPrivate( this ) ) -{ - Q_ASSERT( parent ); - Q_D( UpcomingEventsStackItem ); - d->stack = parent; - d->name = name; - - //create the toolbox. - d->toolbox = new UpcomingEventsStackItemToolBox( this ); - d->toolboxLayout = new QGraphicsLinearLayout( d->toolbox ); - - //create own layout - d->layout = new QGraphicsLinearLayout( Qt::Vertical, this ); - d->layout->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); - d->layout->addItem( d->toolbox ); - d->layout->setContentsMargins( 0, 0, 0, 0 ); - - //create maximize action - d->maximizeSignalMapper = new QSignalMapper( d->toolbox ); - connect( d->maximizeSignalMapper, SIGNAL(mapped(QString)), d->stack, SLOT(maximizeItem(QString)) ); - - Plasma::Svg svg; - svg.setImagePath( QLatin1String("widgets/configuration-icons") ); - QAction *maximizeAction = new QAction( svg.pixmap(QLatin1String("restore")), QString(), d->toolbox ); - maximizeAction->setToolTip( i18n( "Maximize" ) ); - connect( maximizeAction, SIGNAL(triggered()), d->maximizeSignalMapper, SLOT(map()) ); - d->maximizeSignalMapper->setMapping( maximizeAction, d->name ); - d->actions.insert( QLatin1String("maximize"), maximizeAction ); - - d->collapseButton = new Plasma::IconWidget( d->toolbox ); - d->collapseButton->setCursor( Qt::ArrowCursor ); - d->titleLabel = new TextScrollingWidget( d->toolbox ); - d->titleLabel->setAlignment( Qt::AlignLeft | Qt::AlignVCenter ); - - d->toolboxLayout->addItem( d->collapseButton ); - d->toolboxLayout->addItem( d->titleLabel ); - d->toolboxLayout->setStretchFactor( d->titleLabel, 10 ); - connect( d->collapseButton, SIGNAL(clicked()), SLOT(_toggleCollapse()) ); - - setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); - setContentsMargins( 0, 0, 0, 0 ); - - d->_updateToolbox(); - d->_themeChanged(); - connect( Plasma::Theme::defaultTheme(), SIGNAL(themeChanged()), SLOT(_themeChanged()) ); -} - -UpcomingEventsStackItem::~UpcomingEventsStackItem() -{ - delete d_ptr; -} - -void -UpcomingEventsStackItem::setWidget( QGraphicsWidget *widget ) -{ - Q_ASSERT( widget ); - Q_D( UpcomingEventsStackItem ); - if( d->widget.data() ) - { - d->layout->removeItem( d->widget.data() ); - delete d->widget.data(); - } - widget->setParentItem( this ); - d->widget = widget; - d->layout->insertItem( 1, d->widget.data() ); - d->layout->setItemSpacing( 0, 2 ); - d->widget.data()->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); - d->widget.data()->setVisible( !d->collapsed ); -} - -QGraphicsWidget * -UpcomingEventsStackItem::widget() const -{ - Q_D( const UpcomingEventsStackItem ); - return d->widget.data(); -} - -void -UpcomingEventsStackItem::setTitle( const QString &title ) -{ - Q_D( UpcomingEventsStackItem ); - d->title = title; - d->_updateToolbox(); -} - -QString -UpcomingEventsStackItem::title() const -{ - Q_D( const UpcomingEventsStackItem ); - return d->title; -} - -void -UpcomingEventsStackItem::setName( const QString &name ) -{ - Q_D( UpcomingEventsStackItem ); - d->name = name; -} - -void -UpcomingEventsStackItem::addAction( const QString &name, QAction *action ) -{ - Q_ASSERT( action ); - Q_D( UpcomingEventsStackItem ); - d->actions.insert( name, action ); - d->_updateToolbox(); -} - -QHash<QString, QAction *> -UpcomingEventsStackItem::actions() const -{ - Q_D( const UpcomingEventsStackItem ); - return d->actions; -} - -QAction * -UpcomingEventsStackItem::action( const QString &name ) const -{ - Q_D( const UpcomingEventsStackItem ); - return d->actions.value( name ); -} - -QString -UpcomingEventsStackItem::name() const -{ - Q_D( const UpcomingEventsStackItem ); - return d->name; -} - -void -UpcomingEventsStackItem::setIcon( const QIcon &icon ) -{ - Q_D( UpcomingEventsStackItem ); - d->collapseButton->setIcon( icon ); - d->collapseButton->setVisible( !icon.isNull() ); - d->_updateToolbox(); -} - -void -UpcomingEventsStackItem::setIcon( const QString &icon ) -{ - Q_D( UpcomingEventsStackItem ); - if( icon != d->iconName ) - { - d->collapseButton->setIcon( icon ); - d->iconName = icon; - } -} - -QIcon -UpcomingEventsStackItem::icon() const -{ - Q_D( const UpcomingEventsStackItem ); - return d->collapseButton->icon(); -} - -UpcomingEventsStack * -UpcomingEventsStackItem::stack() const -{ - Q_D( const UpcomingEventsStackItem ); - return d->stack; -} - -bool -UpcomingEventsStackItem::isCollapsed() const -{ - Q_D( const UpcomingEventsStackItem ); - return d->collapsed; -} - -void -UpcomingEventsStackItem::setCollapsed( bool collapsed ) -{ - Q_D( UpcomingEventsStackItem ); - d->collapsed = collapsed; - if( d->widget ) - { - prepareGeometryChange(); - d->widget.data()->setVisible( !collapsed ); - if( collapsed ) - d->layout->removeItem( d->widget.data() ); - else - { - d->layout->insertItem( 1, d->widget.data() ); - d->layout->setItemSpacing( 0, 2 ); - } - d->toolboxLayout->invalidate(); - emit collapseChanged( collapsed ); - updateGeometry(); - } - d->collapseButton->setToolTip( collapsed ? i18n("Expand this widget") : i18n("Collapse this widget") ); -} - -void -UpcomingEventsStackItem::showCloseButton( bool show ) -{ - Q_D( UpcomingEventsStackItem ); - d->destroyButtonEnabled = show; - d->_updateToolbox(); -} - -void -UpcomingEventsStackItem::mouseDoubleClickEvent( QGraphicsSceneMouseEvent *event ) -{ - Q_D( UpcomingEventsStackItem ); - if( d->toolbox->boundingRect().contains( event->pos() ) ) - d->_toggleCollapse(); -} - -void -UpcomingEventsStackItem::mousePressEvent( QGraphicsSceneMouseEvent *event ) -{ - Q_D( UpcomingEventsStackItem ); - if( !(d->toolbox->boundingRect().contains(event->pos())) ) - event->ignore(); -} - -QSizeF -UpcomingEventsStackItem::sizeHint( Qt::SizeHint which, const QSizeF &constraint ) const -{ - Q_D( const UpcomingEventsStackItem ); - QSizeF size = d->toolbox->effectiveSizeHint( which, constraint ); - if( !d->collapsed && d->widget ) - { - size.rheight() += d->layout->itemSpacing( 1 ) * 2; - size.rheight() += d->widget.data()->effectiveSizeHint( which, constraint ).height(); - } - return size; -} - -QRectF -UpcomingEventsStackItem::boundingRect() const -{ - Q_D( const UpcomingEventsStackItem ); - if( !d->collapsed && d->widget ) - { - QSharedPointer<QGraphicsWidget> w = d->widget.toStrongRef(); - if( w ) - return d->toolbox->boundingRect().united( mapRectFromItem( w.data(), w->boundingRect() ) ); - } - return d->toolbox->boundingRect(); -} - -#include "moc_UpcomingEventsStackItem.cpp" diff --git a/amarok/src/context/applets/upcomingevents/UpcomingEventsStackItem.h b/amarok/src/context/applets/upcomingevents/UpcomingEventsStackItem.h deleted file mode 100644 index 8124598d..00000000 --- a/amarok/src/context/applets/upcomingevents/UpcomingEventsStackItem.h +++ /dev/null @@ -1,145 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Rick W. Chen <stuffcorpse@archlinux.us> * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see <http://www.gnu.org/licenses/>. * - ****************************************************************************************/ - -#ifndef UPCOMINGEVENTSSTACKITEM_H -#define UPCOMINGEVENTSSTACKITEM_H - -#include <QGraphicsWidget> -#include <QIcon> - -class QGraphicsSceneMouseEvent; -class UpcomingEventsStack; -class UpcomingEventsStackItemPrivate; - -/** - * A widget that mimics the look and feel of Plasma::ExtenderItem, to be used - * within an UpcomingEventsStack. It has a toolbox area containing icons, - * text, and push buttons for pleasure. - */ -class UpcomingEventsStackItem : public QGraphicsWidget -{ - Q_OBJECT - Q_PROPERTY( QGraphicsWidget *widget READ widget WRITE setWidget ) - Q_PROPERTY( QString title READ title WRITE setTitle ) - Q_PROPERTY( QString name READ name WRITE setName ) - Q_PROPERTY( QIcon icon READ icon WRITE setIcon ) - Q_PROPERTY( UpcomingEventsStack *stack READ stack ) - Q_PROPERTY( bool collapsed READ isCollapsed WRITE setCollapsed NOTIFY collapseChanged ) - -public: - explicit UpcomingEventsStackItem( const QString &name, UpcomingEventsStack *parent ); - ~UpcomingEventsStackItem(); - - /** - * @param widget The widget that should be wrapped into the stack item. - * It has to be a QGraphicsWidget. - */ - void setWidget( QGraphicsWidget *widget ); - - /** - * @return The widget that is wrapped into the stack item. - */ - QGraphicsWidget *widget() const; - - /** - * @param title the title that will be shown in the stack item's dragger. - */ - void setTitle( const QString &title ); - - /** - * @return the title shown in the stack item's dragger. - */ - QString title() const; - - /** - * You can assign names to stack items to look them up through the item() function. - * Make sure you only use unique names. - * @param name the name of the item. - */ - void setName( const QString &name ); - - /** - * @return the name of the item. - */ - QString name() const; - - /** - * Adds custom actions to appear in the drag handle. - * @param action the action to add. Actions will be displayed as an icon in the drag - * handle. - */ - void addAction( const QString &name, QAction *action ); - - /** - * @return the custom actions in the drag handle. - */ - QHash<QString, QAction *> actions() const; - - /** - * @return the QAction with the given name from our collection. - */ - QAction *action( const QString &name ) const; - - /** - * @param icon the icon to display in the stack item's drag handle. - */ - void setIcon( const QIcon &icon ); - - /** - * @param icon the icon name to display in the stack item's drag handle. - */ - void setIcon( const QString &icon ); - - /** - * @return the icon being displayed in the stack item's drag handle. - */ - QIcon icon() const; - - /** - * @return the stack this items belongs to. - */ - UpcomingEventsStack *stack() const; - - /** - * @return whether or not the stack item is collapsed. - */ - bool isCollapsed() const; - - QRectF boundingRect() const; - -public slots: - void setCollapsed( bool collapsed ); - void showCloseButton( bool show = true ); - -signals: - void collapseChanged( bool isCollapsed ); - -protected: - void mouseDoubleClickEvent( QGraphicsSceneMouseEvent *event ); - void mousePressEvent( QGraphicsSceneMouseEvent *event ); - QSizeF sizeHint( Qt::SizeHint which, const QSizeF &constraint = QSizeF() ) const; - -private: - UpcomingEventsStackItemPrivate *const d_ptr; - Q_DECLARE_PRIVATE( UpcomingEventsStackItem ) - Q_DISABLE_COPY( UpcomingEventsStackItem ) - - Q_PRIVATE_SLOT( d_ptr, void _themeChanged() ) - Q_PRIVATE_SLOT( d_ptr, void _toggleCollapse() ) - Q_PRIVATE_SLOT( d_ptr, void _updateToolbox() ) -}; - -#endif /* UPCOMINGEVENTSSTACKITEM_H */ diff --git a/amarok/src/context/applets/upcomingevents/UpcomingEventsWidget.cpp b/amarok/src/context/applets/upcomingevents/UpcomingEventsWidget.cpp deleted file mode 100644 index a8b4c1b4..00000000 --- a/amarok/src/context/applets/upcomingevents/UpcomingEventsWidget.cpp +++ /dev/null @@ -1,382 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009-2010 Ludovic Deveaux <deveaux.ludovic31@gmail.com> * - * Copyright (c) 2010 Hormiere Guillaume <hormiere.guillaume@gmail.com> * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see <http://www.gnu.org/licenses/>. * - ****************************************************************************************/ - -#define DEBUG_PREFIX "UpcomingEventsWidget" - -#include "UpcomingEventsWidget.h" -#include "core/support/Amarok.h" -#include "core/support/Debug.h" -#include "SvgHandler.h" - -#include <KDateTime> -#include <KIcon> -#include <KLocale> - -#include <Plasma/Label> -#include <Plasma/PushButton> -#include <Plasma/Separator> - -#include <QDesktopServices> -#include <QLabel> -#include <QPixmap> -#include <QPixmapCache> -#include <QGraphicsGridLayout> -#include <QGraphicsLinearLayout> -#include <QGraphicsProxyWidget> -#include <QSignalMapper> - -UpcomingEventsWidget::UpcomingEventsWidget( const LastFmEventPtr &event, - QGraphicsItem *parent, - Qt::WindowFlags wFlags ) - : QGraphicsWidget( parent, wFlags ) - , m_mapButton( 0 ) - , m_urlButton( 0 ) - , m_image( new QLabel ) - , m_event( event ) -{ - setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Maximum ); - - m_image->setText( i18n("Loading picture...") ); - m_image->setAttribute( Qt::WA_NoSystemBackground ); - m_image->setAlignment( Qt::AlignCenter ); - m_image->setFixedSize( 128, 128 ); - QGraphicsProxyWidget *imageProxy = new QGraphicsProxyWidget( this ); - imageProxy->setWidget( m_image ); - - m_attendance = createLabel(); - m_date = createLabel(); - m_location = createLabel(); - m_name = createLabel(); - m_participants = createLabel(); - m_tags = createLabel(); - m_venue = createLabel(); - - QGraphicsLinearLayout *buttonsLayout = new QGraphicsLinearLayout( Qt::Horizontal ); - buttonsLayout->setSizePolicy( QSizePolicy::Maximum, QSizePolicy::Fixed ); - if( event && event->venue() && event->venue()->location ) - { - QPointF geo( event->venue()->location->longitude, event->venue()->location->latitude ); - if( !geo.isNull() ) - { - m_mapButton = new Plasma::PushButton( this ); - m_mapButton->setMaximumSize( QSizeF( 22, 22 ) ); - m_mapButton->setIcon( KIcon("edit-find") ); // TODO: a map icon would be nice - m_mapButton->setToolTip( i18n( "View map" ) ); - buttonsLayout->addItem( m_mapButton ); - } - } - - if( event && event->url().isValid() ) - { - m_urlButton = new Plasma::PushButton( this ); - m_urlButton->setMaximumSize( QSizeF( 22, 22 ) ); - m_urlButton->setIcon( KIcon("applications-internet") ); - m_urlButton->setToolTip( i18n( "Open Last.fm webpage for this event" ) ); - connect( m_urlButton, SIGNAL(clicked()), this, SLOT(openUrl()) ); - buttonsLayout->addItem( m_urlButton ); - } - - QSizePolicy::Policy minPol = QSizePolicy::Minimum; - QGraphicsWidget *supportLabel, *venueLabel, *locationLabel, *dateLabel, *attendLabel, *tagsLabel; - supportLabel = createLabel( i18nc("@label:textbox Supporing acts for an event", "Supporting:"), minPol ); - venueLabel = createLabel( i18nc("@label:textbox", "Venue:"), minPol ); - locationLabel = createLabel( i18nc("@label:textbox", "Location:"), minPol ); - dateLabel = createLabel( i18nc("@label:textbox", "Date:"), minPol ); - attendLabel = createLabel( i18nc("@label:textbox", "Attending:"), minPol ); - tagsLabel = createLabel( i18nc("@label:textbox", "Tags:"), minPol ); - - QGraphicsGridLayout *infoLayout = new QGraphicsGridLayout; - infoLayout->addItem( supportLabel, 0, 0 ); - infoLayout->addItem( venueLabel, 1, 0 ); - infoLayout->addItem( locationLabel, 2, 0 ); - infoLayout->addItem( dateLabel, 3, 0 ); - infoLayout->addItem( attendLabel, 4, 0 ); - infoLayout->addItem( tagsLabel, 5, 0 ); - infoLayout->addItem( m_participants, 0, 1 ); - infoLayout->addItem( m_venue, 1, 1 ); - infoLayout->addItem( m_location, 2, 1 ); - infoLayout->addItem( m_date, 3, 1 ); - infoLayout->addItem( m_attendance, 4, 1 ); - infoLayout->addItem( m_tags, 5, 1 ); - - QGraphicsGridLayout *layout = new QGraphicsGridLayout; - layout->addItem( imageProxy, 0, 0, 2, 1, Qt::AlignCenter ); - layout->addItem( m_name, 0, 1 ); - layout->addItem( buttonsLayout, 0, 2, Qt::AlignRight ); - layout->addItem( infoLayout, 1, 1, 1, 2 ); - setLayout( layout ); - - QString name = event->name(); - if( event->isCancelled() ) - name = i18nc( "@label:textbox Title for a canceled upcoming event", "<s>%1</s> (Canceled)", name ); - setName( name ); - setDate( event->date() ); - setLocation( event->venue()->location ); - setVenue( event->venue() ); - setAttendance( event->attendance() ); - setParticipants( event->participants() ); - setTags( event->tags() ); - setImage( event->imageUrl(LastFmEvent::Large) ); -} - -UpcomingEventsWidget::~UpcomingEventsWidget() -{ -} - -QGraphicsProxyWidget * -UpcomingEventsWidget::createLabel( const QString &text, QSizePolicy::Policy hPolicy ) -{ - QLabel *label = new QLabel; - label->setAttribute( Qt::WA_NoSystemBackground ); - label->setMinimumWidth( 10 ); - label->setSizePolicy( hPolicy, QSizePolicy::Preferred ); - label->setText( text ); - label->setWordWrap( false ); - QGraphicsProxyWidget *proxy = new QGraphicsProxyWidget( this ); - proxy->setWidget( label ); - return proxy; -} - -void -UpcomingEventsWidget::setImage( const KUrl &url ) -{ - if( url.isValid() ) - { - m_imageUrl = url; - QPixmap pixmap; - if( QPixmapCache::find(url.url(), &pixmap) ) - { - m_image->setPixmap( pixmap ); - return; - } - QNetworkReply *reply = The::networkAccessManager()->get( QNetworkRequest(url) ); - connect( reply, SIGNAL(finished()), SLOT(loadImage()), Qt::QueuedConnection ); - } - m_image->setPixmap( Amarok::semiTransparentLogo( 120 ) ); -} - -void -UpcomingEventsWidget::loadImage() -{ - QNetworkReply *reply = qobject_cast<QNetworkReply*>( sender() ); - if( !reply ) - return; - - reply->deleteLater(); - const KUrl &url = reply->request().url(); - if( m_imageUrl != url ) - return; - - if( reply->error() != QNetworkReply::NoError ) - return; - - QPixmap image; - if( image.loadFromData( reply->readAll() ) ) - { - image = image.scaled( 116, 116, Qt::KeepAspectRatio, Qt::SmoothTransformation ); - image = The::svgHandler()->addBordersToPixmap( image, 6, QString(), true ); - QPixmapCache::insert( url.url(), image ); - m_image->setPixmap( image ); - } -} - -void -UpcomingEventsWidget::openUrl() -{ - if( m_event->url().isValid() ) - QDesktopServices::openUrl( m_event->url() ); -} - -void -UpcomingEventsWidget::setTags( const QStringList &tags ) -{ - QLabel *tagsLabel = static_cast<QLabel*>( m_tags->widget() ); - tagsLabel->setText( tags.isEmpty() ? i18n( "none" ) : tags.join(", ") ); - QStringList tooltips; - if( tags.count() > 10 ) - { - for( int i = 0; i < 10; ++i ) - tooltips << tags.value( i ); - } - else - tooltips = tags; - tagsLabel->setToolTip( i18nc( "@info:tooltip", "<strong>Tags:</strong><nl/>%1", tooltips.join(", ") ) ); -} - -void -UpcomingEventsWidget::setAttendance( int count ) -{ - static_cast<QLabel*>(m_attendance->widget())->setText( QString::number(count) ); -} - -void -UpcomingEventsWidget::setParticipants( const QStringList &participants ) -{ - QLabel *participantsLabel = static_cast<QLabel*>( m_participants->widget() ); - if( participants.isEmpty() ) - { - participantsLabel->setText( i18n( "none" ) ); - } - else - { - QString combined = participants.join( ", " ); - participantsLabel->setText( combined ); - if( participants.size() > 1 ) - { - QString tooltip = i18nc( "@info:tooltip Supporting artists for an event", - "<strong>Supporting artists:</strong><nl/>%1", combined ); - participantsLabel->setToolTip( tooltip ); - } - } -} - -void -UpcomingEventsWidget::setDate( const KDateTime &date ) -{ - QLabel *dateLabel = static_cast<QLabel*>( m_date->widget() ); - dateLabel->setText( KGlobal::locale()->formatDateTime( date, KLocale::FancyLongDate ) ); - KDateTime currentDT = KDateTime::currentLocalDateTime(); - if( currentDT.compare(date) == KDateTime::Before ) - { - int daysTo = currentDT.daysTo( date ); - dateLabel->setToolTip( i18ncp( "@info:tooltip Number of days till an event", - "Tomorrow", "In <strong>%1</strong> days", daysTo ) ); - } -} - -void -UpcomingEventsWidget::setLocation( const LastFmLocationPtr &loc ) -{ - QString text = QString( "%1, %2" ).arg( loc->city ).arg( loc->country ); - if( !loc->street.isEmpty() ) - text.prepend( loc->street + ", " ); - QLabel *locLabel = static_cast<QLabel*>( m_location->widget() ); - locLabel->setText( text ); - locLabel->setToolTip( i18nc( "@info:tooltip", "<strong>Location:</strong><nl/>%1", text ) ); -} - -void -UpcomingEventsWidget::setVenue( const LastFmVenuePtr &venue ) -{ - static_cast<QLabel*>( m_venue->widget() )->setText( venue->name ); -} - -void -UpcomingEventsWidget::setName( const QString &name ) -{ - QLabel *nameLabel = static_cast<QLabel*>( m_name->widget() ); - QFont nameFont; - nameFont.setBold( true ); - nameFont.setPointSize( nameLabel->font().pointSize() + 2 ); - nameLabel->setFont( nameFont ); - nameLabel->setText( name ); -} - -UpcomingEventsListWidget::UpcomingEventsListWidget( QGraphicsWidget *parent ) - : Plasma::ScrollWidget( parent ) - , m_sigmap( new QSignalMapper( this ) ) -{ - // The widgets are displayed line by line with only one column - m_layout = new QGraphicsLinearLayout( Qt::Vertical ); - QGraphicsWidget *content = new QGraphicsWidget( this ); - content->setLayout( m_layout ); - setWidget( content ); - connect( m_sigmap, SIGNAL(mapped(QObject*)), this, SIGNAL(mapRequested(QObject*)) ); -} - -UpcomingEventsListWidget::~UpcomingEventsListWidget() -{ - clear(); -} - -int -UpcomingEventsListWidget::count() const -{ - return m_events.count(); -} - -LastFmEvent::List -UpcomingEventsListWidget::events() const -{ - return m_events; -} - -void -UpcomingEventsListWidget::addEvent( const LastFmEventPtr &event ) -{ - m_events << event; - UpcomingEventsWidget *widget = new UpcomingEventsWidget( event ); - const uint eventTime = event->date().toTime_t(); - QMap<uint, UpcomingEventsWidget*>::const_iterator iBound( m_sortMap.insertMulti( eventTime, widget ) ); - QMap<uint, UpcomingEventsWidget*>::const_iterator i( m_sortMap.constBegin() ); - int index = 0; - while( i++ != iBound ) - ++index; // find the right index to insert the widget - index *= 2; // take separators into account - m_layout->insertItem( index, widget ); - m_layout->insertItem( index + 1, new Plasma::Separator ); - if( widget->m_mapButton ) - { - connect( widget->m_mapButton, SIGNAL(clicked()), m_sigmap, SLOT(map()) ); - m_sigmap->setMapping( widget->m_mapButton, widget ); - } - emit eventAdded( event ); -} - -void -UpcomingEventsListWidget::addEvents( const LastFmEvent::List &events ) -{ - foreach( const LastFmEventPtr &event, events ) - addEvent( event ); -} - -void -UpcomingEventsListWidget::clear() -{ - foreach( const LastFmEventPtr &event, m_events ) - emit eventRemoved( event ); - m_events.clear(); - qDeleteAll( m_sortMap.values() ); - m_sortMap.clear(); - int count = m_layout->count(); - while( --count >= 0 ) - { - QGraphicsLayoutItem *child = m_layout->itemAt( 0 ); - m_layout->removeItem( child ); - delete child; - } -} - -bool -UpcomingEventsListWidget::isEmpty() const -{ - return count() == 0; -} - -QString -UpcomingEventsListWidget::name() const -{ - return m_name; -} - -void -UpcomingEventsListWidget::setName( const QString &name ) -{ - m_name = name; -} - -#include "moc_UpcomingEventsWidget.cpp" diff --git a/amarok/src/context/applets/upcomingevents/UpcomingEventsWidget.h b/amarok/src/context/applets/upcomingevents/UpcomingEventsWidget.h deleted file mode 100644 index 0b414da6..00000000 --- a/amarok/src/context/applets/upcomingevents/UpcomingEventsWidget.h +++ /dev/null @@ -1,177 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009-2010 Ludovic Deveaux <deveaux.ludovic31@gmail.com> * - * Copyright (c) 2010 Hormiere Guillaume <hormiere.guillaume@gmail.com> * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see <http://www.gnu.org/licenses/>. * - ****************************************************************************************/ - -#ifndef UPCOMING_EVENTS_WIDGET_H -#define UPCOMING_EVENTS_WIDGET_H - -#include "NetworkAccessManagerProxy.h" -#include "LastFmEvent.h" - -#include <KUrl> -#include <Plasma/ScrollWidget> - -#include <QGraphicsWidget> - -class KDateTime; -class QLabel; -class QGraphicsLinearLayout; -class QGraphicsProxyWidget; -class QPixmap; -class QPointF; -class QSignalMapper; -namespace Plasma { - class Label; - class PushButton; -} - -class UpcomingEventsWidget : public QGraphicsWidget -{ - Q_OBJECT - - public: - /** - * UpcomingEventsWidget constructor - * @param QGraphicsWidget*, like QGraphicsWidget constructor - */ - UpcomingEventsWidget( const LastFmEventPtr &event, - QGraphicsItem *parent = 0, - Qt::WindowFlags wFlags = 0 ); - ~UpcomingEventsWidget(); - - /** - * The upcoming event associated with this widget - */ - LastFmEventPtr eventPtr() const - { return m_event; } - - /** - *Set the event's image in Plasma::Label from an url - *@param KUrl, image's url to be displayed - */ - void setImage( const KUrl &url ); - - /** - * Set attendance for this event - * @param count number of attendees - */ - void setAttendance( int count ); - - /** - *Set the event's participants text in Plasma::Label from a QString - *@param QString, participant's text to be displayed - */ - void setParticipants( const QStringList &participants ); - - /** - *Set the event's date in Plasma::Label from a KDateTime - *@param KDateTime, date to be displayed - */ - void setDate( const KDateTime &date ); - - /** - *Set the event's name in Plasma::Label from a QString - *@param QString, name's text to be displayed - */ - void setName( const QString &name ); - - /** - *Set the event's location in a Plasma::Label from a QString - *@param QString, location's text to be displayed - */ - void setLocation( const LastFmLocationPtr &location ); - - /** - * Set event venue - * @param venue Last.fm's venue - */ - void setVenue( const LastFmVenuePtr &venue ); - - /** - *Set the event's url in Plasma::Label from a KUrl - *@param KUrl, url to be displayed - */ - void setUrl( const KUrl &url ); - - /** - * Set the events tags - * @param tags list of tags - */ - void setTags( const QStringList &tags ); - - protected: - Plasma::PushButton *m_mapButton; - - private: - Plasma::PushButton *m_urlButton; - QGraphicsProxyWidget *m_attendance; - QGraphicsProxyWidget *m_date; - QGraphicsProxyWidget *m_location; - QGraphicsProxyWidget *m_name; - QGraphicsProxyWidget *m_participants; - QGraphicsProxyWidget *m_tags; - QGraphicsProxyWidget *m_venue; - QLabel *m_image; - KUrl m_imageUrl; - const LastFmEventPtr m_event; - - QGraphicsProxyWidget *createLabel( const QString &text = QString(), - QSizePolicy::Policy hPolicy = QSizePolicy::Expanding ); - - friend class UpcomingEventsListWidget; - - private slots: - void loadImage(); - void openUrl(); -}; - -class UpcomingEventsListWidget : public Plasma::ScrollWidget -{ - Q_OBJECT - Q_PROPERTY( QString name READ name WRITE setName ) - Q_PROPERTY( LastFmEvent::List events READ events ) - -public: - explicit UpcomingEventsListWidget( QGraphicsWidget *parent = 0 ); - ~UpcomingEventsListWidget(); - - int count() const; - bool isEmpty() const; - - void addEvent( const LastFmEventPtr &event ); - void addEvents( const LastFmEvent::List &events ); - - LastFmEvent::List events() const; - QString name() const; - void setName( const QString &name ); - - void clear(); - -signals: - void mapRequested( QObject *widget ); - void eventAdded( const LastFmEventPtr &event ); - void eventRemoved( const LastFmEventPtr &event ); - -private: - QString m_name; - LastFmEvent::List m_events; - QMap<uint, UpcomingEventsWidget*> m_sortMap; - QGraphicsLinearLayout *m_layout; - QSignalMapper *m_sigmap; - Q_DISABLE_COPY( UpcomingEventsListWidget ) -}; - -#endif /* UPCOMINGEVENTSWIDGET_H */ diff --git a/amarok/src/context/applets/upcomingevents/amarok-context-applet-upcomingEvents.desktop b/amarok/src/context/applets/upcomingevents/amarok-context-applet-upcomingEvents.desktop deleted file mode 100644 index 06bc4284..00000000 --- a/amarok/src/context/applets/upcomingevents/amarok-context-applet-upcomingEvents.desktop +++ /dev/null @@ -1,68 +0,0 @@ -[Desktop Entry] -Name=Upcoming Events -Name[bg]=Предстоящи събития -Name[bs]=Predstoјeći događaјi -Name[ca]=Propers esdeveniments -Name[ca@valencia]=Propers esdeveniments -Name[cs]=Nadcházející události -Name[da]=Kommende begivenheder -Name[de]=Anstehende Ereignisse -Name[el]=Επόμενες εκδηλώσεις -Name[en_GB]=Upcoming Events -Name[es]=Próximos eventos -Name[et]=Tulevased sündmused -Name[eu]=Hurrengo gertaerak -Name[fi]=Tulevat tapahtumat -Name[fr]=Évènements à venir -Name[ga]=Imeachtaí atá ag teacht -Name[gl]=Vindeiros eventos -Name[hu]=Közelgő események -Name[id]=Event Mendatang -Name[is]=Væntanlegir atburðir -Name[it]=Prossimi eventi -Name[ja]=近日中のイベント -Name[km]=ព្រឹត្តិការណ៍​ដែល​នឹង​កើត​មាន​ឡើង -Name[ko]=다가오는 약속 -Name[lt]=Artimiausi įvykiai -Name[lv]=Tuvākie notikumi -Name[mr]=पुढे येणाऱ्या घटना -Name[nb]=Kommende hendelser -Name[nds]=Anstahn Begeefnissen -Name[nl]=Komende evenementen -Name[nn]=Kommande hendingar -Name[pa]=ਆ ਰਹੇ ਈਵੈਂਟ -Name[pl]=Nadchodzące wydarzenia -Name[pt]=Próximos Eventos -Name[pt_BR]=Próximos eventos -Name[ro]=Evenimente apropiate -Name[ru]=События -Name[se]=Hotplug-dáhpáhusaid dáhtamohtor -Name[sk]=Nové udalosti -Name[sl]=Prihajajoči dogodki -Name[sr]=Предстојећи догађаји -Name[sr@ijekavian]=Предстојећи догађаји -Name[sr@ijekavianlatin]=Predstojeći događaji -Name[sr@latin]=Predstojeći događaji -Name[sv]=Kommande händelser -Name[tr]=Gelecek Etkinlikler -Name[ug]=پىلاندىكى ھادىسىلەر -Name[uk]=Майбутні події -Name[x-test]=xxUpcoming Eventsxx -Name[zh_CN]=近期事件 -Name[zh_TW]=即將來臨的事件 -Type=Service -ServiceTypes=Plasma/Applet -Icon=upcomingevents-amarok - -X-KDE-Library=amarok_context_applet_upcomingEvents -X-KDE-PluginInfo-Author=Joffrey Clavel -X-KDE-PluginInfo-Email=jclavel@clabert.info -X-KDE-PluginInfo-Name=upcomingEvents -X-KDE-PluginInfo-Version=0.1 -X-KDE-PluginInfo-Website= -X-KDE-PluginInfo-Depends= -X-KDE-PluginInfo-License=GPL -X-KDE-PluginInfo-EnabledByDefault=true -X-KDE-ParentApp=amarok -X-KDE-PluginInfo-Category=Current - diff --git a/amarok/src/context/applets/upcomingevents/upcoming-events-map.html b/amarok/src/context/applets/upcomingevents/upcoming-events-map.html deleted file mode 100644 index 62086cd4..00000000 --- a/amarok/src/context/applets/upcomingevents/upcoming-events-map.html +++ /dev/null @@ -1,87 +0,0 @@ -<html> -<head> -<meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> -<meta http-equiv="content-type" content="text/html; charset=UTF-8"/> -<style type="text/css"> - html { height: 100% } - body { height: 100%; margin: 0px; padding: 0px } - #map_canvas { height: 100% } -</style> -<title>Upcoming Event Venue Location - - - - -
- - - diff --git a/amarok/src/context/applets/upcomingevents/upcomingEventsGeneralSettings.ui b/amarok/src/context/applets/upcomingevents/upcomingEventsGeneralSettings.ui deleted file mode 100644 index 32a2e371..00000000 --- a/amarok/src/context/applets/upcomingevents/upcomingEventsGeneralSettings.ui +++ /dev/null @@ -1,59 +0,0 @@ - - - upcomingEventsGeneralSettings - - - - 0 - 0 - 217 - 60 - - - - - QFormLayout::ExpandingFieldsGrow - - - - - Filter events by date: - - - - - - - - All events - - - - - This week - - - - - This month - - - - - This year - - - - - - - - &Group venue events - - - - - - - - diff --git a/amarok/src/context/applets/upcomingevents/upcomingEventsSettings.ui b/amarok/src/context/applets/upcomingevents/upcomingEventsSettings.ui deleted file mode 100644 index 37efaf97..00000000 --- a/amarok/src/context/applets/upcomingevents/upcomingEventsSettings.ui +++ /dev/null @@ -1,52 +0,0 @@ - - - upcomingEventsSettings - - - - 0 - 0 - 163 - 68 - - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - All events - - - - - This week - - - - - This month - - - - - This year - - - - - - - - Show places as links - - - - - - - - diff --git a/amarok/src/context/applets/upcomingevents/upcomingEventsVenueSettings.ui b/amarok/src/context/applets/upcomingevents/upcomingEventsVenueSettings.ui deleted file mode 100644 index 18748028..00000000 --- a/amarok/src/context/applets/upcomingevents/upcomingEventsVenueSettings.ui +++ /dev/null @@ -1,310 +0,0 @@ - - - upcomingEventsVenueSettings - - - - 0 - 0 - 500 - 370 - - - - - 0 - 0 - - - - - 500 - 300 - - - - - - - - - - - - 150 - 0 - - - - true - - - true - - - Search Venue - - - true - - - - - - - Restrict venues to a specific country - - - QComboBox::AdjustToContentsOnFirstShow - - - 10 - - - - Any Country - - - - - - - - - - Search Results: - - - - - - - - 0 - 100 - - - - QAbstractItemView::NoEditTriggers - - - true - - - true - - - true - - - - - - - Selected Venues: - - - - - - - - 0 - 50 - - - - QAbstractItemView::NoEditTriggers - - - true - - - true - - - true - - - - - - - - - QLayout::SetMinAndMaxSize - - - - - - 0 - 0 - - - - - 150 - 150 - - - - 1 - - - Photo - - - Qt::AlignCenter - - - - - - - - 0 - 0 - - - - Qt::AlignCenter - - - - QLayout::SetMinAndMaxSize - - - QFormLayout::AllNonFixedFieldsGrow - - - - - Name: - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - - - City: - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - - - - - - true - - - - - - - - - - true - - - - - - - URL: - - - - - - - Website: - - - - - - - - - - true - - - - - - - - - - true - - - - - - - Country: - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - - - Street: - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - - - - - - true - - - - - - - - - - - - - KLineEdit - QLineEdit -
klineedit.h
-
- - KUrlLabel - QLabel -
kurllabel.h
-
- - KComboBox - QComboBox -
kcombobox.h
-
-
- - -
diff --git a/amarok/src/context/applets/wikipedia/CMakeLists.txt b/amarok/src/context/applets/wikipedia/CMakeLists.txt deleted file mode 100644 index a859cd90..00000000 --- a/amarok/src/context/applets/wikipedia/CMakeLists.txt +++ /dev/null @@ -1,23 +0,0 @@ -project(context-currenttrack) - -set( wiki_SRCS WikipediaApplet.cpp wikipediaGeneralSettings.ui wikipediaLanguageSettings.ui) - -include_directories(${Amarok_SOURCE_DIR}/src - ${Amarok_SOURCE_DIR}/src/context - ${Amarok_SOURCE_DIR}/src/network - ) - -kde4_add_plugin(amarok_context_applet_wikipedia ${wiki_SRCS}) -target_link_libraries(amarok_context_applet_wikipedia - amarokcore - amaroklib - ${KDE4_PLASMA_LIBS} - ${KDE4_KIO_LIBS} - ${KDE4_KDEWEBKIT_LIBS} - ${QT_QTWEBKIT_LIBRARY} -) - -install(TARGETS amarok_context_applet_wikipedia DESTINATION ${PLUGIN_INSTALL_DIR}) -install(FILES amarok-context-applet-wikipedia.desktop DESTINATION ${SERVICES_INSTALL_DIR}) -install(FILES amarok-wikipedia.svg amarok-wikipediaheader.svg DESTINATION ${DATA_INSTALL_DIR}/desktoptheme/default/widgets/ ) -install(FILES WikipediaCustomStyle.css bullet.gif DESTINATION ${DATA_INSTALL_DIR}/amarok/data ) diff --git a/amarok/src/context/applets/wikipedia/WikipediaApplet.cpp b/amarok/src/context/applets/wikipedia/WikipediaApplet.cpp deleted file mode 100644 index d905afb4..00000000 --- a/amarok/src/context/applets/wikipedia/WikipediaApplet.cpp +++ /dev/null @@ -1,805 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Leo Franchi * - * Copyright (c) 2009 Simon Esneault * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "WikipediaApplet" - -#include "WikipediaApplet.h" -#include "WikipediaApplet_p.h" -#include "moc_WikipediaApplet_p.cpp" - -#include "App.h" -#include "core/support/Amarok.h" -#include "context/widgets/AppletHeader.h" -#include "core/support/Debug.h" -#include "PaletteHandler.h" - -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -void -WikipediaAppletPrivate::parseWikiLangXml( const QByteArray &data ) -{ - QXmlStreamReader xml( data ); - while( !xml.atEnd() && !xml.hasError() ) - { - xml.readNext(); - if( xml.isStartElement() && xml.name() == "iw" ) - { - const QXmlStreamAttributes &a = xml.attributes(); - if( a.hasAttribute("prefix") && a.hasAttribute("language") && a.hasAttribute("url") ) - { - const QString &prefix = a.value("prefix").toString(); - const QString &language = a.value("language").toString(); - const QString &display = QString( "[%1] %2" ).arg( prefix ).arg( language ); - QListWidgetItem *item = new QListWidgetItem( display, 0 ); - // The urlPrefix is the lang code infront of the wikipedia host - // url. It is mostly the same as the "prefix" attribute but in - // some weird cases they differ, so we can't just use "prefix". - QString urlPrefix = QUrl( a.value("url").toString() ).host().remove(".wikipedia.org"); - item->setData( PrefixRole, prefix ); - item->setData( UrlPrefixRole, urlPrefix ); - item->setData( LanguageStringRole, language ); - languageSettingsUi.langSelector->availableListWidget()->addItem( item ); - } - } - } -} - -qint64 -WikipediaAppletPrivate::writeStyleSheet( const QByteArray &data ) -{ - delete css; - css = new KTemporaryFile(); - css->setSuffix( ".css" ); - qint64 written( -1 ); - if( css->open() ) - { - written = css->write( data ); - // NOTE shall we keep this commented out, and bring it back later or the base64 is just what we need ? - // QString filename = css->fileName(); - css->close(); // flush buffer to disk - // debug() << "set user stylesheet to:" << "file://" + filename; - // webView->page()->settings()->setUserStyleSheetUrl( "file://" + filename ); - } - return written; -} - -void -WikipediaAppletPrivate::scheduleEngineUpdate() -{ - Q_Q( WikipediaApplet ); - q->dataEngine( "amarok-wikipedia" )->query( "update" ); -} - -void -WikipediaAppletPrivate::setUrl( const QUrl &url ) -{ - webView->settings()->resetFontSize( QWebSettings::MinimumFontSize ); - webView->settings()->resetFontSize( QWebSettings::MinimumLogicalFontSize ); - webView->settings()->resetFontSize( QWebSettings::DefaultFontSize ); - webView->settings()->resetFontSize( QWebSettings::DefaultFixedFontSize ); - webView->settings()->resetFontFamily( QWebSettings::StandardFont ); - webView->setUrl( url ); - currentUrl = url; - dataContainer->removeAllData(); -} - -void -WikipediaAppletPrivate::pushUrlHistory( const QUrl &url ) -{ - if( !isForwardHistory && !isBackwardHistory && !url.isEmpty() ) - { - if( historyBack.isEmpty() || (!historyBack.isEmpty() && (url != historyBack.top())) ) - historyBack.push( url ); - historyForward.clear(); - } - isBackwardHistory = false; - isForwardHistory = false; - updateNavigationIcons(); -} - -void -WikipediaAppletPrivate::updateNavigationIcons() -{ - forwardIcon->action()->setEnabled( !historyForward.isEmpty() ); - backwardIcon->action()->setEnabled( !historyBack.isEmpty() ); -} - -void -WikipediaAppletPrivate::_titleChanged( const QString &title ) -{ - Q_Q( WikipediaApplet ); - q->setHeaderText( title ); -} - -void -WikipediaAppletPrivate::_goBackward() -{ - DEBUG_BLOCK - if( !historyBack.empty() ) - { - historyForward.push( currentUrl ); - currentUrl = historyBack.pop(); - isBackwardHistory = true; - dataContainer->removeAllData(); - dataContainer->setData( "clickUrl", currentUrl ); - scheduleEngineUpdate(); - updateNavigationIcons(); - } -} - -void -WikipediaAppletPrivate::_goForward() -{ - DEBUG_BLOCK - if( !historyForward.empty() ) - { - historyBack.push( currentUrl ); - currentUrl = historyForward.pop(); - isForwardHistory = true; - dataContainer->removeAllData(); - dataContainer->setData( "clickUrl", currentUrl ); - scheduleEngineUpdate(); - updateNavigationIcons(); - } -} - -void -WikipediaAppletPrivate::_gotoAlbum() -{ - dataContainer->setData( "goto", "album" ); - scheduleEngineUpdate(); -} - -void -WikipediaAppletPrivate::_gotoArtist() -{ - dataContainer->setData( "goto", "artist" ); - scheduleEngineUpdate(); -} - -void -WikipediaAppletPrivate::_gotoComposer() -{ - dataContainer->setData( "goto", "composer" ); - scheduleEngineUpdate(); -} - -void -WikipediaAppletPrivate::_gotoTrack() -{ - dataContainer->setData( "goto", "track" ); - scheduleEngineUpdate(); -} - -void -WikipediaAppletPrivate::_jsWindowObjectCleared() -{ - Q_Q( WikipediaApplet ); - webView->page()->mainFrame()->addToJavaScriptWindowObject( "mWebPage", q ); -} - -void -WikipediaAppletPrivate::_linkClicked( const QUrl &url ) -{ - DEBUG_BLOCK - Q_Q( WikipediaApplet ); - if( url.host().contains( "wikipedia.org" ) ) - { - isBackwardHistory = false; - isForwardHistory = false; - pushUrlHistory( currentUrl ); - if( useMobileWikipedia ) - { - setUrl( url ); - return; - } - q->setBusy( true ); - dataContainer->setData( "clickUrl", url ); - scheduleEngineUpdate(); - } - else - QDesktopServices::openUrl( url.toString() ); -} - -void -WikipediaAppletPrivate::_loadSettings() -{ - QStringList list; - QListWidget *listWidget = languageSettingsUi.langSelector->selectedListWidget(); - for( int i = 0, count = listWidget->count(); i < count; ++i ) - { - QListWidgetItem *item = listWidget->item( i ); - const QString &prefix = item->data( PrefixRole ).toString(); - const QString &urlPrefix = item->data( UrlPrefixRole ).toString(); - QString concat = QString("%1:%2").arg( prefix ).arg( urlPrefix ); - list << (prefix == urlPrefix ? prefix : concat); - } - langList = list; - useMobileWikipedia = (generalSettingsUi.mobileCheckBox->checkState() == Qt::Checked); - useSSL = (generalSettingsUi.sslCheckBox->checkState() == Qt::Checked); - Amarok::config("Wikipedia Applet").writeEntry( "PreferredLang", list ); - Amarok::config("Wikipedia Applet").writeEntry( "UseMobile", useMobileWikipedia ); - Amarok::config( "Wikipedia Applet" ).writeEntry( "UseSSL", useSSL ); - _paletteChanged( App::instance()->palette() ); - dataContainer->setData( "lang", langList ); - dataContainer->setData( "mobile", useMobileWikipedia ); - dataContainer->setData( "ssl", useSSL ); - scheduleEngineUpdate(); -} - -void -WikipediaAppletPrivate::_paletteChanged( const QPalette &palette ) -{ - if( useMobileWikipedia ) - { - webView->settings()->setUserStyleSheetUrl( QUrl() ); - return; - } - - // read css, replace color placeholders, write to file, load into page - QFile file( KStandardDirs::locate("data", "amarok/data/WikipediaCustomStyle.css" ) ); - if( file.open(QIODevice::ReadOnly | QIODevice::Text) ) - { - // transparent background - QPalette newPalette( palette ); - newPalette.setBrush( QPalette::Base, Qt::transparent ); - webView->page()->setPalette( newPalette ); - webView->setPalette( newPalette ); - webView->setAttribute( Qt::WA_OpaquePaintEvent, false ); - - QString contents = QString( file.readAll() ); - contents.replace( "/*{text_color}*/", palette.text().color().name() ); - contents.replace( "/*{link_color}*/", palette.link().color().name() ); - contents.replace( "/*{link_hover_color}*/", palette.linkVisited().color().name() ); - - const QString abg = The::paletteHandler()->alternateBackgroundColor().name(); - contents.replace( "/*{shaded_text_background_color}*/", abg ); - contents.replace( "/*{table_background_color}*/", abg ); - contents.replace( "/*{headings_background_color}*/", abg ); - - const QString hiColor = The::paletteHandler()->highlightColor().name(); - contents.replace( "/*{border_color}*/", hiColor ); - - const QString atbg = palette.highlight().color().name(); - contents.replace( "/*{alternate_table_background_color}*/", atbg ); - - const QByteArray &css = contents.toLatin1(); - qint64 written = writeStyleSheet( css ); - if( written != -1 ) - { - QUrl cssUrl( QString("data:text/css;charset=utf-8;base64,") + css.toBase64() ); - //NOTE We give it encoded on a base64 - // as it is currently broken on QtWebkit (see https://bugs.webkit.org/show_bug.cgi?id=34884 ) - webView->settings()->setUserStyleSheetUrl( cssUrl ); - } - } -} - -void -WikipediaAppletPrivate::_reloadWikipedia() -{ - DEBUG_BLOCK - if( useMobileWikipedia ) - { - webView->reload(); - return; - } - dataContainer->setData( "reload", true ); - scheduleEngineUpdate(); -} - -void -WikipediaAppletPrivate::_updateWebFonts() -{ - Q_Q( WikipediaApplet ); - if( !q->view() ) - return; - qreal ratio = q->view()->logicalDpiY() / 72.0; - qreal fixedFontSize = KGlobalSettings::fixedFont().pointSize() * ratio; - qreal generalFontSize = KGlobalSettings::generalFont().pointSize() * ratio; - qreal minimumFontSize = KGlobalSettings::smallestReadableFont().pointSize() * ratio; - QWebSettings *webSettings = webView->page()->settings(); - webSettings->setFontSize( QWebSettings::DefaultFixedFontSize, qRound(fixedFontSize) ); - webSettings->setFontSize( QWebSettings::DefaultFontSize, qRound(generalFontSize) ); - webSettings->setFontSize( QWebSettings::MinimumFontSize, qRound(minimumFontSize) ); - webSettings->setFontFamily( QWebSettings::StandardFont, KGlobalSettings::generalFont().family() ); -} - -void -WikipediaAppletPrivate::_getLangMapProgress( qint64 received, qint64 total ) -{ - languageSettingsUi.progressBar->setValue( 100.0 * qreal(received) / total ); -} - -void -WikipediaAppletPrivate::_getLangMapFinished( const KUrl &url, QByteArray data, - NetworkAccessManagerProxy::Error e ) -{ - Q_UNUSED( url ) - languageSettingsUi.downloadButton->setEnabled( true ); - languageSettingsUi.progressBar->setEnabled( false ); - - if( e.code != QNetworkReply::NoError ) - { - debug() << "Downloading Wikipedia supported languages failed:" << e.description; - return; - } - - QListWidget *availableListWidget = languageSettingsUi.langSelector->availableListWidget(); - availableListWidget->clear(); - parseWikiLangXml( data ); - languageSettingsUi.langSelector->setButtonsEnabled(); - QString buttonText = ( availableListWidget->count() > 0 ) - ? i18n( "Update Supported Languages" ) - : i18n( "Get Supported Languages" ); - languageSettingsUi.downloadButton->setText( buttonText ); - - QListWidget *selectedListWidget = languageSettingsUi.langSelector->selectedListWidget(); - QList selectedListItems = selectedListWidget->findItems( QChar('*'), Qt::MatchWildcard ); - for( int i = 0, count = selectedListItems.count(); i < count; ++i ) - { - QListWidgetItem *item = selectedListItems.at( i ); - int rowAtSelectedList = selectedListWidget->row( item ); - item = selectedListWidget->takeItem( rowAtSelectedList ); - const QString &prefix = item->data( PrefixRole ).toString(); - QList foundItems = availableListWidget->findItems( QString("[%1]").arg( prefix ), - Qt::MatchStartsWith ); - // should only have found one item if any - if( !foundItems.isEmpty() ) - { - item = foundItems.first(); - int rowAtAvailableList = languageSettingsUi.langSelector->availableListWidget()->row( item ); - item = availableListWidget->takeItem( rowAtAvailableList ); - selectedListWidget->addItem( item ); - } - } - - KSaveFile saveFile; - saveFile.setFileName( Amarok::saveLocation() + "wikipedia_languages.xml" ); - if( saveFile.open() ) - { - debug() << "Saving" << saveFile.fileName(); - QTextStream stream( &saveFile ); - stream << data; - stream.flush(); - saveFile.finalize(); - } - else - { - debug() << "Failed to saving Wikipedia languages file"; - } -} - -void -WikipediaAppletPrivate::_getLangMap() -{ - Q_Q( WikipediaApplet ); - languageSettingsUi.downloadButton->setEnabled( false ); - languageSettingsUi.progressBar->setEnabled( true ); - languageSettingsUi.progressBar->setMaximum( 100 ); - languageSettingsUi.progressBar->setValue( 0 ); - - KUrl url; - url.setScheme( "http" ); - url.setHost( "en.wikipedia.org" ); - url.setPath( "/w/api.php" ); - url.addQueryItem( "action", "query" ); - url.addQueryItem( "meta", "siteinfo" ); - url.addQueryItem( "siprop", "interwikimap" ); - url.addQueryItem( "sifilteriw", "local" ); - url.addQueryItem( "format", "xml" ); - QNetworkReply *reply = The::networkAccessManager()->getData( url, q, - SLOT(_getLangMapFinished(KUrl,QByteArray,NetworkAccessManagerProxy::Error)) ); - q->connect( reply, SIGNAL(downloadProgress(qint64,qint64)), q, SLOT(_getLangMapProgress(qint64,qint64)) ); -} - -void -WikipediaAppletPrivate::_configureLangSelector() -{ - DEBUG_BLOCK - Q_Q( WikipediaApplet ); - - QFile savedFile( Amarok::saveLocation() + "wikipedia_languages.xml" ); - if( savedFile.open(QIODevice::ReadOnly | QIODevice::Text) ) - parseWikiLangXml( savedFile.readAll() ); - savedFile.close(); - - QListWidget *availableListWidget = languageSettingsUi.langSelector->availableListWidget(); - QString buttonText = ( availableListWidget->count() > 0 ) - ? i18n( "Update Supported Languages" ) - : i18n( "Get Supported Languages" ); - languageSettingsUi.downloadButton->setText( buttonText ); - - for( int i = 0, count = langList.count(); i < count; ++i ) - { - const QStringList &split = langList.at( i ).split( QLatin1Char(':') ); - const QString &prefix = split.first(); - const QString &urlPrefix = (split.count() == 1) ? prefix : split.at( 1 ); - QList foundItems = availableListWidget->findItems( QString("[%1]").arg( prefix ), - Qt::MatchStartsWith ); - if( foundItems.isEmpty() ) - { - QListWidgetItem *item = new QListWidgetItem( prefix, 0 ); - item->setData( WikipediaAppletPrivate::PrefixRole, prefix ); - item->setData( WikipediaAppletPrivate::UrlPrefixRole, urlPrefix ); - languageSettingsUi.langSelector->selectedListWidget()->addItem( item ); - } - else // should only have found one item if any - { - QListWidgetItem *item = foundItems.first(); - int rowAtAvailableList = availableListWidget->row( item ); - item = availableListWidget->takeItem( rowAtAvailableList ); - languageSettingsUi.langSelector->selectedListWidget()->addItem( item ); - } - } - q->connect( languageSettingsUi.langSelector, SIGNAL(added(QListWidgetItem*)), q, SLOT(_langSelectorItemChanged(QListWidgetItem*)) ); - q->connect( languageSettingsUi.langSelector, SIGNAL(movedDown(QListWidgetItem*)), q, SLOT(_langSelectorItemChanged(QListWidgetItem*)) ); - q->connect( languageSettingsUi.langSelector, SIGNAL(movedUp(QListWidgetItem*)), q, SLOT(_langSelectorItemChanged(QListWidgetItem*)) ); - q->connect( languageSettingsUi.langSelector, SIGNAL(removed(QListWidgetItem*)), q, SLOT(_langSelectorItemChanged(QListWidgetItem*)) ); - q->connect( languageSettingsUi.langSelector->availableListWidget(), SIGNAL(itemClicked(QListWidgetItem*)), q, SLOT(_langSelectorItemChanged(QListWidgetItem*)) ); - q->connect( languageSettingsUi.langSelector->selectedListWidget(), SIGNAL(itemClicked(QListWidgetItem*)), q, SLOT(_langSelectorItemChanged(QListWidgetItem*)) ); -} - -void -WikipediaAppletPrivate::_pageLoadStarted() -{ - Q_Q( WikipediaApplet ); - - // create a proxy widget for displaying the webview load status in form of a progress bar - - // if the proxyWidget still exists, re-use the existing object - if ( proxyWidget ) - return; - - proxyWidget = new QGraphicsProxyWidget; - proxyWidget->setWidget( new QProgressBar ); - - // add proxy widget to layout - QGraphicsLinearLayout *lo = static_cast( q->layout() ); - lo->addItem( proxyWidget ); - lo->activate(); - QObject::connect( webView, SIGNAL(loadProgress(int)), q, SLOT(_pageLoadProgress(int)) ); -} - -void -WikipediaAppletPrivate::_pageLoadProgress( int progress ) -{ - DEBUG_ASSERT(proxyWidget, return) - - const QString kbytes = QString::number( webView->page()->totalBytes() / 1024 ); - - QProgressBar *pbar = qobject_cast( proxyWidget->widget() ); - pbar->setFormat( QString( "%1kB : %p%" ).arg( kbytes ) ); - pbar->setValue( progress ); -} - -void -WikipediaAppletPrivate::_pageLoadFinished( bool ok ) -{ - Q_UNUSED( ok ) - Q_Q( WikipediaApplet ); - - // remove proxy widget from layout again, delete it - QGraphicsLinearLayout *lo = static_cast( q->layout() ); - lo->removeItem( proxyWidget ); - lo->activate(); - - // disconnect (so that we don't get any further progress signalling) and delete widget - QObject::disconnect( webView, SIGNAL(loadProgress(int)), q, SLOT(_pageLoadProgress(int)) ); - proxyWidget->deleteLater(); - proxyWidget = 0; -} - -void -WikipediaAppletPrivate::_searchLineEditTextEdited( const QString &text ) -{ - webView->page()->findText( QString(), QWebPage::HighlightAllOccurrences ); // clears preivous highlights - webView->page()->findText( text, QWebPage::FindWrapsAroundDocument | QWebPage::HighlightAllOccurrences ); -} - -void -WikipediaAppletPrivate::_searchLineEditReturnPressed() -{ - const QString &text = webView->lineEdit()->text(); - webView->page()->findText( text, QWebPage::FindWrapsAroundDocument ); -} - -void -WikipediaAppletPrivate::_langSelectorItemChanged( QListWidgetItem *item ) -{ - Q_UNUSED( item ) - languageSettingsUi.langSelector->setButtonsEnabled(); -} - -WikipediaApplet::WikipediaApplet( QObject* parent, const QVariantList& args ) - : Context::Applet( parent, args ) - , d_ptr( new WikipediaAppletPrivate( this ) ) -{ - setHasConfigurationInterface( true ); -} - -WikipediaApplet::~WikipediaApplet() -{ - Q_D( WikipediaApplet ); - delete d->webView; - delete d->css; - delete d_ptr; -} - -void -WikipediaApplet::init() -{ - DEBUG_BLOCK - - Context::Applet::init(); - - Q_D( WikipediaApplet ); - - d->webView = new WikipediaWebView( this ); - d->webView->page()->mainFrame()->setScrollBarPolicy( Qt::Horizontal, Qt::ScrollBarAlwaysOff ); - // d->webView->page()->mainFrame()->addToJavaScriptWindowObject( "mWebPage", this ); BUG:259075 - d->webView->page()->setNetworkAccessManager( The::networkAccessManager() ); - d->webView->page()->setLinkDelegationPolicy ( QWebPage::DelegateAllLinks ); - d->webView->page()->settings()->setAttribute( QWebSettings::PrivateBrowsingEnabled, true ); - QWebSettings::globalSettings()->setAttribute( QWebSettings::DnsPrefetchEnabled, true ); - d->webView->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); - d->_updateWebFonts(); - connect( KGlobalSettings::self(), SIGNAL(appearanceChanged()), SLOT(_updateWebFonts()) ); - - connect( The::paletteHandler(), SIGNAL(newPalette(QPalette)), SLOT(_paletteChanged(QPalette)) ); - connect( d->webView->page(), SIGNAL(linkClicked(QUrl)), SLOT(_linkClicked(QUrl)) ); - connect( d->webView->page(), SIGNAL(loadStarted()), SLOT(_pageLoadStarted()) ); - connect( d->webView->page(), SIGNAL(loadFinished(bool)), SLOT(_pageLoadFinished(bool)) ); - // connect( d->webView->page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), SLOT(_jsWindowObjectCleared()) ); BUG:259075 - connect( d->webView->lineEdit(), SIGNAL(textChanged(QString)), SLOT(_searchLineEditTextEdited(QString)) ); - connect( d->webView->lineEdit(), SIGNAL(returnPressed()), SLOT(_searchLineEditReturnPressed()) ); - connect( d->webView, SIGNAL(titleChanged(QString)), this, SLOT(_titleChanged(QString)) ); - - enableHeader( true ); - setHeaderText( i18n( "Wikipedia" ) ); - - setCollapseOffHeight( -1 ); - setCollapseHeight( m_header->height() ); - setMinimumHeight( collapseHeight() ); - setPreferredHeight( collapseHeight() ); - - QAction* backwardAction = new QAction( this ); - backwardAction->setIcon( KIcon( "go-previous" ) ); - backwardAction->setEnabled( false ); - backwardAction->setText( i18n( "Back" ) ); - d->backwardIcon = addLeftHeaderAction( backwardAction ); - connect( d->backwardIcon, SIGNAL(clicked()), this, SLOT(_goBackward()) ); - - QAction* forwardAction = new QAction( this ); - forwardAction->setIcon( KIcon( "go-next" ) ); - forwardAction->setEnabled( false ); - forwardAction->setText( i18n( "Forward" ) ); - d->forwardIcon = addLeftHeaderAction( forwardAction ); - connect( d->forwardIcon, SIGNAL(clicked()), this, SLOT(_goForward()) ); - - QAction* reloadAction = new QAction( this ); - reloadAction->setIcon( KIcon( "view-refresh" ) ); - reloadAction->setText( i18n( "Reload" ) ); - d->reloadIcon = addLeftHeaderAction( reloadAction ); - connect( d->reloadIcon, SIGNAL(clicked()), this, SLOT(_reloadWikipedia()) ); - - QAction* artistAction = new QAction( this ); - artistAction->setIcon( KIcon( "filename-artist-amarok" ) ); - artistAction->setText( i18n( "Artist" ) ); - d->artistIcon = addRightHeaderAction( artistAction ); - connect( d->artistIcon, SIGNAL(clicked()), this, SLOT(_gotoArtist()) ); - - QAction* composerAction = new QAction( this ); - composerAction->setIcon( KIcon( "filename-composer-amarok" ) ); - composerAction->setText( i18n( "Composer" ) ); - d->composerIcon = addRightHeaderAction( composerAction ); - connect( d->composerIcon, SIGNAL(clicked()), this, SLOT(_gotoComposer()) ); - - QAction* albumAction = new QAction( this ); - albumAction->setIcon( KIcon( "filename-album-amarok" ) ); - albumAction->setText( i18n( "Album" ) ); - d->albumIcon = addRightHeaderAction( albumAction ); - connect( d->albumIcon, SIGNAL(clicked()), this, SLOT(_gotoAlbum()) ); - - QAction* trackAction = new QAction( this ); - trackAction->setIcon( KIcon( "filename-title-amarok" ) ); - trackAction->setText( i18n( "Track" ) ); - d->trackIcon = addRightHeaderAction( trackAction ); - connect( d->trackIcon, SIGNAL(clicked()), this, SLOT(_gotoTrack()) ); - - QAction* settingsAction = new QAction( this ); - settingsAction->setIcon( KIcon( "preferences-system" ) ); - settingsAction->setText( i18n( "Settings" ) ); - d->settingsIcon = addRightHeaderAction( settingsAction ); - connect( d->settingsIcon, SIGNAL(clicked()), this, SLOT(showConfigurationInterface()) ); - - QGraphicsLinearLayout *layout = new QGraphicsLinearLayout( Qt::Vertical ); - layout->setSpacing( 2 ); - layout->addItem( m_header ); - layout->addItem( d->webView ); - setLayout( layout ); - - dataEngine( "amarok-wikipedia" )->connectSource( "wikipedia", this ); - d->dataContainer = dataEngine( "amarok-wikipedia" )->containerForSource( "wikipedia" ); - - // Read config and inform the engine. - d->langList = Amarok::config("Wikipedia Applet").readEntry( "PreferredLang", QStringList() << "en" ); - d->useMobileWikipedia = Amarok::config("Wikipedia Applet").readEntry( "UseMobile", false ); - d->useSSL = Amarok::config( "Wikipedia Applet" ).readEntry( "UseSSL", true ); - d->_paletteChanged( App::instance()->palette() ); - d->dataContainer->setData( "lang", d->langList ); - d->dataContainer->setData( "mobile", d->useMobileWikipedia ); - d->dataContainer->setData( "ssl", d->useSSL ); - d->scheduleEngineUpdate(); - - updateConstraints(); -} - -void -WikipediaApplet::constraintsEvent( Plasma::Constraints constraints ) -{ - Context::Applet::constraintsEvent( constraints ); - update(); -} - -bool -WikipediaApplet::hasHeightForWidth() const -{ - return true; -} - -qreal -WikipediaApplet::heightForWidth( qreal width ) const -{ - Q_D( const WikipediaApplet ); - return width * d->aspectRatio; -} - -void -WikipediaApplet::dataUpdated( const QString &source, const Plasma::DataEngine::Data &data ) -{ - DEBUG_BLOCK - Q_UNUSED( source ) - Q_D( WikipediaApplet ); - - if( data.isEmpty() ) - { - debug() << "data Empty!"; - d->webView->hide(); - setCollapseOn(); - return; - } - - if( data.contains( "stopped" ) ) - { - debug() << "stopped"; - d->dataContainer->removeAllData(); - if( d->webView->title().isEmpty() ) - { - d->webView->hide(); - setCollapseOn(); - } - return; - } - - if( data.contains( "busy" ) ) - { - if( canAnimate() && data["busy"].toBool() ) - setBusy( true ); - return; - } - else - { - d->webView->show(); - setBusy( false ); - } - - if( data.contains( "message" ) ) - { - setCollapseOn(); - // messages have higher priority than pages - const QString &message = data.value( "message" ).toString(); - if( !message.isEmpty() ) - { - setHeaderText( i18n( "Wikipedia: %1", message ) ); - d->dataContainer->removeAllData(); - } - } - else if( data.contains( "sourceUrl" ) ) - { - const KUrl &url = data.value( "sourceUrl" ).value(); - d->setUrl( url ); - debug() << "source URL" << url; - setCollapseOff(); - - } - else if( data.contains( "page" ) ) - { - if( data.contains( "url" ) && !data.value( "url" ).toUrl().isEmpty() ) - { - const QUrl &url = data.value( "url" ).toUrl(); - d->_updateWebFonts(); - d->currentUrl = url; - d->webView->setHtml( data[ "page" ].toString(), url ); - d->dataContainer->removeAllData(); - } - setCollapseOff(); - } - else - { - setHeaderText( i18n( "Wikipedia" ) ); - } -} - -void -WikipediaApplet::loadWikipediaUrl( const QString &url ) -{ - Q_D( WikipediaApplet ); - d->_linkClicked( QUrl(url) ); -} - -void -WikipediaApplet::createConfigurationInterface( KConfigDialog *parent ) -{ - Q_D( WikipediaApplet ); - - parent->setButtons( KDialog::Ok | KDialog::Cancel ); - - KConfigGroup configuration = config(); - QWidget *langSettings = new QWidget; - d->languageSettingsUi.setupUi( langSettings ); - d->languageSettingsUi.downloadButton->setGuiItem( KStandardGuiItem::find() ); - d->languageSettingsUi.langSelector->availableListWidget()->setAlternatingRowColors( true ); - d->languageSettingsUi.langSelector->selectedListWidget()->setAlternatingRowColors( true ); - d->languageSettingsUi.langSelector->availableListWidget()->setUniformItemSizes( true ); - d->languageSettingsUi.langSelector->selectedListWidget()->setUniformItemSizes( true ); - d->languageSettingsUi.progressBar->setEnabled( false ); - - QWidget *genSettings = new QWidget; - d->generalSettingsUi.setupUi( genSettings ); - d->generalSettingsUi.mobileCheckBox->setCheckState( d->useMobileWikipedia ? Qt::Checked : Qt::Unchecked ); - d->generalSettingsUi.sslCheckBox->setCheckState( d->useSSL ? Qt::Checked : Qt::Unchecked ); - - connect( d->languageSettingsUi.downloadButton, SIGNAL(clicked()), this, SLOT(_getLangMap()) ); - connect( parent, SIGNAL(okClicked()), this, SLOT(_loadSettings()) ); - - parent->addPage( genSettings, i18n( "Wikipedia General Settings" ), "configure" ); - parent->addPage( langSettings, i18n( "Wikipedia Language Settings" ), "applications-education-language" ); - QTimer::singleShot( 0, this, SLOT(_configureLangSelector()) ); -} - -#include "moc_WikipediaApplet.cpp" diff --git a/amarok/src/context/applets/wikipedia/WikipediaApplet.h b/amarok/src/context/applets/wikipedia/WikipediaApplet.h deleted file mode 100644 index 9663ae30..00000000 --- a/amarok/src/context/applets/wikipedia/WikipediaApplet.h +++ /dev/null @@ -1,91 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Leo Franchi * - * Copyright (c) 2009 Simon Esneault * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef WIKIPEDIA_APPLET_H -#define WIKIPEDIA_APPLET_H - -#include "context/Applet.h" -#include "context/DataEngine.h" -#include "NetworkAccessManagerProxy.h" - -class QAction; -class KDialog; -class KConfigDialog; -class QListWidgetItem; -class WikipediaAppletPrivate; - -namespace Plasma -{ - class WebView; - class IconWidget; -} - -class WikipediaApplet : public Context::Applet -{ - Q_OBJECT - -public: - WikipediaApplet( QObject* parent, const QVariantList& args ); - ~WikipediaApplet(); - - void constraintsEvent( Plasma::Constraints constraints = Plasma::AllConstraints ); - - bool hasHeightForWidth() const; - qreal heightForWidth( qreal width ) const; - -public slots: - virtual void init(); - void dataUpdated( const QString& name, const Plasma::DataEngine::Data& data ); - void loadWikipediaUrl( const QString &url ); - -protected: - void createConfigurationInterface(KConfigDialog *parent); - -private: - WikipediaAppletPrivate *const d_ptr; - Q_DECLARE_PRIVATE( WikipediaApplet ) - - Q_PRIVATE_SLOT( d_ptr, void _goBackward() ) - Q_PRIVATE_SLOT( d_ptr, void _goForward() ) - Q_PRIVATE_SLOT( d_ptr, void _gotoAlbum() ) - Q_PRIVATE_SLOT( d_ptr, void _gotoArtist() ) - Q_PRIVATE_SLOT( d_ptr, void _gotoComposer() ) - Q_PRIVATE_SLOT( d_ptr, void _gotoTrack() ) - Q_PRIVATE_SLOT( d_ptr, void _linkClicked(const QUrl&) ) - Q_PRIVATE_SLOT( d_ptr, void _loadSettings() ) - Q_PRIVATE_SLOT( d_ptr, void _paletteChanged(const QPalette&) ) - Q_PRIVATE_SLOT( d_ptr, void _reloadWikipedia() ) - Q_PRIVATE_SLOT( d_ptr, void _updateWebFonts() ) - - Q_PRIVATE_SLOT( d_ptr, void _getLangMapProgress(qint64,qint64) ) - Q_PRIVATE_SLOT( d_ptr, void _getLangMapFinished(const KUrl&,QByteArray,NetworkAccessManagerProxy::Error) ) - Q_PRIVATE_SLOT( d_ptr, void _getLangMap() ) - Q_PRIVATE_SLOT( d_ptr, void _configureLangSelector() ) - Q_PRIVATE_SLOT( d_ptr, void _langSelectorItemChanged(QListWidgetItem*) ) - - Q_PRIVATE_SLOT( d_ptr, void _titleChanged(const QString&) ) - Q_PRIVATE_SLOT( d_ptr, void _pageLoadStarted() ) - Q_PRIVATE_SLOT( d_ptr, void _pageLoadProgress(int) ) - Q_PRIVATE_SLOT( d_ptr, void _pageLoadFinished(bool) ) - Q_PRIVATE_SLOT( d_ptr, void _searchLineEditTextEdited(const QString&) ) - Q_PRIVATE_SLOT( d_ptr, void _searchLineEditReturnPressed() ) - Q_PRIVATE_SLOT( d_ptr, void _jsWindowObjectCleared() ) -}; - -AMAROK_EXPORT_APPLET( wikipedia, WikipediaApplet ) - -#endif diff --git a/amarok/src/context/applets/wikipedia/WikipediaApplet_p.h b/amarok/src/context/applets/wikipedia/WikipediaApplet_p.h deleted file mode 100644 index 61cd80e9..00000000 --- a/amarok/src/context/applets/wikipedia/WikipediaApplet_p.h +++ /dev/null @@ -1,288 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Leo Franchi * - * Copyright (c) 2009 Simon Esneault * - * Copyright (c) 2010 Rick W. Chen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_WIKIPEDIAAPPLET_P_H -#define AMAROK_WIKIPEDIAAPPLET_P_H - -#include "WikipediaApplet.h" -#include "ui_wikipediaGeneralSettings.h" -#include "ui_wikipediaLanguageSettings.h" - -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -class KTemporaryFile; -class WikipediaWebView; - -namespace Plasma { - class DataContainer; - class IconWidget; -} - -class WikipediaAppletPrivate -{ -private: - WikipediaApplet *const q_ptr; - Q_DECLARE_PUBLIC( WikipediaApplet ) - -public: - WikipediaAppletPrivate( WikipediaApplet *parent ) - : q_ptr( parent ) - , css( 0 ) - , dataContainer( 0 ) - , albumIcon( 0 ) - , artistIcon( 0 ) - , composerIcon( 0 ) - , backwardIcon( 0 ) - , forwardIcon( 0 ) - , reloadIcon( 0 ) - , settingsIcon( 0 ) - , trackIcon( 0 ) - , webView( 0 ) - , proxyWidget( 0 ) - , aspectRatio( 0 ) - , isForwardHistory( false ) - , isBackwardHistory( false ) - {} - ~WikipediaAppletPrivate() {} - - // functions - void pushUrlHistory( const QUrl &url ); - void parseWikiLangXml( const QByteArray &xml ); - qint64 writeStyleSheet( const QByteArray &css ); - void scheduleEngineUpdate(); - void setUrl( const QUrl &url ); - void updateNavigationIcons(); - - // private slots - void _linkClicked( const QUrl &url ); - void _loadSettings(); - - void _goBackward(); - void _goForward(); - void _gotoArtist(); - void _gotoComposer(); - void _gotoAlbum(); - void _gotoTrack(); - - void _switchToLang( const QString &lang ); - void _reloadWikipedia(); - void _updateWebFonts(); - - void _paletteChanged( const QPalette &palette ); - - void _getLangMapProgress( qint64 received, qint64 total ); - void _getLangMapFinished( const KUrl &url, QByteArray data, NetworkAccessManagerProxy::Error e ); - void _getLangMap(); - - void _configureLangSelector(); - void _langSelectorItemChanged( QListWidgetItem *item ); - - void _titleChanged( const QString &title ); - void _pageLoadStarted(); - void _pageLoadProgress( int progress ); - void _pageLoadFinished( bool ok ); - void _searchLineEditTextEdited( const QString &text ); - void _searchLineEditReturnPressed(); - void _jsWindowObjectCleared(); - - // data members - enum WikiLangRoles - { - PrefixRole = Qt::UserRole + 1, - UrlPrefixRole = Qt::UserRole + 2, - LanguageStringRole = Qt::UserRole + 3 - }; - - KTemporaryFile *css; - Plasma::DataContainer *dataContainer; - Plasma::IconWidget *albumIcon; - Plasma::IconWidget *artistIcon; - Plasma::IconWidget *composerIcon; - Plasma::IconWidget *backwardIcon; - Plasma::IconWidget *forwardIcon; - Plasma::IconWidget *reloadIcon; - Plasma::IconWidget *settingsIcon; - Plasma::IconWidget *trackIcon; - WikipediaWebView *webView; - QGraphicsProxyWidget *proxyWidget; - QStack historyBack; - QStack historyForward; - QUrl currentUrl; - QStringList langList; - Ui::wikipediaGeneralSettings generalSettingsUi; - Ui::wikipediaLanguageSettings languageSettingsUi; - qreal aspectRatio; - bool isForwardHistory; - bool isBackwardHistory; - bool useMobileWikipedia; - bool useSSL; -}; - -class WikipediaSearchLineEdit : public Plasma::LineEdit -{ - Q_OBJECT - -public: - WikipediaSearchLineEdit( QGraphicsWidget *parent = 0 ) - : Plasma::LineEdit( parent ) {} - ~WikipediaSearchLineEdit() {} - - void setFocus( Qt::FocusReason reason ) - { - nativeWidget()->setFocus( reason ); - } - -protected: - void focusOutEvent( QFocusEvent *event ) - { - hide(); - nativeWidget()->clear(); - parentWidget()->setFocus(); - event->accept(); - } - - void keyPressEvent( QKeyEvent *event ) - { - if( event->key() == Qt::Key_Escape ) - { - clearFocus(); - event->accept(); - } - else - Plasma::LineEdit::keyPressEvent( event ); - } -}; - -class WikipediaWebView : public KGraphicsWebView -{ - Q_OBJECT - -public: - WikipediaWebView( QGraphicsItem *parent = 0 ) - : KGraphicsWebView( parent ) - { - m_lineEdit = new WikipediaSearchLineEdit( this ); - m_lineEdit->setContentsMargins( 0, 0, 0, 0 ); - m_lineEdit->setClearButtonShown( true ); - m_lineEdit->setVisible( false ); - - Plasma::Svg *borderSvg = new Plasma::Svg( this ); - borderSvg->setImagePath( "widgets/scrollwidget" ); - - m_topBorder = new Plasma::SvgWidget( this ); - m_topBorder->setSvg( borderSvg ); - m_topBorder->setElementID( "border-top" ); - m_topBorder->setZValue( 900 ); - m_topBorder->resize( -1, 10.0 ); - m_topBorder->show(); - - m_bottomBorder = new Plasma::SvgWidget( this ); - m_bottomBorder->setSvg( borderSvg ); - m_bottomBorder->setElementID( "border-bottom" ); - m_bottomBorder->setZValue( 900 ); - m_bottomBorder->resize( -1, 10.0 ); - m_bottomBorder->show(); - - page()->parent()->installEventFilter( this ); -#if defined(DEBUG_BUILD_TYPE) - page()->settings()->setAttribute( QWebSettings::DeveloperExtrasEnabled, true ); - m_inspector = new QWebInspector; - m_inspector->setPage( page() ); -#endif - } - - ~WikipediaWebView() - { -#if defined(DEBUG_BUILD_TYPE) - delete m_inspector; -#endif - } - - Plasma::LineEdit *lineEdit() - { return m_lineEdit; } - -protected: - bool eventFilter( QObject *obj , QEvent *event ) - { - if( obj == page()->parent() ) - { - if( event->type() == QEvent::KeyPress || - event->type() == QEvent::ShortcutOverride ) - { - QKeyEvent *keyEvent = static_cast( event ); - keyPressEvent( keyEvent ); - return true; - } - return false; - } - return KGraphicsWebView::eventFilter( obj, event ); - } - - void keyPressEvent( QKeyEvent *event ) - { - if( event->key() == Qt::Key_Slash || event->matches( QKeySequence::Find ) ) - { - qreal offsetX = m_lineEdit->rect().width(); - qreal offsetY = m_lineEdit->rect().height(); - offsetX += page()->currentFrame()->scrollBarGeometry( Qt::Vertical ).width(); - m_lineEdit->setPos( rect().bottomRight() - QPointF( offsetX, offsetY ) ); - m_lineEdit->setFocus( Qt::PopupFocusReason ); - m_lineEdit->show(); - event->accept(); - } - else - KGraphicsWebView::keyPressEvent( event ); - } - - void resizeEvent( QGraphicsSceneResizeEvent *event ) - { - KGraphicsWebView::resizeEvent( event ); - if( m_topBorder ) - { - m_topBorder->resize( event->newSize().width(), m_topBorder->size().height() ); - m_bottomBorder->resize( event->newSize().width(), m_bottomBorder->size().height() ); - QPointF bottomPoint = boundingRect().bottomLeft(); - bottomPoint.ry() -= m_bottomBorder->size().height(); - m_bottomBorder->setPos( bottomPoint ); - m_topBorder->setPos( mapFromParent( pos() ) ); - } - } - -private: -#if defined(DEBUG_BUILD_TYPE) - QWebInspector *m_inspector; -#endif - WikipediaSearchLineEdit *m_lineEdit; - Plasma::SvgWidget *m_topBorder; - Plasma::SvgWidget *m_bottomBorder; -}; - -#endif /* AMAROK_WIKIPEDIAAPPLET_P_H */ diff --git a/amarok/src/context/applets/wikipedia/WikipediaCustomStyle.css b/amarok/src/context/applets/wikipedia/WikipediaCustomStyle.css deleted file mode 100644 index 937e8dbe..00000000 --- a/amarok/src/context/applets/wikipedia/WikipediaCustomStyle.css +++ /dev/null @@ -1,346 +0,0 @@ -first { element: is; completely: ignored; } - -body -{ - margin: 0px; - padding: 6px 2px; - color: /*{text_color}*/; - font-size: medium; -} - -h1, h2, h3, h4, h5, h6 -{ - border: 2px solid /*{border_color}*/; - -webkit-border-radius: 4px; - -khtml-border-radius: 4px; - -moz-border-radius: 4px; - border-radius: 4px; - overflow: hidden; - margin: 5pt 0; - padding: 2pt 5pt; - background-color: /*{headings_background_color}*/; - color: /*{text_color}*/; -} - -p, div, table, ul, li -{ - font-size: medium; -} - -span.citation -{ - font-size: 90%; -} - -ul li -{ - margin-right: 5pt; -} -ul li a -{ - text-decoration: none; - color: /*{link_color}*/; -} -ul li a:hover -{ - text-decoration: underline; - color: /*{link_hover_color}*/; -} - -div#wiki_otherlangs -{ - clear: both; - border: 2px solid /*{border_color}*/; - -webkit-border-radius: 4px; - -khtml-border-radius: 4px; - -moz-border-radius: 4px; - border-radius: 4px; - background-color: /*{shaded_text_background_color}*/; - padding: 5pt; - color: /*{text_color}*/; -} - -div#bodyContent -{ - color: /*{text_color}*/; -} -div#bodyContent * -{ - color: /*{text_color}*/; -} - -/* Bullet list definition gracefully gottened from wikipedia - since we're - * showing their data, we should really present it like it was intended. So, we - * use their bullet. */ -div#bodyContent ul -{ - list-style-type: square; - margin: 0 1em; - padding: 0 1em; - list-style-image: url(bullet.gif); -} -div#bodyContent ul li -{ - display: list-item; -} -div#bodyContent a -{ - text-decoration: none; - color: /*{link_color}*/; -} -div#bodyContent a:hover -{ - text-decoration: underline; - color: /*{link_hover_color}*/; -} - -/* table for embedded media clip boxes */ -table.metadata, table.ambox -{ - border-radius: 1.6em; - border: 2px solid /*{border_color}*/; - -webkit-border-radius: 4px; - -khtml-border-radius: 4px; - -moz-border-radius: 4px; - border-radius: 4px; - position: relative; - left: 50%; - width: 50%; - margin: 5pt 0; - padding: 5pt; -} - -table.infobox -{ - clear: right; - float: right; - width: 150pt; - border: 2px solid /*{border_color}*/; - -webkit-border-radius: 4px; - -khtml-border-radius: 4px; - -moz-border-radius: 4px; - border-radius: 4px; - background-color: /*{table_background_color}*/; - margin: 5pt 2pt 0 5pt; -} - -table.bordered -{ - clear: both; - display: inline-block; - margin: 5pt 2pt 0 5pt; -} - -table.infobox th -{ - padding: 2pt; - border: 1px solid /*{border_color}*/; - background-color: /*{alternate_table_background_color}*/; - color: /*{text_color}*/; -} - -table.gallery -{ - clear: both; - display: block; - border: 2px solid /*{border_color}*/; - -webkit-border-radius: 4px; - -khtml-border-radius: 4px; - -moz-border-radius: 4px; - border-radius: 4px; - background-color: /*{table_background_color}*/; - margin: 5pt 0; -} - -table#toc -{ - display: none; -} - -/* -We're hiding the TOC, as it currently links directly to the wikipedia URL, not -relatively to the anchor inside the document, which make it open up in an -external browser - not really what we want it to do... -table#toc -{ -border: 1px dotted silver; -background: #f0f0f0; - -} - #toctitle h2 - { - font-size: 11pt; - background: silver; - padding: 2pt; -} - table#toc ul - { - list-style: none; -} - table#toc a,table#toc a span - { - color: #424280; -} - table#toc a:hover,table#toc a:hover span - { - color: #7E7EFF; -} - */ - -/* heading text - e.g. "This article is about the band", etc. */ -div.dablink -{ - width: 100%; - text-align: left; - font-style: italic; - color: /*{text_color}*/; -} -div#contentSub -{ - width: 100%; - text-align: right; - color: gray; -} -div#jump-to-nav -{ - width: 100%; - text-align: right; - color: gray; - margin-right: 5pt; -} -div#contentSub a, div#jump-to-nav a, div.dablink a -{ - color: /*{link_hover_color}*/; -} - -div#stub -{ - clear: right; - background-color: /*{shaded_text_background_color}*/; - border: 2px solid /*{border_color}*/; - border-radius: 4px; - -webkit-border-radius: 4px; - -khtml-border-radius: 4px; - -moz-border-radius: 4px; - border-radius: 4px; - width: 80%; - padding: 5pt; - margin-bottom: 10pt; - margin-left: auto; - margin-right: auto; -} - -table.wikitable -{ - border: 2px solid /*{border_color}*/; - -webkit-border-radius: 4px; - -khtml-border-radius: 4px; - -moz-border-radius: 4px; - border-radius: 4px; - border-collapse: collapse; - margin: 5pt; - background-color: /*{table_background_color}*/; -} -table.wikitable th -{ - padding: 2pt; - background-color: /*{alternate_table_background_color}*/; - border: 2px solid /*{border_color}*/; -} -table.wikitable td -{ - padding: 2pt; - background-color: /*{table_background_color}*/; - border: 2px solid /*{border_color}*/; -} - -table.navbox -{ - border: 2px solid /*{border_color}*/; - -webkit-border-radius: 4px; - -khtml-border-radius: 4px; - -moz-border-radius: 4px; - border-radius: 4px; - border-collapse: collapse; - margin: 5pt 2% 5pt 2%; - width: 96%; - background-color: /*{shaded_text_background_color}*/; -} -table.navbox td -{ - border: 2px solid /*{border_color}*/; - background-color: /*{table_background_color}*/; -} - -/* article thumbnail images */ -div.thumb -{ - border: 2px solid /*{border_color}*/; - -webkit-border-radius: 4px; - -khtml-border-radius: 4px; - -moz-border-radius: 4px; - border-radius: 4px; - margin: 5pt; - padding: 2pt; - width: auto; - background-color: /*{table_background_color}*/; -} - -div.thumbinner -{ - text-align: center; - overflow: hidden; -} - -div.thumbimage -{ - margin: 2pt 0; -} - -/* captions for thumbnail images */ -div.thumbcaption -{ - border: none; - text-align: left; - line-height: 1.4em; - font-size: smaller; -} - -div.magnify -{ - float: right; - border: none !important; - background: none !important; -} - -div.tright -{ - clear: right; - float: right; -} -div.tleft -{ - float: left; - clear: left; -} - -div.medialist ul li -{ - list-style: none; -} - -div#ogg_player_1, div#ogg_player_2, div#ogg_player_3, div#ogg_player_4, div#ogg_player_5, div#ogg_player_6, div#ogg_player_7, div#ogg_player_8, div#ogg_player_9, div#ogg_player_10, div#ogg_player_11, div#ogg_player_12, div#ogg_player_13 -{ - display: none; -} - -div#jump-to-nav, div.NavFrame, table.metadata -{ - display: none; -} - -div.medialist table -{ - margin: 5pt; - width: 100%; -} diff --git a/amarok/src/context/applets/wikipedia/amarok-context-applet-wikipedia.desktop b/amarok/src/context/applets/wikipedia/amarok-context-applet-wikipedia.desktop deleted file mode 100644 index c3310d3d..00000000 --- a/amarok/src/context/applets/wikipedia/amarok-context-applet-wikipedia.desktop +++ /dev/null @@ -1,71 +0,0 @@ -[Desktop Entry] -Name=Wikipedia -Name[bg]=Уикипедия -Name[bs]=Wikipedia -Name[ca]=Viquipèdia -Name[ca@valencia]=Viquipèdia -Name[cs]=Wikipedia -Name[csb]=Wikipedijô -Name[da]=Wikipedia -Name[de]=Wikipedia -Name[el]=Wikipedia -Name[en_GB]=Wikipedia -Name[es]=Wikipedia -Name[et]=Wikipedia -Name[eu]=Wikipedia -Name[fa]=ویکی‌پدیا -Name[fi]=Wikipedia -Name[fr]=Wikipédia -Name[ga]=Vicipéid -Name[gl]=Wikipedia -Name[hu]=Wikipedia -Name[id]=Wikipedia -Name[is]=Wikipedia -Name[it]=Wikipedia -Name[ja]=Wikipedia -Name[km]=វីគីភីឌៀ -Name[ko]=위키백과 -Name[lt]=Vikipedija -Name[lv]=Wikipēdija -Name[mr]=विकिपेडिया -Name[nb]=Wikipedia -Name[nds]=Wikipedia -Name[nl]=Wikipedia -Name[nn]=Wikipedia -Name[pa]=ਵਿਕਿਪੀਡਿਆ -Name[pl]=Wikipedia -Name[pt]=Wikipédia -Name[pt_BR]=Wikipédia -Name[ro]=Wikipedia -Name[ru]=Википедия -Name[sk]=Wikipédia -Name[sl]=Wikipedija -Name[sq]=Wikipedia -Name[sr]=Википедија -Name[sr@ijekavian]=Википедија -Name[sr@ijekavianlatin]=Wikipedia -Name[sr@latin]=Wikipedia -Name[sv]=Wikipedia -Name[th]=วิกิพีเดีย -Name[tr]=Wikipedia -Name[ug]=ۋىكىپېدىيە -Name[uk]=Вікіпедія -Name[wa]=Wikipedia -Name[x-test]=xxWikipediaxx -Name[zh_CN]=维基百科 -Name[zh_TW]=維基百科 -Type=Service -ServiceTypes=Plasma/Applet - -X-KDE-Library=amarok_context_applet_wikipedia -X-KDE-PluginInfo-Author=Leo Franchi -X-KDE-PluginInfo-Email=lfranchi@gmail.com -X-KDE-PluginInfo-Name=wikipedia -X-KDE-PluginInfo-Version=pre0.1 -X-KDE-PluginInfo-Website= -X-KDE-PluginInfo-Depends= -X-KDE-PluginInfo-License=GPL -X-KDE-PluginInfo-EnabledByDefault=true -X-KDE-ParentApp=amarok -X-KDE-PluginInfo-Category=Current - diff --git a/amarok/src/context/applets/wikipedia/amarok-wikipedia.svg b/amarok/src/context/applets/wikipedia/amarok-wikipedia.svg deleted file mode 100644 index 1b34f49e..00000000 --- a/amarok/src/context/applets/wikipedia/amarok-wikipedia.svg +++ /dev/null @@ -1,80 +0,0 @@ - - - - - - - image/svg+xml - - - - image/svg+xml - - - - - - - - - - - diff --git a/amarok/src/context/applets/wikipedia/amarok-wikipediaheader.svg b/amarok/src/context/applets/wikipedia/amarok-wikipediaheader.svg deleted file mode 100644 index da2dd9d9..00000000 --- a/amarok/src/context/applets/wikipedia/amarok-wikipediaheader.svg +++ /dev/null @@ -1,2317 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/amarok/src/context/applets/wikipedia/bullet.gif b/amarok/src/context/applets/wikipedia/bullet.gif deleted file mode 100644 index b43de48a..00000000 Binary files a/amarok/src/context/applets/wikipedia/bullet.gif and /dev/null differ diff --git a/amarok/src/context/applets/wikipedia/wikipediaGeneralSettings.ui b/amarok/src/context/applets/wikipedia/wikipediaGeneralSettings.ui deleted file mode 100644 index 84cb5df7..00000000 --- a/amarok/src/context/applets/wikipedia/wikipediaGeneralSettings.ui +++ /dev/null @@ -1,48 +0,0 @@ - - - wikipediaGeneralSettings - - - - 0 - 0 - 253 - 62 - - - - - 0 - 0 - - - - - 0 - - - 0 - - - - - - - Use Wikipedia &mobile version - - - - - - - Use &SSL - - - - - - - - - - diff --git a/amarok/src/context/applets/wikipedia/wikipediaLanguageSettings.ui b/amarok/src/context/applets/wikipedia/wikipediaLanguageSettings.ui deleted file mode 100644 index 80b1b6a1..00000000 --- a/amarok/src/context/applets/wikipedia/wikipediaLanguageSettings.ui +++ /dev/null @@ -1,81 +0,0 @@ - - - wikipediaLanguageSettings - - - - 0 - 0 - 469 - 300 - - - - - 0 - 0 - - - - - 400 - 300 - - - - - 0 - - - 0 - - - - - - 0 - 0 - - - - - - - - 4 - - - 4 - - - - - - - - - 0 - 0 - - - - - - - - - - - KPushButton - QPushButton -
kpushbutton.h
-
- - KActionSelector - QWidget -
kactionselector.h
-
-
- - -
diff --git a/amarok/src/context/containments/CMakeLists.txt b/amarok/src/context/containments/CMakeLists.txt deleted file mode 100644 index 1ebca0b2..00000000 --- a/amarok/src/context/containments/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -add_subdirectory( verticallayout ) diff --git a/amarok/src/context/containments/verticallayout/CMakeLists.txt b/amarok/src/context/containments/verticallayout/CMakeLists.txt deleted file mode 100644 index d86b9e28..00000000 --- a/amarok/src/context/containments/verticallayout/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -project(context-vertical-containment) - -include_directories( ../../.. - ../.. - .. ) - -set(context_SRCS - VerticalToolbarContainment.cpp - VerticalAppletLayout.cpp - ) - -kde4_add_plugin(amarok_containment_vertical ${context_SRCS}) -if(APPLE) - SET_TARGET_PROPERTIES(amarok_containment_vertical PROPERTIES LINK_FLAGS "-undefined dynamic_lookup") -endif(APPLE) -target_link_libraries(amarok_containment_vertical amarokcore amaroklib ${KDE4_PLASMA_LIBS} ${KDE4_KIO_LIBS}) - -install(TARGETS amarok_containment_vertical DESTINATION ${PLUGIN_INSTALL_DIR}) -install(FILES amarok-containment-vertical.desktop DESTINATION ${SERVICES_INSTALL_DIR}) diff --git a/amarok/src/context/containments/verticallayout/VerticalAppletLayout.cpp b/amarok/src/context/containments/verticallayout/VerticalAppletLayout.cpp deleted file mode 100644 index 13216a2b..00000000 --- a/amarok/src/context/containments/verticallayout/VerticalAppletLayout.cpp +++ /dev/null @@ -1,252 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Leo Franchi * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "VerticalAppletLayout" - -#include "VerticalAppletLayout.h" - -#include "Applet.h" -#include "Containment.h" -#include "core/support/Debug.h" - -#include -#include - -#include -#include -#include -#include -#include -#include - -Context::VerticalAppletLayout::VerticalAppletLayout( QGraphicsItem* parent ) - : QGraphicsWidget( parent ) - , m_showingIndex( -1 ) - , m_layout( new QGraphicsLinearLayout(Qt::Vertical, this) ) - , m_dummyWidget( new QGraphicsWidget( this ) ) -{ - m_layout->setContentsMargins( 0, 2, 0, 2 ); - m_layout->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); - m_layout->setSpacing( 0 ); - - // This dummy widget is added at the end of the layout to eat up the - // remaining space and keep the graphicslayout at the right size. Otherwise, - // if the last applet has a sizehint that is smaller than ours, the layout - // will assume that size, causing applets to be constrained when switching - // to another applet. - m_dummyWidget->setMinimumHeight( 0.0 ); - m_dummyWidget->setPreferredHeight( 0.0 ); - m_dummyWidget->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::MinimumExpanding ); - setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); -} - -Context::VerticalAppletLayout::~VerticalAppletLayout() -{ - DEBUG_BLOCK - qDeleteAll( m_appletList ); -} - -void -Context::VerticalAppletLayout::resizeEvent( QGraphicsSceneResizeEvent * event ) -{ - if( testAttribute( Qt::WA_PendingResizeEvent ) ) - return; // lets not do this more than necessary, shall we? - QGraphicsWidget::resizeEvent( event ); -} - -void -Context::VerticalAppletLayout::addApplet( Plasma::Applet* applet, int location ) -{ - DEBUG_BLOCK - debug() << "layout told to add applet" << applet->pluginName() << "at" << location; - if( m_appletList.isEmpty() ) - emit noApplets( false ); - - applet->show(); - - if( location < 0 ) // being told to add at end - { - m_appletList << applet; - m_layout->addItem( applet ); - location = m_appletList.size() - 1; // so the signal has the correct location - } - else - { - m_appletList.insert( location, applet ); - m_layout->insertItem( location, applet ); - } - - debug() << "emitting addApplet with location" << location; - emit appletAdded( applet, location ); - - // every time the geometry change, we will call showapplet ;) - connect( applet, SIGNAL(sizeHintChanged(Qt::SizeHint)), SLOT(refresh()) ); -} - -void -Context::VerticalAppletLayout::saveToConfig( KConfigGroup &conf ) -{ - DEBUG_BLOCK - QStringList plugins; - - for( int i = 0; i < m_appletList.size(); i++ ) - { - Plasma::Applet *applet = m_appletList.at(i); - if( applet != 0 ) - { - debug() << "saving applet" << applet->pluginName(); - plugins << applet->pluginName(); - } - conf.writeEntry( "plugins", plugins ); - } - conf.writeEntry( "firstShowingApplet", m_showingIndex ); -} - -void -Context::VerticalAppletLayout::refresh() -{ - showAtIndex( m_showingIndex ); -} - -void -Context::VerticalAppletLayout::showApplet( Plasma::Applet* applet ) // SLOT -{ - debug() << "showing applet" << applet->pluginName(); - showAtIndex( m_appletList.indexOf( applet ) ); -} - -void -Context::VerticalAppletLayout::moveApplet( Plasma::Applet* applet, int oldLoc, int newLoc) -{ - DEBUG_BLOCK - // if oldLoc is -1 we search for the applet to get the real location - if( oldLoc == -1 ) - oldLoc = m_appletList.indexOf( applet ); - if( oldLoc == -1 ) - debug() << "COULDN'T FIND APPLET IN LIST!"; - - // debug() << "moving applet in layout from" << oldLoc << "to" << newLoc; - - if( oldLoc < 0 || oldLoc > m_appletList.size() - 1 || newLoc < 0 || newLoc > m_appletList.size() || oldLoc == newLoc ) - return; - m_appletList.insert( newLoc, m_appletList.takeAt( oldLoc ) ); - QGraphicsLayoutItem *item = m_layout->itemAt( oldLoc ); - m_layout->removeAt( oldLoc ); - m_layout->insertItem( newLoc, item ); - showApplet( applet ); -} - -void -Context::VerticalAppletLayout::appletRemoved( Plasma::Applet* app ) -{ - DEBUG_BLOCK - int removedIndex = m_appletList.indexOf( app ); - debug() << "removing applet at index:" << removedIndex; - m_appletList.removeAll( app ); - if( m_showingIndex > removedIndex ) - m_showingIndex--; - m_layout->removeItem( app ); - - debug() << "got " << m_appletList.size() << " applets left"; - if( m_appletList.size() == 0 ) - emit noApplets( true ); - refresh(); -} - -void -Context::VerticalAppletLayout::showAtIndex( int index ) -{ - if( (index < 0) || (index > m_appletList.size() - 1) ) - return; - if( m_appletList.isEmpty() || !m_appletList.value( index ) ) - return; - - setGeometry( scene()->sceneRect() ); - m_layout->removeItem( m_dummyWidget ); - - // remove and hide all applets prior to index - QList toRemove; - for( int i = 0, count = m_layout->count(); i < count; ++i ) - { - if( QGraphicsLayoutItem *item = m_layout->itemAt( i ) ) - { - Plasma::Applet *applet = static_cast( item ); - if( m_appletList.indexOf( applet ) < index ) - toRemove << applet; - } - } - - foreach( Plasma::Applet *applet, toRemove ) - { - m_layout->removeItem( applet ); - applet->hide(); - } - - // iterate through the applets and add ones that we can fit using the size - // hints provided by the applets - qreal height = 0.0; - int currentIndex = m_appletList.size(); - for( int count = currentIndex, i = index; i < count; ++i ) - { - Plasma::Applet *item = m_appletList.at( i ); - const qreal remainingH = size().height() - height; - const qreal preferredH = item->effectiveSizeHint( Qt::PreferredSize ).height(); - const qreal minimumH = item->effectiveSizeHint( Qt::MinimumSize ).height(); - const qreal maximumH = item->effectiveSizeHint( Qt::MaximumSize ).height(); - - Context::Applet *applet = qobject_cast( item ); - if( applet ) { - const bool wantSpace = (applet->collapseOffHeight() < 0) && (maximumH > remainingH); - - if( (preferredH > remainingH) || (wantSpace && !applet->isCollapsed() ) ) - { - bool show = ( minimumH <= remainingH ); - currentIndex = i; - applet->setVisible( show ); - if( show ) - { - m_layout->addItem( applet ); - if( wantSpace ) - { - applet->resize( size().width(), remainingH ); - m_layout->setStretchFactor( applet, 10000 ); - } - applet->update(); - ++currentIndex; - } - break; - } - } - - height += preferredH; - m_layout->addItem( item ); - item->show(); - item->update(); - } - - // remove and hide all other applets - for( int i = currentIndex; i < m_appletList.count(); ++i ) - { - Plasma::Applet *item = m_appletList.at( i ); - m_layout->removeItem( item ); - item->hide(); - } - - m_layout->addItem( m_dummyWidget ); - m_showingIndex = index; -} - -#include "moc_VerticalAppletLayout.cpp" diff --git a/amarok/src/context/containments/verticallayout/VerticalAppletLayout.h b/amarok/src/context/containments/verticallayout/VerticalAppletLayout.h deleted file mode 100644 index 76ba100d..00000000 --- a/amarok/src/context/containments/verticallayout/VerticalAppletLayout.h +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Leo Franchi * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_VERTICAL_APPLET_LAYOUT_H -#define AMAROK_VERTICAL_APPLET_LAYOUT_H - - -#include "amarok_export.h" - -#include - -class KConfigGroup; - -class QGraphicsItem; -class QGraphicsSceneResizeEvent; -class QPainter; -class QStyleOptionGraphicsItem; -class QGraphicsLinearLayout; - -namespace Plasma -{ - class Applet; -} - -namespace Context -{ - -class Containment; - -class VerticalAppletLayout : public QGraphicsWidget -{ - Q_OBJECT - public: - VerticalAppletLayout( QGraphicsItem* parent = 0 ); - ~VerticalAppletLayout(); - - void addApplet( Plasma::Applet*, int location = -1 ); - - virtual void saveToConfig( KConfigGroup &conf ); - - void showAtIndex( int index ); - - signals: - void appletAdded( Plasma::Applet* applet, int location ); - void noApplets( bool ); - - public slots: - void showApplet( Plasma::Applet* ); - void moveApplet( Plasma::Applet*, int, int); - void appletRemoved( Plasma::Applet* app ); - void refresh(); - - protected: - // reimplemented from QGraphicsWidget - virtual void resizeEvent( QGraphicsSceneResizeEvent * event ); - - private: - QList< Plasma::Applet* > m_appletList; - int m_showingIndex; - - QGraphicsLinearLayout *m_layout; - QGraphicsWidget *m_dummyWidget; -}; - -} // namespace Context - -#endif diff --git a/amarok/src/context/containments/verticallayout/VerticalToolbarContainment.cpp b/amarok/src/context/containments/verticallayout/VerticalToolbarContainment.cpp deleted file mode 100644 index 82b306c8..00000000 --- a/amarok/src/context/containments/verticallayout/VerticalToolbarContainment.cpp +++ /dev/null @@ -1,211 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Leo Franchi * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "VerticalToolbarContainment" - -#include "VerticalToolbarContainment.h" - -#include "ContextView.h" -#include "core/interfaces/Logger.h" -#include "core/support/Components.h" -#include "core/support/Debug.h" -#include "EngineController.h" -#include "PaletteHandler.h" -#include "VerticalAppletLayout.h" - -#include - -#include - -Context::VerticalToolbarContainment::VerticalToolbarContainment( QObject *parent, const QVariantList &args ) - : Containment( parent, args ) - , m_view( 0 ) - , m_applets( 0 ) - , m_noAppletText( 0 ) -{ - DEBUG_BLOCK - setContainmentType( CustomContainment ); - setDrawWallpaper( false ); - // setScreen( -1 ); - setImmutability( Plasma::Mutable ); - - debug() << "applet containment has corona:" << corona(); - m_applets = new VerticalAppletLayout( this ); - - connect( this, SIGNAL(appletRemoved(Plasma::Applet*)), SLOT(appletRemoved(Plasma::Applet*)) ); - connect( this, SIGNAL(appletRemoved(Plasma::Applet*)), SIGNAL(geometryChanged()) ); - - connect( m_applets, SIGNAL(appletAdded(Plasma::Applet*,int)), SIGNAL(appletAdded(Plasma::Applet*,int)) ); - connect( m_applets, SIGNAL(appletAdded(Plasma::Applet*,int)), SIGNAL(geometryChanged()) ); - connect( m_applets, SIGNAL(noApplets(bool)), SLOT(showEmptyText(bool)) ); - -} - -Context::VerticalToolbarContainment::~VerticalToolbarContainment() -{} - -void -Context::VerticalToolbarContainment::constraintsEvent( Plasma::Constraints constraints ) -{ - Q_UNUSED( constraints ) - if( m_noAppletText ) - { - QRectF masterRect = contentsRect(); - m_noAppletText->setTextWidth( masterRect.width() * .4 ); - QPointF topLeft( ( masterRect.width() / 2 ) - ( m_noAppletText->boundingRect().width() / 2 ), ( masterRect.height() / 2 ) - ( m_noAppletText->boundingRect().height() / 2 ) ); - m_noAppletText->setPos( topLeft ); - } -} - -QList -Context::VerticalToolbarContainment::contextualActions() -{ - return QList< QAction* >(); -} - -void -Context::VerticalToolbarContainment::saveToConfig( KConfigGroup &conf ) -{ - m_applets->saveToConfig( conf ); -} - -void -Context::VerticalToolbarContainment::loadConfig( const KConfigGroup &conf ) -{ - DEBUG_BLOCK - - QStringList plugins = conf.readEntry( "plugins", QStringList() ); - debug() << "plugins.size(): " << plugins.size(); - - foreach( const QString& plugin, plugins ) - { - PERF_LOG( qPrintable( QString("Adding applet: %1").arg( plugin ) ) ) - debug() << "Adding applet: " << plugin; - addApplet( plugin, -1 ); - } - - int showing = conf.readEntry( "firstShowingApplet", 0 ); - m_applets->showAtIndex( showing ); -} - -void -Context::VerticalToolbarContainment::setView( ContextView* view ) -{ - DEBUG_BLOCK - - m_view = view; - // kick the toolbar with a real corona no w - emit updatedContainment( this ); -} - -Context::ContextView* -Context::VerticalToolbarContainment::view() -{ - return m_view; -} - -void -Context::VerticalToolbarContainment::updateGeometry() -{ - Context::Containment::updateGeometry(); - - /* We used to use _scene_ sceneRect here to update applets and geomtery, but that - * leaded to infinite loop (across mainloop) - see bug 278897. - * (m_applets->setGeometry(), refresh() would enlarge _scene_ sceneRect by a few - * pixels which would trigger updateGeometry() and so on...) - * - * We now use _view_ sceneRect to update geometry and do nothing without a view - */ - if(!view()) - return; - - // mimic ContextView::resizeEvent(), nothing else seems to work, bug 292895 - QRectF rect( view()->pos(), view()->maximumViewportSize() ); - setGeometry( rect ); - m_applets->setGeometry( rect ); - m_applets->refresh(); -} - -void -Context::VerticalToolbarContainment::addApplet( const QString& pluginName, const int loc ) // SLOT -{ - DEBUG_BLOCK - - if( pluginName == "analyzer" && !EngineController::instance()->supportsAudioDataOutput() ) - { - Amarok::Components::logger()->longMessage( i18n( "Error: Visualizations are not supported by your current Phonon backend." ), - Amarok::Logger::Error ) ; - - return; - } - - Plasma::Applet* applet = Plasma::Containment::addApplet( pluginName ); - - Q_ASSERT_X( applet, "addApplet", "FAILED ADDING APPLET TO CONTAINMENT!! NOT FOUND!!" ); - - m_applets->addApplet( applet, loc ); - applet->setFlag( QGraphicsItem::ItemIsMovable, false ); -} - -void -Context::VerticalToolbarContainment::appletRemoved( Plasma::Applet* applet ) -{ - m_applets->appletRemoved( applet ); -} - -void -Context::VerticalToolbarContainment::showApplet( Plasma::Applet* applet ) -{ - m_applets->showApplet( applet ); -} - -void -Context::VerticalToolbarContainment::moveApplet( Plasma::Applet* applet, int a, int b) -{ - m_applets->moveApplet( applet, a, b); -} - -void -Context::VerticalToolbarContainment::wheelEvent( QGraphicsSceneWheelEvent* event ) -{ - Q_UNUSED( event ) - //eat wheel events, we don't want scrolling -} - -void -Context::VerticalToolbarContainment::showEmptyText( bool toShow ) // SLOT -{ - if( toShow ) - { - if( !m_noAppletText ) - { - m_noAppletText = new QGraphicsTextItem( this ); - m_noAppletText->setHtml( QString( " \ -

%2 " ) - .arg( The::paletteHandler()->highlightColor().name() ) - .arg( i18n( "Please add some applets from the toolbar at the bottom of the context view." ) ) ); - } - m_noAppletText->show(); - } - else if( m_noAppletText ) - { - m_noAppletText->hide(); - } - updateConstraints(); - update(); -} - -#include "moc_VerticalToolbarContainment.cpp" diff --git a/amarok/src/context/containments/verticallayout/VerticalToolbarContainment.h b/amarok/src/context/containments/verticallayout/VerticalToolbarContainment.h deleted file mode 100644 index 6c933ab1..00000000 --- a/amarok/src/context/containments/verticallayout/VerticalToolbarContainment.h +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Leo Franchi * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_VERTICAL_TOOLBAR_CONTAINMENT_H -#define AMAROK_VERTICAL_TOOLBAR_CONTAINMENT_H - -#include "Applet.h" -#include "Containment.h" -#include "ContextView.h" - -class KConfigGroup; - -class QGraphicsLinearLayout; - -namespace Context -{ - -class VerticalAppletLayout; - -class VerticalToolbarContainment : public Containment -{ - Q_OBJECT - public: - VerticalToolbarContainment( QObject *parent, const QVariantList &args ); - ~VerticalToolbarContainment(); - - void constraintsEvent( Plasma::Constraints constraints ); - - QList contextualActions(); - - virtual void saveToConfig( KConfigGroup &conf ); - virtual void loadConfig( const KConfigGroup &conf ); - - virtual void setView( ContextView* view); - virtual ContextView *view(); - - public slots: - void addApplet( const QString& pluginName, const int ); - void appletRemoved( Plasma::Applet* ); - // these slots below are forwarded to the layout - void showApplet( Plasma::Applet* ); - void moveApplet( Plasma::Applet*, int, int ); - - protected: - virtual void wheelEvent( QGraphicsSceneWheelEvent* event ); - virtual void updateGeometry(); - - signals: - void updatedContainment( Containment* ); - void appletAdded( Plasma::Applet*, int ); - - private slots: - void showEmptyText( bool ); - - private: - ContextView* m_view; - VerticalAppletLayout* m_applets; - QGraphicsTextItem* m_noAppletText; -}; - -K_EXPORT_PLASMA_APPLET( amarok_containment_vertical, VerticalToolbarContainment ) - -} - -#endif - diff --git a/amarok/src/context/containments/verticallayout/amarok-containment-vertical.desktop b/amarok/src/context/containments/verticallayout/amarok-containment-vertical.desktop deleted file mode 100644 index 1b80b8cd..00000000 --- a/amarok/src/context/containments/verticallayout/amarok-containment-vertical.desktop +++ /dev/null @@ -1,116 +0,0 @@ -[Desktop Entry] -Name=Vertical Context Containment -Name[bg]=Вертикален контекст -Name[bs]=Sadržalac za vertikalni kontekst -Name[ca]=Contenidor vertical de context -Name[ca@valencia]=Contenidor vertical de context -Name[cs]=Svislý kontejner kontextu -Name[da]=Lodret kontekstbeholder -Name[de]=Vertikaler Kontext-Container -Name[el]=Υποδοχέας κατακόρυφου περιεχομένου -Name[en_GB]=Vertical Context Containment -Name[es]=Contenedor de contexto vertical -Name[et]=Püstine kontekstikonteiner -Name[eu]=Testuinguru bertikaleko edukia -Name[fi]=Pystysuuntainen kontekstin sovelmasäiliö -Name[fr]=Conteneur vertical du navigateur de contexte -Name[ga]=Coimeádán Comhthéacs Ingearaigh -Name[gl]=Contedor vertical de contextos -Name[hu]=Függőleges környezettároló -Name[id]=Ruang Kendali Konteks Vertikal -Name[is]=Lóðréttur geymslugrunnur samhengisupplýsinga -Name[it]=Contenitore verticale di contesto -Name[ja]=垂直コンテキストコンテンツ -Name[km]=ការ​ផ្ទុក​បរិបទ​បញ្ឈរ -Name[ko]=수직 컨텍스트 컨테이너 -Name[lt]=Vertikali konteksto vieta -Name[lv]=Vertikāls konteksta konteiners -Name[nb]=Loddrett kontekstbeholder -Name[nds]=Pielrecht Kontextgelaats -Name[nl]=Verticale contextcontainer -Name[nn]=Loddrett behaldar -Name[pa]=ਵਰਟੀਕਲ ਪਰਸੰਗ ਕੰਨਟੇਨਮੈਂਟ -Name[pl]=Zasobnik kontekstu pionowej -Name[pt]=Contentor de Contexto Vertical -Name[pt_BR]=Contendor vertical de contexto -Name[ro]=Container vertical pentru context -Name[ru]=Содержимое контекста по вертикали -Name[sk]=Vertikálne obmedzenie kontextu -Name[sl]=Vsebnik za navpično vsebino -Name[sr]=Садржалац за вертикални контекст -Name[sr@ijekavian]=Садржалац за вертикални контекст -Name[sr@ijekavianlatin]=Sadržalac za vertikalni kontekst -Name[sr@latin]=Sadržalac za vertikalni kontekst -Name[sv]=Vertikal sammanhangsomgivning -Name[th]=ส่วนบรรจุสำหรับคอนเท็กซ์ของแอมอะร็อก -Name[tr]=Dikey İçerik Taşıyıcı -Name[uk]=Вертикальний контейнер вмісту -Name[wa]=Contneu d' astampé do contecse -Name[x-test]=xxVertical Context Containmentxx -Name[zh_CN]=垂直环境容器 -Name[zh_TW]=垂直的內容容器 -Comment=A vertical containment for the Amarok Context -Comment[bg]=Вертикален контекст на Amarok -Comment[bs]=Vertikalni sadržalac za Amarokov kontekst -Comment[ca]=Un contenidor vertical per a l'Amarok Context -Comment[ca@valencia]=Un contenidor vertical per a l'Amarok Context -Comment[cs]=Svislý kontejner pro kontext Amaroku -Comment[da]=En lodret beholder til Amarok-kontekst -Comment[de]=Ein senkrechtes Behältnis für Amarok-Kontext -Comment[el]=Ένας κατακόρυφος υποδοχέας για το περιεχόμενο Amarok -Comment[en_GB]=A vertical containment for the Amarok Context -Comment[es]=Un contenedor vertical para el contexto de Amarok -Comment[et]=Amaroki konteksti püstine konteiner -Comment[eu]=Amarok-en testuingururako eduki bertikala -Comment[fi]=Pystysuuntainen sovelmasäiliö Amarokin kontekstille -Comment[fr]=Un conteneur vertical pour le navigateur de contexte de Amarok -Comment[ga]=Coimeádán ingearach le haghaidh Comhthéacs Amarok -Comment[gl]=Un contedor vertical para o contexto de Amarok -Comment[hu]=Függőleges tároló az Amarok-környezethez -Comment[id]=Sebuah ruang kendali vertikal untuk Konteks Amarok -Comment[is]=Lóðréttur grunnur fyrir Amarok samhengisupplýsingar -Comment[it]=Un contenitore verticale per i contesti di Amarok -Comment[ja]=Amarok コンテキストの垂直コンテンツ -Comment[km]=ការ​ផ្ទុក​បញ្ឈរ​សម្រាប់​​បរិបទ Amarok -Comment[ko]=Amarok 컨텍스트를 포함하는 수직 컨테이너 -Comment[lt]=Vertikali Amaroko kontekstinės informacijos vieta -Comment[lv]=Vertikāls konteiners Amarok kontekstam -Comment[nb]=En loddrett beholder for Amarok Kontekst -Comment[nds]=En pielrecht Schell för Amarok-Kontext -Comment[nl]=Een verticale container voor de Amarok-context -Comment[nn]=Ein loddrett behaldar for Amarok-samanheng -Comment[pl]=Zasobnik dla pionowego kontekstu Amaroka -Comment[pt]=Um contentor vertical para o Contexto do Amarok -Comment[pt_BR]=Um contendor vertical para o contexto do Amarok -Comment[ro]=Un container vertical pentru contextul Amarok -Comment[ru]=Содержимое контекста Amarok по вертикали -Comment[sk]=Vertikálne obmedzenie pre kontext Amaroku -Comment[sl]=Vsebnik za navpično vsebino v Amaroku -Comment[sr]=Вертикални садржалац за Амароков контекст -Comment[sr@ijekavian]=Вертикални садржалац за Амароков контекст -Comment[sr@ijekavianlatin]=Vertikalni sadržalac za Amarokov kontekst -Comment[sr@latin]=Vertikalni sadržalac za Amarokov kontekst -Comment[sv]=En vertikal omgivning för Amaroks Sammanhang -Comment[th]=ส่วนบรรจุทางแนวตั้งสำหรับคอนเท็กซ์ของแอมอะร็อก -Comment[tr]=Amarok İçeriği için bir dikey taşıyıcı -Comment[uk]=Вертикальний контейнер для контексту Amarok -Comment[wa]=On contneu d' astampé po l' contecse d' Amarok -Comment[x-test]=xxA vertical containment for the Amarok Contextxx -Comment[zh_CN]=用于 Amarok 环境的一个垂直容器 -Comment[zh_TW]=提供給 Amarok 內容的垂直容器 - -Icon= -Type=Service -ServiceTypes=Plasma/Containment - -X-KDE-Library=amarok_containment_vertical -X-KDE-PluginInfo-Author=Leo Franchi -X-KDE-PluginInfo-Email=amarok@kde.org -X-KDE-PluginInfo-Name=amarok_containment_vertical -X-KDE-PluginInfo-Version=.1 -X-KDE-PluginInfo-Website=http://amarok.kde.org/ -X-KDE-PluginInfo-Category=Miscellaneous -X-KDE-PluginInfo-Depends= -X-KDE-PluginInfo-License=GPL -X-KDE-PluginInfo-EnabledByDefault=true -X-KDE-ParentApp=AmarokInvisible diff --git a/amarok/src/context/engines/CMakeLists.txt b/amarok/src/context/engines/CMakeLists.txt deleted file mode 100644 index ec191a83..00000000 --- a/amarok/src/context/engines/CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ -add_subdirectory( current ) -add_subdirectory( info ) -add_subdirectory( labels ) -add_subdirectory( lyrics ) -add_subdirectory( photos ) -add_subdirectory( tabs ) -add_subdirectory( wikipedia ) - -if(LIBLASTFM_FOUND) - add_subdirectory( similarartists ) - add_subdirectory( upcomingevents ) -endif(LIBLASTFM_FOUND) diff --git a/amarok/src/context/engines/current/CMakeLists.txt b/amarok/src/context/engines/current/CMakeLists.txt deleted file mode 100644 index 3de7b041..00000000 --- a/amarok/src/context/engines/current/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -include_directories( ../../.. - ../../../context - ${CMAKE_CURRENT_BINARY_DIR}/../../.. # for amarok_config.h -) - -set( current_engine_SRCS - CurrentEngine.cpp -) - -kde4_add_plugin(amarok_data_engine_current ${current_engine_SRCS}) -target_link_libraries( amarok_data_engine_current amarokcore amaroklib ${KDE4_PLASMA_LIBS} ${KDE4_KDECORE_LIBS} ${QT_QTGUI_LIBRARY} ) - -install( TARGETS amarok_data_engine_current DESTINATION ${PLUGIN_INSTALL_DIR} ) -install( FILES amarok-data-engine-current.desktop DESTINATION ${SERVICES_INSTALL_DIR} ) diff --git a/amarok/src/context/engines/current/CurrentEngine.cpp b/amarok/src/context/engines/current/CurrentEngine.cpp deleted file mode 100644 index 9050cd54..00000000 --- a/amarok/src/context/engines/current/CurrentEngine.cpp +++ /dev/null @@ -1,273 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Leo Franchi * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "CurrentEngine" - -#include "CurrentEngine.h" - -#include "EngineController.h" -#include "context/ContextView.h" -#include "core/support/Debug.h" -#include "core/capabilities/SourceInfoCapability.h" -#include "core/collections/Collection.h" -#include "core/collections/QueryMaker.h" -#include "core/meta/Meta.h" -#include "core/meta/support/MetaUtility.h" -#include "core/support/Amarok.h" -#include "core-impl/collections/support/CollectionManager.h" -#include "covermanager/CoverCache.h" - -#include - -#include -#include -#include -#include -#include //Needed for the slot - -using namespace Context; - -CurrentEngine::CurrentEngine( QObject* parent, const QList& args ) - : DataEngine( parent ) - , m_coverWidth( 0 ) - , m_coverCacheKey( 0 ) - , m_lastQueryMaker( 0 ) -{ - Q_UNUSED( args ) - - m_sources << QLatin1String("current") << QLatin1String("albums"); - m_requested[ QLatin1String("current") ] = false; - m_requested[ QLatin1String("albums") ] = false; - EngineController* engine = The::engineController(); - - connect( engine, SIGNAL(trackPlaying(Meta::TrackPtr)), - this, SLOT(trackPlaying(Meta::TrackPtr)) ); - connect( engine, SIGNAL(stopped(qint64,qint64)), - this, SLOT(stopped()) ); - - connect( engine, SIGNAL(trackMetadataChanged(Meta::TrackPtr)), - this, SLOT(metadataChanged(Meta::TrackPtr)) ); - connect( engine, SIGNAL(albumMetadataChanged(Meta::AlbumPtr)), - this, SLOT(metadataChanged(Meta::AlbumPtr)) ); -} - -CurrentEngine::~CurrentEngine() -{ -} - -QStringList -CurrentEngine::sources() const -{ - return m_sources; // we don't have sources, if connected, it is enabled. -} - -bool -CurrentEngine::sourceRequestEvent( const QString& name ) -{ - Meta::TrackPtr track = The::engineController()->currentTrack(); - m_requested[ name ] = true; - if( !track ) - stopped(); - - if( name == QLatin1String("current") ) - update( track ); - else if( name == QLatin1String("albums") ) - track ? update(track->album()) : setData(name, Plasma::DataEngine::Data()); - else - return false; - - return true; -} - -void -CurrentEngine::metadataChanged( Meta::AlbumPtr album ) -{ - // disregard changes for other albums (BR: 306735) - if( !m_currentTrack || m_currentTrack->album() != album ) - return; - - QImage cover = album->image( m_coverWidth ); - qint64 coverCacheKey = cover.cacheKey(); - if( m_coverCacheKey != coverCacheKey ) - { - m_coverCacheKey = coverCacheKey; - setData( "current", "albumart", cover ); - } -} - -void -CurrentEngine::metadataChanged( Meta::TrackPtr track ) -{ - DEBUG_BLOCK - - QVariantMap trackInfo = Meta::Field::mapFromTrack( track ); - if( m_trackInfo != trackInfo ) - { - m_trackInfo = trackInfo; - setData( "current", "current", trackInfo ); - if( track && m_requested.value( QLatin1String("albums") ) ) - update( track->album() ); - } -} - -void -CurrentEngine::trackPlaying( Meta::TrackPtr track ) -{ - DEBUG_BLOCK - m_lastQueryMaker = 0; - if( m_requested.value( QLatin1String("current") ) ) - update( track ); - if( track && m_requested.value( QLatin1String("albums") ) ) - update( track->album() ); -} - -void -CurrentEngine::stopped() -{ - if( m_requested.value( QLatin1String("current") ) ) - { - removeAllData( "current" ); - setData( "current", "notrack", i18n( "No track playing") ); - m_currentTrack.clear(); - } - - if( m_requested.value( QLatin1String("albums") ) ) - { - removeAllData( "albums" ); - m_albumData.clear(); - - // Collect data for the recently added albums - setData( "albums", "headerText", QVariant( i18n( "Recently Added Albums" ) ) ); - m_albums.clear(); - - Collections::QueryMaker *qm = CollectionManager::instance()->queryMaker(); - qm->setAutoDelete( true ); - qm->setQueryType( Collections::QueryMaker::Album ); - qm->excludeFilter( Meta::valAlbum, QString(), true, true ); - qm->orderBy( Meta::valCreateDate, true ); - qm->limitMaxResultSize( Amarok::config("Albums Applet").readEntry("RecentlyAdded", 5) ); - - connect( qm, SIGNAL(newResultReady(Meta::AlbumList)), - SLOT(resultReady(Meta::AlbumList)), Qt::QueuedConnection ); - connect( qm, SIGNAL(queryDone()), SLOT(setupAlbumsData()) ); - - m_lastQueryMaker = qm; - qm->run(); - } -} - -void -CurrentEngine::update( Meta::TrackPtr track ) -{ - if( !m_requested.value( QLatin1String("current") ) || - track == m_currentTrack ) - return; - - m_currentTrack = track; - removeAllData( QLatin1String("current") ); - - if( !track ) - return; - - Plasma::DataEngine::Data data; - QVariantMap trackInfo = Meta::Field::mapFromTrack( track ); - data["current"] = trackInfo; - Meta::AlbumPtr album = track->album(); - data["albumart"] = QVariant( album ? The::coverCache()->getCover( album, m_coverWidth) : QPixmap() ); - - Capabilities::SourceInfoCapability *sic = track->create(); - if( sic ) - { - //is the source defined - const QString source = sic->sourceName(); - debug() <<" We have source " <scalableEmblem(); - - delete sic; - } - else - data["source_emblem"] = QVariant( QPixmap() ); - - debug() << "updating track" << track->name(); - setData( "current", data ); -} - -void -CurrentEngine::update( Meta::AlbumPtr album ) -{ - if( !m_requested.value( QLatin1String("albums") ) ) - return; - - m_lastQueryMaker = 0; - Meta::TrackPtr track = The::engineController()->currentTrack(); - - if( !album ) - return; - - Meta::ArtistPtr artist = track->artist(); - - // Prefer track artist to album artist BUG: 266682 - if( !artist ) - artist = album->albumArtist(); - - if( artist && !artist->name().isEmpty() ) - { - m_albums.clear(); - m_albumData.clear(); - m_albumData[ QLatin1String("currentTrack") ] = qVariantFromValue( track ); - m_albumData[ QLatin1String("headerText") ] = QVariant( i18n( "Albums by %1", artist->name() ) ); - - // -- search the collection for albums with the same artist - Collections::QueryMaker *qm = CollectionManager::instance()->queryMaker(); - qm->setAutoDelete( true ); - qm->addFilter( Meta::valArtist, artist->name(), true, true ); - qm->setAlbumQueryMode( Collections::QueryMaker::AllAlbums ); - qm->setQueryType( Collections::QueryMaker::Album ); - - connect( qm, SIGNAL(newResultReady(Meta::AlbumList)), - SLOT(resultReady(Meta::AlbumList)), Qt::QueuedConnection ); - connect( qm, SIGNAL(queryDone()), SLOT(setupAlbumsData()) ); - - m_lastQueryMaker = qm; - qm->run(); - } - else - { - removeAllData( QLatin1String("albums") ); - setData( QLatin1String("albums"), QLatin1String("headerText"), - i18nc( "Header text for current album applet", "Albums" ) ); - } -} - -void -CurrentEngine::setupAlbumsData() -{ - if( sender() == m_lastQueryMaker ) - { - m_albumData[ QLatin1String("albums") ] = QVariant::fromValue( m_albums ); - setData( QLatin1String("albums"), m_albumData ); - } -} - -void -CurrentEngine::resultReady( const Meta::AlbumList &albums ) -{ - if( sender() == m_lastQueryMaker ) - m_albums << albums; -} - -#include "moc_CurrentEngine.cpp" diff --git a/amarok/src/context/engines/current/CurrentEngine.h b/amarok/src/context/engines/current/CurrentEngine.h deleted file mode 100644 index 77845293..00000000 --- a/amarok/src/context/engines/current/CurrentEngine.h +++ /dev/null @@ -1,95 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Leo Franchi * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_CURRENT_ENGINE -#define AMAROK_CURRENT_ENGINE - -#include "context/DataEngine.h" -#include "core/meta/forward_declarations.h" - -namespace Collections { - class QueryMaker; -} - -/** - This class provides context information on the currently playing track. - This includes info such as the artist, trackname, album of the current song, etc. - - There is no data source: if you connect to the engine, you immediately - start getting updates when there is data. - - The key of the data is "current". - The data is structured as a QVariantList, with the order: - * Artist - * Track - * Album - * Rating (0-10) - * Score - * Track Length - * Last Played - * Number of times played - * Album cover (QImage) - -*/ -class CurrentEngine : public Context::DataEngine -{ - Q_OBJECT - Q_PROPERTY( int coverWidth READ coverWidth WRITE setCoverWidth ) - -public: - CurrentEngine( QObject* parent, const QList& args ); - virtual ~CurrentEngine(); - - QStringList sources() const; - - int coverWidth() { return m_coverWidth; } - void setCoverWidth( const int width ) { m_coverWidth = width; } - -private slots: - void metadataChanged( Meta::AlbumPtr album ); - void metadataChanged( Meta::TrackPtr track ); - void trackPlaying( Meta::TrackPtr track ); - void stopped(); - -protected: - bool sourceRequestEvent( const QString& name ); - -private: - void update( Meta::TrackPtr track ); - void update( Meta::AlbumPtr album ); - - int m_coverWidth; - QStringList m_sources; - QHash< QString, bool > m_requested; - Meta::AlbumList m_albums; - Plasma::DataEngine::Data m_albumData; - Meta::TrackPtr m_currentTrack; - qint64 m_coverCacheKey; - QVariantMap m_trackInfo; - - /** The address of the query maker used for the albums query. - This is only used to check if the query results are from the latest started query maker. - */ - Collections::QueryMaker *m_lastQueryMaker; - -private slots: - void resultReady( const Meta::AlbumList &albums ); - void setupAlbumsData(); -}; - -AMAROK_EXPORT_DATAENGINE( current, CurrentEngine ) - -#endif diff --git a/amarok/src/context/engines/current/amarok-data-engine-current.desktop b/amarok/src/context/engines/current/amarok-data-engine-current.desktop deleted file mode 100644 index dcefd68f..00000000 --- a/amarok/src/context/engines/current/amarok-data-engine-current.desktop +++ /dev/null @@ -1,62 +0,0 @@ -[Desktop Entry] -Name=Current Info Data Engine -Name[bg]=Ядро за дата и време -Name[bs]=Pogon tekućih podataka -Name[ca]=Motor de dades d'informació actual -Name[ca@valencia]=Motor de dades d'informació actual -Name[cs]=Datový nástroj Aktuální informace -Name[csb]=Mòtór aktualny wëdowiedzë ò pòdôwkach -Name[da]=Datamotor til Aktuel info -Name[de]=Datenmodul für Informationen über das aktuelle Stück -Name[el]=Μηχανή δεδομένων τρεχουσών πληροφοριών -Name[en_GB]=Current Info Data Engine -Name[eo]=Datuma motoro de la aktuala informo -Name[es]=Información del motor de datos actual -Name[et]=Aktiivse info andmemootor -Name[eu]=Uneko informazioaren datuen motorra -Name[fi]=Nykyisen infon tietomoottori -Name[fr]=Moteur de données pour les informations courantes -Name[ga]=Inneall Sonraí - Eolas Reatha -Name[gl]=Motor actual de dados de información -Name[hne]=अभी हाल के डाटा इंजिन जानकारी -Name[hu]=Aktuális információk adatmotorja -Name[id]=Mesin Info Data Saat Ini -Name[is]=Núverandi gagnavél fyrir spilun -Name[it]=Motore dati informazione attuale -Name[ja]=現在の情報データエンジン -Name[km]=ម៉ាស៊ីន​ទិន្នន័យ​ព័ត៌មាន​បច្ចុប្បន្ន -Name[ko]=현재 정보 데이터 엔진 -Name[ku]=Motora Dane ya Agahiyên Hene -Name[lt]=Dabartinės informacijos duomenų sistema -Name[lv]=Pašreizējās informācijas datu dzinējs -Name[nb]=Gjeldende Informasjonsdatamotor -Name[nds]=Datenkarn för aktuell Daten -Name[nl]=Informatie-gegevensengine -Name[nn]=Datamotor for gjeldande spor -Name[pa]=ਮੌਜੂਦਾ ਜਾਣਕਾਰੀ ਡਾਟਾ ਇੰਜਣ -Name[pl]=Moduł danych bieżących informacji -Name[pt]=Motor de Dados da Informação Actual -Name[pt_BR]=Mecanismo de dados das informações atuais -Name[ro]=Motor de date Informație curentă -Name[ru]=Источник данных для текущих сведений -Name[sk]=Dátový nástroj Aktuálne informácie -Name[sl]=Podatkovni pogon za podatke trenutni skladbi -Name[sr]=Датомотор текућих података -Name[sr@ijekavian]=Датомотор текућих података -Name[sr@ijekavianlatin]=Datomotor tekućih podataka -Name[sr@latin]=Datomotor tekućih podataka -Name[sv]=Datagränssnitt för aktuell information -Name[th]=กลไกข้อมูลของข้อมูลรายละเอียดปัจจุบัน -Name[tr]=Kullanılan Bilgi Veri Motoru -Name[uk]=Поточний рушій інформаційних даних -Name[wa]=Éndjin d' dinêyes des informåcions do moumint -Name[x-test]=xxCurrent Info Data Enginexx -Name[zh_CN]=当前信息数据引擎 -Name[zh_TW]=目前訊息的資料引擎 -X-KDE-ServiceTypes=Plasma/DataEngine -Type=Service -Icon=amarok -X-KDE-Library=amarok_data_engine_current -X-KDE-PluginInfo-Name=amarok-current -X-KDE-ParentApp=Amarok - diff --git a/amarok/src/context/engines/info/CMakeLists.txt b/amarok/src/context/engines/info/CMakeLists.txt deleted file mode 100644 index 5c276fac..00000000 --- a/amarok/src/context/engines/info/CMakeLists.txt +++ /dev/null @@ -1,21 +0,0 @@ -include_directories( ../../.. - ../../../context - ${CMAKE_CURRENT_BINARY_DIR}/../../.. # for amarok_config.h -) - -set( info_engine_SRCS - InfoEngine.cpp -) - -kde4_add_plugin(amarok_data_engine_info ${info_engine_SRCS}) -target_link_libraries( amarok_data_engine_info amarokcore amaroklib ${KDE4_PLASMA_LIBS} ${KDE4_KDECORE_LIBS} ${QT_QTGUI_LIBRARY}) - -install( TARGETS amarok_data_engine_info DESTINATION ${PLUGIN_INSTALL_DIR} ) -install( FILES amarok-data-engine-info.desktop DESTINATION ${SERVICES_INSTALL_DIR} ) -install( FILES info_frontpage.html DESTINATION ${DATA_INSTALL_DIR}/amarok/data ) -install( FILES - info_frontpage_bg.png - info_frontpage_logo.png - info_frontpage_shadow.png - DESTINATION ${DATA_INSTALL_DIR}/amarok/images - ) diff --git a/amarok/src/context/engines/info/InfoEngine.cpp b/amarok/src/context/engines/info/InfoEngine.cpp deleted file mode 100644 index 1ec32299..00000000 --- a/amarok/src/context/engines/info/InfoEngine.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * Copyright (c) 2007 Leo Franchi * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "InfoEngine.h" - -#include "core/support/Amarok.h" -#include "core/support/Debug.h" -#include "ContextObserver.h" -#include "ContextView.h" -#include "browsers/InfoProxy.h" - -#include - -using namespace Context; - -InfoEngine::InfoEngine( QObject* parent, const QList& args ) - : DataEngine( parent ) - , m_requested( true ) -{ - Q_UNUSED( args ) - DEBUG_BLOCK - m_sources = QStringList(); - m_sources << "service"; - - The::infoProxy()->subscribe( this ); -} - -InfoEngine::~ InfoEngine() -{ - The::infoProxy()->unsubscribe( this ); -} - -QStringList InfoEngine::sources() const -{ - return m_sources; // we don't have sources, if connected, it is enabled. -} - -bool InfoEngine::sourceRequestEvent( const QString& name ) -{ - Q_UNUSED( name ); -/* m_sources << name; // we are already enabled if we are alive*/ - setData( name, QVariant()); - update(); - m_requested = true; - return true; -} - -void InfoEngine::message( const ContextState& state ) -{ - if( state == Current && m_requested ) { - m_storedInfo = The::infoProxy()->info(); - update(); - } -} - - -void InfoEngine::infoChanged( QVariantMap infoMap ) -{ - m_storedInfo = infoMap; - update(); -} - -void InfoEngine::update() -{ - setData( "info", "subject_name", m_storedInfo["service_name"] ); - setData( "info", "main_info", m_storedInfo["main_info"] ); - -} - - - -#include "moc_InfoEngine.cpp" - - diff --git a/amarok/src/context/engines/info/InfoEngine.h b/amarok/src/context/engines/info/InfoEngine.h deleted file mode 100644 index 4c991897..00000000 --- a/amarok/src/context/engines/info/InfoEngine.h +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * Copyright (c) 2007 Leo Franchi * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_INFO_ENGINE -#define AMAROK_INFO_ENGINE - -#include "ContextObserver.h" -#include "browsers/InfoObserver.h" -#include "context/DataEngine.h" - -/** - This class provides context information realted to the currently active service - - There is no data source: if you connect to the engine, you immediately - start getting updates when there is data. - - The key of the data is "service". - The data is a QMap with the keys - * service_name - the name of the currently running service - - -*/ - -class InfoEngine : public Context::DataEngine, - public InfoObserver, - public ContextObserver -{ - Q_OBJECT - - -public: - - InfoEngine( QObject* parent, const QList& args ); - ~InfoEngine(); - - QStringList sources() const; - void message( const Context::ContextState& state ); - - void infoChanged( QVariantMap infoMap ); - -protected: - bool sourceRequestEvent( const QString& name ); - -private: - void update(); - - QStringList m_sources; - bool m_requested; - QVariantMap m_storedInfo; - -}; - -AMAROK_EXPORT_DATAENGINE( info, InfoEngine ) - -#endif diff --git a/amarok/src/context/engines/info/amarok-data-engine-info.desktop b/amarok/src/context/engines/info/amarok-data-engine-info.desktop deleted file mode 100644 index 641e0a1e..00000000 --- a/amarok/src/context/engines/info/amarok-data-engine-info.desktop +++ /dev/null @@ -1,59 +0,0 @@ -[Desktop Entry] -Name=Info Data Engine -Name[bg]=Ядро за данни -Name[bs]=Pogon podataka -Name[ca]=Motor de dades d'informació -Name[ca@valencia]=Motor de dades d'informació -Name[cs]=Datový nástroj informací -Name[csb]=Mòtór wëdowiedzë ò pòdôwkach -Name[da]=Datamotor til info -Name[de]=Datenmodul für Informationen -Name[el]=Μηχανή δεδομένων πληροφοριών -Name[en_GB]=Info Data Engine -Name[es]=Información del motor de datos -Name[et]=Teabe andmemootor -Name[eu]=informazioaren datuen motorra -Name[fi]=Infon tietomoottori -Name[fr]=Moteur de données pour les informations -Name[ga]=Inneall Sonraí Eolais -Name[gl]=Motor de datos de información -Name[hu]=Információs adatmotor -Name[id]=Mesin Info Data -Name[is]=Gagnavél fyrir spilun -Name[it]=Motore dati informazione -Name[ja]=情報データエンジン -Name[km]=ម៉ាស៊ីន​ទិន្នន័យ​ព័ត៌មាន​ -Name[ko]=정보 데이터 엔진 -Name[lt]=Informacijos duomenų sistema -Name[lv]=Informācijas datu dzinējs -Name[nb]=Informasjonsdatamotor -Name[nds]=Info-Datenkarn -Name[nl]=Informatie-gegevensengine -Name[nn]=Datamotor for informasjon -Name[pa]=ਜਾਣਕਾਰੀ ਡਾਟਾ ਇੰਜਣ -Name[pl]=Moduł danych informacji -Name[pt]=Motor de Dados da Informação -Name[pt_BR]=Mecanismo de dados das informações -Name[ro]=Motor de date Informații -Name[ru]=Источник данных для сведений -Name[sk]=Dátový nástroj Informácie -Name[sl]=Podatkovni pogon za podatke -Name[sr]=Датомотор података -Name[sr@ijekavian]=Датомотор података -Name[sr@ijekavianlatin]=Datomotor podataka -Name[sr@latin]=Datomotor podataka -Name[sv]=Datagränssnitt för information -Name[th]=กลไกข้อมูลของข้อมูล -Name[tr]=Bilgi Veri Motoru -Name[uk]=Рушій інформаційних даних -Name[x-test]=xxInfo Data Enginexx -Name[zh_CN]=信息数据引擎 -Name[zh_TW]=資訊資料引擎 - -X-KDE-ServiceTypes=Plasma/DataEngine -Type=Service -Icon=amarok -X-KDE-Library=amarok_data_engine_info -X-KDE-PluginInfo-Name=amarok-info -X-KDE-ParentApp=Amarok - diff --git a/amarok/src/context/engines/info/info_frontpage.html b/amarok/src/context/engines/info/info_frontpage.html deleted file mode 100644 index 7046dafb..00000000 --- a/amarok/src/context/engines/info/info_frontpage.html +++ /dev/null @@ -1,84 +0,0 @@ - - - - - -

-
- -
-
- This is the Amarok 2 info applet. This will display info from and about the browsers as you browse through them and their content.

- Try out some of these services to get you started:
- Magnatune.com
- Jamendo.com

- Or listen to audio books from LibriVox.org by some of these great authors:
- Charles Dickens
- H. G. Wells
- Jules Verne

- You can also browse and subscribe to a huge list of podcasts and radio stations. -

-
- - diff --git a/amarok/src/context/engines/info/info_frontpage_bg.png b/amarok/src/context/engines/info/info_frontpage_bg.png deleted file mode 100644 index d7723db2..00000000 Binary files a/amarok/src/context/engines/info/info_frontpage_bg.png and /dev/null differ diff --git a/amarok/src/context/engines/info/info_frontpage_logo.png b/amarok/src/context/engines/info/info_frontpage_logo.png deleted file mode 100644 index 9299f70e..00000000 Binary files a/amarok/src/context/engines/info/info_frontpage_logo.png and /dev/null differ diff --git a/amarok/src/context/engines/info/info_frontpage_shadow.png b/amarok/src/context/engines/info/info_frontpage_shadow.png deleted file mode 100644 index 9a81630b..00000000 Binary files a/amarok/src/context/engines/info/info_frontpage_shadow.png and /dev/null differ diff --git a/amarok/src/context/engines/labels/CMakeLists.txt b/amarok/src/context/engines/labels/CMakeLists.txt deleted file mode 100644 index 75112cb6..00000000 --- a/amarok/src/context/engines/labels/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -include_directories( ../.. - ../../.. - ${CMAKE_CURRENT_BINARY_DIR} # for amarok_config.h -) - -set( labels_engine_SRCS - LabelsEngine.cpp -) - -kde4_add_plugin(amarok_data_engine_labels ${labels_engine_SRCS}) -target_link_libraries( amarok_data_engine_labels amarokcore amaroklib ${KDE4_PLASMA_LIBS} ${KDE4_KIO_LIBS}) - -install( TARGETS amarok_data_engine_labels DESTINATION ${PLUGIN_INSTALL_DIR} ) -install( FILES amarok-data-engine-labels.desktop DESTINATION ${SERVICES_INSTALL_DIR} ) diff --git a/amarok/src/context/engines/labels/LabelsEngine.cpp b/amarok/src/context/engines/labels/LabelsEngine.cpp deleted file mode 100644 index 2333cbdb..00000000 --- a/amarok/src/context/engines/labels/LabelsEngine.cpp +++ /dev/null @@ -1,374 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Simon Esneault * - * Copyright (c) 2010 Daniel Faust * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "LabelsEngine" - -#include "LabelsEngine.h" - -#include "EngineController.h" -#include "context/ContextObserver.h" -#include "context/ContextView.h" -#include "core/collections/Collection.h" -#include "core/collections/QueryMaker.h" -#include "core/meta/Meta.h" -#include "core/support/Debug.h" -#include "core-impl/collections/support/CollectionManager.h" - -#include -#include - -#include - -using namespace Context; - -LabelsEngine::LabelsEngine( QObject *parent, const QList &args ) - : DataEngine( parent ) - , ContextObserver( ContextView::self() ) -{ - Q_UNUSED( args ) - m_sources << "lastfm" ; - - m_timeoutTimer.setInterval( 10000 ); - m_timeoutTimer.setSingleShot( true ); - connect( &m_timeoutTimer, SIGNAL(timeout()), this, SLOT(timeout()) ); - - EngineController *engine = The::engineController(); - - connect( engine, SIGNAL(trackChanged(Meta::TrackPtr)), - this, SLOT(update()) ); - connect( engine, SIGNAL(trackMetadataChanged(Meta::TrackPtr)), - this, SLOT(update()) ); -} - -LabelsEngine::~LabelsEngine() -{ - DEBUG_BLOCK -} - -QStringList -LabelsEngine::sources() const -{ - return m_sources; -} - -bool -LabelsEngine::sourceRequestEvent( const QString &name ) -{ - DEBUG_BLOCK - - Collections::Collection *coll = CollectionManager::instance()->primaryCollection(); - if( coll ) - { - Collections::QueryMaker *qm = coll->queryMaker(); - qm->setAutoDelete( true ); - qm->setQueryType( Collections::QueryMaker::Label ); - m_allLabels.clear(); - - connect( qm, SIGNAL(newResultReady(Meta::LabelList)), - SLOT(resultReady(Meta::LabelList)), Qt::QueuedConnection ); - connect( qm, SIGNAL(queryDone()), SLOT(dataQueryDone()) ); - - qm->run(); - } - - update( name == "reload" ); - - return true; -} - -void -LabelsEngine::resultReady( const Meta::LabelList &labels ) -{ - foreach( const Meta::LabelPtr &label, labels ) - { - if( !label->name().isEmpty() ) - m_allLabels << label->name(); - } -} - -void -LabelsEngine::dataQueryDone() -{ - DEBUG_BLOCK - QVariant varAll; - varAll.setValue< QStringList >( m_allLabels ); - setData( "labels", "all", varAll ); -} - -void -LabelsEngine::update( bool reload ) -{ - Meta::TrackPtr track = The::engineController()->currentTrack(); - - if( !track ) - { - removeAllData( "labels" ); - m_artist.clear(); - m_title.clear(); - m_album.clear(); - m_userLabels.clear(); - m_webLabels.clear(); - setData( "labels", "state", "stopped" ); - return; - } - - const QString title = track->name(); - Meta::ArtistPtr artist = track->artist(); - if( !artist ) - { - setData( "labels", "message", i18n( "No labels found on Last.fm" ) ); - debug() << "track has no artist, returning"; - return; - } - - QStringList userLabels; - - foreach( const Meta::LabelPtr &label, track->labels() ) - userLabels += label->name(); - - userLabels.sort(); - m_userLabels.sort(); - - // check what changed - if( !reload && artist->name() == m_artist && title == m_title && userLabels == m_userLabels ) - { - // nothing important changed - return; - } - else if( !reload && artist->name() == m_artist && title == m_title ) - { - // only the labels changed - no download necessary - debug() << "only the labels changed - no download necessary"; - QVariant varUser; - varUser.setValue< QStringList >( userLabels ); - setData( "labels", "user", varUser ); - m_userLabels = userLabels; - return; - } - - removeAllData( "labels" ); - setData( "labels", "state", "started" ); - - m_artist = artist->name(); - m_title = title; - if( track->album() ) - m_album = track->album()->name(); - else - m_album.clear(); - - m_userLabels = userLabels; - m_webLabels.clear(); - - QVariant varUser; - varUser.setValue< QStringList >( m_userLabels ); - setData( "labels", "user", varUser ); - - m_try = 0; - fetchLastFm(); -} - -void -LabelsEngine::fetchLastFm() -{ - QStringList separators; - QString currentArtist; - QString currentTitle; - - if( m_title.isEmpty() || m_artist.isEmpty() ) - { - // stop timeout timer - m_timeoutTimer.stop(); - setData( "labels", "message", i18n( "No labels found on Last.fm" ) ); - debug() << "current track is invalid, returning"; - return; - } - - if( m_try == 0 ) - { - currentArtist = m_artist; - currentTitle = m_title; - m_timeoutTimer.start(); - } - else if( m_try == 1 ) - { - currentArtist = m_artist; - currentTitle = m_title; - separators.clear(); - separators << " (" << " [" << " - " << " featuring " << " feat. " << " feat " << " ft. " << " ft " << "/"; - foreach( const QString &separator, separators ) - { - if( m_title.contains(separator,Qt::CaseInsensitive) ) - { - currentTitle = m_title.left( m_title.indexOf(separator,0,Qt::CaseInsensitive) ); - break; - } - } - if ( currentTitle == m_title ) - { - debug() << "try 2: title is the same, retrying"; - m_try++; - fetchLastFm(); - return; - } - } - else if( m_try == 2 ) - { - currentArtist = m_artist; - currentTitle = m_title; - separators.clear(); - separators << " vs. " << " vs " << " featuring " << " feat. " << " feat " << " ft. " << " ft " << ", " << " and " << " & " << "/"; - foreach( const QString &separator, separators ) - { - if( m_artist.contains(separator,Qt::CaseInsensitive) ) - { - currentArtist = m_artist.left( m_artist.indexOf(separator,0,Qt::CaseInsensitive) ); - break; - } - } - separators.clear(); - separators << " (" << " [" << " - " << " featuring " << " feat. " << " feat " << " ft. " << " ft " << "/"; - foreach( const QString &separator, separators ) - { - if( m_title.contains(separator,Qt::CaseInsensitive) ) - { - currentTitle = m_title.left( m_title.indexOf(separator,0,Qt::CaseInsensitive) ); - break; - } - } - if( currentArtist == m_artist ) // the title got modified the same way as on the last try - { - // stop timeout timer - m_timeoutTimer.stop(); - setData( "labels", "message", i18n( "No labels found on Last.fm" ) ); - debug() << "try 3: artist and title are the same, returning"; - return; - } - } - else - { - // shouldn't happen - // stop timeout timer - m_timeoutTimer.stop(); - setData( "labels", "message", i18n( "No labels found on Last.fm" ) ); - debug() << "try > 2, returning"; - return; - } - - if( !currentArtist.isEmpty() && !currentTitle.isEmpty() ) - { - setData( "labels", "message", "fetching"); - // send the atist and title actually used for searching labels - setData( "labels", "artist", currentArtist ); - setData( "labels", "title", currentTitle ); - setData( "labels", "album", m_album ); - - // Query lastfm - KUrl lastFmUrl; - lastFmUrl.setScheme( "http" ); - lastFmUrl.setHost( "ws.audioscrobbler.com" ); - lastFmUrl.setPath( "/2.0/" ); - lastFmUrl.addQueryItem( "method", "track.gettoptags" ); - lastFmUrl.addQueryItem( "api_key", "402d3ca8e9bc9d3cf9b85e1202944ca5" ); - lastFmUrl.addQueryItem( "artist", currentArtist.toLocal8Bit() ); - lastFmUrl.addQueryItem( "track", currentTitle.toLocal8Bit() ); - m_lastFmUrl = lastFmUrl; - - QNetworkRequest req( lastFmUrl ); -// req.setAttribute( QNetworkRequest::ConnectionEncryptedAttribute, QNetworkRequest::AlwaysNetwork ); - The::networkAccessManager()->get( req ); - The::networkAccessManager()->getData( lastFmUrl, this, - SLOT(resultLastFm(KUrl,QByteArray,NetworkAccessManagerProxy::Error)) ); - } - else - { - // stop timeout timer - m_timeoutTimer.stop(); - setData( "labels", "message", i18n( "No labels found on Last.fm" ) ); - debug() << "artist or track empty"; - } -} - -void LabelsEngine::resultLastFm( const KUrl &url, QByteArray data, NetworkAccessManagerProxy::Error e ) -{ - DEBUG_BLOCK; - - if( m_lastFmUrl != url ) - { - debug() << "urls not matching, returning"; - return; - } - - if( e.code != QNetworkReply::NoError ) - { - // stop timeout timer - m_timeoutTimer.stop(); - setData( "labels", "message", i18n( "Unable to retrieve from Last.fm" ) ); - debug() << "Unable to retrieve last.fm information: " << e.description; - return; - } - - QDomDocument xmlDoc; - xmlDoc.setContent( data ); - const QDomElement topElement = xmlDoc.elementsByTagName("toptags").at(0).toElement(); - const QDomNodeList xmlNodeList = topElement.elementsByTagName( "tag" ); - - for( uint i = 0; i < xmlNodeList.length(); i++ ) - { - // Get all the information - const QDomElement nd = xmlNodeList.at( i ).toElement(); - const QDomElement nameElement = nd.elementsByTagName("name").at(0).toElement(); - const QString name = nameElement.text().toLower(); - const QDomElement countElement = nd.elementsByTagName("count").at(0).toElement(); - const int count = countElement.text().toInt(); - m_webLabels.insert( name, count ); - } - - if( m_webLabels.isEmpty() ) - { - if( m_try < 2 ) - { - m_try++; - fetchLastFm(); - } - else - { - // stop timeout timer - m_timeoutTimer.stop(); - setData( "labels", "message", i18n( "No labels found on Last.fm" ) ); - } - } - else - { - // remove previous message - removeData( "labels", "message" ); - // stop timeout timer - m_timeoutTimer.stop(); - - QVariant varWeb; - varWeb.setValue< QMap< QString, QVariant > > ( m_webLabels ); - setData( "labels", "web", varWeb ); - } -} - -void LabelsEngine::timeout() -{ - setData( "labels", "message", i18n( "No connection to Last.fm" ) ); -} - - -#include "moc_LabelsEngine.cpp" - diff --git a/amarok/src/context/engines/labels/LabelsEngine.h b/amarok/src/context/engines/labels/LabelsEngine.h deleted file mode 100644 index be14e892..00000000 --- a/amarok/src/context/engines/labels/LabelsEngine.h +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Simon Esneault * - * Copyright (c) 2010 Daniel Faust * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_LABELS_ENGINE -#define AMAROK_LABELS_ENGINE - -#include "ContextObserver.h" -#include "context/DataEngine.h" -#include "core/meta/forward_declarations.h" -#include "network/NetworkAccessManagerProxy.h" - -#include -#include -#include - -using namespace Context; - - /** - * This class provide labels from last.fm - * - */ -class LabelsEngine : public DataEngine, public ContextObserver -{ - Q_OBJECT -public: - LabelsEngine( QObject *parent, const QList &args ); - virtual ~LabelsEngine(); - - QStringList sources() const; - -protected: - // reimplemented from Plasma::DataEngine - bool sourceRequestEvent( const QString &name ); - -private slots: - - void update( bool reload = false ); - - /** - * This slots will handle last.fm result for this query: - * API key is : 402d3ca8e9bc9d3cf9b85e1202944ca5 - * http://ws.audioscrobbler.com/2.0/?method=track.gettoptags&artist=radiohead&track=paranoid+android&api_key=b25b959554ed76058ac220b7b2e0a026 - * see here for details: http://www.lastfm.com/api/ - */ - void resultLastFm( const KUrl &url, QByteArray data, NetworkAccessManagerProxy::Error e ); - - void resultReady( const Meta::LabelList &labels ); - void dataQueryDone(); - - void timeout(); - -private: - /** - * Engine was updated, so we check if the songs is different, and if it is, we delete every and start - * all the query/ fetching stuff - */ - void fetchLastFm(); - void updateLocal(); - - QTimer m_timeoutTimer; - - /// The URL for the network request - KUrl m_lastFmUrl; - - QStringList m_sources; - - // Cache the artist and title of the current track so we can check against metadata - // updates. We only want to update the labels if the artist change - QString m_artist; - QString m_title; - // Send the album name to the applet, used to filter labels that match the album - QString m_album; - - int m_try; - - QStringList m_allLabels; // all labels known to amarok - QStringList m_userLabels; // user labels - QMap < QString, QVariant > m_webLabels; // downloaded labels - -}; - -AMAROK_EXPORT_DATAENGINE( labels, LabelsEngine ) -#endif - diff --git a/amarok/src/context/engines/labels/amarok-data-engine-labels.desktop b/amarok/src/context/engines/labels/amarok-data-engine-labels.desktop deleted file mode 100644 index ad377dfe..00000000 --- a/amarok/src/context/engines/labels/amarok-data-engine-labels.desktop +++ /dev/null @@ -1,53 +0,0 @@ -[Desktop Entry] -Name=Labels Data Engine -Name[bg]=Ядро за етикети -Name[bs]=Pogon podataka oznaka -Name[ca]=Motor de dades d'etiquetes -Name[ca@valencia]=Motor de dades d'etiquetes -Name[cs]=Datový nástroj štítků -Name[da]=Datamotor til etiketter -Name[de]=Datenmodul für Stichwörter -Name[el]=Μηχανή δεδομένων ετικετών -Name[en_GB]=Labels Data Engine -Name[es]=Motor de datos de etiquetas -Name[et]=Märgendite andmemootor -Name[eu]=Etiketen datuen motorra -Name[fi]=Nimikkeiden tietomoottori -Name[fr]=Moteur de données pour les étiquettes -Name[ga]=Inneall Sonraí Lipéad -Name[gl]=Motor de datos de etiquetas -Name[hu]=Címkék adatmodul -Name[id]=Mesin Data Label -Name[it]=Motore dati delle etichette -Name[ja]=Labels データエンジン -Name[km]=ម៉ាស៊ីន​ទិន្នន័យ​ស្លាក -Name[ko]=레이블 데이터 엔진 -Name[lt]=Etikečių duomenų sistema -Name[lv]=Uzrakstu datu dzinējs -Name[nb]=Datamotor for etiketter -Name[nds]=Slötelwöör-Datenkarn -Name[nl]=Labels-gegevensengine -Name[pa]=ਲੇਬਲ ਡਾਟਾ ਇੰਜਣ -Name[pl]=Silnik danych etykiet -Name[pt]=Motor de Dados de Legendas -Name[pt_BR]=Mecanismo de dados de rótulos -Name[ro]=Motor de date Etichete -Name[ru]=Источник данных для меток -Name[sk]=Dátový engine popisov -Name[sl]=Podatkovni pogon za oznake -Name[sr]=Датомотор етикета -Name[sr@ijekavian]=Датомотор етикета -Name[sr@ijekavianlatin]=Datomotor etiketa -Name[sr@latin]=Datomotor etiketa -Name[sv]=Datagränssnitt för etiketter -Name[tr]=Etiket Veri Motoru -Name[uk]=Рушій даних міток -Name[x-test]=xxLabels Data Enginexx -Name[zh_CN]=标签数据引擎 -Name[zh_TW]=標籤資料引擎 -X-KDE-ServiceTypes=Plasma/DataEngine -X-KDE-ParentApp=Amarok -Type=Service -Icon=document-properties -X-KDE-Library=amarok_data_engine_labels -X-KDE-PluginInfo-Name=amarok-labels diff --git a/amarok/src/context/engines/lyrics/CMakeLists.txt b/amarok/src/context/engines/lyrics/CMakeLists.txt deleted file mode 100644 index 9a3b1fc8..00000000 --- a/amarok/src/context/engines/lyrics/CMakeLists.txt +++ /dev/null @@ -1,15 +0,0 @@ -include_directories( ../../.. - ../../../context - ../../../dialogs - ${CMAKE_CURRENT_BINARY_DIR}/../../.. # for amarok_config.h -) - -set( lyrics_engine_SRCS - LyricsEngine.cpp -) - -kde4_add_plugin(amarok_data_engine_lyrics ${lyrics_engine_SRCS}) -target_link_libraries( amarok_data_engine_lyrics amarokcore amaroklib ${KDE4_PLASMA_LIBS} ${KDE4_KDECORE_LIBS} ${QT_QTGUI_LIBRARY}) - -install( TARGETS amarok_data_engine_lyrics DESTINATION ${PLUGIN_INSTALL_DIR} ) -install( FILES amarok-data-engine-lyrics.desktop DESTINATION ${SERVICES_INSTALL_DIR} ) diff --git a/amarok/src/context/engines/lyrics/LyricsEngine.cpp b/amarok/src/context/engines/lyrics/LyricsEngine.cpp deleted file mode 100644 index 665b16bf..00000000 --- a/amarok/src/context/engines/lyrics/LyricsEngine.cpp +++ /dev/null @@ -1,195 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007-2008 Leo Franchi * - * Copyright (c) 2008 Mark Kretschmann * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "LyricsEngine" - -#include "LyricsEngine.h" - -#include "EngineController.h" -#include "scripting/scriptmanager/ScriptManager.h" -#include "context/ContextView.h" -#include "core/meta/Meta.h" -#include "core/support/Amarok.h" -#include "core/support/Debug.h" - -#include -#include - -using namespace Context; - -LyricsEngine::LyricsEngine( QObject* parent, const QList& /*args*/ ) - : DataEngine( parent ) - , LyricsObserver( LyricsManager::self() ) - , m_isUpdateInProgress( false ) -{ - - EngineController* engine = The::engineController(); - connect( engine, SIGNAL(trackChanged(Meta::TrackPtr)), - this, SLOT(update()), Qt::QueuedConnection ); - connect( engine, SIGNAL(trackMetadataChanged(Meta::TrackPtr)), - this, SLOT(onTrackMetadataChanged(Meta::TrackPtr)), Qt::QueuedConnection ); -} - -QStringList LyricsEngine::sources() const -{ - QStringList sourcesList; - sourcesList << "lyrics" << "suggested"; - - return sourcesList; -} - -bool LyricsEngine::sourceRequestEvent( const QString& name ) -{ - removeAllData( name ); - setData( name, QVariant()); - // in the case where we are resuming playback on startup. Need to be sure - // the script manager is running and a lyrics script is loaded first. - QTimer::singleShot( 0, this, SLOT(update()) ); - return true; -} - -void LyricsEngine::onTrackMetadataChanged( Meta::TrackPtr track ) -{ - DEBUG_BLOCK - - // Only update if the lyrics have changed. - QString artist = track->artist() ? track->artist()->name() : QString(); - if( m_prevLyrics.artist != artist || - m_prevLyrics.title != track->name() || - m_prevLyrics.text != track->cachedLyrics() ) - update(); -} - -void LyricsEngine::update() -{ - if( m_isUpdateInProgress ) - return; - - m_isUpdateInProgress = true; - - // -- get current title and artist - Meta::TrackPtr currentTrack = The::engineController()->currentTrack(); - if( !currentTrack ) - { - debug() << "no current track"; - m_prevLyrics.clear(); - removeAllData( "lyrics" ); - setData( "lyrics", "stopped", "stopped" ); - m_isUpdateInProgress = false; - return; - } - - QString title = currentTrack->name(); - QString artist = currentTrack->artist() ? currentTrack->artist()->name() : QString(); - - // -- clean up title - const QString magnatunePreviewString = QLatin1String( "PREVIEW: buy it at www.magnatune.com" ); - if( title.contains(magnatunePreviewString, Qt::CaseSensitive) ) - title = title.remove( " (" + magnatunePreviewString + ')' ); - if( artist.contains(magnatunePreviewString, Qt::CaseSensitive) ) - artist = artist.remove( " (" + magnatunePreviewString + ')' ); - - if( title.isEmpty() && currentTrack ) - { - /* If title is empty, try to use pretty title. - The fact that it often (but not always) has "artist name" together, can be bad, - but at least the user will hopefully get nice suggestions. */ - QString prettyTitle = currentTrack->prettyName(); - int h = prettyTitle.indexOf( QLatin1Char('-') ); - if ( h != -1 ) - { - title = prettyTitle.mid( h + 1 ).trimmed(); - if( title.contains(magnatunePreviewString, Qt::CaseSensitive) ) - title = title.remove( " (" + magnatunePreviewString + ')' ); - - if( artist.isEmpty() ) - { - artist = prettyTitle.mid( 0, h ).trimmed(); - if( artist.contains(magnatunePreviewString, Qt::CaseSensitive) ) - artist = artist.remove( " (" + magnatunePreviewString + ')' ); - } - } - } - - LyricsData lyrics = { currentTrack->cachedLyrics(), title, artist, KUrl() }; - - // Check if the title, the artist and the lyrics are still the same. - if( !lyrics.text.isEmpty() && (lyrics.text == m_prevLyrics.text) ) - { - debug() << "nothing changed:" << lyrics.title; - newLyrics( lyrics ); - m_isUpdateInProgress = false; - return; - } - - // don't rely on caching for streams - const bool cached = !LyricsManager::self()->isEmpty( lyrics.text ) - && !The::engineController()->isStream(); - - if( cached ) - { - newLyrics( lyrics ); - } - else - { - // no lyrics, and no lyrics script! - if( !ScriptManager::instance()->lyricsScriptRunning() ) - { - debug() << "no lyrics script running"; - removeAllData( "lyrics" ); - setData( "lyrics", "noscriptrunning", "noscriptrunning" ); - disconnect( ScriptManager::instance(), SIGNAL(lyricsScriptStarted()), this, 0 ); - connect( ScriptManager::instance(), SIGNAL(lyricsScriptStarted()), SLOT(update()) ); - m_isUpdateInProgress = false; - return; - } - - // fetch by lyrics script - removeAllData( "lyrics" ); - setData( "lyrics", "fetching", "fetching" ); - ScriptManager::instance()->notifyFetchLyrics( lyrics.artist, lyrics.title, "", currentTrack ); - } - m_isUpdateInProgress = false; -} - -void LyricsEngine::newLyrics( const LyricsData &lyrics ) -{ - QString key = Qt::mightBeRichText( lyrics.text ) ? QLatin1String( "html" ) - : QLatin1String( "lyrics" ); - removeAllData( "lyrics" ); - setData( "lyrics", key, QVariant::fromValue(lyrics) ); - m_prevLyrics = lyrics; -} - -void LyricsEngine::newSuggestions( const QVariantList &suggested ) -{ - DEBUG_BLOCK - // each string is in "title - artist " form - removeAllData( "lyrics" ); - setData( "lyrics", "suggested", suggested ); -} - -void LyricsEngine::lyricsMessage( const QString& key, const QString &val ) -{ - DEBUG_BLOCK - - removeAllData( "lyrics" ); - setData( "lyrics", key, val ); -} - -#include "moc_LyricsEngine.cpp" - diff --git a/amarok/src/context/engines/lyrics/LyricsEngine.h b/amarok/src/context/engines/lyrics/LyricsEngine.h deleted file mode 100644 index 97cf4137..00000000 --- a/amarok/src/context/engines/lyrics/LyricsEngine.h +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Leo Franchi * - * Copyright (c) 2008 Mark Kretschmann * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_LYRICS_ENGINE -#define AMAROK_LYRICS_ENGINE - -#include "context/DataEngine.h" -#include "context/LyricsManager.h" -#include "core/meta/forward_declarations.h" - -/** - This class provides Lyrics data for use in Context applets. - -NOTE: The QVariant data is structured like this: - * the key name is lyrics - * the data is a QVariantList with title, artist, lyricsurl, lyrics -*/ - -using namespace Context; - -class LyricsEngine : public DataEngine, public LyricsObserver -{ - Q_OBJECT - -public: - LyricsEngine( QObject* parent, const QList& args ); - - QStringList sources() const; - - // reimplemented from LyricsObserver - void newLyrics( const LyricsData &lyrics ); - void newSuggestions( const QVariantList &suggest ); - void lyricsMessage( const QString& key, const QString& val ); - -protected: - bool sourceRequestEvent( const QString& name ); - -private slots: - void update(); - void onTrackMetadataChanged( Meta::TrackPtr track ); - -private: - LyricsData m_prevLyrics; - bool m_isUpdateInProgress; - - struct trackMetadata { - QString artist; - QString title; - } m_prevTrackMetadata; -}; - -AMAROK_EXPORT_DATAENGINE( lyrics, LyricsEngine ) - -#endif diff --git a/amarok/src/context/engines/lyrics/amarok-data-engine-lyrics.desktop b/amarok/src/context/engines/lyrics/amarok-data-engine-lyrics.desktop deleted file mode 100644 index f155649f..00000000 --- a/amarok/src/context/engines/lyrics/amarok-data-engine-lyrics.desktop +++ /dev/null @@ -1,62 +0,0 @@ -[Desktop Entry] -Name=Lyrics Data Engine -Name[bg]=Ядро за текстове -Name[bs]=Pogon podatka stihova -Name[ca]=Motor de dades de lletres -Name[ca@valencia]=Motor de dades de lletres -Name[cs]=Datový nástroj textů písní -Name[csb]=Mòtór tekstów -Name[da]=Datamotor til sangtekst -Name[de]=Datenmodul für Liedtexte -Name[el]=Μηχανή δεδομένων στίχων -Name[en_GB]=Lyrics Data Engine -Name[eo]=Datuma motoro de la parolaro -Name[es]=Motor de datos para letras -Name[et]=Sõnade andmemootor -Name[eu]=Hitzen datuen motorra -Name[fi]=Sanojen tietomoottori -Name[fr]=Moteur de données pour les paroles -Name[ga]=Inneall Sonraí Liricí -Name[gl]=Motor de dados de letras de cancións -Name[hne]=गीत डाटा इंजिन -Name[hu]=Dalszöveg-adatmotor -Name[id]=Mesin Data Lirik -Name[is]=Lagatextagagnavél -Name[it]=Motore dati dei testi -Name[ja]=歌詞データエンジン -Name[km]=ម៉ាស៊ីន​ទិន្នន័យ​ទំនុក -Name[ko]=가사 데이터 엔진 -Name[ku]=Motora Dane ya Lîrîk -Name[lt]=Dainos tekstų duomenų sistema -Name[lv]=Dziesmu vārdu datu dzinējs -Name[nb]=Datamotor for sangtekster -Name[nds]=Text-Datenkarn -Name[nl]=Liedteksten-gegevensengine -Name[nn]=Datamotor for songtekstar -Name[pa]=ਬੋਲ ਡਾਟਾ ਇੰਜਣ -Name[pl]=Moduł danych tekstów -Name[pt]=Motor de Dados de Letras Musicais -Name[pt_BR]=Mecanismo de dados das letras -Name[ro]=Motor de date Versuri -Name[ru]=Источник данных для текстов песен -Name[sk]=Dátový nástroj Texty piesní -Name[sl]=Podatkovni pogon za besedila -Name[sr]=Датомотор стихова -Name[sr@ijekavian]=Датомотор стихова -Name[sr@ijekavianlatin]=Datomotor stihova -Name[sr@latin]=Datomotor stihova -Name[sv]=Datagränssnitt för sångtexter -Name[th]=กลไกข้อมูลของเนื้อร้อง -Name[tr]=Şarkı Sözü Veri Motoru -Name[uk]=Рушій даних слів пісень -Name[wa]=Éndjin d' dinêyes des paroles -Name[x-test]=xxLyrics Data Enginexx -Name[zh_CN]=歌词数据引擎 -Name[zh_TW]=歌詞資料引擎 -X-KDE-ServiceTypes=Plasma/DataEngine -Type=Service -Icon=lyrics -X-KDE-Library=amarok_data_engine_lyrics -X-KDE-PluginInfo-Name=amarok-lyrics -X-KDE-ParentApp=Amarok - diff --git a/amarok/src/context/engines/photos/CMakeLists.txt b/amarok/src/context/engines/photos/CMakeLists.txt deleted file mode 100644 index 913b94bb..00000000 --- a/amarok/src/context/engines/photos/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -include_directories( - ${Amarok_SOURCE_DIR}/src - ${Amarok_SOURCE_DIR}/src/context - ${Amarok_SOURCE_DIR}/src/network - ${CMAKE_CURRENT_BINARY_DIR} # for amarok_config.h -) - -set( photos_engine_SRCS - PhotosEngine.cpp -) - -kde4_add_plugin(amarok_data_engine_photos ${photos_engine_SRCS}) -target_link_libraries( amarok_data_engine_photos amarokcore amaroklib ${KDE4_PLASMA_LIBS} ${KDE4_KIO_LIBS}) - -install( TARGETS amarok_data_engine_photos DESTINATION ${PLUGIN_INSTALL_DIR} ) -install( FILES amarok-data-engine-photos.desktop DESTINATION ${SERVICES_INSTALL_DIR} ) diff --git a/amarok/src/context/engines/photos/PhotosEngine.cpp b/amarok/src/context/engines/photos/PhotosEngine.cpp deleted file mode 100644 index cdfe469b..00000000 --- a/amarok/src/context/engines/photos/PhotosEngine.cpp +++ /dev/null @@ -1,263 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Simon Esneault * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "PhotosEngine" - -#include "PhotosEngine.h" - -#include "EngineController.h" -#include "context/ContextView.h" -#include "core/meta/Meta.h" -#include "core/support/Amarok.h" -#include "core/support/Debug.h" - -#include -#include - -using namespace Context; - -PhotosEngine::PhotosEngine( QObject* parent, const QList& /*args*/ ) - : DataEngine( parent ) - , m_nbPhotos( 10 ) -{ - m_sources << "flickr" ; -} - -PhotosEngine::~PhotosEngine() -{ -} - -void -PhotosEngine::init() -{ - DEBUG_BLOCK - EngineController *controller = The::engineController(); - connect( controller, SIGNAL(trackMetadataChanged(Meta::TrackPtr)), SLOT(trackChanged(Meta::TrackPtr)) ); - connect( controller, SIGNAL(trackChanged(Meta::TrackPtr)), SLOT(trackChanged(Meta::TrackPtr)) ); - connect( controller, SIGNAL(stopped(qint64,qint64)), SLOT(stopped()) ); -} - -void -PhotosEngine::stopped() -{ - DEBUG_BLOCK - removeAllData( "photos" ); - setData( "photos", "message", "stopped" ); - m_artist.clear(); - m_currentTrack.clear(); -} - -void -PhotosEngine::trackChanged( Meta::TrackPtr track ) -{ - if( !track ) - return; - - update(); -} - -QStringList -PhotosEngine::sources() const -{ - return m_sources; -} - -int -PhotosEngine::fetchSize() const -{ - return m_nbPhotos; -} - -void -PhotosEngine::setFetchSize( int size ) -{ - m_nbPhotos = size; -} - -QStringList -PhotosEngine::keywords() const -{ - return m_keywords; -} - -void -PhotosEngine::setKeywords( const QStringList &keywords ) -{ - m_keywords = keywords; -} - -bool -PhotosEngine::sourceRequestEvent( const QString& name ) -{ - DEBUG_BLOCK - bool force( false ); - QStringList tokens = name.split( QLatin1Char(':'), QString::SkipEmptyParts ); - if( tokens.contains( QLatin1String("forceUpdate") ) ) - force = true; - update( force ); - return true; -} - -void -PhotosEngine::metadataChanged( Meta::TrackPtr track ) -{ - const bool hasChanged = !track->artist() || track->artist()->name() != m_artist; - if ( hasChanged ) - update(); -} - -void -PhotosEngine::update( bool force ) -{ - QString tmpYoutStr; - // prevent - Meta::TrackPtr currentTrack = The::engineController()->currentTrack(); - if( !currentTrack || !currentTrack->artist() ) - { - debug() << "invalid current track"; - setData( "photos", Plasma::DataEngine::Data() ); - return; - } - else if( !force && currentTrack->artist()->name() == m_artist ) - { - debug() << "artist name unchanged"; - setData( "photos", Plasma::DataEngine::Data() ); - return; - } - else - { - unsubscribeFrom( m_currentTrack ); - m_currentTrack = currentTrack; - subscribeTo( currentTrack ); - - if ( !currentTrack ) - return; - - // Save artist - m_artist = currentTrack->artist()->name(); - - removeAllData( "photos" ); - - // Show the information - if( !m_artist.isEmpty() ) - { - setData( "photos", "message", "Fetching"); - setData( "photos", "artist", m_artist ); - } - else - { - removeAllData( "photos" ); - return; - } - - QStringList tags = m_keywords; - tags << m_artist; - tags.removeDuplicates(); - - // Query flickr, order by relevance, 10 max - // Flickr :http://api.flickr.com/services/rest/?method=flickr.photos.search&api_key=9c5a288116c34c17ecee37877397fe31&text=ARTIST&per_page=20 - KUrl flickrUrl; - flickrUrl.setScheme( "http" ); - flickrUrl.setHost( "api.flickr.com" ); - flickrUrl.setPath( "/services/rest/" ); - flickrUrl.addQueryItem( "method", "flickr.photos.search" ); - flickrUrl.addQueryItem( "api_key", Amarok::flickrApiKey() ); - flickrUrl.addQueryItem( "per_page", QString::number( m_nbPhotos ) ); - flickrUrl.addQueryItem( "sort", "date-posted-desc" ); - flickrUrl.addQueryItem( "media", "photos" ); - flickrUrl.addQueryItem( "content_type", QString::number(1) ); - flickrUrl.addQueryItem( "text", tags.join(" ") ); - debug() << "Flickr url:" << flickrUrl; - - m_flickrUrls << flickrUrl; - The::networkAccessManager()->getData( flickrUrl, this, - SLOT(resultFlickr(KUrl,QByteArray,NetworkAccessManagerProxy::Error)) ); - - } -} - -void -PhotosEngine::resultFlickr( const KUrl &url, QByteArray data, NetworkAccessManagerProxy::Error e ) -{ - if( !m_flickrUrls.contains( url ) ) - return; - - DEBUG_BLOCK - m_flickrUrls.remove( url ); - if( e.code != QNetworkReply::NoError ) - { - setData( "photos", "message", i18n( "Unable to retrieve from Flickr.com: %1", e.description ) ); - debug() << "Unable to retrieve Flickr information:" << e.description; - return; - } - - if( data.isNull() ) - { - debug() << "Got bad xml!"; - return; - } - - removeAllData( "photos" ); - QXmlStreamReader xml( data ); - PhotosInfo::List photosInfo = photosListFromXml( xml ); - debug() << "got" << photosInfo.size() << "photo info"; - setData( "photos", "artist", m_artist ); - setData( "photos", "data", qVariantFromValue( photosInfo ) ); -} - -PhotosInfo::List -PhotosEngine::photosListFromXml( QXmlStreamReader &xml ) -{ - PhotosInfo::List photoList; - xml.readNextStartElement(); // rsp - if( xml.attributes().value(QLatin1String("stat")) != QLatin1String("ok") ) - return photoList; - - xml.readNextStartElement(); // photos - while( xml.readNextStartElement() ) - { - if( xml.name() == QLatin1String("photo") ) - { - const QXmlStreamAttributes &attr = xml.attributes(); - QStringRef id = attr.value( QLatin1String("id") ); - QStringRef farm = attr.value( QLatin1String("farm") ); - QStringRef owner = attr.value( QLatin1String("owner") ); - QStringRef secret = attr.value( QLatin1String("secret") ); - QStringRef server = attr.value( QLatin1String("server") ); - QStringRef title = attr.value( QLatin1String("title") ); - - KUrl photoUrl; - photoUrl.setScheme( "http" ); - photoUrl.setHost( QString("farm%1.static.flickr.com").arg( farm.toString() ) ); - photoUrl.setPath( QString("/%1/%2_%3.jpg").arg( server.toString(), id.toString(), secret.toString() ) ); - - KUrl pageUrl; - pageUrl.setScheme( "http" ); - pageUrl.setHost( QLatin1String("www.flickr.com") ); - pageUrl.setPath( QString("/photos/%1/%2").arg( owner.toString(), id.toString() ) ); - - PhotosInfoPtr info( new PhotosInfo ); - info->title = title.toString(); - info->urlpage = pageUrl; - info->urlphoto = photoUrl; - photoList.append( info ); - } - xml.skipCurrentElement(); - } - return photoList; -} - -#include "moc_PhotosEngine.cpp" diff --git a/amarok/src/context/engines/photos/PhotosEngine.h b/amarok/src/context/engines/photos/PhotosEngine.h deleted file mode 100644 index e5c92e1f..00000000 --- a/amarok/src/context/engines/photos/PhotosEngine.h +++ /dev/null @@ -1,102 +0,0 @@ -#/**************************************************************************************** - * Copyright (c) 2009 Simon Esneault * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_PHOTOS_ENGINE -#define AMAROK_PHOTOS_ENGINE - -#include "context/DataEngine.h" -#include "core/meta/Observer.h" -#include "NetworkAccessManagerProxy.h" -#include "PhotosInfo.h" - -#include - -using namespace Context; - - /** - * This class provide photos from flickr - * - */ -class PhotosEngine : public DataEngine, public Meta::Observer -{ - Q_OBJECT - Q_PROPERTY( int fetchSize READ fetchSize WRITE setFetchSize ) - Q_PROPERTY( QStringList keywords READ keywords WRITE setKeywords ) - -public: - PhotosEngine( QObject* parent, const QList& args ); - virtual ~PhotosEngine(); - - void init(); - - int fetchSize() const; - void setFetchSize( int size ); - - QStringList keywords() const; - void setKeywords( const QStringList &keywords ); - - QStringList sources() const; - - // reimplemented from Meta::Observer - using Observer::metadataChanged; - void metadataChanged( Meta::TrackPtr track ); - -protected: - //reimplement from Plasma::DataEngine - bool sourceRequestEvent( const QString& name ); - -private slots: - - /** - * This slots will handle Flickr result for this query : - * API key is : 9c5a288116c34c17ecee37877397fe31 - * Secret is : cc25e5a9532ddc97 - * http://api.flickr.com/services/rest/?method=flickr.photos.search&api_key=9c5a288116c34c17ecee37877397fe31&text=My+Bloody+Valentine - * see here for details: http://www.flickr.com/services/api/ - */ - void resultFlickr( const KUrl &url, QByteArray data, NetworkAccessManagerProxy::Error e ); - - void stopped(); - void trackChanged( Meta::TrackPtr track ); - -private: - /** - * Engine was updated, so we check if the songs is different, and if it is, we delete every and start - * all the query/ fetching stuff - */ - void update( bool force = false ); - - PhotosInfo::List photosListFromXml( QXmlStreamReader &xml ); - - // TODO implement a reload - void reloadPhotos(); - - int m_nbPhotos; - - QSet m_flickrUrls; - QStringList m_sources; - - Meta::TrackPtr m_currentTrack; - // Cache the artist of the current track so we can check against metadata - // updates. We only want to update the photos if the artist change - - QString m_artist; - QStringList m_keywords; -}; - -AMAROK_EXPORT_DATAENGINE( photos, PhotosEngine ) - -#endif diff --git a/amarok/src/context/engines/photos/PhotosInfo.h b/amarok/src/context/engines/photos/PhotosInfo.h deleted file mode 100644 index 59d00211..00000000 --- a/amarok/src/context/engines/photos/PhotosInfo.h +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************************** - * - * Copyright (c) 2009 Simon Esneault * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_PHOTOS_INFO -#define AMAROK_PHOTOS_INFO - -#include -#include - -#include -#include - -class PhotosInfo; -typedef KSharedPtr PhotosInfoPtr; - -//! Struct PhotosInfo, contain all the info vor a photos -class PhotosInfo : public QSharedData -{ -public: - typedef QList List; - - PhotosInfo() - { - static bool metaTypeRegistered = false; - if( !metaTypeRegistered ) - { - qRegisterMetaType( "PhotosInfo" ); - qRegisterMetaType( "PhotosInfoPtr" ); - qRegisterMetaType( "PhotosInfo::List" ); - metaTypeRegistered = true; - } - } - - PhotosInfo( const PhotosInfo &other ) - : QSharedData( other ) - , title( other.title ) - , urlphoto( other.urlphoto ) - , urlpage( other.urlpage ) - {} - ~PhotosInfo() {} - - QString title; // Name of the phtos - KUrl urlphoto; // url of the photos, for the download - KUrl urlpage; // Url for the browser ( http://www.flickr.com/photos/wanderlustg/322285063/ ) -}; - -Q_DECLARE_METATYPE( PhotosInfo ) -Q_DECLARE_METATYPE( PhotosInfoPtr ) -Q_DECLARE_METATYPE( PhotosInfo::List ) - -#endif diff --git a/amarok/src/context/engines/photos/amarok-data-engine-photos.desktop b/amarok/src/context/engines/photos/amarok-data-engine-photos.desktop deleted file mode 100644 index 51e431d7..00000000 --- a/amarok/src/context/engines/photos/amarok-data-engine-photos.desktop +++ /dev/null @@ -1,57 +0,0 @@ -[Desktop Entry] -Name=Photos Data Engine -Name[bg]=Ядро за снимки -Name[bs]=Pogon podatka fotografija -Name[ca]=Motor de dades de fotos -Name[ca@valencia]=Motor de dades de fotos -Name[cs]=Datový nástroj fotek -Name[csb]=Mòtór pòdôwków òdjimków -Name[da]=Datamotor til fotos -Name[de]=Datenmodul für Fotos -Name[el]=Μηχανή δεδομένων φωτογραφιών -Name[en_GB]=Photos Data Engine -Name[es]=Motor de datos de fotos -Name[et]=Fotode andmemootor -Name[eu]=Argazkien datuen motorra -Name[fi]=Valokuvien tietomoottori -Name[fr]=Moteur de données pour les photos -Name[ga]=Inneall Sonraí Grianghraf -Name[gl]=Motor de datos de fotos -Name[hu]=Fotó-adatmotor -Name[id]=Mesin Data Foto -Name[is]=Ljósmyndagagnavél -Name[it]=Motore dati delle fotografie -Name[ja]=写真 データエンジン -Name[km]=ម៉ាស៊ីន​ទិន្នន័យ​រូប​ថត -Name[ko]=사진 데이터 엔진 -Name[lt]=Nuotraukų duomenų sistema -Name[lv]=Fotogrāfiju datu dzinējs -Name[nb]=Foto datamotor -Name[nds]=Foto-Datenkarn -Name[nl]=Foto-gegevensengine -Name[nn]=Datamotor for bilete -Name[pa]=ਫੋਟੋ ਡਾਟਾ ਇੰਜਣ -Name[pl]=Moduł danych zdjęć -Name[pt]=Motor de Dados de Fotografias -Name[pt_BR]=Mecanismo de dados de fotos -Name[ro]=Motor de date Fotografii -Name[ru]=Источник данных фотографий -Name[sk]=Dátový nástroj Fotografie -Name[sl]=Podatkovni pogon za fotografije -Name[sr]=Датомотор фотографија -Name[sr@ijekavian]=Датомотор фотографија -Name[sr@ijekavianlatin]=Datomotor fotografija -Name[sr@latin]=Datomotor fotografija -Name[sv]=Datagränssnitt för foton -Name[th]=กลไกข้อมูลของภาพถ่าย -Name[tr]=Fotoğraf Veri Motoru -Name[uk]=Рушій даних фотографій -Name[x-test]=xxPhotos Data Enginexx -Name[zh_CN]=照片数据引擎 -Name[zh_TW]=Photos 資料引擎 -X-KDE-ServiceTypes=Plasma/DataEngine -X-KDE-ParentApp=Amarok -Type=Service -Icon=Photos -X-KDE-Library=amarok_data_engine_photos -X-KDE-PluginInfo-Name=amarok-photos diff --git a/amarok/src/context/engines/similarartists/CMakeLists.txt b/amarok/src/context/engines/similarartists/CMakeLists.txt deleted file mode 100644 index 61132e0a..00000000 --- a/amarok/src/context/engines/similarartists/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ - -include_directories( ${Amarok_SOURCE_DIR}/src - ${Amarok_SOURCE_DIR}/src/context - ${Amarok_SOURCE_DIR}/src/network - ${LIBLASTFM_INCLUDE_DIR} - ${LIBLASTFM_INCLUDE_DIR}/.. - ${CMAKE_CURRENT_BINARY_DIR} # for amarok_config.h -) - -set( similarArtists_engine_SRCS - SimilarArtistsEngine.cpp - ../../applets/similarartists/SimilarArtist.cpp -) - -kde4_add_plugin(amarok_data_engine_similarArtists ${similarArtists_engine_SRCS}) -target_link_libraries( amarok_data_engine_similarArtists amarokcore amaroklib ${KDE4_PLASMA_LIBS} ${KDE4_KIO_LIBS} ${LIBLASTFM_LIBRARY} ) - -install( TARGETS amarok_data_engine_similarArtists DESTINATION ${PLUGIN_INSTALL_DIR} ) -install( FILES amarok-data-engine-similarArtists.desktop DESTINATION ${SERVICES_INSTALL_DIR} ) diff --git a/amarok/src/context/engines/similarartists/SimilarArtistsEngine.cpp b/amarok/src/context/engines/similarartists/SimilarArtistsEngine.cpp deleted file mode 100644 index 85453228..00000000 --- a/amarok/src/context/engines/similarartists/SimilarArtistsEngine.cpp +++ /dev/null @@ -1,177 +0,0 @@ -/*************************************************************************************** -* Copyright (c) 2009 Nathan Sala * -* Copyright (c) 2009 Oleksandr Khayrullin * -* Copyright (c) 2009-2010 Joffrey Clavel * -* * -* This program 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 2 of the License, or (at your option) any later * -* version. * -* * -* This program 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 * -* this program. If not, see . * -****************************************************************************************/ - -#define DEBUG_PREFIX "SimilarArtistsEngine" - -#include "SimilarArtistsEngine.h" - -#include "EngineController.h" -#include "core/meta/Meta.h" -#include "core/support/Amarok.h" -#include "core/support/Debug.h" - -#include -#include - -AMAROK_EXPORT_DATAENGINE( similarArtists, SimilarArtistsEngine ) - -using namespace Context; - -SimilarArtistsEngine::SimilarArtistsEngine( QObject *parent, const QList& /*args*/ ) - : DataEngine( parent ) - , m_maxArtists( 5 ) -{ -} - -SimilarArtistsEngine::~SimilarArtistsEngine() -{ -} - -void -SimilarArtistsEngine::init() -{ - EngineController *engine = The::engineController(); - connect( engine, SIGNAL(trackChanged(Meta::TrackPtr)), SLOT(update()) ); - connect( engine, SIGNAL(trackMetadataChanged(Meta::TrackPtr)), SLOT(update()) ); -} - -bool -SimilarArtistsEngine::sourceRequestEvent( const QString &name ) -{ - if( !name.startsWith( "similarArtists" ) ) - return false; - - bool force( false ); - QStringList tokens = name.split( QLatin1Char(':'), QString::SkipEmptyParts ); - if( tokens.contains( QLatin1String("forceUpdate") ) ) - force = true; - - if( tokens.contains( QLatin1String("artist") ) ) - return update( m_artist ); - else - return update( force ); -} - -bool -SimilarArtistsEngine::update( bool force ) -{ - QString newArtist; - - Meta::TrackPtr track = The::engineController()->currentTrack(); - if( track ) - { - if( Meta::ArtistPtr artistPtr = track->artist() ) - newArtist = artistPtr->name(); - } - - if( newArtist.isEmpty() ) - { - m_artist.clear(); - removeAllData( "similarArtists" ); - return false; - } - else //valid artist - { - // wee make a request only if the artist is different - if( force || (newArtist != m_artist) ) - { - // if the artist has changed - m_artist = newArtist; - similarArtistsRequest( m_artist ); - return true; - } - } - return false; -} - -bool -SimilarArtistsEngine::update( const QString &name ) -{ - if( name.isEmpty() ) - return false; - - m_artist = name; - similarArtistsRequest( m_artist ); - return true; -} - -void -SimilarArtistsEngine::similarArtistsRequest( const QString &artistName ) -{ - // we generate the url for the demand on the lastFM Api - KUrl url; - url.setScheme( "http" ); - url.setHost( "ws.audioscrobbler.com" ); - url.setPath( "/2.0/" ); - url.addQueryItem( "method", "artist.getSimilar" ); - url.addQueryItem( "api_key", Amarok::lastfmApiKey() ); - url.addQueryItem( "artist", artistName ); - url.addQueryItem( "limit", QString::number( m_maxArtists ) ); - - The::networkAccessManager()->getData( url, this, - SLOT(parseSimilarArtists(KUrl,QByteArray,NetworkAccessManagerProxy::Error)) ); -} - -void -SimilarArtistsEngine::parseSimilarArtists( const KUrl &url, QByteArray data, - NetworkAccessManagerProxy::Error e ) -{ - if( e.code != QNetworkReply::NoError ) - { - removeAllData( "similarArtists" ); - warning() << "Failed to parse similar artists xml:" << url << e.description; - return; - } - - if( data.isEmpty() ) - return; - - QXmlStreamReader xml( data ); - SimilarArtist::List saList = SimilarArtist::listFromXml( xml ); - debug() << "Found" << saList.size() << "similar artists to" << m_artist; - Plasma::DataEngine::Data eData; - eData[ "artist" ] = m_artist; - eData[ "similar" ] = qVariantFromValue( saList ); - setData( "similarArtists", eData ); -} - -int -SimilarArtistsEngine::maximumArtists() const -{ - return m_maxArtists; -} - -void -SimilarArtistsEngine::setMaximumArtists( int number ) -{ - m_maxArtists = number; -} - -QString -SimilarArtistsEngine::artist() const -{ - return m_artist; -} - -void -SimilarArtistsEngine::setArtist( const QString &name ) -{ - m_artist = name; -} - -#include "moc_SimilarArtistsEngine.cpp" diff --git a/amarok/src/context/engines/similarartists/SimilarArtistsEngine.h b/amarok/src/context/engines/similarartists/SimilarArtistsEngine.h deleted file mode 100644 index 689ff9b0..00000000 --- a/amarok/src/context/engines/similarartists/SimilarArtistsEngine.h +++ /dev/null @@ -1,107 +0,0 @@ -/*************************************************************************************** -* Copyright (c) 2009 Nathan Sala * -* Copyright (c) 2009 Oleksandr Khayrullin * -* Copyright (c) 2009-2010 Joffrey Clavel * -* * -* This program 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 2 of the License, or (at your option) any later * -* version. * -* * -* This program 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 * -* this program. If not, see . * -****************************************************************************************/ - -#ifndef SIMILARARTISTSENGINE_H -#define SIMILARARTISTSENGINE_H - -#include "NetworkAccessManagerProxy.h" -#include "context/DataEngine.h" -#include "context/applets/similarartists/SimilarArtist.h" -#include "core/meta/forward_declarations.h" - -using namespace Context; - -/** - * This class provide SimilarArtists data for use in the SimilarArtists context applet. - * It gets its information from the API lastfm. - */ -class SimilarArtistsEngine : public DataEngine -{ - Q_OBJECT - Q_PROPERTY( int maximumArtists READ maximumArtists WRITE setMaximumArtists ) - Q_PROPERTY( QString artist READ artist WRITE setArtist ) - -public: - - /** - * Construct the engine - * @param parent The object parent to this engine - */ - SimilarArtistsEngine( QObject *parent, const QList &args ); - - virtual void init(); - - /** - * Destroy the dataEngine - */ - virtual ~SimilarArtistsEngine(); - - /** - * Fetches the similar artists for an artist thanks to the LastFM WebService - * Store this in the similar artist list of this class - * @param artistName the name of the artist - */ - void similarArtistsRequest( const QString &artistName ); - - /** - * The maximum number of similar artists - * @return number of similar artists - */ - int maximumArtists() const; - - /** - * Set the maximum number of similar artists - * @param number The maximum number of similar artists - */ - void setMaximumArtists( int number ); - - QString artist() const; - void setArtist( const QString &name ); - -protected: - bool sourceRequestEvent( const QString &name ); - -private: - /** - * The max number of similar artists to get - */ - int m_maxArtists; - - /** - * The artist, whose research is similar artists. - */ - QString m_artist; - -private slots: - /** - * Update similar artists for the current playing track. - * Launch when the track played on amarok has changed. - * @param force force update to take place. - */ - bool update( bool force = false ); - - bool update( const QString &name ); - - /** - * Parse the xml fetched on the lastFM API. - * Launched when the download of the data are finished. - */ - void parseSimilarArtists( const KUrl &url, QByteArray data, NetworkAccessManagerProxy::Error e ); -}; - -#endif // SIMILARARTISTSENGINE_H diff --git a/amarok/src/context/engines/similarartists/amarok-data-engine-similarArtists.desktop b/amarok/src/context/engines/similarartists/amarok-data-engine-similarArtists.desktop deleted file mode 100644 index 2c873148..00000000 --- a/amarok/src/context/engines/similarartists/amarok-data-engine-similarArtists.desktop +++ /dev/null @@ -1,55 +0,0 @@ -[Desktop Entry] -Name=Upcoming Events Data Engine -Name[bg]=Ядро за предстоящи събития -Name[bs]=Pogon podataka predstoјećih događaјa -Name[ca]=Motor de dades de propers esdeveniments -Name[ca@valencia]=Motor de dades de propers esdeveniments -Name[cs]=Datový nástroj nadcházejících událostí -Name[da]=Datamotor til kommende begivenheder -Name[de]=Datenmodul für anstehende Ereignisse -Name[el]=Μηχανή δεδομένων επόμενων εκδηλώσεων -Name[en_GB]=Upcoming Events Data Engine -Name[es]=Motor de datos de próximos eventos -Name[et]=Tulevaste sündmuste andmemootor -Name[eu]=Hurrengo gertaeren datuen motorra -Name[fi]=Tulevien tapahtumien tietomoottori -Name[fr]=Moteur de données pour les évènements à venir -Name[ga]=Inneall Sonraí: Imeachtaí atá ag teacht -Name[gl]=Motor de datos de acontecementos vindeiros -Name[hu]=Közelgő események adatmotorja -Name[id]=Mesin Data Event Mendatang -Name[is]=Gagnavél fyrir væntanlega atburði -Name[it]=Motore dati Prossimi eventi -Name[ja]=近日中のイベントデータエンジン -Name[km]=ម៉ាស៊ីន​ទិន្នន័យ​ព្រឹត្តិការណ៍​ដែល​នឹង​កើត​ឡើង​ -Name[ko]=다가오는 약속 데이터 엔진 -Name[lt]=Artimiausių įvykių duomenų sistema -Name[lv]=Tuvāko notikumu datu dzinis -Name[nb]=Datamotor for kommende hendelser -Name[nds]=Datenkarn för anstahn Begeefnissen -Name[nl]=Gegevensengine voor komende evenementen -Name[pa]=ਆ ਰਹੇ ਈਵੈਂਟ ਡਾਟਾ ਇੰਜਣ -Name[pl]=Silnik danych nadchodzących wydarzeń -Name[pt]=Motor de Dados dos Próximos Eventos -Name[pt_BR]=Mecanismo de dados dos próximos eventos -Name[ro]=Motor de date Evenimente apropiate -Name[ru]=Источник данных о предстоящих событиях -Name[sk]=Dátový engine nových udalostí -Name[sl]=Podatkovni pogon za prihajajoče dogodke -Name[sr]=Датомотор предстојећих догађаја -Name[sr@ijekavian]=Датомотор предстојећих догађаја -Name[sr@ijekavianlatin]=Datomotor predstojećih događaja -Name[sr@latin]=Datomotor predstojećih događaja -Name[sv]=Datagränssnitt för kommande händelser -Name[tr]=Gelecek Etkinlikler Veri Motoru -Name[uk]=Рушій розкладу найближчих подій -Name[x-test]=xxUpcoming Events Data Enginexx -Name[zh_CN]=近期事件数据引擎 -Name[zh_TW]=即將來臨的事件資料引擎 -X-KDE-ServiceTypes=Plasma/DataEngine -Type=Service -Icon=amarok -X-KDE-Library=amarok_data_engine_similarArtists -X-KDE-PluginInfo-Name=amarok-similarArtists -X-KDE-ParentApp=Amarok - diff --git a/amarok/src/context/engines/songkick/CMakeLists.txt b/amarok/src/context/engines/songkick/CMakeLists.txt deleted file mode 100644 index 783fc812..00000000 --- a/amarok/src/context/engines/songkick/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -include_directories( ../../.. - ../../../context - ../../../dialogs - ../../../../external - ) - -set( songkick_engine_SRCS - SongkickEngine.cpp -) - -kde4_add_plugin(amarok_data_engine_songkick ${songkick_engine_SRCS}) -target_link_libraries( amarok_data_engine_songkick amarokcore amaroklib ${KDE4_PLASMA_LIBS} amarokqtjson ${KDE4_KIO_LIBS}) - -install( TARGETS amarok_data_engine_songkick DESTINATION ${PLUGIN_INSTALL_DIR} ) -install( FILES amarok-data-engine-songkick.desktop DESTINATION ${SERVICES_INSTALL_DIR} ) - diff --git a/amarok/src/context/engines/songkick/SongkickEngine.cpp b/amarok/src/context/engines/songkick/SongkickEngine.cpp deleted file mode 100644 index ed0faa69..00000000 --- a/amarok/src/context/engines/songkick/SongkickEngine.cpp +++ /dev/null @@ -1,167 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Jeff Mitchell * - * Copyright (c) 2007-2008 Leo Franchi * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "SongkickEngine.h" - -#include "JsonQt/lib/JsonToVariant.h" -#include "JsonQt/lib/ParseException.h" - -#include "core/support/Amarok.h" -#include "core/support/Debug.h" -#include "ContextObserver.h" -#include "ContextView.h" -#include "EngineController.h" - -#include - -#include -#include -#include - -using namespace Context; - -SongkickEngine::SongkickEngine( QObject* parent, const QList& args ) - : DataEngine( parent ) - , ContextObserver( ContextView::self() ) - , m_datesJob( 0 ) - , m_currentTrack( 0 ) - , m_ontour( true ) - , m_dates( true ) -{ - Q_UNUSED( args ) - DEBUG_BLOCK - - m_sources << I18N_NOOP( "ontour" ) << I18N_NOOP( "dates" ); -} - -QStringList SongkickEngine::sources() const -{ - DEBUG_BLOCK - return m_sources; -} - -bool SongkickEngine::sourceRequestEvent( const QString& name ) -{ - DEBUG_BLOCK - debug() << "sourceRequested with name " << name; - - removeAllData( name ); - setData( name, "fetching" ); - update(); - return true; -} - -void SongkickEngine::message( const ContextState& state ) -{ - DEBUG_BLOCK - if( state == Current ) - update(); -} - -void SongkickEngine::metadataChanged( Meta::TrackPtr track ) -{ - Q_UNUSED( track ) - DEBUG_BLOCK - - update(); -} - -void SongkickEngine::update() -{ - DEBUG_BLOCK - - unsubscribeFrom( m_currentTrack ); - Meta::TrackPtr currentTrack = The::engineController()->currentTrack(); - m_currentTrack = currentTrack; - subscribeTo( currentTrack ); - - if ( !currentTrack ) - { - debug() << "No current track!"; - return; - } - else if ( !currentTrack->artist() ) - { - debug() << "No artist found!"; - return; - } - - QString country = QLocale::system().name().right( 2 ).toLower(); - KUrl ontourUrl( QString( "http://api.songkick.com/api/V2/get_tour_status?key=kJcAUmzi8AoAngzh&id=0&country=%2&range=all&name=%1" ).arg( QUrl::toPercentEncoding( currentTrack->artist()->prettyName() ), country ) ); - debug() << "getting ontour status: " << ontourUrl; - m_ontourJob = KIO::storedGet( ontourUrl, KIO::NoReload, KIO::HideProgressInfo ); - connect( m_ontourJob, SIGNAL(result(KJob*)), this, SLOT(ontourResult(KJob*)) ); - - KUrl datesUrl( QString( "http://api.songkick.com/api/V2/get_dates_extended?key=kJcAUmzi8AoAngzh&id=0&country=%2&range=all&name=%1" ).arg( QUrl::toPercentEncoding( currentTrack->artist()->prettyName() ), country ) ); - debug() << "getting concert dates: " << datesUrl; - m_datesJob = KIO::storedGet( datesUrl, KIO::NoReload, KIO::HideProgressInfo ); - connect( m_datesJob, SIGNAL(result(KJob*)), this, SLOT(datesResult(KJob*)) ); -} - -void SongkickEngine::datesResult( KJob* job ) -{ - DEBUG_BLOCK - if( job != m_datesJob ) - return; - - if( !m_datesJob ) - return; - if( !job->error() == 0 && m_datesJob == job) - { - setData( "dates", "error" ); - return; - } - - KIO::StoredTransferJob* const storedJob = static_cast( job ); - QString data = QString( storedJob->data() ); - - QVariantMap dates; - /*QVariant datesResult = JsonQt::JsonToVariant::parse( data ); - - debug() << "got dates: " << dates; - QMapIterator< QString, QVariant > iter( dates ); - while( iter.hasNext() ) - { - iter.next(); - setData( "dates", iter.key(), iter.value() ); - } - */ - setData( "dates", data ); -} - -void SongkickEngine::ontourResult( KJob* job ) -{ - DEBUG_BLOCK - if( job != m_ontourJob ) - return; - - m_ontour = false; - if( !m_ontourJob ) - return; - if( !job->error() == 0 && m_ontourJob == job ) - { - setData( "ontour", "error" ); - return; - } - - KIO::StoredTransferJob* const storedJob = static_cast( job ); - QString data = QString( storedJob->data() ); - QVariantMap status; - setData( "ontour", data ); -} - -#include "moc_SongkickEngine.cpp" diff --git a/amarok/src/context/engines/songkick/SongkickEngine.h b/amarok/src/context/engines/songkick/SongkickEngine.h deleted file mode 100644 index e8f31e92..00000000 --- a/amarok/src/context/engines/songkick/SongkickEngine.h +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Jeff Mitchell * - * Copyright (c) 2007-2008 Leo Franchi * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_SONGKICK_ENGINE -#define AMAROK_SONGKICK_ENGINE - -#include "ContextObserver.h" -#include "context/DataEngine.h" -#include "core/meta/forward_declarations.h" - -#include - -/** - This class provides Songkick data for use in Context applets. - It provides concert/tour information. -*/ - -using namespace Context; - -class SongkickEngine : public DataEngine, public ContextObserver, Meta::Observer -{ - Q_OBJECT - -public: - SongkickEngine( QObject* parent, const QList& args ); - - QStringList sources() const; - - //reimplemented from ContextObserver - virtual void message( const ContextState& state ); - - //reimplemented from Meta::Observer - using Observer::metadataChanged; - void metadataChanged( Meta::TrackPtr track ); - -protected: - bool sourceRequestEvent( const QString& name ); - -private slots: - void datesResult( KJob* ); - void ontourResult( KJob* ); - -private: - void update(); - - KJob* m_datesJob; - KJob* m_ontourJob; - - QStringList m_sources; - - Meta::TrackPtr m_currentTrack; - - bool m_ontour; - bool m_dates; - -}; - -AMAROK_EXPORT_DATAENGINE( songkick, SongkickEngine ) - -#endif diff --git a/amarok/src/context/engines/songkick/amarok-data-engine-songkick.desktop b/amarok/src/context/engines/songkick/amarok-data-engine-songkick.desktop deleted file mode 100644 index fb752ea0..00000000 --- a/amarok/src/context/engines/songkick/amarok-data-engine-songkick.desktop +++ /dev/null @@ -1,62 +0,0 @@ -[Desktop Entry] -Name=Songkick Data Engine -Name[bg]=Ядро Songkick -Name[bs]=Pogon podataka Songkicka -Name[ca]=Motor de dades de Songkick -Name[ca@valencia]=Motor de dades de Songkick -Name[cs]=Datový nástroj Songkick -Name[csb]=Mòtór Songkicka -Name[da]=Datamotor til Songkick -Name[de]=Datenmodul für Songkick -Name[el]=Μηχανή δεδομένων Songkick -Name[en_GB]=Songkick Data Engine -Name[es]=Motor de datos de Songkick -Name[et]=Songkicki andmemootor -Name[eu]=Songkick datuen motorra -Name[fi]=Songkickin tietomoottori -Name[fr]=Moteur de données pour Songkick -Name[ga]=Inneall Sonraí Songkick -Name[gl]=Motor de dados de Songkick -Name[he]=מנוע מידע של Songkic -Name[hne]=सांगकिक डाटा इंजिन -Name[hu]=Songkick-adatmotor -Name[id]=Mesin Data Songkik -Name[is]=Songkick gagnarvél -Name[it]=Motore dati Songkick -Name[ja]=Songkick データエンジン -Name[km]=ម៉ាស៊ីន​ទិន្នន័យ Songkick -Name[ko]=Songkick 데이터 엔진 -Name[ku]=Songkick Motora Dane yan -Name[lt]=Songkick duomenų sistema -Name[lv]=Songkick datu dzinējs -Name[ms]=Enjin Data Songkick -Name[nb]=Datamotor for Songkick -Name[nds]=Songkick-Datenkarn -Name[nl]=Songkick-gegevensengine -Name[nn]=Datamotor for Songkick -Name[pa]=ਸਾਂਗਕਿੱਕ ਡਾਟਾ ਇੰਜਣ -Name[pl]=Moduł danych Songkick -Name[pt]=Motor de Dados do Songkick -Name[pt_BR]=Mecanismo de dados do Songkick -Name[ro]=Motor de date Songkick -Name[ru]=Источник данных Songkick -Name[sk]=Dátový nástroj Songkick -Name[sl]=Podatkovni pogon za Songkick -Name[sr]=Датомотор Сонгкика -Name[sr@ijekavian]=Датомотор Сонгкика -Name[sr@ijekavianlatin]=Datomotor Songkicka -Name[sr@latin]=Datomotor Songkicka -Name[sv]=Songkick datagränssnitt -Name[th]=กลไกข้อมูลของ Songkick -Name[tr]=Songkick Veri Motoru -Name[uk]=Рушій даних Songkick -Name[wa]=Éndjin d' dinêyes Songkick -Name[x-test]=xxSongkick Data Enginexx -Name[zh_CN]=Songkick 数据引擎 -Name[zh_TW]=Songkick 資料引擎 -X-KDE-ServiceTypes=Plasma/DataEngine -Type=Service -Icon=songkick -X-KDE-Library=amarok_data_engine_songkick -X-KDE-PluginInfo-Name=amarok-songkick -X-KDE-ParentApp=Amarok diff --git a/amarok/src/context/engines/tabs/CMakeLists.txt b/amarok/src/context/engines/tabs/CMakeLists.txt deleted file mode 100644 index 32364519..00000000 --- a/amarok/src/context/engines/tabs/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -include_directories( ../../.. - ../../../context - ${Amarok_SOURCE_DIR}/src/network - ${CMAKE_CURRENT_BINARY_DIR}/../../.. # for amarok_config.h -) - -set( tabs_engine_SRCS TabsEngine.cpp TabsInfo.h ) - -kde4_add_plugin(amarok_data_engine_tabs ${tabs_engine_SRCS}) -target_link_libraries( amarok_data_engine_tabs amarokcore amaroklib ${KDE4_PLASMA_LIBS} ${KDE4_KIO_LIBS}) - -install( TARGETS amarok_data_engine_tabs DESTINATION ${PLUGIN_INSTALL_DIR} ) -install( FILES amarok-data-engine-tabs.desktop DESTINATION ${SERVICES_INSTALL_DIR} ) diff --git a/amarok/src/context/engines/tabs/TabsEngine.cpp b/amarok/src/context/engines/tabs/TabsEngine.cpp deleted file mode 100644 index 5988f0c2..00000000 --- a/amarok/src/context/engines/tabs/TabsEngine.cpp +++ /dev/null @@ -1,512 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Rainer Sigle * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "TabsEngine" - -#include "TabsEngine.h" - -#include "EngineController.h" -#include "context/ContextView.h" -#include "core/meta/Meta.h" -#include "core/support/Amarok.h" -#include "core/support/Debug.h" - -#include - -using namespace Context; - -/** - * \brief Constructor - * - * Creates a new instance of the TabsEngine - */ -TabsEngine::TabsEngine( QObject* parent, const QList& /*args*/ ) - : DataEngine( parent ) - , m_fetchGuitar( true ) - , m_fetchBass( true ) - , m_numAbortedUrls( 0 ) -{ - EngineController *engine = The::engineController(); - connect( engine, SIGNAL(trackChanged(Meta::TrackPtr)), - this, SLOT(update()) ); - connect( engine, SIGNAL(trackMetadataChanged(Meta::TrackPtr)), - this, SLOT(update()) ); -} - -/** - * \brief Destructor - * - * Destroys a TabsEngine instance - */ -TabsEngine::~TabsEngine() -{ - DEBUG_BLOCK - foreach( TabsInfo *info, m_tabs ) - delete info; - m_tabs.clear(); - m_urls.clear(); -} - -/** - * Returns our sources - */ -QStringList -TabsEngine::sources() const -{ - // one source within the tabs-engine - QStringList sources; - sources << "tabs"; - return sources; -} - -bool -TabsEngine::fetchGuitar() const -{ - return m_fetchGuitar; -} - -void -TabsEngine::setFetchGuitar( const bool fetch ) -{ - m_fetchGuitar = fetch; -} - -bool -TabsEngine::fetchBass() const -{ - return m_fetchBass; -} - -void -TabsEngine::setFetchBass( const bool fetch ) -{ - m_fetchBass = fetch; -} - -QString -TabsEngine::artistName() const -{ - return m_artistName; -} - -void -TabsEngine::setArtistName( const QString &artistName ) -{ - m_artistName = artistName; -} - -QString -TabsEngine::titleName() const -{ - return m_titleName; -} - -void -TabsEngine::setTitleName( const QString &titleName ) -{ - m_titleName = titleName; -} - -bool -TabsEngine::sourceRequestEvent( const QString &name ) -{ - removeAllData( name ); - setData( name, QVariant() ); - - QStringList tokens = name.split( QLatin1Char(':'), QString::SkipEmptyParts ); - if( tokens.contains( QLatin1String( "forceUpdate" ) ) ) - { - // data coming from the applet configuration dialog - m_titleName.clear(); - m_artistName.clear(); - update(); - } - else if( tokens.contains( QLatin1String( "forceUpdateSpecificTitleArtist" ) ) ) - { - // handle reload of a specific artist and title - requestTab( m_artistName, m_titleName ); - } - else - { - // update on initial request - update(); - } - return true; -} - -/** - * called whenever metadata of the current track has changed - */ -void -TabsEngine::update() -{ - DEBUG_BLOCK - - // get the current track - Meta::TrackPtr track = The::engineController()->currentTrack(); - if( !track ) - { - debug() << "no track"; - m_titleName.clear(); - m_artistName.clear(); - removeAllData( "tabs" ); - setData( "tabs", "state", "Stopped" ); - return; - } - m_currentTrack = track; - Meta::ArtistPtr artistPtr = track->artist(); - QString newArtist; - if( artistPtr ) - { - if( ( track->playableUrl().protocol() == "lastfm" ) || - ( track->playableUrl().protocol() == "daap" ) || - !The::engineController()->isStream() ) - newArtist = artistPtr->name(); - else - newArtist = artistPtr->prettyName(); - } - - QString newTitle = track->name(); - if( newTitle.isEmpty() ) - newTitle = track->prettyName(); - - // check if something changed - if( newTitle == m_titleName && newArtist == m_artistName ) - { - debug() << "nothing changed"; - return; - } - - // stop fetching for unknown artists or titles - if( newTitle.isEmpty() || newArtist.isEmpty() ) - { - setData("tabs", "state", "noTabs" ); - return; - } - requestTab( newArtist, newTitle ); -} - -/** - * starts a new tab-search - */ -void -TabsEngine::requestTab( const QString &artist, const QString &title ) -{ - DEBUG_BLOCK - debug() << "request tabs for artist: " << artist << " and title " << title; - - // clean all previously allocated stuff - foreach( TabsInfo *tab, m_tabs ) - delete tab; - m_tabs.clear(); - m_urls.clear(); - m_numAbortedUrls = 0; - removeAllData( "tabs" ); - - m_artistName = artist; - m_titleName = title; - - // status update - setData( "tabs", "state", "Fetching" ); - setData( "tabs", "title", m_titleName ); - setData( "tabs", "artist", m_artistName ); - - // define search criteria for the current artist/track - QStringList artistSearchList = defineArtistSearchCriteria( artist ); - QStringList titleSearchList = defineTitleSearchCriteria( title ); - foreach( const QString &searchArtist, artistSearchList ) - { - foreach( const QString &searchTitle, titleSearchList ) - { - queryUltimateGuitar( searchArtist, searchTitle ); - } - } -} - -/** - * * starts a tab-search on UltimateGuitar.com - */ -void -TabsEngine::queryUltimateGuitar( const QString &artist, const QString &title ) -{ - // Query UltimateGuitar.com (filtering guitar (tabs + chords) and bass tabs) - KUrl ultimateGuitarUrl; - ultimateGuitarUrl.setScheme( "http" ); - ultimateGuitarUrl.setHost( "www.ultimate-guitar.com" ); - ultimateGuitarUrl.setPath( "/search.php" ); - ultimateGuitarUrl.addQueryItem( "view_state", "advanced" ); - ultimateGuitarUrl.addQueryItem( "band_name", artist ); - ultimateGuitarUrl.addQueryItem( "song_name", title ); - ultimateGuitarUrl.addQueryItem( "type%5B%5D", QString::number ( 200 ) ); // filter guitar tabs - ultimateGuitarUrl.addQueryItem( "type%5B%5D", QString::number ( 300 ) ); // filter guitar chords - ultimateGuitarUrl.addQueryItem( "type%5B%5D", QString::number ( 400 ) ); // filter bass tabs - ultimateGuitarUrl.addQueryItem( "version_la", "" ); - - The::networkAccessManager()->getData( ultimateGuitarUrl, this, - SLOT(resultUltimateGuitarSearch(KUrl,QByteArray,NetworkAccessManagerProxy::Error)) ); - m_urls.insert( ultimateGuitarUrl ); -} - -/** - * parses the tab search results from UltimateGuitar - */ -void -TabsEngine::resultUltimateGuitarSearch( const KUrl &url, QByteArray data, NetworkAccessManagerProxy::Error e ) -{ - // specific job has finished -> remove from queue - if( !m_urls.contains( url ) ) - return; - m_urls.remove( url ); - - // check if an error occurred during the HTTP-request - if( netReplyError( e ) ) - return; - - // get and parse the result - const QString result( data ); - const QString resultsTable = subStringBetween( result, "class=\"tresults\"", "" ); - if( !resultsTable.isEmpty() ) - { - const QStringList results = resultsTable.split( "" ); - foreach ( const QString &result, results ) - { - // lastIndex on purpose (due to the fact that tabledata for the first result contains two hrefs) - // get the link to the actual tab - const QString tabUrl = subStringBetween( result, "a href=\"", "\" class", true ); - if( !tabUrl.isEmpty() ) - { - // fetch the actual tab - const KUrl tabFetchUrl = KUrl( tabUrl ); - The::networkAccessManager()->getData( tabFetchUrl, this, - SLOT(resultUltimateGuitarTab(KUrl,QByteArray,NetworkAccessManagerProxy::Error)) ); - m_urls.insert( tabFetchUrl ); - } - } - } - resultFinalize(); -} - -/** - * * retrieves the information for a single tab from UltimateGuitar.com - */ -void -TabsEngine::resultUltimateGuitarTab( const KUrl &url, QByteArray data, NetworkAccessManagerProxy::Error e ) -{ - // specific tab search job has finished -> remove from queue - if( !m_urls.contains( url ) ) - return; - m_urls.remove( url ); - - // check if an error occurred during the HTTP-request - if( netReplyError( e ) ) - return; - - // TODO: is this valid in all cases? - // without fromLatin1, umlauts in german tabs are not displayed correctly - QString result; - if( QTextCodec::codecForUtfText( data )->name().contains( "ISO-8859-1" ) ) - result = QString::fromLatin1( data ); - else - result = QString( data ); - - // extract tab title and data - const QString title = subStringBetween( result, "", "" ); - result.remove( subStringBetween( result, "
", "
" ) ); - QRegExp regex = QRegExp( "
.*
", Qt::CaseInsensitive ); - if( regex.indexIn( result ) == -1 ) - return; - QString tabs = regex.cap(); - tabs.remove( "", Qt::CaseInsensitive ); - tabs.remove( "", Qt::CaseInsensitive ); - - TabsInfo::TabType tabType = TabsInfo::GUITAR; - const QString tabTypeString = subStringBetween( result, "", " by " ); - if( tabTypeString.contains( "bass", Qt::CaseInsensitive ) ) - tabType = TabsInfo::BASS; - - if( !tabs.isEmpty() ) - { - if( ( m_fetchGuitar && tabType == TabsInfo::GUITAR ) || - ( m_fetchBass && tabType == TabsInfo::BASS ) ) - { - TabsInfo *item = new TabsInfo; - item->url = url; - item->tabType = tabType; - item->title = title; - item->tabs = tabs; - item->source = "Ultimate-Guitar"; - - m_tabs << item; - } - } - // update the results - resultFinalize(); -} - -/** - * checks if all fetching jobs have finished and send the tab-data to the applet afterwards - */ -void -TabsEngine::resultFinalize() -{ - if( m_urls.count() > 0 ) - return; - - // remove fetching state - removeData( "tabs", "state" ); - - debug() << "Total # of fetched tabs: " << m_tabs.size(); - if( m_numAbortedUrls > 0 ) - { - setData( "tabs", "state", "FetchError" ); - return; - } - else if( m_tabs.size() == 0 ) - { - setData( "tabs", "state", "noTabs" ); - return; - } - else - { - // sort against tabtype - QList < QPair < TabsInfo::TabType, KUrl > > sorting; - foreach( TabsInfo *item, m_tabs ) - sorting << QPair < TabsInfo::TabType, KUrl> ( item->tabType, item->url) ; - qSort(sorting.begin(), sorting.end(), qLess<QPair < TabsInfo::TabType, KUrl> >() ); - - // debug info - foreach( TabsInfo *item, m_tabs ) - debug() << " Title: " << item->title << " (" << item->url << ")"; - - // if the song hasn't change while fetching, we sent the data - if( m_currentTrack != The::engineController()->currentTrack() ) - return; - - // otherwise send the fetched data to the subscribed applets - QList < QPair <TabsInfo::TabType, KUrl > >::iterator i; - int pos = 0; - for(i = sorting.begin(); i != sorting.end(); ++i) - { - foreach( TabsInfo *item, m_tabs) - { - if( (*i).second == item->url ) - { - QVariant var; - var.setValue<TabsInfo *>( item ); - setData( "tabs", QString( "tabs:" ) + QString().setNum( pos ), var ); - pos++; - } - } - } - } -} - -/** - * helper-function for html-parsing - */ -QString -TabsEngine::subStringBetween( const QString &src, const QString &from, const QString &to, - bool lastIndexForFrom ) -{ - int startIdx; - - if( lastIndexForFrom ) - startIdx = src.lastIndexOf( from ); - else - startIdx = src.indexOf( from ); - - if( startIdx == -1 ) - return QString(); - startIdx += from.length(); - - int endIdx = src.indexOf( to, startIdx ); - if( endIdx == -1 ) - return QString(); - - return src.mid( startIdx, endIdx - startIdx ); -} - -/** - * modifications on the artist to get more results - */ -QStringList -TabsEngine::defineArtistSearchCriteria( const QString &artist ) -{ - QStringList artists; - - QString searchArtist = artist.trimmed(); - artists << searchArtist; - - // remove trailing "The" (otherwise no results for 'The Cure', 'The Smashing Pumpkins', ...) - if( searchArtist.startsWith( "The ", Qt::CaseInsensitive ) ) - artists << searchArtist.remove( "The ", Qt::CaseInsensitive ); - - return artists; -} - - -/** - * modifications on the title to get more results - */ -QStringList -TabsEngine::defineTitleSearchCriteria( const QString &title ) -{ - QStringList titles; - - QString searchTitle = title.trimmed(); - titles << searchTitle; - - // remove trailing "The" - if( searchTitle.startsWith( "The ", Qt::CaseInsensitive ) ) - titles << searchTitle.remove( "The ", Qt::CaseInsensitive ); - - // remove anything like (live), (demo-tape), ... - QRegExp regex = QRegExp( "\\s*\\(.*\\)", Qt::CaseInsensitive ); - if( regex.indexIn( searchTitle ) > 0 ) - titles << searchTitle.remove( regex ); - - // remove anything like [xxxx]. - regex = QRegExp( "\\s*\\[.*\\]", Qt::CaseInsensitive ); - if( regex.indexIn( searchTitle ) > 0 ) - titles << searchTitle.remove( regex ); - - return titles; -} - -/** - * checks if a tab-fetch job aborted with an error - * returns true in case of error, false otherwise - */ -bool -TabsEngine::netReplyError( NetworkAccessManagerProxy::Error e ) -{ - // check the access manager network replay - if( e.code == QNetworkReply::NoError ) - { - // at least one job successful, clear list of aborted urls - m_numAbortedUrls = 0; - return false; - } - else - { - // store url, list gets checked in resultFinalize - m_numAbortedUrls++; - resultFinalize(); - return true; - } -} - -#include "moc_TabsEngine.cpp" diff --git a/amarok/src/context/engines/tabs/TabsEngine.h b/amarok/src/context/engines/tabs/TabsEngine.h deleted file mode 100644 index 3772b785..00000000 --- a/amarok/src/context/engines/tabs/TabsEngine.h +++ /dev/null @@ -1,151 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Rainer Sigle <rainer.sigle@web.de> * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see <http://www.gnu.org/licenses/>. * - ****************************************************************************************/ - -#ifndef AMAROK_TABS_ENGINE -#define AMAROK_TABS_ENGINE - -#include "TabsInfo.h" - -#include "context/DataEngine.h" -#include "core/meta/forward_declarations.h" -#include "NetworkAccessManagerProxy.h" - -#include <QVariant> -#include <QSet> - -class KJob; -using namespace Context; - - /** - * This engine provides tab-data for the current song - */ -class TabsEngine : public DataEngine -{ - Q_OBJECT - Q_PROPERTY( QString artistName READ artistName WRITE setArtistName ) - Q_PROPERTY( QString titleName READ titleName WRITE setTitleName ) - Q_PROPERTY( bool fetchGuitarTabs READ fetchGuitar WRITE setFetchGuitar ) - Q_PROPERTY( bool fetchBassTabs READ fetchBass WRITE setFetchBass ) - - public: - TabsEngine( QObject* parent, const QList<QVariant>& args ); - virtual ~TabsEngine(); - - QString artistName() const; - void setArtistName( const QString &artistName ); - - QString titleName() const; - void setTitleName( const QString &titleName ); - - bool fetchGuitar() const; - void setFetchGuitar( const bool fetch ); - - bool fetchBass() const; - void setFetchBass( const bool fetch ); - - QStringList sources() const; - - protected: - bool sourceRequestEvent( const QString &name ); - - private slots: - /** - * handling of tab data search results from ultimateguitar.com - */ - void resultUltimateGuitarSearch( const KUrl &url, QByteArray data, NetworkAccessManagerProxy::Error e ); - void resultUltimateGuitarTab( const KUrl &url, QByteArray data, NetworkAccessManagerProxy::Error e ); - - /** - * This method will send the info to the applet and order them if every jobs are finished - */ - void resultFinalize(); - - /** - * Prepare the calling of the requestTab method. - * Launched when the track played on amarok has changed. - */ - void update(); - - private: - /** - * starts a new tab-search - */ - void requestTab( const QString &artist, const QString &title ); - - /** - * starts a tab search at ultimateguitar.com - */ - void queryUltimateGuitar( const QString &artist, const QString &title ); - - /** - * The currently playing track - */ - Meta::TrackPtr m_currentTrack; - - /** - * Data strucuture which contains all tab-information for - * the current song. After fetching this data will be send to the applet - */ - QList < TabsInfo * > m_tabs; - - /** - * Set containing urls of active jobs - */ - QSet < const KUrl > m_urls; - - /** - * Holds artist and title name of the current track - */ - QString m_titleName; - QString m_artistName; - - /** - * Controls whether guitar-tabs will be fetched - */ - bool m_fetchGuitar; - /** - * Controls whether bass-tabs will be fetched - */ - bool m_fetchBass; - - /** - * Helper function which returns the intermediate string between two strings - */ - QString subStringBetween( const QString &src, const QString &from, const QString &to, - bool lastIndexForFrom = false ); - - /** - * returns a list of possible search criteria for the current artist - */ - QStringList defineArtistSearchCriteria( const QString &artist ); - - /** - * returns a list of possible search criteria for the current title - */ - QStringList defineTitleSearchCriteria( const QString &title ); - - /** - * checks if a tab-fetch job aborted with an error - * returns true in case of error, false otherwise - */ - bool netReplyError( NetworkAccessManagerProxy::Error e ); - int m_numAbortedUrls; -}; - -Q_DECLARE_METATYPE ( TabsInfo * ) -AMAROK_EXPORT_DATAENGINE( tabs, TabsEngine ) - -#endif diff --git a/amarok/src/context/engines/tabs/TabsInfo.h b/amarok/src/context/engines/tabs/TabsInfo.h deleted file mode 100644 index 5591c935..00000000 --- a/amarok/src/context/engines/tabs/TabsInfo.h +++ /dev/null @@ -1,33 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Rainer Sigle <rainer.sigle@web.de> * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see <http://www.gnu.org/licenses/>. * - ****************************************************************************************/ -#ifndef AMAROK_TABS_INFO -#define AMAROK_TABS_INFO - -#include <KUrl> - -// struct TabsInfo contains all the data for a tab -struct TabsInfo -{ - enum TabType { GUITAR, BASS, DRUM, PIANO }; - - QString title; // Name of the specific tab - QString tabs; // Data for the tab - QString source; // origin for the tab - TabType tabType; // TabType for the tab - KUrl url; // Url of the specific tab -}; - -#endif diff --git a/amarok/src/context/engines/tabs/amarok-data-engine-tabs.desktop b/amarok/src/context/engines/tabs/amarok-data-engine-tabs.desktop deleted file mode 100644 index f3a72399..00000000 --- a/amarok/src/context/engines/tabs/amarok-data-engine-tabs.desktop +++ /dev/null @@ -1,52 +0,0 @@ -[Desktop Entry] -Name=Tabs Data Engine -Name[bg]=Ядро за подпрозорци -Name[bs]=Pogon za podatke na karticama -Name[ca]=Motor de dades de pestanyes -Name[ca@valencia]=Motor de dades de pestanyes -Name[cs]=Datový nástroj tabulatur -Name[da]=Datamotor til tabulaturer -Name[de]=Datenmodul für Gitarrengriffe -Name[el]=Μηχανή δεδομένων για παρτιτούρες -Name[en_GB]=Tabs Data Engine -Name[es]=Motor de datos de tablaturas -Name[et]=Tabulatuuri andmemootor -Name[eu]=Fitxetako datuen motorra -Name[fi]=Tabulatuurien tietomoottori -Name[fr]=Moteur de données pour les tablatures -Name[ga]=Inneall Sonraí: Cluaisíní -Name[gl]=Motor de datos de tablaturas -Name[hu]=Tabok adatmodul -Name[id]=Mesin Data Tab -Name[it]=Motore dati delle tablature -Name[ja]=Tabs データエンジン -Name[km]=ម៉ាស៊ីន​ទិន្នន័យ​ផ្ទាំង -Name[lt]=Kortelių duomenų sistema -Name[lv]=Ciļņu datu dzinējs -Name[nb]=Datamotor for tablaturer -Name[nds]=Paneel-Datenkarn -Name[nl]=Tabbladen-gegevensengine -Name[pa]=ਟੈਬ ਡਾਟਾ ਇੰਜਣ -Name[pl]=Silnik danych tabulatur -Name[pt]=Motor de Dados de Tablaturas -Name[pt_BR]=Mecanismo de dados das tablaturas -Name[ru]=Источник данных для табулатур -Name[sk]=Dátový engine kariet -Name[sl]=Podatkovni pogon za zavihke -Name[sr]=Датомотор таблатура -Name[sr@ijekavian]=Датомотор таблатура -Name[sr@ijekavianlatin]=Datomotor tablatura -Name[sr@latin]=Datomotor tablatura -Name[sv]=Datagränssnitt för flikar -Name[tr]=Akor Veri Motoru -Name[uk]=Рушій даних акордів -Name[x-test]=xxTabs Data Enginexx -Name[zh_CN]=吉他谱数据引擎 -Name[zh_TW]=Tabs 資料引擎 -X-KDE-ServiceTypes=Plasma/DataEngine -Type=Service -Icon=Tabs -X-KDE-Library=amarok_data_engine_tabs -X-KDE-PluginInfo-Name=amarok-tabs -X-KDE-ParentApp=Amarok - diff --git a/amarok/src/context/engines/upcomingevents/CMakeLists.txt b/amarok/src/context/engines/upcomingevents/CMakeLists.txt deleted file mode 100644 index 5338e306..00000000 --- a/amarok/src/context/engines/upcomingevents/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -include_directories( ${Amarok_SOURCE_DIR}/src - ${Amarok_SOURCE_DIR}/src/context - ${Amarok_SOURCE_DIR}/src/context/applets/upcomingevents - ${LIBLASTFM_INCLUDE_DIR} - ${LIBLASTFM_INCLUDE_DIR}/.. - ${CMAKE_CURRENT_BINARY_DIR}/../../.. # for amarok_config.h -) - -set( upcomingEvents_engine_SRCS - UpcomingEventsEngine.cpp - ${Amarok_SOURCE_DIR}/src/context/applets/upcomingevents/LastFmEvent.cpp - ${Amarok_SOURCE_DIR}/src/context/applets/upcomingevents/LastFmEventXmlParser.cpp -) - -kde4_add_plugin(amarok_data_engine_upcomingEvents ${upcomingEvents_engine_SRCS}) -target_link_libraries( amarok_data_engine_upcomingEvents amarokcore amaroklib ${KDE4_PLASMA_LIBS} ${KDE4_KIO_LIBS} ${LIBLASTFM_LIBRARY} ) - -install( TARGETS amarok_data_engine_upcomingEvents DESTINATION ${PLUGIN_INSTALL_DIR} ) -install( FILES amarok-data-engine-upcomingEvents.desktop DESTINATION ${SERVICES_INSTALL_DIR} ) diff --git a/amarok/src/context/engines/upcomingevents/UpcomingEventsEngine.cpp b/amarok/src/context/engines/upcomingevents/UpcomingEventsEngine.cpp deleted file mode 100644 index d606d622..00000000 --- a/amarok/src/context/engines/upcomingevents/UpcomingEventsEngine.cpp +++ /dev/null @@ -1,214 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Oleksandr Khayrullin <saniokh@gmail.com> * - * Copyright (c) 2009 Nathan Sala <sala.nathan@gmail.com> * - * Copyright (c) 2009-2010 Ludovic Deveaux <deveaux.ludovic31@gmail.com> * - * Copyright (c) 2010 Hormiere Guillaume <hormiere.guillaume@gmail.com> * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see <http://www.gnu.org/licenses/>. * - ****************************************************************************************/ - -#define DEBUG_PREFIX "UpcomingEventsEngine" - -#include "UpcomingEventsEngine.h" - -#include "context/ContextView.h" -#include "context/applets/upcomingevents/LastFmEventXmlParser.h" -#include "core/meta/Meta.h" -#include "core/support/Amarok.h" -#include "core/support/Debug.h" -#include "EngineController.h" - -#include <KDateTime> - -#include <QtCore/qxmlstream.h> - -AMAROK_EXPORT_DATAENGINE( upcomingEvents, UpcomingEventsEngine ) - -using namespace Context; - -UpcomingEventsEngine::UpcomingEventsEngine( QObject* parent, const QList<QVariant>& /*args*/ ) - : DataEngine( parent ) -{ - m_timeSpan = Amarok::config("UpcomingEvents Applet").readEntry( "timeSpan", "AllEvents" ); - - EngineController *engine = The::engineController(); - - connect( engine, SIGNAL(trackChanged(Meta::TrackPtr)), - this, SLOT(updateDataForArtist()) ); - connect( engine, SIGNAL(trackMetadataChanged(Meta::TrackPtr)), - this, SLOT(updateDataForArtist()) ); -} - -UpcomingEventsEngine::~UpcomingEventsEngine() -{ -} - -bool -UpcomingEventsEngine::sourceRequestEvent( const QString &source ) -{ - if( source == "artistevents" ) - { - updateDataForArtist(); - return false; // data is not ready yet, but will be soon - } - else if( source == "venueevents" ) - { - m_venueIds.clear(); - QStringList venues = Amarok::config("UpcomingEvents Applet").readEntry( "favVenues", QStringList() ); - foreach( const QString &venue, venues ) - { - QStringList frag = venue.split( QChar(';') ); - m_venueIds << frag.at( 0 ).toInt(); - } - updateDataForVenues(); - return true; - } - else if( source == "venueevents:update" ) - { - removeAllData( source ); - sourceRequestEvent( "venueevents" ); - } - else if( source == "timespan:update" ) - { - // user has changed the timespan. - m_timeSpan = Amarok::config("UpcomingEvents Applet").readEntry( "timeSpan", "AllEvents" ); - sourceRequestEvent( "venueevents:update" ); - updateDataForArtist(); - return true; - } - return false; -} - -void -UpcomingEventsEngine::updateDataForVenues() -{ - if( !m_venueIds.isEmpty() ) - { - int id = m_venueIds.takeFirst(); - KUrl url; - url.setScheme( "http" ); - url.setHost( "ws.audioscrobbler.com" ); - url.setPath( "/2.0/" ); - url.addQueryItem( "method", "venue.getEvents" ); - url.addQueryItem( "api_key", Amarok::lastfmApiKey() ); - url.addQueryItem( "venue", QString::number( id ) ); - The::networkAccessManager()->getData( url, this, - SLOT(venueEventsFetched(KUrl,QByteArray,NetworkAccessManagerProxy::Error)) ); - QTimer::singleShot( 50, this, SLOT(updateDataForVenues()) ); - } -} - -void -UpcomingEventsEngine::updateDataForArtist() -{ - Meta::TrackPtr track = The::engineController()->currentTrack(); - if( !track ) - return; - - Meta::ArtistPtr artist = track->artist(); - if( !artist || artist == m_currentArtist || artist->name().isEmpty() ) - return; - - m_currentArtist = artist; - - // Prepares the url for LastFm request - m_urls.clear(); - KUrl url; - url.setScheme( "http" ); - url.setHost( "ws.audioscrobbler.com" ); - url.setPath( "/2.0/" ); - url.addQueryItem( "method", "artist.getEvents" ); - url.addQueryItem( "api_key", Amarok::lastfmApiKey() ); - url.addQueryItem( "artist", m_currentArtist->name() ); - m_urls << url; - The::networkAccessManager()->getData( url, this, - SLOT(artistEventsFetched(KUrl,QByteArray,NetworkAccessManagerProxy::Error)) ); -} - -void -UpcomingEventsEngine::artistEventsFetched( const KUrl &url, QByteArray data, - NetworkAccessManagerProxy::Error e ) -{ - if( !m_urls.contains( url ) ) - return; - - m_urls.remove( url ); - if( e.code != QNetworkReply::NoError ) - { - debug() << "Error received getting upcoming artist events" << e.description; - return; - } - - QXmlStreamReader xml( data ); - LastFmEventXmlParser eventsParser( xml ); - removeAllData( "artistevents" ); - Plasma::DataEngine::Data engineData; - if( eventsParser.read() ) - { - LastFmEvent::List artistEvents = filterEvents( eventsParser.events() ); - engineData[ "artist" ] = m_currentArtist->name(); - engineData[ "events" ] = qVariantFromValue( artistEvents ); - } - setData( "artistevents", engineData ); -} - -void -UpcomingEventsEngine::venueEventsFetched( const KUrl &url, QByteArray data, - NetworkAccessManagerProxy::Error e ) -{ - Q_UNUSED( url ) - if( e.code != QNetworkReply::NoError ) - { - debug() << "Error received getting upcoming venue events" << e.description; - return; - } - - QXmlStreamReader xml( data ); - LastFmEventXmlParser eventsParser( xml ); - Plasma::DataEngine::Data engineData; - if( eventsParser.read() ) - { - LastFmEvent::List venueEvents = filterEvents( eventsParser.events() ); - if( !venueEvents.isEmpty() ) - { - engineData[ "venue" ] = qVariantFromValue( venueEvents.first()->venue() ); - engineData[ "events" ] = qVariantFromValue( venueEvents ); - } - } - setData( "venueevents", engineData ); -} - -LastFmEvent::List -UpcomingEventsEngine::filterEvents( const LastFmEvent::List &events ) const -{ - KDateTime currentTime( KDateTime::currentLocalDateTime() ); - - if( m_timeSpan == "ThisWeek") - currentTime = currentTime.addDays( 7 ); - else if( m_timeSpan == "ThisMonth" ) - currentTime = currentTime.addMonths( 1 ); - else if( m_timeSpan == "ThisYear" ) - currentTime = currentTime.addYears( 1 ); - else - return events; // no filtering is done - - LastFmEvent::List newEvents; - foreach( const LastFmEventPtr &event, events ) - { - if( event->date() < currentTime ) - newEvents << event; - } - return newEvents; -} - -#include "moc_UpcomingEventsEngine.cpp" diff --git a/amarok/src/context/engines/upcomingevents/UpcomingEventsEngine.h b/amarok/src/context/engines/upcomingevents/UpcomingEventsEngine.h deleted file mode 100644 index 6f53a74a..00000000 --- a/amarok/src/context/engines/upcomingevents/UpcomingEventsEngine.h +++ /dev/null @@ -1,111 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Oleksandr Khayrullin <saniokh@gmail.com> * - * Copyright (c) 2009 Nathan Sala <sala.nathan@gmail.com> * - * Copyright (c) 2009-2010 Ludovic Deveaux <deveaux.ludovic31@gmail.com> * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see <http://www.gnu.org/licenses/>. * - ****************************************************************************************/ - -#ifndef AMAROK_UPCOMINGEVENTS_ENGINE -#define AMAROK_UPCOMINGEVENTS_ENGINE - -#include "context/applets/upcomingevents/LastFmEvent.h" -#include "context/DataEngine.h" -#include "core/meta/forward_declarations.h" -#include "network/NetworkAccessManagerProxy.h" - -// Qt -#include <QtXml/qdom.h> -#include <QLocale> -#include <QtCore/qxmlstream.h> -#include <QSet> - -class QNetworkReply; - -using namespace Context; - -/** - * \class UpcomingEventsEngine - * - * This class provide UpcomingEvents data for use in Context applets - */ -class UpcomingEventsEngine : public DataEngine -{ - Q_OBJECT - -public: - /** - * \brief Constructor - * - * Creates a new instance of UpcomingEventsEngine - */ - UpcomingEventsEngine( QObject* parent, const QList<QVariant>& args ); - - /** - * \brief Destructor - * - * Destroys an UpcomingEventsEngine instance - */ - virtual ~UpcomingEventsEngine(); - -protected: - /** - * Reimplemented from Plasma::DataEngine - */ - bool sourceRequestEvent( const QString &name ); - -private: - - /** - * filterEvents filters a list of events depending on settings - * @param events a list of events to filter - * @return a new list of events that satisfies filter settings - */ - LastFmEvent::List filterEvents( const LastFmEvent::List &events ) const; - - /** - * The value can be "AllEvents", "ThisWeek", "ThisMonth" or "ThisYear" - */ - QString m_timeSpan; - - /** - * The current artist - */ - Meta::ArtistPtr m_currentArtist; - - /** - * Current URLs of events being fetched - */ - QSet<KUrl> m_urls; - - /** - * @param ids LastFm's venue ids - */ - QList<int> m_venueIds; - -private slots: - /** - * Get events for specific artist - */ - void updateDataForArtist(); - - /** - * Get events for specific venues - */ - void updateDataForVenues(); - - void artistEventsFetched( const KUrl &url, QByteArray data, NetworkAccessManagerProxy::Error e ); - void venueEventsFetched( const KUrl &url, QByteArray data, NetworkAccessManagerProxy::Error e ); -}; - -#endif diff --git a/amarok/src/context/engines/upcomingevents/amarok-data-engine-upcomingEvents.desktop b/amarok/src/context/engines/upcomingevents/amarok-data-engine-upcomingEvents.desktop deleted file mode 100644 index cec03970..00000000 --- a/amarok/src/context/engines/upcomingevents/amarok-data-engine-upcomingEvents.desktop +++ /dev/null @@ -1,55 +0,0 @@ -[Desktop Entry] -Name=Upcoming Events Data Engine -Name[bg]=Ядро за предстоящи събития -Name[bs]=Pogon podataka predstoјećih događaјa -Name[ca]=Motor de dades de propers esdeveniments -Name[ca@valencia]=Motor de dades de propers esdeveniments -Name[cs]=Datový nástroj nadcházejících událostí -Name[da]=Datamotor til kommende begivenheder -Name[de]=Datenmodul für anstehende Ereignisse -Name[el]=Μηχανή δεδομένων επόμενων εκδηλώσεων -Name[en_GB]=Upcoming Events Data Engine -Name[es]=Motor de datos de próximos eventos -Name[et]=Tulevaste sündmuste andmemootor -Name[eu]=Hurrengo gertaeren datuen motorra -Name[fi]=Tulevien tapahtumien tietomoottori -Name[fr]=Moteur de données pour les évènements à venir -Name[ga]=Inneall Sonraí: Imeachtaí atá ag teacht -Name[gl]=Motor de datos de acontecementos vindeiros -Name[hu]=Közelgő események adatmotorja -Name[id]=Mesin Data Event Mendatang -Name[is]=Gagnavél fyrir væntanlega atburði -Name[it]=Motore dati Prossimi eventi -Name[ja]=近日中のイベントデータエンジン -Name[km]=ម៉ាស៊ីន​ទិន្នន័យ​ព្រឹត្តិការណ៍​ដែល​នឹង​កើត​ឡើង​ -Name[ko]=다가오는 약속 데이터 엔진 -Name[lt]=Artimiausių įvykių duomenų sistema -Name[lv]=Tuvāko notikumu datu dzinis -Name[nb]=Datamotor for kommende hendelser -Name[nds]=Datenkarn för anstahn Begeefnissen -Name[nl]=Gegevensengine voor komende evenementen -Name[pa]=ਆ ਰਹੇ ਈਵੈਂਟ ਡਾਟਾ ਇੰਜਣ -Name[pl]=Silnik danych nadchodzących wydarzeń -Name[pt]=Motor de Dados dos Próximos Eventos -Name[pt_BR]=Mecanismo de dados dos próximos eventos -Name[ro]=Motor de date Evenimente apropiate -Name[ru]=Источник данных о предстоящих событиях -Name[sk]=Dátový engine nových udalostí -Name[sl]=Podatkovni pogon za prihajajoče dogodke -Name[sr]=Датомотор предстојећих догађаја -Name[sr@ijekavian]=Датомотор предстојећих догађаја -Name[sr@ijekavianlatin]=Datomotor predstojećih događaja -Name[sr@latin]=Datomotor predstojećih događaja -Name[sv]=Datagränssnitt för kommande händelser -Name[tr]=Gelecek Etkinlikler Veri Motoru -Name[uk]=Рушій розкладу найближчих подій -Name[x-test]=xxUpcoming Events Data Enginexx -Name[zh_CN]=近期事件数据引擎 -Name[zh_TW]=即將來臨的事件資料引擎 -X-KDE-ServiceTypes=Plasma/DataEngine -Type=Service -Icon=amarok -X-KDE-Library=amarok_data_engine_upcomingEvents -X-KDE-PluginInfo-Name=amarok-upcomingEvents -X-KDE-ParentApp=Amarok - diff --git a/amarok/src/context/engines/wikipedia/CMakeLists.txt b/amarok/src/context/engines/wikipedia/CMakeLists.txt deleted file mode 100644 index 54e2783a..00000000 --- a/amarok/src/context/engines/wikipedia/CMakeLists.txt +++ /dev/null @@ -1,15 +0,0 @@ -include_directories( ../../.. - ${PROJECT_SOURCE_DIR}/src/context - ${PROJECT_SOURCE_DIR}/src/network - ${CMAKE_CURRENT_BINARY_DIR}/../../.. # for amarok_config.h -) - -set( wikipedia_engine_SRCS - WikipediaEngine.cpp -) - -kde4_add_plugin(amarok_data_engine_wikipedia ${wikipedia_engine_SRCS}) -target_link_libraries( amarok_data_engine_wikipedia amarokcore amaroklib ${KDE4_PLASMA_LIBS} ${KDE4_KIO_LIBS} ) - -install( TARGETS amarok_data_engine_wikipedia DESTINATION ${PLUGIN_INSTALL_DIR} ) -install( FILES amarok-data-engine-wikipedia.desktop DESTINATION ${SERVICES_INSTALL_DIR} ) diff --git a/amarok/src/context/engines/wikipedia/WikipediaEngine.cpp b/amarok/src/context/engines/wikipedia/WikipediaEngine.cpp deleted file mode 100644 index 4aeea4a1..00000000 --- a/amarok/src/context/engines/wikipedia/WikipediaEngine.cpp +++ /dev/null @@ -1,964 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Ryan McCoskrie <ryan.mccoskrie@gmail.com * - * Copyright (c) 2007 Leo Franchi <lfranchi@gmail.com> * - * Copyright (c) 2008 Mark Kretschmann <kretschmann@kde.org> * - * Copyright (c) 2009 Simon Esneault <simon.esneault@gmail.com> * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see <http://www.gnu.org/licenses/>. * - ****************************************************************************************/ - -#define DEBUG_PREFIX "WikipediaEngine" - -#include "WikipediaEngine.h" - -#include "EngineController.h" -#include "core/meta/Meta.h" -#include "core/meta/support/MetaConstants.h" -#include "core/support/Amarok.h" -#include "core/support/Debug.h" - -#include <Plasma/DataContainer> - -#include <QtCore/qhash.h> -#include <QtCore/qxmlstream.h> - -using namespace Context; - -class WikipediaEnginePrivate -{ -private: - WikipediaEngine *const q_ptr; - Q_DECLARE_PUBLIC( WikipediaEngine ) - -public: - WikipediaEnginePrivate( WikipediaEngine *parent ) - : q_ptr( parent ) - , currentSelection( Artist ) - , useMobileVersion( false ) - , useSSL( true ) - , dataContainer( 0 ) - {} - ~WikipediaEnginePrivate() {} - - enum SelectionType - { - Artist, - Composer, - Album, - Track - }; - - // functions - void fetchWikiUrl( const QString &title, const QString &urlPrefix ); - void fetchLangLinks( const QString &title, const QString &hostLang, const QString &llcontinue = QString() ); - void fetchListing( const QString &title, const QString &hostLang ); - void reloadWikipedia(); - bool setSelection( SelectionType type ); // returns true if selection is changed - bool setSelection( const QString &type ); - SelectionType selection() const; - void updateEngine(); - void wikiParse( QString &page ); - QString createLanguageComboBox( const QMap<QString, QString> &languageMap ); - - // data members - SelectionType currentSelection; - QUrl wikiCurrentUrl; - QStringList preferredLangs; - struct TrackMetadata - { - QString artist; - QString composer; - QString album; - QString track; - void clear() - { - artist.clear(); - composer.clear(); - album.clear(); - track.clear(); - } - } m_previousTrackMetadata; - bool useMobileVersion; - bool useSSL; - - Plasma::DataContainer *dataContainer; - - QSet< QUrl > urls; - - // private slots - void _checkRequireUpdate( Meta::TrackPtr track ); - void _dataContainerUpdated( const QString &source, const Plasma::DataEngine::Data &data ); - void _parseLangLinksResult( const KUrl &url, QByteArray data, NetworkAccessManagerProxy::Error e ); - void _parseListingResult( const KUrl &url, QByteArray data, NetworkAccessManagerProxy::Error e ); - void _wikiResult( const KUrl &url, QByteArray result, NetworkAccessManagerProxy::Error e ); - void _stopped(); -}; - -void -WikipediaEnginePrivate::_dataContainerUpdated( const QString &source, const Plasma::DataEngine::Data &data ) -{ - DEBUG_BLOCK - Q_Q( WikipediaEngine ); - - if( source != QLatin1String("wikipedia") ) - return; - - if( data.isEmpty() ) - { - debug() << "data is empty"; - return; - } - - if( data.contains( QLatin1String("reload") ) ) - { - if( data.value( QLatin1String("reload") ).toBool() ) - { - debug() << QLatin1String("reloading"); - reloadWikipedia(); - } - q->removeData( source, QLatin1String("reload") ); - } - - if( data.contains( QLatin1String("goto") ) ) - { - QString gotoType = data.value( QLatin1String("goto") ).toString(); - debug() << "goto:" << gotoType; - if( !gotoType.isEmpty() ) - { - setSelection( gotoType ); - q->setData( source, QLatin1String("busy"), true ); - updateEngine(); - } - q->removeData( source, QLatin1String("goto") ); - } - - if( data.contains( QLatin1String("clickUrl") ) ) - { - QUrl clickUrl = data.value( QLatin1String("clickUrl") ).toUrl(); - debug() << "clickUrl:" << clickUrl; - if( clickUrl.isValid() ) - { - wikiCurrentUrl = clickUrl; - if( !wikiCurrentUrl.hasQueryItem( QLatin1String("useskin") ) ) - wikiCurrentUrl.addQueryItem( QLatin1String("useskin"), QLatin1String("monobook") ); - KUrl encodedUrl( wikiCurrentUrl.toEncoded() ); - urls << encodedUrl; - q->setData( source, QLatin1String("busy"), true ); - The::networkAccessManager()->getData( encodedUrl, q, - SLOT(_wikiResult(KUrl,QByteArray,NetworkAccessManagerProxy::Error)) ); - } - q->removeData( source, QLatin1String("clickUrl") ); - } - - if( data.contains( QLatin1String("mobile") ) ) - { - bool mobile = data.value( QLatin1String("mobile") ).toBool(); - if( mobile != useMobileVersion ) - { - debug() << (mobile ? "switching to mobile wikipedia" : "switching to normal wikipedia"); - useMobileVersion = mobile; - updateEngine(); - } - } - - if( data.contains( QLatin1String("ssl") ) ) - { - const bool ssl = data.value( QLatin1String("ssl") ).toBool(); - if( ssl != useSSL ) - { - useSSL = ssl; - updateEngine(); - } - } - - if( data.contains( QLatin1String("lang") ) ) - { - QStringList langList = data.value( QLatin1String("lang") ).toStringList(); - if( !langList.isEmpty() && (preferredLangs != langList) ) - { - preferredLangs = langList; - updateEngine(); - debug() << QLatin1String("updated preferred wikipedia languages:") << preferredLangs; - } - q->removeData( source, QLatin1String("lang") ); - } -} - -void -WikipediaEnginePrivate::_wikiResult( const KUrl &url, QByteArray result, NetworkAccessManagerProxy::Error e ) -{ - Q_Q( WikipediaEngine ); - if( !urls.contains( url ) ) - return; - - urls.remove( url ); - if( e.code != QNetworkReply::NoError ) - { - q->removeAllData( QLatin1String("wikipedia") ); - q->setData( QLatin1String("wikipedia"), QLatin1String("message"), - i18n("Unable to retrieve Wikipedia information: %1", e.description) ); - q->scheduleSourcesUpdated(); - return; - } - - debug() << "Received page from wikipedia:" << url; - QString wiki( result ); - - // FIXME: For now we test if we got an article or not with a test on this string "wgArticleId=0" - // This is bad - if( wiki.contains(QLatin1String("wgArticleId=0")) && - (wiki.contains(QLatin1String("wgNamespaceNumber=0")) || - wiki.contains(QLatin1String("wgPageName=\"Special:Badtitle\"")) ) ) // The article does not exist - { - debug() << "article does not exist"; - q->removeAllData( QLatin1String("wikipedia") ); - q->setData( QLatin1String("wikipedia"), QLatin1String("message"), i18n( "No information found..." ) ); - q->scheduleSourcesUpdated(); - return; - } - - // We've found a page - DataEngine::Data data; - wikiParse( wiki ); - data[QLatin1String("page")] = wiki; - data[QLatin1String("url")] = QUrl(url); - q->removeData( QLatin1String("wikipedia"), QLatin1String("busy") ); - - Meta::TrackPtr currentTrack = The::engineController()->currentTrack(); - if( !currentTrack ) - return; - - if( currentSelection == Artist ) // default, or applet told us to fetch artist - { - if( currentTrack && currentTrack->artist() ) - { - data[QLatin1String("label")] = QLatin1String("Artist"); - data[QLatin1String("title")] = currentTrack->artist()->prettyName(); - } - } - else if( currentSelection == Composer ) - { - data[QLatin1String("label")] = QLatin1String("Title"); - data[QLatin1String("title")] = currentTrack->composer()->prettyName(); - } - else if( currentSelection == Track ) - { - data[QLatin1String("label")] = QLatin1String("Title"); - data[QLatin1String("title")] = currentTrack->prettyName(); - } - else if( currentSelection == Album ) - { - if( currentTrack && currentTrack->album() ) - { - data[QLatin1String("label")] = QLatin1String("Album"); - data[QLatin1String("title")] = currentTrack->album()->prettyName(); - } - } - q->setData( QLatin1String("wikipedia"), data ); - q->scheduleSourcesUpdated(); -} - -void -WikipediaEnginePrivate::_parseLangLinksResult( const KUrl &url, QByteArray data, - NetworkAccessManagerProxy::Error e ) -{ - Q_Q( WikipediaEngine ); - if( !urls.contains( url ) ) - return; - - urls.remove( url ); - if( e.code != QNetworkReply::NoError || data.isEmpty() ) - { - debug() << "Parsing langlinks result failed" << e.description; - q->removeAllData( QLatin1String("wikipedia") ); - q->setData( QLatin1String("wikipedia"), QLatin1String("message"), - i18n("Unable to retrieve Wikipedia information: %1", e.description) ); - q->scheduleSourcesUpdated(); - return; - } - - QString hostLang = url.host(); - hostLang.remove( QLatin1String(".wikipedia.org") ); - const QString &title = url.queryItemValue( QLatin1String("titles") ); - - QHash<QString, QString> langTitleMap; // a hash of langlinks and their titles - QString llcontinue; - QXmlStreamReader xml( data ); - while( !xml.atEnd() && !xml.hasError() ) - { - xml.readNext(); - if( xml.isStartElement() && xml.name() == QLatin1String("page") ) - { - if( xml.attributes().hasAttribute(QLatin1String("missing")) ) - break; - - QXmlStreamAttributes a = xml.attributes(); - if( a.hasAttribute(QLatin1String("pageid")) && a.hasAttribute(QLatin1String("title")) ) - { - const QString &pageTitle = a.value( QLatin1String("title") ).toString(); - if( pageTitle.endsWith(QLatin1String("(disambiguation)")) ) - { - fetchListing( title, hostLang ); - return; - } - langTitleMap[hostLang] = title; - } - - while( !xml.atEnd() ) - { - xml.readNext(); - if( xml.isEndElement() && xml.name() == QLatin1String("page") ) - break; - - if( xml.isStartElement() ) - { - if( xml.name() == QLatin1String("ll") ) - { - QXmlStreamAttributes a = xml.attributes(); - if( a.hasAttribute(QLatin1String("lang")) ) - { - QString lang = a.value( QLatin1String("lang") ).toString(); - langTitleMap[lang] = xml.readElementText(); - } - } - else if( xml.name() == QLatin1String("query-continue") ) - { - xml.readNext(); - if( xml.isStartElement() && xml.name() == QLatin1String("langlinks") ) - { - QXmlStreamAttributes a = xml.attributes(); - if( a.hasAttribute(QLatin1String("llcontinue")) ) - llcontinue = a.value( QLatin1String("llcontinue") ).toString(); - } - } - } - } - } - } - - if( !langTitleMap.isEmpty() ) - { - /* When we query langlinks using a particular language, interwiki - * results will not contain links for that language. However, it may - * appear as part of the "page" element if there's a match or a redirect - * has been set. So we need to manually add it here if it's still empty. */ - if( preferredLangs.contains(hostLang) && !langTitleMap.contains(hostLang) ) - langTitleMap[hostLang] = title; - - q->removeData( QLatin1String("wikipedia"), QLatin1String("busy") ); - QStringListIterator langIter( preferredLangs ); - while( langIter.hasNext() ) - { - QString prefix = langIter.next().split( QLatin1Char(':') ).back(); - if( langTitleMap.contains(prefix) ) - { - QString pageTitle = langTitleMap.value( prefix ); - fetchListing( pageTitle, prefix ); - return; - } - } - } - - if( !llcontinue.isEmpty() ) - { - fetchLangLinks( title, hostLang, llcontinue ); - } - else - { - QRegExp regex( QLatin1Char('^') + hostLang + QLatin1String(".*$") ); - int index = preferredLangs.indexOf( regex ); - if( (index != -1) && (index < preferredLangs.count() - 1) ) - { - // use next preferred language as base for fetching langlinks since - // the current one did not get any results we want. - QString prefix = preferredLangs.value( index + 1 ).split( QLatin1Char(':') ).back(); - fetchLangLinks( title, prefix ); - } - else - { - QStringList refinePossibleLangs = preferredLangs.filter( QRegExp("^(en|fr|de|pl).*$") ); - if( refinePossibleLangs.isEmpty() ) - { - q->removeAllData( QLatin1String("wikipedia") ); - q->setData( QLatin1String("wikipedia"), QLatin1String("message"), - i18n( "No information found..." ) ); - q->scheduleSourcesUpdated(); - return; - } - fetchListing( title, refinePossibleLangs.first().split( QLatin1Char(':') ).back() ); - } - } -} - -void -WikipediaEnginePrivate::_parseListingResult( const KUrl &url, - QByteArray data, - NetworkAccessManagerProxy::Error e ) -{ - Q_Q( WikipediaEngine ); - if( !urls.contains( url ) ) - return; - - urls.remove( url ); - if( e.code != QNetworkReply::NoError || data.isEmpty() ) - { - debug() << "Parsing listing result failed" << e.description; - q->removeAllData( QLatin1String("wikipedia") ); - q->setData( QLatin1String("wikipedia"), QLatin1String("message"), - i18n("Unable to retrieve Wikipedia information: %1", e.description) ); - q->scheduleSourcesUpdated(); - return; - } - - QString hostLang = url.host(); - hostLang.remove( QLatin1String(".wikipedia.org") ); - const QString &title = url.queryItemValue( QLatin1String("srsearch") ); - - QStringList titles; - QXmlStreamReader xml( data ); - while( !xml.atEnd() && !xml.hasError() ) - { - xml.readNext(); - if( xml.isStartElement() && xml.name() == QLatin1String("search") ) - { - while( xml.readNextStartElement() ) - { - if( xml.name() == QLatin1String("p") ) - { - if( xml.attributes().hasAttribute( QLatin1String("title") ) ) - titles << xml.attributes().value( QLatin1String("title") ).toString(); - xml.skipCurrentElement(); - } - else xml.skipCurrentElement(); - } - } - } - - if( titles.isEmpty() ) - { - QStringList refinePossibleLangs = preferredLangs.filter( QRegExp("^(en|fr|de|pl).*$") ); - int index = refinePossibleLangs.indexOf( hostLang ); - if( (index != -1) && (index < refinePossibleLangs.count() - 1) ) - fetchListing( title, refinePossibleLangs.value( index + 1 ).split( QLatin1Char(':') ).back() ); - else - { - q->removeAllData( QLatin1String("wikipedia") ); - q->setData( QLatin1String("wikipedia"), QLatin1String("message"), i18n( "No information found..." ) ); - } - return; - } - - QString pattern; - switch( currentSelection ) - { - default: - case Artist: - pattern = i18nc("Search pattern for an artist or band", ".*\\(.*(artist|band).*\\))").toLatin1(); - break; - case Composer: - pattern = i18nc("Search pattern for a composer", ".*\\(.*(composer|musician).*\\))").toLatin1(); - break; - case Album: - pattern = i18nc("Search pattern for an album", ".*\\(.*(album|score|soundtrack).*\\)").toLatin1(); - break; - - case Track: - pattern = i18nc("Search pattern for a song", ".*\\(.*(song|track).*\\)").toLatin1(); - break; - } - - pattern.prepend( title ); - int patternIndex = titles.indexOf( QRegExp(pattern, Qt::CaseInsensitive) ); - const QString result = ( patternIndex != -1 ) ? titles.at( patternIndex ) : titles.first(); - fetchWikiUrl( result, hostLang ); // end of the line -} - -void -WikipediaEnginePrivate::_checkRequireUpdate( Meta::TrackPtr track ) -{ - if( !track ) - return; - - bool updateNeeded(false); - - switch( currentSelection ) - { - case WikipediaEnginePrivate::Artist: - if( track->artist() ) - updateNeeded = track->artist()->name() != m_previousTrackMetadata.artist; - break; - case WikipediaEnginePrivate::Composer: - if( track->composer() ) - updateNeeded = track->composer()->name() != m_previousTrackMetadata.composer; - break; - case WikipediaEnginePrivate::Album: - if( track->album() ) - updateNeeded = track->album()->name() != m_previousTrackMetadata.album; - break; - - case WikipediaEnginePrivate::Track: - updateNeeded = track->name() != m_previousTrackMetadata.track; - break; - } - - if( updateNeeded ) - { - m_previousTrackMetadata.clear(); - if( track->artist() ) - m_previousTrackMetadata.artist = track->artist()->name(); - if( track->composer() ) - m_previousTrackMetadata.composer = track->composer()->name(); - if( track->album() ) - m_previousTrackMetadata.album = track->album()->name(); - m_previousTrackMetadata.track = track->name(); - - urls.clear(); - updateEngine(); - } -} - -void -WikipediaEnginePrivate::_stopped() -{ - DEBUG_BLOCK - Q_Q( WikipediaEngine ); - dataContainer->removeAllData(); - dataContainer->setData( "stopped", 1 ); - q->scheduleSourcesUpdated(); - m_previousTrackMetadata.clear(); -} - -void -WikipediaEnginePrivate::fetchWikiUrl( const QString &title, const QString &urlPrefix ) -{ - Q_Q( WikipediaEngine ); - KUrl pageUrl; - QString host( ".wikipedia.org" ); - pageUrl.setScheme( useSSL ? QLatin1String( "https" ) : QLatin1String( "http" ) ); - - if( useMobileVersion ) - { - host.prepend( ".m" ); - host.prepend( urlPrefix ); - pageUrl.setHost( host ); - pageUrl.setPath( QString("/wiki/%1").arg(title) ); - DataEngine::Data data; - data[QLatin1String("sourceUrl")] = pageUrl; - q->removeAllData( QLatin1String("wikipedia") ); - q->setData( QLatin1String("wikipedia"), data ); - q->scheduleSourcesUpdated(); - return; - } - - // We now use: http://en.wikipedia.org/w/index.php?title=The_Beatles&useskin=monobook - // instead of: http://en.wikipedia.org/wiki/The_Beatles - // So that wikipedia skin is forced to default "monoskin", and the page can be parsed correctly (see BUG 205901 ) - host.prepend( urlPrefix ); - pageUrl.setHost( host ); - pageUrl.setPath( QLatin1String("/w/index.php") ); - pageUrl.addQueryItem( QLatin1String("title"), title ); - pageUrl.addQueryItem( QLatin1String("redirects"), QString::number(1) ); - pageUrl.addQueryItem( QLatin1String("useskin"), QLatin1String("monobook") ); - wikiCurrentUrl = pageUrl; - urls << pageUrl; - The::networkAccessManager()->getData( pageUrl, q, - SLOT(_wikiResult(KUrl,QByteArray,NetworkAccessManagerProxy::Error)) ); -} - -void -WikipediaEnginePrivate::fetchLangLinks( const QString &title, - const QString &hostLang, - const QString &llcontinue ) -{ - Q_Q( WikipediaEngine ); - KUrl url; - url.setScheme( useSSL ? QLatin1String( "https" ) : QLatin1String( "http" ) ); - url.setHost( hostLang + QLatin1String(".wikipedia.org") ); - url.setPath( QLatin1String("/w/api.php") ); - url.addQueryItem( QLatin1String("action"), QLatin1String("query") ); - url.addQueryItem( QLatin1String("prop"), QLatin1String("langlinks") ); - url.addQueryItem( QLatin1String("titles"), title ); - url.addQueryItem( QLatin1String("format"), QLatin1String("xml") ); - url.addQueryItem( QLatin1String("lllimit"), QString::number(100) ); - url.addQueryItem( QLatin1String("redirects"), QString::number(1) ); - if( !llcontinue.isEmpty() ) - url.addQueryItem( QLatin1String("llcontinue"), llcontinue ); - urls << url; - debug() << "Fetching langlinks:" << url; - The::networkAccessManager()->getData( url, q, - SLOT(_parseLangLinksResult(KUrl,QByteArray,NetworkAccessManagerProxy::Error)) ); -} - -void -WikipediaEnginePrivate::fetchListing( const QString &title, const QString &hostLang ) -{ - Q_Q( WikipediaEngine ); - KUrl url; - url.setScheme( useSSL ? QLatin1String( "https" ) : QLatin1String( "http" ) ); - url.setHost( hostLang + QLatin1String(".wikipedia.org") ); - url.setPath( QLatin1String("/w/api.php") ); - url.addQueryItem( QLatin1String("action"), QLatin1String("query") ); - url.addQueryItem( QLatin1String("list"), QLatin1String("search") ); - url.addQueryItem( QLatin1String("srsearch"), title ); - url.addQueryItem( QLatin1String("srprop"), QLatin1String("size") ); - url.addQueryItem( QLatin1String("srredirects"), QString::number(1) ); - url.addQueryItem( QLatin1String("srlimit"), QString::number(20) ); - url.addQueryItem( QLatin1String("format"), QLatin1String("xml") ); - urls << url; - debug() << "Fetching listing:" << url; - The::networkAccessManager()->getData( url, q, - SLOT(_parseListingResult(KUrl,QByteArray,NetworkAccessManagerProxy::Error)) ); -} - -void -WikipediaEnginePrivate::updateEngine() -{ - static QMap<SelectionType, qint64> typeToFieldMap; - if( typeToFieldMap.isEmpty() ) - { - typeToFieldMap.insert( Artist, Meta::valArtist ); - typeToFieldMap.insert( Composer, Meta::valComposer ); - typeToFieldMap.insert( Album, Meta::valAlbum ); - typeToFieldMap.insert( Track, Meta::valTitle ); - } - - Q_Q( WikipediaEngine ); - - Meta::TrackPtr currentTrack = The::engineController()->currentTrack(); - if( !currentTrack ) - return; - - //TODO: Look into writing one function that can be used with different arguments for each case in this switch. - QString tmpWikiStr; - QString notice = i18nc( "%1 is field name such as 'Artist Name'", - "%1 is needed for searching Wikipedia.", - Meta::i18nForField( typeToFieldMap.value( currentSelection ) ) ); - switch( currentSelection ) - { - case Artist: - if( currentTrack->artist() ) - { - if( currentTrack->artist()->name().isEmpty() ) - { - q->removeAllData( QLatin1String("wikipedia") ); - q->scheduleSourcesUpdated(); - q->setData( QLatin1String("wikipedia"), QLatin1String("message"), - notice ); - return; - } - if( ( currentTrack->playableUrl().protocol() == QLatin1String("lastfm") ) || - ( currentTrack->playableUrl().protocol() == QLatin1String("daap") ) || - !The::engineController()->isStream() ) - tmpWikiStr = currentTrack->artist()->name(); - else - tmpWikiStr = currentTrack->artist()->prettyName(); - } - break; - - case Composer: - if( currentTrack->composer() ) - { - if( currentTrack->composer()->name().isEmpty() ) - { - q->removeAllData( QLatin1String("wikipedia") ); - q->scheduleSourcesUpdated(); - q->setData( QLatin1String("wikipedia"), QLatin1String("message"), - notice ); - return; - } - if( ( currentTrack->playableUrl().protocol() == QLatin1String("lastfm") ) || - ( currentTrack->playableUrl().protocol() == QLatin1String("daap") ) || - !The::engineController()->isStream() ) - tmpWikiStr = currentTrack->composer()->name(); - } - break; - case Album: - if( currentTrack->album() ) - { - if( currentTrack->album()->name().isEmpty() ) - { - q->removeAllData( QLatin1String("wikipedia") ); - q->scheduleSourcesUpdated(); - q->setData( QLatin1String("wikipedia"), QLatin1String("message"), - notice ); - return; - } - if( ( currentTrack->playableUrl().protocol() == QLatin1String("lastfm") ) || - ( currentTrack->playableUrl().protocol() == QLatin1String("daap") ) || - !The::engineController()->isStream() ) - tmpWikiStr = currentTrack->album()->name(); - - } - break; - - case Track: - if( currentTrack->name().isEmpty() ) - { - q->removeAllData( QLatin1String("wikipedia") ); - q->scheduleSourcesUpdated(); - q->setData( QLatin1String("wikipedia"), QLatin1String("message"), - notice ); - return; - } - tmpWikiStr = currentTrack->prettyName(); - break; - } - - //Hack to make wiki searches work with magnatune preview tracks - if( tmpWikiStr.contains( QLatin1String("PREVIEW: buy it at www.magnatune.com") ) ) - { - tmpWikiStr = tmpWikiStr.remove(QLatin1String(" (PREVIEW: buy it at www.magnatune.com)") ); - int index = tmpWikiStr.indexOf( QLatin1Char('-') ); - if( index != -1 ) - tmpWikiStr = tmpWikiStr.left (index - 1); - } - - if( preferredLangs.isEmpty() ) - preferredLangs = QStringList() << QLatin1String("en:en"); - - fetchLangLinks( tmpWikiStr, preferredLangs.first().split( QLatin1Char(':') ).back() ); -} - -void -WikipediaEnginePrivate::wikiParse( QString &wiki ) -{ - //remove the new-lines and tabs(replace with spaces IS needed). - wiki.replace( '\n', QLatin1Char(' ') ); - wiki.replace( '\t', QLatin1Char(' ') ); - - // Get the available language list - QString wikiLanguagesSection; - QMap<QString, QString> langMap; - int langSectionIndex = 0; - if( (langSectionIndex = wiki.indexOf( QLatin1String("<div id=\"p-lang\" class=\"portlet\">") )) != -1 ) - { - QStringRef sref = wiki.midRef( langSectionIndex ); - sref = wiki.midRef( sref.position(), wiki.indexOf( QLatin1String("<ul>"), sref.position() ) - sref.position() ); - sref = wiki.midRef( sref.position(), wiki.indexOf( QLatin1String("</dev>"), sref.position() ) - sref.position() ); - wikiLanguagesSection = sref.toString(); - QXmlStreamReader xml( wikiLanguagesSection ); - while( !xml.atEnd() && !xml.hasError() ) - { - xml.readNext(); - if( xml.isStartElement() && xml.name() == QLatin1String("li") ) - { - while( xml.readNextStartElement() ) - { - if( xml.name() == QLatin1String("a") ) - { - QString url = xml.attributes().value( QLatin1String("href") ).toString(); - langMap[ xml.readElementText() ] = url; - } - else xml.skipCurrentElement(); - } - } - } - } - - QString copyright; - const QString copyrightMark = QLatin1String("<li id=\"f-copyright\">"); - int copyrightIndex = wiki.indexOf( copyrightMark ); - if( copyrightIndex != -1 ) - { - QStringRef sref = wiki.midRef( copyrightIndex + copyrightMark.length() ); - sref = wiki.midRef( sref.position(), wiki.indexOf( QLatin1String("</li>"), sref.position() ) - sref.position() ); - copyright = sref.toString(); - copyright.remove( QLatin1String("<br />") ); - //only one br at the beginning - copyright.prepend( QLatin1String("<br />") ); - } - - const int titleIndex = wiki.indexOf( QRegExp( QLatin1String("<title>[^<]*") ) ) + 7; - const int bsTitleIndex = wiki.indexOf( QLatin1String(""), titleIndex ) - titleIndex; - const QString title = wiki.mid( titleIndex, bsTitleIndex ); - - // Ok lets remove the top and bottom parts of the page - QStringRef wikiRef; - wikiRef = wiki.midRef( wiki.indexOf( QLatin1String("") ) ); - wikiRef = wiki.midRef( wikiRef.position(), wiki.indexOf( QLatin1String("
"), wikiRef.position() ) - wikiRef.position() ); - wiki = wikiRef.toString(); - - auto removeTag = [&wiki] ( const QString& tagStart, const QString& tagEnd ) - { - const int tagEndSize = tagEnd.size(); - int matchIndex = 0; - const QStringMatcher tagMatcher( tagStart ); - while( ( matchIndex = tagMatcher.indexIn( wiki, matchIndex ) ) != -1 ) - { - const int nToTagEnd = wiki.indexOf( tagEnd, matchIndex ) - matchIndex; - const QStringRef tagRef = wiki.midRef( matchIndex, nToTagEnd + tagEndSize ); - wiki.remove( tagRef.toString() ); - } - }; - - // lets remove the warning box - removeTag( "" ); - // remove protection policy (we don't do edits) - removeTag( "
" ); - // lets also remove the "lock" image - removeTag( "" ); - // remove
") ); - wiki.remove( QRegExp( QLatin1String("

[^<]*

") ) ); - - wiki.remove( QRegExp( QLatin1String("]*>[^<]*<[^>]*>[^<]*<[^>]*>[^<]*") ) ); - wiki.remove( QRegExp( QLatin1String("

]*><[^\"]*\"#_skip_noteTA\">[^<]*<[^<]*

") ) ); - - wiki.replace( QRegExp( QLatin1String("
]*>([^<]*)") ), QLatin1String("\\1") ); - - // Remove anything inside of a class called urlexpansion, as it's pointless for us - wiki.remove( QRegExp( QLatin1String("[^(]*[(][^)]*[)]") ) ); - - // Remove hidden table rows as well - QRegExp hidden( QLatin1String("
.*"), Qt::CaseInsensitive ); - hidden.setMinimal( true ); //greedy behaviour wouldn't be any good! - wiki.remove( hidden ); - - // we want to keep our own style (we need to modify the stylesheet a bit to handle things nicely) - wiki.remove( QRegExp( QLatin1String("style= *\"[^\"]*\"") ) ); - // We need to leave the classes behind, otherwise styling it ourselves gets really nasty and tedious and roughly impossible to do in a sane maner - //wiki.replace( QRegExp( "class= *\"[^\"]*\"" ), QString() ); - // let's remove the form elements, we don't want them. - wiki.remove( QRegExp( QLatin1String("]*>") ) ); - wiki.remove( QRegExp( QLatin1String("]*>") ) ); - wiki.remove( QLatin1String("\n") ); - wiki.remove( QRegExp( QLatin1String("]*>") ) ); - wiki.remove( QLatin1String("\n") ); - wiki.remove( QRegExp( QLatin1String("]*>") ) ); - wiki.remove( QLatin1String("") ); - - wiki.prepend( QLatin1String("\n") ); - wiki.append( QString(QLatin1String("%1\n")).arg(title) ); - wiki.append( QLatin1String("\n") ); - // wiki.append( createLanguageComboBox(langMap) ); // BUG:259075 - wiki.append( QLatin1String("\n") ); -} - -QString -WikipediaEnginePrivate::createLanguageComboBox( const QMap &languageMap ) -{ - if( languageMap.isEmpty() ) - return QString(); - - QString html; - QMapIterator i(languageMap); - while( i.hasNext() ) - { - i.next(); - html += QString( "" ).arg( i.value(), i.key() ); - } - html.prepend( QString("
") ); - return html; -} - -void -WikipediaEnginePrivate::reloadWikipedia() -{ - Q_Q( WikipediaEngine ); - if( !wikiCurrentUrl.isValid() ) - return; - urls << wikiCurrentUrl; - q->setData( QLatin1String("wikipedia"), QLatin1String("busy"), true ); - q->scheduleSourcesUpdated(); - The::networkAccessManager()->getData( wikiCurrentUrl, q, - SLOT(_wikiResult(KUrl,QByteArray,NetworkAccessManagerProxy::Error)) ); -} - -WikipediaEnginePrivate::SelectionType -WikipediaEnginePrivate::selection() const -{ - return currentSelection; -} - -bool -WikipediaEnginePrivate::setSelection( SelectionType type ) -{ - if( currentSelection != type ) - { - currentSelection = type; - return true; - } - return false; -} - -bool -WikipediaEnginePrivate::setSelection( const QString &type ) -{ - bool changed( false ); - if( type == QLatin1String("artist") ) - changed = setSelection( Artist ); - else if( type == QLatin1String("composer") ) - changed = setSelection( Composer ); - else if( type == QLatin1String("album") ) - changed = setSelection( Album ); - else if( type == QLatin1String("track") ) - changed = setSelection( Track ); - return changed; -} - -WikipediaEngine::WikipediaEngine( QObject* parent, const QList& /*args*/ ) - : DataEngine( parent ) - , d_ptr( new WikipediaEnginePrivate( this ) ) -{ - -} - -WikipediaEngine::~WikipediaEngine() -{ - delete d_ptr; -} - -void -WikipediaEngine::init() -{ - Q_D( WikipediaEngine ); - d->dataContainer = new Plasma::DataContainer( this ); - d->dataContainer->setObjectName( QLatin1String("wikipedia") ); - addSource( d->dataContainer ); - connect( d->dataContainer, SIGNAL(dataUpdated(QString,Plasma::DataEngine::Data)), - this, SLOT(_dataContainerUpdated(QString,Plasma::DataEngine::Data)) ); - - EngineController *engine = The::engineController(); - - connect( engine, SIGNAL(trackChanged(Meta::TrackPtr)), - this, SLOT(_checkRequireUpdate(Meta::TrackPtr)) ); - connect( engine, SIGNAL(trackMetadataChanged(Meta::TrackPtr)), - this, SLOT(_checkRequireUpdate(Meta::TrackPtr)) ); - connect( engine, SIGNAL(stopped(qint64,qint64)), - this, SLOT(_stopped()) ); -} - -bool -WikipediaEngine::sourceRequestEvent( const QString &source ) -{ - if( source == QLatin1String("update") ) - { - scheduleSourcesUpdated(); - } - else if( source == QLatin1String("wikipedia") ) - { - Q_D( WikipediaEngine ); - d->updateEngine(); - return true; - } - return false; -} - -#include "moc_WikipediaEngine.cpp" diff --git a/amarok/src/context/engines/wikipedia/WikipediaEngine.h b/amarok/src/context/engines/wikipedia/WikipediaEngine.h deleted file mode 100644 index 2a18c0b1..00000000 --- a/amarok/src/context/engines/wikipedia/WikipediaEngine.h +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Leo Franchi * - * Copyright (c) 2008 Mark Kretschmann * - * Copyright (c) 2009 Simon Esneault * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_WIKIPEDIA_ENGINE -#define AMAROK_WIKIPEDIA_ENGINE - -#include "core/meta/forward_declarations.h" -#include "context/DataEngine.h" -#include "NetworkAccessManagerProxy.h" - -/** - This class provide Wikipedia data for use in Context applets. - -NOTE: The QVariant data is structured like this: - * the key name is the artist - * the data is a QString containing the html of the wikipedia page -*/ - -using namespace Context; -namespace Plasma -{ - class DataContainer; -} -class WikipediaEnginePrivate; - -class WikipediaEngine : public DataEngine -{ - Q_OBJECT - -public: - WikipediaEngine( QObject* parent, const QList& args ); - virtual ~WikipediaEngine(); - - virtual void init(); - -protected: - bool sourceRequestEvent( const QString &source ); - -private: - WikipediaEnginePrivate *const d_ptr; - Q_DECLARE_PRIVATE( WikipediaEngine ) - - Q_PRIVATE_SLOT( d_ptr, void _checkRequireUpdate(Meta::TrackPtr) ) - Q_PRIVATE_SLOT( d_ptr, void _dataContainerUpdated(const QString&,const Plasma::DataEngine::Data&) ) - Q_PRIVATE_SLOT( d_ptr, void _wikiResult(const KUrl&,QByteArray,NetworkAccessManagerProxy::Error) ) - Q_PRIVATE_SLOT( d_ptr, void _parseLangLinksResult(const KUrl&,QByteArray,NetworkAccessManagerProxy::Error) ) - Q_PRIVATE_SLOT( d_ptr, void _parseListingResult(const KUrl&,QByteArray,NetworkAccessManagerProxy::Error) ) - Q_PRIVATE_SLOT( d_ptr, void _stopped() ) -}; - -AMAROK_EXPORT_DATAENGINE( wikipedia, WikipediaEngine ) - -#endif - diff --git a/amarok/src/context/engines/wikipedia/amarok-data-engine-wikipedia.desktop b/amarok/src/context/engines/wikipedia/amarok-data-engine-wikipedia.desktop deleted file mode 100644 index f275180a..00000000 --- a/amarok/src/context/engines/wikipedia/amarok-data-engine-wikipedia.desktop +++ /dev/null @@ -1,62 +0,0 @@ -[Desktop Entry] -Name=Wikipedia Data Engine -Name[bg]=Ядро за Уикипедия -Name[bs]=Pogon podataka Wikipediјe -Name[ca]=Motor de dades de la Viquipèdia -Name[ca@valencia]=Motor de dades de la Viquipèdia -Name[cs]=Datový nástroj Wikipedia -Name[csb]=Mòtór pòdôwków z Wikipedijë -Name[da]=Datamotor til Wikipedia -Name[de]=Datenmodul für die Wikipedia-Erweiterung -Name[el]=Μηχανή δεδομένων Wikipedia -Name[en_GB]=Wikipedia Data Engine -Name[eo]=Datuma motoro de Vikipedio -Name[es]=Motor de datos de Wikipedia -Name[et]=Wikipedia andmemootor -Name[eu]=Wikipediako datuen motorra -Name[fi]=Wikipedian tietomoottori -Name[fr]=Moteur de données pour Wikipédia -Name[ga]=Inneall Sonraí: An Vicipéid -Name[gl]=Motor de dados da wikipedia -Name[hne]=विकिपीडिया डाटा इंजिन -Name[hu]=Wikipedia-adatmotor -Name[id]=Mesin Data Wikipedia -Name[is]=Wikipedia gagnavél -Name[it]=Motore dati di Wikipedia -Name[ja]=Wikipedia データエンジン -Name[km]=ម៉ាស៊ីន​ទិន្នន័យ​វីគីភីឌៀ -Name[ko]=위키백과 데이터 엔진 -Name[ku]=Motora Dane ya Wikipedia -Name[lt]=Vikipedijos duomenų sistema -Name[lv]=Wikipēdijas datu dzinējs -Name[nb]=Datamotor for Wikipedia -Name[nds]=Wikipedia-Datenkarn -Name[nl]=Wikipedia-gegevensengine -Name[nn]=Datamotor for Wikipedia -Name[pa]=ਵਿਕਿਪੀਡਿਆ ਡਾਟਾ ਇੰਜਣ -Name[pl]=Moduł danych Wikipedii -Name[pt]=Motor de Dados do Wikipédia -Name[pt_BR]=Mecanismo de dados da Wikipédia -Name[ro]=Motor de date Wikipedia -Name[ru]=Источник данных Википедии -Name[sk]=Dátový nástroj Wikipedia -Name[sl]=Podatkovni pogon za Wikipedijo -Name[sr]=Датомотор Википедије -Name[sr@ijekavian]=Датомотор Википедије -Name[sr@ijekavianlatin]=Datomotor Wikipedije -Name[sr@latin]=Datomotor Wikipedije -Name[sv]=Datagränssnitt för Wikipedia -Name[th]=กลไกข้อมูลของวิกิพีเดีย -Name[tr]=Vikipedi Veri Motoru -Name[uk]=Рушій даних Вікіпедії -Name[wa]=Éndjin d' dinêyes Wikipedia -Name[x-test]=xxWikipedia Data Enginexx -Name[zh_CN]=维基百科数据引擎 -Name[zh_TW]=維基百科資料引擎 -X-KDE-ServiceTypes=Plasma/DataEngine -Type=Service -Icon=wikipedia -X-KDE-Library=amarok_data_engine_wikipedia -X-KDE-PluginInfo-Name=amarok-wikipedia -X-KDE-ParentApp=Amarok - diff --git a/amarok/src/context/popupdropper/COPYING b/amarok/src/context/popupdropper/COPYING deleted file mode 100644 index c9757972..00000000 --- a/amarok/src/context/popupdropper/COPYING +++ /dev/null @@ -1,340 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program 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 2 of the License, or - (at your option) any later version. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. diff --git a/amarok/src/context/popupdropper/LICENSE b/amarok/src/context/popupdropper/LICENSE deleted file mode 100644 index 419d64f8..00000000 --- a/amarok/src/context/popupdropper/LICENSE +++ /dev/null @@ -1,24 +0,0 @@ -See individual files for any license information specific to that file. In its absense, the following holds: - -/*************************************************************************** - * Copyright (c) 2008 Jeff Mitchell * - * * - * This program 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 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -See the COPYING file for a copy of the GPLv2 license. - -The author reserves the right to change the license terms at any point, although they will always be under the terms of a free software license. diff --git a/amarok/src/context/popupdropper/README b/amarok/src/context/popupdropper/README deleted file mode 100644 index f3bbacee..00000000 --- a/amarok/src/context/popupdropper/README +++ /dev/null @@ -1,12 +0,0 @@ -Please see the LICENSE file for important license information. - -This is the PopupDropper, or PUD. It is a Qt4-only library that can be added to almost any Qt4.4+ program to provide a neat drag 'n drop feature: when a drag is started, an overlay appears (runs on top of any QWidget) with sections that the dragged items can be dropped onto for various actions. Both drop and hover actions are supported. It is very highly customizable. - -The library name is pud. - -The first usage of the PUD is in the amazing Amarok project version 2.0 ( http://amarok.kde.org ), and it provides an excellent way to see many of the capabilities of the library, as well as how it can be integrated (both code and functionality-wise) into your own project. Another good and very simple way is to build the modified Qt drag 'n drop robot example in the testapp directory, and play around in there. - -There is no official release of the PUD code yet, and neither binary nor API compatibility is guaranteed. It is a good idea to give the author a buzz at mitchell@kde.org and let him know if you are using it, so that he can keep you informed of any major changes. - -Doxygen comments are in the works -- I promise. - diff --git a/amarok/src/context/popupdropper/libpud/CMakeLists.txt b/amarok/src/context/popupdropper/libpud/CMakeLists.txt deleted file mode 100644 index 11fb5d5f..00000000 --- a/amarok/src/context/popupdropper/libpud/CMakeLists.txt +++ /dev/null @@ -1,42 +0,0 @@ - -set(CMAKE_INCLUDE_CURRENT_DIR ON) -INCLUDE_DIRECTORIES( - ${CMAKE_CURRENT_BINARY_DIR}/popupdropper - ${CMAKE_CURRENT_BINARY_DIR}/.. - ${QT_INCLUDES} -) - -########### next target ############### - -SET(pud_LIB_SRCS - PopupDropper.cpp - PopupDropperItem.cpp - PopupDropperView.cpp -) - -QT4_AUTOMOC( - PopupDropper.cpp - PopupDropperItem.cpp - PopupDropperView.cpp -) - - -ADD_LIBRARY(pud SHARED ${pud_LIB_SRCS}) - -TARGET_LINK_LIBRARIES(pud ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTSVG_LIBRARY}) - -SET_TARGET_PROPERTIES(pud PROPERTIES - VERSION - ${POPUPDROPPER_LIB_MAJOR_VERSION}.${POPUPDROPPER_LIB_MINOR_VERSION}.${POPUPDROPPER_LIB_PATCH_VERSION} - SOVERSION ${POPUPDROPPER_LIB_MAJOR_VERSION} - INSTALL_NAME_DIR ${LIB_INSTALL_DIR} -) -INSTALL(TARGETS pud - LIBRARY DESTINATION ${LIB_INSTALL_DIR} - RUNTIME DESTINATION bin - ARCHIVE DESTINATION ${LIB_INSTALL_DIR} -) - -INSTALL( FILES PopupDropper.h PopupDropperItem.h - PopupDropperView.h PopupDropper_Export.h DESTINATION - ${INCLUDE_INSTALL_DIR}/popupdropper COMPONENT Devel) diff --git a/amarok/src/context/popupdropper/libpud/PopupDropper.cpp b/amarok/src/context/popupdropper/libpud/PopupDropper.cpp deleted file mode 100644 index c134b506..00000000 --- a/amarok/src/context/popupdropper/libpud/PopupDropper.cpp +++ /dev/null @@ -1,983 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2008 Jeff Mitchell * - * * - * This program 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 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#include "PopupDropper.h" -#include "PopupDropper_p.h" -#include "PopupDropperItem.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -PopupDropperPrivate::PopupDropperPrivate( PopupDropper* parent, bool sa, QWidget* widget ) - : QObject( parent ) - , standalone( sa ) - , widget( widget ) - , scene( 0 ) - , view( 0 ) - , fade( PopupDropper::FadeInOut ) - , fadeHideTimer() - , fadeShowTimer() - , fadeInTime( 800 ) - , fadeOutTime( 300 ) - , deleteTimer() - , deleteTimeout( 1000 ) - , frameMax( 30 ) - , windowColor( 0, 0, 0, 64 ) - , windowBackgroundBrush() - , baseTextColor( Qt::white ) - , hoveredTextColor( Qt::blue ) - , hoveredBorderPen() - , hoveredFillBrush() - , file() - , sharedRenderer( 0 ) - , horizontalOffset( 30 ) - , pdiItems() - , overlayLevel( 1 ) - , entered( false ) - , submenuMap() - , submenu( false ) - , allItems() - , quitOnDragLeave( false ) - , onTop( true ) - , widgetRect() - , queuedHide( false ) - , q( parent ) -{ - if( widget ) - widgetRect = widget->rect(); - windowBackgroundBrush.setColor( windowColor ); - hoveredBorderPen.setColor( Qt::blue ); - hoveredBorderPen.setWidth( 2 ); - hoveredBorderPen.setStyle( Qt::SolidLine ); - QColor hoveredFillColor = QColor( Qt::blue ); - hoveredFillColor.setAlpha( 32 ); - hoveredFillBrush.setColor( hoveredFillColor ); - hoveredFillBrush.setStyle( Qt::SolidPattern ); - scene = new QGraphicsScene( ( sa ? 0 : parent ) ); - view = new PopupDropperView( parent, scene, ( sa ? 0 : widget ) ); - //qDebug() << "on create, view size = " << view->size(); - deleteTimer.setSingleShot( true ); - fadeHideTimer.setDirection( QTimeLine::Backward ); - connect( &fadeHideTimer, SIGNAL(frameChanged(int)), this, SLOT(fadeHideTimerFrameChanged(int)) ); - connect( &fadeShowTimer, SIGNAL(frameChanged(int)), this, SLOT(fadeShowTimerFrameChanged(int)) ); - connect( &fadeHideTimer, SIGNAL(finished()), this, SLOT(fadeHideTimerFinished()) ); - connect( &fadeShowTimer, SIGNAL(finished()), this, SLOT(fadeShowTimerFinished()) ); - connect( &deleteTimer, SIGNAL(timeout()), this, SLOT(deleteTimerFinished()) ); -} - -PopupDropperPrivate::~PopupDropperPrivate() -{ -} - -void PopupDropperPrivate::newSceneView( PopupDropper* pud ) -{ - scene->deleteLater(); - scene = new QGraphicsScene( pud ); - //qDebug() << "new scene width in newSceneView = " << scene->width(); - view = new PopupDropperView( pud, scene, widget ); - //qDebug() << "on create, view size = " << view->size(); -} - -void PopupDropperPrivate::setParent( QObject* parent ) -{ - QObject::setParent( parent ); - q = static_cast( parent ); -} - -void PopupDropperPrivate::fadeHideTimerFrameChanged( int frame ) //SLOT -{ - if( fadeHideTimer.state() == QTimeLine::Running ) - { - qreal val = ( frame * 1.0 ) / frameMax; - QColor color = windowColor; - int alpha = (int)( color.alpha() * val ); - color.setAlpha( alpha ); - q->setPalette( color ); - foreach( PopupDropperItem* pdi, pdiItems ) - pdi->setSubitemOpacity( val ); - } -} - -void PopupDropperPrivate::fadeShowTimerFrameChanged( int frame ) //SLOT -{ - if( fadeShowTimer.state() == QTimeLine::Running ) - { - qreal val = ( frame * 1.0 ) / frameMax; - QColor color = windowColor; - int alpha = (int)( color.alpha() * val ); - color.setAlpha( alpha ); - q->setPalette( color ); - foreach( PopupDropperItem* pdi, pdiItems ) - pdi->setSubitemOpacity( val ); - } -} - -void PopupDropperPrivate::fadeHideTimerFinished() //SLOT -{ - view->hide(); - //qDebug() << "Emitting fadeHideFinished in d pointer " << this; - emit q->fadeHideFinished(); -} - -void PopupDropperPrivate::fadeShowTimerFinished() //SLOT -{ - q->setPalette( windowColor ); - queuedHide = false; - foreach( PopupDropperItem* pdi, pdiItems ) - pdi->setSubitemOpacity( 1.0 ); -} - -void PopupDropperPrivate::dragEntered() -{ - //qDebug() << "PopupDropperPrivate::dragEntered"; - q->updateAllOverlays(); -} - -void PopupDropperPrivate::dragLeft() -{ - //qDebug() << "PopupDropperPrivate::dragLeft()"; - //qDebug() << "PUD to be hidden or not hidden = " << q; - if( view->entered() && quitOnDragLeave ) - { - view->setAcceptDrops( false ); - //qDebug() << "View entered, hiding"; - connect( q, SIGNAL(fadeHideFinished()), q, SLOT(subtractOverlay()) ); - q->hide(); - } - q->updateAllOverlays(); -} - -void PopupDropperPrivate::startDeleteTimer() -{ - if( deleteTimeout == 0 ) - return; - view->setEntered( false ); - //qDebug() << "Starting delete timer"; - deleteTimer.start( deleteTimeout ); -} - -void PopupDropperPrivate::deleteTimerFinished() //SLOT -{ - //qDebug() << "Delete Timer Finished"; - if( !view->entered() && quitOnDragLeave ) - { - connect( q, SIGNAL(fadeHideFinished()), q, SLOT(subtractOverlay()) ); - q->hide(); - } -} - -void PopupDropperPrivate::reposItems() -{ - qreal partitionsize, my_min, my_max; - //qDebug() << "allItems.size() = " << allItems.size(); - int counter = 0; - for( int i = 0; i < allItems.size(); i++ ) - { - //qDebug() << "item " << i; - int verticalmargin = 5; - partitionsize = scene->height() / pdiItems.size(); //gives partition size...now center in this area - my_min = ( counter * partitionsize ) + verticalmargin; - my_max = ( ( counter + 1 ) * partitionsize ) - verticalmargin; - //qDebug() << "my_min = " << my_min << ", my_max = " << my_max; - PopupDropperItem* pItem = dynamic_cast( allItems.at( i ) ); - QGraphicsLineItem* qglItem = 0; - if( pItem ) - { - pItem->setPopupDropper( q ); //safety - //qDebug() << "item " << i << " is a PDI "; - //If the svgElementRect is too high, resize it to fit - pItem->svgElementRect().setHeight( my_max - my_min - ( 2 * verticalmargin ) ); - pItem->setPos( 0, my_min ); - pItem->borderRectItem()->setRect( 0 - pItem->borderWidth(), 0, scene->width() + 2*pItem->borderWidth(), my_max - my_min ); - pItem->scaleAndReposSvgItem(); - pItem->reposTextItem(); - pItem->reposHoverFillRects(); - pItem->update(); - //qDebug() << "size of view frame = " << view->size(); - ++counter; - } - else if( ( qglItem = dynamic_cast( allItems.at( i ) ) ) ) - { - //qDebug() << "item " << i << " is a QGLI"; - qglItem->setLine( horizontalOffset, (my_max-partitionsize), scene->width() - horizontalOffset, (my_max-partitionsize) ); - } - } -} - -bool PopupDropperPrivate::amIOnTop( PopupDropperView* pdv ) -{ - if( onTop && pdv == view ) - return true; - return false; -} - -////////////////////////////////////////////////////////////// - -PopupDropper::PopupDropper( QWidget *parent, bool standalone ) - : QObject( parent ) - , d( new PopupDropperPrivate( this, standalone, parent ) ) -{ - if( !parent ) - { - parent = d->view; - d->widget = parent; - } - QObject::setParent( parent ); - initOverlay( parent ); - setColors( d->windowColor, d->baseTextColor, d->hoveredTextColor, d->hoveredBorderPen.color(), d->hoveredFillBrush.color() ); - d->sharedRenderer = new QSvgRenderer( this ); - d->overlayLevel = 1; - //qDebug() << "Popup Dropper created!"; -} - -PopupDropper::~PopupDropper() -{ - //qDebug() << "Popup Dropper destroyed!"; -} - -int PopupDropper::overlayLevel() const -{ - return d->overlayLevel; -} - -void PopupDropper::initOverlay( QWidget* parent, PopupDropperPrivate* priv ) -{ - PopupDropperPrivate *pdp = priv ? priv : d; - //qDebug() << "PUD Overlay being created, d pointer is " << d; - pdp->scene->setSceneRect( QRectF( parent->rect() ) ); - //qDebug() << "Scene width = " << pdp->scene->width(); - pdp->scene->setItemIndexMethod( QGraphicsScene::NoIndex ); - pdp->view->setFixedSize( parent->size() ); - pdp->view->setLineWidth( 0 ); - pdp->view->setFrameStyle( QFrame::NoFrame ); - pdp->view->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); - pdp->view->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); - pdp->view->setBackgroundRole( QPalette::Window ); - pdp->view->setAutoFillBackground( true ); - pdp->fadeHideTimer.setFrameRange( 0, pdp->frameMax ); - pdp->fadeHideTimer.setUpdateInterval( 20 ); // 50 fps - pdp->fadeShowTimer.setFrameRange( 0, pdp->frameMax ); - pdp->fadeShowTimer.setUpdateInterval( 20 ); // 50 fps -} - -void PopupDropper::addOverlay() -{ - d->onTop = false; - m_viewStack.push( d ); - PopupDropperPrivate* old_d = d; - d = new PopupDropperPrivate( this, false, old_d->view ); - d->sharedRenderer = old_d->sharedRenderer; - //qDebug() << "Adding overlay: "; - initOverlay( old_d->view ); - setColors( d->windowColor, d->baseTextColor, d->hoveredTextColor, d->hoveredBorderPen.color(), d->hoveredFillBrush.color() ); - d->quitOnDragLeave = true; - d->overlayLevel = old_d->overlayLevel + 1; - old_d->view->deactivateHover(); -} - -//note: Used when activating a submenu; does not set default colors, should have done that when creating submenu -void PopupDropper::addOverlay( PopupDropperPrivate* newD ) -{ - d->onTop = false; - //qDebug() << "right before push, m_viewStack.size() is " << m_viewStack.size(); - m_viewStack.push( d ); - //qDebug() << "right after push, m_viewStack.size() is " << m_viewStack.size(); - PopupDropperPrivate* old_d = d; - d = newD; - d->onTop = true; - d->sharedRenderer = old_d->sharedRenderer; - d->quitOnDragLeave = true; - d->overlayLevel = old_d->overlayLevel + 1; - //qDebug() << "new d d->overlayLevel = " << d->overlayLevel; - //qDebug() << "in PopupDropper " << this; -} - -//NOTE: just like you have to show the overlay when adding, this function does not hide the overlay; you must do that yourself -//with hide() (which will hide just one level) -bool PopupDropper::subtractOverlay() -{ - //qDebug() << "subtractOverlay, with d pointer " << d; - disconnect( this, SLOT(subtractOverlay()) ); - while( !isHidden() && d->fadeHideTimer.state() == QTimeLine::Running ) - { - //qDebug() << "singleshotting subtractOverlay"; - QTimer::singleShot( 0, this, SLOT(subtractOverlay()) ); - return false; - } - //qDebug() << "in PopupDropper " << this; - //qDebug() << "overlay d->overlayLevel = " << d->overlayLevel; - if( d->overlayLevel == 1 ) - return false; - PopupDropper::Fading currFadeValue = d->fade; - d->fade = PopupDropper::NoFade; - d->onTop = false; - PopupDropperPrivate* old_d = d; - //qDebug() << "right before pop, m_viewStack.size() is " << m_viewStack.size(); - d = m_viewStack.pop(); - d->onTop = true; - if( !old_d->submenu ) - { - //qDebug() << "not submenu, deleting"; - old_d->deleteLater(); - } - else - { - foreach( QGraphicsItem* item, old_d->pdiItems ) - old_d->scene->removeItem( item ); - //qDebug() << "not deleting, submenu"; - old_d->fade = currFadeValue; - old_d->view->resetView(); - } - d->startDeleteTimer(); - return true; -} - -PopupDropperItem* PopupDropper::addSubmenu( PopupDropper** pd, const QString &text ) -{ - //qDebug() << "addSubmenu, this is " << this << " and passed-in PopupDropper is " << (*pd); - if( !(*pd) ) - { - qWarning() << "Did not pass in a valid PUD!"; - return 0; - } - PopupDropperPrivate* newD = (*pd)->d; - newD->submenu = true; - newD->widget = d->widget; - newD->setParent( this ); - foreach( PopupDropperItem* item, newD->pdiItems ) - newD->scene->removeItem( item ); - newD->newSceneView( this ); - initOverlay( d->widget, newD ); - PopupDropperItem* pdi = new PopupDropperItem(); - - QAction* action = new QAction( text, this ); - - connect( action, SIGNAL(hovered()), this, SLOT(activateSubmenu()) ); - pdi->setAction( action ); - pdi->setSubmenuTrigger( true ); - pdi->setHoverIndicatorShowStyle( PopupDropperItem::OnHover ); - d->submenuMap[action] = newD; - delete (*pd); - (*pd) = 0; - foreach( PopupDropperItem* item, newD->pdiItems ) - item->setPopupDropper( this ); - //qDebug() << "d->submenuMap[pda] = " << d->submenuMap[pda]; - addItem( pdi ); - return pdi; -} - -void PopupDropper::activateSubmenu() -{ - //qDebug() << "Sender is " << QObject::sender(); - if( isHidden() || d->fadeHideTimer.state() == QTimeLine::Running ) - return; - PopupDropperPrivate* oldd = d; - addOverlay( d->submenuMap[static_cast(QObject::sender())] ); - //qDebug() << "d->pdiItems.size() = " << d->pdiItems.size() << " for " << d; - foreach( PopupDropperItem* item, d->pdiItems ) - addItem( item, false, false ); - oldd->view->deactivateHover(); - show(); -} - -bool PopupDropper::addMenu( const QMenu *menu ) -{ - Q_UNUSED(menu) - if( !menu ) - return false; - - if( menu->actions().size() == 0 ) - return true; - - PopupDropperItem *pdi = 0; - foreach( QAction *action, menu->actions() ) - { - if( !action->menu() ) - { - pdi = new PopupDropperItem(); - pdi->setAction( action ); - addItem( pdi ); - } - else - { - PopupDropper *pd = new PopupDropper( 0 ); - bool success = pd->addMenu( action->menu() ); - if( success ) - pdi = addSubmenu( &pd, action->text() ); - } - pdi = 0; - } - - return true; -} - -bool PopupDropper::standalone() const -{ - return d->standalone; -} - -void PopupDropper::show() -{ - if( !d->sharedRenderer ) - { - //qDebug() << "No shared renderer set!"; - return; - } - if( d->widget && d->widget->rect() != d->widgetRect ) - { - d->widgetRect = d->widget->rect(); - d->scene->setSceneRect( d->widget->rect() ); - d->view->setFixedSize( d->widget->size() ); - update(); - } - //qDebug() << "Showing PopupDropper"; - d->fadeShowTimer.stop(); - if( ( d->fade == PopupDropper::FadeIn || d->fade == PopupDropper::FadeInOut ) && d->fadeInTime > 0 ) - { - //qDebug() << "Animating!"; - d->fadeShowTimer.setDuration( d->fadeInTime ); - d->fadeShowTimer.setCurrentTime( 0 ); - d->fadeShowTimer.setCurveShape( QTimeLine::EaseOutCurve ); - QColor color = d->windowColor; - color.setAlpha( 0 ); - setPalette( color ); - foreach( PopupDropperItem* pdi, d->pdiItems ) - pdi->setSubitemOpacity( 0.0 ); - d->fadeShowTimer.start(); - //qDebug() << "Timer started"; - } - d->view->show(); -} - -void PopupDropper::showAllOverlays() -{ - show(); - for( int i = m_viewStack.size() - 1; i >= 0; --i ) - { - PopupDropperPrivate* pdi = m_viewStack.at( i ); - if( pdi != d ) - d->view->show(); - } -} - -//returns immediately! -void PopupDropper::hide() -{ - //qDebug() << "PopupDropper::hide entered, d pointer is = " << d; - - //if hide is called and the view is already hidden, it's likely spurious - if( isHidden() ) - { - //qDebug() << "ishidden, returning"; - return; - } - - //queuedHide is to make sure that fadeShowTimerFinished executes before this next hide() - if( d->fadeShowTimer.state() == QTimeLine::Running ) - { - //qDebug() << "show timer running, queueing hide"; - d->fadeShowTimer.stop(); - d->queuedHide = true; - QTimer::singleShot( 0, d, SLOT(fadeShowTimerFinished()) ); - QTimer::singleShot( 0, this, SLOT(hide()) ); - return; - } - - //queuedHide will be set to false from fadeShowTimerFinished...so if this came up first, - //then wait - if( d->fadeHideTimer.state() == QTimeLine::Running || d->queuedHide ) - { - //qDebug() << "hide timer running or queued hide"; - QTimer::singleShot( 0, this, SLOT(hide()) ); - return; - } - - if( ( d->fade == PopupDropper::FadeOut || d->fade == PopupDropper::FadeInOut ) && d->fadeOutTime > 0 ) - { - //qDebug() << "Starting fade out"; - d->fadeHideTimer.setDuration( d->fadeOutTime ); - d->fadeHideTimer.setCurveShape( QTimeLine::LinearCurve ); - d->fadeHideTimer.start(); - //qDebug() << "Timer started"; - return; - } - else //time is zero, or no fade - { - //qDebug() << "time is zero, or no fade"; - QTimer::singleShot( 0, d, SLOT(fadeHideTimerFinished()) ); - return; - } -} - -void PopupDropper::hideAllOverlays() -{ - //qDebug() << "Entered hideAllOverlays"; - connect( this, SIGNAL(fadeHideFinished()), this, SLOT(slotHideAllOverlays()) ); - hide(); - //qDebug() << "Leaving hideAllOverlays"; -} - -void PopupDropper::slotHideAllOverlays() -{ - //qDebug() << "Entered slotHideAllOverlays()"; - disconnect( this, SIGNAL(fadeHideFinished()), this, SLOT(slotHideAllOverlays()) ); - //qDebug() << "m_viewStack.size() = " << m_viewStack.size(); - for( int i = m_viewStack.size() - 1; i >= 0; --i ) - { - PopupDropperPrivate* pdp = m_viewStack.at( i ); - //qDebug() << "checking pdp = " << (QObject*)pdp << ", d is " << (QObject*)d; - if( pdp != d ) - pdp->view->hide(); - } - //qDebug() << "Leaving slotHideAllOverlays"; -} - -void PopupDropper::update() -{ - d->reposItems(); - d->view->update(); -} - -void PopupDropper::updateAllOverlays() -{ - for( int i = m_viewStack.size() - 1; i >= 0; --i ) - { - PopupDropperPrivate* pdp = m_viewStack.at( i ); - pdp->view->update(); - } - d->view->update(); -} - -bool PopupDropper::isHidden() const -{ - return d->view->isHidden(); -} - -void PopupDropper::clear() -{ - while( !isHidden() && d->fadeHideTimer.state() == QTimeLine::Running ) - { - QTimer::singleShot(0, this, SLOT(clear()) ); - return; - } - //qDebug() << "Clear happening!"; - disconnect( this, SLOT(clear()) ); - do - { - foreach( QGraphicsItem* item, d->allItems ) - { - if( dynamic_cast(item) ) - { - if( dynamic_cast(item)->isSubmenuTrigger() ) - { - //qDebug() << "Disconnecting action"; - disconnect( dynamic_cast(item)->action(), SIGNAL(hovered()), this, SLOT(activateSubmenu()) ); - } - dynamic_cast(item)->deleteLater(); - } - else - delete item; - } - d->pdiItems.clear(); - d->allItems.clear(); - //qDebug() << "Size of pdiItems is now " << d->pdiItems.size(); - //qDebug() << "Size of allItems is now " << d->allItems.size(); - d->view->hide(); - d->view->resetView(); - } while ( subtractOverlay() ); -} - -bool PopupDropper::isEmpty( bool allItems ) const -{ - if( allItems ) - return d->allItems.empty(); - else - return d->pdiItems.empty(); -} - -bool PopupDropper::quitOnDragLeave() const -{ - return d->quitOnDragLeave; -} - -void PopupDropper::setQuitOnDragLeave( bool quit ) -{ - d->quitOnDragLeave = quit; -} - -int PopupDropper::fadeInTime() const -{ - return d->fadeInTime; -} - -void PopupDropper::setFadeInTime( const int msecs ) -{ - d->fadeInTime = msecs; -} - -int PopupDropper::fadeOutTime() const -{ - return d->fadeOutTime; -} - -void PopupDropper::setFadeOutTime( const int msecs ) -{ - d->fadeOutTime = msecs; -} - -PopupDropper::Fading PopupDropper::fading() const -{ - return d->fade; -} - -void PopupDropper::setFading( PopupDropper::Fading fade ) -{ - d->fade = fade; -} - -const QTimeLine* PopupDropper::fadeHideTimer() const -{ - return &d->fadeHideTimer; -} - -const QTimeLine* PopupDropper::fadeShowTimer() const -{ - return &d->fadeShowTimer; -} - -int PopupDropper::deleteTimeout() const -{ - return d->deleteTimeout; -} - -void PopupDropper::setDeleteTimeout( int msecs ) -{ - d->deleteTimeout = msecs; -} - -QColor PopupDropper::windowColor() const -{ - return d->windowColor; -} - -void PopupDropper::setWindowColor( const QColor &window ) -{ - d->windowColor = window; - setPalette( window ); -} - -QBrush PopupDropper::windowBackgroundBrush() const -{ - return d->windowBackgroundBrush; -} - -void PopupDropper::setWindowBackgroundBrush( const QBrush &window ) -{ - d->windowBackgroundBrush = window; - d->view->setBackgroundBrush( window ); -} - -QColor PopupDropper::baseTextColor() const -{ - return d->baseTextColor; -} - -void PopupDropper::setBaseTextColor( const QColor &text ) -{ - d->baseTextColor = text; - foreach( PopupDropperItem *item, d->pdiItems ) - item->setBaseTextColor( text ); -} - -QColor PopupDropper::hoveredTextColor() const -{ - return d->hoveredTextColor; -} - -void PopupDropper::setHoveredTextColor( const QColor &text ) -{ - d->hoveredTextColor = text; - foreach( PopupDropperItem *item, d->pdiItems ) - item->setHoveredTextColor( text ); -} - -QPen PopupDropper::hoveredBorderPen() const -{ - return d->hoveredBorderPen; -} - -void PopupDropper::setHoveredBorderPen( const QPen &border ) -{ - d->hoveredBorderPen = border; - foreach( PopupDropperItem *item, d->pdiItems ) - item->setHoveredBorderPen( border ); -} - -QBrush PopupDropper::hoveredFillBrush() const -{ - return d->hoveredFillBrush; -} - -void PopupDropper::setHoveredFillBrush( const QBrush &fill ) -{ - d->hoveredFillBrush = fill; - foreach( PopupDropperItem *item, d->pdiItems ) - item->setHoveredFillBrush( fill ); -} - -void PopupDropper::setColors( const QColor &window, const QColor &baseText, const QColor &hoveredText, const QColor &hoveredBorder, const QColor &hoveredFill ) -{ - d->windowColor = window; - d->baseTextColor = baseText; - d->hoveredTextColor = hoveredText; - d->hoveredBorderPen.setColor( hoveredBorder ); - d->hoveredFillBrush.setColor( hoveredFill ); - setPalette( window, baseText, hoveredText, hoveredBorder, hoveredFill ); -} - -void PopupDropper::setPalette( const QColor &window ) -{ - QPalette p = d->view->palette(); - p.setColor( QPalette::Window, window ); - d->view->setPalette( p ); - updateAllOverlays(); -} - -void PopupDropper::setPalette( const QColor &window, const QColor &baseText, const QColor &hoveredText, const QColor &hoveredBorder, const QColor &hoveredFill ) -{ - QPalette p = d->view->palette(); - p.setColor( QPalette::Window, window ); - d->view->setPalette( p ); - QPen pen; - QBrush brush; - foreach( PopupDropperItem *item, d->pdiItems ) - { - item->setBaseTextColor( baseText ); - item->setHoveredTextColor( hoveredText ); - pen = item->hoveredBorderPen(); - pen.setColor( hoveredBorder ); - item->setHoveredBorderPen( pen ); - brush = item->hoveredFillBrush(); - brush.setColor( hoveredFill ); - item->setHoveredFillBrush( brush ); - } - updateAllOverlays(); -} - -QString PopupDropper::windowTitle() const -{ - return d->view->windowTitle(); -} - -void PopupDropper::setWindowTitle( const QString &title ) -{ - d->view->setWindowTitle( title ); - d->view->update(); -} - -QString PopupDropper::svgFile() const -{ - return d->file; -} - -void PopupDropper::setSvgFile( const QString &file ) -{ - if( d->sharedRenderer ) - { - if( !d->sharedRenderer->load( file ) ) - qWarning() << "Could not load SVG file " << file; - else - { - d->file = file; - //qDebug() << "Loaded SVG file!"; - } - } - else - qWarning() << "No shared renderer!"; -} - -QSvgRenderer* PopupDropper::svgRenderer() -{ - return d->sharedRenderer; -} - -void PopupDropper::setSvgRenderer( QSvgRenderer *renderer ) -{ - d->sharedRenderer = renderer; -} - -int PopupDropper::horizontalOffset() const -{ - return d->horizontalOffset; -} - -void PopupDropper::setHorizontalOffset( int pixels ) -{ - d->horizontalOffset = pixels; -} - -const QSize PopupDropper::viewSize() const -{ - if( d && d->view ) - return d->view->size(); - else - return QSize( 0, 0 ); -} - -void PopupDropper::addItem( PopupDropperItem *item, bool useSharedRenderer ) -{ - addItem( item, useSharedRenderer, true ); -} - -void PopupDropper::addItem( PopupDropperItem *item, bool useSharedRenderer, bool appendToList ) -{ - //qDebug() << "adding item"; - //FIXME: Make separators do something graphical instead of just ignoring them - PopupDropperItem *pItem = static_cast( item ); - if( pItem->isSeparator() ) - return; - if( useSharedRenderer ) - pItem->setSharedRenderer( d->sharedRenderer ); - //qDebug() << "Checking appendToList"; - if( appendToList ) - { - d->pdiItems.append( pItem ); - d->allItems.append( pItem ); - //qDebug() << "pdiItems list is now size " << d->pdiItems.size() << " for " << d; - //qDebug() << "allItems list is now size " << d->allItems.size() << " for " << d; - } - if( !pItem->textItem() ) - { - QGraphicsTextItem *textItem = new QGraphicsTextItem( pItem->text(), pItem ); - pItem->setTextItem( textItem ); - if( !pItem->customBaseTextColor() || !pItem->baseTextColor().isValid() ) - { - pItem->setBaseTextColor( d->baseTextColor ); - //qDebug() << "Using PD's base text color"; - } - else - { - //qDebug() << "Using the item's base text color"; - pItem->textItem()->setDefaultTextColor( pItem->baseTextColor() ); - } - if( !pItem->customHoveredTextColor() ) - pItem->setHoveredTextColor( d->hoveredTextColor ); - } - if( !pItem->borderRectItem() ) - { - QGraphicsRectItem *borderRectItem = new QGraphicsRectItem( pItem ); - borderRectItem->setZValue( -5 ); - pItem->setBorderRectItem( borderRectItem ); - if( !pItem->customHoveredBorderPen() ) - pItem->setHoveredBorderPen( d->hoveredBorderPen ); - if( !pItem->customHoveredFillBrush() ) - pItem->setHoveredFillBrush( d->hoveredFillBrush ); - } - d->reposItems(); - pItem->setPopupDropper( this ); - d->scene->addItem( pItem ); -} - -QList PopupDropper::items() const -{ - QList list; - foreach( PopupDropperItem *item, d->pdiItems ) - list.append( item ); - - return list; -} - -//Won't currently work for > 1 level of submenu! -//TODO: Figure out a better way. (Does anything else work > 1 level?) -QList PopupDropper::submenuItems( const PopupDropperItem *item ) const -{ - QList list; - if( !item || !item->isSubmenuTrigger() || !d->submenuMap.contains( item->action() ) ) - return list; - - PopupDropperPrivate *pdp = d->submenuMap[item->action()]; - foreach( PopupDropperItem *pdi, pdp->pdiItems ) - list.append( pdi ); - - return list; -} - -//Goes through and calls the callback on all items, including submenuItems -//which can be adjusted differently by checking isSubmenuTrigger() -void PopupDropper::forEachItem( void callback(void*) ) -{ - forEachItemPrivate( d, callback ); -} - -void PopupDropper::forEachItemPrivate( PopupDropperPrivate *pdp, void callback(void* item) ) -{ - foreach( PopupDropperItem *item, pdp->pdiItems ) - callback( item ); - foreach( QAction *action, pdp->submenuMap.keys() ) - forEachItemPrivate( pdp->submenuMap[action], callback ); -} - -void PopupDropper::addSeparator( PopupDropperItem* separator ) -{ - - if( !separator ) - { - //qDebug() << "Action is not a separator!"; - return; - } - - separator->setSeparator( true ); - - if( separator->separatorStyle() == PopupDropperItem::TextSeparator ) - { - //qDebug() << "Separator style is text"; - addItem( separator ); - } - - //qDebug() << "Separator style is line"; - QPen linePen; - if( separator && separator->hasLineSeparatorPen() ) - linePen = separator->lineSeparatorPen(); - else - { - linePen.setWidth( 2 ); - linePen.setCapStyle( Qt::RoundCap ); - linePen.setStyle( Qt::DotLine ); - linePen.setColor( QColor( 255, 255, 255 ) ); - } - - //qDebug() << "scene width = " << d->scene->width() << ", horizontalOffset = " << d->horizontalOffset; - //qDebug() << "right side = " << qreal(d->scene->width() - d->horizontalOffset); - QGraphicsLineItem* lineItem = new QGraphicsLineItem( 0, 0, 0, 0 ); - d->allItems.append( lineItem ); - lineItem->setPen( linePen ); - d->reposItems(); - d->scene->addItem( lineItem ); -} - -#include "moc_PopupDropper_p.cpp" -#include "moc_PopupDropper.cpp" - diff --git a/amarok/src/context/popupdropper/libpud/PopupDropper.h b/amarok/src/context/popupdropper/libpud/PopupDropper.h deleted file mode 100644 index d4042cee..00000000 --- a/amarok/src/context/popupdropper/libpud/PopupDropper.h +++ /dev/null @@ -1,161 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2008 Jeff Mitchell * - * * - * This program 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 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#ifndef POPUPDROPPER_H -#define POPUPDROPPER_H - -#include -#include -#include - -#include "PopupDropper_Export.h" - -class QGraphicsSvgItem; -class QGraphicsItem; -class QMenu; -class QSvgRenderer; -class QTimeLine; -class QWidget; -class PopupDropper; -class PopupDropperItem; -class PopupDropperPrivate; - -class POPUPDROPPER_EXPORT PopupDropper : public QObject -{ - Q_OBJECT - - Q_PROPERTY( Fading fading READ fading WRITE setFading ) - Q_PROPERTY( int overlayLevel READ overlayLevel ) - Q_PROPERTY( int deleteTimeout READ deleteTimeout WRITE setDeleteTimeout ) - Q_PROPERTY( bool standalone READ standalone ) - Q_PROPERTY( bool quitOnDragLeave READ quitOnDragLeave WRITE setQuitOnDragLeave ) - Q_PROPERTY( QColor windowColor READ windowColor WRITE setWindowColor ) - Q_PROPERTY( QBrush windowBackgroundBrush READ windowBackgroundBrush WRITE setWindowBackgroundBrush ) - Q_PROPERTY( QColor baseTextColor READ baseTextColor WRITE setBaseTextColor ) - Q_PROPERTY( QPen hoveredBorderPen READ hoveredBorderPen WRITE setHoveredBorderPen ) - Q_PROPERTY( QBrush hoveredFillBrush READ hoveredFillBrush WRITE setHoveredFillBrush ) - Q_PROPERTY( QString windowTitle READ windowTitle WRITE setWindowTitle ) - Q_PROPERTY( QString svgFile READ svgFile WRITE setSvgFile ) - Q_PROPERTY( QSvgRenderer* svgRenderer READ svgRenderer WRITE setSvgRenderer ) - Q_PROPERTY( int horizontalOffset READ horizontalOffset WRITE setHorizontalOffset ) - Q_PROPERTY( const QTimeLine* fadeHideTimer READ fadeHideTimer ) - Q_PROPERTY( const QTimeLine* fadeShowTimer READ fadeShowTimer ) - Q_PROPERTY( const QSize viewSize READ viewSize ) - -public: - enum Fading { NoFade, FadeIn, FadeOut, FadeInOut }; - Q_ENUMS( Fading ) - - explicit PopupDropper( QWidget *parent, bool standalone = false ); - ~PopupDropper(); - - int overlayLevel() const; - void initOverlay( QWidget* parent, PopupDropperPrivate* priv = 0 ); - - void addOverlay(); - - PopupDropperItem* addSubmenu( PopupDropper** pd, const QString &text ); - - bool addMenu( const QMenu *menu ); - - bool standalone() const; - - void show(); - void showAllOverlays(); - void hideAllOverlays(); - void update(); - void updateAllOverlays(); - bool isHidden() const; - bool isEmpty( bool allItems = true ) const; - - bool quitOnDragLeave() const; - void setQuitOnDragLeave( bool quit ); - - int fadeInTime() const; - void setFadeInTime( const int msecs ); - int fadeOutTime() const; - void setFadeOutTime( const int msecs ); - PopupDropper::Fading fading() const; - void setFading( PopupDropper::Fading fade ); - const QTimeLine* fadeHideTimer() const; - const QTimeLine* fadeShowTimer() const; - - void setDeleteTimeout( int msecs ); - int deleteTimeout() const; - - QColor windowColor() const; - void setWindowColor( const QColor &window ); - QBrush windowBackgroundBrush() const; - void setWindowBackgroundBrush( const QBrush &window ); - QColor baseTextColor() const; - void setBaseTextColor( const QColor &baseText ); - QColor hoveredTextColor() const; - void setHoveredTextColor( const QColor &hoveredText ); - QPen hoveredBorderPen() const; - void setHoveredBorderPen( const QPen &hoveredBorder ); - QBrush hoveredFillBrush() const; - void setHoveredFillBrush( const QBrush &hoveredFill ); - void setColors( const QColor &window, const QColor &baseText, const QColor &hoveredText, const QColor &hoveredBorder, const QColor &hoveredFill ); - void setPalette( const QColor &window ); - void setPalette( const QColor &window, const QColor &baseText, const QColor &hoveredText, const QColor &hoveredBorder, const QColor &hoveredFill ); - - QString windowTitle() const; - void setWindowTitle( const QString &title ); - - QString svgFile() const; - void setSvgFile( const QString &file ); - QSvgRenderer* svgRenderer(); - void setSvgRenderer( QSvgRenderer *renderer ); - - void setHorizontalOffset( int pixels ); - int horizontalOffset() const; - - const QSize viewSize() const; - - void addItem( PopupDropperItem *item, bool useSharedRenderer = true ); - QList items() const; - QList submenuItems( const PopupDropperItem *item ) const; - void forEachItem( void callback(void*) ); - void addSeparator( PopupDropperItem *separator = 0 ); - -Q_SIGNALS: - void fadeHideFinished(); - -public Q_SLOTS: - void clear(); - void hide(); - bool subtractOverlay(); - -private Q_SLOTS: - void activateSubmenu(); - void slotHideAllOverlays(); - -private: - friend class PopupDropperView; - friend class PopupDropperPrivate; - PopupDropperPrivate* d; - - void addOverlay( PopupDropperPrivate* newD ); - void addItem( PopupDropperItem *item, bool useSharedRenderer, bool appendToList ); - void forEachItemPrivate( PopupDropperPrivate *pdp, void callback(void*) ); - - QStack m_viewStack; -}; - -#endif //POPUPDROPPER_H diff --git a/amarok/src/context/popupdropper/libpud/PopupDropperItem.cpp b/amarok/src/context/popupdropper/libpud/PopupDropperItem.cpp deleted file mode 100644 index f8589aa1..00000000 --- a/amarok/src/context/popupdropper/libpud/PopupDropperItem.cpp +++ /dev/null @@ -1,885 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2008 Jeff Mitchell * - * * - * This program 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 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#include "PopupDropperItem.h" -#include "PopupDropperItem_p.h" -#include "PopupDropper.h" - -#include -#include -#include -#include -#include - -/////////////////////////////////////////////////////////// - -PopupDropperItemPrivate::PopupDropperItemPrivate( PopupDropperItem *parent ) - : action( 0 ) - , text( QString() ) - , hoverTimer( 500, parent ) - , elementId( QString() ) - , textItem( 0 ) - , borderRectItem( 0 ) - , svgItem( 0 ) - , hoverIndicatorRectItem( 0 ) - , hoverIndicatorRectFillItem( 0 ) - , borderWidth( 2 ) - , hoverIndicatorRectWidth( 15 ) - , font() - , submenuTrigger( false ) - , baseTextColor() - , hoveredTextColor() - , hoveredBorderPen() - , hoveredFillBrush() - , hoverIndicatorRectFillBrush() - , hoveredOver( false ) - , customBaseTextColor( false ) - , customHoveredTextColor( false ) - , customHoveredBorderPen( false ) - , customHoveredFillBrush( false ) - , subitemOpacity( 0.0 ) - , file( QString() ) - , svgElementRect( 0, 0, 50, 50 ) - , sharedRenderer( 0 ) - , horizontalOffset( 30 ) - , textOffset( 30 ) - , separator( false ) - , hasLineSeparatorPen( false ) - , lineSeparatorPen() - , hoverIndicatorShowStyle( PopupDropperItem::Never ) - , orientation( PopupDropperItem::Left ) - , textProtection( PopupDropperItem::ScaleFont ) - , separatorStyle( PopupDropperItem::TextSeparator ) - , pd( 0 ) - , q( parent ) - { - hoverTimer.setFrameRange( 0, 30 ); - hoverTimer.setUpdateInterval( 20 ); // 50 fps - q->setAcceptDrops( true ); - hoverIndicatorRectFillBrush.setColor( Qt::white ); - hoveredBorderPen.setWidth( borderWidth ); - hoveredBorderPen.setColor( Qt::white ); - hoveredBorderPen.setStyle( Qt::SolidLine ); - hoveredFillBrush.setColor( Qt::white ); - hoveredFillBrush.setStyle( Qt::SolidPattern ); - } - -PopupDropperItemPrivate::~PopupDropperItemPrivate() -{ -} - -/////////////////////////////////////////////////////////// - -PopupDropperItem::PopupDropperItem( QGraphicsItem *parent ) - : QObject() - , QAbstractGraphicsShapeItem( parent ) - , d( new PopupDropperItemPrivate( this ) ) -{ - connect( &d->hoverTimer, SIGNAL(finished()), this, SLOT(hoverFinished()) ); - connect( &d->hoverTimer, SIGNAL(frameChanged(int)), this, SLOT(hoverFrameChanged(int)) ); -} - -PopupDropperItem::PopupDropperItem( const QString &file, QGraphicsItem *parent ) - : QObject() - , QAbstractGraphicsShapeItem( parent ) - , d( new PopupDropperItemPrivate( this ) ) -{ - d->file = file; - connect( &d->hoverTimer, SIGNAL(finished()), this, SLOT(hoverFinished()) ); - connect( &d->hoverTimer, SIGNAL(frameChanged(int)), this, SLOT(hoverFrameChanged(int)) ); -} - -PopupDropperItem::~PopupDropperItem() -{ - delete d; -} - -void PopupDropperItem::show() -{ -} - -QAction* PopupDropperItem::action() const -{ - return d->action; -} - -void PopupDropperItem::setAction( QAction *action ) -{ - if( !action ) - return; - //note that this also sets the text - d->action = action; - d->text = action->text(); - if( action ) - { - if( !d->svgItem ) - { - if( !d->file.isEmpty() ) - d->svgItem = new QGraphicsSvgItem( d->file, this ); - else - d->svgItem = new QGraphicsSvgItem( this ); - } - - if( d->sharedRenderer ) - d->svgItem->setSharedRenderer( d->sharedRenderer ); - - if( d->elementId.isEmpty() ) - d->elementId = action->property( "popupdropper_svg_id" ).toString(); - if( !d->elementId.isEmpty() ) - { - if( d->svgItem->renderer() && d->svgItem->renderer()->elementExists( d->elementId ) ) - d->svgItem->setElementId( d->elementId ); - } - - if( !d->svgItem->elementId().isEmpty() && d->svgItem->renderer()->elementExists( d->svgItem->elementId() ) ) - d->svgItem->show(); - else - d->svgItem->hide(); - - if( action->isSeparator() ) - d->separator = true; - - scaleAndReposSvgItem(); - - d->hoverIndicatorRectItem = new QGraphicsRectItem( this ); - - QPen pen = d->hoveredBorderPen; - QColor color( pen.color() ); - color.setAlpha( 255 ); - pen.setColor( color ); - d->hoverIndicatorRectItem->setPen( pen ); - QBrush brush = d->hoverIndicatorRectItem->brush(); - brush.setStyle( Qt::NoBrush ); - d->hoverIndicatorRectItem->setBrush( brush ); - - d->hoverIndicatorRectFillItem = new QGraphicsRectItem( this ); - pen = d->hoverIndicatorRectFillItem->pen(); - pen.setStyle( Qt::NoPen ); - d->hoverIndicatorRectFillItem->setPen( pen ); - d->hoverIndicatorRectFillBrush.setStyle( Qt::SolidPattern ); - - if( d->hoverIndicatorShowStyle == PopupDropperItem::AlwaysShow ) - d->hoverIndicatorRectItem->show(); - else - d->hoverIndicatorRectItem->hide(); - - d->hoverIndicatorRectFillItem->hide(); - - reposHoverFillRects(); - } - - if( d->pd ) - d->pd->updateAllOverlays(); -} - -PopupDropperItem::HoverIndicatorShowStyle PopupDropperItem::hoverIndicatorShowStyle() const -{ - return d->hoverIndicatorShowStyle; -} - -void PopupDropperItem::setHoverIndicatorShowStyle( HoverIndicatorShowStyle hover ) -{ - d->hoverIndicatorShowStyle = hover; - if( !d->hoveredOver ) - { - if( d->hoverIndicatorShowStyle == PopupDropperItem::AlwaysShow ) - d->hoverIndicatorRectItem->show(); - else - d->hoverIndicatorRectItem->hide(); - } -} - -PopupDropperItem::Orientation PopupDropperItem::orientation() const -{ - return d->orientation; -} - -void PopupDropperItem::setOrientation( const Orientation orientation ) -{ - d->orientation = orientation; - fullUpdate(); -} - -PopupDropperItem::TextProtection PopupDropperItem::textProtection() const -{ - return d->textProtection; -} - -void PopupDropperItem::setTextProtection( const TextProtection textProtection ) -{ - d->textProtection = textProtection; - fullUpdate(); -} - -QString PopupDropperItem::text() const -{ - return d->text; -} - -void PopupDropperItem::setText( const QString &text ) -{ - d->text = text; - if( d->textItem ) - d->textItem->setHtml( text ); - reposTextItem(); -} - -QFont PopupDropperItem::font() const -{ - return d->font; -} - -void PopupDropperItem::setFont( const QFont &font ) -{ - d->font = font; - if( d->textItem ) - d->textItem->setFont( font ); - reposTextItem(); -} - -QColor PopupDropperItem::baseTextColor() const -{ - return d->baseTextColor; -} - -void PopupDropperItem::setBaseTextColor( const QColor &color ) -{ - if( !d->hoveredOver && d->textItem ) - d->textItem->setDefaultTextColor( color ); - d->baseTextColor = color; - d->customBaseTextColor = true; -} - -QColor PopupDropperItem::hoveredTextColor() const -{ - return d->hoveredTextColor; -} - -void PopupDropperItem::setHoveredTextColor( const QColor &color ) -{ - if( d->textItem && d->hoveredOver && d->hoverTimer.state() != QTimeLine::Running ) - d->textItem->setDefaultTextColor( color ); - d->hoveredTextColor = color; - d->customHoveredTextColor = true; -} - -QPen PopupDropperItem::hoveredBorderPen() const -{ - return d->hoveredBorderPen; -} - -void PopupDropperItem::setHoveredBorderPen( const QPen &pen ) -{ - d->hoveredBorderPen = pen; - d->customHoveredBorderPen = true; - if( d->borderRectItem && ( !d->hoveredOver || ( d->hoveredOver && d->hoverTimer.state() != QTimeLine::Running ) ) ) - { - QPen borderPen = pen; - if( !d->hoveredOver ) - { - QColor pencolor = borderPen.color(); - pencolor.setAlpha( 0 ); - borderPen.setColor( pencolor ); - } - d->borderRectItem->setPen( borderPen ); - } - if( d->hoverIndicatorRectItem && ( !d->hoveredOver || ( d->hoveredOver && d->hoverTimer.state() != QTimeLine::Running ) ) ) - { - QPen borderPen = d->hoveredBorderPen; - QColor color = borderPen.color(); - color.setAlpha( 255 ); - borderPen.setColor( color ); - d->hoverIndicatorRectItem->setPen( borderPen ); - } -} - -QBrush PopupDropperItem::hoveredFillBrush() const -{ - return d->hoveredFillBrush; -} - -void PopupDropperItem::setHoveredFillBrush( const QBrush &brush ) -{ - d->hoveredFillBrush = brush; - d->customHoveredFillBrush = true; - if( d->borderRectItem && ( !d->hoveredOver || ( d->hoveredOver && d->hoverTimer.state() != QTimeLine::Running ) ) ) - { - QBrush borderBrush = brush; - if( !d->hoveredOver ) - { - QColor brushColor = borderBrush.color(); - brushColor.setAlpha( 0 ); - borderBrush.setColor( brushColor ); - } - d->borderRectItem->setBrush( borderBrush ); - } -} - -QBrush PopupDropperItem::hoverIndicatorFillBrush() const -{ - return d->hoverIndicatorRectFillBrush; -} - -void PopupDropperItem::setHoverIndicatorFillBrush( const QBrush &brush ) -{ - d->hoverIndicatorRectFillBrush = brush; - if( d->hoverIndicatorRectFillItem && ( d->hoveredOver && d->hoverTimer.state() != QTimeLine::Running ) ) - d->hoverIndicatorRectFillItem->setBrush( d->hoverIndicatorRectFillBrush ); -} - -bool PopupDropperItem::customBaseTextColor() const -{ - return d->customBaseTextColor; -} - -bool PopupDropperItem::customHoveredTextColor() const -{ - return d->customHoveredTextColor; -} - -bool PopupDropperItem::customHoveredBorderPen() const -{ - return d->customHoveredBorderPen; -} - -bool PopupDropperItem::customHoveredFillBrush() const -{ - return d->customHoveredFillBrush; -} - -qreal PopupDropperItem::subitemOpacity() const -{ - return d->subitemOpacity; -} - -void PopupDropperItem::setSubitemOpacity( qreal opacity ) -{ - if( d->svgItem ) - d->svgItem->setOpacity( opacity ); - if( d->textItem ) - d->textItem->setOpacity( opacity ); - if( d->borderRectItem ) - d->borderRectItem->setOpacity( opacity ); - if( d->hoverIndicatorRectItem ) - d->hoverIndicatorRectItem->setOpacity( opacity ); - if( d->hoverIndicatorRectFillItem ) - d->hoverIndicatorRectFillItem->setOpacity( opacity ); -} - -QGraphicsTextItem* PopupDropperItem::textItem() const -{ - return d->textItem; -} - -void PopupDropperItem::setTextItem( QGraphicsTextItem *textItem ) -{ - d->textItem = textItem; - if( d->textItem ) - d->textItem->setHtml( d->text ); -} - -QGraphicsRectItem* PopupDropperItem::borderRectItem() const -{ - return d->borderRectItem; -} - -void PopupDropperItem::setBorderRectItem( QGraphicsRectItem *borderRectItem ) -{ - if( !borderRectItem ) - return; - - d->borderRectItem = borderRectItem; - if( !d->hoveredOver ) - { - QPen pen = d->hoveredBorderPen; - QColor color = pen.color(); - color.setAlpha( 0 ); - pen.setColor( color ); - d->borderRectItem->setPen( pen ); - QBrush brush = d->hoveredFillBrush; - color = brush.color(); - color.setAlpha( 0 ); - brush.setColor( color ); - d->borderRectItem->setBrush( brush ); - } -} - -QGraphicsSvgItem* PopupDropperItem::svgItem() const -{ - return d->svgItem; -} - -void PopupDropperItem::scaleAndReposSvgItem() -{ - if( !d->svgItem || !d->borderRectItem ) - return; - - if( d->separator ) - { - d->svgItem->scale( 0, 0 ); - d->svgItem->setPos( 0, 0 ); - return; - } - - //Need to scale if it is too tall or wide - qreal maxheight = d->svgElementRect.height() - ( 2 * d->borderRectItem->pen().width() ); - qreal maxwidth = d->svgElementRect.width() - ( 2 * d->borderRectItem->pen().width() ); - qreal vertScaleValue = maxheight / d->svgItem->sceneBoundingRect().height(); - qreal horizScaleValue = maxwidth / d->svgItem->sceneBoundingRect().width(); - qreal scaleValue = vertScaleValue < horizScaleValue ? vertScaleValue : horizScaleValue; - - d->svgItem->scale( scaleValue, scaleValue ); - - qreal item_center = ( d->borderRectItem->sceneBoundingRect().height() / 2 ) + d->borderRectItem->pos().y(); - - if( d->orientation == PopupDropperItem::Left ) - { - d->svgItem->setPos( d->horizontalOffset, item_center - ( d->svgElementRect.height() / 2 ) ); - } - else - { - int rightside; - if( !d->pd || d->pd->viewSize().width() == 0 ) - rightside = sceneBoundingRect().width(); - else - rightside = d->pd->viewSize().width(); - d->svgItem->setPos( - rightside - - d->svgItem->sceneBoundingRect().width() - - d->horizontalOffset - , item_center - ( d->svgElementRect.height() / 2 ) ); - } -} - -void PopupDropperItem::reposTextItem() -{ - if( !d->textItem || !d->borderRectItem ) - return; - d->textItem->setFont( d->font ); - - qreal item_vert_center = ( d->borderRectItem->sceneBoundingRect().height() / 2 ) + d->borderRectItem->pos().y(); - - if( d->separator ) - { - if( d->text.isEmpty() ) - return; - qreal width = d->textItem->textWidth(); - if( width > d->borderRectItem->sceneBoundingRect().width() ) - d->textItem->setTextWidth( d->borderRectItem->sceneBoundingRect().width() ); - qreal offset = ( d->borderRectItem->sceneBoundingRect().width() - width ) / 2; - d->textItem->setPos( offset, item_vert_center - ( d->textItem->sceneBoundingRect().height() / 2 ) ); - return; - } - - int offsetPos = d->horizontalOffset + d->textOffset + d->svgElementRect.width(); - d->textItem->setPos( - ( d->orientation == PopupDropperItem::Left - ? offsetPos - : 0 - ) - , item_vert_center - ( d->textItem->sceneBoundingRect().height() / 2 ) ); - - if( d->textProtection == PopupDropperItem::ScaleFont ) - { - QFontMetrics fm( d->textItem->font() ); - qreal desiredWidth = d->borderRectItem->sceneBoundingRect().width() - offsetPos; - while( d->textItem->font().pointSize() > 1 && - ( fm.width( d->textItem->toPlainText() ) > desiredWidth || - fm.height() > d->textItem->boundingRect().height() ) ) - { - QFont font = d->textItem->font(); - font.setPointSize( font.pointSize() - 1 ); - d->textItem->setFont( font ); - fm = QFontMetrics( font ); - } - } - else if( d->textProtection == PopupDropperItem::MultiLine && - ( d->textItem->textWidth() == -1 || - d->textItem->textWidth() > ( d->borderRectItem->sceneBoundingRect().width() - offsetPos ) - ) - ) - { - d->textItem->setTextWidth( d->borderRectItem->sceneBoundingRect().width() - offsetPos ); - reposTextItem(); - } -} - -void PopupDropperItem::reposHoverFillRects() -{ - if( !d->hoverIndicatorRectItem || !d->hoverIndicatorRectFillItem || !d->textItem || !d->borderRectItem ) - return; - - if( d->separator ) - { - d->hoverIndicatorRectItem->setRect( 0, 0, 0, 0 ); - d->hoverIndicatorRectFillItem->setRect( 0, 0, 0, 0 ); - return; - } - - //qDebug() << "\n\nPUDItem boundingRect().width() = " << boundingRect().width(); - qreal startx, starty, endx, endy, item_center; - //int rightside = d->borderRectItem ? d->borderRectItem->boundingRect().width() : boundingRect().width(); - if( d->orientation == PopupDropperItem::Left ) - { - startx = d->horizontalOffset - - d->hoverIndicatorRectWidth - - ( 2 * d->hoverIndicatorRectItem->pen().width() ); - } - else - { - int rightside = (!d->pd || d->pd->viewSize().width() == 0 ) - ? sceneBoundingRect().width() - : d->pd->viewSize().width(); - //qDebug() << "right side = " << rightside; - startx = rightside - d->horizontalOffset - + d->hoverIndicatorRectWidth - - ( 2 * d->hoverIndicatorRectItem->pen().width() ); - } - - item_center = ( d->borderRectItem->sceneBoundingRect().height() / 2 ) + d->borderRectItem->pos().y(); - - starty = item_center - ( d->svgElementRect.height() / 2 ); - - endx = d->hoverIndicatorRectWidth - ( 2 * d->hoverIndicatorRectItem->pen().width() ); - - endy = d->svgElementRect.height(); - - QRectF indicatorRect( startx, starty, endx, endy ); - d->hoverIndicatorRectItem->setRect( indicatorRect ); - - QRectF indicatorFillRect( - indicatorRect.left() + d->hoverIndicatorRectItem->pen().width() - , indicatorRect.bottom() - d->hoverIndicatorRectItem->pen().width() - , indicatorRect.width() - ( 2 * d->hoverIndicatorRectItem->pen().width() ) - , 0 ); - d->hoverIndicatorRectFillItem->setRect( indicatorFillRect ); -} - -QSvgRenderer* PopupDropperItem::sharedRenderer() const -{ - return d->sharedRenderer; -} - -void PopupDropperItem::setSharedRenderer( QSvgRenderer *renderer ) -{ - d->sharedRenderer = renderer; - if( renderer && d->svgItem ) - { - d->svgItem->setSharedRenderer( renderer ); - d->svgItem->setElementId( d->elementId ); - if( !d->svgItem->elementId().isEmpty() && d->svgItem->renderer()->elementExists( d->svgItem->elementId() ) ) - { - d->svgItem->show(); - fullUpdate(); - } - } -} - -QString PopupDropperItem::elementId() const -{ - return d->elementId; -} - -void PopupDropperItem::setElementId( const QString &id ) -{ - //qDebug() << "Element ID being set: " << id; - d->elementId = id; - if( id.isEmpty() ) - { - d->svgItem->hide(); - fullUpdate(); - } - else if( d->svgItem && d->svgItem->renderer() && d->svgItem->renderer()->elementExists( id )) - { - d->svgItem->setElementId( id ); - d->svgItem->show(); - fullUpdate(); - } -} - -QRect PopupDropperItem::svgElementRect() const -{ - return d->svgElementRect; -} - -void PopupDropperItem::setSvgElementRect( const QRect &rect ) -{ - d->svgElementRect = rect; -} - -int PopupDropperItem::horizontalOffset() const -{ - return d->horizontalOffset; -} - -void PopupDropperItem::setHorizontalOffset( int offset ) -{ - d->horizontalOffset = offset; -} - -int PopupDropperItem::textOffset() const -{ - return d->textOffset; -} - -void PopupDropperItem::setTextOffset( int offset ) -{ - d->textOffset = offset; -} - -bool PopupDropperItem::isSeparator() const -{ - return d->separator; -} - -void PopupDropperItem::setSeparator( bool separator ) -{ - d->separator = separator; -} - -PopupDropperItem::SeparatorStyle PopupDropperItem::separatorStyle() const -{ - return d->separatorStyle; -} - -void PopupDropperItem::setSeparatorStyle( SeparatorStyle style ) -{ - d->separatorStyle = style; -} - -bool PopupDropperItem::hasLineSeparatorPen() const -{ - return d->hasLineSeparatorPen; -} - -QPen PopupDropperItem::lineSeparatorPen() const -{ - return d->lineSeparatorPen; -} - -void PopupDropperItem::setLineSeparatorPen( const QPen &pen ) -{ - d->lineSeparatorPen = pen; -} - -void PopupDropperItem::clearLineSeparatorPen() -{ - d->lineSeparatorPen = QPen(); - d->hasLineSeparatorPen = false; -} - -int PopupDropperItem::hoverMsecs() const -{ - return d->hoverTimer.duration(); -} - -void PopupDropperItem::setHoverMsecs( const int msecs ) -{ - d->hoverTimer.setDuration( msecs ); -} - -void PopupDropperItem::hoverEntered() -{ - if( d->hoverIndicatorRectItem && d->hoverIndicatorRectFillItem && d->hoverIndicatorShowStyle != PopupDropperItem::Never ) - { - d->hoverIndicatorRectFillItem->show(); - } - d->hoverTimer.stop(); - d->hoverTimer.setDirection( QTimeLine::Forward ); - d->hoveredOver = true; - d->hoverTimer.start(); -} - -void PopupDropperItem::hoverLeft() -{ - d->hoverTimer.stop(); - d->hoverTimer.setDirection( QTimeLine::Backward ); - d->hoveredOver = false; - if( d->hoverTimer.currentFrame() != 0 ) - d->hoverTimer.start(); -} - -int PopupDropperItem::borderWidth() const -{ - return d->borderWidth; -} - -void PopupDropperItem::setBorderWidth( int borderWidth ) -{ - d->borderWidth = borderWidth; - d->hoveredBorderPen.setWidth( borderWidth ); - if( d->borderRectItem ) - { - d->borderRectItem->setPen( d->hoveredBorderPen ); - } -} - -int PopupDropperItem::hoverIndicatorRectWidth() const -{ - return d->hoverIndicatorRectWidth; -} - -void PopupDropperItem::setHoverIndicatorRectWidth( int hoverIndicatorRectWidth ) -{ - d->hoverIndicatorRectWidth = hoverIndicatorRectWidth; - if( d->hoverIndicatorRectItem ) - { - QPen pen = d->hoverIndicatorRectItem->pen(); - pen.setWidth( d->hoverIndicatorRectWidth ); - d->hoverIndicatorRectItem->setPen( pen ); - } -} - -bool PopupDropperItem::isSubmenuTrigger() const -{ - return d->submenuTrigger; -} - -void PopupDropperItem::setSubmenuTrigger( bool trigger ) -{ - d->submenuTrigger = trigger; -} - -void PopupDropperItem::setPopupDropper( PopupDropper* pd ) -{ - d->pd = pd; -} - -//bool PopupDropperItem::operator<( const PopupDropperItem &other ) const -//{ -// return d->text < other.text(); -//} - -void PopupDropperItem::dropped( QDropEvent *event ) //virtual SLOT -{ - Q_UNUSED( event ); - d->hoverTimer.stop(); - //qDebug() << "PopupDropperItem drop detected"; - if( d->action ) - { - //qDebug() << "Triggering action"; - d->action->activate( QAction::Trigger ); - } -} - -void PopupDropperItem::hoverFinished() //SLOT -{ - if( d->separator ) - return; - - //qDebug() << "direction = forwards ? " << ( d->hoverTimer.direction() == QTimeLine::Forward ? "yes" : "no" ); - - if( d->action && d->hoverTimer.direction() == QTimeLine::Forward ) - d->action->activate( QAction::Hover ); - - if( d->hoverTimer.direction() == QTimeLine::Forward ) - d->textItem->setDefaultTextColor( d->hoveredTextColor ); - else - d->textItem->setDefaultTextColor( d->baseTextColor ); - - //Something is messed up in QTimeLine...I get hoverFinished immediately after doing a hoverLeft, but only sometimes...hence the check - //to see if the timeline isn't running - if( d->hoverIndicatorRectFillItem && d->hoverTimer.state() == QTimeLine::NotRunning && d->hoverTimer.direction() == QTimeLine::Backward ) - { - d->hoverIndicatorRectFillItem->hide(); - if( d->hoverIndicatorRectItem && d->hoverIndicatorShowStyle != PopupDropperItem::AlwaysShow ) - d->hoverIndicatorRectItem->hide(); - } - - if( d->pd ) - d->pd->updateAllOverlays(); -} - -void PopupDropperItem::hoverFrameChanged( int frame ) //SLOT -{ - if( d->separator ) - return; - //qDebug() << "hoverFrameChanged for " << static_cast(this) << ", frame = " << frame; - int range = d->hoverTimer.endFrame() - d->hoverTimer.startFrame(); - qreal multiplier = ( 1.0 * frame ) / range; - int r = (int)( ( d->hoveredTextColor.red() - d->baseTextColor.red() ) * multiplier ) + d->baseTextColor.red(); - int g = (int)( ( d->hoveredTextColor.green() - d->baseTextColor.green() ) * multiplier ) + d->baseTextColor.green(); - int b = (int)( ( d->hoveredTextColor.blue() - d->baseTextColor.blue() ) * multiplier ) + d->baseTextColor.blue(); - int a = (int)( ( d->hoveredTextColor.alpha() - d->baseTextColor.alpha() ) * multiplier ) + d->baseTextColor.alpha(); - - d->textItem->setDefaultTextColor( QColor( r, g, b, a ) ); - - QColor borderColor = d->hoveredBorderPen.color(); - borderColor.setAlpha( (int)( borderColor.alpha() * multiplier ) ); - QPen pen = d->borderRectItem->pen(); - pen.setColor( borderColor ); - d->borderRectItem->setPen( pen ); - if( d->hoverIndicatorRectItem && d->hoverIndicatorShowStyle == PopupDropperItem::OnHover ) - { - d->hoverIndicatorRectItem->setPen( pen ); - d->hoverIndicatorRectItem->show(); - } - QColor fillColor = d->hoveredFillBrush.color(); - QBrush brush = d->borderRectItem->brush(); - fillColor.setAlpha( (int)( fillColor.alpha() * multiplier ) ); - brush.setColor( fillColor ); - d->borderRectItem->setBrush( brush ); - - if( d->hoverIndicatorRectItem && d->hoverIndicatorRectFillItem && d->hoverIndicatorShowStyle != PopupDropperItem::Never ) - { - int hoverIndicatorPenWidth = d->hoverIndicatorRectItem->pen().width(); - QRectF rect = d->hoverIndicatorRectFillItem->rect(); - QRectF outerRect = d->hoverIndicatorRectItem->rect(); - rect.setTop( ( multiplier * -1 * ( outerRect.bottom() - outerRect.top() - ( 2 * hoverIndicatorPenWidth ) ) ) - + outerRect.bottom() - - hoverIndicatorPenWidth ); - d->hoverIndicatorRectFillItem->setRect( rect ); - d->hoverIndicatorRectFillItem->setBrush( d->hoverIndicatorRectFillBrush ); - d->hoverIndicatorRectFillItem->show(); - //qDebug() << "hoverIndicatorRectFillItem = " << d->hoverIndicatorRectFillItem; - } - - if( d->pd ) - d->pd->updateAllOverlays(); -} - -void PopupDropperItem::fullUpdate() -{ - scaleAndReposSvgItem(); - reposTextItem(); - reposHoverFillRects(); - if( d->pd ) - d->pd->updateAllOverlays(); -} - -QRectF PopupDropperItem::boundingRect() const -{ - if( d->borderRectItem ) - return d->borderRectItem->boundingRect(); - else if( d->pd && d->pd->viewSize().width() != 0 ) - return QRectF( 0, 0, d->pd->viewSize().width(), d->svgElementRect.height() ); - else - return QRectF( 0, 0, d->svgElementRect.width(), d->svgElementRect.height() ); -} - -void PopupDropperItem::paint( QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget ) -{ - Q_UNUSED( painter ) - Q_UNUSED( option ) - Q_UNUSED( widget ) - return; -} - -#include "moc_PopupDropperItem.cpp" - diff --git a/amarok/src/context/popupdropper/libpud/PopupDropperItem.h b/amarok/src/context/popupdropper/libpud/PopupDropperItem.h deleted file mode 100644 index 2cc17056..00000000 --- a/amarok/src/context/popupdropper/libpud/PopupDropperItem.h +++ /dev/null @@ -1,183 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2008 Jeff Mitchell * - * * - * This program 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 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#ifndef POPUPDROPPERITEM_H -#define POPUPDROPPERITEM_H - -#include -#include -#include - -#include "PopupDropper_Export.h" - -class QDropEvent; -class QGraphicsTextItem; -class QGraphicsView; -class QSvgRenderer; -class QAction; -class PopupDropper; -class PopupDropperItemPrivate; - -class POPUPDROPPER_EXPORT PopupDropperItem : public QObject, public QAbstractGraphicsShapeItem -{ - Q_OBJECT - - Q_PROPERTY( HoverIndicatorShowStyle hoverIndicatorShowStyle READ hoverIndicatorShowStyle WRITE setHoverIndicatorShowStyle ) - Q_PROPERTY( Orientation orientation READ orientation WRITE setOrientation ) - Q_PROPERTY( TextProtection textProtection READ textProtection WRITE setTextProtection ) - Q_PROPERTY( QAction* action READ action WRITE setAction ) - Q_PROPERTY( QString text READ text WRITE setText ) - Q_PROPERTY( QFont font READ font WRITE setFont ) - Q_PROPERTY( QGraphicsTextItem* textItem READ textItem WRITE setTextItem ) - Q_PROPERTY( QGraphicsRectItem* borderRectItem READ borderRectItem WRITE setBorderRectItem ) - Q_PROPERTY( QGraphicsSvgItem* svgItem READ svgItem ) - Q_PROPERTY( QSvgRenderer* sharedRenderer READ sharedRenderer WRITE setSharedRenderer ) - Q_PROPERTY( QString elementId READ elementId WRITE setElementId ) - Q_PROPERTY( QRect svgElementRect READ svgElementRect WRITE setSvgElementRect ) - Q_PROPERTY( int horizontalOffset READ horizontalOffset WRITE setHorizontalOffset ) - Q_PROPERTY( int textOffset READ textOffset WRITE setTextOffset ) - Q_PROPERTY( int hoverMsecs READ hoverMsecs WRITE setHoverMsecs ) - Q_PROPERTY( int borderWidth READ borderWidth WRITE setBorderWidth ) - Q_PROPERTY( int hoverIndicatorRectWidth READ hoverIndicatorRectWidth WRITE setHoverIndicatorRectWidth ) - Q_PROPERTY( bool submenuTrigger READ isSubmenuTrigger WRITE setSubmenuTrigger ) - Q_PROPERTY( QColor baseTextColor READ baseTextColor WRITE setBaseTextColor ) - Q_PROPERTY( QColor hoveredTextColor READ hoveredTextColor WRITE setHoveredTextColor ) - Q_PROPERTY( QPen hoveredBorderPen READ hoveredBorderPen WRITE setHoveredBorderPen ) - Q_PROPERTY( QBrush hoveredBrush READ hoveredFillBrush WRITE setHoveredFillBrush ) - Q_PROPERTY( QBrush hoverIndicatorBrush READ hoverIndicatorFillBrush WRITE setHoverIndicatorFillBrush ) - Q_PROPERTY( bool customBaseTextColor READ customBaseTextColor ) - Q_PROPERTY( bool customHoveredTextColor READ customHoveredTextColor ) - Q_PROPERTY( bool customHoveredBorderPen READ customHoveredBorderPen ) - Q_PROPERTY( bool customHoveredFillBrush READ customHoveredFillBrush ) - Q_PROPERTY( qreal subitemOpacity READ subitemOpacity WRITE setSubitemOpacity ) - Q_PROPERTY( bool separator READ isSeparator WRITE setSeparator ) - Q_PROPERTY( PopupDropperItem::SeparatorStyle separatorStyle READ separatorStyle WRITE setSeparatorStyle ) - Q_PROPERTY( bool hasLineSeparatorPen READ hasLineSeparatorPen ) - Q_PROPERTY( QPen lineSeparatorPen READ lineSeparatorPen WRITE setLineSeparatorPen ) - -public: - enum HoverIndicatorShowStyle { Never, OnHover, AlwaysShow }; - Q_ENUMS( HoverIndicatorShowStyle ) - enum Orientation { Left, Right }; - Q_ENUMS( Orientation ) - enum TextProtection { NoProtection, MultiLine, ScaleFont }; - Q_ENUMS( TextProtection ) - enum SeparatorStyle{TextSeparator, LineSeparator}; - Q_ENUMS( separatorStyle ) - - PopupDropperItem( QGraphicsItem *parent = 0 ); - explicit PopupDropperItem( const QString &file, QGraphicsItem *parent = 0 ); - virtual ~PopupDropperItem(); - - void show(); - - QAction* action() const; - void setAction( QAction *action ); - - HoverIndicatorShowStyle hoverIndicatorShowStyle() const; - void setHoverIndicatorShowStyle( HoverIndicatorShowStyle hover ); - Orientation orientation() const; - void setOrientation( Orientation orientation ); - TextProtection textProtection() const; - void setTextProtection( TextProtection protection ); - - QString text() const; - void setText( const QString &text ); - QFont font() const; - void setFont( const QFont &font ); - QColor baseTextColor() const; - void setBaseTextColor( const QColor &color ); - QColor hoveredTextColor() const; - void setHoveredTextColor( const QColor &color ); - QPen hoveredBorderPen() const; - void setHoveredBorderPen( const QPen &pen ); - QBrush hoveredFillBrush() const; - void setHoveredFillBrush( const QBrush &brush ); - QBrush hoverIndicatorFillBrush() const; - void setHoverIndicatorFillBrush( const QBrush &brush ); - bool customBaseTextColor() const; - bool customHoveredTextColor() const; - bool customHoveredBorderPen() const; - bool customHoveredFillBrush() const; - void setSubitemOpacity( qreal opacity ); - qreal subitemOpacity() const; - - QGraphicsTextItem* textItem() const; - void setTextItem( QGraphicsTextItem *textItem ); - void scaleAndReposSvgItem(); - void reposTextItem(); - void reposHoverFillRects(); - QGraphicsRectItem* borderRectItem() const; - void setBorderRectItem( QGraphicsRectItem *borderRectItem ); - QGraphicsSvgItem* svgItem() const; - - QSvgRenderer* sharedRenderer() const; - void setSharedRenderer( QSvgRenderer *renderer ); - QString elementId() const; - void setElementId( const QString &id ); - QRect svgElementRect() const; - void setSvgElementRect( const QRect &rect ); - int horizontalOffset() const; - void setHorizontalOffset( int offset ); - int textOffset() const; - void setTextOffset( int offset ); - - bool isSeparator() const; - void setSeparator( bool separator ); - PopupDropperItem::SeparatorStyle separatorStyle() const; - void setSeparatorStyle( PopupDropperItem::SeparatorStyle style ); - bool hasLineSeparatorPen() const; - QPen lineSeparatorPen() const; - void setLineSeparatorPen( const QPen &pen ); - void clearLineSeparatorPen(); - - int hoverMsecs() const; - void setHoverMsecs( const int msecs ); - void hoverEntered(); - void hoverLeft(); - - int borderWidth() const; - void setBorderWidth( int width ); - int hoverIndicatorRectWidth() const; - void setHoverIndicatorRectWidth( int width ); - - bool isSubmenuTrigger() const; - void setSubmenuTrigger( bool trigger ); - - void setPopupDropper( PopupDropper* pd ); - - //bool operator<( const PopupDropperItem &other ) const; - - void fullUpdate(); - - virtual QRectF boundingRect() const; - virtual void paint( QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0 ); - -public Q_SLOTS: - virtual void dropped( QDropEvent *event ); - virtual void hoverFinished(); - virtual void hoverFrameChanged( int frame ); - -private: - friend class PopupDropperItemPrivate; - PopupDropperItemPrivate* const d; - -}; - -#endif diff --git a/amarok/src/context/popupdropper/libpud/PopupDropperItem_p.h b/amarok/src/context/popupdropper/libpud/PopupDropperItem_p.h deleted file mode 100644 index 9f164fff..00000000 --- a/amarok/src/context/popupdropper/libpud/PopupDropperItem_p.h +++ /dev/null @@ -1,83 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2008 Jeff Mitchell * - * * - * This program 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 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#ifndef POPUPDROPPER_ITEM_P_H -#define POPUPDROPPER_ITEM_P_H - -#include -#include -#include -#include -#include - -#include "PopupDropperItem.h" - -class PopupDropperItemPrivate -{ - -public: - - PopupDropperItemPrivate( PopupDropperItem* parent ); - - ~PopupDropperItemPrivate(); - - QAction* action; - QString text; - QTimeLine hoverTimer; - QString elementId; - QGraphicsTextItem* textItem; - QGraphicsRectItem* borderRectItem; - QGraphicsSvgItem* svgItem; - QGraphicsRectItem* hoverIndicatorRectItem; - QGraphicsRectItem* hoverIndicatorRectFillItem; - int borderWidth; - int hoverIndicatorRectWidth; - QFont font; - bool submenuTrigger; - QColor baseTextColor; - QColor hoveredTextColor; - QPen hoveredBorderPen; - QBrush hoveredFillBrush; - QBrush hoverIndicatorRectFillBrush; - bool hoveredOver; - bool customBaseTextColor; - bool customHoveredTextColor; - bool customHoveredBorderPen; - bool customHoveredFillBrush; - qreal subitemOpacity; - QString file; - QRect svgElementRect; - QSvgRenderer* sharedRenderer; - int horizontalOffset; - int textOffset; - bool separator; - bool hasLineSeparatorPen; - QPen lineSeparatorPen; - PopupDropperItem::HoverIndicatorShowStyle hoverIndicatorShowStyle; - PopupDropperItem::Orientation orientation; - PopupDropperItem::TextProtection textProtection; - PopupDropperItem::SeparatorStyle separatorStyle; - PopupDropper* pd; - -private: - PopupDropperItem* q; -}; - -#endif - diff --git a/amarok/src/context/popupdropper/libpud/PopupDropperView.cpp b/amarok/src/context/popupdropper/libpud/PopupDropperView.cpp deleted file mode 100644 index 89dc3193..00000000 --- a/amarok/src/context/popupdropper/libpud/PopupDropperView.cpp +++ /dev/null @@ -1,190 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2008 Jeff Mitchell * - * * - * This program 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 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#include "PopupDropperView.h" -#include "PopupDropper.h" -#include "PopupDropper_p.h" -#include "PopupDropperItem.h" - -#include - - - - -#include - -class PopupDropperViewPrivate -{ -public: - PopupDropperViewPrivate( PopupDropper* pd ) - : pd( pd ) - , lastItem( 0 ) - , entered( false ) - {} - - PopupDropper *pd; - PopupDropperItem *lastItem; - bool entered; -}; - -//////////////////////////////////////////////////////////////////////////// - -PopupDropperView::PopupDropperView( PopupDropper *pd, QGraphicsScene *scene, QWidget *parent ) - : QGraphicsView( scene, parent ) - , d( new PopupDropperViewPrivate( pd ) ) -{ - setInteractive( true ); - setAcceptDrops( true ); -} - -PopupDropperView::~PopupDropperView() -{ - delete d; -} - -void PopupDropperView::dragMoveEvent( QDragMoveEvent *event ) -{ - //qDebug() << "PopupDropperView::dragMoveEvent"; - QGraphicsItem* item = itemAt( event->pos() ); - - #define svgitem(x) dynamic_cast(x) - #define textitem(x) dynamic_cast(x) - #define borderitem(x) dynamic_cast(x) - - if( !svgitem(item) && !textitem(item) && !borderitem(item) ) - { - if( d->lastItem ) - d->lastItem->hoverLeft(); - d->lastItem = 0; - } - else if( svgitem(item) && - d->lastItem != dynamic_cast( svgitem(item)->parentItem() ) ) - { - //qDebug() << "svg item"; - if( d->lastItem ) - d->lastItem->hoverLeft(); - static_cast( svgitem(item)->parentItem() )->hoverEntered(); - d->lastItem = static_cast( svgitem(item)->parentItem() ); - } - else if( textitem(item) && - d->lastItem != dynamic_cast( textitem(item)->parentItem() ) ) - { - //qDebug() << "text item"; - if( d->lastItem ) - d->lastItem->hoverLeft(); - static_cast( textitem(item)->parentItem() )->hoverEntered(); - d->lastItem = static_cast( textitem(item)->parentItem() ); - } - else if( borderitem(item) && - d->lastItem != dynamic_cast( borderitem(item)->parentItem() ) ) - { - //qDebug() << "border item"; - if( d->lastItem ) - d->lastItem->hoverLeft(); - static_cast( borderitem(item)->parentItem() )->hoverEntered(); - d->lastItem = static_cast( borderitem(item)->parentItem() ); - } - - #undef borderitem - #undef textitem - #undef pditem - - event->accept(); -} - -void PopupDropperView::dragEnterEvent( QDragEnterEvent *event ) -{ - //qDebug() << "PopupDropperView::dragEnterEvent"; - event->accept(); - d->entered = true; - d->pd->d->dragEntered(); -} - -void PopupDropperView::dragLeaveEvent( QDragLeaveEvent *event ) -{ - //qDebug() << "PopupDropperView::dragLeaveEvent"; - event->accept(); - if( d->lastItem ) - { - d->lastItem->hoverLeft(); - d->lastItem = 0; - } - d->pd->d->dragLeft(); -} - -void PopupDropperView::dropEvent( QDropEvent *event ) -{ - //qDebug() << "PopupDropperView::dropEvent"; - - if( !d->pd->d->amIOnTop( this ) ) - { - event->accept(); - return; - } - - QGraphicsItem* item = itemAt( event->pos() ); - - if( QGraphicsSvgItem *svgItem = dynamic_cast(item) ) - { - //qDebug() << "It's a svg item"; - if( PopupDropperItem *pdi = dynamic_cast( svgItem->parentItem() ) ) - pdi->dropped( event ); - } - else if( QGraphicsTextItem *textItem = dynamic_cast(item) ) - { - //qDebug() << "It's a text item"; - if( PopupDropperItem *pdi = dynamic_cast( textItem->parentItem() ) ) - pdi->dropped( event ); - } - else if( QGraphicsRectItem *borderItem = dynamic_cast(item) ) - { - //qDebug() << "It's a border item"; - if( PopupDropperItem *pdi = dynamic_cast( borderItem->parentItem() ) ) - pdi->dropped( event ); - } - event->accept(); - //qDebug() << "Leaving dropEvent"; -} - -void PopupDropperView::resetView() -{ - d->lastItem = 0; - d->entered = false; - setAcceptDrops( true ); -} - -void PopupDropperView::deactivateHover() -{ - if( d->lastItem ) - d->lastItem->hoverLeft(); - d->lastItem = 0; -} - -bool PopupDropperView::entered() const -{ - return d->entered; -} - -void PopupDropperView::setEntered( bool entered ) -{ - d->entered = entered; -} - -#include "moc_PopupDropperView.cpp" - diff --git a/amarok/src/context/popupdropper/libpud/PopupDropperView.h b/amarok/src/context/popupdropper/libpud/PopupDropperView.h deleted file mode 100644 index f2572e3a..00000000 --- a/amarok/src/context/popupdropper/libpud/PopupDropperView.h +++ /dev/null @@ -1,54 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2008 Jeff Mitchell * - * * - * This program 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 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#ifndef POPUPDROPPER_VIEW_H -#define POPUPDROPPER_VIEW_H - -#include - -class PopupDropper; -class PopupDropperViewPrivate; - -class PopupDropperView : public QGraphicsView -{ - Q_OBJECT - -public: - PopupDropperView( PopupDropper *pd, QGraphicsScene *scene, QWidget *parent ); - ~PopupDropperView(); - - void dropEvent( QDropEvent *event ); - void dragEnterEvent( QDragEnterEvent *event ); - void dragMoveEvent( QDragMoveEvent *event ); - void dragLeaveEvent( QDragLeaveEvent *event ); - - void resetView(); - - void deactivateHover(); - - bool entered() const; - void setEntered( bool entered ); - -private: - friend class PopupDropperViewPrivate; - PopupDropperViewPrivate* const d; -}; - -#endif /* AMAROK_POPUPDROPPER_VIEW_H */ - diff --git a/amarok/src/context/popupdropper/libpud/PopupDropper_Export.h b/amarok/src/context/popupdropper/libpud/PopupDropper_Export.h deleted file mode 100644 index ff8c4962..00000000 --- a/amarok/src/context/popupdropper/libpud/PopupDropper_Export.h +++ /dev/null @@ -1,35 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2008 Jeff Mitchell * - * * - * This program 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 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#ifndef POPUPDROPPER_EXPORT_H -#define POPUPDROPPER_EXPORT_H - -#include - -#ifdef Q_WS_WIN -# if defined(MAKE_POPUPDROPPER_LIB) -# define POPUPDROPPER_EXPORT Q_DECL_EXPORT -# else -# define POPUPDROPPER_EXPORT Q_DECL_IMPORT -# endif -#else -# define POPUPDROPPER_EXPORT Q_DECL_EXPORT -#endif - -#endif diff --git a/amarok/src/context/popupdropper/libpud/PopupDropper_p.h b/amarok/src/context/popupdropper/libpud/PopupDropper_p.h deleted file mode 100644 index e6e96b52..00000000 --- a/amarok/src/context/popupdropper/libpud/PopupDropper_p.h +++ /dev/null @@ -1,99 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2008 Jeff Mitchell * - * * - * This program 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 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#ifndef POPUPDROPPER_P_H -#define POPUPDROPPER_P_H - -#include -#include -#include -#include -#include -#include - -#include "PopupDropper.h" -#include "PopupDropperView.h" - -class QSvgRenderer; -class QWidget; - -class PopupDropperPrivate : public QObject -{ - Q_OBJECT - -public: - PopupDropperPrivate( PopupDropper* parent, bool sa, QWidget* widget ); - ~PopupDropperPrivate(); - - void newSceneView( PopupDropper* pud ); - void setParent( QObject* parent ); - - bool standalone; - QWidget* widget; - QGraphicsScene* scene; - PopupDropperView* view; - PopupDropper::Fading fade; - QTimeLine fadeHideTimer; - QTimeLine fadeShowTimer; - int fadeInTime; - int fadeOutTime; - QTimer deleteTimer; - int deleteTimeout; - int frameMax; - QColor windowColor; - QBrush windowBackgroundBrush; - QColor baseTextColor; - QColor hoveredTextColor; - QPen hoveredBorderPen; - QBrush hoveredFillBrush; - QString file; - QSvgRenderer* sharedRenderer; - int horizontalOffset; - QList pdiItems; - int overlayLevel; - bool entered; - QMap submenuMap; - bool submenu; - QList allItems; - bool quitOnDragLeave; - bool onTop; - QRectF widgetRect; - - //queuedHide: To prevent multiple hide() from being sent if it's already being hidden - bool queuedHide; - - void dragLeft(); - void dragEntered(); - void startDeleteTimer(); - - void reposItems(); - bool amIOnTop( PopupDropperView* pdv ); - -private slots: - void fadeHideTimerFrameChanged( int frame ); - void fadeShowTimerFrameChanged( int frame ); - void fadeShowTimerFinished(); - void fadeHideTimerFinished(); - void deleteTimerFinished(); - -private: - PopupDropper* q; -}; - -#endif //POPUPDROPPER_P_H diff --git a/amarok/src/context/servicetypes/amarok_animator.desktop b/amarok/src/context/servicetypes/amarok_animator.desktop deleted file mode 100644 index 6e211085..00000000 --- a/amarok/src/context/servicetypes/amarok_animator.desktop +++ /dev/null @@ -1,63 +0,0 @@ -[Desktop Entry] -Type=ServiceType -X-KDE-ServiceType=Plasma/Animator - -Comment=Plasma Animation Engine -Comment[bg]=Ядро за Plasma -Comment[bs]=Plazmin pogon podataka animacija -Comment[ca]=Motor d'animació del Plasma -Comment[ca@valencia]=Motor d'animació del Plasma -Comment[cs]=Animační nástroj Plasma -Comment[csb]=Mòtór animacëjów Plasmë -Comment[da]=Motor til Plasma-animation -Comment[de]=Modul für Plasma-Animationen -Comment[el]=Μηχανή κίνησης Plasma -Comment[en_GB]=Plasma Animation Engine -Comment[eo]=Viviga motoro de Plasma -Comment[es]=Motor de animación Plasma -Comment[et]=Plasma animatsiooni mootor -Comment[eu]=Plasma animazioen motorra -Comment[fi]=Plasma-animointimoottori -Comment[fr]=Moteur d'animations de Plasma -Comment[ga]=Inneall Beochana Plasma -Comment[gl]=Motor de animación de Plasma -Comment[hi]=प्लाज्मा एनिमेशन इंजिन -Comment[hne]=प्लाज्मा एनिमेसन इंजिन -Comment[hu]=Motor Plasma-animációkhoz -Comment[id]=Mesin Animasi Plasma -Comment[is]=Plasma hreyfingastjóri -Comment[it]=Motore animazione di Plasma -Comment[ja]=Plasma アニメーションエンジン -Comment[km]=ម៉ាស៊ីន​ចលនា​ប្លាស្មា -Comment[ko]=Plasma 애니메이션 엔진 -Comment[ku]=Motora Zindîkirina Plasma -Comment[lt]=Plasma animacijos sistema -Comment[lv]=Plasma animācijas dzinējs -Comment[mai]=प्लाजमा भावचिन्ह इंजन -Comment[mr]=प्लाज्मा एनीमेशन इंजिन -Comment[nb]=Animasjonsmotor for Plasma -Comment[nds]=Animeerkarn Plasma -Comment[nl]=Plasma animatie-engine -Comment[nn]=Plasma-animasjonsmotor -Comment[pa]=ਪਲਾਜ਼ਮਾ ਐਨੀਮੇਸ਼ਨ ਇੰਜਣ -Comment[pl]=Moduł animacji Plazmy -Comment[pt]=Motor de Animação do Plasma -Comment[pt_BR]=Mecanismo de animação do Plasma -Comment[ro]=Motor de animație Plasma -Comment[ru]=Движок анимации Plasma -Comment[sk]=Animačný nástroj Plasma -Comment[sl]=Animacijski pogon za Plasmo -Comment[sr]=Плазмин мотор анимација -Comment[sr@ijekavian]=Плазмин мотор анимација -Comment[sr@ijekavianlatin]=Plasmin motor animacija -Comment[sr@latin]=Plasmin motor animacija -Comment[sv]=Animeringsgränssnitt för Plasma -Comment[th]=กลไกของพลาสมา สำหรับทำภาพเคลื่อนไหว -Comment[tr]=Plasma Canlandırma Motoru -Comment[ug]=Plasma جانلاندۇرۇم ماتورى -Comment[uk]=Рушій анімації Плазми -Comment[wa]=Éndjin d' animåcion Plasma -Comment[x-test]=xxPlasma Animation Enginexx -Comment[zh_CN]=Plasma 动画引擎 -Comment[zh_TW]=Plasma 動畫引擎 - diff --git a/amarok/src/context/servicetypes/amarok_containment.desktop b/amarok/src/context/servicetypes/amarok_containment.desktop deleted file mode 100644 index 89ff3922..00000000 --- a/amarok/src/context/servicetypes/amarok_containment.desktop +++ /dev/null @@ -1,61 +0,0 @@ -[Desktop Entry] -Type=ServiceType -X-KDE-ServiceType=Plasma/Containment - -Comment=Plasma applet container and background painter -Comment[bg]=Аплет за Plasma и фон -Comment[bs]=Sadržalac za plazma aplete i iscrtavač pozadine -Comment[ca]=Contenidor de miniaplicació del Plasma i pintor de fons -Comment[ca@valencia]=Contenidor de miniaplicació del Plasma i pintor de fons -Comment[cs]=Kontejner apletů a vykreslovač pozadí Plasma -Comment[da]=Beholder til Plasma-applet og tegning af baggrund -Comment[de]=Plasma-Miniprogramm-Behälter und Hintergrund-Zeichenprogramm -Comment[el]=Υποδοχέας μικροεφαρμογής Plasma και σχεδιαστής φόντου -Comment[en_GB]=Plasma applet container and background painter -Comment[eo]=Plasma apletujo kaj fonpentrilo -Comment[es]=Contenedor para la miniaplicación de Plasma y un pintor de fondo -Comment[et]=Plasma apleti konteiner ja tausta joonistaja -Comment[eu]=Plasma miniaplikazioaren edukiontzia eta atzeko planoaren margolaria -Comment[fi]=Plasma-sovelmasäiliö ja taustan piirrin -Comment[fr]=Conteneur du composant graphique Plasma et dessinateur d'arrière-plan -Comment[ga]=Coimeádán feidhmchláiríní Plasma agus péintéir cúlra -Comment[gl]=Un contedor de applet de Plasma e pintor do fondo -Comment[hne]=प्लाज्मा एपलेट कंटेनर अउ पिछोत अंगना पुतइया -Comment[hu]=Tároló Plasma-kisalkalmazásokhoz, háttérrajzoló -Comment[id]=Plasma applet wadah dan pelukis latar belakang -Comment[is]=Ílát og bakgrunnsmálari fyrir Plasma smáforrit -Comment[it]=Contenitore applet Plasma e creazione sfondo -Comment[ja]=Plasma アプレットのコンテナおよび背景描画 -Comment[km]=ឧបករណ៍​ផ្ទុក​អាប់ភ្លេត​ប្លាស្មា និង​ឧបករណ៍​គូរ​ផ្ទៃ​ខាង​ក្រោយ -Comment[ko]=Plasma 애플릿 컨테이너 및 배경 칠하는 도구 -Comment[ku]=Plasma bergeha apletan û renkdarkerê rûerdê -Comment[lt]=Plasma įskiepio langas ir fono piešimas -Comment[lv]=Plasma sīkrīku konteiners un fona zīmētājs -Comment[mai]=प्लाजमा एप्पलेट कंटेनर आओर पृष्ठभूमि पेंटर -Comment[mr]=प्लाज्मा एप्लेट कंटेनर व बेकग्राउंड पेंटर -Comment[nb]=Panelbeholder og bakgrunnsopptegner for Plasma -Comment[nds]=Lüttprogramm-Gelaats un Achtergrundmaler för Plasma -Comment[nl]=Container en achtergrond voor Plasma-applet -Comment[nn]=Plasma-behaldar og bakgrunnsmålar -Comment[pa]=ਪਲਾਜ਼ਮਾ ਐਪਲਿਟ ਕੰਨਟੇਨਰ ਅਤੇ ਬੈਕਗਰਾਊਂਡ ਪੇਂਟਰ -Comment[pl]=Zasobnik i malarz tła Plazmy -Comment[pt]=Contentor de 'applets' do Plasma e pintor do fundo -Comment[pt_BR]=Recipiente de miniaplicativos do Plasma e pintor de plano de fundo -Comment[ro]=Container de miniaplicații Plasma și desenator de fundal -Comment[ru]=Контейнер и модуль отрисовки виджета Plasma -Comment[sk]=Kontainer appletov a vykresľovač pozadia -Comment[sl]=Vsebnik apletov in izrisovalnik ozadja za Plasmo -Comment[sr]=Садржалац за плазма аплете и исцртавач позадине -Comment[sr@ijekavian]=Садржалац за плазма аплете и исцртавач позадине -Comment[sr@ijekavianlatin]=Sadržalac za plasma aplete i iscrtavač pozadine -Comment[sr@latin]=Sadržalac za plasma aplete i iscrtavač pozadine -Comment[sv]=Plasma miniprogrambehållare och bakgrundsuppritning -Comment[th]=ส่วนบรรจุแอพเพล็ตและส่วนวาดพื้นหลังของพลาสมา -Comment[tr]=Plasma programcık taşıyıcısı ve arkaplan boyacısı -Comment[ug]=Plasma قاچا ھەرىكىتى ۋە تەگلىك سىزغۇچ -Comment[uk]=Контейнер аплетів плазми і малювання у тлі -Comment[wa]=Aplikete contneu di Plasma eyet pondeu do fond -Comment[x-test]=xxPlasma applet container and background painterxx -Comment[zh_CN]=Plasma 挂件容器和背景绘制器 -Comment[zh_TW]=Plasma 應用容器與背景上色器 - diff --git a/amarok/src/context/servicetypes/amarok_context_applet.desktop b/amarok/src/context/servicetypes/amarok_context_applet.desktop deleted file mode 100644 index 48f07069..00000000 --- a/amarok/src/context/servicetypes/amarok_context_applet.desktop +++ /dev/null @@ -1,60 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Type=ServiceType -X-KDE-ServiceType=Plasma/Applet - -Comment=Amarok Context applet -Comment[bg]=Аплет за контекст (Amarok) -Comment[bs]=Kontekstni aplet za Amarok -Comment[ca]=Miniaplicació Amarok Context -Comment[ca@valencia]=Miniaplicació Amarok Context -Comment[cs]=Applet Amarok Kontext -Comment[csb]=Aplet kòntekstu Amaroka -Comment[da]=Amarok kontekst-applet -Comment[de]=Amarok-Kontext-Miniprogramm -Comment[el]=Μικροεφαρμογή περιεχομένου Amarok -Comment[en_GB]=Amarok Context applet -Comment[eo]=Amarok kunteksta apleto -Comment[es]=Miniaplicación de contexto de Amarok -Comment[et]=Amaroki konteksti aplett -Comment[eu]=Amarok-en testuinguruko miniaplikazioa -Comment[fi]=Amarok-kontekstisovelma -Comment[fr]=Composant graphique de contexte de Amarok -Comment[ga]=Feidhmchláirín Comhthéacs Amarok -Comment[gl]=Applet de contexto de Amarok -Comment[he]=ישומון תוכן של Amarok -Comment[hne]=अमाराक संदर्भ ऐप्लेट -Comment[hu]=Környezet-kisalkalmazás az Amarokhoz -Comment[id]=Applet Konteks Amarok -Comment[is]=Amarok samhengissmáforrit -Comment[it]=Applet Contesto di Amarok -Comment[ja]=Amarok 関連情報アプレット -Comment[km]=អាប់ភ្លេត​បរិបទ​របស់ Amarok -Comment[ko]=Amarok 컨텍스트 애플릿 -Comment[ku]=Apleta Naveroka Amarok -Comment[lt]=Amarok informacijos įskiepis -Comment[lv]=Amarok konteksta sīkrīks -Comment[nb]=Amarok kontekstpanel -Comment[nds]=Amarok Kontext-Lüttprogramm -Comment[nl]=Amarok-contextapplet -Comment[nn]=Amarok Context-element -Comment[pa]=ਅਮਰੋਕ ਪਰਸੰਗ ਐਪਲਿਟ -Comment[pl]=Aplet kontekstu Amaroka -Comment[pt]='Applet' de Contexto do Amarok -Comment[pt_BR]=Miniaplicativo de contexto do Amarok -Comment[ro]=Miniaplicație contextuală Amarok -Comment[ru]=Аплет контекста для Amarok -Comment[sk]=Applet Amarok kontext -Comment[sl]=Programček za Amarokovo vsebino -Comment[sr]=Контекстни аплет за Амарок -Comment[sr@ijekavian]=Контекстни аплет за Амарок -Comment[sr@ijekavianlatin]=Kontekstni aplet za Amarok -Comment[sr@latin]=Kontekstni aplet za Amarok -Comment[sv]=Sammanhangsminiprogram för Amarok -Comment[th]=แอพเพล็ตคอนเท็กซ์ของแอมอะร็อก -Comment[tr]=Amarok İçerik programcığı -Comment[uk]=Аплет контексту Amarok -Comment[wa]=Aplikete di contecse d' Amarok -Comment[x-test]=xxAmarok Context appletxx -Comment[zh_CN]=Amarok 环境挂件 -Comment[zh_TW]=Amarok 內容應用小程式 diff --git a/amarok/src/context/servicetypes/amarok_data_engine.desktop b/amarok/src/context/servicetypes/amarok_data_engine.desktop deleted file mode 100644 index 01c68aea..00000000 --- a/amarok/src/context/servicetypes/amarok_data_engine.desktop +++ /dev/null @@ -1,117 +0,0 @@ -[Desktop Entry] -Name=Amarok Data Engine -Name[bg]=Ядро Amarok -Name[bs]=Pogon podataka Amaroka -Name[ca]=Motor de dades de l'Amarok -Name[ca@valencia]=Motor de dades de l'Amarok -Name[cs]=Datový nástroj Amarok -Name[csb]=Mòtór pòdôwków Amaroka -Name[da]=Datamotor til Amarok -Name[de]=Amarok-Datenmodul -Name[el]=Μηχανή δεδομένων Amarok -Name[en_GB]=Amarok Data Engine -Name[es]=Motor de datos de Amarok -Name[et]=Amaroki andmemootor -Name[eu]=Amarok-eko datuen motorra -Name[fi]=Amarok-tietomoottori -Name[fr]=Moteur de données pour Amarok -Name[ga]=Inneall Sonraí Amarok -Name[gl]=Motor de dados de Amarok -Name[he]=מנוע המידע של Amarok -Name[hne]=अमाराक डाटा इंजिन -Name[hu]=Amarok-adatmotor -Name[id]=Mesin Data Amarok -Name[is]=Amarok gagnavél -Name[it]=Motore dati di Amarok -Name[ja]=Amarok データエンジン -Name[km]=ម៉ាស៊ីន​ទិន្នន័យ Amarok -Name[ko]=Amarok 데이터 엔진 -Name[ku]=Motora Dane ya Amarok -Name[lt]=Amarok duomenų sistema -Name[lv]=Amarok datu dzinējs -Name[nb]=Datamotor for Amarok -Name[nds]=Amarok-Datenkarn -Name[nl]=Amarok-gegevensengine -Name[nn]=Amarok-datamotor -Name[pa]=ਅਮਰੋਕ ਡਾਟਾ ਇੰਜਣ -Name[pl]=Moduł danych Amaroka -Name[pt]=Motor de Dados do Amarok -Name[pt_BR]=Mecanismo de dados do Amarok -Name[ro]=Motor de date Amarok -Name[ru]=Источник данных Amarok -Name[sk]=Dátový nástroj Amarok -Name[sl]=Podatkovni pogon za Amarok -Name[sr]=Датомотор Амарока -Name[sr@ijekavian]=Датомотор Амарока -Name[sr@ijekavianlatin]=Datomotor Amaroka -Name[sr@latin]=Datomotor Amaroka -Name[sv]=Datagränssnitt för Amarok -Name[th]=กลไกข้อมูลของแอมอะร็อก -Name[tr]=Amarok Veri Motoru -Name[uk]=Рушій даних Amarok -Name[wa]=Éndjin d' dinêyes Amarok -Name[x-test]=xxAmarok Data Enginexx -Name[zh_CN]=Amarok 数据引擎 -Name[zh_TW]=Amarok 資料引擎 -Type=ServiceType -X-KDE-ServiceType=Plasma/DataEngine - -Comment=Amarok Data Engine -Comment[bg]=Ядро Amarok -Comment[bs]=Pogon podataka Amaroka -Comment[ca]=Motor de dades de l'Amarok -Comment[ca@valencia]=Motor de dades de l'Amarok -Comment[cs]=Datový nástroj Amarok -Comment[csb]=Mòtór pòdôwków Amaroka -Comment[da]=Datamotor til Amarok -Comment[de]=Amarok-Datenmodul -Comment[el]=Μηχανή δεδομένων Amarok -Comment[en_GB]=Amarok Data Engine -Comment[eo]=Datuma motoro de Amarok -Comment[es]=Motor de datos de Amarok -Comment[et]=Amaroki andmemootor -Comment[eu]=Amarok-eko datuen motorra -Comment[fi]=Amarok-tietomoottori -Comment[fr]=Moteur de données pour Amarok -Comment[ga]=Inneall Sonraí Amarok -Comment[gl]=Motor de dados de Amarok -Comment[he]=מנוע המידע של Amarok -Comment[hne]=अमाराक डाटा इंजिन -Comment[hu]=Amarok-adatmotor -Comment[id]=Mesin Data Amarok -Comment[is]=Amarok gagnavél -Comment[it]=Motore dati di Amarok -Comment[ja]=Amarok データエンジン -Comment[km]=ម៉ាស៊ីន​ទិន្នន័យ Amarok -Comment[ko]=Amarok 데이터 엔진 -Comment[ku]=Motora Dane ya Amarok -Comment[lt]=Amarok duomenų sistema -Comment[lv]=Amarok datu dzinējs -Comment[nb]=Datamotor for Amarok -Comment[nds]=Amarok-Datenkarn -Comment[nl]=Amarok-gegevensengine -Comment[nn]=Amarok-datamotor -Comment[pa]=ਅਮਰੋਕ ਡਾਟਾ ਇੰਜਣ -Comment[pl]=Moduł danych Amaroka -Comment[pt]=Motor de Dados do Amarok -Comment[pt_BR]=Mecanismo de dados do Amarok -Comment[ro]=Motor de date Amarok -Comment[ru]=Источник данных Amarok -Comment[sk]=Dátový nástroj Amarok -Comment[sl]=Podatkovni pogon za Amarok -Comment[sr]=Датомотор Амарока -Comment[sr@ijekavian]=Датомотор Амарока -Comment[sr@ijekavianlatin]=Datomotor Amaroka -Comment[sr@latin]=Datomotor Amaroka -Comment[sv]=Datagränssnitt för Amarok -Comment[th]=กลไกข้อมูลของแอมอะร็อก -Comment[tr]=Amarok Veri Motoru -Comment[uk]=Рушій даних Amarok -Comment[wa]=Éndjin d' dinêyes Amarok -Comment[x-test]=xxAmarok Data Enginexx -Comment[zh_CN]=Amarok 数据引擎 -Comment[zh_TW]=Amarok 資料引擎 - -[PropertyDef::X-KDE-PluginInfo-Name] -Type=QString - diff --git a/amarok/src/context/toolbar/AppletItemOverlay.cpp b/amarok/src/context/toolbar/AppletItemOverlay.cpp deleted file mode 100644 index e9706565..00000000 --- a/amarok/src/context/toolbar/AppletItemOverlay.cpp +++ /dev/null @@ -1,373 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Leo Franchi * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "AppletItemOverlay" - -#include "AppletItemOverlay.h" - -#include "context/toolbar/AppletToolbarAppletItem.h" -#include "core/support/Debug.h" - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -// stolen verbatim and shamelessly from workspace/plasma/shells/desktop/panelappletoverlay -class AppletMoveSpacer : public QGraphicsWidget -{ -public: - AppletMoveSpacer( QGraphicsWidget *applet ) - : QGraphicsWidget( applet ) - { - } - -protected: - void paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget * widget = 0 ) - { - Q_UNUSED( option ) - Q_UNUSED( widget ) - - //TODO: make this a pretty gradient? - painter->setRenderHint( QPainter::Antialiasing ); - QPainterPath p = Plasma::PaintUtils::roundedRectangle( contentsRect().adjusted( 1, 1, -2, -2 ), 4 ); - QColor c = Plasma::Theme::defaultTheme()->color( Plasma::Theme::TextColor ); - c.setAlphaF( 0.3 ); - - painter->fillPath( p, c ); - } -}; - - -Context::AppletItemOverlay::AppletItemOverlay( Context::AppletToolbarAppletItem *applet, QGraphicsLinearLayout* layout, QWidget *parent ) - : QWidget( parent ), - m_applet( applet ), - m_spacer(0), - m_layout( layout ), - m_deleteIcon( 0 ), - m_index( 0 ), - m_itemHasSwapped( false ) -{ - DEBUG_BLOCK - - if( layout ) - { - m_layout = layout; - int i = 0; - for(; i < m_layout->count(); ++i) - { - QGraphicsWidget *w = dynamic_cast< QGraphicsWidget* >( m_layout->itemAt( i ) ); - if( w == m_applet ) - { - m_index = i; - break; - } - } - } else - debug() << "GOT APPLET WITH NO LAYOUT! BAD!"; - - m_deleteIcon = new QToolButton( this ); - QAction* delApplet = new QAction( i18n( "Remove Applet" ), this ); - delApplet->setIcon( KIcon( "edit-delete" ) ); - delApplet->setVisible( true ); - delApplet->setEnabled( true ); - m_deleteIcon->addAction( delApplet ); - m_deleteIcon->setIcon( KIcon( "edit-delete" ) ); - m_deleteIcon->setMaximumSize( 24, 24 ); - QColor trans; - trans.setAlpha( 0 ); - QBrush brush( Qt::transparent ); - QPalette pal = m_deleteIcon->palette(); - pal.setBrush( QPalette::Window, brush ); - // m_deleteIcon->setBackgroundRole( QPalette::Base ); - m_deleteIcon->setPalette( pal ); - m_deleteIcon->setAutoFillBackground( false ); - m_deleteIcon->setAttribute( Qt::WA_NoSystemBackground ); - //m_deleteIcon->setAttribute( Qt::WA_TranslucentBackground ); //NB: Introduced in Qt 4.5 - - connect( delApplet, SIGNAL(triggered()), this, SLOT(deleteApplet()) ); - connect( m_deleteIcon, SIGNAL(released()), this, SLOT(deleteApplet()) ); - - syncGeometry(); - - connect( m_applet, SIGNAL(destroyed(QObject*)), this, SLOT(deleteLater()) ); - connect( m_applet, SIGNAL(geometryChanged()), this, SLOT(delaySyncGeometry()) ); -} - -Context::AppletItemOverlay::~AppletItemOverlay() -{ - QApplication::restoreOverrideCursor(); - - if( m_spacer ) - { - m_layout->removeItem( m_spacer ); - m_spacer->deleteLater(); - m_spacer = 0; - } - m_applet = 0; - m_layout = 0; -} - -void -Context::AppletItemOverlay::paintEvent( QPaintEvent *event ) -{ - Q_UNUSED( event ) - QStyleOption op; - op.initFrom( this ); - - bool hovered = op.state & QStyle::State_MouseOver; - bool mover = mouseGrabber() == this; - if( !hovered || mover ) - { - return; - } - - QPainter p( this ); - p.save(); - KIcon icon( "transform-move" ); - int iconSize; - QRect iconRect; - - if( m_applet ) - { // it's possible m_applet is null if we just opened amarok and it failed to load the applet plugin - // so the user is seeing a big red X and trying to get rid of item - iconSize = qMin( qMin( height(), int( m_applet->size().width() ) ), 64 ); - iconRect = QRect( rect().center() - QPoint( iconSize / 2, iconSize / 2 ), QSize( iconSize, iconSize ) ); - p.drawPixmap( iconRect, icon.pixmap( iconSize, iconSize ) ); - } - - p.restore(); -} - -void -Context::AppletItemOverlay::mousePressEvent( QMouseEvent *event ) -{ - Q_UNUSED( event ) - DEBUG_BLOCK - - m_itemHasSwapped = false; - - if( !m_spacer ) - { - m_spacer = new AppletMoveSpacer( m_applet ); - } else - { - m_layout->removeItem( m_spacer ); - } - - m_origin = mapToParent( event->pos() ); - m_spacer->setMinimumSize( m_applet->geometry().size() ); - m_spacer->setMaximumSize( m_applet->geometry().size() ); - m_layout->removeItem( m_applet ); - m_layout->insertItem( m_index, m_spacer ); - m_applet->setZValue( m_applet->zValue() + 1 ); - - m_offset = geometry().x() - m_origin.x(); - - QApplication::setOverrideCursor( Qt::ClosedHandCursor ); - grabMouse(); -} - -void -Context::AppletItemOverlay::mouseMoveEvent( QMouseEvent *event ) -{ - if( !m_spacer ) - { - m_spacer = new AppletMoveSpacer( m_applet ); - m_spacer->setMinimumSize( m_applet->geometry().size() ); - m_spacer->setMaximumSize( m_applet->geometry().size() ); - m_layout->removeItem( m_applet ); - m_layout->insertItem( m_index, m_spacer ); - } - - QPoint p = mapToParent( event->pos() ); - QRectF g = m_applet->geometry(); - - g.moveLeft( p.x() + m_offset ); - - m_applet->setGeometry( g ); - - // find position of the config item (always last item) - QGraphicsLayoutItem *lastItem = m_layout->itemAt( m_layout->count() - 1 ); - - // swap items if we move further than two thirds across the next/previous item - if( !m_itemHasSwapped ) - { - if( m_prevGeom.isValid() && g.left() <= m_prevGeom.left() + m_prevGeom.width() / 3 ) - { - swapWithPrevious(); - m_itemHasSwapped = true; - } - else if( m_nextGeom.isValid() && ( g.right() >= m_nextGeom.right() - m_nextGeom.width() / 3 ) && ( g.right() < lastItem->geometry().left() ) ) - { - swapWithNext(); - m_itemHasSwapped = true; - } - } - - if( ( m_prevGeom.isValid() && g.left() <= m_prevGeom.left() ) || ( m_nextGeom.isValid() && g.right() >= m_nextGeom.right() ) ) - m_itemHasSwapped = false; -} - -void -Context::AppletItemOverlay::mouseReleaseEvent( QMouseEvent *event ) -{ - Q_UNUSED( event ) - DEBUG_BLOCK - - QApplication::restoreOverrideCursor(); - releaseMouse(); - - if( !m_spacer ) - return; - - m_layout->removeItem( m_spacer ); - m_spacer->deleteLater(); - m_spacer = 0; - - m_layout->insertItem( m_index, m_applet ); - m_applet->setZValue( m_applet->zValue() - 1 ); // -1 means not specifying where it is from - - emit moveApplet( m_applet->applet(), -1, m_index ); -} - -void -Context::AppletItemOverlay::enterEvent( QEvent *event ) -{ - Q_UNUSED( event ) - update(); -} - -void -Context::AppletItemOverlay::leaveEvent( QEvent *event ) -{ - Q_UNUSED( event ) - update(); -} - - -Context::AppletToolbarAppletItem* -Context::AppletItemOverlay::applet() -{ - return m_applet; -} - - -void -Context::AppletItemOverlay::resizeEvent( QResizeEvent* ) -{ - m_deleteIcon->setGeometry( QRect( QPoint( ( size().width() - (m_deleteIcon->size().width() ) ) , 0 ), m_deleteIcon->geometry().size() ) ); -} - -void -Context::AppletItemOverlay::deleteApplet() -{ - emit deleteApplet( dynamic_cast< Plasma::Applet* >( m_applet->applet() ) ); - m_applet = 0; - deleteLater(); -} - -void -Context::AppletItemOverlay::swapWithPrevious() -{ - DEBUG_BLOCK - - m_index -= 1; - - if( m_index > 1 ) - { - QGraphicsLayoutItem* layout = m_layout->itemAt( m_index - 1 ); - m_prevGeom = layout ? layout->geometry() : QRectF(); - } - else - { - m_prevGeom = QRectF(); - } - - QGraphicsLayoutItem* layout = m_layout->itemAt( m_index + 1 ); - m_nextGeom = layout ? layout->geometry() : QRectF(); - - m_layout->removeItem( m_spacer ); - m_layout->insertItem( m_index, m_spacer ); -} - -void -Context::AppletItemOverlay::swapWithNext() -{ - DEBUG_BLOCK - m_index += 1; - - if ( m_index < m_layout->count() - 1 ) { - m_nextGeom = m_layout->itemAt( m_index + 1)->geometry(); - } else - { - m_nextGeom = QRectF(); - } - - m_prevGeom = m_layout->itemAt( m_index - 1 )->geometry(); - m_layout->removeItem( m_spacer ); - m_layout->insertItem( m_index, m_spacer ); -} - -void -Context::AppletItemOverlay::delaySyncGeometry() -{ - // we need to do this because it gets called in a round-about-way - // from our own mouseMoveEvent. if we call syncGeometry directly, - // we end up with a maze of duplicated and confused mouseMoveEvents - // of which only half are real (the other half being caused by the - // immediate call to syncGeometry!) - QTimer::singleShot( 0, this, SLOT(syncGeometry()) ); -} - -void -Context::AppletItemOverlay::syncGeometry() -{ - // DEBUG_BLOCK - setGeometry( m_applet->geometry().toRect() ); - // debug() << "setting overlay geometry to" << m_applet->geometry().toRect(); - - if( m_index > 0 ) - { - if( m_layout->itemAt( m_index - 1 ) ) - m_prevGeom = m_layout->itemAt( m_index - 1 )->geometry(); - } else - { - m_prevGeom = QRectF(); - } - - if( m_index < m_layout->count() - 1 ) - { - if( m_layout->itemAt( m_index + 1 ) ) - m_nextGeom = m_layout->itemAt( m_index + 1 )->geometry(); - } else - { - m_nextGeom = QRectF(); - } - //debug() << m_index << m_layout->count() << m_prevGeom << m_nextGeom; -} - -#include "moc_AppletItemOverlay.cpp" diff --git a/amarok/src/context/toolbar/AppletItemOverlay.h b/amarok/src/context/toolbar/AppletItemOverlay.h deleted file mode 100644 index d32f26b3..00000000 --- a/amarok/src/context/toolbar/AppletItemOverlay.h +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Leo Franchi * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_APPLET_ITEM_OVERLAY_H -#define AMAROK_APPLET_ITEM_OVERLAY_H - -#include - -class QGraphicsLinearLayout; -class QGraphicsWidget; -class QToolButton; - -// NOTE inspiration and code taken from kdebase/workspace/plasma/shells/desktop/panelappletoverlay.{h,cpp} - -namespace Plasma -{ - class Applet; -} - -namespace Context -{ - -class Applet; -class AppletToolbarAppletItem; - -class AppletItemOverlay : public QWidget -{ - Q_OBJECT - -public: - AppletItemOverlay(AppletToolbarAppletItem *applet, QGraphicsLinearLayout* layout, QWidget *parent); - ~AppletItemOverlay(); - - AppletToolbarAppletItem* applet(); -protected: - virtual void resizeEvent( QResizeEvent* ); - virtual void paintEvent(QPaintEvent *event); - virtual void mousePressEvent(QMouseEvent *event); - virtual void mouseMoveEvent(QMouseEvent *event); - virtual void mouseReleaseEvent(QMouseEvent *event); - virtual void enterEvent(QEvent *event); - virtual void leaveEvent(QEvent *event); - -signals: - void moveApplet( Plasma::Applet*, int, int ); - void deleteApplet( Plasma::Applet* ); - -private slots: - void deleteApplet(); - void delaySyncGeometry(); - void syncGeometry(); - -private: - void swapWithPrevious(); - void swapWithNext(); - - AppletToolbarAppletItem *m_applet; - QGraphicsWidget *m_spacer; - QGraphicsLinearLayout *m_layout; - QRectF m_prevGeom; - QRectF m_nextGeom; - QPoint m_origin; - QToolButton* m_deleteIcon; - int m_offset; - int m_index; - bool m_itemHasSwapped; -}; - -} - -#endif diff --git a/amarok/src/context/toolbar/AppletToolbar.cpp b/amarok/src/context/toolbar/AppletToolbar.cpp deleted file mode 100644 index 78ee96d6..00000000 --- a/amarok/src/context/toolbar/AppletToolbar.cpp +++ /dev/null @@ -1,181 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Leo Franchi * - * Copyright (c) 2009 Mark Kretschmann * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "AppletToolbar.h" - -#include "App.h" -#include "PaletteHandler.h" -#include "context/toolbar/AppletToolbarAddItem.h" -#include "context/toolbar/AppletToolbarAppletItem.h" -#include "context/toolbar/AppletToolbarConfigItem.h" -#include "context/Containment.h" -#include "core/support/Amarok.h" -#include "core/support/Debug.h" - -#include -#include -#include -#include -#include -#include -#include - -Context::AppletToolbar::AppletToolbar( QGraphicsItem* parent ) - : QGraphicsWidget( parent ) - , m_configMode( false ) - , m_appletLayout( 0 ) - , m_cont( 0 ) - , m_configItem( 0 ) -{ - Context::Containment* cont = dynamic_cast( parent ); - if( cont ) - { - m_cont = cont; - debug() << "applettoolbar created with a real containment"; - } - - setAcceptDrops( true ); - - m_appletLayout = new QGraphicsLinearLayout( Qt::Horizontal, this ); - - m_appletLayout->setContentsMargins( 3, 3, 3, 3 ); - m_appletLayout->setSpacing( 4 ); - - m_configItem = new AppletToolbarConfigItem( this ); - connect( m_configItem, SIGNAL(triggered()), this, SLOT(toggleConfigMode()) ); - m_appletLayout->addItem( m_configItem ); - m_appletLayout->setAlignment( m_configItem, Qt::AlignRight ); - m_appletLayout->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Fixed ); -} - -Context::AppletToolbar::~AppletToolbar() -{ -} - -void - -Context::AppletToolbar::setContainment( Containment * containment ) -{ - m_cont = containment; -} - -Context::Containment * -Context::AppletToolbar::containment() const -{ - return m_cont; -} - -void -Context::AppletToolbar::resizeEvent( QGraphicsSceneResizeEvent *event ) -{ - m_appletLayout->setGeometry( QRectF( QPointF( 0, 0 ), event->newSize() ) ); -} - -QSizePolicy -Context::AppletToolbar::sizePolicy () const -{ - return QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); -} - -bool -Context::AppletToolbar::configEnabled() const -{ - return m_configMode; -} - -QGraphicsLinearLayout* -Context::AppletToolbar::appletLayout() const -{ - return m_appletLayout; -} - - -// this takes care of the cleanup after the applet has been removed from the containment itself -void -Context::AppletToolbar::appletRemoved( Plasma::Applet* applet ) -{ - DEBUG_BLOCK - for( int i = 0; i < m_appletLayout->count(); i++ ) - { - AppletToolbarAppletItem* app = static_cast( m_appletLayout->itemAt(i) ); - if( app && app->applet() == applet ) - { - m_appletLayout->removeItem( app ); - app->deleteLater(); - } - } -} - -QSizeF -Context::AppletToolbar::sizeHint( Qt::SizeHint which, const QSizeF &constraint ) const -{ - Q_UNUSED( which ) - return QSizeF( constraint.width(), constraint.height() ); -} - - -void -Context::AppletToolbar::mousePressEvent( QGraphicsSceneMouseEvent *event ) -{ - Q_UNUSED( event ) -} - -// called when the containment is done successfully adding the applet, updates the toolbar -void -Context::AppletToolbar::appletAdded( Plasma::Applet* applet, int loc ) // SLOT -{ - DEBUG_BLOCK - - debug() << "inserting applet icon in position" << loc; - Context::AppletToolbarAppletItem* item = new Context::AppletToolbarAppletItem( this, applet ); - item->setConfigEnabled( m_configMode ); - connect( item, SIGNAL(appletChosen(Plasma::Applet*)), - this, SIGNAL(showApplet(Plasma::Applet*)) ); - - // add the item - m_appletLayout->insertItem( loc, item ); - - // notifications for others who need to know when the layout is done adding the applet - emit appletAddedToToolbar( applet, loc ); -} - -void -Context::AppletToolbar::toggleConfigMode() // SLOT -{ - DEBUG_BLOCK - if( !m_configMode ) - { - m_configMode = true; - emit showAppletExplorer(); - } - else - { - for( int i = 0; i < m_appletLayout->count(); i++ ) // tell each applet we are done configuring - { - Context::AppletToolbarAppletItem* appletItem = dynamic_cast< Context::AppletToolbarAppletItem* >( m_appletLayout->itemAt( i ) ); - if( appletItem ) - appletItem->setConfigEnabled( false ); - } - - m_configMode = false; - - emit hideAppletExplorer(); - } - emit configModeToggled(); -} - -#include "moc_AppletToolbar.cpp" diff --git a/amarok/src/context/toolbar/AppletToolbar.h b/amarok/src/context/toolbar/AppletToolbar.h deleted file mode 100644 index 058baaed..00000000 --- a/amarok/src/context/toolbar/AppletToolbar.h +++ /dev/null @@ -1,93 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Leo Franchi * - * Copyright (c) 2009 Mark Kretschmann * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_APPLET_TOOLBAR_H -#define AMAROK_APPLET_TOOLBAR_H - -#include "amarok_export.h" - -#include - -class QGraphicsItem; -class QGraphicsSceneResizeEvent; -class QPainter; -class QStyleOptionGraphicsItem; -class QSizePolicy; -class QGraphicsLinearLayout; - -// this provides a simple toolbar to switch between applets in the CV -namespace Plasma -{ - class Applet; -} - -namespace Context -{ - -class AppletToolbarAddItem; -class AppletToolbarConfigItem; -class Containment; - -class AppletToolbar : public QGraphicsWidget -{ - Q_OBJECT - public: - AppletToolbar( QGraphicsItem* parent = 0 ); - ~AppletToolbar(); - - QSizePolicy sizePolicy () const; - QGraphicsLinearLayout* appletLayout() const; - bool configEnabled() const; - - void appletRemoved( Plasma::Applet* applet ); - - void setContainment( Containment * containment ); - Containment* containment() const; - - signals: - void showApplet( Plasma::Applet* ); - void appletAddedToToolbar( Plasma::Applet* applet, int loc ); - void moveApplet( Plasma::Applet*, int, int ); - void configModeToggled(); - void hideAppletExplorer(); - void showAppletExplorer(); - - protected: - virtual QSizeF sizeHint( Qt::SizeHint which, const QSizeF & constraint = QSizeF() ) const; - virtual void resizeEvent( QGraphicsSceneResizeEvent * event ); - virtual void mousePressEvent( QGraphicsSceneMouseEvent *event ); - - private slots: - void appletAdded( Plasma::Applet*, int ); - void toggleConfigMode(); - - private: - void newAddItem( int loc ); - - qreal m_width; - - bool m_configMode; - - QGraphicsLinearLayout* m_appletLayout; - - Containment* m_cont; - AppletToolbarConfigItem* m_configItem; -}; - -} - -#endif diff --git a/amarok/src/context/toolbar/AppletToolbarAddItem.cpp b/amarok/src/context/toolbar/AppletToolbarAddItem.cpp deleted file mode 100644 index 705cfcc4..00000000 --- a/amarok/src/context/toolbar/AppletToolbarAddItem.cpp +++ /dev/null @@ -1,153 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Leo Franchi * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "AppletToolbarAddItem.h" - -#include "App.h" -#include "PaletteHandler.h" -#include "context/Containment.h" -#include "context/ContextView.h" -#include "core/support/Amarok.h" -#include "core/support/Debug.h" - -#include - -#include -#include -#include -#include -#include -#include - -#define MARGIN 10 -#define TOOLBAR_X_OFFSET 5 -#define TOOLBAR_Y_OFFSET 5 - -Context::AppletToolbarAddItem::AppletToolbarAddItem( QGraphicsItem* parent, Context::Containment* cont, bool fixedAdd ) - : AppletToolbarBase( parent ) - , m_iconPadding( 0 ) - , m_fixedAdd( fixedAdd ) - , m_showingAppletExplorer( false ) - , m_cont( cont ) - , m_icon( 0 ) - , m_label( 0 ) -{ - QAction* listAdd = new QAction( i18n( "Add Applets..." ), this ); - listAdd->setIcon( KIcon( "list-add" ) ); - listAdd->setVisible( true ); - listAdd->setEnabled( true ); - - connect( listAdd, SIGNAL(triggered()), this, SLOT(iconClicked()) ); - - m_icon = new Plasma::IconWidget( this ); - - m_icon->setAction( listAdd ); - m_icon->setText( QString() ); - m_icon->setToolTip( listAdd->text() ); - m_icon->setDrawBackground( false ); - m_icon->setOrientation( Qt::Horizontal ); - QSizeF iconSize; - if( m_fixedAdd ) - iconSize = m_icon->sizeFromIconSize( 22 ); - else - iconSize = m_icon->sizeFromIconSize( 11 ); - m_icon->setMinimumSize( iconSize ); - m_icon->setMaximumSize( iconSize ); - m_icon->resize( iconSize ); - m_icon->setZValue( zValue() + 1 ); - - m_label = new QGraphicsSimpleTextItem( i18n( "Add Applet..." ), this ); - m_label->hide(); - - if( m_cont ) - connect( m_cont->view(), SIGNAL(appletExplorerHid()), this, SLOT(appletExplorerHid()) ); - - if( m_fixedAdd ) - setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); - else - setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Preferred ); - // resize( QSizeF( 18, 24 ) ); -} - -Context::AppletToolbarAddItem::~AppletToolbarAddItem() -{} - -void -Context::AppletToolbarAddItem::appletExplorerHid() // SLOT -{ - m_showingAppletExplorer = false; -} -void -Context::AppletToolbarAddItem::iconClicked() // SLOT -{ - if( m_showingAppletExplorer ) - { - m_showingAppletExplorer = false; - emit hideAppletExplorer(); - } - else - { - m_showingAppletExplorer = true; - emit showAppletExplorer(); - } -} - -void -Context::AppletToolbarAddItem::resizeEvent( QGraphicsSceneResizeEvent * event ) -{ - Q_UNUSED( event ) - if( m_label->boundingRect().width() < ( boundingRect().width() - 2*m_icon->boundingRect().width() ) ) - // do we have size to show it? - { - m_icon->setPos( boundingRect().width() - m_icon->boundingRect().width(), ( boundingRect().height() / 2 ) - ( -m_icon->size().height() / 2 ) ); - m_label->setPos( ( boundingRect().width() / 2 ) - ( m_label->boundingRect().width() / 2 ), ( -boundingRect().height() / 2 ) - ( m_label->boundingRect().height() / 2 ) ); - m_label->show(); - } else - { - m_icon->setPos( ( boundingRect().width() / 2 ) - ( m_icon->boundingRect().width() / 2 ) , ( -boundingRect().height() / 2 ) - ( m_icon->size().height() / 2 ) ); - m_label->hide(); - } -} - - -QSizeF -Context::AppletToolbarAddItem::sizeHint( Qt::SizeHint which, const QSizeF & constraint ) const -{ - if( m_fixedAdd ) - // return QSizeF( m_icon->size().width() + 2 * m_iconPadding, QGraphicsWidget::sizeHint( which,constraint -//).height() ); - return QGraphicsWidget::sizeHint(which, constraint); - else - if( which == Qt::MinimumSize ) - return QSizeF(); - else - return QSizeF( m_icon->size().width() + 2 * m_iconPadding, QGraphicsWidget::sizeHint( which, constraint -).height() ); - -} - -void -Context::AppletToolbarAddItem::mousePressEvent( QGraphicsSceneMouseEvent * event ) -{ - DEBUG_BLOCK - emit showAppletExplorer(); - event->accept(); -} - -#include "moc_AppletToolbarAddItem.cpp" diff --git a/amarok/src/context/toolbar/AppletToolbarAddItem.h b/amarok/src/context/toolbar/AppletToolbarAddItem.h deleted file mode 100644 index eba08acc..00000000 --- a/amarok/src/context/toolbar/AppletToolbarAddItem.h +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Leo Franchi * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_APPLET_TOOLBAR_ADD_ITEM_H -#define AMAROK_APPLET_TOOLBAR_ADD_ITEM_H - - -#include "amarok_export.h" - -#include - -#include -#include "AppletToolbarBase.h" - -class QGraphicsItem; -class QGraphicsSceneResizeEvent; -class QGraphicsSimpleTextItem; -class QPainter; -class QStyleOptionGraphicsItem; - -namespace Context -{ - -class Containment; -class WidgetExplorer; - -class AppletToolbarAddItem : public AppletToolbarBase -{ - Q_OBJECT - public: - explicit AppletToolbarAddItem( QGraphicsItem* parent = 0, Containment* cont = 0, bool fixedAdd = false ); - ~AppletToolbarAddItem(); - - signals: - void addApplet( const QString&, AppletToolbarAddItem* ); - void hideAppletExplorer(); - void showAppletExplorer(); - - public slots: - void appletExplorerHid(); - void iconClicked(); - - protected: - virtual void resizeEvent( QGraphicsSceneResizeEvent * event ); - virtual QSizeF sizeHint( Qt::SizeHint which, const QSizeF & constraint = QSizeF() ) const; - - void mousePressEvent( QGraphicsSceneMouseEvent * event ); - private: - int m_iconPadding; - bool m_fixedAdd; - bool m_showingAppletExplorer; - - Containment* m_cont; - Plasma::IconWidget* m_icon; - QGraphicsSimpleTextItem* m_label; -}; - -} - -#endif diff --git a/amarok/src/context/toolbar/AppletToolbarAppletItem.cpp b/amarok/src/context/toolbar/AppletToolbarAppletItem.cpp deleted file mode 100644 index 129b64b4..00000000 --- a/amarok/src/context/toolbar/AppletToolbarAppletItem.cpp +++ /dev/null @@ -1,244 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Leo Franchi * - * Copyright (c) 2009 Simon Esneault * - * Copyright (c) 2009 Mark Kretschmann * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "AppletToolbarAppletItem.h" - -#include "core/support/Amarok.h" -#include "core/support/Debug.h" -#include "PaletteHandler.h" - -#include -#include - -#include - -#include -#include -#include -#include -#include - - -Context::AppletToolbarAppletItem::AppletToolbarAppletItem( QGraphicsItem* parent, Plasma::Applet* applet ) - : AppletToolbarBase( parent ) - , m_applet( applet ) - , m_label( 0 ) - , m_deleteIcon( 0 ) - , m_configEnabled( false ) -{ - m_label = new QGraphicsTextItem( this ); - - // Don't propagate opacity changes to the text label, as this reduces readability - m_label->setFlags( QGraphicsItem::ItemIgnoresParentOpacity ); - - if( m_applet ) - { - m_label->setPlainText( m_applet->name() ); - } - else - { - m_label->setPlainText( i18n("no applet name") ); - } - - setAcceptHoverEvents( true ); - m_label->setAcceptHoverEvents( true ); - QAction* delApplet = new QAction( i18n( "Remove Applet" ), this ); - delApplet->setIcon( KIcon( "edit-delete" ) ); - delApplet->setVisible( true ); - delApplet->setEnabled( true ); - - connect( delApplet, SIGNAL(triggered()), this, SLOT(deleteApplet()) ); - m_deleteIcon = addAction( delApplet, 18 ); - m_deleteIcon->hide(); - - setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); - - paletteChanged( palette() ); - connect( The::paletteHandler(), SIGNAL(newPalette(QPalette)), SLOT(paletteChanged(QPalette)) ); -} - -Context::AppletToolbarAppletItem::~AppletToolbarAppletItem() -{ -} - -void -Context::AppletToolbarAppletItem::setConfigEnabled( bool config ) -{ - if( config && !m_configEnabled ) // switching to config mode - { - // center over top-right corner - m_deleteIcon->setPos( ( boundingRect().width() - (m_deleteIcon->boundingRect().width() ) ) - 1, -1 ); - } - else - m_deleteIcon->hide(); - - m_configEnabled = config; -} - -bool -Context::AppletToolbarAppletItem::configEnabled() -{ - return m_configEnabled; -} - -QRectF -Context::AppletToolbarAppletItem::delIconSceneRect() -{ - return mapToScene( m_deleteIcon->boundingRect() ).boundingRect(); -} - -void -Context::AppletToolbarAppletItem::resizeEvent( QGraphicsSceneResizeEvent *event ) -{ - Q_UNUSED( event ) - QFontMetrics fm( m_label->font() ); - if( m_configEnabled ) - { - m_deleteIcon->setPos( ( boundingRect().width() - (m_deleteIcon->boundingRect().width() ) ) - 1, -1 ); - - if( fm.width( m_applet->name() ) + m_deleteIcon->boundingRect().width() > boundingRect().width() ) - m_label->setPlainText( fm.elidedText( m_applet->name(), Qt::ElideRight, boundingRect().width() - m_deleteIcon->boundingRect().width() ) ); - else - m_label->setPlainText( m_applet->name() ); - - m_label->setPos( ( ( boundingRect().width() - m_deleteIcon->boundingRect().width() ) - m_label->boundingRect().width() ) / 2, - ( boundingRect().height() - m_label->boundingRect().height() ) / 2 ); - } - else - { - if( fm.width( m_applet->name() ) > boundingRect().width() ) - m_label->setPlainText( fm.elidedText( m_applet->name(), Qt::ElideRight, boundingRect().width() ) ); - else - m_label->setPlainText( m_applet->name() ); - - m_label->setPos( ( boundingRect().width() - m_label->boundingRect().width() ) / 2, - ( boundingRect().height() - m_label->boundingRect().height() ) / 2 ); - - } - - emit geometryChanged(); -} - -void -Context::AppletToolbarAppletItem::paletteChanged( const QPalette &palette ) -{ - m_label->setDefaultTextColor( palette.text().color() ); -} - -QVariant -Context::AppletToolbarAppletItem::itemChange( GraphicsItemChange change, const QVariant &value ) -{ - QVariant ret = QGraphicsWidget::itemChange( change, value ); - - if( change == ItemPositionHasChanged ) - emit geometryChanged(); - return ret; -} - -QSizeF -Context::AppletToolbarAppletItem::sizeHint( Qt::SizeHint which, const QSizeF & constraint ) const -{ - Q_UNUSED( constraint ) - if( which == Qt::MinimumSize ) - return QSizeF(); - else - return QSizeF( 10000, 10000 ); -} - -void -Context::AppletToolbarAppletItem::mousePressEvent( QGraphicsSceneMouseEvent * event ) -{ - emit appletChosen( m_applet ); - event->accept(); -} - -void -Context::AppletToolbarAppletItem::deleteApplet() -{ - DEBUG_BLOCK - m_applet->deleteLater(); -} - -Plasma::IconWidget* -Context::AppletToolbarAppletItem::addAction( QAction *action, int size ) -{ - if ( !action ) { - debug() << "ERROR!!! PASSED INVALID ACTION"; - return 0; - } - - Plasma::IconWidget *tool = new Plasma::IconWidget( this ); - - tool->setAction( action ); - tool->setText( QString() ); - tool->setToolTip( action->text() ); - tool->setDrawBackground( false ); - tool->setOrientation( Qt::Horizontal ); - QSizeF iconSize = tool->sizeFromIconSize( size ); - tool->setMinimumSize( iconSize ); - tool->setMaximumSize( iconSize ); - tool->resize( iconSize ); - - tool->hide(); - tool->setZValue( zValue() + 1000 ); - - return tool; -} - -void -Context::AppletToolbarAppletItem::hoverEnterEvent( QGraphicsSceneHoverEvent * ) -{ - QPropertyAnimation *animation = m_opacityAnimation.data(); - if( !animation ) - { - animation = new QPropertyAnimation( this, "opacity" ); - animation->setDuration( 250 ); - animation->setStartValue( 0.3 ); - animation->setEndValue( 1.0 ); - m_opacityAnimation = animation; - } - else if( animation->state() == QAbstractAnimation::Running ) - animation->stop(); - - animation->setEasingCurve( QEasingCurve::OutCubic ); - animation->setDirection( QAbstractAnimation::Backward ); - animation->start( QAbstractAnimation::KeepWhenStopped ); -} - -void -Context::AppletToolbarAppletItem::hoverLeaveEvent( QGraphicsSceneHoverEvent * ) -{ - QPropertyAnimation *animation = m_opacityAnimation.data(); - if( !animation ) - { - animation = new QPropertyAnimation( this, "opacity" ); - animation->setDuration( 250 ); - animation->setStartValue( 0.3 ); - animation->setEndValue( 1.0 ); - m_opacityAnimation = animation; - } - else if( animation->state() == QAbstractAnimation::Running ) - animation->pause(); - - animation->setEasingCurve( QEasingCurve::OutCubic ); - animation->setDirection( QAbstractAnimation::Forward ); - animation->start( QAbstractAnimation::DeleteWhenStopped ); -} - - -#include "moc_AppletToolbarAppletItem.cpp" diff --git a/amarok/src/context/toolbar/AppletToolbarAppletItem.h b/amarok/src/context/toolbar/AppletToolbarAppletItem.h deleted file mode 100644 index 2a1197eb..00000000 --- a/amarok/src/context/toolbar/AppletToolbarAppletItem.h +++ /dev/null @@ -1,91 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Leo Franchi * - * Copyright (c) 2009 Simon Esneault * - * Copyright (c) 2009 Mark Kretschmann * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_APPLET_TOOLBAR_APPLET_ITEM_H -#define AMAROK_APPLET_TOOLBAR_APPLET_ITEM_H - -#include "AppletToolbarBase.h" - -#include - -class QPropertyAnimation; -class QPalette; - -namespace Plasma -{ - class Animation; - class Applet; - class IconWidget; -} - -namespace Context -{ - -class AppletToolbarAppletItem : public AppletToolbarBase -{ - Q_OBJECT - - public: - explicit AppletToolbarAppletItem( QGraphicsItem* parent = 0, Plasma::Applet* applet = 0 ); - ~AppletToolbarAppletItem(); - - void setConfigEnabled( bool config ); - bool configEnabled(); - - Plasma::Applet* applet() { return m_applet; } - // needed for the overlay to check if the click is over the del icon - QRectF delIconSceneRect(); - - signals: - void appletChosen( Plasma::Applet* ); - void geometryChanged(); - - protected: - virtual void resizeEvent( QGraphicsSceneResizeEvent * event ); - virtual QSizeF sizeHint( Qt::SizeHint which, const QSizeF & constraint = QSizeF() ) const; - - /** - * Reimplemented from QGraphicsItem - */ - virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value); - - virtual void hoverEnterEvent( QGraphicsSceneHoverEvent * event ); - virtual void hoverLeaveEvent( QGraphicsSceneHoverEvent * event ); - - void mousePressEvent( QGraphicsSceneMouseEvent * event ); - - private slots: - void deleteApplet(); - void paletteChanged( const QPalette &palette ); - - private: - Plasma::IconWidget* addAction( QAction *action, int size ); - - Plasma::Applet* m_applet; - QGraphicsTextItem* m_label; - - QWeakPointer m_opacityAnimation; - - Plasma::IconWidget* m_deleteIcon; - - bool m_configEnabled; -}; - -} // namespace - -#endif diff --git a/amarok/src/context/toolbar/AppletToolbarBase.cpp b/amarok/src/context/toolbar/AppletToolbarBase.cpp deleted file mode 100644 index 6a0af33d..00000000 --- a/amarok/src/context/toolbar/AppletToolbarBase.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Leo Franchi * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "AppletToolbarBase.h" - -#include - -Context::AppletToolbarBase::AppletToolbarBase( QGraphicsItem* parent, Qt::WindowFlags wFlags ) - : QGraphicsWidget( parent, wFlags ) -{ - -} - -Context::AppletToolbarBase::~AppletToolbarBase() -{} - -void -Context::AppletToolbarBase::paint( QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget ) -{ - Q_UNUSED( option ) - Q_UNUSED( widget ) - - painter->save(); - painter->setRenderHint( QPainter::Antialiasing ); - - QColor topColor = palette().color( QPalette::Active, QPalette::Button ); - QColor bottomColor = topColor; - topColor.setAlpha( 200 ); - bottomColor.setAlpha( 100 ); - qreal radius = 3; - qreal boundWidth = boundingRect().width(); - qreal boundHeight = boundingRect().height(); - - // draw top half of rounded applet - QPainterPath path; - path.moveTo( 0, boundHeight / 2 ); - path.lineTo( 0, radius ); - path.quadTo( 0, 0, radius, 0 ); - path.lineTo( boundWidth - radius, 0 ); - path.quadTo( boundWidth, 0, boundWidth, radius ); - path.lineTo( boundWidth, boundHeight / 2 ); - path.lineTo( 0, boundHeight / 2 ); - - painter->fillPath( path, topColor ); - QPainterPath bottom; - bottom.moveTo( 0, boundHeight / 2 ); - bottom.lineTo( 0, boundHeight - radius ); - bottom.quadTo( 0, boundHeight, radius, boundHeight ); - bottom.lineTo( boundWidth - radius, boundHeight ); - bottom.quadTo( boundWidth, boundHeight, boundWidth, boundHeight - radius ); - bottom.lineTo( boundWidth, boundHeight / 2 ); - bottom.lineTo( 0, boundHeight / 2 ); - - painter->fillPath( bottom, bottomColor ); - painter->restore(); -} diff --git a/amarok/src/context/toolbar/AppletToolbarBase.h b/amarok/src/context/toolbar/AppletToolbarBase.h deleted file mode 100644 index 56fe3e96..00000000 --- a/amarok/src/context/toolbar/AppletToolbarBase.h +++ /dev/null @@ -1,37 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Leo Franchi * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef APPLETTOOLBARBASE_H -#define APPLETTOOLBARBASE_H - -#include - -namespace Context -{ - -class AppletToolbarBase : public QGraphicsWidget -{ -public: - explicit AppletToolbarBase(QGraphicsItem* parent = 0, Qt::WindowFlags wFlags = 0); - ~AppletToolbarBase(); - - virtual void paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0 ); - -}; - -} // namespace - -#endif // APPLETTOOLBARBASE_H diff --git a/amarok/src/context/toolbar/AppletToolbarConfigItem.cpp b/amarok/src/context/toolbar/AppletToolbarConfigItem.cpp deleted file mode 100644 index 86f9f6e5..00000000 --- a/amarok/src/context/toolbar/AppletToolbarConfigItem.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Leo Franchi * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "AppletToolbarConfigItem.h" - -#include "App.h" -#include "PaletteHandler.h" - -#include - -#include - -#include -#include -#include -#include - -Context::AppletToolbarConfigItem::AppletToolbarConfigItem( QGraphicsItem* parent ) - : AppletToolbarBase( parent ) - , m_iconPadding( 2 ) - , m_icon( 0 ) -{ - QAction* listAdd = new QAction( i18n( "Configure Applets..." ), this ); - listAdd->setIcon( KIcon( "configure" ) ); - listAdd->setVisible( true ); - listAdd->setEnabled( true ); - - connect( listAdd, SIGNAL(triggered()), this, SIGNAL(triggered()) ); - - m_icon = new Plasma::IconWidget( this ); - - m_icon->setAction( listAdd ); - m_icon->setText( QString() ); - m_icon->setToolTip( listAdd->text() ); - m_icon->setDrawBackground( false ); - m_icon->setOrientation( Qt::Horizontal ); - QSizeF iconSize = m_icon->sizeFromIconSize( 22 ); - m_icon->setMinimumSize( iconSize ); - m_icon->setMaximumSize( iconSize ); - m_icon->resize( iconSize ); - m_icon->setZValue( zValue() + 1 ); - - setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Preferred ); - -} - -Context::AppletToolbarConfigItem::~AppletToolbarConfigItem() -{} - -void -Context::AppletToolbarConfigItem::resizeEvent( QGraphicsSceneResizeEvent * event ) -{ - Q_UNUSED( event ) - // center horizontally and vertically - m_icon->setPos( ( boundingRect().width() / 2 ) - ( m_icon->boundingRect().width() / 2 ) , ( boundingRect().height() / 2 ) - ( m_icon->size().height() / 2 ) ); -} - -QSizeF -Context::AppletToolbarConfigItem::sizeHint( Qt::SizeHint which, const QSizeF & constraint ) const -{ - return QSizeF( m_icon->size().width() + 2 * m_iconPadding , QGraphicsWidget::sizeHint( which, constraint ).height() ); -} - -void -Context::AppletToolbarConfigItem::mousePressEvent( QGraphicsSceneMouseEvent *event ) -{ - Q_UNUSED( event ) - emit triggered(); -} - -#include "moc_AppletToolbarConfigItem.cpp" diff --git a/amarok/src/context/toolbar/AppletToolbarConfigItem.h b/amarok/src/context/toolbar/AppletToolbarConfigItem.h deleted file mode 100644 index f3b5b7fa..00000000 --- a/amarok/src/context/toolbar/AppletToolbarConfigItem.h +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Leo Franchi * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_APPLET_TOOLBAR_CONFIG_ITEM_H -#define AMAROK_APPLET_TOOLBAR_CONFIG_ITEM_H - -#include -#include "AppletToolbarBase.h" - - -class QPainter; -class QSizePolicy; -class QStyleOptionGraphicsItem; - -namespace Plasma -{ - class IconWidget; -} - -namespace Context -{ - -class AppletToolbarConfigItem : public AppletToolbarBase -{ - Q_OBJECT - public: - AppletToolbarConfigItem( QGraphicsItem* parent = 0 ); - ~AppletToolbarConfigItem(); - - signals: - void triggered(); - - protected: - virtual void resizeEvent( QGraphicsSceneResizeEvent * event ); - virtual QSizeF sizeHint( Qt::SizeHint which, const QSizeF & constraint = QSizeF() ) const; - - void mousePressEvent( QGraphicsSceneMouseEvent * event ); - private: - int m_iconPadding; - - Plasma::IconWidget* m_icon; -}; - -} - -#endif diff --git a/amarok/src/context/tools/CMakeLists.txt b/amarok/src/context/tools/CMakeLists.txt deleted file mode 100644 index 47250d7e..00000000 --- a/amarok/src/context/tools/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -set(amarokpkg_SRCS - amarokpkg.cpp -) - -add_executable(amarokpkg ${amarokpkg_SRCS}) - -target_link_libraries(amarokpkg ${KDE4_KDEUI_LIBS} ${KDE4_PLASMA_LIBS}) - -install(TARGETS amarokpkg ${INSTALL_TARGETS_DEFAULT_ARGS}) - diff --git a/amarok/src/context/tools/Messages.sh b/amarok/src/context/tools/Messages.sh deleted file mode 100644 index 8eaf87f0..00000000 --- a/amarok/src/context/tools/Messages.sh +++ /dev/null @@ -1,2 +0,0 @@ -#! /usr/bin/env bash -$XGETTEXT *.cpp -o $podir/amarokpkg.pot diff --git a/amarok/src/context/tools/amarokpkg.cpp b/amarok/src/context/tools/amarokpkg.cpp deleted file mode 100644 index a9036693..00000000 --- a/amarok/src/context/tools/amarokpkg.cpp +++ /dev/null @@ -1,193 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Aaron Seigo * - * Copyright (c) 2009 Leo Franchi * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -static const char description[] = I18N_NOOP("Install, list, remove Amarok applets"); -static const char version[] = "0.1"; - - -void output(const QString &msg) -{ - std::cout << msg.toLocal8Bit().constData() << std::endl; -} - -void runKbuildsycoca() -{ - QDBusInterface dbus("org.kde.kded", "/kbuildsycoca", "org.kde.kbuildsycoca"); - dbus.call(QDBus::NoBlock, "recreate"); -} - -QStringList packages(const QString& type) -{ - QStringList result; - KService::List services = KServiceTypeTrader::self()->query("Plasma/" + type, "'amarok' ~ [X-KDE-ParentApp]"); - foreach(const KService::Ptr &service, services) { - result << service->property("X-KDE-PluginInfo-Name", QVariant::String).toString(); - } - return result; -} - -void listPackages(const QString& type) -{ - QStringList list = packages(type); - list.sort(); - foreach(const QString& package, list) { - output(package); - } -} - -int main(int argc, char **argv) -{ - KAboutData aboutData("amarokpkg", 0, ki18n("Amarok Applet Manager"), - version, ki18n(description), KAboutData::License_GPL, - ki18n("(C) 2008, Aaron Seigo, (C) 2009, Leo Franchi")); - aboutData.addAuthor( ki18n("Aaron Seigo"), - ki18n("Original author"), - "aseigo@kde.org" ); - aboutData.addAuthor( ki18n( "Leo Franchi" ), - ki18n( "Developer" ) , - "lfranchi@kde.org" ); - - KComponentData componentData(aboutData); - - KCmdLineArgs::init( argc, argv, &aboutData ); - - KCmdLineOptions options; - options.add("g"); - options.add("global", ki18n("For install or remove, operates on applets installed for all users.")); - options.add("s"); - options.add("i"); - options.add("install ", ki18nc("Do not translate ", "Install the applet at ")); - options.add("u"); - options.add("upgrade ", ki18nc("Do not translate ", "Upgrade the applet at ")); - options.add("l"); - options.add("list", ki18n("List installed applets")); - options.add("r"); - options.add("remove ", ki18nc("Do not translate ", "Remove the applet named ")); - options.add("p"); - options.add("packageroot ", ki18n("Absolute path to the package root. If not supplied, then the standard data directories for this KDE session will be searched instead.")); - KCmdLineArgs::addCmdLineOptions( options ); - - KApplication app; - - KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); - QString packageRoot = "plasma/plasmoids/"; - QString servicePrefix = "amarok-applet-"; - QString pluginType = "Applet"; - Plasma::PackageStructure *installer = 0; - - if (args->isSet("list")) { - listPackages(pluginType); - } else { - // install, remove or upgrade - if (!installer) { - installer = new Plasma::PackageStructure(); - installer->setServicePrefix(servicePrefix); - } - - if (args->isSet("packageroot")) { - packageRoot = args->getOption("packageroot"); - } else if (args->isSet("global")) { - packageRoot = KStandardDirs::locate("data", packageRoot); - } else { - packageRoot = KStandardDirs::locateLocal("data", packageRoot); - } - - QString package; - QString packageFile; - if (args->isSet("remove")) { - package = args->getOption("remove"); - } else if (args->isSet("upgrade")) { - package = args->getOption("upgrade"); - } else if (args->isSet("install")) { - package = args->getOption("install"); - } - if (!QDir::isAbsolutePath(package)) { - packageFile = QDir(QDir::currentPath() + '/' + package).absolutePath(); - } else { - packageFile = package; - } - - if (args->isSet("remove") || args->isSet("upgrade")) { - installer->setPath(packageFile); - Plasma::PackageMetadata metadata = installer->metadata(); - - QString pluginName; - if (metadata.pluginName().isEmpty()) { - // plugin name given in command line - pluginName = package; - } else { - // Parameter was a plasma package, get plugin name from the package - pluginName = metadata.pluginName(); - } - - QStringList installed = packages(pluginType); - if (installed.contains(pluginName)) { - if (installer->uninstallPackage(pluginName, packageRoot)) { - output(i18n("Successfully removed %1", pluginName)); - } else if (!args->isSet("upgrade")) { - output(i18n("Removal of %1 failed.", pluginName)); - delete installer; - return 1; - } - } else { - output(i18n("Plugin %1 is not installed.", pluginName)); - } - } - if (args->isSet("install") || args->isSet("upgrade")) { - if (installer->installPackage(packageFile, packageRoot)) { - output(i18n("Successfully installed %1", packageFile)); - runKbuildsycoca(); - } else { - output(i18n("Installation of %1 failed.", packageFile)); - delete installer; - return 1; - } - } - if (package.isEmpty()) { - KCmdLineArgs::usageError(i18nc("No option was given, this is the error message telling the user he needs at least one, do not translate install, remove, upgrade nor list", "One of install, remove, upgrade or list is required.")); - } else { - runKbuildsycoca(); - } - } - delete installer; - return 0; -} - - - diff --git a/amarok/src/context/widgets/AppletHeader.cpp b/amarok/src/context/widgets/AppletHeader.cpp deleted file mode 100644 index df0162a8..00000000 --- a/amarok/src/context/widgets/AppletHeader.cpp +++ /dev/null @@ -1,164 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Rick W. Chen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "AppletHeader" - -#include "AppletHeader.h" - -#include "TextScrollingWidget.h" -#include "core/support/Debug.h" - -#include - -#include -#include -#include -#include -#include - -Context::AppletHeader::AppletHeader( QGraphicsItem *parent, Qt::WindowFlags wFlags ) - : QGraphicsWidget( parent, wFlags ) - , m_mainLayout( new QGraphicsLinearLayout( Qt::Horizontal, this ) ) - , m_leftLayout( new QGraphicsLinearLayout( Qt::Horizontal ) ) - , m_rightLayout( new QGraphicsLinearLayout( Qt::Horizontal ) ) - , m_titleWidget( new TextScrollingWidget( this ) ) -{ - QFont labelFont; - labelFont.setPointSize( labelFont.pointSize() + 2 ); - m_titleWidget->setFont( labelFont ); - m_titleWidget->setDrawBackground( true ); - m_titleWidget->setText( i18n( "Context Applet" ) ); - m_titleWidget->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); - - m_mainLayout->setSpacing( 4 ); - m_mainLayout->addItem( m_leftLayout ); - m_mainLayout->addItem( m_titleWidget ); - m_mainLayout->addItem( m_rightLayout ); - m_mainLayout->setContentsMargins( 2, 4, 2, 2 ); - m_mainLayout->setStretchFactor( m_titleWidget, 10000 ); - m_mainLayout->setAlignment( m_leftLayout, Qt::AlignLeft ); - m_mainLayout->setAlignment( m_titleWidget, Qt::AlignHCenter ); - m_mainLayout->setAlignment( m_rightLayout, Qt::AlignRight ); - m_mainLayout->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); - m_leftLayout->setSizePolicy( QSizePolicy::Maximum, QSizePolicy::Fixed ); - m_rightLayout->setSizePolicy( QSizePolicy::Maximum, QSizePolicy::Fixed ); - - m_height = 4 + 2 + m_titleWidget->size().height() - + QApplication::style()->pixelMetric( QStyle::PM_LayoutTopMargin ) - + QApplication::style()->pixelMetric( QStyle::PM_LayoutBottomMargin ); -} - -Context::AppletHeader::~AppletHeader() -{ -} - -qreal -Context::AppletHeader::height() const -{ - return m_height; -} - -void -Context::AppletHeader::addIcon( Plasma::IconWidget *icon, Qt::Alignment align ) -{ - if( !icon ) - return; - - clearDummyItems(); - if( align == Qt::AlignLeft ) - m_leftLayout->addItem( icon ); - else if( align == Qt::AlignRight ) - m_rightLayout->addItem( icon ); - else - return; - - const int diff = m_leftLayout->count() - m_rightLayout->count(); - QGraphicsLinearLayout *layout = ( diff > 0 ) ? m_rightLayout : m_leftLayout; - int index = ( diff > 0 ) ? 0 : -1; - for( int i = 0, count = qAbs( diff ); i < count; ++i ) - { - QGraphicsWidget *dummy = new QGraphicsWidget( this ); - dummy->setMinimumSize( icon->size() ); - dummy->setMaximumSize( icon->size() ); - dummy->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ); - m_dummyItems << dummy; - layout->insertItem( index, dummy ); - } -} - -QString -Context::AppletHeader::titleText() const -{ - return m_titleWidget->text(); -} - -void -Context::AppletHeader::setTitleText( const QString &text ) -{ - m_titleWidget->setScrollingText( text ); -} - -TextScrollingWidget * -Context::AppletHeader::textScrollingWidget() -{ - return m_titleWidget; -} - -void -Context::AppletHeader::clearDummyItems() -{ - if( m_dummyItems.isEmpty() ) - return; - - QList toRemove; - for( int i = 0, count = m_leftLayout->count(); i < count; ++i ) - { - QGraphicsLayoutItem *item = m_leftLayout->itemAt( i ); - if( m_dummyItems.contains( item ) ) - { - m_dummyItems.removeAll( item ); - toRemove << i; - } - } - while( !toRemove.isEmpty() ) - { - int index = toRemove.takeLast(); - QGraphicsLayoutItem *item = m_leftLayout->itemAt( index ); - m_leftLayout->removeAt( index ); - delete item; - } - toRemove.clear(); - - for( int i = 0, count = m_rightLayout->count(); i < count; ++i ) - { - QGraphicsLayoutItem *item = m_rightLayout->itemAt( i ); - if( m_dummyItems.contains( item ) ) - { - m_dummyItems.removeAll( item ); - toRemove << i; - } - } - while( !toRemove.isEmpty() ) - { - int index = toRemove.takeLast(); - QGraphicsLayoutItem *item = m_rightLayout->itemAt( index ); - m_rightLayout->removeAt( index ); - delete item; - } - m_dummyItems.clear(); -} - -#include "moc_AppletHeader.cpp" diff --git a/amarok/src/context/widgets/AppletHeader.h b/amarok/src/context/widgets/AppletHeader.h deleted file mode 100644 index cc10260e..00000000 --- a/amarok/src/context/widgets/AppletHeader.h +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Rick W. Chen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef CONTEXTAPPLETHEADER_H -#define CONTEXTAPPLETHEADER_H - -#include "amarok_export.h" - -#include - -class TextScrollingWidget; -class QGraphicsLinearLayout; - -namespace Plasma { - class IconWidget; -} - -namespace Context -{ - -class AMAROK_EXPORT AppletHeader : public QGraphicsWidget -{ - Q_OBJECT - Q_PROPERTY( QString titleText READ titleText WRITE setTitleText ) - Q_PROPERTY( qreal height READ height ) - -public: - AppletHeader( QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0 ); - ~AppletHeader(); - - qreal height() const; - - QString titleText() const; - void setTitleText( const QString &text ); - - void addIcon( Plasma::IconWidget *icon, Qt::Alignment align ); - - TextScrollingWidget *textScrollingWidget(); - -private: - void clearDummyItems(); - - qreal m_height; - QGraphicsLinearLayout *m_mainLayout; - QGraphicsLinearLayout *m_leftLayout; - QGraphicsLinearLayout *m_rightLayout; - QList m_dummyItems; - TextScrollingWidget *m_titleWidget; - Q_DISABLE_COPY( AppletHeader ) -}; - -} // namespace Context - -#endif // CONTEXTAPPLETHEADER_H diff --git a/amarok/src/context/widgets/ContainmentArrow.cpp b/amarok/src/context/widgets/ContainmentArrow.cpp deleted file mode 100644 index 4d2c9e71..00000000 --- a/amarok/src/context/widgets/ContainmentArrow.cpp +++ /dev/null @@ -1,335 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Leo Franchi * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "ContainmentArrow.h" - -#include "core/support/Debug.h" - -#include -#include -#include - -#include -#include - -// by default this item just grabs the coords of its parents, and positions itself to maximise in the -// direction that it is pointing to. - -namespace Context -{ - -ContainmentArrow::ContainmentArrow( QGraphicsItem *parent, int direction ) : - QGraphicsWidget( parent ), - m_showing( false ), - m_disabled( false ), - m_timer( 0 ) , - m_arrowSvg( 0 ), - m_containment( 0 ) -{ - DEBUG_BLOCK - - setZValue( 10000000 ); - setFlag( ItemClipsToShape, false ); - setFlag( ItemClipsChildrenToShape, false ); - setFlag( ItemIgnoresTransformations, true ); - setAcceptHoverEvents( true ); - - m_timer = new QTimer( this ); - connect( m_timer, SIGNAL(timeout()), this, SLOT(timeToHide()) ); - - m_arrowSvg = new Context::Svg( this ); - m_arrowSvg->setImagePath( KStandardDirs::locate( "data", "amarok/images/navigation_arrows.svg" ) ); - m_arrowSvg->setContainsMultipleImages( true ); - - debug() << "got svg path: " << m_arrowSvg->imagePath(); - - m_containment = dynamic_cast( parent ); - if( !m_containment ) - { - debug() << "ERROR! ContainmentArrow needs to be passed a Containment parent!"; - } - else - { - qreal height = 0, width = 0; - switch( direction ) - { - case DOWN: - case UP: - { - width = m_containment->size().width(); - debug() << " up/down arrow original width: " << width; - QRectF arrow; - if( direction == UP ) - arrow = m_arrowSvg->elementRect( "up_arrow" ); - else - arrow = m_arrowSvg->elementRect( "down_arrow" ); - m_aspectRatio = arrow.width() / arrow.height(); - - height = width / m_aspectRatio; - debug() << "up/down arrow m_aspectRatio and height is: " << m_aspectRatio << height; - debug() << "got UP/DOWN arrow with sizes: " << width << height; - break; - } - case LEFT: - case RIGHT: - { - height = m_containment->size().height(); - QRectF arrow; - debug() << " left/right arrow original height: " << height; - - if( direction == LEFT ) - arrow = m_arrowSvg->elementRect( "left_arrow" ); - else - arrow = m_arrowSvg->elementRect( "right_arrow" ); - m_aspectRatio = arrow.width() / arrow.height(); - - width = height * m_aspectRatio; - debug() << "left/right arrow m_aspectRatio and width is: " << m_aspectRatio << width; - - debug() << "got RIGHT/LEFT arrow with sizes: " << width << height; - break; - } - default: - error() << "Unspecified state, setting 0 size for arrows"; - } - m_size = QSize( width, height ); - } - - debug() << "ContainmentArrow: SETTING DIRECTION TO: " << direction; - m_arrowDirection = direction; -} - -ContainmentArrow::~ContainmentArrow() -{ - // delete m_timer; - // delete m_arrowSvg; - // delete m_containment; -} - - -QRectF -ContainmentArrow::boundingRect() const -{ - return QRectF( QPointF( 0, 0 ), m_size ); - -} - -QSize -ContainmentArrow::size() const -{ - return m_size; -} - -void -ContainmentArrow::resize( const QSizeF newSize ) -{ - DEBUG_BLOCK - prepareGeometryChange(); - switch( m_arrowDirection ) - { - case DOWN: // anchor to new width - case UP: - { - qreal newheight = newSize.width() / m_aspectRatio; - m_size = QSize( newSize.width(), newheight ); - break; - } - case LEFT: - case RIGHT: // anchor on height - { - qreal newWidth = newSize.height() * m_aspectRatio; - m_size = QSize( newWidth, newSize.height() ); - break; - } - } - m_arrowSvg->resize( m_size ); - debug() << "updating new size to: " << m_size; - update(); -} - -void -ContainmentArrow::enable() -{ - m_disabled = false; -} - -void ContainmentArrow::disable() -{ - m_disabled = true; -} - - -void -ContainmentArrow::show() -{ - // DEBUG_BLOCK - m_showing = true; - Plasma::Animation *fadeAnimation = m_fadeAnimation.data(); - if( !fadeAnimation ) - { - fadeAnimation = Plasma::Animator::create( Plasma::Animator::FadeAnimation ); - fadeAnimation->setTargetWidget( this ); - m_fadeAnimation = fadeAnimation; - } - else if( fadeAnimation->state() == QAbstractAnimation::Running ) - { - fadeAnimation->pause(); - } - - fadeAnimation->setProperty( "direction", QAbstractAnimation::Forward ); - fadeAnimation->start( QAbstractAnimation::DeleteWhenStopped ); -} - -void -ContainmentArrow::hide() -{ - - m_showing = false; - update(); - - Plasma::Animation *fadeAnimation = m_fadeAnimation.data(); - if( !fadeAnimation ) - { - fadeAnimation = Plasma::Animator::create( Plasma::Animator::FadeAnimation ); - fadeAnimation->setTargetWidget( this ); - m_fadeAnimation = fadeAnimation; - } - else if( fadeAnimation->state() == QAbstractAnimation::Running ) - { - fadeAnimation->pause(); - } - - fadeAnimation->setProperty( "direction", QAbstractAnimation::Backward ); - fadeAnimation->start( QAbstractAnimation::DeleteWhenStopped ); -} - -void -ContainmentArrow::paint( QPainter *p, const QStyleOptionGraphicsItem *option, QWidget *widget ) -{ - // DEBUG_BLOCK - - Q_UNUSED( option ) - Q_UNUSED( widget ) - - if( !m_showing ) - return; - - p->save(); - - if( m_arrowDirection == UP ) - m_arrowSvg->paint( p, boundingRect(), "up_arrow" ); - else if( m_arrowDirection == DOWN ) - m_arrowSvg->paint( p, boundingRect(), "down_arrow" ); - else if( m_arrowDirection == LEFT ) - m_arrowSvg->paint( p, boundingRect(), "left_arrow" ); - else if( m_arrowDirection == RIGHT ) - m_arrowSvg->paint( p, boundingRect(), "right_arrow" ); - p->restore(); - -} - - -void -ContainmentArrow::hoverEnterEvent( QGraphicsSceneHoverEvent *event ) -{ - // DEBUG_BLOCK - if( m_hovering || m_disabled ) - return; - if( m_timer->isActive() ) - m_timer->stop(); - m_hovering = true; - m_showing = true; - - Plasma::Animation *fadeAnimation = m_fadeAnimation.data(); - if( !fadeAnimation ) - { - fadeAnimation = Plasma::Animator::create( Plasma::Animator::FadeAnimation ); - fadeAnimation->setTargetWidget( this ); - m_fadeAnimation = fadeAnimation; - } - else if( fadeAnimation->state() == QAbstractAnimation::Running ) - { - fadeAnimation->pause(); - } - - fadeAnimation->setProperty( "direction", QAbstractAnimation::Forward ); - fadeAnimation->start( QAbstractAnimation::KeepWhenStopped ); - - QGraphicsItem::hoverEnterEvent( event ); -} - -void -ContainmentArrow::hoverLeaveEvent( QGraphicsSceneHoverEvent *event ) -{ - // DEBUG_BLOCK - if( m_disabled ) - return; - m_hovering = false; - // m_showing = false; - - // m_timer->start( 100 ); - timeToHide(); - - QGraphicsItem::hoverLeaveEvent( event ); -} - - -void -ContainmentArrow::timeToHide() -{ - m_timer->stop(); - - Plasma::Animation *fadeAnimation = m_fadeAnimation.data(); - if( !fadeAnimation ) - { - fadeAnimation = Plasma::Animator::create( Plasma::Animator::FadeAnimation ); - fadeAnimation->setTargetWidget( this ); - m_fadeAnimation = fadeAnimation; - } - else if( fadeAnimation->state() == QAbstractAnimation::Running ) - { - fadeAnimation->pause(); - } - - fadeAnimation->setProperty( "direction", QAbstractAnimation::Backward ); - fadeAnimation->start( QAbstractAnimation::DeleteWhenStopped ); -} - -void -ContainmentArrow::mousePressEvent( QGraphicsSceneMouseEvent *event ) -{ - // DEBUG_BLOCK - event->accept(); -} - -void -ContainmentArrow::mouseReleaseEvent( QGraphicsSceneMouseEvent *event ) -{ - // DEBUG_BLOCK - if ( boundingRect().contains( event->pos() ) && !m_disabled ) - { - debug() << "EMITTING changeContainment!"; - emit changeContainment( m_arrowDirection ); - // TODO add up/down - if( m_timer->isActive() ) - m_timer->stop(); - - } -} - -} - -#include "moc_ContainmentArrow.cpp" diff --git a/amarok/src/context/widgets/ContainmentArrow.h b/amarok/src/context/widgets/ContainmentArrow.h deleted file mode 100644 index 8d2eec87..00000000 --- a/amarok/src/context/widgets/ContainmentArrow.h +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Leo Franchi * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -// -// This provides a simple on-hover SVG arrow to switch between containments. -// - -#ifndef CONTAINMENT_ARROW_H -#define CONTAINMENT_ARROW_H - -#include "amarok_export.h" -#include "context/Svg.h" - -#include -#include -#include -#include - -enum ArrowDirection { - LEFT, - RIGHT, - DOWN, - UP, - DOWN_RIGHT, - DOWN_LEFT, - UP_RIGHT, - UP_LEFT -}; - -namespace Plasma { - class Animation; -} - -#include "context/Containment.h" // needs ArrowDirection to be defined first - -namespace Context { - -class SvgRenderJob; - -class ContainmentArrow : public QGraphicsWidget -{ - Q_OBJECT - Q_INTERFACES( QGraphicsItem ) -public: - explicit ContainmentArrow( QGraphicsItem *parent = 0, int direction = RIGHT ); - ~ContainmentArrow(); - - virtual QRectF boundingRect() const; - - QSize size() const; - void resize( const QSizeF newSize ); - - void enable(); - void disable(); - -public slots: - void show(); - void hide(); - -signals: - void changeContainment( int to ); - -protected: - virtual void paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0 ); - void hoverEnterEvent( QGraphicsSceneHoverEvent *event ); - void hoverLeaveEvent( QGraphicsSceneHoverEvent *event ); - void mousePressEvent( QGraphicsSceneMouseEvent *event ); - void mouseReleaseEvent( QGraphicsSceneMouseEvent *event ); - - -private Q_SLOTS: - void timeToHide(); - -private: - QSize m_size; - qreal m_animHighlightFrame; - int m_animHighlightId; - bool m_hovering; - bool m_showing; - bool m_disabled; - qreal m_aspectRatio; - - QTimer *m_timer; - - Svg* m_arrowSvg; - int m_arrowDirection; - Plasma::Containment *m_containment; - QWeakPointer m_fadeAnimation; -}; - - // namespace - -} -#endif diff --git a/amarok/src/context/widgets/ContainmentSelectionLayer.cpp b/amarok/src/context/widgets/ContainmentSelectionLayer.cpp deleted file mode 100644 index b2ba6da3..00000000 --- a/amarok/src/context/widgets/ContainmentSelectionLayer.cpp +++ /dev/null @@ -1,126 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 William Viana Soares * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "ContainmentSelectionLayer.h" - -#include - -#include - -#include -#include -#include -#include -#include - -#define ICON_SIZE 60 - -ContainmentSelectionLayer::ContainmentSelectionLayer( QGraphicsItem *parent ) - : QGraphicsItem( parent ) - , m_mouseHover( 0 ) -{ - m_containment = static_cast( parent ); - setAcceptHoverEvents( true ); - m_zoomInText = new QGraphicsSimpleTextItem( i18n( "Zoom In" ), this ); - - QFont font; - - font.setBold( true ); - font.setStyleHint( QFont::Times ); - font.setPointSize( font.pointSize() + 10 ); - font.setStyleStrategy( QFont::PreferAntialias ); - - m_zoomInText->setFont( font ); - m_zoomInText->setBrush( Qt::white ); - - m_zoomInText->hide(); - m_zoomInIcon = new KIcon( "zoom-in" ); -} - -QRectF -ContainmentSelectionLayer::boundingRect() const -{ - qreal left, top, right, bottom; - m_containment->getContentsMargins( &left, &top, &right, &bottom ); - return QRectF( m_containment->boundingRect().adjusted( left, top, right, bottom ) ); -} - -void -ContainmentSelectionLayer::hoverEnterEvent( QGraphicsSceneHoverEvent *event ) -{ - Q_UNUSED( event ); - - m_mouseHover = true; - m_zoomInText->show(); - update(); -} - -void -ContainmentSelectionLayer::hoverLeaveEvent( QGraphicsSceneHoverEvent *event ) -{ - Q_UNUSED( event ); - - m_mouseHover = false; - m_zoomInText->hide(); - update(); -} - -void -ContainmentSelectionLayer::mousePressEvent( QGraphicsSceneMouseEvent *event ) -{ - Q_UNUSED( event ); - - m_mouseHover = false; - m_zoomInText->hide(); - emit zoomRequested( m_containment, Plasma::ZoomIn ); -} - -void -ContainmentSelectionLayer::paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget ) -{ - Q_UNUSED( option ); - Q_UNUSED( widget ); - - QFontMetricsF fm( m_zoomInText->font() ); - m_zoomInText->setPos( boundingRect().width() / 2 - fm.boundingRect( m_zoomInText->text() ).width() / 2, - boundingRect().height() / 2 ); - painter->save(); - QColor color = KColorScheme( QPalette::Active, KColorScheme::Window, - Plasma::Theme::defaultTheme()->colorScheme() ).background().color(); - - - painter->setRenderHint( QPainter::Antialiasing ); - - if( m_mouseHover ) - { - m_zoomInIcon->paint( painter, boundingRect().width() / 2 - ICON_SIZE / 2 , - boundingRect().height() / 2 - ICON_SIZE, ICON_SIZE, ICON_SIZE, - Qt::AlignCenter, QIcon::Disabled ); - painter->setOpacity( 0.3 ); - painter->setPen( QPen( Qt::gray, 1) ); - } - else - { - painter->setOpacity( 0 ); - } - - color.setAlpha( 200 ); - painter->setBrush( color ); - - painter->drawRect( boundingRect() ); - - painter->restore(); -} diff --git a/amarok/src/context/widgets/ContainmentSelectionLayer.h b/amarok/src/context/widgets/ContainmentSelectionLayer.h deleted file mode 100644 index 0ace406d..00000000 --- a/amarok/src/context/widgets/ContainmentSelectionLayer.h +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 William Viana Soares * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef CONTAINMENT_SELECTION_LAYER_H -#define CONTAINMENT_SELECTION_LAYER_H - -#include "amarok_export.h" - -#include - -#include - -#include -#include - -#include - -/** - * @class ContainmentSelectionLayer - * @short A layer to add hover effects in the containments when in zoomed out mode. - */ -class AMAROK_EXPORT ContainmentSelectionLayer: public QObject, public QGraphicsItem -{ - Q_OBJECT - Q_INTERFACES( QGraphicsItem ) - public: - ContainmentSelectionLayer( QGraphicsItem *parent = 0 ); - QRectF boundingRect() const; - - protected: - virtual void hoverEnterEvent( QGraphicsSceneHoverEvent *event ); - virtual void hoverLeaveEvent( QGraphicsSceneHoverEvent *event ); - virtual void mousePressEvent( QGraphicsSceneMouseEvent *event ); - virtual void paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0 ); - - private: - Plasma::Containment *m_containment; - bool m_mouseHover; - QGraphicsSimpleTextItem *m_zoomInText; - KIcon *m_zoomInIcon; - Q_SIGNALS: - void zoomRequested( Plasma::Containment *containment, Plasma::ZoomDirection direction ); - -}; - -#endif diff --git a/amarok/src/context/widgets/DropPixmapItem.cpp b/amarok/src/context/widgets/DropPixmapItem.cpp deleted file mode 100644 index adf99712..00000000 --- a/amarok/src/context/widgets/DropPixmapItem.cpp +++ /dev/null @@ -1,159 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Simon Esneault * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "DropPixmapItem" - -#include "DropPixmapItem.h" - -#include "core/support/Debug.h" - -#include -#include - -DropPixmapItem::DropPixmapItem( QGraphicsItem* parent ) - : QGraphicsPixmapItem( parent ) -{ - setAcceptDrops( true ); -} - -void DropPixmapItem::dropEvent(QGraphicsSceneDragDropEvent* event) -{ - DEBUG_BLOCK - if( event->mimeData()->hasText() ) - { - QString file( event->mimeData()->text() ); - debug() << "dropped:" << file; - - if ( file.contains( "http://" ) || file.contains( "https://" ) ) - { - m_url = KUrl( file ); - The::networkAccessManager()->getData( m_url, this, - SLOT(imageDownloadResult(KUrl,QByteArray,NetworkAccessManagerProxy::Error)) ); - } - - else if ( file.contains( "file://" ) ) - { - file.remove( "file://" ); - QPixmap cover; - cover.load( file ); - if ( !cover.isNull() ) - { - emit imageDropped( cover ); - } - else - { - debug() << "not an image"; - } - } - } - - if( event->mimeData()->hasImage() ) - { - debug() << "mimeData has image"; - emit imageDropped( qvariant_cast< QPixmap >( event->mimeData()->imageData() ) ); - } -} - -void DropPixmapItem::imageDownloadResult( const KUrl &url, QByteArray data, NetworkAccessManagerProxy::Error e ) -{ - if( !url.isValid() || m_url != url ) - return; - - m_url.clear(); - if( e.code != QNetworkReply::NoError ) - { - debug() << "unable to download the image:" << e.description; - return; - } - - QPixmap cover; - if( cover.loadFromData( data ) ) - emit imageDropped( cover ); - else - debug() << "not an image"; -} - -DropPixmapLayoutItem::DropPixmapLayoutItem( QGraphicsLayoutItem *parent, bool isLayout ) - : QGraphicsLayoutItem( parent, isLayout ) -{ - m_pixmap = new DropPixmapItem; - m_pixmap->setZValue( 100 ); - setGraphicsItem( m_pixmap ); - connect( m_pixmap, SIGNAL(imageDropped(QPixmap)), SIGNAL(imageDropped(QPixmap)) ); -} - -DropPixmapLayoutItem::~DropPixmapLayoutItem() -{ - delete m_pixmap; -} - -void -DropPixmapLayoutItem::setGeometry( const QRectF &rect ) -{ - QGraphicsLayoutItem::setGeometry( rect ); - int width = m_pixmap->pixmap().width(); - int height = m_pixmap->pixmap().height(); - QPointF pos = rect.topLeft(); - pos.rx() += (rect.width() - width) / 2; - pos.ry() += (rect.height() - height) / 2; - m_pixmap->setPos( pos ); -} - -QSizeF -DropPixmapLayoutItem::sizeHint( Qt::SizeHint which, const QSizeF &constraint ) const -{ - Q_UNUSED( which ) - Q_UNUSED( constraint ) - return m_pixmap->boundingRect().size(); -} - -qreal -DropPixmapLayoutItem::opacity() const -{ - return m_pixmap->opacity(); -} - -void -DropPixmapLayoutItem::setOpacity( qreal value ) -{ - m_pixmap->setOpacity( value ); -} - -QPixmap -DropPixmapLayoutItem::pixmap() const -{ - return m_pixmap->pixmap(); -} - -void -DropPixmapLayoutItem::setPixmap( const QPixmap &pixmap ) -{ - m_pixmap->setPixmap( pixmap ); -} - -void -DropPixmapLayoutItem::show() -{ - m_pixmap->show(); -} - -void -DropPixmapLayoutItem::hide() -{ - m_pixmap->hide(); -} - -#include "moc_DropPixmapItem.cpp" diff --git a/amarok/src/context/widgets/DropPixmapItem.h b/amarok/src/context/widgets/DropPixmapItem.h deleted file mode 100644 index 82ec1800..00000000 --- a/amarok/src/context/widgets/DropPixmapItem.h +++ /dev/null @@ -1,100 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Simon Esneault * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef DROPPIXMAPITEM_H -#define DROPPIXMAPITEM_H - -#include "amarok_export.h" -#include "network/NetworkAccessManagerProxy.h" - -#include - -#include -#include - -//forward -class QGraphicsSceneDragDropEvent; - -/** -* \brief A QGraphicsPixmapItem on which you can drop an image -* -* Used for drag'n drop support for the cover. Will download the file if it's a link (from webrowser) -* -* \sa QGraphicsPixmapItem -* -* \author Simon Esneault -*/ - -class AMAROK_EXPORT DropPixmapItem : public QObject, public QGraphicsPixmapItem -{ - Q_OBJECT - public: - - DropPixmapItem( QGraphicsItem* parent = 0 ); - - signals: - void imageDropped( const QPixmap &pixmap ); - - public slots: - /** - * Result of the image fetching stuff - */ - void imageDownloadResult( const KUrl &url, QByteArray data, NetworkAccessManagerProxy::Error e ); - - protected slots: - /** - * Reimplement dropEvent - */ - virtual void dropEvent( QGraphicsSceneDragDropEvent* ); - - private: - KUrl m_url; - -}; - -class AMAROK_EXPORT DropPixmapLayoutItem : public QObject, public QGraphicsLayoutItem -{ - Q_OBJECT - Q_INTERFACES( QGraphicsLayoutItem ) - Q_PROPERTY( QPixmap pixmap READ pixmap WRITE setPixmap ) - Q_PROPERTY( qreal opacity READ opacity WRITE setOpacity ) - -public: - explicit DropPixmapLayoutItem( QGraphicsLayoutItem *parent = 0, bool isLayout = false ); - virtual ~DropPixmapLayoutItem(); - - virtual void setGeometry( const QRectF &rect ); - - qreal opacity() const; - void setOpacity( qreal value ); - - QPixmap pixmap() const; - void setPixmap( const QPixmap &pixmap ); - - void show(); - void hide(); - -signals: - void imageDropped( const QPixmap &pixmap ); - -protected: - virtual QSizeF sizeHint( Qt::SizeHint which, const QSizeF &constraint = QSizeF() ) const; - -private: - DropPixmapItem *m_pixmap; -}; - -#endif // DROPPIXMAPITEM_H diff --git a/amarok/src/context/widgets/RatingWidget.cpp b/amarok/src/context/widgets/RatingWidget.cpp deleted file mode 100644 index 6cb68467..00000000 --- a/amarok/src/context/widgets/RatingWidget.cpp +++ /dev/null @@ -1,300 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 William Viana Soarjs * - * Copyright (c) 2010 Mark Kretschmann * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -/* - Significant parts of this code is inspired and/or copied from - KDE Nepomuk sources, available at kdelibs/nepomuk -*/ - -#include "RatingWidget.h" - -#include "core/support/Debug.h" - -#include "kratingpainter.h" - -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include - -class RatingWidget::Private -{ -public: - Private() - : rating(0), - hoverRating(-1), - pixSize( 16 ), - showing( true ){ - } - - int rating; - int hoverRating; - int pixSize; - - bool showing; - - KRatingPainter ratingPainter; -}; - - -RatingWidget::RatingWidget( QGraphicsItem* parent ) - : QGraphicsWidget( parent ) - , d( new Private() ) - , m_startupUpdates( 2 ) -{ - setAcceptHoverEvents( true ); - setToolTip( i18n( "Track rating: %1", (float)d->rating / 2 ) ); -} - - -RatingWidget::~RatingWidget() -{ - delete d; -} - -void -RatingWidget::show() -{ - d->showing = true; -} - -void -RatingWidget::hide() -{ - d->showing = false; -} - -void -RatingWidget::setCustomPixmap( const QPixmap& pix ) -{ - d->ratingPainter.setCustomPixmap( pix ); - update(); -} - - -void -RatingWidget::setIcon( const QIcon& icon ) -{ - d->ratingPainter.setIcon( icon ); - update(); -} - - -void -RatingWidget::setPixmapSize( int size ) -{ - d->pixSize = size; - updateGeometry(); -} - - -int -RatingWidget::spacing() const -{ - return d->ratingPainter.spacing(); -} - - -QIcon -RatingWidget::icon() const -{ - return d->ratingPainter.icon(); -} - - -void -RatingWidget::setSpacing( int s ) -{ - d->ratingPainter.setSpacing( s ); - update(); -} - - -Qt::Alignment -RatingWidget::alignment() const -{ - return d->ratingPainter.alignment(); -} - - -void -RatingWidget::setAlignment( Qt::Alignment align ) -{ - d->ratingPainter.setAlignment( align ); - update(); -} - - -Qt::LayoutDirection -RatingWidget::layoutDirection() const -{ - return d->ratingPainter.layoutDirection(); -} - - -void -RatingWidget::setLayoutDirection( Qt::LayoutDirection direction ) -{ - d->ratingPainter.setLayoutDirection( direction ); - update(); -} - - -unsigned int -RatingWidget::rating() const -{ - return d->rating; -} - - -int -RatingWidget::maxRating() const -{ - return d->ratingPainter.maxRating(); -} - - -bool -RatingWidget::halfStepsEnabled() const -{ - return d->ratingPainter.halfStepsEnabled(); -} - -void -RatingWidget::setRating( int rating ) -{ - d->rating = rating; - d->hoverRating = rating; - update(); -} - -void -RatingWidget::setMaxRating( int max ) -{ - d->ratingPainter.setMaxRating( max ); - update(); -} - - -void -RatingWidget::setHalfStepsEnabled( bool enabled ) -{ - d->ratingPainter.setHalfStepsEnabled( enabled ); - update(); -} - -void -RatingWidget::mousePressEvent( QGraphicsSceneMouseEvent* e ) -{ - if ( e->button() == Qt::LeftButton ) - { - QRect rect( contentsRect().topLeft().x(), contentsRect().topLeft().y(), - contentsRect().width(), contentsRect().height() ); - int ratingFromPos = d->ratingPainter.ratingFromPosition( rect, QPoint( e->pos().x(), e->pos().y() ) ); - if ( ratingFromPos >= 0 ) - { - d->hoverRating = d->rating = ratingFromPos; - setToolTip( i18n( "Track rating: %1", (float)d->rating / 2 ) ); - update(); - emit ratingChanged( d->rating ); - } - } -} - - -void -RatingWidget::hoverMoveEvent( QGraphicsSceneHoverEvent* e ) -{ - QRect rect( contentsRect().topLeft().x(), contentsRect().topLeft().y(), - contentsRect().width(), contentsRect().height() ); - d->hoverRating = d->ratingPainter.ratingFromPosition( rect, QPoint( e->pos().x(), e->pos().y() ) ); - - update(); -} - - -void -RatingWidget::hoverEnterEvent( QGraphicsSceneHoverEvent* e ) -{ - QRect rect( contentsRect().topLeft().x(), contentsRect().topLeft().y(), - contentsRect().width(), contentsRect().height() ); - d->hoverRating = d->ratingPainter.ratingFromPosition( rect, QPoint( e->pos().x(), e->pos().y() ) ); - - setToolTip( i18n( "Track rating: %1", (float)d->rating / 2 ) ); - - update(); -} - -void -RatingWidget::hoverLeaveEvent( QGraphicsSceneHoverEvent* ) -{ - d->hoverRating = -1; - update(); -} - - -void -RatingWidget::paint( QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) -{ - Q_UNUSED( option ) - Q_UNUSED( widget ) - if( d->showing ) - { - d->ratingPainter.setEnabled( isEnabled() ); - QRect rect( contentsRect().topLeft().x(), contentsRect().topLeft().y(), - contentsRect().width(), contentsRect().height() ); - d->ratingPainter.paint( painter, rect, d->rating, d->hoverRating ); - } - - // HACK: (this works fine, but if a better fix is found, we should replace it) - // Make sure that the parent item updates itself correctly on startup. - // We use a counter variable to prevent infinite recursion. - if( m_startupUpdates ) - { - parentItem()->update(); - m_startupUpdates--; - } -} - -QSizeF -RatingWidget::sizeHint( Qt::SizeHint hint, const QSizeF& size ) const -{ - Q_UNUSED( hint ) - Q_UNUSED( size ) - int numPix = d->ratingPainter.maxRating(); - if( d->ratingPainter.halfStepsEnabled() ) - numPix /= 2; - - QSizeF pixSize( d->pixSize, d->pixSize ); - if ( !d->ratingPainter.customPixmap().isNull() ) { - pixSize = d->ratingPainter.customPixmap().size(); - } - - return QSizeF( pixSize.width()*numPix + spacing()*(numPix-1) + contentsRect().width(), - pixSize.height() + contentsRect().width() ); -} - -#include "moc_RatingWidget.cpp" - diff --git a/amarok/src/context/widgets/RatingWidget.h b/amarok/src/context/widgets/RatingWidget.h deleted file mode 100644 index 241130c4..00000000 --- a/amarok/src/context/widgets/RatingWidget.h +++ /dev/null @@ -1,169 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 William Viana Soares * - * Copyright (c) 2010 Mark Kretschmann * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -/* - Significant parts of this code is inspired and/or copied from - KDE Nepomuk sources, available at kdelibs/nepomuk -*/ - -#ifndef AMAROK_RATING_WIDGET_H -#define AMAROK_RATING_WIDGET_H - -#include "amarok_export.h" - -#include - -class AMAROK_EXPORT RatingWidget : public QGraphicsWidget -{ - Q_OBJECT - - public: - /** - * Creates a new rating widget. - */ - RatingWidget( QGraphicsItem* parent = 0 ); - - /** - * Destructor - */ - ~RatingWidget(); - - /** - * @return The current rating. - */ - unsigned int rating() const; - - /** - * @return the maximum possible rating. - */ - int maxRating() const; - - /** - * The alignment of the stars. - * - */ - Qt::Alignment alignment() const; - - /** - * The layout direction. If RTL the stars - * representing the rating value will be drawn from the - * right. - * - */ - Qt::LayoutDirection layoutDirection() const; - - /** - * The spacing between the rating stars. - * - */ - int spacing() const; - - QSizeF sizeHint( Qt::SizeHint hint, const QSizeF& size ) const; - - /** - * If half steps are enabled one star equals to 2 rating - * points and uneven rating values result in half-stars being - * drawn. - * - */ - bool halfStepsEnabled() const; - - /** - * The icon used to draw a star. In case a custom pixmap has been set - * this value is ignored. - * - */ - QIcon icon() const; - - void show(); - - void hide(); - - Q_SIGNALS: - /** - * Emitted if the rating is changed by user interaction (ie. mouse click). - * A call to setRating does not trigger this signal. - */ - void ratingChanged( int rating ); - - public Q_SLOTS: - /** - * Set the current rating. Calling this method will NOT trigger the - * ratingChanged signal. - */ - void setRating( int rating ); - - /** - * Set the maximum allowed rating value. The default is 10 which means - * that a rating from 1 to 10 is selectable. If \a max is uneven steps - * are automatically only allowed full. - */ - void setMaxRating( int max ); - - /** - * If half steps are enabled (the default) then - * one rating step corresponds to half a star. - */ - void setHalfStepsEnabled( bool enabled ); - - /** - * Set the spacing between the pixmaps. The default is 0. - */ - void setSpacing( int ); - - /** - * The alignment of the stars in the drawing rect. - * All alignment flags are supported. - */ - void setAlignment( Qt::Alignment align ); - - /** - * LTR or RTL - */ - void setLayoutDirection( Qt::LayoutDirection direction ); - - /** - * Set a custom icon. Defaults to "rating". - */ - void setIcon( const QIcon& icon ); - - /** - * Set a custom pixmap. - */ - void setCustomPixmap( const QPixmap& pixmap ); - - /** - * Set the recommended size of the pixmaps. This is - * only used for the sizeHint. The actual size is always - * dependant on the size of the widget itself. - */ - void setPixmapSize( int size ); - - protected: - virtual void mousePressEvent( QGraphicsSceneMouseEvent* e ); - virtual void hoverMoveEvent( QGraphicsSceneHoverEvent* e ); - virtual void hoverEnterEvent( QGraphicsSceneHoverEvent* e ); - virtual void hoverLeaveEvent( QGraphicsSceneHoverEvent* e ); - virtual void paint( QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0 ); - - private: - class Private; - Private* const d; - int m_startupUpdates; -}; - -#endif diff --git a/amarok/src/context/widgets/RecentlyPlayedListWidget.cpp b/amarok/src/context/widgets/RecentlyPlayedListWidget.cpp deleted file mode 100644 index 0a3eec19..00000000 --- a/amarok/src/context/widgets/RecentlyPlayedListWidget.cpp +++ /dev/null @@ -1,256 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Rick W. Chen * - * Copyright (c) 2013 Konrad Zemek * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "RecentlyPlayedListWidget" - -#include "RecentlyPlayedListWidget.h" - -#include "EngineController.h" -#include "core/meta/Meta.h" -#include "core/support/Amarok.h" -#include "core/support/Debug.h" -#include "core-impl/collections/support/CollectionManager.h" -#include "playlist/PlaylistController.h" - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -ClickableGraphicsWidget::ClickableGraphicsWidget( const QString &url, - QGraphicsItem *parent, - Qt::WindowFlags wFlags ) - : QGraphicsWidget( parent, wFlags ) - , m_url( url ) -{ - setAcceptHoverEvents( true ); - setCursor( Qt::PointingHandCursor ); -} - -ClickableGraphicsWidget::~ClickableGraphicsWidget() -{ -} - -void -ClickableGraphicsWidget::hoverEnterEvent( QGraphicsSceneHoverEvent *event ) -{ - Q_UNUSED( event ) - setOpacity( 0.5 ); - update(); -} - -void -ClickableGraphicsWidget::hoverLeaveEvent( QGraphicsSceneHoverEvent *event ) -{ - Q_UNUSED( event ) - setOpacity( 1 ); - update(); -} - -void -ClickableGraphicsWidget::mousePressEvent( QGraphicsSceneMouseEvent *event ) -{ - Q_UNUSED( event ) -} - -void -ClickableGraphicsWidget::mouseReleaseEvent( QGraphicsSceneMouseEvent *event ) -{ - if( !m_url.isEmpty() ) - { - if( event->button() == Qt::LeftButton ) - emit leftClicked( m_url ); - else if( event->button() == Qt::MidButton ) - emit middleClicked( m_url ); - } -} - -TimeDifferenceLabel::TimeDifferenceLabel( const QDateTime &eventTime , QWidget *parent, - Qt::WindowFlags wFlags ) - : QLabel( parent, wFlags ) - , m_eventTime( eventTime ) -{ - update(); -} - -TimeDifferenceLabel::~TimeDifferenceLabel() -{ -} - -void -TimeDifferenceLabel::update() -{ - setText( Amarok::verboseTimeSince( m_eventTime ) ); -} - -RecentlyPlayedListWidget::RecentlyPlayedListWidget( QGraphicsWidget *parent ) - : Plasma::ScrollWidget( parent ) - , m_layout( new QGraphicsLinearLayout( Qt::Vertical ) ) - , m_trackIcon( KIcon( "media-album-track") ) -{ - QGraphicsWidget *content = new QGraphicsWidget; - content->setLayout( m_layout ); - setWidget( content ); - - connect( EngineController::instance(), SIGNAL(trackChanged(Meta::TrackPtr)), - SLOT(trackChanged(Meta::TrackPtr)) ); - - m_updateTimer = new QTimer( this ); - m_updateTimer->start( 20 * 1000 ); - - // Load saved data - const KConfigGroup group = Amarok::config( "Recently Played" ); - const QVariantList recentlyPlayed = group.readEntry( "Last Played Dates", QVariantList() ); - const QStringList displayNames = group.readEntry( "Display Names", QStringList() ); - const QStringList trackUrls = group.readEntry( "Urls", QStringList() ); - for( int i = 0; i < trackUrls.size(); ++i ) - addTrack( recentlyPlayed[i].toDateTime(), displayNames[i], trackUrls[i] ); -} - -RecentlyPlayedListWidget::~RecentlyPlayedListWidget() -{ - QVariantList recentlyPlayed; - QStringList displayNames; - QStringList trackUrls; - foreach( const RecentlyPlayedTrackData &data, m_recentTracks ) - { - recentlyPlayed.append( data.recentlyPlayed ); - displayNames.append( data.displayName ); - trackUrls.append( data.trackUrl ); - } - - KConfigGroup group = Amarok::config( "Recently Played" ); - group.writeEntry( "Last Played Dates", recentlyPlayed ); - group.writeEntry( "Display Names", displayNames ); - group.writeEntry( "Urls", trackUrls ); - group.sync(); -} - -QGraphicsWidget* -RecentlyPlayedListWidget::addWidgetItem( const RecentlyPlayedTrackData &data ) -{ - KSqueezedTextLabel *squeezer = new KSqueezedTextLabel( data.displayName ); - squeezer->setTextElideMode( Qt::ElideRight ); - squeezer->setAttribute( Qt::WA_NoSystemBackground ); - squeezer->setCursor( Qt::PointingHandCursor ); - - QGraphicsProxyWidget *labelWidget = new QGraphicsProxyWidget; - labelWidget->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred ); - labelWidget->setWidget( squeezer ); - - TimeDifferenceLabel *lastPlayed = new TimeDifferenceLabel( data.recentlyPlayed ); - lastPlayed->setAttribute( Qt::WA_NoSystemBackground ); - lastPlayed->setAlignment( Qt::AlignRight ); - lastPlayed->setWordWrap( false ); - lastPlayed->setCursor( Qt::PointingHandCursor ); - connect( m_updateTimer, SIGNAL(timeout()), lastPlayed, SLOT(update()) ); - - QGraphicsProxyWidget *lastPlayedWidget = new QGraphicsProxyWidget; - lastPlayedWidget->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ); - lastPlayedWidget->setWidget( lastPlayed ); - - Plasma::IconWidget *icon = new Plasma::IconWidget; - QSizeF iconSize = icon->sizeFromIconSize( QFontMetricsF(QFont()).height() ); - icon->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ); - icon->setMinimumSize( iconSize ); - icon->setMaximumSize( iconSize ); - icon->setIcon( m_trackIcon ); - - QGraphicsLinearLayout *itemLayout = new QGraphicsLinearLayout( Qt::Horizontal ); - itemLayout->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); - itemLayout->setContentsMargins( 0, 0, 0, 0 ); - itemLayout->addItem( icon ); - itemLayout->addItem( labelWidget ); - itemLayout->addItem( lastPlayedWidget ); - - ClickableGraphicsWidget *itemWidget = new ClickableGraphicsWidget( data.trackUrl ); - itemWidget->setLayout( itemLayout ); - connect( itemWidget, SIGNAL(leftClicked(QString)), SLOT(itemLeftClicked(QString)) ); - connect( itemWidget, SIGNAL(middleClicked(QString)), SLOT(itemMiddleClicked(QString)) ); - - m_layout->insertItem( 0, itemWidget ); - - return itemWidget; -} - -void -RecentlyPlayedListWidget::itemLeftClicked( const QString &url ) -{ - Playlist::Controller::instance()->insertOptioned( KUrl( url ), - Playlist::OnDoubleClickOnSelectedItems ); -} - -void -RecentlyPlayedListWidget::itemMiddleClicked( const QString &url ) -{ - Playlist::Controller::instance()->insertOptioned( KUrl( url ), - Playlist::OnMiddleClickOnSelectedItems ); -} - -void -RecentlyPlayedListWidget::addTrack( const Meta::TrackPtr &track ) -{ - const Meta::ArtistPtr artist = track->artist(); - const QString displayName = !artist || artist->prettyName().isEmpty() - ? track->prettyName() - : i18nc( "%1 is artist, %2 is title", "%1 - %2", - artist->prettyName(), track->prettyName() ); - - addTrack( QDateTime::currentDateTime(), displayName, track->uidUrl() ); -} - -void RecentlyPlayedListWidget::addTrack( const QDateTime &recentlyPlayed, - const QString &displayName, - const QString &trackUrl ) -{ - while( m_recentTracks.size() >= 10 ) - { - // Get rid of the least recent entry - RecentlyPlayedTrackData data = m_recentTracks.dequeue(); - delete data.widget; - } - - RecentlyPlayedTrackData data; - data.recentlyPlayed = recentlyPlayed; - data.displayName = displayName; - data.trackUrl = trackUrl; - data.widget = addWidgetItem( data ); - m_recentTracks.enqueue( data ); -} - -void -RecentlyPlayedListWidget::trackChanged( const Meta::TrackPtr &track ) -{ - // Nothing has changed - if( m_currentTrack == track ) - return; - - // lastTrack will be null if we're resuming from a stopped state - Meta::TrackPtr lastTrack = m_currentTrack; - m_currentTrack = track; - - if( lastTrack ) - addTrack( lastTrack ); -} diff --git a/amarok/src/context/widgets/RecentlyPlayedListWidget.h b/amarok/src/context/widgets/RecentlyPlayedListWidget.h deleted file mode 100644 index 3c1081dc..00000000 --- a/amarok/src/context/widgets/RecentlyPlayedListWidget.h +++ /dev/null @@ -1,109 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Rick W. Chen * - * Copyright (c) 2013 Konrad Zemek * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef RECENTLY_PLAYED_LIST_WIDGET_H -#define RECENTLY_PLAYED_LIST_WIDGET_H - -#include "core/meta/forward_declarations.h" - -#include -#include -#include - -#include -#include -#include -#include - -class QGraphicsLinearLayout; - -class ClickableGraphicsWidget : public QGraphicsWidget -{ - Q_OBJECT - -public: - explicit ClickableGraphicsWidget( const QString &url, QGraphicsItem *parent = 0, - Qt::WindowFlags wFlags = 0 ); - ~ClickableGraphicsWidget(); - -signals: - void leftClicked( const QString &url ); - void middleClicked( const QString &url ); - -protected: - void hoverEnterEvent( QGraphicsSceneHoverEvent *event ); - void hoverLeaveEvent( QGraphicsSceneHoverEvent *event ); - void mousePressEvent( QGraphicsSceneMouseEvent *event ); - void mouseReleaseEvent( QGraphicsSceneMouseEvent *event ); - -private: - const QString m_url; -}; - -class TimeDifferenceLabel : public QLabel -{ - Q_OBJECT - -public: - explicit TimeDifferenceLabel( const QDateTime &eventTime, QWidget *parent = 0, - Qt::WindowFlags wFlags = 0 ); - ~TimeDifferenceLabel(); - -public slots: - void update(); - -private: - const QDateTime m_eventTime; -}; - -class RecentlyPlayedListWidget : public Plasma::ScrollWidget -{ - Q_OBJECT - - struct RecentlyPlayedTrackData - { - QDateTime recentlyPlayed; - QString displayName; - QString trackUrl; - QGraphicsWidget *widget; - }; - -public: - explicit RecentlyPlayedListWidget( QGraphicsWidget *parent = 0 ); - ~RecentlyPlayedListWidget(); - -private slots: - void itemLeftClicked( const QString &url ); - void itemMiddleClicked( const QString &url ); - void trackChanged( const Meta::TrackPtr &track ); - -private: - Q_DISABLE_COPY( RecentlyPlayedListWidget ) - - void addTrack( const Meta::TrackPtr &track ); - void addTrack( const QDateTime &recentlyPlayed, const QString &displayName, - const QString &trackUrl ); - QGraphicsWidget *addWidgetItem( const RecentlyPlayedTrackData &data ); - - Meta::TrackPtr m_currentTrack; - QGraphicsLinearLayout *m_layout; - QQueue m_recentTracks; - KIcon m_trackIcon; - QTimer *m_updateTimer; -}; - -#endif // RECENTLY_PLAYED_LIST_WIDGET_H diff --git a/amarok/src/context/widgets/TextScrollingWidget.cpp b/amarok/src/context/widgets/TextScrollingWidget.cpp deleted file mode 100644 index 5394fe5d..00000000 --- a/amarok/src/context/widgets/TextScrollingWidget.cpp +++ /dev/null @@ -1,373 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Simon Esneault * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "TextScrollingWidget" - -#include "TextScrollingWidget.h" - -#include "core/support/Debug.h" - -#include - -#include -#include -#include -#include -#include -#include -#include - -class TextScrollingWidgetPrivate -{ -public: - TextScrollingWidgetPrivate( TextScrollingWidget *parent ) - : width( 0.0 ) - , delta( 0.0 ) - , currentDelta( 0.0 ) - , drawBackground( false ) - , alignment( Qt::AlignHCenter ) - , textBackground( 0 ) - , textItem( new QGraphicsSimpleTextItem( parent ) ) - , q_ptr( parent ) - {} - - ~TextScrollingWidgetPrivate() - {} - - void _delayedForwardAnimation() - { - Q_Q( TextScrollingWidget ); - if( q->isUnderMouse() ) - { - q->setText( text ); - q->startAnimation( QAbstractAnimation::Forward ); - } - } - - void drawRoundedRectAroundText( QPainter *p ) - { - Q_Q( TextScrollingWidget ); - p->save(); - p->setRenderHint( QPainter::Antialiasing ); - - if( !textBackground ) - { - textBackground = new Plasma::FrameSvg( q ); - textBackground->setImagePath( QLatin1String("widgets/text-background") ); - textBackground->setEnabledBorders( Plasma::FrameSvg::AllBorders ); - } - - QRectF rect = textItem->boundingRect(); - rect = q->mapRectFromItem( textItem, rect ); - rect.adjust( -5, -5, 5, 5 ); - - textBackground->resizeFrame( rect.size() ); - textBackground->paintFrame( p, rect.topLeft() ); - p->restore(); - } - - void setScrollingText( const QString &str ) - { - text = str; - } - - void setText( const QString &str ) - { - text = str; - textItem->setText( text ); - - if( animation ) - animation.data()->stop(); - - } - - qreal width; // box width - qreal delta; // complete delta - qreal currentDelta; // current delta - bool drawBackground; // whether to draw background svg - QString text; // full sentence - Qt::Alignment alignment; // horizontal text item alignment - Plasma::FrameSvg *textBackground; // background svg for text - QWeakPointer animation; // scroll animation - QGraphicsSimpleTextItem *textItem; - -private: - TextScrollingWidget *const q_ptr; - Q_DECLARE_PUBLIC( TextScrollingWidget ) -}; - -TextScrollingWidget::TextScrollingWidget( QGraphicsWidget *parent, Qt::WindowFlags wFlags ) - : QGraphicsWidget( parent, wFlags ) - , d_ptr( new TextScrollingWidgetPrivate(this) ) -{ - setAcceptHoverEvents( true ); - setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Fixed ); - setFlags( flags() | QGraphicsItem::ItemClipsChildrenToShape ); -} - -TextScrollingWidget::~TextScrollingWidget() -{ - delete d_ptr; -} - -void -TextScrollingWidget::setBrush( const QBrush &brush ) -{ - Q_D( TextScrollingWidget ); - d->textItem->setBrush( brush ); -} - -void -TextScrollingWidget::setScrollingText( const QString &text ) -{ - Q_D( TextScrollingWidget ); - d->setScrollingText( text ); - updateGeometry(); -} - -void -TextScrollingWidget::setText( const QString &text ) -{ - Q_D( TextScrollingWidget ); - d->setText( text ); -} - -void -TextScrollingWidget::setAlignment( Qt::Alignment alignment ) -{ - Q_D( TextScrollingWidget ); - d->alignment = alignment; - updateGeometry(); -} - -void -TextScrollingWidget::setFont( const QFont &font ) -{ - Q_D( TextScrollingWidget ); - d->textItem->setFont( font ); - QFontMetricsF fm( font ); - const int textWidth = fm.width( d->text ); - d->delta = textWidth > d->width ? textWidth - d->width + 5 : 0; -} - -QBrush -TextScrollingWidget::brush() const -{ - Q_D( const TextScrollingWidget ); - return d->textItem->brush(); -} - -QFont -TextScrollingWidget::font() const -{ - Q_D( const TextScrollingWidget ); - return d->textItem->font(); -} - -QString -TextScrollingWidget::text() const -{ - Q_D( const TextScrollingWidget ); - return d->text; -} - -void -TextScrollingWidget::setGeometry( const QRectF &rect ) -{ - Q_D( TextScrollingWidget ); - QGraphicsWidget::setGeometry( rect ); - - // reset the animation and stuff - QPropertyAnimation *animation = d->animation.data(); - if( animation ) - { - animation->stop(); - animation->deleteLater(); - d->animation.clear(); - } - - QRectF textRect = mapFromParent( rect ).boundingRect(); - QFontMetricsF fm( font() ); - int textWidth = fm.width( d->text ); - d->width = textRect.width(); - d->delta = (textWidth > d->width) ? (textWidth - d->width) : 0; - d->textItem->setText( fm.elidedText( d->text, Qt::ElideRight, d->width ) ); - - qreal textX( 0.0 ); - switch( d->alignment ) - { - case Qt::AlignHCenter: - textX = ( textRect.width() - d->textItem->boundingRect().width() ) / 2; - break; - default: - case Qt::AlignLeft: - textX = textRect.left(); - break; - case Qt::AlignRight: - textX = textRect.right() - d->textItem->boundingRect().width(); - break; - } - d->textItem->setPos( textX, textRect.top() ); -} - -void -TextScrollingWidget::hoverEnterEvent( QGraphicsSceneHoverEvent* e ) -{ - Q_D( TextScrollingWidget ); - if( !isAnimating() && d->delta ) - QTimer::singleShot( 150, this, SLOT(_delayedForwardAnimation()) ); - e->accept(); -} - -bool -TextScrollingWidget::isEmpty() const -{ - Q_D( const TextScrollingWidget ); - return d->text.isEmpty(); -} - -bool -TextScrollingWidget::isAnimating() const -{ - Q_D( const TextScrollingWidget ); - return ( d->animation && d->animation.data()->state() == QAbstractAnimation::Running ); -} - -qreal -TextScrollingWidget::animationValue() const -{ - Q_D( const TextScrollingWidget ); - return d->currentDelta; -} - -void -TextScrollingWidget::animationFinished() -{ - Q_D( TextScrollingWidget ); - if( !d->animation ) - return; - - QPropertyAnimation *animation = d->animation.data(); - if( animation->direction() == QAbstractAnimation::Forward ) - { - startAnimation( QAbstractAnimation::Backward ); - } - else - { - // Scroll again if the mouse is still over. - if( isUnderMouse() ) - startAnimation( QAbstractAnimation::Forward ); - else - { - setScrollingText( d->text ); - d->animation.data()->deleteLater(); - update(); - } - } -} - -void -TextScrollingWidget::startAnimation( QAbstractAnimation::Direction direction ) -{ - Q_D( TextScrollingWidget ); - QPropertyAnimation *animation = d->animation.data(); - if( !animation ) - { - animation = new QPropertyAnimation( this, "animationValue" ); - animation->setDuration( d->delta*15 ); - animation->setStartValue( 0.0 ); - animation->setEndValue( 1.0 ); - animation->setEasingCurve( QEasingCurve::InOutQuad ); - d->animation = animation; - connect( animation, SIGNAL(finished()), this, SLOT(animationFinished()) ); - } - else - { - animation->stop(); - } - - animation->setDirection( direction ); - animation->start( QAbstractAnimation::KeepWhenStopped ); -} - -void -TextScrollingWidget::animate( qreal value ) -{ - Q_D( TextScrollingWidget ); - if( d->animation.isNull() ) - return; - - d->currentDelta = -value * d->delta; - d->textItem->setPos( d->currentDelta, 0 ); -} - -QSizeF -TextScrollingWidget::sizeHint( Qt::SizeHint which, const QSizeF &constraint ) const -{ - Q_D( const TextScrollingWidget ); - QFontMetricsF fm( font() ); - switch( which ) - { - case Qt::MinimumSize: - return QSizeF( fm.width( d->text ) / 4.0, fm.height() ); - case Qt::MaximumSize: - return QSizeF( -1, fm.height() + 8 ); - case Qt::MinimumDescent: - return QSizeF( QGraphicsWidget::sizeHint(which, constraint).width(), fm.descent() ); - default: - break; - } - return QSizeF( constraint.width(), fm.height() ); -} - -Qt::Alignment -TextScrollingWidget::alignment() const -{ - Q_D( const TextScrollingWidget ); - return d->alignment; -} - -QRectF -TextScrollingWidget::boundingRect() const -{ - Q_D( const TextScrollingWidget ); - return mapRectFromItem( d->textItem, d->textItem->boundingRect() ); -} - -void -TextScrollingWidget::paint( QPainter *p, const QStyleOptionGraphicsItem *option, QWidget *widget ) -{ - QGraphicsWidget::paint( p, option, widget ); - Q_D( TextScrollingWidget ); - if( d->drawBackground ) - d->drawRoundedRectAroundText( p ); -} - -bool -TextScrollingWidget::isDrawingBackground() const -{ - Q_D( const TextScrollingWidget ); - return d->drawBackground; -} - -void -TextScrollingWidget::setDrawBackground( bool enable ) -{ - Q_D( TextScrollingWidget ); - d->drawBackground = enable; -} - -#include "moc_TextScrollingWidget.cpp" diff --git a/amarok/src/context/widgets/TextScrollingWidget.h b/amarok/src/context/widgets/TextScrollingWidget.h deleted file mode 100644 index 394498a4..00000000 --- a/amarok/src/context/widgets/TextScrollingWidget.h +++ /dev/null @@ -1,110 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Simon Esneault * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_TEXT_SCROLLING_WIDGET_H -#define AMAROK_TEXT_SCROLLING_WIDGET_H - -#include "amarok_export.h" - -#include -#include - -//forward -class TextScrollingWidgetPrivate; - -/** -* \brief An animated QGrahicsTextItem on hovering -* -* The text will be automatically truncate to a specified width and will -* be animated when mouse is hovering above the text (if truncated). -* -* \author Simon Esneault -*/ - -class AMAROK_EXPORT TextScrollingWidget : public QGraphicsWidget -{ - Q_OBJECT - Q_PROPERTY( qreal animationValue READ animationValue WRITE animate ) - Q_PROPERTY( Qt::Alignment alignment READ alignment WRITE setAlignment ) - Q_PROPERTY( QBrush brush READ brush WRITE setBrush ) - Q_PROPERTY( QString text READ text WRITE setText ) - Q_PROPERTY( bool drawBackground READ isDrawingBackground WRITE setDrawBackground ) - Q_PROPERTY( QFont font READ font WRITE setFont ) - Q_PROPERTY( bool empty READ isEmpty ) - - public: - TextScrollingWidget( QGraphicsWidget* parent = 0, Qt::WindowFlags wFlags = 0 ); - virtual ~TextScrollingWidget(); - - /** - * Set the scrolling text. The text will be elided and scrolled - * automatically if text is wider than the avaialble geometry. - */ - void setScrollingText( const QString &text ); - - void setAlignment( Qt::Alignment alignment ); - - void setBrush( const QBrush &brush ); - - void setDrawBackground( bool enable ); - - void setText( const QString &text ); - - void setFont( const QFont &font ); - - Qt::Alignment alignment() const; - - QBrush brush() const; - - QFont font() const; - - QString text() const; - - bool isAnimating() const; - - bool isEmpty() const; - - bool isDrawingBackground() const; - - virtual QRectF boundingRect() const; - - void paint( QPainter *p, const QStyleOptionGraphicsItem *option, QWidget *widget = 0 ); - - protected slots: - void startAnimation( QAbstractAnimation::Direction direction ); - void animationFinished(); - - protected: - /** - * Reimplement mouse hover enter event - */ - virtual void hoverEnterEvent( QGraphicsSceneHoverEvent* ); - - virtual QSizeF sizeHint( Qt::SizeHint which, const QSizeF &constraint = QSizeF() ) const; - - virtual void setGeometry( const QRectF &rect ); - - qreal animationValue() const; - void animate( qreal anim ); - - private: - TextScrollingWidgetPrivate *const d_ptr; - Q_DECLARE_PRIVATE( TextScrollingWidget ) - - Q_PRIVATE_SLOT( d_ptr, void _delayedForwardAnimation() ) -}; - -#endif diff --git a/amarok/src/context/widgets/TextWidget.cpp b/amarok/src/context/widgets/TextWidget.cpp deleted file mode 100644 index ab2617bf..00000000 --- a/amarok/src/context/widgets/TextWidget.cpp +++ /dev/null @@ -1,120 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Leo Franchi * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "TextWidget" - -#include "TextWidget.h" - -#include "core/support/Debug.h" - -#include - -namespace Context -{ - -TextWidget::TextWidget( QGraphicsItem* parent, QGraphicsScene* scene ) - : QGraphicsTextItem( parent, scene ) -{} - -void TextWidget::setText( const QString text ) -{ - setHtml( text ); -} - -Qt::Orientations TextWidget::expandingDirections() const -{ - return Qt::Vertical; -} - -QSizeF TextWidget::minimumSize() const -{ - return QSizeF( textWidth(), boundingRect().height() ); -} - -QSizeF TextWidget::maximumSize() const -{ - return minimumSize(); -} - -bool TextWidget::hasHeightForWidth() const -{ - return true; -} - -qreal TextWidget::heightForWidth( qreal w ) const -{ - document()->setTextWidth( w ); - qreal height = document()->size().height(); -// debug() << "heightForWidth( " << w << " ) is " << height; - return height; -} - -bool TextWidget::hasWidthForHeight() const -{ - return false; -} - -qreal TextWidget::widthForHeight( qreal h ) const -{ - Q_UNUSED( h ) - return 0; -} - -QRectF TextWidget::geometry() const -{ -// debug() << "returning geometry: " << boundingRect().toRect(); - return boundingRect().toRect(); -} - -void TextWidget::setGeometry( const QRectF& geom ) -{ -// debug() << "getting told to change geometry from: " << geometry() << " to : " << geom; - prepareGeometryChange(); - setTextWidth( geom.width() ); - setPos( geom.topLeft() ); - if( document()->size().height() > geom.height() ) - setDocument( shortenHeight( geom.height() ) ); - - update(); -} - -QSizeF TextWidget::sizeHint() const -{ - return document()->size(); -} - -QTextDocument* TextWidget::shortenHeight( qreal height ) -{ - QStringList lines = document()->toHtml().split( "
" ); -// debug() << "trying to shorten: " << document()->toHtml() << " split into " << lines.size() << " lines"; - for( int i = lines.size(); i > 1; i-- ) - { - QStringList tmp = lines; - for( int k = lines.size(); k >= i; k-- ) - tmp.removeAt( k - 1 ); // remove lines from the cut to the end - QString newtext = tmp.join( "
" ); - QTextDocument* newdoc = new QTextDocument(); - newdoc->setHtml( newtext ); -// debug() << "trying to remove bottom line: " << i - 1 << " new size is: " << newdoc->size().height() << " max is: " << height; - if( newdoc->size().height() <= height ) - return newdoc; - } -// debug() << "couldn't shorten height, failing!"; - return document(); -} - -} // Context namespace - diff --git a/amarok/src/context/widgets/TextWidget.h b/amarok/src/context/widgets/TextWidget.h deleted file mode 100644 index 0b88c6e9..00000000 --- a/amarok/src/context/widgets/TextWidget.h +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Leo Franchi * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_TEXT_WIDGET_H -#define AMAROK_TEXT_WIDGET_H - -#include "amarok_export.h" - -#include - -#include - -namespace Context -{ - -class AMAROK_EXPORT TextWidget : public QGraphicsTextItem, - public Plasma::LayoutItem -{ - -public: - explicit TextWidget( QGraphicsItem* parent = 0, QGraphicsScene* scene = 0 ); - - void setText( const QString text ); - - // layout stuff - Qt::Orientations expandingDirections() const; - - QSizeF minimumSize() const; - QSizeF maximumSize() const; - - bool hasHeightForWidth() const; - qreal heightForWidth( qreal w ) const; - - bool hasWidthForHeight() const; - qreal widthForHeight(qreal h) const; - - QRectF geometry() const; - void setGeometry( const QRectF& geometry ); - - QSizeF sizeHint() const; - -private: - - QTextDocument* shortenHeight( qreal height ); -}; - -} // Context namespace - -#endif diff --git a/amarok/src/context/widgets/ToolBoxIcon.cpp b/amarok/src/context/widgets/ToolBoxIcon.cpp deleted file mode 100644 index 7b985fa9..00000000 --- a/amarok/src/context/widgets/ToolBoxIcon.cpp +++ /dev/null @@ -1,180 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 William Viana Soares * - * Copyright (c) 2009 Leo Franchi * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "ToolBoxIcon.h" - -#include "core/support/Debug.h" -#include "PaletteHandler.h" - -#include - -#include - -#include - -#define PADDING 15 - - -ToolBoxIcon::ToolBoxIcon( QGraphicsItem *parent, const float opacity ) - : Plasma::IconWidget( parent ) - , m_hovering( 0 ) - , m_baseOpacity( opacity ) -{ - m_text = new QGraphicsSimpleTextItem( this ); - m_text->setCursor( Qt::ArrowCursor ); // Don't show the carot, the text isn't editable. - - QFont font; - font.setBold( false ); - font.setPointSize( font.pointSize() - 1 ); - font.setStyleStrategy( QFont::PreferAntialias ); - - m_text->setFont( font ); - m_text->show(); - - setOpacity( 1.0 - m_baseOpacity ); -} - -ToolBoxIcon::~ToolBoxIcon() -{} - -void -ToolBoxIcon::mousePressEvent( QGraphicsSceneMouseEvent *event ) -{ - if( event->button() != Qt::LeftButton ) - { - Plasma::IconWidget::mousePressEvent( event ); - return; - } - - if( data( 0 ) != QVariant() ) - { - DEBUG_LINE_INFO - debug() << data( 0 ).toString(); - emit appletChosen( data( 0 ).toString() ); - } - else - { - Plasma::IconWidget::mousePressEvent( event ); - } -} - -void -ToolBoxIcon::mousePressed( bool pressed ) -{ - DEBUG_BLOCK - - if( pressed && data( 0 ) != QVariant() ) - { - debug() << data( 0 ).toString(); - emit appletChosen( data( 0 ).toString() ); - } -} - -void -ToolBoxIcon::paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget ) -{ - painter->setRenderHint( QPainter::Antialiasing ); - if( Plasma::IconWidget::drawBackground() ) - { - if( m_text->text().isEmpty() ) - m_text->setText( text() ); - - const QFontMetricsF fm( m_text->font() ); - m_text->setPos( PADDING, size().height() / 2 - fm.boundingRect( m_text->text() ).height() / 2 ); - painter->save(); - - // QColor color = KColorScheme( QPalette::Active, KColorScheme::Window, - // Plasma::Theme::defaultTheme()->colorScheme() ).background().color(); - - QLinearGradient gradient( boundingRect().topLeft(), boundingRect().bottomLeft() ); - QColor highlight = PaletteHandler::highlightColor(); - highlight.setAlpha( 160 ); - gradient.setColorAt( 0, highlight.darker( 140 ) ); - highlight.setAlpha( 220 ); - gradient.setColorAt( 1, highlight.darker( 180 ) ); - QPainterPath path; - path.addRoundedRect( boundingRect(), 3, 3 ); - painter->fillPath( path, gradient ); - painter->restore(); - - // draw border - painter->save(); - painter->translate(0.5, 0.5); - painter->setPen( PaletteHandler::highlightColor().darker( 150 ) ); - painter->drawRoundedRect( boundingRect(), 3, 3 ); - painter->restore(); - } - else - Plasma::IconWidget::paint( painter, option, widget ); -} - -QRectF -ToolBoxIcon::boundingRect() const -{ - return QRectF( QPointF( 0, 0 ), size() ); -} - -void -ToolBoxIcon::hoverEnterEvent( QGraphicsSceneHoverEvent *event ) -{ - m_hovering = true; - m_defaultTextBrush = m_text->brush(); - m_text->setBrush( The::paletteHandler()->palette().highlightedText() ); - Plasma::IconWidget::hoverEnterEvent( event ); -} - -void -ToolBoxIcon::hoverLeaveEvent( QGraphicsSceneHoverEvent *event ) -{ - m_hovering = false; - m_text->setBrush( m_defaultTextBrush ); - Plasma::IconWidget::hoverLeaveEvent( event ); -} - -QPainterPath -ToolBoxIcon::shape() const -{ - if( Plasma::IconWidget::drawBackground() ) - { - QSize shapeSize( size().width() - 2, size().height() - 2 ); - return Plasma::PaintUtils::roundedRectangle( QRectF( QPointF( 0.0, 0.0 ), shapeSize ), 10.0 ); - } - - return Plasma::IconWidget::shape(); -} - -void -ToolBoxIcon::setText( const QString &text ) -{ - m_text->setText( text ); - update(); -} - -QString -ToolBoxIcon::text() const -{ - return m_text->text(); -} - -void -ToolBoxIcon::setBrush( const QBrush& b ) -{ - m_text->setBrush( b ); -} - -#include "moc_ToolBoxIcon.cpp" - diff --git a/amarok/src/context/widgets/ToolBoxIcon.h b/amarok/src/context/widgets/ToolBoxIcon.h deleted file mode 100644 index 43940b08..00000000 --- a/amarok/src/context/widgets/ToolBoxIcon.h +++ /dev/null @@ -1,82 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 William Viana Soares * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef TOOLBOX_ICON_H -#define TOOLBOX_ICON_H - -#include "amarok_export.h" - -#include - -#include -#include -#include -#include - -class QPainterPath; - -namespace Plasma -{ - class Animation; -} - -class AMAROK_EXPORT ToolBoxIcon: public Plasma::IconWidget -{ - Q_OBJECT - -public: - explicit ToolBoxIcon( QGraphicsItem *parent = 0, const float opacity = 0.8 ); - ~ToolBoxIcon(); - - /** - * reimplemented from Plasma::Icon - */ - QPainterPath shape() const; - - QRectF boundingRect() const; - - /** - * reimplemented from Plasma::Icon - */ - void setText( const QString &text ); - - QString text() const; - - void setBrush( const QBrush& ); - -protected: - void paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0 ); - void hoverEnterEvent( QGraphicsSceneHoverEvent *event ); - void hoverLeaveEvent( QGraphicsSceneHoverEvent *event ); - void mousePressEvent( QGraphicsSceneMouseEvent *event ); - -Q_SIGNALS: - void appletChosen( const QString &pluginName ); - -private slots: - void mousePressed( bool pressed ); - -private: - bool m_hovering; - - const qreal m_baseOpacity; - - QGraphicsSimpleTextItem *m_text; - QBrush m_defaultTextBrush; -}; - -#endif - diff --git a/amarok/src/context/widgets/appletexplorer/AppletExplorer.cpp b/amarok/src/context/widgets/appletexplorer/AppletExplorer.cpp deleted file mode 100644 index c9136124..00000000 --- a/amarok/src/context/widgets/appletexplorer/AppletExplorer.cpp +++ /dev/null @@ -1,232 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 William Viana Soares * - * Significant parts of this code is inspired * - * and/or copied from KDE Plasma sources, available * - * at kdebase/workspace/libs/plasmagenericshell * - * * - ****************************************************************************************/ - -/**************************************************************************************** - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "AppletExplorer" - -#include "AppletExplorer.h" - -#include "AppletIcon.h" -#include "core/support/Debug.h" -#include "PaletteHandler.h" - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -namespace Context -{ - -AppletExplorer::AppletExplorer( QGraphicsItem *parent ) - : QGraphicsWidget( parent ) - , m_containment( 0 ) - , m_scrollWidget( 0 ) -{ - init(); -} - -AppletExplorer::~AppletExplorer() -{} - -void -AppletExplorer::addApplet( const QString &name ) -{ - DEBUG_BLOCK - if( !name.isEmpty() && containment() ) - emit addAppletToContainment( name, -1 ); //always add the applet at the end -} - -void -AppletExplorer::hideMenu() -{ - hide(); - emit appletExplorerHid(); -} - -void -AppletExplorer::init() -{ - QGraphicsLinearLayout *layout = new QGraphicsLinearLayout( Qt::Vertical, this ); - QSignalMapper *iconTriggerMapper = new QSignalMapper( this ); - QGraphicsWidget *scrollView = new QGraphicsWidget( this ); - m_scrollWidget = new Plasma::ScrollWidget( this ); - m_scrollWidget->setWidget( scrollView ); - // m_scrollWidget->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); - m_scrollWidget->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ); - QGraphicsLinearLayout *scrollLayout = new QGraphicsLinearLayout( scrollView ); - m_scrollWidget->setMinimumHeight( 0 ); - - foreach( AppletIconWidget *widget, listAppletWidgets() ) - { - scrollLayout->addItem( widget ); - scrollLayout->setAlignment( widget, Qt::AlignCenter ); - widget->setMinimumSize( widget->sizeFromIconSize( 48 ) ); - widget->setMaximumSize( widget->sizeFromIconSize( 48 ) ); - connect( widget, SIGNAL(clicked()), iconTriggerMapper, SLOT(map()) ); - iconTriggerMapper->setMapping( widget, widget->pluginName() ); - } - connect( iconTriggerMapper, SIGNAL(mapped(QString)), SLOT(addApplet(QString)) ); - - Plasma::IconWidget *appletIcon = new Plasma::IconWidget( this ); - appletIcon->setIcon( KIcon( "preferences-plugin" ) ); - const QSizeF iconSize = appletIcon->sizeFromIconSize( 22 ); - appletIcon->setMinimumSize( iconSize ); - appletIcon->setMaximumSize( iconSize ); - - Plasma::IconWidget *hideIcon = new Plasma::IconWidget( this ); - hideIcon->setIcon( KIcon( "window-close" ) ); - hideIcon->setToolTip( i18n( "Hide menu" ) ); - hideIcon->setMinimumSize( iconSize ); - hideIcon->setMaximumSize( iconSize ); - connect( hideIcon, SIGNAL(clicked()), this, SLOT(hideMenu()) ); - - Plasma::IconWidget *forwardIcon = new Plasma::IconWidget( this ); - forwardIcon->setIcon( KIcon( "go-next" ) ); - forwardIcon->setMinimumSize( iconSize ); - forwardIcon->setMaximumSize( iconSize ); - connect( forwardIcon, SIGNAL(clicked()), this, SLOT(scrollRight()) ); - - Plasma::IconWidget *backIcon = new Plasma::IconWidget( this ); - backIcon->setIcon( KIcon( "go-previous" ) ); - backIcon->setMinimumSize( iconSize ); - backIcon->setMaximumSize( iconSize ); - connect( backIcon, SIGNAL(clicked()), this, SLOT(scrollLeft()) ); - - QLabel *titleLabel = new QLabel( i18n("Applet Explorer") ); - titleLabel->setAttribute( Qt::WA_NoSystemBackground ); - titleLabel->setWordWrap( false ); - QGraphicsProxyWidget *titleWidget = new QGraphicsProxyWidget( this ); - titleWidget->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred ); - titleWidget->setWidget( titleLabel ); - - QGraphicsLinearLayout *headerLayout = new QGraphicsLinearLayout; - headerLayout->addItem( appletIcon ); - headerLayout->addItem( titleWidget ); - headerLayout->addItem( backIcon ); - headerLayout->addItem( forwardIcon ); - headerLayout->addItem( hideIcon ); - headerLayout->setAlignment( appletIcon, Qt::AlignLeft | Qt::AlignTop ); - headerLayout->setAlignment( titleWidget, Qt::AlignLeft | Qt::AlignTop ); - headerLayout->setAlignment( backIcon, Qt::AlignRight | Qt::AlignTop ); - headerLayout->setAlignment( forwardIcon, Qt::AlignRight | Qt::AlignTop ); - headerLayout->setAlignment( hideIcon, Qt::AlignRight | Qt::AlignTop ); - headerLayout->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Maximum ); - - layout->addItem( headerLayout ); - layout->addItem( m_scrollWidget ); - layout->setAlignment( headerLayout, Qt::AlignTop ); - layout->setAlignment( m_scrollWidget, Qt::AlignCenter ); -} - -QSizeF -AppletExplorer::sizeHint( Qt::SizeHint which, const QSizeF &constraint ) const -{ - QSizeF sz = QGraphicsWidget::sizeHint( which, constraint ); - return QSizeF( sz.width(), sz.height() + 2 ); -} - -void -AppletExplorer::paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget ) -{ - Q_UNUSED( option ) - Q_UNUSED( widget ) - - painter->save(); - painter->setRenderHint( QPainter::Antialiasing ); - painter->setOpacity( 0.9 ); - - QLinearGradient gradient( boundingRect().topLeft().x(), boundingRect().topLeft().y(), - boundingRect().bottomLeft().x(), boundingRect().bottomLeft().y() / 1.8 + 3 ); - - QColor highlight = PaletteHandler::highlightColor(); - gradient.setSpread( QGradient::RepeatSpread ); - gradient.setColorAt( 0, highlight.lighter( 100 ) ); - gradient.setColorAt( 1, highlight.lighter( 140 ) ); - QPainterPath path; - path.addRoundedRect( boundingRect(), 6, 6 ); - painter->fillPath( path, gradient ); - painter->restore(); - - // draw border - painter->save(); - painter->setRenderHint( QPainter::Antialiasing ); - painter->translate( 0.5, 0.5 ); - QPen pen( PaletteHandler::highlightColor().lighter( 140 ) ); - pen.setWidth( 3 ); - painter->setPen( pen ); - painter->drawRoundedRect( boundingRect(), 6, 6 ); - painter->restore(); -} - -void -AppletExplorer::setContainment( Containment *containment ) -{ - m_containment = containment; -} - -Containment * -AppletExplorer::containment() const -{ - return m_containment; -} - -void -AppletExplorer::scrollLeft() -{ - QGraphicsSceneWheelEvent event( QEvent::GraphicsSceneWheel ); - event.setDelta( 480 ); - scene()->sendEvent( m_scrollWidget, &event ); -} - -void -AppletExplorer::scrollRight() -{ - QGraphicsSceneWheelEvent event( QEvent::GraphicsSceneWheel ); - event.setDelta( -480 ); - scene()->sendEvent( m_scrollWidget, &event ); -} - -QList -AppletExplorer::listAppletWidgets() -{ - QList widgets; - foreach( const KPluginInfo &info, Plasma::Applet::listAppletInfo( QString(), "amarok" ) ) - { - if( info.property( "NoDisplay" ).toBool() || info.category() == i18n( "Containments" ) ) - continue; - - widgets << new AppletIconWidget( info, this ); - } - return widgets; -} - -} //namespace Context - -#include "moc_AppletExplorer.cpp" diff --git a/amarok/src/context/widgets/appletexplorer/AppletExplorer.h b/amarok/src/context/widgets/appletexplorer/AppletExplorer.h deleted file mode 100644 index 9197496d..00000000 --- a/amarok/src/context/widgets/appletexplorer/AppletExplorer.h +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 William Viana Soares * - * Significant parts of this code is inspired * - * and/or copied from KDE Plasma sources, available * - * at kdebase/workspace/libs/plasmagenericshell * - * * - ****************************************************************************************/ - -/**************************************************************************************** - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef APPLET_EXPLORER_H -#define APPLET_EXPLORER_H - -#include "amarok_export.h" - -#include -#include - -class QAction; -class QStyleOptionGraphicsItem; - -namespace Plasma { - class IconWidget; - class ScrollWidget; -} - -namespace Context -{ -class AppletIconWidget; -class Containment; - -class AMAROK_EXPORT AppletExplorer: public QGraphicsWidget -{ - Q_OBJECT - -public: - AppletExplorer( QGraphicsItem *parent = 0 ); - virtual ~AppletExplorer(); - - void paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0 ); - void setContainment( Containment *containment ); - Containment *containment() const; - -signals: - void addAppletToContainment( const QString &pluginName, const int loc ); - void appletExplorerHid(); - -protected: - QSizeF sizeHint( Qt::SizeHint which, const QSizeF &constraint = QSizeF() ) const; - -private slots: - void addApplet( const QString &name ); - void hideMenu(); - void scrollLeft(); - void scrollRight(); - -private: - void init(); - QList listAppletWidgets(); - Containment *m_containment; - Plasma::ScrollWidget *m_scrollWidget; - Q_DISABLE_COPY( AppletExplorer ) -}; - -} // namespace Context - -#endif diff --git a/amarok/src/context/widgets/appletexplorer/AppletIcon.cpp b/amarok/src/context/widgets/appletexplorer/AppletIcon.cpp deleted file mode 100644 index 12d17e72..00000000 --- a/amarok/src/context/widgets/appletexplorer/AppletIcon.cpp +++ /dev/null @@ -1,99 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 William Viana Soares * - * Copyright (c) 2009 Mark Kretschmann * - * * - * Significant parts of this code is inspired * - * and/or copied from KDE Plasma sources, available * - * at kdebase/workspace/libs/plasmagenericshell * - * * - ****************************************************************************************/ - -/**************************************************************************************** - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "AppletIcon.h" - -#include "PaletteHandler.h" - -#include -#include - -#include -#include - -namespace Context -{ - -AppletIconWidget::AppletIconWidget( const KPluginInfo &info, QGraphicsItem *parent ) - : Plasma::IconWidget( parent ) - , m_pluginName( info.pluginName() ) -{ - setText( info.name() ); - setIcon( KIcon( info.icon().isEmpty() ? "application-x-plasma" : info.icon() ) ); - setToolTip( info.name() ); - setTextBackgroundColor( Qt::transparent ); -} - -AppletIconWidget::~AppletIconWidget() -{} - -void -AppletIconWidget::paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget ) -{ - painter->save(); - painter->setRenderHint( QPainter::Antialiasing ); - - QColor topColor = The::paletteHandler()->palette().color( QPalette::Base ); - QColor bottomColor = topColor; - topColor.setAlpha( 200 ); - bottomColor.setAlpha( 100 ); - qreal radius = 6; - qreal boundWidth = boundingRect().width(); - qreal boundHeight = boundingRect().height(); - - // draw top half of rounded applet - QPainterPath path; - path.moveTo( 0, boundHeight / 2 ); - path.lineTo( 0, radius ); - path.quadTo( 0, 0, radius, 0 ); - path.lineTo( boundWidth - radius, 0 ); - path.quadTo( boundWidth, 0, boundWidth, radius ); - path.lineTo( boundWidth, boundHeight / 2 ); - path.lineTo( 0, boundHeight / 2 ); - - painter->fillPath( path, topColor ); - QPainterPath bottom; - bottom.moveTo( 0, boundHeight / 2 ); - bottom.lineTo( 0, boundHeight - radius ); - bottom.quadTo( 0, boundHeight, radius, boundHeight ); - bottom.lineTo( boundWidth - radius, boundHeight ); - bottom.quadTo( boundWidth, boundHeight, boundWidth, boundHeight - radius ); - bottom.lineTo( boundWidth, boundHeight / 2 ); - bottom.lineTo( 0, boundHeight / 2 ); - - painter->fillPath( bottom, bottomColor ); - painter->restore(); - Plasma::IconWidget::paint( painter, option, widget ); -} - -QString -AppletIconWidget::pluginName() const -{ - return m_pluginName; -} - -} // namespace Context - -#include "moc_AppletIcon.cpp" diff --git a/amarok/src/context/widgets/appletexplorer/AppletIcon.h b/amarok/src/context/widgets/appletexplorer/AppletIcon.h deleted file mode 100644 index b9eda8b7..00000000 --- a/amarok/src/context/widgets/appletexplorer/AppletIcon.h +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 William Viana Soares * - * Copyright (c) 2009 Mark Kretschmann * - * * - * Significant parts of this code is inspired * - * and/or copied from KDE Plasma sources, available * - * at kdebase/workspace/libs/plasmagenericshell * - * * - ****************************************************************************************/ - -/**************************************************************************************** - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef APPLET_ICON_H -#define APPLET_ICON_H - -#include "amarok_export.h" - -#include - -class KPluginInfo; -class QPainter; - -namespace Context -{ - -class AMAROK_EXPORT AppletIconWidget: public Plasma::IconWidget -{ - Q_OBJECT - -public: - explicit AppletIconWidget( const KPluginInfo &info, QGraphicsItem *parent = 0 ); - virtual ~AppletIconWidget(); - - QString pluginName() const; - -protected: - void paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0 ); - -private: - QString m_pluginName; - Q_DISABLE_COPY( AppletIconWidget ) -}; - -} // namespace Context - -#endif // APPLET_ICON_H diff --git a/amarok/src/core-impl/capabilities/AlbumActionsCapability.cpp b/amarok/src/core-impl/capabilities/AlbumActionsCapability.cpp deleted file mode 100644 index 5d5f4059..00000000 --- a/amarok/src/core-impl/capabilities/AlbumActionsCapability.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "AlbumActionsCapability.h" - -#include "core/meta/Meta.h" -#include "covermanager/CoverFetchingActions.h" - -#include -#include - -class CompilationAction : public QAction -{ - Q_OBJECT - - public: - CompilationAction( QObject* parent, Meta::AlbumPtr album ) - : QAction( parent ) - , m_album( album ) - { - connect( this, SIGNAL(triggered(bool)), SLOT(slotTriggered()) ); - if( m_album->isCompilation() ) - { - setIcon( KIcon( "filename-artist-amarok" ) ); - setText( i18n( "Do not show under Various Artists" ) ); - } - else - { - setIcon( KIcon( "similarartists-amarok" ) ); - setText( i18n( "Show under Various Artists" ) ); - } - setEnabled( m_album->canUpdateCompilation() ); - } - - private slots: - void slotTriggered() - { - if( !m_album->canUpdateCompilation() ) - return; - m_album->setCompilation( !m_album->isCompilation() ); - } - - private: - Meta::AlbumPtr m_album; -}; - -using namespace Capabilities; - -AlbumActionsCapability::AlbumActionsCapability( Meta::AlbumPtr album, QList actions ) - : ActionsCapability() -{ - m_actions.append( new DisplayCoverAction( 0, album ) ); - m_actions.append( new FetchCoverAction( 0, album ) ); - m_actions.append( new SetCustomCoverAction( 0, album ) ); - m_actions.append( new UnsetCoverAction( 0, album ) ); - - QAction *separator = new QAction( 0 ); - separator->setSeparator( true ); - m_actions.append( separator ); - m_actions.append( new CompilationAction( 0, album ) ); - - if( actions.isEmpty() ) - return; - separator = new QAction( 0 ); - separator->setSeparator( true ); - m_actions.append( separator ); - m_actions.append( actions ); -} - -AlbumActionsCapability::~AlbumActionsCapability() -{ - // nothing to do -} - -#include "AlbumActionsCapability.moc" diff --git a/amarok/src/core-impl/capabilities/AlbumActionsCapability.h b/amarok/src/core-impl/capabilities/AlbumActionsCapability.h deleted file mode 100644 index 226faeac..00000000 --- a/amarok/src/core-impl/capabilities/AlbumActionsCapability.h +++ /dev/null @@ -1,45 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef ALBUMACTIONSCAPABILITY_H -#define ALBUMACTIONSCAPABILITY_H - -#include "amarok_export.h" -#include "core/capabilities/ActionsCapability.h" -#include "core/meta/forward_declarations.h" - -namespace Capabilities -{ - /** - * An ActionsCapability subclass that automatically adds actions that are suitable for - * albums - the actions are automatically disabled based on what passed album supports. - */ - class AMAROK_EXPORT AlbumActionsCapability : public ActionsCapability - { - public: - /** - * @param album album to create common actions for - * @param actions custom actions to append after common actions - */ - AlbumActionsCapability( Meta::AlbumPtr album, QList actions = QList() ); - virtual ~AlbumActionsCapability(); - - protected: - Meta::AlbumPtr m_album; - }; -} - -#endif // ALBUMACTIONSCAPABILITY_H diff --git a/amarok/src/core-impl/capabilities/multisource/MultiSourceCapabilityImpl.cpp b/amarok/src/core-impl/capabilities/multisource/MultiSourceCapabilityImpl.cpp deleted file mode 100644 index ad9ab0a2..00000000 --- a/amarok/src/core-impl/capabilities/multisource/MultiSourceCapabilityImpl.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "MultiSourceCapabilityImpl.h" - -#include "core/support/Debug.h" - -using namespace Capabilities; - -MultiSourceCapabilityImpl::MultiSourceCapabilityImpl(Meta::MultiTrack * track) - : Capabilities::MultiSourceCapability() - , m_track( track ) -{ - //forward from track, as there might be several instances of MultiSourceCapabilityImpl active for one track. - connect( m_track, SIGNAL(urlChanged(KUrl)), this, SIGNAL(urlChanged(KUrl)) ); -} - -MultiSourceCapabilityImpl::~MultiSourceCapabilityImpl() -{ -} - -QStringList -MultiSourceCapabilityImpl::sources() const -{ - return m_track->sources(); -} - -void -MultiSourceCapabilityImpl::setSource( int source ) -{ - m_track->setSource( source ); -} - -int -MultiSourceCapabilityImpl::current() const -{ - return m_track->current(); -} - -KUrl -MultiSourceCapabilityImpl::nextUrl() const -{ - return m_track->nextUrl(); -} diff --git a/amarok/src/core-impl/capabilities/multisource/MultiSourceCapabilityImpl.h b/amarok/src/core-impl/capabilities/multisource/MultiSourceCapabilityImpl.h deleted file mode 100644 index c8c4636a..00000000 --- a/amarok/src/core-impl/capabilities/multisource/MultiSourceCapabilityImpl.h +++ /dev/null @@ -1,44 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - - -#ifndef AMAROK_MULTISOURCECAPABILITYIMPL_P_H -#define AMAROK_MULTISOURCECAPABILITYIMPL_P_H - -#include "core/capabilities/MultiSourceCapability.h" -#include "core-impl/meta/multi/MultiTrack.h" - -namespace Capabilities -{ - class MultiSourceCapabilityImpl : public MultiSourceCapability - { - Q_OBJECT - - public: - MultiSourceCapabilityImpl( Meta::MultiTrack *track ); - virtual ~MultiSourceCapabilityImpl(); - - virtual QStringList sources() const; - virtual void setSource( int source ); - virtual int current() const; - virtual KUrl nextUrl() const; - - private: - Meta::MultiTrack *m_track; - }; -} - -#endif diff --git a/amarok/src/core-impl/capabilities/timecode/TimecodeBoundedPlaybackCapability.cpp b/amarok/src/core-impl/capabilities/timecode/TimecodeBoundedPlaybackCapability.cpp deleted file mode 100644 index 8f0b4d62..00000000 --- a/amarok/src/core-impl/capabilities/timecode/TimecodeBoundedPlaybackCapability.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "core-impl/capabilities/timecode/TimecodeBoundedPlaybackCapability.h" - -#include "core/capabilities/BoundedPlaybackCapability.h" -#include "core-impl/meta/timecode/TimecodeMeta.h" - -using namespace Capabilities; - -////////////////// BoundedPlaybackCapability ////////////////// - -qint64 TimecodeBoundedPlaybackCapability::startPosition() -{ - return m_track->start(); -} - -qint64 TimecodeBoundedPlaybackCapability::endPosition() -{ - return m_track->end(); -} - - diff --git a/amarok/src/core-impl/capabilities/timecode/TimecodeBoundedPlaybackCapability.h b/amarok/src/core-impl/capabilities/timecode/TimecodeBoundedPlaybackCapability.h deleted file mode 100644 index d403b817..00000000 --- a/amarok/src/core-impl/capabilities/timecode/TimecodeBoundedPlaybackCapability.h +++ /dev/null @@ -1,43 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef TIMECODEBOUNDEDPLAYBACKCAPABILITY_H -#define TIMECODEBOUNDEDPLAYBACKCAPABILITY_H - -#include "amarok_export.h" -#include "core/capabilities/BoundedPlaybackCapability.h" -#include "core-impl/meta/timecode/TimecodeMeta.h" - -namespace Capabilities { - -class AMAROK_EXPORT TimecodeBoundedPlaybackCapability : public BoundedPlaybackCapability -{ -Q_OBJECT -public: - TimecodeBoundedPlaybackCapability( Meta::TimecodeTrack * track ) - : m_track( track ) - {} - - virtual qint64 startPosition(); - virtual qint64 endPosition(); - -private: - Meta::TimecodeTrack * m_track; - -}; - -} -#endif diff --git a/amarok/src/core-impl/capabilities/timecode/TimecodeLoadCapability.cpp b/amarok/src/core-impl/capabilities/timecode/TimecodeLoadCapability.cpp deleted file mode 100644 index 3694f743..00000000 --- a/amarok/src/core-impl/capabilities/timecode/TimecodeLoadCapability.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Casey Link * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "core-impl/capabilities/timecode/TimecodeLoadCapability.h" - -namespace Capabilities -{ -TimecodeLoadCapability::~TimecodeLoadCapability() -{} -} - diff --git a/amarok/src/core-impl/capabilities/timecode/TimecodeLoadCapability.h b/amarok/src/core-impl/capabilities/timecode/TimecodeLoadCapability.h deleted file mode 100644 index 17b935be..00000000 --- a/amarok/src/core-impl/capabilities/timecode/TimecodeLoadCapability.h +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Casey Link * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef TIMECODELOADCAPABILITY_H -#define TIMECODELOADCAPABILITY_H - -#include "amarok_export.h" -#include "core/meta/forward_declarations.h" -#include "core/capabilities/Capability.h" -#include "amarokurls/AmarokUrl.h" - -#include - -#include - -namespace Capabilities { - -typedef QList BookmarkList; -typedef KSharedPtr AmarokUrlPtr; -/** -* This capability determines whether a track has timecodes -* that can be loaded from it, and supplies them if it can. -* @author Casey Link -*/ -class AMAROK_EXPORT TimecodeLoadCapability : public Capability -{ - Q_OBJECT -public: - virtual ~TimecodeLoadCapability(); - - /** - * @return true if the track has timecodes, false if not - */ - virtual bool hasTimecodes() = 0 ; - - /** - * @return a QList of AmarokUrlPtrs representing the track's timecodes. Might return an empty list. - */ - virtual BookmarkList loadTimecodes() = 0; - - /** - * Get the capabilityInterfaceType of this capability - * @return The capabilityInterfaceType ( always Capabilities::Capability::LoadTimecode; ) - */ - static Type capabilityInterfaceType() - { - return Capabilities::Capability::LoadTimecode; - } -}; - -} - -#endif // TIMECODELOADCAPABILITY_H diff --git a/amarok/src/core-impl/capabilities/timecode/TimecodeWriteCapability.cpp b/amarok/src/core-impl/capabilities/timecode/TimecodeWriteCapability.cpp deleted file mode 100644 index 9b64e80b..00000000 --- a/amarok/src/core-impl/capabilities/timecode/TimecodeWriteCapability.cpp +++ /dev/null @@ -1,121 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Casey Link * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - - -#include "TimecodeWriteCapability.h" - -#include "EngineController.h" -#include "amarokurls/AmarokUrl.h" -#include "amarokurls/AmarokUrlHandler.h" -#include "amarokurls/BookmarkModel.h" -#include "amarokurls/PlayUrlGenerator.h" -#include "core/meta/Meta.h" -#include "core/support/Debug.h" -#include "core-impl/capabilities/timecode/TimecodeLoadCapability.h" -#include "widgets/ProgressWidget.h" - -#include - -namespace Capabilities -{ - -TimecodeWriteCapability::~TimecodeWriteCapability() -{} - -bool TimecodeWriteCapability::writeTimecode( qint64 miliseconds, Meta::TrackPtr track ) -{ - DEBUG_BLOCK - AmarokUrl url = PlayUrlGenerator::instance()->createTrackBookmark( track, miliseconds ); - - // lets see if we are bookmarking the currently playing track, if so - // we need to update the slider with another icon - Meta::TrackPtr currtrack = The::engineController()->currentTrack(); - if( currtrack == track ) - { - debug() << " current track"; - debug() << "adding at seconds: " << miliseconds; - The::amarokUrlHandler()->paintNewTimecode( url.name(), miliseconds ); - - } - - url.saveToDb(); - BookmarkModel::instance()->reloadFromDb(); //Update bookmark manager view. - return true; -} - -bool Capabilities::TimecodeWriteCapability::writeAutoTimecode( qint64 miliseconds, Meta::TrackPtr track ) -{ - DEBUG_BLOCK - - //first up, find and delete any previously added auto timecodes for this track - - debug() << "deleting old auto timecodes"; - if( track->has() ) - { - QScopedPointer tcl( track->create() ); - BookmarkList list = tcl->loadTimecodes(); - foreach( AmarokUrlPtr oldUrl, list ) - { - if( oldUrl->command() == "play" ) { - if( oldUrl->customValue() == "auto timecode" ) { - debug() << "deleting: " << oldUrl->name(); - oldUrl->removeFromDb(); - } - } - } - } - - //create url - AmarokUrl url = PlayUrlGenerator::instance()->createTrackBookmark( track, miliseconds ); - - // lets see if we are bookmarking the currently playing track, if so - // we need to update the slider with another icon - - Meta::TrackPtr currtrack = The::engineController()->currentTrack(); - if( currtrack == track ) - { - debug() << " current track"; - QMap args = url.args(); - if ( args.keys().contains( "pos" ) ) - { - int pos = args.value( "pos" ).toInt(); - The::amarokUrlHandler()->paintNewTimecode( url.name(), pos * 1000 ); - } - } - - //change the name a little bit - url.setCustomValue( "auto timecode" ); - - QString date = QDateTime::currentDateTime().toString( "dd.MM.yyyy" ); - url.setName( i18n( "%1 - Stopped %2", track->prettyName(), date ) ); - - debug() << "creating new auto timecode: " << url.name(); - - //put in custom group to ensure that we do not clutter the list of bookmarks. - BookmarkGroupPtr parentPtr = BookmarkGroupPtr( new BookmarkGroup( i18n( "Playback Ended Markers" ), "auto_markers" ) ); - url.reparent( parentPtr ); - - //save it - url.saveToDb(); - BookmarkModel::instance()->reloadFromDb(); //Update bookmark manager view. - return true; -} - -} - - - - diff --git a/amarok/src/core-impl/capabilities/timecode/TimecodeWriteCapability.h b/amarok/src/core-impl/capabilities/timecode/TimecodeWriteCapability.h deleted file mode 100644 index 40127bcb..00000000 --- a/amarok/src/core-impl/capabilities/timecode/TimecodeWriteCapability.h +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Casey Link * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef TIMECODEWRITECAPABILITY_H -#define TIMECODEWRITECAPABILITY_H - -#include "amarok_export.h" -#include "core/meta/forward_declarations.h" -#include "core/capabilities/Capability.h" - -namespace Capabilities -{ -/** - * This capability determines whether a track can have a timecode - * written to it. - * @author Casey Link - */ -class AMAROK_EXPORT TimecodeWriteCapability : public Capability -{ - Q_OBJECT -public: - - virtual ~TimecodeWriteCapability(); - - /** - * Stores a timecode for the track - * @param seconds the position in seconds at which the timecide should be stored. - * @return true if the write was successful, false if not. - */ - virtual bool writeTimecode ( qint64 miliseconds ) = 0; - - /** - * Stores an auto timecode for the track and deletes any previously added auto timecodes - * @param seconds the position in seconds at which the timecide should be stored. - * @return true if the write was successful, false if not. - */ - virtual bool writeAutoTimecode ( qint64 miliseconds ) = 0; - - /** - * Get the capabilityInterfaceType of this capability - * @return The capabilityInterfaceType ( always Capabilities::Capability::WriteTimecode; ) - */ - static Type capabilityInterfaceType() - { - return Capabilities::Capability::WriteTimecode; - } - -protected: - - bool writeTimecode( qint64 miliseconds, Meta::TrackPtr track ); - bool writeAutoTimecode( qint64 miliseconds, Meta::TrackPtr track ); -}; - -#endif // TIMECODEWRITECAPABILITY_H -} diff --git a/amarok/src/core-impl/collections/CMakeLists.txt b/amarok/src/core-impl/collections/CMakeLists.txt deleted file mode 100644 index ce0b7fd5..00000000 --- a/amarok/src/core-impl/collections/CMakeLists.txt +++ /dev/null @@ -1,24 +0,0 @@ -include_directories( - ${KDE4_INCLUDE_DIR} - ${QT_INCLUDES} - ${Amarok_SOURCE_DIR}/src - ) - -set(AMAROK_COLLECTION_SUPPORT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/support) - -add_subdirectory( daap ) - -if( NOT WIN32) -add_subdirectory( audiocd ) -endif( NOT WIN32 ) - -add_subdirectory( ipodcollection ) -add_subdirectory( mtpcollection ) -add_subdirectory( umscollection ) -add_subdirectory( db ) - -# only build playdarcollection if QJson was found -if( QJSON_FOUND ) - add_subdirectory( playdarcollection ) -endif( QJSON_FOUND ) -add_subdirectory( upnpcollection ) diff --git a/amarok/src/core-impl/collections/aggregate/AggregateCollection.cpp b/amarok/src/core-impl/collections/aggregate/AggregateCollection.cpp deleted file mode 100644 index b0b9f492..00000000 --- a/amarok/src/core-impl/collections/aggregate/AggregateCollection.cpp +++ /dev/null @@ -1,526 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "AggregateCollection" - -#include "AggregateCollection.h" - -#include "core/support/Debug.h" -#include "core-impl/collections/aggregate/AggregateMeta.h" -#include "core-impl/collections/aggregate/AggregateQueryMaker.h" -#include "core-impl/collections/support/CollectionManager.h" - -#include - -#include -#include - -using namespace Collections; - -AggregateCollection::AggregateCollection() - : Collections::Collection() -{ - QTimer *timer = new QTimer( this ); - timer->setSingleShot( false ); - timer->setInterval( 60000 ); //clean up every 60 seconds - connect( timer, SIGNAL(timeout()), this, SLOT(emptyCache()) ); - timer->start(); -} - -AggregateCollection::~AggregateCollection() -{ -} - -QString -AggregateCollection::prettyName() const -{ - return i18nc( "Name of the virtual collection that merges tracks from all collections", - "Aggregate Collection" ); -} - -KIcon -AggregateCollection::icon() const -{ - return KIcon("drive-harddisk"); -} - -bool -AggregateCollection::possiblyContainsTrack( const KUrl &url ) const -{ - foreach( Collections::Collection *collection, m_idCollectionMap ) - { - if( collection->possiblyContainsTrack( url ) ) - return true; - } - return false; -} - -Meta::TrackPtr -AggregateCollection::trackForUrl( const KUrl &url ) -{ - foreach( Collections::Collection *collection, m_idCollectionMap ) - { - Meta::TrackPtr track = collection->trackForUrl( url ); - if( track ) - { - //theoretically we should now query the other collections for the same track - //not sure how to do that yet though... - return Meta::TrackPtr( getTrack( track ) ); - } - } - return Meta::TrackPtr(); -} - -QueryMaker* -AggregateCollection::queryMaker() -{ - QList list; - foreach( Collections::Collection *collection, m_idCollectionMap ) - { - list.append( collection->queryMaker() ); - } - return new Collections::AggregateQueryMaker( this, list ); -} - -QString -AggregateCollection::collectionId() const -{ - // do we need more than one AggregateCollection? - return QLatin1String( "AggregateCollection" ); -} - -void -AggregateCollection::addCollection( Collections::Collection *collection, CollectionManager::CollectionStatus status ) -{ - if( !collection ) - return; - - if( !( status & CollectionManager::CollectionViewable ) ) - return; - - m_idCollectionMap.insert( collection->collectionId(), collection ); - //TODO - emit updated(); -} - -void -AggregateCollection::removeCollection( const QString &collectionId ) -{ - m_idCollectionMap.remove( collectionId ); - emit updated(); -} - -void -AggregateCollection::removeCollection( Collections::Collection *collection ) -{ - m_idCollectionMap.remove( collection->collectionId() ); - emit updated(); -} - -void -AggregateCollection::slotUpdated() -{ - //TODO - emit updated(); -} - -void -AggregateCollection::removeYear( const QString &name ) -{ - m_yearLock.lockForWrite(); - m_yearMap.remove( name ); - m_yearLock.unlock(); -} - -Meta::AggreagateYear* -AggregateCollection::getYear( Meta::YearPtr year ) -{ - m_yearLock.lockForRead(); - if( m_yearMap.contains( year->name() ) ) - { - KSharedPtr aggregateYear = m_yearMap.value( year->name() ); - aggregateYear->add( year ); - m_yearLock.unlock(); - return aggregateYear.data(); - } - else - { - m_yearLock.unlock(); - m_yearLock.lockForWrite(); - //we might create two year instances with the same name here, - //which would show some weird behaviour in other places - Meta::AggreagateYear *aggregateYear = new Meta::AggreagateYear( this, year ); - m_yearMap.insert( year->name(), KSharedPtr( aggregateYear ) ); - m_yearLock.unlock(); - return aggregateYear; - } -} - -void -AggregateCollection::setYear( Meta::AggreagateYear *year ) -{ - m_yearLock.lockForWrite(); - m_yearMap.insert( year->name(), KSharedPtr( year ) ); - m_yearLock.unlock(); -} - -bool -AggregateCollection::hasYear( const QString &name ) -{ - QReadLocker locker( &m_yearLock ); - return m_yearMap.contains( name ); -} - -void -AggregateCollection::removeGenre( const QString &name ) -{ - m_genreLock.lockForWrite(); - m_genreMap.remove( name ); - m_genreLock.unlock(); -} - -Meta::AggregateGenre* -AggregateCollection::getGenre( Meta::GenrePtr genre ) -{ - m_genreLock.lockForRead(); - if( m_genreMap.contains( genre->name() ) ) - { - KSharedPtr aggregateGenre = m_genreMap.value( genre->name() ); - aggregateGenre->add( genre ); - m_genreLock.unlock(); - return aggregateGenre.data(); - } - else - { - m_genreLock.unlock(); - m_genreLock.lockForWrite(); - //we might create two instances with the same name here, - //which would show some weird behaviour in other places - Meta::AggregateGenre *aggregateGenre = new Meta::AggregateGenre( this, genre ); - m_genreMap.insert( genre->name(), KSharedPtr( aggregateGenre ) ); - m_genreLock.unlock(); - return aggregateGenre; - } -} - -void -AggregateCollection::setGenre( Meta::AggregateGenre *genre ) -{ - m_genreLock.lockForWrite(); - m_genreMap.insert( genre->name(), KSharedPtr( genre ) ); - m_genreLock.unlock(); -} - -bool -AggregateCollection::hasGenre( const QString &genre ) -{ - QReadLocker locker( &m_genreLock ); - return m_genreMap.contains( genre ); -} - -void -AggregateCollection::removeComposer( const QString &name ) -{ - m_composerLock.lockForWrite(); - m_composerMap.remove( name ); - m_composerLock.unlock(); -} - -Meta::AggregateComposer* -AggregateCollection::getComposer( Meta::ComposerPtr composer ) -{ - m_composerLock.lockForRead(); - if( m_composerMap.contains( composer->name() ) ) - { - KSharedPtr aggregateComposer = m_composerMap.value( composer->name() ); - aggregateComposer->add( composer ); - m_composerLock.unlock(); - return aggregateComposer.data(); - } - else - { - m_composerLock.unlock(); - m_composerLock.lockForWrite(); - //we might create two instances with the same name here, - //which would show some weird behaviour in other places - Meta::AggregateComposer *aggregateComposer = new Meta::AggregateComposer( this, composer ); - m_composerMap.insert( composer->name(), KSharedPtr( aggregateComposer ) ); - m_composerLock.unlock(); - return aggregateComposer; - } -} - -void -AggregateCollection::setComposer( Meta::AggregateComposer *composer ) -{ - m_composerLock.lockForWrite(); - m_composerMap.insert( composer->name(), KSharedPtr( composer ) ); - m_composerLock.unlock(); -} - -bool -AggregateCollection::hasComposer( const QString &name ) -{ - QReadLocker locker( &m_composerLock ); - return m_composerMap.contains( name ); -} - -void -AggregateCollection::removeArtist( const QString &name ) -{ - m_artistLock.lockForWrite(); - m_artistMap.remove( name ); - m_artistLock.unlock(); -} - -Meta::AggregateArtist* -AggregateCollection::getArtist( Meta::ArtistPtr artist ) -{ - m_artistLock.lockForRead(); - if( m_artistMap.contains( artist->name() ) ) - { - KSharedPtr aggregateArtist = m_artistMap.value( artist->name() ); - aggregateArtist->add( artist ); - m_artistLock.unlock(); - return aggregateArtist.data(); - } - else - { - m_artistLock.unlock(); - m_artistLock.lockForWrite(); - //we might create two instances with the same name here, - //which would show some weird behaviour in other places - Meta::AggregateArtist *aggregateArtist = new Meta::AggregateArtist( this, artist ); - m_artistMap.insert( artist->name(), KSharedPtr( aggregateArtist ) ); - m_artistLock.unlock(); - return aggregateArtist; - } -} - -void -AggregateCollection::setArtist( Meta::AggregateArtist *artist ) -{ - m_artistLock.lockForWrite(); - m_artistMap.insert( artist->name(), KSharedPtr( artist ) ); - m_artistLock.unlock(); -} - -bool -AggregateCollection::hasArtist( const QString &artist ) -{ - QReadLocker locker( &m_artistLock ); - return m_artistMap.contains( artist ); -} - -void -AggregateCollection::removeAlbum( const QString &album, const QString &albumartist ) -{ - Meta::AlbumKey key( album, albumartist ); - m_albumLock.lockForWrite(); - m_albumMap.remove( key ); - m_albumLock.unlock(); -} - -Meta::AggregateAlbum* -AggregateCollection::getAlbum( Meta::AlbumPtr album ) -{ - Meta::AlbumKey key( album ); - m_albumLock.lockForRead(); - if( m_albumMap.contains( key ) ) - { - KSharedPtr aggregateAlbum = m_albumMap.value( key ); - aggregateAlbum->add( album ); - m_albumLock.unlock(); - return aggregateAlbum.data(); - } - else - { - m_albumLock.unlock(); - m_albumLock.lockForWrite(); - //we might create two instances with the same name here, - //which would show some weird behaviour in other places - Meta::AggregateAlbum *aggregateAlbum = new Meta::AggregateAlbum( this, album ); - m_albumMap.insert( key, KSharedPtr( aggregateAlbum ) ); - m_albumLock.unlock(); - return aggregateAlbum; - } -} - -void -AggregateCollection::setAlbum( Meta::AggregateAlbum *album ) -{ - m_albumLock.lockForWrite(); - m_albumMap.insert( Meta::AlbumKey( Meta::AlbumPtr( album ) ), - KSharedPtr( album ) ); - m_albumLock.unlock(); -} - -bool -AggregateCollection::hasAlbum( const QString &album, const QString &albumArtist ) -{ - QReadLocker locker( &m_albumLock ); - return m_albumMap.contains( Meta::AlbumKey( album, albumArtist ) ); -} - -void -AggregateCollection::removeTrack( const Meta::TrackKey &key ) -{ - m_trackLock.lockForWrite(); - m_trackMap.remove( key ); - m_trackLock.unlock(); -} - -Meta::AggregateTrack* -AggregateCollection::getTrack( Meta::TrackPtr track ) -{ - const Meta::TrackKey key( track ); - m_trackLock.lockForRead(); - if( m_trackMap.contains( key ) ) - { - KSharedPtr aggregateTrack = m_trackMap.value( key ); - aggregateTrack->add( track ); - m_trackLock.unlock(); - return aggregateTrack.data(); - } - else - { - m_trackLock.unlock(); - m_trackLock.lockForWrite(); - //we might create two instances with the same name here, - //which would show some weird behaviour in other places - Meta::AggregateTrack *aggregateTrack = new Meta::AggregateTrack( this, track ); - m_trackMap.insert( key, KSharedPtr( aggregateTrack ) ); - m_trackLock.unlock(); - return aggregateTrack; - } -} - -void -AggregateCollection::setTrack( Meta::AggregateTrack *track ) -{ - Meta::TrackPtr ptr( track ); - const Meta::TrackKey key( ptr ); - m_trackLock.lockForWrite(); - m_trackMap.insert( key, KSharedPtr( track ) ); - m_trackLock.unlock(); -} - -bool -AggregateCollection::hasTrack( const Meta::TrackKey &key ) -{ - QReadLocker locker( &m_trackLock ); - return m_trackMap.contains( key ); -} - -bool -AggregateCollection::hasLabel( const QString &name ) -{ - QReadLocker locker( &m_labelLock ); - return m_labelMap.contains( name ); -} - -void -AggregateCollection::removeLabel( const QString &name ) -{ - QWriteLocker locker( &m_labelLock ); - m_labelMap.remove( name ); -} - -Meta::AggregateLabel* -AggregateCollection::getLabel( Meta::LabelPtr label ) -{ - m_labelLock.lockForRead(); - if( m_labelMap.contains( label->name() ) ) - { - KSharedPtr aggregateLabel = m_labelMap.value( label->name() ); - aggregateLabel->add( label ); - m_labelLock.unlock(); - return aggregateLabel.data(); - } - else - { - m_labelLock.unlock(); - m_labelLock.lockForWrite(); - //we might create two year instances with the same name here, - //which would show some weird behaviour in other places - Meta::AggregateLabel *aggregateLabel = new Meta::AggregateLabel( this, label ); - m_labelMap.insert( label->name(), KSharedPtr( aggregateLabel ) ); - m_labelLock.unlock(); - return aggregateLabel; - } -} - -void -AggregateCollection::setLabel( Meta::AggregateLabel *label ) -{ - QWriteLocker locker( &m_labelLock ); - m_labelMap.insert( label->name(), KSharedPtr( label ) ); -} - -void -AggregateCollection::emptyCache() -{ - bool hasTrack, hasAlbum, hasArtist, hasYear, hasGenre, hasComposer, hasLabel; - hasTrack = hasAlbum = hasArtist = hasYear = hasGenre = hasComposer = hasLabel = false; - - //try to avoid possible deadlocks by aborting when we can't get all locks - if ( ( hasTrack = m_trackLock.tryLockForWrite() ) - && ( hasAlbum = m_albumLock.tryLockForWrite() ) - && ( hasArtist = m_artistLock.tryLockForWrite() ) - && ( hasYear = m_yearLock.tryLockForWrite() ) - && ( hasGenre = m_genreLock.tryLockForWrite() ) - && ( hasComposer = m_composerLock.tryLockForWrite() ) - && ( hasLabel = m_labelLock.tryLockForWrite() ) ) - { - //this very simple garbage collector doesn't handle cyclic object graphs - //so care has to be taken to make sure that we are not dealing with a cyclic graph - //by invalidating the tracks cache on all objects - #define foreachInvalidateCache( Type, RealType, x ) \ - for( QMutableHashIterator iter(x); iter.hasNext(); ) \ - RealType::staticCast( iter.next().value() )->invalidateCache() - - //elem.count() == 2 is correct because elem is one pointer to the object - //and the other is stored in the hash map (except for m_trackMap, where - //another refence is stored in m_uidMap - #define foreachCollectGarbage( Key, Type, RefCount, x ) \ - for( QMutableHashIterator iter(x); iter.hasNext(); ) \ - { \ - Type elem = iter.next().value(); \ - if( elem.count() == RefCount ) \ - iter.remove(); \ - } - - foreachCollectGarbage( Meta::TrackKey, KSharedPtr, 2, m_trackMap ) - //run before artist so that album artist pointers can be garbage collected - foreachCollectGarbage( Meta::AlbumKey, KSharedPtr, 2, m_albumMap ) - foreachCollectGarbage( QString, KSharedPtr, 2, m_artistMap ) - foreachCollectGarbage( QString, KSharedPtr, 2, m_genreMap ) - foreachCollectGarbage( QString, KSharedPtr, 2, m_composerMap ) - foreachCollectGarbage( QString, KSharedPtr, 2, m_yearMap ) - foreachCollectGarbage( QString, KSharedPtr, 2, m_labelMap ) - } - - //make sure to unlock all necessary locks - //important: calling unlock() on an unlocked mutex gives an undefined result - //unlocking a mutex locked by another thread results in an error, so be careful - if( hasTrack ) m_trackLock.unlock(); - if( hasAlbum ) m_albumLock.unlock(); - if( hasArtist ) m_artistLock.unlock(); - if( hasYear ) m_yearLock.unlock(); - if( hasGenre ) m_genreLock.unlock(); - if( hasComposer ) m_composerLock.unlock(); - if( hasLabel ) m_labelLock.unlock(); -} diff --git a/amarok/src/core-impl/collections/aggregate/AggregateCollection.h b/amarok/src/core-impl/collections/aggregate/AggregateCollection.h deleted file mode 100644 index 17119b6b..00000000 --- a/amarok/src/core-impl/collections/aggregate/AggregateCollection.h +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright (c) 2009 Maximilian Kossick - * - * This program 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 2 of the License, or - * (at your option) any later version. - * - * This program 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 this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#ifndef AGGREGATECOLLECTION_H -#define AGGREGATECOLLECTION_H - -#include "core/collections/Collection.h" -#include "core-impl/collections/support/CollectionManager.h" -#include "core/meta/forward_declarations.h" -#include "core/meta/support/MetaKeys.h" - -#include -#include -#include - -namespace Meta { - class AggreagateYear; - class AggregateTrack; - class AggregateArtist; - class AggregateAlbum; - class AggregateGenre; - class AggregateComposer; - class AggregateLabel; -} - -namespace Collections { - - class AMAROK_EXPORT AggregateCollection : public Collections::Collection - { - Q_OBJECT - public: - AggregateCollection(); - ~AggregateCollection(); - - // Collections::Collection methods - - virtual QString prettyName() const; - virtual KIcon icon() const; - - virtual bool possiblyContainsTrack( const KUrl &url ) const; - virtual Meta::TrackPtr trackForUrl( const KUrl &url ); - - virtual QueryMaker* queryMaker(); - - virtual QString collectionId() const; - - // AggregateCollection methods - - void removeTrack( const Meta::TrackKey &key ); - Meta::AggregateTrack* getTrack( Meta::TrackPtr track ); - void setTrack( Meta::AggregateTrack *track ); - bool hasTrack( const Meta::TrackKey &key ); - - void removeAlbum( const QString &album, const QString &albumArtist ); - Meta::AggregateAlbum* getAlbum( Meta::AlbumPtr album ); - void setAlbum( Meta::AggregateAlbum *album ); - bool hasAlbum( const QString &album, const QString &albumArtist ); - - void removeArtist( const QString &artist ); - Meta::AggregateArtist* getArtist( Meta::ArtistPtr artist ); - void setArtist( Meta::AggregateArtist *artist ); - bool hasArtist( const QString &artist ); - - void removeGenre( const QString &genre ); - Meta::AggregateGenre* getGenre( Meta::GenrePtr genre ); - void setGenre( Meta::AggregateGenre *genre ); - bool hasGenre( const QString &genre ); - - void removeComposer( const QString &name ); - Meta::AggregateComposer* getComposer( Meta::ComposerPtr composer ); - void setComposer( Meta::AggregateComposer *composer ); - bool hasComposer( const QString &name ); - - bool hasYear( const QString &name ); - void removeYear( const QString &name ); - Meta::AggreagateYear* getYear( Meta::YearPtr year ); - void setYear( Meta::AggreagateYear *year ); - - bool hasLabel( const QString &name ); - void removeLabel( const QString &name ); - Meta::AggregateLabel* getLabel( Meta::LabelPtr label ); - void setLabel( Meta::AggregateLabel *label ); - - public slots: - void removeCollection( const QString &collectionId ); - void removeCollection( Collections::Collection *collection ); - void addCollection( Collections::Collection *collection, CollectionManager::CollectionStatus status ); - void slotUpdated(); - - private slots: - void emptyCache(); - - private: - QHash m_idCollectionMap; - - QHash > m_yearMap; - QHash > m_genreMap; - QHash > m_composerMap; - QHash > m_artistMap; - QHash > m_albumMap; - QHash > m_trackMap; - QHash > m_labelMap; - - QReadWriteLock m_yearLock; - QReadWriteLock m_genreLock; - QReadWriteLock m_composerLock; - QReadWriteLock m_artistLock; - QReadWriteLock m_albumLock; - QReadWriteLock m_trackLock; - QReadWriteLock m_labelLock; - }; - -} //namespace Collections - -#endif diff --git a/amarok/src/core-impl/collections/aggregate/AggregateMeta.cpp b/amarok/src/core-impl/collections/aggregate/AggregateMeta.cpp deleted file mode 100644 index 1e63d992..00000000 --- a/amarok/src/core-impl/collections/aggregate/AggregateMeta.cpp +++ /dev/null @@ -1,1532 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009,2010 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "AggregateMeta" - -#include "AggregateMeta.h" - -#include "SvgHandler.h" -#include "core/meta/TrackEditor.h" -#include "core/meta/support/MetaUtility.h" -#include "core/support/Debug.h" -#include "core-impl/collections/aggregate/AggregateCollection.h" - -#include -#include -#include - -namespace Meta -{ - -#define FORWARD( call ) { foreach( TrackEditorPtr e, m_editors ) { e->call; } \ - if( !m_batchMode ) QTimer::singleShot( 0, m_collection, SLOT(slotUpdated()) ); } - -class AggregateTrackEditor : public TrackEditor -{ -public: - AggregateTrackEditor( Collections::AggregateCollection *coll, const QList &editors ) - : TrackEditor() - , m_batchMode( false ) - , m_collection( coll ) - , m_editors( editors ) - {} - - void beginUpdate() - { - m_batchMode = true; - foreach( TrackEditorPtr ec, m_editors ) ec->beginUpdate(); - } - void endUpdate() - { - foreach( TrackEditorPtr ec, m_editors ) ec->endUpdate(); - m_batchMode = false; - QTimer::singleShot( 0, m_collection, SLOT(slotUpdated()) ); - } - void setComment( const QString &newComment ) { FORWARD( setComment( newComment ) ) } - void setTrackNumber( int newTrackNumber ) { FORWARD( setTrackNumber( newTrackNumber ) ) } - void setDiscNumber( int newDiscNumber ) { FORWARD( setDiscNumber( newDiscNumber ) ) } - void setBpm( const qreal newBpm ) { FORWARD( setBpm( newBpm ) ) } - void setTitle( const QString &newTitle ) { FORWARD( setTitle( newTitle ) ) } - void setArtist( const QString &newArtist ) { FORWARD( setArtist( newArtist ) ) } - void setAlbum( const QString &newAlbum ) { FORWARD( setAlbum( newAlbum ) ) } - void setAlbumArtist( const QString &newAlbumArtist ) { FORWARD( setAlbumArtist ( newAlbumArtist ) ) } - void setGenre( const QString &newGenre ) { FORWARD( setGenre( newGenre ) ) } - void setComposer( const QString &newComposer ) { FORWARD( setComposer( newComposer ) ) } - void setYear( int newYear ) { FORWARD( setYear( newYear ) ) } -private: - bool m_batchMode; - Collections::AggregateCollection *m_collection; - QList m_editors; -}; - -#undef FORWARD - -AggregateTrack::AggregateTrack( Collections::AggregateCollection *coll, const TrackPtr &track ) - : Track() - , Observer() - , m_collection( coll ) - , m_name( track->name() ) - , m_album( 0 ) - , m_artist( 0 ) - , m_genre( 0 ) - , m_composer( 0 ) - , m_year( 0 ) -{ - subscribeTo( track ); - m_tracks.append( track ); - - if( track->album() ) - m_album = Meta::AlbumPtr( m_collection->getAlbum( track->album() ) ); - if( track->artist() ) - m_artist = Meta::ArtistPtr( m_collection->getArtist( track->artist() ) ); - if( track->genre() ) - m_genre = Meta::GenrePtr( m_collection->getGenre( track->genre() ) ); - if( track->composer() ) - m_composer = Meta::ComposerPtr( m_collection->getComposer( track->composer() ) ); - if( track->year() ) - m_year = Meta::YearPtr( m_collection->getYear( track->year() ) ); -} - -AggregateTrack::~AggregateTrack() -{ -} - -QString -AggregateTrack::name() const -{ - return m_name; -} - -QString -AggregateTrack::prettyName() const -{ - return m_name; -} - -QString -AggregateTrack::sortableName() const -{ - if( !m_tracks.isEmpty() ) - return m_tracks.first()->sortableName(); - - return m_name; -} - -KUrl -AggregateTrack::playableUrl() const -{ - Meta::TrackPtr bestPlayableTrack; - foreach( const Meta::TrackPtr &track, m_tracks ) - { - if( track->isPlayable() ) - { - bool local = track->playableUrl().isLocalFile(); - if( local ) - { - bestPlayableTrack = track; - break; - } - else - { - //we might want to add some more sophisticated logic to figure out - //the best remote track to play, but this works for now - bestPlayableTrack = track; - } - } - } - if( bestPlayableTrack ) - return bestPlayableTrack->playableUrl(); - - return KUrl(); -} - -QString -AggregateTrack::prettyUrl() const -{ - if( m_tracks.count() == 1 ) - { - return m_tracks.first()->prettyUrl(); - } - else - { - return QString(); - } -} - -QString -AggregateTrack::uidUrl() const -{ - // this is where it gets interesting - // a uidUrl for a AggregateTrack probably has to be generated - // from the parts of the key in AggregateCollection - // need to think about this some more - return QString(); -} - -QString -AggregateTrack::notPlayableReason() const -{ - QStringList reasons; - foreach( const Meta::TrackPtr &track, m_tracks ) - { - if( !track->isPlayable() ) - reasons.append( track->notPlayableReason() ); - else - return QString(); // no reason if at least one playable - } - return reasons.join( QString( ", " ) ); -} - -Meta::AlbumPtr -AggregateTrack::album() const -{ - return m_album; -} - -Meta::ArtistPtr -AggregateTrack::artist() const -{ - return m_artist; -} - -Meta::ComposerPtr -AggregateTrack::composer() const -{ - return m_composer; -} - -Meta::GenrePtr -AggregateTrack::genre() const -{ - return m_genre; -} - -Meta::YearPtr -AggregateTrack::year() const -{ - return m_year; -} - -QString -AggregateTrack::comment() const -{ - //try to return something sensible here... - //do not show a comment if the internal tracks disagree about the comment - QString comment; - if( !m_tracks.isEmpty() ) - comment = m_tracks.first()->comment(); - - foreach( const Meta::TrackPtr &track, m_tracks ) - { - if( track->comment() != comment ) - { - comment.clear(); - break; - } - } - return comment; -} - -qreal -AggregateTrack::bpm() const -{ - //Similar to comment(), try to return something sensible here... - //do not show a common bpm value if the internal tracks disagree about the bpm - qreal bpm = -1.0; - if( !m_tracks.isEmpty() ) - bpm = m_tracks.first()->bpm(); - - foreach( const Meta::TrackPtr &track, m_tracks ) - { - if( track->bpm() != bpm ) - { - bpm = -1.0; - break; - } - } - return bpm; -} - -double -AggregateTrack::score() const -{ - //again, multiple ways to implement this method: - //return the maximum score, the minimum score, the average - //the score of the track with the maximum play count, - //or an average weighted by play count. And probably a couple of ways that - //I cannot think of right now... - - //implementing the weighted average here... - double weightedSum = 0.0; - int totalCount = 0; - foreach( const Meta::TrackPtr &track, m_tracks ) - { - ConstStatisticsPtr statistics = track->statistics(); - totalCount += statistics->playCount(); - weightedSum += statistics->playCount() * statistics->score(); - } - if( totalCount ) - return weightedSum / totalCount; - - return 0.0; -} - -void -AggregateTrack::setScore( double newScore ) -{ - foreach( Meta::TrackPtr track, m_tracks ) - { - track->statistics()->setScore( newScore ); - } -} - -int -AggregateTrack::rating() const -{ - //yay, multiple options again. As this has to be defined by the user, let's take - //the maximum here. - int result = 0; - foreach( const Meta::TrackPtr &track, m_tracks ) - { - if( track->statistics()->rating() > result ) - result = track->statistics()->rating(); - } - return result; -} - -void -AggregateTrack::setRating( int newRating ) -{ - foreach( Meta::TrackPtr track, m_tracks ) - { - track->statistics()->setRating( newRating ); - } -} - -QDateTime -AggregateTrack::firstPlayed() const -{ - QDateTime result; - foreach( const Meta::TrackPtr &track, m_tracks ) - { - ConstStatisticsPtr statistics = track->statistics(); - //use the track's firstPlayed value if it represents an earlier timestamp than - //the current result, or use it directly if result has not been set yet - //this should result in the earliest timestamp for first play of all internal - //tracks being returned - if( ( statistics->firstPlayed().isValid() && result.isValid() && statistics->firstPlayed() < result ) || - ( statistics->firstPlayed().isValid() && !result.isValid() ) ) - { - result = statistics->firstPlayed(); - } - } - return result; -} - -void -AggregateTrack::setFirstPlayed( const QDateTime &date ) -{ - foreach( Meta::TrackPtr track, m_tracks ) - { - // only "lower" the first played - Meta::StatisticsPtr trackStats = track->statistics(); - if( !trackStats->firstPlayed().isValid() || - trackStats->firstPlayed() > date ) - { - trackStats->setFirstPlayed( date ); - } - } -} - -QDateTime -AggregateTrack::lastPlayed() const -{ - QDateTime result; - //return the latest timestamp. Easier than firstPlayed because we do not have to - //care about 0. - //when are we going to perform the refactoring as discussed in Berlin? - foreach( const Meta::TrackPtr &track, m_tracks ) - { - if( track->statistics()->lastPlayed() > result ) - { - result = track->statistics()->lastPlayed(); - } - } - return result; -} - -void -AggregateTrack::setLastPlayed(const QDateTime& date) -{ - foreach( Meta::TrackPtr track, m_tracks ) - { - // only "raise" the last played - Meta::StatisticsPtr trackStats = track->statistics(); - if( !trackStats->lastPlayed().isValid() || - trackStats->lastPlayed() < date ) - { - trackStats->setLastPlayed( date ); - } - } -} - -int -AggregateTrack::playCount() const -{ - // show the maximum of all play counts. - int result = 0; - foreach( const Meta::TrackPtr &track, m_tracks ) - { - if( track->statistics()->playCount() > result ) - { - result = track->statistics()->playCount(); - } - } - return result; -} - -void -AggregateTrack::setPlayCount( int newPlayCount ) -{ - Q_UNUSED( newPlayCount ) - // no safe thing to do here. Notice we override finishedPlaying() -} - -void -AggregateTrack::finishedPlaying( double playedFraction ) -{ - foreach( Meta::TrackPtr track, m_tracks ) - { - track->finishedPlaying( playedFraction ); - } -} - -qint64 -AggregateTrack::length() const -{ - foreach( const Meta::TrackPtr &track, m_tracks ) - { - if( track->length() ) - return track->length(); - } - return 0; -} - -int -AggregateTrack::filesize() const -{ - foreach( const Meta::TrackPtr &track, m_tracks ) - { - if( track->filesize() ) - { - return track->filesize(); - } - } - return 0; -} - -int -AggregateTrack::sampleRate() const -{ - foreach( const Meta::TrackPtr &track, m_tracks ) - { - if( track->sampleRate() ) - return track->sampleRate(); - } - return 0; -} - -int -AggregateTrack::bitrate() const -{ - foreach( const Meta::TrackPtr &track, m_tracks ) - { - if( track->bitrate() ) - return track->bitrate(); - } - return 0; -} - -QDateTime -AggregateTrack::createDate() const -{ - QDateTime result; - foreach( const Meta::TrackPtr &track, m_tracks ) - { - //use the track's firstPlayed value if it represents an earlier timestamp than - //the current result, or use it directly if result has not been set yet - //this should result in the earliest timestamp for first play of all internal - //tracks being returned - if( ( track->createDate().isValid() && result.isValid() && track->createDate() < result ) || - ( track->createDate().isValid() && !result.isValid() ) ) - { - result = track->createDate(); - } - } - return result; -} - -int -AggregateTrack::trackNumber() const -{ - int result = 0; - foreach( const Meta::TrackPtr &track, m_tracks ) - { - if( ( !result && track->trackNumber() ) || ( result && result == track->trackNumber() ) ) - { - result = track->trackNumber(); - } - else if( result && result != track->trackNumber() ) - { - //tracks disagree about the tracknumber - return 0; - } - } - return result; -} - -int -AggregateTrack::discNumber() const -{ - int result = 0; - foreach( const Meta::TrackPtr &track, m_tracks ) - { - if( ( !result && track->discNumber() ) || ( result && result == track->discNumber() ) ) - { - result = track->discNumber(); - } - else if( result && result != track->discNumber() ) - { - //tracks disagree about the disc number - return 0; - } - } - return result; -} - -QString -AggregateTrack::type() const -{ - if( m_tracks.size() == 1 ) - { - return m_tracks.first()->type(); - } - else - { - //TODO: figure something out - return QString(); - } -} - -Collections::Collection* -AggregateTrack::collection() const -{ - return m_collection; -} - -bool -AggregateTrack::hasCapabilityInterface( Capabilities::Capability::Type type ) const -{ - if( m_tracks.count() == 1 ) - // if we aggregate only one track, simply return the tracks capability directly - return m_tracks.first()->hasCapabilityInterface( type ); - else - return false; -} - -Capabilities::Capability* -AggregateTrack::createCapabilityInterface( Capabilities::Capability::Type type ) -{ - if( m_tracks.count() == 1 ) - return m_tracks.first()->createCapabilityInterface( type ); - else - return 0; -} - -TrackEditorPtr -AggregateTrack::editor() -{ - if( m_tracks.count() == 1 ) - return m_tracks.first()->editor(); - - QList editors; - foreach( Meta::TrackPtr track, m_tracks ) - { - Meta::TrackEditorPtr ec = track->editor(); - if( ec ) - editors << ec; - else - return TrackEditorPtr(); - } - return TrackEditorPtr( new AggregateTrackEditor( m_collection, editors ) ); -} - -void -AggregateTrack::addLabel( const QString &label ) -{ - foreach( Meta::TrackPtr track, m_tracks ) - { - track->addLabel( label ); - } -} - -void -AggregateTrack::addLabel( const Meta::LabelPtr &label ) -{ - foreach( Meta::TrackPtr track, m_tracks ) - { - track->addLabel( label ); - } -} - -void -AggregateTrack::removeLabel( const Meta::LabelPtr &label ) -{ - foreach( Meta::TrackPtr track, m_tracks ) - { - track->removeLabel( label ); - } -} - -Meta::LabelList -AggregateTrack::labels() const -{ - QSet aggregateLabels; - foreach( const Meta::TrackPtr &track, m_tracks ) - { - foreach( Meta::LabelPtr label, track->labels() ) - { - aggregateLabels.insert( m_collection->getLabel( label ) ); - } - } - Meta::LabelList result; - foreach( AggregateLabel *label, aggregateLabels ) - { - result << Meta::LabelPtr( label ); - } - return result; -} - -StatisticsPtr -AggregateTrack::statistics() -{ - return StatisticsPtr( this ); -} - -void -AggregateTrack::add( const Meta::TrackPtr &track ) -{ - if( !track || m_tracks.contains( track ) ) - return; - - m_tracks.append( track ); - subscribeTo( track ); - - notifyObservers(); -} - -void -AggregateTrack::metadataChanged( Meta::TrackPtr track ) -{ - if( !track ) - return; - - if( !m_tracks.contains( track ) ) - { - //why are we subscribed? - unsubscribeFrom( track ); - return; - } - - const TrackKey myKey( Meta::TrackPtr( this ) ); - const TrackKey otherKey( track ); - if( myKey == otherKey ) - { - //no key relevant metadata did change - notifyObservers(); - return; - } - else - { - if( m_tracks.size() == 1 ) - { - if( m_collection->hasTrack( otherKey ) ) - { - unsubscribeFrom( track ); - m_collection->getTrack( track ); - m_tracks.removeAll( track ); - m_collection->removeTrack( myKey ); - return; //do not notify observers, this track is not valid anymore! - } - else - { - m_name = track->name(); - if( track->album() ) - m_album = Meta::AlbumPtr( m_collection->getAlbum( track->album() ) ); - if( track->artist() ) - m_artist = Meta::ArtistPtr( m_collection->getArtist( track->artist() ) ); - if( track->genre() ) - m_genre = Meta::GenrePtr( m_collection->getGenre( track->genre() ) ); - if( track->composer() ) - m_composer = Meta::ComposerPtr( m_collection->getComposer( track->composer() ) ); - if( track->year() ) - m_year = Meta::YearPtr( m_collection->getYear( track->year() ) ); - - m_collection->setTrack( this ); - m_collection->removeTrack( myKey ); - } - } - else - { - unsubscribeFrom( track ); - m_collection->getTrack( track ); - m_tracks.removeAll( track ); - } - notifyObservers(); - } -} - -AggregateAlbum::AggregateAlbum( Collections::AggregateCollection *coll, Meta::AlbumPtr album ) - : Meta::Album() - , Meta::Observer() - , m_collection( coll ) - , m_name( album->name() ) -{ - m_albums.append( album ); - if( album->hasAlbumArtist() ) - m_albumArtist = Meta::ArtistPtr( m_collection->getArtist( album->albumArtist() ) ); -} - -AggregateAlbum::~AggregateAlbum() -{ -} - -QString -AggregateAlbum::name() const -{ - return m_name; -} - -QString -AggregateAlbum::prettyName() const -{ - return m_name; -} - -QString -AggregateAlbum::sortableName() const -{ - if( !m_albums.isEmpty() ) - return m_albums.first()->sortableName(); - - return m_name; -} - -Meta::TrackList -AggregateAlbum::tracks() -{ - QSet tracks; - foreach( Meta::AlbumPtr album, m_albums ) - { - Meta::TrackList tmp = album->tracks(); - foreach( const Meta::TrackPtr &track, tmp ) - { - tracks.insert( m_collection->getTrack( track ) ); - } - } - - Meta::TrackList result; - foreach( AggregateTrack *track, tracks ) - { - result.append( Meta::TrackPtr( track ) ); - } - return result; -} - -Meta::ArtistPtr -AggregateAlbum::albumArtist() const -{ - return m_albumArtist; -} - -bool -AggregateAlbum::isCompilation() const -{ - return m_albumArtist.isNull(); -} - -bool -AggregateAlbum::hasAlbumArtist() const -{ - return !m_albumArtist.isNull(); -} - -bool -AggregateAlbum::hasCapabilityInterface(Capabilities::Capability::Type type ) const -{ - - if( m_albums.count() == 1 ) - { - return m_albums.first()->hasCapabilityInterface( type ); - } - else - { - return false; - } -} - -Capabilities::Capability* -AggregateAlbum::createCapabilityInterface( Capabilities::Capability::Type type ) -{ - if( m_albums.count() == 1 ) - { - return m_albums.first()->createCapabilityInterface( type ); - } - else - { - return 0; - } -} - -void -AggregateAlbum::add( Meta::AlbumPtr album ) -{ - if( !album || m_albums.contains( album ) ) - return; - - m_albums.append( album ); - subscribeTo( album ); - - notifyObservers(); -} - -bool -AggregateAlbum::hasImage( int size ) const -{ - foreach( const Meta::AlbumPtr &album, m_albums ) - { - if( album->hasImage( size ) ) - return true; - } - return false; -} - -QImage -AggregateAlbum::image( int size ) const -{ - foreach( Meta::AlbumPtr album, m_albums ) - { - if( album->hasImage( size ) ) - { - return album->image( size ); - } - } - return Meta::Album::image( size ); -} - -KUrl -AggregateAlbum::imageLocation( int size ) -{ - foreach( Meta::AlbumPtr album, m_albums ) - { - if( album->hasImage( size ) ) - { - KUrl url = album->imageLocation( size ); - if( url.isValid() ) - { - return url; - } - } - } - return KUrl(); -} - -QPixmap -AggregateAlbum::imageWithBorder( int size, int borderWidth ) -{ - foreach( Meta::AlbumPtr album, m_albums ) - { - if( album->hasImage( size ) ) - { - return The::svgHandler()->imageWithBorder( album, size, borderWidth ); - } - } - return QPixmap(); -} - -bool -AggregateAlbum::canUpdateImage() const -{ - if( m_albums.count() == 0 ) - return false; - - foreach( const Meta::AlbumPtr &album, m_albums ) - { - //we can only update the image for all albusm at the same time - if( !album->canUpdateImage() ) - return false; - } - return true; -} - -void -AggregateAlbum::setImage( const QImage &image ) -{ - foreach( Meta::AlbumPtr album, m_albums ) - { - album->setImage( image ); - } -} - -void -AggregateAlbum::removeImage() -{ - foreach( Meta::AlbumPtr album, m_albums ) - { - album->removeImage(); - } -} - -void -AggregateAlbum::setSuppressImageAutoFetch( bool suppress ) -{ - foreach( Meta::AlbumPtr album, m_albums ) - { - album->setSuppressImageAutoFetch( suppress ); - } -} - -bool -AggregateAlbum::suppressImageAutoFetch() const -{ - foreach( const Meta::AlbumPtr &album, m_albums ) - { - if( !album->suppressImageAutoFetch() ) - return false; - } - return true; -} - -void -AggregateAlbum::metadataChanged( Meta::AlbumPtr album ) -{ - if( !album || !m_albums.contains( album ) ) - return; - - if( album->name() != m_name || - hasAlbumArtist() != album->hasAlbumArtist() || - ( hasAlbumArtist() && m_albumArtist->name() != album->albumArtist()->name() ) ) - { - if( m_albums.count() > 1 ) - { - m_collection->getAlbum( album ); - unsubscribeFrom( album ); - m_albums.removeAll( album ); - } - else - { - Meta::ArtistPtr albumartist; - if( album->hasAlbumArtist() ) - albumartist = Meta::ArtistPtr( m_collection->getArtist( album->albumArtist() ) ); - - QString artistname = m_albumArtist ? m_albumArtist->name() : QString(); - m_collection->removeAlbum( m_name, artistname ); - m_name = album->name(); - m_albumArtist = albumartist; - m_collection->setAlbum( this ); - } - } - - notifyObservers(); -} - -AggregateArtist::AggregateArtist( Collections::AggregateCollection *coll, Meta::ArtistPtr artist ) - : Meta::Artist() - , Meta::Observer() - , m_collection( coll ) - , m_name( artist->name() ) -{ - m_artists.append( artist ); - subscribeTo( artist ); -} - -AggregateArtist::~AggregateArtist() -{ -} - -QString -AggregateArtist::name() const -{ - return m_name; -} - -QString -AggregateArtist::prettyName() const -{ - return m_name; -} - -QString -AggregateArtist::sortableName() const -{ - if( !m_artists.isEmpty() ) - return m_artists.first()->sortableName(); - - return m_name; -} - -Meta::TrackList -AggregateArtist::tracks() -{ - QSet tracks; - foreach( Meta::ArtistPtr artist, m_artists ) - { - Meta::TrackList tmp = artist->tracks(); - foreach( const Meta::TrackPtr &track, tmp ) - { - tracks.insert( m_collection->getTrack( track ) ); - } - } - - Meta::TrackList result; - foreach( AggregateTrack *track, tracks ) - { - result.append( Meta::TrackPtr( track ) ); - } - return result; -} - -bool -AggregateArtist::hasCapabilityInterface(Capabilities::Capability::Type type ) const -{ - - if( m_artists.count() == 1 ) - { - return m_artists.first()->hasCapabilityInterface( type ); - } - else - { - return false; - } -} - -Capabilities::Capability* -AggregateArtist::createCapabilityInterface( Capabilities::Capability::Type type ) -{ - if( m_artists.count() == 1 ) - { - return m_artists.first()->createCapabilityInterface( type ); - } - else - { - return 0; - } -} - -void -AggregateArtist::add( Meta::ArtistPtr artist ) -{ - if( !artist || m_artists.contains( artist ) ) - return; - - m_artists.append( artist ); - subscribeTo( artist ); - - notifyObservers(); -} - -void -AggregateArtist::metadataChanged( Meta::ArtistPtr artist ) -{ - if( !artist || !m_artists.contains( artist ) ) - return; - - if( artist->name() != m_name ) - { - if( m_artists.count() > 1 ) - { - m_collection->getArtist( artist ); - unsubscribeFrom( artist ); - m_artists.removeAll( artist ); - } - else - { - //possible race condition here: - //if another thread creates an Artist with the new name - //we will have two instances that have the same name! - //TODO: figure out a way around that - //the race condition is a problem for all other metadataChanged methods too - m_collection->removeArtist( m_name ); - m_name = artist->name(); - m_collection->setArtist( this ); - - } - } - - notifyObservers(); -} - -AggregateGenre::AggregateGenre( Collections::AggregateCollection *coll, Meta::GenrePtr genre ) - : Meta::Genre() - , Meta::Observer() - , m_collection( coll ) - , m_name( genre->name() ) -{ - m_genres.append( genre ); - subscribeTo( genre ); -} - -AggregateGenre::~AggregateGenre() -{ -} - -QString -AggregateGenre::name() const -{ - return m_name; -} - -QString -AggregateGenre::prettyName() const -{ - return m_name; -} - -QString -AggregateGenre::sortableName() const -{ - if( !m_genres.isEmpty() ) - return m_genres.first()->sortableName(); - - return m_name; -} - -Meta::TrackList -AggregateGenre::tracks() -{ - QSet tracks; - foreach( Meta::GenrePtr genre, m_genres ) - { - Meta::TrackList tmp = genre->tracks(); - foreach( const Meta::TrackPtr &track, tmp ) - { - tracks.insert( m_collection->getTrack( track ) ); - } - } - - Meta::TrackList result; - foreach( AggregateTrack *track, tracks ) - { - result.append( Meta::TrackPtr( track ) ); - } - return result; -} - -bool -AggregateGenre::hasCapabilityInterface(Capabilities::Capability::Type type ) const -{ - - if( m_genres.count() == 1 ) - { - return m_genres.first()->hasCapabilityInterface( type ); - } - else - { - return false; - } -} - -Capabilities::Capability* -AggregateGenre::createCapabilityInterface( Capabilities::Capability::Type type ) -{ - if( m_genres.count() == 1 ) - { - return m_genres.first()->createCapabilityInterface( type ); - } - else - { - return 0; - } -} - -void -AggregateGenre::add( Meta::GenrePtr genre ) -{ - if( !genre || m_genres.contains( genre ) ) - return; - - m_genres.append( genre ); - subscribeTo( genre ); - - notifyObservers(); -} - -void -AggregateGenre::metadataChanged( Meta::GenrePtr genre ) -{ - if( !genre || !m_genres.contains( genre ) ) - return; - - if( genre->name() != m_name ) - { - if( m_genres.count() > 1 ) - { - m_collection->getGenre( genre ); - unsubscribeFrom( genre ); - m_genres.removeAll( genre ); - } - else - { - m_collection->removeGenre( m_name ); - m_collection->setGenre( this ); - m_name = genre->name(); - } - } - - notifyObservers(); -} - -AggregateComposer::AggregateComposer( Collections::AggregateCollection *coll, Meta::ComposerPtr composer ) - : Meta::Composer() - , Meta::Observer() - , m_collection( coll ) - , m_name( composer->name() ) -{ - m_composers.append( composer ); - subscribeTo( composer ); -} - -AggregateComposer::~AggregateComposer() -{ -} - -QString -AggregateComposer::name() const -{ - return m_name; -} - -QString -AggregateComposer::prettyName() const -{ - return m_name; -} - -QString -AggregateComposer::sortableName() const -{ - if( !m_composers.isEmpty() ) - return m_composers.first()->sortableName(); - - return m_name; -} - -Meta::TrackList -AggregateComposer::tracks() -{ - QSet tracks; - foreach( Meta::ComposerPtr composer, m_composers ) - { - Meta::TrackList tmp = composer->tracks(); - foreach( const Meta::TrackPtr &track, tmp ) - { - tracks.insert( m_collection->getTrack( track ) ); - } - } - - Meta::TrackList result; - foreach( AggregateTrack *track, tracks ) - { - result.append( Meta::TrackPtr( track ) ); - } - return result; -} - -bool -AggregateComposer::hasCapabilityInterface(Capabilities::Capability::Type type ) const -{ - - if( m_composers.count() == 1 ) - { - return m_composers.first()->hasCapabilityInterface( type ); - } - else - { - return false; - } -} - -Capabilities::Capability* -AggregateComposer::createCapabilityInterface( Capabilities::Capability::Type type ) -{ - if( m_composers.count() == 1 ) - { - return m_composers.first()->createCapabilityInterface( type ); - } - else - { - return 0; - } -} - -void -AggregateComposer::add( Meta::ComposerPtr composer ) -{ - if( !composer || m_composers.contains( composer ) ) - return; - - m_composers.append( composer ); - subscribeTo( composer ); - - notifyObservers(); -} - -void -AggregateComposer::metadataChanged( Meta::ComposerPtr composer ) -{ - if( !composer || !m_composers.contains( composer ) ) - return; - - if( composer->name() != m_name ) - { - if( m_composers.count() > 1 ) - { - m_collection->getComposer( composer ); - unsubscribeFrom( composer ); - m_composers.removeAll( composer ); - } - else - { - m_collection->removeComposer( m_name ); - m_collection->setComposer( this ); - m_name = composer->name(); - } - } - - notifyObservers(); -} - -AggreagateYear::AggreagateYear( Collections::AggregateCollection *coll, Meta::YearPtr year ) - : Meta::Year() - , Meta::Observer() - , m_collection( coll ) - , m_name( year->name() ) -{ - m_years.append( year ); - subscribeTo( year ); -} - -AggreagateYear::~AggreagateYear() -{ - //nothing to do -} - -QString -AggreagateYear::name() const -{ - return m_name; -} - -QString -AggreagateYear::prettyName() const -{ - return m_name; -} - -QString -AggreagateYear::sortableName() const -{ - if( !m_years.isEmpty() ) - return m_years.first()->sortableName(); - - return m_name; -} - -Meta::TrackList -AggreagateYear::tracks() -{ - QSet tracks; - foreach( Meta::YearPtr year, m_years ) - { - Meta::TrackList tmp = year->tracks(); - foreach( const Meta::TrackPtr &track, tmp ) - { - tracks.insert( m_collection->getTrack( track ) ); - } - } - - Meta::TrackList result; - foreach( AggregateTrack *track, tracks ) - { - result.append( Meta::TrackPtr( track ) ); - } - return result; -} - -bool -AggreagateYear::hasCapabilityInterface(Capabilities::Capability::Type type ) const -{ - - if( m_years.count() == 1 ) - { - return m_years.first()->hasCapabilityInterface( type ); - } - else - { - return false; - } -} - -Capabilities::Capability* -AggreagateYear::createCapabilityInterface( Capabilities::Capability::Type type ) -{ - if( m_years.count() == 1 ) - { - return m_years.first()->createCapabilityInterface( type ); - } - else - { - return 0; - } -} - -void -AggreagateYear::add( Meta::YearPtr year ) -{ - if( !year || m_years.contains( year ) ) - return; - - m_years.append( year ); - subscribeTo( year ); - - notifyObservers(); -} - -void -AggreagateYear::metadataChanged( Meta::YearPtr year ) -{ - if( !year || !m_years.contains( year ) ) - return; - - if( year->name() != m_name ) - { - if( m_years.count() > 1 ) - { - m_collection->getYear( year ); - unsubscribeFrom( year ); - m_years.removeAll( year ); - } - else - { - if( m_collection->hasYear( year->name() ) ) - { - unsubscribeFrom( year ); - m_collection->getYear( year ); - m_years.removeAll( year ); - m_collection->removeYear( m_name ); - return; //do NOT notify observers, the instance is not valid anymore! - } - else - { - // be careful with the ordering of instructions here - // AggregateCollection uses KSharedPtr internally - // so we have to make sure that there is more than one pointer - // to this instance by registering this instance under the new name - // before removing the old one. Otherwise kSharedPtr might delete this - // instance in removeYear() - QString tmpName = m_name; - m_name = year->name(); - m_collection->setYear( this ); - m_collection->removeYear( tmpName ); - } - } - } - - notifyObservers(); -} - -AggregateLabel::AggregateLabel( Collections::AggregateCollection *coll, const Meta::LabelPtr &label ) - : Meta::Label() - , m_collection( coll ) - , m_name( label->name() ) -{ - m_labels.append( label ); - Q_UNUSED(m_collection); // might be needed later -} - -AggregateLabel::~AggregateLabel() -{ - //nothing to do -} - -QString -AggregateLabel::name() const -{ - return m_name; -} - -QString -AggregateLabel::prettyName() const -{ - return m_name; -} - -QString -AggregateLabel::sortableName() const -{ - if( !m_labels.isEmpty() ) - return m_labels.first()->sortableName(); - - return m_name; -} - -bool -AggregateLabel::hasCapabilityInterface( Capabilities::Capability::Type type ) const -{ - - if( m_labels.count() == 1 ) - { - return m_labels.first()->hasCapabilityInterface( type ); - } - else - { - return false; - } -} - -Capabilities::Capability* -AggregateLabel::createCapabilityInterface( Capabilities::Capability::Type type ) -{ - if( m_labels.count() == 1 ) - { - return m_labels.first()->createCapabilityInterface( type ); - } - else - { - return 0; - } -} - -void -AggregateLabel::add( const Meta::LabelPtr &label ) -{ - if( !label || m_labels.contains( label ) ) - return; - - m_labels.append( label ); -} - -} //namespace Meta diff --git a/amarok/src/core-impl/collections/aggregate/AggregateMeta.h b/amarok/src/core-impl/collections/aggregate/AggregateMeta.h deleted file mode 100644 index 4c19bdc5..00000000 --- a/amarok/src/core-impl/collections/aggregate/AggregateMeta.h +++ /dev/null @@ -1,301 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AGGREGATEMETA_H -#define AGGREGATEMETA_H - -#include "amarok_export.h" -#include "core/meta/Meta.h" -#include "core/meta/Observer.h" -#include "core/meta/Statistics.h" - -#include - -namespace Collections { - class AggregateCollection; -} - -namespace Meta { - - class AMAROK_EXPORT AggregateTrack : public Meta::Track, public Meta::Statistics, private Meta::Observer - { - public: - AggregateTrack( Collections::AggregateCollection *coll, const Meta::TrackPtr &track ); - ~AggregateTrack(); - - QString name() const; - QString prettyName() const; - virtual QString sortableName() const; - - KUrl playableUrl() const; - QString prettyUrl() const; - QString uidUrl() const; - - /** - * Return a comma separated list of reasons why constituent - * tracks are unplayable or an empty string if any of the tracks is playable - */ - QString notPlayableReason() const; - - Meta::AlbumPtr album() const; - Meta::ArtistPtr artist() const; - Meta::ComposerPtr composer() const; - Meta::GenrePtr genre() const; - Meta::YearPtr year() const; - - QString comment() const; - qreal bpm() const; - - void finishedPlaying( double playedFraction ); - - qint64 length() const; - int filesize() const; - int sampleRate() const; - int bitrate() const; - QDateTime createDate() const; - int trackNumber() const; - int discNumber() const; - QString type() const; - - Collections::Collection* collection() const; - - virtual bool hasCapabilityInterface( Capabilities::Capability::Type type ) const; - virtual Capabilities::Capability* createCapabilityInterface( Capabilities::Capability::Type type ); - - virtual void addLabel( const QString &label ); - virtual void addLabel( const Meta::LabelPtr &label ); - virtual void removeLabel( const Meta::LabelPtr &label ); - virtual Meta::LabelList labels() const; - - virtual TrackEditorPtr editor(); - virtual StatisticsPtr statistics(); - - // Meta::Statistics methods: - double score() const; - void setScore( double newScore ); - int rating() const; - void setRating( int newRating ); - QDateTime firstPlayed() const; - void setFirstPlayed( const QDateTime &date ); - QDateTime lastPlayed() const; - void setLastPlayed( const QDateTime &date ); - int playCount() const; - void setPlayCount( int newPlayCount ); - - void add( const Meta::TrackPtr &track ); - - protected: - using Observer::metadataChanged; - virtual void metadataChanged( Meta::TrackPtr track ); - - private: - Collections::AggregateCollection *m_collection; - Meta::TrackList m_tracks; - QString m_name; - Meta::AlbumPtr m_album; - Meta::ArtistPtr m_artist; - Meta::GenrePtr m_genre; - Meta::ComposerPtr m_composer; - Meta::YearPtr m_year; - }; - - class AMAROK_EXPORT AggregateAlbum : public Meta::Album, private Meta::Observer - { - public: - AggregateAlbum( Collections::AggregateCollection *coll, Meta::AlbumPtr album ); - ~AggregateAlbum(); - - QString name() const; - QString prettyName() const; - virtual QString sortableName() const; - - Meta::TrackList tracks(); - Meta::ArtistPtr albumArtist() const; - bool isCompilation() const; - bool hasAlbumArtist() const; - - virtual bool hasCapabilityInterface( Capabilities::Capability::Type type ) const; - virtual Capabilities::Capability* createCapabilityInterface( Capabilities::Capability::Type type ); - - void add( Meta::AlbumPtr album ); - - /** returns true if the album has a cover set */ - virtual bool hasImage( int size = 0 ) const; - /** returns the cover of the album */ - virtual QImage image( int size = 0 ) const; - /** returns the image location on disk */ - virtual KUrl imageLocation( int size = 0 ); - /** returns the cover of the album with a nice border around it*/ - virtual QPixmap imageWithBorder( int size = 0, int borderWidth = 5 ); - /** Returns true if it is possible to update the cover of the album */ - virtual bool canUpdateImage() const; - /** updates the cover of the album */ - virtual void setImage( const QImage &image ); - virtual void removeImage(); - /** don't automatically fetch artwork */ - virtual void setSuppressImageAutoFetch( const bool suppress ); - /** should automatic artwork retrieval be suppressed? */ - virtual bool suppressImageAutoFetch() const; - - protected: - using Observer::metadataChanged; - virtual void metadataChanged( Meta::AlbumPtr album ); - - private: - Collections::AggregateCollection *m_collection; - Meta::AlbumList m_albums; - QString m_name; - Meta::ArtistPtr m_albumArtist; - }; - - class AMAROK_EXPORT AggregateArtist : public Meta::Artist, private Meta::Observer - { - public: - AggregateArtist( Collections::AggregateCollection *coll, Meta::ArtistPtr artist ); - ~AggregateArtist(); - - QString name() const; - QString prettyName() const; - virtual QString sortableName() const; - - Meta::TrackList tracks(); - - virtual bool hasCapabilityInterface( Capabilities::Capability::Type type ) const; - virtual Capabilities::Capability* createCapabilityInterface( Capabilities::Capability::Type type ); - - void add( Meta::ArtistPtr artist ); - - protected: - using Observer::metadataChanged; - virtual void metadataChanged( Meta::ArtistPtr artist ); - - private: - Collections::AggregateCollection *m_collection; - Meta::ArtistList m_artists; - QString m_name; - }; - - class AMAROK_EXPORT AggregateGenre : public Meta::Genre, private Meta::Observer - { - public: - AggregateGenre( Collections::AggregateCollection *coll, Meta::GenrePtr genre ); - ~AggregateGenre(); - - QString name() const; - QString prettyName() const; - virtual QString sortableName() const; - - Meta::TrackList tracks(); - - virtual bool hasCapabilityInterface( Capabilities::Capability::Type type ) const; - virtual Capabilities::Capability* createCapabilityInterface( Capabilities::Capability::Type type ); - - void add( Meta::GenrePtr genre ); - - protected: - using Observer::metadataChanged; - virtual void metadataChanged( Meta::GenrePtr genre ); - - private: - Collections::AggregateCollection *m_collection; - Meta::GenreList m_genres; - QString m_name; - }; - - class AMAROK_EXPORT AggregateComposer : public Meta::Composer, private Meta::Observer - { - public: - AggregateComposer( Collections::AggregateCollection *coll, Meta::ComposerPtr composer ); - ~AggregateComposer(); - - QString name() const; - QString prettyName() const; - virtual QString sortableName() const; - - Meta::TrackList tracks(); - - virtual bool hasCapabilityInterface( Capabilities::Capability::Type type ) const; - virtual Capabilities::Capability* createCapabilityInterface( Capabilities::Capability::Type type ); - - void add( Meta::ComposerPtr composer ); - - protected: - using Observer::metadataChanged; - virtual void metadataChanged( Meta::ComposerPtr composer ); - - private: - Collections::AggregateCollection *m_collection; - Meta::ComposerList m_composers; - QString m_name; - }; - - class AMAROK_EXPORT AggreagateYear : public Meta::Year, private Meta::Observer - { - public: - AggreagateYear( Collections::AggregateCollection * coll, Meta::YearPtr year ); - ~AggreagateYear(); - - QString name() const; - QString prettyName() const; - virtual QString sortableName() const; - - Meta::TrackList tracks(); - - virtual bool hasCapabilityInterface( Capabilities::Capability::Type type ) const; - virtual Capabilities::Capability* createCapabilityInterface( Capabilities::Capability::Type type ); - - /** - * adds another Meta::Year instance to be proxied. - */ - void add( Meta::YearPtr year ); - - protected: - using Observer::metadataChanged; - virtual void metadataChanged( Meta::YearPtr year ); - - private: - Collections::AggregateCollection *m_collection; - Meta::YearList m_years; - QString m_name; - - }; - - class AMAROK_EXPORT AggregateLabel : public Meta::Label - { - public: - AggregateLabel( Collections::AggregateCollection *coll, const Meta::LabelPtr &label ); - virtual ~AggregateLabel(); - - virtual QString name() const; - virtual QString prettyName() const; - virtual QString sortableName() const; - - virtual bool hasCapabilityInterface( Capabilities::Capability::Type type ) const; - virtual Capabilities::Capability* createCapabilityInterface( Capabilities::Capability::Type type ); - - /** - adds another Meta::Label instance to be proxied. - */ - void add( const Meta::LabelPtr &label ); - - private: - Collections::AggregateCollection *m_collection; - Meta::LabelList m_labels; - QString m_name; - }; -} // namespace Meta - -#endif // AGGREGATEMETA_H diff --git a/amarok/src/core-impl/collections/aggregate/AggregateQueryMaker.cpp b/amarok/src/core-impl/collections/aggregate/AggregateQueryMaker.cpp deleted file mode 100644 index 06b1b362..00000000 --- a/amarok/src/core-impl/collections/aggregate/AggregateQueryMaker.cpp +++ /dev/null @@ -1,546 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "AggregateQueryMaker" - -#include "AggregateQueryMaker.h" - -#include "core/meta/Meta.h" -#include "core/support/Debug.h" -#include "core-impl/collections/aggregate/AggregateCollection.h" -#include "core-impl/collections/support/MemoryCustomValue.h" -#include "core-impl/collections/support/MemoryQueryMakerHelper.h" - -#include -#include - -using namespace Collections; - -AggregateQueryMaker::AggregateQueryMaker( AggregateCollection *collection, const QList &queryMakers ) - : QueryMaker() - , m_collection( collection ) - , m_builders( queryMakers ) - , m_queryDoneCount( 0 ) - , m_maxResultSize( -1 ) - , m_queryType( QueryMaker::None ) - , m_orderDescending( false ) - , m_orderField( 0 ) - , m_orderByNumberField( false ) - , m_queryDoneCountMutex() -{ - foreach( QueryMaker *b, m_builders ) - { - connect( b, SIGNAL(queryDone()), this, SLOT(slotQueryDone()) ); - connect( b, SIGNAL(newResultReady(Meta::TrackList)), this, SLOT(slotNewResultReady(Meta::TrackList)), Qt::QueuedConnection ); - connect( b, SIGNAL(newResultReady(Meta::ArtistList)), this, SLOT(slotNewResultReady(Meta::ArtistList)), Qt::QueuedConnection ); - connect( b, SIGNAL(newResultReady(Meta::AlbumList)), this, SLOT(slotNewResultReady(Meta::AlbumList)), Qt::QueuedConnection ); - connect( b, SIGNAL(newResultReady(Meta::GenreList)), this, SLOT(slotNewResultReady(Meta::GenreList)), Qt::QueuedConnection ); - connect( b, SIGNAL(newResultReady(Meta::ComposerList)), this, SLOT(slotNewResultReady(Meta::ComposerList)), Qt::QueuedConnection ); - connect( b, SIGNAL(newResultReady(Meta::YearList)), this, SLOT(slotNewResultReady(Meta::YearList)), Qt::QueuedConnection ); - connect( b, SIGNAL(newResultReady(Meta::LabelList)), this, SLOT(slotNewResultReady(Meta::LabelList)), Qt::QueuedConnection ); - } -} - -AggregateQueryMaker::~AggregateQueryMaker() -{ - qDeleteAll( m_returnFunctions ); - qDeleteAll( m_returnValues ); - qDeleteAll( m_builders ); -} - -void -AggregateQueryMaker::run() -{ - foreach( QueryMaker *b, m_builders ) - b->run(); -} - -void -AggregateQueryMaker::abortQuery() -{ - foreach( QueryMaker *b, m_builders ) - b->abortQuery(); -} - -QueryMaker* -AggregateQueryMaker::setQueryType( QueryType type ) -{ - m_queryType = type; - if( type != QueryMaker::Custom ) - { - foreach( QueryMaker *b, m_builders ) - b->setQueryType( type ); - return this; - } - else - { - // we cannot forward custom queries as there is no way to integrate the results - // delivered by the QueryMakers. Instead we ask for tracks that match the criterias, - // and then generate the custom result similar to MemoryQueryMaker. - // And yes, this means that we will load all tracks when we simply want the count of tracks - // in the collection. It might be necessary to add some specific logic for that case. - // On second thought, there is no way around loading all objects, as we want to operate on distinct - // elements (for some value of distinct) in AggregateCollection. We can only figure out what the union - // of all elements is after loading them in memory - foreach( QueryMaker *b, m_builders ) - b->setQueryType( QueryMaker::Track ); - return this; - } -} - -QueryMaker* -AggregateQueryMaker::addReturnValue( qint64 value ) -{ - //do not forward this call, see comment in setQueryType() - m_returnValues.append( CustomValueFactory::returnValue( value ) ); - return this; -} - -QueryMaker* -AggregateQueryMaker::addReturnFunction( ReturnFunction function, qint64 value ) -{ - //do not forward this call, see comment in setQueryType() - m_returnFunctions.append( CustomValueFactory::returnFunction( function, value ) ); - return this; -} - -QueryMaker* -AggregateQueryMaker::orderBy( qint64 value, bool descending ) -{ - m_orderField = value; - m_orderDescending = descending; - //copied from MemoryQueryMaker. TODO: think of a sensible place to put this code - switch( value ) - { - case Meta::valYear: - case Meta::valTrackNr: - case Meta::valDiscNr: - case Meta::valBpm: - case Meta::valLength: - case Meta::valBitrate: - case Meta::valSamplerate: - case Meta::valFilesize: - case Meta::valFormat: - case Meta::valCreateDate: - case Meta::valScore: - case Meta::valRating: - case Meta::valFirstPlayed: - case Meta::valLastPlayed: - case Meta::valPlaycount: - case Meta::valModified: - { - m_orderByNumberField = true; - break; - } - default: - m_orderByNumberField = false; - } - foreach( QueryMaker *b, m_builders ) - b->orderBy( value, descending ); - return this; -} - -QueryMaker* -AggregateQueryMaker::addFilter( qint64 value, const QString &filter, bool matchBegin, bool matchEnd ) -{ - foreach( QueryMaker *b, m_builders ) - b->addFilter( value, filter, matchBegin, matchEnd ); - return this; -} - -QueryMaker* -AggregateQueryMaker::excludeFilter( qint64 value, const QString &filter, bool matchBegin, bool matchEnd ) -{ - foreach( QueryMaker *b, m_builders ) - b->excludeFilter( value, filter, matchBegin, matchEnd ); - return this; -} - -QueryMaker* -AggregateQueryMaker::addNumberFilter( qint64 value, qint64 filter, QueryMaker::NumberComparison compare ) -{ - foreach( QueryMaker *b, m_builders ) - b->addNumberFilter( value, filter, compare); - return this; -} - -QueryMaker* -AggregateQueryMaker::excludeNumberFilter( qint64 value, qint64 filter, QueryMaker::NumberComparison compare ) -{ - foreach( QueryMaker *b, m_builders ) - b->excludeNumberFilter( value, filter, compare ); - return this; -} - -QueryMaker* -AggregateQueryMaker::addMatch( const Meta::TrackPtr &track ) -{ - foreach( QueryMaker *b, m_builders ) - b->addMatch( track ); - return this; -} - -QueryMaker* -AggregateQueryMaker::addMatch( const Meta::ArtistPtr &artist, QueryMaker::ArtistMatchBehaviour behaviour ) -{ - foreach( QueryMaker *b, m_builders ) - b->addMatch( artist, behaviour ); - return this; -} - -QueryMaker* -AggregateQueryMaker::addMatch( const Meta::AlbumPtr &album ) -{ - foreach( QueryMaker *b, m_builders ) - b->addMatch( album ); - return this; -} - -QueryMaker* -AggregateQueryMaker::addMatch( const Meta::GenrePtr &genre ) -{ - foreach( QueryMaker *b, m_builders ) - b->addMatch( genre ); - return this; -} - -QueryMaker* -AggregateQueryMaker::addMatch( const Meta::ComposerPtr &composer ) -{ - foreach( QueryMaker *b, m_builders ) - b->addMatch( composer ); - return this; -} - -QueryMaker* -AggregateQueryMaker::addMatch( const Meta::YearPtr &year ) -{ - foreach( QueryMaker *b, m_builders ) - b->addMatch( year ); - return this; -} - -QueryMaker* -AggregateQueryMaker::addMatch( const Meta::LabelPtr &label ) -{ - foreach( QueryMaker *b, m_builders ) - b->addMatch( label ); - return this; -} - -QueryMaker* -AggregateQueryMaker::limitMaxResultSize( int size ) -{ - //forward the call so the m_builders do not have to do work - //that we definitely know is unnecessary (like returning more than size results) - //we have to limit the combined result of all m_builders nevertheless - m_maxResultSize = size; - foreach( QueryMaker *b, m_builders ) - b->limitMaxResultSize( size ); - return this; -} - -QueryMaker* -AggregateQueryMaker::beginAnd() -{ - foreach( QueryMaker *b, m_builders ) - b->beginAnd(); - return this; -} - -QueryMaker* -AggregateQueryMaker::beginOr() -{ - foreach( QueryMaker *b, m_builders ) - b->beginOr(); - return this; -} - -QueryMaker* -AggregateQueryMaker::endAndOr() -{ - foreach( QueryMaker *b, m_builders ) - b->endAndOr(); - return this; -} - -QueryMaker* -AggregateQueryMaker::setAlbumQueryMode( AlbumQueryMode mode ) -{ - foreach( QueryMaker *b, m_builders ) - b->setAlbumQueryMode( mode ); - return this; -} - -QueryMaker* -AggregateQueryMaker::setLabelQueryMode( LabelQueryMode mode ) -{ - foreach( QueryMaker *b, m_builders ) - b->setLabelQueryMode( mode ); - return this; -} - -void -AggregateQueryMaker::slotQueryDone() -{ - m_queryDoneCountMutex.lock(); - m_queryDoneCount++; - if ( m_queryDoneCount == m_builders.size() ) - { - //make sure we don't give control to code outside this class while holding the lock - m_queryDoneCountMutex.unlock(); - handleResult(); - emit queryDone(); - } - else - { - m_queryDoneCountMutex.unlock(); - } -} - -template -void AggregateQueryMaker::emitProperResult( const QList& list ) -{ - QList resultList = list; - - if ( m_maxResultSize >= 0 && resultList.count() > m_maxResultSize ) - resultList = resultList.mid( 0, m_maxResultSize ); - - emit newResultReady( list ); -} - -void -AggregateQueryMaker::handleResult() -{ - //copied from MemoryQueryMaker::handleResult() - switch( m_queryType ) - { - case QueryMaker::Custom : - { - QStringList result; - Meta::TrackList tracks; - foreach( KSharedPtr track, m_tracks ) - { - tracks.append( Meta::TrackPtr::staticCast( track ) ); - } - if( !m_returnFunctions.empty() ) - { - //no sorting necessary - foreach( CustomReturnFunction *function, m_returnFunctions ) - { - result.append( function->value( tracks ) ); - } - } - else if( !m_returnValues.empty() ) - { - if( m_orderField ) - { - if( m_orderByNumberField ) - tracks = MemoryQueryMakerHelper::orderListByNumber( tracks, m_orderField, m_orderDescending ); - else - tracks = MemoryQueryMakerHelper::orderListByString( tracks, m_orderField, m_orderDescending ); - } - - int count = 0; - foreach( const Meta::TrackPtr &track, tracks ) - { - if ( m_maxResultSize >= 0 && count == m_maxResultSize ) - break; - - foreach( CustomReturnValue *value, m_returnValues ) - { - result.append( value->value( track ) ); - } - count++; - } - } - emit newResultReady( result ); - break; - } - case QueryMaker::Track : - { - Meta::TrackList tracks; - foreach( KSharedPtr track, m_tracks ) - { - tracks.append( Meta::TrackPtr::staticCast( track ) ); - } - - if( m_orderField ) - { - if( m_orderByNumberField ) - tracks = MemoryQueryMakerHelper::orderListByNumber( tracks, m_orderField, m_orderDescending ); - else - tracks = MemoryQueryMakerHelper::orderListByString( tracks, m_orderField, m_orderDescending ); - } - - emitProperResult( tracks ); - break; - } - case QueryMaker::Album : - { - Meta::AlbumList albums; - foreach( KSharedPtr album, m_albums ) - { - albums.append( Meta::AlbumPtr::staticCast( album ) ); - } - - albums = MemoryQueryMakerHelper::orderListByName( albums, m_orderDescending ); - - emitProperResult( albums ); - break; - } - case QueryMaker::Artist : - case QueryMaker::AlbumArtist : - { - Meta::ArtistList artists; - foreach( KSharedPtr artist, m_artists ) - { - artists.append( Meta::ArtistPtr::staticCast( artist ) ); - } - - artists = MemoryQueryMakerHelper::orderListByName( artists, m_orderDescending ); - emitProperResult( artists ); - break; - } - case QueryMaker::Composer : - { - Meta::ComposerList composers; - foreach( KSharedPtr composer, m_composers ) - { - composers.append( Meta::ComposerPtr::staticCast( composer ) ); - } - - composers = MemoryQueryMakerHelper::orderListByName( composers, m_orderDescending ); - - emitProperResult( composers ); - break; - } - case QueryMaker::Genre : - { - Meta::GenreList genres; - foreach( KSharedPtr genre, m_genres ) - { - genres.append( Meta::GenrePtr::staticCast( genre ) ); - } - - genres = MemoryQueryMakerHelper::orderListByName( genres, m_orderDescending ); - - emitProperResult( genres ); - break; - } - case QueryMaker::Year : - { - Meta::YearList years; - foreach( KSharedPtr year, m_years ) - { - years.append( Meta::YearPtr::staticCast( year ) ); - } - - //years have to be ordered as numbers, but orderListByNumber does not work for Meta::YearPtrs - if( m_orderField == Meta::valYear ) - { - years = MemoryQueryMakerHelper::orderListByYear( years, m_orderDescending ); - } - - emitProperResult( years ); - break; - } - case QueryMaker::Label : - { - Meta::LabelList labels; - foreach( KSharedPtr label, m_labels ) - { - labels.append( Meta::LabelPtr::staticCast( label ) ); - } - - labels = MemoryQueryMakerHelper::orderListByName( labels, m_orderDescending ); - emitProperResult( labels ); - break; - } - case QueryMaker::None : - //nothing to do - break; - } - m_tracks.clear(); - m_albums.clear(); - m_artists.clear(); - m_composers.clear(); - m_genres.clear(); - m_years.clear(); -} - -void -AggregateQueryMaker::slotNewResultReady( const Meta::TrackList &tracks ) -{ - foreach( const Meta::TrackPtr &track, tracks ) - { - m_tracks.insert( KSharedPtr( m_collection->getTrack( track ) ) ); - } -} - -void -AggregateQueryMaker::slotNewResultReady( const Meta::ArtistList &artists ) -{ - foreach( const Meta::ArtistPtr &artist, artists ) - { - m_artists.insert( KSharedPtr( m_collection->getArtist( artist ) ) ); - } -} - -void -AggregateQueryMaker::slotNewResultReady( const Meta::AlbumList &albums ) -{ - foreach( const Meta::AlbumPtr &album, albums ) - { - m_albums.insert( KSharedPtr( m_collection->getAlbum( album ) ) ); - } -} - -void -AggregateQueryMaker::slotNewResultReady( const Meta::GenreList &genres ) -{ - foreach( const Meta::GenrePtr &genre, genres ) - { - m_genres.insert( KSharedPtr( m_collection->getGenre( genre ) ) ); - } -} - -void -AggregateQueryMaker::slotNewResultReady( const Meta::ComposerList &composers ) -{ - foreach( const Meta::ComposerPtr &composer, composers ) - { - m_composers.insert( KSharedPtr( m_collection->getComposer( composer ) ) ); - } -} - -void -AggregateQueryMaker::slotNewResultReady( const Meta::YearList &years ) -{ - foreach( const Meta::YearPtr &year, years ) - { - m_years.insert( KSharedPtr( m_collection->getYear( year ) ) ); - } -} - -void -AggregateQueryMaker::slotNewResultReady( const Meta::LabelList &labels ) -{ - foreach( const Meta::LabelPtr &label, labels ) - { - m_labels.insert( KSharedPtr( m_collection->getLabel( label ) ) ); - } -} diff --git a/amarok/src/core-impl/collections/aggregate/AggregateQueryMaker.h b/amarok/src/core-impl/collections/aggregate/AggregateQueryMaker.h deleted file mode 100644 index 2232467a..00000000 --- a/amarok/src/core-impl/collections/aggregate/AggregateQueryMaker.h +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright (c) 2009 Maximilian Kossick - * - * This program 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 2 of the License, or - * (at your option) any later version. - * - * This program 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 this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#ifndef AGGREGATEQUERYMAKER_H -#define AGGREGATEQUERYMAKER_H - -#include "core/collections/QueryMaker.h" -#include "core/collections/Collection.h" -#include "core-impl/collections/aggregate/AggregateMeta.h" - -#include -#include -#include - -#include - -class CustomReturnFunction; -class CustomReturnValue; - -namespace Collections -{ - -class AMAROK_EXPORT AggregateQueryMaker : public QueryMaker -{ - Q_OBJECT - - public: - AggregateQueryMaker( Collections::AggregateCollection *collection, const QList &queryMakers ); - ~AggregateQueryMaker(); - - virtual void run(); - virtual void abortQuery(); - - virtual QueryMaker* setQueryType( QueryType type ); - - virtual QueryMaker* addReturnValue( qint64 value); - virtual QueryMaker* addReturnFunction( ReturnFunction function, qint64 value ); - virtual QueryMaker* orderBy( qint64 value, bool descending = false ); - - virtual QueryMaker* addMatch( const Meta::TrackPtr &track ); - virtual QueryMaker* addMatch( const Meta::ArtistPtr &artist, ArtistMatchBehaviour behaviour = TrackArtists ); - virtual QueryMaker* addMatch( const Meta::AlbumPtr &album ); - virtual QueryMaker* addMatch( const Meta::ComposerPtr &composer ); - virtual QueryMaker* addMatch( const Meta::GenrePtr &genre ); - virtual QueryMaker* addMatch( const Meta::YearPtr &year ); - virtual QueryMaker* addMatch( const Meta::LabelPtr &label ); - - virtual QueryMaker* addFilter( qint64 value, const QString &filter, bool matchBegin, bool matchEnd ); - virtual QueryMaker* excludeFilter( qint64 value, const QString &filter, bool matchBegin, bool matchEnd ); - - virtual QueryMaker* addNumberFilter( qint64 value, qint64 filter, QueryMaker::NumberComparison compare ); - virtual QueryMaker* excludeNumberFilter( qint64 value, qint64 filter, QueryMaker::NumberComparison compare ); - - virtual QueryMaker* limitMaxResultSize( int size ); - - virtual QueryMaker* beginAnd(); - virtual QueryMaker* beginOr(); - virtual QueryMaker* endAndOr(); - - virtual QueryMaker* setAlbumQueryMode( AlbumQueryMode mode ); - virtual QueryMaker* setLabelQueryMode( LabelQueryMode mode ); - - private: - template - void emitProperResult( const QList &list ); - - void handleResult(); - - private slots: - void slotQueryDone(); - void slotNewResultReady( const Meta::TrackList &tracks ); - void slotNewResultReady( const Meta::ArtistList &artists ); - void slotNewResultReady( const Meta::AlbumList &albums ); - void slotNewResultReady( const Meta::GenreList &genres ); - void slotNewResultReady( const Meta::ComposerList &composers ); - void slotNewResultReady( const Meta::YearList &years ); - void slotNewResultReady( const Meta::LabelList &labels ); - - private: - AggregateCollection *m_collection; - QList m_builders; - int m_queryDoneCount; - bool m_returnDataPointers; - int m_maxResultSize; - QueryType m_queryType; - bool m_orderDescending; - qint64 m_orderField; - bool m_orderByNumberField; - QMutex m_queryDoneCountMutex; - // store AggregateCollection meta stuff using KSharedPtr, - // otherwise AggregateCollection might delete it (as soon as it gets garbage collection) - QSet > m_tracks; - QSet > m_artists; - QSet > m_albums; - QSet > m_genres; - QSet > m_composers; - QSet > m_years; - QSet > m_labels; - QList m_returnFunctions; - QList m_returnValues; -}; - -} - -#endif /* AGGREGATEQUERYMAKER_H */ diff --git a/amarok/src/core-impl/collections/aggregate/CMakeLists.txt b/amarok/src/core-impl/collections/aggregate/CMakeLists.txt deleted file mode 100644 index e69de29b..00000000 diff --git a/amarok/src/core-impl/collections/audiocd/AudioCdCollection.cpp b/amarok/src/core-impl/collections/audiocd/AudioCdCollection.cpp deleted file mode 100644 index f2690a38..00000000 --- a/amarok/src/core-impl/collections/audiocd/AudioCdCollection.cpp +++ /dev/null @@ -1,603 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * Copyright (c) 2009 Seb Ruiz * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "AudioCdCollection" - -#include "AudioCdCollection.h" - -#include "MainWindow.h" -#include "amarokconfig.h" -#include "AudioCdCollectionLocation.h" -#include "AudioCdMeta.h" -#include "core-impl/collections/support/CollectionManager.h" -#include "core-impl/collections/support/MemoryQueryMaker.h" -#include "covermanager/CoverFetcher.h" -#include "core/support/Debug.h" -#include "EngineController.h" -#include "MediaDeviceMonitor.h" -#include "MemoryQueryMaker.h" -#include "SvgHandler.h" -#include "handler/AudioCdHandler.h" -#include "support/AudioCdConnectionAssistant.h" -#include "support/AudioCdDeviceInfo.h" - -#include -#include -#include - -#include -#include - -#include -#include - -#include -#include - -using namespace Collections; - -AMAROK_EXPORT_COLLECTION( AudioCdCollectionFactory, audiocdcollection ) - -static const QString unknownCddbId( "unknown" ); - -AudioCdCollectionFactory::AudioCdCollectionFactory( QObject *parent, const QVariantList &args ) - : MediaDeviceCollectionFactory( parent, args, new AudioCdConnectionAssistant() ) -{ - m_info = KPluginInfo( "amarok_collection-audiocdcollection.desktop", "services" ); -} - -AudioCdCollection::AudioCdCollection( MediaDeviceInfo* info ) - : MediaDeviceCollection() - , m_encodingFormat( OGG ) -{ - DEBUG_BLOCK - // so that `amarok --cdplay` works: - connect( this, SIGNAL(collectionReady(Collections::Collection*)), - SLOT(checkForStartPlayRequest()) ); - - debug() << "Getting Audio CD info"; - AudioCdDeviceInfo *cdInfo = qobject_cast( info ); - m_udi = cdInfo->udi(); - m_device = cdInfo->device(); - - readAudioCdSettings(); - - m_handler = new Meta::AudioCdHandler( this ); -} - - -AudioCdCollection::~AudioCdCollection() -{ -} - - -KUrl -AudioCdCollection::audiocdUrl( const QString &path ) const -{ - KUrl url("audiocd:/"); - url.addPath( path ); - - if( !m_device.isEmpty() ) - url.addQueryItem( "device", m_device ); - - return url; -} - - -void -AudioCdCollection::readCd() -{ - DEBUG_BLOCK - //get the CDDB info file if possible. - KIO::ListJob *listJob = KIO::listRecursive( audiocdUrl(), KIO::HideProgressInfo, false ); - connect( listJob, SIGNAL(entries(KIO::Job*,KIO::UDSEntryList)), - this, SLOT(audioCdEntries(KIO::Job*,KIO::UDSEntryList)) ); - connect( listJob, SIGNAL(result(KJob*)), SLOT(slotEntriesJobDone(KJob*)) ); -} - -void -AudioCdCollection::audioCdEntries( KIO::Job *job, const KIO::UDSEntryList &list ) -{ - DEBUG_BLOCK - Q_UNUSED( job ) - for( KIO::UDSEntryList::ConstIterator it = list.begin(); it != list.end(); ++it ) - { - const KIO::UDSEntry &entry = *it; - QString name = entry.stringValue( KIO::UDSEntry::UDS_NAME ); - if( name.endsWith( QLatin1String(".txt") ) ) - m_cddbTextFiles.insert( entry.numberValue( KIO::UDSEntry::UDS_SIZE ), audiocdUrl( name ) ); - } -} - -void -AudioCdCollection::slotEntriesJobDone( KJob *job ) -{ - DEBUG_BLOCK - if( job->error() ) - warning() << __PRETTY_FUNCTION__ << job->errorString() << job->errorText(); - - if( m_cddbTextFiles.isEmpty() ) - { - warning() << __PRETTY_FUNCTION__ << "haven't found .txt file under audiocd:/, but continuing"; - noInfoAvailable(); - return; - } - - int biggestTextFile = m_cddbTextFiles.keys().last(); - KUrl url = m_cddbTextFiles.value( biggestTextFile ); - m_cddbTextFiles.clear(); // save memory - KIO::StoredTransferJob *tjob = KIO::storedGet( url, KIO::NoReload, KIO::HideProgressInfo ); - connect( tjob, SIGNAL(result(KJob*)), SLOT(infoFetchComplete(KJob*)) ); -} - -void -AudioCdCollection::infoFetchComplete( KJob *job ) -{ - DEBUG_BLOCK - if( job->error() ) - { - error() << job->error() << job->errorString() << job->errorText(); - job->deleteLater(); - noInfoAvailable(); - return; - } - - KIO::StoredTransferJob *tjob = static_cast( job ); - QString cddbInfo = tjob->data(); - - debug() << "got cddb info: " << cddbInfo; - if (cddbInfo.length() == 0) { - job->deleteLater(); - noInfoAvailable(); - return; - } - - int startIndex; - int endIndex; - - QString artist; - QString album; - QString year; - QString genre; - - startIndex = cddbInfo.indexOf( "DTITLE=", 0 ); - if ( startIndex != -1 ) - { - startIndex += 7; - endIndex = cddbInfo.indexOf( "\n", startIndex ); - QString compoundTitle = cddbInfo.mid( startIndex, endIndex - startIndex ); - - debug() << "compoundTitle: " << compoundTitle; - - QStringList compoundTitleList = compoundTitle.split( " / " ); - - artist = compoundTitleList.at( 0 ); - album = compoundTitleList.at( 1 ); - } - - Meta::AudioCdArtistPtr artistPtr = Meta::AudioCdArtistPtr( new Meta::AudioCdArtist( artist ) ); - memoryCollection()->addArtist( Meta::ArtistPtr::staticCast( artistPtr ) ); - Meta::AudioCdComposerPtr composerPtr = Meta::AudioCdComposerPtr( new Meta::AudioCdComposer( QString() ) ); - memoryCollection()->addComposer( Meta::ComposerPtr::staticCast( composerPtr ) ); - Meta::AudioCdAlbumPtr albumPtr = Meta::AudioCdAlbumPtr( new Meta::AudioCdAlbum( album ) ); - albumPtr->setAlbumArtist( artistPtr ); - memoryCollection()->addAlbum( Meta::AlbumPtr::staticCast( albumPtr ) ); - - - startIndex = cddbInfo.indexOf( "DYEAR=", 0 ); - if ( startIndex != -1 ) - { - startIndex += 6; - endIndex = cddbInfo.indexOf( "\n", startIndex ); - year = cddbInfo.mid( startIndex, endIndex - startIndex ); - } - - Meta::AudioCdYearPtr yearPtr = Meta::AudioCdYearPtr( new Meta::AudioCdYear( year ) ); - memoryCollection()->addYear( Meta::YearPtr::staticCast( yearPtr ) ); - - - startIndex = cddbInfo.indexOf( "DGENRE=", 0 ); - if ( startIndex != -1 ) - { - startIndex += 7; - endIndex = cddbInfo.indexOf( "\n", startIndex ); - genre = cddbInfo.mid( startIndex, endIndex - startIndex ); - } - - Meta::AudioCdGenrePtr genrePtr = Meta::AudioCdGenrePtr( new Meta::AudioCdGenre( genre ) ); - memoryCollection()->addGenre( Meta::GenrePtr::staticCast( genrePtr ) ); - - m_discCddbId = unknownCddbId; - - startIndex = cddbInfo.indexOf( "DISCID=", 0 ); - if ( startIndex != -1 ) - { - startIndex += 7; - endIndex = cddbInfo.indexOf( "\n", startIndex ); - m_discCddbId = cddbInfo.mid( startIndex, endIndex - startIndex ); - } - - //MediaDeviceMonitor::instance()->setCurrentCdId( m_discCddbId ); - - //get the list of tracknames - startIndex = cddbInfo.indexOf( "TTITLE0=", 0 ); - if ( startIndex != -1 ) - { - endIndex = cddbInfo.indexOf( "\nEXTD=", startIndex ); - QString tracksBlock = cddbInfo.mid( startIndex, endIndex - startIndex ); - debug() << "Tracks block: " << tracksBlock; - QStringList tracksBlockList = tracksBlock.split( '\n' ); - - int numberOfTracks = tracksBlockList.count(); - - for ( int i = 0; i < numberOfTracks; i++ ) - { - QString prefix = "TTITLE" + QString::number( i ) + '='; - debug() << "prefix: " << prefix; - QString trackName = tracksBlockList.at( i ); - trackName = trackName.remove( prefix ); - - QString trackArtist; - //check if a track artist is included in the track name: - - if ( trackName.contains( " / " ) ) - { - QStringList trackArtistList = trackName.split( " / " ); - trackName = trackArtistList.at( 1 ); - trackArtist = trackArtistList.at( 0 ); - - } - - debug() << "Track name: " << trackName; - - QString padding = (i + 1) < 10 ? "0" : QString(); - - QString baseFileName = m_fileNamePattern; - debug() << "Track Base File Name (before): " << baseFileName; - - baseFileName.replace( "%{title}", trackName, Qt::CaseInsensitive ); - baseFileName.replace( "%{number}", padding + QString::number( i + 1 ), Qt::CaseInsensitive ); - baseFileName.replace( "%{albumtitle}", album, Qt::CaseInsensitive ); - baseFileName.replace( "%{trackartist}", trackArtist, Qt::CaseInsensitive ); - baseFileName.replace( "%{albumartist}", artist, Qt::CaseInsensitive ); - baseFileName.replace( "%{year}", year, Qt::CaseInsensitive ); - baseFileName.replace( "%{genre}", genre, Qt::CaseInsensitive ); - - //we hack the url so the engine controller knows what track on the CD to play.. - KUrl baseUrl = audiocdUrl( m_discCddbId + '/' + QString::number( i + 1 ) ); - - debug() << "Track Base File Name (after): " << baseFileName; - debug() << "Track url: " << baseUrl; - - Meta::AudioCdTrackPtr trackPtr = Meta::AudioCdTrackPtr( new Meta::AudioCdTrack( this, trackName, baseUrl ) ); - - trackPtr->setTrackNumber( i + 1 ); - trackPtr->setFileNameBase( baseFileName ); - trackPtr->setLength( trackLength( i + 1 ) ); - - memoryCollection()->addTrack( Meta::TrackPtr::staticCast( trackPtr ) ); - - artistPtr->addTrack( trackPtr ); - - if ( trackArtist.isEmpty() ) - trackPtr->setArtist( artistPtr ); - else - { - albumPtr->setCompilation( true ); - - Meta::AudioCdArtistPtr trackArtistPtr = Meta::AudioCdArtistPtr( new Meta::AudioCdArtist( trackArtist ) ); - trackArtistPtr->addTrack( trackPtr ); - trackPtr->setArtist( trackArtistPtr ); - } - - composerPtr->addTrack( trackPtr ); - trackPtr->setComposer( composerPtr ); - - albumPtr->addTrack( trackPtr ); - trackPtr->setAlbum( albumPtr ); - - genrePtr->addTrack( trackPtr ); - trackPtr->setGenre( genrePtr ); - - yearPtr->addTrack( trackPtr ); - trackPtr->setYear( yearPtr ); - - } - } - - //lets see if we can find a cover for the album: - if( AmarokConfig::autoGetCoverArt() ) - The::coverFetcher()->queueAlbum( Meta::AlbumPtr::staticCast( albumPtr ) ); - - updateProxyTracks(); - emit collectionReady( this ); -} - -void -AudioCdCollection::checkForStartPlayRequest() -{ - //be nice and check if MainWindow is just aching for an audio cd to start playing - if( The::mainWindow()->isWaitingForCd() ) - { - debug() << "Tell MainWindow to start playing us immediately."; - The::mainWindow()->playAudioCd(); - } -} - -qint64 -AudioCdCollection::trackLength(int i) const -{ - KUrl kioUrl = audiocdUrl( QString("Track%1.wav").arg(i, 2, 10, QChar('0') ) ); - KIO::UDSEntry uds; - if ( KIO::NetAccess::stat(kioUrl, uds, NULL) ) - { - qint64 samples = (uds.numberValue(KIO::UDSEntry::UDS_SIZE, 44) - 44) / 4; - return (samples - 44) * 10 / 441; - } - return 0; -} - -QString -AudioCdCollection::collectionId() const -{ - return QLatin1String( "AudioCd" ); -} - -QString -AudioCdCollection::prettyName() const -{ - return i18n( "Audio CD" ); -} - -KIcon -AudioCdCollection::icon() const -{ - return KIcon( "media-optical-audio" ); -} - -void -AudioCdCollection::cdRemoved() -{ - emit remove(); -} - -QString -AudioCdCollection::encodingFormat() const -{ - switch( m_encodingFormat ) - { - case WAV: - return "wav"; - case FLAC: - return "flac"; - case OGG: - return "ogg"; - case MP3: - return "mp3"; - } - return QString(); -} - -QString -AudioCdCollection::copyableFilePath( const QString &fileName ) const -{ - switch( m_encodingFormat ) - { - case WAV: - return audiocdUrl( fileName ).url(); - case FLAC: - return audiocdUrl( "FLAC/" + fileName ).url(); - case OGG: - return audiocdUrl( "Ogg Vorbis/" + fileName ).url(); - case MP3: - return audiocdUrl( "MP3/" + fileName ).url(); - } - return QString(); -} - -void -AudioCdCollection::setEncodingFormat( int format ) const -{ - m_encodingFormat = format; -} - -CollectionLocation * -AudioCdCollection::location() -{ - return new AudioCdCollectionLocation( this ); -} - -void -AudioCdCollection::eject() -{ - DEBUG_BLOCK - - //we need to do a quick check if we are currently playing from this cd, if so, stop playback and then eject - Meta::TrackPtr track = The::engineController()->currentTrack(); - - if ( track ) - { - if( track->playableUrl().url().startsWith( "audiocd:/" ) ) - The::engineController()->stop(); - } - - Solid::Device device = Solid::Device( m_udi ); - - Solid::OpticalDrive *drive = device.parent().as(); - if( drive ) - drive->eject(); - else - debug() << "disc has no drive"; -} - -void -AudioCdCollection::noInfoAvailable() -{ - DEBUG_BLOCK - - m_discCddbId = unknownCddbId; - - //MediaDeviceMonitor::instance()->setCurrentCdId( m_discCddbId ); - - QString artist = i18n( "Unknown" ); - QString album = i18n( "Unknown" ); - QString year = i18n( "Unknown" ); - QString genre = i18n( "Unknown" ); - - Meta::AudioCdArtistPtr artistPtr = Meta::AudioCdArtistPtr( new Meta::AudioCdArtist( artist ) ); - memoryCollection()->addArtist( Meta::ArtistPtr::staticCast( artistPtr ) ); - Meta::AudioCdComposerPtr composerPtr = Meta::AudioCdComposerPtr( new Meta::AudioCdComposer( QString() ) ); - memoryCollection()->addComposer( Meta::ComposerPtr::staticCast( composerPtr ) ); - Meta::AudioCdAlbumPtr albumPtr = Meta::AudioCdAlbumPtr( new Meta::AudioCdAlbum( album ) ); - albumPtr->setAlbumArtist( artistPtr ); - memoryCollection()->addAlbum( Meta::AlbumPtr::staticCast( albumPtr ) ); - Meta::AudioCdYearPtr yearPtr = Meta::AudioCdYearPtr( new Meta::AudioCdYear( year ) ); - memoryCollection()->addYear( Meta::YearPtr::staticCast( yearPtr ) ); - Meta::AudioCdGenrePtr genrePtr = Meta::AudioCdGenrePtr( new Meta::AudioCdGenre( genre ) ); - memoryCollection()->addGenre( Meta::GenrePtr::staticCast( genrePtr ) ); - - - int i = 1; - QString prefix( "0" ); - QString trackName = "Track " + prefix + QString::number( i ); - - while( KIO::NetAccess::exists( QString( "audiocd:/" + trackName + ".wav" ), KIO::NetAccess::SourceSide, 0 ) ) - { - debug() << "got track: " << "audiocd:/" + trackName + ".wav"; - - QString baseUrl = "audiocd:/" + m_discCddbId + '/' + QString::number( i ); - - Meta::AudioCdTrackPtr trackPtr = Meta::AudioCdTrackPtr( new Meta::AudioCdTrack( this, trackName, baseUrl ) ); - - trackPtr->setTrackNumber( i ); - trackPtr->setFileNameBase( trackName ); - trackPtr->setLength( trackLength( i ) ); - - memoryCollection()->addTrack( Meta::TrackPtr::staticCast( trackPtr ) ); - - artistPtr->addTrack( trackPtr ); - trackPtr->setArtist( artistPtr ); - - composerPtr->addTrack( trackPtr ); - trackPtr->setComposer( composerPtr ); - - albumPtr->addTrack( trackPtr ); - trackPtr->setAlbum( albumPtr ); - - genrePtr->addTrack( trackPtr ); - trackPtr->setGenre( genrePtr ); - - yearPtr->addTrack( trackPtr ); - trackPtr->setYear( yearPtr ); - - i++; - prefix = i < 10 ? "0" : ""; - trackName = "Track " + prefix + QString::number( i ); - } - - updateProxyTracks(); - emit collectionReady( this ); -} - -void -AudioCdCollection::readAudioCdSettings() -{ - KSharedConfigPtr conf = KSharedConfig::openConfig( "kcmaudiocdrc" ); - KConfigGroup filenameConf = conf->group( "FileName" ); - - m_fileNamePattern = filenameConf.readEntry( "file_name_template", "%{trackartist} - %{number} - %{title}" ); - m_albumNamePattern = filenameConf.readEntry( "album_name_template", "%{albumartist} - %{albumtitle}" ); -} - -bool -AudioCdCollection::possiblyContainsTrack( const KUrl &url ) const -{ - return url.protocol() == "audiocd"; -} - -Meta::TrackPtr -AudioCdCollection::trackForUrl( const KUrl &url ) -{ - QReadLocker locker( memoryCollection()->mapLock() ); - if( memoryCollection()->trackMap().contains( url.url() ) ) - return memoryCollection()->trackMap().value( url.url() ); - - QRegExp trackUrlScheme( "^audiocd:/([a-zA-Z0-9]*)/([0-9]{1,})" ); - if( trackUrlScheme.indexIn( url.url() ) != 0 ) - { - warning() << __PRETTY_FUNCTION__ << url.url() << "doesn't have correct scheme" << trackUrlScheme; - return Meta::TrackPtr(); - } - - const QString trackCddbId = trackUrlScheme.capturedTexts().value( 1 ); - const int trackNumber = trackUrlScheme.capturedTexts().value( 2 ).toInt(); - if( !trackCddbId.isEmpty() && trackCddbId != unknownCddbId && - !m_discCddbId.isEmpty() && m_discCddbId != unknownCddbId && - trackCddbId != m_discCddbId ) - { - warning() << __PRETTY_FUNCTION__ << "track with cddbId" << trackCddbId - << "doesn't match our cddbId" << m_discCddbId; - return Meta::TrackPtr(); - } - - foreach( const Meta::TrackPtr &track, memoryCollection()->trackMap() ) - { - if( track->trackNumber() == trackNumber ) - return track; - } - - warning() << __PRETTY_FUNCTION__ << "track with number" << trackNumber << "not found"; - return Meta::TrackPtr(); -} - -void -AudioCdCollection::updateProxyTracks() -{ - foreach( const KUrl &url, m_proxyMap.keys() ) - { - - QString urlString = url.url().remove( "audiocd:/" ); - const QStringList &parts = urlString.split( '/' ); - - if( parts.count() != 2 ) - continue; - - const QString &discId = parts.at( 0 ); - - if( discId != m_discCddbId ) - continue; - - const int trackNumber = parts.at( 1 ).toInt(); - - foreach( const Meta::TrackPtr &track, memoryCollection()->trackMap().values() ) - { - if( track->trackNumber() == trackNumber ) - { - m_proxyMap.value( url )->updateTrack( track ); - } - } - - } - - m_proxyMap.clear(); -} - -void AudioCdCollection::startFullScan() -{ - DEBUG_BLOCK - readCd(); -} diff --git a/amarok/src/core-impl/collections/audiocd/AudioCdCollection.h b/amarok/src/core-impl/collections/audiocd/AudioCdCollection.h deleted file mode 100644 index dc2cad75..00000000 --- a/amarok/src/core-impl/collections/audiocd/AudioCdCollection.h +++ /dev/null @@ -1,134 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AUDIOCDCOLLECTION_H -#define AUDIOCDCOLLECTION_H - -#include "core/collections/Collection.h" -#include "MediaDeviceCollection.h" -#include "MemoryCollection.h" -#include "core-impl/meta/proxy/MetaProxy.h" - -#include - -#include -#include - -class MediaDeviceInfo; - -namespace Collections { - -class AudioCdCollection; - -class AudioCdCollectionFactory : public MediaDeviceCollectionFactory -{ - Q_OBJECT -public: - AudioCdCollectionFactory( QObject *parent, const QVariantList &args ); - virtual ~AudioCdCollectionFactory() {}; - -/* virtual void init(); - -private slots: - void audioCdAdded( const QString &uid ); - void deviceRemoved( const QString &uid ); - -private: - - QString m_currentUid; - AudioCdCollection * m_collection;*/ - -}; - - -/** - * This is a Memorycollection sublclass that uses the KIO audiocd:/ slave to - * populate itself whenever it detects a CD. - * - * @author Nikolaj Hald Nielsen - */ -class AudioCdCollection : public MediaDeviceCollection -{ - Q_OBJECT -public: - - enum { WAV, FLAC, OGG, MP3 } EncodingFormat; - - AudioCdCollection( MediaDeviceInfo* info ); - ~AudioCdCollection(); - - QString encodingFormat() const; - QString copyableFilePath( const QString &fileName ) const; - - void setEncodingFormat( int format ) const; - - virtual QString collectionId() const; - virtual QString prettyName() const; - virtual KIcon icon() const; - - virtual CollectionLocation* location(); - - virtual bool possiblyContainsTrack( const KUrl &url ) const; - virtual Meta::TrackPtr trackForUrl( const KUrl &url ); - - void cdRemoved(); - - virtual void startFullScan(); //Override this one as I really don't want to move parsing to the handler atm. - virtual void startFullScanDevice() { startFullScan(); } - -public slots: - virtual void eject(); - -private slots: - void audioCdEntries( KIO::Job *job, const KIO::UDSEntryList &list ); - void slotEntriesJobDone( KJob *job ); - void infoFetchComplete( KJob *job ); - void checkForStartPlayRequest(); - -private: - void readAudioCdSettings(); - - // Helper function to build the audiocd url. - KUrl audiocdUrl( const QString &path = "" ) const; - qint64 trackLength( int i ) const; - - /** - * Clear collection and read the CD currently in the drive, adding Artist, Album, - * Genre, Year and whatnot as detected by audiocd using CDDB. - */ - void readCd(); - - void noInfoAvailable(); - - void updateProxyTracks(); - - QMap m_cddbTextFiles; - - QString m_cdName; - QString m_discCddbId; - QString m_udi; - QString m_device; - mutable int m_encodingFormat; - - QString m_fileNamePattern; - QString m_albumNamePattern; - - QMap m_proxyMap; -}; - -} //namespace Collections - -#endif diff --git a/amarok/src/core-impl/collections/audiocd/AudioCdCollectionLocation.cpp b/amarok/src/core-impl/collections/audiocd/AudioCdCollectionLocation.cpp deleted file mode 100644 index 35fa5e34..00000000 --- a/amarok/src/core-impl/collections/audiocd/AudioCdCollectionLocation.cpp +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "AudioCdCollectionLocation.h" - -#include "AudioCdMeta.h" -#include "core/support/Debug.h" -#include "FormatSelectionDialog.h" - -using namespace Collections; - -AudioCdCollectionLocation::AudioCdCollectionLocation( AudioCdCollection *parentCollection ) - : CollectionLocation( parentCollection ) - , m_collection( parentCollection ) -{ -} - - -AudioCdCollectionLocation::~AudioCdCollectionLocation() -{ -} - -void AudioCdCollectionLocation::getKIOCopyableUrls( const Meta::TrackList & tracks ) -{ - DEBUG_BLOCK - - QMap resultMap; - foreach( Meta::TrackPtr trackPtr, tracks ) - { - Meta::AudioCdTrackPtr cdTrack = Meta::AudioCdTrackPtr::staticCast( trackPtr ); - - const QString path = m_collection->copyableFilePath( cdTrack->fileNameBase() + '.' + m_collection->encodingFormat() ); - resultMap.insert( trackPtr, KUrl( path ) ); - } - - slotGetKIOCopyableUrlsDone( resultMap ); -} - -void AudioCdCollectionLocation::showSourceDialog( const Meta::TrackList &tracks, bool removeSources ) -{ - DEBUG_BLOCK - Q_UNUSED( tracks ) - Q_UNUSED( removeSources ) - FormatSelectionDialog * dlg = new FormatSelectionDialog(); - - connect( dlg, SIGNAL(formatSelected(int)), this, SLOT(onFormatSelected(int)) ); - connect( dlg, SIGNAL(rejected()), this, SLOT(onCancel()) ); - - dlg->show(); -} - -void AudioCdCollectionLocation::formatSelected( int format ) -{ - Q_UNUSED( format ) -} - -void AudioCdCollectionLocation::formatSelectionCancelled() -{ -} - -void AudioCdCollectionLocation::onFormatSelected( int format ) -{ - DEBUG_BLOCK - m_collection->setEncodingFormat( format ); - slotShowSourceDialogDone(); -} - -void AudioCdCollectionLocation::onCancel() -{ - DEBUG_BLOCK - abort(); -} - - -#include "moc_AudioCdCollectionLocation.cpp" - - diff --git a/amarok/src/core-impl/collections/audiocd/AudioCdCollectionLocation.h b/amarok/src/core-impl/collections/audiocd/AudioCdCollectionLocation.h deleted file mode 100644 index f6ca3b83..00000000 --- a/amarok/src/core-impl/collections/audiocd/AudioCdCollectionLocation.h +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AUDIOCDCOLLECTIONLOCATION_H -#define AUDIOCDCOLLECTIONLOCATION_H - -#include "core/collections/CollectionLocation.h" - -#include "AudioCdCollection.h" - -namespace Collections { - -/** -A custom CollectionLocation handling the encoding file type and so on for AudioCd collections - - @author Nikolaj Hald Nielsen -*/ -class AudioCdCollectionLocation : public CollectionLocation -{ - Q_OBJECT -public: - AudioCdCollectionLocation( AudioCdCollection *parentCollection ); - ~AudioCdCollectionLocation(); - - virtual void getKIOCopyableUrls( const Meta::TrackList &tracks ); - - virtual void showSourceDialog( const Meta::TrackList &tracks, bool removeSources ); - -private slots: - void formatSelected( int format ); - void formatSelectionCancelled(); - - void onFormatSelected( int format ); - void onCancel(); - -private: - AudioCdCollection *m_collection; -}; - -} //namespace Collections - -#endif diff --git a/amarok/src/core-impl/collections/audiocd/AudioCdMeta.cpp b/amarok/src/core-impl/collections/audiocd/AudioCdMeta.cpp deleted file mode 100644 index 6007e871..00000000 --- a/amarok/src/core-impl/collections/audiocd/AudioCdMeta.cpp +++ /dev/null @@ -1,484 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Maximilian Kossick * - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "AudioCdMeta.h" -#include "AudioCdCollection.h" - -#include "core/support/Debug.h" -#include "covermanager/CoverCache.h" - -using namespace Meta; - -AudioCdTrack::AudioCdTrack( Collections::AudioCdCollection *collection, const QString &name, const KUrl &url ) - : Meta::Track() - , m_collection( collection ) - , m_artist( 0 ) - , m_album( 0 ) - , m_genre( 0 ) - , m_composer( 0 ) - , m_year( 0 ) - , m_name( name) - , m_length( 0 ) - , m_trackNumber( 0 ) - , m_playableUrl( url ) -{ -} - -AudioCdTrack::~AudioCdTrack() -{ - //nothing to do -} - -QString -AudioCdTrack::name() const -{ - return m_name; -} - -KUrl -AudioCdTrack::playableUrl() const -{ - return m_playableUrl; -} - -QString -AudioCdTrack::uidUrl() const -{ - return m_playableUrl.url(); -} - -QString -AudioCdTrack::prettyUrl() const -{ - return m_playableUrl.prettyUrl(); -} - -QString -AudioCdTrack::notPlayableReason() const -{ - //TODO: check availablity of correct CD somehow - return QString(); -} - -AlbumPtr -AudioCdTrack::album() const -{ - return AlbumPtr::staticCast( m_album ); -} - -ArtistPtr -AudioCdTrack::artist() const -{ - return ArtistPtr::staticCast( m_artist ); -} - -GenrePtr -AudioCdTrack::genre() const -{ - return GenrePtr::staticCast( m_genre ); -} - -ComposerPtr -AudioCdTrack::composer() const -{ - return ComposerPtr::staticCast( m_composer ); -} - -YearPtr -AudioCdTrack::year() const -{ - return YearPtr::staticCast( m_year ); -} - -qreal -AudioCdTrack::bpm() const -{ - return -1.0; -} - -QString -AudioCdTrack::comment() const -{ - return QString(); -} - -void -AudioCdTrack::setComment( const QString &newComment ) -{ - Q_UNUSED( newComment ) -} - -qint64 -AudioCdTrack::length() const -{ - return m_length; -} - -int -AudioCdTrack::filesize() const -{ - return 0; -} - -int -AudioCdTrack::sampleRate() const -{ - return 0; -} - -int -AudioCdTrack::bitrate() const -{ - return 0; -} - -int -AudioCdTrack::trackNumber() const -{ - return m_trackNumber; -} - -void -AudioCdTrack::setTrackNumber( int newTrackNumber ) -{ - m_trackNumber = newTrackNumber; -} - -int -AudioCdTrack::discNumber() const -{ - return 0; -} - -void -AudioCdTrack::setDiscNumber( int newDiscNumber ) -{ - Q_UNUSED( newDiscNumber ) -} - -QString -AudioCdTrack::type() const -{ - return m_collection->encodingFormat(); -} - -bool -AudioCdTrack::inCollection() const -{ - return true; -} - -Collections::Collection* -AudioCdTrack::collection() const -{ - return m_collection; -} - -void -AudioCdTrack::setAlbum( AudioCdAlbumPtr album ) -{ - m_album = album; -} - -void -AudioCdTrack::setArtist( AudioCdArtistPtr artist ) -{ - m_artist = artist; -} - -void -AudioCdTrack::setGenre( AudioCdGenrePtr genre ) -{ - m_genre = genre; -} - -void -AudioCdTrack::setComposer( AudioCdComposerPtr composer ) -{ - m_composer = composer; -} - -void -AudioCdTrack::setYear( AudioCdYearPtr year ) -{ - m_year = year; -} - -void -AudioCdTrack::setTitle( const QString &title ) -{ - m_name = title; -} - -void -AudioCdTrack::setLength( qint64 length ) -{ - m_length = length; -} - -void Meta::AudioCdTrack::setFileNameBase( const QString & fileNameBase ) -{ - m_fileNameBase = fileNameBase; -} - -QString Meta::AudioCdTrack::fileNameBase() -{ - return m_fileNameBase; -} - - -//AudioCdArtist - -AudioCdArtist::AudioCdArtist( const QString &name ) - : Meta::Artist() - , m_name( name ) - , m_tracks() -{ - //nothing to do -} - -AudioCdArtist::~AudioCdArtist() -{ - //nothing to do -} - -QString -AudioCdArtist::name() const -{ - return m_name; -} - -TrackList -AudioCdArtist::tracks() -{ - return m_tracks; -} - -AlbumList -AudioCdArtist::albums() -{ - //TODO - return AlbumList(); -} - -void -AudioCdArtist::addTrack( AudioCdTrackPtr track ) -{ - m_tracks.append( TrackPtr::staticCast( track ) ); -} - -AudioCdAlbum::AudioCdAlbum( const QString &name ) - : Meta::Album() - , m_name( name ) - , m_tracks() - , m_isCompilation( false ) - , m_albumArtist( 0 ) -{ - //nothing to do -} - -AudioCdAlbum::~AudioCdAlbum() -{ - CoverCache::invalidateAlbum( this ); -} - -QString -AudioCdAlbum::name() const -{ - return m_name; -} - -bool -AudioCdAlbum::isCompilation() const -{ - return m_isCompilation; -} - -bool -AudioCdAlbum::canUpdateCompilation() const -{ - return true; -} - -void -AudioCdAlbum::setCompilation( bool compilation ) -{ - m_isCompilation = compilation; -} - -bool -AudioCdAlbum::hasAlbumArtist() const -{ - return !m_albumArtist.isNull(); -} - -ArtistPtr -AudioCdAlbum::albumArtist() const -{ - return ArtistPtr::staticCast( m_albumArtist ); -} - -TrackList -AudioCdAlbum::tracks() -{ - return m_tracks; -} - -QImage -AudioCdAlbum::image( int size ) const -{ - if ( m_cover.isNull() ) - return Meta::Album::image( size ); - else - return m_cover.scaled( size, size, Qt::KeepAspectRatio, Qt::SmoothTransformation ); -} - -bool -AudioCdAlbum::hasImage( int size ) const -{ - if ( m_cover.isNull() ) - return Meta::Album::hasImage( size ); - else - return true; -} - -bool -AudioCdAlbum::canUpdateImage() const -{ - return false; -} - -void -AudioCdAlbum::setImage( const QImage &image ) -{ - m_cover = image; - CoverCache::invalidateAlbum( this ); -} - -void -AudioCdAlbum::addTrack( AudioCdTrackPtr track ) -{ - m_tracks.append( TrackPtr::staticCast( track ) ); -} - -void -AudioCdAlbum::setAlbumArtist( AudioCdArtistPtr artist ) -{ - m_albumArtist = artist; -} - -//AudioCdGenre - -AudioCdGenre::AudioCdGenre( const QString &name ) - : Meta::Genre() - , m_name( name ) - , m_tracks() -{ - //nothing to do -} - -AudioCdGenre::~AudioCdGenre() -{ - //nothing to do -} - -QString -AudioCdGenre::name() const -{ - return m_name; -} - -TrackList -AudioCdGenre::tracks() -{ - return m_tracks; -} - -void -AudioCdGenre::addTrack( AudioCdTrackPtr track ) -{ - m_tracks.append( TrackPtr::staticCast( track ) ); -} - -//AudioCdComposer - -AudioCdComposer::AudioCdComposer( const QString &name ) - : Meta::Composer() - , m_name( name ) - , m_tracks() -{ - //nothing to do -} - -AudioCdComposer::~AudioCdComposer() -{ - //nothing to do -} - -QString -AudioCdComposer::name() const -{ - return m_name; -} - -TrackList -AudioCdComposer::tracks() -{ - return m_tracks; -} - -void -AudioCdComposer::addTrack( AudioCdTrackPtr track ) -{ - m_tracks.append( TrackPtr::staticCast( track ) ); -} - -//AudioCdYear - -AudioCdYear::AudioCdYear( const QString &name ) - : Meta::Year() - , m_name( name ) - , m_tracks() -{ - //nothing to do -} - -AudioCdYear::~AudioCdYear() -{ - //nothing to do -} - -QString -AudioCdYear::name() const -{ - return m_name; -} - -TrackList -AudioCdYear::tracks() -{ - return m_tracks; -} - -void -AudioCdYear::addTrack( AudioCdTrackPtr track ) -{ - m_tracks.append( TrackPtr::staticCast( track ) ); -} - - - diff --git a/amarok/src/core-impl/collections/audiocd/AudioCdMeta.h b/amarok/src/core-impl/collections/audiocd/AudioCdMeta.h deleted file mode 100644 index af1f766a..00000000 --- a/amarok/src/core-impl/collections/audiocd/AudioCdMeta.h +++ /dev/null @@ -1,225 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Maximilian Kossick * - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AUDIOCDMETA_H -#define AUDIOCDMETA_H - -#include "core/meta/Meta.h" - -namespace Collections { - class AudioCdCollection; -} - -namespace Meta -{ - -class AudioCdTrack; -class AudioCdAlbum; -class AudioCdArtist; -class AudioCdGenre; -class AudioCdComposer; -class AudioCdYear; - -typedef KSharedPtr AudioCdTrackPtr; -typedef KSharedPtr AudioCdArtistPtr; -typedef KSharedPtr AudioCdAlbumPtr; -typedef KSharedPtr AudioCdGenrePtr; -typedef KSharedPtr AudioCdComposerPtr; -typedef KSharedPtr AudioCdYearPtr; - -class AudioCdTrack : public Meta::Track -{ - public: - AudioCdTrack( Collections::AudioCdCollection *collection, const QString &name, const KUrl &url ); - virtual ~AudioCdTrack(); - - virtual QString name() const; - - virtual KUrl playableUrl() const; - virtual QString uidUrl() const; - virtual QString prettyUrl() const; - virtual QString notPlayableReason() const; - - virtual AlbumPtr album() const; - virtual ArtistPtr artist() const; - virtual GenrePtr genre() const; - virtual ComposerPtr composer() const; - virtual YearPtr year() const; - - virtual void setTitle( const QString &newTitle ); - - virtual qreal bpm() const; - - virtual QString comment() const; - virtual void setComment ( const QString &newComment ); - - virtual qint64 length() const; - - virtual int filesize() const; - virtual int sampleRate() const; - virtual int bitrate() const; - - virtual int trackNumber() const; - virtual void setTrackNumber ( int newTrackNumber ); - - virtual int discNumber() const; - virtual void setDiscNumber ( int newDiscNumber ); - - virtual QString type() const; - - virtual bool inCollection() const; - virtual Collections::Collection* collection() const; - - //AudioCdTrack specific methods - void setAlbum( AudioCdAlbumPtr album ); - void setArtist( AudioCdArtistPtr artist ); - void setComposer( AudioCdComposerPtr composer ); - void setGenre( AudioCdGenrePtr genre ); - void setYear( AudioCdYearPtr year ); - - void setLength( qint64 length ); - - void setFileNameBase( const QString &fileNameBase ); - QString fileNameBase(); - - private: - Collections::AudioCdCollection *m_collection; - - AudioCdArtistPtr m_artist; - AudioCdAlbumPtr m_album; - AudioCdGenrePtr m_genre; - AudioCdComposerPtr m_composer; - AudioCdYearPtr m_year; - - QString m_name; - qint64 m_length; - int m_trackNumber; - KUrl m_playableUrl; - QString m_fileNameBase; -}; - -class AudioCdArtist : public Meta::Artist -{ - public: - AudioCdArtist( const QString &name ); - virtual ~AudioCdArtist(); - - virtual QString name() const; - - virtual TrackList tracks(); - - virtual AlbumList albums(); - - //AudioCdArtist specific methods - void addTrack( AudioCdTrackPtr track ); - - private: - QString m_name; - TrackList m_tracks; -}; - -class AudioCdAlbum : public Meta::Album -{ - public: - AudioCdAlbum( const QString &name ); - virtual ~AudioCdAlbum(); - - virtual QString name() const; - - virtual bool isCompilation() const; - virtual bool canUpdateCompilation() const; - virtual void setCompilation( bool compilation ); - - virtual bool hasAlbumArtist() const; - virtual ArtistPtr albumArtist() const; - virtual TrackList tracks(); - - virtual QImage image( int size = 0 ) const; - virtual bool hasImage( int size = 0 ) const; - virtual bool canUpdateImage() const; - virtual void setImage( const QImage &image ); - - //AudioCdAlbum specific methods - void addTrack( AudioCdTrackPtr track ); - void setAlbumArtist( AudioCdArtistPtr artist ); - - private: - QString m_name; - TrackList m_tracks; - bool m_isCompilation; - AudioCdArtistPtr m_albumArtist; - QImage m_cover; -}; - -class AudioCdGenre : public Meta::Genre -{ - public: - AudioCdGenre( const QString &name ); - virtual ~AudioCdGenre(); - - virtual QString name() const; - - virtual TrackList tracks(); - - //AudioCdGenre specific methods - void addTrack( AudioCdTrackPtr track ); - - private: - QString m_name; - TrackList m_tracks; -}; - -class AudioCdComposer : public Meta::Composer -{ - public: - AudioCdComposer( const QString &name ); - virtual ~AudioCdComposer(); - - virtual QString name() const; - - virtual TrackList tracks(); - - //AudioCdComposer specific methods - void addTrack( AudioCdTrackPtr track ); - - private: - QString m_name; - TrackList m_tracks; -}; - -class AudioCdYear : public Meta::Year -{ - public: - AudioCdYear( const QString &name ); - virtual ~AudioCdYear(); - - virtual QString name() const; - - virtual TrackList tracks(); - - //AudioCdYear specific methods - void addTrack( AudioCdTrackPtr track ); - - private: - QString m_name; - TrackList m_tracks; -}; - -} - -#endif - diff --git a/amarok/src/core-impl/collections/audiocd/CMakeLists.txt b/amarok/src/core-impl/collections/audiocd/CMakeLists.txt deleted file mode 100644 index d555b155..00000000 --- a/amarok/src/core-impl/collections/audiocd/CMakeLists.txt +++ /dev/null @@ -1,48 +0,0 @@ -include_directories( ../.. - ../../collections - ../mediadevicecollection - ../mediadevicecollection/support - ../mediadevicecollection/handler - ../mediadevicecollection/podcast - ${CMAKE_BINARY_DIR}/src - ${AMAROK_COLLECTION_SUPPORT_DIR} - ${KDE4_INCLUDE_DIR} - ${QT_INCLUDES} -) - - -########### next target ############### - -set(amarok_collection-audiocdcollection_PART_SRCS - AudioCdCollection.cpp - AudioCdMeta.cpp - AudioCdCollectionLocation.cpp - FormatSelectionDialog.cpp - handler/AudioCdHandler.cpp - support/AudioCdDeviceInfo.cpp - support/AudioCdConnectionAssistant.cpp - FormatSelectionDialog.ui -) - -kde4_add_plugin(amarok_collection-audiocdcollection ${amarok_collection-audiocdcollection_PART_SRCS}) - -target_link_libraries( - amarok_collection-audiocdcollection - amarokcore - amaroklib - ${KDE4_THREADWEAVER_LIBS} - ${KDE4_KIO_LIBS} - ${KDE4_KUTILS_LIBS} - ${KDE4_SOLID_LIBRARY} -) - -if(APPLE) - SET_TARGET_PROPERTIES(amarok_collection-audiocdcollection PROPERTIES LINK_FLAGS "-undefined dynamic_lookup") -endif(APPLE) - -install(TARGETS amarok_collection-audiocdcollection DESTINATION ${PLUGIN_INSTALL_DIR} ) - - -########### install files ############### - -install( FILES amarok_collection-audiocdcollection.desktop DESTINATION ${SERVICES_INSTALL_DIR}) diff --git a/amarok/src/core-impl/collections/audiocd/FormatSelectionDialog.cpp b/amarok/src/core-impl/collections/audiocd/FormatSelectionDialog.cpp deleted file mode 100644 index 1a8aa77d..00000000 --- a/amarok/src/core-impl/collections/audiocd/FormatSelectionDialog.cpp +++ /dev/null @@ -1,121 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "FormatSelectionDialog.h" - -#include "AudioCdCollection.h" - -#include - -FormatSelectionDialog::FormatSelectionDialog( QWidget *parent ) - : QDialog( parent ) -{ - setupUi( this ); - - connect( oggButton, SIGNAL(toggled(bool)), this, SLOT(selectionChanged(bool)) ); - connect( flacButton, SIGNAL(toggled(bool)), this, SLOT(selectionChanged(bool)) ); - connect( wavButton, SIGNAL(toggled(bool)), this, SLOT(selectionChanged(bool)) ); - connect( mp3Button, SIGNAL(toggled(bool)), this, SLOT(selectionChanged(bool)) ); - - connect( advancedButton, SIGNAL(clicked(bool)), this, SLOT(showAdvancedSettings()) ); - - - //restore format from last time, if any. - KConfigGroup config = Amarok::config("Audio CD Collection"); - QString format = config.readEntry( "Import Format", "ogg" ); - - if ( format.compare( "ogg", Qt::CaseInsensitive ) == 0 ) - oggButton->setChecked( true ); - else if ( format.compare( "flac", Qt::CaseInsensitive ) == 0 ) - flacButton->setChecked( true ); - else if ( format.compare( "wav", Qt::CaseInsensitive ) == 0 ) - wavButton->setChecked( true ); - else if ( format.compare( "mp3", Qt::CaseInsensitive ) == 0 ) - mp3Button->setChecked( true ); -} - - -FormatSelectionDialog::~FormatSelectionDialog() -{ -} - -void FormatSelectionDialog::selectionChanged( bool checked ) -{ - if ( !checked ) - return; - - if( sender() == oggButton ) - { - descriptionLabel->setText( i18n( "Ogg Vorbis is a fully free and unencumbered compressed audio format that is perfect for storing your compressed music on your computer. The sound quality is slightly better than MP3 at the same bitrate. Note that not all mobile players support the Ogg Vorbis format." ) ); - - m_selectedFormat = Collections::AudioCdCollection::OGG; - } - else if( sender() == flacButton ) - { - descriptionLabel->setText( i18n( "FLAC is a lossless compressed audio format free of any patents or license fees. It maintains perfect CD audio quality while reducing file size by about 50%. Because the filesize is much larger than Ogg Vorbis or MP3 it is not recommended if you want to transfer your music to a mobile player." ) ); - - m_selectedFormat = Collections::AudioCdCollection::FLAC; - } - else if( sender() == wavButton ) - { - descriptionLabel->setText( i18n( "WAV is a basic, uncompressed audio file format. It takes up a lot of space but maintains perfect quality. It is generally not recommended unless you know what you are doing. If you want perfect quality, use FLAC instead." ) ); - - m_selectedFormat = Collections::AudioCdCollection::WAV; - } - else if( sender() == mp3Button ) - { - descriptionLabel->setText( i18n( "MP3 is the de facto standard in compressed audio compatible with almost all mobile players. It is however non free and generally not recommended." ) ); - - m_selectedFormat = Collections::AudioCdCollection::MP3; - } - -} - -void FormatSelectionDialog::accept() -{ - - //store to config for next download: - - QString format; - - if( m_selectedFormat == Collections::AudioCdCollection::OGG ) - format = "ogg"; - else if( m_selectedFormat == Collections::AudioCdCollection::FLAC ) - format = "flac"; - else if( m_selectedFormat == Collections::AudioCdCollection::WAV ) - format = "wav"; - else if( m_selectedFormat == Collections::AudioCdCollection::MP3 ) - format = "mp3"; - - KConfigGroup config = Amarok::config("Audio CD Collection"); - config.writeEntry( "Import Format", format ); - - emit formatSelected( m_selectedFormat ); - QDialog::accept(); -} - -void FormatSelectionDialog::showAdvancedSettings() -{ - KCMultiDialog KCM; - KCM.setWindowTitle( i18n( "Audio CD settings - Amarok" ) ); - KCM.addModule( "audiocd" ); - - KCM.exec(); -} - - -#include "moc_FormatSelectionDialog.cpp" - diff --git a/amarok/src/core-impl/collections/audiocd/FormatSelectionDialog.h b/amarok/src/core-impl/collections/audiocd/FormatSelectionDialog.h deleted file mode 100644 index 0d353ef4..00000000 --- a/amarok/src/core-impl/collections/audiocd/FormatSelectionDialog.h +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef FORMATSELECTIONDIALOG_H -#define FORMATSELECTIONDIALOG_H - -#include - -#include "ui_FormatSelectionDialog.h" - -/** -A dialog for selecting the format of of tracks imported from a AudioCdCollection - - @author -*/ -class FormatSelectionDialog - : public QDialog - , private Ui::FormatSelectionDialog -{ - Q_OBJECT -public: - FormatSelectionDialog( QWidget *parent = 0 ); - - ~FormatSelectionDialog(); - -public slots: - virtual void accept(); - - virtual void showAdvancedSettings(); - -signals: - void formatSelected( int ); - -private slots: - void selectionChanged( bool checked ); - -private: - int m_selectedFormat; - -}; - -#endif diff --git a/amarok/src/core-impl/collections/audiocd/FormatSelectionDialog.ui b/amarok/src/core-impl/collections/audiocd/FormatSelectionDialog.ui deleted file mode 100644 index 5cdebead..00000000 --- a/amarok/src/core-impl/collections/audiocd/FormatSelectionDialog.ui +++ /dev/null @@ -1,133 +0,0 @@ - - - FormatSelectionDialog - - - - 0 - 0 - 484 - 347 - - - - Amarok - - - - - - - 0 - 0 - - - - Available formats - - - - - - Ogg Vorbis - - - - - - - FLAC - - - - - - - Wav - - - - - - - MP3 - - - - - - - - - - Description - - - - - - - - - true - - - - - - - - - - Advanced - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - - buttonBox - accepted() - FormatSelectionDialog - accept() - - - 222 - 275 - - - 157 - 274 - - - - - buttonBox - rejected() - FormatSelectionDialog - reject() - - - 290 - 281 - - - 286 - 274 - - - - - diff --git a/amarok/src/core-impl/collections/audiocd/amarok_collection-audiocdcollection.desktop b/amarok/src/core-impl/collections/audiocd/amarok_collection-audiocdcollection.desktop deleted file mode 100644 index 66f2c3ef..00000000 --- a/amarok/src/core-impl/collections/audiocd/amarok_collection-audiocdcollection.desktop +++ /dev/null @@ -1,124 +0,0 @@ -[Desktop Entry] -Type=Service -Icon=media-optical-audio -Name=AudioCd Collection -Name[bg]=Колекция с компактдискове -Name[bs]=Zbirka Audio CD-ova -Name[ca]=Col·lecció de CD d'àudio -Name[ca@valencia]=Col·lecció de CD d'àudio -Name[cs]=Sbírka AudioCD -Name[csb]=Kòlekcëjô AudioCd -Name[da]=Lyd-cd-samling -Name[de]=Audio-CD-Sammlung -Name[el]=Συλλογή AudioCd -Name[en_GB]=AudioCd Collection -Name[es]=Colección de Cd de audio -Name[et]=Heli-CD kogu -Name[eu]=Audio CDen bilduma -Name[fi]=Musiikki-CD-kokoelma -Name[fr]=Collection de CD audio -Name[ga]=Bailiúchán AudioCd -Name[gl]=Colección de CD de son -Name[hu]=Hang-CD-gyűjtemény -Name[id]=Koleksi AudioCD -Name[is]=AudioCd safn -Name[it]=Collezione CD audio -Name[ja]=オーディオ CD コレクション -Name[km]=សម្រាំង​ស៊ីឌី​អូឌីយ៉ូ -Name[ko]=오디오 CD 모음집 -Name[lt]=Garso CD fonoteka -Name[lv]=AudioCd kolekcija -Name[nb]=LydCD-samling -Name[nds]=Klang-CD-Sammeln -Name[nl]=Audio-cd-verzameling -Name[nn]=Lyd-CD-samling -Name[pa]=ਆਡੀਓਸੀਡੀ ਭੰਡਾਰ -Name[pl]=Zbiór audioCD -Name[pt]=Colecção de CD's Áudio -Name[pt_BR]=Coleção de CDs de áudio -Name[ro]=Colecție AudioCd -Name[ru]=Коллекция AudioCD -Name[sk]=AudioCD kolekcia -Name[sl]=Zbirka glasbenega CD-ja -Name[sr]=Аудио ЦД збирка -Name[sr@ijekavian]=Аудио ЦД збирка -Name[sr@ijekavianlatin]=Audio CD zbirka -Name[sr@latin]=Audio CD zbirka -Name[sv]=Musik cd-samling -Name[th]=คลังสื่อของแผ่นซีดีเสียง -Name[tr]=AudioCd Koleksiyonu -Name[uk]=Збірка звукових КД -Name[wa]=Ramexhnêye di plakes lazer odio -Name[x-test]=xxAudioCd Collectionxx -Name[zh_CN]=音频 CD 收藏 -Name[zh_TW]=音效 CD 收藏 -Comment=AudioCd collection plugin for Amarok -Comment[bg]=Приставка за колекция с компактдискове (Amarok) -Comment[bs]=Priključak audio CD zbirke za Amarok -Comment[ca]=Connector de col·leccions de CD d'àudio per a l'Amarok -Comment[ca@valencia]=Connector de col·leccions de CD d'àudio per a l'Amarok -Comment[cs]=Modul sbírky AudioCd pro Amarok -Comment[csb]=Wtëkôcz kòlekcëji AudioCd dlô Amaroka -Comment[da]=Plugin til lyd-cd-samling til Amarok -Comment[de]=Audio-CD-Sammlungsmodul für Amarok -Comment[el]=Πρόσθετο συλλογής AudioCd για το AmaroK -Comment[en_GB]=AudioCd collection plugin for Amarok -Comment[es]=Complemento de colección de Cd de audio para Amarok -Comment[et]=Amaroki heli-CD kogu plugin -Comment[eu]=Audio CDen bildumen plugina Amarok-entzako -Comment[fi]=Musiikki-CD-kokoelmaliitännäinen -Comment[fr]=Module externe de collections de CD audio pour Amarok -Comment[ga]=Breiseán bailiúcháin AudioCd le haghaidh Amarok -Comment[gl]=Engadido de colección de CD de son para Amarok -Comment[hu]=Hang-CD-gyűjteményt megvalósító bővítőmodul az Amarokhoz -Comment[id]=Plugin koleksi AudioCD untuk Amarok -Comment[is]=AudioCd safníforrit fyrir Amarok -Comment[it]=Estensione CD audio della collezione di Amarok -Comment[ja]=Amarok の オーディオ CD コレクションプラグイン -Comment[km]=កម្មវិធី​ជំនួយ​សម្រាំង​ស៊ីឌី​អូឌីយ៉ូ​​សម្រាប់ Amarok -Comment[ko]=Amarok의 오디오 CD 모음집 플러그인 -Comment[lt]=Garso CD fonotekos Amarok papildinys -Comment[lv]=AudioCd kolekcijas Amarok spraudnis -Comment[nb]=LydCD-samling programtillegg for Amarok -Comment[nds]=Klang-CD-Sammelnmoduul för Amarok -Comment[nl]=Plugin voor audio-cd-verzameling voor Amarok -Comment[nn]=Amarok-samlingstillegg for lyd-CD-ar -Comment[pa]=ਅਮਰੋਕ ਲਈ ਆਡੀਓਸੀਡੀ ਭੰਡਾਰ ਪਲੱਗਇਨ -Comment[pl]=Wtyczka kolekcji audioCD dla Amaroka -Comment[pt]=Um 'plugin' da colecção de CD's de áudio para o Amarok -Comment[pt_BR]=Plugin de coleção de CDs de áudio para o Amarok -Comment[ro]=Modul de colecție AudioCd pentru Amarok -Comment[ru]=Модуль коллекции AudioCD для Amarok -Comment[sk]=Modul AudioCD kolekcia pre Amarok -Comment[sl]=Vstavek za zbirko glasbenega CD-ja za Amarok -Comment[sr]=Прикључак аудио ЦД збирке за Амарок -Comment[sr@ijekavian]=Прикључак аудио ЦД збирке за Амарок -Comment[sr@ijekavianlatin]=Priključak audio CD zbirke za Amarok -Comment[sr@latin]=Priključak audio CD zbirke za Amarok -Comment[sv]=Insticksprogram med musik cd-samling för Amarok -Comment[th]=ส่วนเสริมของแอมอะร็อก สำหรับจัดการคลังสื่อของแผ่นซีดีเสียง -Comment[tr]=Amarok için AudioCd koleksiyon eklentisi -Comment[uk]=Додаток збірки звукових КД для Amarok -Comment[wa]=Tchôke-divins di ramexhnêye d' plakes lazer odio po Amarok -Comment[x-test]=xxAudioCd collection plugin for Amarokxx -Comment[zh_CN]=Amarok 的音频 CD 收藏插件 -Comment[zh_TW]=Amarok 的音效 CD 收藏外掛程式 - -ServiceTypes=Amarok/Plugin - -X-KDE-Amarok-authors=Nikolaj Hald Nielsen -X-KDE-Amarok-email=nhnFreespirit@gmail.com -X-KDE-Amarok-framework-version=72 -X-KDE-Amarok-name=audiocd-collection -X-KDE-Amarok-plugintype=collection -X-KDE-Amarok-rank=100 -X-KDE-Amarok-version=1 - -X-KDE-PluginInfo-Author=Nikolaja Hald Nielsen -X-KDE-PluginInfo-Email=nhnFreespirit@gmail.com -X-KDE-PluginInfo-Version=1.0 -X-KDE-PluginInfo-Category=Collection -X-KDE-PluginInfo-License=GPL -X-KDE-PluginInfo-EnabledByDefault=true -X-KDE-PluginInfo-Name=amarok_collection-audiocdcollection -X-KDE-Library=amarok_collection-audiocdcollection diff --git a/amarok/src/core-impl/collections/audiocd/handler/AudioCdHandler.cpp b/amarok/src/core-impl/collections/audiocd/handler/AudioCdHandler.cpp deleted file mode 100644 index 957167a0..00000000 --- a/amarok/src/core-impl/collections/audiocd/handler/AudioCdHandler.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "AudioCdHandler.h" -#include "MediaDeviceCollection.h" - -#include - - -using namespace Meta; - -AudioCdHandler::AudioCdHandler( QObject *parent ) - : MediaDeviceHandler( parent) -{ -} - - -AudioCdHandler::~AudioCdHandler() -{ -} - -QString Meta::AudioCdHandler::prettyName() const -{ - return i18n( "Audio CD" ); -} - -void Meta::AudioCdHandler::init() -{ - m_memColl->slotAttemptConnectionDone( m_success ); -} - - diff --git a/amarok/src/core-impl/collections/audiocd/handler/AudioCdHandler.h b/amarok/src/core-impl/collections/audiocd/handler/AudioCdHandler.h deleted file mode 100644 index f9e1d3cf..00000000 --- a/amarok/src/core-impl/collections/audiocd/handler/AudioCdHandler.h +++ /dev/null @@ -1,44 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AUDIOCDHANDLER_H -#define AUDIOCDHANDLER_H - -#include "core-impl/collections/mediadevicecollection/handler/MediaDeviceHandler.h" - -namespace Meta { - -/** -A hander class for the AudioCd collection - - @author -*/ -class AudioCdHandler : public MediaDeviceHandler -{ -public: - AudioCdHandler( QObject *parent ); - - ~AudioCdHandler(); - - virtual void init(); - virtual bool isWritable() const { return false; } - virtual QString prettyName() const; - -}; - -} - -#endif diff --git a/amarok/src/core-impl/collections/audiocd/support/AudioCdConnectionAssistant.cpp b/amarok/src/core-impl/collections/audiocd/support/AudioCdConnectionAssistant.cpp deleted file mode 100644 index ec5a1780..00000000 --- a/amarok/src/core-impl/collections/audiocd/support/AudioCdConnectionAssistant.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************************** - * Copyright (C) 2009 Alejandro Wainzinger - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "AudioCdConnectionAssistant.h" -#include "AudioCdDeviceInfo.h" - -#include "MediaDeviceCache.h" // for mountpoint - -#include "core/support/Debug.h" - -#include - -#include -#include - -AudioCdConnectionAssistant::~AudioCdConnectionAssistant() -{ -} - -bool -AudioCdConnectionAssistant::identify( const QString& udi ) -{ - const Solid::Device device = Solid::Device(udi); - if( device.is() ) - { - debug() << "OpticalDisc"; - const Solid::OpticalDisc * opt = device.as(); - if ( opt->availableContent() & Solid::OpticalDisc::Audio ) - { - debug() << "AudioCd"; - return true; - } - } - return false; -} - - -MediaDeviceInfo* -AudioCdConnectionAssistant::deviceInfo( const QString& udi ) -{ - const QString device = MediaDeviceCache::instance()->device(udi); - return new AudioCdDeviceInfo( device, udi ); -} - -#include "moc_AudioCdConnectionAssistant.cpp" diff --git a/amarok/src/core-impl/collections/audiocd/support/AudioCdConnectionAssistant.h b/amarok/src/core-impl/collections/audiocd/support/AudioCdConnectionAssistant.h deleted file mode 100644 index 2c7c13b7..00000000 --- a/amarok/src/core-impl/collections/audiocd/support/AudioCdConnectionAssistant.h +++ /dev/null @@ -1,36 +0,0 @@ -/**************************************************************************************** - * Copyright (C) 2009 Alejandro Wainzinger - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AUDIOCDCONNECTIONASSISTANT_H -#define AUDIOCDCONNECTIONASSISTANT_H - -#include "ConnectionAssistant.h" - -#include - -class AudioCdConnectionAssistant : public ConnectionAssistant -{ - Q_OBJECT - -public: - virtual ~AudioCdConnectionAssistant(); - - virtual bool identify( const QString& udi ); - virtual MediaDeviceInfo* deviceInfo( const QString& udi ); - -}; - -#endif // AUDIOCDCONNECTIONASSISTANT_H diff --git a/amarok/src/core-impl/collections/audiocd/support/AudioCdDeviceInfo.cpp b/amarok/src/core-impl/collections/audiocd/support/AudioCdDeviceInfo.cpp deleted file mode 100644 index 4dd44b09..00000000 --- a/amarok/src/core-impl/collections/audiocd/support/AudioCdDeviceInfo.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/**************************************************************************************** - * Copyright (C) 2008 Alejandro Wainzinger - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "AudioCdDeviceInfo.h" -#include "MediaDeviceInfo.h" - -AudioCdDeviceInfo::AudioCdDeviceInfo( QString device, QString udi ) -: MediaDeviceInfo(), -m_device( device ) -{ - m_udi = udi; -} - -AudioCdDeviceInfo::~AudioCdDeviceInfo() -{ -} - -QString -AudioCdDeviceInfo::device() -{ - return m_device; -} - -#include "moc_AudioCdDeviceInfo.cpp" diff --git a/amarok/src/core-impl/collections/audiocd/support/AudioCdDeviceInfo.h b/amarok/src/core-impl/collections/audiocd/support/AudioCdDeviceInfo.h deleted file mode 100644 index 499a3915..00000000 --- a/amarok/src/core-impl/collections/audiocd/support/AudioCdDeviceInfo.h +++ /dev/null @@ -1,35 +0,0 @@ -/**************************************************************************************** - * copyright (C) 2008 Alejandro Wainzinger - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AUDIOCD_DEVICE_INFO_H -#define AUDIOCD_DEVICE_INFO_H - -#include "MediaDeviceInfo.h" - -class AudioCdDeviceInfo : public MediaDeviceInfo -{ - Q_OBJECT - public: - AudioCdDeviceInfo( QString device, QString udi ); - ~AudioCdDeviceInfo(); - - QString device(); - - private: - QString m_device; -}; - -#endif diff --git a/amarok/src/core-impl/collections/daap/CMakeLists.txt b/amarok/src/core-impl/collections/daap/CMakeLists.txt deleted file mode 100644 index 3a7de900..00000000 --- a/amarok/src/core-impl/collections/daap/CMakeLists.txt +++ /dev/null @@ -1,42 +0,0 @@ -include_directories( ../.. - ${CMAKE_BINARY_DIR}/src - ${AMAROK_COLLECTION_SUPPORT_DIR} - daapreader - ${KDE4_INCLUDE_DIR} - ${QT_INCLUDES} ) - -remove_definitions(-DQT_NO_HTTP) - -########### next target ############### - -set(amarok_collection-daapcollection_PART_SRCS - DaapMeta.cpp - DaapCollection.cpp - daapreader/Reader.cpp - daapreader/authentication/contentfetcher.cpp - daapreader/authentication/hasher.c - daapreader/authentication/md5.c ) - -kde4_add_plugin(amarok_collection-daapcollection ${amarok_collection-daapcollection_PART_SRCS}) - -target_link_libraries(amarok_collection-daapcollection - amarokcore - amaroklib - ${KDE4_KDECORE_LIBS} - ${KDE4_KDEUI_LIBS} - ${KDE4_THREADWEAVER_LIBS} - ${KDE4_KDNSSD_LIBS} - ${KDE4_SOLID_LIBS} - ${QT_QTNETWORK_LIBRARY} -) - -if(APPLE) - SET_TARGET_PROPERTIES(amarok_collection-daapcollection PROPERTIES LINK_FLAGS "-undefined dynamic_lookup") -endif(APPLE) - -install(TARGETS amarok_collection-daapcollection DESTINATION ${PLUGIN_INSTALL_DIR} ) - - -########### install files ############### - -install( FILES amarok_collection-daapcollection.desktop DESTINATION ${SERVICES_INSTALL_DIR}) diff --git a/amarok/src/core-impl/collections/daap/DaapCollection.cpp b/amarok/src/core-impl/collections/daap/DaapCollection.cpp deleted file mode 100644 index f97342c1..00000000 --- a/amarok/src/core-impl/collections/daap/DaapCollection.cpp +++ /dev/null @@ -1,318 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2006 Ian Monroe * - * Copyright (c) 2006 Seb Ruiz * - * Copyright (c) 2007 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "DaapCollection" - -#include "DaapCollection.h" - -#include "amarokconfig.h" -#include "core/interfaces/Logger.h" -#include "core/support/Components.h" -#include "core/support/Debug.h" -#include "DaapMeta.h" -#include "MemoryQueryMaker.h" -#include "Reader.h" - -#include -#include - -#include - -#include -#include -#include - -using namespace Collections; - -AMAROK_EXPORT_COLLECTION( DaapCollectionFactory, daapcollection ) - -DaapCollectionFactory::DaapCollectionFactory( QObject *parent, const QVariantList &args ) - : Collections::CollectionFactory( parent, args ) - , m_browser( 0 ) -{ - m_info = KPluginInfo( "amarok_collection-daapcollection.desktop", "services" ); -} - -DaapCollectionFactory::~DaapCollectionFactory() -{ - delete m_browser; -} - -void -DaapCollectionFactory::init() -{ - DEBUG_BLOCK - switch( DNSSD::ServiceBrowser::isAvailable() ) - { - case DNSSD::ServiceBrowser::Working: - //don't block Amarok's startup by connecting to DAAP servers - QTimer::singleShot( 1000, this, SLOT(connectToManualServers()) ); - m_browser = new DNSSD::ServiceBrowser("_daap._tcp"); - m_browser->setObjectName("daapServiceBrowser"); - connect( m_browser, SIGNAL(serviceAdded(DNSSD::RemoteService::Ptr)), - this, SLOT(foundDaap(DNSSD::RemoteService::Ptr)) ); - connect( m_browser, SIGNAL(serviceRemoved(DNSSD::RemoteService::Ptr)), - this, SLOT(serverOffline(DNSSD::RemoteService::Ptr)) ); - m_browser->startBrowse(); - break; - - case DNSSD::ServiceBrowser::Stopped: - debug() << "The Zeroconf daemon is not running"; - break; - - case DNSSD::ServiceBrowser::Unsupported: - debug() << "Zeroconf support is not available"; - break; - - default: - debug() << "Unknown error with Zeroconf"; - } - m_initialized = true; -} - -void -DaapCollectionFactory::connectToManualServers() -{ - DEBUG_BLOCK - QStringList sl = AmarokConfig::manuallyAddedServers(); - foreach( const QString &server, sl ) - { - debug() << "Adding server " << server; - QStringList current = server.split( ':', QString::KeepEmptyParts ); - //handle invalid urls gracefully - if( current.count() < 2 ) - continue; - - QString host = current.first(); - quint16 port = current.last().toUShort(); - Amarok::Components::logger()->longMessage( - i18n( "Loading remote collection from host %1", host), - Amarok::Logger::Information ); - - int lookup_id = QHostInfo::lookupHost( host, this, SLOT(resolvedManualServerIp(QHostInfo))); - m_lookupHash.insert( lookup_id, port ); - } -} - -void -DaapCollectionFactory::serverOffline( DNSSD::RemoteService::Ptr service ) -{ - DEBUG_BLOCK - QString key = serverKey( service.data()->hostName(), service.data()->port() ); - if( m_collectionMap.contains( key ) ) - { - QWeakPointer coll = m_collectionMap[ key ]; - if( coll ) - coll.data()->serverOffline(); //collection will be deleted by collectionmanager - else - warning() << "collection already null"; - - m_collectionMap.remove( key ); - - } - else - warning() << "removing non-existent service"; -} - -void -DaapCollectionFactory::foundDaap( DNSSD::RemoteService::Ptr service ) -{ - DEBUG_BLOCK - - connect( service.data(), SIGNAL(resolved(bool)), this, SLOT(resolvedDaap(bool)) ); - service->resolveAsync(); -} - -void -DaapCollectionFactory::resolvedDaap( bool success ) -{ - const DNSSD::RemoteService* service = dynamic_cast(sender()); - if( !success || !service ) return; - debug() << service->serviceName() << ' ' << service->hostName() << ' ' << service->domain() << ' ' << service->type(); - - int lookup_id = QHostInfo::lookupHost( service->hostName(), this, SLOT(resolvedServiceIp(QHostInfo))); - m_lookupHash.insert( lookup_id, service->port() ); -} - -QString -DaapCollectionFactory::serverKey( const QString& host, quint16 port) const -{ - return host + ':' + QString::number( port ); -} - -void -DaapCollectionFactory::slotCollectionReady() -{ - DEBUG_BLOCK - DaapCollection *collection = dynamic_cast( sender() ); - if( collection ) - { - disconnect( collection, SIGNAL(remove()), this, SLOT(slotCollectionDownloadFailed()) ); - emit newCollection( collection ); - } -} - -void -DaapCollectionFactory::slotCollectionDownloadFailed() -{ - DEBUG_BLOCK - DaapCollection *collection = qobject_cast( sender() ); - if( !collection ) - return; - disconnect( collection, SIGNAL(collectionReady()), this, SLOT(slotCollectionReady()) ); - foreach( const QWeakPointer< DaapCollection > &it, m_collectionMap ) - { - if( it.data() == collection ) - { - m_collectionMap.remove( m_collectionMap.key( it ) ); - break; - } - } - collection->deleteLater(); -} - -void -DaapCollectionFactory::resolvedManualServerIp( QHostInfo hostInfo ) -{ - if ( !m_lookupHash.contains(hostInfo.lookupId()) ) - return; - - if ( hostInfo.addresses().isEmpty() ) - return; - - QString host = hostInfo.hostName(); - QString ip = hostInfo.addresses().at(0).toString(); - quint16 port = m_lookupHash.value( hostInfo.lookupId() ); - - //adding manual servers to the collectionMap doesn't make sense - DaapCollection *coll = new DaapCollection( host, ip, port ); - connect( coll, SIGNAL(collectionReady()), SLOT(slotCollectionReady()) ); - connect( coll, SIGNAL(remove()), SLOT(slotCollectionDownloadFailed()) ); -} - -void -DaapCollectionFactory::resolvedServiceIp( QHostInfo hostInfo ) -{ - DEBUG_BLOCK - // debug() << "got address:" << hostInfo.addresses() << "and lookup hash contains id" << hostInfo.lookupId() << "?" << m_lookupHash.contains(hostInfo.lookupId()); - if ( !m_lookupHash.contains(hostInfo.lookupId()) ) - return; - - if ( hostInfo.addresses().isEmpty() ) - return; - - QString host = hostInfo.hostName(); - QString ip = hostInfo.addresses().at(0).toString(); - quint16 port = m_lookupHash.value( hostInfo.lookupId() ); - - // debug() << "already added server?" << m_collectionMap.contains(serverKey( host, port )); - if( m_collectionMap.contains(serverKey( host, port )) ) //same server from multiple interfaces - return; - - // debug() << "creating daap collection with" << host << ip << port; - QWeakPointer coll( new DaapCollection( host, ip, port ) ); - connect( coll.data(), SIGNAL(collectionReady()), SLOT(slotCollectionReady()) ); - connect( coll.data(), SIGNAL(remove()), SLOT(slotCollectionDownloadFailed()) ); - m_collectionMap.insert( serverKey( host, port ), coll.data() ); -} - -//DaapCollection - -DaapCollection::DaapCollection( const QString &host, const QString &ip, quint16 port ) - : Collection() - , m_host( host ) - , m_port( port ) - , m_ip( ip ) - , m_reader( 0 ) - , m_mc( new MemoryCollection() ) -{ - debug() << "Host: " << host << " port: " << port; - m_reader = new Daap::Reader( this, host, port, QString(), this, "DaapReader" ); - connect( m_reader, SIGNAL(passwordRequired()), SLOT(passwordRequired()) ); - connect( m_reader, SIGNAL(httpError(QString)), SLOT(httpError(QString)) ); - m_reader->loginRequest(); -} - -DaapCollection::~DaapCollection() -{ -} - -QueryMaker* -DaapCollection::queryMaker() -{ - return new MemoryQueryMaker( m_mc.toWeakRef(), collectionId() ); -} - -QString -DaapCollection::collectionId() const -{ - return QString( "daap://" + m_ip + ':' ) + QString::number( m_port ); -} - -QString -DaapCollection::prettyName() const -{ - QString host = m_host; - // No need to be overly verbose - if( host.endsWith( ".local" ) ) - host = host.remove( QRegExp(".local$") ); - return i18n("Music share at %1", host); -} - -void -DaapCollection::passwordRequired() -{ - //get password - QString password; - delete m_reader; - m_reader = new Daap::Reader( this, m_host, m_port, password, this, "DaapReader" ); - connect( m_reader, SIGNAL(passwordRequired()), SLOT(passwordRequired()) ); - connect( m_reader, SIGNAL(httpError(QString)), SLOT(httpError(QString)) ); - m_reader->loginRequest(); -} - -void -DaapCollection::httpError( const QString &error ) -{ - DEBUG_BLOCK - debug() << "Http error in DaapReader: " << error; - emit remove(); -} - -void -DaapCollection::serverOffline() -{ - emit remove(); -} - -void -DaapCollection::loadedDataFromServer() -{ - DEBUG_BLOCK - emit collectionReady(); -} - -void -DaapCollection::parsingFailed() -{ - DEBUG_BLOCK - emit remove(); -} - -#include "moc_DaapCollection.cpp" - diff --git a/amarok/src/core-impl/collections/daap/DaapCollection.h b/amarok/src/core-impl/collections/daap/DaapCollection.h deleted file mode 100644 index defc7728..00000000 --- a/amarok/src/core-impl/collections/daap/DaapCollection.h +++ /dev/null @@ -1,115 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2006 Ian Monroe * - * Copyright (c) 2006 Seb Ruiz * - * Copyright (c) 2007 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef DAAPCOLLECTION_H -#define DAAPCOLLECTION_H - -#include "core/collections/Collection.h" -#include "MemoryCollection.h" -#include "Reader.h" - -#include -#include -#include -#include -#include -#include - -#include - -#include //for DNSSD::RemoteService::Ptr - -namespace DNSSD { - class ServiceBrowser; -} - -namespace Collections { - -class DaapCollection; - -class DaapCollectionFactory : public Collections::CollectionFactory -{ - Q_OBJECT - public: - DaapCollectionFactory( QObject *parent, const QVariantList &args ); - virtual ~DaapCollectionFactory(); - - virtual void init(); - - private: - QString serverKey( const QString& host, quint16 port ) const; - - private slots: - void connectToManualServers(); - void serverOffline( DNSSD::RemoteService::Ptr ); - void foundDaap( DNSSD::RemoteService::Ptr ); - void resolvedDaap( bool ); - void slotCollectionReady(); - void slotCollectionDownloadFailed(); - - void resolvedServiceIp(QHostInfo); - void resolvedManualServerIp(QHostInfo); - - private: - DNSSD::ServiceBrowser* m_browser; - - QMap > m_collectionMap; - - QHash m_lookupHash; -}; - -class DaapCollection : public Collections::Collection -{ - Q_OBJECT - public: - DaapCollection( const QString &host, const QString &ip, quint16 port ); - virtual ~DaapCollection(); - - virtual QueryMaker* queryMaker(); - - virtual QString collectionId() const; - virtual QString prettyName() const; - virtual KIcon icon() const { return KIcon("network-server"); } - - void serverOffline(); - - QSharedPointer memoryCollection() const { return m_mc; } - - signals: - void collectionReady(); - - public slots: - void loadedDataFromServer(); - void parsingFailed(); - - private slots: - void passwordRequired(); - void httpError( const QString &error ); - - private: - QString m_host; - quint16 m_port; - QString m_ip; - - Daap::Reader *m_reader; - QSharedPointer m_mc; -}; - -} //namespace Collections - -#endif diff --git a/amarok/src/core-impl/collections/daap/DaapMeta.cpp b/amarok/src/core-impl/collections/daap/DaapMeta.cpp deleted file mode 100644 index 12c39dc8..00000000 --- a/amarok/src/core-impl/collections/daap/DaapMeta.cpp +++ /dev/null @@ -1,466 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "DaapMeta.h" - -#include "DaapCollection.h" - -using namespace Meta; - -DaapTrack::DaapTrack( Collections::DaapCollection *collection, const QString &host, quint16 port, const QString &dbId, const QString &itemId, const QString &format) - : Meta::Track() - , m_collection( collection ) - , m_artist( 0 ) - , m_album( 0 ) - , m_genre( 0 ) - , m_composer( 0 ) - , m_year( 0 ) - , m_name() - , m_type( format ) - , m_length( 0 ) - , m_trackNumber( 0 ) - , m_displayUrl() - , m_playableUrl() -{ - QString url = QString( "daap://%1:%2/databases/%3/items/%4.%5" ) - .arg( host, QString::number( port ), dbId, itemId, format ); - m_displayUrl = url; - m_playableUrl = url; -} - -DaapTrack::~DaapTrack() -{ - //nothing to do -} - -QString -DaapTrack::name() const -{ - return m_name; -} - -KUrl -DaapTrack::playableUrl() const -{ - KUrl url( m_playableUrl ); - url.setProtocol( "http" ); - return url; -} - -QString -DaapTrack::uidUrl() const -{ - return m_playableUrl; -} - -QString -DaapTrack::prettyUrl() const -{ - return m_displayUrl; -} - -QString -DaapTrack::notPlayableReason() const -{ - return networkNotPlayableReason(); -} - -AlbumPtr -DaapTrack::album() const -{ - return AlbumPtr::staticCast( m_album ); -} - -ArtistPtr -DaapTrack::artist() const -{ - return ArtistPtr::staticCast( m_artist ); -} - -GenrePtr -DaapTrack::genre() const -{ - return GenrePtr::staticCast( m_genre ); -} - -ComposerPtr -DaapTrack::composer() const -{ - return ComposerPtr::staticCast( m_composer ); -} - -YearPtr -DaapTrack::year() const -{ - return YearPtr::staticCast( m_year ); -} - -void -DaapTrack::setAlbum( const QString &newAlbum ) -{ - Q_UNUSED( newAlbum ) -} - -void -DaapTrack::setArtist( const QString &newArtist ) -{ - Q_UNUSED( newArtist ) -} - -void -DaapTrack::setComposer( const QString &newComposer ) -{ - Q_UNUSED( newComposer ) -} - -void -DaapTrack::setGenre( const QString &newGenre ) -{ - Q_UNUSED( newGenre ) -} - -void -DaapTrack::setYear( int newYear ) -{ - Q_UNUSED( newYear ) -} - -/* -TODO: This isn't good enough, but for now as daapreader/Reader.cpp indicates - we can query for the BPM from daap server, but desire is to get BPM of files working - first! -*/ -qreal -DaapTrack::bpm() const -{ - return -1.0; -} - -QString -DaapTrack::comment() const -{ - return QString(); -} - -void -DaapTrack::setComment( const QString &newComment ) -{ - Q_UNUSED( newComment ) -} - -qint64 -DaapTrack::length() const -{ - return m_length; -} - -int -DaapTrack::filesize() const -{ - return 0; -} - -int -DaapTrack::sampleRate() const -{ - return 0; -} - -int -DaapTrack::bitrate() const -{ - return 0; -} - -int -DaapTrack::trackNumber() const -{ - return m_trackNumber; -} - -void -DaapTrack::setTrackNumber( int newTrackNumber ) -{ - m_trackNumber = newTrackNumber; -} - -int -DaapTrack::discNumber() const -{ - return 0; -} - -void -DaapTrack::setDiscNumber( int newDiscNumber ) -{ - Q_UNUSED( newDiscNumber ) -} - -QString -DaapTrack::type() const -{ - return m_type; -} - -bool -DaapTrack::inCollection() const -{ - return true; -} - -Collections::Collection* -DaapTrack::collection() const -{ - return m_collection; -} - -void -DaapTrack::setAlbum( DaapAlbumPtr album ) -{ - m_album = album; -} - -void -DaapTrack::setArtist( DaapArtistPtr artist ) -{ - m_artist = artist; -} - -void -DaapTrack::setGenre( DaapGenrePtr genre ) -{ - m_genre = genre; -} - -void -DaapTrack::setComposer( DaapComposerPtr composer ) -{ - m_composer = composer; -} - -void -DaapTrack::setYear( DaapYearPtr year ) -{ - m_year = year; -} - -void -DaapTrack::setTitle( const QString &title ) -{ - m_name = title; -} - -void -DaapTrack::setLength( qint64 length ) -{ - m_length = length; -} - -//DaapArtist - -DaapArtist::DaapArtist( const QString &name ) - : Meta::Artist() - , m_name( name ) - , m_tracks() -{ - //nothing to do -} - -DaapArtist::~DaapArtist() -{ - //nothing to do -} - -QString -DaapArtist::name() const -{ - return m_name; -} - -TrackList -DaapArtist::tracks() -{ - return m_tracks; -} - -AlbumList -DaapArtist::albums() -{ - //TODO - return AlbumList(); -} - -void -DaapArtist::addTrack( DaapTrackPtr track ) -{ - m_tracks.append( TrackPtr::staticCast( track ) ); -} - -DaapAlbum::DaapAlbum( const QString &name ) - : Meta::Album() - , m_name( name ) - , m_tracks() - , m_isCompilation( false ) - , m_albumArtist( 0 ) -{ - //nothing to do -} - -DaapAlbum::~DaapAlbum() -{ - //nothing to do -} - -QString -DaapAlbum::name() const -{ - return m_name; -} - -bool -DaapAlbum::isCompilation() const -{ - return m_isCompilation; -} - -bool -DaapAlbum::hasAlbumArtist() const -{ - return !m_albumArtist.isNull(); -} - -ArtistPtr -DaapAlbum::albumArtist() const -{ - return ArtistPtr::staticCast( m_albumArtist ); -} - -TrackList -DaapAlbum::tracks() -{ - return m_tracks; -} - -void -DaapAlbum::addTrack( DaapTrackPtr track ) -{ - m_tracks.append( TrackPtr::staticCast( track ) ); -} - -void -DaapAlbum::setAlbumArtist( DaapArtistPtr artist ) -{ - m_albumArtist = artist; -} - -//DaapGenre - -DaapGenre::DaapGenre( const QString &name ) - : Meta::Genre() - , m_name( name ) - , m_tracks() -{ - //nothing to do -} - -DaapGenre::~DaapGenre() -{ - //nothing to do -} - -QString -DaapGenre::name() const -{ - return m_name; -} - -TrackList -DaapGenre::tracks() -{ - return m_tracks; -} - -void -DaapGenre::addTrack( DaapTrackPtr track ) -{ - m_tracks.append( TrackPtr::staticCast( track ) ); -} - -//DaapComposer - -DaapComposer::DaapComposer( const QString &name ) - : Meta::Composer() - , m_name( name ) - , m_tracks() -{ - //nothing to do -} - -DaapComposer::~DaapComposer() -{ - //nothing to do -} - -QString -DaapComposer::name() const -{ - return m_name; -} - -TrackList -DaapComposer::tracks() -{ - return m_tracks; -} - -void -DaapComposer::addTrack( DaapTrackPtr track ) -{ - m_tracks.append( TrackPtr::staticCast( track ) ); -} - -//DaapYear - -DaapYear::DaapYear( const QString &name ) - : Meta::Year() - , m_name( name ) - , m_tracks() -{ - //nothing to do -} - -DaapYear::~DaapYear() -{ - //nothing to do -} - -QString -DaapYear::name() const -{ - return m_name; -} - -TrackList -DaapYear::tracks() -{ - return m_tracks; -} - -void -DaapYear::addTrack( DaapTrackPtr track ) -{ - m_tracks.append( TrackPtr::staticCast( track ) ); -} diff --git a/amarok/src/core-impl/collections/daap/DaapMeta.h b/amarok/src/core-impl/collections/daap/DaapMeta.h deleted file mode 100644 index 7fcbfc9c..00000000 --- a/amarok/src/core-impl/collections/daap/DaapMeta.h +++ /dev/null @@ -1,219 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef DAAPMETA_H -#define DAAPMETA_H - -#include "core/meta/Meta.h" - -namespace Collections { - class DaapCollection; -} - -namespace Meta -{ - -class DaapTrack; -class DaapAlbum; -class DaapArtist; -class DaapGenre; -class DaapComposer; -class DaapYear; - -typedef KSharedPtr DaapTrackPtr; -typedef KSharedPtr DaapArtistPtr; -typedef KSharedPtr DaapAlbumPtr; -typedef KSharedPtr DaapGenrePtr; -typedef KSharedPtr DaapComposerPtr; -typedef KSharedPtr DaapYearPtr; - -class DaapTrack : public Meta::Track -{ - public: - DaapTrack( Collections::DaapCollection *collection, const QString &host, quint16 port, const QString &dbId, const QString &itemId, const QString &format); - virtual ~DaapTrack(); - - virtual QString name() const; - - virtual KUrl playableUrl() const; - virtual QString uidUrl() const; - virtual QString prettyUrl() const; - virtual QString notPlayableReason() const; - - virtual AlbumPtr album() const; - virtual ArtistPtr artist() const; - virtual GenrePtr genre() const; - virtual ComposerPtr composer() const; - virtual YearPtr year() const; - - virtual void setAlbum ( const QString &newAlbum ); - virtual void setArtist ( const QString &newArtist ); - virtual void setGenre ( const QString &newGenre ); - virtual void setComposer ( const QString &newComposer ); - virtual void setYear ( int newYear ); - - virtual void setTitle( const QString &newTitle ); - - virtual qreal bpm() const; - - virtual QString comment() const; - virtual void setComment ( const QString &newComment ); - - virtual qint64 length() const; - - virtual int filesize() const; - virtual int sampleRate() const; - virtual int bitrate() const; - - virtual int trackNumber() const; - virtual void setTrackNumber ( int newTrackNumber ); - - virtual int discNumber() const; - virtual void setDiscNumber ( int newDiscNumber ); - - virtual QString type() const; - - virtual bool inCollection() const; - virtual Collections::Collection* collection() const; - - //DaapTrack specific methods - void setAlbum( DaapAlbumPtr album ); - void setArtist( DaapArtistPtr artist ); - void setComposer( DaapComposerPtr composer ); - void setGenre( DaapGenrePtr genre ); - void setYear( DaapYearPtr year ); - - void setLength( qint64 length ); - - private: - Collections::DaapCollection *m_collection; - - DaapArtistPtr m_artist; - DaapAlbumPtr m_album; - DaapGenrePtr m_genre; - DaapComposerPtr m_composer; - DaapYearPtr m_year; - - QString m_name; - QString m_type; - qint64 m_length; - int m_trackNumber; - QString m_displayUrl; - QString m_playableUrl; -}; - -class DaapArtist : public Meta::Artist -{ - public: - DaapArtist( const QString &name ); - virtual ~DaapArtist(); - - virtual QString name() const; - - virtual TrackList tracks(); - - virtual AlbumList albums(); - - //DaapArtist specific methods - void addTrack( DaapTrackPtr track ); - - private: - QString m_name; - TrackList m_tracks; -}; - -class DaapAlbum : public Meta::Album -{ - public: - DaapAlbum( const QString &name ); - virtual ~DaapAlbum(); - - virtual QString name() const; - - virtual bool isCompilation() const; - virtual bool hasAlbumArtist() const; - virtual ArtistPtr albumArtist() const; - virtual TrackList tracks(); - - //DaapAlbum specific methods - void addTrack( DaapTrackPtr track ); - void setAlbumArtist( DaapArtistPtr artist ); - - private: - QString m_name; - TrackList m_tracks; - bool m_isCompilation; - DaapArtistPtr m_albumArtist; -}; - -class DaapGenre : public Meta::Genre -{ - public: - DaapGenre( const QString &name ); - virtual ~DaapGenre(); - - virtual QString name() const; - - virtual TrackList tracks(); - - //DaapGenre specific methods - void addTrack( DaapTrackPtr track ); - - private: - QString m_name; - TrackList m_tracks; -}; - -class DaapComposer : public Meta::Composer -{ - public: - DaapComposer( const QString &name ); - virtual ~DaapComposer(); - - virtual QString name() const; - - virtual TrackList tracks(); - - //DaapComposer specific methods - void addTrack( DaapTrackPtr track ); - - private: - QString m_name; - TrackList m_tracks; -}; - -class DaapYear : public Meta::Year -{ - public: - DaapYear( const QString &name ); - virtual ~DaapYear(); - - virtual QString name() const; - - virtual TrackList tracks(); - - //DaapYear specific methods - void addTrack( DaapTrackPtr track ); - - private: - QString m_name; - TrackList m_tracks; -}; - -} - -#endif - diff --git a/amarok/src/core-impl/collections/daap/amarok_collection-daapcollection.desktop b/amarok/src/core-impl/collections/daap/amarok_collection-daapcollection.desktop deleted file mode 100644 index d019cf15..00000000 --- a/amarok/src/core-impl/collections/daap/amarok_collection-daapcollection.desktop +++ /dev/null @@ -1,136 +0,0 @@ -[Desktop Entry] -Type=Service -Icon=network-workgroup -Name=DAAP Collection -Name[be]=Калекцыя DAAP -Name[bg]=Колекция DAAP -Name[bs]=Zbirka DAAP -Name[ca]=Col·lecció DAAP -Name[ca@valencia]=Col·lecció DAAP -Name[cs]=Sbírka DAAP -Name[csb]=Kòlekcëjô DAAP -Name[da]=DAAP-samling -Name[de]=DAAP-Sammlung -Name[el]=Συλλογή DAAP -Name[en_GB]=DAAP Collection -Name[eo]=DAAP kolekto -Name[es]=Colección DAAP -Name[et]=DAAP kogu -Name[eu]=DAAP bilduma -Name[fi]=DAAP-kokoelma -Name[fr]=Collection « DAAP » -Name[ga]=Bailiúchán DAAP -Name[gl]=Colección DAAP -Name[he]=אוסף DAAP -Name[hne]=डीएएपी संग्रह -Name[hu]=DAAP-gyűjtemény -Name[id]=Koleksi DAAP -Name[is]=DAAP safn -Name[it]=Collezione DAAP -Name[ja]=DAAP コレクション -Name[km]=សម្រាំង DAAP -Name[ko]=DAAP 모음집 -Name[ku]=Berhevoka DAAP -Name[lt]=DAAP fonoteka -Name[lv]=DAAP kolekcija -Name[nb]=DAAP-samling -Name[nds]=DAAP-Sammeln -Name[ne]=DAAP सङ्कलन -Name[nl]=DAAP-collectie -Name[nn]=DAAP-samling -Name[pa]=DAAP ਭੰਡਾਰ -Name[pl]=Zbiór DAAP -Name[pt]=Colecção de DAAP -Name[pt_BR]=Coleção de DAAP -Name[ro]=Colecție DAAP -Name[ru]=Коллекция DAAP -Name[sk]=DAAP kolekcia -Name[sl]=Zbirka DAAP -Name[sr]=ДААП збирка -Name[sr@ijekavian]=ДААП збирка -Name[sr@ijekavianlatin]=DAAP zbirka -Name[sr@latin]=DAAP zbirka -Name[sv]=DAAP-samling -Name[th]=คลังสื่อของ DAAP -Name[tr]=DAAP Koleksiyonu -Name[uk]=Збірка DAAP -Name[wa]=Ramexhnêye DAAP -Name[x-test]=xxDAAP Collectionxx -Name[zh_CN]=DAAP 收藏 -Name[zh_TW]=DAAP 收藏 -Comment=DAAP collection plugin for Amarok -Comment[be]=Утулка калекцыі DAAP для Amarok -Comment[bg]=Приставка за колекция DAAP (Amarok) -Comment[bs]=Priključak zbirke DAAP za Amarok -Comment[ca]=Connector de col·leccions DAAP per a l'Amarok -Comment[ca@valencia]=Connector de col·leccions DAAP per a l'Amarok -Comment[cs]=Modul sbírky DAAP pro AmaroK -Comment[csb]=Wtëkôcz kòlekcëji DAAP dlô Amaroka -Comment[da]=Plugin til DAAP-samling til Amarok -Comment[de]=DAAP-Sammlungsmodul für Amarok -Comment[el]=Πρόσθετο συλλογής DAAP για το AmaroK -Comment[en_GB]=DAAP collection plugin for Amarok -Comment[eo]=DAAP kolekta kromaĵo por Amarok -Comment[es]=Complemento de la colección DAAP para Amarok -Comment[et]=Amaroki DAAP kogu plugin -Comment[eu]=DAAP bildumen plugina Amarok-entzako -Comment[fi]=Amarok-kokoelmaliitännäinen -Comment[fr]=Module externe de collections « DAAP » pour Amarok -Comment[ga]=Breiseán bailiúchán DAAP le haghaidh Amarok -Comment[gl]=Complemento de coleccións DAAP para Amarok -Comment[he]=תוסף אוסף DAAP ל־Amarok -Comment[hne]=अमाराक बर डीएएपी संग्रह प्लगइन -Comment[hu]=DAAP-gyűjteményt megvalósító bővítőmodul az Amarokhoz -Comment[id]=Plugin koleksi DAAP untuk Amarok -Comment[is]=DAAP safníforrit fyrir Amarok -Comment[it]=Estensione della collezione DAAP di Amarok -Comment[ja]=Amarok のための DAAP コレクションプラグイン -Comment[km]=កម្មវិធី​ជំនួយ​សម្រាំង DAAP សម្រាប់​ Amarok -Comment[ko]=Amarok의 DAAP 모음집 플러그인 -Comment[ku]=Pêveka berhevoka DAAP ji bo Amarok -Comment[lt]=DAAP fonotekos Amarok įskiepis -Comment[lv]=Amarok DAAP kolekcijas spraudnis -Comment[nb]=DAAP-samling – programtillegg for Amarok -Comment[nds]=DAAP-Sammelnmoduul för Amarok -Comment[ne]=अमारोकका लागि DAAP सङ्कलन प्लगइन -Comment[nl]=DAAP-collectieplugin voor Amarok -Comment[nn]=Amarok-samlingstillegg for DAAP -Comment[pa]=ਅਮਰੋਕ ਲਈ DAAP ਭੰਡਾਰ ਪਲੱਗਇਨ -Comment[pl]=Wtyczka kolekcji DAAP dla Amaroka -Comment[pt]=Um 'plugin' de colecção para DAAP no Amarok -Comment[pt_BR]=Plugin de coleção DAAP para o Amarok -Comment[ro]=Modul de colecție DAAP pentru Amarok -Comment[ru]=Модуль коллекции DAAP для Amarok -Comment[sk]=Modul DAAP kolekcia pre Amarok -Comment[sl]=Vstavek za zbirko DAAP za Amarok -Comment[sr]=Прикључак ДААП збирке за Амарок -Comment[sr@ijekavian]=Прикључак ДААП збирке за Амарок -Comment[sr@ijekavianlatin]=Priključak DAAP zbirke za Amarok -Comment[sr@latin]=Priključak DAAP zbirke za Amarok -Comment[sv]=Insticksprogram med DAAP-samling för Amarok -Comment[th]=ส่วนเสริมของแอมอะร็อก สำหรับเสริมจัดการคลังสื่อของ DAAP -Comment[tr]=Amarok için DAAP koleksiyon eklentisi -Comment[uk]=Додаток збірки DAAP для Amarok -Comment[wa]=Tchôke-divins di ramexhnêye DAAP po Amarok -Comment[x-test]=xxDAAP collection plugin for Amarokxx -Comment[zh_CN]=Amarok 的 DAAP 收藏插件 -Comment[zh_TW]=Amarok 的 DAAP 收藏外掛程式 - -ServiceTypes=Amarok/Plugin - -X-KDE-Amarok-authors=Maximilian Kossick -X-KDE-Amarok-email=maximilian.kossick@googlemail.com -X-KDE-Amarok-framework-version=72 -X-KDE-Amarok-name=daap-collection -X-KDE-Amarok-plugintype=collection -X-KDE-Amarok-rank=100 -X-KDE-Amarok-version=1 - -X-KDE-PluginInfo-Author=Maximilian Kossick -X-KDE-PluginInfo-Email=maximilian.kossick@googlemail.com -X-KDE-PluginInfo-Version=1.0 -X-KDE-PluginInfo-Category=Collection -X-KDE-PluginInfo-License=GPL -X-KDE-PluginInfo-EnabledByDefault=false -X-KDE-PluginInfo-Name=amarok_collection-daapcollection -X-KDE-Library=amarok_collection-daapcollection diff --git a/amarok/src/core-impl/collections/daap/daapreader/Reader.cpp b/amarok/src/core-impl/collections/daap/daapreader/Reader.cpp deleted file mode 100644 index 833c469d..00000000 --- a/amarok/src/core-impl/collections/daap/daapreader/Reader.cpp +++ /dev/null @@ -1,597 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2006 Ian Monroe * - * Copyright (c) 2007 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "DaapReader" - -#include "Reader.h" - -#include "authentication/contentfetcher.h" -#include "DaapCollection.h" -#include "DaapMeta.h" -#include "core/support/Debug.h" - - -#include -#include -#include -#include -#include - -#include - -using namespace Daap; -using namespace Meta; - -//#define DEBUGTAG( VAR ) debug() << tag << " has value " << VAR; -#define DEBUGTAG( VAR ) - -Reader::Reader( Collections::DaapCollection* mc, const QString& host, quint16 port, const QString& password, QObject* parent, const char* name) - : QObject( parent ) - , m_memColl( mc ) - , m_host( host ) - , m_port( port ) - , m_sessionId( -1 ) - , m_password( password ) -{ - setObjectName( name ); - debug() << "Host: " << host << " port: " << port; - - // these content codes are needed to learn all others - m_codes["mccr"] = Code( "dmap.contentcodesresponse", CONTAINER ); - m_codes["mstt"] = Code( "dmap.status", LONG ); - m_codes["mdcl"] = Code( "dmap.dictionary", CONTAINER ); - // mcnm is actually an int, but string makes parsing easier - m_codes["mcnm"] = Code( "dmap.contentcodesnumber", STRING ); - m_codes["mcna"] = Code( "dmap.contentcodesname", STRING ); - m_codes["mcty"] = Code( "dmap.contentcodestype", SHORT ); - - // stupid, stupid. The reflection just isn't good enough - // to connect to an iPhoto server. - m_codes["ppro"] = Code( "dpap.protocolversion", LONG ); - m_codes["avdb"] = Code( "daap.serverdatabases", CONTAINER ); - m_codes["adbs"] = Code( "daap.databasesongs", CONTAINER ); - m_codes["pret"] = Code( "dpap.unknown", CONTAINER ); -} - -Reader::~Reader() -{ } - -void -Reader::logoutRequest() -{ - DEBUG_BLOCK - ContentFetcher* http = new ContentFetcher( m_host, m_port, m_password, this, "readerLogoutHttp" ); - connect( http, SIGNAL(httpError(QString)), this, SLOT(fetchingError(QString)) ); - connect( http, SIGNAL(requestFinished(int,bool)), this, SLOT(logoutRequest(int,bool)) ); - http->getDaap( "/logout?" + m_loginString ); -} - -void -Reader::logoutRequest( int, bool ) -{ - DEBUG_BLOCK - const_cast(sender())->deleteLater(); - deleteLater(); -} - -void -Reader::loginRequest() -{ - DEBUG_BLOCK - ContentFetcher* http = new ContentFetcher( m_host, m_port, m_password, this, "readerHttp"); - connect( http, SIGNAL(httpError(QString)), this, SLOT(fetchingError(QString)) ); - connect( http, SIGNAL(requestFinished(int,bool)), this, SLOT(contentCodesReceived(int,bool)) ); - http->getDaap( "/content-codes" ); -} - -void -Reader::contentCodesReceived( int /* id */, bool error ) -{ - DEBUG_BLOCK - ContentFetcher* http = (ContentFetcher*) sender(); - disconnect( http, SIGNAL(requestFinished(int,bool)), this, SLOT(contentCodesReceived(int,bool)) ); - if( error ) - { - http->deleteLater(); - return; - } - - QDataStream raw( http->results() ); - Map contentCodes = parse( raw ); - QList root = contentCodes["mccr"].toList(); - if( root.isEmpty() ) - return; //error - root = root[0].toMap().value( "mdcl" ).toList(); - foreach( const QVariant &v, root ) - { - Map entry = v.toMap(); - QString code = entry.value( "mcnm" ).toList().value( 0 ).toString(); - QString name = entry.value( "mcna" ).toList().value( 0 ).toString(); - ContentTypes type = ContentTypes( entry.value( "mcty" ).toList().value( 0 ).toInt() ); - if( !m_codes.contains( code ) && !code.isEmpty() && type > 0 ) - { - m_codes[code] = Code( name, type ); - debug() << "Added DAAP code" << code << ":" << name << "with type" << type; - } - } - - connect( http, SIGNAL(responseHeaderReceived(QHttpResponseHeader)) - , this, SLOT(loginHeaderReceived(QHttpResponseHeader)) ); - http->getDaap( "/login" ); -} - -void -Reader::loginHeaderReceived( const QHttpResponseHeader & resp ) -{ - DEBUG_BLOCK - ContentFetcher* http = (ContentFetcher*) sender(); - disconnect( http, SIGNAL(responseHeaderReceived(QHttpResponseHeader)) - , this, SLOT(loginHeaderReceived(QHttpResponseHeader)) ); - if( resp.statusCode() == 401 /*authorization required*/) - { - emit passwordRequired(); - http->deleteLater(); - return; - } - connect( http, SIGNAL(requestFinished(int,bool)), this, SLOT(loginFinished(int,bool)) ); -} - - -void -Reader::loginFinished( int /* id */, bool error ) -{ - DEBUG_BLOCK - ContentFetcher* http = (ContentFetcher*) sender(); - disconnect( http, SIGNAL(requestFinished(int,bool)), this, SLOT(loginFinished(int,bool)) ); - if( error ) - { - http->deleteLater(); - return; - } - QDataStream raw( http->results() ); - Map loginResults = parse( raw ); - QVariantList list = loginResults.value( "mlog" ).toList(); - debug() << "list size is " << list.size(); - QVariantList innerList = list.value( 0 ).toMap().value( "mlid" ).toList(); - debug() << "innerList size is " << innerList.size(); - if( innerList.isEmpty() ) - { - http->deleteLater(); - return; - } - m_sessionId = innerList.value( 0 ).toInt(); - m_loginString = "session-id=" + QString::number( m_sessionId ); - connect( http, SIGNAL(requestFinished(int,bool)), this, SLOT(updateFinished(int,bool)) ); - http->getDaap( "/update?" + m_loginString ); -} - -void -Reader::updateFinished( int /*id*/, bool error ) -{ - DEBUG_BLOCK - ContentFetcher* http = (ContentFetcher*) sender(); - disconnect( http, SIGNAL(requestFinished(int,bool)), this, SLOT(updateFinished(int,bool)) ); - if( error ) - { - http->deleteLater(); - warning() << "what is going on here? " << http->error(); - return; - } - - QDataStream raw( http->results() ); - Map updateResults = parse( raw ); - if( updateResults["mupd"].toList().isEmpty() ) - return; //error - if( updateResults["mupd"].toList()[0].toMap()["musr"].toList().isEmpty() ) - return; //error - m_loginString = m_loginString + "&revision-number=" + - QString::number( updateResults["mupd"].toList()[0].toMap()["musr"].toList()[0].toInt() ); - - connect( http, SIGNAL(requestFinished(int,bool)), this, SLOT(databaseIdFinished(int,bool)) ); - http->getDaap( "/databases?" + m_loginString ); -} - -void -Reader::databaseIdFinished( int /*id*/, bool error ) -{ - ContentFetcher* http = (ContentFetcher*) sender(); - disconnect( http, SIGNAL(requestFinished(int,bool)), this, SLOT(databaseIdFinished(int,bool)) ); - if( error ) - { - http->deleteLater(); - return; - } - - QDataStream raw( http->results() ); - Map dbIdResults = parse( raw ); - m_databaseId = QString::number( dbIdResults["avdb"].toList()[0].toMap()["mlcl"].toList()[0].toMap()["mlit"].toList()[0].toMap()["miid"].toList()[0].toInt() ); - connect( http, SIGNAL(requestFinished(int,bool)), this, SLOT(songListFinished(int,bool)) ); - http->getDaap( QString("/databases/%1/items?type=music&meta=dmap.itemid,dmap.itemname,daap.songformat,daap.songartist,daap.songalbum,daap.songtime,daap.songtracknumber,daap.songcomment,daap.songyear,daap.songgenre&%2") - .arg( m_databaseId, m_loginString ) ); - -} - -void -Reader::songListFinished( int /*id*/, bool error ) -{ - DEBUG_BLOCK - ContentFetcher* http = (ContentFetcher*) sender(); - disconnect( http, SIGNAL(requestFinished(int,bool)), this, SLOT(songListFinished(int,bool)) ); - if( error ) - { - http->deleteLater(); - return; - } - QByteArray result = http->results(); - http->deleteLater(); - - ThreadWeaver::Weaver::instance()->enqueue( new WorkerThread( result, this, m_memColl ) ); -} - -bool -Reader::parseSongList( const QByteArray &data, bool set_collection ) -{ - // The original implementation used parse(), which uses addElement() and - // makes heavy usage of QMaps and QList which hurts performance very badly. - // Therefore this function parses the daap responses directly into the - // DaapCollection which is 27 times faster here and saves a slight bit of - // heap space. - // parse() and addElement() create a more qt like structure though and might be - // kept for other daap tasks. - - DEBUG_BLOCK - QDataStream raw( data ); - - // Cache for music data - QString itemId; - QString format; - QString title; - QString artist; - QString composer; - QString comment; - QString album; - QString genre; - int year = 0; - qint32 trackNumber=0; - qint32 songTime=0; - - while( !raw.atEnd() ) - { - char rawTag[5]; - quint32 tagLength = getTagAndLength( raw, rawTag ); - - if( tagLength == 0 ) - continue; - - QVariant tagData = readTagData( raw, rawTag, tagLength ); - - if( !tagData.isValid() ) - continue; - - QString tag = QString( rawTag ); - - if( m_codes[tag].type == CONTAINER ) - { - parseSongList( tagData.toByteArray() ); - continue; - } - - if( tag == "astn" ) - trackNumber = tagData.toInt(); - else if( tag == "asyr" ) - year = tagData.toInt(); - else if( tag == "miid" ) - itemId = tagData.toString(); - else if(tag == "astm" ) - songTime = tagData.toInt(); - else if( tag== "asfm" ) - format = tagData.toString(); - else if( tag == "minm" ) - title = tagData.toString(); - else if( tag == "asal" ) - album = tagData.toString(); - else if( tag == "asar" ) - artist = tagData.toString(); - else if( tag == "ascp" ) - composer = tagData.toString(); - else if( tag == "ascm" ) - comment = tagData.toString(); - else if( tag == "asgn" ) - genre = tagData.toString(); - } - - if( !itemId.isEmpty() ) - addTrack( itemId, title, artist, composer, comment, album, genre, year, format, trackNumber, songTime ); - - if( set_collection ) - { - m_memColl->memoryCollection()->acquireWriteLock(); - m_memColl->memoryCollection()->setTrackMap( m_trackMap ); - m_memColl->memoryCollection()->setArtistMap( m_artistMap ); - m_memColl->memoryCollection()->setAlbumMap( m_albumMap ); - m_memColl->memoryCollection()->setGenreMap( m_genreMap ); - m_memColl->memoryCollection()->setComposerMap( m_composerMap ); - m_memColl->memoryCollection()->setYearMap( m_yearMap ); - m_memColl->memoryCollection()->releaseLock(); - m_trackMap.clear(); - m_artistMap.clear(); - m_albumMap.clear(); - m_genreMap.clear(); - m_composerMap.clear(); - m_yearMap.clear(); - } - return true; -} - -void -Reader::addTrack( const QString& itemId, const QString& title, const QString& artist, const QString& composer, - const QString& comment, const QString& album, const QString& genre, int year, const QString& format, - qint32 trackNumber, qint32 songTime ) -{ - DaapTrackPtr track( new DaapTrack( m_memColl, m_host, m_port, m_databaseId, itemId, format ) ); - track->setTitle( title ); - track->setLength( songTime ); - track->setTrackNumber( trackNumber ); - track->setComment( comment ); - track->setComposer( composer ); - - DaapArtistPtr artistPtr; - if ( m_artistMap.contains( artist ) ) - artistPtr = DaapArtistPtr::staticCast( m_artistMap.value( artist ) ); - else - { - artistPtr = DaapArtistPtr( new DaapArtist( artist ) ); - m_artistMap.insert( artist, ArtistPtr::staticCast( artistPtr ) ); - } - artistPtr->addTrack( track ); - track->setArtist( artistPtr ); - - DaapAlbumPtr albumPtr; - if ( m_albumMap.contains( album, artist ) ) - albumPtr = DaapAlbumPtr::staticCast( m_albumMap.value( album, artist ) ); - else - { - albumPtr = DaapAlbumPtr( new DaapAlbum( album ) ); - albumPtr->setAlbumArtist( artistPtr ); - m_albumMap.insert( AlbumPtr::staticCast( albumPtr ) ); - } - albumPtr->addTrack( track ); - track->setAlbum( albumPtr ); - - DaapComposerPtr composerPtr; - if ( m_composerMap.contains( composer ) ) - composerPtr = DaapComposerPtr::staticCast( m_composerMap.value( composer ) ); - else - { - composerPtr = DaapComposerPtr( new DaapComposer ( composer ) ); - m_composerMap.insert( composer, ComposerPtr::staticCast( composerPtr ) ); - } - composerPtr->addTrack( track ); - track->setComposer ( composerPtr ); - - DaapYearPtr yearPtr; - if ( m_yearMap.contains( year ) ) - yearPtr = DaapYearPtr::staticCast( m_yearMap.value( year ) ); - else - { - yearPtr = DaapYearPtr( new DaapYear( QString::number(year) ) ); - m_yearMap.insert( year, YearPtr::staticCast( yearPtr ) ); - } - yearPtr->addTrack( track ); - track->setYear( yearPtr ); - - DaapGenrePtr genrePtr; - if ( m_genreMap.contains( genre ) ) - genrePtr = DaapGenrePtr::staticCast( m_genreMap.value( genre ) ); - else - { - genrePtr = DaapGenrePtr( new DaapGenre( genre ) ); - m_genreMap.insert( genre, GenrePtr::staticCast( genrePtr ) ); - } - genrePtr->addTrack( track ); - track->setGenre( genrePtr ); - m_trackMap.insert( track->uidUrl(), TrackPtr::staticCast( track ) ); -} - - -quint32 -Reader::getTagAndLength( QDataStream &raw, char tag[5] ) -{ - tag[4] = 0; - raw.readRawData(tag, 4); - quint32 tagLength = 0; - raw >> tagLength; - return tagLength; -} - -QVariant -Reader::readTagData( QDataStream &raw, char *tag, quint32 tagLength) -{ - /** - * Consume tagLength bytes of data from the stream and convert it to the - * proper type, while making sure that datalength/datatype mismatches are handled properly - */ - - QVariant ret = QVariant(); - - if ( tagLength == 0 ) - return ret; - -#define READ_DATA(var) \ - DEBUGTAG( var ) \ - if( sizeof(var) != tagLength ) { \ - warning() << "Bad tag data length:" << tag << ":" << tagLength; \ - raw.skipRawData(tagLength); \ - break; \ - } else { \ - raw >> var ; \ - ret = QVariant(var); \ - } - switch( m_codes[tag].type ) - { - case CHAR: - { - qint8 charData; - READ_DATA( charData ) - break; - } - case SHORT: - { - qint16 shortData; - READ_DATA( shortData ) - break; - } - case LONG: - { - qint32 longData; - READ_DATA( longData ); - break; - } - case LONGLONG: - { - qint64 longlongData; - READ_DATA( longlongData ); - break; - } - case STRING: - { - QByteArray stringData( tagLength, ' ' ); - raw.readRawData( stringData.data(), tagLength ); - ret = QVariant(QString::fromUtf8( stringData, tagLength )); - DEBUGTAG( QString::fromUtf8( stringData, tagLength ) ) - break; - } - case DATE: - { - qint64 dateData; - READ_DATA( dateData ) - QDateTime date; - date.setTime_t( dateData ); - ret = QVariant( date ); - break; - } - case DVERSION: - { - qint32 verData; - READ_DATA( verData ) - QString version( "%1.%2.%3" ); - version = version.arg( verData >> 16, (verData >> 8) & 0xFF, verData & 0xFF); - ret = QVariant( version ); - break; - } - case CONTAINER: - { - QByteArray containerData( tagLength, ' ' ); - raw.readRawData( containerData.data(), tagLength ); - ret = QVariant( containerData ); - break; - } - default: - warning() << "Tag" << tag << "has unhandled type."; - raw.skipRawData(tagLength); - break; - } -#undef READ_DATA - return ret; -} - -Map -Reader::parse( QDataStream &raw ) -{ - DEBUG_BLOCK - /** - * http://daap.sourceforge.net/docs/index.html - * 0-3 Content code OSType (unsigned long), description of the contents of this chunk - * 4-7 Length Length of the contents of this chunk (not the whole chunk) - * 8- Data The data contained within the chunk - **/ - Map childMap; - while( !raw.atEnd() ) - { - char tag[5]; - quint32 tagLength = getTagAndLength( raw, tag ); - if( tagLength == 0 ) - continue; - - QVariant tagData = readTagData(raw, tag, tagLength); - if( !tagData.isValid() ) - continue; - - if( m_codes[tag].type == CONTAINER ) - { - QDataStream substream( tagData.toByteArray() ); - addElement( childMap, tag, QVariant( parse( substream ) ) ); - } - else - addElement( childMap, tag, tagData ); - } - return childMap; -} - -void -Reader::addElement( Map &parentMap, char* tag, QVariant element ) -{ - QList list; - Map::Iterator it = parentMap.find( tag ); - if ( it == parentMap.end() ) { - list.append( element ); - parentMap.insert( tag, QVariant( list ) ); - } else { - list = it.value().toList(); - list.append( element ); - it.value() = QVariant( list ); - } -} - -void -Reader::fetchingError( const QString& error ) -{ - DEBUG_BLOCK - const_cast< QObject* >( sender() )->deleteLater(); - emit httpError( error ); -} - -WorkerThread::WorkerThread( const QByteArray &data, Reader *reader, Collections::DaapCollection *coll ) - : ThreadWeaver::Job() - , m_success( false ) - , m_data( data ) - , m_reader( reader ) -{ - connect( this, SIGNAL(done(ThreadWeaver::Job*)), coll, SLOT(loadedDataFromServer()) ); - connect( this, SIGNAL(failed(ThreadWeaver::Job*)), coll, SLOT(parsingFailed()) ); - connect( this, SIGNAL(done(ThreadWeaver::Job*)), this, SLOT(deleteLater()) ); -} - -WorkerThread::~WorkerThread() -{ - //nothing to do -} - -bool -WorkerThread::success() const -{ - return m_success; -} - -void -WorkerThread::run() -{ - m_success = m_reader->parseSongList( m_data, true ); -} - -#include "moc_Reader.cpp" - diff --git a/amarok/src/core-impl/collections/daap/daapreader/Reader.h b/amarok/src/core-impl/collections/daap/daapreader/Reader.h deleted file mode 100644 index 331e89ac..00000000 --- a/amarok/src/core-impl/collections/daap/daapreader/Reader.h +++ /dev/null @@ -1,142 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2006 Ian Monroe * - * * - * This program 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 2 of the License, or (at your option) version 3 or * - * any later version accepted by the membership of KDE e.V. (or its successor approved * - * by the membership of KDE e.V.), which shall act as a proxy defined in Section 14 of * - * version 3 of the license. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef DAAPREADER_H -#define DAAPREADER_H - -#include - -#include -#include -#include "MemoryCollection.h" - -class QString; - -namespace Collections { - class DaapCollection; -} - -class QHttpResponseHeader; - -namespace Daap -{ - typedef QMap Map; - - enum ContentTypes { INVALID = 0, CHAR = 1, SHORT = 3, LONG = 5, LONGLONG = 7, - STRING = 9, DATE = 10, DVERSION = 11, CONTAINER = 12 }; - - struct Code - { - Code() : type(INVALID) { } - Code( const QString& nName, ContentTypes nType ) : name( nName ), type( nType ) { } - ~Code() { } - QString name; - ContentTypes type; - }; - - - - /** - The nucleus of the DAAP client; composes queries and parses responses. - @author Ian Monroe - */ - class Reader : public QObject - { - Q_OBJECT - - public: - Reader( Collections::DaapCollection *mc, const QString& host, quint16 port, const QString& password, QObject* parent, const char* name ); - ~Reader(); - - //QPtrList getSongList(); - enum Options { SESSION_ID = 1, SERVER_VERSION = 2 }; - void loginRequest(); - void logoutRequest(); - - int sessionId() const { return m_sessionId; } - QString host() const { return m_host; } - quint16 port() const { return m_port; } - - bool parseSongList( const QByteArray &data, bool set_collection = false); - public slots: - void logoutRequest(int, bool ); - void contentCodesReceived( int id , bool error ); - void loginHeaderReceived( const QHttpResponseHeader& resp ); - void loginFinished( int id , bool error ); - void updateFinished( int id , bool error ); - void databaseIdFinished( int id , bool error ); - void songListFinished( int id, bool error ); - void fetchingError( const QString& error ); - - signals: - //void daapBundles( const QString& host, Daap::SongList bundles ); - void httpError( const QString& ); - void passwordRequired(); - - private: - /** - * Make a map-vector tree out of the DAAP binary result - * @param raw stream of DAAP reply - * @param containerLength length of the container (or entire result) being analyzed - */ - Map parse( QDataStream &raw); - static void addElement( Map &parentMap, char* tag, QVariant element ); //!< supporter function for parse - static quint32 getTagAndLength( QDataStream &raw, char tag[5] ); - QVariant readTagData(QDataStream &, char[5], quint32); - void addTrack( const QString& itemId, const QString& title, const QString& artist, const QString& composer, - const QString& commment, const QString& album, const QString& genre, int year, - const QString& format, qint32 trackNumber, qint32 songTime ); - - QMap m_codes; - - Collections::DaapCollection *m_memColl; - QString m_host; - quint16 m_port; - QString m_loginString; - QString m_databaseId; - int m_sessionId; - QString m_password; - TrackMap m_trackMap; - ArtistMap m_artistMap; - AlbumMap m_albumMap; - GenreMap m_genreMap; - ComposerMap m_composerMap; - YearMap m_yearMap; - }; - - class WorkerThread : public ThreadWeaver::Job - { - Q_OBJECT - public: - WorkerThread( const QByteArray &data, Reader* reader, Collections::DaapCollection *coll ); - virtual ~WorkerThread(); - - virtual bool success() const; - - protected: - virtual void run(); - - private: - bool m_success; - QByteArray m_data; - Reader *m_reader; - }; - -} - -#endif diff --git a/amarok/src/core-impl/collections/daap/daapreader/authentication/contentfetcher.cpp b/amarok/src/core-impl/collections/daap/daapreader/authentication/contentfetcher.cpp deleted file mode 100644 index 054c4ce9..00000000 --- a/amarok/src/core-impl/collections/daap/daapreader/authentication/contentfetcher.cpp +++ /dev/null @@ -1,114 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2006 Ian Monroe * - * * - * This program 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 2 of the License, or (at your option) version 3 or * - * any later version accepted by the membership of KDE e.V. (or its successor approved * - * by the membership of KDE e.V.), which shall act as a proxy defined in Section 14 of * - * version 3 of the license. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "contentfetcher.h" -#include "core/support/Debug.h" -#include "hasher.h" - -#include -#include -#include - -#include -#include - -using namespace Daap; -int ContentFetcher::s_requestId = 10; - -ContentFetcher::ContentFetcher( const QString & hostname, quint16 port, const QString& password, QObject * parent, const char * name ) - : QHttp(hostname, port, parent) - , m_hostname( hostname ) - , m_port( port ) - , m_selfDestruct( false ) -{ - setObjectName( name ); - connect( this, SIGNAL(stateChanged(int)), this , SLOT(checkForErrors(int)) ); - QByteArray pass = password.toUtf8(); - if( !password.isNull() ) - { - m_authorize = "Basic " + KCodecs::base64Encode( "none:" + pass ); - } -} - -ContentFetcher::~ContentFetcher() -{ } - -QByteArray -ContentFetcher::results() -{ - QByteArray read = readAll(); - QHttpResponseHeader header = lastResponse(); - if( header.value( "Content-Encoding" ) == "gzip" ) - { - QBuffer* bytes = new QBuffer( &read ); - QIODevice* stream = KFilterDev::device( bytes, "application/x-gzip", false ); - if ( !stream->open( QIODevice::ReadOnly ) ) - return read; - - //do not assign directly to read, see the documentation of the QBuffer ctor - QByteArray filteredRead = stream->readAll(); - delete stream; - delete bytes; - read = filteredRead; - } - return read; -} - -void -ContentFetcher::getDaap( const QString & command, QIODevice* musicFile /*= 0*/ ) -{ - QHttpRequestHeader header( "GET", command ); - char hash[33] = {0}; - const char *cmd = command.toAscii(); - GenerateHash(3, reinterpret_cast( cmd ), 2, reinterpret_cast(hash), 0 /*s_requestId*/); - - if( !m_authorize.isEmpty() ) - { - header.setValue( "Authorization", m_authorize ); - } - - header.setValue( "Host", m_hostname + QString::number( m_port ) ); - header.setValue( "Client-DAAP-Request-ID", "0"/*QString::number( s_requestId )*/ ); - header.setValue( "Client-DAAP-Access-Index", "2" ); - header.setValue( "Client-DAAP-Validation", hash ); - header.setValue( "Client-DAAP-Version", "3.0" ); - header.setValue( "User-Agent", "iTunes/4.6 (Windows; N)" ); - header.setValue( "Accept", "*/*" ); - header.setValue( "Accept-Encoding", "gzip" ); - - request( header, 0, musicFile ); -} - -/** - * QHttp enjoys forgetting to emit a requestFinished when there's an error - * This gets around that. - */ -void -ContentFetcher::checkForErrors( int /*state*/ ) -{ - if( !m_selfDestruct && error() != 0 ) - { - debug() << "there is an error? " << error() << " " << errorString(); - m_selfDestruct = true; - emit httpError( errorString() ); - } -} - - -#include "moc_contentfetcher.cpp" - diff --git a/amarok/src/core-impl/collections/daap/daapreader/authentication/contentfetcher.h b/amarok/src/core-impl/collections/daap/daapreader/authentication/contentfetcher.h deleted file mode 100644 index d76463fd..00000000 --- a/amarok/src/core-impl/collections/daap/daapreader/authentication/contentfetcher.h +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2006 Ian Monroe * - * * - * This program 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 2 of the License, or (at your option) version 3 or * - * any later version accepted by the membership of KDE e.V. (or its successor approved * - * by the membership of KDE e.V.), which shall act as a proxy defined in Section 14 of * - * version 3 of the license. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef DAAPCONTENTFETCHER_H -#define DAAPCONTENTFETCHER_H - -#include -#include - -namespace Daap { - -/** - Inspired by a daapsharp class of the same name. Basically it adds all the silly headers - that DAAP needs - @author Ian Monroe -*/ -class ContentFetcher : public QHttp -{ - Q_OBJECT - - public: - ContentFetcher( const QString & hostname, quint16 port, const QString& password, QObject * parent = 0, const char * name = 0 ); - ~ContentFetcher(); - - void getDaap( const QString & command, QIODevice* musicFile = 0 ); - QByteArray results(); - - private slots: - void checkForErrors( int state ); - - signals: - void httpError( const QString& ); - - private: - QString m_hostname; - quint16 m_port; - QByteArray m_authorize; - bool m_selfDestruct; - static int s_requestId; //!< Apple needs this for some reason -}; - - - -} - -#endif diff --git a/amarok/src/core-impl/collections/daap/daapreader/authentication/hasher.c b/amarok/src/core-impl/collections/daap/daapreader/authentication/hasher.c deleted file mode 100644 index 66d541a3..00000000 --- a/amarok/src/core-impl/collections/daap/daapreader/authentication/hasher.c +++ /dev/null @@ -1,211 +0,0 @@ -/* Copyright (C) 2004 David Hammerton - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - * - */ - -#include -#include -#include "hasher.h" -#include "md5.h" - -static int staticHashDone = 0; -static unsigned char staticHash_42[256*65] = {0}; -static unsigned char staticHash_45[256*65] = {0}; - -static const unsigned char hexchars[] = "0123456789ABCDEF"; -static const char appleCopyright[] = "Copyright 2003 Apple Computer, Inc."; - -static size_t ustrlen(const unsigned char * str) { - - size_t i; - for (i = 0; str[i] != '\0'; ++i) ; - return i; -} - -static void DigestToString(const unsigned char *digest, unsigned char *string) -{ - int i; - for (i = 0; i < 16; ++i) - { - unsigned char tmp = digest[i]; - string[i*2+1] = hexchars[tmp & 0x0f]; - string[i*2] = hexchars[(tmp >> 4) & 0x0f]; - } -} - -static void GenerateStatic_42() -{ - MD5_CTX ctx; - unsigned char *p = staticHash_42; - int i; - unsigned char buf[16]; - - for (i = 0; i < 256; ++i) - { - OpenDaap_MD5Init(&ctx, 0); - -#define MD5_STRUPDATE(str) OpenDaap_MD5Update(&ctx, (const unsigned char*) str, strlen(str)) - - if ((i & 0x80) != 0) - MD5_STRUPDATE("Accept-Language"); - else - MD5_STRUPDATE("user-agent"); - - if ((i & 0x40) != 0) - MD5_STRUPDATE("max-age"); - else - MD5_STRUPDATE("Authorization"); - - if ((i & 0x20) != 0) - MD5_STRUPDATE("Client-DAAP-Version"); - else - MD5_STRUPDATE("Accept-Encoding"); - - if ((i & 0x10) != 0) - MD5_STRUPDATE("daap.protocolversion"); - else - MD5_STRUPDATE("daap.songartist"); - - if ((i & 0x08) != 0) - MD5_STRUPDATE("daap.songcomposer"); - else - MD5_STRUPDATE("daap.songdatemodified"); - - if ((i & 0x04) != 0) - MD5_STRUPDATE("daap.songdiscnumber"); - else - MD5_STRUPDATE("daap.songdisabled"); - - if ((i & 0x02) != 0) - MD5_STRUPDATE("playlist-item-spec"); - else - MD5_STRUPDATE("revision-number"); - - if ((i & 0x01) != 0) - MD5_STRUPDATE("session-id"); - else - MD5_STRUPDATE("content-codes"); -#undef MD5_STRUPDATE - - OpenDaap_MD5Final(&ctx, buf); - DigestToString(buf, p); - p += 65; - } -} - -static void GenerateStatic_45() -{ - MD5_CTX ctx; - unsigned char *p = staticHash_45; - int i; - unsigned char buf[16]; - - for (i = 0; i < 256; ++i) - { - OpenDaap_MD5Init(&ctx, 1); - -#define MD5_STRUPDATE(str) OpenDaap_MD5Update(&ctx, (const unsigned char*) str, strlen(str)) - - if ((i & 0x40) != 0) - MD5_STRUPDATE("eqwsdxcqwesdc"); - else - MD5_STRUPDATE("op[;lm,piojkmn"); - - if ((i & 0x20) != 0) - MD5_STRUPDATE("876trfvb 34rtgbvc"); - else - MD5_STRUPDATE("=-0ol.,m3ewrdfv"); - - if ((i & 0x10) != 0) - MD5_STRUPDATE("87654323e4rgbv "); - else - MD5_STRUPDATE("1535753690868867974342659792"); - - if ((i & 0x08) != 0) - MD5_STRUPDATE("Song Name"); - else - MD5_STRUPDATE("DAAP-CLIENT-ID:"); - - if ((i & 0x04) != 0) - MD5_STRUPDATE("111222333444555"); - else - MD5_STRUPDATE("4089961010"); - - if ((i & 0x02) != 0) - MD5_STRUPDATE("playlist-item-spec"); - else - MD5_STRUPDATE("revision-number"); - - if ((i & 0x01) != 0) - MD5_STRUPDATE("session-id"); - else - MD5_STRUPDATE("content-codes"); - - if ((i & 0x80) != 0) - MD5_STRUPDATE("IUYHGFDCXWEDFGHN"); - else - MD5_STRUPDATE("iuytgfdxwerfghjm"); - -#undef MD5_STRUPDATE - - OpenDaap_MD5Final(&ctx, buf); - DigestToString(buf, p); - p += 65; - } -} - -void GenerateHash(short version_major, - const unsigned char *url, unsigned char hashSelect, - unsigned char *outhash, - int request_id) -{ - unsigned char buf[16]; - MD5_CTX ctx; - - unsigned char *hashTable = (version_major == 3) ? - staticHash_45 : staticHash_42; - - if (!staticHashDone) - { - GenerateStatic_42(); - GenerateStatic_45(); - staticHashDone = 1; - } - - OpenDaap_MD5Init(&ctx, (version_major == 3) ? 1 : 0); - - OpenDaap_MD5Update(&ctx, url, ustrlen(url)); - OpenDaap_MD5Update(&ctx, (const unsigned char*) appleCopyright, strlen(appleCopyright)); - - OpenDaap_MD5Update(&ctx, &hashTable[hashSelect * 65], 32); - - if (request_id && version_major == 3) - { - char scribble[20]; - sprintf(scribble, "%u", request_id); - OpenDaap_MD5Update(&ctx, (unsigned char*) scribble, strlen(scribble)); - } - - OpenDaap_MD5Final(&ctx, buf); - DigestToString(buf, outhash); -} - diff --git a/amarok/src/core-impl/collections/daap/daapreader/authentication/hasher.h b/amarok/src/core-impl/collections/daap/daapreader/authentication/hasher.h deleted file mode 100644 index 628c2ecf..00000000 --- a/amarok/src/core-impl/collections/daap/daapreader/authentication/hasher.h +++ /dev/null @@ -1,34 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2004 David Hammerton * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef _HASHER_H -#define _HASHER_H - -#ifdef __cplusplus - extern "C" { -#endif - -void GenerateHash(short version_major, - const unsigned char *url, unsigned char hashSelect, - unsigned char *outhash, - int request_id); - -#ifdef __cplusplus - } -#endif - -#endif /* _HASHER_H */ - diff --git a/amarok/src/core-impl/collections/daap/daapreader/authentication/md5.c b/amarok/src/core-impl/collections/daap/daapreader/authentication/md5.c deleted file mode 100644 index 4e4047a8..00000000 --- a/amarok/src/core-impl/collections/daap/daapreader/authentication/md5.c +++ /dev/null @@ -1,288 +0,0 @@ -/* Parts Copyright 2004 David Hammerton - * Parts found in the public domain with no copyright claim. - * - * see rfc1321 - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - * - */ - -#include -#include "md5.h" - -/* -* This code implements the MD5 message-digest algorithm. -* The algorithm is due to Ron Rivest. This code was -* written by Colin Plumb in 1993, no copyright is claimed. -* This code is in the public domain; do with it what you wish. -* -* Equivalent code is available from RSA Data Security, Inc. -* This code has been tested against that, and is equivalent, -* except that you don't need to include two pages of legalese -* with every copy. -* -* To compute the message digest of a chunk of bytes, declare an MD5Context -* structure, pass it to OpenDaap_MD5Init, call OpenDaap_MD5Update as needed -* on buffers full of bytes, and then call OpenDaap_MD5Final, which will fill -* a supplied 16-byte array with the digest. -*/ -static void MD5Transform(uint32_t buf[4], uint32_t const in[16], int apple_ver); -/* for some reason we still have to reverse bytes on bigendian machines - * I don't really know why... but otherwise it fails.. - * Any MD5 gurus out there know why??? - */ -#if 0 /*ndef WORDS_BIGENDIAN was: HIGHFIRST */ -#define byteReverse(buf, len) /* Nothing */ -#else -static void byteReverse(unsigned char *buf, unsigned longs); - -#ifndef ASM_MD5 -/* -* Note: this code is harmless on little-endian machines. -*/ -static void byteReverse(unsigned char *buf, unsigned longs) -{ - uint32_t t; - do { - t = (uint32_t) ((unsigned) buf[3] << 8 | buf[2]) << 16 | - ((unsigned) buf[1] << 8 | buf[0]); - *(uint32_t *) buf = t; - buf += 4; - } while (--longs); -} -#endif -#endif - - -void OpenDaap_MD5Init(MD5_CTX *ctx, int apple_ver) -{ - memset(ctx, 0, sizeof(*ctx)); - ctx->buf[0] = 0x67452301; - ctx->buf[1] = 0xefcdab89; - ctx->buf[2] = 0x98badcfe; - ctx->buf[3] = 0x10325476; - - ctx->bits[0] = 0; - ctx->bits[1] = 0; - - ctx->apple_ver = apple_ver; -} - -void OpenDaap_MD5Update(MD5_CTX *ctx, unsigned char const *buf, unsigned int len) -{ - uint32_t t; - - /* Update bitcount */ - - t = ctx->bits[0]; - if ((ctx->bits[0] = t + ((uint32_t) len << 3)) < t) - ctx->bits[1]++; /* Carry from low to high */ - ctx->bits[1] += len >> 29; - - t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */ - - /* Handle any leading odd-sized chunks */ - - if (t) { - unsigned char *p = (unsigned char *) ctx->in + t; - - t = 64 - t; - if (len < t) { - memcpy(p, buf, len); - return; - } - memcpy(p, buf, t); - byteReverse(ctx->in, 16); - MD5Transform(ctx->buf, (uint32_t *) ctx->in, ctx->apple_ver); - buf += t; - len -= t; - } - /* Process data in 64-byte chunks */ - - while (len >= 64) { - memcpy(ctx->in, buf, 64); - byteReverse(ctx->in, 16); - MD5Transform(ctx->buf, (uint32_t *) ctx->in, ctx->apple_ver); - buf += 64; - len -= 64; - } - - /* Handle any remaining bytes of data. */ - - memcpy(ctx->in, buf, len); - -} - -void OpenDaap_MD5Final(MD5_CTX *ctx, unsigned char digest[16]) -{ - unsigned count; - unsigned char *p; - - /* Compute number of bytes mod 64 */ - count = (ctx->bits[0] >> 3) & 0x3F; - - /* Set the first char of padding to 0x80. This is safe since there is - always at least one byte free */ - p = ctx->in + count; - *p++ = 0x80; - - /* Bytes of padding needed to make 64 bytes */ - count = 64 - 1 - count; - - /* Pad out to 56 mod 64 */ - if (count < 8) { - /* Two lots of padding: Pad the first block to 64 bytes */ - memset(p, 0, count); - byteReverse(ctx->in, 16); - MD5Transform(ctx->buf, (uint32_t *) ctx->in, ctx->apple_ver); - - /* Now fill the next block with 56 bytes */ - memset(ctx->in, 0, 56); - } else { - /* Pad block to 56 bytes */ - memset(p, 0, count - 8); - } - byteReverse(ctx->in, 14); - - /* Append length in bits and transform */ - ((uint32_t *) ctx->in)[14] = ctx->bits[0]; - ((uint32_t *) ctx->in)[15] = ctx->bits[1]; - - MD5Transform(ctx->buf, (uint32_t *) ctx->in, ctx->apple_ver); - byteReverse((unsigned char *) ctx->buf, 4); - memcpy(digest, ctx->buf, 16); - memset(ctx, 0, sizeof(*ctx)); /* In case it's sensitive */ -} - -#ifndef ASM_MD5 - -/* The four core functions - F1 is optimized somewhat */ - -/* #define F1(x, y, z) (x & y | ~x & z) */ -#define F1(x, y, z) (z ^ (x & (y ^ z))) -#define F2(x, y, z) F1(z, x, y) -#define F3(x, y, z) (x ^ y ^ z) -#define F4(x, y, z) (y ^ (x | ~z)) - -/* This is the central step in the MD5 algorithm. */ -#define MD5STEP(f, w, x, y, z, data, s) \ -( w += f(x, y, z) + data, w = w<>(32-s), w += x ) - -/* -* The core of the MD5 algorithm, this alters an existing MD5 hash to reflect -* the addition of 16 longwords of new data. OpenDaap_MD5Update blocks the -* data and converts bytes into longwords for this routine. -*/ -static void MD5Transform(uint32_t buf[4], uint32_t const in[16], int apple_ver) -{ - uint32_t a, b, c, d; - - a = buf[0]; - b = buf[1]; - c = buf[2]; - d = buf[3]; - - MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7); - MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12); - MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17); - MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22); - MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7); - MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12); - MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17); - MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22); - MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7); - MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12); - MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17); - MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22); - MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7); - MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12); - MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17); - MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22); - - MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5); - MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9); - MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14); - MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20); - MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5); - MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9); - MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14); - MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20); - MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5); - MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9); - MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14); - - if (apple_ver == 1) - { - MD5STEP(F2, b, c, d, a, in[8] + 0x445a14ed, 20); - } - else - { - MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20); - } - MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5); - MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9); - MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14); - MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20); - - MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4); - MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11); - MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16); - MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23); - MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4); - MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11); - MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16); - MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23); - MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4); - MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11); - MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16); - MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23); - MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4); - MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11); - MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16); - MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23); - - MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6); - MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10); - MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15); - MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21); - MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6); - MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10); - MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15); - MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21); - MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6); - MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10); - MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15); - MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21); - MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6); - MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10); - MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15); - MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21); - - buf[0] += a; - buf[1] += b; - buf[2] += c; - buf[3] += d; -} - -#endif - - - diff --git a/amarok/src/core-impl/collections/daap/daapreader/authentication/md5.h b/amarok/src/core-impl/collections/daap/daapreader/authentication/md5.h deleted file mode 100644 index 8b81c542..00000000 --- a/amarok/src/core-impl/collections/daap/daapreader/authentication/md5.h +++ /dev/null @@ -1,39 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2006 Ian Monroe * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef __MD5_H__ -#define __MD5_H__ - -#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L -#include -#else -typedef unsigned int uint32_t; -#endif - -#include "portability.h" - -typedef struct { - uint32_t buf[4]; - uint32_t bits[2]; - unsigned char in[64]; - int apple_ver; -} MD5_CTX; - -void OpenDaap_MD5Init(MD5_CTX *, int apple_ver); -void OpenDaap_MD5Update(MD5_CTX *, const unsigned char *, unsigned int); -void OpenDaap_MD5Final(MD5_CTX *, unsigned char digest[16]); - -#endif /* __WINE_MD5_H__ */ diff --git a/amarok/src/core-impl/collections/daap/daapreader/authentication/portability.h b/amarok/src/core-impl/collections/daap/daapreader/authentication/portability.h deleted file mode 100644 index 7d630b08..00000000 --- a/amarok/src/core-impl/collections/daap/daapreader/authentication/portability.h +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2004 David Hammerton * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef _PORTABILITY_H -#define _PORTABILITY_H - -#if !defined(WIN32) /* POSIX */ - -#define SYSTEM_POSIX - -#include - -#if !defined(HAVE_U_INT64_T) && defined(HAVE_UINT64_T) - typedef uint64_t u_int64_t; -#endif -#if !defined(HAVE_U_INT32_T) && defined(HAVE_UINT32_T) - typedef uint32_t u_int32_t; -#endif -#if !defined(HAVE_U_INT16_T) && defined(HAVE_UINT16_T) - typedef uint16_t u_int16_t; -#endif -#if !defined(HAVE_U_INT8_T) && defined(HAVE_UINT8_T) - typedef uint8_t u_int8_t; -#endif - -#else /* WIN32 */ - -#define SYSTEM_WIN32 - -#include -#include -typedef INT64 int64_t; -typedef UINT64 u_int64_t; - -typedef signed int int32_t; -typedef unsigned int u_int32_t; - -typedef signed short int16_t; -typedef unsigned short u_int16_t; - -typedef signed char int8_t; -typedef unsigned char u_int8_t; - -#endif - -#endif /* _PORTABILITY_H */ diff --git a/amarok/src/core-impl/collections/db/CMakeLists.txt b/amarok/src/core-impl/collections/db/CMakeLists.txt deleted file mode 100644 index 37cfd98a..00000000 --- a/amarok/src/core-impl/collections/db/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -add_subdirectory( sql ) diff --git a/amarok/src/core-impl/collections/db/DatabaseCollection.cpp b/amarok/src/core-impl/collections/db/DatabaseCollection.cpp deleted file mode 100644 index 705892ad..00000000 --- a/amarok/src/core-impl/collections/db/DatabaseCollection.cpp +++ /dev/null @@ -1,249 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Maximilian Kossick * - * Copyright (c) 2007 Casey Link * - * Copyright (c) 2010 Jeff Mitchell * - * Copyright (c) 2013 Ralf Engels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "DatabaseCollection" - -#include "DatabaseCollection.h" - -#include "core/support/Debug.h" -#include "scanner/GenericScanManager.h" -#include "MountPointManager.h" - -using namespace Collections; - -DatabaseCollection::DatabaseCollection() - : Collection() - , m_mpm( 0 ) - , m_scanManager( 0 ) - , m_blockUpdatedSignalCount( 0 ) - , m_updatedSignalRequested( false ) -{ -} - -DatabaseCollection::~DatabaseCollection() -{ - delete m_mpm; -} - -QString -DatabaseCollection::collectionId() const -{ - return QLatin1String( "localCollection" ); -} - -QString -DatabaseCollection::prettyName() const -{ - return i18n( "Local Collection" ); -} - -KIcon -DatabaseCollection::icon() const -{ - return KIcon("drive-harddisk"); -} - -GenericScanManager* -DatabaseCollection::scanManager() const -{ - return m_scanManager; -} - -MountPointManager* -DatabaseCollection::mountPointManager() const -{ - Q_ASSERT( m_mpm ); - return m_mpm; -} - -void -DatabaseCollection::setMountPointManager( MountPointManager *mpm ) -{ - Q_ASSERT( mpm ); - - if( m_mpm ) - { - disconnect( mpm, SIGNAL(deviceAdded(int)), this, SLOT(slotDeviceAdded(int)) ); - disconnect( mpm, SIGNAL(deviceRemoved(int)), this, SLOT(slotDeviceRemoved(int)) ); - } - - m_mpm = mpm; - connect( mpm, SIGNAL(deviceAdded(int)), this, SLOT(slotDeviceAdded(int)) ); - connect( mpm, SIGNAL(deviceRemoved(int)), this, SLOT(slotDeviceRemoved(int)) ); -} - - -QStringList -DatabaseCollection::collectionFolders() const -{ - return mountPointManager()->collectionFolders(); -} - -void -DatabaseCollection::setCollectionFolders( const QStringList &folders ) -{ - mountPointManager()->setCollectionFolders( folders ); -} - - -void -DatabaseCollection::blockUpdatedSignal() -{ - QMutexLocker locker( &m_mutex ); - m_blockUpdatedSignalCount ++; -} - -void -DatabaseCollection::unblockUpdatedSignal() -{ - QMutexLocker locker( &m_mutex ); - - Q_ASSERT( m_blockUpdatedSignalCount > 0 ); - m_blockUpdatedSignalCount --; - - // check if meanwhile somebody had updated the collection - if( m_blockUpdatedSignalCount == 0 && m_updatedSignalRequested ) - { - m_updatedSignalRequested = false; - locker.unlock(); - emit updated(); - } -} - -void -DatabaseCollection::collectionUpdated() -{ - QMutexLocker locker( &m_mutex ); - if( m_blockUpdatedSignalCount == 0 ) - { - m_updatedSignalRequested = false; - locker.unlock(); - emit updated(); - } - else - { - m_updatedSignalRequested = true; - } -} - -bool -DatabaseCollection::hasCapabilityInterface( Capabilities::Capability::Type type ) const -{ - switch( type ) - { - case Capabilities::Capability::CollectionImport: - case Capabilities::Capability::CollectionScan: - return true; - default: - return Collection::hasCapabilityInterface( type ); - } -} - -Capabilities::Capability* -DatabaseCollection::createCapabilityInterface( Capabilities::Capability::Type type ) -{ - switch( type ) - { - case Capabilities::Capability::CollectionImport: - return new DatabaseCollectionImportCapability( this ); - case Capabilities::Capability::CollectionScan: - return new DatabaseCollectionScanCapability( this ); - default: - return Collection::createCapabilityInterface( type ); - } -} - -// --------- DatabaseCollectionScanCapability ------------- - -DatabaseCollectionScanCapability::DatabaseCollectionScanCapability( DatabaseCollection* collection ) - : m_collection( collection ) -{ - Q_ASSERT( m_collection ); -} - -DatabaseCollectionScanCapability::~DatabaseCollectionScanCapability() -{ } - -void -DatabaseCollectionScanCapability::startFullScan() -{ - QList urls; - foreach( const QString& path, m_collection->mountPointManager()->collectionFolders() ) - urls.append( KUrl::fromPath( path ) ); - - m_collection->scanManager()->requestScan( urls, GenericScanManager::FullScan ); -} - -void -DatabaseCollectionScanCapability::startIncrementalScan( const QString &directory ) -{ - if( directory.isEmpty() ) - { - QList urls; - foreach( const QString& path, m_collection->mountPointManager()->collectionFolders() ) - urls.append( KUrl::fromPath( path ) ); - - m_collection->scanManager()->requestScan( urls, GenericScanManager::UpdateScan ); - } - else - { - QList urls; - urls.append( KUrl::fromPath( directory ) ); - - m_collection->scanManager()->requestScan( urls, - GenericScanManager::PartialUpdateScan ); - } -} - -void -DatabaseCollectionScanCapability::stopScan() -{ - m_collection->scanManager()->abort(); -} - -// --------- DatabaseCollectionImportCapability ------------- - -DatabaseCollectionImportCapability::DatabaseCollectionImportCapability( DatabaseCollection* collection ) - : m_collection( collection ) -{ - Q_ASSERT( m_collection ); -} - -DatabaseCollectionImportCapability::~DatabaseCollectionImportCapability() -{ } - -void -DatabaseCollectionImportCapability::import( QIODevice *input, QObject *listener ) -{ - DEBUG_BLOCK - - if( listener ) - { - // TODO: change import capability to collection action - // TODO: why have listeners here and not for the scan capability - // TODO: showMessage does not longer work like this, the scan result processor is doing this - connect( m_collection->scanManager(), SIGNAL(succeeded()), - listener, SIGNAL(importSucceeded()) ); - connect( m_collection->scanManager(), SIGNAL(failed(QString)), - listener, SIGNAL(showMessage(QString)) ); - } - - m_collection->scanManager()->requestImport( input ); -} - diff --git a/amarok/src/core-impl/collections/db/DatabaseCollection.h b/amarok/src/core-impl/collections/db/DatabaseCollection.h deleted file mode 100644 index c338d9f6..00000000 --- a/amarok/src/core-impl/collections/db/DatabaseCollection.h +++ /dev/null @@ -1,158 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Maximilian Kossick * - * Copyright (c) 2007 Casey Link * - * Copyright (c) 2010 Jeff Mitchell * - * Copyright (c) 2013 Ralf Engels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_COLLECTION_DATABASECOLLECTION_H -#define AMAROK_COLLECTION_DATABASECOLLECTION_H - -#include "core/collections/Collection.h" -#include "core/capabilities/CollectionScanCapability.h" -#include "core/capabilities/CollectionImportCapability.h" - -#include - -#include - -typedef QHash TrackUrls; -typedef QHash > ChangedTrackUrls; - -class MountPointManager; -class GenericScanManager; - -namespace Collections { - -class CollectionLocation; -class DatabaseCollectionLocationFactory; - -/** The DatabaseCollection is intended to be a base class for all database backed primary collections. - * Primary collection implies that the basis for the collection is a file system. - * It also means that there is a scan manager that scans the file system and - * a mount point manager for the dynamic collection feature (we can blend out - * whole parts of the collection in case a drive is just unmounted). - */ -class DatabaseCollection : public Collections::Collection -{ - Q_OBJECT - - /** This property is important. CollectionSetup is using the property to - determine the folders covered by this collection (and also setting them) */ - Q_PROPERTY( QStringList collectionFolders - READ collectionFolders - WRITE setCollectionFolders - SCRIPTABLE false - DESIGNABLE false ) - - public: - /** Creates a new DatabaseCollection. - * @param storage The storage this collection should work on. It will be freed by the collection. - */ - DatabaseCollection(); - virtual ~DatabaseCollection(); - - virtual QString collectionId() const; - virtual QString prettyName() const; - virtual KIcon icon() const; - - virtual GenericScanManager *scanManager() const; - virtual MountPointManager *mountPointManager() const; - /** This set's the mount point manager which is actually only useful for testing. - * Note: The old MountPointManager is not deleted when the new one is set. - */ - virtual void setMountPointManager( MountPointManager *mpm ); - - virtual QStringList collectionFolders() const; - virtual void setCollectionFolders( const QStringList &folders ); - - /** - * Call this function to prevent the collection updated signal emitted. - * This function can be called in preparation of larger updates. - */ - void blockUpdatedSignal(); - - /** - * Unblocks one blockUpdatedSignal call. If collectionUpdated() has been called, - * when the update was blocked, update() will be emitted here. - */ - void unblockUpdatedSignal(); - - /** - * Emit updated if the signal. If it is blocked by blockUpdatedSignal(), it will - * be postponed until unblockUpdatedSignal() is called, but never discarded. - */ - void collectionUpdated(); - - virtual bool hasCapabilityInterface( Capabilities::Capability::Type type ) const; - virtual Capabilities::Capability* createCapabilityInterface( Capabilities::Capability::Type type ); - - public slots: - /** Dumps the complete database content. - * The content of all Amarok tables is dumped in a couple of files - * in the users homedirectory. - */ - virtual void dumpDatabaseContent() = 0; - - protected slots: - virtual void slotDeviceAdded( int id ) { Q_UNUSED( id ); }; - virtual void slotDeviceRemoved( int id ) { Q_UNUSED( id ); }; - - protected: - MountPointManager *m_mpm; - GenericScanManager *m_scanManager; - - int m_blockUpdatedSignalCount; - bool m_updatedSignalRequested; - QMutex m_mutex; -}; - -class DatabaseCollectionScanCapability : public Capabilities::CollectionScanCapability -{ - Q_OBJECT - public: - - DatabaseCollectionScanCapability( DatabaseCollection* collection ); - virtual ~DatabaseCollectionScanCapability(); - - virtual void startFullScan(); - virtual void startIncrementalScan( const QString &directory = QString() ); - virtual void stopScan(); - - private: - DatabaseCollection* m_collection; -}; - -class DatabaseCollectionImportCapability : public Capabilities::CollectionImportCapability -{ - Q_OBJECT - public: - - DatabaseCollectionImportCapability( DatabaseCollection* collection ); - virtual ~DatabaseCollectionImportCapability(); - - virtual void import( QIODevice *input, QObject *listener ); - - private: - DatabaseCollection* m_collection; -}; - - -} - -Q_DECLARE_METATYPE( TrackUrls ) -Q_DECLARE_METATYPE( ChangedTrackUrls ) - -#endif /* AMAROK_COLLECTION_DATABASECOLLECTION_H */ diff --git a/amarok/src/core-impl/collections/db/MountPointManager.cpp b/amarok/src/core-impl/collections/db/MountPointManager.cpp deleted file mode 100644 index 77a43c0b..00000000 --- a/amarok/src/core-impl/collections/db/MountPointManager.cpp +++ /dev/null @@ -1,416 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2006-2007 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "MountPointManager" - -#include "MountPointManager.h" - -#include "MediaDeviceCache.h" -#include "core/support/Amarok.h" -#include "core/support/Debug.h" -#include -#include "core-impl/collections/db/sql/device/massstorage/MassStorageDeviceHandler.h" -#include "core-impl/collections/db/sql/device/nfs/NfsDeviceHandler.h" -#include "core-impl/collections/db/sql/device/smb/SmbDeviceHandler.h" - -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -MountPointManager::MountPointManager( QObject *parent, SqlStorage *storage ) - : QObject( parent ) - , m_storage( storage ) - , m_ready( false ) -{ - DEBUG_BLOCK - setObjectName( "MountPointManager" ); - - if ( !Amarok::config( "Collection" ).readEntry( "DynamicCollection", true ) ) - { - debug() << "Dynamic Collection deactivated in amarokrc, not loading plugins, not connecting signals"; - m_ready = true; - handleMusicLocation(); - return; - } - - connect( MediaDeviceCache::instance(), SIGNAL(deviceAdded(QString)), SLOT(deviceAdded(QString)) ); - connect( MediaDeviceCache::instance(), SIGNAL(deviceRemoved(QString)), SLOT(deviceRemoved(QString)) ); - - createDeviceFactories(); -} - -void -MountPointManager::handleMusicLocation() -{ - // For users who were using QDesktopServices::MusicLocation exclusively up - // to v2.2.2, which did not store the location into config. - // and also for versions up to 2.7-git that did wrote the Use MusicLocation entry - - KConfigGroup folders = Amarok::config( "Collection Folders" ); - const QString entryKey( "Use MusicLocation" ); - if( !folders.hasKey( entryKey ) ) - return; // good, already solved, nothing to do - - // write the music location as another collection folder in this case - if( folders.readEntry( entryKey, false ) ) - { - const KUrl musicUrl = QDesktopServices::storageLocation( QDesktopServices::MusicLocation ); - const QString musicDir = musicUrl.toLocalFile( KUrl::RemoveTrailingSlash ); - const QDir dir( musicDir ); - if( dir.exists() && dir.isReadable() ) - { - QStringList currentFolders = collectionFolders(); - if( !currentFolders.contains( musicDir ) ) - setCollectionFolders( currentFolders << musicDir ); - } - } - - folders.deleteEntry( entryKey ); // get rid of it for good -} - -MountPointManager::~MountPointManager() -{ - DEBUG_BLOCK - - m_handlerMapMutex.lock(); - foreach( DeviceHandler *dh, m_handlerMap ) - delete dh; - m_handlerMapMutex.unlock(); - - // DeviceHandlerFactories are memory managed using QObject parentship -} - - -void -MountPointManager::createDeviceFactories() -{ - DEBUG_BLOCK - QList factories; - factories << new MassStorageDeviceHandlerFactory( this ); - factories << new NfsDeviceHandlerFactory( this ); - factories << new SmbDeviceHandlerFactory( this ); - foreach( DeviceHandlerFactory *factory, factories ) - { - debug() << "Initializing DeviceHandlerFactory of type:" << factory->type(); - if( factory->canCreateFromMedium() ) - m_mediumFactories.append( factory ); - else if (factory->canCreateFromConfig() ) - m_remoteFactories.append( factory ); - else //FIXME max: better error message - debug() << "Unknown DeviceHandlerFactory"; - } - - Solid::Predicate predicate = Solid::Predicate( Solid::DeviceInterface::StorageAccess ); - QList devices = Solid::Device::listFromQuery( predicate ); - foreach( const Solid::Device &device, devices ) - createHandlerFromDevice( device, device.udi() ); - - m_ready = true; - handleMusicLocation(); -} - -int -MountPointManager::getIdForUrl( const KUrl &url ) -{ - int mountPointLength = 0; - int id = -1; - m_handlerMapMutex.lock(); - foreach( DeviceHandler *dh, m_handlerMap ) - { - if ( url.path().startsWith( dh->getDevicePath() ) && mountPointLength < dh->getDevicePath().length() ) - { - id = m_handlerMap.key( dh ); - mountPointLength = dh->getDevicePath().length(); - } - } - m_handlerMapMutex.unlock(); - if ( mountPointLength > 0 ) - { - return id; - } - else - { - //default fallback if we could not identify the mount point. - //treat -1 as mount point / in all other methods - return -1; - } -} - -bool -MountPointManager::isMounted( const int deviceId ) const -{ - m_handlerMapMutex.lock(); - const bool result = m_handlerMap.contains( deviceId ); - m_handlerMapMutex.unlock(); - return result; -} - -QString -MountPointManager::getMountPointForId( const int id ) const -{ - QString mountPoint; - if ( isMounted( id ) ) - { - m_handlerMapMutex.lock(); - mountPoint = m_handlerMap[id]->getDevicePath(); - m_handlerMapMutex.unlock(); - } - else - //TODO better error handling - mountPoint = '/'; - return mountPoint; -} - -QString -MountPointManager::getAbsolutePath( const int deviceId, const QString& relativePath ) const -{ - // TODO: someone who clearly understands KUrl should clean this up. - KUrl rpath; - rpath.setPath( relativePath ); - KUrl absolutePath; - - // debug() << "id is " << deviceId << ", relative path is " << relativePath; - if ( deviceId == -1 ) - { -#ifdef Q_OS_WIN32 - absolutePath.setPath( rpath.toLocalFile() ); -#else - absolutePath.setPath( "/" ); - absolutePath.addPath( rpath.path() ); -#endif - absolutePath.cleanPath(); - // debug() << "Deviceid is -1, using relative Path as absolute Path, returning " << absolutePath.path(); - } - else - { - m_handlerMapMutex.lock(); - if ( m_handlerMap.contains( deviceId ) ) - { - m_handlerMap[deviceId]->getURL( absolutePath, rpath ); - m_handlerMapMutex.unlock(); - } - else - { - m_handlerMapMutex.unlock(); - const QStringList lastMountPoint = m_storage->query( - QString( "SELECT lastmountpoint FROM devices WHERE id = %1" ) - .arg( deviceId ) ); - if ( lastMountPoint.count() == 0 ) - { - //hmm, no device with that id in the DB...serious problem - warning() << "Device " << deviceId << " not in database, this should never happen!"; - return getAbsolutePath( -1, relativePath ); - } - else - { - absolutePath.setPath( lastMountPoint.first() ); - absolutePath.addPath( rpath.path() ); - absolutePath.cleanPath(); - //debug() << "Device " << deviceId << " not mounted, using last mount point and returning " << absolutePath.path(); - } - } - } - - #ifdef Q_OS_WIN32 - return absolutePath.toLocalFile(); - #else - return absolutePath.path(); - #endif -} - -QString -MountPointManager::getRelativePath( const int deviceId, const QString& absolutePath ) const -{ - QMutexLocker locker(&m_handlerMapMutex); - if ( deviceId != -1 && m_handlerMap.contains( deviceId ) ) - { - //FIXME max: returns garbage if the absolute path is actually not under the device's mount point - return KUrl::relativePath( m_handlerMap[deviceId]->getDevicePath(), absolutePath ); - } - else - { - //TODO: better error handling -#ifdef Q_OS_WIN32 - return KUrl( absolutePath ).toLocalFile(); -#else - return KUrl::relativePath( "/", absolutePath ); -#endif - } -} - -IdList -MountPointManager::getMountedDeviceIds() const -{ - m_handlerMapMutex.lock(); - IdList list( m_handlerMap.keys() ); - m_handlerMapMutex.unlock(); - list.append( -1 ); - return list; -} - -QStringList -MountPointManager::collectionFolders() const -{ - if( !m_ready ) - { - debug() << "requested collectionFolders from MountPointManager that is not yet ready"; - return QStringList(); - } - - //TODO max: cache data - QStringList result; - KConfigGroup folders = Amarok::config( "Collection Folders" ); - const IdList ids = getMountedDeviceIds(); - - foreach( int id, ids ) - { - const QStringList rpaths = folders.readEntry( QString::number( id ), QStringList() ); - foreach( const QString &strIt, rpaths ) - { - const KUrl url = ( strIt == "./" ) ? getMountPointForId( id ) : getAbsolutePath( id, strIt ); - const QString absPath = url.toLocalFile( KUrl::RemoveTrailingSlash ); - if ( !result.contains( absPath ) ) - result.append( absPath ); - } - } - - return result; -} - -void -MountPointManager::setCollectionFolders( const QStringList &folders ) -{ - typedef QMap FolderMap; - KConfigGroup folderConf = Amarok::config( "Collection Folders" ); - FolderMap folderMap; - - foreach( const QString &folder, folders ) - { - int id = getIdForUrl( folder ); - const QString rpath = getRelativePath( id, folder ); - if( folderMap.contains( id ) ) { - if( !folderMap[id].contains( rpath ) ) - folderMap[id].append( rpath ); - } - else - folderMap[id] = QStringList( rpath ); - } - //make sure that collection folders on devices which are not in foldermap are deleted - IdList ids = getMountedDeviceIds(); - foreach( int deviceId, ids ) - { - if( !folderMap.contains( deviceId ) ) - { - folderConf.deleteEntry( QString::number( deviceId ) ); - } - } - QMapIterator i( folderMap ); - while( i.hasNext() ) - { - i.next(); - folderConf.writeEntry( QString::number( i.key() ), i.value() ); - } -} - -void -MountPointManager::deviceAdded( const QString &udi ) -{ - DEBUG_BLOCK - Solid::Predicate predicate = Solid::Predicate( Solid::DeviceInterface::StorageAccess ); - QList devices = Solid::Device::listFromQuery( predicate ); - //Looking for a specific udi in predicate seems flaky/buggy; the foreach loop barely - //takes any time, so just be safe - bool found = false; - debug() << "looking for udi " << udi; - foreach( const Solid::Device &device, devices ) - { - if( device.udi() == udi ) - { - createHandlerFromDevice( device, udi ); - found = true; - } - } - if( !found ) - debug() << "Did not find device from Solid for udi " << udi; -} - -void -MountPointManager::deviceRemoved( const QString &udi ) -{ - DEBUG_BLOCK - m_handlerMapMutex.lock(); - foreach( DeviceHandler *dh, m_handlerMap ) - { - if( dh->deviceMatchesUdi( udi ) ) - { - int key = m_handlerMap.key( dh ); - m_handlerMap.remove( key ); - delete dh; - debug() << "removed device " << key; - m_handlerMapMutex.unlock(); - //we found the medium which was removed, so we can abort the loop - emit deviceRemoved( key ); - return; - } - } - m_handlerMapMutex.unlock(); -} - -void MountPointManager::createHandlerFromDevice( const Solid::Device& device, const QString &udi ) -{ - DEBUG_BLOCK - if ( device.isValid() ) - { - debug() << "Device added and mounted, checking handlers"; - foreach( DeviceHandlerFactory *factory, m_mediumFactories ) - { - if( factory->canHandle( device ) ) - { - debug() << "found handler for " << udi; - DeviceHandler *handler = factory->createHandler( device, udi, m_storage ); - if( !handler ) - { - debug() << "Factory " << factory->type() << "could not create device handler"; - break; - } - int key = handler->getDeviceID(); - m_handlerMapMutex.lock(); - if( m_handlerMap.contains( key ) ) - { - debug() << "Key " << key << " already exists in handlerMap, replacing"; - delete m_handlerMap[key]; - m_handlerMap.remove( key ); - } - m_handlerMap.insert( key, handler ); - m_handlerMapMutex.unlock(); -// debug() << "added device " << key << " with mount point " << volumeAccess->mountPoint(); - emit deviceAdded( key ); - break; //we found the added medium and don't have to check the other device handlers - } - else - debug() << "Factory can't handle device " << udi; - } - } - else - debug() << "Device not valid!"; -} diff --git a/amarok/src/core-impl/collections/db/MountPointManager.h b/amarok/src/core-impl/collections/db/MountPointManager.h deleted file mode 100644 index 4e588d7a..00000000 --- a/amarok/src/core-impl/collections/db/MountPointManager.h +++ /dev/null @@ -1,231 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2006-2007 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_MOUNTPOINTMANAGER_H -#define AMAROK_MOUNTPOINTMANAGER_H - -#include "core-impl/collections/db/sql/amarok_sqlcollection_export.h" - -#include - -#include -#include -#include - -class DeviceHandler; -class DeviceHandlerFactory; -class SqlStorage; -class KUrl; -namespace Solid { - class Device; -} - -typedef QList IdList; -typedef QList FactoryList; -typedef QMap HandlerMap; - -class DeviceHandlerFactory : public QObject -{ - Q_OBJECT - -public: - DeviceHandlerFactory( QObject *parent ) : QObject( parent ) {} - virtual ~DeviceHandlerFactory() {} - - /** - * checks whether a DeviceHandler subclass can handle a given Medium. - * @param volume the connected solid volume - * @return true if the DeviceHandler implementation can handle the medium, - * false otherwise - */ - virtual bool canHandle( const Solid::Device &device ) const = 0; - - /** - * tells the MountPointManager whether it makes sense to ask the factory to - * create a Devicehandler when a new Medium was connected - * @return true if the factory can create DeviceHandlers from Medium instances - */ - virtual bool canCreateFromMedium() const = 0; - - /** - * creates a DeviceHandler which represents the Medium. - * @param volume the Volume for which a DeviceHandler is required - * @return a DeviceHandler or 0 if the factory cannot handle the Medium - */ - virtual DeviceHandler* createHandler( const Solid::Device &device, const QString &udi, SqlStorage *s ) const = 0; - - virtual bool canCreateFromConfig() const = 0; - - virtual DeviceHandler* createHandler( KSharedConfigPtr c, SqlStorage *s ) const = 0; - - /** - * returns the type of the DeviceHandler. Should be the same as the value used in - * ~/.kde/share/config/amarokrc - * @return a QString describing the type of the DeviceHandler - */ - virtual QString type() const = 0; -}; - -class DeviceHandler -{ -public: - DeviceHandler() {} - virtual ~DeviceHandler() {} - - - virtual bool isAvailable() const = 0; - - /** - * returns the type of the DeviceHandler. Should be the same as the value used in - * ~/.kde/share/config/amarokrc - * @return a QString describing the type of the DeviceHandler - */ - virtual QString type() const = 0; - - /** - * returns an absolute path which is guaranteed to be playable by amarok's current engine. (based on an - * idea by andrewt512: this method would only be called when we actually want to play the file, not when we - * simply want to show it to the user. It could for example download a file using KIO and return a path to a - * temporary file. Needs some more thought and is not actually used at the moment. - * @param absolutePath - * @param relativePath - */ - virtual void getPlayableURL( KUrl &absolutePath, const KUrl &relativePath ) = 0; - - /** - * builds an absolute path from a relative path and DeviceHandler specific information. The absolute path - * is not necessarily playable! (based on an idea by andrewt512: allows better handling of files stored in remote * collections. this method would return a "pretty" URL which might not be playable by amarok's engines. - * @param absolutePath the not necessarily playbale absolute path - * @param relativePath the device specific relative path - */ - virtual void getURL( KUrl &absolutePath, const KUrl &relativePath ) = 0; - - /** - * retrieves the unique database id of a given Medium. Implementations are responsible - * for generating a (sufficiently) unique value which identifies the Medium. - * Additionally, implementations must recognize unknown mediums and store the necessary - * information to recognize them the next time they are connected in the database. - * @return unique identifier which can be used as a foreign key to the media table. - */ - virtual int getDeviceID() = 0; - - virtual const QString &getDevicePath() const = 0; - - /** - * allows MountPointManager to check if a device handler handles a specific medium. - * @param m - * @return true if the device handler handles the Medium m - */ - virtual bool deviceMatchesUdi( const QString &udi ) const = 0; -}; - -/** - * @author Maximilian Kossick - */ -class AMAROK_SQLCOLLECTION_EXPORT MountPointManager : public QObject -{ - Q_OBJECT - -public: - MountPointManager( QObject *parent, SqlStorage *storage ); - ~MountPointManager(); - - /** - * - * @param url - * @return - */ - virtual int getIdForUrl( const KUrl &url ); - - /** - * - * @param id - * @return - */ - virtual QString getMountPointForId( const int id ) const; - - /** - * builds the absolute path from the mount point of the medium and the given relative - * path. - * @param deviceId the medium(device)'s unique id - * @param relativePath relative path on the medium - * @return the absolute path - */ - virtual QString getAbsolutePath( const int deviceId, const QString& relativePath ) const; - - /** - * calculates a file's/directory's relative path on a given device. - * @param deviceId the unique id which identifies the device the file/directory is supposed to be on - * @param absolutePath the file's/directory's absolute path - * @param relativePath the calculated relative path - */ - virtual QString getRelativePath( const int deviceId, const QString& absolutePath ) const; - - /** - * allows calling code to access the ids of all active devices - * @return the ids of all devices which are currently mounted or otherwise accessible - */ - virtual IdList getMountedDeviceIds() const; - - virtual QStringList collectionFolders() const; - virtual void setCollectionFolders( const QStringList &folders ); - -signals: - void deviceAdded( int id ); - void deviceRemoved( int id ); - -private: - void createDeviceFactories(); - - /** - * Old Amarok versions used to have "Use MusicLocation" config option which caused - * problems (bug 316216). This method converts out of it and needs to be run after - * MountPointManager has initialized. - */ - void handleMusicLocation(); - - /** - * checks whether a medium identified by its unique database id is currently mounted. - * Note: does not handle deviceId = -1! It only checks real devices - * @param deviceId the mediums unique id - * @return true if the medium is mounted, false otherwise - */ - bool isMounted ( const int deviceId ) const; - - SqlStorage *m_storage; - /** - * maps a device id to a mount point. does only work for mountable filesystems and needs to be - * changed for the real Dynamic Collection implementation. - */ - HandlerMap m_handlerMap; - mutable QMutex m_handlerMapMutex; - FactoryList m_mediumFactories; - FactoryList m_remoteFactories; - bool m_ready; - -//Solid specific - void createHandlerFromDevice( const Solid::Device &device, const QString &udi ); -private slots: - void deviceAdded( const QString &udi ); - void deviceRemoved( const QString &udi ); - -}; - -#define AMAROK_EXPORT_DEVICE_PLUGIN(libname, classname) \ -K_PLUGIN_FACTORY(factory, registerPlugin();) \ -K_EXPORT_PLUGIN(factory("amarok_device_" #libname))\ - -#endif diff --git a/amarok/src/core-impl/collections/db/sql/CMakeLists.txt b/amarok/src/core-impl/collections/db/sql/CMakeLists.txt deleted file mode 100644 index ea46509f..00000000 --- a/amarok/src/core-impl/collections/db/sql/CMakeLists.txt +++ /dev/null @@ -1,46 +0,0 @@ -set( amarok_collection-sqlcollection_SRCS - SqlCapabilities.cpp - DatabaseUpdater.cpp - ../DatabaseCollection.cpp - ../MountPointManager.cpp - SqlCollection.cpp - SqlCollectionFactory.cpp - SqlCollectionLocation.cpp - SqlQueryMaker.cpp - SqlQueryMakerInternal.cpp - SqlReadLabelCapability.cpp - SqlRegistry.cpp - SqlRegistry_p.cpp - SqlMeta.cpp - SqlWriteLabelCapability.cpp - SqlScanResultProcessor.cpp - device/massstorage/MassStorageDeviceHandler.cpp - device/nfs/NfsDeviceHandler.cpp - device/smb/SmbDeviceHandler.cpp -) - -add_library(amarok-sqlcollection SHARED ${amarok_collection-sqlcollection_SRCS}) - -target_link_libraries(amarok-sqlcollection - ${KDE4_KDECORE_LIBS} - ${KDE4_KDEUI_LIBS} - ${KDE4_KIO_LIBS} - ${KDE4_SOLID_LIBRARY} - ${KDE4_THREADWEAVER_LIBS} - ${QT_QTCORE_LIBRARY} - ${QT_QTGUI_LIBRARY} - ${CMAKE_THREAD_LIBS_INIT} - amarokcore - amaroklib - amarok-transcoding - amarokshared -) - -if(APPLE) - SET_TARGET_PROPERTIES(amarok-sqlcollection PROPERTIES LINK_FLAGS "-undefined dynamic_lookup") -endif(APPLE) - -set_target_properties(amarok-sqlcollection PROPERTIES VERSION 1.0.0 SOVERSION 1 ) -install(TARGETS amarok-sqlcollection ${INSTALL_TARGETS_DEFAULT_ARGS} ) - -add_subdirectory( mysqlcollection ) diff --git a/amarok/src/core-impl/collections/db/sql/DatabaseUpdater.cpp b/amarok/src/core-impl/collections/db/sql/DatabaseUpdater.cpp deleted file mode 100644 index 16e83a37..00000000 --- a/amarok/src/core-impl/collections/db/sql/DatabaseUpdater.cpp +++ /dev/null @@ -1,1097 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "DatabaseUpdater.h" - -#include "amarokconfig.h" -#include "core/support/Debug.h" -#include -#include "SqlCollection.h" - -#include -#include -#include -#include -#include - -#include -#include - -static const int DB_VERSION = 15; - -int -DatabaseUpdater::expectedDatabaseVersion() -{ - return DB_VERSION; -} - -DatabaseUpdater::DatabaseUpdater( Collections::SqlCollection *collection ) - : m_collection( collection ) - , m_debugDatabaseContent( false ) -{ - m_debugDatabaseContent = KGlobal::config()->group( "SqlCollection" ).readEntry( "DebugDatabaseContent", false ); -} - -DatabaseUpdater::~DatabaseUpdater() -{ - //nothing to do -} - -bool -DatabaseUpdater::needsUpdate() const -{ - return adminValue( "DB_VERSION" ) != DB_VERSION; -} - -bool -DatabaseUpdater::schemaExists() const -{ - return adminValue( "DB_VERSION" ) != 0; -} - -bool -DatabaseUpdater::update() -{ - DEBUG_BLOCK - int dbVersion = adminValue( "DB_VERSION" ); - - debug() << "Database version: " << dbVersion; - - if( dbVersion == 0 ) - { - createTables(); - QString query = QString( "INSERT INTO admin(component, version) VALUES ('DB_VERSION', %1);" ).arg( DB_VERSION ); - m_collection->sqlStorage()->query( query ); - return true; - } - - if( dbVersion < DB_VERSION ) - { - debug() << "Database out of date: database version is" << dbVersion << ", current version is" << DB_VERSION; - switch( dbVersion ) - { - case 1: - upgradeVersion1to2(); - case 2: - upgradeVersion2to3(); - case 3: - upgradeVersion3to4(); - case 4: - upgradeVersion4to5(); - case 5: - upgradeVersion5to6(); - case 6: - upgradeVersion6to7(); - case 7: - upgradeVersion7to8(); - case 8: - //removes stray rows from albums that were caused by the initial full scan - upgradeVersion8to9(); - case 9: - //removes stray rows from albums that were caused by the initial full scan - upgradeVersion9to10(); - case 10: - upgradeVersion10to11(); - case 11: - upgradeVersion11to12(); - case 12: - upgradeVersion12to13(); - case 13: - upgradeVersion13to14(); - case 14: - upgradeVersion14to15(); - dbVersion = 15; // be sure to update this manually when introducing new version! - } - - QString query = QString( "UPDATE admin SET version = %1 WHERE component = 'DB_VERSION';" ).arg( dbVersion ); - m_collection->sqlStorage()->query( query ); - - //NOTE: A rescan will be triggered automatically as a result of an upgrade. Don't trigger it here, as the - //collection isn't fully initialized and this will trigger a crash/assert. - return true; - } - - if( dbVersion > DB_VERSION ) - { - KMessageBox::error(0, - "

The Amarok collection database was created by a newer version of Amarok, " - "and this version of Amarok cannot use it.

", - "Database Type Unknown"); - // FIXME: maybe we should tell them how to delete the database? - // FIXME: exit() may be a little harsh, but QCoreApplication::exit() doesn't seem to work - exit(1); - } - - return false; -} - -void -DatabaseUpdater::upgradeVersion1to2() -{ - DEBUG_BLOCK - - m_collection->sqlStorage()->query( "ALTER TABLE tracks " - "ADD COLUMN albumgain FLOAT, " - "ADD COLUMN albumpeakgain FLOAT, " - "ADD COLUMN trackgain FLOAT," - "ADD COLUMN trackpeakgain FLOAT;" ); -} - -void -DatabaseUpdater::upgradeVersion2to3() -{ - DEBUG_BLOCK; - - SqlStorage *storage = m_collection->sqlStorage(); - storage->query( "DROP TABLE devices;" ); - - QString create = "CREATE TABLE devices " - "(id " + storage->idType() + - ",type " + storage->textColumnType() + - ",label " + storage->textColumnType() + - ",lastmountpoint " + storage->textColumnType() + - ",uuid " + storage->textColumnType() + - ",servername " + storage->textColumnType() + - ",sharename " + storage->textColumnType() + ");"; - storage->query( create ); - storage->query( "CREATE INDEX devices_type ON devices( type );" ); - storage->query( "CREATE UNIQUE INDEX devices_uuid ON devices( uuid );" ); - storage->query( "CREATE INDEX devices_rshare ON devices( servername, sharename );" ); - -} - -void -DatabaseUpdater::upgradeVersion3to4() -{ - SqlStorage *storage = m_collection->sqlStorage(); - - storage->query( "CREATE TABLE statistics_permanent " - "(url " + storage->exactTextColumnType() + - ",firstplayed DATETIME" - ",lastplayed DATETIME" - ",score FLOAT" - ",rating INTEGER DEFAULT 0" - ",playcount INTEGER)" ); - storage->query( "CREATE UNIQUE INDEX ON statistics_permanent(url)" ); - //Note: the above index query is invalid, but kept here for posterity - - storage->query( "CREATE TABLE statistics_tag " - "(name " + storage->textColumnType() + - ",artist " + storage->textColumnType() + - ",album " + storage->textColumnType() + - ",firstplayed DATETIME" - ",lastplayed DATETIME" - ",score FLOAT" - ",rating INTEGER DEFAULT 0" - ",playcount INTEGER)" ); - storage->query( "CREATE UNIQUE INDEX ON statistics_tag(name,artist,album)" ); - //Note: the above index query is invalid, but kept here for posterity -} - -void -DatabaseUpdater::upgradeVersion4to5() -{ - SqlStorage *storage = m_collection->sqlStorage(); - - //first the database - storage->query( "ALTER DATABASE amarok DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci" ); - - //now the tables - - //first, drop tables that can easily be recreated by doing an update - QStringList dropTables; - dropTables << "jamendo_albums" << "jamendo_artists" << "jamendo_genre" << "jamendo_tracks"; - dropTables << "magnatune_albums" << "magnatune_artists" << "magnatune_genre" << "magnatune_moods" << "magnatune_tracks"; - dropTables << "opmldirectory_albums" << "opmldirectory_artists" << "opmldirectory_genre" << "opmldirectory_tracks"; - - foreach( const QString &table, dropTables ) - storage->query( "DROP TABLE " + table ); - - //now, the rest of them - QStringList tables; - tables << "admin" << "albums" << "amazon" << "artists" << "bookmark_groups" << "bookmarks"; - tables << "composers" << "devices" << "directories" << "genres" << "images" << "labels" << "lyrics"; - tables << "playlist_groups" << "playlist_tracks" << "playlists"; - tables << "podcastchannels" << "podcastepisodes"; - tables << "statistics" << "statistics_permanent" << "statistics_tag"; - tables << "tracks" << "urls" << "urls_labels" << "years"; - - foreach( const QString &table, tables ) - storage->query( "ALTER TABLE " + table + " DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci" ); - - //now the columns (ugh) - //first, varchar - typedef QPair vcpair; - QMultiMap columns; - columns.insert( "admin", vcpair( "component", 255 ) ); - columns.insert( "albums", vcpair( "name", textColumnLength() ) ); - columns.insert( "amazon", vcpair( "asin", 20 ) ); - columns.insert( "amazon", vcpair( "locale", 2 ) ); - columns.insert( "amazon", vcpair( "filename", 33 ) ); - columns.insert( "artists", vcpair( "name", textColumnLength() ) ); - columns.insert( "bookmark_groups", vcpair( "name", 255 ) ); - columns.insert( "bookmark_groups", vcpair( "description", 255 ) ); - columns.insert( "bookmark_groups", vcpair( "custom", 255 ) ); - columns.insert( "bookmarks", vcpair( "name", 255 ) ); - columns.insert( "bookmarks", vcpair( "url", 1024 ) ); - columns.insert( "bookmarks", vcpair( "description", 1024 ) ); - columns.insert( "bookmarks", vcpair( "custom", 255 ) ); - columns.insert( "composers", vcpair( "name", textColumnLength() ) ); - columns.insert( "devices", vcpair( "type", 255 ) ); - columns.insert( "devices", vcpair( "label", 255 ) ); - columns.insert( "devices", vcpair( "lastmountpoint", 255 ) ); - columns.insert( "devices", vcpair( "uuid", 255 ) ); - columns.insert( "devices", vcpair( "servername", 255 ) ); - columns.insert( "devices", vcpair( "sharename", 255 ) ); - columns.insert( "directories", vcpair( "dir", 1024 ) ); - columns.insert( "genres", vcpair( "name", 255 ) ); - columns.insert( "images", vcpair( "path", 255 ) ); - columns.insert( "labels", vcpair( "label", textColumnLength() ) ); - columns.insert( "lyrics", vcpair( "url", 1024 ) ); - columns.insert( "playlist_groups", vcpair( "name", 255 ) ); - columns.insert( "playlist_groups", vcpair( "description", 255 ) ); - columns.insert( "playlist_tracks", vcpair( "url", 1024 ) ); - columns.insert( "playlist_tracks", vcpair( "title", 255 ) ); - columns.insert( "playlist_tracks", vcpair( "album", 255 ) ); - columns.insert( "playlist_tracks", vcpair( "artist", 255 ) ); - columns.insert( "playlist_tracks", vcpair( "uniqueid", 128 ) ); - columns.insert( "playlists", vcpair( "name", 255 ) ); - columns.insert( "playlists", vcpair( "description", 255 ) ); - columns.insert( "playlists", vcpair( "urlid", 1024 ) ); - columns.insert( "podcastchannels", vcpair( "copyright", 255 ) ); - columns.insert( "podcastchannels", vcpair( "directory", 255 ) ); - columns.insert( "podcastchannels", vcpair( "labels", 255 ) ); - columns.insert( "podcastchannels", vcpair( "subscribedate", 255 ) ); - columns.insert( "podcastepisodes", vcpair( "guid", 1024 ) ); - columns.insert( "podcastepisodes", vcpair( "mimetype", 255 ) ); - columns.insert( "podcastepisodes", vcpair( "pubdate", 255 ) ); - columns.insert( "statistics_permanent", vcpair( "url", 1024 ) ); - columns.insert( "statistics_tag", vcpair( "name", 255 ) ); - columns.insert( "statistics_tag", vcpair( "artist", 255 ) ); - columns.insert( "tracks", vcpair( "title", textColumnLength() ) ); - columns.insert( "urls", vcpair( "rpath", 1024 ) ); - columns.insert( "urls", vcpair( "uniqueid", 128 ) ); - columns.insert( "years", vcpair( "name", textColumnLength() ) ); - - QMultiMap::const_iterator i, iEnd; - for( i = columns.constBegin(), iEnd = columns.constEnd(); i != iEnd; ++i ) - { - storage->query( "ALTER TABLE " + i.key() + " MODIFY " + i.value().first + " VARBINARY(" + QString::number( i.value().second ) + ')' ); - storage->query( "ALTER IGNORE TABLE " + i.key() + " MODIFY " + i.value().first + - " VARCHAR(" + QString::number( i.value().second ) + ") CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL" ); - } - - columns.clear(); - - //text fields, not varchars - columns.insert( "lyrics", vcpair( "lyrics", 0 ) ); - columns.insert( "podcastchannels", vcpair( "url", 0 ) ); - columns.insert( "podcastchannels", vcpair( "title", 0 ) ); - columns.insert( "podcastchannels", vcpair( "weblink", 0 ) ); - columns.insert( "podcastchannels", vcpair( "image", 0 ) ); - columns.insert( "podcastchannels", vcpair( "description", 0 ) ); - columns.insert( "podcastepisodes", vcpair( "url", 0 ) ); - columns.insert( "podcastepisodes", vcpair( "localurl", 0 ) ); - columns.insert( "podcastepisodes", vcpair( "title", 0 ) ); - columns.insert( "podcastepisodes", vcpair( "subtitle", 0 ) ); - columns.insert( "podcastepisodes", vcpair( "description", 0 ) ); - columns.insert( "tracks", vcpair( "comment", 0 ) ); - - storage->query( "DROP INDEX url_podchannel ON podcastchannels" ); - storage->query( "DROP INDEX url_podepisode ON podcastepisodes" ); - storage->query( "DROP INDEX localurl_podepisode ON podcastepisodes" ); - for( i = columns.constBegin(), iEnd = columns.constEnd(); i != iEnd; ++i ) - { - storage->query( "ALTER TABLE " + i.key() + " MODIFY " + i.value().first + " BLOB" ); - storage->query( "ALTER IGNORE TABLE " + i.key() + " MODIFY " + i.value().first + " TEXT CHARACTER SET utf8 NOT NULL" ); - } - storage->query( "CREATE FULLTEXT INDEX url_podchannel ON podcastchannels( url )" ); - storage->query( "CREATE FULLTEXT INDEX url_podepisode ON podcastepisodes( url )" ); - storage->query( "CREATE FULLTEXT INDEX localurl_podepisode ON podcastepisodes( localurl )" ); -} - -void -DatabaseUpdater::upgradeVersion5to6() -{ - DEBUG_BLOCK - - SqlStorage *storage = m_collection->sqlStorage(); - - //first, drop tables that can easily be recreated by doing an update - QStringList dropTables; - dropTables << "jamendo_albums" << "jamendo_artists" << "jamendo_genre" << "jamendo_tracks"; - dropTables << "magnatune_albums" << "magnatune_artists" << "magnatune_genre" << "magnatune_moods" << "magnatune_tracks"; - dropTables << "opmldirectory_albums" << "opmldirectory_artists" << "opmldirectory_genre" << "opmldirectory_tracks"; - - foreach( const QString &table, dropTables ) - storage->query( "DROP TABLE " + table ); - - //now, the rest of them - QStringList tables; - tables << "admin" << "albums" << "amazon" << "artists" << "bookmark_groups" << "bookmarks"; - tables << "composers" << "devices" << "directories" << "genres" << "images" << "labels" << "lyrics"; - tables << "playlist_groups" << "playlist_tracks" << "playlists"; - tables << "podcastchannels" << "podcastepisodes"; - tables << "statistics" << "statistics_permanent" << "statistics_tag"; - tables << "tracks" << "urls" << "urls_labels" << "years"; - - foreach( const QString &table, tables ) - storage->query( "ALTER TABLE " + table + " ENGINE = MyISAM" ); - - typedef QPair vcpair; - QMultiMap columns; - columns.insert( "bookmarks", vcpair( "url", 1000 ) ); - columns.insert( "bookmarks", vcpair( "description", 1000 ) ); - columns.insert( "directories", vcpair( "dir", 1000 ) ); - columns.insert( "lyrics", vcpair( "url", 324 ) ); - columns.insert( "playlist_tracks", vcpair( "url", 1000 ) ); - columns.insert( "playlists", vcpair( "urlid", 1000 ) ); - columns.insert( "podcastepisodes", vcpair( "guid", 1000 ) ); - columns.insert( "statistics_permanent", vcpair( "url", 324 ) ); - columns.insert( "urls", vcpair( "rpath", 324 ) ); - columns.insert( "devices", vcpair( "servername", 80 ) ); - columns.insert( "devices", vcpair( "sharename", 240 ) ); - columns.insert( "statistics_tag", vcpair( "name", 108 ) ); - columns.insert( "statistics_tag", vcpair( "artist", 108 ) ); - columns.insert( "statistics_tag", vcpair( "album", 108 ) ); - - QMultiMap::const_iterator i, iEnd; - - for( i = columns.constBegin(), iEnd = columns.constEnd(); i != iEnd; ++i ) - storage->query( "ALTER IGNORE TABLE " + i.key() + " MODIFY " + i.value().first + " VARCHAR(" + QString::number( i.value().second ) + ") " ); - - storage->query( "CREATE INDEX devices_rshare ON devices( servername, sharename );" ); - storage->query( "CREATE UNIQUE INDEX lyrics_url ON lyrics(url);" ); - storage->query( "CREATE UNIQUE INDEX urls_id_rpath ON urls(deviceid, rpath);" ); - storage->query( "CREATE UNIQUE INDEX stats_tag_name_artist_album ON statistics_tag(name,artist,album)" ); -} - -void -DatabaseUpdater::upgradeVersion6to7() -{ - DEBUG_BLOCK - - SqlStorage *storage = m_collection->sqlStorage(); - - typedef QPair vcpair; - QMultiMap columns; - columns.insert( "directories", vcpair( "dir", 1000 ) ); - columns.insert( "urls", vcpair( "rpath", 324 ) ); - columns.insert( "statistics_permanent", vcpair( "url", 324 ) ); - - QMultiMap::const_iterator i, iEnd; - - for( i = columns.constBegin(), iEnd = columns.constEnd(); i != iEnd; ++i ) - { - storage->query( "ALTER IGNORE TABLE " + i.key() + " MODIFY " + i.value().first + - " VARCHAR(" + QString::number( i.value().second ) + ") COLLATE utf8_bin NOT NULL" ); - } - - columns.clear(); - -} - - -void -DatabaseUpdater::upgradeVersion7to8() -{ - DEBUG_BLOCK - - SqlStorage *storage = m_collection->sqlStorage(); - - QHash< int, int > trackLengthHash; - - // First, get the lengths from the db and insert them into a hash - const QStringList result = storage->query( "SELECT id, length FROM tracks" ); - - QListIterator iter(result); - while( iter.hasNext() ) - trackLengthHash.insert( iter.next().toInt(), iter.next().toInt() ); - - // Now Iterate over the hash, and insert each track back in, changing the length to milliseconds - QHashIterator iter2( trackLengthHash ); - const QString updateString = QString( "UPDATE tracks SET length=%1 WHERE id=%2 ;"); - while( iter2.hasNext() ) - { - iter2.next(); - debug() << "Running the following query: " << updateString.arg( QString::number( iter2.value() * 1000 ), QString::number( iter2.key() ) ); - storage->query( updateString.arg( QString::number( iter2.value() * 1000 ), QString::number( iter2.key() ) ) ); - } -} - -void -DatabaseUpdater::upgradeVersion8to9() -{ - deleteAllRedundant( "album" ); -} - -void -DatabaseUpdater::upgradeVersion9to10() -{ - DEBUG_BLOCK - - SqlStorage *storage = m_collection->sqlStorage(); - - //first the database - storage->query( "ALTER DATABASE amarok DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_bin" ); - - //now the tables - - //first, drop tables that can easily be recreated by doing an update - QStringList dropTables; - dropTables << "jamendo_albums" << "jamendo_artists" << "jamendo_genre" << "jamendo_tracks"; - dropTables << "magnatune_albums" << "magnatune_artists" << "magnatune_genre" << "magnatune_moods" << "magnatune_tracks"; - dropTables << "opmldirectory_albums" << "opmldirectory_artists" << "opmldirectory_genre" << "opmldirectory_tracks"; - - foreach( const QString &table, dropTables ) - storage->query( "DROP TABLE " + table ); - - //now, the rest of them - QStringList tables; - tables << "admin" << "albums" << "amazon" << "artists" << "bookmark_groups" << "bookmarks"; - tables << "composers" << "devices" << "directories" << "genres" << "images" << "labels" << "lyrics"; - tables << "playlist_groups" << "playlist_tracks" << "playlists"; - tables << "podcastchannels" << "podcastepisodes"; - tables << "statistics" << "statistics_permanent" << "statistics_tag"; - tables << "tracks" << "urls" << "urls_labels" << "years"; - - foreach( const QString &table, tables ) - storage->query( "ALTER TABLE " + table + " DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_bin COLLATE utf8_bin ENGINE = MyISAM" ); - - //now the columns (ugh) - //first, varchar - typedef QPair vcpair; - QMultiMap columns; - columns.insert( "admin", vcpair( "component", 255 ) ); - columns.insert( "albums", vcpair( "name", textColumnLength() ) ); - columns.insert( "amazon", vcpair( "asin", 20 ) ); - columns.insert( "amazon", vcpair( "locale", 2 ) ); - columns.insert( "amazon", vcpair( "filename", 33 ) ); - columns.insert( "artists", vcpair( "name", textColumnLength() ) ); - columns.insert( "bookmark_groups", vcpair( "name", 255 ) ); - columns.insert( "bookmark_groups", vcpair( "description", 255 ) ); - columns.insert( "bookmark_groups", vcpair( "custom", 255 ) ); - columns.insert( "bookmarks", vcpair( "name", 255 ) ); - columns.insert( "bookmarks", vcpair( "url", 1000 ) ); - columns.insert( "bookmarks", vcpair( "description", 1000 ) ); - columns.insert( "bookmarks", vcpair( "custom", 255 ) ); - columns.insert( "composers", vcpair( "name", textColumnLength() ) ); - columns.insert( "devices", vcpair( "type", 255 ) ); - columns.insert( "devices", vcpair( "label", 255 ) ); - columns.insert( "devices", vcpair( "lastmountpoint", 255 ) ); - columns.insert( "devices", vcpair( "uuid", 255 ) ); - columns.insert( "devices", vcpair( "servername", 80 ) ); - columns.insert( "devices", vcpair( "sharename", 240 ) ); - columns.insert( "directories", vcpair( "dir", 1000 ) ); - columns.insert( "genres", vcpair( "name", textColumnLength() ) ); - columns.insert( "images", vcpair( "path", 255 ) ); - columns.insert( "labels", vcpair( "label", textColumnLength() ) ); - columns.insert( "lyrics", vcpair( "url", 324 ) ); - columns.insert( "playlist_groups", vcpair( "name", 255 ) ); - columns.insert( "playlist_groups", vcpair( "description", 255 ) ); - columns.insert( "playlist_tracks", vcpair( "url", 1000 ) ); - columns.insert( "playlist_tracks", vcpair( "title", 255 ) ); - columns.insert( "playlist_tracks", vcpair( "album", 255 ) ); - columns.insert( "playlist_tracks", vcpair( "artist", 255 ) ); - columns.insert( "playlist_tracks", vcpair( "uniqueid", 128 ) ); - columns.insert( "playlists", vcpair( "name", 255 ) ); - columns.insert( "playlists", vcpair( "description", 255 ) ); - columns.insert( "playlists", vcpair( "urlid", 1000 ) ); - columns.insert( "podcastchannels", vcpair( "copyright", 255 ) ); - columns.insert( "podcastchannels", vcpair( "directory", 255 ) ); - columns.insert( "podcastchannels", vcpair( "labels", 255 ) ); - columns.insert( "podcastchannels", vcpair( "subscribedate", 255 ) ); - columns.insert( "podcastepisodes", vcpair( "guid", 1000 ) ); - columns.insert( "podcastepisodes", vcpair( "mimetype", 255 ) ); - columns.insert( "podcastepisodes", vcpair( "pubdate", 255 ) ); - columns.insert( "statistics_permanent", vcpair( "url", 324 ) ); - columns.insert( "statistics_tag", vcpair( "name", 108 ) ); - columns.insert( "statistics_tag", vcpair( "artist", 108 ) ); - columns.insert( "statistics_tag", vcpair( "album", 108 ) ); - columns.insert( "tracks", vcpair( "title", textColumnLength() ) ); - columns.insert( "urls", vcpair( "rpath", 324 ) ); - columns.insert( "urls", vcpair( "uniqueid", 128 ) ); - columns.insert( "years", vcpair( "name", textColumnLength() ) ); - - QMultiMap::const_iterator i, iEnd; - - for( i = columns.constBegin(), iEnd = columns.constEnd(); i != iEnd; ++i ) - { - storage->query( "ALTER TABLE " + i.key() + " MODIFY " + i.value().first + " VARBINARY(" + QString::number( i.value().second ) + ')' ); - storage->query( "ALTER IGNORE TABLE " + i.key() + " MODIFY " + i.value().first + - " VARCHAR(" + QString::number( i.value().second ) + ") CHARACTER SET utf8 COLLATE utf8_bin NOT NULL" ); - } - - storage->query( "CREATE INDEX devices_rshare ON devices( servername, sharename );" ); - storage->query( "CREATE UNIQUE INDEX lyrics_url ON lyrics(url);" ); - storage->query( "CREATE UNIQUE INDEX urls_id_rpath ON urls(deviceid, rpath);" ); - storage->query( "CREATE UNIQUE INDEX stats_tag_name_artist_album ON statistics_tag(name,artist,album)" ); - - columns.clear(); - - //text fields, not varchars - columns.insert( "lyrics", vcpair( "lyrics", 0 ) ); - columns.insert( "podcastchannels", vcpair( "url", 0 ) ); - columns.insert( "podcastchannels", vcpair( "title", 0 ) ); - columns.insert( "podcastchannels", vcpair( "weblink", 0 ) ); - columns.insert( "podcastchannels", vcpair( "image", 0 ) ); - columns.insert( "podcastchannels", vcpair( "description", 0 ) ); - columns.insert( "podcastepisodes", vcpair( "url", 0 ) ); - columns.insert( "podcastepisodes", vcpair( "localurl", 0 ) ); - columns.insert( "podcastepisodes", vcpair( "title", 0 ) ); - columns.insert( "podcastepisodes", vcpair( "subtitle", 0 ) ); - columns.insert( "podcastepisodes", vcpair( "description", 0 ) ); - columns.insert( "tracks", vcpair( "comment", 0 ) ); - - storage->query( "DROP INDEX url_podchannel ON podcastchannels" ); - storage->query( "DROP INDEX url_podepisode ON podcastepisodes" ); - storage->query( "DROP INDEX localurl_podepisode ON podcastepisodes" ); - for( i = columns.constBegin(), iEnd = columns.constEnd(); i != iEnd; ++i ) - { - storage->query( "ALTER TABLE " + i.key() + " MODIFY " + i.value().first + " BLOB" ); - storage->query( "ALTER IGNORE TABLE " + i.key() + " MODIFY " + i.value().first + " TEXT CHARACTER SET utf8 COLLATE utf8_bin NOT NULL" ); - } - storage->query( "CREATE FULLTEXT INDEX url_podchannel ON podcastchannels( url )" ); - storage->query( "CREATE FULLTEXT INDEX url_podepisode ON podcastepisodes( url )" ); - storage->query( "CREATE FULLTEXT INDEX localurl_podepisode ON podcastepisodes( localurl )" ); -} - -void -DatabaseUpdater::upgradeVersion10to11() -{ - DEBUG_BLOCK - //OK, this isn't really a database upgrade, but it does affect scanning. - //New default is for the charset detector not to run; but those that have existing collection - //won't like it if suddenly that changes their behavior, so set to true for existing collections - AmarokConfig::setUseCharsetDetector( true ); -} - -void -DatabaseUpdater::upgradeVersion11to12() -{ - DEBUG_BLOCK - //Counteract the above -- force it off for everyone except those explicitly enabling it. - AmarokConfig::setUseCharsetDetector( false ); -} - -void -DatabaseUpdater::upgradeVersion12to13() -{ - DEBUG_BLOCK - m_collection->sqlStorage()->query( "UPDATE urls SET uniqueid = REPLACE(uniqueid, 'MB_', 'mb-');" ); -} - -void -DatabaseUpdater::upgradeVersion13to14() -{ - DEBUG_BLOCK - SqlStorage *storage = m_collection->sqlStorage(); - - /* Following commands transition lyrics table from text-based urls (in fact just rpath - * parts) to references to urls table. */ - - // first, rename column - storage->query( "ALTER TABLE lyrics CHANGE url rpath VARCHAR(324) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL" ); - // add integer column for url id - storage->query( "ALTER TABLE lyrics ADD COLUMN url INT NULL DEFAULT NULL FIRST" ); - // try to extract url id from urls table using rpath - storage->query( "UPDATE lyrics l SET l.url = (SELECT u.id FROM urls u WHERE u.rpath = l.rpath LIMIT 1)" ); - // delete entries with no matches in urls table; these should be just stale ones - storage->query( "DELETE FROM lyrics WHERE url IS NULL" ); - // make the url columnt non-null - storage->query( "ALTER TABLE lyrics MODIFY url INT NOT NULL" ); - // select duplicate ids into temporary table - storage->query( "CREATE TEMPORARY TABLE duplicate_lyrics_ids ( id INT NOT NULL ) " - "ENGINE=MEMORY SELECT dupl.id FROM lyrics orig " - "LEFT JOIN lyrics dupl ON dupl.url = orig.url AND dupl.id > orig.id" ); - // delete duplicate lyrics entries - storage->query( "DELETE FROM lyrics WHERE id IN (SELECT id FROM duplicate_lyrics_ids)" ); - // drop unwanted columns along with indexes defined on them - storage->query( "ALTER TABLE lyrics DROP id, DROP rpath" ); - // add primary key; should definitely not fail as we have removed duplicate entries - storage->query( "ALTER TABLE lyrics ADD PRIMARY KEY(url)" ); -} - -void -DatabaseUpdater::upgradeVersion14to15() -{ - /* This update solves bug 302837. In short, updates - * 4 -> 5, 5 -> 6, 6 -> 7 and 9 -> 10 ignored NULL status of some columns and replaced - * them with NOT NULL columns, causing various consequences, one of them is Dynamic - * Collection not working. Fix it back. - * - * A list of columns to fix was obtained by comparing a database created by - * Amarok 2.1.1 and then upgraded to current version with a db freshly created by - * Amarok 2.6-git. - */ - DEBUG_BLOCK - SqlStorage *storage = m_collection->sqlStorage(); - - // zero length = TEXT datatype - typedef QPair vcpair; - QMultiMap columns; - - columns.insert( "admin", vcpair( "component", 255 ) ); - columns.insert( "devices", vcpair( "type", 255 ) ); - columns.insert( "devices", vcpair( "label", 255 ) ); - columns.insert( "devices", vcpair( "lastmountpoint", 255 ) ); - columns.insert( "devices", vcpair( "uuid", 255 ) ); - columns.insert( "devices", vcpair( "servername", 80 ) ); - columns.insert( "devices", vcpair( "sharename", 240 ) ); - columns.insert( "labels", vcpair( "label", textColumnLength() ) ); - columns.insert( "lyrics", vcpair( "lyrics", 0 ) ); - columns.insert( "playlists", vcpair( "name", 255 ) ); - columns.insert( "playlists", vcpair( "description", 255 ) ); - columns.insert( "playlists", vcpair( "urlid", 1000 ) ); - columns.insert( "playlist_groups", vcpair( "name", 255 ) ); - columns.insert( "playlist_groups", vcpair( "description", 255 ) ); - columns.insert( "playlist_tracks", vcpair( "url", 1000 ) ); - columns.insert( "playlist_tracks", vcpair( "title", 255 ) ); - columns.insert( "playlist_tracks", vcpair( "album", 255 ) ); - columns.insert( "playlist_tracks", vcpair( "artist", 255 ) ); - columns.insert( "playlist_tracks", vcpair( "uniqueid", 128 ) ); - columns.insert( "podcastchannels", vcpair( "url", 0 ) ); - columns.insert( "podcastchannels", vcpair( "title", 0 ) ); - columns.insert( "podcastchannels", vcpair( "weblink", 0 ) ); - columns.insert( "podcastchannels", vcpair( "image", 0 ) ); - columns.insert( "podcastchannels", vcpair( "description", 0 ) ); - columns.insert( "podcastchannels", vcpair( "copyright", 255 ) ); - columns.insert( "podcastchannels", vcpair( "directory", 255 ) ); - columns.insert( "podcastchannels", vcpair( "labels", 255 ) ); - columns.insert( "podcastchannels", vcpair( "subscribedate", 255 ) ); - columns.insert( "podcastepisodes", vcpair( "url", 0 ) ); - columns.insert( "podcastepisodes", vcpair( "localurl", 0 ) ); - columns.insert( "podcastepisodes", vcpair( "guid", 1000 ) ); - columns.insert( "podcastepisodes", vcpair( "title", 0 ) ); - columns.insert( "podcastepisodes", vcpair( "subtitle", 0 ) ); - columns.insert( "podcastepisodes", vcpair( "description", 0 ) ); - columns.insert( "podcastepisodes", vcpair( "mimetype", 255 ) ); - columns.insert( "podcastepisodes", vcpair( "pubdate", 255 ) ); - columns.insert( "statistics_tag", vcpair( "name", 108 ) ); - columns.insert( "statistics_tag", vcpair( "artist", 108 ) ); - columns.insert( "statistics_tag", vcpair( "album", 108 ) ); - columns.insert( "tracks", vcpair( "title", textColumnLength() ) ); - columns.insert( "tracks", vcpair( "comment", 0 ) ); - columns.insert( "urls", vcpair( "uniqueid", 128 ) ); - - QMapIterator it( columns ); - while( it.hasNext() ) - { - it.next(); - QString table = it.key(); - QString column = it.value().first; - int length = it.value().second; - - QString query; - if( length > 0 ) - query = QString( "ALTER TABLE `%1` CHANGE `%2` `%2` VARCHAR(%3) CHARACTER SET utf8 " - "COLLATE utf8_bin NULL DEFAULT NULL" ).arg( table, column ).arg( length ); - else - query = QString( "ALTER TABLE `%1` CHANGE `%2` `%2` TEXT CHARACTER SET utf8 " - "COLLATE utf8_bin" ).arg( table, column ); - storage->query( query ); - } - - // there may be a stale unique index on the urls table, remove it if it is there: - QStringList results = storage->query( "SHOW CREATE TABLE urls" ); - bool oldIndexFound = results.value( 1 ).contains( "UNIQUE KEY `uniqueid`" ); - if( oldIndexFound ) - { - debug() << "dropping obsolete INDEX uniqueid on table urls"; - storage->query( "DROP INDEX uniqueid ON urls" ); - } -} - -void -DatabaseUpdater::cleanupDatabase() -{ - // maybe clean up redundant information here? -} - -void -DatabaseUpdater::checkTables( bool full ) -{ - DEBUG_BLOCK - - SqlStorage *storage = m_collection->sqlStorage(); - - QStringList res = storage->query( "SHOW TABLES" ); - if( res.count() > 0 ) - { - foreach( const QString &table, res ) - storage->query( "CHECK TABLE " + table + ( full ? " EXTENDED;" : " MEDIUM;" ) ); - } -} - - -void -DatabaseUpdater::createTables() const -{ - DEBUG_BLOCK - - SqlStorage *storage = m_collection->sqlStorage(); - - // see docs/database/amarokTables.svg for documentation about database layout - { - QString c = "CREATE TABLE admin (component " + storage->textColumnType() + ", version INTEGER) COLLATE = utf8_bin ENGINE = MyISAM;"; - storage->query( c ); - } - { - QString create = "CREATE TABLE devices " - "(id " + storage->idType() + - ",type " + storage->textColumnType() + - ",label " + storage->textColumnType() + - ",lastmountpoint " + storage->textColumnType() + - ",uuid " + storage->textColumnType() + - ",servername " + storage->textColumnType(80) + - ",sharename " + storage->textColumnType(240) + ") COLLATE = utf8_bin ENGINE = MyISAM;"; - storage->query( create ); - storage->query( "CREATE INDEX devices_type ON devices( type );" ); - storage->query( "CREATE UNIQUE INDEX devices_uuid ON devices( uuid );" ); - storage->query( "CREATE INDEX devices_rshare ON devices( servername, sharename );" ); - } - { - QString create = "CREATE TABLE urls " - "(id " + storage->idType() + - ",deviceid INTEGER" - ",rpath " + storage->exactIndexableTextColumnType() + " NOT NULL" + - ",directory INTEGER" - ",uniqueid " + storage->exactTextColumnType(128) + " UNIQUE) COLLATE = utf8_bin ENGINE = MyISAM;"; - storage->query( create ); - storage->query( "CREATE UNIQUE INDEX urls_id_rpath ON urls(deviceid, rpath);" ); - storage->query( "CREATE INDEX urls_uniqueid ON urls(uniqueid);" ); - storage->query( "CREATE INDEX urls_directory ON urls(directory);" ); - } - { - QString create = "CREATE TABLE directories " - "(id " + storage->idType() + - ",deviceid INTEGER" - ",dir " + storage->exactTextColumnType() + " NOT NULL" + - ",changedate INTEGER) COLLATE = utf8_bin ENGINE = MyISAM;"; - storage->query( create ); - storage->query( "CREATE INDEX directories_deviceid ON directories(deviceid);" ); - } - { - QString create = "CREATE TABLE artists " - "(id " + storage->idType() + - ",name " + storage->textColumnType() + " NOT NULL) COLLATE = utf8_bin ENGINE = MyISAM;"; - storage->query( create ); - storage->query( "CREATE UNIQUE INDEX artists_name ON artists(name);" ); - } - { - QString create = "CREATE TABLE images " - "(id " + storage->idType() + - ",path " + storage->textColumnType() + " NOT NULL) COLLATE = utf8_bin ENGINE = MyISAM;"; - storage->query( create ); - storage->query( "CREATE UNIQUE INDEX images_name ON images(path);" ); - } - { - QString c = "CREATE TABLE albums " - "(id " + storage->idType() + - ",name " + storage->textColumnType() + " NOT NULL" - ",artist INTEGER" + - ",image INTEGER) COLLATE = utf8_bin ENGINE = MyISAM;"; - storage->query( c ); - storage->query( "CREATE INDEX albums_name ON albums(name);" ); - storage->query( "CREATE INDEX albums_artist ON albums(artist);" ); - storage->query( "CREATE INDEX albums_image ON albums(image);" ); - storage->query( "CREATE UNIQUE INDEX albums_name_artist ON albums(name,artist);" ); - //the index below should not be necessary. uncomment if a query plan shows it is - //storage->query( "CREATE UNIQUE INDEX albums_artist_name ON albums(artist,name);" ); - } - { - QString create = "CREATE TABLE genres " - "(id " + storage->idType() + - ",name " + storage->textColumnType() + " NOT NULL) COLLATE = utf8_bin ENGINE = MyISAM;"; - storage->query( create ); - storage->query( "CREATE UNIQUE INDEX genres_name ON genres(name);" ); - } - { - QString create = "CREATE TABLE composers " - "(id " + storage->idType() + - ",name " + storage->textColumnType() + " NOT NULL) COLLATE = utf8_bin ENGINE = MyISAM;"; - storage->query( create ); - storage->query( "CREATE UNIQUE INDEX composers_name ON composers(name);" ); - } - { - QString create = "CREATE TABLE years " - "(id " + storage->idType() + - ",name " + storage->textColumnType() + " NOT NULL) COLLATE = utf8_bin ENGINE = MyISAM;"; - storage->query( create ); - storage->query( "CREATE UNIQUE INDEX years_name ON years(name);" ); - } - { - QString c = "CREATE TABLE tracks " - "(id " + storage->idType() + - ",url INTEGER" - ",artist INTEGER" - ",album INTEGER" - ",genre INTEGER" - ",composer INTEGER" - ",year INTEGER" - ",title " + storage->textColumnType() + - ",comment " + storage->longTextColumnType() + - ",tracknumber INTEGER" - ",discnumber INTEGER" - ",bitrate INTEGER" - ",length INTEGER" - ",samplerate INTEGER" - ",filesize INTEGER" - ",filetype INTEGER" //does this still make sense? - ",bpm FLOAT" - ",createdate INTEGER" // this is the track creation time - ",modifydate INTEGER" // UNUSED currently - ",albumgain FLOAT" - ",albumpeakgain FLOAT" // decibels, relative to albumgain - ",trackgain FLOAT" - ",trackpeakgain FLOAT" // decibels, relative to trackgain - ") COLLATE = utf8_bin ENGINE = MyISAM;"; - - storage->query( c ); - storage->query( "CREATE UNIQUE INDEX tracks_url ON tracks(url);" ); - - QStringList indices; - indices << "id" << "artist" << "album" << "genre" << "composer" << "year" << "title"; - indices << "discnumber" << "createdate" << "length" << "bitrate" << "filesize"; - foreach( const QString &index, indices ) - { - QString query = QString( "CREATE INDEX tracks_%1 ON tracks(%2);" ).arg( index, index ); - storage->query( query ); - } - } - { - QString c = "CREATE TABLE statistics " - "(id " + storage->idType() + - ",url INTEGER NOT NULL" - ",createdate INTEGER" // this is the first played time - ",accessdate INTEGER" // this is the last played time - ",score FLOAT" - ",rating INTEGER NOT NULL DEFAULT 0" // the "default" undefined rating is 0. We cannot display anything else. - ",playcount INTEGER NOT NULL DEFAULT 0" // a track is either played or not. - ",deleted BOOL NOT NULL DEFAULT " + storage->boolFalse() + - ") COLLATE = utf8_bin ENGINE = MyISAM;"; - storage->query( c ); - storage->query( "CREATE UNIQUE INDEX statistics_url ON statistics(url);" ); - QStringList indices; - indices << "createdate" << "accessdate" << "score" << "rating" << "playcount"; - foreach( const QString &index, indices ) - { - QString q = QString( "CREATE INDEX statistics_%1 ON statistics(%2);" ).arg( index, index ); - storage->query( q ); - } - } - { - QString q = "CREATE TABLE labels " - "(id " + storage->idType() + - ",label " + storage->textColumnType() + - ") COLLATE = utf8_bin ENGINE = MyISAM;"; - storage->query( q ); - storage->query( "CREATE UNIQUE INDEX labels_label ON labels(label);" ); - - QString r = "CREATE TABLE urls_labels(url INTEGER, label INTEGER);"; - storage->query( r ); - storage->query( "CREATE INDEX urlslabels_url ON urls_labels(url);" ); - storage->query( "CREATE INDEX urlslabels_label ON urls_labels(label);" ); - } - { - QString q = "CREATE TABLE amazon (" - "asin " + storage->textColumnType( 20 ) + - ",locale " + storage->textColumnType( 2 ) + - ",filename " + storage->textColumnType( 33 ) + - ",refetchdate INTEGER ) COLLATE = utf8_bin ENGINE = MyISAM;"; - storage->query( q ); - storage->query( "CREATE INDEX amazon_date ON amazon(refetchdate);" ); - } - { - QString q = "CREATE TABLE lyrics (" - "url INTEGER PRIMARY KEY" - ",lyrics " + storage->longTextColumnType() + - ") COLLATE = utf8_bin ENGINE = MyISAM;"; - storage->query( q ); - } - storage->query( "INSERT INTO admin(component,version) " - "VALUES('AMAROK_TRACK'," + QString::number( DB_VERSION ) + ");" ); - { - storage->query( "CREATE TABLE statistics_permanent " - "(url " + storage->exactIndexableTextColumnType() + " NOT NULL" + - ",firstplayed DATETIME" - ",lastplayed DATETIME" - ",score FLOAT" - ",rating INTEGER DEFAULT 0" - ",playcount INTEGER) COLLATE = utf8_bin ENGINE = MyISAM;" ); - - //Below query is invalid! Fix it, and then put the proper query in an upgrade function! - storage->query( "CREATE UNIQUE INDEX stats_perm_url ON statistics_permanent(url)" ); - - storage->query( "CREATE TABLE statistics_tag " - "(name " + storage->textColumnType(108) + - ",artist " + storage->textColumnType(108) + - ",album " + storage->textColumnType(108) + - ",firstplayed DATETIME" - ",lastplayed DATETIME" - ",score FLOAT" - ",rating INTEGER DEFAULT 0" - ",playcount INTEGER) COLLATE = utf8_bin ENGINE = MyISAM" ); - - //Below query is invalid! Fix it, and then put the proper query in an upgrade function! - storage->query( "CREATE UNIQUE INDEX stats_tag_name_artist_album ON statistics_tag(name,artist,album)" ); - } -} - -int -DatabaseUpdater::adminValue( const QString &key ) const -{ - SqlStorage *storage = m_collection->sqlStorage(); - - QStringList columns = storage->query( - QString( "SELECT column_name FROM INFORMATION_SCHEMA.columns " - "WHERE table_name='admin'" ) ); - if( columns.isEmpty() ) - return 0; //no table with that name - - QStringList values = storage->query( - QString( "SELECT version FROM admin WHERE component = '%1';") - .arg(storage->escape( key ) ) ); - if( values.isEmpty() ) - return 0; - - return values.first().toInt(); -} - -void -DatabaseUpdater::deleteAllRedundant( const QString &type ) -{ - SqlStorage *storage = m_collection->sqlStorage(); - - const QString tablename = type + 's'; - if( type == "artist" ) - storage->query( QString( "DELETE FROM artists " - "WHERE id NOT IN ( SELECT artist FROM tracks WHERE artist IS NOT NULL ) AND " - "id NOT IN ( SELECT artist FROM albums WHERE artist IS NOT NULL )") ); - else - storage->query( QString( "DELETE FROM %1 " - "WHERE id NOT IN ( SELECT %2 FROM tracks WHERE %2 IS NOT NULL )" ). - arg( tablename, type ) ); -} - -void -DatabaseUpdater::deleteOrphanedByDirectory( const QString &table ) -{ - SqlStorage *storage = m_collection->sqlStorage(); - QString query( "DELETE FROM %1 WHERE directory NOT IN ( SELECT id FROM directories )" ); - storage->query( query.arg( table ) ); -} - -void -DatabaseUpdater::deleteOrphanedByUrl( const QString &table ) -{ - SqlStorage *storage = m_collection->sqlStorage(); - QString query( "DELETE FROM %1 WHERE url NOT IN ( SELECT id FROM urls )" ); - storage->query( query.arg( table ) ); -} - -void -DatabaseUpdater::removeFilesInDir( int deviceid, const QString &rdir ) -{ - SqlStorage *storage = m_collection->sqlStorage(); - - QString select = QString( "SELECT urls.id FROM urls LEFT JOIN directories ON urls.directory = directories.id " - "WHERE directories.deviceid = %1 AND directories.dir = '%2';" ) - .arg( QString::number( deviceid ), storage->escape( rdir ) ); - QStringList idResult = storage->query( select ); - if( !idResult.isEmpty() ) - { - QString id; - QString ids; - QStringList::ConstIterator it = idResult.constBegin(), end = idResult.constEnd(); - while( it != end ) - { - id = (*(it++)); - if( !ids.isEmpty() ) - ids += ','; - ids += id; - } - QString drop = QString( "DELETE FROM tracks WHERE url IN (%1);" ).arg( ids ); - storage->query( drop ); - } -} - -void -DatabaseUpdater::writeCSVFile( const QString &table, const QString &filename, bool forceDebug ) -{ - SqlStorage *storage = m_collection->sqlStorage(); - - if( !forceDebug && !m_debugDatabaseContent ) - return; - - QString ctable = table; - QStringList columns = storage->query( - QString( "SELECT column_name FROM INFORMATION_SCHEMA.columns WHERE table_name='%1'" ) - .arg( storage->escape( ctable ) ) ); - - if( columns.isEmpty() ) - return; //no table with that name - - // ok. it was probably a little bit unlucky to name a table statistics - // that clashes with INFORMATION_SCHEMA.statistics, a build in table. - if( table == "statistics" && columns.count() > 15 ) - { - // delete all columns with full upper case name. Those are the buildins. - for( int i = columns.count()-1; i>= 0; --i ) - { - if( columns[i].toUpper() == columns[i] ) - columns.removeAt( i ); - } - } - - QString select; - foreach( const QString &column, columns ) - { - if( !select.isEmpty() ) - select.append( ',' ); - select.append( column ); - } - - QString query = "SELECT %1 FROM %2"; - - QStringList result = storage->query( query.arg( select, storage->escape( table ) ) ); - - QFile file( filename ); - if( file.open( QFile::WriteOnly | QFile::Text | QFile::Truncate ) ) - { - QTextStream stream( &file ); - int i = 0; - QString line; - //write header - foreach( const QString &column, columns ) - { - stream << column; - stream << ';'; - } - stream << '\n'; - - foreach( const QString &data, result ) - { - stream << data; - stream << ';'; - ++i; - if( i % columns.count() == 0 ) - stream << '\n'; - } - file.close(); - } -} - diff --git a/amarok/src/core-impl/collections/db/sql/DatabaseUpdater.h b/amarok/src/core-impl/collections/db/sql/DatabaseUpdater.h deleted file mode 100644 index f30917fa..00000000 --- a/amarok/src/core-impl/collections/db/sql/DatabaseUpdater.h +++ /dev/null @@ -1,125 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_DATABASEUPDATER_H -#define AMAROK_DATABASEUPDATER_H - -#include -#include - -#include "amarok_sqlcollection_export.h" - -class SqlStorage; - -namespace Collections { - class SqlCollection; -} - -/** The DatabaseUpdater class is a collection of function that can update the sql database from previous versions or create it from new. - */ -class AMAROK_SQLCOLLECTION_EXPORT DatabaseUpdater { -public: - DatabaseUpdater( Collections::SqlCollection *collection ); - ~DatabaseUpdater(); - - static int expectedDatabaseVersion(); - - /** - * Return true if the current database schema is outdated or non-existent and needs to - * be updated using to update() method. - */ - bool needsUpdate() const; - - /** - * Return true if database schema already exists in the database. When this method - * returns false, needsUpdate() returns true. - */ - bool schemaExists() const; - - /** - * Updates the database to @see expectedDatabaseVersion() - * @returns true if a update was performed, false otherwise - */ - bool update(); - - void upgradeVersion1to2(); - void upgradeVersion2to3(); - void upgradeVersion3to4(); - void upgradeVersion4to5(); - void upgradeVersion5to6(); - void upgradeVersion6to7(); - void upgradeVersion7to8(); - void upgradeVersion8to9(); - void upgradeVersion9to10(); - void upgradeVersion10to11(); - void upgradeVersion11to12(); - void upgradeVersion12to13(); - void upgradeVersion13to14(); - void upgradeVersion14to15(); - - /** Checks the given table for redundant entries. - * Table can be artist,album,genre,composer,urls or year - * Note that you should check album table first so that the rest can - * be deleted fully. - * Note: it can handle also the directories table but that is better - * be left to the ScannerProcessor - * - * TODO: also check the remainding 8 tables - */ - void deleteAllRedundant( const QString &type ); - - /** - * Delete all entries from @p table with broken link to directories table. Currently - * had only sense on the urls table. - */ - void deleteOrphanedByDirectory( const QString &table ); - - /** - * Use on tables that link to non-existent entries in the urls table, for example - * urls_labels, statistics, lyrics. @param table must have a column named url. - */ - void deleteOrphanedByUrl( const QString &table ); - - void removeFilesInDir( int deviceid, const QString &rdir ); - - /** Cleans up the database - * The current functionality is quite fuzzy because it does not have anything. - * to clean. - */ - void cleanupDatabase(); - - /** Checks all tables for errors. - * It does not try to repair as this could be fatal. - * The check results should be in the log file so the user would send them - * to the developers upon request. - */ - void checkTables( bool full = true ); - - void writeCSVFile( const QString &table, const QString &filename, bool forceDebug = false ); - - static int textColumnLength() { return 255; }; - -private: - /** creates all the necessary tables, indexes etc. for the database */ - void createTables() const; - - int adminValue( const QString &key ) const; - - Collections::SqlCollection *m_collection; - bool m_debugDatabaseContent; -}; - -#endif diff --git a/amarok/src/core-impl/collections/db/sql/DefaultSqlQueryMakerFactory.h b/amarok/src/core-impl/collections/db/sql/DefaultSqlQueryMakerFactory.h deleted file mode 100644 index c6a00966..00000000 --- a/amarok/src/core-impl/collections/db/sql/DefaultSqlQueryMakerFactory.h +++ /dev/null @@ -1,43 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef DEFAULTSQLQUERYMAKERFACTORY_H -#define DEFAULTSQLQUERYMAKERFACTORY_H - -#include "SqlQueryMaker.h" - -namespace Collections { - -class DefaultSqlQueryMakerFactory : public SqlQueryMakerFactory -{ -public: - DefaultSqlQueryMakerFactory( SqlCollection *collection ) - : SqlQueryMakerFactory() - , m_collection( collection ) {} - - SqlQueryMaker *createQueryMaker() const - { - Q_ASSERT( m_collection ); - return new SqlQueryMaker( m_collection ); - } - -private: - SqlCollection *m_collection; -}; - -} //namespace Collections - -#endif // DEFAULTSQLQUERYMAKERFACTORY_H diff --git a/amarok/src/core-impl/collections/db/sql/SqlCapabilities.cpp b/amarok/src/core-impl/collections/db/sql/SqlCapabilities.cpp deleted file mode 100644 index e8167d27..00000000 --- a/amarok/src/core-impl/collections/db/sql/SqlCapabilities.cpp +++ /dev/null @@ -1,128 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Maximilian Kossick * - * Copyright (c) 2013 Ralf Engels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "SqlCapabilities" - -#include "SqlCapabilities.h" - -#include "MetaValues.h" -#include "SqlMeta.h" -#include "core/support/Debug.h" - -#include -#include - -namespace Capabilities { - -OrganiseCapabilityImpl::OrganiseCapabilityImpl( Meta::SqlTrack *track ) - : Capabilities::OrganiseCapability() - , m_track( track ) -{} - -OrganiseCapabilityImpl::~OrganiseCapabilityImpl() -{} - - -void -OrganiseCapabilityImpl::deleteTrack() -{ - if( QFile::remove( m_track->playableUrl().path() ) ) - m_track->remove(); -} - - -TimecodeWriteCapabilityImpl::TimecodeWriteCapabilityImpl( Meta::SqlTrack *track ) - : Capabilities::TimecodeWriteCapability() - , m_track( track ) -{} - -TimecodeWriteCapabilityImpl::~TimecodeWriteCapabilityImpl() -{} - - -TimecodeLoadCapabilityImpl::TimecodeLoadCapabilityImpl( Meta::SqlTrack *track ) - : Capabilities::TimecodeLoadCapability() - , m_track( track ) -{} - -TimecodeLoadCapabilityImpl::~TimecodeLoadCapabilityImpl() -{} - -bool -TimecodeLoadCapabilityImpl::hasTimecodes() -{ - return ( loadTimecodes().size() > 0 ); -} - -QList > -TimecodeLoadCapabilityImpl::loadTimecodes() -{ - QList > list = PlayUrlRunner::bookmarksFromUrl( m_track->playableUrl() ); - return list; -} - - -FindInSourceCapabilityImpl::FindInSourceCapabilityImpl( Meta::SqlTrack *track ) - : Capabilities::FindInSourceCapability() - , m_track( track ) -{} - -FindInSourceCapabilityImpl::~FindInSourceCapabilityImpl() -{} - -void -FindInSourceCapabilityImpl::findInSource( QFlags tag ) -{ - DEBUG_BLOCK - - QStringList filters; - Meta::AlbumPtr album = m_track->album(); - Meta::ArtistPtr artist = m_track->artist(); - Meta::ComposerPtr composer = m_track->composer(); - Meta::GenrePtr genre = m_track->genre(); - Meta::YearPtr year = m_track->year(); - QString name; - - if( tag.testFlag(Artist) && !(name = artist ? artist->prettyName() : QString()).isEmpty() ) - filters << QString( "%1:\"%2\"" ).arg( Meta::shortI18nForField( Meta::valArtist ), name ); - if( tag.testFlag(Album) && !(name = album ? album->prettyName() : QString()).isEmpty() ) - filters << QString( "%1:\"%2\"" ).arg( Meta::shortI18nForField( Meta::valAlbum ), name ); - if( tag.testFlag(Composer) && !(name = composer ? composer->prettyName() : QString()).isEmpty() ) - filters << QString( "%1:\"%2\"" ).arg( Meta::shortI18nForField( Meta::valComposer ), name ); - if( tag.testFlag(Genre) && !(name = genre ? genre->prettyName() : QString()).isEmpty() ) - filters << QString( "%1:\"%2\"" ).arg( Meta::shortI18nForField( Meta::valGenre ), name ); - if( tag.testFlag(Track) && !(name = m_track ? m_track->prettyName() : QString()).isEmpty() ) - filters << QString( "%1:\"%2\"" ).arg( Meta::shortI18nForField( Meta::valTitle ), name ); - if( tag.testFlag(Year) && !(name = year ? year->name() : QString()).isEmpty() ) - filters << QString( "%1:%2" ).arg( Meta::shortI18nForField( Meta::valYear ), name ); - - if( !filters.isEmpty() ) - { - AmarokUrl url; - url.setCommand( "navigate" ); - url.setPath( "collections" ); - url.setArg( "filter", filters.join( QLatin1String(" AND ") ) ); - - debug() << "running url: " << url.url(); - url.run(); - } -} - -} //namespace Capabilities - -#include "moc_SqlCapabilities.cpp" - diff --git a/amarok/src/core-impl/collections/db/sql/SqlCapabilities.h b/amarok/src/core-impl/collections/db/sql/SqlCapabilities.h deleted file mode 100644 index fab7c07f..00000000 --- a/amarok/src/core-impl/collections/db/sql/SqlCapabilities.h +++ /dev/null @@ -1,116 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Maximilian Kossick * - * Copyright (c) 2013 Ralf Engels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef SQLCAPABILITIES_H -#define SQLCAPABILITIES_H - -#include "amarok_sqlcollection_export.h" -#include "amarokurls/PlayUrlRunner.h" -#include "core/capabilities/Capability.h" -#include "core/capabilities/FindInSourceCapability.h" -#include "core/capabilities/OrganiseCapability.h" -#include "core/meta/TrackEditor.h" -#include "core-impl/capabilities/timecode/TimecodeLoadCapability.h" -#include "core-impl/capabilities/timecode/TimecodeWriteCapability.h" -#include "core-impl/collections/db/sql/SqlMeta.h" - -/* note: currently SqlTrack has the following capabilities - ActionsCapability - OrganiseCapabilityImpl - BookmarkThisCapability - TimecodeWriteCapabilityImpl - TimecodeLoadCapabilityImpl - SqlReadLabelCapability - SqlWriteLabelCapability - FindInSourceCapabilityImpl -*/ - -namespace Capabilities { - -class OrganiseCapabilityImpl : public Capabilities::OrganiseCapability -{ - Q_OBJECT - - public: - - OrganiseCapabilityImpl( Meta::SqlTrack *track ); - virtual ~OrganiseCapabilityImpl(); - - virtual void deleteTrack(); - - private: - KSharedPtr m_track; -}; - -class TimecodeWriteCapabilityImpl : public Capabilities::TimecodeWriteCapability -{ - Q_OBJECT - - public: - - TimecodeWriteCapabilityImpl( Meta::SqlTrack *track ); - virtual ~TimecodeWriteCapabilityImpl(); - - virtual bool writeTimecode( qint64 miliseconds ) - { - return Capabilities::TimecodeWriteCapability::writeTimecode( miliseconds, Meta::TrackPtr( m_track.data() ) ); - } - - virtual bool writeAutoTimecode( qint64 miliseconds ) - { - return Capabilities::TimecodeWriteCapability::writeAutoTimecode( miliseconds, Meta::TrackPtr( m_track.data() ) ); - } - - private: - KSharedPtr m_track; -}; - -class TimecodeLoadCapabilityImpl : public Capabilities::TimecodeLoadCapability -{ - Q_OBJECT - - public: - - TimecodeLoadCapabilityImpl( Meta::SqlTrack *track ); - virtual ~TimecodeLoadCapabilityImpl(); - - virtual bool hasTimecodes(); - virtual QList > loadTimecodes(); - - private: - KSharedPtr m_track; -}; - - -class FindInSourceCapabilityImpl : public Capabilities::FindInSourceCapability -{ - Q_OBJECT - - public: - FindInSourceCapabilityImpl( Meta::SqlTrack *track ); - virtual ~FindInSourceCapabilityImpl(); - - virtual void findInSource( QFlags tag ); - - private: - KSharedPtr m_track; -}; - - -} //namespace Capabilities - -#endif // SQLCAPABILITIES_H diff --git a/amarok/src/core-impl/collections/db/sql/SqlCollection.cpp b/amarok/src/core-impl/collections/db/sql/SqlCollection.cpp deleted file mode 100644 index 14bfc655..00000000 --- a/amarok/src/core-impl/collections/db/sql/SqlCollection.cpp +++ /dev/null @@ -1,472 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Maximilian Kossick * - * Copyright (c) 2007 Casey Link * - * Copyright (c) 2008-2009 Jeff Mitchell * - * Copyright (c) 2013 Ralf Engels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "SqlCollection" - -#include "SqlCollection.h" - -#include "DefaultSqlQueryMakerFactory.h" -#include "DatabaseUpdater.h" -#include "core/support/Amarok.h" -#include "core/support/Debug.h" -#include "core/capabilities/TranscodeCapability.h" -#include "core/transcoding/TranscodingController.h" -#include "core-impl/collections/db/MountPointManager.h" -#include "scanner/GenericScanManager.h" -#include "scanner/AbstractDirectoryWatcher.h" -#include "dialogs/OrganizeCollectionDialog.h" -#include "SqlCollectionLocation.h" -#include "SqlQueryMaker.h" -#include "SqlScanResultProcessor.h" -#include "SvgHandler.h" -#include "MainWindow.h" - -#include "collectionscanner/BatchFile.h" - -#include -#include -#include - -#include -#include - - -/** Concrete implementation of the directory watcher */ -class SqlDirectoryWatcher : public AbstractDirectoryWatcher -{ -public: - SqlDirectoryWatcher( Collections::SqlCollection* collection ) - : AbstractDirectoryWatcher() - , m_collection( collection ) - { } - - ~SqlDirectoryWatcher() - { } - -protected: - QList collectionFolders() - { return m_collection->mountPointManager()->collectionFolders(); } - - Collections::SqlCollection* m_collection; -}; - -class SqlScanManager : public GenericScanManager -{ -public: - SqlScanManager( Collections::SqlCollection* collection, QObject* parent ) - : GenericScanManager( parent ) - , m_collection( collection ) - { } - - ~SqlScanManager() - { } - -protected: - QList< QPair > getKnownDirs() - { - QList< QPair > result; - - // -- get all (mounted) mount points - QList idList = m_collection->mountPointManager()->getMountedDeviceIds(); - - // -- query all known directories - QString deviceIds; - foreach( int id, idList ) - { - if( !deviceIds.isEmpty() ) - deviceIds += ','; - deviceIds += QString::number( id ); - } - QString query = QString( "SELECT deviceid, dir, changedate FROM directories WHERE deviceid IN (%1);" ); - - QStringList values = m_collection->sqlStorage()->query( query.arg( deviceIds ) ); - for( QListIterator iter( values ); iter.hasNext(); ) - { - int deviceid = iter.next().toInt(); - QString dir = iter.next(); - uint mtime = iter.next().toUInt(); - - QString folder = m_collection->mountPointManager()->getAbsolutePath( deviceid, dir ); - result.append( QPair( folder, mtime ) ); - } - - return result; - } - - QString getBatchFile( const QStringList &scanDirsRequested ) - { - // -- write the batch file - // the batch file contains the known modification dates so that the scanner only - // needs to report changed directories - QList > knownDirs = getKnownDirs(); - if( !knownDirs.isEmpty() ) - { - QString path = KGlobal::dirs()->saveLocation( "data", QString("amarok/"), false ) + "amarokcollectionscanner_batchscan.xml"; - while( QFile::exists( path ) ) - path += '_'; - - CollectionScanner::BatchFile batchfile; - batchfile.setTimeDefinitions( knownDirs ); - batchfile.setDirectories( scanDirsRequested ); - if( !batchfile.write( path ) ) - { - warning() << "Failed to write batch file" << path; - return QString(); - } - return path; - } - return QString(); - } - - Collections::SqlCollection* m_collection; -}; - -namespace Collections { - -class OrganizeCollectionDelegateImpl : public OrganizeCollectionDelegate -{ -public: - OrganizeCollectionDelegateImpl() - : OrganizeCollectionDelegate() - , m_dialog( 0 ) - , m_organizing( false ) {} - virtual ~ OrganizeCollectionDelegateImpl() { delete m_dialog; } - - virtual void setTracks( const Meta::TrackList &tracks ) { m_tracks = tracks; } - virtual void setFolders( const QStringList &folders ) { m_folders = folders; } - virtual void setIsOrganizing( bool organizing ) { m_organizing = organizing; } - virtual void setTranscodingConfiguration( const Transcoding::Configuration &configuration ) - { m_targetFileExtension = - Amarok::Components::transcodingController()->format( configuration.encoder() )->fileExtension(); } - virtual void setCaption( const QString &caption ) { m_caption = caption; } - - virtual void show() - { - m_dialog = new OrganizeCollectionDialog( m_tracks, - m_folders, - m_targetFileExtension, - The::mainWindow(), //parent - "", //name is unused - true, //modal - m_caption //caption - ); - - connect( m_dialog, SIGNAL(accepted()), SIGNAL(accepted()) ); - connect( m_dialog, SIGNAL(rejected()), SIGNAL(rejected()) ); - m_dialog->show(); - } - - virtual bool overwriteDestinations() const { return m_dialog->overwriteDestinations(); } - virtual QMap destinations() const { return m_dialog->getDestinations(); } - -private: - Meta::TrackList m_tracks; - QStringList m_folders; - OrganizeCollectionDialog *m_dialog; - bool m_organizing; - QString m_targetFileExtension; - QString m_caption; -}; - - -class OrganizeCollectionDelegateFactoryImpl : public OrganizeCollectionDelegateFactory -{ -public: - virtual OrganizeCollectionDelegate* createDelegate() { return new OrganizeCollectionDelegateImpl(); } -}; - - -class SqlCollectionLocationFactoryImpl : public SqlCollectionLocationFactory -{ -public: - SqlCollectionLocationFactoryImpl( SqlCollection *collection ) - : SqlCollectionLocationFactory() - , m_collection( collection ) {} - - SqlCollectionLocation *createSqlCollectionLocation() const - { - Q_ASSERT( m_collection ); - SqlCollectionLocation *loc = new SqlCollectionLocation( m_collection ); - loc->setOrganizeCollectionDelegateFactory( new OrganizeCollectionDelegateFactoryImpl() ); - return loc; - } - - Collections::SqlCollection *m_collection; -}; - -} //namespace Collections - -using namespace Collections; - -SqlCollection::SqlCollection( SqlStorage* storage ) - : DatabaseCollection() - , m_registry( 0 ) - , m_sqlStorage( storage ) - , m_scanProcessor( 0 ) - , m_directoryWatcher( 0 ) - , m_collectionLocationFactory( 0 ) - , m_queryMakerFactory( 0 ) -{ - qRegisterMetaType( "TrackUrls" ); - qRegisterMetaType( "ChangedTrackUrls" ); - - // update database to current schema version; this must be run *before* MountPointManager - // is initialized or its handlers may try to insert - // into the database before it's created/updated! - DatabaseUpdater updater( this ); - if( updater.needsUpdate() ) - { - if( updater.schemaExists() ) // this is an update - { - KDialog dialog( 0, Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint ); - QLabel label( i18n( "Updating Amarok database schema. Please don't terminate " - "Amarok now as it may result in database corruption." ) ); - label.setWordWrap( true ); - dialog.setMainWidget( &label ); - dialog.setCaption( i18n( "Updating Amarok database schema" ) ); - dialog.setButtons( KDialog::None ); - dialog.setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ); - dialog.show(); - dialog.raise(); - // otherwise the splash screen doesn't load image and this dialog is not shown: - kapp->processEvents(); - - updater.update(); - - dialog.hide(); - kapp->processEvents(); - } - else // this is new schema creation - updater.update(); - } - - //perform a quick check of the database - updater.cleanupDatabase(); - - m_registry = new SqlRegistry( this ); - - m_collectionLocationFactory = new SqlCollectionLocationFactoryImpl( this ); - m_queryMakerFactory = new DefaultSqlQueryMakerFactory( this ); - - // scanning - m_scanManager = new SqlScanManager( this, this ); - m_scanProcessor = new SqlScanResultProcessor( m_scanManager, this, this ); - m_directoryWatcher = new SqlDirectoryWatcher( this ); - connect( m_directoryWatcher, SIGNAL(done(ThreadWeaver::Job*)), - m_directoryWatcher, SLOT(deleteLater()) ); // auto delete - connect( m_directoryWatcher, SIGNAL(requestScan(QList,GenericScanManager::ScanType)), - m_scanManager, SLOT(requestScan(QList,GenericScanManager::ScanType)) ); - ThreadWeaver::Weaver::instance()->enqueue( m_directoryWatcher ); - -} - -SqlCollection::~SqlCollection() -{ - m_directoryWatcher->abort(); - delete m_scanProcessor; // this prevents any further commits from the scanner - delete m_collectionLocationFactory; - delete m_queryMakerFactory; - delete m_sqlStorage; - delete m_registry; -} - -QString -SqlCollection::uidUrlProtocol() const -{ - return "amarok-sqltrackuid"; -} - -QString -SqlCollection::generateUidUrl( const QString &hash ) -{ - return uidUrlProtocol() + "://" + hash; -} - -QueryMaker* -SqlCollection::queryMaker() -{ - Q_ASSERT( m_queryMakerFactory ); - return m_queryMakerFactory->createQueryMaker(); -} - -SqlRegistry* -SqlCollection::registry() const -{ - Q_ASSERT( m_registry ); - return m_registry; -} - -SqlStorage* -SqlCollection::sqlStorage() const -{ - Q_ASSERT( m_sqlStorage ); - return m_sqlStorage; -} - -bool -SqlCollection::possiblyContainsTrack( const KUrl &url ) const -{ - if( url.isLocalFile() ) - { - foreach( const QString &folder, collectionFolders() ) - { - if( KUrl( folder ).isParentOf( url ) ) - return true; - } - return false; - } - else - return url.protocol() == uidUrlProtocol(); -} - -Meta::TrackPtr -SqlCollection::trackForUrl( const KUrl &url ) -{ - if( url.protocol() == uidUrlProtocol() ) - return m_registry->getTrackFromUid( url.url() ); - else if( url.protocol() == "file" ) - return m_registry->getTrack( url.path() ); - else - return Meta::TrackPtr(); -} - -Meta::TrackPtr -SqlCollection::getTrack( int deviceId, const QString &rpath, int directoryId, const QString &uidUrl ) -{ - return m_registry->getTrack( deviceId, rpath, directoryId, uidUrl ); -} - -Meta::TrackPtr -SqlCollection::getTrackFromUid( const QString &uniqueid ) -{ - return m_registry->getTrackFromUid( uniqueid ); -} - -Meta::AlbumPtr -SqlCollection::getAlbum( const QString &album, const QString &artist ) -{ - return m_registry->getAlbum( album, artist ); -} - -CollectionLocation* -SqlCollection::location() -{ - Q_ASSERT( m_collectionLocationFactory ); - return m_collectionLocationFactory->createSqlCollectionLocation(); -} - -void -SqlCollection::slotDeviceAdded( int id ) -{ - QString query = "select count(*) from tracks inner join urls on tracks.url = urls.id where urls.deviceid = %1"; - QStringList rs = m_sqlStorage->query( query.arg( id ) ); - if( !rs.isEmpty() ) - { - int count = rs.first().toInt(); - if( count > 0 ) - { - collectionUpdated(); - } - } - else - { - warning() << "Query " << query << "did not return a result! Is the database available?"; - } -} - -void -SqlCollection::slotDeviceRemoved( int id ) -{ - QString query = "select count(*) from tracks inner join urls on tracks.url = urls.id where urls.deviceid = %1"; - QStringList rs = m_sqlStorage->query( query.arg( id ) ); - if( !rs.isEmpty() ) - { - int count = rs.first().toInt(); - if( count > 0 ) - { - collectionUpdated(); - } - } - else - { - warning() << "Query " << query << "did not return a result! Is the database available?"; - } -} - -bool -SqlCollection::hasCapabilityInterface( Capabilities::Capability::Type type ) const -{ - switch( type ) - { - case Capabilities::Capability::Transcode: - return true; - default: - return DatabaseCollection::hasCapabilityInterface( type ); - } -} - -Capabilities::Capability* -SqlCollection::createCapabilityInterface( Capabilities::Capability::Type type ) -{ - switch( type ) - { - case Capabilities::Capability::Transcode: - return new SqlCollectionTranscodeCapability(); - default: - return DatabaseCollection::createCapabilityInterface( type ); - } -} - -void -SqlCollection::dumpDatabaseContent() -{ - DatabaseUpdater updater( this ); - - QStringList tables = m_sqlStorage->query( "select table_name from INFORMATION_SCHEMA.tables WHERE table_schema='amarok'" ); - foreach( const QString &table, tables ) - { - QString filePath = - QDir::home().absoluteFilePath( table + '-' + QDateTime::currentDateTime().toString( Qt::ISODate ) + ".csv" ); - updater.writeCSVFile( table, filePath, true ); - } -} - -// ---------- SqlCollectionTranscodeCapability ------------- - -SqlCollectionTranscodeCapability::~SqlCollectionTranscodeCapability() -{ - // nothing to do -} - -Transcoding::Configuration -SqlCollectionTranscodeCapability::savedConfiguration() -{ - KConfigGroup transcodeGroup = Amarok::config( SQL_TRANSCODING_GROUP_NAME ); - return Transcoding::Configuration::fromConfigGroup( transcodeGroup ); -} - -void -SqlCollectionTranscodeCapability::setSavedConfiguration( const Transcoding::Configuration &configuration ) -{ - KConfigGroup transcodeGroup = Amarok::config( SQL_TRANSCODING_GROUP_NAME ); - configuration.saveToConfigGroup( transcodeGroup ); - transcodeGroup.sync(); -} - -#include "moc_SqlCollection.cpp" diff --git a/amarok/src/core-impl/collections/db/sql/SqlCollection.h b/amarok/src/core-impl/collections/db/sql/SqlCollection.h deleted file mode 100644 index 7478c795..00000000 --- a/amarok/src/core-impl/collections/db/sql/SqlCollection.h +++ /dev/null @@ -1,120 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Maximilian Kossick * - * Copyright (c) 2007 Casey Link * - * Copyright (c) 2013 Ralf Engels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_COLLECTION_SQLCOLLECTION_H -#define AMAROK_COLLECTION_SQLCOLLECTION_H - -#include "amarok_sqlcollection_export.h" -#include "core/capabilities/TranscodeCapability.h" -#include -#include -#include "SqlRegistry.h" - -class SqlScanResultProcessor; -class AbstractDirectoryWatcher; - -namespace Collections { - -class CollectionLocation; -class SqlCollectionLocationFactory; -class SqlQueryMakerFactory; - -/// Configuration group name in amarokrc for preferred transcoding configuration for SqlCollection -static const QString SQL_TRANSCODING_GROUP_NAME = "Collection Transcoding Preference"; - -class AMAROK_SQLCOLLECTION_EXPORT SqlCollection : public Collections::DatabaseCollection -{ - Q_OBJECT - - public: - /** Creates a new SqlCollection. - * @param storage The storage this collection should work on. It will be freed by the collection. - */ - SqlCollection( SqlStorage *storage ); - virtual ~SqlCollection(); - - virtual QueryMaker *queryMaker(); - - /** Returns the protocol for the uid urls of this collection. - The SqlCollection support "amarok-sqltrackuid" and "file" protocol. - */ - virtual QString uidUrlProtocol() const; - /** - * Generates uidUrl out of a hash (as returned by tag reader) that can be then - * fed to Track::setUidUrl(). - */ - QString generateUidUrl( const QString &hash ); - - // Local collection cannot have a capacity since it may be spread over multiple - // physical locations (even network components) - - SqlRegistry* registry() const; - SqlStorage* sqlStorage() const; - - /** Every collection has this function. */ - virtual bool possiblyContainsTrack( const KUrl &url ) const; - - virtual Meta::TrackPtr trackForUrl( const KUrl &url ); - - /** Gets an existing track (or a new one) at the given position. - This function should only be used by the SqlScanResultProcessor. */ - virtual Meta::TrackPtr getTrack( int deviceId, const QString &rpath, int directoryId, const QString &uidUrl ); - virtual Meta::TrackPtr getTrackFromUid( const QString &uniqueid ); - virtual Meta::AlbumPtr getAlbum( const QString &album, const QString &artist ); - - virtual CollectionLocation* location(); - - virtual bool hasCapabilityInterface( Capabilities::Capability::Type type ) const; - virtual Capabilities::Capability* createCapabilityInterface( Capabilities::Capability::Type type ); - - public slots: - /** Dumps the complete database content. - * The content of all Amarok tables is dumped in a couple of files - * in the users homedirectory. - */ - void dumpDatabaseContent(); - - private slots: - void slotDeviceAdded( int id ); - void slotDeviceRemoved( int id ); - - private: - SqlRegistry* m_registry; - SqlStorage* m_sqlStorage; - - SqlScanResultProcessor* m_scanProcessor; - AbstractDirectoryWatcher* m_directoryWatcher; - - SqlCollectionLocationFactory* m_collectionLocationFactory; - SqlQueryMakerFactory* m_queryMakerFactory; -}; - -class AMAROK_SQLCOLLECTION_EXPORT SqlCollectionTranscodeCapability : public Capabilities::TranscodeCapability -{ - Q_OBJECT - public: - - virtual ~SqlCollectionTranscodeCapability(); - - virtual Transcoding::Configuration savedConfiguration(); - virtual void setSavedConfiguration( const Transcoding::Configuration &configuration ); -}; - -} - -#endif /* AMAROK_COLLECTION_SQLCOLLECTION_H */ diff --git a/amarok/src/core-impl/collections/db/sql/SqlCollectionFactory.cpp b/amarok/src/core-impl/collections/db/sql/SqlCollectionFactory.cpp deleted file mode 100644 index 36e595f0..00000000 --- a/amarok/src/core-impl/collections/db/sql/SqlCollectionFactory.cpp +++ /dev/null @@ -1,33 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "SqlCollectionFactory.h" - -#include "core-impl/collections/db/MountPointManager.h" -#include "core-impl/collections/db/sql/SqlCollection.h" - -Collections::SqlCollectionFactory::SqlCollectionFactory() -{ -} - -Collections::SqlCollection* -Collections::SqlCollectionFactory::createSqlCollection( SqlStorage *storage ) const -{ - SqlCollection *coll = new SqlCollection( storage ); - MountPointManager *mpm = new MountPointManager( coll, storage ); - coll->setMountPointManager( mpm ); - return coll; -} diff --git a/amarok/src/core-impl/collections/db/sql/SqlCollectionFactory.h b/amarok/src/core-impl/collections/db/sql/SqlCollectionFactory.h deleted file mode 100644 index 61ba1983..00000000 --- a/amarok/src/core-impl/collections/db/sql/SqlCollectionFactory.h +++ /dev/null @@ -1,40 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef SQLCOLLECTIONFACTORY_H -#define SQLCOLLECTIONFACTORY_H - -#include "amarok_sqlcollection_export.h" - -#include - -class SqlStorage; - -namespace Collections { - -class SqlCollection; - -class AMAROK_SQLCOLLECTION_EXPORT SqlCollectionFactory -{ -public: - SqlCollectionFactory(); - - SqlCollection* createSqlCollection( SqlStorage *storage ) const; -}; - -} //namespace Collections - -#endif // SQLCOLLECTIONFACTORY_H diff --git a/amarok/src/core-impl/collections/db/sql/SqlCollectionLocation.cpp b/amarok/src/core-impl/collections/db/sql/SqlCollectionLocation.cpp deleted file mode 100644 index c98e7e6e..00000000 --- a/amarok/src/core-impl/collections/db/sql/SqlCollectionLocation.cpp +++ /dev/null @@ -1,784 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Maximilian Kossick * - * Copyright (c) 2008 Jason A. Donenfeld * - * Copyright (c) 2010 Casey Link * - * Copyright (c) 2010 Teo Mrnjavac * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "SqlCollectionLocation" - -#include "SqlCollectionLocation.h" - -#include "MetaTagLib.h" // for getting the uid -#include "core/collections/CollectionLocationDelegate.h" -#include -#include "core/interfaces/Logger.h" -#include "core/support/Components.h" -#include "core/support/Debug.h" -#include "core/meta/Meta.h" -#include "core/meta/support/MetaUtility.h" -#include "core/transcoding/TranscodingController.h" -#include "core-impl/collections/db/MountPointManager.h" -#include "core-impl/collections/db/sql/SqlCollection.h" -#include "core-impl/collections/db/sql/SqlMeta.h" -#include "transcoding/TranscodingJob.h" - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -using namespace Collections; - -SqlCollectionLocation::SqlCollectionLocation( SqlCollection *collection ) - : CollectionLocation( collection ) - , m_collection( collection ) - , m_delegateFactory( 0 ) - , m_overwriteFiles( false ) - , m_transferjob( 0 ) -{ - //nothing to do -} - -SqlCollectionLocation::~SqlCollectionLocation() -{ - //nothing to do - delete m_delegateFactory; -} - -QString -SqlCollectionLocation::prettyLocation() const -{ - return i18n( "Local Collection" ); -} - -QStringList -SqlCollectionLocation::actualLocation() const -{ - return m_collection->mountPointManager()->collectionFolders(); -} - -bool -SqlCollectionLocation::isWritable() const -{ - // TODO: This function is also called when removing files to check - // if the tracks can be removed. In such a case we should not check the space - - // The collection is writable if there exists a path that has more than - // 500 MB free space. - bool path_exists_with_space = false; - bool path_exists_writable = false; - QStringList folders = actualLocation(); - foreach( const QString &path, folders ) - { - float used = KDiskFreeSpaceInfo::freeSpaceInfo( path ).used(); - float total = KDiskFreeSpaceInfo::freeSpaceInfo( path ).size(); - - if( total <= 0 ) // protect against div by zero - continue; //How did this happen? - - float free_space = total - used; - if( free_space >= 500*1000*1000 ) // ~500 megabytes - path_exists_with_space = true; - - QFileInfo info( path ); - if( info.isWritable() ) - path_exists_writable = true; - } - return path_exists_with_space && path_exists_writable; -} - -bool -SqlCollectionLocation::isOrganizable() const -{ - return true; -} - -bool -SqlCollectionLocation::remove( const Meta::TrackPtr &track ) -{ - DEBUG_BLOCK - Q_ASSERT( track ); - - if( track->inCollection() && - track->collection()->collectionId() == m_collection->collectionId() ) - { - bool removed; - KUrl src = track->playableUrl(); - if( isGoingToRemoveSources() ) // is organize operation? - { - SqlCollectionLocation* destinationloc = qobject_cast( destination() ); - if( destinationloc ) - { - src = destinationloc->m_originalUrls[track]; - if( src == track->playableUrl() ) - return false; - } - } - // we are going to delete it from the database only if is no longer on disk - removed = !QFile::exists( src.path() ); - if( removed ) - static_cast(const_cast(track.data()))->remove(); - - return removed; - } - else - { - debug() << "Remove Failed"; - return false; - } -} - -bool -SqlCollectionLocation::insert( const Meta::TrackPtr &track, const QString &url ) -{ - if( !QFile::exists( url ) ) - { - warning() << Q_FUNC_INFO << "file" << url << "does not exist, not inserting into db"; - return false; - } - - // -- the target url - SqlRegistry *registry = m_collection->registry(); - int deviceId = m_collection->mountPointManager()->getIdForUrl( url ); - QString rpath = m_collection->mountPointManager()->getRelativePath( deviceId, url ); - int directoryId = registry->getDirectory( QFileInfo( url ).path() ); - - // -- the track uid (we can't use the original one from the old collection) - Meta::FieldHash fileTags = Meta::Tag::readTags( url ); - QString uid = fileTags.value( Meta::valUniqueId ).toString(); - uid = m_collection->generateUidUrl( uid ); // add the right prefix - - // -- the track from the registry - Meta::SqlTrackPtr metaTrack; - metaTrack = Meta::SqlTrackPtr::staticCast( registry->getTrackFromUid( uid ) ); - - if( metaTrack ) - { - warning() << "Location is inserting a file with the same uid as an already existing one."; - metaTrack->setUrl( deviceId, rpath, directoryId ); - } else - metaTrack = Meta::SqlTrackPtr::staticCast( registry->getTrack( deviceId, rpath, directoryId, uid ) ); - - Meta::ConstStatisticsPtr origStats = track->statistics(); - - // -- set the values - metaTrack->setWriteFile( false ); // no need to write the tags back - metaTrack->beginUpdate(); - - if( !track->name().isEmpty() ) - metaTrack->setTitle( track->name() ); - if( track->album() ) - metaTrack->setAlbum( track->album()->name() ); - if( track->artist() ) - metaTrack->setArtist( track->artist()->name() ); - if( track->composer() ) - metaTrack->setComposer( track->composer()->name() ); - if( track->year() && track->year()->year() > 0 ) - metaTrack->setYear( track->year()->year() ); - if( track->genre() ) - metaTrack->setGenre( track->genre()->name() ); - - if( track->bpm() > 0 ) - metaTrack->setBpm( track->bpm() ); - if( !track->comment().isEmpty() ) - metaTrack->setComment( track->comment() ); - - if( origStats->score() > 0 ) - metaTrack->setScore( origStats->score() ); - if( origStats->rating() > 0 ) - metaTrack->setRating( origStats->rating() ); - - /* These tags change when transcoding. Prefer to read those from file */ - if( fileTags.value( Meta::valLength, 0 ).toLongLong() > 0 ) - metaTrack->setLength( fileTags.value( Meta::valLength ).value() ); - else if( track->length() > 0 ) - metaTrack->setLength( track->length() ); - // the filesize is updated every time after the - // file is changed. Doesn't make sense to set it. - if( fileTags.value( Meta::valSamplerate, 0 ).toInt() > 0 ) - metaTrack->setSampleRate( fileTags.value( Meta::valSamplerate ).toInt() ); - else if( track->sampleRate() > 0 ) - metaTrack->setSampleRate( track->sampleRate() ); - if( fileTags.value( Meta::valBitrate, 0 ).toInt() > 0 ) - metaTrack->setBitrate( fileTags.value( Meta::valBitrate ).toInt() ); - else if( track->bitrate() > 0 ) - metaTrack->setBitrate( track->bitrate() ); - - // createDate is already set in Track constructor - if( track->modifyDate().isValid() ) - metaTrack->setModifyDate( track->modifyDate() ); - - if( track->trackNumber() > 0 ) - metaTrack->setTrackNumber( track->trackNumber() ); - if( track->discNumber() > 0 ) - metaTrack->setDiscNumber( track->discNumber() ); - - if( origStats->lastPlayed().isValid() ) - metaTrack->setLastPlayed( origStats->lastPlayed() ); - if( origStats->firstPlayed().isValid() ) - metaTrack->setFirstPlayed( origStats->firstPlayed() ); - if( origStats->playCount() > 0 ) - metaTrack->setPlayCount( origStats->playCount() ); - - Meta::ReplayGainTag modes[] = { Meta::ReplayGain_Track_Gain, - Meta::ReplayGain_Track_Peak, - Meta::ReplayGain_Album_Gain, - Meta::ReplayGain_Album_Peak }; - for( int i=0; i<4; i++ ) - if( track->replayGain( modes[i] ) != 0 ) - metaTrack->setReplayGain( modes[i], track->replayGain( modes[i] ) ); - - Meta::LabelList labels = track->labels(); - foreach( Meta::LabelPtr label, labels ) - metaTrack->addLabel( label ); - - if( fileTags.value( Meta::valFormat, int(Amarok::Unknown) ).toInt() != int(Amarok::Unknown) ) - metaTrack->setType( Amarok::FileType( fileTags.value( Meta::valFormat ).toInt() ) ); - else if( Amarok::FileTypeSupport::fileType( track->type() ) != Amarok::Unknown ) - metaTrack->setType( Amarok::FileTypeSupport::fileType( track->type() ) ); - - // Used to be updated after changes commit to prevent crash on NULL pointer access - // if metaTrack had no album. - if( track->album() && metaTrack->album() ) - { - if( track->album()->hasAlbumArtist() && !metaTrack->album()->hasAlbumArtist() ) - metaTrack->setAlbumArtist( track->album()->albumArtist()->name() ); - - if( track->album()->hasImage() && !metaTrack->album()->hasImage() ) - metaTrack->album()->setImage( track->album()->image() ); - } - - metaTrack->endUpdate(); - metaTrack->setWriteFile( true ); - - // we have a first shot at the meta data (expecially ratings and playcounts from media - // collections) but we still need to trigger the collection scanner - // to get the album and other meta data correct. - // TODO m_collection->directoryWatcher()->delayedIncrementalScan( QFileInfo(url).path() ); - - return true; -} - -void -SqlCollectionLocation::showDestinationDialog( const Meta::TrackList &tracks, - bool removeSources, - const Transcoding::Configuration &configuration ) -{ - DEBUG_BLOCK - setGoingToRemoveSources( removeSources ); - - KIO::filesize_t transferSize = 0; - foreach( Meta::TrackPtr track, tracks ) - transferSize += track->filesize(); - - QStringList actual_folders = actualLocation(); // the folders in the collection - QStringList available_folders; // the folders which have freespace available - foreach(QString path, actual_folders) - { - if( path.isEmpty() ) - continue; - debug() << "Path" << path; - KDiskFreeSpaceInfo spaceInfo = KDiskFreeSpaceInfo::freeSpaceInfo( path ); - if( !spaceInfo.isValid() ) - continue; - - KIO::filesize_t totalCapacity = spaceInfo.size(); - KIO::filesize_t used = spaceInfo.used(); - - KIO::filesize_t freeSpace = totalCapacity - used; - - debug() << "used:" << used; - debug() << "total:" << totalCapacity; - debug() << "Free space" << freeSpace; - debug() << "transfersize" << transferSize; - - if( totalCapacity <= 0 ) // protect against div by zero - continue; //How did this happen? - - QFileInfo info( path ); - - // since bad things happen when drives become totally full - // we make sure there is at least ~500MB left - // finally, ensure the path is writable - debug() << ( freeSpace - transferSize ); - if( ( freeSpace - transferSize ) > 1024*1024*500 && info.isWritable() ) - available_folders << path; - } - - if( available_folders.size() <= 0 ) - { - debug() << "No space available or not writable"; - CollectionLocationDelegate *delegate = Amarok::Components::collectionLocationDelegate(); - delegate->notWriteable( this ); - abort(); - return; - } - - OrganizeCollectionDelegate *delegate = m_delegateFactory->createDelegate(); - delegate->setTracks( tracks ); - delegate->setFolders( available_folders ); - delegate->setIsOrganizing( ( collection() == source()->collection() ) ); - delegate->setTranscodingConfiguration( configuration ); - delegate->setCaption( operationText( configuration ) ); - - connect( delegate, SIGNAL(accepted()), SLOT(slotDialogAccepted()) ); - connect( delegate, SIGNAL(rejected()), SLOT(slotDialogRejected()) ); - delegate->show(); -} - -void -SqlCollectionLocation::slotDialogAccepted() -{ - DEBUG_BLOCK - sender()->deleteLater(); - OrganizeCollectionDelegate *ocDelegate = qobject_cast( sender() ); - m_destinations = ocDelegate->destinations(); - m_overwriteFiles = ocDelegate->overwriteDestinations(); - if( isGoingToRemoveSources() ) - { - CollectionLocationDelegate *delegate = Amarok::Components::collectionLocationDelegate(); - const bool del = delegate->reallyMove( this, m_destinations.keys() ); - if( !del ) - { - abort(); - return; - } - } - slotShowDestinationDialogDone(); -} - -void -SqlCollectionLocation::slotDialogRejected() -{ - DEBUG_BLOCK - sender()->deleteLater(); - abort(); -} - -void -SqlCollectionLocation::slotJobFinished( KJob *job ) -{ - DEBUG_BLOCK - - Meta::TrackPtr track = m_jobs.value( job ); - if( job->error() && job->error() != KIO::ERR_FILE_ALREADY_EXIST ) - { - //TODO: proper error handling - warning() << "An error occurred when copying a file: " << job->errorString(); - source()->transferError( track, KIO::buildErrorString( job->error(), job->errorString() ) ); - m_destinations.remove( track ); - } - else - source()->transferSuccessful( track ); - - m_jobs.remove( job ); - job->deleteLater(); - -} - -void -SqlCollectionLocation::slotRemoveJobFinished( KJob *job ) -{ - DEBUG_BLOCK - Meta::TrackPtr track = m_removejobs.value( job ); - if( job->error() ) - { - //TODO: proper error handling - warning() << "An error occurred when removing a file: " << job->errorString(); - } - - // -- remove the track from the database if it's gone - if( !QFile(track->playableUrl().path()).exists() ) - { - // Remove the track from the database - remove( track ); - - //we assume that KIO works correctly... - transferSuccessful( track ); - } - else - { - transferError( track, KIO::buildErrorString( job->error(), job->errorString() ) ); - } - - m_removejobs.remove( job ); - job->deleteLater(); - - if( !startNextRemoveJob() ) - { - slotRemoveOperationFinished(); - } - -} - -void SqlCollectionLocation::slotTransferJobFinished( KJob* job ) -{ - DEBUG_BLOCK - if( job->error() ) - { - debug() << job->errorText(); - } - // filter the list of destinations to only include tracks - // that were successfully copied - foreach( const Meta::TrackPtr &track, m_destinations.keys() ) - { - if( QFile::exists( m_destinations[ track ] ) ) - insert( track, m_destinations[ track ] ); - m_originalUrls[track] = track->playableUrl(); - } - debug () << "m_originalUrls" << m_originalUrls; - slotCopyOperationFinished(); -} - -void SqlCollectionLocation::slotTransferJobAborted() -{ - DEBUG_BLOCK - if( !m_transferjob ) - return; - m_transferjob->kill(); - // filter the list of destinations to only include tracks - // that were successfully copied - foreach( const Meta::TrackPtr &track, m_destinations.keys() ) - { - if( QFile::exists( m_destinations[ track ] ) ) - insert( track, m_destinations[ track ] ); // was already copied, so have to insert it in the db - m_originalUrls[track] = track->playableUrl(); - } - abort(); -} - - -void -SqlCollectionLocation::copyUrlsToCollection( const QMap &sources, - const Transcoding::Configuration &configuration ) -{ - DEBUG_BLOCK - m_sources = sources; - - QString statusBarTxt = operationInProgressText( configuration, sources.count() ); - m_transferjob = new TransferJob( this, configuration ); - Amarok::Components::logger()->newProgressOperation( m_transferjob, statusBarTxt, this, - SLOT(slotTransferJobAborted()) ); - connect( m_transferjob, SIGNAL(result(KJob*)), SLOT(slotTransferJobFinished(KJob*)) ); - m_transferjob->start(); -} - -void -SqlCollectionLocation::removeUrlsFromCollection( const Meta::TrackList &sources ) -{ - DEBUG_BLOCK - - m_removetracks = sources; - - if( !startNextRemoveJob() ) //this signal needs to be called no matter what, even if there are no job finishes to call it - slotRemoveOperationFinished(); -} - -void -SqlCollectionLocation::setOrganizeCollectionDelegateFactory( OrganizeCollectionDelegateFactory *fac ) -{ - m_delegateFactory = fac; -} - -bool SqlCollectionLocation::startNextJob( const Transcoding::Configuration configuration ) -{ - DEBUG_BLOCK - if( !m_sources.isEmpty() ) - { - Meta::TrackPtr track = m_sources.keys().first(); - KUrl src = m_sources.take( track ); - - KUrl dest = m_destinations[ track ]; - dest.cleanPath(); - src.cleanPath(); - - bool hasMoodFile = QFile::exists( moodFile( src ).toLocalFile() ); - bool isJustCopy = configuration.isJustCopy( track ); - - if( isJustCopy ) - debug() << "copying from " << src << " to " << dest; - else - debug() << "transcoding from " << src << " to " << dest; - - KFileItem srcInfo( src, src.toMimeDataString(), KFileItem::Unknown ); - if( !srcInfo.isFile() ) - { - warning() << "Source track" << src << "was no file"; - source()->transferError( track, i18n( "Source track does not exist: %1", src.pathOrUrl() ) ); - return true; // Attempt to copy/move the next item in m_sources - } - - QFileInfo destInfo( dest.pathOrUrl() ); - QDir dir = destInfo.dir(); - if( !dir.exists() ) - { - if( !dir.mkpath( "." ) ) - { - warning() << "Could not create directory " << dir; - source()->transferError(track, i18n( "Could not create directory: %1", dir.path() ) ); - return true; // Attempt to copy/move the next item in m_sources - } - } - - KIO::JobFlags flags; - if( isJustCopy ) - { - flags = KIO::HideProgressInfo; - if( m_overwriteFiles ) - { - flags |= KIO::Overwrite; - } - } - - KJob *job = 0; - KJob *moodJob = 0; - - if( src.equals( dest ) ) - { - warning() << "move to itself found: " << destInfo.absoluteFilePath(); - m_transferjob->slotJobFinished( 0 ); - if( m_sources.isEmpty() ) - return false; - return true; - } - else if( isGoingToRemoveSources() && source()->collection() == collection() ) - { - debug() << "moving!"; - job = KIO::file_move( src, dest, -1, flags ); - if( hasMoodFile ) - { - KUrl moodSrc = moodFile( src ); - KUrl moodDest = moodFile( dest ); - moodJob = KIO::file_move( moodSrc, moodDest, -1, flags ); - } - } - else - { - //later on in the case that remove is called, the file will be deleted because we didn't apply moveByDestination to the track - if( isJustCopy ) - job = KIO::file_copy( src, dest, -1, flags ); - else - { - QString destPath = dest.path(); - destPath.truncate( dest.path().lastIndexOf( '.' ) + 1 ); - destPath.append( Amarok::Components::transcodingController()-> - format( configuration.encoder() )->fileExtension() ); - dest.setPath( destPath ); - job = new Transcoding::Job( src, dest, configuration, this ); - job->start(); - } - - if( hasMoodFile ) - { - KUrl moodSrc = moodFile( src ); - KUrl moodDest = moodFile( dest ); - moodJob = KIO::file_copy( moodSrc, moodDest, -1, flags ); - } - } - if( job ) //just to be safe - { - connect( job, SIGNAL(result(KJob*)), SLOT(slotJobFinished(KJob*)) ); - connect( job, SIGNAL(result(KJob*)), m_transferjob, SLOT(slotJobFinished(KJob*)) ); - m_transferjob->addSubjob( job ); - - if( moodJob ) - { - connect( moodJob, SIGNAL(result(KJob*)), m_transferjob, SLOT(slotJobFinished(KJob*)) ); - m_transferjob->addSubjob( moodJob ); - } - - QString name = track->prettyName(); - if( track->artist() ) - name = QString( "%1 - %2" ).arg( track->artist()->name(), track->prettyName() ); - - if( isJustCopy ) - m_transferjob->emitInfo( i18n( "Transferring: %1", name ) ); - else - m_transferjob->emitInfo( i18n( "Transcoding: %1", name ) ); - m_jobs.insert( job, track ); - return true; - } - debug() << "JOB NULL OMG!11"; - } - return false; -} - -bool SqlCollectionLocation::startNextRemoveJob() -{ - DEBUG_BLOCK - while ( !m_removetracks.isEmpty() ) - { - Meta::TrackPtr track = m_removetracks.takeFirst(); - // KUrl src = track->playableUrl(); - KUrl src = track->playableUrl(); - KUrl srcMoodFile = moodFile( src ); - - debug() << "isGoingToRemoveSources() " << isGoingToRemoveSources(); - if( isGoingToRemoveSources() && destination() ) // is organize operation? - { - SqlCollectionLocation* destinationloc = dynamic_cast( destination() ); - - // src = destinationloc->m_originalUrls[track]; - if( destinationloc && src == destinationloc->m_destinations[track] ) { - debug() << "src == dst ("<prettyName(); - if( track->artist() ) - name = QString( "%1 - %2" ).arg( track->artist()->name(), track->prettyName() ); - - Amarok::Components::logger()->newProgressOperation( job, i18n( "Removing: %1", name ) ); - m_removejobs.insert( job, track ); - return true; - } - break; - } - return false; -} - -KUrl -SqlCollectionLocation::moodFile( const KUrl &track ) const -{ - KUrl moodPath = track; - moodPath.setFileName( '.' + moodPath.fileName().replace( QRegExp( "(\\.\\w{2,5})$" ), ".mood" ) ); - return moodPath; -} - -TransferJob::TransferJob( SqlCollectionLocation * location, const Transcoding::Configuration & configuration ) - : KCompositeJob( 0 ) - , m_location( location ) - , m_killed( false ) - , m_transcodeFormat( configuration ) -{ - setCapabilities( KJob::Killable ); - debug() << "TransferJob::TransferJob"; -} - -bool TransferJob::addSubjob( KJob* job ) -{ - connect( job, SIGNAL(processedAmount(KJob*,KJob::Unit,qulonglong)), - this, SLOT(propagateProcessedAmount(KJob*,KJob::Unit,qulonglong)) ); - //KCompositeJob::addSubjob doesn't handle progress reporting. - return KCompositeJob::addSubjob( job ); -} - -void TransferJob::emitInfo(const QString& message) -{ - emit infoMessage( this, message ); -} - -void TransferJob::slotResult( KJob *job ) -{ - // When copying without overwriting some files might already be - // there and it is not a reason for stopping entire transfer. - if ( job->error() == KIO::ERR_FILE_ALREADY_EXIST ) - removeSubjob( job ); - else - KCompositeJob::slotResult( job ); -} - -void TransferJob::start() -{ - DEBUG_BLOCK - if( m_location == 0 ) - { - setError( 1 ); - setErrorText( "Location is null!" ); - emitResult(); - return; - } - QTimer::singleShot( 0, this, SLOT(doWork()) ); -} - -void TransferJob::doWork() -{ - DEBUG_BLOCK - setTotalAmount( KJob::Files, m_location->m_sources.size() ); - setTotalAmount( KJob::Bytes, m_location->m_sources.size() * 1000 ); - setProcessedAmount( KJob::Files, 0 ); - if( !m_location->startNextJob( m_transcodeFormat ) ) - { - if( !hasSubjobs() ) - emitResult(); - } -} - -void TransferJob::slotJobFinished( KJob* job ) -{ - DEBUG_BLOCK - if( job ) - removeSubjob( job ); - if( m_killed ) - { - debug() << "slotJobFinished entered, but it should be killed!"; - return; - } - setProcessedAmount( KJob::Files, processedAmount( KJob::Files ) + 1 ); - emitPercent( processedAmount( KJob::Files ) * 1000, totalAmount( KJob::Bytes ) ); - debug() << "processed" << processedAmount( KJob::Files ) << " totalAmount" << totalAmount( KJob::Files ); - if( !m_location->startNextJob( m_transcodeFormat ) ) - { - debug() << "sources empty"; - // don't quit if there are still subjobs - if( !hasSubjobs() ) - emitResult(); - else - debug() << "have subjobs"; - } -} - -bool TransferJob::doKill() -{ - DEBUG_BLOCK - m_killed = true; - foreach( KJob* job, subjobs() ) - { - job->kill(); - } - clearSubjobs(); - return KJob::doKill(); -} - -void TransferJob::propagateProcessedAmount( KJob *job, KJob::Unit unit, qulonglong amount ) //SLOT -{ - if( unit == KJob::Bytes ) - { - qulonglong currentJobAmount = ( static_cast< qreal >( amount ) / job->totalAmount( KJob::Bytes ) ) * 1000; - - setProcessedAmount( KJob::Bytes, processedAmount( KJob::Files ) * 1000 + currentJobAmount ); - emitPercent( processedAmount( KJob::Bytes ), totalAmount( KJob::Bytes ) ); - } -} - -#include "moc_SqlCollectionLocation.cpp" diff --git a/amarok/src/core-impl/collections/db/sql/SqlCollectionLocation.h b/amarok/src/core-impl/collections/db/sql/SqlCollectionLocation.h deleted file mode 100644 index da1b2e57..00000000 --- a/amarok/src/core-impl/collections/db/sql/SqlCollectionLocation.h +++ /dev/null @@ -1,165 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Maximilian Kossick * - * Copyright (c) 2008 Jason A. Donenfeld * - * Copyright (c) 2010 Casey Link * - * Copyright (c) 2010 Teo Mrnjavac * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_SQLCOLLECTIONLOCATION_H -#define AMAROK_SQLCOLLECTIONLOCATION_H - -#include "amarok_sqlcollection_export.h" -#include "core/collections/CollectionLocation.h" - -#include -#include -#include -#include -#include - -class OrganizeCollectionDelegateFactory; - -namespace Collections { - -class SqlCollection; - -class SqlCollectionLocation; - -/** - * @class TransferJob - * A simple class that provides KJob functionality (progress reporting, aborting, etc) for sqlcollectionlocation. - * It calls SqlCollectionLocation::startNextJob() - */ -class TransferJob : public KCompositeJob -{ - Q_OBJECT - public: - TransferJob( SqlCollectionLocation * location, const Transcoding::Configuration & configuration ); - - void start(); - virtual bool addSubjob( KJob* job ); - - void emitInfo( const QString &message ); - public slots: - /** - * A move or copy job finished - */ - void slotJobFinished( KJob *job ); - protected slots: - void slotResult( KJob *job ); - void doWork(); - void propagateProcessedAmount( KJob *job, KJob::Unit unit, qulonglong amount); - protected: - virtual bool doKill(); - private: - SqlCollectionLocation* m_location; - bool m_killed; - Transcoding::Configuration m_transcodeFormat; -}; - -class AMAROK_SQLCOLLECTION_EXPORT SqlCollectionLocation : public CollectionLocation -{ - Q_OBJECT - - public: - SqlCollectionLocation( SqlCollection *collection ); - virtual ~SqlCollectionLocation(); - - virtual QString prettyLocation() const; - virtual QStringList actualLocation() const; - virtual bool isWritable() const; - virtual bool isOrganizable() const; - - bool remove( const Meta::TrackPtr &track ); - virtual bool insert( const Meta::TrackPtr &track, const QString &url ); - - //dependency injectors - void setOrganizeCollectionDelegateFactory( OrganizeCollectionDelegateFactory *fac ); - - protected: - virtual void showDestinationDialog( const Meta::TrackList &tracks, - bool removeSources, - const Transcoding::Configuration &configuration ); - virtual void copyUrlsToCollection( const QMap &sources, - const Transcoding::Configuration & configuration ); - virtual void removeUrlsFromCollection( const Meta::TrackList &sources ); - - private slots: - void slotDialogAccepted(); - void slotDialogRejected(); - void slotJobFinished( KJob *job ); - void slotRemoveJobFinished( KJob *job ); - void slotTransferJobFinished( KJob *job ); - void slotTransferJobAborted(); - - private: - KUrl moodFile( const KUrl &track ) const; - void migrateLabels( const QMap &trackMap ); - bool startNextJob( const Transcoding::Configuration configuration ); - bool startNextRemoveJob(); - - Collections::SqlCollection *m_collection; - OrganizeCollectionDelegateFactory *m_delegateFactory; - QMap m_destinations; - QMap m_sources; - Meta::TrackList m_removetracks; - QHash m_originalUrls; - bool m_overwriteFiles; - QMap m_jobs; - QMap m_removejobs; - TransferJob* m_transferjob; - friend class TransferJob; // so the transfer job can run the jobs -}; - -class SqlCollectionLocationFactory -{ - public: - virtual SqlCollectionLocation* createSqlCollectionLocation() const = 0; - virtual ~SqlCollectionLocationFactory() {} -}; - -} //namespace Collections - -class AMAROK_SQLCOLLECTION_EXPORT OrganizeCollectionDelegate : public QObject -{ - Q_OBJECT -public: - OrganizeCollectionDelegate() : QObject() {} - virtual ~ OrganizeCollectionDelegate() {} - - virtual void setTracks( const Meta::TrackList &tracks ) = 0; - virtual void setFolders( const QStringList &folders ) = 0; - virtual void setIsOrganizing( bool organizing ) = 0; - virtual void setTranscodingConfiguration( const Transcoding::Configuration &configuration ) = 0; - virtual void setCaption( const QString &caption ) = 0; - - virtual void show() = 0; - - virtual bool overwriteDestinations() const = 0; - virtual QMap destinations() const = 0; - -signals: - void accepted(); - void rejected(); -}; - -class OrganizeCollectionDelegateFactory -{ -public: - virtual OrganizeCollectionDelegate* createDelegate() = 0; - virtual ~OrganizeCollectionDelegateFactory() {} -}; - -#endif diff --git a/amarok/src/core-impl/collections/db/sql/SqlMeta.cpp b/amarok/src/core-impl/collections/db/sql/SqlMeta.cpp deleted file mode 100644 index e02d9dcf..00000000 --- a/amarok/src/core-impl/collections/db/sql/SqlMeta.cpp +++ /dev/null @@ -1,2243 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Maximilian Kossick * - * Copyright (c) 2008 Daniel Winter * - * Copyright (c) 2010 Ralf Engels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "SqlMeta" - -#include "SqlMeta.h" - -#include "amarokconfig.h" - -#include "SqlCapabilities.h" -#include "SqlCollection.h" -#include "SqlQueryMaker.h" -#include "SqlRegistry.h" -#include "SqlReadLabelCapability.h" -#include "SqlWriteLabelCapability.h" - -#include "MetaTagLib.h" // for getting an embedded cover - -#include "amarokurls/BookmarkMetaActions.h" -#include -#include "core/meta/support/MetaUtility.h" -#include "core/support/Amarok.h" -#include "core/support/Debug.h" -#include "core/capabilities/BookmarkThisCapability.h" -#include "core-impl/capabilities/AlbumActionsCapability.h" -#include "core-impl/collections/db/MountPointManager.h" -#include "core-impl/collections/support/ArtistHelper.h" -#include "core-impl/collections/support/jobs/WriteTagsJob.h" -#include "covermanager/CoverCache.h" -#include "covermanager/CoverFetcher.h" - -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include - -// additional constants -namespace Meta -{ - static const qint64 valAlbumId = valCustom + 1; -} - -using namespace Meta; - -QString -SqlTrack::getTrackReturnValues() -{ - //do not use any weird column names that contains commas: this will break getTrackReturnValuesCount() - // NOTE: when changing this, always check that SqlTrack::TrackReturnIndex enum remains valid - return "urls.id, urls.deviceid, urls.rpath, urls.directory, urls.uniqueid, " - "tracks.id, tracks.title, tracks.comment, " - "tracks.tracknumber, tracks.discnumber, " - "statistics.score, statistics.rating, " - "tracks.bitrate, tracks.length, " - "tracks.filesize, tracks.samplerate, " - "statistics.id, " - "statistics.createdate, statistics.accessdate, " - "statistics.playcount, tracks.filetype, tracks.bpm, " - "tracks.createdate, tracks.modifydate, tracks.albumgain, tracks.albumpeakgain, " - "tracks.trackgain, tracks.trackpeakgain, " - "artists.name, artists.id, " // TODO: just reading the id should be sufficient - "albums.name, albums.id, albums.artist, " // TODO: again here - "genres.name, genres.id, " // TODO: again here - "composers.name, composers.id, " // TODO: again here - "years.name, years.id"; // TODO: again here -} - -QString -SqlTrack::getTrackJoinConditions() -{ - return "LEFT JOIN tracks ON urls.id = tracks.url " - "LEFT JOIN statistics ON urls.id = statistics.url " - "LEFT JOIN artists ON tracks.artist = artists.id " - "LEFT JOIN albums ON tracks.album = albums.id " - "LEFT JOIN genres ON tracks.genre = genres.id " - "LEFT JOIN composers ON tracks.composer = composers.id " - "LEFT JOIN years ON tracks.year = years.id"; -} - -int -SqlTrack::getTrackReturnValueCount() -{ - static int count = getTrackReturnValues().split( ',' ).count(); - return count; -} - -SqlTrack::SqlTrack( Collections::SqlCollection *collection, int deviceId, - const QString &rpath, int directoryId, const QString uidUrl ) - : Track() - , m_collection( collection ) - , m_batchUpdate( 0 ) - , m_writeFile( true ) - , m_labelsInCache( false ) -{ - m_batchUpdate = 1; // I don't want commits yet - - m_urlId = -1; // this will be set with the first database write - m_trackId = -1; // this will be set with the first database write - m_statisticsId = -1; - - setUrl( deviceId, rpath, directoryId ); - m_url = m_cache.value( Meta::valUrl ).toString(); // SqlRegistry already has this url - setUidUrl( uidUrl ); - m_uid = m_cache.value( Meta::valUniqueId ).toString(); // SqlRegistry already has this uid - - - // ensure that these values get a correct database id - m_cache.insert( Meta::valAlbum, QVariant() ); - m_cache.insert( Meta::valArtist, QVariant() ); - m_cache.insert( Meta::valComposer, QVariant() ); - m_cache.insert( Meta::valYear, QVariant() ); - m_cache.insert( Meta::valGenre, QVariant() ); - - m_trackNumber = 0; - m_discNumber = 0; - m_score = 0; - m_rating = 0; - m_bitrate = 0; - m_length = 0; - m_filesize = 0; - m_sampleRate = 0; - m_playCount = 0; - m_bpm = 0.0; - m_createDate = QDateTime::currentDateTime(); - m_cache.insert( Meta::valCreateDate, m_createDate ); // ensure that the created date is written the next time - - m_trackGain = 0.0; - m_trackPeakGain = 0.0; - m_albumGain = 0.0; - m_albumPeakGain = 0.0; - - m_batchUpdate = 0; // reset in-batch-update without committing - - m_filetype = Amarok::Unknown; -} - -SqlTrack::SqlTrack( Collections::SqlCollection *collection, const QStringList &result ) - : Track() - , m_collection( collection ) - , m_batchUpdate( 0 ) - , m_writeFile( true ) - , m_labelsInCache( false ) -{ - QStringList::ConstIterator iter = result.constBegin(); - m_urlId = (*(iter++)).toInt(); - Q_ASSERT( m_urlId > 0 && "refusing to create SqlTrack with non-positive urlId, please file a bug" ); - m_deviceId = (*(iter++)).toInt(); - Q_ASSERT( m_deviceId != 0 && "refusing to create SqlTrack with zero deviceId, please file a bug" ); - m_rpath = *(iter++); - m_directoryId = (*(iter++)).toInt(); - Q_ASSERT( m_directoryId > 0 && "refusing to create SqlTrack with non-positive directoryId, please file a bug" ); - m_url = KUrl( m_collection->mountPointManager()->getAbsolutePath( m_deviceId, m_rpath ) ); - m_uid = *(iter++); - m_trackId = (*(iter++)).toInt(); - m_title = *(iter++); - m_comment = *(iter++); - m_trackNumber = (*(iter++)).toInt(); - m_discNumber = (*(iter++)).toInt(); - m_score = (*(iter++)).toDouble(); - m_rating = (*(iter++)).toInt(); - m_bitrate = (*(iter++)).toInt(); - m_length = (*(iter++)).toInt(); - m_filesize = (*(iter++)).toInt(); - m_sampleRate = (*(iter++)).toInt(); - m_statisticsId = (*(iter++)).toInt(); - uint time = (*(iter++)).toUInt(); - if( time > 0 ) - m_firstPlayed = QDateTime::fromTime_t(time); - time = (*(iter++)).toUInt(); - if( time > 0 ) - m_lastPlayed = QDateTime::fromTime_t(time); - m_playCount = (*(iter++)).toInt(); - m_filetype = Amarok::FileType( (*(iter++)).toInt() ); - m_bpm = (*(iter++)).toFloat(); - m_createDate = QDateTime::fromTime_t((*(iter++)).toUInt()); - m_modifyDate = QDateTime::fromTime_t((*(iter++)).toUInt()); - - // if there is no track gain, we assume a gain of 0 - // if there is no album gain, we use the track gain - QString albumGain = *(iter++); - QString albumPeakGain = *(iter++); - m_trackGain = (*(iter++)).toDouble(); - m_trackPeakGain = (*(iter++)).toDouble(); - if ( albumGain.isEmpty() ) - { - m_albumGain = m_trackGain; - m_albumPeakGain = m_trackPeakGain; - } - else - { - m_albumGain = albumGain.toDouble(); - m_albumPeakGain = albumPeakGain.toDouble(); - } - SqlRegistry* registry = m_collection->registry(); - - QString artist = *(iter++); - int artistId = (*(iter++)).toInt(); - if( artistId > 0 ) - m_artist = registry->getArtist( artistId, artist ); - - QString album = *(iter++); - int albumId =(*(iter++)).toInt(); - int albumArtistId = (*(iter++)).toInt(); - if( albumId > 0 ) // sanity check - m_album = registry->getAlbum( albumId, album, albumArtistId ); - - QString genre = *(iter++); - int genreId = (*(iter++)).toInt(); - if( genreId > 0 ) // sanity check - m_genre = registry->getGenre( genreId, genre ); - - QString composer = *(iter++); - int composerId = (*(iter++)).toInt(); - if( composerId > 0 ) // sanity check - m_composer = registry->getComposer( composerId, composer ); - - QString year = *(iter++); - int yearId = (*(iter++)).toInt(); - if( yearId > 0 ) // sanity check - m_year = registry->getYear( year.toInt(), yearId ); - //Q_ASSERT_X( iter == result.constEnd(), "SqlTrack( Collections::SqlCollection*, QStringList )", "number of expected fields did not match number of actual fields: expected " + result.size() ); -} - -SqlTrack::~SqlTrack() -{ - QWriteLocker locker( &m_lock ); - - if( !m_cache.isEmpty() ) - warning() << "Destroying track with unwritten meta information." << m_title << "cache:" << m_cache; - if( m_batchUpdate ) - warning() << "Destroying track with unclosed batch update." << m_title; -} - -QString -SqlTrack::name() const -{ - QReadLocker locker( &m_lock ); - return m_title; -} - -QString -SqlTrack::prettyName() const -{ - if ( !name().isEmpty() ) - return name(); - return prettyTitle( m_url.fileName() ); -} - -void -SqlTrack::setTitle( const QString &newTitle ) -{ - QWriteLocker locker( &m_lock ); - - if ( m_title != newTitle ) - commitIfInNonBatchUpdate( Meta::valTitle, newTitle ); -} - - -KUrl -SqlTrack::playableUrl() const -{ - QReadLocker locker( &m_lock ); - return m_url; -} - -QString -SqlTrack::prettyUrl() const -{ - QReadLocker locker( &m_lock ); - return m_url.path(); -} - -void -SqlTrack::setUrl( int deviceId, const QString &rpath, int directoryId ) -{ - QWriteLocker locker( &m_lock ); - - if( m_deviceId == deviceId && - m_rpath == rpath && - m_directoryId == directoryId ) - return; - - m_deviceId = deviceId; - m_rpath = rpath; - m_directoryId = directoryId; - - commitIfInNonBatchUpdate( Meta::valUrl, - m_collection->mountPointManager()->getAbsolutePath( m_deviceId, m_rpath ) ); -} - -QString -SqlTrack::uidUrl() const -{ - QReadLocker locker( &m_lock ); - return m_uid; -} - -void -SqlTrack::setUidUrl( const QString &uid ) -{ - QWriteLocker locker( &m_lock ); - - // -- ensure that the uid starts with the collections protocol (amarok-sqltrackuid) - QString newid = uid; - QString protocol; - if( m_collection ) - protocol = m_collection->uidUrlProtocol()+"://"; - if( !newid.startsWith( protocol ) ) - newid.prepend( protocol ); - - m_cache.insert( Meta::valUniqueId, newid ); - - if( m_batchUpdate == 0 ) - { - debug() << "setting uidUrl manually...did you really mean to do this?"; - commitIfInNonBatchUpdate(); - } -} - -QString -SqlTrack::notPlayableReason() const -{ - return localFileNotPlayableReason( playableUrl().toLocalFile() ); -} - -bool -SqlTrack::isEditable() const -{ - QReadLocker locker( &m_lock ); - - QFile::Permissions p = QFile::permissions( m_url.path() ); - const bool editable = ( p & QFile::WriteUser ) || ( p & QFile::WriteGroup ) || ( p & QFile::WriteOther ); - return m_collection && QFile::exists( m_url.path() ) && editable; -} - -Meta::AlbumPtr -SqlTrack::album() const -{ - QReadLocker locker( &m_lock ); - return m_album; -} - -void -SqlTrack::setAlbum( const QString &newAlbum ) -{ - QWriteLocker locker( &m_lock ); - - if( !m_album || m_album->name() != newAlbum ) - commitIfInNonBatchUpdate( Meta::valAlbum, newAlbum ); -} - -void -SqlTrack::setAlbum( int albumId ) -{ - QWriteLocker locker( &m_lock ); - - commitIfInNonBatchUpdate( Meta::valAlbumId, albumId ); -} - -Meta::ArtistPtr -SqlTrack::artist() const -{ - QReadLocker locker( &m_lock ); - return m_artist; -} - -void -SqlTrack::setArtist( const QString &newArtist ) -{ - QWriteLocker locker( &m_lock ); - - if( !m_artist || m_artist->name() != newArtist ) - commitIfInNonBatchUpdate( Meta::valArtist, newArtist ); -} - -void -SqlTrack::setAlbumArtist( const QString &newAlbumArtist ) -{ - if( m_album.isNull() ) - return; - - if( !newAlbumArtist.compare( "Various Artists", Qt::CaseInsensitive ) || - !newAlbumArtist.compare( i18n( "Various Artists" ), Qt::CaseInsensitive ) ) - { - commitIfInNonBatchUpdate( Meta::valCompilation, true ); - } - else - { - m_cache.insert( Meta::valAlbumArtist, ArtistHelper::realTrackArtist( newAlbumArtist ) ); - m_cache.insert( Meta::valCompilation, false ); - commitIfInNonBatchUpdate(); - } -} - -Meta::ComposerPtr -SqlTrack::composer() const -{ - QReadLocker locker( &m_lock ); - return m_composer; -} - -void -SqlTrack::setComposer( const QString &newComposer ) -{ - QWriteLocker locker( &m_lock ); - - if( !m_composer || m_composer->name() != newComposer ) - commitIfInNonBatchUpdate( Meta::valComposer, newComposer ); -} - -Meta::YearPtr -SqlTrack::year() const -{ - QReadLocker locker( &m_lock ); - return m_year; -} - -void -SqlTrack::setYear( int newYear ) -{ - QWriteLocker locker( &m_lock ); - - if( !m_year || m_year->year() != newYear ) - commitIfInNonBatchUpdate( Meta::valYear, newYear ); -} - -Meta::GenrePtr -SqlTrack::genre() const -{ - QReadLocker locker( &m_lock ); - return m_genre; -} - -void -SqlTrack::setGenre( const QString &newGenre ) -{ - QWriteLocker locker( &m_lock ); - - if( !m_genre || m_genre->name() != newGenre ) - commitIfInNonBatchUpdate( Meta::valGenre, newGenre ); -} - -QString -SqlTrack::type() const -{ - QReadLocker locker( &m_lock ); - - return m_url.isLocalFile() - ? Amarok::FileTypeSupport::toString( m_filetype ) - // don't localize. This is used in different files to identify streams, see EngineController quirks - : "stream"; -} - -void -SqlTrack::setType( Amarok::FileType newType ) -{ - QWriteLocker locker( &m_lock ); - - if ( m_filetype != newType ) - commitIfInNonBatchUpdate( Meta::valFormat, int(newType) ); -} - -qreal -SqlTrack::bpm() const -{ - QReadLocker locker( &m_lock ); - return m_bpm; -} - -void -SqlTrack::setBpm( const qreal newBpm ) -{ - QWriteLocker locker( &m_lock ); - - if ( m_bpm != newBpm ) - commitIfInNonBatchUpdate( Meta::valBpm, newBpm ); -} - -QString -SqlTrack::comment() const -{ - QReadLocker locker( &m_lock ); - return m_comment; -} - -void -SqlTrack::setComment( const QString &newComment ) -{ - QWriteLocker locker( &m_lock ); - - if( newComment != m_comment ) - commitIfInNonBatchUpdate( Meta::valComment, newComment ); -} - -double -SqlTrack::score() const -{ - QReadLocker locker( &m_lock ); - return m_score; -} - -void -SqlTrack::setScore( double newScore ) -{ - QWriteLocker locker( &m_lock ); - - newScore = qBound( double(0), newScore, double(100) ); - if( qAbs( newScore - m_score ) > 0.001 ) // we don't commit for minimal changes - commitIfInNonBatchUpdate( Meta::valScore, newScore ); -} - -int -SqlTrack::rating() const -{ - QReadLocker locker( &m_lock ); - return m_rating; -} - -void -SqlTrack::setRating( int newRating ) -{ - QWriteLocker locker( &m_lock ); - - newRating = qBound( 0, newRating, 10 ); - if( newRating != m_rating ) - commitIfInNonBatchUpdate( Meta::valRating, newRating ); -} - -qint64 -SqlTrack::length() const -{ - QReadLocker locker( &m_lock ); - return m_length; -} - -void -SqlTrack::setLength( qint64 newLength ) -{ - QWriteLocker locker( &m_lock ); - - if( newLength != m_length ) - commitIfInNonBatchUpdate( Meta::valLength, newLength ); -} - -int -SqlTrack::filesize() const -{ - QReadLocker locker( &m_lock ); - return m_filesize; -} - -int -SqlTrack::sampleRate() const -{ - QReadLocker locker( &m_lock ); - return m_sampleRate; -} - -void -SqlTrack::setSampleRate( int newSampleRate ) -{ - QWriteLocker locker( &m_lock ); - - if( newSampleRate != m_sampleRate ) - commitIfInNonBatchUpdate( Meta::valSamplerate, newSampleRate ); -} - -int -SqlTrack::bitrate() const -{ - QReadLocker locker( &m_lock ); - return m_bitrate; -} - -void -SqlTrack::setBitrate( int newBitrate ) -{ - QWriteLocker locker( &m_lock ); - - if( newBitrate != m_bitrate ) - commitIfInNonBatchUpdate( Meta::valBitrate, newBitrate ); -} - -QDateTime -SqlTrack::createDate() const -{ - QReadLocker locker( &m_lock ); - return m_createDate; -} - -QDateTime -SqlTrack::modifyDate() const -{ - QReadLocker locker( &m_lock ); - return m_modifyDate; -} - -void -SqlTrack::setModifyDate( const QDateTime &newTime ) -{ - QWriteLocker locker( &m_lock ); - - if( newTime != m_modifyDate ) - commitIfInNonBatchUpdate( Meta::valModified, newTime ); -} - -int -SqlTrack::trackNumber() const -{ - QReadLocker locker( &m_lock ); - return m_trackNumber; -} - -void -SqlTrack::setTrackNumber( int newTrackNumber ) -{ - QWriteLocker locker( &m_lock ); - - if( newTrackNumber != m_trackNumber ) - commitIfInNonBatchUpdate( Meta::valTrackNr, newTrackNumber ); -} - -int -SqlTrack::discNumber() const -{ - QReadLocker locker( &m_lock ); - return m_discNumber; -} - -void -SqlTrack::setDiscNumber( int newDiscNumber ) -{ - QWriteLocker locker( &m_lock ); - - if( newDiscNumber != m_discNumber ) - commitIfInNonBatchUpdate( Meta::valDiscNr, newDiscNumber ); -} - -QDateTime -SqlTrack::lastPlayed() const -{ - QReadLocker locker( &m_lock ); - return m_lastPlayed; -} - -void -SqlTrack::setLastPlayed( const QDateTime &newTime ) -{ - QWriteLocker locker( &m_lock ); - - if( newTime != m_lastPlayed ) - commitIfInNonBatchUpdate( Meta::valLastPlayed, newTime ); -} - -QDateTime -SqlTrack::firstPlayed() const -{ - QReadLocker locker( &m_lock ); - return m_firstPlayed; -} - -void -SqlTrack::setFirstPlayed( const QDateTime &newTime ) -{ - QWriteLocker locker( &m_lock ); - - if( newTime != m_firstPlayed ) - commitIfInNonBatchUpdate( Meta::valFirstPlayed, newTime ); -} - -int -SqlTrack::playCount() const -{ - QReadLocker locker( &m_lock ); - return m_playCount; -} - -void -SqlTrack::setPlayCount( const int newCount ) -{ - QWriteLocker locker( &m_lock ); - - if( newCount != m_playCount ) - commitIfInNonBatchUpdate( Meta::valPlaycount, newCount ); -} - -qreal -SqlTrack::replayGain( ReplayGainTag mode ) const -{ - QReadLocker locker(&(const_cast(this)->m_lock)); - - switch( mode ) - { - case Meta::ReplayGain_Track_Gain: - return m_trackGain; - case Meta::ReplayGain_Track_Peak: - return m_trackPeakGain; - case Meta::ReplayGain_Album_Gain: - return m_albumGain; - case Meta::ReplayGain_Album_Peak: - return m_albumPeakGain; - } - return 0.0; -} - -void -SqlTrack::setReplayGain( Meta::ReplayGainTag mode, qreal value ) -{ - if( qAbs( value - replayGain( mode ) ) < 0.01 ) - return; - - { - QWriteLocker locker( &m_lock ); - - switch( mode ) - { - case Meta::ReplayGain_Track_Gain: - m_cache.insert( Meta::valTrackGain, value ); - break; - case Meta::ReplayGain_Track_Peak: - m_cache.insert( Meta::valTrackGainPeak, value ); - break; - case Meta::ReplayGain_Album_Gain: - m_cache.insert( Meta::valAlbumGain, value ); - break; - case Meta::ReplayGain_Album_Peak: - m_cache.insert( Meta::valAlbumGainPeak, value ); - break; - } - - commitIfInNonBatchUpdate(); - } -} - - -void -SqlTrack::beginUpdate() -{ - QWriteLocker locker( &m_lock ); - m_batchUpdate++; -} - -void -SqlTrack::endUpdate() -{ - QWriteLocker locker( &m_lock ); - Q_ASSERT( m_batchUpdate > 0 ); - m_batchUpdate--; - commitIfInNonBatchUpdate(); -} - -void -SqlTrack::commitIfInNonBatchUpdate( qint64 field, const QVariant &value ) -{ - m_cache.insert( field, value ); - commitIfInNonBatchUpdate(); -} - -void -SqlTrack::commitIfInNonBatchUpdate() -{ - if( m_batchUpdate > 0 || m_cache.isEmpty() ) - return; // nothing to do - - // debug() << "SqlTrack::commitMetaDataChanges " << m_cache; - - QString oldUid = m_uid; - - // for all the following objects we need to invalidate the cache and - // notify the observers after the update - KSharedPtr oldArtist; - KSharedPtr newArtist; - KSharedPtr oldAlbum; - KSharedPtr newAlbum; - KSharedPtr oldComposer; - KSharedPtr newComposer; - KSharedPtr oldGenre; - KSharedPtr newGenre; - KSharedPtr oldYear; - KSharedPtr newYear; - - if( m_cache.contains( Meta::valFormat ) ) - m_filetype = Amarok::FileType(m_cache.value( Meta::valFormat ).toInt()); - if( m_cache.contains( Meta::valTitle ) ) - m_title = m_cache.value( Meta::valTitle ).toString(); - if( m_cache.contains( Meta::valComment ) ) - m_comment = m_cache.value( Meta::valComment ).toString(); - if( m_cache.contains( Meta::valScore ) ) - m_score = m_cache.value( Meta::valScore ).toDouble(); - if( m_cache.contains( Meta::valRating ) ) - m_rating = m_cache.value( Meta::valRating ).toInt(); - if( m_cache.contains( Meta::valLength ) ) - m_length = m_cache.value( Meta::valLength ).toLongLong(); - if( m_cache.contains( Meta::valSamplerate ) ) - m_sampleRate = m_cache.value( Meta::valSamplerate ).toInt(); - if( m_cache.contains( Meta::valBitrate ) ) - m_bitrate = m_cache.value( Meta::valBitrate ).toInt(); - if( m_cache.contains( Meta::valFirstPlayed ) ) - m_firstPlayed = m_cache.value( Meta::valFirstPlayed ).toDateTime(); - if( m_cache.contains( Meta::valLastPlayed ) ) - m_lastPlayed = m_cache.value( Meta::valLastPlayed ).toDateTime(); - if( m_cache.contains( Meta::valTrackNr ) ) - m_trackNumber = m_cache.value( Meta::valTrackNr ).toInt(); - if( m_cache.contains( Meta::valDiscNr ) ) - m_discNumber = m_cache.value( Meta::valDiscNr ).toInt(); - if( m_cache.contains( Meta::valPlaycount ) ) - m_playCount = m_cache.value( Meta::valPlaycount ).toInt(); - if( m_cache.contains( Meta::valCreateDate ) ) - m_createDate = m_cache.value( Meta::valCreateDate ).toDateTime(); - if( m_cache.contains( Meta::valModified ) ) - m_modifyDate = m_cache.value( Meta::valModified ).toDateTime(); - if( m_cache.contains( Meta::valTrackGain ) ) - m_trackGain = m_cache.value( Meta::valTrackGain ).toDouble(); - if( m_cache.contains( Meta::valTrackGainPeak ) ) - m_trackPeakGain = m_cache.value( Meta::valTrackGainPeak ).toDouble(); - if( m_cache.contains( Meta::valAlbumGain ) ) - m_albumGain = m_cache.value( Meta::valAlbumGain ).toDouble(); - if( m_cache.contains( Meta::valAlbumGainPeak ) ) - m_albumPeakGain = m_cache.value( Meta::valAlbumGainPeak ).toDouble(); - - if( m_cache.contains( Meta::valUrl ) ) - { - // slight problem here: it is possible to set the url to the one of an already - // existing track, which is forbidden by the database - // At least the ScanResultProcessor handles this problem - - KUrl oldUrl = m_url; - KUrl newUrl = m_cache.value( Meta::valUrl ).toString(); - if( oldUrl != newUrl ) - m_collection->registry()->updateCachedUrl( oldUrl.path(), newUrl.path() ); - m_url = newUrl; - // debug() << "m_cache contains a new URL, setting m_url to " << m_url << " from " << oldUrl; - } - - if( m_cache.contains( Meta::valArtist ) ) - { - //invalidate cache of the old artist... - oldArtist = static_cast(m_artist.data()); - m_artist = m_collection->registry()->getArtist( m_cache.value( Meta::valArtist ).toString() ); - //and the new one - newArtist = static_cast(m_artist.data()); - - // if the current album is no compilation and we aren't changing - // the album anyway, then we need to create a new album with the - // new artist. - if( m_album ) - { - bool supp = m_album->suppressImageAutoFetch(); - m_album->setSuppressImageAutoFetch( true ); - - if( m_album->hasAlbumArtist() && - m_album->albumArtist() == oldArtist && - !m_cache.contains( Meta::valAlbum ) && - !m_cache.contains( Meta::valAlbumId ) ) - { - m_cache.insert( Meta::valAlbum, m_album->name() ); - } - - m_album->setSuppressImageAutoFetch( supp ); - } - } - - if( m_cache.contains( Meta::valAlbum ) || - m_cache.contains( Meta::valAlbumId ) || - m_cache.contains( Meta::valAlbumArtist ) ) - { - oldAlbum = static_cast(m_album.data()); - - if( m_cache.contains( Meta::valAlbumId ) ) - m_album = m_collection->registry()->getAlbum( m_cache.value( Meta::valAlbumId ).toInt() ); - else - { - // the album should remain a compilation after renaming it - // TODO: we would need to use the artist helper - QString newArtistName; - if( m_cache.contains( Meta::valAlbumArtist ) ) - newArtistName = m_cache.value( Meta::valAlbumArtist ).toString(); - else if( oldAlbum && oldAlbum->isCompilation() && !oldAlbum->name().isEmpty() ) - newArtistName.clear(); - else if( oldAlbum && oldAlbum->hasAlbumArtist() ) - newArtistName = oldAlbum->albumArtist()->name(); - - m_album = m_collection->registry()->getAlbum( m_cache.contains( Meta::valAlbum) - ? m_cache.value( Meta::valAlbum ).toString() - : oldAlbum->name(), - newArtistName ); - } - - newAlbum = static_cast(m_album.data()); - - // due to the complex logic with artist and albumId it can happen that - // in the end we have the same album as before. - if( newAlbum == oldAlbum ) - { - m_cache.remove( Meta::valAlbum ); - m_cache.remove( Meta::valAlbumId ); - m_cache.remove( Meta::valAlbumArtist ); - oldAlbum.clear(); - newAlbum.clear(); - } - } - - if( m_cache.contains( Meta::valComposer ) ) - { - oldComposer = static_cast(m_composer.data()); - m_composer = m_collection->registry()->getComposer( m_cache.value( Meta::valComposer ).toString() ); - newComposer = static_cast(m_composer.data()); - } - - if( m_cache.contains( Meta::valGenre ) ) - { - oldGenre = static_cast(m_genre.data()); - m_genre = m_collection->registry()->getGenre( m_cache.value( Meta::valGenre ).toString() ); - newGenre = static_cast(m_genre.data()); - } - - if( m_cache.contains( Meta::valYear ) ) - { - oldYear = static_cast(m_year.data()); - m_year = m_collection->registry()->getYear( m_cache.value( Meta::valYear ).toInt() ); - newYear = static_cast(m_year.data()); - } - - if( m_cache.contains( Meta::valBpm ) ) - m_bpm = m_cache.value( Meta::valBpm ).toDouble(); - - // --- write the file - if( m_writeFile && AmarokConfig::writeBack() ) - { - Meta::Tag::writeTags( m_url.path(), m_cache, AmarokConfig::writeBackStatistics() ); - // unique id may have changed - QString uid = Meta::Tag::readTags( m_url.path() ).value( Meta::valUniqueId ).toString(); - if( !uid.isEmpty() ) - m_cache[ Meta::valUniqueId ] = m_collection->generateUidUrl( uid ); - } - - // needs to be after writing to file; that may have changed generated uid - if( m_cache.contains( Meta::valUniqueId ) ) - { - QString newUid = m_cache.value( Meta::valUniqueId ).toString(); - if( oldUid != newUid && m_collection->registry()->updateCachedUid( oldUid, newUid ) ) - m_uid = newUid; - } - - //updating the fields might have changed the filesize - //read the current filesize so that we can update the db - QFile file( m_url.path() ); - if( file.exists() ) - { - if( m_filesize != file.size() ) - { - m_cache.insert( Meta::valFilesize, file.size() ); - m_filesize = file.size(); - } - } - - // --- add to the registry dirty list - SqlRegistry *registry = 0; - // prevent writing to the db when we don't know the directory, bug 322474. Note that - // m_urlId is created by registry->commitDirtyTracks() if there is none. - if( m_deviceId != 0 && m_directoryId > 0 ) - { - registry = m_collection->registry(); - QMutexLocker locker2( ®istry->m_blockMutex ); - registry->m_dirtyTracks.insert( Meta::SqlTrackPtr( this ) ); - if( oldArtist ) - registry->m_dirtyArtists.insert( oldArtist ); - if( newArtist ) - registry->m_dirtyArtists.insert( newArtist ); - if( oldAlbum ) - registry->m_dirtyAlbums.insert( oldAlbum ); - if( newAlbum ) - registry->m_dirtyAlbums.insert( newAlbum ); - if( oldComposer ) - registry->m_dirtyComposers.insert( oldComposer ); - if( newComposer ) - registry->m_dirtyComposers.insert( newComposer ); - if( oldGenre ) - registry->m_dirtyGenres.insert( oldGenre ); - if( newGenre ) - registry->m_dirtyGenres.insert( newGenre ); - if( oldYear ) - registry->m_dirtyYears.insert( oldYear ); - if( newYear ) - registry->m_dirtyYears.insert( newYear ); - } - else - error() << Q_FUNC_INFO << "non-positive urlId, zero deviceId or non-positive" - << "directoryId encountered in track" << m_url - << "urlId:" << m_urlId << "deviceId:" << m_deviceId - << "directoryId:" << m_directoryId << "- not writing back metadata" - << "changes to the database."; - - m_lock.unlock(); // or else we provoke a deadlock - - // copy the image BUG: 203211 (we need to do it here or provoke a dead lock) - if( oldAlbum && newAlbum ) - { - bool oldSupp = oldAlbum->suppressImageAutoFetch(); - bool newSupp = newAlbum->suppressImageAutoFetch(); - oldAlbum->setSuppressImageAutoFetch( true ); - newAlbum->setSuppressImageAutoFetch( true ); - - if( oldAlbum->hasImage() && !newAlbum->hasImage() ) - newAlbum->setImage( oldAlbum->imageLocation().path() ); - - oldAlbum->setSuppressImageAutoFetch( oldSupp ); - newAlbum->setSuppressImageAutoFetch( newSupp ); - } - - if( registry ) - registry->commitDirtyTracks(); // calls notifyObservers() as appropriate - else - notifyObservers(); - m_lock.lockForWrite(); // reset back to state it was during call - - if( m_uid != oldUid ) - { - updatePlaylistsToDb( m_cache, oldUid ); - updateEmbeddedCoversToDb( m_cache, oldUid ); - } - - // --- clean up - m_cache.clear(); -} - -void -SqlTrack::updatePlaylistsToDb( const FieldHash &fields, const QString &oldUid ) -{ - if( fields.isEmpty() ) - return; // nothing to do - - SqlStorage *storage = m_collection->sqlStorage(); - QStringList tags; - - // keep this in sync with SqlPlaylist::saveTracks()! - if( fields.contains( Meta::valUrl ) ) - tags << QString( "url='%1'" ).arg( storage->escape( m_url.path() ) ); - if( fields.contains( Meta::valTitle ) ) - tags << QString( "title='%1'" ).arg( storage->escape( m_title ) ); - if( fields.contains( Meta::valAlbum ) ) - tags << QString( "album='%1'" ).arg( m_album ? storage->escape( m_album->prettyName() ) : "" ); - if( fields.contains( Meta::valArtist ) ) - tags << QString( "artist='%1'" ).arg( m_artist ? storage->escape( m_artist->prettyName() ) : "" ); - if( fields.contains( Meta::valLength ) ) - tags << QString( "length=%1").arg( QString::number( m_length ) ); - if( fields.contains( Meta::valUniqueId ) ) - { - // SqlPlaylist mirrors uniqueid to url, update it too, bug 312128 - tags << QString( "url='%1'" ).arg( storage->escape( m_uid ) ); - tags << QString( "uniqueid='%1'" ).arg( storage->escape( m_uid ) ); - } - - if( !tags.isEmpty() ) - { - QString update = "UPDATE playlist_tracks SET %1 WHERE uniqueid = '%2';"; - update = update.arg( tags.join( ", " ), storage->escape( oldUid ) ); - storage->query( update ); - } -} - -void -SqlTrack::updateEmbeddedCoversToDb( const FieldHash &fields, const QString &oldUid ) -{ - if( fields.isEmpty() ) - return; // nothing to do - - SqlStorage *storage = m_collection->sqlStorage(); - QString tags; - - if( fields.contains( Meta::valUniqueId ) ) - tags += QString( ",path='%1'" ).arg( storage->escape( m_uid ) ); - - if( !tags.isEmpty() ) - { - tags = tags.remove(0, 1); // the first character is always a ',' - QString update = "UPDATE images SET %1 WHERE path = '%2';"; - update = update.arg( tags, storage->escape( oldUid ) ); - storage->query( update ); - } -} - -QString -SqlTrack::prettyTitle( const QString &filename ) //static -{ - QString s = filename; //just so the code is more readable - - //remove .part extension if it exists - if (s.endsWith( ".part" )) - s = s.left( s.length() - 5 ); - - //remove file extension, s/_/ /g and decode %2f-like sequences - s = s.left( s.lastIndexOf( '.' ) ).replace( '_', ' ' ); - s = KUrl::fromPercentEncoding( s.toAscii() ); - - return s; -} - -bool -SqlTrack::inCollection() const -{ - QReadLocker locker( &m_lock ); - return m_trackId > 0; -} - -Collections::Collection* -SqlTrack::collection() const -{ - return m_collection; -} - -QString -SqlTrack::cachedLyrics() const -{ - /* We don't cache the string as it may be potentially very long */ - QString query = QString( "SELECT lyrics FROM lyrics WHERE url = %1" ).arg( m_urlId ); - QStringList result = m_collection->sqlStorage()->query( query ); - if( result.isEmpty() ) - return QString(); - return result.first(); -} - -void -SqlTrack::setCachedLyrics( const QString &lyrics ) -{ - QString query = QString( "SELECT count(*) FROM lyrics WHERE url = %1").arg( m_urlId ); - const QStringList queryResult = m_collection->sqlStorage()->query( query ); - if( queryResult.isEmpty() ) - return; // error in the query? - - if( queryResult.first().toInt() == 0 ) - { - QString insert = QString( "INSERT INTO lyrics( url, lyrics ) VALUES ( %1, '%2' )" ) - .arg( QString::number( m_urlId ), - m_collection->sqlStorage()->escape( lyrics ) ); - m_collection->sqlStorage()->insert( insert, "lyrics" ); - } - else - { - QString update = QString( "UPDATE lyrics SET lyrics = '%1' WHERE url = %2" ) - .arg( m_collection->sqlStorage()->escape( lyrics ), - QString::number( m_urlId ) ); - m_collection->sqlStorage()->query( update ); - } - - notifyObservers(); -} - -bool -SqlTrack::hasCapabilityInterface( Capabilities::Capability::Type type ) const -{ - switch( type ) - { - case Capabilities::Capability::Actions: - case Capabilities::Capability::Organisable: - case Capabilities::Capability::BookmarkThis: - case Capabilities::Capability::WriteTimecode: - case Capabilities::Capability::LoadTimecode: - case Capabilities::Capability::ReadLabel: - case Capabilities::Capability::WriteLabel: - case Capabilities::Capability::FindInSource: - return true; - default: - return Track::hasCapabilityInterface( type ); - } -} - -Capabilities::Capability* -SqlTrack::createCapabilityInterface( Capabilities::Capability::Type type ) -{ - switch( type ) - { - case Capabilities::Capability::Actions: - { - QList actions; - //TODO These actions will hang around until m_collection is destructed. - // Find a better parent to avoid this memory leak. - //actions.append( new CopyToDeviceAction( m_collection, this ) ); - - return new Capabilities::ActionsCapability( actions ); - } - case Capabilities::Capability::Organisable: - return new Capabilities::OrganiseCapabilityImpl( this ); - case Capabilities::Capability::BookmarkThis: - return new Capabilities::BookmarkThisCapability( new BookmarkCurrentTrackPositionAction( 0 ) ); - case Capabilities::Capability::WriteTimecode: - return new Capabilities::TimecodeWriteCapabilityImpl( this ); - case Capabilities::Capability::LoadTimecode: - return new Capabilities::TimecodeLoadCapabilityImpl( this ); - case Capabilities::Capability::ReadLabel: - return new Capabilities::SqlReadLabelCapability( this, sqlCollection()->sqlStorage() ); - case Capabilities::Capability::WriteLabel: - return new Capabilities::SqlWriteLabelCapability( this, sqlCollection()->sqlStorage() ); - case Capabilities::Capability::FindInSource: - return new Capabilities::FindInSourceCapabilityImpl( this ); - - default: - return Track::createCapabilityInterface( type ); - } - -} - -void -SqlTrack::addLabel( const QString &label ) -{ - Meta::LabelPtr realLabel = m_collection->registry()->getLabel( label ); - addLabel( realLabel ); -} - -void -SqlTrack::addLabel( const Meta::LabelPtr &label ) -{ - KSharedPtr sqlLabel = KSharedPtr::dynamicCast( label ); - if( !sqlLabel ) - { - Meta::LabelPtr tmp = m_collection->registry()->getLabel( label->name() ); - sqlLabel = KSharedPtr::dynamicCast( tmp ); - } - if( sqlLabel ) - { - QWriteLocker locker( &m_lock ); - commitIfInNonBatchUpdate(); // we need to have a up-to-date m_urlId - if( m_urlId <= 0 ) - { - warning() << "Track does not have an urlId."; - return; - } - - QString countQuery = "SELECT COUNT(*) FROM urls_labels WHERE url = %1 AND label = %2;"; - QStringList countRs = m_collection->sqlStorage()->query( countQuery.arg( QString::number( m_urlId ), QString::number( sqlLabel->id() ) ) ); - if( !countRs.isEmpty() && countRs.first().toInt() == 0 ) - { - QString insert = "INSERT INTO urls_labels(url,label) VALUES (%1,%2);"; - m_collection->sqlStorage()->insert( insert.arg( QString::number( m_urlId ), QString::number( sqlLabel->id() ) ), "urls_labels" ); - - if( m_labelsInCache ) - { - m_labelsCache.append( Meta::LabelPtr::staticCast( sqlLabel ) ); - } - locker.unlock(); - notifyObservers(); - sqlLabel->invalidateCache(); - } - } -} - -int -SqlTrack::id() const -{ - QReadLocker locker( &m_lock ); - return m_trackId; -} - -int -SqlTrack::urlId() const -{ - QReadLocker locker( &m_lock ); - return m_urlId; -} - -void -SqlTrack::removeLabel( const Meta::LabelPtr &label ) -{ - KSharedPtr sqlLabel = KSharedPtr::dynamicCast( label ); - if( !sqlLabel ) - { - Meta::LabelPtr tmp = m_collection->registry()->getLabel( label->name() ); - sqlLabel = KSharedPtr::dynamicCast( tmp ); - } - if( sqlLabel ) - { - QString query = "DELETE FROM urls_labels WHERE label = %2 and url = (SELECT url FROM tracks WHERE id = %1);"; - m_collection->sqlStorage()->query( query.arg( QString::number( m_trackId ), QString::number( sqlLabel->id() ) ) ); - if( m_labelsInCache ) - { - m_labelsCache.removeAll( Meta::LabelPtr::staticCast( sqlLabel ) ); - } - notifyObservers(); - sqlLabel->invalidateCache(); - } -} - -Meta::LabelList -SqlTrack::labels() const -{ - { - QReadLocker locker( &m_lock ); - if( m_labelsInCache ) - return m_labelsCache; - } - - if( !m_collection ) - return Meta::LabelList(); - - // when running the query maker don't lock. might lead to deadlock via registry - Collections::SqlQueryMaker *qm = static_cast< Collections::SqlQueryMaker* >( m_collection->queryMaker() ); - qm->setQueryType( Collections::QueryMaker::Label ); - qm->addMatch( Meta::TrackPtr( const_cast(this) ) ); - qm->setBlocking( true ); - qm->run(); - - { - QWriteLocker locker( &m_lock ); - m_labelsInCache = true; - m_labelsCache = qm->labels(); - - delete qm; - return m_labelsCache; - } -} - -TrackEditorPtr -SqlTrack::editor() -{ - return TrackEditorPtr( isEditable() ? this : 0 ); -} - -StatisticsPtr -SqlTrack::statistics() -{ - return StatisticsPtr( this ); -} - -void -SqlTrack::remove() -{ - QWriteLocker locker( &m_lock ); - m_cache.clear(); - locker.unlock(); - m_collection->registry()->removeTrack( m_urlId, m_uid ); - - // -- inform all albums, artist, years -#undef foreachInvalidateCache -#define INVALIDATE_AND_UPDATE(X) if( X ) \ - { \ - X->invalidateCache(); \ - X->notifyObservers(); \ - } - INVALIDATE_AND_UPDATE(static_cast(m_artist.data())); - INVALIDATE_AND_UPDATE(static_cast(m_album.data())); - INVALIDATE_AND_UPDATE(static_cast(m_composer.data())); - INVALIDATE_AND_UPDATE(static_cast(m_genre.data())); - INVALIDATE_AND_UPDATE(static_cast(m_year.data())); -#undef INVALIDATE_AND_UPDATE - m_artist = 0; - m_album = 0; - m_composer = 0; - m_genre = 0; - m_year = 0; - - m_urlId = 0; - m_trackId = 0; - m_statisticsId = 0; - - m_collection->collectionUpdated(); -} - -//---------------------- class Artist -------------------------- - -SqlArtist::SqlArtist( Collections::SqlCollection *collection, int id, const QString &name ) - : Artist() - , m_collection( collection ) - , m_id( id ) - , m_name( name ) - , m_tracksLoaded( false ) -{ - Q_ASSERT( m_collection ); - Q_ASSERT( m_id > 0 ); -} - -Meta::SqlArtist::~SqlArtist() -{ -} - -void -SqlArtist::invalidateCache() -{ - QMutexLocker locker( &m_mutex ); - m_tracksLoaded = false; - m_tracks.clear(); -} - -TrackList -SqlArtist::tracks() -{ - { - QMutexLocker locker( &m_mutex ); - if( m_tracksLoaded ) - return m_tracks; - } - - // when running the query maker don't lock. might lead to deadlock via registry - Collections::SqlQueryMaker *qm = static_cast< Collections::SqlQueryMaker* >( m_collection->queryMaker() ); - qm->setQueryType( Collections::QueryMaker::Track ); - qm->addMatch( Meta::ArtistPtr( this ) ); - qm->setBlocking( true ); - qm->run(); - - { - QMutexLocker locker( &m_mutex ); - m_tracks = qm->tracks(); - m_tracksLoaded = true; - delete qm; - return m_tracks; - } -} - -bool -SqlArtist::hasCapabilityInterface( Capabilities::Capability::Type type ) const -{ - switch( type ) - { - case Capabilities::Capability::BookmarkThis: - return true; - default: - return Artist::hasCapabilityInterface( type ); - } -} - -Capabilities::Capability* -SqlArtist::createCapabilityInterface( Capabilities::Capability::Type type ) -{ - switch( type ) - { - case Capabilities::Capability::BookmarkThis: - return new Capabilities::BookmarkThisCapability( new BookmarkArtistAction( 0, Meta::ArtistPtr( this ) ) ); - default: - return Artist::createCapabilityInterface( type ); - } -} - - -//--------------- class Album --------------------------------- -const QString SqlAlbum::AMAROK_UNSET_MAGIC = QString( "AMAROK_UNSET_MAGIC" ); - -SqlAlbum::SqlAlbum( Collections::SqlCollection *collection, int id, const QString &name, int artist ) - : Album() - , m_collection( collection ) - , m_name( name ) - , m_id( id ) - , m_artistId( artist ) - , m_imageId( -1 ) - , m_hasImage( false ) - , m_hasImageChecked( false ) - , m_unsetImageId( -1 ) - , m_tracksLoaded( false ) - , m_suppressAutoFetch( false ) - , m_mutex( QMutex::Recursive ) -{ - Q_ASSERT( m_collection ); - Q_ASSERT( m_id > 0 ); -} - -Meta::SqlAlbum::~SqlAlbum() -{ - CoverCache::invalidateAlbum( this ); -} - -void -SqlAlbum::invalidateCache() -{ - QMutexLocker locker( &m_mutex ); - m_tracksLoaded = false; - m_hasImage = false; - m_hasImageChecked = false; - m_tracks.clear(); -} - -TrackList -SqlAlbum::tracks() -{ - { - QMutexLocker locker( &m_mutex ); - if( m_tracksLoaded ) - return m_tracks; - } - - // when running the query maker don't lock. might lead to deadlock via registry - Collections::SqlQueryMaker *qm = static_cast< Collections::SqlQueryMaker* >( m_collection->queryMaker() ); - qm->setQueryType( Collections::QueryMaker::Track ); - qm->addMatch( Meta::AlbumPtr( this ) ); - qm->orderBy( Meta::valDiscNr ); - qm->orderBy( Meta::valTrackNr ); - qm->orderBy( Meta::valTitle ); - qm->setBlocking( true ); - qm->run(); - - { - QMutexLocker locker( &m_mutex ); - m_tracks = qm->tracks(); - m_tracksLoaded = true; - delete qm; - return m_tracks; - } -} - -// note for internal implementation: -// if hasImage returns true then m_imagePath is set -bool -SqlAlbum::hasImage( int size ) const -{ - Q_UNUSED(size); // we have every size if we have an image at all - QMutexLocker locker( &m_mutex ); - - if( m_name.isEmpty() ) - return false; - - if( !m_hasImageChecked ) - { - m_hasImageChecked = true; - - const_cast( this )->largeImagePath(); - - // The user has explicitly set no cover - if( m_imagePath == AMAROK_UNSET_MAGIC ) - m_hasImage = false; - - // if we don't have an image but it was not explicitly blocked - else if( m_imagePath.isEmpty() ) - { - // Cover fetching runs in another thread. If there is a retrieved cover - // then updateImage() gets called which updates the cache and alerts the - // subscribers. We use queueAlbum() because this runs the fetch as a - // background job and doesn't give an intruding popup asking for confirmation - if( !m_suppressAutoFetch && !m_name.isEmpty() && AmarokConfig::autoGetCoverArt() ) - CoverFetcher::instance()->queueAlbum( AlbumPtr(const_cast(this)) ); - - m_hasImage = false; - } - else - m_hasImage = true; - } - - return m_hasImage; -} - -QImage -SqlAlbum::image( int size ) const -{ - QMutexLocker locker( &m_mutex ); - - if( !hasImage() ) - return Meta::Album::image( size ); - - // findCachedImage looks for a scaled version of the fullsize image - // which may have been saved on a previous lookup - QString cachedImagePath; - if( size <= 1 ) - cachedImagePath = m_imagePath; - else - cachedImagePath = scaledDiskCachePath( size ); - - //FIXME this cache doesn't differentiate between shadowed/unshadowed - // a image exists. just load it. - if( !cachedImagePath.isEmpty() && QFile( cachedImagePath ).exists() ) - { - QImage image( cachedImagePath ); - if( image.isNull() ) - return Meta::Album::image( size ); - return image; - } - - // no cached scaled image exists. Have to create it - QImage image; - - // --- embedded cover - if( m_collection && m_imagePath.startsWith( m_collection->uidUrlProtocol() ) ) - { - // -- check if we have a track with the given path as uid - Meta::TrackPtr track = m_collection->getTrackFromUid( m_imagePath ); - if( track ) - image = Meta::Tag::embeddedCover( track->playableUrl().path() ); - } - - // --- a normal path - if( image.isNull() ) - image = QImage( m_imagePath ); - - if( image.isNull() ) - return Meta::Album::image( size ); - - if( size > 1 && size < 1000 ) - { - image = image.scaled( size, size, Qt::KeepAspectRatio, Qt::SmoothTransformation ); - image.save( cachedImagePath, "PNG" ); - } - - return image; -} - -KUrl -SqlAlbum::imageLocation( int size ) -{ - if( !hasImage() ) - return KUrl(); - - // findCachedImage looks for a scaled version of the fullsize image - // which may have been saved on a previous lookup - if( size <= 1 ) - return m_imagePath; - - QString cachedImagePath = scaledDiskCachePath( size ); - - if( cachedImagePath.isEmpty() ) - return KUrl(); - - if( !QFile( cachedImagePath ).exists() ) - { - // If we don't have the location, it's possible that we haven't tried to find the image yet - // So, let's look for it and just ignore the result - QImage i = image( size ); - Q_UNUSED( i ) - } - - if( !QFile( cachedImagePath ).exists() ) - return KUrl(); - - return cachedImagePath; -} - -void -SqlAlbum::setImage( const QImage &image ) -{ - // the unnamed album is special. it will never have an image - if( m_name.isEmpty() ) - return; - - QMutexLocker locker( &m_mutex ); - if( image.isNull() ) - return; - - // removeImage() will destroy all scaled cached versions of the artwork - // and remove references from the database if required. - removeImage(); - - QString path = largeDiskCachePath(); - // make sure not to overwrite existing images - while( QFile(path).exists() ) - path += '_'; // not that nice but it shouldn't happen that often. - - image.save( path, "JPG" ); - setImage( path ); - - locker.unlock(); - notifyObservers(); - - // -- write back the album cover if allowed - if( AmarokConfig::writeBackCover() ) - { - // - scale to cover to a sensible size - QImage scaledImage( image ); - if( scaledImage.width() > AmarokConfig::writeBackCoverDimensions() || scaledImage.height() > AmarokConfig::writeBackCoverDimensions() ) - scaledImage = scaledImage.scaled( AmarokConfig::writeBackCoverDimensions(), AmarokConfig::writeBackCoverDimensions(), Qt::KeepAspectRatio, Qt::SmoothTransformation ); - - // - set the image for each track - Meta::TrackList myTracks = tracks(); - foreach( Meta::TrackPtr metaTrack, myTracks ) - { - // the song needs to be at least one mb big or we won't set an image - // that means that the new image will increase the file size by less than 2% - if( metaTrack->filesize() > 1024l * 1024l ) - { - Meta::FieldHash fields; - fields.insert( Meta::valImage, scaledImage ); - WriteTagsJob *job = new WriteTagsJob( metaTrack->playableUrl().path(), fields ); - QObject::connect( job, SIGNAL(done(ThreadWeaver::Job*)), job, SLOT(deleteLater()) ); - ThreadWeaver::Weaver::instance()->enqueue( job ); - } - // note: we might want to update the track file size after writing the image - } - } -} - -void -SqlAlbum::removeImage() -{ - QMutexLocker locker( &m_mutex ); - if( !hasImage() ) - return; - - // Update the database image path - // Set the album image to a magic value which will tell Amarok not to fetch it automatically - const int unsetId = unsetImageId(); - QString query = "UPDATE albums SET image = %1 WHERE id = %2"; - m_collection->sqlStorage()->query( query.arg( QString::number( unsetId ), QString::number( m_id ) ) ); - - // From here on we check if there are any remaining references to that particular image in the database - // If there aren't, then we should remove the image path from the database ( and possibly delete the file? ) - // If there are, we need to leave it since other albums will reference this particular image path. - // - query = "SELECT count( albums.id ) FROM albums " - "WHERE albums.image = %1"; - QStringList res = m_collection->sqlStorage()->query( query.arg( QString::number( m_imageId ) ) ); - - if( !res.isEmpty() ) - { - int references = res.first().toInt(); - - // If there are no more references to this particular image, then we should clean up - if( references <= 0 ) - { - query = "DELETE FROM images WHERE id = %1"; - m_collection->sqlStorage()->query( query.arg( QString::number( m_imageId ) ) ); - - // remove the large cover only if it was cached. - QDir largeCoverDir( Amarok::saveLocation( "albumcovers/large/" ) ); - if( QFileInfo(m_imagePath).absoluteDir() == largeCoverDir ) - QFile::remove( m_imagePath ); - - // remove all cache images - QString key = md5sum( QString(), QString(), m_imagePath ); - QDir cacheDir( Amarok::saveLocation( "albumcovers/cache/" ) ); - QStringList cacheFilter; - cacheFilter << QString( "*@" ) + key; - QStringList cachedImages = cacheDir.entryList( cacheFilter ); - - foreach( const QString &image, cachedImages ) - { - bool r = QFile::remove( cacheDir.filePath( image ) ); - debug() << "deleting cached image: " << image << " : " + ( r ? QString("ok") : QString("fail") ); - } - - CoverCache::invalidateAlbum( this ); - } - } - - m_imageId = -1; - m_imagePath.clear(); - m_hasImage = false; - m_hasImageChecked = true; - - locker.unlock(); - notifyObservers(); -} - -int -SqlAlbum::unsetImageId() const -{ - // Return the cached value if we have already done the lookup before - if( m_unsetImageId >= 0 ) - return m_unsetImageId; - - QString query = "SELECT id FROM images WHERE path = '%1'"; - QStringList res = m_collection->sqlStorage()->query( query.arg( AMAROK_UNSET_MAGIC ) ); - - // We already have the AMAROK_UNSET_MAGIC variable in the database - if( !res.isEmpty() ) - { - m_unsetImageId = res.first().toInt(); - } - else - { - // We need to create this value - query = QString( "INSERT INTO images( path ) VALUES ( '%1' )" ) - .arg( m_collection->sqlStorage()->escape( AMAROK_UNSET_MAGIC ) ); - m_unsetImageId = m_collection->sqlStorage()->insert( query, "images" ); - } - return m_unsetImageId; -} - -bool -SqlAlbum::isCompilation() const -{ - return !hasAlbumArtist(); -} - -bool -SqlAlbum::hasAlbumArtist() const -{ - return !albumArtist().isNull(); -} - -Meta::ArtistPtr -SqlAlbum::albumArtist() const -{ - if( m_artistId > 0 && !m_artist ) - { - const_cast( this )->m_artist = - m_collection->registry()->getArtist( m_artistId ); - } - return m_artist; -} - -QByteArray -SqlAlbum::md5sum( const QString& artist, const QString& album, const QString& file ) const -{ - // FIXME: names with unicode characters are not supported. - // FIXME: "The Beatles"."Collection" and "The"."Beatles Collection" will produce the same hash. - // FIXME: Correcting this now would invalidate all existing image stores. - KMD5 context( artist.toLower().toLocal8Bit() + album.toLower().toLocal8Bit() + file.toLocal8Bit() ); - return context.hexDigest(); -} - -QString -SqlAlbum::largeDiskCachePath() const -{ - // IMPROVEMENT: the large disk cache path could be human readable - const QString artist = hasAlbumArtist() ? albumArtist()->name() : QString(); - if( artist.isEmpty() && m_name.isEmpty() ) - return QString(); - - QDir largeCoverDir( Amarok::saveLocation( "albumcovers/large/" ) ); - const QString key = md5sum( artist, m_name, QString() ); - return largeCoverDir.filePath( key ); -} - -QString -SqlAlbum::scaledDiskCachePath( int size ) const -{ - const QByteArray widthKey = QByteArray::number( size ) + '@'; - QDir cacheCoverDir( Amarok::saveLocation( "albumcovers/cache/" ) ); - QString key = md5sum( QString(), QString(), m_imagePath ); - - if( !cacheCoverDir.exists( widthKey + key ) ) - { - // the correct location is empty - // check deprecated locations for the image cache and delete them - // (deleting the scaled image cache is fine) - - const QString artist = hasAlbumArtist() ? albumArtist()->name() : QString(); - if( artist.isEmpty() && m_name.isEmpty() ) - ; // do nothing special - else - { - QString oldKey; - oldKey = md5sum( artist, m_name, m_imagePath ); - if( cacheCoverDir.exists( widthKey + oldKey ) ) - cacheCoverDir.remove( widthKey + oldKey ); - - oldKey = md5sum( artist, m_name, QString() ); - if( cacheCoverDir.exists( widthKey + oldKey ) ) - cacheCoverDir.remove( widthKey + oldKey ); - } - } - - return cacheCoverDir.filePath( widthKey + key ); -} - -QString -SqlAlbum::largeImagePath() -{ - if( !m_collection ) - return m_imagePath; - - // Look up in the database - QString query = "SELECT images.id, images.path FROM images, albums WHERE albums.image = images.id AND albums.id = %1;"; // TODO: shouldn't we do a JOIN here? - QStringList res = m_collection->sqlStorage()->query( query.arg( m_id ) ); - if( !res.isEmpty() ) - { - m_imageId = res.at(0).toInt(); - m_imagePath = res.at(1); - - // explicitly deleted image - if( m_imagePath == AMAROK_UNSET_MAGIC ) - return AMAROK_UNSET_MAGIC; - - // embedded image (e.g. id3v2 APIC - // We store embedded images as unique ids in the database - // we will get the real image later on from the track. - if( m_imagePath.startsWith( m_collection->uidUrlProtocol()+"://" ) ) - return m_imagePath; - - // normal file - if( !m_imagePath.isEmpty() && QFile::exists( m_imagePath ) ) - return m_imagePath; - } - - // After a rescan we currently lose all image information, so we need - // to check that we haven't already downloaded this image before. - m_imagePath = largeDiskCachePath(); - if( !m_imagePath.isEmpty() && QFile::exists( m_imagePath ) ) { - setImage(m_imagePath); - return m_imagePath; - } - - m_imageId = -1; - m_imagePath.clear(); - return m_imagePath; -} - -// note: we won't notify the observers. we are a private function. the caller must do that. -void -SqlAlbum::setImage( const QString &path ) -{ - if( m_imagePath == path ) - return; - if( m_name.isEmpty() ) // the empty album never has an image - return; - - QMutexLocker locker( &m_mutex ); - - QString imagePath = path; - - QString query = "SELECT id FROM images WHERE path = '%1'"; - query = query.arg( m_collection->sqlStorage()->escape( imagePath ) ); - QStringList res = m_collection->sqlStorage()->query( query ); - - if( res.isEmpty() ) - { - QString insert = QString( "INSERT INTO images( path ) VALUES ( '%1' )" ) - .arg( m_collection->sqlStorage()->escape( imagePath ) ); - m_imageId = m_collection->sqlStorage()->insert( insert, "images" ); - } - else - m_imageId = res.first().toInt(); - - if( m_imageId >= 0 ) - { - query = QString("UPDATE albums SET image = %1 WHERE albums.id = %2" ) - .arg( QString::number( m_imageId ), QString::number( m_id ) ); - m_collection->sqlStorage()->query( query ); - - m_imagePath = imagePath; - m_hasImage = true; - m_hasImageChecked = true; - CoverCache::invalidateAlbum( this ); - } -} - -/** Set the compilation flag. - * Actually it does not cange this album but instead moves - * the tracks to other albums (e.g. one with the same name which is a - * compilation) - * If the compilation flag is set to "false" then all songs - * with different artists will be moved to other albums, possibly even - * creating them. - */ -void -SqlAlbum::setCompilation( bool compilation ) -{ - if( m_name.isEmpty() ) - return; - - if( isCompilation() == compilation ) - { - return; - } - else - { - m_collection->blockUpdatedSignal(); - - if( compilation ) - { - // get the new compilation album - Meta::AlbumPtr metaAlbum = m_collection->registry()->getAlbum( name(), QString() ); - KSharedPtr sqlAlbum = KSharedPtr::dynamicCast( metaAlbum ); - - Meta::FieldHash changes; - changes.insert( Meta::valCompilation, 1); - - Meta::TrackList myTracks = tracks(); - foreach( Meta::TrackPtr metaTrack, myTracks ) - { - SqlTrack* sqlTrack = static_cast(metaTrack.data()); - - // copy over the cover image - if( sqlTrack->album()->hasImage() && !sqlAlbum->hasImage() ) - sqlAlbum->setImage( sqlTrack->album()->imageLocation().path() ); - - // move the track - sqlTrack->setAlbum( sqlAlbum->id() ); - if( AmarokConfig::writeBack() ) - Meta::Tag::writeTags( sqlTrack->playableUrl().path(), changes, - AmarokConfig::writeBackStatistics() ); - } - /* TODO: delete all old tracks albums */ - } - else - { - Meta::FieldHash changes; - changes.insert( Meta::valCompilation, 0); - - Meta::TrackList myTracks = tracks(); - foreach( Meta::TrackPtr metaTrack, myTracks ) - { - SqlTrack* sqlTrack = static_cast(metaTrack.data()); - Meta::ArtistPtr trackArtist = sqlTrack->artist(); - - // get the new album - Meta::AlbumPtr metaAlbum = m_collection->registry()->getAlbum( - sqlTrack->album()->name(), - trackArtist ? ArtistHelper::realTrackArtist( trackArtist->name() ) : QString() ); - KSharedPtr sqlAlbum = KSharedPtr::dynamicCast( metaAlbum ); - - // copy over the cover image - if( sqlTrack->album()->hasImage() && !sqlAlbum->hasImage() ) - sqlAlbum->setImage( sqlTrack->album()->imageLocation().path() ); - - // move the track - sqlTrack->setAlbum( sqlAlbum->id() ); - if( AmarokConfig::writeBack() ) - Meta::Tag::writeTags( sqlTrack->playableUrl().path(), changes, - AmarokConfig::writeBackStatistics() ); - } - /* TODO //step 5: delete the original album, if necessary */ - } - - m_collection->unblockUpdatedSignal(); - } -} - -bool -SqlAlbum::hasCapabilityInterface( Capabilities::Capability::Type type ) const -{ - if( m_name.isEmpty() ) - return false; - - switch( type ) - { - case Capabilities::Capability::Actions: - case Capabilities::Capability::BookmarkThis: - return true; - default: - return Album::hasCapabilityInterface( type ); - } -} - -Capabilities::Capability* -SqlAlbum::createCapabilityInterface( Capabilities::Capability::Type type ) -{ - if( m_name.isEmpty() ) - return 0; - - switch( type ) - { - case Capabilities::Capability::Actions: - return new Capabilities::AlbumActionsCapability( Meta::AlbumPtr( this ) ); - case Capabilities::Capability::BookmarkThis: - return new Capabilities::BookmarkThisCapability( new BookmarkAlbumAction( 0, Meta::AlbumPtr( this ) ) ); - default: - return Album::createCapabilityInterface( type ); - } -} - -//---------------SqlComposer--------------------------------- - -SqlComposer::SqlComposer( Collections::SqlCollection *collection, int id, const QString &name ) - : Composer() - , m_collection( collection ) - , m_id( id ) - , m_name( name ) - , m_tracksLoaded( false ) -{ - Q_ASSERT( m_collection ); - Q_ASSERT( m_id > 0 ); -} - -void -SqlComposer::invalidateCache() -{ - QMutexLocker locker( &m_mutex ); - m_tracksLoaded = false; - m_tracks.clear(); -} - -TrackList -SqlComposer::tracks() -{ - { - QMutexLocker locker( &m_mutex ); - if( m_tracksLoaded ) - return m_tracks; - } - - Collections::SqlQueryMaker *qm = static_cast< Collections::SqlQueryMaker* >( m_collection->queryMaker() ); - qm->setQueryType( Collections::QueryMaker::Track ); - qm->addMatch( Meta::ComposerPtr( this ) ); - qm->setBlocking( true ); - qm->run(); - - { - QMutexLocker locker( &m_mutex ); - m_tracks = qm->tracks(); - m_tracksLoaded = true; - delete qm; - return m_tracks; - } -} - -//---------------SqlGenre--------------------------------- - -SqlGenre::SqlGenre( Collections::SqlCollection *collection, int id, const QString &name ) - : Genre() - , m_collection( collection ) - , m_id( id ) - , m_name( name ) - , m_tracksLoaded( false ) -{ - Q_ASSERT( m_collection ); - Q_ASSERT( m_id > 0 ); -} - -void -SqlGenre::invalidateCache() -{ - QMutexLocker locker( &m_mutex ); - m_tracksLoaded = false; - m_tracks.clear(); -} - -TrackList -SqlGenre::tracks() -{ - { - QMutexLocker locker( &m_mutex ); - if( m_tracksLoaded ) - return m_tracks; - } - - // when running the query maker don't lock. might lead to deadlock via registry - Collections::SqlQueryMaker *qm = static_cast< Collections::SqlQueryMaker* >( m_collection->queryMaker() ); - qm->setQueryType( Collections::QueryMaker::Track ); - qm->addMatch( Meta::GenrePtr( this ) ); - qm->setBlocking( true ); - qm->run(); - - { - QMutexLocker locker( &m_mutex ); - m_tracks = qm->tracks(); - m_tracksLoaded = true; - delete qm; - return m_tracks; - } -} - -//---------------SqlYear--------------------------------- - -SqlYear::SqlYear( Collections::SqlCollection *collection, int id, int year) - : Year() - , m_collection( collection ) - , m_id( id ) - , m_year( year ) - , m_tracksLoaded( false ) -{ - Q_ASSERT( m_collection ); - Q_ASSERT( m_id > 0 ); -} - -void -SqlYear::invalidateCache() -{ - QMutexLocker locker( &m_mutex ); - m_tracksLoaded = false; - m_tracks.clear(); -} - -TrackList -SqlYear::tracks() -{ - { - QMutexLocker locker( &m_mutex ); - if( m_tracksLoaded ) - return m_tracks; - } - - // when running the query maker don't lock. might lead to deadlock via registry - Collections::SqlQueryMaker *qm = static_cast< Collections::SqlQueryMaker* >( m_collection->queryMaker() ); - qm->setQueryType( Collections::QueryMaker::Track ); - qm->addMatch( Meta::YearPtr( this ) ); - qm->setBlocking( true ); - qm->run(); - - { - QMutexLocker locker( &m_mutex ); - m_tracks = qm->tracks(); - m_tracksLoaded = true; - delete qm; - return m_tracks; - } -} - -//---------------SqlLabel--------------------------------- - -SqlLabel::SqlLabel( Collections::SqlCollection *collection, int id, const QString &name ) - : Label() - , m_collection( collection ) - , m_id( id ) - , m_name( name ) - , m_tracksLoaded( false ) -{ - Q_ASSERT( m_collection ); - Q_ASSERT( m_id > 0 ); -} - -void -SqlLabel::invalidateCache() -{ - QMutexLocker locker( &m_mutex ); - m_tracksLoaded = false; - m_tracks.clear(); -} - -TrackList -SqlLabel::tracks() -{ - { - QMutexLocker locker( &m_mutex ); - if( m_tracksLoaded ) - return m_tracks; - } - - // when running the query maker don't lock. might lead to deadlock via registry - Collections::SqlQueryMaker *qm = static_cast< Collections::SqlQueryMaker* >( m_collection->queryMaker() ); - qm->setQueryType( Collections::QueryMaker::Track ); - qm->addMatch( Meta::LabelPtr( this ) ); - qm->setBlocking( true ); - qm->run(); - - { - QMutexLocker locker( &m_mutex ); - m_tracks = qm->tracks(); - m_tracksLoaded = true; - delete qm; - return m_tracks; - } -} - diff --git a/amarok/src/core-impl/collections/db/sql/SqlMeta.h b/amarok/src/core-impl/collections/db/sql/SqlMeta.h deleted file mode 100644 index 407fd725..00000000 --- a/amarok/src/core-impl/collections/db/sql/SqlMeta.h +++ /dev/null @@ -1,586 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Maximilian Kossick * - * Copyright (c) 2007 Alexandre Pereira de Oliveira * - * Copyright (c) 2010 Ralf Engels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef SQLMETA_H -#define SQLMETA_H - -#include "core/meta/Meta.h" -#include "core/meta/Statistics.h" -#include "core/meta/TrackEditor.h" -#include "core/meta/support/MetaConstants.h" -#include "amarok_sqlcollection_export.h" -#include "FileType.h" - -#include -#include -#include -#include -#include -#include - -namespace Capabilities { - class AlbumCapabilityDelegate; - class ArtistCapabilityDelegate; - class TrackCapabilityDelegate; -} -class QAction; - -class SqlRegistry; -class TrackUrlsTableCommitter; -class TrackTracksTableCommitter; -class TrackStatisticsTableCommitter; -namespace Collections { - class SqlCollection; -} - -class SqlScanResultProcessor; - -namespace Meta -{ - -/** The SqlTrack is a Meta::Track used by the SqlCollection. - The SqlTrack has a couple of functions for writing values and also - some functions for getting e.g. the track id used in the underlying database. - However it is not recommended to interface with the database directly. - - The whole class should be thread save. -*/ -class AMAROK_SQLCOLLECTION_EXPORT SqlTrack : public Track, public Statistics, public TrackEditor -{ - public: - /** Creates a new SqlTrack without. - * Note that the trackId and urlId are empty meaning that this track - * has no database representation until it's written first by setting - * some of the meta information. - * It is advisable to set at least the path. - */ - SqlTrack( Collections::SqlCollection *collection, int deviceId, - const QString &rpath, int directoryId, const QString uidUrl ); - SqlTrack( Collections::SqlCollection *collection, const QStringList &queryResult ); - ~ SqlTrack(); - - virtual QString name() const; - virtual QString prettyName() const; - virtual KUrl playableUrl() const; - virtual QString prettyUrl() const; - virtual QString uidUrl() const; - virtual QString notPlayableReason() const; - - virtual Meta::AlbumPtr album() const; - virtual Meta::ArtistPtr artist() const; - virtual Meta::ComposerPtr composer() const; - virtual Meta::YearPtr year() const; - virtual Meta::GenrePtr genre() const; - - virtual QString type() const; - virtual qreal bpm() const; - virtual QString comment() const; - virtual qint64 length() const; - virtual int filesize() const; - virtual int sampleRate() const; - virtual int bitrate() const; - virtual QDateTime createDate() const; - virtual QDateTime modifyDate() const; - virtual int trackNumber() const; - virtual int discNumber() const; - virtual qreal replayGain( Meta::ReplayGainTag mode ) const; - - virtual bool inCollection() const; - virtual Collections::Collection* collection() const; - - virtual QString cachedLyrics() const; - virtual void setCachedLyrics( const QString &lyrics ); - - virtual bool hasCapabilityInterface( Capabilities::Capability::Type type ) const; - virtual Capabilities::Capability* createCapabilityInterface( Capabilities::Capability::Type type ); - - virtual void addLabel( const QString &label ); - virtual void addLabel( const Meta::LabelPtr &label ); - virtual void removeLabel( const Meta::LabelPtr &label ); - virtual Meta::LabelList labels() const; - - virtual TrackEditorPtr editor(); - virtual StatisticsPtr statistics(); - - // Meta::TrackEditor methods: - virtual void setAlbum( const QString &newAlbum ); - virtual void setAlbumArtist( const QString &newAlbumArtist ); - virtual void setArtist( const QString &newArtist ); - virtual void setComposer( const QString &newComposer ); - virtual void setGenre( const QString &newGenre ); - virtual void setYear( int newYear ); - virtual void setTitle( const QString &newTitle ); - virtual void setComment( const QString &newComment ); - virtual void setTrackNumber( int newTrackNumber ); - virtual void setDiscNumber( int newDiscNumber ); - virtual void setBpm( const qreal newBpm ); - - // Meta::Statistics methods: - virtual double score() const; - virtual void setScore( double newScore ); - - virtual int rating() const; - virtual void setRating( int newRating ); - - virtual QDateTime firstPlayed() const; - virtual void setFirstPlayed( const QDateTime &newTime ); - - virtual QDateTime lastPlayed() const; - virtual void setLastPlayed( const QDateTime &newTime ); - - virtual int playCount() const; - virtual void setPlayCount( const int newCount ); - - // combined Meta::Statistics and Meta::TrackEditor methods: - virtual void beginUpdate(); - virtual void endUpdate(); - - // SqlTrack specific methods - /** true if there is a collection, the file exists on disk and is writable */ - bool isEditable() const; - - void setUidUrl( const QString &uid ); - void setAlbum( int albumId ); - void setType( Amarok::FileType newType ); - void setLength( qint64 newLength ); - void setSampleRate( int newSampleRate ); - void setUrl( int deviceId, const QString &rpath, int directoryId ); - void setBitrate( int newBitrate ); - void setModifyDate( const QDateTime &newTime ); - void setReplayGain( Meta::ReplayGainTag mode, qreal value ); - - /** Enables or disables writing changes to the file. - * This function can be useful when changes are imported from the file. - * In such a case writing the changes back again is stupid. - */ - virtual void setWriteFile( const bool enable ) - { m_writeFile = enable; } - - int id() const; - int urlId() const; - Collections::SqlCollection* sqlCollection() const { return m_collection; } - - /** Does it's best to remove the track from database. - * Considered that there is no signal that says "I am now removed" - * this function still tries it's best to notify everyone - * That the track is now removed, plus it will also delete it from - * the database. - */ - void remove(); - - // SqlDatabase specific values - - /** Some numbers used in SqlRegistry. - * Update if getTrackReturnValues is updated. - */ - enum TrackReturnIndex - { - returnIndex_urlId = 0, - returnIndex_urlDeviceId = 1, - returnIndex_urlRPath = 2, - returnIndex_urlUid = 4, - returnIndex_trackId = 5 - }; - - // SqlDatabase specific values - - /** returns a string of all database values that can be fetched for a track */ - static QString getTrackReturnValues(); - /** returns the number of return values in getTrackReturnValues() */ - static int getTrackReturnValueCount(); - /** returns a string of all database joins that are required to fetch all values for a track*/ - static QString getTrackJoinConditions(); - - - protected: - /** - * Will commit all changes in m_cache if m_batch == 0. Must be called with m_lock - * locked for writing. - * - * commitIfInNonBatchUpdate() will do three things: - * 1. It will update the member variables. - * 2. It will call all write methods - * 3. It will notify all observers and the collection about the changes. - */ - void commitIfInNonBatchUpdate( qint64 field, const QVariant &value ); - void commitIfInNonBatchUpdate(); - - void updatePlaylistsToDb( const FieldHash &fields, const QString &oldUid ); - void updateEmbeddedCoversToDb( const FieldHash &fields, const QString &oldUid ); - - private: - //helper functions - static QString prettyTitle( const QString &filename ); - - Collections::SqlCollection* const m_collection; - - QString m_title; - - // the url table - int m_urlId; - int m_deviceId; - QString m_rpath; - int m_directoryId; // only set when the urls table needs to be written - KUrl m_url; - QString m_uid; - - // the rest - int m_trackId; - int m_statisticsId; - - qint64 m_length; - qint64 m_filesize; - int m_trackNumber; - int m_discNumber; - QDateTime m_lastPlayed; - QDateTime m_firstPlayed; - int m_playCount; - int m_bitrate; - int m_sampleRate; - int m_rating; - double m_score; - QString m_comment; - qreal m_bpm; - qreal m_albumGain; - qreal m_albumPeakGain; - qreal m_trackGain; - qreal m_trackPeakGain; - QDateTime m_createDate; - QDateTime m_modifyDate; - - Meta::AlbumPtr m_album; - Meta::ArtistPtr m_artist; - Meta::GenrePtr m_genre; - Meta::ComposerPtr m_composer; - Meta::YearPtr m_year; - - Amarok::FileType m_filetype; - - /** - * Number of current batch operations started by @see beginUpdate() and not - * yet ended by @see endUpdate(). Must only be accessed with m_lock held. - */ - int m_batchUpdate; - bool m_writeFile; - bool m_writeAllStatisticsFields; - FieldHash m_cache; - - /** This ReadWriteLock is protecting all internal variables. - It is ensuring that m_cache, m_batchUpdate and the othre internal variable are - in a consistent state all the time. - */ - mutable QReadWriteLock m_lock; - - mutable bool m_labelsInCache; - mutable Meta::LabelList m_labelsCache; - - friend class ::SqlRegistry; // needs to call notifyObservers - friend class ::TrackUrlsTableCommitter; - friend class ::TrackTracksTableCommitter; - friend class ::TrackStatisticsTableCommitter; -}; - -class AMAROK_SQLCOLLECTION_EXPORT SqlArtist : public Meta::Artist -{ - public: - SqlArtist( Collections::SqlCollection* collection, int id, const QString &name ); - ~SqlArtist(); - - virtual QString name() const { return m_name; } - - virtual void invalidateCache(); - - virtual Meta::TrackList tracks(); - - virtual bool hasCapabilityInterface( Capabilities::Capability::Type type ) const; - - virtual Capabilities::Capability* createCapabilityInterface( Capabilities::Capability::Type type ); - - //SQL specific methods - int id() const { return m_id; } - private: - Collections::SqlCollection* const m_collection; - const int m_id; - const QString m_name; - - bool m_tracksLoaded; - Meta::TrackList m_tracks; - QMutex m_mutex; - - friend class ::SqlRegistry; // needs to call notifyObservers - friend class Meta::SqlTrack; // needs to call notifyObservers -}; - -/** Represents an albums stored in the database. - Note: The album without name is special. It will always be a compilation - and never have a picture. -*/ -class AMAROK_SQLCOLLECTION_EXPORT SqlAlbum : public Meta::Album -{ - public: - SqlAlbum( Collections::SqlCollection* collection, int id, const QString &name, int artist ); - ~SqlAlbum(); - - virtual QString name() const { return m_name; } - - virtual void invalidateCache(); - - virtual Meta::TrackList tracks(); - - virtual bool isCompilation() const; - virtual bool canUpdateCompilation() const { return true; } - void setCompilation( bool compilation ); - - /** Returns true if this album has an artist. - * The following equation is always true: isCompilation() != hasAlbumArtist() - */ - virtual bool hasAlbumArtist() const; - - /** Returns the album artist. - * Note that setting the album artist is not supported. - * A compilation does not have an artist and not only an empty artist. - */ - virtual Meta::ArtistPtr albumArtist() const; - - //updating album images is possible for local tracks, but let's ignore it for now - - /** Returns true if the album has a cover image. - * @param size The maximum width or height of the result. - * when size is <= 1, return the full size image - */ - virtual bool hasImage(int size = 0) const; - virtual bool canUpdateImage() const { return true; } - - /** Returns the album cover image. - * Returns a default image if no specific album image could be found. - * In such a case it will start the cover fetcher. - * - * @param size is the maximum width or height of the resulting image. - * when size is <= 1, return the full size image - */ - virtual QImage image( int size = 0 ) const; - - virtual KUrl imageLocation( int size = 0 ); - virtual void setImage( const QImage &image ); - virtual void removeImage(); - virtual void setSuppressImageAutoFetch( const bool suppress ) { m_suppressAutoFetch = suppress; } - virtual bool suppressImageAutoFetch() const { return m_suppressAutoFetch; } - - virtual bool hasCapabilityInterface( Capabilities::Capability::Type type ) const; - - virtual Capabilities::Capability* createCapabilityInterface( Capabilities::Capability::Type type ); - - //SQL specific methods - int id() const { return m_id; } - - Collections::SqlCollection *sqlCollection() const { return m_collection; } - - private: - QByteArray md5sum( const QString& artist, const QString& album, const QString& file ) const; - - /** Returns a unique key for the album cover. */ - QByteArray imageKey() const; - - /** Returns the path that the large scale image should have on the disk - * Does not check if the file exists. - * Note: not all large images have a disk cache, e.g. if they are set from outside - * or embedded inside an audio file. - * The largeDiskCache is only used for images set via setImage(QImage) - */ - QString largeDiskCachePath() const; - - /** Returns the path that the image should have on the disk - * Does not check if the file exists. - * @param size is the maximum width or height of the resulting image. - * size==0 is the large image and the location of this file is completely different. - * there should never be a scaled cached version of the large image. it dose not make - * sense. - */ - QString scaledDiskCachePath( int size ) const; - - /** Returns the path to the large image - * Queries the database for the path of the large scale image. - */ - QString largeImagePath(); - - /** Updates the database - * Sets the current albums image to the given path. - * The path should point to a valid image. - * Note: setImage will not delete the already set image. - */ - void setImage( const QString &path ); - - /** Finds or creates a magic value in the database which tells Amarok not to auto fetch an image since it has been explicitly unset. - */ - int unsetImageId() const; - - private: - Collections::SqlCollection* const m_collection; - - - QString m_name; - int m_id; // the id of this album in the database - int m_artistId; - int m_imageId; - mutable QString m_imagePath; // path read from the database - mutable bool m_hasImage; // true if we have an original image - mutable bool m_hasImageChecked; // true if hasImage was checked - - mutable int m_unsetImageId; // this is the id of the unset magic value in the image sql database - static const QString AMAROK_UNSET_MAGIC; - - bool m_tracksLoaded; - bool m_suppressAutoFetch; - Meta::ArtistPtr m_artist; - Meta::TrackList m_tracks; - mutable QMutex m_mutex; - - //TODO: add album artist - - friend class ::SqlRegistry; // needs to call notifyObservers - friend class Meta::SqlTrack; // needs to set images directly - friend class ::SqlScanResultProcessor; // needs to set images directly -}; - -class AMAROK_SQLCOLLECTION_EXPORT SqlComposer : public Meta::Composer -{ - public: - SqlComposer( Collections::SqlCollection* collection, int id, const QString &name ); - - virtual QString name() const { return m_name; } - - virtual void invalidateCache(); - - virtual Meta::TrackList tracks(); - - //SQL specific methods - int id() const { return m_id; } - - private: - Collections::SqlCollection* const m_collection; - - const int m_id; - const QString m_name; - - bool m_tracksLoaded; - Meta::TrackList m_tracks; - QMutex m_mutex; - - friend class ::SqlRegistry; // needs to call notifyObservers - friend class Meta::SqlTrack; // needs to call notifyObservers -}; - -class SqlGenre : public Meta::Genre -{ - public: - SqlGenre( Collections::SqlCollection* collection, int id, const QString &name ); - - virtual QString name() const { return m_name; } - - /** Invalidates the tracks cache */ - /** Invalidates the tracks cache */ - virtual void invalidateCache(); - - virtual Meta::TrackList tracks(); - - //SQL specific methods - int id() const { return m_id; } - - private: - Collections::SqlCollection* const m_collection; - - const int m_id; - const QString m_name; - - bool m_tracksLoaded; - Meta::TrackList m_tracks; - QMutex m_mutex; - - friend class ::SqlRegistry; // needs to call notifyObservers - friend class Meta::SqlTrack; // needs to call notifyObservers -}; - -class AMAROK_SQLCOLLECTION_EXPORT SqlYear : public Meta::Year -{ - public: - SqlYear( Collections::SqlCollection* collection, int id, int year ); - - virtual QString name() const { return QString::number(m_year); } - - virtual int year() const { return m_year; } - - /** Invalidates the tracks cache */ - virtual void invalidateCache(); - - virtual Meta::TrackList tracks(); - - //SQL specific methods - int id() const { return m_id; } - - private: - Collections::SqlCollection* const m_collection; - const int m_id; - const int m_year; - - - bool m_tracksLoaded; - Meta::TrackList m_tracks; - QMutex m_mutex; - - friend class ::SqlRegistry; // needs to call notifyObservers - friend class Meta::SqlTrack; // needs to call notifyObservers -}; - -class AMAROK_SQLCOLLECTION_EXPORT SqlLabel : public Meta::Label -{ -public: - SqlLabel( Collections::SqlCollection *collection, int id, const QString &name ); - - virtual QString name() const { return m_name; } - - /** Invalidates the tracks cache */ - virtual void invalidateCache(); - - virtual Meta::TrackList tracks(); - - //SQL specific methods - int id() const { return m_id; } - -private: - Collections::SqlCollection* const m_collection; - const int m_id; - const QString m_name; - - bool m_tracksLoaded; - Meta::TrackList m_tracks; - QMutex m_mutex; - - friend class ::SqlRegistry; // needs to call notifyObservers - friend class Meta::SqlTrack; // needs to call notifyObservers -}; - -typedef KSharedPtr SqlTrackPtr; -typedef KSharedPtr SqlArtistPtr; -typedef KSharedPtr SqlAlbumPtr; -typedef KSharedPtr SqlComposerPtr; -typedef KSharedPtr SqlGenrePtr; -typedef KSharedPtr SqlYearPtr; - -} - -#endif /* SQLMETA_H */ diff --git a/amarok/src/core-impl/collections/db/sql/SqlQueryMaker.cpp b/amarok/src/core-impl/collections/db/sql/SqlQueryMaker.cpp deleted file mode 100644 index b8384c53..00000000 --- a/amarok/src/core-impl/collections/db/sql/SqlQueryMaker.cpp +++ /dev/null @@ -1,1157 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Maximilian Kossick * - * Copyright (c) 2008 Daniel Winter * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "SqlQueryMaker" - -#include "SqlQueryMaker.h" - -#include "SqlCollection.h" -#include "SqlQueryMakerInternal.h" -#include -#include "core/support/Debug.h" -#include "core-impl/collections/db/MountPointManager.h" - -#include -#include - -#include -#include - -using namespace Collections; - -class SqlWorkerThread : public ThreadWeaver::Job -{ - public: - SqlWorkerThread( SqlQueryMakerInternal *queryMakerInternal ) - : ThreadWeaver::Job() - , m_queryMakerInternal( queryMakerInternal ) - , m_aborted( false ) - { - //nothing to do - } - - virtual ~SqlWorkerThread() - { - delete m_queryMakerInternal; - } - - virtual void requestAbort() - { - m_aborted = true; - } - - SqlQueryMakerInternal* queryMakerInternal() const - { - return m_queryMakerInternal; - } - - protected: - virtual void run() - { - m_queryMakerInternal->run(); - setFinished( !m_aborted ); - } - private: - SqlQueryMakerInternal *m_queryMakerInternal; - - bool m_aborted; -}; - -struct SqlQueryMaker::Private -{ - enum { TAGS_TAB = 1, ARTIST_TAB = 2, ALBUM_TAB = 4, GENRE_TAB = 8, COMPOSER_TAB = 16, YEAR_TAB = 32, STATISTICS_TAB = 64, URLS_TAB = 128, ALBUMARTIST_TAB = 256, LABELS_TAB = 1024 }; - int linkedTables; - QueryMaker::QueryType queryType; - QString query; - QString queryReturnValues; - QString queryFrom; - QString queryMatch; - QString queryFilter; - QString queryOrderBy; - bool withoutDuplicates; - int maxResultSize; - AlbumQueryMode albumMode; - LabelQueryMode labelMode; - SqlWorkerThread *worker; - - QStack andStack; - - QStringList blockingCustomData; - Meta::TrackList blockingTracks; - Meta::AlbumList blockingAlbums; - Meta::ArtistList blockingArtists; - Meta::GenreList blockingGenres; - Meta::ComposerList blockingComposers; - Meta::YearList blockingYears; - Meta::LabelList blockingLabels; - bool blocking; - bool used; - qint64 returnValueType; -}; - -SqlQueryMaker::SqlQueryMaker( SqlCollection* collection ) - : QueryMaker() - , m_collection( collection ) - , d( new Private ) -{ - d->worker = 0; - d->queryType = QueryMaker::None; - d->linkedTables = 0; - d->withoutDuplicates = false; - d->albumMode = AllAlbums; - d->labelMode = QueryMaker::NoConstraint; - d->maxResultSize = -1; - d->andStack.clear(); - d->andStack.push( true ); //and is default - d->blocking = false; - d->used = false; - d->returnValueType = 0; -} - -SqlQueryMaker::~SqlQueryMaker() -{ - disconnect(); - abortQuery(); - if( d->worker ) - d->worker->deleteLater(); - delete d; -} - -void -SqlQueryMaker::abortQuery() -{ - if( d->worker ) - { - d->worker->requestAbort(); - d->worker->disconnect( this ); - if( d->worker->queryMakerInternal() ) - d->worker->queryMakerInternal()->disconnect( this ); - } -} - -void -SqlQueryMaker::run() -{ - if( d->queryType == QueryMaker::None || (d->blocking && d->used) ) - { - debug() << "sql querymaker used without reset or initialization" << endl; - return; //better error handling? - } - if( d->worker && !d->worker->isFinished() ) - { - //the worker thread seems to be running - //TODO: wait or job to complete - - } - else - { - SqlQueryMakerInternal *qmi = new SqlQueryMakerInternal( m_collection ); - qmi->setQuery( query() ); - qmi->setQueryType( d->queryType ); - - if ( !d->blocking ) - { - connect( qmi, SIGNAL(newResultReady(Meta::AlbumList)), SIGNAL(newResultReady(Meta::AlbumList)), Qt::DirectConnection ); - connect( qmi, SIGNAL(newResultReady(Meta::ArtistList)), SIGNAL(newResultReady(Meta::ArtistList)), Qt::DirectConnection ); - connect( qmi, SIGNAL(newResultReady(Meta::GenreList)), SIGNAL(newResultReady(Meta::GenreList)), Qt::DirectConnection ); - connect( qmi, SIGNAL(newResultReady(Meta::ComposerList)), SIGNAL(newResultReady(Meta::ComposerList)), Qt::DirectConnection ); - connect( qmi, SIGNAL(newResultReady(Meta::YearList)), SIGNAL(newResultReady(Meta::YearList)), Qt::DirectConnection ); - connect( qmi, SIGNAL(newResultReady(Meta::TrackList)), SIGNAL(newResultReady(Meta::TrackList)), Qt::DirectConnection ); - connect( qmi, SIGNAL(newResultReady(QStringList)), SIGNAL(newResultReady(QStringList)), Qt::DirectConnection ); - connect( qmi, SIGNAL(newResultReady(Meta::LabelList)), SIGNAL(newResultReady(Meta::LabelList)), Qt::DirectConnection ); - d->worker = new SqlWorkerThread( qmi ); - connect( d->worker, SIGNAL(done(ThreadWeaver::Job*)), SLOT(done(ThreadWeaver::Job*)) ); - ThreadWeaver::Weaver::instance()->enqueue( d->worker ); - } - else //use it blocking - { - connect( qmi, SIGNAL(newResultReady(Meta::AlbumList)), SLOT(blockingNewResultReady(Meta::AlbumList)), Qt::DirectConnection ); - connect( qmi, SIGNAL(newResultReady(Meta::ArtistList)), SLOT(blockingNewResultReady(Meta::ArtistList)), Qt::DirectConnection ); - connect( qmi, SIGNAL(newResultReady(Meta::GenreList)), SLOT(blockingNewResultReady(Meta::GenreList)), Qt::DirectConnection ); - connect( qmi, SIGNAL(newResultReady(Meta::ComposerList)), SLOT(blockingNewResultReady(Meta::ComposerList)), Qt::DirectConnection ); - connect( qmi, SIGNAL(newResultReady(Meta::YearList)), SLOT(blockingNewResultReady(Meta::YearList)), Qt::DirectConnection ); - connect( qmi, SIGNAL(newResultReady(Meta::TrackList)), SLOT(blockingNewResultReady(Meta::TrackList)), Qt::DirectConnection ); - connect( qmi, SIGNAL(newResultReady(QStringList)), SLOT(blockingNewResultReady(QStringList)), Qt::DirectConnection ); - connect( qmi, SIGNAL(newResultReady(Meta::LabelList)), SLOT(blockingNewResultReady(Meta::LabelList)), Qt::DirectConnection ); - qmi->run(); - delete qmi; - } - } - d->used = true; -} - -void -SqlQueryMaker::done( ThreadWeaver::Job *job ) -{ - job->deleteLater(); - d->worker = 0; // d->worker *is* the job, prevent stale pointer - emit queryDone(); -} - -QueryMaker* -SqlQueryMaker::setQueryType( QueryType type ) -{ - // we need the unchanged m_queryType in the blocking result methods so prevent - // reseting queryType without reseting the QM - if ( d->blocking && d->used ) - return this; - - switch( type ) { - case QueryMaker::Track: - //make sure to keep this method in sync with handleTracks(QStringList) and the SqlTrack ctor - if( d->queryType == QueryMaker::None ) - { - d->queryType = QueryMaker::Track; - d->linkedTables |= Private::URLS_TAB; - d->linkedTables |= Private::TAGS_TAB; - d->linkedTables |= Private::GENRE_TAB; - d->linkedTables |= Private::ARTIST_TAB; - d->linkedTables |= Private::ALBUM_TAB; - d->linkedTables |= Private::COMPOSER_TAB; - d->linkedTables |= Private::YEAR_TAB; - d->linkedTables |= Private::STATISTICS_TAB; - d->queryReturnValues = Meta::SqlTrack::getTrackReturnValues(); - } - return this; - - case QueryMaker::Artist: - if( d->queryType == QueryMaker::None ) - { - d->queryType = QueryMaker::Artist; - d->withoutDuplicates = true; - d->linkedTables |= Private::ARTIST_TAB; - //reading the ids from the database means we don't have to query for them later - d->queryReturnValues = "artists.name, artists.id"; - } - return this; - - case QueryMaker::Album: - if( d->queryType == QueryMaker::None ) - { - d->queryType = QueryMaker::Album; - d->withoutDuplicates = true; - d->linkedTables |= Private::ALBUM_TAB; - //add whatever is necessary to identify compilations - d->queryReturnValues = "albums.name, albums.id, albums.artist"; - } - return this; - - case QueryMaker::AlbumArtist: - if( d->queryType == QueryMaker::None ) - { - d->queryType = QueryMaker::AlbumArtist; - d->withoutDuplicates = true; - d->linkedTables |= Private::ALBUMARTIST_TAB; - d->linkedTables |= Private::ALBUM_TAB; - d->queryReturnValues = "albumartists.name, albumartists.id"; - } - return this; - - case QueryMaker::Composer: - if( d->queryType == QueryMaker::None ) - { - d->queryType = QueryMaker::Composer; - d->withoutDuplicates = true; - d->linkedTables |= Private::COMPOSER_TAB; - d->queryReturnValues = "composers.name, composers.id"; - } - return this; - - case QueryMaker::Genre: - if( d->queryType == QueryMaker::None ) - { - d->queryType = QueryMaker::Genre; - d->withoutDuplicates = true; - d->linkedTables |= Private::GENRE_TAB; - d->queryReturnValues = "genres.name, genres.id"; - } - return this; - - case QueryMaker::Year: - if( d->queryType == QueryMaker::None ) - { - d->queryType = QueryMaker::Year; - d->withoutDuplicates = true; - d->linkedTables |= Private::YEAR_TAB; - d->queryReturnValues = "years.name, years.id"; - } - return this; - - case QueryMaker::Custom: - if( d->queryType == QueryMaker::None ) - d->queryType = QueryMaker::Custom; - return this; - - case QueryMaker::Label: - if( d->queryType == QueryMaker::None ) - { - d->queryType = QueryMaker::Label; - d->withoutDuplicates = true; - d->queryReturnValues = "labels.label,labels.id"; - d->linkedTables |= Private::LABELS_TAB; - } - - case QueryMaker::None: - return this; - } - return this; -} - -QueryMaker* -SqlQueryMaker::addMatch( const Meta::TrackPtr &track ) -{ - QString url = track->uidUrl(); - if( !url.isEmpty() ) - /* - KUrl kurl( url ); - if( kurl.protocol() == "amarok-sqltrackuid" ) - */ - { - d->queryMatch += QString( " AND urls.uniqueid = '%1' " ).arg( url /*kurl.url()*/ ); - } - else - { - QString path; - /* - if( kurl.isLocalFile() ) - { - path = kurl.path(); - } - else - */ - { - path = track->playableUrl().path(); - } - int deviceid = m_collection->mountPointManager()->getIdForUrl( path ); - QString rpath = m_collection->mountPointManager()->getRelativePath( deviceid, path ); - d->queryMatch += QString( " AND urls.deviceid = %1 AND urls.rpath = '%2'" ) - .arg( QString::number( deviceid ), escape( rpath ) ); - } - return this; -} - - -QueryMaker* -SqlQueryMaker::addMatch( const Meta::ArtistPtr &artist, ArtistMatchBehaviour behaviour ) -{ - d->linkedTables |= Private::ARTIST_TAB; - if( behaviour == AlbumArtists || behaviour == AlbumOrTrackArtists ) - d->linkedTables |= Private::ALBUMARTIST_TAB; - - QString artistQuery; - QString albumArtistQuery; - - if( artist && !artist->name().isEmpty() ) - { - artistQuery = QString("artists.name = '%1'").arg( escape( artist->name() ) ); - albumArtistQuery = QString("albumartists.name = '%1'").arg( escape( artist->name() ) ); - } - else - { - artistQuery = "( artists.name IS NULL OR artists.name = '')"; - albumArtistQuery = "( albumartists.name IS NULL OR albumartists.name = '')"; - } - - switch( behaviour ) - { - case TrackArtists: - d->queryMatch += " AND " + artistQuery; - break; - case AlbumArtists: - d->queryMatch += " AND " + albumArtistQuery; - break; - case AlbumOrTrackArtists: - d->queryMatch += " AND ( (" + artistQuery + " ) OR ( " + albumArtistQuery + " ) )"; - break; - } - return this; -} - -QueryMaker* -SqlQueryMaker::addMatch( const Meta::AlbumPtr &album ) -{ - d->linkedTables |= Private::ALBUM_TAB; - - // handle singles - if( !album || album->name().isEmpty() ) - d->queryMatch += QString( " AND ( albums.name IS NULL OR albums.name = '' )" ); - else - d->queryMatch += QString( " AND albums.name = '%1'" ).arg( escape( album->name() ) ); - - if( album ) - { - //handle compilations - Meta::ArtistPtr albumArtist = album->albumArtist(); - if( albumArtist ) - { - d->linkedTables |= Private::ALBUMARTIST_TAB; - d->queryMatch += QString( " AND albumartists.name = '%1'" ).arg( escape( albumArtist->name() ) ); - } - else - { - d->queryMatch += " AND albums.artist IS NULL"; - } - } - return this; -} - -QueryMaker* -SqlQueryMaker::addMatch( const Meta::GenrePtr &genre ) -{ - d->linkedTables |= Private::GENRE_TAB; - d->queryMatch += QString( " AND genres.name = '%1'" ).arg( escape( genre->name() ) ); - return this; -} - -QueryMaker* -SqlQueryMaker::addMatch( const Meta::ComposerPtr &composer ) -{ - d->linkedTables |= Private::COMPOSER_TAB; - d->queryMatch += QString( " AND composers.name = '%1'" ).arg( escape( composer->name() ) ); - return this; -} - -QueryMaker* -SqlQueryMaker::addMatch( const Meta::YearPtr &year ) -{ - // handle tracks without a year - if( !year ) - { - d->queryMatch += " AND year IS NULL"; - } - else - { - d->linkedTables |= Private::YEAR_TAB; - d->queryMatch += QString( " AND years.name = '%1'" ).arg( escape( year->name() ) ); - } - return this; -} - -QueryMaker* -SqlQueryMaker::addMatch( const Meta::LabelPtr &label ) -{ - KSharedPtr sqlLabel = KSharedPtr::dynamicCast( label ); - QString labelSubQuery; - if( sqlLabel ) - { - labelSubQuery = "SELECT url FROM urls_labels WHERE label = %1"; - labelSubQuery = labelSubQuery.arg( sqlLabel->id() ); - } - else - { - labelSubQuery = "SELECT a.url FROM urls_labels a INNER JOIN labels b ON a.label = b.id WHERE b.label = '%1'"; - labelSubQuery = labelSubQuery.arg( escape( label->name() ) ); - } - d->linkedTables |= Private::TAGS_TAB; - QString match = " AND tracks.url in (%1)"; - d->queryMatch += match.arg( labelSubQuery ); - return this; -} - -QueryMaker* -SqlQueryMaker::addFilter( qint64 value, const QString &filter, bool matchBegin, bool matchEnd ) -{ - // special case for albumartist... - if( value == Meta::valAlbumArtist && filter.isEmpty() ) - { - d->linkedTables |= Private::ALBUMARTIST_TAB; - d->linkedTables |= Private::ALBUM_TAB; - d->queryFilter += QString( " %1 ( albums.artist IS NULL or albumartists.name = '') " ).arg( andOr() ); - } - else if( value == Meta::valLabel ) - { - d->linkedTables |= Private::TAGS_TAB; - QString like = likeCondition( filter, !matchBegin, !matchEnd ); - QString filter = " %1 tracks.url IN (SELECT a.url FROM urls_labels a INNER JOIN labels b ON a.label = b.id WHERE b.label %2) "; - d->queryFilter += filter.arg( andOr(), like ); - } - else - { - QString like = likeCondition( filter, !matchBegin, !matchEnd ); - d->queryFilter += QString( " %1 %2 %3 " ).arg( andOr(), nameForValue( value ), like ); - } - return this; -} - -QueryMaker* -SqlQueryMaker::excludeFilter( qint64 value, const QString &filter, bool matchBegin, bool matchEnd ) -{ - // special case for album... - if( value == Meta::valAlbumArtist && filter.isEmpty() ) - { - d->linkedTables |= Private::ALBUMARTIST_TAB; - d->queryFilter += QString( " %1 NOT ( albums.artist IS NULL or albumartists.name = '') " ).arg( andOr() ); - } - else if( value == Meta::valLabel ) - { - d->linkedTables |= Private::TAGS_TAB; - QString like = likeCondition( filter, !matchBegin, !matchEnd ); - QString filter = " %1 tracks.url NOT IN (SELECT a.url FROM urls_labels a INNER JOIN labels b ON a.label = b.id WHERE b.label %2) "; - d->queryFilter += filter.arg( andOr(), like ); - } - else - { - QString like = likeCondition( filter, !matchBegin, !matchEnd ); - d->queryFilter += QString( " %1 NOT %2 %3 " ).arg( andOr(), nameForValue( value ), like ); - } - return this; -} - -QueryMaker* -SqlQueryMaker::addNumberFilter( qint64 value, qint64 filter, QueryMaker::NumberComparison compare ) -{ - QString comparison; - switch( compare ) - { - case QueryMaker::Equals: - comparison = '='; - break; - case QueryMaker::GreaterThan: - comparison = '>'; - break; - case QueryMaker::LessThan: - comparison = '<'; - break; - } - - // note: a NULL value in the database means undefined and not 0! - d->queryFilter += QString( " %1 %2 %3 %4 " ).arg( andOr(), nameForValue( value ), comparison, QString::number( filter ) ); - - return this; -} - -QueryMaker* -SqlQueryMaker::excludeNumberFilter( qint64 value, qint64 filter, QueryMaker::NumberComparison compare ) -{ - QString comparison; - switch( compare ) - { - case QueryMaker::Equals: - comparison = "!="; - break; - case QueryMaker::GreaterThan: //negating greater than is less or equal - comparison = "<="; - break; - case QueryMaker::LessThan: //negating less than is greater or equal - comparison = ">="; - break; - } - - // note: a NULL value in the database means undefined and not 0! - // We can't exclude NULL values here because they are not defined! - d->queryFilter += QString( " %1 (%2 %3 %4 or %2 is null)" ).arg( andOr(), nameForValue( value ), comparison, QString::number( filter ) ); - - return this; -} - -QueryMaker* -SqlQueryMaker::addReturnValue( qint64 value ) -{ - if( d->queryType == QueryMaker::Custom ) - { - if ( !d->queryReturnValues.isEmpty() ) - d->queryReturnValues += ','; - d->queryReturnValues += nameForValue( value ); - d->returnValueType = value; - } - return this; -} - -QueryMaker* -SqlQueryMaker::addReturnFunction( ReturnFunction function, qint64 value ) -{ - if( d->queryType == QueryMaker::Custom ) - { - if( !d->queryReturnValues.isEmpty() ) - d->queryReturnValues += ','; - QString sqlfunction; - switch( function ) - { - case QueryMaker::Count: - sqlfunction = "COUNT"; - break; - case QueryMaker::Sum: - sqlfunction = "SUM"; - break; - case QueryMaker::Max: - sqlfunction = "MAX"; - break; - case QueryMaker::Min: - sqlfunction = "MIN"; - break; - default: - sqlfunction = "Unknown function in SqlQueryMaker::addReturnFunction, function was: " + QString::number( function ); - } - d->queryReturnValues += QString( "%1(%2)" ).arg( sqlfunction, nameForValue( value ) ); - d->returnValueType = value; - } - return this; -} - -QueryMaker* -SqlQueryMaker::orderBy( qint64 value, bool descending ) -{ - if ( d->queryOrderBy.isEmpty() ) - d->queryOrderBy = " ORDER BY "; - else - d->queryOrderBy += ','; - d->queryOrderBy += nameForValue( value ); - d->queryOrderBy += QString( " %1 " ).arg( descending ? "DESC" : "ASC" ); - return this; -} - -QueryMaker* -SqlQueryMaker::limitMaxResultSize( int size ) -{ - d->maxResultSize = size; - return this; -} - -QueryMaker* -SqlQueryMaker::setAlbumQueryMode( AlbumQueryMode mode ) -{ - if( mode != AllAlbums ) - { - d->linkedTables |= Private::ALBUM_TAB; - } - d->albumMode = mode; - return this; -} - -QueryMaker* -SqlQueryMaker::setLabelQueryMode( LabelQueryMode mode ) -{ - d->labelMode = mode; - return this; -} - -QueryMaker* -SqlQueryMaker::beginAnd() -{ - d->queryFilter += andOr(); - d->queryFilter += " ( 1 "; - d->andStack.push( true ); - return this; -} - -QueryMaker* -SqlQueryMaker::beginOr() -{ - d->queryFilter += andOr(); - d->queryFilter += " ( 0 "; - d->andStack.push( false ); - return this; -} - -QueryMaker* -SqlQueryMaker::endAndOr() -{ - d->queryFilter += ')'; - d->andStack.pop(); - return this; -} - -void -SqlQueryMaker::linkTables() -{ - switch( d->queryType ) - { - case QueryMaker::Track: - { - d->queryFrom += " tracks"; - if( d->linkedTables & Private::TAGS_TAB ) - d->linkedTables ^= Private::TAGS_TAB; - break; - } - case QueryMaker::Artist: - { - d->queryFrom += " artists"; - if( d->linkedTables != Private::ARTIST_TAB ) - d->queryFrom += " JOIN tracks ON tracks.artist = artists.id"; - if( d->linkedTables & Private::ARTIST_TAB ) - d->linkedTables ^= Private::ARTIST_TAB; - break; - } - case QueryMaker::Album: - case QueryMaker::AlbumArtist: - { - d->queryFrom += " albums"; - if( d->linkedTables != Private::ALBUM_TAB && d->linkedTables != ( Private::ALBUM_TAB | Private::ALBUMARTIST_TAB ) ) - d->queryFrom += " JOIN tracks ON tracks.album = albums.id"; - if( d->linkedTables & Private::ALBUM_TAB ) - d->linkedTables ^= Private::ALBUM_TAB; - break; - } - case QueryMaker::Genre: - { - d->queryFrom += " genres"; - if( d->linkedTables != Private::GENRE_TAB ) - d->queryFrom += " INNER JOIN tracks ON tracks.genre = genres.id"; - if( d->linkedTables & Private::GENRE_TAB ) - d->linkedTables ^= Private::GENRE_TAB; - break; - } - case QueryMaker::Composer: - { - d->queryFrom += " composers"; - if( d->linkedTables != Private::COMPOSER_TAB ) - d->queryFrom += " JOIN tracks ON tracks.composer = composers.id"; - if( d->linkedTables & Private::COMPOSER_TAB ) - d->linkedTables ^= Private::COMPOSER_TAB; - break; - } - case QueryMaker::Year: - { - d->queryFrom += " years"; - if( d->linkedTables != Private::YEAR_TAB ) - d->queryFrom += " JOIN tracks on tracks.year = years.id"; - if( d->linkedTables & Private::YEAR_TAB ) - d->linkedTables ^= Private::YEAR_TAB; - break; - } - case QueryMaker::Label: - { - d->queryFrom += " labels"; - if( d->linkedTables != Private::LABELS_TAB ) - d->queryFrom += " INNER JOIN urls_labels ON labels.id = urls_labels.label" - " INNER JOIN tracks ON urls_labels.url = tracks.url"; - if( d->linkedTables & Private::LABELS_TAB ) - d->linkedTables ^= Private::LABELS_TAB; - break; - } - case QueryMaker::Custom: - { - switch( d->returnValueType ) - { - default: - case Meta::valUrl: - { - d->queryFrom += " tracks"; - if( d->linkedTables & Private::TAGS_TAB ) - d->linkedTables ^= Private::TAGS_TAB; - break; - } - case Meta::valAlbum: - { - d->queryFrom += " albums"; - if( d->linkedTables & Private::ALBUM_TAB ) - d->linkedTables ^= Private::ALBUM_TAB; - if( d->linkedTables & Private::URLS_TAB ) - d->linkedTables ^= Private::URLS_TAB; - break; - } - case Meta::valArtist: - { - d->queryFrom += " artists"; - if( d->linkedTables & Private::ARTIST_TAB ) - d->linkedTables ^= Private::ARTIST_TAB; - if( d->linkedTables & Private::URLS_TAB ) - d->linkedTables ^= Private::URLS_TAB; - break; - } - case Meta::valGenre: - { - d->queryFrom += " genres"; - if( d->linkedTables & Private::GENRE_TAB ) - d->linkedTables ^= Private::GENRE_TAB; - if( d->linkedTables & Private::URLS_TAB ) - d->linkedTables ^= Private::URLS_TAB; - break; - } - } - } - case QueryMaker::None: - { - //??? - break; - } - } - if( !d->linkedTables ) - return; - - if( d->linkedTables & Private::URLS_TAB ) - d->queryFrom += " INNER JOIN urls ON tracks.url = urls.id"; - if( d->linkedTables & Private::ARTIST_TAB ) - d->queryFrom += " LEFT JOIN artists ON tracks.artist = artists.id"; - if( d->linkedTables & Private::ALBUM_TAB ) - d->queryFrom += " LEFT JOIN albums ON tracks.album = albums.id"; - if( d->linkedTables & Private::ALBUMARTIST_TAB ) - d->queryFrom += " LEFT JOIN artists AS albumartists ON albums.artist = albumartists.id"; - if( d->linkedTables & Private::GENRE_TAB ) - d->queryFrom += " LEFT JOIN genres ON tracks.genre = genres.id"; - if( d->linkedTables & Private::COMPOSER_TAB ) - d->queryFrom += " LEFT JOIN composers ON tracks.composer = composers.id"; - if( d->linkedTables & Private::YEAR_TAB ) - d->queryFrom += " LEFT JOIN years ON tracks.year = years.id"; - if( d->linkedTables & Private::STATISTICS_TAB ) - { - if( d->linkedTables & Private::URLS_TAB ) - { - d->queryFrom += " LEFT JOIN statistics ON urls.id = statistics.url"; - } - else - { - d->queryFrom += " LEFT JOIN statistics ON tracks.url = statistics.url"; - } - } -} - -void -SqlQueryMaker::buildQuery() -{ - //URLS is always required for dynamic collection - d->linkedTables |= Private::URLS_TAB; - linkTables(); - QString query = "SELECT "; - if ( d->withoutDuplicates ) - query += "DISTINCT "; - query += d->queryReturnValues; - query += " FROM "; - query += d->queryFrom; - - // dynamic collection (only mounted file systems are considered) - if( (d->linkedTables & Private::URLS_TAB) && m_collection->mountPointManager() ) - { - query += " WHERE 1 "; - IdList list = m_collection->mountPointManager()->getMountedDeviceIds(); - if( !list.isEmpty() ) - { - QString commaSeparatedIds; - foreach( int id, list ) - { - if( !commaSeparatedIds.isEmpty() ) - commaSeparatedIds += ','; - commaSeparatedIds += QString::number( id ); - } - query += QString( " AND urls.deviceid in (%1)" ).arg( commaSeparatedIds ); - } - } - - switch( d->albumMode ) - { - case OnlyNormalAlbums: - query += " AND albums.artist IS NOT NULL "; - break; - case OnlyCompilations: - query += " AND albums.artist IS NULL "; - break; - case AllAlbums: - //do nothing - break; - } - if( d->labelMode != QueryMaker::NoConstraint ) - { - switch( d->labelMode ) - { - case QueryMaker::OnlyWithLabels: - query += " AND tracks.url IN "; - break; - - case QueryMaker::OnlyWithoutLabels: - query += " AND tracks.url NOT IN "; - break; - - case QueryMaker::NoConstraint: - //do nothing, will never be called - break; - } - query += " (SELECT DISTINCT url FROM urls_labels) "; - } - - query += d->queryMatch; - if ( !d->queryFilter.isEmpty() ) - { - query += " AND ( 1 "; - query += d->queryFilter; - query += " ) "; - } - query += d->queryOrderBy; - if ( d->maxResultSize > -1 ) - query += QString( " LIMIT %1 OFFSET 0 " ).arg( d->maxResultSize ); - query += ';'; - d->query = query; -} - -QString -SqlQueryMaker::query() -{ - if ( d->query.isEmpty() ) - buildQuery(); - return d->query; -} - -QStringList -SqlQueryMaker::runQuery( const QString &query ) -{ - return m_collection->sqlStorage()->query( query ); -} - -void -SqlQueryMaker::setBlocking( bool enabled ) -{ - d->blocking = enabled; -} - -QStringList -SqlQueryMaker::collectionIds() const -{ - QStringList list; - list << m_collection->collectionId(); - return list; -} - -Meta::TrackList -SqlQueryMaker::tracks() const -{ - return d->blockingTracks; -} - -Meta::AlbumList -SqlQueryMaker::albums() const -{ - return d->blockingAlbums; -} - -Meta::ArtistList -SqlQueryMaker::artists() const -{ - return d->blockingArtists; -} - -Meta::GenreList -SqlQueryMaker::genres() const -{ - return d->blockingGenres; -} - -Meta::ComposerList -SqlQueryMaker::composers() const -{ - return d->blockingComposers; -} - -Meta::YearList -SqlQueryMaker::years() const -{ - return d->blockingYears; -} - -QStringList -SqlQueryMaker::customData() const -{ - return d->blockingCustomData; -} - -Meta::LabelList -SqlQueryMaker::labels() const -{ - return d->blockingLabels; -} - -QString -SqlQueryMaker::nameForValue( qint64 value ) -{ - switch( value ) - { - case Meta::valUrl: - d->linkedTables |= Private::URLS_TAB; - return "urls.rpath"; //TODO figure out how to handle deviceid - case Meta::valTitle: - d->linkedTables |= Private::TAGS_TAB; - return "tracks.title"; - case Meta::valArtist: - d->linkedTables |= Private::ARTIST_TAB; - return "artists.name"; - case Meta::valAlbum: - d->linkedTables |= Private::ALBUM_TAB; - return "albums.name"; - case Meta::valGenre: - d->linkedTables |= Private::GENRE_TAB; - return "genres.name"; - case Meta::valComposer: - d->linkedTables |= Private::COMPOSER_TAB; - return "composers.name"; - case Meta::valYear: - d->linkedTables |= Private::YEAR_TAB; - return "years.name"; - case Meta::valBpm: - d->linkedTables |= Private::TAGS_TAB; - return "tracks.bpm"; - case Meta::valComment: - d->linkedTables |= Private::TAGS_TAB; - return "tracks.comment"; - case Meta::valTrackNr: - d->linkedTables |= Private::TAGS_TAB; - return "tracks.tracknumber"; - case Meta::valDiscNr: - d->linkedTables |= Private::TAGS_TAB; - return "tracks.discnumber"; - case Meta::valLength: - d->linkedTables |= Private::TAGS_TAB; - return "tracks.length"; - case Meta::valBitrate: - d->linkedTables |= Private::TAGS_TAB; - return "tracks.bitrate"; - case Meta::valSamplerate: - d->linkedTables |= Private::TAGS_TAB; - return "tracks.samplerate"; - case Meta::valFilesize: - d->linkedTables |= Private::TAGS_TAB; - return "tracks.filesize"; - case Meta::valFormat: - d->linkedTables |= Private::TAGS_TAB; - return "tracks.filetype"; - case Meta::valCreateDate: - d->linkedTables |= Private::TAGS_TAB; - return "tracks.createdate"; - case Meta::valScore: - d->linkedTables |= Private::STATISTICS_TAB; - return "statistics.score"; - case Meta::valRating: - d->linkedTables |= Private::STATISTICS_TAB; - return "statistics.rating"; - case Meta::valFirstPlayed: - d->linkedTables |= Private::STATISTICS_TAB; - return "statistics.createdate"; - case Meta::valLastPlayed: - d->linkedTables |= Private::STATISTICS_TAB; - return "statistics.accessdate"; - case Meta::valPlaycount: - d->linkedTables |= Private::STATISTICS_TAB; - return "statistics.playcount"; - case Meta::valUniqueId: - d->linkedTables |= Private::URLS_TAB; - return "urls.uniqueid"; - case Meta::valAlbumArtist: - d->linkedTables |= Private::ALBUMARTIST_TAB; - //albumartist_tab means that the artist table is joined to the albums table - //so add albums as well - d->linkedTables |= Private::ALBUM_TAB; - return "albumartists.name"; - case Meta::valModified: - d->linkedTables |= Private::TAGS_TAB; - return "tracks.modifydate"; - default: - return "ERROR: unknown value in SqlQueryMaker::nameForValue(qint64): value=" + QString::number( value ); - } -} - -QString -SqlQueryMaker::andOr() const -{ - return d->andStack.top() ? " AND " : " OR "; -} - -QString -SqlQueryMaker::escape( QString text ) const //krazy:exclude=constref -{ - return m_collection->sqlStorage()->escape( text ); -} - -QString -SqlQueryMaker::likeCondition( const QString &text, bool anyBegin, bool anyEnd ) const -{ - if( anyBegin || anyEnd ) - { - QString escaped = text; - //according to http://dev.mysql.com/doc/refman/5.0/en/string-comparison-functions.html - //the escape character (\ as we are using the default) is escaped twice when using like. - //mysql_real_escape will escape it once, so we have to escape it another time here - escaped = escaped.replace( '\\', "\\\\" ); // "////" will result in two backslahes - escaped = escape( escaped ); - //as we are in pattern matching mode '_' and '%' have to be escaped - //mysql_real_excape_string does not do that for us - //see http://dev.mysql.com/doc/refman/5.0/en/string-syntax.html - //and http://dev.mysql.com/doc/refman/5.0/en/mysql-real-escape-string.html - //replace those characters after calling escape(), which calls the mysql - //function in turn, so that mysql does not escape the escape backslashes - escaped.replace( '%', "\\%" ).replace( '_', "\\_" ); - - QString ret = " LIKE "; - - ret += '\''; - if ( anyBegin ) - ret += '%'; - ret += escaped; - if ( anyEnd ) - ret += '%'; - ret += '\''; - - //Case insensitive collation for queries - ret += " COLLATE utf8_unicode_ci "; - - //Use \ as the escape character - //ret += " ESCAPE '\\' "; - - return ret; - } - else - { - return QString( " = '%1' COLLATE utf8_unicode_ci " ).arg( escape( text ) ); - } -} - -void -SqlQueryMaker::blockingNewResultReady(const Meta::AlbumList &albums) -{ - d->blockingAlbums = albums; -} - -void -SqlQueryMaker::blockingNewResultReady(const Meta::ArtistList &artists) -{ - d->blockingArtists = artists; -} - -void -SqlQueryMaker::blockingNewResultReady(const Meta::GenreList &genres) -{ - d->blockingGenres = genres; -} - -void -SqlQueryMaker::blockingNewResultReady(const Meta::ComposerList &composers) -{ - d->blockingComposers = composers; -} - -void -SqlQueryMaker::blockingNewResultReady(const Meta::YearList &years) -{ - d->blockingYears = years; -} - -void -SqlQueryMaker::blockingNewResultReady(const Meta::TrackList &tracks) -{ - d->blockingTracks = tracks; -} - -void -SqlQueryMaker::blockingNewResultReady(const QStringList &customData) -{ - d->blockingCustomData = customData; -} - -void -SqlQueryMaker::blockingNewResultReady(const Meta::LabelList &labels ) -{ - d->blockingLabels = labels; -} - -#include "moc_SqlQueryMaker.cpp" - diff --git a/amarok/src/core-impl/collections/db/sql/SqlQueryMaker.h b/amarok/src/core-impl/collections/db/sql/SqlQueryMaker.h deleted file mode 100644 index b9d7b989..00000000 --- a/amarok/src/core-impl/collections/db/sql/SqlQueryMaker.h +++ /dev/null @@ -1,135 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_COLLECTION_SQLQUERYMAKER_H -#define AMAROK_COLLECTION_SQLQUERYMAKER_H - -#include "core/collections/QueryMaker.h" - -#include "amarok_sqlcollection_export.h" - -#include - -namespace Collections { - -class SqlCollection; - -class AMAROK_SQLCOLLECTION_EXPORT SqlQueryMaker : public QueryMaker -{ - Q_OBJECT - - public: - SqlQueryMaker( SqlCollection* collection ); - virtual ~SqlQueryMaker(); - - virtual void abortQuery(); - virtual void run(); - - virtual QueryMaker* setQueryType( QueryType type ); - - virtual QueryMaker* addMatch( const Meta::TrackPtr &track ); - virtual QueryMaker* addMatch( const Meta::ArtistPtr &artist, ArtistMatchBehaviour behaviour = TrackArtists ); - virtual QueryMaker* addMatch( const Meta::AlbumPtr &album ); - virtual QueryMaker* addMatch( const Meta::ComposerPtr &composer ); - virtual QueryMaker* addMatch( const Meta::GenrePtr &genre ); - virtual QueryMaker* addMatch( const Meta::YearPtr &year ); - virtual QueryMaker* addMatch( const Meta::LabelPtr &label ); - - virtual QueryMaker* addFilter( qint64 value, const QString &filter, bool matchBegin, bool matchEnd ); - virtual QueryMaker* excludeFilter( qint64 value, const QString &filter, bool matchBegin, bool matchEnd ); - - virtual QueryMaker* addNumberFilter( qint64 value, qint64 filter, NumberComparison compare ); - virtual QueryMaker* excludeNumberFilter( qint64 value, qint64 filter, NumberComparison compare ); - - virtual QueryMaker* addReturnValue( qint64 value ); - virtual QueryMaker* addReturnFunction( ReturnFunction function, qint64 value ); - virtual QueryMaker* orderBy( qint64 value, bool descending = false ); - - virtual QueryMaker* limitMaxResultSize( int size ); - - virtual QueryMaker* setAlbumQueryMode( AlbumQueryMode mode ); - virtual QueryMaker* setLabelQueryMode( LabelQueryMode mode ); - - virtual QueryMaker* beginAnd(); - virtual QueryMaker* beginOr(); - virtual QueryMaker* endAndOr(); - - QString query(); - QStringList runQuery( const QString &query ); - void handleResult( const QStringList &result ); - - // for using it blocking (only for collection internal use) - - void setBlocking( bool enabled ); - - QStringList collectionIds() const; - - Meta::TrackList tracks() const; - Meta::AlbumList albums() const; - Meta::ArtistList artists() const; - Meta::GenreList genres() const; - Meta::ComposerList composers() const; - Meta::YearList years() const; - QStringList customData() const; - Meta::LabelList labels() const; - - protected: - virtual QString escape( QString text ) const; - - /** - * returns a pattern for LIKE operator that will match given text with given options - * @param text the text to match (should not be escape()'d, function does it itself) - * @param anyBegin wildcard match the beginning of @p text (*text) - * @param anyEnd wildcard match the end of @p text (text*) - */ - virtual QString likeCondition( const QString &text, bool anyBegin, bool anyEnd ) const; - - public slots: - void done( ThreadWeaver::Job * job ); - void blockingNewResultReady( const QStringList &customData ); - void blockingNewResultReady( const Meta::AlbumList &albums ); - void blockingNewResultReady( const Meta::ArtistList &artists ); - void blockingNewResultReady( const Meta::GenreList &genres ); - void blockingNewResultReady( const Meta::ComposerList &composers ); - void blockingNewResultReady( const Meta::YearList &years ); - void blockingNewResultReady( const Meta::TrackList &tracks ); - void blockingNewResultReady( const Meta::LabelList &labels ); - - private: - - void linkTables(); - void buildQuery(); - - QString nameForValue( qint64 value ); - QString andOr() const; - - SqlCollection *m_collection; - - struct Private; - Private * const d; - -}; - -class SqlQueryMakerFactory -{ -public: - virtual SqlQueryMaker* createQueryMaker() const = 0; - virtual ~SqlQueryMakerFactory() {}; -}; - -} //namespace Collections - -#endif /* AMAROK_COLLECTION_SQLQUERYMAKER_H */ diff --git a/amarok/src/core-impl/collections/db/sql/SqlQueryMakerInternal.cpp b/amarok/src/core-impl/collections/db/sql/SqlQueryMakerInternal.cpp deleted file mode 100644 index 8d306903..00000000 --- a/amarok/src/core-impl/collections/db/sql/SqlQueryMakerInternal.cpp +++ /dev/null @@ -1,245 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "SqlQueryMakerInternal.h" - -#include -#include "core/support/Debug.h" -#include "SqlCollection.h" -#include "SqlMeta.h" -#include "SqlRegistry.h" - -#include - -using namespace Collections; - -SqlQueryMakerInternal::SqlQueryMakerInternal( SqlCollection *collection ) - : QObject() - , m_collection( collection ) - , m_queryType( QueryMaker::None ) -{ -} - -SqlQueryMakerInternal::~ SqlQueryMakerInternal() -{ - disconnect(); -} - -void -SqlQueryMakerInternal::run() -{ - Q_ASSERT( !m_query.isEmpty() ); - if( !m_collection.isNull() ) - { - QStringList result = m_collection.data()->sqlStorage()->query( m_query ); - handleResult( result ); - } - else - { - deleteLater(); - } - -} - -void -SqlQueryMakerInternal::setQuery( const QString &query ) -{ - //qDebug() << query; - m_query = query; -} - -void -SqlQueryMakerInternal::setQueryType( QueryMaker::QueryType type ) -{ - m_queryType = type; -} - -void -SqlQueryMakerInternal::handleResult( const QStringList &result ) -{ - if( !result.isEmpty() ) - { - switch( m_queryType ) { - case QueryMaker::Custom: - emit newResultReady( result ); - break; - case QueryMaker::Track: - handleTracks( result ); - break; - case QueryMaker::Artist: - case QueryMaker::AlbumArtist: - handleArtists( result ); - break; - case QueryMaker::Album: - handleAlbums( result ); - break; - case QueryMaker::Genre: - handleGenres( result ); - break; - case QueryMaker::Composer: - handleComposers( result ); - break; - case QueryMaker::Year: - handleYears( result ); - break; - case QueryMaker::Label: - handleLabels( result ); - break; - - case QueryMaker::None: - debug() << "Warning: queryResult with queryType == NONE"; - } - } - else - { - switch( m_queryType ) { - case QueryMaker::Custom: - emit newResultReady( QStringList() ); - break; - case QueryMaker::Track: - emit newResultReady( Meta::TrackList() ); - break; - case QueryMaker::Artist: - case QueryMaker::AlbumArtist: - emit newResultReady( Meta::ArtistList() ); - break; - case QueryMaker::Album: - emit newResultReady( Meta::AlbumList() ); - break; - case QueryMaker::Genre: - emit newResultReady( Meta::GenreList() ); - break; - case QueryMaker::Composer: - emit newResultReady( Meta::ComposerList() ); - break; - case QueryMaker::Year: - emit newResultReady( Meta::YearList() ); - break; - case QueryMaker::Label: - emit newResultReady( Meta::LabelList() ); - break; - - case QueryMaker::None: - debug() << "Warning: queryResult with queryType == NONE"; - } - } - - //queryDone will be emitted in done(Job*) -} - -void -SqlQueryMakerInternal::handleTracks( const QStringList &result ) -{ - Meta::TrackList tracks; - SqlRegistry* reg = m_collection.data()->registry(); - int returnCount = Meta::SqlTrack::getTrackReturnValueCount(); - int resultRows = result.size() / returnCount; - for( int i = 0; i < resultRows; i++ ) - { - QStringList row = result.mid( i*returnCount, returnCount ); - tracks.append( reg->getTrack( row[Meta::SqlTrack::returnIndex_trackId].toInt(), row ) ); - } - emit newResultReady( tracks ); -} - -void -SqlQueryMakerInternal::handleArtists( const QStringList &result ) -{ - Meta::ArtistList artists; - SqlRegistry* reg = m_collection.data()->registry(); - for( QStringListIterator iter( result ); iter.hasNext(); ) - { - QString name = iter.next(); - QString id = iter.next(); - if( id.toInt() > 0 ) - artists.append( reg->getArtist( id.toInt(), name ) ); - } - emit newResultReady( artists ); -} - -void -SqlQueryMakerInternal::handleAlbums( const QStringList &result ) -{ - Meta::AlbumList albums; - SqlRegistry* reg = m_collection.data()->registry(); - for( QStringListIterator iter( result ); iter.hasNext(); ) - { - QString name = iter.next(); - QString id = iter.next(); - QString artist = iter.next(); - albums.append( reg->getAlbum( id.toInt(), name, artist.toInt() ) ); - } - emit newResultReady( albums ); -} - -void -SqlQueryMakerInternal::handleGenres( const QStringList &result ) -{ - Meta::GenreList genres; - SqlRegistry* reg = m_collection.data()->registry(); - for( QStringListIterator iter( result ); iter.hasNext(); ) - { - QString name = iter.next(); - QString id = iter.next(); - genres.append( reg->getGenre( id.toInt(), name ) ); - } - emit newResultReady( genres ); -} - -void -SqlQueryMakerInternal::handleComposers( const QStringList &result ) -{ - Meta::ComposerList composers; - SqlRegistry* reg = m_collection.data()->registry(); - for( QStringListIterator iter( result ); iter.hasNext(); ) - { - QString name = iter.next(); - QString id = iter.next(); - composers.append( reg->getComposer( id.toInt(), name ) ); - } - emit newResultReady( composers ); -} - -void -SqlQueryMakerInternal::handleYears( const QStringList &result ) -{ - Meta::YearList years; - SqlRegistry* reg = m_collection.data()->registry(); - for( QStringListIterator iter( result ); iter.hasNext(); ) - { - QString name = iter.next(); - QString id = iter.next(); - years.append( reg->getYear( id.toInt(), name.toInt() ) ); - } - emit newResultReady( years ); -} - -void -SqlQueryMakerInternal::handleLabels( const QStringList &result ) -{ - Meta::LabelList labels; - SqlRegistry *reg = m_collection.data()->registry(); - for( QStringListIterator iter( result ); iter.hasNext(); ) - { - QString label = iter.next(); - QString id = iter.next(); - labels.append( reg->getLabel( id.toInt(), label ) ); - } - - emit newResultReady( labels ); -} - -#include "moc_SqlQueryMakerInternal.cpp" diff --git a/amarok/src/core-impl/collections/db/sql/SqlQueryMakerInternal.h b/amarok/src/core-impl/collections/db/sql/SqlQueryMakerInternal.h deleted file mode 100644 index ab66b6fd..00000000 --- a/amarok/src/core-impl/collections/db/sql/SqlQueryMakerInternal.h +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef SQLQUERYMAKERINTERNAL_H -#define SQLQUERYMAKERINTERNAL_H - -#include "core/collections/QueryMaker.h" -#include "core/meta/forward_declarations.h" - -#include -#include -#include - -namespace Collections { - -class SqlCollection; - -class SqlQueryMakerInternal : public QObject -{ -Q_OBJECT -public: - explicit SqlQueryMakerInternal( SqlCollection *collection ); - virtual ~ SqlQueryMakerInternal(); - - void run(); - void setQuery( const QString &query ); - void setQueryType( QueryMaker::QueryType type ); - void setResultAsDataPtrs( bool value ); - -signals: - void newResultReady( Meta::TrackList ); - void newResultReady( Meta::ArtistList ); - void newResultReady( Meta::AlbumList ); - void newResultReady( Meta::GenreList ); - void newResultReady( Meta::ComposerList ); - void newResultReady( Meta::YearList ); - void newResultReady( QStringList ); - void newResultReady( Meta::LabelList ); - -private: - void handleResult( const QStringList &result ); - void handleTracks( const QStringList &result ); - void handleArtists( const QStringList &result ); - void handleAlbums( const QStringList &result ); - void handleGenres( const QStringList &result ); - void handleComposers( const QStringList &result ); - void handleYears( const QStringList &result ); - void handleLabels( const QStringList &result ); - -private: - QWeakPointer m_collection; - QueryMaker::QueryType m_queryType; - QString m_query; - -}; - -} //namespace Collections - -#endif // SQLQUERYMAKERINTERNAL_H diff --git a/amarok/src/core-impl/collections/db/sql/SqlReadLabelCapability.cpp b/amarok/src/core-impl/collections/db/sql/SqlReadLabelCapability.cpp deleted file mode 100644 index 2f15d457..00000000 --- a/amarok/src/core-impl/collections/db/sql/SqlReadLabelCapability.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/* - Copyright (C) 2009 Dan Meltzer - - This program 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 2 of the License, or - (at your option) any later version. - - This program 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 this program. If not, see . - -*/ - -#include "SqlReadLabelCapability.h" - -#include "core-impl/collections/support/CollectionManager.h" -#include "core/support/Debug.h" -#include - -namespace Capabilities -{ - -SqlReadLabelCapability::SqlReadLabelCapability( Meta::SqlTrack *track, SqlStorage *storage ) - : ReadLabelCapability() - , m_track( track ) - , m_storage( storage ) -{ - //TODO: Update cached labels when new labels are added. - fetchLabels(); -} - -void -SqlReadLabelCapability::fetch( QString uniqueURL ) -{ - QStringList labels; - - if( !m_storage ) - { - debug() << "Could not get SqlStorage, aborting" << endl; - return; - } - - QString query = "SELECT a.label FROM labels a"; - QStringList result; - - if ( !uniqueURL.isEmpty() ) - { - query = query + QString( ", urls_labels b, urls c WHERE a.id=b.label AND b.url=c.id AND c.uniqueid=\"%1\"" ); - result = m_storage->query( query.arg( m_storage->escape( uniqueURL ) ) ); - } - else - result = m_storage->query( query ); - - if( !result.isEmpty() ) - { - for ( int x = 0; x < result.count(); x++) - { - if ( !labels.contains( result.value(x) ) ) - labels.append( result.value(x) ); - } - } - - m_labels = labels; - emit labelsFetched( labels ); -} - - -void -SqlReadLabelCapability::fetchLabels() -{ - fetch( m_track->uidUrl() ); -} - -//TODO: This shouldn't be in a track capability -void -SqlReadLabelCapability::fetchGlobalLabels() -{ - fetch( QString() ); -} - -QStringList -SqlReadLabelCapability::labels() -{ - return m_labels; -} - -} - -#include "moc_SqlReadLabelCapability.cpp" diff --git a/amarok/src/core-impl/collections/db/sql/SqlReadLabelCapability.h b/amarok/src/core-impl/collections/db/sql/SqlReadLabelCapability.h deleted file mode 100644 index a0c72c5b..00000000 --- a/amarok/src/core-impl/collections/db/sql/SqlReadLabelCapability.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - Copyright (C) 2009 Dan Meltzer - - This program 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 2 of the License, or - (at your option) any later version. - - This program 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 this program. If not, see . - -*/ - -#ifndef SQLREADLABELCAPABILITY_H -#define SQLREADLABELCAPABILITY_H - -#include "core/capabilities/ReadLabelCapability.h" -#include "SqlMeta.h" - -class SqlStorage; - -namespace Capabilities -{ - -class SqlReadLabelCapability : public Capabilities::ReadLabelCapability -{ - Q_OBJECT - public: - SqlReadLabelCapability( Meta::SqlTrack *track, SqlStorage *storage ); - - /** - * fetches a list of labels assigned to this track - */ - virtual void fetchLabels(); - - /** - * fetches a list of all labels in the database - */ - virtual void fetchGlobalLabels(); //TODO: This shouldn't be in a Track capability - - /** - * @returns all labels assigned to this track - */ - virtual QStringList labels(); - - private: - QStringList m_labels; - Meta::TrackPtr m_track; - SqlStorage *m_storage; - void fetch( QString uniqueURL ); -}; - -} - -#endif // SQLREADLABELCAPABILITY_H diff --git a/amarok/src/core-impl/collections/db/sql/SqlRegistry.cpp b/amarok/src/core-impl/collections/db/sql/SqlRegistry.cpp deleted file mode 100644 index d0dea8a4..00000000 --- a/amarok/src/core-impl/collections/db/sql/SqlRegistry.cpp +++ /dev/null @@ -1,1004 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Maximilian Kossick * - * Copyright (c) 2010 Ralf Engels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "SqlRegistry" - -#include "SqlRegistry.h" - -#include "DatabaseUpdater.h" -#include "SqlRegistry_p.h" -#include "SqlCollection.h" -#include "core/support/Debug.h" -#include "core-impl/collections/db/MountPointManager.h" -#include "scanner/GenericScanManager.h" - -#include -#include - -SqlRegistry::SqlRegistry( Collections::SqlCollection* collection ) - : QObject( 0 ) - , m_collection( collection ) - , m_blockDatabaseUpdateCount( 0 ) - , m_collectionChanged( false ) -{ - DEBUG_BLOCK - setObjectName( "SqlRegistry" ); - - // -- remove unneeded entries from the database. - // we have to do this now before anyone can hold references - // to those objects. - DatabaseUpdater databaseUpdater( m_collection ); - - // url entries without associated directory just stick around and cannot be processed - // by SqlScanResultProcessor. Delete them before checking tracks - databaseUpdater.deleteOrphanedByDirectory( "urls" ); - - // tracks with no associated url entry are useless, just a bunch of medatada with - // nothing to associate them to; remove those first - databaseUpdater.deleteOrphanedByUrl( "tracks" ); - - databaseUpdater.deleteAllRedundant( "album" ); // what about cover images in database and disk cache? - databaseUpdater.deleteAllRedundant( "artist" ); - databaseUpdater.deleteAllRedundant( "genre" ); - databaseUpdater.deleteAllRedundant( "composer" ); - databaseUpdater.deleteAllRedundant( "url" ); - databaseUpdater.deleteAllRedundant( "year" ); - - databaseUpdater.deleteOrphanedByUrl( "lyrics" ); - databaseUpdater.deleteOrphanedByUrl( "statistics" ); - databaseUpdater.deleteOrphanedByUrl( "urls_labels" ); - - m_timer = new QTimer( this ); - m_timer->setInterval( 30 * 1000 ); //try to clean up every 30 seconds, change if necessary - m_timer->setSingleShot( false ); - connect( m_timer, SIGNAL(timeout()), this, SLOT(emptyCache()) ); - m_timer->start(); -} - -SqlRegistry::~SqlRegistry() -{ - //don't delete m_collection -} - -// ------ directory -int -SqlRegistry::getDirectory( const QString &path, uint mtime ) -{ - int dirId; - int deviceId = m_collection->mountPointManager()->getIdForUrl( path ); - QString rdir = m_collection->mountPointManager()->getRelativePath( deviceId, path ); - - SqlStorage *storage = m_collection->sqlStorage(); - - // - find existing entry - QString query = QString( "SELECT id, changedate FROM directories " - "WHERE deviceid = %1 AND dir = '%2';" ) - .arg( QString::number( deviceId ), storage->escape( rdir ) ); - QStringList res = storage->query( query ); - - // - create new entry - if( res.isEmpty() ) - { - debug() << "SqlRegistry::getDirectory(): new directory" << path; - QString insert = QString( "INSERT INTO directories(deviceid,changedate,dir) " - "VALUES (%1,%2,'%3');" ) - .arg( QString::number( deviceId ), QString::number( mtime ), - storage->escape( rdir ) ); - dirId = storage->insert( insert, "directories" ); - m_collectionChanged = true; - } - else - { - // update old one - dirId = res[0].toUInt(); - uint oldMtime = res[1].toUInt(); - if( oldMtime != mtime ) - { - QString update = QString( "UPDATE directories SET changedate = %1 " - "WHERE id = %2;" ) - .arg( QString::number( mtime ), res[0] ); - debug() << "SqlRegistry::getDirectory(): update directory" << path << "(id" << - res[0] << ") from" << oldMtime << "to" << mtime << "UNIX time"; - storage->query( update ); - } - } - return dirId; -} - -// ------ track - -Meta::TrackPtr -SqlRegistry::getTrack( int urlId ) -{ - QString query = "SELECT %1 FROM urls %2 " - "WHERE urls.id = %3"; - query = query.arg( Meta::SqlTrack::getTrackReturnValues(), - Meta::SqlTrack::getTrackJoinConditions(), - QString::number( urlId ) ); - QStringList rowData = m_collection->sqlStorage()->query( query ); - if( rowData.isEmpty() ) - return Meta::TrackPtr(); - - TrackPath id( rowData[Meta::SqlTrack::returnIndex_urlDeviceId].toInt(), - rowData[Meta::SqlTrack::returnIndex_urlRPath] ); - QString uid = rowData[Meta::SqlTrack::returnIndex_urlUid]; - - QMutexLocker locker( &m_trackMutex ); - if( m_trackMap.contains( id ) ) - { - Meta::SqlTrackPtr track = Meta::SqlTrackPtr::staticCast( m_trackMap[ id ] ); - // yes, it may happen that we get a different track in corner cases, see bug 323156 - if( track->urlId() == urlId ) - return Meta::TrackPtr::staticCast( track ); - warning() << Q_FUNC_INFO << "track with (deviceId, rpath)" << id << "found in" - << "m_trackMap, but it had different urlId (" << track->urlId() << ")" - << "than requested (" << urlId << "). This may happen in corner-cases."; - } - if( m_uidMap.contains( uid ) ) - { - Meta::SqlTrackPtr track = Meta::SqlTrackPtr::staticCast( m_uidMap[ uid ] ); - // yes, it may happen that we get a different track in corner cases, see bug 323156 - if( track->urlId() == urlId ) - return Meta::TrackPtr::staticCast( track ); - warning() << Q_FUNC_INFO << "track with uid" << uid << "found in m_uidMap, but it" - << "had different urlId (" << track->urlId() << ") than requested (" - << urlId << "). This may happen in corner-cases."; - } - - Meta::SqlTrack *sqlTrack = new Meta::SqlTrack( m_collection, rowData ); - Meta::TrackPtr trackPtr( sqlTrack ); - - m_trackMap.insert( id, trackPtr ); - m_uidMap.insert( sqlTrack->uidUrl(), trackPtr ); - return trackPtr; -} - -Meta::TrackPtr -SqlRegistry::getTrack( const QString &path ) -{ - int deviceId = m_collection->mountPointManager()->getIdForUrl( path ); - QString rpath = m_collection->mountPointManager()->getRelativePath( deviceId, path ); - TrackPath id( deviceId, rpath ); - - QMutexLocker locker( &m_trackMutex ); - if( m_trackMap.contains( id ) ) - return m_trackMap.value( id ); - else - { - QString query; - QStringList result; - - query = "SELECT %1 FROM urls %2 " - "WHERE urls.deviceid = %3 AND urls.rpath = '%4';"; - query = query.arg( Meta::SqlTrack::getTrackReturnValues(), - Meta::SqlTrack::getTrackJoinConditions(), - QString::number( deviceId ), - m_collection->sqlStorage()->escape( rpath ) ); - result = m_collection->sqlStorage()->query( query ); - if( result.isEmpty() ) - return Meta::TrackPtr(); - - Meta::SqlTrack *sqlTrack = new Meta::SqlTrack( m_collection, result ); - - Meta::TrackPtr trackPtr( sqlTrack ); - m_trackMap.insert( id, trackPtr ); - m_uidMap.insert( sqlTrack->uidUrl(), trackPtr ); - return trackPtr; - } -} - - -Meta::TrackPtr -SqlRegistry::getTrack( int deviceId, const QString &rpath, int directoryId, const QString &uidUrl ) -{ - TrackPath id( deviceId, rpath ); - - QMutexLocker locker( &m_trackMutex ); - if( m_trackMap.contains( id ) ) - return m_trackMap.value( id ); - else - { - QString query; - QStringList result; - Meta::SqlTrack *sqlTrack = 0; - - // -- get it from the database - query = "SELECT %1 FROM urls %2 " - "WHERE urls.deviceid = %3 AND urls.rpath = '%4';"; - query = query.arg( Meta::SqlTrack::getTrackReturnValues(), - Meta::SqlTrack::getTrackJoinConditions(), - QString::number( deviceId ), - m_collection->sqlStorage()->escape( rpath ) ); - result = m_collection->sqlStorage()->query( query ); - - if( !result.isEmpty() ) - sqlTrack = new Meta::SqlTrack( m_collection, result ); - - // -- we have to create a new track - if( !sqlTrack ) - sqlTrack = new Meta::SqlTrack( m_collection, deviceId, rpath, directoryId, uidUrl ); - - Meta::TrackPtr trackPtr( sqlTrack ); - m_trackMap.insert( id, trackPtr ); - m_uidMap.insert( sqlTrack->uidUrl(), trackPtr ); - return trackPtr; - } -} - -Meta::TrackPtr -SqlRegistry::getTrack( int trackId, const QStringList &rowData ) -{ - Q_ASSERT( trackId == rowData[Meta::SqlTrack::returnIndex_trackId].toInt() ); - Q_UNUSED( trackId ); - - TrackPath path( rowData[Meta::SqlTrack::returnIndex_urlDeviceId].toInt(), - rowData[Meta::SqlTrack::returnIndex_urlRPath] ); - QString uid = rowData[Meta::SqlTrack::returnIndex_urlUid]; - - QMutexLocker locker( &m_trackMutex ); - if( m_trackMap.contains( path ) ) - return m_trackMap.value( path ); - else if( m_uidMap.contains( uid ) ) - return m_uidMap.value( uid ); - else - { - Meta::SqlTrack *sqlTrack = new Meta::SqlTrack( m_collection, rowData ); - Meta::TrackPtr track( sqlTrack ); - - m_trackMap.insert( path, track ); - m_uidMap.insert( KSharedPtr::staticCast( track )->uidUrl(), track ); - return track; - } -} - -bool -SqlRegistry::updateCachedUrl( const QString &oldUrl, const QString &newUrl ) -{ - int deviceId = m_collection->mountPointManager()->getIdForUrl( oldUrl ); - QString rpath = m_collection->mountPointManager()->getRelativePath( deviceId, oldUrl ); - TrackPath oldId( deviceId, rpath ); - - int newdeviceId = m_collection->mountPointManager()->getIdForUrl( newUrl ); - QString newRpath = m_collection->mountPointManager()->getRelativePath( newdeviceId, newUrl ); - TrackPath newId( newdeviceId, newRpath ); - - QMutexLocker locker( &m_trackMutex ); - if( m_trackMap.contains( newId ) ) - warning() << "updating path to an already existing path."; - else if( !m_trackMap.contains( oldId ) ) - warning() << "updating path from a non existing path."; - else - { - Meta::TrackPtr track = m_trackMap.take( oldId ); - m_trackMap.insert( newId, track ); - return true; - } - return false; -} - -bool -SqlRegistry::updateCachedUid( const QString &oldUid, const QString &newUid ) -{ - QMutexLocker locker( &m_trackMutex ); - // TODO: improve uid handling - if( m_uidMap.contains( newUid ) ) - warning() << "updating uid to an already existing uid."; - else if( !oldUid.isEmpty() && !m_uidMap.contains( oldUid ) ) - warning() << "updating uid from a non existing uid."; - else - { - Meta::TrackPtr track = m_uidMap.take(oldUid); - m_uidMap.insert( newUid, track ); - return true; - } - return false; -} - -Meta::TrackPtr -SqlRegistry::getTrackFromUid( const QString &uid ) -{ - QMutexLocker locker( &m_trackMutex ); - if( m_uidMap.contains( uid ) ) - return m_uidMap.value( uid ); - { - QString query; - QStringList result; - - // -- get all the track info - query = "SELECT %1 FROM urls %2 " - "WHERE urls.uniqueid = '%3';"; - query = query.arg( Meta::SqlTrack::getTrackReturnValues(), - Meta::SqlTrack::getTrackJoinConditions(), - m_collection->sqlStorage()->escape( uid ) ); - result = m_collection->sqlStorage()->query( query ); - if( result.isEmpty() ) - return Meta::TrackPtr(); - - Meta::SqlTrack *sqlTrack = new Meta::SqlTrack( m_collection, result ); - Meta::TrackPtr trackPtr( sqlTrack ); - - int deviceid = m_collection->mountPointManager()->getIdForUrl( trackPtr->playableUrl().path() ); - QString rpath = m_collection->mountPointManager()->getRelativePath( deviceid, trackPtr->playableUrl().path() ); - TrackPath id(deviceid, rpath); - m_trackMap.insert( id, trackPtr ); - m_uidMap.insert( uid, trackPtr ); - return trackPtr; - } -} - -void -SqlRegistry::removeTrack( int urlId, const QString uid ) -{ - // delete all entries linked to the url, including track - QStringList tables = QStringList() << "tracks" << "lyrics" << "statistics" << "urls_labels"; - foreach( const QString &table, tables ) - { - QString query = QString( "DELETE FROM %1 WHERE url=%2" ).arg( table ).arg( urlId ); - m_collection->sqlStorage()->query( query ); - } - - // delete url entry from database; we used to keep it and keep its statistics, but - // DatabaseUpdater::deleteAllRedundant( url ) removes the url entry on the next Amarok - // startup, plus we don't know how long we should keep the entry, so just delete - // everything. ScanResultProcessor should be witty enough not to delete tracks that - // have been moved to another directory and/or device, even if it is currently - // unavailable. - QString query = QString( "DELETE FROM urls WHERE id=%1" ).arg( urlId ); - m_collection->sqlStorage()->query( query ); - - // --- delete the track from memory - QMutexLocker locker( &m_trackMutex ); - if( m_uidMap.contains( uid ) ) - { - // -- remove from hashes - Meta::TrackPtr track = m_uidMap.take( uid ); - Meta::SqlTrack *sqlTrack = static_cast( track.data() ); - - int deviceId = m_collection->mountPointManager()->getIdForUrl( sqlTrack->playableUrl().path() ); - QString rpath = m_collection->mountPointManager()->getRelativePath( deviceId, sqlTrack->playableUrl().path() ); - TrackPath id(deviceId, rpath); - m_trackMap.remove( id ); - } -} - -// -------- artist - -Meta::ArtistPtr -SqlRegistry::getArtist( const QString &oName ) -{ - QMutexLocker locker( &m_artistMutex ); - - QString name = oName.left( DatabaseUpdater::textColumnLength() ); - if( m_artistMap.contains( name ) ) - return m_artistMap.value( name ); - - int id; - - QString query = QString( "SELECT id FROM artists WHERE name = '%1';" ).arg( m_collection->sqlStorage()->escape( name ) ); - QStringList res = m_collection->sqlStorage()->query( query ); - if( res.isEmpty() ) - { - QString insert = QString( "INSERT INTO artists( name ) VALUES ('%1');" ).arg( m_collection->sqlStorage()->escape( name ) ); - id = m_collection->sqlStorage()->insert( insert, "artists" ); - m_collectionChanged = true; - } - else - { - id = res[0].toInt(); - } - - if( !id ) - return Meta::ArtistPtr(); - - Meta::ArtistPtr artist( new Meta::SqlArtist( m_collection, id, name ) ); - m_artistMap.insert( name, artist ); - m_artistIdMap.insert( id, artist ); - return artist; -} - -Meta::ArtistPtr -SqlRegistry::getArtist( int id ) -{ - QMutexLocker locker( &m_artistMutex ); - - if( m_artistIdMap.contains( id ) ) - return m_artistIdMap.value( id ); - - QString query = QString( "SELECT name FROM artists WHERE id = %1;" ).arg( id ); - QStringList res = m_collection->sqlStorage()->query( query ); - if( res.isEmpty() ) - return Meta::ArtistPtr(); - - QString name = res[0]; - Meta::ArtistPtr artist( new Meta::SqlArtist( m_collection, id, name ) ); - m_artistMap.insert( name, artist ); - m_artistIdMap.insert( id, artist ); - return artist; -} - -Meta::ArtistPtr -SqlRegistry::getArtist( int id, const QString &name ) -{ - Q_ASSERT( id > 0 ); // must be a valid id - QMutexLocker locker( &m_artistMutex ); - - if( m_artistMap.contains( name ) ) - return m_artistMap.value( name ); - - Meta::ArtistPtr artist( new Meta::SqlArtist( m_collection, id, name ) ); - m_artistMap.insert( name, artist ); - m_artistIdMap.insert( id, artist ); - return artist; -} - -// -------- genre - -Meta::GenrePtr -SqlRegistry::getGenre( const QString &oName ) -{ - QMutexLocker locker( &m_genreMutex ); - - QString name = oName.left( DatabaseUpdater::textColumnLength() ); - if( m_genreMap.contains( name ) ) - return m_genreMap.value( name ); - - int id; - - QString query = QString( "SELECT id FROM genres WHERE name = '%1';" ).arg( m_collection->sqlStorage()->escape( name ) ); - QStringList res = m_collection->sqlStorage()->query( query ); - if( res.isEmpty() ) - { - QString insert = QString( "INSERT INTO genres( name ) VALUES ('%1');" ).arg( m_collection->sqlStorage()->escape( name ) ); - id = m_collection->sqlStorage()->insert( insert, "genres" ); - m_collectionChanged = true; - } - else - { - id = res[0].toInt(); - } - - if( !id ) - return Meta::GenrePtr(); - - Meta::GenrePtr genre( new Meta::SqlGenre( m_collection, id, name ) ); - m_genreMap.insert( name, genre ); - return genre; -} - -Meta::GenrePtr -SqlRegistry::getGenre( int id ) -{ - QMutexLocker locker( &m_genreMutex ); - - QString query = QString( "SELECT name FROM genres WHERE id = '%1';" ).arg( id ); - QStringList res = m_collection->sqlStorage()->query( query ); - if( res.isEmpty() ) - return Meta::GenrePtr(); - - QString name = res[0]; - Meta::GenrePtr genre( new Meta::SqlGenre( m_collection, id, name ) ); - m_genreMap.insert( name, genre ); - return genre; -} - -Meta::GenrePtr -SqlRegistry::getGenre( int id, const QString &name ) -{ - Q_ASSERT( id > 0 ); // must be a valid id - QMutexLocker locker( &m_genreMutex ); - - if( m_genreMap.contains( name ) ) - return m_genreMap.value( name ); - - Meta::GenrePtr genre( new Meta::SqlGenre( m_collection, id, name ) ); - m_genreMap.insert( name, genre ); - return genre; -} - -// -------- composer - -Meta::ComposerPtr -SqlRegistry::getComposer( const QString &oName ) -{ - QMutexLocker locker( &m_composerMutex ); - - QString name = oName.left( DatabaseUpdater::textColumnLength() ); - if( m_composerMap.contains( name ) ) - return m_composerMap.value( name ); - - int id; - - QString query = QString( "SELECT id FROM composers WHERE name = '%1';" ).arg( m_collection->sqlStorage()->escape( name ) ); - QStringList res = m_collection->sqlStorage()->query( query ); - if( res.isEmpty() ) - { - QString insert = QString( "INSERT INTO composers( name ) VALUES ('%1');" ).arg( m_collection->sqlStorage()->escape( name ) ); - id = m_collection->sqlStorage()->insert( insert, "composers" ); - m_collectionChanged = true; - } - else - { - id = res[0].toInt(); - } - - if( !id ) - return Meta::ComposerPtr(); - - Meta::ComposerPtr composer( new Meta::SqlComposer( m_collection, id, name ) ); - m_composerMap.insert( name, composer ); - return composer; -} - -Meta::ComposerPtr -SqlRegistry::getComposer( int id ) -{ - if( id <= 0 ) - return Meta::ComposerPtr(); - - QMutexLocker locker( &m_composerMutex ); - - QString query = QString( "SELECT name FROM composers WHERE id = '%1';" ).arg( id ); - QStringList res = m_collection->sqlStorage()->query( query ); - if( res.isEmpty() ) - return Meta::ComposerPtr(); - - QString name = res[0]; - Meta::ComposerPtr composer( new Meta::SqlComposer( m_collection, id, name ) ); - m_composerMap.insert( name, composer ); - return composer; -} - -Meta::ComposerPtr -SqlRegistry::getComposer( int id, const QString &name ) -{ - Q_ASSERT( id > 0 ); // must be a valid id - QMutexLocker locker( &m_composerMutex ); - - if( m_composerMap.contains( name ) ) - return m_composerMap.value( name ); - - Meta::ComposerPtr composer( new Meta::SqlComposer( m_collection, id, name ) ); - m_composerMap.insert( name, composer ); - return composer; -} - -// -------- year - -Meta::YearPtr -SqlRegistry::getYear( int year, int yearId ) -{ - QMutexLocker locker( &m_yearMutex ); - - if( m_yearMap.contains( year ) ) - return m_yearMap.value( year ); - - // don't know the id yet - if( yearId <= 0 ) - { - QString query = QString( "SELECT id FROM years WHERE name = '%1';" ).arg( QString::number( year ) ); - QStringList res = m_collection->sqlStorage()->query( query ); - if( res.isEmpty() ) - { - QString insert = QString( "INSERT INTO years( name ) VALUES ('%1');" ).arg( QString::number( year ) ); - yearId = m_collection->sqlStorage()->insert( insert, "years" ); - m_collectionChanged = true; - } - else - { - yearId = res[0].toInt(); - } - } - - if( !yearId ) - return Meta::YearPtr(); - - Meta::YearPtr yearPtr( new Meta::SqlYear( m_collection, yearId, year ) ); - m_yearMap.insert( year, yearPtr ); - return yearPtr; -} - -// -------- album - -Meta::AlbumPtr -SqlRegistry::getAlbum( const QString &oName, const QString &oArtist ) -{ - // we allow albums with empty name but nonempty artist, see bug 272471 - QString name = oName.left( DatabaseUpdater::textColumnLength() ); - QString albumArtist = oArtist.left( DatabaseUpdater::textColumnLength() ); - AlbumKey key( name, albumArtist ); - - QMutexLocker locker( &m_albumMutex ); - if( m_albumMap.contains( key ) ) - return m_albumMap.value( key ); - - int albumId = -1; - int artistId = -1; - - QString query = QString( "SELECT id FROM albums WHERE name = '%1' AND " ).arg( m_collection->sqlStorage()->escape( name ) ); - - if( albumArtist.isEmpty() ) - { - query += QString( "artist IS NULL" ); - } - else - { - Meta::ArtistPtr artistPtr = getArtist( albumArtist ); - if( !artistPtr ) - return Meta::AlbumPtr(); - Meta::SqlArtist *sqlArtist = static_cast(artistPtr.data()); - artistId = sqlArtist->id(); - - query += QString( "artist=%1" ).arg( artistId ); - } - - QStringList res = m_collection->sqlStorage()->query( query ); - if( res.isEmpty() ) - { - // ok. have to create a new album - QString insert = QString( "INSERT INTO albums( name, artist ) VALUES ('%1',%2);" ). - arg( m_collection->sqlStorage()->escape( name ), - artistId > 0 ? QString::number( artistId ) : "NULL" ); - albumId = m_collection->sqlStorage()->insert( insert, "albums" ); - m_collectionChanged = true; // we just added a new album - } - else - { - albumId = res[0].toInt(); - } - - if( !albumId ) - return Meta::AlbumPtr(); - - Meta::SqlAlbum *sqlAlbum = new Meta::SqlAlbum( m_collection, albumId, name, artistId ); - Meta::AlbumPtr album( sqlAlbum ); - m_albumMap.insert( key, album ); - m_albumIdMap.insert( albumId, album ); - locker.unlock(); // prevent deadlock - return album; -} - -Meta::AlbumPtr -SqlRegistry::getAlbum( int albumId ) -{ - Q_ASSERT( albumId > 0 ); // must be a valid id - - { - // we want locker only for this block because we call another getAlbum() below - QMutexLocker locker( &m_albumMutex ); - if( m_albumIdMap.contains( albumId ) ) - return m_albumIdMap.value( albumId ); - } - - QString query = QString( "SELECT name, artist FROM albums WHERE id = %1" ).arg( albumId ); - QStringList res = m_collection->sqlStorage()->query( query ); - if( res.isEmpty() ) - return Meta::AlbumPtr(); // someone messed up - - QString name = res[0]; - int artistId = res[1].toInt(); - return getAlbum( albumId, name, artistId ); -} - -Meta::AlbumPtr -SqlRegistry::getAlbum( int albumId, const QString &name, int artistId ) -{ - Q_ASSERT( albumId > 0 ); // must be a valid id - - QMutexLocker locker( &m_albumMutex ); - if( m_albumIdMap.contains( albumId ) ) - return m_albumIdMap.value( albumId ); - - Meta::ArtistPtr artist = getArtist( artistId ); - AlbumKey key(name, artist ? artist->name() : QString() ); - if( m_albumMap.contains( key ) ) - return m_albumMap.value( key ); - - Meta::SqlAlbum *sqlAlbum = new Meta::SqlAlbum( m_collection, albumId, name, artistId ); - Meta::AlbumPtr album( sqlAlbum ); - m_albumMap.insert( key, album ); - m_albumIdMap.insert( albumId, album ); - return album; -} - -// ------------ label - -Meta::LabelPtr -SqlRegistry::getLabel( const QString &oLabel ) -{ - QMutexLocker locker( &m_labelMutex ); - QString label = oLabel.left( DatabaseUpdater::textColumnLength() ); - if( m_labelMap.contains( label ) ) - return m_labelMap.value( label ); - - int id; - - QString query = QString( "SELECT id FROM labels WHERE label = '%1';" ).arg( m_collection->sqlStorage()->escape( label ) ); - QStringList res = m_collection->sqlStorage()->query( query ); - if( res.isEmpty() ) - { - QString insert = QString( "INSERT INTO labels( label ) VALUES ('%1');" ).arg( m_collection->sqlStorage()->escape( label ) ); - id = m_collection->sqlStorage()->insert( insert, "albums" ); - } - else - { - id = res[0].toInt(); - } - - if( !id ) - return Meta::LabelPtr(); - - Meta::LabelPtr labelPtr( new Meta::SqlLabel( m_collection, id, label ) ); - m_labelMap.insert( label, labelPtr ); - return labelPtr; -} - -Meta::LabelPtr -SqlRegistry::getLabel( int id ) -{ - Q_ASSERT( id > 0 ); // must be a valid id - QMutexLocker locker( &m_labelMutex ); - - QString query = QString( "SELECT label FROM labels WHERE id = '%1';" ).arg( id ); - QStringList res = m_collection->sqlStorage()->query( query ); - if( res.isEmpty() ) - return Meta::LabelPtr(); - - QString label = res[0]; - Meta::LabelPtr labelPtr( new Meta::SqlLabel( m_collection, id, label ) ); - m_labelMap.insert( label, labelPtr ); - return labelPtr; -} - -Meta::LabelPtr -SqlRegistry::getLabel( int id, const QString &label ) -{ - Q_ASSERT( id > 0 ); // must be a valid id - QMutexLocker locker( &m_labelMutex ); - - if( m_labelMap.contains( label ) ) - return m_labelMap.value( label ); - - Meta::LabelPtr labelPtr( new Meta::SqlLabel( m_collection, id, label ) ); - m_labelMap.insert( label, labelPtr ); - return labelPtr; -} - - - -// ---------------- generic database management -------------- - -void -SqlRegistry::blockDatabaseUpdate() -{ - QMutexLocker locker( &m_blockMutex ); - m_blockDatabaseUpdateCount++; -} - -void -SqlRegistry::unblockDatabaseUpdate() -{ - { - QMutexLocker locker( &m_blockMutex ); - Q_ASSERT( m_blockDatabaseUpdateCount > 0 ); - m_blockDatabaseUpdateCount--; - } - - // update the database - commitDirtyTracks(); -} - -void -SqlRegistry::commitDirtyTracks() -{ - QMutexLocker locker( &m_blockMutex ); - - if( m_blockDatabaseUpdateCount > 0 ) - return; - - QList< Meta::SqlYearPtr > dirtyYears = m_dirtyYears.toList(); - QList< Meta::SqlGenrePtr > dirtyGenres = m_dirtyGenres.toList(); - QList< Meta::SqlAlbumPtr > dirtyAlbums = m_dirtyAlbums.toList(); - QList< Meta::SqlTrackPtr > dirtyTracks = m_dirtyTracks.toList(); - QList< Meta::SqlArtistPtr > dirtyArtists = m_dirtyArtists.toList(); - QList< Meta::SqlComposerPtr > dirtyComposers = m_dirtyComposers.toList(); - - m_dirtyYears.clear(); - m_dirtyGenres.clear(); - m_dirtyAlbums.clear(); - m_dirtyTracks.clear(); - m_dirtyArtists.clear(); - m_dirtyComposers.clear(); - locker.unlock(); // need to unlock before notifying the observers - - // -- commit all the dirty tracks - TrackUrlsTableCommitter().commit( dirtyTracks ); - TrackTracksTableCommitter().commit( dirtyTracks ); - TrackStatisticsTableCommitter().commit( dirtyTracks ); - - // -- notify all observers - foreach( Meta::SqlYearPtr year, dirtyYears ) - { - // this means that a new year was added to track or an old removed (or both), - // Collection docs says we need to emit updated() in this case. Ditto below. - m_collectionChanged = true; - year->invalidateCache(); - year->notifyObservers(); - } - foreach( Meta::SqlGenrePtr genre, dirtyGenres ) - { - m_collectionChanged = true; - genre->invalidateCache(); - genre->notifyObservers(); - } - foreach( Meta::SqlAlbumPtr album, dirtyAlbums ) - { - m_collectionChanged = true; - album->invalidateCache(); - album->notifyObservers(); - } - foreach( Meta::SqlTrackPtr track, dirtyTracks ) - { - // if only track changes, no need to emit updated() from here - track->notifyObservers(); - } - foreach( Meta::SqlArtistPtr artist, dirtyArtists ) - { - m_collectionChanged = true; - artist->invalidateCache(); - artist->notifyObservers(); - } - foreach( Meta::SqlComposerPtr composer, dirtyComposers ) - { - m_collectionChanged = true; - composer->invalidateCache(); - composer->notifyObservers(); - } - if( m_collectionChanged ) - m_collection->collectionUpdated(); - m_collectionChanged = false; -} - - - -void -SqlRegistry::emptyCache() -{ - if( m_collection->scanManager() && m_collection->scanManager()->isRunning() ) - return; // don't clean the cache if a scan is done - - bool hasTrack, hasAlbum, hasArtist, hasYear, hasGenre, hasComposer, hasLabel; - hasTrack = hasAlbum = hasArtist = hasYear = hasGenre = hasComposer = hasLabel = false; - - //try to avoid possible deadlocks by aborting when we can't get all locks - if ( ( hasTrack = m_trackMutex.tryLock() ) - && ( hasAlbum = m_albumMutex.tryLock() ) - && ( hasArtist = m_artistMutex.tryLock() ) - && ( hasYear = m_yearMutex.tryLock() ) - && ( hasGenre = m_genreMutex.tryLock() ) - && ( hasComposer = m_composerMutex.tryLock() ) - && ( hasLabel = m_labelMutex.tryLock() ) ) - { - #define mapCached( Cache, Key, Map, Res ) \ - Cache[Key] = qMakePair( Map.count(), Res.join(QLatin1String(" ")).toInt() ); - - QMap > cachedBefore; - - QString query = QString( "SELECT COUNT(*) FROM albums;" ); - QStringList res = m_collection->sqlStorage()->query( query ); - mapCached( cachedBefore, "albums", m_albumMap, res ); - - query = QString( "SELECT COUNT(*) FROM tracks;" ); - res = m_collection->sqlStorage()->query( query ); - mapCached( cachedBefore, "tracks", m_trackMap, res ); - - query = QString( "SELECT COUNT(*) FROM artists;" ); - res = m_collection->sqlStorage()->query( query ); - mapCached( cachedBefore, "artists", m_artistMap, res ); - - query = QString( "SELECT COUNT(*) FROM genres;" ); - res = m_collection->sqlStorage()->query( query ); - mapCached( cachedBefore, "genres", m_genreMap, res ); - - //this very simple garbage collector doesn't handle cyclic object graphs - //so care has to be taken to make sure that we are not dealing with a cyclic graph - //by invalidating the tracks cache on all objects - #define foreachInvalidateCache( Key, Type, RealType, x ) \ - for( QMutableHashIterator iter(x); iter.hasNext(); ) \ - RealType::staticCast( iter.next().value() )->invalidateCache() - - foreachInvalidateCache( AlbumKey, Meta::AlbumPtr, KSharedPtr, m_albumMap ); - foreachInvalidateCache( QString, Meta::ArtistPtr, KSharedPtr, m_artistMap ); - foreachInvalidateCache( QString, Meta::GenrePtr, KSharedPtr, m_genreMap ); - foreachInvalidateCache( QString, Meta::ComposerPtr, KSharedPtr, m_composerMap ); - foreachInvalidateCache( int, Meta::YearPtr, KSharedPtr, m_yearMap ); - foreachInvalidateCache( QString, Meta::LabelPtr, KSharedPtr, m_labelMap ); - #undef foreachInvalidateCache - - // elem.count() == 2 is correct because elem is one pointer to the object - // and the other is stored in the hash map (except for m_trackMap, m_albumMap - // and m_artistMap , where another refence is stored in m_uidMap, m_albumIdMap - // and m_artistIdMap - #define foreachCollectGarbage( Key, Type, RefCount, x ) \ - for( QMutableHashIterator iter(x); iter.hasNext(); ) \ - { \ - Type elem = iter.next().value(); \ - if( elem.count() == RefCount ) \ - iter.remove(); \ - } - - foreachCollectGarbage( TrackPath, Meta::TrackPtr, 3, m_trackMap ); - foreachCollectGarbage( QString, Meta::TrackPtr, 2, m_uidMap ); - // run before artist so that album artist pointers can be garbage collected - foreachCollectGarbage( AlbumKey, Meta::AlbumPtr, 3, m_albumMap ); - foreachCollectGarbage( int, Meta::AlbumPtr, 2, m_albumIdMap ); - foreachCollectGarbage( QString, Meta::ArtistPtr, 3, m_artistMap ); - foreachCollectGarbage( int, Meta::ArtistPtr, 2, m_artistIdMap ); - foreachCollectGarbage( QString, Meta::GenrePtr, 2, m_genreMap ); - foreachCollectGarbage( QString, Meta::ComposerPtr, 2, m_composerMap ); - foreachCollectGarbage( int, Meta::YearPtr, 2, m_yearMap ); - foreachCollectGarbage( QString, Meta::LabelPtr, 2, m_labelMap ); - #undef foreachCollectGarbage - - QMap > cachedAfter; - - query = QString( "SELECT COUNT(*) FROM albums;" ); - res = m_collection->sqlStorage()->query( query ); - mapCached( cachedAfter, "albums", m_albumMap, res ); - - query = QString( "SELECT COUNT(*) FROM tracks;" ); - res = m_collection->sqlStorage()->query( query ); - mapCached( cachedAfter, "tracks", m_trackMap, res ); - - query = QString( "SELECT COUNT(*) FROM artists;" ); - res = m_collection->sqlStorage()->query( query ); - mapCached( cachedAfter, "artists", m_artistMap, res ); - - query = QString( "SELECT COUNT(*) FROM genres;" ); - res = m_collection->sqlStorage()->query( query ); - mapCached( cachedAfter, "genres", m_genreMap, res ); - #undef mapCached - - if( cachedBefore != cachedAfter ) - { - QMapIterator > i(cachedAfter), iLast(cachedBefore); - while( i.hasNext() && iLast.hasNext() ) - { - i.next(); - iLast.next(); - int count = i.value().first; - int total = i.value().second; - QString diff = QString::number( count - iLast.value().first ); - QString text = QString( "%1 (%2) of %3 cached" ).arg( count ).arg( diff ).arg( total ); - debug() << QString( "%1: %2" ).arg( i.key(), 8 ).arg( text ).toLocal8Bit().constData(); - } - } - } - - //make sure to unlock all necessary locks - //important: calling unlock() on an unlocked mutex gives an undefined result - //unlocking a mutex locked by another thread results in an error, so be careful - if( hasTrack ) m_trackMutex.unlock(); - if( hasAlbum ) m_albumMutex.unlock(); - if( hasArtist ) m_artistMutex.unlock(); - if( hasYear ) m_yearMutex.unlock(); - if( hasGenre ) m_genreMutex.unlock(); - if( hasComposer ) m_composerMutex.unlock(); - if( hasLabel ) m_labelMutex.unlock(); -} - -#include "moc_SqlRegistry.cpp" - diff --git a/amarok/src/core-impl/collections/db/sql/SqlRegistry.h b/amarok/src/core-impl/collections/db/sql/SqlRegistry.h deleted file mode 100644 index e95eac41..00000000 --- a/amarok/src/core-impl/collections/db/sql/SqlRegistry.h +++ /dev/null @@ -1,247 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef SQLREGISTRY_H -#define SQLREGISTRY_H - -#include "SqlMeta.h" -#include "amarok_sqlcollection_export.h" - -#include -#include -#include -#include -#include -#include - -class SqlStorage; - -class TestScanResultProcessorFull; -class TestSqlAlbum; -class TestSqlArtist; -class TestSqlTrack; -class TestSqlCollectionLocation; - -namespace Collections { - class SqlCollection; - class SqlQueryMakerInternal; -} -typedef QPair TrackPath; - -/** The SqlRegistry class buffers Meta objects from an Sql database. - This class can be considered a memory cache for the Sql database. - All requests for Meta objects like SqlTrack should go through here. - - Some notes regarding performance: - Scanning of nearly 10000 tracks on my lokal disk takes over 2 minutes. - The second time it only a little over 4 seconds. However I would not see the - second scan as a valid usecase. - Putting 10000 tracks from memory directly into the database with - single inserts takes around 12 seconds. - This time however increases dramatically with the amount of tracks. - 50000 tracks take around 15 minutes. - The reason is the many indices that need to be updated. The tracks - table e.g. has around 15 indices. - - To increase the performance we are currently using two tricks. - 1. Prevent queries. - The SqlScanResultProcessor will query all tracks in the database. - The SqlRegistry is caching them as usually but while the scanner - is running it will not clean the cache. - The SqlScanResultProcessor will also cache all urls entries. - - 2. Combine inserts and updates. - All dirty tracks will be written in one big insert or with delayed - updates. - The ScanResultProcessor will block database access for five - seconds at a time to collect dirty tracks for such a batch update. - Have a look at the AbstractTrackTableCommitter to see how this - is done. - - Note: updating tracks is not optimized for single changes. - A single update is only done very seldom and does currently not - need to be optimized. -*/ -class AMAROK_SQLCOLLECTION_EXPORT SqlRegistry : public QObject -{ - Q_OBJECT - - public: - SqlRegistry(Collections::SqlCollection *collection); - virtual ~SqlRegistry(); - - /** Searches a directory entry in the scanned directories - This function searches an existing directory entry. - @param mtime if mtime is != 0 then the mtime of the entry is updated - @returns the directory id - */ - int getDirectory( const QString &path, uint mtime = 0 ); - - Meta::TrackPtr getTrack( int urlId ); - Meta::TrackPtr getTrack( const QString &path ); - - /** Returns the track located at the given url or a new one if not existing. - This is kind of dangerous because it can generate a new track in - the database without a file on the filesystem, so don't call it unless - you really want tracks to be generate. - The new track must be committed by writing - some other meta information. - Use SqlCollection::trackForUrl instead. - */ - Meta::TrackPtr getTrack( int deviceId, const QString &rpath, int directoryId, const QString &uidUrl ); - - /** Returns a track from a specific uid. - Returns a complete track or 0. - */ - Meta::TrackPtr getTrackFromUid( const QString &uid ); - - Meta::ArtistPtr getArtist( const QString &name ); - Meta::ArtistPtr getArtist( int id ); - - Meta::GenrePtr getGenre( const QString &name ); - Meta::GenrePtr getGenre( int id ); - - Meta::ComposerPtr getComposer( const QString &name ); - Meta::ComposerPtr getComposer( int id ); - - Meta::YearPtr getYear( int year, int yearId = -1 ); - - Meta::AlbumPtr getAlbum( const QString &album, const QString &artist ); - Meta::AlbumPtr getAlbum( int id ); - - Meta::LabelPtr getLabel( const QString &label ); - Meta::LabelPtr getLabel( int id ); - - /** Call this function to collect changes for the sql database. - This function can be called in preparation of larger updates. - */ - void blockDatabaseUpdate(); - - /** Unblocks one blockDatabaseUpdate call. */ - void unblockDatabaseUpdate(); - - private slots: - /** empytCache clears up the different hash tables by unrefing all pointers that are no longer ref'd by anyone else. - SqlRegistry is calling this function periodically. - This is no free ticket for modifying the database directly as - parties holding Meta pointers will still have the old status. - */ - void emptyCache(); - - private: - typedef QPair AlbumKey; - - // only SqlTrack can change this - /** Updates the uid of an already cached track. - @return true if the update was successful. - */ - bool updateCachedUrl( const QString &oldUrl, const QString &newUrl ); - - /** Updates the uid of an already cached track. - @return true if the update was successful. - */ - bool updateCachedUid( const QString &oldUid, const QString &newUid ); - - /** - * Removes the track and associated entries (url, statistics, lyrics, labels) - * from the database and the cache (but not from the file system). This function - * is normally called by SqlTrack. Do not call directly unless you know what you - * do. - */ - void removeTrack( int urlId, const QString uid ); - - // --- functions needed to commit a track - - /** Returns a string with all the values needed to be committed to the urls table */ - QString getTrackUrlsValues( Meta::SqlTrack *track ); - - /** Returns a string with all the values needed to be committed to the tracks table */ - QString getTrackTracksValues( Meta::SqlTrack *track ); - - /** Returns a string with all the values needed to be committed to the statistics table */ - QString getTrackStatisticsValues( Meta::SqlTrack *track ); - - void commitDirtyTracks(); - - - - friend class Meta::SqlTrack; - - // only the query maker creates Metas like this - Meta::TrackPtr getTrack( int id, const QStringList &rowData ); - Meta::ArtistPtr getArtist( int id, const QString &name ); - Meta::GenrePtr getGenre( int id, const QString &name ); - Meta::ComposerPtr getComposer( int id, const QString &name ); - Meta::AlbumPtr getAlbum( int id, const QString &album, int artistId ); - Meta::LabelPtr getLabel( int id, const QString &label ); - - friend class Collections::SqlQueryMakerInternal; - - // we don't care about the ordering so use the faster QHash - QHash m_trackMap; - QHash m_uidMap; - QHash m_artistMap; - QHash m_artistIdMap; - QHash m_composerMap; - QHash m_genreMap; - QHash m_yearMap; - QHash m_albumMap; - QHash m_albumIdMap; - QHash m_labelMap; - - QMutex m_trackMutex; // guards access to m_trackMap, m_uidMap - QMutex m_artistMutex; // guards access to m_artistMap, m_artistIdMap - QMutex m_composerMutex; // guards access to m_composerMap - QMutex m_genreMutex; // guards access to m_genreMap - QMutex m_yearMutex; // guards access to m_yearMap - QMutex m_albumMutex; // guards access to m_albumMap, m_albumIdMap - QMutex m_labelMutex; // guards access to m_labelMap - - /** The timer is used for cleaning up the different caches. */ - QTimer *m_timer; - - Collections::SqlCollection *m_collection; - - QMutex m_blockMutex; // protects the count and all the dirty sets. - int m_blockDatabaseUpdateCount; - - /** A set of all tracks that need to be written to the database */ - QSet< Meta::SqlTrackPtr > m_dirtyTracks; - - /** A set of all tracks that are dirty. - Dirty years do not need to be written back as they are - invariant. However we need to notice the observers and - invalidate the cache. */ - QSet< Meta::SqlYearPtr > m_dirtyYears; - QSet< Meta::SqlGenrePtr > m_dirtyGenres; - QSet< Meta::SqlAlbumPtr > m_dirtyAlbums; - QSet< Meta::SqlArtistPtr > m_dirtyArtists; - QSet< Meta::SqlComposerPtr > m_dirtyComposers; - - /** Set to true when something was added or removed form the database */ - bool m_collectionChanged; - - friend class SqlScanResultProcessor; - - // all those classes need to call emptyCache - friend class TestSqlScanManager; - friend class TestSqlAlbum; - friend class TestSqlArtist; - friend class TestSqlTrack; - friend class TestSqlCollectionLocation; -}; - -#endif /* SQLREGISTRY_H */ diff --git a/amarok/src/core-impl/collections/db/sql/SqlRegistry_p.cpp b/amarok/src/core-impl/collections/db/sql/SqlRegistry_p.cpp deleted file mode 100644 index b7cba3a2..00000000 --- a/amarok/src/core-impl/collections/db/sql/SqlRegistry_p.cpp +++ /dev/null @@ -1,347 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Ralf Engels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "SqlRegistryP" -#include "core/support/Debug.h" - -#include "SqlRegistry_p.h" -#include "SqlMeta.h" -#include "SqlCollection.h" - -void -AbstractTrackTableCommitter::commit( const QList &tracks ) -{ - // Note: The code is greatly inspired by the old ScanResultProcessor - // by jeffrai - - // Note2: The code is optimized for batch update. - // Reason: a single update is completely harmless and not frequent. - // The real difficulty is the collection scanner and it's runtime - // Especially with collections larger than 30000 tracks. - - if( tracks.isEmpty() ) - return; - - m_storage = tracks.first()->sqlCollection()->sqlStorage(); - - // -- get the maximum size for our commit - static int maxSize = 0; - if( maxSize == 0 ) - { - QStringList res = m_storage->query( "SHOW VARIABLES LIKE 'max_allowed_packet';" ); - if( res.size() < 2 || res[1].toInt() == 0 ) - { - warning() << "Uh oh! For some reason MySQL thinks there isn't a max allowed size!"; - return; - } - debug() << "obtained max_allowed_packet is " << res[1]; - maxSize = res[1].toInt() / 3; //for safety, due to multibyte encoding - } - - - QStringList fields = getFields(); - - const QString updateQueryStart = "UPDATE LOW_PRIORITY "+tableName()+" SET "; - const QString insertQueryStart = "INSERT INTO "+tableName()+ - " ("+fields.join(",")+") VALUES "; - - QList< Meta::SqlTrackPtr > insertedTracks; - QString insertQuery; - insertQuery.reserve( 1024 ); // a sensible initial size - - foreach( Meta::SqlTrackPtr track, tracks ) - { - QStringList values = getValues( track.data() ); - - // -- update - if( getId( track.data() ) > 0 ) - { - // we just commit all values to save code complexity. - // we would need to track the real changed fields otherwise - QString updateQuery; - updateQuery.reserve( 256 ); // a sensible initial size - for( int i = 0; i < fields.count() && i < values.count(); i++ ) - { - if( !updateQuery.isEmpty() ) - updateQuery += ", "; - updateQuery += fields.at( i ); - updateQuery += '='; - updateQuery += values.at( i ); - } - updateQuery = updateQueryStart + updateQuery + - " WHERE id=" + QString::number( getId( track.data() ) ) + ';'; - m_storage->query( updateQuery ); - - } - else - // -- insert - { - QString newValues = '(' + values.join(",") + ')'; - - // - if the insertQuery is long enough, commit it. - if( insertQueryStart.length() + insertQuery.length() + newValues.length() + 1 >= maxSize - 3 ) // ";" - { - // commit - insertQuery = insertQueryStart + insertQuery + ';'; - int firstId = m_storage->insert( insertQuery, tableName() ); - - // set the resulting ids - if( firstId <= 0 ) - warning() << "Insert failed."; - for( int i = 0; i < insertedTracks.count(); i++ ) - setId( const_cast(insertedTracks.at( i ).data()), - firstId + i ); - - insertQuery.clear(); - insertedTracks.clear(); - } - - if( !insertQuery.isEmpty() ) - insertQuery += ','; - insertQuery += newValues; - insertedTracks.append( track ); - } - } - - // - insert the rest - if( !insertQuery.isEmpty() ) - { - // commit - insertQuery = insertQueryStart + insertQuery + ';'; - int firstId = m_storage->insert( insertQuery, tableName() ); - - // set the resulting ids - if( firstId <= 0 ) - warning() << "Insert failed."; - for( int i = 0; i < insertedTracks.count(); i++ ) - setId( const_cast(insertedTracks.at( i ).data()), - firstId + i ); - - insertQuery.clear(); - insertedTracks.clear(); - } -} - - -// --- some help functions for the query -QString -AbstractTrackTableCommitter::nullString( const QString &str ) const -{ - if( str.isEmpty() ) - return "NULL"; - else - return str; -} - -QString -AbstractTrackTableCommitter::nullNumber( const qint64 number ) const -{ - if( number <= 0 ) - return "NULL"; - else - return QString::number( number ); -} - -QString -AbstractTrackTableCommitter::nullNumber( const int number ) const -{ - if( number <= 0 ) - return "NULL"; - else - return QString::number( number ); -} - -QString -AbstractTrackTableCommitter::nullNumber( const double number ) const -{ - if( number <= 0 ) - return "NULL"; - else - return QString::number( number ); -} - -QString -AbstractTrackTableCommitter::nullDate( const QDateTime &date ) const -{ - if( date.isValid() ) - return QString::number( date.toTime_t() ); - else - return "NULL"; -} - - -QString -AbstractTrackTableCommitter::escape( const QString &str ) const -{ - return '\'' + m_storage->escape( str ) + '\''; -} - - -// ------------ urls --------------- - -QString -TrackUrlsTableCommitter::tableName() -{ - return "urls"; -} - -int -TrackUrlsTableCommitter::getId( Meta::SqlTrack *track ) -{ - return track->m_urlId; -} - -void -TrackUrlsTableCommitter::setId( Meta::SqlTrack *track, int id ) -{ - track->m_urlId = id; -} - -QStringList -TrackUrlsTableCommitter::getFields() -{ - QStringList result; - result << "deviceid" << "rpath" << "directory" << "uniqueid"; - return result; -} - -QStringList -TrackUrlsTableCommitter::getValues( Meta::SqlTrack *track ) -{ - QStringList result; - Q_ASSERT( track->m_deviceId != 0 && "refusing to write zero deviceId to urls table, please file a bug" ); - result << QString::number( track->m_deviceId ); - result << escape( track->m_rpath ); - Q_ASSERT( track->m_directoryId > 0 && "refusing to write non-positive directoryId to urls table, please file a bug" ); - result << nullNumber( track->m_directoryId ); - result << escape( track->m_uid ); - return result; -} - - -// ------------ tracks --------------- - -QString -TrackTracksTableCommitter::tableName() -{ - return "tracks"; -} - -int -TrackTracksTableCommitter::getId( Meta::SqlTrack *track ) -{ - return track->m_trackId; -} - -void -TrackTracksTableCommitter::setId( Meta::SqlTrack *track, int id ) -{ - track->m_trackId = id; -} - -QStringList -TrackTracksTableCommitter::getFields() -{ - QStringList result; - result << "url" << "artist" << "album" << "genre" << "composer" << "year" << - "title" << "comment" << "tracknumber" << "discnumber" << "bitrate" << - "length" << "samplerate" << "filesize" << "filetype" << "bpm" << "createdate" << - "modifydate" << "albumgain" << "albumpeakgain" << "trackgain" << "trackpeakgain"; - return result; -} - -QStringList -TrackTracksTableCommitter::getValues( Meta::SqlTrack *track ) -{ - QStringList result; - Q_ASSERT( track->m_urlId > 0 && "refusing to write non-positive urlId to tracks table, please file a bug" ); - result << QString::number( track->m_urlId ); - result << QString::number( track->m_artist ? - KSharedPtr::staticCast( track->m_artist )->id() : - -1 ); - result << QString::number( track->m_album ? - KSharedPtr::staticCast( track->m_album )->id() : - -1 ); - result << QString::number( track->m_genre ? - KSharedPtr::staticCast( track->m_genre )->id() : - -1 ); - result << QString::number( track->m_composer ? - KSharedPtr::staticCast( track->m_composer )->id() : - -1 ); - result << QString::number( track->m_year ? - KSharedPtr::staticCast( track->m_year )->id() : - -1 ); - result << escape( track->m_title ); - result << escape( track->m_comment ); - result << nullNumber( track->m_trackNumber ); - result << nullNumber( track->m_discNumber ); - result << nullNumber( track->m_bitrate ); - result << nullNumber( track->m_length ); - result << nullNumber( track->m_sampleRate ); - result << nullNumber( track->m_filesize ); - result << nullNumber( int(track->m_filetype) ); - result << nullNumber( track->m_bpm ); - result << nullDate( track->m_createDate ); - result << nullDate( track->m_modifyDate ); - result << QString::number( track->m_albumGain ); - result << QString::number( track->m_albumPeakGain ); - result << QString::number( track->m_trackGain ); - result << QString::number( track->m_trackPeakGain ); - return result; -} - -// ------------ statistics --------------- - -QString -TrackStatisticsTableCommitter::tableName() -{ - return "statistics"; -} - -int -TrackStatisticsTableCommitter::getId( Meta::SqlTrack *track ) -{ - return track->m_statisticsId; -} - -void -TrackStatisticsTableCommitter::setId( Meta::SqlTrack *track, int id ) -{ - track->m_statisticsId = id; -} - -QStringList -TrackStatisticsTableCommitter::getFields() -{ - QStringList result; - result << "url" << "createdate" << "accessdate" << "score" << "rating" << "playcount" << "deleted"; - return result; -} - -QStringList -TrackStatisticsTableCommitter::getValues( Meta::SqlTrack *track ) -{ - QStringList result; - Q_ASSERT( track->m_urlId > 0 && "refusing to write non-positive urlId to statistics table, please file a bug" ); - result << QString::number( track->m_urlId ); - result << nullDate( track->m_firstPlayed ); - result << nullDate( track->m_lastPlayed ); - result << nullNumber( track->m_score ); - result << QString::number( track->m_rating ); // NOT NULL - result << QString::number( track->m_playCount ); // NOT NULL - result << "0"; // not deleted - return result; -} diff --git a/amarok/src/core-impl/collections/db/sql/SqlRegistry_p.h b/amarok/src/core-impl/collections/db/sql/SqlRegistry_p.h deleted file mode 100644 index a7d4e263..00000000 --- a/amarok/src/core-impl/collections/db/sql/SqlRegistry_p.h +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Ralf Engels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef SQLREGISTRY_P_H -#define SQLREGISTRY_P_H - -#include "SqlMeta.h" - -#include -#include - -class SqlStorage; - -/** A table committer will commit one table for a list of tracks. - The table committer is a helper class that will batch insert/update one table - for a list of tracks. -*/ -class AbstractTrackTableCommitter -{ - public: - /** Will commit one table for all the tracks. - This will insert all the values into one table or update all the values. - The id will be updated. - */ - void commit( const QList &tracks ); - virtual ~AbstractTrackTableCommitter() {} - - protected: - virtual QString tableName() = 0; - virtual int getId( Meta::SqlTrack *track ) = 0; - virtual void setId( Meta::SqlTrack *track, int id ) = 0; - virtual QStringList getFields() = 0; - virtual QStringList getValues( Meta::SqlTrack *track ) = 0; - - QString nullString( const QString &str ) const; - QString nullNumber( const qint64 number ) const; - QString nullNumber( const int number ) const; - QString nullNumber( const double number ) const; - QString nullDate( const QDateTime &date ) const; - QString escape( const QString &str ) const; - - SqlStorage *m_storage; -}; - -class TrackUrlsTableCommitter: public AbstractTrackTableCommitter -{ - public: - virtual ~TrackUrlsTableCommitter() {} - - protected: - virtual QString tableName(); - virtual int getId( Meta::SqlTrack *track ); - virtual void setId( Meta::SqlTrack *track, int id ); - virtual QStringList getFields(); - virtual QStringList getValues( Meta::SqlTrack *track ); -}; - -class TrackTracksTableCommitter: public AbstractTrackTableCommitter -{ - public: - virtual ~TrackTracksTableCommitter() {} - - protected: - virtual QString tableName(); - virtual int getId( Meta::SqlTrack *track ); - virtual void setId( Meta::SqlTrack *track, int id ); - virtual QStringList getFields(); - virtual QStringList getValues( Meta::SqlTrack *track ); -}; - -class TrackStatisticsTableCommitter: public AbstractTrackTableCommitter -{ - public: - virtual ~TrackStatisticsTableCommitter() {} - - protected: - virtual QString tableName(); - virtual int getId( Meta::SqlTrack *track ); - virtual void setId( Meta::SqlTrack *track, int id ); - virtual QStringList getFields(); - virtual QStringList getValues( Meta::SqlTrack *track ); -}; - - -#endif /* SQLREGISTRY_P_H */ diff --git a/amarok/src/core-impl/collections/db/sql/SqlScanResultProcessor.cpp b/amarok/src/core-impl/collections/db/sql/SqlScanResultProcessor.cpp deleted file mode 100644 index ea9c911f..00000000 --- a/amarok/src/core-impl/collections/db/sql/SqlScanResultProcessor.cpp +++ /dev/null @@ -1,728 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Maximilian Kossick * - * Copyright (c) 2008 Seb Ruiz * - * Copyright (c) 2009-2010 Jeff Mitchell * - * Copyright (c) 2013 Ralf Engels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "SqlScanResultProcessor" - -#include "SqlScanResultProcessor.h" - -#include "MainWindow.h" -#include "collectionscanner/Directory.h" -#include "collectionscanner/Album.h" -#include "collectionscanner/Track.h" -#include "collectionscanner/Playlist.h" -#include "core/support/Debug.h" -#include "core-impl/collections/db/MountPointManager.h" -#include "core-impl/collections/db/sql/SqlQueryMaker.h" -#include "playlistmanager/PlaylistManager.h" - -#include - -#include - -SqlScanResultProcessor::SqlScanResultProcessor( GenericScanManager* manager, - Collections::SqlCollection* collection, - QObject *parent ) - : AbstractScanResultProcessor( manager, parent ) - , m_collection( collection ) -{ } - -SqlScanResultProcessor::~SqlScanResultProcessor() -{ } - -void -SqlScanResultProcessor::scanStarted( GenericScanManager::ScanType type ) -{ - AbstractScanResultProcessor::scanStarted( type ); - - m_collection->sqlStorage()->clearLastErrors(); - m_messages.clear(); -} - -void -SqlScanResultProcessor::scanSucceeded() -{ - DEBUG_BLOCK; - - // we are blocking the updated signal for maximum of one second. - m_blockedTime = QDateTime::currentDateTime(); - blockUpdates(); - - urlsCacheInit(); - - // -- call the base implementation - AbstractScanResultProcessor::scanSucceeded(); - - // -- error reporting - m_messages.append( m_collection->sqlStorage()->getLastErrors() ); - - if( !m_messages.isEmpty() && QApplication::type() != QApplication::Tty ) - QTimer::singleShot(0, this, SLOT(displayMessages())); // do in the UI thread - - unblockUpdates(); -} - -void -SqlScanResultProcessor::displayMessages() -{ - QString errorList = m_messages.join( "
  • " ).replace( '\n', "
    " ); - QString text = i18n( "
    • %1
    " - "In most cases this means that not all of your tracks were imported.
    " - "See " - "Amarok Manual for information about duplicate tracks.", errorList ); - KMessageBox::error( The::mainWindow(), text, i18n( "Errors During Collection Scan" ), - KMessageBox::AllowLink ); - - m_messages.clear(); -} - -void -SqlScanResultProcessor::blockUpdates() -{ - m_collection->blockUpdatedSignal(); - m_collection->registry()->blockDatabaseUpdate(); -} - -void -SqlScanResultProcessor::unblockUpdates() -{ - m_collection->registry()->unblockDatabaseUpdate(); - m_collection->unblockUpdatedSignal(); -} - -void -SqlScanResultProcessor::message( const QString& message ) -{ - m_messages.append( message ); -} - -void -SqlScanResultProcessor::commitDirectory( QSharedPointer directory ) -{ - QString path = directory->path(); - // a bit of paranoia: - if( m_foundDirectories.contains( path ) ) - warning() << "commitDirectory(): duplicate directory path" << path << "in" - << "collectionscanner output. This shouldn't happen."; - - // getDirectory() updates the directory entry mtime: - int dirId = m_collection->registry()->getDirectory( path, directory->mtime() ); - // we never dereference key of m_directoryIds, it is safe to add it as a plain pointer - m_directoryIds.insert( directory.data(), dirId ); - m_foundDirectories.insert( path, dirId ); - - AbstractScanResultProcessor::commitDirectory( directory ); - - // --- unblock every 5 second. Maybe not really needed, but still nice - if( m_blockedTime.secsTo( QDateTime::currentDateTime() ) >= 5 ) - { - unblockUpdates(); - m_blockedTime = QDateTime::currentDateTime(); - blockUpdates(); - } -} - -void -SqlScanResultProcessor::commitAlbum( CollectionScanner::Album *album ) -{ - debug() << "commitAlbum on"<name()<< "artist"<artist(); - - // --- get or create the album - Meta::SqlAlbumPtr metaAlbum; - metaAlbum = Meta::SqlAlbumPtr::staticCast( m_collection->getAlbum( album->name(), album->artist() ) ); - if( !metaAlbum ) - return; - m_albumIds.insert( album, metaAlbum->id() ); - - // --- add all tracks - foreach( CollectionScanner::Track *track, album->tracks() ) - commitTrack( track, album ); - - // --- set the cover if we have one - // we need to do this after the tracks are added in case of an embedded cover - bool suppressAutoFetch = metaAlbum->suppressImageAutoFetch(); - metaAlbum->setSuppressImageAutoFetch( true ); - if( m_type == GenericScanManager::FullScan ) - { - if( !album->cover().isEmpty() ) - { - metaAlbum->removeImage(); - metaAlbum->setImage( album->cover() ); - } - } - else - { - if( !metaAlbum->hasImage() && !album->cover().isEmpty() ) - metaAlbum->setImage( album->cover() ); - } - metaAlbum->setSuppressImageAutoFetch( suppressAutoFetch ); -} - -void -SqlScanResultProcessor::commitTrack( CollectionScanner::Track *track, - CollectionScanner::Album *srcAlbum ) -{ - // debug() << "commitTrack on"<title()<< "album"<name() << "dir:" << track->directory()->path()<directory(); - - Q_ASSERT( track ); - Q_ASSERT( srcAlbum ); - - Q_ASSERT( m_directoryIds.contains( track->directory() ) ); - int directoryId = m_directoryIds.value( track->directory() ); - Q_ASSERT( m_albumIds.contains( srcAlbum ) ); - int albumId = m_albumIds.value( srcAlbum ); - - QString uid = track->uniqueid(); - if( uid.isEmpty() ) - { - warning() << "commitTrack(): got track with empty unique id from the scanner," - << "not adding it"; - m_messages.append( QString( "Not adding track %1 because it has no unique id." ). - arg(track->path()) ); - return; - } - uid = m_collection->generateUidUrl( uid ); - - int deviceId = m_collection->mountPointManager()->getIdForUrl( track->path() ); - QString rpath = m_collection->mountPointManager()->getRelativePath( deviceId, track->path() ); - - if( m_foundTracks.contains( uid ) ) - { - const UrlEntry old = m_urlsCache.value( m_uidCache.value( uid ) ); - const char *pattern = I18N_NOOP( "Duplicates found, the second file will be ignored:\n%1\n%2" ); - - // we want translated version for GUI and non-translated for debug log - warning() << "commitTrack():" << QString( pattern ).arg( old.path, track->path() ); - m_messages.append( i18n( pattern, old.path, track->path() ) ); - return; - } - - Meta::SqlTrackPtr metaTrack; - UrlEntry entry; - // find an existing track by uid - if( m_uidCache.contains( uid ) ) - { - // uid is sadly not unique. Try to find the best url id. - int urlId = findBestUrlId( uid, track->path() ); - Q_ASSERT( urlId > 0 ); - Q_ASSERT( m_urlsCache.contains( urlId ) ); - entry = m_urlsCache.value( urlId ); - entry.path = track->path(); - entry.directoryId = directoryId; - - metaTrack = Meta::SqlTrackPtr::staticCast( m_collection->registry()->getTrack( urlId ) ); - Q_ASSERT( metaTrack->urlId() == entry.id ); - } - // find an existing track by path - else if( m_pathCache.contains( track->path() ) ) - { - int urlId = m_pathCache.value( track->path() ); - Q_ASSERT( m_urlsCache.contains( urlId ) ); - entry = m_urlsCache.value( urlId ); - entry.uid = uid; - entry.directoryId = directoryId; - - metaTrack = Meta::SqlTrackPtr::staticCast( m_collection->registry()->getTrack( urlId ) ); - Q_ASSERT( metaTrack->urlId() == entry.id ); - } - // create a new one - else - { - static int autoDecrementId = -1; - entry.id = autoDecrementId--; - entry.path = track->path(); - entry.uid = uid; - entry.directoryId = directoryId; - - metaTrack = Meta::SqlTrackPtr::staticCast( m_collection->getTrack( deviceId, rpath, directoryId, uid ) ); - } - - if( !metaTrack ) - { - QString text = QString( "Something went wrong when importing track %1, metaTrack " - "is null while it shouldn't be." ).arg( track->path() ); - warning() << "commitTrack():" << text.toLocal8Bit().data(); - m_messages.append( text ); - return; - } - urlsCacheInsert( entry ); // removes the previous entry (by id) first if necessary - m_foundTracks.insert( uid, entry.id ); - - // TODO: we need to check the modified date of the file agains the last updated of the file - // to figure out if the track information was updated from outside Amarok. - // In such a case we would fully reread all the information as if in a FullScan - - // -- set the values - metaTrack->setWriteFile( false ); // no need to write the tags back - metaTrack->beginUpdate(); - - metaTrack->setUidUrl( uid ); - metaTrack->setUrl( deviceId, rpath, directoryId ); - - if( m_type == GenericScanManager::FullScan || - !track->title().isEmpty() ) - metaTrack->setTitle( track->title() ); - - if( m_type == GenericScanManager::FullScan || - albumId != -1 ) - metaTrack->setAlbum( albumId ); - - if( m_type == GenericScanManager::FullScan || - !track->artist().isEmpty() ) - metaTrack->setArtist( track->artist() ); - - if( m_type == GenericScanManager::FullScan || - !track->composer().isEmpty() ) - metaTrack->setComposer( track->composer() ); - - if( m_type == GenericScanManager::FullScan || - track->year() >= 0 ) - metaTrack->setYear( (track->year() >= 0) ? track->year() : 0 ); - - if( m_type == GenericScanManager::FullScan || - !track->genre().isEmpty() ) - metaTrack->setGenre( track->genre() ); - - metaTrack->setType( track->filetype() ); - - if( m_type == GenericScanManager::FullScan || - !track->bpm() >= 0 ) - metaTrack->setBpm( track->bpm() ); - - if( m_type == GenericScanManager::FullScan || - !track->comment().isEmpty() ) - metaTrack->setComment( track->comment() ); - - if( (m_type == GenericScanManager::FullScan || metaTrack->score() == 0) && - track->score() >= 0 ) - metaTrack->setScore( track->score() ); - - if( (m_type == GenericScanManager::FullScan || metaTrack->rating() == 0.0) && - track->rating() >= 0 ) - metaTrack->setRating( track->rating() ); - - if( (m_type == GenericScanManager::FullScan || metaTrack->length() == 0) && - track->length() >= 0 ) - metaTrack->setLength( track->length() ); - - // the filesize is updated every time after the - // file is changed. Doesn't make sense to set it. - - if( (m_type == GenericScanManager::FullScan || !metaTrack->modifyDate().isValid()) && - track->modified().isValid() ) - metaTrack->setModifyDate( track->modified() ); - - if( (m_type == GenericScanManager::FullScan || metaTrack->sampleRate() == 0) && - track->samplerate() >= 0 ) - metaTrack->setSampleRate( track->samplerate() ); - - if( (m_type == GenericScanManager::FullScan || metaTrack->bitrate() == 0) && - track->bitrate() >= 0 ) - metaTrack->setBitrate( track->bitrate() ); - - if( (m_type == GenericScanManager::FullScan || metaTrack->trackNumber() == 0) && - track->track() >= 0 ) - metaTrack->setTrackNumber( track->track() ); - - if( (m_type == GenericScanManager::FullScan || metaTrack->discNumber() == 0) && - track->disc() >= 0 ) - metaTrack->setDiscNumber( track->disc() ); - - if( m_type == GenericScanManager::FullScan && track->playcount() >= metaTrack->playCount() ) - metaTrack->setPlayCount( track->playcount() ); - - - Meta::ReplayGainTag modes[] = { Meta::ReplayGain_Track_Gain, - Meta::ReplayGain_Track_Peak, - Meta::ReplayGain_Album_Gain, - Meta::ReplayGain_Album_Peak }; - - for( int i=0; i<4; i++ ) - { - if( track->replayGain( modes[i] ) != 0.0 ) - metaTrack->setReplayGain( modes[i], track->replayGain( modes[i] ) ); - } - - metaTrack->endUpdate(); - metaTrack->setWriteFile( true ); -} - -void -SqlScanResultProcessor::deleteDeletedDirectories() -{ - SqlStorage *storage = m_collection->sqlStorage(); - - QList toCheck; - switch( m_type ) - { - case GenericScanManager::FullScan: - case GenericScanManager::UpdateScan: - toCheck = mountedDirectories(); - break; - case GenericScanManager::PartialUpdateScan: - toCheck = deletedDirectories(); - } - - // -- check if the have been found during the scan - foreach( const DirectoryEntry &e, toCheck ) - { - /* we need to match directories by their (absolute) path, otherwise following - * scenario triggers statistics loss (bug 298275): - * - * 1. user relocates collection to different filesystem, but clones path structure - * or toggles MassStorageDeviceHandler enabled in Config -> plugins. - * 2. collectionscanner knows nothings about directory ids, so it doesn't detect - * any track changes and emits a bunch of skipped (unchanged) dirs with no - * tracks. - * 3. SqlRegistry::getDirectory() called there from returns different directory id - * then in past. - * 4. deleteDeletedDirectories() is called, and if it operates on directory ids, - * it happily removes _all_ directories, taking tracks with it. - * 5. Tracks disappear from the UI until full rescan, stats, lyrics, labels are - * lost forever. - */ - QString path = m_collection->mountPointManager()->getAbsolutePath( e.deviceId, e.dir ); - bool deleteThisDir = false; - if( !m_foundDirectories.contains( path ) ) - deleteThisDir = true; - else if( m_foundDirectories.value( path ) != e.dirId ) - { - int newDirId = m_foundDirectories.value( path ); - // as a safety measure, we don't delete the old dir if relocation fails - deleteThisDir = relocateTracksToNewDirectory( e.dirId, newDirId ); - } - - if( deleteThisDir ) - { - deleteDeletedTracks( e.dirId ); - QString query = QString( "DELETE FROM directories WHERE id = %1;" ).arg( e.dirId ); - storage->query( query ); - } - } -} - -void -SqlScanResultProcessor::deleteDeletedTracksAndSubdirs( QSharedPointer directory ) -{ - Q_ASSERT( m_directoryIds.contains( directory.data() ) ); - int directoryId = m_directoryIds.value( directory.data() ); - // only deletes tracks directly in this dir - deleteDeletedTracks( directoryId ); - // trigger deletion of deleted subdirectories in deleteDeletedDirectories(): - m_scannedDirectoryIds.insert( directoryId ); -} - -void -SqlScanResultProcessor::deleteDeletedTracks( int directoryId ) -{ - // -- find all tracks - QList urlIds = m_directoryCache.values( directoryId ); - - // -- check if the tracks have been found during the scan - foreach( int urlId, urlIds ) - { - Q_ASSERT( m_urlsCache.contains( urlId ) ); - const UrlEntry &entry = m_urlsCache[ urlId ]; - Q_ASSERT( entry.directoryId == directoryId ); - // we need to match both uid and url id, because uid is not unique - if( !m_foundTracks.contains( entry.uid, entry.id ) ) - { - removeTrack( entry ); - urlsCacheRemove( entry ); - } - } -} - -int -SqlScanResultProcessor::findBestUrlId( const QString &uid, const QString &path ) -{ - QList urlIds = m_uidCache.values( uid ); - if( urlIds.isEmpty() ) - return -1; - if( urlIds.size() == 1 ) - return urlIds.at( 0 ); // normal operation - - foreach( int testedUrlId, urlIds ) - { - Q_ASSERT( m_urlsCache.contains( testedUrlId ) ); - if( m_urlsCache[ testedUrlId ].path == path ) - return testedUrlId; - } - - warning() << "multiple url entries with uid" << uid << "found in the database, but" - << "none with current path" << path << "Choosing blindly the last one out" - << "of url id candidates" << urlIds; - return urlIds.last(); -} - -bool -SqlScanResultProcessor::relocateTracksToNewDirectory( int oldDirId, int newDirId ) -{ - QList urlIds = m_directoryCache.values( oldDirId ); - if( urlIds.isEmpty() ) - return true; // nothing to do - - MountPointManager *manager = m_collection->mountPointManager(); - SqlRegistry *reg = m_collection->registry(); - SqlStorage *storage = m_collection->sqlStorage(); - - // sanity checking, not strictly needed, but imagine new device appearing in the - // middle of the scan, so rather prevent db corruption: - QStringList res = storage->query( QString( "SELECT deviceid FROM directories " - "WHERE id = %1" ).arg( newDirId ) ); - if( res.count() != 1 ) - { - warning() << "relocateTracksToNewDirectory(): no or multiple entries when" - << "quering directory with id" << newDirId; - return false; - } - int newDirDeviceId = res.at( 0 ).toInt(); - - foreach( int urlId, urlIds ) - { - Q_ASSERT( m_urlsCache.contains( urlId ) ); - UrlEntry entry = m_urlsCache.value( urlId ); - Meta::SqlTrackPtr track = Meta::SqlTrackPtr::staticCast( reg->getTrack( urlId ) ); - Q_ASSERT( track ); - - // not strictly needed, but we want to sanity check it to prevent corrupt db - int deviceId = manager->getIdForUrl( entry.path ); - if( newDirDeviceId != deviceId ) - { - warning() << "relocateTracksToNewDirectory(): device id from newDirId (" - << res.at( 0 ).toInt() << ") and device id from mountPointManager (" - << deviceId << ") don't match!"; - return false; - } - QString rpath = manager->getRelativePath( deviceId, entry.path ); - - track->setUrl( deviceId, rpath, newDirId ); - entry.directoryId = newDirId; - urlsCacheInsert( entry ); // removes the previous entry (by id) first - } - return true; -} - -void -SqlScanResultProcessor::removeTrack( const UrlEntry &entry ) -{ - debug() << "removeTrack(" << entry << ")"; - // we used to skip track removal is m_messages wasn't empty, but that lead to to - // tracks left laying around. We now hope that the result processor got better and - // only removes tracks that should be removed. - - SqlRegistry *reg = m_collection->registry(); - // we must get the track by id, uid is not unique - Meta::SqlTrackPtr track = Meta::SqlTrackPtr::staticCast( reg->getTrack( entry.id ) ); - Q_ASSERT( track->urlId() == entry.id ); - track->remove(); -} - -QList -SqlScanResultProcessor::mountedDirectories() const -{ - SqlStorage *storage = m_collection->sqlStorage(); - - // -- get a list of all mounted device ids - QList idList = m_collection->mountPointManager()->getMountedDeviceIds(); - QString deviceIds; - foreach( int id, idList ) - { - if ( !deviceIds.isEmpty() ) - deviceIds += ','; - deviceIds += QString::number( id ); - } - - // -- get all (mounted) directories - QString query = QString( "SELECT id, deviceid, dir FROM directories " - "WHERE deviceid IN (%1)" ).arg( deviceIds ); - QStringList res = storage->query( query ); - - QList result; - for( int i = 0; i < res.count(); ) - { - DirectoryEntry e; - e.dirId = res.at( i++ ).toInt(); - e.deviceId = res.at( i++ ).toInt(); - e.dir = res.at( i++ ); - result << e; - } - - return result; -} - -QList -SqlScanResultProcessor::deletedDirectories() const -{ - SqlStorage *storage = m_collection->sqlStorage(); - - QHash idToDirEntryMap; // for faster processing during filtering - foreach( int directoryId, m_scannedDirectoryIds ) - { - QString query = QString( "SELECT deviceid, dir FROM directories WHERE id = %1" ) - .arg( directoryId ); - QStringList res = storage->query( query ); - if( res.count() != 2 ) - { - warning() << "unexpected query result" << res << "in deletedDirectories()"; - continue; - } - - int deviceId = res.at( 0 ).toInt(); - QString dir = res.at( 1 ); - // select all child directories - query = QString( "SELECT id, deviceid, dir FROM directories WHERE deviceid = %1 " - "AND dir LIKE '%2_%'" ).arg( deviceId ).arg( storage->escape( dir ) ); - res = storage->query( query ); - for( int i = 0; i < res.count(); ) - { - DirectoryEntry e; - e.dirId = res.at( i++ ).toInt(); - e.deviceId = res.at( i++ ).toInt(); - e.dir = res.at( i++ ); - idToDirEntryMap.insert( e.dirId, e ); - } - } - - // now we must fileter-out all found directories *and their children*, because the - // children are *not* in m_foundDirectories and deleteDeletedDirectories() would - // remove them errorneously - foreach( int foundDirectoryId, m_foundDirectories ) - { - if( idToDirEntryMap.contains( foundDirectoryId ) ) - { - int existingDeviceId = idToDirEntryMap[ foundDirectoryId ].deviceId; - QString existingPath = idToDirEntryMap[ foundDirectoryId ].dir; - idToDirEntryMap.remove( foundDirectoryId ); - - // now remove all children of the existing directory - QMutableHashIterator it( idToDirEntryMap ); - while( it.hasNext() ) - { - const DirectoryEntry &e = it.next().value(); - if( e.deviceId == existingDeviceId && e.dir.startsWith( existingPath ) ) - it.remove(); - } - } - } - - return idToDirEntryMap.values(); -} - -void -SqlScanResultProcessor::urlsCacheInit() -{ - SqlStorage *storage = m_collection->sqlStorage(); - - QString query = QString( "SELECT id, deviceid, rpath, directory, uniqueid FROM urls;"); - QStringList res = storage->query( query ); - - for( int i = 0; i < res.count(); ) - { - int id = res.at(i++).toInt(); - int deviceId = res.at(i++).toInt(); - QString rpath = res.at(i++); - int directoryId = res.at(i++).toInt(); - QString uid = res.at(i++); - - QString path; - if( deviceId ) - path = m_collection->mountPointManager()->getAbsolutePath( deviceId, rpath ); - else - path = rpath; - - UrlEntry entry; - entry.id = id; - entry.path = path; - entry.directoryId = directoryId; - entry.uid = uid; - - if( !directoryId ) - { - warning() << "Found urls entry without directory. A phantom track. Removing" << path; - removeTrack( entry ); - continue; - } - - urlsCacheInsert( entry ); - } -} - -void -SqlScanResultProcessor::urlsCacheInsert( const UrlEntry &entry ) -{ - // this case is normal operation - if( m_urlsCache.contains( entry.id ) ) - urlsCacheRemove( m_urlsCache[ entry.id ] ); - - // following shoudn't normally happen: - if( m_pathCache.contains( entry.path ) ) - { - int oldId = m_pathCache.value( entry.path ); - Q_ASSERT( m_urlsCache.contains( oldId ) ); - const UrlEntry &old = m_urlsCache[ oldId ]; - warning() << "urlsCacheInsert(): found duplicate in path. old" << old - << "will be hidden by the new one in the cache:" << entry; - } - - // this will signify error in this class: - Q_ASSERT( !m_uidCache.contains( entry.uid, entry.id ) ); - Q_ASSERT( !m_directoryCache.contains( entry.directoryId, entry.id ) ); - - m_urlsCache.insert( entry.id, entry ); - m_uidCache.insert( entry.uid, entry.id ); - m_pathCache.insert( entry.path, entry.id ); - m_directoryCache.insert( entry.directoryId, entry.id ); -} - -void -SqlScanResultProcessor::cleanupMembers() -{ - m_foundDirectories.clear(); - m_foundTracks.clear(); - m_scannedDirectoryIds.clear(); - m_directoryIds.clear(); - m_albumIds.clear(); - - m_urlsCache.clear(); - m_uidCache.clear(); - m_pathCache.clear(); - m_directoryCache.clear(); - - AbstractScanResultProcessor::cleanupMembers(); -} - -void -SqlScanResultProcessor::urlsCacheRemove( const UrlEntry &entry ) -{ - if( !m_urlsCache.contains( entry.id ) ) - return; - - m_uidCache.remove( entry.uid, entry.id ); - m_pathCache.remove( entry.path ); - m_directoryCache.remove( entry.directoryId, entry.id ); - m_urlsCache.remove( entry.id ); -} - -QDebug -operator<<( QDebug dbg, const SqlScanResultProcessor::UrlEntry &entry ) -{ - dbg.nospace() << "Entry(id=" << entry.id << ", path=" << entry.path << ", dirId=" - << entry.directoryId << ", uid=" << entry.uid << ")"; - return dbg.space(); -} diff --git a/amarok/src/core-impl/collections/db/sql/SqlScanResultProcessor.h b/amarok/src/core-impl/collections/db/sql/SqlScanResultProcessor.h deleted file mode 100644 index 8782af6e..00000000 --- a/amarok/src/core-impl/collections/db/sql/SqlScanResultProcessor.h +++ /dev/null @@ -1,164 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Maximilian Kossick * - * Copyright (c) 2008 Seb Ruiz * - * Copyright (c) 2009-2010 Jeff Mitchell * - * Copyright (c) 2013 Ralf Engels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_SQL_SCANRESULTPROCESSOR_H -#define AMAROK_SQL_SCANRESULTPROCESSOR_H - -#include "scanner/AbstractScanResultProcessor.h" -#include "core-impl/collections/db/sql/SqlCollection.h" - -/** The ScanResulProcessor class takes the results from the ScanManager and puts them into the database. - */ -class SqlScanResultProcessor : public AbstractScanResultProcessor -{ - Q_OBJECT - - public: - SqlScanResultProcessor( GenericScanManager* manager, - Collections::SqlCollection *collection, - QObject *parent = 0 ); - virtual ~SqlScanResultProcessor(); - - - protected slots: - virtual void scanStarted( GenericScanManager::ScanType type ); - virtual void scanSucceeded(); - - virtual void displayMessages(); - - protected: - virtual void message( const QString& message ); - - virtual void commitDirectory( QSharedPointer directory ); - virtual void commitAlbum( CollectionScanner::Album *album ); - virtual void commitTrack( CollectionScanner::Track *track, CollectionScanner::Album *srcAlbum ); - - /** Deletes all directories (and it's tracks) not contained in m_foundDirectories */ - virtual void deleteDeletedDirectories(); - - virtual void deleteDeletedTracksAndSubdirs( QSharedPointer directory ); - - /** Removes all tracks contained in the directory dirId that are not contained in m_foundTracks. */ - virtual void deleteDeletedTracks( int directoryId ); - - virtual void cleanupMembers(); - - void blockUpdates(); - void unblockUpdates(); - - private: - // to speed up the scanning we buffer the whole urls table - struct UrlEntry { - int id; - QString path; - int directoryId; - QString uid; - }; - friend QDebug operator<<( QDebug, const UrlEntry& ); - - /** - * Finds best url id of a track identified by @param uid uniqueid in caches. If - * multiple entries are found, tries to use @param path as a hint. - * - * @returns url id or -1 if nothing is found. - */ - int findBestUrlId( const QString &uid, const QString &path ); - - /** - * Directory id has changed from @param oldDirId to @param newDirId without - * actual change in the absolute directory path or contents. Try to relocate - * tracks to the new directory, updating necessary fields. - * @return true if all tracks were successfully relocated and the old dir can be - * deleted without losses, false otherwise. - */ - bool relocateTracksToNewDirectory( int oldDirId, int newDirId ); - - /** - * Remove track from the database. Does not touch the cache - you should probably - * call urlsCacheRemove( entry ) - */ - void removeTrack( const UrlEntry &entry ); - - struct DirectoryEntry { - int dirId; - int deviceId; - QString dir; - }; - - /** - * Get a list of all mounted directories from the database. - */ - QList mountedDirectories() const; - - /** - * Get a list of directories that have been physically removed during the - * PartialUpdateScan. - */ - QList deletedDirectories() const; - - Collections::SqlCollection *m_collection; - - /** - * Contains all found directories with their absolute path and id - */ - QHash m_foundDirectories; - - /** - * Contains all found tracks with the unique id and url id. QMultiHash only - * because it implements contains( key, value ) - */ - QMultiHash m_foundTracks; - - /** - * In UpdateScan and PartialUpdateScan this set gets filled with directory ids - * that have been (non-recursively) fully scanned (not skipped). Direct child - * directories from the database that are not contained in m_foundDirectories can - * be considered deleted. - */ - QSet m_scannedDirectoryIds; - - // never dereference they key, it might be a stale pointer in corner cases - QHash m_directoryIds; - QHash m_albumIds; - - void urlsCacheInit(); - /** - * Inserts @param entry into caches. If an entry with same url id already exists - * in cache, it will be replaced. Duplicates in uidUrl and path are _not_ avoided, - * m_uidCache and m_pathCache will point to most recently added entry. - */ - void urlsCacheInsert( const UrlEntry &entry ); - void urlsCacheRemove( const UrlEntry &entry ); - - /// maps UrlEntry id to UrlEntry - QHash m_urlsCache; - /// maps uid to UrlEntry id - QMultiHash m_uidCache; - /// maps path to UrlEntry id - QHash m_pathCache; - /// maps directory id to UrlEntry id - QMultiHash m_directoryCache; - - QDateTime m_blockedTime; - QStringList m_messages; -}; - -QDebug operator<<( QDebug dbg, const SqlScanResultProcessor::UrlEntry &entry ); - -#endif diff --git a/amarok/src/core-impl/collections/db/sql/SqlWriteLabelCapability.cpp b/amarok/src/core-impl/collections/db/sql/SqlWriteLabelCapability.cpp deleted file mode 100644 index fad5aa07..00000000 --- a/amarok/src/core-impl/collections/db/sql/SqlWriteLabelCapability.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/* - Copyright (C) 2009 Dan Meltzer - - This program 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 2 of the License, or - (at your option) any later version. - - This program 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 this program. If not, see . - -*/ - -#include "SqlWriteLabelCapability.h" - -#include "core-impl/collections/support/CollectionManager.h" -#include "core/support/Debug.h" -#include - -namespace Capabilities -{ - -SqlWriteLabelCapability::SqlWriteLabelCapability( Meta::SqlTrack* track, SqlStorage* storage ) - : WriteLabelCapability() - , m_track( track ) - , m_storage( storage ) -{ -} - -void -SqlWriteLabelCapability::setLabels( const QStringList &removedLabels, const QStringList &newlabels ) -{ - - if( !m_storage ) - { - debug() << "Could not get SqlStorage, aborting" << endl; - return; - } - - for ( int x = 0; x < newlabels.length(); x++) - { - //Check if all new labels are already in the Database - const QString checkQuery = "SELECT label FROM labels WHERE label=\"%1\""; - QStringList result = m_storage->query( checkQuery.arg( m_storage->escape( newlabels.at( x ) ) ) ); - - if ( result.isEmpty() ) - { - const QString newQuery = "INSERT INTO labels (label) VALUE(\"%1\")"; - m_storage->query( newQuery.arg( m_storage->escape( newlabels.at( x ) ) ) ); - } - - //Insert connection for every new label if not already there - const QString checkNewQuery = "SELECT label from urls_labels WHERE label=(SELECT id FROM labels WHERE label=\"%1\") AND url=(SELECT id FROM urls WHERE uniqueid=\"%2\")"; - result = m_storage->query( checkNewQuery.arg( m_storage->escape( newlabels.at( x ) ), m_storage->escape( m_track->uidUrl() ) ) ); - - if ( result.isEmpty() ) - { - const QString insertQuery = "INSERT INTO urls_labels (label,url) VALUE((SELECT id FROM labels WHERE label=\"%1\"),(SELECT id FROM urls WHERE uniqueid=\"%2\"))"; - m_storage->query( insertQuery.arg( m_storage->escape( newlabels.at( x ) ), m_storage->escape( m_track->uidUrl() ) ) ); - } - } - - for ( int y = 0; y < removedLabels.length(); y++) - { - //Delete connections for every removed label - const QString removeQuery = "DELETE FROM urls_labels WHERE url=(SELECT id FROM urls WHERE uniqueid=\"%1\") AND label=(SELECT id FROM labels WHERE label=\"%2\")"; - m_storage->query( removeQuery.arg( m_storage->escape( m_track->uidUrl() ), m_storage->escape( removedLabels.at( y ) ) ) ); - - //Check if label isn't used anymore - const QString checkQuery = "SELECT label FROM urls_labels where label=(SELECT id FROM labels WHERE label=\"%1\")"; - QStringList result = m_storage->query( checkQuery.arg( m_storage->escape( removedLabels.at( y ) ) ) ); - - if ( result.isEmpty() ) - { - const QString labelRemoveQuery = "DELETE FROM labels WHERE label=\"%1\""; - m_storage->query( labelRemoveQuery.arg( m_storage->escape( removedLabels.at( y ) ) ) ); - } - } -} - -} diff --git a/amarok/src/core-impl/collections/db/sql/SqlWriteLabelCapability.h b/amarok/src/core-impl/collections/db/sql/SqlWriteLabelCapability.h deleted file mode 100644 index f27c29a9..00000000 --- a/amarok/src/core-impl/collections/db/sql/SqlWriteLabelCapability.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - Copyright (C) 2009 Dan Meltzer - - This program 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 2 of the License, or - (at your option) any later version. - - This program 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 this program. If not, see . - -*/ - -#ifndef SQLWRITELABELCAPABILITY_H -#define SQLWRITELABELCAPABILITY_H - -#include "core/capabilities/WriteLabelCapability.h" -#include "SqlMeta.h" - -class SqlStorage; - -namespace Capabilities -{ - -class SqlWriteLabelCapability : public WriteLabelCapability -{ - Q_OBJECT - public: - SqlWriteLabelCapability( Meta::SqlTrack *track, SqlStorage *storage ); - void setLabels( const QStringList &removedLabels, const QStringList &newlabels ); - - private: - Meta::TrackPtr m_track; - SqlStorage *m_storage; -}; - -} - -#endif // SQLREADLABELCAPABILITY_H diff --git a/amarok/src/core-impl/collections/db/sql/amarok_sqlcollection_export.h b/amarok/src/core-impl/collections/db/sql/amarok_sqlcollection_export.h deleted file mode 100644 index 737e0389..00000000 --- a/amarok/src/core-impl/collections/db/sql/amarok_sqlcollection_export.h +++ /dev/null @@ -1,47 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 David Faure * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_SQLCOLLECTION_EXPORT_H -#define AMAROK_SQLCOLLECTION_EXPORT_H - -/* needed for KDE_EXPORT and KDE_IMPORT macros */ -#include - -#ifndef AMAROK_SQLCOLLECTION_EXPORT -# if defined(MAKE_AMAROK_SQLCOLLECTION_LIB) - /* We are building this library */ -# define AMAROK_SQLCOLLECTION_EXPORT KDE_EXPORT -# else - /* We are using this library */ -# define AMAROK_SQLCOLLECTION_EXPORT KDE_IMPORT -# endif -#endif - -#ifndef AMAROK_SQLCOLLECTION_MYSQLE_EXPORT -# if defined(MAKE_AMAROK_COLLECTION_MYSQLECOLLECTION_LIB) - /* We are building this library */ -# define AMAROK_SQLCOLLECTION_MYSQLE_EXPORT KDE_EXPORT -# else - /* We are using this library */ -# define AMAROK_SQLCOLLECTION_MYSQLE_EXPORT KDE_IMPORT -# endif -#endif - -# ifndef AMAROK_SQLCOLLECTION_EXPORT_DEPRECATED -# define AMAROK_SQLCOLLECTION_EXPORT_DEPRECATED KDE_DEPRECATED AMAROK_SQLCOLLECTION_EXPORT -# endif - -#endif diff --git a/amarok/src/core-impl/collections/db/sql/device/massstorage/MassStorageDeviceHandler.cpp b/amarok/src/core-impl/collections/db/sql/device/massstorage/MassStorageDeviceHandler.cpp deleted file mode 100644 index c7f1d3d5..00000000 --- a/amarok/src/core-impl/collections/db/sql/device/massstorage/MassStorageDeviceHandler.cpp +++ /dev/null @@ -1,189 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2006-2007 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "MassStorageDeviceHandler" - -#include "MassStorageDeviceHandler.h" - -#include "core/support/Debug.h" -#include - -#include -#include -#include -#include - -MassStorageDeviceHandler::MassStorageDeviceHandler(): DeviceHandler() -{ -} - -MassStorageDeviceHandler::MassStorageDeviceHandler( int deviceId, const QString &mountPoint, const QString &udi ) - : DeviceHandler() - , m_deviceID( deviceId ) - , m_mountPoint( mountPoint ) - , m_udi( udi ) -{ - DEBUG_BLOCK -} - -MassStorageDeviceHandler::~MassStorageDeviceHandler() -{ -} - -bool MassStorageDeviceHandler::isAvailable() const -{ - return true; -} - - -QString MassStorageDeviceHandler::type() const -{ - return "uuid"; -} - -int MassStorageDeviceHandler::getDeviceID() -{ - return m_deviceID; -} - -const QString &MassStorageDeviceHandler::getDevicePath() const -{ - return m_mountPoint; -} - -void MassStorageDeviceHandler::getURL( KUrl &absolutePath, const KUrl &relativePath ) -{ - absolutePath.setPath( m_mountPoint ); - absolutePath.addPath( relativePath.path() ); - absolutePath.cleanPath(); -} - -void MassStorageDeviceHandler::getPlayableURL( KUrl &absolutePath, const KUrl &relativePath ) -{ - getURL( absolutePath, relativePath ); -} - -bool MassStorageDeviceHandler::deviceMatchesUdi( const QString &udi ) const -{ - return m_udi == udi; -} - -/////////////////////////////////////////////////////////////////////////////// -// class MassStorageDeviceHandlerFactory -/////////////////////////////////////////////////////////////////////////////// - -QString MassStorageDeviceHandlerFactory::type( ) const -{ - return "uuid"; -} - -bool MassStorageDeviceHandlerFactory::canCreateFromMedium( ) const -{ - return true; -} - -bool MassStorageDeviceHandlerFactory::canCreateFromConfig( ) const -{ - return false; -} - -bool MassStorageDeviceHandlerFactory::canHandle( const Solid::Device &device ) const -{ - DEBUG_BLOCK - const Solid::StorageVolume *volume = device.as(); - if( !volume ) - { - debug() << "found no volume"; - return false; - } - if( volume->uuid().isEmpty() ) - debug() << "has empty uuid"; - if( volume->isIgnored() ) - debug() << "volume is ignored"; - if( excludedFilesystem( volume->fsType() ) ) - debug() << "excluded filesystem of type " << volume->fsType(); - return volume && !volume->uuid().isEmpty() - && !volume->isIgnored() && !excludedFilesystem( volume->fsType() ); -} - -MassStorageDeviceHandlerFactory::~MassStorageDeviceHandlerFactory( ) -{ -} - -DeviceHandler * MassStorageDeviceHandlerFactory::createHandler( KSharedConfigPtr, SqlStorage* ) const -{ - return 0; -} - -DeviceHandler * MassStorageDeviceHandlerFactory::createHandler( const Solid::Device &device, const QString &udi, SqlStorage *s ) const -{ - DEBUG_BLOCK - if( !s ) - { - debug() << "!s, returning 0"; - return 0; - } - const Solid::StorageVolume *volume = device.as(); - const Solid::StorageAccess *volumeAccess = device.as(); - if( !volume || !volumeAccess ) - { - debug() << "Volume isn't valid, can't create a handler"; - return 0; - } - if( volumeAccess->filePath().isEmpty() ) - { - debug() << "not mounted, can't do anything"; - return 0; // It's not mounted, we can't do anything. - } - QStringList ids = s->query( QString( "SELECT id, label, lastmountpoint " - "FROM devices WHERE type = 'uuid' " - "AND uuid = '%1';" ).arg( volume->uuid() ) ); - if ( ids.size() == 3 ) - { - debug() << "Found existing UUID config for ID " << ids[0] << " , uuid " << volume->uuid(); - s->query( QString( "UPDATE devices SET lastmountpoint = '%2' WHERE " - "id = %1;" ) - .arg( ids[0] ) - .arg( s->escape( volumeAccess->filePath() ) ) ); - return new MassStorageDeviceHandler( ids[0].toInt(), volumeAccess->filePath(), udi ); - } - else - { - const int id = s->insert( QString( "INSERT INTO devices( type, uuid, lastmountpoint ) " - "VALUES ( 'uuid', '%1', '%2' );" ) - .arg( volume->uuid() ) - .arg( s->escape( volumeAccess->filePath() ) ), - "devices" ); - if ( id == 0 ) - { - warning() << "Inserting into devices failed for type=uuid, uuid=" << volume->uuid(); - return 0; - } - debug() << "Created new UUID device with ID " << id << " , uuid " << volume->uuid(); - return new MassStorageDeviceHandler( id, volumeAccess->filePath(), udi ); - } -} - -bool -MassStorageDeviceHandlerFactory::excludedFilesystem( const QString &fstype ) const -{ - return fstype.isEmpty() || - fstype.indexOf( "smb" ) != -1 || - fstype.indexOf( "cifs" ) != -1 || - fstype.indexOf( "nfs" ) != -1 || - fstype == "udf" || - fstype == "iso9660" ; -} diff --git a/amarok/src/core-impl/collections/db/sql/device/massstorage/MassStorageDeviceHandler.h b/amarok/src/core-impl/collections/db/sql/device/massstorage/MassStorageDeviceHandler.h deleted file mode 100644 index 5320c3cd..00000000 --- a/amarok/src/core-impl/collections/db/sql/device/massstorage/MassStorageDeviceHandler.h +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2006-2007 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef MASSSTORAGEDEVICEHANDLER_H -#define MASSSTORAGEDEVICEHANDLER_H - -#include "core-impl/collections/db/MountPointManager.h" - -class SqlStorage; - -class MassStorageDeviceHandlerFactory : public DeviceHandlerFactory -{ -public: - MassStorageDeviceHandlerFactory( QObject *parent ) : DeviceHandlerFactory( parent ) {} - virtual ~MassStorageDeviceHandlerFactory(); - - virtual bool canHandle( const Solid::Device &device ) const; - - virtual bool canCreateFromMedium() const; - - virtual DeviceHandler* createHandler( const Solid::Device &device, const QString &uuid, SqlStorage *s ) const; - - virtual bool canCreateFromConfig() const; - - virtual DeviceHandler* createHandler( KSharedConfigPtr c, SqlStorage *s ) const; - - virtual QString type() const; - -private: - bool excludedFilesystem( const QString &fstype ) const; -}; - -/** - @author Maximilian Kossick -*/ -class MassStorageDeviceHandler : public DeviceHandler -{ -public: - MassStorageDeviceHandler(); - MassStorageDeviceHandler(int deviceId, const QString &mountPoint, const QString &uuid ); - - virtual ~MassStorageDeviceHandler(); - - virtual bool isAvailable() const; - virtual QString type() const; - virtual int getDeviceID( ); - virtual const QString &getDevicePath() const; - virtual void getURL( KUrl &absolutePath, const KUrl &relativePath ); - virtual void getPlayableURL( KUrl &absolutePath, const KUrl &relativePath ); - virtual bool deviceMatchesUdi( const QString &udi ) const; - -private: - - int m_deviceID; - const QString m_mountPoint; - QString m_udi; -}; - -#endif diff --git a/amarok/src/core-impl/collections/db/sql/device/nfs/NfsDeviceHandler.cpp b/amarok/src/core-impl/collections/db/sql/device/nfs/NfsDeviceHandler.cpp deleted file mode 100644 index cc7ba519..00000000 --- a/amarok/src/core-impl/collections/db/sql/device/nfs/NfsDeviceHandler.cpp +++ /dev/null @@ -1,206 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2006-2007 Maximilian Kossick * - * Copyright (c) 2011 Peter C. Ndikuwera * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "NfsDeviceHandler" - -#include "NfsDeviceHandler.h" - -#include "core/support/Debug.h" -#include - -#include -#include -#include -#include - -NfsDeviceHandler::NfsDeviceHandler( int deviceId, const QString &server, const QString &share, const QString &mountPoint, const QString &udi ) - : DeviceHandler() - , m_deviceID( deviceId ) - , m_server( server ) - , m_share( share ) - , m_mountPoint( mountPoint ) - , m_udi( udi ) -{ - DEBUG_BLOCK -} - -NfsDeviceHandler::NfsDeviceHandler( int deviceId, const QString &mountPoint, const QString &udi ) - : DeviceHandler() - , m_deviceID( deviceId ) - , m_mountPoint( mountPoint ) - , m_udi( udi ) -{ - DEBUG_BLOCK -} - -NfsDeviceHandler::~NfsDeviceHandler() -{ -} - -bool -NfsDeviceHandler::isAvailable() const -{ - return true; -} - - -QString -NfsDeviceHandler::type() const -{ - return "nfs"; -} - -int -NfsDeviceHandler::getDeviceID() -{ - return m_deviceID; -} - -const QString &NfsDeviceHandler::getDevicePath() const -{ - return m_mountPoint; -} - -void NfsDeviceHandler::getURL( KUrl &absolutePath, const KUrl &relativePath ) -{ - absolutePath.setPath( m_mountPoint ); - absolutePath.addPath( relativePath.path() ); - absolutePath.cleanPath(); -} - -void NfsDeviceHandler::getPlayableURL( KUrl &absolutePath, const KUrl &relativePath ) -{ - getURL( absolutePath, relativePath ); -} - -bool NfsDeviceHandler::deviceMatchesUdi( const QString &udi ) const -{ - return m_udi == udi; -} - -/////////////////////////////////////////////////////////////////////////////// -// class NfsDeviceHandlerFactory -/////////////////////////////////////////////////////////////////////////////// - -QString NfsDeviceHandlerFactory::type( ) const -{ - return "nfs"; -} - -bool NfsDeviceHandlerFactory::canCreateFromMedium( ) const -{ - return true; -} - -bool NfsDeviceHandlerFactory::canCreateFromConfig( ) const -{ - return false; -} - -bool NfsDeviceHandlerFactory::canHandle( const Solid::Device &device ) const -{ - const Solid::NetworkShare *share = device.as(); - if( !share ) - { - debug() << __PRETTY_FUNCTION__ << device.udi() << "has no NetworkShare interface"; - return false; - } - if( share->type() != Solid::NetworkShare::Nfs ) - { - debug() << __PRETTY_FUNCTION__ << device.udi() << "has type" << share->type() - << "but nfs type is" << Solid::NetworkShare::Nfs; - return false; - } - const Solid::StorageAccess *access = device.as(); - if( !access ) - { - debug() << __PRETTY_FUNCTION__ << device.udi() << "has no StorageAccess interface"; - return false; - } - if( !access->isAccessible() || access->filePath().isEmpty() ) - { - debug() << __PRETTY_FUNCTION__ << device.udi() << "is not accessible" - << "or has empty mount-point"; - return false; - } - return true; -} - -NfsDeviceHandlerFactory::~NfsDeviceHandlerFactory( ) -{ -} - -DeviceHandler * -NfsDeviceHandlerFactory::createHandler( KSharedConfigPtr, SqlStorage* ) const -{ - return 0; -} - -DeviceHandler * -NfsDeviceHandlerFactory::createHandler( const Solid::Device &device, const QString &udi, SqlStorage *s ) const -{ - DEBUG_BLOCK - if( !s ) - { - debug() << "!s, returning 0"; - return 0; - } - if( !canHandle( device ) ) - return 0; - - const Solid::StorageAccess *access = device.as(); - Q_ASSERT( access ); // canHandle() checks it - QString mountPoint = access->filePath(); - - const Solid::NetworkShare *netShare = device.as(); - Q_ASSERT( netShare ); // canHandle() checks it - QUrl url = netShare->url(); // nfs://thinkpad/test or nfs://thinkpad/ - QString server = url.host(); - QString share = url.path(); // leading slash is preserved for nfs shares - - QStringList ids = s->query( QString( "SELECT id, label, lastmountpoint " - "FROM devices WHERE type = 'nfs' " - "AND servername = '%1' AND sharename = '%2';" ) - .arg( s->escape( server ) ) - .arg( s->escape( share ) ) ); - if ( ids.size() == 3 ) - { - debug() << "Found existing NFS config for ID " << ids[0] << " , server " << server << " ,share " << share; - s->query( QString( "UPDATE devices SET lastmountpoint = '%2' WHERE " - "id = %1;" ) - .arg( ids[0] ) - .arg( s->escape( mountPoint ) ) ); - return new NfsDeviceHandler( ids[0].toInt(), server, share, mountPoint, udi ); - } - else - { - int id = s->insert( QString( "INSERT INTO devices" - "( type, servername, sharename, lastmountpoint ) " - "VALUES ( 'nfs', '%1', '%2', '%3' );" ) - .arg( s->escape( server ) ) - .arg( s->escape( share ) ) - .arg( s->escape( mountPoint ) ), - "devices" ); - if ( id == 0 ) - { - warning() << "Inserting into devices failed for type=nfs, server=" << server << ", share=" << share; - return 0; - } - debug() << "Created new NFS device with ID " << id << " , server " << server << " ,share " << share; - return new NfsDeviceHandler( id, server, share, mountPoint, udi ); - } -} diff --git a/amarok/src/core-impl/collections/db/sql/device/nfs/NfsDeviceHandler.h b/amarok/src/core-impl/collections/db/sql/device/nfs/NfsDeviceHandler.h deleted file mode 100644 index 702f8c1f..00000000 --- a/amarok/src/core-impl/collections/db/sql/device/nfs/NfsDeviceHandler.h +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2006-2007 Maximilian Kossick * - * Copyright (c) 2011 Peter C. Ndikuwera * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef NFSDEVICEHANDLER_H -#define NFSDEVICEHANDLER_H - -#include "core-impl/collections/db/MountPointManager.h" - -class NfsDeviceHandlerFactory : public DeviceHandlerFactory -{ -public: - NfsDeviceHandlerFactory( QObject *parent ) : DeviceHandlerFactory( parent ) {} - virtual ~NfsDeviceHandlerFactory(); - - virtual bool canHandle( const Solid::Device &device ) const; - - virtual bool canCreateFromMedium() const; - - virtual DeviceHandler* createHandler( const Solid::Device &device, const QString &uuid, SqlStorage *s ) const; - - virtual bool canCreateFromConfig() const; - - virtual DeviceHandler* createHandler( KSharedConfigPtr c, SqlStorage *s ) const; - - virtual QString type() const; -}; - -/** - @author Maximilian Kossick -*/ -class NfsDeviceHandler : public DeviceHandler -{ -public: - NfsDeviceHandler(); - NfsDeviceHandler(int deviceId, const QString &mountPoint, const QString &udi ); - NfsDeviceHandler(int deviceId, const QString &server, const QString &share, const QString &mountPoint, const QString &udi ); - - virtual ~NfsDeviceHandler(); - - virtual bool isAvailable() const; - virtual QString type() const; - virtual int getDeviceID( ); - virtual const QString &getDevicePath() const; - virtual void getURL( KUrl &absolutePath, const KUrl &relativePath ); - virtual void getPlayableURL( KUrl &absolutePath, const KUrl &relativePath ); - virtual bool deviceMatchesUdi( const QString &udi ) const; - -private: - - int m_deviceID; - QString m_server; - QString m_share; - const QString m_mountPoint; - QString m_udi; - -}; - -#endif diff --git a/amarok/src/core-impl/collections/db/sql/device/smb/SmbDeviceHandler.cpp b/amarok/src/core-impl/collections/db/sql/device/smb/SmbDeviceHandler.cpp deleted file mode 100644 index a6d8df28..00000000 --- a/amarok/src/core-impl/collections/db/sql/device/smb/SmbDeviceHandler.cpp +++ /dev/null @@ -1,206 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2006-2007 Maximilian Kossick * - * Copyright (c) 2011 Peter C. Ndikuwera * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "SmbDeviceHandler" - -#include "SmbDeviceHandler.h" - -#include "core/support/Debug.h" -#include - -#include -#include -#include -#include - -SmbDeviceHandler::SmbDeviceHandler( int deviceId, const QString &server, const QString &share, const QString &mountPoint, const QString &udi ) - : DeviceHandler() - , m_deviceID( deviceId ) - , m_server( server ) - , m_share( share ) - , m_mountPoint( mountPoint ) - , m_udi( udi ) -{ - DEBUG_BLOCK -} - -SmbDeviceHandler::SmbDeviceHandler( int deviceId, const QString &mountPoint, const QString &udi ) - : DeviceHandler() - , m_deviceID( deviceId ) - , m_mountPoint( mountPoint ) - , m_udi( udi ) -{ - DEBUG_BLOCK -} - -SmbDeviceHandler::~SmbDeviceHandler() -{ -} - -bool -SmbDeviceHandler::isAvailable() const -{ - return true; -} - - -QString -SmbDeviceHandler::type() const -{ - return "smb"; -} - -int -SmbDeviceHandler::getDeviceID() -{ - return m_deviceID; -} - -const QString &SmbDeviceHandler::getDevicePath() const -{ - return m_mountPoint; -} - -void SmbDeviceHandler::getURL( KUrl &absolutePath, const KUrl &relativePath ) -{ - absolutePath.setPath( m_mountPoint ); - absolutePath.addPath( relativePath.path() ); - absolutePath.cleanPath(); -} - -void SmbDeviceHandler::getPlayableURL( KUrl &absolutePath, const KUrl &relativePath ) -{ - getURL( absolutePath, relativePath ); -} - -bool SmbDeviceHandler::deviceMatchesUdi( const QString &udi ) const -{ - return m_udi == udi; -} - -/////////////////////////////////////////////////////////////////////////////// -// class SmbDeviceHandlerFactory -/////////////////////////////////////////////////////////////////////////////// - -QString SmbDeviceHandlerFactory::type( ) const -{ - return "smb"; -} - -bool SmbDeviceHandlerFactory::canCreateFromMedium( ) const -{ - return true; -} - -bool SmbDeviceHandlerFactory::canCreateFromConfig( ) const -{ - return false; -} - -bool SmbDeviceHandlerFactory::canHandle( const Solid::Device &device ) const -{ - const Solid::NetworkShare *share = device.as(); - if( !share ) - { - debug() << __PRETTY_FUNCTION__ << device.udi() << "has no NetworkShare interface"; - return false; - } - if( share->type() != Solid::NetworkShare::Cifs ) - { - debug() << __PRETTY_FUNCTION__ << device.udi() << "has type" << share->type() - << "but smbfs/cifs type is" << Solid::NetworkShare::Cifs; - return false; - } - const Solid::StorageAccess *access = device.as(); - if( !access ) - { - debug() << __PRETTY_FUNCTION__ << device.udi() << "has no StorageAccess interface"; - return false; - } - if( !access->isAccessible() || access->filePath().isEmpty() ) - { - debug() << __PRETTY_FUNCTION__ << device.udi() << "is not accessible" - << "or has empty mount-point"; - return false; - } - return true; -} - -SmbDeviceHandlerFactory::~SmbDeviceHandlerFactory( ) -{ -} - -DeviceHandler * -SmbDeviceHandlerFactory::createHandler( KSharedConfigPtr, SqlStorage* ) const -{ - return 0; -} - -DeviceHandler * -SmbDeviceHandlerFactory::createHandler( const Solid::Device &device, const QString &udi, SqlStorage *s ) const -{ - DEBUG_BLOCK - if( !s ) - { - debug() << "!s, returning 0"; - return 0; - } - if( !canHandle( device ) ) - return 0; - - const Solid::StorageAccess *access = device.as(); - Q_ASSERT( access ); // canHandle() checks it - QString mountPoint = access->filePath(); - - const Solid::NetworkShare *netShare = device.as(); - Q_ASSERT( netShare ); // canHandle() checks it - QUrl url = netShare->url(); // smb://testanot/share2 - QString server = url.host(); - QString share = url.path().mid( 1 ); // strip leading slash, not usual in smb shares - - QStringList ids = s->query( QString( "SELECT id, label, lastmountpoint " - "FROM devices WHERE type = 'smb' " - "AND servername = '%1' AND sharename = '%2';" ) - .arg( s->escape( server ) ) - .arg( s->escape( share ) ) ); - if ( ids.size() == 3 ) - { - debug() << "Found existing SMB config for ID " << ids[0] << " , server " << server << " ,share " << share; - s->query( QString( "UPDATE devices SET lastmountpoint = '%2' WHERE " - "id = %1;" ) - .arg( ids[0] ) - .arg( s->escape( mountPoint ) ) ); - return new SmbDeviceHandler( ids[0].toInt(), server, share, mountPoint, udi ); - } - else - { - int id = s->insert( QString( "INSERT INTO devices" - "( type, servername, sharename, lastmountpoint ) " - "VALUES ( 'smb', '%1', '%2', '%3' );" ) - .arg( s->escape( server ) ) - .arg( s->escape( share ) ) - .arg( s->escape( mountPoint ) ), - "devices" ); - if ( id == 0 ) - { - warning() << "Inserting into devices failed for type=smb, server=" << server << ", share=" << share; - return 0; - } - debug() << "Created new SMB device with ID " << id << " , server " << server << " ,share " << share; - return new SmbDeviceHandler( id, server, share, mountPoint, udi ); - } -} diff --git a/amarok/src/core-impl/collections/db/sql/device/smb/SmbDeviceHandler.h b/amarok/src/core-impl/collections/db/sql/device/smb/SmbDeviceHandler.h deleted file mode 100644 index c5a01038..00000000 --- a/amarok/src/core-impl/collections/db/sql/device/smb/SmbDeviceHandler.h +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2006-2007 Maximilian Kossick * - * Copyright (c) 2011 Peter C. Ndikuwera * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef SMBDEVICEHANDLER_H -#define SMBDEVICEHANDLER_H - -#include "core-impl/collections/db/MountPointManager.h" - -class SmbDeviceHandlerFactory : public DeviceHandlerFactory -{ -public: - SmbDeviceHandlerFactory( QObject *parent ) : DeviceHandlerFactory( parent ) {} - virtual ~SmbDeviceHandlerFactory(); - - virtual bool canHandle( const Solid::Device &device ) const; - - virtual bool canCreateFromMedium() const; - - virtual DeviceHandler* createHandler( const Solid::Device &device, const QString &uuid, SqlStorage *s ) const; - - virtual bool canCreateFromConfig() const; - - virtual DeviceHandler* createHandler( KSharedConfigPtr c, SqlStorage *s ) const; - - virtual QString type() const; -}; - -/** - @author Maximilian Kossick -*/ -class SmbDeviceHandler : public DeviceHandler -{ -public: - SmbDeviceHandler(); - SmbDeviceHandler(int deviceId, const QString &mountPoint, const QString &udi ); - SmbDeviceHandler(int deviceId, const QString &server, const QString &share, const QString &mountPoint, const QString &udi ); - - virtual ~SmbDeviceHandler(); - - virtual bool isAvailable() const; - virtual QString type() const; - virtual int getDeviceID( ); - virtual const QString &getDevicePath() const; - virtual void getURL( KUrl &absolutePath, const KUrl &relativePath ); - virtual void getPlayableURL( KUrl &absolutePath, const KUrl &relativePath ); - virtual bool deviceMatchesUdi( const QString &udi ) const; - -private: - - int m_deviceID; - QString m_server; - QString m_share; - const QString m_mountPoint; - QString m_udi; - -}; - -#endif diff --git a/amarok/src/core-impl/collections/db/sql/mysqlcollection/CMakeLists.txt b/amarok/src/core-impl/collections/db/sql/mysqlcollection/CMakeLists.txt deleted file mode 100644 index 244cde17..00000000 --- a/amarok/src/core-impl/collections/db/sql/mysqlcollection/CMakeLists.txt +++ /dev/null @@ -1,39 +0,0 @@ - -########### mysql ############### - -set( amarok_collection-mysqlcollection_PART_SRCS - MySqlCollectionFactory.cpp - MySqlQueryMaker.cpp -) - -kde4_add_plugin(amarok_collection-mysqlcollection ${amarok_collection-mysqlcollection_PART_SRCS}) - -STRING(REPLACE "-Wl,--fatal-warnings" "" CMAKE_SHARED_LINKER_FLAGS_NOFATALWARN "${CMAKE_SHARED_LINKER_FLAGS}") -SET(CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS_NOFATALWARN} ) - -STRING(REPLACE "-Wl,--fatal-warnings" "" CMAKE_MODULE_LINKER_FLAGS_NOFATALWARN "${CMAKE_MODULE_LINKER_FLAGS}") -SET(CMAKE_MODULE_LINKER_FLAGS ${CMAKE_MODULE_LINKER_FLAGS_NOFATALWARN} ) - -target_link_libraries(amarok_collection-mysqlcollection - amarok-sqlcollection - amarokcore - amaroklib - ${KDE4_KDECORE_LIBS} - ${QT_QTCORE_LIBRARY} - ${QT_QTGUI_LIBRARY} - ${MYSQL_EMBEDDED_LIBRARIES} - ${CMAKE_DL_LIBS} - ${ZLIB_LIBRARIES} -) - -if(NOT WIN32 AND NOT APPLE) - target_link_libraries( amarok_collection-mysqlcollection crypt pthread ) -endif(NOT WIN32 AND NOT APPLE) - -if(APPLE) - SET_TARGET_PROPERTIES(amarok_collection-mysqlcollection PROPERTIES LINK_FLAGS "-undefined dynamic_lookup") -endif(APPLE) - -install(TARGETS amarok_collection-mysqlcollection DESTINATION ${PLUGIN_INSTALL_DIR} ) - -install(FILES amarok_collection-mysqlcollection.desktop DESTINATION ${SERVICES_INSTALL_DIR}) diff --git a/amarok/src/core-impl/collections/db/sql/mysqlcollection/MySqlCollectionFactory.cpp b/amarok/src/core-impl/collections/db/sql/mysqlcollection/MySqlCollectionFactory.cpp deleted file mode 100644 index c878a67d..00000000 --- a/amarok/src/core-impl/collections/db/sql/mysqlcollection/MySqlCollectionFactory.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Edward Toroshchin * - * Copyright (c) 2009 Jeff Mitchell * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "MySqlCollectionFactory.h" - -#include -#include -#include - -#include - -using namespace Collections; - -AMAROK_EXPORT_COLLECTION( MySqlCollectionFactory, mysqlcollection ) - -void -MySqlCollectionFactory::init() -{ - if( m_initialized ) - return; - - SqlCollectionFactory fac; - SqlStorage *storage = StorageManager::instance()->sqlStorage(); - SqlCollection *collection = fac.createSqlCollection( storage ); - m_initialized = true; - - emit newCollection( collection ); -} - -#include "moc_MySqlCollectionFactory.cpp" diff --git a/amarok/src/core-impl/collections/db/sql/mysqlcollection/MySqlCollectionFactory.h b/amarok/src/core-impl/collections/db/sql/mysqlcollection/MySqlCollectionFactory.h deleted file mode 100644 index e97438b8..00000000 --- a/amarok/src/core-impl/collections/db/sql/mysqlcollection/MySqlCollectionFactory.h +++ /dev/null @@ -1,42 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Edward Toroshchin * - * Copyright (c) 2009 Jeff Mitchell * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_COLLECTION_MYSQLCOLLECTION_FACTORY_H -#define AMAROK_COLLECTION_MYSQLCOLLECTION_FACTORY_H - -#include "core/collections/Collection.h" - -namespace Collections { - -class MySqlCollectionFactory : public Collections::CollectionFactory -{ - Q_OBJECT - - public: - MySqlCollectionFactory( QObject *parent, const QVariantList &args ) - : Collections::CollectionFactory( parent, args ) - { - m_info = KPluginInfo( "amarok_collection-mysqlcollection.desktop", "services" ); - } - virtual ~MySqlCollectionFactory() {} - - virtual void init(); -}; - -} //namespace Collections - -#endif diff --git a/amarok/src/core-impl/collections/db/sql/mysqlcollection/MySqlQueryMaker.cpp b/amarok/src/core-impl/collections/db/sql/mysqlcollection/MySqlQueryMaker.cpp deleted file mode 100644 index d01bd59e..00000000 --- a/amarok/src/core-impl/collections/db/sql/mysqlcollection/MySqlQueryMaker.cpp +++ /dev/null @@ -1,34 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "MySqlQueryMaker.h" - -Collections::MySqlQueryMaker::MySqlQueryMaker( SqlCollection *collection ) - : SqlQueryMaker( collection ) -{ - //nothing to do -} - -Collections::MySqlQueryMaker::~MySqlQueryMaker() -{ - //nothing to do -} - -QString -Collections::MySqlQueryMaker::escape( QString text ) const // krazy:exclude=constref -{ - return text.replace("\\", "\\\\").replace( '\'', "''" ); -} diff --git a/amarok/src/core-impl/collections/db/sql/mysqlcollection/MySqlQueryMaker.h b/amarok/src/core-impl/collections/db/sql/mysqlcollection/MySqlQueryMaker.h deleted file mode 100644 index a30df13e..00000000 --- a/amarok/src/core-impl/collections/db/sql/mysqlcollection/MySqlQueryMaker.h +++ /dev/null @@ -1,38 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_COLLECTION_MYSQLQUERYMAKER_H -#define AMAROK_COLLECTION_MYSQLQUERYMAKER_H - -#include "../SqlCollection.h" -#include "../SqlQueryMaker.h" - -namespace Collections -{ - -class MySqlQueryMaker : public SqlQueryMaker -{ - public: - MySqlQueryMaker( SqlCollection* collection ); - virtual ~MySqlQueryMaker(); - - protected: - virtual QString escape( QString text ) const; -}; - -} - -#endif diff --git a/amarok/src/core-impl/collections/db/sql/mysqlcollection/amarok_collection-mysqlcollection.desktop b/amarok/src/core-impl/collections/db/sql/mysqlcollection/amarok_collection-mysqlcollection.desktop deleted file mode 100644 index 6716247d..00000000 --- a/amarok/src/core-impl/collections/db/sql/mysqlcollection/amarok_collection-mysqlcollection.desktop +++ /dev/null @@ -1,94 +0,0 @@ -[Desktop Entry] -Type=Service -Icon=server-database -Name=MySQL Collection -Name[ca]=Col·lecció MySQL -Name[cs]=Sbírka MySQL -Name[en_GB]=MySQL Collection -Name[fi]=MySQL-kokoelma -Name[it]=Collezione MySQL -Name[nl]=MySQL-verzameling -Name[pl]=Zbiór MySQL -Name[pt]=Colecção de MySQL -Name[pt_BR]=Coleção MySQL -Name[sv]=MySQL-anslutning -Name[uk]=Збірка MySQL -Name[x-test]=xxMySQL Collectionxx -Comment=Collection plugin for Amarok -Comment[be]=Утулка калекцыі для Amarok -Comment[bg]=Приставка за колекция (Amarok) -Comment[bs]=Priključak zbirke za Amarok -Comment[ca]=Connector de col·leccions per a l'Amarok -Comment[ca@valencia]=Connector de col·leccions per a l'Amarok -Comment[cs]=Modul sbírky pro Amarok -Comment[csb]=Wtëkôcz kòlekcëji dlô Amaroka -Comment[da]=Samlings-plugin til Amarok -Comment[de]=Sammlungsmodul für Amarok -Comment[el]=Πρόσθετο συλλογής για το AmaroK -Comment[en_GB]=Collection plugin for Amarok -Comment[eo]=Kolekta kromaĵo por Amarok -Comment[es]=Complemento de colección para Amarok -Comment[et]=Amaroki muusikakogu plugin -Comment[eu]=Bildumen plugina Amarok-entzako -Comment[fi]=Amarokin kokoelmaliitännäinen -Comment[fr]=Module externe de collections pour Amarok -Comment[ga]=Breiseán bailiúchán le haghaidh Amarok -Comment[gl]=Extensión de colección para Amarok -Comment[he]=תוסף אוסף ל־Amarok -Comment[hne]=अमाराक बर संग्रह प्लगइन -Comment[hu]=Gyűjtemény-bővítőmodul az Amarokhoz -Comment[id]=Koleksi plugin untuk Amarok -Comment[is]=Safníforrit fyrir Amarok -Comment[it]=Estensione della collezione di Amarok -Comment[ja]=Amarok のためのコレクションプラグイン -Comment[km]=កម្មវិធី​ជំនួយ​សម្រាំង​សម្រាប់​ Amarok -Comment[ko]=Amarok의 모음집 플러그인 -Comment[ku]=Pêveka berhevokê ji bo Amarok -Comment[lt]=Fonotekos Amarok papildinys -Comment[lv]=Kolekciju Amarok spraudnis -Comment[nb]=SQL-samling – programtillegg for Amarok -Comment[nds]=Sammelnmoduul för Amarok -Comment[ne]=अमारोकका लागि सङ्कलन प्लगइन -Comment[nl]=Collectie-plugin voor Amarok -Comment[nn]=Amarok-samlingstillegg -Comment[pa]=ਅਮਰੋਕ ਲਈ ਭੰਡਾਰ ਪਲੱਗਇਨ -Comment[pl]=Wtyczka kolekcji dla Amaroka -Comment[pt]=Um 'plugin' da colecção para o Amarok -Comment[pt_BR]=Plugin de coleção para o Amarok -Comment[ro]=Modul de colecție pentru Amarok -Comment[ru]=Модуль коллекции для Amarok -Comment[sk]=Modul kolekcia pre Amarok -Comment[sl]=Vstavek za zbirko za Amarok -Comment[sr]=Прикључак збирке за Амарок -Comment[sr@ijekavian]=Прикључак збирке за Амарок -Comment[sr@ijekavianlatin]=Priključak zbirke za Amarok -Comment[sr@latin]=Priključak zbirke za Amarok -Comment[sv]=Samlingsinsticksprogram för Amarok -Comment[th]=ส่วนเสริมของแอมอะร็อก สำหรับจัดการคลังสื่อ -Comment[tr]=Amarok için Koleksiyon eklentisi -Comment[uk]=Додаток збірки для Amarok -Comment[wa]=Tchôke-divins di ramexhnêye pos Amarok -Comment[x-test]=xxCollection plugin for Amarokxx -Comment[zh_CN]=Amarok 的收藏插件 -Comment[zh_TW]=Amarok 的收藏外掛程式 -NoDisplay=true - -ServiceTypes=Amarok/Plugin - -X-KDE-Amarok-authors=Maximilian Kossick -X-KDE-Amarok-email=maximilian.kossick@googlemail.com -X-KDE-Amarok-framework-version=72 -X-KDE-Amarok-name=mysql-collection -X-KDE-Amarok-plugintype=collection -X-KDE-Amarok-rank=100 -X-KDE-Amarok-version=1 -X-KDE-Amarok-vital=true - -X-KDE-PluginInfo-Author=Maximilian Kossick -X-KDE-PluginInfo-Email=maximilian.kossick@googlemail.com -X-KDE-PluginInfo-Version=1.0 -X-KDE-PluginInfo-Category=Collection -X-KDE-PluginInfo-License=GPL -X-KDE-PluginInfo-EnabledByDefault=true -X-KDE-PluginInfo-Name=amarok_collection-mysqlcollection -X-KDE-Library=amarok_collection-mysqlcollection diff --git a/amarok/src/core-impl/collections/ipodcollection/CMakeLists.txt b/amarok/src/core-impl/collections/ipodcollection/CMakeLists.txt deleted file mode 100644 index 484d58f4..00000000 --- a/amarok/src/core-impl/collections/ipodcollection/CMakeLists.txt +++ /dev/null @@ -1,78 +0,0 @@ -if(NOT GDKPIXBUF_FOUND) - set(GDKPIXBUF_INCLUDE_DIR "") - set(GDKPIXBUF_LIBRARY "") -endif(NOT GDKPIXBUF_FOUND) - -if(IPOD_FOUND AND WITH_IPOD) - - include_directories( - ${CMAKE_BINARY_DIR}/src - - ${KDE4_INCLUDE_DIR} - ${QT_INCLUDES} - - ${GLIB2_INCLUDE_DIR} - ${GDKPIXBUF_INCLUDE_DIR} - ${GOBJECT_INCLUDE_DIR} - ${IPOD_INCLUDE_DIRS} - ) - - ########### set macros for the ipod collection plugin ########## - # Generate config-ipodcollection.h - configure_file(config-ipodcollection.h.cmake - ${CMAKE_CURRENT_BINARY_DIR}/config-ipodcollection.h - ) - - ########### next target ################ - set(amarok_collection-ipodcollection_PART_SRCS - IpodCollection.cpp - IpodCollectionFactory.cpp - IpodCollectionLocation.cpp - IpodMeta.cpp - IpodPlaylist.cpp - IpodPlaylistProvider.cpp - jobs/IpodCopyTracksJob.cpp - jobs/IpodDeleteTracksJob.cpp - jobs/IpodParseTracksJob.cpp - jobs/IpodWriteDatabaseJob.cpp - IphoneMountPoint.cpp - IpodDeviceHelper.cpp - IpodTranscodeCapability.cpp - IpodConfiguration.ui - ) - - link_directories(${IPOD_LIBRARY_DIRS}) - - kde4_add_plugin(amarok_collection-ipodcollection ${amarok_collection-ipodcollection_PART_SRCS}) - - target_link_libraries(amarok_collection-ipodcollection - amarokshared - amarokcore - amaroklib - amarok-transcoding - ${KDE4_KDECORE_LIBS} - ${KDE4_KIO_LIBS} - ${KDE4_SOLID_LIBRARY} - ${KDE4_THREADWEAVER_LIBS} - ${QT_QTGUI_LIBRARY} - ${GLIB2_LIBRARIES} - ${GDKPIXBUF_LIBRARY} - ${GOBJECT_LIBRARIES} - ${IPOD_LIBRARIES} - ) - - install(TARGETS - amarok_collection-ipodcollection - DESTINATION - ${PLUGIN_INSTALL_DIR} - ) - - ########### install files ############### - - install(FILES - amarok_collection-ipodcollection.desktop - DESTINATION - ${SERVICES_INSTALL_DIR} - ) - -endif( IPOD_FOUND AND WITH_IPOD ) diff --git a/amarok/src/core-impl/collections/ipodcollection/IphoneMountPoint.cpp b/amarok/src/core-impl/collections/ipodcollection/IphoneMountPoint.cpp deleted file mode 100644 index cbf6e847..00000000 --- a/amarok/src/core-impl/collections/ipodcollection/IphoneMountPoint.cpp +++ /dev/null @@ -1,156 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Martin Aumueller * - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "IphoneMountPoint.h" - -#include "core/support/Debug.h" - -#include -#include -#include - -#include -#include - - -IphoneMountPoint::IphoneMountPoint( const QString &uuid ) -{ - QString mountPointCandidate = constructMountpoint( uuid ); - QStringList checkedDirs; // see itdb_get_control_dir (const gchar *mountpoint) - checkedDirs << "/iTunes_Control"; - checkedDirs << "/iPod_Control"; - checkedDirs << "/iTunes/iTunes_Control"; - foreach( const QString &dir, checkedDirs ) - { - if( QFile::exists( mountPointCandidate + dir ) ) - { - logMessage( QString( "%1 exists, assuming iPhone is already mounted" ).arg( dir ) ); - m_mountPoint = mountPointCandidate; - return; - } - } - - QStringList args; - if( !uuid.isEmpty() ) - // good change here: --uuid option was renamed to --udid with ifuse-1.1.2, the - // short option, -u, fortunately remained the same - args << "-u" << uuid << QString( "-ofsname=afc://%1" ).arg( uuid ); - args << mountPointCandidate; - if( !call( "ifuse", args ) ) - { - logMessage( QString( "Failed to mount iPhone on %1" ).arg( mountPointCandidate ) ); - KMessageBox::detailedSorry( 0, i18n( "Connecting to iPhone, iPad or iPod touch failed."), - failureDetails() ); - return; - } - logMessage( QString( "Successfully mounted iPhone on %1" ).arg( mountPointCandidate ) ); - m_mountPoint = mountPointCandidate; - -} - -IphoneMountPoint::~IphoneMountPoint() -{ - if( m_mountPoint.isEmpty() ) - return; // easy, nothing to do - - logMessage( "" ); // have a line between constructor and destructor messages - - if( !call( "fusermount", QStringList() << "-u" << "-z" << m_mountPoint ) ) - { - logMessage( QString( "Failed to unmount iPhone from %1" ).arg( m_mountPoint ) ); - return; - } - logMessage( QString( "Successfully unmounted iPhone from %1" ).arg( m_mountPoint ) ); - - if( QDir( mountPoint() ).rmpath( "." ) ) - logMessage( QString( "Deleted %1 directory and empty parent directories" ).arg( m_mountPoint ) ); - else - logMessage( QString( "Failed to delete %1 directory" ).arg( m_mountPoint ) ); -} - -QString -IphoneMountPoint::mountPoint() const -{ - return m_mountPoint; -} - -QString IphoneMountPoint::failureDetails() const -{ - return m_messages.join( "
    \n" ); -} - -QString -IphoneMountPoint::constructMountpoint( const QString &uuid ) -{ - QString mountPointCandidate = KStandardDirs::locateLocal( "tmp", "amarok/" ); - mountPointCandidate += "imobiledevice"; - if( !uuid.isEmpty() ) - mountPointCandidate += "_uuid_" + uuid; - logMessage( QString( "determined mount-point path to %1" ).arg( mountPointCandidate ) ); - - QDir mp( mountPointCandidate ); - if( !mp.exists() ) - { - mp.mkpath( mountPointCandidate ); - logMessage( QString( "created %1 directory" ).arg( mountPointCandidate ) ); - } - return mountPointCandidate; -} - -bool IphoneMountPoint::call( const QString &command, const QStringList &arguments, int timeout ) -{ - QProcess process; - process.setProcessChannelMode( QProcess::MergedChannels ); - logMessage( QString( "calling `%1 \"%2\"` with timeout of %3s" ).arg( command, arguments.join( "\" \"" ) ).arg( timeout/1000.0 ) ); - process.start( command, arguments ); - - if( !process.waitForStarted( timeout ) ) - { - logMessage( "command failed to start within timeout" ); - return false; - } - if( !process.waitForFinished( timeout ) ) - { - logMessage( "command failed to finish within timeout" ); - return false; - } - - QByteArray output( process.readAllStandardOutput() ); - foreach( const QString &line, QString::fromLocal8Bit( output ).split( QChar( '\n' ) ) ) - { - logMessage( QString("%1: %2").arg( command, line ) ); - } - - if( process.exitStatus() != QProcess::NormalExit ) - { - logMessage( "command crashed" ); - return false; - } - if( process.exitCode() != 0 ) - { - logMessage( QString( "command exited with non-zero return code %1" ).arg( process.exitCode() ) ); - return false; - } - return true; -} - -void IphoneMountPoint::logMessage( const QString &message ) -{ - m_messages << message; - if( !message.isEmpty() ) - debug() << "IpodCollection: IphoneMountPoint:" << message.toLocal8Bit().constData(); -} diff --git a/amarok/src/core-impl/collections/ipodcollection/IphoneMountPoint.h b/amarok/src/core-impl/collections/ipodcollection/IphoneMountPoint.h deleted file mode 100644 index 9d5a1555..00000000 --- a/amarok/src/core-impl/collections/ipodcollection/IphoneMountPoint.h +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef IPHONEMOUNTPOINT_H -#define IPHONEMOUNTPOINT_H - -#include -#include - - -/** - * An automatic iPhone/iPad mountpoint that tries to mount the device using ifuse in - * constructor and to unmount it in destructor. - */ -class IphoneMountPoint -{ - public: - /** - * Mount iPhone/iPad device by its 40-digit device UUID or mount any connected - * iPhone/iPad if @param uuid is empty. - */ - IphoneMountPoint( const QString &uuid ); - ~IphoneMountPoint(); - - /** - * Get location where iPhone was mounted to. If empty, mounting the iPhone failed. - */ - QString mountPoint() const; - - /** - * Return a rather long string describing mount failure. - */ - QString failureDetails() const; - - private: - Q_DISABLE_COPY(IphoneMountPoint) - - /** - * Creates unique directory for mounting iPhone under temporary directory - */ - QString constructMountpoint( const QString &uuid ); - - /** - * Calls command, logs the call and any errors using logMessage(), returns true - * if the command executed and returned successfully, false otherwise. - * - * @param timeout timeot of starting, waiting for process finished, etc. in milliseconds - */ - bool call( const QString &command, const QStringList &arguments, int timeout = 10000 ); - - /** - * Log message to debugging output and to m_messages - */ - void logMessage( const QString &message ); - - QString m_mountPoint; - QStringList m_messages; -}; - -#endif // IPHONEMOUNTPOINT_H diff --git a/amarok/src/core-impl/collections/ipodcollection/IpodCollection.cpp b/amarok/src/core-impl/collections/ipodcollection/IpodCollection.cpp deleted file mode 100644 index 53803588..00000000 --- a/amarok/src/core-impl/collections/ipodcollection/IpodCollection.cpp +++ /dev/null @@ -1,701 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "IpodCollection.h" - -#include "IpodCollectionLocation.h" -#include "IpodMeta.h" -#include "IpodPlaylistProvider.h" -#include "jobs/IpodWriteDatabaseJob.h" -#include "jobs/IpodParseTracksJob.h" -#include "IphoneMountPoint.h" -#include "IpodDeviceHelper.h" -#include "IpodTranscodeCapability.h" - -#include "core/capabilities/ActionsCapability.h" -#include "core/interfaces/Logger.h" -#include "core/support/Components.h" -#include "core/support/Debug.h" -#include "core-impl/collections/support/MemoryCollection.h" -#include "core-impl/collections/support/MemoryMeta.h" -#include "core-impl/collections/support/MemoryQueryMaker.h" -#include "playlistmanager/PlaylistManager.h" - -#include -#include -#include -#include -#include - -#include -#include - -#include - - -const QString IpodCollection::s_uidUrlProtocol = QString( "amarok-ipodtrackuid" ); -const QStringList IpodCollection::s_audioFileTypes = QStringList() << "mp3" << "aac" - << "m4a" /* MPEG-4 AAC and also ALAC */ << "m4b" /* audiobook */ << "aiff" << "wav"; -const QStringList IpodCollection::s_videoFileTypes = QStringList() << "m4v" << "mov"; -const QStringList IpodCollection::s_audioVideoFileTypes = QStringList() << "mp4"; - -IpodCollection::IpodCollection( const QDir &mountPoint, const QString &uuid ) - : Collections::Collection() - , m_configureDialog( 0 ) - , m_mc( new Collections::MemoryCollection() ) - , m_itdb( 0 ) - , m_lastUpdated( 0 ) - , m_preventUnmountTempFile( 0 ) - , m_mountPoint( mountPoint.absolutePath() ) - , m_uuid( uuid ) - , m_iphoneAutoMountpoint( 0 ) - , m_playlistProvider( 0 ) - , m_configureAction( 0 ) - , m_ejectAction( 0 ) - , m_consolidateAction( 0 ) -{ - DEBUG_BLOCK - if( m_uuid.isEmpty() ) - m_uuid = m_mountPoint; -} - -IpodCollection::IpodCollection( const QString &uuid ) - : Collections::Collection() - , m_configureDialog( 0 ) - , m_mc( new Collections::MemoryCollection() ) - , m_itdb( 0 ) - , m_lastUpdated( 0 ) - , m_preventUnmountTempFile( 0 ) - , m_uuid( uuid ) - , m_playlistProvider( 0 ) - , m_configureAction( 0 ) - , m_ejectAction( 0 ) - , m_consolidateAction( 0 ) -{ - DEBUG_BLOCK - // following constructor displays sorry message if it cannot mount iPhone: - m_iphoneAutoMountpoint = new IphoneMountPoint( uuid ); - m_mountPoint = m_iphoneAutoMountpoint->mountPoint(); - if( m_uuid.isEmpty() ) - m_uuid = m_mountPoint; -} - -bool IpodCollection::init() -{ - if( m_mountPoint.isEmpty() ) - return false; // we have already displayed sorry message - - m_updateTimer.setSingleShot( true ); - connect( this, SIGNAL(startUpdateTimer()), SLOT(slotStartUpdateTimer()) ); - connect( &m_updateTimer, SIGNAL(timeout()), SLOT(collectionUpdated()) ); - - m_writeDatabaseTimer.setSingleShot( true ); - connect( this, SIGNAL(startWriteDatabaseTimer()), SLOT(slotStartWriteDatabaseTimer()) ); - connect( &m_writeDatabaseTimer, SIGNAL(timeout()), SLOT(slotInitiateDatabaseWrite()) ); - - m_configureAction = new QAction( KIcon( "configure" ), i18n( "&Configure Device" ), this ); - m_configureAction->setProperty( "popupdropper_svg_id", "configure" ); - connect( m_configureAction, SIGNAL(triggered()), SLOT(slotShowConfigureDialog()) ); - - m_ejectAction = new QAction( KIcon( "media-eject" ), i18n( "&Eject Device" ), this ); - m_ejectAction->setProperty( "popupdropper_svg_id", "eject" ); - connect( m_ejectAction, SIGNAL(triggered()), SLOT(slotEject()) ); - - QString parseErrorMessage; - m_itdb = IpodDeviceHelper::parseItdb( m_mountPoint, parseErrorMessage ); - m_prettyName = IpodDeviceHelper::collectionName( m_itdb ); // allows null m_itdb - - // m_consolidateAction is used by the provider - m_consolidateAction = new QAction( KIcon( "dialog-ok-apply" ), i18n( "Re-add orphaned and forget stale tracks" ), this ); - // provider needs to be up before IpodParseTracksJob is started - m_playlistProvider = new IpodPlaylistProvider( this ); - connect( m_playlistProvider, SIGNAL(startWriteDatabaseTimer()), SIGNAL(startWriteDatabaseTimer()) ); - connect( m_consolidateAction, SIGNAL(triggered()), m_playlistProvider, SLOT(slotConsolidateStaleOrphaned()) ); - The::playlistManager()->addProvider( m_playlistProvider, m_playlistProvider->category() ); - - if( m_itdb ) - { - // parse tracks in a thread in order not to block main thread - IpodParseTracksJob *job = new IpodParseTracksJob( this ); - m_parseTracksJob = job; - connect( job, SIGNAL(done(ThreadWeaver::Job*)), job, SLOT(deleteLater()) ); - ThreadWeaver::Weaver::instance()->enqueue( job ); - } - else - slotShowConfigureDialog( parseErrorMessage ); // shows error message and allows initializing - - return true; // we have found iPod, even if it might not be initialised -} - -IpodCollection::~IpodCollection() -{ - DEBUG_BLOCK - The::playlistManager()->removeProvider( m_playlistProvider ); - - // this is not racy: destructor should be called in a main thread, the timer fires in the - // same thread - if( m_writeDatabaseTimer.isActive() ) - { - m_writeDatabaseTimer.stop(); - // call directly from main thread in destructor, we have no other chance: - writeDatabase(); - } - delete m_preventUnmountTempFile; // this should have been certaily 0, but why not - m_preventUnmountTempFile = 0; - - /* because m_itdb takes ownership of the tracks added to it, we need to remove the - * tracks from itdb before we delete it because in Amarok, IpodMeta::Track is the owner - * of the track */ - IpodDeviceHelper::unlinkPlaylistsTracksFromItdb( m_itdb ); // does nothing if m_itdb is null - itdb_free( m_itdb ); // does nothing if m_itdb is null - m_itdb = 0; - - delete m_configureDialog; - delete m_iphoneAutoMountpoint; // this can unmount iPhone and remove temporary dir -} - -bool -IpodCollection::possiblyContainsTrack( const KUrl &url ) const -{ - return url.toLocalFile().startsWith( m_mountPoint ); -} - -Meta::TrackPtr -IpodCollection::trackForUrl( const KUrl &url ) -{ - QString relativePath = url.toLocalFile().mid( m_mountPoint.size() + 1 ); - QString uidUrl = QString( "%1/%2" ).arg( collectionId(), relativePath ); - return trackForUidUrl( uidUrl ); -} - -bool -IpodCollection::hasCapabilityInterface( Capabilities::Capability::Type type ) const -{ - switch( type ) - { - case Capabilities::Capability::Actions: - case Capabilities::Capability::Transcode: - return true; - default: - break; - } - return false; -} - -Capabilities::Capability* -IpodCollection::createCapabilityInterface( Capabilities::Capability::Type type ) -{ - switch( type ) - { - case Capabilities::Capability::Actions: - { - QList actions; - if( m_configureAction ) - actions << m_configureAction; - if( m_ejectAction ) - actions << m_ejectAction; - if( m_consolidateAction && m_playlistProvider && m_playlistProvider->hasStaleOrOrphaned() ) - actions << m_consolidateAction; - return new Capabilities::ActionsCapability( actions ); - } - case Capabilities::Capability::Transcode: - { - gchar *deviceDirChar = itdb_get_device_dir( QFile::encodeName( m_mountPoint ) ); - QString deviceDir = QFile::decodeName( deviceDirChar ); - g_free( deviceDirChar ); - return new Capabilities::IpodTranscodeCapability( this, deviceDir ); - } - default: - break; - } - return 0; -} - -Collections::QueryMaker* -IpodCollection::queryMaker() -{ - return new Collections::MemoryQueryMaker( m_mc.toWeakRef(), collectionId() ); -} - -QString -IpodCollection::uidUrlProtocol() const -{ - return s_uidUrlProtocol; -} - -QString -IpodCollection::collectionId() const -{ - return QString( "%1://%2" ).arg( s_uidUrlProtocol, m_uuid ); -} - -QString -IpodCollection::prettyName() const -{ - return m_prettyName; -} - -KIcon -IpodCollection::icon() const -{ - return KIcon("multimedia-player-apple-ipod"); -} - -bool -IpodCollection::hasCapacity() const -{ - return KDiskFreeSpaceInfo::freeSpaceInfo( m_mountPoint ).isValid(); -} - -float -IpodCollection::usedCapacity() const -{ - return KDiskFreeSpaceInfo::freeSpaceInfo( m_mountPoint ).used(); -} - -float -IpodCollection::totalCapacity() const -{ - return KDiskFreeSpaceInfo::freeSpaceInfo( m_mountPoint ).size(); -} - -Collections::CollectionLocation* -IpodCollection::location() -{ - return new IpodCollectionLocation( QWeakPointer( this ) ); -} - -bool -IpodCollection::isWritable() const -{ - return IpodDeviceHelper::safeToWrite( m_mountPoint, m_itdb ); // returns false if m_itdb is null -} - -bool -IpodCollection::isOrganizable() const -{ - return false; // iPods are never organizable -} - -void -IpodCollection::metadataChanged( Meta::TrackPtr track ) -{ - // reflect change to ouside world: - bool mapsChanged = MemoryMeta::MapChanger( m_mc.data() ).trackChanged( track ); - if( mapsChanged ) - // while docs say somehting different, collection browser doesn't update unless we emit updated() - emit startUpdateTimer(); - emit startWriteDatabaseTimer(); -} - -QString -IpodCollection::mountPoint() -{ - return m_mountPoint; -} - -float -IpodCollection::capacityMargin() const -{ - return 20*1024*1024; // 20 MiB -} - -QStringList -IpodCollection::supportedFormats() const -{ - QStringList ret( s_audioFileTypes ); - if( m_itdb && itdb_device_supports_video( m_itdb->device ) ) - ret << s_videoFileTypes << s_audioVideoFileTypes; - return ret; -} - -Playlists::UserPlaylistProvider* -IpodCollection::playlistProvider() const -{ - return m_playlistProvider; -} - -Meta::TrackPtr -IpodCollection::trackForUidUrl( const QString &uidUrl ) -{ - m_mc->acquireReadLock(); - Meta::TrackPtr ret = m_mc->trackMap().value( uidUrl, Meta::TrackPtr() ); - m_mc->releaseLock(); - return ret; -} - -void -IpodCollection::slotDestroy() -{ - // guard against user hitting the button twice or hitting it while there is another - // write database job alreaddy running - if( m_writeDatabaseJob ) - { - IpodWriteDatabaseJob *job = m_writeDatabaseJob.data(); - // don't create duplicate connections: - disconnect( job, SIGNAL(destroyed(QObject*)), this, SLOT(slotRemove()) ); - disconnect( job, SIGNAL(destroyed(QObject*)), this, SLOT(slotPerformTeardownAndRemove()) ); - connect( job, SIGNAL(destroyed(QObject*)), SLOT(slotRemove()) ); - } - // this is not racy: slotDestroy() is delivered to main thread, the timer fires in the - // same thread - else if( m_writeDatabaseTimer.isActive() ) - { - // write database in a thread so that it need not be written in destructor - m_writeDatabaseTimer.stop(); - IpodWriteDatabaseJob *job = new IpodWriteDatabaseJob( this ); - m_writeDatabaseJob = job; - connect( job, SIGNAL(done(ThreadWeaver::Job*)), job, SLOT(deleteLater()) ); - connect( job, SIGNAL(destroyed(QObject*)), SLOT(slotRemove()) ); - ThreadWeaver::Weaver::instance()->enqueue( job ); - } - else - slotRemove(); -} - -void -IpodCollection::slotEject() -{ - // guard against user hitting the button twice or hitting it while there is another - // write database job alreaddy running - if( m_writeDatabaseJob ) - { - IpodWriteDatabaseJob *job = m_writeDatabaseJob.data(); - // don't create duplicate connections: - disconnect( job, SIGNAL(destroyed(QObject*)), this, SLOT(slotRemove()) ); - disconnect( job, SIGNAL(destroyed(QObject*)), this, SLOT(slotPerformTeardownAndRemove()) ); - connect( job, SIGNAL(destroyed(QObject*)), SLOT(slotPerformTeardownAndRemove()) ); - } - // this is not racy: slotEject() is delivered to main thread, the timer fires in the - // same thread - else if( m_writeDatabaseTimer.isActive() ) - { - // write database now because iPod will be already unmounted in destructor - m_writeDatabaseTimer.stop(); - IpodWriteDatabaseJob *job = new IpodWriteDatabaseJob( this ); - m_writeDatabaseJob = job; - connect( job, SIGNAL(done(ThreadWeaver::Job*)), job, SLOT(deleteLater()) ); - connect( job, SIGNAL(destroyed(QObject*)), SLOT(slotPerformTeardownAndRemove()) ); - ThreadWeaver::Weaver::instance()->enqueue( job ); - } - else - slotPerformTeardownAndRemove(); -} - -void -IpodCollection::slotShowConfigureDialog( const QString &errorMessage ) -{ - if( !m_configureDialog ) - { - // create the dialog - m_configureDialog = new KDialog(); - QWidget *settingsWidget = new QWidget( m_configureDialog ); - m_configureDialogUi.setupUi( settingsWidget ); - - m_configureDialog->setButtons( KDialog::Ok | KDialog::Cancel ); - m_configureDialog->setMainWidget( settingsWidget ); - m_configureDialog->setWindowTitle( settingsWidget->windowTitle() ); // setupUi() sets this - if( m_itdb ) - { - // we will never initialize this iPod this time, hide ui for it completely - m_configureDialogUi.modelComboLabel->hide(); - m_configureDialogUi.modelComboBox->hide(); - m_configureDialogUi.initializeLabel->hide(); - m_configureDialogUi.initializeButton->hide(); - } - - connect( m_configureDialogUi.initializeButton, SIGNAL(clicked(bool)), SLOT(slotInitialize()) ); - connect( m_configureDialog, SIGNAL(okClicked()), SLOT(slotApplyConfiguration()) ); - } - QScopedPointer tc( create() ); - IpodDeviceHelper::fillInConfigureDialog( m_configureDialog, &m_configureDialogUi, - m_mountPoint, m_itdb, tc->savedConfiguration(), - errorMessage ); - - // don't allow to resize the dialog too small: - m_configureDialog->setMinimumSize( m_configureDialog->sizeHint() ); - m_configureDialog->show(); - m_configureDialog->raise(); -} - -void IpodCollection::collectionUpdated() -{ - m_lastUpdated = QDateTime::currentMSecsSinceEpoch(); - emit updated(); -} - -void -IpodCollection::slotInitialize() -{ - if( m_itdb ) - return; // why the hell we were called? - - m_configureDialogUi.initializeButton->setEnabled( false ); - QString errorMessage; - bool success = IpodDeviceHelper::initializeIpod( m_mountPoint, &m_configureDialogUi, errorMessage ); - if( !success ) - { - slotShowConfigureDialog( errorMessage ); - return; - } - - errorMessage.clear(); - m_itdb = IpodDeviceHelper::parseItdb( m_mountPoint, errorMessage ); - m_prettyName = IpodDeviceHelper::collectionName( m_itdb ); // allows null m_itdb - - if( m_itdb ) - { - QScopedPointer tc( create() ); - errorMessage = i18nc( "iPod was successfully initialized", "Initialization successful." ); - // so that the buttons are re-enabled, info filled etc: - IpodDeviceHelper::fillInConfigureDialog( m_configureDialog, &m_configureDialogUi, - m_mountPoint, m_itdb, tc->savedConfiguration(), errorMessage ); - - // there will be probably 0 tracks, but it may do more in future, for example stale - // & orphaned track search. - IpodParseTracksJob *job = new IpodParseTracksJob( this ); - connect( job, SIGNAL(done(ThreadWeaver::Job*)), job, SLOT(deleteLater()) ); - ThreadWeaver::Weaver::instance()->enqueue( job ); - } - else - slotShowConfigureDialog( errorMessage ); // shows error message and allows initializing -} - -void -IpodCollection::slotApplyConfiguration() -{ - if( !isWritable() ) - return; // we can do nothing if we are not writeable - - QString newName = m_configureDialogUi.nameLineEdit->text(); - if( !newName.isEmpty() && newName != IpodDeviceHelper::ipodName( m_itdb ) ) - { - IpodDeviceHelper::setIpodName( m_itdb, newName ); - m_prettyName = IpodDeviceHelper::collectionName( m_itdb ); - emit startWriteDatabaseTimer(); // the change should be written down to the database - emit startUpdateTimer(); - } - - QScopedPointer tc( create() ); - tc->setSavedConfiguration( m_configureDialogUi.transcodeComboBox->currentChoice() ); -} - -void -IpodCollection::slotStartUpdateTimer() -{ - // there are no concurrency problems, this method can only be called from the main - // thread and that's where the timer fires - if( m_updateTimer.isActive() ) - return; // already running, nothing to do - - // number of milliseconds to next desired update, may be negative - int timeout = m_lastUpdated + 1000 - QDateTime::currentMSecsSinceEpoch(); - // give at least 50 msecs to catch multi-tracks edits nicely on the first frame - m_updateTimer.start( qBound( 50, timeout, 1000 ) ); -} - -void -IpodCollection::slotStartWriteDatabaseTimer() -{ - m_writeDatabaseTimer.start( 30000 ); - // ensure we have a file on iPod open that prevents unmounting it if db is dirty - if( !m_preventUnmountTempFile ) - { - m_preventUnmountTempFile = new QTemporaryFile(); - QString name( "/.itunes_database_dirty_in_amarok_prevent_unmounting" ); - m_preventUnmountTempFile->setFileTemplate( m_mountPoint + name ); - m_preventUnmountTempFile->open(); - } -} - -void IpodCollection::slotInitiateDatabaseWrite() -{ - if( m_writeDatabaseJob ) - { - warning() << __PRETTY_FUNCTION__ << "called while m_writeDatabaseJob still points" - << "to an older job. Not doing anyhing."; - return; - } - IpodWriteDatabaseJob *job = new IpodWriteDatabaseJob( this ); - m_writeDatabaseJob = job; - connect( job, SIGNAL(done(ThreadWeaver::Job*)), job, SLOT(deleteLater()) ); - ThreadWeaver::Weaver::instance()->enqueue( job ); -} - -void IpodCollection::slotPerformTeardownAndRemove() -{ - /* try to eject the device from system. Following technique potentially catches more - * cases than simply passing the udi from IpodCollectionFactory, think of fuse-based - * filesystems for mounting iPhones et caetera.. */ - Solid::Predicate query( Solid::DeviceInterface::StorageAccess, QString( "filePath" ), - m_mountPoint ); - QList devices = Solid::Device::listFromQuery( query ); - if( devices.count() == 1 ) - { - Solid::Device device = devices.at( 0 ); - Solid::StorageAccess *ssa = device.as(); - if( ssa ) - ssa->teardown(); - } - - slotRemove(); -} - -void IpodCollection::slotRemove() -{ - // this is not racy, we are in the main thread and parseTracksJob can be deleted only - // in the main thread - if( m_parseTracksJob ) - { - // we need to wait until parseTracksJob finishes, because it acceses IpodCollection - // and IpodPlaylistProvider in an asynchronous way that cannot safely cope with - // IpodCollection disappearing - connect( m_parseTracksJob.data(), SIGNAL(destroyed(QObject*)), SIGNAL(remove()) ); - m_parseTracksJob.data()->abort(); - } - else - emit remove(); -} - -Meta::TrackPtr -IpodCollection::addTrack( IpodMeta::Track *track ) -{ - if( !track || !m_itdb ) - return Meta::TrackPtr(); - - Itdb_Track *itdbTrack = track->itdbTrack(); - bool justAdded = false; - - m_itdbMutex.lock(); - Q_ASSERT( !itdbTrack->itdb || itdbTrack->itdb == m_itdb /* refuse to take track from another itdb */ ); - if( !itdbTrack->itdb ) - { - itdb_track_add( m_itdb, itdbTrack, -1 ); - // if it wasn't in itdb, it couldn't have legally been in master playlist - // TODO: podcasts should not go into MPL - itdb_playlist_add_track( itdb_playlist_mpl( m_itdb ), itdbTrack, -1 ); - - justAdded = true; - emit startWriteDatabaseTimer(); - } - track->setCollection( QWeakPointer( this ) ); - - Meta::TrackPtr trackPtr( track ); - Meta::TrackPtr memTrack = MemoryMeta::MapChanger( m_mc.data() ).addTrack( trackPtr ); - if( !memTrack && justAdded ) - { - /* this new track was not added to MemoryCollection, it may vanish soon, prevent - * dangling pointer in m_itdb */ - itdb_playlist_remove_track( 0 /* = MPL */, itdbTrack ); - itdb_track_unlink( itdbTrack ); - } - m_itdbMutex.unlock(); - - if( memTrack ) - { - subscribeTo( trackPtr ); - emit startUpdateTimer(); - } - return memTrack; -} - -void -IpodCollection::removeTrack( const Meta::TrackPtr &track ) -{ - if( !track ) - return; // nothing to do - /* Following call ensures thread-safety even when this method is called multiple times - * from different threads with the same track: only one thread will get non-null - * deletedTrack from MapChanger. */ - Meta::TrackPtr deletedTrack = MemoryMeta::MapChanger( m_mc.data() ).removeTrack( track ); - if( !deletedTrack ) - { - warning() << __PRETTY_FUNCTION__ << "attempt to delete a track that was not in" - << "MemoryCollection or not added using MapChanger"; - return; - } - IpodMeta::Track *ipodTrack = dynamic_cast( deletedTrack.data() ); - if( !ipodTrack ) - { - warning() << __PRETTY_FUNCTION__ << "attempt to delete a track that was not" - << "internally iPod track"; - return; - } - - Itdb_Track *itdbTrack = ipodTrack->itdbTrack(); - if( itdbTrack->itdb && m_itdb ) - { - // remove from all playlists excluding the MPL: - m_playlistProvider->removeTrackFromPlaylists( track ); - - QMutexLocker locker( &m_itdbMutex ); - // remove track from the master playlist: - itdb_playlist_remove_track( itdb_playlist_mpl( m_itdb ), itdbTrack ); - // remove it from the db: - itdb_track_unlink( itdbTrack ); - emit startWriteDatabaseTimer(); - } - - emit startUpdateTimer(); -} - -bool IpodCollection::writeDatabase() -{ - if( !IpodDeviceHelper::safeToWrite( m_mountPoint, m_itdb ) ) // returns false if m_itdb is null - { - // we have to delete unmount-preventing file even in this case - delete m_preventUnmountTempFile; - m_preventUnmountTempFile = 0; - warning() << "Refusing to write iTunes database to iPod becauase device is not safe to write"; - return false; - } - - m_itdbMutex.lock(); - GError *error = 0; - bool success = itdb_write( m_itdb, &error ); - m_itdbMutex.unlock(); - QString gpodError; - if( error ) - { - gpodError = QString::fromUtf8( error->message ); - g_error_free( error ); - error = 0; - } - delete m_preventUnmountTempFile; // this deletes the file - m_preventUnmountTempFile = 0; - - if( success ) - { - QString message = i18nc( "%1: iPod collection name", - "iTunes database successfully written to %1", prettyName() ); - Amarok::Components::logger()->shortMessage( message ); - } - else - { - QString message; - if( gpodError.isEmpty() ) - message = i18nc( "%1: iPod collection name", - "Writing iTunes database to %1 failed without an indication of error", - prettyName() ); - else - message = i18nc( "%1: iPod collection name, %2: technical error from libgpod", - "Writing iTunes database to %1 failed: %2", prettyName(), gpodError ); - Amarok::Components::logger()->longMessage( message ); - } - return success; -} - -#include "moc_IpodCollection.cpp" diff --git a/amarok/src/core-impl/collections/ipodcollection/IpodCollection.h b/amarok/src/core-impl/collections/ipodcollection/IpodCollection.h deleted file mode 100644 index 40fe8803..00000000 --- a/amarok/src/core-impl/collections/ipodcollection/IpodCollection.h +++ /dev/null @@ -1,284 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl . * - ****************************************************************************************/ - -#ifndef IPODCOLLECTION_H -#define IPODCOLLECTION_H - -#include "ui_IpodConfiguration.h" -#include "core/collections/Collection.h" -#include "core/meta/Observer.h" - -#include - -#include -#include -#include - -namespace Collections { class MemoryCollection; } -namespace IpodMeta { class Track; } -class IphoneMountPoint; -class IpodParseTracksJob; -class IpodWriteDatabaseJob; -class IpodPlaylistProvider; -class QDir; -class QTemporaryFile; -struct _Itdb_iTunesDB; -typedef _Itdb_iTunesDB Itdb_iTunesDB; - -class IpodCollection : public Collections::Collection, public Meta::Observer -{ - Q_OBJECT - - public: - /** - * Creates an iPod collection on top of already-mounted filesystem. - * - * @param mountPoint actual iPod mount point to use, must be already mounted and - * accessible. When eject is requested, solid StorageAccess with this mount point - * is searched for to perform unmounting. - * @param uuid filesystem volume UUID or another unique identifier for this iPod - */ - explicit IpodCollection( const QDir &mountPoint, const QString &uuid ); - - /** - * Creates an iPod collection on top of not-mounted iPhone/iPad by accessing it - * using libimobiledevice by its 40-digit device UUID. UUID may be empty which - * means "any connected iPhone/iPad". - */ - explicit IpodCollection( const QString &uuid ); - - virtual ~IpodCollection(); - - // TrackProvider methods: - virtual bool possiblyContainsTrack( const KUrl &url ) const; - virtual Meta::TrackPtr trackForUrl( const KUrl &url ); - - // CollectionBase methods: - virtual bool hasCapabilityInterface( Capabilities::Capability::Type type ) const; - virtual Capabilities::Capability* createCapabilityInterface( Capabilities::Capability::Type type ); - - // Collection methods: - virtual Collections::QueryMaker *queryMaker(); - - virtual QString uidUrlProtocol() const; - virtual QString collectionId() const; - virtual QString prettyName() const; - virtual KIcon icon() const; - - virtual bool hasCapacity() const; - virtual float usedCapacity() const; - virtual float totalCapacity() const; - - virtual Collections::CollectionLocation *location(); - virtual bool isWritable() const; - virtual bool isOrganizable() const; - - // Observer methods: - virtual void metadataChanged( Meta::TrackPtr track ); - // so that the compiler doesn't complain about hidden virtual functions: - using Meta::Observer::metadataChanged; - - // IpodCollection methods: - /** - * In-fact second phase of the construcor. Called by CollectionFactory right after - * constructor. Should return true if the collection initialised itself successfully - * and should be shown to the user; return value of false means it should be - * destroyed and forgotten by the factory. - */ - bool init(); - - /** - * Get local mount point. Can return QString() in case no reasonamble mountpoint - * is available - */ - QString mountPoint(); - - /** - * Return number of bytes that should be kept free in iPod for database operations. - * CollectionLocation should try hard not to occupy this safety margin. - */ - float capacityMargin() const; - - /** - * Return a list of file formats (compatible with Meta::Track::type()) current iPod - * is able to play. - */ - QStringList supportedFormats() const; - - /** - * Return pointer to playlist provider associated with this iPod. May be null in - * special cases (iPod not yet initialised etc.) - */ - Playlists::UserPlaylistProvider *playlistProvider() const; - - Meta::TrackPtr trackForUidUrl( const QString &uidUrl ); - - signals: - /** - * Start a count-down that emits updated() signal after it expires. - * Resets the timer to original timeout if already running. This is to ensure - * that we emit update() max. once per for batch updates. - * - * Timers can only be started from "their" thread so use signals & slots for that. - */ - void startUpdateTimer(); - - /** - * Start a count-down that initiates iTunes database wrtiging after it expires. - * Resets the timer to original timeout if already running. This is to ensure - * that we don't write the database all the time for batch updates. - * - * Timers can only be started from "their" thread so use signals & slots for that. - */ - void startWriteDatabaseTimer(); - - public slots: - /** - * Destroy the collection, try to write back iTunes database (if dirty) - */ - void slotDestroy(); - - /** - * Destroy the collection, write back iTunes db (if dirty) and try to eject the - * iPod from system - */ - void slotEject(); - - /** - * Shows the configuration dialog in a non-modal window. If m_itdb is null, shows - * some info and a button to try to initialize iPod. - */ - void slotShowConfigureDialog( const QString &errorMessage = QString() ); - - private slots: - /** - * Update m_lastUpdated timestamp and emit updated() - */ - void collectionUpdated(); - - /** - * Tries to initialize iPod, read the database, add tracks. (Re)shows the - * configuration dialog with info about initialization. - */ - void slotInitialize(); - - /** - * Sets iPod name to the name in configure dialog. - */ - void slotApplyConfiguration(); - - /** - * Starts a timer that ensures we emit updated() signal sometime in future. - */ - void slotStartUpdateTimer(); - - /** - * Starts a timer that initiates iTunes database writing after 30 seconds. - */ - void slotStartWriteDatabaseTimer(); - - /** - * Enqueues a job in a thread that writes iTunes database back to iPod. Should - * only be called from m_writeDatabaseTimer's timeout() signal. (with exception - * when IpodCollection is about to destroy itself) - */ - void slotInitiateDatabaseWrite(); - - /** - * Tries to unmount underlying solid device. You must try to write database before - * calling this. Emits remove() before returning. - */ - void slotPerformTeardownAndRemove(); - - /** - * Do sanity checks and emit remove() so that this collection is destroyed by - * CollectionManager. No other method is allowed to emit remove()! - */ - void slotRemove(); - - private: - friend class IpodCopyTracksJob; - friend class IpodDeleteTracksJob; - friend class IpodParseTracksJob; - friend class IpodWriteDatabaseJob; - friend class IpodPlaylistProvider; - - static const QString s_uidUrlProtocol; - static const QStringList s_audioFileTypes; - static const QStringList s_videoFileTypes; - static const QStringList s_audioVideoFileTypes; - - // method for IpodParseTracksJob and IpodCopyTracksJob: - /** - * Add an iPod track to the collection. - * - * This method adds it to the collection, master playlist (if not already there) - * etc. The file must be already physically copied to iPod. (Re)Sets track's - * collection to this collection. Takes ownership of the track (passes it to - * KSharedPtr) - * - * This method is thread-safe. - * - * @return pointer to newly added track if successful, null pointer otherwise - */ - Meta::TrackPtr addTrack( IpodMeta::Track *track ); - - // method for IpodDeleteTracksJob: - /** - * Removes a track from iPod collection. Does not delete the file physically, - * caller must do it after calling this method. - * - * @param track a track from associated MemoryCollection to delete. Accepts also - * underlying IpodMeta::Track, this is treated as if MemoryMeta::Track track - * proxy it was passed. - * - * This method is thread-safe. - */ - void removeTrack( const Meta::TrackPtr &track ); - - // method for IpodWriteDatabaseJob and destructor: - /** - * Calls itdb_write() directly. Logs a message about success/failure in Amarok - * interface. - */ - bool writeDatabase(); - - KDialog *m_configureDialog; - Ui::IpodConfiguration m_configureDialogUi; - QSharedPointer m_mc; - /** - * pointer to libgpod iTunes database. If null, this collection is invalid - * (not yet initialised). Can only be changed with m_itdbMutex hold. - */ - Itdb_iTunesDB *m_itdb; - QMutex m_itdbMutex; - QTimer m_updateTimer; - qint64 m_lastUpdated; /* msecs since epoch */ - QTimer m_writeDatabaseTimer; - QTemporaryFile *m_preventUnmountTempFile; - QString m_mountPoint; - QString m_uuid; - IphoneMountPoint *m_iphoneAutoMountpoint; - QString m_prettyName; - IpodPlaylistProvider *m_playlistProvider; - QAction *m_configureAction; - QAction *m_ejectAction; - QAction *m_consolidateAction; - QWeakPointer m_parseTracksJob; - QWeakPointer m_writeDatabaseJob; -}; - -#endif // IPODCOLLECTION_H diff --git a/amarok/src/core-impl/collections/ipodcollection/IpodCollectionFactory.cpp b/amarok/src/core-impl/collections/ipodcollection/IpodCollectionFactory.cpp deleted file mode 100644 index 1d4312fa..00000000 --- a/amarok/src/core-impl/collections/ipodcollection/IpodCollectionFactory.cpp +++ /dev/null @@ -1,274 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl . * - ****************************************************************************************/ - -#include "IpodCollectionFactory.h" - -#include "IpodCollection.h" -#include "core/support/Debug.h" - -#include -#include -#include -#include -#include - -#include - -AMAROK_EXPORT_COLLECTION( IpodCollectionFactory, ipodcollection ) - -IpodCollectionFactory::IpodCollectionFactory( QObject *parent, const QVariantList &args ) - : CollectionFactory( parent, args ) -{ - m_info = KPluginInfo( "amarok_collection-ipodcollection.desktop", "services" ); -} - -IpodCollectionFactory::~IpodCollectionFactory() -{ -} - -void -IpodCollectionFactory::init() -{ - connect( Solid::DeviceNotifier::instance(), SIGNAL(deviceAdded(QString)), - SLOT(slotAddSolidDevice(QString)) ); - connect( Solid::DeviceNotifier::instance(), SIGNAL(deviceRemoved(QString)), - SLOT(slotRemoveSolidDevice(QString)) ); - - // detect iPods that were already connected on startup - QString query( "[IS StorageAccess OR IS PortableMediaPlayer]" ); - QList ipodDevices = Solid::Device::listFromQuery( query ); - foreach( const Solid::Device &device, ipodDevices ) - { - if( identifySolidDevice( device.udi() ) ) - createCollectionForSolidDevice( device.udi() ); - } - m_initialized = true; -} - -void -IpodCollectionFactory::slotAddSolidDevice( const QString &udi ) -{ - if( m_collectionMap.contains( udi ) ) - return; // a device added twice (?) - - if( identifySolidDevice( udi ) ) - createCollectionForSolidDevice( udi ); -} - -void -IpodCollectionFactory::slotAccessibilityChanged( bool accessible, const QString &udi ) -{ - if( accessible ) - slotAddSolidDevice( udi ); - else - slotRemoveSolidDevice( udi ); -} - -void -IpodCollectionFactory::slotRemoveSolidDevice( const QString &udi ) -{ - IpodCollection *collection = m_collectionMap.take( udi ); - if( collection ) - collection->slotDestroy(); -} - -void -IpodCollectionFactory::slotCollectionDestroyed( QObject *collection ) -{ - // remove destroyed collection from m_collectionMap - QMutableMapIterator it( m_collectionMap ); - while( it.hasNext() ) - { - it.next(); - if( (QObject *) it.value() == collection ) - it.remove(); - } -} - -/** - * @brief Return true if device is identified as iPod-compatible using product and vendor. - * - * @param device Solid device to identify - * @return true if the device is iPod-like, false if it cannot be proved. - **/ -static bool -deviceIsRootIpodDevice( const Solid::Device &device ) -{ - if( !device.vendor().contains( "Apple", Qt::CaseInsensitive ) ) - return false; - return device.product().startsWith( "iPod" ) - || device.product().startsWith( "iPhone" ) - || device.product().startsWith( "iPad" ); -} - -/** - * @brief Returns true if device is identified as iPod-compatible using - * PortableMediaPlayer interface. - * - * @param device Solid device to identify - * @return true if the device is iPod-like, false if it cannot be proved. - **/ -static bool -deviceIsPMPIpodDevice( const Solid::Device &device ) -{ - /* This should be the one and only way to identify iPod-likes, but as of KDE 4.9.4, - * solid attaches PortableMediaPlayer to a wrong device path like - * /org/kde/solid/udev/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1/1-1.1.4/1-1.1.4:1.0/host6/target6:0:0/6:0:0:0/block/sdc/sdc2, - * while it should attach is to UDIsks device /org/freedesktop/UDisks/devices/sdc2 - * - * It works correctly for iPhones though. - */ - const Solid::PortableMediaPlayer *pmp = device.as(); - if( !pmp ) - return false; - - debug() << "Device supported PMP protocols:" << pmp->supportedProtocols(); - return pmp->supportedProtocols().contains( "ipod", Qt::CaseInsensitive ); -} - -bool -IpodCollectionFactory::identifySolidDevice( const QString &udi ) const -{ - DEBUG_BLOCK - Solid::Device device( udi ); - - if( deviceIsPMPIpodDevice( device ) ) - { - debug() << "Device" << device.udi() << "identified iPod-like using " - "PortableMediaPlayer interface"; - return true; - } - - if( !device.is() ) - { - debug() << "Device" << device.udi() << "doesn't have PortableMediaPlayer ipod" - << "interface or StorageAccess interface -> cannot be and iPod"; - return false; - } - - /* Start with device to identify, opportunistically try to identify it as - * iPod-compatible. If found not, try its parent. Repeat until parent device is - * valid. - * - * @see MediaDeviceCache::slotAddSolidDevice(), whose iPhone hack shouldn't be - * needed since iPod rewrite in Amarok 2.6. - */ - while ( device.isValid() ) - { - if( deviceIsRootIpodDevice( device ) ) - { - debug() << "Device" << device.udi() << "identified iPod-like using " - "vendor and product name"; - return true; - } - - debug() << "Device" << device.udi() << "not identified iPod-like, trying parent device"; - device = device.parent(); - } - debug() << "Device" << device.udi() << "is invalid, returning false. (i.e. was not iPod-like)"; - return false; -} - -void -IpodCollectionFactory::createCollectionForSolidDevice( const QString &udi ) -{ - DEBUG_BLOCK - DeviceType type; - QDir mountPoint; - QString uuid; - Solid::Device device( udi ); - Solid::StorageAccess *ssa = device.as(); - if( ssa ) - { - type = iPod; - if( ssa->isIgnored() ) - { - debug() << "device" << udi << "ignored, ignoring :-)"; - return; - } - - // we are definitely interested in this device, listen for accessibility changes - disconnect( ssa, SIGNAL(accessibilityChanged(bool,QString)), this, 0 ); - connect( ssa, SIGNAL(accessibilityChanged(bool,QString)), - SLOT(slotAccessibilityChanged(bool,QString)) ); - - if( !ssa->isAccessible() ) - { - debug() << "device" << udi << "not accessible, ignoring for now"; - return; - } - mountPoint = ssa->filePath(); - Solid::StorageVolume *volume = device.as(); - if( volume ) - uuid = volume->uuid(); - } - else // no ssa - { - do { // break inside this block means "continue with collection creation" - type = iOS; - debug() << "device" << udi << "has no StorageAccess interface, treating as iPhone/iPad"; - Solid::PortableMediaPlayer *pmp = device.as(); - if( !pmp ) - { - debug() << "Ignoring above device as it doesn't have PortableMediaPlayer interface"; - return; - } - - if( pmp->supportedProtocols().contains( "ipod" ) && - pmp->supportedDrivers().contains( "usbmux" ) ) - { - uuid = pmp->driverHandle( "usbmux" ).toString(); - debug() << "Above device suports ipod/usbmux protocol/driver combo, good"; - break; - } - - debug() << "Ignoring above device as it doesn't support ipod/usbmux" - << "PortableMediaPlayer protocol/driver combo"; - return; - } while( false ); - } - - debug() << "Creating iPod collection, mount-point (empty if iOS):" << mountPoint - << "uuid:" << uuid; - IpodCollection *collection; - switch( type ) - { - case iPod: - collection = new IpodCollection( mountPoint, uuid ); - break; - case iOS: - collection = new IpodCollection( uuid ); - break; - } - m_collectionMap.insert( udi, collection ); - - // when the collection is destroyed by someone else, remove it from m_collectionMap: - connect( collection, SIGNAL(destroyed(QObject*)), SLOT(slotCollectionDestroyed(QObject*)) ); - - if( ssa ) - // try to gracefully destroy collection when unmounting is requested using - // external means: Device notifier plasmoid etc.. Because the original action - // could fail if we hold some files on the device open, we eject the collection, - // not just destroy it. - connect( ssa, SIGNAL(teardownRequested(QString)), collection, SLOT(slotEject()) ); - - if( collection->init() ) - emit newCollection( collection ); - else - collection->deleteLater(); -} - -#include "moc_IpodCollectionFactory.cpp" diff --git a/amarok/src/core-impl/collections/ipodcollection/IpodCollectionFactory.h b/amarok/src/core-impl/collections/ipodcollection/IpodCollectionFactory.h deleted file mode 100644 index 77ec6d45..00000000 --- a/amarok/src/core-impl/collections/ipodcollection/IpodCollectionFactory.h +++ /dev/null @@ -1,85 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl . * - ****************************************************************************************/ - -#ifndef IPODCOLLECTIONFACTORY_H -#define IPODCOLLECTIONFACTORY_H - -#include "core/collections/Collection.h" - -#include - - -namespace Solid { -class Device; -} - -class IpodCollection; - -class IpodCollectionFactory : public Collections::CollectionFactory -{ - Q_OBJECT - - public: - IpodCollectionFactory( QObject *parent, const QVariantList &args ); - virtual ~IpodCollectionFactory(); - - virtual void init(); - - private slots: - /** - * Called when solid notifier detects a new device has been added - */ - void slotAddSolidDevice( const QString &udi ); - - /** - * Called when solid StorageAccess device we are interested in is mounted or - * unmounted - */ - void slotAccessibilityChanged( bool accessible, const QString &udi ); - - /** - * Called when solid notifier detects a device has been removed - */ - void slotRemoveSolidDevice( const QString &udi ); - - /** - * Called when "tracked" collection is destroyed - */ - void slotCollectionDestroyed( QObject *collection ); - - private: - enum DeviceType { - iPod, // classic wasy of accessing - iOS // access using libimobiledevice - }; - - /** - * Checks whether a solid device is an iPod. - */ - bool identifySolidDevice( const QString &udi ) const; - - /** - * Attempts to create appropriate collection for already identified solid device - * @param udi. Should emit newCollection() if the collection was successfully - * created and should become visible to the user. - */ - void createCollectionForSolidDevice( const QString &udi ); - - /// udi to iPod collection map - QMap m_collectionMap; -}; - -#endif // IPODCOLLECTIONFACTORY_H diff --git a/amarok/src/core-impl/collections/ipodcollection/IpodCollectionLocation.cpp b/amarok/src/core-impl/collections/ipodcollection/IpodCollectionLocation.cpp deleted file mode 100644 index 85675eac..00000000 --- a/amarok/src/core-impl/collections/ipodcollection/IpodCollectionLocation.cpp +++ /dev/null @@ -1,154 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "IpodCollectionLocation.h" - -#include "jobs/IpodDeleteTracksJob.h" -#include "core/interfaces/Logger.h" -#include "core/support/Components.h" -#include "core/support/Debug.h" - -#include - -#include -#include - -#include - -IpodCollectionLocation::IpodCollectionLocation( QWeakPointer parentCollection ) - : CollectionLocation() // we implement collection(), we need not pass parentCollection - , m_coll( parentCollection ) -{ -} - -IpodCollectionLocation::~IpodCollectionLocation() -{ -} - -Collections::Collection* -IpodCollectionLocation::collection() const -{ - // overridden to avoid dangling pointers - return m_coll.data(); -} - -QString -IpodCollectionLocation::prettyLocation() const -{ - if( m_coll ) - return m_coll.data()->prettyName(); - // match string with IpodCopyTracksJob::slotDisplaySorryDialog() - return i18n( "Disconnected iPod/iPad/iPhone" ); -} - -bool -IpodCollectionLocation::isWritable() const -{ - if( !m_coll ) - return false; - return m_coll.data()->isWritable(); // no infinite loop, IpodCollection iplements this -} - -void -IpodCollectionLocation::copyUrlsToCollection( const QMap &sources, - const Transcoding::Configuration &configuration ) -{ - if( !isWritable() ) - return; // mostly unreachable, CollectionLocation already checks this and issues a warning - ensureDirectoriesExist(); - - IpodCopyTracksJob *job = new IpodCopyTracksJob( sources, m_coll, configuration, isGoingToRemoveSources() ); - int trackCount = sources.size(); - Amarok::Components::logger()->newProgressOperation( job, - operationInProgressText( configuration, trackCount ), trackCount, job, SLOT(abort()) ); - - qRegisterMetaType( "IpodCopyTracksJob::CopiedStatus" ); - connect( job, SIGNAL(signalTrackProcessed(Meta::TrackPtr,Meta::TrackPtr,IpodCopyTracksJob::CopiedStatus)), - this, SLOT(slotCopyTrackProcessed(Meta::TrackPtr,Meta::TrackPtr,IpodCopyTracksJob::CopiedStatus)) ); - connect( job, SIGNAL(done(ThreadWeaver::Job*)), this, SLOT(slotCopyOperationFinished()) ); - connect( job, SIGNAL(done(ThreadWeaver::Job*)), job, SLOT(deleteLater()) ); - ThreadWeaver::Weaver::instance()->enqueue( job ); -} - -void -IpodCollectionLocation::removeUrlsFromCollection( const Meta::TrackList &sources ) -{ - if( !isWritable() ) - return; - - IpodDeleteTracksJob *job = new IpodDeleteTracksJob( sources, m_coll ); - connect( job, SIGNAL(done(ThreadWeaver::Job*)), this, SLOT(slotRemoveOperationFinished()) ); - connect( job, SIGNAL(done(ThreadWeaver::Job*)), job, SLOT(deleteLater()) ); - ThreadWeaver::Weaver::instance()->enqueue( job ); -} - -void -IpodCollectionLocation::setDestinationPlaylist( Playlists::PlaylistPtr destPlaylist, const QMap &trackPlaylistPositions ) -{ - m_destPlaylist = destPlaylist; - m_trackPlaylistPositions = trackPlaylistPositions; -} - -void -IpodCollectionLocation::slotCopyTrackProcessed( Meta::TrackPtr srcTrack, Meta::TrackPtr destTrack, - IpodCopyTracksJob::CopiedStatus status ) -{ - if( status == IpodCopyTracksJob::Success ) - // we do not include track found by matching meta-data here for safety reasons - source()->transferSuccessful( srcTrack ); - - if( m_destPlaylist && ( status == IpodCopyTracksJob::Success || status == IpodCopyTracksJob::Duplicate ) - && destTrack && m_trackPlaylistPositions.contains( srcTrack ) ) - // add this track to iPod playlist - { - m_destPlaylist->addTrack( destTrack, m_trackPlaylistPositions.value( srcTrack ) ); - } -} - -void IpodCollectionLocation::ensureDirectoriesExist() -{ - QByteArray mountPoint = m_coll ? QFile::encodeName( m_coll.data()->mountPoint() ) : QByteArray(); - if( mountPoint.isEmpty() ) - return; - - gchar *musicDirChar = itdb_get_music_dir( mountPoint.constData() ); - QString musicDirPath = QFile::decodeName( musicDirChar ); - g_free( musicDirChar ); - if( musicDirPath.isEmpty() ) - return; - - QDir musicDir( musicDirPath ); - if( !musicDir.exists() && !musicDir.mkpath( "." ) /* try to create it */ ) - { - warning() << __PRETTY_FUNCTION__ << "failed to create" << musicDirPath << "directory."; - return; - } - - QChar fillChar( '0' ); - for( int i = 0; i < 20; i++ ) - { - QString name = QString( "F%1" ).arg( i, /* min-width */ 2, /* base */ 10, fillChar ); - if( musicDir.exists( name ) ) - continue; - QString toCreatePath = QString( "%1/%2" ).arg( musicDirPath, name ); - if( musicDir.mkdir( name ) ) - debug() << __PRETTY_FUNCTION__ << "created" << toCreatePath << "directory."; - else - warning() << __PRETTY_FUNCTION__ << "failed to create" << toCreatePath << "directory."; - } -} - -#include "moc_IpodCollectionLocation.cpp" diff --git a/amarok/src/core-impl/collections/ipodcollection/IpodCollectionLocation.h b/amarok/src/core-impl/collections/ipodcollection/IpodCollectionLocation.h deleted file mode 100644 index 4fe2d6df..00000000 --- a/amarok/src/core-impl/collections/ipodcollection/IpodCollectionLocation.h +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef IPODCOLLECTIONLOCATION_H -#define IPODCOLLECTIONLOCATION_H - -#include "IpodCollection.h" -#include "jobs/IpodCopyTracksJob.h" - -#include "core/collections/CollectionLocation.h" -#include "core/playlists/Playlist.h" - -#include - - -class IpodCollectionLocation : public Collections::CollectionLocation -{ - Q_OBJECT - - public: - IpodCollectionLocation( QWeakPointer parentCollection ); - virtual ~IpodCollectionLocation(); - - // CollectionLocation methods: - virtual Collections::Collection *collection() const; - virtual QString prettyLocation() const; - virtual bool isWritable() const; - - virtual void copyUrlsToCollection( const QMap &sources, - const Transcoding::Configuration &configuration ); - virtual void removeUrlsFromCollection( const Meta::TrackList &sources ); - - // IpodCollectionLocation specific methods: - /** - * Calling this causes that when the tracks are copied, they are added to iPod - * playlist @param playlist - */ - void setDestinationPlaylist( Playlists::PlaylistPtr destPlaylist, - const QMap &trackPlaylistPositions ); - - /** - * This method is published so that IpodPlaylistProvider can hide removal dialog. - */ - using Collections::CollectionLocation::setHidingRemoveConfirm; - - private slots: - void slotCopyTrackProcessed( Meta::TrackPtr srcTrack, Meta::TrackPtr destTrack, - IpodCopyTracksJob::CopiedStatus status ); - - private: - /** - * Helper method to create a basic set of /iPod_Contol/Music/F.. directories - * so that copying doesn't fail for this simple reason - */ - void ensureDirectoriesExist(); - - QWeakPointer m_coll; - QMap m_trackPlaylistPositions; - Playlists::PlaylistPtr m_destPlaylist; -}; - -#endif // IPODCOLLECTIONLOCATION_H diff --git a/amarok/src/core-impl/collections/ipodcollection/IpodConfiguration.ui b/amarok/src/core-impl/collections/ipodcollection/IpodConfiguration.ui deleted file mode 100644 index f128c7f3..00000000 --- a/amarok/src/core-impl/collections/ipodcollection/IpodConfiguration.ui +++ /dev/null @@ -1,229 +0,0 @@ - - - IpodConfiguration - - - - 0 - 0 - 427 - 451 - - - - iPod device configuration - - - - - - Settings - - - - - - iPod name: - - - - - - - - - - Transcode: - - - - - - - QComboBox::AdjustToContents - - - - - - - Model: - - - - - - - - - - true - - - <b>Warning: some rather long placeholder text.</b> Also with explanation. Initializing iPod does something and something. - - - true - - - true - - - - - - - - - Qt::Horizontal - - - - 40 - 0 - - - - - - - - &Initialize iPod - - - - - - - - - - - - Information - - - - - - Model: - - - - - - - <modelplaceholer> - - - - - - - Generation: - - - - - - - <generationplaceholer> - - - - - - - Video: - - - - - - - <videoplaceholder> - - - - - - - Album artwork: - - - - - - - <artworkplaceholder> - - - - - - - - - - Troubleshooting - - - - - - SysInfo file: - - - - - - - <placeholder> - - - - - - - SysInfoExtended file: - - - - - - - <placeholder> - - - - - - - <multi line notes placeholder> - - - true - - - true - - - Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse - - - - - - - - - - - Transcoding::SelectConfigWidget - QComboBox -
    transcoding/TranscodingSelectConfigWidget.h
    -
    -
    - - -
    diff --git a/amarok/src/core-impl/collections/ipodcollection/IpodDeviceHelper.cpp b/amarok/src/core-impl/collections/ipodcollection/IpodDeviceHelper.cpp deleted file mode 100644 index 80d7b4ff..00000000 --- a/amarok/src/core-impl/collections/ipodcollection/IpodDeviceHelper.cpp +++ /dev/null @@ -1,480 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "IpodDeviceHelper.h" - -#include "core/support/Debug.h" - -#include -#include - -#include -#include - - -Itdb_iTunesDB* -IpodDeviceHelper::parseItdb( const QString &mountPoint, QString &errorMsg ) -{ - Itdb_iTunesDB *itdb; - GError *error = 0; - - errorMsg.clear(); - itdb = itdb_parse( QFile::encodeName( mountPoint ), &error ); - if( error ) - { - if( itdb ) - itdb_free( itdb ); - itdb = 0; - errorMsg = QString::fromUtf8( error->message ); - g_error_free( error ); - error = 0; - } - if( !itdb && errorMsg.isEmpty() ) - errorMsg = i18n( "Cannot parse iTunes database due to an unreported error." ); - return itdb; -} - -QString -IpodDeviceHelper::collectionName( Itdb_iTunesDB *itdb ) -{ - const Itdb_IpodInfo *info = (itdb && itdb->device) ? itdb_device_get_ipod_info( itdb->device ) : 0; - QString modelName = info ? QString::fromUtf8( itdb_info_get_ipod_model_name_string( info->ipod_model ) ) - : i18nc( "iPod model that is not (yet) recognized", "Unrecognized model" ); - - return i18nc( "Name of the iPod collection; %1 is iPod name, %2 is iPod model; example: My iPod: Nano (Blue)", - "%1: %2", IpodDeviceHelper::ipodName( itdb ), modelName ); -} - -QString -IpodDeviceHelper::ipodName( Itdb_iTunesDB *itdb ) -{ - Itdb_Playlist *mpl = itdb ? itdb_playlist_mpl( itdb ) : 0; - QString mplName = mpl ? QString::fromUtf8( mpl->name ) : QString(); - if( mplName.isEmpty() ) - mplName = i18nc( "default iPod name (when user-set name is empty)", "iPod" ); - - return mplName; -} - -void -IpodDeviceHelper::unlinkPlaylistsTracksFromItdb( Itdb_iTunesDB *itdb ) -{ - if( !itdb ) - return; - - while( itdb->playlists ) - { - Itdb_Playlist *ipodPlaylist = (Itdb_Playlist *) itdb->playlists->data; - if( !ipodPlaylist || ipodPlaylist->itdb != itdb ) - { - /* a) itdb_playlist_unlink() cannot work if ipodPlaylist is null, prevent - * infinite loop - * b) if ipodPlaylist->itdb != itdb, something went horribly wrong. Prevent - * infinite loop even in this case - */ - itdb->playlists = g_list_remove( itdb->playlists, ipodPlaylist ); - continue; - } - itdb_playlist_unlink( ipodPlaylist ); - } - - while( itdb->tracks ) - { - Itdb_Track *ipodTrack = (Itdb_Track *) itdb->tracks->data; - if( !ipodTrack || ipodTrack->itdb != itdb ) - { - /* a) itdb_track_unlink() cannot work if ipodTrack is null, prevent infinite - * loop - * b) if ipodTrack->itdb != itdb, something went horribly wrong. Prevent - * infinite loop even in this case - */ - itdb->tracks = g_list_remove( itdb->tracks, ipodTrack ); - continue; - } - itdb_track_unlink( ipodTrack ); - } -} - -/** - * Return ipod info if iPod model is recognized, returns null if itdb is null or if iPod - * is invalid or unknown. - */ -static const Itdb_IpodInfo *getIpodInfo( const Itdb_iTunesDB *itdb ) -{ - if( !itdb || !itdb->device ) - return 0; - const Itdb_IpodInfo *info = itdb_device_get_ipod_info( itdb->device ); - if( !info ) - return 0; - if( info->ipod_model == ITDB_IPOD_MODEL_INVALID - || info->ipod_model == ITDB_IPOD_MODEL_UNKNOWN ) - { - return 0; - } - return info; -} - -static bool -firewireGuidNeeded( const Itdb_IpodGeneration &generation ) -{ - switch( generation ) - { - // taken from libgpod itdb_device.c itdb_device_get_checksum_type() - // not nice, but should not change, no new devices use hash58 - case ITDB_IPOD_GENERATION_CLASSIC_1: - case ITDB_IPOD_GENERATION_CLASSIC_2: - case ITDB_IPOD_GENERATION_CLASSIC_3: - case ITDB_IPOD_GENERATION_NANO_3: - case ITDB_IPOD_GENERATION_NANO_4: - return true; // ITDB_CHECKSUM_HASH58 - default: - break; - } - return false; -} - -static bool -hashInfoNeeded( const Itdb_IpodGeneration &generation ) -{ - switch( generation ) - { - // taken from libgpod itdb_device.c itdb_device_get_checksum_type() - // not nice, but should not change, current devices need libhashab - case ITDB_IPOD_GENERATION_NANO_5: - case ITDB_IPOD_GENERATION_TOUCH_1: - case ITDB_IPOD_GENERATION_TOUCH_2: - case ITDB_IPOD_GENERATION_TOUCH_3: - case ITDB_IPOD_GENERATION_IPHONE_1: - case ITDB_IPOD_GENERATION_IPHONE_2: - case ITDB_IPOD_GENERATION_IPHONE_3: - return true; // ITDB_CHECKSUM_HASH72 - default: - break; - } - return false; -} - -static bool -hashAbNeeded( const Itdb_IpodGeneration &generation ) -{ - switch( generation ) - { - // taken from libgpod itdb_device.c itdb_device_get_checksum_type() - // TODO: not nice, new released devices may be added! - case ITDB_IPOD_GENERATION_IPAD_1: - case ITDB_IPOD_GENERATION_IPHONE_4: - case ITDB_IPOD_GENERATION_TOUCH_4: - case ITDB_IPOD_GENERATION_NANO_6: - return true; // ITDB_CHECKSUM_HASHAB - default: - break; - } - return false; -} - -/** - * Returns true if file @param relFilename is found, readable and nonempty. - * Searches in @param mountPoint /iPod_Control/Device/ - */ -static bool -fileFound( const QString &mountPoint, const QString &relFilename ) -{ - gchar *controlDir = itdb_get_device_dir( QFile::encodeName( mountPoint ) ); - if( !controlDir ) - return false; - QString absFilename = QString( "%1/%2" ).arg( QFile::decodeName( controlDir ) ) - .arg( relFilename ); - g_free( controlDir ); - - QFileInfo fileInfo( absFilename ); - return fileInfo.isReadable() && fileInfo.size() > 0; -} - -static bool -safeToWriteWithMessage( const QString &mountPoint, const Itdb_iTunesDB *itdb, QString &message ) -{ - const Itdb_IpodInfo *info = getIpodInfo( itdb ); // returns null on null itdb - if( !info ) - { - message = i18n( "iPod model was not recognized." ); - return false; - } - - QString gen = QString::fromUtf8( itdb_info_get_ipod_generation_string( info->ipod_generation ) ); - if( firewireGuidNeeded( info->ipod_generation ) ) - { - // okay FireWireGUID may be in plain SysInfo, too, but it's hard to check and - // error-prone so we just require SysInfoExtended which is machine-generated - const QString sysInfoExtended( "SysInfoExtended" ); - bool sysInfoExtendedExists = fileFound( mountPoint, sysInfoExtended ); - message += ( sysInfoExtendedExists ) - ? i18n( "%1 family uses %2 file to generate correct database checksum.", - gen, sysInfoExtended ) - : i18n( "%1 family needs %2 file to generate correct database checksum.", - gen, sysInfoExtended ); - if( !sysInfoExtendedExists ) - return false; - } - if( hashInfoNeeded( info->ipod_generation ) ) - { - const QString hashInfo( "HashInfo" ); - bool hashInfoExists = fileFound( mountPoint, hashInfo ); - message += hashInfoExists - ? i18n( "%1 family uses %2 file to generate correct database checksum.", - gen, hashInfo ) - : i18n( "%1 family needs %2 file to generate correct database checksum.", - gen, hashInfo ); - if( !hashInfoExists ) - return false; - } - if( hashAbNeeded( info->ipod_generation ) ) - { - message += i18nc( "Do not translate hash-AB, libgpod, libhashab.so", - "%1 family probably uses hash-AB to generate correct database checksum. " - "libgpod (as of version 0.8.2) doesn't know how to compute it, but tries " - "to dynamically load external library libhashab.so to do it.", gen - ); - // we don't return false, user may have hash-AB support installed - } - return true; -} - -static void -fillInModelComboBox( QComboBox *comboBox, bool someSysInfoFound ) -{ - if( someSysInfoFound ) - { - comboBox->addItem( i18n( "Autodetect (%1 file(s) present)", QString( "SysInfo") ), QString() ); - comboBox->setEnabled( false ); - return; - } - - const Itdb_IpodInfo *info = itdb_info_get_ipod_info_table(); - if( !info ) - { - // this is not i18n-ed for purpose: it should never happen - comboBox->addItem( QString( "Failed to get iPod info table!" ), QString() ); - return; - } - - while( info->model_number ) - { - QString generation = QString::fromUtf8( itdb_info_get_ipod_generation_string( info->ipod_generation) ); - QString capacity = KGlobal::locale()->formatByteSize( info->capacity * 1073741824.0, 0 ); - QString modelName = QString::fromUtf8( itdb_info_get_ipod_model_name_string( info->ipod_model ) ); - QString modelNumber = QString::fromUtf8( info->model_number ); - QString label = i18nc( "Examples: " - "%1: Nano with camera (5th Gen.); [generation]" - "%2: 16 GiB; [capacity]" - "%3: Nano (Orange); [model name]" - "%4: A123 [model number]", - "%1: %2 %3 [%4]", - generation, capacity, modelName, modelNumber ); - comboBox->addItem( label, modelNumber ); - info++; // list is ended by null-filled info - } - comboBox->setMaxVisibleItems( 16 ); -} - -void -IpodDeviceHelper::fillInConfigureDialog( KDialog *configureDialog, - Ui::IpodConfiguration *configureDialogUi, - const QString &mountPoint, - Itdb_iTunesDB *itdb, - const Transcoding::Configuration &transcodeConfig, - const QString &errorMessage ) -{ - static const QString unknown = i18nc( "Unknown iPod model, generation...", "Unknown" ); - static const QString supported = i18nc( "In a dialog: Video: Supported", "Supported" ); - static const QString notSupported = i18nc( "In a dialog: Video: Not supported", "Not supported" ); - static const QString present = i18nc( "In a dialog: Some file: Present", "Present" ); - static const QString notFound = i18nc( "In a dialog: Some file: Not found", "Not found" ); - static const QString notNeeded = i18nc( "In a dialog: Some file: Not needed", "Not needed" ); - - // following call accepts null itdb - configureDialogUi->nameLineEdit->setText( IpodDeviceHelper::ipodName( itdb ) ); - QString notes; - QString warningText; - QString safeToWriteMessage; - bool isSafeToWrite = safeToWriteWithMessage( mountPoint, itdb, safeToWriteMessage ); - bool sysInfoExtendedExists = fileFound( mountPoint, "SysInfoExtended" ); - bool sysInfoExists = fileFound( mountPoint, "SysInfo" ); - - if( itdb ) - { - configureDialogUi->nameLineEdit->setEnabled( isSafeToWrite ); - configureDialogUi->transcodeComboBox->setEnabled( isSafeToWrite ); - configureDialogUi->transcodeComboBox->fillInChoices( transcodeConfig ); - configureDialogUi->modelComboLabel->setEnabled( false ); - configureDialogUi->modelComboBox->setEnabled( false ); - configureDialogUi->initializeLabel->setEnabled( false ); - configureDialogUi->initializeButton->setEnabled( false ); - if( !errorMessage.isEmpty() ) - // to inform user about successful initialization. - warningText = QString( "%1" ).arg( errorMessage ); - - const Itdb_Device *device = itdb->device; - const Itdb_IpodInfo *info = device ? itdb_device_get_ipod_info( device ) : 0; - configureDialogUi->infoGroupBox->setEnabled( true ); - configureDialogUi->modelPlaceholer->setText( info ? QString::fromUtf8( - itdb_info_get_ipod_model_name_string( info->ipod_model ) ) : unknown ); - configureDialogUi->generationPlaceholder->setText( info ? QString::fromUtf8( - itdb_info_get_ipod_generation_string( info->ipod_generation ) ) : unknown ); - configureDialogUi->videoPlaceholder->setText( device ? - ( itdb_device_supports_video( device ) ? supported : notSupported ) : unknown ); - configureDialogUi->albumArtworkPlaceholder->setText( device ? - ( itdb_device_supports_artwork( device ) ? supported : notSupported ) : unknown ); - - if( isSafeToWrite ) - notes += safeToWriteMessage; // may be empty, doesn't hurt - else - { - Q_ASSERT( !safeToWriteMessage.isEmpty() ); - const QString link( "http://gtkpod.git.sourceforge.net/git/gitweb.cgi?p=gtkpod/libgpod;a=blob_plain;f=README.overview" ); - notes += i18nc( "%1 is informational sentence giving reason", - "%1

    " - "As a safety measure, Amarok will refuse to perform any writes to " - "iPod. (modifying iTunes database could make it look empty from the device " - "point of view)
    " - "See README.overview file from libgpod source repository " - "for more information.", - safeToWriteMessage, link - ); - } - } - else - { - configureDialogUi->nameLineEdit->setEnabled( true ); // for initialization - configureDialogUi->modelComboLabel->setEnabled( true ); - configureDialogUi->modelComboBox->setEnabled( true ); - if( configureDialogUi->modelComboBox->count() == 0 ) - fillInModelComboBox( configureDialogUi->modelComboBox, sysInfoExists || sysInfoExtendedExists ); - configureDialogUi->initializeLabel->setEnabled( true ); - configureDialogUi->initializeButton->setEnabled( true ); - configureDialogUi->initializeButton->setIcon( KIcon( "task-attention" ) ); - if( !errorMessage.isEmpty() ) - warningText = i18n( - "%1

    " - "Above problem prevents Amarok from using your iPod. You can try to " - "re-create critical iPod folders and files (including iTunes database) " - "using the %2 button below.

    " - "Initializing iPod destroys iPod track and photo database, however " - "it should not delete any tracks. The tracks will become orphaned.", - errorMessage, - configureDialogUi->initializeButton->text().remove( QChar('&') ) - ); - - configureDialogUi->infoGroupBox->setEnabled( false ); - configureDialogUi->modelPlaceholer->setText( unknown ); - configureDialogUi->generationPlaceholder->setText( unknown ); - configureDialogUi->videoPlaceholder->setText( unknown ); - configureDialogUi->albumArtworkPlaceholder->setText( unknown ); - } - - if( !warningText.isEmpty() ) - { - configureDialogUi->initializeLabel->setText( warningText ); - configureDialogUi->initializeLabel->adjustSize(); - } - - QString sysInfoExtendedString = sysInfoExtendedExists ? present : notFound; - QString sysInfoString = sysInfoExists ? present : - ( sysInfoExtendedExists ? notNeeded : notFound ); - - configureDialogUi->sysInfoPlaceholder->setText( sysInfoString ); - configureDialogUi->sysInfoExtendedPlaceholder->setText( sysInfoExtendedString ); - configureDialogUi->notesPlaceholder->setText( notes ); - configureDialogUi->notesPlaceholder->adjustSize(); - - configureDialog->enableButtonOk( isSafeToWrite ); -} - -bool -IpodDeviceHelper::initializeIpod( const QString &mountPoint, - const Ui::IpodConfiguration *configureDialogUi, - QString &errorMessage ) -{ - DEBUG_BLOCK - bool success = true; - - int currentModelIndex = configureDialogUi->modelComboBox->currentIndex(); - QByteArray modelNumber = configureDialogUi->modelComboBox->itemData( currentModelIndex ).toString().toUtf8(); - if( !modelNumber.isEmpty() ) - { - modelNumber.prepend( 'x' ); // ModelNumStr should start with x - const char *modelNumberRaw = modelNumber.constData(); - Itdb_Device *device = itdb_device_new(); - // following call reads existing SysInfo - itdb_device_set_mountpoint( device, QFile::encodeName( mountPoint ) ); - const char *field = "ModelNumStr"; - debug() << "Setting SysInfo field" << field << "to value" << modelNumberRaw; - itdb_device_set_sysinfo( device, field, modelNumberRaw ); - GError *error = 0; - success = itdb_device_write_sysinfo( device, &error ); - if( !success ) - { - if( error ) - { - errorMessage = i18nc( "Do not translate SysInfo", - "Failed to write SysInfo: %1", error->message ); - g_error_free( error ); - } - else - errorMessage = i18nc( "Do not translate SysInfo", - "Failed to write SysInfo file due to an unreported error" ); - } - itdb_device_free( device ); - if( !success ) - return success; - } - - QString name = configureDialogUi->nameLineEdit->text(); - if( name.isEmpty() ) - name = ipodName( 0 ); // return fallback name - - GError *error = 0; - success = itdb_init_ipod( QFile::encodeName( mountPoint ), 0 /* model number */, - name.toUtf8(), &error ); - errorMessage.clear(); - if( error ) - { - errorMessage = QString::fromUtf8( error->message ); - g_error_free( error ); - error = 0; - } - if( !success && errorMessage.isEmpty() ) - errorMessage = i18n( "Cannot initialize iPod due to an unreported error." ); - return success; -} - -void -IpodDeviceHelper::setIpodName( Itdb_iTunesDB *itdb, const QString &newName ) -{ - if( !itdb ) - return; - Itdb_Playlist *mpl = itdb_playlist_mpl( itdb ); - if( !mpl ) - return; - g_free( mpl->name ); - mpl->name = g_strdup( newName.toUtf8() ); -} - -bool -IpodDeviceHelper::safeToWrite( const QString &mountPoint, const Itdb_iTunesDB *itdb ) -{ - QString dummyMessage; - return safeToWriteWithMessage( mountPoint, itdb, dummyMessage ); -} diff --git a/amarok/src/core-impl/collections/ipodcollection/IpodDeviceHelper.h b/amarok/src/core-impl/collections/ipodcollection/IpodDeviceHelper.h deleted file mode 100644 index 0784f6fe..00000000 --- a/amarok/src/core-impl/collections/ipodcollection/IpodDeviceHelper.h +++ /dev/null @@ -1,102 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef IPODDEVICEHELPER_H -#define IPODDEVICEHELPER_H - -#include "ui_IpodConfiguration.h" -#include "amarok_export.h" -#include "core/transcoding/TranscodingConfiguration.h" - -#include - -#include - -#include - - -namespace IpodDeviceHelper { - - /** - * Tries to parse itunes db from an iPod mounted at @param mountPoint. - * @param errorMsg is set appropriately if error occurred - * @return valid itdb or null, in which case @param errorMsg is not empty - */ - AMAROK_EXPORT Itdb_iTunesDB *parseItdb( const QString &mountPoint, QString &errorMsg ); - - /** - * Return pretty iPod name usable as collection name. - * @param itdb parsed iTunes db, may be null in which cese fallback name is used - */ - AMAROK_EXPORT QString collectionName( Itdb_iTunesDB *itdb ); - - /** - * Return iPod name without model, or placeholder if no or empty name can be read - */ - AMAROK_EXPORT QString ipodName( Itdb_iTunesDB *itdb ); - - /** - * Unlinks playlists and tracks from itdb so that itdb no longer frees them when it - * itself is freed. Does nothing when itdb is null. - */ - AMAROK_EXPORT void unlinkPlaylistsTracksFromItdb( Itdb_iTunesDB *itdb ); - - /** - * Fills in a dialog with iPod configuration. - * - * @param configureDialog KDialog that coutains the ui. Must not be null - * @param configureDialogUi ui of the dialog. Must not be null - * @param itdb itdb of the device or null if could not be parsed - * @param transcodeConfig current transcoding configuration preference - * @param errorMessage from parsing/initializing itsb (empty if no error) - */ - AMAROK_EXPORT void fillInConfigureDialog( KDialog *configureDialog, - Ui::IpodConfiguration *configureDialogUi, - const QString &mountPoint, - Itdb_iTunesDB *itdb, - const Transcoding::Configuration &transcodeConfig, - const QString &errorMessage = QString() ); - - /** - * Try to initialize iPod using libgpod. - * - * @param mountPoint mount point of an already mounted iPod - * @param configureDialogUi configure dialog ui from which some info is gathered - * @param errorMessage if initializing fails, errorMessage will contain problem - * - * @return true if initialization succeeded, false otherwise - */ - AMAROK_EXPORT bool initializeIpod( const QString& mountPoint, - const Ui::IpodConfiguration *configureDialogUi, - QString &errorMessage ); - - /** - * Sets iPod name to @param name. Does nothing if @param itdb is null - */ - AMAROK_EXPORT void setIpodName( Itdb_iTunesDB *itdb, const QString &newName ); - - /** - * Return true if it is considered safe to write to itdb. itdb can be null and this - * function is guaranteed to return false in such case. - * - * @param mountPoint path to a mounted ipod - * @param itdb iTunes database, may be null - */ - AMAROK_EXPORT bool safeToWrite( const QString &mountPoint, const Itdb_iTunesDB *itdb ); - -} // namespace IpodDeviceHelper - -#endif // IPODDEVICEHELPER_H diff --git a/amarok/src/core-impl/collections/ipodcollection/IpodMeta.cpp b/amarok/src/core-impl/collections/ipodcollection/IpodMeta.cpp deleted file mode 100644 index 6beca0ab..00000000 --- a/amarok/src/core-impl/collections/ipodcollection/IpodMeta.cpp +++ /dev/null @@ -1,888 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl . * - ****************************************************************************************/ - -#include "IpodMeta.h" - -#include "amarokconfig.h" -#include "core/support/Amarok.h" -#include "core/support/Debug.h" -#include "core-impl/collections/ipodcollection/IpodCollection.h" -#include "core-impl/collections/ipodcollection/config-ipodcollection.h" -#include "core-impl/collections/support/jobs/WriteTagsJob.h" -#include "core-impl/collections/support/ArtistHelper.h" -#include "covermanager/CoverCache.h" -#include "FileType.h" - -#include -#include - -#include -#include -#ifdef GDKPIXBUF_FOUND -#undef signals // gdbusintrospection.h uses a member named signals, prevent build fail -#include -#include -#endif - - -using namespace IpodMeta; - -gpointer AmarokItdbUserDataDuplicateFunc( gpointer userdata ) -{ - Q_UNUSED( userdata ) - return 0; // we never copy our userdata -} - -Track::Track( Itdb_Track *ipodTrack ) - : m_track( ipodTrack ) - , m_batch( 0 ) -{ - Q_ASSERT( m_track != 0 ); - m_track->usertype = m_gpodTrackUserTypeAmarokTrackPtr; - m_track->userdata = this; - m_track->userdata_duplicate = AmarokItdbUserDataDuplicateFunc; -} - -Track::Track( const Meta::TrackPtr &origTrack ) - : m_track( itdb_track_new() ) - , m_batch( 0 ) -{ - Q_ASSERT( m_track != 0 ); - m_track->usertype = m_gpodTrackUserTypeAmarokTrackPtr; - m_track->userdata = this; - m_track->userdata_duplicate = AmarokItdbUserDataDuplicateFunc; - - Meta::AlbumPtr origAlbum = origTrack->album(); - Meta::ArtistPtr origArtist = origTrack->artist(); - - beginUpdate(); - setTitle( origTrack->name() ); - // url is set in setCollection() - setAlbum( origAlbum ? origAlbum->name() : QString() ); - setArtist( origArtist ? origArtist->name() : QString() ); - setComposer( origTrack->composer() ? origTrack->composer()->name() : QString() ); - setGenre( origTrack->genre() ? origTrack->genre()->name() : QString() ); - setYear( origTrack->year() ? origTrack->year()->year() : 0 ); - - QString albumArtist; - bool isCompilation = false; - if ( origAlbum ) - { - isCompilation = origAlbum->isCompilation(); - if( origAlbum->hasAlbumArtist() && origAlbum->albumArtist() ) - albumArtist = origAlbum->albumArtist()->name(); - - if( origAlbum->hasImage() ) - setImage( origAlbum->image() ); - } - /* iPod doesn't handle empty album artist well for compilation albums (splits these - * albums). Ensure that we have something in albumArtist. We filter it for Amarok for - * compilation albums in IpodMeta::Album::albumArtist() */ - if( albumArtist.isEmpty() && origArtist ) - albumArtist = origArtist->name(); - if( albumArtist.isEmpty() ) - albumArtist = i18n( "Various Artists" ); - - Meta::ConstStatisticsPtr origStats = origTrack->statistics(); - - setAlbumArtist( albumArtist ); - setIsCompilation( isCompilation ); - - setBpm( origTrack->bpm() ); - setComment( origTrack->comment() ); - - setScore( origStats->score() ); - setRating( origStats->rating() ); - - setLength( origTrack->length() ); - // filesize is set in finalizeCopying(), which could be more accurate - setSampleRate( origTrack->sampleRate() ); - setBitrate( origTrack->bitrate() ); - - setCreateDate( QDateTime::currentDateTime() ); // createDate == added to collection - setModifyDate( origTrack->modifyDate() ); - - setTrackNumber( origTrack->trackNumber() ); - setDiscNumber( origTrack->discNumber() ); - - setLastPlayed( origStats->lastPlayed() ); - setFirstPlayed( origStats->firstPlayed() ); - setPlayCount( origStats->playCount() ); - - setReplayGain( Meta::ReplayGain_Track_Gain, origTrack->replayGain( Meta::ReplayGain_Track_Gain ) ); - setReplayGain( Meta::ReplayGain_Track_Peak, origTrack->replayGain( Meta::ReplayGain_Track_Peak ) ); - setReplayGain( Meta::ReplayGain_Album_Gain, origTrack->replayGain( Meta::ReplayGain_Album_Gain ) ); - setReplayGain( Meta::ReplayGain_Album_Peak, origTrack->replayGain( Meta::ReplayGain_Album_Peak ) ); - - setType( origTrack->type() ); - m_changedFields.clear(); // some of the set{Something} insert to m_changedFields, not - // desirable for constructor - endUpdate(); -} - -Track::~Track() -{ - itdb_track_free( m_track ); - if( !m_tempImageFilePath.isEmpty() ) - QFile::remove( m_tempImageFilePath ); -} - -QString -Track::name() const -{ - QReadLocker locker( &m_trackLock ); - return QString::fromUtf8( m_track->title ); -} - -void -Track::setTitle( const QString &newTitle ) -{ - QWriteLocker locker( &m_trackLock ); - g_free( m_track->title ); - m_track->title = g_strdup( newTitle.toUtf8() ); - commitIfInNonBatchUpdate( Meta::valTitle, newTitle ); -} - -KUrl -Track::playableUrl() const -{ - if( m_mountPoint.isEmpty() || !m_track->ipod_path || m_track->ipod_path[0] == '\0' ) - return KUrl(); - QReadLocker locker( &m_trackLock ); - gchar *relPathChar = g_strdup( m_track->ipod_path ); - locker.unlock(); - itdb_filename_ipod2fs( relPathChar ); // in-place - // relPath begins with a slash - QString relPath = QFile::decodeName( relPathChar ); - g_free( relPathChar ); - return KUrl( m_mountPoint + relPath ); -} - -QString -Track::prettyUrl() const -{ - const KUrl &url = playableUrl(); - if( url.isLocalFile() ) - return url.toLocalFile(); - - QString collName = m_coll ? m_coll.data()->prettyName() : i18n( "Unknown Collection" ); - QString artistName = artist() ? artist()->prettyName() : i18n( "Unknown Artist" ); - QString trackName = !name().isEmpty() ? name() : i18n( "Unknown track" ); - - return QString( "%1: %2 - %3" ).arg( collName, artistName, trackName ); -} - -QString -Track::uidUrl() const -{ - QReadLocker locker( &m_trackLock ); - gchar *relPathChar = g_strdup( m_track->ipod_path ); - locker.unlock(); - itdb_filename_ipod2fs( relPathChar ); // in-place - // relPath begins with a slash - QString relPath = QFile::decodeName( relPathChar ); - g_free( relPathChar ); - - if( m_coll ) - return m_coll.data()->collectionId() + relPath; - else - return m_mountPoint + relPath; -} - -QString -Track::notPlayableReason() const -{ - return localFileNotPlayableReason( playableUrl().toLocalFile() ); -} - -Meta::AlbumPtr -Track::album() const -{ - // we may not store KSharedPtr to Album because it would create circular reference - return Meta::AlbumPtr( new Album( const_cast( this ) ) ); -} - -void -Track::setAlbum( const QString &newAlbum ) -{ - QWriteLocker locker( &m_trackLock ); - g_free( m_track->album ); - m_track->album = g_strdup( newAlbum.toUtf8() ); - commitIfInNonBatchUpdate( Meta::valAlbum, newAlbum ); -} - -void -Track::setAlbumArtist( const QString &newAlbumArtist ) -{ - QWriteLocker locker( &m_trackLock ); - g_free( m_track->albumartist ); - m_track->albumartist = g_strdup( newAlbumArtist.toUtf8() ); - commitIfInNonBatchUpdate( Meta::valAlbumArtist, newAlbumArtist ); -} - -void -Track::setIsCompilation( bool newIsCompilation ) -{ - // libgpod says: m_track->combination: True if set to 0x1, false if set to 0x0. - if( m_track->compilation == newIsCompilation ) - return; // nothing to do - - QWriteLocker locker( &m_trackLock ); - m_track->compilation = newIsCompilation ? 0x1 : 0x0; - commitIfInNonBatchUpdate( Meta::valCompilation, newIsCompilation ); -} - -void -Track::setImage( const QImage &newImage ) -{ - QWriteLocker locker( &m_trackLock ); - if( !m_tempImageFilePath.isEmpty() ) - QFile::remove( m_tempImageFilePath ); - m_tempImageFilePath.clear(); - if( newImage.isNull() ) - itdb_track_remove_thumbnails( m_track ); - else - { - // we set artwork even for devices that don't support it, everyone has new-enough iPod nowadays - const int maxSize = AmarokConfig::writeBackCoverDimensions(); - QImage image; - if( newImage.width() > maxSize || newImage.height() > maxSize ) - image = newImage.scaled( maxSize, maxSize, Qt::KeepAspectRatio, Qt::SmoothTransformation ); - else - image = newImage; - - KTemporaryFile tempImageFile; - tempImageFile.setAutoRemove( false ); // file will be removed in ~Track() - tempImageFile.setSuffix( QString( ".png" ) ); - // we save the file to disk rather than pass image data to save several megabytes of RAM - if( tempImageFile.open() ) - m_tempImageFilePath = tempImageFile.fileName(); - if( tempImageFile.isOpen() && image.save( &tempImageFile, "PNG" ) ) - /* this function remembers image path, it also fogots previous images (if any) - * and sets artwork_size, artwork_count and has_artwork m_track fields */ - itdb_track_set_thumbnails( m_track, QFile::encodeName( m_tempImageFilePath ) ); - } - commitIfInNonBatchUpdate( Meta::valImage, newImage ); -} - -Meta::ArtistPtr -Track::artist() const -{ - QReadLocker locker( &m_trackLock ); - return Meta::ArtistPtr( new Artist( QString::fromUtf8( m_track->artist ) ) ); -} - -void -Track::setArtist( const QString &newArtist ) -{ - QWriteLocker locker( &m_trackLock ); - g_free( m_track->artist ); - m_track->artist = g_strdup( newArtist.toUtf8() ); - commitIfInNonBatchUpdate( Meta::valArtist, newArtist ); -} - -Meta::ComposerPtr -Track::composer() const -{ - QReadLocker locker( &m_trackLock ); - return Meta::ComposerPtr( new Composer( QString::fromUtf8( m_track->composer ) ) ); -} - -void -Track::setComposer( const QString &newComposer ) -{ - QWriteLocker locker( &m_trackLock ); - g_free( m_track->composer ); - m_track->composer = g_strdup( newComposer.toUtf8() ); - commitIfInNonBatchUpdate( Meta::valComposer, newComposer ); -} - -Meta::GenrePtr -Track::genre() const -{ - QReadLocker locker( &m_trackLock ); - return Meta::GenrePtr( new Genre( QString::fromUtf8( m_track->genre ) ) ); -} - -void -Track::setGenre( const QString &newGenre ) -{ - QWriteLocker locker( &m_trackLock ); - g_free( m_track->genre ); - m_track->genre = g_strdup( newGenre.toUtf8() ); - commitIfInNonBatchUpdate( Meta::valGenre, newGenre ); -} - -Meta::YearPtr -Track::year() const -{ - // no need for lock here, reading integer should be atomic - return Meta::YearPtr( new Year( QString::number( m_track->year ) ) ); -} - -void Track::setYear( int newYear ) -{ - QWriteLocker locker( &m_trackLock ); - m_track->year = newYear; - commitIfInNonBatchUpdate( Meta::valYear, newYear ); -} - -qreal -Track::bpm() const -{ - // no need for lock here, integer read - return m_track->BPM; -} - -void Track::setBpm( const qreal newBpm ) -{ - QWriteLocker locker( &m_trackLock ); - m_track->BPM = newBpm; - commitIfInNonBatchUpdate( Meta::valBpm, newBpm ); -} - -QString -Track::comment() const -{ - QReadLocker locker( &m_trackLock ); - return QString::fromUtf8( m_track->comment ); -} - -void Track::setComment( const QString &newComment ) -{ - QWriteLocker locker( &m_trackLock ); - g_free( m_track->comment ); - m_track->comment = g_strdup( newComment.toUtf8() ); - commitIfInNonBatchUpdate( Meta::valComment, newComment ); -} - -int -Track::rating() const -{ - /* (rating/RATING_STEP) is a number of stars, Amarok uses numer of half-stars. - * the order of multiply and divide operations is significant because of rounding */ - return ( ( m_track->rating * 2 ) / ITDB_RATING_STEP ); -} - -void -Track::setRating( int newRating ) -{ - newRating = ( newRating * ITDB_RATING_STEP ) / 2; - if( newRating == (int) m_track->rating ) // casting prevents compiler waring about signedness - return; // nothing to do, do not notify observers - - QWriteLocker locker( &m_trackLock ); - m_track->rating = newRating; - commitIfInNonBatchUpdate( Meta::valRating, newRating ); -} - -qint64 -Track::length() const -{ - return m_track->tracklen; -} - -void -Track::setLength( qint64 newLength ) -{ - QWriteLocker locker( &m_trackLock ); - m_track->tracklen = newLength; - commitIfInNonBatchUpdate( Meta::valLength, newLength ); -} - -int -Track::filesize() const -{ - return m_track->size; -} - -int -Track::sampleRate() const -{ - return m_track->samplerate; -} - -void -Track::setSampleRate( int newSampleRate ) -{ - QWriteLocker locker( &m_trackLock ); - m_track->samplerate = newSampleRate; - commitIfInNonBatchUpdate( Meta::valSamplerate, newSampleRate ); -} - -int -Track::bitrate() const -{ - return m_track->bitrate; -} - -void -Track::setBitrate( int newBitrate ) -{ - QWriteLocker locker( &m_trackLock ); - m_track->bitrate = newBitrate; - commitIfInNonBatchUpdate( Meta::valBitrate, newBitrate ); -} - -QDateTime -Track::createDate() const -{ - time_t time = m_track->time_added; - if( time == 0 ) - return QDateTime(); // 0 means "no reasonable time", so return invalid QDateTime - return QDateTime::fromTime_t( time ); -} - -void -Track::setCreateDate( const QDateTime &newDate ) -{ - QWriteLocker locker( &m_trackLock ); - m_track->time_added = newDate.isValid() ? newDate.toTime_t() : 0; - commitIfInNonBatchUpdate( Meta::valCreateDate, newDate ); -} - -QDateTime -Track::modifyDate() const -{ - time_t time = m_track->time_modified; - if( time == 0 ) - return QDateTime(); // 0 means "no reasonable time", so return invalid QDateTime - return QDateTime::fromTime_t( time ); -} - -void -Track::setModifyDate( const QDateTime &newDate ) -{ - // this method _cannot_ lock m_trackLock or deadlock will occur in commitChanges() - m_track->time_modified = newDate.isValid() ? newDate.toTime_t() : 0; -} - -int -Track::trackNumber() const -{ - // no need for lock here, integer read - return m_track->track_nr; -} - -void -Track::setTrackNumber( int newTrackNumber ) -{ - QWriteLocker locker( &m_trackLock ); - m_track->track_nr = newTrackNumber; - commitIfInNonBatchUpdate( Meta::valTrackNr, newTrackNumber ); -} - -int -Track::discNumber() const -{ - // no need for lock here, integer read - return m_track->cd_nr; -} - -void -Track::setDiscNumber( int newDiscNumber ) -{ - QWriteLocker locker( &m_trackLock ); - m_track->cd_nr = newDiscNumber; - commitIfInNonBatchUpdate( Meta::valDiscNr, newDiscNumber ); -} - -QDateTime -Track::lastPlayed() const -{ - return m_track->time_played ? QDateTime::fromTime_t( m_track->time_played ) : QDateTime(); -} - -void -Track::setLastPlayed( const QDateTime &time ) -{ - QWriteLocker locker( &m_trackLock ); - m_track->time_played = time.isValid() ? time.toTime_t() : 0; - commitIfInNonBatchUpdate( Meta::valLastPlayed, time ); -} - -QDateTime -Track::firstPlayed() const -{ - // we abuse time_released for this, which should be okay for non-podcast tracks - // TODO: return QDateTime for podcast tracks - return m_track->time_released ? QDateTime::fromTime_t( m_track->time_released ) : QDateTime(); -} - -void -Track::setFirstPlayed( const QDateTime &time ) -{ - QWriteLocker locker( &m_trackLock ); - m_track->time_released = time.isValid() ? time.toTime_t() : 0; - commitIfInNonBatchUpdate( Meta::valFirstPlayed, time ); -} - -int -Track::playCount() const -{ - return m_track->playcount; -} - -int -Track::recentPlayCount() const -{ - if( !m_coll || !m_coll.data()->isWritable() ) - return 0; // we must be able to reset recent playcount if we return nonzero - return m_track->recent_playcount; -} - -void -Track::setPlayCount( const int playcount ) -{ - QWriteLocker locker( &m_trackLock ); - m_track->playcount = playcount; - m_track->recent_playcount = 0; - commitIfInNonBatchUpdate( Meta::valLastPlayed, playcount ); -} - -qreal -Track::replayGain( Meta::ReplayGainTag mode ) const -{ - // iPods are not able to differentiante between different replay gain modes (track & album) - switch( mode ) - { - case Meta::ReplayGain_Track_Gain: - case Meta::ReplayGain_Album_Gain: - break; // fall to the computation - case Meta::ReplayGain_Track_Peak: - case Meta::ReplayGain_Album_Peak: - return 0.0; // perhaps return -replayGain assuming there was enough headroom - } - - if( m_track->soundcheck == 0 ) - return 0.0; // libgpod: The value 0 is special, treated as "no Soundcheck" - // libgpod: X = 1000 * 10 ^ (-.1 * Y) - // where Y is the adjustment value in dB and X is the value that goes into the SoundCheck field - return 30.0 - 10.0 * std::log10( m_track->soundcheck ); -} - -void -Track::setReplayGain( Meta::ReplayGainTag mode, qreal newReplayGain ) -{ - guint32 soundcheck; - switch( mode ) - { - case Meta::ReplayGain_Track_Gain: - if( newReplayGain == 0.0 ) - // libgpod: The value 0 is special, treated as "no Soundcheck" - soundcheck = 0; - else - // libgpod: X = 1000 * 10 ^ (-.1 * Y) - // where Y is the adjustment value in dB and X is the value that goes into the SoundCheck field - soundcheck = 1000 * std::pow( 10.0, -0.1 * newReplayGain ); - m_track->soundcheck = soundcheck; - break; - case Meta::ReplayGain_Album_Gain: - case Meta::ReplayGain_Track_Peak: - // we should somehow abuse Itdb_Track to store this, it is really needed - case Meta::ReplayGain_Album_Peak: - break; - } -} - -QString -Track::type() const -{ - QReadLocker locker( &m_trackLock ); - return QString::fromUtf8( m_track->filetype ); -} - -void -Track::setType( const QString &newType ) -{ - QWriteLocker locker( &m_trackLock ); - g_free( m_track->filetype ); - m_track->filetype = g_strdup( newType.toUtf8() ); - commitIfInNonBatchUpdate( Meta::valFormat, newType ); -} - -bool -Track::inCollection() const -{ - return m_coll; // converts to bool nicely -} - -Collections::Collection* -Track::collection() const -{ - return m_coll.data(); -} - -Meta::TrackEditorPtr -Track::editor() -{ - return Meta::TrackEditorPtr( isEditable() ? this : 0 ); -} - -Meta::StatisticsPtr -Track::statistics() -{ - return Meta::StatisticsPtr( this ); -} - -Meta::TrackPtr -Track::fromIpodTrack( const Itdb_Track *ipodTrack ) -{ - if( !ipodTrack ) - return Meta::TrackPtr(); - if( ipodTrack->usertype != m_gpodTrackUserTypeAmarokTrackPtr ) - return Meta::TrackPtr(); - if( !ipodTrack->userdata ) - return Meta::TrackPtr(); - return Meta::TrackPtr( static_cast( ipodTrack->userdata ) ); -} - -Itdb_Track* -Track::itdbTrack() const -{ - return m_track; -} - -bool -Track::finalizeCopying( const gchar *mountPoint, const gchar *filePath ) -{ - GError *error = 0; - // we cannot use m_mountPoint, we are not yet in collection - Itdb_Track *res = itdb_cp_finalize( m_track, mountPoint, filePath, &error ); - if( error ) - { - warning() << "Failed to finalize copying of iPod track:" << error->message; - g_error_free( error ); - error = 0; - } - return res == m_track; -} - -void -Track::setCollection( QWeakPointer collection ) -{ - m_coll = collection; - if( !collection ) - return; - { // scope for locker - QWriteLocker locker( &m_trackLock ); - // paranoia: collection may become null while we were waiting for lock... - m_mountPoint = collection ? collection.data()->mountPoint() : QString(); - } - - // m_track->filetype field may have been set by someone else, rather check it (if set - // by us, it can be more accurate than file extension, so we prefer it) - if( !Amarok::FileTypeSupport::possibleFileTypes().contains( type() ) ) - setType( Amarok::extension( playableUrl().path() ) ); - // we don't make the datbase dirty, this can be recomputed every time -} - -void Track::beginUpdate() -{ - QWriteLocker locker( &m_trackLock ); - m_batch++; -} - -void Track::endUpdate() -{ - QWriteLocker locker( &m_trackLock ); - Q_ASSERT( m_batch > 0 ); - m_batch--; - commitIfInNonBatchUpdate(); -} - -bool -Track::isEditable() const -{ - if( !inCollection() ) - return false; - return collection()->isWritable(); // IpodCollection implements this nicely -} - -void -Track::commitIfInNonBatchUpdate( qint64 field, const QVariant &value ) -{ - m_changedFields.insert( field, value ); - commitIfInNonBatchUpdate(); -} - -void -Track::commitIfInNonBatchUpdate() -{ - static const QSet statFields = ( QSet() << Meta::valFirstPlayed << - Meta::valLastPlayed << Meta::valPlaycount << Meta::valScore << Meta::valRating ); - - if( m_batch > 0 || m_changedFields.isEmpty() ) - return; - - // we block changing the track meta-data of read-only iPod Collections; - // it would only be cofusing to the user as the changes would get discarded. - if( !m_coll || !m_coll.data()->isWritable() ) - return; - - if( AmarokConfig::writeBackStatistics() || - !(QSet::fromList( m_changedFields.keys() ) - statFields).isEmpty() ) - { - setModifyDate( QDateTime::currentDateTime() ); - } - - m_trackLock.unlock(); // playableUrl() locks it too, notifyObservers() better without lock - QString path = playableUrl().path(); // needs to be here because it locks m_trackLock too - - // write tags to file in a thread in order not to block - WriteTagsJob *job = new WriteTagsJob( path, m_changedFields ); - job->connect( job, SIGNAL(done(ThreadWeaver::Job*)), job, SLOT(deleteLater()) ); - ThreadWeaver::Weaver::instance()->enqueue( job ); - - notifyObservers(); - m_trackLock.lockForWrite(); // reset to original state when this was called - m_changedFields.clear(); -} - -// IpodMeta:Album - -Album::Album( Track *track ) - : m_track( track ) -{ -} - -QString Album::name() const -{ - QReadLocker locker( &m_track->m_trackLock ); - return QString::fromUtf8( m_track->m_track->album ); -} - -bool -Album::isCompilation() const -{ - return m_track->m_track->compilation; -} - -bool -Album::canUpdateCompilation() const -{ - Collections::Collection *coll = m_track->collection(); - return coll ? coll->isWritable() : false; -} - -void -Album::setCompilation( bool isCompilation ) -{ - m_track->setIsCompilation( isCompilation ); -} - -bool -Album::hasAlbumArtist() const -{ - return !isCompilation(); -} - -Meta::ArtistPtr -Album::albumArtist() const -{ - if( isCompilation() ) - return Meta::ArtistPtr(); - QReadLocker locker( &m_track->m_trackLock ); - QString albumArtistName = QString::fromUtf8( m_track->m_track->albumartist ); - if( albumArtistName.isEmpty() ) - albumArtistName = QString::fromUtf8( m_track->m_track->artist ); - return Meta::ArtistPtr( new Artist( albumArtistName ) ); -} - -bool -Album::hasImage( int size ) const -{ - Q_UNUSED(size) - if( m_track->m_track->has_artwork != 0x01 ) - return false; // libgpod: has_artwork: True if set to 0x01, false if set to 0x02. - return itdb_track_has_thumbnails( m_track->m_track ); // should be false if GdbPixBuf is not available -} - -QImage -Album::image( int size ) const -{ - Q_UNUSED(size) // MemoryMeta does scaling for us - - QImage albumImage; -#ifdef GDKPIXBUF_FOUND - do { - if( m_track->m_track->has_artwork != 0x01 ) - break; // libgpod: has_artwork: True if set to 0x01, false if set to 0x02. - - // it reads "thumbnail", but this is the correct function to call - GdkPixbuf *pixbuf = (GdkPixbuf*) itdb_track_get_thumbnail( m_track->m_track, -1, -1 ); - if( !pixbuf ) - break; - if( gdk_pixbuf_get_colorspace( pixbuf ) != GDK_COLORSPACE_RGB ) - { - warning() << __PRETTY_FUNCTION__ << "Unsupported GTK colorspace."; - g_object_unref( pixbuf ); - break; - } - if( gdk_pixbuf_get_bits_per_sample( pixbuf ) != 8 ) - { - warning() << __PRETTY_FUNCTION__ << "Unsupported number of bits per sample."; - g_object_unref( pixbuf ); - break; - } - int n_channels = gdk_pixbuf_get_n_channels( pixbuf ); - bool has_alpha = gdk_pixbuf_get_has_alpha( pixbuf ); - QImage::Format format; - if( n_channels == 4 && has_alpha ) - format = QImage::Format_ARGB32; - else if( n_channels == 3 && !has_alpha ) - format = QImage::Format_RGB888; - else - { - warning() << __PRETTY_FUNCTION__ << "Unsupported n_channels / has_alpha combination."; - g_object_unref( pixbuf ); - break; - } - - // cost cast needed to choose QImage constructor that takes read-only image data - albumImage = QImage( const_cast( gdk_pixbuf_get_pixels( pixbuf ) ), - gdk_pixbuf_get_width( pixbuf ), - gdk_pixbuf_get_height( pixbuf ), - gdk_pixbuf_get_rowstride( pixbuf ), - format ); - // force deep copy so that memory from gdk pixbuf can be unreferenced: - albumImage.setDotsPerMeterX( 2835 ); - g_object_unref( pixbuf ); - } while( false ); -#endif - return albumImage; -} - -bool Album::canUpdateImage() const -{ -#ifdef GDKPIXBUF_FOUND - Collections::Collection *coll = m_track->collection(); - return coll ? coll->isWritable() : false; -#else - return false; -#endif -} - -void Album::setImage( const QImage &image ) -{ - m_track->setImage( image ); - CoverCache::invalidateAlbum( this ); -} - -void Album::removeImage() -{ - setImage( QImage() ); -} diff --git a/amarok/src/core-impl/collections/ipodcollection/IpodMeta.h b/amarok/src/core-impl/collections/ipodcollection/IpodMeta.h deleted file mode 100644 index cfa4f7f2..00000000 --- a/amarok/src/core-impl/collections/ipodcollection/IpodMeta.h +++ /dev/null @@ -1,335 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl . * - ****************************************************************************************/ - -#ifndef IPODMETA_H -#define IPODMETA_H - -#include "MetaValues.h" -#include "core/meta/Meta.h" -#include "core/meta/Statistics.h" -#include "core/meta/TrackEditor.h" - -#include - -#include - -struct _Itdb_Track; -typedef _Itdb_Track Itdb_Track; -class IpodCollection; - -namespace IpodMeta -{ - /** - * An iPod track. album, artist, composer etc. are invisible to ouside world, they are - * proxied in the MemoMeta track. All methods in this class are thread-safe with a few - * exceptions that are noted in relevant method docstrings. - */ - class Track : public Meta::Track, public Meta::Statistics, public Meta::TrackEditor - { - public: - /** - * Constructs an iPod track from an existing libgpod track structure. Caller - * must guarantee that these are already added to the collection's itdb databse. - */ - explicit Track( Itdb_Track *ipodTrack ); - - /** - * Constructs an iPod track out of an existing track by copying its meta-data - */ - explicit Track( const Meta::TrackPtr &origTrack ); - - virtual ~Track(); - - // Meta::Base methods: - virtual QString name() const; - - // Meta::Track methods: - virtual KUrl playableUrl() const; - virtual QString prettyUrl() const; - virtual QString uidUrl() const; - virtual QString notPlayableReason() const; - - virtual Meta::AlbumPtr album() const; - virtual Meta::ArtistPtr artist() const; - virtual Meta::ComposerPtr composer() const; - virtual Meta::GenrePtr genre() const; - virtual Meta::YearPtr year() const; - - virtual qreal bpm() const; - virtual QString comment() const; - - virtual qint64 length() const; - virtual int filesize() const; - virtual int sampleRate() const; - virtual int bitrate() const; - - virtual QDateTime createDate() const; - virtual QDateTime modifyDate() const; - - virtual int trackNumber() const; - virtual int discNumber() const; - - virtual qreal replayGain( Meta::ReplayGainTag mode ) const; - virtual QString type() const; - - virtual bool inCollection() const; - virtual Collections::Collection* collection() const; - - virtual Meta::TrackEditorPtr editor(); - virtual Meta::StatisticsPtr statistics(); - - // Meta::TrackEditor methods: - virtual void setAlbum( const QString &newAlbum ); - virtual void setAlbumArtist( const QString &newAlbumArtist ); - virtual void setArtist( const QString &newArtist ); - virtual void setComposer( const QString &newComposer ); - virtual void setGenre( const QString &newGenre ); - virtual void setYear( int newYear ); - virtual void setTitle( const QString &newTitle ); - virtual void setComment( const QString &newComment ); - virtual void setTrackNumber( int newTrackNumber ); - virtual void setDiscNumber( int newDiscNumber ); - virtual void setBpm( const qreal newBpm ); - - // Meta::Statistics methods: - virtual int rating() const; - virtual void setRating( int newRating ); - - virtual QDateTime lastPlayed() const; - virtual void setLastPlayed( const QDateTime &time ); - - virtual QDateTime firstPlayed() const; - virtual void setFirstPlayed( const QDateTime &time ); - - virtual int playCount() const; - virtual int recentPlayCount() const; - virtual void setPlayCount( const int playcount ); - - // Combined Meta::TrackEditor, Meta::Statistics methods: - virtual void beginUpdate(); - virtual void endUpdate(); - - // IpodMeta::Track methods: - /** - * Return a pointer to IpodMeta::Track given pointer to underlying libgpod - * track. Does not attempt to create the track, so it may return null ptr if - * there is no IpodMeta::Track associated with given libgpod track. - */ - static Meta::TrackPtr fromIpodTrack( const Itdb_Track *ipodTrack ); - - /** - * Return a pointer to underlying libgpod track. You aren't allowed to cache - * the pointer - IpodMeta::Track owns it. Guaranteed to be non-null and - * constant throughout the lifetime of IpodMeta::Track. - */ - Itdb_Track *itdbTrack() const; - - /** - * CollectionLocation must call this method when it finishes copying the - * track file onto iPod, before adding this track to IpodCollection. - * Sets ipod_path, filetype_marker, transferred and size m_track fields. - * - * @param mountPoint a path where iPod is mounted, e.g. /media/MyiPod in local - * encoding (use QFile::encodeName()) - * @param filePath full absolute path to copied file, must be in form - * <@param mountPoint>/iPod_Control/Music/... - it is recommended to use - * itdb_cp_get_dest_filename() to construct the filename - * - * @return true if the track was "accepted", false if not in which case you - * shouldn't add it to collection. - */ - bool finalizeCopying( const gchar *mountPoint, const gchar *filePath ); - - /** - * Set collection this track belongs to. If collection is not null, (re)set - * the mount point stored in track. (affects playableUrl()) - */ - void setCollection( QWeakPointer collection ); - - // Methods for copy constructor: - void setIsCompilation( bool newIsCompilation ); - void setImage( const QImage &newImage ); - void setLength( qint64 newLength ); - void setSampleRate( int newSampleRate ); - void setBitrate( int newBitrate ); - void setCreateDate( const QDateTime &newDate ); - void setModifyDate( const QDateTime &newDate ); - void setReplayGain( Meta::ReplayGainTag mode, qreal newReplayGain ); - void setType( const QString &newType ); - - private: - bool isEditable() const; - - /** - * Must be called at end of every set*() method, with m_trackLock locked for - * writing. Takes care of writing back the fields and notifying observers. - */ - void commitIfInNonBatchUpdate( qint64 field, const QVariant &value ); - void commitIfInNonBatchUpdate(); - - friend class Album; // so that is can access m_track and friends - - /** - * Meta::Track is memory-managed using KSharedPointer to QSharedData, but - * IpodCollection's memory management is out of our control, therefore the - * weak pointer. - */ - QWeakPointer m_coll; - - /** - * While mount point is accessible through m_track->itdb-> ..., we want to - * remember our location even when we are removed from collection - */ - QString m_mountPoint; - - /** - * Associated libgpod track structure that holds all the data, we own this - * pointer - */ - Itdb_Track *const m_track; // yes, the address is constant, not the track - - /** - * You must hold this lock when acessing m_track data. Beware that - * m_track->itdb may change even with this lock hold - IpodCollection is the - * owner of this field - */ - mutable QReadWriteLock m_trackLock; - - /** - * We need the temporary image file to exist for the lifetime of Track because - * calling itdb_track_set_thumbnails() only saves the filename - the file is - * read only when needed. If this path is non-empty, it means that the file - * should be deleted in destructor. - */ - QString m_tempImageFilePath; - - /** - * Set of field types (identified by constants from MetaValues.h) changed by - * TrackEditor or set{Rating,Score,...} not yet committed to database and - * underlying file - */ - Meta::FieldHash m_changedFields; - - /** - * Number of current batch operations started by @see beginUpdate() and not - * yet ended by @see endUpdate(). Must only be accessed with m_trackLock held. - */ - int m_batch; - - static const quint64 m_gpodTrackUserTypeAmarokTrackPtr = Q_UINT64_C(0x416d61726f6b5472); /* AmarokTr */ - }; - - /** - * Dummy Artist that just stores its name; not visible from outside - iPod tracks are - * proxied by MemoryMeta that creates its own Artist entities. - */ - class Artist : public Meta::Artist - { - public: - Artist( const QString &name ) : m_name( name ) {} - virtual ~Artist() {} - - virtual QString name() const { return m_name; } - virtual Meta::TrackList tracks() { return Meta::TrackList(); } - - private: - QString m_name; - }; - - /** - * For performance reasons, Album stores just pointer to the tracks and reads all its - * fields on-demand. - */ - class Album : public Meta::Album - { - public: - Album( Track *track ); - - virtual QString name() const; - // dummy, iPod tracks are supposed to be proxied by MemoryMeta which handles this - virtual Meta::TrackList tracks() { return Meta::TrackList(); } - - virtual bool isCompilation() const; - virtual bool canUpdateCompilation() const; - virtual void setCompilation( bool isCompilation ); - - virtual bool hasAlbumArtist() const; - virtual Meta::ArtistPtr albumArtist() const; - - virtual bool hasImage( int size = 0 ) const; - virtual QImage image( int size = 0 ) const; - virtual bool canUpdateImage() const; - virtual void setImage( const QImage &image ); - virtual void removeImage(); - - private: - KSharedPtr m_track; - }; - - /** - * Dummy Composer that just stores its name; not visible from outside - iPod tracks are - * proxied by MemoryMeta that creates its own Composer entities. - */ - class Composer : public Meta::Composer - { - public: - Composer( const QString &name ) : m_name( name ) {} - virtual ~Composer() {} - - virtual QString name() const { return m_name; } - virtual Meta::TrackList tracks() { return Meta::TrackList(); } - - private: - QString m_name; - }; - - /** - * Dummy Genre that just stores its name; not visible from outside - iPod tracks are - * proxied by MemoryMeta that creates its own Genre entities. - */ - class Genre : public Meta::Genre - { - public: - Genre( const QString &name ) : m_name( name ) {} - virtual ~Genre() {} - - virtual QString name() const { return m_name; } - virtual Meta::TrackList tracks() { return Meta::TrackList(); } - - private: - QString m_name; - }; - - /** - * Dummy Year that just stores its name; not visible from outside - iPod tracks are - * proxied by MemoryMeta that creates its own Year entities. - */ - class Year : public Meta::Year - { - public: - Year( const QString &name ) : m_name( name ) {} - virtual ~Year() {} - - virtual QString name() const { return m_name; } - virtual Meta::TrackList tracks() { return Meta::TrackList(); } - - private: - QString m_name; - }; - -} // namespace IpodMeta - -#endif // IPODMETA_H diff --git a/amarok/src/core-impl/collections/ipodcollection/IpodPlaylist.cpp b/amarok/src/core-impl/collections/ipodcollection/IpodPlaylist.cpp deleted file mode 100644 index 61c60ba6..00000000 --- a/amarok/src/core-impl/collections/ipodcollection/IpodPlaylist.cpp +++ /dev/null @@ -1,248 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "IpodPlaylist.h" - -#include "IpodCollection.h" -#include "IpodMeta.h" -#include "IpodPlaylistProvider.h" -#include "core/playlists/PlaylistProvider.h" -#include "core/support/Debug.h" -#include "core-impl/collections/support/MemoryMeta.h" -#include "core-impl/playlists/providers/user/UserPlaylistProvider.h" - -#include - - -IpodPlaylist::IpodPlaylist( Itdb_Playlist *ipodPlaylist, IpodCollection *collection ) - : m_playlist( ipodPlaylist ) - , m_coll( collection ) - , m_type( Normal ) -{ - Q_ASSERT( m_playlist && collection ); - for( GList *members = m_playlist->members; members; members = members->next ) - { - Itdb_Track *itdbTrack = (Itdb_Track *) members->data; - Q_ASSERT( itdbTrack ); - Meta::TrackPtr track = IpodMeta::Track::fromIpodTrack( itdbTrack ); - Q_ASSERT( track ); - track = collection->trackForUidUrl( track->uidUrl() ); // get MemoryMeta proxy track - Q_ASSERT( track ); - m_tracks << track; - } -} - -IpodPlaylist::IpodPlaylist( const Meta::TrackList &tracks, const QString &name, - IpodCollection *collection, Type type ) - : m_coll( collection ) - , m_type( type ) -{ - m_playlist = itdb_playlist_new( name.toUtf8(), false /* Smart playlist */ ); - Q_ASSERT( m_playlist ); - - if( m_type != Normal ) - { - m_tracks = tracks; - return; // m_playlist holds just the name in this case - } - - int position = 0; - int finalPosition = 0; - foreach( Meta::TrackPtr track, tracks ) - { - if( track->collection() == collection ) // track from associated collection - { - addIpodTrack( track, position ); - position++; - } - else - m_tracksToCopy << TrackPosition( track, finalPosition ); - finalPosition++; // yes increment every time, tracks are inserted in order so this is correct - } - - if( !m_tracksToCopy.isEmpty() ) - scheduleCopyAndInsert(); -} - -IpodPlaylist::~IpodPlaylist() -{ - itdb_playlist_free( m_playlist ); -} - -KUrl -IpodPlaylist::uidUrl() const -{ - // integer reading is atomic, no lock needed - QString collId = m_coll ? m_coll.data()->collectionId() : "removedipodcolleciton:/"; - return QString( "%1/playlists/%2" ).arg( collId ).arg( m_playlist->id ); -} - -QString -IpodPlaylist::name() const -{ - QReadLocker locker( &m_playlistLock ); - return QString::fromUtf8( m_playlist->name ); -} - -void -IpodPlaylist::setName( const QString &name ) -{ - QWriteLocker locker( &m_playlistLock ); - g_free( m_playlist->name ); - m_playlist->name = g_strdup( name.toUtf8() ); -} - -Playlists::PlaylistProvider* -IpodPlaylist::provider() const -{ - return m_coll ? m_coll.data()->playlistProvider() : 0; -} - -int -IpodPlaylist::trackCount() const -{ - return m_tracks.count(); -} - -Meta::TrackList -IpodPlaylist::tracks() -{ - return m_tracks; -} - -void -IpodPlaylist::addTrack( Meta::TrackPtr track, int position ) -{ - if( m_type != Normal || !m_coll || !m_coll.data()->isWritable() ) - return; - - if( position < 0 || position > m_tracks.count() ) - position = m_tracks.count(); - - if( track->collection() == m_coll.data() ) // track from associated collection - addIpodTrack( track, position ); - else - { - m_tracksToCopy << TrackPosition( track, position ); - scheduleCopyAndInsert(); - } -} - -void -IpodPlaylist::removeTrack( int position ) -{ - // we should fail only if position is incorrect, prevent infinite loops in - // IpodPlaylistProvider::removeTrackFromPlaylists() - if( position < 0 || position >= m_tracks.count() ) - return; - - Meta::TrackPtr removedTrack = m_tracks.takeAt( position ); - if( m_type == Stale || m_type == Orphaned ) - { - notifyObserversTrackRemoved( position ); - return; // do not fire following machinery for special playlists - } - - KSharedPtr proxyTrack = KSharedPtr::dynamicCast( removedTrack ); - if( !proxyTrack ) - { - error() << __PRETTY_FUNCTION__ << "track" << removedTrack.data() << "from m_track was not MemoryMeta track!"; - return; - } - - KSharedPtr ipodTrack = KSharedPtr::dynamicCast( proxyTrack->originalTrack() ); - if( !proxyTrack ) - { - error() << __PRETTY_FUNCTION__ << "originalTrack of the proxyTrack was not IpodMeta track!"; - return; - } - - { - // notify observers _without_ the lock held - QWriteLocker locker( &m_playlistLock ); - itdb_playlist_remove_track( m_playlist, ipodTrack->itdbTrack() ); - } - notifyObserversTrackRemoved( position ); -} - -Itdb_Playlist* -IpodPlaylist::itdbPlaylist() -{ - return m_playlist; -} - -TrackPositionList -IpodPlaylist::takeTracksToCopy() -{ - TrackPositionList tracksToCopy = m_tracksToCopy; - m_tracksToCopy.clear(); - return tracksToCopy; -} - -void -IpodPlaylist::scheduleCopyAndInsert() -{ - Playlists::PlaylistProvider *prov = provider(); - if( !prov ) - return; // we can do nothing - static_cast( prov )->scheduleCopyAndInsertToPlaylist( - KSharedPtr( this ) ); -} - -void -IpodPlaylist::addIpodTrack( Meta::TrackPtr track, int position ) -{ - Q_ASSERT( position >= 0 && position <= m_tracks.count() ); - - Meta::TrackPtr proxyTrack = Meta::TrackPtr(); - KSharedPtr memoryTrack = KSharedPtr::dynamicCast( track ); - if( memoryTrack ) - { - track = memoryTrack->originalTrack(); // iPod track is usually hidden below MemoryMeta proxy - proxyTrack = track; - } - KSharedPtr ipodTrack = KSharedPtr::dynamicCast( track ); - if( !ipodTrack ) - { - error() << __PRETTY_FUNCTION__ << "Could not get IpodMeta::Track out of supplied track." - << ( memoryTrack ? "(but cast to MemoryMeta::Track succeeded)" - : "(cast to MemoryMeta::Track failed too)" ); - return; - } - - if( !proxyTrack) // we got IpodTrack directly, expose its MemoryMeta proxy - proxyTrack = m_coll ? m_coll.data()->trackForUidUrl( ipodTrack->uidUrl() ) : Meta::TrackPtr(); - if( !proxyTrack ) - { - error() << __PRETTY_FUNCTION__ << "was passed IpodMeta::Track but we could not find" - << "MemoryMeta::Track proxy for it."; - return; - } - - Itdb_Track *itdbTrack = ipodTrack->itdbTrack(); - /* There is following code in libgpod's itdb_playlist_add_track(): - * g_return_if_fail (pl->itdb); - * track->itdb = pl->itdb; - * Just fool libgpod by setting itdb to assumed value - */ - Itdb_iTunesDB *save = m_playlist->itdb; - m_playlist->itdb = itdbTrack->itdb; - itdb_playlist_add_track( m_playlist, itdbTrack, -1 ); - m_playlist->itdb = save; - - m_tracks.insert( position, proxyTrack ); - notifyObserversTrackAdded( proxyTrack, position ); -} diff --git a/amarok/src/core-impl/collections/ipodcollection/IpodPlaylist.h b/amarok/src/core-impl/collections/ipodcollection/IpodPlaylist.h deleted file mode 100644 index eabae04b..00000000 --- a/amarok/src/core-impl/collections/ipodcollection/IpodPlaylist.h +++ /dev/null @@ -1,112 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef IPODPLAYLIST_H -#define IPODPLAYLIST_H - -#include "core/playlists/Playlist.h" - -#include - - -class IpodCollection; -struct _Itdb_Playlist; -typedef struct _Itdb_Playlist Itdb_Playlist; - -// we cannot use QMap because it doesn't preserve order -typedef QPair TrackPosition; -typedef QList TrackPositionList; - -/** - * Represents playlist on the iPod. Takes ownership of the m_playlist pointer. - */ -class IpodPlaylist : public Playlists::Playlist -{ - public: - enum Type { - Normal, // regular iPod playlist - Stale, // playlist containing stale iTunes database entries - Orphaned, // playlist containing track on iPod filesystem that are not it database - }; - - /** - * Create Amarok iPod playlist out of existing itdb playlist - */ - IpodPlaylist( Itdb_Playlist *ipodPlaylist, IpodCollection *collection ); - - /** - * Create new Amarok iPod playlist. Some @param tracks may not be in corresponding - * iPod collection, these are copied to iPod (unless not matched by meta tags) - * - * @param type whether this playlist is an ordinatory one or a kind of special - */ - IpodPlaylist( const Meta::TrackList &tracks, const QString &name, - IpodCollection *collection, Type type = Normal ); - - virtual ~IpodPlaylist(); - - virtual KUrl uidUrl() const; - virtual QString name() const; - virtual void setName( const QString &name ); - - virtual Playlists::PlaylistProvider *provider() const; - - virtual int trackCount() const; - virtual Meta::TrackList tracks(); - virtual void addTrack( Meta::TrackPtr track, int position = -1 ); - virtual void removeTrack( int position ); - - // IpodPlaylist specific: - Itdb_Playlist *itdbPlaylist(); - - /** - * Return tracks that should be copied to iPod and then added to this playlist, - * clearing this map. - */ - TrackPositionList takeTracksToCopy(); - - /** - * Return type of this playlist. Can be used to determine whether this one is - * special or not. - */ - Type type() const { return m_type; } - - private: - Q_DISABLE_COPY( IpodPlaylist ) - - /** - * Copy m_tracksToCopy to iPod and them add them to this playlist. The actual call - * to start copying tracks is deferred to next eventloop iteration to pickup - * multiple successive addTrack() calls - */ - void scheduleCopyAndInsert(); - - /** - * Does the dirty job of adding @param track to this playlist, both to m_tracks - * and to underlying libgpoid playlist. @param position must be a valid position - * otherwise this method asserts out. - */ - void addIpodTrack( Meta::TrackPtr track, int position ); - - Itdb_Playlist *m_playlist; - mutable QReadWriteLock m_playlistLock; - QWeakPointer m_coll; - Type m_type; - Meta::TrackList m_tracks; // playlists tracks, in fact MemoryMeta::Track objects - TrackPositionList m_tracksToCopy; -}; - -#endif // IPODPLAYLIST_H diff --git a/amarok/src/core-impl/collections/ipodcollection/IpodPlaylistProvider.cpp b/amarok/src/core-impl/collections/ipodcollection/IpodPlaylistProvider.cpp deleted file mode 100644 index 825cb939..00000000 --- a/amarok/src/core-impl/collections/ipodcollection/IpodPlaylistProvider.cpp +++ /dev/null @@ -1,410 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "IpodPlaylistProvider.h" - -#include "IpodCollection.h" -#include "IpodCollectionLocation.h" -#include "IpodPlaylist.h" -#include "core/capabilities/ActionsCapability.h" -#include "core/interfaces/Logger.h" -#include "core/support/Components.h" -#include "core/support/Debug.h" -#include "core-impl/collections/support/FileCollectionLocation.h" - -#include -#include - -#include - -IpodPlaylistProvider::IpodPlaylistProvider( IpodCollection* collection ) - : UserPlaylistProvider( collection ) - , m_coll( collection ) -{ -} - -IpodPlaylistProvider::~IpodPlaylistProvider() -{ -} - -QString -IpodPlaylistProvider::prettyName() const -{ - return m_coll->prettyName(); -} - -KIcon -IpodPlaylistProvider::icon() const -{ - return m_coll->icon(); -} - -int -IpodPlaylistProvider::playlistCount() const -{ - return m_playlists.count(); -} - -Playlists::PlaylistList -IpodPlaylistProvider::playlists() -{ - return m_playlists; -} - -Playlists::PlaylistPtr -IpodPlaylistProvider::addPlaylist( Playlists::PlaylistPtr playlist ) -{ - return save( playlist->tracks(), playlist->name() ); -} - -Meta::TrackPtr -IpodPlaylistProvider::addTrack( Meta::TrackPtr track ) -{ - QString name = KGlobal::locale()->formatDateTime( QDateTime::currentDateTime() ); - return save( Meta::TrackList() << track , name )->tracks().last(); -} - -Playlists::PlaylistPtr -IpodPlaylistProvider::save( const Meta::TrackList &tracks, const QString &name ) -{ - if( !isWritable() ) - return Playlists::PlaylistPtr(); - - IpodPlaylist *playlist = new IpodPlaylist( tracks, name, m_coll ); - itdb_playlist_add( m_coll->m_itdb, playlist->itdbPlaylist(), -1 ); - Playlists::PlaylistPtr playlistPtr( playlist ); - m_playlists << playlistPtr; - subscribeTo( playlistPtr ); - emit playlistAdded( playlistPtr ); - emit startWriteDatabaseTimer(); - return playlistPtr; -} - -QActionList -IpodPlaylistProvider::providerActions() -{ - QScopedPointer ac( m_coll->create() ); - return ac->actions(); // all IpodCollection actions are parented, no memory leak here -} - -QActionList -IpodPlaylistProvider::playlistActions( const Playlists::PlaylistList &playlists ) -{ - QActionList actions; - foreach( const Playlists::PlaylistPtr &playlist, playlists ) - { - if( !m_playlists.contains( playlist ) ) // make following static cast safe - continue; - IpodPlaylist::Type type = KSharedPtr::staticCast( playlist )->type(); - if( type == IpodPlaylist::Stale || type == IpodPlaylist::Orphaned ) - { - actions << m_coll->m_consolidateAction; - break; - } - } - - return actions; -} - -QActionList -IpodPlaylistProvider::trackActions( const QMultiHash &playlistTracks ) -{ - return playlistActions( playlistTracks.uniqueKeys() ); -} - -bool -IpodPlaylistProvider::isWritable() -{ - return m_coll->isWritable(); -} - -void -IpodPlaylistProvider::renamePlaylist( Playlists::PlaylistPtr playlist, const QString &newName ) -{ - if( !m_playlists.contains( playlist ) ) // make following static cast safe - return; - KSharedPtr ipodPlaylist = KSharedPtr::staticCast( playlist ); - if( ipodPlaylist->type() != IpodPlaylist::Normal ) - return; // special playlists cannot be renamed - - playlist->setName( newName ); - emit updated(); - emit startWriteDatabaseTimer(); -} - -bool -IpodPlaylistProvider::deletePlaylists( const Playlists::PlaylistList &playlistlist ) -{ - if( !isWritable() ) - return false; - - foreach( Playlists::PlaylistPtr playlist, playlistlist ) - { - if( !m_playlists.contains( playlist ) ) - continue; - if( KSharedPtr::staticCast( playlist )->type() != IpodPlaylist::Normal ) - continue; // special playlists cannot be removed using this method - m_playlists.removeOne( playlist ); - - unsubscribeFrom( playlist ); - IpodPlaylist *ipodPlaylist = static_cast( playlist.data() ); - itdb_playlist_unlink( ipodPlaylist->itdbPlaylist() ); - - emit playlistRemoved( playlist ); - emit startWriteDatabaseTimer(); - } - return true; -} - -void -IpodPlaylistProvider::metadataChanged( Playlists::PlaylistPtr ) -{ - emit startWriteDatabaseTimer(); -} - -void -IpodPlaylistProvider::trackAdded( Playlists::PlaylistPtr, Meta::TrackPtr, int ) -{ - emit startWriteDatabaseTimer(); -} - -void -IpodPlaylistProvider::trackRemoved( Playlists::PlaylistPtr, int ) -{ - emit startWriteDatabaseTimer(); -} - -void -IpodPlaylistProvider::scheduleCopyAndInsertToPlaylist( KSharedPtr playlist ) -{ - m_copyTracksTo.insert( playlist ); - QTimer::singleShot( 0, this, SLOT(slotCopyAndInsertToPlaylists()) ); -} - -void -IpodPlaylistProvider::removeTrackFromPlaylists( Meta::TrackPtr track ) -{ - foreach( Playlists::PlaylistPtr playlist, m_playlists ) - { - int trackIndex; - // track may be multiple times in a playlist: - while( ( trackIndex = playlist->tracks().indexOf( track ) ) >= 0 ) - playlist->removeTrack( trackIndex ); - } -} - -bool -IpodPlaylistProvider::hasStaleOrOrphaned() const -{ - return m_stalePlaylist || m_orphanedPlaylist; -} - -void -IpodPlaylistProvider::slotConsolidateStaleOrphaned() -{ - int matched = 0, added = 0, removed = 0, failed = 0; - - /* Sometimes users accidentaly rename files on iPod. This creates a pair of a stale - * iTunes database entry and an orphaned file. Find these specifically and move the files - * back to their original location. */ - if( m_stalePlaylist && m_orphanedPlaylist ) - { - QMap orphanedToStale; - foreach( Meta::TrackPtr orphanedTrack, m_orphanedPlaylist->tracks() ) - { - Meta::TrackPtr matchingStaleTrack; - foreach( Meta::TrackPtr staleTrack, m_stalePlaylist->tracks() ) - { - if( orphanedAndStaleTracksMatch( orphanedTrack, staleTrack ) ) - { - matchingStaleTrack = staleTrack; - break; - } - } - - if( matchingStaleTrack ) // matching track found - { - orphanedToStale.insert( orphanedTrack, matchingStaleTrack ); - m_stalePlaylist->removeTrack( m_stalePlaylist->tracks().indexOf( matchingStaleTrack ) ); - } - } - - QMapIterator it( orphanedToStale ); - while( it.hasNext() ) - { - it.next(); - Meta::TrackPtr orphanedTrack = it.key(); - Meta::TrackPtr staleTrack = it.value(); - m_orphanedPlaylist->removeTrack( m_orphanedPlaylist->tracks().indexOf( orphanedTrack ) ); - - QString from = orphanedTrack->playableUrl().toLocalFile(); - QString to = staleTrack->playableUrl().toLocalFile(); - if( !QFileInfo( to ).absoluteDir().mkpath( "." ) ) - { - warning() << __PRETTY_FUNCTION__ << "Failed to create directory path" - << QFileInfo( to ).absoluteDir().path(); - failed++; - continue; - } - if( !QFile::rename( from, to ) ) - { - warning() << __PRETTY_FUNCTION__ << "Failed to move track from" << from - << "to" << to; - failed++; - continue; - } - matched++; - } - } - - // remove remaining stale tracks - if( m_stalePlaylist && m_stalePlaylist->trackCount() ) - { - Collections::CollectionLocation *location = m_coll->location(); - // hide removal confirmation - these tracks are already deleted, don't confuse user - static_cast( location )->setHidingRemoveConfirm( true ); - removed += m_stalePlaylist->trackCount(); - location->prepareRemove( m_stalePlaylist->tracks() ); - // remove all tracks from the playlist, assume the removal suceeded - while( m_stalePlaylist->trackCount() ) - m_stalePlaylist->removeTrack( 0 ); - } - - // add remaining orphaned tracks back to database - if( m_orphanedPlaylist && m_orphanedPlaylist->trackCount() ) - { - Collections::CollectionLocation *src = new Collections::FileCollectionLocation(); - Collections::CollectionLocation *dest = m_coll->location(); - added += m_orphanedPlaylist->trackCount(); - src->prepareMove( m_orphanedPlaylist->tracks(), dest ); - // remove all tracks from the playlist, assume the move suceeded - while( m_orphanedPlaylist->trackCount() ) - m_orphanedPlaylist->removeTrack( 0 ); - } - - // if some of the playlists became empty, remove them completely. no need to - // unsubscribe - we were not subscribed - if( m_stalePlaylist && m_stalePlaylist->trackCount() == 0 ) - { - m_playlists.removeOne( m_stalePlaylist ); - emit playlistRemoved( m_stalePlaylist ); - m_stalePlaylist = 0; - } - if( m_orphanedPlaylist && m_orphanedPlaylist->trackCount() == 0 ) - { - m_playlists.removeOne( m_orphanedPlaylist ); - emit playlistRemoved( m_orphanedPlaylist ); - m_orphanedPlaylist = 0; - } - - QString failedText = failed ? i18np("Failed to process one track. (more info about " - "it is in the Amarok debugging log)", "Failed to process %1 tracks. (more info " - "about these is in the Amarok debugging log)", failed ) : QString(); - QString text = i18nc( "Infrequently displayed message, don't bother with singlar " - "forms. %1 to %3 are numbers, %4 is the 'Failed to process ...' sentence or an " - "empty string.", "Done consolidating iPod files. %1 orphaned tracks matched with " - "stale iTunes database entries, %2 stale database entries removed, %3 orphaned " - "tracks added back to the iTunes database. %4", matched, removed, added, - failedText ); - Amarok::Components::logger()->longMessage( text ); -} - -void -IpodPlaylistProvider::slotCopyAndInsertToPlaylists() -{ - QMutableSetIterator< KSharedPtr > it( m_copyTracksTo ); - while( it.hasNext() ) - { - KSharedPtr ipodPlaylist = it.next(); - TrackPositionList tracks = ipodPlaylist->takeTracksToCopy(); - copyAndInsertToPlaylist( tracks, Playlists::PlaylistPtr::staticCast( ipodPlaylist ) ); - it.remove(); - } -} - -void IpodPlaylistProvider::copyAndInsertToPlaylist( const TrackPositionList &tracks, Playlists::PlaylistPtr destPlaylist ) -{ - QMap sourceCollections; - foreach( const TrackPosition &pair, tracks ) - { - Collections::Collection *coll = pair.first->collection(); - if( coll == m_coll ) - continue; - - if( sourceCollections.contains( coll ) ) - sourceCollections[ coll ] << pair; - else - sourceCollections.insert( coll, TrackPositionList() << pair ); - } - - foreach( Collections::Collection *coll, sourceCollections.keys() ) - { - Meta::TrackList sourceTracks; - QMap trackPlaylistPositions; - foreach( const TrackPosition &pair, sourceCollections.value( coll ) ) - { - sourceTracks << pair.first; - trackPlaylistPositions.insert( pair.first, pair.second ); - } - - Collections::CollectionLocation *sourceLocation = coll - ? coll->location() : new Collections::FileCollectionLocation(); - Q_ASSERT( sourceLocation ); - // prepareCopy() takes ownership of the pointers, we must create target collection every time - IpodCollectionLocation *targetLocation = static_cast( m_coll->location() ); - - targetLocation->setDestinationPlaylist( destPlaylist, trackPlaylistPositions ); - sourceLocation->prepareCopy( sourceTracks, targetLocation ); - } -} - -bool -IpodPlaylistProvider::orphanedAndStaleTracksMatch( const Meta::TrackPtr &orphaned, const Meta::TrackPtr &stale ) -{ - if( orphaned->filesize() != stale->filesize() ) // first for performance reasons - return false; - if( orphaned->length() != stale->length() ) - return false; - if( orphaned->name() != stale->name() ) - return false; - if( orphaned->type() != stale->type() ) - return false; - if( orphaned->trackNumber() != stale->trackNumber() ) - return false; - if( orphaned->discNumber() != stale->discNumber() ) - return false; - - if( entitiesDiffer( orphaned->album(), stale->album() ) ) - return false; - if( entitiesDiffer( orphaned->artist(), stale->artist() ) ) - return false; - if( entitiesDiffer( orphaned->composer(), stale->composer() ) ) - return false; - if( entitiesDiffer( orphaned->genre(), stale->genre() ) ) - return false; - if( entitiesDiffer( orphaned->year(), stale->year() ) ) - return false; - - return true; -} - -template bool -IpodPlaylistProvider::entitiesDiffer( T first, T second ) -{ - return ( first ? first->name() : QString() ) != ( second ? second->name() : QString() ); -} - -#include "moc_IpodPlaylistProvider.cpp" diff --git a/amarok/src/core-impl/collections/ipodcollection/IpodPlaylistProvider.h b/amarok/src/core-impl/collections/ipodcollection/IpodPlaylistProvider.h deleted file mode 100644 index 92fe66e6..00000000 --- a/amarok/src/core-impl/collections/ipodcollection/IpodPlaylistProvider.h +++ /dev/null @@ -1,114 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef IPODPLAYLISTPROVIDER_H -#define IPODPLAYLISTPROVIDER_H - -#include "IpodPlaylist.h" - -#include "core-impl/playlists/providers/user/UserPlaylistProvider.h" - - -class IpodCollection; -struct _Itdb_iTunesDB; -typedef _Itdb_iTunesDB Itdb_iTunesDB; - -class IpodPlaylistProvider : public Playlists::UserPlaylistProvider, private Playlists::PlaylistObserver -{ - Q_OBJECT - - public: - IpodPlaylistProvider( IpodCollection *collection ); - virtual ~IpodPlaylistProvider(); - - // PlaylistProvider methods: - virtual QString prettyName() const; - virtual KIcon icon() const; - - virtual int playlistCount() const; - virtual Playlists::PlaylistList playlists(); - - virtual Playlists::PlaylistPtr addPlaylist( Playlists::PlaylistPtr playlist ); - virtual Meta::TrackPtr addTrack( Meta::TrackPtr track ); - - // UserPlaylistProvider methods: - virtual Playlists::PlaylistPtr save( const Meta::TrackList &tracks, - const QString& name = QString() ); - - virtual QActionList providerActions(); - virtual QActionList playlistActions( const Playlists::PlaylistList &playlists ); - virtual QActionList trackActions( const QMultiHash &playlistTracks ); - - virtual bool isWritable(); - virtual void renamePlaylist( Playlists::PlaylistPtr playlist, const QString &newName ); - virtual bool deletePlaylists( const Playlists::PlaylistList &playlistlist ); - - // PlaylistObserver methods: - virtual void metadataChanged( Playlists::PlaylistPtr playlist ); - virtual void trackAdded( Playlists::PlaylistPtr playlist, Meta::TrackPtr track, int position ); - virtual void trackRemoved( Playlists::PlaylistPtr playlist, int position ); - - // IpodPlaylistProvider specific methods: - /** - * Copy tracks stored in playlists tracksToCopy() to iPod and them add them to the - * playlist. The actual call to start copying tracks is deferred to next eventloop - * iteration to pickup multiple successive addTrack() calls. - */ - void scheduleCopyAndInsertToPlaylist( KSharedPtr playlist ); - - /** - * Remove this track from all playlists it belongs to, it was removed from the - * database. The @param track is the MemoryMeta proxy track. - */ - void removeTrackFromPlaylists( Meta::TrackPtr track ); - - /** - * Return true whether there are some stale & orphaned files/entries in iTunes db - */ - bool hasStaleOrOrphaned() const; - - public slots: - /** - * Re-add orphaned files to db and remove stale iTunes database entries. Meant to - * be connected to the respective QAction. - */ - void slotConsolidateStaleOrphaned(); - - signals: - /** - * Signals to IpodCollection that the database has been dirtied and it has to - * write the database in some point in time. - */ - void startWriteDatabaseTimer(); - - private slots: - void slotCopyAndInsertToPlaylists(); - - private: - friend class IpodParseTracksJob; - - void copyAndInsertToPlaylist( const TrackPositionList &tracks, Playlists::PlaylistPtr destPlaylist ); - bool orphanedAndStaleTracksMatch( const Meta::TrackPtr &orphaned, const Meta::TrackPtr &stale ); - template bool entitiesDiffer( T first, T second ); - - IpodCollection *m_coll; - Playlists::PlaylistList m_playlists; - QSet< KSharedPtr > m_copyTracksTo; - Playlists::PlaylistPtr m_stalePlaylist; - Playlists::PlaylistPtr m_orphanedPlaylist; -}; - -#endif // IPODPLAYLISTPROVIDER_H diff --git a/amarok/src/core-impl/collections/ipodcollection/IpodTranscodeCapability.cpp b/amarok/src/core-impl/collections/ipodcollection/IpodTranscodeCapability.cpp deleted file mode 100644 index b317a2cc..00000000 --- a/amarok/src/core-impl/collections/ipodcollection/IpodTranscodeCapability.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "IpodTranscodeCapability.h" - - -using namespace Capabilities; - -IpodTranscodeCapability::IpodTranscodeCapability( IpodCollection *coll, const QString &deviceDirPath ) - : TranscodeCapability() - , m_coll( coll ) - , m_configFilePath( deviceDirPath + QString( "/AmarokTranscodingPrefs" ) ) -{ -} - -IpodTranscodeCapability::~IpodTranscodeCapability() -{ - // nothing to do -} - -QStringList -IpodTranscodeCapability::playableFileTypes() -{ - if( m_coll ) - return m_coll.data()->supportedFormats(); - return QStringList(); -} - -Transcoding::Configuration -IpodTranscodeCapability::savedConfiguration() -{ - KConfig config( m_configFilePath, KConfig::SimpleConfig ); - return Transcoding::Configuration::fromConfigGroup( config.group( 0 ) ); -} - -void -IpodTranscodeCapability::setSavedConfiguration( const Transcoding::Configuration &configuration ) -{ - KConfig config( m_configFilePath, KConfig::SimpleConfig ); - KConfigGroup group = config.group( 0 ); - configuration.saveToConfigGroup( group ); - config.sync(); -} - -#include "moc_IpodTranscodeCapability.cpp" diff --git a/amarok/src/core-impl/collections/ipodcollection/IpodTranscodeCapability.h b/amarok/src/core-impl/collections/ipodcollection/IpodTranscodeCapability.h deleted file mode 100644 index a17f84a3..00000000 --- a/amarok/src/core-impl/collections/ipodcollection/IpodTranscodeCapability.h +++ /dev/null @@ -1,49 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef IPODTRANSCODECAPABILITY_H -#define IPODTRANSCODECAPABILITY_H - -#include "IpodCollection.h" -#include "core/capabilities/TranscodeCapability.h" - - -namespace Capabilities -{ - - class IpodTranscodeCapability : public TranscodeCapability - { - Q_OBJECT - - public: - /** - * @param deviceDirPath path to .../iPod_Control/Device directory - */ - IpodTranscodeCapability( IpodCollection *coll, const QString &deviceDirPath ); - virtual ~IpodTranscodeCapability(); - - virtual QStringList playableFileTypes(); - virtual Transcoding::Configuration savedConfiguration(); - virtual void setSavedConfiguration( const Transcoding::Configuration &configuration ); - - private: - QWeakPointer m_coll; - QString m_configFilePath; // must be absolute - }; - -} // namespace capabilities - -#endif // IPODTRANSCODECAPABILITY_H diff --git a/amarok/src/core-impl/collections/ipodcollection/amarok_collection-ipodcollection.desktop b/amarok/src/core-impl/collections/ipodcollection/amarok_collection-ipodcollection.desktop deleted file mode 100644 index e937ec25..00000000 --- a/amarok/src/core-impl/collections/ipodcollection/amarok_collection-ipodcollection.desktop +++ /dev/null @@ -1,103 +0,0 @@ -[Desktop Entry] -Type=Service -Icon=multimedia-player-apple-ipod -Name=iPod, iPad & iPhone Collection -Name[bs]=iPod, iPad & iPhone kolekcija -Name[ca]=Col·lecció en iPod, iPad i iPhone -Name[ca@valencia]=Col·lecció en iPod, iPad i iPhone -Name[cs]=Sbírka pro iPod, iPad & iPhone -Name[da]=iPod-, iPad- og iPhone-samling -Name[de]=Sammlung auf iPod, iPad und iPhone -Name[el]=Συλλογή iPod, iPad & iPhone -Name[en_GB]=iPod, iPad & iPhone Collection -Name[es]=Colección de iPod, iPad e iPhone -Name[et]=iPodi, iPadi ja iPhone'i kogu -Name[fi]=iPod-, iPad- ja iPhone-kokoelma -Name[fr]=Collection iPod, iPad & iPhone -Name[ga]=Bailiúchán iPod, iPad, agus iPhone -Name[gl]=Colección de iPod, iPad e iPhone -Name[hu]=iPod-, iPad- és iPhone-gyűjtemény -Name[id]=Koleksi iPod, iPad & iPhone -Name[it]=Collezione iPod, iPad e iPhone -Name[km]=សម្រាំង iPod, iPad & iPhone -Name[lt]=iPod, iPad & iPhone kolekcija -Name[lv]=iPod, iPad un iPhone kolekcija -Name[nb]=iPod, iPad og iPhone-samling -Name[nl]=iPod-, iPad- & iPhone-verzameling -Name[pa]=iPod, iPad & iPhone ਭੰਡਾਰ -Name[pl]=Zbiór iPod, iPad i iPhone -Name[pt]=Colecção do iPod, iPad & iPhone -Name[pt_BR]=Coleção iPod, iPad & iPhone -Name[ro]=Colecție iPod, iPad și iPhone -Name[ru]=Коллекция с iPod, iPad и iPhone -Name[sk]=Kolekcia iPod, iPad & iPhone -Name[sl]=Zbirka za iPod, iPad in iPhone -Name[sr]=Збирка са и‑пода, и‑пада и и‑фона -Name[sr@ijekavian]=Збирка са и‑пода, и‑пада и и‑фона -Name[sr@ijekavianlatin]=Zbirka sa iPoda, iPada i iPhonea -Name[sr@latin]=Zbirka sa iPoda, iPada i iPhonea -Name[sv]=Samling på iPod, iPad och iPhone -Name[tr]=iPod, iPad & iPhone Koleksiyonu -Name[uk]=Збірка на iPod, iPad і iPhone -Name[x-test]=xxiPod, iPad & iPhone Collectionxx -Name[zh_CN]=iPod,iPad 和 iPhone 收藏 -Name[zh_TW]=iPod, iPad 與 iPhone 收藏 -Comment=Plugin to use iPod-like devices as collections in Amarok -Comment[bs]=Priključak za korištenje uređaja poput iPod-a kao kolekcija u Amaroku -Comment[ca]=Connector per utilitzar dispositius de tipus iPod com a col·leccions en l'Amarok -Comment[ca@valencia]=Connector per utilitzar dispositius de tipus iPod com a col·leccions en l'Amarok -Comment[cs]=Modul pro využití zařízení jako např. iPod jako sbírky pro AmaroK -Comment[da]=Plugin til at bruge iPod-lignende enheder som samlinger i Amarok -Comment[de]=Modul für die Verwendung von Geräten wie dem iPod als Sammlung in Amarok -Comment[el]=Πρόσθετο χρήσης συσκευών παρόμοιων με το iPod ως συλλογές στο AmaroK -Comment[en_GB]=Plugin to use iPod-like devices as collections in Amarok -Comment[es]=Complemento para dispositivos similares a iPod en Amarok -Comment[et]=Plugin iPodi-laadsete seadmete kasutamiseks Amaroki koguna -Comment[fi]=Liitännäinen iPodin kaltaisten laitteiden käyttämiseen Amarokissa kokoelmina -Comment[fr]=Module externe pour utiliser des périphériques de type iPod comme collections dans Amarok -Comment[ga]=Breiseán chun gléasanna cosúil le iPod a úsáid mar bhailiúcháin in Amarok -Comment[gl]=Complemento para empregar dispositivos como o iPod a modo de coleccións en Amarok -Comment[hu]=Bővítmény iPod-szerű eszközök Amarok-gyűjteményként való használatára -Comment[id]=Plugin untuk digunakan perangkat iPod-like sebagai koleksi di Amarok -Comment[it]=Estensione per utilizzare dispositivi del tipo iPod come collezioni di Amarok -Comment[km]=កម្មវិធី​ជំនួយ​ ដើម្បី​ប្រើ​ឧបករណ៍​ដូច​ជា iPod ជា​ការ​សម្រាំង​នៅ​ក្នុង Amarok -Comment[lt]=Papildinys naudoti iPod tipo įrenginius kaip kolekcijas Amarok grotuve -Comment[lv]=Spraudnis, lai lietotu iPod līdzīgas iekārtas kā kolekcijas iekš Amarok -Comment[nb]=Programtillegg som bruker iPod-aktige enheter som samlinger i Amarok -Comment[nl]=Plugin voor gebruik van iPod-achtige apparaten als verzamelingen in Amarok -Comment[pl]=Wtyczka umożliwiająca używania urządzeń takich jak iPody jako kolekcji w Amaroku -Comment[pt]=Um 'plugin' para usar dispositivos compatíveis com o iPod como colecções do Amarok -Comment[pt_BR]=Plugin para usar dispositivos tipo iPod como coleções no Amarok -Comment[ro]=Extensie pentru folosirea dispozitivelor de tip iPod ca pe colecții în Amarok -Comment[ru]=Модуль коллекции устройств iPod и подобных им для Amarok -Comment[sk]=Plugin na použitie zariadení ako iPod ako kolekcie v Amaroku -Comment[sl]=Vstavek za uporabo iPod-u podobnih naprav kot zbirk v Amaroku -Comment[sr]=Прикључак за употребу уређаја налик на и‑под као збирки у Амароку -Comment[sr@ijekavian]=Прикључак за употребу уређаја налик на и‑под као збирки у Амароку -Comment[sr@ijekavianlatin]=Priključak za upotrebu uređaja nalik na iPod kao zbirki u Amaroku -Comment[sr@latin]=Priključak za upotrebu uređaja nalik na iPod kao zbirki u Amaroku -Comment[sv]=Insticksprogram för att använda iPod-liknande enheter som samlingar i Amarok -Comment[tr]=Amarok için iPod benzeri aygıtları koleksiyon olarak kullanma eklentisi -Comment[uk]=Додаток для використання iPod-подібних пристроїв як збірок у Amarok -Comment[x-test]=xxPlugin to use iPod-like devices as collections in Amarokxx -Comment[zh_CN]=在 Amarok 中使用类 iPod 设备作为收藏的插件 -Comment[zh_TW]=Amarok 的類 iPod 裝置收藏外掛程式 - -ServiceTypes=Amarok/Plugin - -X-KDE-Amarok-authors=Matěj Laitl -X-KDE-Amarok-email=matej@laitl.cz -X-KDE-Amarok-framework-version=72 -X-KDE-Amarok-name=ipod-collection -X-KDE-Amarok-plugintype=collection -X-KDE-Amarok-rank=100 -X-KDE-Amarok-version=1 - -X-KDE-PluginInfo-Author=Matěj Laitl -X-KDE-PluginInfo-Email=matej@laitl.cz -X-KDE-PluginInfo-Version=2.0 -X-KDE-PluginInfo-Category=Collection -X-KDE-PluginInfo-License=GPL -X-KDE-PluginInfo-EnabledByDefault=true -X-KDE-PluginInfo-Name=amarok_collection-ipodcollection -X-KDE-Library=amarok_collection-ipodcollection diff --git a/amarok/src/core-impl/collections/ipodcollection/config-ipodcollection.h.cmake b/amarok/src/core-impl/collections/ipodcollection/config-ipodcollection.h.cmake deleted file mode 100644 index 5055887f..00000000 --- a/amarok/src/core-impl/collections/ipodcollection/config-ipodcollection.h.cmake +++ /dev/null @@ -1 +0,0 @@ -#cmakedefine GDKPIXBUF_FOUND 1 diff --git a/amarok/src/core-impl/collections/ipodcollection/jobs/IpodCopyTracksJob.cpp b/amarok/src/core-impl/collections/ipodcollection/jobs/IpodCopyTracksJob.cpp deleted file mode 100644 index a99d33d9..00000000 --- a/amarok/src/core-impl/collections/ipodcollection/jobs/IpodCopyTracksJob.cpp +++ /dev/null @@ -1,413 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "IpodCopyTracksJob.h" - -#include "IpodMeta.h" -#include "core/collections/QueryMaker.h" -#include "core/interfaces/Logger.h" -#include "core/support/Components.h" -#include "core/support/Debug.h" -#include "core/transcoding/TranscodingController.h" -#include "MetaTagLib.h" -#include "FileType.h" -#include "transcoding/TranscodingJob.h" - -#include -#include -#include - -#include - -#include -#include // fsync() - -IpodCopyTracksJob::IpodCopyTracksJob( const QMap &sources, - const QWeakPointer &collection, - const Transcoding::Configuration &configuration, - bool goingToRemoveSources ) - : Job() - , m_coll( collection ) - , m_transcodingConfig( configuration ) - , m_sources( sources ) - , m_aborted( false ) - , m_goingToRemoveSources( goingToRemoveSources ) -{ - connect( this, SIGNAL(startDuplicateTrackSearch(Meta::TrackPtr)), - SLOT(slotStartDuplicateTrackSearch(Meta::TrackPtr)) ); - connect( this, SIGNAL(startCopyOrTranscodeJob(KUrl,KUrl,bool)), - SLOT(slotStartCopyOrTranscodeJob(KUrl,KUrl,bool)) ); - connect( this, SIGNAL(displaySorryDialog()), SLOT(slotDisplaySorryDialog()) ); -} - -void -IpodCopyTracksJob::run() -{ - if( !m_coll ) - return; // destructed behind our back - float totalSafeCapacity = m_coll.data()->totalCapacity() - m_coll.data()->capacityMargin(); - QByteArray mountPoint = QFile::encodeName( m_coll.data()->mountPoint() ); - QString collectionPrettyName = m_coll.data()->prettyName(); - - itdb_start_sync( m_coll.data()->m_itdb ); - QMapIterator it( m_sources ); - while( it.hasNext() ) - { - if( m_aborted || !m_coll ) - break; - - it.next(); - Meta::TrackPtr track = it.key(); - KUrl sourceUrl = it.value(); - emit startDuplicateTrackSearch( track ); - - // wait for searching to finish: - m_searchingForDuplicates.acquire( 1 ); - if( m_duplicateTrack ) - { - trackProcessed( Duplicate, track, m_duplicateTrack ); - continue; - } - - if( !m_coll ) - break; // destructed behind our back - - bool isJustCopy = m_transcodingConfig.isJustCopy( track, m_coll.data()->supportedFormats() ); - - if( isJustCopy // if not copying, we catch big files later - && track->filesize() > totalSafeCapacity - m_coll.data()->usedCapacity() ) - { - // this is a best effort check, we do one definite one after the file is copied - debug() << "Refusing to copy" << track->prettyUrl() << "to iPod: there are only" - << totalSafeCapacity - m_coll.data()->usedCapacity() << "free bytes (not" - << "counting a safety margin) on iPod and track has" << track->filesize() - << "bytes."; - trackProcessed( ExceededingSafeCapacity, track ); - continue; - } - QString fileExtension; - if( isJustCopy ) - fileExtension = track->type(); - else - fileExtension = Amarok::Components::transcodingController()->format( - m_transcodingConfig.encoder() )->fileExtension(); - if( !m_coll.data()->supportedFormats().contains( fileExtension ) ) - { - m_notPlayableFormats.insert( fileExtension ); - trackProcessed( NotPlayable, track ); - continue; - } - QByteArray fakeSrcName( "filename." ); // only for file extension - fakeSrcName.append( QFile::encodeName( fileExtension ) ); - - /* determine destination filename; we cannot use ipodTrack because as it has no itdb - * (and thus mountpoint) set */ - GError *error = 0; - gchar *destFilename = itdb_cp_get_dest_filename( 0, mountPoint, fakeSrcName, &error ); - if( error ) - { - warning() << "Cannot construct iPod track filename:" << error->message; - g_error_free( error ); - error = 0; - } - if( !destFilename ) - { - trackProcessed( InternalError, track ); - continue; - } - - // start the physical copying - KUrl destUrl = KUrl( QFile::decodeName( destFilename ) ); - emit startCopyOrTranscodeJob( sourceUrl, destUrl, isJustCopy ); - - // wait for copying to finish: - m_copying.acquire( 1 ); - /* fsync so that progress bar gives correct info and user doesn't remove the iPod - * prematurely */ - QFile destFile( QFile::decodeName( destFilename ) ); - if( !destFile.exists() ) - { - debug() << destFile.fileName() << "does not exist even though we thought we copied it to iPod"; - trackProcessed( CopyingFailed, track ); - continue; - } - if( !m_coll ) - break; // destructed behind our back - if( m_coll.data()->usedCapacity() > totalSafeCapacity ) - { - debug() << "We exceeded total safe-to-use capacity on iPod (safe-to-use:" - << totalSafeCapacity << "B, used:" << m_coll.data()->usedCapacity() - << "): removing copied track from iPod"; - destFile.remove(); - trackProcessed( ExceededingSafeCapacity, track ); - continue; - } - // fsync needs a file opened for writing, and without Apped it truncates files (?) - if( !destFile.open( QIODevice::WriteOnly | QIODevice::Append ) ) - { - warning() << "Cannot open file copied to ipod (for writing):" << destFile.fileName() - << ": removing it"; - destFile.remove(); - trackProcessed( InternalError, track ); - continue; - } - if( destFile.size() ) - fsync( destFile.handle() ); // should flush all kernel buffers to disk - destFile.close(); - - // create a new track object by copying meta-data from existing one: - IpodMeta::Track *ipodTrack = new IpodMeta::Track( track ); - // tell the track it has been copied: - bool accepted = ipodTrack->finalizeCopying( mountPoint, destFilename ); - g_free( destFilename ); - destFilename = 0; - if( !accepted ) - { - debug() << "ipodTrack->finalizeCopying( destFilename ) returned false!"; - delete ipodTrack; - trackProcessed( InternalError, track ); - continue; - } - if( !isJustCopy ) - { - // we need to reread some metadata in case the file was transcoded - Meta::FieldHash fields = Meta::Tag::readTags( destFile.fileName() ); - ipodTrack->setBitrate( fields.value( Meta::valBitrate, 0 ).toInt() ); - ipodTrack->setLength( fields.value( Meta::valLength, 0 ).toLongLong() ); - ipodTrack->setSampleRate( fields.value( Meta::valSamplerate, 0 ).toInt() ); - Amarok::FileType type = Amarok::FileType( fields.value( Meta::valFormat, 0 ).toInt() ); - ipodTrack->setType( Amarok::FileTypeSupport::toString( type ) ); - // we retain ReplayGain, tags etc - these shouldn't change; size is read - // in finalizeCopying() - } - - // add the track to collection - if( !m_coll ) - { - delete ipodTrack; - break; // we were waiting for copying, m_coll may got destoryed - } - Meta::TrackPtr newTrack = m_coll.data()->addTrack( ipodTrack ); - if( !newTrack ) - { - destFile.remove(); - trackProcessed( InternalError, track ); - continue; - } - trackProcessed( Success, track, newTrack ); - } - - if( m_coll ) - itdb_stop_sync( m_coll.data()->m_itdb ); - emit endProgressOperation( this ); - - int sourceSize = m_sources.size(); - int successCount = m_sourceTrackStatus.count( Success ); - int duplicateCount = m_sourceTrackStatus.count( Duplicate ); - QString transferredText; - if ( m_transcodingConfig.isJustCopy() ) - transferredText = i18ncp( "%2 is collection name", "Transferred one track to %2.", - "Transferred %1 tracks to %2.", successCount, collectionPrettyName ); - else - transferredText = i18ncp( "%2 is collection name", "Transcoded one track to %2.", - "Transcoded %1 tracks to %2.", successCount, collectionPrettyName ); - - if( successCount == sourceSize ) - { - Amarok::Components::logger()->shortMessage( transferredText ); - } - else if( m_aborted ) - { - QString text = i18np( "Transfer aborted. Managed to transfer one track.", - "Transfer aborted. Managed to transfer %1 tracks.", - successCount ); - Amarok::Components::logger()->longMessage( text ); - } - else if( successCount + duplicateCount == sourceSize ) - { - QString text = i18ncp( "%2 is the 'Transferred 123 tracks to Some collection.' message", - "%2 One track was already there.", "%2 %1 tracks were already there.", - duplicateCount, transferredText ); - Amarok::Components::logger()->longMessage( text ); - } - else - { - // somethig more severe failed, notify user using a dialog - emit displaySorryDialog(); - } -} - -void -IpodCopyTracksJob::abort() -{ - m_aborted = true; -} - -void -IpodCopyTracksJob::slotStartDuplicateTrackSearch( const Meta::TrackPtr &track ) -{ - Collections::QueryMaker *qm = m_coll.data()->queryMaker(); - qm->setQueryType( Collections::QueryMaker::Track ); - - // we cannot qm->addMatch( track ) - it matches by uidUrl() - qm->addFilter( Meta::valTitle, track->name(), true, true ); - qm->addMatch( track->album() ); - qm->addMatch( track->artist(), Collections::QueryMaker::TrackArtists ); - qm->addMatch( track->composer() ); - qm->addMatch( track->year() ); - qm->addNumberFilter( Meta::valTrackNr, track->trackNumber(), Collections::QueryMaker::Equals ); - qm->addNumberFilter( Meta::valDiscNr, track->discNumber(), Collections::QueryMaker::Equals ); - // we don't want to match by filesize, track length, filetype etc - these change during - // transcoding. We don't match album artist because handling of it is inconsistent - - connect( qm, SIGNAL(newResultReady(Meta::TrackList)), - SLOT(slotDuplicateTrackSearchNewResult(Meta::TrackList)) ); - connect( qm, SIGNAL(queryDone()), SLOT(slotDuplicateTrackSearchQueryDone()) ); - qm->setAutoDelete( true ); - m_duplicateTrack = Meta::TrackPtr(); // reset duplicate track from previous query - qm->run(); -} - -void -IpodCopyTracksJob::slotDuplicateTrackSearchNewResult( const Meta::TrackList &tracks ) -{ - if( !tracks.isEmpty() ) - // we don't really know which one, but be sure to allow multiple results - m_duplicateTrack = tracks.last(); -} - -void -IpodCopyTracksJob::slotDuplicateTrackSearchQueryDone() -{ - m_searchingForDuplicates.release( 1 ); // wakeup run() -} - -void -IpodCopyTracksJob::slotStartCopyOrTranscodeJob( const KUrl &sourceUrl, const KUrl &destUrl, - bool isJustCopy ) -{ - KJob *job = 0; - if( isJustCopy ) - { - if( m_goingToRemoveSources && m_coll && - sourceUrl.toLocalFile().startsWith( m_coll.data()->mountPoint() ) ) - { - // special case for "add orphaned tracks" to either save space and significantly - // speed-up the process: - debug() << "Moving from" << sourceUrl << "to" << destUrl; - job = KIO::file_move( sourceUrl, destUrl, -1, KIO::HideProgressInfo | KIO::Overwrite ); - } - else - { - debug() << "Copying from" << sourceUrl << "to" << destUrl; - job = KIO::file_copy( sourceUrl, destUrl, -1, KIO::HideProgressInfo | KIO::Overwrite ); - } - } - else - { - debug() << "Transcoding from" << sourceUrl << "to" << destUrl; - job = new Transcoding::Job( sourceUrl, destUrl, m_transcodingConfig ); - } - job->setUiDelegate( 0 ); // be non-interactive - connect( job, SIGNAL(finished(KJob*)), // we must use this instead of result() to prevent deadlock - SLOT(slotCopyOrTranscodeJobFinished(KJob*)) ); - job->start(); // no-op for KIO job, but matters for transcoding job -} - -void -IpodCopyTracksJob::slotCopyOrTranscodeJobFinished( KJob *job ) -{ - if( job->error() != 0 && m_copyErrors.count() < 10 ) - m_copyErrors.insert( job->errorString() ); - m_copying.release( 1 ); // wakeup run() -} - -void -IpodCopyTracksJob::slotDisplaySorryDialog() -{ - int sourceSize = m_sources.size(); - int successCount = m_sourceTrackStatus.count( Success ); - - // match string with IpodCollectionLocation::prettyLocation() - QString collName = m_coll ? m_coll.data()->prettyName() : i18n( "Disconnected iPod/iPad/iPhone" ); - QString caption = i18nc( "%1 is collection pretty name, e.g. My Little iPod", - "Transferred Tracks to %1", collName ); - QString text; - if( successCount ) - text = i18np( "One track successfully transferred, but transfer of some other tracks failed.", - "%1 tracks successfully transferred, but transfer of some other tracks failed.", - successCount ); - else - text = i18n( "Transfer of tracks failed." ); - QString details; - int exceededingSafeCapacityCount = m_sourceTrackStatus.count( ExceededingSafeCapacity ); - if( exceededingSafeCapacityCount ) - { - details += i18np( "One track was not transferred because it would exceed iPod capacity.
    ", - "%1 tracks were not transferred because it would exceed iPod capacity.
    ", - exceededingSafeCapacityCount ); - QString reservedSpace = m_coll ? KGlobal::locale()->formatByteSize( - m_coll.data()->capacityMargin(), 1 ) : QString( "???" ); // improbable, don't bother translators - details += i18nc( "Example of %1 would be: 20.0 MiB", - "Amarok reserves %1 on iPod for iTunes database writing.
    ", - reservedSpace ); - } - int notPlayableCount = m_sourceTrackStatus.count( NotPlayable ); - if( notPlayableCount ) - { - QString formats = QStringList( m_notPlayableFormats.toList() ).join( ", " ); - details += i18np( "One track was not copied because it wouldn't be playable - its " - " %2 format is unsupported.
    ", - "%1 tracks were not copied because they wouldn't be playable - " - "they are in unsupported formats (%2).
    ", - notPlayableCount, formats ); - } - int copyingFailedCount = m_sourceTrackStatus.count( CopyingFailed ); - if( copyingFailedCount ) - { - details += i18np( "Copy/move/transcode of one file failed.
    ", - "Copy/move/transcode of %1 files failed.
    ", copyingFailedCount ); - } - int internalErrorCount = m_sourceTrackStatus.count( InternalError ); - if( internalErrorCount ) - { - details += i18np( "One track was not transferred due to an internal Amarok error.
    ", - "%1 tracks were not transferred due to an internal Amarok error.
    ", - internalErrorCount ); - details += i18n( "You can find details in Amarok debugging output.
    " ); - } - if( m_sourceTrackStatus.size() != sourceSize ) - { - // aborted case was already caught in run() - details += i18n( "The rest was not transferred because iPod collection disappeared.
    " ); - } - if( !m_copyErrors.isEmpty() ) - { - details += i18nc( "%1 is a list of errors that occurred during copying of tracks", - "Error causes: %1
    ", QStringList( m_copyErrors.toList() ).join( "
    " ) ); - } - KMessageBox::detailedSorry( 0, text, details, caption ); -} - -void -IpodCopyTracksJob::trackProcessed( CopiedStatus status, Meta::TrackPtr srcTrack, Meta::TrackPtr destTrack ) -{ - m_sourceTrackStatus.insert( status, srcTrack ); - emit incrementProgress(); - emit signalTrackProcessed( srcTrack, destTrack, status ); -} - -#include "moc_IpodCopyTracksJob.cpp" diff --git a/amarok/src/core-impl/collections/ipodcollection/jobs/IpodCopyTracksJob.h b/amarok/src/core-impl/collections/ipodcollection/jobs/IpodCopyTracksJob.h deleted file mode 100644 index 0258bf29..00000000 --- a/amarok/src/core-impl/collections/ipodcollection/jobs/IpodCopyTracksJob.h +++ /dev/null @@ -1,111 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef COPYTRACKSJOB_H -#define COPYTRACKSJOB_H - -#include "IpodCollection.h" -#include "core/meta/forward_declarations.h" -#include "core/transcoding/TranscodingConfiguration.h" - -#include - -#include -#include - -class KJob; - -class IpodCopyTracksJob : public ThreadWeaver::Job -{ - Q_OBJECT - - public: - enum CopiedStatus { - Duplicate, /// a track with same meta-data is already in iPod collection - ExceededingSafeCapacity, /// would exceed "safe" capacity - NotPlayable, /// track format would not be playable on connected iPod - CopyingFailed, /// KIO failed to copy the file - InternalError, /// all other reasons that have no nice user-tellable reason - Success /// copied successfully - }; - - /** - * @param goingToRemoveSources whether this is in fact a move operation - */ - IpodCopyTracksJob( const QMap &sources, - const QWeakPointer &collection, - const Transcoding::Configuration &configuration, - bool goingToRemoveSources ); - virtual void run(); - - public slots: - void abort(); - - signals: - // a hack to create QueryMaken in a thread with event loop: - void startDuplicateTrackSearch( const Meta::TrackPtr &track ); - - // a hack to create copyjob in a thread with event loop: - void startCopyOrTranscodeJob( const KUrl &src, const KUrl &dest, bool isJustCopy ); - - // a hack to display KMessageBox in a gui thread: - void displaySorryDialog(); - - // signals for progress operation: - void incrementProgress(); - void endProgressOperation( QObject *obj ); - void totalSteps( int steps ); // not used, defined to keep QObject::conect warning quiet - - /** - * Signal various track copy statuses back to IpodCollectionLocation - * @param srcTrack source track, always non-nul - * @param destTrack destination track on iPod, copied one or existing if - * status == Duplicate; may be null - * @param status copying status - */ - void signalTrackProcessed( Meta::TrackPtr srcTrack, Meta::TrackPtr destTrack, IpodCopyTracksJob::CopiedStatus status ); - - private slots: - /// @see startDuplicateTrackSearch() - void slotStartDuplicateTrackSearch( const Meta::TrackPtr &track ); - void slotDuplicateTrackSearchNewResult( const Meta::TrackList &tracks ); - void slotDuplicateTrackSearchQueryDone(); - - /// @see startCopyJob() - void slotStartCopyOrTranscodeJob( const KUrl &sourceUrl, const KUrl &destUrl, - bool isJustCopy ); - void slotCopyOrTranscodeJobFinished( KJob *job ); - - /// @see displaySorryDialog() - void slotDisplaySorryDialog(); - - private: - void trackProcessed( CopiedStatus status, Meta::TrackPtr srcTrack, Meta::TrackPtr destTrack = Meta::TrackPtr() ); - - QWeakPointer m_coll; - Transcoding::Configuration m_transcodingConfig; - QMap m_sources; - QMultiHash m_sourceTrackStatus; - QSemaphore m_copying; - QSemaphore m_searchingForDuplicates; - Meta::TrackPtr m_duplicateTrack; - bool m_aborted; - bool m_goingToRemoveSources; - QSet m_notPlayableFormats; - QSet m_copyErrors; -}; - -#endif // COPYTRACKSJOB_H diff --git a/amarok/src/core-impl/collections/ipodcollection/jobs/IpodDeleteTracksJob.cpp b/amarok/src/core-impl/collections/ipodcollection/jobs/IpodDeleteTracksJob.cpp deleted file mode 100644 index a46748c5..00000000 --- a/amarok/src/core-impl/collections/ipodcollection/jobs/IpodDeleteTracksJob.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "IpodDeleteTracksJob.h" - -#include "core/interfaces/Logger.h" -#include "core/support/Components.h" -#include "core-impl/collections/ipodcollection/IpodMeta.h" - -#include - -#include - -IpodDeleteTracksJob::IpodDeleteTracksJob( const Meta::TrackList &sources, - const QWeakPointer &collection ) - : Job() - , m_sources( sources ) - , m_coll( collection ) -{ -} - -void -IpodDeleteTracksJob::run() -{ - if( !m_coll ) - return; - int trackCount = m_sources.size(); - QString operationText = i18np( "Removing one track from iPod", - "Removing %1 tracks from iPod", trackCount ); - Amarok::Components::logger()->newProgressOperation( this, operationText, trackCount ); - itdb_start_sync( m_coll.data()->m_itdb ); - - QListIterator it( m_sources ); - while( it.hasNext() ) - { - if( !m_coll ) - break; - - /* delete the file first, then remove from database. Dangling entry in iTunes db - * is better than dangling file */ - Meta::TrackPtr track = it.next(); - QFile file( track->playableUrl().path() ); // iPod files are always local, QFile suffices - bool success = true; - if( file.exists() ) - success = file.remove(); - if( success ) - m_coll.data()->removeTrack( track ); - - incrementProgress(); - } - - emit endProgressOperation( this ); - if( m_coll ) - itdb_stop_sync( m_coll.data()->m_itdb ); -} - -#include "moc_IpodDeleteTracksJob.cpp" diff --git a/amarok/src/core-impl/collections/ipodcollection/jobs/IpodDeleteTracksJob.h b/amarok/src/core-impl/collections/ipodcollection/jobs/IpodDeleteTracksJob.h deleted file mode 100644 index 2e0803d4..00000000 --- a/amarok/src/core-impl/collections/ipodcollection/jobs/IpodDeleteTracksJob.h +++ /dev/null @@ -1,46 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef IPODDELETETRACKSJOB_H -#define IPODDELETETRACKSJOB_H - -#include "IpodCollection.h" -#include "core/meta/forward_declarations.h" - -#include - - -class IpodDeleteTracksJob : public ThreadWeaver::Job -{ - Q_OBJECT - - public: - explicit IpodDeleteTracksJob( const Meta::TrackList &sources, - const QWeakPointer &collection ); - virtual void run(); - - signals: - // signals for progress operation: - void incrementProgress(); - void endProgressOperation( QObject *obj ); - void totalSteps( int steps ); // not used, defined to keep QObject::conect warning quiet - - private: - Meta::TrackList m_sources; - QWeakPointer m_coll; -}; - -#endif // IPODDELETETRACKSJOB_H diff --git a/amarok/src/core-impl/collections/ipodcollection/jobs/IpodParseTracksJob.cpp b/amarok/src/core-impl/collections/ipodcollection/jobs/IpodParseTracksJob.cpp deleted file mode 100644 index ad02410a..00000000 --- a/amarok/src/core-impl/collections/ipodcollection/jobs/IpodParseTracksJob.cpp +++ /dev/null @@ -1,164 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "IpodParseTracksJob.h" - -#include "IpodCollection.h" -#include "IpodMeta.h" -#include "IpodPlaylistProvider.h" -#include "core/interfaces/Logger.h" -#include "core/support/Components.h" -#include "core/support/Debug.h" -#include "core-impl/meta/file/File.h" - -#include -#include - -#include - -IpodParseTracksJob::IpodParseTracksJob( IpodCollection *collection ) - : Job() - , m_coll( collection ) - , m_aborted( false ) -{ -} - -void IpodParseTracksJob::abort() -{ - m_aborted = true; -} - -void -IpodParseTracksJob::run() -{ - DEBUG_BLOCK - Itdb_iTunesDB *itdb = m_coll->m_itdb; - if( !itdb ) - return; // paranoia - - guint32 trackNumber = itdb_tracks_number( itdb ); - QString operationText = i18nc( "operation when iPod is connected", "Reading iPod tracks" ); - Amarok::Components::logger()->newProgressOperation( this, operationText, trackNumber, - this, SLOT(abort()) ); - - Meta::TrackList staleTracks; - QSet knownPaths; - - for( GList *tracklist = itdb->tracks; tracklist; tracklist = tracklist->next ) - { - if( m_aborted ) - break; - - Itdb_Track *ipodTrack = (Itdb_Track *) tracklist->data; - if( !ipodTrack ) - continue; // paranoia - // IpodCollection::addTrack() locks and unlocks the m_itdbMutex mutex - Meta::TrackPtr proxyTrack = m_coll->addTrack( new IpodMeta::Track( ipodTrack ) ); - if( proxyTrack ) - { - QString canonPath = QFileInfo( proxyTrack->playableUrl().toLocalFile() ).canonicalFilePath(); - if( !proxyTrack->isPlayable() ) - staleTracks.append( proxyTrack ); - else if( !canonPath.isEmpty() ) // nonexistent files return empty canonical path - knownPaths.insert( canonPath ); - } - - incrementProgress(); - } - - parsePlaylists( staleTracks, knownPaths ); - emit endProgressOperation( this ); -} - -void -IpodParseTracksJob::parsePlaylists( const Meta::TrackList &staleTracks, - const QSet &knownPaths ) -{ - IpodPlaylistProvider *prov = m_coll->m_playlistProvider; - if( !prov || m_aborted ) - return; - - if( !staleTracks.isEmpty() ) - { - prov->m_stalePlaylist = Playlists::PlaylistPtr( new IpodPlaylist( staleTracks, - i18nc( "iPod playlist name", "Stale tracks" ), m_coll, IpodPlaylist::Stale ) ); - prov->m_playlists << prov->m_stalePlaylist; // we don't subscribe to this playlist, no need to update database - emit prov->playlistAdded( prov->m_stalePlaylist ); - } - - Meta::TrackList orphanedTracks = findOrphanedTracks( knownPaths ); - if( !orphanedTracks.isEmpty() ) - { - prov->m_orphanedPlaylist = Playlists::PlaylistPtr( new IpodPlaylist( orphanedTracks, - i18nc( "iPod playlist name", "Orphaned tracks" ), m_coll, IpodPlaylist::Orphaned ) ); - prov->m_playlists << prov->m_orphanedPlaylist; // we don't subscribe to this playlist, no need to update database - emit prov->playlistAdded( prov->m_orphanedPlaylist ); - } - - if( !m_coll->m_itdb || m_aborted ) - return; - for( GList *playlists = m_coll->m_itdb->playlists; playlists; playlists = playlists->next ) - { - Itdb_Playlist *playlist = (Itdb_Playlist *) playlists->data; - if( !playlist || itdb_playlist_is_mpl( playlist ) ) - continue; // skip null (?) or master playlists - Playlists::PlaylistPtr playlistPtr( new IpodPlaylist( playlist, m_coll ) ); - prov->m_playlists << playlistPtr; - prov->subscribeTo( playlistPtr ); - emit prov->playlistAdded( playlistPtr ); - } - - if( !m_aborted && ( prov->m_stalePlaylist || prov->m_orphanedPlaylist ) ) - { - QString text = i18n( "Stale and/or orphaned tracks detected on %1. You can resolve " - "the situation using the %2 collection action. You can also view the tracks " - "under the Saved Playlists tab.", m_coll->prettyName(), - m_coll->m_consolidateAction->text() ); - Amarok::Components::logger()->longMessage( text ); - } -} - -Meta::TrackList IpodParseTracksJob::findOrphanedTracks(const QSet< QString >& knownPaths) -{ - gchar *musicDirChar = itdb_get_music_dir( QFile::encodeName( m_coll->mountPoint() ) ); - QString musicDirPath = QFile::decodeName( musicDirChar ); - g_free( musicDirChar ); - musicDirChar = 0; - - QStringList trackPatterns; - foreach( const QString &suffix, m_coll->supportedFormats() ) - { - trackPatterns << QString( "*.%1" ).arg( suffix ); - } - - Meta::TrackList orphanedTracks; - QDir musicDir( musicDirPath ); - foreach( QString subdir, musicDir.entryList( QStringList( "F??" ), QDir::Dirs | QDir::NoDotAndDotDot ) ) - { - if( m_aborted ) - return Meta::TrackList(); - subdir = musicDir.absoluteFilePath( subdir ); // make the path absolute - foreach( const QFileInfo &info, QDir( subdir ).entryInfoList( trackPatterns ) ) - { - QString canonPath = info.canonicalFilePath(); - if( knownPaths.contains( canonPath ) ) - continue; // already in iTunes database - Meta::TrackPtr track( new MetaFile::Track( KUrl( canonPath ) ) ); - orphanedTracks << track; - } - } - return orphanedTracks; -} diff --git a/amarok/src/core-impl/collections/ipodcollection/jobs/IpodParseTracksJob.h b/amarok/src/core-impl/collections/ipodcollection/jobs/IpodParseTracksJob.h deleted file mode 100644 index b6283a75..00000000 --- a/amarok/src/core-impl/collections/ipodcollection/jobs/IpodParseTracksJob.h +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef IPODPARSETRACKSJOB_H -#define IPODPARSETRACKSJOB_H - -#include "core/meta/forward_declarations.h" - -#include - -class IpodCollection; - -/** - * A job designed to parse iPod tracks and playlists in a thread so that main thread is - * not blocked with it. It is guaranteed by IpodCollection that is doesn't destory itself - * while this job is alive. Memory management of this job is up to the caller of it. - */ -class IpodParseTracksJob : public ThreadWeaver::Job -{ - Q_OBJECT - - public: - explicit IpodParseTracksJob( IpodCollection *collection ); - - public slots: - /** - * Aborts the job as soon as it is safely possible - */ - void abort(); - - protected: - void run(); - - signals: - // signals for progress operation: - void incrementProgress(); - void endProgressOperation( QObject *obj ); - void totalSteps( int steps ); // not used, defined to keep QObject::conect warning quiet - - private: - /** - * Go through iPod playlists and create Amarok playlists for them. - * - * @param staleTracks list of track from iTunes database whose associated file - * no longer exists - * @param knownPaths a set of absolute local paths of all track from iTunes - * database; used for orphaned tracks detection - */ - void parsePlaylists( const Meta::TrackList &staleTracks, - const QSet &knownPaths ); - Meta::TrackList findOrphanedTracks( const QSet &knownPaths ); - - IpodCollection *m_coll; - bool m_aborted; -}; - -#endif // IPODPARSETRACKSJOB_H diff --git a/amarok/src/core-impl/collections/ipodcollection/jobs/IpodWriteDatabaseJob.cpp b/amarok/src/core-impl/collections/ipodcollection/jobs/IpodWriteDatabaseJob.cpp deleted file mode 100644 index 123d29dd..00000000 --- a/amarok/src/core-impl/collections/ipodcollection/jobs/IpodWriteDatabaseJob.cpp +++ /dev/null @@ -1,33 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "IpodWriteDatabaseJob.h" - -#include "IpodCollection.h" - -IpodWriteDatabaseJob::IpodWriteDatabaseJob( IpodCollection *collection ) - : Job() - , m_coll( collection ) -{ -} - -void -IpodWriteDatabaseJob::run() -{ - m_coll->writeDatabase(); -} - -#include "moc_IpodWriteDatabaseJob.cpp" diff --git a/amarok/src/core-impl/collections/ipodcollection/jobs/IpodWriteDatabaseJob.h b/amarok/src/core-impl/collections/ipodcollection/jobs/IpodWriteDatabaseJob.h deleted file mode 100644 index fb0a1009..00000000 --- a/amarok/src/core-impl/collections/ipodcollection/jobs/IpodWriteDatabaseJob.h +++ /dev/null @@ -1,42 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef IPODWRITEDATABASEJOB_H -#define IPODWRITEDATABASEJOB_H - -#include - -class IpodCollection; - -/** - * A job designed to call IpodCollection::writeDatabase() in a thread so that main - * thread is not blocked with it. It is guaranteed by IpodCollection that is doesn't - * destory itself while this job is alive. Memory management of this job is up to - * the caller of it. - */ -class IpodWriteDatabaseJob : public ThreadWeaver::Job -{ - Q_OBJECT - - public: - explicit IpodWriteDatabaseJob( IpodCollection *collection ); - virtual void run(); - - private: - IpodCollection *m_coll; -}; - -#endif // IPODWRITEDATABASEJOB_H diff --git a/amarok/src/core-impl/collections/mediadevicecollection/MediaDeviceCollection.cpp b/amarok/src/core-impl/collections/mediadevicecollection/MediaDeviceCollection.cpp deleted file mode 100644 index 068e18d3..00000000 --- a/amarok/src/core-impl/collections/mediadevicecollection/MediaDeviceCollection.cpp +++ /dev/null @@ -1,251 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2006 Ian Monroe * - * Copyright (c) 2006 Seb Ruiz * - * Copyright (c) 2007 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "MediaDeviceCollection" - -#include "MediaDeviceMonitor.h" -#include "core/capabilities/ActionsCapability.h" -#include "core-impl/collections/mediadevicecollection/MediaDeviceCollection.h" -#include "core-impl/collections/mediadevicecollection/support/MediaDeviceInfo.h" -#include "core-impl/collections/support/MemoryQueryMaker.h" - -#include - -using namespace Collections; - -MediaDeviceCollectionFactoryBase::MediaDeviceCollectionFactoryBase( QObject *parent, const QVariantList &args, - ConnectionAssistant* assistant ) - : Collections::CollectionFactory( parent, args ) - , m_assistant( assistant ) -{ -} - - -MediaDeviceCollectionFactoryBase::~MediaDeviceCollectionFactoryBase() -{ -} - -void -MediaDeviceCollectionFactoryBase::init() -{ - // When assistant identifies a device, Factory will attempt to build Collection - connect( m_assistant, SIGNAL(identified(MediaDeviceInfo*)), SLOT(slotDeviceDetected(MediaDeviceInfo*)) ); - - // When assistant told to disconnect, Factory will disconnect - // the device, and have the Collection destroyed - connect( m_assistant, SIGNAL(disconnected(QString)), SLOT(slotDeviceDisconnected(QString)) ); - - // Register the device type with the Monitor - MediaDeviceMonitor::instance()->registerDeviceType( m_assistant ); - - m_initialized = true; -} - -void MediaDeviceCollectionFactoryBase::slotDeviceDetected(MediaDeviceInfo* info) -{ - MediaDeviceCollection* coll = 0; - // If device not already connected to - if( !m_collectionMap.contains( info->udi() ) ) - { - // create the collection using the info provided - coll = createCollection( info ); - // if collection successfully created, - // aka device connected to, then... - if( coll ) - { - // insert it into the map of known collections - m_collectionMap.insert( info->udi(), coll ); - connect( coll, SIGNAL(collectionReady(Collections::Collection*)), - this, SIGNAL(newCollection(Collections::Collection*)) ); - connect( coll, SIGNAL(collectionDisconnected(QString)), - this, SLOT(slotDeviceDisconnected(QString)) ); - coll->init(); - } - } -} - -void -MediaDeviceCollectionFactoryBase::slotDeviceDisconnected( const QString &udi ) -{ - DEBUG_BLOCK - // If device is known about - if( m_collectionMap.contains( udi ) ) - { - // Pull collection for the udi out of map - MediaDeviceCollection* coll = m_collectionMap[ udi ]; - // If collection exists/found - if( coll ) - { - // Remove collection from map - m_collectionMap.remove( udi ); - // Have Collection disconnect device - // and destroy itself - coll->deleteCollection(); - } - } - - return; -} - -//MediaDeviceCollection - -MediaDeviceCollection::MediaDeviceCollection() - : Collection() - , m_ejectAction( 0 ) - , m_mc( new MemoryCollection() ) -{ - connect( this, SIGNAL(attemptConnectionDone(bool)), - this, SLOT(slotAttemptConnectionDone(bool)) ); -} - -MediaDeviceCollection::~MediaDeviceCollection() -{ - DEBUG_BLOCK -} - -QueryMaker* -MediaDeviceCollection::queryMaker() -{ - return new MemoryQueryMaker( m_mc.toWeakRef(), collectionId() ); -} - -QString MediaDeviceCollection::collectionId() const -{ - return m_udi; -} - -void -MediaDeviceCollection::startFullScanDevice() -{ - DEBUG_BLOCK - // If handler successfully connected to device - - m_handler->parseTracks(); - //emit collectionReady( this ); -} - -Meta::MediaDeviceHandler* -MediaDeviceCollection::handler() -{ - return m_handler; -} - -void -MediaDeviceCollection::eject() -{ - DEBUG_BLOCK - // Do nothing special here. - emit collectionDisconnected( m_udi ); -} - -void -MediaDeviceCollection::deleteCollection() -{ - DEBUG_BLOCK - emit deletingCollection(); - emit remove(); -} - -void -MediaDeviceCollection::slotAttemptConnectionDone( bool success ) -{ - DEBUG_BLOCK - if( success ) - { - debug() << "starting full scan"; - // TODO: thread the track parsing? - startFullScanDevice(); - } - else - { - debug() << "connection failed, not scanning"; - emit collectionDisconnected( m_udi ); - } -} - -/// CollectionCapability for Disconnect Action - -bool -MediaDeviceCollection::hasCapabilityInterface( Capabilities::Capability::Type type ) const -{ - switch( type ) - { - case Capabilities::Capability::Actions: - return true; - - default: - return false; - } -} - -Capabilities::Capability* -MediaDeviceCollection::createCapabilityInterface( Capabilities::Capability::Type type ) -{ - switch( type ) - { - case Capabilities::Capability::Actions: - { - QList< QAction* > actions; - actions << m_handler->collectionActions(); - actions << ejectAction(); - return new Capabilities::ActionsCapability( actions ); - } - default: - return 0; - } -} - -bool -MediaDeviceCollection::hasCapacity() const -{ - return totalCapacity() > 0; -} - -float -MediaDeviceCollection::usedCapacity() const -{ - return m_handler->usedcapacity(); -} - -float -MediaDeviceCollection::totalCapacity() const -{ - return m_handler->totalcapacity(); -} - -void -MediaDeviceCollection::emitCollectionReady() -{ - emit collectionReady( this ); -} - -QAction * -MediaDeviceCollection::ejectAction() const -{ - if( !m_ejectAction ) - { - m_ejectAction = new QAction( KIcon( "media-eject" ), i18n( "&Disconnect Device" ), - const_cast(this) ); - m_ejectAction->setProperty( "popupdropper_svg_id", "eject" ); - - connect( m_ejectAction, SIGNAL(triggered()), SLOT(eject()) ); - } - return m_ejectAction; -} - -#include "moc_MediaDeviceCollection.cpp" diff --git a/amarok/src/core-impl/collections/mediadevicecollection/MediaDeviceCollection.h b/amarok/src/core-impl/collections/mediadevicecollection/MediaDeviceCollection.h deleted file mode 100644 index 5618e095..00000000 --- a/amarok/src/core-impl/collections/mediadevicecollection/MediaDeviceCollection.h +++ /dev/null @@ -1,174 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Alejandro Wainzinger * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef MEDIADEVICECOLLECTION_H -#define MEDIADEVICECOLLECTION_H - -#include "core/collections/Collection.h" -#include "core-impl/collections/mediadevicecollection/MediaDeviceCollectionLocation.h" -#include "core-impl/collections/mediadevicecollection/support/ConnectionAssistant.h" -#include "core-impl/collections/mediadevicecollection/support/mediadevicecollection_export.h" -#include "core-impl/collections/support/MemoryCollection.h" - -#include - -#include -#include - -namespace Collections { - -class MediaDeviceCollection; - -/** - * HACK: Base and Factory are separate because Q_OBJECT does not work directly with templates. - * Templates used to reduce duplicated code in subclasses. - */ -class MEDIADEVICECOLLECTION_EXPORT MediaDeviceCollectionFactoryBase : public Collections::CollectionFactory -{ - Q_OBJECT - - public: - virtual ~MediaDeviceCollectionFactoryBase(); - virtual void init(); - - protected: - MediaDeviceCollectionFactoryBase( QObject *parent, const QVariantList &args, - ConnectionAssistant* assistant ); - - protected slots: - virtual void slotDeviceDetected( MediaDeviceInfo* info ); // detected type of device, connect it - - private slots: - void slotDeviceDisconnected( const QString &udi ); - - private: - virtual MediaDeviceCollection* createCollection( MediaDeviceInfo* info ) = 0; - - ConnectionAssistant* m_assistant; - QMap m_collectionMap; -}; - -template -class MediaDeviceCollectionFactory : public MediaDeviceCollectionFactoryBase -{ - protected: - MediaDeviceCollectionFactory( QObject *parent, const QVariantList &args, - ConnectionAssistant *assistant ) - : MediaDeviceCollectionFactoryBase( parent, args, assistant ) - {} - - virtual ~MediaDeviceCollectionFactory() {} - - private: - virtual MediaDeviceCollection* createCollection( MediaDeviceInfo* info ) - { - return new CollType( info ); - } -}; - - -class MEDIADEVICECOLLECTION_EXPORT MediaDeviceCollection : public Collections::Collection -{ - Q_OBJECT - - public: - /** Collection-related methods */ - - virtual ~MediaDeviceCollection(); - - /** - * url-based methods can be abstracted via use of Amarok URLs - * subclasses simply define a protocol prefix, e.g. ipod - */ - virtual bool possiblyContainsTrack( const KUrl &url ) const { Q_UNUSED(url); return false;} // TODO: NYI - virtual Meta::TrackPtr trackForUrl( const KUrl &url ) { Q_UNUSED(url); return Meta::TrackPtr(); } // TODO: NYI - - virtual QueryMaker* queryMaker(); - virtual void startFullScanDevice(); - - // NOTE: incrementalscan and stopscan not implemented, might be used by UMS later though - - /** - The protocol of uids coming from this collection. - @return A string of the protocol, without the :// - - This has to be overridden for every device type, e.g. ipod:// - */ - virtual QString uidUrlProtocol() const { return QString(); } // TODO: NYI - virtual QString collectionId() const; // uses udi - - virtual QString prettyName() const = 0; // NOTE: must be overridden based on device type - virtual KIcon icon() const = 0; // NOTE: must be overridden based on device type - - virtual bool hasCapacity() const; - virtual float usedCapacity() const; - virtual float totalCapacity() const; - - // NOTE: location will have same method calls always, no need to redo each time - virtual CollectionLocation* location() { return new MediaDeviceCollectionLocation( this ); } - - /** Capability-related methods */ - virtual bool hasCapabilityInterface( Capabilities::Capability::Type type ) const; - virtual Capabilities::Capability* createCapabilityInterface( Capabilities::Capability::Type type ); - - /** MediaDeviceCollection methods */ - QString udi() const { return m_udi; } - - /** MediaDeviceCollection-specific */ - Meta::MediaDeviceHandler* handler(); - void init() { m_handler->init(); } // tell handler to start connection - void emitCollectionReady(); - - virtual QAction *ejectAction() const; - - QSharedPointer memoryCollection() const { return m_mc; } - void collectionUpdated() { emit updated(); } - - signals: - void collectionReady( Collections::Collection* ); - /** collectionDisconnected is called when ConnectionAssistant - is told it is to be disconnected. This could be - because another part of Amarok (e.g. applet) told it to - or because the MediaDeviceMonitor noticed it disconnect - */ - void collectionDisconnected( const QString &udi ); - void deletingCollection(); - - void attemptConnectionDone( bool success ); - - void copyTracksCompleted( bool success ); - - public slots: - void slotAttemptConnectionDone( bool success ); - - virtual void eject(); - void deleteCollection(); - - protected: - MediaDeviceCollection(); - - QString m_udi; - Meta::MediaDeviceHandler *m_handler; - - mutable QAction *m_ejectAction; - - QSharedPointer m_mc; - -}; - -} //namespace Collections - -#endif diff --git a/amarok/src/core-impl/collections/mediadevicecollection/MediaDeviceCollectionLocation.cpp b/amarok/src/core-impl/collections/mediadevicecollection/MediaDeviceCollectionLocation.cpp deleted file mode 100644 index 9ae37741..00000000 --- a/amarok/src/core-impl/collections/mediadevicecollection/MediaDeviceCollectionLocation.cpp +++ /dev/null @@ -1,140 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Alejandro Wainzinger * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "MediaDeviceCollectionLocation.h" - -#include "MediaDeviceCache.h" // for collection refresh hack -#include "core/meta/Meta.h" -#include "core/support/Debug.h" -#include "core-impl/collections/mediadevicecollection/MediaDeviceCollection.h" - -#include -#include -#include -#include - -using namespace Collections; - -MediaDeviceCollectionLocation::MediaDeviceCollectionLocation( MediaDeviceCollection *collection ) - : CollectionLocation( collection ) - , m_collection( collection ) - , m_handler( m_collection->handler() ) -{ - //nothing to do -} - -MediaDeviceCollectionLocation::~MediaDeviceCollectionLocation() -{ - //nothing to do -} - -QString -MediaDeviceCollectionLocation::prettyLocation() const -{ - return collection()->prettyName(); -} - -bool -MediaDeviceCollectionLocation::isWritable() const -{ - return m_handler->isWritable(); -} - -void -MediaDeviceCollectionLocation::getKIOCopyableUrls( const Meta::TrackList &tracks ) -{ - connect( m_handler, SIGNAL(gotCopyableUrls(QMap)),SLOT(slotGetKIOCopyableUrlsDone(QMap)) ); - m_handler->getCopyableUrls( tracks ); -} - - -void -MediaDeviceCollectionLocation::copyUrlsToCollection( const QMap &sources, - const Transcoding::Configuration &configuration ) -{ - DEBUG_BLOCK - Q_UNUSED( configuration ) - - connect( m_handler, SIGNAL(copyTracksDone(bool)), - this, SLOT(copyOperationFinished(bool)), - Qt::QueuedConnection ); - m_handler->copyTrackListToDevice( sources.keys() ); - -/* - connect( m_collection, SIGNAL(copyTracksCompleted(bool)), - SLOT(copyOperationFinished(bool)) ); - - // Copy list of tracks - m_collection->copyTrackListToDevice( sources.keys() ); - */ - - // TODO: call handler's method for copying a list of - // tracks to the device. At the end, if successful, - // write to database, and any unsuccessful track - // copies will generate warning/error messages -} - -void -MediaDeviceCollectionLocation::copyOperationFinished( bool success ) -{ - // TODO: should connect database written signal to - // to this slot - - if( success ) - { - m_handler->writeDatabase(); - } - // TODO: will be replaced with a more powerful method - // which deals with particular reasons for failed copies - /* - DEBUG_BLOCK - if( !success ) - { - QMap failedTracks = m_collection->handler()->tracksFailed(); - debug() << "The following tracks failed to copy"; - foreach( Meta::TrackPtr track, failedTracks.keys() ) - { - // TODO: better error handling - debug() << track->artist()->name() << " - " << track->name() << " with error: " << failedTracks[ track ]; - source()->transferError( track, failedTracks[ track ] ); - } - } - */ - slotCopyOperationFinished(); -} - -void -MediaDeviceCollectionLocation::removeUrlsFromCollection( const Meta::TrackList &sources ) -{ - DEBUG_BLOCK - connect( m_handler, SIGNAL(removeTracksDone()), - this, SLOT(removeOperationFinished()) ); - - m_handler->removeTrackListFromDevice( sources ); -} - -void -MediaDeviceCollectionLocation::removeOperationFinished() -{ - DEBUG_BLOCK - - m_handler->writeDatabase(); - - slotRemoveOperationFinished(); -} - -#include "moc_MediaDeviceCollectionLocation.cpp" - diff --git a/amarok/src/core-impl/collections/mediadevicecollection/MediaDeviceCollectionLocation.h b/amarok/src/core-impl/collections/mediadevicecollection/MediaDeviceCollectionLocation.h deleted file mode 100644 index e40529fb..00000000 --- a/amarok/src/core-impl/collections/mediadevicecollection/MediaDeviceCollectionLocation.h +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Alejandro Wainzinger * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_MEDIADEVICECOLLECTIONLOCATION_H -#define AMAROK_MEDIADEVICECOLLECTIONLOCATION_H - -#include "core/collections/CollectionLocation.h" -#include "core-impl/collections/mediadevicecollection/handler/MediaDeviceHandler.h" -#include "core-impl/collections/mediadevicecollection/support/mediadevicecollection_export.h" - -#include -#include -#include - -class KJob; - -namespace Collections { - -class MediaDeviceCollection; - -class MEDIADEVICECOLLECTION_EXPORT MediaDeviceCollectionLocation : public CollectionLocation -{ - Q_OBJECT - public: - MediaDeviceCollectionLocation( MediaDeviceCollection *collection ); - virtual ~MediaDeviceCollectionLocation(); - - virtual QString prettyLocation() const; - virtual bool isWritable() const; - - protected: - virtual void getKIOCopyableUrls( const Meta::TrackList &tracks ); - - /// Copies these tracks to the Collection using the Handler - virtual void copyUrlsToCollection( const QMap &sources, - const Transcoding::Configuration &configuration ); - - virtual void removeUrlsFromCollection( const Meta::TrackList &sources ); - - - private slots: - void copyOperationFinished( bool success ); - void removeOperationFinished(); - - private: - MediaDeviceCollection *m_collection; - Meta::MediaDeviceHandler *m_handler; -}; - -} //namespace Collections - -#endif diff --git a/amarok/src/core-impl/collections/mediadevicecollection/MediaDeviceMeta.cpp b/amarok/src/core-impl/collections/mediadevicecollection/MediaDeviceMeta.cpp deleted file mode 100644 index 4a419d5a..00000000 --- a/amarok/src/core-impl/collections/mediadevicecollection/MediaDeviceMeta.cpp +++ /dev/null @@ -1,1024 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Alejandro Wainzinger * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "MediaDeviceMeta.h" - -#include "SvgHandler.h" -#include "core/capabilities/ActionsCapability.h" -#include "core/support/Debug.h" -#include "core-impl/capabilities/AlbumActionsCapability.h" -#include "core-impl/collections/mediadevicecollection/MediaDeviceCollection.h" -#include "core-impl/collections/mediadevicecollection/MediaDeviceTrackEditor.h" -#include "core-impl/collections/mediadevicecollection/handler/capabilities/ArtworkCapability.h" -#include "covermanager/CoverCache.h" -#include "covermanager/CoverFetchingActions.h" - -#include -#include - -#include - -using namespace Meta; - -MediaDeviceTrack::MediaDeviceTrack( Collections::MediaDeviceCollection *collection ) - : Meta::Track() - , m_collection( collection ) - , m_artist( 0 ) - , m_album( 0 ) - , m_genre( 0 ) - , m_composer( 0 ) - , m_year( 0 ) - , m_image() - , m_comment() - , m_name() - , m_type() - , m_bitrate( 0 ) - , m_filesize( 0 ) - , m_length( 0 ) - , m_discNumber( 0 ) - , m_samplerate( 0 ) - , m_trackNumber( 0 ) - , m_playCount( 0 ) - , m_rating( 0 ) - , m_bpm( 0 ) - , m_playableUrl() -{ -} - -MediaDeviceTrack::~MediaDeviceTrack() -{ - //nothing to do -} - -QString -MediaDeviceTrack::name() const -{ - return m_name; -} - -KUrl -MediaDeviceTrack::playableUrl() const -{ - return m_playableUrl; -} - -QString -MediaDeviceTrack::uidUrl() const -{ - return m_playableUrl.isLocalFile() ? m_playableUrl.toLocalFile() : m_playableUrl.url(); -} - -QString -MediaDeviceTrack::prettyUrl() const -{ - if( m_playableUrl.isLocalFile() ) - return m_playableUrl.toLocalFile(); - - QString collName = m_collection ? m_collection.data()->prettyName() : i18n( "Unknown Collection" ); - QString artistName = artist()? artist()->prettyName() : i18n( "Unknown Artist" ); - // Check name() to prevent infinite recursion - QString trackName = !name().isEmpty()? prettyName() : i18n( "Unknown track" ); - - return QString( "%1: %2 - %3" ).arg( collName, artistName, trackName ); -} - -QString -MediaDeviceTrack::notPlayableReason() const -{ - return localFileNotPlayableReason( playableUrl().toLocalFile() ); -} - -bool -MediaDeviceTrack::isEditable() const -{ - if( m_collection ) - return m_collection.data()->isWritable(); - return false; -} - -AlbumPtr -MediaDeviceTrack::album() const -{ - return AlbumPtr::staticCast( m_album ); -} - -ArtistPtr -MediaDeviceTrack::artist() const -{ - return ArtistPtr::staticCast( m_artist ); -} - -GenrePtr -MediaDeviceTrack::genre() const -{ - return GenrePtr::staticCast( m_genre ); -} - -ComposerPtr -MediaDeviceTrack::composer() const -{ - return ComposerPtr::staticCast( m_composer ); -} - -YearPtr -MediaDeviceTrack::year() const -{ - return YearPtr::staticCast( m_year ); -} - -QString -MediaDeviceTrack::comment() const -{ - return m_comment; -} - -void -MediaDeviceTrack::setComment( const QString &newComment ) -{ - m_comment = newComment; -} - -double -MediaDeviceTrack::score() const -{ - return 0.0; -} - -void -MediaDeviceTrack::setScore( double newScore ) -{ - Q_UNUSED( newScore ) -} - -int -MediaDeviceTrack::rating() const -{ - return m_rating; -} - -void -MediaDeviceTrack::setRating( int newRating ) -{ - if( newRating == m_rating ) - return; - m_rating = newRating; - // this method is _not_ called though TrackEditor, notify observers manually - notifyObservers(); -} - -qint64 -MediaDeviceTrack::length() const -{ - return m_length; -} - -void -MediaDeviceTrack::setFileSize( int newFileSize ) -{ - m_filesize = newFileSize; -} - -int -MediaDeviceTrack::filesize() const -{ - return m_filesize; -} - -int -MediaDeviceTrack::bitrate() const -{ - return m_bitrate; -} - -void -MediaDeviceTrack::setBitrate( int newBitrate ) -{ - m_bitrate = newBitrate; -} - -int -MediaDeviceTrack::sampleRate() const -{ - return m_samplerate; -} - -void -MediaDeviceTrack::setSamplerate( int newSamplerate ) -{ - m_samplerate = newSamplerate; -} - -qreal -MediaDeviceTrack::bpm() const -{ - return m_bpm; -} -void -MediaDeviceTrack::setBpm( const qreal newBpm ) -{ - m_bpm = newBpm; -} - -int -MediaDeviceTrack::trackNumber() const -{ - return m_trackNumber; -} - -void -MediaDeviceTrack::setTrackNumber( int newTrackNumber ) -{ - m_trackNumber = newTrackNumber; -} - -int -MediaDeviceTrack::discNumber() const -{ - return m_discNumber; -} - -void -MediaDeviceTrack::setDiscNumber( int newDiscNumber ) -{ - m_discNumber = newDiscNumber; -} - -int -MediaDeviceTrack::playCount() const -{ - return m_playCount; -} - -void -MediaDeviceTrack::setPlayCount( const int newCount ) -{ - m_playCount = newCount; -} - -QDateTime -MediaDeviceTrack::lastPlayed() const -{ - return m_lastPlayed; -} - -void -MediaDeviceTrack::setLastPlayed( const QDateTime &newTime ) -{ - m_lastPlayed = newTime; -} - -qreal -MediaDeviceTrack::replayGain( ReplayGainTag mode ) const -{ - /* no known non-UMS portable media player is able to differentiante between different - * replay gain modes (track & album), so store only one value */ - switch( mode ) { - case Meta::ReplayGain_Track_Gain: - case Meta::ReplayGain_Album_Gain: - return m_replayGain; - case Meta::ReplayGain_Track_Peak: - case Meta::ReplayGain_Album_Peak: - // no default label so that compiler emits a warning when new enum value is added - break; - } - return 0.0; -} - -void -MediaDeviceTrack::setReplayGain( qreal newReplayGain ) -{ - m_replayGain = newReplayGain; -} - -QString -MediaDeviceTrack::type() const -{ - if( m_type.isEmpty() && !m_playableUrl.path().isEmpty() ) - { - QString path = m_playableUrl.path(); - return path.mid( path.lastIndexOf( '.' ) + 1 ); - } - return m_type; -} - -void -MediaDeviceTrack::setType( const QString & type ) -{ - m_type = type; -} - -void -MediaDeviceTrack::prepareToPlay() -{ - Meta::MediaDeviceTrackPtr ptr = Meta::MediaDeviceTrackPtr( this ); - - if( m_collection && m_collection.data()->handler() ) - m_collection.data()->handler()->prepareToPlay( ptr ); -} - -// TODO: employ observers (e.g. Handler) to take care of updated -// data -/* -void -MediaDeviceTrack::subscribe( Observer *observer ) -{ - Q_UNUSED( observer ) //read only -} - -void -MediaDeviceTrack::unsubscribe( Observer *observer ) -{ - Q_UNUSED( observer ) //read only -} -*/ -// TODO: implement this for MediaDeviceCollectionLocation -bool -MediaDeviceTrack::inCollection() const -{ - return m_collection; // true is m_collection is not null pointer, false otherwise -} - -Collections::Collection* -MediaDeviceTrack::collection() const -{ - return m_collection.data(); -} - -TrackEditorPtr -MediaDeviceTrack::editor() -{ - return TrackEditorPtr( isEditable() ? new MediaDeviceTrackEditor( this ) : 0 ); -} - -StatisticsPtr -MediaDeviceTrack::statistics() -{ - return StatisticsPtr( this ); -} - -void -MediaDeviceTrack::setAlbum( const QString &newAlbum ) -{ - if( !m_collection ) - return; - - MediaDeviceAlbumPtr albumPtr; - MediaDeviceTrackPtr track( this ); - AlbumMap albumMap = m_collection.data()->memoryCollection()->albumMap(); - - // do cleanup of soon to be previous album - - MediaDeviceArtistPtr albumArtist; - QString albumArtistName; - albumPtr = m_album; - if ( !albumPtr.isNull() ) - { - albumArtist = MediaDeviceArtistPtr::staticCast( albumPtr->albumArtist() ); - if( albumArtist ) - albumArtistName = albumArtist->name(); - // remove track from previous album's tracklist - albumPtr->remTrack( track ); - // if album's tracklist is empty, remove album from albummap - if( albumPtr->tracks().isEmpty() ) - albumMap.remove( AlbumPtr::staticCast( albumPtr ) ); - } - - // change to a new album - - // check for the existence of the album to be set to, - // if album exists, reuse, else create - - if ( albumMap.contains( newAlbum, albumArtistName ) ) - { - albumPtr = MediaDeviceAlbumPtr::staticCast( albumMap.value( newAlbum, albumArtistName ) ); - } - else - { - albumPtr = MediaDeviceAlbumPtr( new MediaDeviceAlbum( m_collection.data(), newAlbum ) ); - albumPtr->setAlbumArtist( albumArtist ); - albumMap.insert( AlbumPtr::staticCast( albumPtr ) ); - } - - // add track to album's tracklist - albumPtr->addTrack( track ); - // set track's album to the new album - setAlbum( albumPtr ); - - m_collection.data()->memoryCollection()->acquireWriteLock(); - m_collection.data()->memoryCollection()->setAlbumMap( albumMap ); - m_collection.data()->memoryCollection()->releaseLock(); -} - -void -MediaDeviceTrack::setAlbumArtist( const QString &newAlbumArtist ) -{ - if( !m_collection ) - return; - - if( m_album.isNull() || newAlbumArtist.isEmpty() ) - return; - - MediaDeviceArtistPtr artistPtr; - ArtistMap artistMap = m_collection.data()->memoryCollection()->artistMap(); - - if( artistMap.contains( newAlbumArtist ) ) - artistPtr = MediaDeviceArtistPtr::staticCast( artistMap.value( newAlbumArtist ) ); - else - { - artistPtr = MediaDeviceArtistPtr( new MediaDeviceArtist( newAlbumArtist ) ); - artistMap.insert( newAlbumArtist, ArtistPtr::staticCast( artistPtr ) ); - } - - m_album->setAlbumArtist( artistPtr ); - - m_collection.data()->memoryCollection()->acquireWriteLock(); - m_collection.data()->memoryCollection()->setArtistMap( artistMap ); - m_collection.data()->memoryCollection()->releaseLock(); -} - -void -MediaDeviceTrack::setArtist( const QString &newArtist ) -{ - if( !m_collection ) - return; - - MediaDeviceArtistPtr artistPtr; - MediaDeviceTrackPtr track( this ); - ArtistMap artistMap = m_collection.data()->memoryCollection()->artistMap(); - - // do cleanup of soon to be previous artist - - artistPtr = m_artist; - // remove track from previous artist's tracklist - if ( !artistPtr.isNull() ) - { - artistPtr->remTrack( track ); - // if artist's tracklist is empty, remove artist from artistmap - if( artistPtr->tracks().isEmpty() ) - artistMap.remove( artistPtr->name() ); - } - - // change to a new artist - - // check for the existence of the artist to be set to, - // if artist exists, reuse, else create - - if ( artistMap.contains( newArtist ) ) - { - artistPtr = MediaDeviceArtistPtr::staticCast( artistMap.value( newArtist ) ); - } - else - { - artistPtr = MediaDeviceArtistPtr( new MediaDeviceArtist( newArtist ) ); - artistMap.insert( newArtist, ArtistPtr::staticCast( artistPtr ) ); - } - - // add track to artist's tracklist - artistPtr->addTrack( track ); - // set track's artist to the new artist - setArtist( artistPtr ); - - m_collection.data()->memoryCollection()->acquireWriteLock(); - m_collection.data()->memoryCollection()->setArtistMap( artistMap ); - m_collection.data()->memoryCollection()->releaseLock(); -} - -void -MediaDeviceTrack::setGenre( const QString &newGenre ) -{ - if( !m_collection ) - return; - - MediaDeviceGenrePtr genrePtr; - MediaDeviceTrackPtr track( this ); - GenreMap genreMap = m_collection.data()->memoryCollection()->genreMap(); - - // do cleanup of soon to be previous genre - - genrePtr = m_genre; - if ( !genrePtr.isNull() ) - { - // remove track from previous genre's tracklist - genrePtr->remTrack( track ); - // if genre's tracklist is empty, remove genre from genremap - if( genrePtr->tracks().isEmpty() ) - genreMap.remove( genrePtr->name() ); - } - - // change to a new genre - - // check for the existence of the genre to be set to, - // if genre exists, reuse, else create - - if ( genreMap.contains( newGenre ) ) - { - genrePtr = MediaDeviceGenrePtr::staticCast( genreMap.value( newGenre ) ); - } - else - { - genrePtr = MediaDeviceGenrePtr( new MediaDeviceGenre( newGenre ) ); - genreMap.insert( newGenre, GenrePtr::staticCast( genrePtr ) ); - } - - // add track to genre's tracklist - genrePtr->addTrack( track ); - // set track's genre to the new genre - setGenre( genrePtr ); - - m_collection.data()->memoryCollection()->acquireWriteLock(); - m_collection.data()->memoryCollection()->setGenreMap( genreMap ); - m_collection.data()->memoryCollection()->releaseLock(); -} - -void -MediaDeviceTrack::setComposer( const QString &newComposer ) -{ - if( !m_collection ) - return; - - MediaDeviceComposerPtr composerPtr; - MediaDeviceTrackPtr track( this ); - ComposerMap composerMap = m_collection.data()->memoryCollection()->composerMap(); - - // do cleanup of soon to be previous composer - - composerPtr = m_composer; - if ( !composerPtr.isNull() ) - { - // remove track from previous composer's tracklist - composerPtr->remTrack( track ); - // if composer's tracklist is empty, remove composer from composermap - if( composerPtr->tracks().isEmpty() ) - composerMap.remove( composerPtr->name() ); - } - - // change to a new composer - - // check for the existence of the composer to be set to, - // if composer exists, reuse, else create - - if ( composerMap.contains( newComposer ) ) - { - composerPtr = MediaDeviceComposerPtr::staticCast( composerMap.value( newComposer ) ); - } - else - { - composerPtr = MediaDeviceComposerPtr( new MediaDeviceComposer( newComposer ) ); - composerMap.insert( newComposer, ComposerPtr::staticCast( composerPtr ) ); - } - - // add track to composer's tracklist - composerPtr->addTrack( track ); - // set track's composer to the new composer - setComposer( composerPtr ); - - m_collection.data()->memoryCollection()->acquireWriteLock(); - m_collection.data()->memoryCollection()->setComposerMap( composerMap ); - m_collection.data()->memoryCollection()->releaseLock(); -} - -void -MediaDeviceTrack::setYear( int newYear ) -{ - if( !m_collection ) - return; - - MediaDeviceYearPtr yearPtr; - MediaDeviceTrackPtr track( this ); - YearMap yearMap = m_collection.data()->memoryCollection()->yearMap(); - - // do cleanup of soon to be previous year - - yearPtr = m_year; - if ( !yearPtr.isNull() ) - { - // remove track from previous year's tracklist - yearPtr->remTrack( track ); - // if year's tracklist is empty, remove year from yearmap - if( yearPtr->tracks().isEmpty() ) - yearMap.remove( yearPtr->year() ); - } - - // change to a new year - - // check for the existence of the year to be set to, - // if year exists, reuse, else create - - if ( yearMap.contains( newYear ) ) - { - yearPtr = MediaDeviceYearPtr::staticCast( yearMap.value( newYear ) ); - } - else - { - yearPtr = MediaDeviceYearPtr( new MediaDeviceYear( QString::number(newYear) ) ); - yearMap.insert( newYear, YearPtr::staticCast( yearPtr ) ); - } - - // add track to year's tracklist - yearPtr->addTrack( track ); - // set track's year to the new year - setYear( yearPtr ); - - m_collection.data()->memoryCollection()->acquireWriteLock(); - m_collection.data()->memoryCollection()->setYearMap( yearMap ); - m_collection.data()->memoryCollection()->releaseLock(); -} - -void -MediaDeviceTrack::setAlbum( MediaDeviceAlbumPtr album ) -{ - m_album = album; -} - -void -MediaDeviceTrack::setArtist( MediaDeviceArtistPtr artist ) -{ - m_artist = artist; -} - -void -MediaDeviceTrack::setGenre( MediaDeviceGenrePtr genre ) -{ - m_genre = genre; -} - -void -MediaDeviceTrack::setComposer( MediaDeviceComposerPtr composer ) -{ - m_composer = composer; -} - -void -MediaDeviceTrack::setYear( MediaDeviceYearPtr year ) -{ - m_year = year; -} - -QString -MediaDeviceTrack::title() const -{ - return m_name; -} - -void -MediaDeviceTrack::setTitle( const QString &title ) -{ - m_name = title; -} - -void -MediaDeviceTrack::setLength( qint64 length ) -{ - m_length = length; -} - -void -MediaDeviceTrack::commitChanges() -{ - notifyObservers(); -} - -//MediaDeviceArtist - -MediaDeviceArtist::MediaDeviceArtist( const QString &name ) - : Meta::Artist() - , m_name( name ) - , m_tracks() -{ - //nothing to do -} - -MediaDeviceArtist::~MediaDeviceArtist() -{ - //nothing to do -} - -QString -MediaDeviceArtist::name() const -{ - return m_name; -} - -TrackList -MediaDeviceArtist::tracks() -{ - return m_tracks; -} - -void -MediaDeviceArtist::addTrack( MediaDeviceTrackPtr track ) -{ - m_tracks.append( TrackPtr::staticCast( track ) ); -} - -void -MediaDeviceArtist::remTrack( MediaDeviceTrackPtr track ) -{ - m_tracks.removeOne( TrackPtr::staticCast( track ) ); -} - -//---------------MediaDeviceAlbum----------------------------------- - -MediaDeviceAlbum::MediaDeviceAlbum( Collections::MediaDeviceCollection *collection, const QString &name ) - : Meta::Album() - , m_collection( collection ) - , m_artworkCapability() - , m_name( name ) - , m_tracks() - , m_isCompilation( false ) - , m_hasImagePossibility( true ) // assume it has a cover until proven otherwise - , m_hasImageChecked( false ) - , m_image( QImage() ) - , m_albumArtist( 0 ) -{ - MediaDeviceHandler *handler = m_collection.data()->handler(); - if( handler && handler->hasCapabilityInterface( Handler::Capability::Artwork ) ) - m_artworkCapability = handler->create(); -} - -MediaDeviceAlbum::~MediaDeviceAlbum() -{ - if( m_artworkCapability ) - m_artworkCapability.data()->deleteLater(); - CoverCache::invalidateAlbum( this ); -} - -QString -MediaDeviceAlbum::name() const -{ - return m_name; -} - -bool -MediaDeviceAlbum::isCompilation() const -{ - return m_isCompilation; -} - -void -MediaDeviceAlbum::setIsCompilation( bool compilation ) -{ - m_isCompilation = compilation; -} - -bool -MediaDeviceAlbum::hasAlbumArtist() const -{ - return !m_albumArtist.isNull(); -} - -ArtistPtr -MediaDeviceAlbum::albumArtist() const -{ - return ArtistPtr::staticCast( m_albumArtist ); -} - -TrackList -MediaDeviceAlbum::tracks() -{ - return m_tracks; -} - -bool -MediaDeviceAlbum::hasImage( int size ) const -{ - Q_UNUSED( size ) - - if( !m_hasImageChecked ) - m_hasImagePossibility = ! const_cast( this )->image().isNull(); - return m_hasImagePossibility; -} - -QImage -MediaDeviceAlbum::image( int size ) const -{ - if( m_name.isEmpty() || !m_hasImagePossibility || m_tracks.isEmpty() ) - return Meta::Album::image( size ); - - if( m_image.isNull() && m_artworkCapability ) - { - MediaDeviceTrackPtr track = MediaDeviceTrackPtr::staticCast( m_tracks.first() ); - m_image = m_artworkCapability.data()->getCover( track ); - m_hasImagePossibility = !m_image.isNull(); - m_hasImageChecked = true; - CoverCache::invalidateAlbum( this ); - } - - if( !m_image.isNull() ) - { - if( !size ) - return m_image; - return m_image.scaled( QSize( size, size ), Qt::KeepAspectRatio ); - } - return Meta::Album::image( size ); -} - -bool -MediaDeviceAlbum::canUpdateImage() const -{ - if( m_artworkCapability ) - return m_artworkCapability.data()->canUpdateCover(); - return false; -} - -void -MediaDeviceAlbum::setImage( const QImage &image ) -{ - if( m_artworkCapability && m_artworkCapability.data()->canUpdateCover() ) - { - // reset to initial values, let next call to image() re-fetch it - m_hasImagePossibility = true; - m_hasImageChecked = false; - - m_artworkCapability.data()->setCover( MediaDeviceAlbumPtr( this ), image ); - CoverCache::invalidateAlbum( this ); - } -} - -void -MediaDeviceAlbum::setImagePath( const QString &path ) -{ - if( m_artworkCapability && m_artworkCapability.data()->canUpdateCover() ) - { - // reset to initial values, let next call to image() re-fetch it - m_hasImagePossibility = true; - m_hasImageChecked = false; - - m_artworkCapability.data()->setCoverPath( MediaDeviceAlbumPtr( this ), path ); - CoverCache::invalidateAlbum( this ); - } -} - -bool -MediaDeviceAlbum::hasCapabilityInterface( Capabilities::Capability::Type type ) const -{ - switch( type ) - { - case Capabilities::Capability::Actions: - return true; - default: - return false; - } -} - -Capabilities::Capability* -MediaDeviceAlbum::createCapabilityInterface( Capabilities::Capability::Type type ) -{ - switch( type ) - { - case Capabilities::Capability::Actions: - return new Capabilities::AlbumActionsCapability( Meta::AlbumPtr( this ) ); - - default: - return 0; - } -} - -void -MediaDeviceAlbum::addTrack( MediaDeviceTrackPtr track ) -{ - m_tracks.append( TrackPtr::staticCast( track ) ); -} - -void -MediaDeviceAlbum::remTrack( MediaDeviceTrackPtr track ) -{ - m_tracks.removeOne( TrackPtr::staticCast( track ) ); -} - -void -MediaDeviceAlbum::setAlbumArtist( MediaDeviceArtistPtr artist ) -{ - m_albumArtist = artist; -} - -//MediaDeviceComposer - -MediaDeviceComposer::MediaDeviceComposer( const QString &name ) - : Meta::Composer() - , m_name( name ) - , m_tracks() -{ - //nothing to do -} - -MediaDeviceComposer::~MediaDeviceComposer() -{ - //nothing to do -} - -QString -MediaDeviceComposer::name() const -{ - return m_name; -} - -TrackList -MediaDeviceComposer::tracks() -{ - return m_tracks; -} - -void -MediaDeviceComposer::addTrack( MediaDeviceTrackPtr track ) -{ - m_tracks.append( TrackPtr::staticCast( track ) ); -} - -void -MediaDeviceComposer::remTrack( MediaDeviceTrackPtr track ) -{ - m_tracks.removeOne( TrackPtr::staticCast( track ) ); -} - -//---------------MediaDeviceGenre----------------------------------- - -MediaDeviceGenre::MediaDeviceGenre( const QString &name ) - : Meta::Genre() - , m_name( name ) - , m_tracks() -{ - //nothing to do -} - -MediaDeviceGenre::~MediaDeviceGenre() -{ - //nothing to do -} - -QString -MediaDeviceGenre::name() const -{ - return m_name; -} - -TrackList -MediaDeviceGenre::tracks() -{ - return m_tracks; -} - -void -MediaDeviceGenre::addTrack( MediaDeviceTrackPtr track ) -{ - m_tracks.append( TrackPtr::staticCast( track ) ); -} - -void -MediaDeviceGenre::remTrack( MediaDeviceTrackPtr track ) -{ - m_tracks.removeOne( TrackPtr::staticCast( track ) ); -} - - -//MediaDeviceYear - -MediaDeviceYear::MediaDeviceYear( const QString &name ) - : Meta::Year() - , m_name( name ) - , m_tracks() -{ - //nothing to do -} - -MediaDeviceYear::~MediaDeviceYear() -{ - //nothing to do -} - -QString -MediaDeviceYear::name() const -{ - return m_name; -} - -TrackList -MediaDeviceYear::tracks() -{ - return m_tracks; -} - -void -MediaDeviceYear::addTrack( MediaDeviceTrackPtr track ) -{ - m_tracks.append( TrackPtr::staticCast( track ) ); -} - -void -MediaDeviceYear::remTrack( MediaDeviceTrackPtr track ) -{ - m_tracks.removeOne( TrackPtr::staticCast( track ) ); -} diff --git a/amarok/src/core-impl/collections/mediadevicecollection/MediaDeviceMeta.h b/amarok/src/core-impl/collections/mediadevicecollection/MediaDeviceMeta.h deleted file mode 100644 index 7cd0ba0d..00000000 --- a/amarok/src/core-impl/collections/mediadevicecollection/MediaDeviceMeta.h +++ /dev/null @@ -1,312 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Alejandro Wainzinger * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef MEDIADEVICEMETA_H -#define MEDIADEVICEMETA_H - -#include "core/meta/Meta.h" -#include "core/meta/Statistics.h" -#include "core/support/Debug.h" -#include "core-impl/collections/mediadevicecollection/support/mediadevicecollection_export.h" - -#include -#include -#include - -namespace Collections { - class MediaDeviceCollection; -} - -class QAction; - -namespace Handler { class ArtworkCapability; } - -namespace Meta -{ - -class MediaDeviceTrack; -class MediaDeviceAlbum; -class MediaDeviceArtist; -class MediaDeviceGenre; -class MediaDeviceComposer; -class MediaDeviceYear; - -typedef KSharedPtr MediaDeviceTrackPtr; -typedef KSharedPtr MediaDeviceArtistPtr; -typedef KSharedPtr MediaDeviceAlbumPtr; -typedef KSharedPtr MediaDeviceGenrePtr; -typedef KSharedPtr MediaDeviceComposerPtr; -typedef KSharedPtr MediaDeviceYearPtr; - -typedef QList MediaDeviceTrackList; - -class MEDIADEVICECOLLECTION_EXPORT MediaDeviceTrack : public Meta::Track, public Statistics -{ - public: - MediaDeviceTrack( Collections::MediaDeviceCollection *collection ); - virtual ~MediaDeviceTrack(); - - virtual QString name() const; - - virtual KUrl playableUrl() const; - virtual QString uidUrl() const; - virtual QString prettyUrl() const; - virtual QString notPlayableReason() const; - - bool isEditable() const; - - virtual AlbumPtr album() const; - virtual ArtistPtr artist() const; - virtual GenrePtr genre() const; - virtual ComposerPtr composer() const; - virtual YearPtr year() const; - - virtual void setAlbum ( const QString &newAlbum ); - virtual void setAlbumArtist( const QString &newAlbumArtist ); - virtual void setArtist ( const QString &newArtist ); - virtual void setGenre ( const QString &newGenre ); - virtual void setComposer ( const QString &newComposer ); - virtual void setYear ( int newYear ); - - virtual QString title() const; - virtual void setTitle( const QString &newTitle ); - - virtual QString comment() const; - virtual void setComment ( const QString &newComment ); - - virtual qint64 length() const; - - void setFileSize( int newFileSize ); - virtual int filesize() const; - - virtual int bitrate() const; - virtual void setBitrate( int newBitrate ); - - virtual int sampleRate() const; - virtual void setSamplerate( int newSamplerate ); - - virtual qreal bpm() const; - virtual void setBpm( const qreal newBpm ); - - virtual int trackNumber() const; - virtual void setTrackNumber ( int newTrackNumber ); - - virtual int discNumber() const; - virtual void setDiscNumber ( int newDiscNumber ); - - virtual qreal replayGain( ReplayGainTag mode ) const; - /* Set the track replay gain (other types unsupported) */ - void setReplayGain( qreal newReplayGain ); - - virtual QString type() const; - virtual void prepareToPlay(); - - virtual bool inCollection() const; - virtual Collections::Collection* collection() const; - - virtual TrackEditorPtr editor(); - virtual StatisticsPtr statistics(); - - // Meta::Statistics methods - virtual double score() const; - virtual void setScore ( double newScore ); - - virtual int rating() const; - virtual void setRating ( int newRating ); - - virtual QDateTime lastPlayed() const; - void setLastPlayed( const QDateTime &newTime ); - - // firstPlayed() not available in any media device - - virtual int playCount() const; - void setPlayCount( const int newCount ); - - //MediaDeviceTrack specific methods - - // These methods are for Handler - void setAlbum( MediaDeviceAlbumPtr album ); - void setArtist( MediaDeviceArtistPtr artist ); - void setComposer( MediaDeviceComposerPtr composer ); - void setGenre( MediaDeviceGenrePtr genre ); - void setYear( MediaDeviceYearPtr year ); - - void setType( const QString & type ); - - void setLength( qint64 length ); - void setPlayableUrl( const KUrl &url) { m_playableUrl = url; } - - /** - * Notifies observers about changes to metadata, one of the observers is media - * device handler which writes the changes back to the device. - */ - void commitChanges(); - - private: - QWeakPointer m_collection; - - MediaDeviceArtistPtr m_artist; - MediaDeviceAlbumPtr m_album; - MediaDeviceGenrePtr m_genre; - MediaDeviceComposerPtr m_composer; - MediaDeviceYearPtr m_year; - - // For MediaDeviceTrack-specific use - - QImage m_image; - - QString m_comment; - QString m_name; - QString m_type; - int m_bitrate; - int m_filesize; - qint64 m_length; - int m_discNumber; - int m_samplerate; - int m_trackNumber; - int m_playCount; - QDateTime m_lastPlayed; - int m_rating; - qreal m_bpm; - qreal m_replayGain; - QString m_displayUrl; - KUrl m_playableUrl; -}; - -class MEDIADEVICECOLLECTION_EXPORT MediaDeviceArtist : public Meta::Artist -{ - public: - MediaDeviceArtist( const QString &name ); - virtual ~MediaDeviceArtist(); - - virtual QString name() const; - - virtual TrackList tracks(); - - //MediaDeviceArtist specific methods - virtual void addTrack( MediaDeviceTrackPtr track ); - virtual void remTrack( MediaDeviceTrackPtr track ); - - private: - QString m_name; - TrackList m_tracks; -}; - -class MEDIADEVICECOLLECTION_EXPORT MediaDeviceAlbum : public Meta::Album -{ - public: - MediaDeviceAlbum( Collections::MediaDeviceCollection *collection, const QString &name ); - virtual ~MediaDeviceAlbum(); - - virtual QString name() const; - - virtual bool isCompilation() const; - void setIsCompilation( bool compilation ); - - virtual bool hasAlbumArtist() const; - virtual ArtistPtr albumArtist() const; - virtual TrackList tracks(); - - virtual bool hasImage( int size = 0 ) const; - virtual QImage image( int size = 0 ) const; - virtual bool canUpdateImage() const; - virtual void setImage( const QImage &image ); - virtual void setImagePath( const QString &path ); - - virtual bool hasCapabilityInterface( Capabilities::Capability::Type type ) const; - virtual Capabilities::Capability* createCapabilityInterface( Capabilities::Capability::Type type ); - - //MediaDeviceAlbum specific methods - - void addTrack( MediaDeviceTrackPtr track ); - void remTrack( MediaDeviceTrackPtr track ); - void setAlbumArtist( MediaDeviceArtistPtr artist ); - - private: - QWeakPointer m_collection; - QWeakPointer m_artworkCapability; - - QString m_name; - TrackList m_tracks; - bool m_isCompilation; - mutable bool m_hasImagePossibility; - mutable bool m_hasImageChecked; - mutable QImage m_image; - MediaDeviceArtistPtr m_albumArtist; -}; - -class MEDIADEVICECOLLECTION_EXPORT MediaDeviceComposer : public Meta::Composer -{ - public: - MediaDeviceComposer( const QString &name ); - virtual ~MediaDeviceComposer(); - - virtual QString name() const; - - virtual TrackList tracks(); - - //MediaDeviceComposer specific methods - void addTrack( MediaDeviceTrackPtr track ); - void remTrack( MediaDeviceTrackPtr track ); - - private: - QString m_name; - TrackList m_tracks; -}; - -class MEDIADEVICECOLLECTION_EXPORT MediaDeviceGenre : public Meta::Genre -{ - public: - MediaDeviceGenre( const QString &name ); - virtual ~MediaDeviceGenre(); - - virtual QString name() const; - - virtual TrackList tracks(); - - //MediaDeviceGenre specific methods - void addTrack( MediaDeviceTrackPtr track ); - void remTrack( MediaDeviceTrackPtr track ); - private: - QString m_name; - TrackList m_tracks; -}; - - - -class MEDIADEVICECOLLECTION_EXPORT MediaDeviceYear : public Meta::Year -{ - public: - MediaDeviceYear( const QString &name ); - virtual ~MediaDeviceYear(); - - virtual QString name() const; - - virtual TrackList tracks(); - - //MediaDeviceYear specific methods - void addTrack( MediaDeviceTrackPtr track ); - void remTrack( MediaDeviceTrackPtr track ); - - private: - QString m_name; - TrackList m_tracks; -}; - -} - -#endif - diff --git a/amarok/src/core-impl/collections/mediadevicecollection/MediaDeviceTrackEditor.cpp b/amarok/src/core-impl/collections/mediadevicecollection/MediaDeviceTrackEditor.cpp deleted file mode 100644 index 88b55ce7..00000000 --- a/amarok/src/core-impl/collections/mediadevicecollection/MediaDeviceTrackEditor.cpp +++ /dev/null @@ -1,124 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2011 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "MediaDeviceTrackEditor.h" - -using namespace Meta; - -MediaDeviceTrackEditor::MediaDeviceTrackEditor( MediaDeviceTrack *track ) - : Meta::TrackEditor() - , m_inBatchUpdate( false ) - , m_track( track ) -{ -} - -void -MediaDeviceTrackEditor::setAlbum( const QString &newAlbum ) -{ - m_track->setAlbum( newAlbum ); - commitIfInNonBatchUpdate(); -} - -void -MediaDeviceTrackEditor::setAlbumArtist( const QString &newAlbumArtist ) -{ - m_track->setAlbumArtist( newAlbumArtist ); - commitIfInNonBatchUpdate(); -} - -void -MediaDeviceTrackEditor::setArtist( const QString &newArtist ) -{ - m_track->setArtist( newArtist ); - commitIfInNonBatchUpdate(); -} - -void -MediaDeviceTrackEditor::setComposer( const QString &newComposer ) -{ - m_track->setComposer( newComposer ); - commitIfInNonBatchUpdate(); -} - -void -MediaDeviceTrackEditor::setGenre( const QString &newGenre ) -{ - m_track->setGenre( newGenre ); - commitIfInNonBatchUpdate(); -} - -void -MediaDeviceTrackEditor::setYear( int newYear ) -{ - m_track->setYear( newYear ); - commitIfInNonBatchUpdate(); -} - -void -MediaDeviceTrackEditor::setBpm( const qreal newBpm ) -{ - m_track->setBpm( newBpm ); - commitIfInNonBatchUpdate(); -} - -void -MediaDeviceTrackEditor::setTitle( const QString &newTitle ) -{ - m_track->setTitle( newTitle ); - commitIfInNonBatchUpdate(); -} - -void -MediaDeviceTrackEditor::setComment( const QString &newComment ) -{ - m_track->setComment( newComment ); - commitIfInNonBatchUpdate(); -} - -void -MediaDeviceTrackEditor::setTrackNumber( int newTrackNumber ) -{ - m_track->setTrackNumber( newTrackNumber ); - commitIfInNonBatchUpdate(); -} - -void -MediaDeviceTrackEditor::setDiscNumber( int newDiscNumber ) -{ - m_track->setDiscNumber( newDiscNumber ); - commitIfInNonBatchUpdate(); -} - -void -MediaDeviceTrackEditor::beginUpdate() -{ - m_inBatchUpdate = true; -} - -void -MediaDeviceTrackEditor::endUpdate() -{ - m_inBatchUpdate = false; - m_track->commitChanges(); -} - -void -MediaDeviceTrackEditor::commitIfInNonBatchUpdate() -{ - if( m_inBatchUpdate ) - return; - m_track->commitChanges(); -} diff --git a/amarok/src/core-impl/collections/mediadevicecollection/MediaDeviceTrackEditor.h b/amarok/src/core-impl/collections/mediadevicecollection/MediaDeviceTrackEditor.h deleted file mode 100644 index 77735715..00000000 --- a/amarok/src/core-impl/collections/mediadevicecollection/MediaDeviceTrackEditor.h +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2011 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef MEDIADEVICE_EDIT_CAPABILITY_H -#define MEDIADEVICE_EDIT_CAPABILITY_H - -#include "core/meta/TrackEditor.h" -#include "MediaDeviceMeta.h" - -namespace Meta -{ -class MediaDeviceTrackEditor : public Meta::TrackEditor -{ - public: - MediaDeviceTrackEditor( MediaDeviceTrack *track ); - - virtual void setAlbum( const QString &newAlbum ); - virtual void setAlbumArtist( const QString &newAlbumArtist ); - virtual void setArtist( const QString &newArtist ); - virtual void setComposer( const QString &newComposer ); - virtual void setGenre( const QString &newGenre ); - virtual void setYear( int newYear ); - virtual void setBpm( const qreal newBpm ); - virtual void setTitle( const QString &newTitle ); - virtual void setComment( const QString &newComment ); - virtual void setTrackNumber( int newTrackNumber ); - virtual void setDiscNumber( int newDiscNumber ); - - virtual void beginUpdate(); - virtual void endUpdate(); - - private: - /** - * Tells the underlying track to write back changes if and only if current update - * is not a part of a larger batch (initiated by beginUpdate()) - */ - void commitIfInNonBatchUpdate(); - - bool m_inBatchUpdate; - MediaDeviceTrackPtr m_track; -}; - -} - -#endif diff --git a/amarok/src/core-impl/collections/mediadevicecollection/amarok_collection-mediadevicecollection.desktop b/amarok/src/core-impl/collections/mediadevicecollection/amarok_collection-mediadevicecollection.desktop deleted file mode 100644 index 40183449..00000000 --- a/amarok/src/core-impl/collections/mediadevicecollection/amarok_collection-mediadevicecollection.desktop +++ /dev/null @@ -1,132 +0,0 @@ -[Desktop Entry] -Type=Service -Icon=multimedia-player -Name=Media Device Collection -Name[be]=Калекцыя медыяпрылады -Name[bg]=Колекция на медийните устройства -Name[bs]=Zbirka multimediјalnog uređaјa -Name[ca]=Col·lecció de dispositius de suports -Name[ca@valencia]=Col·lecció de dispositius de suports -Name[cs]=Sbírka zařízení médií -Name[csb]=Kòlekcëjô ùrządzenia medium -Name[da]=Medieenhedssamling -Name[de]=Mediengerät-Sammlung -Name[el]=Συλλογή συσκευών πολυμέσων -Name[en_GB]=Media Device Collection -Name[es]=Colección de dispositivo de medios -Name[et]=Meediaseadme kogu -Name[eu]=Multimedia gailuko bilduma -Name[fi]=Mediasoitinkokoelma -Name[fr]=Collection de périphériques de média -Name[ga]=Bailiúchán Gléis Meán -Name[gl]=Colección de dispositivos de medios -Name[he]=אוסף התקן מדיה -Name[hne]=मीडिया उपकरन संग्रह -Name[hu]=Médiaeszköz-gyűjtemény -Name[id]=Koleksi Perangkat Media -Name[is]=Ferðatækjasafn -Name[it]=Collezione dispositivo multimediale -Name[ja]=メディアデバイスコレクション -Name[km]=សម្រាំង​ឧបករណ៍​មេឌៀ -Name[ko]=미디어 장치 모음집 -Name[ku]=Berhevoka Cîhazên Medya ji bo Amarok -Name[lt]=Muzikos įrenginio fonoteka -Name[lv]=Multivides ierīces kolekcija -Name[nb]=Media Device samling -Name[nds]=Medienreedschap-Sammeln -Name[nl]=Media-apparaatcollectie -Name[nn]=Medieeiningssamling -Name[pa]=ਮੀਡਿਆ ਜੰਤਰ ਭੰਡਾਰ -Name[pl]=Zbiór na urządzeniu multimedialnym -Name[pt]=Colecção do Dispositivo Multimédia -Name[pt_BR]=Coleção de dispositivo de mídia -Name[ro]=Colecție dispozitiv media -Name[ru]=Коллекция переносного устройства -Name[sk]=Kolekcia mediálnych zariadení -Name[sl]=Zbirka predstavnostne naprave -Name[sr]=Збирка мултимедијалног уређаја -Name[sr@ijekavian]=Збирка мултимедијалног уређаја -Name[sr@ijekavianlatin]=Zbirka multimedijalnog uređaja -Name[sr@latin]=Zbirka multimedijalnog uređaja -Name[sv]=Mediaenhetssamling -Name[th]=คลังสื่อของอุปกรณ์เล่นสื่อ -Name[tr]=Ortam Aygıtı Koleksiyonu -Name[uk]=Збірка на носіях інформації -Name[wa]=Ramexhnêye d' éndjin media -Name[x-test]=xxMedia Device Collectionxx -Name[zh_CN]=媒体设备收藏 -Name[zh_TW]=媒體裝置收藏 -Comment=Media Device collection plugin for Amarok -Comment[be]=Утулка калекцыі медыяпрылады для Amarok -Comment[bg]=Приставка за колекцията на медийните устройства (Amarok) -Comment[bs]=Priključak zbirke multimedijalnog uređaja za Amarok -Comment[ca]=Connector de col·leccions de dispositius de suports per a l'Amarok -Comment[ca@valencia]=Connector de col·leccions de dispositius de suports per a l'Amarok -Comment[cs]=Modul sbírky zařízení médií pro AmaroK -Comment[csb]=Wtëkôcz kòlekcëji ùrządzenia medium dlô Amaroka -Comment[da]=Plugin til medieenhedssamling til Amarok -Comment[de]=Mediengerät-Sammlungsmodul für Amarok -Comment[el]=Πρόσθετο συλλογής συσκευών πολυμέσων για το AmaroK -Comment[en_GB]=Media Device collection plugin for Amarok -Comment[es]=Complemento de la colección del dispositivo de medios para Amarok -Comment[et]=Amaroki meediaseadme kogu plugin -Comment[eu]=Multimedia gailuko bildumen plugina Amarok-entzako -Comment[fi]=Amarokin mediasoitinkokoelmaliitännäinen -Comment[fr]=Module externe de collection de périphériques de média pour Amarok -Comment[ga]=Breiseán bailiúchán Gléis Meán le haghaidh Amarok -Comment[gl]=Extensión de colección de dispositivos de medios para Amarok -Comment[he]=תוסף אוסף התקן מדיה ל־Amarok -Comment[hne]=अमाराक बर मीडिया उपकरन संग्रह प्लगइन -Comment[hu]=Médiaeszköz-gyűjteményt megvalósító bővítőmodul az Amarokhoz -Comment[id]=Plugin koleksi Media Perangkat untuk Amarok -Comment[is]=Ferðatækjasafníforrit fyrir Amarok -Comment[it]=Estensione della collezione dispositivo multimediale di Amarok -Comment[ja]=Amarok のためのメディアデバイスコレクションプラグイン -Comment[km]=កម្មវិធី​ជំនួយ​សម្រាំង​ឧបករណ៍​មេឌៀ​សម្រាប់​ Amarok -Comment[ko]=Amarok의 미디어 장치 모음집 플러그인 -Comment[ku]=Peveka Berhevoka Cîhazên Medya ji bo Amarok -Comment[lt]=Muzikos įrenginio fonotekos Amarok papildinys -Comment[lv]=Multivides ierīces kolekcijas Amarok spraudnis -Comment[nb]=Media Device-samling – programtillegg for Amarok -Comment[nds]=Medienreedschap-Sammelnmoduul för Amarok -Comment[nl]=Media-apparaatcollectieplugin voor Amarok -Comment[nn]=Amarok-samlingstillegg for medieeining -Comment[pa]=ਅਮਰੋਕ ਲਈ ਮੀਡਿਆ ਜੰਤਰ ਭੰਡਾਰ ਪਲੱਗਇਨ -Comment[pl]=Wtyczka kolekcji mediów dla Amaroka -Comment[pt]=Um 'plugin' de colecção de dispositivos multimédia para o Amarok -Comment[pt_BR]=Plugin de coleção de dispositivo de mídia para o Amarok -Comment[ro]=Modul de colecție dispozitiv media pentru Amarok -Comment[ru]=Модуль коллекции переносного устройства для Amarok -Comment[sk]=Modul kolekcia mediálnych zariadení pre Amarok -Comment[sl]=Vstavek za zbirko predstavnostne naprave za Amarok -Comment[sr]=Прикључак збирке мултимедијалног уређаја за Амарок -Comment[sr@ijekavian]=Прикључак збирке мултимедијалног уређаја за Амарок -Comment[sr@ijekavianlatin]=Priključak zbirke multimedijalnog uređaja za Amarok -Comment[sr@latin]=Priključak zbirke multimedijalnog uređaja za Amarok -Comment[sv]=Insticksprogram med mediaenhetssamling för Amarok -Comment[th]=ส่วนเสริมของแอมอะร็อก สำหรับจัดการคลังสื่อของอุปกรณ์เล่นสื่อ -Comment[tr]=Amarok için Ortam Aygıtı koleksiyon eklentisi -Comment[uk]=Додаток збірки на носіях інформації для Amarok -Comment[wa]=Tchôke-divins di ramexhnêye d' éndjin media po Amarok -Comment[x-test]=xxMedia Device collection plugin for Amarokxx -Comment[zh_CN]=Amarok 的媒体设备收藏插件 -Comment[zh_TW]=Amarok 的媒體裝置收藏外掛程式 - -ServiceTypes=Amarok/Plugin - -X-KDE-Amarok-authors=Alejandro Wainzinger -X-KDE-Amarok-email=aikawarazuni@gmail.com -X-KDE-Amarok-framework-version=72 -X-KDE-Amarok-name=mediadevice-collection -X-KDE-Amarok-plugintype=collection -X-KDE-Amarok-rank=100 -X-KDE-Amarok-version=1 - -X-KDE-PluginInfo-Author=Alejandro Wainzinger -X-KDE-PluginInfo-Email=aikawarazuni@gmail.com -X-KDE-PluginInfo-Version=1.0 -X-KDE-PluginInfo-Category=Collection -X-KDE-PluginInfo-License=GPL -X-KDE-PluginInfo-EnabledByDefault=true -X-KDE-PluginInfo-Name=amarok_collection-mediadevicecollection -X-KDE-Library=amarok_collection-mediadevicecollection diff --git a/amarok/src/core-impl/collections/mediadevicecollection/handler/MediaDeviceHandler.cpp b/amarok/src/core-impl/collections/mediadevicecollection/handler/MediaDeviceHandler.cpp deleted file mode 100644 index 23f4704f..00000000 --- a/amarok/src/core-impl/collections/mediadevicecollection/handler/MediaDeviceHandler.cpp +++ /dev/null @@ -1,1246 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Alejandro Wainzinger * - * * - * This program 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 2 of the License, or (at your option) version 3 or * - * any later version accepted by the membership of KDE e.V. (or its successor approved * - * by the membership of KDE e.V.), which shall act as a proxy defined in Section 14 of * - * version 3 of the license. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "MediaDeviceHandler.h" - -#include "core/interfaces/Logger.h" -#include "core/support/Components.h" -#include "core-impl/collections/mediadevicecollection/MediaDeviceCollection.h" -#include "core-impl/collections/mediadevicecollection/handler/MediaDeviceHandlerCapability.h" -#include "core-impl/collections/support/ArtistHelper.h" -#include "playlistmanager/PlaylistManager.h" - -#include -#include -#include - -using namespace Meta; - -bool -MetaHandlerCapability::hasCapabilityInterface( Handler::Capability::Type type ) const -{ - Q_UNUSED( type ); - return false; -} - -Handler::Capability* -MetaHandlerCapability::createCapabilityInterface( Handler::Capability::Type type ) -{ - Q_UNUSED( type ); - return 0; -} - -MediaDeviceHandler::MediaDeviceHandler( QObject *parent ) - : QObject( parent ) - , m_memColl( qobject_cast(parent) ) - , m_provider( 0 ) - , m_isCopying( false ) - , m_isDeleting( false ) - , m_pc( 0 ) - , m_rc( 0 ) - , m_wc( 0 ) -{ - DEBUG_BLOCK - - connect( m_memColl, SIGNAL(deletingCollection()), - this, SLOT(slotDeletingHandler()), Qt::QueuedConnection ); - - connect( this, SIGNAL(databaseWritten(bool)), - this, SLOT(slotDatabaseWritten(bool)), Qt::QueuedConnection ); -} - -MediaDeviceHandler::~MediaDeviceHandler() -{ - DEBUG_BLOCK - delete m_provider; -} - -void -MediaDeviceHandler::slotDeletingHandler() -{ - DEBUG_BLOCK - if( m_provider ) - The::playlistManager()->removeProvider( m_provider ); - m_memColl = NULL; -} - -void -MediaDeviceHandler::getBasicMediaDeviceTrackInfo( const Meta::MediaDeviceTrackPtr &srcTrack, Meta::MediaDeviceTrackPtr destTrack ) -{ - /* 1-liner info retrieval */ - destTrack->setTitle( m_rc->libGetTitle( srcTrack ) ); - destTrack->setLength( m_rc->libGetLength( srcTrack ) ); - destTrack->setTrackNumber( m_rc->libGetTrackNumber( srcTrack ) ); - destTrack->setComment( m_rc->libGetComment( srcTrack ) ); - destTrack->setDiscNumber( m_rc->libGetDiscNumber( srcTrack ) ); - destTrack->setBitrate( m_rc->libGetBitrate( srcTrack ) ); - destTrack->setSamplerate( m_rc->libGetSamplerate( srcTrack ) ); - destTrack->setBpm( m_rc->libGetBpm( srcTrack ) ); - destTrack->setFileSize( m_rc->libGetFileSize( srcTrack ) ); - destTrack->setPlayCount( m_rc->libGetPlayCount( srcTrack ) ); - destTrack->setLastPlayed( m_rc->libGetLastPlayed( srcTrack ) ); - destTrack->setRating( m_rc->libGetRating( srcTrack ) ); - destTrack->setReplayGain( m_rc->libGetReplayGain( srcTrack ) ); - - destTrack->setPlayableUrl( m_rc->libGetPlayableUrl( srcTrack ) ); - - destTrack->setType( m_rc->libGetType( srcTrack ) ); -} - -void -MediaDeviceHandler::setBasicMediaDeviceTrackInfo( const Meta::TrackPtr& srcTrack, MediaDeviceTrackPtr destTrack ) -{ - DEBUG_BLOCK - if( !setupWriteCapability() ) - return; - - m_wc->libSetTitle( destTrack, srcTrack->name() ); - - QString albumArtist; - bool isCompilation = false; - if ( srcTrack->album() ) - { - AlbumPtr album = srcTrack->album(); - - m_wc->libSetAlbum( destTrack, album->name() ); - isCompilation = album->isCompilation(); - m_wc->libSetIsCompilation( destTrack, isCompilation ); - if( album->hasAlbumArtist() ) - albumArtist = album->albumArtist()->name(); - - if( album->hasImage() ) - m_wc->libSetCoverArt( destTrack, album->image() ); - } - - QString trackArtist; - if ( srcTrack->artist() ) - { - trackArtist = srcTrack->artist()->name(); - m_wc->libSetArtist( destTrack, trackArtist ); - } - - QString composer; - if ( srcTrack->composer() ) - { - composer = srcTrack->composer()->name(); - m_wc->libSetComposer( destTrack, composer ); - } - - QString genre; - if ( srcTrack->genre() ) - { - genre = srcTrack->genre()->name(); - m_wc->libSetGenre( destTrack, genre ); - } - - if( isCompilation && albumArtist.isEmpty() ) - // iPod doesn't handle empy album artist well for compilation albums (splits these albums) - albumArtist = i18n( "Various Artists" ); - else - albumArtist = ArtistHelper::bestGuessAlbumArtist( albumArtist, trackArtist, genre, composer ); - m_wc->libSetAlbumArtist( destTrack, albumArtist ); - - if ( srcTrack->year() ) - m_wc->libSetYear( destTrack, srcTrack->year()->name() ); - m_wc->libSetLength( destTrack, srcTrack->length() ); - m_wc->libSetTrackNumber( destTrack, srcTrack->trackNumber() ); - m_wc->libSetComment( destTrack, srcTrack->comment() ); - m_wc->libSetDiscNumber( destTrack, srcTrack->discNumber() ); - m_wc->libSetBitrate( destTrack, srcTrack->bitrate() ); - m_wc->libSetSamplerate( destTrack, srcTrack->sampleRate() ); - m_wc->libSetBpm( destTrack, srcTrack->bpm() ); - m_wc->libSetFileSize( destTrack, srcTrack->filesize() ); - m_wc->libSetPlayCount( destTrack, srcTrack->statistics()->playCount() ); - m_wc->libSetLastPlayed( destTrack, srcTrack->statistics()->lastPlayed() ); - m_wc->libSetRating( destTrack, srcTrack->statistics()->rating() ); - // MediaDeviceTrack stores only track gain: - m_wc->libSetReplayGain( destTrack, srcTrack->replayGain( Meta::ReplayGain_Track_Gain ) ); - m_wc->libSetType( destTrack, srcTrack->type() ); - //libSetPlayableUrl( destTrack, srcTrack ); -} - -void -MediaDeviceHandler::addMediaDeviceTrackToCollection( Meta::MediaDeviceTrackPtr& track ) -{ - if( !setupReadCapability() ) - return; - - TrackMap trackMap = m_memColl->memoryCollection()->trackMap(); - ArtistMap artistMap = m_memColl->memoryCollection()->artistMap(); - AlbumMap albumMap = m_memColl->memoryCollection()->albumMap(); - GenreMap genreMap = m_memColl->memoryCollection()->genreMap(); - ComposerMap composerMap = m_memColl->memoryCollection()->composerMap(); - YearMap yearMap = m_memColl->memoryCollection()->yearMap(); - - /* 1-liner info retrieval */ - - //Meta::TrackPtr srcTrack = Meta::TrackPtr::staticCast( track ); - - //getBasicMediaDeviceTrackInfo( srcTrack, track ); - - /* map-related info retrieval */ - // NB: setupArtistMap _MUST_ be called before setupAlbumMap - setupArtistMap( track, artistMap ); - setupAlbumMap( track, albumMap, artistMap ); - setupGenreMap( track, genreMap ); - setupComposerMap( track, composerMap ); - setupYearMap( track, yearMap ); - - /* trackmap also soon to be subordinated */ - trackMap.insert( track->uidUrl(), TrackPtr::staticCast( track ) ); - - m_titlemap.insert( track->name(), TrackPtr::staticCast( track ) ); - - // Finally, assign the created maps to the collection - m_memColl->memoryCollection()->acquireWriteLock(); - m_memColl->memoryCollection()->setTrackMap( trackMap ); - m_memColl->memoryCollection()->setArtistMap( artistMap ); - m_memColl->memoryCollection()->setAlbumMap( albumMap ); - m_memColl->memoryCollection()->setGenreMap( genreMap ); - m_memColl->memoryCollection()->setComposerMap( composerMap ); - m_memColl->memoryCollection()->setYearMap( yearMap ); - m_memColl->memoryCollection()->releaseLock(); -} - -void -MediaDeviceHandler::removeMediaDeviceTrackFromCollection( Meta::MediaDeviceTrackPtr &track ) -{ - TrackMap trackMap = m_memColl->memoryCollection()->trackMap(); - ArtistMap artistMap = m_memColl->memoryCollection()->artistMap(); - AlbumMap albumMap = m_memColl->memoryCollection()->albumMap(); - GenreMap genreMap = m_memColl->memoryCollection()->genreMap(); - ComposerMap composerMap = m_memColl->memoryCollection()->composerMap(); - YearMap yearMap = m_memColl->memoryCollection()->yearMap(); - - Meta::MediaDeviceArtistPtr artist = Meta::MediaDeviceArtistPtr::dynamicCast( track->artist() ); - Meta::MediaDeviceAlbumPtr album = Meta::MediaDeviceAlbumPtr::dynamicCast( track->album() ); - Meta::MediaDeviceGenrePtr genre = Meta::MediaDeviceGenrePtr::dynamicCast( track->genre() ); - Meta::MediaDeviceComposerPtr composer = Meta::MediaDeviceComposerPtr::dynamicCast( track->composer() ); - Meta::MediaDeviceYearPtr year = Meta::MediaDeviceYearPtr::dynamicCast( track->year() ); - - // remove track from metadata's tracklists - artist->remTrack( track ); - album->remTrack( track ); - genre->remTrack( track ); - composer->remTrack( track ); - year->remTrack( track ); - - // if empty, get rid of metadata in general - if( artist->tracks().isEmpty() ) - { - artistMap.remove( artist->name() ); - m_memColl->memoryCollection()->acquireWriteLock(); - m_memColl->memoryCollection()->setArtistMap( artistMap ); - m_memColl->memoryCollection()->releaseLock(); - } - if( album->tracks().isEmpty() ) - { - albumMap.remove( AlbumPtr::staticCast( album ) ); - m_memColl->memoryCollection()->acquireWriteLock(); - m_memColl->memoryCollection()->setAlbumMap( albumMap ); - m_memColl->memoryCollection()->releaseLock(); - } - if( genre->tracks().isEmpty() ) - { - genreMap.remove( genre->name() ); - m_memColl->memoryCollection()->acquireWriteLock(); - m_memColl->memoryCollection()->setGenreMap( genreMap ); - m_memColl->memoryCollection()->releaseLock(); - } - if( composer->tracks().isEmpty() ) - { - composerMap.remove( composer->name() ); - m_memColl->memoryCollection()->acquireWriteLock(); - m_memColl->memoryCollection()->setComposerMap( composerMap ); - m_memColl->memoryCollection()->releaseLock(); - } - if( year->tracks().isEmpty() ) - { - yearMap.remove( year->year() ); - m_memColl->memoryCollection()->acquireWriteLock(); - m_memColl->memoryCollection()->setYearMap( yearMap ); - m_memColl->memoryCollection()->releaseLock(); - } - - // remove from trackmap - trackMap.remove( track->uidUrl() ); - - m_titlemap.remove( track->name(), TrackPtr::staticCast( track ) ); - - // Finally, assign the created maps to the collection - m_memColl->memoryCollection()->acquireWriteLock(); - m_memColl->memoryCollection()->setTrackMap( trackMap ); - m_memColl->memoryCollection()->setArtistMap( artistMap ); - m_memColl->memoryCollection()->setAlbumMap( albumMap ); - m_memColl->memoryCollection()->setGenreMap( genreMap ); - m_memColl->memoryCollection()->setComposerMap( composerMap ); - m_memColl->memoryCollection()->setYearMap( yearMap ); - m_memColl->memoryCollection()->releaseLock(); -} - -void -MediaDeviceHandler::getCopyableUrls(const Meta::TrackList &tracks) -{ - QMap urls; - foreach( Meta::TrackPtr track, tracks ) - { - if( track->isPlayable() ) - urls.insert( track, track->playableUrl() ); - } - - emit gotCopyableUrls( urls ); -} - -void -MediaDeviceHandler::copyTrackListToDevice(const Meta::TrackList tracklist) -{ - DEBUG_BLOCK - const QString copyErrorCaption = i18n( "Copying Tracks Failed" ); - - if ( m_isCopying ) - { - KMessageBox::error( 0, i18n( "Tracks not copied: the device is already being copied to" ), copyErrorCaption ); - return; - } - - setupReadCapability(); - if( !setupWriteCapability() ) - return; - - m_isCopying = true; - - bool isDupe = false; - bool hasError = false; - QString format; - TrackMap trackMap = m_memColl->memoryCollection()->trackMap(); - - Meta::TrackList tempTrackList; - - m_copyFailed = false; - - m_tracksFailed.clear(); - - // Clear Transfer queue - m_tracksToCopy.clear(); - - // Check for same tags, don't copy if same tags - // Also check for compatible format - foreach( Meta::TrackPtr track, tracklist ) - { - // Check for compatible formats - format = track->type(); - - if( !m_wc->supportedFormats().contains( format ) ) - { - const QString error = i18n("Unsupported format: %1", format); - m_tracksFailed.insert( track, error ); - hasError = true; - continue; - } - - tempTrackList = m_titlemap.values( track->name() ); - - /* If no song with same title, already not a dupe */ - - if( tempTrackList.isEmpty() ) - { - debug() << "No tracks with same title, track not a dupe"; - m_tracksToCopy.append( track ); - continue; - } - - /* Songs with same title present, check other tags */ - isDupe = false; - - foreach( Meta::TrackPtr tempTrack, tempTrackList ) - { - if( ( tempTrack->artist()->name() != track->artist()->name() ) - || ( tempTrack->album()->name() != track->album()->name() ) - || ( tempTrack->genre()->name() != track->genre()->name() ) - || ( tempTrack->composer()->name() != track->composer()->name() ) - || ( tempTrack->year()->name() != track->year()->name() ) ) - { - continue; - } - - // Track is already on there, break - isDupe = true; - hasError = true; - break; - } - - if( !isDupe ) - m_tracksToCopy.append( track ); - else - { - debug() << "Track " << track->name() << " is a dupe!"; - - const QString error = i18n("Already on device"); - m_tracksFailed.insert( track, error ); - } - } - - // NOTE: see comment at top of copyTrackListToDevice - if( hasError ) - m_copyFailed = true; - - /* List ready, begin copying */ - - // Do not bother copying 0 tracks - // This could happen if all tracks to copy are dupes - - if( m_tracksToCopy.size() == 0 ) - { - KMessageBox::error( 0, i18n( "Tracks not copied: the device already has these tracks" ), copyErrorCaption ); - m_isCopying = false; - emit copyTracksDone( false ); - return; - } - - // Check for available space, in bytes, after the copy - - int transfersize = 0; - - foreach( Meta::TrackPtr track, m_tracksToCopy ) - transfersize += track->filesize(); - - // NOTE: if the device will not have more than 5 MB to spare, abort the copy - // This is important because on some devices if there is insufficient space to write the database, it will appear as - // though all music has been wiped off the device - since neither the device nor amarok will be able to read the - // (corrupted) database. - if( !( (freeSpace() - transfersize) > 1024*1024*5 ) ) - { - debug() << "Free space: " << freeSpace(); - debug() << "Space would've been after copy: " << (freeSpace() - transfersize); - KMessageBox::error( 0, i18n( "Tracks not copied: the device has insufficient space" ), copyErrorCaption ); - m_isCopying = false; - emit copyTracksDone( false ); - return; - } - debug() << "Copying " << m_tracksToCopy.size() << " tracks"; - - // Set up progress bar - - Amarok::Components::logger()->newProgressOperation( this, - i18n( "Transferring Tracks to Device" ), m_tracksToCopy.size() ); - - // prepare to copy - m_wc->prepareToCopy(); - - m_numTracksToCopy = m_tracksToCopy.count(); - m_tracksCopying.clear(); - m_trackSrcDst.clear(); - - // begin copying tracks to device - - if( !m_copyingthreadsafe ) - copyNextTrackToDevice(); - else - enqueueNextCopyThread(); -} - -void -MediaDeviceHandler::copyNextTrackToDevice() -{ - DEBUG_BLOCK - Meta::TrackPtr track; - - debug() << "Tracks left to copy after this one is now done: " << m_numTracksToCopy; - - if ( !m_tracksToCopy.isEmpty() ) - { - // Pop the track off the front of the list - track = m_tracksToCopy.takeFirst(); - - // Copy the track and check result - if ( !privateCopyTrackToDevice( track ) ) - slotCopyTrackFailed( track ); - } - else - { - if ( m_numTracksToCopy > 0 ) - debug() << "Oops. \"Tracks to copy\" counter is not zero, but copy list is empty. Something missed?"; - - if ( m_copyFailed ) - { - Amarok::Components::logger()->shortMessage( - i18np( "%1 track failed to copy to the device", - "%1 tracks failed to copy to the device", m_tracksFailed.size() ) ); - } - - // clear maps/hashes used - m_tracksCopying.clear(); - m_trackSrcDst.clear(); - m_tracksFailed.clear(); - m_tracksToCopy.clear(); - - // copying done - - m_isCopying = false; - emit copyTracksDone( true ); - } -} - - -bool -MediaDeviceHandler::privateCopyTrackToDevice( const Meta::TrackPtr &track ) -{ - DEBUG_BLOCK - - // Create new destTrack that will go into the device collection, based on source track - Meta::MediaDeviceTrackPtr destTrack ( new Meta::MediaDeviceTrack( m_memColl ) ); - - // find path to copy to - m_wc->findPathToCopy( track, destTrack ); - - // Create a track struct, associate it to destTrack - m_wc->libCreateTrack( destTrack ); - - // Fill the track struct of the destTrack with info from the track parameter as source - setBasicMediaDeviceTrackInfo( track, destTrack ); - - // set up the play url - m_wc->libSetPlayableUrl( destTrack, track ); - - getBasicMediaDeviceTrackInfo( destTrack, destTrack ); - - m_trackSrcDst[ track ] = destTrack; // associate source with destination, for finalizing copy - - // Copy the file to the device - return m_wc->libCopyTrack( track, destTrack ); -} - -/// @param track is the source track from which we are copying -void -MediaDeviceHandler::slotFinalizeTrackCopy( const Meta::TrackPtr & track ) -{ - DEBUG_BLOCK - //m_tracksCopying.removeOne( track ); - - Meta::MediaDeviceTrackPtr destTrack = m_trackSrcDst[ track ]; - - // Add the track struct into the database, if the library needs to - m_wc->addTrackInDB( destTrack ); - - // Inform subclass that a track has been added to the db - m_wc->setDatabaseChanged(); - - // Add the new Meta::MediaDeviceTrackPtr into the device collection - - // add track to collection - addMediaDeviceTrackToCollection( destTrack ); - - emit incrementProgress(); - m_numTracksToCopy--; -} - -void -MediaDeviceHandler::slotCopyTrackFailed( const Meta::TrackPtr & track ) -{ - DEBUG_BLOCK - emit incrementProgress(); - - m_numTracksToCopy--; - - QString error = i18n( "The track failed to copy to the device" ); - - m_tracksFailed.insert( track, error ); -} - -void -MediaDeviceHandler::removeTrackListFromDevice( const Meta::TrackList &tracks ) -{ - DEBUG_BLOCK - - QString removeError = i18np( "Track not deleted:", "Tracks not deleted:", tracks.size() ); - QString removeErrorCaption = i18np( "Deleting Track Failed", "Deleting Tracks Failed", tracks.size() ); - - if ( m_isDeleting ) - { - KMessageBox::error( 0, i18n( "%1 tracks are already being deleted from the device.", removeError ), removeErrorCaption ); - return; - } - - if( !setupWriteCapability() ) - return; - - m_isDeleting = true; - - // Init the list of tracks to be deleted - m_tracksToDelete = tracks; - - // Set up statusbar for deletion operation - Amarok::Components::logger()->newProgressOperation( this, - i18np( "Removing Track from Device", "Removing Tracks from Device", tracks.size() ), - tracks.size() ); - - m_wc->prepareToDelete(); - - m_numTracksToRemove = m_tracksToDelete.count(); - - removeNextTrackFromDevice(); -} - -void -MediaDeviceHandler::removeNextTrackFromDevice() -{ - DEBUG_BLOCK - Meta::TrackPtr track; - // If there are more tracks to remove, remove the next one - if( !m_tracksToDelete.isEmpty() ) - { - // Pop the track off the front of the list - - track = m_tracksToDelete.takeFirst(); - - // Remove the track - - privateRemoveTrackFromDevice( track ); - } -} - -void -MediaDeviceHandler::privateRemoveTrackFromDevice( const Meta::TrackPtr &track ) -{ - DEBUG_BLOCK - - Meta::MediaDeviceTrackPtr devicetrack = Meta::MediaDeviceTrackPtr::staticCast( track ); - - // Remove the physical file from the device, perhaps using a libcall, or KIO - m_wc->libDeleteTrackFile( devicetrack ); -} - -void -MediaDeviceHandler::slotFinalizeTrackRemove( const Meta::TrackPtr & track ) -{ - DEBUG_BLOCK - Meta::MediaDeviceTrackPtr devicetrack = Meta::MediaDeviceTrackPtr::staticCast( track ); - - // Remove the track struct from the db, references to it - m_wc->removeTrackFromDB( devicetrack ); - - // delete the struct associated with this track - m_wc->libDeleteTrack( devicetrack ); - - // Inform subclass that a track has been removed from - m_wc->setDatabaseChanged(); - - // remove from memory collection - removeMediaDeviceTrackFromCollection( devicetrack ); - - emit incrementProgress(); - - m_numTracksToRemove--; - - if( m_numTracksToRemove == 0 ) - { - /* - if( m_tracksFailed.size() > 0 ) - { - Amarok::Components::logger()->shortMessage( - i18n( "%1 tracks failed to copy to the device", m_tracksFailed.size() ) ); - } - */ - debug() << "Done removing tracks"; - m_isDeleting = false; - emit removeTracksDone(); - } -} - -void -MediaDeviceHandler::slotDatabaseWritten( bool success ) -{ - DEBUG_BLOCK - Q_UNUSED( success ) - - emit endProgressOperation( this ); - - m_memColl->collectionUpdated(); -} - - -void -MediaDeviceHandler::setupArtistMap( Meta::MediaDeviceTrackPtr track, ArtistMap &artistMap ) -{ - const QString artist( m_rc->libGetArtist( track ) ); - MediaDeviceArtistPtr artistPtr; - - if( artistMap.contains( artist ) ) - artistPtr = MediaDeviceArtistPtr::staticCast( artistMap.value( artist ) ); - else - { - artistPtr = MediaDeviceArtistPtr( new MediaDeviceArtist( artist ) ); - artistMap.insert( artist, ArtistPtr::staticCast( artistPtr ) ); - } - - artistPtr->addTrack( track ); - track->setArtist( artistPtr ); -} - -void -MediaDeviceHandler::setupAlbumMap( Meta::MediaDeviceTrackPtr track, AlbumMap& albumMap, ArtistMap &artistMap ) -{ - const QString album( m_rc->libGetAlbum( track ) ); - QString albumArtist( m_rc->libGetAlbumArtist( track ) ); - if( albumArtist.compare( "Various Artists", Qt::CaseInsensitive ) == 0 || - albumArtist.compare( i18n( "Various Artists" ), Qt::CaseInsensitive ) == 0 ) - { - albumArtist.clear(); - } - MediaDeviceAlbumPtr albumPtr; - - if ( albumMap.contains( album, albumArtist ) ) - albumPtr = MediaDeviceAlbumPtr::staticCast( albumMap.value( album, albumArtist ) ); - else - { - MediaDeviceArtistPtr albumArtistPtr; - if( artistMap.contains( albumArtist ) ) - albumArtistPtr = MediaDeviceArtistPtr::staticCast( artistMap.value( albumArtist ) ); - else if( !albumArtist.isEmpty() ) - { - albumArtistPtr = MediaDeviceArtistPtr( new MediaDeviceArtist( albumArtist ) ); - artistMap.insert( albumArtist, ArtistPtr::staticCast( albumArtistPtr ) ); - } - - albumPtr = MediaDeviceAlbumPtr( new MediaDeviceAlbum( m_memColl, album ) ); - albumPtr->setAlbumArtist( albumArtistPtr ); // needs to be before albumMap.insert() - albumMap.insert( AlbumPtr::staticCast( albumPtr ) ); - } - - albumPtr->addTrack( track ); - track->setAlbum( albumPtr ); - - bool isCompilation = albumPtr->isCompilation(); - /* if at least one track from album identifies itself as a part of compilation, mark - * whole album as such: (we should be deterministic wrt track adding order) */ - isCompilation |= m_rc->libIsCompilation( track ); - albumPtr->setIsCompilation( isCompilation ); - - if( albumArtist.isEmpty() ) - { - // set compilation flag, otherwise the album would be invisible in collection - // browser if "Album Artist / Album" view is selected. - albumPtr->setIsCompilation( true ); - } -} - -void -MediaDeviceHandler::setupGenreMap( Meta::MediaDeviceTrackPtr track, GenreMap& genreMap ) -{ - const QString genre = m_rc->libGetGenre( track ); - MediaDeviceGenrePtr genrePtr; - - if ( genreMap.contains( genre ) ) - genrePtr = MediaDeviceGenrePtr::staticCast( genreMap.value( genre ) ); - - else - { - genrePtr = MediaDeviceGenrePtr( new MediaDeviceGenre( genre ) ); - genreMap.insert( genre, GenrePtr::staticCast( genrePtr ) ); - } - - genrePtr->addTrack( track ); - track->setGenre( genrePtr ); -} - -void -MediaDeviceHandler::setupComposerMap( Meta::MediaDeviceTrackPtr track, ComposerMap& composerMap ) -{ - QString composer ( m_rc->libGetComposer( track ) ); - MediaDeviceComposerPtr composerPtr; - - if ( composerMap.contains( composer ) ) - composerPtr = MediaDeviceComposerPtr::staticCast( composerMap.value( composer ) ); - else - { - composerPtr = MediaDeviceComposerPtr( new MediaDeviceComposer( composer ) ); - composerMap.insert( composer, ComposerPtr::staticCast( composerPtr ) ); - } - - composerPtr->addTrack( track ); - track->setComposer( composerPtr ); -} - -void -MediaDeviceHandler::setupYearMap( Meta::MediaDeviceTrackPtr track, YearMap& yearMap ) -{ - int year = m_rc->libGetYear( track ); - MediaDeviceYearPtr yearPtr; - if ( yearMap.contains( year ) ) - yearPtr = MediaDeviceYearPtr::staticCast( yearMap.value( year ) ); - else - { - yearPtr = MediaDeviceYearPtr( new MediaDeviceYear( QString::number(year) ) ); - yearMap.insert( year, YearPtr::staticCast( yearPtr ) ); - } - yearPtr->addTrack( track ); - track->setYear( yearPtr ); -} - -bool -MediaDeviceHandler::privateParseTracks() -{ - DEBUG_BLOCK - - if( !setupReadCapability() ) - return false; - - TrackMap trackMap; - ArtistMap artistMap; - AlbumMap albumMap; - GenreMap genreMap; - ComposerMap composerMap; - YearMap yearMap; - - /* iterate through tracklist and add to appropriate map */ - for( m_rc->prepareToParseTracks(); !m_rc->isEndOfParseTracksList(); m_rc->prepareToParseNextTrack() ) - { - /// Fetch next track to parse - - m_rc->nextTrackToParse(); - - // FIXME: should we return true or false? - if (!m_memColl) - return true; - - MediaDeviceTrackPtr track( new MediaDeviceTrack( m_memColl ) ); - - m_rc->setAssociateTrack( track ); - getBasicMediaDeviceTrackInfo( track, track ); - - /* map-related info retrieval */ - setupArtistMap( track, artistMap ); - setupAlbumMap( track, albumMap, artistMap ); - setupGenreMap( track, genreMap ); - setupComposerMap( track, composerMap ); - setupYearMap( track, yearMap ); - - /* TrackMap stuff to be subordinated later */ - trackMap.insert( track->uidUrl(), TrackPtr::staticCast( track ) ); - - // TODO: setup titlemap for copy/deleting - m_titlemap.insert( track->name(), TrackPtr::staticCast( track ) ); - - // TODO: abstract playlist parsing - - // Subscribe to Track for metadata updates - subscribeTo( Meta::TrackPtr::staticCast( track ) ); - } - - - if( !m_pc && this->hasCapabilityInterface( Handler::Capability::Playlist ) ) - m_pc = this->create(); - - if( m_pc ) - { - // Register the playlist provider with the playlistmanager - - // register a playlist provider for this type of device - m_provider = new Playlists::MediaDeviceUserPlaylistProvider( m_memColl ); - - // Begin parsing the playlists - Playlists::MediaDevicePlaylistList playlists; - - for( m_pc->prepareToParsePlaylists(); !m_pc->isEndOfParsePlaylistsList(); m_pc->prepareToParseNextPlaylist() ) - { - m_pc->nextPlaylistToParse(); - - if( m_pc->shouldNotParseNextPlaylist() ) - continue; - - // Create a new track list - - Meta::TrackList tracklist; - - for ( m_pc->prepareToParsePlaylistTracks(); !(m_pc->isEndOfParsePlaylist()); m_pc->prepareToParseNextPlaylistTrack() ) - { - m_pc->nextPlaylistTrackToParse(); - // Grab the track associated with the next struct - Meta::TrackPtr track = Meta::TrackPtr::staticCast( m_pc->libGetTrackPtrForTrackStruct() ); - // if successful, add it into the list at the end. - // it is assumed that the list has some presorted order - // and this is left to the library - - if ( track ) - tracklist << track; - } - - // Make a playlist out of this tracklist - Playlists::MediaDevicePlaylistPtr playlist( new Playlists::MediaDevicePlaylist( m_pc->libGetPlaylistName(), tracklist ) ); - - m_pc->setAssociatePlaylist( playlist ); - - // Insert the new playlist into the list of playlists - //playlists << playlist; - - // Inform the provider of the new playlist - m_provider->addMediaDevicePlaylist( playlist ); - } - - // When the provider saves a playlist, the handler should save it internally - connect( m_provider, SIGNAL(playlistSaved(Playlists::MediaDevicePlaylistPtr,QString)), - SLOT(savePlaylist(Playlists::MediaDevicePlaylistPtr,QString)) ); - connect( m_provider, SIGNAL(playlistRenamed(Playlists::MediaDevicePlaylistPtr)), - SLOT(renamePlaylist(Playlists::MediaDevicePlaylistPtr)) ); - connect( m_provider, SIGNAL(playlistsDeleted(Playlists::MediaDevicePlaylistList)), - SLOT(deletePlaylists(Playlists::MediaDevicePlaylistList)) ); - - The::playlistManager()->addProvider( m_provider, m_provider->category() ); - m_provider->sendUpdated(); - - } - - if( !m_podcastCapability && hasCapabilityInterface( Handler::Capability::Podcast ) ) - { - - } - - // Finally, assign the created maps to the collection - m_memColl->memoryCollection()->acquireWriteLock(); - m_memColl->memoryCollection()->setTrackMap( trackMap ); - m_memColl->memoryCollection()->setArtistMap( artistMap ); - m_memColl->memoryCollection()->setAlbumMap( albumMap ); - m_memColl->memoryCollection()->setGenreMap( genreMap ); - m_memColl->memoryCollection()->setComposerMap( composerMap ); - m_memColl->memoryCollection()->setYearMap( yearMap ); - m_memColl->memoryCollection()->releaseLock(); - - m_memColl->collectionUpdated(); - - return true; -} - -void -MediaDeviceHandler::slotCopyNextTrackFailed( ThreadWeaver::Job* job, const Meta::TrackPtr& track ) -{ - Q_UNUSED( job ); - enqueueNextCopyThread(); - m_copyFailed = true; - slotCopyTrackFailed( track ); -} - -void -MediaDeviceHandler::slotCopyNextTrackDone( ThreadWeaver::Job* job, const Meta::TrackPtr& track ) -{ - Q_UNUSED( track ) - enqueueNextCopyThread(); - if ( job->success() ) - slotFinalizeTrackCopy( track ); - else - { - m_copyFailed = true; - slotCopyTrackFailed( track ); - } -} - -void -MediaDeviceHandler::enqueueNextCopyThread() -{ - Meta::TrackPtr track; - - // If there are more tracks to copy, copy the next one - if( !m_tracksToCopy.isEmpty() ) - { - // Pop the track off the front of the list - - track = m_tracksToCopy.first(); - m_tracksToCopy.removeFirst(); - - // Copy the track - ThreadWeaver::Weaver::instance()->enqueue( new CopyWorkerThread( track, this ) ); - } - else - { - // Finish the progress bar - emit incrementProgress(); - emit endProgressOperation( this ); - - // Inform CollectionLocation that copying is done - m_isCopying = false; - emit copyTracksDone( true ); - } -} - -float -MediaDeviceHandler::freeSpace() -{ - if ( setupReadCapability() ) - return m_rc->totalCapacity() - m_rc->usedCapacity(); - else - return 0.0; -} - -float -MediaDeviceHandler::usedcapacity() -{ - if ( setupReadCapability() ) - return m_rc->usedCapacity(); - else - return 0.0; -} - -float -MediaDeviceHandler::totalcapacity() -{ - if ( setupReadCapability() ) - return m_rc->totalCapacity(); - else - return 0.0; -} - -Playlists::UserPlaylistProvider* -MediaDeviceHandler::provider() -{ - DEBUG_BLOCK - return (qobject_cast( m_provider ) ); -} - -void -MediaDeviceHandler::savePlaylist( const Playlists::MediaDevicePlaylistPtr &playlist, const QString& name ) -{ - DEBUG_BLOCK - if( !m_pc ) - { - if( this->hasCapabilityInterface( Handler::Capability::Playlist ) ) - { - m_pc = this->create(); - if( !m_pc ) - { - debug() << "Handler does not have MediaDeviceHandler::PlaylistCapability."; - } - } - } - - if( m_pc ) - { - m_pc->savePlaylist( playlist, name ); - writeDatabase(); - } -} - -void -MediaDeviceHandler::renamePlaylist( const Playlists::MediaDevicePlaylistPtr &playlist ) -{ - DEBUG_BLOCK - if( !m_pc ) - { - if( this->hasCapabilityInterface( Handler::Capability::Playlist ) ) - { - m_pc = this->create(); - if( !m_pc ) - { - debug() << "Handler does not have MediaDeviceHandler::PlaylistCapability."; - } - } - } - - if( m_pc ) - { - debug() << "Renaming playlist"; - m_pc->renamePlaylist( playlist ); - writeDatabase(); - } -} - -void -MediaDeviceHandler::deletePlaylists( const Playlists::MediaDevicePlaylistList &playlistlist ) -{ - DEBUG_BLOCK - if( !m_pc ) - { - if( this->hasCapabilityInterface( Handler::Capability::Playlist ) ) - { - m_pc = this->create(); - if( !m_pc ) - { - debug() << "Handler does not have MediaDeviceHandler::PlaylistCapability."; - } - } - } - - if( m_pc ) - { - debug() << "Deleting playlists"; - foreach( Playlists::MediaDevicePlaylistPtr playlist, playlistlist ) - { - m_pc->deletePlaylist( playlist ); - } - - writeDatabase(); - } -} - -bool -MediaDeviceHandler::setupReadCapability() -{ - if( m_rc ) - return true; - if( !hasCapabilityInterface( Handler::Capability::Readable ) ) - return false; - - m_rc = create(); - return (bool) m_rc; -} - -bool -MediaDeviceHandler::setupWriteCapability() -{ - if( m_wc ) - return true; - if( !hasCapabilityInterface( Handler::Capability::Writable ) ) - return false; - - m_wc = create(); - return (bool) m_wc; -} - -/** Observer Methods **/ -void -MediaDeviceHandler::metadataChanged( TrackPtr track ) -{ - DEBUG_BLOCK - - Meta::MediaDeviceTrackPtr trackPtr = Meta::MediaDeviceTrackPtr::staticCast( track ); - - if( !setupWriteCapability() ) - return; - - setBasicMediaDeviceTrackInfo( track, trackPtr ); - m_wc->setDatabaseChanged(); - - m_wc->updateTrack( trackPtr ); -} - -void -MediaDeviceHandler::metadataChanged( ArtistPtr artist ) -{ - Q_UNUSED( artist ); -} - -void -MediaDeviceHandler::metadataChanged( AlbumPtr album ) -{ - Q_UNUSED( album ); -} - -void -MediaDeviceHandler::metadataChanged( GenrePtr genre ) -{ - Q_UNUSED( genre ); -} - -void -MediaDeviceHandler::metadataChanged( ComposerPtr composer ) -{ - Q_UNUSED( composer ); -} - -void -MediaDeviceHandler::metadataChanged( YearPtr year ) -{ - Q_UNUSED( year ); -} - -void -MediaDeviceHandler::parseTracks() -{ - ThreadWeaver::Weaver::instance()->enqueue( new ParseWorkerThread( this ) ); -} - -// ParseWorkerThread - -ParseWorkerThread::ParseWorkerThread( MediaDeviceHandler* handler ) - : ThreadWeaver::Job() - , m_success( false ) - , m_handler( handler ) -{ - connect( this, SIGNAL(done(ThreadWeaver::Job*)), this, SLOT(slotDoneSuccess(ThreadWeaver::Job*)) ); -} - -ParseWorkerThread::~ParseWorkerThread() -{ - //nothing to do -} - -bool -ParseWorkerThread::success() const -{ - return m_success; -} - -void -ParseWorkerThread::run() -{ - m_success = m_handler->privateParseTracks(); -} - -void -ParseWorkerThread::slotDoneSuccess( ThreadWeaver::Job* ) -{ - if (m_handler->m_memColl) - m_handler->m_memColl->emitCollectionReady(); -} - -// CopyWorkerThread - -CopyWorkerThread::CopyWorkerThread( const Meta::TrackPtr &track, MediaDeviceHandler* handler ) - : ThreadWeaver::Job() - , m_success( false ) - , m_track( track ) - , m_handler( handler ) -{ - //connect( this, SIGNAL(done(ThreadWeaver::Job*)), m_handler, SLOT(slotCopyNextTrackToDevice(ThreadWeaver::Job*)), Qt::QueuedConnection ); - connect( this, SIGNAL(failed(ThreadWeaver::Job*)), this, SLOT(slotDoneFailed(ThreadWeaver::Job*)), Qt::QueuedConnection ); - connect( this, SIGNAL(copyTrackFailed(ThreadWeaver::Job*,Meta::TrackPtr)), m_handler, SLOT(slotCopyNextTrackFailed(ThreadWeaver::Job*,Meta::TrackPtr)) ); - connect( this, SIGNAL(copyTrackDone(ThreadWeaver::Job*,Meta::TrackPtr)), m_handler, SLOT(slotCopyNextTrackDone(ThreadWeaver::Job*,Meta::TrackPtr)) ); - connect( this, SIGNAL(done(ThreadWeaver::Job*)), this, SLOT(slotDoneSuccess(ThreadWeaver::Job*)) ); - - //connect( this, SIGNAL(done(ThreadWeaver::Job*)), this, SLOT(deleteLater()) ); -} - -CopyWorkerThread::~CopyWorkerThread() -{ - //nothing to do -} - -bool -CopyWorkerThread::success() const -{ - return m_success; -} - -void -CopyWorkerThread::run() -{ - m_success = m_handler->privateCopyTrackToDevice( m_track ); -} - -void -CopyWorkerThread::slotDoneSuccess( ThreadWeaver::Job* ) -{ - emit copyTrackDone( this, m_track ); -} - -void -CopyWorkerThread::slotDoneFailed( ThreadWeaver::Job* ) -{ - emit copyTrackFailed( this, m_track ); -} - - -#include "moc_MediaDeviceHandler.cpp" diff --git a/amarok/src/core-impl/collections/mediadevicecollection/handler/MediaDeviceHandler.h b/amarok/src/core-impl/collections/mediadevicecollection/handler/MediaDeviceHandler.h deleted file mode 100644 index 01d798b6..00000000 --- a/amarok/src/core-impl/collections/mediadevicecollection/handler/MediaDeviceHandler.h +++ /dev/null @@ -1,490 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Alejandro Wainzinger * - * * - * This program 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 2 of the License, or (at your option) version 3 or * - * any later version accepted by the membership of KDE e.V. (or its successor approved * - * by the membership of KDE e.V.), which shall act as a proxy defined in Section 14 of * - * version 3 of the license. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef MEDIADEVICEHANDLER_H -#define MEDIADEVICEHANDLER_H - -#include "core/meta/Observer.h" -#include "core-impl/collections/mediadevicecollection/MediaDeviceMeta.h" -#include "core-impl/collections/mediadevicecollection/handler/MediaDeviceHandlerCapability.h" -#include "core-impl/collections/mediadevicecollection/handler/capabilities/PlaylistCapability.h" -#include "core-impl/collections/mediadevicecollection/handler/capabilities/PodcastCapability.h" -#include "core-impl/collections/mediadevicecollection/handler/capabilities/ReadCapability.h" -#include "core-impl/collections/mediadevicecollection/handler/capabilities/WriteCapability.h" -#include "core-impl/collections/mediadevicecollection/playlist/MediaDevicePlaylist.h" -#include "core-impl/collections/mediadevicecollection/playlist/MediaDeviceUserPlaylistProvider.h" -#include "core-impl/collections/support/MemoryCollection.h" -#include "core-impl/playlists/providers/user/UserPlaylistProvider.h" - -#include - -#include -#include -#include -#include - -class QString; -class QMutex; - -namespace Collections { - class MediaDeviceCollection; -} - -namespace Meta -{ - typedef QMultiMap TitleMap; - - class MEDIADEVICECOLLECTION_EXPORT MetaHandlerCapability - { - public: - virtual ~MetaHandlerCapability() {} - - virtual bool hasCapabilityInterface( Handler::Capability::Type type ) const; - - virtual Handler::Capability* createCapabilityInterface( Handler::Capability::Type type ); - - /** - * Retrieves a specialized interface which represents a capability of this - * object. - * - * @returns a pointer to the capability interface if it exists, 0 otherwise - */ - template CapIface *create() - { - Handler::Capability::Type type = CapIface::capabilityInterfaceType(); - Handler::Capability *iface = createCapabilityInterface(type); - return qobject_cast(iface); - } - - /** - * Tests if an object provides a given capability interface. - * - * @returns true if the interface is available, false otherwise - */ - template bool is() const - { - return hasCapabilityInterface( CapIface::capabilityInterfaceType() ); - } - }; - -/** -The MediaDeviceHandler is the backend where all low-level library calls are made. -It exists to leave a generic API in the other classes, while allowing for low-level -calls to be isolated here. -*/ - -class MEDIADEVICECOLLECTION_EXPORT MediaDeviceHandler : public QObject, public Meta::MetaHandlerCapability, public Meta::Observer -{ - Q_OBJECT - -public: - /** - * Destructor - */ - virtual ~MediaDeviceHandler(); - - // Declare thread as friend class - - friend class ParseWorkerThread; - - /** - * Begins an attempt to connect to the device, and emits - * attemptConnectionDone when it finishes. - */ - virtual void init() = 0; // collection - - /** - * Checks if the handler successfully connected - * to the device. - * @return - * TRUE if the device was successfully connected to - * FALSE if the device was not successfully connected to - */ - bool succeeded() const // collection - { - return m_success; - } - - /// Methods provided for CollectionLocation - - /** - * Checks if a device can be written to. - * @return - * TRUE if the device can be written to - * FALSE if the device can not be written to - */ - virtual bool isWritable() const = 0; - - /** Given a list of tracks, get URLs for device tracks - * of this type of device. If the device needs to - * do some work to get URLs (e.g. copy tracks to a - * temporary location) the overridden method in - * the handler takes care of it, but must emit - * gotCopyableUrls when finished. - * @param tracks The list of tracks for which to fetch urls - */ - virtual void getCopyableUrls( const Meta::TrackList &tracks ); - - /** - * Fetches the human-readable name of the device. - * This is often called from the Collection since - * a library call is needed to get this name. - * @return A QString with the name - */ - virtual QString prettyName() const = 0; - - /** - * Copies a list of tracks to the device. - * @param tracklist The list of tracks to copy. - */ - void copyTrackListToDevice( const Meta::TrackList tracklist ); - - /** - * Removes a list of tracks from the device. - * @param tracklist The list of tracks to remove. - */ - void removeTrackListFromDevice( const Meta::TrackList &tracks ); - - /** This function is called just before a track in the playlist is to be played, and gives - * a chance for e.g. MTP to copy the track to a temporary location, set a playable url, - * to emulate the track actually being played off the device - * @param track The track that needs to prepare to be played - */ - virtual void prepareToPlay( Meta::MediaDeviceTrackPtr &track ) { Q_UNUSED( track ) } // called by @param track - - virtual float usedcapacity(); - virtual float totalcapacity(); - - Playlists::UserPlaylistProvider* provider(); - - // HACK: Used for device-specific actions, such as initialize for iPod - virtual QList collectionActions() { return QList (); } - -signals: - void gotCopyableUrls( const QMap &urls ); - void databaseWritten( bool succeeded ); - - void deleteTracksDone(); - void incrementProgress(); - void endProgressOperation( QObject *owner ); - - void copyTracksDone( bool success ); - void removeTracksDone(); - - /* File I/O Methods */ - -public slots: - - /** - * Parses the media device's database and creates a Meta::MediaDeviceTrack - * for each track in the database. NOTE: only call once per device. - */ - void parseTracks(); // collection - - /** - * Writes to the device's database if it has one, otherwise - * simply calls slotDatabaseWritten to continue the workflow. - */ - - virtual void writeDatabase() { slotDatabaseWritten( true ); } - - void savePlaylist( const Playlists::MediaDevicePlaylistPtr &playlist, const QString& name ); - void renamePlaylist( const Playlists::MediaDevicePlaylistPtr &playlist ); - void deletePlaylists( const Playlists::MediaDevicePlaylistList &playlistlist ); - - bool privateParseTracks(); - - void copyNextTrackToDevice(); - bool privateCopyTrackToDevice( const Meta::TrackPtr& track ); - - void removeNextTrackFromDevice(); - void privateRemoveTrackFromDevice( const Meta::TrackPtr &track ); - - -protected: - - /** - * Constructor - * @param parent the Collection whose handler this is - */ - MediaDeviceHandler( QObject *parent ); - - /** - * Creates a MediaDeviceTrack based on the latest track struct created as a - * result of a copy to the device, and adds it into the collection to reflect - * that it has been copied. - * @param track The track to add to the collection - */ - void addMediaDeviceTrackToCollection( Meta::MediaDeviceTrackPtr &track ); - - /** - * Removes the @param track from all the collection's maps to reflect that - * it has been removed from the collection - * @param track The track to remove from the collection - */ - void removeMediaDeviceTrackFromCollection( Meta::MediaDeviceTrackPtr &track ); - - /** - * Uses wrapped libGet methods to fill a track with information from device - * @param track The track from whose associated struct to get the information - * @param destTrack The track that we want to fill with information - */ - void getBasicMediaDeviceTrackInfo( const Meta::MediaDeviceTrackPtr& track, Meta::MediaDeviceTrackPtr destTrack ); - - /** - * Uses wrapped libSet methods to fill a track struct of the particular library - * with information from a Meta::Track - * @param srcTrack The track that has the source information - * @param destTrack The track whose associated struct we want to fill with information - */ - void setBasicMediaDeviceTrackInfo( const Meta::TrackPtr &srcTrack, Meta::MediaDeviceTrackPtr destTrack ); - - Collections::MediaDeviceCollection *m_memColl; ///< Associated collection - - bool m_success; - bool m_copyingthreadsafe; ///< whether or not the handler's method of copying is threadsafe - TitleMap m_titlemap; ///< Map of track titles to tracks, used to detect duplicates - -protected slots: - - void slotCopyNextTrackFailed( ThreadWeaver::Job* job, const Meta::TrackPtr& track ); - void slotCopyNextTrackDone( ThreadWeaver::Job* job, const Meta::TrackPtr& track ); - - void slotFinalizeTrackCopy( const Meta::TrackPtr & track ); - void slotCopyTrackFailed( const Meta::TrackPtr & track ); - void slotFinalizeTrackRemove( const Meta::TrackPtr & track ); - - void slotDatabaseWritten( bool success ); - - void enqueueNextCopyThread(); - - void slotDeletingHandler(); - -private: - - /** - * Pulls out meta information (e.g. artist string) - * from track struct, inserts into appropriate map - * (e.g. ArtistMap). Sets track's meta info - * (e.g. artist string) to that extracted from - * track struct's. - * @param track - track being written to - * @param Map - map where meta information is - * associated to appropriate meta pointer - * (e.g. QString artist, ArtistPtr ) - */ - - void setupArtistMap( Meta::MediaDeviceTrackPtr track, ArtistMap &artistMap ); - void setupAlbumMap( Meta::MediaDeviceTrackPtr track, AlbumMap &albumMap, ArtistMap &artistMap ); - void setupGenreMap( Meta::MediaDeviceTrackPtr track, GenreMap &genreMap ); - void setupComposerMap( Meta::MediaDeviceTrackPtr track, ComposerMap &composerMap ); - void setupYearMap( Meta::MediaDeviceTrackPtr track, YearMap &yearMap ); - - // Misc. Helper Methods - - /** - * Tries to create read capability in m_rc - * @return true if m_rc is valid read capability, false otherwise - */ - bool setupReadCapability(); - - /** - * Tries to create write capability in m_rc - * @return true if m_wc is valid write capability, false otherwise - */ - bool setupWriteCapability(); - - /** - * @return free space on the device - */ - float freeSpace(); - - // Observer Methods - - /** These methods are called when the metadata of a track has changed. They invoke an MediaDevice DB update */ - virtual void metadataChanged( Meta::TrackPtr track ); - virtual void metadataChanged( Meta::ArtistPtr artist ); - virtual void metadataChanged( Meta::AlbumPtr album ); - virtual void metadataChanged( Meta::GenrePtr genre ); - virtual void metadataChanged( Meta::ComposerPtr composer ); - virtual void metadataChanged( Meta::YearPtr year ); - - /** - * Handler Variables - */ - - Playlists::MediaDeviceUserPlaylistProvider *m_provider; ///< Associated playlist provider - - bool m_copyFailed; ///< Indicates whether a copy failed or not - bool m_isCopying; - bool m_isDeleting; - - Meta::TrackList m_tracksToCopy; ///< List of tracks left to copy - Meta::TrackList m_tracksCopying; ///< List of tracks currrently copying - Meta::TrackList m_tracksToDelete; ///< List of tracks left to delete - - int m_numTracksToCopy; ///< The number of tracks left to copy - int m_numTracksToRemove; ///< The number of tracks left to remove - - QMap m_tracksFailed; ///< tracks that failed to copy - QHash m_trackSrcDst; ///< points source to destTracks, for completion of addition to collection - - QMutex m_mutex; ///< A make certain operations atomic when threads are at play - - // Capability-related variables - - Handler::PlaylistCapability *m_pc; - Handler::PodcastCapability *m_podcastCapability; - Handler::ReadCapability *m_rc; - Handler::WriteCapability *m_wc; - -}; - -/** -* The ParseWorkerThread is used to run a full parse of the device's database in -* a separate thread. Once done, it informs the Collection it is done -*/ - -class ParseWorkerThread : public ThreadWeaver::Job -{ - Q_OBJECT -public: - /** - * The constructor. - * @param handler The handler - */ - - ParseWorkerThread( MediaDeviceHandler* handler); - - /** - * The destructor. - */ - - virtual ~ParseWorkerThread(); - - /** - * Sees the success variable, which says whether or not the copy completed -successfully. - * @return Whether or not the copy was successful, i.e. m_success - */ - - virtual bool success() const; - -signals: - -private slots: - /** - * Is called when the job is done successfully, and simply - * calls Collection's emitCollectionReady() - * @param job The job that was done - */ - - void slotDoneSuccess( ThreadWeaver::Job* ); - -protected: - /** - * Reimplemented, simply runs the parse method. - */ - virtual void run(); - -private: - bool m_success; ///< Whether or not the parse was successful - MediaDeviceHandler *m_handler; ///< The handler -}; - -/** -* The CopyWorkerThread is used to run a copy operation on a single track in a separate thread. -* Copying is generally done one thread at a time so as to not hurt performance, and because -* many copying mechanisms like that of libmtp can only copy one file at a time. Copying -* methods that are not threadsafe should not use CopyWorkerThread, and should set the -* Handler's m_copyingthreadsafe variable to false in the Handler's constructor. -*/ - -class CopyWorkerThread : public ThreadWeaver::Job -{ - Q_OBJECT -public: - /** - * The constructor. - * @param track The source track to copy from - * @param handler The handler - */ - - CopyWorkerThread( const Meta::TrackPtr &track, MediaDeviceHandler* handler ); - - /** - * The destructor. - */ - - virtual ~CopyWorkerThread(); - - /** - * Sets the success variable, which says whether or not the copy completed successfully. - * @return Whether or not the copy was successful, i.e. m_success - */ - - virtual bool success() const; - -signals: - - /** - * Is emitted when the job is done successfully - * @param job The job that was done - * @param track The source track used for the copy - */ - - void copyTrackDone( ThreadWeaver::Job*, const Meta::TrackPtr& track ); - - /** - * Is emitted when the job is done and has failed - * @param job The job that was done - * @param track The source track used for the copy - */ - void copyTrackFailed( ThreadWeaver::Job*, const Meta::TrackPtr& track ); - -private slots: - /** - * Is called when the job is done successfully, and simply - * emits copyTrackDone - * @param job The job that was done - */ - - void slotDoneSuccess( ThreadWeaver::Job* ); - - /** - * Is called when the job is done and failed, and simply - * emits copyTrackFailed - * @param job The job that was done - */ - - void slotDoneFailed( ThreadWeaver::Job* ); - -protected: - /** - * Reimplemented, simply runs the copy track method. - */ - virtual void run(); - -private: - bool m_success; ///< Whether or not the copy was successful - Meta::TrackPtr m_track; ///< The source track to copy from - MediaDeviceHandler *m_handler; ///< The handler -}; - -} -#endif diff --git a/amarok/src/core-impl/collections/mediadevicecollection/handler/MediaDeviceHandlerCapability.cpp b/amarok/src/core-impl/collections/mediadevicecollection/handler/MediaDeviceHandlerCapability.cpp deleted file mode 100644 index 7e6e7ff8..00000000 --- a/amarok/src/core-impl/collections/mediadevicecollection/handler/MediaDeviceHandlerCapability.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Alejandro Wainzinger * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "MediaDeviceHandlerCapability.h" - -Handler::Capability::Capability( QObject *handler ) - : QObject() -{ - if( thread() != handler->thread() ) { - /* we need to be in handler's thread so that we can become children */ - moveToThread( handler->thread() ); - } - - /* moveToThread( hander->thread() ); setParent( handler ); fails on assert in debug - * Qt builds. This is a workaround that is safe as long as this object is only deleted - * using deleteLater() or form the handler's thread */ - connect( this, SIGNAL(signalSetParent(QObject*)), this, SLOT(slotSetParent(QObject*)) ); - emit signalSetParent( handler ); -} - -Handler::Capability::~Capability() -{ - // nothing to do -} - -void Handler::Capability::slotSetParent( QObject *parent ) -{ - setParent( parent ); -} - -#include "moc_MediaDeviceHandlerCapability.cpp" diff --git a/amarok/src/core-impl/collections/mediadevicecollection/handler/MediaDeviceHandlerCapability.h b/amarok/src/core-impl/collections/mediadevicecollection/handler/MediaDeviceHandlerCapability.h deleted file mode 100644 index 358a6b02..00000000 --- a/amarok/src/core-impl/collections/mediadevicecollection/handler/MediaDeviceHandlerCapability.h +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Alejandro Wainzinger * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef MEDIADEVICEHANDLER_CAPABILITY_H -#define MEDIADEVICEHANDLER_CAPABILITY_H - -#include "core-impl/collections/mediadevicecollection/support/mediadevicecollection_export.h" - -#include - -/** - * Base class for all media device Capabilities - * - * Following rules apply when working with capabilities: - * * Capabilities get deleted along their media device handler. Therefore use - * QWeakPointer everywhere to detect that. - * * the one who creates capability using create() must deleteLater() it when no - * longer used. - */ -namespace Handler -{ - class MEDIADEVICECOLLECTION_EXPORT Capability : public QObject - { - Q_OBJECT - Q_ENUMS( Type ) - - public: - //add additional capabilities here - enum Type { Unknown = 0 - , Readable = 1 // can read from device - , Writable = 2 // can write to device - , Playlist = 3 // can read/write playlists - , Artwork = 4 // can read/write artwork - , Podcast = 5 // can read/write podcasts - }; - - /** - * @param handler should be set to associated MediaDeviceHandler or Collection. - * - * The capability sets its parent to handler, so that it can be guaranteed that - * the handler is valid for Capability's lifetime. - */ - Capability( QObject *handler ); - virtual ~Capability(); - - signals: - /** - * Signals that parent of this object should be set to @param parent - */ - void signalSetParent( QObject *parent ); - - private slots: - /** - * Simply calls setParent( parent ); needed for cases where moveToThread() is - * called in constructor - setting parent needs to be done in the new thread. - */ - void slotSetParent( QObject *parent ); - }; -} - -#endif diff --git a/amarok/src/core-impl/collections/mediadevicecollection/handler/capabilities/ArtworkCapability.cpp b/amarok/src/core-impl/collections/mediadevicecollection/handler/capabilities/ArtworkCapability.cpp deleted file mode 100644 index bca8ea1e..00000000 --- a/amarok/src/core-impl/collections/mediadevicecollection/handler/capabilities/ArtworkCapability.cpp +++ /dev/null @@ -1,32 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Seb Ruiz * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "ArtworkCapability.h" - -Handler::ArtworkCapability::~ArtworkCapability() -{ - // nothing to do here -} - -void -Handler::ArtworkCapability::setCoverPath( Meta::MediaDeviceAlbumPtr album, const QString &path ) -{ - const QImage pix( path ); - if( !pix.isNull() ) - setCover( album, pix ); -} - -#include "moc_ArtworkCapability.cpp" diff --git a/amarok/src/core-impl/collections/mediadevicecollection/handler/capabilities/ArtworkCapability.h b/amarok/src/core-impl/collections/mediadevicecollection/handler/capabilities/ArtworkCapability.h deleted file mode 100644 index a462580f..00000000 --- a/amarok/src/core-impl/collections/mediadevicecollection/handler/capabilities/ArtworkCapability.h +++ /dev/null @@ -1,45 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Seb Ruiz * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef MEDIADEVICEHANDLER_ARTWORK_CAPABILITY_H -#define MEDIADEVICEHANDLER_ARTWORK_CAPABILITY_H - -#include "core-impl/collections/mediadevicecollection/MediaDeviceMeta.h" -#include "core-impl/collections/mediadevicecollection/handler/MediaDeviceHandlerCapability.h" - -namespace Handler -{ - class MEDIADEVICECOLLECTION_EXPORT ArtworkCapability : public Handler::Capability - { - Q_OBJECT - - public: - ArtworkCapability( QObject *parent ) : Capability( parent ) {} - virtual ~ArtworkCapability(); - - virtual QImage getCover( const Meta::MediaDeviceTrackPtr &track ) = 0; - - virtual void setCover( Meta::MediaDeviceAlbumPtr album, const QImage &image ) = 0; - - virtual void setCoverPath( Meta::MediaDeviceAlbumPtr album, const QString &path ); - - virtual bool canUpdateCover() const = 0; - - static Type capabilityInterfaceType() { return Handler::Capability::Artwork; } - }; -} - -#endif diff --git a/amarok/src/core-impl/collections/mediadevicecollection/handler/capabilities/PlaylistCapability.cpp b/amarok/src/core-impl/collections/mediadevicecollection/handler/capabilities/PlaylistCapability.cpp deleted file mode 100644 index 10bc67cd..00000000 --- a/amarok/src/core-impl/collections/mediadevicecollection/handler/capabilities/PlaylistCapability.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Alejandro Wainzinger * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "PlaylistCapability.h" - -Handler::PlaylistCapability::~PlaylistCapability() -{ - // nothing to do here -} - -#include "moc_PlaylistCapability.cpp" diff --git a/amarok/src/core-impl/collections/mediadevicecollection/handler/capabilities/PlaylistCapability.h b/amarok/src/core-impl/collections/mediadevicecollection/handler/capabilities/PlaylistCapability.h deleted file mode 100644 index f6ea7b29..00000000 --- a/amarok/src/core-impl/collections/mediadevicecollection/handler/capabilities/PlaylistCapability.h +++ /dev/null @@ -1,150 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Alejandro Wainzinger * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef MEDIADEVICEHANDLER_PLAYLISTCAPABILITY_H -#define MEDIADEVICEHANDLER_PLAYLISTCAPABILITY_H - -#include "core-impl/collections/mediadevicecollection/MediaDeviceMeta.h" -#include "core-impl/collections/mediadevicecollection/handler/MediaDeviceHandlerCapability.h" -#include "core-impl/collections/mediadevicecollection/playlist/MediaDevicePlaylist.h" -#include "core-impl/collections/mediadevicecollection/support/mediadevicecollection_export.h" - -namespace Handler -{ - class MEDIADEVICECOLLECTION_EXPORT PlaylistCapability : public Handler::Capability - { - Q_OBJECT - - public: - PlaylistCapability( QObject *parent ) : Capability( parent ) {} - virtual ~PlaylistCapability(); - - /// Parsing of Tracks in Playlists on Device - /// NOTE: not required by devices with no playlists, just reimplement empty functions - - /** - * This method initializes iteration over some list of playlist structs - * e.g. with libgpod, this initializes a GList to the beginning of - * the list of playlists - */ - virtual void prepareToParsePlaylists() = 0; - - /** - * This method runs a test to see if we have reached the end of - * the list of playlists to be parsed on the device, e.g. in libgpod - * this tests if cur != NULL, i.e. if(cur) - */ - virtual bool isEndOfParsePlaylistsList() = 0; - - /** - * This method moves the iterator to the next playlist on the list of - * playlist structs, e.g. with libgpod, cur = cur->next where cur - * is a GList* - */ - virtual void prepareToParseNextPlaylist() = 0; - - /** - * This method attempts to access the special struct of the - * next playlist, so that information can then be parsed from it. - * For libgpod, this is m_currplaylist = ( Itdb_Playlist * ) cur->data - */ - virtual void nextPlaylistToParse() = 0; - - /** - * This method checks if the playlist should be parsed, or skipped. - * Certain playlists, like the master playlist on the iPod, do not - * need to be or should not be parsed. - * @return true if should not parse, false otherwise. - */ - virtual bool shouldNotParseNextPlaylist() = 0; - - /** - * This method initializes iteration over some list of track structs - * that correspond to a playlist struct - * e.g. with libgpod, this initializes a GList to the beginning of - * the list of tracks - */ - virtual void prepareToParsePlaylistTracks() = 0; - - /** - * This method runs a test to see if we have reached the end of - * the list of tracks in the playlist to be parsed on the device, e.g. in libgpod - * this tests if cur != NULL, i.e. if(cur) - */ - - virtual bool isEndOfParsePlaylist() = 0; - - /** - * This method moves the iterator to the next track on the playlist of - * track structs, e.g. with libgpod, cur = cur->next where cur - * is a GList* - */ - - virtual void prepareToParseNextPlaylistTrack() = 0; - - /** - * This method attempts to access the special struct of the - * next track on the playlist, so that information can then be parsed from it. - * For libgpod, this is m_currtrack = (Itdb_Track*) cur->data - */ - virtual void nextPlaylistTrackToParse() = 0; - - /** - * Returns a MediaDeviceTrackPtr that is associated with the currently parsed track struct. - * @return A MediaDeviceTrackPtr to currently parsed track struct - */ - virtual Meta::MediaDeviceTrackPtr libGetTrackPtrForTrackStruct() = 0; - - /** - * Returns a string containing the playlist name of the currently parsed playlist struct, if available. - * @return A string with the name of the currently parsed playlist - */ - virtual QString libGetPlaylistName() = 0; - - /** - * Saves a playlist of tracks, with a name. - * @param tracks the tracks that make up the playlist to be made - * @param name the name of the playlist - */ - virtual void savePlaylist( const Playlists::MediaDevicePlaylistPtr &playlist, const QString& name ) = 0; - - /** - * Deletes a particular playlist from the device - * @param playlist the playlist to remove - */ - virtual void deletePlaylist( const Playlists::MediaDevicePlaylistPtr &playlist ) = 0; - - /** - * Renames a particular playlist on the device - * @param playlist the playlist to rename - */ - virtual void renamePlaylist( const Playlists::MediaDevicePlaylistPtr &playlist ) = 0; - - /** - * This method must create a two-way association of the current Meta::Playlist - * to the special struct provided by the library to read/write information. - * For example, for libgpod one would associate Itdb_Playlist*. It makes - * the most sense to use a QHash since it is fastest lookup and order - * does not matter. - * @param playlist The list to two-way associate with a library list struct - */ - virtual void setAssociatePlaylist( const Playlists::MediaDevicePlaylistPtr &playlist ) { Q_UNUSED( playlist ) } - - static Type capabilityInterfaceType() { return Handler::Capability::Playlist; } - }; -} - -#endif diff --git a/amarok/src/core-impl/collections/mediadevicecollection/handler/capabilities/PodcastCapability.cpp b/amarok/src/core-impl/collections/mediadevicecollection/handler/capabilities/PodcastCapability.cpp deleted file mode 100644 index 406b25cf..00000000 --- a/amarok/src/core-impl/collections/mediadevicecollection/handler/capabilities/PodcastCapability.cpp +++ /dev/null @@ -1,23 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Alejandro Wainzinger * - * Copyright (c) 2010 Bart Cerneels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "PodcastCapability.h" - -Handler::PodcastCapability::~PodcastCapability() -{ - // nothing to do here -} diff --git a/amarok/src/core-impl/collections/mediadevicecollection/handler/capabilities/PodcastCapability.h b/amarok/src/core-impl/collections/mediadevicecollection/handler/capabilities/PodcastCapability.h deleted file mode 100644 index e323afd7..00000000 --- a/amarok/src/core-impl/collections/mediadevicecollection/handler/capabilities/PodcastCapability.h +++ /dev/null @@ -1,139 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Alejandro Wainzinger * - * Copyright (c) 2010 Bart Cerneels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef PODCASTCAPABILITY_H -#define PODCASTCAPABILITY_H - -#include "core-impl/collections/mediadevicecollection/handler/MediaDeviceHandlerCapability.h" -#include "core-impl/collections/mediadevicecollection/podcast/MediaDevicePodcastMeta.h" - -namespace Handler -{ - class MEDIADEVICECOLLECTION_EXPORT PodcastCapability : public Handler::Capability - { - public: - virtual ~PodcastCapability(); - - /** - * This method initializes iteration over some list of Podcast structs - * e.g. with libgpod, this initializes a GList to the beginning of - * the list of Podcasts - */ - virtual void prepareToParsePodcasts() = 0; - - /** - * This method runs a test to see if we have reached the end of - * the list of Podcasts to be parsed on the device, e.g. in libgpod - * this tests if cur != NULL, i.e. if(cur) - */ - virtual bool isEndOfParsePodcastsList() = 0; - - /** - * This method moves the iterator to the next Podcast on the list of - * Podcast structs, e.g. with libgpod, cur = cur->next where cur - * is a GList* - */ - virtual void prepareToParseNextPodcast() = 0; - - /** - * This method attempts to access the special struct of the - * next Podcast, so that information can then be parsed from it. - * For libgpod, this is m_currPodcast = ( Itdb_Podcast * ) cur->data - */ - virtual void nextPodcastToParse() = 0; - - /** - * This method checks if the Podcast should be parsed, or skipped. - * Certain Podcasts, like the master Podcast on the iPod, do not - * need to be or should not be parsed. - * @return true if should not parse, false otherwise. - */ - virtual bool shouldNotParseNextPodcast() = 0; - - /** - * This method initializes iteration over some list of track structs - * that correspond to a Podcast struct - * e.g. with libgpod, this initializes a GList to the beginning of - * the list of tracks - */ - virtual void prepareToParsePodcastEpisode() = 0; - - /** - * This method runs a test to see if we have reached the end of - * the list of episode in the Podcast to be parsed on the device, e.g. in libgpod - * this tests if cur != NULL, i.e. if(cur) - */ - virtual bool isEndOfParsePodcast() = 0; - - /** - * This method moves the iterator to the next track on the Podcast of - * track structs, e.g. with libgpod, cur = cur->next where cur - * is a GList* - */ - virtual void prepareToParseNextPodcastEpisode() = 0; - - /** - * This method attempts to access the special struct of the - * next track on the Podcast, so that information can then be parsed from it. - * For libgpod, this is m_currtrack = (Itdb_Track*) cur->data - */ - virtual void nextPodcastEpisodeToParse() = 0; - - /** - * Returns a MediaDeviceTrackPtr that is associated with the currently parsed track struct. - * @return A MediaDeviceTrackPtr to currently parsed track struct - */ - virtual MediaDevicePodcastEpisodePtr libGetEpisodePtrForEpisodeStruct() = 0; - - /** - * Returns a string containing the Podcast name of the currently parsed Podcast struct, if available. - * @return A string with the name of the currently parsed Podcast - */ - virtual QString libGetPodcastName() = 0; - - /** - * Adds a podcast - */ - virtual void addPodcast( const Podcasts::PodcastChannelPtr &channel ) = 0; - - /** - * Deletes a particular Podcast from the device - * @param Podcast the Podcast to remove - */ - virtual void removePodcast( const MediaDevicePodcastChannelPtr &channel ) = 0; - - /** - * Deletes a particular Podcast Episode from the device - * @param Podcast the Podcast to remove - */ - virtual void removePodcastEpisode( const MediaDevicePodcastEpisodePtr &episode ) = 0; - - /** - * This method must create a two-way association of the current Podcasts::Podcast - * to the special struct provided by the library to read/write information. - * For example, for libgpod one would associate Itdb_Podcast*. It makes - * the most sense to use a QHash since it is fastest lookup and order - * does not matter. - * @param Podcast The list to two-way associate with a library list struct - */ - virtual void setAssociatePodcast( const MediaDevicePodcastChannelPtr &channel ) { Q_UNUSED( channel ) } - - static Type capabilityInterfaceType() { return Handler::Capability::Podcast; } - }; -} - -#endif diff --git a/amarok/src/core-impl/collections/mediadevicecollection/handler/capabilities/ReadCapability.cpp b/amarok/src/core-impl/collections/mediadevicecollection/handler/capabilities/ReadCapability.cpp deleted file mode 100644 index f16da501..00000000 --- a/amarok/src/core-impl/collections/mediadevicecollection/handler/capabilities/ReadCapability.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Alejandro Wainzinger * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "ReadCapability.h" - -Handler::ReadCapability::~ReadCapability() -{ - // nothing to do here -} - -bool -Handler::ReadCapability::libIsCompilation( const Meta::MediaDeviceTrackPtr &track ) -{ - Q_UNUSED( track ) - // provide default implementation so that MTP collection doesn't need to override. - return false; -} - -qreal Handler::ReadCapability::libGetReplayGain( const Meta::MediaDeviceTrackPtr &track ) -{ - Q_UNUSED( track ) - return 0.0; -} - -#include "moc_ReadCapability.cpp" diff --git a/amarok/src/core-impl/collections/mediadevicecollection/handler/capabilities/ReadCapability.h b/amarok/src/core-impl/collections/mediadevicecollection/handler/capabilities/ReadCapability.h deleted file mode 100644 index 5d87d85d..00000000 --- a/amarok/src/core-impl/collections/mediadevicecollection/handler/capabilities/ReadCapability.h +++ /dev/null @@ -1,126 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Alejandro Wainzinger * - * Copyright (c) 2011 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef MEDIADEVICEHANDLER_READCAPABILITY_H -#define MEDIADEVICEHANDLER_READCAPABILITY_H - -#include "core-impl/collections/mediadevicecollection/MediaDeviceMeta.h" -#include "core-impl/collections/mediadevicecollection/handler/MediaDeviceHandlerCapability.h" -#include "core-impl/collections/mediadevicecollection/support/mediadevicecollection_export.h" - -#include - -namespace Handler -{ - -class MEDIADEVICECOLLECTION_EXPORT ReadCapability : public Handler::Capability -{ - Q_OBJECT - - public: - ReadCapability( QObject *parent ) : Capability( parent ) {} - virtual ~ReadCapability(); - - static Type capabilityInterfaceType() { return Handler::Capability::Readable; } - - /* Parsing of Tracks on Device */ - - /** - * Initializes iteration over some list of track structs - * e.g. with libgpod, this initializes a GList to the beginning of - * the list of tracks - */ - virtual void prepareToParseTracks() = 0; - - /** - * Runs a test to see if we have reached the end of - * the list of tracks to be parsed on the device, e.g. in libgpod - * this tests if cur != NULL, i.e. if(cur) - */ - virtual bool isEndOfParseTracksList() = 0; - - /** - * Moves the iterator to the next track on the list of - * track structs, e.g. with libgpod, cur = cur->next where cur - * is a GList* - */ - virtual void prepareToParseNextTrack() = 0; - - /** - * This method attempts to access the special struct of the - * next track, so that information can then be parsed from it. - * For libgpod, this is m_currtrack = (Itdb_Track*) cur->data - */ - virtual void nextTrackToParse() = 0; - - /** - * This method must create a two-way association of the current Meta::Track - * to the special struct provided by the library to read/write information. - * For example, for libgpod one would associate Itdb_Track*. It makes - * the most sense to use a QHash since it is fastest lookup and order - * does not matter. - * @param track The track to two-way associate with a library track struct - */ - virtual void setAssociateTrack( const Meta::MediaDeviceTrackPtr track ) = 0; - - /* - * Methods that wrap get/set of information using given library (e.g. libgpod) - * Subclasses of MediaDeviceHandler must keep a pointer to the track struct - * associated to the track parameter to get the information from the struct in libGet*, - * and to set the struct's information to the passed metadata in libSet* - */ - - virtual QString libGetAlbum( const Meta::MediaDeviceTrackPtr &track ) = 0; - virtual QString libGetArtist( const Meta::MediaDeviceTrackPtr &track ) = 0; - virtual QString libGetAlbumArtist( const Meta::MediaDeviceTrackPtr &track ) = 0; - virtual QString libGetComposer( const Meta::MediaDeviceTrackPtr &track ) = 0; - virtual QString libGetGenre( const Meta::MediaDeviceTrackPtr &track ) = 0; - virtual int libGetYear( const Meta::MediaDeviceTrackPtr &track ) = 0; - - virtual QString libGetTitle( const Meta::MediaDeviceTrackPtr &track ) = 0; - virtual qint64 libGetLength( const Meta::MediaDeviceTrackPtr &track ) = 0; - virtual int libGetTrackNumber( const Meta::MediaDeviceTrackPtr &track ) = 0; - virtual QString libGetComment( const Meta::MediaDeviceTrackPtr &track ) = 0; - virtual int libGetDiscNumber( const Meta::MediaDeviceTrackPtr &track ) = 0; - virtual int libGetBitrate( const Meta::MediaDeviceTrackPtr &track ) = 0; - virtual int libGetSamplerate( const Meta::MediaDeviceTrackPtr &track ) = 0; - virtual qreal libGetBpm( const Meta::MediaDeviceTrackPtr &track ) = 0; - virtual int libGetFileSize( const Meta::MediaDeviceTrackPtr &track ) = 0; - virtual int libGetPlayCount( const Meta::MediaDeviceTrackPtr &track ) = 0; - virtual QDateTime libGetLastPlayed( const Meta::MediaDeviceTrackPtr &track ) = 0; - virtual int libGetRating( const Meta::MediaDeviceTrackPtr &track ) = 0; - virtual QString libGetType( const Meta::MediaDeviceTrackPtr &track ) = 0; - virtual KUrl libGetPlayableUrl( const Meta::MediaDeviceTrackPtr &track ) = 0; - virtual bool libIsCompilation( const Meta::MediaDeviceTrackPtr &track ); - virtual qreal libGetReplayGain( const Meta::MediaDeviceTrackPtr &track ); - - /** - * Get used capacity on the device, in bytes. Returns 0.0 if capacity information - * is not appropriate or not available. - */ - virtual float usedCapacity() const { return 0.0; } - - /** - * Get total (used + free) capacity on the device, in bytes. Returns 0.0 if - * capacity information is not appropriate or not available. - */ - virtual float totalCapacity() const { return 0.0; } - -}; -} - -#endif diff --git a/amarok/src/core-impl/collections/mediadevicecollection/handler/capabilities/WriteCapability.cpp b/amarok/src/core-impl/collections/mediadevicecollection/handler/capabilities/WriteCapability.cpp deleted file mode 100644 index 915f462f..00000000 --- a/amarok/src/core-impl/collections/mediadevicecollection/handler/capabilities/WriteCapability.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Alejandro Wainzinger * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "WriteCapability.h" - -Handler::WriteCapability::~WriteCapability() -{ - // nothing to do here -} - -void -Handler::WriteCapability::libSetIsCompilation( Meta::MediaDeviceTrackPtr &track, bool isCompilation ) -{ - Q_UNUSED( track ) - Q_UNUSED( isCompilation ) - // provide default implementation so that MTP collection doesn't need to override. -} - -void -Handler::WriteCapability::libSetReplayGain( Meta::MediaDeviceTrackPtr &track, qreal newReplayGain ) -{ - Q_UNUSED( track ) - Q_UNUSED( newReplayGain ) -} - -#include "moc_WriteCapability.cpp" diff --git a/amarok/src/core-impl/collections/mediadevicecollection/handler/capabilities/WriteCapability.h b/amarok/src/core-impl/collections/mediadevicecollection/handler/capabilities/WriteCapability.h deleted file mode 100644 index fba5a45a..00000000 --- a/amarok/src/core-impl/collections/mediadevicecollection/handler/capabilities/WriteCapability.h +++ /dev/null @@ -1,164 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Alejandro Wainzinger * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef MEDIADEVICEHANDLER_WRITECAPABILITY_H -#define MEDIADEVICEHANDLER_WRITECAPABILITY_H - -#include "core-impl/collections/mediadevicecollection/MediaDeviceMeta.h" -#include "core-impl/collections/mediadevicecollection/handler/MediaDeviceHandlerCapability.h" -#include "core-impl/collections/mediadevicecollection/support/mediadevicecollection_export.h" - -namespace Handler -{ - -class MEDIADEVICECOLLECTION_EXPORT WriteCapability : public Handler::Capability -{ - Q_OBJECT - - public: - WriteCapability( QObject *parent ) : Capability( parent ) {} - virtual ~WriteCapability(); - - static Type capabilityInterfaceType() { return Handler::Capability::Writable; } - - /** - * Returns a list of formats supported by the device, all in lowercase - * For example mp3, mpeg, aac. This is used to avoid copying unsupported - * types to a particular device. - */ - virtual QStringList supportedFormats() = 0; // md:write - - /** - * Finds the place to copy the track to on the device, which - * could be a url in the case of Ipods, or a folder in the - * case of MTP devices. - * @param srcTrack The source track of the copy - * @param destTrack The destination track whose path we seek - */ - virtual void findPathToCopy( const Meta::TrackPtr &srcTrack, const Meta::MediaDeviceTrackPtr &destTrack ) = 0; - - /** - * libCopyTrack does the actual file copying. For Ipods, it uses KIO, - * for MTPs this uses a libmtp call - * Copy the file associate with srcTrack to destTrack - * @param srcTrack The track being copied from - * @param destTrack The track being copied to - * @return Whether or not the track copy was successful - */ - virtual bool libCopyTrack( const Meta::TrackPtr &srcTrack, Meta::MediaDeviceTrackPtr &destTrack ) = 0; - - /** - * libDeleteTrack does the actual file deleting. For Ipods, it uses KIO, - * for MTPs this uses a libmtp call. Must emit libRemoveTrackDone when finished. - * @param track The track whose file is to be deleted - * @return Whether or not the track removal was successful - */ - virtual bool libDeleteTrackFile( const Meta::MediaDeviceTrackPtr &track ) = 0; - - /** - * This function is called just before copying tracks begin and allows - * a subclass to prepare to copy, e.g. for Ipods it would initialize - * the job counter to 0. - */ - virtual void prepareToCopy() = 0; - - /** - * This function is called just before deleting tracks begin and allows - * a subclass to prepare to delete, e.g. for Ipods it would initialize - * the m_tracksdeleting to keep track of urls it is deleting. - */ - virtual void prepareToDelete() = 0; - - /** - * Tells subclass that it can update the track, usually because - * the track's tags have changed. - * @param track The track whose tags should be updated - */ - virtual void updateTrack( Meta::MediaDeviceTrackPtr &track ) - { - Q_UNUSED( track ) - } - - /** - * Creates a new track struct particular to the library of the device - * e.g. LIBMTP_new_track_t(), and associates it with the track for - * later use, in the same way that setAssociateTrack does it. - * @param track The track for which to create a track struct and associate it to - */ - virtual void libCreateTrack( const Meta::MediaDeviceTrackPtr &track ) = 0; - - /** - * Deletes the track struct associated with this track, freeing - * any memory it occupied, and dissociating it from the track - * @param track The track whose associated track struct is to be deleted. - */ - virtual void libDeleteTrack( const Meta::MediaDeviceTrackPtr &track ) = 0; - - /** - * Adds the newly created track struct now populated with info into the - * database struct of the particular device, e.g. into the itdb for Ipods. - * MTP devices automatically add the track into the database upon copying, - * so MTP would do nothing. - * @param track The track whose associated track struct is to be added - * into the database. - */ - virtual void addTrackInDB( const Meta::MediaDeviceTrackPtr &track ) = 0; - - /** - * Remove all traces of the track struct associated with @param track from - * the database struct, but do not delete the struct - * @param track The track whose associated track struct is to be removed - * from the database. - */ - virtual void removeTrackFromDB( const Meta::MediaDeviceTrackPtr &track ) = 0; - - /** - * Indicates to the subclass that the database has been updated - */ - virtual void setDatabaseChanged() = 0; - - /* - * Each libSet function sets the private track struct associated with @param track - * to the second value passed into the function. - */ - - virtual void libSetTitle( Meta::MediaDeviceTrackPtr &track, const QString& title ) = 0; - virtual void libSetAlbum( Meta::MediaDeviceTrackPtr &track, const QString& album ) = 0; - virtual void libSetArtist( Meta::MediaDeviceTrackPtr &track, const QString& artist ) = 0; - virtual void libSetAlbumArtist( Meta::MediaDeviceTrackPtr &track, const QString& albumArtist ) = 0; - virtual void libSetComposer( Meta::MediaDeviceTrackPtr &track, const QString& composer ) = 0; - virtual void libSetGenre( Meta::MediaDeviceTrackPtr &track, const QString& genre ) = 0; - virtual void libSetYear( Meta::MediaDeviceTrackPtr &track, const QString& year ) = 0; - virtual void libSetLength( Meta::MediaDeviceTrackPtr &track, int length ) = 0; - virtual void libSetTrackNumber( Meta::MediaDeviceTrackPtr &track, int tracknum ) = 0; - virtual void libSetComment( Meta::MediaDeviceTrackPtr &track, const QString& comment ) = 0; - virtual void libSetDiscNumber( Meta::MediaDeviceTrackPtr &track, int discnum ) = 0; - virtual void libSetBitrate( Meta::MediaDeviceTrackPtr &track, int bitrate ) = 0; - virtual void libSetSamplerate( Meta::MediaDeviceTrackPtr &track, int samplerate ) = 0; - virtual void libSetBpm( Meta::MediaDeviceTrackPtr &track, qreal bpm ) = 0; - virtual void libSetFileSize( Meta::MediaDeviceTrackPtr &track, int filesize ) = 0; - virtual void libSetPlayCount( Meta::MediaDeviceTrackPtr &track, int playcount ) = 0; - virtual void libSetLastPlayed( Meta::MediaDeviceTrackPtr &track, const QDateTime &lastplayed ) = 0; - virtual void libSetRating( Meta::MediaDeviceTrackPtr &track, int rating ) = 0; - virtual void libSetType( Meta::MediaDeviceTrackPtr &track, const QString& type ) = 0; - virtual void libSetPlayableUrl( Meta::MediaDeviceTrackPtr &destTrack, const Meta::TrackPtr &srcTrack ) = 0; - virtual void libSetIsCompilation( Meta::MediaDeviceTrackPtr &track, bool isCompilation ); - virtual void libSetReplayGain( Meta::MediaDeviceTrackPtr &track, qreal newReplayGain ); - virtual void libSetCoverArt( Meta::MediaDeviceTrackPtr &track, const QImage &cover ) = 0; -}; -} - -#endif diff --git a/amarok/src/core-impl/collections/mediadevicecollection/playlist/MediaDevicePlaylist.cpp b/amarok/src/core-impl/collections/mediadevicecollection/playlist/MediaDevicePlaylist.cpp deleted file mode 100644 index f96943d0..00000000 --- a/amarok/src/core-impl/collections/mediadevicecollection/playlist/MediaDevicePlaylist.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Alejandro Wainzinger * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "MediaDevicePlaylist.h" - -#include "core-impl/collections/support/CollectionManager.h" -#include "core/support/Debug.h" -//#include "core/meta/stream/Stream.h" -//#include "MediaDeviceStorage.h" -#include "playlistmanager/PlaylistManager.h" -#include "MediaDeviceUserPlaylistProvider.h" - -#include - -Playlists::MediaDevicePlaylist::MediaDevicePlaylist( const QString & name, const Meta::TrackList - &tracks ) - : m_tracks( tracks ) -{ - m_name = name; - // Tell the handler to save it -} - -Playlists::MediaDevicePlaylist::~MediaDevicePlaylist() -{ -} - -int -Playlists::MediaDevicePlaylist::trackCount() const -{ - return m_tracks.count(); -} - -Meta::TrackList -Playlists::MediaDevicePlaylist::tracks() -{ - return m_tracks; -} - -void -Playlists::MediaDevicePlaylist::addTrack( Meta::TrackPtr track, int position ) -{ - DEBUG_BLOCK - int insertAt = (position == -1) ? m_tracks.count() : position; - m_tracks.insert( insertAt, track ); -} - -void -Playlists::MediaDevicePlaylist::removeTrack( int position ) -{ - DEBUG_BLOCK - m_tracks.removeAt( position ); -} - -void -Playlists::MediaDevicePlaylist::setName( const QString & name ) -{ - m_name = name; -} - diff --git a/amarok/src/core-impl/collections/mediadevicecollection/playlist/MediaDevicePlaylist.h b/amarok/src/core-impl/collections/mediadevicecollection/playlist/MediaDevicePlaylist.h deleted file mode 100644 index acfa4cce..00000000 --- a/amarok/src/core-impl/collections/mediadevicecollection/playlist/MediaDevicePlaylist.h +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Alejandro Wainzinger * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef METAMEDIADEVICEPLAYLIST_H -#define METAMEDIADEVICEPLAYLIST_H - -#include "core/playlists/Playlist.h" - -#include "core/support/Debug.h" - -namespace Playlists -{ - - class MediaDevicePlaylist; - - typedef KSharedPtr MediaDevicePlaylistPtr; - typedef QList MediaDevicePlaylistList; - - class MediaDevicePlaylist : public Playlist - { - public: - MediaDevicePlaylist( const QString &name, const Meta::TrackList &tracks ); - ~MediaDevicePlaylist(); - - // Playlist Functions - virtual QString name() const { return m_name; } - virtual KUrl uidUrl() const { return KUrl(); } - - /**override showing just the filename */ - virtual void setName( const QString &name ); - - virtual int trackCount() const; - virtual Meta::TrackList tracks(); - virtual void addTrack( Meta::TrackPtr track, int position = -1 ); - - virtual void removeTrack( int position ); - - private: - Meta::TrackList m_tracks; - QString m_name; - - }; - -} - -Q_DECLARE_METATYPE( Playlists::MediaDevicePlaylistPtr ) -Q_DECLARE_METATYPE( Playlists::MediaDevicePlaylistList ) - -#endif diff --git a/amarok/src/core-impl/collections/mediadevicecollection/playlist/MediaDeviceUserPlaylistProvider.cpp b/amarok/src/core-impl/collections/mediadevicecollection/playlist/MediaDeviceUserPlaylistProvider.cpp deleted file mode 100644 index aea50ed0..00000000 --- a/amarok/src/core-impl/collections/mediadevicecollection/playlist/MediaDeviceUserPlaylistProvider.cpp +++ /dev/null @@ -1,163 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Nikolaj Hald Nielsen * - * Copyright (c) 2008 Bart Cerneels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "MediaDeviceUserPlaylistProvider.h" - -#include "SvgHandler.h" -#include "browsers/playlistbrowser/UserPlaylistModel.h" -#include "core/support/Amarok.h" -#include "core/support/Debug.h" -#include "core-impl/collections/mediadevicecollection/MediaDeviceCollection.h" -#include "core-impl/collections/support/CollectionManager.h" -#include "core-impl/playlists/types/file/PlaylistFileSupport.h" -#include "core-impl/playlists/types/file/m3u/M3UPlaylist.h" -#include "core-impl/playlists/types/file/pls/PLSPlaylist.h" -#include "core-impl/playlists/types/file/xspf/XSPFPlaylist.h" -#include "playlistmanager/PlaylistManager.h" - -#include -#include -#include - -#include - -static const int USERPLAYLIST_DB_VERSION = 2; -static const QString key("AMAROK_USERPLAYLIST"); - -namespace Playlists { - -MediaDeviceUserPlaylistProvider::MediaDeviceUserPlaylistProvider( Collections::MediaDeviceCollection *collection ) - : Playlists::UserPlaylistProvider() - , m_collection( collection ) -{ - DEBUG_BLOCK -// checkTables(); -// m_root = Playlists::MediaDevicePlaylistGroupPtr( new Playlists::MediaDevicePlaylistGroup( "", -// Playlists::MediaDevicePlaylistGroupPtr() ) ); -// The::playlistManager()->addProvider( this, category() ); -} - -MediaDeviceUserPlaylistProvider::~MediaDeviceUserPlaylistProvider() -{ - DEBUG_BLOCK -// foreach( Playlists::MediaDevicePlaylistPtr playlist, m_playlists ) -// { -// playlist->saveToDb( true ); -// } - m_playlists.clear(); -// emit updated(); -// The::playlistManager()->removeProvider( this ); - -} - -Playlists::PlaylistList -MediaDeviceUserPlaylistProvider::playlists() -{ - DEBUG_BLOCK - Playlists::PlaylistList playlists; - - foreach( Playlists::MediaDevicePlaylistPtr mediadevicePlaylist, m_playlists ) - { - playlists << Playlists::PlaylistPtr::staticCast( mediadevicePlaylist ); - } - - return playlists; -} - -Playlists::PlaylistPtr -MediaDeviceUserPlaylistProvider::save( const Meta::TrackList &tracks ) -{ - DEBUG_BLOCK - // This provider can only save it's own tracks for now, filter out all the others. - Meta::TrackList filteredTracks; - foreach( const Meta::TrackPtr track, tracks ) - if( track->collection() == m_collection ) - filteredTracks << track; - - return save( filteredTracks, - QDateTime::currentDateTime().toString( "ddd MMMM d yy hh-mm" ) ); -} - -Playlists::PlaylistPtr -MediaDeviceUserPlaylistProvider::save( const Meta::TrackList &tracks, const QString& name ) -{ - DEBUG_BLOCK - debug() << "saving " << tracks.count() << " tracks to device with name" << name; - // NOTE: the playlist constructor tells the handler to make the playlist, save to db etc. - Playlists::MediaDevicePlaylistPtr pl = Playlists::MediaDevicePlaylistPtr( new Playlists::MediaDevicePlaylist( name, tracks ) ); - //pl = 0; - - emit playlistSaved( pl, name ); // inform handler of new playlist - - addMediaDevicePlaylist( pl ); - - return Playlists::PlaylistPtr::dynamicCast( pl ); -} - -void -MediaDeviceUserPlaylistProvider::renamePlaylist( Playlists::PlaylistPtr playlist, const QString &newName ) -{ - DEBUG_BLOCK - Playlists::MediaDevicePlaylistPtr pl = Playlists::MediaDevicePlaylistPtr::staticCast( playlist ); - if( pl ) - { - debug() << "Setting name of playlist"; - pl->setName( newName ); - - emit playlistRenamed( pl ); - } -} - -bool -MediaDeviceUserPlaylistProvider::deletePlaylists( const Playlists::PlaylistList &playlistlist ) -{ - Playlists::MediaDevicePlaylistList pllist; - foreach( Playlists::PlaylistPtr playlist, playlistlist ) - { - Playlists::MediaDevicePlaylistPtr pl = - Playlists::MediaDevicePlaylistPtr::staticCast( playlist ); - - if( pl ) - { - debug() << "Deleting playlist: " << pl->name(); - removePlaylist( pl ); - pllist << pl; - } - } - - emit playlistsDeleted( pllist ); - - return true; -} - -void -MediaDeviceUserPlaylistProvider::addMediaDevicePlaylist( Playlists::MediaDevicePlaylistPtr &playlist ) -{ - m_playlists << playlist; - emit updated(); -} - -void -MediaDeviceUserPlaylistProvider::removePlaylist( Playlists::MediaDevicePlaylistPtr &playlist ) -{ - m_playlists.removeOne( playlist ); - emit updated(); -} - -} //namespace Playlists - -#include "moc_MediaDeviceUserPlaylistProvider.cpp" diff --git a/amarok/src/core-impl/collections/mediadevicecollection/playlist/MediaDeviceUserPlaylistProvider.h b/amarok/src/core-impl/collections/mediadevicecollection/playlist/MediaDeviceUserPlaylistProvider.h deleted file mode 100644 index d86decc7..00000000 --- a/amarok/src/core-impl/collections/mediadevicecollection/playlist/MediaDeviceUserPlaylistProvider.h +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Alejandro Wainzinger * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_COLLECTION_MEDIADEVICEUSERPLAYLISTPROVIDER_H -#define AMAROK_COLLECTION_MEDIADEVICEUSERPLAYLISTPROVIDER_H - -#include "core-impl/playlists/providers/user/UserPlaylistProvider.h" -#include "MediaDevicePlaylist.h" - -#include -#include - -namespace Collections { - class MediaDeviceCollection; -} - -namespace Playlists { - -class AMAROK_EXPORT MediaDeviceUserPlaylistProvider : public Playlists::UserPlaylistProvider -{ - Q_OBJECT - public: - MediaDeviceUserPlaylistProvider( Collections::MediaDeviceCollection *collection ); - ~MediaDeviceUserPlaylistProvider(); - - /* PlaylistProvider functions */ - virtual QString prettyName() const { return i18n( "Media Device playlists" ); }; - virtual KIcon icon() const { return KIcon( "multimedia-player" ); } - - /* Playlists::UserPlaylistProvider functions */ - virtual Playlists::PlaylistList playlists(); - - virtual Playlists::PlaylistPtr save( const Meta::TrackList &tracks ); - virtual Playlists::PlaylistPtr save( const Meta::TrackList &tracks, const QString& name ); - - virtual bool isWritable() { return true; } - virtual void renamePlaylist( Playlists::PlaylistPtr playlist, const QString &newName ); - virtual bool deletePlaylists( const Playlists::PlaylistList &playlistlist ); - - /// MediaDevice-specific Functions - - void addMediaDevicePlaylist( Playlists::MediaDevicePlaylistPtr &playlist ); - void removePlaylist( Playlists::MediaDevicePlaylistPtr &playlist ); - - public slots: - void sendUpdated() { emit updated(); } - - signals: - void playlistSaved( const Playlists::MediaDevicePlaylistPtr &playlist, const QString &name ); - void playlistRenamed( const Playlists::MediaDevicePlaylistPtr &playlist ); - void playlistsDeleted( const Playlists::MediaDevicePlaylistList &playlistlist ); - - private: - MediaDevicePlaylistList m_playlists; - - Collections::MediaDeviceCollection *m_collection; -}; - -} //namespace Playlists - -#endif diff --git a/amarok/src/core-impl/collections/mediadevicecollection/podcast/MediaDevicePodcastMeta.h b/amarok/src/core-impl/collections/mediadevicecollection/podcast/MediaDevicePodcastMeta.h deleted file mode 100644 index 6a91c332..00000000 --- a/amarok/src/core-impl/collections/mediadevicecollection/podcast/MediaDevicePodcastMeta.h +++ /dev/null @@ -1,49 +0,0 @@ -/**************************************************************************************** - * Copyright 2010 Bart Cerneels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - - -#ifndef MEDIADEVICEPODCASTMETA_H -#define MEDIADEVICEPODCASTMETA_H - -#endif // MEDIADEVICEPODCASTMETA_H - -#include "core/podcasts/PodcastMeta.h" - -namespace Handler -{ - class MediaDevicePodcastChannel; - typedef KSharedPtr MediaDevicePodcastChannelPtr; - typedef QList MediaDevicePodcastChannelList; - - class MediaDevicePodcastEpisode; - typedef KSharedPtr MediaDevicePodcastEpisodePtr; - typedef QList MediaDevicePodcastEpisodeList; - - class MediaDevicePodcastChannel : public Podcasts::PodcastChannel - { - - }; - - class MediaDevicePodcastEpisode : public Podcasts::PodcastEpisode - { - - }; -} - -Q_DECLARE_METATYPE( Handler::MediaDevicePodcastChannelPtr ) -Q_DECLARE_METATYPE( Handler::MediaDevicePodcastChannelList ) -Q_DECLARE_METATYPE( Handler::MediaDevicePodcastEpisodePtr ) -Q_DECLARE_METATYPE( Handler::MediaDevicePodcastEpisodeList ) diff --git a/amarok/src/core-impl/collections/mediadevicecollection/podcast/MediaDevicePodcastProvider.cpp b/amarok/src/core-impl/collections/mediadevicecollection/podcast/MediaDevicePodcastProvider.cpp deleted file mode 100644 index 785063ff..00000000 --- a/amarok/src/core-impl/collections/mediadevicecollection/podcast/MediaDevicePodcastProvider.cpp +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************************** - * Copyright 2010 Bart Cerneels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - - -#include "MediaDevicePodcastProvider.h" - -using namespace Podcasts; - -MediaDevicePodcastProvider::MediaDevicePodcastProvider( Meta::MediaDeviceHandler *handler ) - : m_handler( handler ) -{ -} - -void -MediaDevicePodcastProvider::addPodcast( const KUrl &url ) -{ - Q_UNUSED( url ) - //can this handler even fetch feeds itself? -} - -PodcastChannelPtr -MediaDevicePodcastProvider::addChannel( PodcastChannelPtr channel ) -{ - Q_UNUSED( channel ) - return PodcastChannelPtr(); -} - -PodcastEpisodePtr -MediaDevicePodcastProvider::addEpisode( PodcastEpisodePtr episode ) -{ - Q_UNUSED( episode ) - return PodcastEpisodePtr(); -} - -PodcastChannelList -MediaDevicePodcastProvider::channels() -{ - PodcastChannelList channels; - return channels; -} - -void -MediaDevicePodcastProvider::removeSubscription( PodcastChannelPtr channel ) -{ - Q_UNUSED( channel ) -} - -void -MediaDevicePodcastProvider::configureProvider() -{ -} - -void -MediaDevicePodcastProvider::configureChannel( PodcastChannelPtr channel ) -{ - Q_UNUSED( channel ) -} - -QString -MediaDevicePodcastProvider::prettyName() const -{ - return i18nc( "Podcasts on a media device", "Podcasts on %1", m_handler->prettyName() ); -} - -Playlists::PlaylistList -MediaDevicePodcastProvider::playlists() -{ - Playlists::PlaylistList playlists; - - foreach( PodcastChannelPtr channel, channels() ) - playlists << Playlists::PlaylistPtr::dynamicCast( channel ); - - return playlists; -} - -Playlists::PlaylistPtr -MediaDevicePodcastProvider::addPlaylist( Playlists::PlaylistPtr playlist ) -{ - PodcastChannelPtr channel = PodcastChannelPtr::dynamicCast( playlist ); - if( channel.isNull() ) - return Playlists::PlaylistPtr(); - - return Playlists::PlaylistPtr::dynamicCast( addChannel( channel ) ); -} - -Meta::TrackPtr -MediaDevicePodcastProvider::addTrack( Meta::TrackPtr track ) -{ - PodcastEpisodePtr episode = PodcastEpisodePtr::dynamicCast( track ); - if( episode.isNull() ) - return Meta::TrackPtr(); - - return Meta::TrackPtr::dynamicCast( addEpisode( episode ) ); -} diff --git a/amarok/src/core-impl/collections/mediadevicecollection/podcast/MediaDevicePodcastProvider.h b/amarok/src/core-impl/collections/mediadevicecollection/podcast/MediaDevicePodcastProvider.h deleted file mode 100644 index 00e24f6b..00000000 --- a/amarok/src/core-impl/collections/mediadevicecollection/podcast/MediaDevicePodcastProvider.h +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************************** - * Copyright 2010 Bart Cerneels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef MEDIADEVICEPODCASTPROVIDER_H -#define MEDIADEVICEPODCASTPROVIDER_H - -#include "core/podcasts/PodcastProvider.h" -#include "core-impl/collections/mediadevicecollection/handler/MediaDeviceHandler.h" - -namespace Podcasts { - -class MediaDevicePodcastProvider : public Podcasts::PodcastProvider -{ - public: - MediaDevicePodcastProvider( Meta::MediaDeviceHandler *handler ); - - //TODO:implement these - virtual bool possiblyContainsTrack( const KUrl &url ) const { Q_UNUSED(url); return false;} - virtual Meta::TrackPtr trackForUrl( const KUrl &url ) { Q_UNUSED(url); return Meta::TrackPtr(); } - - virtual void addPodcast( const KUrl &url ); - - virtual Podcasts::PodcastChannelPtr addChannel( Podcasts::PodcastChannelPtr channel ); - virtual Podcasts::PodcastEpisodePtr addEpisode( Podcasts::PodcastEpisodePtr episode ); - - virtual Podcasts::PodcastChannelList channels(); - - virtual void removeSubscription( Podcasts::PodcastChannelPtr channel ); - - virtual void configureProvider(); - virtual void configureChannel( Podcasts::PodcastChannelPtr channel ); - - // PlaylistProvider methods - virtual QString prettyName() const; - virtual int category() const { return (int)Playlists::PodcastChannelPlaylist; } - - virtual Playlists::PlaylistList playlists(); - - virtual Playlists::PlaylistPtr addPlaylist( Playlists::PlaylistPtr playlist ); - virtual Meta::TrackPtr addTrack( Meta::TrackPtr track ); - - private: - Meta::MediaDeviceHandler *m_handler; -}; - -} //namespace Podcasts - -#endif // MEDIADEVICEPODCASTPROVIDER_H diff --git a/amarok/src/core-impl/collections/mediadevicecollection/support/ConnectionAssistant.cpp b/amarok/src/core-impl/collections/mediadevicecollection/support/ConnectionAssistant.cpp deleted file mode 100644 index e43a47b6..00000000 --- a/amarok/src/core-impl/collections/mediadevicecollection/support/ConnectionAssistant.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Alejandro Wainzinger * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "ConnectionAssistant.h" - -#include "MediaDeviceMonitor.h" - -ConnectionAssistant::ConnectionAssistant( bool wait ) - : QObject() - , m_wait( wait ) -{ -} - -ConnectionAssistant::~ConnectionAssistant() -{ -} - -bool -ConnectionAssistant::identify(const QString& udi) -{ - Q_UNUSED( udi ); - return false; -} - -MediaDeviceInfo* -ConnectionAssistant::deviceInfo( const QString& udi ) -{ - Q_UNUSED( udi ); - MediaDeviceInfo *info = 0; - return info; -} - -void -ConnectionAssistant::tellIdentified( const QString &udi ) -{ - DEBUG_BLOCK - emit identified( deviceInfo( udi ) ); -} - -void -ConnectionAssistant::tellDisconnected( const QString& udi ) -{ - DEBUG_BLOCK - emit disconnected( udi ); -} - -bool -ConnectionAssistant::wait() -{ - return m_wait; -} - - -#include "moc_ConnectionAssistant.cpp" diff --git a/amarok/src/core-impl/collections/mediadevicecollection/support/ConnectionAssistant.h b/amarok/src/core-impl/collections/mediadevicecollection/support/ConnectionAssistant.h deleted file mode 100644 index 459c2792..00000000 --- a/amarok/src/core-impl/collections/mediadevicecollection/support/ConnectionAssistant.h +++ /dev/null @@ -1,104 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Alejandro Wainzinger * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef CONNECTIONASSISTANT_H -#define CONNECTIONASSISTANT_H - -#include "mediadevicecollection_export.h" - -#include - -class MediaDeviceInfo; - -class QString; - -/** -@class ConnectionAssistant - -The ConnectionAssistant (CA) serves as a way for MediaDeviceCollectionFactory to register its -device type with the MediaDeviceMonitor (MDM). Once registered, the MDM can use the CA to -attempt to identify a newly plugged-in device, and retrieve the MediaDeviceInfo object necessary -for the Factory to connect to it. - -*/ - -class MEDIADEVICECOLLECTION_EXPORT ConnectionAssistant : public QObject -{ - Q_OBJECT - -public: - - virtual ~ConnectionAssistant(); - - /** - - identify checks if a device identified by @param uid matches the type - of device described by this ConnectionAssistant - - */ - virtual bool identify( const QString& udi ); - - /** - - deviceInfo returns a pointer to a new MediaDeviceInfo of the type of device - described by this ConnectionAssistant - - */ - - virtual MediaDeviceInfo* deviceInfo( const QString& udi ); - - bool wait(); - - // Simply emit identified( info ) - virtual void tellIdentified( const QString &udi ); - virtual void tellDisconnected( const QString &udi ); - -protected: - - /* - * Constructor - * @param wait whether or not to wait to identify this device, - * to give other types of devices a chance to claim this device - * type during autodetection - */ - ConnectionAssistant( bool wait = false ); - -signals: - - /** - - identified is emitted when identify returns true, and the device type's Factory - has a slot that then attempts to connect to the device - - */ - void identified( MediaDeviceInfo* info ); - - /** - - disconnected is emitted when a device with a given @param udi - has been disconnected. The device type's factory should then - destroy the Collection appropriately - - */ - - void disconnected( const QString &udi ); - -private: - bool m_wait; - -}; - -#endif // CONNECTIONASSISTANT_H diff --git a/amarok/src/core-impl/collections/mediadevicecollection/support/MediaDeviceInfo.cpp b/amarok/src/core-impl/collections/mediadevicecollection/support/MediaDeviceInfo.cpp deleted file mode 100644 index 2101ce66..00000000 --- a/amarok/src/core-impl/collections/mediadevicecollection/support/MediaDeviceInfo.cpp +++ /dev/null @@ -1,35 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Alejandro Wainzinger * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "MediaDeviceInfo.h" - -MediaDeviceInfo::MediaDeviceInfo() -: QObject() -, m_udi() -{ -} - -MediaDeviceInfo::~MediaDeviceInfo() -{ -} - -QString -MediaDeviceInfo::udi() -{ - return m_udi; -} - -#include "moc_MediaDeviceInfo.cpp" diff --git a/amarok/src/core-impl/collections/mediadevicecollection/support/MediaDeviceInfo.h b/amarok/src/core-impl/collections/mediadevicecollection/support/MediaDeviceInfo.h deleted file mode 100644 index fb9b46cd..00000000 --- a/amarok/src/core-impl/collections/mediadevicecollection/support/MediaDeviceInfo.h +++ /dev/null @@ -1,39 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Alejandro Wainzinger * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef MEDIA_DEVICE_INFO_H -#define MEDIA_DEVICE_INFO_H - -#include "mediadevicecollection_export.h" - -#include -#include - -class MEDIADEVICECOLLECTION_EXPORT MediaDeviceInfo : public QObject -{ - Q_OBJECT - public: - - QString udi(); - - protected: - MediaDeviceInfo(); - virtual ~MediaDeviceInfo(); - - QString m_udi; -}; - -#endif diff --git a/amarok/src/core-impl/collections/mediadevicecollection/support/mediadevicecollection_export.h b/amarok/src/core-impl/collections/mediadevicecollection/support/mediadevicecollection_export.h deleted file mode 100644 index 5cfc1f97..00000000 --- a/amarok/src/core-impl/collections/mediadevicecollection/support/mediadevicecollection_export.h +++ /dev/null @@ -1,33 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Patrick Spendrin * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef MEDIADEVICECOLLECTION_EXPORT_H -#define MEDIADEVICECOLLECTION_EXPORT_H - -/* needed for KDE_EXPORT and KDE_IMPORT macros */ -#include - -#ifndef MEDIADEVICECOLLECTION_EXPORT -# if defined(MAKE_MEDIADEVICELIB_LIB) || defined(MAKE_AMAROKLIB_LIB) - /* We are building this library */ -# define MEDIADEVICECOLLECTION_EXPORT KDE_EXPORT -# else - /* We are using this library */ -# define MEDIADEVICECOLLECTION_EXPORT KDE_IMPORT -# endif -#endif - -#endif // MEDIADEVICECOLLECTION_EXPORT_H diff --git a/amarok/src/core-impl/collections/mtpcollection/CMakeLists.txt b/amarok/src/core-impl/collections/mtpcollection/CMakeLists.txt deleted file mode 100644 index 9d2c76fa..00000000 --- a/amarok/src/core-impl/collections/mtpcollection/CMakeLists.txt +++ /dev/null @@ -1,56 +0,0 @@ -macro_optional_find_package(Mtp) - - -if (MTP_FOUND) - include_directories( - ${Amarok_SOURCE_DIR}/src - ${Amarok_SOURCE_DIR}/src/core-impl/collections - ${Amarok_SOURCE_DIR}/src/core-impl/collections/mediadevicecollection - ${Amarok_SOURCE_DIR}/src/core-impl/collections/mediadevicecollection/support - ${Amarok_SOURCE_DIR}/src/core-impl/collections/mediadevicecollection/handler - ${Amarok_SOURCE_DIR}/src/core-impl/collections/mediadevicecollection/handler/capabilities - ${Amarok_SOURCE_DIR}/src/core-impl/collections/mtpcollection/handler - ${Amarok_SOURCE_DIR}/src/core-impl/collections/mtpcollection/handler/capabilities - ${Amarok_SOURCE_DIR}/src/core-impl/collections/mtpcollection/support - ${GLIB2_INCLUDE_DIR} - ${MTP_INCLUDE_DIR} - ${CMAKE_BINARY_DIR}/src - ${AMAROK_COLLECTION_SUPPORT_DIR} - ${KDE4_INCLUDE_DIR} - ${QT_INCLUDES} -) - - -########### next target ############### - -set(amarok_collection-mtpcollection_PART_SRCS - MtpCollection.cpp - handler/MtpHandler.cpp - handler/capabilities/MtpPlaylistCapability.cpp - handler/capabilities/MtpReadCapability.cpp - handler/capabilities/MtpWriteCapability.cpp - support/MtpDeviceInfo.cpp - support/MtpConnectionAssistant.cpp -) -kde4_add_plugin(amarok_collection-mtpcollection ${amarok_collection-mtpcollection_PART_SRCS}) - -target_link_libraries(amarok_collection-mtpcollection - amarokcore - amaroklib - ${KDE4_KDECORE_LIBS} - ${KDE4_KIO_LIBS} - ${KDE4_KDEUI_LIBS} - ${KDE4_SOLID_LIBRARY} - ${KDE4_THREADWEAVER_LIBS} - ${QT_QTGUI_LIBRARY} - ${MTP_LIBRARIES} -) - -install(TARGETS amarok_collection-mtpcollection DESTINATION ${PLUGIN_INSTALL_DIR} ) - - -########### install files ############### - -install( FILES amarok_collection-mtpcollection.desktop DESTINATION ${SERVICES_INSTALL_DIR}) - -endif (MTP_FOUND) diff --git a/amarok/src/core-impl/collections/mtpcollection/MtpCollection.cpp b/amarok/src/core-impl/collections/mtpcollection/MtpCollection.cpp deleted file mode 100644 index 31c0be0b..00000000 --- a/amarok/src/core-impl/collections/mtpcollection/MtpCollection.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Alejandro Wainzinger * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "MtpCollection" - -#include "MtpCollection.h" -#include "MtpConnectionAssistant.h" -#include "MtpDeviceInfo.h" -#include "MediaDeviceInfo.h" - -#include "amarokconfig.h" -#include "core/support/Debug.h" - -#include - -using namespace Collections; - -AMAROK_EXPORT_COLLECTION( MtpCollectionFactory, mtpcollection ) - -MtpCollectionFactory::MtpCollectionFactory( QObject *parent, const QVariantList &args ) - : MediaDeviceCollectionFactory( parent, args, new MtpConnectionAssistant() ) -{ - m_info = KPluginInfo( "amarok_collection-mtpcollection.desktop", "services" ); -} - -MtpCollectionFactory::~MtpCollectionFactory() -{ - DEBUG_BLOCK - // nothing to do -} - -//MtpCollection - -MtpCollection::MtpCollection( MediaDeviceInfo* info ) -: MediaDeviceCollection() -{ - DEBUG_BLOCK - /** Fetch Info needed to construct MtpCollection */ - debug() << "Getting mtp info"; - MtpDeviceInfo *mtpinfo = qobject_cast( info ); - - debug() << "Getting udi"; - m_udi = mtpinfo->udi(); - - debug() << "constructing handler"; - - m_handler = new Meta::MtpHandler( this ); - - //startFullScan();// parse tracks -} - -MtpCollection::~MtpCollection() -{ - DEBUG_BLOCK - //if( m_handler ) - // qobject_cast ( m_handler )->terminate(); -} - -QString -MtpCollection::collectionId() const -{ - return m_udi; -} - -QString -MtpCollection::prettyName() const -{ - return m_handler->prettyName(); -} - - - -#include "moc_MtpCollection.cpp" - diff --git a/amarok/src/core-impl/collections/mtpcollection/MtpCollection.h b/amarok/src/core-impl/collections/mtpcollection/MtpCollection.h deleted file mode 100644 index 3766757b..00000000 --- a/amarok/src/core-impl/collections/mtpcollection/MtpCollection.h +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Alejandro Wainzinger * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef MTPCOLLECTION_H -#define MTPCOLLECTION_H - -#include - -#include "MtpHandler.h" - -#include "MediaDeviceCollection.h" -#include "core/support/Debug.h" - -#include - -#include - -class MediaDeviceInfo; - -namespace Collections { - -class MtpCollection; - -class MtpCollectionFactory : public MediaDeviceCollectionFactory -{ - Q_OBJECT - public: - MtpCollectionFactory( QObject *parent, const QVariantList &args ); - virtual ~MtpCollectionFactory(); - -}; - -class MtpCollection : public MediaDeviceCollection -{ - Q_OBJECT - public: - - MtpCollection( MediaDeviceInfo* ); - virtual ~MtpCollection(); - - virtual QString collectionId() const; - virtual QString prettyName() const; - virtual KIcon icon() const { return KIcon("multimedia-player"); } - - //void writeDatabase(); -}; - -} //namespace Collections - -#endif diff --git a/amarok/src/core-impl/collections/mtpcollection/amarok_collection-mtpcollection.desktop b/amarok/src/core-impl/collections/mtpcollection/amarok_collection-mtpcollection.desktop deleted file mode 100644 index b6d0d224..00000000 --- a/amarok/src/core-impl/collections/mtpcollection/amarok_collection-mtpcollection.desktop +++ /dev/null @@ -1,132 +0,0 @@ -[Desktop Entry] -Type=Service -Icon=media-flash-smart-media -Name=MTP Collection -Name[be]=Калекцыя MTP -Name[bg]=Колекция MTP -Name[bs]=MTP Zbirka -Name[ca]=Col·lecció MTP -Name[ca@valencia]=Col·lecció MTP -Name[cs]=Sbírka MTP -Name[csb]=Kòlekcëjô MTP -Name[da]=MTP-samling -Name[de]=MTP-Sammlung -Name[el]=Συλλογή MTP -Name[en_GB]=MTP Collection -Name[es]=Colección de MTP -Name[et]=MTP kogu -Name[eu]=MTP bilduma -Name[fi]=MTP-kokoelma -Name[fr]=Collection « MTP » -Name[ga]=Bailiúchán MTP -Name[gl]=Colección MTP -Name[he]=אוסף MTP -Name[hne]=एमटीपी संग्रह -Name[hu]=MTP-gyűjtemény -Name[id]=Koleksi MTP -Name[is]=MTP safn -Name[it]=Collezione MTP -Name[ja]=MTP コレクション -Name[km]=សម្រាំង MTP -Name[ko]=MTP 모음집 -Name[ku]=Berhevoka MTP -Name[lt]=MTP fonoteka -Name[lv]=MTP kolekcija -Name[nb]=MTP-samling -Name[nds]=MTP-Reedschap-Sammeln -Name[nl]=MTP-collectie -Name[nn]=MTP-samling -Name[pa]=MTP ਭੰਡਾਰ -Name[pl]=Zbiór MTP -Name[pt]=Colecção do MTP -Name[pt_BR]=Coleção de MTP -Name[ro]=Colecție MTP -Name[ru]=Коллекция MTP -Name[sk]=MTP kolekcia -Name[sl]=Zbirka MTP -Name[sr]=МТП збирка -Name[sr@ijekavian]=МТП збирка -Name[sr@ijekavianlatin]=MTP zbirka -Name[sr@latin]=MTP zbirka -Name[sv]=MTP-samling -Name[th]=คลังสื่อของ MTP -Name[tr]=MTP Koleksiyonu -Name[uk]=Збірка MTP -Name[wa]=Ramexhnêye MTP -Name[x-test]=xxMTP Collectionxx -Name[zh_CN]=MTP 收藏 -Name[zh_TW]=MTP 收藏 -Comment=MTP collection plugin for Amarok -Comment[be]=Утулка калекцыі MTP для Amarok -Comment[bg]=Приставка за колекция MTP (Amarok) -Comment[bs]=Priključak zbirke MTP za Amarok -Comment[ca]=Connector de col·leccions MTP per a l'Amarok -Comment[ca@valencia]=Connector de col·leccions MTP per a l'Amarok -Comment[cs]=Modul sbírky MTP pro AmaroK -Comment[csb]=Wtëkôcz kòlekcëji MTP dlô Amaroka -Comment[da]=Plugin til MTP-samling til Amarok -Comment[de]=MTP-Sammlungsmodul für Amarok -Comment[el]=Πρόσθετο συλλογής MTP για το AmaroK -Comment[en_GB]=MTP collection plugin for Amarok -Comment[es]=Complemento de colección MTP para Amarok -Comment[et]=Amaroki MTP kogu plugin -Comment[eu]=MTP bildumen plugina Amarok-entzako -Comment[fi]=Amarokin MTP-kokoelmaliitännäinen -Comment[fr]=Module externe de collections « MTP » pour Amarok -Comment[ga]=Breiseán bailiúchán MTP le haghaidh Amarok -Comment[gl]=Complemento de coleccións MTP para Amarok -Comment[he]=תוסף אוסף MTP ל־Amarok -Comment[hne]=अमाराक बर एमटीपी संग्रह प्लगइन -Comment[hu]=MTP-gyűjteményt megvalósító bővítőmodul az Amarokhoz -Comment[id]=Koleksi plugin MTP untuk Amarok -Comment[is]=MTP safníforrit fyrir Amarok -Comment[it]=Estensione della collezione MTP di Amarok -Comment[ja]=Amarok のための MTP コレクションプラグイン -Comment[km]=កម្មវិធី​ជំនួយ​សម្រាំង MTP សម្រាប់​ Amarok -Comment[ko]=Amarok의 MTP 모음집 플러그인 -Comment[ku]=Pêveka Berhevoka MTP ji bo Amarok -Comment[lt]=MTP fonotekos Amarok papildinys -Comment[lv]=Amarok MTP kolekcijas spraudnis -Comment[nb]=MTP-samling – programtillegg for Amarok -Comment[nds]=MTP-Reedschap-Sammelnmoduul för Amarok -Comment[nl]=MTP-collectieplugin voor Amarok -Comment[nn]=Amarok-samlingstillegg for MTP -Comment[pa]=ਅਮਰੋਕ ਲਈ MTP ਭੰਡਾਰ ਪਲੱਗਇਨ -Comment[pl]=Wtyczka kolekcji MTP dla Amaroka -Comment[pt]=Um 'plugin' de colecção do MTP no Amarok -Comment[pt_BR]=Plugin de coleção de MTP para o Amarok -Comment[ro]=Modul de colecție MTP pentru Amarok -Comment[ru]=Модуль коллекции MTP для Amarok -Comment[sk]=Modul MTP kolekcia pre Amarok -Comment[sl]=Vstavek za zbirko MTP za Amarok -Comment[sr]=Прикључак МТП збирке за Амарок -Comment[sr@ijekavian]=Прикључак МТП збирке за Амарок -Comment[sr@ijekavianlatin]=Priključak MTP zbirke za Amarok -Comment[sr@latin]=Priključak MTP zbirke za Amarok -Comment[sv]=Insticksprogram med MTP-samling för Amarok -Comment[th]=ส่วนเสริมของแอมอะร็อก สำหรับจัดการคลังสื่อของ MTP -Comment[tr]=Amarok için MTP koleksiyon eklentisi -Comment[uk]=Додаток збірки MTP для Amarok -Comment[wa]=Tchôke-divins di ramexhnêye MTP po Amarok -Comment[x-test]=xxMTP collection plugin for Amarokxx -Comment[zh_CN]=Amarok 的 MTP 收藏插件 -Comment[zh_TW]=Amarok 的 MTP 收藏外掛程式 - -ServiceTypes=Amarok/Plugin - -X-KDE-Amarok-authors=Alejandro Wainzinger -X-KDE-Amarok-email=aikawarazuni@gmail.com -X-KDE-Amarok-framework-version=72 -X-KDE-Amarok-name=mtp-collection -X-KDE-Amarok-plugintype=collection -X-KDE-Amarok-rank=100 -X-KDE-Amarok-version=1 - -X-KDE-PluginInfo-Author=Alejandro Wainzinger -X-KDE-PluginInfo-Email=aikawarazuni@gmail.com -X-KDE-PluginInfo-Version=1.0 -X-KDE-PluginInfo-Category=Collection -X-KDE-PluginInfo-License=GPL -X-KDE-PluginInfo-EnabledByDefault=true -X-KDE-PluginInfo-Name=amarok_collection-mtpcollection -X-KDE-Library=amarok_collection-mtpcollection diff --git a/amarok/src/core-impl/collections/mtpcollection/handler/MtpHandler.cpp b/amarok/src/core-impl/collections/mtpcollection/handler/MtpHandler.cpp deleted file mode 100644 index a2c07e2e..00000000 --- a/amarok/src/core-impl/collections/mtpcollection/handler/MtpHandler.cpp +++ /dev/null @@ -1,1510 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2006 Andy Kelk * - * Copyright (c) 2008 Alejandro Wainzinger * - * Copyright (c) 2009 Mark Kretschmann * - * * - * This program 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 2 of the License, or (at your option) version 3 or * - * any later version accepted by the membership of KDE e.V. (or its successor approved * - * by the membership of KDE e.V.), which shall act as a proxy defined in Section 14 of * - * version 3 of the license. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "MtpHandler" - -#include "MtpHandler.h" - -#include "MtpCollection.h" -#include "core/support/Debug.h" - -#include "core-impl/meta/file/File.h" // for KIO file handling -#include "core/interfaces/Logger.h" - -#include -#include -#include "kjob.h" -#include -#include - -#include -#include -#include -#include - -using namespace Meta; - -MtpHandler::MtpHandler( Collections::MtpCollection *mc ) - : MediaDeviceHandler( mc ) - , m_device( 0 ) - , m_capacity( 0.0 ) - , m_default_parent_folder( 0 ) - , m_folders( 0 ) - , m_folderStructure() - , m_format() - , m_name() - , m_supportedFiles() - , m_isCanceled( false ) - , m_wait( false ) - , m_dbChanged( false ) - , m_trackcounter( 0 ) - , m_copyParentId( 0 ) - , m_tempDir( new KTempDir() ) -{ - DEBUG_BLOCK - m_copyingthreadsafe = true; - m_tempDir->setAutoRemove( true ); -// init(); -} - -MtpHandler::~MtpHandler() -{ - // TODO: free used memory - DEBUG_BLOCK - // clear folder structure - - if ( m_folders != 0 ) - { - - LIBMTP_destroy_folder_t( m_folders ); - - m_folders = 0; - debug() << "Folders destroyed"; - } - - // Delete temporary files - - //delete m_tempDir; - - // release device - - if ( m_device != 0 ) - { - - LIBMTP_Release_Device( m_device ); - /* possible race condition with statusbar destructor, - will uncomment when fixed */ - //Amarok::Components::logger()->longMessage( - // i18n( "The MTP device %1 has been disconnected", prettyName() ), StatusBar::Information ); - debug() << "Device released"; - } - -} - -bool -MtpHandler::isWritable() const -{ - // TODO: check if read-only - return true; -} - -void -MtpHandler::init() -{ - mtpFileTypes[LIBMTP_FILETYPE_WAV] = "wav"; - mtpFileTypes[LIBMTP_FILETYPE_MP3] = "mp3"; - mtpFileTypes[LIBMTP_FILETYPE_WMA] = "wma"; - mtpFileTypes[LIBMTP_FILETYPE_OGG] = "ogg"; - mtpFileTypes[LIBMTP_FILETYPE_AUDIBLE] = "aa"; - mtpFileTypes[LIBMTP_FILETYPE_MP4] = "mp4"; - mtpFileTypes[LIBMTP_FILETYPE_UNDEF_AUDIO] = "undef-audio"; - mtpFileTypes[LIBMTP_FILETYPE_WMV] = "wmv"; - mtpFileTypes[LIBMTP_FILETYPE_AVI] = "avi"; - mtpFileTypes[LIBMTP_FILETYPE_MPEG] = "mpg"; - mtpFileTypes[LIBMTP_FILETYPE_ASF] = "asf"; - mtpFileTypes[LIBMTP_FILETYPE_QT] = "mov"; - mtpFileTypes[LIBMTP_FILETYPE_UNDEF_VIDEO] = "undef-video"; - mtpFileTypes[LIBMTP_FILETYPE_JPEG] = "jpg"; - mtpFileTypes[LIBMTP_FILETYPE_JFIF] = "jfif"; - mtpFileTypes[LIBMTP_FILETYPE_TIFF] = "tiff"; - mtpFileTypes[LIBMTP_FILETYPE_BMP] = "bmp"; - mtpFileTypes[LIBMTP_FILETYPE_GIF] = "gif"; - mtpFileTypes[LIBMTP_FILETYPE_PICT] = "pict"; - mtpFileTypes[LIBMTP_FILETYPE_PNG] = "png"; - mtpFileTypes[LIBMTP_FILETYPE_VCALENDAR1] = "vcs"; - mtpFileTypes[LIBMTP_FILETYPE_VCALENDAR2] = "vcs"; - mtpFileTypes[LIBMTP_FILETYPE_VCARD2] = "vcf"; - mtpFileTypes[LIBMTP_FILETYPE_VCARD3] = "vcf"; - mtpFileTypes[LIBMTP_FILETYPE_WINDOWSIMAGEFORMAT] = "wim"; - mtpFileTypes[LIBMTP_FILETYPE_WINEXEC] = "exe"; - mtpFileTypes[LIBMTP_FILETYPE_TEXT] = "txt"; - mtpFileTypes[LIBMTP_FILETYPE_HTML] = "html"; - mtpFileTypes[LIBMTP_FILETYPE_AAC] = "aac"; - mtpFileTypes[LIBMTP_FILETYPE_FLAC] = "flac"; - mtpFileTypes[LIBMTP_FILETYPE_MP2] = "mp3"; - mtpFileTypes[LIBMTP_FILETYPE_M4A] = "m4a"; - mtpFileTypes[LIBMTP_FILETYPE_DOC] = "doc"; - mtpFileTypes[LIBMTP_FILETYPE_XML] = "xml"; - mtpFileTypes[LIBMTP_FILETYPE_XLS] = "xls"; - mtpFileTypes[LIBMTP_FILETYPE_PPT] = "ppt"; - mtpFileTypes[LIBMTP_FILETYPE_MHT] = "mht"; - mtpFileTypes[LIBMTP_FILETYPE_JP2] = "jpg"; - mtpFileTypes[LIBMTP_FILETYPE_JPX] = "jpx"; - mtpFileTypes[LIBMTP_FILETYPE_UNKNOWN] = "unknown"; - - QString genericError = i18n( "Could not connect to MTP Device" ); - - m_success = false; - - // begin checking connected devices - - LIBMTP_raw_device_t * rawdevices; - int numrawdevices; - LIBMTP_error_number_t err; - - debug() << "Initializing MTP stuff"; - LIBMTP_Init(); - - // get list of raw devices - debug() << "Getting list of raw devices"; - err = LIBMTP_Detect_Raw_Devices( &rawdevices, &numrawdevices ); - - debug() << "Error is: " << err; - - switch ( err ) - { - case LIBMTP_ERROR_NO_DEVICE_ATTACHED: - debug() << "No raw devices found."; - m_success = false; - break; - - case LIBMTP_ERROR_CONNECTING: - debug() << "Detect: There has been an error connecting."; - m_success = false; - break; - - case LIBMTP_ERROR_MEMORY_ALLOCATION: - debug() << "Detect: Encountered a Memory Allocation Error. Exiting"; - m_success = false; - break; - - case LIBMTP_ERROR_NONE: - m_success = true; - break; - - default: - debug() << "Unhandled mtp error"; - m_success = false; - break; - } - - if ( m_success ) - { - debug() << "Got mtp list, connecting to device using thread"; - ThreadWeaver::Weaver::instance()->enqueue( new WorkerThread( numrawdevices, rawdevices, this ) ); - } - else - { - free( rawdevices ); - // emit failed(); - } -} - - -// this function is threaded -bool -MtpHandler::iterateRawDevices( int numrawdevices, LIBMTP_raw_device_t* rawdevices ) -{ - DEBUG_BLOCK - - bool success = false; - - LIBMTP_mtpdevice_t *device = 0; - // test raw device for connectability - for ( int i = 0; i < numrawdevices; i++ ) - { - debug() << "Opening raw device number: " << ( i + 1 ); - device = LIBMTP_Open_Raw_Device( &rawdevices[i] ); - if ( device == NULL ) - { - debug() << "Unable to open raw device: " << ( i + 1 ); - success = false; - continue; - } - - // HACK: not checking serial to confirm the right device is in place - // this is not incorrect, and long-term goal is to remove serial number from use altogether - - /* - QString mtpSerial = QString::fromUtf8( LIBMTP_Get_Serialnumber( device ) ); - if( !mtpSerial.contains(serial) ) - { - debug() << "Wrong device, going to next"; - debug() << "Expected: " << serial << " but got: " << mtpSerial; - success = false; - LIBMTP_Release_Device( device ); - continue; - } - */ - - debug() << "Correct device found"; - success = true; - break; - } - - m_device = device; - - if ( m_device == 0 ) - { - // TODO: error protection - success = false; - free( rawdevices ); - } - - //QString serial = QString::fromUtf8( LIBMTP_Get_Serialnumber( m_device ) ); - - // debug() << "Serial is: " << serial; - - return success; -} - -void -MtpHandler::getDeviceInfo() -{ - DEBUG_BLOCK - - // Get information for device - - // Get Battery level and print to debug - - unsigned char max; - unsigned char curr; - int failed; - - failed = LIBMTP_Get_Batterylevel( m_device, &max, &curr ); - - if ( !failed ) - debug() << "Battery at: " << curr << "/" << max; - else - debug() << "Unknown battery level"; - - if( LIBMTP_Get_Storage( m_device, LIBMTP_STORAGE_SORTBY_NOTSORTED ) != 0 ) - { - debug() << "Failed to get storage properties, cannot get capacity"; - m_capacity = 0.0; - } - - else - { - m_capacity = m_device->storage->MaxCapacity; - } - - QString modelname = QString( LIBMTP_Get_Modelname( m_device ) ); - - // NOTE: on next libmtp bump, may reintroduce owner name - // for now it doesn't work as expected - /* - QString ownername = QString( LIBMTP_Get_Friendlyname( m_device ) ); - m_name = modelname; - if(! ownername.isEmpty() ) - if( modelname != ownername ) - m_name += " (" + ownername + ')'; - - else - m_name += " (No Owner Name)"; - - */ - - m_name = modelname; - - m_default_parent_folder = m_device->default_music_folder; - debug() << "setting default parent : " << m_default_parent_folder; - - - m_folders = LIBMTP_Get_Folder_List( m_device ); - uint16_t *filetypes; - uint16_t filetypes_len; - int ret = LIBMTP_Get_Supported_Filetypes( m_device, &filetypes, &filetypes_len ); - if ( ret == 0 ) - { - uint16_t i; - for ( i = 0; i < filetypes_len; ++i ) - { - debug() << "Device supports: " << mtpFileTypes.value( filetypes[ i ] ); - m_supportedFiles << mtpFileTypes.value( filetypes[ i ] ); - } - } - // find supported image types (for album art). - if ( m_supportedFiles.indexOf( "jpg" ) ) - m_format = "JPEG"; - else if ( m_supportedFiles.indexOf( "png" ) ) - m_format = "PNG"; - else if ( m_supportedFiles.indexOf( "gif" ) ) - m_format = "GIF"; - free( filetypes ); -} - -void -MtpHandler::terminate() -{ - DEBUG_BLOCK - // clear folder structure - if ( m_folders != 0 ) - { - LIBMTP_destroy_folder_t( m_folders ); - - m_folders = 0; - } - - // release device - if ( m_device != 0 ) - { - LIBMTP_Release_Device( m_device ); - /* possible race condition with statusbar destructor, - will uncomment when fixed - Amarok::Components::logger()->longMessage( - i18n( "The MTP device %1 has been disconnected", prettyName() ), - Amarok::Logger::Information - ); */ - - debug() << "Device released"; - } -} - -void -MtpHandler::getCopyableUrls( const Meta::TrackList &tracks ) -{ - DEBUG_BLOCK - - QMap urls; - - QString genericError = i18n( "Could not copy track from device." ); - - foreach( Meta::TrackPtr trackptr, tracks ) - { - Meta::MediaDeviceTrackPtr track = Meta::MediaDeviceTrackPtr::dynamicCast( trackptr ); - if( !track ) - break; - - QString trackFileName = QString::fromUtf8( m_mtpTrackHash.value( track )->filename ); - - QString filename = m_tempDir->name() + trackFileName; - - debug() << "Temp Filename: " << filename; - - int ret = getTrackToFile( m_mtpTrackHash.value( track )->item_id, filename ); - if ( ret != 0 ) - { - debug() << "Get Track failed: " << ret; - /*Amarok::Components::logger()->shortLongMessage( - genericError, - i18n( "Could not copy track from device." ), - StatusBar::Error - );*/ - } - else - { - urls.insert( trackptr, filename ); - } - } - - emit gotCopyableUrls( urls ); -} - -/** - * Check (and optionally create) the folder structure to put a - * track into. Return the (possibly new) parent folder ID - */ -uint32_t -MtpHandler::checkFolderStructure( const Meta::TrackPtr track, bool create ) -{ - QString artistName; - Meta::ArtistPtr artist = track->artist(); - if ( !artist || artist->prettyName().isEmpty() ) - artistName = i18n( "Unknown Artist" ); - else - artistName = artist->prettyName(); - - //FIXME: Port -// if( bundle.compilation() == MetaBundle::CompilationYes ) -// artist = i18n( "Various Artists" ); - QString albumName; - Meta::AlbumPtr album = track->album(); - if ( !album || album->prettyName().isEmpty() ) - albumName = i18n( "Unknown Album" ); - else - albumName = album->prettyName(); - QString genreName; - Meta::GenrePtr genre = track->genre(); - if ( !genre || genre->prettyName().isEmpty() ) - genreName = i18n( "Unknown Genre" ); - else - genreName = genre->prettyName(); - - uint32_t parent_id = getDefaultParentId(); - QStringList folders = m_folderStructure.split( '/' ); // use slash as a dir separator - QString completePath; - for ( QStringList::Iterator it = folders.begin(); it != folders.end(); ++it ) - { - if (( *it ).isEmpty() ) - continue; - // substitute %a , %b , %g - ( *it ).replace( QRegExp( "%a" ), artistName ) - .replace( QRegExp( "%b" ), albumName ) - .replace( QRegExp( "%g" ), genreName ); - // check if it exists - uint32_t check_folder = subfolderNameToID(( *it ).toUtf8(), m_folders, parent_id ); - // create if not exists (if requested) - if ( check_folder == 0 ) - { - if ( create ) - { - check_folder = createFolder(( *it ).toUtf8() , parent_id ); - if ( check_folder == 0 ) - { - return 0; - } - } - else - { - return 0; - } - } - completePath += ( *it ).toUtf8() + '/'; - // set new parent - parent_id = check_folder; - } - debug() << "Folder path : " << completePath; - return parent_id; -} - -uint32_t -MtpHandler::getDefaultParentId( void ) -{ - // Decide which folder to send it to: - // If the device gave us a parent_folder setting, we use it - uint32_t parent_id = 0; - if ( m_default_parent_folder ) - { - parent_id = m_default_parent_folder; - } - // Otherwise look for a folder called "Music" - else if ( m_folders != 0 ) - { - parent_id = folderNameToID( qstrdup( QString( "Music" ).toUtf8() ), m_folders ); - if ( !parent_id ) - { - debug() << "Parent folder could not be found. Going to use top level."; - } - } - // Give up and don't set a parent folder, let the device deal with it - else - { - debug() << "No folders found. Going to use top level."; - } - return parent_id; -} - -/** - * Recursively search the folder list for a matching one - * and return its ID - */ -uint32_t -MtpHandler::folderNameToID( char *name, LIBMTP_folder_t *folderlist ) -{ - uint32_t i; - - if ( folderlist == 0 ) - return 0; - - if ( !strcasecmp( name, folderlist->name ) ) - return folderlist->folder_id; - - if (( i = ( folderNameToID( name, folderlist->child ) ) ) ) - return i; - if (( i = ( folderNameToID( name, folderlist->sibling ) ) ) ) - return i; - - return 0; -} - -/** - * Recursively search the folder list for a matching one under the specified - * parent ID and return the child's ID - */ -uint32_t -MtpHandler::subfolderNameToID( const char *name, LIBMTP_folder_t *folderlist, uint32_t parent_id ) -{ - uint32_t i; - - if ( folderlist == 0 ) - return 0; - - if ( !strcasecmp( name, folderlist->name ) && folderlist->parent_id == parent_id ) - return folderlist->folder_id; - - if (( i = ( subfolderNameToID( name, folderlist->child, parent_id ) ) ) ) - return i; - if (( i = ( subfolderNameToID( name, folderlist->sibling, parent_id ) ) ) ) - return i; - - return 0; -} - -/** - * Create a new mtp folder - */ -uint32_t -MtpHandler::createFolder( const char *name, uint32_t parent_id ) -{ - debug() << "Creating new folder '" << name << "' as a child of " << parent_id; - char *name_copy = qstrdup( name ); - // NOTE: api change, 0 refers to default storage_id - uint32_t new_folder_id = LIBMTP_Create_Folder( m_device, name_copy, parent_id, 0 ); - delete( name_copy ); - debug() << "New folder ID: " << new_folder_id; - if ( new_folder_id == 0 ) - { - debug() << "Attempt to create folder '" << name << "' failed."; - return 0; - } - updateFolders(); - - return new_folder_id; -} - -/** - * Update local cache of mtp folders - */ -void -MtpHandler::updateFolders( void ) -{ - LIBMTP_destroy_folder_t( m_folders ); - m_folders = 0; - m_folders = LIBMTP_Get_Folder_List( m_device ); -} -#if 0 - -void -MtpHandler::privateDeleteTrackFromDevice( const Meta::MtpTrackPtr &track ) -{ - DEBUG_BLOCK - - //If nothing is left in a folder, delete the folder - u_int32_t object_id = track->id(); - - QString genericError = i18n( "Could not delete item" ); - - debug() << "delete this id : " << object_id; - - - int status = LIBMTP_Delete_Object( m_device, object_id ); - - if ( status != 0 ) - { - debug() << "delete object failed"; - Amarok::Components::logger()->longMessage( i18n( "Delete failed" ), - Amarok::Logger::Error - ); -// return false; - } - debug() << "object deleted"; - -// return true; - - m_titlemap.remove( track->name(), Meta::TrackPtr::staticCast( track ) ); - -} -#endif -int -MtpHandler::getTrackToFile( const uint32_t id, const QString & filename ) -{ - return LIBMTP_Get_Track_To_File( m_device, id, filename.toUtf8(), 0, 0 ); -} - -int -MtpHandler::progressCallback( uint64_t const sent, uint64_t const total, void const * const data ) -{ - DEBUG_BLOCK - Q_UNUSED( sent ); - MtpHandler *handler = ( MtpHandler* )( data ); - - // NOTE: setting max many times wastes cycles, - // but how else to get total outside of callback? - - debug() << "Setting max to: " << (( int ) total ); - - debug() << "Device: " << handler->prettyName(); -/* - handler->setBarMaximum(( int ) total ); - handler->setBarProgress(( int ) sent ); - - if ( sent == total ) - handler->endBarProgressOperation(); - */ - - return 0; -} - - -QString -MtpHandler::prettyName() const -{ - return m_name; -} - -/// Begin MediaDeviceHandler overrides - -void -MtpHandler::findPathToCopy( const Meta::TrackPtr &srcTrack, const Meta::MediaDeviceTrackPtr &destTrack ) -{ - Q_UNUSED( destTrack ); - uint32_t parent_id = 0; - if ( !m_folderStructure.isEmpty() ) - { - parent_id = checkFolderStructure( srcTrack, true ); // true means create - if ( parent_id == 0 ) - { - debug() << "Could not create new parent (" << m_folderStructure << ")"; - /*Amarok::Components::logger()->shortLongMessage( - genericError, - i18n( "Cannot create parent folder. Check your structure." ), - Amarok::Logger::Error - );*/ - return; - } - } - else - { - parent_id = getDefaultParentId(); - } - debug() << "Parent id : " << parent_id; - - m_copyParentId = parent_id; - -} - -bool -MtpHandler::libCopyTrack( const Meta::TrackPtr &srcTrack, Meta::MediaDeviceTrackPtr &destTrack ) -{ - DEBUG_BLOCK - - findPathToCopy( srcTrack, destTrack ); - debug() << "sending..."; - - debug() << "Playable Url is: " << srcTrack->playableUrl(); - debug() << "Sending file with path: " << srcTrack->playableUrl().path().toUtf8(); - - - - int ret = LIBMTP_Send_Track_From_File( m_device, qstrdup( srcTrack->playableUrl().path().toUtf8() ), m_mtpTrackHash.value( destTrack ), - 0, 0 ); - - debug() << "sent"; -// emit canCopyMoreTracks(); - -// emit libCopyTrackDone( srcTrack ); - - return ( ret == 0 ); -} - -bool -MtpHandler::libDeleteTrackFile( const Meta::MediaDeviceTrackPtr &track ) -{ - slotFinalizeTrackRemove( Meta::TrackPtr::staticCast( track ) ); - return true; -} - -void -MtpHandler::libDeleteTrack( const Meta::MediaDeviceTrackPtr &track ) -{ - DEBUG_BLOCK - LIBMTP_track_struct *mtptrack = m_mtpTrackHash.value( track ); - - m_mtpTrackHash.remove( track ); - - quint32 object_id = mtptrack->item_id; - - const QString genericError = i18n( "Could not delete item" ); - - int status = LIBMTP_Delete_Object( m_device, object_id ); - - removeNextTrackFromDevice(); - - if( status != 0 ) - debug() << "delete object failed"; - else - debug() << "object deleted"; -} - -void -MtpHandler::setDatabaseChanged() -{ - m_dbChanged = true; -} - - -void -MtpHandler::prepareToParseTracks() -{ - DEBUG_BLOCK - - m_currentTrackList = LIBMTP_Get_Tracklisting_With_Callback( m_device, 0, this ); -} - -bool -MtpHandler::isEndOfParseTracksList() -{ - return m_currentTrackList ? false : true; -} - -void -MtpHandler::prepareToParseNextTrack() -{ - m_currentTrackList = m_currentTrackList->next; -} - -void -MtpHandler::nextTrackToParse() -{ - m_currentTrack = m_currentTrackList; -} - -/// Playlist Parsing - -void -MtpHandler::prepareToParsePlaylists() -{ - m_currentPlaylistList = LIBMTP_Get_Playlist_List( m_device ); -} - - -bool -MtpHandler::isEndOfParsePlaylistsList() -{ - return (m_currentPlaylistList == 0); -} - - -void -MtpHandler::prepareToParseNextPlaylist() -{ - m_currentPlaylistList = m_currentPlaylistList->next; -} - - -void -MtpHandler::nextPlaylistToParse() -{ - m_currentPlaylist = m_currentPlaylistList; -} - -bool -MtpHandler::shouldNotParseNextPlaylist() -{ - // NOTE: parse all - return false; -} - - -void -MtpHandler::prepareToParsePlaylistTracks() -{ - m_trackcounter = 0; -} - - -bool -MtpHandler::isEndOfParsePlaylist() -{ - return (m_trackcounter >= m_currentPlaylist->no_tracks); -} - - -void -MtpHandler::prepareToParseNextPlaylistTrack() -{ - m_trackcounter++; -} - - -void -MtpHandler::nextPlaylistTrackToParse() -{ - m_currentTrack = m_idTrackHash.value( m_currentPlaylist->tracks[ m_trackcounter ] ); -} - - -Meta::MediaDeviceTrackPtr -MtpHandler::libGetTrackPtrForTrackStruct() -{ - return m_mtpTrackHash.key( m_currentTrack ); -} - -QString -MtpHandler::libGetPlaylistName() -{ - return QString::fromUtf8( m_currentPlaylist->name ); -} - -void -MtpHandler::setAssociatePlaylist( const Playlists::MediaDevicePlaylistPtr &playlist ) -{ - m_mtpPlaylisthash[ playlist ] = m_currentPlaylist; -} - -void -MtpHandler::libSavePlaylist( const Playlists::MediaDevicePlaylistPtr &playlist, const QString& name ) -{ - DEBUG_BLOCK - Meta::TrackList tracklist = const_cast ( playlist )->tracks(); - // Make new playlist - - LIBMTP_playlist_t *metadata = LIBMTP_new_playlist_t(); - metadata->name = qstrdup( name.toUtf8() ); - const int trackCount = tracklist.count(); - if( trackCount > 0 ) - { - uint32_t *tracks = ( uint32_t* )malloc( sizeof( uint32_t ) * trackCount ); - uint32_t i = 0; - foreach( Meta::TrackPtr trk, tracklist ) - { - if( !trk ) // playlists might contain invalid tracks. see BUG: 297816 - continue; - Meta::MediaDeviceTrackPtr track = Meta::MediaDeviceTrackPtr::staticCast( trk ); - tracks[i] = m_mtpTrackHash.value( track )->item_id; - } - metadata->tracks = tracks; - metadata->no_tracks = trackCount; - } - else - { - debug() << "no tracks available for playlist " << metadata->name; - metadata->no_tracks = 0; - } - - QString genericError = i18n( "Could not save playlist." ); - - debug() << "creating new playlist : " << metadata->name << endl; - int ret = LIBMTP_Create_New_Playlist( m_device, metadata ); - if( ret == 0 ) - { - m_mtpPlaylisthash[ playlist ] = metadata; - debug() << "playlist saved : " << metadata->playlist_id << endl; - } - else - debug () << "Could not create new playlist on device."; -} - -void -MtpHandler::deletePlaylist( const Playlists::MediaDevicePlaylistPtr &playlist ) -{ - DEBUG_BLOCK - - LIBMTP_playlist_t *pl = m_mtpPlaylisthash.value( playlist ); - - if( pl ) - { - - m_mtpPlaylisthash.remove( playlist ); - - quint32 object_id = pl->playlist_id; - - QString genericError = i18n( "Could not delete item" ); - - debug() << "delete this id : " << object_id; - - int status = LIBMTP_Delete_Object( m_device, object_id ); - - if ( status != 0 ) - { - debug() << "delete object failed"; - } - else - debug() << "object deleted"; - } -} - -void -MtpHandler::renamePlaylist( const Playlists::MediaDevicePlaylistPtr &playlist ) -{ - DEBUG_BLOCK - LIBMTP_playlist_t *pl = m_mtpPlaylisthash.value( playlist ); - - if( pl ) - { - debug() << "updating playlist : " << pl->name << endl; - int ret = LIBMTP_Update_Playlist( m_device, pl ); - if( ret != 0 ) - { - debug() << "Could not rename playlist"; - } - else - debug() << "Playlist renamed"; - } -} - -void -MtpHandler::setAssociateTrack( const Meta::MediaDeviceTrackPtr track ) -{ - m_mtpTrackHash[ track ] = m_currentTrack; - m_idTrackHash[ m_currentTrack->item_id ] = m_currentTrack; -} - -QStringList -MtpHandler::supportedFormats() -{ - return m_supportedFiles; -} - - -QString -MtpHandler::libGetTitle( const Meta::MediaDeviceTrackPtr &track ) -{ - return QString::fromUtf8( m_mtpTrackHash.value( track )->title ); -} - -QString -MtpHandler::libGetAlbum( const Meta::MediaDeviceTrackPtr &track ) -{ - return QString::fromUtf8( m_mtpTrackHash.value( track )->album ); -} - -QString -MtpHandler::libGetArtist( const Meta::MediaDeviceTrackPtr &track ) -{ - return QString::fromUtf8( m_mtpTrackHash.value( track )->artist ); -} - -QString -MtpHandler::libGetAlbumArtist( const Meta::MediaDeviceTrackPtr &track ) -{ - //Album artist isn't supported by libmtp ATM. - Q_UNUSED( track ) - return QString(); -} - -QString -MtpHandler::libGetComposer( const Meta::MediaDeviceTrackPtr &track ) -{ - return QString::fromUtf8( m_mtpTrackHash.value( track )->composer ); -} - -QString -MtpHandler::libGetGenre( const Meta::MediaDeviceTrackPtr &track ) -{ - return QString::fromUtf8( m_mtpTrackHash.value( track )->genre ); -} - -int -MtpHandler::libGetYear( const Meta::MediaDeviceTrackPtr &track ) -{ - return QString::fromUtf8( m_mtpTrackHash.value( track )->date ).mid( 0, 4 ).toUInt(); -} - -qint64 -MtpHandler::libGetLength( const Meta::MediaDeviceTrackPtr &track ) -{ - if ( m_mtpTrackHash.value( track )->duration > 0 ) - return ( ( m_mtpTrackHash.value( track )->duration ) ); - return 0; -} - -int -MtpHandler::libGetTrackNumber( const Meta::MediaDeviceTrackPtr &track ) -{ - return m_mtpTrackHash.value( track )->tracknumber; -} - -QString -MtpHandler::libGetComment( const Meta::MediaDeviceTrackPtr &track ) -{ - // NOTE: defaulting, since not provided - Q_UNUSED( track ); - return QString(); -} - -int -MtpHandler::libGetDiscNumber( const Meta::MediaDeviceTrackPtr &track ) -{ - Q_UNUSED( track ); - // NOTE: defaulting, since not provided - return 1; -} - -int -MtpHandler::libGetBitrate( const Meta::MediaDeviceTrackPtr &track ) -{ - return m_mtpTrackHash.value( track )->bitrate; -} - -int -MtpHandler::libGetSamplerate( const Meta::MediaDeviceTrackPtr &track ) -{ - return m_mtpTrackHash.value( track )->samplerate; -} - -qreal -MtpHandler::libGetBpm( const Meta::MediaDeviceTrackPtr &track ) -{ - Q_UNUSED( track ); - // NOTE: defaulting, since not provided - return 0.0; -} -int -MtpHandler::libGetFileSize( const Meta::MediaDeviceTrackPtr &track ) -{ - return m_mtpTrackHash.value( track )->filesize; -} -int -MtpHandler::libGetPlayCount( const Meta::MediaDeviceTrackPtr &track ) -{ - return m_mtpTrackHash.value( track )->usecount; -} - -QDateTime -MtpHandler::libGetLastPlayed( const Meta::MediaDeviceTrackPtr &track ) -{ - Q_UNUSED( track ); - // NOTE: defaulting, since not provided - return QDateTime(); -} - -// TODO: implement rating -int -MtpHandler::libGetRating( const Meta::MediaDeviceTrackPtr &track ) -{ - return ( m_mtpTrackHash.value( track )->rating / 10 ); -} -QString -MtpHandler::libGetType( const Meta::MediaDeviceTrackPtr &track ) -{ - return mtpFileTypes.value( m_mtpTrackHash.value( track )->filetype ); -} - -KUrl -MtpHandler::libGetPlayableUrl( const Meta::MediaDeviceTrackPtr &track ) -{ - Q_UNUSED( track ) - // NOTE: not a real url, using for unique key for qm - return KUrl( QString::number( m_mtpTrackHash.value( track )->item_id, 10 ) ); -} - -float -MtpHandler::totalCapacity() const -{ - DEBUG_BLOCK - return m_capacity; -} - -float -MtpHandler::usedCapacity() const -{ - DEBUG_BLOCK - if( LIBMTP_Get_Storage( m_device, LIBMTP_STORAGE_SORTBY_NOTSORTED ) != 0 ) - { - debug() << "Failed to get storage properties, cannot get capacity"; - return 0.0; - } - return ( totalCapacity() - m_device->storage->FreeSpaceInBytes ); -} - -/// Sets - -void -MtpHandler::libSetTitle( Meta::MediaDeviceTrackPtr& track, const QString& title ) -{ - m_mtpTrackHash.value( track )->title = ( title.isEmpty() ? qstrdup( "" ) : qstrdup( title.toUtf8() ) ); - debug() << "Set to: " << m_mtpTrackHash.value( track )->title; -} -void -MtpHandler::libSetAlbum( Meta::MediaDeviceTrackPtr &track, const QString& album ) -{ - m_mtpTrackHash.value( track )->album = ( album.isEmpty() ? qstrdup( "" ) : qstrdup( album.toUtf8() ) ); - debug() << "Set to: " << m_mtpTrackHash.value( track )->album; -} -void -MtpHandler::libSetArtist( Meta::MediaDeviceTrackPtr &track, const QString& artist ) -{ - m_mtpTrackHash.value( track )->artist = ( artist.isEmpty() ? qstrdup( "" ) : qstrdup( artist.toUtf8() ) ); - debug() << "Set to: " << m_mtpTrackHash.value( track )->artist; -} - -void -MtpHandler::libSetAlbumArtist( MediaDeviceTrackPtr &track, const QString &albumArtist ) -{ - //Album artist isn't supported by libmtp ATM. - Q_UNUSED( track ) - Q_UNUSED( albumArtist ) -} - -void -MtpHandler::libSetComposer( Meta::MediaDeviceTrackPtr &track, const QString& composer ) -{ - m_mtpTrackHash.value( track )->composer = ( composer.isEmpty() ? qstrdup( "" ) : qstrdup( composer.toUtf8() ) ); - debug() << "Set to: " << m_mtpTrackHash.value( track )->composer; -} -void -MtpHandler::libSetGenre( Meta::MediaDeviceTrackPtr &track, const QString& genre ) -{ - m_mtpTrackHash.value( track )->genre = ( genre.isEmpty() ? qstrdup( "" ) : qstrdup( genre.toUtf8() ) ); - debug() << "Set to: " << m_mtpTrackHash.value( track )->genre; -} -void -MtpHandler::libSetYear( Meta::MediaDeviceTrackPtr &track, const QString& year ) -{ - if( year.toInt() > 0 ) - { - QString date; - QTextStream( &date ) << year.toInt() << "0101T0000.0"; - m_mtpTrackHash.value( track )->date = qstrdup( date.toUtf8() ); - } - else - m_mtpTrackHash.value( track )->date = qstrdup( "00010101T0000.0" ); -} -void -MtpHandler::libSetLength( Meta::MediaDeviceTrackPtr &track, int length ) -{ - m_mtpTrackHash.value( track )->duration = ( length > 0 ? length : 0 ); -} -void -MtpHandler::libSetTrackNumber( Meta::MediaDeviceTrackPtr &track, int tracknum ) -{ - m_mtpTrackHash.value( track )->tracknumber = tracknum; -} -void -MtpHandler::libSetComment( Meta::MediaDeviceTrackPtr &track, const QString& comment ) -{ - // NOTE: defaulting, since not provided - Q_UNUSED( track ) - Q_UNUSED( comment ) -} -void -MtpHandler::libSetDiscNumber( Meta::MediaDeviceTrackPtr &track, int discnum ) -{ - // NOTE: defaulting, since not provided - Q_UNUSED( track ) - Q_UNUSED( discnum ) -} -void -MtpHandler::libSetBitrate( Meta::MediaDeviceTrackPtr &track, int bitrate ) -{ - m_mtpTrackHash.value( track )->bitrate = bitrate; -} -void -MtpHandler::libSetSamplerate( Meta::MediaDeviceTrackPtr &track, int samplerate ) -{ - m_mtpTrackHash.value( track )->samplerate = samplerate; -} -void -MtpHandler::libSetBpm( Meta::MediaDeviceTrackPtr &track, qreal bpm ) -{ - // NOTE: defaulting, since not provided - Q_UNUSED( track ) - Q_UNUSED( bpm ) -} -void -MtpHandler::libSetFileSize( Meta::MediaDeviceTrackPtr &track, int filesize ) -{ - m_mtpTrackHash.value( track )->filesize = filesize; -} -void -MtpHandler::libSetPlayCount( Meta::MediaDeviceTrackPtr &track, int playcount ) -{ - m_mtpTrackHash.value( track )->usecount = playcount; -} - -void -MtpHandler::libSetLastPlayed( Meta::MediaDeviceTrackPtr &track, const QDateTime &lastplayed) -{ - Q_UNUSED( track ) - Q_UNUSED( lastplayed ) -} -void -MtpHandler::libSetRating( Meta::MediaDeviceTrackPtr &track, int rating ) -{ - m_mtpTrackHash.value( track )->rating = ( rating * 10 ); -} -void -MtpHandler::libSetType( Meta::MediaDeviceTrackPtr &track, const QString& type ) -{ - debug() << "filetype : " << type; - if ( type == "mp3" ) - { - m_mtpTrackHash.value( track )->filetype = LIBMTP_FILETYPE_MP3; - } - else if ( type == "ogg" ) - { - m_mtpTrackHash.value( track )->filetype = LIBMTP_FILETYPE_OGG; - } - else if ( type == "wma" ) - { - m_mtpTrackHash.value( track )->filetype = LIBMTP_FILETYPE_WMA; - } - else if ( type == "mp4" ) - { - m_mtpTrackHash.value( track )->filetype = LIBMTP_FILETYPE_MP4; - } - else - { - // Couldn't recognise an Amarok filetype. - // fallback to checking the extension (e.g. .wma, .ogg, etc) - debug() << "No filetype found by Amarok filetype"; - - const QString extension = type.toLower(); - - int libmtp_type = m_supportedFiles.indexOf( extension ); - if ( libmtp_type >= 0 ) - { - int keyIndex = mtpFileTypes.values().indexOf( extension ); - libmtp_type = mtpFileTypes.keys()[keyIndex]; - m_mtpTrackHash.value( track )->filetype = ( LIBMTP_filetype_t ) libmtp_type; - debug() << "set filetype to " << libmtp_type << " based on extension of ." << extension; - } - else - { - debug() << "We do not support the extension ." << extension; - /* Amarok::Components::logger()->shortLongMessage( - genericError, - i18n( "Cannot determine a valid file type" ), - Amarok::Logger::Error - );*/ - } - } - - debug() << "Filetype set to: " << mtpFileTypes.value( m_mtpTrackHash.value( track )->filetype ); -} - -void -MtpHandler::libSetPlayableUrl( Meta::MediaDeviceTrackPtr &destTrack, const Meta::TrackPtr &srcTrack ) -{ - if( !srcTrack->playableUrl().fileName().isEmpty() ) - m_mtpTrackHash.value( destTrack )->filename = qstrdup( srcTrack->playableUrl().fileName().toUtf8() ); -} - -void -MtpHandler::libCreateTrack( const Meta::MediaDeviceTrackPtr& track ) -{ - m_mtpTrackHash[ track ] = LIBMTP_new_track_t(); - m_mtpTrackHash.value( track )->item_id = 0; - m_mtpTrackHash.value( track )->parent_id = m_copyParentId; - m_mtpTrackHash.value( track )->storage_id = 0; // default storage id -} - -void -MtpHandler::prepareToPlay( Meta::MediaDeviceTrackPtr &track ) -{ - DEBUG_BLOCK - KUrl url; - if( m_cachedTracks.contains( track ) ) - { - debug() << "File is already copied, simply return"; - //m_playableUrl = KUrl::fromPath( m_playableUrl ); - } - else - { - QString tempPath = setTempFile( track, libGetType( track ) ); - track->setPlayableUrl( tempPath ); - - debug() << "Beginning temporary file copy"; -// m_tempfile.open(); - bool success = !(getTrackToFile( m_mtpTrackHash.value( track )->item_id , track->playableUrl().path() ) ); - debug() << "File transfer complete"; - if( success ) - { - debug() << "File transfer successful!"; - //m_playableUrl = KUrl::fromPath( m_playableUrl ); - } - else - { - debug() << "File transfer failed!"; - //m_playableUrl = KUrl::fromPath( "" ); - m_cachedTracks.remove( track ); - } - } -} - -QString -MtpHandler::setTempFile( Meta::MediaDeviceTrackPtr &track, const QString &format ) -{ - m_cachedTracks[ track ] = new KTemporaryFile(); - m_cachedTracks.value( track )->setSuffix( ('.' + format) ); // set suffix based on info from libmtp - if (!m_cachedTracks.value( track )->open()) - return QString(); - - QFileInfo tempFileInfo( *(m_cachedTracks.value( track ) ) ); // get info for path - QString tempPath = tempFileInfo.absoluteFilePath(); // path - - m_cachedTracks.value( track )->setAutoRemove( true ); - - return tempPath; -} - - -void -MtpHandler::slotDeviceMatchSucceeded( ThreadWeaver::Job* job ) -{ - DEBUG_BLOCK - if( !m_memColl ) // try to fix BUG:279966 - return; - - if ( job->success() ) - { - getDeviceInfo(); -// debug() << "Device matches serial, emitting succeeded()"; - m_memColl->slotAttemptConnectionDone( true ); - } - else - m_memColl->slotAttemptConnectionDone( false ); -} - -void -MtpHandler::slotDeviceMatchFailed( ThreadWeaver::Job* job ) -{ - DEBUG_BLOCK - if( !m_memColl ) // try to fix BUG:279966 - return; - - debug() << "Running slot device match failed"; - disconnect( job, SIGNAL(done(ThreadWeaver::Job*)), this, SLOT(slotDeviceMatchSucceeded()) ); - m_memColl->slotAttemptConnectionDone( false ); -} - -void -MtpHandler::updateTrack( Meta::MediaDeviceTrackPtr &track ) -{ - DEBUG_BLOCK - - // pull out track struct to prepare for update - - LIBMTP_track_t *mtptrack = m_mtpTrackHash.value( track ); - - // commence update on device - - int failed = LIBMTP_Update_Track_Metadata( m_device, mtptrack ); - - if ( !failed ) - debug() << "Metadata update succeeded!"; - - else - debug() << "Failed to update metadata"; -} - -/// Capability-related functions - -bool -MtpHandler::hasCapabilityInterface( Handler::Capability::Type type ) const -{ - switch( type ) - { - case Handler::Capability::Readable: - return true; - case Handler::Capability::Playlist: - return true; - case Handler::Capability::Writable: - return true; - - default: - return false; - } -} - -Handler::Capability* -MtpHandler::createCapabilityInterface( Handler::Capability::Type type ) -{ - switch( type ) - { - case Handler::Capability::Readable: - return new Handler::MtpReadCapability( this ); - case Handler::Capability::Playlist: - return new Handler::MtpPlaylistCapability( this ); - case Handler::Capability::Writable: - return new Handler::MtpWriteCapability( this ); - - default: - return 0; - } -} - -WorkerThread::WorkerThread( int numrawdevices, LIBMTP_raw_device_t* rawdevices, MtpHandler* handler ) - : ThreadWeaver::Job() - , m_success( false ) - , m_numrawdevices( numrawdevices ) - , m_rawdevices( rawdevices ) - , m_handler( handler ) -{ - connect( this, SIGNAL(failed(ThreadWeaver::Job*)), m_handler, SLOT(slotDeviceMatchFailed(ThreadWeaver::Job*)) ); - connect( this, SIGNAL(done(ThreadWeaver::Job*)), m_handler, SLOT(slotDeviceMatchSucceeded(ThreadWeaver::Job*)) ); - connect( this, SIGNAL(done(ThreadWeaver::Job*)), this, SLOT(deleteLater()) ); -} - -WorkerThread::~WorkerThread() -{ - //nothing to do -} - -bool -WorkerThread::success() const -{ - return m_success; -} - -void -WorkerThread::run() -{ - m_success = m_handler->iterateRawDevices( m_numrawdevices, m_rawdevices ); -} -/* -void -MtpHandler::slotCopyNextTrackFailed( ThreadWeaver::Job* job ) -{ - Q_UNUSED( job ); - m_copyFailed = true; - QString error = "Job Failed"; - m_tracksFailed.insert( m_lastTrackCopied, error ); - - copyNextTrackToDevice(); -} - -void -MtpHandler::slotCopyNextTrackToDevice( ThreadWeaver::Job* job ) -{ - if ( job->success() ) - { - emit incrementProgress(); - } - else - { - m_copyFailed = true; - QString error = "MTP copy error"; - m_tracksFailed.insert( m_lastTrackCopied, error ); - } - - copyNextTrackToDevice(); -} - -CopyWorkerThread::CopyWorkerThread( const Meta::TrackPtr &track, MtpHandler* handler ) - : ThreadWeaver::Job() - , m_success( false ) - , m_track( track ) - , m_handler( handler ) -{ - connect( this, SIGNAL(failed(ThreadWeaver::Job*)), m_handler, SLOT(slotCopyNextTrackFailed(ThreadWeaver::Job*)) ); - connect( this, SIGNAL(done(ThreadWeaver::Job*)), m_handler, SLOT(slotCopyNextTrackToDevice(ThreadWeaver::Job*)) ); - connect( this, SIGNAL(done(ThreadWeaver::Job*)), this, SLOT(deleteLater()) ); -} - -CopyWorkerThread::~CopyWorkerThread() -{ - //nothing to do -} - -bool -CopyWorkerThread::success() const -{ - return m_success; -} - -void -CopyWorkerThread::run() -{ - m_success = m_handler->privateCopyTrackToDevice( m_track ); -} -*/ diff --git a/amarok/src/core-impl/collections/mtpcollection/handler/MtpHandler.h b/amarok/src/core-impl/collections/mtpcollection/handler/MtpHandler.h deleted file mode 100644 index 47a16206..00000000 --- a/amarok/src/core-impl/collections/mtpcollection/handler/MtpHandler.h +++ /dev/null @@ -1,276 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2006 Andy Kelk * - * Copyright (c) 2008 Alejandro Wainzinger * - * Copyright (c) 2009 Mark Kretschmann * - * * - * This program 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 2 of the License, or (at your option) version 3 or * - * any later version accepted by the membership of KDE e.V. (or its successor approved * - * by the membership of KDE e.V.), which shall act as a proxy defined in Section 14 of * - * version 3 of the license. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef MTPHANDLER_H -#define MTPHANDLER_H - -#include - -#include "MtpPlaylistCapability.h" -#include "MtpReadCapability.h" -#include "MtpWriteCapability.h" - -#include "MediaDeviceMeta.h" -#include "MediaDeviceHandler.h" - -#include -#include -#include -#include - -#include -#include -#include -#include -#include - - -class QString; -class QMutex; -class QStringList; - -namespace Collections { - class MtpCollection; -} - -namespace Meta -{ -typedef QMultiMap TitleMap; -class WorkerThread; - -/* The libmtp backend for all Mtp calls */ -class MtpHandler : public MediaDeviceHandler -{ - Q_OBJECT - - public: - MtpHandler( Collections::MtpCollection *mc ); - virtual ~MtpHandler(); - - friend class WorkerThread; - - virtual void init(); // collection - virtual bool isWritable() const; - - virtual void getCopyableUrls( const Meta::TrackList &tracks ); - - virtual QString prettyName() const; - - virtual void prepareToPlay( Meta::MediaDeviceTrackPtr &track ); - - /// Capability-related methods - - virtual bool hasCapabilityInterface( Handler::Capability::Type type ) const; - virtual Handler::Capability* createCapabilityInterface( Handler::Capability::Type type ); - - friend class Handler::MtpPlaylistCapability; - friend class Handler::MtpReadCapability; - friend class Handler::MtpWriteCapability; - - protected: - /* Parsing of Tracks on Device */ - virtual void prepareToParseTracks(); - virtual bool isEndOfParseTracksList(); - virtual void prepareToParseNextTrack(); - virtual void nextTrackToParse(); - - virtual void setAssociateTrack( const Meta::MediaDeviceTrackPtr track ); - - virtual void prepareToParsePlaylists(); - virtual bool isEndOfParsePlaylistsList(); - virtual void prepareToParseNextPlaylist(); - virtual void nextPlaylistToParse(); - - virtual bool shouldNotParseNextPlaylist(); - - virtual void prepareToParsePlaylistTracks(); - virtual bool isEndOfParsePlaylist(); - virtual void prepareToParseNextPlaylistTrack(); - virtual void nextPlaylistTrackToParse(); - - virtual QStringList supportedFormats(); - - virtual void findPathToCopy( const Meta::TrackPtr &srcTrack, const Meta::MediaDeviceTrackPtr &destTrack ); - virtual bool libCopyTrack( const Meta::TrackPtr &srcTrack, Meta::MediaDeviceTrackPtr &destTrack ); - virtual bool libDeleteTrackFile( const Meta::MediaDeviceTrackPtr &track ); - virtual void libCreateTrack( const Meta::MediaDeviceTrackPtr &track ); - virtual void libDeleteTrack( const Meta::MediaDeviceTrackPtr &track ); - - virtual Meta::MediaDeviceTrackPtr libGetTrackPtrForTrackStruct(); - - virtual QString libGetPlaylistName(); - virtual void setAssociatePlaylist( const Playlists::MediaDevicePlaylistPtr &playlist ); - virtual void libSavePlaylist( const Playlists::MediaDevicePlaylistPtr &playlist, const QString& name ); - virtual void deletePlaylist( const Playlists::MediaDevicePlaylistPtr &playlist ); - virtual void renamePlaylist( const Playlists::MediaDevicePlaylistPtr &playlist ); - - virtual void addTrackInDB( const Meta::MediaDeviceTrackPtr &track ) { Q_UNUSED( track ) } - virtual void removeTrackFromDB( const Meta::MediaDeviceTrackPtr &track ) { Q_UNUSED( track ) } - virtual void setDatabaseChanged(); - - virtual QString libGetTitle( const Meta::MediaDeviceTrackPtr &track ); - virtual QString libGetAlbum( const Meta::MediaDeviceTrackPtr &track ); - virtual QString libGetArtist( const Meta::MediaDeviceTrackPtr &track ); - virtual QString libGetAlbumArtist( const Meta::MediaDeviceTrackPtr &track ); - virtual QString libGetComposer( const Meta::MediaDeviceTrackPtr &track ); - virtual QString libGetGenre( const Meta::MediaDeviceTrackPtr &track ); - virtual int libGetYear( const Meta::MediaDeviceTrackPtr &track ); - virtual qint64 libGetLength( const Meta::MediaDeviceTrackPtr &track ); - virtual int libGetTrackNumber( const Meta::MediaDeviceTrackPtr &track ); - virtual QString libGetComment( const Meta::MediaDeviceTrackPtr &track ); - virtual int libGetDiscNumber( const Meta::MediaDeviceTrackPtr &track ); - virtual int libGetBitrate( const Meta::MediaDeviceTrackPtr &track ); - virtual int libGetSamplerate( const Meta::MediaDeviceTrackPtr &track ); - virtual qreal libGetBpm( const Meta::MediaDeviceTrackPtr &track ); - virtual int libGetFileSize( const Meta::MediaDeviceTrackPtr &track ); - virtual int libGetPlayCount( const Meta::MediaDeviceTrackPtr &track ); - virtual QDateTime libGetLastPlayed( const Meta::MediaDeviceTrackPtr &track ); - virtual int libGetRating( const Meta::MediaDeviceTrackPtr &track ) ; - virtual QString libGetType( const Meta::MediaDeviceTrackPtr &track ); - virtual KUrl libGetPlayableUrl( const Meta::MediaDeviceTrackPtr &track ); - - virtual float usedCapacity() const; - virtual float totalCapacity() const; - - virtual void libSetTitle( Meta::MediaDeviceTrackPtr &track, const QString& title ); - virtual void libSetAlbum( Meta::MediaDeviceTrackPtr &track, const QString& album ); - virtual void libSetArtist( Meta::MediaDeviceTrackPtr &track, const QString& artist ); - virtual void libSetAlbumArtist( Meta::MediaDeviceTrackPtr &track, const QString& albumArtist ); - virtual void libSetComposer( Meta::MediaDeviceTrackPtr &track, const QString& composer ); - virtual void libSetGenre( Meta::MediaDeviceTrackPtr &track, const QString& genre ); - virtual void libSetYear( Meta::MediaDeviceTrackPtr &track, const QString& year ); - virtual void libSetLength( Meta::MediaDeviceTrackPtr &track, int length ); - virtual void libSetTrackNumber( Meta::MediaDeviceTrackPtr &track, int tracknum ); - virtual void libSetComment( Meta::MediaDeviceTrackPtr &track, const QString& comment ); - virtual void libSetDiscNumber( Meta::MediaDeviceTrackPtr &track, int discnum ); - virtual void libSetBitrate( Meta::MediaDeviceTrackPtr &track, int bitrate ); - virtual void libSetSamplerate( Meta::MediaDeviceTrackPtr &track, int samplerate ); - virtual void libSetBpm( Meta::MediaDeviceTrackPtr &track, qreal bpm ); - virtual void libSetFileSize( Meta::MediaDeviceTrackPtr &track, int filesize ); - virtual void libSetPlayCount( Meta::MediaDeviceTrackPtr &track, int playcount ); - virtual void libSetLastPlayed( Meta::MediaDeviceTrackPtr &track, const QDateTime &lastplayed ); - virtual void libSetRating( Meta::MediaDeviceTrackPtr &track, int rating ) ; - virtual void libSetType( Meta::MediaDeviceTrackPtr &track, const QString& type ); - virtual void libSetPlayableUrl( Meta::MediaDeviceTrackPtr &destTrack, const Meta::TrackPtr &srcTrack ); - - virtual void prepareToCopy() {} - virtual void prepareToDelete() {} - - /// libmtp-specific - private slots: - void slotDeviceMatchSucceeded( ThreadWeaver::Job* job ); - void slotDeviceMatchFailed( ThreadWeaver::Job* job ); - - private: - bool iterateRawDevices( int numrawdevices, LIBMTP_raw_device_t* rawdevices ); - void getDeviceInfo(); - - void terminate(); - - int getTrackToFile( const uint32_t id, const QString & filename ); - - // Some internal stuff that must be public due to libmtp being in C - static int progressCallback( uint64_t const sent, uint64_t const total, void const * const data ); - - // file-copying related functions - uint32_t checkFolderStructure( const Meta::TrackPtr track, bool create ); - uint32_t getDefaultParentId( void ); - uint32_t folderNameToID( char *name, LIBMTP_folder_t *folderlist ); - uint32_t subfolderNameToID( const char *name, LIBMTP_folder_t *folderlist, uint32_t parent_id ); - uint32_t createFolder( const char *name, uint32_t parent_id ); - void updateFolders( void ); - - QString setTempFile( Meta::MediaDeviceTrackPtr &track, const QString &format ); - - virtual void updateTrack( Meta::MediaDeviceTrackPtr &track ); - - // mtp database - LIBMTP_mtpdevice_t *m_device; - - float m_capacity; - - QMap mtpFileTypes; - - uint32_t m_default_parent_folder; - LIBMTP_folder_t *m_folders; - QString m_folderStructure; - QString m_format; - QString m_name; - QStringList m_supportedFiles; - - QMutex m_critical_mutex; - - // KIO-related Vars (to be moved elsewhere eventually) - bool m_isCanceled; - bool m_wait; - bool m_dbChanged; - - LIBMTP_track_t* m_currentTrackList; - LIBMTP_track_t* m_currentTrack; - LIBMTP_playlist_t* m_currentPlaylistList; - LIBMTP_playlist_t* m_currentPlaylist; - - QHash m_mtpPlaylisthash; - - uint32_t m_trackcounter; - - // Hash that associates an LIBMTP_track_t* to every Track* - - QHash m_mtpTrackHash; - - // Keeps track of which tracks have been copied/cached for playing - - QHash m_cachedTracks; - - // Maps id's to tracks - - QHash m_idTrackHash; - - // parentid calculated for new track copied to device - - uint32_t m_copyParentId; - - // Used as temporary location for copying files from mtp - - KTempDir *m_tempDir; -}; - -class WorkerThread : public ThreadWeaver::Job -{ - Q_OBJECT - - public: - WorkerThread( int numrawdevices, LIBMTP_raw_device_t* rawdevices, MtpHandler* handler ); - virtual ~WorkerThread(); - - virtual bool success() const; - - protected: - virtual void run(); - - private: - bool m_success; - int m_numrawdevices; - LIBMTP_raw_device_t* m_rawdevices; - MtpHandler *m_handler; -}; - -} -#endif diff --git a/amarok/src/core-impl/collections/mtpcollection/handler/capabilities/MtpPlaylistCapability.cpp b/amarok/src/core-impl/collections/mtpcollection/handler/capabilities/MtpPlaylistCapability.cpp deleted file mode 100644 index 84d7ac22..00000000 --- a/amarok/src/core-impl/collections/mtpcollection/handler/capabilities/MtpPlaylistCapability.cpp +++ /dev/null @@ -1,112 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Alejandro Wainzinger * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "MtpReadCapability.h" -#include "MtpHandler.h" - -using namespace Handler; - -MtpPlaylistCapability::MtpPlaylistCapability( Meta::MtpHandler *handler ) - : Handler::PlaylistCapability( handler ) - , m_handler( handler ) -{ -} - -void -MtpPlaylistCapability::prepareToParsePlaylists() -{ - m_handler->prepareToParsePlaylists(); -} - -bool -MtpPlaylistCapability::isEndOfParsePlaylistsList() -{ - return m_handler->isEndOfParsePlaylistsList(); -} - -void -MtpPlaylistCapability::prepareToParseNextPlaylist() -{ - m_handler->prepareToParseNextPlaylist(); -} - -void -MtpPlaylistCapability::nextPlaylistToParse() -{ - m_handler->nextPlaylistToParse(); -} - -bool -MtpPlaylistCapability::shouldNotParseNextPlaylist() -{ - return m_handler->shouldNotParseNextPlaylist(); -} - -void -MtpPlaylistCapability::prepareToParsePlaylistTracks() -{ - m_handler->prepareToParsePlaylistTracks(); -} - -bool -MtpPlaylistCapability::isEndOfParsePlaylist() -{ - return m_handler->isEndOfParsePlaylist(); -} - -void -MtpPlaylistCapability::prepareToParseNextPlaylistTrack() -{ - m_handler->prepareToParseNextPlaylistTrack(); -} - -void -MtpPlaylistCapability::nextPlaylistTrackToParse() -{ - m_handler->nextPlaylistTrackToParse(); -} - -Meta::MediaDeviceTrackPtr -MtpPlaylistCapability::libGetTrackPtrForTrackStruct() -{ - return m_handler->libGetTrackPtrForTrackStruct(); -} - -QString -MtpPlaylistCapability::libGetPlaylistName() -{ - return m_handler->libGetPlaylistName(); -} - -void -MtpPlaylistCapability::savePlaylist( const Playlists::MediaDevicePlaylistPtr &playlist, const QString& name ) -{ - m_handler->libSavePlaylist( playlist, name ); -} - -void -MtpPlaylistCapability::deletePlaylist( const Playlists::MediaDevicePlaylistPtr &playlist ) -{ - m_handler->deletePlaylist( playlist ); -} - -void -MtpPlaylistCapability::renamePlaylist( const Playlists::MediaDevicePlaylistPtr &playlist ) -{ - m_handler->renamePlaylist( playlist ); -} - -#include "moc_MtpPlaylistCapability.cpp" diff --git a/amarok/src/core-impl/collections/mtpcollection/handler/capabilities/MtpPlaylistCapability.h b/amarok/src/core-impl/collections/mtpcollection/handler/capabilities/MtpPlaylistCapability.h deleted file mode 100644 index 2204ee7c..00000000 --- a/amarok/src/core-impl/collections/mtpcollection/handler/capabilities/MtpPlaylistCapability.h +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Alejandro Wainzinger * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef MTPPLAYLISTCAPABILITY_H -#define MTPPLAYLISTCAPABILITY_H - -#include "mediadevicecollection_export.h" -#include "PlaylistCapability.h" - -namespace Meta { - class MtpHandler; -} - -namespace Handler -{ - -class MtpPlaylistCapability : public PlaylistCapability -{ - Q_OBJECT - - public: - MtpPlaylistCapability( Meta::MtpHandler *handler ); - - virtual void prepareToParsePlaylists(); - virtual bool isEndOfParsePlaylistsList(); - virtual void prepareToParseNextPlaylist(); - virtual void nextPlaylistToParse(); - virtual bool shouldNotParseNextPlaylist(); - virtual void prepareToParsePlaylistTracks(); - virtual bool isEndOfParsePlaylist(); - virtual void prepareToParseNextPlaylistTrack(); - virtual void nextPlaylistTrackToParse(); - - virtual void savePlaylist( const Playlists::MediaDevicePlaylistPtr &playlist, const QString& name ); - virtual void deletePlaylist( const Playlists::MediaDevicePlaylistPtr &playlist ); - virtual void renamePlaylist( const Playlists::MediaDevicePlaylistPtr &playlist ); - - virtual Meta::MediaDeviceTrackPtr libGetTrackPtrForTrackStruct(); - virtual QString libGetPlaylistName(); - - private: - Meta::MtpHandler *m_handler; -}; - -} - -#endif diff --git a/amarok/src/core-impl/collections/mtpcollection/handler/capabilities/MtpReadCapability.cpp b/amarok/src/core-impl/collections/mtpcollection/handler/capabilities/MtpReadCapability.cpp deleted file mode 100644 index 267df92d..00000000 --- a/amarok/src/core-impl/collections/mtpcollection/handler/capabilities/MtpReadCapability.cpp +++ /dev/null @@ -1,195 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Alejandro Wainzinger * - * Copyright (c) 2009 Mark Kretschmann * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "MtpReadCapability.h" -#include "MtpHandler.h" - -using namespace Handler; - - -MtpReadCapability::MtpReadCapability( Meta::MtpHandler *handler ) - : Handler::ReadCapability( handler ) - , m_handler( handler ) -{} - -void -MtpReadCapability::prepareToParseTracks() -{ - if( m_handler ) - m_handler.data()->prepareToParseTracks(); -} - -bool -MtpReadCapability::isEndOfParseTracksList() -{ - return m_handler.data()->isEndOfParseTracksList(); -} - -void -MtpReadCapability::prepareToParseNextTrack() -{ - if( m_handler ) - m_handler.data()->prepareToParseNextTrack(); -} - -void -MtpReadCapability::nextTrackToParse() -{ - if( m_handler ) - m_handler.data()->nextTrackToParse(); -} - -void -MtpReadCapability::setAssociateTrack( const Meta::MediaDeviceTrackPtr track ) -{ - if( m_handler ) - m_handler.data()->setAssociateTrack( track ); -} - -QString -MtpReadCapability::libGetTitle( const Meta::MediaDeviceTrackPtr &track ) -{ - return m_handler.data()->libGetTitle( track ); -} - -QString -MtpReadCapability::libGetAlbum( const Meta::MediaDeviceTrackPtr &track ) -{ - return m_handler.data()->libGetAlbum( track ); -} - -QString -MtpReadCapability::libGetArtist( const Meta::MediaDeviceTrackPtr &track ) -{ - return m_handler.data()->libGetArtist( track ); -} - -QString -MtpReadCapability::libGetAlbumArtist( const Meta::MediaDeviceTrackPtr &track ) -{ - return m_handler.data()->libGetAlbumArtist( track ); -} - -QString -MtpReadCapability::libGetComposer( const Meta::MediaDeviceTrackPtr &track ) -{ - return m_handler.data()->libGetComposer( track ); -} - -QString -MtpReadCapability::libGetGenre( const Meta::MediaDeviceTrackPtr &track ) -{ - return m_handler.data()->libGetGenre( track ); -} - -int -MtpReadCapability::libGetYear( const Meta::MediaDeviceTrackPtr &track ) -{ - return m_handler.data()->libGetYear( track ); -} - -qint64 -MtpReadCapability::libGetLength( const Meta::MediaDeviceTrackPtr &track ) -{ - return m_handler.data()->libGetLength( track ); -} - -int -MtpReadCapability::libGetTrackNumber( const Meta::MediaDeviceTrackPtr &track ) -{ - return m_handler.data()->libGetTrackNumber( track ); -} - -QString -MtpReadCapability::libGetComment( const Meta::MediaDeviceTrackPtr &track ) -{ - return m_handler.data()->libGetComment( track ); -} - -int -MtpReadCapability::libGetDiscNumber( const Meta::MediaDeviceTrackPtr &track ) -{ - return m_handler.data()->libGetDiscNumber( track ); -} - -int -MtpReadCapability::libGetBitrate( const Meta::MediaDeviceTrackPtr &track ) -{ - return m_handler.data()->libGetBitrate( track ); -} - -int -MtpReadCapability::libGetSamplerate( const Meta::MediaDeviceTrackPtr &track ) -{ - return m_handler.data()->libGetSamplerate( track ); -} - -qreal -MtpReadCapability::libGetBpm( const Meta::MediaDeviceTrackPtr &track ) -{ - return m_handler.data()->libGetBpm( track ); -} - -int -MtpReadCapability::libGetFileSize( const Meta::MediaDeviceTrackPtr &track ) -{ - return m_handler.data()->libGetFileSize( track ); -} - -int -MtpReadCapability::libGetPlayCount( const Meta::MediaDeviceTrackPtr &track ) -{ - return m_handler.data()->libGetPlayCount( track ); -} - -QDateTime -MtpReadCapability::libGetLastPlayed( const Meta::MediaDeviceTrackPtr &track ) -{ - return m_handler.data()->libGetLastPlayed( track ); -} - -int -MtpReadCapability::libGetRating( const Meta::MediaDeviceTrackPtr &track ) -{ - return m_handler.data()->libGetRating( track ); -} - -QString -MtpReadCapability::libGetType( const Meta::MediaDeviceTrackPtr &track ) -{ - return m_handler.data()->libGetType( track ); -} - -KUrl -MtpReadCapability::libGetPlayableUrl( const Meta::MediaDeviceTrackPtr &track ) -{ - return m_handler.data()->libGetPlayableUrl( track ); -} - -float -MtpReadCapability::usedCapacity() const -{ - return m_handler.data()->usedCapacity(); -} - -float -MtpReadCapability::totalCapacity() const -{ - return m_handler.data()->totalCapacity(); -} - -#include "moc_MtpReadCapability.cpp" diff --git a/amarok/src/core-impl/collections/mtpcollection/handler/capabilities/MtpReadCapability.h b/amarok/src/core-impl/collections/mtpcollection/handler/capabilities/MtpReadCapability.h deleted file mode 100644 index 61a459cf..00000000 --- a/amarok/src/core-impl/collections/mtpcollection/handler/capabilities/MtpReadCapability.h +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Alejandro Wainzinger * - * Copyright (c) 2009 Mark Kretschmann * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef MTPREADCAPABILITY_H -#define MTPREADCAPABILITY_H - -#include "mediadevicecollection_export.h" -#include "ReadCapability.h" - -#include - - -namespace Meta { - class MtpHandler; -} - -namespace Handler -{ - -class MtpReadCapability : public ReadCapability -{ - Q_OBJECT - - public: - MtpReadCapability( Meta::MtpHandler *handler ); - - virtual void prepareToParseTracks(); - - virtual bool isEndOfParseTracksList(); - - virtual void prepareToParseNextTrack(); - - virtual void nextTrackToParse(); - - virtual void setAssociateTrack( const Meta::MediaDeviceTrackPtr track ); - - virtual QString libGetTitle( const Meta::MediaDeviceTrackPtr &track ); - virtual QString libGetAlbum( const Meta::MediaDeviceTrackPtr &track ); - virtual QString libGetArtist( const Meta::MediaDeviceTrackPtr &track ); - virtual QString libGetAlbumArtist( const Meta::MediaDeviceTrackPtr &track ); - virtual QString libGetComposer( const Meta::MediaDeviceTrackPtr &track ); - virtual QString libGetGenre( const Meta::MediaDeviceTrackPtr &track ); - virtual int libGetYear( const Meta::MediaDeviceTrackPtr &track ); - virtual qint64 libGetLength( const Meta::MediaDeviceTrackPtr &track ); - virtual int libGetTrackNumber( const Meta::MediaDeviceTrackPtr &track ); - virtual QString libGetComment( const Meta::MediaDeviceTrackPtr &track ); - virtual int libGetDiscNumber( const Meta::MediaDeviceTrackPtr &track ); - virtual int libGetBitrate( const Meta::MediaDeviceTrackPtr &track ); - virtual int libGetSamplerate( const Meta::MediaDeviceTrackPtr &track ); - virtual qreal libGetBpm( const Meta::MediaDeviceTrackPtr &track ); - virtual int libGetFileSize( const Meta::MediaDeviceTrackPtr &track ); - virtual int libGetPlayCount( const Meta::MediaDeviceTrackPtr &track ); - virtual QDateTime libGetLastPlayed( const Meta::MediaDeviceTrackPtr &track ); - virtual int libGetRating( const Meta::MediaDeviceTrackPtr &track ); - virtual QString libGetType( const Meta::MediaDeviceTrackPtr &track ); - virtual KUrl libGetPlayableUrl( const Meta::MediaDeviceTrackPtr &track ); - - virtual float usedCapacity() const; - virtual float totalCapacity() const; - - private: - QWeakPointer m_handler; -}; - -} - -#endif diff --git a/amarok/src/core-impl/collections/mtpcollection/handler/capabilities/MtpWriteCapability.cpp b/amarok/src/core-impl/collections/mtpcollection/handler/capabilities/MtpWriteCapability.cpp deleted file mode 100644 index ff9442e4..00000000 --- a/amarok/src/core-impl/collections/mtpcollection/handler/capabilities/MtpWriteCapability.cpp +++ /dev/null @@ -1,250 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Alejandro Wainzinger * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "MtpWriteCapability.h" -#include "MtpHandler.h" - -using namespace Handler; - -MtpWriteCapability::MtpWriteCapability( Meta::MtpHandler *handler ) - : Handler::WriteCapability( handler ) - , m_handler( handler ) -{ -} - -QStringList -MtpWriteCapability::supportedFormats() -{ - return m_handler->supportedFormats(); -} - -void -MtpWriteCapability::findPathToCopy( const Meta::TrackPtr &srcTrack, const Meta::MediaDeviceTrackPtr &destTrack ) -{ - m_handler->findPathToCopy( srcTrack, destTrack ); -} - - -bool -MtpWriteCapability::libCopyTrack( const Meta::TrackPtr &srcTrack, Meta::MediaDeviceTrackPtr &destTrack ) -{ - return m_handler->libCopyTrack( srcTrack, destTrack ); -} - - -bool -MtpWriteCapability::libDeleteTrackFile( const Meta::MediaDeviceTrackPtr &track ) -{ - return m_handler->libDeleteTrackFile( track ); -} - - -void -MtpWriteCapability::libCreateTrack( const Meta::MediaDeviceTrackPtr &track ) -{ - m_handler->libCreateTrack( track ); -} - - -void -MtpWriteCapability::libDeleteTrack( const Meta::MediaDeviceTrackPtr &track ) -{ - m_handler->libDeleteTrack( track ); -} - - -void -MtpWriteCapability::addTrackInDB( const Meta::MediaDeviceTrackPtr &track ) -{ - m_handler->addTrackInDB( track ); -} - - -void -MtpWriteCapability::removeTrackFromDB( const Meta::MediaDeviceTrackPtr &track ) -{ - m_handler->removeTrackFromDB( track ); -} - - -void -MtpWriteCapability::setDatabaseChanged() -{ - m_handler->setDatabaseChanged(); -} - - -void -MtpWriteCapability::libSetTitle( Meta::MediaDeviceTrackPtr &track, const QString& title ) -{ - m_handler->libSetTitle( track, title ); -} - - -void -MtpWriteCapability::libSetAlbum( Meta::MediaDeviceTrackPtr &track, const QString& album ) -{ - m_handler->libSetAlbum( track, album ); -} - - -void -MtpWriteCapability::libSetArtist( Meta::MediaDeviceTrackPtr &track, const QString& artist ) -{ - m_handler->libSetArtist( track, artist ); -} - -void -MtpWriteCapability::libSetAlbumArtist( Meta::MediaDeviceTrackPtr &track, const QString &albumArtist ) -{ - m_handler->libSetAlbumArtist( track, albumArtist ); -} - -void -MtpWriteCapability::libSetComposer( Meta::MediaDeviceTrackPtr &track, const QString& composer ) -{ - m_handler->libSetComposer( track, composer ); -} - - -void -MtpWriteCapability::libSetGenre( Meta::MediaDeviceTrackPtr &track, const QString& genre ) -{ - m_handler->libSetGenre( track, genre ); -} - - -void -MtpWriteCapability::libSetYear( Meta::MediaDeviceTrackPtr &track, const QString& year ) -{ - m_handler->libSetYear( track, year ); -} - - -void -MtpWriteCapability::libSetLength( Meta::MediaDeviceTrackPtr &track, int length ) -{ - m_handler->libSetLength( track, length ); -} - - -void -MtpWriteCapability::libSetTrackNumber( Meta::MediaDeviceTrackPtr &track, int tracknum ) -{ - m_handler->libSetTrackNumber( track, tracknum ); -} - - -void -MtpWriteCapability::libSetComment( Meta::MediaDeviceTrackPtr &track, const QString& comment ) -{ - m_handler->libSetComment( track, comment ); -} - - -void -MtpWriteCapability::libSetDiscNumber( Meta::MediaDeviceTrackPtr &track, int discnum ) -{ - m_handler->libSetDiscNumber( track, discnum ); -} - - -void -MtpWriteCapability::libSetBitrate( Meta::MediaDeviceTrackPtr &track, int bitrate ) -{ - m_handler->libSetBitrate( track, bitrate ); -} - - -void -MtpWriteCapability::libSetSamplerate( Meta::MediaDeviceTrackPtr &track, int samplerate ) -{ - m_handler->libSetSamplerate( track, samplerate ); -} - - -void -MtpWriteCapability::libSetBpm( Meta::MediaDeviceTrackPtr &track, qreal bpm ) -{ - m_handler->libSetBpm( track, bpm ); -} - - -void -MtpWriteCapability::libSetFileSize( Meta::MediaDeviceTrackPtr &track, int filesize ) -{ - m_handler->libSetFileSize( track, filesize ); -} - - -void -MtpWriteCapability::libSetPlayCount( Meta::MediaDeviceTrackPtr &track, int playcount ) -{ - m_handler->libSetPlayCount( track, playcount ); -} - -void -MtpWriteCapability::libSetLastPlayed( Meta::MediaDeviceTrackPtr &track, const QDateTime &lastplayed ) -{ - m_handler->libSetLastPlayed( track, lastplayed ); -} - -void -MtpWriteCapability::libSetRating( Meta::MediaDeviceTrackPtr &track, int rating ) -{ - m_handler->libSetRating( track, rating ); -} - -void -MtpWriteCapability::libSetType( Meta::MediaDeviceTrackPtr &track, const QString& type ) -{ - m_handler->libSetType( track, type ); -} - -void -MtpWriteCapability::libSetPlayableUrl( Meta::MediaDeviceTrackPtr &destTrack, const Meta::TrackPtr &srcTrack ) -{ - m_handler->libSetPlayableUrl( destTrack, srcTrack ); -} - -void -MtpWriteCapability::libSetCoverArt( Meta::MediaDeviceTrackPtr &track, const QImage &cover ) -{ - AMAROK_NOTIMPLEMENTED - Q_UNUSED( track ) - Q_UNUSED( cover ) -} - -void -MtpWriteCapability::prepareToCopy() -{ - m_handler->prepareToCopy(); -} - - -void -MtpWriteCapability::prepareToDelete() -{ - m_handler->prepareToDelete(); -} - -void -MtpWriteCapability::updateTrack( Meta::MediaDeviceTrackPtr &track ) -{ - m_handler->updateTrack( track ); -} - -#include "moc_MtpWriteCapability.cpp" diff --git a/amarok/src/core-impl/collections/mtpcollection/handler/capabilities/MtpWriteCapability.h b/amarok/src/core-impl/collections/mtpcollection/handler/capabilities/MtpWriteCapability.h deleted file mode 100644 index bb53d6ca..00000000 --- a/amarok/src/core-impl/collections/mtpcollection/handler/capabilities/MtpWriteCapability.h +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Alejandro Wainzinger * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef MTPWRITECAPABILITY_H -#define MTPWRITECAPABILITY_H - -#include "mediadevicecollection_export.h" -#include "WriteCapability.h" - -namespace Meta { - class MtpHandler; -} - -namespace Handler -{ - -class MtpWriteCapability : public WriteCapability -{ - Q_OBJECT - public: - MtpWriteCapability( Meta::MtpHandler *handler ); - - virtual QStringList supportedFormats(); - - virtual void findPathToCopy( const Meta::TrackPtr &srcTrack, const Meta::MediaDeviceTrackPtr &destTrack ); - - virtual bool libCopyTrack( const Meta::TrackPtr &srcTrack, Meta::MediaDeviceTrackPtr &destTrack ); - - virtual bool libDeleteTrackFile( const Meta::MediaDeviceTrackPtr &track ); - - virtual void libCreateTrack( const Meta::MediaDeviceTrackPtr &track ); - - virtual void libDeleteTrack( const Meta::MediaDeviceTrackPtr &track ); - - virtual void addTrackInDB( const Meta::MediaDeviceTrackPtr &track ); - - virtual void removeTrackFromDB( const Meta::MediaDeviceTrackPtr &track ); - - virtual void setDatabaseChanged(); - - virtual void libSetTitle( Meta::MediaDeviceTrackPtr &track, const QString& title ); - virtual void libSetAlbum( Meta::MediaDeviceTrackPtr &track, const QString& album ); - virtual void libSetArtist( Meta::MediaDeviceTrackPtr &track, const QString& artist ); - virtual void libSetAlbumArtist( Meta::MediaDeviceTrackPtr &track, const QString& albumArtist ); - virtual void libSetComposer( Meta::MediaDeviceTrackPtr &track, const QString& composer ); - virtual void libSetGenre( Meta::MediaDeviceTrackPtr &track, const QString& genre ); - virtual void libSetYear( Meta::MediaDeviceTrackPtr &track, const QString& year ); - virtual void libSetLength( Meta::MediaDeviceTrackPtr &track, int length ); - virtual void libSetTrackNumber( Meta::MediaDeviceTrackPtr &track, int tracknum ); - virtual void libSetComment( Meta::MediaDeviceTrackPtr &track, const QString& comment ); - virtual void libSetDiscNumber( Meta::MediaDeviceTrackPtr &track, int discnum ); - virtual void libSetBitrate( Meta::MediaDeviceTrackPtr &track, int bitrate ); - virtual void libSetSamplerate( Meta::MediaDeviceTrackPtr &track, int samplerate ); - virtual void libSetBpm( Meta::MediaDeviceTrackPtr &track, qreal bpm ); - virtual void libSetFileSize( Meta::MediaDeviceTrackPtr &track, int filesize ); - virtual void libSetPlayCount( Meta::MediaDeviceTrackPtr &track, int playcount ); - virtual void libSetLastPlayed( Meta::MediaDeviceTrackPtr &track, const QDateTime &lastplayed ); - virtual void libSetRating( Meta::MediaDeviceTrackPtr &track, int rating ) ; - virtual void libSetType( Meta::MediaDeviceTrackPtr &track, const QString& type ); - virtual void libSetPlayableUrl( Meta::MediaDeviceTrackPtr &destTrack, const Meta::TrackPtr &srcTrack ); - virtual void libSetCoverArt( Meta::MediaDeviceTrackPtr &track, const QImage &cover ); - - virtual void prepareToCopy(); - virtual void prepareToDelete(); - - virtual void updateTrack( Meta::MediaDeviceTrackPtr &track ); - - private: - Meta::MtpHandler *m_handler; -}; - -} - -#endif diff --git a/amarok/src/core-impl/collections/mtpcollection/support/MtpConnectionAssistant.cpp b/amarok/src/core-impl/collections/mtpcollection/support/MtpConnectionAssistant.cpp deleted file mode 100644 index 27795c5a..00000000 --- a/amarok/src/core-impl/collections/mtpcollection/support/MtpConnectionAssistant.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Alejandro Wainzinger * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "MtpConnectionAssistant.h" -#include "MtpDeviceInfo.h" - -#include "MediaDeviceCache.h" // for mountpoint - -#include "core/support/Debug.h" - -#include - -#include -#include - -MtpConnectionAssistant::~MtpConnectionAssistant() -{ -} - -bool -MtpConnectionAssistant::identify( const QString& udi ) -{ - DEBUG_BLOCK - - Solid::Device device; - - device = Solid::Device( udi ); - if( !device.is() ) - { - debug() << "Not a PMP"; - return false; - } - - Solid::PortableMediaPlayer *pmp = device.as(); - - debug() << "Supported Protocols: " << pmp->supportedProtocols(); - - return pmp->supportedProtocols().contains( "mtp" ); -} - - -MediaDeviceInfo* -MtpConnectionAssistant::deviceInfo( const QString& udi ) -{ - MediaDeviceInfo* info = new MtpDeviceInfo( udi ); - return info; -} - -#include "moc_MtpConnectionAssistant.cpp" diff --git a/amarok/src/core-impl/collections/mtpcollection/support/MtpConnectionAssistant.h b/amarok/src/core-impl/collections/mtpcollection/support/MtpConnectionAssistant.h deleted file mode 100644 index 96c0c1d7..00000000 --- a/amarok/src/core-impl/collections/mtpcollection/support/MtpConnectionAssistant.h +++ /dev/null @@ -1,36 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Alejandro Wainzinger * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef MTPCONNECTIONASSISTANT_H -#define MTPCONNECTIONASSISTANT_H - -#include "ConnectionAssistant.h" - -#include - -class MtpConnectionAssistant : public ConnectionAssistant -{ - Q_OBJECT - -public: - virtual ~MtpConnectionAssistant(); - - virtual bool identify( const QString& udi ); - virtual MediaDeviceInfo* deviceInfo( const QString& udi ); - -}; - -#endif // MTPCONNECTIONASSISTANT_H diff --git a/amarok/src/core-impl/collections/mtpcollection/support/MtpDeviceInfo.cpp b/amarok/src/core-impl/collections/mtpcollection/support/MtpDeviceInfo.cpp deleted file mode 100644 index 23191758..00000000 --- a/amarok/src/core-impl/collections/mtpcollection/support/MtpDeviceInfo.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Alejandro Wainzinger * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "MtpDeviceInfo.h" -#include "MediaDeviceInfo.h" - -MtpDeviceInfo::MtpDeviceInfo( QString udi ) -: MediaDeviceInfo() -{ - m_udi = udi; -} - -MtpDeviceInfo::~MtpDeviceInfo() -{ -} - -#include "moc_MtpDeviceInfo.cpp" diff --git a/amarok/src/core-impl/collections/mtpcollection/support/MtpDeviceInfo.h b/amarok/src/core-impl/collections/mtpcollection/support/MtpDeviceInfo.h deleted file mode 100644 index e2f82665..00000000 --- a/amarok/src/core-impl/collections/mtpcollection/support/MtpDeviceInfo.h +++ /dev/null @@ -1,33 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Alejandro Wainzinger * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef MTP_DEVICE_INFO_H -#define MTP_DEVICE_INFO_H - -#include "MediaDeviceInfo.h" - -class MtpDeviceInfo : public MediaDeviceInfo -{ - Q_OBJECT - public: - MtpDeviceInfo( QString udi ); - ~MtpDeviceInfo(); - - private: - -}; - -#endif diff --git a/amarok/src/core-impl/collections/playdarcollection/CMakeLists.txt b/amarok/src/core-impl/collections/playdarcollection/CMakeLists.txt deleted file mode 100644 index e536fa5d..00000000 --- a/amarok/src/core-impl/collections/playdarcollection/CMakeLists.txt +++ /dev/null @@ -1,24 +0,0 @@ -include_directories( ${QJSON_INCLUDE_DIR} ) - -set( amarok_collection-playdarcollection_PART_SRCS - PlaydarMeta.cpp - PlaydarCollection.cpp - PlaydarQueryMaker.cpp - support/Controller.cpp - support/Query.cpp - support/ProxyResolver.cpp - support/QMFunctionTypes.h ) - -kde4_add_plugin(amarok_collection-playdarcollection ${amarok_collection-playdarcollection_PART_SRCS}) - -target_link_libraries( amarok_collection-playdarcollection - amarokcore - amaroklib - ${QJSON_LIBRARIES} - ${KDE4_KDECORE_LIBS} - ${KDE4_THREADWEAVER_LIBS} - ${KDE4_KIO_LIBS} ) - -install(TARGETS amarok_collection-playdarcollection DESTINATION ${PLUGIN_INSTALL_DIR} ) - -install(FILES amarok_collection-playdarcollection.desktop DESTINATION ${SERVICES_INSTALL_DIR}) diff --git a/amarok/src/core-impl/collections/playdarcollection/PlaydarCollection.cpp b/amarok/src/core-impl/collections/playdarcollection/PlaydarCollection.cpp deleted file mode 100644 index e4d5acff..00000000 --- a/amarok/src/core-impl/collections/playdarcollection/PlaydarCollection.cpp +++ /dev/null @@ -1,375 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Andrew Coder * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "PlaydarCollection" - -#include "PlaydarCollection.h" - -#include "core/collections/Collection.h" -#include "core-impl/collections/support/MemoryCollection.h" -#include "core-impl/collections/support/MemoryQueryMaker.h" -#include "core-impl/collections/support/CollectionManager.h" -#include "core-impl/meta/proxy/MetaProxy.h" -#include "PlaydarQueryMaker.h" -#include "support/Controller.h" -#include "support/ProxyResolver.h" -#include "core/support/Debug.h" - -#include - -#include -#include -#include - -namespace Collections -{ - - AMAROK_EXPORT_COLLECTION( PlaydarCollectionFactory, playdarcollection ) - - PlaydarCollectionFactory::PlaydarCollectionFactory( QObject* parent, const QVariantList &args ) - : CollectionFactory( parent, args ) - , m_controller( 0 ) - , m_collectionIsManaged( false ) - { - m_info = KPluginInfo( "amarok_collection-playdarcollection.desktop", "services" ); - DEBUG_BLOCK - } - - PlaydarCollectionFactory::~PlaydarCollectionFactory() - { - DEBUG_BLOCK - CollectionManager::instance()->removeTrackProvider( m_collection.data() ); - delete m_collection.data(); - delete m_controller; - } - - void - PlaydarCollectionFactory::init() - { - DEBUG_BLOCK - m_controller = new Playdar::Controller( this ); - connect( m_controller, SIGNAL(playdarReady()), - this, SLOT(playdarReady()) ); - connect( m_controller, SIGNAL(playdarError(Playdar::Controller::ErrorState)), - this, SLOT(slotPlaydarError(Playdar::Controller::ErrorState)) ); - checkStatus(); - - m_collection = new PlaydarCollection; - connect( m_collection.data(), SIGNAL(remove()), this, SLOT(collectionRemoved()) ); - CollectionManager::instance()->addTrackProvider( m_collection.data() ); - - m_initialized = true; - } - - void - PlaydarCollectionFactory::checkStatus() - { - m_controller->status(); - } - - - void - PlaydarCollectionFactory::playdarReady() - { - DEBUG_BLOCK - - if( !m_collection ) - { - m_collection = new PlaydarCollection(); - connect( m_collection.data(), SIGNAL(remove()), this, SLOT(collectionRemoved()) ); - } - - if( !m_collectionIsManaged ) - { - m_collectionIsManaged = true; - emit newCollection( m_collection.data() ); - } - } - - void - PlaydarCollectionFactory::slotPlaydarError( Playdar::Controller::ErrorState error ) - { - // DEBUG_BLOCK - - if( error == Playdar::Controller::ErrorState( 1 ) ) - { - if( m_collection && !m_collectionIsManaged ) - CollectionManager::instance()->removeTrackProvider( m_collection.data() ); - - QTimer::singleShot( 10 * 60 * 1000, this, SLOT(checkStatus()) ); - } - } - - void - PlaydarCollectionFactory::collectionRemoved() - { - DEBUG_BLOCK - - m_collectionIsManaged = false; - QTimer::singleShot( 10000, this, SLOT(checkStatus()) ); - } - - PlaydarCollection::PlaydarCollection() - : m_collectionId( i18n( "Playdar Collection" ) ) - , m_memoryCollection( new MemoryCollection ) - { - DEBUG_BLOCK - - } - - PlaydarCollection::~PlaydarCollection() - { - DEBUG_BLOCK - - } - - QueryMaker* - PlaydarCollection::queryMaker() - { - DEBUG_BLOCK - - PlaydarQueryMaker *freshQueryMaker = new PlaydarQueryMaker( this ); - connect( freshQueryMaker, SIGNAL(playdarError(Playdar::Controller::ErrorState)), - this, SLOT(slotPlaydarError(Playdar::Controller::ErrorState)) ); - return freshQueryMaker; - } - - Playlists::UserPlaylistProvider* - PlaydarCollection::userPlaylistProvider() - { - DEBUG_BLOCK - - return 0; - } - - QString - PlaydarCollection::uidUrlProtocol() const - { - return QString( "playdar" ); - } - - QString - PlaydarCollection::collectionId() const - { - return m_collectionId; - } - - QString - PlaydarCollection::prettyName() const - { - return collectionId(); - } - - KIcon - PlaydarCollection::icon() const - { - return KIcon( "network-server" ); - } - - bool - PlaydarCollection::isWritable() const - { - DEBUG_BLOCK - - return false; - } - - bool - PlaydarCollection::isOrganizable() const - { - DEBUG_BLOCK - - return false; - } - - bool - PlaydarCollection::possiblyContainsTrack( const KUrl &url ) const - { - DEBUG_BLOCK - - if( url.protocol() == uidUrlProtocol() && - url.hasQueryItem( QString( "artist" ) ) && - url.hasQueryItem( QString( "album" ) ) && - url.hasQueryItem( QString( "title" ) ) ) - return true; - else - return false; - } - - Meta::TrackPtr - PlaydarCollection::trackForUrl( const KUrl &url ) - { - DEBUG_BLOCK - - m_memoryCollection->acquireReadLock(); - - if( m_memoryCollection->trackMap().contains( url.url() ) ) - { - Meta::TrackPtr track = m_memoryCollection->trackMap().value( url.url() ); - m_memoryCollection->releaseLock(); - return track; - } - else - { - m_memoryCollection->releaseLock(); - MetaProxy::TrackPtr proxyTrack( new MetaProxy::Track( url ) ); - proxyTrack->setArtist( url.queryItem( "artist" ) ); - proxyTrack->setAlbum( url.queryItem( "album" ) ); - proxyTrack->setTitle( url.queryItem( "title" ) ); - Playdar::ProxyResolver *proxyResolver = new Playdar::ProxyResolver( this, url, proxyTrack ); - - connect( proxyResolver, SIGNAL(playdarError(Playdar::Controller::ErrorState)), - this, SLOT(slotPlaydarError(Playdar::Controller::ErrorState)) ); - - return Meta::TrackPtr::staticCast( proxyTrack ); - } - } - - bool - PlaydarCollection::hasCapabilityInterface( Capabilities::Capability::Type type ) const - { - //TODO: Make this work once capabilities are set. - Q_UNUSED( type ); - return false; - } - - Capabilities::Capability* - PlaydarCollection::createCapabilityInterface( Capabilities::Capability::Type type ) - { - //TODO: Make this work once capabilities are set. - Q_UNUSED( type ); - return 0; - } - - void - PlaydarCollection::addNewTrack( Meta::PlaydarTrackPtr track ) - { - DEBUG_BLOCK - - m_memoryCollection->acquireReadLock(); - - if( !m_memoryCollection->trackMap().contains( track->uidUrl() ) ) - { - m_memoryCollection->releaseLock(); - m_memoryCollection->acquireWriteLock(); - - Meta::PlaydarArtistPtr artistPtr; - if( m_memoryCollection->artistMap().contains( track->artist()->name() ) ) - { - Meta::ArtistPtr artist = m_memoryCollection->artistMap().value( track->artist()->name() ); - artistPtr = Meta::PlaydarArtistPtr::staticCast( artist ); - } - else - { - artistPtr = track->playdarArtist(); - Meta::ArtistPtr artist = Meta::ArtistPtr::staticCast( artistPtr ); - m_memoryCollection->addArtist( artist ); - } - artistPtr->addTrack( track ); - track->setArtist( artistPtr ); - - Meta::PlaydarAlbumPtr albumPtr; - if( m_memoryCollection->albumMap().contains( track->album()->name(), - artistPtr->name() ) ) - { - Meta::AlbumPtr album = m_memoryCollection->albumMap().value( track->album()->name(), - artistPtr->name() ); - albumPtr = Meta::PlaydarAlbumPtr::staticCast( album ); - } - else - { - albumPtr = track->playdarAlbum(); - albumPtr->setAlbumArtist( artistPtr ); - artistPtr->addAlbum( albumPtr ); - Meta::AlbumPtr album = Meta::AlbumPtr::staticCast( albumPtr ); - m_memoryCollection->addAlbum( album ); - } - albumPtr->addTrack( track ); - track->setAlbum( albumPtr ); - - Meta::PlaydarGenrePtr genrePtr; - if( m_memoryCollection->genreMap().contains( track->genre()->name() ) ) - { - Meta::GenrePtr genre = m_memoryCollection->genreMap().value( track->genre()->name() ); - genrePtr = Meta::PlaydarGenrePtr::staticCast( genre ); - } - else - { - genrePtr = track->playdarGenre(); - Meta::GenrePtr genre = Meta::GenrePtr::staticCast( genrePtr ); - m_memoryCollection->addGenre( genre ); - } - genrePtr->addTrack( track ); - track->setGenre( genrePtr ); - - Meta::PlaydarComposerPtr composerPtr; - if( m_memoryCollection->composerMap().contains( track->composer()->name() ) ) - { - Meta::ComposerPtr composer = m_memoryCollection->composerMap().value( track->composer()->name() ); - composerPtr = Meta::PlaydarComposerPtr::staticCast( composer ); - } - else - { - composerPtr = track->playdarComposer(); - Meta::ComposerPtr composer = Meta::ComposerPtr::staticCast( composerPtr ); - m_memoryCollection->addComposer( composer ); - } - composerPtr->addTrack( track ); - track->setComposer( composerPtr ); - - Meta::PlaydarYearPtr yearPtr; - if( m_memoryCollection->yearMap().contains( track->year()->year() ) ) - { - Meta::YearPtr year = m_memoryCollection->yearMap().value( track->year()->year() ); - yearPtr = Meta::PlaydarYearPtr::staticCast( year ); - } - else - { - yearPtr = track->playdarYear(); - Meta::YearPtr year = Meta::YearPtr::staticCast( yearPtr ); - m_memoryCollection->addYear( year ); - } - yearPtr->addTrack( track ); - track->setYear( yearPtr ); - - m_memoryCollection->addTrack( Meta::TrackPtr::staticCast( track ) ); - - foreach( Meta::PlaydarLabelPtr label, track->playdarLabels() ) - { - m_memoryCollection->addLabelToTrack( Meta::LabelPtr::staticCast( label ), - Meta::TrackPtr::staticCast( track ) ); - } - - m_memoryCollection->releaseLock(); - emit updated(); - } - else - m_memoryCollection->releaseLock(); - } - - QSharedPointer< MemoryCollection > - PlaydarCollection::memoryCollection() - { - return m_memoryCollection; - } - - void - PlaydarCollection::slotPlaydarError( Playdar::Controller::ErrorState error ) - { - if( error == Playdar::Controller::ErrorState( 1 ) ) - emit remove(); - } -} diff --git a/amarok/src/core-impl/collections/playdarcollection/PlaydarCollection.h b/amarok/src/core-impl/collections/playdarcollection/PlaydarCollection.h deleted file mode 100644 index 1a7ec89d..00000000 --- a/amarok/src/core-impl/collections/playdarcollection/PlaydarCollection.h +++ /dev/null @@ -1,101 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Andrew Coder * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef PLAYDAR_COLLECTION_H -#define PLAYDAR_COLLECTION_H - -#include "core/collections/Collection.h" -#include "core-impl/collections/support/MemoryCollection.h" -#include "PlaydarQueryMaker.h" -#include "PlaydarMeta.h" -#include "support/Controller.h" -#include "support/ProxyResolver.h" - -#include - -#include -#include -#include - -namespace Collections -{ - - class QueryMaker; - - class PlaydarCollectionFactory : public CollectionFactory - { - Q_OBJECT - public: - PlaydarCollectionFactory( QObject* parent, const QVariantList &args ); - virtual ~PlaydarCollectionFactory(); - - virtual void init(); - - private Q_SLOTS: - void checkStatus(); - void playdarReady(); - void slotPlaydarError( Playdar::Controller::ErrorState error ); - void collectionRemoved(); - - private: - Playdar::Controller* m_controller; - QWeakPointer< PlaydarCollection > m_collection; - bool m_collectionIsManaged; - }; - - class PlaydarCollection : public Collection - { - Q_OBJECT - public: - - PlaydarCollection(); - ~PlaydarCollection(); - - QueryMaker* queryMaker(); - Playlists::UserPlaylistProvider* userPlaylistProvider(); - - QString uidUrlProtocol() const; - QString collectionId() const; - QString prettyName() const; - KIcon icon() const; - - bool isWritable() const; - bool isOrganizable() const; - - //Methods from Collections::TrackProvider - bool possiblyContainsTrack( const KUrl &url ) const; - Meta::TrackPtr trackForUrl( const KUrl &url ); - - //Methods from Collections::CollectionBase - bool hasCapabilityInterface( Capabilities::Capability::Type type ) const; - Capabilities::Capability* createCapabilityInterface( Capabilities::Capability::Type type ); - - //PlaydarCollection-specific - void addNewTrack( Meta::PlaydarTrackPtr track ); - QSharedPointer< MemoryCollection > memoryCollection(); - - private Q_SLOTS: - void slotPlaydarError( Playdar::Controller::ErrorState error ); - - private: - QString m_collectionId; - - QSharedPointer< MemoryCollection > m_memoryCollection; - QList< QWeakPointer< Playdar::ProxyResolver > > m_proxyResolverList; - }; -} - -#endif diff --git a/amarok/src/core-impl/collections/playdarcollection/PlaydarMeta.cpp b/amarok/src/core-impl/collections/playdarcollection/PlaydarMeta.cpp deleted file mode 100644 index 2db789a9..00000000 --- a/amarok/src/core-impl/collections/playdarcollection/PlaydarMeta.cpp +++ /dev/null @@ -1,667 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Andrew Coder * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "PlaydarMeta.h" - -#include "amarokconfig.h" -#include "core/meta/Meta.h" -#include "core-impl/meta/default/DefaultMetaTypes.h" -#include "core-impl/support/UrlStatisticsStore.h" -#include "covermanager/CoverFetcher.h" -#include "covermanager/CoverCache.h" -#include "PlaydarCollection.h" - -#include -#include -#include -#include - -#include -#include - -namespace Collections -{ - class Collection; - class PlaydarCollection; -} - -Meta::PlaydarTrack::PlaydarTrack( QString &sid, - QString &playableUrl, - QString &name, - QString &artist, - QString &album, - QString &mimetype, - double score, - qint64 length, - int bitrate, - int filesize, - QString &source ) - : m_album( new PlaydarAlbum( album ) ) - , m_artist( new PlaydarArtist( artist ) ) - , m_composer( new PlaydarComposer( QString( "" ) ) ) - , m_genre( new PlaydarGenre( QString( "" ) ) ) - , m_year( new PlaydarYear( QString( "" ) ) ) - , m_labelList( ) - , m_sid( sid ) - , m_uidUrl( ) - , m_playableUrl( playableUrl ) - , m_name( name ) - , m_mimetype( mimetype ) - , m_score( score ) - , m_length( length ) - , m_bitrate( bitrate ) - , m_filesize( filesize ) - , m_trackNumber( 0 ) - , m_discNumber( 0 ) - , m_createDate( QDateTime::currentDateTime() ) - , m_comment( QString( "" ) ) - , m_source( source ) -{ - m_uidUrl.setProtocol( QString( "playdar" ) ); - m_uidUrl.addPath( source ); - m_uidUrl.addQueryItem( QString( "artist" ), artist ); - m_uidUrl.addQueryItem( QString( "album" ), album ); - m_uidUrl.addQueryItem( QString( "title" ), name ); - m_statsStore = new UrlStatisticsStore( this ); -} - -Meta::PlaydarTrack::~PlaydarTrack() -{ - //Do nothing... -} - -QString -Meta::PlaydarTrack::name() const -{ - return m_name; -} - -KUrl -Meta::PlaydarTrack::playableUrl() const -{ - return KUrl( m_playableUrl ); -} - -QString -Meta::PlaydarTrack::prettyUrl() const -{ - return uidUrl(); -} - -QString -Meta::PlaydarTrack::uidUrl() const -{ - return m_uidUrl.url(); -} - -QString -Meta::PlaydarTrack::sid() const -{ - return m_sid; -} - -QString -Meta::PlaydarTrack::notPlayableReason() const -{ - if( !m_collection.data() ) - return i18n( "Source collection removed" ); - return QString(); -} - -Meta::AlbumPtr -Meta::PlaydarTrack::album() const -{ - return AlbumPtr::staticCast( m_album ); -} - -Meta::ArtistPtr -Meta::PlaydarTrack::artist() const -{ - return ArtistPtr::staticCast( m_artist ); -} - -Meta::ComposerPtr -Meta::PlaydarTrack::composer() const -{ - return ComposerPtr::staticCast( m_composer ); -} - -Meta::GenrePtr -Meta::PlaydarTrack::genre() const -{ - return GenrePtr::staticCast( m_genre ); -} - -Meta::YearPtr -Meta::PlaydarTrack::year() const -{ - return YearPtr::staticCast( m_year ); -} - -Meta::LabelList -Meta::PlaydarTrack::labels() const -{ - Meta::LabelList labelList; - foreach( const PlaydarLabelPtr &label, m_labelList ) - { - labelList.append( LabelPtr::staticCast( label ) ); - } - - return labelList; -} - -qreal -Meta::PlaydarTrack::bpm() const -{ - /** TODO: Can we do better here? */ - return -1.0; -} - -QString -Meta::PlaydarTrack::comment() const -{ - return m_comment; -} - -double -Meta::PlaydarTrack::score() const -{ - return m_score; -} - -qint64 -Meta::PlaydarTrack::length() const -{ - return m_length; -} - -int -Meta::PlaydarTrack::filesize() const -{ - return m_filesize; -} - -int -Meta::PlaydarTrack::sampleRate() const -{ - return 0; -} - -int -Meta::PlaydarTrack::bitrate() const -{ - return m_bitrate; -} - -QDateTime -Meta::PlaydarTrack::createDate() const -{ - return m_createDate; -} - -int -Meta::PlaydarTrack::trackNumber() const -{ - return m_trackNumber; -} - -int -Meta::PlaydarTrack::discNumber() const -{ - return m_discNumber; -} - -QString -Meta::PlaydarTrack::type() const -{ - return QString( "stream" ); -} - -QString -Meta::PlaydarTrack::mimetype() const -{ - return m_mimetype; -} - -bool -Meta::PlaydarTrack::inCollection() const -{ - return m_collection.data(); -} - -Collections::Collection* -Meta::PlaydarTrack::collection() const -{ - return m_collection.data(); -} - -QString -Meta::PlaydarTrack::cachedLyrics() const -{ - return QString( "" ); -} - -void -Meta::PlaydarTrack::setCachedLyrics( const QString &lyrics ) -{ - Q_UNUSED( lyrics ); -} - -void -Meta::PlaydarTrack::addLabel( const QString &label ) -{ - PlaydarLabelPtr newLabel( new PlaydarLabel( label ) ); - - m_labelList.append( newLabel ); -} - -void -Meta::PlaydarTrack::addLabel( const LabelPtr &label ) -{ - PlaydarLabelPtr newLabel( new PlaydarLabel( label->name() ) ); - - m_labelList.append( newLabel ); -} - -void -Meta::PlaydarTrack::removeLabel( const LabelPtr &label ) -{ - foreach( const PlaydarLabelPtr &labelPtr, m_labelList ) - { - if( labelPtr->name() == label->name() ) - { - m_labelList.removeOne( labelPtr ); - return; - } - } -} - -Meta::StatisticsPtr -Meta::PlaydarTrack::statistics() -{ - return m_statsStore; -} - -QString -Meta::PlaydarTrack::source() const -{ - return m_source; -} - -void -Meta::PlaydarTrack::addToCollection( Collections::PlaydarCollection *collection ) -{ - m_collection = collection; - if( m_collection.data() ) - { - PlaydarTrackPtr sharedThis( this ); - m_collection.data()->addNewTrack( sharedThis ); - } -} - -void -Meta::PlaydarTrack::setAlbum( PlaydarAlbumPtr album ) -{ - m_album = album; -} - -void -Meta::PlaydarTrack::setArtist( PlaydarArtistPtr artist ) -{ - m_artist = artist; -} - -void -Meta::PlaydarTrack::setComposer( PlaydarComposerPtr composer ) -{ - m_composer = composer; -} - -void -Meta::PlaydarTrack::setGenre( PlaydarGenrePtr genre ) -{ - m_genre = genre; -} - -void -Meta::PlaydarTrack::setYear( PlaydarYearPtr year ) -{ - m_year = year; -} - -Meta::PlaydarAlbumPtr -Meta::PlaydarTrack::playdarAlbum() -{ - return m_album; -} - -Meta::PlaydarArtistPtr -Meta::PlaydarTrack::playdarArtist() -{ - return m_artist; -} - -Meta::PlaydarComposerPtr -Meta::PlaydarTrack::playdarComposer() -{ - return m_composer; -} - -Meta::PlaydarGenrePtr -Meta::PlaydarTrack::playdarGenre() -{ - return m_genre; -} - -Meta::PlaydarYearPtr -Meta::PlaydarTrack::playdarYear() -{ - return m_year; -} - -Meta::PlaydarLabelList -Meta::PlaydarTrack::playdarLabels() -{ - return m_labelList; -} - -Meta::PlaydarArtist::PlaydarArtist( const QString &name ) - : m_name( name ) - , m_tracks( ) - , m_albums( ) -{ - //Do nothing... -} - -Meta::PlaydarArtist::~PlaydarArtist() -{ - //Do nothing... -} - -QString -Meta::PlaydarArtist::name() const -{ - return m_name; -} - -Meta::TrackList -Meta::PlaydarArtist::tracks() -{ - return m_tracks; -} - -Meta::AlbumList -Meta::PlaydarArtist::albums() -{ - return m_albums; -} - -void -Meta::PlaydarArtist::addTrack( PlaydarTrackPtr newTrack ) -{ - m_tracks.append( TrackPtr::staticCast( newTrack ) ); -} - -void -Meta::PlaydarArtist::addAlbum( PlaydarAlbumPtr newAlbum ) -{ - m_albums.append( AlbumPtr::staticCast( newAlbum ) ); -} - -Meta::PlaydarAlbum::PlaydarAlbum( const QString &name ) - : m_name( name ) - , m_tracks( ) - , m_isCompilation( false ) - , m_albumArtist( 0 ) - , m_suppressImageAutoFetch( false ) - , m_triedToFetchCover( false ) -{ - //Do nothing... -} - -Meta::PlaydarAlbum::~PlaydarAlbum() -{ - CoverCache::invalidateAlbum( this ); -} - -bool -Meta::PlaydarAlbum::isCompilation() const -{ - return m_isCompilation; -} - -QString -Meta::PlaydarAlbum::name() const -{ - return m_name; -} - -bool -Meta::PlaydarAlbum::hasAlbumArtist() const -{ - if( !m_albumArtist.isNull() ) - return true; - else - return false; -} - -Meta::ArtistPtr -Meta::PlaydarAlbum::albumArtist() const -{ - return m_albumArtist; -} - -Meta::TrackList -Meta::PlaydarAlbum::tracks() -{ - return m_tracks; -} - -bool -Meta::PlaydarAlbum::hasImage( int size ) const -{ - Q_UNUSED( size ); - - if( !m_cover.isNull() ) - return true; - else - return false; -} - -QImage -Meta::PlaydarAlbum::image( int size ) const -{ - if ( m_cover.isNull() ) - { - if( !m_suppressImageAutoFetch && !m_name.isEmpty() && - !m_triedToFetchCover && AmarokConfig::autoGetCoverArt() ) - { - m_triedToFetchCover = true; - CoverFetcher::instance()->queueAlbum( Meta::AlbumPtr(const_cast(this)) ); - } - - return Meta::Album::image( size ); - } - - return size <= 1 ? m_cover : m_cover.scaled( size, size, Qt::KeepAspectRatio, Qt::SmoothTransformation ); -} - -KUrl -Meta::PlaydarAlbum::imageLocation( int size ) -{ - if( !m_cover.isNull() ) - return KUrl(); - - return Meta::Album::imageLocation( size ); -} - -bool -Meta::PlaydarAlbum::canUpdateImage() const -{ - return true; -} - -void -Meta::PlaydarAlbum::setImage( const QImage &image ) -{ - m_cover = image; - CoverCache::invalidateAlbum( this ); -} - -void -Meta::PlaydarAlbum::removeImage() -{ - m_cover = QImage(); - CoverCache::invalidateAlbum( this ); -} - -void -Meta::PlaydarAlbum::setSuppressImageAutoFetch( const bool suppress ) -{ - m_suppressImageAutoFetch = suppress; -} - -bool -Meta::PlaydarAlbum::suppressImageAutoFetch() const -{ - return m_suppressImageAutoFetch; -} - -void -Meta::PlaydarAlbum::addTrack( PlaydarTrackPtr newTrack ) -{ - m_tracks.append( TrackPtr::staticCast( newTrack ) ); -} - -void -Meta::PlaydarAlbum::setAlbumArtist( PlaydarArtistPtr newArtist ) -{ - m_albumArtist = ArtistPtr::staticCast( newArtist ); -} - -Meta::PlaydarComposer::PlaydarComposer( const QString &name ) - : m_name( name ) - , m_tracks( ) -{ - //Do nothing... -} - -Meta::PlaydarComposer::~PlaydarComposer() -{ - //Do nothing... -} - -QString -Meta::PlaydarComposer::name() const -{ - return m_name; -} - -Meta::TrackList -Meta::PlaydarComposer::tracks() -{ - return m_tracks; -} - -void -Meta::PlaydarComposer::addTrack( PlaydarTrackPtr newTrack ) -{ - m_tracks.append( Meta::TrackPtr::staticCast( newTrack ) ); -} - -Meta::PlaydarGenre::PlaydarGenre( const QString &name ) - : m_name( name ) - , m_tracks( ) -{ - //Do nothing... -} - -Meta::PlaydarGenre::~PlaydarGenre() -{ - //Do nothing... -} - -QString -Meta::PlaydarGenre::name() const -{ - return m_name; -} - -Meta::TrackList -Meta::PlaydarGenre::tracks() -{ - return m_tracks; -} - -void -Meta::PlaydarGenre::addTrack( PlaydarTrackPtr newTrack ) -{ - m_tracks.append( Meta::TrackPtr::staticCast( newTrack ) ); -} - -Meta::PlaydarYear::PlaydarYear( const QString &name ) - : m_name( name ) - , m_tracks( ) -{ - //Do nothing... -} - -Meta::PlaydarYear::~PlaydarYear() -{ - //Do nothing... -} - -QString -Meta::PlaydarYear::name() const -{ - return m_name; -} - -Meta::TrackList -Meta::PlaydarYear::tracks() -{ - return m_tracks; -} - -void -Meta::PlaydarYear::addTrack( PlaydarTrackPtr newTrack ) -{ - m_tracks.append( Meta::TrackPtr::staticCast( newTrack ) ); -} - -Meta::PlaydarLabel::PlaydarLabel( const QString &name ) - : m_name( name ) - , m_tracks( ) -{ - //Do nothing... -} - -Meta::PlaydarLabel::~PlaydarLabel() -{ - //Do nothing... -} - -QString -Meta::PlaydarLabel::name() const -{ - return m_name; -} - -void -Meta::PlaydarLabel::addTrack( PlaydarTrackPtr newTrack ) -{ - m_tracks.append( Meta::TrackPtr::staticCast( newTrack ) ); -} diff --git a/amarok/src/core-impl/collections/playdarcollection/PlaydarMeta.h b/amarok/src/core-impl/collections/playdarcollection/PlaydarMeta.h deleted file mode 100644 index 41e10c56..00000000 --- a/amarok/src/core-impl/collections/playdarcollection/PlaydarMeta.h +++ /dev/null @@ -1,282 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Andrew Coder * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef PLAYDAR_META_H -#define PLAYDAR_META_H - -#include "core/meta/Meta.h" - -#include -#include -#include -#include - -#include -#include - -namespace Collections -{ - class Collection; - class PlaydarCollection; -} - -namespace Meta -{ - class PlaydarTrack; - class PlaydarArtist; - class PlaydarAlbum; - class PlaydarGenre; - class PlaydarComposer; - class PlaydarYear; - class PlaydarLabel; - - typedef KSharedPtr< PlaydarTrack > PlaydarTrackPtr; - typedef QList< PlaydarTrackPtr > PlaydarTrackList; - typedef KSharedPtr< PlaydarArtist > PlaydarArtistPtr; - typedef QList< PlaydarArtistPtr > PlaydarArtistList; - typedef KSharedPtr< PlaydarAlbum > PlaydarAlbumPtr; - typedef QList< PlaydarAlbumPtr > PlaydarAlbumList; - typedef KSharedPtr< PlaydarComposer > PlaydarComposerPtr; - typedef QList< PlaydarComposerPtr > PlaydarComposerList; - typedef KSharedPtr< PlaydarGenre > PlaydarGenrePtr; - typedef QList< PlaydarGenrePtr > PlaydarGenreList; - typedef KSharedPtr< PlaydarYear > PlaydarYearPtr; - typedef QList< PlaydarYearPtr > PlaydarYearList; - typedef KSharedPtr< PlaydarLabel > PlaydarLabelPtr; - typedef QList< PlaydarLabelPtr > PlaydarLabelList; - - class PlaydarTrack : public Track - { - public: - PlaydarTrack( QString &sid, - QString &playableUrl, - QString &name, - QString &artist, - QString &album, - QString &mimetype, - double score, - qint64 length, - int bitrate, - int filesize, - QString &source ); - ~PlaydarTrack(); - - QString name() const; - KUrl playableUrl() const; - QString prettyUrl() const; - QString uidUrl() const; - QString sid() const; - QString notPlayableReason() const; - - AlbumPtr album() const; - ArtistPtr artist() const; - ComposerPtr composer() const; - GenrePtr genre() const; - YearPtr year() const; - LabelList labels() const; - qreal bpm() const; - QString comment() const; - double score() const; - qint64 length() const; - int filesize() const; - int sampleRate() const; - int bitrate() const; - QDateTime createDate() const; - int trackNumber() const; - int discNumber() const; - - QString type() const; - - bool inCollection() const; - Collections::Collection* collection() const; - - QString cachedLyrics() const; - void setCachedLyrics( const QString &lyrics ); - - void addLabel( const QString &label ); - void addLabel( const LabelPtr &label ); - void removeLabel( const LabelPtr &label ); - - StatisticsPtr statistics(); - - //PlaydarTrack-specific: - QString source() const; - QString mimetype() const; - - void addToCollection( Collections::PlaydarCollection *collection ); - void setAlbum( PlaydarAlbumPtr album ); - void setArtist( PlaydarArtistPtr artist ); - void setComposer( PlaydarComposerPtr composer ); - void setGenre( PlaydarGenrePtr genre ); - void setYear( PlaydarYearPtr year ); - - PlaydarAlbumPtr playdarAlbum(); - PlaydarArtistPtr playdarArtist(); - PlaydarComposerPtr playdarComposer(); - PlaydarGenrePtr playdarGenre(); - PlaydarYearPtr playdarYear(); - PlaydarLabelList playdarLabels(); - - private: - QWeakPointer< Collections::PlaydarCollection > m_collection; - - PlaydarAlbumPtr m_album; - PlaydarArtistPtr m_artist; - PlaydarComposerPtr m_composer; - PlaydarGenrePtr m_genre; - PlaydarYearPtr m_year; - PlaydarLabelList m_labelList; - Meta::StatisticsPtr m_statsStore; - - QString m_sid; - KUrl m_uidUrl; - QString m_playableUrl; - QString m_name; - QString m_mimetype; - double m_score; - qint64 m_length; - int m_bitrate; - int m_filesize; - int m_trackNumber; - int m_discNumber; - QDateTime m_createDate; - QString m_comment; - - QString m_source; - }; - - class PlaydarArtist : public Artist - { - public: - PlaydarArtist( const QString &name ); - ~PlaydarArtist(); - - QString name() const; - - TrackList tracks(); - AlbumList albums(); - - void addTrack( PlaydarTrackPtr newTrack ); - void addAlbum( PlaydarAlbumPtr newAlbum ); - - private: - QString m_name; - TrackList m_tracks; - AlbumList m_albums; - }; - - class PlaydarAlbum : public Album - { - public: - PlaydarAlbum( const QString &name ); - ~PlaydarAlbum(); - bool isCompilation() const; - - QString name() const; - - bool hasAlbumArtist() const; - ArtistPtr albumArtist() const; - TrackList tracks(); - bool hasImage( int size = 0 ) const; - QImage image( int size = 0 ) const; - KUrl imageLocation( int size = 0 ); - bool canUpdateImage() const; - void setImage( const QImage &image ); - void removeImage(); - void setSuppressImageAutoFetch( const bool suppress ); - bool suppressImageAutoFetch() const; - - void addTrack( PlaydarTrackPtr newTrack ); - void setAlbumArtist( PlaydarArtistPtr newAlbumArtist ); - - private: - QString m_name; - TrackList m_tracks; - bool m_isCompilation; - ArtistPtr m_albumArtist; - bool m_suppressImageAutoFetch; - mutable bool m_triedToFetchCover; - mutable QImage m_cover; - }; - - class PlaydarComposer : public Composer - { - public: - PlaydarComposer( const QString &name ); - ~PlaydarComposer(); - - QString name() const; - - TrackList tracks(); - - void addTrack( PlaydarTrackPtr newTrack ); - - private: - QString m_name; - TrackList m_tracks; - }; - - class PlaydarGenre : public Genre - { - public: - PlaydarGenre( const QString &name ); - ~PlaydarGenre(); - - QString name() const; - - TrackList tracks(); - - void addTrack( PlaydarTrackPtr newTrack ); - - private: - QString m_name; - TrackList m_tracks; - }; - - class PlaydarYear : public Year - { - public: - PlaydarYear( const QString &name ); - ~PlaydarYear(); - - QString name() const; - - TrackList tracks(); - - void addTrack( PlaydarTrackPtr newTrack ); - - private: - QString m_name; - TrackList m_tracks; - }; - - class PlaydarLabel : public Label - { - public: - PlaydarLabel( const QString &name ); - ~PlaydarLabel(); - - QString name() const; - - void addTrack( PlaydarTrackPtr newTrack ); - - private: - QString m_name; - TrackList m_tracks; - }; -} - -#endif /* PLAYDARMETA_H */ diff --git a/amarok/src/core-impl/collections/playdarcollection/PlaydarQueryMaker.cpp b/amarok/src/core-impl/collections/playdarcollection/PlaydarQueryMaker.cpp deleted file mode 100644 index 64ce33a2..00000000 --- a/amarok/src/core-impl/collections/playdarcollection/PlaydarQueryMaker.cpp +++ /dev/null @@ -1,593 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Andrew Coder * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "PlaydarQueryMaker.h" - -#include "PlaydarMeta.h" -#include "PlaydarCollection.h" - -#include "support/Controller.h" -#include "support/Query.h" -#include "support/QMFunctionTypes.h" - -#include "core/collections/QueryMaker.h" -#include "core/meta/Meta.h" -#include "core/meta/support/MetaConstants.h" -#include "core/support/Debug.h" -#include "core-impl/collections/support/MemoryQueryMaker.h" - -#include -#include - -namespace Collections -{ - PlaydarQueryMaker::PlaydarQueryMaker( PlaydarCollection *collection ) - : m_queryType( QueryMaker::QueryType( None ) ) - , m_autoDelete( false ) - , m_activeQueryCount( 0 ) - , m_memoryQueryIsRunning( false ) - , m_collectionUpdated( false ) - , m_filterMap( ) - , m_collection( collection ) - , m_controller( new Playdar::Controller() ) - { - DEBUG_BLOCK - - m_memoryQueryMaker = new MemoryQueryMaker( m_collection.data()->memoryCollection().toWeakRef(), - m_collection.data()->collectionId() ); - connect( m_memoryQueryMaker.data(), SIGNAL(newResultReady(Meta::TrackList)), - this, SIGNAL(newResultReady(Meta::TrackList)) ); - connect( m_memoryQueryMaker.data(), SIGNAL(newResultReady(Meta::ArtistList)), - this, SIGNAL(newResultReady(Meta::ArtistList)) ); - connect( m_memoryQueryMaker.data(), SIGNAL(newResultReady(Meta::AlbumList)), - this, SIGNAL(newResultReady(Meta::AlbumList)) ); - connect( m_memoryQueryMaker.data(), SIGNAL(newResultReady(Meta::GenreList)), - this, SIGNAL(newResultReady(Meta::GenreList)) ); - connect( m_memoryQueryMaker.data(), SIGNAL(newResultReady(Meta::ComposerList)), - this, SIGNAL(newResultReady(Meta::ComposerList)) ); - connect( m_memoryQueryMaker.data(), SIGNAL(newResultReady(Meta::YearList)), - this, SIGNAL(newResultReady(Meta::YearList)) ); - connect( m_memoryQueryMaker.data(), SIGNAL(newResultReady(Meta::DataList)), - this, SIGNAL(newResultReady(Meta::DataList)) ); - connect( m_memoryQueryMaker.data(), SIGNAL(newResultReady(QStringList)), - this, SIGNAL(newResultReady(QStringList)) ); - connect( m_memoryQueryMaker.data(), SIGNAL(newResultReady(Meta::LabelList)), - this, SIGNAL(newResultReady(Meta::LabelList)) ); - connect( m_memoryQueryMaker.data(), SIGNAL(queryDone()), - this, SLOT(memoryQueryDone()) ); - m_memoryQueryMaker.data()->setAutoDelete( true ); - } - - PlaydarQueryMaker::~PlaydarQueryMaker() - { - DEBUG_BLOCK - - if( !m_queryMakerFunctions.isEmpty() ) - { - qDeleteAll( m_queryMakerFunctions.begin(), m_queryMakerFunctions.end() ); - m_queryMakerFunctions.clear(); - } - - delete m_memoryQueryMaker.data(); - } - - - void - PlaydarQueryMaker::run() - { - DEBUG_BLOCK - - if( !m_filterMap.isEmpty() ) - { - connect( m_controller.data(), SIGNAL(playdarError(Playdar::Controller::ErrorState)), - this, SLOT(slotPlaydarError(Playdar::Controller::ErrorState)) ); - connect( m_controller.data(), SIGNAL(queryReady(Playdar::Query*)), - this, SLOT(collectQuery(Playdar::Query*)) ); - - QString artist( "" ); - QString album( "" ); - QString title( "" ); - - if( m_filterMap.contains( Meta::valArtist ) ) - artist.append( m_filterMap.value( Meta::valArtist ) ); - if( m_filterMap.contains( Meta::valAlbum ) ) - album.append( m_filterMap.value( Meta::valAlbum ) ); - if( m_filterMap.contains( Meta::valTitle ) ) - title.append( m_filterMap.value( Meta::valTitle ) ); - - if( !artist.isEmpty() && !title.isEmpty() ) - { - m_activeQueryCount++; - m_controller.data()->resolve( artist, album, title ); - } - } - - m_activeQueryCount++; - m_memoryQueryIsRunning = true; - m_memoryQueryMaker.data()->run(); - } - - void - PlaydarQueryMaker::abortQuery() - { - DEBUG_BLOCK - - m_memoryQueryMaker.data()->abortQuery(); - - m_controller.data()->disconnect( this ); - } - - QueryMaker* - PlaydarQueryMaker::setQueryType( QueryType type ) - { - DEBUG_BLOCK - - CurriedUnaryQMFunction< QueryType >::FunPtr funPtr = &QueryMaker::setQueryType; - CurriedQMFunction *curriedFun = new CurriedUnaryQMFunction< QueryType >( funPtr, type ); - m_queryMakerFunctions.append( curriedFun ); - - (*curriedFun)( m_memoryQueryMaker.data() ); - - m_queryType = type; - - return this; - } - - QueryMaker* - PlaydarQueryMaker::addReturnValue( qint64 value ) - { - DEBUG_BLOCK - - CurriedUnaryQMFunction< qint64 >::FunPtr funPtr = &QueryMaker::addReturnValue; - CurriedQMFunction *curriedFun = new CurriedUnaryQMFunction< qint64 >( funPtr, value ); - m_queryMakerFunctions.append( curriedFun ); - - (*curriedFun)( m_memoryQueryMaker.data() ); - - return this; - } - - QueryMaker* - PlaydarQueryMaker::addReturnFunction( ReturnFunction function, qint64 value ) - { - DEBUG_BLOCK - - CurriedBinaryQMFunction< ReturnFunction, qint64 >::FunPtr funPtr = &QueryMaker::addReturnFunction; - CurriedQMFunction *curriedFun = new CurriedBinaryQMFunction< ReturnFunction, qint64 >( funPtr, function, value ); - m_queryMakerFunctions.append( curriedFun ); - - (*curriedFun)( m_memoryQueryMaker.data() ); - - return this; - } - - QueryMaker* - PlaydarQueryMaker::orderBy( qint64 value, bool descending ) - { - DEBUG_BLOCK - - CurriedBinaryQMFunction< qint64, bool >::FunPtr funPtr = &QueryMaker::orderBy; - CurriedQMFunction *curriedFun = new CurriedBinaryQMFunction< qint64, bool >( funPtr, value, descending ); - m_queryMakerFunctions.append( curriedFun ); - - (*curriedFun)( m_memoryQueryMaker.data() ); - - return this; - } - - QueryMaker* - PlaydarQueryMaker::addMatch( const Meta::TrackPtr &track ) - { - DEBUG_BLOCK - - CurriedUnaryQMFunction< const Meta::TrackPtr& >::FunPtr funPtr = &QueryMaker::addMatch; - CurriedQMFunction *curriedFun = new CurriedUnaryQMFunction< const Meta::TrackPtr& >( funPtr, track ); - m_queryMakerFunctions.append( curriedFun ); - - (*curriedFun)( m_memoryQueryMaker.data() ); - - return this; - } - - QueryMaker* - PlaydarQueryMaker::addMatch( const Meta::ArtistPtr &artist, ArtistMatchBehaviour behaviour ) - { - DEBUG_BLOCK - - CurriedBinaryQMFunction::FunPtr funPtr = &QueryMaker::addMatch; - CurriedQMFunction *curriedFun = new CurriedBinaryQMFunction( funPtr, artist, behaviour ); - m_queryMakerFunctions.append( curriedFun ); - - (*curriedFun)( m_memoryQueryMaker.data() ); - - if( artist ) - m_filterMap.insert( Meta::valArtist, artist->name() ); - - return this; - } - - QueryMaker* - PlaydarQueryMaker::addMatch( const Meta::AlbumPtr &album ) - { - DEBUG_BLOCK - - CurriedUnaryQMFunction< const Meta::AlbumPtr& >::FunPtr funPtr = &QueryMaker::addMatch; - CurriedQMFunction *curriedFun = new CurriedUnaryQMFunction< const Meta::AlbumPtr& >( funPtr, album ); - m_queryMakerFunctions.append( curriedFun ); - - (*curriedFun)( m_memoryQueryMaker.data() ); - - if( album ) - m_filterMap.insert( Meta::valAlbum, album->name() ); - - return this; - } - - QueryMaker* - PlaydarQueryMaker::addMatch( const Meta::ComposerPtr &composer ) - { - DEBUG_BLOCK - - CurriedUnaryQMFunction< const Meta::ComposerPtr& >::FunPtr funPtr = &QueryMaker::addMatch; - CurriedQMFunction *curriedFun = new CurriedUnaryQMFunction< const Meta::ComposerPtr& >( funPtr, composer ); - m_queryMakerFunctions.append( curriedFun ); - - (*curriedFun)( m_memoryQueryMaker.data() ); - - return this; - } - - QueryMaker* - PlaydarQueryMaker::addMatch( const Meta::GenrePtr &genre ) - { - DEBUG_BLOCK - - CurriedUnaryQMFunction< const Meta::GenrePtr& >::FunPtr funPtr = &QueryMaker::addMatch; - CurriedQMFunction *curriedFun = new CurriedUnaryQMFunction< const Meta::GenrePtr& >( funPtr, genre ); - m_queryMakerFunctions.append( curriedFun ); - - (*curriedFun)( m_memoryQueryMaker.data() ); - - return this; - } - - QueryMaker* - PlaydarQueryMaker::addMatch( const Meta::YearPtr &year ) - { - DEBUG_BLOCK - - CurriedUnaryQMFunction< const Meta::YearPtr& >::FunPtr funPtr = &QueryMaker::addMatch; - CurriedQMFunction *curriedFun = new CurriedUnaryQMFunction< const Meta::YearPtr& >( funPtr, year ); - m_queryMakerFunctions.append( curriedFun ); - - (*curriedFun)( m_memoryQueryMaker.data() ); - - return this; - } - - QueryMaker* - PlaydarQueryMaker::addMatch( const Meta::LabelPtr &label ) - { - DEBUG_BLOCK - - CurriedUnaryQMFunction< const Meta::LabelPtr& >::FunPtr funPtr = &QueryMaker::addMatch; - CurriedQMFunction *curriedFun = new CurriedUnaryQMFunction< const Meta::LabelPtr& >( funPtr, label ); - m_queryMakerFunctions.append( curriedFun ); - - (*curriedFun)( m_memoryQueryMaker.data() ); - - return this; - } - - QueryMaker* - PlaydarQueryMaker::addFilter( qint64 value, const QString &filter, bool matchBegin, bool matchEnd ) - { - DEBUG_BLOCK - - CurriedQMStringFilterFunction::FunPtr funPtr = &QueryMaker::addFilter; - CurriedQMFunction *curriedFun = - new CurriedQMStringFilterFunction( funPtr, value, filter, matchBegin, matchEnd ); - m_queryMakerFunctions.append( curriedFun ); - - (*curriedFun)( m_memoryQueryMaker.data() ); - - if( !m_filterMap.isEmpty() && m_filterMap.contains( value ) ) - { - QString newFilter = m_filterMap.value( value ); - newFilter.append( QString( " " ) ).append( filter ); - m_filterMap.insert( value, newFilter ); - } - else - m_filterMap.insert( value, filter ); - - return this; - } - - QueryMaker* - PlaydarQueryMaker::excludeFilter( qint64 value, const QString &filter, bool matchBegin, bool matchEnd ) - { - DEBUG_BLOCK - - CurriedQMStringFilterFunction::FunPtr funPtr = &QueryMaker::excludeFilter; - CurriedQMFunction *curriedFun = - new CurriedQMStringFilterFunction( funPtr, value, filter, matchBegin, matchEnd ); - m_queryMakerFunctions.append( curriedFun ); - - (*curriedFun)( m_memoryQueryMaker.data() ); - - if( m_filterMap.contains( value ) && m_filterMap.value( value ).contains( filter ) ) - { - QString localFilter = m_filterMap.value( value ); - localFilter.remove( filter ); - m_filterMap.insert( value, localFilter ); - } - - return this; - } - - QueryMaker* - PlaydarQueryMaker::addNumberFilter( qint64 value, qint64 filter, NumberComparison compare ) - { - DEBUG_BLOCK - - CurriedTrinaryQMFunction< qint64, qint64, NumberComparison >::FunPtr funPtr = &QueryMaker::addNumberFilter; - CurriedQMFunction *curriedFun = - new CurriedTrinaryQMFunction< qint64, qint64, NumberComparison > - ( - funPtr, value, filter, compare - ); - m_queryMakerFunctions.append( curriedFun ); - - (*curriedFun)( m_memoryQueryMaker.data() ); - - return this; - } - - QueryMaker* - PlaydarQueryMaker::excludeNumberFilter( qint64 value, qint64 filter, NumberComparison compare ) - { - DEBUG_BLOCK - - CurriedTrinaryQMFunction< qint64, qint64, NumberComparison >::FunPtr funPtr = &QueryMaker::excludeNumberFilter; - CurriedQMFunction *curriedFun = - new CurriedTrinaryQMFunction< qint64, qint64, NumberComparison > - ( - funPtr, value, filter, compare - ); - m_queryMakerFunctions.append( curriedFun ); - - (*curriedFun)( m_memoryQueryMaker.data() ); - - return this; - } - - QueryMaker* - PlaydarQueryMaker::limitMaxResultSize( int size ) - { - DEBUG_BLOCK - - CurriedUnaryQMFunction< int >::FunPtr funPtr = &QueryMaker::limitMaxResultSize; - CurriedQMFunction *curriedFun = new CurriedUnaryQMFunction< int >( funPtr, size ); - m_queryMakerFunctions.append( curriedFun ); - - (*curriedFun)( m_memoryQueryMaker.data() ); - - return this; - } - - QueryMaker* - PlaydarQueryMaker::setAlbumQueryMode( AlbumQueryMode mode ) - { - DEBUG_BLOCK - - CurriedUnaryQMFunction< AlbumQueryMode >::FunPtr funPtr = &QueryMaker::setAlbumQueryMode; - CurriedQMFunction *curriedFun = new CurriedUnaryQMFunction< AlbumQueryMode >( funPtr, mode ); - m_queryMakerFunctions.append( curriedFun ); - - (*curriedFun)( m_memoryQueryMaker.data() ); - - return this; - } - - QueryMaker* - PlaydarQueryMaker::setLabelQueryMode( LabelQueryMode mode ) - { - DEBUG_BLOCK - - CurriedUnaryQMFunction< LabelQueryMode >::FunPtr funPtr = &QueryMaker::setLabelQueryMode; - CurriedQMFunction *curriedFun = new CurriedUnaryQMFunction< LabelQueryMode >( funPtr, mode ); - m_queryMakerFunctions.append( curriedFun ); - - (*curriedFun)( m_memoryQueryMaker.data() ); - - return this; - } - - QueryMaker* - PlaydarQueryMaker::beginAnd() - { - DEBUG_BLOCK - - CurriedZeroArityQMFunction::FunPtr funPtr = &QueryMaker::beginAnd; - CurriedQMFunction *curriedFun = new CurriedZeroArityQMFunction( funPtr ); - m_queryMakerFunctions.append( curriedFun ); - - (*curriedFun)( m_memoryQueryMaker.data() ); - - return this; - } - - QueryMaker* - PlaydarQueryMaker::beginOr() - { - DEBUG_BLOCK - - CurriedZeroArityQMFunction::FunPtr funPtr = &QueryMaker::beginOr; - CurriedQMFunction *curriedFun = new CurriedZeroArityQMFunction( funPtr ); - m_queryMakerFunctions.append( curriedFun ); - - (*curriedFun)( m_memoryQueryMaker.data() ); - - return this; - } - - QueryMaker* - PlaydarQueryMaker::endAndOr() - { - DEBUG_BLOCK - - CurriedZeroArityQMFunction::FunPtr funPtr = &QueryMaker::endAndOr; - CurriedQMFunction *curriedFun = new CurriedZeroArityQMFunction( funPtr ); - m_queryMakerFunctions.append( curriedFun ); - - (*curriedFun)( m_memoryQueryMaker.data() ); - - return this; - } - - QueryMaker* - PlaydarQueryMaker::setAutoDelete( bool autoDelete ) - { - DEBUG_BLOCK - - m_autoDelete = autoDelete; - - return this; - } - - int - PlaydarQueryMaker::validFilterMask() - { - DEBUG_BLOCK - - return QueryMaker::ValidFilters( ArtistFilter ) | - QueryMaker::ValidFilters( AlbumFilter ) | - QueryMaker::ValidFilters( TitleFilter ) | - m_memoryQueryMaker.data()->validFilterMask(); - } - - void - PlaydarQueryMaker::slotPlaydarError( Playdar::Controller::ErrorState error ) - { - DEBUG_BLOCK - - emit playdarError( error ); - } - - void - PlaydarQueryMaker::collectQuery( Playdar::Query* query ) - { - DEBUG_BLOCK - - connect( query, SIGNAL(newTrackAdded(Meta::PlaydarTrackPtr)), - this, SLOT(collectResult(Meta::PlaydarTrackPtr)) ); - connect( query, SIGNAL(queryDone(Playdar::Query*,Meta::PlaydarTrackList)), - this, SLOT(aQueryEnded(Playdar::Query*,Meta::PlaydarTrackList)) ); - } - - void - PlaydarQueryMaker::collectResult( Meta::PlaydarTrackPtr track ) - { - DEBUG_BLOCK - - track->addToCollection( m_collection.data() ); - if( m_collection.data()->trackForUrl( track->uidUrl() ) == Meta::TrackPtr::staticCast( track ) ) - m_collectionUpdated = true; - } - - void - PlaydarQueryMaker::aQueryEnded( Playdar::Query *query, const Meta::PlaydarTrackList &trackList ) - { - DEBUG_BLOCK - - Q_UNUSED( query ); - Q_UNUSED( trackList ); - - m_activeQueryCount--; - - - if( m_activeQueryCount <= 0 ) - { - if( m_collectionUpdated && !m_memoryQueryIsRunning ) - { - m_collectionUpdated = false; - runMemoryQueryAgain(); - } - else - { - emit queryDone(); - if( m_autoDelete ) - deleteLater(); - } - } - } - - void - PlaydarQueryMaker::memoryQueryDone() - { - DEBUG_BLOCK - - m_memoryQueryIsRunning = false; - m_activeQueryCount--; - - if( m_activeQueryCount <= 0 ) - { - emit queryDone(); - if( m_autoDelete ) - deleteLater(); - } - } - - void - PlaydarQueryMaker::runMemoryQueryAgain() - { - DEBUG_BLOCK - - if( m_memoryQueryMaker.data() ) - return; - - m_memoryQueryMaker = new MemoryQueryMaker( m_collection.data()->memoryCollection().toWeakRef(), - m_collection.data()->collectionId() ); - connect( m_memoryQueryMaker.data(), SIGNAL(newResultReady(Meta::TrackList)), - this, SIGNAL(newResultReady(Meta::TrackList)) ); - connect( m_memoryQueryMaker.data(), SIGNAL(newResultReady(Meta::ArtistList)), - this, SIGNAL(newResultReady(Meta::ArtistList)) ); - connect( m_memoryQueryMaker.data(), SIGNAL(newResultReady(Meta::AlbumList)), - this, SIGNAL(newResultReady(Meta::AlbumList)) ); - connect( m_memoryQueryMaker.data(), SIGNAL(newResultReady(Meta::GenreList)), - this, SIGNAL(newResultReady(Meta::GenreList)) ); - connect( m_memoryQueryMaker.data(), SIGNAL(newResultReady(Meta::ComposerList)), - this, SIGNAL(newResultReady(Meta::ComposerList)) ); - connect( m_memoryQueryMaker.data(), SIGNAL(newResultReady(Meta::YearList)), - this, SIGNAL(newResultReady(Meta::YearList)) ); - connect( m_memoryQueryMaker.data(), SIGNAL(newResultReady(Meta::DataList)), - this, SIGNAL(newResultReady(Meta::DataList)) ); - connect( m_memoryQueryMaker.data(), SIGNAL(newResultReady(QStringList)), - this, SIGNAL(newResultReady(QStringList)) ); - connect( m_memoryQueryMaker.data(), SIGNAL(newResultReady(Meta::LabelList)), - this, SIGNAL(newResultReady(Meta::LabelList)) ); - connect( m_memoryQueryMaker.data(), SIGNAL(queryDone()), - this, SLOT(memoryQueryDone()) ); - m_memoryQueryMaker.data()->setAutoDelete( true ); - - foreach( CurriedQMFunction *funPtr, m_queryMakerFunctions ) - (*funPtr)( m_memoryQueryMaker.data() ); - - m_activeQueryCount++; - m_memoryQueryIsRunning = true; - m_memoryQueryMaker.data()->run(); - } -} diff --git a/amarok/src/core-impl/collections/playdarcollection/PlaydarQueryMaker.h b/amarok/src/core-impl/collections/playdarcollection/PlaydarQueryMaker.h deleted file mode 100644 index 1076eb33..00000000 --- a/amarok/src/core-impl/collections/playdarcollection/PlaydarQueryMaker.h +++ /dev/null @@ -1,126 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Andrew Coder * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - - -#ifndef PLAYDAR_QUERYMAKER_H -#define PLAYDAR_QUERYMAKER_H - -#include "PlaydarMeta.h" -#include "PlaydarCollection.h" - -#include "support/Controller.h" -#include "support/Query.h" -#include "support/QMFunctionTypes.h" - -#include "core/meta/forward_declarations.h" -#include "core/meta/support/MetaConstants.h" -#include "core/collections/QueryMaker.h" - -#include -#include - -namespace Collections -{ - class QueryMakerFunction; - - class PlaydarQueryMaker : public QueryMaker - { - Q_OBJECT - - public: - PlaydarQueryMaker( PlaydarCollection *collection ); - ~PlaydarQueryMaker(); - - void run(); - void abortQuery(); - - QueryMaker* setQueryType( QueryType type ); - QueryMaker* addReturnValue( qint64 value ); - QueryMaker* addReturnFunction( ReturnFunction function, qint64 value ); - QueryMaker* orderBy( qint64 value, bool descending = false ); - - QueryMaker* addMatch( const Meta::TrackPtr &track ); - QueryMaker* addMatch( const Meta::ArtistPtr &artist, ArtistMatchBehaviour behaviour = TrackArtists ); - QueryMaker* addMatch( const Meta::AlbumPtr &album ); - QueryMaker* addMatch( const Meta::ComposerPtr &composer ); - QueryMaker* addMatch( const Meta::GenrePtr &genre ); - QueryMaker* addMatch( const Meta::YearPtr &year ); - QueryMaker* addMatch( const Meta::LabelPtr &label ); - - QueryMaker* addFilter( qint64 value, const QString &filter, bool matchBegin = false, bool matchEnd = false ); - QueryMaker* excludeFilter( qint64 value, const QString &filter, bool matchBegin = false, bool matchEnd = false ); - - QueryMaker* addNumberFilter( qint64 value, qint64 filter, NumberComparison compare ); - QueryMaker* excludeNumberFilter( qint64 value, qint64 filter, NumberComparison compare ); - - QueryMaker* limitMaxResultSize( int size ); - - QueryMaker* setAlbumQueryMode( AlbumQueryMode mode ); - - QueryMaker* setLabelQueryMode( LabelQueryMode mode ); - - QueryMaker* beginAnd(); - QueryMaker* beginOr(); - QueryMaker* endAndOr(); - QueryMaker* setAutoDelete( bool autoDelete ); - - int validFilterMask(); - - signals: - void newResultReady( Meta::TrackList ); - void newResultReady( Meta::ArtistList ); - void newResultReady( Meta::AlbumList ); - void newResultReady( Meta::GenreList ); - void newResultReady( Meta::ComposerList ); - void newResultReady( Meta::YearList ); - void newResultReady( QStringList ); - void newResultReady( Meta::LabelList ); - - void queryDone(); - - void playdarError( Playdar::Controller::ErrorState ); - - private Q_SLOTS: - void slotPlaydarError( Playdar::Controller::ErrorState error ); - void collectQuery( Playdar::Query *query ); - void collectResult( Meta::PlaydarTrackPtr track ); - void aQueryEnded( Playdar::Query *query, const Meta::PlaydarTrackList &trackList ); - void memoryQueryDone(); - - private: - QueryType m_queryType; - bool m_autoDelete; - int m_activeQueryCount; - bool m_memoryQueryIsRunning; - bool m_collectionUpdated; - QList< CurriedQMFunction* > m_queryMakerFunctions; - - typedef QMap< qint64, QString > FilterMap; - FilterMap m_filterMap; - - QWeakPointer< PlaydarCollection > m_collection; - QWeakPointer< QueryMaker > m_memoryQueryMaker; - - QWeakPointer< Playdar::Controller > m_controller; - - void runMemoryQueryAgain(); - }; - - - -} - -#endif diff --git a/amarok/src/core-impl/collections/playdarcollection/amarok_collection-playdarcollection.desktop b/amarok/src/core-impl/collections/playdarcollection/amarok_collection-playdarcollection.desktop deleted file mode 100644 index fde7628a..00000000 --- a/amarok/src/core-impl/collections/playdarcollection/amarok_collection-playdarcollection.desktop +++ /dev/null @@ -1,110 +0,0 @@ -[Desktop Entry] -Type=Service -Icon=network-workgroup -Name=Playdar Collection -Name[bg]=Колекция Playdar -Name[bs]=Playdar kolekcija -Name[ca]=Col·lecció del Playdar -Name[ca@valencia]=Col·lecció del Playdar -Name[cs]=Sbírka Playdar -Name[da]=Playdar-samling -Name[de]=Playdar-Sammlung -Name[el]=Συλλογή Playdar -Name[en_GB]=Playdar Collection -Name[es]=Colección de Playdar -Name[et]=Playdari kogu -Name[eu]=Playdar bilduma -Name[fi]=Playdar-kokoelma -Name[fr]=Collection « Playdar » -Name[ga]=Bailiúchán Playdar -Name[gl]=Colección de Playdar -Name[hu]=Playdar gyűjtemény -Name[id]=Koleksi Playdar -Name[it]=Collezione Playdar -Name[ja]=Playdar コレクション -Name[km]=សម្រាំង Playdar -Name[lt]=Playdar fonoteka -Name[lv]=Playdar kolekcija -Name[nb]=Playdar-samling -Name[nds]=Playdar-Sammeln -Name[nl]=Playdar-collectie -Name[pl]=Zbiór Playdar -Name[pt]=Colecção do Playdar -Name[pt_BR]=Coleção do Playdar -Name[ro]=Colecție Playdar -Name[ru]=Коллекция Playdar -Name[sk]=Kolekcia Playdar -Name[sl]=Zbirka Playdar -Name[sr]=Збирка Плејдара -Name[sr@ijekavian]=Збирка Плејдара -Name[sr@ijekavianlatin]=Zbirka Playdara -Name[sr@latin]=Zbirka Playdara -Name[sv]=Playdar-samling -Name[tr]=Playdar Koleksiyonu -Name[uk]=Збірка Playdar -Name[x-test]=xxPlaydar Collectionxx -Name[zh_CN]=Playdar 收藏 -Name[zh_TW]=Playdar 收藏 -Comment=Music that Playdar can find -Comment[bg]=Музика откривана с Playdar -Comment[bs]=Muzika koju Playdar može pronaći -Comment[ca]=Música que el Playdar pot trobar -Comment[ca@valencia]=Música que el Playdar pot trobar -Comment[cs]=Hudba, kterou může Playdar najít -Comment[da]=Musik som Playdar kan finde -Comment[de]=Von Playdar auffindbare Musik -Comment[el]=Μουσική την οποία το Playdar μπορεί να βρει -Comment[en_GB]=Music that Playdar can find -Comment[es]=Música que puede encontrar Playdar -Comment[et]=Muusika, mida Playdar suudab leida -Comment[eu]=Playdar-ek aurki dezakeen musika -Comment[fi]=Musiikki, jonka Playdar saa löytää -Comment[fr]=Musique que Playdar peut trouver -Comment[ga]=Ceol is féidir le Playdar aimsiú -Comment[gl]=Música que pode atopar Playdar -Comment[hu]=A Playdar által található zenék -Comment[id]=Musik pada Playdar itu akan dicari -Comment[it]=Musica che Playdar può trovare -Comment[ja]=Playdar が見つけることのできる音楽 -Comment[km]=តន្ត្រី​ដែល​ Playdar អាច​រក​ឃើញ -Comment[lt]=Muziką, kurią gali rasti Playdar -Comment[lv]=Mūzika, ko atrod Playdar -Comment[nb]=Musikk som Playdar kan finne -Comment[nds]=Musik, de sik mit Playdar finnen lett -Comment[nl]=Muziek die Playdar kan vinden -Comment[pl]=Muzyka, której Playdar nie może znaleźć -Comment[pt]=Música que o Playdar consegue encontrar -Comment[pt_BR]=Música que o Playdar pode encontrar -Comment[ro]=Muzică ce poate fi găsită de Playdar -Comment[ru]=Модуль коллекции Playdar для Amarok -Comment[sk]=Hudba, ktorú môže nájsť Playdar -Comment[sl]=Glasba, ki jo lahko najde Playdar -Comment[sr]=Музика коју Плејдар проналази -Comment[sr@ijekavian]=Музика коју Плејдар проналази -Comment[sr@ijekavianlatin]=Muzika koju Playdar pronalazi -Comment[sr@latin]=Muzika koju Playdar pronalazi -Comment[sv]=Musik som Playdar kan hitta -Comment[tr]=Playdar'ın bulabileceği müzik -Comment[uk]=Музика, яку може знайти Playdar -Comment[x-test]=xxMusic that Playdar can findxx -Comment[zh_CN]=Playdar 可找到的音乐 -Comment[zh_TW]=Playdar 可以找到的音樂 - -ServiceTypes=Amarok/Plugin-disabled - -X-KDE-Amarok-authors=Andrew Coder -X-KDE-Amarok-email=andrew.coder@gmail.com -X-KDE-Amarok-framework-version=72 -X-KDE-Amarok-name=playdar-collection -X-KDE-Amarok-plugintype=collection -X-KDE-Amarok-rank=100 -X-KDE-Amarok-version=1 - -X-KDE-PluginInfo-Author=Andrew Coder -X-KDE-PluginInfo-Email=andrew.coder@gmail.com -X-KDE-PluginInfo-Version=1.0 -X-KDE-PluginInfo-Category=Collection -X-KDE-PluginInfo-License=GPL -X-KDE-PluginInfo-EnabledByDefault=false -X-KDE-PluginInfo-Name=amarok_collection-playdarcollection -X-KDE-Library=amarok_collection-playdarcollection diff --git a/amarok/src/core-impl/collections/playdarcollection/support/Controller.cpp b/amarok/src/core-impl/collections/playdarcollection/support/Controller.cpp deleted file mode 100644 index 7caf9dcb..00000000 --- a/amarok/src/core-impl/collections/playdarcollection/support/Controller.cpp +++ /dev/null @@ -1,204 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Andrew Coder * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "Playdar::Controller" - -#include "Controller.h" - -#include "Query.h" -#include "core/support/Debug.h" - -#include - -#include -#include - -#include -#include -#include -#include - -namespace Playdar { - - Controller::Controller( bool queriesShouldWaitForSolutions ) - : m_errorState( ErrorState( NoError ) ) - , m_queriesShouldWaitForSolutions( queriesShouldWaitForSolutions ) - - { - DEBUG_BLOCK - } - - Controller::~Controller() - { - DEBUG_BLOCK - } - - void - Controller::resolve( const QString &artist, const QString &album, const QString &title ) - { - DEBUG_BLOCK - - debug() << "Querying playdar for artist name = " << artist - << ", album name = " << album << ", and track title = " << title; - - const QString baseUrl( "http://localhost:60210/api/?method=resolve" ); - KUrl resolveUrl( baseUrl ); - - resolveUrl.addQueryItem( QString( "artist" ), artist ); - resolveUrl.addQueryItem( QString( "album" ), album ); - resolveUrl.addQueryItem( QString( "track" ), title ); - - debug() << "Starting storedGetJob for " << resolveUrl.url(); - - KJob* resolveJob = KIO::storedGet( resolveUrl, KIO::Reload, KIO::HideProgressInfo ); - connect( resolveJob, SIGNAL(result(KJob*)), this, SLOT(processQuery(KJob*)) ); - } - - void - Controller::getResults( Query* query ) - { - DEBUG_BLOCK - - const QString baseUrl( "http://localhost:60210/api/?method=get_results" ); - KUrl getResultsUrl( baseUrl ); - - getResultsUrl.addQueryItem( QString( "qid" ), query->qid() ); - - KJob* getResultsJob = KIO::storedGet( getResultsUrl, KIO::Reload, KIO::HideProgressInfo ); - connect( getResultsJob, SIGNAL(result(KJob*)), query, SLOT(receiveResults(KJob*)) ); - } - - void - Controller::getResultsLongPoll( Query* query ) - { - DEBUG_BLOCK - - const QString baseUrl( "http://localhost:60210/api/?method=get_results_long" ); - KUrl getResultsUrl( baseUrl ); - - getResultsUrl.addQueryItem( QString( "qid" ), query->qid() ); - - KJob* getResultsJob = KIO::storedGet( getResultsUrl, KIO::Reload, KIO::HideProgressInfo ); - connect( getResultsJob, SIGNAL(result(KJob*)), query, SLOT(receiveResults(KJob*)) ); - } - - KUrl - Controller::urlForSid( const QString &sid ) const - { - DEBUG_BLOCK - - const QString baseUrl( "http://localhost:60210/sid/" ); - KUrl playableUrl( baseUrl ); - - playableUrl.addPath( sid ); - - return playableUrl; - } - - void - Controller::status() - { - // DEBUG_BLOCK - - const QString baseUrl( "http://localhost:60210/api/?method=stat" ); - KUrl statusUrl( baseUrl ); - - KJob* statusJob = KIO::storedGet( statusUrl, KIO::Reload, KIO::HideProgressInfo ); - connect( statusJob, SIGNAL(result(KJob*)), this, SLOT(processStatus(KJob*)) ); - } - - void - Controller::processStatus( KJob *statusJob ) - { - if( statusJob->error() != 0 ) { - // debug() << "Error getting status from Playdar"; - emit playdarError( Playdar::Controller::ErrorState( ExternalError ) ); - return; - } - - debug() << "Processing received JSON data..."; - KIO::StoredTransferJob* storedStatusJob = static_cast( statusJob ); - - QVariant parsedStatusVariant; - - QJson::Parser parser; - bool ok; - parsedStatusVariant = parser.parse( storedStatusJob->data(),&ok ); - if ( !ok ) - { - debug() << "Error parsing JSON Data"; - } - QVariantMap parsedStatus = parsedStatusVariant.toMap(); - - if( !parsedStatus.contains("name") ) - { - debug() << "Expected a service name from Playdar, received none"; - emit playdarError( Playdar::Controller::ErrorState( MissingServiceName ) ); - return; - } - if( parsedStatus.value("name") != QString( "playdar" ) ) - { - debug() << "Expected Playdar, got response from some other service"; - emit playdarError( Playdar::Controller::ErrorState( WrongServiceName ) ); - return; - } - - debug() << "All good! Emitting playdarReady()"; - emit playdarReady(); - } - - void - Controller::processQuery( KJob *queryJob ) - { - DEBUG_BLOCK - - if( queryJob->error() != 0 ) - { - debug() << "Error getting qid from Playdar"; - emit playdarError( Playdar::Controller::ErrorState( ExternalError ) ); - return; - } - - debug() << "Processing received JSON data..."; - KIO::StoredTransferJob* storedQueryJob = - static_cast( queryJob ); - - QVariant parsedQueryVariant; - QJson::Parser parser; - bool ok; - parsedQueryVariant = parser.parse( storedQueryJob->data(),&ok ); - if ( !ok ) - { - debug() << "Error parsing JSON Data"; - } - - QVariantMap parsedQuery = parsedQueryVariant.toMap(); - if( !parsedQuery.contains( "qid" ) ) - { - debug() << "Expected qid in Playdar's response, but didn't get it"; - emit playdarError( Playdar::Controller::ErrorState( MissingQid ) ); - return; - } - - Query* query = new Query( parsedQuery.value( "qid" ).toString(), this, m_queriesShouldWaitForSolutions ); - - debug() << "All good! Emitting queryReady( Playdar::Query* )..."; - emit queryReady( query ); - - connect( query, SIGNAL(playdarError(Playdar::Controller::ErrorState)), - this, SIGNAL(playdarError(Playdar::Controller::ErrorState)) ); - } -} diff --git a/amarok/src/core-impl/collections/playdarcollection/support/Controller.h b/amarok/src/core-impl/collections/playdarcollection/support/Controller.h deleted file mode 100644 index fa02c835..00000000 --- a/amarok/src/core-impl/collections/playdarcollection/support/Controller.h +++ /dev/null @@ -1,158 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Andrew Coder * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef PLAYDAR_CONTROLLER_H -#define PLAYDAR_CONTROLLER_H - -#include -#include - -class KUrl; -class KJob; - -class QString; - -/** - * @namespace Playdar contains the implementation of the Playdar API - * in Amarok, so far as it is not specific to collection or context use. - */ -namespace Playdar -{ - class Query; - class ProxyResolver; - - /** - * This class provides a basic interface to Playdar's resolution - * functionality. A user should initialize a Controller, wait for - * playdarReady(), and proceed to use resolve( artist, album, title ) - * as much as they'd like. Unless some error occurs, queryReady( QueryPtr ) - * will provide a QueryPtr for each call to resolve(). Results will - * be provided by the appropriate Query as they become available, and - * the friendly relationship between Controller and Query ensures that - * results are properly matched with Queries. - */ - class Controller : public QObject - { - Q_OBJECT - public: - /** - * We invoke the private function status() here, return immediately, - * and will emit playdarReady() once things are actually set up. - * @param queriesShouldWaitForSolutions - * If true, Playdar::Queries created by this controller will - * only use getResultsLongPoll instead of first using getResults. - */ - Controller( bool queriesShouldWaitForSolutions = false ); - /** - * Controllers don't hold on to anything, so the deconstructor does nothing. - */ - ~Controller(); - - /** - * Asks Playdar for status information, which eventually results in - * the emission of playdarReady() if it does or error() otherwise. - */ - void status(); - - /** - * Asks Playdar to resolve a query, which eventually results in the - * emission of queryReady() if okay, or error() if something goes wrong. - * @param artist Name of artist to search for. - * @param album Name of album (by artist) to search for. - * @param title Name of track on album to search for. - * NOTE: Currently, for a query to have any chance of being solved, - * both artist and title must be non-empty! - */ - void resolve( const QString &artist, - const QString &album, - const QString &title ); - - /** These errors are used when Playdar::Controller emits error(). */ - enum ErrorState - { - /** Nothing bad happened yet! */ - NoError, - /** Indicates an error from KIO or the Playdar service itself. */ - ExternalError, - /** A request for status revealed a service claiming to not be Playdar. */ - WrongServiceName, - /** A service asked for status didn't identify itself. */ - MissingServiceName, - /** No "qid" field was found in a response to resolve() or getResults(). */ - MissingQid, - /** Results were delivered to the wrong query */ - WrongQid, - /** A response to getResults() didn't include a "results" array. */ - MissingResults - }; - - signals: - /** - * Emitted once after construction, as long as some service responds - * from where we think Playdar is, and identifies itself as "playdar". - * Clients shouldn't try to resolve things until they get this signal. - */ - void playdarReady(); - /** - * Emitted after resolve() is invoked, as long as Playdar's response - * includes a "qid" field. If the client object's looking for results, - * the Query's where they'll be when Playdar's got back to us. The - * controller doesn't keep any QueryPtrs around, so interested clients - * should keep a QueryList for any QueryPtrs they'd like to have. - */ - void queryReady( Playdar::Query* ); - /** - * Emitted after something unfortunate happens, - * along with the (hopefully) appropriate ErrorType - */ - void playdarError( Playdar::Controller::ErrorState ); - - public: - /** - * NOTE: Queries handle invoking these on their own. - */ - /** - * Asks Playdar for the state of the query with @p qid. - * If all goes well, resultsReady() is emitted, error() if something goes wrong. - * @param query The query to get results for - */ - void getResults( Playdar::Query* query ); - /** - * Like getResults(), but Playdar will wait to respond until the query - * has either been solved or enough time passes, (usually about 4000ms), - * that the query would have been solved it was possible. - * @param query The query to get results for - */ - void getResultsLongPoll( Playdar::Query* query ); - - /** - * Makes a naive attempt to produce a KUrl that points to - * a playable location of a query result. - * @param sid The sid of the result desired. - */ - KUrl urlForSid( const QString &sid ) const; - - private Q_SLOTS: - void processStatus( KJob* statusJob ); - void processQuery( KJob* queryJob ); - - private: - ErrorState m_errorState; - bool m_queriesShouldWaitForSolutions; - }; -} - -#endif diff --git a/amarok/src/core-impl/collections/playdarcollection/support/ProxyResolver.cpp b/amarok/src/core-impl/collections/playdarcollection/support/ProxyResolver.cpp deleted file mode 100644 index c7683c1a..00000000 --- a/amarok/src/core-impl/collections/playdarcollection/support/ProxyResolver.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Andrew Coder * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "ProxyResolver.h" - -#include "Controller.h" -#include "../PlaydarCollection.h" -#include "../PlaydarMeta.h" -#include "core-impl/meta/proxy/MetaProxy.h" - -#include - -#include - -Playdar::ProxyResolver::ProxyResolver( Collections::PlaydarCollection *collection, - const KUrl &url, MetaProxy::TrackPtr track ) - : m_collection( collection ) - , m_proxyTrack( track ) - , m_controller( new Playdar::Controller( true ) ) - , m_query() -{ - connect( m_controller, SIGNAL(playdarError(Playdar::Controller::ErrorState)), - this, SLOT(slotPlaydarError(Playdar::Controller::ErrorState)) ); - connect( m_controller, SIGNAL(queryReady(Playdar::Query*)), - this, SLOT(collectQuery(Playdar::Query*)) ); - m_controller->resolve( url.queryItem( "artist" ), - url.queryItem( "album" ), - url.queryItem( "title" ) ); -} - -Playdar::ProxyResolver::~ProxyResolver() -{ - delete m_query; - delete m_controller; -} - -void -Playdar::ProxyResolver::slotPlaydarError( Playdar::Controller::ErrorState error ) -{ - emit playdarError( error ); - this->deleteLater(); -} - -void -Playdar::ProxyResolver::collectQuery( Playdar::Query *query ) -{ - m_query = query; - connect( m_query, SIGNAL(querySolved(Meta::PlaydarTrackPtr)), - this, SLOT(collectSolution(Meta::PlaydarTrackPtr)) ); - connect( m_query, SIGNAL(queryDone(Playdar::Query*,Meta::PlaydarTrackList)), - this, SLOT(slotQueryDone(Playdar::Query*,Meta::PlaydarTrackList)) ); -} - -void -Playdar::ProxyResolver::collectSolution( Meta::PlaydarTrackPtr track ) -{ - if( !m_proxyTrack->isPlayable() ) - { - Meta::TrackPtr realTrack; - - if( !m_collection.isNull() ) - { - track->addToCollection( m_collection ); - realTrack = m_collection->trackForUrl( track->uidUrl() ); - } - else - realTrack = Meta::TrackPtr::staticCast( track ); - - m_proxyTrack->updateTrack( realTrack ); - } -} - -void -Playdar::ProxyResolver::slotQueryDone( Playdar::Query* query, const Meta::PlaydarTrackList& tracks ) -{ - Q_UNUSED( query ); - Q_UNUSED( tracks ); - this->deleteLater(); -} - diff --git a/amarok/src/core-impl/collections/playdarcollection/support/ProxyResolver.h b/amarok/src/core-impl/collections/playdarcollection/support/ProxyResolver.h deleted file mode 100644 index 06a06691..00000000 --- a/amarok/src/core-impl/collections/playdarcollection/support/ProxyResolver.h +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Andrew Coder * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef PLAYDAR_PROXY_RESOLVER_H -#define PLAYDAR_PROXY_RESOLVER_H - -#include "Controller.h" -#include "../PlaydarCollection.h" -#include "../PlaydarMeta.h" -#include "core-impl/meta/proxy/MetaProxy.h" - -#include - -class KUrl; - -namespace Playdar -{ - /** - * ProxyResolver takes a MetaProxy::Track and a playdar:// url, - * and updates the Track with a PlaydarTrack if we can find it. - */ - class ProxyResolver : public QObject - { - Q_OBJECT - - public: - ProxyResolver( Collections::PlaydarCollection *collection, - const KUrl &url, MetaProxy::TrackPtr track ); - ~ProxyResolver(); - - signals: - void playdarError( Playdar::Controller::ErrorState ); - - private Q_SLOTS: - void slotPlaydarError( Playdar::Controller::ErrorState error ); - void collectQuery( Playdar::Query *query ); - void collectSolution( Meta::PlaydarTrackPtr track ); - void slotQueryDone( Playdar::Query *query, const Meta::PlaydarTrackList & tracks ); - - private: - QPointer< Collections::PlaydarCollection > m_collection; - MetaProxy::TrackPtr m_proxyTrack; - Playdar::Controller* m_controller; - Playdar::Query* m_query; - }; -} - -#endif diff --git a/amarok/src/core-impl/collections/playdarcollection/support/QMFunctionTypes.h b/amarok/src/core-impl/collections/playdarcollection/support/QMFunctionTypes.h deleted file mode 100644 index 870eef30..00000000 --- a/amarok/src/core-impl/collections/playdarcollection/support/QMFunctionTypes.h +++ /dev/null @@ -1,195 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Andrew Coder * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef QUERYMAKER_FUNCTION_TYPES_H -#define QUERYMAKER_FUNCTION_TYPES_H - -#include "core/collections/QueryMaker.h" - -using namespace Collections; - -/** - * A CurriedQMFunction is a call to any of the member functions - * of QueryMaker that return a QueryMaker*, which it's arguments - * specified, but missing, (normally implicit), this pointer parameter. - * - * Subclasses provide a typedef named FunPtr as a convenience, which - * provides a type equal to that of a pointer to a QueryMaker member - * function which returns a QueryMaker* and accepts the number and - * type of parameters that the CurriedQMFunction does. Having the - * typedefs in the classes prevents issues with C++'s lack of support - * for template typedefs. - */ -class CurriedQMFunction -{ - public: - virtual ~CurriedQMFunction() {}; - /** - * Invokes the stored function, with the stored - * parameters, providing @param qm as the this pointer. - * @return qm - */ - virtual QueryMaker* operator()( QueryMaker *qm = 0 ) = 0; -}; - -/** - * The CurriedQMFunction for functions with no arguments. - */ -class CurriedZeroArityQMFunction : public CurriedQMFunction -{ - public: - typedef QueryMaker* ( QueryMaker::*FunPtr ) (); - - CurriedZeroArityQMFunction( FunPtr function ) - : m_function( function ) - {}; - virtual ~CurriedZeroArityQMFunction() {}; - - QueryMaker* operator()( QueryMaker *qm = 0 ) - { - if( qm ) - return ( qm->*m_function )(); - return qm; - }; - - private: - FunPtr m_function; -}; - -/** - * The CurriedQMFunction for functions with one arguments. - */ -template< class Type > -class CurriedUnaryQMFunction : public CurriedQMFunction -{ - public: - typedef QueryMaker* ( QueryMaker::*FunPtr ) ( Type ); - - CurriedUnaryQMFunction( FunPtr function, Type parameter ) - : m_function( function ) - , m_parameter( parameter ) - {}; - virtual ~CurriedUnaryQMFunction() {}; - - QueryMaker* operator()( QueryMaker *qm ) - { - if( qm ) - return ( qm->*m_function )( m_parameter ); - return qm; - }; - - private: - FunPtr m_function; - Type m_parameter; -}; - -/** - * The CurriedQMFunction for functions with two arguments. - */ -template< class FirstType, class SecondType > -class CurriedBinaryQMFunction : public CurriedQMFunction -{ - public: - typedef QueryMaker* ( QueryMaker::*FunPtr ) ( FirstType, SecondType ); - - CurriedBinaryQMFunction( FunPtr function, FirstType parameterOne, SecondType parameterTwo ) - : m_function( function ) - , m_parameterOne( parameterOne ) - , m_parameterTwo( parameterTwo ) - {}; - virtual ~CurriedBinaryQMFunction() {}; - - QueryMaker* operator()( QueryMaker *qm ) - { - if( qm ) - return ( qm->*m_function )( m_parameterOne, m_parameterTwo ); - return qm; - }; - - private: - FunPtr m_function; - FirstType m_parameterOne; - SecondType m_parameterTwo; -}; - -/** - * The CurriedQMFunction for functions with three arguments. - */ -template< class FirstType, class SecondType, class ThirdType > -class CurriedTrinaryQMFunction : public CurriedQMFunction -{ - public: - typedef QueryMaker* ( QueryMaker::*FunPtr ) ( FirstType, SecondType, ThirdType ); - - CurriedTrinaryQMFunction( FunPtr function, FirstType parameterOne, SecondType parameterTwo, ThirdType parameterThree ) - : m_function( function ) - , m_parameterOne( parameterOne ) - , m_parameterTwo( parameterTwo ) - , m_parameterThree( parameterThree ) - {}; - virtual ~CurriedTrinaryQMFunction() {}; - - QueryMaker* operator()( QueryMaker *qm ) - { - if( qm ) - return ( qm->*m_function )( m_parameterOne, m_parameterTwo, m_parameterThree ); - return qm; - }; - - private: - FunPtr m_function; - FirstType m_parameterOne; - SecondType m_parameterTwo; - ThirdType m_parameterThree; -}; - -/** - * The CurriedQMFunction for functions with four arguments. - * Passing the QString as a reference to the constructor caused - * some problems, so this one's specialized for the only two - * members of QueryMaker that have four parameters, addFilter - * and excludeFilter. - */ -class CurriedQMStringFilterFunction : public CurriedQMFunction -{ - public: - typedef QueryMaker* ( QueryMaker::*FunPtr ) ( qint64, const QString&, bool, bool ); - - CurriedQMStringFilterFunction( FunPtr function, qint64 value, QString filter, bool matchBegin, bool matchEnd ) - : m_function( function ) - , m_value( value ) - , m_filter( filter ) - , m_matchBegin( matchBegin ) - , m_matchEnd( matchEnd ) - {}; - virtual ~CurriedQMStringFilterFunction() {}; - - QueryMaker* operator()( QueryMaker *qm ) - { - if( qm ) - return ( qm->*m_function )( m_value, m_filter, m_matchBegin, m_matchEnd ); - return qm; - }; - - private: - FunPtr m_function; - qint64 m_value; - QString m_filter; - bool m_matchBegin; - bool m_matchEnd; -}; - -#endif diff --git a/amarok/src/core-impl/collections/playdarcollection/support/Query.cpp b/amarok/src/core-impl/collections/playdarcollection/support/Query.cpp deleted file mode 100644 index 02600a07..00000000 --- a/amarok/src/core-impl/collections/playdarcollection/support/Query.cpp +++ /dev/null @@ -1,219 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Andrew Coder * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "Query.h" - -#include "Controller.h" -#include "core/meta/Meta.h" -#include "../PlaydarMeta.h" -#include "core/support/Debug.h" - -#include - -#include -#include - -#include -#include -#include -#include - -namespace Playdar -{ - Query::Query( const QString &qid, - Playdar::Controller* controller, - bool waitForSolution ) - : m_controller( controller ) - , m_waitForSolution( waitForSolution ) - , m_qid( qid ) - , m_artist( QString( "" ) ) - , m_album( QString( "" ) ) - , m_title( QString( "" ) ) - , m_solved( false ) - , m_receivedFirstResults( false ) - , m_trackList( ) - { - DEBUG_BLOCK - - if( m_waitForSolution ) - { - m_receivedFirstResults = true; - m_controller.data()->getResultsLongPoll( this ); - } - else - m_controller.data()->getResults( this ); - } - - Query::~Query() - { - DEBUG_BLOCK - - } - - QString - Query::qid() const - { - DEBUG_BLOCK - - return m_qid; - } - - QString - Query::artist() const - { - DEBUG_BLOCK - - return m_artist; - } - - QString - Query::album() const - { - DEBUG_BLOCK - - return m_album; - } - - QString - Query::title() const - { - DEBUG_BLOCK - - return m_title; - } - - bool - Query::isSolved() const - { - DEBUG_BLOCK - - return m_solved; - } - - Meta::PlaydarTrackList - Query::getTrackList() const - { - DEBUG_BLOCK - - return m_trackList; - } - - void - Query::receiveResults( KJob* resultsJob) - { - DEBUG_BLOCK - - if( resultsJob->error() != 0 ) { - debug() << "Error getting results from Playdar"; - emit playdarError( Playdar::Controller::ErrorState( 1 ) ); - return; - } - - debug() << "Processing received JSON data..."; - KIO::StoredTransferJob* storedResultsJob = static_cast( resultsJob ); - - QJson::Parser parser; - bool ok; - QVariant parsedResultsVariant; - parsedResultsVariant = parser.parse( storedResultsJob->data(),&ok ); - if ( !ok ) - { - debug() << "Error parsing JSON Data"; - } - - QVariantMap parsedResults = parsedResultsVariant.toMap(); - if( !parsedResults.contains( "results" ) ) - { - debug() << "Expecting results in Playdar's response, received none"; - emit playdarError( Playdar::Controller::ErrorState( 6 ) ); - return; - } - if( !parsedResults.contains( "qid" ) ) - { - debug() << "Expected qid in Playdar's response, received none"; - emit playdarError( Playdar::Controller::ErrorState( 4 ) ); - return; - } - if( parsedResults.value( "qid" ) != m_qid ) - { - debug() << "A query received the wrong results from Playdar..."; - emit playdarError( Playdar::Controller::ErrorState( 5 ) ); - return; - } - - m_artist = parsedResults.value( "artist" ).toString(); - m_album = parsedResults.value( "album" ).toString(); - m_title = parsedResults.value( "track" ).toString(); - - foreach( const QVariant &resultVariant, parsedResults.value( "results" ).toList() ) - { - QVariantMap result = resultVariant.toMap(); - Meta::PlaydarTrackPtr aTrack; - KUrl resultUrl( m_controller.data()->urlForSid( result.value( "sid" ).toString() ) ); - - QString trackSid = result.value( "sid" ).toString(); - QString trackUrl = resultUrl.url(); - QString trackTitle = result.value( "track" ).toString(); - QString trackArtist = result.value( "artist" ).toString(); - QString trackAlbum = result.value( "album" ).toString(); - QString trackType = result.value( "mimetype" ).toString(); - QString trackSource = result.value( "source" ).toString(); - qint64 trackLengthInSeconds( result.value( "duration" ).toInt() ); - aTrack = new Meta::PlaydarTrack - ( - trackSid, - trackUrl, - trackTitle, - trackArtist, - trackAlbum, - trackType, - result.value( "score" ).toDouble() * 100, - ( trackLengthInSeconds * 1000 ), //convert s to ms - result.value( "bitrate" ).toInt(), - result.value( "size" ).toInt(), - trackSource - ); - - if( !m_solved && aTrack->score() >= 1.00 ) - { - m_solved = true; - m_trackList.prepend( aTrack ); - emit querySolved( aTrack ); - - if( m_waitForSolution ) - { - emit queryDone( this, m_trackList ); - return; - } - } - else - { - m_trackList.append( aTrack ); - } - emit newTrackAdded( aTrack ); - } - - if( m_receivedFirstResults || m_solved ) - { - m_receivedFirstResults = true; - emit queryDone( this, m_trackList ); - } - else - { - m_receivedFirstResults = true; - m_controller.data()->getResultsLongPoll( this ); - } - } -} diff --git a/amarok/src/core-impl/collections/playdarcollection/support/Query.h b/amarok/src/core-impl/collections/playdarcollection/support/Query.h deleted file mode 100644 index 8bd850dd..00000000 --- a/amarok/src/core-impl/collections/playdarcollection/support/Query.h +++ /dev/null @@ -1,120 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Andrew Coder * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef PLAYDAR_QUERYOBJECT_H -#define PLAYDAR_QUERYOBJECT_H - -#include "Controller.h" -#include "core/meta/forward_declarations.h" -#include "../PlaydarMeta.h" - -#include - -class KJob; - -class QString; - -namespace Playdar -{ - /** - * A Query provides an interface to a single Playdar query. - * Clients should receive these from their Playdar::Controller, - * rather than constructing them. After getting a Query, just - * wait for newTrackAdded(), querySolved(), or queryDone(), - * as appropriate. Using QueryPtr will make sure a neglected Query - * gets deleted, and Controllers won't hold on to the reference, - * so interested objects should be sure to store their QueryPtrs. - * NOTE: artist(), album(), and title() are all empty until - * the first round of results has come in from Playdar. - * Queries are matched with results by qid(). - */ - class Query : public QObject - { - Q_OBJECT - - public: - //Constructor and Destructor - Query( const QString &qid, Playdar::Controller* controller, bool waitForSolution ); - ~Query(); - - /** @return UID for this query given by Playdar */ - QString qid() const; - /** @return Name of artist used in query */ - QString artist() const; - /** @return Name of album used in query */ - QString album() const; - /** @return Track title used in query */ - QString title() const; - /** - * @return @c true A track has received a 1.00 score - * @return @c false No track has a 1.00 score - */ - bool isSolved() const; - - /** - * @return 0 if the query is unsolved, and an arbitrary track - * with a perfect score of 1.00 if the query is solved. - */ - Meta::PlaydarTrackPtr getSolution() const; - /** - * @return The (possibly empty) PlaydarTrackList containing any - * results found so far. - */ - Meta::PlaydarTrackList getTrackList() const; - - public Q_SLOTS: - void receiveResults( KJob* ); - - signals: - /** - * Emitted each time a new track is added to the list of results, - * returning the latest result as a Meta::PlaydarTrack. - */ - void newTrackAdded( Meta::PlaydarTrackPtr ); - /** - * Emitted once if a query is solved, and returns the first track - * with a perfect score of 1.00. Will not be emitted if the query - * ends otherwise. (Emitted alongside newTrackAdded). - */ - void querySolved( Meta::PlaydarTrackPtr ); - /** - * Emitted once all results that may be found by our means have - * been found, and returns the internal results list in its final state. - */ - void queryDone( Playdar::Query*, Meta::PlaydarTrackList ); - /** - * Indicates an error. Don't bother connecting to this if you're - * already connected to Controller::error, since the controller - * will pass the signal along. - */ - void playdarError( Playdar::Controller::ErrorState ); - - private: - QWeakPointer< Playdar::Controller > m_controller; - bool m_waitForSolution; - - QString m_qid; - QString m_artist; - QString m_album; - QString m_title; - bool m_solved; - - bool m_receivedFirstResults; - - Meta::PlaydarTrackList m_trackList; - }; -} -#endif diff --git a/amarok/src/core-impl/collections/support/ArtistHelper.cpp b/amarok/src/core-impl/collections/support/ArtistHelper.cpp deleted file mode 100644 index 4c3f7428..00000000 --- a/amarok/src/core-impl/collections/support/ArtistHelper.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "ArtistHelper.h" - -#include - -#include - -QString -ArtistHelper::bestGuessAlbumArtist( const QString &albumArtist, const QString &trackArtist, - const QString &genre, const QString &composer) -{ - QString best( albumArtist ); - - // - for classical tracks it's the composer - if( best.isEmpty() && - (genre.compare( i18nc( "The genre name for classical music", "Classical" ), Qt::CaseInsensitive ) == 0 || - genre.compare( QLatin1String( "Classical" ), Qt::CaseInsensitive ) == 0 ) ) - best = ArtistHelper::realTrackArtist( composer ); - - // - for "normal" tracks it's the track artist - if( best.isEmpty() ) - best = ArtistHelper::realTrackArtist( trackArtist ); - - // - "Various Artists" is the same as no artist - if( best.compare( i18n( "Various Artists" ), Qt::CaseInsensitive ) == 0 || - best.compare( QLatin1String( "Various Artists" ), Qt::CaseInsensitive ) == 0 ) - best.clear(); - - return best; -} - -QString -ArtistHelper::realTrackArtist( const QString &trackArtistTag ) -{ - bool featuring = false; - QStringList trackArtists; - if( trackArtistTag.contains( "featuring" ) ) - { - featuring = true; - trackArtists = trackArtistTag.split( "featuring" ); - } - else if( trackArtistTag.contains( "feat." ) ) - { - featuring = true; - trackArtists = trackArtistTag.split( "feat." ); - } - else if( trackArtistTag.contains( "ft." ) ) - { - featuring = true; - trackArtists = trackArtistTag.split( "ft." ); - } - else if( trackArtistTag.contains( "f." ) ) - { - featuring = true; - trackArtists = trackArtistTag.split( "f." ); - } - - //this needs to be improved - - if( featuring ) - { - //always use the first artist - QString tmp = trackArtists[0].simplified(); - //artists are written as "A (feat. B)" or "A [feat. B]" as well - if( tmp.endsWith(" (") || tmp.endsWith( " [" ) ) - tmp = tmp.left( tmp.length() -2 ).simplified(); //remove last two characters - - if( tmp.isEmpty() ) - return trackArtistTag; //huh? - else - { - return tmp; - } - } - else - { - return trackArtistTag; - } -} diff --git a/amarok/src/core-impl/collections/support/ArtistHelper.h b/amarok/src/core-impl/collections/support/ArtistHelper.h deleted file mode 100644 index 38b441d4..00000000 --- a/amarok/src/core-impl/collections/support/ArtistHelper.h +++ /dev/null @@ -1,44 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef ARTISTHELPER_H -#define ARTISTHELPER_H - -#include "amarok_export.h" - -#include - -namespace ArtistHelper -{ - /** - * Return the best guess of the album artist. - * - * Guessing algorithm includes extracting artist from composer for classical tracks, - * falling back to trackArtist if albumArtist is empty etc. Returns empty string for - * tracks that are believed to belong into a compilation. - */ - AMAROK_EXPORT QString bestGuessAlbumArtist( const QString &albumArtist, const QString &trackArtist, - const QString &genre, const QString &composer ); - - /** - * This helper function will determine the actual track artist. - * It takes into account "A featuring B" strings, in which case - * the actual track artist would be A. - */ - AMAROK_EXPORT QString realTrackArtist( const QString &trackArtistTag ); -} - -#endif diff --git a/amarok/src/core-impl/collections/support/CollectionLocationDelegateImpl.cpp b/amarok/src/core-impl/collections/support/CollectionLocationDelegateImpl.cpp deleted file mode 100644 index 14fd2512..00000000 --- a/amarok/src/core-impl/collections/support/CollectionLocationDelegateImpl.cpp +++ /dev/null @@ -1,146 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Ryan McCoskrie * - * Copyright (c) 2010 Maximilian Kossick * - * Copyright (c) 2010 Casey Link * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "CollectionLocationDelegateImpl.h" - -#include "core/interfaces/Logger.h" -#include "core/collections/CollectionLocation.h" -#include "core/support/Components.h" -#include "transcoding/TranscodingAssistantDialog.h" - -#include -#include - -using namespace Collections; - -bool -CollectionLocationDelegateImpl::reallyDelete( CollectionLocation *loc, const Meta::TrackList &tracks ) const -{ - QStringList files = trackList( tracks ); - const QString text( i18ncp( "@info", - "Do you really want to delete this track? It will be removed from %2 and from underlying storage medium.", - "Do you really want to delete these %1 tracks? They will be removed from %2 and from underlying storage medium.", - tracks.count(), loc->prettyLocation()) ); - int ret = KMessageBox::warningContinueCancelList(0, text, files, - i18nc( "@title:window", "Confirm Delete" ), KStandardGuiItem::del() ); - return ret == KMessageBox::Continue; -} - -bool -CollectionLocationDelegateImpl::reallyTrash( CollectionLocation *loc, const Meta::TrackList &tracks ) const -{ - QStringList files = trackList( tracks ); - const QString text( i18ncp( "@info", - "Do you really want to move this track to the trash? It will be removed from %2.", - "Do you really want to move these %1 tracks to the trash? They will be removed from %2.", - tracks.count(), loc->prettyLocation() ) ); - int ret = KMessageBox::warningContinueCancelList( 0, text, files, - i18nc( "@title:window", "Confirm Move to Trash" ), KStandardGuiItem::remove() ); - return ret == KMessageBox::Continue; -} - -bool -CollectionLocationDelegateImpl::reallyMove( CollectionLocation *loc, const Meta::TrackList &tracks ) const -{ - Q_UNUSED( loc ) - QStringList files = trackList( tracks ); - const QString text( i18ncp( "@info", - "Do you really want to move this track? It will be renamed and the original deleted.", - "Do you really want to move these %1 tracks? They will be renamed and the originals deleted.", - tracks.count() ) ); - int ret = KMessageBox::warningContinueCancelList( 0, text, files, - i18nc( "@title:window", "Move Files" ), KGuiItem( i18nc( "rename files button", "&Rename" ), "go-jump" ) ); - return ret == KMessageBox::Continue; -} - -void -CollectionLocationDelegateImpl::errorDeleting( CollectionLocation *loc, const Meta::TrackList &tracks ) const -{ - Q_UNUSED( loc ) - QStringList files = trackList( tracks ); - const QString text( i18ncp( "@info", - "There was a problem and this track could not be removed. Make sure the directory is writable.", - "There was a problem and %1 tracks could not be removed. Make sure the directory is writable.", - files.count() ) ); - KMessageBox::informationList( 0, text, files, i18n( "Unable to remove tracks") ); -} - -void -CollectionLocationDelegateImpl::notWriteable( CollectionLocation *loc ) const -{ - Q_UNUSED( loc ) - Amarok::Components::logger()->longMessage( - i18n( "The collection does not have enough free space available or is not writable." ), - Amarok::Logger::Error ); -} - -bool -CollectionLocationDelegateImpl::deleteEmptyDirs( CollectionLocation *loc ) const -{ - const QString text( i18n( "Do you want to remove empty folders?" ) ); - const QString caption( i18n( "Remove empty folders?" ) ); - int result = KMessageBox::questionYesNo( 0, text, caption, KStandardGuiItem::yes(), - KStandardGuiItem::no(), QString( "Delete empty dirs from " + loc->prettyLocation() ) ); - return result == KMessageBox::Yes; -} - -Transcoding::Configuration -CollectionLocationDelegateImpl::transcode( const QStringList &playableFileTypes, - bool *remember, OperationType operation, - const QString &destCollectionName, - const Transcoding::Configuration &prevConfiguration ) const -{ - Transcoding::AssistantDialog dialog( playableFileTypes, remember != 0, operation, - destCollectionName, prevConfiguration ); - if( dialog.exec() ) - { - if( remember ) - *remember = dialog.shouldSave(); - return dialog.configuration(); - } - return Transcoding::Configuration( Transcoding::INVALID ); -} - -QStringList -CollectionLocationDelegateImpl::trackList( const Meta::TrackList &tracks ) const -{ - QStringList trackList; - foreach( Meta::TrackPtr track, tracks ) - { - QString url = track->prettyUrl(); - Meta::ArtistPtr artist = track->artist(); - QString artistName = artist ? artist->name() : QString(); - QString trackName = track->name(); - - QString str; - // Add track and artist name if available - if( !trackName.isEmpty() && !artistName.isEmpty() ) - str = i18nc( "%1 is track url, %2 track title, %3 track artist", - "%1 (%2 by %3)", url, trackName, artistName ); - else if( !trackName.isEmpty() ) - str = i18nc( "%1 is track url, %2 track name", "%1 (%2)", url, trackName ); - else if( !artistName.isEmpty() ) - str = i18nc( "%1 is track url, %2 artist name", "%1 (by %2)", url, artistName ); - else - str = url; - - trackList << str; - } - - return trackList; -} diff --git a/amarok/src/core-impl/collections/support/CollectionLocationDelegateImpl.h b/amarok/src/core-impl/collections/support/CollectionLocationDelegateImpl.h deleted file mode 100644 index 9d905801..00000000 --- a/amarok/src/core-impl/collections/support/CollectionLocationDelegateImpl.h +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Ryan McCoskrie * - * Copyright (c) 2010 Maximilian Kossick * - * Copyright (c) 2010 Casey Link * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef COLLECTIONLOCATIONDELEGATEIMPL_H -#define COLLECTIONLOCATIONDELEGATEIMPL_H - -#include "amarok_export.h" -#include "core/collections/CollectionLocationDelegate.h" - -#include - -namespace Collections { - -class AMAROK_EXPORT CollectionLocationDelegateImpl : public CollectionLocationDelegate -{ -public: - CollectionLocationDelegateImpl() {}; - virtual ~ CollectionLocationDelegateImpl() {}; - - virtual bool reallyDelete( CollectionLocation *loc, const Meta::TrackList &tracks ) const; - virtual bool reallyMove(CollectionLocation* loc, const Meta::TrackList& tracks) const; - virtual bool reallyTrash( CollectionLocation *loc, const Meta::TrackList &tracks ) const; - virtual void errorDeleting( CollectionLocation* loc, const Meta::TrackList& tracks ) const; - virtual void notWriteable(CollectionLocation* loc) const; - virtual bool deleteEmptyDirs(CollectionLocation* loc) const; - virtual Transcoding::Configuration transcode( const QStringList &playableFileTypes, - bool *remember, OperationType operation, - const QString &destCollectionName, - const Transcoding::Configuration &prevConfiguration ) const; - -private: - QStringList trackList( const Meta::TrackList &tracks ) const; -}; - -} //namespace Collections - -#endif diff --git a/amarok/src/core-impl/collections/support/CollectionManager.cpp b/amarok/src/core-impl/collections/support/CollectionManager.cpp deleted file mode 100644 index 72d7f7ab..00000000 --- a/amarok/src/core-impl/collections/support/CollectionManager.cpp +++ /dev/null @@ -1,426 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007-2008 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "CollectionManager" - -#include "CollectionManager.h" - -#include "core/capabilities/CollectionScanCapability.h" -#include "core/collections/Collection.h" -#include "core/collections/MetaQueryMaker.h" -#include "core/support/Amarok.h" -#include "core/support/Debug.h" -#include "core/support/SmartPointerList.h" -#include "core-impl/meta/file/FileTrackProvider.h" -#include "core-impl/meta/stream/Stream.h" -#include "core-impl/meta/timecode/TimecodeTrackProvider.h" - -#include -#include - -#include -#include -#include -#include -#include - -typedef QPair CollectionPair; - - -/** Private structure of the collection manager */ -struct CollectionManager::Private -{ - QList collections; - QList factories; // factories belong to PluginManager - - QList trackProviders; - TimecodeTrackProvider *timecodeTrackProvider; - Collections::TrackProvider *fileTrackProvider; // special case - - Collections::Collection *primaryCollection; - - QReadWriteLock lock; ///< protects all other variables against threading issues -}; - -CollectionManager *CollectionManager::s_instance = 0; - -CollectionManager * -CollectionManager::instance() -{ - if( !s_instance ) { - s_instance = new CollectionManager(); - s_instance->init(); - } - - return s_instance; -} - -void -CollectionManager::destroy() -{ - if( s_instance ) { - delete s_instance; - s_instance = 0; - } -} - -CollectionManager::CollectionManager() - : QObject() - , d( new Private ) -{ - DEBUG_BLOCK - // ensure this object is created in a main thread - Q_ASSERT( thread() == QCoreApplication::instance()->thread() ); - - setObjectName( "CollectionManager" ); - d->primaryCollection = 0; - d->timecodeTrackProvider = 0; - d->fileTrackProvider = 0; -} - -CollectionManager::~CollectionManager() -{ - DEBUG_BLOCK - - { - QWriteLocker locker( &d->lock ); - - d->collections.clear(); - d->trackProviders.clear(); - delete d->timecodeTrackProvider; - delete d->fileTrackProvider; - - // Hmm, qDeleteAll from Qt 4.8 crashes with our SmartPointerList, do it manually. Bug 285951 - while (!d->factories.isEmpty() ) - delete d->factories.takeFirst(); - } - - delete d; -} - -void -CollectionManager::init() -{ - // register the timecode track provider now, as it needs to get added before loading - // the stored playlist... Since it can have playable urls that might also match other providers, it needs to get added first. - d->timecodeTrackProvider = new TimecodeTrackProvider(); - addTrackProvider( d->timecodeTrackProvider ); - - // addint fileTrackProvider second since local tracks should be preferred even if the url matchs two tracks - d->fileTrackProvider = new FileTrackProvider(); - addTrackProvider( d->fileTrackProvider ); -} - -void -CollectionManager::setFactories( const QList &factories ) -{ - using Collections::CollectionFactory; - - - QSet newFactories = factories.toSet(); - QSet oldFactories; - - { - QReadLocker locker( &d->lock ); - oldFactories = d->factories.toSet(); - } - - // remove old factories - foreach( Plugins::PluginFactory* pFactory, oldFactories - newFactories ) - { - - CollectionFactory *factory = qobject_cast( pFactory ); - if( !factory ) - continue; - - disconnect( factory, SIGNAL(newCollection(Collections::Collection*)), - this, SLOT(slotNewCollection(Collections::Collection*)) ); - { - QWriteLocker locker( &d->lock ); - d->factories.removeAll( factory ); - } - } - - // create new factories - foreach( Plugins::PluginFactory* pFactory, newFactories - oldFactories ) - { - CollectionFactory *factory = qobject_cast( pFactory ); - if( !factory ) - continue; - - connect( factory, SIGNAL(newCollection(Collections::Collection*)), - this, SLOT(slotNewCollection(Collections::Collection*)) ); - { - QWriteLocker locker( &d->lock ); - d->factories.append( factory ); - } - } - - d->factories = factories; -} - - -void -CollectionManager::startFullScan() -{ - QReadLocker locker( &d->lock ); - - foreach( const CollectionPair &pair, d->collections ) - { - QScopedPointer csc( pair.first->create()); - if( csc ) - csc->startFullScan(); - } -} - -void -CollectionManager::startIncrementalScan( const QString &directory ) -{ - QReadLocker locker( &d->lock ); - - foreach( const CollectionPair &pair, d->collections ) - { - QScopedPointer csc( pair.first->create()); - if( csc ) - csc->startIncrementalScan( directory ); - } -} - -void -CollectionManager::stopScan() -{ - QReadLocker locker( &d->lock ); - - foreach( const CollectionPair &pair, d->collections ) - { - QScopedPointer csc( pair.first->create()); - if( csc ) - csc->stopScan(); - } -} - -void -CollectionManager::checkCollectionChanges() -{ - startIncrementalScan( QString() ); -} - -Collections::QueryMaker* -CollectionManager::queryMaker() const -{ - QReadLocker locker( &d->lock ); - - QList colls; - foreach( const CollectionPair &pair, d->collections ) - { - if( pair.second & CollectionQueryable ) - { - colls << pair.first; - } - } - return new Collections::MetaQueryMaker( colls ); -} - -void -CollectionManager::slotNewCollection( Collections::Collection* newCollection ) -{ - DEBUG_BLOCK - - if( !newCollection ) - { - error() << "newCollection in slotNewCollection is 0"; - return; - } - { - QWriteLocker locker( &d->lock ); - foreach( const CollectionPair &p, d->collections ) - { - if( p.first == newCollection ) - { - error() << "newCollection " << newCollection->collectionId() << " is already being managed"; - return; - } - } - } - - const QMetaObject *mo = metaObject(); - const QMetaEnum me = mo->enumerator( mo->indexOfEnumerator( "CollectionStatus" ) ); - const QString &value = KGlobal::config()->group( "CollectionManager" ).readEntry( newCollection->collectionId() ); - int enumValue = me.keyToValue( value.toLocal8Bit().constData() ); - CollectionStatus status; - enumValue == -1 ? status = CollectionEnabled : status = (CollectionStatus) enumValue; - CollectionPair pair( newCollection, status ); - - { - QWriteLocker locker( &d->lock ); - if( newCollection->collectionId() == QLatin1String("localCollection") ) - { - d->primaryCollection = newCollection; - d->collections.insert( 0, pair ); // the primary collection should be the first collection to be searched - d->trackProviders.insert( 1, newCollection ); // the primary collection should be between the timecode track provider and the local file track provider - } - else - { - d->collections.append( pair ); - d->trackProviders.append( newCollection ); - } - connect( newCollection, SIGNAL(remove()), SLOT(slotRemoveCollection()), Qt::QueuedConnection ); - connect( newCollection, SIGNAL(updated()), SLOT(slotCollectionChanged()), Qt::QueuedConnection ); - - debug() << "new Collection " << newCollection->collectionId(); - } - - if( status & CollectionViewable ) - { - emit collectionAdded( newCollection ); - emit collectionAdded( newCollection, status ); - } -} - -void -CollectionManager::slotRemoveCollection() -{ - Collections::Collection* collection = qobject_cast( sender() ); - if( collection ) - { - CollectionStatus status = collectionStatus( collection->collectionId() ); - CollectionPair pair( collection, status ); - - { - QWriteLocker locker( &d->lock ); - d->collections.removeAll( pair ); - d->trackProviders.removeAll( collection ); - } - - emit collectionRemoved( collection->collectionId() ); - QTimer::singleShot( 500, collection, SLOT(deleteLater()) ); // give the tree some time to update itself until we really delete the collection pointers. - } -} - -void -CollectionManager::slotCollectionChanged() -{ - Collections::Collection *collection = dynamic_cast( sender() ); - if( collection ) - { - CollectionStatus status = collectionStatus( collection->collectionId() ); - if( status & CollectionViewable ) - { - emit collectionDataChanged( collection ); - } - } -} - -QList -CollectionManager::viewableCollections() const -{ - QReadLocker locker( &d->lock ); - - QList result; - foreach( const CollectionPair &pair, d->collections ) - { - if( pair.second & CollectionViewable ) - { - result << pair.first; - } - } - return result; -} - -Collections::Collection* -CollectionManager::primaryCollection() const -{ - QReadLocker locker( &d->lock ); - - return d->primaryCollection; -} - -Meta::TrackPtr -CollectionManager::trackForUrl( const KUrl &url ) -{ - QReadLocker locker( &d->lock ); - - // TODO: - // might be a podcast, in that case we'll have additional meta information - // might be a lastfm track, another stream - if( !url.isValid() ) - return Meta::TrackPtr( 0 ); - - foreach( Collections::TrackProvider *provider, d->trackProviders ) - { - if( provider->possiblyContainsTrack( url ) ) - { - Meta::TrackPtr track = provider->trackForUrl( url ); - if( track ) - return track; - } - } - - // TODO: create specific TrackProviders for these: - static const QSet remoteProtocols = QSet() - << "http" << "https" << "mms" << "smb"; // consider unifying with TrackLoader::tracksLoaded() - if( remoteProtocols.contains( url.protocol() ) ) - return Meta::TrackPtr( new MetaStream::Track( url ) ); - - return Meta::TrackPtr( 0 ); -} - - -CollectionManager::CollectionStatus -CollectionManager::collectionStatus( const QString &collectionId ) const -{ - QReadLocker locker( &d->lock ); - - foreach( const CollectionPair &pair, d->collections ) - { - if( pair.first->collectionId() == collectionId ) - { - return pair.second; - } - } - return CollectionDisabled; -} - -QHash -CollectionManager::collections() const -{ - QReadLocker locker( &d->lock ); - - QHash result; - foreach( const CollectionPair &pair, d->collections ) - { - result.insert( pair.first, pair.second ); - } - return result; -} - -void -CollectionManager::addTrackProvider( Collections::TrackProvider *provider ) -{ - { - QWriteLocker locker( &d->lock ); - d->trackProviders.append( provider ); - } - emit trackProviderAdded( provider ); -} - -void -CollectionManager::removeTrackProvider( Collections::TrackProvider *provider ) -{ - QWriteLocker locker( &d->lock ); - d->trackProviders.removeAll( provider ); -} - diff --git a/amarok/src/core-impl/collections/support/CollectionManager.h b/amarok/src/core-impl/collections/support/CollectionManager.h deleted file mode 100644 index 5f56394d..00000000 --- a/amarok/src/core-impl/collections/support/CollectionManager.h +++ /dev/null @@ -1,178 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007-2008 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_COLLECTIONMANAGER_H -#define AMAROK_COLLECTIONMANAGER_H - -#include "amarok_export.h" -#include "core/meta/forward_declarations.h" - -#include - -#include -#include - -class CollectionManagerSingleton; - -namespace Plugins { - class PluginFactory; -} - -namespace Collections { - class Collection; - class CollectionFactory; - class TrackProvider; - class QueryMaker; -} - -/** Class managing the different collections. - * - * This singleton class is the main repository for all current collections. - * The most usefull functions are probably queryMaker and - * viewableCollections - */ -class AMAROK_EXPORT CollectionManager : public QObject -{ - Q_OBJECT - Q_ENUMS( CollectionStatus ) - - public: - - /** - * defines the status of a collection in respect to global queries (i.e. queries that query all known collections) - * or the collection browser. - */ - enum CollectionStatus { CollectionDisabled = 1, ///< Collection neither viewable nor queryable (but might produce tracks that can be played) - CollectionViewable = 2, ///< Collection will not be queried by CollectionManager::queryMaker - CollectionQueryable= 4, ///< Collection wil not show up in the browser, but is queryable by global queries - CollectionEnabled = CollectionViewable | CollectionQueryable ///< Collection viewable in the browser and queryable - }; - - static CollectionManager *instance(); - - /** Destroys the instance of the CollectionManager. - */ - static void destroy(); - - /** - * Returns a query maker that queries all queryable the collections - */ - Collections::QueryMaker *queryMaker() const; - - /** - * returns all viewable collections. - */ - QList viewableCollections() const; - - //TODO: Remove - /** - * Allows access to one of Amarok's collection. - * - * @deprecated DO NOT USE this method. This is legacy code from the early days of Amarok - * when SqlCollection was the only working collection. If you are writing new code, make - * sure that it is able to handle multiple collections, - * e.g. multiple connected media devices. Using this method means you are lazy. An easy way - * is to use CollectionManager::queryMaker(). Alternatively, access the available collections - * using CollectionManager::queryableCollections() or CollectionManager::viewableCollections() - * and do whatever you want to. - * - */ - Collections::Collection* primaryCollection() const; - - /** - This method will try to get a Track object for the given url. This method will return 0 if no Track object - could be created for the url. - */ - Meta::TrackPtr trackForUrl( const KUrl &url ); - - CollectionStatus collectionStatus( const QString &collectionId ) const; - - QHash collections() const; - - /** - * adds a TrackProvider to the list of TrackProviders, - * which allows CollectionManager to create tracks in trackForUrl. - * CollectionManager does not take ownership of the TrackProvider pointer - * - * Note: collections that CollectionManager knows about are automatically - * added to the list of TrackProviders. - * - * @param provider the new TrackProvider - */ - void addTrackProvider( Collections::TrackProvider *provider ); - - /** - * removes a TrackProvider. Does not do anything if - * CollectionManager does not know the given TrackProvider. - * - * Note: collections will be automatically removed from - * the list of available TrackProviders. - * - * @param provider the provider to be removed - */ - void removeTrackProvider( Collections::TrackProvider *provider ); - - /** - * Set the list of current factories - * - * For every factory that is a CollectionFactory uses it to create new - * collections and register with this manager. - */ - void setFactories( const QList &factories ); - - public slots: - /** Starts the full scan for each collection with CollectionScanCapability */ - void startFullScan(); - /** Starts the incremetal scan for each collection with CollectionScanCapability */ - void startIncrementalScan( const QString &directory = QString() ); - void stopScan(); - void checkCollectionChanges(); - - signals: - //deprecated, use collectionAdded( Collections::Collection*, CollectionStatus ) instead - void collectionAdded( Collections::Collection *newCollection ); - - void collectionAdded( Collections::Collection *newCollection, CollectionManager::CollectionStatus status ); - void collectionRemoved( QString collectionId ); - void trackProviderAdded( Collections::TrackProvider *provider ); - //this signal will be emitted after major changes to the collection - //e.g. new songs where added, or an album changed - //from compilation to non-compilation (and vice versa) - //it will not be emitted on minor changes (e.g. the tags of a song were changed) - void collectionDataChanged( Collections::Collection *changedCollection ); - - private slots: - /** Will be called whenever a registered collection factory creates a new collection */ - void slotNewCollection( Collections::Collection *newCollection ); - /** Will remove the collection that emitted the signal */ - void slotRemoveCollection(); - void slotCollectionChanged(); - - private: - static CollectionManager* s_instance; - CollectionManager(); - ~CollectionManager(); - - void init(); - - - Q_DISABLE_COPY( CollectionManager ) - - struct Private; - Private * const d; -}; - -#endif /* AMAROK_COLLECTIONMANAGER_H */ diff --git a/amarok/src/core-impl/collections/support/Expression.cpp b/amarok/src/core-impl/collections/support/Expression.cpp deleted file mode 100644 index f341aba9..00000000 --- a/amarok/src/core-impl/collections/support/Expression.cpp +++ /dev/null @@ -1,198 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2006 Gbor Lehel * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "Expression.h" -#include "core/support/Debug.h" - -ExpressionParser::ExpressionParser( const QString &expression ) - : m_expression( expression ) - , m_state( ExpectMinus ) - , m_haveGroup( false ) - , m_inQuote( false ) - , m_inOrGroup( false ) -{ } - -ParsedExpression ExpressionParser::parse() -{ - const uint length = m_expression.length(); - for( uint pos = 0; pos < length; ++pos ) - parseChar( m_expression.at( pos ) ); - finishedToken(); - finishedOrGroup(); - - return m_parsed; -} - -ParsedExpression ExpressionParser::parse( const QString &expression ) //static -{ - ExpressionParser p( expression ); - return p.parse(); -} - -bool ExpressionParser::isAdvancedExpression( const QString &expression ) //static -{ - return ( expression.contains( '"' ) || - expression.contains( ':' ) || - expression.contains( '-' ) || - expression.contains( "AND" ) || - expression.contains( "OR" ) ); -} - -/* PRIVATE */ - -void ExpressionParser::parseChar( const QChar &c ) -{ - if( m_inQuote && c != '"' ) - m_string += c; - else if( c.isSpace() ) - handleSpace( c ); - else if( c == '-' ) - handleMinus( c ); - else if( c == ':' ) - handleColon( c ); - else if( c == '=' || c == '>' || c == '<' ) - handleMod( c ); - else if( c == '"' ) - handleQuote( c ); - else - handleChar( c ); -} - -void ExpressionParser::handleSpace( const QChar& ) -{ - if( m_state > ExpectMinus ) - finishedToken(); -} - -void ExpressionParser::handleMinus( const QChar &c ) -{ - if( m_state == ExpectMinus ) - { - m_element.negate = true; - m_state = ExpectField; - } - else - handleChar( c ); -} - -void ExpressionParser::handleColon( const QChar &c ) -{ - if( m_state <= ExpectField && !m_string.isEmpty() ) - { - m_element.field = m_string; - m_string.clear(); - m_state = ExpectMod; - } - else - handleChar( c ); -} - -void ExpressionParser::handleMod( const QChar &c ) -{ - if( m_state == ExpectMod ) - { - if( c == '=' ) - m_element.match = expression_element::Equals; - else if( c == '>' ) - m_element.match = expression_element::More; - else if( c == '<' ) - m_element.match = expression_element::Less; - m_state = ExpectText; - } - else - handleChar( c ); -} - -void ExpressionParser::handleQuote( const QChar& ) -{ - if( m_inQuote ) - { - finishedElement(); - m_inQuote = false; - } - else - { - if( !m_string.isEmpty() ) - finishedToken(); - m_state = ExpectText; - m_inQuote = true; - } -} - -void ExpressionParser::handleChar( const QChar &c ) -{ - m_string += c; - if( m_state <= ExpectField ) - m_state = ExpectField; - else if( m_state <= ExpectText ) - m_state = ExpectText; -} - -void ExpressionParser::finishedToken() -{ - enum { And, Or, Neither }; - int s; - if( m_haveGroup || !m_element.field.isEmpty() ) - s = Neither; - else if( m_string == "AND" ) - s = And; - else if( m_string == "OR" ) - s = Or; - else - s = Neither; - - if( s == Neither ) - finishedElement(); - else - { - m_haveGroup = true; - - if( s == Or ) - m_inOrGroup = true; - else - finishedOrGroup(); - - m_string.clear(); - m_state = ExpectMinus; - } -} - -void ExpressionParser::finishedElement() -{ - if( !m_inOrGroup ) - finishedOrGroup(); - m_inOrGroup = m_haveGroup = false; - m_element.text = m_string; - m_string.clear(); - - if( !m_element.text.isEmpty() ) - m_or.append( m_element ); - - //m_element = expression_element(); - m_element.field.clear(); - m_element.negate = false; - m_element.match = expression_element::Contains; - m_state = ExpectMinus; -} - -void ExpressionParser::finishedOrGroup() -{ - if( !m_or.isEmpty() ) - m_parsed.append( m_or ); - m_or.clear(); - m_inOrGroup = false; -} - diff --git a/amarok/src/core-impl/collections/support/Expression.h b/amarok/src/core-impl/collections/support/Expression.h deleted file mode 100644 index cf23ac81..00000000 --- a/amarok/src/core-impl/collections/support/Expression.h +++ /dev/null @@ -1,89 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2006 Gbor Lehel * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_EXPRESSION_H -#define AMAROK_EXPRESSION_H - -#include -#include - -#include - -struct expression_element -{ - QString field; - QString text; - bool negate: 1; - enum { Contains, Equals, Less, More } match: 2; - expression_element(): negate( false ), match( Contains ) { } - - // workaround for gcc bug 56235 - expression_element(const expression_element&) = default; - expression_element& operator=(const expression_element&) = default; - expression_element(expression_element&& o) - : field(std::move(o.field)) - , text(std::move(o.text)) - , negate(o.negate) - , match(o.match) - {} - expression_element& operator=(expression_element&& o) - { - field = std::move(o.field); - text = std::move(o.text); - negate = o.negate; - match = o.match; - return *this; - } -}; -typedef QList or_list; - -typedef QList ParsedExpression; - -class ExpressionParser -{ - public: - ExpressionParser( const QString &expression ); - ParsedExpression parse(); - static ParsedExpression parse( const QString &expression ); - - static bool isAdvancedExpression( const QString &expression ); - - private: - void parseChar( const QChar &c ); - void handleSpace( const QChar &c ); - void handleMinus( const QChar &c ); - void handleColon( const QChar &c ); - void handleMod( const QChar &c ); - void handleQuote( const QChar &c ); - void handleChar( const QChar &c ); - void finishedToken(); - void finishedElement(); - void finishedOrGroup(); - - const QString &m_expression; - enum State { ExpectMinus, ExpectField, ExpectMod, ExpectText }; - int m_state; - bool m_haveGroup; - bool m_inQuote; - bool m_inOrGroup; - QString m_string; - expression_element m_element; - or_list m_or; - ParsedExpression m_parsed; -}; - - -#endif diff --git a/amarok/src/core-impl/collections/support/FileCollectionLocation.cpp b/amarok/src/core-impl/collections/support/FileCollectionLocation.cpp deleted file mode 100644 index 0bc1938f..00000000 --- a/amarok/src/core-impl/collections/support/FileCollectionLocation.cpp +++ /dev/null @@ -1,135 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Casey Link * - * Copyright (c) 2008 Jason A. Donenfeld * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "FileCollectionLocation.h" - -#include "core/collections/CollectionLocationDelegate.h" -#include "core/interfaces/Logger.h" -#include "core/support/Components.h" -#include "core/support/Debug.h" - - -#include -#include -#include - -#include - -#include -#include -#include - -using namespace Collections; - -FileCollectionLocation::FileCollectionLocation() - : CollectionLocation() -{ - // nothing to do -} - -FileCollectionLocation::~FileCollectionLocation() -{ - // nothing to do -} - -QString -FileCollectionLocation::prettyLocation() const -{ - return "File Browser Location"; -} - - -bool -FileCollectionLocation::isWritable() const -{ - return true; -} - -bool -FileCollectionLocation::isOrganizable() const -{ - return false; -} - -void FileCollectionLocation::startRemoveJobs() -{ - DEBUG_BLOCK - while ( !m_removetracks.isEmpty() ) - { - Meta::TrackPtr track = m_removetracks.takeFirst(); - KUrl src = track->playableUrl(); - - KIO::DeleteJob *job = 0; - - src.cleanPath(); - debug() << "deleting " << src; - KIO::JobFlags flags = KIO::HideProgressInfo; - job = KIO::del( src, flags ); - connect( job, SIGNAL(result(KJob*)), SLOT(slotRemoveJobFinished(KJob*)) ); - QString name = track->prettyName(); - if( track->artist() ) - name = QString( "%1 - %2" ).arg( track->artist()->name(), track->prettyName() ); - - Amarok::Components::logger()->newProgressOperation( job, i18n( "Removing: %1", name ) ); - m_removejobs.insert( job, track ); - } -} - -void FileCollectionLocation::slotRemoveJobFinished( KJob *job ) -{ - // ignore and error that the file did not exist in the first place. Perhaps destination - // collection too eager? :-) - if( job->error() && job->error() != KIO::ERR_DOES_NOT_EXIST ) - transferError( m_removejobs.value( job ), KIO::buildErrorString( job->error(), job->errorString() ) ); - else - transferSuccessful( m_removejobs.value( job ) ); - - m_removejobs.remove( job ); - job->deleteLater(); - - if(m_removejobs.isEmpty()) { - slotRemoveOperationFinished(); - } -} - - -void FileCollectionLocation::removeUrlsFromCollection(const Meta::TrackList& sources) -{ - DEBUG_BLOCK - m_removetracks = sources; - - debug() << "removing " << m_removetracks.size() << "tracks"; - startRemoveJobs(); -} - -void FileCollectionLocation::showRemoveDialog( const Meta::TrackList &tracks ) -{ - DEBUG_BLOCK - if( !isHidingRemoveConfirm() ) - { - Collections::CollectionLocationDelegate *delegate = Amarok::Components::collectionLocationDelegate(); - const bool del = delegate->reallyDelete( this, tracks ); - - if( !del ) - abort(); - else - slotShowRemoveDialogDone(); - } else - slotShowRemoveDialogDone(); -} - -#include "moc_FileCollectionLocation.cpp" diff --git a/amarok/src/core-impl/collections/support/FileCollectionLocation.h b/amarok/src/core-impl/collections/support/FileCollectionLocation.h deleted file mode 100644 index 9bd303e2..00000000 --- a/amarok/src/core-impl/collections/support/FileCollectionLocation.h +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008-2010 Casey Link * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_FILECOLLECTIONLOCATION_H -#define AMAROK_FILECOLLECTIONLOCATION_H - -#include "amarok_export.h" -#include "core/collections/CollectionLocation.h" - -#include -#include -#include - -class KJob; - -namespace Collections { - -class AMAROK_EXPORT FileCollectionLocation : public CollectionLocation -{ - Q_OBJECT - public: - FileCollectionLocation(); - virtual ~FileCollectionLocation(); - - virtual QString prettyLocation() const; - virtual bool isWritable() const; - virtual bool isOrganizable() const; - virtual void removeUrlsFromCollection( const Meta::TrackList& sources ); - virtual void showRemoveDialog( const Meta::TrackList &tracks ); - public slots: - void slotRemoveJobFinished( KJob *job ); - private: - void startRemoveJobs(); - - QMap m_removejobs; - Meta::TrackList m_removetracks; -}; - -} //namespace Collections - -#endif diff --git a/amarok/src/core-impl/collections/support/MemoryCollection.h b/amarok/src/core-impl/collections/support/MemoryCollection.h deleted file mode 100644 index 94ca0cab..00000000 --- a/amarok/src/core-impl/collections/support/MemoryCollection.h +++ /dev/null @@ -1,152 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef MEMORYCOLLECTION_H -#define MEMORYCOLLECTION_H - -#include "core/meta/Meta.h" -#include "core/meta/support/MetaKeys.h" - -#include - -//QMap is slower than QHash but the items are ordered by key -typedef QMap TrackMap; -typedef QMap ArtistMap; -class AlbumMap : public QMap -{ - public: - /** - * Return true if this map contains album with same name and artist as @param album - * - * This is a convenience overload of contains( QString, QString ) that has same - * semantics, i.e. compares albums by name and artist name. - */ - bool contains( const Meta::AlbumPtr &album ) const { - return QMap::contains( Meta::AlbumKey( album ) ); } - - /** - * Return true if this map contains album named @param name with album artist - * @param artistName. Amarok convention is to use empty artistName for compilaitons. - */ - bool contains( const QString &name, const QString &artistName ) const { - return QMap::contains( Meta::AlbumKey( name, artistName ) ); } - - /** - * Inserts new album @param album into this map, using its name and album artist. - * If album has no album artist, empty QString is used as artist key. You must not - * change name and album artist of album after adding it to this map! - */ - void insert( const Meta::AlbumPtr &album ) { - QMap::insert( Meta::AlbumKey( album ) , album ); } - - /** - * Remove album from this map that has same name and artist as @param album - */ - int remove( const Meta::AlbumPtr &album ) { - return QMap::remove( Meta::AlbumKey( album ) ); } - - /** - * Return pointer to album from this map that has same name and artist as @param album - * - * This is a convenience overload of value( QString, QString ) that has same - * semantics, i.e. compares albums by name and artist name. - */ - const Meta::AlbumPtr value( const Meta::AlbumPtr &album ) const { - return QMap::value( Meta::AlbumKey( album ) ); } - - /** - * Return pointer to album from this map that has name @param name and - * album artist @param artistName - */ - const Meta::AlbumPtr value( const QString &name, const QString &artistName ) const { - return QMap::value( Meta::AlbumKey( name, artistName ) ); } -}; -typedef QMap GenreMap; -typedef QMap ComposerMap; -typedef QMap YearMap; -typedef QMap LabelMap; -typedef QHash LabelToTrackMap; - -namespace Collections { - -class MemoryCollection -{ - public: - void acquireReadLock() { m_readWriteLock.lockForRead(); } - void releaseLock() { m_readWriteLock.unlock(); } - void acquireWriteLock() { m_readWriteLock.lockForWrite(); } - - const TrackMap &trackMap() const { return m_trackMap; } - const ArtistMap &artistMap() const { return m_artistMap; } - const AlbumMap &albumMap() const { return m_albumMap; } - const GenreMap &genreMap() const { return m_genreMap; } - const ComposerMap &composerMap() const { return m_composerMap; } - const YearMap &yearMap() const { return m_yearMap; } - const LabelMap &labelMap() const { return m_labelMap; } - const LabelToTrackMap &labelToTrackMap() const { return m_labelToTrackMap; } - - void setTrackMap( const TrackMap &map ) { m_trackMap = map; } - void addTrack( Meta::TrackPtr trackPtr ) { m_trackMap.insert( trackPtr->uidUrl(), trackPtr ); } - void setArtistMap( const ArtistMap &map ) { m_artistMap = map; } - void addArtist( Meta::ArtistPtr artistPtr) { m_artistMap.insert( artistPtr->name(), artistPtr ); } - void setAlbumMap( const AlbumMap &map ) { m_albumMap = map; } - void addAlbum ( Meta::AlbumPtr albumPtr ) { m_albumMap.insert( albumPtr ); } - void setGenreMap( GenreMap map ) { m_genreMap = map; } - void addGenre( Meta::GenrePtr genrePtr) { m_genreMap.insert( genrePtr->name(), genrePtr ); } - void setComposerMap( const ComposerMap &map ) { m_composerMap = map; } - void addComposer( Meta::ComposerPtr composerPtr ) { m_composerMap.insert( composerPtr->name(), composerPtr ); } - void setYearMap( const YearMap &map ) { m_yearMap = map; } - void addYear( Meta::YearPtr yearPtr ) { m_yearMap.insert( yearPtr->year(), yearPtr ); } - void clearLabels() - { - m_labelMap = LabelMap(); - m_labelToTrackMap = LabelToTrackMap(); - } - - void addLabelToTrack( const Meta::LabelPtr &labelPtr, const Meta::TrackPtr &track ) - { - m_labelMap.insert( labelPtr->name(), labelPtr ); - Meta::TrackList tracks; - if( m_labelToTrackMap.contains( labelPtr ) ) - { - tracks = m_labelToTrackMap.value( labelPtr ); - } - tracks << track; - m_labelToTrackMap.insert( labelPtr, tracks ); - } - - /** - * Return a pointer to MemoryCollection's internal lock. Useful to use - * QReadWriteLocker instead of acquireRead/WriteLock() and releaseLock() - */ - QReadWriteLock *mapLock() const { return &m_readWriteLock; } - - protected: - mutable QReadWriteLock m_readWriteLock; - TrackMap m_trackMap; - ArtistMap m_artistMap; - AlbumMap m_albumMap; - GenreMap m_genreMap; - ComposerMap m_composerMap; - YearMap m_yearMap; - LabelMap m_labelMap; - LabelToTrackMap m_labelToTrackMap; - -}; - -} //namespace Collections - -#endif diff --git a/amarok/src/core-impl/collections/support/MemoryCustomValue.cpp b/amarok/src/core-impl/collections/support/MemoryCustomValue.cpp deleted file mode 100644 index 04d3383d..00000000 --- a/amarok/src/core-impl/collections/support/MemoryCustomValue.cpp +++ /dev/null @@ -1,505 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "MemoryCustomValue.h" - -#include "core/meta/Meta.h" -#include "core/meta/Statistics.h" - -#include - -class SumReturnFunction : public CustomReturnFunction -{ - public: - SumReturnFunction( CustomReturnValue * rv ) : returnValue( rv ) {} - ~SumReturnFunction() { delete returnValue; } - - QString value( const Meta::TrackList &tracks ) const - { - if( !returnValue ) - return QString::number( 0 ); - - double sum = 0.0; - foreach( const Meta::TrackPtr &track, tracks ) - sum += returnValue->value( track ).toDouble(); - - return QString::number( sum ); - } - - private: - CustomReturnValue *returnValue; -}; - -class MinimumReturnFunction : public CustomReturnFunction -{ - public: - MinimumReturnFunction( CustomReturnValue * rv ) : returnValue( rv ) {} - ~MinimumReturnFunction() { delete returnValue; } - - QString value( const Meta::TrackList &tracks ) const - { - if( tracks.empty() || !returnValue ) - return QString::number( 0 ); - - double min = returnValue->value( tracks.first() ).toDouble(); - foreach( const Meta::TrackPtr &track, tracks ) - min = qMin( min, returnValue->value( track ).toDouble() ); - - return QString::number( min ); - } - - private: - CustomReturnValue *returnValue; -}; - -class MaximumReturnFunction : public CustomReturnFunction -{ - public: - MaximumReturnFunction( CustomReturnValue * rv ) : returnValue( rv ) {} - ~MaximumReturnFunction() { delete returnValue; } - - QString value( const Meta::TrackList &tracks ) const - { - if( tracks.empty() || !returnValue ) - return QString::number( 0 ); - - double max = returnValue->value( tracks.first() ).toDouble(); - foreach( const Meta::TrackPtr &track, tracks ) - max = qMax( max, returnValue->value( track ).toDouble() ); - - return QString::number( max ); - } - - private: - CustomReturnValue *returnValue; -}; - -CustomReturnFunction* -CustomValueFactory::returnFunction( Collections::QueryMaker::ReturnFunction function, qint64 value ) -{ - switch( function ) - { - case Collections::QueryMaker::Count: - { - switch( value ) - { - case Meta::valUrl: - case Meta::valTitle: - { - return new TrackCounter(); - } - case Meta::valArtist: - { - return new ArtistCounter(); - } - case Meta::valAlbum: - { - return new AlbumCounter(); - } - case Meta::valGenre: - { - return new GenreCounter(); - } - case Meta::valComposer: - { - return new ComposerCounter(); - } - case Meta::valYear: - { - return new YearCounter(); - } - default: - return 0; - } - } - case Collections::QueryMaker::Sum: - { - CustomReturnValue *crv = CustomValueFactory::returnValue( value ); - return crv ? new SumReturnFunction( crv ) : 0; - } - case Collections::QueryMaker::Min: - { - CustomReturnValue *crv = CustomValueFactory::returnValue( value ); - return crv ? new MinimumReturnFunction( crv ) : 0; - } - case Collections::QueryMaker::Max: - { - CustomReturnValue *crv = CustomValueFactory::returnValue( value ); - return crv ? new MaximumReturnFunction( crv ) : 0; - } - default: - return 0; - } -} - -CustomReturnFunction::CustomReturnFunction() -{ -} - -CustomReturnFunction::~CustomReturnFunction() -{ -} - -CustomReturnValue::CustomReturnValue() -{ -} - -CustomReturnValue::~CustomReturnValue() -{ -} - -TrackCounter::TrackCounter() -{ -} - -TrackCounter::~TrackCounter() -{ -} - -QString -TrackCounter::value( const Meta::TrackList &tracks ) const -{ - return QString::number( tracks.count() ); -} - -ArtistCounter::ArtistCounter() -{ -} - -ArtistCounter::~ArtistCounter() -{ -} - -QString -ArtistCounter::value( const Meta::TrackList &tracks ) const -{ - QSet artists; - foreach( const Meta::TrackPtr &track, tracks ) - { - if( track->artist() ) - artists.insert( track->artist() ); - } - return QString::number( artists.count() ); -} - -GenreCounter::GenreCounter() -{ -} - -GenreCounter::~GenreCounter() -{ -} - -QString -GenreCounter::value( const Meta::TrackList &tracks ) const -{ - QSet genres; - foreach( const Meta::TrackPtr &track, tracks ) - { - if( track->genre() ) - genres.insert( track->genre() ); - } - return QString::number( genres.count() ); -} - -AlbumCounter::AlbumCounter() -{ -} - -AlbumCounter::~AlbumCounter() -{ -} - -QString -AlbumCounter::value( const Meta::TrackList &tracks ) const -{ - QSet albums; - foreach( const Meta::TrackPtr &track, tracks ) - { - if( track->album() ) - albums.insert( track->album() ); - } - return QString::number( albums.count() ); -} - -ComposerCounter::ComposerCounter() -{ -} - -ComposerCounter::~ComposerCounter() -{ -} - -QString -ComposerCounter::value( const Meta::TrackList &tracks ) const -{ - QSet composers; - foreach( const Meta::TrackPtr &track, tracks ) - { - if( track->composer() ) - composers.insert( track->composer() ); - } - return QString::number( composers.count() ); -} - -YearCounter::YearCounter() -{ -} - -YearCounter::~YearCounter() -{ -} - -QString -YearCounter::value( const Meta::TrackList &tracks ) const -{ - QSet years; - foreach( const Meta::TrackPtr &track, tracks ) - { - if( track->year() ) - years.insert( track->year() ); - } - return QString::number( years.count() ); -} - - -//CustomReturnValues - -TitleReturnValue::TitleReturnValue() -{ -} - -TitleReturnValue::~TitleReturnValue() -{ -} - -QString -TitleReturnValue::value( const Meta::TrackPtr &track ) const -{ - return track->name(); -} - -UrlReturnValue::UrlReturnValue() -{ -} - -UrlReturnValue::~UrlReturnValue() -{ -} - -QString -UrlReturnValue::value( const Meta::TrackPtr &track ) const -{ - return track->playableUrl().url(); -} - -class ArtistReturnValue : public CustomReturnValue -{ - public: - ArtistReturnValue() {} - virtual ~ArtistReturnValue() {} - virtual QString value( const Meta::TrackPtr &track ) const { return track->artist() ? track->artist()->name() : QString(); } -}; - -class AlbumReturnValue : public CustomReturnValue -{ - public: - AlbumReturnValue() {} - virtual ~AlbumReturnValue() {} - virtual QString value( const Meta::TrackPtr &track ) const { return track->album() ? track->album()->name() : QString(); } -}; - -class ComposerReturnValue : public CustomReturnValue -{ - public: - ComposerReturnValue() {} - virtual ~ComposerReturnValue() {} - virtual QString value( const Meta::TrackPtr &track ) const { return track->composer() ? track->composer()->name() : QString(); } -}; - -class GenreReturnValue : public CustomReturnValue -{ - public: - GenreReturnValue() {} - virtual ~GenreReturnValue() {} - virtual QString value( const Meta::TrackPtr &track ) const { return track->genre() ? track->genre()->name() : QString(); } -}; - -class YearReturnValue : public CustomReturnValue -{ - public: - YearReturnValue() {} - virtual ~YearReturnValue() {} - virtual QString value( const Meta::TrackPtr &track ) const { return track->year() ? track->year()->name() : QString(); } -}; - -class CommentReturnValue : public CustomReturnValue -{ - public: - CommentReturnValue() {} - virtual ~CommentReturnValue() {} - virtual QString value( const Meta::TrackPtr &track ) const { return track->comment(); } -}; - -class TrackNrReturnValue : public CustomReturnValue -{ - public: - TrackNrReturnValue() {} - virtual ~TrackNrReturnValue() {} - virtual QString value( const Meta::TrackPtr &track ) const { return QString::number( track->trackNumber() ); } -}; - -class DiscNrReturnValue : public CustomReturnValue -{ - public: - DiscNrReturnValue() {} - virtual ~DiscNrReturnValue() {} - virtual QString value( const Meta::TrackPtr &track ) const { return QString::number( track->discNumber() ); } -}; - -class ScoreReturnValue : public CustomReturnValue -{ - public: - ScoreReturnValue() {} - virtual ~ScoreReturnValue() {} - virtual QString value( const Meta::TrackPtr &track ) const { return QString::number( track->statistics()->score() ); } -}; - -class RatingReturnValue : public CustomReturnValue -{ - public: - RatingReturnValue() {} - virtual ~RatingReturnValue() {} - virtual QString value( const Meta::TrackPtr &track ) const { return QString::number( track->statistics()->rating() ); } -}; - -class PlaycountReturnValue : public CustomReturnValue -{ - public: - PlaycountReturnValue() {} - virtual ~PlaycountReturnValue() {} - virtual QString value( const Meta::TrackPtr &track ) const { return QString::number( track->statistics()->playCount() ); } -}; - -class LengthReturnValue : public CustomReturnValue -{ - public: - LengthReturnValue() {} - virtual ~LengthReturnValue() {} - virtual QString value( const Meta::TrackPtr &track ) const { return QString::number( track->length() / 1000 ); } -}; - -class BitrateReturnValue : public CustomReturnValue -{ - public: - BitrateReturnValue() {} - virtual ~BitrateReturnValue() {} - virtual QString value( const Meta::TrackPtr &track ) const { return QString::number( track->bitrate() ); } -}; - -class FileSizeReturnValue : public CustomReturnValue -{ - public: - FileSizeReturnValue() {} - virtual ~FileSizeReturnValue() {} - virtual QString value( const Meta::TrackPtr &track ) const { return QString::number( track->filesize() ); } -}; - -class SampleRateReturnValue : public CustomReturnValue -{ - public: - SampleRateReturnValue() {} - virtual ~SampleRateReturnValue() {} - virtual QString value( const Meta::TrackPtr &track ) const { return QString::number( track->sampleRate() ); } -}; - -CustomReturnValue* -CustomValueFactory::returnValue( qint64 value ) -{ - switch( value ) - { - case Meta::valTitle: - { - return new TitleReturnValue(); - } - case Meta::valUrl: - { - return new UrlReturnValue(); - } - case Meta::valArtist: - { - return new ArtistReturnValue(); - } - case Meta::valAlbum: - { - return new AlbumReturnValue(); - } - case Meta::valGenre: - { - return new GenreReturnValue(); - } - case Meta::valComposer: - { - return new ComposerReturnValue(); - } - case Meta::valYear: - { - return new YearReturnValue(); - } - case Meta::valComment: - { - return new CommentReturnValue(); - } - case Meta::valTrackNr: - { - return new TrackNrReturnValue(); - } - case Meta::valDiscNr: - { - return new DiscNrReturnValue(); - } - case Meta::valScore: - { - return new ScoreReturnValue(); - } - case Meta::valRating: - { - return new RatingReturnValue(); - } - case Meta::valPlaycount: - { - return new PlaycountReturnValue(); - } - case Meta::valLength: - { - return new LengthReturnValue(); - } - case Meta::valBitrate: - { - return new BitrateReturnValue(); - } - case Meta::valFilesize: - { - return new FileSizeReturnValue(); - } - case Meta::valSamplerate: - { - return new SampleRateReturnValue(); - } - default: - return 0; - } -} diff --git a/amarok/src/core-impl/collections/support/MemoryCustomValue.h b/amarok/src/core-impl/collections/support/MemoryCustomValue.h deleted file mode 100644 index 1269f1df..00000000 --- a/amarok/src/core-impl/collections/support/MemoryCustomValue.h +++ /dev/null @@ -1,125 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef MEMORYCUSTOMVALUE_H -#define MEMORYCUSTOMVALUE_H - -#include "amarok_export.h" -#include "core/meta/forward_declarations.h" -#include "core/collections/QueryMaker.h" - -#include -#include - -class CustomReturnFunction; -class CustomReturnValue; - -namespace CustomValueFactory -{ - CustomReturnFunction* returnFunction( Collections::QueryMaker::ReturnFunction function, qint64 value ); - CustomReturnValue* returnValue( qint64 value ); -} - -class AMAROK_EXPORT CustomReturnFunction -{ - public: - CustomReturnFunction(); - virtual ~CustomReturnFunction(); - - virtual QString value( const Meta::TrackList &tracks ) const = 0; -}; - -class AMAROK_EXPORT TrackCounter : public CustomReturnFunction -{ - public: - TrackCounter(); - virtual ~TrackCounter(); - - virtual QString value( const Meta::TrackList &tracks ) const; -}; - -class AMAROK_EXPORT ArtistCounter : public CustomReturnFunction -{ - public: - ArtistCounter(); - virtual ~ArtistCounter(); - - virtual QString value( const Meta::TrackList &tracks ) const; -}; - -class AMAROK_EXPORT GenreCounter : public CustomReturnFunction -{ - public: - GenreCounter(); - virtual ~GenreCounter(); - - virtual QString value( const Meta::TrackList &tracks ) const; -}; - -class AMAROK_EXPORT ComposerCounter : public CustomReturnFunction -{ - public: - ComposerCounter(); - virtual ~ComposerCounter(); - - virtual QString value( const Meta::TrackList &tracks ) const; -}; - -class AMAROK_EXPORT AlbumCounter : public CustomReturnFunction -{ - public: - AlbumCounter(); - virtual ~AlbumCounter(); - - virtual QString value( const Meta::TrackList &tracks ) const; -}; - -class AMAROK_EXPORT YearCounter : public CustomReturnFunction -{ - public: - YearCounter(); - virtual ~YearCounter(); - - virtual QString value( const Meta::TrackList &tracks ) const; -}; - -class AMAROK_EXPORT CustomReturnValue -{ - public: - CustomReturnValue(); - virtual ~CustomReturnValue(); - - virtual QString value( const Meta::TrackPtr &track ) const = 0; -}; - -class AMAROK_EXPORT TitleReturnValue : public CustomReturnValue -{ - public: - TitleReturnValue(); - virtual ~TitleReturnValue(); - virtual QString value( const Meta::TrackPtr &track ) const; -}; - -class AMAROK_EXPORT UrlReturnValue : public CustomReturnValue -{ - public: - UrlReturnValue(); - virtual ~UrlReturnValue(); - virtual QString value( const Meta::TrackPtr &track ) const; -}; - - -#endif diff --git a/amarok/src/core-impl/collections/support/MemoryFilter.cpp b/amarok/src/core-impl/collections/support/MemoryFilter.cpp deleted file mode 100644 index c3a5e0d7..00000000 --- a/amarok/src/core-impl/collections/support/MemoryFilter.cpp +++ /dev/null @@ -1,277 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "MemoryFilter.h" - -#include "core/meta/Meta.h" -#include "core/meta/support/MetaConstants.h" - -#include - -class UrlMemoryFilter : public StringMemoryFilter -{ -protected: - virtual QString value( Meta::TrackPtr track ) const - { return track->playableUrl().url(); } - -}; - -class GenericStringMemoryFilter : public StringMemoryFilter -{ - public: - GenericStringMemoryFilter( qint64 value, const QString &filter, - bool matchBegin, bool matchEnd ) - : m_value( value ) - { setFilter( filter, matchBegin, matchEnd ); } - - protected: - virtual QString value( Meta::TrackPtr track ) const - { return Meta::valueForField( m_value, track ).toString(); } - - private: - qint64 m_value; -}; - -class GenericNumberMemoryFilter : public NumberMemoryFilter -{ - public: - GenericNumberMemoryFilter( qint64 value, qint64 filter, - Collections::QueryMaker::NumberComparison compare ) - : m_value( value ) - { setFilter( filter, compare ); } - - protected: - virtual qint64 value( Meta::TrackPtr track ) const - { - QVariant v = Meta::valueForField( m_value, track ); - if( v.type() == QVariant::DateTime ) - return v.toDateTime().toTime_t(); - else - return v.toLongLong(); - } - - private: - qint64 m_value; -}; - -namespace FilterFactory -{ - - MemoryFilter* filter( qint64 value, const QString &filter, bool matchBegin, bool matchEnd ) - { - MemoryFilter *result = new GenericStringMemoryFilter( value, filter, matchBegin, matchEnd ); - return result; - } - - MemoryFilter* numberFilter( qint64 value, qint64 filter, Collections::QueryMaker::NumberComparison compare ) - { - NumberMemoryFilter *result = new GenericNumberMemoryFilter( value, filter, compare ); - return result; - } -} - -MemoryFilter::MemoryFilter() -{ -} - -MemoryFilter::~MemoryFilter() -{ -} - -ContainerMemoryFilter::ContainerMemoryFilter() - : MemoryFilter() -{ -} - -ContainerMemoryFilter::~ContainerMemoryFilter() -{ - qDeleteAll( m_filters ); -} - -void -ContainerMemoryFilter::addFilter( MemoryFilter *filter ) -{ - if( filter ) - m_filters.append( filter ); -} - -AndContainerMemoryFilter::AndContainerMemoryFilter() - : ContainerMemoryFilter() -{ -} - -AndContainerMemoryFilter::~AndContainerMemoryFilter() -{ -} - -bool -AndContainerMemoryFilter::filterMatches( Meta::TrackPtr track ) const -{ - if( m_filters.isEmpty() ) - return false; - - foreach( MemoryFilter *filter, m_filters ) - { - if( filter && !filter->filterMatches( track ) ) - return false; - } - return true; -} - -OrContainerMemoryFilter::OrContainerMemoryFilter() - : ContainerMemoryFilter() -{ -} - -OrContainerMemoryFilter::~OrContainerMemoryFilter() -{ -} - -bool -OrContainerMemoryFilter::filterMatches( Meta::TrackPtr track ) const -{ - if( m_filters.isEmpty() ) - return false; - - foreach( MemoryFilter *filter, m_filters ) - { - if( filter && filter->filterMatches( track ) ) - return true; - } - return false; -} - -NegateMemoryFilter::NegateMemoryFilter( MemoryFilter *filter ) - :MemoryFilter() - , m_filter( filter ) -{ -} - -NegateMemoryFilter::~NegateMemoryFilter() -{ - delete m_filter; -} - -bool -NegateMemoryFilter::filterMatches( Meta::TrackPtr track ) const -{ - return !m_filter->filterMatches( track ); -} - -StringMemoryFilter::StringMemoryFilter() - : MemoryFilter() - , m_matchBegin( false ) - , m_matchEnd( false ) -{ -} - -StringMemoryFilter::~StringMemoryFilter() -{ - -} - -void -StringMemoryFilter::setFilter( const QString &filter, bool matchBegin, bool matchEnd ) -{ - m_filter = filter; - m_matchBegin = matchBegin; - m_matchEnd = matchEnd; -} - -bool -StringMemoryFilter::filterMatches( Meta::TrackPtr track ) const -{ - const QString &str = value( track ); - if( m_matchBegin && m_matchEnd ) - { - return QString::compare( str, m_filter, Qt::CaseInsensitive ) == 0; - } - else if( m_matchBegin ) - { - return str.startsWith( m_filter, Qt::CaseInsensitive ); - } - else if( m_matchEnd ) - { - return str.endsWith( m_filter, Qt::CaseInsensitive ); - } - else - { - return str.contains( m_filter, Qt::CaseInsensitive ); - } -} - -NumberMemoryFilter::NumberMemoryFilter() - : MemoryFilter() - , m_filter( 0 ) - , m_compare( Collections::QueryMaker::Equals ) -{ -} - -NumberMemoryFilter::~NumberMemoryFilter() -{ -} - -void -NumberMemoryFilter::setFilter( qint64 filter, Collections::QueryMaker::NumberComparison compare ) -{ - m_filter = filter; - m_compare = compare; -} - -bool -NumberMemoryFilter::filterMatches( Meta::TrackPtr track ) const -{ - qint64 currentValue = value( track ); - switch( m_compare ) - { - case Collections::QueryMaker::Equals: - return currentValue == m_filter; - case Collections::QueryMaker::GreaterThan: - return currentValue > m_filter; - case Collections::QueryMaker::LessThan: - return currentValue < m_filter; - } - return false; -} - -LabelFilter::LabelFilter( const QString &filter, bool matchBegin, bool matchEnd ) - : MemoryFilter() -{ - QString pattern; - if( matchBegin ) - pattern += '^'; - pattern += filter; - if( matchEnd ) - pattern += '$'; - - m_expression = QRegExp( pattern, Qt::CaseInsensitive ); -} - -LabelFilter::~LabelFilter() -{ - //nothing to do -} - -bool -LabelFilter::filterMatches( Meta::TrackPtr track ) const -{ - foreach( const Meta::LabelPtr &label, track->labels() ) - { - if( m_expression.indexIn( label->name() ) != -1 ) - return true; - } - return false; -} diff --git a/amarok/src/core-impl/collections/support/MemoryFilter.h b/amarok/src/core-impl/collections/support/MemoryFilter.h deleted file mode 100644 index f5227b4e..00000000 --- a/amarok/src/core-impl/collections/support/MemoryFilter.h +++ /dev/null @@ -1,124 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef MEMORYFILTER_H -#define MEMORYFILTER_H - -#include "amarok_export.h" -#include "core/meta/forward_declarations.h" -#include "core/collections/QueryMaker.h" - -#include -#include -#include - -class MemoryFilter; - -namespace FilterFactory -{ - MemoryFilter* filter( qint64 value, const QString &filter, bool matchBegin, bool matchEnd ); - MemoryFilter* numberFilter( qint64 value, qint64 filter, Collections::QueryMaker::NumberComparison compare ); -} - -class AMAROK_EXPORT MemoryFilter -{ - public: - MemoryFilter(); - virtual ~MemoryFilter(); - virtual bool filterMatches( Meta::TrackPtr track ) const = 0; -}; - -class AMAROK_EXPORT ContainerMemoryFilter : public MemoryFilter -{ - public: - ContainerMemoryFilter(); - virtual ~ContainerMemoryFilter(); - void addFilter( MemoryFilter *filter ); - protected: - QList m_filters; -}; - -class AMAROK_EXPORT AndContainerMemoryFilter : public ContainerMemoryFilter -{ - public: - AndContainerMemoryFilter(); - virtual ~AndContainerMemoryFilter(); - virtual bool filterMatches( Meta::TrackPtr track ) const; -}; - -class AMAROK_EXPORT OrContainerMemoryFilter : public ContainerMemoryFilter -{ - public: - OrContainerMemoryFilter(); - virtual ~OrContainerMemoryFilter(); - virtual bool filterMatches( Meta::TrackPtr track ) const; -}; - -class AMAROK_EXPORT NegateMemoryFilter : public MemoryFilter -{ - public: - NegateMemoryFilter( MemoryFilter *filter ); - virtual ~NegateMemoryFilter(); - virtual bool filterMatches( Meta::TrackPtr track ) const; - private: - MemoryFilter *m_filter; -}; - -class AMAROK_EXPORT StringMemoryFilter : public MemoryFilter -{ - public: - StringMemoryFilter(); - virtual ~StringMemoryFilter(); - virtual bool filterMatches( Meta::TrackPtr track ) const; - - void setFilter( const QString &filter, bool matchBegin, bool matchEnd ); - protected: - virtual QString value( Meta::TrackPtr track ) const = 0; - - private: - QString m_filter; - bool m_matchBegin; - bool m_matchEnd; -}; - - -class AMAROK_EXPORT NumberMemoryFilter : public MemoryFilter -{ - public: - NumberMemoryFilter(); - virtual ~NumberMemoryFilter(); - void setFilter( qint64 filter, Collections::QueryMaker::NumberComparison compare ); - bool filterMatches( Meta::TrackPtr track ) const; - protected: - virtual qint64 value( Meta::TrackPtr track ) const = 0; - private: - qint64 m_filter; - Collections::QueryMaker::NumberComparison m_compare; -}; - - -class AMAROK_EXPORT LabelFilter : public MemoryFilter -{ -public: - LabelFilter( const QString &filter, bool matchBegin, bool matchEnd ); - virtual ~ LabelFilter(); - bool filterMatches( Meta::TrackPtr track ) const; - -private: - QRegExp m_expression; -}; - -#endif diff --git a/amarok/src/core-impl/collections/support/MemoryMatcher.cpp b/amarok/src/core-impl/collections/support/MemoryMatcher.cpp deleted file mode 100644 index b545554d..00000000 --- a/amarok/src/core-impl/collections/support/MemoryMatcher.cpp +++ /dev/null @@ -1,366 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * Copyright (c) 2007 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "MemoryMatcher.h" - -using namespace Meta; - -MemoryMatcher::MemoryMatcher() - : m_next( 0 ) -{ -} - -MemoryMatcher::~MemoryMatcher() -{ - delete m_next; -} - -bool -MemoryMatcher::isLast() const -{ - return !m_next; -} - -MemoryMatcher* -MemoryMatcher::next() const -{ - return m_next; -} - -void -MemoryMatcher::setNext( MemoryMatcher *next ) -{ - delete m_next; - m_next = next; -} - -TrackMatcher::TrackMatcher( TrackPtr track ) - : MemoryMatcher() - , m_track( track ) -{} - -TrackList TrackMatcher::match( Collections::MemoryCollection *memColl ) -{ - if( !m_track || !memColl ) - return TrackList(); - TrackMap trackMap = memColl->trackMap(); - TrackList result; - if ( trackMap.contains( m_track->uidUrl() ) ) - result.append( trackMap.value( m_track->uidUrl() ) ); - return result; //checking for another matcher is not necessary -} - -TrackList TrackMatcher::match( const TrackList &tracks ) -{ - if( !m_track ) - return TrackList(); - TrackList result; - QString url = m_track->uidUrl(); - foreach( TrackPtr track, tracks ) - if ( track->uidUrl() == url ) - { - result.append( track ); - break; - } - return result; //checking for another matcher is not necessary -} - - - -ArtistMatcher::ArtistMatcher( ArtistPtr artist, Collections::QueryMaker::ArtistMatchBehaviour artistMode ) - : MemoryMatcher() - , m_artist( artist ) - , m_queryMode( artistMode ) -{} - -TrackList ArtistMatcher::match( Collections::MemoryCollection *memColl ) -{ - if( !m_artist || !memColl ) - return TrackList(); - - if( !memColl->artistMap().contains( m_artist->name() ) ) - return TrackList(); - - ArtistPtr artist = memColl->artistMap().value( m_artist->name() ); - - TrackList matchingTracks; - switch( m_queryMode ) - { - case Collections::QueryMaker::AlbumOrTrackArtists: - case Collections::QueryMaker::AlbumArtists: - foreach( AlbumPtr album, memColl->albumMap() ) - if( album->albumArtist() == artist ) - matchingTracks.append( album->tracks() ); - - if( m_queryMode != Collections::QueryMaker::AlbumOrTrackArtists ) - break; - - case Collections::QueryMaker::TrackArtists: - matchingTracks.append( artist->tracks() ); - } - - if( isLast() || matchingTracks.isEmpty() ) - return matchingTracks; - else - return next()->match( matchingTracks ); -} - - -TrackList ArtistMatcher::match( const TrackList &tracks ) -{ - if( !m_artist ) - return TrackList(); - TrackList matchingTracks; - QString name = m_artist->name(); - foreach( TrackPtr track, tracks ) - switch( m_queryMode ) - { - case Collections::QueryMaker::AlbumOrTrackArtists: - case Collections::QueryMaker::AlbumArtists: - if( track->album()->hasAlbumArtist() && - track->album()->albumArtist()->name() == name ) - matchingTracks.append( track ); - if( m_queryMode != Collections::QueryMaker::AlbumOrTrackArtists ) - break; - case Collections::QueryMaker::TrackArtists: - if( track->artist()->name() == name ) - matchingTracks.append( track ); - } - - if( isLast() || matchingTracks.isEmpty() ) - return matchingTracks; - else - return next()->match( matchingTracks ); -} - - - -AlbumMatcher::AlbumMatcher( AlbumPtr album ) - : MemoryMatcher() - , m_album( album ) -{} - -TrackList AlbumMatcher::match( Collections::MemoryCollection *memColl ) -{ - if( !m_album || !memColl ) - return TrackList(); - AlbumMap albumMap = memColl->albumMap(); - if ( albumMap.contains( m_album ) ) // compares albums by value - { - AlbumPtr album = albumMap.value( m_album ); // compares albums by value, too - TrackList matchingTracks = album->tracks(); - if ( isLast() ) - return matchingTracks; - else - return next()->match( matchingTracks ); - } - else - return TrackList(); -} - -TrackList AlbumMatcher::match( const TrackList &tracks ) -{ - if( !m_album ) - return TrackList(); - TrackList matchingTracks; - QString name = m_album->name(); - foreach( TrackPtr track, tracks ) - if ( track->album()->name() == name ) - matchingTracks.append( track ); - if ( isLast() || matchingTracks.count() == 0) - return matchingTracks; - else - return next()->match( matchingTracks ); -} - - - -GenreMatcher::GenreMatcher( GenrePtr genre ) - : MemoryMatcher() - , m_genre( genre ) -{} - -TrackList GenreMatcher::match( Collections::MemoryCollection *memColl ) -{ - if( !m_genre || !memColl ) - return TrackList(); - GenreMap genreMap = memColl->genreMap(); - if ( genreMap.contains( m_genre->name() ) ) - { - GenrePtr genre = genreMap.value( m_genre->name() ); - TrackList matchingTracks = genre->tracks(); - if ( isLast() ) - return matchingTracks; - else - return next()->match( matchingTracks ); - } - else - return TrackList(); -} - -TrackList GenreMatcher::match( const TrackList &tracks ) -{ - if( !m_genre ) - return TrackList(); - TrackList matchingTracks; - QString name = m_genre->name(); - foreach( TrackPtr track, tracks ) - if ( track->genre()->name() == name ) - matchingTracks.append( track ); - if ( isLast() || matchingTracks.count() == 0) - return matchingTracks; - else - return next()->match( matchingTracks ); -} - - - -ComposerMatcher::ComposerMatcher( ComposerPtr composer ) - : MemoryMatcher() - , m_composer( composer ) -{} - -TrackList ComposerMatcher::match( Collections::MemoryCollection *memColl ) -{ - if( !m_composer || !memColl ) - return TrackList(); - ComposerMap composerMap = memColl->composerMap(); - if ( composerMap.contains( m_composer->name() ) ) - { - ComposerPtr composer = composerMap.value( m_composer->name() ); - TrackList matchingTracks = composer->tracks(); - if ( isLast() ) - return matchingTracks; - else - return next()->match( matchingTracks ); - } - else - return TrackList(); -} - -TrackList ComposerMatcher::match( const TrackList &tracks ) -{ - if( !m_composer ) - return TrackList(); - TrackList matchingTracks; - QString name = m_composer->name(); - foreach( TrackPtr track, tracks ) - if ( track->composer()->name() == name ) - matchingTracks.append( track ); - if ( isLast() || matchingTracks.count() == 0) - return matchingTracks; - else - return next()->match( matchingTracks ); -} - - - -YearMatcher::YearMatcher( YearPtr year ) - : MemoryMatcher() - , m_year( year ) -{} - -TrackList YearMatcher::match( Collections::MemoryCollection *memColl ) -{ - if( !m_year || !memColl ) - return TrackList(); - YearMap yearMap = memColl->yearMap(); - if ( yearMap.contains( m_year->year() ) ) - { - YearPtr year = yearMap.value( m_year->year() ); - TrackList matchingTracks = year->tracks(); - if ( isLast() ) - return matchingTracks; - else - return next()->match( matchingTracks ); - } - else - return TrackList(); -} - -TrackList YearMatcher::match( const TrackList &tracks ) -{ - if( !m_year ) - return TrackList(); - TrackList matchingTracks; - int year = m_year->year(); - foreach( TrackPtr track, tracks ) - if ( track->year()->year() == year ) - matchingTracks.append( track ); - if ( isLast() || matchingTracks.count() == 0) - return matchingTracks; - else - return next()->match( matchingTracks ); -} - -LabelMatcher::LabelMatcher( const Meta::LabelPtr &label ) - : MemoryMatcher() - , m_label( label ) -{ - //nothing to do -} - -Meta::TrackList -LabelMatcher::match( const Meta::TrackList &tracks ) -{ - if( !m_label ) - return Meta::TrackList(); - - Meta::TrackList matchingTracks; - QString name = m_label->name(); - //not really efficient... - foreach( const Meta::TrackPtr &track, tracks ) - { - foreach( const Meta::LabelPtr &label, track->labels() ) - { - if( name == label->name() ) - { - matchingTracks << track; - break; - } - } - } - if( isLast() || matchingTracks.count() == 0 ) - return matchingTracks; - else - return next()->match( matchingTracks ); -} - -Meta::TrackList -LabelMatcher::match( Collections::MemoryCollection *memColl ) -{ - if( !m_label ) - return Meta::TrackList(); - - Meta::TrackList matchingTracks; - - if( memColl->labelMap().contains( m_label->name() ) ) - { - //m_label might actually be a proxy label - Meta::LabelPtr realLabel = memColl->labelMap().value( m_label->name() ); - matchingTracks = memColl->labelToTrackMap().value( realLabel ); - } - if( isLast() || matchingTracks.count() == 0 ) - return matchingTracks; - else - return next()->match( matchingTracks ); -} - - - - - diff --git a/amarok/src/core-impl/collections/support/MemoryMatcher.h b/amarok/src/core-impl/collections/support/MemoryMatcher.h deleted file mode 100644 index 335589cf..00000000 --- a/amarok/src/core-impl/collections/support/MemoryMatcher.h +++ /dev/null @@ -1,128 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * Copyright (c) 2007 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef MEMORYMATCHER_H -#define MEMORYMATCHER_H - -#include "amarok_export.h" -#include "MemoryCollection.h" -#include "core/collections/QueryMaker.h" -#include "core/meta/forward_declarations.h" - -/** -A helper class for finding items in a MemoryCollection - - @author -*/ -class AMAROK_EXPORT MemoryMatcher{ - public: - MemoryMatcher(); - virtual ~MemoryMatcher(); - virtual Meta::TrackList match( Collections::MemoryCollection *memColl) = 0; - virtual Meta::TrackList match( const Meta::TrackList &tracks ) = 0; - - bool isLast() const; - void setNext( MemoryMatcher *next ); - MemoryMatcher* next() const; - - private: - MemoryMatcher *m_next; -}; - - -class AMAROK_EXPORT TrackMatcher : public MemoryMatcher -{ - public: - TrackMatcher( Meta::TrackPtr track ); - virtual Meta::TrackList match( Collections::MemoryCollection *memColl ); - virtual Meta::TrackList match( const Meta::TrackList &tracks ); - - private: - Meta::TrackPtr m_track; -}; - - -class AMAROK_EXPORT ArtistMatcher : public MemoryMatcher -{ - public: - ArtistMatcher( Meta::ArtistPtr artist, Collections::QueryMaker::ArtistMatchBehaviour artistMode - = Collections::QueryMaker::TrackArtists ); - virtual Meta::TrackList match( Collections::MemoryCollection *memColl ); - virtual Meta::TrackList match( const Meta::TrackList &tracks ); - - private: - Meta::ArtistPtr m_artist; - Collections::QueryMaker::ArtistMatchBehaviour m_queryMode; -}; - -class AMAROK_EXPORT AlbumMatcher : public MemoryMatcher -{ - public: - AlbumMatcher( Meta::AlbumPtr album ); - virtual Meta::TrackList match( Collections::MemoryCollection *memColl ); - virtual Meta::TrackList match( const Meta::TrackList &tracks ); - - private: - Meta::AlbumPtr m_album; -}; - -class AMAROK_EXPORT GenreMatcher : public MemoryMatcher -{ - public: - GenreMatcher( Meta::GenrePtr genre ); - virtual Meta::TrackList match( Collections::MemoryCollection *memColl ); - virtual Meta::TrackList match( const Meta::TrackList &tracks ); - - private: - Meta::GenrePtr m_genre; -}; - -class AMAROK_EXPORT ComposerMatcher : public MemoryMatcher -{ - public: - ComposerMatcher( Meta::ComposerPtr composer ); - virtual Meta::TrackList match( Collections::MemoryCollection *memColl ); - virtual Meta::TrackList match( const Meta::TrackList &tracks ); - - private: - Meta::ComposerPtr m_composer; -}; - -class AMAROK_EXPORT YearMatcher : public MemoryMatcher -{ - public: - YearMatcher( Meta::YearPtr year ); - virtual Meta::TrackList match( Collections::MemoryCollection *memColl ); - virtual Meta::TrackList match( const Meta::TrackList &tracks ); - - private: - Meta::YearPtr m_year; -}; - -class AMAROK_EXPORT LabelMatcher : public MemoryMatcher -{ - public: - LabelMatcher( const Meta::LabelPtr &label ); - virtual Meta::TrackList match( Collections::MemoryCollection *memColl ); - virtual Meta::TrackList match( const Meta::TrackList &tracks ); - - private: - Meta::LabelPtr m_label; -}; - - -#endif diff --git a/amarok/src/core-impl/collections/support/MemoryMeta.cpp b/amarok/src/core-impl/collections/support/MemoryMeta.cpp deleted file mode 100644 index 9aac4e81..00000000 --- a/amarok/src/core-impl/collections/support/MemoryMeta.cpp +++ /dev/null @@ -1,535 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2011 Bart Cerneels * - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "MemoryMeta.h" - -#include "core/meta/Statistics.h" -#include "core/meta/TrackEditor.h" -#include "core-impl/capabilities/AlbumActionsCapability.h" -#include "covermanager/CoverCache.h" - - -using namespace MemoryMeta; - -Meta::TrackList -Base::tracks() -{ - // construct KSharedPtrs on demand, see m_track comment - QReadLocker locker( &m_tracksLock ); - Meta::TrackList list; - foreach( Track *track, m_tracks ) - { - list << Meta::TrackPtr( track ); - } - return list; -} - -void -Base::addTrack( Track *track ) -{ - QWriteLocker locker( &m_tracksLock ); - m_tracks.append( track ); -} - -void -Base::removeTrack( Track *track ) -{ - QWriteLocker locker( &m_tracksLock ); - m_tracks.removeOne( track ); -} - -Album::Album( const Meta::AlbumPtr &other ) - : MemoryMeta::Base( other->name() ) - , m_isCompilation( other->isCompilation() ) - , m_canUpdateCompilation( other->canUpdateCompilation() ) - , m_image( other->image() ) - , m_canUpdateImage( other->canUpdateImage() ) -{ - if( other->hasAlbumArtist() && other->albumArtist() ) - m_albumArtist = Meta::ArtistPtr( new Artist( other->albumArtist()->name() ) ); -} - -bool -Album::hasCapabilityInterface( Capabilities::Capability::Type type ) const -{ - switch( type ) - { - case Capabilities::Capability::Actions: - return true; - default: - return false; - } -} - -Capabilities::Capability* -Album::createCapabilityInterface( Capabilities::Capability::Type type ) -{ - switch( type ) - { - case Capabilities::Capability::Actions: - return new Capabilities::AlbumActionsCapability( Meta::AlbumPtr( this ) ); - default: - return 0; - } -} - -void -Album::setCompilation( bool isCompilation ) -{ - // we re-create the albums for each track - that's how MemoryMeta works - by - // aggregating multiple entities of same name into one. - foreach( Meta::TrackPtr track, tracks() ) - { - Track *memoryTrack = static_cast( track.data() ); - Meta::AlbumPtr album = memoryTrack->originalTrack()->album(); - if( album && album->canUpdateCompilation() ) - album->setCompilation( isCompilation ); - } - // no notifyObservers() etc needed - this is done from down-up by proxied tracks -} - -QImage -Album::image( int size ) const -{ - if( size > 1 && size <= 1000 && !m_image.isNull() ) - return m_image.scaled( size, size, Qt::KeepAspectRatio, Qt::FastTransformation ); - return m_image; -} - -void -Album::setImage( const QImage &image ) -{ - foreach( Meta::TrackPtr track, tracks() ) - { - Track *memoryTrack = static_cast( track.data() ); - Meta::AlbumPtr album = memoryTrack->originalTrack()->album(); - if( album && album->canUpdateImage() ) - album->setImage( image ); - } - // no notifyObservers() etc needed - this is done from down-up by proxied tracks -} - -void -Album::removeImage() -{ - foreach( Meta::TrackPtr track, tracks() ) - { - Track *memoryTrack = static_cast( track.data() ); - Meta::AlbumPtr album = memoryTrack->originalTrack()->album(); - if( album && album->canUpdateImage() ) - album->removeImage(); - } - // no notifyObservers() etc needed - this is done from down-up by proxied tracks -} - -void -Album::updateCachedValues() -{ - m_isCompilation = false; - m_canUpdateCompilation = false; - m_image = QImage(); - m_canUpdateImage = false; - foreach( Meta::TrackPtr track, tracks() ) - { - Track *memoryTrack = static_cast( track.data() ); - Meta::AlbumPtr album = memoryTrack->originalTrack()->album(); - - if( !album ) - continue; - - if( !m_isCompilation ) - m_isCompilation = album->isCompilation(); - if( !m_canUpdateCompilation ) - m_canUpdateCompilation = album->canUpdateCompilation(); - if( m_image.isNull() && album->hasImage() ) - m_image = album->image(); - if( !m_canUpdateImage ) - m_canUpdateImage = album->canUpdateImage(); - } -} - -Track::Track(const Meta::TrackPtr& originalTrack) - : m_track( originalTrack ) - , m_album( 0 ) - , m_artist( 0 ) - , m_composer( 0 ) - , m_genre( 0 ) - , m_year( 0 ) -{ - Q_ASSERT( originalTrack ); -} - -Track::~Track() -{ - // all following static casts are valid - there is no way attributes could have been - // set to different Meta::* subclasses - if( m_album ) - static_cast( m_album.data() )->removeTrack( this ); - if( m_artist ) - static_cast( m_artist.data() )->removeTrack( this ); - if( m_composer ) - static_cast( m_composer.data() )->removeTrack( this ); - if( m_genre ) - static_cast( m_genre.data() )->removeTrack( this ); - if( m_year ) - static_cast( m_year.data() )->removeTrack( this ); -} - -Meta::TrackEditorPtr -Track::editor() -{ - return m_track->editor(); -} - -Meta::StatisticsPtr -Track::statistics() -{ - return m_track->statistics(); -} - -void -Track::setAlbum( Album *album ) -{ - if( m_album ) - static_cast( m_album.data() )->removeTrack( this ); - if( album ) - album->addTrack( this ); - m_album = Meta::AlbumPtr( album ); -} - -void -Track::setArtist( Artist *artist ) -{ - if( m_artist ) - static_cast( m_artist.data() )->removeTrack( this ); - if( artist ) - artist->addTrack( this ); - m_artist = Meta::ArtistPtr( artist ); -} - -void -Track::setComposer( Composer *composer ) -{ - if( m_composer ) - static_cast( m_composer.data() )->removeTrack( this ); - if( composer ) - composer->addTrack( this ); - m_composer = Meta::ComposerPtr( composer ); -} - -void -Track::setGenre( Genre *genre ) -{ - if( m_genre ) - static_cast( m_genre.data() )->removeTrack( this ); - if( genre ) - genre->addTrack( this ); - m_genre = Meta::GenrePtr( genre ); -} - -void -Track::setYear( Year *year ) -{ - if( m_year ) - static_cast( m_year.data() )->removeTrack( this ); - if( year ) - year->addTrack( this ); - m_year = Meta::YearPtr( year ); -} - -MapChanger::MapChanger( MemoryCollection *memoryCollection ) - : m_mc( memoryCollection ) -{ - m_mc->acquireWriteLock(); -} - -MapChanger::~MapChanger() -{ - m_mc->releaseLock(); -} - -Meta::TrackPtr -MapChanger::addTrack( Meta::TrackPtr track ) -{ - if( !track ) - return Meta::TrackPtr(); // nothing to do - if( m_mc->trackMap().contains( track->uidUrl() ) ) - return Meta::TrackPtr(); - - Track *memoryTrack = new Track( track ); - return addExistingTrack( track, memoryTrack ); -} - -Meta::TrackPtr -MapChanger::addExistingTrack( Meta::TrackPtr track, Track *memoryTrack ) -{ - Meta::TrackPtr metaTrackPtr = Meta::TrackPtr( memoryTrack ); - m_mc->addTrack( metaTrackPtr ); - - QString artistName = track->artist().isNull() ? QString() : track->artist()->name(); - Meta::ArtistPtr artist = m_mc->artistMap().value( artistName ); - if( artist.isNull() ) - { - artist = Meta::ArtistPtr( new Artist( artistName ) ); - m_mc->addArtist( artist ); - } - memoryTrack->setArtist( static_cast( artist.data() ) ); - - Meta::AlbumPtr trackAlbum = track->album(); - QString albumName = trackAlbum ? trackAlbum->name() : QString(); - QString albumArtistName; - if( trackAlbum && trackAlbum->hasAlbumArtist() && trackAlbum->albumArtist() ) - albumArtistName = trackAlbum->albumArtist()->name(); - Meta::AlbumPtr album = m_mc->albumMap().value( albumName, albumArtistName ); - if( !album ) - { - Meta::ArtistPtr albumArtist; - const bool isCompilation = trackAlbum ? trackAlbum->isCompilation() : false; - // we create even empty-named album artists if the album is not compilation - // because Collection Browser wouldn't show these otherwise - if( !albumArtistName.isEmpty() || !isCompilation ) - { - /* Even if MemoryQueryMaker doesn't need albumArtists to be in MemoryCollection - * maps, we add her into artist map so that album artist has the same instance as - * indentically-named artist (of potentially different tracks) */ - albumArtist = m_mc->artistMap().value( albumArtistName ); - if( !albumArtist ) - { - albumArtist = Meta::ArtistPtr( new Artist( albumArtistName ) ); - m_mc->addArtist( albumArtist ); - } - } - - album = Meta::AlbumPtr( new Album( albumName, albumArtist ) ); - m_mc->addAlbum( album ); - } - Album *memoryAlbum = static_cast( album.data() ); - memoryTrack->setAlbum( memoryAlbum ); - memoryAlbum->updateCachedValues(); - - QString genreName = track->genre().isNull() ? QString() : track->genre()->name(); - Meta::GenrePtr genre = m_mc->genreMap().value( genreName ); - if( genre.isNull() ) - { - genre = Meta::GenrePtr( new Genre( genreName ) ); - m_mc->addGenre( genre ); - } - memoryTrack->setGenre( static_cast( genre.data() ) ); - - QString composerName = track->composer().isNull() ? QString() : track->composer()->name(); - Meta::ComposerPtr composer = m_mc->composerMap().value( composerName ); - if( composer.isNull() ) - { - composer = Meta::ComposerPtr( new Composer( composerName ) ); - m_mc->addComposer( composer ); - } - memoryTrack->setComposer( static_cast( composer.data() ) ); - - int year = track->year().isNull() ? 0 : track->year()->year(); - Meta::YearPtr yearPtr = m_mc->yearMap().value( year ); - if( yearPtr.isNull() ) - { - yearPtr = Meta::YearPtr( new Year( year ? QString::number( year ) : QString() ) ); - m_mc->addYear( yearPtr ); - } - memoryTrack->setYear( static_cast( yearPtr.data() ) ); - - //TODO: labels (when doing this, don't forget to tweak removeTrack too) - - return metaTrackPtr; -} - -Meta::TrackPtr -MapChanger::removeTrack( Meta::TrackPtr track ) -{ - if( !track ) - return Meta::TrackPtr(); // nothing to do - - TrackMap trackMap = m_mc->trackMap(); - ArtistMap artistMap = m_mc->artistMap(); - AlbumMap albumMap = m_mc->albumMap(); - GenreMap genreMap = m_mc->genreMap(); - ComposerMap composerMap = m_mc->composerMap(); - YearMap yearMap = m_mc->yearMap(); - - /* Ensure that we have the memory track (not the underlying one) and that it is - * actually present in MemoryCollection */ - track = trackMap.value( track->uidUrl() ); - if( !track ) - return Meta::TrackPtr(); // was not in collection, nothing to do - - /* Track added using mapadder are MemoryMeta::Tracks, but cope with different too: */ - Track *memoryTrack = dynamic_cast( track.data() ); - - trackMap.remove( track->uidUrl() ); - - /* Remove potentially dangling entities from memory collection. We cannot simply use - * if( entity && entity->tracks().count() == 1 ) because it would be racy: entity could - * have referenced a track that is no longer in MemoryCollection, but not yet destroyed. - * - * When track to remove is MemoryMeta::Track, copy and reassign Meta:: entities so - * that the track is detached from MemoryCollection completely. */ - - Meta::ArtistPtr artist = track->artist(); - if( artist && !hasTrackInMap( artist->tracks(), trackMap ) - && !referencedAsAlbumArtist( artist, albumMap ) ) - artistMap.remove( artist->name() ); - if( artist && memoryTrack ) - memoryTrack->setArtist( new Artist( artist->name() ) ); - - Meta::AlbumPtr album = track->album(); - if( album && !hasTrackInMap( album->tracks(), trackMap ) ) - { - albumMap.remove( album ); - Meta::ArtistPtr albumArtist = album->hasAlbumArtist() ? album->albumArtist() : Meta::ArtistPtr(); - if( albumArtist && !hasTrackInMap( albumArtist->tracks(), trackMap ) - && !referencedAsAlbumArtist( albumArtist, albumMap ) ) - artistMap.remove( albumArtist->name() ); - } - if( album && memoryTrack ) - memoryTrack->setAlbum( new Album( album ) ); // copy-like constructor - - Meta::GenrePtr genre = track->genre(); - if( genre && !hasTrackInMap( genre->tracks(), trackMap ) ) - genreMap.remove( genre->name() ); - if( genre && memoryTrack ) - memoryTrack->setGenre( new Genre( genre->name() ) ); - - Meta::ComposerPtr composer = track->composer(); - if( composer && !hasTrackInMap( composer->tracks(), trackMap ) ) - composerMap.remove( composer->name() ); - if( composer && memoryTrack ) - memoryTrack->setComposer( new Composer( composer->name() ) ); - - Meta::YearPtr year = track->year(); - if( year && !hasTrackInMap( year->tracks(), trackMap ) ) - yearMap.remove( year->year() ); - if( year && memoryTrack ) - memoryTrack->setYear( new Year( year->name() ) ); - - m_mc->setTrackMap( trackMap ); - m_mc->setArtistMap( artistMap ); - m_mc->setAlbumMap( albumMap ); - m_mc->setGenreMap( genreMap ); - m_mc->setComposerMap( composerMap ); - m_mc->setYearMap( yearMap ); - - if( memoryTrack ) - return memoryTrack->originalTrack(); - return Meta::TrackPtr(); -} - -bool -MapChanger::trackChanged( Meta::TrackPtr track ) -{ - if( !track ) - return false; - // make sure we have a track from memory collection: - track = m_mc->trackMap().value( track->uidUrl() ); - if( !track ) - return false; - Track *memoryTrack = dynamic_cast( track.data() ); - if( !memoryTrack ) - return false; - - Meta::TrackPtr originalTrack = memoryTrack->originalTrack(); - if( !originalTrack ) - return false; // paranoia - - bool mapsNeedUpdating = false; - // make album first so that invalidateAlbum is called every time it is needed - if( entitiesDiffer( originalTrack->album().data(), memoryTrack->album().data() ) ) - { - CoverCache::invalidateAlbum( memoryTrack->album().data() ); - mapsNeedUpdating = true; - } - else if( entitiesDiffer( originalTrack->artist().data(), memoryTrack->artist().data() ) ) - mapsNeedUpdating = true; - else if( entitiesDiffer( originalTrack->genre().data(), memoryTrack->genre().data() ) ) - mapsNeedUpdating = true; - else if( entitiesDiffer( originalTrack->composer().data(), memoryTrack->composer().data() ) ) - mapsNeedUpdating = true; - else if( entitiesDiffer( originalTrack->year().data(), memoryTrack->year().data() ) ) - mapsNeedUpdating = true; - - if( mapsNeedUpdating ) - { - // we hold write lock so we can do the followin trick: - removeTrack( track ); - addExistingTrack( originalTrack, memoryTrack ); - } - - memoryTrack->notifyObservers(); - return mapsNeedUpdating; -} - -bool -MapChanger::hasTrackInMap( const Meta::TrackList &needles, const TrackMap &haystack ) -{ - foreach( Meta::TrackPtr track, needles ) - { - if( track && haystack.contains( track->uidUrl() ) ) - return true; - } - return false; -} - -bool -MapChanger::referencedAsAlbumArtist( const Meta::ArtistPtr &artist, const AlbumMap &haystack ) -{ - foreach( Meta::AlbumPtr album, haystack ) - { - if( album && album->hasAlbumArtist() && album->albumArtist() == artist ) - return true; - } - return false; -} - -bool MapChanger::entitiesDiffer( const Meta::Base *first, const Meta::Base *second ) -{ - if( !first && !second ) - return false; // both null -> do not differ - if( !first || !second ) - return true; // one of them null -> do differ - - return first->name() != second->name(); -} - -bool MapChanger::entitiesDiffer( const Meta::Album *first, const Meta::Album *second ) -{ - if( !first && !second ) - return false; // both null -> do not differ - if( !first || !second ) - return true; // one of them null -> do differ - - if( first->name() != second->name() ) - return true; - if( first->isCompilation() != second->isCompilation() ) - return true; - if( first->hasImage() != second->hasImage() ) - return true; - if( entitiesDiffer( first->albumArtist().data(), second->albumArtist().data() ) ) - return true; - - // we only compare images using dimension, it would be too costy otherwise - if( first->image().width() != second->image().width() ) - return true; - if( first->image().height() != second->image().height() ) - return true; - - return false; -} diff --git a/amarok/src/core-impl/collections/support/MemoryMeta.h b/amarok/src/core-impl/collections/support/MemoryMeta.h deleted file mode 100644 index 93a4bfff..00000000 --- a/amarok/src/core-impl/collections/support/MemoryMeta.h +++ /dev/null @@ -1,357 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2011 Bart Cerneels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef MEMORYMETA_H -#define MEMORYMETA_H - -#include "amarok_export.h" -#include "MemoryCollection.h" -#include "core/meta/Meta.h" - -using namespace Collections; - -/** These classes can be used with a MemoryCollection to populate the meta-type maps */ -namespace MemoryMeta { - -class Track; - -/** - * Base class for all MemoryMeta:: entities that store a list of associated tracks: - * Artist, Album, Composer, Genre, Year. - * - * All methods of this class are thread-safe. - */ -class Base -{ - public: - Base( const QString &name ) : m_name( name ) {} - virtual ~Base() {} - - // Meta::{Artist,Album,Composer,Genre,Year} methods: - virtual QString name() const { return m_name; } - virtual Meta::TrackList tracks(); - - // MemoryMeta::Base methods: - void addTrack( Track *track ); - void removeTrack( Track *track ); - - private: - QString m_name; - /* We cannot easily store KSharedPtr to tracks, because it creates reference - * counting cycle: MemoryMeta::Track::m_album -> MemoryMeta::Album::tracks() -> - * MemoryMeta::Track. We therefore store plain pointers and rely on - * MemoryMeta::Track to notify when it is destroyed. */ - QList m_tracks; - QReadWriteLock m_tracksLock; -}; - -class Artist : public Meta::Artist, public Base -{ - public: - Artist( const QString &name ) : MemoryMeta::Base( name ) {} - - virtual QString name() const { return MemoryMeta::Base::name(); } - virtual Meta::TrackList tracks() { return MemoryMeta::Base::tracks(); } -}; - -class Album : public Meta::Album, public Base -{ - public: - Album( const QString &name, const Meta::ArtistPtr &albumArtist ) - : MemoryMeta::Base( name ) - , m_albumArtist( albumArtist ) - , m_isCompilation( false ) - , m_canUpdateCompilation( false ) - , m_canUpdateImage( false ) - {} - /** - * Copy-like constructor for MapChanger - */ - Album( const Meta::AlbumPtr &other ); - - /* Meta::MetaCapability virtual methods */ - virtual bool hasCapabilityInterface( Capabilities::Capability::Type type ) const; - virtual Capabilities::Capability* createCapabilityInterface( Capabilities::Capability::Type type ); - - /* Meta::Base virtual methods */ - virtual QString name() const { return MemoryMeta::Base::name(); } - - /* Meta::Album virtual methods */ - virtual bool isCompilation() const { return m_isCompilation; } - virtual bool canUpdateCompilation() const { return m_canUpdateCompilation; } - virtual void setCompilation( bool isCompilation ); - - virtual bool hasAlbumArtist() const { return !m_albumArtist.isNull(); } - virtual Meta::ArtistPtr albumArtist() const { return m_albumArtist; } - virtual Meta::TrackList tracks() { return MemoryMeta::Base::tracks(); } - - virtual bool hasImage( int /* size */ = 0 ) const { return !m_image.isNull(); } - virtual QImage image( int size = 0 ) const; - virtual bool canUpdateImage() const { return m_canUpdateImage; } - virtual void setImage( const QImage &image ); - virtual void removeImage(); - - /* MemoryMeta::Album methods: */ - /** - * Re-read isCompilation, canUpdateCompilation, image, canUpdateImage from all - * underlying tracks. - */ - void updateCachedValues(); - - private: - Meta::ArtistPtr m_albumArtist; - bool m_isCompilation; - bool m_canUpdateCompilation; - QImage m_image; - bool m_canUpdateImage; -}; - -class Composer : public Meta::Composer, public Base -{ - public: - Composer( const QString &name ) : MemoryMeta::Base( name ) {} - - virtual QString name() const { return MemoryMeta::Base::name(); } - virtual Meta::TrackList tracks() { return MemoryMeta::Base::tracks(); } -}; - -class Genre : public Meta::Genre, public Base -{ - public: - Genre( const QString &name ) : MemoryMeta::Base( name ) {} - - virtual QString name() const { return MemoryMeta::Base::name(); } - virtual Meta::TrackList tracks() { return MemoryMeta::Base::tracks(); } -}; - -class Year : public Meta::Year, public Base -{ - public: - Year( const QString &name ) : MemoryMeta::Base( name ) {} - - virtual QString name() const { return MemoryMeta::Base::name(); } - virtual Meta::TrackList tracks() { return MemoryMeta::Base::tracks(); } -}; - -class AMAROK_EXPORT Track : public Meta::Track -{ - public: - Track( const Meta::TrackPtr &originalTrack ); - virtual ~Track(); - - /* Meta::MetaCapability methods */ - virtual bool hasCapabilityInterface( Capabilities::Capability::Type type ) const - { return m_track->hasCapabilityInterface( type ); } - virtual Capabilities::Capability *createCapabilityInterface( Capabilities::Capability::Type type ) - { return m_track->createCapabilityInterface( type ); } - - /* Meta::Base virtual methods */ - virtual QString name() const { return m_track->name(); } - - /* Meta::Track virtual methods */ - virtual KUrl playableUrl() const { return m_track->playableUrl(); } - virtual QString prettyUrl() const { return m_track->prettyUrl(); } - virtual QString uidUrl() const { return m_track->uidUrl(); } - virtual QString notPlayableReason() const { return m_track->notPlayableReason(); } - - //these functions return the proxy track values - virtual Meta::AlbumPtr album() const { return m_album; } - virtual Meta::ArtistPtr artist() const { return m_artist; } - virtual Meta::ComposerPtr composer() const { return m_composer; } - virtual Meta::GenrePtr genre() const { return m_genre; } - virtual Meta::YearPtr year() const { return m_year; } - - //TODO:implement labels - virtual Meta::LabelList labels() const { return Meta::LabelList(); } - virtual qreal bpm() const { return m_track->bpm(); } - virtual QString comment() const { return m_track->comment(); } - virtual qint64 length() const { return m_track->length(); } - virtual int filesize() const { return m_track->filesize(); } - virtual int sampleRate() const { return m_track->sampleRate(); } - virtual int bitrate() const { return m_track->bitrate(); } - virtual QDateTime createDate() const { return m_track->createDate(); } - virtual QDateTime modifyDate() const { return m_track->modifyDate(); } - virtual int trackNumber() const { return m_track->trackNumber(); } - virtual int discNumber() const { return m_track->discNumber(); } - - virtual qreal replayGain( Meta::ReplayGainTag mode ) const - { return m_track->replayGain( mode ); } - virtual QString type() const { return m_track->type(); } - - virtual void prepareToPlay() { m_track->prepareToPlay(); } - virtual void finishedPlaying( double fraction ) { m_track->finishedPlaying( fraction ); } - - virtual bool inCollection() const { return m_track->inCollection(); } - virtual Collections::Collection *collection() const { return m_track->collection(); } - - virtual QString cachedLyrics() const { return m_track->cachedLyrics(); } - virtual void setCachedLyrics( const QString &lyrics ) { m_track->setCachedLyrics( lyrics ); } - - //TODO: implement labels - virtual void addLabel( const QString &label ) { Q_UNUSED( label ) } - virtual void addLabel( const Meta::LabelPtr &label ) { Q_UNUSED( label ) } - virtual void removeLabel( const Meta::LabelPtr &label ) { Q_UNUSED( label ) } - - virtual Meta::TrackEditorPtr editor(); - virtual Meta::StatisticsPtr statistics(); - - // MemoryMeta::Track methods: - - /* All of these set* methods pass the pointer to KSharedPtr (thus memory-manage it), - * remove this track from previous {Album,Artist,Composer,Genre,Year} entity (if any) - * and add this track to newly set entity. (if non-null) - * All these methods are reentrant, but not thread-safe: caller must ensure that - * only one of the following methods is called at a time on a single instance. - */ - void setAlbum( Album *album ); - void setArtist( Artist *artist ); - void setComposer( Composer *composer ); - void setGenre( Genre *genre ); - void setYear( Year *year ); - - /** - * Return the original track this track proxies. - */ - Meta::TrackPtr originalTrack() const { return m_track; } - - /** - * Make notifyObservers() public so that MapChanger can call this - */ - using Meta::Track::notifyObservers; - - private: - Meta::TrackPtr m_track; - Meta::AlbumPtr m_album; - Meta::ArtistPtr m_artist; - Meta::ComposerPtr m_composer; - Meta::GenrePtr m_genre; - Meta::YearPtr m_year; -}; - -/** - * Helper class that facilitates adding, removing and changing tracks that are in - * MemoryCollection. This class locks underlying MemoryCollection upon construction for - * writing and releases the lock in destructor. - * - * Typical usage: - * { - * MemoryMeta::MapChanger changer( memoryCollectionPtr ); - * Meta::Track newTrack = changer.addTrack( trackPtr ); - * ... - * changer.removeTrack( newTrack ); - * } - * - * All methods in this class are re-entrant and it operates on MemoryCollection in - * a thread-safe way: you can run MapChangers from multiple threads on a single - * MemoryCollection at once. (each thread constructing MapChanger when needed and deleting - * it as soon as possible) - * - * All methods can be called multiple times on a single instance and can be combined. - */ -class AMAROK_EXPORT MapChanger -{ - public: - MapChanger( MemoryCollection *memoryCollection ); - ~MapChanger(); - - /** - * Adds a track to MemoryCollection by proxying it using @see MemoryMeta::Track - * track artist, album, genre, composer and year are replaced in MemoryMeta::Track - * by relevant MemoryMeta entities, based on their value. Refuses to add a track - * whose proxy is already in MemoryCollection (returns null pointer in this case) - * - * @return pointer to a newly created MemoryMeta::Track (may be null if not - * successful) - */ - Meta::TrackPtr addTrack( Meta::TrackPtr track ); - - /** - * Removes a track from MemoryCollection. Pays attention to remove artists, - * albums, genres, composers and years that may become dangling in - * MemoryCollection. - * - * @param track MemoryMeta track to remove, it doesn't matter if this is the track - * returned by MapChanger::addTrack or the underlying one passed to - * MapChanger::addTrack - the real track is looked up using its uidUrl in - * MemoryCollection. - * - * @return shared pointer to underlying track of the deleted track, i.e. the track - * that you passed to MapChanger::addTrack() originally. May be null pointer if - * @param track is not found in collection or if it wasn't added using MapChanger. - */ - Meta::TrackPtr removeTrack( Meta::TrackPtr track ); - - /** - * Reflects changes made to underlying track to its proxy track in - * MemoryCollection and to MemoryCollection maps. - * - * The one who called MapChanger::addTrack() is responsible to call this method - * every time it detects that some metadata of underlying track have changed - * (perhaps by becoming its observer), even in minor fields such as comment. This - * method instructs proxy track to call notifyObservers(). - * - * Please note that this method is currently unable to cope with changes - * to track uidUrl(). If you really need it, change MemoryCollection's - * trackMap manually _before_ calling this. - * - * @param track track whose metadata have changed, it doesn't matter if this is - * the track returned by MapChanger::addTrack or the underlying one passed to - * MapChanger::addTrack - the real track is looked up using its uidUrl in - * MemoryCollection. Does nothing if @param track is not found in MemoryCollection. - * - * @return true if memory collection maps had to be changed, false for minor - * changes where this is not required - */ - bool trackChanged( Meta::TrackPtr track ); - - private: - /** - * Worker for addTrack. - * - * @param track original underlying track - source of metadata - * @param memoryTrack new track to add to MemoryCollection - target of metadata - */ - Meta::TrackPtr addExistingTrack( Meta::TrackPtr track, Track *memoryTrack ); - - /** - * Return true if at least one of the tracks in @param needles is in - * @param haystack, false otherwise. Comparison is done using track uidUrl. - */ - static bool hasTrackInMap( const Meta::TrackList &needles, const TrackMap &haystack ); - - /** - * Return true if artist @param artist is referenced as albumArtist of one of the - * albums from @param haystack. The match is done using Meta:ArtistPtr - * operator==. - */ - static bool referencedAsAlbumArtist( const Meta::ArtistPtr &artist, const AlbumMap &haystack ); - - /** - * Return true if @param first has different value than @param other. Specifically - * returns true if one entity is null and the other non-null, but returns true if - * both are null. - */ - static bool entitiesDiffer( const Meta::Base *first, const Meta::Base *second ); - /** - * Overload for albums, we compare album artist, isCollection and image too - */ - static bool entitiesDiffer( const Meta::Album *first, const Meta::Album *second ); - - MemoryCollection *m_mc; -}; - -} -#endif diff --git a/amarok/src/core-impl/collections/support/MemoryQueryMaker.cpp b/amarok/src/core-impl/collections/support/MemoryQueryMaker.cpp deleted file mode 100644 index 973d07b8..00000000 --- a/amarok/src/core-impl/collections/support/MemoryQueryMaker.cpp +++ /dev/null @@ -1,492 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007-2009 Maximilian Kossick * - * Copyright (c) 2007-2009 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "MemoryQueryMaker.h" -#include "MemoryCustomValue.h" -#include "MemoryFilter.h" -#include "MemoryMatcher.h" -#include "MemoryQueryMakerHelper.h" -#include "MemoryQueryMakerInternal.h" -#include "core/support/Debug.h" - -#include -#include - -#include -#include -#include -#include - -#include -#include - -using namespace Collections; - -//QueryJob - -class QueryJob : public ThreadWeaver::Job -{ - public: - QueryJob( MemoryQueryMakerInternal *qmInternal ) - : ThreadWeaver::Job() - , queryMakerInternal( qmInternal ) - { - //nothing to do - } - - ~QueryJob() - { - delete queryMakerInternal; - } - - protected: - void run() - { - queryMakerInternal->runQuery(); - setFinished( true ); - } - - public: - MemoryQueryMakerInternal *queryMakerInternal; -}; - -struct MemoryQueryMaker::Private { - QueryMaker::QueryType type; - bool returnDataPtrs; - MemoryMatcher* matcher; - QueryJob *job; - int maxsize; - QStack containerFilters; - QList returnFunctions; - QList returnValues; - bool usingFilters; - KRandomSequence sequence; //do not reset - qint64 orderByField; - bool orderDescending; - bool orderByNumberField; - AlbumQueryMode albumQueryMode; - LabelQueryMode labelQueryMode; - QString collectionId; -}; - -MemoryQueryMaker::MemoryQueryMaker( QWeakPointer mc, const QString &collectionId ) - : QueryMaker() - , m_collection( mc ) - , d( new Private ) -{ - d->collectionId = collectionId; - d->matcher = 0; - d->job = 0; - d->type = QueryMaker::None; - d->returnDataPtrs = false; - d->job = 0; - d->job = 0; - d->maxsize = -1; - d->containerFilters.push( new AndContainerMemoryFilter() ); - d->usingFilters = false; - d->orderByField = 0; - d->orderDescending = false; - d->orderByNumberField = false; - d->albumQueryMode = AllAlbums; - d->labelQueryMode = QueryMaker::NoConstraint; -} - -MemoryQueryMaker::~MemoryQueryMaker() -{ - disconnect(); - abortQuery(); - if( !d->containerFilters.isEmpty() ) - delete d->containerFilters.first(); - delete d; -} - -void -MemoryQueryMaker::run() -{ - if ( d->type == QueryMaker::None ) - //TODO error handling - return; - else if( d->job && !d->job->isFinished() ) - { - //the worker thread seems to be running - //TODO: wait or job to complete - } - else - { - MemoryQueryMakerInternal *qmi = new MemoryQueryMakerInternal( m_collection ); - if( d->usingFilters ) - { - qmi->setFilters( d->containerFilters.first() ); - d->containerFilters.clear(); //will be deleted by MemoryQueryMakerInternal - } - qmi->setMatchers( d->matcher ); - d->matcher = 0; //will be deleted by MemoryQueryMakerInternal - qmi->setMaxSize( d->maxsize ); - qmi->setType( d->type ); - qmi->setCustomReturnFunctions( d->returnFunctions ); - d->returnFunctions.clear(); //will be deleted by MemoryQueryMakerInternal - qmi->setCustomReturnValues( d->returnValues ); - d->returnValues.clear(); //will be deleted by MemoryQueryMakerInternal - qmi->setAlbumQueryMode( d->albumQueryMode ); - qmi->setLabelQueryMode( d->labelQueryMode ); - qmi->setOrderDescending( d->orderDescending ); - qmi->setOrderByNumberField( d->orderByNumberField ); - qmi->setOrderByField( d->orderByField ); - qmi->setCollectionId( d->collectionId ); - - connect( qmi, SIGNAL(newResultReady(Meta::AlbumList)), SIGNAL(newResultReady(Meta::AlbumList)), Qt::DirectConnection ); - connect( qmi, SIGNAL(newResultReady(Meta::ArtistList)), SIGNAL(newResultReady(Meta::ArtistList)), Qt::DirectConnection ); - connect( qmi, SIGNAL(newResultReady(Meta::GenreList)), SIGNAL(newResultReady(Meta::GenreList)), Qt::DirectConnection ); - connect( qmi, SIGNAL(newResultReady(Meta::ComposerList)), SIGNAL(newResultReady(Meta::ComposerList)), Qt::DirectConnection ); - connect( qmi, SIGNAL(newResultReady(Meta::YearList)), SIGNAL(newResultReady(Meta::YearList)), Qt::DirectConnection ); - connect( qmi, SIGNAL(newResultReady(Meta::TrackList)), SIGNAL(newResultReady(Meta::TrackList)), Qt::DirectConnection ); - connect( qmi, SIGNAL(newResultReady(QStringList)), SIGNAL(newResultReady(QStringList)), Qt::DirectConnection ); - connect( qmi, SIGNAL(newResultReady(Meta::LabelList)), SIGNAL(newResultReady(Meta::LabelList)), Qt::DirectConnection ); - - d->job = new QueryJob( qmi ); - connect( d->job, SIGNAL(done(ThreadWeaver::Job*)), SLOT(done(ThreadWeaver::Job*)) ); - ThreadWeaver::Weaver::instance()->enqueue( d->job ); - } -} - -void -MemoryQueryMaker::abortQuery() -{ - if( d->job ) - { - d->job->requestAbort(); - d->job->disconnect( this ); - if( d->job->queryMakerInternal ) - d->job->queryMakerInternal->disconnect( this ); - } -} - -QueryMaker* -MemoryQueryMaker::setQueryType( QueryType type ) -{ - switch( type ) { - case QueryMaker::Track: - if ( d->type == QueryMaker::None ) - d->type = QueryMaker::Track; - return this; - - case QueryMaker::Artist: - if ( d->type == QueryMaker::None ) - d->type = QueryMaker::Artist; - return this; - - case QueryMaker::Album: - if ( d->type == QueryMaker::None ) - d->type = QueryMaker::Album; - return this; - - case QueryMaker::AlbumArtist: - if ( d->type == QueryMaker::None ) - d->type = QueryMaker::AlbumArtist; - return this; - - case QueryMaker::Composer: - if ( d->type == QueryMaker::None ) - d->type = QueryMaker::Composer; - return this; - - case QueryMaker::Genre: - if ( d->type == QueryMaker::None ) - d->type = QueryMaker::Genre; - return this; - - case QueryMaker::Year: - if ( d->type == QueryMaker::None ) - d->type = QueryMaker::Year; - return this; - - case QueryMaker::Custom: - if ( d->type == QueryMaker::None ) - d->type = QueryMaker::Custom; - return this; - - case QueryMaker::Label: - if( d->type == QueryMaker::None ) - d->type = QueryMaker::Label; - return this; - - case QueryMaker::None: - return this; - } - return this; -} - -QueryMaker* -MemoryQueryMaker::addReturnValue( qint64 value ) -{ - //MQM can not deliver sensible results if both a custom return value and a return function is selected - if( d->returnFunctions.empty() ) - { - CustomReturnValue *returnValue = CustomValueFactory::returnValue( value ); - if( returnValue ) - d->returnValues.append( returnValue ); - } - return this; -} - -QueryMaker* -MemoryQueryMaker::addReturnFunction( ReturnFunction function, qint64 value ) -{ - //MQM can not deliver sensible results if both a custom return value and a return function is selected - if( d->returnValues.empty() ) - { - CustomReturnFunction *returnFunction = CustomValueFactory::returnFunction( function, value ); - if( returnFunction ) - d->returnFunctions.append( returnFunction ); - } - return this; -} - -QueryMaker* -MemoryQueryMaker::orderBy( qint64 value, bool descending ) -{ - d->orderByField = value; - d->orderDescending = descending; - switch( value ) - { - case Meta::valYear: - case Meta::valDiscNr: - case Meta::valTrackNr: - case Meta::valScore: - case Meta::valRating: - case Meta::valPlaycount: - case Meta::valFilesize: - case Meta::valSamplerate: - case Meta::valBitrate: - case Meta::valLength: - { - d->orderByNumberField = true; - break; - } - //TODO: what about Meta::valFirstPlayed, Meta::valCreateDate or Meta::valLastPlayed?? - - default: - d->orderByNumberField = false; - } - return this; -} - -QueryMaker* -MemoryQueryMaker::addMatch( const Meta::TrackPtr &track ) -{ - MemoryMatcher *trackMatcher = new TrackMatcher( track ); - if ( d->matcher == 0 ) - d->matcher = trackMatcher; - else - { - MemoryMatcher *tmp = d->matcher; - while ( !tmp->isLast() ) - tmp = tmp->next(); - tmp->setNext( trackMatcher ); - } - return this; -} - -QueryMaker* -MemoryQueryMaker::addMatch( const Meta::ArtistPtr &artist, ArtistMatchBehaviour behaviour ) -{ - MemoryMatcher *artistMatcher = new ArtistMatcher( artist, behaviour ); - if ( d->matcher == 0 ) - d->matcher = artistMatcher; - else - { - MemoryMatcher *tmp = d->matcher; - while ( !tmp->isLast() ) - tmp = tmp->next(); - tmp->setNext( artistMatcher ); - } - return this; -} - -QueryMaker* -MemoryQueryMaker::addMatch( const Meta::AlbumPtr &album ) -{ - MemoryMatcher *albumMatcher = new AlbumMatcher( album ); - if ( d->matcher == 0 ) - d->matcher = albumMatcher; - else - { - MemoryMatcher *tmp = d->matcher; - while ( !tmp->isLast() ) - tmp = tmp->next(); - tmp->setNext( albumMatcher ); - } - return this; -} - -QueryMaker* -MemoryQueryMaker::addMatch( const Meta::GenrePtr &genre ) -{ - MemoryMatcher *genreMatcher = new GenreMatcher( genre ); - if ( d->matcher == 0 ) - d->matcher = genreMatcher; - else - { - MemoryMatcher *tmp = d->matcher; - while ( !tmp->isLast() ) - tmp = tmp->next(); - tmp->setNext( genreMatcher ); - } - return this; -} - -QueryMaker* -MemoryQueryMaker::addMatch( const Meta::ComposerPtr &composer ) -{ - MemoryMatcher *composerMatcher = new ComposerMatcher( composer ); - if ( d->matcher == 0 ) - d->matcher = composerMatcher; - else - { - MemoryMatcher *tmp = d->matcher; - while ( !tmp->isLast() ) - tmp = tmp->next(); - tmp->setNext( composerMatcher ); - } - return this; -} - -QueryMaker* -MemoryQueryMaker::addMatch( const Meta::YearPtr &year ) -{ - MemoryMatcher *yearMatcher = new YearMatcher( year ); - if ( d->matcher == 0 ) - d->matcher = yearMatcher; - else - { - MemoryMatcher *tmp = d->matcher; - while ( !tmp->isLast() ) - tmp = tmp->next(); - tmp->setNext( yearMatcher ); - } - return this; -} - -QueryMaker* -MemoryQueryMaker::addMatch( const Meta::LabelPtr &label ) -{ - MemoryMatcher *labelMatcher = new LabelMatcher( label ); - if( d->matcher == 0 ) - { - d->matcher = labelMatcher; - } - else - { - MemoryMatcher *tmp = d->matcher; - while( !tmp->isLast() ) - { - tmp = tmp->next(); - } - tmp->setNext( labelMatcher ); - } - return this; -} - -QueryMaker* -MemoryQueryMaker::addFilter( qint64 value, const QString &filter, bool matchBegin, bool matchEnd ) -{ - d->containerFilters.top()->addFilter( FilterFactory::filter( value, filter, matchBegin, matchEnd ) ); - d->usingFilters = true; - return this; -} - -QueryMaker* -MemoryQueryMaker::excludeFilter( qint64 value, const QString &filter, bool matchBegin, bool matchEnd ) -{ - MemoryFilter *tmp = FilterFactory::filter( value, filter, matchBegin, matchEnd ); - d->containerFilters.top()->addFilter( new NegateMemoryFilter( tmp ) ); - d->usingFilters = true; - return this; -} - -QueryMaker* -MemoryQueryMaker::addNumberFilter( qint64 value, qint64 filter, NumberComparison compare ) -{ - d->containerFilters.top()->addFilter( FilterFactory::numberFilter( value, filter, compare ) ); - d->usingFilters = true; - return this; -} - -QueryMaker* -MemoryQueryMaker::excludeNumberFilter( qint64 value, qint64 filter, NumberComparison compare ) -{ - MemoryFilter *tmp = FilterFactory::numberFilter( value, filter, compare ); - d->containerFilters.top()->addFilter( new NegateMemoryFilter( tmp ) ); - d->usingFilters = true; - return this; -} - -QueryMaker* -MemoryQueryMaker::limitMaxResultSize( int size ) -{ - d->maxsize = size; - return this; -} - -QueryMaker* -MemoryQueryMaker::beginAnd() -{ - ContainerMemoryFilter *filter = new AndContainerMemoryFilter(); - d->containerFilters.top()->addFilter( filter ); - d->containerFilters.push( filter ); - return this; -} - -QueryMaker* -MemoryQueryMaker::beginOr() -{ - ContainerMemoryFilter *filter = new OrContainerMemoryFilter(); - d->containerFilters.top()->addFilter( filter ); - d->containerFilters.push( filter ); - return this; -} - -QueryMaker* -MemoryQueryMaker::endAndOr() -{ - d->containerFilters.pop(); - return this; -} - -void -MemoryQueryMaker::done( ThreadWeaver::Job *job ) -{ - ThreadWeaver::Weaver::instance()->dequeue( job ); - job->deleteLater(); - d->job = 0; - emit queryDone(); -} - -QueryMaker * MemoryQueryMaker::setAlbumQueryMode( AlbumQueryMode mode ) -{ - d->albumQueryMode = mode; - return this; -} - -QueryMaker* -MemoryQueryMaker::setLabelQueryMode( LabelQueryMode mode ) -{ - d->labelQueryMode = mode; - return this; -} - -#include "moc_MemoryQueryMaker.cpp" diff --git a/amarok/src/core-impl/collections/support/MemoryQueryMaker.h b/amarok/src/core-impl/collections/support/MemoryQueryMaker.h deleted file mode 100644 index a6cad3df..00000000 --- a/amarok/src/core-impl/collections/support/MemoryQueryMaker.h +++ /dev/null @@ -1,94 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Maximilian Kossick * - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef MEMORYQUERYMAKER_H -#define MEMORYQUERYMAKER_H - -#include "amarok_export.h" - -#include "MemoryCollection.h" -#include "core/collections/QueryMaker.h" - -#include - - -namespace ThreadWeaver -{ - class Job; -} - -namespace Collections { - -class AMAROK_EXPORT MemoryQueryMaker : public QueryMaker -{ - Q_OBJECT - public: - /** - * Creates a new MemoryQueryMaker that will query a memory collection. - * This class implements the QueryMaker interface and can be used as a generic - * query maker for all collections that use MemoryCollection. - * @param mc the MemoryCollection instance that the query should be run on. - * @param collectionId the collectionid that has to be emitted by this querymaker. - */ - MemoryQueryMaker( QWeakPointer mc, const QString &collectionId ); - virtual ~MemoryQueryMaker(); - - virtual void run(); - virtual void abortQuery(); - - virtual QueryMaker* setQueryType( QueryType type ); - - virtual QueryMaker* addReturnValue( qint64 value ); - virtual QueryMaker* addReturnFunction( ReturnFunction function, qint64 value ); - virtual QueryMaker* orderBy( qint64 value, bool descending = false ); - - virtual QueryMaker* addMatch( const Meta::TrackPtr &track ); - virtual QueryMaker* addMatch( const Meta::ArtistPtr &artist, ArtistMatchBehaviour behaviour = TrackArtists ); - virtual QueryMaker* addMatch( const Meta::AlbumPtr &album ); - virtual QueryMaker* addMatch( const Meta::ComposerPtr &composer ); - virtual QueryMaker* addMatch( const Meta::GenrePtr &genre ); - virtual QueryMaker* addMatch( const Meta::YearPtr &year ); - virtual QueryMaker* addMatch( const Meta::LabelPtr &label ); - - virtual QueryMaker* addFilter( qint64 value, const QString &filter, bool matchBegin, bool matchEnd ); - virtual QueryMaker* excludeFilter( qint64 value, const QString &filter, bool matchBegin, bool matchEnd ); - - virtual QueryMaker* addNumberFilter( qint64 value, qint64 filter, NumberComparison compare ); - virtual QueryMaker* excludeNumberFilter( qint64 value, qint64 filter, NumberComparison compare ); - - virtual QueryMaker* limitMaxResultSize( int size ); - - virtual QueryMaker* beginAnd(); - virtual QueryMaker* beginOr(); - virtual QueryMaker* endAndOr(); - - virtual QueryMaker* setAlbumQueryMode( AlbumQueryMode mode ); - virtual QueryMaker* setLabelQueryMode( LabelQueryMode mode ); - - private slots: - void done( ThreadWeaver::Job * job ); - - protected: - - QWeakPointer m_collection; - struct Private; - Private * const d; -}; - -} //namespace Collections - -#endif diff --git a/amarok/src/core-impl/collections/support/MemoryQueryMakerHelper.cpp b/amarok/src/core-impl/collections/support/MemoryQueryMakerHelper.cpp deleted file mode 100644 index 548586e2..00000000 --- a/amarok/src/core-impl/collections/support/MemoryQueryMakerHelper.cpp +++ /dev/null @@ -1,168 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "MemoryQueryMakerHelper.h" - -#include "core-impl/collections/support/MemoryCustomValue.h" -#include "core/meta/Meta.h" - -#include -#include -#include -#include - -#include -#include - -using namespace Collections; - -template -QList -MemoryQueryMakerHelper::orderListByName( const QList &list, bool descendingOrder ) -{ - QList resultList = list; - KSortableList sortList; - foreach( const PointerType &pointer, list ) - { - sortList.insert( pointer->name(), pointer ); - } - sortList.sort(); - QList tmpList; - typedef KSortableItem SortItem; - foreach( const SortItem &item, sortList ) - { - tmpList.append( item.second ); - } - if( descendingOrder ) - { - //KSortableList uses qSort, which orders a list in ascending order - resultList = reverse( tmpList ); - } - else - { - resultList = tmpList; - } - return resultList; -} - -Meta::YearList -MemoryQueryMakerHelper::orderListByYear( const Meta::YearList &list, bool descendingOrder ) -{ - KSortableList sortList; - foreach( Meta::YearPtr pointer, list ) - { - sortList.insert( pointer->name().toDouble(), pointer ); - } - sortList.sort(); - QList tmpList; - typedef KSortableItem SortItem; - foreach( const SortItem &item, sortList ) - { - tmpList.append( item.second ); - } - if( descendingOrder ) - { - //KSortableList uses qSort, which orders a list in ascending order - return reverse( tmpList ); - } - else - { - return tmpList; - } -} - -template -QList -MemoryQueryMakerHelper::reverse(const QList &l) -{ - QList ret; - for (int i=l.size() - 1; i>=0; --i) - ret.append(l.at(i)); - return ret; -} - -Meta::TrackList -MemoryQueryMakerHelper::orderListByString( const Meta::TrackList &tracks, qint64 value, bool orderDescending ) -{ - Meta::TrackList resultList = tracks; - CustomReturnValue *crv = CustomValueFactory::returnValue( value ); - if( crv ) - { - KSortableList sortList; - foreach( const Meta::TrackPtr &pointer, tracks ) - { - sortList.insert( crv->value( pointer ), pointer ); - } - sortList.sort(); - Meta::TrackList tmpList; - typedef KSortableItem SortItem; - foreach( const SortItem &item, sortList ) - { - tmpList.append( item.second ); - } - if( orderDescending ) - { - //KSortableList uses qSort, which orders a list in ascending order - resultList = reverse( tmpList ); - } - else - { - resultList = tmpList; - } - } - delete crv; - return resultList; -} - -Meta::TrackList -MemoryQueryMakerHelper::orderListByNumber( const Meta::TrackList &tracks, qint64 value, bool orderDescending ) -{ - Meta::TrackList resultList = tracks; - CustomReturnValue *crv = CustomValueFactory::returnValue( value ); - if( crv ) - { - KSortableList sortList; - foreach( const Meta::TrackPtr &pointer, tracks ) - { - sortList.insert( crv->value( pointer ).toDouble(), pointer ); - } - sortList.sort(); - Meta::TrackList tmpList; - typedef KSortableItem SortItem; - foreach( const SortItem &item, sortList ) - { - tmpList.append( item.second ); - } - if( orderDescending ) - { - //KSortableList uses qSort, which orders a list in ascending order - resultList = reverse( tmpList ); - } - else - { - resultList = tmpList; - } - } - delete crv; - return resultList; -} - -template QList MemoryQueryMakerHelper::orderListByName( const QList &list, bool ); -template QList MemoryQueryMakerHelper::orderListByName( const QList &list, bool ); -template QList MemoryQueryMakerHelper::orderListByName( const QList &list, bool ); -template QList MemoryQueryMakerHelper::orderListByName( const QList &list, bool ); -template QList MemoryQueryMakerHelper::orderListByName( const QList &list, bool ); - diff --git a/amarok/src/core-impl/collections/support/MemoryQueryMakerHelper.h b/amarok/src/core-impl/collections/support/MemoryQueryMakerHelper.h deleted file mode 100644 index 2039e49b..00000000 --- a/amarok/src/core-impl/collections/support/MemoryQueryMakerHelper.h +++ /dev/null @@ -1,41 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef MEMORYQUERYMAKERHELPER_H -#define MEMORYQUERYMAKERHELPER_H - -#include -#include "core/meta/forward_declarations.h" - -namespace Collections { - -namespace MemoryQueryMakerHelper -{ - template - QList orderListByName( const QList &list, bool descendingOrder ); - - Meta::YearList orderListByYear ( const Meta::YearList &list, bool descendingOrder ); - - Meta::TrackList orderListByString( const Meta::TrackList &tracks, qint64 value, bool orderDescending ); - Meta::TrackList orderListByNumber( const Meta::TrackList &tracks, qint64 value, bool orderDescending ); - - template - QList reverse(const QList &l); -} - -} //namespace Collections - -#endif diff --git a/amarok/src/core-impl/collections/support/MemoryQueryMakerInternal.cpp b/amarok/src/core-impl/collections/support/MemoryQueryMakerInternal.cpp deleted file mode 100644 index 50b491c4..00000000 --- a/amarok/src/core-impl/collections/support/MemoryQueryMakerInternal.cpp +++ /dev/null @@ -1,614 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "MemoryQueryMakerInternal.h" - -#include "MemoryCollection.h" -#include "MemoryCustomValue.h" -#include "MemoryFilter.h" -#include "MemoryMatcher.h" -#include "MemoryQueryMakerHelper.h" - -#include "core/meta/Meta.h" - -#include - -#include - -namespace Collections { - -MemoryQueryMakerInternal::MemoryQueryMakerInternal( const QWeakPointer &collection ) - : QObject() - , m_collection( collection ) - , m_matchers( 0 ) - , m_filters( 0 ) - , m_maxSize( 0 ) - , m_type( QueryMaker::None ) - , m_albumQueryMode( QueryMaker::AllAlbums ) - , m_orderDescending( false ) - , m_orderByNumberField( false ) - , m_orderByField( 0 ) -{ - -} - -MemoryQueryMakerInternal::~MemoryQueryMakerInternal() -{ - delete m_filters; - delete m_matchers; - qDeleteAll( m_returnFunctions ); - qDeleteAll( m_returnValues ); -} - -void -MemoryQueryMakerInternal::runQuery() -{ - QSharedPointer coll = m_collection.toStrongRef(); - if( coll ) - coll->acquireReadLock(); - //naive implementation, fix this - if ( m_matchers ) - { - Meta::TrackList result = coll ? m_matchers->match( coll.data() ) : Meta::TrackList(); - if ( m_filters ) - { - Meta::TrackList filtered; - foreach( Meta::TrackPtr track, result ) - { - if( m_filters->filterMatches( track ) ) - filtered.append( track ); - } - handleResult( filtered ); - } - else - handleResult( result ); - } - else if ( m_filters ) - { - Meta::TrackList tracks = coll ? coll->trackMap().values() : Meta::TrackList(); - Meta::TrackList filtered; - foreach( const Meta::TrackPtr &track, tracks ) - { - if ( m_filters->filterMatches( track ) ) - filtered.append( track ); - } - handleResult( filtered ); - } - else - handleResult(); - if( coll ) - coll->releaseLock(); -} - -template -void MemoryQueryMakerInternal::emitProperResult( const QList& list ) -{ - QList resultList = list; - - if ( m_maxSize >= 0 && resultList.count() > m_maxSize ) - resultList = resultList.mid( 0, m_maxSize ); - - emit newResultReady( list ); -} - -template -static inline QList reverse(const QList &l) -{ - QList ret; - for (int i=l.size() - 1; i>=0; --i) - ret.append(l.at(i)); - return ret; -} - -void -MemoryQueryMakerInternal::handleResult() -{ - QSharedPointer coll = m_collection.toStrongRef(); - //this gets called when we want to return all values for the given query type - switch( m_type ) - { - case QueryMaker::Custom : - { - QStringList result; - Meta::TrackList tmpTracks = coll ? coll->trackMap().values() : Meta::TrackList(); - Meta::TrackList tracks; - foreach( const Meta::TrackPtr &track, tmpTracks ) - { - if( ( m_albumQueryMode == QueryMaker::AllAlbums - || ( m_albumQueryMode == QueryMaker::OnlyCompilations && track->album()->isCompilation() ) - || ( m_albumQueryMode == QueryMaker::OnlyNormalAlbums && !track->album()->isCompilation()) ) && - ( m_labelQueryMode == QueryMaker::NoConstraint - || ( m_labelQueryMode == QueryMaker::OnlyWithLabels && track->labels().count() > 0 ) - || ( m_labelQueryMode == QueryMaker::OnlyWithoutLabels && track->labels().count() == 0) ) ) - { - tracks.append( track ); - } - } - - if( !m_returnFunctions.empty() ) - { - //no sorting necessary - foreach( CustomReturnFunction *function, m_returnFunctions ) - { - result.append( function->value( tracks ) ); - } - } - else if( !m_returnValues.empty() ) - { - if( m_orderByField ) - { - if( m_orderByNumberField ) - tracks = MemoryQueryMakerHelper::orderListByNumber( tracks, m_orderByField, m_orderDescending ); - else - tracks = MemoryQueryMakerHelper::orderListByString( tracks, m_orderByField, m_orderDescending ); - } - - int count = 0; - foreach( const Meta::TrackPtr &track, tracks ) - { - if ( m_maxSize >= 0 && count == m_maxSize ) - break; - - foreach( CustomReturnValue *value, m_returnValues ) - { - result.append( value->value( track ) ); - } - count++; - } - } - emit newResultReady( result ); - break; - } - case QueryMaker::Track : - { - Meta::TrackList tracks; - - Meta::TrackList tmpTracks = coll ? coll->trackMap().values() : Meta::TrackList(); - foreach( Meta::TrackPtr track, tmpTracks ) - { - Meta::AlbumPtr album = track->album(); - if( ( m_albumQueryMode == QueryMaker::AllAlbums - || ( m_albumQueryMode == QueryMaker::OnlyCompilations && (!album || album->isCompilation()) ) - || ( m_albumQueryMode == QueryMaker::OnlyNormalAlbums && (album && !album->isCompilation()) ) ) && - ( m_labelQueryMode == QueryMaker::NoConstraint - || ( m_labelQueryMode == QueryMaker::OnlyWithLabels && track->labels().count() > 0 ) - || ( m_labelQueryMode == QueryMaker::OnlyWithoutLabels && track->labels().count() == 0) ) ) - { - tracks.append( track ); - } - } - - if( m_orderByField ) - { - if( m_orderByNumberField ) - tracks = MemoryQueryMakerHelper::orderListByNumber( tracks, m_orderByField, m_orderDescending ); - else - tracks = MemoryQueryMakerHelper::orderListByString( tracks, m_orderByField, m_orderDescending ); - } - - emitProperResult( tracks ); - break; - } - case QueryMaker::Album : - { - Meta::AlbumList albums; - Meta::AlbumList tmp = coll ? coll->albumMap().values() : Meta::AlbumList(); - foreach( Meta::AlbumPtr album, tmp ) - { - Meta::TrackList tracks = album->tracks(); - foreach( Meta::TrackPtr track, tracks ) - { - Meta::AlbumPtr album = track->album(); - if( ( m_albumQueryMode == QueryMaker::AllAlbums - || ( m_albumQueryMode == QueryMaker::OnlyCompilations && (!album || album->isCompilation()) ) - || ( m_albumQueryMode == QueryMaker::OnlyNormalAlbums && (album && !album->isCompilation()) ) ) && - ( m_labelQueryMode == QueryMaker::NoConstraint - || ( m_labelQueryMode == QueryMaker::OnlyWithLabels && track->labels().count() > 0 ) - || ( m_labelQueryMode == QueryMaker::OnlyWithoutLabels && track->labels().count() == 0) ) ) - { - albums.append( album ); - break; - } - } - } - - albums = MemoryQueryMakerHelper::orderListByName( albums, m_orderDescending ); - - emitProperResult( albums ); - break; - } - case QueryMaker::Artist : - { - Meta::ArtistList artists; - Meta::ArtistList tmp = coll ? coll->artistMap().values() : Meta::ArtistList(); - foreach( Meta::ArtistPtr artist, tmp ) - { - Meta::TrackList tracks = artist->tracks(); - foreach( Meta::TrackPtr track, tracks ) - { - if( ( m_albumQueryMode == QueryMaker::AllAlbums - || ( m_albumQueryMode == QueryMaker::OnlyCompilations && track->album()->isCompilation() ) - || ( m_albumQueryMode == QueryMaker::OnlyNormalAlbums && !track->album()->isCompilation()) ) && - ( m_labelQueryMode == QueryMaker::NoConstraint - || ( m_labelQueryMode == QueryMaker::OnlyWithLabels && track->labels().count() > 0 ) - || ( m_labelQueryMode == QueryMaker::OnlyWithoutLabels && track->labels().count() == 0) ) ) - { - artists.append( artist ); - break; - } - } - } - artists = MemoryQueryMakerHelper::orderListByName( artists, m_orderDescending ); - emitProperResult( artists ); - break; - } - case QueryMaker::AlbumArtist : - { - Meta::ArtistList artists; - Meta::AlbumList tmp = coll ? coll->albumMap().values() : Meta::AlbumList(); - foreach( Meta::AlbumPtr album, tmp ) - { - if( !album->hasAlbumArtist() ) - continue; - - Meta::TrackList tracks = album->tracks(); - foreach( Meta::TrackPtr track, tracks ) - { - if( ( m_albumQueryMode == QueryMaker::AllAlbums - || ( m_albumQueryMode == QueryMaker::OnlyCompilations && album->isCompilation() ) - || ( m_albumQueryMode == QueryMaker::OnlyNormalAlbums && !album->isCompilation()) ) && - ( m_labelQueryMode == QueryMaker::NoConstraint - || ( m_labelQueryMode == QueryMaker::OnlyWithLabels && track->labels().count() > 0 ) - || ( m_labelQueryMode == QueryMaker::OnlyWithoutLabels && track->labels().count() == 0) ) ) - { - artists.append( album->albumArtist() ); - break; - } - } - } - artists = MemoryQueryMakerHelper::orderListByName( artists, m_orderDescending ); - emitProperResult( artists ); - break; - } - case QueryMaker::Composer : - { - Meta::ComposerList composers; - Meta::ComposerList tmp = coll ? coll->composerMap().values() : Meta::ComposerList(); - foreach( Meta::ComposerPtr composer, tmp ) - { - Meta::TrackList tracks = composer->tracks(); - foreach( Meta::TrackPtr track, tracks ) - { - if( ( m_albumQueryMode == QueryMaker::AllAlbums - || ( m_albumQueryMode == QueryMaker::OnlyCompilations && track->album()->isCompilation() ) - || ( m_albumQueryMode == QueryMaker::OnlyNormalAlbums && !track->album()->isCompilation()) ) && - ( m_labelQueryMode == QueryMaker::NoConstraint - || ( m_labelQueryMode == QueryMaker::OnlyWithLabels && track->labels().count() > 0 ) - || ( m_labelQueryMode == QueryMaker::OnlyWithoutLabels && track->labels().count() == 0) ) ) - { - composers.append( composer ); - break; - } - } - } - composers = MemoryQueryMakerHelper::orderListByName( composers, m_orderDescending ); - - emitProperResult( composers ); - break; - } - case QueryMaker::Genre : - { - Meta::GenreList genres; - Meta::GenreList tmp = coll ? coll->genreMap().values() : Meta::GenreList(); - foreach( Meta::GenrePtr genre, tmp ) - { - Meta::TrackList tracks = genre->tracks(); - foreach( Meta::TrackPtr track, tracks ) - { - if( ( m_albumQueryMode == QueryMaker::AllAlbums - || ( m_albumQueryMode == QueryMaker::OnlyCompilations && track->album()->isCompilation() ) - || ( m_albumQueryMode == QueryMaker::OnlyNormalAlbums && !track->album()->isCompilation()) ) && - ( m_labelQueryMode == QueryMaker::NoConstraint - || ( m_labelQueryMode == QueryMaker::OnlyWithLabels && track->labels().count() > 0 ) - || ( m_labelQueryMode == QueryMaker::OnlyWithoutLabels && track->labels().count() == 0) ) ) - { - genres.append( genre ); - break; - } - } - } - - genres = MemoryQueryMakerHelper::orderListByName( genres, m_orderDescending ); - - emitProperResult( genres ); - break; - } - case QueryMaker::Year : - { - Meta::YearList years; - Meta::YearList tmp = coll ? coll->yearMap().values() : Meta::YearList(); - foreach( Meta::YearPtr year, tmp ) - { - Meta::TrackList tracks = year->tracks(); - foreach( Meta::TrackPtr track, tracks ) - { - if( ( m_albumQueryMode == QueryMaker::AllAlbums - || ( m_albumQueryMode == QueryMaker::OnlyCompilations && track->album()->isCompilation() ) - || ( m_albumQueryMode == QueryMaker::OnlyNormalAlbums && !track->album()->isCompilation()) ) && - ( m_labelQueryMode == QueryMaker::NoConstraint - || ( m_labelQueryMode == QueryMaker::OnlyWithLabels && track->labels().count() > 0 ) - || ( m_labelQueryMode == QueryMaker::OnlyWithoutLabels && track->labels().count() == 0) ) ) - { - years.append( year ); - break; - } - } - } - - //this a special case which requires a bit of code duplication - //years have to be ordered as numbers, but orderListByNumber does not work for Meta::YearPtrs - if( m_orderByField == Meta::valYear ) - { - years = MemoryQueryMakerHelper::orderListByYear( years, m_orderDescending ); - } - - emitProperResult( years ); - break; - } - case QueryMaker::Label: - { - Meta::LabelList labels; - Meta::LabelList tmp = coll ? coll->labelMap().values() : Meta::LabelList(); - foreach( const Meta::LabelPtr &label, tmp ) - { - Meta::TrackList tracks = coll ? coll->labelToTrackMap().value( label ) : Meta::TrackList(); - foreach( const Meta::TrackPtr &track, tracks ) - { - if( ( m_albumQueryMode == QueryMaker::AllAlbums - || ( m_albumQueryMode == QueryMaker::OnlyCompilations && track->album()->isCompilation() ) - || ( m_albumQueryMode == QueryMaker::OnlyNormalAlbums && !track->album()->isCompilation()) ) && - ( m_labelQueryMode == QueryMaker::NoConstraint - || ( m_labelQueryMode == QueryMaker::OnlyWithLabels && track->labels().count() > 0 ) - || ( m_labelQueryMode == QueryMaker::OnlyWithoutLabels && track->labels().count() == 0) ) ) - { - labels.append( label ); - break; - } - } - } - - labels = MemoryQueryMakerHelper::orderListByName( labels, m_orderDescending ); - - emitProperResult( labels ); - break; - } - case QueryMaker::None : - //nothing to do - break; - } -} - -void -MemoryQueryMakerInternal::handleResult( const Meta::TrackList &tmpTracks ) -{ - Meta::TrackList tracks; - foreach( const Meta::TrackPtr &track, tmpTracks ) - { - if( ( m_albumQueryMode == QueryMaker::AllAlbums - || ( m_albumQueryMode == QueryMaker::OnlyCompilations && track->album()->isCompilation() ) - || ( m_albumQueryMode == QueryMaker::OnlyNormalAlbums && !track->album()->isCompilation()) ) && - ( m_labelQueryMode == QueryMaker::NoConstraint - || ( m_labelQueryMode == QueryMaker::OnlyWithLabels && track->labels().count() > 0 ) - || ( m_labelQueryMode == QueryMaker::OnlyWithoutLabels && track->labels().count() == 0) ) ) - { - tracks.append( track ); - } - } - - switch( m_type ) - { - case QueryMaker::Custom : - { - QStringList result; - if( !m_returnFunctions.empty() ) - { - //no sorting necessary - foreach( CustomReturnFunction *function, m_returnFunctions ) - { - result.append( function->value( tracks ) ); - } - } - else if( !m_returnValues.empty() ) - { - Meta::TrackList resultTracks = tracks; - if( m_orderByField ) - { - if( m_orderByNumberField ) - resultTracks = MemoryQueryMakerHelper::orderListByNumber( resultTracks, m_orderByField, m_orderDescending ); - else - resultTracks = MemoryQueryMakerHelper::orderListByString( resultTracks, m_orderByField, m_orderDescending ); - } - - int count = 0; - foreach( const Meta::TrackPtr &track, resultTracks ) - { - if ( m_maxSize >= 0 && count == m_maxSize ) - break; - - foreach( CustomReturnValue *value, m_returnValues ) - { - result.append( value->value( track ) ); - } - count++; - } - } - emit newResultReady( result ); - break; - } - case QueryMaker::Track : - { - Meta::TrackList newResult; - - if( m_orderByField ) - { - if( m_orderByNumberField ) - newResult = MemoryQueryMakerHelper::orderListByNumber( tracks, m_orderByField, m_orderDescending ); - else - newResult = MemoryQueryMakerHelper::orderListByString( tracks, m_orderByField, m_orderDescending ); - } - else - newResult = tracks; - - emitProperResult( newResult ); - break; - } - case QueryMaker::Album : - { - QSet albumSet; - foreach( Meta::TrackPtr track, tracks ) - { - albumSet.insert( track->album() ); - } - Meta::AlbumList albumList = albumSet.toList(); - albumList = MemoryQueryMakerHelper::orderListByName( albumList, m_orderDescending ); - emitProperResult( albumList ); - break; - } - case QueryMaker::Artist : - { - QSet artistSet; - foreach( Meta::TrackPtr track, tracks ) - { - artistSet.insert( track->artist() ); - } - Meta::ArtistList list = artistSet.toList(); - list = MemoryQueryMakerHelper::orderListByName( list, m_orderDescending ); - emitProperResult( list ); - break; - } - case QueryMaker::AlbumArtist : - { - QSet artistSet; - foreach( Meta::TrackPtr track, tracks ) - { - if( !track->album().isNull() && track->album()->hasAlbumArtist() ) - artistSet.insert( track->album()->albumArtist() ); - } - Meta::ArtistList list = artistSet.toList(); - list = MemoryQueryMakerHelper::orderListByName( list, m_orderDescending ); - emitProperResult( list ); - break; - } - case QueryMaker::Genre : - { - QSet genreSet; - foreach( Meta::TrackPtr track, tracks ) - { - genreSet.insert( track->genre() ); - } - Meta::GenreList list = genreSet.toList(); - list = MemoryQueryMakerHelper::orderListByName( list, m_orderDescending ); - emitProperResult( list ); - break; - } - case QueryMaker::Composer : - { - QSet composerSet; - foreach( Meta::TrackPtr track, tracks ) - { - composerSet.insert( track->composer() ); - } - Meta::ComposerList list = composerSet.toList(); - list = MemoryQueryMakerHelper::orderListByName( list, m_orderDescending ); - emitProperResult( list ); - break; - } - case QueryMaker::Year : - { - QSet yearSet; - foreach( Meta::TrackPtr track, tracks ) - { - yearSet.insert( track->year() ); - } - Meta::YearList years = yearSet.toList(); - if( m_orderByField == Meta::valYear ) - { - years = MemoryQueryMakerHelper::orderListByYear( years, m_orderDescending ); - } - - emitProperResult( years ); - break; - } - case QueryMaker::Label: - { - QSet labelSet; - foreach( const Meta::TrackPtr &track, tracks ) - { - labelSet.unite( track->labels().toSet() ); - } - Meta::LabelList labels = labelSet.toList(); - if( m_orderByField == Meta::valLabel ) - { - labels = MemoryQueryMakerHelper::orderListByName( labels, m_orderDescending ); - } - emitProperResult( labels ); - break; - } - case QueryMaker::None: - //should never happen, but handle error anyway - break; - } -} - -void -MemoryQueryMakerInternal::setMatchers( MemoryMatcher *matchers ) -{ - m_matchers = matchers; -} - -void -MemoryQueryMakerInternal::setFilters( MemoryFilter *filters ) -{ - m_filters = filters; -} - -void -MemoryQueryMakerInternal::setMaxSize( int maxSize ) -{ - m_maxSize = maxSize; -} - -void -MemoryQueryMakerInternal::setType( QueryMaker::QueryType type ) -{ - m_type = type; -} - -void -MemoryQueryMakerInternal::setCustomReturnFunctions( const QList &functions ) -{ - m_returnFunctions = functions; -} - -void -MemoryQueryMakerInternal::setCustomReturnValues( const QList &values ) -{ - m_returnValues = values; -} - -} //namespace Collections - -#include "moc_MemoryQueryMakerInternal.cpp" diff --git a/amarok/src/core-impl/collections/support/MemoryQueryMakerInternal.h b/amarok/src/core-impl/collections/support/MemoryQueryMakerInternal.h deleted file mode 100644 index 8fe1d31f..00000000 --- a/amarok/src/core-impl/collections/support/MemoryQueryMakerInternal.h +++ /dev/null @@ -1,112 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef MEMORYQUERYMAKERINTERNAL_H -#define MEMORYQUERYMAKERINTERNAL_H - -#include "core/collections/QueryMaker.h" -#include "core/meta/forward_declarations.h" - -#include -#include - -class CustomReturnFunction; -class CustomReturnValue; -class MemoryFilter; -class MemoryMatcher; - -namespace Collections { - -class MemoryCollection; - -/** - * A helper class for MemoryQueryMaker - * This class will run in a dedicated thread. It exists so the actual MemoryQueryMaker - * can be safely deleted in the original thread while the query is still running. - * All relevant information is passed from MemoryQueryMaker to MemoryQueryMakerInternal - * using the provided setter methods. - */ -class MemoryQueryMakerInternal : public QObject -{ - Q_OBJECT -public: - /** - * Creates a new MemoryQueryMakerInternal that will query collection. - * This class will run in a dedicated thread. It exists so the actual MemoryQueryMaker - * can be safely deleted in the original thread while the query is still running. - * @param guard a class that will be deleted before collection. It is used to - * ensure that MemoryQueryMakerInternal does not access a dangling MemoryCollection - * pointer. - * @param collection the MemoryCollection instance that the query should be run on. - */ - MemoryQueryMakerInternal( const QWeakPointer &collection ); - ~MemoryQueryMakerInternal(); - - - void runQuery(); - void handleResult(); - void handleResult( const Meta::TrackList &tracks ); - - void setMatchers( MemoryMatcher *matchers ); - void setFilters( MemoryFilter *filters ); - void setMaxSize( int maxSize ); - void setReturnAsDataPtrs( bool returnAsDataPtrs ); - void setType( QueryMaker::QueryType ); - void setCustomReturnFunctions( const QList &functions ); - void setCustomReturnValues( const QList &values ); - void setAlbumQueryMode( Collections::QueryMaker::AlbumQueryMode mode ) { m_albumQueryMode = mode; } - void setOrderDescending( bool orderDescending ) { m_orderDescending = orderDescending; } - void setOrderByNumberField( bool orderByNumberField ) { m_orderByNumberField = orderByNumberField; } - void setOrderByField( qint64 orderByField ) { m_orderByField = orderByField; } - void setCollectionId( const QString &collectionId ) { m_collectionId = collectionId; } - void setLabelQueryMode( Collections::QueryMaker::LabelQueryMode mode ) { m_labelQueryMode = mode; } - -signals: - void newResultReady( Meta::TrackList ); - void newResultReady( Meta::ArtistList ); - void newResultReady( Meta::AlbumList ); - void newResultReady( Meta::GenreList ); - void newResultReady( Meta::ComposerList ); - void newResultReady( Meta::YearList ); - void newResultReady( QStringList ); - void newResultReady( Meta::LabelList ); - void newResultReady( Meta::DataList ); - -private: - template - void emitProperResult( const QList &list ); - -private: - QWeakPointer m_collection; - QWeakPointer m_guard; - MemoryMatcher *m_matchers; - MemoryFilter *m_filters; - int m_maxSize; - bool m_returnAsDataPtrs; - Collections::QueryMaker::QueryType m_type; - Collections::QueryMaker::AlbumQueryMode m_albumQueryMode; - Collections::QueryMaker::LabelQueryMode m_labelQueryMode; - bool m_orderDescending; - bool m_orderByNumberField; - qint64 m_orderByField; - QString m_collectionId; - QList m_returnFunctions; - QList m_returnValues; -}; - -} //namespace Collections - -#endif diff --git a/amarok/src/core-impl/collections/support/TextualQueryFilter.cpp b/amarok/src/core-impl/collections/support/TextualQueryFilter.cpp deleted file mode 100644 index 9962d92e..00000000 --- a/amarok/src/core-impl/collections/support/TextualQueryFilter.cpp +++ /dev/null @@ -1,360 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Alexandre Pereira de Oliveira * - * Copyright (c) 2007-2009 Maximilian Kossick * - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * Copyright (c) 2011 Ralf Engels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "TextualQueryFilter" - -#include "TextualQueryFilter.h" -#include "Expression.h" - -#include "FileType.h" -#include "core/support/Debug.h" - -#include -#include - -using namespace Meta; - - -#define ADD_OR_EXCLUDE_FILTER( VALUE, FILTER, MATCHBEGIN, MATCHEND ) \ - { if( elem.negate ) \ - qm->excludeFilter( VALUE, FILTER, MATCHBEGIN, MATCHEND ); \ - else \ - qm->addFilter( VALUE, FILTER, MATCHBEGIN, MATCHEND ); } -#define ADD_OR_EXCLUDE_NUMBER_FILTER( VALUE, FILTER, COMPARE ) \ - { if( elem.negate ) \ - qm->excludeNumberFilter( VALUE, FILTER, COMPARE ); \ - else \ - qm->addNumberFilter( VALUE, FILTER, COMPARE ); } - -void -Collections::addTextualFilter( Collections::QueryMaker *qm, const QString &filter ) -{ - const int validFilters = qm->validFilterMask(); - - ParsedExpression parsed = ExpressionParser::parse( filter ); - foreach( const or_list &orList, parsed ) - { - qm->beginOr(); - - foreach( const expression_element &elem, orList ) - { - if( elem.negate ) - qm->beginAnd(); - else - qm->beginOr(); - - if ( elem.field.isEmpty() ) - { - qm->beginOr(); - - if( ( validFilters & Collections::QueryMaker::TitleFilter ) ) - ADD_OR_EXCLUDE_FILTER( Meta::valTitle, elem.text, false, false ); - if( ( validFilters & Collections::QueryMaker::UrlFilter ) ) - ADD_OR_EXCLUDE_FILTER( Meta::valUrl, elem.text, false, false ); - if( ( validFilters & Collections::QueryMaker::AlbumFilter ) ) - ADD_OR_EXCLUDE_FILTER( Meta::valAlbum, elem.text, false, false ); - if( ( validFilters & Collections::QueryMaker::ArtistFilter ) ) - ADD_OR_EXCLUDE_FILTER( Meta::valArtist, elem.text, false, false ); - if( ( validFilters & Collections::QueryMaker::AlbumArtistFilter ) ) - ADD_OR_EXCLUDE_FILTER( Meta::valAlbumArtist, elem.text, false, false ); - if( ( validFilters & Collections::QueryMaker::ComposerFilter ) ) - ADD_OR_EXCLUDE_FILTER( Meta::valComposer, elem.text, false, false ); - if( ( validFilters & Collections::QueryMaker::GenreFilter ) ) - ADD_OR_EXCLUDE_FILTER( Meta::valGenre, elem.text, false, false ); - if( ( validFilters & Collections::QueryMaker::YearFilter ) ) - ADD_OR_EXCLUDE_FILTER( Meta::valYear, elem.text, false, false ); - - ADD_OR_EXCLUDE_FILTER( Meta::valLabel, elem.text, false, false ); - - qm->endAndOr(); - } - else - { - //get field values based on name - const qint64 field = Meta::fieldForName( elem.field ); - Collections::QueryMaker::NumberComparison compare = Collections::QueryMaker::Equals; - switch( elem.match ) - { - case expression_element::More: - compare = Collections::QueryMaker::GreaterThan; - break; - case expression_element::Less: - compare = Collections::QueryMaker::LessThan; - break; - case expression_element::Equals: - case expression_element::Contains: - compare = Collections::QueryMaker::Equals; - break; - } - - const bool matchEqual = ( elem.match == expression_element::Equals ); - - switch( field ) - { - case Meta::valAlbum: - if( ( validFilters & Collections::QueryMaker::AlbumFilter ) == 0 ) break; - ADD_OR_EXCLUDE_FILTER( field, elem.text, matchEqual, matchEqual ); - break; - case Meta::valArtist: - if( ( validFilters & Collections::QueryMaker::ArtistFilter ) == 0 ) break; - ADD_OR_EXCLUDE_FILTER( field, elem.text, matchEqual, matchEqual ); - break; - case Meta::valAlbumArtist: - if( ( validFilters & Collections::QueryMaker::AlbumArtistFilter ) == 0 ) break; - ADD_OR_EXCLUDE_FILTER( field, elem.text, matchEqual, matchEqual ); - break; - case Meta::valGenre: - if( ( validFilters & Collections::QueryMaker::GenreFilter ) == 0 ) break; - ADD_OR_EXCLUDE_FILTER( field, elem.text, matchEqual, matchEqual ); - break; - case Meta::valTitle: - if( ( validFilters & Collections::QueryMaker::TitleFilter ) == 0 ) break; - ADD_OR_EXCLUDE_FILTER( field, elem.text, matchEqual, matchEqual ); - break; - case Meta::valComposer: - if( ( validFilters & Collections::QueryMaker::ComposerFilter ) == 0 ) break; - ADD_OR_EXCLUDE_FILTER( field, elem.text, matchEqual, matchEqual ); - break; - case Meta::valYear: - if( ( validFilters & Collections::QueryMaker::YearFilter ) == 0 ) break; - ADD_OR_EXCLUDE_NUMBER_FILTER( field, elem.text.toInt(), compare ); - break; - case Meta::valLabel: - case Meta::valComment: - ADD_OR_EXCLUDE_FILTER( field, elem.text, matchEqual, matchEqual ); - break; - case Meta::valUrl: - ADD_OR_EXCLUDE_FILTER( field, elem.text, false, false ); - break; - case Meta::valBpm: - case Meta::valBitrate: - case Meta::valScore: - case Meta::valPlaycount: - case Meta::valSamplerate: - case Meta::valDiscNr: - case Meta::valTrackNr: - ADD_OR_EXCLUDE_NUMBER_FILTER( field, elem.text.toInt(), compare ); - break; - case Meta::valRating: - ADD_OR_EXCLUDE_NUMBER_FILTER( field, elem.text.toFloat() * 2, compare ); - break; - case Meta::valLength: - ADD_OR_EXCLUDE_NUMBER_FILTER( field, elem.text.toInt() * 1000, compare ); - break; - case Meta::valLastPlayed: - case Meta::valFirstPlayed: - case Meta::valCreateDate: - case Meta::valModified: - addDateFilter( field, compare, elem.negate, elem.text, qm ); - break; - case Meta::valFilesize: - { - bool doubleOk( false ); - const double mbytes = elem.text.toDouble( &doubleOk ); // input in MBs - if( !doubleOk ) - { - qm->endAndOr(); - return; - } - /* - * A special case is made for Equals (e.g. filesize:100), which actually filters - * for anything beween 100 and 101MBs. Megabytes are used because for audio files - * they are the most reasonable units for the user to deal with. - */ - const qreal bytes = mbytes * 1024.0 * 1024.0; - const qint64 mbFloor = qint64( qAbs(mbytes) ); - switch( compare ) - { - case Collections::QueryMaker::Equals: - qm->endAndOr(); - qm->beginAnd(); - ADD_OR_EXCLUDE_NUMBER_FILTER( field, mbFloor * 1024 * 1024, Collections::QueryMaker::GreaterThan ); - ADD_OR_EXCLUDE_NUMBER_FILTER( field, (mbFloor + 1) * 1024 * 1024, Collections::QueryMaker::LessThan ); - break; - case Collections::QueryMaker::GreaterThan: - case Collections::QueryMaker::LessThan: - ADD_OR_EXCLUDE_NUMBER_FILTER( field, bytes, compare ); - break; - } - break; - } - case Meta::valFormat: - { - const QString &ftStr = elem.text; - Amarok::FileType ft = Amarok::FileTypeSupport::fileType(ftStr); - ADD_OR_EXCLUDE_NUMBER_FILTER( field, int(ft), compare ); - break; - } - } - } - qm->endAndOr(); - } - qm->endAndOr(); - } -} - -void -Collections::addDateFilter( qint64 field, Collections::QueryMaker::NumberComparison compare, - bool negate, const QString &text, Collections::QueryMaker *qm ) -{ - bool absolute = false; - const uint date = semanticDateTimeParser( text, &absolute ).toTime_t(); - if( date == 0 ) - return; - - if( compare == Collections::QueryMaker::Equals ) - { - // equal means, on the same day - uint day = 24 * 60 * 60; - - qm->endAndOr(); - qm->beginAnd(); - - if( negate ) - { - qm->excludeNumberFilter( field, date - day, Collections::QueryMaker::GreaterThan ); - qm->excludeNumberFilter( field, date + day, Collections::QueryMaker::LessThan ); - } - else - { - qm->addNumberFilter( field, date - day, Collections::QueryMaker::GreaterThan ); - qm->addNumberFilter( field, date + day, Collections::QueryMaker::LessThan ); - } - } - // note: if the date is a relative time difference, invert the condition - else if( ( compare == Collections::QueryMaker::LessThan && !absolute ) || ( compare == Collections::QueryMaker::GreaterThan && absolute ) ) - { - if( negate ) - qm->excludeNumberFilter( field, date, Collections::QueryMaker::GreaterThan ); - else - qm->addNumberFilter( field, date, Collections::QueryMaker::GreaterThan ); - } - else if( ( compare == Collections::QueryMaker::GreaterThan && !absolute ) || ( compare == Collections::QueryMaker::LessThan && absolute ) ) - { - if( negate ) - qm->excludeNumberFilter( field, date, Collections::QueryMaker::LessThan ); - else - qm->addNumberFilter( field, date, Collections::QueryMaker::LessThan ); - } -} - -QDateTime -Collections::semanticDateTimeParser( const QString &text, bool *absolute ) -{ - /* TODO: semanticDateTimeParser: has potential to extend and form a class of its own */ - // some code duplications, see EditFilterDialog::parseTextFilter - - const QString lowerText = text.toLower(); - const QDateTime curTime = QDateTime::currentDateTime(); - QDateTime result; - - if( absolute ) - *absolute = false; - - // parse date using local settings - KLocalizedDate localizedDate = KLocalizedDate::readDate( text, KLocale::ShortFormat ); - - // parse date using a backup standard independent from local settings - QRegExp shortDateReg("(\\d{1,2})[-.](\\d{1,2})"); - QRegExp longDateReg("(\\d{1,2})[-.](\\d{1,2})[-.](\\d{4})"); - - if( text.at(0).isLetter() ) - { - if( ( lowerText.compare( "today" ) == 0 ) || ( lowerText.compare( i18n( "today" ) ) == 0 ) ) - result = curTime.addDays( -1 ); - else if( ( lowerText.compare( "last week" ) == 0 ) || ( lowerText.compare( i18n( "last week" ) ) == 0 ) ) - result = curTime.addDays( -7 ); - else if( ( lowerText.compare( "last month" ) == 0 ) || ( lowerText.compare( i18n( "last month" ) ) == 0 ) ) - result = curTime.addMonths( -1 ); - else if( ( lowerText.compare( "two months ago" ) == 0 ) || ( lowerText.compare( i18n( "two months ago" ) ) == 0 ) ) - result = curTime.addMonths( -2 ); - else if( ( lowerText.compare( "three months ago" ) == 0 ) || ( lowerText.compare( i18n( "three months ago" ) ) == 0 ) ) - result = curTime.addMonths( -3 ); - } - else if( localizedDate.isValid() ) - { - result = QDateTime( localizedDate.date() ); - if( absolute ) - *absolute = true; - } - else if( text.contains(shortDateReg) ) - { - result = QDateTime( QDate( QDate::currentDate().year(), shortDateReg.cap(2).toInt(), shortDateReg.cap(1).toInt() ) ); - if( absolute ) - *absolute = true; - } - else if( text.contains(longDateReg) ) - { - result = QDateTime( QDate( longDateReg.cap(3).toInt(), longDateReg.cap(2).toInt(), longDateReg.cap(1).toInt() ) ); - if( absolute ) - *absolute = true; - } - else // first character is a number - { - // parse a "#m#d" (discoverability == 0, but without a GUI, how to do it?) - int years = 0, months = 0, days = 0, secs = 0; - QString tmp; - for( int i = 0; i < text.length(); i++ ) - { - QChar c = text.at( i ); - if( c.isNumber() ) - { - tmp += c; - } - else if( c == 'y' ) - { - years += -tmp.toInt(); - tmp.clear(); - } - else if( c == 'm' ) - { - months += -tmp.toInt(); - tmp.clear(); - } - else if( c == 'w' ) - { - days += -tmp.toInt() * 7; - tmp.clear(); - } - else if( c == 'd' ) - { - days += -tmp.toInt(); - tmp.clear(); - } - else if( c == 'h' ) - { - secs += -tmp.toInt() * 60 * 60; - tmp.clear(); - } - else if( c == 'M' ) - { - secs += -tmp.toInt() * 60; - tmp.clear(); - } - else if( c == 's' ) - { - secs += -tmp.toInt(); - tmp.clear(); - } - } - result = QDateTime::currentDateTime().addYears( years ).addMonths( months ).addDays( days ).addSecs( secs ); - } - return result; -} - diff --git a/amarok/src/core-impl/collections/support/TextualQueryFilter.h b/amarok/src/core-impl/collections/support/TextualQueryFilter.h deleted file mode 100644 index 1c3bd35d..00000000 --- a/amarok/src/core-impl/collections/support/TextualQueryFilter.h +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Alexandre Pereira de Oliveira * - * Copyright (c) 2007-2009 Maximilian Kossick * - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * Copyright (c) 2011 Ralf Engels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef TEXTUALQUERYFILTER_H -#define TEXTUALQUERYFILTER_H - -#include "amarok_export.h" - -#include "browsers/CollectionTreeItem.h" -#include "core/meta/forward_declarations.h" -#include "core/collections/QueryMaker.h" - -#include -#include - -namespace Collections -{ - /** Adds a conditions to the query maker specified in the filter. - This is the engine behind the search field. - */ - void addTextualFilter( Collections::QueryMaker *qm, const QString &filter ); - - void addDateFilter( qint64 field, Collections::QueryMaker::NumberComparison compare, - bool negate, const QString &text, Collections::QueryMaker *qm ); - - /** Returns a QDateTime from a text. - e.g. converts "today" to the current date. - - */ - QDateTime semanticDateTimeParser( const QString &text, bool *absolute = 0 ); - -} - -#endif diff --git a/amarok/src/core-impl/collections/support/TrashCollectionLocation.cpp b/amarok/src/core-impl/collections/support/TrashCollectionLocation.cpp deleted file mode 100644 index 4e6730a3..00000000 --- a/amarok/src/core-impl/collections/support/TrashCollectionLocation.cpp +++ /dev/null @@ -1,140 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Rick W. Chen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "TrashCollectionLocation" - -#include "TrashCollectionLocation.h" - -#include "core/collections/CollectionLocationDelegate.h" -#include "core/interfaces/Logger.h" -#include "core/support/Components.h" -#include "core/support/Debug.h" - - -#include -#include - -#include - -namespace Collections { - -TrashCollectionLocation::TrashCollectionLocation() - : CollectionLocation() - , m_trashConfirmed( false ) -{ -} - -TrashCollectionLocation::~TrashCollectionLocation() -{ -} - -QString -TrashCollectionLocation::prettyLocation() const -{ - return i18n( "Trash" ); -} - -bool -TrashCollectionLocation::isWritable() const -{ - return true; -} - -void -TrashCollectionLocation::copyUrlsToCollection( const QMap &sources, - const Transcoding::Configuration &configuration ) -{ - DEBUG_BLOCK - Q_UNUSED( configuration ); - - if( sources.isEmpty() ) - { - debug() << "Error: sources is empty"; - abort(); - return; - } - - if( m_trashConfirmed ) - { - KUrl::List files = sources.values(); - foreach( const KUrl &file, files ) - { - if( !QFile::exists( file.toLocalFile() ) ) - { - debug() << "Error: file does not exist!" << file.toLocalFile(); - abort(); - return; - } - } - - KIO::CopyJob *job = KIO::trash( files, KIO::HideProgressInfo ); - connect( job, SIGNAL(result(KJob*)), SLOT(slotTrashJobFinished(KJob*)) ); - - Meta::TrackList tracks = sources.keys(); - m_trashJobs.insert( job, tracks ); - QString name = tracks.takeFirst()->prettyName(); - if( !tracks.isEmpty() ) - { - int max = 3; - while( !tracks.isEmpty() && (max > 0) ) - { - name += QString( ", %1" ).arg( tracks.takeFirst()->prettyName() ); - --max; - } - - if( max == 0 && !tracks.isEmpty() ) - name += " ..."; - } - Amarok::Components::logger()->newProgressOperation( job, i18n( "Moving to trash: %1", name ) ); - } -} - -void -TrashCollectionLocation::showDestinationDialog( const Meta::TrackList &tracks, bool removeSources, const Transcoding::Configuration &configuration ) -{ - Collections::CollectionLocationDelegate *delegate = Amarok::Components::collectionLocationDelegate(); - m_trashConfirmed = delegate->reallyTrash( source(), tracks ); - if( !m_trashConfirmed ) - abort(); - else - CollectionLocation::showDestinationDialog( tracks, removeSources, configuration ); -} - -void -TrashCollectionLocation::slotTrashJobFinished( KJob *job ) -{ - DEBUG_BLOCK - if( job->error() ) - { - warning() << "An error occurred when moving a file to trash: " << job->errorString(); - foreach( Meta::TrackPtr track, m_trashJobs.value( job ) ) - source()->transferError( track, KIO::buildErrorString( job->error(), job->errorString() ) ); - } - else - { - foreach( Meta::TrackPtr track, m_trashJobs.value( job ) ) - source()->transferSuccessful( track ); - } - - m_trashJobs.remove( job ); - job->deleteLater(); - if( m_trashJobs.isEmpty() ) - slotCopyOperationFinished(); -} - -#include "moc_TrashCollectionLocation.cpp" - -} //namespace Collections diff --git a/amarok/src/core-impl/collections/support/TrashCollectionLocation.h b/amarok/src/core-impl/collections/support/TrashCollectionLocation.h deleted file mode 100644 index 239a9778..00000000 --- a/amarok/src/core-impl/collections/support/TrashCollectionLocation.h +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Rick W. Chen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef TRASHCOLLECTIONLOCATION_H -#define TRASHCOLLECTIONLOCATION_H - -#include "core/collections/CollectionLocation.h" - -class KJob; - -namespace Collections { - -/** - * Utility class that allows moving tracks to the KIO trash using standard - * CollectionLocation API. It is not intented to be a collection, but more - * as a black hole destination. - */ -class TrashCollectionLocation : public CollectionLocation -{ - Q_OBJECT - -public: - TrashCollectionLocation(); - ~TrashCollectionLocation(); - - QString prettyLocation() const; - bool isWritable() const; - -protected: - void copyUrlsToCollection( const QMap &sources, - const Transcoding::Configuration &configuration ); - void showDestinationDialog( const Meta::TrackList &tracks, bool removeSources, - const Transcoding::Configuration &configuration ); - -private slots: - void slotTrashJobFinished( KJob *job ); - -private: - bool m_trashConfirmed; - QHash m_trashJobs; -}; - -} //namespace Collections - -#endif // TRASHCOLLECTIONLOCATION_H diff --git a/amarok/src/core-impl/collections/support/XmlQueryReader.cpp b/amarok/src/core-impl/collections/support/XmlQueryReader.cpp deleted file mode 100644 index af1b3fbd..00000000 --- a/amarok/src/core-impl/collections/support/XmlQueryReader.cpp +++ /dev/null @@ -1,324 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007-2008 Maximilian Kossick * - * Copyright (c) 2008 Daniel Caleb Jones * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "XmlQueryReader.h" - -#include "core/support/Debug.h" -#include "core-impl/collections/support/CollectionManager.h" - -#include - -struct XmlQueryReader::Private -{ - ReturnValueEnum flag; - Collections::QueryMaker *qm; - QList filters; -}; - -Collections::QueryMaker* -XmlQueryReader::getQueryMaker( const QString &xmlData, ReturnValueEnum flag ) -{ - Collections::QueryMaker *qm = CollectionManager::instance()->queryMaker(); - XmlQueryReader reader( qm, flag ); - if( reader.read( xmlData ) ) - return qm; - else - return 0; -} - -XmlQueryReader::XmlQueryReader( Collections::QueryMaker *qm, ReturnValueEnum flag ) - : QXmlStreamReader() - , d( new Private ) -{ - d->flag = flag; - d->qm = qm; -} - -XmlQueryReader::~XmlQueryReader() -{ - delete d; -} - -const QList& -XmlQueryReader::getFilters() const -{ - return d->filters; -} - -bool -XmlQueryReader::read( const QString &xmlData ) -{ - addData( xmlData ); - int queryCount = 0; - while( !atEnd() ) - { - readNext(); - - if( isStartElement() ) - { - //we expect exactly one query definition in the xml data. - //so fail if we find more than one - if( name() == "query" ) - { - if( attributes().value( "version" ) == "1.0" ) - { - queryCount++; - readQuery(); - } - } - } - } - - return queryCount == 1 && !error(); -} - -void -XmlQueryReader::readQuery() -{ - while( !atEnd() ) - { - readNext(); - - if( isStartElement() ) - { - if( name() == "filters" ) - readFilters(); - else if( name() == "order" ) - { - QXmlStreamAttributes attr = attributes(); - QStringRef fieldStr = attr.value( "field" ); - QStringRef valueStr = attr.value( "value" ); - - qint64 field = Meta::fieldForName( fieldStr.toString() ); - bool descending = valueStr == "descending"; - - if( field != 0 ) - d->qm->orderBy( field, descending ); - } - else if( name() == "limit" ) - { - QStringRef value = attributes().value( "value" ); - if( !value.isEmpty() ) - d->qm->limitMaxResultSize( value.toString().toInt() ); - } - else if( name() == "onlyCompilations" ) - { - d->qm->setAlbumQueryMode( Collections::QueryMaker::OnlyCompilations ); - } - else if( name() == "onlyNormalAlbums" ) - { - d->qm->setAlbumQueryMode( Collections::QueryMaker::OnlyNormalAlbums ); - } - else if( name() == "returnValues" ) - readReturnValues(); - //add more container elements here - else - ignoreElements(); - } - } -} - -void -XmlQueryReader::ignoreElements() -{ - //let QXmlStreamReader worry about the fell-formedness of the document - int depth = 1; - while( !atEnd() && depth > 0 ) - { - readNext(); - if( isEndElement() ) - depth--; - if( isStartElement() ) - depth++; - } -} - -void -XmlQueryReader::readReturnValues() -{ - if( d->flag & XmlQueryReader::IgnoreReturnValues ) - { - ignoreElements(); - return; - } - else - { - bool customQueryStarted = false; - while( !atEnd() ) - { - readNext(); - if( name() == "tracks" ) - { - d->qm->setQueryType( Collections::QueryMaker::Track ); - } - else if( name() == "artists" ) - { - d->qm->setQueryType( Collections::QueryMaker::Artist ); - } - else if( name() == "albums" ) - { - d->qm->setQueryType( Collections::QueryMaker::Album ); - } - else if( name() == "albumartist" ) - { - d->qm->setQueryType( Collections::QueryMaker::AlbumArtist ); - } - else if( name() == "genres" ) - { - d->qm->setQueryType( Collections::QueryMaker::Genre ); - } - else if( name() == "composers" ) - { - d->qm->setQueryType( Collections::QueryMaker::Composer ); - } - else if( name() == "year" ) - { - d->qm->setQueryType( Collections::QueryMaker::Year ); - } - else - { - if( !customQueryStarted ) - { - d->qm->setQueryType( Collections::QueryMaker::Custom ); - } - //TODO write a mapping function somewhere - if( name() == "title" ) - { - d->qm->addReturnValue( Meta::valTitle ); - } - else if( name() == "artist" ) - { - d->qm->addReturnValue( Meta::valArtist ); - } - } - } - } -} - -void -XmlQueryReader::readAndOr() -{ - readFilters(); - ignoreElements(); - d->qm->endAndOr(); -} - -XmlQueryReader::Filter -XmlQueryReader::readFilter(QXmlStreamReader *reader) -{ - Filter filter; - - QXmlStreamAttributes attr = reader->attributes(); - - filter.exclude = (reader->name() != "include"); - filter.field = Meta::fieldForName( attr.value( "field" ).toString() ); - filter.value = attr.value( "value" ).toString(); - - QStringRef compareStr = attr.value( "compare" ); - if( compareStr.isEmpty() ) - filter.compare = -1; - else - filter.compare = compareVal( compareStr ); - - return filter; -} - -void -XmlQueryReader::readFilters() -{ - while( !atEnd() ) - { - readNext(); - if( isEndElement() ) - { - if( name() == "and" || name() == "or" ) - { - d->qm->endAndOr(); - break; - } - else if( name() == "filters" ) - { - break; - } - else - continue; - } - - if( name() == "include" || name() == "exclude" ) - { - Filter filter = readFilter(this); - - if( filter.field == 0 ) - break; - - if( filter.compare != -1 ) - { - qint64 numValue = filter.value.toInt(); - if( !filter.exclude ) - { - debug() << "XQR: number include filter:"; - d->qm->addNumberFilter( filter.field, numValue, - (Collections::QueryMaker::NumberComparison)filter.compare ); - } - else - { - debug() << "XQR: number exclude filter: "; - d->qm->excludeNumberFilter( filter.field, numValue, - (Collections::QueryMaker::NumberComparison)filter.compare ); - } - } - else - { - if( !filter.exclude ) - { - debug() << "XQR: include filter"; - d->qm->addFilter( filter.field, filter.value ); - } - else - { - debug() << "XQR: exclude filter"; - d->qm->excludeFilter( filter.field, filter.value ); - } - } - - d->filters.append( filter ); - } - else if( name() == "and" ) - { - d->qm->beginAnd(); - readFilters(); - } - else if( name() == "or" ) - { - d->qm->beginOr(); - readFilters(); - } - } -} - -int -XmlQueryReader::compareVal( QStringRef compare ) -{ - if( compare == "less" ) - return Collections::QueryMaker::LessThan; - else if( compare == "greater" ) - return Collections::QueryMaker::GreaterThan; - else if( compare == "equals" ) - return Collections::QueryMaker::Equals; - else - return -1; -} diff --git a/amarok/src/core-impl/collections/support/XmlQueryReader.h b/amarok/src/core-impl/collections/support/XmlQueryReader.h deleted file mode 100644 index c884da76..00000000 --- a/amarok/src/core-impl/collections/support/XmlQueryReader.h +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007-2008 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_XMLQUERYREADER_H -#define AMAROK_XMLQUERYREADER_H - -#include "core/collections/QueryMaker.h" - -#include -#include - -namespace Collections { - class QueryMaker; -} - -class XmlQueryReader : public QXmlStreamReader -{ -public: - - enum ReturnValueEnum { IgnoreReturnValues = 0 - , ParseReturnValues - }; - - static Collections::QueryMaker* getQueryMaker( const QString &xmlData, ReturnValueEnum flag ); - - XmlQueryReader( Collections::QueryMaker *qm, ReturnValueEnum flag ); - virtual ~XmlQueryReader(); - - bool read( const QString &xmlData ); - - struct Filter - { - Filter() : exclude(false), field(0), compare(-1) {} - - bool exclude; - qint64 field; - QString value; - int compare; /* -1 => not a numerical comparison */ - }; - - const QList& getFilters() const; - - /** - * Reads only one filter element. - */ - static Filter readFilter(QXmlStreamReader *reader); - - static int compareVal( QStringRef compare ); - -private: - void readQuery(); - void readFilters(); - void readReturnValues(); - void ignoreElements(); - void readAndOr(); - - struct Private; - Private * const d; -}; - -#endif diff --git a/amarok/src/core-impl/collections/support/jobs/WriteTagsJob.cpp b/amarok/src/core-impl/collections/support/jobs/WriteTagsJob.cpp deleted file mode 100644 index 6a26ad9a..00000000 --- a/amarok/src/core-impl/collections/support/jobs/WriteTagsJob.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "WriteTagsJob.h" - -#include "amarokconfig.h" -#include "MetaTagLib.h" - -#include - -WriteTagsJob::WriteTagsJob( const QString &path, const Meta::FieldHash &changes, bool respectConfig ) - : Job() - , m_path( path ) - , m_changes( changes ) - , m_respectConfig( respectConfig ) -{ -} - -void WriteTagsJob::run() -{ - if( !AmarokConfig::writeBack() && m_respectConfig ) - return; - - Meta::Tag::writeTags( m_path, m_changes, AmarokConfig::writeBackStatistics() ); - - if( m_changes.contains( Meta::valImage ) && ( AmarokConfig::writeBackCover() || !m_respectConfig ) ) - Meta::Tag::setEmbeddedCover( m_path, m_changes.value( Meta::valImage ).value() ); -} - -#include "moc_WriteTagsJob.cpp" diff --git a/amarok/src/core-impl/collections/support/jobs/WriteTagsJob.h b/amarok/src/core-impl/collections/support/jobs/WriteTagsJob.h deleted file mode 100644 index e27d440c..00000000 --- a/amarok/src/core-impl/collections/support/jobs/WriteTagsJob.h +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef WRITETAGSJOB_H -#define WRITETAGSJOB_H - -#include "amarok_export.h" -#include "MetaValues.h" - -#include - -/** - * Calls Meta::Tag::writeTags( path, changedFields ) in a thread so that main thread - * is not blocked with IO. writeTags() respects AmarokConfig::writeBackStatistics, - * AmarokConfig::writeBack(). - * - * If @param changes contains Meta::valImage, writes back image too, respecting - * AmarokConfig::writeBackCover(). - * - * The caller is responsible to delete this job after use, perhaps by connecting its - * done() signal to its deleteLater() slot. - */ -class AMAROK_EXPORT WriteTagsJob : public ThreadWeaver::Job -{ - Q_OBJECT - - public: - WriteTagsJob( const QString &path, const Meta::FieldHash &changes, bool respectConfig = true ); - virtual void run(); - - private: - const QString m_path; - const Meta::FieldHash m_changes; - const bool m_respectConfig; -}; - -#endif // WRITETAGSJOB_H diff --git a/amarok/src/core-impl/collections/umscollection/CMakeLists.txt b/amarok/src/core-impl/collections/umscollection/CMakeLists.txt deleted file mode 100644 index b3051573..00000000 --- a/amarok/src/core-impl/collections/umscollection/CMakeLists.txt +++ /dev/null @@ -1,47 +0,0 @@ -include_directories( ../.. - ../../collections - podcasts - ${CMAKE_BINARY_DIR}/src - ${AMAROK_COLLECTION_SUPPORT_DIR} - ${KDE4_INCLUDE_DIR} - ${QT_INCLUDES} - ) - -########### next target ################ - -set(amarok_collection-umscollection_PART_SRCS - UmsCollection.cpp - UmsCollectionLocation.cpp - UmsTranscodeCapability.cpp - podcasts/UmsPodcastProvider.cpp - podcasts/UmsPodcastMeta.cpp - UmsConfiguration.ui -) - -kde4_add_plugin(amarok_collection-umscollection ${amarok_collection-umscollection_PART_SRCS}) - -target_link_libraries(amarok_collection-umscollection - amarokshared - amaroklib - amarokcore - amarok-transcoding - ${KDE4_KDECORE_LIBS} - ${KDE4_KIO_LIBS} - ${KDE4_KDEUI_LIBS} - ${KDE4_SOLID_LIBRARY} - ${KDE4_THREADWEAVER_LIBS} - ${QT_QTGUI_LIBRARY} - ) - -install(TARGETS - amarok_collection-umscollection - DESTINATION - ${PLUGIN_INSTALL_DIR} ) - -########### install files ############### - -install(FILES - amarok_collection-umscollection.desktop - DESTINATION - ${SERVICES_INSTALL_DIR}) - diff --git a/amarok/src/core-impl/collections/umscollection/UmsCollection.cpp b/amarok/src/core-impl/collections/umscollection/UmsCollection.cpp deleted file mode 100644 index 70e57b84..00000000 --- a/amarok/src/core-impl/collections/umscollection/UmsCollection.cpp +++ /dev/null @@ -1,744 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2011 Bart Cerneels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "UmsCollection" - -#include "UmsCollection.h" - -#include "amarokconfig.h" -#include "ui_UmsConfiguration.h" -#include "collectionscanner/Track.h" -#include "core/capabilities/ActionsCapability.h" -#include "core/interfaces/Logger.h" -#include "core/meta/Meta.h" -#include "core/support/Components.h" -#include "core/support/Debug.h" -#include "core-impl/collections/support/MemoryQueryMaker.h" -#include "core-impl/collections/support/MemoryMeta.h" -#include "core-impl/collections/umscollection/UmsCollectionLocation.h" -#include "core-impl/collections/umscollection/UmsTranscodeCapability.h" -#include "core-impl/meta/file/File.h" -#include "dialogs/OrganizeCollectionDialog.h" -#include "dialogs/TrackOrganizer.h" //TODO: move to core/utils -#include "scanner/GenericScanManager.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include - -AMAROK_EXPORT_COLLECTION( UmsCollectionFactory, umscollection ) - -UmsCollectionFactory::UmsCollectionFactory( QObject *parent, const QVariantList &args ) - : CollectionFactory( parent, args ) -{ - m_info = KPluginInfo( "amarok_collection-umscollection.desktop", "services" ); -} - -UmsCollectionFactory::~UmsCollectionFactory() -{ -} - -void -UmsCollectionFactory::init() -{ - connect( Solid::DeviceNotifier::instance(), SIGNAL(deviceAdded(QString)), - SLOT(slotAddSolidDevice(QString)) ); - connect( Solid::DeviceNotifier::instance(), SIGNAL(deviceRemoved(QString)), - SLOT(slotRemoveSolidDevice(QString)) ); - - // detect UMS devices that were already connected on startup - QString query( "IS StorageAccess" ); - QList devices = Solid::Device::listFromQuery( query ); - foreach( const Solid::Device &device, devices ) - { - if( identifySolidDevice( device.udi() ) ) - createCollectionForSolidDevice( device.udi() ); - } - m_initialized = true; -} - -void -UmsCollectionFactory::slotAddSolidDevice( const QString &udi ) -{ - if( m_collectionMap.contains( udi ) ) - return; // a device added twice (?) - - if( identifySolidDevice( udi ) ) - createCollectionForSolidDevice( udi ); -} - -void -UmsCollectionFactory::slotAccessibilityChanged( bool accessible, const QString &udi ) -{ - if( accessible ) - slotAddSolidDevice( udi ); - else - slotRemoveSolidDevice( udi ); -} - -void -UmsCollectionFactory::slotRemoveSolidDevice( const QString &udi ) -{ - UmsCollection *collection = m_collectionMap.take( udi ); - if( collection ) - collection->slotDestroy(); -} - -void -UmsCollectionFactory::slotRemoveAndTeardownSolidDevice( const QString &udi ) -{ - UmsCollection *collection = m_collectionMap.take( udi ); - if( collection ) - collection->slotEject(); -} - -void -UmsCollectionFactory::slotCollectionDestroyed( QObject *collection ) -{ - // remove destroyed collection from m_collectionMap - QMutableMapIterator it( m_collectionMap ); - while( it.hasNext() ) - { - it.next(); - if( (QObject *) it.value() == collection ) - it.remove(); - } -} - -bool -UmsCollectionFactory::identifySolidDevice( const QString &udi ) const -{ - Solid::Device device( udi ); - if( !device.is() ) - return false; - // HACK to exlude iPods until UMS and iPod have common collection factory - if( device.vendor().contains( "Apple", Qt::CaseInsensitive ) ) - return false; - - // everything okay, check whether the device is a data CD - if( device.is() ) - { - const Solid::OpticalDisc *disc = device.as(); - if( disc && ( disc->availableContent() & Solid::OpticalDisc::Data ) ) - return true; - return false; - } - - // check whether there is parent USB StorageDrive device - while( device.isValid() ) - { - if( device.is() ) - { - Solid::StorageDrive *sd = device.as(); - if( sd->driveType() == Solid::StorageDrive::CdromDrive ) - return false; - // USB Flash discs are usually hotpluggable, SD/MMC card slots are usually removable - return sd->isHotpluggable() || sd->isRemovable(); - } - device = device.parent(); - } - return false; // no valid parent USB StorageDrive -} - -void -UmsCollectionFactory::createCollectionForSolidDevice( const QString &udi ) -{ - DEBUG_BLOCK - Solid::Device device( udi ); - Solid::StorageAccess *ssa = device.as(); - if( !ssa ) - { - warning() << __PRETTY_FUNCTION__ << "called for non-StorageAccess device!?!"; - return; - } - if( ssa->isIgnored() ) - { - debug() << "device" << udi << "ignored, ignoring :-)"; - return; - } - - // we are definitely interested in this device, listen for accessibility changes - disconnect( ssa, SIGNAL(accessibilityChanged(bool,QString)), this, 0 ); - connect( ssa, SIGNAL(accessibilityChanged(bool,QString)), - SLOT(slotAccessibilityChanged(bool,QString)) ); - - if( !ssa->isAccessible() ) - { - debug() << "device" << udi << "not accessible, ignoring for now"; - return; - } - - UmsCollection *collection = new UmsCollection( device ); - m_collectionMap.insert( udi, collection ); - - // when the collection is destroyed by someone else, remove it from m_collectionMap: - connect( collection, SIGNAL(destroyed(QObject*)), SLOT(slotCollectionDestroyed(QObject*)) ); - - // try to gracefully destroy collection when unmounting is requested using - // external means: (Device notifier plasmoid etc.). Because the original action could - // fail if we hold some files on the device open, we try to tearDown the device too. - connect( ssa, SIGNAL(teardownRequested(QString)), SLOT(slotRemoveAndTeardownSolidDevice(QString)) ); - - emit newCollection( collection ); -} - -//UmsCollection - -QString UmsCollection::s_settingsFileName( ".is_audio_player" ); -QString UmsCollection::s_musicFolderKey( "audio_folder" ); -QString UmsCollection::s_musicFilenameSchemeKey( "music_filenamescheme" ); -QString UmsCollection::s_vfatSafeKey( "vfat_safe" ); -QString UmsCollection::s_asciiOnlyKey( "ascii_only" ); -QString UmsCollection::s_postfixTheKey( "ignore_the" ); -QString UmsCollection::s_replaceSpacesKey( "replace_spaces" ); -QString UmsCollection::s_regexTextKey( "regex_text" ); -QString UmsCollection::s_replaceTextKey( "replace_text" ); -QString UmsCollection::s_podcastFolderKey( "podcast_folder" ); -QString UmsCollection::s_autoConnectKey( "use_automatically" ); -QString UmsCollection::s_collectionName( "collection_name" ); -QString UmsCollection::s_transcodingGroup( "transcoding" ); - -UmsCollection::UmsCollection( Solid::Device device ) - : Collection() - , m_device( device ) - , m_mc( 0 ) - , m_tracksParsed( false ) - , m_autoConnect( false ) - , m_musicFilenameScheme( "%artist%/%album%/%track% %title%" ) - , m_vfatSafe( true ) - , m_asciiOnly( false ) - , m_postfixThe( false ) - , m_replaceSpaces( false ) - , m_regexText( QString() ) - , m_replaceText( QString() ) - , m_collectionName( QString() ) - , m_scanManager( 0 ) - , m_lastUpdated( 0 ) -{ - debug() << "Creating UmsCollection for device with udi: " << m_device.udi(); - - m_updateTimer.setSingleShot( true ); - connect( this, SIGNAL(startUpdateTimer()), SLOT(slotStartUpdateTimer()) ); - connect( &m_updateTimer, SIGNAL(timeout()), SLOT(collectionUpdated()) ); - - m_configureAction = new QAction( KIcon( "configure" ), i18n( "&Configure Device" ), this ); - m_configureAction->setProperty( "popupdropper_svg_id", "configure" ); - connect( m_configureAction, SIGNAL(triggered()), SLOT(slotConfigure()) ); - - m_parseAction = new QAction( KIcon( "checkbox" ), i18n( "&Activate This Collection" ), this ); - m_parseAction->setProperty( "popupdropper_svg_id", "edit" ); - connect( m_parseAction, SIGNAL(triggered()), this, SLOT(slotParseActionTriggered()) ); - - m_ejectAction = new QAction( KIcon( "media-eject" ), i18n( "&Eject Device" ), - const_cast( this ) ); - m_ejectAction->setProperty( "popupdropper_svg_id", "eject" ); - connect( m_ejectAction, SIGNAL(triggered()), SLOT(slotEject()) ); - - init(); -} - -UmsCollection::~UmsCollection() -{ - DEBUG_BLOCK -} - -void -UmsCollection::init() -{ - Solid::StorageAccess *storageAccess = m_device.as(); - m_mountPoint = storageAccess->filePath(); - Solid::StorageVolume *ssv = m_device.as(); - m_collectionId = ssv ? ssv->uuid() : m_device.udi(); - debug() << "Mounted at: " << m_mountPoint << "collection id:" << m_collectionId; - - // read .is_audio_player from filesystem - KConfig config( m_mountPoint + '/' + s_settingsFileName, KConfig::SimpleConfig ); - KConfigGroup entries = config.group( QString() ); // default group - if( entries.hasKey( s_musicFolderKey ) ) - { - m_musicPath = KUrl( m_mountPoint ); - m_musicPath.addPath( entries.readPathEntry( s_musicFolderKey, QString() ) ); - m_musicPath.cleanPath(); - if( !QDir( m_musicPath.toLocalFile() ).exists() ) - { - QString message = i18n( "File %1 suggests that we should use %2 " - "as music folder on the device, but it doesn't exist. Falling back to " - "%3 instead", m_mountPoint + '/' + s_settingsFileName, - m_musicPath.toLocalFile(), m_mountPoint ); - Amarok::Components::logger()->longMessage( message, Amarok::Logger::Warning ); - m_musicPath = m_mountPoint; - } - } - else if( !entries.keyList().isEmpty() ) - // config file exists, but has no s_musicFolderKey -> music should be disabled - m_musicPath = KUrl(); - else - m_musicPath = m_mountPoint; // related BR 259849 - QString scheme = entries.readEntry( s_musicFilenameSchemeKey ); - m_musicFilenameScheme = !scheme.isEmpty() ? scheme : m_musicFilenameScheme; - m_vfatSafe = entries.readEntry( s_vfatSafeKey, m_vfatSafe ); - m_asciiOnly = entries.readEntry( s_asciiOnlyKey, m_asciiOnly ); - m_postfixThe = entries.readEntry( s_postfixTheKey, m_postfixThe ); - m_replaceSpaces = entries.readEntry( s_replaceSpacesKey, m_replaceSpaces ); - m_regexText = entries.readEntry( s_regexTextKey, m_regexText ); - m_replaceText = entries.readEntry( s_replaceTextKey, m_replaceText ); - if( entries.hasKey( s_podcastFolderKey ) ) - { - m_podcastPath = KUrl( m_mountPoint ); - m_podcastPath.addPath( entries.readPathEntry( s_podcastFolderKey, QString() ) ); - m_podcastPath.cleanPath(); - } - m_autoConnect = entries.readEntry( s_autoConnectKey, m_autoConnect ); - m_collectionName = entries.readEntry( s_collectionName, m_collectionName ); - - m_mc = QSharedPointer(new MemoryCollection()); - - if( m_autoConnect ) - QTimer::singleShot( 0, this, SLOT(slotParseTracks()) ); -} - -bool -UmsCollection::possiblyContainsTrack( const KUrl &url ) const -{ - //not initialized yet. - if( m_mc.isNull() ) - return false; - - QString u = QUrl::fromPercentEncoding( url.url().toUtf8() ); - return u.startsWith( m_mountPoint ) || u.startsWith( "file://" + m_mountPoint ); -} - -Meta::TrackPtr -UmsCollection::trackForUrl( const KUrl &url ) -{ - //not initialized yet. - if( m_mc.isNull() ) - return Meta::TrackPtr(); - - QString uid = QUrl::fromPercentEncoding( url.url().toUtf8() ); - if( uid.startsWith("file://") ) - uid = uid.remove( 0, 7 ); - return m_mc->trackMap().value( uid, Meta::TrackPtr() ); -} - -QueryMaker * -UmsCollection::queryMaker() -{ - return new MemoryQueryMaker( m_mc.toWeakRef(), collectionId() ); -} - -QString -UmsCollection::uidUrlProtocol() const -{ - return QString( "file://" ); -} - -QString -UmsCollection::collectionId() const -{ - return m_collectionId; -} - -QString -UmsCollection::prettyName() const -{ - QString actualName; - if( !m_collectionName.isEmpty() ) - actualName = m_collectionName; - else if( !m_device.description().isEmpty() ) - actualName = m_device.description(); - else - { - actualName = m_device.vendor().simplified(); - if( !actualName.isEmpty() ) - actualName += ' '; - actualName += m_device.product().simplified(); - } - - if( m_tracksParsed ) - return actualName; - else - return i18nc( "Name of the USB Mass Storage collection that has not yet been " - "activated. See also the 'Activate This Collection' action; %1 is " - "actual collection name", "%1 (not activated)", actualName ); -} - -KIcon -UmsCollection::icon() const -{ - if( m_device.icon().isEmpty() ) - return KIcon( "drive-removable-media-usb-pendrive" ); - else - return KIcon( m_device.icon() ); -} - -bool -UmsCollection::hasCapacity() const -{ - if( m_device.isValid() && m_device.is() ) - return m_device.as()->isAccessible(); - return false; -} - -float -UmsCollection::usedCapacity() const -{ - return KDiskFreeSpaceInfo::freeSpaceInfo( m_mountPoint ).used(); -} - -float -UmsCollection::totalCapacity() const -{ - return KDiskFreeSpaceInfo::freeSpaceInfo( m_mountPoint ).size(); -} - -CollectionLocation * -UmsCollection::location() -{ - return new UmsCollectionLocation( this ); -} - -bool -UmsCollection::isOrganizable() const -{ - return isWritable(); -} - -bool -UmsCollection::hasCapabilityInterface( Capabilities::Capability::Type type ) const -{ - switch( type ) - { - case Capabilities::Capability::Actions: - case Capabilities::Capability::Transcode: - return true; - default: - return false; - } -} - -Capabilities::Capability * -UmsCollection::createCapabilityInterface( Capabilities::Capability::Type type ) -{ - switch( type ) - { - case Capabilities::Capability::Actions: - { - QList actions; - if( m_tracksParsed ) - { - actions << m_configureAction; - actions << m_ejectAction; - } - else - { - actions << m_parseAction; - } - return new Capabilities::ActionsCapability( actions ); - } - case Capabilities::Capability::Transcode: - return new UmsTranscodeCapability( m_mountPoint + '/' + s_settingsFileName, - s_transcodingGroup ); - default: - return 0; - } -} - -void -UmsCollection::metadataChanged( Meta::TrackPtr track ) -{ - if( MemoryMeta::MapChanger( m_mc.data() ).trackChanged( track ) ) - // big-enough change: - emit startUpdateTimer(); -} - -KUrl -UmsCollection::organizedUrl( Meta::TrackPtr track, const QString &fileExtension ) const -{ - TrackOrganizer trackOrganizer( Meta::TrackList() << track ); - //%folder% prefix required to get absolute url. - trackOrganizer.setFormatString( "%collectionroot%/" + m_musicFilenameScheme + ".%filetype%" ); - trackOrganizer.setVfatSafe( m_vfatSafe ); - trackOrganizer.setAsciiOnly( m_asciiOnly ); - trackOrganizer.setFolderPrefix( m_musicPath.path() ); - trackOrganizer.setPostfixThe( m_postfixThe ); - trackOrganizer.setReplaceSpaces( m_replaceSpaces ); - trackOrganizer.setReplace( m_regexText, m_replaceText ); - if( !fileExtension.isEmpty() ) - trackOrganizer.setTargetFileExtension( fileExtension ); - - return KUrl( trackOrganizer.getDestinations().value( track ) ); -} - -void -UmsCollection::slotDestroy() -{ - //TODO: stop scanner if running - //unregister PlaylistProvider - //CollectionManager will call destructor. - emit remove(); -} - -void -UmsCollection::slotEject() -{ - slotDestroy(); - Solid::StorageAccess *storageAccess = m_device.as(); - storageAccess->teardown(); -} - -void -UmsCollection::slotTrackAdded( KUrl location ) -{ - Q_ASSERT( m_musicPath.isParentOf( location ) ); - MetaFile::Track *fileTrack = new MetaFile::Track( location ); - fileTrack->setCollection( this ); - Meta::TrackPtr fileTrackPtr = Meta::TrackPtr( fileTrack ); - Meta::TrackPtr proxyTrack = MemoryMeta::MapChanger( m_mc.data() ).addTrack( fileTrackPtr ); - if( proxyTrack ) - { - subscribeTo( fileTrackPtr ); - emit startUpdateTimer(); - } - else - warning() << __PRETTY_FUNCTION__ << "Failed to add" << fileTrackPtr->playableUrl() - << "to MemoryCollection. Perhaps already there?!?"; -} - -void -UmsCollection::slotTrackRemoved( const Meta::TrackPtr &track ) -{ - Meta::TrackPtr removedTrack = MemoryMeta::MapChanger( m_mc.data() ).removeTrack( track ); - if( removedTrack ) - { - unsubscribeFrom( removedTrack ); - // we only added MetaFile::Tracks, following static cast is safe - static_cast( removedTrack.data() )->setCollection( 0 ); - emit startUpdateTimer(); - } - else - warning() << __PRETTY_FUNCTION__ << "Failed to remove" << track->playableUrl() - << "from MemoryCollection. Perhaps it was never there?"; -} - -void -UmsCollection::collectionUpdated() -{ - m_lastUpdated = QDateTime::currentMSecsSinceEpoch(); - emit updated(); -} - -void -UmsCollection::slotParseTracks() -{ - if( !m_scanManager ) - { - m_scanManager = new GenericScanManager( this ); - connect( m_scanManager, SIGNAL(directoryScanned(QSharedPointer)), - SLOT(slotDirectoryScanned(QSharedPointer)) ); - } - - m_tracksParsed = true; - m_scanManager->requestScan( QList() << m_musicPath, GenericScanManager::FullScan ); -} - -void -UmsCollection::slotParseActionTriggered() -{ - if( m_mc->trackMap().isEmpty() ) - QTimer::singleShot( 0, this, SLOT(slotParseTracks()) ); -} - -void -UmsCollection::slotConfigure() -{ - KDialog umsSettingsDialog; - QWidget *settingsWidget = new QWidget( &umsSettingsDialog ); - QScopedPointer tc( create() ); - - Ui::UmsConfiguration *settings = new Ui::UmsConfiguration(); - settings->setupUi( settingsWidget ); - - settings->m_autoConnect->setChecked( m_autoConnect ); - - settings->m_musicFolder->setMode( KFile::Directory ); - settings->m_musicCheckBox->setChecked( !m_musicPath.isEmpty() ); - settings->m_musicWidget->setEnabled( settings->m_musicCheckBox->isChecked() ); - settings->m_musicFolder->setUrl( m_musicPath.isEmpty() ? KUrl( m_mountPoint ) : m_musicPath ); - settings->m_transcodeConfig->fillInChoices( tc->savedConfiguration() ); - - settings->m_podcastFolder->setMode( KFile::Directory ); - settings->m_podcastCheckBox->setChecked( !m_podcastPath.isEmpty() ); - settings->m_podcastWidget->setEnabled( settings->m_podcastCheckBox->isChecked() ); - settings->m_podcastFolder->setUrl( m_podcastPath.isEmpty() ? KUrl( m_mountPoint ) - : m_podcastPath ); - - settings->m_collectionName->setText( prettyName() ); - - OrganizeCollectionWidget layoutWidget( &umsSettingsDialog ); - //TODO: save the setting that are normally written in onAccept() -// connect( this, SIGNAL(accepted()), &layoutWidget, SLOT(onAccept()) ); - QVBoxLayout layout( &umsSettingsDialog ); - layout.addWidget( &layoutWidget ); - settings->m_filenameSchemeBox->setLayout( &layout ); - //hide the unuse preset selector. - //TODO: change the presets to concurrent presets for regular albums v.s. compilations - // layoutWidget.setformatPresetVisible( false ); - layoutWidget.setScheme( m_musicFilenameScheme ); - - OrganizeCollectionOptionWidget optionsWidget; - optionsWidget.setVfatCompatible( m_vfatSafe ); - optionsWidget.setAsciiOnly( m_asciiOnly ); - optionsWidget.setPostfixThe( m_postfixThe ); - optionsWidget.setReplaceSpaces( m_replaceSpaces ); - optionsWidget.setRegexpText( m_regexText ); - optionsWidget.setReplaceText( m_replaceText ); - - layout.addWidget( &optionsWidget ); - - umsSettingsDialog.setButtons( KDialog::Ok | KDialog::Cancel ); - umsSettingsDialog.setMainWidget( settingsWidget ); - - umsSettingsDialog.setWindowTitle( i18n( "Configure USB Mass Storage Device" ) ); - - if( umsSettingsDialog.exec() == QDialog::Accepted ) - { - debug() << "accepted"; - - if( settings->m_musicCheckBox->isChecked() ) - { - if( settings->m_musicFolder->url() != m_musicPath ) - { - debug() << "music location changed from " << m_musicPath.toLocalFile() << " to "; - debug() << settings->m_musicFolder->url().toLocalFile(); - m_musicPath = settings->m_musicFolder->url(); - //TODO: reparse music - } - QString scheme = layoutWidget.getParsableScheme().simplified(); - //protect against empty string. - if( !scheme.isEmpty() ) - m_musicFilenameScheme = scheme; - } - else - { - debug() << "music support is disabled"; - m_musicPath = KUrl(); - //TODO: remove all tracks from the MemoryCollection. - } - - m_asciiOnly = optionsWidget.asciiOnly(); - m_postfixThe = optionsWidget.postfixThe(); - m_replaceSpaces = optionsWidget.replaceSpaces(); - m_regexText = optionsWidget.regexpText(); - m_replaceText = optionsWidget.replaceText(); - m_collectionName = settings->m_collectionName->text(); - - if( settings->m_podcastCheckBox->isChecked() ) - { - if( settings->m_podcastFolder->url() != m_podcastPath ) - { - debug() << "podcast location changed from " << m_podcastPath << " to "; - debug() << settings->m_podcastFolder->url().url(); - m_podcastPath = settings->m_podcastFolder->url().toLocalFile(); - //TODO: reparse podcasts - } - } - else - { - debug() << "podcast support is disabled"; - m_podcastPath = KUrl(); - //TODO: remove the PodcastProvider - } - - m_autoConnect = settings->m_autoConnect->isChecked(); - if( !m_musicPath.isEmpty() && m_autoConnect ) - QTimer::singleShot( 0, this, SLOT(slotParseTracks()) ); - - // write the data to the on-disk file - KConfig config( m_mountPoint + '/' + s_settingsFileName, KConfig::SimpleConfig ); - KConfigGroup entries = config.group( QString() ); // default group - if( !m_musicPath.isEmpty() ) - entries.writePathEntry( s_musicFolderKey, KUrl::relativePath( m_mountPoint, - m_musicPath.toLocalFile() ) ); - else - entries.deleteEntry( s_musicFolderKey ); - entries.writeEntry( s_musicFilenameSchemeKey, m_musicFilenameScheme ); - entries.writeEntry( s_vfatSafeKey, m_vfatSafe ); - entries.writeEntry( s_asciiOnlyKey, m_asciiOnly ); - entries.writeEntry( s_postfixTheKey, m_postfixThe ); - entries.writeEntry( s_replaceSpacesKey, m_replaceSpaces ); - entries.writeEntry( s_regexTextKey, m_regexText ); - entries.writeEntry( s_replaceTextKey, m_replaceText ); - if( !m_podcastPath.isEmpty() ) - entries.writePathEntry( s_podcastFolderKey, KUrl::relativePath( m_mountPoint, - m_podcastPath.toLocalFile() ) ); - else - entries.deleteEntry( s_podcastFolderKey ); - entries.writeEntry( s_autoConnectKey, m_autoConnect ); - entries.writeEntry( s_collectionName, m_collectionName ); - config.sync(); - - tc->setSavedConfiguration( settings->m_transcodeConfig->currentChoice() ); - } - - delete settings; -} - -void -UmsCollection::slotDirectoryScanned( QSharedPointer dir ) -{ - debug() << "directory scanned: " << dir->path(); - if( dir->tracks().isEmpty() ) - { - debug() << "does not have tracks"; - return; - } - - foreach( const CollectionScanner::Track *scannerTrack, dir->tracks() ) - { - //TODO: use proxy tracks so no real file read is required - // following method calls startUpdateTimer(), no need to emit updated() - slotTrackAdded( scannerTrack->path() ); - } - - //TODO: read playlists -} - -void -UmsCollection::slotStartUpdateTimer() -{ - // there are no concurrency problems, this method can only be called from the main - // thread and that's where the timer fires - if( m_updateTimer.isActive() ) - return; // already running, nothing to do - - // number of milliseconds to next desired update, may be negative - int timeout = m_lastUpdated + 1000 - QDateTime::currentMSecsSinceEpoch(); - // give at least 50 msecs to catch multi-tracks edits nicely on the first frame - m_updateTimer.start( qBound( 50, timeout, 1000 ) ); -} diff --git a/amarok/src/core-impl/collections/umscollection/UmsCollection.h b/amarok/src/core-impl/collections/umscollection/UmsCollection.h deleted file mode 100644 index 0bc620cf..00000000 --- a/amarok/src/core-impl/collections/umscollection/UmsCollection.h +++ /dev/null @@ -1,243 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Alejandro Wainzinger * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef UMSCOLLECTION_H -#define UMSCOLLECTION_H - -#include "collectionscanner/Directory.h" -#include "core/collections/Collection.h" -#include "core/meta/Observer.h" -#include "core-impl/collections/support/MemoryCollection.h" - -#include -#include - -#include - -#include -#include - -class GenericScanManager; -class UmsPodcastProvider; -class UmsCollection; -class UmsCollectionLocation; -class QAction; - -using namespace Collections; - -class UmsCollectionFactory : public CollectionFactory -{ - Q_OBJECT - - public: - UmsCollectionFactory( QObject *parent, const QVariantList &args ); - virtual ~UmsCollectionFactory(); - - virtual void init(); - - private slots: - /** - * Called when solid notifier detects a new device has been added - */ - void slotAddSolidDevice( const QString &udi ); - - /** - * Called when solid StorageAccess device we are interested in is mounted or - * unmounted - */ - void slotAccessibilityChanged( bool accessible, const QString &udi ); - - /** - * Called when solid notifier detects a device has been removed - */ - void slotRemoveSolidDevice( const QString &udi ); - - /** - * Like @see slotRemoveSolidDevice(), but instructs Collection to eject the - * device after it has performed necessary teardown operations. - * - * Called when user wants to unmount the device from for example Device Notifier - */ - void slotRemoveAndTeardownSolidDevice( const QString &udi ); - - /** - * Called when "tracked" collection is destroyed - */ - void slotCollectionDestroyed( QObject *collection ); - - private: - /** - * Checks whether a solid device is a USB mass-storage one - */ - bool identifySolidDevice( const QString &udi ) const; - - /** - * Attempts to create appropriate collection for already identified solid device - * @param udi. Should emit newCollection() if the collection was successfully - * created and should become visible to the user. - */ - void createCollectionForSolidDevice( const QString &udi ); - - // maps device udi to active UMS collections - QMap m_collectionMap; -}; - -class UmsCollection : public Collection, public Meta::Observer -{ - Q_OBJECT - - public: - // inherited methods - - UmsCollection( Solid::Device device ); - virtual ~UmsCollection(); - - /* TrackProvider methods */ - virtual bool possiblyContainsTrack( const KUrl &url ) const; - virtual Meta::TrackPtr trackForUrl( const KUrl &url ); - - /* Collection methods */ - virtual QueryMaker *queryMaker(); - virtual QString uidUrlProtocol() const; - - virtual QString collectionId() const; - virtual QString prettyName() const; - virtual KIcon icon() const; - - virtual bool hasCapacity() const; - virtual float usedCapacity() const; - virtual float totalCapacity() const; - - virtual CollectionLocation *location(); - - virtual bool isOrganizable() const; - - /* Capability-related methods */ - virtual bool hasCapabilityInterface( Capabilities::Capability::Type type ) const; - virtual Capabilities::Capability *createCapabilityInterface( - Capabilities::Capability::Type type ); - - /* Meta::Observer methods */ - virtual void metadataChanged( Meta::TrackPtr track ); - using Meta::Observer::metadataChanged; // silence compiler warning about hidder overloads - - /* own methods */ - const KUrl &musicPath() const { return m_musicPath; } - const KUrl &podcastPath() const { return m_podcastPath; } - - /** - * Get location where track @param track should be transferred to. - * - * @param fileExtension new extension to use. Leave empty if you don't wish to - * change file extension - */ - KUrl organizedUrl( Meta::TrackPtr track, const QString &fileExtension = QString() ) const; - - QSharedPointer memoryCollection() const { return m_mc; } - - signals: - /** - * Start a count-down that emits updated() signal after it expires. - * Resets the timer to original timeout if already running. This is to ensure - * that we emit update() max. once per for batch updates. - * - * Timers can only be started from "their" thread so use signals & slots for that. - */ - void startUpdateTimer(); - - public slots: - /** - * Destroy the collection (by emitting remove) - */ - void slotDestroy(); - - /** - * Destroy the collection and try to eject the device from system - */ - void slotEject(); - - void slotTrackAdded( KUrl trackLocation ); - void slotTrackRemoved( const Meta::TrackPtr &track ); - - private slots: - /** - * Update m_lastUpdated timestamp and emit updated() - */ - void collectionUpdated(); - - void slotParseTracks(); - void slotParseActionTriggered(); - void slotConfigure(); - - void slotDirectoryScanned( QSharedPointer dir ); - - /** - * Starts a timer that ensures we emit updated() signal sometime in future. - */ - void slotStartUpdateTimer(); - - private: - /** extended constructor */ - void init(); - - //static variables relating to the on-disk configuration file - static QString s_settingsFileName; - static QString s_musicFolderKey; - static QString s_musicFilenameSchemeKey; - static QString s_vfatSafeKey; - static QString s_asciiOnlyKey; - static QString s_postfixTheKey; - static QString s_replaceSpacesKey; - static QString s_regexTextKey; - static QString s_replaceTextKey; - static QString s_podcastFolderKey; - static QString s_autoConnectKey; - static QString s_collectionName; - static QString s_transcodingGroup; - - Solid::Device m_device; - QSharedPointer m_mc; - bool m_tracksParsed; - - bool m_autoConnect; - QString m_mountPoint; - KUrl m_musicPath; - KUrl m_podcastPath; - QString m_musicFilenameScheme; - bool m_vfatSafe; - bool m_asciiOnly; - bool m_postfixThe; - bool m_replaceSpaces; - QString m_regexText; - QString m_replaceText; - QString m_collectionName; - QString m_collectionId; - - GenericScanManager *m_scanManager; - KDirWatch m_watcher; - - QStringList m_supportedMimeTypes; - - UmsPodcastProvider *m_podcastProvider; - - QAction *m_parseAction; - QAction *m_configureAction; - QAction *m_ejectAction; - QTimer m_updateTimer; - qint64 m_lastUpdated; /* msecs since epoch */ -}; - -#endif diff --git a/amarok/src/core-impl/collections/umscollection/UmsCollectionLocation.cpp b/amarok/src/core-impl/collections/umscollection/UmsCollectionLocation.cpp deleted file mode 100644 index cef90d78..00000000 --- a/amarok/src/core-impl/collections/umscollection/UmsCollectionLocation.cpp +++ /dev/null @@ -1,272 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2011 Bart Cerneels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "UmsCollectionLocation.h" - -#include "core/support/Components.h" -#include "core/support/Debug.h" -#include "core/interfaces/Logger.h" -#include "core/transcoding/TranscodingController.h" -#include "core-impl/meta/file/File.h" -#include "transcoding/TranscodingJob.h" - -#include -#include -#include -#include -#include - -#include - -UmsCollectionLocation::UmsCollectionLocation( UmsCollection *umsCollection ) - : CollectionLocation( umsCollection ) - , m_umsCollection( umsCollection ) -{ -} - -UmsCollectionLocation::~UmsCollectionLocation() -{ -} - -QString -UmsCollectionLocation::prettyLocation() const -{ - return m_umsCollection->musicPath().toLocalFile( KUrl::RemoveTrailingSlash ); -} - -QStringList -UmsCollectionLocation::actualLocation() const -{ - return QStringList() << prettyLocation(); -} - -bool -UmsCollectionLocation::isWritable() const -{ - const QFileInfo info( m_umsCollection->musicPath().toLocalFile() ); - return info.isWritable(); -} - -bool -UmsCollectionLocation::isOrganizable() const -{ - return isWritable(); -} - -void -UmsCollectionLocation::copyUrlsToCollection( const QMap &sources, - const Transcoding::Configuration &configuration ) -{ - //TODO: disable scanning until we are done with copying - - UmsTransferJob *transferJob = new UmsTransferJob( this, configuration ); - QMapIterator i( sources ); - while( i.hasNext() ) - { - i.next(); - Meta::TrackPtr track = i.key(); - KUrl destination; - bool isJustCopy = configuration.isJustCopy( track ); - if( isJustCopy ) - destination = m_umsCollection->organizedUrl( track ); - else - destination = m_umsCollection->organizedUrl( track, Amarok::Components:: - transcodingController()->format( configuration.encoder() )->fileExtension() ); - debug() << "destination is " << destination.toLocalFile(); - QDir dir( destination.directory() ); - if( !dir.exists() && !dir.mkpath( "." ) ) - { - error() << "could not create directory to copy into."; - abort(); - } - m_sourceUrlToTrackMap.insert( i.value(), track ); // needed for slotTrackTransferred() - if( isJustCopy ) - transferJob->addCopy( i.value(), destination ); - else - transferJob->addTranscode( i.value(), destination ); - } - - connect( transferJob, SIGNAL(sourceFileTransferDone(KUrl)), - this, SLOT(slotTrackTransferred(KUrl)) ); - connect( transferJob, SIGNAL(fileTransferDone(KUrl)), - m_umsCollection, SLOT(slotTrackAdded(KUrl)) ); - connect( transferJob, SIGNAL(finished(KJob*)), - this, SLOT(slotCopyOperationFinished()) ); - - QString loggerText = operationInProgressText( configuration, sources.count(), m_umsCollection->prettyName() ); - Amarok::Components::logger()->newProgressOperation( transferJob, loggerText, transferJob, - SLOT(slotCancel()) ); - transferJob->start(); -} - -void -UmsCollectionLocation::removeUrlsFromCollection( const Meta::TrackList &sources ) -{ - KUrl::List sourceUrls; - foreach( const Meta::TrackPtr track, sources ) - { - KUrl trackUrl = track->playableUrl(); - m_sourceUrlToTrackMap.insert( trackUrl, track ); - sourceUrls.append( trackUrl ); - } - - QString loggerText = i18np( "Removing one track from %2", - "Removing %1 tracks from %2", sourceUrls.count(), - m_umsCollection->prettyName() ); - KIO::DeleteJob *delJob = KIO::del( sourceUrls, KIO::HideProgressInfo ); - Amarok::Components::logger()->newProgressOperation( delJob, loggerText, delJob, SLOT(kill()) ); - - connect( delJob, SIGNAL(finished(KJob*)), SLOT(slotRemoveOperationFinished()) ); -} - -void -UmsCollectionLocation::slotTrackTransferred( const KUrl &sourceTrackUrl ) -{ - Meta::TrackPtr sourceTrack = m_sourceUrlToTrackMap.value( sourceTrackUrl ); - if( !sourceTrack ) - warning() << __PRETTY_FUNCTION__ << ": I don't know about" << sourceTrackUrl; - else - // this is needed for example for "move" operation to actually remove source tracks - source()->transferSuccessful( sourceTrack ); -} - -void UmsCollectionLocation::slotRemoveOperationFinished() -{ - foreach( Meta::TrackPtr track, m_sourceUrlToTrackMap ) - { - KUrl trackUrl = track->playableUrl(); - if( !trackUrl.isLocalFile() // just pretend it was deleted - || !QFileInfo( trackUrl.toLocalFile() ).exists() ) - { - // good, the file was deleted. following is needed to trigger - // CollectionLocation's functionality to remove empty dirs: - transferSuccessful( track ); - m_umsCollection->slotTrackRemoved( track ); - } - } - CollectionLocation::slotRemoveOperationFinished(); -} - -UmsTransferJob::UmsTransferJob( UmsCollectionLocation* location, - const Transcoding::Configuration &configuration ) - : KCompositeJob( location ) - , m_location( location ) - , m_transcodingConfiguration( configuration ) - , m_abort( false ) -{ - setCapabilities( KJob::Killable ); -} - -void -UmsTransferJob::addCopy( const KUrl &from, const KUrl &to ) -{ - m_copyList << KUrlPair( from, to ); -} - -void -UmsTransferJob::addTranscode( const KUrl &from, const KUrl &to ) -{ - m_transcodeList << KUrlPair( from, to ); -} - -void -UmsTransferJob::start() -{ - DEBUG_BLOCK; - if( m_copyList.isEmpty() && m_transcodeList.isEmpty() ) - return; - - m_totalTracks = m_transcodeList.size() + m_copyList.size(); - startNextJob(); -} - -void -UmsTransferJob::slotCancel() -{ - m_abort = true; -} - -void -UmsTransferJob::startNextJob() -{ - if( m_abort ) - { - emitResult(); - return; - } - - KJob *job; - if( !m_transcodeList.isEmpty() ) - { - KUrlPair urlPair = m_transcodeList.takeFirst(); - job = new Transcoding::Job( urlPair.first, urlPair.second, m_transcodingConfiguration ); - } - else if( !m_copyList.isEmpty() ) - { - KUrlPair urlPair = m_copyList.takeFirst(); - job = KIO::file_copy( urlPair.first, urlPair.second, -1, KIO::HideProgressInfo ); - } - else - { - emitResult(); - return; - } - - connect( job, SIGNAL(percent(KJob*,ulong)), - SLOT(slotChildJobPercent(KJob*,ulong)) ); - addSubjob( job ); - job->start(); // no-op for KIO job, but matters for transcoding job -} - -void -UmsTransferJob::slotChildJobPercent( KJob *job, unsigned long percentage ) -{ - Q_UNUSED(job) - // the -1 is for the current track that is being processed but already removed from transferList - int alreadyTransferred = m_totalTracks - m_transcodeList.size() - m_copyList.size() - 1; - emitPercent( alreadyTransferred * 100.0 + percentage, 100.0 * m_totalTracks ); -} - -void -UmsTransferJob::slotResult( KJob *job ) -{ - removeSubjob( job ); - - if( job->error() == KJob::NoError ) - { - KIO::FileCopyJob *copyJob = dynamic_cast( job ); - Transcoding::Job *transcodingJob = dynamic_cast( job ); - if( copyJob ) - { - emit sourceFileTransferDone( copyJob->srcUrl() ); - emit fileTransferDone( copyJob->destUrl() ); - } - else if( transcodingJob ) - { - emit sourceFileTransferDone( transcodingJob->srcUrl() ); - emit fileTransferDone( transcodingJob->destUrl() ); - } - else - Debug::warning() << __PRETTY_FUNCTION__ << "invalid job passed to me!"; - } - else - Debug::warning() << __PRETTY_FUNCTION__ << "job failed with" << job->error(); - - // transcoding job currently doesn't emit percentage, so emit it at least once for track - emitPercent( m_totalTracks - ( m_transcodeList.size() + m_copyList.size() ), - m_totalTracks ); - startNextJob(); -} diff --git a/amarok/src/core-impl/collections/umscollection/UmsCollectionLocation.h b/amarok/src/core-impl/collections/umscollection/UmsCollectionLocation.h deleted file mode 100644 index 6cfe4df2..00000000 --- a/amarok/src/core-impl/collections/umscollection/UmsCollectionLocation.h +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2011 Bart Cerneels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef UMSCOLLECTIONLOCATION_H -#define UMSCOLLECTIONLOCATION_H - -#include "core/collections/CollectionLocation.h" -#include "UmsCollection.h" - -#include -#include - -#include -#include - -class UmsTransferJob; - -class UmsCollectionLocation : public Collections::CollectionLocation -{ - Q_OBJECT - public: - UmsCollectionLocation( UmsCollection *umsCollection ); - ~UmsCollectionLocation(); - - /* CollectionLocation methods */ - virtual QString prettyLocation() const; - virtual QStringList actualLocation() const; - virtual bool isWritable() const; - virtual bool isOrganizable() const; - - virtual void copyUrlsToCollection( const QMap &sources, - const Transcoding::Configuration &configuration ); - virtual void removeUrlsFromCollection( const Meta::TrackList &sources ); - - protected slots: - void slotRemoveOperationFinished(); // hides intentionally parent methods - - private slots: - /** - * Needed for removal of source tracks during move operation - */ - void slotTrackTransferred( const KUrl &sourceTrackUrl ); - - private: - UmsCollection *m_umsCollection; - QHash m_sourceUrlToTrackMap; -}; - -class UmsTransferJob : public KCompositeJob -{ - Q_OBJECT - public: - UmsTransferJob( UmsCollectionLocation *location, const Transcoding::Configuration &configuration ); - - void addCopy( const KUrl &from, const KUrl &to ); - void addTranscode( const KUrl &from, const KUrl &to ); - virtual void start(); - - signals: - void sourceFileTransferDone( KUrl source ); - void fileTransferDone( KUrl destination ); - - public slots: - void slotCancel(); - - private slots: - void startNextJob(); - void slotChildJobPercent( KJob *job, unsigned long percentage ); - - //reimplemented from KCompositeJob - virtual void slotResult( KJob *job ); - - private: - UmsCollectionLocation *m_location; - Transcoding::Configuration m_transcodingConfiguration; - bool m_abort; - - typedef QPair KUrlPair; - QList m_copyList; - QList m_transcodeList; - int m_totalTracks; // total number of tracks in whole transfer -}; - -#endif // UMSCOLLECTIONLOCATION_H diff --git a/amarok/src/core-impl/collections/umscollection/UmsConfiguration.ui b/amarok/src/core-impl/collections/umscollection/UmsConfiguration.ui deleted file mode 100644 index 0e65034a..00000000 --- a/amarok/src/core-impl/collections/umscollection/UmsConfiguration.ui +++ /dev/null @@ -1,238 +0,0 @@ - - - UmsConfiguration - - - - 0 - 0 - 751 - 473 - - - - USB Mass Storage device configuration - - - - - - - - Name: - - - - - - - - - - - - Use automatically when connected - - - - - - - - 50 - false - false - - - - - - - Music - - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 12 - 20 - - - - - - - - - 0 - 0 - - - - - QFormLayout::ExpandingFieldsGrow - - - - - Music folder: - - - - - - - - - - - 0 - 0 - - - - Filename scheme of tracks that are added to the device - - - - - - - Transcode: - - - - - - - - - - - - - - - - 50 - false - false - - - - - - - Podcasts - - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 12 - 20 - - - - - - - - - 0 - 0 - - - - - QFormLayout::ExpandingFieldsGrow - - - - - QFrame::NoFrame - - - Podcast folder: - - - - - - - - - - - - - - - - KUrlRequester - QFrame -
    kurlrequester.h
    - 1 -
    - - Transcoding::SelectConfigWidget - QComboBox -
    transcoding/TranscodingSelectConfigWidget.h
    -
    -
    - - - - m_musicCheckBox - toggled(bool) - m_musicWidget - setEnabled(bool) - - - 12 - 41 - - - 49 - 86 - - - - - m_podcastCheckBox - toggled(bool) - m_podcastWidget - setEnabled(bool) - - - 14 - 205 - - - 25 - 236 - - - - -
    diff --git a/amarok/src/core-impl/collections/umscollection/UmsTranscodeCapability.cpp b/amarok/src/core-impl/collections/umscollection/UmsTranscodeCapability.cpp deleted file mode 100644 index 76496958..00000000 --- a/amarok/src/core-impl/collections/umscollection/UmsTranscodeCapability.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "UmsTranscodeCapability.h" - -#include - - -UmsTranscodeCapability::UmsTranscodeCapability( const QString &configFilePath, const QString &groupName ) - : TranscodeCapability() - , m_configFilePath( configFilePath ) - , m_groupName( groupName ) -{ -} - -UmsTranscodeCapability::~UmsTranscodeCapability() -{ -} - -Transcoding::Configuration -UmsTranscodeCapability::savedConfiguration() -{ - KConfig configFile( m_configFilePath, KConfig::SimpleConfig ); - if( !configFile.hasGroup( m_groupName ) ) - return Transcoding::Configuration( Transcoding::INVALID ); - return Transcoding::Configuration::fromConfigGroup( configFile.group( m_groupName ) ); -} - -void -UmsTranscodeCapability::setSavedConfiguration( const Transcoding::Configuration &configuration ) -{ - KConfig configFile( m_configFilePath, KConfig::SimpleConfig ); - KConfigGroup group = configFile.group( m_groupName ); - configuration.saveToConfigGroup( group ); - configFile.sync(); -} - -#include "moc_UmsTranscodeCapability.cpp" diff --git a/amarok/src/core-impl/collections/umscollection/UmsTranscodeCapability.h b/amarok/src/core-impl/collections/umscollection/UmsTranscodeCapability.h deleted file mode 100644 index 98a638f2..00000000 --- a/amarok/src/core-impl/collections/umscollection/UmsTranscodeCapability.h +++ /dev/null @@ -1,41 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef UMSTRANSCODECAPABILITY_H -#define UMSTRANSCODECAPABILITY_H - -#include "core/capabilities/TranscodeCapability.h" - - -class UmsTranscodeCapability : public Capabilities::TranscodeCapability -{ - Q_OBJECT - - public: - UmsTranscodeCapability( const QString &configFilePath, const QString &groupName ); - virtual ~UmsTranscodeCapability(); - - virtual Transcoding::Configuration savedConfiguration(); - virtual void setSavedConfiguration(const Transcoding::Configuration& configuration); - - private: - Q_DISABLE_COPY( UmsTranscodeCapability ) - - QString m_configFilePath; - QString m_groupName; -}; - -#endif // UMSTRANSCODECAPABILITY_H diff --git a/amarok/src/core-impl/collections/umscollection/amarok_collection-umscollection.desktop b/amarok/src/core-impl/collections/umscollection/amarok_collection-umscollection.desktop deleted file mode 100644 index 67dd5263..00000000 --- a/amarok/src/core-impl/collections/umscollection/amarok_collection-umscollection.desktop +++ /dev/null @@ -1,71 +0,0 @@ -[Desktop Entry] -Type=Service -Icon=drive-removable-media-usb-pendrive -Name=Universal Mass Storage Collection -Name[bg]=Колекция Universal Mass Storage -Name[bs]=Zbirka na univerzalnom masovnom skladištu -Name[ca]=Col·lecció d'emmagatzematge en massa universal -Name[ca@valencia]=Col·lecció d'emmagatzematge en massa universal -Name[cs]=Sbírka na velkokapacitním úložném zařízení -Name[csb]=Kòlekcëjô ùniwersalnych zôpisownych mediów -Name[da]=Universal Mass Storage-samling -Name[de]=Universelle Massenspeicher-Sammlung -Name[el]=Συλλογή καθολικής μαζικής αποθήκευσης -Name[en_GB]=Universal Mass Storage Collection -Name[es]=Colección universal de almacenamiento masivo -Name[et]=Universaalse massmäluseadme kogu -Name[eu]=Biltegiratze gailu unibertsalen bilduma -Name[fi]=USB-massamuistikokoelma -Name[fr]=Collection de stockage de masse universel -Name[ga]=Bailiúchán Uilíoch Ollstórála -Name[gl]=Colección de almacenamento masivo universal -Name[hu]=Univerzális tárolóhoz (UMS) tartozó gyűjtemény -Name[id]=Koleksi Mass Storage Universal -Name[is]=Universal Mass Storage safn -Name[it]=Collezione universale di memorizzazione di massa -Name[ja]=Universal Mass Storage コレクション -Name[km]=សម្រាំង​ឧបករណ៍​​ផ្ទុក​សកល -Name[ko]=UMS 모음집 -Name[lt]=Universali didelių laikmenų fonoteka -Name[lv]=Universal Mass Storage kolekcija -Name[nb]=Universell masselagersamling -Name[nds]=Allmeen Bültspieker-Sammeln -Name[nl]=Universele massaopslag-verzameling -Name[nn]=Universell masselagringssamling -Name[pa]=ਯੂਨੀਵਰਸਲ ਸਟੋਰੇਜ਼ ਭੰਡਾਰ -Name[pl]=Zbiór na urządzeniu danych -Name[pt]=Colecção de Armazenamento em Massa Universal -Name[pt_BR]=Coleção de armazenamento universal em massa -Name[ro]=Colecție pe stocare în masă universală -Name[ru]=Коллекция UMS -Name[sk]=Kolekcia univerzálnych veľkokapacitných zariadení -Name[sl]=Zbirka univerzalnega hranilnika podatkov -Name[sr]=Збирка на универзалном масовном складишту -Name[sr@ijekavian]=Збирка на универзалном масовном складишту -Name[sr@ijekavianlatin]=Zbirka na univerzalnom masovnom skladištu -Name[sr@latin]=Zbirka na univerzalnom masovnom skladištu -Name[sv]=Samling på generell lagringsenhet -Name[tr]=Evrensel Yığın Depolama Koleksiyonu -Name[uk]=Універсальна збірка на носії даних -Name[x-test]=xxUniversal Mass Storage Collectionxx -Name[zh_CN]=通用大容量存储收藏 -Name[zh_TW]=通用大容量儲存裝置收藏 - -ServiceTypes=Amarok/Plugin - -X-KDE-Amarok-authors=Alejandro Wainzinger -X-KDE-Amarok-email=aikawarazuni@gmail.com -X-KDE-Amarok-framework-version=72 -X-KDE-Amarok-name=ums-collection -X-KDE-Amarok-plugintype=collection -X-KDE-Amarok-rank=100 -X-KDE-Amarok-version=1 - -X-KDE-PluginInfo-Author=Alejandro Wainzinger -X-KDE-PluginInfo-Email=aikawarazuni@gmail.com -X-KDE-PluginInfo-Version=1.0 -X-KDE-PluginInfo-Category=Collection -X-KDE-PluginInfo-License=GPL -X-KDE-PluginInfo-EnabledByDefault=true -X-KDE-PluginInfo-Name=amarok_collection-umscollection -X-KDE-Library=amarok_collection-umscollection diff --git a/amarok/src/core-impl/collections/umscollection/podcasts/UmsPodcastMeta.cpp b/amarok/src/core-impl/collections/umscollection/podcasts/UmsPodcastMeta.cpp deleted file mode 100644 index 5c515fed..00000000 --- a/amarok/src/core-impl/collections/umscollection/podcasts/UmsPodcastMeta.cpp +++ /dev/null @@ -1,273 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Bart Cerneels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "UmsPodcastMeta.h" - -#include "core/support/Debug.h" - -#include "core-impl/playlists/types/file/PlaylistFileSupport.h" - -#include "UmsPodcastProvider.h" - -using namespace Podcasts; - -UmsPodcastEpisodePtr -UmsPodcastEpisode::fromPodcastEpisodePtr( PodcastEpisodePtr episode ) -{ - return UmsPodcastEpisodePtr::dynamicCast( episode ); -} - -UmsPodcastEpisodePtr -UmsPodcastEpisode::fromTrackPtr( Meta::TrackPtr track ) -{ - return UmsPodcastEpisodePtr::dynamicCast( track ); -} - -PodcastEpisodePtr -UmsPodcastEpisode::toPodcastEpisodePtr( UmsPodcastEpisodePtr episode ) -{ - return PodcastEpisodePtr::dynamicCast( episode ); -} - -PodcastEpisodeList -UmsPodcastEpisode::toPodcastEpisodeList( UmsPodcastEpisodeList episodes ) -{ - PodcastEpisodeList list; - foreach( UmsPodcastEpisodePtr e, episodes ) - list << toPodcastEpisodePtr( e ); - return list; -} - -UmsPodcastEpisode::UmsPodcastEpisode( UmsPodcastChannelPtr channel ) - : Podcasts::PodcastEpisode( UmsPodcastChannel::toPodcastChannelPtr( channel ) ) -{ -} - -UmsPodcastEpisode::~UmsPodcastEpisode() -{ -} - -void -UmsPodcastEpisode::setLocalUrl( const KUrl &localUrl ) -{ - m_localUrl = localUrl; - //TODO: load local file -} - -KUrl -UmsPodcastEpisode::playableUrl() const -{ - if( m_localFile.isNull() ) - return m_url; - - return m_localFile->playableUrl(); -} - -QString -UmsPodcastEpisode::notPlayableReason() const -{ - if( m_localFile ) - return m_localFile->notPlayableReason(); - return PodcastEpisode::notPlayableReason(); -} - -void -UmsPodcastEpisode::setLocalFile( MetaFile::TrackPtr localFile ) -{ - m_localFile = localFile; -} - -QString -UmsPodcastEpisode::title() const -{ - if( m_localFile.isNull() ) - return m_title; - - return m_localFile->name(); -} - -QDateTime -UmsPodcastEpisode::createDate() const -{ - if( m_localFile ) - return m_localFile->createDate(); - return Meta::Track::createDate(); -} - -void -UmsPodcastEpisode::setTitle( const QString &title ) -{ - if( !m_localFile.isNull() ) - { - m_localFile->setTitle( title ); - } - - m_title = title; -} - -Meta::AlbumPtr -UmsPodcastEpisode::album() const -{ - if( m_localFile.isNull() ) - return m_albumPtr; - - return m_localFile->album(); -} - -Meta::ArtistPtr -UmsPodcastEpisode::artist() const -{ - if( m_localFile.isNull() ) - return m_artistPtr; - - return m_localFile->artist(); -} - -Meta::ComposerPtr -UmsPodcastEpisode::composer() const -{ - if( m_localFile.isNull() ) - return m_composerPtr; - - return m_localFile->composer(); -} - -Meta::GenrePtr -UmsPodcastEpisode::genre() const -{ - if( m_localFile.isNull() ) - return m_genrePtr; - - return m_localFile->genre(); -} - -Meta::YearPtr -UmsPodcastEpisode::year() const -{ - if( m_localFile.isNull() ) - return m_yearPtr; - - return m_localFile->year(); -} - -UmsPodcastChannelPtr -UmsPodcastChannel::fromPodcastChannelPtr( PodcastChannelPtr channel ) -{ - return UmsPodcastChannelPtr::dynamicCast( channel ); -} - -PodcastChannelPtr -UmsPodcastChannel::toPodcastChannelPtr( UmsPodcastChannelPtr channel ) -{ - return PodcastChannelPtr::dynamicCast( channel ); -} - -PodcastChannelList -UmsPodcastChannel::toPodcastChannelList( UmsPodcastChannelList umsChannels ) -{ - PodcastChannelList channels; - foreach( UmsPodcastChannelPtr umsChannel, umsChannels ) - channels << UmsPodcastChannel::toPodcastChannelPtr( umsChannel ); - return channels; -} - -UmsPodcastChannel::UmsPodcastChannel( UmsPodcastProvider *provider ) - : Podcasts::PodcastChannel() - , m_provider( provider ) -{ - -} - -UmsPodcastChannel::UmsPodcastChannel( PodcastChannelPtr channel, - UmsPodcastProvider *provider ) - : Podcasts::PodcastChannel( channel ) - , m_provider( provider ) -{ - //Since we need to copy the tracks, make sure it's loaded. - //TODO: we might also need to subscribe to get trackAdded() when channel does async loading. - channel->triggerTrackLoad(); - - foreach( PodcastEpisodePtr episode, channel->episodes() ) - addEpisode( episode ); -} - -UmsPodcastChannel::~UmsPodcastChannel() -{ - -} - -PodcastEpisodePtr -UmsPodcastChannel::addEpisode( PodcastEpisodePtr episode ) -{ - DEBUG_BLOCK - - if( !episode->isNew() || !episode->playableUrl().isLocalFile() ) - return PodcastEpisodePtr(); //we don't care about these. - - if( !m_provider ) - return PodcastEpisodePtr(); - - return m_provider->addEpisode( episode ); - //track adding is asynchronous, provider will call addUmsEpisode once done. - //TODO: change this so track can show progress once playlist-inline-progress is implemented -} - -void -UmsPodcastChannel::addUmsEpisode( UmsPodcastEpisodePtr umsEpisode ) -{ - int i = 0; - foreach( UmsPodcastEpisodePtr e, m_umsEpisodes ) - { - if( umsEpisode->createDate() > e->createDate() ) - { - i = m_umsEpisodes.indexOf( e ); - break; - } - } - - m_umsEpisodes.insert( i, umsEpisode ); - notifyObserversTrackAdded( Meta::TrackPtr::dynamicCast( umsEpisode ), i ); -} - -void -UmsPodcastChannel::setPlaylistFileSource( const KUrl &playlistFilePath ) -{ - m_playlistFilePath = playlistFilePath; - m_playlistFile = Playlists::loadPlaylistFile( playlistFilePath ); - - //now parse the playlist and use it to create out episode list -} - -Playlists::PlaylistProvider * -UmsPodcastChannel::provider() const -{ - return dynamic_cast( m_provider ); -} - -void -UmsPodcastChannel::removeEpisode( UmsPodcastEpisodePtr episode ) -{ - int position = m_umsEpisodes.indexOf( episode ); - - if( position == -1 ) - { - error() << title() << " does't have this episode"; - return; - } - - m_umsEpisodes.removeAt( position ); - notifyObserversTrackRemoved( position ); -} diff --git a/amarok/src/core-impl/collections/umscollection/podcasts/UmsPodcastMeta.h b/amarok/src/core-impl/collections/umscollection/podcasts/UmsPodcastMeta.h deleted file mode 100644 index 3b22df33..00000000 --- a/amarok/src/core-impl/collections/umscollection/podcasts/UmsPodcastMeta.h +++ /dev/null @@ -1,122 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Bart Cerneels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef UMSPODCASTMETA_H -#define UMSPODCASTMETA_H - -#include "core-impl/playlists/types/file/PlaylistFile.h" -#include "core/podcasts/PodcastMeta.h" - -#include "core-impl/meta/file/File.h" - -class KUrl; - -namespace Podcasts { - -class UmsPodcastEpisode; -class UmsPodcastChannel; -class UmsPodcastProvider; - - -typedef KSharedPtr UmsPodcastEpisodePtr; -typedef KSharedPtr UmsPodcastChannelPtr; - -typedef QList UmsPodcastEpisodeList; -typedef QList UmsPodcastChannelList; - -class UmsPodcastEpisode : public Podcasts::PodcastEpisode -{ - friend class UmsPodcastProvider; - - public: - static UmsPodcastEpisodePtr fromPodcastEpisodePtr( Podcasts::PodcastEpisodePtr episode ); - static UmsPodcastEpisodePtr fromTrackPtr( Meta::TrackPtr track ); - static Podcasts::PodcastEpisodePtr toPodcastEpisodePtr( UmsPodcastEpisodePtr episode ); - static Podcasts::PodcastEpisodeList toPodcastEpisodeList( UmsPodcastEpisodeList episodes ); - - UmsPodcastEpisode( UmsPodcastChannelPtr channel ); - ~UmsPodcastEpisode(); - - void setLocalFile( MetaFile::TrackPtr localFile ); - - //PodcastEpisode methods - virtual QString title() const; - virtual void setLocalUrl( const KUrl &localUrl ); - - //Track Methods - virtual QString name() const { return title(); } - virtual KUrl playableUrl() const; - virtual QString notPlayableReason() const; - virtual QString prettyName() const { return name(); } - virtual void setTitle( const QString &title ); - virtual QDateTime createDate() const; - - virtual Meta::AlbumPtr album() const; - virtual Meta::ArtistPtr artist() const; - virtual Meta::ComposerPtr composer() const; - virtual Meta::GenrePtr genre() const; - virtual Meta::YearPtr year() const; - - private: - MetaFile::TrackPtr m_localFile; - UmsPodcastChannelPtr m_umsChannel; -}; - -class UmsPodcastChannel : public Podcasts::PodcastChannel -{ - friend class UmsPodcastProvider; - public: - static UmsPodcastChannelPtr fromPodcastChannelPtr( - Podcasts::PodcastChannelPtr channel ); - static Podcasts::PodcastChannelPtr toPodcastChannelPtr( UmsPodcastChannelPtr channel ); - static Podcasts::PodcastChannelList toPodcastChannelList( - UmsPodcastChannelList umsChannels ); - - UmsPodcastChannel( UmsPodcastProvider *provider ); - UmsPodcastChannel( Podcasts::PodcastChannelPtr channel, UmsPodcastProvider *provider ); - ~UmsPodcastChannel(); - - virtual Podcasts::PodcastEpisodePtr addEpisode( Podcasts::PodcastEpisodePtr episode ); - - UmsPodcastEpisodeList umsEpisodes() { return m_umsEpisodes; } - void addUmsEpisode( UmsPodcastEpisodePtr episode ); - - void setPlaylistFileSource( const KUrl &playlistFilePath ); - KUrl playlistFilePath() const { return m_playlistFilePath; } - - virtual Podcasts::PodcastEpisodeList episodes() const - { return UmsPodcastEpisode::toPodcastEpisodeList( m_umsEpisodes ); } - virtual Playlists::PlaylistProvider *provider() const; - - protected: - void removeEpisode( UmsPodcastEpisodePtr episode ); - - private: - UmsPodcastProvider *m_provider; - KUrl m_playlistFilePath; - Playlists::PlaylistFilePtr m_playlistFile; //used to keep track of episodes. - - UmsPodcastEpisodeList m_umsEpisodes; -}; - -} //namespace Podcasts - -Q_DECLARE_METATYPE( Podcasts::UmsPodcastEpisodePtr ) -Q_DECLARE_METATYPE( Podcasts::UmsPodcastEpisodeList ) -Q_DECLARE_METATYPE( Podcasts::UmsPodcastChannelPtr ) -Q_DECLARE_METATYPE( Podcasts::UmsPodcastChannelList ) - -#endif // UMSPODCASTMETA_H diff --git a/amarok/src/core-impl/collections/umscollection/podcasts/UmsPodcastProvider.cpp b/amarok/src/core-impl/collections/umscollection/podcasts/UmsPodcastProvider.cpp deleted file mode 100644 index 425a97f0..00000000 --- a/amarok/src/core-impl/collections/umscollection/podcasts/UmsPodcastProvider.cpp +++ /dev/null @@ -1,554 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Bart Cerneels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ -#include "UmsPodcastProvider.h" -#include "core/support/Debug.h" - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -using namespace Podcasts; - -UmsPodcastProvider::UmsPodcastProvider( KUrl scanDirectory ) - : m_scanDirectory( scanDirectory ) - , m_deleteEpisodeAction( 0 ) - , m_deleteChannelAction( 0 ) -{ - -} - -UmsPodcastProvider::~UmsPodcastProvider() -{ - -} - -bool -UmsPodcastProvider::possiblyContainsTrack( const KUrl &url ) const -{ - Q_UNUSED( url ) - return false; -} - -Meta::TrackPtr -UmsPodcastProvider::trackForUrl( const KUrl &url ) -{ - Q_UNUSED( url ) - return Meta::TrackPtr(); -} - -PodcastEpisodePtr -UmsPodcastProvider::episodeForGuid( const QString &guid ) -{ - Q_UNUSED( guid ) - return PodcastEpisodePtr(); -} - -void -UmsPodcastProvider::addPodcast( const KUrl &url ) -{ - Q_UNUSED( url ); -} - -PodcastChannelPtr -UmsPodcastProvider::addChannel( PodcastChannelPtr channel ) -{ - UmsPodcastChannelPtr umsChannel = UmsPodcastChannelPtr( - new UmsPodcastChannel( channel, this ) ); - m_umsChannels << umsChannel; - - emit playlistAdded( Playlists::PlaylistPtr( umsChannel.data() ) ); - return PodcastChannelPtr( umsChannel.data() ); -} - -PodcastEpisodePtr -UmsPodcastProvider::addEpisode( PodcastEpisodePtr episode ) -{ - KUrl localFilePath = episode->playableUrl(); - if( !localFilePath.isLocalFile() ) - return PodcastEpisodePtr(); - - KUrl destination = KUrl( m_scanDirectory ); - destination.addPath( Amarok::vfatPath( episode->channel()->prettyName() ) ); - KIO::mkdir( destination ); - destination.addPath( Amarok::vfatPath( localFilePath.fileName() ) ); - - debug() << QString( "Copy episode \"%1\" to %2" ).arg( localFilePath.path()) - .arg( destination.path() ); - KIO::FileCopyJob *copyJob = KIO::file_copy( localFilePath, destination ); - connect( copyJob, SIGNAL(result(KJob*)), SLOT(slotCopyComplete(KJob*)) ); - copyJob->start(); - //we have not copied the data over yet so we can't return an episode yet - //TODO: return a proxy for the episode we are still copying. - return PodcastEpisodePtr(); -} - -void -UmsPodcastProvider::slotCopyComplete( KJob *job ) -{ - KIO::FileCopyJob *copyJob = dynamic_cast( job ); - if( !copyJob ) - return; - - KUrl localFilePath = copyJob->destUrl(); - MetaFile::Track *fileTrack = new MetaFile::Track( localFilePath ); - - UmsPodcastEpisodePtr umsEpisode = addFile( MetaFile::TrackPtr( fileTrack ) ); -} - -PodcastChannelList -UmsPodcastProvider::channels() -{ - return UmsPodcastChannel::toPodcastChannelList( m_umsChannels ); -} - -void -UmsPodcastProvider::removeSubscription( PodcastChannelPtr channel ) -{ - UmsPodcastChannelPtr umsChannel = UmsPodcastChannelPtr::dynamicCast( channel ); - if( umsChannel.isNull() ) - { - error() << "trying to remove a podcast channel of the wrong type"; - return; - } - - if( !m_umsChannels.contains( umsChannel ) ) - { - error() << "trying to remove a podcast channel that is not in the list"; - return; - } - - m_umsChannels.removeAll( umsChannel ); -} - -void -UmsPodcastProvider::configureProvider() -{ -} - -void -UmsPodcastProvider::configureChannel( PodcastChannelPtr channel ) -{ - Q_UNUSED( channel ); -} - -QString -UmsPodcastProvider::prettyName() const -{ - return i18nc( "Podcasts on a media device", "Podcasts on %1", QString("TODO: replace me") ); -} - -KIcon -UmsPodcastProvider::icon() const -{ - return KIcon("drive-removable-media-usb-pendrive"); -} - -Playlists::PlaylistList -UmsPodcastProvider::playlists() -{ - Playlists::PlaylistList playlists; - foreach( UmsPodcastChannelPtr channel, m_umsChannels ) - playlists << Playlists::PlaylistPtr::dynamicCast( channel ); - return playlists; -} - -QActionList -UmsPodcastProvider::episodeActions( PodcastEpisodeList episodes ) -{ - QActionList actions; - if( episodes.isEmpty() ) - return actions; - - if( m_deleteEpisodeAction == 0 ) - { - m_deleteEpisodeAction = new QAction( KIcon( "edit-delete" ), i18n( "&Delete Episode" ), this ); - m_deleteEpisodeAction->setProperty( "popupdropper_svg_id", "delete" ); - connect( m_deleteEpisodeAction, SIGNAL(triggered()), SLOT(slotDeleteEpisodes()) ); - } - // set the episode list as data that we'll retrieve in the slot - m_deleteEpisodeAction->setData( QVariant::fromValue( episodes ) ); - actions << m_deleteEpisodeAction; - - return actions; -} - -void -UmsPodcastProvider::slotDeleteEpisodes() -{ - DEBUG_BLOCK - QAction *action = qobject_cast( QObject::sender() ); - if( action == 0 ) - return; - - //get the list of episodes to apply to, then clear that data. - PodcastEpisodeList episodes = - action->data().value(); - action->setData( QVariant() ); - - UmsPodcastEpisodeList umsEpisodes; - foreach( PodcastEpisodePtr episode, episodes ) - { - UmsPodcastEpisodePtr umsEpisode = - UmsPodcastEpisode::fromPodcastEpisodePtr( episode ); - if( !umsEpisode ) - { - error() << "Could not cast to UmsPodcastEpisode"; - continue; - } - - PodcastChannelPtr channel = umsEpisode->channel(); - if( !channel ) - { - error() << "episode did not have a valid channel"; - continue; - } - - UmsPodcastChannelPtr umsChannel = - UmsPodcastChannel::fromPodcastChannelPtr( channel ); - if( !umsChannel ) - { - error() << "Could not cast to UmsPodcastChannel"; - continue; - } - - umsEpisodes << umsEpisode; - } - - deleteEpisodes( umsEpisodes ); -} - -void -UmsPodcastProvider::deleteEpisodes( UmsPodcastEpisodeList umsEpisodes ) -{ - KUrl::List urlsToDelete; - foreach( UmsPodcastEpisodePtr umsEpisode, umsEpisodes ) - urlsToDelete << umsEpisode->playableUrl(); - - KDialog dialog; - dialog.setCaption( i18n( "Confirm Delete" ) ); - dialog.setButtons( KDialog::Ok | KDialog::Cancel ); - QLabel label( i18np( "Are you sure you want to delete this episode?", - "Are you sure you want to delete these %1 episodes?", - urlsToDelete.count() ) - , &dialog - ); - QListWidget listWidget( &dialog ); - listWidget.setSelectionMode( QAbstractItemView::NoSelection ); - foreach( const KUrl &url, urlsToDelete ) - { - new QListWidgetItem( url.toLocalFile(), &listWidget ); - } - - QWidget *widget = new QWidget( &dialog ); - QVBoxLayout *layout = new QVBoxLayout( widget ); - layout->addWidget( &label ); - layout->addWidget( &listWidget ); - dialog.setButtonText( KDialog::Ok, i18n( "Yes, delete from %1.", - QString("TODO: replace me") ) ); - - dialog.setMainWidget( widget ); - if( dialog.exec() != QDialog::Accepted ) - return; - - KIO::DeleteJob *deleteJob = KIO::del( urlsToDelete, KIO::HideProgressInfo ); - - //keep track of these episodes until the job is done - m_deleteJobMap.insert( deleteJob, umsEpisodes ); - - connect( deleteJob, SIGNAL(result(KJob*)), - SLOT(deleteJobComplete(KJob*)) ); -} - -void -UmsPodcastProvider::deleteJobComplete( KJob *job ) -{ - DEBUG_BLOCK - if( job->error() ) - { - error() << "problem deleting episode(s): " << job->errorString(); - return; - } - - UmsPodcastEpisodeList deletedEpisodes = m_deleteJobMap.take( job ); - foreach( UmsPodcastEpisodePtr deletedEpisode, deletedEpisodes ) - { - PodcastChannelPtr channel = deletedEpisode->channel(); - UmsPodcastChannelPtr umsChannel = - UmsPodcastChannel::fromPodcastChannelPtr( channel ); - if( !umsChannel ) - { - error() << "Could not cast to UmsPodcastChannel"; - continue; - } - - umsChannel->removeEpisode( deletedEpisode ); - if( umsChannel->m_umsEpisodes.isEmpty() ) - { - debug() << "channel is empty now, remove it"; - m_umsChannels.removeAll( umsChannel ); - emit( playlistRemoved( Playlists::PlaylistPtr::dynamicCast( umsChannel ) ) ); - } - } -} - -QActionList -UmsPodcastProvider::channelActions( PodcastChannelList channels ) -{ - QActionList actions; - if( channels.isEmpty() ) - return actions; - - if( m_deleteChannelAction == 0 ) - { - m_deleteChannelAction = new QAction( KIcon( "edit-delete" ), i18n( "&Delete " - "Channel and Episodes" ), this ); - m_deleteChannelAction->setProperty( "popupdropper_svg_id", "delete" ); - connect( m_deleteChannelAction, SIGNAL(triggered()), SLOT(slotDeleteChannels()) ); - } - // set the episode list as data that we'll retrieve in the slot - m_deleteChannelAction->setData( QVariant::fromValue( channels ) ); - actions << m_deleteChannelAction; - - return actions; -} - -void -UmsPodcastProvider::slotDeleteChannels() -{ - DEBUG_BLOCK - QAction *action = qobject_cast( QObject::sender() ); - if( action == 0 ) - return; - - //get the list of episodes to apply to, then clear that data. - PodcastChannelList channels = - action->data().value(); - action->setData( QVariant() ); - - foreach( PodcastChannelPtr channel, channels ) - { - UmsPodcastChannelPtr umsChannel = - UmsPodcastChannel::fromPodcastChannelPtr( channel ); - if( !umsChannel ) - { - error() << "Could not cast to UmsPodcastChannel"; - continue; - } - - deleteEpisodes( umsChannel->m_umsEpisodes ); - //slot deleteJobComplete() will emit signal once all tracks are gone. - } -} - -QActionList -UmsPodcastProvider::playlistActions( const Playlists::PlaylistList &playlists ) -{ - PodcastChannelList channels; - foreach( const Playlists::PlaylistPtr &playlist, playlists ) - { - PodcastChannelPtr channel = PodcastChannelPtr::dynamicCast( playlist ); - if( channel ) - channels << channel; - } - - return channelActions( channels ); -} - -QActionList -UmsPodcastProvider::trackActions( const QMultiHash &playlistTracks ) -{ - PodcastEpisodeList episodes; - foreach( const Playlists::PlaylistPtr &playlist, playlistTracks.uniqueKeys() ) - { - PodcastChannelPtr channel = PodcastChannelPtr::dynamicCast( playlist ); - if( !channel ) - continue; - - PodcastEpisodeList channelEpisodes = channel->episodes(); - QList trackPositions = playlistTracks.values( playlist ); - qSort( trackPositions ); - foreach( int trackPosition, trackPositions ) - { - if( trackPosition >= 0 && trackPosition < channelEpisodes.count() ) - episodes << channelEpisodes.at( trackPosition ); - } - } - - return episodeActions( episodes ); -} - -void -UmsPodcastProvider::completePodcastDownloads() -{ - -} - -void -UmsPodcastProvider::updateAll() //slot -{ -} - -void -UmsPodcastProvider::update( Podcasts::PodcastChannelPtr channel ) //slot -{ - Q_UNUSED( channel ); -} - -void -UmsPodcastProvider::downloadEpisode( Podcasts::PodcastEpisodePtr episode ) //slot -{ - Q_UNUSED( episode ); -} - -void -UmsPodcastProvider::deleteDownloadedEpisode( Podcasts::PodcastEpisodePtr episode ) //slot -{ - Q_UNUSED( episode ); -} - -void -UmsPodcastProvider::slotUpdated() //slot -{ - -} - -void -UmsPodcastProvider::scan() -{ - if( m_scanDirectory.isEmpty() ) - return; - m_dirList.clear(); - debug() << "scan directory for podcasts: " << - m_scanDirectory.toLocalFile( KUrl::AddTrailingSlash ); - QDirIterator it( m_scanDirectory.toLocalFile(), QDirIterator::Subdirectories ); - while( it.hasNext() ) - addPath( it.next() ); -} - -int -UmsPodcastProvider::addPath( const QString &path ) -{ - DEBUG_BLOCK - int acc = 0; - debug() << path; - KMimeType::Ptr mime = KMimeType::findByFileContent( path, &acc ); - if( !mime || mime->name() == KMimeType::defaultMimeType() ) - { - debug() << "Trying again with findByPath:" ; - mime = KMimeType::findByPath( path, 0, true, &acc ); - if( mime->name() == KMimeType::defaultMimeType() ) - return 0; - } - debug() << "Got type: " << mime->name() << ", with accuracy: " << acc; - - QFileInfo info( path ); - if( info.isDir() ) - { - if( m_dirList.contains( path ) ) - return 0; - m_dirList << info.canonicalPath(); - return 1; - } - else if( info.isFile() ) - { -// foreach( const QString &mimetype, m_handler->mimetypes() ) -// { -// if( mime->is( mimetype ) ) -// { - addFile( MetaFile::TrackPtr( new MetaFile::Track( - KUrl( info.canonicalFilePath() ) ) ) ); - return 2; -// } -// } - } - - return 0; -} - -UmsPodcastEpisodePtr -UmsPodcastProvider::addFile( MetaFile::TrackPtr metafileTrack ) -{ - DEBUG_BLOCK - debug() << metafileTrack->playableUrl().url(); - debug() << "album: " << metafileTrack->album()->name(); - debug() << "title: " << metafileTrack->name(); - if( metafileTrack->album()->name().isEmpty() ) - { - debug() << "Can't figure out channel without album tag."; - return UmsPodcastEpisodePtr(); - } - - if( metafileTrack->name().isEmpty() ) - { - debug() << "Can not use a track without a title."; - return UmsPodcastEpisodePtr(); - } - - //see if there is already a UmsPodcastEpisode for this track - UmsPodcastChannelPtr channel; - UmsPodcastEpisodePtr episode; - - foreach( UmsPodcastChannelPtr c, m_umsChannels ) - { - if( c->name() == metafileTrack->album()->name() ) - { - channel = c; - break; - } - } - - if( channel ) - { - foreach( UmsPodcastEpisodePtr e, channel->umsEpisodes() ) - { - if( e->title() == metafileTrack->name() ) - { - episode = e; - break; - } - } - } - else - { - debug() << "there is no channel for this episode yet"; - channel = UmsPodcastChannelPtr( new UmsPodcastChannel( this ) ); - channel->setTitle( metafileTrack->album()->name() ); - m_umsChannels << channel; - emit playlistAdded( Playlists::PlaylistPtr( channel.data() ) ); - } - - if( episode.isNull() ) - { - debug() << "this episode was not found in an existing channel"; - episode = UmsPodcastEpisodePtr( new UmsPodcastEpisode( channel ) ); - episode->setLocalFile( metafileTrack ); - - channel->addUmsEpisode( episode ); - } - - episode->setLocalFile( metafileTrack ); - - return episode; -} diff --git a/amarok/src/core-impl/collections/umscollection/podcasts/UmsPodcastProvider.h b/amarok/src/core-impl/collections/umscollection/podcasts/UmsPodcastProvider.h deleted file mode 100644 index 18f29f68..00000000 --- a/amarok/src/core-impl/collections/umscollection/podcasts/UmsPodcastProvider.h +++ /dev/null @@ -1,101 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Bart Cerneels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef UMSPODCASTPROVIDER_H -#define UMSPODCASTPROVIDER_H - -#include "core/podcasts/PodcastProvider.h" -#include "UmsPodcastMeta.h" - -class KJob; - -namespace Podcasts { - -class UmsPodcastProvider : public PodcastProvider -{ - Q_OBJECT - public: - UmsPodcastProvider( KUrl scanDirectory ); - ~UmsPodcastProvider(); - - UmsPodcastEpisodePtr addFile( MetaFile::TrackPtr metafileTrack ); - int addPath( const QString &path ); - - virtual bool possiblyContainsTrack( const KUrl &url ) const; - virtual Meta::TrackPtr trackForUrl( const KUrl &url ); - - virtual Podcasts::PodcastEpisodePtr episodeForGuid( const QString &guid ); - - virtual void addPodcast( const KUrl &url ); - - virtual Podcasts::PodcastChannelPtr addChannel( Podcasts::PodcastChannelPtr channel ); - virtual Podcasts::PodcastEpisodePtr addEpisode( Podcasts::PodcastEpisodePtr episode ); - - virtual Podcasts::PodcastChannelList channels(); - - virtual void removeSubscription( Podcasts::PodcastChannelPtr channel ); - - virtual void configureProvider(); - virtual void configureChannel( Podcasts::PodcastChannelPtr channel ); - - // PlaylistProvider methods - virtual QString prettyName() const; - virtual KIcon icon() const; - - virtual Playlists::PlaylistList playlists(); - - virtual QActionList playlistActions( const Playlists::PlaylistList &playlists ); - virtual QActionList trackActions( const QMultiHash &playlistTracks ); - - virtual void completePodcastDownloads(); - - public slots: - virtual void updateAll(); - virtual void update( Podcasts::PodcastChannelPtr channel ); - virtual void downloadEpisode( Podcasts::PodcastEpisodePtr episode ); - virtual void deleteDownloadedEpisode( Podcasts::PodcastEpisodePtr episode ); - virtual void slotUpdated(); - virtual void scan(); - - signals: - void updated(); - - private slots: - void slotDeleteEpisodes(); - void slotDeleteChannels(); - void deleteJobComplete( KJob *job ); - void slotCopyComplete( KJob *job ); - - private: - QList episodeActions( Podcasts::PodcastEpisodeList ); - QList channelActions( Podcasts::PodcastChannelList ); - void deleteEpisodes( UmsPodcastEpisodeList umsEpisodes ); - - KUrl m_scanDirectory; - QStringList m_dirList; - - UmsPodcastChannelList m_umsChannels; - - QAction *m_deleteEpisodeAction; //delete a downloaded Episode - QAction *m_deleteChannelAction; //delete a everything from one channel - QList m_providerActions; - - QMap m_deleteJobMap; -}; - -} //namespace Podcasts - -#endif // UMSPODCASTPROVIDER_H diff --git a/amarok/src/core-impl/collections/upnpcollection/CMakeLists.txt b/amarok/src/core-impl/collections/upnpcollection/CMakeLists.txt deleted file mode 100644 index 6be9e23d..00000000 --- a/amarok/src/core-impl/collections/upnpcollection/CMakeLists.txt +++ /dev/null @@ -1,47 +0,0 @@ -include_directories( ../.. - ${CMAKE_CURRENT_BINARY_DIR}/../.. - ${AMAROK_COLLECTION_SUPPORT_DIR} - ${KDE4_INCLUDE_DIR} - ${QT_INCLUDES} -) - - -########### next target ############### - -set(amarok_collection-upnpcollection_PART_SRCS - dbuscodec.cpp - UpnpCollectionBase.cpp - UpnpBrowseCollection.cpp - UpnpSearchCollection.cpp - UpnpCollectionFactory.cpp - UpnpMemoryQueryMaker.cpp - UpnpQueryMaker.cpp - UpnpQueryMakerInternal.cpp - UpnpMeta.cpp - UpnpCache.cpp - UpnpQuery.cpp -) - - -kde4_add_plugin(amarok_collection-upnpcollection ${amarok_collection-upnpcollection_PART_SRCS}) - -target_link_libraries( - amarok_collection-upnpcollection - amarokcore - amaroklib - ${KDE4_THREADWEAVER_LIBS} - ${KDE4_KDEUI_LIBS} - ${KDE4_KIO_LIBS} - ${KDE4_SOLID_LIBS} -) - -if(APPLE) - SET_TARGET_PROPERTIES(amarok_collection-upnpcollection PROPERTIES LINK_FLAGS "-undefined dynamic_lookup") -endif(APPLE) - -install(TARGETS amarok_collection-upnpcollection DESTINATION ${PLUGIN_INSTALL_DIR} ) - - -########### install files ############### - -install( FILES amarok_collection-upnpcollection.desktop DESTINATION ${SERVICES_INSTALL_DIR}) diff --git a/amarok/src/core-impl/collections/upnpcollection/NOTES b/amarok/src/core-impl/collections/upnpcollection/NOTES deleted file mode 100644 index 680d6e65..00000000 --- a/amarok/src/core-impl/collections/upnpcollection/NOTES +++ /dev/null @@ -1,7 +0,0 @@ -upnptypes.h belongs to kio-upnp-ms, but is copied here -since we want a run time and not compile time check -of the upnp slave being present. - -Once the slave is part of kdebase-runtime, this can be removed -since we can be sure the file will exist when kdebase -is installed. diff --git a/amarok/src/core-impl/collections/upnpcollection/UpnpBrowseCollection.cpp b/amarok/src/core-impl/collections/upnpcollection/UpnpBrowseCollection.cpp deleted file mode 100644 index 9bd45f39..00000000 --- a/amarok/src/core-impl/collections/upnpcollection/UpnpBrowseCollection.cpp +++ /dev/null @@ -1,292 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Nikhil Marathe * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "UpnpBrowseCollection" - -#include "UpnpBrowseCollection.h" - -#include "core/interfaces/Logger.h" -#include "core/support/Components.h" -#include "core/support/Debug.h" -#include "MemoryQueryMaker.h" - -#include "UpnpMemoryQueryMaker.h" -#include "UpnpQueryMaker.h" -#include "UpnpMeta.h" -#include "UpnpCache.h" - -#include -#include -#include -#include - -#include -#include -#include "upnptypes.h" -#include -#include - -using namespace Meta; - -namespace Collections { - -//UpnpBrowseCollection - -// TODO register for the device bye bye and emit remove() -UpnpBrowseCollection::UpnpBrowseCollection( const DeviceInfo& dev ) - : UpnpCollectionBase( dev ) - , m_mc( new MemoryCollection() ) - , m_fullScanInProgress( false ) - , m_cache( new UpnpCache( this ) ) -{ - DEBUG_BLOCK - - // experimental code, will probably be moved to a better place - OrgKdeKDirNotifyInterface *notify = new OrgKdeKDirNotifyInterface("", "", QDBusConnection::sessionBus(), this ); - connect( notify, SIGNAL(FilesChanged(QStringList)), SLOT(slotFilesChanged(QStringList)) ); -} - -UpnpBrowseCollection::~UpnpBrowseCollection() -{ -} - -void UpnpBrowseCollection::slotFilesChanged(const QStringList &list ) -{ - if( m_fullScanInProgress ) - return; - - m_updateQueue += list; - - debug() << "Files changed" << list; -} - -void UpnpBrowseCollection::processUpdates() -{ - if( m_updateQueue.isEmpty() ) - return; - - QString urlString = m_updateQueue.dequeue(); - debug() << "Update URL is" << urlString; - invalidateTracksIn( urlString ); - KUrl url( urlString ); - if( url.scheme() != "upnp-ms" || m_device.uuid() != url.host() ) - return; - debug() << "Now incremental scanning" << url; - startIncrementalScan( url.path() ); -} - -void UpnpBrowseCollection::invalidateTracksIn( const QString &dir ) -{ - debug() << "INVALIDATING" << m_tracksInContainer[dir].length(); - - /* - * when we get dir as / a / b we also have to invalidate - * any tracks in / a / b / * so we need to iterate over keys - * If performance is really affected we can use some - * kind of a prefix tree instead of a hash. - */ - foreach( const QString &key, m_tracksInContainer.keys() ) { - if( key.startsWith( dir ) ) { - debug() << key << " matches " << dir; - foreach( TrackPtr track, m_tracksInContainer[dir] ) { - removeTrack( track ); - } - } - } - m_tracksInContainer.remove( dir ); -} - -void -UpnpBrowseCollection::startFullScan() -{ - DEBUG_BLOCK; - - // TODO probably set abort slot - // TODO figure out what to do with the total steps - Amarok::Components::logger()->newProgressOperation( this, i18n( "Scanning %1", prettyName() ) ); - - startIncrementalScan( "/" ); - - m_fullScanInProgress = true; - m_fullScanTimer = new QTimer( this ); - Q_ASSERT( - connect( m_fullScanTimer, - SIGNAL(timeout()), - this, - SLOT(updateMemoryCollection()) ) - ); - m_fullScanTimer->start(5000); -} - -void -UpnpBrowseCollection::startIncrementalScan( const QString &directory ) -{ - if( m_fullScanInProgress ) { - debug() << "Full scan in progress, aborting"; - return; - } - debug() << "Scanning directory" << directory; - KUrl url; - url.setScheme( "upnp-ms" ); - url.setHost( m_device.uuid() ); - url.setPath( directory ); - KIO::ListJob *listJob = KIO::listRecursive( url, KIO::HideProgressInfo ); - addJob( listJob ); - Q_ASSERT( connect( listJob, SIGNAL(entries(KIO::Job*,KIO::UDSEntryList)), - this, SLOT(entries(KIO::Job*,KIO::UDSEntryList)), Qt::UniqueConnection ) ); - Q_ASSERT( connect( listJob, SIGNAL(result(KJob*)), - this, SLOT(done(KJob*)), Qt::UniqueConnection ) ); - listJob->start(); - -} - -void -UpnpBrowseCollection::entries( KIO::Job *job, const KIO::UDSEntryList &list ) -{ - DEBUG_BLOCK; - int count = 0; - KIO::SimpleJob *sj = static_cast( job ); - foreach( const KIO::UDSEntry &entry, list ) { - if( entry.contains( KIO::UPNP_CLASS ) - && entry.stringValue( KIO::UPNP_CLASS ).startsWith( "object.item.audioItem" ) ) { - createTrack( entry, sj->url().prettyUrl() ); - } - count++; - emit totalSteps( count ); - emit incrementProgress(); - } - updateMemoryCollection(); -} - -void -UpnpBrowseCollection::updateMemoryCollection() -{ - memoryCollection()->setTrackMap( m_cache->tracks() ); - memoryCollection()->setArtistMap( m_cache->artists() ); - memoryCollection()->setAlbumMap( m_cache->albums() ); - memoryCollection()->setGenreMap( m_cache->genres() ); - memoryCollection()->setYearMap( m_cache->years() ); - emit updated(); -} - -void -UpnpBrowseCollection::createTrack( const KIO::UDSEntry &entry, const QString &baseUrl ) -{ -DEBUG_BLOCK - TrackPtr t = m_cache->getTrack( entry ); - - QFileInfo info( entry.stringValue( KIO::UDSEntry::UDS_NAME ) ); - QString container = QDir(baseUrl).filePath( info.dir().path() ); - debug() << "CONTAINER" << container; - m_tracksInContainer[container] << t; -} - -void -UpnpBrowseCollection::removeTrack( TrackPtr t ) -{ - m_cache->removeTrack( t ); -} - -void -UpnpBrowseCollection::done( KJob *job ) -{ -DEBUG_BLOCK - if( job->error() ) - { - Amarok::Components::logger()->longMessage( i18n("UPnP Error: %1", job->errorString() ), - Amarok::Logger::Error ); - return; - } - updateMemoryCollection(); - if( m_fullScanInProgress ) - { - m_fullScanTimer->stop(); - m_fullScanInProgress = false; - emit endProgressOperation( this ); - debug() << "Full Scan done"; - } - - // process new updates if any - // this is the only place processUpdates() - // should be called since a full scan at the very beginning - // will always call done(). - processUpdates(); -} - -bool -UpnpBrowseCollection::hasCapabilityInterface( Capabilities::Capability::Type type ) const -{ - return ( type == Capabilities::Capability::CollectionScan ); -} - -Capabilities::Capability* -UpnpBrowseCollection::createCapabilityInterface( Capabilities::Capability::Type type ) -{ - if( type == Capabilities::Capability::CollectionScan ) - return new UpnpBrowseCollectionScanCapability( this ); - else - return 0; -} - -QueryMaker* -UpnpBrowseCollection::queryMaker() -{ - DEBUG_BLOCK; - UpnpMemoryQueryMaker *umqm = new UpnpMemoryQueryMaker(m_mc.toWeakRef(), collectionId() ); - Q_ASSERT( connect( umqm, SIGNAL(startFullScan()), this, SLOT(startFullScan()) ) ); - return umqm; -} - -Meta::TrackPtr -UpnpBrowseCollection::trackForUrl( const KUrl &url ) -{ - debug() << "TRACK FOR URL " << url; - if( url.scheme() == "upnptrack" && url.host() == collectionId() ) - return m_cache->tracks()[url.url()]; - debug() << "NONE FOUND"; - return Collection::trackForUrl( url ); -} - -// ---------- CollectionScanCapability ------------ - -UpnpBrowseCollectionScanCapability::UpnpBrowseCollectionScanCapability( UpnpBrowseCollection* collection ) - : m_collection( collection ) -{ } - -UpnpBrowseCollectionScanCapability::~UpnpBrowseCollectionScanCapability() -{ } - -void -UpnpBrowseCollectionScanCapability::startFullScan() -{ - m_collection->startFullScan(); -} - -void -UpnpBrowseCollectionScanCapability::startIncrementalScan( const QString &directory ) -{ - m_collection->startIncrementalScan( directory ); -} - -void -UpnpBrowseCollectionScanCapability::stopScan() -{ - // the UpnpBrowseCollection does not yet know how to stop a scan -} - -} //~ namespace -#include "moc_UpnpBrowseCollection.cpp" - diff --git a/amarok/src/core-impl/collections/upnpcollection/UpnpBrowseCollection.h b/amarok/src/core-impl/collections/upnpcollection/UpnpBrowseCollection.h deleted file mode 100644 index 3c526960..00000000 --- a/amarok/src/core-impl/collections/upnpcollection/UpnpBrowseCollection.h +++ /dev/null @@ -1,121 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Nikhil Marathe * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef UPNPBROWSECOLLECTION_H -#define UPNPBROWSECOLLECTION_H - -#include "UpnpCollectionBase.h" -#include "MemoryCollection.h" -#include "core/capabilities/CollectionScanCapability.h" - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -namespace KIO { - class Job; - class ListJob; -} -class KJob; - -class QTimer; - -namespace Collections { - -class UpnpCache; -class UpnpMemoryQueryMaker; - -class UpnpBrowseCollection : public UpnpCollectionBase -{ - Q_OBJECT - public: - UpnpBrowseCollection( const DeviceInfo& ); - virtual ~UpnpBrowseCollection(); - - virtual QueryMaker* queryMaker(); - - virtual bool hasCapabilityInterface( Capabilities::Capability::Type type ) const; - virtual Capabilities::Capability* createCapabilityInterface( Capabilities::Capability::Type type ); - - Meta::TrackPtr trackForUrl( const KUrl &url ); - virtual KIcon icon() const { return KIcon("network-server"); } - - QSharedPointer memoryCollection() const { return m_mc; } - - signals: - void incrementProgress(); - void totalSteps( int ); - void endProgressOperation( QObject * ); - - public slots: - virtual void startFullScan(); - virtual void startIncrementalScan( const QString &directory = QString() ); - - private slots: - void entries( KIO::Job *, const KIO::UDSEntryList& ); - void done( KJob * ); - void createTrack( const KIO::UDSEntry &, const QString &baseUrl ); - void removeTrack( Meta::TrackPtr t ); - void invalidateTracksIn( const QString &dir ); - void updateMemoryCollection(); - void slotFilesChanged(const QStringList &); - void processUpdates(); - - private: - QSharedPointer m_mc; - - QTimer *m_fullScanTimer; - bool m_fullScanInProgress; - - // associates each track with its UPNP Parent - // when a update occurs on a - // invalidate all tracks, and rescan - // it remains to be seen how badly this - // affects performance or memory - QHash m_tracksInContainer; - - QQueue m_updateQueue; - - UpnpCache *m_cache; -}; - -class UpnpBrowseCollectionScanCapability : public Capabilities::CollectionScanCapability -{ - Q_OBJECT - public: - UpnpBrowseCollectionScanCapability( UpnpBrowseCollection* collection ); - virtual ~UpnpBrowseCollectionScanCapability(); - - virtual void startFullScan(); - virtual void startIncrementalScan( const QString &directory = QString() ); - virtual void stopScan(); - - private: - UpnpBrowseCollection *m_collection; -}; - - -} //namespace Collections - -#endif diff --git a/amarok/src/core-impl/collections/upnpcollection/UpnpCache.cpp b/amarok/src/core-impl/collections/upnpcollection/UpnpCache.cpp deleted file mode 100644 index b87b72f2..00000000 --- a/amarok/src/core-impl/collections/upnpcollection/UpnpCache.cpp +++ /dev/null @@ -1,177 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Nikhil Marathe * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ***************************************************************************************/ -#include "UpnpCache.h" - -#include - -#include -#include "upnptypes.h" - -#include "UpnpMeta.h" -#include "UpnpCollectionBase.h" - -// TODO : move this to CollectionBase -static qint64 duration( QString duration ) { - if( duration.isEmpty() ) - return 0; - - QStringList parts = duration.split( ':' ); - int hours = parts.takeFirst().toInt(); - int minutes = parts.takeFirst().toInt(); - QString rest = parts.takeFirst(); - int seconds = 0; - int mseconds = 0; - if( rest.contains( '.' ) ) { - int dotIndex = rest.indexOf( "." ); - seconds = rest.left( dotIndex ).toInt(); - QString frac = rest.mid( dotIndex + 1 ); - if( frac.contains( '/' ) ) { - int slashIndex = frac.indexOf( '/' ); - int num = frac.left( frac.indexOf( '/' ) ).toInt(); - int den = frac.mid( slashIndex + 1 ).toInt(); - mseconds = num * 1000 / den; - } - else { - mseconds = QString( '.' + frac ).toFloat() * 1000; - } - } - else { - seconds = rest.toInt(); - } - - return hours * 60 * 60 * 1000 - + minutes * 60 * 1000 - + seconds * 1000 - + mseconds; -} - -namespace Collections { - -UpnpCache::UpnpCache( UpnpCollectionBase* collection ) - : m_collection( collection ) -{ -} - -Meta::TrackPtr UpnpCache::getTrack( const KIO::UDSEntry &entry, bool refresh ) -{ - QMutexLocker lock( &m_cacheMutex ); - - // a little indirection to get the nicely formatted track uidUrl - Meta::UpnpTrackPtr track( new Meta::UpnpTrack( m_collection ) ); - track->setUidUrl( entry.stringValue( KIO::UPNP_ID ) ); - - // if we have a reference ID search for that - // in either case the original ID (refID) becomes our UID URL instead of the UPNP_ID - if( entry.contains( KIO::UPNP_REF_ID ) ) { - track->setUidUrl( entry.stringValue( KIO::UPNP_REF_ID ) ); - } - - QString uidUrl = track->uidUrl(); - if( m_trackMap.contains( uidUrl ) && !refresh ) { - return m_trackMap[uidUrl]; - } - - // UDS_NAME is the plain ASCII, relative path prefixed name - // but UDS_DISPLAY_NAME is the unicode, 'file' name. - track->setTitle( entry.stringValue( KIO::UDSEntry::UDS_DISPLAY_NAME ) ); - track->setPlayableUrl( entry.stringValue(KIO::UDSEntry::UDS_TARGET_URL) ); - track->setTrackNumber( entry.stringValue(KIO::UPNP_TRACK_NUMBER).toInt() ); - // TODO validate and then convert to kbps - track->setBitrate( entry.stringValue( KIO::UPNP_BITRATE ).toInt() / 1024 ); - track->setLength( duration( entry.stringValue( KIO::UPNP_DURATION ) ) ); - - Meta::UpnpArtistPtr artist = Meta::UpnpArtistPtr::staticCast( getArtist( entry.stringValue( KIO::UPNP_ARTIST ) ) ); - artist->addTrack( track ); - track->setArtist( artist ); - - Meta::UpnpAlbumPtr album = Meta::UpnpAlbumPtr::staticCast( getAlbum( entry.stringValue( KIO::UPNP_ALBUM ), artist->name() ) ); - album->setAlbumArtist( artist ); - album->addTrack( track ); - track->setAlbum( album ); - // album art - if( ! album->imageLocation().isValid() ) - album->setAlbumArtUrl( entry.stringValue( KIO::UPNP_ALBUMART_URI ) ); - - Meta::UpnpGenrePtr genre = Meta::UpnpGenrePtr::staticCast( getGenre( entry.stringValue( KIO::UPNP_GENRE ) ) ); - genre->addTrack( track ); - track->setGenre( genre ); - - - // TODO this is plain WRONG! the UPNP_DATE will not have year of the album - // it will have year of addition to the collection - //QString yearStr = yearForDate( entry.stringValue( KIO::UPNP_DATE ) ); - // - //Meta::UpnpYearPtr year = Meta::UpnpYearPtr::staticCast( getYear( yearStr ) ); - //year->addTrack( track ); - //track->setYear( year ); - - m_trackMap.insert( uidUrl, Meta::TrackPtr::staticCast( track ) ); - return Meta::TrackPtr::staticCast( track ); -} - -Meta::ArtistPtr UpnpCache::getArtist( const QString& name ) -{ - if( m_artistMap.contains( name ) ) - return m_artistMap[name]; - - Meta::UpnpArtistPtr artist( new Meta::UpnpArtist( name ) ); - m_artistMap.insert( name, Meta::ArtistPtr::staticCast( artist ) ); - return m_artistMap[name]; -} - -Meta::AlbumPtr UpnpCache::getAlbum(const QString& name, const QString &artist ) -{ - if( m_albumMap.contains( name, artist ) ) - return m_albumMap.value( name, artist ); - - Meta::UpnpAlbumPtr album( new Meta::UpnpAlbum( name ) ); - album->setAlbumArtist( Meta::UpnpArtistPtr::staticCast( getArtist( artist ) ) ); - m_albumMap.insert( Meta::AlbumPtr::staticCast( album ) ); - return Meta::AlbumPtr::staticCast( album ); -} - -Meta::GenrePtr UpnpCache::getGenre(const QString& name) -{ - if( m_genreMap.contains( name ) ) - return m_genreMap[name]; - - Meta::UpnpGenrePtr genre( new Meta::UpnpGenre( name ) ); - m_genreMap.insert( name, Meta::GenrePtr::staticCast( genre ) ); - return m_genreMap[name]; -} - -Meta::YearPtr UpnpCache::getYear(int name) -{ - if( m_yearMap.contains( name ) ) - return m_yearMap[name]; - - Meta::UpnpYearPtr year( new Meta::UpnpYear( name ) ); - m_yearMap.insert( name, Meta::YearPtr::staticCast( year ) ); - return m_yearMap[name]; -} - -void UpnpCache::removeTrack( Meta::TrackPtr t ) -{ -#define DOWNCAST( Type, item ) Meta::Upnp##Type##Ptr::staticCast( item ) - Meta::UpnpTrackPtr track = DOWNCAST( Track, t ); - DOWNCAST( Artist, m_artistMap[ track->artist()->name() ] )->removeTrack( track ); - DOWNCAST( Album, m_albumMap.value( track->album() ) )->removeTrack( track ); - DOWNCAST( Genre, m_genreMap[ track->genre()->name() ] )->removeTrack( track ); - DOWNCAST( Year, m_yearMap[ track->year()->year() ] )->removeTrack( track ); -#undef DOWNCAST - m_trackMap.remove( track->uidUrl() ); -} -} diff --git a/amarok/src/core-impl/collections/upnpcollection/UpnpCache.h b/amarok/src/core-impl/collections/upnpcollection/UpnpCache.h deleted file mode 100644 index 0736cea4..00000000 --- a/amarok/src/core-impl/collections/upnpcollection/UpnpCache.h +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Nikhil Marathe * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ***************************************************************************************/ -#ifndef UPNPCACHE_H -#define UPNPCACHE_H - -#include - -#include - -#include "core/meta/forward_declarations.h" -#include "core-impl/collections/support/MemoryCollection.h" - - -namespace Collections { - -class UpnpCollectionBase; - -class UpnpCache -{ -public: - UpnpCache( UpnpCollectionBase *collection ); - - Meta::TrackPtr getTrack( const KIO::UDSEntry &entry, bool refresh = false ); - Meta::ArtistPtr getArtist( const QString &name ); - Meta::AlbumPtr getAlbum( const QString& name, const QString& artist = QString() ); - Meta::GenrePtr getGenre( const QString &name ); - Meta::YearPtr getYear( int name ); - - void removeTrack( Meta::TrackPtr track ); - - TrackMap tracks() { return m_trackMap; } - ArtistMap artists() { return m_artistMap; } - AlbumMap albums() { return m_albumMap; } - GenreMap genres() { return m_genreMap; } - YearMap years() { return m_yearMap; } - -private: - TrackMap m_trackMap; - ArtistMap m_artistMap; - AlbumMap m_albumMap; - GenreMap m_genreMap; - YearMap m_yearMap; - - QMutex m_cacheMutex; - UpnpCollectionBase *m_collection; -}; - -} - -#endif // UPNPCACHE_H -// kate: indent-mode cstyle; space-indent on; indent-width 0; diff --git a/amarok/src/core-impl/collections/upnpcollection/UpnpCollectionBase.cpp b/amarok/src/core-impl/collections/upnpcollection/UpnpCollectionBase.cpp deleted file mode 100644 index 44eab7f0..00000000 --- a/amarok/src/core-impl/collections/upnpcollection/UpnpCollectionBase.cpp +++ /dev/null @@ -1,129 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Nikhil Marathe * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "UpnpCollectionBase" - -#include "UpnpCollectionBase.h" - -#include "upnptypes.h" -#include -#include -#include - -#include "core/support/Debug.h" - -namespace Collections { - -static const int MAX_JOB_FAILURES_BEFORE_ABORT = 5; - -UpnpCollectionBase::UpnpCollectionBase( const DeviceInfo& dev ) - : Collection() - , m_device( dev ) - , m_slave( 0 ) - , m_slaveConnected( false ) - , m_continuousJobFailureCount( 0 ) -{ - KIO::Scheduler::connect( SIGNAL(slaveError(KIO::Slave*,int,QString)), - this, SLOT(slotSlaveError(KIO::Slave*,int,QString)) ); - KIO::Scheduler::connect( SIGNAL(slaveConnected(KIO::Slave*)), - this, SLOT(slotSlaveConnected(KIO::Slave*)) ); - m_slave = KIO::Scheduler::getConnectedSlave( collectionId() ); -} - -UpnpCollectionBase::~UpnpCollectionBase() -{ - foreach( KIO::SimpleJob *job, m_jobSet ) - KIO::Scheduler::cancelJob( job ); - m_jobSet.clear(); - if( m_slave ) { - KIO::Scheduler::disconnectSlave( m_slave ); - m_slave = 0; - m_slaveConnected = false; - } -} - -QString UpnpCollectionBase::collectionId() const -{ - return QString("upnp-ms://") + m_device.uuid(); -} - -QString UpnpCollectionBase::prettyName() const -{ - return m_device.friendlyName(); -} - -bool UpnpCollectionBase::possiblyContainsTrack( const KUrl &url ) const -{ - if( url.scheme() == "upnp-ms" ) -// && url.host() == m_device.host() -// && url.port() == m_device.port() ) - return true; - return false; -} - -void UpnpCollectionBase::addJob( KIO::SimpleJob *job ) -{ - connect( job, SIGNAL(result(KJob*)), this, SLOT(slotRemoveJob(KJob*)) ); - m_jobSet.insert( job ); - KIO::Scheduler::assignJobToSlave( m_slave, job ); -} - -void UpnpCollectionBase::slotRemoveJob(KJob* job) -{ - KIO::SimpleJob *sj = static_cast( job ); - - m_jobSet.remove( sj ); - - if( sj->error() ) { - m_continuousJobFailureCount++; - if( m_continuousJobFailureCount >= MAX_JOB_FAILURES_BEFORE_ABORT ) { - debug() << prettyName() << "Had" << m_continuousJobFailureCount << "continuous job failures, something wrong with the device. Removing this collection."; - emit remove(); - } - } - else { - m_continuousJobFailureCount = 0; - } -} - -void UpnpCollectionBase::slotSlaveError(KIO::Slave* slave, int err, const QString& msg) -{ - debug() << "SLAVE ERROR" << slave << err << msg; - if( m_slave != slave ) - return; - - if( err == KIO::ERR_COULD_NOT_CONNECT - || err == KIO::ERR_CONNECTION_BROKEN ) { - debug() << "COULD NOT CONNECT TO " << msg << "REMOVING THE COLLECTION"; - emit remove(); - } - - if( err == KIO::ERR_SLAVE_DIED ) { - m_slave = 0; - emit remove(); - } -} - -void UpnpCollectionBase::slotSlaveConnected(KIO::Slave* slave) -{ - if( m_slave != slave ) - return; - - debug() << "SLAVE IS CONNECTED"; - m_slaveConnected = true; -} - -} //namespace Collections diff --git a/amarok/src/core-impl/collections/upnpcollection/UpnpCollectionBase.h b/amarok/src/core-impl/collections/upnpcollection/UpnpCollectionBase.h deleted file mode 100644 index 74b64e20..00000000 --- a/amarok/src/core-impl/collections/upnpcollection/UpnpCollectionBase.h +++ /dev/null @@ -1,85 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Nikhil Marathe * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef UPNPCOLLECTIONBASE_H -#define UPNPCOLLECTIONBASE_H - -#include "core/collections/Collection.h" - -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "deviceinfo.h" - -namespace KIO { - class Slave; - class Job; - class SimpleJob; -} -class KJob; - -class QTimer; - -namespace Collections { - -class UpnpMemoryQueryMaker; - -/** - * UPnP Collections are of two types. - * If a MediaServer only supports the Browse() action - * a directory walking, recursive listing UpnpBrowseCollection - * is used. - * If a server also supports Search(), a more efficient, - * UpnpSearchCollection is used. - * Certain things are common to both, removal, - * track creation from the UDSEntry, collection identification, - */ -class UpnpCollectionBase : public Collections::Collection -{ - Q_OBJECT - public: - UpnpCollectionBase( const DeviceInfo& dev ); - virtual ~UpnpCollectionBase(); - void removeCollection() { emit remove(); } - - virtual QString collectionId() const; - virtual QString prettyName() const; - bool possiblyContainsTrack( const KUrl &url ) const; - - private slots: - void slotSlaveError( KIO::Slave *slave, int err, const QString &msg ); - void slotSlaveConnected( KIO::Slave *slave ); - void slotRemoveJob( KJob *job ); - protected: - void addJob( KIO::SimpleJob *job ); - //const Solid::Device m_device; - const DeviceInfo m_device; - KIO::Slave *m_slave; - bool m_slaveConnected; - QSet m_jobSet; - int m_continuousJobFailureCount; -}; - -} //namespace Collections - -#endif diff --git a/amarok/src/core-impl/collections/upnpcollection/UpnpCollectionFactory.cpp b/amarok/src/core-impl/collections/upnpcollection/UpnpCollectionFactory.cpp deleted file mode 100644 index 6d87e91e..00000000 --- a/amarok/src/core-impl/collections/upnpcollection/UpnpCollectionFactory.cpp +++ /dev/null @@ -1,259 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Nikhil Marathe * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "UpnpCollectionFactory" -#include "UpnpCollectionFactory.h" - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "core/support/Debug.h" -#include "UpnpBrowseCollection.h" -#include "UpnpSearchCollection.h" - -#include "dbuscodec.h" - -namespace Collections { - -AMAROK_EXPORT_COLLECTION( UpnpCollectionFactory, upnpcollection ) - -UpnpCollectionFactory::UpnpCollectionFactory( QObject *parent, const QVariantList &args ) - : Collections::CollectionFactory( parent, args ) -{ - m_info = KPluginInfo( "amarok_collection-upnpcollection.desktop", "services" ); - qRegisterMetaType(); - qDBusRegisterMetaType< QHash >(); - qDBusRegisterMetaType(); - qDBusRegisterMetaType(); -} - -UpnpCollectionFactory::~UpnpCollectionFactory() -{ -} - -void UpnpCollectionFactory::init() -{ - DEBUG_BLOCK - - if( !cagibi0_1_0Init( QDBusConnection::sessionBus() ) - && !cagibi0_1_0Init( QDBusConnection::systemBus() ) - && !cagibi0_2_0Init( QDBusConnection::sessionBus() ) - && !cagibi0_2_0Init( QDBusConnection::systemBus() ) ) - { - // we had problems with Cagibi - return; - } -} - -bool UpnpCollectionFactory::cagibi0_1_0Init( QDBusConnection bus ) -{ - bus.connect( "org.kde.Cagibi", - "/org/kde/Cagibi", - "org.kde.Cagibi", - "devicesAdded", - this, - SLOT(slotDeviceAdded(DeviceTypeMap)) ); - - bus.connect( "org.kde.Cagibi", - "/org/kde/Cagibi", - "org.kde.Cagibi", - "devicesRemoved", - this, - SLOT(slotDeviceRemoved(DeviceTypeMap)) ); - - m_iface = new QDBusInterface( "org.kde.Cagibi", - "/org/kde/Cagibi", - "org.kde.Cagibi", - bus, - this ); - - QDBusReply reply = m_iface->call( "allDevices" ); - if( !reply.isValid() ) - { - debug() << "ERROR" << reply.error().message(); - return false; - } - else - { - slotDeviceAdded( reply.value() ); - } - - //Solid::DeviceNotifier *notifier = Solid::DeviceNotifier::instance(); - //connect( notifier, SIGNAL(deviceAdded(QString)), this, SLOT(slotDeviceAdded(QString)) ); - //connect( notifier, SIGNAL(deviceRemoved(QString)), this, SLOT(slotDeviceRemoved(QString)) ); - - //foreach( Solid::Device device, Solid::Device::allDevices() ) { - // slotDeviceAdded(device.udi()); - //} - - m_initialized = true; - return true; -} - -bool UpnpCollectionFactory::cagibi0_2_0Init( QDBusConnection bus ) -{ - bus.connect( "org.kde.Cagibi", - "/org/kde/Cagibi/DeviceList", - "org.kde.Cagibi.DeviceList", - "devicesAdded", - this, - SLOT(slotDeviceAdded(DeviceTypeMap)) ); - - bus.connect( "org.kde.Cagibi", - "/org/kde/Cagibi/DeviceList", - "org.kde.Cagibi.DeviceList", - "devicesRemoved", - this, - SLOT(slotDeviceRemoved(DeviceTypeMap)) ); - - m_iface = new QDBusInterface( "org.kde.Cagibi", - "/org/kde/Cagibi/DeviceList", - "org.kde.Cagibi.DeviceList", - bus, - this ); - - QDBusReply reply = m_iface->call( "allDevices" ); - if( !reply.isValid() ) - { - debug() << "ERROR" << reply.error().message(); - debug() << "Maybe cagibi is not installed."; - return false; - } - else - { - slotDeviceAdded( reply.value() ); - } - - //Solid::DeviceNotifier *notifier = Solid::DeviceNotifier::instance(); - //connect( notifier, SIGNAL(deviceAdded(QString)), this, SLOT(slotDeviceAdded(QString)) ); - //connect( notifier, SIGNAL(deviceRemoved(QString)), this, SLOT(slotDeviceRemoved(QString)) ); - - //foreach( Solid::Device device, Solid::Device::allDevices() ) { - // slotDeviceAdded(device.udi()); - //} - - m_initialized = true; - return true; -} - -void UpnpCollectionFactory::slotDeviceAdded( const DeviceTypeMap &map ) -{ - foreach( const QString &udn, map.keys() ) { - QString type = map[udn]; - debug() << "|||| DEVICE" << udn << type; - if( type.startsWith("urn:schemas-upnp-org:device:MediaServer") ) - createCollection( udn ); - } -} - -void UpnpCollectionFactory::slotDeviceRemoved( const DeviceTypeMap &map ) -{ - foreach( QString udn, map.keys() ) { - udn.remove("uuid:"); - if( m_devices.contains(udn) ) { - m_devices[udn]->removeCollection(); - m_devices.remove(udn); - } - } -} - -void UpnpCollectionFactory::createCollection( const QString &udn ) -{ - debug() << "|||| Creating collection " << udn; - DeviceInfo info; - if( !cagibi0_1_0DeviceDetails( udn, &info ) - && !cagibi0_2_0DeviceDetails( udn, &info ) ) - { - return; - } - debug() << "|||| Creating collection " << info.uuid(); - KIO::ListJob *job = KIO::listDir( QString( "upnp-ms://" + info.uuid() + "/?searchcapabilities=1" ) ); - job->setProperty( "deviceInfo", QVariant::fromValue( info ) ); - connect( job, SIGNAL(entries(KIO::Job*,KIO::UDSEntryList)), - this, SLOT(slotSearchEntries(KIO::Job*,KIO::UDSEntryList)) ); - connect( job, SIGNAL(result(KJob*)), this, SLOT(slotSearchCapabilitiesDone(KJob*)) ); -} - -bool UpnpCollectionFactory::cagibi0_1_0DeviceDetails( const QString &udn, DeviceInfo *info ) -{ - QDBusReply reply = m_iface->call( "deviceDetails", udn ); - if( !reply.isValid() ) { - debug() << "Invalid reply from deviceDetails for" << udn << ". Skipping"; - debug() << "Error" << reply.error().message(); - return false; - } - *info = reply.value(); - return true; -} - -bool UpnpCollectionFactory::cagibi0_2_0DeviceDetails( const QString &udn, DeviceInfo *info ) -{ - QDBusReply reply = m_iface->call( "deviceDetails", udn ); - if( !reply.isValid() ) { - debug() << "Invalid reply from deviceDetails for" << udn << ". Skipping"; - debug() << "Error" << reply.error().message(); - return false; - } - - foreach( const QString &k, reply.value().keys() ) - debug() << k << reply.value()[k]; - DeviceInfo0_2_0 v( reply.value() ); - *info = v; - return true; -} - -void UpnpCollectionFactory::slotSearchEntries( KIO::Job *job, const KIO::UDSEntryList &list ) -{ - Q_UNUSED( job ); - KIO::ListJob *lj = static_cast( job ); - foreach( const KIO::UDSEntry &entry, list ) - m_capabilities[lj->url().host()] << entry.stringValue( KIO::UDSEntry::UDS_NAME ); -} - -void UpnpCollectionFactory::slotSearchCapabilitiesDone( KJob *job ) -{ - KIO::ListJob *lj = static_cast( job ); - QStringList searchCaps = m_capabilities[lj->url().host()]; - - if( !job->error() ) { - DeviceInfo dev = job->property( "deviceInfo" ).value(); - - if( searchCaps.contains( "upnp:class" ) - && searchCaps.contains( "dc:title" ) - && searchCaps.contains( "upnp:artist" ) - && searchCaps.contains( "upnp:album" ) ) { - kDebug() << "Supports all search meta-data required, using UpnpSearchCollection"; - m_devices[dev.uuid()] = new UpnpSearchCollection( dev, searchCaps ); - } - else { - kDebug() << "Supported Search() meta-data" << searchCaps << "not enough. Using UpnpBrowseCollection"; - m_devices[dev.uuid()] = new UpnpBrowseCollection( dev ); - } - emit newCollection( m_devices[dev.uuid()] ); - } -} - -} diff --git a/amarok/src/core-impl/collections/upnpcollection/UpnpCollectionFactory.h b/amarok/src/core-impl/collections/upnpcollection/UpnpCollectionFactory.h deleted file mode 100644 index fdb995cf..00000000 --- a/amarok/src/core-impl/collections/upnpcollection/UpnpCollectionFactory.h +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Nikhil Marathe * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef UPNPCOLLECTIONFACTORY_H -#define UPNPCOLLECTIONFACTORY_H - -#include "core/collections/Collection.h" -#include "core-impl/collections/upnpcollection/deviceinfo.h" - -#include -#include - -#include - -namespace KIO { - class Job; -} -class KJob; - -class QDBusInterface; - -typedef QHash DeviceTypeMap; -Q_DECLARE_METATYPE( DeviceTypeMap ) - -namespace Collections { - -class UpnpCollectionBase; - -class UpnpCollectionFactory : public Collections::CollectionFactory -{ - Q_OBJECT - public: - UpnpCollectionFactory( QObject *parent, const QVariantList &args ); - virtual ~UpnpCollectionFactory(); - - virtual void init(); - - private: - - private slots: - void slotDeviceAdded( const DeviceTypeMap &udi ); - void slotDeviceRemoved( const DeviceTypeMap &udi ); - void createCollection( const QString& ); - - void slotSearchEntries( KIO::Job *job, const KIO::UDSEntryList &list ); - void slotSearchCapabilitiesDone( KJob * ); - - private: - bool cagibi0_1_0Init( QDBusConnection bus ); - bool cagibi0_2_0Init( QDBusConnection bus ); - bool cagibi0_1_0DeviceDetails( const QString &udn, DeviceInfo *info ); - bool cagibi0_2_0DeviceDetails( const QString &udn, DeviceInfo *info ); - QHash m_devices; - QHash m_capabilities; - - QDBusInterface *m_iface; -}; - -} //namespace Collections - -#endif diff --git a/amarok/src/core-impl/collections/upnpcollection/UpnpMemoryQueryMaker.cpp b/amarok/src/core-impl/collections/upnpcollection/UpnpMemoryQueryMaker.cpp deleted file mode 100644 index e18c64ed..00000000 --- a/amarok/src/core-impl/collections/upnpcollection/UpnpMemoryQueryMaker.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Nikhil Marathe * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "UpnpMemoryQueryMaker" - -#include "UpnpMemoryQueryMaker.h" - -#include - -#include "core/support/Debug.h" -#include "UpnpBrowseCollection.h" - -namespace Collections { - -bool UpnpMemoryQueryMaker::m_firstRun = true; -UpnpMemoryQueryMaker::UpnpMemoryQueryMaker( QWeakPointer mc, const QString &collectionId ) - : MemoryQueryMaker( mc, collectionId ) -{ -} - -UpnpMemoryQueryMaker::~UpnpMemoryQueryMaker() -{ -} - -void -UpnpMemoryQueryMaker::run() -{ -DEBUG_BLOCK - if( m_firstRun ) { - m_firstRun = false; - emit startFullScan(); - } - MemoryQueryMaker::run(); -} - -} //namespace Collections - diff --git a/amarok/src/core-impl/collections/upnpcollection/UpnpMemoryQueryMaker.h b/amarok/src/core-impl/collections/upnpcollection/UpnpMemoryQueryMaker.h deleted file mode 100644 index a0d1593e..00000000 --- a/amarok/src/core-impl/collections/upnpcollection/UpnpMemoryQueryMaker.h +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Nikhil Marathe * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef UPNP_MEMORYQUERYMAKER_H -#define UPNP_MEMORYQUERYMAKER_H - -#include "amarok_export.h" - -#include "MemoryCollection.h" -#include "core-impl/collections/support/MemoryQueryMaker.h" - -namespace Collections { - -class UpnpMemoryQueryMaker : public MemoryQueryMaker -{ - Q_OBJECT - public: - UpnpMemoryQueryMaker( QWeakPointer mc, const QString &collectionId ); - virtual ~UpnpMemoryQueryMaker(); - - virtual void run(); - - signals: - void startFullScan(); - - private: - /* - * On the first run we need to tell the collection - * to start scanning. So we need to know when its - * the first run. Is this crude? I don't know now - */ - static bool m_firstRun; - -}; - -} //namespace Collections - -#endif diff --git a/amarok/src/core-impl/collections/upnpcollection/UpnpMeta.cpp b/amarok/src/core-impl/collections/upnpcollection/UpnpMeta.cpp deleted file mode 100644 index 9b660de5..00000000 --- a/amarok/src/core-impl/collections/upnpcollection/UpnpMeta.cpp +++ /dev/null @@ -1,561 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Nikhil Marathe * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "UpnpMeta.h" - -#include "UpnpCollectionBase.h" -#include "core/support/Debug.h" -#include "covermanager/CoverCache.h" -#include "covermanager/CoverFetchingActions.h" -#include "core-impl/capabilities/AlbumActionsCapability.h" - -#include - -#include - -using namespace Meta; - -UpnpTrack::UpnpTrack( Collections::UpnpCollectionBase *collection ) - : Meta::Track() - , m_collection( collection ) - , m_album( 0 ) - , m_genre( 0 ) - , m_composer( 0 ) - , m_year( 0 ) -{ -} - -UpnpTrack::~UpnpTrack() -{ - //nothing to do -} - -QString -UpnpTrack::name() const -{ - return m_name; -} - -KUrl -UpnpTrack::playableUrl() const -{ - - KUrl url( m_playableUrl ); - return url; -} - -QString -UpnpTrack::uidUrl() const -{ - return m_uidUrl; -} - -QString -UpnpTrack::prettyUrl() const -{ - return m_playableUrl; -} - -QString -UpnpTrack::notPlayableReason() const -{ - return networkNotPlayableReason(); -} - -AlbumPtr -UpnpTrack::album() const -{ - return AlbumPtr::staticCast( m_album ); -} - -ArtistPtr -UpnpTrack::artist() const -{ - return ArtistPtr::staticCast( m_artist ); -} - -GenrePtr -UpnpTrack::genre() const -{ - return GenrePtr::staticCast( m_genre ); -} - -ComposerPtr -UpnpTrack::composer() const -{ - return ComposerPtr::staticCast( m_composer ); -} - -YearPtr -UpnpTrack::year() const -{ - return YearPtr::staticCast( m_year ); -} - -void -UpnpTrack::setAlbum( const QString &newAlbum ) -{ - Q_UNUSED( newAlbum ) -} - -void -UpnpTrack::setArtist( const QString &newArtist ) -{ - Q_UNUSED( newArtist ) -} - -void -UpnpTrack::setComposer( const QString &newComposer ) -{ - Q_UNUSED( newComposer ) -} - -void -UpnpTrack::setGenre( const QString &newGenre ) -{ - Q_UNUSED( newGenre ) -} - -void -UpnpTrack::setYear( int newYear ) -{ - Q_UNUSED( newYear ) -} - -void -UpnpTrack::setUidUrl( const QString &url ) -{ -// TODO should we include uuid() also in the url? - m_uidUrl = url; - if( !url.startsWith( "upnp-ms://" ) ) - m_uidUrl = "upnp-ms://" + m_collection->collectionId() + "/" + m_uidUrl; -} - -void -UpnpTrack::setPlayableUrl( const QString& url ) -{ - m_playableUrl = url; -} - -/* -TODO: This isn't good enough, but for now as daapreader/Reader.cpp indicates - we can query for the BPM from daap server, but desire is to get BPM of files working - first! -*/ -qreal -UpnpTrack::bpm() const -{ - return -1.0; -} - -QString -UpnpTrack::comment() const -{ - return QString(); -} - -void -UpnpTrack::setComment( const QString &newComment ) -{ - Q_UNUSED( newComment ) -} - -qint64 -UpnpTrack::length() const -{ - return m_length; -} - -int -UpnpTrack::filesize() const -{ - return 0; -} - -int -UpnpTrack::sampleRate() const -{ - return 0; -} - -int -UpnpTrack::bitrate() const -{ - return m_bitrate; -} - -int -UpnpTrack::trackNumber() const -{ - return m_trackNumber; -} - -void -UpnpTrack::setTrackNumber( int newTrackNumber ) -{ - m_trackNumber = newTrackNumber; -} - -int -UpnpTrack::discNumber() const -{ - return 0; -} - -void -UpnpTrack::setDiscNumber( int newDiscNumber ) -{ - Q_UNUSED( newDiscNumber ) -} - -QString -UpnpTrack::type() const -{ - return m_type; -} - -bool -UpnpTrack::inCollection() const -{ - return true; -} - -Collections::Collection* -UpnpTrack::collection() const -{ - return m_collection; -} - -void -UpnpTrack::setAlbum( UpnpAlbumPtr album ) -{ - m_album = album; -} - -void -UpnpTrack::setArtist( UpnpArtistPtr artist ) -{ - m_artist = artist; -} - -void -UpnpTrack::setGenre( UpnpGenrePtr genre ) -{ - m_genre = genre; -} - -void -UpnpTrack::setComposer( UpnpComposerPtr composer ) -{ - m_composer = composer; -} - -void -UpnpTrack::setYear( UpnpYearPtr year ) -{ - m_year = year; -} - -void -UpnpTrack::setTitle( const QString &title ) -{ - m_name = title; -} - -void -UpnpTrack::setLength( qint64 length ) -{ - m_length = length; -} - -void -UpnpTrack::setBitrate( int rate ) -{ - m_bitrate = rate; -} - -//UpnpArtist - -UpnpArtist::UpnpArtist( const QString &name ) - : Meta::Artist() - , m_name( name ) - , m_tracks() -{ - //nothing to do -} - -UpnpArtist::~UpnpArtist() -{ - //nothing to do -} - -QString -UpnpArtist::name() const -{ - return m_name; -} - -TrackList -UpnpArtist::tracks() -{ - - return m_tracks; -} - -void -UpnpArtist::addTrack( UpnpTrackPtr track ) -{ - m_tracks.append( TrackPtr::staticCast( track ) ); -} - -void -UpnpArtist::removeTrack( UpnpTrackPtr track ) -{ - m_tracks.removeOne( TrackPtr::staticCast( track ) ); -} - -UpnpAlbum::UpnpAlbum( const QString &name ) - : QObject() - , Meta::Album() - , m_name( name ) - , m_tracks() - , m_isCompilation( false ) - , m_albumArtist( 0 ) -{ - //nothing to do -} - -UpnpAlbum::~UpnpAlbum() -{ - CoverCache::invalidateAlbum( this ); -} - -QString -UpnpAlbum::name() const -{ - return m_name; -} - -bool -UpnpAlbum::isCompilation() const -{ - return m_isCompilation; -} - -bool -UpnpAlbum::hasAlbumArtist() const -{ - return !m_albumArtist.isNull(); -} - -ArtistPtr -UpnpAlbum::albumArtist() const -{ - return ArtistPtr::staticCast( m_albumArtist ); -} - -TrackList -UpnpAlbum::tracks() -{ - return m_tracks; -} - -bool -UpnpAlbum::hasImage( int size ) const -{ - Q_UNUSED( size ); - return m_albumArtUrl.isValid(); -} - -QImage -UpnpAlbum::image( int size ) const -{ - if( m_image.isNull() ) - { - QString path; - if( m_albumArtUrl.isValid() - && KIO::NetAccess::download( m_albumArtUrl, path, NULL ) ) - { - m_image = QImage( path ); - CoverCache::invalidateAlbum( this ); - } - } - - if( m_image.isNull() ) - return Meta::Album::image( size ); - - return size <= 1 ? m_image : m_image.scaled( size, size ); -} - -KUrl -UpnpAlbum::imageLocation( int size ) -{ - Q_UNUSED( size ); - return m_albumArtUrl; -} - -void -UpnpAlbum::addTrack( UpnpTrackPtr track ) -{ - m_tracks.append( TrackPtr::staticCast( track ) ); -} - -void -UpnpAlbum::removeTrack( UpnpTrackPtr track ) -{ - m_tracks.removeOne( TrackPtr::staticCast( track ) ); -} - -void -UpnpAlbum::setAlbumArtist( UpnpArtistPtr artist ) -{ - m_albumArtist = artist; -} - -void -UpnpAlbum::setAlbumArtUrl( const KUrl &url ) -{ - m_albumArtUrl = url; -} - -Capabilities::Capability* -UpnpAlbum::createCapabilityInterface( Capabilities::Capability::Type type ) -{ - switch( type ) - { - case Capabilities::Capability::Actions: - return new Capabilities::AlbumActionsCapability( Meta::AlbumPtr( this ) ); - default: - return 0; - } -} -//UpnpGenre - -UpnpGenre::UpnpGenre( const QString &name ) - : Meta::Genre() - , m_name( name ) - , m_tracks() -{ - //nothing to do -} - -UpnpGenre::~UpnpGenre() -{ - //nothing to do -} - -QString -UpnpGenre::name() const -{ - return m_name; -} - -TrackList -UpnpGenre::tracks() -{ - return m_tracks; -} - -void -UpnpGenre::addTrack( UpnpTrackPtr track ) -{ - m_tracks.append( TrackPtr::staticCast( track ) ); -} - -void -UpnpGenre::removeTrack( UpnpTrackPtr track ) -{ - m_tracks.removeOne( TrackPtr::staticCast( track ) ); -} - -//UpnpComposer - -UpnpComposer::UpnpComposer( const QString &name ) - : Meta::Composer() - , m_name( name ) - , m_tracks() -{ - //nothing to do -} - -UpnpComposer::~UpnpComposer() -{ - //nothing to do -} - -QString -UpnpComposer::name() const -{ - return m_name; -} - -TrackList -UpnpComposer::tracks() -{ - return m_tracks; -} - -void -UpnpComposer::addTrack( UpnpTrackPtr track ) -{ - m_tracks.append( TrackPtr::staticCast( track ) ); -} - -void -UpnpComposer::removeTrack( UpnpTrackPtr track ) -{ - m_tracks.removeOne( TrackPtr::staticCast( track ) ); -} - -//UpnpYear - -UpnpYear::UpnpYear( int name ) - : Meta::Year() - , m_name( name ) - , m_tracks() -{ - //nothing to do -} - -UpnpYear::~UpnpYear() -{ - //nothing to do -} - -QString -UpnpYear::name() const -{ - return m_name; -} - -TrackList -UpnpYear::tracks() -{ - return m_tracks; -} - -void -UpnpYear::addTrack( UpnpTrackPtr track ) -{ - m_tracks.append( TrackPtr::staticCast( track ) ); -} - -void -UpnpYear::removeTrack( UpnpTrackPtr track ) -{ - m_tracks.removeOne( TrackPtr::staticCast( track ) ); -} - diff --git a/amarok/src/core-impl/collections/upnpcollection/UpnpMeta.h b/amarok/src/core-impl/collections/upnpcollection/UpnpMeta.h deleted file mode 100644 index c5f859fe..00000000 --- a/amarok/src/core-impl/collections/upnpcollection/UpnpMeta.h +++ /dev/null @@ -1,238 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Nikhil Marathe * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef UPNPMETA_H -#define UPNPMETA_H - -#include "core/meta/Meta.h" - -namespace Collections { - class UpnpCollectionBase; -} - -namespace Meta -{ - -class UpnpTrack; -class UpnpAlbum; -class UpnpArtist; -class UpnpGenre; -class UpnpComposer; -class UpnpYear; - -typedef KSharedPtr UpnpTrackPtr; -typedef KSharedPtr UpnpArtistPtr; -typedef KSharedPtr UpnpAlbumPtr; -typedef KSharedPtr UpnpGenrePtr; -typedef KSharedPtr UpnpComposerPtr; -typedef KSharedPtr UpnpYearPtr; - -class UpnpTrack : public Meta::Track -{ - public: - UpnpTrack( Collections::UpnpCollectionBase *collection ); - virtual ~UpnpTrack(); - - virtual QString name() const; - - virtual KUrl playableUrl() const; - virtual QString uidUrl() const; - virtual QString prettyUrl() const; - virtual QString notPlayableReason() const; - - virtual AlbumPtr album() const; - virtual ArtistPtr artist() const; - virtual GenrePtr genre() const; - virtual ComposerPtr composer() const; - virtual YearPtr year() const; - - virtual void setAlbum ( const QString &newAlbum ); - virtual void setArtist ( const QString &newArtist ); - virtual void setGenre ( const QString &newGenre ); - virtual void setComposer ( const QString &newComposer ); - virtual void setYear ( int year ); - - virtual void setTitle( const QString &newTitle ); - - virtual void setUidUrl( const QString &url ); - - virtual qreal bpm() const; - - virtual QString comment() const; - virtual void setComment ( const QString &newComment ); - - virtual qint64 length() const; - - virtual int filesize() const; - virtual int sampleRate() const; - virtual int bitrate() const; - - virtual int trackNumber() const; - virtual void setTrackNumber ( int newTrackNumber ); - - virtual int discNumber() const; - virtual void setDiscNumber ( int newDiscNumber ); - - virtual QString type() const; - - virtual bool inCollection() const; - virtual Collections::Collection* collection() const; - - //UpnpTrack specific methods - void setAlbum( UpnpAlbumPtr album ); - void setArtist( UpnpArtistPtr artist ); - void setComposer( UpnpComposerPtr composer ); - void setGenre( UpnpGenrePtr genre ); - void setYear( UpnpYearPtr year ); - void setPlayableUrl( const QString &url ); - - void setLength( qint64 length ); - void setBitrate( int rate ); - - private: - Collections::UpnpCollectionBase *m_collection; - - UpnpArtistPtr m_artist; - UpnpAlbumPtr m_album; - UpnpGenrePtr m_genre; - UpnpComposerPtr m_composer; - UpnpYearPtr m_year; - - QString m_name; - QString m_type; - qint64 m_length; - int m_bitrate; - int m_trackNumber; - QString m_displayUrl; - QString m_playableUrl; - QString m_uidUrl; -}; - -class UpnpArtist : public Meta::Artist -{ - public: - UpnpArtist( const QString &name ); - virtual ~UpnpArtist(); - - virtual QString name() const; - - virtual TrackList tracks(); - - //UpnpArtist specific methods - void addTrack( UpnpTrackPtr track ); - void removeTrack( UpnpTrackPtr track ); - - private: - QString m_name; - TrackList m_tracks; -}; - -class UpnpAlbum : public QObject, public Meta::Album -{ - Q_OBJECT - public: - UpnpAlbum( const QString &name ); - virtual ~UpnpAlbum(); - - virtual QString name() const; - - virtual bool isCompilation() const; - virtual bool hasAlbumArtist() const; - virtual ArtistPtr albumArtist() const; - virtual TrackList tracks(); - - virtual bool hasImage( int size = 0 ) const; - virtual QImage image( int size = 0 ) const; - virtual KUrl imageLocation( int size = 0 ); - - virtual Capabilities::Capability* createCapabilityInterface( Capabilities::Capability::Type type ); - - //UpnpAlbum specific methods - void addTrack( UpnpTrackPtr track ); - void removeTrack( UpnpTrackPtr track ); - void setAlbumArtist( UpnpArtistPtr artist ); - void setAlbumArtUrl( const KUrl &url ); - - private: - QString m_name; - mutable QImage m_image; - TrackList m_tracks; - bool m_isCompilation; - UpnpArtistPtr m_albumArtist; - KUrl m_albumArtUrl; -}; - -class UpnpGenre : public Meta::Genre -{ - public: - UpnpGenre( const QString &name ); - virtual ~UpnpGenre(); - - virtual QString name() const; - - virtual TrackList tracks(); - - //UpnpGenre specific methods - void addTrack( UpnpTrackPtr track ); - void removeTrack( UpnpTrackPtr track ); - - private: - QString m_name; - TrackList m_tracks; -}; - -class UpnpComposer : public Meta::Composer -{ - public: - UpnpComposer( const QString &name ); - virtual ~UpnpComposer(); - - virtual QString name() const; - - virtual TrackList tracks(); - - //UpnpComposer specific methods - void addTrack( UpnpTrackPtr track ); - void removeTrack( UpnpTrackPtr track ); - - private: - QString m_name; - TrackList m_tracks; -}; - -class UpnpYear : public Meta::Year -{ - public: - UpnpYear( int year ); - virtual ~UpnpYear(); - - virtual QString name() const; - - virtual TrackList tracks(); - - //UpnpYear specific methods - void addTrack( UpnpTrackPtr track ); - void removeTrack( UpnpTrackPtr track ); - - private: - QString m_name; - TrackList m_tracks; -}; - -} - -#endif - diff --git a/amarok/src/core-impl/collections/upnpcollection/UpnpQuery.cpp b/amarok/src/core-impl/collections/upnpcollection/UpnpQuery.cpp deleted file mode 100644 index fcdbe123..00000000 --- a/amarok/src/core-impl/collections/upnpcollection/UpnpQuery.cpp +++ /dev/null @@ -1,104 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Nikhil Marathe * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "UpnpQuery" - -#include "UpnpQuery.h" - -#include "core/support/Debug.h" - -UpnpQuery::UpnpQuery() -{ - reset(); -} - -void UpnpQuery::reset() -{ - m_stack.clear(); - m_expressions.clear(); - m_andStack.clear(); - m_andStack.push( true ); - m_hasMatchFilter = false; -} - -QStringList UpnpQuery::queries() -{ - return m_expressions; -} - -void UpnpQuery::setType(const QString& type ) -{ - m_expressions.append( type ); -} - -void UpnpQuery::beginAnd() -{ - for( int i = 0; i < m_expressions.length() ; ++i ) { - m_expressions[i] += " and "; - } -} - -void UpnpQuery::beginOr() -{ - if( m_andStack.top() ) { - m_stack.push( m_expressions ); - m_expressions.clear(); - } - m_andStack.push( false ); -} - -void UpnpQuery::endAndOr() -{ - m_andStack.pop(); - - if( m_andStack.empty() ) - return; - - if( m_andStack.top() ) { - ExpressionList top = m_stack.pop(); - ExpressionList copy = ExpressionList( m_expressions ); - m_expressions.clear(); - - if( copy.isEmpty() ) { - m_expressions = top; - } - else if( top.isEmpty() ) { - m_expressions = copy; - } - else { - foreach( const QString &stackElem, top ) - foreach( const QString ©Elem, copy ) - m_expressions.append( stackElem + " and " + copyElem ); - } - } -} - -void UpnpQuery::addFilter(const QString& filter ) -{ - m_hasMatchFilter = true; - m_expressions.append( filter ); -} - -void UpnpQuery::addMatch(const QString& match ) -{ - m_hasMatchFilter = true; - for( int i = 0; i < m_expressions.length() ; ++i ) { - m_expressions[i] += " and "; - m_expressions[i] += match; - } -} - - diff --git a/amarok/src/core-impl/collections/upnpcollection/UpnpQuery.h b/amarok/src/core-impl/collections/upnpcollection/UpnpQuery.h deleted file mode 100644 index 2caa4078..00000000 --- a/amarok/src/core-impl/collections/upnpcollection/UpnpQuery.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - Copyright (C) 2010 Nikhil Marathe - - This program 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 2 of the License, or - (at your option) any later version. - - This program 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 this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - - -#ifndef UPNPQUERY_H -#define UPNPQUERY_H - -#include -#include -#include - -class UpnpQuery -{ - - public: - UpnpQuery(); - void reset(); - void setType( const QString & ); - void beginAnd(); - void beginOr(); - void endAndOr(); - void addFilter( const QString & ); - void addMatch( const QString & ); - QStringList queries(); - bool hasMatchFilter() const { return m_hasMatchFilter; } - - private: - // poor man's tree - typedef QStack ExpressionListStack; - typedef QStringList ExpressionList; - - ExpressionListStack m_stack; - ExpressionList m_expressions; - QStack m_andStack; - bool m_hasMatchFilter; -}; - -#endif // UPNPQUERY_H diff --git a/amarok/src/core-impl/collections/upnpcollection/UpnpQueryMaker.cpp b/amarok/src/core-impl/collections/upnpcollection/UpnpQueryMaker.cpp deleted file mode 100644 index 4b311909..00000000 --- a/amarok/src/core-impl/collections/upnpcollection/UpnpQueryMaker.cpp +++ /dev/null @@ -1,543 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Nikhil Marathe * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "UpnpQueryMaker" - -#include "UpnpQueryMaker.h" - -#include -#include "upnptypes.h" -#include -#include - -#include "core/support/Debug.h" -#include "UpnpSearchCollection.h" -#include "UpnpQueryMakerInternal.h" -#include "UpnpMeta.h" -#include "UpnpCache.h" - -namespace Collections { - -UpnpQueryMaker::UpnpQueryMaker( UpnpSearchCollection *collection ) - : QueryMaker() - , m_collection( collection ) - , m_internalQM( new UpnpQueryMakerInternal( collection ) ) -{ - reset(); - connect( m_internalQM, SIGNAL(done()), this, SLOT(slotDone()) ); - - connect( m_internalQM, SIGNAL(newResultReady(Meta::TrackList)), - this, SLOT(handleTracks(Meta::TrackList)) ); - connect( m_internalQM, SIGNAL(newResultReady(Meta::ArtistList)), - this, SLOT(handleArtists(Meta::ArtistList)) ); - connect( m_internalQM, SIGNAL(newResultReady(Meta::AlbumList)), - this, SLOT(handleAlbums(Meta::AlbumList)) ); - connect( m_internalQM, SIGNAL(newResultReady(KIO::UDSEntryList)), - this, SLOT(handleCustom(KIO::UDSEntryList)) ); -} - -UpnpQueryMaker::~UpnpQueryMaker() -{ - m_internalQM->deleteLater(); -} - - -QueryMaker* UpnpQueryMaker::reset() -{ - // TODO kill all jobs here too - m_queryType = None; - m_albumMode = AllAlbums; - m_query.reset(); - m_jobCount = 0; - - m_numericFilters.clear(); - m_internalQM->reset(); - -// the Amarok Collection Model expects at least one entry -// otherwise it will harass us continuously for more entries. -// of course due to the poor quality of UPnP servers I've -// had experience with :P, some may not have sub-results -// for something ( they may have a track with an artist, but -// not be able to give any album for it ) - m_noResults = true; - return this; -} - -void UpnpQueryMaker::run() -{ -DEBUG_BLOCK - - KUrl baseUrl( m_collection->collectionId() ); - baseUrl.addQueryItem( "search", "1" ); - - if( m_queryType == Custom ) { - switch( m_returnFunction ) { - case Count: - m_query.reset(); - m_query.setType( "( upnp:class derivedfrom \"object.item.audioItem\" )" ); - baseUrl.addQueryItem( "getCount", "1" ); - break; - case Sum: - case Max: - case Min: - break; - } - } - // we don't deal with compilations - else if( m_queryType == Album && m_albumMode == OnlyCompilations ) { - // we don't support any other attribute - emit newResultReady( Meta::TrackList() ); - emit newResultReady( Meta::ArtistList() ); - emit newResultReady( Meta::AlbumList() ); - emit newResultReady( Meta::GenreList() ); - emit newResultReady( Meta::ComposerList() ); - emit newResultReady( Meta::YearList() ); - emit newResultReady( QStringList() ); - emit newResultReady( Meta::LabelList() ); - emit queryDone(); - return; - } - - QStringList queryList; - if( m_query.hasMatchFilter() || !m_numericFilters.empty() ) { - queryList = m_query.queries(); - } - else { - switch( m_queryType ) { - case Artist: - debug() << this << "Query type Artist"; - queryList << "( upnp:class derivedfrom \"object.container.person.musicArtist\" )"; - break; - case Album: - debug() << this << "Query type Album"; - queryList << "( upnp:class derivedfrom \"object.container.album.musicAlbum\" )"; - break; - case Track: - debug() << this << "Query type Track"; - queryList << "( upnp:class derivedfrom \"object.item.audioItem\" )"; - break; - case Genre: - debug() << this << "Query type Genre"; - queryList << "( upnp:class derivedfrom \"object.container.genre.musicGenre\" )"; - break; - case Custom: - debug() << this << "Query type Custom"; - queryList << "( upnp:class derivedfrom \"object.item.audioItem\" )"; - break; - default: - debug() << this << "Default case: Query type"; - // we don't support any other attribute - emit newResultReady( Meta::TrackList() ); - emit newResultReady( Meta::ArtistList() ); - emit newResultReady( Meta::AlbumList() ); - emit newResultReady( Meta::GenreList() ); - emit newResultReady( Meta::ComposerList() ); - emit newResultReady( Meta::YearList() ); - emit newResultReady( QStringList() ); - emit newResultReady( Meta::LabelList() ); - emit queryDone(); - return; - } - } - - // and experiment in using the filter only for the query - // and checking the returned upnp:class - // based on your query types. - for( int i = 0; i < queryList.length() ; i++ ) { - if( queryList[i].isEmpty() ) - continue; - - KUrl url( baseUrl ); - url.addQueryItem( "query", queryList[i] ); - - debug() << this << "Running query" << url; - m_internalQM->runQuery( url ); - } -} - -void UpnpQueryMaker::abortQuery() -{ -DEBUG_BLOCK - Q_ASSERT( false ); -// TODO implement this to kill job -} - -QueryMaker* UpnpQueryMaker::setQueryType( QueryType type ) -{ -DEBUG_BLOCK -// TODO allow all, based on search capabilities -// which should be passed on by the factory - m_queryType = type; - m_query.setType( "( upnp:class derivedfrom \"object.item.audioItem\" )" ); - m_internalQM->setQueryType( type ); - - return this; -} - -QueryMaker* UpnpQueryMaker::addReturnValue( qint64 value ) -{ -DEBUG_BLOCK - debug() << this << "Add return value" << value; - m_returnValue = value; - return this; -} - -QueryMaker* UpnpQueryMaker::addReturnFunction( ReturnFunction function, qint64 value ) -{ -DEBUG_BLOCK - Q_UNUSED( function ) - debug() << this << "Return function with value" << value; - m_returnFunction = function; - m_returnValue = value; - return this; -} - -QueryMaker* UpnpQueryMaker::orderBy( qint64 value, bool descending ) -{ -DEBUG_BLOCK - debug() << this << "Order by " << value << "Descending?" << descending; - return this; -} - -QueryMaker* UpnpQueryMaker::addMatch( const Meta::TrackPtr &track ) -{ -DEBUG_BLOCK - debug() << this << "Adding track match" << track->name(); - // TODO: CHECK query type before searching by dc:title? - m_query.addMatch( "( dc:title = \"" + track->name() + "\" )" ); - return this; -} - -QueryMaker* UpnpQueryMaker::addMatch( const Meta::ArtistPtr &artist, QueryMaker::ArtistMatchBehaviour behaviour ) -{ -DEBUG_BLOCK - Q_UNUSED( behaviour ); // TODO: does UPnP tell between track and album artists? - debug() << this << "Adding artist match" << artist->name(); - m_query.addMatch( "( upnp:artist = \"" + artist->name() + "\" )" ); - return this; -} - -QueryMaker* UpnpQueryMaker::addMatch( const Meta::AlbumPtr &album ) -{ -DEBUG_BLOCK - debug() << this << "Adding album match" << album->name(); - m_query.addMatch( "( upnp:album = \"" + album->name() + "\" )" ); - return this; -} - -QueryMaker* UpnpQueryMaker::addMatch( const Meta::ComposerPtr &composer ) -{ -DEBUG_BLOCK - debug() << this << "Adding composer match" << composer->name(); -// NOTE unsupported - return this; -} - -QueryMaker* UpnpQueryMaker::addMatch( const Meta::GenrePtr &genre ) -{ -DEBUG_BLOCK - debug() << this << "Adding genre match" << genre->name(); - m_query.addMatch( "( upnp:genre = \"" + genre->name() + "\" )" ); - return this; -} - -QueryMaker* UpnpQueryMaker::addMatch( const Meta::YearPtr &year ) -{ -DEBUG_BLOCK - debug() << this << "Adding year match" << year->name(); -// TODO - return this; -} - -QueryMaker* UpnpQueryMaker::addMatch( const Meta::LabelPtr &label ) -{ -DEBUG_BLOCK - debug() << this << "Adding label match" << label->name(); -// NOTE how? - return this; -} - -QueryMaker* UpnpQueryMaker::addFilter( qint64 value, const QString &filter, bool matchBegin, bool matchEnd ) -{ -DEBUG_BLOCK - debug() << this << "Adding filter" << value << filter << matchBegin << matchEnd; - -// theoretically this should be '=' I think and set to contains below if required - QString cmpOp = "contains"; - //TODO should we add filters ourselves - // eg. we always query for audioItems, but how do we decide - // whether to add a dc:title filter or others. - // for example, for the artist list - // our query should be like ( pseudocode ) - // ( upnp:class = audioItem ) and ( dc:title contains "filter" ) - // OR - // ( upnp:class = audioItem ) and ( upnp:artist contains "filter" ); - // ... - // so who adds the second query? - QString property = propertyForValue( value ); - if( property.isNull() ) - return this; - - if( matchBegin || matchEnd ) - cmpOp = "contains"; - - QString filterString = "( " + property + " " + cmpOp + " \"" + filter + "\" ) "; - m_query.addFilter( filterString ); - return this; -} - -QueryMaker* UpnpQueryMaker::excludeFilter( qint64 value, const QString &filter, bool matchBegin, bool matchEnd ) -{ -DEBUG_BLOCK - debug() << this << "Excluding filter" << value << filter << matchBegin << matchEnd; - QString cmpOp = "!="; - QString property = propertyForValue( value ); - if( property.isNull() ) - return this; - - if( matchBegin || matchEnd ) - cmpOp = "doesNotContain"; - - QString filterString = "( " + property + " " + cmpOp + " \"" + filter + "\" ) "; - m_query.addFilter( filterString ); - return this; -} - -QueryMaker* UpnpQueryMaker::addNumberFilter( qint64 value, qint64 filter, NumberComparison compare ) -{ -DEBUG_BLOCK - debug() << this << "Adding number filter" << value << filter << compare; - NumericFilter f = { value, filter, compare }; - m_numericFilters << f; - return this; -} - -QueryMaker* UpnpQueryMaker::excludeNumberFilter( qint64 value, qint64 filter, NumberComparison compare ) -{ -DEBUG_BLOCK - debug() << this << "Excluding number filter" << value << filter << compare; - return this; -} - -QueryMaker* UpnpQueryMaker::limitMaxResultSize( int size ) -{ -DEBUG_BLOCK - debug() << this << "Limit max results to" << size; - return this; -} - -QueryMaker* UpnpQueryMaker::setAlbumQueryMode( AlbumQueryMode mode ) -{ -DEBUG_BLOCK - debug() << this << "Set album query mode" << mode; - m_albumMode = mode; - return this; -} - -QueryMaker* UpnpQueryMaker::setLabelQueryMode( LabelQueryMode mode ) -{ -DEBUG_BLOCK - debug() << this << "Set label query mode" << mode; - return this; -} - -QueryMaker* UpnpQueryMaker::beginAnd() -{ -DEBUG_BLOCK - m_query.beginAnd(); - return this; -} - -QueryMaker* UpnpQueryMaker::beginOr() -{ -DEBUG_BLOCK - m_query.beginOr(); - return this; -} - -QueryMaker* UpnpQueryMaker::endAndOr() -{ -DEBUG_BLOCK - debug() << this << "End AND/OR"; - m_query.endAndOr(); - return this; -} - -QueryMaker* UpnpQueryMaker::setAutoDelete( bool autoDelete ) -{ -DEBUG_BLOCK - debug() << this << "Auto delete" << autoDelete; - return this; -} - -int UpnpQueryMaker::validFilterMask() -{ - int mask = 0; - QStringList caps = m_collection->searchCapabilities(); - if( caps.contains( "dc:title" ) ) - mask |= TitleFilter; - if( caps.contains( "upnp:album" ) ) - mask |= AlbumFilter; - if( caps.contains( "upnp:artist" ) ) - mask |= ArtistFilter; - if( caps.contains( "upnp:genre" ) ) - mask |= GenreFilter; - return mask; -} - -void UpnpQueryMaker::handleArtists( Meta::ArtistList list ) -{ - // TODO Post filtering - emit newResultReady( list ); -} - -void UpnpQueryMaker::handleAlbums( Meta::AlbumList list ) -{ - // TODO Post filtering - emit newResultReady( list ); -} - -void UpnpQueryMaker::handleTracks( Meta::TrackList list ) -{ - // TODO Post filtering - emit newResultReady( list ); -} - -/* -void UpnpQueryMaker::handleCustom( const KIO::UDSEntryList& list ) -{ - if( m_returnFunction == Count ) - { - { - Q_ASSERT( !list.empty() ); - QString count = list.first().stringValue( KIO::UDSEntry::UDS_NAME ); - m_collection->setProperty( "numberOfTracks", count.toUInt() ); - emit newResultReady( QStringList( count ) ); - } - default: - debug() << "Custom result functions other than \"Count\" are not supported by UpnpQueryMaker"; - } -} -*/ - -void UpnpQueryMaker::slotDone() -{ -DEBUG_BLOCK - if( m_noResults ) { - debug() << "++++++++++++++++++++++++++++++++++++ NO RESULTS ++++++++++++++++++++++++"; - // TODO proper data types not just DataPtr - Meta::DataList ret; - Meta::UpnpTrack *fake = new Meta::UpnpTrack( m_collection ); - fake->setTitle( "No results" ); - fake->setYear( Meta::UpnpYearPtr( new Meta::UpnpYear( 2010 ) ) ); - Meta::DataPtr ptr( fake ); - ret << ptr; - //emit newResultReady( ret ); - } - - switch( m_queryType ) { - case Artist: - { - Meta::ArtistList list; - foreach( Meta::DataPtr ptr, m_cacheEntries ) - list << Meta::ArtistPtr::staticCast( ptr ); - emit newResultReady( list ); - break; - } - - case Album: - { - Meta::AlbumList list; - foreach( Meta::DataPtr ptr, m_cacheEntries ) - list << Meta::AlbumPtr::staticCast( ptr ); - emit newResultReady( list ); - break; - } - - case Track: - { - Meta::TrackList list; - foreach( Meta::DataPtr ptr, m_cacheEntries ) - list << Meta::TrackPtr::staticCast( ptr ); - emit newResultReady( list ); - break; - } - default: - { - debug() << "Query type not supported by UpnpQueryMaker"; - } - } - - debug() << "ALL JOBS DONE< TERMINATING THIS QM" << this; - emit queryDone(); -} - -QString UpnpQueryMaker::propertyForValue( qint64 value ) -{ - switch( value ) { - case Meta::valTitle: - return "dc:title"; - case Meta::valArtist: - { - //if( m_queryType != Artist ) - return "upnp:artist"; - } - case Meta::valAlbum: - { - //if( m_queryType != Album ) - return "upnp:album"; - } - case Meta::valGenre: - return "upnp:genre"; - break; - default: - debug() << "UNSUPPORTED QUERY TYPE" << value; - return QString(); - } -} - -bool UpnpQueryMaker::postFilter( const KIO::UDSEntry &entry ) -{ - //numeric filters - foreach( const NumericFilter &filter, m_numericFilters ) { - // should be set by the filter based on filter.type - qint64 aValue = 0; - - switch( filter.type ) { - case Meta::valCreateDate: - { - // TODO might use UDSEntry::UDS_CREATION_TIME instead later - QString dateString = entry.stringValue( KIO::UPNP_DATE ); - QDateTime time = QDateTime::fromString( dateString, Qt::ISODate ); - if( !time.isValid() ) - return false; - aValue = time.toTime_t(); - debug() << "FILTER BY creation timestamp entry:" << aValue << "query:" << filter.value << "OP:" << filter.compare; - break; - } - } - - if( ( filter.compare == Equals ) && ( filter.value != aValue ) ) - return false; - else if( ( filter.compare == GreaterThan ) && ( filter.value >= aValue ) ) - return false; // since only allow entries with aValue > filter.value - else if( ( filter.compare == LessThan ) && ( filter.value <= aValue ) ) - return false; - } - return true; -} - -} //namespace Collections diff --git a/amarok/src/core-impl/collections/upnpcollection/UpnpQueryMaker.h b/amarok/src/core-impl/collections/upnpcollection/UpnpQueryMaker.h deleted file mode 100644 index 83424f83..00000000 --- a/amarok/src/core-impl/collections/upnpcollection/UpnpQueryMaker.h +++ /dev/null @@ -1,143 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Nikhil Marathe * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef UPNP_QUERYMAKER_H -#define UPNP_QUERYMAKER_H - -#include "core/collections/QueryMaker.h" - -#include -#include -#include -#include - -#include "UpnpQuery.h" - -namespace KIO { - class UDSEntry; - typedef QList UDSEntryList; - class Job; - class ListJob; -} - -class KJob; - -namespace Collections { - -class UpnpSearchCollection; -class UpnpQueryMakerInternal; - -class UpnpQueryMaker : public QueryMaker -{ - Q_OBJECT - - public: - UpnpQueryMaker( UpnpSearchCollection * ); - ~UpnpQueryMaker(); - - QueryMaker* reset(); - void run() ; - void abortQuery() ; - - QueryMaker* setQueryType( QueryType type ) ; - QueryMaker* addReturnValue( qint64 value ) ; - QueryMaker* addReturnFunction( ReturnFunction function, qint64 value ) ; - QueryMaker* orderBy( qint64 value, bool descending = false ) ; - - QueryMaker* addMatch( const Meta::TrackPtr &track ) ; - QueryMaker* addMatch( const Meta::ArtistPtr &artist, ArtistMatchBehaviour behaviour = TrackArtists ); - QueryMaker* addMatch( const Meta::AlbumPtr &album ) ; - QueryMaker* addMatch( const Meta::ComposerPtr &composer ) ; - QueryMaker* addMatch( const Meta::GenrePtr &genre ) ; - QueryMaker* addMatch( const Meta::YearPtr &year ) ; - QueryMaker* addMatch( const Meta::LabelPtr &label ); - - QueryMaker* addFilter( qint64 value, const QString &filter, bool matchBegin = false, bool matchEnd = false ) ; - QueryMaker* excludeFilter( qint64 value, const QString &filter, bool matchBegin = false, bool matchEnd = false ) ; - - QueryMaker* addNumberFilter( qint64 value, qint64 filter, NumberComparison compare ) ; - QueryMaker* excludeNumberFilter( qint64 value, qint64 filter, NumberComparison compare ) ; - - QueryMaker* limitMaxResultSize( int size ) ; - - QueryMaker* setAlbumQueryMode( AlbumQueryMode mode ); - - QueryMaker* setLabelQueryMode( LabelQueryMode mode ); - - QueryMaker* beginAnd() ; - QueryMaker* beginOr() ; - QueryMaker* endAndOr() ; - - QueryMaker* setAutoDelete( bool autoDelete ); - - int validFilterMask(); - - signals: - void newResultReady( Meta::TrackList ); - void newResultReady( Meta::ArtistList ); - void newResultReady( Meta::AlbumList ); - void newResultReady( Meta::GenreList ); - void newResultReady( Meta::ComposerList ); - void newResultReady( Meta::YearList ); - void newResultReady( QStringList ); - void newResultReady( Meta::LabelList ); - - void queryDone(); - - private slots: - void slotDone(); - void handleArtists( Meta::ArtistList ); - void handleAlbums( Meta::AlbumList ); - void handleTracks( Meta::TrackList ); - - private: - /* - * apply numeric filters and such which UPnP doesn't handle. - */ - bool postFilter( const KIO::UDSEntry& entry ); - - QString propertyForValue( qint64 value ); - - UpnpSearchCollection *m_collection; - UpnpQueryMakerInternal *m_internalQM; - - QueryType m_queryType; - AlbumQueryMode m_albumMode; - - bool m_asDataPtrs; - - UpnpQuery m_query; - - bool m_noResults; - int m_jobCount; - - Meta::DataList m_cacheEntries; - - ReturnFunction m_returnFunction; - qint64 m_returnValue; - - struct NumericFilter { - qint64 type; - qint64 value; - NumberComparison compare; - }; - QList m_numericFilters; -}; - -} //namespace Collections - -#endif - diff --git a/amarok/src/core-impl/collections/upnpcollection/UpnpQueryMakerInternal.cpp b/amarok/src/core-impl/collections/upnpcollection/UpnpQueryMakerInternal.cpp deleted file mode 100644 index 04488793..00000000 --- a/amarok/src/core-impl/collections/upnpcollection/UpnpQueryMakerInternal.cpp +++ /dev/null @@ -1,250 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Nikhil Marathe * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "UpnpQueryMakerInternal" - -#include "UpnpQueryMakerInternal.h" - -#include "upnptypes.h" -#include -#include - -#include "UpnpSearchCollection.h" -#include "UpnpCache.h" -#include "UpnpMeta.h" -#include "core/support/Debug.h" - -namespace Collections { - -// use filter for faster data transfer and parsing -// if cached tracks > remote tracks * CACHE_CHECK_THRESHOLD -static const float CACHE_CHECK_THRESHOLD = 0.75f; - -UpnpQueryMakerInternal::UpnpQueryMakerInternal( UpnpSearchCollection *collection ) - : m_collection( collection ) -{ - reset(); -} - -void UpnpQueryMakerInternal::reset() -{ - m_queryType = QueryMaker::None; - m_jobCount = 0; -} - -UpnpQueryMakerInternal::~UpnpQueryMakerInternal() -{ -} - -void UpnpQueryMakerInternal::queueJob(KIO::SimpleJob* job) -{ - KUrl url = job->url(); - debug() << "+-+- RUNNING JOB WITH" << url.prettyUrl(); - m_collection->addJob( job ); - m_jobCount++; - job->start(); -} - -void UpnpQueryMakerInternal::runQuery( KUrl query, bool filter ) -{ - // insert this query as a job - // first check cache size vs remote size - // if over threshold, apply filter, otherwise pass on as normal - int remoteCount = m_collection->property( "numberOfTracks" ).toInt(); - debug() << "REMOTE COUNT" << remoteCount << "Cache size" << m_collection->cache()->tracks().size(); - if( m_collection->cache()->tracks().size() > remoteCount * CACHE_CHECK_THRESHOLD - && remoteCount > 0 - && filter ) { - debug() << "FILTERING BY CLASS ONLY"; - query.addQueryItem( "filter", "upnp:class" ); - } - - KIO::ListJob *job = KIO::listDir( query, KIO::HideProgressInfo ); - connect( job, SIGNAL(entries(KIO::Job*,KIO::UDSEntryList)), - this, SLOT(slotEntries(KIO::Job*,KIO::UDSEntryList)) ); - connect( job, SIGNAL(result(KJob*)), this, SLOT(slotDone(KJob*)) ); - queueJob( job ); -} - -void UpnpQueryMakerInternal::runStat( const QString& id ) -{ - KUrl url( m_collection->collectionId() ); - url.addQueryItem( "id", id ); - debug() << "STAT URL" << url; - KIO::StatJob *job = KIO::stat( url, KIO::HideProgressInfo ); - connect( job, SIGNAL(result(KJob*)), this, SLOT(slotStatDone(KJob*)) ); - queueJob( job ); -} - -void UpnpQueryMakerInternal::slotEntries( KIO::Job *job, const KIO::UDSEntryList &list ) -{ - debug() << "+-+- JOB DONE" << static_cast(job)->url() << job->error(); - foreach( const KIO::UDSEntry &entry, list ) - debug() << "GOT ENTRY " << entry.stringValue( KIO::UDSEntry::UDS_NAME ); - // actually iterate over the list, check for cache hits - // if hit, get the relevant Meta::*Ptr object and pass it on - // for post filtering etc. - // if miss, queue up another job to fetch all details - // job->url() can be used to decide if complete details - // are available or not using queryItem("filter") details - // - if( job->error() ) - emit results( true, KIO::UDSEntryList() ); - else - emit results( false, list ); - - debug() << this << "SLOT ENTRIES" << list.length() << m_queryType; - - switch( m_queryType ) { - case QueryMaker::Artist: - handleArtists( list ); - break; - case QueryMaker::Album: - handleAlbums( list ); - break; - case QueryMaker::Track: - handleTracks( list ); - break; - case QueryMaker::Custom: - handleCustom( list ); - break; - default: - break; - // TODO handle remaining cases - } - - if( !list.empty() ) { - debug() << "_______________________ RESULTS! ____________________________"; - } -} - -void UpnpQueryMakerInternal::slotDone( KJob *job ) -{ - // here check if all jobs done, then we might want to emit done() - // clean up this job, remove it from the hash and so on. - m_jobCount--; - job->deleteLater(); - - if( m_jobCount <= 0 ) { - //emit newResultReady( list ); - debug() << "ALL JOBS DONE< TERMINATING THIS QM" << this; - emit done(); - } -} - -void UpnpQueryMakerInternal::slotStatDone( KJob *job ) -{ - m_jobCount--; - KIO::StatJob *sj = static_cast( job ); - if( sj->error() ) { - debug() << "STAT ERROR ON" << sj->url() << sj->errorString(); - } - else { - KIO::UDSEntry entry = sj->statResult(); - slotEntries( static_cast( job ), KIO::UDSEntryList() << entry ); - } - sj->deleteLater(); - if( m_jobCount <= 0 ) { - //emit newResultReady( list ); - debug() << "ALL JOBS DONE< TERMINATING THIS QM" << this; - emit done(); - } -} - -void UpnpQueryMakerInternal::handleArtists( const KIO::UDSEntryList &list ) -{ - Meta::ArtistList ret; - foreach( const KIO::UDSEntry &entry, list ) { - if( entry.stringValue( KIO::UPNP_CLASS ) == "object.container.person.musicArtist" ) { - debug() << this << "ARTIST" << entry.stringValue( KIO::UDSEntry::UDS_DISPLAY_NAME ); - ret << m_collection->cache()->getArtist( entry.stringValue( KIO::UDSEntry::UDS_DISPLAY_NAME ) ); - } - else { - if( entry.contains( KIO::UPNP_ARTIST ) ) { - ret << m_collection->cache()->getArtist( entry.stringValue( KIO::UPNP_ARTIST ) ); - } - else { - runStat( entry.stringValue( KIO::UPNP_ID ) ); - } - } - } - emit newResultReady( ret ); -} - -void UpnpQueryMakerInternal::handleAlbums( const KIO::UDSEntryList &list ) -{ -DEBUG_BLOCK - debug() << "HANDLING ALBUMS" << list.length(); - Meta::AlbumList ret; - foreach( const KIO::UDSEntry &entry, list ) { - if( entry.stringValue( KIO::UPNP_CLASS ) == "object.container.album.musicAlbum" ) { - debug() << this << "ALBUM" << entry.stringValue( KIO::UDSEntry::UDS_DISPLAY_NAME ) << entry.stringValue(KIO::UPNP_ARTIST); - ret << m_collection->cache()->getAlbum( entry.stringValue( KIO::UDSEntry::UDS_DISPLAY_NAME ), entry.stringValue( KIO::UPNP_ARTIST ) ); - } - else { - if( entry.contains( KIO::UPNP_ALBUM ) ) { - ret << m_collection->cache()->getAlbum( entry.stringValue( KIO::UPNP_ALBUM ), entry.stringValue( KIO::UPNP_ARTIST ) ); - } - else { - runStat( entry.stringValue( KIO::UPNP_ID ) ); - } - } - } - emit newResultReady( ret ); -} - -void UpnpQueryMakerInternal::handleTracks( const KIO::UDSEntryList &list ) -{ -DEBUG_BLOCK - debug() << "HANDLING TRACKS" << list.length(); - Meta::TrackList ret; - foreach( const KIO::UDSEntry &entry, list ) { - // If we did a list job with an attempt to check the cache (ie. no meta-data requested from server ) - // we might have an incomplete cache entry for the track. - // if we have an incomplete entry, we queue a stat job which fetches - // the entry. Now this stat job is going to call handleTracks again - // When called from a StatJob, we want to fill up the cache - // with valid values. - // So if the cache entry is incomplete, but the UDSEntry is complete - // set the refresh option to true when calling getTrack - Meta::TrackPtr track = m_collection->cache()->getTrack( entry ); - if( track->playableUrl().isEmpty() ) { - debug() << "TRACK HAS INCOMPLETE ENTRY" << track->name() << track->album()->name(); - if( !entry.stringValue( KIO::UDSEntry::UDS_TARGET_URL ).isEmpty() ) { - debug() << "GOT TRACK DETAILS FROM STAT JOB"; - // reached from a StatJob - // fill up valid values AND add this track to ret since it is now valid - track = m_collection->cache()->getTrack( entry, true ); - debug() << "NOW TRACK DETAILS ARE" << track->name() << track->album()->name(); - } - else { - // start a StatJob, but DON'T insert this incomplete entry into ret - debug() << "FETCHING COMPLETE TRACK DATA" << track->name(); - runStat( entry.stringValue( KIO::UPNP_ID ) ); - continue; - } - } - ret << m_collection->cache()->getTrack( entry ); - } - emit newResultReady( ret ); -} - -void UpnpQueryMakerInternal::handleCustom( const KIO::UDSEntryList &list ) -{ - emit newResultReady( list ); -} - -} diff --git a/amarok/src/core-impl/collections/upnpcollection/UpnpQueryMakerInternal.h b/amarok/src/core-impl/collections/upnpcollection/UpnpQueryMakerInternal.h deleted file mode 100644 index 03154a47..00000000 --- a/amarok/src/core-impl/collections/upnpcollection/UpnpQueryMakerInternal.h +++ /dev/null @@ -1,82 +0,0 @@ -/* - Copyright (C) 2010 Nikhil Marathe - - This program 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 2 of the License, or - (at your option) any later version. - - This program 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 this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - - -#ifndef UPNPQUERYMAKERINTERNAL_H -#define UPNPQUERYMAKERINTERNAL_H - -#include - -#include -#include - -#include "core/collections/QueryMaker.h" - -class KJob; -namespace KIO { - class Job; - class SimpleJob; -} - -namespace Collections { - -class UpnpSearchCollection; - -class UpnpQueryMakerInternal : public QObject -{ - Q_OBJECT - public: - UpnpQueryMakerInternal( UpnpSearchCollection *collection ); - ~UpnpQueryMakerInternal(); - void setQueryType( Collections::QueryMaker::QueryType type ) { m_queryType = type; } - void reset(); - void runQuery( KUrl query, bool filter=true ); - - signals: - void results( bool error, const KIO::UDSEntryList list ); - void done(); - - void newResultReady( Meta::TrackList ); - void newResultReady( Meta::ArtistList ); - void newResultReady( Meta::AlbumList ); - void newResultReady( Meta::GenreList ); - void newResultReady( const KIO::UDSEntryList & ); - private slots: - void slotEntries( KIO::Job *, const KIO::UDSEntryList & ); - void slotDone( KJob * ); - void slotStatDone( KJob * ); - - private: - void handleArtists( const KIO::UDSEntryList &list ); - void handleAlbums( const KIO::UDSEntryList &list ); - void handleTracks( const KIO::UDSEntryList &list ); - void handleCustom( const KIO::UDSEntryList &list ); - - void queueJob( KIO::SimpleJob *job ); - void runStat( const QString &id ); - - private: - UpnpSearchCollection *m_collection; - - QueryMaker::QueryType m_queryType; - int m_jobCount; -}; - -} - -#endif // UPNPQUERYMAKERINTERNAL_H diff --git a/amarok/src/core-impl/collections/upnpcollection/UpnpSearchCollection.cpp b/amarok/src/core-impl/collections/upnpcollection/UpnpSearchCollection.cpp deleted file mode 100644 index 87f79f1b..00000000 --- a/amarok/src/core-impl/collections/upnpcollection/UpnpSearchCollection.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Nikhil Marathe * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "UpnpSearchCollection" - -#include "UpnpSearchCollection.h" - -#include "core/support/Debug.h" - -#include "UpnpQueryMaker.h" -#include "UpnpMeta.h" -#include "UpnpCache.h" - -#include -#include - -#include -#include -#include -#include "upnptypes.h" -#include -#include - -using namespace Meta; - -namespace Collections { - -//UpnpSearchCollection - -// TODO register for the device bye bye and emit remove() -UpnpSearchCollection::UpnpSearchCollection( const DeviceInfo& dev, QStringList searchCapabilities ) - : UpnpCollectionBase( dev ) - , m_searchCapabilities( searchCapabilities ) - , m_cache( new UpnpCache( this ) ) -{ - DEBUG_BLOCK - - OrgKdeKDirNotifyInterface *notify = new OrgKdeKDirNotifyInterface("", "", QDBusConnection::sessionBus(), this ); - connect( notify, SIGNAL(FilesChanged(QStringList)), SLOT(slotFilesChanged(QStringList)) ); -} - -UpnpSearchCollection::~UpnpSearchCollection() -{ -} - -void UpnpSearchCollection::slotFilesChanged(const QStringList &list ) -{ - debug() << "Files changed" << list; -} - -QueryMaker* -UpnpSearchCollection::queryMaker() -{ - DEBUG_BLOCK; - return new UpnpQueryMaker( this ); -} - -Meta::TrackPtr -UpnpSearchCollection::trackForUrl( const KUrl &url ) -{ -#ifdef __GNUC__ - #warning Implement track for url -#endif - // TODO FIXME how to do this? - debug() << "Requested track " << url; - return Collection::trackForUrl( url ); -} - -} //~ namespace -#include "moc_UpnpSearchCollection.cpp" - diff --git a/amarok/src/core-impl/collections/upnpcollection/UpnpSearchCollection.h b/amarok/src/core-impl/collections/upnpcollection/UpnpSearchCollection.h deleted file mode 100644 index ea118019..00000000 --- a/amarok/src/core-impl/collections/upnpcollection/UpnpSearchCollection.h +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Nikhil Marathe * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef UPNPSEARCHCOLLECTION_H -#define UPNPSEARCHCOLLECTION_H - -#include "UpnpCollectionBase.h" - -#include -#include -#include -#include -#include -#include - -#include -#include - -namespace KIO { - class Job; - class ListJob; -} -class KJob; - -class QTimer; - -namespace Collections { - -class UpnpQueryMaker; -class UpnpQueryMakerInternal; -class UpnpCache; - -class UpnpSearchCollection : public UpnpCollectionBase -{ - Q_OBJECT - public: - UpnpSearchCollection( const DeviceInfo&, QStringList searchCapabilities ); - virtual ~UpnpSearchCollection(); - virtual QueryMaker* queryMaker(); - - virtual KIcon icon() const { return KIcon("network-server"); } - - Meta::TrackPtr trackForUrl( const KUrl &url ); - - UpnpCache* cache() { return m_cache; } - QStringList searchCapabilities() { return m_searchCapabilities; } - private slots: - void slotFilesChanged(const QStringList &); - - private: - QStringList m_searchCapabilities; - - UpnpCache *m_cache; - - friend class UpnpQueryMakerInternal; -}; - -} //namespace Collections - -#endif diff --git a/amarok/src/core-impl/collections/upnpcollection/amarok_collection-upnpcollection.desktop b/amarok/src/core-impl/collections/upnpcollection/amarok_collection-upnpcollection.desktop deleted file mode 100644 index 31b8ea87..00000000 --- a/amarok/src/core-impl/collections/upnpcollection/amarok_collection-upnpcollection.desktop +++ /dev/null @@ -1,132 +0,0 @@ -[Desktop Entry] -Type=Service -Icon=network-server -Name=UPnP Collection -Name[be]=Калекцыя UPnP -Name[bg]=Колекция UPnP -Name[bs]=UPnP Zbirka -Name[ca]=Col·lecció UPnP -Name[ca@valencia]=Col·lecció UPnP -Name[cs]=Sbírka UPnP -Name[csb]=Kòlekcëjô UPnP -Name[da]=UPnP-samling -Name[de]=UPnP-Sammlung -Name[el]=Συλλογή UPnP -Name[en_GB]=UPnP Collection -Name[es]=Colección UPnP -Name[et]=UPnP kogu -Name[eu]=UPnP bilduma -Name[fi]=UPnP-kokoelma -Name[fr]=Collection « UPnP » -Name[ga]=Bailiúchán UpnP -Name[gl]=Colección UPnP -Name[he]=אוסף UPnP -Name[hne]=यूपीएनपी संग्रह -Name[hu]=UPnP-gyűjtemény -Name[id]=Koleksi UPnP -Name[is]=UPnP safn -Name[it]=Collezione UPnP -Name[ja]=UPnP コレクション -Name[km]=សម្រាំង UPnP -Name[ko]=UPnP 모음집 -Name[ku]=Berhevoka UPnP -Name[lt]=UPnP fonoteka -Name[lv]=UPnP kolekcija -Name[nb]=UPnP-samling -Name[nds]=UPnP-Sammeln -Name[nl]=UPnP-collectie -Name[nn]=UPnP-samling -Name[pa]=UPnP ਭੰਡਾਰ -Name[pl]=Zbiór UPnP -Name[pt]=Colecção de UPnP -Name[pt_BR]=Coleção UPnP -Name[ro]=Colecție UPnP -Name[ru]=Коллекция UPnP -Name[sk]=Kolekcia UPnP -Name[sl]=Zbirka UPnP -Name[sr]=УПнП збирка -Name[sr@ijekavian]=УПнП збирка -Name[sr@ijekavianlatin]=UPnP zbirka -Name[sr@latin]=UPnP zbirka -Name[sv]=UPnP-samling -Name[th]=คลังสื่อของ UPnP -Name[tr]=UPnP Koleksiyonu -Name[uk]=Збірка на UPnP -Name[wa]=Ramexhnêye UPnP -Name[x-test]=xxUPnP Collectionxx -Name[zh_CN]=UPnP 收藏 -Name[zh_TW]=UPnP 收藏 -Comment=UPnP collection plugin for Amarok -Comment[be]=Утулка калекцыі UPnP для Amarok -Comment[bg]=Приставка за колекция UPnP (Amarok) -Comment[bs]=Priključak UPnP zbirke za Amarok -Comment[ca]=Connector de col·leccions UPnP per a l'Amarok -Comment[ca@valencia]=Connector de col·leccions UPnP per a l'Amarok -Comment[cs]=Modul sbírky UPnP pro AmaroK -Comment[csb]=Wtëkôcz kòlekcëji UPnP dlô Amaroka -Comment[da]=Plugin til UPnP-samling til Amarok -Comment[de]=UPnp-Sammlungsmodul für Amarok -Comment[el]=Πρόσθετο συλλογής UPnP για το AmaroK -Comment[en_GB]=UPnP collection plugin for Amarok -Comment[es]=Complemento de la colección UPnP para Amarok -Comment[et]=Amaroki UPnP kogu plugin -Comment[eu]=UPnP bildumen plugina Amarok-entzako -Comment[fi]=Amarokin UPnP-kokoelmaliitännäinen -Comment[fr]=Module externe de collections « UPnP » pour Amarok -Comment[ga]=Breiseán bailiúchán UPnP le haghaidh Amarok -Comment[gl]=Complemento de coleccións UPnP para Amarok -Comment[he]=תוסף אוסף UPnP ל־Amarok -Comment[hne]=अमाराक बर यूपीएनपी संग्रह प्लगइन -Comment[hu]=UPnP-gyűjteményt megvalósító bővítőmodul az Amarokhoz -Comment[id]=Plugin koleksi UPnP untuk Amarok -Comment[is]=UPnP safníforrit fyrir Amarok -Comment[it]=Estensione della collezione UPnP di Amarok -Comment[ja]=Amarok のための UPnP コレクションプラグイン -Comment[km]=កម្មវិធី​ជំនួយ​សម្រាំង UPnP សម្រាប់ Amarok -Comment[ko]=Amarok의 UPnP 모음집 플러그인 -Comment[ku]=Pêveka Berhevoka UPnP ji bo Amarok -Comment[lt]=UPnP fonotekos Amarok papildinys -Comment[lv]=UPnP kolekcijas Amarok spraudnis -Comment[nb]=UPnP-samling – programtillegg for Amarok -Comment[nds]=UPnP-Sammelnmoduul för Amarok -Comment[nl]=UPnP-collectieplugin voor Amarok -Comment[nn]=Amarok-samlingstillegg for UPnP -Comment[pa]=ਅਮਰੋਕ ਲਈ UPnP ਭੰਡਾਰ ਪਲੱਗਇਨ -Comment[pl]=Wtyczka kolekcji UPnP dla Amaroka -Comment[pt]=Um 'plugin' de colecção para UPnP no Amarok -Comment[pt_BR]=Plugin de coleção UPnP para o Amarok -Comment[ro]=Modul de colecție UPnP pentru Amarok -Comment[ru]=Модуль коллекции UPnP для Amarok -Comment[sk]=Modul UPnP kolekcia pre Amarok -Comment[sl]=Vstavek za zbirko UPnP za Amarok -Comment[sr]=Прикључак УПнП збирке за Амарок -Comment[sr@ijekavian]=Прикључак УПнП збирке за Амарок -Comment[sr@ijekavianlatin]=Priključak UPnP zbirke za Amarok -Comment[sr@latin]=Priključak UPnP zbirke za Amarok -Comment[sv]=Insticksprogram med UPnP-samling för Amarok -Comment[th]=ส่วนเสริมของแอมอะร็อก สำหรับจัดการคลังสื่อของ UPnP -Comment[tr]=Amarok için UPnP koleksiyon eklentisi -Comment[uk]=Додаток збірки на UPnP для Amarok -Comment[wa]=Tchôke-divins di ramexhnêye UPnP pos Amarok -Comment[x-test]=xxUPnP collection plugin for Amarokxx -Comment[zh_CN]=Amarok 的 UPnP 收藏插件 -Comment[zh_TW]=Amarok 的 UPnP 收藏外掛程式 - -ServiceTypes=Amarok/Plugin - -X-KDE-Amarok-authors=Nikhil Marathe -X-KDE-Amarok-email=nsm.nikhil@gmail.com -X-KDE-Amarok-framework-version=72 -X-KDE-Amarok-name=upnp-collection -X-KDE-Amarok-plugintype=collection -X-KDE-Amarok-rank=100 -X-KDE-Amarok-version=1 - -X-KDE-PluginInfo-Author=Nikhil Marathe -X-KDE-PluginInfo-Email=nsm.nikhil@gmail.com -X-KDE-PluginInfo-Version=1.0 -X-KDE-PluginInfo-Category=Collection -X-KDE-PluginInfo-License=GPL -X-KDE-PluginInfo-EnabledByDefault=false -X-KDE-PluginInfo-Name=amarok_collection-upnpcollection -X-KDE-Library=amarok_collection-upnpcollection diff --git a/amarok/src/core-impl/collections/upnpcollection/dbuscodec.cpp b/amarok/src/core-impl/collections/upnpcollection/dbuscodec.cpp deleted file mode 100644 index 19b9e459..00000000 --- a/amarok/src/core-impl/collections/upnpcollection/dbuscodec.cpp +++ /dev/null @@ -1,90 +0,0 @@ -/* - This file is part of the Cagibi library, part of the KDE project. - - Copyright 2010 Friedrich W. H. Kossebau - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#include "dbuscodec.h" - -// Qt -#include -#include - -QDBusArgument& operator<<( QDBusArgument& argument, const DeviceInfo0_1_0& device ) -{ - argument.beginStructure(); - - argument << device.type() - << device.friendlyName() - << device.manufacturerName() -// const QString& manufacturerUrl() const; - << device.modelDescription() - << device.modelName() - << device.modelNumber() - << device.serialNumber() - << device.udn() -// const QString upc() const; - << device.presentationUrl(); - - argument << device.host() - << device.port(); - - argument << device.parentDeviceUdn(); - -// const QList& icons() const; -// const QList& services() const; -// const QList& devices() const; - - argument.endStructure(); - - return argument; -} - -const QDBusArgument& operator>>( const QDBusArgument& argument, - DeviceInfo0_1_0& device ) -{ - argument.beginStructure(); - - argument >> device.m_type - >> device.m_friendlyName - >> device.m_manufacturerName -// const QString& manufacturerUrl() const; - >> device.m_modelDescription - >> device.m_modelName - >> device.m_modelNumber - >> device.m_serialNumber - >> device.m_udn -// const QString upc() const; - >> device.m_presentationUrl; - - - QString parentDeviceUdn; - argument >> parentDeviceUdn; -// << ( device.hasParentDevice() ? -// device.parentDevice().udn() : -// QString() ); - -// const QList& icons() const; -// const QList& services() const; -// const QList& devices() const; - - argument.endStructure(); - - return argument; -} diff --git a/amarok/src/core-impl/collections/upnpcollection/dbuscodec.h b/amarok/src/core-impl/collections/upnpcollection/dbuscodec.h deleted file mode 100644 index 0b73e45a..00000000 --- a/amarok/src/core-impl/collections/upnpcollection/dbuscodec.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - This file is part of the Cagibi library, part of the KDE project. - - Copyright 2010 Friedrich W. H. Kossebau - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef DBUSCODEC_H -#define DBUSCODEC_H - -// lib -#include "deviceinfo.h" -// Qt -#include -// #include - -class QDBusArgument; -QDBusArgument& operator<<( QDBusArgument &argument, - const DeviceInfo0_1_0 &device ); -const QDBusArgument& operator>>( const QDBusArgument &argument, - DeviceInfo0_1_0 &device ); -#endif diff --git a/amarok/src/core-impl/collections/upnpcollection/deviceinfo.h b/amarok/src/core-impl/collections/upnpcollection/deviceinfo.h deleted file mode 100644 index b60c8d2a..00000000 --- a/amarok/src/core-impl/collections/upnpcollection/deviceinfo.h +++ /dev/null @@ -1,178 +0,0 @@ -/* - This file is part of the UPnP MediaServer Kioslave library, part of the KDE project. - - Copyright 2010 Nikhil Marathe - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef DEVICEINFO_H -#define DEVICEINFO_H - -#include -#include - -class DeviceInfo; - -class DeviceInfo0_1_0; -class DeviceInfo0_2_0; - -extern const QDBusArgument& operator>>( const QDBusArgument& argument, DeviceInfo0_1_0& device ); - -typedef QMap DeviceDetailsMap; - -class DeviceInfo -{ -public: - const QString& type() const; - const QString& friendlyName() const; - const QString& manufacturerName() const; - const QString& modelDescription() const; - const QString& modelName() const; - const QString& modelNumber() const; - const QString& serialNumber() const; - const QString& udn() const; - QString uuid() const; - const QString& presentationUrl() const; - - const QString& host() const; - int port() const; - - const QString& parentDeviceUdn() const; - - bool isValid() const; - -protected: - QString m_type; - QString m_friendlyName; - QString m_manufacturerName; - QString m_modelDescription; - QString m_modelName; - QString m_modelNumber; - QString m_serialNumber; - QString m_udn; - QString m_presentationUrl; - - QString m_host; - int m_port; - - QString m_parentDeviceUdn; - -}; - -inline bool DeviceInfo::isValid() const -{ - return !m_type.isNull(); -} - -inline const QString& DeviceInfo::type() const -{ - return m_type; -} - -inline const QString& DeviceInfo::friendlyName() const -{ - return m_friendlyName; -} - -inline const QString& DeviceInfo::manufacturerName() const -{ - return m_manufacturerName; -} - -inline const QString& DeviceInfo::modelDescription() const -{ - return m_modelDescription; -} - -inline const QString& DeviceInfo::modelName() const -{ - return m_modelName; -} - -inline const QString& DeviceInfo::modelNumber() const -{ - return m_modelNumber; -} - -inline const QString& DeviceInfo::serialNumber() const -{ - return m_serialNumber; -} - -inline const QString& DeviceInfo::udn() const -{ - return m_udn; -} - -inline const QString& DeviceInfo::presentationUrl() const -{ - return m_presentationUrl; -} - -inline const QString& DeviceInfo::host() const -{ - return m_host; -} - -inline int DeviceInfo::port() const -{ - return m_port; -} - -inline const QString& DeviceInfo::parentDeviceUdn() const -{ - return m_parentDeviceUdn; -} - -inline QString DeviceInfo::uuid() const -{ - return QString( udn() ).replace( "uuid:", "" ); -} - -class DeviceInfo0_1_0 : public DeviceInfo -{ -friend const QDBusArgument& operator>>( const QDBusArgument& argument, DeviceInfo0_1_0& device ); -}; - -class DeviceInfo0_2_0 : public DeviceInfo -{ -public: - DeviceInfo0_2_0( const DeviceDetailsMap &map ) - { - m_type = map.value( "deviceType" ); - m_friendlyName = map.value( "friendlyName" ); - m_manufacturerName = map.value( "manufacturer" ); - m_modelDescription = map.value( "modelDescription" ); - m_modelName = map.value( "modelName" ); - m_modelNumber = map.value( "modelNumber" ); - m_serialNumber = map.value( "serialNumber" ); - m_udn = map.value( "UDN" ); - m_presentationUrl = map.value( "presentationURL" ); - - m_host = map.value( "ipAddress" ); - m_port = map.value( "ipPortNumber" ).toUInt(); - - m_parentDeviceUdn = map.value( "parentDeviceUDN" ); - - } -}; - -Q_DECLARE_METATYPE( DeviceInfo ) -Q_DECLARE_METATYPE( DeviceInfo0_1_0 ) -Q_DECLARE_METATYPE( DeviceDetailsMap ) -#endif diff --git a/amarok/src/core-impl/collections/upnpcollection/upnptypes.h b/amarok/src/core-impl/collections/upnpcollection/upnptypes.h deleted file mode 100644 index f0a7a713..00000000 --- a/amarok/src/core-impl/collections/upnpcollection/upnptypes.h +++ /dev/null @@ -1,116 +0,0 @@ -/******************************************************************** - This file is part of the KDE project. - -Copyright (C) 2010 Nikhil Marathe - -This program 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 2 of the License, or -(at your option) any later version. - -This program 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 this program. If not, see . -*********************************************************************/ - -/** - * @file Provides extra UDSEntry field types for UPnP specific meta-data - */ - -#ifndef UPNPTYPES_H -#define UPNPTYPES_H - -#include - -namespace KIO { - -/** -* This enumeration defines some custom UDS fields to allow -* UPnP metadata to be exposed. UPnP provides a number -* of fields for meta-data which adheres to the recommended -* properties in the DLNA specification ( August 2009 ) -* -* Certain fields are shared, such as UPNP_DURATION which applies -* to audioItems and videoItems. -* -* When a resource is available, size is advertised using the -* UDS_SIZE value, there is no special UPNP_SIZE. -* -* Note: when adding new fields, remember, the restriction is 39 -* fields. -* -* Very Important: It seems fields using UDS_EXTRA as a base -* can only be of type String. I don't know why since the UDSEntry -* implementation never internally uses enum values but only -* uint which should be able to fit a number too. But it doesn't seem to -* work, at least for UPNP_TRACK_NUMBER. The field is set properly, -* it is accessible within the kioslave. Even copying the entry is fine. -* -* When emitted to the Job, the Job's UDSEntry reports as containing -* that field, but its value is reported as 0. -*/ - -enum UPnPFieldTypes { - UPNP_CLASS = ( UDSEntry::UDS_EXTRA + 1 ) | UDSEntry::UDS_STRING, - - // object.item.audioItem - - UPNP_CREATOR = ( UDSEntry::UDS_EXTRA + 2 ) | UDSEntry::UDS_STRING, - /// The Album to which the item belongs - UPNP_ALBUM = ( UDSEntry::UDS_EXTRA + 3 ) | UDSEntry::UDS_STRING, - /// The genre - UPNP_GENRE = ( UDSEntry::UDS_EXTRA + 4 ) | UDSEntry::UDS_STRING, - /// Duration of the content in "HH:MM:SS" - UPNP_DURATION = (UDSEntry::UDS_EXTRA + 5 ) | UDSEntry::UDS_STRING, - - // object.item.imageItem - - // NOTE: for date, should we convert if the device isn't formatting properly? - // TODO: should we use the UDS_TIME format modeled by long long - // instead and handle the conversion? - - /// the date the image was taken. This may not be the same - /// as the access time or file creation time and so has a - /// separate field. - /// Date is in ISO format, see the UPnP ContentDirectory service - /// specification for details. - UPNP_DATE = ( UDSEntry::UDS_EXTRA + 6 ) | UDSEntry::UDS_STRING, - /// Image resolution, "[0-9]+x[0-9]+" in pixels - UPNP_IMAGE_RESOLUTION = ( UDSEntry::UDS_EXTRA + 7 ) | UDSEntry::UDS_STRING, - - // object.item.videoItem - // none unique - - // object.container.album.musicAlbum - UPNP_ALBUM_CHILDCOUNT = ( UDSEntry::UDS_EXTRA + 8 ) | UDSEntry::UDS_NUMBER, - - // object.item.videoItem.videoBroadcast, object.item.audioItem.audioBroadcast - UPNP_CHANNEL_NAME = ( UDSEntry::UDS_EXTRA + 9 ) | UDSEntry::UDS_STRING, - UPNP_CHANNEL_NUMBER = ( UDSEntry::UDS_EXTRA + 10 ) | UDSEntry::UDS_NUMBER, - - /// Track number in the Album (audioItems) - UPNP_TRACK_NUMBER = ( UDSEntry::UDS_EXTRA + 11 ) | UDSEntry::UDS_STRING, - - - // These are types not recommended by DLNA but good for - // Amarok :) - UPNP_BITRATE = ( UDSEntry::UDS_EXTRA + 12 ) | UDSEntry::UDS_STRING, - - // and these are good for UPNP-aware applications - // which will need to keep track of changes and so on. - UPNP_ID = ( UDSEntry::UDS_EXTRA + 13 ) | UDSEntry::UDS_STRING, - UPNP_PARENT_ID = ( UDSEntry::UDS_EXTRA + 14 ) | UDSEntry::UDS_STRING, - - UPNP_ALBUMART_URI = ( UDSEntry::UDS_EXTRA + 15 ) | UDSEntry::UDS_STRING, - - UPNP_ARTIST = ( UDSEntry::UDS_EXTRA + 16 ) | UDSEntry::UDS_STRING, - - UPNP_REF_ID = ( UDSEntry::UDS_EXTRA + 17 ) | UDSEntry::UDS_STRING -}; -} - -#endif diff --git a/amarok/src/core-impl/logger/ProxyLogger.cpp b/amarok/src/core-impl/logger/ProxyLogger.cpp deleted file mode 100644 index 6e507050..00000000 --- a/amarok/src/core-impl/logger/ProxyLogger.cpp +++ /dev/null @@ -1,187 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "ProxyLogger.h" - -#include -#include -#include - -ProxyLogger::ProxyLogger() - : Amarok::Logger() - , m_logger( 0 ) - , m_timer( 0 ) -{ - // ensure that the object livs in the GUI thread - Q_ASSERT( thread() == QCoreApplication::instance()->thread() ); - - m_timer = new QTimer( this ); - connect( m_timer, SIGNAL(timeout()), this, SLOT(forwardNotifications()) ); - m_timer->setSingleShot( true ); - m_timer->setInterval( 0 ); - - connect( this, SIGNAL(startTimer()), SLOT(slotStartTimer()) ); -} - -ProxyLogger::~ProxyLogger() -{ - //nothing to do -} - -void -ProxyLogger::setLogger( Amarok::Logger *logger ) -{ - m_logger = logger; - emit startTimer(); -} - -Amarok::Logger * -ProxyLogger::logger() const -{ - return m_logger; -} - -void -ProxyLogger::slotStartTimer() -{ - if( m_logger && !m_timer->isActive() ) - m_timer->start(); -} - -void -ProxyLogger::shortMessage( const QString &text ) -{ - QMutexLocker locker( &m_lock ); - m_shortMessageQueue.enqueue( text ); - emit startTimer(); -} - -void -ProxyLogger::longMessage( const QString &text, MessageType type ) -{ - QMutexLocker locker( &m_lock ); - LongMessage msg; - msg.first = text; - msg.second = type; - m_longMessageQueue.enqueue( msg ); - emit startTimer(); -} - -void -ProxyLogger::newProgressOperation( KJob *job, const QString &text, QObject *obj, const char *slot, Qt::ConnectionType type ) -{ - QMutexLocker locker( &m_lock ); - ProgressData data; - data.job = job; - data.text = text; - data.cancelObject = obj; - data.slot = slot; - data.type = type; - m_progressQueue.enqueue( data ); - emit startTimer(); -} - -void -ProxyLogger::newProgressOperation( QNetworkReply *reply, const QString &text, QObject *obj, const char *slot, Qt::ConnectionType type ) -{ - QMutexLocker locker( &m_lock ); - ProgressData data; - data.reply = reply; - data.text = text; - data.cancelObject = obj; - data.slot = slot; - data.type = type; - m_progressQueue.enqueue( data ); - emit startTimer(); -} - -void -ProxyLogger::newProgressOperation( QObject *sender, const QString &text, int maximum, QObject *obj, - const char *slot, Qt::ConnectionType type ) -{ - QMutexLocker locker( &m_lock ); - ProgressData data; - data.sender = sender; - data.text = text; - data.maximum = maximum; - data.cancelObject = obj; - data.slot = slot; - data.type = type; - m_progressQueue.enqueue( data ); - connect( sender, SIGNAL(totalSteps(int)), SLOT(slotTotalSteps(int)) ); - emit startTimer(); -} - -void -ProxyLogger::forwardNotifications() -{ - QMutexLocker locker( &m_lock ); - if( !m_logger ) - return; //can't do anything before m_logger is created. - - while( !m_shortMessageQueue.isEmpty() ) - { - m_logger->shortMessage( m_shortMessageQueue.dequeue() ); - } - while( !m_longMessageQueue.isEmpty() ) - { - LongMessage msg = m_longMessageQueue.dequeue(); - m_logger->longMessage( msg.first, msg.second ); - } - while( !m_progressQueue.isEmpty() ) - { - ProgressData d = m_progressQueue.dequeue(); - if( d.job ) - { - m_logger->newProgressOperation( d.job.data(), d.text, d.cancelObject.data(), - d.cancelObject.data() ? d.slot : 0 , d.type ); - } - else if( d.reply ) - { - m_logger->newProgressOperation( d.reply.data(), d.text, d.cancelObject.data(), - d.cancelObject.data() ? d.slot : 0 , d.type ); - } - else if( d.sender ) - { - // m_logger handles the signals from now on - disconnect( d.sender.data(), 0, this, 0 ); - m_logger->newProgressOperation( d.sender.data(), d.text, d.maximum, - d.cancelObject.data(), - d.cancelObject.data() ? d.slot : 0 , d.type ); - } - } -} - -void -ProxyLogger::slotTotalSteps( int totalSteps ) -{ - QObject *operation = sender(); - if( !operation ) - // warning, slotTotalSteps can only be connected to progress operation QObject signal - return; - QMutableListIterator it( m_progressQueue ); - while( it.hasNext() ) - { - ProgressData &data = it.next(); - if( data.sender.data() != operation ) - continue; - data.maximum = totalSteps; - return; - } - // warning, operation not found in m_progressQueue -} - -#include "moc_ProxyLogger.cpp" diff --git a/amarok/src/core-impl/logger/ProxyLogger.h b/amarok/src/core-impl/logger/ProxyLogger.h deleted file mode 100644 index c8d37cbe..00000000 --- a/amarok/src/core-impl/logger/ProxyLogger.h +++ /dev/null @@ -1,108 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_PROXY_LOGGER_H -#define AMAROK_PROXY_LOGGER_H - -#include "core/interfaces/Logger.h" - -#include -#include -#include -#include -#include -#include - -#include - -class QNetworkReply; - -typedef QPair LongMessage; - -struct ProgressData -{ - QWeakPointer sender; - QWeakPointer job; - QWeakPointer reply; - QString text; - int maximum; - QWeakPointer cancelObject; - const char *slot; - Qt::ConnectionType type; -}; - -/** - * Proxy implementation for the Amarok::Logger interface. - * This class does not notify the user, but forwards the notifications - * to a real logger if available. If no logger is available yet, it stores - * the notifications until another logger becomes available. - * - * This class can be only instantiated from the main thread and must reside in the main - * thread for its lifetime. - */ -class ProxyLogger : public QObject, public Amarok::Logger -{ - Q_OBJECT - Q_PROPERTY( Amarok::Logger* logger - READ logger - WRITE setLogger - DESIGNABLE false ) - -public: - ProxyLogger(); - virtual ~ProxyLogger(); - -public slots: - virtual void shortMessage( const QString &text ); - virtual void longMessage( const QString &text, MessageType type ); - virtual void newProgressOperation( KJob *job, const QString &text, QObject *obj = 0, - const char *slot = 0, - Qt::ConnectionType type = Qt::AutoConnection ); - virtual void newProgressOperation( QNetworkReply *reply, const QString &text, QObject *obj = 0, - const char *slot = 0, - Qt::ConnectionType type = Qt::AutoConnection ); - virtual void newProgressOperation( QObject *sender, const QString &text, int maximum = 100, - QObject *obj = 0, const char *slot = 0, - Qt::ConnectionType type = Qt::AutoConnection ); - - /** - * Set the real logger. - * The proxy logger will forward notifications to this logger. - * @param logger The real logger to use. ProxyLogger does not take ownership of the pointer - */ - void setLogger( Logger *logger ); - Logger* logger() const; - -private slots: - void forwardNotifications(); - void slotStartTimer(); - void slotTotalSteps( int totalSteps ); - -signals: - // timer can only be started from its thread, use signals & slots to pass thread barrier - void startTimer(); - -private: - Logger *m_logger; //!< stores the real logger - QMutex m_lock; //!< protect members that may be accessed from multiple threads - QTimer *m_timer; //!< internal timer that triggers forwarding of notifications - QQueue m_shortMessageQueue; //!< temporary storage for notifications that have not been forwarded yet - QQueue m_longMessageQueue; //!< temporary storage for notifications that have not been forwarded yet - QQueue m_progressQueue; //!< temporary storage for notifications that have not been forwarded yet -}; - -Q_DECLARE_METATYPE(ProxyLogger *) -#endif diff --git a/amarok/src/core-impl/meta/cue/CueFileSupport.cpp b/amarok/src/core-impl/meta/cue/CueFileSupport.cpp deleted file mode 100644 index 30361dd2..00000000 --- a/amarok/src/core-impl/meta/cue/CueFileSupport.cpp +++ /dev/null @@ -1,456 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 Pulic License for more details. * - * * - * You should have received a copy of the GNU General Public License along with * - * this program. If not, see . * - ****************************************************************************************/ - - -#include "CueFileSupport.h" - -#include "core/support/Debug.h" -#include "core-impl/meta/timecode/TimecodeMeta.h" - -#include -#include -#include - -using namespace MetaCue; - -/** -* Parses a cue sheet file into CueFileItems and inserts them in a QMap -* @return a map of CueFileItems. If the cue file was not successfully loaded -* the map is empty. -* @author (C) 2005 by Martin Ehmke -*/ - -CueFileItemMap CueFileSupport::loadCueFile( const KUrl &cuefile, const Meta::TrackPtr track ) -{ - return loadCueFile( cuefile, track->playableUrl(), track->length() ); -} - - -CueFileItemMap CueFileSupport::loadCueFile( const KUrl &cuefile, const KUrl &trackUrl, qint64 trackLen ) -{ - - DEBUG_BLOCK - - CueFileItemMap cueItems; - - debug() << "CUEFILE: " << cuefile.pathOrUrl(); - if ( QFile::exists ( cuefile.pathOrUrl() ) ) - { - debug() << " EXISTS!"; - QFile file ( cuefile.pathOrUrl() ); - int trackNr = 0; - QString defaultArtist; - QString defaultAlbum; - QString artist; - QString title; - long length = 0; - long prevIndex = -1; - bool index00Present = false; - long index = -1; - bool filesSection = false; - bool fileFound = false; - - int mode = BEGIN; - if ( file.open ( QIODevice::ReadOnly ) ) - { - QTextStream stream ( &file ); - QString line; - - file.seek( 0 ); - - stream.setAutoDetectUnicode(true); - - while ( !stream.atEnd() ) - { - line = stream.readLine().simplified(); - - if ( line.startsWith ( "title", Qt::CaseInsensitive ) ) - { - title = line.mid ( 6 ).remove ( '"' ); - if ( mode == BEGIN && !filesSection ) - { - defaultAlbum = title; - title.clear(); - debug() << "Album: " << defaultAlbum; - } - else if( !fileFound ) - { - title.clear(); - continue; - } - else - debug() << "Title: " << title; - } - - else if ( line.startsWith ( "performer", Qt::CaseInsensitive ) ) - { - artist = line.mid ( 10 ).remove ( '"' ); - if ( mode == BEGIN && !filesSection ) - { - defaultArtist = artist; - artist.clear(); - debug() << "Album Artist: " << defaultArtist; - } - else if( !fileFound ) - { - artist.clear(); - continue; - } - else - debug() << "Artist: " << artist; - } - - else if ( line.startsWith ( "track", Qt::CaseInsensitive ) && fileFound ) - { - if ( mode == TRACK_FOUND ) - { - // not valid, because we have to have an index for the previous track - file.close(); - debug() << "Mode is TRACK_FOUND, abort."; - return CueFileItemMap(); - } - else if ( mode == INDEX_FOUND ) - { - if ( artist.isNull() ) - artist = defaultArtist; - - debug() << "Inserting item: " << title << " - " << artist << " on " << defaultAlbum << " (" << trackNr << ")"; - // add previous entry to map - cueItems.insert ( index, CueFileItem ( title, artist, defaultAlbum, trackNr, index ) ); - prevIndex = index; - title.clear(); - artist.clear(); - trackNr = 0; - } - trackNr = line.section ( ' ',1,1 ).toInt(); - debug() << "Track: " << trackNr; - mode = TRACK_FOUND; - } - else if ( line.startsWith ( "index", Qt::CaseInsensitive ) && fileFound ) - { - if ( mode == TRACK_FOUND ) - { - int indexNo = line.section ( ' ',1,1 ).toInt(); - - if ( indexNo == 1 ) - { - QStringList time = line.section ( ' ', -1, -1 ).split ( ':' ); - - index = time[0].toLong() *60*1000 + time[1].toLong() *1000 + time[2].toLong() *1000/75; //75 frames per second - - if ( prevIndex != -1 && !index00Present ) // set the prev track's length if there is INDEX01 present, but no INDEX00 - { - length = index - prevIndex; - debug() << "Setting length of track " << cueItems[prevIndex].title() << " to " << length << " msecs."; - cueItems[prevIndex].setLength ( length ); - } - - index00Present = false; - mode = INDEX_FOUND; - length = 0; - } - - else if ( indexNo == 0 ) // gap, use to calc prev track length - { - QStringList time = line.section ( ' ', -1, -1 ).split ( ':' ); - - length = time[0].toLong() * 60 * 1000 + time[1].toLong() * 1000 + time[2].toLong() *1000/75; //75 frames per second - - if ( prevIndex != -1 ) - { - length -= prevIndex; //this[prevIndex].getIndex(); - debug() << "Setting length of track " << cueItems[prevIndex].title() << " to " << length << " msecs."; - cueItems[prevIndex].setLength ( length ); - index00Present = true; - } - else - length = 0; - } - else - { - debug() << "Skipping unsupported INDEX " << indexNo; - } - } - else - { - // not valid, because we don't have an associated track - file.close(); - debug() << "Mode is not TRACK_FOUND but encountered INDEX, abort."; - return CueFileItemMap(); - } - debug() << "index: " << index; - } - else if( line.startsWith ( "file", Qt::CaseInsensitive ) ) - { - QString file = line.mid ( 5 ).remove ( '"' ); - if( fileFound ) - break; - - fileFound = file.contains ( trackUrl.fileName(), Qt::CaseInsensitive ); - filesSection = true; - } - } - - if ( artist.isNull() ) - artist = defaultArtist; - - debug() << "Inserting item: " << title << " - " << artist << " on " << defaultAlbum << " (" << trackNr << ")"; - // add previous entry to map - cueItems.insert ( index, CueFileItem ( title, artist, defaultAlbum, trackNr, index ) ); - file.close(); - } - - /** - * Because there is no way to set the length for the last track in a normal way, - * we have to do some magic here. Having the total length of the media file given - * we can set the lenth for the last track after all the cue file was loaded into array. - */ - - cueItems[index].setLength ( trackLen - index ); - debug() << "Setting length of track " << cueItems[index].title() << " to " << trackLen - index << " msecs."; - - return cueItems; - } - return CueFileItemMap(); -} - -KUrl CueFileSupport::locateCueSheet ( const KUrl &trackurl ) -{ - if ( !trackurl.isValid() || !trackurl.isLocalFile() ) - return KUrl(); - // look for the cue file that matches the media file - QString path = trackurl.path(); - QString cueFile = path.left ( path.lastIndexOf ( '.' ) ) + ".cue"; - - if ( validateCueSheet ( cueFile ) ) - { - debug() << "[CUEFILE]: " << cueFile << " - Shoot blindly, found and loaded. "; - return KUrl ( cueFile ); - } - debug() << "[CUEFILE]: " << cueFile << " - Shoot blindly and missed, searching for other cue files."; - - bool foundCueFile = false; - QDir dir ( trackurl.directory() ); - QStringList filters; - filters << "*.cue" << "*.CUE"; - dir.setNameFilters ( filters ); - - QStringList cueFilesList = dir.entryList(); - - if ( !cueFilesList.empty() ) - for ( QStringList::Iterator it = cueFilesList.begin(); it != cueFilesList.end() && !foundCueFile; ++it ) - { - QFile file ( dir.filePath ( *it ) ); - if ( file.open ( QIODevice::ReadOnly ) ) - { - debug() << "[CUEFILE]: " << *it << " - Opened, looking for the matching FILE stanza." << endl; - QTextStream stream ( &file ); - QString line; - - while ( !stream.atEnd() && !foundCueFile ) - { - line = stream.readLine().simplified(); - - if ( line.startsWith ( "file", Qt::CaseInsensitive ) ) - { - line = line.mid ( 5 ).remove ( '"' ); - - if ( line.contains ( trackurl.fileName(), Qt::CaseInsensitive ) ) - { - cueFile = dir.filePath ( *it ); - - if ( validateCueSheet ( cueFile ) ) - { - debug() << "[CUEFILE]: " << cueFile << " - Looked inside cue files, found and loaded proper one" << endl; - foundCueFile = true; - } - } - } - } - - file.close(); - } - } - - if ( foundCueFile ) - return KUrl ( cueFile ); - debug() << "[CUEFILE]: - Didn't find any matching cue file." << endl; - return KUrl(); -} - -bool CueFileSupport::validateCueSheet ( const QString& cuefile ) -{ - if ( !QFile::exists ( cuefile ) ) - return false; - - QFile file ( cuefile ); - int track = 0; - QString defaultArtist; - QString defaultAlbum; - QString artist; - QString title; - long length = 0; - long prevIndex = -1; - bool index00Present = false; - long index = -1; - - int mode = BEGIN; - if ( file.open ( QIODevice::ReadOnly ) ) - { - QTextStream stream ( &file ); - QString line; - - while ( !stream.atEnd() ) - { - line = stream.readLine().simplified(); - - if ( line.startsWith ( "title", Qt::CaseInsensitive ) ) - { - title = line.mid ( 6 ).remove ( '"' ); - if ( mode == BEGIN ) - { - defaultAlbum = title; - title.clear(); - debug() << "Album: " << defaultAlbum; - } - else - debug() << "Title: " << title; - } - - else if ( line.startsWith ( "performer", Qt::CaseInsensitive ) ) - { - artist = line.mid ( 10 ).remove ( '"' ); - if ( mode == BEGIN ) - { - defaultArtist = artist; - artist.clear(); - debug() << "Album Artist: " << defaultArtist; - } - else - debug() << "Artist: " << artist; - } - - else if ( line.startsWith ( "track", Qt::CaseInsensitive ) ) - { - if ( mode == TRACK_FOUND ) - { - // not valid, because we have to have an index for the previous track - file.close(); - debug() << "Mode is TRACK_FOUND, abort."; - return false; - } - if ( mode == INDEX_FOUND ) - { - if ( artist.isNull() ) - artist = defaultArtist; - - prevIndex = index; - title.clear(); - artist.clear(); - track = 0; - } - track = line.section ( ' ',1,1 ).toInt(); - debug() << "Track: " << track; - mode = TRACK_FOUND; - } - else if ( line.startsWith ( "index", Qt::CaseInsensitive ) ) - { - if ( mode == TRACK_FOUND ) - { - int indexNo = line.section ( ' ',1,1 ).toInt(); - - if ( indexNo == 1 ) - { - QStringList time = line.section ( ' ', -1, -1 ).split ( ':' ); - - index = time[0].toLong() *60*1000 + time[1].toLong() *1000 + time[2].toLong() *1000/75; //75 frames per second - - if ( prevIndex != -1 && !index00Present ) // set the prev track's length if there is INDEX01 present, but no INDEX00 - { - length = index - prevIndex; - } - - index00Present = false; - mode = INDEX_FOUND; - length = 0; - } - - else if ( indexNo == 0 ) // gap, use to calc prev track length - { - QStringList time = line.section ( ' ', -1, -1 ).split ( ':' ); - - length = time[0].toLong() *60*1000 + time[1].toLong() *1000 + time[2].toLong() *1000/75; //75 frames per second - - if ( prevIndex != -1 ) - { - length -= prevIndex; //this[prevIndex].getIndex(); - index00Present = true; - } - else - length = 0; - } - else - { - debug() << "Skipping unsupported INDEX " << indexNo; - } - } - else - { - // not valid, because we don't have an associated track - file.close(); - debug() << "Mode is not TRACK_FOUND but encountered INDEX, abort."; - return false; - } - debug() << "index: " << index; - } - } - - if( mode == BEGIN ) - { - file.close(); - debug() << "Cue file is invalid"; - return false; - } - - if ( artist.isNull() ) - artist = defaultArtist; - - file.close(); - } - return true; -} - - -Meta::TrackList -CueFileSupport::generateTimeCodeTracks( Meta::TrackPtr baseTrack, CueFileItemMap itemMap ) -{ - Meta::TrackList trackList; - - foreach( const CueFileItem &item, itemMap ) - { - Meta::TimecodeTrack *track = new Meta::TimecodeTrack( item.title(), - baseTrack->playableUrl().url(), item.index(), item.index() + item.length() ); - track->beginUpdate(); - track->setArtist( item.artist() ); - track->setAlbum( item.album() ); - track->setTrackNumber( item.trackNumber() ); - track->endUpdate(); - - trackList << Meta::TrackPtr( track ); - } - - return trackList; -} diff --git a/amarok/src/core-impl/meta/cue/CueFileSupport.h b/amarok/src/core-impl/meta/cue/CueFileSupport.h deleted file mode 100644 index e8699ccf..00000000 --- a/amarok/src/core-impl/meta/cue/CueFileSupport.h +++ /dev/null @@ -1,130 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 Pulic License for more details. * - * * - * You should have received a copy of the GNU General Public License along with * - * this program. If not, see . * - ****************************************************************************************/ - - -#ifndef CUEFILESUPPORT_H -#define CUEFILESUPPORT_H - -#include "core/meta/forward_declarations.h" - -#include - -#include -#include -#include - -namespace MetaCue -{ - -class CueFileItem -{ -public: - CueFileItem ( const QString& title, const QString& artist, const QString& album, const int trackNumber, const long index ) - : m_title ( title ) - , m_artist ( artist ) - , m_album ( album ) - , m_trackNumber ( trackNumber ) - , m_index ( index ) - , m_length ( -1 ) - {} - - CueFileItem() - : m_title( ) - , m_artist( ) - , m_album( ) - , m_trackNumber ( -1 ) - , m_index ( -1 ) - , m_length ( -1 ) - {} - void setLength ( const long length ) - { - m_length = length; - } - const QString title () const - { - return m_title; - } - const QString artist () const - { - return m_artist; - } - const QString album () const - { - return m_album; - } - int trackNumber () const - { - return m_trackNumber; - } - long index () const - { - return m_index; - } - long length () const - { - return m_length; - } - -private: - QString m_title; - QString m_artist; - QString m_album; - int m_trackNumber; - long m_index; - long m_length; - - //QSet observers; - KUrl m_url; -}; - -typedef QMap CueFileItemMap; - - -class CueFileSupport -{ - - public: - - enum Markers - { - BEGIN = 0, - TRACK_FOUND, // track found, index not yet found - INDEX_FOUND - }; - - static CueFileItemMap loadCueFile( const KUrl &cuefile, const Meta::TrackPtr track ); - static CueFileItemMap loadCueFile( const KUrl &cuefile, const KUrl &trackUrl, qint64 trackLen ); - - /** - * Used to locate a cue sheet for a local track. - * @return A KUrl containing the url for the cue sheet - * if a valid one was located - */ - static KUrl locateCueSheet ( const KUrl &trackurl ); - - /** - * Attempts to load and parse a cue sheet. - * @return true if the cue sheet is valid - * false if the cue sheet is invalid - */ - static bool validateCueSheet ( const QString& cuefile ); - - static Meta::TrackList generateTimeCodeTracks( Meta::TrackPtr baseTrack, CueFileItemMap itemMap ); -}; - -} - -#endif // CUEFILESUPPORT_H diff --git a/amarok/src/core-impl/meta/default/DefaultMetaTypes.h b/amarok/src/core-impl/meta/default/DefaultMetaTypes.h deleted file mode 100644 index ace05311..00000000 --- a/amarok/src/core-impl/meta/default/DefaultMetaTypes.h +++ /dev/null @@ -1,114 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) version 3 or * - * any later version accepted by the membership of KDE e.V. (or its successor approved * - * by the membership of KDE e.V.), which shall act as a proxy defined in Section 14 of * - * version 3 of the license. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef DEFAULTMETATYPES_H -#define DEFAULTMETATYPES_H - -#include "amarok_export.h" -#include "core/support/Debug.h" -#include "core/meta/Meta.h" - -#include - - -namespace Meta -{ - -class AMAROK_EXPORT DefaultArtist : public Meta::Artist -{ - public: - - DefaultArtist() {}; - virtual ~DefaultArtist() {}; - - virtual QString name() const { return i18nc( "The value is not known", "Unknown" ); } - - virtual TrackList tracks() { return TrackList(); } -}; - -class AMAROK_EXPORT DefaultAlbum : public Meta::Album -{ - public: - - DefaultAlbum() - : Meta::Album() - , m_albumArtist( new DefaultArtist() ) {} - virtual ~DefaultAlbum() {}; - - virtual bool hasAlbumArtist() const { return true; } - virtual ArtistPtr albumArtist() const { return m_albumArtist; } - - virtual bool isCompilation() const { return false; } - - virtual QString name() const { return i18nc( "The Value is not known", "Unknown" ); } - - virtual TrackList tracks() { return TrackList(); } - - private: - Meta::ArtistPtr m_albumArtist; - -}; - - -class AMAROK_EXPORT DefaultComposer : public Meta::Composer -{ - public: - - DefaultComposer() {}; - virtual ~DefaultComposer() {}; - - virtual QString name() const { return i18nc( "The value is not known", "Unknown" ); } - - virtual TrackList tracks() { return TrackList(); } - - private: - - static ComposerPtr s_instance; - -}; - -class AMAROK_EXPORT DefaultGenre : public Meta::Genre -{ - public: - - DefaultGenre() {}; - virtual ~DefaultGenre() {}; - - virtual QString name() const { return i18nc( "The value is not known", "Unknown" ); } - - virtual TrackList tracks() { return TrackList(); } - -}; -class AMAROK_EXPORT DefaultYear : public Meta::Year -{ - public: - - DefaultYear() {}; - virtual ~DefaultYear() {}; - - virtual QString name() const { return "0"; } - - virtual TrackList tracks() { return TrackList(); } - -}; - -} - -#endif - - diff --git a/amarok/src/core-impl/meta/file/File.cpp b/amarok/src/core-impl/meta/file/File.cpp deleted file mode 100644 index c413bbad..00000000 --- a/amarok/src/core-impl/meta/file/File.cpp +++ /dev/null @@ -1,596 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Maximilian Kossick * - * Copyright (c) 2008 Seb Ruiz * - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "File.h" -#include "File_p.h" - -#include -#ifdef HAVE_LIBLASTFM -#include "LastfmReadLabelCapability.h" -#endif -#include "MainWindow.h" -#include "amarokurls/BookmarkMetaActions.h" -#include "amarokurls/PlayUrlRunner.h" -#include "browsers/filebrowser/FileBrowser.h" -#include "core/capabilities/BookmarkThisCapability.h" -#include "core/capabilities/FindInSourceCapability.h" -#include "core/meta/Meta.h" -#include "core/meta/support/MetaUtility.h" -#include "core/playlists/PlaylistFormat.h" -#include "core/support/Amarok.h" -#include "core-impl/capabilities/timecode/TimecodeWriteCapability.h" -#include "core-impl/capabilities/timecode/TimecodeLoadCapability.h" -#include "core-impl/support/UrlStatisticsStore.h" - -#include - -#include -#include -#include -#include -#include - -using namespace MetaFile; - -class TimecodeWriteCapabilityImpl : public Capabilities::TimecodeWriteCapability -{ - public: - TimecodeWriteCapabilityImpl( MetaFile::Track *track ) - : Capabilities::TimecodeWriteCapability() - , m_track( track ) - {} - - virtual bool writeTimecode ( qint64 miliseconds ) - { - DEBUG_BLOCK - return Capabilities::TimecodeWriteCapability::writeTimecode( miliseconds, Meta::TrackPtr( m_track.data() ) ); - } - - virtual bool writeAutoTimecode ( qint64 miliseconds ) - { - DEBUG_BLOCK - return Capabilities::TimecodeWriteCapability::writeAutoTimecode( miliseconds, Meta::TrackPtr( m_track.data() ) ); - } - - private: - KSharedPtr m_track; -}; - -class TimecodeLoadCapabilityImpl : public Capabilities::TimecodeLoadCapability -{ - public: - TimecodeLoadCapabilityImpl( MetaFile::Track *track ) - : Capabilities::TimecodeLoadCapability() - , m_track( track ) - {} - - virtual bool hasTimecodes() - { - if ( loadTimecodes().size() > 0 ) - return true; - return false; - } - - virtual BookmarkList loadTimecodes() - { - BookmarkList list = PlayUrlRunner::bookmarksFromUrl( m_track->playableUrl() ); - return list; - } - - private: - KSharedPtr m_track; -}; - - -class FindInSourceCapabilityImpl : public Capabilities::FindInSourceCapability -{ -public: - FindInSourceCapabilityImpl( MetaFile::Track *track ) - : Capabilities::FindInSourceCapability() - , m_track( track ) - {} - - virtual void findInSource( QFlags tag ) - { - Q_UNUSED( tag ) - //first show the filebrowser - AmarokUrl url; - url.setCommand( "navigate" ); - url.setPath( "files" ); - url.run(); - - //then navigate to the correct directory - BrowserCategory * fileCategory = The::mainWindow()->browserDock()->list()->activeCategoryRecursive(); - if( fileCategory ) - { - FileBrowser * fileBrowser = dynamic_cast( fileCategory ); - if( fileBrowser ) - { - //get the path of the parent directory of the file - KUrl playableUrl = m_track->playableUrl(); - fileBrowser->setDir( playableUrl.directory() ); - } - } - } - -private: - KSharedPtr m_track; -}; - - -Track::Track( const KUrl &url ) - : Meta::Track() - , d( new Track::Private( this ) ) -{ - d->url = url; - d->readMetaData(); - d->album = Meta::AlbumPtr( new MetaFile::FileAlbum( d ) ); - d->artist = Meta::ArtistPtr( new MetaFile::FileArtist( d ) ); - d->albumArtist = Meta::ArtistPtr( new MetaFile::FileArtist( d, true ) ); - d->genre = Meta::GenrePtr( new MetaFile::FileGenre( d ) ); - d->composer = Meta::ComposerPtr( new MetaFile::FileComposer( d ) ); - d->year = Meta::YearPtr( new MetaFile::FileYear( d ) ); -} - -Track::~Track() -{ - delete d; -} - -QString -Track::name() const -{ - if( d ) - { - const QString trackName = d->m_data.title; - return trackName; - } - return "This is a bug!"; -} - -KUrl -Track::playableUrl() const -{ - return d->url; -} - -QString -Track::prettyUrl() const -{ - if(d->url.isLocalFile()) - { - return d->url.toLocalFile(); - } - else - { - return d->url.path(); - } -} - -QString -Track::uidUrl() const -{ - return d->url.url(); -} - -QString -Track::notPlayableReason() const -{ - return localFileNotPlayableReason( playableUrl().toLocalFile() ); -} - -bool -Track::isEditable() const -{ - QFileInfo info = QFileInfo( playableUrl().pathOrUrl() ); - return info.isFile() && info.isWritable(); -} - -Meta::AlbumPtr -Track::album() const -{ - return d->album; -} - -Meta::ArtistPtr -Track::artist() const -{ - return d->artist; -} - -Meta::GenrePtr -Track::genre() const -{ - return d->genre; -} - -Meta::ComposerPtr -Track::composer() const -{ - return d->composer; -} - -Meta::YearPtr -Track::year() const -{ - return d->year; -} - -void -Track::setAlbum( const QString &newAlbum ) -{ - QWriteLocker locker( &d->lock ); - commitIfInNonBatchUpdate( Meta::valAlbum, newAlbum ); -} - -void -Track::setAlbumArtist( const QString &newAlbumArtist ) -{ - QWriteLocker locker( &d->lock ); - commitIfInNonBatchUpdate( Meta::valAlbumArtist, newAlbumArtist ); -} - -void -Track::setArtist( const QString &newArtist ) -{ - QWriteLocker locker( &d->lock ); - commitIfInNonBatchUpdate( Meta::valArtist, newArtist ); -} - -void -Track::setGenre( const QString &newGenre ) -{ - QWriteLocker locker( &d->lock ); - commitIfInNonBatchUpdate( Meta::valGenre, newGenre ); -} - -void -Track::setComposer( const QString &newComposer ) -{ - QWriteLocker locker( &d->lock ); - commitIfInNonBatchUpdate( Meta::valComposer, newComposer ); -} - -void -Track::setYear( int newYear ) -{ - QWriteLocker locker( &d->lock ); - commitIfInNonBatchUpdate( Meta::valYear, newYear ); -} - -void -Track::setTitle( const QString &newTitle ) -{ - QWriteLocker locker( &d->lock ); - commitIfInNonBatchUpdate( Meta::valTitle, newTitle ); -} - -void -Track::setBpm( const qreal newBpm ) -{ - QWriteLocker locker( &d->lock ); - commitIfInNonBatchUpdate( Meta::valBpm, newBpm ); -} - -qreal -Track::bpm() const -{ - const qreal bpm = d->m_data.bpm; - return bpm; -} - -QString -Track::comment() const -{ - const QString commentName = d->m_data.comment; - if( !commentName.isEmpty() ) - return commentName; - return QString(); -} - -void -Track::setComment( const QString& newComment ) -{ - QWriteLocker locker( &d->lock ); - commitIfInNonBatchUpdate( Meta::valComment, newComment ); -} - -int -Track::trackNumber() const -{ - return d->m_data.trackNumber; -} - -void -Track::setTrackNumber( int newTrackNumber ) -{ - QWriteLocker locker( &d->lock ); - commitIfInNonBatchUpdate( Meta::valTrackNr, newTrackNumber ); -} - -int -Track::discNumber() const -{ - return d->m_data.discNumber; -} - -void -Track::setDiscNumber( int newDiscNumber ) -{ - QWriteLocker locker( &d->lock ); - commitIfInNonBatchUpdate( Meta::valDiscNr, newDiscNumber ); -} - -qint64 -Track::length() const -{ - qint64 length = d->m_data.length; - if( length == -2 /*Undetermined*/ ) - length = 0; - return length; -} - -int -Track::filesize() const -{ - return d->m_data.fileSize; -} - -int -Track::sampleRate() const -{ - int sampleRate = d->m_data.sampleRate; - if( sampleRate == -2 /*Undetermined*/ ) - sampleRate = 0; - return sampleRate; -} - -int -Track::bitrate() const -{ - int bitrate = d->m_data.bitRate; - if( bitrate == -2 /*Undetermined*/ ) - bitrate = 0; - return bitrate; -} - -QDateTime -Track::createDate() const -{ - if( d->m_data.created > 0 ) - return QDateTime::fromTime_t(d->m_data.created); - else - return QDateTime(); -} - -qreal -Track::replayGain( Meta::ReplayGainTag mode ) const -{ - switch( mode ) - { - case Meta::ReplayGain_Track_Gain: - return d->m_data.trackGain; - case Meta::ReplayGain_Track_Peak: - return d->m_data.trackPeak; - case Meta::ReplayGain_Album_Gain: - return d->m_data.albumGain; - case Meta::ReplayGain_Album_Peak: - return d->m_data.albumPeak; - } - return 0.0; -} - -QString -Track::type() const -{ - return Amarok::extension( d->url.fileName() ); -} - -bool -Track::isTrack( const KUrl &url ) -{ - // some playlists lay under audio/ mime category, filter them - if( Playlists::isPlaylist( url ) ) - return false; - - // accept remote files, it's too slow to check them at this point - if( !url.isLocalFile() ) - return true; - - QFileInfo fileInfo( url.toLocalFile() ); - if( fileInfo.size() <= 0 ) - return false; - - // We can't play directories - if( fileInfo.isDir() ) - return false; - - const KMimeType::Ptr mimeType = KMimeType::findByPath( url.toLocalFile() ); - const QString name = mimeType->name(); - return name.startsWith( "audio/" ) || name.startsWith( "video/" ); -} - -void -Track::beginUpdate() -{ - QWriteLocker locker( &d->lock ); - d->batchUpdate++; -} - -void -Track::endUpdate() -{ - QWriteLocker locker( &d->lock ); - Q_ASSERT( d->batchUpdate > 0 ); - d->batchUpdate--; - commitIfInNonBatchUpdate(); -} - -bool -Track::inCollection() const -{ - return d->collection; // calls QWeakPointer's (bool) operator -} - -Collections::Collection* -Track::collection() const -{ - return d->collection.data(); -} - -void -Track::setCollection( Collections::Collection *newCollection ) -{ - d->collection = newCollection; -} - -bool -Track::hasCapabilityInterface( Capabilities::Capability::Type type ) const -{ - bool readlabel = false; -#ifdef HAVE_LIBLASTFM - readlabel = true; -#endif - return type == Capabilities::Capability::BookmarkThis || - type == Capabilities::Capability::WriteTimecode || - type == Capabilities::Capability::LoadTimecode || - ( type == Capabilities::Capability::ReadLabel && readlabel ) || - type == Capabilities::Capability::FindInSource; -} - -Capabilities::Capability* -Track::createCapabilityInterface( Capabilities::Capability::Type type ) -{ - switch( type ) - { - case Capabilities::Capability::BookmarkThis: - return new Capabilities::BookmarkThisCapability( new BookmarkCurrentTrackPositionAction( 0 ) ); - - case Capabilities::Capability::WriteTimecode: - return new TimecodeWriteCapabilityImpl( this ); - - case Capabilities::Capability::LoadTimecode: - return new TimecodeLoadCapabilityImpl( this ); - - case Capabilities::Capability::FindInSource: - return new FindInSourceCapabilityImpl( this ); - -#ifdef HAVE_LIBLASTFM - case Capabilities::Capability::ReadLabel: - if( !d->readLabelCapability ) - d->readLabelCapability = new Capabilities::LastfmReadLabelCapability( this ); -#endif - - default: // fall-through - - - return 0; - } -} - -Meta::TrackEditorPtr -Track::editor() -{ - return Meta::TrackEditorPtr( isEditable() ? this : 0 ); -} - -Meta::StatisticsPtr -Track::statistics() -{ - return Meta::StatisticsPtr( this ); -} - -double -Track::score() const -{ - return d->m_data.score; -} - -void -Track::setScore( double newScore ) -{ - QWriteLocker locker( &d->lock ); - commitIfInNonBatchUpdate( Meta::valScore, newScore ); -} - -int -Track::rating() const -{ - return d->m_data.rating; -} - -void -Track::setRating( int newRating ) -{ - QWriteLocker locker( &d->lock ); - commitIfInNonBatchUpdate( Meta::valRating, newRating ); -} - -int -Track::playCount() const -{ - return d->m_data.playCount; -} - -void -Track::setPlayCount( int newPlayCount ) -{ - QWriteLocker locker( &d->lock ); - commitIfInNonBatchUpdate( Meta::valPlaycount, newPlayCount ); -} - -QImage -Track::getEmbeddedCover() const -{ - if( d->m_data.embeddedImage ) - return Meta::Tag::embeddedCover( d->url.path() ); - - return QImage(); -} - -void -Track::commitIfInNonBatchUpdate( qint64 field, const QVariant &value ) -{ - d->changes.insert( field, value ); - commitIfInNonBatchUpdate(); -} - -void -Track::commitIfInNonBatchUpdate() -{ - static const QSet statFields = ( QSet() << Meta::valFirstPlayed << - Meta::valLastPlayed << Meta::valPlaycount << Meta::valScore << Meta::valRating ); - - if( d->batchUpdate > 0 || d->changes.isEmpty() ) - return; - - // special case (shortcut) when writing statistics is disabled - if( !AmarokConfig::writeBackStatistics() && - (QSet::fromList( d->changes.keys() ) - statFields).isEmpty() ) - { - d->changes.clear(); - return; - } - - d->writeMetaData(); // clears d->chages - d->lock.unlock(); // rather call notifyObservers() without a lock - notifyObservers(); - d->lock.lockForWrite(); // return to original state -} - -#include "moc_File_p.cpp" diff --git a/amarok/src/core-impl/meta/file/File.h b/amarok/src/core-impl/meta/file/File.h deleted file mode 100644 index ee2a6bbf..00000000 --- a/amarok/src/core-impl/meta/file/File.h +++ /dev/null @@ -1,137 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_META_FILE_H -#define AMAROK_META_FILE_H - -#include "amarok_export.h" -#include "core/meta/Meta.h" -#include "core/meta/Statistics.h" -#include "core/meta/TrackEditor.h" - -namespace MetaFile -{ - class Track; - - typedef KSharedPtr TrackPtr; - - class AMAROK_EXPORT Track : public Meta::Track, public Meta::Statistics, Meta::TrackEditor - { - public: - Track( const KUrl &url ); - virtual ~Track(); - - //methods inherited from Meta::Base - virtual QString name() const; - - //methods inherited from Meta::Track - virtual KUrl playableUrl() const; - virtual QString prettyUrl() const; - virtual QString uidUrl() const; - virtual QString notPlayableReason() const; - - virtual Meta::AlbumPtr album() const; - virtual Meta::ArtistPtr artist() const; - virtual Meta::GenrePtr genre() const; - virtual Meta::ComposerPtr composer() const; - virtual Meta::YearPtr year() const; - - virtual qreal bpm() const; - virtual QString comment() const; - - virtual int trackNumber() const; - virtual int discNumber() const; - - virtual qint64 length() const; - virtual int filesize() const; - virtual int sampleRate() const; - virtual int bitrate() const; - virtual QDateTime createDate() const; - - virtual qreal replayGain( Meta::ReplayGainTag mode ) const; - - virtual QString type() const; - - virtual bool inCollection() const; - virtual Collections::Collection *collection() const; - - virtual bool hasCapabilityInterface( Capabilities::Capability::Type type ) const; - virtual Capabilities::Capability* createCapabilityInterface( Capabilities::Capability::Type type ); - - virtual Meta::TrackEditorPtr editor(); - virtual Meta::StatisticsPtr statistics(); - - // Meta::TrackEditor methods: - virtual void setAlbum( const QString &newAlbum ); - virtual void setAlbumArtist( const QString &newAlbumArtist ); - virtual void setArtist( const QString &newArtist ); - virtual void setComposer( const QString &newComposer ); - virtual void setGenre( const QString &newGenre ); - virtual void setYear( int newYear ); - virtual void setTitle( const QString &newTitle ); - virtual void setComment( const QString &newComment ); - virtual void setTrackNumber( int newTrackNumber ); - virtual void setDiscNumber( int newDiscNumber ); - virtual void setBpm( const qreal newBpm ); - - // Meta::Statistics methods: - virtual double score() const; - virtual void setScore( double newScore ); - - virtual int rating() const; - virtual void setRating( int newRating ); - - virtual int playCount() const; - virtual void setPlayCount( int newPlayCount ); - - // combined Meta::TrackEditor, Meta::Statistics methods: - virtual void beginUpdate(); - virtual void endUpdate(); - - // MetaFile::Track own methods: - bool isEditable() const; - - /** - * Return true if file at @param url is a track. - * - * This method does only basic checking of the mime type and is pretty - * optimistic, so it may be possible that is the song is not playable with - * current backend even if isTrack() returns true. - */ - static bool isTrack( const KUrl &url ); - - virtual QImage getEmbeddedCover() const; - virtual void setCollection( Collections::Collection *newCollection ); - - // publish method so that it can be called by Private. - using Meta::Track::notifyObservers; - - class Private; - - private: - Private * const d; - - /** - * Must be called at end of every set*() method, with d->lock locked for - * writing. Takes care of writing back the fields, re-reading them and - * notifying observers. - */ - void commitIfInNonBatchUpdate( qint64 field, const QVariant &value ); - void commitIfInNonBatchUpdate(); - }; -} - -#endif diff --git a/amarok/src/core-impl/meta/file/FileTrackProvider.cpp b/amarok/src/core-impl/meta/file/FileTrackProvider.cpp deleted file mode 100644 index 74c2abc1..00000000 --- a/amarok/src/core-impl/meta/file/FileTrackProvider.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "FileTrackProvider.h" - -#include "core-impl/meta/file/File.h" - -FileTrackProvider::FileTrackProvider() -{ -} - -FileTrackProvider::~FileTrackProvider() -{ -} - -bool -FileTrackProvider::possiblyContainsTrack( const KUrl &url ) const -{ - if( !url.isLocalFile() ) - return false; - - return MetaFile::Track::isTrack( url ); -} - -Meta::TrackPtr -FileTrackProvider::trackForUrl( const KUrl &url ) -{ - if( !possiblyContainsTrack( url ) ) - return Meta::TrackPtr(); - return Meta::TrackPtr( new MetaFile::Track( url ) ); -} diff --git a/amarok/src/core-impl/meta/file/FileTrackProvider.h b/amarok/src/core-impl/meta/file/FileTrackProvider.h deleted file mode 100644 index 28962cef..00000000 --- a/amarok/src/core-impl/meta/file/FileTrackProvider.h +++ /dev/null @@ -1,40 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef FILETRACKPROVIDER_H -#define FILETRACKPROVIDER_H - -#include "amarok_export.h" -#include "core/collections/Collection.h" - -/** - * A simple track provider that contructs MetaFile::Tracks for local and - * existing urls. (no remote protocols supported, just "file" protocol.) - */ -class AMAROK_EXPORT FileTrackProvider : public Collections::TrackProvider -{ - public: - FileTrackProvider(); - virtual ~FileTrackProvider(); - - virtual bool possiblyContainsTrack( const KUrl &url ) const; - virtual Meta::TrackPtr trackForUrl( const KUrl &url ); - - private: - Q_DISABLE_COPY( FileTrackProvider ) -}; - -#endif // FILETRACKPROVIDER_H diff --git a/amarok/src/core-impl/meta/file/File_p.h b/amarok/src/core-impl/meta/file/File_p.h deleted file mode 100644 index dd282fb4..00000000 --- a/amarok/src/core-impl/meta/file/File_p.h +++ /dev/null @@ -1,462 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007-2009 Maximilian Kossick * - * Copyright (c) 2008 Peter ZHOU * - * Copyright (c) 2008 Seb Ruiz * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_META_FILE_P_H -#define AMAROK_META_FILE_P_H - -#include "amarokconfig.h" -#include "core/collections/Collection.h" -#include "core/support/Debug.h" -#include "core/meta/Meta.h" -#include "core/meta/support/MetaUtility.h" -#include "MetaReplayGain.h" -#include "MetaTagLib.h" -#include "core-impl/collections/support/jobs/WriteTagsJob.h" -#include "core-impl/collections/support/ArtistHelper.h" -#include "core-impl/capabilities/AlbumActionsCapability.h" -#include "covermanager/CoverCache.h" - -#include - -#include -#include -#include -#include -#include -#include -#include - -namespace Capabilities -{ - class LastfmReadLabelCapability; -} - -namespace MetaFile -{ - -//d-pointer implementation - -struct MetaData -{ - MetaData() - : created( 0 ) - , discNumber( 0 ) - , trackNumber( 0 ) - , length( 0 ) - , fileSize( 0 ) - , sampleRate( 0 ) - , bitRate( 0 ) - , year( 0 ) - , bpm( -1.0 ) - , trackGain( 0.0 ) - , trackPeak( 0.0 ) - , albumGain( 0.0 ) - , albumPeak( 0.0 ) - , embeddedImage( false ) - , rating( 0 ) - , score( 0.0 ) - , playCount( 0 ) - { } - QString title; - QString artist; - QString album; - QString albumArtist; - QString comment; - QString composer; - QString genre; - uint created; - int discNumber; - int trackNumber; - qint64 length; - int fileSize; - int sampleRate; - int bitRate; - int year; - qreal bpm; - qreal trackGain; - qreal trackPeak; - qreal albumGain; - qreal albumPeak; - bool embeddedImage; - - int rating; - double score; - int playCount; -}; - -class Track::Private : public QObject -{ - Q_OBJECT -public: - Private( Track *t ) - : QObject() - , url() - , album() - , artist() - , albumArtist() - , batchUpdate( 0 ) - , track( t ) - {} - -public: - KUrl url; - - Meta::AlbumPtr album; - Meta::ArtistPtr artist; - Meta::ArtistPtr albumArtist; - Meta::GenrePtr genre; - Meta::ComposerPtr composer; - Meta::YearPtr year; - QWeakPointer readLabelCapability; - QWeakPointer collection; - - /** - * Number of current batch operations started by @see beginUpdate() and not - * yet ended by @see endUpdate(). Must only be accessed with lock held. - */ - int batchUpdate; - Meta::FieldHash changes; - QReadWriteLock lock; - - void writeMetaData() - { - DEBUG_BLOCK - debug() << "changes:" << changes; - if( AmarokConfig::writeBack() ) - Meta::Tag::writeTags( url.isLocalFile() ? url.toLocalFile() : url.path(), - changes, AmarokConfig::writeBackStatistics() ); - changes.clear(); - readMetaData(); - } - - void notifyObservers() - { - track->notifyObservers(); - } - - MetaData m_data; - -public slots: - void readMetaData(); - -private: - TagLib::FileRef getFileRef(); - Track *track; -}; - -void Track::Private::readMetaData() -{ - QFileInfo fi( url.isLocalFile() ? url.toLocalFile() : url.path() ); - m_data.created = fi.created().toTime_t(); - - Meta::FieldHash values = Meta::Tag::readTags( fi.absoluteFilePath() ); - - // (re)set all fields to behave the same as the constructor. E.g. catch even complete - // removal of tags etc. - MetaData def; // default - m_data.title = values.value( Meta::valTitle, def.title ).toString(); - m_data.artist = values.value( Meta::valArtist, def.artist ).toString(); - m_data.album = values.value( Meta::valAlbum, def.album ).toString(); - m_data.albumArtist = values.value( Meta::valAlbumArtist, def.albumArtist ).toString(); - m_data.embeddedImage = values.value( Meta::valHasCover, def.embeddedImage ).toBool(); - m_data.comment = values.value( Meta::valComment, def.comment ).toString(); - m_data.genre = values.value( Meta::valGenre, def.genre ).toString(); - m_data.composer = values.value( Meta::valComposer, def.composer ).toString(); - m_data.year = values.value( Meta::valYear, def.year ).toInt(); - m_data.discNumber = values.value( Meta::valDiscNr, def.discNumber ).toInt(); - m_data.trackNumber = values.value( Meta::valTrackNr, def.trackNumber ).toInt(); - m_data.bpm = values.value( Meta::valBpm, def.bpm ).toReal(); - m_data.bitRate = values.value( Meta::valBitrate, def.bitRate ).toInt(); - m_data.length = values.value( Meta::valLength, def.length ).toLongLong(); - m_data.sampleRate = values.value( Meta::valSamplerate, def.sampleRate ).toInt(); - m_data.fileSize = values.value( Meta::valFilesize, def.fileSize ).toLongLong(); - - m_data.trackGain = values.value( Meta::valTrackGain, def.trackGain ).toReal(); - m_data.trackPeak= values.value( Meta::valTrackGainPeak, def.trackPeak ).toReal(); - m_data.albumGain = values.value( Meta::valAlbumGain, def.albumGain ).toReal(); - m_data.albumPeak= values.value( Meta::valAlbumGainPeak, def.albumPeak ).toReal(); - - // only read the stats if we can write them later. Would be annoying to have - // read-only rating that you don't like - if( AmarokConfig::writeBackStatistics() ) - { - m_data.rating = values.value( Meta::valRating, def.rating ).toInt(); - m_data.score = values.value( Meta::valScore, def.score ).toDouble(); - m_data.playCount = values.value( Meta::valPlaycount, def.playCount ).toInt(); - } - - if(url.isLocalFile()) - { - m_data.fileSize = QFile( url.toLocalFile() ).size(); - } - else - { - m_data.fileSize = QFile( url.path() ).size(); - } - - //as a last ditch effort, use the filename as the title if nothing else has been found - if ( m_data.title.isEmpty() ) - { - m_data.title = url.fileName(); - } - - // try to guess best album artist (even if non-empty, part of compilation detection) - m_data.albumArtist = ArtistHelper::bestGuessAlbumArtist( m_data.albumArtist, - m_data.artist, m_data.genre, m_data.composer ); -} - -// internal helper classes - -class FileArtist : public Meta::Artist -{ -public: - FileArtist( MetaFile::Track::Private *dptr, bool isAlbumArtist = false ) - : Meta::Artist() - , d( dptr ) - , m_isAlbumArtist( isAlbumArtist ) - {} - - Meta::TrackList tracks() - { - return Meta::TrackList(); - } - - QString name() const - { - const QString artist = m_isAlbumArtist ? d.data()->m_data.albumArtist - : d.data()->m_data.artist; - return artist; - } - - bool operator==( const Meta::Artist &other ) const { - return name() == other.name(); - } - - QWeakPointer const d; - const bool m_isAlbumArtist; -}; - -class FileAlbum : public Meta::Album -{ -public: - FileAlbum( MetaFile::Track::Private *dptr ) - : Meta::Album() - , d( dptr ) - {} - - bool hasCapabilityInterface( Capabilities::Capability::Type type ) const - { - switch( type ) - { - case Capabilities::Capability::Actions: - return true; - default: - return false; - } - } - - Capabilities::Capability* createCapabilityInterface( Capabilities::Capability::Type type ) - { - switch( type ) - { - case Capabilities::Capability::Actions: - return new Capabilities::AlbumActionsCapability( Meta::AlbumPtr( this ) ); - default: - return 0; - } - } - - bool isCompilation() const - { - /* non-compilation albums with no album artists may be hidden in collection - * browser if certain modes are used, so force compilation in this case */ - return !hasAlbumArtist(); - } - - bool hasAlbumArtist() const - { - return !d.data()->albumArtist->name().isEmpty(); - } - - Meta::ArtistPtr albumArtist() const - { - /* only return album artist if it would be non-empty, some Amarok parts do not - * call hasAlbumArtist() prior to calling albumArtist() and it is better to be - * consistent with other Meta::Track implementations */ - if( hasAlbumArtist() ) - return d.data()->albumArtist; - return Meta::ArtistPtr(); - } - - Meta::TrackList tracks() - { - return Meta::TrackList(); - } - - QString name() const - { - if( d ) - { - const QString albumName = d.data()->m_data.album; - return albumName; - } - else - return QString(); - } - - bool hasImage( int /* size */ = 0 ) const - { - if( d && d.data()->m_data.embeddedImage ) - return true; - return false; - } - - QImage image( int size = 0 ) const - { - QImage image; - if( d && d.data()->m_data.embeddedImage ) - { - image = Meta::Tag::embeddedCover( d.data()->url.toLocalFile() ); - } - - if( image.isNull() || size <= 0 /* do not scale */ ) - return image; - return image.scaled( size, size, Qt::KeepAspectRatio, Qt::SmoothTransformation ); - } - - bool canUpdateImage() const - { - return d; // true if underlying track is not null - } - - void setImage( const QImage &image ) - { - if( !d ) - return; - - Meta::FieldHash fields; - fields.insert( Meta::valImage, image ); - WriteTagsJob *job = new WriteTagsJob( d.data()->url.toLocalFile(), fields ); - QObject::connect( job, SIGNAL(done(ThreadWeaver::Job*)), job, SLOT(deleteLater()) ); - ThreadWeaver::Weaver::instance()->enqueue( job ); - if( d.data()->m_data.embeddedImage == image.isNull() ) - // we need to toggle the embeddedImage switch in this case - QObject::connect( job, SIGNAL(done(ThreadWeaver::Job*)), d.data(), SLOT(readMetaData()) ); - - CoverCache::invalidateAlbum( this ); - notifyObservers(); - // following call calls Track's notifyObservers. This is needed because for example - // UmsCollection justifiably listens only to Track's metadataChanged() to update - // its MemoryCollection maps - d.data()->notifyObservers(); - } - - void removeImage() - { - setImage( QImage() ); - } - - bool operator==( const Meta::Album &other ) const { - return name() == other.name(); - } - - QWeakPointer const d; -}; - -class FileGenre : public Meta::Genre -{ -public: - FileGenre( MetaFile::Track::Private *dptr ) - : Meta::Genre() - , d( dptr ) - {} - - Meta::TrackList tracks() - { - return Meta::TrackList(); - } - - QString name() const - { - const QString genreName = d.data()->m_data.genre; - return genreName; - } - - bool operator==( const Meta::Genre &other ) const { - return name() == other.name(); - } - - QWeakPointer const d; -}; - -class FileComposer : public Meta::Composer -{ -public: - FileComposer( MetaFile::Track::Private *dptr ) - : Meta::Composer() - , d( dptr ) - {} - - Meta::TrackList tracks() - { - return Meta::TrackList(); - } - - QString name() const - { - const QString composer = d.data()->m_data.composer; - return composer; - } - - bool operator==( const Meta::Composer &other ) const { - return name() == other.name(); - } - - QWeakPointer const d; -}; - -class FileYear : public Meta::Year -{ -public: - FileYear( MetaFile::Track::Private *dptr ) - : Meta::Year() - , d( dptr ) - {} - - Meta::TrackList tracks() - { - return Meta::TrackList(); - } - - QString name() const - { - const QString year = QString::number( d.data()->m_data.year ); - return year; - } - - bool operator==( const Meta::Year &other ) const { - return name() == other.name(); - } - - QWeakPointer const d; -}; - - -} - -#endif diff --git a/amarok/src/core-impl/meta/multi/MultiTrack.cpp b/amarok/src/core-impl/meta/multi/MultiTrack.cpp deleted file mode 100644 index e50740ac..00000000 --- a/amarok/src/core-impl/meta/multi/MultiTrack.cpp +++ /dev/null @@ -1,154 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "MultiTrack.h" - -#include "core/meta/Statistics.h" -#include "core-impl/capabilities/multisource/MultiSourceCapabilityImpl.h" - -using namespace Meta; - -MultiTrack::MultiTrack( Playlists::PlaylistPtr playlist ) - : QObject() - , Track() - , m_playlist( playlist ) -{ - Q_ASSERT( playlist ); - if( playlist->trackCount() < 0 ) - { - PlaylistObserver::subscribeTo( playlist ); - playlist->triggerTrackLoad(); - } - if( !playlist->tracks().isEmpty() ) - setSource( 0 ); -} - -MultiTrack::~MultiTrack() -{ -} - -QStringList -Meta::MultiTrack::sources() const -{ - QStringList trackNames; - foreach ( TrackPtr track, m_playlist->tracks() ) - { - trackNames << track->prettyUrl(); - } - - return trackNames; -} - -void -MultiTrack::setSource( int source ) -{ - QWriteLocker locker( &m_lock ); - setSourceImpl( source ); - locker.unlock(); - - notifyObservers(); - emit urlChanged( playableUrl() ); -} - -int -Meta::MultiTrack::current() const -{ - QReadLocker locker( &m_lock ); - return m_playlist->tracks().indexOf( m_currentTrack ); -} - -KUrl -MultiTrack::nextUrl() const -{ - int index = current() + 1; - Meta::TrackPtr track = m_playlist->tracks().value( index ); - if( track ) - { - track->prepareToPlay(); - return track->playableUrl(); - } - return KUrl(); -} - -bool -MultiTrack::hasCapabilityInterface(Capabilities::Capability::Type type) const -{ - return type == Capabilities::Capability::MultiSource; -} - -Capabilities::Capability * -MultiTrack::createCapabilityInterface(Capabilities::Capability::Type type) -{ - switch( type ) - { - case Capabilities::Capability::MultiSource: - return new Capabilities::MultiSourceCapabilityImpl( this ); - default: - return 0; - } -} - -void -MultiTrack::prepareToPlay() -{ - QReadLocker locker( &m_lock ); - if( m_currentTrack ) - m_currentTrack->prepareToPlay(); -} - -Meta::StatisticsPtr -Meta::MultiTrack::statistics() -{ - QReadLocker locker( &m_lock ); - return m_currentTrack ? m_currentTrack->statistics() : Track::statistics(); -} - -void -Meta::MultiTrack::metadataChanged( Meta::TrackPtr track ) -{ - Q_UNUSED( track ) - // forward changes from active tracks - notifyObservers(); -} - -void -MultiTrack::trackAdded( Playlists::PlaylistPtr, TrackPtr, int ) -{ - PlaylistObserver::unsubscribeFrom( m_playlist ); - - QWriteLocker locker( &m_lock ); - if( !m_currentTrack ) - { - setSourceImpl( 0 ); - locker.unlock(); - - notifyObservers(); - emit urlChanged( playableUrl() ); - } -} - -void -MultiTrack::setSourceImpl( int source ) -{ - if( source < 0 || source >= m_playlist->tracks().count() ) - return; - - if( m_currentTrack ) - Observer::unsubscribeFrom( m_currentTrack ); - - m_currentTrack = m_playlist->tracks().at( source ); - Observer::subscribeTo( m_currentTrack ); -} diff --git a/amarok/src/core-impl/meta/multi/MultiTrack.h b/amarok/src/core-impl/meta/multi/MultiTrack.h deleted file mode 100644 index 32cbe828..00000000 --- a/amarok/src/core-impl/meta/multi/MultiTrack.h +++ /dev/null @@ -1,108 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef METAMULTITRACK_H -#define METAMULTITRACK_H - -#include "core/capabilities/MultiSourceCapability.h" -#include "core/meta/Meta.h" -#include "core/meta/Observer.h" -#include "core/playlists/Playlist.h" -#include "core-impl/meta/default/DefaultMetaTypes.h" - -namespace Meta -{ - /** - * A track that wraps a playlist. This is useful, for instance, for adding radio - * streams with multiple fallback streams to the playlist as a single item. - * - * @author Nikolaj Hald Nielsen - */ - class MultiTrack : public QObject, public Track, private Meta::Observer, private Playlists::PlaylistObserver - { - Q_OBJECT - - public: - MultiTrack( Playlists::PlaylistPtr playlist ); - ~MultiTrack(); - - QStringList sources() const; - void setSource( int source ); - int current() const; - KUrl nextUrl() const; - - virtual bool hasCapabilityInterface( Capabilities::Capability::Type type ) const; - virtual Capabilities::Capability *createCapabilityInterface( Capabilities::Capability::Type type ); - - // forward lots of stuff: -#define FORWARD( Type, method, default ) Type method() const { return m_currentTrack ? m_currentTrack->method() : default; } - FORWARD( QString, name, QString() ) - FORWARD( QString, prettyName, QString() ) - FORWARD( KUrl, playableUrl, KUrl() ) - FORWARD( QString, prettyUrl, m_playlist->uidUrl().prettyUrl() ) - // TODO: change to m_playlist->uidUrl() unconditionally once playlist restorer can cope with it: - FORWARD( QString, uidUrl, m_playlist->uidUrl().url() ) - FORWARD( QString, notPlayableReason, i18nc( "Reason why a track is not playable", - "Underlying playlist is empty" ) ) - - FORWARD( AlbumPtr, album, AlbumPtr( new DefaultAlbum() ) ); - FORWARD( ArtistPtr, artist, ArtistPtr( new DefaultArtist() ) ); - FORWARD( ComposerPtr, composer, ComposerPtr( new DefaultComposer() ) ); - FORWARD( GenrePtr, genre, GenrePtr( new DefaultGenre() ) ); - FORWARD( YearPtr, year, YearPtr( new DefaultYear() ) ); - - FORWARD( qreal, bpm, -1 ) - FORWARD( QString, comment, QString() ) - FORWARD( qint64, length, 0 ) - FORWARD( int, filesize, 0 ) - FORWARD( int, sampleRate, 0 ) - FORWARD( int, bitrate, 0 ) - FORWARD( int, trackNumber, 0 ) - FORWARD( int, discNumber, 0 ) - FORWARD( QString, type, QString() ) -#undef FORWARD - - void prepareToPlay(); - virtual StatisticsPtr statistics(); - - signals: - void urlChanged( const KUrl &url ); - - private: - using Observer::metadataChanged; - virtual void metadataChanged( Meta::TrackPtr track ); - - using PlaylistObserver::metadataChanged; - virtual void trackAdded( Playlists::PlaylistPtr playlist, TrackPtr track, int position ); - - /** - * Implementation for setSource. Must be called with m_lock held for writing. - */ - void setSourceImpl( int source ); - - // marked as mutable because many Playlist methods aren't const while they should be - mutable Playlists::PlaylistPtr m_playlist; - TrackPtr m_currentTrack; - /** - * Guards access to data members; note that m_playlist methods are considered - * thread-safe and the pointer itself does not change throughout life of thhis - * object, so mere m_playlist->someMethod() doesn't have to be guarded. - */ - mutable QReadWriteLock m_lock; - }; -} - -#endif diff --git a/amarok/src/core-impl/meta/proxy/MetaProxy.cpp b/amarok/src/core-impl/meta/proxy/MetaProxy.cpp deleted file mode 100644 index 2f97ee4c..00000000 --- a/amarok/src/core-impl/meta/proxy/MetaProxy.cpp +++ /dev/null @@ -1,525 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "MetaProxy.h" - -#include "core/meta/Statistics.h" -#include "core-impl/collections/support/CollectionManager.h" -#include "core-impl/meta/proxy/MetaProxy_p.h" -#include "core-impl/meta/proxy/moc_MetaProxy_p.cpp" -#include "core-impl/meta/proxy/MetaProxyWorker.h" - -#include -#include - -#include -#include -#include -#include - -using namespace MetaProxy; - -class ProxyArtist; -class ProxyFmAlbum; -class ProxyGenre; -class ProxyComposer; -class ProxyYear; - -MetaProxy::Track::Track( const KUrl &url, LookupType lookupType ) - : Meta::Track() - , d( new Private() ) -{ - d->url = url; - d->proxy = this; - d->cachedLength = 0; - d->albumPtr = Meta::AlbumPtr( new ProxyAlbum( d ) ); - d->artistPtr = Meta::ArtistPtr( new ProxyArtist( d ) ); - d->genrePtr = Meta::GenrePtr( new ProxyGenre( d ) ); - d->composerPtr = Meta::ComposerPtr( new ProxyComposer( d ) ); - d->yearPtr = Meta::YearPtr( new ProxyYear( d ) ); - - QThread *mainThread = QCoreApplication::instance()->thread(); - bool foreignThread = QThread::currentThread() != mainThread; - if( foreignThread ) - d->moveToThread( mainThread ); - - if( lookupType == AutomaticLookup ) - { - Worker *worker = new Worker( d->url ); - if( foreignThread ) - worker->moveToThread( mainThread ); - - QObject::connect( worker, SIGNAL(finishedLookup(Meta::TrackPtr)), - d, SLOT(slotUpdateTrack(Meta::TrackPtr)) ); - ThreadWeaver::Weaver::instance()->enqueue( worker ); - } -} - -MetaProxy::Track::~Track() -{ - delete d; -} - -void -MetaProxy::Track::lookupTrack( Collections::TrackProvider *provider ) -{ - Worker *worker = new Worker( d->url, provider ); - QThread *mainThread = QCoreApplication::instance()->thread(); - if( QThread::currentThread() != mainThread ) - worker->moveToThread( mainThread ); - - QObject::connect( worker, SIGNAL(finishedLookup(Meta::TrackPtr)), - d, SLOT(slotUpdateTrack(Meta::TrackPtr)) ); - ThreadWeaver::Weaver::instance()->enqueue( worker ); -} - -QString -MetaProxy::Track::name() const -{ - if( d->realTrack ) - return d->realTrack->name(); - else - return d->cachedName; -} - -void -MetaProxy::Track::setTitle( const QString &name ) -{ - d->cachedName = name; -} - -QString -MetaProxy::Track::prettyName() const -{ - if( d->realTrack ) - return d->realTrack->prettyName(); - else - return Meta::Track::prettyName(); -} - -QString -MetaProxy::Track::sortableName() const -{ - if( d->realTrack ) - return d->realTrack->sortableName(); - else - return Meta::Track::sortableName(); -} - -KUrl -MetaProxy::Track::playableUrl() const -{ - if( d->realTrack ) - return d->realTrack->playableUrl(); - else - /* don't return d->url here, it may be something like - * amarok-sqltrackuid://2f9277bb7e49962c1c4c5612811807a1 and Phonon may choke - * on such urls trying to find a codec and causing hang (bug 308371) */ - return KUrl(); -} - -QString -MetaProxy::Track::prettyUrl() const -{ - if( d->realTrack ) - return d->realTrack->prettyUrl(); - else - return d->url.prettyUrl(); -} - -QString -MetaProxy::Track::uidUrl() const -{ - if( d->realTrack ) - return d->realTrack->uidUrl(); - else - return d->url.url(); -} - -QString -MetaProxy::Track::notPlayableReason() const -{ - if( !d->realTrack ) - return i18n( "When Amarok was last closed, this track was at %1, but Amarok " - "cannot find this track on the filesystem or in any of your collections " - "anymore. You may try plugging in the device this track might be on.", - prettyUrl() ); - return d->realTrack->notPlayableReason(); -} - -Meta::AlbumPtr -MetaProxy::Track::album() const -{ - return d->albumPtr; -} - -void -MetaProxy::Track::setAlbum( const QString &album ) -{ - d->cachedAlbum = album; -} - -void -Track::setAlbumArtist( const QString &artist ) -{ - Q_UNUSED( artist ); -} - -Meta::ArtistPtr -MetaProxy::Track::artist() const -{ - return d->artistPtr; -} - -void -MetaProxy::Track::setArtist( const QString &artist ) -{ - d->cachedArtist = artist; -} - -Meta::GenrePtr -MetaProxy::Track::genre() const -{ - return d->genrePtr; -} - -void -MetaProxy::Track::setGenre( const QString &genre ) -{ - d->cachedGenre = genre; -} - -Meta::ComposerPtr -MetaProxy::Track::composer() const -{ - return d->composerPtr; -} - -void -MetaProxy::Track::setComposer( const QString &composer ) -{ - d->cachedComposer = composer; -} - -Meta::YearPtr -MetaProxy::Track::year() const -{ - return d->yearPtr; -} - -void -MetaProxy::Track::setYear( int year ) -{ - d->cachedYear = year; -} - -Meta::LabelList -Track::labels() const -{ - if( d->realTrack ) - return d->realTrack->labels(); - else - return Meta::Track::labels(); -} - -qreal -MetaProxy::Track::bpm() const -{ - if( d->realTrack ) - return d->realTrack->bpm(); - else - return d->cachedBpm; -} - -void -MetaProxy::Track::setBpm( const qreal bpm ) -{ - d->cachedBpm = bpm; -} - -QString -MetaProxy::Track::comment() const -{ - if( d->realTrack ) - return d->realTrack->comment(); - else - return QString(); // we don't cache comment -} - -void -Track::setComment( const QString & ) -{ - // we don't cache comment -} - -int -MetaProxy::Track::trackNumber() const -{ - if( d->realTrack ) - return d->realTrack->trackNumber(); - else - return d->cachedTrackNumber; -} - -void -MetaProxy::Track::setTrackNumber( int number ) -{ - d->cachedTrackNumber = number; -} - -int -MetaProxy::Track::discNumber() const -{ - if( d->realTrack ) - return d->realTrack->discNumber(); - else - return d->cachedDiscNumber; -} - -void -MetaProxy::Track::setDiscNumber( int discNumber ) -{ - d->cachedDiscNumber = discNumber; -} - -qint64 -MetaProxy::Track::length() const -{ - if( d->realTrack ) - return d->realTrack->length(); - else - return d->cachedLength; -} - -void -MetaProxy::Track::setLength( qint64 length ) -{ - d->cachedLength = length; -} - -int -MetaProxy::Track::filesize() const -{ - if( d->realTrack ) - return d->realTrack->filesize(); - else - return 0; -} - -int -MetaProxy::Track::sampleRate() const -{ - if( d->realTrack ) - return d->realTrack->sampleRate(); - else - return 0; -} - -int -MetaProxy::Track::bitrate() const -{ - if( d->realTrack ) - return d->realTrack->bitrate(); - else - return 0; -} - -QDateTime -MetaProxy::Track::createDate() const -{ - if( d->realTrack ) - return d->realTrack->createDate(); - else - return Meta::Track::createDate(); -} - -QDateTime -Track::modifyDate() const -{ - if( d->realTrack ) - return d->realTrack->modifyDate(); - else - return Meta::Track::modifyDate(); -} - -qreal -Track::replayGain( Meta::ReplayGainTag mode ) const -{ - if( d->realTrack ) - return d->realTrack->replayGain( mode ); - else - return Meta::Track::replayGain( mode ); -} - -QString -MetaProxy::Track::type() const -{ - if( d->realTrack ) - return d->realTrack->type(); - else - // just debugging, normal users shouldn't hit this - return QString( "MetaProxy::Track" ); -} - -void -Track::prepareToPlay() -{ - if( d->realTrack ) - d->realTrack->prepareToPlay(); -} - -void -MetaProxy::Track::finishedPlaying( double playedFraction ) -{ - if( d->realTrack ) - d->realTrack->finishedPlaying( playedFraction ); -} - -bool -MetaProxy::Track::inCollection() const -{ - if( d->realTrack ) - return d->realTrack->inCollection(); - else - return false; -} - -Collections::Collection * -MetaProxy::Track::collection() const -{ - if( d->realTrack ) - return d->realTrack->collection(); - else - return 0; -} - -QString -Track::cachedLyrics() const -{ - if( d->realTrack ) - return d->realTrack->cachedLyrics(); - else - return Meta::Track::cachedLyrics(); -} - -void -Track::setCachedLyrics(const QString& lyrics) -{ - if( d->realTrack ) - d->realTrack->setCachedLyrics( lyrics ); - else - Meta::Track::setCachedLyrics( lyrics ); -} - -void -Track::addLabel( const QString &label ) -{ - if( d->realTrack ) - d->realTrack->addLabel( label ); - else - Meta::Track::addLabel( label ); -} - -void -Track::addLabel( const Meta::LabelPtr &label ) -{ - if( d->realTrack ) - d->realTrack->addLabel( label ); - else - Meta::Track::addLabel( label ); -} - -void -Track::removeLabel( const Meta::LabelPtr &label ) -{ - if( d->realTrack ) - d->realTrack->removeLabel( label ); - else - Meta::Track::removeLabel( label ); -} - -void -MetaProxy::Track::updateTrack( Meta::TrackPtr track ) -{ - d->slotUpdateTrack( track ); -} - -bool -MetaProxy::Track::hasCapabilityInterface( Capabilities::Capability::Type type ) const -{ - if( d->realTrack ) - return d->realTrack->hasCapabilityInterface( type ); - else - return false; -} - -Capabilities::Capability * -MetaProxy::Track::createCapabilityInterface( Capabilities::Capability::Type type ) -{ - if( d->realTrack ) - return d->realTrack->createCapabilityInterface( type ); - else - return 0; -} - -bool -MetaProxy::Track::operator==( const Meta::Track &track ) const -{ - const MetaProxy::Track *proxy = dynamic_cast( &track ); - if( proxy && d->realTrack ) - return d->realTrack == proxy->d->realTrack; - else if( proxy ) - return d->url == proxy->d->url; - - return d->realTrack && d->realTrack.data() == &track; -} - -Meta::TrackEditorPtr -Track::editor() -{ - if( d->realTrack ) - return d->realTrack->editor(); - else - return Meta::TrackEditorPtr( this ); -} - -Meta::StatisticsPtr -Track::statistics() -{ - if( d->realTrack ) - return d->realTrack->statistics(); - else - return Meta::Track::statistics(); -} - -void -Track::beginUpdate() -{ - // nothing to do -} - -void -Track::endUpdate() -{ - // we intentionally don't call metadataUpdated() so that thi first thing that - // triggers metadataUpdated() is when the real track is found. -} - -bool -Track::isResolved() const -{ - return d->realTrack; -} diff --git a/amarok/src/core-impl/meta/proxy/MetaProxy.h b/amarok/src/core-impl/meta/proxy/MetaProxy.h deleted file mode 100644 index 3cf20fcd..00000000 --- a/amarok/src/core-impl/meta/proxy/MetaProxy.h +++ /dev/null @@ -1,164 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_METAPROXY_H -#define AMAROK_METAPROXY_H - -#include "amarok_export.h" -#include "core/capabilities/Capability.h" -#include "core/meta/Meta.h" -#include "core/meta/TrackEditor.h" -#include "core-impl/meta/proxy/MetaProxyWorker.h" - -#include - -namespace Collections -{ - class TrackProvider; -} - -namespace MetaProxy -{ - class Track; - typedef KSharedPtr TrackPtr; - class AMAROK_EXPORT Track : public Meta::Track, public Meta::TrackEditor - { - public: - class Private; - - enum LookupType { - AutomaticLookup, - ManualLookup - }; - - /** - * Construct a lazy-loading proxying track. You must assign this track to a - * KSharedPtr right after constructing it. - * - * If @param lookupType is AutomaticLookup (the default), an asynchronous - * job employing CollectionManager to lookup the track in TrackProviders is - * enqueued and started right from this constructor. - * - * If @param lookupType is ManualLookup, lookup is not done automatically - * and you are responsible to call lookupTrack() once it is feasible. This way - * you can also optionally define which TrackProvider will be used. - */ - Track( const KUrl &url, LookupType lookupType = AutomaticLookup ); - virtual ~Track(); - - /** - * Tell MetaProxy::Track to start looking up the real track. Only valid if - * this Track is constructed with lookupType = ManualLookup. This method - * returns quickly and the lookup happens asynchronously in a thread (in - * other words, @param provider, id supplied, must be thread-safe). - * - * If @param provider is null (the default), lookup happens in all - * registered providers by employing CollectionManager. Otherwise lookup - * only checks @param provider (still asynchronously). - */ - void lookupTrack( Collections::TrackProvider *provider = 0 ); - - // methods inherited from Meta::MetaCapability - virtual bool hasCapabilityInterface( Capabilities::Capability::Type type ) const; - virtual Capabilities::Capability* createCapabilityInterface( Capabilities::Capability::Type type ); - - // methods inherited from Meta::Base - virtual QString name() const; - virtual QString prettyName() const; - virtual QString sortableName() const; - - // methods inherited from Meta::Track - virtual KUrl playableUrl() const; - virtual QString prettyUrl() const; - virtual QString uidUrl() const; - virtual QString notPlayableReason() const; - - virtual Meta::AlbumPtr album() const; - virtual Meta::ArtistPtr artist() const; - virtual Meta::GenrePtr genre() const; - virtual Meta::ComposerPtr composer() const; - virtual Meta::YearPtr year() const; - - virtual Meta::LabelList labels() const; - virtual qreal bpm() const; - virtual QString comment() const; - virtual qint64 length() const; - virtual int filesize() const; - virtual int sampleRate() const; - virtual int bitrate() const; - virtual QDateTime createDate() const; - virtual QDateTime modifyDate() const; - virtual int trackNumber() const; - virtual int discNumber() const; - virtual qreal replayGain( Meta::ReplayGainTag mode ) const; - - virtual QString type() const; - - virtual void prepareToPlay(); - virtual void finishedPlaying( double playedFraction ); - - virtual bool inCollection() const; - virtual Collections::Collection *collection() const; - - virtual QString cachedLyrics() const; - virtual void setCachedLyrics( const QString &lyrics ); - - virtual void addLabel( const QString &label ); - virtual void addLabel( const Meta::LabelPtr &label ); - virtual void removeLabel( const Meta::LabelPtr &label ); - - virtual Meta::TrackEditorPtr editor(); - virtual Meta::StatisticsPtr statistics(); - - virtual bool operator==( const Meta::Track &track ) const; - - // Meta::TrackEditor methods: - virtual void setAlbum( const QString &album ); - virtual void setAlbumArtist( const QString &artist ); - virtual void setArtist( const QString &artist ); - virtual void setComposer( const QString &composer ); - virtual void setGenre( const QString &genre ); - virtual void setYear( int year ); - virtual void setComment( const QString &comment ); - virtual void setTitle( const QString &name ); - virtual void setTrackNumber( int number ); - virtual void setDiscNumber( int discNumber ); - virtual void setBpm( const qreal bpm ); - - virtual void beginUpdate(); - virtual void endUpdate(); - - // custom MetaProxy methods - /** - * Return true if underlying track has already been found, false otherwise. - */ - bool isResolved() const; - void setLength( qint64 length ); - - /** - * MetaProxy will update the proxy with the track. - */ - void updateTrack( Meta::TrackPtr track ); - - private: - Q_DISABLE_COPY( Track ) - - Private *const d; // constant pointer to non-constant object - }; - -} - -#endif diff --git a/amarok/src/core-impl/meta/proxy/MetaProxyWorker.cpp b/amarok/src/core-impl/meta/proxy/MetaProxyWorker.cpp deleted file mode 100644 index de4422e0..00000000 --- a/amarok/src/core-impl/meta/proxy/MetaProxyWorker.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Bart Cerneels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "MetaProxyWorker.h" - -#include "core/meta/Meta.h" -#include "core-impl/collections/support/CollectionManager.h" - -using namespace MetaProxy; - -Worker::Worker( const KUrl &url, Collections::TrackProvider *provider ) - : m_url( url ) - , m_provider( provider ) - , m_stepsDoneReceived( 0 ) -{ - connect( this, SIGNAL(done(ThreadWeaver::Job*)), SLOT(slotStepDone()) ); - connect( this, SIGNAL(finishedLookup(Meta::TrackPtr)), SLOT(slotStepDone()) ); -} - -void -Worker::run() -{ - Meta::TrackPtr track; - - if( m_provider ) - { - track = m_provider->trackForUrl( m_url ); - emit finishedLookup( track ); - return; - } - - track = CollectionManager::instance()->trackForUrl( m_url ); - if( track ) - { - emit finishedLookup( track ); - return; - } - - // no TrackProvider has a track for us yet, query new ones that are added. - if( !track ) - { - connect( CollectionManager::instance(), - SIGNAL(trackProviderAdded(Collections::TrackProvider*)), - SLOT(slotNewTrackProvider(Collections::TrackProvider*)), - Qt::DirectConnection ); // we may live in a thread w/out event loop - connect( CollectionManager::instance(), - SIGNAL(collectionAdded(Collections::Collection*)), - SLOT(slotNewCollection(Collections::Collection*)), - Qt::DirectConnection ); // we may live in a thread w/out event loop - return; - } - -} - -void -Worker::slotNewTrackProvider( Collections::TrackProvider *newTrackProvider ) -{ - if( !newTrackProvider ) - return; - - if( newTrackProvider->possiblyContainsTrack( m_url ) ) - { - Meta::TrackPtr track = newTrackProvider->trackForUrl( m_url ); - emit finishedLookup( track ); - } -} - -void -Worker::slotNewCollection( Collections::Collection *newCollection ) -{ - slotNewTrackProvider( newCollection ); -} - -void -Worker::slotStepDone() -{ - m_stepsDoneReceived++; - if( m_stepsDoneReceived >= 2 ) - deleteLater(); -} diff --git a/amarok/src/core-impl/meta/proxy/MetaProxyWorker.h b/amarok/src/core-impl/meta/proxy/MetaProxyWorker.h deleted file mode 100644 index fb19d65c..00000000 --- a/amarok/src/core-impl/meta/proxy/MetaProxyWorker.h +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Bart Cerneels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef METAPROXY_METAPROXYWORKER_H -#define METAPROXY_METAPROXYWORKER_H - -#include "core/collections/Collection.h" - -#include - -namespace MetaProxy -{ - /** - * Worker to get real track for MetaProxy::Track. Worker deletes itself somewhere - * after emitting finishedLookup(). - */ - class Worker : public ThreadWeaver::Job - { - Q_OBJECT - - public: - /** - * If @param provider is null (the default), all providers registered to - * CollectionManager are used and a watch for new providers is used. - * Otherwise the lookup happes just in @param provider and is one-shot. - */ - explicit Worker( const KUrl &url, Collections::TrackProvider *provider = 0 ); - - //TrackForUrlWorker virtual methods - virtual void run(); - - signals: - void finishedLookup( Meta::TrackPtr track ); - - private slots: - void slotNewTrackProvider( Collections::TrackProvider *newTrackProvider ); - void slotNewCollection( Collections::Collection *newCollection ); - void slotStepDone(); - - private: - KUrl m_url; - Collections::TrackProvider *m_provider; - int m_stepsDoneReceived; - }; -} // namespace MetaProxy - -#endif // METAPROXY_METAPROXYWORKER_H diff --git a/amarok/src/core-impl/meta/proxy/MetaProxy_p.h b/amarok/src/core-impl/meta/proxy/MetaProxy_p.h deleted file mode 100644 index 7a0dd7b3..00000000 --- a/amarok/src/core-impl/meta/proxy/MetaProxy_p.h +++ /dev/null @@ -1,456 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_METAPROXY_P_H -#define AMAROK_METAPROXY_P_H - -#include "core/collections/Collection.h" -#include "core/meta/Meta.h" -#include "core/meta/Observer.h" -#include "core-impl/meta/stream/Stream.h" - -#include -#include -#include -#include - -#include -#include - - -using namespace MetaProxy; - -class MetaProxy::Track::Private : public QObject, public Meta::Observer -{ - Q_OBJECT - - public: - Track *proxy; - KUrl url; - - Meta::TrackPtr realTrack; - - QString cachedArtist; - QString cachedAlbum; - QString cachedName; - QString cachedGenre; - QString cachedComposer; - int cachedYear; - qint64 cachedLength; - qreal cachedBpm; - int cachedTrackNumber; - int cachedDiscNumber; - - Meta::ArtistPtr artistPtr; - Meta::AlbumPtr albumPtr; - Meta::GenrePtr genrePtr; - Meta::ComposerPtr composerPtr; - Meta::YearPtr yearPtr; - - public: - using Observer::metadataChanged; - void metadataChanged( Meta::TrackPtr track ) - { - Q_UNUSED( track ) - proxy->notifyObservers(); - } - - public slots: - void slotUpdateTrack( Meta::TrackPtr track ) - { - if( track ) - { - // special handling for streams that cannot fetch metadata until played, bug 305389 - MetaStream::Track *stream = dynamic_cast( track.data() ); - if( stream ) - stream->setInitialInfo( cachedArtist, cachedAlbum, cachedName, - cachedLength, cachedTrackNumber ); - - subscribeTo( track ); - realTrack = track; - - // clear memory of now-unused cached fields: - url.clear(); - cachedArtist.clear(); - cachedAlbum.clear(); - cachedName.clear(); - cachedGenre.clear(); - cachedComposer.clear(); - - proxy->notifyObservers(); - } - } -}; - -// internal helper classes - -class ProxyArtist : public Meta::Artist -{ -public: - ProxyArtist( MetaProxy::Track::Private *dptr ) - : Meta::Artist() - , d( dptr ) - {} - - Meta::TrackList tracks() - { - Meta::TrackPtr realTrack = d ? d->realTrack : Meta::TrackPtr(); - Meta::ArtistPtr artist = realTrack ? realTrack->artist() : Meta::ArtistPtr(); - return artist ? artist->tracks() : Meta::TrackList(); - } - - QString name() const - { - Meta::TrackPtr realTrack = d ? d->realTrack : Meta::TrackPtr(); - if( realTrack ) - { - Meta::ArtistPtr artist = realTrack ? realTrack->artist() : Meta::ArtistPtr(); - return artist ? artist->name() : QString(); - } - return d ? d->cachedArtist : QString(); - } - - QString prettyName() const - { - Meta::TrackPtr realTrack = d ? d->realTrack : Meta::TrackPtr(); - if( realTrack ) - { - Meta::ArtistPtr artist = realTrack ? realTrack->artist() : Meta::ArtistPtr(); - return artist ? artist->prettyName() : QString(); - } - return d ? d->cachedArtist : QString(); - } - - virtual bool operator==( const Meta::Artist &artist ) const - { - const ProxyArtist *proxy = dynamic_cast( &artist ); - if( proxy ) - { - return d && proxy->d && d->realTrack && proxy->d->realTrack && d->realTrack->artist() && d->realTrack->artist() == proxy->d->realTrack->artist(); - } - else - { - return d && d->realTrack && d->realTrack->artist() && d->realTrack->artist().data() == &artist; - } - } - - MetaProxy::Track::Private * const d; -}; - -/** TODO: what about MetaDataChanged? */ -class ProxyAlbum : public Meta::Album -{ -public: - ProxyAlbum( MetaProxy::Track::Private *dptr ) - : Meta::Album() - , d( dptr ) - {} - - bool hasCapabilityInterface( Capabilities::Capability::Type type ) const - { - if( d && d->realTrack && d->realTrack->album() ) - return d->realTrack->album()->hasCapabilityInterface( type ); - else - return false; - } - - Capabilities::Capability* createCapabilityInterface( Capabilities::Capability::Type type ) - { - if( d && d->realTrack && d->realTrack->album() ) - return d->realTrack->album()->createCapabilityInterface( type ); - else - return 0; - } - - bool isCompilation() const - { - if( d && d->realTrack && d->realTrack->album() ) - return d->realTrack->album()->isCompilation(); - else - return false; - } - - bool canUpdateCompilation() const - { - if( d && d->realTrack && d->realTrack->album() ) - return d->realTrack->album()->canUpdateCompilation(); - else - return Meta::Album::canUpdateCompilation(); - } - - void setCompilation( bool isCompilation ) - { - if( d && d->realTrack && d->realTrack->album() ) - return d->realTrack->album()->setCompilation( isCompilation ); - } - - bool hasAlbumArtist() const - { - if( d && d->realTrack && d->realTrack->album() ) - return d->realTrack->album()->hasAlbumArtist(); - else - return false; - } - - Meta::ArtistPtr albumArtist() const - { - if( d && d->realTrack && d->realTrack->album() ) - return d->realTrack->album()->albumArtist(); - else - return Meta::ArtistPtr(); - } - - Meta::TrackList tracks() - { - if( d && d->realTrack && d->realTrack->album() ) - return d->realTrack->album()->tracks(); - else - return Meta::TrackList(); - } - - QString name() const - { - if( d && d->realTrack ) - { - if ( d->realTrack->album() ) - return d->realTrack->album()->name(); - return QString(); - } - else if ( d ) - return d->cachedAlbum; - else - return QString(); - } - - QString prettyName() const - { - if( d && d->realTrack && d->realTrack->album() ) - return d->realTrack->album()->prettyName(); - else - return name(); - } - - QImage image( int size ) const - { - if( d && d->realTrack && d->realTrack->album() ) - return d->realTrack->album()->image( size ); - else - return Meta::Album::image( size ); - } - - bool hasImage( int size ) const - { - if( d && d->realTrack && d->realTrack->album() ) - return d->realTrack->album()->hasImage( size ); - else - return Meta::Album::hasImage( size ); - } - - KUrl imageLocation( int size = 0 ) - { - if( d && d->realTrack && d->realTrack->album() ) - return d->realTrack->album()->imageLocation( size ); - else - return Meta::Album::imageLocation( size ); - } - - bool canUpdateImage() const - { - if( d && d->realTrack && d->realTrack->album() ) - return d->realTrack->album()->canUpdateImage(); - else - return Meta::Album::canUpdateImage(); - } - - void setImage( const QImage &image ) - { - if( d && d->realTrack && d->realTrack->album() ) - return d->realTrack->album()->setImage( image ); - } - - void removeImage() - { - if( d && d->realTrack && d->realTrack->album() ) - return d->realTrack->album()->removeImage(); - } - - virtual bool operator==( const Meta::Album &album ) const - { - const ProxyAlbum *proxy = dynamic_cast( &album ); - if( proxy ) - { - return d && proxy->d && d->realTrack && proxy->d->realTrack && d->realTrack->album() && ( *d->realTrack->album().data() ) == ( *proxy->d->realTrack->album().data() ); - } - else - { - return d && d->realTrack && d->realTrack->album() && ( *d->realTrack->album().data() ) == album; - } - } - - MetaProxy::Track::Private * const d; -}; - -class ProxyGenre : public Meta::Genre -{ -public: - ProxyGenre( MetaProxy::Track::Private *dptr ) - : Meta::Genre() - , d( dptr ) - {} - - QString name() const - { - if( d && d->realTrack && d->realTrack->genre() ) - return d->realTrack->genre()->name(); - else if( d ) - return d->cachedGenre; - else - return QString(); - } - - QString prettyName() const - { - if( d && d->realTrack && d->realTrack->genre() ) - return d->realTrack->genre()->prettyName(); - else - return QString(); - } - - Meta::TrackList tracks() - { - if( d && d->realTrack && d->realTrack->genre() ) - return d->realTrack->genre()->tracks(); - else - return Meta::TrackList(); - } - - virtual bool operator==( const Meta::Genre &genre ) const - { - const ProxyGenre *proxy = dynamic_cast( &genre ); - if( proxy ) - { - return d && proxy->d && d->realTrack && proxy->d->realTrack && d->realTrack->genre() && d->realTrack->genre() == proxy->d->realTrack->genre(); - } - else - { - return d && d->realTrack && d->realTrack->genre() && d->realTrack->genre().data() == &genre; - } - } - - MetaProxy::Track::Private * const d; -}; - -class ProxyComposer : public Meta::Composer -{ -public: - ProxyComposer( MetaProxy::Track::Private *dptr ) - : Meta::Composer() - , d( dptr ) - {} - - QString name() const - { - if( d && d->realTrack && d->realTrack->composer() ) - return d->realTrack->composer()->name(); - else if ( d ) - return d->cachedComposer; - else - return QString(); - } - - QString prettyName() const - { - if( d && d->realTrack && d->realTrack->composer()) - return d->realTrack->composer()->prettyName(); - else - return name(); - } - - Meta::TrackList tracks() - { - if( d && d->realTrack && d->realTrack->composer() ) - return d->realTrack->composer()->tracks(); - else - return Meta::TrackList(); - } - - virtual bool operator==( const Meta::Composer &composer ) const - { - const ProxyComposer *proxy = dynamic_cast( &composer ); - if( proxy ) - { - return d && proxy->d && d->realTrack && proxy->d->realTrack && d->realTrack->composer() && d->realTrack->composer() == proxy->d->realTrack->composer(); - } - else - { - return d && d->realTrack && d->realTrack->composer() && d->realTrack->composer().data() == &composer; - } - } - - MetaProxy::Track::Private * const d; -}; - -class ProxyYear : public Meta::Year -{ -public: - ProxyYear( MetaProxy::Track::Private *dptr ) - : Meta::Year() - , d( dptr ) - {} - - QString name() const - { - if( d && d->realTrack && d->realTrack->year() ) - return d->realTrack->year()->name(); - else if( d ) - return QString::number(d->cachedYear); - else - return QString(); - } - - QString prettyName() const - { - if( d && d->realTrack && d->realTrack->year() ) - return d->realTrack->year()->prettyName(); - else - return name(); - } - - Meta::TrackList tracks() - { - if( d && d->realTrack && d->realTrack->year() ) - return d->realTrack->year()->tracks(); - else - return Meta::TrackList(); - } - - virtual bool operator==( const Meta::Year &year ) const - { - const ProxyYear *proxy = dynamic_cast( &year ); - if( proxy ) - { - return d && proxy->d && d->realTrack && proxy->d->realTrack && d->realTrack->year() && d->realTrack->year() == proxy->d->realTrack->year(); - } - else - { - return d && d->realTrack && d->realTrack->year() && d->realTrack->year().data() == &year; - } - } - - MetaProxy::Track::Private * const d; -}; - -#endif diff --git a/amarok/src/core-impl/meta/stream/Stream.cpp b/amarok/src/core-impl/meta/stream/Stream.cpp deleted file mode 100644 index 339deacc..00000000 --- a/amarok/src/core-impl/meta/stream/Stream.cpp +++ /dev/null @@ -1,193 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007-2008 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "core-impl/meta/stream/Stream.h" -#include "core-impl/meta/stream/Stream_p.h" - -#include "core/support/Amarok.h" -#include "core/support/Debug.h" -#include "core/meta/Meta.h" -#include "core-impl/meta/default/DefaultMetaTypes.h" -#include "core-impl/support/UrlStatisticsStore.h" - -#include -#include - -using namespace MetaStream; - -Track::Track( const KUrl &url ) - : Meta::Track() - , d( new Track::Private( this ) ) -{ - d->url = url; - d->artistPtr = Meta::ArtistPtr( new StreamArtist( d ) ); - d->albumPtr = Meta::AlbumPtr( new StreamAlbum( d ) ); - d->genrePtr = Meta::GenrePtr( new StreamGenre( d ) ); - d->composerPtr = Meta::ComposerPtr( new Meta::DefaultComposer() ); - d->yearPtr = Meta::YearPtr( new Meta::DefaultYear() ); -} - -Track::~Track() -{ - delete d; -} - -QString -Track::name() const -{ - if( d->title.isEmpty() ) - return i18n( "Stream (%1)", d->url.url() ); - return d->title; -} - -KUrl -Track::playableUrl() const -{ - return d->url; -} - -QString -Track::prettyUrl() const -{ - return playableUrl().prettyUrl(); -} - -QString -Track::uidUrl() const -{ - return playableUrl().url(); -} - -QString -Track::notPlayableReason() const -{ - return networkNotPlayableReason(); -} - -Meta::AlbumPtr -Track::album() const -{ - return d->albumPtr; -} - -Meta::ArtistPtr -Track::artist() const -{ - return d->artistPtr; -} - -Meta::GenrePtr -Track::genre() const -{ - return d->genrePtr; -} - -Meta::ComposerPtr -Track::composer() const -{ - return d->composerPtr; -} - -Meta::YearPtr -Track::year() const -{ - return d->yearPtr; -} - -qreal -Track::bpm() const -{ - return -1.0; -} - -QString -Track::comment() const -{ - return d->comment; -} - -int -Track::trackNumber() const -{ - return d->trackNumber; -} - -int -Track::discNumber() const -{ - return 0; -} - -qint64 -Track::length() const -{ - return d->length; -} - -int -Track::filesize() const -{ - return 0; -} - -int -Track::sampleRate() const -{ - return 0; -} - -int -Track::bitrate() const -{ - return 0; -} - -void -Track::finishedPlaying( double playedFraction ) -{ - // playedFraction will nearly always be 1, because EngineController updates length - // just before calling finishedPlaying(). Mimic Last.fm scrobbling wrt min length - // requirement, tracks shorter than 30s are often ads etc. - if( length() < 30 * 1000 ) - return; - Meta::Track::finishedPlaying( playedFraction ); -} - -QString -Track::type() const -{ - // don't localize. See EngineController quirks - return "stream"; -} - -void -Track::setInitialInfo( const QString &artist, const QString &album, const QString &title, - qint64 length, int trackNumber ) -{ - if( d->artist.isEmpty() ) - d->artist = artist; - if( d->album.isEmpty() ) - d->album = album; - if( d->title.isEmpty() ) - d->title = title; - - if( d->length == 0 ) - d->length = length; - if( d->trackNumber == 0 ) - d->trackNumber = trackNumber; -} - -#include "moc_Stream_p.cpp" diff --git a/amarok/src/core-impl/meta/stream/Stream.h b/amarok/src/core-impl/meta/stream/Stream.h deleted file mode 100644 index 42fc30f8..00000000 --- a/amarok/src/core-impl/meta/stream/Stream.h +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_STREAM_H -#define AMAROK_STREAM_H - -#include "amarok_export.h" -#include "core/meta/Meta.h" - -namespace MetaStream -{ - class AMAROK_EXPORT Track : public Meta::Track - { - public: - class Private; - - Track( const KUrl &url ); - virtual ~Track(); - - // methods inherited from Meta::Base - virtual QString name() const; - - // methods inherited from Meta::Track - virtual KUrl playableUrl() const; - virtual QString prettyUrl() const; - virtual QString uidUrl() const; - virtual QString notPlayableReason() const; - - virtual Meta::AlbumPtr album() const; - virtual Meta::ArtistPtr artist() const; - virtual Meta::GenrePtr genre() const; - virtual Meta::ComposerPtr composer() const; - virtual Meta::YearPtr year() const; - - virtual qreal bpm() const; - virtual QString comment() const; - virtual int trackNumber() const; - virtual int discNumber() const; - - virtual qint64 length() const; - virtual int filesize() const; - virtual int sampleRate() const; - virtual int bitrate() const; - - virtual void finishedPlaying( double playedFraction ); - - virtual QString type() const; - - // MetaStream::Track methods, used to restore initial stream info - - /** - * Set initial values to display before more accurate info can be fetched. - * This method doesn't call notifyObservers(), it is the caller's - * responsibility; it also doesn't overwrite already filled entries. - * - * @param length is in milliseconds - */ - void setInitialInfo( const QString &artist, const QString &album, - const QString &title, qint64 length, int trackNumber ); - - private: - Private * const d; - }; - -} - -#endif diff --git a/amarok/src/core-impl/meta/stream/Stream_p.h b/amarok/src/core-impl/meta/stream/Stream_p.h deleted file mode 100644 index a4378f86..00000000 --- a/amarok/src/core-impl/meta/stream/Stream_p.h +++ /dev/null @@ -1,202 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007-2008 Maximilian Kossick * - * Copyright (c) 2008 Mark Kretschmann * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_STREAM_P_H -#define AMAROK_STREAM_P_H - -#include "EngineController.h" -#include "core/meta/Meta.h" -#include "core/meta/support/MetaConstants.h" -#include "core/support/Debug.h" -#include "core-impl/meta/default/DefaultMetaTypes.h" -#include "covermanager/CoverCache.h" - -#include - -using namespace MetaStream; - -class MetaStream::Track::Private : public QObject -{ - Q_OBJECT - - public: - Private( Track *t ) - : trackNumber( 0 ) - , length( 0 ) - , track( t ) - { - EngineController *engine = The::engineController(); - if( !engine ) - return; // engine might not be available during tests, silence the warning - - // force a direct connection or slot might not be called because of thread - // affinity. (see BUG 300334) - connect( engine, SIGNAL(currentMetadataChanged( QVariantMap) ), - this, SLOT(currentMetadataChanged( QVariantMap )), - Qt::DirectConnection ); - } - - public Q_SLOTS: - void currentMetadataChanged( QVariantMap metaData ) - { - const QUrl metaDataUrl = metaData.value( Meta::Field::URL ).toUrl(); - if( metaDataUrl == url ) - { - // keep synchronized to EngineController::slotMetaDataChanged() - if( metaData.contains( Meta::Field::ARTIST ) ) - artist = metaData.value( Meta::Field::ARTIST ).toString(); - if( metaData.contains( Meta::Field::TITLE ) ) - title = metaData.value( Meta::Field::TITLE ).toString(); - if( metaData.contains( Meta::Field::ALBUM ) ) - album = metaData.value( Meta::Field::ALBUM ).toString(); - if( metaData.contains( Meta::Field::GENRE ) ) - genre = metaData.value( Meta::Field::GENRE ).toString(); - if( metaData.contains( Meta::Field::TRACKNUMBER ) ) - trackNumber = metaData.value( Meta::Field::TRACKNUMBER ).toInt(); - if( metaData.contains( Meta::Field::COMMENT ) ) - comment = metaData.value( Meta::Field::COMMENT ).toString(); - if( metaData.contains( Meta::Field::LENGTH ) ) - length = metaData.value( Meta::Field::LENGTH ).value(); - - //TODO: move special handling to subclass or using some configurable XSPF - // Special demangling of artist/title for Shoutcast streams, which usually - // have "Artist - Title" in the title tag: - if( artist.isEmpty() && title.contains( " - " ) ) - { - const QStringList artist_title = title.split( " - " ); - if( artist_title.size() >= 2 ) - { - artist = artist_title[0]; - title = title.remove( 0, artist.length() + 3 ); - } - } - - track->notifyObservers(); - } - } - - public: - KUrl url; - QString title; - QString artist; - QString album; - QString genre; - int trackNumber; - QString comment; - qint64 length; - - Meta::ArtistPtr artistPtr; - Meta::AlbumPtr albumPtr; - Meta::GenrePtr genrePtr; - Meta::ComposerPtr composerPtr; - Meta::YearPtr yearPtr; - - private: - Track *track; -}; - - -// internal helper classes - -class StreamArtist : public Meta::DefaultArtist -{ - public: - StreamArtist( MetaStream::Track::Private *dptr ) - : DefaultArtist() - , d( dptr ) - {} - - QString name() const - { - if( d && !d->artist.isEmpty() ) - return d->artist; - return DefaultArtist::name(); - } - - MetaStream::Track::Private * const d; -}; - -class StreamAlbum : public Meta::DefaultAlbum -{ -public: - StreamAlbum( MetaStream::Track::Private *dptr ) - : DefaultAlbum() - , d( dptr ) - {} - - ~StreamAlbum() - { - CoverCache::invalidateAlbum( this ); - } - - bool hasAlbumArtist() const - { - return false; - } - - QString name() const - { - if( d && !d->album.isEmpty() ) - return d->album; - return DefaultAlbum::name(); - } - - bool hasImage( int size ) const - { - if( m_cover.isNull() ) - return Meta::Album::hasImage( size ); - else - return true; - } - - QImage image( int size ) const - { - if( m_cover.isNull() ) - return Meta::Album::image( size ); - else - return m_cover.scaled( size, size, Qt::KeepAspectRatio, Qt::SmoothTransformation ); - } - - void setImage( const QImage &image ) - { - m_cover = image; - CoverCache::invalidateAlbum( this ); - } - - MetaStream::Track::Private * const d; - QImage m_cover; -}; - -class StreamGenre : public Meta::DefaultGenre -{ -public: - StreamGenre( MetaStream::Track::Private *dptr ) - : DefaultGenre() - , d( dptr ) - {} - - QString name() const - { - if( d && !d->genre.isEmpty() ) - return d->genre; - return DefaultGenre::name(); - } - - MetaStream::Track::Private * const d; -}; - -#endif diff --git a/amarok/src/core-impl/meta/timecode/TimecodeMeta.cpp b/amarok/src/core-impl/meta/timecode/TimecodeMeta.cpp deleted file mode 100644 index b053eb63..00000000 --- a/amarok/src/core-impl/meta/timecode/TimecodeMeta.cpp +++ /dev/null @@ -1,621 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "core-impl/meta/timecode/TimecodeMeta.h" - -#include "core/support/Debug.h" -#include "covermanager/CoverCache.h" -#include "covermanager/CoverFetchingActions.h" -#include "covermanager/CoverFetcher.h" -#include "core/capabilities/ActionsCapability.h" -#include "core/capabilities/Capability.h" -#include "core/capabilities/BoundedPlaybackCapability.h" -#include "core-impl/capabilities/AlbumActionsCapability.h" -#include "core-impl/capabilities/timecode/TimecodeBoundedPlaybackCapability.h" - -using namespace Meta; -using namespace Capabilities; - -////////////////// TRACK ////////////////// - -TimecodeTrack::TimecodeTrack( const QString &name, const QString &url, qint64 start, qint64 end ) - : m_name( name ) - , m_start( start ) - , m_end( end ) - , m_length( end - start ) - , m_bpm( -1.0 ) - , m_trackNumber( 0 ) - , m_discNumber( 0 ) - , m_comment( QString() ) - , m_playableUrl( url ) - , m_updatedFields( 0 ) -{ - m_displayUrl = url + ':' + QString::number( start ) + '-' + QString::number( end ); -} - -TimecodeTrack::~ TimecodeTrack() -{ -} - -QString -TimecodeTrack::name() const -{ - return m_name; -} - -KUrl -TimecodeTrack::playableUrl() const -{ - return m_playableUrl; -} - -QString -TimecodeTrack::uidUrl() const -{ - return m_displayUrl; -} - -QString -TimecodeTrack::prettyUrl() const -{ - return m_displayUrl; -} - -QString -TimecodeTrack::notPlayableReason() const -{ - return localFileNotPlayableReason( m_playableUrl ); -} - -AlbumPtr -TimecodeTrack::album() const -{ - return AlbumPtr::staticCast( m_album ); -} - -ArtistPtr -TimecodeTrack::artist() const -{ - return ArtistPtr::staticCast( m_artist ); -} - -GenrePtr -TimecodeTrack::genre() const -{ - return GenrePtr::staticCast( m_genre ); -} - -ComposerPtr -TimecodeTrack::composer() const -{ - return ComposerPtr::staticCast( m_composer ); -} - -YearPtr -TimecodeTrack::year() const -{ - return YearPtr::staticCast( m_year ); -} - -qreal -TimecodeTrack::bpm() const -{ - return m_bpm; -} - -QString -TimecodeTrack::comment() const -{ - return m_comment; -} - -int -TimecodeTrack::bitrate() const -{ - return -1; -} - -int -TimecodeTrack::sampleRate() const -{ - return -1; -} - -int -TimecodeTrack::filesize() const -{ - return -1; -} - -qint64 -TimecodeTrack::length() const -{ - return m_length; -} - -int -TimecodeTrack::trackNumber() const -{ - return m_trackNumber; -} - -int -TimecodeTrack::discNumber() const -{ - return m_discNumber; -} - -QString -TimecodeTrack::type() const -{ - return QString(); -} - -void -TimecodeTrack::setAlbum( const QString &newAlbum ) -{ - m_updatedFields |= ALBUM_UPDATED; - m_fields.insert( ALBUM_UPDATED, newAlbum ); -} - -void -TimecodeTrack::setArtist( const QString &newArtist ) -{ - m_updatedFields |= ARTIST_UPDATED; - m_fields.insert( ARTIST_UPDATED, newArtist ); -} - -void -TimecodeTrack::setComposer( const QString &newComposer ) -{ - m_updatedFields |= COMPOSER_UPDATED; - m_fields.insert( COMPOSER_UPDATED, newComposer ); -} - -void -TimecodeTrack::setGenre( const QString &newGenre ) -{ - m_updatedFields |= GENRE_UPDATED; - m_fields.insert( GENRE_UPDATED, newGenre ); -} - -void -TimecodeTrack::setYear( int newYear ) -{ - m_updatedFields |= YEAR_UPDATED; - m_fields.insert( YEAR_UPDATED, QString::number( newYear ) ); -} - -void -TimecodeTrack::setBpm( const qreal newBpm ) -{ - m_updatedFields |= BPM_UPDATED; - m_fields.insert( BPM_UPDATED, QString::number( (qreal) newBpm ) ); -} - -void -TimecodeTrack::setTitle( const QString &newTitle ) -{ - m_updatedFields |= TITLE_UPDATED; - m_fields.insert( TITLE_UPDATED, newTitle ); -} - -void -TimecodeTrack::setComment( const QString &newComment ) -{ - m_updatedFields |= COMMENT_UPDATED; - m_fields.insert( COMMENT_UPDATED, newComment ); -} - -void -TimecodeTrack::setTrackNumber( int newTrackNumber ) -{ - m_updatedFields |= TRACKNUMBER_UPDATED; - m_fields.insert( TRACKNUMBER_UPDATED, QString::number( newTrackNumber ) ); -} - -void -TimecodeTrack::setDiscNumber( int newDiscNumber ) -{ - m_updatedFields |= DISCNUMBER_UPDATED; - m_fields.insert( DISCNUMBER_UPDATED, QString::number( newDiscNumber ) ); -} - -void TimecodeTrack::beginUpdate() -{ - m_updatedFields = 0; - m_fields.clear(); -} - -void TimecodeTrack::endUpdate() -{ - - bool updateCover = false; - - if ( m_updatedFields & ALBUM_UPDATED ) - { - //create a new album: - m_album = TimecodeAlbumPtr( new TimecodeAlbum( m_fields.value( ALBUM_UPDATED ) ) ); - m_album->addTrack( TimecodeTrackPtr( this ) ); - setAlbum( m_album ); - m_album->setAlbumArtist( m_artist ); - } - - if ( m_updatedFields & ARTIST_UPDATED ) - { - //create a new album: - m_artist = TimecodeArtistPtr( new TimecodeArtist( m_fields.value( ARTIST_UPDATED ) ) ); - m_artist->addTrack( TimecodeTrackPtr( this ) ); - setArtist( m_artist ); - m_album->setAlbumArtist( m_artist ); - updateCover = true; - } - - if ( m_updatedFields & COMPOSER_UPDATED ) - { - //create a new album: - m_composer = TimecodeComposerPtr( new TimecodeComposer( m_fields.value( COMPOSER_UPDATED ) ) ); - m_composer->addTrack( TimecodeTrackPtr( this ) ); - setComposer( m_composer ); - } - - if ( m_updatedFields & GENRE_UPDATED ) - { - //create a new album: - m_genre = TimecodeGenrePtr( new TimecodeGenre( m_fields.value( GENRE_UPDATED ) ) ); - m_genre->addTrack( TimecodeTrackPtr( this ) ); - setGenre( m_genre ); - } - - if ( m_updatedFields & YEAR_UPDATED ) - { - //create a new album: - m_year = TimecodeYearPtr( new TimecodeYear( m_fields.value( YEAR_UPDATED ) ) ); - m_year->addTrack( TimecodeTrackPtr( this ) ); - setYear( m_year ); - } - - if ( m_updatedFields & BPM_UPDATED ) - { - m_bpm = m_fields.value( BPM_UPDATED ).toDouble(); - } - - if ( m_updatedFields & TITLE_UPDATED ) - { - //create a new album: - m_name = m_fields.value( TITLE_UPDATED ); - updateCover = true; - } - - if ( m_updatedFields & COMMENT_UPDATED ) - { - //create a new album: - m_comment = m_fields.value( COMMENT_UPDATED ); - } - - if ( m_updatedFields & TRACKNUMBER_UPDATED ) - { - //create a new album: - m_trackNumber = m_fields.value( TRACKNUMBER_UPDATED ).toInt(); - } - - if ( m_updatedFields & DISCNUMBER_UPDATED ) - { - //create a new album: - m_discNumber = m_fields.value( DISCNUMBER_UPDATED ).toInt(); - } - - if ( updateCover ) - The::coverFetcher()->queueAlbum( AlbumPtr::staticCast( m_album ) ); - - m_updatedFields = 0; - m_fields.clear(); - - notifyObservers(); -} - -void -TimecodeTrack::setAlbum( TimecodeAlbumPtr album ) -{ - m_album = album; -} - -void -TimecodeTrack::setAlbumArtist( const QString & ) -{ - // no suport for it -} - -void -TimecodeTrack::setYear( TimecodeYearPtr year ) -{ - m_year = year; -} - -void -TimecodeTrack::setGenre( TimecodeGenrePtr genre ) -{ - m_genre = genre; -} - -void -TimecodeTrack::setComposer( TimecodeComposerPtr composer ) -{ - m_composer = composer; -} - -void -TimecodeTrack::setArtist( TimecodeArtistPtr artist ) -{ - m_artist = artist; -} - - -bool -TimecodeTrack::hasCapabilityInterface( Capabilities::Capability::Type type ) const -{ - return type == Capabilities::Capability::BoundedPlayback; -} - -Capabilities::Capability * -TimecodeTrack::createCapabilityInterface( Capabilities::Capability::Type type ) -{ - DEBUG_BLOCK - - if ( type == Capabilities::Capability::BoundedPlayback ) - return new Capabilities::TimecodeBoundedPlaybackCapability( this ); - else - return 0; -} - -TrackEditorPtr -TimecodeTrack::editor() -{ - return TrackEditorPtr( this ); -} - -qint64 Meta::TimecodeTrack::start() -{ - return m_start; -} - -qint64 Meta::TimecodeTrack::end() -{ - return m_end; -} - - -////////////////// ARTIST ////////////////// - -TimecodeArtist::TimecodeArtist( const QString & name ) - : m_name( name ) -{ -} - -TimecodeArtist::~ TimecodeArtist() -{ -} - -QString -TimecodeArtist::name() const -{ - return m_name; -} - -TrackList -TimecodeArtist::tracks() -{ - return m_tracks; -} - -AlbumList -TimecodeArtist::albums() -{ - return AlbumList(); -} - -void -TimecodeArtist::addTrack( TimecodeTrackPtr track ) -{ - m_tracks.append( TrackPtr::staticCast( track ) ); -} - -////////////////// ALBUM ////////////////// - -TimecodeAlbum::TimecodeAlbum( const QString & name ) - : QObject() - , m_name( name ) - , m_isCompilation( false ) -{ -} - -TimecodeAlbum::~ TimecodeAlbum() -{ - CoverCache::invalidateAlbum( this ); -} - -QString -TimecodeAlbum::name() const -{ - return m_name; -} - -bool -TimecodeAlbum::isCompilation() const -{ - return m_isCompilation; -} - -bool TimecodeAlbum::hasAlbumArtist() const -{ - return !m_albumArtist.isNull(); -} - -ArtistPtr TimecodeAlbum::albumArtist() const -{ - return ArtistPtr::staticCast( m_albumArtist ); -} - -TrackList -TimecodeAlbum::tracks() -{ - return m_tracks; -} - -QImage -TimecodeAlbum::image( int size ) const -{ - if( m_cover.isNull() ) - return Meta::Album::image( size ); - else - return m_cover.scaled( size, size, Qt::KeepAspectRatio, Qt::SmoothTransformation ); -} - -bool -TimecodeAlbum::canUpdateImage() const -{ - return true; -} - -void -TimecodeAlbum::setImage( const QImage &image ) -{ - m_cover = image; - CoverCache::invalidateAlbum( this ); - notifyObservers(); -} - -void -TimecodeAlbum::addTrack( TimecodeTrackPtr track ) -{ - m_tracks.append( TrackPtr::staticCast( track ) ); -} - -void TimecodeAlbum::setAlbumArtist( TimecodeArtistPtr artist ) -{ - m_albumArtist = artist; -} - -bool TimecodeAlbum::hasCapabilityInterface( Capabilities::Capability::Type type ) const -{ - switch( type ) - { - case Capabilities::Capability::Actions: - return true; - default: - return false; - } -} - -Capabilities::Capability* TimecodeAlbum::createCapabilityInterface( Capabilities::Capability::Type type ) -{ - switch( type ) - { - case Capabilities::Capability::Actions: - return new AlbumActionsCapability( Meta::AlbumPtr( this ) ); - default: - return 0; - } -} - -////////////////// GENRE ////////////////// - -TimecodeGenre::TimecodeGenre(const QString & name) - : m_name( name ) -{ -} - -TimecodeGenre::~ TimecodeGenre() -{ -} - -QString -TimecodeGenre::name() const -{ - return m_name; -} - -TrackList -TimecodeGenre::tracks() -{ - return tracks(); -} - -void -TimecodeGenre::addTrack( TimecodeTrackPtr track ) -{ - m_tracks.append( TrackPtr::staticCast( track ) ); -} - -////////////////// COMPOSER ////////////////// - -TimecodeComposer::TimecodeComposer( const QString & name ) - : m_name( name ) -{ -} - -TimecodeComposer::~ TimecodeComposer() -{ -} - -QString -TimecodeComposer::name() const -{ - return m_name; -} - -TrackList -TimecodeComposer::tracks() -{ - return m_tracks; -} - -void -TimecodeComposer::addTrack( TimecodeTrackPtr track ) -{ - m_tracks.append( TrackPtr::staticCast( track ) ); -} - -////////////////// YEAR ////////////////// - -TimecodeYear::TimecodeYear( const QString & name ) - : m_name( name ) -{ -} - -TimecodeYear::~ TimecodeYear() -{ -} - -QString -TimecodeYear::name() const -{ - return m_name; -} - -TrackList -TimecodeYear::tracks() -{ - return m_tracks; -} - -void -TimecodeYear::addTrack( TimecodeTrackPtr track ) -{ - m_tracks.append( TrackPtr::staticCast( track ) ); -} - -#include "moc_TimecodeMeta.cpp" diff --git a/amarok/src/core-impl/meta/timecode/TimecodeMeta.h b/amarok/src/core-impl/meta/timecode/TimecodeMeta.h deleted file mode 100644 index 8227126f..00000000 --- a/amarok/src/core-impl/meta/timecode/TimecodeMeta.h +++ /dev/null @@ -1,276 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef TIMECODEMETA_H -#define TIMECODEMETA_H - -#include "core/meta/Meta.h" -#include "core/meta/TrackEditor.h" - -class QAction; - -namespace Meta { - - class TimecodeTrack; - class TimecodeAlbum; - class TimecodeArtist; - class TimecodeGenre; - class TimecodeComposer; - class TimecodeYear; - - typedef KSharedPtr TimecodeTrackPtr; - typedef KSharedPtr TimecodeArtistPtr; - typedef KSharedPtr TimecodeAlbumPtr; - typedef KSharedPtr TimecodeGenrePtr; - typedef KSharedPtr TimecodeComposerPtr; - typedef KSharedPtr TimecodeYearPtr; - - -class TimecodeTrack : public Track, public TrackEditor -{ -public: - TimecodeTrack( const QString &name, const QString &url, qint64 start, qint64 end ); - virtual ~TimecodeTrack(); - - virtual QString name() const; - - virtual KUrl playableUrl() const; - virtual QString uidUrl() const; - virtual QString prettyUrl() const; - virtual QString notPlayableReason() const; - - virtual AlbumPtr album() const; - virtual ArtistPtr artist() const; - virtual GenrePtr genre() const; - virtual ComposerPtr composer() const; - virtual YearPtr year() const; - - virtual qreal bpm() const; - virtual QString comment() const; - virtual qint64 length() const; - virtual int filesize() const; - virtual int sampleRate() const; - virtual int bitrate() const; - virtual int trackNumber() const; - virtual int discNumber() const; - virtual QString type() const; - - virtual bool hasCapabilityInterface( Capabilities::Capability::Type type ) const; - virtual Capabilities::Capability *createCapabilityInterface( Capabilities::Capability::Type type ); - - virtual TrackEditorPtr editor(); - - // TrackEditor methods - virtual void setAlbum( const QString &newAlbum ); - virtual void setAlbumArtist( const QString &newAlbumArtist ); - virtual void setArtist( const QString &newArtist ); - virtual void setComposer( const QString &newComposer ); - virtual void setGenre( const QString &newGenre ); - virtual void setYear( int newYear ); - virtual void setTitle( const QString &newTitle ); - virtual void setComment( const QString &newComment ); - virtual void setTrackNumber( int newTrackNumber ); - virtual void setDiscNumber( int newDiscNumber ); - virtual void setBpm( const qreal newBpm ); - - virtual void beginUpdate(); - virtual void endUpdate(); - - //TimecodeTrack specific methods - void setAlbum( TimecodeAlbumPtr album ); - void setArtist( TimecodeArtistPtr artist ); - void setComposer( TimecodeComposerPtr composer ); - void setGenre( TimecodeGenrePtr genre ); - void setYear( TimecodeYearPtr year ); - - qint64 start(); - qint64 end(); - - -private: - //TimecodeCollection *m_collection; - - TimecodeArtistPtr m_artist; - TimecodeAlbumPtr m_album; - TimecodeGenrePtr m_genre; - TimecodeComposerPtr m_composer; - TimecodeYearPtr m_year; - - QString m_name; - QString m_type; - qint64 m_start; - qint64 m_end; - qint64 m_length; - qreal m_bpm; - int m_trackNumber; - int m_discNumber; - QString m_comment; - QString m_displayUrl; - QString m_playableUrl; - - int m_updatedFields; - QMap m_fields; - - enum - { - ALBUM_UPDATED = 1 << 0, - ARTIST_UPDATED = 1 << 1, - COMPOSER_UPDATED = 1 << 2, - GENRE_UPDATED = 1 << 3, - YEAR_UPDATED = 1 << 4, - TITLE_UPDATED = 1 << 5, - COMMENT_UPDATED = 1 << 6, - TRACKNUMBER_UPDATED = 1 << 7, - DISCNUMBER_UPDATED = 1 << 8, - BPM_UPDATED = 1 << 9 - }; -}; - -class TimecodeArtist : public Meta::Artist -{ -public: - TimecodeArtist( const QString &name ); - virtual ~TimecodeArtist(); - - virtual QString name() const; - - virtual TrackList tracks(); - - virtual AlbumList albums(); - - bool operator==( const Meta::Artist &other ) const - { - return name() == other.name(); - } - - //TimecodeArtist specific methods - void addTrack( TimecodeTrackPtr track ); - -private: - QString m_name; - TrackList m_tracks; -}; - -class TimecodeAlbum : public QObject, public Meta::Album -{ -Q_OBJECT -public: - TimecodeAlbum( const QString &name ); - virtual ~TimecodeAlbum(); - - virtual QString name() const; - - virtual bool isCompilation() const; - virtual bool hasAlbumArtist() const; - virtual ArtistPtr albumArtist() const; - virtual TrackList tracks(); - - virtual QImage image( int size = 0 ) const; - virtual bool canUpdateImage() const; - virtual void setImage( const QImage &image ); - - virtual bool hasCapabilityInterface( Capabilities::Capability::Type type ) const; - virtual Capabilities::Capability* createCapabilityInterface( Capabilities::Capability::Type type ); - - //TimecodeAlbum specific methods - void addTrack( TimecodeTrackPtr track ); - void setAlbumArtist( TimecodeArtistPtr artist ); - - bool operator==( const Meta::Album &other ) const - { - return name() == other.name(); - } - -private: - QString m_name; - TrackList m_tracks; - bool m_isCompilation; - TimecodeArtistPtr m_albumArtist; - - QImage m_cover; -}; - -class TimecodeGenre : public Meta::Genre -{ -public: - TimecodeGenre( const QString &name ); - virtual ~TimecodeGenre(); - - virtual QString name() const; - - virtual TrackList tracks(); - - bool operator==( const Meta::Genre &other ) const - { - return name() == other.name(); - } - - //TimecodeGenre specific methods - void addTrack( TimecodeTrackPtr track ); - -private: - QString m_name; - TrackList m_tracks; -}; - -class TimecodeComposer : public Meta::Composer -{ -public: - TimecodeComposer( const QString &name ); - virtual ~TimecodeComposer(); - - virtual QString name() const; - - virtual TrackList tracks(); - - bool operator==( const Meta::Composer &other ) const - { - return name() == other.name(); - } - - //TimecodeComposer specific methods - void addTrack( TimecodeTrackPtr track ); - -private: - QString m_name; - TrackList m_tracks; -}; - -class TimecodeYear : public Meta::Year -{ -public: - TimecodeYear( const QString &name ); - virtual ~TimecodeYear(); - - virtual QString name() const; - - virtual TrackList tracks(); - - bool operator==( const Meta::Year &other ) const - { - return name() == other.name(); - } - - //TimecodeYear specific methods - void addTrack( TimecodeTrackPtr track ); - -private: - QString m_name; - TrackList m_tracks; -}; - -} -#endif diff --git a/amarok/src/core-impl/meta/timecode/TimecodeObserver.cpp b/amarok/src/core-impl/meta/timecode/TimecodeObserver.cpp deleted file mode 100644 index c6f9323d..00000000 --- a/amarok/src/core-impl/meta/timecode/TimecodeObserver.cpp +++ /dev/null @@ -1,95 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Casey Link * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "TimecodeObserver.h" - -#include "core/meta/Meta.h" -#include "core/support/Debug.h" -#include "core-impl/collections/support/CollectionManager.h" -#include "core-impl/capabilities/timecode/TimecodeWriteCapability.h" - -const qint64 TimecodeObserver::m_threshold = 600 * 1000; // 6000000ms = 10 minutes - -TimecodeObserver::TimecodeObserver( QObject *parent ) - : QObject( parent ) - , m_trackTimecodeable ( false ) - , m_currentTrack ( 0 ) - , m_currPos ( 0 ) -{ - EngineController *engine = The::engineController(); - - connect( engine, SIGNAL(stopped(qint64,qint64)), - this, SLOT(stopped(qint64,qint64)) ); - connect( engine, SIGNAL(trackPlaying(Meta::TrackPtr)), - this, SLOT(trackPlaying(Meta::TrackPtr)) ); - connect( engine, SIGNAL(trackPositionChanged(qint64,bool)), - this, SLOT(trackPositionChanged(qint64,bool)) ); -} - -TimecodeObserver::~TimecodeObserver() -{} - -void -TimecodeObserver::stopped( qint64 finalPosition, qint64 trackLength ) -{ - DEBUG_BLOCK - - if( m_trackTimecodeable && finalPosition != trackLength && trackLength > m_threshold && finalPosition > 60 * 1000 ) - { - Meta::TrackPtr currentTrack = The::engineController()->currentTrack(); - if( currentTrack ) - { - Capabilities::TimecodeWriteCapability *tcw = currentTrack->create(); - if( tcw ) - { - tcw->writeAutoTimecode ( finalPosition ); // save the timecode - delete tcw; - } - } - } -} - -void -TimecodeObserver::trackPlaying( Meta::TrackPtr track ) -{ - if( track == m_currentTrack ) // no change, so do nothing - return; - - if( m_currentTrack ) // this is really the track _just_ played - { - if( m_trackTimecodeable && m_currPos != m_currentTrack->length() && m_currentTrack->length() > m_threshold && m_currPos > 60 * 1000 ) - { - QScopedPointer tcw( m_currentTrack->create() ); - if( tcw ) - tcw->writeAutoTimecode ( m_currPos ); // save the timecode - } - } - - // now update to the new track - if( track && track->has() ) - m_trackTimecodeable = true; - - m_currentTrack = track; - m_currPos = 0; -} - -void TimecodeObserver::trackPositionChanged( qint64 position, bool userSeek ) -{ - Q_UNUSED ( userSeek ) - - m_currPos = position; -} - diff --git a/amarok/src/core-impl/meta/timecode/TimecodeObserver.h b/amarok/src/core-impl/meta/timecode/TimecodeObserver.h deleted file mode 100644 index 4e63603c..00000000 --- a/amarok/src/core-impl/meta/timecode/TimecodeObserver.h +++ /dev/null @@ -1,49 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Casey Link * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef TIMECODEOBSERVER_H -#define TIMECODEOBSERVER_H - -#include -#include "EngineController.h" - -/** - * This class handles auto timecoding (position bookmarking) of tracks. - * After the current track's position has crossed an arbitrary threshold - * when the user stops playing the track (before the ending) a timecode - * will be created. - */ -class TimecodeObserver : public QObject -{ - Q_OBJECT - -public: - TimecodeObserver( QObject *parent = 0 ); - virtual ~TimecodeObserver(); - -protected slots: - void stopped( qint64 finalPosition, qint64 trackLength ); - void trackPlaying( Meta::TrackPtr track ); - void trackPositionChanged( qint64 position, bool userSeek ); - -private: - bool m_trackTimecodeable; //!< stores if current track has the writetimecode capability - static const qint64 m_threshold; //!< the arbitrary minum tracklength threshold in milliseconds - Meta::TrackPtr m_currentTrack; //!< The current/just played track - qint64 m_currPos; //!< the position the current track is at -}; - -#endif // TIMECODEOBSERVER_H diff --git a/amarok/src/core-impl/meta/timecode/TimecodeTrackProvider.cpp b/amarok/src/core-impl/meta/timecode/TimecodeTrackProvider.cpp deleted file mode 100644 index 12b6b605..00000000 --- a/amarok/src/core-impl/meta/timecode/TimecodeTrackProvider.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "TimecodeTrackProvider.h" - -#include "TimecodeMeta.h" - -#include "QRegExp" - -TimecodeTrackProvider::TimecodeTrackProvider() -{ -} - - -TimecodeTrackProvider::~TimecodeTrackProvider() -{ -} - -bool TimecodeTrackProvider::possiblyContainsTrack( const KUrl & url ) const -{ - return url.url().contains( QRegExp(":\\d+-\\d+$") ); -} - -Meta::TrackPtr TimecodeTrackProvider::trackForUrl( const KUrl & url ) -{ - QString urlString = url.url(); - - QRegExp rx; - rx.setPattern( "^(.+):(\\d+)-(\\d+)$" ); - if( rx.indexIn( urlString ) != -1 ) - { - QString baseUrl = rx.cap(1); - int start = rx.cap(2).toInt(); - int end = rx.cap(3).toInt(); - - Meta::TimecodeTrack * track = new Meta::TimecodeTrack( "TimecodeTrack", baseUrl, start, end ); - return Meta::TrackPtr( track ); - } - return Meta::TrackPtr(); -} - - diff --git a/amarok/src/core-impl/meta/timecode/TimecodeTrackProvider.h b/amarok/src/core-impl/meta/timecode/TimecodeTrackProvider.h deleted file mode 100644 index ce0701ec..00000000 --- a/amarok/src/core-impl/meta/timecode/TimecodeTrackProvider.h +++ /dev/null @@ -1,38 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef TIMECODETRACKPROVIDER_H -#define TIMECODETRACKPROVIDER_H - -#include "core/collections/Collection.h" - -/** -A track provider that recognizes timecode track urls - - @author Nikolaj Hald Nielsen -*/ -class TimecodeTrackProvider : public Collections::TrackProvider{ -public: - TimecodeTrackProvider(); - - ~TimecodeTrackProvider(); - - virtual bool possiblyContainsTrack( const KUrl &url ) const; - virtual Meta::TrackPtr trackForUrl( const KUrl &url ); - -}; - -#endif diff --git a/amarok/src/core-impl/playlists/providers/user/UserPlaylistProvider.cpp b/amarok/src/core-impl/playlists/providers/user/UserPlaylistProvider.cpp deleted file mode 100644 index abcd1d49..00000000 --- a/amarok/src/core-impl/playlists/providers/user/UserPlaylistProvider.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Alejandro Wainzinger * - * Copyright (c) 2012 Ralf Engels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "UserPlaylistProvider.h" - -Playlists::UserPlaylistProvider::UserPlaylistProvider( QObject *parent ) - : PlaylistProvider( parent ) -{ -} - -int -Playlists::UserPlaylistProvider::category() const -{ - return Playlists::UserPlaylist; -} diff --git a/amarok/src/core-impl/playlists/providers/user/UserPlaylistProvider.h b/amarok/src/core-impl/playlists/providers/user/UserPlaylistProvider.h deleted file mode 100644 index b72ead57..00000000 --- a/amarok/src/core-impl/playlists/providers/user/UserPlaylistProvider.h +++ /dev/null @@ -1,45 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Nikolaj Hald Nielsen * - * Copyright (c) 2008 Bart Cerneels * - * Copyright (c) 2012 Ralf Engels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef USERPLAYLISTPROVIDER_H -#define USERPLAYLISTPROVIDER_H - -#include "amarok_export.h" -#include "core/playlists/PlaylistProvider.h" - -namespace Playlists { - /** - * @author Bart Cerneels - */ - class AMAROK_EXPORT UserPlaylistProvider : public PlaylistProvider - { - Q_OBJECT - - public: - explicit UserPlaylistProvider( QObject *parent = 0 ); - - /* PlaylistProvider functions */ - virtual int category() const; - - /* UserPlaylistProvider functions */ - virtual PlaylistPtr save( const Meta::TrackList &tracks, - const QString &name = QString() ) = 0; - }; -} //namespace Playlists - -#endif diff --git a/amarok/src/core-impl/playlists/types/file/PlaylistFile.cpp b/amarok/src/core-impl/playlists/types/file/PlaylistFile.cpp deleted file mode 100644 index fd9e287b..00000000 --- a/amarok/src/core-impl/playlists/types/file/PlaylistFile.cpp +++ /dev/null @@ -1,187 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2011 Bart Cerneels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "PlaylistFile.h" - -#include "core/support/Debug.h" -#include "core-impl/playlists/types/file/PlaylistFileLoaderJob.h" -#include "playlistmanager/file/PlaylistFileProvider.h" -#include "playlistmanager/PlaylistManager.h" - -#include -#include - -#include - -using namespace Playlists; - -PlaylistFile::PlaylistFile( const KUrl &url, PlaylistProvider *provider ) - : Playlist() - , m_provider( provider ) - , m_url( url ) - , m_tracksLoaded( false ) - , m_name( m_url.fileName() ) - , m_relativePaths( false ) - , m_loadingDone( 0 ) -{ -} - -void -PlaylistFile::saveLater() -{ - PlaylistFileProvider *fileProvider = qobject_cast( m_provider ); - if( !fileProvider ) - return; - - fileProvider->saveLater( PlaylistFilePtr( this ) ); -} - -void -PlaylistFile::triggerTrackLoad() -{ - if( m_tracksLoaded ) - { - notifyObserversTracksLoaded(); - return; - } - PlaylistFileLoaderJob *worker = new PlaylistFileLoaderJob( PlaylistFilePtr( this ) ); - ThreadWeaver::Weaver::instance()->enqueue( worker ); - if ( !isLoadingAsync() ) - m_loadingDone.acquire(); // after loading is finished worker will release semapore -} - -bool -PlaylistFile::isWritable() const -{ - if( m_url.isEmpty() ) - return false; - - return QFileInfo( m_url.path() ).isWritable(); -} - -int -PlaylistFile::trackCount() const -{ - if( m_tracksLoaded ) - return m_tracks.count(); - else - return -1; -} - -void -PlaylistFile::addTrack( Meta::TrackPtr track, int position ) -{ - if( !track ) // playlists might contain invalid tracks. see BUG: 303056 - return; - - int trackPos = position < 0 ? m_tracks.count() : position; - if( trackPos > m_tracks.count() ) - trackPos = m_tracks.count(); - m_tracks.insert( trackPos, track ); - // set in case no track was in the playlist before - m_tracksLoaded = true; - - notifyObserversTrackAdded( track, trackPos ); - - if( !m_url.isEmpty() ) - saveLater(); -} - -void -PlaylistFile::removeTrack( int position ) -{ - if( position < 0 || position >= m_tracks.count() ) - return; - - m_tracks.removeAt( position ); - - notifyObserversTrackRemoved( position ); - - if( !m_url.isEmpty() ) - saveLater(); -} - -bool -PlaylistFile::save( bool relative ) -{ - m_relativePaths = relative; - QMutexLocker locker( &m_saveLock ); - - //if the location is a directory append the name of this playlist. - if( m_url.fileName( KUrl::ObeyTrailingSlash ).isNull() ) - m_url.setFileName( name() ); - - QFile file( m_url.path() ); - - if( !file.open( QIODevice::WriteOnly ) ) - { - warning() << QString( "Cannot write playlist (%1)." ).arg( file.fileName() ) - << file.errorString(); - return false; - } - - savePlaylist( file ); - file.close(); - return true; -} - -void -PlaylistFile::setName( const QString &name ) -{ - //can't save to a new file if we don't know where. - if( !m_url.isEmpty() && !name.isEmpty() ) - { - QString exten = QString( ".%1" ).arg(extension()); - m_url.setFileName( name + ( name.endsWith( exten, Qt::CaseInsensitive ) ? "" : exten ) ); - } -} - -void -PlaylistFile::addProxyTrack( const Meta::TrackPtr &proxyTrack ) -{ - m_tracks << proxyTrack; - notifyObserversTrackAdded( m_tracks.last(), m_tracks.size() - 1 ); -} - -KUrl -PlaylistFile::getAbsolutePath( const KUrl &url ) -{ - KUrl absUrl = url; - if( url.isRelative() ) - { - m_relativePaths = true; - // example: url = KUrl("../tunes/tune.ogg") - const QString relativePath = url.path(); // "../tunes/tune.ogg" - absUrl = m_url.directory(); // file:///playlists/ - absUrl.addPath( relativePath ); // file:///playlists/../tunes/tune.ogg - absUrl.cleanPath(); // file:///playlists/tunes/tune.ogg - } - return absUrl; -} - -QString -PlaylistFile::trackLocation( const Meta::TrackPtr &track ) const -{ - KUrl path = track->playableUrl(); - if( path.isEmpty() ) - return track->uidUrl(); - - if( !m_relativePaths || m_url.isEmpty() || !path.isLocalFile() || !m_url.isLocalFile() ) - return path.toEncoded(); - - QDir playlistDir( m_url.directory() ); - return QUrl::toPercentEncoding( playlistDir.relativeFilePath( path.path() ), "/" ); -} diff --git a/amarok/src/core-impl/playlists/types/file/PlaylistFile.h b/amarok/src/core-impl/playlists/types/file/PlaylistFile.h deleted file mode 100644 index cbc790ec..00000000 --- a/amarok/src/core-impl/playlists/types/file/PlaylistFile.h +++ /dev/null @@ -1,155 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009-2011 Bart Cerneels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef METAPLAYLISTFILE_H -#define METAPLAYLISTFILE_H - -#include "amarok_export.h" -#include "core/playlists/Playlist.h" -#include "core/meta/forward_declarations.h" -#include "core-impl/meta/proxy/MetaProxy.h" - -#include -#include - -class QFile; - -namespace Playlists -{ - class PlaylistProvider; - class PlaylistFile; - class PlaylistFileLoaderJob; - - typedef KSharedPtr PlaylistFilePtr; - typedef QList PlaylistFileList; - - /** - * Base class for all playlist files - **/ - class AMAROK_EXPORT PlaylistFile : public Playlist - { - friend class PlaylistFileLoaderJob; - - public: - /* Playlist methods */ - virtual KUrl uidUrl() const { return m_url; } - virtual QString name() const { return m_url.fileName(); } - virtual Meta::TrackList tracks() { return m_tracks; } - virtual int trackCount() const; - virtual void addTrack( Meta::TrackPtr track, int position ); - virtual void removeTrack( int position ); - virtual void triggerTrackLoad(); - - /** - * Overrides filename - */ - virtual void setName( const QString &name ); - virtual PlaylistProvider *provider() const { return m_provider; } - - /* PlaylistFile methods */ - virtual QList queue() { return QList(); } - virtual void setQueue( const QList &rows ) { Q_UNUSED( rows ); } - - /** - * Returns file extension which is corresponding to the playlist type - */ - virtual QString extension() const = 0; - - /** - * Returns mime type of this playlist file - */ - virtual QString mimetype() const = 0; - virtual bool isWritable() const; - - /** - * Saves the playlist to underlying file immediatelly. - * - * @param relative whether to use relative paths to track in the file - */ - bool save( bool relative ); - - /** - * Adds tracks to internal store. - * - * @note in order to save tracks to file, save method should be called - **/ - virtual void addTracks( const Meta::TrackList &tracks ) { m_tracks += tracks; } - virtual void setGroups( const QStringList &groups ) { m_groups = groups; } - virtual QStringList groups() { return m_groups; } - - protected: - PlaylistFile( const KUrl &url, PlaylistProvider *provider ); - - /** - * Schedule this playlist file to be saved on the next iteration of the - * mainloop. Useful in addTrack() and removeTrack() functions. - */ - void saveLater(); - - /** - * Actual file-specific implementation of playlist saving. - */ - virtual void savePlaylist( QFile &file ) = 0; - - /** - * Appends MetaProxy::Track* to m_tracks and invokes notifyObserversTrackAdded() - */ - void addProxyTrack( const Meta::TrackPtr &proxyTrack ); - - /** - * Loads playlist from the stream. - * @returns true if the loading was successful. - */ - virtual bool load( QTextStream &stream ) = 0; - - /** - * Loads playlist from QByteArray in order to postpone encoding detection procedure - * @returns true if the loading was successful. - */ - virtual bool load( QByteArray &content ) { QTextStream stream( &content ); return load( stream ); } - - /** Normalizes track location */ - QString trackLocation( const Meta::TrackPtr &track ) const; - - /** - * If the passed url is relative, this method convert given url to absolute. - * For example, "tunes/tune.ogg" gets converted to "file:///playlists/tunes/tune.ogg" - * Sets m_relative to true if it ecounters a relative url - * (this serves to preserve playlist "relativity" across reads & saves) - **/ - KUrl getAbsolutePath( const KUrl &url ); - - PlaylistProvider *m_provider; - QStringList m_groups; - - KUrl m_url; - - mutable bool m_tracksLoaded; - mutable Meta::TrackList m_tracks; - QString m_name; - /** true if tracks path are relative */ - bool m_relativePaths; - - QMutex m_saveLock; - /** allows to wait for end of loading */ - QSemaphore m_loadingDone; - }; -} - -Q_DECLARE_METATYPE( Playlists::PlaylistFilePtr ) -Q_DECLARE_METATYPE( Playlists::PlaylistFileList ) - -#endif diff --git a/amarok/src/core-impl/playlists/types/file/PlaylistFileLoaderJob.cpp b/amarok/src/core-impl/playlists/types/file/PlaylistFileLoaderJob.cpp deleted file mode 100644 index 75f4d01b..00000000 --- a/amarok/src/core-impl/playlists/types/file/PlaylistFileLoaderJob.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2013 Tatjana Gornak * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ -#include "core-impl/playlists/types/file/PlaylistFileLoaderJob.h" - -#include "core/meta/Meta.h" -#include "core/playlists/PlaylistFormat.h" -#include "core/interfaces/Logger.h" -#include "core/support/Amarok.h" -#include "core/support/Components.h" -#include "core/support/Debug.h" -#include "core/support/SemaphoreReleaser.h" - -#include -#include -#include -#include - -#include -#include -#include -#include - -using namespace Playlists; - -PlaylistFileLoaderJob::PlaylistFileLoaderJob( const PlaylistFilePtr &playlist ) - : m_playlist( playlist ) -{ - connect( this, SIGNAL(done(ThreadWeaver::Job*)), this, SLOT(slotDone()) ); - - // we must handle remove downloading here as KIO is coupled with GUI as is not - // designed to work from another thread - const KUrl url = playlist->uidUrl(); - if( url.isLocalFile() ) - { - m_actualPlaylistFile = url.toLocalFile(); - m_downloadSemaphore.release(); // pretend file "already downloaded" - } - else - { - m_tempFile.setSuffix( '.' + Amarok::extension( url.url() ) ); - if( !m_tempFile.open() ) - { - Amarok::Components::logger()->longMessage( - i18n( "Could not create a temporary file to download playlist." ) ); - m_downloadSemaphore.release(); // prevent deadlock - return; - } - - KIO::FileCopyJob *job = KIO::file_copy( url , m_tempFile.fileName(), 0774, - KIO::Overwrite | KIO::HideProgressInfo ); - Amarok::Components::logger()->newProgressOperation( job, - i18n("Downloading remote playlist" ) ); - if( playlist->isLoadingAsync() ) - // job is started automatically by KIO - connect( job, SIGNAL(finished(KJob*)), SLOT(slotDonwloadFinished(KJob*)) ); - else - { - job->exec(); - slotDonwloadFinished( job ); - } - } -} - -void -PlaylistFileLoaderJob::run() -{ - SemaphoreReleaser releaser( m_playlist->isLoadingAsync() ? 0 : &m_playlist->m_loadingDone ); - m_downloadSemaphore.acquire(); // wait for possible download to finish - if( m_actualPlaylistFile.isEmpty() ) - return; // previous error, already reported - - QFile file( m_actualPlaylistFile ); - if( !file.open( QIODevice::ReadOnly | QIODevice::Text ) ) - { - using namespace Amarok; - Components::logger()->longMessage( i18nc( "%1 is file path", - "Cannot read playlist from %1", m_actualPlaylistFile ), Logger::Error ); - return; - } - - QByteArray content = file.readAll(); - file.close(); - - m_playlist->load( content ); -} - -void -PlaylistFileLoaderJob::slotDonwloadFinished( KJob *job ) -{ - if( job->error() ) - { - using namespace Amarok; - warning() << job->errorString(); - } - else - m_actualPlaylistFile = m_tempFile.fileName(); - m_downloadSemaphore.release(); -} - -void -PlaylistFileLoaderJob::slotDone() -{ - m_playlist->notifyObserversTracksLoaded(); - deleteLater(); -} diff --git a/amarok/src/core-impl/playlists/types/file/PlaylistFileLoaderJob.h b/amarok/src/core-impl/playlists/types/file/PlaylistFileLoaderJob.h deleted file mode 100644 index fe0b5395..00000000 --- a/amarok/src/core-impl/playlists/types/file/PlaylistFileLoaderJob.h +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2013 Tatjana Gornak * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_PLAYLISTFILELOADERJOB_H -#define AMAROK_PLAYLISTFILELOADERJOB_H - -#include "core-impl/playlists/types/file/PlaylistFile.h" - -#include -#include - -class KJob; - -namespace Playlists -{ - /** - * Allows threading during playlist file loading. Auto-deletes when its work is done. - */ - class PlaylistFileLoaderJob : public ThreadWeaver::Job - { - Q_OBJECT - - public: - PlaylistFileLoaderJob( const PlaylistFilePtr &playlist ); - - protected: - void run(); - - private slots: - void slotDonwloadFinished( KJob *job ); - - /** - * Responsible for notification of finished loading - */ - void slotDone(); - - private: - PlaylistFilePtr m_playlist; - KTemporaryFile m_tempFile; - QString m_actualPlaylistFile; // path to local playlist file to actually load - QSemaphore m_downloadSemaphore; - }; -} - -#endif diff --git a/amarok/src/core-impl/playlists/types/file/PlaylistFileSupport.cpp b/amarok/src/core-impl/playlists/types/file/PlaylistFileSupport.cpp deleted file mode 100644 index 522f4daf..00000000 --- a/amarok/src/core-impl/playlists/types/file/PlaylistFileSupport.cpp +++ /dev/null @@ -1,158 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Ian Monroe * - * * - * This program 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 2 of the License, or (at your option) version 3 or * - * any later version accepted by the membership of KDE e.V. (or its successor approved * - * by the membership of KDE e.V.), which shall act as a proxy defined in Section 14 of * - * version 3 of the license. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "core/playlists/PlaylistFormat.h" -#include "core/interfaces/Logger.h" -#include "core/support/Components.h" -#include "core/support/Amarok.h" -#include "core-impl/playlists/types/file/PlaylistFileSupport.h" -#include "core/support/Debug.h" -#include "core-impl/playlists/types/file/asx/ASXPlaylist.h" -#include "core-impl/playlists/types/file/xspf/XSPFPlaylist.h" -#include "core-impl/playlists/types/file/pls/PLSPlaylist.h" -#include "core-impl/playlists/types/file/m3u/M3UPlaylist.h" -#include "playlistmanager/file/PlaylistFileProvider.h" - -#include "amarokconfig.h" - - -#include -#include -#include -#include - -#include -#include - -using namespace Playlists; - -PlaylistFilePtr -Playlists::loadPlaylistFile( const KUrl &url, PlaylistFileProvider *provider ) -{ - // note: this function can be called from out of process, so don't do any - // UI stuff from this thread. - if( !url.isValid() ) - { - error() << "url is not valid!"; - return PlaylistFilePtr(); - } - - if( url.isLocalFile() ) - { - if( !QFileInfo( url.toLocalFile() ).exists() ) - { - error() << QString("Could not load local playlist file %1!").arg( url.toLocalFile() ); - return PlaylistFilePtr(); - } - } - - PlaylistFormat format = Playlists::getFormat( url ); - PlaylistFilePtr playlist; - switch( format ) - { - case ASX: - playlist = new ASXPlaylist( url, provider ); - break; - case PLS: - playlist = new PLSPlaylist( url, provider ); - break; - case M3U: - playlist = new M3UPlaylist( url, provider ); - break; - case XSPF: - playlist = new XSPFPlaylist( url, provider ); - break; - default: - debug() << "Could not load playlist file " << url; - break; - } - - return playlist; -} - -bool -Playlists::exportPlaylistFile( const Meta::TrackList &list, const KUrl &path, bool relative, - const QList &queued ) -{ - PlaylistFormat format = Playlists::getFormat( path ); - bool result = false; - PlaylistFilePtr playlist; - - switch( format ) - { - case ASX: - playlist = new ASXPlaylist( path.toLocalFile() ); - break; - case PLS: - playlist = new PLSPlaylist( path.toLocalFile() ); - break; - case M3U: - playlist = new M3UPlaylist( path.toLocalFile() ); - break; - case XSPF: - playlist = new XSPFPlaylist( path.toLocalFile() ); - break; - default: - debug() << "Could not export playlist file " << path; - break; - } - - if( playlist ) - { - playlist->addTracks( list ); - playlist->setQueue( queued ); - result = playlist->save( relative ); - } - else - { - KMessageBox::error( 0, - i18n( "The used file extension is not valid for playlists." ), - i18n( "Unknown playlist format" ) ); - } - - return result; -} - -bool -Playlists::canExpand( Meta::TrackPtr track ) -{ - if( !track ) - return false; - - return Playlists::getFormat( track->uidUrl() ) != Playlists::NotPlaylist; -} - -PlaylistPtr -Playlists::expand( Meta::TrackPtr track ) -{ - return Playlists::PlaylistPtr::dynamicCast( loadPlaylistFile( track->uidUrl() ) ); -} - -KUrl -Playlists::newPlaylistFilePath( const QString &fileExtension ) -{ - int trailingNumber = 1; - KLocalizedString fileName = ki18n("Playlist_%1"); - KUrl url( Amarok::saveLocation( "playlists" ) ); - url.addPath( fileName.subs( trailingNumber ).toString() ); - - while( QFileInfo( url.path() ).exists() ) - url.setFileName( fileName.subs( ++trailingNumber ).toString() ); - - return KUrl( QString( "%1.%2" ).arg( url.path() ).arg( fileExtension ) ); -} diff --git a/amarok/src/core-impl/playlists/types/file/PlaylistFileSupport.h b/amarok/src/core-impl/playlists/types/file/PlaylistFileSupport.h deleted file mode 100644 index 8335a240..00000000 --- a/amarok/src/core-impl/playlists/types/file/PlaylistFileSupport.h +++ /dev/null @@ -1,44 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Ian Monroe * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_META_PLAYLISTFILESUPPORT_H -#define AMAROK_META_PLAYLISTFILESUPPORT_H - -#include "amarok_export.h" -#include "core/meta/forward_declarations.h" -#include "core-impl/playlists/types/file/PlaylistFile.h" - -namespace Playlists -{ - class PlaylistFileProvider; - - AMAROK_EXPORT PlaylistFilePtr loadPlaylistFile( const KUrl &url, PlaylistFileProvider *provider = 0 ); - - bool exportPlaylistFile( const Meta::TrackList &list, const KUrl &path, bool relative = false, - const QList &queued = QList() ); - - /* HACK: - * the next two functions are needed to support some services that have no other way - * of presenting data to the user than wrapping the url to a playlist in a track. - */ - bool canExpand( Meta::TrackPtr track ); - PlaylistPtr expand( Meta::TrackPtr track ); - - AMAROK_EXPORT KUrl newPlaylistFilePath( const QString &fileExtension ); - -} - -#endif diff --git a/amarok/src/core-impl/playlists/types/file/asx/ASXPlaylist.cpp b/amarok/src/core-impl/playlists/types/file/asx/ASXPlaylist.cpp deleted file mode 100644 index 1d1b3ce5..00000000 --- a/amarok/src/core-impl/playlists/types/file/asx/ASXPlaylist.cpp +++ /dev/null @@ -1,192 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2013 Tatjana Gornak * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "ASXPlaylist.h" - -#include "core/capabilities/StreamInfoCapability.h" -#include "core/support/Debug.h" -#include "core-impl/meta/proxy/MetaProxy.h" -#include "core-impl/playlists/types/file/xspf/XSPFPlaylist.h" - -#include - -#include -#include - -using namespace Playlists; - -ASXPlaylist::ASXPlaylist( const KUrl &url, PlaylistProvider *provider ) - : PlaylistFile( url, provider ) - , QDomDocument() -{ -} - -void -ASXPlaylist::savePlaylist( QFile &file ) -{ - QTextStream stream( &file ); - stream.setCodec( "UTF-8" ); - writeTrackList(); - QDomDocument::save( stream, 2 /*indent*/, QDomNode::EncodingFromTextStream ); -} - -bool -ASXPlaylist::processContent( QTextStream &stream ) -{ - QString errorMsg; - int errorLine, errorColumn; - - QString data = stream.readAll(); - - // ASX looks a lot like xml, but doesn't require tags to be case sensitive, - // meaning we have to accept things like: ... - // We use a dirty way to achieve this: we make all tags lower case - QRegExp tagPattern( "(<[/]?[^>]*[A-Z]+[^>]*>)", Qt::CaseInsensitive ); - QRegExp urlPattern( "(href\\s*=\\s*\")([^\"]+)\"", Qt::CaseInsensitive ); - - int index = 0; - while ( ( index = tagPattern.indexIn( data, index ) ) != -1 ) - { - QString original = tagPattern.cap( 1 ).toLocal8Bit(); - QString tagReplacement = tagPattern.cap( 1 ).toLower().toLocal8Bit(); - if ( urlPattern.indexIn( original, 0 ) != -1 ) - { - // Some playlists have unescaped & characters in URLs - QString url = urlPattern.cap( 2 ); - url.replace( QRegExp( "&(?!amp;|quot;|apos;|lt;|gt;)" ), "&" ); - - QString urlReplacement = urlPattern.cap( 1 ) % url % "\""; - tagReplacement.replace( urlPattern.cap(0).toLocal8Bit().toLower(), - urlReplacement.toLocal8Bit() ); - } - data.replace( original, tagReplacement ); - index += tagPattern.matchedLength(); - } - if( !setContent( data, &errorMsg, &errorLine, &errorColumn ) ) - { - error() << "Error loading xml file: " "(" << errorMsg << ")" - << " at line " << errorLine << ", column " << errorColumn; - m_tracksLoaded = false; - } - else - m_tracksLoaded = true; - - return m_tracksLoaded; -} - -bool -ASXPlaylist::loadAsx( QTextStream &stream ) -{ - if ( !processContent( stream ) ) - return false; - - QDomNode asx = documentElement(); - QDomNode subNode = asx.firstChild(); - QDomNode subSubNode; - while( !subNode.isNull() ) - { - XSPFTrack track; - subSubNode = subNode.firstChild(); - if( subNode.nodeName() == "entry" ) - { - while( !subSubNode.isNull() ) - { - if( subSubNode.nodeName() == "ref" ) - { - QByteArray path = subSubNode.attributes().namedItem("href").nodeValue().toUtf8(); - path.replace( '\\', '/' ); - - KUrl url = getAbsolutePath( KUrl::fromEncoded( path ) ); - track.location = url; - } - else if( subSubNode.nodeName() == "title" ) - track.title = subSubNode.firstChild().nodeValue(); - else if( subSubNode.nodeName() == "author" ) - track.creator = subSubNode.firstChild().nodeValue(); - - subSubNode = subSubNode.nextSibling(); - } - } - MetaProxy::Track *proxyTrack = new MetaProxy::Track( track.location ); - proxyTrack->setTitle( track.title ); - proxyTrack->setArtist( track.creator ); - proxyTrack->setLength( track.duration ); - m_tracks << Meta::TrackPtr( proxyTrack ); - subNode = subNode.nextSibling(); - } - return true; -} - -void -ASXPlaylist::writeTrackList( ) -{ - Meta::TrackList trackList = tracks(); - - if ( documentElement().namedItem( "asx" ).isNull() ) - { - QDomElement root = createElement( "asx" ); - root.setAttribute( "version", 3.0 ); - appendChild( root ); - } - - foreach( Meta::TrackPtr track, trackList ) - { - QDomNode subNode = createElement( "entry" ); - - //URI of resource to be rendered. - QDomElement location = createElement( "ref" ); - - //Track title - QDomNode title = createElement( "title" ); - - //Human-readable name of the entity that authored the resource. - QDomNode creator = createElement( "author" ); - - //Description of a track - QDomNode abstact = createElement( "abstract" ); - - location.setAttribute( "href", trackLocation( track ) ); - subNode.appendChild( location ); - - #define APPENDNODE( X, Y ) \ - { \ - X.appendChild( createTextNode( Y ) ); \ - subNode.appendChild( X ); \ - } - - Capabilities::StreamInfoCapability *streamInfo = track->create(); - if( streamInfo ) // We have a stream, use it's metadata instead of the tracks. - { - if( !streamInfo->streamName().isEmpty() ) - APPENDNODE( title, streamInfo->streamName() ); - if( !streamInfo->streamSource().isEmpty() ) - APPENDNODE( creator, streamInfo->streamSource() ); - - delete streamInfo; - } - else - { - if( !track->name().isEmpty() ) - APPENDNODE( title, track->name() ); - if( track->artist() && !track->artist()->name().isEmpty() ) - APPENDNODE( creator, track->artist()->name() ); - } - if( !track->comment().isEmpty() ) - APPENDNODE(abstact, track->comment() ); - #undef APPENDNODE - documentElement().appendChild( subNode ); - } -} diff --git a/amarok/src/core-impl/playlists/types/file/asx/ASXPlaylist.h b/amarok/src/core-impl/playlists/types/file/asx/ASXPlaylist.h deleted file mode 100644 index 69e69bbe..00000000 --- a/amarok/src/core-impl/playlists/types/file/asx/ASXPlaylist.h +++ /dev/null @@ -1,47 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2013 Tatjana Gornak * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ -#ifndef ASXPLAYLIST_H -#define ASXPLAYLIST_H - -#include "core-impl/playlists/types/file/PlaylistFile.h" - -#include - -namespace Playlists { -/** - * TODO: Use QDomDocument locally just in saving and loading methods. - */ -class AMAROK_EXPORT ASXPlaylist : public PlaylistFile, public QDomDocument -{ - public: - ASXPlaylist( const KUrl &url, PlaylistProvider *provider = 0 ); - - virtual bool save( bool relative ) { return PlaylistFile::save( relative ); } - - using PlaylistFile::load; - virtual bool load( QTextStream &stream ) { return loadAsx( stream ); } - - virtual QString extension() const { return "asx"; } - virtual QString mimetype() const { return "video/x-ms-asf"; } - - protected: - bool loadAsx( QTextStream &stream ); - /** Writes tracks to file */ - void writeTrackList(); - virtual void savePlaylist( QFile &file ); - bool processContent( QTextStream &stream ); -}; -} -#endif diff --git a/amarok/src/core-impl/playlists/types/file/m3u/M3UPlaylist.cpp b/amarok/src/core-impl/playlists/types/file/m3u/M3UPlaylist.cpp deleted file mode 100644 index 28e3b000..00000000 --- a/amarok/src/core-impl/playlists/types/file/m3u/M3UPlaylist.cpp +++ /dev/null @@ -1,116 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Bart Cerneels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "M3UPlaylist.h" - -#include "core/support/Debug.h" - -#include - -using namespace Playlists; - -M3UPlaylist::M3UPlaylist( const KUrl &url, PlaylistProvider *provider ) - : PlaylistFile( url, provider ) -{ -} - -bool -M3UPlaylist::loadM3u( QTextStream &stream ) -{ - if( m_tracksLoaded ) - return true; - const QString directory = m_url.directory(); - m_tracksLoaded = true; - - int length = -1; - QString extinfTitle; - do - { - QString line = stream.readLine(); - if( line.startsWith( "#EXTINF" ) ) - { - const QString extinf = line.section( ':', 1 ); - bool ok; - length = extinf.section( ',', 0, 0 ).toInt( &ok ); - if( !ok ) - length = -1; - extinfTitle = extinf.section( ',', 1 ); - } - else if( !line.startsWith( '#' ) && !line.isEmpty() ) - { - line = line.replace( "\\", "/" ); - - KUrl url = getAbsolutePath( KUrl( line ) ); - - MetaProxy::TrackPtr proxyTrack( new MetaProxy::Track( url ) ); - QString artist = extinfTitle.section( " - ", 0, 0 ); - QString title = extinfTitle.section( " - ", 1, 1 ); - //if title and artist are saved such as in M3UPlaylist::save() - if( !title.isEmpty() && !artist.isEmpty() ) - { - proxyTrack->setTitle( title ); - proxyTrack->setArtist( artist ); - } - else - { - proxyTrack->setTitle( extinfTitle ); - } - proxyTrack->setLength( length ); - Meta::TrackPtr track( proxyTrack.data() ); - addProxyTrack( track ); - } - } while( !stream.atEnd() ); - - //TODO: return false if stream is not readable, empty or has errors - return true; -} - -void -M3UPlaylist::savePlaylist( QFile &file ) -{ - QTextStream stream( &file ); - - stream << "#EXTM3U\n"; - KUrl::List urls; - QStringList titles; - QList lengths; - - foreach( const Meta::TrackPtr &track, m_tracks ) - { - if( !track ) // see BUG: 303056 - continue; - - const KUrl &url = track->playableUrl(); - int length = track->length() / 1000; - const QString &title = track->name(); - const QString &artist = track->artist()->name(); - - if( !title.isEmpty() && !artist.isEmpty() && length ) - { - stream << "#EXTINF:"; - stream << QString::number( length ); - stream << ','; - stream << artist << " - " << title; - stream << '\n'; - } - - if( url.protocol() == "file" ) - stream << trackLocation( track ); - else - stream << url.url(); - stream << "\n"; - } -} diff --git a/amarok/src/core-impl/playlists/types/file/m3u/M3UPlaylist.h b/amarok/src/core-impl/playlists/types/file/m3u/M3UPlaylist.h deleted file mode 100644 index 08a434ec..00000000 --- a/amarok/src/core-impl/playlists/types/file/m3u/M3UPlaylist.h +++ /dev/null @@ -1,46 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Bart Cerneels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef METAM3UPLAYLIST_H -#define METAM3UPLAYLIST_H - -#include "core-impl/playlists/types/file/PlaylistFile.h" - -namespace Playlists { -/** - * @author Bart Cerneels - */ -class AMAROK_EXPORT M3UPlaylist : public PlaylistFile -{ - public: - M3UPlaylist( const KUrl &url, PlaylistProvider *provider = 0 ); - - /* PlaylistFile methods */ - using PlaylistFile::load; - virtual bool load( QTextStream &stream ) { return loadM3u( stream ); } - - virtual QString extension() const { return "m3u"; } - virtual QString mimetype() const { return "audio/x-mpegurl"; } - - protected: - virtual void savePlaylist( QFile &file ); - - private: - bool loadM3u( QTextStream &stream ); -}; -} - -#endif diff --git a/amarok/src/core-impl/playlists/types/file/pls/PLSPlaylist.cpp b/amarok/src/core-impl/playlists/types/file/pls/PLSPlaylist.cpp deleted file mode 100644 index a120ae2e..00000000 --- a/amarok/src/core-impl/playlists/types/file/pls/PLSPlaylist.cpp +++ /dev/null @@ -1,216 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Bart Cerneels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "PLSPlaylist.h" - -#include "core/support/Debug.h" - -#include - -using namespace Playlists; - -PLSPlaylist::PLSPlaylist( const KUrl &url, PlaylistProvider *provider ) - : PlaylistFile( url, provider ) -{ -} - -bool -PLSPlaylist::loadPls( QTextStream &textStream ) -{ - if( m_tracksLoaded ) - return true; - m_tracksLoaded = true; - - // Counted number of "File#=" lines. - unsigned int entryCnt = 0; - // Value of the "NumberOfEntries=#" line. - unsigned int numberOfEntries = 0; - // Does the file have a "[playlist]" section? (as it's required by the standard) - bool havePlaylistSection = false; - QString tmp; - QStringList lines; - - QRegExp regExp_NumberOfEntries("^NumberOfEntries\\s*=\\s*\\d+$"); - regExp_NumberOfEntries.setCaseSensitivity( Qt::CaseInsensitive ); // It seems many playlists use numberofentries - const QRegExp regExp_File("^File\\d+\\s*="); - const QRegExp regExp_Title("^Title\\d+\\s*="); - const QRegExp regExp_Length("^Length\\d+\\s*=\\s*-?\\d+$"); // Length Can be -1 - const QRegExp regExp_Version("^Version\\s*=\\s*\\d+$"); - const QString section_playlist("[playlist]"); - - - - /* Preprocess the input data. - * Read the lines into a buffer; Cleanup the line strings; - * Count the entries manually and read "NumberOfEntries". - */ - while( !textStream.atEnd() ) - { - tmp = textStream.readLine(); - tmp = tmp.trimmed(); - if( tmp.isEmpty() ) - continue; - lines.append( tmp ); - - if( tmp.contains( regExp_File ) ) - { - entryCnt++; - continue; - } - if( tmp == section_playlist ) - { - havePlaylistSection = true; - continue; - } - if( tmp.contains( regExp_NumberOfEntries ) ) - { - numberOfEntries = tmp.section( '=', -1 ).trimmed().toUInt(); - continue; - } - } - if( numberOfEntries != entryCnt ) - { - warning() << ".pls playlist: Invalid \"NumberOfEntries\" value. " - << "NumberOfEntries=" << numberOfEntries << " counted=" - << entryCnt << endl; - /* Corrupt file. The "NumberOfEntries" value is - * not correct. Fix it by setting it to the manually - * counted number and go on parsing. - */ - numberOfEntries = entryCnt; - } - if( numberOfEntries == 0 ) - { - return true; - } - - unsigned int index; - bool ok = false; - bool inPlaylistSection = false; - - MetaProxy::TrackPtr proxyTrack; - /* Now iterate through all beautified lines in the buffer - * and parse the playlist data. */ - QStringList::const_iterator i = lines.constBegin(), end = lines.constEnd(); - for( ; i != end; ++i ) - { - if( !inPlaylistSection && havePlaylistSection ) - { - /* The playlist begins with the "[playlist]" tag. - * Skip everything before this. - */ - if( (*i) == section_playlist ) - inPlaylistSection = true; - continue; - } - if( (*i).contains( regExp_File ) ) - { - // Have a "File#=XYZ" line. - index = loadPls_extractIndex( *i ); - if( index > numberOfEntries || index == 0 ) - continue; - tmp = (*i).section( '=', 1 ).trimmed(); - KUrl url = getAbsolutePath( KUrl( tmp ) ); - proxyTrack = new MetaProxy::Track( url ); - Meta::TrackPtr track( proxyTrack.data() ); - addProxyTrack( track ); - continue; - } - if( (*i).contains(regExp_Title) && proxyTrack ) - { - // Have a "Title#=XYZ" line. - index = loadPls_extractIndex(*i); - if( index > numberOfEntries || index == 0 ) - continue; - tmp = (*i).section( '=', 1 ).trimmed(); - proxyTrack->setTitle( tmp ); - continue; - } - if( (*i).contains( regExp_Length ) && proxyTrack ) - { - // Have a "Length#=XYZ" line. - index = loadPls_extractIndex(*i); - if( index > numberOfEntries || index == 0 ) - continue; - tmp = (*i).section( '=', 1 ).trimmed(); - bool ok = false; - int seconds = tmp.toInt( &ok ); - if( ok ) - proxyTrack->setLength( seconds * 1000 ); //length is in milliseconds - continue; - } - if( (*i).contains( regExp_NumberOfEntries ) ) - { - // Have the "NumberOfEntries=#" line. - continue; - } - if( (*i).contains( regExp_Version ) ) - { - // Have the "Version=#" line. - tmp = (*i).section( '=', 1 ).trimmed(); - // We only support Version=2 - if (tmp.toUInt( &ok ) != 2) - warning() << ".pls playlist: Unsupported version." << endl; - continue; - } - warning() << ".pls playlist: Unrecognized line: \"" << *i << "\"" << endl; - } - return true; -} - -unsigned int -PLSPlaylist::loadPls_extractIndex( const QString &str ) const -{ - /* Extract the index number out of a .pls line. - * Example: - * loadPls_extractIndex("File2=foobar") == 2 */ - bool ok = false; - unsigned int ret; - QString tmp( str.section( '=', 0, 0 ) ); - tmp.remove( QRegExp( "^\\D*" ) ); - ret = tmp.trimmed().toUInt( &ok ); - Q_ASSERT(ok); - return ret; -} - -void -PLSPlaylist::savePlaylist( QFile &file ) -{ - //Format: http://en.wikipedia.org/wiki/PLS_(file_format) - QTextStream stream( &file ); - //header - stream << "[Playlist]\n"; - - //body - int i = 1; //PLS starts at File1= - foreach( Meta::TrackPtr track, m_tracks ) - { - if( !track ) // see BUG: 303056 - continue; - - stream << "File" << i << "=" << trackLocation( track ); - stream << "\nTitle" << i << "="; - stream << track->name(); - stream << "\nLength" << i << "="; - stream << track->length() / 1000; - stream << "\n"; - i++; - } - - //footer - stream << "NumberOfEntries=" << m_tracks.count() << endl; - stream << "Version=2\n"; -} diff --git a/amarok/src/core-impl/playlists/types/file/pls/PLSPlaylist.h b/amarok/src/core-impl/playlists/types/file/pls/PLSPlaylist.h deleted file mode 100644 index 74d2fad3..00000000 --- a/amarok/src/core-impl/playlists/types/file/pls/PLSPlaylist.h +++ /dev/null @@ -1,47 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Bart Cerneels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef METAPLSPLAYLIST_H -#define METAPLSPLAYLIST_H - -#include "core-impl/playlists/types/file/PlaylistFile.h" - -namespace Playlists { -/** - * @author Bart Cerneels - */ -class AMAROK_EXPORT PLSPlaylist : public PlaylistFile -{ - public: - PLSPlaylist( const KUrl &url, PlaylistProvider *provider = 0 ); - - /* PlaylistFile methods */ - using PlaylistFile::load; - virtual bool load( QTextStream &stream ) { return loadPls( stream ); } - - virtual QString extension() const { return "pls"; } - virtual QString mimetype() const { return "audio/x-scpls"; } - - protected: - virtual void savePlaylist( QFile &file ); - - private: - bool loadPls( QTextStream &stream ); - unsigned int loadPls_extractIndex( const QString &str ) const; -}; -} - -#endif diff --git a/amarok/src/core-impl/playlists/types/file/xspf/XSPFPlaylist.cpp b/amarok/src/core-impl/playlists/types/file/xspf/XSPFPlaylist.cpp deleted file mode 100644 index 4bdb9b96..00000000 --- a/amarok/src/core-impl/playlists/types/file/xspf/XSPFPlaylist.cpp +++ /dev/null @@ -1,680 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2006 Mattias Fliesberg * - * Copyright (c) 2007 Ian Monroe * - * Copyright (c) 2007 Bart Cerneels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "XSPFPlaylist" - -#include "XSPFPlaylist.h" - -#include "core/capabilities/StreamInfoCapability.h" -#include "core/support/Debug.h" -#include "core-impl/collections/support/CollectionManager.h" -#include "core-impl/meta/stream/Stream.h" -#include "playlist/PlaylistController.h" -#include "playlist/PlaylistModelStack.h" - -using namespace Playlists; - -XSPFPlaylist::XSPFPlaylist( const KUrl &url, Playlists::PlaylistProvider *provider, OnLoadAction onLoad ) - : PlaylistFile( url, provider ) - , QDomDocument() - , m_autoAppendAfterLoad( onLoad == AppendToPlaylist ) -{ -} - -XSPFPlaylist::~XSPFPlaylist() -{ -} - -void -XSPFPlaylist::savePlaylist(QFile &file) -{ - // if trackList item exists than no need to setup new file - if ( documentElement().namedItem( "trackList" ).isNull() ) - { - QDomElement root = createElement( "playlist" ); - - root.setAttribute( "version", 1 ); - root.setAttribute( "xmlns", "http://xspf.org/ns/0/" ); - - root.appendChild( createElement( "trackList" ) ); - - appendChild( root ); - } - - setTrackList( tracks(), false ); - - QTextStream stream( &file ); - stream.setCodec( "UTF-8" ); - QDomDocument::save( stream, 2 /*indent*/, QDomNode::EncodingFromTextStream ); -} - -bool -XSPFPlaylist::processContent( QByteArray &content ) -{ - QString errorMsg; - int errorLine, errorColumn; - - if( !setContent( content, &errorMsg, &errorLine, &errorColumn ) ) - { - error() << "Error loading xml file: " "(" << errorMsg << ")" - << " at line " << errorLine << ", column " << errorColumn; - m_tracksLoaded = false; - } - else - m_tracksLoaded = true; - return m_tracksLoaded; -} - -void -XSPFPlaylist::load() -{ - XSPFTrackList xspfTracks = trackList(); - - foreach( const XSPFTrack &track, xspfTracks ) - { - MetaProxy::TrackPtr proxyTrack( new MetaProxy::Track( track.location ) ); - //Fill in values from xspf.. - proxyTrack->setTitle( track.title ); - proxyTrack->setAlbum( track.album ); - proxyTrack->setArtist( track.creator ); - proxyTrack->setLength( track.duration ); - proxyTrack->setTrackNumber( track.trackNum ); - Meta::TrackPtr metaTrack( proxyTrack.data() ); - addProxyTrack( metaTrack ); - } - - //FIXME: this needs to be moved to whatever is creating the XSPFPlaylist - if( m_autoAppendAfterLoad ) - The::playlistController()->insertPlaylist( - ::Playlist::ModelStack::instance()->bottom()->rowCount(), - Playlists::PlaylistPtr( this ) - ); -} - -bool -XSPFPlaylist::loadXSPF( QTextStream &stream ) -{ - QByteArray content = stream.readAll().toUtf8(); - if ( !processContent( content ) ) - return false; - load(); - - return true; -} - -bool -XSPFPlaylist::loadXSPF( QByteArray &content ) -{ - if ( !processContent( content ) ) - return false; - load(); - - return true; -} - -QString -XSPFPlaylist::name() const -{ - if ( m_tracksLoaded ) - return title(); - else - return m_url.fileName(); -} - -QString -XSPFPlaylist::title() const -{ - return documentElement().namedItem( "title" ).firstChild().nodeValue(); -} - -QString -XSPFPlaylist::creator() const -{ - return documentElement().namedItem( "creator" ).firstChild().nodeValue(); -} - -QString -XSPFPlaylist::annotation() const -{ - return documentElement().namedItem( "annotation" ).firstChild().nodeValue(); -} - -KUrl -XSPFPlaylist::info() const -{ - return KUrl( documentElement().namedItem( "info" ).firstChild().nodeValue() ); -} - -KUrl -XSPFPlaylist::location() const -{ - return KUrl( documentElement().namedItem( "location" ).firstChild().nodeValue() ); -} - -QString -XSPFPlaylist::identifier() const -{ - return documentElement().namedItem( "identifier" ).firstChild().nodeValue(); -} - -KUrl -XSPFPlaylist::image() const -{ - return KUrl( documentElement().namedItem( "image" ).firstChild().nodeValue() ); -} - -QDateTime -XSPFPlaylist::date() const -{ - return QDateTime::fromString( documentElement().namedItem( "date" ).firstChild().nodeValue(), Qt::ISODate ); -} - -KUrl -XSPFPlaylist::license() const -{ - return KUrl( documentElement().namedItem( "license" ).firstChild().nodeValue() ); -} - -KUrl::List -XSPFPlaylist::attribution() const -{ - const QDomNodeList nodes = documentElement().namedItem( "attribution" ).childNodes(); - KUrl::List list; - - for( int i = 0, count = nodes.length(); i < count; ++i ) - { - const QDomNode &node = nodes.at( i ); - if( !node.firstChild().nodeValue().isNull() ) - list.append( node.firstChild().nodeValue() ); - } - return list; -} - -KUrl -XSPFPlaylist::link() const -{ - return KUrl( documentElement().namedItem( "link" ).firstChild().nodeValue() ); -} - -void -XSPFPlaylist::setTitle( const QString &title ) -{ - QDomNode titleNode = documentElement().namedItem( "title" ); - if( titleNode.isNull() || !titleNode.hasChildNodes() ) - { - QDomNode node = createElement( "title" ); - QDomNode subNode = createTextNode( title ); - node.appendChild( subNode ); - documentElement().insertBefore( node, documentElement().namedItem( "trackList" ) ); - } - else - { - documentElement().namedItem( "title" ).replaceChild( createTextNode( title ), - documentElement().namedItem( "title" ).firstChild() - ); - } - notifyObserversMetadataChanged(); - //write changes to file directly if we know where. - if( !m_url.isEmpty() ) - PlaylistFile::save( false ); -} - -void -XSPFPlaylist::setCreator( const QString &creator ) -{ - if( documentElement().namedItem( "creator" ).isNull() ) - { - QDomNode node = createElement( "creator" ); - QDomNode subNode = createTextNode( creator ); - node.appendChild( subNode ); - documentElement().insertBefore( node, documentElement().namedItem( "trackList" ) ); - } - else - { - documentElement().namedItem( "creator" ).replaceChild( createTextNode( creator ), - documentElement().namedItem( "creator" ).firstChild() ); - } - - //write changes to file directly if we know where - if( !m_url.isEmpty() ) - PlaylistFile::save( false ); -} - -void -XSPFPlaylist::setAnnotation( const QString &annotation ) -{ - if( documentElement().namedItem( "annotation" ).isNull() ) - { - QDomNode node = createElement( "annotation" ); - QDomNode subNode = createTextNode( annotation ); - node.appendChild( subNode ); - documentElement().insertBefore( node, documentElement().namedItem( "trackList" ) ); - } - else - { - documentElement().namedItem( "annotation" ).replaceChild( createTextNode( annotation ), - documentElement().namedItem( "annotation" ).firstChild() ); - } - - //write changes to file directly if we know where. - if( !m_url.isEmpty() ) - PlaylistFile::save( false ); -} - -void -XSPFPlaylist::setInfo( const KUrl &info ) -{ - - if( documentElement().namedItem( "info" ).isNull() ) - { - QDomNode node = createElement( "info" ); - QDomNode subNode = createTextNode( info.url() ); - node.appendChild( subNode ); - documentElement().insertBefore( node, documentElement().namedItem( "trackList" ) ); - } - else - { - documentElement().namedItem( "info" ).replaceChild( createTextNode( info.url() ), - documentElement().namedItem( "info" ).firstChild() ); - } - - //write changes to file directly if we know where. - if( !m_url.isEmpty() ) - PlaylistFile::save( false ); -} - -void -XSPFPlaylist::setLocation( const KUrl &location ) -{ - if( documentElement().namedItem( "location" ).isNull() ) - { - QDomNode node = createElement( "location" ); - QDomNode subNode = createTextNode( location.url() ); - node.appendChild( subNode ); - documentElement().insertBefore( node, documentElement().namedItem( "trackList" ) ); - } - else - { - documentElement().namedItem( "location" ).replaceChild( createTextNode( location.url() ), - documentElement().namedItem( "location" ).firstChild() ); - } - - //write changes to file directly if we know where. - if( !m_url.isEmpty() ) - PlaylistFile::save( false ); -} - -void -XSPFPlaylist::setIdentifier( const QString &identifier ) -{ - if( documentElement().namedItem( "identifier" ).isNull() ) - { - QDomNode node = createElement( "identifier" ); - QDomNode subNode = createTextNode( identifier ); - node.appendChild( subNode ); - documentElement().insertBefore( node, documentElement().namedItem( "trackList" ) ); - } - else - { - documentElement().namedItem( "identifier" ).replaceChild( createTextNode( identifier ), - documentElement().namedItem( "identifier" ).firstChild() ); - } - - //write changes to file directly if we know where. - if( !m_url.isEmpty() ) - PlaylistFile::save( false ); -} - -void -XSPFPlaylist::setImage( const KUrl &image ) -{ - if( documentElement().namedItem( "image" ).isNull() ) - { - QDomNode node = createElement( "image" ); - QDomNode subNode = createTextNode( image.url() ); - node.appendChild( subNode ); - documentElement().insertBefore( node, documentElement().namedItem( "trackList" ) ); - } - else - { - documentElement().namedItem( "image" ).replaceChild( createTextNode( image.url() ), - documentElement().namedItem( "image" ).firstChild() ); - } - - //write changes to file directly if we know where. - if( !m_url.isEmpty() ) - PlaylistFile::save( false ); -} - -void -XSPFPlaylist::setDate( const QDateTime &date ) -{ - /* date needs timezone info to be compliant with the standard - (ex. 2005-01-08T17:10:47-05:00 ) */ - - if( documentElement().namedItem( "date" ).isNull() ) - { - QDomNode node = createElement( "date" ); - QDomNode subNode = createTextNode( date.toString( "yyyy-MM-ddThh:mm:ss" ) ); - node.appendChild( subNode ); - documentElement().insertBefore( node, documentElement().namedItem( "trackList" ) ); - } - else - { - documentElement().namedItem( "date" ) - .replaceChild( createTextNode( date.toString( "yyyy-MM-ddThh:mm:ss" ) ), - documentElement().namedItem( "date" ).firstChild() ); - } - - //write changes to file directly if we know where. - if( !m_url.isEmpty() ) - PlaylistFile::save( false ); -} - -void -XSPFPlaylist::setLicense( const KUrl &license ) -{ - if( documentElement().namedItem( "license" ).isNull() ) - { - QDomNode node = createElement( "license" ); - QDomNode subNode = createTextNode( license.url() ); - node.appendChild( subNode ); - documentElement().insertBefore( node, documentElement().namedItem( "trackList" ) ); - } - else - { - documentElement().namedItem( "license" ).replaceChild( createTextNode( license.url() ), - documentElement().namedItem( "license" ).firstChild() ); - } - - //write changes to file directly if we know where. - if( !m_url.isEmpty() ) - PlaylistFile::save( false ); -} - -void -XSPFPlaylist::setAttribution( const KUrl &attribution, bool append ) -{ - if( !attribution.isValid() ) - return; - - if( documentElement().namedItem( "attribution" ).isNull() ) - { - documentElement().insertBefore( createElement( "attribution" ), - documentElement().namedItem( "trackList" ) ); - } - - if( append ) - { - QDomNode subNode = createElement( "location" ); - QDomNode subSubNode = createTextNode( attribution.url() ); - subNode.appendChild( subSubNode ); - - QDomNode first = documentElement().namedItem( "attribution" ).firstChild(); - documentElement().namedItem( "attribution" ).insertBefore( subNode, first ); - } - else - { - QDomNode node = createElement( "attribution" ); - QDomNode subNode = createElement( "location" ); - QDomNode subSubNode = createTextNode( attribution.url() ); - subNode.appendChild( subSubNode ); - node.appendChild( subNode ); - documentElement().replaceChild( node, documentElement().namedItem( "attribution" ) ); - } - - //write changes to file directly if we know where. - if( !m_url.isEmpty() ) - PlaylistFile::save( false ); -} - -void -XSPFPlaylist::setLink( const KUrl &link ) -{ - if( documentElement().namedItem( "link" ).isNull() ) - { - QDomNode node = createElement( "link" ); - QDomNode subNode = createTextNode( link.url() ); - node.appendChild( subNode ); - documentElement().insertBefore( node, documentElement().namedItem( "trackList" ) ); - } - else - { - documentElement().namedItem( "link" ).replaceChild( createTextNode( link.url() ), - documentElement().namedItem( "link" ).firstChild() ); - } - - //write changes to file directly if we know where. - if( !m_url.isEmpty() ) - PlaylistFile::save( false ); -} - -XSPFTrackList -XSPFPlaylist::trackList() -{ - XSPFTrackList list; - - QDomNode trackList = documentElement().namedItem( "trackList" ); - QDomNode subNode = trackList.firstChild(); - QDomNode subSubNode; - - while( !subNode.isNull() ) - { - XSPFTrack track; - subSubNode = subNode.firstChild(); - if( subNode.nodeName() == "track" ) - { - while( !subSubNode.isNull() ) - { - if( subSubNode.nodeName() == "location" ) - { - QByteArray path = subSubNode.firstChild().nodeValue().toAscii(); - path.replace( '\\', '/' ); - - KUrl url = getAbsolutePath( KUrl::fromEncoded( path ) ); - track.location = url; - } - else if( subSubNode.nodeName() == "title" ) - track.title = subSubNode.firstChild().nodeValue(); - else if( subSubNode.nodeName() == "creator" ) - track.creator = subSubNode.firstChild().nodeValue(); - else if( subSubNode.nodeName() == "duration" ) - track.duration = subSubNode.firstChild().nodeValue().toInt(); - else if( subSubNode.nodeName() == "annotation" ) - track.annotation = subSubNode.firstChild().nodeValue(); - else if( subSubNode.nodeName() == "album" ) - track.album = subSubNode.firstChild().nodeValue(); - else if( subSubNode.nodeName() == "trackNum" ) - track.trackNum = (uint)subSubNode.firstChild().nodeValue().toInt(); - else if( subSubNode.nodeName() == "identifier" ) - track.identifier = subSubNode.firstChild().nodeValue(); - else if( subSubNode.nodeName() == "info" ) - track.info = subSubNode.firstChild().nodeValue(); - else if( subSubNode.nodeName() == "image" ) - track.image = subSubNode.firstChild().nodeValue(); - else if( subSubNode.nodeName() == "link" ) - track.link = subSubNode.firstChild().nodeValue(); - - subSubNode = subSubNode.nextSibling(); - } - } - list.append( track ); - subNode = subNode.nextSibling(); - } - - return list; -} - -void -XSPFPlaylist::setTrackList( Meta::TrackList trackList, bool append ) -{ - //documentation of attributes from http://www.xspf.org/xspf-v1.html - - if( documentElement().namedItem( "trackList" ).isNull() ) - documentElement().appendChild( createElement( "trackList" ) ); - - QDomNode node = createElement( "trackList" ); - - Meta::TrackPtr track; - foreach( track, trackList ) // krazy:exclude=foreach - { - QDomNode subNode = createElement( "track" ); - - //URI of resource to be rendered. - QDomNode location = createElement( "location" ); - - //Human-readable name of the track that authored the resource - QDomNode title = createElement( "title" ); - - //Human-readable name of the entity that authored the resource. - QDomNode creator = createElement( "creator" ); - - //A human-readable comment on the track. - QDomNode annotation = createElement( "annotation" ); - - //Human-readable name of the collection from which the resource comes - QDomNode album = createElement( "album" ); - - //Integer > 0 giving the ordinal position of the media in the album. - QDomNode trackNum = createElement( "trackNum" ); - - //The time to render a resource, in milliseconds. It MUST be a nonNegativeInteger. - QDomNode duration = createElement( "duration" ); - - //location-independent name, such as a MusicBrainz identifier. MUST be a legal URI. - QDomNode identifier = createElement( "identifier" ); - - //info - URI of a place where this resource can be bought or more info can be found. - //QDomNode info = createElement( "info" ); - - //image - URI of an image to display for the duration of the track. - //QDomNode image = createElement( "image" ); - - //link - element allows XSPF to be extended without the use of XML namespaces. - //QDomNode link = createElement( "link" ); - - //QDomNode meta - //amarok specific queue info, see the XSPF specification's meta element - QDomElement queue = createElement( "meta" ); - queue.setAttribute( "rel", "http://amarok.kde.org/queue" ); - - //QDomNode extension - - #define APPENDNODE( X, Y ) \ - { \ - X.appendChild( createTextNode( Y ) ); \ - subNode.appendChild( X ); \ - } - - APPENDNODE( location, trackLocation( track ) ) - APPENDNODE( identifier, track->uidUrl() ) - - Capabilities::StreamInfoCapability *streamInfo = track->create(); - if( streamInfo ) // We have a stream, use it's metadata instead of the tracks. - { - if( !streamInfo->streamName().isEmpty() ) - APPENDNODE( title, streamInfo->streamName() ) - if( !streamInfo->streamSource().isEmpty() ) - APPENDNODE( creator, streamInfo->streamSource() ) - - delete streamInfo; - } - else - { - if( !track->name().isEmpty() ) - APPENDNODE(title, track->name() ) - if( track->artist() && !track->artist()->name().isEmpty() ) - APPENDNODE(creator, track->artist()->name() ); - } - if( !track->comment().isEmpty() ) - APPENDNODE(annotation, track->comment() ); - if( track->album() && !track->album()->name().isEmpty() ) - APPENDNODE( album, track->album()->name() ); - if( track->trackNumber() > 0 ) - APPENDNODE( trackNum, QString::number( track->trackNumber() ) ); - if( track->length() > 0 ) - APPENDNODE( duration, QString::number( track->length() ) ); - - node.appendChild( subNode ); - } - #undef APPENDNODE - - if( append ) - { - while( !node.isNull() ) - { - documentElement().namedItem( "trackList" ).appendChild( node.firstChild() ); - node = node.nextSibling(); - } - } - else - documentElement().replaceChild( node, documentElement().namedItem( "trackList" ) ); -} - -void -XSPFPlaylist::setQueue( const QList &queue ) -{ - QDomElement q = createElement( "queue" ); - - foreach( int row, queue ) - { - QDomElement qTrack = createElement( "track" ); - qTrack.appendChild( createTextNode( QString::number( row ) ) ); - q.appendChild( qTrack ); - } - - QDomElement extension = createElement( "extension" ); - extension.setAttribute( "application", "http://amarok.kde.org" ); - extension.appendChild( q ); - - QDomNode root = firstChild(); - root.appendChild( extension ); -} - -QList -XSPFPlaylist::queue() -{ - QList tracks; - - QDomElement extension = documentElement().firstChildElement( "extension" ); - if( extension.isNull() ) - return tracks; - - if( extension.attribute( "application" ) != "http://amarok.kde.org" ) - return tracks; - - QDomElement queue = extension.firstChildElement( "queue" ); - if( queue.isNull() ) - return tracks; - - for( QDomElement trackElem = queue.firstChildElement( "track" ); - !trackElem.isNull(); - trackElem = trackElem.nextSiblingElement( "track" ) ) - { - tracks << trackElem.text().toInt(); - } - - return tracks; -} - -void -XSPFPlaylist::setName( const QString &name ) -{ - PlaylistFile::setName( name ); - setTitle( name ); -} diff --git a/amarok/src/core-impl/playlists/types/file/xspf/XSPFPlaylist.h b/amarok/src/core-impl/playlists/types/file/xspf/XSPFPlaylist.h deleted file mode 100644 index 202962db..00000000 --- a/amarok/src/core-impl/playlists/types/file/xspf/XSPFPlaylist.h +++ /dev/null @@ -1,136 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Bart Cerneels * - * Copyright (c) 2006 Mattias Fliesberg * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef XSPFPLAYLIST_H -#define XSPFPLAYLIST_H - -#include "core-impl/playlists/types/file/PlaylistFile.h" - -#include -#include - -namespace Playlists -{ -/* convenience struct for internal use */ -struct XSPFTrack { - // initialize primitive types, don't give stochasticity a chance! - XSPFTrack() : trackNum( 0 ), duration( 0 ) {} - - KUrl location; - QString identifier; - QString title; - QString creator; - QString annotation; - KUrl info; - KUrl image; - QString album; - uint trackNum; - uint duration; - KUrl link; -}; - -typedef QList XSPFTrackList; - -/** - * @author Bart Cerneels - */ -class AMAROK_EXPORT XSPFPlaylist : public PlaylistFile, public QDomDocument -{ -public: - enum OnLoadAction { - NoAction, // do nothing on playlist load - AppendToPlaylist, // apped this playlist to play queue on load - }; - - /** - * Creates a new XSPFPlaylist - * - * @param url The Url of the xspf file to load. - * @param onLoad Should this playlist automatically append itself to the playlist when loaded (useful when loading a remote url as it - * allows the caller to do it in a "one shot" way and not have to worry about waiting untill download and parsing is completed. - */ - explicit XSPFPlaylist( const KUrl &url, PlaylistProvider *provider = 0, OnLoadAction onLoad = NoAction ); - - ~XSPFPlaylist(); - - virtual QString name() const; - - /* convenience functions */ - QString title() const; - QString creator() const; - QString annotation() const; - KUrl info() const; - KUrl location() const; - QString identifier() const; - KUrl image() const; - QDateTime date() const; - KUrl license() const; - KUrl::List attribution() const; - KUrl link() const; - - /* Extra XSPF setter methods: */ - void setTitle( const QString &title ); - void setCreator( const QString &creator ); - void setAnnotation( const QString &annotation ); - void setInfo( const KUrl &info ); - void setLocation( const KUrl &location ); - void setIdentifier( const QString &identifier ); - void setImage( const KUrl &image ); - void setDate( const QDateTime &date ); - void setLicense( const KUrl &license ); - void setAttribution( const KUrl &attribution, bool append = true ); - void setLink( const KUrl &link ); - void setTrackList( Meta::TrackList trackList, bool append = false ); - - /* PlaylistFile methods */ - virtual bool load( QTextStream &stream ) { return loadXSPF( stream ); } - virtual bool load( QByteArray &content ) { return loadXSPF( content ); } - /* Overrides filename and title */ - void setName(const QString &name); - virtual QString extension() const { return "xspf"; } - virtual QString mimetype() const { return "application/xspf+xml"; } - - virtual bool save( bool relative ) { return PlaylistFile::save( relative ); } - - void setQueue( const QList &queue ); - QList queue(); - -protected: - virtual void savePlaylist( QFile &file ); - -private: - XSPFTrackList trackList(); - - /** - * Load file after content was set - */ - void load(); - - /** - * Sets content in terms of xml document - * @return true is xml-document is correct, false overwise - */ - bool processContent( QByteArray &content ); - - bool loadXSPF( QTextStream &stream ); - bool loadXSPF( QByteArray &content ); - - bool m_autoAppendAfterLoad; -}; -} - -#endif diff --git a/amarok/src/core-impl/podcasts/sql/PodcastFilenameLayoutConfigDialog.cpp b/amarok/src/core-impl/podcasts/sql/PodcastFilenameLayoutConfigDialog.cpp deleted file mode 100644 index b7b4db61..00000000 --- a/amarok/src/core-impl/podcasts/sql/PodcastFilenameLayoutConfigDialog.cpp +++ /dev/null @@ -1,82 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2011 Sandeep Raghuraman * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "PodcastFilenameLayoutConfigDialog.h" -#include "ui_PodcastFilenameLayoutConfigWidget.h" - -#include - -PodcastFilenameLayoutConfigDialog::PodcastFilenameLayoutConfigDialog( Podcasts::SqlPodcastChannelPtr channel, QWidget *parent ) - : KDialog( parent ) - , m_channel( channel ) - , m_pflc( new Ui::PodcastFilenameLayoutConfigWidget ) -{ - QWidget* main = new QWidget( this ); - m_pflc->setupUi( main ); - setMainWidget( main ); - - setCaption( i18nc( "Change filename layout", "Podcast Episode Filename Configuration" ) ); - setModal( true ); - setButtons( Cancel | Ok ); - setDefaultButton( Ok ); - showButtonSeparator( true ); - setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Fixed ); - - init(); -} - -void -PodcastFilenameLayoutConfigDialog::init() -{ - //initialize state of the various gui items based on the channel settings - - QString filenameLayout = m_channel->filenameLayout(); - - if( filenameLayout == QLatin1String( "%default%" ) ) - { - m_pflc->m_filenameLayoutDefault->setChecked( true ); - m_pflc->m_filenameLayoutCustom->setChecked( false ); - m_choice = 0; - } - else - { - m_pflc->m_filenameLayoutDefault->setChecked( false ); - m_pflc->m_filenameLayoutCustom->setChecked( true ); - m_pflc->m_filenameLayoutText->setText( filenameLayout ); - m_choice = 1; - } - - connect( this, SIGNAL(okClicked()), this, SLOT(slotApply()) ); -} - - -void -PodcastFilenameLayoutConfigDialog::slotApply() -{ - if( m_pflc->m_filenameLayoutCustom->isChecked() ) - m_channel->setFilenameLayout( m_pflc->m_filenameLayoutText->text() ); - else - m_channel->setFilenameLayout( "%default%" ); -} - -bool -PodcastFilenameLayoutConfigDialog::configure() -{ - return exec() == QDialog::Accepted; -} - - -#include "moc_PodcastFilenameLayoutConfigDialog.cpp" diff --git a/amarok/src/core-impl/podcasts/sql/PodcastFilenameLayoutConfigDialog.h b/amarok/src/core-impl/podcasts/sql/PodcastFilenameLayoutConfigDialog.h deleted file mode 100644 index 3f943414..00000000 --- a/amarok/src/core-impl/podcasts/sql/PodcastFilenameLayoutConfigDialog.h +++ /dev/null @@ -1,48 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2011 Sandeep Raghuraman * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_PODCASTFILENAMELAYOUTCONFIGDIALOG_H -#define AMAROK_PODCASTFILENAMELAYOUTCONFIGDIALOG_H - -#include "SqlPodcastMeta.h" - -#include - -namespace Ui -{ -class PodcastFilenameLayoutConfigWidget; -} - -class PodcastFilenameLayoutConfigDialog : public KDialog -{ - - Q_OBJECT -public: - explicit PodcastFilenameLayoutConfigDialog( Podcasts::SqlPodcastChannelPtr channel, QWidget *parent = 0 ); - //shows the filename configuration dialog - bool configure(); - -protected slots: - void slotApply(); - -private: - void init(); - Podcasts::SqlPodcastChannelPtr m_channel; - Ui::PodcastFilenameLayoutConfigWidget *m_pflc; - int m_choice; -}; - -#endif diff --git a/amarok/src/core-impl/podcasts/sql/PodcastFilenameLayoutConfigWidget.ui b/amarok/src/core-impl/podcasts/sql/PodcastFilenameLayoutConfigWidget.ui deleted file mode 100644 index 33f8f65b..00000000 --- a/amarok/src/core-impl/podcasts/sql/PodcastFilenameLayoutConfigWidget.ui +++ /dev/null @@ -1,133 +0,0 @@ - - - Sandeep Raghuraman - PodcastFilenameLayoutConfigWidget - - - Qt::WindowModal - - - - 0 - 0 - 400 - 110 - - - - - 250 - 100 - - - - - 400 - 100 - - - - Podcast Filename Layout Configuration - - - - - 20 - 20 - 231 - 22 - - - - - 0 - 0 - - - - - 85 - 0 - - - - Specified by podcast channel - - - - - - 20 - 60 - 115 - 22 - - - - - 0 - 0 - - - - - 40 - 20 - - - - custom - - - - - - 110 - 60 - 261 - 27 - - - - - 200 - 20 - - - - - 200 - 20 - - - - - 200 - 20 - - - - Available fields : %artist%,%title%,%genre%,%year%,%composer%,%pubdate%,%number%,%album% - - - - - - - m_filenameLayoutCustom - toggled(bool) - m_filenameLayoutText - setEnabled(bool) - - - 20 - 20 - - - 20 - 20 - - - - - diff --git a/amarok/src/core-impl/podcasts/sql/PodcastSettingsBase.ui b/amarok/src/core-impl/podcasts/sql/PodcastSettingsBase.ui deleted file mode 100644 index c20533e4..00000000 --- a/amarok/src/core-impl/podcasts/sql/PodcastSettingsBase.ui +++ /dev/null @@ -1,318 +0,0 @@ - - - Bart Cerneels - PodcastSettingsBase - - - Qt::WindowModal - - - - 0 - 0 - 527 - 305 - - - - - 0 - 0 - - - - - 0 - 0 - - - - Podcast Configuration - - - - - - - - - - - 0 - 0 - - - - - 25 - 0 - - - - URL: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 0 - 0 - - - - Save Location: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - - - - - - 0 - 0 - - - - - - - - - - - - When checked, Amarok will automatically scan the podcast for updates - - - When checked, Amarok will automatically scan the podcast for updates - - - Automatically scan for updates - - - - - - - Media Download - - - false - - - - - - Download media as soon as it becomes available - - - Download media as soon as it becomes available - - - Download when a&vailable - - - - - - - Media must be explicitly downloaded, otherwise the podcast will be played from the remote server. - - - Media must be explicitly downloaded, otherwise the podcast will be played from the remote server. - - - Stream or download on re&quest - - - - - - - - - - - - If checked, Amarok will throw away old podcast episodes - - - If checked, Amarok will throw away old podcast episodes - - - Limit &number of episodes - - - - - - - Qt::Horizontal - - - QSizePolicy::Expanding - - - - 108 - 29 - - - - - - - - Keep maximum of: - - - false - - - - - - - The maximum number of podcast items to store - - - The maximum number of podcast items to store - - - 1 - - - - - - - - - - - The RSS feed and the tags in the downloaded file sometimes do not contain the same information. Writing the tags ensures the information in the playlist and on media devices will be the same as in the feed. - - - Write feed information to tags after downloading. - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - 0 - 0 - - - - - 240 - 30 - - - - - 16777215 - 16777215 - - - - Episode Filename Configuration - - - - - - - - - KIntSpinBox - QSpinBox -
    knuminput.h
    - 1 -
    - - KUrlRequester - QFrame -
    kurlrequester.h
    - 1 -
    - - KButtonGroup - QGroupBox -
    kbuttongroup.h
    - 1 -
    -
    - - kurlrequester.h - klineedit.h - kpushbutton.h - - - - - m_purgeCheck - toggled(bool) - m_purgeCountSpinBox - setEnabled(bool) - - - 20 - 20 - - - 20 - 20 - - - - - m_purgeCheck - toggled(bool) - m_purgeCountLabel - setEnabled(bool) - - - 20 - 20 - - - 20 - 20 - - - - -
    diff --git a/amarok/src/core-impl/podcasts/sql/PodcastSettingsDialog.cpp b/amarok/src/core-impl/podcasts/sql/PodcastSettingsDialog.cpp deleted file mode 100644 index 36dcfdbe..00000000 --- a/amarok/src/core-impl/podcasts/sql/PodcastSettingsDialog.cpp +++ /dev/null @@ -1,164 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2006-2008 Bart Cerneels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "PodcastSettingsDialog.h" -#include "ui_PodcastSettingsBase.h" -#include "PodcastFilenameLayoutConfigDialog.h" - -#include "core/support/Debug.h" - -#include -#include -#include - -PodcastSettingsDialog::PodcastSettingsDialog( Podcasts::SqlPodcastChannelPtr channel, QWidget* parent ) - : KDialog( parent ) - , m_ps( new Ui::PodcastSettingsBase() ) - , m_channel( channel ) -{ - QWidget* main = new QWidget( this ); - m_ps->setupUi( main ); - setMainWidget( main ); - - setCaption( i18nc("change options", "Configure %1", m_channel->title() ) ); - setModal( true ); - setButtons( Apply | Cancel | Ok ); - setDefaultButton( Ok ); - showButtonSeparator( true ); - - init(); -} - -void -PodcastSettingsDialog::init() -{ - QString url = m_channel->url().url(); - m_ps->m_urlLineEdit->setText( url ); - - m_ps->m_saveLocation->setMode( KFile::Directory | KFile::ExistingOnly ); - m_ps->m_saveLocation->setUrl( m_channel->saveLocation() ); - - m_ps->m_autoFetchCheck->setChecked( m_channel->autoScan() ); - - if( m_channel->fetchType() == Podcasts::PodcastChannel::StreamOrDownloadOnDemand ) - { - m_ps->m_streamRadio->setChecked( true ); - m_ps->m_downloadRadio->setChecked( false ); - } - else if( m_channel->fetchType() == Podcasts::PodcastChannel::DownloadWhenAvailable ) - { - m_ps->m_streamRadio->setChecked( false ); - m_ps->m_downloadRadio->setChecked( true ); - } - - m_ps->m_purgeCheck->setChecked( m_channel->hasPurge() ); - m_ps->m_purgeCountSpinBox->setValue( m_channel->purgeCount() ); - m_ps->m_purgeCountSpinBox->setSuffix( ki18np( " Item", " Items" ) ); - - if( !m_channel->hasPurge() ) - { - m_ps->m_purgeCountSpinBox->setEnabled( false ); - m_ps->m_purgeCountLabel->setEnabled( false ); - } - - m_ps->m_writeTagsCheck->setChecked( m_channel->writeTags() ); - - enableButtonApply( false ); - - // Connects for modification check - connect( m_ps->m_urlLineEdit, SIGNAL(textChanged(QString)), - SLOT(checkModified()) ); - connect( m_ps->m_saveLocation, SIGNAL(textChanged(QString)), - SLOT(checkModified()) ); - connect( m_ps->m_autoFetchCheck, SIGNAL(clicked()), SLOT(checkModified()) ); - connect( m_ps->m_streamRadio, SIGNAL(clicked()), SLOT(checkModified()) ); - connect( m_ps->m_downloadRadio, SIGNAL(clicked()), SLOT(checkModified()) ); - connect( m_ps->m_purgeCheck, SIGNAL(clicked()), SLOT(checkModified()) ); - connect( m_ps->m_purgeCountSpinBox, SIGNAL(valueChanged(int)), SLOT(checkModified()) ); - connect( m_ps->m_writeTagsCheck, SIGNAL(clicked()), SLOT(checkModified()) ); - connect( m_ps->m_filenameLayoutConfigWidgetButton, SIGNAL(clicked()), SLOT(launchFilenameLayoutConfigDialog()) ); - - connect( this, SIGNAL(applyClicked()), this ,SLOT(slotApply()) ); - connect( this, SIGNAL(okClicked()), this, SLOT(slotApply()) ); -} - -void -PodcastSettingsDialog::slotFeedUrlClicked( const QString &url ) //SLOT -{ - //adding url to clipboard for users convenience - QApplication::clipboard()->setText( url ); -} - -bool -PodcastSettingsDialog::hasChanged() -{ - bool fetchTypeChanged = true; - - if( ( m_ps->m_streamRadio->isChecked() && m_channel->fetchType() == Podcasts::PodcastChannel::StreamOrDownloadOnDemand ) || - ( m_ps->m_downloadRadio->isChecked() && m_channel->fetchType() == Podcasts::PodcastChannel::DownloadWhenAvailable ) ) - { - fetchTypeChanged = false; - } - - return( m_channel->url() != m_ps->m_urlLineEdit->text() || - m_channel->saveLocation() != m_ps->m_saveLocation->url() || - m_channel->autoScan() != m_ps->m_autoFetchCheck->isChecked() || - m_channel->hasPurge() != m_ps->m_purgeCheck->isChecked() || - m_channel->purgeCount() != m_ps->m_purgeCountSpinBox->value() || - fetchTypeChanged || - m_channel->writeTags() != m_ps->m_writeTagsCheck->isChecked() - ); -} - -void -PodcastSettingsDialog::checkModified() //slot -{ - enableButtonApply( hasChanged() ); -} - -void -PodcastSettingsDialog::slotApply() //slot -{ - m_channel->setUrl( KUrl( m_ps->m_urlLineEdit->text() ) ); - m_channel->setAutoScan( m_ps->m_autoFetchCheck->isChecked() ); - m_channel->setFetchType( - m_ps->m_downloadRadio->isChecked() ? - Podcasts::PodcastChannel::DownloadWhenAvailable : - Podcasts::PodcastChannel::StreamOrDownloadOnDemand - ); - m_channel->setSaveLocation( m_ps->m_saveLocation->url() ); - - m_channel->setPurge( m_ps->m_purgeCheck->isChecked() ); - m_channel->setPurgeCount( m_ps->m_purgeCountSpinBox->value() ); - m_channel->setWriteTags( m_ps->m_writeTagsCheck->isChecked() ); - - enableButtonApply( false ); -} - -bool PodcastSettingsDialog::configure() -{ - return exec() == QDialog::Accepted; -} - -void PodcastSettingsDialog::launchFilenameLayoutConfigDialog() -{ - PodcastFilenameLayoutConfigDialog pflcDialog( m_channel, this ); - pflcDialog.configure(); -} - - -#include "moc_PodcastSettingsDialog.cpp" - diff --git a/amarok/src/core-impl/podcasts/sql/PodcastSettingsDialog.h b/amarok/src/core-impl/podcasts/sql/PodcastSettingsDialog.h deleted file mode 100644 index d0ca8ff2..00000000 --- a/amarok/src/core-impl/podcasts/sql/PodcastSettingsDialog.h +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2006-2008 Bart Cerneels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_PODCASTSETTINGSDIALOG_H -#define AMAROK_PODCASTSETTINGSDIALOG_H - -#include "SqlPodcastMeta.h" - -#include - -namespace Ui { - class PodcastSettingsBase; -} - -class PodcastSettingsDialog : public KDialog -{ - Q_OBJECT - - public: - explicit PodcastSettingsDialog( Podcasts::SqlPodcastChannelPtr channel, QWidget* parent=0 ); - - bool configure(); - - protected: - bool hasChanged(); - - protected slots: - void checkModified(); - void slotApply(); - void slotFeedUrlClicked( const QString &url ); - void launchFilenameLayoutConfigDialog(); - - private: - void init(); - QString requesterSaveLocation(); - - Ui::PodcastSettingsBase *m_ps; - - Podcasts::SqlPodcastChannelPtr m_channel; -}; - -#endif /*AMAROK_PODCASTSETTINGSDIALOG_H*/ diff --git a/amarok/src/core-impl/podcasts/sql/SqlPodcastMeta.cpp b/amarok/src/core-impl/podcasts/sql/SqlPodcastMeta.cpp deleted file mode 100644 index 0ccbcc3a..00000000 --- a/amarok/src/core-impl/podcasts/sql/SqlPodcastMeta.cpp +++ /dev/null @@ -1,949 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Bart Cerneels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "SqlPodcastMeta.h" - -#include "amarokurls/BookmarkMetaActions.h" -#include "amarokurls/PlayUrlRunner.h" -#include "core/capabilities/ActionsCapability.h" -#include -#include "core/meta/TrackEditor.h" -#include "core/support/Debug.h" -#include "core-impl/capabilities/timecode/TimecodeLoadCapability.h" -#include "core-impl/capabilities/timecode/TimecodeWriteCapability.h" -#include "core-impl/collections/support/CollectionManager.h" -#include "core-impl/storage/StorageManager.h" -#include "core-impl/meta/proxy/MetaProxy.h" -#include "core-impl/meta/file/FileTrackProvider.h" -#include "core-impl/podcasts/sql/SqlPodcastProvider.h" - -#include -#include - -using namespace Podcasts; - -static FileTrackProvider myFileTrackProvider; // we need it to be available for lookups - -class TimecodeWriteCapabilityPodcastImpl : public Capabilities::TimecodeWriteCapability -{ - public: - TimecodeWriteCapabilityPodcastImpl( Podcasts::PodcastEpisode *episode ) - : Capabilities::TimecodeWriteCapability() - , m_episode( episode ) - {} - - virtual bool writeTimecode ( qint64 miliseconds ) - { - DEBUG_BLOCK - return Capabilities::TimecodeWriteCapability::writeTimecode( miliseconds, - Meta::TrackPtr::dynamicCast( m_episode ) ); - } - - virtual bool writeAutoTimecode ( qint64 miliseconds ) - { - DEBUG_BLOCK - return Capabilities::TimecodeWriteCapability::writeAutoTimecode( miliseconds, - Meta::TrackPtr::dynamicCast( m_episode ) ); - } - - private: - Podcasts::PodcastEpisodePtr m_episode; -}; - -class TimecodeLoadCapabilityPodcastImpl : public Capabilities::TimecodeLoadCapability -{ - public: - TimecodeLoadCapabilityPodcastImpl( Podcasts::PodcastEpisode *episode ) - : Capabilities::TimecodeLoadCapability() - , m_episode( episode ) - { - DEBUG_BLOCK - debug() << "episode: " << m_episode->name(); - } - - virtual bool hasTimecodes() - { - if ( loadTimecodes().size() > 0 ) - return true; - return false; - } - - virtual BookmarkList loadTimecodes() - { - DEBUG_BLOCK - if ( m_episode && m_episode->playableUrl().isValid() ) - { - BookmarkList list = PlayUrlRunner::bookmarksFromUrl( m_episode->playableUrl() ); - return list; - } - else - return BookmarkList(); - } - - private: - Podcasts::PodcastEpisodePtr m_episode; -}; - -Meta::TrackList -SqlPodcastEpisode::toTrackList( Podcasts::SqlPodcastEpisodeList episodes ) -{ - Meta::TrackList tracks; - foreach( SqlPodcastEpisodePtr sqlEpisode, episodes ) - tracks << Meta::TrackPtr::dynamicCast( sqlEpisode ); - - return tracks; -} - -Podcasts::PodcastEpisodeList -SqlPodcastEpisode::toPodcastEpisodeList( SqlPodcastEpisodeList episodes ) -{ - Podcasts::PodcastEpisodeList sqlEpisodes; - foreach( SqlPodcastEpisodePtr sqlEpisode, episodes ) - sqlEpisodes << Podcasts::PodcastEpisodePtr::dynamicCast( sqlEpisode ); - - return sqlEpisodes; -} - -SqlPodcastEpisode::SqlPodcastEpisode( const QStringList &result, SqlPodcastChannelPtr sqlChannel ) - : Podcasts::PodcastEpisode( Podcasts::PodcastChannelPtr::staticCast( sqlChannel ) ) - , m_channel( sqlChannel ) -{ - SqlStorage *sqlStorage = StorageManager::instance()->sqlStorage(); - QStringList::ConstIterator iter = result.constBegin(); - m_dbId = (*(iter++)).toInt(); - m_url = KUrl( *(iter++) ); - int channelId = (*(iter++)).toInt(); - Q_UNUSED( channelId ); - m_localUrl = KUrl( *(iter++) ); - m_guid = *(iter++); - m_title = *(iter++); - m_subtitle = *(iter++); - m_sequenceNumber = (*(iter++)).toInt(); - m_description = *(iter++); - m_mimeType = *(iter++); - m_pubDate = QDateTime::fromString( *(iter++), Qt::ISODate ); - m_duration = (*(iter++)).toInt(); - m_fileSize = (*(iter++)).toInt(); - m_isNew = sqlStorage->boolTrue() == (*(iter++)); - m_isKeep = sqlStorage->boolTrue() == (*(iter++)); - - Q_ASSERT_X( iter == result.constEnd(), "SqlPodcastEpisode( PodcastCollection*, QStringList )", "number of expected fields did not match number of actual fields" ); - - setupLocalFile(); -} - -//TODO: why do PodcastMetaCommon and PodcastEpisode not have an appropriate copy constructor? -SqlPodcastEpisode::SqlPodcastEpisode( Podcasts::PodcastEpisodePtr episode ) - : Podcasts::PodcastEpisode() - , m_dbId( 0 ) - , m_isKeep( false ) -{ - m_channel = SqlPodcastChannelPtr::dynamicCast( episode->channel() ); - - if( !m_channel && episode->channel() ) - { - debug() << "BUG: creating SqlEpisode but not an sqlChannel!!!"; - debug() << episode->channel()->title(); - debug() << m_channel->title(); - } - - // PodcastMetaCommon - m_title = episode->title(); - m_description = episode->description(); - m_keywords = episode->keywords(); - m_subtitle = episode->subtitle(); - m_summary = episode->summary(); - m_author = episode->author(); - - // PodcastEpisode - m_guid = episode->guid(); - m_url = KUrl( episode->uidUrl() ); - m_localUrl = episode->localUrl(); - m_mimeType = episode->mimeType(); - m_pubDate = episode->pubDate(); - m_duration = episode->duration(); - m_fileSize = episode->filesize(); - m_sequenceNumber = episode->sequenceNumber(); - m_isNew = episode->isNew(); - - // The album, artist, composer, genre and year fields - // contain proxy objects with internal references to this. - // These proxies are created by Podcasts::PodcastEpisode(), so - // these fields don't have to be set here. - - //commit to the database - updateInDb(); - setupLocalFile(); -} - -SqlPodcastEpisode::SqlPodcastEpisode( PodcastChannelPtr channel, Podcasts::PodcastEpisodePtr episode ) - : Podcasts::PodcastEpisode() - , m_dbId( 0 ) - , m_isKeep( false ) -{ - m_channel = SqlPodcastChannelPtr::dynamicCast( channel ); - - if( !m_channel && episode->channel() ) - { - debug() << "BUG: creating SqlEpisode but not an sqlChannel!!!"; - debug() << episode->channel()->title(); - debug() << m_channel->title(); - } - - // PodcastMetaCommon - m_title = episode->title(); - m_description = episode->description(); - m_keywords = episode->keywords(); - m_subtitle = episode->subtitle(); - m_summary = episode->summary(); - m_author = episode->author(); - - // PodcastEpisode - m_guid = episode->guid(); - m_url = KUrl( episode->uidUrl() ); - m_localUrl = episode->localUrl(); - m_mimeType = episode->mimeType(); - m_pubDate = episode->pubDate(); - m_duration = episode->duration(); - m_fileSize = episode->filesize(); - m_sequenceNumber = episode->sequenceNumber(); - m_isNew = episode->isNew(); - - // The album, artist, composer, genre and year fields - // contain proxy objects with internal references to this. - // These proxies are created by Podcasts::PodcastEpisode(), so - // these fields don't have to be set here. - - //commit to the database - updateInDb(); - setupLocalFile(); -} - -void -SqlPodcastEpisode::setupLocalFile() -{ - if( m_localUrl.isEmpty() || !QFileInfo( m_localUrl.toLocalFile() ).exists() ) - return; - - MetaProxy::TrackPtr proxyTrack( new MetaProxy::Track( m_localUrl, MetaProxy::Track::ManualLookup ) ); - m_localFile = Meta::TrackPtr( proxyTrack.data() ); // avoid static_cast - /* following won't write to actual file, because MetaProxy::Track hasn't yet looked - * up the underlying track. It will just set some cached values. */ - writeTagsToFile(); - proxyTrack->lookupTrack( &myFileTrackProvider ); -} - -SqlPodcastEpisode::~SqlPodcastEpisode() -{ -} - -void -SqlPodcastEpisode::setNew( bool isNew ) -{ - PodcastEpisode::setNew( isNew ); - updateInDb(); -} - -void SqlPodcastEpisode::setKeep( bool isKeep ) -{ - m_isKeep = isKeep; - updateInDb(); -} - -void -SqlPodcastEpisode::setLocalUrl( const KUrl &url ) -{ - m_localUrl = url; - updateInDb(); - - if( m_localUrl.isEmpty() && !m_localFile.isNull() ) - { - m_localFile.clear(); - notifyObservers(); - } - else - { - //if we had a local file previously it should get deleted by the KSharedPtr. - m_localFile = new MetaFile::Track( m_localUrl ); - if( m_channel->writeTags() ) - writeTagsToFile(); - } -} - -qint64 -SqlPodcastEpisode::length() const -{ - //if downloaded get the duration from the file, else use the value read from the feed - if( m_localFile.isNull() ) - return m_duration * 1000; - - return m_localFile->length(); -} - -bool -SqlPodcastEpisode::hasCapabilityInterface( Capabilities::Capability::Type type ) const -{ - switch( type ) - { - case Capabilities::Capability::Actions: - case Capabilities::Capability::WriteTimecode: - case Capabilities::Capability::LoadTimecode: - //only downloaded episodes can be position marked -// return !localUrl().isEmpty(); - return true; - default: - return false; - } -} - -Capabilities::Capability* -SqlPodcastEpisode::createCapabilityInterface( Capabilities::Capability::Type type ) -{ - switch( type ) - { - case Capabilities::Capability::Actions: - { - QList< QAction * > actions; - actions << new BookmarkCurrentTrackPositionAction( 0 ); - return new Capabilities::ActionsCapability( actions ); - } - case Capabilities::Capability::WriteTimecode: - return new TimecodeWriteCapabilityPodcastImpl( this ); - case Capabilities::Capability::LoadTimecode: - return new TimecodeLoadCapabilityPodcastImpl( this ); - default: - return 0; - } -} - -void -SqlPodcastEpisode::finishedPlaying( double playedFraction ) -{ - if( length() <= 0 || playedFraction >= 0.1 ) - setNew( false ); - - PodcastEpisode::finishedPlaying( playedFraction ); -} - -QString -SqlPodcastEpisode::name() const -{ - if( m_localFile.isNull() ) - return m_title; - - return m_localFile->name(); -} - -QString -SqlPodcastEpisode::prettyName() const -{ - /*for now just do the same as name, but in the future we might want to used a cleaned - up string using some sort of regex tag rewrite for podcasts. decapitateString on - steroides. */ - return name(); -} - -void -SqlPodcastEpisode::setTitle( const QString &title ) -{ - m_title = title; - - Meta::TrackEditorPtr ec = m_localFile ? m_localFile->editor() : Meta::TrackEditorPtr(); - if( ec ) - ec->setTitle( title ); -} - -Meta::ArtistPtr -SqlPodcastEpisode::artist() const -{ - if( m_localFile.isNull() ) - return m_artistPtr; - - return m_localFile->artist(); -} - -Meta::ComposerPtr -SqlPodcastEpisode::composer() const -{ - if( m_localFile.isNull() ) - return m_composerPtr; - - return m_localFile->composer(); -} - -Meta::GenrePtr -SqlPodcastEpisode::genre() const -{ - if( m_localFile.isNull() ) - return m_genrePtr; - - return m_localFile->genre(); -} - -Meta::YearPtr -SqlPodcastEpisode::year() const -{ - if( m_localFile.isNull() ) - return m_yearPtr; - - return m_localFile->year(); -} - -Meta::TrackEditorPtr -SqlPodcastEpisode::editor() -{ - if( m_localFile ) - return m_localFile->editor(); - else - return Meta::TrackEditorPtr(); -} - -bool -SqlPodcastEpisode::writeTagsToFile() -{ - if( !m_localFile ) - return false; - - Meta::TrackEditorPtr ec = m_localFile->editor(); - if( !ec ) - return false; - - debug() << "writing tags for podcast episode " << title() << "to " << m_localUrl.url(); - ec->beginUpdate(); - ec->setTitle( m_title ); - ec->setAlbum( m_channel->title() ); - ec->setArtist( m_channel->author() ); - ec->setGenre( i18n( "Podcast" ) ); - ec->setYear( m_pubDate.date().year() ); - ec->endUpdate(); - - notifyObservers(); - return true; -} - -void -SqlPodcastEpisode::updateInDb() -{ - SqlStorage *sqlStorage = StorageManager::instance()->sqlStorage(); - - QString boolTrue = sqlStorage->boolTrue(); - QString boolFalse = sqlStorage->boolFalse(); - #define escape(x) sqlStorage->escape(x) - QString command; - QTextStream stream( &command ); - if( m_dbId ) - { - stream << "UPDATE podcastepisodes "; - stream << "SET url='"; - stream << escape(m_url.url()); - stream << "', channel="; - stream << m_channel->dbId(); - stream << ", localurl='"; - stream << escape(m_localUrl.url()); - stream << "', guid='"; - stream << escape(m_guid); - stream << "', title='"; - stream << escape(m_title); - stream << "', subtitle='"; - stream << escape(m_subtitle); - stream << "', sequencenumber="; - stream << m_sequenceNumber; - stream << ", description='"; - stream << escape(m_description); - stream << "', mimetype='"; - stream << escape(m_mimeType); - stream << "', pubdate='"; - stream << escape(m_pubDate.toString(Qt::ISODate)); - stream << "', duration="; - stream << m_duration; - stream << ", filesize="; - stream << m_fileSize; - stream << ", isnew="; - stream << (isNew() ? boolTrue : boolFalse); - stream << ", iskeep="; - stream << (isKeep() ? boolTrue : boolFalse); - stream << " WHERE id="; - stream << m_dbId; - stream << ";"; - sqlStorage->query( command ); - } - else - { - stream << "INSERT INTO podcastepisodes ("; - stream << "url,channel,localurl,guid,title,subtitle,sequencenumber,description,"; - stream << "mimetype,pubdate,duration,filesize,isnew,iskeep) "; - stream << "VALUES ( '"; - stream << escape(m_url.url()) << "', "; - stream << m_channel->dbId() << ", '"; - stream << escape(m_localUrl.url()) << "', '"; - stream << escape(m_guid) << "', '"; - stream << escape(m_title) << "', '"; - stream << escape(m_subtitle) << "', "; - stream << m_sequenceNumber << ", '"; - stream << escape(m_description) << "', '"; - stream << escape(m_mimeType) << "', '"; - stream << escape(m_pubDate.toString(Qt::ISODate)) << "', "; - stream << m_duration << ", "; - stream << m_fileSize << ", "; - stream << (isNew() ? boolTrue : boolFalse) << ", "; - stream << (isKeep() ? boolTrue : boolFalse); - stream << ");"; - m_dbId = sqlStorage->insert( command, "podcastepisodes" ); - } -} - -void -SqlPodcastEpisode::deleteFromDb() -{ - SqlStorage *sqlStorage = StorageManager::instance()->sqlStorage(); - sqlStorage->query( - QString( "DELETE FROM podcastepisodes WHERE id = %1;" ).arg( dbId() ) ); -} - -Playlists::PlaylistPtr -SqlPodcastChannel::toPlaylistPtr( SqlPodcastChannelPtr sqlChannel ) -{ - Playlists::PlaylistPtr playlist = Playlists::PlaylistPtr::dynamicCast( sqlChannel ); - return playlist; -} - -SqlPodcastChannelPtr -SqlPodcastChannel::fromPlaylistPtr( Playlists::PlaylistPtr playlist ) -{ - SqlPodcastChannelPtr sqlChannel = SqlPodcastChannelPtr::dynamicCast( playlist ); - return sqlChannel; -} - -SqlPodcastChannel::SqlPodcastChannel( SqlPodcastProvider *provider, - const QStringList &result ) - : Podcasts::PodcastChannel() - , m_episodesLoaded( false ) - , m_trackCacheIsValid( false ) - , m_provider( provider ) -{ - SqlStorage *sqlStorage = StorageManager::instance()->sqlStorage(); - QStringList::ConstIterator iter = result.constBegin(); - m_dbId = (*(iter++)).toInt(); - m_url = KUrl( *(iter++) ); - m_title = *(iter++); - m_webLink = *(iter++); - m_imageUrl = *(iter++); - m_description = *(iter++); - m_copyright = *(iter++); - m_directory = KUrl( *(iter++) ); - m_labels = QStringList( QString( *(iter++) ).split( ',', QString::SkipEmptyParts ) ); - m_subscribeDate = QDate::fromString( *(iter++) ); - m_autoScan = sqlStorage->boolTrue() == *(iter++); - m_fetchType = (*(iter++)).toInt() == DownloadWhenAvailable ? DownloadWhenAvailable : StreamOrDownloadOnDemand; - m_purge = sqlStorage->boolTrue() == *(iter++); - m_purgeCount = (*(iter++)).toInt(); - m_writeTags = sqlStorage->boolTrue() == *(iter++); - m_filenameLayout = *(iter++); -} - -SqlPodcastChannel::SqlPodcastChannel( Podcasts::SqlPodcastProvider *provider, - Podcasts::PodcastChannelPtr channel ) - : Podcasts::PodcastChannel() - , m_dbId( 0 ) - , m_trackCacheIsValid( false ) - , m_provider( provider ) - , m_filenameLayout( "%default%" ) -{ - // PodcastMetaCommon - m_title = channel->title(); - m_description = channel->description(); - m_keywords = channel->keywords(); - m_subtitle = channel->subtitle(); - m_summary = channel->summary(); - m_author = channel->author(); - - // PodcastChannel - m_url = channel->url(); - m_webLink = channel->webLink(); - m_imageUrl = channel->imageUrl(); - m_labels = channel->labels(); - m_subscribeDate = channel->subscribeDate(); - m_copyright = channel->copyright(); - - if( channel->hasImage() ) - m_image = channel->image(); - - //Default Settings - - m_directory = KUrl( m_provider->baseDownloadDir() ); - m_directory.addPath( Amarok::vfatPath( m_title ) ); - m_autoScan = true; - m_fetchType = StreamOrDownloadOnDemand; - m_purge = false; - m_purgeCount = 10; - m_writeTags = true; - - updateInDb(); - - foreach( Podcasts::PodcastEpisodePtr episode, channel->episodes() ) - { - episode->setChannel( PodcastChannelPtr( this ) ); - SqlPodcastEpisode *sqlEpisode = new SqlPodcastEpisode( episode ); - - m_episodes << SqlPodcastEpisodePtr( sqlEpisode ); - } - m_episodesLoaded = true; -} - -int -SqlPodcastChannel::trackCount() const -{ - if( m_episodesLoaded ) - return m_episodes.count(); - else - return -1; -} - -void -SqlPodcastChannel::triggerTrackLoad() -{ - if( !m_episodesLoaded ) - loadEpisodes(); - notifyObserversTracksLoaded(); -} - -Playlists::PlaylistProvider * -SqlPodcastChannel::provider() const -{ - return dynamic_cast( m_provider ); -} - -QStringList -SqlPodcastChannel::groups() -{ - return m_labels; -} - -void -SqlPodcastChannel::setGroups( const QStringList &groups ) -{ - m_labels = groups; -} - -KUrl -SqlPodcastChannel::uidUrl() const -{ - return KUrl( QString( "amarok-sqlpodcastuid://%1").arg( m_dbId ) ); -} - -SqlPodcastChannel::~SqlPodcastChannel() -{ - m_episodes.clear(); -} - -void -SqlPodcastChannel::setTitle( const QString &title ) -{ - /* also change the savelocation if a title is not set yet. - This is a special condition that can happen when first fetching a podcast feed */ - if( m_title.isEmpty() ) - m_directory.addPath( Amarok::vfatPath( title ) ); - m_title = title; -} - -Podcasts::PodcastEpisodeList -SqlPodcastChannel::episodes() const -{ - return SqlPodcastEpisode::toPodcastEpisodeList( m_episodes ); -} - -void -SqlPodcastChannel::setImage( const QImage &image ) -{ - DEBUG_BLOCK - - m_image = image; -} - -void -SqlPodcastChannel::setImageUrl( const KUrl &imageUrl ) -{ - DEBUG_BLOCK - debug() << imageUrl; - m_imageUrl = imageUrl; - - if( imageUrl.isLocalFile() ) - { - m_image = QImage( imageUrl.path() ); - return; - } - - debug() << "Image is remote, handled by podcastImageFetcher."; -} - -Podcasts::PodcastEpisodePtr -SqlPodcastChannel::addEpisode( PodcastEpisodePtr episode ) -{ - if( !m_provider ) - return PodcastEpisodePtr(); - - KUrl checkUrl; - //searched in the database for guid or enclosure url - if( !episode->guid().isEmpty() ) - checkUrl = episode->guid(); - else if( !episode->uidUrl().isEmpty() ) - checkUrl = episode->uidUrl(); - else - return PodcastEpisodePtr(); //noting to check for - - if( m_provider->possiblyContainsTrack( checkUrl ) ) - return PodcastEpisodePtr::dynamicCast( m_provider->trackForUrl( episode->guid() ) ); - - //force episodes load. - if( !m_episodesLoaded ) - loadEpisodes(); - - SqlPodcastEpisodePtr sqlEpisode; - - if (SqlPodcastEpisodePtr::dynamicCast( episode )) - sqlEpisode = SqlPodcastEpisodePtr( new SqlPodcastEpisode( episode ) ); - else - sqlEpisode = SqlPodcastEpisodePtr( new SqlPodcastEpisode( PodcastChannelPtr(this) , episode ) ); - - - //episodes are sorted on pubDate high to low - int i; - for( i = 0; i < m_episodes.count() ; i++ ) - { - if( sqlEpisode->pubDate() > m_episodes[i]->pubDate() ) - { - m_episodes.insert( i, sqlEpisode ); - break; - } - } - - //insert in case the list is empty or at the end of the list - if( i == m_episodes.count() ) - m_episodes << sqlEpisode; - - notifyObserversTrackAdded( Meta::TrackPtr::dynamicCast( sqlEpisode ), i ); - - applyPurge(); - m_trackCacheIsValid = false; - return PodcastEpisodePtr::dynamicCast( sqlEpisode ); -} - -void -SqlPodcastChannel::applyPurge() -{ - DEBUG_BLOCK - if( !hasPurge() ) - return; - - if( m_episodes.count() > purgeCount() ) - { - int purgeIndex = 0; - - foreach( SqlPodcastEpisodePtr episode, m_episodes ) - { - if ( !episode->isKeep() ) - { - if( purgeIndex >= purgeCount() ) - { - m_provider->deleteDownloadedEpisode( episode ); - m_episodes.removeOne( episode ); - } - else - purgeIndex++; - } - } - m_trackCacheIsValid = false; - } -} - -void -SqlPodcastChannel::updateInDb() -{ - SqlStorage *sqlStorage = StorageManager::instance()->sqlStorage(); - - QString boolTrue = sqlStorage->boolTrue(); - QString boolFalse = sqlStorage->boolFalse(); - #define escape(x) sqlStorage->escape(x) - QString command; - QTextStream stream( &command ); - if( m_dbId ) - { - stream << "UPDATE podcastchannels "; - stream << "SET url='"; - stream << escape(m_url.url()); - stream << "', title='"; - stream << escape(m_title); - stream << "', weblink='"; - stream << escape(m_webLink.url()); - stream << "', image='"; - stream << escape(m_imageUrl.url()); - stream << "', description='"; - stream << escape(m_description); - stream << "', copyright='"; - stream << escape(m_copyright); - stream << "', directory='"; - stream << escape(m_directory.url()); - stream << "', labels='"; - stream << escape(m_labels.join( "," )); - stream << "', subscribedate='"; - stream << escape(m_subscribeDate.toString()); - stream << "', autoscan="; - stream << (m_autoScan ? boolTrue : boolFalse); - stream << ", fetchtype="; - stream << QString::number(m_fetchType); - stream << ", haspurge="; - stream << (m_purge ? boolTrue : boolFalse); - stream << ", purgecount="; - stream << QString::number(m_purgeCount); - stream << ", writetags="; - stream << (m_writeTags ? boolTrue : boolFalse); - stream << ", filenamelayout='"; - stream << escape(m_filenameLayout); - stream << "' WHERE id="; - stream << m_dbId; - stream << ";"; - kDebug() << command; - sqlStorage->query( command ); - } - else - { - stream << "INSERT INTO podcastchannels("; - stream << "url,title,weblink,image,description,copyright,directory,labels,"; - stream << "subscribedate,autoscan,fetchtype,haspurge,purgecount,writetags,filenamelayout) "; - stream << "VALUES ( '"; - stream << escape(m_url.url()) << "', '"; - stream << escape(m_title) << "', '"; - stream << escape(m_webLink.url()) << "', '"; - stream << escape(m_imageUrl.url()) << "', '"; - stream << escape(m_description) << "', '"; - stream << escape(m_copyright) << "', '"; - stream << escape(m_directory.url()) << "', '"; - stream << escape(m_labels.join( "," )) << "', '"; - stream << escape(m_subscribeDate.toString()) << "', "; - stream << (m_autoScan ? boolTrue : boolFalse) << ", "; - stream << QString::number(m_fetchType) << ", "; - stream << (m_purge ? boolTrue : boolFalse) << ", "; - stream << QString::number(m_purgeCount) << ", "; - stream << (m_writeTags ? boolTrue : boolFalse) << ", '"; - stream << escape(m_filenameLayout); - stream << "');"; - kDebug() << command; - m_dbId = sqlStorage->insert( command, "podcastchannels" ); - } -} - -void -SqlPodcastChannel::deleteFromDb() -{ - SqlStorage *sqlStorage = StorageManager::instance()->sqlStorage(); - foreach( SqlPodcastEpisodePtr sqlEpisode, m_episodes ) - { - sqlEpisode->deleteFromDb(); - m_episodes.removeOne( sqlEpisode ); - } - m_trackCacheIsValid = false; - - sqlStorage->query( - QString( "DELETE FROM podcastchannels WHERE id = %1;" ).arg( dbId() ) ); -} - -void -SqlPodcastChannel::loadEpisodes() -{ - m_episodes.clear(); - - SqlStorage *sqlStorage = StorageManager::instance()->sqlStorage(); - - //If purge is enabled we must limit the number of results - QString command; - - int rowLength = 15; - - //If purge is enabled we must limit the number of results, though there are some files - //the user want to be shown even if there is no more slot - if( hasPurge() ) - { - command = QString( "(SELECT id, url, channel, localurl, guid, " - "title, subtitle, sequencenumber, description, mimetype, pubdate, " - "duration, filesize, isnew, iskeep FROM podcastepisodes WHERE channel = %1 " - "AND iskeep IS FALSE ORDER BY pubdate DESC LIMIT " + QString::number( purgeCount() ) + ") " - "UNION " - "(SELECT id, url, channel, localurl, guid, " - "title, subtitle, sequencenumber, description, mimetype, pubdate, " - "duration, filesize, isnew, iskeep FROM podcastepisodes WHERE channel = %1 " - "AND iskeep IS TRUE) " - "ORDER BY pubdate DESC;" - ); - } - else - { - command = QString( "SELECT id, url, channel, localurl, guid, " - "title, subtitle, sequencenumber, description, mimetype, pubdate, " - "duration, filesize, isnew, iskeep FROM podcastepisodes WHERE channel = %1 " - "ORDER BY pubdate DESC;" - ); - } - - QStringList results = sqlStorage->query( command.arg( m_dbId ) ); - - for( int i = 0; i < results.size(); i += rowLength ) - { - QStringList episodesResult = results.mid( i, rowLength ); - SqlPodcastEpisodePtr sqlEpisode = SqlPodcastEpisodePtr( - new SqlPodcastEpisode( - episodesResult, - SqlPodcastChannelPtr( this ) ) ); - m_episodes << sqlEpisode; - } - - m_episodesLoaded = true; - m_trackCacheIsValid = false; -} - -Meta::TrackList -Podcasts::SqlPodcastChannel::tracks() -{ - if ( !m_trackCacheIsValid ) { - m_episodesAsTracksCache = Podcasts::SqlPodcastEpisode::toTrackList( m_episodes ); - m_trackCacheIsValid = true; - } - return m_episodesAsTracksCache; -} - -void -Podcasts::SqlPodcastChannel::syncTrackStatus( int position, Meta::TrackPtr otherTrack ) -{ - Q_UNUSED( position ); - - Podcasts::PodcastEpisodePtr master = - Podcasts::PodcastEpisodePtr::dynamicCast( otherTrack ); - - if ( master ) - { - this->setName( master->channel()->name() ); - this->setTitle( master->channel()->title() ); - this->setUrl( master->channel()->url() ); - } -} - -void -Podcasts::SqlPodcastChannel::addTrack( Meta::TrackPtr track, int position ) -{ - Q_UNUSED( position ); - - addEpisode( Podcasts::PodcastEpisodePtr::dynamicCast( track ) ); - notifyObserversTrackAdded( track, position ); -} diff --git a/amarok/src/core-impl/podcasts/sql/SqlPodcastMeta.h b/amarok/src/core-impl/podcasts/sql/SqlPodcastMeta.h deleted file mode 100644 index ed346bac..00000000 --- a/amarok/src/core-impl/podcasts/sql/SqlPodcastMeta.h +++ /dev/null @@ -1,171 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Bart Cerneels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef SQLPODCASTMETA_H -#define SQLPODCASTMETA_H - -#include "core/podcasts/PodcastMeta.h" -#include "core-impl/meta/file/File.h" -#include "core/playlists/PlaylistProvider.h" - -namespace Podcasts -{ - -class SqlPodcastEpisode; -class SqlPodcastChannel; -class SqlPodcastProvider; - -typedef KSharedPtr SqlPodcastEpisodePtr; -typedef KSharedPtr SqlPodcastChannelPtr; - -typedef QList SqlPodcastEpisodeList; -typedef QList SqlPodcastChannelList; - -class SqlPodcastEpisode : public Podcasts::PodcastEpisode -{ - public: - static Meta::TrackList toTrackList( SqlPodcastEpisodeList episodes ); - static PodcastEpisodeList toPodcastEpisodeList( SqlPodcastEpisodeList episodes ); - - SqlPodcastEpisode( const QStringList &queryResult, SqlPodcastChannelPtr sqlChannel ); - - /** Copy from another PodcastEpisode - */ - SqlPodcastEpisode( PodcastEpisodePtr episode ); - SqlPodcastEpisode( PodcastChannelPtr channel, PodcastEpisodePtr episode ); - - ~SqlPodcastEpisode(); - - //PodcastEpisode methods - PodcastChannelPtr channel() const { return PodcastChannelPtr::dynamicCast( m_channel ); } - virtual bool isKeep() const { return m_isKeep; } - - virtual void setNew( bool isNew ); - virtual void setKeep( bool isKeep ); - virtual void setLocalUrl( const KUrl &url ); - - //Track Methods - virtual QString name() const; - virtual QString prettyName() const; - virtual void setTitle( const QString &title ); - virtual qint64 length() const; - virtual bool hasCapabilityInterface( Capabilities::Capability::Type type ) const; - virtual Capabilities::Capability* createCapabilityInterface( Capabilities::Capability::Type type ); - virtual void finishedPlaying( double playedFraction ); - - virtual Meta::ArtistPtr artist() const; - virtual Meta::ComposerPtr composer() const; - virtual Meta::GenrePtr genre() const; - virtual Meta::YearPtr year() const; - - virtual Meta::TrackEditorPtr editor(); - - //SqlPodcastEpisode specific methods - bool writeTagsToFile(); - int dbId() const { return m_dbId; } - - void updateInDb(); - void deleteFromDb(); - - private: - /** - * Establishes m_localFile using MetaProxy::Track if m_localUrl is valid. - */ - void setupLocalFile(); - - int m_dbId; //database ID - bool m_isKeep; //Keep the download after purge or not? - SqlPodcastChannelPtr m_channel; //the parent of this episode - - Meta::TrackPtr m_localFile; -}; - -class SqlPodcastChannel : public Podcasts::PodcastChannel -{ - public: - static Playlists::PlaylistPtr toPlaylistPtr( SqlPodcastChannelPtr sqlChannel ); - static SqlPodcastChannelPtr fromPlaylistPtr( Playlists::PlaylistPtr playlist ); - - SqlPodcastChannel( SqlPodcastProvider *provider, const QStringList &queryResult ); - - /** Copy a PodcastChannel - */ - SqlPodcastChannel( SqlPodcastProvider *provider, PodcastChannelPtr channel ); - - ~SqlPodcastChannel(); - // Playlists::Playlist methods - virtual void syncTrackStatus( int position, Meta::TrackPtr otherTrack ); - virtual int trackCount() const; - - virtual QString filenameLayout() const { return m_filenameLayout; } - - virtual Meta::TrackList tracks(); - virtual void addTrack( Meta::TrackPtr track, int position = -1 ); - - virtual void triggerTrackLoad(); - virtual Playlists::PlaylistProvider *provider() const; - - virtual QStringList groups(); - virtual void setGroups( const QStringList &groups ); - - //Podcasts::PodcastChannel methods - virtual KUrl uidUrl() const; - virtual void setTitle( const QString &title ); - virtual Podcasts::PodcastEpisodeList episodes() const; - virtual bool hasImage() const { return !m_image.isNull(); } - virtual void setImage( const QImage &image ); - virtual QImage image() const { return m_image; } - virtual KUrl imageUrl() const { return m_imageUrl; } - virtual void setImageUrl( const KUrl &imageUrl ); - virtual void setFilenameLayout( const QString &filenameLayout ) { m_filenameLayout = filenameLayout; } - - - PodcastEpisodePtr addEpisode( PodcastEpisodePtr episode ); - - //SqlPodcastChannel specific methods - int dbId() const { return m_dbId; } - //void addEpisode( SqlPodcastEpisodePtr episode ) { m_episodes << episode; } - - bool writeTags() const { return m_writeTags; } - void setWriteTags( bool writeTags ) { m_writeTags = writeTags; } - void updateInDb(); - void deleteFromDb(); - - const SqlPodcastEpisodeList sqlEpisodes() { return m_episodes; } - - void loadEpisodes(); - void applyPurge(); - - private: - bool m_writeTags; - int m_dbId; //database ID - bool m_episodesLoaded; - - SqlPodcastEpisodeList m_episodes; - bool m_trackCacheIsValid; - Meta::TrackList m_episodesAsTracksCache; - SqlPodcastProvider *m_provider; - QString m_filenameLayout; //specifies filename layout for episodes -}; - -} //namespace Podcasts - -Q_DECLARE_METATYPE( Podcasts::SqlPodcastEpisodePtr ) -Q_DECLARE_METATYPE( Podcasts::SqlPodcastEpisodeList ) -Q_DECLARE_METATYPE( Podcasts::SqlPodcastChannelPtr ) -Q_DECLARE_METATYPE( Podcasts::SqlPodcastChannelList ) - -#endif diff --git a/amarok/src/core-impl/podcasts/sql/SqlPodcastProvider.cpp b/amarok/src/core-impl/podcasts/sql/SqlPodcastProvider.cpp deleted file mode 100644 index a23ff21c..00000000 --- a/amarok/src/core-impl/podcasts/sql/SqlPodcastProvider.cpp +++ /dev/null @@ -1,1630 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007-2009 Bart Cerneels * - * Copyright (c) 2009 Frank Meerkoetter * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "SqlPodcastProvider.h" - -#include "MainWindow.h" -#include "OpmlWriter.h" -#include "SvgHandler.h" -#include "QStringx.h" -#include "browsers/playlistbrowser/PodcastModel.h" -#include "context/popupdropper/libpud/PopupDropper.h" -#include "context/popupdropper/libpud/PopupDropperItem.h" -#include -#include "core/interfaces/Logger.h" -#include "core/podcasts/PodcastImageFetcher.h" -#include "core/podcasts/PodcastReader.h" -#include "core/support/Amarok.h" -#include "core/support/Components.h" -#include "core/support/Debug.h" -#include "core-impl/storage/StorageManager.h" -#include "core-impl/podcasts/sql/PodcastSettingsDialog.h" -#include "playlistmanager/sql/SqlPlaylistGroup.h" - -#include "ui_SqlPodcastProviderSettingsWidget.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -using namespace Podcasts; - -static const int PODCAST_DB_VERSION = 6; -static const QString key( "AMAROK_PODCAST" ); -static const QString PODCAST_TMP_POSTFIX( ".tmp" ); - -SqlPodcastProvider::SqlPodcastProvider() - : m_updateTimer( new QTimer( this ) ) - , m_updatingChannels( 0 ) - , m_completedDownloads( 0 ) - , m_providerSettingsDialog( 0 ) - , m_providerSettingsWidget( 0 ) - , m_configureChannelAction( 0 ) - , m_deleteAction( 0 ) - , m_downloadAction( 0 ) - , m_keepAction( 0 ) - , m_removeAction( 0 ) - , m_updateAction( 0 ) - , m_writeTagsAction( 0 ) - , m_podcastImageFetcher( 0 ) -{ - connect( m_updateTimer, SIGNAL(timeout()), SLOT(autoUpdate()) ); - - SqlStorage *sqlStorage = StorageManager::instance()->sqlStorage(); - - if( !sqlStorage ) - { - error() << "Could not get a SqlStorage instance"; - return; - } - - m_autoUpdateInterval = Amarok::config( "Podcasts" ) - .readEntry( "AutoUpdate Interval", 30 ); - m_maxConcurrentDownloads = Amarok::config( "Podcasts" ) - .readEntry( "Maximum Simultaneous Downloads", 4 ); - m_maxConcurrentUpdates = Amarok::config( "Podcasts" ) - .readEntry( "Maximum Simultaneous Updates", 4 ); - m_baseDownloadDir = Amarok::config( "Podcasts" ).readEntry( "Base Download Directory", - Amarok::saveLocation( "podcasts" ) ); - - QStringList values; - - values = sqlStorage->query( - QString( "SELECT version FROM admin WHERE component = '%1';" ) - .arg( sqlStorage->escape( key ) ) - ); - if( values.isEmpty() ) - { - debug() << "creating Podcast Tables"; - createTables(); - sqlStorage->query( "INSERT INTO admin(component,version) " - "VALUES('" + key + "'," - + QString::number( PODCAST_DB_VERSION ) + ");" ); - } - else - { - int version = values.first().toInt(); - if( version == PODCAST_DB_VERSION ) - loadPodcasts(); - else - updateDatabase( version /*from*/, PODCAST_DB_VERSION /*to*/ ); - - startTimer(); - } -} - -void -SqlPodcastProvider::startTimer() -{ - if( !m_autoUpdateInterval ) - return; //timer is disabled - - if( m_updateTimer->isActive() && - m_updateTimer->interval() == ( m_autoUpdateInterval * 1000 * 60 ) ) - return; //already started with correct interval - - //and only start if at least one channel has autoscan enabled - foreach( Podcasts::SqlPodcastChannelPtr channel, m_channels ) - { - if( channel->autoScan() ) - { - m_updateTimer->start( 1000 * 60 * m_autoUpdateInterval ); - return; - } - } -} - -SqlPodcastProvider::~SqlPodcastProvider() -{ - foreach( Podcasts::SqlPodcastChannelPtr channel, m_channels ) - { - channel->updateInDb(); - foreach( Podcasts::SqlPodcastEpisodePtr episode, channel->sqlEpisodes() ) - episode->updateInDb(); - } - m_channels.clear(); - - Amarok::config( "Podcasts" ) - .writeEntry( "AutoUpdate Interval", m_autoUpdateInterval ); - Amarok::config( "Podcasts" ) - .writeEntry( "Maximum Simultaneous Downloads", m_maxConcurrentDownloads ); - Amarok::config( "Podcasts" ) - .writeEntry( "Maximum Simultaneous Updates", m_maxConcurrentUpdates ); -} - -void -SqlPodcastProvider::loadPodcasts() -{ - m_channels.clear(); - SqlStorage *sqlStorage = StorageManager::instance()->sqlStorage(); - if( !sqlStorage ) - return; - - QStringList results = sqlStorage->query( "SELECT id, url, title, weblink, image" - ", description, copyright, directory, labels, subscribedate, autoscan, fetchtype" - ", haspurge, purgecount, writetags, filenamelayout FROM podcastchannels;" ); - - int rowLength = 16; - for( int i = 0; i < results.size(); i += rowLength ) - { - QStringList channelResult = results.mid( i, rowLength ); - SqlPodcastChannelPtr channel = - SqlPodcastChannelPtr( new SqlPodcastChannel( this, channelResult ) ); - if( channel->image().isNull() ) - fetchImage( channel ); - - m_channels << channel; - } - if( m_podcastImageFetcher ) - m_podcastImageFetcher->run(); - emit updated(); -} - -SqlPodcastEpisodePtr -SqlPodcastProvider::sqlEpisodeForString( const QString &string ) -{ - if( string.isEmpty() ) - return SqlPodcastEpisodePtr(); - - SqlStorage *sqlStorage = StorageManager::instance()->sqlStorage(); - if( !sqlStorage ) - return SqlPodcastEpisodePtr(); - - QString command = "SELECT id, url, channel, localurl, guid, " - "title, subtitle, sequencenumber, description, mimetype, pubdate, " - "duration, filesize, isnew, iskeep FROM podcastepisodes " - "WHERE guid='%1' OR url='%1' OR localurl='%1' ORDER BY id DESC;"; - command = command.arg( sqlStorage->escape( string ) ); - QStringList dbResult = sqlStorage->query( command ); - - if( dbResult.isEmpty() ) - return SqlPodcastEpisodePtr(); - - int episodeId = dbResult[0].toInt(); - int channelId = dbResult[2].toInt(); - bool found = false; - Podcasts::SqlPodcastChannelPtr channel; - foreach( channel, m_channels ) - { - if( channel->dbId() == channelId ) - { - found = true; - break; - } - } - - if( !found ) - { - error() << QString( "There is a track in the database with url/guid=%1 (%2) " - "but there is no channel with dbId=%3 in our list!" ) - .arg( string ).arg( episodeId ).arg( channelId ); - return SqlPodcastEpisodePtr(); - } - - Podcasts::SqlPodcastEpisodePtr episode; - foreach( episode, channel->sqlEpisodes() ) - if( episode->dbId() == episodeId ) - return episode; - - //The episode was found in the database but it's channel didn't have it in it's list. - //That probably is because it's beyond the purgecount limit or the tracks were not loaded yet. - return SqlPodcastEpisodePtr( new SqlPodcastEpisode( dbResult.mid( 0, 15 ), channel ) ); -} - -bool -SqlPodcastProvider::possiblyContainsTrack( const KUrl &url ) const -{ - SqlStorage *sqlStorage = StorageManager::instance()->sqlStorage(); - if( !sqlStorage ) - return false; - - QString command = "SELECT id FROM podcastepisodes WHERE guid='%1' OR url='%1' " - "OR localurl='%1';"; - command = command.arg( sqlStorage->escape( url.url() ) ); - - QStringList dbResult = sqlStorage->query( command ); - return !dbResult.isEmpty(); -} - -Meta::TrackPtr -SqlPodcastProvider::trackForUrl( const KUrl &url ) -{ - if( url.isEmpty() ) - return Meta::TrackPtr(); - - SqlPodcastEpisodePtr episode = sqlEpisodeForString( url.url() ); - - return Meta::TrackPtr::dynamicCast( episode ); -} - -Playlists::PlaylistList -SqlPodcastProvider::playlists() -{ - Playlists::PlaylistList playlistList; - - QListIterator i( m_channels ); - while( i.hasNext() ) - { - playlistList << Playlists::PlaylistPtr::staticCast( i.next() ); - } - return playlistList; -} - -QActionList -SqlPodcastProvider::providerActions() -{ - if( m_providerActions.isEmpty() ) - { - QAction *updateAllAction = new QAction( KIcon( "view-refresh-amarok" ), - i18n( "&Update All Channels" ), this ); - updateAllAction->setProperty( "popupdropper_svg_id", "update" ); - connect( updateAllAction, SIGNAL(triggered()), this, SLOT(updateAll()) ); - m_providerActions << updateAllAction; - - QAction *configureAction = new QAction( KIcon( "configure" ), - i18n( "&Configure General Settings" ), this ); - configureAction->setProperty( "popupdropper_svg_id", "configure" ); - connect( configureAction, SIGNAL(triggered()), this, SLOT(slotConfigureProvider()) ); - m_providerActions << configureAction; - - QAction *exportOpmlAction = new QAction( KIcon( "document-export" ), - i18n( "&Export subscriptions to OPML file" ), this ); - connect( exportOpmlAction, SIGNAL(triggered()), SLOT(slotExportOpml()) ); - m_providerActions << exportOpmlAction; - } - - return m_providerActions; -} - -QActionList -SqlPodcastProvider::playlistActions( const Playlists::PlaylistList &playlists ) -{ - QActionList actions; - SqlPodcastChannelList sqlChannels; - foreach( const Playlists::PlaylistPtr &playlist, playlists ) - { - SqlPodcastChannelPtr sqlChannel = SqlPodcastChannel::fromPlaylistPtr( playlist ); - if( sqlChannel ) - sqlChannels << sqlChannel; - } - - if( sqlChannels.isEmpty() ) - return actions; - - //TODO: add export OPML action for selected playlists only. Use the QAction::data() trick. - if( m_configureChannelAction == 0 ) - { - m_configureChannelAction = new QAction( KIcon( "configure" ), i18n( "&Configure" ), this ); - m_configureChannelAction->setProperty( "popupdropper_svg_id", "configure" ); - connect( m_configureChannelAction, SIGNAL(triggered()), SLOT(slotConfigureChannel()) ); - } - //only one channel can be configured at a time. - if( sqlChannels.count() == 1 ) - { - m_configureChannelAction->setData( QVariant::fromValue( sqlChannels.first() ) ); - actions << m_configureChannelAction; - } - - if( m_removeAction == 0 ) - { - m_removeAction = new QAction( KIcon( "news-unsubscribe" ), i18n( "&Remove Subscription" ), this ); - m_removeAction->setProperty( "popupdropper_svg_id", "remove" ); - connect( m_removeAction, SIGNAL(triggered()), SLOT(slotRemoveChannels()) ); - } - m_removeAction->setData( QVariant::fromValue( sqlChannels ) ); - actions << m_removeAction; - - if( m_updateAction == 0 ) - { - m_updateAction = new QAction( KIcon( "view-refresh-amarok" ), i18n( "&Update Channel" ), this ); - m_updateAction->setProperty( "popupdropper_svg_id", "update" ); - connect( m_updateAction, SIGNAL(triggered()), SLOT(slotUpdateChannels()) ); - } - m_updateAction->setData( QVariant::fromValue( sqlChannels ) ); - actions << m_updateAction; - - return actions; -} - -QActionList -SqlPodcastProvider::trackActions( const QMultiHash &playlistTracks ) -{ - SqlPodcastEpisodeList episodes; - foreach( const Playlists::PlaylistPtr &playlist, playlistTracks.uniqueKeys() ) - { - SqlPodcastChannelPtr sqlChannel = SqlPodcastChannel::fromPlaylistPtr( playlist ); - if( !sqlChannel ) - continue; - - SqlPodcastEpisodeList channelEpisodes = sqlChannel->sqlEpisodes(); - QList trackPositions = playlistTracks.values( playlist ); - qSort( trackPositions ); - foreach( int trackPosition, trackPositions ) - { - if( trackPosition >= 0 && trackPosition < channelEpisodes.count() ) - episodes << channelEpisodes.at( trackPosition ); - } - } - - QActionList actions; - if( episodes.isEmpty() ) - return actions; - - if( m_downloadAction == 0 ) - { - m_downloadAction = new QAction( KIcon( "go-down" ), i18n( "&Download Episode" ), this ); - m_downloadAction->setProperty( "popupdropper_svg_id", "download" ); - connect( m_downloadAction, SIGNAL(triggered()), SLOT(slotDownloadEpisodes()) ); - } - - if( m_deleteAction == 0 ) - { - m_deleteAction = new QAction( KIcon( "edit-delete" ), - i18n( "&Delete Downloaded Episode" ), this ); - m_deleteAction->setProperty( "popupdropper_svg_id", "delete" ); - m_deleteAction->setObjectName( "deleteAction" ); - connect( m_deleteAction, SIGNAL(triggered()), SLOT(slotDeleteDownloadedEpisodes()) ); - } - - if( m_writeTagsAction == 0 ) - { - m_writeTagsAction = new QAction( KIcon( "media-track-edit-amarok" ), - i18n( "&Write Feed Information to File" ), this ); - m_writeTagsAction->setProperty( "popupdropper_svg_id", "edit" ); - connect( m_writeTagsAction, SIGNAL(triggered()), SLOT(slotWriteTagsToFiles()) ); - } - - if( m_keepAction == 0 ) - { - m_keepAction = new QAction( KIcon( "podcast-amarok" ), - i18n( "&Keep downloaded file" ), this ); - m_keepAction->setToolTip( i18n( "Toggle the \"keep\" downloaded file status of " - "this podcast episode. Downloaded files with this status wouldn't be " - "deleted even if we apply a purge." ) ); - m_keepAction->setProperty( "popupdropper_svg_id", "keep" ); - m_keepAction->setCheckable( true ); - connect( m_keepAction, SIGNAL(triggered(bool)), SLOT(slotSetKeep()) ); - } - - SqlPodcastEpisodeList remoteEpisodes; - SqlPodcastEpisodeList keptDownloadedEpisodes, unkeptDownloadedEpisodes; - foreach( const SqlPodcastEpisodePtr &episode, episodes ) - { - if( episode->localUrl().isEmpty() ) - remoteEpisodes << episode; - else - { - if( episode->isKeep() ) - keptDownloadedEpisodes << episode; - else - unkeptDownloadedEpisodes << episode; - } - } - - if( !remoteEpisodes.isEmpty() ) - { - m_downloadAction->setData( QVariant::fromValue( remoteEpisodes ) ); - actions << m_downloadAction; - } - if( !( keptDownloadedEpisodes + unkeptDownloadedEpisodes ).isEmpty() ) - { - m_deleteAction->setData( QVariant::fromValue( keptDownloadedEpisodes + unkeptDownloadedEpisodes ) ); - actions << m_deleteAction; - - m_keepAction->setChecked( unkeptDownloadedEpisodes.isEmpty() ); - m_keepAction->setData( QVariant::fromValue( keptDownloadedEpisodes + unkeptDownloadedEpisodes ) ); - actions << m_keepAction; - } - - return actions; -} - -Podcasts::PodcastEpisodePtr -SqlPodcastProvider::episodeForGuid( const QString &guid ) -{ - return PodcastEpisodePtr::dynamicCast( sqlEpisodeForString( guid ) ); -} - -void -SqlPodcastProvider::addPodcast( const KUrl &url ) -{ - KUrl kurl = KUrl( url ); - debug() << "importing " << kurl.url(); - - SqlStorage *sqlStorage = StorageManager::instance()->sqlStorage(); - if( !sqlStorage ) - return; - - QString command = "SELECT title FROM podcastchannels WHERE url='%1';"; - command = command.arg( sqlStorage->escape( kurl.url() ) ); - - QStringList dbResult = sqlStorage->query( command ); - if( !dbResult.isEmpty() ) - { - //Already subscribed to this Channel - //notify the user. - Amarok::Components::logger()->longMessage( - i18n( "Already subscribed to %1.", dbResult.first() ), Amarok::Logger::Error ); - } - else - { - subscribe( kurl ); - } -} - -void -SqlPodcastProvider::updateAll() -{ - foreach( Podcasts::SqlPodcastChannelPtr channel, m_channels ) - updateSqlChannel( channel ); -} - -void -SqlPodcastProvider::subscribe( const KUrl &url ) -{ - if( !url.isValid() ) - return; - - if( m_updatingChannels >= m_maxConcurrentUpdates ) - { - debug() << QString( "Maximum concurrent updates (%1) reached. " - "Queueing \"%2\" for subscribing." ) - .arg( m_maxConcurrentUpdates ) - .arg( url.url() ); - m_subscribeQueue << url; - return; - } - - PodcastReader *podcastReader = new PodcastReader( this ); - connect( podcastReader, SIGNAL(finished(PodcastReader*)), - SLOT(slotReadResult(PodcastReader*)) ); - connect( podcastReader, SIGNAL(statusBarSorryMessage(QString)), - this, SLOT(slotStatusBarSorryMessage(QString)) ); - connect( podcastReader, - SIGNAL(statusBarNewProgressOperation( KIO::TransferJob *, const QString &, - Podcasts::PodcastReader* )), - SLOT(slotStatusBarNewProgressOperation( KIO::TransferJob *, const QString &, - Podcasts::PodcastReader* )) - ); - - m_updatingChannels++; - podcastReader->read( url ); -} - -Podcasts::PodcastChannelPtr -SqlPodcastProvider::addChannel( Podcasts::PodcastChannelPtr channel ) -{ - Podcasts::SqlPodcastChannelPtr sqlChannel = - SqlPodcastChannelPtr( new Podcasts::SqlPodcastChannel( this, channel ) ); - m_channels << sqlChannel; - - if( sqlChannel->episodes().count() == 0 ) - updateSqlChannel( sqlChannel ); - - emit playlistAdded( Playlists::PlaylistPtr( sqlChannel.data() ) ); - return PodcastChannelPtr( sqlChannel.data() ); -} - -Podcasts::PodcastEpisodePtr -SqlPodcastProvider::addEpisode( Podcasts::PodcastEpisodePtr episode ) -{ - Podcasts::SqlPodcastEpisodePtr sqlEpisode = - Podcasts::SqlPodcastEpisodePtr::dynamicCast( episode ); - if( sqlEpisode.isNull() ) - return Podcasts::PodcastEpisodePtr(); - - if( sqlEpisode->channel().isNull() ) - { - debug() << "channel is null"; - return Podcasts::PodcastEpisodePtr(); - } - - if( sqlEpisode->channel()->fetchType() == Podcasts::PodcastChannel::DownloadWhenAvailable ) - downloadEpisode( sqlEpisode ); - return Podcasts::PodcastEpisodePtr::dynamicCast( sqlEpisode ); -} - -Podcasts::PodcastChannelList -SqlPodcastProvider::channels() -{ - PodcastChannelList list; - QListIterator i( m_channels ); - while( i.hasNext() ) - { - list << PodcastChannelPtr::dynamicCast( i.next() ); - } - return list; -} - -void -SqlPodcastProvider::removeSubscription( Podcasts::SqlPodcastChannelPtr sqlChannel ) -{ - debug() << "Deleting channel " << sqlChannel->title(); - sqlChannel->deleteFromDb(); - - m_channels.removeOne( sqlChannel ); - - //HACK: because of a database "leak" in the past we have orphan data in the tables. - //Remove it when we know it's supposed to be empty. - if( m_channels.isEmpty() ) - { - SqlStorage *sqlStorage = StorageManager::instance()->sqlStorage(); - if( !sqlStorage ) - return; - debug() << "Unsubscribed from last channel, cleaning out the podcastepisodes table."; - sqlStorage->query( "DELETE FROM podcastepisodes WHERE 1;" ); - } - - emit playlistRemoved( Playlists::PlaylistPtr::dynamicCast( sqlChannel ) ); -} - -void -SqlPodcastProvider::configureProvider() -{ - m_providerSettingsDialog = new KDialog( The::mainWindow() ); - QWidget *settingsWidget = new QWidget( m_providerSettingsDialog ); - m_providerSettingsDialog->setObjectName( "SqlPodcastProviderSettings" ); - Ui::SqlPodcastProviderSettingsWidget settings; - m_providerSettingsWidget = &settings; - settings.setupUi( settingsWidget ); - - settings.m_baseDirUrl->setMode( KFile::Directory ); - settings.m_baseDirUrl->setUrl( m_baseDownloadDir ); - - settings.m_autoUpdateInterval->setValue( m_autoUpdateInterval ); - settings.m_autoUpdateInterval->setPrefix( - i18nc( "prefix to 'x minutes'", "every " ) ); - settings.m_autoUpdateInterval->setSuffix( ki18np( " minute", " minutes" ) ); - - m_providerSettingsDialog->setButtons( KDialog::Ok | KDialog::Cancel | KDialog::Apply ); - m_providerSettingsDialog->setMainWidget( settingsWidget ); - - connect( settings.m_baseDirUrl, SIGNAL(textChanged(QString)), SLOT(slotConfigChanged()) ); - connect( settings.m_autoUpdateInterval, SIGNAL(valueChanged(int)), - SLOT(slotConfigChanged()) ); - - m_providerSettingsDialog->setWindowTitle( i18n( "Configure Local Podcasts" ) ); - m_providerSettingsDialog->enableButtonApply( false ); - - if( m_providerSettingsDialog->exec() == QDialog::Accepted ) - { - m_autoUpdateInterval = settings.m_autoUpdateInterval->value(); - if( m_autoUpdateInterval ) - startTimer(); - else - m_updateTimer->stop(); - KUrl adjustedNewPath = settings.m_baseDirUrl->url(); - adjustedNewPath.adjustPath( KUrl::RemoveTrailingSlash ); - if( adjustedNewPath != m_baseDownloadDir ) - { - m_baseDownloadDir = adjustedNewPath; - Amarok::config( "Podcasts" ).writeEntry( "Base Download Directory", m_baseDownloadDir ); - if( !m_channels.isEmpty() ) - { - //TODO: check if there actually are downloaded episodes - KDialog moveAllDialog; - moveAllDialog.setCaption( i18n( "Move Podcasts" ) ); - - KVBox *vbox = new KVBox( &moveAllDialog ); - - QString question( i18n( "Do you want to move all downloaded episodes to the " - "new location?") ); - QLabel *label = new QLabel( question, vbox ); - label->setWordWrap( true ); - label->setMaximumWidth( 400 ); - - moveAllDialog.setMainWidget( vbox ); - moveAllDialog.setButtons( KDialog::Yes | KDialog::No ); - - if( moveAllDialog.exec() == KDialog::Yes ) - { - foreach( SqlPodcastChannelPtr sqlChannel, m_channels ) - { - KUrl oldSaveLocation = sqlChannel->saveLocation(); - KUrl newSaveLocation = m_baseDownloadDir; - newSaveLocation.addPath( oldSaveLocation.fileName() ); - sqlChannel->setSaveLocation( newSaveLocation ); - debug() << newSaveLocation.path(); - moveDownloadedEpisodes( sqlChannel ); - - if( !QDir().rmdir( oldSaveLocation.toLocalFile() ) ) - debug() << "Could not remove old directory " - << oldSaveLocation.toLocalFile(); - } - } - } - } - } - - delete m_providerSettingsDialog; - m_providerSettingsDialog = 0; - m_providerSettingsWidget = 0; -} - -void -SqlPodcastProvider::slotConfigChanged() -{ - if( !m_providerSettingsWidget ) - return; - - if( m_providerSettingsWidget->m_autoUpdateInterval->value() != m_autoUpdateInterval - || m_providerSettingsWidget->m_baseDirUrl->url() != m_baseDownloadDir ) - { - m_providerSettingsDialog->enableButtonApply( true ); - } -} - -void -SqlPodcastProvider::slotExportOpml() -{ - QList rootOutlines; - QMap headerData; - //TODO: set header data such as date - - //TODO: folder outline support - foreach( SqlPodcastChannelPtr channel, m_channels ) - { - OpmlOutline *channelOutline = new OpmlOutline(); - #define addAttr( k, v ) channelOutline->addAttribute( k, v ) - addAttr( "text", channel->title() ); - addAttr( "type", "rss" ); - addAttr( "xmlUrl", channel->url().url() ); - rootOutlines << channelOutline; - } - - //TODO: add checkbox as widget to filedialog to include podcast settings. - KFileDialog fileDialog( KUrl( "kfiledialog:///podcast/amarok_podcasts.opml"), "*.opml", - The::mainWindow() ); - fileDialog.setMode( KFile::File ); - fileDialog.setCaption( i18n( "Select file for OPML export") ); - if( fileDialog.exec() != KDialog::Accepted ) - return; - - KUrl filePath = fileDialog.selectedUrl(); - - QFile *opmlFile = new QFile( filePath.toLocalFile(), this ); - if( !opmlFile->open( QIODevice::WriteOnly | QIODevice::Truncate ) ) - { - error() << "could not open OPML file " << filePath.url(); - return; - } - OpmlWriter *opmlWriter = new OpmlWriter( rootOutlines, headerData, opmlFile ); - connect( opmlWriter, SIGNAL(result(int)), SLOT(slotOpmlWriterDone(int)) ); - opmlWriter->run(); -} - -void -SqlPodcastProvider::slotOpmlWriterDone( int result ) -{ - Q_UNUSED( result ) - - OpmlWriter *writer = qobject_cast( QObject::sender() ); - Q_ASSERT( writer ); - writer->device()->close(); - delete writer; -} - -void -SqlPodcastProvider::configureChannel( Podcasts::SqlPodcastChannelPtr sqlChannel ) -{ - if( !sqlChannel ) - return; - - KUrl oldUrl = sqlChannel->url(); - KUrl oldSaveLocation = sqlChannel->saveLocation(); - bool oldHasPurge = sqlChannel->hasPurge(); - int oldPurgeCount = sqlChannel->purgeCount(); - bool oldAutoScan = sqlChannel->autoScan(); - - PodcastSettingsDialog dialog( sqlChannel, The::mainWindow() ); - dialog.configure(); - - sqlChannel->updateInDb(); - - if( ( oldHasPurge && !sqlChannel->hasPurge() ) - || ( oldPurgeCount < sqlChannel->purgeCount() ) ) - { - /* changed from purge to no-purge or increase purge count: - we need to reload all episodes from the database. */ - sqlChannel->loadEpisodes(); - } - else - sqlChannel->applyPurge(); - - emit updated(); - - if( oldSaveLocation != sqlChannel->saveLocation() ) - { - moveDownloadedEpisodes( sqlChannel ); - if( !QDir().rmdir( oldSaveLocation.toLocalFile() ) ) - debug() << "Could not remove old directory " << oldSaveLocation.toLocalFile(); - } - - //if the url changed force an update. - if( oldUrl != sqlChannel->url() ) - updateSqlChannel( sqlChannel ); - - //start autoscan in case it wasn't already - if( sqlChannel->autoScan() && !oldAutoScan ) - startTimer(); -} - -void -SqlPodcastProvider::deleteDownloadedEpisodes( Podcasts::SqlPodcastEpisodeList &episodes ) -{ - foreach( Podcasts::SqlPodcastEpisodePtr episode, episodes ) - deleteDownloadedEpisode( episode ); -} - -void -SqlPodcastProvider::moveDownloadedEpisodes( Podcasts::SqlPodcastChannelPtr sqlChannel ) -{ - debug() << QString( "We need to move downloaded episodes of \"%1\" to %2" ) - .arg( sqlChannel->title() ) - .arg( sqlChannel->saveLocation().prettyUrl() ); - - KUrl::List filesToMove; - foreach( Podcasts::SqlPodcastEpisodePtr episode, sqlChannel->sqlEpisodes() ) - { - if( !episode->localUrl().isEmpty() ) - { - KUrl newLocation = sqlChannel->saveLocation(); - QDir dir( newLocation.toLocalFile() ); - dir.mkpath( "." ); - - newLocation.addPath( episode->localUrl().fileName() ); - debug() << "Moving from " << episode->localUrl() << " to " << newLocation; - KIO::Job *moveJob = KIO::move( episode->localUrl(), newLocation, - KIO::HideProgressInfo ); - //wait until job is finished. - if( KIO::NetAccess::synchronousRun( moveJob, The::mainWindow() ) ) - episode->setLocalUrl( newLocation ); - } - } -} - -void -SqlPodcastProvider::slotDeleteDownloadedEpisodes() -{ - QAction *action = qobject_cast( QObject::sender() ); - if( action == 0 ) - return; - Podcasts::SqlPodcastEpisodeList episodes = action->data().value(); - deleteDownloadedEpisodes( episodes ); -} - -void -SqlPodcastProvider::slotDownloadEpisodes() -{ - QAction *action = qobject_cast( QObject::sender() ); - if( action == 0 ) - return; - Podcasts::SqlPodcastEpisodeList episodes = action->data().value(); - - foreach( Podcasts::SqlPodcastEpisodePtr episode, episodes ) - downloadEpisode( episode ); -} - -void -SqlPodcastProvider::slotSetKeep() -{ - QAction *action = qobject_cast( QObject::sender() ); - if( action == 0 ) - return; - - Podcasts::SqlPodcastEpisodeList episodes = action->data().value(); - - foreach( Podcasts::SqlPodcastEpisodePtr episode, episodes ) - episode->setKeep( action->isChecked() ); -} - -QPair -SqlPodcastProvider::confirmUnsubscribe( Podcasts::SqlPodcastChannelPtr channel ) -{ - KDialog unsubscribeDialog; - unsubscribeDialog.setCaption( i18n( "Unsubscribe" ) ); - - KVBox *vbox = new KVBox( &unsubscribeDialog ); - - QString question( i18n( "Do you really want to unsubscribe from \"%1\"?", channel->title() ) ); - QLabel *label = new QLabel( question, vbox ); - label->setWordWrap( true ); - label->setMaximumWidth( 400 ); - - QCheckBox *deleteMediaCheckBox = new QCheckBox( i18n( "Delete downloaded episodes" ), vbox ); - unsubscribeDialog.setMainWidget( vbox ); - unsubscribeDialog.setButtons( KDialog::Ok | KDialog::Cancel ); - - QPair result; - result.first = unsubscribeDialog.exec() == QDialog::Accepted; - result.second = deleteMediaCheckBox->isChecked(); - return result; -} - -void -SqlPodcastProvider::slotRemoveChannels() -{ - QAction *action = qobject_cast( QObject::sender() ); - if( action == 0 ) - return; - - Podcasts::SqlPodcastChannelList channels = action->data().value(); - - foreach( Podcasts::SqlPodcastChannelPtr channel, channels ) - { - QPair result = confirmUnsubscribe( channel ); - if( result.first ) - { - debug() << "unsubscribing " << channel->title(); - if( result.second ) - { - debug() << "removing all episodes"; - Podcasts::SqlPodcastEpisodeList sqlEpisodes = channel->sqlEpisodes(); - deleteDownloadedEpisodes( sqlEpisodes ); - } - removeSubscription( channel ); - } - } -} - -void -SqlPodcastProvider::slotUpdateChannels() -{ - QAction *action = qobject_cast( QObject::sender() ); - if( action == 0 ) - return; - Podcasts::SqlPodcastChannelList channels = action->data().value(); - - foreach( Podcasts::SqlPodcastChannelPtr channel, channels ) - updateSqlChannel( channel ); -} - -void -SqlPodcastProvider::slotDownloadProgress( KJob *job, unsigned long percent ) -{ - Q_UNUSED( job ); - Q_UNUSED( percent ); - - unsigned int totalDownloadPercentage = 0; - foreach( const KJob *jobKey, m_downloadJobMap.keys() ) - totalDownloadPercentage += jobKey->percent(); - - //keep the completed jobs in mind as well. - totalDownloadPercentage += m_completedDownloads * 100; - - emit totalPodcastDownloadProgress( - totalDownloadPercentage / ( m_downloadJobMap.count() + m_completedDownloads ) ); -} - -void -SqlPodcastProvider::slotWriteTagsToFiles() -{ - QAction *action = qobject_cast( QObject::sender() ); - if( action == 0 ) - return; - - Podcasts::SqlPodcastEpisodeList episodes = action->data().value(); - foreach( Podcasts::SqlPodcastEpisodePtr episode, episodes ) - episode->writeTagsToFile(); -} - -void -SqlPodcastProvider::slotConfigureChannel() -{ - QAction *action = qobject_cast( QObject::sender() ); - if( action == 0 ) - return; - - Podcasts::SqlPodcastChannelPtr podcastChannel = action->data().value(); - if( !podcastChannel.isNull() ) - configureChannel( podcastChannel ); -} - -void -SqlPodcastProvider::deleteDownloadedEpisode( Podcasts::SqlPodcastEpisodePtr episode ) -{ - if( !episode || episode->localUrl().isEmpty() ) - return; - - debug() << "deleting " << episode->title(); - KIO::del( episode->localUrl(), KIO::HideProgressInfo ); - - episode->setLocalUrl( KUrl() ); - - emit episodeDeleted( Podcasts::PodcastEpisodePtr::dynamicCast( episode ) ); -} - -Podcasts::SqlPodcastChannelPtr -SqlPodcastProvider::podcastChannelForId( int podcastChannelId ) -{ - QListIterator i( m_channels ); - while( i.hasNext() ) - { - int id = i.next()->dbId(); - if( id == podcastChannelId ) - return i.previous(); - } - return Podcasts::SqlPodcastChannelPtr(); -} - -void -SqlPodcastProvider::completePodcastDownloads() -{ - //check to see if there are still downloads in progress - if( !m_downloadJobMap.isEmpty() ) - { - debug() << QString( "There are still %1 podcast download jobs running!" ) - .arg( m_downloadJobMap.count() ); - KProgressDialog progressDialog( The::mainWindow(), - i18n( "Waiting for Podcast Downloads to Finish" ), - i18np( "There is still a podcast download in progress", - "There are still %1 podcast downloads in progress", - m_downloadJobMap.count() ) - ); - progressDialog.setButtonText( i18n("Cancel Download and Quit.") ); - - m_completedDownloads = 0; - foreach( KJob *job, m_downloadJobMap.keys() ) - { - connect( job, SIGNAL(percent(KJob*,ulong)), - SLOT(slotDownloadProgress(KJob*,ulong)) - ); - } - connect( this, SIGNAL(totalPodcastDownloadProgress(int)), - progressDialog.progressBar(), SLOT(setValue(int)) ); - int result = progressDialog.exec(); - if( result == QDialog::Rejected ) - { - foreach( KJob *job, m_downloadJobMap.keys() ) - { - job->kill(); - } - } - } -} - -void -SqlPodcastProvider::autoUpdate() -{ - if( Solid::Networking::status() != Solid::Networking::Connected - && Solid::Networking::status() != Solid::Networking::Unknown ) - { - debug() << "Solid reports we are not online, canceling podcast auto-update"; - return; - } - - foreach( Podcasts::SqlPodcastChannelPtr channel, m_channels ) - { - if( channel->autoScan() ) - updateSqlChannel( channel ); - } -} - -void -SqlPodcastProvider::updateSqlChannel( Podcasts::SqlPodcastChannelPtr channel ) -{ - if( channel.isNull() ) - return; - if( m_updatingChannels >= m_maxConcurrentUpdates ) - { - debug() << QString( "Maximum concurrent updates (%1) reached. " - "Queueing \"%2\" for download." ) - .arg( m_maxConcurrentUpdates ) - .arg( channel->title() ); - m_updateQueue << channel; - return; - } - - PodcastReader *podcastReader = new PodcastReader( this ); - - connect( podcastReader, SIGNAL(finished(PodcastReader*)), - SLOT(slotReadResult(PodcastReader*)) ); - connect( podcastReader, SIGNAL(statusBarSorryMessage(QString)), - this, SLOT(slotStatusBarSorryMessage(QString)) ); - connect( podcastReader, SIGNAL(statusBarNewProgressOperation(KIO::TransferJob*,QString,Podcasts::PodcastReader*)), - this, SLOT(slotStatusBarNewProgressOperation(KIO::TransferJob*,QString,Podcasts::PodcastReader*)) ); - - m_updatingChannels++; - podcastReader->update( Podcasts::PodcastChannelPtr::dynamicCast( channel ) ); -} - -void -SqlPodcastProvider::slotReadResult( Podcasts::PodcastReader *podcastReader ) -{ - if( podcastReader->error() != QXmlStreamReader::NoError ) - { - debug() << podcastReader->errorString(); - Amarok::Components::logger()->longMessage( podcastReader->errorString(), - Amarok::Logger::Error ); - } - debug() << "Finished updating: " << podcastReader->url(); - --m_updatingChannels; - debug() << "Updating counter reached " << m_updatingChannels; - - Podcasts::SqlPodcastChannelPtr channel = - Podcasts::SqlPodcastChannelPtr::dynamicCast( podcastReader->channel() ); - - if( channel.isNull() ) - { - error() << "Could not cast to SqlPodcastChannel " << __FILE__ << ":" << __LINE__; - return; - } - - if( channel->image().isNull() ) - { - fetchImage( channel ); - } - - channel->updateInDb(); - - podcastReader->deleteLater(); - - //first we work through the list of new subscriptions - if( !m_subscribeQueue.isEmpty() ) - { - subscribe( m_subscribeQueue.takeFirst() ); - } - else if( !m_updateQueue.isEmpty() ) - { - updateSqlChannel( m_updateQueue.takeFirst() ); - } - else if( m_updatingChannels == 0 ) - { - //TODO: start downloading episodes here. - if( m_podcastImageFetcher ) - m_podcastImageFetcher->run(); - } -} - -void -SqlPodcastProvider::slotStatusBarNewProgressOperation( KIO::TransferJob * job, - const QString &description, - Podcasts::PodcastReader* reader ) -{ - Amarok::Components::logger()->newProgressOperation( job, description, reader, SLOT(slotAbort()) ); -} - -void -SqlPodcastProvider::downloadEpisode( Podcasts::SqlPodcastEpisodePtr sqlEpisode ) -{ - if( sqlEpisode.isNull() ) - { - error() << "SqlPodcastProvider::downloadEpisode( Podcasts::SqlPodcastEpisodePtr sqlEpisode ) was called for a non-SqlPodcastEpisode"; - return; - } - - foreach( struct PodcastEpisodeDownload download, m_downloadJobMap ) - { - if( download.episode == sqlEpisode ) - { - debug() << "already downloading " << sqlEpisode->uidUrl(); - return; - } - } - - if( m_downloadJobMap.size() >= m_maxConcurrentDownloads ) - { - debug() << QString( "Maximum concurrent downloads (%1) reached. " - "Queueing \"%2\" for download." ) - .arg( m_maxConcurrentDownloads ) - .arg( sqlEpisode->title() ); - //put into a FIFO which is used in downloadResult() to start a new download - m_downloadQueue << sqlEpisode; - return; - } - - KIO::TransferJob *transferJob = - KIO::get( sqlEpisode->uidUrl(), KIO::Reload, KIO::HideProgressInfo ); - - - QFile *tmpFile = createTmpFile( sqlEpisode ); - struct PodcastEpisodeDownload download = { sqlEpisode, - tmpFile, - /* Unless a redirect happens the filename from the enclosure is used. This is a potential source - of filename conflicts in downloadResult() */ - KUrl( sqlEpisode->uidUrl() ).fileName(), - false - }; - m_downloadJobMap.insert( transferJob, download ); - - if( tmpFile->exists() ) - { - qint64 offset = tmpFile->size(); - debug() << "temporary file exists, resume download from offset " << offset; - QMap resumeData; - resumeData.insert( "resume", QString::number( offset ) ); - transferJob->addMetaData( resumeData ); - } - - if( !tmpFile->open( QIODevice::WriteOnly | QIODevice::Append ) ) - { - Amarok::Components::logger()->longMessage( i18n( "Unable to save podcast episode file to %1", - tmpFile->fileName() ) ); - delete tmpFile; - return; - } - - debug() << "starting download for " << sqlEpisode->title() - << " url: " << sqlEpisode->prettyUrl(); - Amarok::Components::logger()->newProgressOperation( transferJob - , sqlEpisode->title().isEmpty() - ? i18n( "Downloading Podcast Media" ) - : i18n( "Downloading Podcast \"%1\"" - , sqlEpisode->title() ), - transferJob, - SLOT(kill()) - ); - - connect( transferJob, SIGNAL(data(KIO::Job*,QByteArray)), - SLOT(addData(KIO::Job*,QByteArray)) ); - //need to connect to finished instead of result because it's always emitted. - //We need to cleanup after a download is cancled regardless of the argument in - //KJob::kill() - connect( transferJob, SIGNAL(finished(KJob*)), - SLOT(downloadResult(KJob*)) ); - connect( transferJob, SIGNAL(redirection(KIO::Job*,KUrl)), - SLOT(redirected(KIO::Job*,KUrl)) ); -} - -void -SqlPodcastProvider::downloadEpisode( Podcasts::PodcastEpisodePtr episode ) -{ - downloadEpisode( SqlPodcastEpisodePtr::dynamicCast( episode ) ); -} - -void -SqlPodcastProvider::cleanupDownload( KJob *job, bool downloadFailed ) -{ - struct PodcastEpisodeDownload download = m_downloadJobMap.value( job ); - QFile *tmpFile = download.tmpFile; - - if( downloadFailed && tmpFile ) - { - debug() << "deleting temporary podcast file: " << tmpFile->fileName(); - tmpFile->remove(); - } - m_downloadJobMap.remove( job ); - - delete tmpFile; -} - -QFile * -SqlPodcastProvider::createTmpFile( Podcasts::SqlPodcastEpisodePtr sqlEpisode ) -{ - if( sqlEpisode.isNull() ) - { - error() << "sqlEpisodePtr is NULL after download"; - return 0; - } - Podcasts::SqlPodcastChannelPtr sqlChannel = - Podcasts::SqlPodcastChannelPtr::dynamicCast( sqlEpisode->channel() ); - if( sqlChannel.isNull() ) - { - error() << "sqlChannelPtr is NULL after download"; - return 0; - } - - QDir dir( sqlChannel->saveLocation().toLocalFile() ); - dir.mkpath( "." ); // ensure that the path is there - //TODO: what if result is false? - - KUrl localUrl = KUrl::fromPath( dir.absolutePath() ); - QString tempName; - if( !sqlEpisode->guid().isEmpty() ) - tempName = QUrl::toPercentEncoding( sqlEpisode->guid() ); - else - tempName = QUrl::toPercentEncoding( sqlEpisode->uidUrl() ); - - QString tempNameMd5( KMD5( tempName.toUtf8() ).hexDigest() ); - - localUrl.addPath( tempNameMd5 + PODCAST_TMP_POSTFIX ); - - return new QFile( localUrl.toLocalFile() ); -} - -bool -SqlPodcastProvider::checkEnclosureLocallyAvailable( KIO::Job *job ) -{ - struct PodcastEpisodeDownload download = m_downloadJobMap.value( job ); - Podcasts::SqlPodcastEpisodePtr sqlEpisode = download.episode; - if( sqlEpisode.isNull() ) - { - error() << "sqlEpisodePtr is NULL after download"; - return false; - } - Podcasts::SqlPodcastChannelPtr sqlChannel = - Podcasts::SqlPodcastChannelPtr::dynamicCast( sqlEpisode->channel() ); - if( sqlChannel.isNull() ) - { - error() << "sqlChannelPtr is NULL after download"; - return false; - } - - QString fileName = sqlChannel->saveLocation().toLocalFile( KUrl::AddTrailingSlash ); - fileName += download.fileName; - debug() << "checking " << fileName; - QFileInfo fileInfo( fileName ); - if( !fileInfo.exists() ) - return false; - - debug() << fileName << " already exists, no need to redownload"; - // NOTE: we need to emit because the KJobProgressBar relies on it to clean up - job->kill( KJob::EmitResult ); - sqlEpisode->setLocalUrl( fileName ); - //TODO: repaint icons, probably with signal metadataUpdate() - return true; -} - -void -SqlPodcastProvider::addData( KIO::Job *job, const QByteArray &data ) -{ - if( !data.size() ) - { - return; // EOF - } - - struct PodcastEpisodeDownload &download = m_downloadJobMap[job]; - - // NOTE: if there is a tmpfile we are already downloading, no need to - // checkEnclosureLocallyAvailable() on every data chunk. performance optimization. - if( !download.finalNameReady ) - { - download.finalNameReady = true; - if( checkEnclosureLocallyAvailable( job ) ) - return; - } - - if( download.tmpFile->write( data ) == -1 ) - { - error() << "write error for " << download.tmpFile->fileName() << ": " - << download.tmpFile->errorString(); - job->kill(); - } -} - -void -SqlPodcastProvider::deleteDownloadedEpisode( Podcasts::PodcastEpisodePtr episode ) -{ - deleteDownloadedEpisode( SqlPodcastEpisodePtr::dynamicCast( episode ) ); -} - -void -SqlPodcastProvider::slotStatusBarSorryMessage( const QString &message ) -{ - Amarok::Components::logger()->longMessage( message, Amarok::Logger::Error ); -} - -void -SqlPodcastProvider::downloadResult( KJob *job ) -{ - struct PodcastEpisodeDownload download = m_downloadJobMap.value( job ); - QFile *tmpFile = download.tmpFile; - bool downloadFailed = false; - - if( job->error() ) - { - // NOTE: prevents empty error notifications from popping up - // in the statusbar when the user cancels a download - if( job->error() != KJob::KilledJobError ) - { - Amarok::Components::logger()->longMessage( job->errorText() ); - } - error() << "Unable to retrieve podcast media. KIO Error: " << job->errorText(); - error() << "keeping temporary file for download restart"; - downloadFailed = false; - } - else - { - Podcasts::SqlPodcastEpisodePtr sqlEpisode = download.episode; - if( sqlEpisode.isNull() ) - { - error() << "sqlEpisodePtr is NULL after download"; - cleanupDownload( job, true ); - return; - } - Podcasts::SqlPodcastChannelPtr sqlChannel = - Podcasts::SqlPodcastChannelPtr::dynamicCast( sqlEpisode->channel() ); - if( sqlChannel.isNull() ) - { - error() << "sqlChannelPtr is NULL after download"; - cleanupDownload( job, true ); - return; - } - - Amarok::QStringx filenameLayout = Amarok::QStringx( sqlChannel->filenameLayout() ); - QMap layoutmap; - QString sequenceNumber; - - if( sqlEpisode->artist() ) - layoutmap.insert( "artist", sqlEpisode->artist()->prettyName() ); - - layoutmap.insert( "title", sqlEpisode->title() ); - - if( sqlEpisode->genre() ) - layoutmap.insert( "genre", sqlEpisode->genre()->prettyName() ); - - if( sqlEpisode->year() ) - layoutmap.insert( "year", sqlEpisode->year()->prettyName() ); - - if( sqlEpisode->composer() ) - layoutmap.insert( "composer", sqlEpisode->composer()->prettyName() ); - - layoutmap.insert( "pubdate", sqlEpisode->pubDate().toString() ); - - sequenceNumber.sprintf( "%.6d", sqlEpisode->sequenceNumber() ); - layoutmap.insert( "number", sequenceNumber ); - - if( sqlEpisode->album() ) - layoutmap.insert( "album", sqlEpisode->album()->prettyName() ); - - if( !filenameLayout.isEmpty() && - Amarok::QStringx::compare( filenameLayout, "%default%", Qt::CaseInsensitive ) ) - { - filenameLayout = filenameLayout.namedArgs( layoutmap ); - //add the file extension to the filename - filenameLayout.append( QString( "." ) ); - filenameLayout.append( sqlEpisode->type() ); - download.fileName = QString( filenameLayout ); - } - - QString finalName = sqlChannel->saveLocation().toLocalFile( KUrl::AddTrailingSlash ) - + download.fileName; - if( tmpFile->rename( finalName ) ) - { - debug() << "successfully written Podcast Episode " << sqlEpisode->title() - << " to " << finalName; - sqlEpisode->setLocalUrl( finalName ); - - if( sqlChannel->writeTags() ) - sqlEpisode->writeTagsToFile(); - //TODO: force a redraw of the view so the icon can be updated in the PlaylistBrowser - - emit episodeDownloaded( Podcasts::PodcastEpisodePtr::dynamicCast( sqlEpisode ) ); - } - else - { - Amarok::Components::logger()->longMessage( i18n( "Unable to save podcast episode file to %1", - finalName ) ); - downloadFailed = true; - } - } - - //remove it from the jobmap - m_completedDownloads++; - cleanupDownload( job, downloadFailed ); - - //start a new download. We just finished one so there is at least one slot free. - if( !m_downloadQueue.isEmpty() ) - downloadEpisode( m_downloadQueue.takeFirst() ); -} - -void -SqlPodcastProvider::redirected( KIO::Job *job, const KUrl &redirectedUrl ) -{ - debug() << "redirecting to " << redirectedUrl << ". filename: " - << redirectedUrl.fileName(); - m_downloadJobMap[job].fileName = redirectedUrl.fileName(); -} - -void -SqlPodcastProvider::createTables() const -{ - SqlStorage *sqlStorage = StorageManager::instance()->sqlStorage(); - if( !sqlStorage ) - return; - - sqlStorage->query( QString( "CREATE TABLE podcastchannels (" - "id " + sqlStorage->idType() + - ",url " + sqlStorage->longTextColumnType() + - ",title " + sqlStorage->longTextColumnType() + - ",weblink " + sqlStorage->longTextColumnType() + - ",image " + sqlStorage->longTextColumnType() + - ",description " + sqlStorage->longTextColumnType() + - ",copyright " + sqlStorage->textColumnType() + - ",directory " + sqlStorage->textColumnType() + - ",labels " + sqlStorage->textColumnType() + - ",subscribedate " + sqlStorage->textColumnType() + - ",autoscan BOOL, fetchtype INTEGER" - ",haspurge BOOL, purgecount INTEGER" - ",writetags BOOL, filenamelayout VARCHAR(1024) ) ENGINE = MyISAM;" ) ); - - sqlStorage->query( QString( "CREATE TABLE podcastepisodes (" - "id " + sqlStorage->idType() + - ",url " + sqlStorage->longTextColumnType() + - ",channel INTEGER" - ",localurl " + sqlStorage->longTextColumnType() + - ",guid " + sqlStorage->exactTextColumnType() + - ",title " + sqlStorage->longTextColumnType() + - ",subtitle " + sqlStorage->longTextColumnType() + - ",sequencenumber INTEGER" + - ",description " + sqlStorage->longTextColumnType() + - ",mimetype " + sqlStorage->textColumnType() + - ",pubdate " + sqlStorage->textColumnType() + - ",duration INTEGER" - ",filesize INTEGER" - ",isnew BOOL" - ",iskeep BOOL) ENGINE = MyISAM;" ) ); - - sqlStorage->query( "CREATE FULLTEXT INDEX url_podchannel ON podcastchannels( url );" ); - sqlStorage->query( "CREATE FULLTEXT INDEX url_podepisode ON podcastepisodes( url );" ); - sqlStorage->query( - "CREATE FULLTEXT INDEX localurl_podepisode ON podcastepisodes( localurl );" ); -} - -void -SqlPodcastProvider::updateDatabase( int fromVersion, int toVersion ) -{ - debug() << QString( "Updating Podcast tables from version %1 to version %2" ) - .arg( fromVersion ).arg( toVersion ); - - SqlStorage *sqlStorage = StorageManager::instance()->sqlStorage(); - if( !sqlStorage ) - return; -#define escape(x) sqlStorage->escape(x) - - if( fromVersion == 1 && toVersion == 2 ) - { - QString updateChannelQuery = QString( "ALTER TABLE podcastchannels" - " ADD subscribedate " + sqlStorage->textColumnType() + ';' ); - - sqlStorage->query( updateChannelQuery ); - - QString setDateQuery = QString( - "UPDATE podcastchannels SET subscribedate='%1' WHERE subscribedate='';" ) - .arg( escape( QDate::currentDate().toString() ) ); - sqlStorage->query( setDateQuery ); - } - else if( fromVersion < 3 && toVersion == 3 ) - { - sqlStorage->query( QString( "CREATE TABLE podcastchannels_temp (" - "id " + sqlStorage->idType() + - ",url " + sqlStorage->exactTextColumnType() + " UNIQUE" - ",title " + sqlStorage->textColumnType() + - ",weblink " + sqlStorage->exactTextColumnType() + - ",image " + sqlStorage->exactTextColumnType() + - ",description " + sqlStorage->longTextColumnType() + - ",copyright " + sqlStorage->textColumnType() + - ",directory " + sqlStorage->textColumnType() + - ",labels " + sqlStorage->textColumnType() + - ",subscribedate " + sqlStorage->textColumnType() + - ",autoscan BOOL, fetchtype INTEGER" - ",haspurge BOOL, purgecount INTEGER ) ENGINE = MyISAM;" ) ); - - sqlStorage->query( QString( "CREATE TABLE podcastepisodes_temp (" - "id " + sqlStorage->idType() + - ",url " + sqlStorage->exactTextColumnType() + " UNIQUE" - ",channel INTEGER" - ",localurl " + sqlStorage->exactTextColumnType() + - ",guid " + sqlStorage->exactTextColumnType() + - ",title " + sqlStorage->textColumnType() + - ",subtitle " + sqlStorage->textColumnType() + - ",sequencenumber INTEGER" + - ",description " + sqlStorage->longTextColumnType() + - ",mimetype " + sqlStorage->textColumnType() + - ",pubdate " + sqlStorage->textColumnType() + - ",duration INTEGER" - ",filesize INTEGER" - ",isnew BOOL" - ",iskeep BOOL) ENGINE = MyISAM;" ) ); - - sqlStorage->query( "INSERT INTO podcastchannels_temp SELECT * FROM podcastchannels;" ); - sqlStorage->query( "INSERT INTO podcastepisodes_temp SELECT * FROM podcastepisodes;" ); - - sqlStorage->query( "DROP TABLE podcastchannels;" ); - sqlStorage->query( "DROP TABLE podcastepisodes;" ); - - createTables(); - - sqlStorage->query( "INSERT INTO podcastchannels SELECT * FROM podcastchannels_temp;" ); - sqlStorage->query( "INSERT INTO podcastepisodes SELECT * FROM podcastepisodes_temp;" ); - - sqlStorage->query( "DROP TABLE podcastchannels_temp;" ); - sqlStorage->query( "DROP TABLE podcastepisodes_temp;" ); - } - - if( fromVersion < 4 && toVersion == 4 ) - { - QString updateChannelQuery = QString( "ALTER TABLE podcastchannels" - " ADD writetags BOOL;" ); - sqlStorage->query( updateChannelQuery ); - QString setWriteTagsQuery = QString( "UPDATE podcastchannels SET writetags=" + - sqlStorage->boolTrue() + - " WHERE 1;" ); - sqlStorage->query( setWriteTagsQuery ); - } - - if( fromVersion < 5 && toVersion == 5 ) - { - QString updateChannelQuery = QString ( "ALTER TABLE podcastchannels" - " ADD filenamelayout VARCHAR(1024);" ); - sqlStorage->query( updateChannelQuery ); - QString setWriteTagsQuery = QString( "UPDATE podcastchannels SET filenamelayout='%default%'" ); - sqlStorage->query( setWriteTagsQuery ); - } - - if( fromVersion < 6 && toVersion == 6 ) - { - QString updateEpisodeQuery = QString ( "ALTER TABLE podcastepisodes" - " ADD iskeep BOOL;" ); - sqlStorage->query( updateEpisodeQuery ); - QString setIsKeepQuery = QString( "UPDATE podcastepisodes SET iskeep=FALSE;" ); - sqlStorage->query( setIsKeepQuery ); - } - - QString updateAdmin = QString( "UPDATE admin SET version=%1 WHERE component='%2';" ); - sqlStorage->query( updateAdmin.arg( toVersion ).arg( escape( key ) ) ); - - loadPodcasts(); -} - -void -SqlPodcastProvider::fetchImage( SqlPodcastChannelPtr channel ) -{ - if( m_podcastImageFetcher == 0 ) - { - m_podcastImageFetcher = new PodcastImageFetcher(); - connect( m_podcastImageFetcher, - SIGNAL(imageReady(Podcasts::PodcastChannelPtr,QImage)), - SLOT(channelImageReady(Podcasts::PodcastChannelPtr,QImage)) - ); - connect( m_podcastImageFetcher, - SIGNAL(done(PodcastImageFetcher*)), - SLOT(podcastImageFetcherDone(PodcastImageFetcher*)) - ); - } - - m_podcastImageFetcher->addChannel( PodcastChannelPtr::dynamicCast( channel ) ); -} - -void -SqlPodcastProvider::channelImageReady( Podcasts::PodcastChannelPtr channel, QImage image ) -{ - if( image.isNull() ) - return; - - channel->setImage( image ); -} - -void -SqlPodcastProvider::podcastImageFetcherDone( PodcastImageFetcher *fetcher ) -{ - fetcher->deleteLater(); - m_podcastImageFetcher = 0; -} - -void -SqlPodcastProvider::slotConfigureProvider() -{ - configureProvider(); -} - -#include "moc_SqlPodcastProvider.cpp" diff --git a/amarok/src/core-impl/podcasts/sql/SqlPodcastProvider.h b/amarok/src/core-impl/podcasts/sql/SqlPodcastProvider.h deleted file mode 100644 index 606d990f..00000000 --- a/amarok/src/core-impl/podcasts/sql/SqlPodcastProvider.h +++ /dev/null @@ -1,205 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Bart Cerneels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef SQLPODCASTPROVIDER_H -#define SQLPODCASTPROVIDER_H - -#include "core/podcasts/PodcastProvider.h" -#include "core/podcasts/PodcastReader.h" -#include "SqlPodcastMeta.h" - -#include -#include - -class PodcastImageFetcher; - -class KDialog; -class KUrl; -class PodcastReader; -class SqlStorage; -class QTimer; - -namespace Ui { - class SqlPodcastProviderSettingsWidget; -} - -namespace Podcasts { - -/** - @author Bart Cerneels -*/ -class AMAROK_EXPORT SqlPodcastProvider : public Podcasts::PodcastProvider -{ - Q_OBJECT - public: - SqlPodcastProvider(); - virtual ~SqlPodcastProvider(); - - //TrackProvider methods - virtual bool possiblyContainsTrack( const KUrl &url ) const; - virtual Meta::TrackPtr trackForUrl( const KUrl &url ); - - //PlaylistProvider methods - virtual QString prettyName() const { return i18n("Local Podcasts"); } - virtual KIcon icon() const { return KIcon( "server-database" ); } - - virtual Playlists::PlaylistList playlists(); - - //PlaylistProvider methods - virtual QActionList providerActions(); - virtual QActionList playlistActions( const Playlists::PlaylistList &playlists ); - virtual QActionList trackActions( const QMultiHash &playlistTracks ); - - //PodcastProvider methods - virtual Podcasts::PodcastEpisodePtr episodeForGuid( const QString &guid ); - - virtual void addPodcast( const KUrl &url ); - - virtual Podcasts::PodcastChannelPtr addChannel( Podcasts::PodcastChannelPtr channel ); - virtual Podcasts::PodcastEpisodePtr addEpisode( Podcasts::PodcastEpisodePtr episode ); - - virtual Podcasts::PodcastChannelList channels(); - - virtual void completePodcastDownloads(); - - //SqlPodcastProvider specific methods - virtual Podcasts::SqlPodcastChannelPtr podcastChannelForId( int podcastChannelDbId ); - - virtual KUrl baseDownloadDir() const { return m_baseDownloadDir; } - - public slots: - void updateAll(); - void downloadEpisode( Podcasts::PodcastEpisodePtr episode ); - void deleteDownloadedEpisode( Podcasts::PodcastEpisodePtr episode ); - - void slotReadResult( PodcastReader *podcastReader ); - void downloadEpisode( Podcasts::SqlPodcastEpisodePtr episode ); - void deleteDownloadedEpisode( Podcasts::SqlPodcastEpisodePtr episode ); - - private slots: - void downloadResult( KJob * ); - void addData( KIO::Job *job, const QByteArray & data ); - void redirected( KIO::Job *, const KUrl& ); - void autoUpdate(); - void slotDeleteDownloadedEpisodes(); - void slotDownloadEpisodes(); - void slotSetKeep(); - void slotConfigureChannel(); - void slotRemoveChannels(); - void slotUpdateChannels(); - void slotDownloadProgress( KJob *job, unsigned long percent ); - void slotWriteTagsToFiles(); - void slotConfigChanged(); - void slotExportOpml(); - - signals: - void totalPodcastDownloadProgress( int progress ); - - //SqlPodcastProvider signals - void episodeDownloaded( Podcasts::PodcastEpisodePtr ); - void episodeDeleted( Podcasts::PodcastEpisodePtr ); - - private slots: - void channelImageReady( Podcasts::PodcastChannelPtr, QImage ); - void podcastImageFetcherDone( PodcastImageFetcher * ); - void slotConfigureProvider(); - - void slotStatusBarNewProgressOperation( KIO::TransferJob * job, - const QString &description, - Podcasts::PodcastReader* reader ); - void slotStatusBarSorryMessage( const QString &message ); - void slotOpmlWriterDone( int result ); - - private: - void startTimer(); - void configureProvider(); - void configureChannel( Podcasts::SqlPodcastChannelPtr channel ); - void updateSqlChannel( Podcasts::SqlPodcastChannelPtr channel ); - - /** creates all the necessary tables, indexes etc. for the database */ - void createTables() const; - void loadPodcasts(); - - /** @arg string: a url, localUrl or guid in string form */ - Podcasts::SqlPodcastEpisodePtr sqlEpisodeForString( const QString &string ); - - void updateDatabase( int fromVersion, int toVersion ); - void fetchImage( Podcasts::SqlPodcastChannelPtr channel ); - - /** shows a modal dialog asking the user if he really wants to unsubscribe - and if he wants to keep the podcast media */ - QPair confirmUnsubscribe( Podcasts::SqlPodcastChannelPtr channel ); - - /** remove the episodes in the list from the filesystem */ - void deleteDownloadedEpisodes( Podcasts::SqlPodcastEpisodeList &episodes ); - - void moveDownloadedEpisodes( Podcasts::SqlPodcastChannelPtr channel ); - - /** Removes a podcast from the list. Will ask for confirmation to delete the episodes - * as well - */ - void removeSubscription( Podcasts::SqlPodcastChannelPtr channel ); - - void subscribe( const KUrl &url ); - QFile* createTmpFile ( Podcasts::SqlPodcastEpisodePtr sqlEpisode ); - void cleanupDownload( KJob *job, bool downloadFailed ); - - /** returns true if the file that is downloaded by 'job' is already locally available */ - bool checkEnclosureLocallyAvailable( KIO::Job *job ); - - Podcasts::SqlPodcastChannelList m_channels; - - QTimer *m_updateTimer; - int m_autoUpdateInterval; //interval between autoupdate attempts in minutes - unsigned int m_updatingChannels; - unsigned int m_maxConcurrentUpdates; - Podcasts::SqlPodcastChannelList m_updateQueue; - QList m_subscribeQueue; - - struct PodcastEpisodeDownload { - Podcasts::SqlPodcastEpisodePtr episode; - QFile *tmpFile; - QString fileName; - bool finalNameReady; - }; - - QHash m_downloadJobMap; - - Podcasts::SqlPodcastEpisodeList m_downloadQueue; - int m_maxConcurrentDownloads; - int m_completedDownloads; - - KUrl m_baseDownloadDir; - - KDialog *m_providerSettingsDialog; - Ui::SqlPodcastProviderSettingsWidget *m_providerSettingsWidget; - - QList m_providerActions; - - QAction *m_configureChannelAction; //Configure a Channel - QAction *m_deleteAction; //delete a downloaded Episode - QAction *m_downloadAction; - QAction *m_keepAction; - QAction *m_removeAction; //remove a subscription - QAction *m_updateAction; - QAction *m_writeTagsAction; //write feed information to downloaded file - - PodcastImageFetcher *m_podcastImageFetcher; -}; - -} //namespace Podcasts - -#endif diff --git a/amarok/src/core-impl/podcasts/sql/SqlPodcastProviderSettingsWidget.ui b/amarok/src/core-impl/podcasts/sql/SqlPodcastProviderSettingsWidget.ui deleted file mode 100644 index 61fb4097..00000000 --- a/amarok/src/core-impl/podcasts/sql/SqlPodcastProviderSettingsWidget.ui +++ /dev/null @@ -1,134 +0,0 @@ - - - SqlPodcastProviderSettingsWidget - - - - 0 - 0 - 506 - 65 - - - - - 0 - 0 - - - - - 330 - 65 - - - - - QFormLayout::ExpandingFieldsGrow - - - - - Auto-update: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 0 - 0 - - - - - 200 - 0 - - - - QAbstractSpinBox::PlusMinus - - - disabled - - - every - - - 0 - - - 300 - - - 30 - - - - - - - - - - Base directory: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 0 - 0 - - - - - 230 - 0 - - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'DejaVu Sans'; font-size:8pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Base directory for all new podcast channels.</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">When a podcast channel is added <span style=" font-style:italic;">&lt;base directory&gt;</span>/<span style=" font-style:italic;">&lt;channel name&gt;</span> is used as the download directory.</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">This can be changed for each channel individually.</p></body></html> - - - Base directory for all new podcast channels. -When a podcast channel is added <base directory>/<channel name> is used as the download directory. -This can be changed for each channel individually. - - - - - - - - KIntSpinBox - QSpinBox -
    knuminput.h
    - 1 -
    - - KUrlRequester - QFrame -
    kurlrequester.h
    - 1 -
    -
    - - -
    diff --git a/amarok/src/core-impl/storage/StorageManager.cpp b/amarok/src/core-impl/storage/StorageManager.cpp deleted file mode 100644 index c749c4fa..00000000 --- a/amarok/src/core-impl/storage/StorageManager.cpp +++ /dev/null @@ -1,208 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2014 Ralf Engels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "StorageManager" - -#include "StorageManager.h" - -#include -#include - -#include -#include - -#include - -/** A SqlStorage that doesn't do anything. - * - * An object of this type is used whenever we couldn't - * load a better SqlStorage. - * - * The reason is that plugins don't have to check for - * a null pointer as SqlStorage every time. - */ -class EmptySqlStorage : public SqlStorage -{ -public: - EmptySqlStorage() {} - virtual ~EmptySqlStorage() {} - - virtual int sqlDatabasePriority() const - { return 10; } - - virtual QString type() const { return QLatin1String("Empty"); } - - virtual QString escape( const QString &text) const { return text; } - - virtual QStringList query( const QString &) { return QStringList(); } - virtual int insert( const QString &, const QString &) { return 0; } - - virtual QString boolTrue() const { return QString(); } - virtual QString boolFalse() const { return QString(); } - - virtual QString idType() const { return QString(); }; - virtual QString textColumnType( int ) const { return QString(); } - virtual QString exactTextColumnType( int ) const { return QString(); } - - virtual QString exactIndexableTextColumnType( int ) const { return QString(); } - virtual QString longTextColumnType() const { return QString(); } - virtual QString randomFunc() const { return QString(); } - - virtual QStringList getLastErrors() const { return QStringList(); } - - /** Clears the list of the last errors. */ - virtual void clearLastErrors() { } - -}; - -static EmptySqlStorage emptyStorage; - - -struct StorageManager::Private -{ - SqlStorage* sqlDatabase; - - /** A list that collects errors from database plugins - * - * StoragePlugin factories can report errors that - * prevent the storage from even being created. - * - * This list collects them. - */ - QStringList errorList; -}; - -StorageManager *StorageManager::s_instance = 0; - - -StorageManager * -StorageManager::instance() -{ - if( !s_instance ) { - s_instance = new StorageManager(); - s_instance->init(); - } - - return s_instance; -} - -void -StorageManager::destroy() -{ - if( s_instance ) { - delete s_instance; - s_instance = 0; - } -} - -StorageManager::StorageManager() - : QObject() - , d( new Private ) -{ - DEBUG_BLOCK - - setObjectName( "StorageManager" ); - qRegisterMetaType( "SqlStorage*" ); - d->sqlDatabase = &emptyStorage; -} - -StorageManager::~StorageManager() -{ - DEBUG_BLOCK - - if( d->sqlDatabase != &emptyStorage ) - delete d->sqlDatabase; - delete d; -} - -SqlStorage* -StorageManager::sqlStorage() const -{ - return d->sqlDatabase; -} - -void -StorageManager::init() -{ -} - - -void -StorageManager::setFactories( const QList &factories ) -{ - foreach( Plugins::PluginFactory* pFactory, factories ) - { - StorageFactory *factory = qobject_cast( pFactory ); - if( !factory ) - continue; - - connect( factory, SIGNAL(newStorage(SqlStorage*)), - this, SLOT(slotNewStorage(SqlStorage*)) ); - connect( factory, SIGNAL(newError(QStringList)), - this, SLOT(slotNewError(QStringList)) ); - } -} - -QStringList -StorageManager::getLastErrors() const -{ - if( !d->errorList.isEmpty() ) - return d->errorList; - if( d->sqlDatabase == &emptyStorage ) - { - QStringList list; - list << i18n( "The configured database plugin could not be loaded." ); - return list; - } - return d->errorList; -} - -void -StorageManager::clearLastErrors() -{ - d->errorList.clear(); -} - -void -StorageManager::slotNewStorage( SqlStorage* newStorage ) -{ - DEBUG_BLOCK - - if( !newStorage ) - { - warning() << "Warning, newStorage in slotNewStorage is 0"; - return; - } - - if( d->sqlDatabase && d->sqlDatabase != &emptyStorage ) - { - warning() << "Warning, newStorage when we already have a storage"; - delete newStorage; - return; // once we have the database set we can't change it since - // plugins might have already created their tables in the old database - // or caching data from it. - } - - d->sqlDatabase = newStorage; -} - -void -StorageManager::slotNewError( QStringList errorMessageList ) -{ - d->errorList << errorMessageList; -} - - diff --git a/amarok/src/core-impl/storage/StorageManager.h b/amarok/src/core-impl/storage/StorageManager.h deleted file mode 100644 index 1532ccf6..00000000 --- a/amarok/src/core-impl/storage/StorageManager.h +++ /dev/null @@ -1,121 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2014 Ralf Engels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_STORAGEMANAGER_H -#define AMAROK_STORAGEMANAGER_H - -#include "amarok_export.h" - -#include -#include -#include - -namespace Plugins { - class PluginFactory; -} - -class SqlStorage; - -/** Class managing the Amarok SqlStorage - * - * This singleton class is the main responsible for providing everybody - * with the current SqlStorage. - */ -class AMAROK_EXPORT StorageManager : public QObject -{ - Q_OBJECT - - public: - - /** Get THE instance of the storage manager. - * - * This function will return the storage manager - * that returns the sql storage to be used for Amarok. - * - * In addition to the SqlCollection a lot of other components - * use a sql storage to persist data. - * - */ - static StorageManager *instance(); - - /** Destroys the instance of the StorageManager. - */ - static void destroy(); - - /** - retrieve an interface which allows client-code to store/load data in a relational database. - Note: code using this method does NOT take ownership of the pointer, but may cache the pointer - Note2: You should never modify the database unless you really really know what you do. - Using the SqlMeta (e.g. SqlRegistry or SqlTrack) is much better. - @return Returns a pointer to the amarok wide SqlStorage or - to an internal dummy SqlStorage if that cannot be found. - It never returns a null pointer. - */ - SqlStorage* sqlStorage() const; - - /** - * Set the list of current factories - * - * For every factory that is a CollectionFactory uses it to create new - * collections and register with this manager. - */ - void setFactories( const QList &factories ); - - /** Returns a list of the last sql errors. - The list might not include every one error if the number - is beyond a sensible limit. - */ - QStringList getLastErrors() const; - - /** Clears the list of the last errors. */ - void clearLastErrors(); - - private slots: - - /** Will be called whenever a factory emits a newStorage signal. - * - * The first factory to emit this signal will get it's storage - * registered as "the" storage. - * - * StorageManager will take ownership of the pointer and free it - * after all other plugins are done. - */ - void slotNewStorage( SqlStorage* newStorage ); - - /** Will be called whenever a factory emits a newError signal. - * - * The factories will not emit the newStorage signal in case - * of initialization problems. - * In order to report their issues they will instead emit - * newError with the list of errors. - */ - void slotNewError( QStringList errorMessageList ); - - private: - static StorageManager* s_instance; - StorageManager(); - ~StorageManager(); - - void init(); - - - Q_DISABLE_COPY( StorageManager ) - - struct Private; - Private * const d; -}; - -#endif /* AMAROK_STORAGEMANAGER_H */ diff --git a/amarok/src/core-impl/storage/sql/CMakeLists.txt b/amarok/src/core-impl/storage/sql/CMakeLists.txt deleted file mode 100644 index 1e9008fa..00000000 --- a/amarok/src/core-impl/storage/sql/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -if( BUILD_MYSQLE_COLLECTION ) - add_subdirectory( mysqlestorage ) -endif( BUILD_MYSQLE_COLLECTION ) -if( MYSQL_FOUND ) - add_subdirectory( mysqlserverstorage ) -endif( MYSQL_FOUND ) diff --git a/amarok/src/core-impl/storage/sql/amarok_sqlstorage_export.h b/amarok/src/core-impl/storage/sql/amarok_sqlstorage_export.h deleted file mode 100644 index c2171267..00000000 --- a/amarok/src/core-impl/storage/sql/amarok_sqlstorage_export.h +++ /dev/null @@ -1,47 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 David Faure * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_SQLSTORAGE_EXPORT_H -#define AMAROK_SQLSTORAGE_EXPORT_H - -/* needed for KDE_EXPORT and KDE_IMPORT macros */ -#include - -#ifndef AMAROK_SQLSTORAGE_EXPORT -# if defined(MAKE_AMAROK_SQLSTORAGE_LIB) - /* We are building this library */ -# define AMAROK_SQLSTORAGE_EXPORT KDE_EXPORT -# else - /* We are using this library */ -# define AMAROK_SQLSTORAGE_EXPORT KDE_IMPORT -# endif -#endif - -#ifndef AMAROK_SQLSTORAGE_MYSQLE_EXPORT -# if defined(MAKE_AMAROK_STORAGE_MYSQLESTORAGE_LIB) - /* We are building this library */ -# define AMAROK_SQLSTORAGE_MYSQLE_EXPORT KDE_EXPORT -# else - /* We are using this library */ -# define AMAROK_SQLSTORAGE_MYSQLE_EXPORT KDE_IMPORT -# endif -#endif - -# ifndef AMAROK_SQLSTORAGE_EXPORT_DEPRECATED -# define AMAROK_SQLSTORAGE_EXPORT_DEPRECATED KDE_DEPRECATED AMAROK_SQLSTORAGE_EXPORT -# endif - -#endif diff --git a/amarok/src/core-impl/storage/sql/mysql-shared/MySqlStorage.cpp b/amarok/src/core-impl/storage/sql/mysql-shared/MySqlStorage.cpp deleted file mode 100644 index 8cc2460b..00000000 --- a/amarok/src/core-impl/storage/sql/mysql-shared/MySqlStorage.cpp +++ /dev/null @@ -1,312 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Edward Toroshchin * - * Copyright (c) 2009 Jeff Mitchell * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "MySqlStorage" - -#include "MySqlStorage.h" - -#include "core/support/Amarok.h" -#include "core/support/Debug.h" -#include "amarokconfig.h" - -#include -#include -#include - - -#include - -/** - * This class is used by MySqlStorage to fulfill mysql's thread - * requirements. In every function that calls mysql_*, an init() method of - * this class must be invoked. - */ -class ThreadInitializer -{ - static int threadsCount; - static QMutex countMutex; - static QThreadStorage< ThreadInitializer* > storage; - - /** - * This should be called ONLY by init() - */ - ThreadInitializer() - { - mysql_thread_init(); - - countMutex.lock(); - threadsCount++; - countMutex.unlock(); - - debug() << "Initialized thread, count==" << threadsCount; - } - -public: - /** - * This is called by QThreadStorage when a thread is destroyed - */ - ~ThreadInitializer() - { - mysql_thread_end(); - - countMutex.lock(); - threadsCount--; - countMutex.unlock(); - - debug() << "Deinitialized thread, count==" << threadsCount; - - if( threadsCount == 0 ) - mysql_library_end(); - } - - static void init() - { - if( !storage.hasLocalData() ) - storage.setLocalData( new ThreadInitializer() ); - } -}; - -int ThreadInitializer::threadsCount = 0; -QMutex ThreadInitializer::countMutex; -QThreadStorage< ThreadInitializer* > ThreadInitializer::storage; - - -MySqlStorage::MySqlStorage() - : SqlStorage() - , m_db( 0 ) - , m_mutex( QMutex::Recursive ) - , m_debugIdent( "MySQL-none" ) -{ - //Relevant code must be implemented in subclasses -} - -MySqlStorage::~MySqlStorage() -{ } - -QStringList MySqlStorage::query( const QString& statement ) -{ - //DEBUG_BLOCK - //debug() << "[ATTN!] MySql::query( " << statement << " )"; - - initThreadInitializer(); - QMutexLocker locker( &m_mutex ); - - QStringList values; - if( !m_db ) - { - error() << "Tried to perform query on uninitialized MySQL"; - return values; - } - - int res = mysql_query( m_db, statement.toUtf8() ); - - if( res ) - { - reportError( statement ); - return values; - } - - MYSQL_RES *pres = mysql_store_result( m_db ); - if( !pres ) // No results... check if any were expected - { - if( mysql_field_count( m_db ) ) - reportError( statement ); - return values; - } - - int number = mysql_num_fields( pres ); - if( number <= 0 ) - { - warning() << "Errr... query returned but with no fields"; - } - -#if QT_VERSION >= 0x040700 - int rows = mysql_num_rows( pres ); - values.reserve( rows ); -#endif - MYSQL_ROW row = mysql_fetch_row( pres ); - while( row ) - { - for( int i = 0; i < number; ++i ) - { - values << QString::fromUtf8( (const char*) row[i] ); - } - - row = mysql_fetch_row( pres ); - } - - mysql_free_result( pres ); - return values; -} - -int MySqlStorage::insert( const QString& statement, const QString& /* table */ ) -{ - //DEBUG_BLOCK - //debug() << "[ATTN!] MySql::insert( " << statement << " )"; - - initThreadInitializer(); - QMutexLocker locker( &m_mutex ); - - if( !m_db ) - { - error() << "Tried to perform insert on uninitialized MySQL"; - return 0; - } - - int res = mysql_query( m_db, statement.toUtf8() ); - if( res ) - { - reportError( statement ); - return 0; - } - - MYSQL_RES *pres = mysql_store_result( m_db ); - if( pres ) - { - warning() << "[IMPORTANT!] insert returned data"; - mysql_free_result( pres ); - } - - res = mysql_insert_id( m_db ); - - return res; -} - -QString -MySqlStorage::escape( const QString &text ) const -{ - if( !m_db ) - { - error() << "Tried to perform escape() on uninitialized MySQL"; - return QString(); - } - - const QByteArray utfText = text.toUtf8(); - const int length = utfText.length() * 2 + 1; - QVarLengthArray outputBuffer( length ); - - { - QMutexLocker locker( &m_mutex ); - mysql_real_escape_string( m_db, outputBuffer.data(), utfText.constData(), utfText.length() ); - } - - return QString::fromUtf8( outputBuffer.constData() ); -} - -QString -MySqlStorage::randomFunc() const -{ - return "RAND()"; -} - -QString -MySqlStorage::boolTrue() const -{ - return "1"; -} - -QString -MySqlStorage::boolFalse() const -{ - return "0"; -} - -QString -MySqlStorage::idType() const -{ - return "INTEGER PRIMARY KEY AUTO_INCREMENT"; -} - -QString -MySqlStorage::textColumnType( int length ) const -{ - return QString( "VARCHAR(%1)" ).arg( length ); -} - -QString -MySqlStorage::exactTextColumnType( int length ) const -{ - return textColumnType( length ); -} - -QString -MySqlStorage::exactIndexableTextColumnType( int length ) const -{ - return textColumnType( length ); -} - -QString -MySqlStorage::longTextColumnType() const -{ - return "TEXT"; -} - -QStringList -MySqlStorage::getLastErrors() const -{ - QMutexLocker locker( &m_mutex ); - return m_lastErrors; -} - -void -MySqlStorage::clearLastErrors() -{ - QMutexLocker locker( &m_mutex ); - m_lastErrors.clear(); -} - -void -MySqlStorage::reportError( const QString& message ) -{ - QMutexLocker locker( &m_mutex ); - QString errorMessage; - if( m_db ) - errorMessage = m_debugIdent + " query failed! (" + QString::number( mysql_errno( m_db ) ) + ") " + mysql_error( m_db ) + " on " + message; - else - errorMessage = m_debugIdent + " something failed! on " + message; - error() << errorMessage; - - if( m_lastErrors.count() < 20 ) - m_lastErrors.append( errorMessage ); -} - - -void -MySqlStorage::initThreadInitializer() -{ - ThreadInitializer::init(); -} - -bool -MySqlStorage::sharedInit( const QString &databaseName ) -{ - QMutexLocker locker( &m_mutex ); - if( mysql_query( m_db, QString( "SET NAMES 'utf8'" ).toUtf8() ) ) - reportError( "SET NAMES 'utf8' died" ); - if( mysql_query( m_db, QString( "CREATE DATABASE IF NOT EXISTS %1 DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_bin" ).arg( databaseName ).toUtf8() ) ) - reportError( QString( "Could not create %1 database" ).arg( databaseName ) ); - if( mysql_query( m_db, QString( "ALTER DATABASE %1 DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_bin" ).arg( databaseName ).toUtf8() ) ) - reportError( "Could not alter database charset/collation" ); - if( mysql_query( m_db, QString( "USE %1" ).arg( databaseName ).toUtf8() ) ) - { - reportError( "Could not select database" ); - return false; // this error is fatal - } - - debug() << "Connected to MySQL server" << mysql_get_server_info( m_db ); - return true; -} diff --git a/amarok/src/core-impl/storage/sql/mysql-shared/MySqlStorage.h b/amarok/src/core-impl/storage/sql/mysql-shared/MySqlStorage.h deleted file mode 100644 index 213ea7b8..00000000 --- a/amarok/src/core-impl/storage/sql/mysql-shared/MySqlStorage.h +++ /dev/null @@ -1,94 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Edward Toroshchin * - * Copyright (c) 2009 Jeff Mitchell * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_STORAGE_MYSQLSTORAGE_H -#define AMAROK_STORAGE_MYSQLSTORAGE_H - -#include "core/storage/SqlStorage.h" - - -#include -#include - -#ifdef Q_WS_WIN - #include -#endif - -struct st_mysql; -typedef struct st_mysql MYSQL; - -/** - * Implements a SqlStorage using a MySQL backend - */ -class MySqlStorage: public SqlStorage -{ - public: - MySqlStorage(); - virtual ~MySqlStorage(); - - virtual QStringList query( const QString &query ); - virtual int insert( const QString &statement, const QString &table = QString() ); - - virtual QString escape( const QString &text ) const; - virtual QString randomFunc() const; - - virtual QString boolTrue() const; - virtual QString boolFalse() const; - virtual QString idType() const; - virtual QString textColumnType( int length = 255 ) const; - virtual QString exactTextColumnType( int length = 1000 ) const; - //the below value may have to be decreased even more for different indexes; only time will tell - virtual QString exactIndexableTextColumnType( int length = 324 ) const; - virtual QString longTextColumnType() const; - - /** Returns a list of the last sql errors. - The list might not include every one error if the number - is beyond a sensible limit. - */ - QStringList getLastErrors() const; - - /** Clears the list of the last errors. */ - void clearLastErrors(); - - protected: - /** Adds an error message to the m_lastErrors. - * - * Adds a message including the mysql error number and mesage - * to the last error messages. - * @param message Usually the query statement being executed. - */ - void reportError( const QString &message ); - - void initThreadInitializer(); - - /** Sends the first sql commands to setup the connection. - * - * Sets things like the used database and charset. - * @returns false if something fatal was wrong. - */ - bool sharedInit( const QString &databaseName ); - - MYSQL* m_db; - - /** Mutex protecting the m_lastErrors list */ - mutable QMutex m_mutex; - - QString m_debugIdent; - QStringList m_lastErrors; -}; - -#endif diff --git a/amarok/src/core-impl/storage/sql/mysqlestorage/CMakeLists.txt b/amarok/src/core-impl/storage/sql/mysqlestorage/CMakeLists.txt deleted file mode 100644 index 1b9e0640..00000000 --- a/amarok/src/core-impl/storage/sql/mysqlestorage/CMakeLists.txt +++ /dev/null @@ -1,41 +0,0 @@ -add_definitions(${MYSQL_EMBEDDED_CFLAGS}) - -########### mysqle ############### - -set( amarok_storage-mysqlestorage_PART_SRCS - ../mysql-shared/MySqlStorage.cpp - MySqlEmbeddedStorage.cpp - MySqlEmbeddedStorageFactory.cpp -) - -kde4_add_plugin(amarok_storage-mysqlestorage ${amarok_storage-mysqlestorage_PART_SRCS}) - -STRING(REPLACE "-Wl,--fatal-warnings" "" CMAKE_SHARED_LINKER_FLAGS_NOFATALWARN "${CMAKE_SHARED_LINKER_FLAGS}") -SET(CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS_NOFATALWARN} ) - -STRING(REPLACE "-Wl,--fatal-warnings" "" CMAKE_MODULE_LINKER_FLAGS_NOFATALWARN "${CMAKE_MODULE_LINKER_FLAGS}") -SET(CMAKE_MODULE_LINKER_FLAGS ${CMAKE_MODULE_LINKER_FLAGS_NOFATALWARN} ) - -target_link_libraries(amarok_storage-mysqlestorage - # amarok-sqlstorage - amarokcore - amaroklib - ${KDE4_KDECORE_LIBS} - ${QT_QTCORE_LIBRARY} - ${QT_QTGUI_LIBRARY} - ${MYSQL_EMBEDDED_LIBRARIES} - ${CMAKE_DL_LIBS} - ${ZLIB_LIBRARIES} -) - -if(NOT WIN32 AND NOT APPLE) - target_link_libraries( amarok_storage-mysqlestorage crypt pthread ) -endif(NOT WIN32 AND NOT APPLE) - -if(APPLE) - SET_TARGET_PROPERTIES(amarok_storage-mysqlestorage PROPERTIES LINK_FLAGS "-undefined dynamic_lookup") -endif(APPLE) - -install(TARGETS amarok_storage-mysqlestorage DESTINATION ${PLUGIN_INSTALL_DIR} ) - -install(FILES amarok_storage-mysqlestorage.desktop DESTINATION ${SERVICES_INSTALL_DIR}) diff --git a/amarok/src/core-impl/storage/sql/mysqlestorage/MySqlEmbeddedStorage.cpp b/amarok/src/core-impl/storage/sql/mysqlestorage/MySqlEmbeddedStorage.cpp deleted file mode 100644 index d542f01a..00000000 --- a/amarok/src/core-impl/storage/sql/mysqlestorage/MySqlEmbeddedStorage.cpp +++ /dev/null @@ -1,147 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Edward Toroshchin * - * Copyright (c) 2009 Jeff Mitchell * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "MySqlEmbeddedStorage" - -#include "MySqlEmbeddedStorage.h" - -#include -#include -#include - -#include -#include -#include -#include - -#include - -/** number of times the library is used. - */ -static QAtomicInt libraryInitRef; - -MySqlEmbeddedStorage::MySqlEmbeddedStorage() - : MySqlStorage() -{ - m_debugIdent = "MySQLe"; -} - -bool -MySqlEmbeddedStorage::init( const QString &storageLocation ) -{ - - // -- figuring out and setting the database path. - QString storagePath = storageLocation; - QString databaseDir; - // TODO: the following logic is not explained in the comments. - // tests use a different directory then the real run - if( storagePath.isEmpty() ) - { - storagePath = Amarok::saveLocation(); - databaseDir = Amarok::config( "MySQLe" ).readEntry( "data", QString(storagePath + "mysqle") ); - } - else - { - QDir dir( storagePath ); - dir.mkpath( "." ); //ensure directory exists - databaseDir = dir.absolutePath() + QDir::separator() + "mysqle"; - } - - QVector mysql_args; - QByteArray dataDir = QString( "--datadir=%1" ).arg( databaseDir ).toLocal8Bit(); - mysql_args << "amarok" - << dataDir.constData() - // CAUTION: if we ever change the table type we will need to fix a number of MYISAM specific - // functions, such as FULLTEXT indexing. - << "--default-storage-engine=MyISAM" - << "--innodb=OFF" - << "--skip-grant-tables" - << "--myisam-recover=FORCE" - << "--key-buffer-size=16777216" // (16Mb) - << "--character-set-server=utf8" - << "--collation-server=utf8_bin"; - - - if( !QFile::exists( databaseDir ) ) - { - QDir dir( databaseDir ); - dir.mkpath( "." ); - } - - // -- initializing the library - // we only need to do this once - if( !libraryInitRef.fetchAndAddOrdered( 1 ) ) - { - int ret = mysql_library_init( mysql_args.size(), const_cast(mysql_args.data()), 0 ); - if( ret != 0 ) - { - // mysql sources show that there is only 0 and 1 as return code - // and it can only fail because of memory or thread issues. - reportError( "library initialization " - "failed, return code " + QString::number( ret ) ); - libraryInitRef.deref(); - return false; - } - } - - m_db = mysql_init( NULL ); - if( !m_db ) - { - reportError( "call to mysql_init" ); - return false; - } - - if( mysql_options( m_db, MYSQL_READ_DEFAULT_GROUP, "amarokclient" ) ) - reportError( "Error setting options for READ_DEFAULT_GROUP" ); - if( mysql_options( m_db, MYSQL_OPT_USE_EMBEDDED_CONNECTION, NULL ) ) - reportError( "Error setting option to use embedded connection" ); - - if( !mysql_real_connect( m_db, NULL,NULL,NULL, 0, 0,NULL, 0 ) ) - { - error() << "Could not connect to mysql embedded!"; - reportError( "call to mysql_real_connect" ); - mysql_close( m_db ); - m_db = 0; - return false; - } - - if( !sharedInit( QLatin1String("amarok") ) ) - { - // if sharedInit fails then we can usually not switch to the correct database - // sharedInit already reports errors. - mysql_close( m_db ); - m_db = 0; - return false; - } - - MySqlStorage::initThreadInitializer(); - - return true; -} - -MySqlEmbeddedStorage::~MySqlEmbeddedStorage() -{ - if( m_db ) - { - mysql_close( m_db ); - if( !libraryInitRef.deref() ) - { - mysql_library_end(); - } - } -} - diff --git a/amarok/src/core-impl/storage/sql/mysqlestorage/MySqlEmbeddedStorage.h b/amarok/src/core-impl/storage/sql/mysqlestorage/MySqlEmbeddedStorage.h deleted file mode 100644 index 29963d92..00000000 --- a/amarok/src/core-impl/storage/sql/mysqlestorage/MySqlEmbeddedStorage.h +++ /dev/null @@ -1,45 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Edward Toroshchin * - * Copyright (c) 2009 Jeff Mitchell * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef MYSQLEMBEDDEDSTORAGE_H -#define MYSQLEMBEDDEDSTORAGE_H - -#include "../amarok_sqlstorage_export.h" -#include "../mysql-shared/MySqlStorage.h" - -/** - * Implements a MySqlStorage using a MySQL Embedded Server - */ -class AMAROK_SQLSTORAGE_MYSQLE_EXPORT MySqlEmbeddedStorage : public MySqlStorage -{ - public: - /** Creates a new SqlStorage. - * - * Note: Currently it is not possible to open two storages to different locations - * in one process. - * The first caller wins. - */ - MySqlEmbeddedStorage(); - virtual ~MySqlEmbeddedStorage(); - - /** Initializes the storage. - * @param storageLocation The directory for storing the mysql database, will use the default defined by Amarok/KDE if not set. - */ - bool init( const QString &storageLocation = QString() ); -}; - -#endif // MYSQLEMBEDDEDSTORAGE_H diff --git a/amarok/src/core-impl/storage/sql/mysqlestorage/MySqlEmbeddedStorageFactory.cpp b/amarok/src/core-impl/storage/sql/mysqlestorage/MySqlEmbeddedStorageFactory.cpp deleted file mode 100644 index 13432304..00000000 --- a/amarok/src/core-impl/storage/sql/mysqlestorage/MySqlEmbeddedStorageFactory.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2014 Ralf Engels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "MySqlEmbeddedStorageFactory.h" -#include "MySqlEmbeddedStorage.h" - -#include - -AMAROK_EXPORT_STORAGE( MySqleStorageFactory, mysqlestorage ) - -MySqleStorageFactory::MySqleStorageFactory( QObject *parent, const QVariantList &args ) - : StorageFactory( parent, args ) -{ - m_info = KPluginInfo( "amarok_storage-mysqlestorage.desktop", "services" ); -} - -MySqleStorageFactory::~MySqleStorageFactory() -{ -} - -void -MySqleStorageFactory::init() -{ - if( m_initialized ) - return; - - m_initialized = true; - - if( ! Amarok::config( "MySQL" ).readEntry( "UseServer", false ) ) - { - MySqlEmbeddedStorage* storage = new MySqlEmbeddedStorage(); - bool initResult = storage->init(); - - // handle errors during creation - if( !storage->getLastErrors().isEmpty() ) - emit newError( storage->getLastErrors() ); - storage->clearLastErrors(); - - if( initResult ) - emit newStorage( storage ); - else - delete storage; - } -} - -#include "moc_MySqlEmbeddedStorageFactory.cpp" - diff --git a/amarok/src/core-impl/storage/sql/mysqlestorage/MySqlEmbeddedStorageFactory.h b/amarok/src/core-impl/storage/sql/mysqlestorage/MySqlEmbeddedStorageFactory.h deleted file mode 100644 index 9f648df8..00000000 --- a/amarok/src/core-impl/storage/sql/mysqlestorage/MySqlEmbeddedStorageFactory.h +++ /dev/null @@ -1,34 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2014 Ralf Engels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_STORAGE_MYSQLEMBEDDEDFACTORY_H -#define AMAROK_STORAGE_MYSQLEMBEDDEDFACTORY_H - -#include "core/storage/StorageFactory.h" - -class MySqleStorageFactory : public StorageFactory -{ - Q_OBJECT - - public: - MySqleStorageFactory( QObject *parent, const QVariantList &args ); - virtual ~MySqleStorageFactory(); - - virtual void init(); -}; - - -#endif diff --git a/amarok/src/core-impl/storage/sql/mysqlestorage/amarok_storage-mysqlestorage.desktop b/amarok/src/core-impl/storage/sql/mysqlestorage/amarok_storage-mysqlestorage.desktop deleted file mode 100644 index f44991e7..00000000 --- a/amarok/src/core-impl/storage/sql/mysqlestorage/amarok_storage-mysqlestorage.desktop +++ /dev/null @@ -1,48 +0,0 @@ -[Desktop Entry] -Type=Service -Icon=server-database -Name=MySQLe Storage -Name[ca]=Emmagatzematge MySQLe -Name[cs]=Úložiště MySQLe -Name[en_GB]=MySQLe Storage -Name[it]=Archiviazione MySQLe -Name[nl]=MySQLe-opslag -Name[pl]=Przechowalnia MySQLe -Name[pt]=Armazenamento no MySQLe -Name[pt_BR]=Armazenamento MySQLe -Name[sv]=MySQLe-lagring -Name[uk]=Сховище даних MySQLe -Name[x-test]=xxMySQLe Storagexx -Comment=Storage plugin for Amarok -Comment[ca]=Connector d'emmagatzematge per l'Amarok -Comment[cs]=Modul úložiště pro AmaroK -Comment[en_GB]=Storage plugin for Amarok -Comment[it]=Estensione di archiviazione per Amarok -Comment[nl]=Opslag-plug-in voor Amarok -Comment[pl]=Wtyczka przechowywania dla Amaroka -Comment[pt]='Plugin' de armazenamento do Amarok -Comment[pt_BR]=Plugin de armazenamento para o Amarok -Comment[sv]=Lagringsinsticksprogram för Amarok -Comment[uk]=Додаток сховища даних для Amarok -Comment[x-test]=xxStorage plugin for Amarokxx -NoDisplay=true - -ServiceTypes=Amarok/Plugin - -X-KDE-Amarok-authors=Ralf Engels -X-KDE-Amarok-email=ralf-engels@gmx.de -X-KDE-Amarok-framework-version=72 -X-KDE-Amarok-name=mysqle-storage -X-KDE-Amarok-plugintype=storage -X-KDE-Amarok-rank=100 -X-KDE-Amarok-version=1 -X-KDE-Amarok-vital=true - -X-KDE-PluginInfo-Author=Ralf Engels -X-KDE-PluginInfo-Email=ralf.engels@gmx.de -X-KDE-PluginInfo-Version=1.0 -X-KDE-PluginInfo-Category=Storage -X-KDE-PluginInfo-License=GPL -X-KDE-PluginInfo-EnabledByDefault=true -X-KDE-PluginInfo-Name=amarok_storage-mysqlestorage -X-KDE-Library=amarok_storage-mysqlestorage diff --git a/amarok/src/core-impl/storage/sql/mysqlserverstorage/CMakeLists.txt b/amarok/src/core-impl/storage/sql/mysqlserverstorage/CMakeLists.txt deleted file mode 100644 index e6e71f83..00000000 --- a/amarok/src/core-impl/storage/sql/mysqlserverstorage/CMakeLists.txt +++ /dev/null @@ -1,41 +0,0 @@ -add_definitions(${MYSQL_CFLAGS}) - -########### mysqlserver ############### - -set( amarok_storage-mysqlserverstorage_PART_SRCS - ../mysql-shared/MySqlStorage.cpp - MySqlServerStorage.cpp - MySqlServerStorageFactory.cpp -) - -kde4_add_plugin(amarok_storage-mysqlserverstorage ${amarok_storage-mysqlserverstorage_PART_SRCS}) - -STRING(REPLACE "-Wl,--fatal-warnings" "" CMAKE_SHARED_LINKER_FLAGS_NOFATALWARN "${CMAKE_SHARED_LINKER_FLAGS}") -SET(CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS_NOFATALWARN} ) - -STRING(REPLACE "-Wl,--fatal-warnings" "" CMAKE_MODULE_LINKER_FLAGS_NOFATALWARN "${CMAKE_MODULE_LINKER_FLAGS}") -SET(CMAKE_MODULE_LINKER_FLAGS ${CMAKE_MODULE_LINKER_FLAGS_NOFATALWARN} ) - -target_link_libraries(amarok_storage-mysqlserverstorage - # amarok-sqlstorage - amarokcore - amaroklib - ${KDE4_KDECORE_LIBS} - ${QT_QTCORE_LIBRARY} - ${QT_QTGUI_LIBRARY} - ${MYSQL_LIBRARIES} - ${CMAKE_DL_LIBS} - ${ZLIB_LIBRARIES} -) - -if(NOT WIN32 AND NOT APPLE) - target_link_libraries( amarok_storage-mysqlserverstorage crypt pthread ) -endif(NOT WIN32 AND NOT APPLE) - -if(APPLE) - SET_TARGET_PROPERTIES(amarok_storage-mysqlserverstorage PROPERTIES LINK_FLAGS "-undefined dynamic_lookup") -endif(APPLE) - -install(TARGETS amarok_storage-mysqlserverstorage DESTINATION ${PLUGIN_INSTALL_DIR} ) - -install(FILES amarok_storage-mysqlserverstorage.desktop DESTINATION ${SERVICES_INSTALL_DIR}) diff --git a/amarok/src/core-impl/storage/sql/mysqlserverstorage/MySqlServerStorage.cpp b/amarok/src/core-impl/storage/sql/mysqlserverstorage/MySqlServerStorage.cpp deleted file mode 100644 index 56c8b82d..00000000 --- a/amarok/src/core-impl/storage/sql/mysqlserverstorage/MySqlServerStorage.cpp +++ /dev/null @@ -1,160 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Edward Toroshchin * - * Copyright (c) 2009 Jeff Mitchell * - * Copyright (c) 2012 Lachlan Dufton * - * Copyright (c) 2014 Ralf Engels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "MySqlServerStorage" - -#include "MySqlServerStorage.h" - -#include - -#include - -#include - -/** number of times the library is used. - */ -static QAtomicInt libraryInitRef; - -MySqlServerStorage::MySqlServerStorage() - : MySqlStorage() -{ - m_debugIdent = "MySQL-server"; -} - -bool -MySqlServerStorage::init( const QString &host, const QString &user, const QString &password, int port, const QString &databaseName ) -{ - DEBUG_BLOCK - - // -- initializing the library - // we only need to do this once - if( !libraryInitRef.fetchAndAddOrdered( 1 ) ) - { - int ret = mysql_library_init( 0, NULL, NULL ); - if( ret != 0 ) - { - // mysql sources show that there is only 0 and 1 as return code - // and it can only fail because of memory or thread issues. - reportError( "library initialization " - "failed, return code " + QString::number( ret ) ); - libraryInitRef.deref(); - return false; - } - } - - m_db = mysql_init( NULL ); - if( !m_db ) - { - reportError( "call to mysql_init" ); - return false; - } - - //first here, the right way for >= 5.1.6 - my_bool reconnect = true; - if( mysql_options( m_db, MYSQL_OPT_RECONNECT, &reconnect ) ) - reportError( "Asking for automatic reconnect did not succeed!" ); - else - debug() << "Automatic reconnect successfully activated"; - - debug() << "Connecting to mysql server " << user << "@" << host << ":" << port; - if( !mysql_real_connect( m_db, - host.toUtf8(), - user.toUtf8(), - password.toUtf8(), - NULL, - port, - NULL, - CLIENT_COMPRESS ) - ) - { - reportError( "call to mysql_real_connect" ); - mysql_close( m_db ); - m_db = 0; - return false; - } - - //but in versions prior to 5.1.6, have to call it after every real_connect - reconnect = true; - if( mysql_options( m_db, MYSQL_OPT_RECONNECT, &reconnect ) ) - reportError( "Asking for automatic reconnect did not succeed!" ); - else - debug() << "Automatic reconnect successfully activated"; - - m_databaseName = databaseName; // store it when we need it later for reconnect - if( !sharedInit( databaseName ) ) - { - // if sharedInit fails then we can usually not switch to the correct database - // sharedInit already reports errors. - mysql_close( m_db ); - m_db = 0; - return false; - } - - MySqlServerStorage::initThreadInitializer(); - return true; -} - -MySqlServerStorage::~MySqlServerStorage() -{ - DEBUG_BLOCK - - if( m_db ) - { - mysql_close( m_db ); - if( !libraryInitRef.deref() ) - { - mysql_library_end(); - } - } -} - -QStringList -MySqlServerStorage::query( const QString &query ) -{ - MySqlStorage::initThreadInitializer(); - QMutexLocker locker( &m_mutex ); - if( !m_db ) - { - error() << "Tried to query an uninitialized m_db!"; - return QStringList(); - } - - unsigned long tid = mysql_thread_id( m_db ); - - int res = mysql_ping( m_db ); - if( res ) - { - reportError( "mysql_ping failed!" ); - return QStringList(); - } - - if( tid != mysql_thread_id( m_db ) ) - { - debug() << "NOTE: MySQL server had gone away, ping reconnected it"; - if( mysql_query( m_db, QString( "SET NAMES 'utf8'" ).toUtf8() ) ) - reportError( "SET NAMES 'utf8' died" ); - if( mysql_query( m_db, QString( "USE %1" ).arg( m_databaseName ).toUtf8() ) ) - reportError( "Could not select database" ); - } - - - return MySqlStorage::query( query ); -} - - diff --git a/amarok/src/core-impl/storage/sql/mysqlserverstorage/MySqlServerStorage.h b/amarok/src/core-impl/storage/sql/mysqlserverstorage/MySqlServerStorage.h deleted file mode 100644 index b91aa816..00000000 --- a/amarok/src/core-impl/storage/sql/mysqlserverstorage/MySqlServerStorage.h +++ /dev/null @@ -1,48 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Edward Toroshchin * - * Copyright (c) 2009 Jeff Mitchell * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_STORAGE_MYSQLSERVERSTORAGE_H -#define AMAROK_STORAGE_MYSQLSERVERSTORAGE_H - -#include "../amarok_sqlstorage_export.h" -#include "../mysql-shared/MySqlStorage.h" - -/** - * Implements a MySqlStorage using a MySQL Server - */ -class AMAROK_SQLSTORAGE_MYSQLE_EXPORT MySqlServerStorage: public MySqlStorage -{ - public: - /** Constructor for the server based mysql storage. */ - MySqlServerStorage(); - virtual ~MySqlServerStorage(); - - /** Try to connect to the server indicated by the options. - * - * Error messages are in the store error log. - * - * @return true if connection works. - */ - virtual bool init( const QString &host, const QString &user, const QString &password, int port, const QString &databaseName ); - - virtual QStringList query( const QString &query ); - - private: - QString m_databaseName; ///< remember the name given at init for reconnects -}; - -#endif diff --git a/amarok/src/core-impl/storage/sql/mysqlserverstorage/MySqlServerStorageFactory.cpp b/amarok/src/core-impl/storage/sql/mysqlserverstorage/MySqlServerStorageFactory.cpp deleted file mode 100644 index 99db1118..00000000 --- a/amarok/src/core-impl/storage/sql/mysqlserverstorage/MySqlServerStorageFactory.cpp +++ /dev/null @@ -1,82 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2014 Ralf Engels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "MySqlServerStorageFactory.h" -#include "MySqlServerStorage.h" - -#include -#include - -AMAROK_EXPORT_STORAGE( MySqlServerStorageFactory, mysqlserverstorage ) - -MySqlServerStorageFactory::MySqlServerStorageFactory( QObject *parent, const QVariantList &args ) - : StorageFactory( parent, args ) -{ - m_info = KPluginInfo( "amarok_storage-mysqlserverstorage.desktop", "services" ); -} - -MySqlServerStorageFactory::~MySqlServerStorageFactory() -{ -} - -void -MySqlServerStorageFactory::init() -{ - if( m_initialized ) - return; - - m_initialized = true; - - if( Amarok::config( "MySQL" ).readEntry( "UseServer", false ) ) - { - MySqlServerStorage* storage = new MySqlServerStorage(); - bool initResult = storage->init( - Amarok::config( "MySQL" ).readEntry( "Host", "localhost" ), - Amarok::config( "MySQL" ).readEntry( "User", "amarokuser" ), - Amarok::config( "MySQL" ).readEntry( "Password", "password" ), - Amarok::config( "MySQL" ).readEntry( "Port", "3306" ).toInt(), - Amarok::config( "MySQL" ).readEntry( "Database", "amarokdb" ) ); - - // handle errors during creation - if( !storage->getLastErrors().isEmpty() ) - emit newError( storage->getLastErrors() ); - storage->clearLastErrors(); - - if( initResult ) - emit newStorage( storage ); - else - delete storage; - } -} - -QStringList -MySqlServerStorageFactory::testSettings( const QString &host, const QString &user, const QString &password, int port, const QString &databaseName ) -{ - QStringList errors; - - MySqlServerStorage* storage = new MySqlServerStorage(); - bool initResult = storage->init( host, user, password, port, databaseName ); - - // we are just interested in the errors. - errors = storage->getLastErrors(); - - delete storage; - - return errors; -} - -#include "moc_MySqlServerStorageFactory.cpp" - diff --git a/amarok/src/core-impl/storage/sql/mysqlserverstorage/MySqlServerStorageFactory.h b/amarok/src/core-impl/storage/sql/mysqlserverstorage/MySqlServerStorageFactory.h deleted file mode 100644 index f0e46450..00000000 --- a/amarok/src/core-impl/storage/sql/mysqlserverstorage/MySqlServerStorageFactory.h +++ /dev/null @@ -1,40 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2014 Ralf Engels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_STORAGE_MYSQLSERVERSTORAGEFACTORY_H -#define AMAROK_STORAGE_MYSQLSERVERSTORAGEFACTORY_H - -#include "core/storage/StorageFactory.h" - -class MySqlServerStorageFactory : public StorageFactory -{ - Q_OBJECT - - public: - MySqlServerStorageFactory( QObject *parent, const QVariantList &args ); - virtual ~MySqlServerStorageFactory(); - - virtual void init(); - - public slots: - - /** Returns the error messages created during establishing the connection. - */ - QStringList testSettings( const QString &host, const QString &user, const QString &password, int port, const QString &databaseName ); -}; - - -#endif diff --git a/amarok/src/core-impl/storage/sql/mysqlserverstorage/amarok_storage-mysqlserverstorage.desktop b/amarok/src/core-impl/storage/sql/mysqlserverstorage/amarok_storage-mysqlserverstorage.desktop deleted file mode 100644 index 956cb338..00000000 --- a/amarok/src/core-impl/storage/sql/mysqlserverstorage/amarok_storage-mysqlserverstorage.desktop +++ /dev/null @@ -1,48 +0,0 @@ -[Desktop Entry] -Type=Service -Icon=network-server-database -Name=MySQLServer Storage -Name[ca]=Emmagatzematge MySQLServer -Name[cs]=Úložiště MySQLServer -Name[en_GB]=MySQLServer Storage -Name[it]=Archiviazione MySQLServer -Name[nl]=MySQLServer-opslag -Name[pl]=Przechowalnia MySQLServer -Name[pt]=Armazenamento no Servidor de MySQL -Name[pt_BR]=Armazenamento MySQLServer -Name[sv]=MySQLServer-lagring -Name[uk]=Сховище даних MySQLServer -Name[x-test]=xxMySQLServer Storagexx -Comment=Storage plugin for Amarok -Comment[ca]=Connector d'emmagatzematge per l'Amarok -Comment[cs]=Modul úložiště pro AmaroK -Comment[en_GB]=Storage plugin for Amarok -Comment[it]=Estensione di archiviazione per Amarok -Comment[nl]=Opslag-plug-in voor Amarok -Comment[pl]=Wtyczka przechowywania dla Amaroka -Comment[pt]='Plugin' de armazenamento do Amarok -Comment[pt_BR]=Plugin de armazenamento para o Amarok -Comment[sv]=Lagringsinsticksprogram för Amarok -Comment[uk]=Додаток сховища даних для Amarok -Comment[x-test]=xxStorage plugin for Amarokxx -NoDisplay=true - -ServiceTypes=Amarok/Plugin - -X-KDE-Amarok-authors=Ralf Engels -X-KDE-Amarok-email=ralf-engels@gmx.de -X-KDE-Amarok-framework-version=72 -X-KDE-Amarok-name=mysqlserver-storage -X-KDE-Amarok-plugintype=storage -X-KDE-Amarok-rank=100 -X-KDE-Amarok-version=1 -X-KDE-Amarok-vital=true - -X-KDE-PluginInfo-Author=Ralf Engels -X-KDE-PluginInfo-Email=ralf.engels@gmx.de -X-KDE-PluginInfo-Version=1.0 -X-KDE-PluginInfo-Category=Storage -X-KDE-PluginInfo-License=GPL -X-KDE-PluginInfo-EnabledByDefault=true -X-KDE-PluginInfo-Name=amarok_storage-mysqlserverstorage -X-KDE-Library=amarok_storage-mysqlserverstorage diff --git a/amarok/src/core-impl/support/PersistentStatisticsStore.cpp b/amarok/src/core-impl/support/PersistentStatisticsStore.cpp deleted file mode 100644 index 54640669..00000000 --- a/amarok/src/core-impl/support/PersistentStatisticsStore.cpp +++ /dev/null @@ -1,149 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Maximilian Kossick * - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "PersistentStatisticsStore.h" - -#include "core/meta/Meta.h" -#include "core/support/Amarok.h" -#include "core/support/Debug.h" - -const QString PersistentStatisticsStore::s_sqlDateFormat( "yyyy-MM-dd hh:mm:ss" ); - -PersistentStatisticsStore::PersistentStatisticsStore( Meta::Track *track ) - : m_track( track ) - , m_score( 0.0 ) - , m_rating( 0 ) - , m_playCount( 0 ) - , m_batch( 0 ) -{ - subscribeTo( track ); // notice the track being deleted -} - -PersistentStatisticsStore::~PersistentStatisticsStore() -{ -} - -double -PersistentStatisticsStore::score() const -{ - QReadLocker locker( &m_lock ); - return m_score; -} - -void -PersistentStatisticsStore::setScore( double newScore ) -{ - QWriteLocker locker( &m_lock ); - m_score = newScore; - commitIfInNonBatchUpdate(); -} - -int -PersistentStatisticsStore::rating() const -{ - // no lock, int fetching is atomic - return m_rating; -} - -void -PersistentStatisticsStore::setRating( int newRating ) -{ - QWriteLocker locker( &m_lock ); - m_rating = newRating; - commitIfInNonBatchUpdate(); -} - -QDateTime -PersistentStatisticsStore::lastPlayed() const -{ - QReadLocker locker( &m_lock ); - return m_lastPlayed; -} - -void -PersistentStatisticsStore::setLastPlayed( const QDateTime &dt ) -{ - QWriteLocker locker( &m_lock ); - m_lastPlayed = dt; - commitIfInNonBatchUpdate(); -} - -QDateTime -PersistentStatisticsStore::firstPlayed() const -{ - QReadLocker locker( &m_lock ); - return m_firstPlayed; -} - -void -PersistentStatisticsStore::setFirstPlayed( const QDateTime &dt ) -{ - QWriteLocker locker( &m_lock ); - m_firstPlayed = dt; - commitIfInNonBatchUpdate(); -} - -int -PersistentStatisticsStore::playCount() const -{ - // no lock, in fetching is atomic - return m_playCount; -} - -void -PersistentStatisticsStore::setPlayCount( int playCount ) -{ - QWriteLocker locker( &m_lock ); - m_playCount = playCount; - commitIfInNonBatchUpdate(); -} - -void PersistentStatisticsStore::beginUpdate() -{ - QWriteLocker locker( &m_lock ); - m_batch++; -} - -void PersistentStatisticsStore::endUpdate() -{ - QWriteLocker locker( &m_lock ); - Q_ASSERT( m_batch > 0 ); - m_batch--; - commitIfInNonBatchUpdate(); -} - -void -PersistentStatisticsStore::entityDestroyed() -{ - QWriteLocker locker( &m_lock ); - m_track = 0; // prevent stale pointer -} - -void -PersistentStatisticsStore::commitIfInNonBatchUpdate() -{ - if( m_batch > 0 ) - return; - - save(); - if( m_track ) - { - m_lock.unlock(); // better call the notify without lock hold to prevent deadlocks - m_track->notifyObservers(); - m_lock.lockForWrite(); - } -} diff --git a/amarok/src/core-impl/support/PersistentStatisticsStore.h b/amarok/src/core-impl/support/PersistentStatisticsStore.h deleted file mode 100644 index e9e74265..00000000 --- a/amarok/src/core-impl/support/PersistentStatisticsStore.h +++ /dev/null @@ -1,101 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Maximilian Kossick * - * Copyright (c) 2012 Matěj Lait * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef PERMANENTSTATISTICSSTORE_H -#define PERMANENTSTATISTICSSTORE_H - -#include "amarok_export.h" -#include "core/meta/Observer.h" -#include "core/meta/Statistics.h" - -#include -#include - -/** - * Base class for all permanent statistics storage providers. Use one of the sublassed if - * your collection cannot store statistics (rating, play count..) natively, but you still - * want to provide the functionality. - * - * All subclasses automatically call notifyObservers() on your track when the statistics - * change. PersistentStatisticsStore uses some trickery not to hold reference to your - * track to avoid circular reference counting. PersistentStatisticsStore can even deal - * with your track being destroyed and is implemented in thread-safe way. You should - * store is as StatisticsPtr (a KSharedPtr) in your Track class. - */ -class AMAROK_EXPORT PersistentStatisticsStore : public Meta::Statistics, private Meta::Observer -{ - public: - /** - * Create persistent statistics store of @param track statistics. @param trak may - * not be null. - * - * This methods takes plain pointer so that you can call it in the Track - * constructor without KSharedPtr deleting it right away. - */ - PersistentStatisticsStore( Meta::Track *track ); - virtual ~PersistentStatisticsStore(); - - // Meta::Statistics methods - virtual double score() const; - virtual void setScore( double newScore ); - - virtual int rating() const; - virtual void setRating( int newRating ); - - virtual QDateTime lastPlayed() const; - virtual void setLastPlayed( const QDateTime &dt ); - - virtual QDateTime firstPlayed() const; - virtual void setFirstPlayed( const QDateTime &dt ); - - virtual int playCount() const; - virtual void setPlayCount( int playCount ); - - virtual void beginUpdate(); - virtual void endUpdate(); - - // Meta::Observer methods - - /** - * Notice that the linked track was destroyed. - */ - virtual void entityDestroyed(); - - protected: - virtual void save() = 0; // called with m_lock locked for writing! - - static const QString s_sqlDateFormat; - - Meta::Track *m_track; // plain pointer not to hold reference - QDateTime m_lastPlayed; - QDateTime m_firstPlayed; - double m_score; - int m_rating; - int m_playCount; - mutable QReadWriteLock m_lock; // lock procecting access to fields. - - private: - void commitIfInNonBatchUpdate(); // must be called with the m_lock locked for writing - - /** - * Number of current batch operations started by @see beginUpdate() and not - * yet ended by @see endUpdate(). Must only be accessed with m_track held. - */ - int m_batch; -}; - -#endif // PERMANENTSTATISTICSSTORE_H diff --git a/amarok/src/core-impl/support/TagStatisticsStore.cpp b/amarok/src/core-impl/support/TagStatisticsStore.cpp deleted file mode 100644 index d72aceda..00000000 --- a/amarok/src/core-impl/support/TagStatisticsStore.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "TagStatisticsStore.h" - -#include -#include "core/meta/Meta.h" -#include "core-impl/storage/StorageManager.h" - -TagStatisticsStore::TagStatisticsStore( Meta::Track *track ) - : PersistentStatisticsStore( track ) - , m_name( track->name() ) - , m_artist( track->artist() ? track->artist()->name() : QString() ) - , m_album( track->album() ? track->album()->name() : QString() ) -{ - SqlStorage *sql = StorageManager::instance()->sqlStorage(); - - const QString query = "SELECT firstPlayed, lastPlayed, score, rating, playcount FROM " - "statistics_tag WHERE name = '%1' AND artist = '%2' AND album = '%3'"; - QStringList result = sql->query( query.arg( sql->escape( m_name ), - sql->escape( m_artist ), - sql->escape( m_album ) ) ); - if( !result.isEmpty() ) - { - m_firstPlayed = QDateTime::fromString( result.value( 0 ), s_sqlDateFormat ); - m_lastPlayed = QDateTime::fromString( result.value( 1 ), s_sqlDateFormat ); - m_score = result.value( 2 ).toDouble(); - m_rating = result.value( 3 ).toInt(); - m_playCount = result.value( 4 ).toInt(); - } -} - -void -TagStatisticsStore::save() -{ - SqlStorage *sql = StorageManager::instance()->sqlStorage(); - - const QString check = "SELECT COUNT(*) FROM statistics_tag WHERE name = '%1' " - "AND artist = '%2' AND album = '%3'"; - QStringList rsCheck = sql->query( check.arg( sql->escape( m_name ), - sql->escape( m_artist ), - sql->escape( m_album ) ) ); - if( !rsCheck.isEmpty() ) - { - QString sqlString; - if( rsCheck.first().toInt() ) - { - sqlString = "UPDATE statistics_tag SET firstPlayed = '%1',lastPlayed = '%2'," - "score = %3,rating = %4,playcount=%5 WHERE name = '%6' " - "AND artist = '%7' AND album = '%8'"; - } - else - { - sqlString = "INSERT INTO statistics_tag(firstPlayed,lastPlayed,score," - "rating,playcount,name,artist,album) " - "VALUE ('%1','%2',%3,%4,%5,'%6','%7','%8')"; - } - sqlString = sqlString.arg( m_firstPlayed.toString( s_sqlDateFormat ), - m_lastPlayed.toString( s_sqlDateFormat ), - QString::number( m_score ), - QString::number( m_rating ), - QString::number( m_playCount ), - sql->escape( m_name ), - sql->escape( m_artist ), - sql->escape( m_album ) ); - sql->query( sqlString ); - } -} diff --git a/amarok/src/core-impl/support/TagStatisticsStore.h b/amarok/src/core-impl/support/TagStatisticsStore.h deleted file mode 100644 index 696c1c47..00000000 --- a/amarok/src/core-impl/support/TagStatisticsStore.h +++ /dev/null @@ -1,38 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef TAGSTATISTICSPROVIDER_H -#define TAGSTATISTICSPROVIDER_H - -#include "core-impl/support/PersistentStatisticsStore.h" - -#include - -class AMAROK_EXPORT TagStatisticsStore : public PersistentStatisticsStore -{ - public: - TagStatisticsStore( Meta::Track *track ); - - protected: - virtual void save(); - - private: - QString m_name; - QString m_artist; - QString m_album; -}; - -#endif // PERMANENTURLSTATISTICSPROVIDER_H diff --git a/amarok/src/core-impl/support/TrackLoader.cpp b/amarok/src/core-impl/support/TrackLoader.cpp deleted file mode 100644 index 04bb0a84..00000000 --- a/amarok/src/core-impl/support/TrackLoader.cpp +++ /dev/null @@ -1,294 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007-2008 Ian Monroe * - * Copyright (c) 2013 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) version 3 or * - * any later version accepted by the membership of KDE e.V. (or its successor approved * - * by the membership of KDE e.V.), which shall act as a proxy defined in Section 14 of * - * version 3 of the license. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "TrackLoader.h" - -#include "core/playlists/PlaylistFormat.h" -#include "core/support/Debug.h" -#include "core-impl/meta/file/File.h" -#include "core-impl/meta/proxy/MetaProxy.h" -#include "core-impl/meta/multi/MultiTrack.h" -#include "core-impl/playlists/types/file/PlaylistFileSupport.h" - -#include -#include - -#include -#include - -TrackLoader::TrackLoader( Flags flags, int timeout ) - : m_status( LoadingTracks ) - , m_flags( flags ) - , m_timeout( timeout ) -{ -} - -TrackLoader::~TrackLoader() -{ -} - -void -TrackLoader::init( const KUrl &url ) -{ - init( QList() << url ); -} - -void -TrackLoader::init( const QList &qurls ) -{ - QList kurls; - foreach( const QUrl &qurl, qurls ) - kurls << KUrl( qurl ); - init( kurls ); -} - -void -TrackLoader::init( const QList &urls ) -{ - m_sourceUrls = urls; - QTimer::singleShot( 0, this, SLOT(processNextSourceUrl()) ); -} - -void -TrackLoader::init( const Playlists::PlaylistList &playlists ) -{ - m_resultPlaylists = playlists; - // no need to process source urls here, short-cut to result urls (just playlists) - QTimer::singleShot( 0, this, SLOT(processNextResultUrl()) ); -} - -void -TrackLoader::processNextSourceUrl() -{ - if( m_sourceUrls.isEmpty() ) - { - QTimer::singleShot( 0, this, SLOT(processNextResultUrl()) ); - return; - } - - KUrl sourceUrl = m_sourceUrls.takeFirst(); - if( sourceUrl.isLocalFile() && QFileInfo( sourceUrl.toLocalFile() ).isDir() ) - { - // KJobs delete themselves - KIO::ListJob *lister = KIO::listRecursive( sourceUrl, KIO::HideProgressInfo ); - connect( lister, SIGNAL(finished(KJob*)), SLOT(listJobFinished()) ); - connect( lister, SIGNAL(entries(KIO::Job*,KIO::UDSEntryList)), - SLOT(directoryListResults(KIO::Job*,KIO::UDSEntryList)) ); - // listJobFinished() calls processNextSourceUrl() in the end, don't do it here: - return; - } - else - m_resultUrls.append( sourceUrl ); - - QTimer::singleShot( 0, this, SLOT(processNextSourceUrl()) ); -} - -void -TrackLoader::directoryListResults( KIO::Job *job, const KIO::UDSEntryList &list ) -{ - //dfaure says that job->redirectionUrl().isValid() ? job->redirectionUrl() : job->url(); might be needed - //but to wait until an issue is actually found, since it might take more work - const KUrl dir = static_cast( job )->url(); - foreach( const KIO::UDSEntry &entry, list ) - { - KFileItem item( entry, dir, true, true ); - KUrl url = item.url(); - if( MetaFile::Track::isTrack( url ) ) - m_listJobResults << url; - } -} - -void -TrackLoader::listJobFinished() -{ - qSort( m_listJobResults.begin(), m_listJobResults.end(), directorySensitiveLessThan ); - - m_resultUrls << m_listJobResults; - m_listJobResults.clear(); - - QTimer::singleShot( 0, this, SLOT(processNextSourceUrl()) ); -} - -void -TrackLoader::processNextResultUrl() -{ - using namespace Playlists; - if( !m_resultPlaylists.isEmpty() ) - { - PlaylistPtr playlist = m_resultPlaylists.takeFirst(); - PlaylistObserver::subscribeTo( playlist ); - playlist->triggerTrackLoad(); // playlist track loading is on demand. - // will trigger tracksLoaded() which in turn calls processNextResultUrl(), - // therefore we shouldn't call trigger processNextResultUrl() here: - return; - } - - if( m_resultUrls.isEmpty() ) - { - mayFinish(); - return; - } - - KUrl resultUrl = m_resultUrls.takeFirst(); - if( isPlaylist( resultUrl ) ) - { - PlaylistFilePtr playlist = loadPlaylistFile( resultUrl ); - if( playlist ) - { - PlaylistObserver::subscribeTo( PlaylistPtr::staticCast( playlist ) ); - playlist->triggerTrackLoad(); // playlist track loading is on demand. - // will trigger tracksLoaded() which in turn calls processNextResultUrl(), - // therefore we shouldn't call trigger processNextResultUrl() here: - return; - } - else - warning() << __PRETTY_FUNCTION__ << "cannot load playlist" << resultUrl; - } - else if( MetaFile::Track::isTrack( resultUrl ) ) - { - MetaProxy::TrackPtr proxyTrack( new MetaProxy::Track( resultUrl ) ); - proxyTrack->setTitle( resultUrl.fileName() ); // set temporary name - Meta::TrackPtr track( proxyTrack.data() ); - m_tracks << Meta::TrackPtr( track ); - - if( m_flags.testFlag( FullMetadataRequired ) && !proxyTrack->isResolved() ) - { - m_unresolvedTracks.insert( track ); - Observer::subscribeTo( track ); - } - } - else - warning() << __PRETTY_FUNCTION__ << resultUrl - << "is neither a playlist or a track, skipping"; - - QTimer::singleShot( 0, this, SLOT(processNextResultUrl()) ); -} - -void -TrackLoader::tracksLoaded( Playlists::PlaylistPtr playlist ) -{ - // this method needs to be thread-safe! - - // some playlists used to emit tracksLoaded() in ->tracks(), prevent infinite - // recursion by unsubscribing early - PlaylistObserver::unsubscribeFrom( playlist ); - - // accessing m_tracks is thread-safe as nothing else is happening in this class in - // the main thread while we are waiting for tracksLoaded() to trigger: - Meta::TrackList tracks = playlist->tracks(); - if( m_flags.testFlag( FullMetadataRequired ) ) - { - foreach( const Meta::TrackPtr &track, tracks ) - { - MetaProxy::TrackPtr proxyTrack = MetaProxy::TrackPtr::dynamicCast( track ); - if( !proxyTrack ) - { - debug() << __PRETTY_FUNCTION__ << "strange, playlist" << playlist->name() - << "doesn't use MetaProxy::Tracks"; - continue; - } - if( !proxyTrack->isResolved() ) - { - m_unresolvedTracks.insert( track ); - Observer::subscribeTo( track ); - } - } - } - - static const QSet remoteProtocols = QSet() - << "http" << "https" << "mms" << "smb"; // consider unifying with CollectionManager::trackForUrl() - if( m_flags.testFlag( RemotePlaylistsAreStreams ) && tracks.count() > 1 - && remoteProtocols.contains( playlist->uidUrl().protocol() ) ) - { - m_tracks << Meta::TrackPtr( new Meta::MultiTrack( playlist ) ); - } - else - m_tracks << tracks; - - // this also ensures that processNextResultUrl() will resume in the main thread - QTimer::singleShot( 0, this, SLOT(processNextResultUrl()) ); -} - -void -TrackLoader::metadataChanged( Meta::TrackPtr track ) -{ - // first metadataChanged() from a MetaProxy::Track means that it has found the real track - bool isEmpty; - { - QMutexLocker locker( &m_unresolvedTracksMutex ); - m_unresolvedTracks.remove( track ); - isEmpty = m_unresolvedTracks.isEmpty(); - } - - Observer::unsubscribeFrom( track ); - if( m_status == MayFinish && isEmpty ) - QTimer::singleShot( 0, this, SLOT(finish()) ); -} - -void -TrackLoader::mayFinish() -{ - m_status = MayFinish; - bool isEmpty; - { - QMutexLocker locker( &m_unresolvedTracksMutex ); - isEmpty = m_unresolvedTracks.isEmpty(); - } - if( isEmpty ) - { - finish(); - return; - } - - // we must wait for tracks to resolve, but with a timeout - QTimer::singleShot( m_timeout, this, SLOT(finish()) ); -} - -void -TrackLoader::finish() -{ - // prevent double emit of finished(), race between singleshot QTimers from mayFinish() - // and metadataChanged() - if( m_status != MayFinish ) - return; - - m_status = Finished; - emit finished( m_tracks ); - deleteLater(); -} - -bool -TrackLoader::directorySensitiveLessThan( const KUrl &left, const KUrl &right ) -{ - QString leftDir = left.directory( KUrl::AppendTrailingSlash ); - QString rightDir = right.directory( KUrl::AppendTrailingSlash ); - - // filter out tracks from same directories: - if( leftDir == rightDir ) - return QString::localeAwareCompare( left.fileName(), right.fileName() ) < 0; - - // left is "/a/b/c/", right is "/a/b/" - if( leftDir.startsWith( rightDir ) ) - return true; // we sort directories above files - // left is "/a/b/", right is "/a/b/c/" - if( rightDir.startsWith( leftDir ) ) - return false; - - return QString::localeAwareCompare( leftDir, rightDir ) < 0; -} diff --git a/amarok/src/core-impl/support/TrackLoader.h b/amarok/src/core-impl/support/TrackLoader.h deleted file mode 100644 index 1a368f4b..00000000 --- a/amarok/src/core-impl/support/TrackLoader.h +++ /dev/null @@ -1,152 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Ian Monroe * - * Copyright (c) 2013 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) version 3 or * - * any later version accepted by the membership of KDE e.V. (or its successor approved * - * by the membership of KDE e.V.), which shall act as a proxy defined in Section 14 of * - * version 3 of the license. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_TRACKLOADER_H -#define AMAROK_TRACKLOADER_H - -#include "amarok_export.h" -#include "core/meta/forward_declarations.h" -#include "core/meta/Observer.h" -#include "core/playlists/Playlist.h" - -namespace KIO { - class Job; - class UDSEntry; - typedef QList UDSEntryList; -} - -/** - * Helper class that helps with loading of urls (with local and remote tracks, - * playlists and local directories) to tracks. - * - * Only explicitly listed playlists are loaded, not the ones found in subdirectories. - * TrackLoader takes care to preserve order of urls you pass, and it sorts tracks in - * directories you pass it using directory- and locale-aware sort. - */ -class AMAROK_EXPORT TrackLoader : public QObject, public Playlists::PlaylistObserver, public Meta::Observer -{ - Q_OBJECT - - public: - /** - * FullMetadataRequired: signal TrackLoader that it should postpone the finished() - * signal until the any possible proxy tracks have resolved and their full - * metadata is available. Also use this flag when you need to immediately play - * the tracks. This no longer implies any blocking behaviour, you'll just get the - * finished signal a bit later. - * - * RemotePlaylistsAreStreams: treat playlists with remote urls as Streams with - * multiple alternative download locations (Meta::MultiTracks). Works even when - * you pass playlists. - */ - enum Flag { - FullMetadataRequired = 1 << 0, - RemotePlaylistsAreStreams = 1 << 1, - }; - Q_DECLARE_FLAGS( Flags, Flag ) - - /** - * Construct TrackLoader. You must construct it on the heap, it will auto-delete - * itself. - * - * @param flags binary or of flags, see TrackLoader::Flags enum - * @param timeout if FullMetadataRequired is in flags, this is the timeout in - * milliseconds for wating on track to resolve. Ignored otherwise. - */ - TrackLoader( Flags flags = 0, int timeout = 2000 ); - ~TrackLoader(); - - /** - * Convenience overload for init( const QList &urls ) - */ - void init( const KUrl &url ); - - /** - * Convenience overload for init( const QList &urls ) - */ - void init( const QList &urls ); - - /** - * Starts TrackLoader's job, you'll get finished() signal in the end and - * TrackLoader will auto-delete itself. - * - * @urls list of urls to load tracks from, you can pass local and remote urls - * pointing to directories, tracks and playlists. - */ - void init( const QList &urls ); - - /** - * Short-hand if you already have a list of playlists and want a convenient way - * to get notified of their loaded tracks. See init( const QList ) and - * class description. - */ - void init( const Playlists::PlaylistList &playlists ); - - /* PlaylistObserver methods */ - using PlaylistObserver::metadataChanged; - virtual void tracksLoaded( Playlists::PlaylistPtr playlist ); - - /* Meta::Observer methods */ - using Observer::metadataChanged; - virtual void metadataChanged( Meta::TrackPtr track ); - - signals: - void finished( const Meta::TrackList &tracks ); - - private slots: - void processNextSourceUrl(); - void directoryListResults( KIO::Job *job, const KIO::UDSEntryList &list ); - void listJobFinished(); - void processNextResultUrl(); - /** - * Emits the result and auto-destroys the TrackLoader - */ - void finish(); - - private: - enum Status { - LoadingTracks, - MayFinish, - Finished - }; - void mayFinish(); - - static bool directorySensitiveLessThan( const KUrl &left, const KUrl &right ); - - Status m_status; - const Flags m_flags; - int m_timeout; - /// passed urls, may contain urls of directories - QList m_sourceUrls; - /// contains just urls of tracks and playlists - QList m_resultUrls; - /// a list of playlists directly passed, same semantics as m_resultUrls - Playlists::PlaylistList m_resultPlaylists; - /// the tracks found - Meta::TrackList m_tracks; - /// temporary list of results of the list job, to keep right sorting - QList m_listJobResults; - /// set of unresolved MetaProxy::Tracks that we wait for - QSet m_unresolvedTracks; - QMutex m_unresolvedTracksMutex; -}; - -Q_DECLARE_OPERATORS_FOR_FLAGS( TrackLoader::Flags ) - -#endif // AMAROK_TRACKLOADER_H diff --git a/amarok/src/core-impl/support/UrlStatisticsStore.cpp b/amarok/src/core-impl/support/UrlStatisticsStore.cpp deleted file mode 100644 index b25c3181..00000000 --- a/amarok/src/core-impl/support/UrlStatisticsStore.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "UrlStatisticsStore.h" - -#include -#include "core/meta/Meta.h" -#include "core/support/Debug.h" -#include "core-impl/storage/StorageManager.h" - -UrlStatisticsStore::UrlStatisticsStore( Meta::Track *track, const QString &permanentUrl ) - : PersistentStatisticsStore( track ) - , m_permanentUrl( permanentUrl ) -{ - if( m_permanentUrl.isEmpty() ) - m_permanentUrl = track->uidUrl(); - SqlStorage *sql = StorageManager::instance()->sqlStorage(); - if( !sql ) - { - warning() << __PRETTY_FUNCTION__ << "could not get SqlStorage, aborting"; - return; - } - - - const QString query = "SELECT firstplayed, lastplayed, score, rating, playcount FROM " - "statistics_permanent WHERE url = '%1'"; - QStringList result = sql->query( query.arg( sql->escape( m_permanentUrl ) ) ); - if( !result.isEmpty() ) - { - m_firstPlayed = QDateTime::fromString( result.value( 0 ), s_sqlDateFormat ); - m_lastPlayed = QDateTime::fromString( result.value( 1 ), s_sqlDateFormat ); - m_score = result.value( 2 ).toDouble(); - m_rating = result.value( 3 ).toInt(); - m_playCount = result.value( 4 ).toInt(); - } -} - -void -UrlStatisticsStore::save() -{ - SqlStorage *sql = StorageManager::instance()->sqlStorage(); - if( !sql ) - { - warning() << __PRETTY_FUNCTION__ << "could not get SqlStorage, aborting"; - return; - } - - const QString check = "SELECT COUNT(*) FROM statistics_permanent WHERE url = '%1'"; - QStringList rsCheck = sql->query( check.arg( sql->escape( m_permanentUrl ) ) ); - if( !rsCheck.isEmpty() ) - { - QString sqlString; - if( rsCheck.first().toInt() ) - { - sqlString = "UPDATE statistics_permanent SET firstplayed = '%1',lastplayed = '%2'," - "score = %3,rating = %4,playcount=%5 WHERE url = '%6'"; - } - else - { - sqlString = "INSERT INTO statistics_permanent(firstplayed,lastplayed,score," - "rating,playcount,url) VALUE ('%1','%2',%3,%4,%5,'%6')"; - } - sqlString = sqlString.arg( m_firstPlayed.toString( s_sqlDateFormat ), - m_lastPlayed.toString( s_sqlDateFormat ), - QString::number( m_score ), - QString::number( m_rating ), - QString::number( m_playCount ), - sql->escape( m_permanentUrl ) ); - sql->query( sqlString ); - } -} diff --git a/amarok/src/core-impl/support/UrlStatisticsStore.h b/amarok/src/core-impl/support/UrlStatisticsStore.h deleted file mode 100644 index 52d9b2ea..00000000 --- a/amarok/src/core-impl/support/UrlStatisticsStore.h +++ /dev/null @@ -1,40 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef URLSTATISTICSSTORE_H -#define URLSTATISTICSSTORE_H - -#include "core-impl/support/PersistentStatisticsStore.h" - -#include - -class AMAROK_EXPORT UrlStatisticsStore : public PersistentStatisticsStore -{ - public: - /** - * Construct persistent per-url statistics store. If @param permanentUrl is not - * specified, track->uidUrl() is used. - */ - UrlStatisticsStore( Meta::Track *track, const QString &permanentUrl = QString() ); - - protected: - virtual void save(); - - private: - QString m_permanentUrl; -}; - -#endif // URLSTATISTICSSTORE_H diff --git a/amarok/src/core/CMakeLists.txt b/amarok/src/core/CMakeLists.txt deleted file mode 100644 index 7b6bc52f..00000000 --- a/amarok/src/core/CMakeLists.txt +++ /dev/null @@ -1,123 +0,0 @@ -include_directories( - ${CMAKE_SOURCE_DIR}/src - ${CMAKE_SOURCE_DIR}/shared - ${KDE4_INCLUDE_DIR} - ${QT_INCLUDES} -) - -set(libcore_interfaces_SRCS - interfaces/Logger.cpp - interfaces/MetaCapability.cpp -) - -set(libcore_meta_SRCS - meta/Base.cpp - meta/Meta.cpp - meta/Observer.cpp - meta/Statistics.cpp - meta/TrackEditor.cpp - meta/support/MetaConstants.cpp - meta/support/MetaUtility.cpp - meta/support/MetaKeys.cpp - meta/support/PrivateMetaRegistry.cpp -) - -set(libcore_playlists_SRCS - playlists/Playlist.cpp - playlists/PlaylistFormat.cpp - playlists/PlaylistProvider.cpp -) - -set(libcore_capabilities_SRCS - capabilities/Capability.cpp - capabilities/ActionsCapability.cpp - capabilities/BookmarkThisCapability.cpp - capabilities/BoundedPlaybackCapability.cpp - capabilities/CollectionScanCapability.cpp - capabilities/CollectionImportCapability.cpp - capabilities/FindInSourceCapability.cpp - capabilities/MultiPlayableCapability.cpp - capabilities/MultiSourceCapability.cpp - capabilities/OrganiseCapability.cpp - capabilities/ReadLabelCapability.cpp - capabilities/SourceInfoCapability.cpp - capabilities/StreamInfoCapability.cpp - capabilities/TranscodeCapability.cpp - capabilities/WriteLabelCapability.cpp -) - -set(libcore_collection_SRCS - collections/Collection.cpp - collections/CollectionLocation.cpp - collections/MetaQueryMaker.cpp - collections/QueryMaker.cpp - collections/support/TrackForUrlWorker.cpp -) - -set(libcore_storage_SRCS - storage/StorageFactory.cpp -) - -set(libcore_podcasts_SRCS - podcasts/PodcastReader.cpp - podcasts/PodcastMeta.cpp - podcasts/PodcastImageFetcher.cpp - podcasts/PodcastProvider.cpp -) - -set(libcore_support_SRCS - support/Amarok.cpp - support/Components.cpp - support/SemaphoreReleaser.cpp - support/SmartPointerList.cpp - support/PluginFactory.cpp - support/Debug.cpp -) - -set(libcore_transcoding_SRCS - transcoding/formats/TranscodingNullFormat.cpp - transcoding/formats/TranscodingAacFormat.cpp - transcoding/formats/TranscodingAlacFormat.cpp - transcoding/formats/TranscodingFlacFormat.cpp - transcoding/formats/TranscodingMp3Format.cpp - transcoding/formats/TranscodingOpusFormat.cpp - transcoding/formats/TranscodingVorbisFormat.cpp - transcoding/formats/TranscodingWmaFormat.cpp - transcoding/TranscodingConfiguration.cpp - transcoding/TranscodingController.cpp - transcoding/TranscodingProperty.cpp -) - -##################################################################### -# LIBCORE -##################################################################### -set(libcore_LIB_SRCS - ${libcore_podcasts_SRCS} - ${libcore_interfaces_SRCS} - ${libcore_collection_SRCS} - ${libcore_storage_SRCS} - ${libcore_playlists_SRCS} - ${libcore_meta_SRCS} - ${libcore_capabilities_SRCS} - ${libcore_support_SRCS} - ${libcore_transcoding_SRCS} -) - -add_library(amarokcore SHARED ${libcore_LIB_SRCS}) - -target_link_libraries(amarokcore - amarokshared - ${CMAKE_DL_LIBS} - ${CMAKE_THREAD_LIBS_INIT} - ${KDE4_KIO_LIBS} - ${KDE4_SOLID_LIBRARY} - ${KDE4_THREADWEAVER_LIBS} - ${QT_CORE_LIBRARY} -) - -if(APPLE) - SET_TARGET_PROPERTIES(amarokcore PROPERTIES LINK_FLAGS "-undefined dynamic_lookup") -endif(APPLE) - -set_target_properties(amarokcore PROPERTIES VERSION 1.0.0 SOVERSION 1 ) -install(TARGETS amarokcore ${INSTALL_TARGETS_DEFAULT_ARGS} ) diff --git a/amarok/src/core/README b/amarok/src/core/README deleted file mode 100644 index 425b478f..00000000 --- a/amarok/src/core/README +++ /dev/null @@ -1,6 +0,0 @@ -This library needs to be solely self-referential. - -If you are putting any code in here that includes files outside of this -library, with the exception of includes in the top-level shared/ directory, -YOU ARE DOING IT WRONG and should cease and desist immediately. - diff --git a/amarok/src/core/amarokcore_export.h b/amarok/src/core/amarokcore_export.h deleted file mode 100644 index 6eed5aa6..00000000 --- a/amarok/src/core/amarokcore_export.h +++ /dev/null @@ -1,35 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 David Faure * - * Copyright (c) 2010 Patrick von Reth * - * Copyright (c) 2013 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROKCORE_EXPORT_H -#define AMAROKCORE_EXPORT_H - -/* needed for KDE_EXPORT and KDE_IMPORT macros */ -#include - -#ifndef AMAROK_CORE_EXPORT -# ifdef MAKE_AMAROKCORE_LIB - /* We are building this library */ -# define AMAROK_CORE_EXPORT KDE_EXPORT -# else - /* We are using this library */ -# define AMAROK_CORE_EXPORT KDE_IMPORT -# endif // MAKE_AMAROKCORE_LIB -#endif // AMAROK_CORE_EXPORT - -#endif // AMAROKCORE_EXPORT_H diff --git a/amarok/src/core/capabilities/ActionsCapability.cpp b/amarok/src/core/capabilities/ActionsCapability.cpp deleted file mode 100644 index fe8f6c00..00000000 --- a/amarok/src/core/capabilities/ActionsCapability.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "core/capabilities/ActionsCapability.h" - -Capabilities::ActionsCapability::ActionsCapability() - : Capabilities::Capability() -{ - //nothing to do -} - -Capabilities::ActionsCapability::ActionsCapability( const QList &actions ) - : Capabilities::Capability() - , m_actions( actions ) -{ - //nothing to do -} - -Capabilities::ActionsCapability::~ActionsCapability() -{ - //nothing to do. -} - -QList -Capabilities::ActionsCapability::actions() const -{ - return m_actions; -} - -#include "moc_ActionsCapability.cpp" diff --git a/amarok/src/core/capabilities/ActionsCapability.h b/amarok/src/core/capabilities/ActionsCapability.h deleted file mode 100644 index 0bf9e32b..00000000 --- a/amarok/src/core/capabilities/ActionsCapability.h +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_ACTIONSCAPABILITY_H -#define AMAROK_ACTIONSCAPABILITY_H - -#include "core/amarokcore_export.h" -#include "core/capabilities/Capability.h" - -#include -#include - -namespace Capabilities -{ - /** - * This capability allows different meta types to display custom actions in the right click menu in the tree view - * or anywhere else where the actions are shown. This is useful for purchasing from stores, downloading from services - * banning a genre or whatever we can think of in the future. - * - * If you want to provide this capability for an album, consider using - * @see AlbumActionsCapability that provides you with common album actions such as - * show cover etc. for free. - * - * @author Nikolaj Hald Nielsen - */ - class AMAROK_CORE_EXPORT ActionsCapability : public Capabilities::Capability - { - Q_OBJECT - public: - /** - * Constructor - * Note: The actions are not freed after usage - * @param actions A list of actions to use. - */ - ActionsCapability( const QList< QAction* > &actions ); - - /** - * Destructor - */ - virtual ~ActionsCapability(); - - /** - * Get the custom actions for this capablility - * The caller must free actions that have no parent after use. - * Actions with a parent are freed by the parent (obviously) - * @return The list of actions - */ - virtual QList actions() const; - - /** - * Get the capabilityInterfaceType of this capability - * @return The capabilityInterfaceType ( always Capabilities::Capability::Actions; ) - */ - static Type capabilityInterfaceType() { return Capabilities::Capability::Actions; } - - protected: - /** - * No-action constructor has sense only for subclasses. - */ - ActionsCapability(); - - QList< QAction* > m_actions; - }; -} - -#endif diff --git a/amarok/src/core/capabilities/BookmarkThisCapability.cpp b/amarok/src/core/capabilities/BookmarkThisCapability.cpp deleted file mode 100644 index 8e07142c..00000000 --- a/amarok/src/core/capabilities/BookmarkThisCapability.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "core/capabilities/BookmarkThisCapability.h" - -namespace Capabilities { - -BookmarkThisCapability::BookmarkThisCapability( QAction *action ) - : m_action( action ) -{ } - -BookmarkThisCapability::~BookmarkThisCapability() -{ } - - -} diff --git a/amarok/src/core/capabilities/BookmarkThisCapability.h b/amarok/src/core/capabilities/BookmarkThisCapability.h deleted file mode 100644 index 64d8b15c..00000000 --- a/amarok/src/core/capabilities/BookmarkThisCapability.h +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef METABOOKMARKTHISCAPABILITY_H -#define METABOOKMARKTHISCAPABILITY_H - -#include "core/amarokcore_export.h" -#include "core/capabilities/Capability.h" - -#include - -namespace Capabilities { - -/** - This capability determines whether a meta item in a collection can be directly bookmarked. Not all collections/services supports bookmarks on all levels, and some might not support Item level bookmarks at all as they have no query field and some might only support simple queries. - - @author Nikolaj Hald Nielsen -*/ -class AMAROK_CORE_EXPORT BookmarkThisCapability : public Capability { - Q_OBJECT -public: - BookmarkThisCapability( QAction* action ); - virtual ~BookmarkThisCapability(); - - virtual bool isBookmarkable() { return true; } - virtual QString browserName() { return "collections"; } - virtual QString collectionName() { return QString(); } - virtual bool simpleFiltering() { return false; } - - /** - The caller must free actions that have no parent after use. - Actions with a parent are freed by the parent (obviously) - @return the bookmarkAction itself (or 0). - */ - virtual QAction * bookmarkAction() const { return m_action; } - - /** - * Get the capabilityInterfaceType of this capability - * @return The capabilityInterfaceType ( always Capabilities::Capability::BookmarkThis; ) - */ - static Type capabilityInterfaceType() { return Capabilities::Capability::BookmarkThis; } - -protected: - QAction* m_action; - -}; - -} - -#endif diff --git a/amarok/src/core/capabilities/BoundedPlaybackCapability.cpp b/amarok/src/core/capabilities/BoundedPlaybackCapability.cpp deleted file mode 100644 index 6f1d8c68..00000000 --- a/amarok/src/core/capabilities/BoundedPlaybackCapability.cpp +++ /dev/null @@ -1,35 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "core/capabilities/BoundedPlaybackCapability.h" - -namespace Capabilities { - -Capabilities::BoundedPlaybackCapability::BoundedPlaybackCapability() - : Capability() -{ -} - -BoundedPlaybackCapability::~BoundedPlaybackCapability() -{ -} - -} - -#include "moc_BoundedPlaybackCapability.cpp" - - - diff --git a/amarok/src/core/capabilities/BoundedPlaybackCapability.h b/amarok/src/core/capabilities/BoundedPlaybackCapability.h deleted file mode 100644 index d5ee3994..00000000 --- a/amarok/src/core/capabilities/BoundedPlaybackCapability.h +++ /dev/null @@ -1,49 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef METABOUNDEDPLAYBACKCAPABILITY_H -#define METABOUNDEDPLAYBACKCAPABILITY_H - -#include "core/capabilities/Capability.h" - -namespace Capabilities { - -/** -A capability for tracks that represents a given, bounded, interval of a url, for instance a single track in a long podcast. - - @author Nikolaj Hald Nielsen -*/ -class AMAROK_CORE_EXPORT BoundedPlaybackCapability : public Capability -{ - Q_OBJECT -public: - BoundedPlaybackCapability(); - ~BoundedPlaybackCapability(); - - virtual qint64 startPosition() = 0; - virtual qint64 endPosition() = 0; - - /** - * Get the capabilityInterfaceType of this capability - * @return The capabilityInterfaceType ( always Capabilities::Capability::BoundedPlayback; ) - */ - static Type capabilityInterfaceType() { return Capability::BoundedPlayback; } - -}; - -} - -#endif diff --git a/amarok/src/core/capabilities/Capability.cpp b/amarok/src/core/capabilities/Capability.cpp deleted file mode 100644 index b27f3120..00000000 --- a/amarok/src/core/capabilities/Capability.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "core/capabilities/Capability.h" - -Capabilities::Capability::~Capability() -{ - //nothing to do -} - -#include "moc_Capability.cpp" diff --git a/amarok/src/core/capabilities/Capability.h b/amarok/src/core/capabilities/Capability.h deleted file mode 100644 index 9fa5a3c1..00000000 --- a/amarok/src/core/capabilities/Capability.h +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_CAPABILITY_H -#define AMAROK_CAPABILITY_H - -#include "core/amarokcore_export.h" - -#include - -namespace Capabilities -{ - /** The capabilities are used by several amarok objects to express add on functionality. - Capabilities are used inside Amarok to implement a Java-like interface pattern. - Several object (Collection, Track, Album) can return capability object. - Since the implementation of these objects is in a library usually it would - be otherwise difficult to implement something like this. - - Please note that the capability object will be created on demand and - also destroyed. - */ - class AMAROK_CORE_EXPORT Capability : public QObject - { - Q_OBJECT - Q_ENUMS( Type ) - - public: - //add additional capabilities here - enum Type { Unknown = 0 - // not longer used - // not longer used - , Buyable = 3 - , Actions = 4 - , EditablePlaylist = 5 - , MultiPlayable = 6 - , Organisable = 7 - , SourceInfo = 8 - // not longer used - , StreamInfo = 10 - // not longer used - // not longe used - // not longer used - , BookmarkThis = 14 - , WriteTimecode = 15 - , LoadTimecode = 16 - , MultiSource = 17 - , BoundedPlayback = 18 - // not longer used - , ReadLabel = 20 - , WriteLabel = 21 - , FindInSource = 22 - , CollectionImport = 23 - , CollectionScan = 24 - , Transcode = 25 - }; - - virtual ~Capability(); - - }; -} - - -#endif diff --git a/amarok/src/core/capabilities/CollectionImportCapability.cpp b/amarok/src/core/capabilities/CollectionImportCapability.cpp deleted file mode 100644 index 384592dc..00000000 --- a/amarok/src/core/capabilities/CollectionImportCapability.cpp +++ /dev/null @@ -1,26 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Ralf Engels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "core/capabilities/CollectionImportCapability.h" - -Capabilities::CollectionImportCapability::CollectionImportCapability() - : Capabilities::Capability() -{ } - -Capabilities::CollectionImportCapability::~CollectionImportCapability() -{ } - -#include "moc_CollectionImportCapability.cpp" diff --git a/amarok/src/core/capabilities/CollectionImportCapability.h b/amarok/src/core/capabilities/CollectionImportCapability.h deleted file mode 100644 index 7f0da287..00000000 --- a/amarok/src/core/capabilities/CollectionImportCapability.h +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Ralf Engels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_COLLECTIONIMPORTCAPABILITY_H -#define AMAROK_COLLECTIONIMPORTCAPABILITY_H - -#include "core/amarokcore_export.h" -#include "core/capabilities/Capability.h" - -#include - -namespace Capabilities -{ - /** - * This capability allows the collection to import it's content form a file. - * Currently this is only used by the SqlCollection and it's scanner - * - * @author Ralf Engels - */ - - class AMAROK_CORE_EXPORT CollectionImportCapability : public Capabilities::Capability - { - Q_OBJECT - public: - - CollectionImportCapability(); - virtual ~CollectionImportCapability(); - - /** Starts importing the given file into the collection. - @param input is an already opened input device. The importer will take ownership. - @param listener An object that will listen on import signals. - Those signals are: - trackAdded( Meta::TrackPtr ) - trackDiscarded( QString ) - trackMatchFound( Meta::TrackPtr, QString ) - trackMatchMultiple( Meta::TrackList, QString ) - importError( QString ) - done( ThreadWeaver::Job* ) - showMessage( QString ) - @return A QObject that can be used to connect several status signals from. - */ - virtual void import( QIODevice *input, QObject *listener ) = 0; - - /** Get the capabilityInterfaceType of this capability - @return The capabilityInterfaceType ( always Capabilities::Capability::CollectionImport; ) - */ - static Type capabilityInterfaceType() { return Capabilities::Capability::CollectionImport; } - }; -} - -#endif diff --git a/amarok/src/core/capabilities/CollectionScanCapability.cpp b/amarok/src/core/capabilities/CollectionScanCapability.cpp deleted file mode 100644 index da48dc98..00000000 --- a/amarok/src/core/capabilities/CollectionScanCapability.cpp +++ /dev/null @@ -1,26 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Ralf Engels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "core/capabilities/CollectionScanCapability.h" - -Capabilities::CollectionScanCapability::CollectionScanCapability() - : Capabilities::Capability() -{ } - -Capabilities::CollectionScanCapability::~CollectionScanCapability() -{ } - -#include "moc_CollectionScanCapability.cpp" diff --git a/amarok/src/core/capabilities/CollectionScanCapability.h b/amarok/src/core/capabilities/CollectionScanCapability.h deleted file mode 100644 index b894b90e..00000000 --- a/amarok/src/core/capabilities/CollectionScanCapability.h +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Ralf Engels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_COLLECTIONSSCANCAPABILITY_H -#define AMAROK_COLLECTIONSSCANCAPABILITY_H - -#include "core/amarokcore_export.h" -#include "core/capabilities/Capability.h" - -namespace Capabilities -{ - /** - * This capability allows to initiate a scan on a collection. - * Currently only a few collections have this capablitity and even then it's unclear - * Which collections uses the collection folders. - * - * @author Ralf Engels - */ - - class AMAROK_CORE_EXPORT CollectionScanCapability : public Capabilities::Capability - { - Q_OBJECT - public: - - /** - * Constructor - */ - CollectionScanCapability(); - - /** - * Destructor - */ - virtual ~CollectionScanCapability(); - - /** Begin a full scan on the collection. - */ - virtual void startFullScan() = 0; - - /** Begin an incremental scan on the collection. - @p directory An optional specification of which directory to scan. If empty the scanner will check all the collections directories set in the Amarok settings - */ - virtual void startIncrementalScan( const QString &directory = QString() ) = 0; - - /** Stop a scan on this collection. - */ - virtual void stopScan() = 0; - - /** - * Get the capabilityInterfaceType of this capability - * @return The capabilityInterfaceType ( always Capabilities::Capability::CollectionScan; ) - */ - static Type capabilityInterfaceType() { return Capabilities::Capability::CollectionScan; } - }; -} - -#endif diff --git a/amarok/src/core/capabilities/FindInSourceCapability.cpp b/amarok/src/core/capabilities/FindInSourceCapability.cpp deleted file mode 100644 index 135b303f..00000000 --- a/amarok/src/core/capabilities/FindInSourceCapability.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "core/capabilities/FindInSourceCapability.h" - -using namespace Capabilities; - -FindInSourceCapability::~FindInSourceCapability() -{ -} - -#include "moc_FindInSourceCapability.cpp" diff --git a/amarok/src/core/capabilities/FindInSourceCapability.h b/amarok/src/core/capabilities/FindInSourceCapability.h deleted file mode 100644 index 585e9bae..00000000 --- a/amarok/src/core/capabilities/FindInSourceCapability.h +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef FINDINSOURCECAPABILITY_H -#define FINDINSOURCECAPABILITY_H - -#include "core/amarokcore_export.h" -#include "core/capabilities/Capability.h" - -namespace Capabilities { - -/** -This capability exposes a method that shows this track (or the closest possible parent, such as album) in the source where it was added from. - - @author Nikolaj Hald Nielsen -*/ - -class AMAROK_CORE_EXPORT FindInSourceCapability : public Capabilities::Capability -{ - Q_OBJECT - Q_FLAGS( TargetTag TargetTags ) - -public: - enum TargetTag - { - Artist = 0x01, - Album = 0x02, - Composer = 0x04, - Genre = 0x08, - Track = 0x10, - Year = 0x20 - }; - - virtual ~FindInSourceCapability(); - - virtual void findInSource( QFlags tag = Album ) = 0; - - /** - * Get the capabilityInterfaceType of this capability - * @return The capabilityInterfaceType ( always Capabilities::Capability::FindInSource; ) - */ - static Type capabilityInterfaceType() { return Capabilities::Capability::FindInSource; } - - Q_DECLARE_FLAGS( TargetTags, TargetTag ) -}; - -} // namespace Capabilities - -Q_DECLARE_OPERATORS_FOR_FLAGS( Capabilities::FindInSourceCapability::TargetTags ) - -#endif // FINDINSOURCECAPABILITY_H diff --git a/amarok/src/core/capabilities/MultiPlayableCapability.cpp b/amarok/src/core/capabilities/MultiPlayableCapability.cpp deleted file mode 100644 index 97d75423..00000000 --- a/amarok/src/core/capabilities/MultiPlayableCapability.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Shane King * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "core/capabilities/MultiPlayableCapability.h" - -Capabilities::MultiPlayableCapability::~MultiPlayableCapability() -{ - //nothing to do -} - -#include "moc_MultiPlayableCapability.cpp" diff --git a/amarok/src/core/capabilities/MultiPlayableCapability.h b/amarok/src/core/capabilities/MultiPlayableCapability.h deleted file mode 100644 index af1fe91e..00000000 --- a/amarok/src/core/capabilities/MultiPlayableCapability.h +++ /dev/null @@ -1,44 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Shane King * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_MULTIPLAYABLECAPABILITY_H -#define AMAROK_MULTIPLAYABLECAPABILITY_H - -#include "core/capabilities/Capability.h" - -#include - -namespace Capabilities -{ - class AMAROK_CORE_EXPORT MultiPlayableCapability : public Capability - { - Q_OBJECT - - public: - virtual ~MultiPlayableCapability(); - - static Type capabilityInterfaceType() - { return Capabilities::Capability::MultiPlayable; } - - virtual void fetchFirst() = 0; - virtual void fetchNext() = 0; - - signals: - void playableUrlFetched( const KUrl &url ); - }; -} - -#endif // AMAROK_MULTIPLAYABLECAPABILITY_H diff --git a/amarok/src/core/capabilities/MultiSourceCapability.cpp b/amarok/src/core/capabilities/MultiSourceCapability.cpp deleted file mode 100644 index b818c222..00000000 --- a/amarok/src/core/capabilities/MultiSourceCapability.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "MultiSourceCapability.h" - -using namespace Capabilities; - -MultiSourceCapability::MultiSourceCapability() - : Capability() -{ -} - -MultiSourceCapability::~MultiSourceCapability() -{ -} diff --git a/amarok/src/core/capabilities/MultiSourceCapability.h b/amarok/src/core/capabilities/MultiSourceCapability.h deleted file mode 100644 index 7c737753..00000000 --- a/amarok/src/core/capabilities/MultiSourceCapability.h +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef METAMULTISOURCECAPABILITY_H -#define METAMULTISOURCECAPABILITY_H - -#include "core/capabilities/Capability.h" - -class KUrl; - -namespace Capabilities -{ - /** - * A capability for tracks that can have several different source urls, such as - * multiple fallback streams for a radio station. If one source url fails or finishes, - * the track will automatically use the next one. It is also possbile to get a list - * of all urls that can be presented to the user so tha she can choose. - * - * @author Nikolaj Hald Nielsen - */ - class AMAROK_CORE_EXPORT MultiSourceCapability : public Capability - { - Q_OBJECT - - public: - MultiSourceCapability(); - virtual ~MultiSourceCapability(); - - static Type capabilityInterfaceType() { return MultiSource; } - - /** - * Return list of displayable urls in this MultiSource. Only for display - * purposes, don't attempt to play these urls. - */ - virtual QStringList sources() const = 0; - - /** - * Set current source. Does nothing if @param current is out of bounds. - */ - virtual void setSource( int source ) = 0; - - /** - * Get index of the current source - */ - virtual int current() const = 0; - - /** - * Return the url of the next source without actually advancing to it. - * Returns empty url if the current source is the last one. - */ - virtual KUrl nextUrl() const = 0; - - signals: - void urlChanged( const KUrl &url ); - }; -} - -#endif diff --git a/amarok/src/core/capabilities/OrganiseCapability.cpp b/amarok/src/core/capabilities/OrganiseCapability.cpp deleted file mode 100644 index 8efd0f1d..00000000 --- a/amarok/src/core/capabilities/OrganiseCapability.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "core/capabilities/OrganiseCapability.h" - -Capabilities::OrganiseCapability::~OrganiseCapability() -{ - //nothing to do -} diff --git a/amarok/src/core/capabilities/OrganiseCapability.h b/amarok/src/core/capabilities/OrganiseCapability.h deleted file mode 100644 index 535f3c5f..00000000 --- a/amarok/src/core/capabilities/OrganiseCapability.h +++ /dev/null @@ -1,41 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_ORGANISECAPABILITY_H -#define AMAROK_ORGANISECAPABILITY_H - -#include "core/amarokcore_export.h" -#include "core/capabilities/Capability.h" - -namespace Capabilities -{ - class AMAROK_CORE_EXPORT OrganiseCapability : public Capabilities::Capability - { - Q_OBJECT - public: - virtual ~OrganiseCapability(); - - static Type capabilityInterfaceType() { return Capabilities::Capability::Organisable; } - - /** - * delete this track from the collection - */ - virtual void deleteTrack() = 0; - //virtual void organiseTrack() = 0; - }; -} - -#endif diff --git a/amarok/src/core/capabilities/ReadLabelCapability.cpp b/amarok/src/core/capabilities/ReadLabelCapability.cpp deleted file mode 100644 index 6e8eaf0c..00000000 --- a/amarok/src/core/capabilities/ReadLabelCapability.cpp +++ /dev/null @@ -1,18 +0,0 @@ -/**************************************************************************************** - * Copyright (C) 2009 Dan Meltzer * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "core/capabilities/ReadLabelCapability.h" - diff --git a/amarok/src/core/capabilities/ReadLabelCapability.h b/amarok/src/core/capabilities/ReadLabelCapability.h deleted file mode 100644 index be2295d9..00000000 --- a/amarok/src/core/capabilities/ReadLabelCapability.h +++ /dev/null @@ -1,46 +0,0 @@ -/**************************************************************************************** - * Copyright (C) 2009 Dan Meltzer * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef READLABELCAPABILITY_H -#define READLABELCAPABILITY_H - -#include "core/amarokcore_export.h" -#include "core/capabilities/Capability.h" -#include "core/meta/forward_declarations.h" - -#include - -namespace Capabilities -{ - -class AMAROK_CORE_EXPORT ReadLabelCapability : public Capabilities::Capability -{ - Q_OBJECT - public: - static Type capabilityInterfaceType() { return Capabilities::Capability::ReadLabel; } - - //Implementors - virtual void fetchLabels() = 0; - virtual void fetchGlobalLabels() = 0; - virtual QStringList labels() = 0; - - signals: - void labelsFetched( QStringList ); - -}; - -} -#endif // READLABELCAPABILITY_H diff --git a/amarok/src/core/capabilities/SourceInfoCapability.cpp b/amarok/src/core/capabilities/SourceInfoCapability.cpp deleted file mode 100644 index 4abfdb22..00000000 --- a/amarok/src/core/capabilities/SourceInfoCapability.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "core/capabilities/SourceInfoCapability.h" - -Capabilities::SourceInfoCapability::SourceInfoCapability() - : Capabilities::Capability() -{ -} - - -Capabilities::SourceInfoCapability::~SourceInfoCapability() -{ -} - - - diff --git a/amarok/src/core/capabilities/SourceInfoCapability.h b/amarok/src/core/capabilities/SourceInfoCapability.h deleted file mode 100644 index 52aae818..00000000 --- a/amarok/src/core/capabilities/SourceInfoCapability.h +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef SOURCEINFOCAPABILITY_H -#define SOURCEINFOCAPABILITY_H - -#include "core/amarokcore_export.h" -#include "core/capabilities/Capability.h" - -class QPixmap; - -namespace Capabilities -{ - - /** - This capability allows getting additional information about the source of a meta item. For now, it is intended for allowing the playlist to display a little emblem to let users know if a track is a Magnatune preview track, a lastfm stream or so on... - - @author Nikolaj Hald Nielsen - */ - class AMAROK_CORE_EXPORT SourceInfoCapability : public Capabilities::Capability{ - public: - Q_OBJECT - public: - /** - * Constructor - */ - SourceInfoCapability(); - /** - * Destructor - */ - virtual ~SourceInfoCapability(); - - /** - * Get the human readable name of the source, for instance "Magnatune.com" - * @return The name of the source - */ - virtual QString sourceName() = 0; - /** - * Get a brief human readable description or the source - * @return The source description - */ - virtual QString sourceDescription() = 0; - /** - * Get a small 16x16 pixle emblem that represents the source. - * @return The source emblem - */ - virtual QPixmap emblem() = 0; - - /** - * Get a path to a scalable (svg) version of the source emblem. - */ - virtual QString scalableEmblem() = 0; - - /** - * Get the capabilityInterfaceType of this capability - * @return The capabilityInterfaceType ( always Capabilities::Capability::SourceInfo; ) - */ - static Type capabilityInterfaceType() { return Capabilities::Capability::SourceInfo; } - - }; - -} - -#endif diff --git a/amarok/src/core/capabilities/StreamInfoCapability.cpp b/amarok/src/core/capabilities/StreamInfoCapability.cpp deleted file mode 100644 index cacfa516..00000000 --- a/amarok/src/core/capabilities/StreamInfoCapability.cpp +++ /dev/null @@ -1,19 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Dan Meltzer * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - - //Stupid cmake. -#include "core/capabilities/StreamInfoCapability.h" -#include "moc_StreamInfoCapability.cpp" diff --git a/amarok/src/core/capabilities/StreamInfoCapability.h b/amarok/src/core/capabilities/StreamInfoCapability.h deleted file mode 100644 index 7d6298b3..00000000 --- a/amarok/src/core/capabilities/StreamInfoCapability.h +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Dan Meltzer * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef STREAMINFOCAPABILITY_H -#define STREAMINFOCAPABILITY_H - -#include "core/amarokcore_export.h" -#include "core/capabilities/Capability.h" - -#include -namespace Capabilities -{ - - /** - * This capability is designed to provide additional information - * about streaming metadata. For meta types that provide multiple - * tracks within the same stream (lastfm, shoutcast, etc ) - * this capability is designed to return stream metadata, - * where the properties in the Meta::Track class refers to the track - * being played within the stream. - - @author Dan Meltzer - */ - class AMAROK_CORE_EXPORT StreamInfoCapability : public Capabilities::Capability - { - Q_OBJECT - public: - StreamInfoCapability() {}; - virtual ~StreamInfoCapability() {}; - - /** - * The human readable name of this stream - * @return A string representing the name of this stream. - */ - virtual QString streamName() const = 0; - /** - * The source this stream belongs to. - * @return The name of the owning source. - */ - virtual QString streamSource() const { return QString(); } - static Type capabilityInterfaceType() { return Capabilities::Capability::StreamInfo; } - - }; - -} - -#endif diff --git a/amarok/src/core/capabilities/TranscodeCapability.cpp b/amarok/src/core/capabilities/TranscodeCapability.cpp deleted file mode 100644 index ae6eca76..00000000 --- a/amarok/src/core/capabilities/TranscodeCapability.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "TranscodeCapability.h" - -using namespace Capabilities; - -TranscodeCapability::~TranscodeCapability() -{ - // nothing to do -} diff --git a/amarok/src/core/capabilities/TranscodeCapability.h b/amarok/src/core/capabilities/TranscodeCapability.h deleted file mode 100644 index ab276a63..00000000 --- a/amarok/src/core/capabilities/TranscodeCapability.h +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef TRANSCODECAPABILITY_H -#define TRANSCODECAPABILITY_H - -#include "core/amarokcore_export.h" -#include "core/capabilities/Capability.h" -#include "core/transcoding/TranscodingConfiguration.h" - -#include - -namespace Capabilities -{ - - /** - * Collections whose CollectionLocation supports transcoding (e.g. it doesn't ignore - * Transcoding::Configuration configuration parameter in copyUrlsToCollection()) - * can and should provide this capability so that core CollectionLocation methods can - * ask user whether she wants to just copy/move or transcode tracks when - * copying/moving/dragging them to destination collection. - * - * If your collection doesn't support transcoding (not implemented or just - * temporarily), you should not (temporarily) provide this capability. - * - * @author Matěj Laitl - */ - class AMAROK_CORE_EXPORT TranscodeCapability : public Capability - { - Q_OBJECT - - public: - virtual ~TranscodeCapability(); - - /** - * Return a list of file types (should be compatible with Meta::Track::type()) - * that your collection is able to play. This is used to disable transcoding - * to formats that wouldnt be playable; if your collection is a portable player - * that can only play ogg vorbis and flac, you would return - * QStringList() << "ogg" << "flac"; - * - * In order not to suck users, "plain copy" option is always available - * regardless of what this method returns. - * - * Return value of empty QStringList() is special and means that there should - * be no restriction on enabled transcoders. Default implementation returns - * this value. - */ - virtual QStringList playableFileTypes() { return QStringList(); } - - /** - * Return configuration previously saved using setSavedConfiguration() or invalid - * configuration if there is no configuration saved. - */ - virtual Transcoding::Configuration savedConfiguration() = 0; - - /** - * Set saved configuration to @param configuration. An invalid configuration - * should be interpreted as an action to unset saved configuration. - */ - virtual void setSavedConfiguration( const Transcoding::Configuration &configuration ) = 0; - - /** - * Type of this capability - */ - static Type capabilityInterfaceType() { return Capability::Transcode; } - }; - -} // napespace Capabilities - -#endif // TRANSCODECAPABILITY_H diff --git a/amarok/src/core/capabilities/WriteLabelCapability.cpp b/amarok/src/core/capabilities/WriteLabelCapability.cpp deleted file mode 100644 index 8676a674..00000000 --- a/amarok/src/core/capabilities/WriteLabelCapability.cpp +++ /dev/null @@ -1,17 +0,0 @@ -/**************************************************************************************** - * Copyright (C) 2009 Dan Meltzer * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "core/capabilities/WriteLabelCapability.h" diff --git a/amarok/src/core/capabilities/WriteLabelCapability.h b/amarok/src/core/capabilities/WriteLabelCapability.h deleted file mode 100644 index 2970752b..00000000 --- a/amarok/src/core/capabilities/WriteLabelCapability.h +++ /dev/null @@ -1,39 +0,0 @@ -/**************************************************************************************** - * Copyright (C) 2009 Dan Meltzer * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef WRITELABELCAPABILITY_H -#define WRITELABELCAPABILITY_H - -#include "core/amarokcore_export.h" -#include "core/capabilities/Capability.h" -#include "core/meta/forward_declarations.h" - -namespace Capabilities -{ - -class AMAROK_CORE_EXPORT WriteLabelCapability : public Capabilities::Capability -{ - Q_OBJECT - public: - static Type capabilityInterfaceType() { return Capabilities::Capability::WriteLabel; } - - //Implementors - virtual void setLabels( const QStringList &removedLabels, const QStringList &labels ) = 0; - -}; - -} -#endif // READLABELCAPABILITY_H diff --git a/amarok/src/core/collections/Collection.cpp b/amarok/src/core/collections/Collection.cpp deleted file mode 100644 index 8e963b0b..00000000 --- a/amarok/src/core/collections/Collection.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007-2008 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "core/collections/Collection.h" - -#include "core/collections/CollectionLocation.h" -#include "core/meta/Meta.h" - -Collections::CollectionFactory::CollectionFactory( QObject *parent, const QVariantList &args ) - : Plugins::PluginFactory( parent, args ) -{ -} - -Collections::CollectionFactory::~CollectionFactory() -{ -} - - -Collections::TrackProvider::TrackProvider() -{ -} - -Collections::TrackProvider::~TrackProvider() -{ -} - -bool -Collections::TrackProvider::possiblyContainsTrack( const KUrl &url ) const -{ - Q_UNUSED( url ) - return false; -} - -Meta::TrackPtr -Collections::TrackProvider::trackForUrl( const KUrl &url ) -{ - Q_UNUSED( url ) - return Meta::TrackPtr(); -} - -// Collection - -Collections::Collection::~Collection() -{ -} - -QString -Collections::Collection::uidUrlProtocol() const -{ - return QString(); -} - -Collections::CollectionLocation* -Collections::Collection::location() -{ - return new Collections::CollectionLocation( this ); -} - -bool -Collections::Collection::isWritable() const -{ - Collections::CollectionLocation* loc = const_cast(this)->location(); - if( !loc ) - return false; - bool writable = loc->isWritable(); - delete loc; - return writable; -} - -bool -Collections::Collection::isOrganizable() const -{ - Collections::CollectionLocation* loc = const_cast(this)->location(); - if( !loc ) - return false; - bool organizable = loc->isOrganizable(); - delete loc; - return organizable; -} - -#include "moc_Collection.cpp" diff --git a/amarok/src/core/collections/Collection.h b/amarok/src/core/collections/Collection.h deleted file mode 100644 index bfa6e32b..00000000 --- a/amarok/src/core/collections/Collection.h +++ /dev/null @@ -1,185 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007-2008 Maximilian Kossick * - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_COLLECTION_H -#define AMAROK_COLLECTION_H - -#include "core/amarokcore_export.h" -#include "core/interfaces/MetaCapability.h" -#include "core/support/PluginFactory.h" - -#include - -namespace Meta { - class Track; - typedef KSharedPtr TrackPtr; -} -namespace Playlists { - class UserPlaylistProvider; -} - -class KIcon; - -namespace Collections -{ - class Collection; - class CollectionLocation; - class QueryMaker; - typedef QList CollectionList; - - /** A plugin that creates new collections. - */ - class AMAROK_CORE_EXPORT CollectionFactory : public Plugins::PluginFactory - { - Q_OBJECT - - public: - CollectionFactory( QObject *parent, const QVariantList &args ); - virtual ~CollectionFactory(); - - signals: - void newCollection( Collections::Collection *newCollection ); - }; - - /** A TrackProvider is a class that can lookup urls and return Track objects. - * - * A track provider is implemented by every collection, but there - * are also a couple of other track providers. - * All TrackProvider are managed by the CollectionManager. - */ - class AMAROK_CORE_EXPORT TrackProvider - { - public: - TrackProvider(); - virtual ~TrackProvider(); - - /** - * Returns true if this track provider has a chance of providing the - * track specified by @p url. - * This should do a minimal amount of checking, and return quickly. - */ - virtual bool possiblyContainsTrack( const KUrl &url ) const; - - /** - * Creates a TrackPtr object for url @p url. Returns a null track Ptr if - * it cannot be done. - * If asynchronysity is desired it is suggested to return a MetaProxy track here - * and have the proxy watch for the real track. - */ - virtual Meta::TrackPtr trackForUrl( const KUrl &url ); - }; - - class AMAROK_CORE_EXPORT Collection : public QObject, public TrackProvider, public MetaCapability - { - Q_OBJECT - - public: - virtual ~Collection(); - - /** - * The collection's querymaker - * @return A querymaker that belongs to this collection. - */ - virtual QueryMaker *queryMaker() = 0; - - /** - * The protocol of uids coming from this collection. - * @return A string of the protocol, without the :// - */ - virtual QString uidUrlProtocol() const; - - /** - * @return A unique identifier for this collection - */ - virtual QString collectionId() const = 0; - - /** - * @return a user visible name for this collection, to be displayed in the collectionbrowser and elsewhere - */ - virtual QString prettyName() const = 0; - - /** - * @return an icon representing this collection - */ - virtual KIcon icon() const = 0; - - virtual bool hasCapacity() const { return false; } - virtual float usedCapacity() const { return 0.0; } - virtual float totalCapacity() const { return 0.0; } - - /** - * Create collection location that can be used to copy track to this - * collection or to delete collection tracks. If you don't call - * prepare{Move,Copy,Remove} on it, you must delete it after use. - */ - virtual Collections::CollectionLocation *location(); - - /** - * Return true if this collection can be written to (tracks added, removed). - * Convenience short-cut for calling CollectionLocation's isWritable. - */ - virtual bool isWritable() const; - - /** - * Return true if user can choose track file path within this collection. - * Convenience short-cut for calling CollectionLocation's isOrganizable. - */ - virtual bool isOrganizable() const; - - signals: - /** - * Once you register a collection with CollectionManager, this signal is the - * only way to safely destroy it. CollectionManger will remove this collection - * from the list of active ones and will destroy this collection after some - * time. - */ - void remove(); - - /** - * This signal must be emitted when the collection contents has changed - * significantly. - * - * More specifically, you must emit this signal (only) in such situations: - * a) the set of entities (tracks, albums, years, ...) in this collection has - * changed: a track was added, album is renamed, year was removed... - * b) the relationship between the entities has changed: the track changed - * album, album is no longer associated to an album artist and bacame a - * compilation, an alum changed its year... - * - * You should not emit this signal when some minor data of an entity change, - * for example when a track comment changes, etc. - * - * Also note there are ::notifyObservers() methods of various entities. - * ::notifyObservers() and Collection::updated() are perpendicular and - * responsibility to call one of these may and may not mean need to call the - * other. - * - * This signal spedifically this means that previous done searches can no - * longer be considered valid. - */ - void updated(); - }; -} - -Q_DECLARE_METATYPE( Collections::Collection* ) -Q_DECLARE_METATYPE( Collections::CollectionList ) - -#define AMAROK_EXPORT_COLLECTION( classname, libname ) \ - K_PLUGIN_FACTORY( factory, registerPlugin(); ) \ - K_EXPORT_PLUGIN( factory( "amarok_collection-" #libname ) ) - -#endif /* AMAROK_COLLECTION_H */ diff --git a/amarok/src/core/collections/CollectionLocation.cpp b/amarok/src/core/collections/CollectionLocation.cpp deleted file mode 100644 index 9399ed2c..00000000 --- a/amarok/src/core/collections/CollectionLocation.cpp +++ /dev/null @@ -1,743 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007-2008 Maximilian Kossick * - * Copyright (c) 2008 Jason A. Donenfeld * - * Copyright (c) 2010 Casey Link * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "CollectionLocation" - -#include "CollectionLocation.h" - -#include "core/capabilities/TranscodeCapability.h" -#include "core/collections/Collection.h" -#include "core/collections/CollectionLocationDelegate.h" -#include "core/collections/QueryMaker.h" -#include "core/meta/Meta.h" -#include "core/support/Components.h" -#include "core/support/Debug.h" -#include "core/transcoding/TranscodingConfiguration.h" -#include "core/transcoding/TranscodingController.h" - -#include -#include - -using namespace Collections; - -CollectionLocation::CollectionLocation() - :QObject() - , m_destination( 0 ) - , m_source( 0 ) - , m_sourceTracks() - , m_parentCollection( 0 ) - , m_removeSources( false ) - , m_isRemoveAction( false ) - , m_noRemoveConfirmation( false ) - , m_transcodingConfiguration( Transcoding::JUST_COPY ) -{ - //nothing to do -} - -CollectionLocation::CollectionLocation( Collections::Collection *parentCollection) - :QObject() - , m_destination( 0 ) - , m_source( 0 ) - , m_sourceTracks() - , m_parentCollection( parentCollection ) - , m_removeSources( false ) - , m_isRemoveAction( false ) - , m_noRemoveConfirmation( false ) - , m_transcodingConfiguration( Transcoding::JUST_COPY ) -{ - //nothing to do -} - -CollectionLocation::~CollectionLocation() -{ - //nothing to do -} - -Collections::Collection* -CollectionLocation::collection() const -{ - return m_parentCollection; -} - -QString -CollectionLocation::prettyLocation() const -{ - return QString(); -} - -QStringList -CollectionLocation::actualLocation() const -{ - return QStringList(); -} - -bool -CollectionLocation::isWritable() const -{ - return false; -} - -bool -CollectionLocation::isOrganizable() const -{ - return false; -} - -void -CollectionLocation::prepareCopy( Meta::TrackPtr track, CollectionLocation *destination ) -{ - Q_ASSERT(destination); - Meta::TrackList list; - list.append( track ); - prepareCopy( list, destination ); -} - -void -CollectionLocation::prepareCopy( const Meta::TrackList &tracks, CollectionLocation *destination ) -{ - if( !destination->isWritable() ) - { - CollectionLocationDelegate *delegate = Amarok::Components::collectionLocationDelegate(); - delegate->notWriteable( this ); - destination->deleteLater(); - deleteLater(); - return; - } - - m_destination = destination; - m_destination->setSource( this ); - startWorkflow( tracks, false ); -} - -void -CollectionLocation::prepareCopy( Collections::QueryMaker *qm, CollectionLocation *destination ) -{ - DEBUG_BLOCK - if( !destination->isWritable() ) - { - CollectionLocationDelegate *delegate = Amarok::Components::collectionLocationDelegate(); - delegate->notWriteable( this ); - destination->deleteLater(); - qm->deleteLater(); - deleteLater(); - return; - } - m_destination = destination; - m_removeSources = false; - m_isRemoveAction = false; - connect( qm, SIGNAL(newResultReady(Meta::TrackList)), SLOT(resultReady(Meta::TrackList)) ); - connect( qm, SIGNAL(queryDone()), SLOT(queryDone()) ); - qm->setQueryType( Collections::QueryMaker::Track ); - qm->run(); -} - -void -CollectionLocation::prepareMove( Meta::TrackPtr track, CollectionLocation *destination ) -{ - Meta::TrackList list; - list.append( track ); - prepareMove( list, destination ); -} - -void -CollectionLocation::prepareMove( const Meta::TrackList &tracks, CollectionLocation *destination ) -{ - DEBUG_BLOCK - if( !destination->isWritable() ) - { - CollectionLocationDelegate *delegate = Amarok::Components::collectionLocationDelegate(); - delegate->notWriteable( this ); - destination->deleteLater(); - deleteLater(); - return; - } - - m_destination = destination; - m_destination->setSource( this ); - startWorkflow( tracks, true ); -} - -void -CollectionLocation::prepareMove( Collections::QueryMaker *qm, CollectionLocation *destination ) -{ - DEBUG_BLOCK - if( !destination->isWritable() ) - { - Collections::CollectionLocationDelegate *delegate = Amarok::Components::collectionLocationDelegate(); - delegate->notWriteable( this ); - destination->deleteLater(); - qm->deleteLater(); - deleteLater(); - return; - } - m_destination = destination; - m_isRemoveAction = false; - m_removeSources = true; - connect( qm, SIGNAL(newResultReady(Meta::TrackList)), SLOT(resultReady(Meta::TrackList)) ); - connect( qm, SIGNAL(queryDone()), SLOT(queryDone()) ); - qm->setQueryType( Collections::QueryMaker::Track ); - qm->run(); -} - -void -CollectionLocation::prepareRemove( const Meta::TrackList &tracks ) -{ - DEBUG_BLOCK - if( !isWritable() ) - { - Collections::CollectionLocationDelegate *delegate = Amarok::Components::collectionLocationDelegate(); - delegate->notWriteable( this ); - deleteLater(); - return; - } - startRemoveWorkflow( tracks ); -} - -void -CollectionLocation::prepareRemove( Collections::QueryMaker *qm ) -{ - DEBUG_BLOCK - if( !isWritable() ) - { - Collections::CollectionLocationDelegate *delegate = Amarok::Components::collectionLocationDelegate(); - delegate->notWriteable( this ); - qm->deleteLater(); - deleteLater(); - return; - } - - m_isRemoveAction = true; - m_removeSources = false; - - connect( qm, SIGNAL(newResultReady(Meta::TrackList)), SLOT(resultReady(Meta::TrackList)) ); - connect( qm, SIGNAL(queryDone()), SLOT(queryDone()) ); - qm->setQueryType( Collections::QueryMaker::Track ); - qm->run(); -} - -bool -CollectionLocation::insert( const Meta::TrackPtr &track, const QString &url ) -{ - Q_UNUSED( track ) - Q_UNUSED( url ) - warning() << __PRETTY_FUNCTION__ << "Don't call this method. It exists only because" - << "database importers need it. Call prepareCopy() instead."; - return false; -} - -void -CollectionLocation::abort() -{ - emit aborted(); -} - -void -CollectionLocation::getKIOCopyableUrls( const Meta::TrackList &tracks ) -{ - DEBUG_BLOCK - QMap urls; - foreach( Meta::TrackPtr track, tracks ) - { - if( track->isPlayable() ) - { - urls.insert( track, track->playableUrl() ); - debug() << "adding url " << track->playableUrl(); - } - } - - slotGetKIOCopyableUrlsDone( urls ); -} - -void -CollectionLocation::copyUrlsToCollection( const QMap &sources, - const Transcoding::Configuration &configuration ) -{ - DEBUG_BLOCK - //reimplement in implementations which are writable - Q_UNUSED( sources ) - Q_UNUSED( configuration ) - slotCopyOperationFinished(); -} - -void -CollectionLocation::removeUrlsFromCollection( const Meta::TrackList &sources ) -{ - DEBUG_BLOCK - //reimplement in implementations which are writable - Q_UNUSED( sources ) - slotRemoveOperationFinished(); -} - -void -CollectionLocation::showSourceDialog( const Meta::TrackList &tracks, bool removeSources ) -{ - Q_UNUSED( tracks ) - Q_UNUSED( removeSources ) - - m_transcodingConfiguration = getDestinationTranscodingConfig(); - if( m_transcodingConfiguration.isValid() ) - slotShowSourceDialogDone(); - else - abort(); -} - -Transcoding::Configuration -CollectionLocation::getDestinationTranscodingConfig() -{ - Transcoding::Configuration configuration( Transcoding::JUST_COPY ); - Collection *destCollection = destination() ? destination()->collection() : 0; - if( !destCollection ) - return configuration; - if( !destCollection->has() ) - return configuration; - QScopedPointer tc( - destCollection->create() ); - if( !tc ) - return configuration; - - Transcoding::Controller* tcC = Amarok::Components::transcodingController(); - QSet availableEncoders; - if( tcC ) - availableEncoders = tcC->availableEncoders(); - - Transcoding::Configuration saved = tc->savedConfiguration(); - if( saved.isValid() && ( saved.isJustCopy() || availableEncoders.contains( saved.encoder() ) ) ) - return saved; - // saved configuration was not available or was invalid, ask user - - CollectionLocationDelegate *delegate = Amarok::Components::collectionLocationDelegate(); - bool saveConfiguration = false; - CollectionLocationDelegate::OperationType operation = CollectionLocationDelegate::Copy; - if( isGoingToRemoveSources() ) - operation = CollectionLocationDelegate::Move; - if( collection() && collection() == destination()->collection() ) - operation = CollectionLocationDelegate::Move; // organizing - configuration = delegate->transcode( tc->playableFileTypes(), &saveConfiguration, - operation, destCollection->prettyName(), - saved ); - if( configuration.isValid() ) - { - if( saveConfiguration ) - tc->setSavedConfiguration( configuration ); - else //save the trackSelection value for restore anyway - tc->setSavedConfiguration( Transcoding::Configuration( Transcoding::INVALID, - configuration.trackSelection() ) ); - } - return configuration; // may be invalid, it means user has hit cancel -} - -void -CollectionLocation::showDestinationDialog( const Meta::TrackList &tracks, - bool removeSources, - const Transcoding::Configuration &configuration ) -{ - Q_UNUSED( tracks ) - Q_UNUSED( configuration ) - setGoingToRemoveSources( removeSources ); - slotShowDestinationDialogDone(); -} - -void -CollectionLocation::showRemoveDialog( const Meta::TrackList &tracks ) -{ - DEBUG_BLOCK - - if( !isHidingRemoveConfirm() ) - { - Collections::CollectionLocationDelegate *delegate = Amarok::Components::collectionLocationDelegate(); - - const bool del = delegate->reallyDelete( this, tracks ); - - if( !del ) - slotFinishRemove(); - else - slotShowRemoveDialogDone(); - } else - slotShowRemoveDialogDone(); -} - -QString -CollectionLocation::operationText( const Transcoding::Configuration &configuration ) -{ - if( source()->collection() == collection() ) - { - if( configuration.isJustCopy() ) - return i18n( "Organize tracks" ); - else - return i18n( "Transcode and organize tracks" ); - } - if( isGoingToRemoveSources() ) - { - if( configuration.isJustCopy() ) - return i18n( "Move tracks" ); - else - return i18n( "Transcode and move tracks" ); - } - else - { - if( configuration.isJustCopy() ) - return i18n( "Copy tracks" ); - else - return i18n( "Transcode and copy tracks" ); - } -} - -QString -CollectionLocation::operationInProgressText( const Transcoding::Configuration &configuration, - int trackCount, QString destinationName ) -{ - if( destinationName.isEmpty() ) - destinationName = prettyLocation(); - if( source()->collection() == collection() ) - { - if( configuration.isJustCopy() ) - return i18np( "Organizing one track", - "Organizing %1 tracks", trackCount ); - else - return i18np( "Transcoding and organizing one track", - "Transcoding and organizing %1 tracks", trackCount ); - } - if( isGoingToRemoveSources() ) - { - if( configuration.isJustCopy() ) - return i18np( "Moving one track to %2", - "Moving %1 tracks to %2", trackCount, destinationName ); - else - return i18np( "Transcoding and moving one track to %2", - "Transcoding and moving %1 tracks to %2", trackCount, destinationName ); - } - else - { - if( configuration.isJustCopy() ) - return i18np( "Copying one track to %2", - "Copying %1 tracks to %2", trackCount, destinationName ); - else - return i18np( "Transcoding and copying one track to %2", - "Transcoding and copying %1 tracks to %2", trackCount, destinationName ); - } -} - -void -CollectionLocation::slotGetKIOCopyableUrlsDone( const QMap &sources ) -{ - emit startCopy( sources, m_transcodingConfiguration ); -} - -void -CollectionLocation::slotCopyOperationFinished() -{ - emit finishCopy(); -} - -void -CollectionLocation::slotRemoveOperationFinished() -{ - emit finishRemove(); -} - -void -CollectionLocation::slotShowSourceDialogDone() -{ - emit prepareOperation( m_sourceTracks, m_removeSources, m_transcodingConfiguration ); -} - -void -CollectionLocation::slotShowDestinationDialogDone() -{ - emit operationPrepared(); -} - -void -CollectionLocation::slotShowRemoveDialogDone() -{ - emit startRemove(); -} - -void -CollectionLocation::slotShowSourceDialog() -{ - showSourceDialog( m_sourceTracks, m_removeSources ); -} - -void -CollectionLocation::slotPrepareOperation( const Meta::TrackList &tracks, bool removeSources, - const Transcoding::Configuration &configuration ) -{ - m_removeSources = removeSources; - showDestinationDialog( tracks, removeSources, configuration ); -} - -void -CollectionLocation::slotOperationPrepared() -{ - getKIOCopyableUrls( m_sourceTracks ); -} - -void -CollectionLocation::slotStartCopy( const QMap &sources, - const Transcoding::Configuration &configuration ) -{ - DEBUG_BLOCK - copyUrlsToCollection( sources, configuration ); -} - -void -CollectionLocation::slotFinishCopy() -{ - DEBUG_BLOCK - if( m_removeSources ) - { - removeSourceTracks( m_tracksSuccessfullyTransferred ); - m_sourceTracks.clear(); - m_tracksSuccessfullyTransferred.clear(); - } - else - { - m_sourceTracks.clear(); - m_tracksSuccessfullyTransferred.clear(); - - if( m_destination ) - m_destination->deleteLater(); - m_destination = 0; - this->deleteLater(); - } -} - -void -CollectionLocation::slotStartRemove() -{ - DEBUG_BLOCK - removeUrlsFromCollection( m_sourceTracks ); -} - -void -CollectionLocation::slotFinishRemove() -{ - DEBUG_BLOCK - - Collections::CollectionLocationDelegate *delegate = Amarok::Components::collectionLocationDelegate(); - if( m_tracksWithError.size() > 0 ) - { - delegate->errorDeleting( this, m_tracksWithError.keys() ); - m_tracksWithError.clear(); - } - - QStringList dirsToRemove; - debug() << "remove finished updating"; - foreach( Meta::TrackPtr track, m_tracksSuccessfullyTransferred ) - { - if(!track) - continue; - - if( track->playableUrl().isLocalFile() ) - dirsToRemove.append( track->playableUrl().directory( KUrl::AppendTrailingSlash ) ); - } - - if( !dirsToRemove.isEmpty() && delegate->deleteEmptyDirs( this ) ) - { - debug() << "Removing empty directories"; - dirsToRemove.removeDuplicates(); - dirsToRemove.sort(); - while( !dirsToRemove.isEmpty() ) - { - QDir dir( dirsToRemove.takeLast() ); - if( !dir.exists() ) - continue; - - dir.setFilter( QDir::NoDotAndDotDot ); - while( !dir.isRoot() && dir.count() == 0 ) - { - const QString name = dir.dirName(); - dir.cdUp(); - if( !dir.rmdir( name ) ) - { - debug() << "Unable to remove " << name; - break; - } - } - } - } - - m_tracksSuccessfullyTransferred.clear(); - m_sourceTracks.clear(); - this->deleteLater(); -} - -void -CollectionLocation::slotAborted() -{ - m_destination->deleteLater(); - deleteLater(); -} - -void -CollectionLocation::resultReady( const Meta::TrackList &tracks ) -{ - m_sourceTracks << tracks; -} - -void -CollectionLocation::queryDone() -{ - DEBUG_BLOCK - QObject *obj = sender(); - if( obj ) - { - obj->deleteLater(); - } - if( m_isRemoveAction ) - { - debug() << "we were about to remove something, lets proceed"; - prepareRemove( m_sourceTracks ); - } - else if( m_removeSources ) - { - debug() << "we were about to move something, lets proceed"; - prepareMove( m_sourceTracks, m_destination ); - } - else - { - debug() << "we were about to copy something, lets proceed"; - prepareCopy( m_sourceTracks, m_destination ); - } -} - -void -CollectionLocation::setupConnections() -{ - connect( this, SIGNAL(prepareOperation(Meta::TrackList,bool,Transcoding::Configuration)), - m_destination, SLOT(slotPrepareOperation(Meta::TrackList,bool,Transcoding::Configuration)) ); - connect( m_destination, SIGNAL(operationPrepared()), SLOT(slotOperationPrepared()) ); - connect( this, SIGNAL(startCopy(QMap,Transcoding::Configuration)), - m_destination, SLOT(slotStartCopy(QMap,Transcoding::Configuration)) ); - connect( m_destination, SIGNAL(finishCopy()), - this, SLOT(slotFinishCopy()) ); - connect( this, SIGNAL(aborted()), SLOT(slotAborted()) ); - connect( m_destination, SIGNAL(aborted()), SLOT(slotAborted()) ); -} - -void -CollectionLocation::setupRemoveConnections() -{ - connect( this, SIGNAL(aborted()), SLOT(slotAborted()) ); - connect( this, SIGNAL(startRemove()), - this, SLOT(slotStartRemove()) ); - connect( this, SIGNAL(finishRemove()), - this, SLOT(slotFinishRemove()) ); -} - -void -CollectionLocation::startWorkflow( const Meta::TrackList &tracks, bool removeSources ) -{ - DEBUG_BLOCK - m_removeSources = removeSources; - m_sourceTracks = tracks; - setupConnections(); - if( tracks.size() <= 0 ) - abort(); - else - // show dialog in next mainloop iteration so that prepare[Something]() returns quickly - QTimer::singleShot( 0, this, SLOT(slotShowSourceDialog()) ); -} - -void -CollectionLocation::startRemoveWorkflow( const Meta::TrackList &tracks ) -{ - DEBUG_BLOCK - m_sourceTracks = tracks; - setupRemoveConnections(); - if( tracks.isEmpty() ) - abort(); - else - showRemoveDialog( tracks ); -} - -void -CollectionLocation::removeSourceTracks( const Meta::TrackList &tracks ) -{ - DEBUG_BLOCK - debug() << "Transfer errors:" << m_tracksWithError.count() << "of" << tracks.count(); - - foreach( Meta::TrackPtr track, m_tracksWithError.keys() ) - { - debug() << "transfer error for track" << track->playableUrl(); - } - - QSet toRemove = QSet::fromList( tracks ); - QSet errored = QSet::fromList( m_tracksWithError.keys() ); - toRemove.subtract( errored ); - - // start the remove workflow - setHidingRemoveConfirm( true ); - prepareRemove( toRemove.toList() ); -} - -CollectionLocation* -CollectionLocation::source() const -{ - return m_source; -} - -CollectionLocation* -CollectionLocation::destination() const -{ - return m_destination; -} - -void -CollectionLocation::setSource( CollectionLocation *source ) -{ - m_source = source; -} - -void -CollectionLocation::transferSuccessful( const Meta::TrackPtr &track ) -{ - m_tracksSuccessfullyTransferred.append( track ); -} - -bool -CollectionLocation::isGoingToRemoveSources() const -{ - return m_removeSources; -} -void -CollectionLocation::setGoingToRemoveSources( bool removeSources ) -{ - m_removeSources = removeSources; -} - -bool -CollectionLocation::isHidingRemoveConfirm() const -{ - return m_noRemoveConfirmation; -} - -void -CollectionLocation::setHidingRemoveConfirm( bool hideRemoveConfirm ) -{ - m_noRemoveConfirmation = hideRemoveConfirm; -} - -void -CollectionLocation::transferError( const Meta::TrackPtr &track, const QString &error ) -{ - m_tracksWithError.insert( track, error ); -} - -#include "moc_CollectionLocation.cpp" diff --git a/amarok/src/core/collections/CollectionLocation.h b/amarok/src/core/collections/CollectionLocation.h deleted file mode 100644 index 7a1ed1e9..00000000 --- a/amarok/src/core/collections/CollectionLocation.h +++ /dev/null @@ -1,425 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007-2008 Maximilian Kossick * - * Copyright (c) 2008 Jason A. Donenfeld * - * Copyright (c) 2010 Casey Link * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_COLLECTIONLOCATION_H -#define AMAROK_COLLECTIONLOCATION_H - -#include "core/amarokcore_export.h" -#include "core/meta/forward_declarations.h" -#include "core/transcoding/TranscodingConfiguration.h" - -#include -#include - -#include - -namespace Collections { - class Collection; - class QueryMaker; - -/** - This base class defines the methods necessary to allow the copying and moving - of tracks between different collections in a generic way. - - This class should be used as follows in client code: - - select a source and a destination CollectionLocation - - call prepareCopy or prepareMove on the source CollectionLocation - - forget about the rest of the workflow - - Implementations which are writable must reimplement the following methods - - prettyLocation() - - isWritable() - - remove( Meta::Track ) - - copyUrlsToCollection( QMap ) - - Writable collections that are also organizable should reimplement isOrganizable(). - Organizable means that the user is able to decide (to varying degrees, the details - depend on the actual collection) where the files are stored in the filesystem (or some - kind of VFS). An example would be the local collection, where the user can select the directory - structure that Amarok uses to store the files. An example for a writable collection that is not - organizable are ipods, where the user has no control about the actual location of the music files - (they are automatically stored in a not human-readable form). - - Implementations which are only readable can reimplement getKIOCopyableUrls( Meta::TrackList ) - if it is necessary, but can use the default implementations if possible. - - Implementations that have a string expressable location(s), such as a URL or path on disk - should reimplement actualLocation(). - - Implementations that need additional information provided by the user have to implement - showSourceDialog() and showDestinationDialog(), depending on whether the information is required - in the source, the destination, or both. - - The methods will be called in the following order: - startWorkflow (source) - showSourceDialog (source) (reimplementable) - slotShowSourceDialogDone (source) - slotPrepareOperation (destination) - showDestinationDialog (destination) (reimplementable) - slotShowDestinationDialogDone (destination) - slotOperationPrepared (source) - getKIOCopyableUrls (source) (reimplementable) - slotGetKIOCopyableUrlsDone (source) - slotStartCopy (destination) - copyUrlsToCollection (destination) (reimplementable) - slotCopyOperationFinished (destination) - slotFinishCopy (source) - - To provide removal ability, it is required to reimplement removeUrlsFromCollection, - and this function must call slotRemoveOperationFinished() when it is done. Optionally, - showRemoveDialog can be reimplemented to customize the warning displayed before a removal, - and this function must call slotShowRemoveDialogDone when finished. - - The methods for remove will be called in the following order: - startRemoveWorkflow - showRemoveDialog (reimplementable) - slotShowRemoveDialogDone - slotStartRemove - removeUrlsFromCollection (reimplementable) - slotRemoveOperationFinished - slotFinishRemove -*/ - -class AMAROK_CORE_EXPORT CollectionLocation : public QObject -{ - Q_OBJECT - - //testing only do not use these properties in anything but tests - Q_PROPERTY( bool removeSources - READ getRemoveSources - WRITE setRemoveSources - DESIGNABLE false - SCRIPTABLE false ) - - public: - CollectionLocation(); - CollectionLocation( Collections::Collection *parentCollection ); - virtual ~CollectionLocation(); - - /** - Returns a pointer to the collection location's corresponding collection. - @return a pointer to the collection location's corresponding collection - */ - virtual Collections::Collection *collection() const; - - /** - a displayable string representation of the collection location. use the return - value of this method to display the collection location to the user. - @return a string representation of the collection location - */ - virtual QString prettyLocation() const; - - /** - Returns a list of machine usable strings representingthe collection location. - For example, a local collection would return a list of paths where tracks are - stored, while an Ampache collection would return a list with one string - containing the URL of an ampache server. An iPod collection and a MTP device - collection are examples of collections that do not need to reimplement this method. - */ - virtual QStringList actualLocation() const; - - /** - Returns whether the collection location is writable or not. For example, a - local collection or an ipod collection would return true, a daap collection - or a service collection false. The value returned by this method indicates - if it is possible to copy tracks to the collection, and if it is generally - possible to remove/delete files from the collection. - @return @c true if the collection location is writable - @return @c false if the collection location is not writable - */ - virtual bool isWritable() const; - - /** - Returns whether the collection is organizable or not. Organizable collections - allow move operations where the source and destination collection are the same. - @return @c true if the collection location is organizable, false otherwise - */ - virtual bool isOrganizable() const; - - /** - Convenience method for copying a single track. - @see prepareCopy( Meta::TrackList, CollectionLocation* ) - */ - void prepareCopy( Meta::TrackPtr track, CollectionLocation *destination ); - /** - Schedule copying of @param tracks to collection location @param destination. - This method takes ownership of the @param destination, you may not reference - or delete it after this call. This method returns immediately and the actual - copy is performed in the event loop and/or another thread. - */ - void prepareCopy( const Meta::TrackList &tracks, CollectionLocation *destination ); - /** - Convenience method for copying tracks based on QueryMaker restults, - takes ownership of the @param qm. - @see prepareCopy( Meta::TrackList, CollectionLocation* ) - */ - void prepareCopy( Collections::QueryMaker *qm, CollectionLocation *destination ); - - /** - * Convenience method for moving a single track. - * @see prepareMove( Meta::TrackList, CollectionLocation* ) - */ - void prepareMove( Meta::TrackPtr track, CollectionLocation *destination ); - /** - Schedule moving of @param tracks to collection location @param destination. - This method takes ownership of the @param destination, you may not reference - or delete it after this call. This method returns immediately and the actual - move is performed in the event loop and/or another thread. - */ - void prepareMove( const Meta::TrackList &tracks, CollectionLocation *destination ); - /** - Convenience method for moving tracks based on QueryMaker restults, - takes ownership of the @param qm. - @see prepareMove( Meta::TrackList, CollectionLocation* ) - */ - void prepareMove( Collections::QueryMaker *qm, CollectionLocation *destination ); - - /** - Starts workflow for removing tracks. - */ - void prepareRemove( const Meta::TrackList &tracks ); - /** - Convenience method for removing tracks selected by QueryMaker, - takes ownership of the @param qm. - @see prepareRemove( Meta::TrackList ) - */ - void prepareRemove( Collections::QueryMaker *qm ); - - /** - * Adds or merges a track to the collection (not to the disk) - * Inserts a set of TrackPtrs directly into the database without needing to actual move any files - * This is a hack required by the DatabaseImporter - * TODO: Remove this hack - * @return true if the database entry was inserted, false otherwise - */ - virtual bool insert( const Meta::TrackPtr &track, const QString &url ); - - /** - explicitly inform the source collection of successful transfer. - The source collection will only remove files (if necessary) - for which this method was called. - */ - void transferSuccessful( const Meta::TrackPtr &track ); - - /** - * tells the source location that an error occurred during the transfer of the file - */ - virtual void transferError( const Meta::TrackPtr &track, const QString &error ); - - signals: - void startCopy( const QMap &sources, - const Transcoding::Configuration & ); - void finishCopy(); - void startRemove(); - void finishRemove(); - void prepareOperation( const Meta::TrackList &tracks, bool removeSources, - const Transcoding::Configuration & ); - void operationPrepared(); - void aborted(); - - protected: - /** - * aborts the workflow - */ - void abort(); - - /** - * allows the destination location to access the source CollectionLocation. - * note: subclasses do not take ownership of the pointer - */ - CollectionLocation* source() const; - - /** - * allows the source location to access the destination CollectionLocation. - * Pointer may be null! - * note: subclasses do not take ownership of the pointer - */ - CollectionLocation* destination() const; - - /** - this method is called on the source location, and should return a list of urls - which the destination location can copy using KIO. You must call - slotGetKIOCopyableUrlsDone( QMap ) after retrieving the - urls. The order of urls passed to that method has to be the same as the order - of the tracks passed to this method. - */ - virtual void getKIOCopyableUrls( const Meta::TrackList &tracks ); - /** - this method is called on the destination. reimplement it if your implementation - is writable. You must call slotCopyOperationFinished() when you are done copying - the files. - - Before calling slotCopyOperationFinished(), you should call - source()->transferSuccessful() for every source track that was for sure - successfully copied to destination collection. Only such marked tracks are - then removed in case of a "move" action. - */ - virtual void copyUrlsToCollection( const QMap &sources, - const Transcoding::Configuration &configuration ); - - /** - this method is called on the collection you want to remove tracks from. it must - be reimplemented if your collection is writable and you wish to implement - removing tracks. You must call slotRemoveOperationFinished() when you are done - removing the files. - - Before calling slotRemoveOperationFinished(), you should call transferSuccessful() - for every track that was successfully deleted. CollectionLocation then scans - directories of such tracks and allows user to remove empty ones. - */ - virtual void removeUrlsFromCollection( const Meta::TrackList &sources ); - - /** - * this method is called on the source. It allows the source CollectionLocation to - * show a dialog. Classes that reimplement this method must call - * slotShowSourceDialogDone() after they have acquired all necessary information from the user. - * - * Default implementation calls getDestinationTranscodingConfig() which may ask - * user. If you reimplement this you may (or not) call this base method instead - * of calling slotShowDestinationDialogDone() to support transcoding. - */ - virtual void showSourceDialog( const Meta::TrackList &tracks, bool removeSources ); - - /** - * Get transcoding configuration to use when transferring tracks to destination. - * If destination collection doesn't support transcoding, JUST_COPY configuration - * is returned, otherwise preferred configuration is read or user is asked. - * Returns invalid configuration in case user has hit cancel or closed the dialog. - * - * This method is meant to be called by source collection. - */ - virtual Transcoding::Configuration getDestinationTranscodingConfig(); - - /** - * This method is called on the destination. It allows the destination - * CollectionLocation to show a dialog. Classes that reimplement this method - * must call slotShowDestinationDialogDone() after they have acquired all necessary - * information from the user. - * - * Default implementation calls setGoingToRemoveSources( removeSources ) so that - * isGoingToRemoveSources() is available on destination, too and then calls - * slotShowDestinationDialogDone() - */ - virtual void showDestinationDialog( const Meta::TrackList &tracks, - bool removeSources, - const Transcoding::Configuration &configuration ); - - /** - * this methods allows the collection to show a warning dialog before tracks are removed, - * rather than using the default provided. Classes that reimplement this method must call - * slotShowRemoveDialogDone() after they are finished. - */ - - virtual void showRemoveDialog( const Meta::TrackList &tracks ); - - /** - * Get nice localised string describing the current operation based on transcoding - * configuraiton and isGoingToRemoveSources(); meant to be called by destination - * collection. - * - * @return "Copy Tracks", "Transcode and Organize Tracks" etc. - */ - QString operationText( const Transcoding::Configuration &configuration ); - - /** - * Get nice localised string that can be used as progress bar text for the current - * operation; meant to be called by the destination collection. - * - * @param trackCount number of tracks in the transfer - * @param destinationName pretty localised name of the destination collection; - * prettyLocation() is used if the string is empty or not specified - * - * @return "Transcoding and moving tracks to " etc. - */ - QString operationInProgressText( const Transcoding::Configuration &configuration, - int trackCount, QString destinationName = QString() ); - - /** - * Sets or gets whether some source files may be removed - */ - virtual bool isGoingToRemoveSources() const; - virtual void setGoingToRemoveSources( bool removeSources ); - - /** - * Sets or gets whether to stifle the removal confirmation - */ - virtual bool isHidingRemoveConfirm() const; - virtual void setHidingRemoveConfirm( bool hideRemoveConfirm ); - - protected slots: - /** - * this slot has to be called from getKIOCopyableUrls( Meta::TrackList ) - * Please note: the order of urls in the argument has to be the same as in the - * tracklist - */ - void slotGetKIOCopyableUrlsDone( const QMap &sources ); - void slotCopyOperationFinished(); - void slotRemoveOperationFinished(); - void slotShowSourceDialogDone(); - void slotShowRemoveDialogDone(); - void slotShowDestinationDialogDone(); - - private slots: - void slotShowSourceDialog(); // trick to show dialog in next mainloop iteration - void slotPrepareOperation( const Meta::TrackList &tracks, bool removeSources, - const Transcoding::Configuration &configuration ); - void slotOperationPrepared(); - void slotStartCopy( const QMap &sources, - const Transcoding::Configuration &configuration ); - void slotFinishCopy(); - void slotStartRemove(); - void slotFinishRemove(); - void slotAborted(); - void resultReady( const Meta::TrackList &tracks ); - void queryDone(); - - private: - void setupConnections(); - void setupRemoveConnections(); - void startWorkflow( const Meta::TrackList &tracks, bool removeSources ); - void startRemoveWorkflow( const Meta::TrackList &tracks ); - void startRemove( const Meta::TrackList &tracks ); - void removeSourceTracks( const Meta::TrackList &tracks ); - void setSource( CollectionLocation *source ); - - //only used in the source CollectionLocation - CollectionLocation *m_destination; - //only used in destination CollectionLocation - CollectionLocation *m_source; - - Meta::TrackList getSourceTracks() const { return m_sourceTracks; } - void setSourceTracks( Meta::TrackList tracks ) { m_sourceTracks = tracks; } - Meta::TrackList m_sourceTracks; - - Collections::Collection *m_parentCollection; - - bool getRemoveSources() const { return m_removeSources; } - void setRemoveSources( bool removeSources ) { m_removeSources = removeSources; } - bool m_removeSources; - bool m_isRemoveAction; - bool m_noRemoveConfirmation; - Transcoding::Configuration m_transcodingConfiguration; - //used by the source collection to store the tracks that were successfully - //copied by the destination and can be removed as part of a move - Meta::TrackList m_tracksSuccessfullyTransferred; - QMap m_tracksWithError; -}; - -} //namespace Collections - -#endif diff --git a/amarok/src/core/collections/CollectionLocationDelegate.h b/amarok/src/core/collections/CollectionLocationDelegate.h deleted file mode 100644 index 3c80d077..00000000 --- a/amarok/src/core/collections/CollectionLocationDelegate.h +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Maximilian Kossick * - * Copyright (c) 2010 Casey Link * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef COLLECTIONLOCATIONDELEGATE_H -#define COLLECTIONLOCATIONDELEGATE_H - -#include "core/amarokcore_export.h" -#include "core/meta/forward_declarations.h" -#include "core/transcoding/TranscodingConfiguration.h" - -namespace Collections { - -class CollectionLocation; - -class AMAROK_CORE_EXPORT CollectionLocationDelegate -{ -public: - enum OperationType { - Copy, - Move - }; - - CollectionLocationDelegate() {}; - virtual ~ CollectionLocationDelegate() {}; - - virtual bool reallyDelete( CollectionLocation *loc, const Meta::TrackList &tracks ) const = 0; - virtual bool reallyMove( CollectionLocation *loc, const Meta::TrackList &tracks ) const = 0; - virtual bool reallyTrash( CollectionLocation *loc, const Meta::TrackList &tracks ) const = 0; - virtual void errorDeleting( CollectionLocation *loc, const Meta::TrackList &tracks ) const = 0; - virtual void notWriteable( CollectionLocation *loc ) const = 0; - virtual bool deleteEmptyDirs( CollectionLocation *loc ) const = 0; - - /** - * Displays a dialog requesting what transcoding configuration to use. - * - * @param playableFileTypes list of filetypes that are playable (empty if everyhing playable) - * @param remember is set to true if user checks this transcoding config should be - * remembered per target collection. If null, such option is disabled in the UI. - * @param operation whether this is copying or moving - * @param destCollectionName name of the destination collection - * @param savedConfiguration the previously saved configuration, for restoring values from - * - * @return Transcoding configuration user requested or invalid configuration if user - * has hit Cancel or closed the dialog. - */ - virtual Transcoding::Configuration transcode( const QStringList &playableFileTypes, - bool *remember, OperationType operation, - const QString &destCollectionName, - const Transcoding::Configuration &prevConfiguration ) const = 0; -}; - -} //namespace Collections - -#endif diff --git a/amarok/src/core/collections/MetaQueryMaker.cpp b/amarok/src/core/collections/MetaQueryMaker.cpp deleted file mode 100644 index ce720b88..00000000 --- a/amarok/src/core/collections/MetaQueryMaker.cpp +++ /dev/null @@ -1,275 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "core/collections/MetaQueryMaker.h" - -using namespace Collections; - -MetaQueryMaker::MetaQueryMaker( const QList &collections ) - : QueryMaker() - , m_queryDoneCount( 0 ) - , m_queryDoneCountMutex() -{ - foreach( Collections::Collection *c, collections ) - { - QueryMaker *b = c->queryMaker(); - builders.append( b ); - connect( b, SIGNAL(queryDone()), this, SLOT(slotQueryDone()) ); - //relay signals directly - // actually this is wrong. We would need to combine the results - // to prevent duplicate album name results. - // On the other hand we need duplicate AlbumPtr results. - // Summary: be carefull when using this class. (Ralf) - connect( b, SIGNAL(newResultReady(Meta::TrackList)), this, SIGNAL(newResultReady(Meta::TrackList)), Qt::DirectConnection ); - connect( b, SIGNAL(newResultReady(Meta::ArtistList)), this, SIGNAL(newResultReady(Meta::ArtistList)), Qt::DirectConnection ); - connect( b, SIGNAL(newResultReady(Meta::AlbumList)), this, SIGNAL(newResultReady(Meta::AlbumList)), Qt::DirectConnection ); - connect( b, SIGNAL(newResultReady(Meta::GenreList)), this, SIGNAL(newResultReady(Meta::GenreList)), Qt::DirectConnection ); - connect( b, SIGNAL(newResultReady(Meta::ComposerList)), this, SIGNAL(newResultReady(Meta::ComposerList)), Qt::DirectConnection ); - connect( b, SIGNAL(newResultReady(Meta::YearList)), this, SIGNAL(newResultReady(Meta::YearList)), Qt::DirectConnection ); - connect( b, SIGNAL(newResultReady(QStringList)), this, SIGNAL(newResultReady(QStringList)), Qt::DirectConnection ); - connect( b, SIGNAL(newResultReady(Meta::LabelList)), this, SIGNAL(newResultReady(Meta::LabelList)), Qt::DirectConnection ); - } -} - -MetaQueryMaker::MetaQueryMaker( const QList &queryMakers ) - : QueryMaker() - , builders( queryMakers ) - , m_queryDoneCount( 0 ) - , m_queryDoneCountMutex() -{ - foreach( QueryMaker *b, builders ) - { - connect( b, SIGNAL(queryDone()), this, SLOT(slotQueryDone()) ); - //relay signals directly - connect( b, SIGNAL(newResultReady(Meta::TrackList)), this, SIGNAL(newResultReady(Meta::TrackList)), Qt::DirectConnection ); - connect( b, SIGNAL(newResultReady(Meta::ArtistList)), this, SIGNAL(newResultReady(Meta::ArtistList)), Qt::DirectConnection ); - connect( b, SIGNAL(newResultReady(Meta::AlbumList)), this, SIGNAL(newResultReady(Meta::AlbumList)), Qt::DirectConnection ); - connect( b, SIGNAL(newResultReady(Meta::GenreList)), this, SIGNAL(newResultReady(Meta::GenreList)), Qt::DirectConnection ); - connect( b, SIGNAL(newResultReady(Meta::ComposerList)), this, SIGNAL(newResultReady(Meta::ComposerList)), Qt::DirectConnection ); - connect( b, SIGNAL(newResultReady(Meta::YearList)), this, SIGNAL(newResultReady(Meta::YearList)), Qt::DirectConnection ); - connect( b, SIGNAL(newResultReady(QStringList)), this, SIGNAL(newResultReady(QStringList)), Qt::DirectConnection ); - connect( b, SIGNAL(newResultReady(Meta::LabelList)), this, SIGNAL(newResultReady(Meta::LabelList)), Qt::DirectConnection ); - } -} - -MetaQueryMaker::~MetaQueryMaker() -{ - foreach( QueryMaker *b, builders ) - delete b; -} - -void -MetaQueryMaker::run() -{ - foreach( QueryMaker *b, builders ) - b->run(); -} - -void -MetaQueryMaker::abortQuery() -{ - foreach( QueryMaker *b, builders ) - b->abortQuery(); -} - -QueryMaker* -MetaQueryMaker::setQueryType( QueryType type ) -{ - foreach( QueryMaker *qm, builders ) - qm->setQueryType( type ); - return this; -} - -QueryMaker* -MetaQueryMaker::addReturnValue( qint64 value ) -{ - foreach( QueryMaker *b, builders ) - b->addReturnValue( value ); - return this; -} - -QueryMaker* -MetaQueryMaker::addReturnFunction( ReturnFunction function, qint64 value ) -{ - foreach( QueryMaker *qm, builders ) - qm->addReturnFunction( function, value ); - return this; -} - -/* Ok. That doesn't work. First connecting the signals directly and then - doing "orderBy" directly */ -QueryMaker* -MetaQueryMaker::orderBy( qint64 value, bool descending ) -{ - foreach( QueryMaker *b, builders ) - b->orderBy( value, descending ); - return this; -} - -QueryMaker* -MetaQueryMaker::addFilter( qint64 value, const QString &filter, bool matchBegin, bool matchEnd ) -{ - foreach( QueryMaker *b, builders ) - b->addFilter( value, filter, matchBegin, matchEnd ); - return this; -} - -QueryMaker* -MetaQueryMaker::excludeFilter( qint64 value, const QString &filter, bool matchBegin, bool matchEnd ) -{ - foreach( QueryMaker *b, builders ) - b->excludeFilter( value, filter, matchBegin, matchEnd ); - return this; -} - -QueryMaker* -MetaQueryMaker::addNumberFilter( qint64 value, qint64 filter, QueryMaker::NumberComparison compare ) -{ - foreach( QueryMaker *b, builders ) - b->addNumberFilter( value, filter, compare); - return this; -} - -QueryMaker* -MetaQueryMaker::excludeNumberFilter( qint64 value, qint64 filter, QueryMaker::NumberComparison compare ) -{ - foreach( QueryMaker *b, builders ) - b->excludeNumberFilter( value, filter, compare ); - return this; -} - -QueryMaker* -MetaQueryMaker::addMatch( const Meta::TrackPtr &track ) -{ - foreach( QueryMaker *b, builders ) - b->addMatch( track ); - return this; -} - - -QueryMaker* -MetaQueryMaker::addMatch( const Meta::ArtistPtr &artist, QueryMaker::ArtistMatchBehaviour behaviour ) -{ - foreach( QueryMaker *b, builders ) - b->addMatch( artist, behaviour ); - return this; -} - -QueryMaker* -MetaQueryMaker::addMatch( const Meta::AlbumPtr &album ) -{ - foreach( QueryMaker *b, builders ) - b->addMatch( album ); - return this; -} - -QueryMaker* -MetaQueryMaker::addMatch( const Meta::GenrePtr &genre ) -{ - foreach( QueryMaker *b, builders ) - b->addMatch( genre ); - return this; -} - -QueryMaker* -MetaQueryMaker::addMatch( const Meta::ComposerPtr &composer ) -{ - foreach( QueryMaker *b, builders ) - b->addMatch( composer ); - return this; -} - -QueryMaker* -MetaQueryMaker::addMatch( const Meta::YearPtr &year ) -{ - foreach( QueryMaker *b, builders ) - b->addMatch( year ); - return this; -} - -QueryMaker* -MetaQueryMaker::addMatch( const Meta::LabelPtr &label ) -{ - foreach( QueryMaker *b, builders ) - b->addMatch( label ); - return this; -} - -QueryMaker* -MetaQueryMaker::limitMaxResultSize( int size ) -{ - foreach( QueryMaker *b, builders ) - b->limitMaxResultSize( size ); - return this; -} - -QueryMaker* -MetaQueryMaker::beginAnd() -{ - foreach( QueryMaker *b, builders ) - b->beginAnd(); - return this; -} - -QueryMaker* -MetaQueryMaker::beginOr() -{ - foreach( QueryMaker *b, builders ) - b->beginOr(); - return this; -} - -QueryMaker* -MetaQueryMaker::endAndOr() -{ - foreach( QueryMaker *b, builders ) - b->endAndOr(); - return this; -} - -QueryMaker* -MetaQueryMaker::setAlbumQueryMode( AlbumQueryMode mode ) -{ - foreach( QueryMaker *qm, builders ) - qm->setAlbumQueryMode( mode ); - return this; -} - -QueryMaker* -MetaQueryMaker::setLabelQueryMode( LabelQueryMode mode ) -{ - foreach( QueryMaker *qm, builders ) - qm->setLabelQueryMode( mode ); - return this; -} - -void -MetaQueryMaker::slotQueryDone() -{ - m_queryDoneCountMutex.lock(); - m_queryDoneCount++; - if ( m_queryDoneCount == builders.size() ) - { - //make sure we don't give control to code outside this class while holding the lock - m_queryDoneCountMutex.unlock(); - emit queryDone(); - } - else - m_queryDoneCountMutex.unlock(); -} - -#include "moc_MetaQueryMaker.cpp" - diff --git a/amarok/src/core/collections/MetaQueryMaker.h b/amarok/src/core/collections/MetaQueryMaker.h deleted file mode 100644 index 8c29b9bd..00000000 --- a/amarok/src/core/collections/MetaQueryMaker.h +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef COLLECTION_METAQUERYMAKER_H -#define COLLECTION_METAQUERYMAKER_H - -#include "core/collections/QueryMaker.h" -#include "core/collections/Collection.h" - -#include -#include - -namespace Collections { - -class AMAROK_CORE_EXPORT MetaQueryMaker : public QueryMaker -{ - Q_OBJECT - - public: - MetaQueryMaker( const QList &collections ); - MetaQueryMaker( const QList &queryMakers ); - ~MetaQueryMaker(); - - virtual void run(); - virtual void abortQuery(); - - virtual QueryMaker* setQueryType( QueryType type ); - - virtual QueryMaker* addReturnValue( qint64 value); - virtual QueryMaker* addReturnFunction( ReturnFunction function, qint64 value ); - virtual QueryMaker* orderBy( qint64 value, bool descending = false ); - - virtual QueryMaker* addMatch( const Meta::TrackPtr &track ); - virtual QueryMaker* addMatch( const Meta::ArtistPtr &artist, ArtistMatchBehaviour behaviour = TrackArtists ); - virtual QueryMaker* addMatch( const Meta::AlbumPtr &album ); - virtual QueryMaker* addMatch( const Meta::ComposerPtr &composer ); - virtual QueryMaker* addMatch( const Meta::GenrePtr &genre ); - virtual QueryMaker* addMatch( const Meta::YearPtr &year ); - virtual QueryMaker* addMatch( const Meta::LabelPtr &label ); - - virtual QueryMaker* addFilter( qint64 value, const QString &filter, bool matchBegin, bool matchEnd ); - virtual QueryMaker* excludeFilter( qint64 value, const QString &filter, bool matchBegin, bool matchEnd ); - - virtual QueryMaker* addNumberFilter( qint64 value, qint64 filter, QueryMaker::NumberComparison compare ); - virtual QueryMaker* excludeNumberFilter( qint64 value, qint64 filter, QueryMaker::NumberComparison compare ); - - virtual QueryMaker* limitMaxResultSize( int size ); - - virtual QueryMaker* beginAnd(); - virtual QueryMaker* beginOr(); - virtual QueryMaker* endAndOr(); - - virtual QueryMaker* setAlbumQueryMode( AlbumQueryMode mode ); - virtual QueryMaker* setLabelQueryMode( LabelQueryMode mode ); - - private slots: - void slotQueryDone(); - - private: - QList builders; - int m_queryDoneCount; - QMutex m_queryDoneCountMutex; - -}; - -} //namespace Collections - -#endif /* COLLECTION_METAQUERYMAKER_H */ diff --git a/amarok/src/core/collections/QueryMaker.cpp b/amarok/src/core/collections/QueryMaker.cpp deleted file mode 100644 index 06d0dfa8..00000000 --- a/amarok/src/core/collections/QueryMaker.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "core/collections/QueryMaker.h" - - -using namespace Collections; - -#include "core/meta/Meta.h" -#include "core/support/Debug.h" - -QueryMaker::QueryMaker() : QObject() -{ -} - -QueryMaker::~QueryMaker() -{ -} - -QueryMaker* -QueryMaker::setAlbumQueryMode( AlbumQueryMode mode ) -{ - Q_UNUSED( mode ) - return this; -} - -QueryMaker* -QueryMaker::setLabelQueryMode( LabelQueryMode mode ) -{ - Q_UNUSED( mode ) - return this; -} - -int QueryMaker::validFilterMask() -{ - return AllFilters; -} - -QueryMaker* -QueryMaker::setAutoDelete( bool autoDelete ) -{ - if( autoDelete ) - connect( this, SIGNAL(queryDone()), this, SLOT(deleteLater()) ); - else - disconnect( this, SIGNAL(queryDone()), this, SLOT(deleteLater()) ); - return this; -} - -QueryMaker* -QueryMaker::addMatch( const Meta::LabelPtr &label ) -{ - debug() << metaObject()->className() << " does not support label queries, ignoring label " << label->name(); - return this; -} - -#include "moc_QueryMaker.cpp" - diff --git a/amarok/src/core/collections/QueryMaker.h b/amarok/src/core/collections/QueryMaker.h deleted file mode 100644 index fce461cd..00000000 --- a/amarok/src/core/collections/QueryMaker.h +++ /dev/null @@ -1,245 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_COLLECTION_QUERYMAKER_H -#define AMAROK_COLLECTION_QUERYMAKER_H - -#include "core/amarokcore_export.h" -#include "core/meta/forward_declarations.h" -#include "core/meta/support/MetaConstants.h" - -#include -#include -#include - -namespace Collections { - -class AMAROK_CORE_EXPORT QueryMaker : public QObject -{ - Q_OBJECT - - public: - enum AlbumQueryMode { - AllAlbums, - OnlyCompilations , - OnlyNormalAlbums - }; - - enum LabelQueryMode { - NoConstraint, - OnlyWithLabels, - OnlyWithoutLabels - }; - - enum ArtistMatchBehaviour { - TrackArtists, - AlbumArtists, - AlbumOrTrackArtists - }; - - /** - * Filters that the QueryMaker accepts for searching. - * not all implementations will accept all filter levels, so make it possible to - * specify which ones make sense for a given qm. Add to this as needed - */ - enum ValidFilters { - TitleFilter = 1, - AlbumFilter = 2, - ArtistFilter = 4, - AlbumArtistFilter = 8, - GenreFilter = 16, - ComposerFilter = 32, - YearFilter = 64, - UrlFilter = 128, - AllFilters = 65535 - }; - - enum ReturnFunction { - Count, - Sum, - Max, - Min - }; - - enum NumberComparison { - Equals, - GreaterThan, - LessThan - }; - - enum QueryType { - None, // Set to faciliate using this in subclasses - Track, - Artist, - Album, - AlbumArtist, - Genre, - Composer, - Year, - Custom, - Label - }; - QueryMaker(); - virtual ~QueryMaker(); - - /** - * starts the query. This method returns immediately. All processing is done in one or more - * separate worker thread(s). One of the newResultReady signals will be emitted at least once, - * followed by the queryDone() signal exactly once. - */ - virtual void run() = 0; - /** - * aborts a running query. Calling this method aborts a running query as soon as possible. - * This method returns immediately. No signals will be emitted after calling this method. - * This method has no effect if no query is running. - */ - virtual void abortQuery() = 0; - - /** - * Sets the type of objects the querymaker will query for. These are mutually - * exclusive. The results of the query will be returned as objects of the - * appropriate type, therefore it is necessary to connect the client to the - * newResultReady( Meta::Type ) signal - * - * if you set QueryType custom, this starts a custom query. Unlike other query types, you have to set up the return - * values yourself using addReturnValue( qint64 ) and addReturnFunction(). The results will - * be returned as a QStringList. Threfore you have to connect to the - * newResultReady( QStringList ) signal to receive the results. - * @return this - */ - virtual QueryMaker* setQueryType( QueryType type ) = 0; - - /** - * only works after starting a custom query with setQueryType( Custom ) - * Use this to inform the query maker you are looking for results of value @param value. - * @return this - */ - virtual QueryMaker* addReturnValue( qint64 value ) = 0; - /** - * Returns the output of the function specified by function. - * Only works after starting a custom query - * @return this - */ - virtual QueryMaker* addReturnFunction( ReturnFunction function, qint64 value ) = 0; - /** - * Return results sorted by @p value. - * @return this - */ - virtual QueryMaker* orderBy( qint64 value, bool descending = false ) = 0; - - virtual QueryMaker* addMatch( const Meta::TrackPtr &track ) = 0; - /** - * Match given artist. Depending on @param behaviour matches: - * track artist if TrackArtists is given, - * album artist if AlbumArtists is given, - * any of track or album artist if AlbumOrTrackArtists is given. - * - * By default matches only track artist. - */ - virtual QueryMaker* addMatch( const Meta::ArtistPtr &artist, ArtistMatchBehaviour behaviour = TrackArtists ) = 0; - virtual QueryMaker* addMatch( const Meta::AlbumPtr &album ) = 0; - virtual QueryMaker* addMatch( const Meta::ComposerPtr &composer ) = 0; - virtual QueryMaker* addMatch( const Meta::GenrePtr &genre ) = 0; - virtual QueryMaker* addMatch( const Meta::YearPtr &year ) = 0; - virtual QueryMaker* addMatch( const Meta::LabelPtr &label ); - - /** - * Add a filter of type @p value and value @p filter. The querymaker applies this to all queries. - * @param text the text to match - * @param matchBegin If set then wildcard match the beginning of @p text (*text) - * @param matchEnd If set then wildcard match the end of @p text (text*) - * @return this - */ - virtual QueryMaker* addFilter( qint64 value, const QString &filter, bool matchBegin = false, bool matchEnd = false ) = 0; - /** - * Exclude filter of type @p value and value @p filter. The querymaker applies this to all queries. - * @param text the text to match - * @param matchBegin If set then wildcard match the beginning of @p text (*text) - * @param matchEnd If set then wildcard match the end of @p text (text*) - * @return this - */ - virtual QueryMaker* excludeFilter( qint64 value, const QString &filter, bool matchBegin = false, bool matchEnd = false ) = 0; - - virtual QueryMaker* addNumberFilter( qint64 value, qint64 filter, NumberComparison compare ) = 0; - virtual QueryMaker* excludeNumberFilter( qint64 value, qint64 filter, NumberComparison compare ) = 0; - - /** - * limit the maximum number of items in a result. the result will have [0..@p size ] items. When this function - * is not used, the result size is unbounded. Note: the maximum size applies to each result individually, so if - * the newResultReady signal is emitted multiple times, each result may have up to @p size items. - */ - virtual QueryMaker* limitMaxResultSize( int size ) = 0; - - /** - * select the mode for querying albums. If this method is not called, - * QueryMaker defaults to AlbumQueryMode::AllAlbums. - */ - virtual QueryMaker* setAlbumQueryMode( AlbumQueryMode mode ); - - /** - * Sets the label query mode. This method restricts a query to tracks - * that have labels assigned to them, no labels assigned to them, or no constraint. - * The default is no constraint. - * @param mode The LabelQueryMode that will be used by the query. - * @see LabelQueryMode - */ - virtual QueryMaker* setLabelQueryMode( LabelQueryMode mode ); - - virtual QueryMaker* beginAnd() = 0; - virtual QueryMaker* beginOr() = 0; - virtual QueryMaker* endAndOr() = 0; - - /** - * Choose whether the query maker instance should delete itself after the query. - * By passing true the query maker instance will delete itself after emitting queryDone(). - * Otherwise it is the responsibility of the owner (the code which called ::queryMaker() usually) to delete the instance - * when it is not needed anymore. - * - * Defaults to false, i.e. the querymaker instance will not delete itself. - */ - QueryMaker* setAutoDelete( bool autoDelete ); - - virtual int validFilterMask(); - - signals: - /** - * newResultReady will be emitted every time new results from the query maker are received. - * This signal can be emitted zero times (in case of no results) one (the usual case) or multiple times - * (e.g. in case when the result is received in several batches). - * The results will be terminated by a queryDone signal. - */ - void newResultReady( Meta::TrackList ); - void newResultReady( Meta::ArtistList ); - void newResultReady( Meta::AlbumList ); - void newResultReady( Meta::GenreList ); - void newResultReady( Meta::ComposerList ); - void newResultReady( Meta::YearList ); - void newResultReady( QStringList ); - void newResultReady( Meta::LabelList ); - void newResultReady( Meta::DataList ); - - /** - * This signal is emitted after all the results have been submitted via zero or more newResultReady signals. - */ - void queryDone(); -}; - -} //namespace Collections - -Q_DECLARE_METATYPE( Collections::QueryMaker* ) - -#endif /* AMAROK_COLLECTION_QUERYMAKER_H */ - diff --git a/amarok/src/core/collections/support/TrackForUrlWorker.cpp b/amarok/src/core/collections/support/TrackForUrlWorker.cpp deleted file mode 100644 index 4855d308..00000000 --- a/amarok/src/core/collections/support/TrackForUrlWorker.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Casey Link * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "TrackForUrlWorker.h" - -#include "core/meta/Meta.h" - -Amarok::TrackForUrlWorker::TrackForUrlWorker( const KUrl &url ) - : ThreadWeaver::Job() - , m_url( url ) -{ - connect( this, SIGNAL(done(ThreadWeaver::Job*)), SLOT(completeJob()) ); -} - -Amarok::TrackForUrlWorker::TrackForUrlWorker( const QString &url ) - : ThreadWeaver::Job() - , m_url( KUrl( url ) ) -{ - connect( this, SIGNAL(done(ThreadWeaver::Job*)), SLOT(completeJob()) ); -} - -Amarok::TrackForUrlWorker::~TrackForUrlWorker() -{} - -void -Amarok::TrackForUrlWorker::completeJob() -{ - emit finishedLookup( m_track ); - deleteLater(); -} diff --git a/amarok/src/core/collections/support/TrackForUrlWorker.h b/amarok/src/core/collections/support/TrackForUrlWorker.h deleted file mode 100644 index 7696a149..00000000 --- a/amarok/src/core/collections/support/TrackForUrlWorker.h +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Casey Link * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef TRACKFORURLWORKER_H -#define TRACKFORURLWORKER_H - -#include "core/amarokcore_export.h" -#include "core/support/Amarok.h" -#include "core/meta/forward_declarations.h" - -#include - -#include - -namespace Amarok -{ -/** - * Derive from this class and implement the run() method to set mTrack. - * @author Casey Link - */ -class AMAROK_CORE_EXPORT TrackForUrlWorker : public ThreadWeaver::Job -{ - Q_OBJECT -public: - TrackForUrlWorker( const KUrl &url ); - TrackForUrlWorker( const QString &url ); - ~TrackForUrlWorker(); - - virtual void run() = 0; -signals: - void finishedLookup( const Meta::TrackPtr &track ); - -protected: - KUrl m_url; - Meta::TrackPtr m_track; - -private slots: - void completeJob(); - - -}; - -} -#endif // TRACKFORURLWORKER_H diff --git a/amarok/src/core/interfaces/Logger.cpp b/amarok/src/core/interfaces/Logger.cpp deleted file mode 100644 index 6d4c3334..00000000 --- a/amarok/src/core/interfaces/Logger.cpp +++ /dev/null @@ -1,17 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "Logger.h" diff --git a/amarok/src/core/interfaces/Logger.h b/amarok/src/core/interfaces/Logger.h deleted file mode 100644 index 40e419ac..00000000 --- a/amarok/src/core/interfaces/Logger.h +++ /dev/null @@ -1,112 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_LOGGER_H -#define AMAROK_LOGGER_H - -#include "core/amarokcore_export.h" - -#include -#include - -class KJob; -class QNetworkReply; - -namespace Amarok -{ - /** - * This interface provides methods that allow backend components to notify the user. - * Users of this class may not make assumptions about the kind of notifications that - * will be sent to the user. - * - * The class name is up for discussion btw. - */ - class AMAROK_CORE_EXPORT Logger - { - public: - - enum MessageType { Information, Warning, Error }; - - Logger() {} - virtual ~Logger() {} - - public slots: - - /** - * Informs the user about the progress of a job, i.e. a download job. - * At the very least, the user is notified about the start and end of the job. - * - * @param job The job whose progress should be monitored - * @param text An additional text that will be part of the notification - * @param obj The object that will be called if the user cancels the job. If not set, the job will not be cancellable - * @param slot The slot on the given object that will be called if the user cancels the job. No slot will be called if not set. - * The signal will be emitted from the GUI thread. The receiver may not make assumptions about the sender - * @param type The Qt connection type to use for the connection to the receiving slot. Defaults to Qt::AutoConnection - */ - virtual void newProgressOperation( KJob *job, const QString &text, QObject *obj = 0, const char *slot = 0, Qt::ConnectionType type = Qt::AutoConnection ) = 0; - - /** - * Informs the user about the progress of a network request. - * At the very least, the user is notified about the start and end of the request. - * - * @param reply The network reply object whose progress should be monitored - * @param text An additional text that will be part of the notification - * @param obj The object that will be called if the user cancels the network request. If not set, the progress will not be cancellable - * @param slot The slot on the given object that will be called if the user cancels the network request. No slot will be called if not set. - * The signal will be emitted from the GUI thread. The receiver may not make assumptions about the sender - * @param type The Qt connection type to use for the connection to the receiving slot. Defaults to Qt::AutoConnection - */ - virtual void newProgressOperation( QNetworkReply *reply, const QString &text, QObject *obj = 0, const char *slot = 0, Qt::ConnectionType type = Qt::AutoConnection ) = 0; - - /** - * Informs the user about the progress of a generic QObject - * - * @param sender The object sending the required signals. This sender must emit singals - * incrementProgress() and endProgressOperation() and optionally totalSteps(). - * @param text An additional text that will be part of the notification - * @param maximum The maximum value of the progress operation - * @param obj The object that will be called if the user cancels the network request. If not - * set, the progress will not be cancellable - * @param slot The slot on the given object that will be called if the user cancels the - * network request. No slot will be called if not set. - * The signal will be emitted from the GUI thread. The receiver may not make assumptions - * about the sender - * @param type The Qt connection type to use for the connection to the receiving slot. - * Defaults to Qt::AutoConnection - */ - virtual void newProgressOperation( QObject *sender, const QString &text, int maximum = 100, - QObject *obj = 0, const char *slot = 0, - Qt::ConnectionType type = Qt::AutoConnection ) = 0; - - /** - * Sends a notification to the user. - * This method will send a notification containing the given text to the user. - * - * @param text The text that the notification will contain - */ - virtual void shortMessage( const QString &text ) = 0; - - /** - * Send a notification to the user with an additional context. - * A notification will be send to the user containing the given text. Additionally, it will convey the context given by @p type. - * @param text The text that the notification will contain - * @param type The context of the notification - */ - virtual void longMessage( const QString &text, MessageType type = Information ) = 0; - }; -} - -#endif diff --git a/amarok/src/core/interfaces/MetaCapability.cpp b/amarok/src/core/interfaces/MetaCapability.cpp deleted file mode 100644 index c8e1f560..00000000 --- a/amarok/src/core/interfaces/MetaCapability.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "MetaCapability.h" - -bool -MetaCapability::hasCapabilityInterface( Capabilities::Capability::Type type ) const -{ - Q_UNUSED( type ); - return false; -} - -Capabilities::Capability* -MetaCapability::createCapabilityInterface( Capabilities::Capability::Type type ) -{ - Q_UNUSED( type ); - return 0; -} diff --git a/amarok/src/core/interfaces/MetaCapability.h b/amarok/src/core/interfaces/MetaCapability.h deleted file mode 100644 index 8761ed60..00000000 --- a/amarok/src/core/interfaces/MetaCapability.h +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef METACAPABILITY_H -#define METACAPABILITY_H - -#include "core/capabilities/Capability.h" -#include "core/amarokcore_export.h" - -class AMAROK_CORE_EXPORT MetaCapability -{ - public: - virtual ~MetaCapability() {} - - /** - * Return true if this entity has capability @param CapIface, false otherwise. - */ - template bool has() const - { - return hasCapabilityInterface( CapIface::capabilityInterfaceType() ); - } - - /** - * Creates a specialized interface which represents a capability of this - * Meta::Base object. The caller of this method is responsible for deleting - * created capability! - * - * @returns a pointer to the capability interface if it exists, 0 otherwise - */ - template CapIface *create() - { - Capabilities::Capability::Type type = CapIface::capabilityInterfaceType(); - Capabilities::Capability *iface = createCapabilityInterface( type ); - return qobject_cast( iface ); - } - - /** - * Subclasses should override this method to denote they provide particular - * capability type. Must match @see createCapabilityInterface() - * - * This method should be considered protected (but is not because of practical - * reasons), you should normally call @see has() - */ - virtual bool hasCapabilityInterface( Capabilities::Capability::Type type ) const; - - /** - * Subclasses should override this method to create particular capability. - * Memory-management of the returned pointer is the responsibility of the - * caller of this method. Must match @see hasCapabilityInterface() - * - * This method should be considered protected (but is not because of practical - * reasons), you should normally call @see create() - */ - virtual Capabilities::Capability *createCapabilityInterface( Capabilities::Capability::Type type ); -}; - -#endif // METACAPABILITY_H diff --git a/amarok/src/core/meta/Base.cpp b/amarok/src/core/meta/Base.cpp deleted file mode 100644 index 2c937c10..00000000 --- a/amarok/src/core/meta/Base.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Maximilian Kossick * - * Copyright (c) 2007 Ian Monroe * - * Copyright (c) 2008 Mark Kretschmann * - * Copyright (c) 2013 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ***************************************************************************************/ - -#include "Base.h" - -#include "core/meta/Observer.h" - -#include - -using namespace Meta; - -Base::Base() - : m_observersLock( QReadWriteLock::Recursive ) -{ -} - -Base::~Base() -{ - // we need to notify all observers that we're deleted to avoid stale pointers - foreach( Observer *observer, m_observers ) - { - observer->destroyedNotify( this ); - } -} - -void -Base::subscribe( Observer *observer ) -{ - if( observer ) - { - QWriteLocker locker( &m_observersLock ); - m_observers.insert( observer ); - } -} - -void -Base::unsubscribe( Observer *observer ) -{ - QWriteLocker locker( &m_observersLock ); - m_observers.remove( observer ); -} - -QDebug & -operator<<( QDebug dbg, const Base &base ) -{ - dbg.nospace() << "Meta::Base(" << base.name() << " at " << &base << ")"; - return dbg.space(); -} diff --git a/amarok/src/core/meta/Base.h b/amarok/src/core/meta/Base.h deleted file mode 100644 index a761f9db..00000000 --- a/amarok/src/core/meta/Base.h +++ /dev/null @@ -1,121 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Maximilian Kossick * - * Copyright (c) 2007 Ian Monroe * - * Copyright (c) 2008 Mark Kretschmann * - * Copyright (c) 2013 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ***************************************************************************************/ - -#ifndef META_BASE_H -#define META_BASE_H - -#include "core/amarokcore_export.h" -#include "core/interfaces/MetaCapability.h" -#include "core/meta/forward_declarations.h" - -#include -#include -#include - -namespace Meta { - class Observer; - - class AMAROK_CORE_EXPORT Base : public virtual QSharedData, public MetaCapability - // virtual inherit. so that implementations can be both Meta::Track and Meta::Statistics - { - public: - Base(); - virtual ~Base(); - - /** - * The textual label for this object. - * - * For a track this is the track title, for an album it is the album name. - * If the name is unknown or unset then this returns an empty string. - */ - virtual QString name() const = 0; - - /** - * This is a nicer representation of the object. - * - * We will try to prevent this name from being empty. E.g. a track will fall - * back to the filename if possible. - */ - virtual QString prettyName() const { return name(); }; - - /** - * A name that can be used for sorting. - * - * This should usually mean that "The Beatles" is returned as "Beatles, The" - */ - virtual QString sortableName() const { return name(); } - - protected: - /** - * Helper so that notifyObservers() implemetation can be shared. Template - * parameter Obs is just Observer, we add it so that Observer.h doesn't need - * to be included in this header. - */ - template - void notifyObserversHelper( const T *self ) const; - - private: - // no copy allowed, since it's not safe with observer list - Q_DISABLE_COPY( Base ) - - friend class Observer; // so that Observer can call (un)subscribe() - - /** - * Subscribe @param observer for change updates. Don't ever think of calling - * this method yourself or overriding it, it's highly coupled with Observer. - */ - void subscribe( Observer *observer ); - - /** - * Unsubscribe @param observer from change updates. Don't ever think of - * calling this method yourself or overriging it, it's highly coupled with - * Observer. - */ - void unsubscribe( Observer *observer ); - - QSet m_observers; - mutable QReadWriteLock m_observersLock; // guards access to m_observers - }; - - template - void - Base::notifyObserversHelper( const T *self ) const - { - // observers ale allowed to remove themselves during metadataChanged() call. That's - // why the lock needs to be recursive AND the lock needs to be for writing, because - // a lock for reading cannot be recursively relocked for writing. - QWriteLocker locker( &m_observersLock ); - foreach( Obs *observer, m_observers ) - { - // observers can potentially remove or even destory other observers during - // metadataChanged() call. Guard against it. The guarding doesn't need to be - // thread-safe, because we already hold m_observersLock (which is recursive), - // so other threads wait on potential unsubscribe(). - if( m_observers.contains( observer ) ) - observer->metadataChanged( KSharedPtr( const_cast( self ) ) ); - } - } -} - -Q_DECLARE_METATYPE( Meta::DataPtr ) -Q_DECLARE_METATYPE( Meta::DataList ) - -AMAROK_CORE_EXPORT QDebug &operator<<( QDebug dbg, const Meta::Base &base ); - -#endif // META_BASE_H diff --git a/amarok/src/core/meta/Meta.cpp b/amarok/src/core/meta/Meta.cpp deleted file mode 100644 index a94394c4..00000000 --- a/amarok/src/core/meta/Meta.cpp +++ /dev/null @@ -1,388 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Maximilian Kossick * - * Copyright (c) 2007 Ian Monroe * - * Copyright (c) 2008 Mark Kretschmann * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "core/meta/Meta.h" - -#include "core/collections/Collection.h" -#include "core/collections/QueryMaker.h" -#include "core/meta/Observer.h" -#include "core/meta/Statistics.h" -#include "core/meta/TrackEditor.h" -#include "core/support/Amarok.h" -#include "core/support/Debug.h" - -#include - -#include -#include - -using namespace Meta; - -//Meta::Track - -QString -Meta::Track::prettyName() const -{ - if( !name().isEmpty() ) - return name(); - return prettyUrl(); -} - -bool -Meta::Track::inCollection() const -{ - return false; -} - -Collections::Collection* -Meta::Track::collection() const -{ - return 0; -} - -Meta::LabelList -Meta::Track::labels() const -{ - return Meta::LabelList(); -} - -QString -Meta::Track::cachedLyrics() const -{ - return QString(); -} - -void -Meta::Track::setCachedLyrics( const QString &lyrics ) -{ - Q_UNUSED( lyrics ) -} - -void -Meta::Track::addLabel( const QString &label ) -{ - Q_UNUSED( label ) -} - -void -Meta::Track::addLabel( const Meta::LabelPtr &label ) -{ - Q_UNUSED( label ) -} - -void -Meta::Track::removeLabel( const Meta::LabelPtr &label ) -{ - Q_UNUSED( label ) -} - -QDateTime -Meta::Track::createDate() const -{ - return QDateTime(); -} - -QDateTime -Meta::Track::modifyDate() const -{ - return QDateTime(); -} - -qreal -Meta::Track::replayGain( Meta::ReplayGainTag mode ) const -{ - Q_UNUSED( mode ) - return 0.0; -} - -void -Meta::Track::prepareToPlay() -{ -} - -void -Meta::Track::finishedPlaying( double playedFraction ) -{ - qint64 len = length(); - bool updatePlayCount; - if( len <= 30 * 1000 ) - updatePlayCount = ( playedFraction >= 1.0 ); - else - // at least half the song or at least 5 minutes played - updatePlayCount = ( playedFraction >= 0.5 || ( playedFraction * len ) >= 5 * 60 * 1000 ); - - StatisticsPtr stats = statistics(); - stats->beginUpdate(); - // we should update score even if updatePlayCount is false to record skips - stats->setScore( Amarok::computeScore( stats->score(), stats->playCount(), playedFraction ) ); - if( updatePlayCount ) - { - stats->setPlayCount( stats->playCount() + 1 ); - if( !stats->firstPlayed().isValid() ) - stats->setFirstPlayed( QDateTime::currentDateTime() ); - stats->setLastPlayed( QDateTime::currentDateTime() ); - } - stats->endUpdate(); -} - -void -Meta::Track::notifyObservers() const -{ - notifyObserversHelper( this ); -} - -bool -Meta::Track::operator==( const Meta::Track &track ) const -{ - return dynamic_cast( this ) == dynamic_cast( &track ); -} - -bool -Meta::Track::lessThan( const Meta::TrackPtr& left, const Meta::TrackPtr& right ) -{ - if( !left || !right ) // These should never be 0, but it can apparently happen (http://bugs.kde.org/show_bug.cgi?id=181187) - return false; - - if( left->album() && right->album() ) - if( left->album()->name() == right->album()->name() ) - { - if( left->discNumber() < right->discNumber() ) - return true; - else if( left->discNumber() > right->discNumber() ) - return false; - - if( left->trackNumber() < right->trackNumber() ) - return true; - if( left->trackNumber() > right->trackNumber() ) - return false; - } - - if( left->artist() && right->artist() ) - { - int compare = QString::localeAwareCompare( left->artist()->prettyName(), right->artist()->prettyName() ); - if ( compare < 0 ) - return true; - else if ( compare > 0 ) - return false; - } - - if( left->album() && right->album() ) - { - int compare = QString::localeAwareCompare( left->album()->prettyName(), right->album()->prettyName() ); - if ( compare < 0 ) - return true; - else if ( compare > 0 ) - return false; - } - - return QString::localeAwareCompare( left->prettyName(), right->prettyName() ) < 0; -} - -bool -Track::isPlayable() const -{ - return notPlayableReason().isEmpty(); -} - -QString -Track::networkNotPlayableReason() const -{ - switch( Solid::Networking::status() ) - { - case Solid::Networking::Unconnected: - case Solid::Networking::Disconnecting: - case Solid::Networking::Connecting: - return i18n( "No network connection" ); - case Solid::Networking::Unknown: - case Solid::Networking::Connected: - return QString(); - } - return QString(); -} - -QString -Track::localFileNotPlayableReason( const QString &path ) const -{ - QFileInfo trackFileInfo = QFileInfo( path ); - if( !trackFileInfo.exists() ) - return i18n( "File does not exist" ); - if( !trackFileInfo.isFile() ) - return i18n( "Not a file" ); - if( !trackFileInfo.isReadable() ) - return i18n( "No read permissions" ); - return QString(); -} - -TrackEditorPtr -Track::editor() -{ - return TrackEditorPtr(); -} - -StatisticsPtr -Track::statistics() -{ - // return dummy implementation - return StatisticsPtr( new Statistics() ); -} - -ConstStatisticsPtr -Track::statistics() const -{ - StatisticsPtr statistics = const_cast( this )->statistics(); - return ConstStatisticsPtr( statistics.data() ); -} - - -//Meta::Artist - -QString -Meta::Artist::prettyName() const -{ - if( !name().isEmpty() ) - return name(); - return i18n("Unknown Artist"); -} - -void -Meta::Artist::notifyObservers() const -{ - m_sortableName.clear(); // name() may have changed, recompute sortableName next time - notifyObserversHelper( this ); -} - -bool -Meta::Artist::operator==( const Meta::Artist &artist ) const -{ - return dynamic_cast( this ) == dynamic_cast( &artist ); -} - -QString -Meta::Artist::sortableName() const -{ - if( !m_sortableName.isEmpty() ) - return m_sortableName; - - const QString &n = name(); - if( n.startsWith( QLatin1String("the "), Qt::CaseInsensitive ) ) - { - QStringRef article = n.leftRef( 3 ); - QStringRef subject = n.midRef( 4 ); - m_sortableName = QString( "%1, %2" ).arg( subject.toString(), article.toString() ); - } - else if( n.startsWith( QLatin1String("dj "), Qt::CaseInsensitive ) ) - { - QStringRef article = n.leftRef( 2 ); - QStringRef subject = n.midRef( 3 ); - m_sortableName = QString( "%1, %2" ).arg( subject.toString(), article.toString() ); - } - else - m_sortableName = n; - return m_sortableName; -} - -//Meta::Album - -QString -Meta::Album::prettyName() const -{ - if( !name().isEmpty() ) - return name(); - return i18n("Unknown Album"); -} - -void -Meta::Album::notifyObservers() const -{ - notifyObserversHelper( this ); -} - -/* - * This is the base class's image() function, which returns just an null image. - * Retrieval of the cover for the actual album is done by subclasses. - */ -QImage -Meta::Album::image( int size ) const -{ - Q_UNUSED( size ); - return QImage(); -} - -bool -Meta::Album::operator==( const Meta::Album &album ) const -{ - return dynamic_cast( this ) == dynamic_cast( &album ); -} - -//Meta::Genre - -QString -Meta::Genre::prettyName() const -{ - if( !name().isEmpty() ) - return name(); - return i18n("Unknown Genre"); -} - -void -Meta::Genre::notifyObservers() const -{ - notifyObserversHelper( this ); -} - -bool -Meta::Genre::operator==( const Meta::Genre &genre ) const -{ - return dynamic_cast( this ) == dynamic_cast( &genre ); -} - -//Meta::Composer - -QString -Meta::Composer::prettyName() const -{ - if( !name().isEmpty() ) - return name(); - return i18n("Unknown Composer"); -} - -void -Meta::Composer::notifyObservers() const -{ - notifyObserversHelper( this ); -} - -bool -Meta::Composer::operator==( const Meta::Composer &composer ) const -{ - return dynamic_cast( this ) == dynamic_cast( &composer ); -} - -//Meta::Year - -void -Meta::Year::notifyObservers() const -{ - notifyObserversHelper( this ); -} - -bool -Meta::Year::operator==( const Meta::Year &year ) const -{ - return dynamic_cast( this ) == dynamic_cast( &year ); -} diff --git a/amarok/src/core/meta/Meta.h b/amarok/src/core/meta/Meta.h deleted file mode 100644 index e3b90f52..00000000 --- a/amarok/src/core/meta/Meta.h +++ /dev/null @@ -1,388 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Maximilian Kossick * - * Copyright (c) 2008 Mark Kretschmann * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_META_H -#define AMAROK_META_H - -#include "MetaReplayGain.h" -#include "core/meta/Base.h" - -#include -#include -#include -#include -#include - -#include - -namespace Collections -{ - class Collection; - class QueryMaker; -} -class PersistentStatisticsStore; - -namespace Meta -{ - class AMAROK_CORE_EXPORT Track : public Base - { - public: - /** used to display the trackname, should never be empty, returns prettyUrl() by default if name() is empty */ - virtual QString prettyName() const; - /** an url which can be played by the engine backends */ - virtual KUrl playableUrl() const = 0; - /** an url for display purposes */ - virtual QString prettyUrl() const = 0; - - /** - * A fake url which is unique for this track. Use this if you need a key for - * the track. - */ - virtual QString uidUrl() const = 0; - - /** - * Return whether playableUrl() will return a valid & readable playable url. - * - * Convenience method that just checks whether notPlayableReason() is empty. - */ - bool isPlayable() const; - - /** - * Return user-readable localized reason why isPlayable() is false. - * - * Subclasses must return a non-empty (localized) string if this track is not - * playable (i.e. playableUrl() won't return a valid url) and an empty string - * otherwise. - * - * This method is used to implement convenience Meta::Track::isPlayable() - * method. - */ - virtual QString notPlayableReason() const = 0; - - /** Returns the album this track belongs to */ - virtual AlbumPtr album() const = 0; - /** Returns the artist of this track */ - virtual ArtistPtr artist() const = 0; - /** Returns the composer of this track */ - virtual ComposerPtr composer() const = 0; - /** Returns the genre of this track */ - virtual GenrePtr genre() const = 0; - /** Returns the year of this track */ - virtual YearPtr year() const = 0; - /** - * Returns the labels that are assigned to a track. - */ - virtual Meta::LabelList labels() const; - /** Returns the BPM of this track */ - virtual qreal bpm() const = 0; - /** Returns the comment of this track */ - virtual QString comment() const = 0; - /** Returns the length of this track in milliseconds, or 0 if unknown */ - virtual qint64 length() const = 0; - /** Returns the filesize of this track in bytes */ - virtual int filesize() const = 0; - /** Returns the sample rate of this track */ - virtual int sampleRate() const = 0; - /** Returns the bitrate o this track in kbps (kilo BITS per second) */ - virtual int bitrate() const = 0; - /** Returns the time when the track was added to the collection, - or an invalid QDateTime if the time is not known. */ - virtual QDateTime createDate() const; - /** Returns the time when the track was last modified (before being added to the collection) - or an invalid QDateTime if the time is not known. */ - virtual QDateTime modifyDate() const; - /** Returns the track number of this track */ - virtual int trackNumber() const = 0; - /** Returns the discnumber of this track */ - virtual int discNumber() const = 0; - /** - * Returns the gain adjustment for a given replay gain mode. - * - * Should return @c 0 if no replay gain value is known. - * - * Should return the track replay gain if the album gain is requested but - * is not available. - */ - virtual qreal replayGain( ReplayGainTag mode ) const; - - /** - * Returns the type of this track, e.g. "ogg", "mp3", "stream" - * - * TODO: change return type to Amarok::FileType enum. Clients needing - * user-representation would call FileTypeSupport::toLocalizedString() - */ - virtual QString type() const = 0; - - /** tell the track to perform any prerequisite - * operations before playing */ - virtual void prepareToPlay(); - - /** tell the track object that amarok finished playing it. - The argument is the percentage of the track which was played, in the range 0 to 1*/ - virtual void finishedPlaying( double playedFraction ); - - /** returns true if the track is part of a collection false otherwise */ - virtual bool inCollection() const; - /** - returns the collection that the track is part of, or 0 iff - inCollection() returns false */ - virtual Collections::Collection* collection() const; - - /** get the cached lyrics for the track. returns an empty string if - no cached lyrics are available */ - virtual QString cachedLyrics() const; - /** - set the cached lyrics for the track - */ - virtual void setCachedLyrics( const QString &lyrics ); - - /** - Adds a label to the track. - Does nothing if the track already has the given label. - */ - virtual void addLabel( const QString &label ); - /** - Adds a label to the track. - Does nothing if the track already has the given label. - */ - virtual void addLabel( const Meta::LabelPtr &label ); - - /** - Removes a lbel from a track. - Does nothing if the track does not actually have the label assigned to it. - */ - virtual void removeLabel( const Meta::LabelPtr &label ); - - virtual bool operator==( const Track &track ) const; - - static bool lessThan( const TrackPtr& left, const TrackPtr& right ); - - /** - * Return a pointer to TrackEditor interface that allows you to edit metadata - * of this track. May be null, which signifies that the track is not editable. - * - * This is a replacement to ::create() with more - * well-defined memory management and nicer implementation possibilities. - * (multiple inheritance and returning self) - * - * Default implementation returns null pointer. - */ - virtual TrackEditorPtr editor(); - - /** - * Return a pointer to track's Statistics interface. May never be null. - * - * Subclasses: always return the default implementation instead of returning 0. - */ - virtual StatisticsPtr statistics(); - ConstStatisticsPtr statistics() const; // allow const statistics methods on const tracks - - protected: - friend class ::PersistentStatisticsStore; // so that it can call notifyObservers - virtual void notifyObservers() const; - - /** - * Helper method for subclasses to implement notPlayableReason(). - * Checks network status and returns a non-empty reason string if - * it isn't online. - */ - QString networkNotPlayableReason() const; - - /** - * Helper method for subclasses to implement notPlayableReason(). - * Checks, in order, if the file exists, if it is a file and if - * the file is readable - */ - QString localFileNotPlayableReason( const QString &path ) const; - }; - - class AMAROK_CORE_EXPORT Artist : public Base - { - public: - virtual QString prettyName() const; - - /** returns all tracks by this artist */ - virtual TrackList tracks() = 0; - - virtual bool operator==( const Meta::Artist &artist ) const; - - virtual QString sortableName() const; - - protected: - virtual void notifyObservers() const; - - private: - mutable QString m_sortableName; - }; - - /** - * Represents an album. - * - * Most collections do not store a specific album object. Instead an album is just - * a property of a track, a container containing one or more tracks. - * - * Collections should provide an album for every track as the collection browser - * will, depending on the setting, only display tracks inside albums. - * - * For all albums in a compilation the pair album-title/album-artist should be - * unique as this pair is used as a key in several places. - * - * Albums without an artist are called compilations. Albums without a title but - * with an artist should contain all singles of the specific artist. There should - * be one album without title and artist for all the rest. - */ - class AMAROK_CORE_EXPORT Album : public Base - { - public: - virtual QString prettyName() const; - - /** - * Whether this album is considered to be a compilation of tracks from various - * artists. - */ - virtual bool isCompilation() const = 0; - /** - * Whether toggling the compilation status is currenlty supported. Default - * implementation returns false. - */ - virtual bool canUpdateCompilation() const { return false; } - /** - * Set compilation status. You should check canUpdateCompilation() first. - */ - virtual void setCompilation( bool isCompilation ) { Q_UNUSED( isCompilation ) } - - /** Returns true if this album has an album artist */ - virtual bool hasAlbumArtist() const = 0; - /** Returns a pointer to the album's artist */ - virtual ArtistPtr albumArtist() const = 0; - /** returns all tracks on this album */ - virtual TrackList tracks() = 0; - - /** - * A note about image sizes: - * when size is <= 1, return the full size image - */ - /** returns true if the album has a cover set */ - virtual bool hasImage( int size = 0 ) const { Q_UNUSED( size ); return false; } - - /** Returns the image for the album, usually the cover image. - The default implementation returns an null image. - If you need a pixmap call The::coverCache()->getCover( album, size ) - instead. That function also returns a "nocover" pixmap - */ - virtual QImage image( int size = 0 ) const; - - /** Returns the image location on disk. - The mpris interface is using this information for notifications so - it better is a local file url. - */ - virtual KUrl imageLocation( int size = 0 ) { Q_UNUSED( size ); return KUrl(); } - - /** Returns true if it is possible to update the cover of the album */ - virtual bool canUpdateImage() const { return false; } - - /** updates the cover of the album - @param image The large scale image that should be used as cover for the album. - Note: the parameter should not be a QPixmap as a pixmap can only be created reliable in a UI thread. - */ - virtual void setImage( const QImage &image ) { Q_UNUSED( image ); } - - /** removes the album art */ - virtual void removeImage() { } - - /** don't automatically fetch artwork */ - virtual void setSuppressImageAutoFetch( const bool suppress ) { Q_UNUSED( suppress ); } - /** should automatic artwork retrieval be suppressed? */ - virtual bool suppressImageAutoFetch() const { return false; } - - virtual bool operator==( const Meta::Album &album ) const; - - protected: - virtual void notifyObservers() const; - }; - - class AMAROK_CORE_EXPORT Composer : public Base - { - public: - virtual QString prettyName() const; - - /** returns all tracks by this composer */ - virtual TrackList tracks() = 0; - - virtual bool operator==( const Meta::Composer &composer ) const; - - protected: - virtual void notifyObservers() const; - }; - - class AMAROK_CORE_EXPORT Genre : public Base - { - public: - virtual QString prettyName() const; - - /** returns all tracks which belong to the genre */ - virtual TrackList tracks() = 0; - - virtual bool operator==( const Meta::Genre &genre ) const; - - protected: - virtual void notifyObservers() const; - }; - - class AMAROK_CORE_EXPORT Year : public Base - { - public: - /** - * Returns the year this object represents. - * number of 0 is considered unset. - */ - virtual int year() const { return name().toInt(); } - - /** returns all tracks which are tagged with this year */ - virtual TrackList tracks() = 0; - - virtual bool operator==( const Meta::Year &year ) const; - - protected: - virtual void notifyObservers() const; - }; - - /** - * A Label represents an arbitrary classification of a Track. - */ - class AMAROK_CORE_EXPORT Label : public Base - { - // we need nothing more than what Meta::Base has - }; -} - -Q_DECLARE_METATYPE( Meta::TrackPtr ) -Q_DECLARE_METATYPE( Meta::TrackList ) -Q_DECLARE_METATYPE( Meta::ArtistPtr ) -Q_DECLARE_METATYPE( Meta::ArtistList ) -Q_DECLARE_METATYPE( Meta::AlbumPtr ) -Q_DECLARE_METATYPE( Meta::AlbumList ) -Q_DECLARE_METATYPE( Meta::ComposerPtr ) -Q_DECLARE_METATYPE( Meta::ComposerList ) -Q_DECLARE_METATYPE( Meta::GenrePtr ) -Q_DECLARE_METATYPE( Meta::GenreList ) -Q_DECLARE_METATYPE( Meta::YearPtr ) -Q_DECLARE_METATYPE( Meta::YearList ) -Q_DECLARE_METATYPE( Meta::LabelPtr ) -Q_DECLARE_METATYPE( Meta::LabelList ) - -#endif /* AMAROK_META_H */ diff --git a/amarok/src/core/meta/Observer.cpp b/amarok/src/core/meta/Observer.cpp deleted file mode 100644 index 7c34ba8b..00000000 --- a/amarok/src/core/meta/Observer.cpp +++ /dev/null @@ -1,103 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Maximilian Kossick * - * Copyright (c) 2008 Mark Kretschmann * - * Copyright (c) 2013 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ***************************************************************************************/ - -#include "Observer.h" - -#include "core/meta/Base.h" - -using namespace Meta; - -Observer::~Observer() -{ - // Unsubscribe all stray Meta subscriptions: - foreach( Base *ptr, m_subscriptions ) - { - if( ptr ) - ptr->unsubscribe( this ); - } -} - -void -Observer::metadataChanged( TrackPtr track ) -{ - Q_UNUSED( track ); -} - -void -Observer::metadataChanged( ArtistPtr artist ) -{ - Q_UNUSED( artist ); -} - -void -Observer::metadataChanged( AlbumPtr album ) -{ - Q_UNUSED( album ); -} - -void -Observer::metadataChanged( ComposerPtr composer ) -{ - Q_UNUSED( composer ); -} - -void -Observer::metadataChanged( GenrePtr genre ) -{ - Q_UNUSED( genre ); -} - -void -Observer::metadataChanged( YearPtr year ) -{ - Q_UNUSED( year ); -} - -void -Observer::entityDestroyed() -{ -} - -void -Observer::subscribeTo( Base *ptr ) -{ - if( !ptr ) - return; - QMutexLocker locker( &m_subscriptionsMutex ); - ptr->subscribe( this ); - m_subscriptions.insert( ptr ); -} - -void -Observer::unsubscribeFrom( Base *ptr ) -{ - QMutexLocker locker( &m_subscriptionsMutex ); - if( ptr ) - ptr->unsubscribe( this ); - m_subscriptions.remove( ptr ); -} - -void -Observer::destroyedNotify( Base *ptr ) -{ - { - QMutexLocker locker( &m_subscriptionsMutex ); - m_subscriptions.remove( ptr ); - } - entityDestroyed(); -} diff --git a/amarok/src/core/meta/Observer.h b/amarok/src/core/meta/Observer.h deleted file mode 100644 index 3b34550d..00000000 --- a/amarok/src/core/meta/Observer.h +++ /dev/null @@ -1,93 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Maximilian Kossick * - * Copyright (c) 2008 Mark Kretschmann * - * Copyright (c) 2013 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ***************************************************************************************/ - -#ifndef META_OBSERVER_H -#define META_OBSERVER_H - -#include "core/amarokcore_export.h" -#include "core/meta/forward_declarations.h" - -#include -#include - -class PersistentStatisticsStore; - -namespace Meta { - /** - * Subclass this class to be able to listen to changes of track, artist, album, genre, - * composer and year metadata. Must useful just for tracks and albums though. - * - * If you want to everride just one metadataChanged() and want to get rid of "method - * hidden compiler warnings", use following pattern in your class declaration: - * - * using Observer::metadataChanged; - * void metadataChanged( AlbumPtr album ); - * - * This class is thread-safe. - */ - class AMAROK_CORE_EXPORT Observer - { - friend class Base; // so that it can call destroyedNotify() - - public: - virtual ~Observer(); - - /** - * Subscribe to changes made by @param entity. - * - * Changed in 2.7: being subscribed to an entity no longer prevents its - * destruction. - */ - template - void subscribeTo( KSharedPtr entity ) { subscribeTo( entity.data() ); } - template - void unsubscribeFrom( KSharedPtr entity ) { unsubscribeFrom( entity.data() ); } - - /** - * This method is called when the metadata of a track has changed. - * The called class may not cache the pointer. - */ - virtual void metadataChanged( TrackPtr track ); - virtual void metadataChanged( ArtistPtr artist ); - virtual void metadataChanged( AlbumPtr album ); - virtual void metadataChanged( GenrePtr genre ); - virtual void metadataChanged( ComposerPtr composer ); - virtual void metadataChanged( YearPtr year ); - - /** - * One of the subscribed entities was destroyed. You don't get which one - * because it is already invalid. - */ - virtual void entityDestroyed(); - - private: - friend class ::PersistentStatisticsStore; // so that it can call KSharedPtr-free subscribe: - void subscribeTo( Base *ptr ); - void unsubscribeFrom( Base *ptr ); - - /** - * Called in Meta::Base destructor so that Observer doesn't have a stale pointer. - */ - void destroyedNotify( Base *ptr ); - - QSet m_subscriptions; - QMutex m_subscriptionsMutex; /// mutex guarding access to m_subscriptions - }; -} - -#endif // META_OBSERVER_H diff --git a/amarok/src/core/meta/Statistics.cpp b/amarok/src/core/meta/Statistics.cpp deleted file mode 100644 index b8e148da..00000000 --- a/amarok/src/core/meta/Statistics.cpp +++ /dev/null @@ -1,101 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "Statistics.h" - -#include - -using namespace Meta; - -Statistics::~Statistics() -{ -} - -double -Statistics::score() const -{ - return 0.0; -} - -void -Statistics::setScore( double newScore ) -{ - Q_UNUSED( newScore ) -} - -int -Statistics::rating() const -{ - return 0; -} - -void -Statistics::setRating( int newRating ) -{ - Q_UNUSED( newRating ) -} - -QDateTime -Statistics::lastPlayed() const -{ - return QDateTime(); -} - -void -Statistics::setLastPlayed( const QDateTime &date ) -{ - Q_UNUSED( date ) -} - -QDateTime -Statistics::firstPlayed() const -{ - return QDateTime(); -} - -void -Statistics::setFirstPlayed( const QDateTime &date ) -{ - Q_UNUSED( date ) -} - -int -Statistics::playCount() const -{ - return 0; -} - -int -Statistics::recentPlayCount() const -{ - return 0; -} - -void -Statistics::setPlayCount( int newPlayCount ) -{ - Q_UNUSED( newPlayCount ) -} - -void -Statistics::beginUpdate() -{ -} - -void -Statistics::endUpdate() -{ -} diff --git a/amarok/src/core/meta/Statistics.h b/amarok/src/core/meta/Statistics.h deleted file mode 100644 index b4812578..00000000 --- a/amarok/src/core/meta/Statistics.h +++ /dev/null @@ -1,131 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef META_STATISTICS_H -#define META_STATISTICS_H - -#include "core/amarokcore_export.h" - -#include - -class QDateTime; - -namespace Meta -{ - /** - * Interface that can be provided by tracks that can support play-related statistics: - * rating, score, first/last played, play count. - * - * This class is memory-managed exclusively using KSharedPtrs: always use - * StatisticsPtr to store or pass pointer to this class. This class must be - * implemented in a reentrant manner. Additionally, underlying Meta::Track must be - * thread-safe -- if you return same instance of Statistics every time then it means - * that even the instance must be thread-safe. - */ - class AMAROK_CORE_EXPORT Statistics : public virtual QSharedData // virtual inheritance - // so that Track implementations can inherit both Meta::Track and Meta::Statistics - { - public: - virtual ~Statistics(); - - /** - * Return the score of this track in range 0 .. 100. Default implementation - * returns 0. - */ - virtual double score() const; - - /** - * Set score of this track. If you touch more fields, consider using - * @see beginUpdate(), @see endUpdate() - */ - virtual void setScore( double newScore ); - - /** - * Return the rating of this track as a count of half-stars in range 0 .. 10. - * Default implementation returns 0. - */ - virtual int rating() const; - - /** - * Set rating of this track. If you touch more fields, consider using - * @see beginUpdate(), @see endUpdate() - */ - virtual void setRating( int newRating ); - - /** - * Return the time the song was last played, or an invalid QDateTime if it - * has not been played yet (done by the default implementation). - */ - virtual QDateTime lastPlayed() const; - - /** - * Set the last played time. @param date may be an invalid date to reset - * the date to "never played". If you touch more fields, consider using - * @see beginUpdate(), @see endUpdate() - */ - virtual void setLastPlayed( const QDateTime &date ); - - /** - * Return the time the song was first played, or an invalid QDateTime if it - * has not been played yet (done by the default implementation). - */ - virtual QDateTime firstPlayed() const; - - /** - * Set the first played time. @param date may be an invalid date to reset - * the date to "never played". If you touch more fields, consider using - * @see beginUpdate(), @see endUpdate() - */ - virtual void setFirstPlayed( const QDateTime &date ); - - /** - * Returns the number of times the track was played, 0 id it is unknown. - * Default implementation returns 0. - */ - virtual int playCount() const; - - /** - * Return play count on device since it has been last connected to a computer. - * This number is _already_ _included_ in playCount()! Subclasses returning - * nonzero must also implement setPlayCount() and setting play count must - * reset recent playcount to 0. Default implementation returns 0. - */ - virtual int recentPlayCount() const; - - /** - * Set play count. If you touch more fields, consider using - * @see beginUpdate(), @see endUpdate() - */ - virtual void setPlayCount( int newPlayCount ); - - /** - * If you call multiple set*() methods, enclose the calls in beginUpdate() ... - * endUpdate(); to allow more efficient processing. - */ - virtual void beginUpdate(); - - /** - * If you call multiple set*() methods, enclose the calls in beginUpdate() ... - * endUpdate(); to allow more efficient processing. - */ - virtual void endUpdate(); - }; - - typedef KSharedPtr StatisticsPtr; - typedef KSharedPtr ConstStatisticsPtr; -} - -#endif // META_STATISTICS_H diff --git a/amarok/src/core/meta/TrackEditor.cpp b/amarok/src/core/meta/TrackEditor.cpp deleted file mode 100644 index 31dd18cd..00000000 --- a/amarok/src/core/meta/TrackEditor.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "TrackEditor.h" - -Meta::TrackEditor::~TrackEditor() -{ - //nothing to do -} diff --git a/amarok/src/core/meta/TrackEditor.h b/amarok/src/core/meta/TrackEditor.h deleted file mode 100644 index 598ed961..00000000 --- a/amarok/src/core/meta/TrackEditor.h +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Maximilian Kossick * - * Copyright (c) 2013 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef META_TRACKEDITOR_H -#define META_TRACKEDITOR_H - -#include "core/amarokcore_export.h" - -#include - -namespace Meta -{ - /** - * Capability to edit meta-data of a track. - * - * If you are calling more than one setter method, you should call beginUpdate() - * before calling any setter methods and endUpdate() when you're done. - * - * This class is memory-managed exclusively using KSharedPtrs: always use - * TrackEditorPtr to store or pass pointer to this class. This class must be - * implemented in a reentrant manner. Additionally, underlying Meta::Track must - * be thread-safe -- if you return same instance of TrackEditor every time then it - * means that even the instance must be thread-safe. - */ - class AMAROK_CORE_EXPORT TrackEditor : public virtual QSharedData // virtual inheritance - // so that Track implementations can inherit both Meta::Track and Meta::TrackEditor - { - public: - virtual ~TrackEditor(); - - virtual void setAlbum( const QString &newAlbum ) = 0; - virtual void setAlbumArtist( const QString &newAlbumArtist ) = 0; - virtual void setArtist( const QString &newArtist ) = 0; - virtual void setComposer( const QString &newComposer ) = 0; - virtual void setGenre( const QString &newGenre ) = 0; - virtual void setYear( int newYear ) = 0; - virtual void setTitle( const QString &newTitle ) = 0; - virtual void setComment( const QString &newComment ) = 0; - virtual void setTrackNumber( int newTrackNumber ) = 0; - virtual void setDiscNumber( int newDiscNumber ) = 0; - virtual void setBpm( const qreal newBpm ) = 0; - - /** - * The track object should not store changed meta data immediately but cache - * the changes until endUpdate() is called - */ - virtual void beginUpdate() = 0; - - /** - * All meta data has been updated and the object should commit the changes - */ - virtual void endUpdate() = 0; - }; - - typedef KSharedPtr TrackEditorPtr; -} - -#endif // META_TRACKEDITOR_H diff --git a/amarok/src/core/meta/forward_declarations.h b/amarok/src/core/meta/forward_declarations.h deleted file mode 100644 index 14e63d9d..00000000 --- a/amarok/src/core/meta/forward_declarations.h +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2013 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROKCORE_META_FORWARD_DECLARATIONS_H -#define AMAROKCORE_META_FORWARD_DECLARATIONS_H - -#include - -#include - -namespace Meta -{ - class Base; - typedef KSharedPtr DataPtr; - typedef QList DataList; - - class Track; - typedef KSharedPtr TrackPtr; - typedef QList TrackList; - - class Artist; - typedef KSharedPtr ArtistPtr; - typedef QList ArtistList; - - class Album; - typedef KSharedPtr AlbumPtr; - typedef QList AlbumList; - - class Genre; - typedef KSharedPtr GenrePtr; - typedef QList GenreList; - - class Composer; - typedef KSharedPtr ComposerPtr; - typedef QList ComposerList; - - class Year; - typedef KSharedPtr YearPtr; - typedef QList YearList; - - class Label; - typedef KSharedPtr
  • "; - contextHtml += ""; - contextHtml += ""; - - // track parsing - for( int i = 0; i < trackItemsList.size(); i++ ) - { - artist = trackItemsList.at( i ).firstChildElement( QLatin1String( "artist" ) ).firstChild().nodeValue(); - trackPrice = trackItemsList.at( i ).firstChildElement( QLatin1String( "price" ) ).firstChild().nodeValue(); - trackTitle = trackItemsList.at( i ).firstChildElement( QLatin1String( "title" ) ).firstChild().nodeValue(); - trackAsin = trackItemsList.at( i ).firstChildElement( QLatin1String( "asin" ) ).firstChild().nodeValue(); - - searchUrl = "amarok://navigate/MP3%20Music%20Store/?filter=" + artist; - playableUrl = "http://www.amazon." + AmazonConfig::instance()->country() + "/gp/dmusic/get_sample_url.html?ASIN=" + trackAsin; - addToCartUrl = "amarok://service-amazonstore?asin=" + trackAsin + "&command=addToCart&name=" + artist + " - " + trackTitle + "&price=" + trackPrice; - - contextHtml += ""; - contextHtml += ""; - contextHtml += ""; - } - - contextHtml += "
    " + i18n( "Artist" ) + "" + i18n( "Track" ) + "
    \""" + artist + "" + trackTitle + " (" + Amazon::prettyPrice( trackPrice ) + ")
    "; - - QFile::remove( tempFileName ); - responseFile.close(); - - emit( info( contextHtml ) ); -} - -#include "moc_AmazonInfoParser.cpp" diff --git a/amarok/src/services/amazon/AmazonInfoParser.h b/amarok/src/services/amazon/AmazonInfoParser.h deleted file mode 100644 index c4344213..00000000 --- a/amarok/src/services/amazon/AmazonInfoParser.h +++ /dev/null @@ -1,47 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Sven Krohlas * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAZONINFOPARSER_H -#define AMAZONINFOPARSER_H - -#include "../InfoParserBase.h" - -#include "AmazonMeta.h" - -#include -#include - -class AmazonInfoParser : public InfoParserBase -{ - Q_OBJECT - -public: - AmazonInfoParser() - : InfoParserBase() {} - - ~AmazonInfoParser() {} - - virtual void getInfo( Meta::ArtistPtr artist ); - virtual void getInfo( Meta::AlbumPtr album ); - virtual void getInfo( Meta::TrackPtr track ); - - void showFrontPage(); - -private slots: - void albumInfoDownloadComplete( KJob *requestJob ); -}; - -#endif // AMAZONINFOPARSER_H diff --git a/amarok/src/services/amazon/AmazonItemTreeModel.cpp b/amarok/src/services/amazon/AmazonItemTreeModel.cpp deleted file mode 100644 index c1db459c..00000000 --- a/amarok/src/services/amazon/AmazonItemTreeModel.cpp +++ /dev/null @@ -1,313 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2011 Sven Krohlas * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "AmazonItemTreeModel.h" - -#include "Amazon.h" -#include "AmazonMeta.h" - -#include "AmarokMimeData.h" - -#include "klocalizedstring.h" -#include - -AmazonItemTreeModel::AmazonItemTreeModel( Collections::AmazonCollection* collection ) : - m_hiddenAlbums( 0 ) -{ - m_collection = collection; - - connect( m_collection, SIGNAL(updated()), this, SLOT(collectionChanged()) ); -} - -int -AmazonItemTreeModel::columnCount( const QModelIndex &parent ) const -{ - Q_UNUSED( parent ); - return 2; // name and price -} - -QVariant -AmazonItemTreeModel::data( const QModelIndex &index, int role ) const -{ - if( !index.isValid() ) - return QVariant(); - - int id; - - if( role == Qt::DisplayRole ) // text - { - if( index.row() < m_collection->albumIDMap().size() - m_hiddenAlbums ) // we have to take data from the album map - { - id = index.row() + 1; // collection IDs start with 1 - - if( index.column() == 0 ) // name - return prettyNameByIndex( index ); - - else if( index.column() == 1 ) // price - { - if( m_collection->albumById( id ) ) - return Amazon::prettyPrice( dynamic_cast( m_collection->albumById( id ).data() )->price() ); - } - } - else // track map - { - if( index.column() == 0 ) // name - return prettyNameByIndex( index ); - - else if( index.column() == 1 ) // price - { - id = index.row() - m_collection->albumIDMap().size() + 1 + m_hiddenAlbums; - - if( m_collection->trackById( id ) ) - return Amazon::prettyPrice( dynamic_cast( m_collection->trackById( id ).data() )->price() ); - } - } - } - else if( role == Qt::DecorationRole ) // icon - { - if( index.row() < m_collection->albumIDMap().size() - m_hiddenAlbums ) // album - { - if( index.column() == 0 ) - return KIcon( "media-optical-amarok" ); - } - else // track - { - if( index.column() == 0 ) - return KIcon( "media-album-track" ); - } - } - else if( role == Qt::ToolTipRole ) - { - // TODO: maybe we could also show the cover here - QString toolTip; - toolTip = "
    " + prettyNameByIndex( index ) + "

    "; - - if( isAlbum( index ) ) - { - id = index.row() + 1; - - Meta::AmazonAlbum* album; - album = dynamic_cast( m_collection->albumById( id ).data() ); - - if( !album ) - return QString(); - - toolTip += i18n( "Artist: " ); - toolTip += m_collection->artistById( album->artistId() )->name(); - toolTip += "
    "; - - toolTip += i18n( "Album: " ); - toolTip += album->name(); - toolTip += "
    "; - - toolTip += i18n( "Price: " ); - toolTip += Amazon::prettyPrice( album->price() ); - } - else // track - { - id = index.row() - m_collection->albumIDMap().size() + 1 + m_hiddenAlbums; - - Meta::AmazonTrack* track; - track = dynamic_cast( m_collection->trackById( id ).data() ); - - if( !track ) - return QString(); - - toolTip += i18n( "Artist: " ); - toolTip += m_collection->artistById( track->artistId() )->name(); - toolTip += "
    "; - - toolTip += i18n( "Album: " ); - toolTip += m_collection->albumById( track->albumId() )->name(); - toolTip += "
    "; - - toolTip += i18n( "Track: " ); - toolTip += track->name(); - toolTip += "
    "; - - toolTip += i18n( "Price: " ); - toolTip += Amazon::prettyPrice( track->price() ); - } - - return toolTip; - } - - return QVariant(); -} - -Qt::ItemFlags -AmazonItemTreeModel::flags( const QModelIndex &index ) const -{ - Q_UNUSED( index ) - return ( Qt::ItemIsDragEnabled | Qt::ItemIsSelectable | Qt::ItemIsEnabled ); -} - -QVariant -AmazonItemTreeModel::headerData( int section, Qt::Orientation orientation, int role ) const -{ - if( orientation == Qt::Horizontal ) // column headers - { - if( role == Qt::DisplayRole ) // text - { - switch( section ) - { - case 0: - return i18n( "Name" ); - break; - case 1: - return i18n( "Price" ); - break; - default: - return QVariant(); // should not happen - } - } - else if( role == Qt::DecorationRole ) //icon - { - // TODO - } - } - - else if( orientation == Qt::Vertical ) // row headers - return QVariant(); - - return QVariant(); -} - -QMimeData* -AmazonItemTreeModel::mimeData( const QModelIndexList &indices ) const -{ - if( indices.isEmpty() ) - return 0; - - Meta::TrackList tracks; - - if( indices[0].row() < m_collection->albumIDMap().size() - m_hiddenAlbums ) // album - { - return new QMimeData; - } - else // track - { - int id = indices[0].row() - m_collection->albumIDMap().size() + 1 + m_hiddenAlbums; - tracks.append( m_collection->trackById( id ) ); - } - - AmarokMimeData *mimeData = new AmarokMimeData(); - mimeData->setTracks( tracks ); - return mimeData; -} - -QStringList -AmazonItemTreeModel::mimeTypes() const -{ - QStringList types; - types << AmarokMimeData::TRACK_MIME; - return types; -} - -int -AmazonItemTreeModel::rowCount( const QModelIndex &parent ) const -{ - Q_UNUSED( parent ); - if( !m_collection ) - return 0; - - return m_collection->albumIDMap().size() + m_collection->trackIDMap().size() - m_hiddenAlbums; -} - -int -AmazonItemTreeModel::idForIndex( const QModelIndex &index ) const -{ - /* Collection-IDs start with 1, model rows with 0. */ - /* Albums and tracks have their own IDs. */ - - int result = -1; - - if( !index.isValid() ) - return result; - - if( isAlbum( index ) ) - result = index.row() + 1; - else // track - result = index.row() - m_collection->albumIDMap().size() + m_hiddenAlbums + 1; - - return result; -} - -bool -AmazonItemTreeModel::isAlbum( const QModelIndex &index ) const -{ - if( index.row() < m_collection->albumIDMap().size() - m_hiddenAlbums ) // album - return true; - else - return false; -} - - -// private - -QString -AmazonItemTreeModel::prettyNameByIndex( const QModelIndex &index ) const -{ - QString prettyName; - int id; - - if( index.row() < m_collection->albumIDMap().size() - m_hiddenAlbums ) // album - { - id = index.row() + 1; // collection IDs start with 1 - - int artistId = dynamic_cast( m_collection->albumById( id ).data() )->artistId(); - prettyName = m_collection->artistById( artistId )->name(); - prettyName = prettyName + " - " + m_collection->albumById( id )->name(); - } - else // track - { - id = index.row() - m_collection->albumIDMap().size() + 1 + m_hiddenAlbums; - - int artistId = dynamic_cast( m_collection->trackById( id ).data() )->artistId(); - prettyName = m_collection->artistById( artistId )->name(); - prettyName = prettyName + " - " + m_collection->trackById( id )->name(); - } - - return prettyName; -} - - -// private slots - -void -AmazonItemTreeModel::collectionChanged() -{ - // the following calculation dramatically changes the model - emit beginResetModel(); - - // remember: collection IDs start with 1, not 0! - int i = 1, result = 0; - - // let's count empty prices - while( i <= m_collection->albumIDMap().size() ) - { - if( ( dynamic_cast( m_collection->albumById( i ).data() )->price() ).isEmpty() ) // no price set - result++; - - i++; - } - - m_hiddenAlbums = result; - - // end of the drama - emit endResetModel(); - emit dataChanged( QModelIndex(), QModelIndex() ); -} diff --git a/amarok/src/services/amazon/AmazonItemTreeModel.h b/amarok/src/services/amazon/AmazonItemTreeModel.h deleted file mode 100644 index bd8b607f..00000000 --- a/amarok/src/services/amazon/AmazonItemTreeModel.h +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2011 Sven Krohlas * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAZONITEMTREEMODEL_H -#define AMAZONITEMTREEMODEL_H - -#include "AmazonCollection.h" - -#include - -class AmazonItemTreeModel : public QAbstractTableModel -{ - Q_OBJECT - -public: - AmazonItemTreeModel( Collections::AmazonCollection* collection ); - - // Reimplemented from QAbstractItemModel - virtual int columnCount( const QModelIndex &parent ) const; - virtual QVariant data( const QModelIndex &index, int role ) const; - virtual Qt::ItemFlags flags( const QModelIndex &index ) const; - virtual QVariant headerData( int section, Qt::Orientation orientation, int role ) const; - virtual QMimeData* mimeData( const QModelIndexList &indices ) const; - virtual QStringList mimeTypes() const; - virtual int rowCount( const QModelIndex &parent ) const; - - /** - * Given a QModelIndex this returns the ID the item has in the collection. - * Use isAlbum() to check weather it's an album or a track. - * @param index the QModelIndex to check. - * @return the ID the item can be found in the collection, -1 if index is invalid. - */ - int idForIndex( const QModelIndex &index ) const; - - /** - * Checks if the item at the specified index is an album or not. - * Use idForIndex() to get the ID of the item. - * @param index the QModelIndex to check. - * @return true if album, false if track. - */ - bool isAlbum( const QModelIndex &index ) const; - -private: - Collections::AmazonCollection* m_collection; - int m_hiddenAlbums; - - /** - * Helper function. Returns the pretty name for the item at the specified index. - * @param index the QModelIndex to generate the pretty name from. - * @return pretty name of the item at the specified index. - */ - QString prettyNameByIndex( const QModelIndex &index ) const; - -private slots: - void collectionChanged(); -}; - -#endif // AMAZONITEMTREEMODEL_H diff --git a/amarok/src/services/amazon/AmazonItemTreeView.cpp b/amarok/src/services/amazon/AmazonItemTreeView.cpp deleted file mode 100644 index 27069e49..00000000 --- a/amarok/src/services/amazon/AmazonItemTreeView.cpp +++ /dev/null @@ -1,285 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2011 Sven Krohlas * - * Copyright (c) 2007 Alexandre Pereira de Oliveira * - * Copyright (c) 2007 Ian Monroe * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "AmazonItemTreeModel.h" -#include "AmazonItemTreeView.h" - -#include "AmarokMimeData.h" - -#include "context/ContextView.h" -#include "core/support/Debug.h" -#include "PopupDropperFactory.h" -#include "context/popupdropper/libpud/PopupDropper.h" -#include "context/popupdropper/libpud/PopupDropperItem.h" - -#include -#include - -#include - -#include -#include - -AmazonItemTreeView::AmazonItemTreeView( QWidget *parent ) : - Amarok::PrettyTreeView( parent ) - , m_pd( 0 ) -{ - setDragDropMode( QAbstractItemView::DragOnly ); -} - - -void -AmazonItemTreeView::setModel( QAbstractItemModel *model ) -{ - Amarok::PrettyTreeView::setModel( model ); - header()->setStretchLastSection( false ); -} - - -// protected - -void -AmazonItemTreeView::contextMenuEvent( QContextMenuEvent *event ) -{ - QModelIndex index = indexAt( event->pos() ); - - if( !index.isValid() ) - { - event->accept(); - return; - } - - KMenu menu( this ); - QList< QAction * > actions; - - AmazonItemTreeModel *amazonModel; - amazonModel = dynamic_cast( model() ); - - if( !amazonModel ) - { - menu.exec( actions, event->globalPos() ); - event->accept(); - return; - } - - if( amazonModel->isAlbum( index ) ) - actions.append( createDetailsAction() ); - else // track - { - actions.append( createAddToPlaylistAction() ); // this should be the first action - actions.append( createSearchForAlbumAction() ); - } - - actions.append( createAddToCartAction() ); - actions.append( createDirectCheckoutAction() ); - - menu.exec( actions, event->globalPos() ); - event->accept(); -} - -void -AmazonItemTreeView::mouseDoubleClickEvent( QMouseEvent *event ) -{ - // for tracks: append them to the playlist - // for albums: query for the album - if( event->button() == Qt::MidButton ) - { - event->accept(); - return; - } - - QModelIndex index = indexAt( event->pos() ); - if( index.isValid() ) - { - event->accept(); - emit itemDoubleClicked( index ); - } - -} - -void -AmazonItemTreeView::mouseReleaseEvent( QMouseEvent *event ) -{ - if( m_pd ) - { - m_pd->hide(); - connect( m_pd, SIGNAL(fadeHideFinished()), m_pd, SLOT(deleteLater()) ); - m_pd = 0; - } - - Amarok::PrettyTreeView::mouseReleaseEvent( event ); -} - -void -AmazonItemTreeView::startDrag( Qt::DropActions supportedActions ) -{ - DEBUG_BLOCK - QModelIndexList indices = selectedIndexes(); - if( indices.isEmpty() ) - return; - - if( !m_pd ) - m_pd = The::popupDropperFactory()->createPopupDropper( Context::ContextView::self() ); - - if( m_pd && m_pd->isHidden() ) - { - AmazonItemTreeModel *amazonModel; - amazonModel = dynamic_cast( model() ); - - if( !amazonModel ) - return; - - if( amazonModel->isAlbum( indices.at( 0 ) ) ) - { - QAction *detailsAction = createDetailsAction(); - detailsAction->setProperty( "popupdropper_svg_id", "loading" ); - m_pd->addItem( The::popupDropperFactory()->createItem( detailsAction ) ); - } - else // track - { - QAction *addToPlaylistAction = createAddToPlaylistAction(); - addToPlaylistAction->setProperty( "popupdropper_svg_id", "append" ); - m_pd->addItem( The::popupDropperFactory()->createItem( addToPlaylistAction ) ); - - QAction *searchForAlbumAction = createSearchForAlbumAction(); - addToPlaylistAction->setProperty( "popupdropper_svg_id", "collection" ); - m_pd->addItem( The::popupDropperFactory()->createItem( searchForAlbumAction ) ); - } - - QAction *addToCartAction = createAddToCartAction(); - addToCartAction->setProperty( "popupdropper_svg_id", "cart_in" ); - m_pd->addItem( The::popupDropperFactory()->createItem( addToCartAction ) ); - - QAction *directCheckoutAction = createDirectCheckoutAction(); - directCheckoutAction->setProperty( "popupdropper_svg_id", "download" ); - m_pd->addItem( The::popupDropperFactory()->createItem( directCheckoutAction ) ); - - m_pd->show(); - } - - QTreeView::startDrag( supportedActions ); - - if( m_pd ) - { - connect( m_pd, SIGNAL(fadeHideFinished()), m_pd, SLOT(clear()) ); - m_pd->hide(); - } -} - - -// protected slots - -void -AmazonItemTreeView::dataChanged( const QModelIndex &topLeft, const QModelIndex &bottomRight ) -{ - Q_UNUSED( topLeft ) - Q_UNUSED( bottomRight ) - header()->setResizeMode( 1, QHeaderView::ResizeToContents ); - header()->setResizeMode( 0, QHeaderView::Stretch ); -} - -void -AmazonItemTreeView::selectionChanged( const QItemSelection &selected, const QItemSelection &deselected ) -{ - QTreeView::selectionChanged( selected, deselected ); // to avoid repainting problems - QModelIndexList indexes = selected.indexes(); - - if( indexes.count() < 1 ) - return; - - emit( itemSelected( indexes[0] ) ); // emit the QModelIndex -} - -void -AmazonItemTreeView::itemActivatedAction() -{ - QModelIndexList indexes = selectedIndexes(); - - if( indexes.count() < 1 ) - return; - - emit itemDoubleClicked( indexes[0] ); // same behaviour as double click -} - -void -AmazonItemTreeView::searchForAlbumAction() -{ - QModelIndexList indexes = selectedIndexes(); - - if( indexes.count() < 1 ) - return; - - // make sure we are working on a track - AmazonItemTreeModel *amazonModel; - amazonModel = dynamic_cast( model() ); - - if( !amazonModel ) - return; - - if( amazonModel->isAlbum( indexes[0] ) ) - return; - - emit searchForAlbum( indexes[0] ); -} - -// private - -QAction* -AmazonItemTreeView::createAddToCartAction() -{ - QAction *addToCartAction = new QAction( KIcon( "amarok_cart_add" ), QString( i18n( "Add to Cart" ) ), this ); - connect( addToCartAction, SIGNAL(triggered()), this, SIGNAL(addToCart()) ); - - return addToCartAction; -} - -QAction* -AmazonItemTreeView::createAddToPlaylistAction() -{ - QAction *addToPlaylistAction = new QAction( KIcon( "media-track-add-amarok" ), QString( i18n( "Add Preview to Playlist" ) ), this ); - connect( addToPlaylistAction, SIGNAL(triggered()), this, SLOT(itemActivatedAction()) ); - - return addToPlaylistAction; -} - -QAction* -AmazonItemTreeView::createDetailsAction() -{ - QAction *getDetailsAction = new QAction( QIcon( KStandardDirs::locate( "data", "amarok/images/loading1.png" ) ), QString( i18n( "Load Details..." ) ), this ); - connect( getDetailsAction, SIGNAL(triggered()), this, SLOT(itemActivatedAction()) ); - - return getDetailsAction; -} - -QAction* -AmazonItemTreeView::createDirectCheckoutAction() -{ - QAction *directCheckoutAction = new QAction( KIcon( "download-amarok" ), QString( i18n( "Direct Checkout" ) ), this ); - connect( directCheckoutAction, SIGNAL(triggered()), this, SIGNAL(directCheckout()) ); - - return directCheckoutAction; -} - -QAction* -AmazonItemTreeView::createSearchForAlbumAction() -{ - QAction *searchForAlbumAction = new QAction( KIcon( "media-optical-amarok" ), QString( i18n( "Search for Album..." ) ), this ); - connect( searchForAlbumAction, SIGNAL(triggered()), this, SLOT(searchForAlbumAction()) ); - - return searchForAlbumAction; -} diff --git a/amarok/src/services/amazon/AmazonItemTreeView.h b/amarok/src/services/amazon/AmazonItemTreeView.h deleted file mode 100644 index d1f01fd8..00000000 --- a/amarok/src/services/amazon/AmazonItemTreeView.h +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2011 Sven Krohlas * - * Copyright (c) 2007 Alexandre Pereira de Oliveira * - * Copyright (c) 2007 Ian Monroe * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAZONITEMTREEVIEW_H -#define AMAZONITEMTREEVIEW_H - -#include "widgets/PrettyTreeView.h" - -#include -#include -#include -#include - -class PopupDropper; - -class AmazonItemTreeView : public Amarok::PrettyTreeView -{ - Q_OBJECT - -public: - AmazonItemTreeView( QWidget *parent = 0 ); - - // Reimplemented from QTreeView - virtual void setModel( QAbstractItemModel *model ); - -protected: - // Reimplemented from QAbstractScrollArea - virtual void contextMenuEvent( QContextMenuEvent *event ); - - // Reimplemented from QAbstractItemView - virtual void startDrag( Qt::DropActions supportedActions ); - - // Reimplemented from QTreeView - virtual void mouseDoubleClickEvent( QMouseEvent *event ); - virtual void mouseReleaseEvent( QMouseEvent *event ); - -protected slots: - // Reimplemented from QTreeView - virtual void dataChanged( const QModelIndex &topLeft, const QModelIndex &bottomRight ); - virtual void selectionChanged( const QItemSelection &selected, const QItemSelection &deselected ); - - void itemActivatedAction(); - void searchForAlbumAction(); - -private: - PopupDropper *m_pd; - - QAction* createAddToCartAction(); - QAction* createAddToPlaylistAction(); - QAction* createDetailsAction(); - QAction* createDirectCheckoutAction(); - QAction* createSearchForAlbumAction(); - -signals: - void addToCart(); - void directCheckout(); - void itemDoubleClicked( QModelIndex index ); - void itemSelected( QModelIndex index ); - void searchForAlbum( QModelIndex index ); -}; - -#endif // AMAZONITEMTREEVIEW_H diff --git a/amarok/src/services/amazon/AmazonMeta.cpp b/amarok/src/services/amazon/AmazonMeta.cpp deleted file mode 100644 index f450d334..00000000 --- a/amarok/src/services/amazon/AmazonMeta.cpp +++ /dev/null @@ -1,182 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2011 Sven Krohlas * - * The Amazon store in based upon the Magnatune store in Amarok, * - * Copyright (c) 2006,2007 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "AmazonMeta.h" - -#include -#include "klocalizedstring.h" - -using namespace Meta; - -/////////////////////////////////////////////////////////////////////////////// -// class AmazonAlbum -/////////////////////////////////////////////////////////////////////////////// - -/* - resultRow[0]: id - resultRow[1]: name - resultRow[2]: description - resultRow[3]: artistId - resultRow[4]: price - resultRow[5]: coverUrl - resultRow[6]: ASIN -*/ -Meta::AmazonAlbum::AmazonAlbum( const QStringList & resultRow ) - : ServiceAlbumWithCover( resultRow ) -{ - setPrice( resultRow[4] ); - setCoverUrl( resultRow[5] ); - setAsin( resultRow[6] ); -} - -void -Meta::AmazonAlbum::setCoverUrl( const QString & coverUrl ) -{ - m_coverUrl = coverUrl; -} - -QString -Meta::AmazonAlbum::coverUrl() const -{ - return m_coverUrl; -} - - -/////////////////////////////////////////////////////////////////////////////// -// class AmazonArtist -/////////////////////////////////////////////////////////////////////////////// - -/* - resultRow[0]: id - resultRow[1]: name - resultRow[2]: description -*/ - -Meta::AmazonArtist::AmazonArtist( const QStringList & resultRow ) - : ServiceArtist( resultRow ) -{ -} - - -/////////////////////////////////////////////////////////////////////////////// -// class AmazonItem -/////////////////////////////////////////////////////////////////////////////// - -void -Meta::AmazonItem::setAsin( QString asin ) -{ - m_asin = asin; -} - -QString -Meta::AmazonItem::asin() const -{ - return m_asin; -} - -void -Meta::AmazonItem::setPrice( const QString price ) -{ - m_price = price; -} - -QString -Meta::AmazonItem::price() const -{ - return m_price; -} - - -/////////////////////////////////////////////////////////////////////////////// -// class AmazonTrack -/////////////////////////////////////////////////////////////////////////////// - -/* - resultRow[0]: id - resultRow[1]: name - resultRow[2]: trackNumber - resultRow[3]: length - resultRow[4]: playableUrl - resultRow[5]: albumId - resultRow[6]: artistId - resultRow[7]: price - resultRow[8]: asin -*/ - -Meta::AmazonTrack::AmazonTrack( const QStringList & resultRow ) - : ServiceTrack( resultRow ) -{ - setPrice( resultRow[7] ); - setAsin( resultRow[8] ); -} - -QPixmap -Meta::AmazonTrack::emblem() -{ - return QPixmap( KStandardDirs::locate( "data", "amarok/images/emblem-amazon.png" ) ); -} - -QString -Meta::AmazonTrack::sourceDescription() -{ - return i18n( "Snippet taken from the Amazon MP3 store" ); -} - -QString -Meta::AmazonTrack::sourceName() -{ - return "Amazon"; -} - - -/////////////////////////////////////////////////////////////////////////////// -// class AmazonMetaFactory -/////////////////////////////////////////////////////////////////////////////// - -AmazonMetaFactory::AmazonMetaFactory( const QString &dbPrefix ) - : ServiceMetaFactory( dbPrefix ) -{} - - -TrackPtr -AmazonMetaFactory::createTrack( const QStringList &rows ) -{ - AmazonTrack* track = new AmazonTrack( rows ); - - return TrackPtr( track ); -} - - -AlbumPtr -AmazonMetaFactory::createAlbum( const QStringList &rows ) -{ - AmazonAlbum* album = new AmazonAlbum( rows ); - album->setSourceName( "Amazon" ); - - return AlbumPtr( album ); -} - - -ArtistPtr -AmazonMetaFactory::createArtist( const QStringList &rows ) -{ - AmazonArtist* artist = new AmazonArtist( rows ); - artist->setSourceName( "Amazon" ); - - return ArtistPtr( artist ); -} diff --git a/amarok/src/services/amazon/AmazonMeta.h b/amarok/src/services/amazon/AmazonMeta.h deleted file mode 100644 index 2627f955..00000000 --- a/amarok/src/services/amazon/AmazonMeta.h +++ /dev/null @@ -1,141 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2011 Sven Krohlas * - * The Amazon store in based upon the Magnatune store in Amarok, * - * Copyright (c) 2006,2007 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAZONMETA_H -#define AMAZONMETA_H - -#include "../ServiceMetaBase.h" -#include "../ServiceAlbumCoverDownloader.h" - -#include -#include -#include - -#include - -class AmazonStore; - -namespace Meta -{ - -/////////////////////////////////////////////////////////////////////////////// -// class AmazonItem -/////////////////////////////////////////////////////////////////////////////// - -/* Amazon items contain all the Amazon specific stuff and are the base class for everything that - can be added to the amazon shopping cart. - * ASIN: Amazon Standard Identification Number, see - https://secure.wikimedia.org/wikipedia/en/wiki/Amazon_Standard_Identification_Number - * Price: price of the item, in cents (or whatever the smallest unit of the currency is called) - */ - -class AmazonItem : public QObject -{ - Q_OBJECT - -public: - virtual void setAsin( const QString asin ); - virtual QString asin() const; - - virtual void setPrice( const QString price ); - virtual QString price() const; - - virtual bool isBookmarkable() const { return true; } - virtual QString collectionName() const { return "Amazon"; } - -private: - QAction* m_addToCartAction; - QString m_asin; - QString m_price; -}; - -/////////////////////////////////////////////////////////////////////////////// -// class AmazonAlbum -/////////////////////////////////////////////////////////////////////////////// - -class AmazonAlbum : public ServiceAlbumWithCover, public AmazonItem -{ -public: - AmazonAlbum( const QStringList & resultRow ); - - virtual void setCoverUrl( const QString &coverUrl ); - virtual QString coverUrl() const; - - virtual QString downloadPrefix() const { return "amazon"; } - - virtual KUrl imageLocation( int size = 1 ) { Q_UNUSED( size ); return KUrl( coverUrl() ); } - - virtual bool isBookmarkable() const { return true; } - virtual QString collectionName() const { return "Amazon"; } - virtual bool simpleFiltering() const { return false; } - -private: - QString m_coverUrl; -}; - -/////////////////////////////////////////////////////////////////////////////// -// class AmazonArtist -/////////////////////////////////////////////////////////////////////////////// - -class AmazonArtist : public ServiceArtist -{ -public: - AmazonArtist( const QStringList & resultRow ); - - virtual bool isBookmarkable() const { return true; } - virtual QString collectionName() const { return "Amazon"; } - virtual bool simpleFiltering() const { return false; } -}; - - -/////////////////////////////////////////////////////////////////////////////// -// class AmazonTrack -/////////////////////////////////////////////////////////////////////////////// - -class AmazonTrack : public ServiceTrack, public AmazonItem -{ -public: - AmazonTrack( const QStringList & resultRow ); - - virtual QPixmap emblem(); - virtual QString sourceDescription(); - virtual QString sourceName(); - - virtual bool isBookmarkable() const { return true; } - virtual QString collectionName() const { return "Amazon"; } - virtual bool simpleFiltering() const { return false; } -}; - -} // namespace Meta - -/////////////////////////////////////////////////////////////////////////////// -// class AmazonMetaFactory -/////////////////////////////////////////////////////////////////////////////// - -class AmazonMetaFactory : public ServiceMetaFactory -{ - public: - AmazonMetaFactory( const QString &dbPrefix ); - virtual ~AmazonMetaFactory() {} - - virtual Meta::TrackPtr createTrack( const QStringList &rows ); - virtual Meta::AlbumPtr createAlbum( const QStringList &rows ); - virtual Meta::ArtistPtr createArtist( const QStringList &rows ); -}; - -#endif // AMAZONMETA_H diff --git a/amarok/src/services/amazon/AmazonParser.cpp b/amarok/src/services/amazon/AmazonParser.cpp deleted file mode 100644 index 5fde6b27..00000000 --- a/amarok/src/services/amazon/AmazonParser.cpp +++ /dev/null @@ -1,210 +0,0 @@ - /**************************************************************************************** - * Copyright (c) 2011 Sven Krohlas * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "AmazonParser.h" - -#include "AmazonConfig.h" - -#include "core/support/Debug.h" - -#include - -AmazonParser::AmazonParser( QString tempFileName, Collections::AmazonCollection* collection, AmazonMetaFactory* factory ) - : ThreadWeaver::Job() -{ - m_tempFileName = tempFileName; - m_collection = collection; - m_factory = factory; - - m_success = true; -} - -AmazonParser::~AmazonParser() -{ -} - -bool -AmazonParser::success() const -{ - return m_success; -} - - -/* protected */ - -void -AmazonParser::run() -{ - m_responseDocument = new QDomDocument; - - QFile responseFile( m_tempFileName ); - if( !responseFile.open( QIODevice::ReadOnly ) ) - { - warning() << "Failed to open temp file" << m_tempFileName; - emit( failed( this ) ); - QFile::remove( m_tempFileName ); - return; - } - - QString errorMsg; - int errorLine; - int errorColumn; - - if( !m_responseDocument->setContent( &responseFile, false, &errorMsg, &errorLine, &errorColumn ) ) // parse error - { - debug() << m_responseDocument->toString(); - debug() << "Parse ERROR"; - debug() << "Message:" << errorMsg; - debug() << "Line:" << errorLine; - debug() << "Column:" << errorColumn; - m_success = false; - // let's keep the temp file in case of an error - //QFile::remove( m_tempFileName ); - return; - } - - QString compilation; - QString trackAsin, albumAsin, albumPrice; - QString artist, albumTitle, songTitle; - QString price, imgUrl, playableUrl; - QString artistID, albumID, trackID; - QStringList results; - QString description( "TODO: I am a description. Where do I show up?" ); - - QDomNodeList albumItemsList = m_responseDocument->documentElement().firstChildElement( QLatin1String( "albums" ) ).elementsByTagName( QString( "item" ) ); - QDomNodeList trackItemsList = m_responseDocument->documentElement().firstChildElement( QLatin1String( "tracks" ) ).elementsByTagName( QString( "item" ) ); - - m_collection->acquireWriteLock(); // locks for reading AND writing - // we have a new results page, so we can clear the old one - m_collection->clear(); - - // album parsing - for( int i = 0; i < albumItemsList.size(); i++ ) - { - albumAsin = albumItemsList.at( i ).firstChildElement( QLatin1String( "asin" ) ).firstChild().nodeValue(); - artist = albumItemsList.at( i ).firstChildElement( QLatin1String( "artist" ) ).firstChild().nodeValue(); - albumTitle = albumItemsList.at( i ).firstChildElement( QLatin1String( "album" ) ).firstChild().nodeValue(); - albumPrice = albumItemsList.at( i ).firstChildElement( QLatin1String( "price" ) ).firstChild().nodeValue(); - compilation = albumItemsList.at( i ).firstChildElement( QLatin1String( "iscompilation" ) ).firstChild().nodeValue(); - imgUrl = albumItemsList.at( i ).firstChildElement( QLatin1String( "img" ) ).firstChild().nodeValue(); - - artistID.setNum( addArtistToCollection( artist, description ) ); - addAlbumToCollection( albumTitle, description, artistID, albumPrice, imgUrl, albumAsin, compilation == QLatin1String( "true" ) ); - } - - // track parsing - albumPrice.clear(); // maybe we get that with tracks in future API revisions, but not now - - for( int i = 0; i < trackItemsList.size(); i++ ) - { - albumAsin = trackItemsList.at( i ).firstChildElement( QLatin1String( "albumasin" ) ).firstChild().nodeValue(); - artist = trackItemsList.at( i ).firstChildElement( QLatin1String( "artist" ) ).firstChild().nodeValue(); - albumTitle = trackItemsList.at( i ).firstChildElement( QLatin1String( "album" ) ).firstChild().nodeValue(); - compilation = trackItemsList.at( i ).firstChildElement( QLatin1String( "iscompilation" ) ).firstChild().nodeValue(); - imgUrl = trackItemsList.at( i ).firstChildElement( QLatin1String( "img" ) ).firstChild().nodeValue(); - price = trackItemsList.at( i ).firstChildElement( QLatin1String( "price" ) ).firstChild().nodeValue(); - songTitle = trackItemsList.at( i ).firstChildElement( QLatin1String( "title" ) ).firstChild().nodeValue(); - trackAsin = trackItemsList.at( i ).firstChildElement( QLatin1String( "asin" ) ).firstChild().nodeValue(); - - // first we make sure the artist is in the collection and get its id - artistID.setNum( addArtistToCollection( artist, description ) ); - - // same for the album - albumID.setNum( addAlbumToCollection( albumTitle, description, artistID, albumPrice, imgUrl, albumAsin, compilation == QLatin1String( "true" ) ) ); - - // now we can be sure that artist and album of this track are in the collection and we have their IDs - // id, name, tracknumber, length, Url, albumId, artistID - trackID.setNum( m_collection->trackIDMap().size() + 1 ); - playableUrl = "http://www.amazon." + AmazonConfig::instance()->country() + "/gp/dmusic/get_sample_url.html?ASIN=" + trackAsin; - results << trackID << songTitle << "1" << "30000" << playableUrl << albumID << artistID << price << trackAsin; - - Meta::TrackPtr trackPtr = m_factory->createTrack( results ); - - if( trackPtr ) - { - dynamic_cast( trackPtr.data() )->setAlbumPtr( m_collection->albumById( albumID.toInt() ) ); - dynamic_cast( trackPtr.data() )->setArtist( m_collection->artistById( artistID.toInt() ) ); - } - - m_collection->addTrack( trackPtr ); - m_collection->trackIDMap().insert( trackAsin, trackID.toInt() ); - results.clear(); - } - - m_collection->releaseLock(); - m_collection->emitUpdated(); - QFile::remove( m_tempFileName ); - responseFile.close(); - // ThreadWeaver::Job automatically emits the done( this ) signal -} - - -/* private */ - -int -AmazonParser::addArtistToCollection( const QString &artistName, const QString &description ) -{ - QStringList results; - QString artistID; - - if( !m_collection->artistIDMap().contains( artistName ) ) - { - artistID.setNum( m_collection->artistIDMap().size() + 1 ); - results << artistID << artistName << description; - m_collection->addArtist( m_factory->createArtist( results ) ); - m_collection->artistIDMap().insert( artistName, artistID.toInt() ); - } - - // return artist ID - return m_collection->artistIDMap().value( artistName ); -} - -int -AmazonParser::addAlbumToCollection( const QString &albumTitle, const QString &description, const QString &artistID, const QString &price, const QString &imgUrl, const QString &albumAsin, const bool isCompilation ) -{ - QStringList results; - QString albumID; - - if( !m_collection->albumIDMap().contains( albumAsin ) ) // we have a new album here - { - // id, name, description, artistID - albumID.setNum( m_collection->albumIDMap().size() + 1 ); - results << albumID << albumTitle << description << artistID << price << imgUrl << albumAsin; - - Meta::AlbumPtr newAlbum = m_factory->createAlbum( results ); - newAlbum->setCompilation( isCompilation ); - m_collection->addAlbum( newAlbum ); - m_collection->albumIDMap().insert( albumAsin, albumID.toInt() ); - } - else // album is known, but we might need to update it - { - int id; - id = m_collection->albumIDMap().value( albumAsin ); - - if( !price.isEmpty() ) - { - dynamic_cast( m_collection->albumById( id ).data() )->setPrice( price ); - } - - if( !imgUrl.isEmpty() ) - { - dynamic_cast( m_collection->albumById( id ).data() )->setCoverUrl( imgUrl ); - } - } - - // return album ID - return m_collection->albumIDMap().value( albumAsin ); -} diff --git a/amarok/src/services/amazon/AmazonParser.h b/amarok/src/services/amazon/AmazonParser.h deleted file mode 100644 index 954611b8..00000000 --- a/amarok/src/services/amazon/AmazonParser.h +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2011 Sven Krohlas * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAZONPARSER_H -#define AMAZONPARSER_H - -#include "AmazonCollection.h" -#include "AmazonMeta.h" - -#include -#include - -#include -#include - -#include - - -class AmazonParser : public ThreadWeaver::Job -{ -public: - AmazonParser( QString tempFileName, Collections::AmazonCollection* collection, AmazonMetaFactory* factory ); - ~AmazonParser(); - - // Reimplemented from ThreadWeaver::Job. - // The parser can fail e.g. for invalid replies, network failures, etc. - virtual bool success() const; - -protected: - virtual void run(); - - Collections::AmazonCollection* m_collection; - QString m_tempFileName; - QDomDocument *m_responseDocument; - AmazonMetaFactory *m_factory; - bool m_success; - -private: - /** - * Adds an artist to the collection if it does not yet exist. In any case it returns the ID of the artist. - * @param artist name of the artist to add. - * @param description description of the artist to add. - */ - int addArtistToCollection( const QString &artist, const QString &description ); - - /** - * Adds an album to the collection if it does not yet exist. In any case it returns the ID of the album. - * @param albumTitle name of the album to add. - * @param descritpion description of the album to add. - * @param artistID ID of the artist this album belongs to. - * @param price price of the album. - * @param imgUrl url of a cover image. - * @param albumAsin the ASIN for this album in the Amazon store. - */ - int addAlbumToCollection( const QString &albumTitle, const QString &description, const QString &artistID, const QString &price, const QString &imgUrl, const QString &albumAsin, const bool isCompilation ); -}; - -#endif // AMAZONPARSER_H diff --git a/amarok/src/services/amazon/AmazonSettingsModule.cpp b/amarok/src/services/amazon/AmazonSettingsModule.cpp deleted file mode 100644 index de1f6f43..00000000 --- a/amarok/src/services/amazon/AmazonSettingsModule.cpp +++ /dev/null @@ -1,175 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2011 Sven Krohlas * - * The Amazon store in based upon the Magnatune store in Amarok, * - * Copyright (c) 2006,2007 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "AmazonSettingsModule.h" - -#include "AmazonCollection.h" -#include "AmazonConfig.h" -#include "AmazonMeta.h" - -#include "ui_AmazonConfigWidget.h" - -#include - -#include - -K_PLUGIN_FACTORY( AmazonSettingsFactory, registerPlugin(); ) -K_EXPORT_PLUGIN( AmazonSettingsFactory( "kcm_amarok_service_amazonstore" ) ) - -AmazonSettingsModule::AmazonSettingsModule( QWidget *parent, const QVariantList &args ) - : KCModule( AmazonSettingsFactory::componentData(), parent, args ) -{ - m_configDialog = new Ui::AmazonConfigWidget; - m_configDialog->setupUi( this ); - - connect( m_configDialog->countrySelectionComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(settingsChanged()) ); -} - -AmazonSettingsModule::~AmazonSettingsModule() -{ - delete m_configDialog; - - // TODO: clear cart and collection, if the settings have changed -} - -void -AmazonSettingsModule::save() -{ - switch( m_configDialog->countrySelectionComboBox->currentIndex() ) - { - case AMAZON_COM: - AmazonConfig::instance()->setCountry( QLatin1String( "com" ) ); - break; - - case AMAZON_DE: - AmazonConfig::instance()->setCountry( QLatin1String( "de" ) ); - break; - - case AMAZON_ES: - AmazonConfig::instance()->setCountry( QLatin1String( "es" ) ); - break; - - case AMAZON_FR: - AmazonConfig::instance()->setCountry( QLatin1String( "fr" ) ); - break; - - case AMAZON_IT: - AmazonConfig::instance()->setCountry( QLatin1String( "it" ) ); - break; - - case AMAZON_JP: - AmazonConfig::instance()->setCountry( QLatin1String( "co.jp" ) ); - break; - - case AMAZON_UK: - AmazonConfig::instance()->setCountry( QLatin1String( "co.uk" ) ); - break; - - case AMAZON_NONE: - AmazonConfig::instance()->setCountry( QLatin1String( "none" ) ); - break; - - default: - break; - } -} - -void -AmazonSettingsModule::load() -{ - int index = -1; - QString text = AmazonConfig::instance()->country(); - - if ( text == QLatin1String( "co.jp" ) ) - index = AMAZON_JP; - else if ( text == QLatin1String( "co.uk" ) ) - index = AMAZON_UK; - else if ( text == QLatin1String( "com" ) ) - index = AMAZON_COM; - else if ( text == QLatin1String( "de" ) ) - index = AMAZON_DE; - else if ( text == QLatin1String( "es" ) ) - index = AMAZON_ES; - else if( text == QLatin1String( "fr" ) ) - index = AMAZON_FR; - else if ( text == QLatin1String( "it" ) ) - index = AMAZON_IT; - else if ( text == QLatin1String( "none" ) ) - index = AMAZON_NONE; - - if( index != -1 ) - m_configDialog->countrySelectionComboBox->setCurrentIndex( index ); - else - { - defaults(); - /* - * The following line is my entry to the "Ugliest Hack of the Year" contest. - * - * load() is being called during initialization of the KCModule. In that phase - * the connections to react to changes in the widget seem not yet to be set up. - * - * As a result, when - * 1. we guess the location and propose it in the widget - * 2. the user clicks OK without doing anything else - * nothing gets saved, as the change in the widget has been done during init - * and the changed( true ) signal is consequently being lost. - * - * Workaround: - */ - QTimer::singleShot( 200, this, SLOT(settingsChanged()) ); - - /* - * I'm going to burn in hell for that one, am I? :-/ - */ - } -} - -void -AmazonSettingsModule::defaults() -{ - int index = -1; - - // try to guess - KLocale locale( "amarok" ); - QString guess = locale.country(); - - if( guess == QLatin1String( "fr" ) ) - index = AMAZON_FR; - else if ( guess == QLatin1String( "de" ) || guess == QLatin1String( "at" ) || guess == QLatin1String( "ch" ) ) - index = AMAZON_DE; - else if ( guess == QLatin1String( "es" ) ) - index = AMAZON_ES; - else if ( guess == QLatin1String( "it" ) ) - index = AMAZON_IT; - else if ( guess == QLatin1String( "jp" ) ) - index = AMAZON_JP; - else if ( guess == QLatin1String( "gb" ) ) - index = AMAZON_UK; - else if ( guess == QLatin1String( "us" ) ) - index = AMAZON_COM; - else - index = AMAZON_NONE; - - m_configDialog->countrySelectionComboBox->setCurrentIndex( index ); -} - -void -AmazonSettingsModule::settingsChanged() -{ - emit changed( true ); -} diff --git a/amarok/src/services/amazon/AmazonSettingsModule.h b/amarok/src/services/amazon/AmazonSettingsModule.h deleted file mode 100644 index e03f7dcf..00000000 --- a/amarok/src/services/amazon/AmazonSettingsModule.h +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2011 Sven Krohlas * - * The Amazon store in based upon the Magnatune store in Amarok, * - * Copyright (c) 2006,2007 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAZONSETTINGSMODULE_H -#define AMAZONSETTINGSMODULE_H - -#include - -namespace Ui { class AmazonConfigWidget; } - - -/** - * Represents the position of the different Amazon locales in the AmazonConfigWidget. - */ - -enum Location -{ - AMAZON_FR = 0, - AMAZON_DE, - AMAZON_JP, - AMAZON_UK, - AMAZON_COM, - AMAZON_IT, - AMAZON_ES, - AMAZON_NONE // user explicitly doesn't want to set a country -}; - -/** -A KCM module to configure the Amazon service - - @author Sven Krohlas -*/ -class AmazonSettingsModule : public KCModule -{ - Q_OBJECT - -public: - explicit AmazonSettingsModule( QWidget *parent = 0, const QVariantList &args = QVariantList() ); - ~AmazonSettingsModule(); - - virtual void save(); - virtual void load(); - virtual void defaults(); - -private slots: - void settingsChanged(); - -private: - Ui::AmazonConfigWidget *m_configDialog; -}; - -#endif // AMAZONSETTINGSMODULE_H diff --git a/amarok/src/services/amazon/AmazonShoppingCart.cpp b/amarok/src/services/amazon/AmazonShoppingCart.cpp deleted file mode 100644 index ef05058c..00000000 --- a/amarok/src/services/amazon/AmazonShoppingCart.cpp +++ /dev/null @@ -1,132 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2011 Sven Krohlas * - * The Amazon store in based upon the Magnatune store in Amarok, * - * Copyright (c) 2006,2007 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "AmazonShoppingCart.h" - -#include "Amazon.h" -#include "AmazonConfig.h" - -#include "core/interfaces/Logger.h" -#include "core/support/Components.h" - -AmazonShoppingCart* AmazonShoppingCart::m_instance = 0; - -AmazonShoppingCart* AmazonShoppingCart::instance() -{ - if( !m_instance ) - m_instance = new AmazonShoppingCart(); - - return m_instance; -} - -void -AmazonShoppingCart::destroy() -{ - if( m_instance ) - { - delete m_instance; - m_instance = 0; - } -} - -AmazonShoppingCart::~AmazonShoppingCart() -{ -} - -AmazonShoppingCart::AmazonShoppingCart() -{ - m_price = 0; -} - -void -AmazonShoppingCart::add( QString asin, QString price, QString name ) -{ - AmazonShoppingCartItem item( asin, price, name ); - m_price = m_price + price.toInt(); - insert( size(), item ); - Amarok::Components::logger()->longMessage( i18n( "MP3 Music Store

    %1 has been added to your shopping cart.", name ) ); -} - -void -AmazonShoppingCart::clear() -{ - QList::clear(); - m_price = 0; -} - -QStringList -AmazonShoppingCart::stringList() -{ - QStringList result; - - for( int i = 0; i < size(); i++ ) - { - result.append( at( i ).prettyName() + " (" + Amazon::prettyPrice( at( i ).price() ) + ')' ); - } - - return result; -} - -QString -AmazonShoppingCart::price() -{ - QString price; - return price.setNum( m_price ); -} - -void -AmazonShoppingCart::remove( int pos ) -{ - if( pos < 0 || pos >= size() ) // not valid - return; - - m_price = m_price - at( pos ).price().toInt(); - QList::removeAt( pos ); -} - -QUrl -AmazonShoppingCart::checkoutUrl( QString asin ) -{ - if( isEmpty() && asin.isEmpty() ) // we don't create empty carts - return QUrl(); - - QString url; - - // the basics - url += MP3_MUSIC_STORE_HOST; - url += "/index.php?apikey="; - url += MP3_MUSIC_STORE_KEY; - url += "&redirect=true&method=CreateCart&Location="; - url += AmazonConfig::instance()->country(); - url += "&Player=amarok"; - - // let's add the ASINs - - if( !asin.isEmpty() ) - url += "&ASINs[]=" + asin; - else - { - for( int i = 0; i < size(); i++ ) - { - url += "&ASINs[]="; - url += at( i ).asin(); - } - } - - return QUrl( url ); -} diff --git a/amarok/src/services/amazon/AmazonShoppingCart.h b/amarok/src/services/amazon/AmazonShoppingCart.h deleted file mode 100644 index 0c33634f..00000000 --- a/amarok/src/services/amazon/AmazonShoppingCart.h +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2011 Sven Krohlas * - * The Amazon store in based upon the Magnatune store in Amarok, * - * Copyright (c) 2006,2007 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAZONSHOPPINGCART_H -#define AMAZONSHOPPINGCART_H - -#include "AmazonShoppingCartItem.h" - -#include - -#include -#include -#include - - -/* Singleton representing the Amazon shopping cart. */ - -class AmazonShoppingCart : public QList -{ -public: - static AmazonShoppingCart* instance(); - static void destroy(); - - /** - * Adds an item to the cart. - */ - void add( QString asin, QString price, QString name ); - - /** - * Empties the cart. - */ - void clear(); - - /** - * Returns the list of items in the cart. - */ - QStringList stringList(); - - /** - * Returns the total price of all items in the cart. - */ - QString price(); - - /** - * Removes an item from the cart. - * @param pos position of the item. - */ - void remove( int pos ); - - /** - * Returns the URL required to check the items in the cart out. - ** @asin single item to check out (optional). - */ - QUrl checkoutUrl( QString asin = QString() ); - -private: - AmazonShoppingCart(); - ~AmazonShoppingCart(); - - static AmazonShoppingCart* m_instance; - quint64 m_price; -}; - -#endif // AMAZONSHOPPINGCART_H diff --git a/amarok/src/services/amazon/AmazonShoppingCartDialog.cpp b/amarok/src/services/amazon/AmazonShoppingCartDialog.cpp deleted file mode 100644 index 6774f138..00000000 --- a/amarok/src/services/amazon/AmazonShoppingCartDialog.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2011 Sven Krohlas * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "AmazonShoppingCartDialog.h" - -#include "Amazon.h" -#include "AmazonShoppingCart.h" - -#include "ui_AmazonShoppingCartDialog.h" - -AmazonShoppingCartDialog::AmazonShoppingCartDialog( QWidget *parent, AmazonStore *store ) : - QDialog( parent ), - ui( new Ui::AmazonShoppingCartDialog ), - m_store( store ) -{ - ui->setupUi( this ); - - m_model = new AmazonShoppingCartModel; - m_model->setStringList( AmazonShoppingCart::instance()->stringList() ); - ui->listView->setModel( m_model ); - ui->cartValueLabel->setText( i18n( "Shopping cart value: %1", Amazon::prettyPrice( AmazonShoppingCart::instance()->price() ) ) ); - ui->cookieLabel->setText( i18n( "When clicking checkout you are being redirected to Amazon for the checkout process. To simplify that process please click this link to tell Amazon that you have a downloader application for their MP3s installed.", Amazon::createCookieUrl().toString() ) ); - ui->checkoutButton->setIcon( KIcon( "download-amarok" ) ); - - if( AmazonShoppingCart::instance()->isEmpty() ) - ui->checkoutButton->setEnabled( false ); - else - ui->checkoutButton->setEnabled( true ); - - connect( ui->checkoutButton, SIGNAL(clicked()), m_store, SLOT(checkout()) ); - connect( ui->checkoutButton, SIGNAL(clicked()), this, SLOT(accept()) ); - connect( m_model, SIGNAL(contentsChanged()), this, SLOT(contentsChanged()) ); -} - -AmazonShoppingCartDialog::~AmazonShoppingCartDialog() -{ - delete ui; -} - - -/* public slots */ - -void -AmazonShoppingCartDialog::contentsChanged() -{ - // update price - ui->cartValueLabel->setText( i18n( "Shopping cart value: %1", Amazon::prettyPrice( AmazonShoppingCart::instance()->price() ) ) ); - - // update view - m_model->setStringList( AmazonShoppingCart::instance()->stringList() ); // HACK, but works - ui->listView->setModel( m_model ); - - // update button status - if( AmazonShoppingCart::instance()->isEmpty() ) - ui->checkoutButton->setEnabled( false ); - else - ui->checkoutButton->setEnabled( true ); -} diff --git a/amarok/src/services/amazon/AmazonShoppingCartDialog.h b/amarok/src/services/amazon/AmazonShoppingCartDialog.h deleted file mode 100644 index 62d9377f..00000000 --- a/amarok/src/services/amazon/AmazonShoppingCartDialog.h +++ /dev/null @@ -1,46 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2011 Sven Krohlas * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAZONSHOPPINGCARTDIALOG_H -#define AMAZONSHOPPINGCARTDIALOG_H - -#include "AmazonShoppingCartModel.h" -#include "AmazonStore.h" - -#include - -namespace Ui { - class AmazonShoppingCartDialog; -} - -class AmazonShoppingCartDialog : public QDialog -{ - Q_OBJECT - -public: - explicit AmazonShoppingCartDialog( QWidget *parent = 0, AmazonStore *store = 0 ); - ~AmazonShoppingCartDialog(); - -public slots: - void contentsChanged(); - -private: - Ui::AmazonShoppingCartDialog *ui; - AmazonShoppingCartModel *m_model; - AmazonStore *m_store; -}; - -#endif // AMAZONSHOPPINGCARTDIALOG_H diff --git a/amarok/src/services/amazon/AmazonShoppingCartDialog.ui b/amarok/src/services/amazon/AmazonShoppingCartDialog.ui deleted file mode 100644 index 9c56636a..00000000 --- a/amarok/src/services/amazon/AmazonShoppingCartDialog.ui +++ /dev/null @@ -1,118 +0,0 @@ - - - AmazonShoppingCartDialog - - - - 0 - 0 - 400 - 300 - - - - Amarok - Your Shopping Cart - - - - - - QAbstractItemView::NoEditTriggers - - - true - - - - - - - [placeholder] Shopping cart value: - - - - - - - [placeholder] When clicking checkout you are being redirected to Amazon for the checkout process. To simplify that process please click this link to tell Amazon that you have a downloader application for their MP3s installed. - - - true - - - true - - - - - - - - - Checkout - - - - - - - - 0 - 0 - - - - Qt::Horizontal - - - QDialogButtonBox::Ok - - - - - - - - - - AmazonShoppingCartView - QListView -
    AmazonShoppingCartView.h
    -
    -
    - - - - buttonBox - accepted() - AmazonShoppingCartDialog - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - AmazonShoppingCartDialog - reject() - - - 316 - 260 - - - 286 - 274 - - - - -
    diff --git a/amarok/src/services/amazon/AmazonShoppingCartItem.cpp b/amarok/src/services/amazon/AmazonShoppingCartItem.cpp deleted file mode 100644 index 34427a8a..00000000 --- a/amarok/src/services/amazon/AmazonShoppingCartItem.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2011 Sven Krohlas * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "AmazonShoppingCartItem.h" - -AmazonShoppingCartItem::AmazonShoppingCartItem( QString asin, QString price, QString prettyName ) -{ - m_asin = asin; - m_prettyName = prettyName; - m_price = price; -} - -QString -AmazonShoppingCartItem::asin() const -{ - return m_asin; -} - -QString -AmazonShoppingCartItem::prettyName() const -{ - return m_prettyName; -} - -QString -AmazonShoppingCartItem::price() const -{ - return m_price; -} diff --git a/amarok/src/services/amazon/AmazonShoppingCartItem.h b/amarok/src/services/amazon/AmazonShoppingCartItem.h deleted file mode 100644 index 14c89722..00000000 --- a/amarok/src/services/amazon/AmazonShoppingCartItem.h +++ /dev/null @@ -1,48 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2011 Sven Krohlas * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAZONSHOPPINGCARTITEM_H -#define AMAZONSHOPPINGCARTITEM_H - -#include - -class AmazonShoppingCartItem -{ -public: - AmazonShoppingCartItem( QString asin, QString price, QString prettyName ); - - /** - * Returns the Amazon internal ID of the item. - */ - QString asin() const; - - /** - * Returns the pretty name of the item. - */ - QString prettyName() const; - - /** - * Returns the price of the item. - */ - QString price() const; - -private: - QString m_asin; - QString m_prettyName; - QString m_price; -}; - -#endif // AMAZONSHOPPINGCARTITEM_H diff --git a/amarok/src/services/amazon/AmazonShoppingCartModel.cpp b/amarok/src/services/amazon/AmazonShoppingCartModel.cpp deleted file mode 100644 index c9d23cb8..00000000 --- a/amarok/src/services/amazon/AmazonShoppingCartModel.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2011 Sven Krohlas * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "AmazonShoppingCartModel.h" - -#include "AmazonShoppingCart.h" - -AmazonShoppingCartModel::AmazonShoppingCartModel() -{ -} - -bool -AmazonShoppingCartModel::removeRows( int row, int count, const QModelIndex &parent ) -{ - Q_UNUSED( count ) - beginRemoveRows( parent, row, 1 ); // we can only select one item - AmazonShoppingCart::instance()->remove( row ); - endRemoveRows(); - - emit contentsChanged(); - - return true; -} diff --git a/amarok/src/services/amazon/AmazonShoppingCartModel.h b/amarok/src/services/amazon/AmazonShoppingCartModel.h deleted file mode 100644 index 44ca773f..00000000 --- a/amarok/src/services/amazon/AmazonShoppingCartModel.h +++ /dev/null @@ -1,36 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2011 Sven Krohlas * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAZONSHOPPINGCARTMODEL_H -#define AMAZONSHOPPINGCARTMODEL_H - -#include - -class AmazonShoppingCartModel : public QStringListModel -{ - Q_OBJECT - -public: - AmazonShoppingCartModel(); - - // reimplemented from QStringListModel - virtual bool removeRows( int row, int count, const QModelIndex &parent = QModelIndex() ); - -signals: - void contentsChanged(); -}; - -#endif // AMAZONSHOPPINGCARTMODEL_H diff --git a/amarok/src/services/amazon/AmazonShoppingCartView.cpp b/amarok/src/services/amazon/AmazonShoppingCartView.cpp deleted file mode 100644 index e1f7c940..00000000 --- a/amarok/src/services/amazon/AmazonShoppingCartView.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2011 Sven Krohlas * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "AmazonShoppingCartView.h" - -#include "klocalizedstring.h" - -#include -#include - -AmazonShoppingCartView::AmazonShoppingCartView( QWidget *parent ) : - QListView( parent ) -{ - setAlternatingRowColors( true ); - setUniformItemSizes( true ); -} - -void -AmazonShoppingCartView::keyPressEvent( QKeyEvent *event ) -{ - if( event->key() == Qt::Key_Delete ) - { - QModelIndex index = currentIndex(); - int row = index.row(); - int count = 1; - - model()->removeRows( row, count, index ); - event->accept(); - - return; - } - - QListView::keyPressEvent( event ); -} - - -/* protected */ - -void -AmazonShoppingCartView::contextMenuEvent( QContextMenuEvent *event ) -{ - QModelIndex index = indexAt( event->pos() ); - if( !index.isValid() ) - { - event->accept(); - return; - } - - KMenu menu( this ); - QList< QAction * > actions; - - QAction *removeFromCartAction = new QAction( KIcon( "amarok_cart_remove" ), QString( i18n( "Remove from Cart" ) ), &menu ); - actions.append( removeFromCartAction ); - connect( removeFromCartAction, SIGNAL(triggered()), this, SLOT(removeFromCartAction()) ); - - menu.exec( actions, event->globalPos() ); - event->accept(); -} - - -/* protected slots */ - -void -AmazonShoppingCartView::removeFromCartAction() -{ - QModelIndex index = currentIndex(); - int row = index.row(); - int count = 1; - - model()->removeRows( row, count, index ); -} diff --git a/amarok/src/services/amazon/AmazonShoppingCartView.h b/amarok/src/services/amazon/AmazonShoppingCartView.h deleted file mode 100644 index b50ba05f..00000000 --- a/amarok/src/services/amazon/AmazonShoppingCartView.h +++ /dev/null @@ -1,46 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2011 Sven Krohlas * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAZONSHOPPINGCARTVIEW_H -#define AMAZONSHOPPINGCARTVIEW_H - -#include -#include - -class AmazonShoppingCartView : public QListView -{ - Q_OBJECT -public: - explicit AmazonShoppingCartView( QWidget *parent = 0 ); - - /** - * Reimplemented from QAbstractItemView. - * Catches DEL key presses to remove items from the view. - */ - virtual void keyPressEvent( QKeyEvent *event ); - -protected: - /** - * Reimplemented from QAbstractScrollArea. - * Shows a context menu for items in the view. - */ - virtual void contextMenuEvent( QContextMenuEvent *event ); - -protected slots: - void removeFromCartAction(); -}; - -#endif // AMAZONSHOPPINGCARTVIEW_H diff --git a/amarok/src/services/amazon/AmazonStore.cpp b/amarok/src/services/amazon/AmazonStore.cpp deleted file mode 100644 index 4c339eba..00000000 --- a/amarok/src/services/amazon/AmazonStore.cpp +++ /dev/null @@ -1,605 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2011, 2012 Sven Krohlas * - * The Amazon store in based upon the Magnatune store in Amarok, * - * Copyright (c) 2006,2007 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "AmazonStore.h" - -#include "Amazon.h" -#include "AmazonConfig.h" -#include "AmazonMeta.h" -#include "AmazonParser.h" -#include "AmazonShoppingCart.h" -#include "AmazonShoppingCartDialog.h" -#include "AmazonUrlRunner.h" -#include "AmazonWantCountryWidget.h" - -#include "amarokurls/AmarokUrlHandler.h" -#include "browsers/CollectionTreeItem.h" -#include "browsers/SingleCollectionTreeItemModel.h" -#include "core/interfaces/Logger.h" -#include "core/support/Components.h" -#include "core-impl/collections/support/CollectionManager.h" -#include "playlist/PlaylistController.h" -#include "widgets/SearchWidget.h" - -#include -#include -#include -#include - -#include -#include "kio/jobclasses.h" -#include -#include -#include -#include "klocalizedstring.h" - -AMAROK_EXPORT_SERVICE_PLUGIN( amazonstore, AmazonServiceFactory ) - -//////////////////////////////////////////////////////////////////////////////////////// -// class AmazonServiceFactory -//////////////////////////////////////////////////////////////////////////////////////// - -AmazonServiceFactory::AmazonServiceFactory( QObject *parent, const QVariantList &args ) - : ServiceFactory( parent, args ) -{ - KPluginInfo pluginInfo( "amarok_service_amazonstore.desktop", "services" ); - pluginInfo.setConfig( config() ); - m_info = pluginInfo; -} - -void -AmazonServiceFactory::init() -{ - DEBUG_BLOCK - AmazonStore* service = new AmazonStore( this, "MP3 Music Store" ); - m_initialized = true; - emit newService( service ); -} - -QString -AmazonServiceFactory::name() -{ - return "Amazon"; -} - -KConfigGroup -AmazonServiceFactory::config() -{ - return Amarok::config( "Service_Amazon" ); -} - - -//////////////////////////////////////////////////////////////////////////////////////// -// class AmazonStore -//////////////////////////////////////////////////////////////////////////////////////// - -// TODO: force country selection before first search, advanced search (albums/tracks only, further search result pages) - -AmazonStore::AmazonStore( AmazonServiceFactory* parent, const char *name ) - : ServiceBase( name, parent, false ) - , m_wantCountryWidget(0) -{ - DEBUG_BLOCK - setObjectName( name ); - - m_polished = false; - m_isNavigation = false; - - setShortDescription( i18n( "Access the Amazon MP3 Store directly from Amarok" ) ); - setIcon( KIcon( "view-services-amazon-amarok" ) ); - - // used in info applet - setLongDescription( i18n( "This plugin allows searching and purchasing songs and albums from the Amazon MP3 store. Amarok gets a share of the profits made by this service." ) ); - - setImagePath( KStandardDirs::locate( "data", "amarok/images/hover_info_amazon.png" ) ); - - m_metaFactory = new AmazonMetaFactory( "amazon" ); - m_collection = new Collections::AmazonCollection( this, "amazon", "MP3 Music Store" ); - polish(); - setPlayableTracks( true ); - - m_lastSearch.clear(); - - // add the collection, exclude it from global queries - CollectionManager::instance()->addTrackProvider( m_collection ); - - connect( m_searchWidget, SIGNAL(filterChanged(QString)), this, SLOT(newSearchRequest(QString)) ); - - setServiceReady( true ); - newSearchRequest( QLatin1String( "" ) ); // to get some default content -} - -AmazonStore::~AmazonStore() -{ - CollectionManager::instance()->removeTrackProvider( m_collection ); - delete m_collection; -} - -void -AmazonStore::polish() -{ - DEBUG_BLOCK; - - if( !m_polished ) { - m_polished = true; - - initTopPanel(); - initBottomPanel(); - initView(); - - connect( m_itemView, SIGNAL(itemSelected(QModelIndex)), this, SLOT(itemSelected(QModelIndex)) ); - connect( m_itemView, SIGNAL(itemDoubleClicked(QModelIndex)), this, SLOT(itemDoubleClicked(QModelIndex)) ); - connect( m_itemView, SIGNAL(searchForAlbum(QModelIndex)), this, SLOT(searchForAlbum(QModelIndex)) ); - - m_amazonInfoParser = new AmazonInfoParser(); - setInfoParser( m_amazonInfoParser ); - m_amazonInfoParser->showFrontPage(); - - AmazonUrlRunner *runner = new AmazonUrlRunner(); - connect( runner, SIGNAL(search(QString)), this, SLOT(newSearchRequest(QString)) ); - The::amarokUrlHandler()->registerRunner( runner, runner->command() ); - } -} - - -/* public slots */ - -void -AmazonStore::addToCart() -{ - QString asin, name, price; - int id = m_itemModel->idForIndex( m_selectedIndex );; - - // get item from collection - if( m_itemModel->isAlbum( m_selectedIndex ) ) // album - { - Meta::AmazonAlbum* album; - - album = dynamic_cast( m_collection->albumById( id ).data() ); - - if( !album ) - return; - - name = m_collection->artistById( album->artistId() )->name() + " - " + album->name(); - asin = album->asin(); - price = album->price(); - } - else // track - { - Meta::AmazonTrack* track; - track = dynamic_cast( m_collection->trackById( id ).data() ); - - if( !track ) - return; - - name = m_collection->artistById( track->artistId() )->name() + " - " + track->name(); - asin = track->asin(); - price = track->price(); - } - - AmazonShoppingCart::instance()->add( asin, price, name ); - m_checkoutButton->setEnabled( true ); -} - -void -AmazonStore::viewCart() -{ - AmazonShoppingCartDialog cartDialog( this, this ); - cartDialog.exec(); -} - -void -AmazonStore::checkout() -{ - QUrl url = AmazonShoppingCart::instance()->checkoutUrl(); - debug() << url; - - if( QDesktopServices::openUrl( url ) ) - { - m_checkoutButton->setEnabled( false ); - AmazonShoppingCart::instance()->clear(); - } - - Amarok::Components::logger()->longMessage( i18n( "MP3 Music Store

    You are now being redirected to Amazon for the checkout process.
    To simplify that process please click this link to tell Amazon that you have a downloader application for their MP3s installed.", Amazon::createCookieUrl().toString() ) ); -} - -void -AmazonStore::directCheckout() -{ - if( !m_selectedIndex.isValid() ) - return; - - // get item ASIN from collection - int id = m_itemModel->idForIndex( m_selectedIndex ); - QString asin; - Meta::AmazonItem* item; - - if( m_itemModel->isAlbum( m_selectedIndex ) ) // album - item = dynamic_cast( m_collection->albumById( id ).data() ); - else // track - item = dynamic_cast( m_collection->trackById( id ).data() ); - - if( !item ) - return; - - asin = item->asin(); - - // create and open direct checkout url - QUrl url( AmazonShoppingCart::instance()->checkoutUrl( asin ) ); - QDesktopServices::openUrl( url ); -} - -void -AmazonStore::itemDoubleClicked( QModelIndex index ) -{ - // for albums: search for the album ASIN to get details about it - // for tracks: add it to the playlist - - int id = m_itemModel->idForIndex( index ); - - if( m_itemModel->isAlbum( index ) ) // album - { - Meta::AmazonAlbum* album; - album = dynamic_cast( m_collection->albumById( id ).data() ); - - if( !album ) - return; - - m_searchWidget->setSearchString( "asin:" + album->asin() ); - } - else // track - { - Meta::AmazonTrack* track; - track = dynamic_cast( m_collection->trackById( id ).data() ); - - if( !track ) - return; - - Meta::TrackPtr trackPtr( track ); - - The::playlistController()->instance()->insertOptioned( trackPtr, Playlist::OnDoubleClickOnSelectedItems ); - } -} - -void -AmazonStore::itemSelected( QModelIndex index ) -{ - m_addToCartButton->setEnabled( true ); - m_selectedIndex = index; - - int id = m_itemModel->idForIndex( index ); - Meta::AlbumPtr album; - - if( m_itemModel->isAlbum( index ) ) - album = m_collection->albumById( id ).data(); - else // track - album = m_collection->trackById( id ).data()->album(); - - m_amazonInfoParser->getInfo( album ); -} - -void -AmazonStore::newSearchRequest( const QString request ) -{ - DEBUG_BLOCK - - if( AmazonConfig::instance()->country() == QLatin1String( "none" ) || AmazonConfig::instance()->country().isEmpty() ) - { - // user explicitly said we are not in a supported country or refused to supply one - if( m_itemView->isVisible() ) // show the message on startup only if the service is visible - Amarok::Components::logger()->longMessage( i18n( "MP3 Music Store

    Please select a valid country in the settings to make the store work." ) ); - - return; // do nothing - } - - if( m_lastSearch != request ) - { - // only add the request to the stack if it's a new one - if( !m_isNavigation ) - m_backStack.push( m_lastSearch ); - - // we start by showing the first result page - m_lastSearch = request; - m_resultpageSpinBox->setValue( 1 ); - } - - m_isNavigation = false; - - // update actions status - m_backwardAction->setEnabled( !m_backStack.isEmpty() ); - m_forwardAction->setEnabled( !m_forwardStack.isEmpty() ); - - // create request fetcher thread - debug() << "Amazon: newSearchRequest: " << request; - QUrl requestUrl = createRequestUrl( request ); - - QTemporaryFile tempFile; - tempFile.setAutoRemove( false ); // file must be removed later -> AmazonParser does it - - if( !tempFile.open() ) - { - Amarok::Components::logger()->longMessage( i18n( "MP3 Music Store

    Error: Unable to write temporary file. :-(" ) ); - return; - } - - m_searchWidget->searchStarted(); - KIO::FileCopyJob *requestJob = KIO::file_copy( requestUrl, KUrl( tempFile.fileName() ), 0700 , KIO::HideProgressInfo | KIO::Overwrite ); - - connect( requestJob, SIGNAL(result(KJob*)), this, SLOT(parseReply(KJob*)) ); - requestJob->start(); -} - -void -AmazonStore::newSpinBoxSearchRequest( int i ) -{ - Q_UNUSED( i ) - newSearchRequest( m_searchWidget->currentText() ); -} - -void -AmazonStore::searchForAlbum( QModelIndex index ) -{ - // only being called for tracks to search for the album - - if( !m_itemModel->isAlbum( index ) ) // track - { - Meta::AmazonTrack* track; - int id = m_itemModel->idForIndex( index ); - - track = dynamic_cast( m_collection->trackById( id ).data() ); - - if( !track ) - return; - - Meta::AmazonAlbum* album; - album = dynamic_cast( m_collection->albumById( track->albumId() ).data() ); - - if( !album ) - return; - - m_searchWidget->setSearchString( "asin:" + album->asin() ); - } -} - -/* private */ - -QUrl -AmazonStore::createRequestUrl( QString request ) -{ - DEBUG_BLOCK - QString urlString; - QString pageValue; - - urlString += MP3_MUSIC_STORE_HOST; - urlString += "/?apikey="; - urlString += MP3_MUSIC_STORE_KEY; - urlString += "&Player=amarok&Location="; - urlString += AmazonConfig::instance()->country(); - - if( request.startsWith( "asin:" ) ) // we need to load album details - { - urlString += "&method=LoadAlbum"; - urlString += "&ASIN=" + request.remove( "asin:" ); - } - else // normal search - { - pageValue.setNum( m_resultpageSpinBox->value() ); - - urlString += "&method=Search"; - urlString += "&Text="; - urlString += request.toUtf8().toBase64(); - urlString += "&Page="; - urlString += pageValue; - } - - debug() << urlString; - return QUrl( urlString ); -} - -void -AmazonStore::initTopPanel() -{ - KHBox *topPanel = new KHBox( m_topPanel ); - delete m_searchWidget; - - KToolBar *navigationToolbar = new KToolBar( topPanel ); - navigationToolbar->setToolButtonStyle( Qt::ToolButtonIconOnly ); - navigationToolbar->setIconDimensions( 16 ); - - m_backwardAction = KStandardAction::back( this, SLOT(back()), topPanel ); - m_forwardAction = KStandardAction::forward( this, SLOT(forward()), topPanel ); - m_backwardAction->setEnabled( false ); - m_forwardAction->setEnabled( false ); - - m_searchWidget = new SearchWidget( topPanel, false ); - m_searchWidget->setTimeout( 1500 ); - m_searchWidget->showAdvancedButton( false ); - - m_resultpageSpinBox = new QSpinBox; - m_resultpageSpinBox->setMinimum( 1 ); - m_resultpageSpinBox->setToolTip( i18n( "Select results page to show" ) ); - - navigationToolbar->addAction( m_backwardAction ); - navigationToolbar->addAction( m_forwardAction ); - m_searchWidget->toolBar()->addWidget( m_resultpageSpinBox ); - - connect( m_resultpageSpinBox, SIGNAL(valueChanged(int)), this, SLOT(newSpinBoxSearchRequest(int)) ); -} - -void -AmazonStore::initBottomPanel() -{ - QString country(AmazonConfig::instance()->country()); - if( country.isEmpty() || country == QLatin1String( "none" ) ) - { - m_wantCountryWidget = new AmazonWantCountryWidget(m_bottomPanel); - connect(m_wantCountryWidget, SIGNAL(countrySelected()), - SLOT(countryUpdated())); - } -} - -void -AmazonStore::initView() -{ - m_itemView = new AmazonItemTreeView( this ); - m_itemModel = new AmazonItemTreeModel( m_collection ); - m_itemView->setParent( this ); - m_itemView->setRootIsDecorated( false ); // items cannot be expanded - m_itemView->setUniformRowHeights( true ); // for perf reasons - m_itemView->setFrameStyle( QFrame::NoFrame ); // no frame around the view, especially when selecting items - m_itemView->setModel( m_itemModel ); - - KHBox* bottomPanelLayout = new KHBox; - bottomPanelLayout->setParent( this ); - - m_addToCartButton = new QPushButton; - m_addToCartButton->setText( i18nc( "Add selected item to your shopping cart", "Add to Cart" ) ); - m_addToCartButton->setToolTip( i18n( "Add selected item to your shopping cart" ) ); - m_addToCartButton->setEnabled( false ); - m_addToCartButton->setObjectName( "addToCartButton" ); - m_addToCartButton->setParent( bottomPanelLayout ); - m_addToCartButton->setIcon( KIcon( "amarok_cart_add" ) ); - - m_viewCartButton = new QPushButton; - m_viewCartButton->setText( i18nc( "View your shopping cart contents", "View Cart" ) ); - m_viewCartButton->setToolTip( i18n( "View your shopping cart contents" ) ); - m_viewCartButton->setEnabled( true ); - m_viewCartButton->setObjectName( "viewCartButton" ); - m_viewCartButton->setParent( bottomPanelLayout ); - m_viewCartButton->setIcon( KIcon( "amarok_cart_view" ) ); - - m_checkoutButton = new QPushButton; - m_checkoutButton->setText( i18nc( "Checkout your shopping cart", "Checkout" ) ); - m_checkoutButton->setToolTip( i18n( "Checkout your shopping cart" ) ); - m_checkoutButton->setEnabled( false ); - m_checkoutButton->setObjectName( "checkoutButton" ); - m_checkoutButton->setParent( bottomPanelLayout ); - m_checkoutButton->setIcon( KIcon( "download-amarok" ) ); - - connect( m_addToCartButton, SIGNAL(clicked()), this, SLOT(addToCart()) ); - connect( m_itemView, SIGNAL(addToCart()), this, SLOT(addToCart()) ); - connect( m_itemView, SIGNAL(directCheckout()), this, SLOT(directCheckout()) ); - connect( m_viewCartButton, SIGNAL(clicked()), this, SLOT(viewCart()) ); - connect( m_checkoutButton, SIGNAL(clicked()), this, SLOT(checkout()) ); -} - -QString AmazonStore::iso3166toAmazon( const QString& country ) -{ - static QHash table; - if( table.isEmpty() ) - { - table["at"] = "de"; - table["ch"] = "de"; - table["de"] = "de"; - table["es"] = "es"; - table["fr"] = "fr"; - table["it"] = "it"; - table["jp"] = "co.jp"; - table["gb"] = "co.uk"; - table["us"] = "com"; - } - - return table.value( country, "none" ); -} - -/* private slots */ - -void -AmazonStore::parseReply( KJob* requestJob ) -{ - DEBUG_BLOCK - if( requestJob->error() ) - { - Amarok::Components::logger()->longMessage( i18n( "MP3 Music Store

    Error: Querying MP3 Music Store database failed. :-(" ) ); - debug() << requestJob->errorString(); - requestJob->deleteLater(); - m_searchWidget->searchEnded(); - return; - } - - QString tempFileName; - KIO::FileCopyJob *job = dynamic_cast( requestJob ); - - if( job ) - tempFileName = job->destUrl().toLocalFile(); - - // create parser thread - AmazonParser *parser = new AmazonParser( tempFileName, m_collection, m_metaFactory ); - connect( parser, SIGNAL(done(ThreadWeaver::Job*)), this, SLOT(parsingDone(ThreadWeaver::Job*)) ); - connect( parser, SIGNAL(failed(ThreadWeaver::Job*)), this, SLOT(parsingFailed(ThreadWeaver::Job*)) ); - ThreadWeaver::Weaver::instance()->enqueue( parser ); - - requestJob->deleteLater(); -} - -void -AmazonStore::parsingDone( ThreadWeaver::Job* parserJob ) -{ - Q_UNUSED( parserJob ) - // model has been reset now, we no longer have a valid selection - m_addToCartButton->setEnabled( false ); - m_searchWidget->searchEnded(); -} - -void -AmazonStore::parsingFailed( ThreadWeaver::Job* parserJob ) -{ - Q_UNUSED( parserJob ) - Amarok::Components::logger()->longMessage( i18n( "MP3 Music Store

    Error: Received an invalid reply. :-(" ) ); - m_searchWidget->searchEnded(); -} - -void -AmazonStore::back() -{ - if( m_backStack.isEmpty() ) - return; - - QString request = m_backStack.pop(); - m_forwardStack.push( m_lastSearch ); - m_isNavigation = true; - m_searchWidget->setSearchString( request ); -} - -void -AmazonStore::forward() -{ - if( m_forwardStack.isEmpty() ) - return; - - QString request = m_forwardStack.pop(); - m_backStack.push( m_lastSearch ); - m_isNavigation = true; - m_searchWidget->setSearchString( request ); -} - -void -AmazonStore::countryUpdated() -{ - QString country( AmazonConfig::instance()->country() ); - if( country.isEmpty() || country == QLatin1String( "none" ) ) - return; - - if( m_wantCountryWidget ) - { - m_wantCountryWidget->setParent( 0 ); - m_wantCountryWidget->deleteLater(); - m_wantCountryWidget = 0; - } - newSearchRequest( QString() ); -} diff --git a/amarok/src/services/amazon/AmazonStore.h b/amarok/src/services/amazon/AmazonStore.h deleted file mode 100644 index a0129bb4..00000000 --- a/amarok/src/services/amazon/AmazonStore.h +++ /dev/null @@ -1,228 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2011 Sven Krohlas * - * The Amazon store in based upon the Magnatune store in Amarok, * - * Copyright (c) 2006,2007 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAZONSTORE_H -#define AMAZONSTORE_H - -#include "AmazonCollection.h" -#include "AmazonInfoParser.h" -#include "AmazonItemTreeModel.h" -#include "AmazonItemTreeView.h" -#include "AmazonMeta.h" - -#include "../ServiceBase.h" -#include "ServiceSqlRegistry.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -class AmazonMetaFactory; -class AmazonInfoParser; - -class AmazonWantCountryWidget; - -class AmazonServiceFactory : public ServiceFactory -{ - Q_OBJECT - -public: - AmazonServiceFactory( QObject* parent, const QVariantList &args ); - virtual ~AmazonServiceFactory() {} - - virtual void init(); - virtual QString name(); - virtual KConfigGroup config(); - - virtual bool possiblyContainsTrack( const KUrl &url ) const { return url.url().contains( "amazon.", Qt::CaseInsensitive ); } // XXX: ??? -}; - - -class AmazonStore : public ServiceBase -{ - Q_OBJECT - -public: - /** - * Constructor - */ - AmazonStore( AmazonServiceFactory* parent, const char *name ); - - /** - * Destructor - */ - ~AmazonStore(); - - virtual Collections::Collection* collection() { return m_collection; } - void polish(); - - /** - * Convert an ISO 3166 two-letter country code to Amazon - * top level domain - * - * @returns a TLD for corresponding Amazon store, or "none" - */ - static QString iso3166toAmazon(const QString& country); - -public slots: - /** - * Adds the currently selected item to the cart. - */ - void addToCart(); - - /** - * Shows a dialog with the cart contents. - */ - void viewCart(); - - /** - * Checks the non-empty cart out. - */ - void checkout(); - - /** - * Checks the currently selected item out directly, without adding it to the local Amarok shopping cart. - */ - void directCheckout(); - - /** - * React to a double click on an item. - * @param index The QModelIndex of the item. - */ - void itemDoubleClicked( QModelIndex index ); - - /** - * Activates buttons required to interact with the currently selected item and updates the context view. - * @param index The QModelIndex of the item. - */ - void itemSelected( QModelIndex index ); - - /** - * The user requested us to query the service. - * @param request string to search for. - */ - void newSearchRequest( const QString request ); - - /** - * The user wants to go to another page of search results. - * @param i page to go to. - */ - void newSpinBoxSearchRequest( int i ); - - /** - * Starts a search for the album of a track the given QModelIndex represents. - * @param index The QModelIndex for the track. - */ - void searchForAlbum( QModelIndex index ); - -private: - /** - * Helper method. Creates a valid request URL for the Amazon service. - * @param request string to search for. - */ - QUrl createRequestUrl( const QString request ); - - /** - * Inits the top part of the Amazon store browser view with its widgets. - */ - void initTopPanel(); - - /** - * Initializes the bottom panel of Amazon store browser. - * - * Currently this contains nothing, except for possible "Select country" - * widget. - */ - void initBottomPanel(); - - /** - * Inits the Amazon store browser view with its widgets. - */ - void initView(); - - AmazonMetaFactory* m_metaFactory; - - Collections::AmazonCollection* m_collection; - - ServiceSqlRegistry* m_registry; - - QPushButton* m_addToCartButton; - QPushButton* m_removeFromCartButton; - QPushButton* m_viewCartButton; - QPushButton* m_checkoutButton; - - AmazonWantCountryWidget* m_wantCountryWidget; - - QSpinBox* m_resultpageSpinBox; - KAction* m_forwardAction; - KAction* m_backwardAction; - - bool m_isNavigation; - - QString m_lastSearch; - QStack m_backStack; - QStack m_forwardStack; - - AmazonItemTreeView* m_itemView; - AmazonItemTreeModel* m_itemModel; - - QModelIndex m_selectedIndex; - - AmazonInfoParser* m_amazonInfoParser; - -private slots: - /** - * Parse the API reply XML document. - */ - void parseReply( KJob* requestJob ); - - /** - * Clean up after parsing the API reply XML document, update collection. - */ - void parsingDone( ThreadWeaver::Job* parserJob ); - - /** - * Clean up after parsing the API reply XML document. - */ - void parsingFailed( ThreadWeaver::Job* parserJob ); - - /** - * Go backward in Amazon store. - */ - void back(); - - /** - * Go forward in Amazon store. - */ - void forward(); - - /** - * Country has been updated in the configuration - */ - void countryUpdated(); -}; - -#endif // AMAZONSTORE_H diff --git a/amarok/src/services/amazon/AmazonUrlRunner.cpp b/amarok/src/services/amazon/AmazonUrlRunner.cpp deleted file mode 100644 index dd405372..00000000 --- a/amarok/src/services/amazon/AmazonUrlRunner.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * Copyright (c) 2011 Sven Krohlas * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "AmazonShoppingCart.h" -#include "AmazonUrlRunner.h" - -#include - -AmazonUrlRunner::AmazonUrlRunner() - : QObject() - , AmarokUrlRunnerBase() -{ -} - -AmazonUrlRunner::~AmazonUrlRunner() -{ -} - -QString -AmazonUrlRunner::command() const -{ - return "service-amazonstore"; -} - -QString -AmazonUrlRunner::prettyCommand() const -{ - return i18nc( "A type of command that triggers an action in the integrated MP3 Music Store service", "Amazon" ); -} - -KIcon -AmazonUrlRunner::icon() const -{ - return KIcon( "view-services-amazon-amarok" ); -} - -bool -AmazonUrlRunner::run( AmarokUrl url ) -{ - DEBUG_BLOCK - if( !url.isNull() ) - { - QString command = url.args().value( "command" ); - - if( command == "search" ) - { - QString request = url.args().value( "filter" ); - emit( search( request ) ); - } - else if( command == "addToCart") - { - QString asin = url.args().value( "asin" ); - QString name = url.args().value( "name" ); - QString price = url.args().value( "price" ); - - // do nothing if url is invalid - if( asin.isEmpty() || name.isEmpty() || price.isEmpty() ) - return false; - else - AmazonShoppingCart::instance()->add( asin, price, name ); - } - } - return true; -} - - -#include "moc_AmazonUrlRunner.cpp" diff --git a/amarok/src/services/amazon/AmazonUrlRunner.h b/amarok/src/services/amazon/AmazonUrlRunner.h deleted file mode 100644 index 28ed4bf9..00000000 --- a/amarok/src/services/amazon/AmazonUrlRunner.h +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * Copyright (c) 2011 Sven Krohlas * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAZONURLRUNNER_H -#define AMAZONURLRUNNER_H - -#include "amarokurls/AmarokUrlRunnerBase.h" - -#include - -#include - -/** -@author Nikolaj Hald Nielsen -@author Sven Krohlas - -We support URLs like -amarok://service-amazonstore?asin=B004UQSB8I&command=addToCart&name=The%20Cure%20-%20Disintegration%20(Remastered)&price=989 -to add something to the shopping cart and -amarok://navigate/MP3%20Music%20Store/?filter=something_to_search_for -to search in the mp3 database of the store. -*/ -class AmazonUrlRunner : public QObject, public AmarokUrlRunnerBase -{ - Q_OBJECT -public: - AmazonUrlRunner(); - - virtual ~AmazonUrlRunner(); - - virtual QString command() const; - virtual QString prettyCommand() const; - virtual KIcon icon() const; - virtual bool run( AmarokUrl url ); - -signals: - void search( const QString &request ); -}; - -#endif // AMAZONURLRUNNER_H diff --git a/amarok/src/services/amazon/AmazonWantCountryWidget.cpp b/amarok/src/services/amazon/AmazonWantCountryWidget.cpp deleted file mode 100644 index 375778e9..00000000 --- a/amarok/src/services/amazon/AmazonWantCountryWidget.cpp +++ /dev/null @@ -1,104 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Edward "hades" Toroshchin * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "AmazonWantCountryWidget.h" - -#include "ui_AmazonWantCountryWidget.h" - -#include "AmazonConfig.h" -#include "AmazonSettingsModule.h" -#include "AmazonStore.h" - -AmazonWantCountryWidget::AmazonWantCountryWidget(QWidget *parent) : - QWidget(parent), ui(new Ui::AmazonWantCountryWidget) -{ - ui->setupUi(this); - - // TODO: this is a code duplication from AmazonSettingsModule.cpp - int index = -1; - QString text = AmazonConfig::instance()->country(); - if( text.isEmpty() || text == QLatin1String("none") ) - { - QString country(KGlobal::locale()->country()); - text = AmazonStore::iso3166toAmazon(country); - } - - if( text == QLatin1String( "fr" ) ) - index = AMAZON_FR; - else if ( text == QLatin1String( "de" ) ) - index = AMAZON_DE; - else if ( text == QLatin1String( "co.jp" ) ) - index = AMAZON_JP; - else if ( text == QLatin1String( "co.uk" ) ) - index = AMAZON_UK; - else if ( text == QLatin1String( "com" ) ) - index = AMAZON_COM; - else if ( text == QLatin1String( "none" ) ) - index = AMAZON_NONE; - - if( index != -1 ) - ui->countrySelectionComboBox->setCurrentIndex( index ); - - connect(ui->saveSettings, SIGNAL(clicked()), SLOT(storeCountry())); - connect(ui->countrySelectionComboBox, SIGNAL(currentIndexChanged(int)), - SLOT(adjustButtonState())); - - adjustButtonState(); -} - -void -AmazonWantCountryWidget::storeCountry() -{ - // TODO: this is a code duplication with AmazonSettingsModule.cpp - switch( ui->countrySelectionComboBox->currentIndex() ) - { - case AMAZON_FR: - AmazonConfig::instance()->setCountry( QLatin1String( "fr" ) ); - break; - - case AMAZON_DE: - AmazonConfig::instance()->setCountry( QLatin1String( "de" ) ); - break; - - case AMAZON_JP: - AmazonConfig::instance()->setCountry( QLatin1String( "co.jp" ) ); - break; - - case AMAZON_UK: - AmazonConfig::instance()->setCountry( QLatin1String( "co.uk" ) ); - break; - - case AMAZON_COM: - AmazonConfig::instance()->setCountry( QLatin1String( "com" ) ); - break; - - case AMAZON_NONE: - AmazonConfig::instance()->setCountry( QLatin1String( "none" ) ); - break; - - default: - return; - } - - emit countrySelected(); -} - -void -AmazonWantCountryWidget::adjustButtonState() -{ - ui->saveSettings->setEnabled( - ui->countrySelectionComboBox->currentIndex() != AMAZON_NONE); -} diff --git a/amarok/src/services/amazon/AmazonWantCountryWidget.h b/amarok/src/services/amazon/AmazonWantCountryWidget.h deleted file mode 100644 index 9e3232db..00000000 --- a/amarok/src/services/amazon/AmazonWantCountryWidget.h +++ /dev/null @@ -1,43 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Edward "hades" Toroshchin * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAZONWANTCOUNTRYWIDGET_H -#define AMAZONWANTCOUNTRYWIDGET_H - -#include - -namespace Ui{ class AmazonWantCountryWidget; } - -class AmazonWantCountryWidget : public QWidget -{ - Q_OBJECT -public: - explicit AmazonWantCountryWidget(QWidget *parent = 0); - -protected: - Ui::AmazonWantCountryWidget* ui; - -signals: - void countrySelected(); - -public slots: - -private slots: - void storeCountry(); - void adjustButtonState(); -}; - -#endif // AMAZONWANTCOUNTRYWIDGET_H diff --git a/amarok/src/services/amazon/AmazonWantCountryWidget.ui b/amarok/src/services/amazon/AmazonWantCountryWidget.ui deleted file mode 100644 index 5daa3708..00000000 --- a/amarok/src/services/amazon/AmazonWantCountryWidget.ui +++ /dev/null @@ -1,163 +0,0 @@ - - - AmazonWantCountryWidget - - - - 0 - 0 - 302 - 258 - - - - - 0 - 0 - - - - - 0 - 0 - - - - - QLayout::SetMinimumSize - - - - - - 0 - 0 - - - - Select Country - - - - - - - 0 - 0 - - - - In order to buy tracks from Amazon Store, you need to select your country of residence. - - - true - - - - - - - - 0 - 0 - - - - If you do not want Amarok to send this data to Amazon, select "none" in the box below. In this case Amazon Store will not work. - - - true - - - - - - - Select your country in the box below: - - - true - - - - - - - - 0 - 0 - - - - - France - - - - - Austria, Germany, Switzerland - - - - - Japan - - - - - United Kingdom - - - - - United States - - - - - Italy - - - - - Spain - - - - - none of the above (store won't work) - - - - - - - - Press this button to save your preferred settings, and log on to Amazon Store using the provided data: - - - true - - - - - - - - 0 - 0 - - - - Save and Log on to Amazon Store - - - - - - - - - - - diff --git a/amarok/src/services/amazon/CMakeLists.txt b/amarok/src/services/amazon/CMakeLists.txt deleted file mode 100644 index d3d7705b..00000000 --- a/amarok/src/services/amazon/CMakeLists.txt +++ /dev/null @@ -1,68 +0,0 @@ -include_directories( - ../ - ../../ - ../../core-impl/collections - ../../core-impl/collections/support - ../../statusbar - ${CMAKE_CURRENT_BINARY_DIR}/../../.. - ${KDE4_INCLUDE_DIR} - ${QT_INCLUDES} ) - -add_subdirectory( images ) - -########### next target ############### - -set( amarok_service_amazonstore_PART_SRCS - AmazonCollection.cpp - AmazonConfig.cpp - AmazonInfoParser.cpp - AmazonItemTreeModel.cpp - AmazonItemTreeView.cpp - AmazonParser.cpp - AmazonMeta.cpp - AmazonShoppingCart.cpp - AmazonShoppingCartDialog.cpp - AmazonShoppingCartItem.cpp - AmazonShoppingCartModel.cpp - AmazonShoppingCartView.cpp - AmazonStore.cpp - AmazonUrlRunner.cpp - AmazonWantCountryWidget.cpp - AmazonConfigWidget.ui - AmazonShoppingCartDialog.ui - AmazonWantCountryWidget.ui -) - -kde4_add_plugin( amarok_service_amazonstore ${amarok_service_amazonstore_PART_SRCS} ) - -target_link_libraries( amarok_service_amazonstore - amarokcore - amaroklib - amarokpud - ${KDE4_KDECORE_LIBS} - ${KDE4_KDEUI_LIBS} - ${KDE4_KUTILS_LIBS} - ${KDE4_KIO_LIBS} - ${KDE4_THREADWEAVER_LIBS} -) - -install(TARGETS amarok_service_amazonstore DESTINATION ${PLUGIN_INSTALL_DIR} ) - -########### next target ############### - -set(kcm_amarok_service_amazonstore_PART_SRCSS - AmazonSettingsModule.cpp - AmazonConfig.cpp - AmazonConfigWidget.ui -) - -kde4_add_plugin( kcm_amarok_service_amazonstore ${kcm_amarok_service_amazonstore_PART_SRCSS} ) - -target_link_libraries( kcm_amarok_service_amazonstore ${KDE4_KUTILS_LIBS} ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${KDE4_KDECORE_LIBRARY} ${KDE4_KDEUI_LIBS} ) - -install(TARGETS kcm_amarok_service_amazonstore DESTINATION ${PLUGIN_INSTALL_DIR}) - -########### install files ############### - -install( FILES amarok_service_amazonstore.desktop DESTINATION ${SERVICES_INSTALL_DIR}) -install( FILES amarok_service_amazonstore_config.desktop DESTINATION ${SERVICES_INSTALL_DIR}) diff --git a/amarok/src/services/amazon/amarok_service_amazonstore.desktop b/amarok/src/services/amazon/amarok_service_amazonstore.desktop deleted file mode 100644 index b765ca5c..00000000 --- a/amarok/src/services/amazon/amarok_service_amazonstore.desktop +++ /dev/null @@ -1,108 +0,0 @@ -[Desktop Entry] -Type=Service -ServiceTypes=KPluginInfo -Icon=view-services-amazon-amarok -Name=MP3 Music Store -Name[bs]=MP3 muzička prodavnica -Name[ca]=MP3 Music Store -Name[ca@valencia]=MP3 Music Store -Name[cs]=Obchod s hudbou v MP3 -Name[da]=Musikbutik med MP3 -Name[de]=MP3-Musikladen -Name[el]=MP3 Music Store -Name[en_GB]=MP3 Music Store -Name[es]=Tienda de música MP3 -Name[et]=MP3 muusikapood -Name[fi]=MP3-musiikkikauppa -Name[fr]=Boutique de musiques « MP3 » -Name[ga]=Siopa Ceoil MP3 -Name[gl]=Tenda de música en MP3 -Name[hu]=MP3 Music Store -Name[id]=MP3 Music Store -Name[it]=MP3 Music Store -Name[ja]=MP3 ミュージックストア -Name[km]=ហាង​តន្ត្រី​ MP3 -Name[lt]=MP3 Muzikos parduotuvė -Name[lv]=MP3 mūzikas veikals -Name[nb]=MP3 Musikkbutikk -Name[nl]=MP3 Music-store -Name[pa]=MP3 ਸੰਗੀਤ ਸਟੋਰ -Name[pl]=Sklep z muzyką MP3 -Name[pt]=Loja de Música em MP3 -Name[pt_BR]=MP3 Music Store -Name[ro]=Magazin de muzică MP3 -Name[ru]=Магазин музыки в MP3 -Name[sk]=Obchod s hudbou MP3 -Name[sl]=Trgovina z glasbo MP3 -Name[sr]=МП3 музичка продавница -Name[sr@ijekavian]=МП3 музичка продавница -Name[sr@ijekavianlatin]=MP3 muzička prodavnica -Name[sr@latin]=MP3 muzička prodavnica -Name[sv]=MP3-musikbutik -Name[tr]=MP3 Müzik Mağazası -Name[uk]=Музична крамниця з продажу MP3 -Name[x-test]=xxMP3 Music Storexx -Name[zh_CN]=MP3 音乐商店 -Name[zh_TW]=MP3 音樂商店 -Comment=Access the Amazon MP3 Store directly from Amarok -Comment[bs]=Pristupi Amazonovoj MP3 prodavnici direktno sa Amaroka -Comment[ca]=Accés directe a l'Amazon MP3 Store des de l'Amarok -Comment[ca@valencia]=Accés directe a l'Amazon MP3 Store des de l'Amarok -Comment[cs]=Přistupujte k Amazon MP3 Store přímo z Amaroku -Comment[da]=Tilgå Amazons MP3-butik direkte fra Amarok -Comment[de]=Den MP3-Laden von Amazon direkt aus Amarok heraus nutzen -Comment[el]=Αποκτήστε πρόσβαση στο κατάστημα MP3 της Amazon απευθείας από το Amarok -Comment[en_GB]=Access the Amazon MP3 Store directly from Amarok -Comment[es]=Acceder a la tienda de música MP3 de Amazon directamente desde Amarok -Comment[et]=Amazoni MP3 poe kasutamine otse Amarokist -Comment[fi]=Pääsy Amazonin MP3-kauppaan suoraan Amarokista -Comment[fr]=Accéder à la boutique « MP3 » de Amazon directement depuis Amarok -Comment[ga]=Déan siopadóireacht sa Siopa MP3 Amazon taobh istigh d'Amarok -Comment[gl]=Acceder a tenda de MP3 de Amazon directamente desde Amarok -Comment[hu]=Az Amazon MP3 Store elérése közvetlenül az Amarokból -Comment[id]=Mengakses Amazon MP3 Store langsung dari Amarok -Comment[it]=Accedi al MP3 Store di Amazon direttamente da Amarok -Comment[ja]=Amarok から Amazon MP3 ストアに直接アクセスする -Comment[km]=ចូល​ដំណើរការ​ហាង Amazon MP3 ដោយ​ផ្ទាល់​ពី Amarok -Comment[lt]=Pasiekti Amazon MP3 parduotuvę tiesiai iš Amarok -Comment[lv]=Tiešā piekļuve Amazon MP3 veikalam no Amarok -Comment[nb]=Bruk Amazons M3-butikk direkte fra Amarok -Comment[nl]=De Amazon MP3-store direct vanuit Amarok benaderen -Comment[pl]=Uzyskaj dostęp do sklepu z MP3 Amazon bezpośrednio z Amaroka -Comment[pt]=Aceder à loja de MP3 da Amazon directamente do Amarok -Comment[pt_BR]=Acessa a loja Amazon MP3 diretamente do Amarok -Comment[ro]=Accesați magazinul MP3 Amazon direct din Amarok -Comment[ru]=Доступ к магазину MP3 Amazon напрямую из Amarok -Comment[sk]=Prístup na Amazon MP3 obchod priamo z Amaroku -Comment[sl]=Dostopajte do Amazonove trgovine z MP3-ji neposredno iz Amaroka -Comment[sr]=Приступите Амазоновој МП3 продавници непосредно из Амарока -Comment[sr@ijekavian]=Приступите Амазоновој МП3 продавници непосредно из Амарока -Comment[sr@ijekavianlatin]=Pristupite Amazonovoj MP3 prodavnici neposredno iz Amaroka -Comment[sr@latin]=Pristupite Amazonovoj MP3 prodavnici neposredno iz Amaroka -Comment[sv]=Kom åt Amazons MP3-butik direkt från Amarok -Comment[tr]=Amarok'tan Amazon MP3 Mağazası'na doğrudan erişim -Comment[uk]=Доступ до крамниці з продажу MP3 Amazon безпосередньо з Amarok -Comment[x-test]=xxAccess the Amazon MP3 Store directly from Amarokxx -Comment[zh_CN]=直接从 Amarok 访问亚马逊 MP3 商店 -Comment[zh_TW]=直接到 Amazon 存取 Amazon MP3 商店 - -ServiceTypes=Amarok/Plugin - -X-KDE-Library=amarok_service_amazonstore - -X-KDE-Amarok-authors=Sven Krohlas -X-KDE-Amarok-email=sven@asbest-online.de -X-KDE-Amarok-framework-version=72 -X-KDE-Amarok-name=AmazonStore -X-KDE-Amarok-plugintype=service -X-KDE-Amarok-rank=100 -X-KDE-Amarok-version=1 - -X-KDE-PluginInfo-Author=Sven Krohlas -X-KDE-PluginInfo-Email=sven@asbest-online.de -X-KDE-PluginInfo-Version=1.0 -X-KDE-PluginInfo-Category=Service -X-KDE-PluginInfo-License=GPL -X-KDE-PluginInfo-EnabledByDefault=true -X-KDE-Library=amarok_service_amazonstore -X-KDE-PluginInfo-Name=amarok_service_amazonstore diff --git a/amarok/src/services/amazon/amarok_service_amazonstore_config.desktop b/amarok/src/services/amazon/amarok_service_amazonstore_config.desktop deleted file mode 100644 index 49fc6f0c..00000000 --- a/amarok/src/services/amazon/amarok_service_amazonstore_config.desktop +++ /dev/null @@ -1,52 +0,0 @@ -[Desktop Entry] -Icon=view-services-amazon-amarok -Type=Service -ServiceTypes=Amarok/Plugin -X-KDE-ServiceTypes=KCModule - -X-KDE-Library=kcm_amarok_service_amazonstore -X-KDE-ParentApp=amarok_service_amazonstore -X-KDE-ParentComponents=amarok_service_amazonstore - -Name=Amazon Store Service Config -Name[bs]=Postavke usluga Amazon prodavnice -Name[ca]=Configuració del servei d'Amazon Store -Name[ca@valencia]=Configuració del servei d'Amazon Store -Name[cs]=Nastavení služby Amazon Store -Name[da]=Konfiguration af Amazon Store-tjenesten -Name[de]=Einrichtung von Amazon -Name[el]=Διαμόρφωση υπηρεσίας καταστήματος Amazon -Name[en_GB]=Amazon Store Service Config -Name[es]=Configurar servicio de Amazon Store -Name[et]=Amazoni poe teenuse seadistamine -Name[fi]=Amazon-verkkokaupan määritykset -Name[fr]=Configuration des services de la boutique Amazon -Name[ga]=Cumraíocht Sheirbhís Siopa Amazon -Name[gl]=Configuración do servizo da tenda de Amazon -Name[hu]=Az Amazon Store szolgáltatás beállítása -Name[id]=Konfig Layanan Amazon Store -Name[it]=Configurazione servizio Amazon Store -Name[ja]=Amazon ストアサービスの設定 -Name[km]=កំណត់​រចនាសម្ព័ន្ធ​សេវា​រក្សាទុក Amazon -Name[lt]=Amazon parduotuvės tarnybos nustatymai -Name[lv]=Amazon veikala pakalpojuma konfigurācija -Name[nb]=Innstillinger for AmazonStore-tjenesten -Name[nl]=Amazon-store service instelling -Name[pa]=ਐਮੇਜ਼ੋਨ ਸਟੋਰ ਸਰਵਿਸ ਸੰਰਚਨਾ -Name[pl]=Ustawienia usługi sklepu Amazon -Name[pt]=Configuração do Serviço da Loja Amazon -Name[pt_BR]=Configuração do serviço Amazon Store -Name[ro]=Configurare serviciu Magazin Amazon -Name[ru]=Настройка службы магазина Amazon -Name[sk]=Nastavenie služby Amazon Store -Name[sl]=Nastavitev storitve Amazon Store -Name[sr]=Постава Амазоновог складишног сервиса -Name[sr@ijekavian]=Постава Амазоновог складишног сервиса -Name[sr@ijekavianlatin]=Postava Amazonovog skladišnog servisa -Name[sr@latin]=Postava Amazonovog skladišnog servisa -Name[sv]=Inställning av Amazon butikstjänst -Name[tr]=Amazon Mağazası Hizmet Yapılandırması -Name[uk]=Налаштування служби крамниці Amazon -Name[x-test]=xxAmazon Store Service Configxx -Name[zh_CN]=亚马逊商店服务配置 -Name[zh_TW]=Amazon 商店服務設定 diff --git a/amarok/src/services/amazon/images/CMakeLists.txt b/amarok/src/services/amazon/images/CMakeLists.txt deleted file mode 100644 index 88266539..00000000 --- a/amarok/src/services/amazon/images/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -install( - FILES - hover_info_amazon.png - DESTINATION ${DATA_INSTALL_DIR}/amarok/images -) diff --git a/amarok/src/services/amazon/images/hover_info_amazon.png b/amarok/src/services/amazon/images/hover_info_amazon.png deleted file mode 100644 index 3772e68d..00000000 Binary files a/amarok/src/services/amazon/images/hover_info_amazon.png and /dev/null differ diff --git a/amarok/src/services/amazon/images/hover_info_amazon.svg b/amarok/src/services/amazon/images/hover_info_amazon.svg deleted file mode 100644 index 9d07bb54..00000000 --- a/amarok/src/services/amazon/images/hover_info_amazon.svg +++ /dev/null @@ -1,101 +0,0 @@ - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - diff --git a/amarok/src/services/ampache/AddServerDialog.cpp b/amarok/src/services/ampache/AddServerDialog.cpp deleted file mode 100644 index cf888b8a..00000000 --- a/amarok/src/services/ampache/AddServerDialog.cpp +++ /dev/null @@ -1,110 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Ian Monroe * - * - * This program 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 2 of the License, or (at your option) version 3 or * - * any later version accepted by the membership of KDE e.V. (or its successor approved * - * by the membership of KDE e.V.), which shall act as a proxy defined in Section 14 of * - * version 3 of the license. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "AddServerDialog.h" - -#include "AmpacheAccountLogin.h" -#include "ui_NewServerWidget.h" - -#include - -AddServerDialog::AddServerDialog() - : KDialog() - , m_widgets( new Ui::NewServerWidget ) -{ - QWidget* widget = new QWidget(); - m_widgets->setupUi(widget); - setMainWidget(widget); - - m_widgets->verifyButton->setEnabled(false); - setCaption(i18n("Add new Ampache server")); - enableButtonOk(false); - - connect( m_widgets->verifyButton, SIGNAL(released()), this, SLOT(verifyData())); - QList inputs; - inputs << m_widgets->nameLineEdit << m_widgets->serverAddressLineEdit - << m_widgets->userNameLineEdit << m_widgets-> passwordLineEdit; - foreach(QObject* line, inputs) - connect( line, SIGNAL(textEdited(QString)), this, SLOT(anyTextEdited())); -} - -AddServerDialog::~AddServerDialog() -{ - delete m_widgets; -} - -void -AddServerDialog::anyTextEdited() -{ - bool minimumData = (!(name().isEmpty() || url().isEmpty() - || password().isEmpty() - || username().isEmpty() )); - enableButtonOk(minimumData); - m_widgets->verifyButton->setEnabled(minimumData); -} - -void AddServerDialog::verifyData() -{ - m_widgets->verifyButton->setEnabled(false); - delete m_login; //should always be null at this point. - m_login = new AmpacheAccountLogin( url(), username(), password(), this ); - connect(m_login, SIGNAL(finished()), this, SLOT(loginResult())); -} - -void AddServerDialog::loginResult() -{ - QLabel* label = m_widgets->verifyLabel; - QPalette pal = label->palette(); - if( m_login->authenticated() ) - { - label->setText( i18n("Successfully connected") ); - pal.setColor( QPalette::WindowText, Qt::darkGreen ); - } - else - { - label->setText( i18n("Connection failure") ); - pal.setColor( QPalette::WindowText, Qt::red ); - } - label->setPalette(pal); - delete m_login; - m_widgets->verifyButton->setEnabled(true); -} - -QString -AddServerDialog::name() -{ - return m_widgets->nameLineEdit->text(); -} - -QString -AddServerDialog::url() -{ - return m_widgets->serverAddressLineEdit->text(); -} - -QString -AddServerDialog::password() -{ - return m_widgets->passwordLineEdit->text(); -} - -QString -AddServerDialog::username() -{ - return m_widgets->userNameLineEdit->text(); -} diff --git a/amarok/src/services/ampache/AddServerDialog.h b/amarok/src/services/ampache/AddServerDialog.h deleted file mode 100644 index b22004a1..00000000 --- a/amarok/src/services/ampache/AddServerDialog.h +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Ian Monroe * - * - * This program 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 2 of the License, or (at your option) version 3 or * - * any later version accepted by the membership of KDE e.V. (or its successor approved * - * by the membership of KDE e.V.), which shall act as a proxy defined in Section 14 of * - * version 3 of the license. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef ADDSERVERDIALOG_H -#define ADDSERVERDIALOG_H - -#include -#include - -namespace Ui -{ - class NewServerWidget; -} - -class AmpacheAccountLogin; - -class AddServerDialog : public KDialog -{ - Q_OBJECT - public: - AddServerDialog(); - ~AddServerDialog(); - QString name(); - QString password(); - QString username(); - QString url(); - private slots: - void anyTextEdited(); - void verifyData(); - void loginResult(); - private: - Ui::NewServerWidget* m_widgets; - QPointer m_login; -}; - -#endif // ADDSERVERDIALOG_H diff --git a/amarok/src/services/ampache/AmpacheAccountLogin.cpp b/amarok/src/services/ampache/AmpacheAccountLogin.cpp deleted file mode 100644 index d17babee..00000000 --- a/amarok/src/services/ampache/AmpacheAccountLogin.cpp +++ /dev/null @@ -1,280 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * (c) 2010 Ian Monroe * - * (c) 2013 Ralf Engels * - * * - * This program 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 2 of the License, or (at your option) version 3 or * - * any later version accepted by the membership of KDE e.V. (or its successor approved * - * by the membership of KDE e.V.), which shall act as a proxy defined in Section 14 of * - * version 3 of the license. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - - -#include "AmpacheAccountLogin.h" - -#include "core/support/Amarok.h" -#include "core/support/Components.h" -#include "core/support/Debug.h" - -#include -#include -#include - -#include -#include -#include - - -AmpacheAccountLogin::AmpacheAccountLogin( const QString& url, const QString& username, const QString& password, QWidget* parent ) - : QObject(parent) - , m_authenticated( false ) - , m_server( url ) - , m_username( username ) - , m_password( password ) - , m_sessionId( QString() ) - , m_lastRequest( 0 ) -{ - reauthenticate(); - -} - - -AmpacheAccountLogin::~AmpacheAccountLogin() -{ - -} - -void -AmpacheAccountLogin::reauthenticate() -{ - DEBUG_BLOCK - - // We need to check the version of Ampache we are attempting to authenticate against, as this changes how we deal with it - KUrl url = getRequestUrl( "ping" ); - - debug() << "Verifying Ampache Version Using: " << url.url(); - - m_lastRequest = The::networkAccessManager()->getData( url, this, - SLOT(authenticate(KUrl,QByteArray,NetworkAccessManagerProxy::Error)) ); - - if( !m_lastRequest ) - emit finished(); -} - -void -AmpacheAccountLogin::authenticate( const KUrl &requestUrl, QByteArray data, NetworkAccessManagerProxy::Error e ) -{ - if( !m_lastRequest ) - return; - - QCA::Initializer init; - - DEBUG_BLOCK - Q_UNUSED( requestUrl ); - - QDomDocument doc; - doc.setContent( data ); - - if( !generalVerify( doc, e ) ) - return; - - // so lets figure out what we got here: - debug() << "Version reply: " << data; - int version = getVersion( doc ); - - KUrl url = getRequestUrl( "handshake" ); - QString timestamp = QString::number( QDateTime::currentDateTime().toTime_t() ); - QString passPhrase; - - // We need to use different authentication strings depending on the version of ampache - if( version > 350000 ) - { - - - - debug() << "New Password Scheme " << version; - url.addQueryItem( "version", "350001" ); - - QCA::Hash sha256Hash( "sha256" ); - sha256Hash.update( m_password.toUtf8() ); - QString hashedPassword = QCA::arrayToHex( sha256Hash.final().toByteArray() ); - - QString rawHandshake = timestamp + hashedPassword; - sha256Hash.clear(); - sha256Hash.update( rawHandshake.toUtf8() ); - - passPhrase = QCA::arrayToHex( sha256Hash.final().toByteArray() ); - - } - else - { - debug() << "Version Older than 35001 Generated MD5 Auth " << version; - - QString rawHandshake = timestamp + m_password; - QCA::Hash md5Hash( "md5" ); - - md5Hash.update( rawHandshake.toUtf8() ); - passPhrase = QCA::arrayToHex( md5Hash.final().toByteArray() ); - } - - url.addQueryItem( "timestamp", timestamp ); - url.addQueryItem( "auth", passPhrase ); - - debug() << "Authenticating with string: " << url.url() << passPhrase; - - // TODO: Amarok::Components::logger()->newProgressOperation( m_xmlDownloadJob, i18n( "Authenticating with Ampache" ) ); - m_lastRequest = The::networkAccessManager()->getData( url, this, - SLOT(authenticationComplete(KUrl,QByteArray,NetworkAccessManagerProxy::Error)) ); - - if( !m_lastRequest ) - emit finished(); -} - -void AmpacheAccountLogin::authenticationComplete( const KUrl &requestUrl, QByteArray data, NetworkAccessManagerProxy::Error e ) -{ - if( !m_lastRequest ) - return; - - DEBUG_BLOCK - Q_UNUSED( requestUrl ); - - QDomDocument doc; - doc.setContent( data ); - - if( !generalVerify( doc, e ) ) - return; - - // so lets figure out what we got here: - debug() << "Authentication reply: " << data; - QDomElement root = doc.firstChildElement("root"); - - //find status code: - QDomElement element = root.firstChildElement("auth"); - if( element.isNull() ) - { - // Default the Version down if it didn't work - debug() << "authenticationComplete failed"; - KMessageBox::error( qobject_cast(parent()), - i18n( "Authentication failed." ), - i18n( "Authentication Error" ) ); - emit finished(); - return; - } - - m_sessionId = element.text(); - m_authenticated = true; - - emit loginSuccessful(); - emit finished(); -} - -int -AmpacheAccountLogin::getVersion( const QDomDocument& doc ) const -{ - DEBUG_BLOCK - - QDomElement root = doc.firstChildElement("root"); - //is this an error? - QDomElement error = root.firstChildElement("error"); - //find status code: - QDomElement version = root.firstChildElement("version"); - - // It's OK if we get a null response from the version, that just means we're dealing with an older version - if( !error.isNull() ) - { - // Default the Version down if it didn't work - debug() << "getVersion error: " << error.text(); - return 100000; - } - else if( !version.isNull() ) - { - debug() << "getVersion returned: " << version.text(); - return version.text().toInt(); - } - else - { - debug() << "getVersion no version"; - return 0; - } -} - -bool -AmpacheAccountLogin::generalVerify( const QDomDocument& doc, NetworkAccessManagerProxy::Error e ) -{ - Q_ASSERT( m_lastRequest ); - - if( m_lastRequest->attribute( QNetworkRequest::HttpStatusCodeAttribute ).toInt() != 200 ) - { - debug() << "server response code:" << - m_lastRequest->attribute( QNetworkRequest::HttpStatusCodeAttribute ).toInt() << - m_lastRequest->attribute( QNetworkRequest::HttpReasonPhraseAttribute ).toString(); - // KMessageBox::error( qobject_cast(parent()), domError.text(), i18n( "Authentication Error" ) ); - emit finished(); - return false; - } - - if( e.code != QNetworkReply::NoError ) - { - debug() << "authenticate Error:" << e.description; - emit finished(); - return false; - } - - QDomElement root = doc.firstChildElement("root"); - QDomElement error = root.firstChildElement("error"); - - if( !error.isNull() ) - { - // Default the Version down if it didn't work - debug() << "generalVerify error: " << error.text(); - KMessageBox::error( qobject_cast(parent()), error.text(), i18n( "Authentication Error" ) ); - emit finished(); - return false; - } - - return true; -} - -KUrl -AmpacheAccountLogin::getRequestUrl( const QString &action ) const -{ - //lets keep this around for now if we want to allow people to add a service that prompts for stuff - /* But comment it out since the AmpacheQueryMaker does not do this - if ( m_server.isEmpty() || m_password.isEmpty() ) - { - KPasswordDialog dlg( 0 , KPasswordDialog::ShowUsernameLine ); - dlg.setPrompt( i18n( "Enter the server name and a password" ) ); - if( !dlg.exec() ) - return KUrl(); //the user canceled - - m_server = KUrl( dlg.username() ).url(); - m_password = dlg.password(); - } - */ - - QString path = m_server + "/server/xml.server.php"; - - if( !path.startsWith("http://") && !path.startsWith("https://") ) - path = "http://" + path; - - KUrl url( path ); - - if( !action.isEmpty() ) - url.addQueryItem( "action", action ); - - if( !m_username.isEmpty() ) - url.addQueryItem( "user", m_username ); - - return url; -} - -#include "moc_AmpacheAccountLogin.cpp" diff --git a/amarok/src/services/ampache/AmpacheAccountLogin.h b/amarok/src/services/ampache/AmpacheAccountLogin.h deleted file mode 100644 index c09cb942..00000000 --- a/amarok/src/services/ampache/AmpacheAccountLogin.h +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * (c) 2010 Ian Monroe * - * (c) 2013 Ralf Engels * - * * - * This program 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 2 of the License, or (at your option) version 3 or * - * any later version accepted by the membership of KDE e.V. (or its successor approved * - * by the membership of KDE e.V.), which shall act as a proxy defined in Section 14 of * - * version 3 of the license. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - - -#ifndef AMPACHEACCOUNTLOGIN_H -#define AMPACHEACCOUNTLOGIN_H - -#include "NetworkAccessManagerProxy.h" - -#include -#include - -#include -#include -class QNetworkReply; - -#ifdef MAKE_AMPACHE_ACCOUNT_LOGIN_LIB -#define AMPACHE_ACCOUNT_EXPORT KDE_EXPORT -#else -#define AMPACHE_ACCOUNT_EXPORT KDE_IMPORT -#endif - -class AMPACHE_ACCOUNT_EXPORT AmpacheAccountLogin : public QObject -{ - Q_OBJECT - public: - AmpacheAccountLogin ( const QString& url, const QString& username, const QString& password, QWidget* parent = 0 ); - ~AmpacheAccountLogin(); - QString server() const { return m_server; } - QString sessionId() const { return m_sessionId; } - bool authenticated() const { return m_authenticated; } - void reauthenticate(); - - signals: - void loginSuccessful(); //!authentication was successful - void finished(); //!authentication was or was not successful - - private slots: - void authenticate( const KUrl &url, QByteArray data, NetworkAccessManagerProxy::Error e ); - void authenticationComplete( const KUrl &url, QByteArray data, NetworkAccessManagerProxy::Error e ); - - private: - int getVersion( const QDomDocument& doc ) const; - - /** Does general response verification. - Emits finished if something is fishy. - @returns true if the check was successful. - */ - bool generalVerify( const QDomDocument& doc, NetworkAccessManagerProxy::Error e ); - - /** Returns the base url. - You would need to add query items to use it. */ - KUrl getRequestUrl( const QString &action = QString() ) const; - - bool m_authenticated; - QString m_server; - QString m_username; - QString m_password; - QString m_sessionId; - - QNetworkReply* m_lastRequest; -}; - -#endif // AMPACHEACCOUNTLOGIN_H diff --git a/amarok/src/services/ampache/AmpacheConfig.cpp b/amarok/src/services/ampache/AmpacheConfig.cpp deleted file mode 100644 index 9d7379a5..00000000 --- a/amarok/src/services/ampache/AmpacheConfig.cpp +++ /dev/null @@ -1,122 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "AmpacheConfig.h" - -#include -#include -#include -#include - -AmpacheConfig::AmpacheConfig() -{ - load(); -} - -void -AmpacheConfig::load() -{ - KConfigGroup config = KGlobal::config()->group( "Service_Ampache" ); - - int serverIndex = 0; - QString serverEntry = "server" + QString::number( serverIndex ); - - while ( config.hasKey( serverEntry ) ) - { - QStringList list = config.readEntry(serverEntry, QStringList() ); - if ( list.isEmpty() ) - continue; - - AmpacheServerEntry entry; - entry.name = list.takeFirst(); - entry.url = list.takeFirst(); - entry.username = list.takeFirst(); - entry.password = list.takeFirst(); - entry.addToCollection = false; //FIXME - - m_servers.append( entry ); - - serverIndex++; - serverEntry = "server" + QString::number( serverIndex ); - } -} - -void -AmpacheConfig::save() -{ - //delete all entries to make sure the indexes are correct - KConfigGroup config = KGlobal::config()->group( "Service_Ampache" ); - - kDebug( 14310 ) << "saving to config file " << KGlobal::config()->name() ; - - int serverIndex = 0; - QString serverEntry = "server" + QString::number( serverIndex ); - - while ( config.hasKey ( serverEntry ) ) - { - kDebug( 14310 ) << "deleting " << serverEntry; - config.deleteEntry( serverEntry ); - serverIndex++; - serverEntry = "server" + QString::number( serverIndex ); - } - - for( int i = 0; i < m_servers.size(); i++ ) - { - AmpacheServerEntry entry = m_servers.at( i ); - QStringList list; - - list << entry.name; - list << entry.url; - list << entry.username; - list << entry.password; - - serverEntry = "server" + QString::number( i ); - kDebug( 14310 ) << "adding " << serverEntry; - config.writeEntry( serverEntry, list ); - } -} - -int -AmpacheConfig::serverCount() -{ - return m_servers.size(); -} - -AmpacheServerList -AmpacheConfig::servers() -{ - return m_servers; -} - -void -AmpacheConfig::addServer( const AmpacheServerEntry &server ) -{ - m_servers.append( server ); -} - -void -AmpacheConfig::removeServer( int index ) -{ - m_servers.removeAt( index ); -} - -void -AmpacheConfig::updateServer( int index, const AmpacheServerEntry & server ) -{ - m_servers.removeAt( index ); - m_servers.insert( index, server ); -} - diff --git a/amarok/src/services/ampache/AmpacheConfig.h b/amarok/src/services/ampache/AmpacheConfig.h deleted file mode 100644 index b2e8d343..00000000 --- a/amarok/src/services/ampache/AmpacheConfig.h +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMPACHECONFIG_H -#define AMPACHECONFIG_H - -#include -#include - -class AmpacheServerEntry { - -public: - QString name; - QString url; - QString username; - QString password; - bool addToCollection; -}; - -typedef QList< AmpacheServerEntry > AmpacheServerList; - -/** -A class for accessing the Ampache plugin configuration - - @author -*/ -class AmpacheConfig{ -public: - - AmpacheConfig(); - void load(); - void save(); - - int serverCount(); - AmpacheServerList servers(); - - void addServer( const AmpacheServerEntry &server ); - void removeServer( int index); - void updateServer( int index, const AmpacheServerEntry &server ); - -private: - - bool m_hasChanged; - AmpacheServerList m_servers; - - // Disable copy constructor and assignment - AmpacheConfig( const AmpacheConfig& ); - AmpacheConfig& operator=( const AmpacheConfig& ); - -}; - -#endif diff --git a/amarok/src/services/ampache/AmpacheConfigWidget.ui b/amarok/src/services/ampache/AmpacheConfigWidget.ui deleted file mode 100644 index af8a2c6b..00000000 --- a/amarok/src/services/ampache/AmpacheConfigWidget.ui +++ /dev/null @@ -1,77 +0,0 @@ - - - AmpacheConfigWidget - - - - 0 - 0 - 608 - 197 - - - - - 0 - 0 - - - - - - - Add Server - - - - - - - Remove Server - - - - - - - 4 - - - false - - - 20 - - - 20 - - - false - - - - Name - - - - - Server Address - - - - - Username - - - - - Password - - - - - - - - - diff --git a/amarok/src/services/ampache/AmpacheMeta.cpp b/amarok/src/services/ampache/AmpacheMeta.cpp deleted file mode 100644 index a104d10c..00000000 --- a/amarok/src/services/ampache/AmpacheMeta.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Casey Link * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "AmpacheMeta.h" -#include "core/support/Debug.h" - -using namespace Meta; - -//// AmpacheAlbum //// - -AmpacheAlbum::AmpacheAlbum( const QString &name ) - : ServiceAlbumWithCover( name ) -{} - -AmpacheAlbum::AmpacheAlbum(const QStringList & resultRow) - : ServiceAlbumWithCover( resultRow ) -{} - -AmpacheAlbum::~ AmpacheAlbum() -{} - -void AmpacheAlbum::setCoverUrl( const QString &coverURL ) -{ - m_coverURL = coverURL; -} - -QString AmpacheAlbum::coverUrl( ) const -{ - return m_coverURL; -} - -void -AmpacheAlbum::addInfo( const AmpacheAlbum::AmpacheAlbumInfo &info ) -{ - m_ampacheAlbums.insert( info.id, info ); -} - -AmpacheAlbum::AmpacheAlbumInfo -AmpacheAlbum::getInfo( int id ) const -{ - if( !m_ampacheAlbums.contains( id ) ) - { - AmpacheAlbumInfo info; - info.id = -1; - info.discNumber = -1; - info.year = -1; - return info; - } - return m_ampacheAlbums.value( id ); -} - -QString -AmpacheTrack::notPlayableReason() const -{ - return networkNotPlayableReason(); -} diff --git a/amarok/src/services/ampache/AmpacheMeta.h b/amarok/src/services/ampache/AmpacheMeta.h deleted file mode 100644 index 99c20eb8..00000000 --- a/amarok/src/services/ampache/AmpacheMeta.h +++ /dev/null @@ -1,138 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Casey Link * - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * (c) 2013 Ralf Engels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMPACHEMETA_H -#define AMPACHEMETA_H - -#include "ServiceBase.h" -#include "ServiceMetaBase.h" -#include "ServiceAlbumCoverDownloader.h" - -#include - -#include -#include -#include -#include -#include - - -namespace Meta -{ - -class AmpacheTrack : public ServiceTrack -{ - -public: - explicit AmpacheTrack( const QString& title, ServiceBase * service = 0 ) - : ServiceTrack( title ) - , m_service( service ) - , m_discNumber( 0 ) - { - Q_UNUSED(m_service); // might be used again later - } - - virtual QString sourceName() { return "Ampache"; } - virtual QString sourceDescription() { return "The Ampache music server project: http://Ampache.org"; } - virtual QPixmap emblem() { return QPixmap( KStandardDirs::locate( "data", "amarok/images/emblem-ampache.png" ) ); } - virtual QString scalableEmblem() { return KStandardDirs::locate( "data", "amarok/images/emblem-ampache-scalable.svgz" ); } - virtual QString notPlayableReason() const; - - virtual int discNumber() const { return m_discNumber; } - virtual void setDiscNumber( int newDiscNumber ) { m_discNumber = newDiscNumber; } - -private: - ServiceBase * m_service; - - int m_discNumber; -}; - - -class AmpacheAlbum : public ServiceAlbumWithCover -{ -private: - QString m_coverURL; - -public: - AmpacheAlbum( const QString &name ); - AmpacheAlbum( const QStringList &resultRow ); - - ~AmpacheAlbum(); - - virtual QString downloadPrefix() const { return "ampache"; } - - virtual void setCoverUrl( const QString &coverURL ); - virtual QString coverUrl() const; - - bool operator==( const Meta::Album &other ) const - { - return name() == other.name(); - } - - QList ids() const { return m_ampacheAlbums.keys(); } - - struct AmpacheAlbumInfo { - int id; - int discNumber; - int year; - }; - - /** Add an ampache album to this Amarok album. - Warning: The album will not be automatically - registered with the new id, same as with setId - */ - void addInfo( const AmpacheAlbumInfo &info ); - - /** Get's an album info for a specific ID */ - AmpacheAlbumInfo getInfo( int id ) const; - -private: - - // the unique album key of ampache contains discNumber and year - // the Amarok key only name and artist - // so this AmpacheAlbum object represents a number of ampache albums. - QHash m_ampacheAlbums; -}; - -class AmpacheArtist : public ServiceArtist -{ - private: - QString m_coverURL; - - public: - AmpacheArtist( const QString &name, ServiceBase * service ) - : ServiceArtist( name ) - , m_service( service ) - {} - - virtual bool isBookmarkable() const { return true; } - virtual QString collectionName() const { return m_service->name(); } - virtual bool simpleFiltering() const { return true; } - - bool operator==( const Meta::Artist &other ) const - { - return name() == other.name(); - } - - private: - ServiceBase * m_service; -}; - -} - -#endif // End include guard diff --git a/amarok/src/services/ampache/AmpacheService.cpp b/amarok/src/services/ampache/AmpacheService.cpp deleted file mode 100644 index 76573e48..00000000 --- a/amarok/src/services/ampache/AmpacheService.cpp +++ /dev/null @@ -1,145 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "AmpacheService" - -#include "AmpacheService.h" - -#include "AmpacheConfig.h" -#include "AmpacheAccountLogin.h" - -#include "core/support/Amarok.h" -#include "core/support/Components.h" -#include "core/interfaces/Logger.h" -#include "browsers/SingleCollectionTreeItemModel.h" -#include "core-impl/collections/support/CollectionManager.h" -#include -#include "core/support/Debug.h" - -#ifdef HAVE_LIBLASTFM - #include "LastfmInfoParser.h" -#endif - -#include - -AMAROK_EXPORT_SERVICE_PLUGIN( ampache, AmpacheServiceFactory ) - -AmpacheServiceFactory::AmpacheServiceFactory( QObject *parent, const QVariantList &args ) - : ServiceFactory( parent, args ) -{ - KPluginInfo pluginInfo( "amarok_service_ampache.desktop", "services" ); - pluginInfo.setConfig( config() ); - m_info = pluginInfo; -} - -void AmpacheServiceFactory::init() -{ - //read config and create the needed number of services - AmpacheConfig config; - AmpacheServerList servers = config.servers(); - m_initialized = true; - - for( int i = 0; i < servers.size(); i++ ) - { - AmpacheServerEntry server = servers.at( i ); - ServiceBase* service = new AmpacheService( this, "Ampache (" + server.name + ')', server.url, server. username, server.password ); - emit newService( service ); - } -} - -QString -AmpacheServiceFactory::name() -{ - return "Ampache"; -} - -KConfigGroup -AmpacheServiceFactory::config() -{ - return Amarok::config( "Service_Ampache" ); -} - -bool -AmpacheServiceFactory::possiblyContainsTrack(const KUrl & url) const -{ - AmpacheConfig config; - foreach( const AmpacheServerEntry &server, config.servers() ) - { - if ( url.url().contains( server.url, Qt::CaseInsensitive ) ) - return true; - } - - return false; -} - - -AmpacheService::AmpacheService( AmpacheServiceFactory* parent, const QString & name, const QString &url, const QString &username, const QString &password ) - : ServiceBase( name, parent ) - , m_infoParser( 0 ) - , m_collection( 0 ) - , m_ampacheLogin(new AmpacheAccountLogin(url, username, password, this)) -{ - DEBUG_BLOCK - connect(m_ampacheLogin, SIGNAL(loginSuccessful()), this, SLOT(onLoginSuccessful())); - setShortDescription( i18n( "Amarok frontend for your Ampache server" ) ); - setIcon( KIcon( "view-services-ampache-amarok" ) ); - setLongDescription( i18n( "Use Amarok as a seamless frontend to your Ampache server. This lets you browse and play all the Ampache contents from within Amarok." ) ); - setImagePath( KStandardDirs::locate( "data", "amarok/images/hover_info_ampache.png" ) ); -#ifdef HAVE_LIBLASTFM - m_infoParser = new LastfmInfoParser(); -#endif -} - -AmpacheService::~AmpacheService() -{ - CollectionManager::instance()->removeTrackProvider( m_collection ); - delete m_collection; - m_ampacheLogin->deleteLater(); -} - -void -AmpacheService::polish() -{ - m_bottomPanel->hide(); - setInfoParser( m_infoParser ); - - /*if ( !m_authenticated ) - authenticate( );*/ -} - -void -AmpacheService::reauthenticate() -{ - m_ampacheLogin->reauthenticate(); - // it would make sense here to clean the complete cache - // information from a server might get outdated. -} - - -void -AmpacheService::onLoginSuccessful() -{ - m_collection = new Collections::AmpacheServiceCollection( this, m_ampacheLogin->server(), m_ampacheLogin->sessionId() ); - // connect( m_collection, SIGNAL(authenticationNeeded()), SLOT(authenticate()) ); - - CollectionManager::instance()->addTrackProvider( m_collection ); - QList levels; - levels << CategoryId::Artist << CategoryId::Album; - setModel( new SingleCollectionTreeItemModel( m_collection, levels ) ); - setServiceReady( true ); -} - -#include "moc_AmpacheService.cpp" diff --git a/amarok/src/services/ampache/AmpacheService.h b/amarok/src/services/ampache/AmpacheService.h deleted file mode 100644 index bf9de579..00000000 --- a/amarok/src/services/ampache/AmpacheService.h +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMPACHESERVICE_H -#define AMPACHESERVICE_H - -#include "AmpacheServiceCollection.h" -#include "ServiceBase.h" - -#include - -class AmpacheAccountLogin; - -class AmpacheServiceFactory: public ServiceFactory -{ - Q_OBJECT - - public: - AmpacheServiceFactory( QObject *parent, const QVariantList &args ); - virtual ~AmpacheServiceFactory() {} - - virtual bool possiblyContainsTrack( const KUrl &url ) const; - - virtual void init(); - virtual QString name(); - virtual KConfigGroup config(); -}; - - -/** -A service for displaying, previewing and downloading music from Ampache music servers - - @author -*/ -class AmpacheService : public ServiceBase -{ - -Q_OBJECT - -public: - explicit AmpacheService( AmpacheServiceFactory* parent, const QString &name, - const QString &url = QString(), const QString &username = QString(), - const QString &password = QString() ); - - ~AmpacheService(); - - void polish(); - void reauthenticate(); - - virtual Collections::Collection * collection() { return m_collection; } - -private slots: - void onLoginSuccessful(); - -private: - InfoParserBase *m_infoParser; - Collections::AmpacheServiceCollection * m_collection; - QPointer m_ampacheLogin; - - // Disable copy constructor and assignment - AmpacheService( const AmpacheService& ); - AmpacheService& operator=( const AmpacheService& ); -}; - -#endif diff --git a/amarok/src/services/ampache/AmpacheServiceCollection.cpp b/amarok/src/services/ampache/AmpacheServiceCollection.cpp deleted file mode 100644 index 7aee5f9c..00000000 --- a/amarok/src/services/ampache/AmpacheServiceCollection.cpp +++ /dev/null @@ -1,186 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "AmpacheServiceCollection.h" - -#include "AmpacheServiceQueryMaker.h" -#include "NetworkAccessManagerProxy.h" - -#include -#include - -#include -#include - -using namespace Collections; - -AmpacheServiceCollection::AmpacheServiceCollection( ServiceBase *service, - const QString &server, - const QString &sessionId ) - : ServiceCollection( service, "AmpacheCollection", "AmpacheCollection" ) - , m_server( server ) - , m_sessionId( sessionId ) -{ - m_trackForUrlWorker = 0; -} - -AmpacheServiceCollection::~AmpacheServiceCollection() -{ -} - -QueryMaker * -AmpacheServiceCollection::queryMaker() -{ - return new AmpacheServiceQueryMaker( this, m_server, m_sessionId ); -} - -QString -AmpacheServiceCollection::collectionId() const -{ - return "Ampache: " + m_server; -} - -QString -AmpacheServiceCollection::prettyName() const -{ - return i18n( "Ampache Server %1", m_server ); -} - -bool -AmpacheServiceCollection::possiblyContainsTrack( const KUrl &url ) const -{ - return url.url().contains( m_server ); -} - -void -AmpacheServiceCollection::slotAuthenticationNeeded() -{ - emit authenticationNeeded(); -} - -Meta::TrackPtr -AmpacheServiceCollection::trackForUrl( const KUrl &url ) -{ - MetaProxy::TrackPtr trackptr( new MetaProxy::Track( url.url(), MetaProxy::Track::ManualLookup ) ); - AmpacheTrackForUrlWorker *worker = new AmpacheTrackForUrlWorker( url, trackptr, - m_server, m_sessionId, service() ); - connect( worker, SIGNAL(authenticationNeeded()), SLOT(slotAuthenticationNeeded()) ); - ThreadWeaver::Weaver::instance()->enqueue( worker ); - - return Meta::TrackPtr::staticCast( trackptr ); -} - -void AmpacheServiceCollection::slotLookupComplete( const Meta::TrackPtr& ) -{ -} - -void AmpacheTrackForUrlWorker::parseTrack( const QString &xml ) -{ - //so lets figure out what we got here: - QDomDocument doc( "reply" ); - doc.setContent( xml ); - QDomElement root = doc.firstChildElement( "root" ); - QDomElement song = root.firstChildElement( "song" ); - - m_urlTrackId = song.attribute( "id", "0" ).toInt(); - - QDomElement element = song.firstChildElement( "title" ); - - QString title = element.text(); - if ( title.isEmpty() ) title = "Unknown"; - - element = song.firstChildElement( "url" ); - - m_urlTrack = new Meta::AmpacheTrack( title, m_service ); - Meta::TrackPtr trackPtr( m_urlTrack ); - - m_urlTrack->setUidUrl( element.text() ); - m_urlTrack->setId( m_urlTrackId ); - - element = song.firstChildElement( "time" ); - m_urlTrack->setLength( element.text().toInt() * 1000 ); - - element = song.firstChildElement( "track" ); - m_urlTrack->setTrackNumber( element.text().toInt() ); - - QDomElement albumElement = song.firstChildElement( "album" ); - m_urlAlbumId = albumElement.attribute( "id", "0" ).toInt(); - - Meta::AmpacheAlbum *album = new Meta::AmpacheAlbum( albumElement.text() ); - - QDomElement artElement = song.firstChildElement( "art" ); - album->setCoverUrl( artElement.text() ); - - album->addTrack( trackPtr ); - m_urlTrack->setAlbumPtr( Meta::AlbumPtr( album ) ); - - QDomElement artistElement = song.firstChildElement( "artist" ); - Meta::ServiceArtist *artist = new Meta::ServiceArtist( artistElement.text() ); - - Meta::ArtistPtr artistPtr( artist ); - m_urlTrack->setArtist( artistPtr ); - album->setAlbumArtist( artistPtr ); -} - -AmpacheTrackForUrlWorker::AmpacheTrackForUrlWorker( const KUrl &url, - MetaProxy::TrackPtr track, - const QString &server, - const QString &sessionId, - ServiceBase *service ) - : Amarok::TrackForUrlWorker( url ) - , m_proxy( track ) - , m_server( server ) - , m_sessionId( sessionId ) - , m_service( service ) -{ -} - -AmpacheTrackForUrlWorker::~AmpacheTrackForUrlWorker() -{} - -void -AmpacheTrackForUrlWorker::run() -{ - m_urlTrack = 0; - m_urlAlbum = 0; - m_urlArtist = 0; - - m_urlTrackId = 0; - m_urlAlbumId = 0; - m_urlArtistId = 0; - - //send url_to_song to Ampache - - QString requestUrl = - QString( "%1/server/xml.server.php?action=url_to_song&auth=%2&url=%3" ) - .arg( m_server, m_sessionId, QUrl::toPercentEncoding( m_url.url() ) ); - - QNetworkRequest req( requestUrl ); - QNetworkReply *reply = The::networkAccessManager()->get( req ); - - if( reply->waitForReadyRead(-1) ) - { - if( reply->error() == QNetworkReply::ContentAccessDenied ) - { - debug() << "Trying to re-authenticate Ampache.."; - emit authenticationNeeded(); - } - } - parseTrack( reply->readAll() ); - m_track = Meta::TrackPtr( m_urlTrack ); - m_proxy->updateTrack( m_track ); - reply->deleteLater(); -} diff --git a/amarok/src/services/ampache/AmpacheServiceCollection.h b/amarok/src/services/ampache/AmpacheServiceCollection.h deleted file mode 100644 index cc49775c..00000000 --- a/amarok/src/services/ampache/AmpacheServiceCollection.h +++ /dev/null @@ -1,93 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMPACHESERVICECOLLECTION_H -#define AMPACHESERVICECOLLECTION_H - -#include -#include "AmpacheMeta.h" -#include "core/collections/support/TrackForUrlWorker.h" - -class AmpacheTrackForUrlWorker : public Amarok::TrackForUrlWorker -{ - Q_OBJECT - public: - AmpacheTrackForUrlWorker( const KUrl &url, MetaProxy::TrackPtr track, - const QString &server, const QString &sessionId, - ServiceBase *service); - ~AmpacheTrackForUrlWorker(); - virtual void run(); - void parseTrack( const QString &xml ); - signals: - void authenticationNeeded(); - private: - MetaProxy::TrackPtr m_proxy; - int m_urlTrackId; - int m_urlAlbumId; - int m_urlArtistId; - - Meta::AmpacheTrack *m_urlTrack; - Meta::AmpacheAlbum *m_urlAlbum; - Meta::ServiceArtist *m_urlArtist; - - QString m_server; - QString m_sessionId; - - ServiceBase *m_service; -}; - -namespace Collections { - -/** -A collection that dynamically fetches data from a remote location as needed - - @author -*/ -class AmpacheServiceCollection : public ServiceCollection -{ - Q_OBJECT - -public: - AmpacheServiceCollection( ServiceBase *service, const QString &server, - const QString &sessionId ); - - virtual ~AmpacheServiceCollection(); - - virtual QueryMaker *queryMaker(); - - virtual QString collectionId() const; - virtual QString prettyName() const; - - virtual Meta::TrackPtr trackForUrl( const KUrl &url ); - virtual bool possiblyContainsTrack( const KUrl &url ) const; - -signals: - void authenticationNeeded(); - -public slots: - void slotAuthenticationNeeded(); - void slotLookupComplete( const Meta::TrackPtr & ); - -private: - QString m_server; - QString m_sessionId; - - AmpacheTrackForUrlWorker *m_trackForUrlWorker; -}; - -} //namespace Collections - -#endif diff --git a/amarok/src/services/ampache/AmpacheServiceQueryMaker.cpp b/amarok/src/services/ampache/AmpacheServiceQueryMaker.cpp deleted file mode 100644 index b4d2976b..00000000 --- a/amarok/src/services/ampache/AmpacheServiceQueryMaker.cpp +++ /dev/null @@ -1,739 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * Copyright (c) 2007 Adam Pigg * - * Copyright (c) 2007 Casey Link * - * (c) 2013 Ralf Engels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "AmpacheServiceQueryMaker" - -#include "AmpacheServiceQueryMaker.h" - -#include "AmpacheMeta.h" -#include "core/meta/Statistics.h" -#include "core/support/Amarok.h" -#include "core/support/Debug.h" -#include "core/meta/support/MetaConstants.h" -#include "core-impl/collections/support/MemoryMatcher.h" - -#include -#include -#include - -using namespace Collections; - -struct AmpacheServiceQueryMaker::Private -{ - AmpacheServiceCollection* collection; - - QueryMaker::QueryType type; - int maxsize; - - QAtomicInt expectedReplies; - - QString server; - QString sessionId; - QList parentTrackIds; - QList parentAlbumIds; - QList parentArtistIds; - uint dateFilter; - QString artistFilter; - QString albumFilter; - - /** We are collecting the results of the queries and submit them - in one block to ensure that we don't report albums twice - and because the CollectionTreeItemModelBase does not handle - multiple results correctly (which it should). - */ - Meta::AlbumList albumResults; - Meta::ArtistList artistResults; - Meta::TrackList trackResults; -}; - -AmpacheServiceQueryMaker::AmpacheServiceQueryMaker( AmpacheServiceCollection * collection, const QString &server, const QString &sessionId ) - : DynamicServiceQueryMaker() - , d( new Private ) -{ - d->collection = collection; - d->type = QueryMaker::None; - d->maxsize = 0; - d->server = server; - d->sessionId = sessionId; - d->dateFilter = 0; -} - -AmpacheServiceQueryMaker::~AmpacheServiceQueryMaker() -{ - delete d; -} - -void -AmpacheServiceQueryMaker::run() -{ - DEBUG_BLOCK - - if( d->expectedReplies ) // still running an old query - return; - - //naive implementation, fix this - //note: we are not handling filtering yet - - d->collection->acquireReadLock(); - - if ( d->type == QueryMaker::Artist ) - fetchArtists(); - else if( d->type == QueryMaker::Album ) - fetchAlbums(); - else if( d->type == QueryMaker::Track ) - fetchTracks(); - else - warning() << "Requested unhandled query type"; //TODO error handling - - d->collection->releaseLock(); -} - -void -AmpacheServiceQueryMaker::abortQuery() -{ -} - -QueryMaker * -AmpacheServiceQueryMaker::setQueryType( QueryType type ) -{ - d->type = type; - - return this; -} - -QueryMaker* -AmpacheServiceQueryMaker::addMatch( const Meta::TrackPtr &track ) -{ - DEBUG_BLOCK - - const Meta::AmpacheTrack* serviceTrack = dynamic_cast< const Meta::AmpacheTrack * >( track.data() ); - if( serviceTrack ) - { - d->parentTrackIds << serviceTrack->id(); - debug() << "parent id set to: " << d->parentTrackIds; - } - else - { - // searching for something from another collection - //hmm, not sure what to do now - } - - return this; -} - -QueryMaker* -AmpacheServiceQueryMaker::addMatch( const Meta::ArtistPtr &artist, ArtistMatchBehaviour behaviour ) -{ - Q_UNUSED( behaviour ) // TODO - DEBUG_BLOCK - - if( d->parentAlbumIds.isEmpty() ) - { - const Meta::AmpacheArtist* serviceArtist = dynamic_cast< const Meta::AmpacheArtist * >( artist.data() ); - if( serviceArtist ) - { - d->parentArtistIds << serviceArtist->id(); - } - else - { - // searching for something from another collection - if( d->collection->artistMap().contains( artist->name() ) ) - { - serviceArtist = static_cast< const Meta::AmpacheArtist* >( d->collection->artistMap().value( artist->name() ).data() ); - d->parentArtistIds << serviceArtist->id(); - } - else - { - //hmm, not sure what to do now - } - } - } - return this; -} - -QueryMaker * -AmpacheServiceQueryMaker::addMatch( const Meta::AlbumPtr & album ) -{ - DEBUG_BLOCK - const Meta::AmpacheAlbum* serviceAlbum = dynamic_cast< const Meta::AmpacheAlbum * >( album.data() ); - if( serviceAlbum ) - { - d->parentAlbumIds << serviceAlbum->ids(); - debug() << "parent id set to: " << d->parentAlbumIds; - d->parentArtistIds.clear(); - } - else - { - // searching for something from another collection - if( d->collection->albumMap().contains( album ) ) // compares albums by value - { - serviceAlbum = static_cast< const Meta::AmpacheAlbum* >( d->collection->albumMap().value( album ).data() ); - d->parentAlbumIds << serviceAlbum->ids(); - d->parentArtistIds.clear(); - } - else - { - //hmm, not sure what to do now - } - } - - return this; -} - -void -AmpacheServiceQueryMaker::fetchArtists() -{ - DEBUG_BLOCK - - Meta::ArtistList artists; - - // first try the cache - if( !d->parentArtistIds.isEmpty() ) - { - foreach( int artistId, d->parentArtistIds ) - artists << d->collection->artistById( artistId ); - } - - if( !artists.isEmpty() ) - { - debug() << "got" << artists.count() << "artists from the memory collection"; - emit newResultReady( artists ); - emit queryDone(); - return; - } - - KUrl request = getRequestUrl( "artists" ); - - if ( !d->artistFilter.isEmpty() ) - request.addQueryItem( "filter", d->artistFilter ); - - d->expectedReplies.ref(); - The::networkAccessManager()->getData( request, this, - SLOT(artistDownloadComplete(KUrl,QByteArray,NetworkAccessManagerProxy::Error)) ); -} - -void -AmpacheServiceQueryMaker::fetchAlbums() -{ - DEBUG_BLOCK - - Meta::AlbumList albums; - - // first try the cache - if( !d->parentArtistIds.isEmpty() ) - { - foreach( int artistId, d->parentArtistIds ) - albums << matchAlbums( d->collection, d->collection->artistById( artistId ) ); - } - if( !albums.isEmpty() ) - { - debug() << "got" << albums.count() << "albums from the memory collection"; - emit newResultReady( albums ); - emit queryDone(); - return; - } - - if( !d->parentArtistIds.isEmpty() ) - { - foreach( int id, d->parentArtistIds ) - { - KUrl request = getRequestUrl( "artist_albums" ); - request.addQueryItem( "filter", QString::number( id ) ); - - d->expectedReplies.ref(); - The::networkAccessManager()->getData( request, this, - SLOT(albumDownloadComplete(KUrl,QByteArray,NetworkAccessManagerProxy::Error)) ); - } - } - else - { - KUrl request = getRequestUrl( "albums" ); - - if ( !d->albumFilter.isEmpty() ) - request.addQueryItem( "filter", d->albumFilter ); - - d->expectedReplies.ref(); - The::networkAccessManager()->getData( request, this, - SLOT(albumDownloadComplete(KUrl,QByteArray,NetworkAccessManagerProxy::Error)) ); - } -} - -void -AmpacheServiceQueryMaker::fetchTracks() -{ - DEBUG_BLOCK - - Meta::TrackList tracks; - - //debug() << "parent album id: " << d->parentAlbumId; - - // first try the cache - // TODO: this is fishy as we cannot be sure that the cache contains - // everything - // we should cache database query results instead - if( !d->parentTrackIds.isEmpty() ) - { - foreach( int trackId, d->parentTrackIds ) - { - tracks << d->collection->trackById( trackId ); - } - } - else if( !d->parentAlbumIds.isEmpty() ) - { - foreach( int albumId, d->parentAlbumIds ) - { - AlbumMatcher albumMatcher( d->collection->albumById( albumId ) ); - tracks << albumMatcher.match( d->collection->trackMap().values() ); - } - } - else if( d->parentArtistIds.isEmpty() ) - { - foreach( int artistId, d->parentArtistIds ) - { - ArtistMatcher artistMatcher( d->collection->artistById( artistId ) ); - tracks << artistMatcher.match( d->collection->trackMap().values() ); - } - } - - if( !tracks.isEmpty() ) - { - debug() << "got" << tracks.count() << "tracks from the memory collection"; - emit newResultReady( tracks ); - emit queryDone(); - return; - } - - KUrl request = getRequestUrl(); - - - if( !d->parentAlbumIds.isEmpty() ) - { - foreach( int id, d->parentAlbumIds ) - { - KUrl request = getRequestUrl( "album_songs" ); - request.addQueryItem( "filter", QString::number( id ) ); - - d->expectedReplies.ref(); - The::networkAccessManager()->getData( request, this, - SLOT(trackDownloadComplete(KUrl,QByteArray,NetworkAccessManagerProxy::Error)) ); - } - } - else if( !d->parentArtistIds.isEmpty() ) - { - foreach( int id, d->parentArtistIds ) - { - KUrl request = getRequestUrl( "artist_songs" ); - request.addQueryItem( "filter", QString::number( id ) ); - - d->expectedReplies.ref(); - The::networkAccessManager()->getData( request, this, - SLOT(trackDownloadComplete(KUrl,QByteArray,NetworkAccessManagerProxy::Error)) ); - } - } - else - { - KUrl request = getRequestUrl( "songs" ); - - d->expectedReplies.ref(); - The::networkAccessManager()->getData( request, this, - SLOT(trackDownloadComplete(KUrl,QByteArray,NetworkAccessManagerProxy::Error)) ); - } -} - -void -AmpacheServiceQueryMaker::artistDownloadComplete( const KUrl &url, QByteArray data, NetworkAccessManagerProxy::Error e ) -{ - Q_UNUSED( url ); - - if( e.code != QNetworkReply::NoError ) - { - warning() << "Artist download error:" << e.description; - if( !d->expectedReplies.deref() ) - emit queryDone(); - return; - } - - // DEBUG_BLOCK - - // so lets figure out what we got here: - QDomDocument doc( "reply" ); - doc.setContent( data ); - QDomElement root = doc.firstChildElement( "root" ); - - // Is this an error, if so we need to 'un-ready' the service and re-authenticate before contiuning - QDomElement domError = root.firstChildElement( "error" ); - - if ( !domError.isNull() ) - { - warning() << "Error getting Artist List" << domError.text(); - AmpacheService *parentService = dynamic_cast< AmpacheService * >( d->collection->service() ); - if( parentService == 0 ) - return; - else - parentService->reauthenticate(); - } - - for( QDomNode n = root.firstChild(); !n.isNull(); n = n.nextSibling() ) - { - QDomElement e = n.toElement(); // try to convert the node to an element. - - QDomElement element = n.firstChildElement( "name" ); - int artistId = e.attribute( "id", "0").toInt(); - - // check if we have the artist already - Meta::ArtistPtr artistPtr = d->collection->artistById( artistId ); - - if( !artistPtr ) - { - // new artist - Meta::ServiceArtist* artist = new Meta::AmpacheArtist( element.text(), d->collection->service() ); - artist->setId( artistId ); - - // debug() << "Adding artist: " << element.text() << " with id: " << artistId; - - artistPtr = artist; - - d->collection->acquireWriteLock(); - d->collection->addArtist( artistPtr ); - d->collection->releaseLock(); - } - - if( !d->artistResults.contains( artistPtr ) ) - d->artistResults.push_back( artistPtr ); - } - - if( !d->expectedReplies.deref() ) - { - emit newResultReady( d->artistResults ); - emit queryDone(); - d->artistResults.clear(); - } -} - -void -AmpacheServiceQueryMaker::albumDownloadComplete( const KUrl &url, QByteArray data, NetworkAccessManagerProxy::Error e ) -{ - Q_UNUSED( url ); - - if( e.code != QNetworkReply::NoError ) - { - warning() << "Album download error:" << e.description; - if( !d->expectedReplies.deref() ) - emit queryDone(); - return; - } - - // DEBUG_BLOCK - - //so lets figure out what we got here: - QDomDocument doc( "reply" ); - doc.setContent( data ); - QDomElement root = doc.firstChildElement( "root" ); - - // Is this an error, if so we need to 'un-ready' the service and re-authenticate before contiuning - QDomElement domError = root.firstChildElement( "error" ); - - if( !domError.isNull() ) - { - warning() << "Error getting Album List" << domError.text(); - AmpacheService *parentService = dynamic_cast< AmpacheService * >(d->collection->service()); - if( parentService == 0 ) - return; - else - parentService->reauthenticate(); - } - - for( QDomNode n = root.firstChild(); !n.isNull(); n = n.nextSibling() ) - { - QDomElement e = n.toElement(); // try to convert the node to an element. - - // --- the album artist - Meta::ArtistPtr artistPtr; - QDomElement artistElement = n.firstChildElement( "artist" ); - if( !artistElement.isNull() ) - { - int artistId = artistElement.attribute( "id", "0").toInt(); - // check if we already know the artist - artistPtr = d->collection->artistById( artistId ); - if( !artistPtr.data() ) - { - // new artist. - Meta::ServiceArtist* artist = new Meta::AmpacheArtist( artistElement.text(), d->collection->service() ); - artistPtr = artist; - - artist->setId( artistId ); - // debug() << "Adding artist: " << artistElement.text() << " with id: " << artistId; - - d->collection->acquireWriteLock(); - d->collection->addArtist( artistPtr ); - d->collection->releaseLock(); - } - } - - QDomElement element = n.firstChildElement( "name" ); - QString title = element.text(); - - Meta::AmpacheAlbum::AmpacheAlbumInfo info; - info.id = e.attribute( "id", "0" ).toInt(); - - element = n.firstChildElement( "disk" ); - info.discNumber = element.text().toInt(); - - element = n.firstChildElement( "year" ); - info.year = element.text().toInt(); - - // check if we have the album already - Meta::AlbumPtr albumPtr = d->collection->albumById( info.id ); - - if( !albumPtr ) - { - // check if we at least have an album with the same title and artist - Meta::AmpacheAlbum* album = static_cast( - const_cast( d->collection->albumMap().value( title, artistPtr ? artistPtr->name() : QString() ).data() ) ); - - if( !album ) - { - // new album - album = new Meta::AmpacheAlbum( title ); - album->setAlbumArtist( artistPtr ); - - // -- cover - element = n.firstChildElement( "art" ); - - QString coverUrl = element.text(); - album->setCoverUrl( coverUrl ); - } - album->addInfo( info ); - - // debug() << "Adding album" << title << "with id:" << info.id; - - albumPtr = album; - - // register a new id with the ServiceCollection - album->setId( info.id ); - d->collection->acquireWriteLock(); - d->collection->addAlbum( albumPtr ); - d->collection->releaseLock(); - } - - if( !d->albumResults.contains( albumPtr ) ) - d->albumResults.push_back( albumPtr ); - } - - if( !d->expectedReplies.deref() ) - { - emit newResultReady( d->albumResults ); - emit queryDone(); - d->albumResults.clear(); - } -} - -void -AmpacheServiceQueryMaker::trackDownloadComplete( const KUrl &url, QByteArray data, NetworkAccessManagerProxy::Error e ) -{ - Q_UNUSED( url ); - - if( e.code != QNetworkReply::NoError ) - { - warning() << "Track download error:" << e.description; - if( !d->expectedReplies.deref() ) - emit queryDone(); - return; - } - - // DEBUG_BLOCK - - //so lets figure out what we got here: - QDomDocument doc( "reply" ); - doc.setContent( data ); - QDomElement root = doc.firstChildElement( "root" ); - - // Is this an error, if so we need to 'un-ready' the service and re-authenticate before contiuning - QDomElement domError = root.firstChildElement( "error" ); - - if( !domError.isNull() ) - { - warning() << "Error getting Track Download " << domError.text(); - AmpacheService *parentService = dynamic_cast< AmpacheService * >( d->collection->service() ); - if( parentService == 0 ) - return; - else - parentService->reauthenticate(); - } - - for( QDomNode n = root.firstChild(); !n.isNull(); n = n.nextSibling() ) - { - QDomElement e = n.toElement(); // try to convert the node to an element. - - int trackId = e.attribute( "id", "0" ).toInt(); - Meta::TrackPtr trackPtr = d->collection->trackById( trackId ); - - if( !trackPtr ) - { - // new track - - QDomElement element = n.firstChildElement( "title" ); - QString title = element.text(); - Meta::AmpacheTrack * track = new Meta::AmpacheTrack( title, d->collection->service() ); - trackPtr = track; - - track->setId( trackId ); - - element = n.firstChildElement( "url" ); - track->setUidUrl( element.text() ); - - element = n.firstChildElement( "time" ); - track->setLength( element.text().toInt() * 1000 ); - - element = n.firstChildElement( "track" ); - track->setTrackNumber( element.text().toInt() ); - - element = n.firstChildElement( "rating" ); - track->statistics()->setRating( element.text().toDouble() * 2.0 ); - - QDomElement albumElement = n.firstChildElement( "album" ); - int albumId = albumElement.attribute( "id", "0").toInt(); - - QDomElement artistElement = n.firstChildElement( "artist" ); - int artistId = artistElement.attribute( "id", "0").toInt(); - - Meta::ArtistPtr artistPtr = d->collection->artistById( artistId ); - // TODO: this assumes that we query all artist before tracks - if( artistPtr ) - { - // debug() << "Found parent artist " << artistPtr->name(); - Meta::ServiceArtist *artist = dynamic_cast< Meta::ServiceArtist * > ( artistPtr.data() ); - track->setArtist( artistPtr ); - artist->addTrack( trackPtr ); - } - - Meta::AlbumPtr albumPtr = d->collection->albumById( albumId ); - // TODO: this assumes that we query all albums before tracks - if( albumPtr ) - { - // debug() << "Found parent album " << albumPtr->name() << albumId; - Meta::AmpacheAlbum *album = dynamic_cast< Meta::AmpacheAlbum * > ( albumPtr.data() ); - track->setDiscNumber( album->getInfo( albumId ).discNumber ); - track->setYear( album->getInfo( albumId ).year ); - track->setAlbumPtr( albumPtr ); - // debug() << " parent album with"<discNumber()<year(); - album->addTrack( trackPtr ); - } - - // debug() << "Adding track: " << title << " with id: " << trackId; - - d->collection->acquireWriteLock(); - d->collection->addTrack( trackPtr ); - d->collection->releaseLock(); - } - - if( !d->trackResults.contains( trackPtr ) ) - d->trackResults.push_back( trackPtr ); - } - - if( !d->expectedReplies.deref() ) - { - emit newResultReady( d->trackResults ); - emit queryDone(); - d->trackResults.clear(); - } -} - -QueryMaker * -AmpacheServiceQueryMaker::addFilter( qint64 value, const QString & filter, bool matchBegin, bool matchEnd ) -{ - Q_UNUSED( matchBegin ) - Q_UNUSED( matchEnd ) - - //for now, only accept artist filters - // TODO: What about albumArtist? - if( value == Meta::valArtist ) - { - d->artistFilter = filter; - } - else if( value == Meta::valAlbum ) - { - d->albumFilter = filter; - } - else - { - warning() << "unsupported filter" << Meta::nameForField( value ); - } - return this; -} - -QueryMaker* -AmpacheServiceQueryMaker::addNumberFilter( qint64 value, qint64 filter, QueryMaker::NumberComparison compare ) -{ - if( value == Meta::valCreateDate && compare == QueryMaker::GreaterThan ) - { - debug() << "asking to filter based on added date"; - d->dateFilter = filter; - debug() << "setting dateFilter to:" << d->dateFilter; - } - else - { - warning() << "unsupported filter" << Meta::nameForField( value ); - } - return this; -} - -int -AmpacheServiceQueryMaker::validFilterMask() -{ - //we only supprt artist and album filters for now... - return ArtistFilter | AlbumFilter; -} - -QueryMaker * -AmpacheServiceQueryMaker::limitMaxResultSize( int size ) -{ - d->maxsize = size; - return this; -} - -KUrl -AmpacheServiceQueryMaker::getRequestUrl( const QString &action ) const -{ - QString path = d->server; - - if( !path.startsWith("http://") && !path.startsWith("https://") ) - path = "http://" + path; - - KUrl url( path ); - - url.addPath( "/server/xml.server.php" ); - url.addQueryItem( "auth", d->sessionId ); - - if( !action.isEmpty() ) - url.addQueryItem( "action", action ); - - if( d->dateFilter > 0 ) - { - QDateTime from; - from.setTime_t( d->dateFilter ); - url.addQueryItem( "add", from.toString( Qt::ISODate ) ); - } - url.addQueryItem( "limit", QString::number( d->maxsize ) ); - - return url; -} - -#include "moc_AmpacheServiceQueryMaker.cpp" - diff --git a/amarok/src/services/ampache/AmpacheServiceQueryMaker.h b/amarok/src/services/ampache/AmpacheServiceQueryMaker.h deleted file mode 100644 index a9b881cf..00000000 --- a/amarok/src/services/ampache/AmpacheServiceQueryMaker.h +++ /dev/null @@ -1,92 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMPACHESERVICEQUERYMAKER_H -#define AMPACHESERVICEQUERYMAKER_H - -#include "DynamicServiceQueryMaker.h" - -#include "AmpacheServiceCollection.h" -#include "AmpacheService.h" -#include "NetworkAccessManagerProxy.h" - -#include - -namespace Collections { - -/** QueryMaker for Ampache - Since Ampache only supports a very limited set of searches - this query maker is very restricted. - E.g. it does not support searches with AND and OR. - TODO: support tags - TODO: think about only using the MemoryQueryMaker -*/ -class AmpacheServiceQueryMaker : public DynamicServiceQueryMaker -{ - Q_OBJECT - -public: - AmpacheServiceQueryMaker( AmpacheServiceCollection * collection, const QString &server, const QString &sessionId ); - ~AmpacheServiceQueryMaker(); - - virtual void run(); - virtual void abortQuery(); - - virtual QueryMaker* setQueryType( QueryType type ); - - using DynamicServiceQueryMaker::addMatch; - virtual QueryMaker* addMatch( const Meta::TrackPtr &track ); - virtual QueryMaker* addMatch( const Meta::ArtistPtr &artist, ArtistMatchBehaviour behaviour = TrackArtists ); - virtual QueryMaker* addMatch( const Meta::AlbumPtr &album ); - - virtual QueryMaker* addFilter( qint64 value, const QString &filter, bool matchBegin = false, bool matchEnd = false ); - virtual QueryMaker* addNumberFilter( qint64 value, qint64 filter, QueryMaker::NumberComparison compare ); - - virtual int validFilterMask(); - virtual QueryMaker* limitMaxResultSize( int size ); - - void fetchArtists(); - void fetchAlbums(); - void fetchTracks(); - -protected: - struct Private; - Private * const d; - -public slots: - void artistDownloadComplete( const KUrl &url, QByteArray data, NetworkAccessManagerProxy::Error e ); - void albumDownloadComplete( const KUrl &url, QByteArray data, NetworkAccessManagerProxy::Error e ); - void trackDownloadComplete( const KUrl &url, QByteArray data, NetworkAccessManagerProxy::Error e ); - -private: - // Disable copy constructor and assignment - AmpacheServiceQueryMaker( const AmpacheServiceQueryMaker& ); - AmpacheServiceQueryMaker& operator= ( const AmpacheServiceQueryMaker& ); - - /** Gets the url for the ampache requests. - Already adds query items for the dateFilter and the limit. - */ - KUrl getRequestUrl( const QString &action = QString() ) const; - - /* - template - void emitProperResult(const ListType& list); - */ -}; - -} //namespace Collections - -#endif diff --git a/amarok/src/services/ampache/AmpacheSettings.cpp b/amarok/src/services/ampache/AmpacheSettings.cpp deleted file mode 100644 index 54973932..00000000 --- a/amarok/src/services/ampache/AmpacheSettings.cpp +++ /dev/null @@ -1,174 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "AmpacheSettings.h" - -#include "AddServerDialog.h" -#include "ui_AmpacheConfigWidget.h" - -#include -#include - -#include -#include - -K_PLUGIN_FACTORY( AmpacheSettingsFactory, registerPlugin(); ) -K_EXPORT_PLUGIN( AmpacheSettingsFactory( "kcm_amarok_ampache" ) ) - - -AmpacheSettings::AmpacheSettings(QWidget * parent, const QVariantList & args) - : KCModule( AmpacheSettingsFactory::componentData(), parent, args ) - , m_lastRowEdited(-1) - , m_lastColumnEdited(-1) -{ - m_configDialog = new Ui::AmpacheConfigWidget; - m_configDialog->setupUi( this ); - m_configDialog->serverList->setMinimumWidth(700); - m_configDialog->serverList->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred); - m_configDialog->serverList->verticalHeader()->hide(); - - connect ( m_configDialog->serverList, SIGNAL(cellDoubleClicked(int,int)), this, SLOT(onCellDoubleClicked(int,int))); - connect ( m_configDialog->serverList, SIGNAL(cellChanged(int,int)), this, SLOT(saveCellEdit(int,int))); - connect ( m_configDialog->addButton, SIGNAL(clicked()), this, SLOT(add()) ); - connect ( m_configDialog->removeButton, SIGNAL(clicked()), this, SLOT(remove()) ); -} - -AmpacheSettings::~AmpacheSettings() -{ - delete m_configDialog; -} - -void -AmpacheSettings::serverNameChanged(const QString & text) -{ - m_configDialog->addButton->setEnabled( !text.isEmpty() ); -} - -void -AmpacheSettings::save() -{ - m_config.save(); - KCModule::save(); -} - -void -AmpacheSettings::load() -{ - loadList(); - KCModule::load(); -} - -void -AmpacheSettings::loadList() -{ - QTableWidget* serverList = m_configDialog->serverList; - serverList->setRowCount(m_config.servers().size()); - for( int i = 0; i < m_config.servers().size(); i++ ) - { - AmpacheServerEntry entry = m_config.servers().at( i ); - - serverList->setItem(i, 0, new QTableWidgetItem(entry.name)); - serverList->setItem(i, 1, new QTableWidgetItem(entry.url)); - serverList->setItem(i, 2, new QTableWidgetItem(entry.username)); - QString starPassword = entry.password; - starPassword.fill('*'); - QTableWidgetItem* password = new QTableWidgetItem(starPassword); - password->setData(0xf00, entry.password); - serverList->setItem(i, 3, password); - } - serverList->resizeColumnsToContents(); - int columnWidth = serverList->columnWidth(3) + serverList->columnViewportPosition(3); - serverList->setMinimumWidth( qBound( 200, columnWidth, 700) ); - -} - -void -AmpacheSettings::defaults() -{ -} - -void -AmpacheSettings::add() -{ - AddServerDialog dialog; - if(dialog.exec() == QDialog::Accepted) - { - AmpacheServerEntry server; - server.name = dialog.name(); - server.url = dialog.url(); - server.username = dialog.username(); - server.password =dialog.password(); - if( server.name.isEmpty()) - return; - m_config.addServer( server ); - } - loadList(); - emit changed( true ); -} - -void -AmpacheSettings::remove() -{ - int index = m_configDialog->serverList->currentRow(); - m_configDialog->serverList->removeRow( index ); - m_config.removeServer( index ); - - emit changed( true ); -} - -void -AmpacheSettings::onCellDoubleClicked(int row, int column) -{ - QTableWidgetItem* item = m_configDialog->serverList->item(row, column); - m_configDialog->serverList->editItem(item); - m_lastRowEdited = row; - m_lastColumnEdited = column; -} - -void -AmpacheSettings::saveCellEdit(int row, int column) -{ - if(m_lastRowEdited != row || m_lastColumnEdited != column) //only worry about user edits - return; - kDebug( 14310 ) << Q_FUNC_INFO << row << column; - QString newValue = m_configDialog->serverList->item(row, column)->text(); - AmpacheServerEntry server = m_config.servers().at(row); - switch(column) - { - case 0: - server.name = newValue; - break; - case 1: - server.url = newValue; - break; - case 2: - server.username = newValue; - break; - case 3: - server.password = newValue; - break; - default: - qWarning() << Q_FUNC_INFO << "invalid column"; - - } - m_config.updateServer(row, server); - m_configDialog->serverList->resizeColumnToContents(column); - emit changed( true ); -} - - -#include "moc_AmpacheSettings.cpp" - diff --git a/amarok/src/services/ampache/AmpacheSettings.h b/amarok/src/services/ampache/AmpacheSettings.h deleted file mode 100644 index c65f482a..00000000 --- a/amarok/src/services/ampache/AmpacheSettings.h +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMPACHESETTINGS_H -#define AMPACHESETTINGS_H - -#include "AmpacheConfig.h" - -#include - -namespace Ui { class AmpacheConfigWidget; } - -/** -Class for handling settings for Ampache services - - @author -*/ -class AmpacheSettings : public KCModule -{ - Q_OBJECT -public: - explicit AmpacheSettings( QWidget *parent = 0, const QVariantList &args = QVariantList() ); - - ~AmpacheSettings(); - - virtual void save(); - virtual void load(); - virtual void defaults(); - -private: - - AmpacheConfig m_config; - Ui::AmpacheConfigWidget * m_configDialog; - void loadList(); - int m_lastRowEdited; - int m_lastColumnEdited; -private slots: - - void add(); - void remove(); - void serverNameChanged(const QString & text); - void onCellDoubleClicked(int row, int column); - void saveCellEdit(int row, int column); -}; - -#endif diff --git a/amarok/src/services/ampache/CMakeLists.txt b/amarok/src/services/ampache/CMakeLists.txt deleted file mode 100644 index e47d357d..00000000 --- a/amarok/src/services/ampache/CMakeLists.txt +++ /dev/null @@ -1,96 +0,0 @@ - include_directories( - ../ - ${Amarok_SOURCE_DIR}/src/ - ${Amarok_SOURCE_DIR}/src/core-impl/collections - ${Amarok_SOURCE_DIR}/src/network - ${Amarok_SOURCE_DIR}/src/statusbar - ${CMAKE_CURRENT_BINARY_DIR}/../../.. - ${KDE4_INCLUDE_DIR} - ${QCA2_INCLUDE_DIR} - ${QT_INCLUDES} - ) - -if( LIBLASTFM_FOUND ) - include_directories( - ${LIBLASTFM_INCLUDE_DIR} - ) -endif( LIBLASTFM_FOUND ) - -add_subdirectory( images ) - -########### next target ############### - -set(libampache_account_login_SRCS - AmpacheAccountLogin.cpp) -add_library(ampache_account_login SHARED ${libampache_account_login_SRCS}) -target_link_libraries(ampache_account_login - amaroklib - amarokcore - ${KDE4_KDECORE_LIBS} - ${KDE4_KDEUI_LIBS} - ${KDE4_KIO_LIBS} - ${QCA2_LIBRARIES} -) -install(TARGETS ampache_account_login DESTINATION ${INSTALL_TARGETS_DEFAULT_ARGS}) - -########### next target ############### - set(amarok_service_ampache_PART_SRCS - AmpacheService.cpp - AmpacheServiceCollection.cpp - AmpacheServiceQueryMaker.cpp - AmpacheMeta.cpp - AmpacheConfig.cpp - ) - if( LIBLASTFM_FOUND ) - set(amarok_service_ampache_PART_SRCS - ${amarok_service_ampache_PART_SRCS} - LastfmInfoParser.cpp ) - endif( LIBLASTFM_FOUND ) - - - - kde4_add_plugin(amarok_service_ampache ${amarok_service_ampache_PART_SRCS}) - target_link_libraries(amarok_service_ampache - ampache_account_login - amarokcore - amaroklib - ${KDE4_KDECORE_LIBS} - ${KDE4_KDEUI_LIBS} - ${KDE4_KIO_LIBS} - ${KDE4_THREADWEAVER_LIBS} - ${QT_QTXML_LIBRARY} - ${KDE4_SOLID_LIBS} - ) - if( LIBLASTFM_FOUND ) - target_link_libraries(amarok_service_ampache - ${LIBLASTFM_LIBRARY} - ) - endif( LIBLASTFM_FOUND ) - - - install(TARGETS amarok_service_ampache DESTINATION ${PLUGIN_INSTALL_DIR} ) - - -########### next target ############### - - set(kcm_amarok_service_ampache_PART_SRCSS - AddServerDialog.cpp - AmpacheSettings.cpp - AmpacheConfig.cpp - AmpacheConfigWidget.ui - NewServerWidget.ui - ) - - kde4_add_plugin(kcm_amarok_service_ampache ${kcm_amarok_service_ampache_PART_SRCSS} ) - - target_link_libraries( kcm_amarok_service_ampache - ampache_account_login ${KDE4_KUTILS_LIBS} ${QT_QTCORE_LIBRARY} - ${QT_QTGUI_LIBRARY} ${KDE4_KDECORE_LIBRARY} ${KDE4_KDEUI_LIBS} ) - - install(TARGETS kcm_amarok_service_ampache DESTINATION ${PLUGIN_INSTALL_DIR}) - - -########### install files ############### - - install( FILES amarok_service_ampache.desktop DESTINATION ${SERVICES_INSTALL_DIR}) - install( FILES amarok_service_ampache_config.desktop DESTINATION ${SERVICES_INSTALL_DIR}) diff --git a/amarok/src/services/ampache/LastfmInfoParser.cpp b/amarok/src/services/ampache/LastfmInfoParser.cpp deleted file mode 100644 index ae4b9322..00000000 --- a/amarok/src/services/ampache/LastfmInfoParser.cpp +++ /dev/null @@ -1,186 +0,0 @@ -/*************************************************************************************** -* Copyright (c) 2009 Dan Meltzer * -* * -* This program 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 2 of the License, or (at your option) any later * -* version. * -* * -* This program 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 * -* this program. If not, see . * -****************************************************************************************/ - - -#include "LastfmInfoParser.h" - -#include "core/meta/Meta.h" -#include "core/support/Amarok.h" -#include "core/support/Debug.h" - -#include - -#include - -#include - -void LastfmInfoParser::getInfo(Meta::TrackPtr track) -{ - DEBUG_BLOCK - QMap query; - query[ "method" ] = "track.getInfo"; - query[ "track" ] = track->name(); - query[ "album" ] = track->album() ? track->album()->name() : QString(); - query[ "artist" ] = track->artist() ? track->artist()->name() : QString(); - query[ "apikey" ] = Amarok::lastfmApiKey(); - - m_jobs[ "getTrackInfo" ] = lastfm::ws::post( query ); - - connect( m_jobs[ "getTrackInfo" ], SIGNAL(finished()), SLOT(onGetTrackInfo()) ); -} - -void LastfmInfoParser::onGetTrackInfo() -{ - DEBUG_BLOCK - if( !m_jobs[ "getTrackInfo" ] ) - { - debug() << "WARNING: GOT RESULT but no object"; - return; - } - - switch ( m_jobs[ "getTrackInfo" ]->error() ) - { - case QNetworkReply::NoError: - { - lastfm::XmlQuery lfm; - lfm.parse( m_jobs[ "getTrackInfo" ]->readAll() ); - lastfm::XmlQuery wiki = lfm["track"]["wiki"]; - const QString contentText = wiki["content"].text(); - const QString publishedDate = wiki["published"].text(); - - QString html; - if( !contentText.isEmpty() ) - html = QString("

    %1

    Updated: %2

    ").arg( contentText, publishedDate ); - else - html = i18n( "

    No information found for this track.

    " ); - emit info( html ); - break; - } - default: - break; - } - m_jobs["getTrackInfo"]->deleteLater(); - m_jobs["getTrackInfo"] = 0; -} - -void LastfmInfoParser::getInfo(Meta::AlbumPtr album) -{ - DEBUG_BLOCK - QMap query; - query[ "method" ] = "album.getInfo"; - query[ "album" ] = album->name(); - query[ "artist" ] = album->albumArtist() ? album->albumArtist()->name() : QString(); - query[ "apikey" ] = Amarok::lastfmApiKey(); - - m_jobs[ "getAlbumInfo" ] = lastfm::ws::post( query ); - - connect( m_jobs[ "getAlbumInfo" ], SIGNAL(finished()), SLOT(onGetAlbumInfo()) ); -} - - -void LastfmInfoParser::onGetAlbumInfo() -{ - DEBUG_BLOCK - if( !m_jobs[ "getAlbumInfo" ] ) - { - debug() << "WARNING: GOT RESULT but no object"; - return; - } - - switch ( m_jobs[ "getAlbumInfo" ]->error() ) - { - case QNetworkReply::NoError: - { - lastfm::XmlQuery lfm; - lfm.parse( m_jobs[ "getAlbumInfo" ]->readAll() ); - lastfm::XmlQuery wiki = lfm["album"]["wiki"]; - const QString summaryText = wiki["summary"].text(); - const QString contentText = wiki["content"].text(); - const QString publishedDate = wiki["published"].text(); - - const QString albumUrl = lfm["image size=large"].text(); - - QString html; - if( !contentText.isEmpty() ) - html = QString("

    %2

    Updated: %3

    ").arg( albumUrl, contentText, publishedDate ); - else - html = i18n( "

    No information found for this album.

    " ); - emit info( html ); - break; - } - default: - break; - } - m_jobs["getAlbumInfo"]->deleteLater(); - m_jobs["getAlbumInfo"] = 0; -} - - -void LastfmInfoParser::getInfo(Meta::ArtistPtr artist) -{ - QMap query; - query[ "method" ] = "artist.getInfo"; - query[ "artist" ] = artist->name(); - debug() << "api key is: " << Amarok::lastfmApiKey(); - query[ "apikey" ] = Amarok::lastfmApiKey(); - - m_jobs[ "getArtistInfo" ] = lastfm::ws::post( query ); - - connect( m_jobs[ "getArtistInfo" ], SIGNAL(finished()), SLOT(onGetArtistInfo()) ); - -} - - -void LastfmInfoParser::onGetArtistInfo() -{ - DEBUG_BLOCK - if( !m_jobs[ "getArtistInfo" ] ) - { - debug() << "WARNING: GOT RESULT but no object"; - return; - } - - switch ( m_jobs[ "getArtistInfo" ]->error() ) - { - case QNetworkReply::NoError: - { - lastfm::XmlQuery lfm; - lfm.parse( m_jobs[ "getArtistInfo" ]->readAll() ); - debug() << lfm.text(); - lastfm::XmlQuery bio = lfm["artist"]["bio"]; - const QString summaryText = bio["summary"].text(); - const QString contentText = bio["content"].text(); - const QString publishedDate = bio["published"].text(); - - const QString imageUrl = lfm["image size=large"].text(); - - QString html; - if( !contentText.isEmpty() ) - html = QString("

    %2

    Updated: %3

    ").arg( imageUrl, contentText, publishedDate ); - else - html = i18n( "

    No information found for this artist.

    " ); - emit info( html ); - - break; - } - default: - break; - } - m_jobs["getArtistInfo"]->deleteLater(); - m_jobs["getArtistInfo"] = 0; -} - -#include "moc_LastfmInfoParser.cpp" diff --git a/amarok/src/services/ampache/LastfmInfoParser.h b/amarok/src/services/ampache/LastfmInfoParser.h deleted file mode 100644 index d92ff1f9..00000000 --- a/amarok/src/services/ampache/LastfmInfoParser.h +++ /dev/null @@ -1,47 +0,0 @@ -/*************************************************************************************** -* Copyright (c) 2009 Dan Meltzer * -* * -* This program 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 2 of the License, or (at your option) any later * -* version. * -* * -* This program 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 * -* this program. If not, see . * -****************************************************************************************/ - - -#ifndef LASTFMINFOPARSER_H -#define LASTFMINFOPARSER_H - -#include "services/InfoParserBase.h" - -#include - -class QNetworkReply; - -class LastfmInfoParser : public InfoParserBase -{ - Q_OBJECT - - public: - LastfmInfoParser() : InfoParserBase() {} - ~LastfmInfoParser() {} - virtual void getInfo(Meta::TrackPtr track); - virtual void getInfo(Meta::AlbumPtr album); - virtual void getInfo(Meta::ArtistPtr artist); - - private slots: - void onGetTrackInfo(); - void onGetAlbumInfo(); - void onGetArtistInfo(); - - private: - QMap m_jobs; -}; - -#endif // LASTFMINFOPARSER_H diff --git a/amarok/src/services/ampache/NewServerWidget.ui b/amarok/src/services/ampache/NewServerWidget.ui deleted file mode 100644 index f336a126..00000000 --- a/amarok/src/services/ampache/NewServerWidget.ui +++ /dev/null @@ -1,107 +0,0 @@ - - - NewServerWidget - - - - 0 - 0 - 345 - 184 - - - - - - - Name - - - - - - - - - - Server Address - - - - - - - - 0 - 0 - - - - - 200 - 0 - - - - - - - - Username - - - - - - - - - - Password - - - - - - - QLineEdit::Password - - - - - - - Check Connection - - - - - - - - 0 - 0 - - - - - - - - - - - - KPushButton - QPushButton -
    kpushbutton.h
    -
    - - KLineEdit - QLineEdit -
    klineedit.h
    -
    -
    - - -
    diff --git a/amarok/src/services/ampache/amarok_service_ampache.desktop b/amarok/src/services/ampache/amarok_service_ampache.desktop deleted file mode 100644 index 8f053aea..00000000 --- a/amarok/src/services/ampache/amarok_service_ampache.desktop +++ /dev/null @@ -1,129 +0,0 @@ -[Desktop Entry] -Type=Service -ServiceTypes=KPluginInfo -Icon=view-services-ampache-amarok -Name=Ampache -Name[bg]=Ampache -Name[bs]=Ampache -Name[ca]=Ampache -Name[ca@valencia]=Ampache -Name[cs]=Ampache -Name[da]=Ampache -Name[de]=Ampache -Name[el]=Ampache -Name[en_GB]=Ampache -Name[eo]=Ampache -Name[es]=Ampache -Name[et]=Ampache -Name[eu]=Ampache -Name[fi]=Ampache -Name[fr]=Ampache -Name[ga]=Ampache -Name[gl]=Ampache -Name[hu]=Ampache -Name[id]=Ampache -Name[is]=Ampache -Name[it]=Ampache -Name[ja]=Ampache -Name[km]=Ampache -Name[ko]=Ampache -Name[lt]=Ampache -Name[lv]=Ampache -Name[nb]=Ampache -Name[nds]=Ampache -Name[nl]=Ampache -Name[nn]=Ampache -Name[pa]=ਅਮਪਾਂਚੇ -Name[pl]=Ampache -Name[pt]=Ampache -Name[pt_BR]=Ampache -Name[ro]=Ampache -Name[ru]=Ampache -Name[sk]=Ampache -Name[sl]=Ampache -Name[sq]=Ampache -Name[sr]=Ампач -Name[sr@ijekavian]=Ампач -Name[sr@ijekavianlatin]=Ampache -Name[sr@latin]=Ampache -Name[sv]=Ampache -Name[th]=บริการ Ampache -Name[tr]=Ampache -Name[uk]=Ampache -Name[wa]=Ampache -Name[x-test]=xxAmpachexx -Name[zh_CN]=Ampache -Name[zh_TW]=Ampache -Comment=Listen to music from an Ampache server -Comment[bg]=Слушане на музика от Ampache сървър -Comment[bs]=Slušajte muziku sa Ampačevog servera -Comment[ca]=Escolta música des d'un servidor Ampache -Comment[ca@valencia]=Escolta música des d'un servidor Ampache -Comment[cs]=Poslouchejte hudbu ze serveru Ampache -Comment[da]=Lyt til musik fra en Ampache-server -Comment[de]=Musik von einem Ampache-Server wiedergeben -Comment[el]=Ακρόαση μουσικής από έναν εξυπηρετητή Ampache -Comment[en_GB]=Listen to music from an Ampache server -Comment[es]=Escuchar música desde el servidor Ampache -Comment[et]=Ampache serveri muusika kuulamine -Comment[eu]=Entzun musika Ampache zerbitzari batetik -Comment[fi]=Kuuntele musiikkia Ampache-palvelusta -Comment[fr]=Écouter de la musique depuis un serveur « Ampache » -Comment[ga]=Éist le ceol ó fhreastalaí Ampache -Comment[gl]=Escoite música dun servizo Ampache -Comment[he]=האזנה למוזיקה משרת Ampache -Comment[hu]=Zenehallgatás egy Ampache-kiszolgálóról -Comment[id]=Mendengarkan musik dari server Ampache -Comment[is]=Hlusta á tónlist frá Ampache þjóni -Comment[it]=Ascolta musica da un server Ampache -Comment[ja]=Ampache サーバから音楽を聴けます -Comment[km]=ស្ដាប់​តន្ត្រី​ពី​ម៉ាស៊ីន​បម្រើ Ampache -Comment[ko]=Ampache 서버의 음악 듣기 -Comment[ku]=Ji pêşkêşkera Ampache guhdarî ya muzîkê bike -Comment[lt]=Klausyti muzikos iš Ampache serverio -Comment[lv]=Klausieties mūziku no Ampache servera -Comment[nb]=Lytt til musikk fra en Ampache-tjener -Comment[nds]=Musik vun en Ampache-Server tohören -Comment[nl]=Luister naar muziek vanaf een Ampache-server -Comment[nn]=Høyr på musikk frå ein Ampache-tenar -Comment[pl]=Słuchaj muzyki z serwera Ampache -Comment[pt]=Ouvir música de um servidor Ampache -Comment[pt_BR]=Ouça músicas de um servidor Ampache -Comment[ro]=Ascultă muzică de pe un server Ampache -Comment[ru]=Прослушивание музыки с сервера Ampache -Comment[sk]=Počúvať hudbu z Ampache servra -Comment[sl]=Poslušajte glasbo s strežnika Ampache -Comment[sr]=Слушајте музику са Ампачевог сервера -Comment[sr@ijekavian]=Слушајте музику са Ампачевог сервера -Comment[sr@ijekavianlatin]=Slušajte muziku sa Ampachejevog servera -Comment[sr@latin]=Slušajte muziku sa Ampachejevog servera -Comment[sv]=Lyssna på musik från en Ampache-server -Comment[th]=ฟังดนตรีจากบริการ Ampache -Comment[tr]=Bir Ampache sunucudan müzik dinle -Comment[uk]=Прослуховування музики з сервера Ampache -Comment[wa]=Schoûter del muzike d' on sierveu Ampache -Comment[x-test]=xxListen to music from an Ampache serverxx -Comment[zh_CN]=聆听来自 Ampache 服务器的音乐 -Comment[zh_TW]=從 Ampache 伺服器上聽音樂 - - -ServiceTypes=Amarok/Plugin - - -X-KDE-Amarok-authors=Nikolaj Hald Nielsen -X-KDE-Amarok-email=nhnFreespirit@gmail.com -X-KDE-Amarok-framework-version=72 -X-KDE-Amarok-name=AmpacheService -X-KDE-Amarok-plugintype=service -X-KDE-Amarok-rank=100 -X-KDE-Amarok-version=1 - -X-KDE-PluginInfo-Author=Nikolaj Hald Nielsen -X-KDE-PluginInfo-Email=nhnFreespirit@gmail.com -X-KDE-PluginInfo-Version=1.0 -X-KDE-PluginInfo-Category=Service -X-KDE-PluginInfo-License=GPL -X-KDE-PluginInfo-EnabledByDefault=false -X-KDE-Library=amarok_service_ampache -X-KDE-PluginInfo-Name=amarok_service_ampache - diff --git a/amarok/src/services/ampache/amarok_service_ampache_config.desktop b/amarok/src/services/ampache/amarok_service_ampache_config.desktop deleted file mode 100644 index b20ff315..00000000 --- a/amarok/src/services/ampache/amarok_service_ampache_config.desktop +++ /dev/null @@ -1,116 +0,0 @@ -[Desktop Entry] -Icon=view-services-ampache-amarok -Type=Service -ServiceTypes=Amarok/Plugin -X-KDE-ServiceTypes=KCModule - -X-KDE-Library=kcm_amarok_service_ampache -X-KDE-ParentApp=amarok_service_ampache -X-KDE-ParentComponents=amarok_service_ampache - -Name=Ampache Service Config -Name[bg]=Настройване на Ampache -Name[bs]=Postavke za Ampache servis -Name[ca]=Configuració del servei Ampache -Name[ca@valencia]=Configuració del servei Ampache -Name[cs]=Nastavení služby Ampache -Name[da]=Konfiguration af Ampache-tjeneste -Name[de]=Einrichtung von Ampache -Name[el]=Διαμόρφωση της υπηρεσίας Ampache -Name[en_GB]=Ampache Service Config -Name[eo]=Ampache Serva Agordo -Name[es]=Configuración del servicio Ampache -Name[et]=Ampache teenuse seadistamine -Name[eu]=Ampache zerbitzariaren konfigurazioa -Name[fi]=Ampache-palvelumääritykset -Name[fr]=Configuration du service « Ampache » -Name[ga]=Cumraíocht Sheirbhís Ampache -Name[gl]=Configuración do servizo Ampache -Name[he]=הגדרות שירות Ampache -Name[hu]=Ampache szolgáltatás beállítása -Name[id]=Konfig Layanan Ampache -Name[is]=Stillingar Ampache þjónustu -Name[it]=Configurazione servizio Ampache -Name[ja]=Ampache サービスの設定 -Name[km]=កំណត់​រចនាសម្ព័ន្ធ​សេវា​របស់ Ampache -Name[ko]=Ampache 서비스 설정 -Name[ku]=Veavakirina Servîsa Ampache -Name[lt]=Ampache tarnybos parinktys -Name[lv]=Ampache pakalpojuma konfigurācija -Name[nb]=Innstillinger for Ampache-tjenesten -Name[nds]=Ampache-Deenst instellen -Name[nl]=Ampache-dienst instellen -Name[nn]=Set opp Ampache-teneste -Name[pa]=ਅਮਪਾਂਚ ਸਰਵਿਸ ਸੰਰਚਨਾ -Name[pl]=Ustawienia usługi Ampache -Name[pt]=Configuração do Serviço do Ampache -Name[pt_BR]=Configuração do serviço Ampache -Name[ro]=Configurare serviciu Ampache -Name[ru]=Настройка службы Ampache -Name[sk]=Konfigurácie služby Ampache -Name[sl]=Nastavitev storitve Ampache -Name[sr]=Поставке за Ампачев сервис -Name[sr@ijekavian]=Поставке за Ампачев сервис -Name[sr@ijekavianlatin]=Postavke za Ampachejev servis -Name[sr@latin]=Postavke za Ampachejev servis -Name[sv]=Inställning av Ampache-tjänst -Name[th]=ปรับแต่งบริการ Ampache -Name[tr]=Ampache Hizmet Yapılandırması -Name[uk]=Налаштування служби Ampache -Name[wa]=Apontiaedje siervice Ampache -Name[x-test]=xxAmpache Service Configxx -Name[zh_CN]=Ampache 服务配置 -Name[zh_TW]=Ampache 服務設定 -Comment=Sets up the ampache server(s) to connect to -Comment[bg]=Настройване на ampache сървър/и -Comment[bs]=Određuje Ampačeve servere za povezivanje -Comment[ca]=Defineix el servidor(s) Ampache al que connectar -Comment[ca@valencia]=Defineix el servidor(s) Ampache al que connectar -Comment[cs]=Nastaví server(y) ampache ke kterým se připojit -Comment[da]=Sætter de Ampache-servere op, der skal forbindes til -Comment[de]=Richtet die Verbindungen zu Ampache-Servern ein -Comment[el]=Ρυθμίζει τον εξυπηρετητή Ampache με τον οποίο θα γίνει σύνδεση -Comment[en_GB]=Sets up the ampache server(s) to connect to -Comment[eo]=Difinas la ampache servilo(j) konektenda(j) -Comment[es]=Configurar los servidores ampache a los que conectarse -Comment[et]=Ampache'i serverite määramine, millega ühendus luua -Comment[eu]=Ampache zerbitzariak konfiguratzen ditu haietara konektatzeko -Comment[fi]=Asettaa Ampache-palvelimet, joihin yhdistää -Comment[fr]=Définit le ou les serveurs « Ampache » auxquels se connecter -Comment[ga]=Cumraigh na freastalaithe ampache ar chóir ceangal leo -Comment[gl]=Configura o servidor ampache co que conectar -Comment[hu]=Az elérendő Ampache-kiszolgálók beállítása -Comment[id]=Persiapan server ampache untuk berhubungan -Comment[is]=Setur upp ampache þjóna til tengingar -Comment[it]=Configura server Ampache ai quali connettersi -Comment[ja]=接続する Ampache サーバを設定します -Comment[km]=រៀបចំ​ម៉ាស៊ីន​បម្រើ ampache ដើម្បី​​តភ្ជាប់ -Comment[ko]=연결할 Ampache 서버 설정 -Comment[ku]=Servîsa/ên ampache ava dike ku girê bide -Comment[lt]=Nurodyti ampache serveriui(-iams) jungtis prie -Comment[lv]=Uzstāda ampache serveri(us), pie kā pieslēgties -Comment[nb]=Set opp Ampache-server(ne) som du vil ha forbindelse til -Comment[nds]=Leggt de(n) Ampache-Server(s) för't Tokoppeln fast -Comment[nl]=Stelt de ampache-server(s) in waarmee u verbinding wilt maken -Comment[nn]=Set opp tilkopling til Ampache-tenar(ar) -Comment[pl]=Ustawia serwer(y) ampache, do których ma się podłączyć -Comment[pt]=Configura os servidores de Ampache aos quais ligar -Comment[pt_BR]=Configura o(s) servidor(es) ampache para conectar -Comment[ro]=Configurează server(e) Ampache pentru conectare -Comment[ru]=Сервер(ы) Ampache, с которым следуют соединиться -Comment[sk]=Nastavenie ampache servra(ov) na pripojenie -Comment[sl]=Nastavite strežnike Ampache, s katerimi se boste povezali -Comment[sr]=Одређује Ампачеве сервере за повезивање -Comment[sr@ijekavian]=Одређује Ампачеве сервере за повезивање -Comment[sr@ijekavianlatin]=Određuje Ampachejeve servere za povezivanje -Comment[sr@latin]=Određuje Ampachejeve servere za povezivanje -Comment[sv]=Ställer in Ampache-server att ansluta till -Comment[th]=ตั้งค่าแม่ข่ายบริการ ampache ที่จะเชื่อมต่อไป -Comment[tr]=Bağlanılacak ampache sunucularını ayarlar -Comment[uk]=Встановлює сервер ampache, з яким слід з’єднуватися -Comment[wa]=Aponteye li/les sierveu(s) ampache po s' raloyî a -Comment[x-test]=xxSets up the ampache server(s) to connect toxx -Comment[zh_CN]=设定要连接的 Ampache 服务器 -Comment[zh_TW]=設定要連結的 ampache 伺服器 - - diff --git a/amarok/src/services/ampache/images/CMakeLists.txt b/amarok/src/services/ampache/images/CMakeLists.txt deleted file mode 100644 index af2e6842..00000000 --- a/amarok/src/services/ampache/images/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -install( - FILES - hover_info_ampache.png - DESTINATION ${DATA_INSTALL_DIR}/amarok/images -) diff --git a/amarok/src/services/ampache/images/hover_info_ampache.png b/amarok/src/services/ampache/images/hover_info_ampache.png deleted file mode 100644 index df7d355f..00000000 Binary files a/amarok/src/services/ampache/images/hover_info_ampache.png and /dev/null differ diff --git a/amarok/src/services/gpodder/CMakeLists.txt b/amarok/src/services/gpodder/CMakeLists.txt deleted file mode 100644 index cb8d449c..00000000 --- a/amarok/src/services/gpodder/CMakeLists.txt +++ /dev/null @@ -1,71 +0,0 @@ -include_directories( - ../ - ../../ - ../../core-impl/collections - ../../statusbar - ../../widgets - ../../context - ../../network - ../../dynamic # for CustomBias.h - ../../browsers/playlistbrowser - ${CMAKE_CURRENT_BINARY_DIR}/../.. #for amarokconfig.h - ${KDE4_INCLUDE_DIR} - ${QT_INCLUDES} - ${LIBMYGPO_QT_INCLUDE_DIRS} - ${LIBMYGPO_QT_INCLUDE_DIRS}/../ - ) - - add_subdirectory( images ) - - set(amarok_service_gpodder_PART_SRCS - GpodderService.cpp - GpodderServiceConfig.cpp - GpodderServiceModel.cpp - GpodderServiceView.cpp - GpodderProvider.cpp - GpodderPodcastMeta.cpp - GpodderTreeItem.cpp - GpodderPodcastTreeItem.cpp - GpodderTagTreeItem.cpp - GpodderPodcastRequestHandler.cpp - GpodderSortFilterProxyModel.cpp - ) - - kde4_add_plugin(amarok_service_gpodder ${amarok_service_gpodder_PART_SRCS}) - - target_link_libraries(amarok_service_gpodder - amarokcore - amaroklib - amarokpud - ${LIBMYGPO_QT_LIBRARIES} - ${KDE4_KDECORE_LIBS} - ${KDE4_KDEUI_LIBS} - ${KDE4_KIO_LIBS} - ${KDE4_SOLID_LIBRARY} - ${KDE4_THREADWEAVER_LIBS} - ${QT_QTNETWORK_LIBRARY} - ) - - install( TARGETS amarok_service_gpodder DESTINATION ${PLUGIN_INSTALL_DIR} ) - - set(kcm_amarok_service_gpodder_PART_SRCS - GpodderServiceSettings.cpp - GpodderServiceConfig.cpp - GpodderConfigWidget.ui - ) - - kde4_add_plugin( kcm_amarok_service_gpodder ${kcm_amarok_service_gpodder_PART_SRCS} ) - - target_link_libraries( kcm_amarok_service_gpodder - amarokcore - amaroklib - ${LIBMYGPO_QT_LIBRARIES} - ${KDE4_KDEUI_LIBS} - ${KDE4_KUTILS_LIBS} - ${KDE4_KIO_LIBS} - ${QT_QTNETWORK_LIBRARY} ) - - install(TARGETS kcm_amarok_service_gpodder DESTINATION ${PLUGIN_INSTALL_DIR}) - - install( FILES amarok_service_gpodder.desktop DESTINATION ${SERVICES_INSTALL_DIR} ) - install( FILES amarok_service_gpodder_config.desktop DESTINATION ${SERVICES_INSTALL_DIR} ) diff --git a/amarok/src/services/gpodder/GpodderConfigWidget.ui b/amarok/src/services/gpodder/GpodderConfigWidget.ui deleted file mode 100644 index 76d60677..00000000 --- a/amarok/src/services/gpodder/GpodderConfigWidget.ui +++ /dev/null @@ -1,125 +0,0 @@ - - - GpodderConfigWidget - - - - 0 - 0 - 341 - 162 - - - - - 1 - 1 - - - - - 0 - - - - - gpodder.net Profile - - - - - - &Username: - - - false - - - kcfg_GpodderUsername - - - - - - - &Password: - - - false - - - kcfg_GpodderPassword - - - - - - - QLineEdit::Password - - - - - - - - - - - 0 - 0 - - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Ubuntu'; font-size:9pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://www.gpodder.net/register/"><span style=" text-decoration: underline; color:#0057ae;">Sign up to gpodder.net</span></a></p></body></html> - - - true - - - true - - - - - - - &Test Login - - - - - - - - - - Qt::Horizontal - - - - - - - - - KLineEdit - QLineEdit -
    klineedit.h
    -
    -
    - - kcfg_GpodderUsername - kcfg_GpodderPassword - testLogin - - - klineedit.h - - - -
    diff --git a/amarok/src/services/gpodder/GpodderPodcastMeta.cpp b/amarok/src/services/gpodder/GpodderPodcastMeta.cpp deleted file mode 100644 index 0e02e229..00000000 --- a/amarok/src/services/gpodder/GpodderPodcastMeta.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2011 Stefan Derkits * - * Copyright (c) 2011 Christian Wagner * - * Copyright (c) 2011 Felix Winter * - * Copyright (c) 2011 Lucas Lira Gomes * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "GpodderPodcastMeta" - -#include "GpodderPodcastMeta.h" - -#include "GpodderProvider.h" - -using namespace Podcasts; - -Podcasts::GpodderPodcastChannel::GpodderPodcastChannel( GpodderProvider *provider ) - : PodcastChannel() - , m_provider( provider ) -{ -} - -Podcasts::GpodderPodcastChannel::GpodderPodcastChannel( GpodderProvider *provider, - PodcastChannelPtr channel ) - : PodcastChannel( channel ) - , m_provider( provider ) -{ -} - -Podcasts::GpodderPodcastChannel::GpodderPodcastChannel( GpodderProvider *provider, - mygpo::PodcastPtr channel ) - : PodcastChannel() - , m_provider( provider ) -{ - setUrl( channel->url() ); - setWebLink( channel->website() ); - setImageUrl( channel->logoUrl() ); - setDescription( channel->description() ); - setTitle( channel->title() ); -} - -Playlists::PlaylistProvider * -Podcasts::GpodderPodcastChannel::provider() const -{ - return dynamic_cast( m_provider ); -} - - -KUrl -Podcasts::GpodderPodcastChannel::uidUrl() const -{ - return QString( "amarok-gpodder://%1" ).arg( url().url() ); -} diff --git a/amarok/src/services/gpodder/GpodderPodcastMeta.h b/amarok/src/services/gpodder/GpodderPodcastMeta.h deleted file mode 100644 index 1bfe5760..00000000 --- a/amarok/src/services/gpodder/GpodderPodcastMeta.h +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2011 Stefan Derkits * - * Copyright (c) 2011 Christian Wagner * - * Copyright (c) 2011 Felix Winter * - * Copyright (c) 2011 Lucas Lira Gomes * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef GPODDERPODCASTMETA_H -#define GPODDERPODCASTMETA_H - -#include "core/playlists/PlaylistProvider.h" -#include "core/podcasts/PodcastMeta.h" -#include - -namespace Podcasts { - -class GpodderPodcastChannel; -class GpodderProvider; - -typedef KSharedPtr GpodderPodcastChannelPtr; -typedef QList GpodderPodcastChannelList; - -class GpodderPodcastChannel : public PodcastChannel -{ - public: - GpodderPodcastChannel( GpodderProvider *provider ); - - //Copy a PodcastChannel - GpodderPodcastChannel( GpodderProvider *provider, PodcastChannelPtr channel ); - - //Create a channel from a mygpo podcast channel - GpodderPodcastChannel( GpodderProvider *provider, mygpo::PodcastPtr channel ); - - //PodcastChannel Methods - virtual Playlists::PlaylistProvider *provider() const; - - //Playlist virtual methods - virtual KUrl uidUrl() const; - - private: - GpodderProvider *m_provider; -}; - -} - -Q_DECLARE_METATYPE( Podcasts::GpodderPodcastChannelPtr ) -Q_DECLARE_METATYPE( Podcasts::GpodderPodcastChannelList ) - -#endif diff --git a/amarok/src/services/gpodder/GpodderPodcastRequestHandler.cpp b/amarok/src/services/gpodder/GpodderPodcastRequestHandler.cpp deleted file mode 100644 index bef9ffe0..00000000 --- a/amarok/src/services/gpodder/GpodderPodcastRequestHandler.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2011 Stefan Derkits * - * Copyright (c) 2011 Christian Wagner * - * Copyright (c) 2011 Felix Winter * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "GpodderPodcastRequestHandler.h" - -#include "core/support/Debug.h" - -GpodderPodcastRequestHandler::GpodderPodcastRequestHandler( mygpo::PodcastListPtr podcasts, QModelIndex parentItem, - GpodderServiceModel *model ) - : QObject( model ) - , m_podcasts( podcasts ) - , m_parentItem( parentItem ) - , m_model( model ) -{ -} - -GpodderPodcastRequestHandler::~GpodderPodcastRequestHandler() -{ - -} - -void GpodderPodcastRequestHandler::finished() -{ - m_model->insertPodcastList( m_podcasts, m_parentItem ); -} - -void GpodderPodcastRequestHandler::requestError( QNetworkReply::NetworkError error ) -{ - debug() << "Error in Podcast request: " << error; -} -void GpodderPodcastRequestHandler::parseError() -{ - debug() << "Error while parsing gpodder.net Podcasts"; -} diff --git a/amarok/src/services/gpodder/GpodderPodcastRequestHandler.h b/amarok/src/services/gpodder/GpodderPodcastRequestHandler.h deleted file mode 100644 index b8fced56..00000000 --- a/amarok/src/services/gpodder/GpodderPodcastRequestHandler.h +++ /dev/null @@ -1,45 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2011 Stefan Derkits * - * Copyright (c) 2011 Christian Wagner * - * Copyright (c) 2011 Felix Winter * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef GPODDERPODCASTREQUESTHANDLER_H_ -#define GPODDERPODCASTREQUESTHANDLER_H_ - -#include "GpodderServiceModel.h" -#include - -#include - -class GpodderPodcastRequestHandler : public QObject -{ - Q_OBJECT -public: - GpodderPodcastRequestHandler( mygpo::PodcastListPtr podcasts, QModelIndex parentItem, GpodderServiceModel *model ); - virtual ~GpodderPodcastRequestHandler(); - -public slots: - void finished(); - void requestError( QNetworkReply::NetworkError ); - void parseError(); - -private: - mygpo::PodcastListPtr m_podcasts; - QModelIndex m_parentItem; - GpodderServiceModel *m_model; -}; - -#endif /* GPODDERPODCASTREQUESTHANDLER_H_ */ diff --git a/amarok/src/services/gpodder/GpodderPodcastTreeItem.cpp b/amarok/src/services/gpodder/GpodderPodcastTreeItem.cpp deleted file mode 100644 index 460a7141..00000000 --- a/amarok/src/services/gpodder/GpodderPodcastTreeItem.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2011 Stefan Derkits * - * Copyright (c) 2011 Christian Wagner * - * Copyright (c) 2011 Felix Winter * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "GpodderPodcastTreeItem.h" - -GpodderPodcastTreeItem::GpodderPodcastTreeItem( mygpo::PodcastPtr podcast, GpodderTreeItem *parent ) : GpodderTreeItem( parent ), m_podcast( podcast ) -{ -} - -GpodderPodcastTreeItem::~GpodderPodcastTreeItem() -{ -} - -QVariant GpodderPodcastTreeItem::displayData() const -{ - return m_podcast->title(); -} - -mygpo::PodcastPtr GpodderPodcastTreeItem::podcast() const -{ - return m_podcast; -} diff --git a/amarok/src/services/gpodder/GpodderPodcastTreeItem.h b/amarok/src/services/gpodder/GpodderPodcastTreeItem.h deleted file mode 100644 index 62517a57..00000000 --- a/amarok/src/services/gpodder/GpodderPodcastTreeItem.h +++ /dev/null @@ -1,38 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2011 Stefan Derkits * - * Copyright (c) 2011 Christian Wagner * - * Copyright (c) 2011 Felix Winter * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef GPODDERPODCASTTREEITEM_H_ -#define GPODDERPODCASTTREEITEM_H_ - -#include "GpodderTreeItem.h" -#include - -class GpodderPodcastTreeItem: public GpodderTreeItem -{ - Q_OBJECT -public: - GpodderPodcastTreeItem( mygpo::PodcastPtr podcast, GpodderTreeItem *parent = 0 ); - virtual ~GpodderPodcastTreeItem(); - virtual QVariant displayData() const; - - mygpo::PodcastPtr podcast() const; -private: - mygpo::PodcastPtr m_podcast; -}; - -#endif /* GPODDERPODCASTTREEITEM_H_ */ diff --git a/amarok/src/services/gpodder/GpodderProvider.cpp b/amarok/src/services/gpodder/GpodderProvider.cpp deleted file mode 100644 index d7ae60fc..00000000 --- a/amarok/src/services/gpodder/GpodderProvider.cpp +++ /dev/null @@ -1,1307 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2011 Stefan Derkits * - * Copyright (c) 2011 Christian Wagner * - * Copyright (c) 2011 Felix Winter * - * Copyright (c) 2011 Lucas Lira Gomes * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "GpodderProvider" - -#include "GpodderProvider.h" - -#include "core-impl/capabilities/timecode/TimecodeWriteCapability.h" -#include "core-impl/podcasts/sql/SqlPodcastProvider.h" -#include "core/interfaces/Logger.h" -#include "core/support/Amarok.h" -#include "core/support/Components.h" -#include "core/support/Debug.h" -#include "EngineController.h" -#include "gpodder/GpodderServiceConfig.h" -#include "NetworkAccessManagerProxy.h" -#include "PodcastModel.h" - -#include -#include -#include -#include - -#include -#include -#include - -using namespace Podcasts; - -GpodderProvider::GpodderProvider( const QString& username, - const QString& devicename, - ApiRequest *apiRequest ) - : m_apiRequest( apiRequest ) - , m_username( username ) - , m_deviceName( devicename ) - , m_channels() - , m_addRemoveResult() - , m_deviceUpdatesResult() - , m_episodeActionListResult() - , m_timestampStatus( 0 ) - , m_timestampSubscription( subscriptionTimestamp() ) - , m_removeAction( 0 ) - , m_addList() - , m_removeList() - , m_timerGeneratePlayAction( new QTimer( this ) ) - , m_timerSynchronizeStatus( new QTimer( this ) ) - , m_timerSynchronizeSubscriptions( new QTimer( this ) ) -{ - //We have to load episode actions and podcasts subscriptions changes - //that weren't uploaded before the time we closed amarok - loadCachedEpisodeActions(); - loadCachedPodcastsChanges(); - - //Request all channels and episodes from m_devicename device and after it - //request episode actions too - requestDeviceUpdates(); - - //Connect default podcasts signals to make possible to ask the user if he wants - //to upload a new local podcast to gpodder.net - connect( The::playlistManager()->defaultPodcasts(), - SIGNAL(playlistAdded(Playlists::PlaylistPtr)), - SLOT(slotSyncPlaylistAdded(Playlists::PlaylistPtr)) ); - connect( The::playlistManager()->defaultPodcasts(), - SIGNAL(playlistRemoved(Playlists::PlaylistPtr)), - SLOT(slotSyncPlaylistRemoved(Playlists::PlaylistPtr)) ); - - Podcasts::SqlPodcastProvider *sqlPodcastProvider; - - sqlPodcastProvider = - dynamic_cast - ( The::playlistManager()->defaultPodcasts() ); - - connect( The::podcastModel(), - SIGNAL(episodeMarkedAsNew(Podcasts::PodcastEpisodePtr)), - SLOT(slotEpisodeMarkedAsNew(Podcasts::PodcastEpisodePtr)) ); - - if( sqlPodcastProvider ) - { - connect( sqlPodcastProvider, - SIGNAL(episodeDeleted(Podcasts::PodcastEpisodePtr)), - SLOT(slotEpisodeDeleted(Podcasts::PodcastEpisodePtr)) ); - connect( sqlPodcastProvider, - SIGNAL(episodeDownloaded(Podcasts::PodcastEpisodePtr)), - SLOT(slotEpisodeDownloaded(Podcasts::PodcastEpisodePtr)) ); - } - - //Connect engine controller signals to make possible to synchronize podcast status - connect( The::engineController(), SIGNAL(trackChanged(Meta::TrackPtr)), - SLOT(slotTrackChanged(Meta::TrackPtr)) ); - connect( The::engineController(), SIGNAL(trackPositionChanged(qint64,bool)), - SLOT(slotTrackPositionChanged(qint64,bool)) ); - connect( The::engineController(), SIGNAL(paused()), - SLOT(slotPaused()) ); - - //These timers will periodically synchronize data between local podcasts and gpodder.net - connect( m_timerSynchronizeStatus, SIGNAL(timeout()), - SLOT(timerSynchronizeStatus()) ); - connect( m_timerSynchronizeSubscriptions, SIGNAL(timeout()), - SLOT(timerSynchronizeSubscriptions()) ); - connect( m_timerGeneratePlayAction, SIGNAL(timeout()), - SLOT(timerGenerateEpisodeAction()) ); - - m_timerGeneratePlayAction->stop(); - m_timerSynchronizeStatus->stop(); - m_timerSynchronizeSubscriptions->stop(); -} - -GpodderProvider::~GpodderProvider() -{ - delete m_timerGeneratePlayAction; - delete m_timerSynchronizeStatus; - delete m_timerSynchronizeSubscriptions; - - //Save cached episode actions and Podcast changes, in order to - //upload them to gpodder.net in the next - saveCachedEpisodeActions(); - saveCachedPodcastsChanges(); - - m_uploadEpisodeStatusMap.clear(); - m_episodeStatusMap.clear(); - m_redirectionUrlMap.clear(); - - m_channels.clear(); -} - -bool -GpodderProvider::possiblyContainsTrack( const KUrl &url ) const -{ - DEBUG_BLOCK - - foreach( PodcastChannelPtr ptr, m_channels ) - { - foreach( PodcastEpisodePtr episode, ptr->episodes() ) - { - if( episode->uidUrl() == url.url() ) - return true; - } - } - - return false; -} - -Meta::TrackPtr -GpodderProvider::trackForUrl( const KUrl &url ) -{ - DEBUG_BLOCK - - if( url.isEmpty() ) - return Meta::TrackPtr(); - - foreach( PodcastChannelPtr podcast, m_channels ) - { - foreach( PodcastEpisodePtr episode, podcast->episodes() ) - { - if( episode->uidUrl() == url.url() ) - { - return Meta::TrackPtr::dynamicCast( episode ); - } - } - } - - return Meta::TrackPtr(); -} - -PodcastEpisodePtr -GpodderProvider::episodeForGuid( const QString &guid ) -{ - foreach( PodcastChannelPtr ptr, m_channels ) - { - foreach( PodcastEpisodePtr episode, ptr->episodes() ) - { - if( episode->guid() == guid ) - return episode; - } - } - - return PodcastEpisodePtr(); -} - -void -GpodderProvider::addPodcast( const KUrl &url ) -{ - Q_UNUSED( url ) -} - -Playlists::PlaylistPtr -GpodderProvider::addPlaylist( Playlists::PlaylistPtr playlist ) -{ - DEBUG_BLOCK - - PodcastChannelPtr channel = PodcastChannelPtr::dynamicCast( playlist ); - if( channel.isNull() ) - return Playlists::PlaylistPtr(); - - //This function is executed every time a new channel is found on gpodder.net - PodcastChannelPtr master; - PodcastChannelPtr slave; - - foreach( PodcastChannelPtr tempChannel, - The::playlistManager()->defaultPodcasts()->channels() ) - if( tempChannel->url() == channel->url() ) - master = tempChannel; - - foreach( PodcastChannelPtr tempChannel, this->channels() ) - if( tempChannel->url() == channel->url() ) - slave = tempChannel; - - if( !master ) - master = The::playlistManager()->defaultPodcasts()->addChannel( channel ); - - if( !slave ) - { - slave = this->addChannel( master ); - - //If playlist is not a GpodderPodcastChannelPtr then we must subscribe - //it in gpodder.net - if( !GpodderPodcastChannelPtr::dynamicCast( playlist ) ) - { - //The service will try to subscribe this podcast in gpodder.net in - //the next synchronization - QUrl url = QUrl( slave->url().url() ); - m_removeList.removeAll( url ); - m_addList << url; - } - } - - //Create a playlist synchronization between master and slave - The::playlistManager()->setupSync( Playlists::PlaylistPtr::dynamicCast( master ), - Playlists::PlaylistPtr::dynamicCast( slave ) - ); - - return Playlists::PlaylistPtr::dynamicCast( slave ); -} - - -PodcastChannelPtr -GpodderProvider::addChannel( PodcastChannelPtr channel ) -{ - DEBUG_BLOCK - - GpodderPodcastChannelPtr gpodderChannel( new GpodderPodcastChannel( this, channel ) ); - - m_channels << PodcastChannelPtr::dynamicCast( gpodderChannel );; - - emit playlistAdded( Playlists::PlaylistPtr::dynamicCast( gpodderChannel ) ); - - return PodcastChannelPtr::dynamicCast( gpodderChannel ); -} - -PodcastEpisodePtr -GpodderProvider::addEpisode( PodcastEpisodePtr episode ) -{ - if( episode.isNull() ) - return PodcastEpisodePtr(); - - if( episode->channel().isNull() ) - { - debug() << "channel is null"; - - return PodcastEpisodePtr(); - } - - return episode; -} - -PodcastChannelList -GpodderProvider::channels() -{ - DEBUG_BLOCK - - PodcastChannelList list; - - foreach( PodcastChannelPtr channel, m_channels ) - list << PodcastChannelPtr::dynamicCast( channel ); - - return list; -} - -QString -GpodderProvider::prettyName() const -{ - return i18n( "Gpodder Podcasts" ); -} - -KIcon -GpodderProvider::icon() const -{ - return KIcon( "view-services-gpodder-amarok" ); -} - -Playlists::PlaylistList -GpodderProvider::playlists() -{ - Playlists::PlaylistList playlists; - - foreach( PodcastChannelPtr channel, m_channels ) - playlists << Playlists::PlaylistPtr::staticCast( channel ); - - return playlists; -} - -void -GpodderProvider::completePodcastDownloads() -{ -} - -void -GpodderProvider::removeChannel( const QUrl &url ) -{ - for( int i = 0; i < m_channels.size(); i++ ) - { - if( m_channels.at( i )->url() == url ) - { - PodcastChannelPtr channel = m_channels.at( i ); - QUrl url = QUrl( channel->url().url() ); - - m_channels.removeAll( channel ); - m_episodeStatusMap.remove( url ); - m_uploadEpisodeStatusMap.remove( url ); - m_addList.removeAll( url ); - - emit playlistRemoved( - Playlists::PlaylistPtr::dynamicCast( channel ) ); - - return; - } - } -} - -QActionList -GpodderProvider::channelActions( PodcastChannelList channels ) -{ - QActionList actions; - if( channels.isEmpty() ) - return actions; - - if( m_removeAction == 0 ) - { - m_removeAction = new QAction( KIcon( "edit-delete" ), - i18n( "&Delete Channel and Episodes" ), this ); - m_removeAction->setProperty( "popupdropper_svg_id", "delete" ); - connect( m_removeAction, SIGNAL(triggered()), SLOT(slotRemoveChannels()) ); - } - //Set the episode list as data that we'll retrieve in the slot - m_removeAction->setData( QVariant::fromValue( channels ) ); - actions << m_removeAction; - - return actions; -} - -QActionList -GpodderProvider::playlistActions( const Playlists::PlaylistList &playlists ) -{ - PodcastChannelList channels; - foreach( const Playlists::PlaylistPtr &playlist, playlists ) - { - PodcastChannelPtr channel = PodcastChannelPtr::dynamicCast( playlist ); - if( channel ) - channels << channel; - } - - return channelActions( channels ); -} - -void -GpodderProvider::slotRemoveChannels() -{ - DEBUG_BLOCK - - QAction *action = qobject_cast( QObject::sender() ); - - if( action == 0 ) - return; - - PodcastChannelList channels = action->data().value(); - action->setData( QVariant() ); //Clear data - - foreach( PodcastChannelPtr channel, channels ) - { - removeChannel( channel->url().url() ); - - //The service will try to unsubscribe this podcast from gpodder.net - //in the next synchronization - m_removeList << channel->url(); - } -} - -void -GpodderProvider::slotSyncPlaylistAdded( Playlists::PlaylistPtr playlist ) -{ - PodcastChannelPtr channel = Podcasts::PodcastChannelPtr::dynamicCast( playlist ); - //If the new channel already exist in gpodder channels, then - //we don't have to add it to gpodder.net again - foreach( PodcastChannelPtr tempChannel, m_channels ) - if( channel->url() == tempChannel->url() ) - return; - - addPlaylist( playlist ); - m_timerSynchronizeSubscriptions->start( 60000 ); -} - -void -GpodderProvider::slotSyncPlaylistRemoved( Playlists::PlaylistPtr playlist ) -{ - Podcasts::PodcastChannelPtr channel = Podcasts::PodcastChannelPtr::dynamicCast( playlist ); - //If gpodder channels doesn't contais the removed channel from default - //podcast provider, then we don't have to remove it from gpodder.net - foreach( PodcastChannelPtr tempChannel, m_channels ) - if( channel->url() == tempChannel->url() ) - { - removeChannel( tempChannel->url().url() ); - - //The service will try to unsubscribe this podcast from gpodder.net - //in the next synchronization - m_removeList << tempChannel->url(); - m_timerSynchronizeSubscriptions->start( 60000 ); - return; - } -} - -qulonglong -GpodderProvider::subscriptionTimestamp() -{ - KConfigGroup config = KGlobal::config()->group( GpodderServiceConfig::configSectionName() ); - return config.readEntry( "subscriptionTimestamp", 0 ); -} - -void -GpodderProvider::setSubscriptionTimestamp( qulonglong newTimestamp ) -{ - KConfigGroup config = KGlobal::config()->group( GpodderServiceConfig::configSectionName() ); - config.writeEntry( "subscriptionTimestamp", newTimestamp ); -} - -void GpodderProvider::synchronizeStatus() -{ - DEBUG_BLOCK - - debug() << "new episodes status: " << m_uploadEpisodeStatusMap.size(); - - if( Solid::Networking::status() == Solid::Networking::Unconnected ) - return; - - if( !m_uploadEpisodeStatusMap.isEmpty() ) - { - m_episodeActionsResult = - m_apiRequest->uploadEpisodeActions( m_username, - m_uploadEpisodeStatusMap.values() ); - - //Only clear m_episodeStatusList if the synchronization with gpodder.net really worked - connect( m_episodeActionsResult.data(), SIGNAL(finished()), - SLOT(slotSuccessfulStatusSynchronisation()) ); - connect( m_episodeActionsResult.data(), - SIGNAL(requestError(QNetworkReply::NetworkError)), - SLOT(synchronizeStatusRequestError(QNetworkReply::NetworkError)) ); - connect( m_episodeActionsResult.data(), SIGNAL(parseError()), - SLOT(synchronizeStatusParseError()) ); - - Amarok::Components::logger()->shortMessage( i18n( "Trying to synchronize statuses with gpodder.net" ) ); - } - else - m_timerSynchronizeStatus->stop(); -} - -void GpodderProvider::slotSuccessfulStatusSynchronisation() -{ - DEBUG_BLOCK - - m_timestampStatus = QDateTime::currentMSecsSinceEpoch(); - - m_uploadEpisodeStatusMap.clear(); - - //In addition, the server MUST send any URLs that have been rewritten (sanitized, see bug:747) - //as a list of tuples with the key "update_urls". The client SHOULD parse this list and update - //the local subscription list accordingly (the server only sanitizes the URL, so the semantic - //"content" should stay the same and therefore the client can simply update the URL value - //locally and use it for future updates - updateLocalPodcasts( m_episodeActionsResult->updateUrlsList() ); -} - -void GpodderProvider::synchronizeStatusParseError() -{ - DEBUG_BLOCK - - QTimer::singleShot( 20000, this, SLOT(timerSynchronizeStatus()) ); - - debug() << "synchronizeStatus [Status Synchronization] - Parse error"; -} - -void GpodderProvider::synchronizeStatusRequestError(QNetworkReply::NetworkError error) -{ - DEBUG_BLOCK - - QTimer::singleShot( 20000, this, SLOT(timerSynchronizeStatus()) ); - - debug() << "synchronizeStatus [Status Synchronization] - Request error nr.: " << error; -} - -void -GpodderProvider::synchronizeSubscriptions() -{ - DEBUG_BLOCK - - debug() << "add: " << m_addList.size(); - debug() << "remove: " << m_removeList.size(); - - if( Solid::Networking::status() == Solid::Networking::Unconnected ) - return; - - if( !m_removeList.isEmpty() || !m_addList.isEmpty() ) - { - m_addRemoveResult = - m_apiRequest->addRemoveSubscriptions( m_username, m_deviceName, m_addList, m_removeList ); - - //Only clear m_addList and m_removeList if the synchronization with gpodder.net really worked - connect( m_addRemoveResult.data(), SIGNAL(finished()), this, - SLOT(slotSuccessfulSubscriptionSynchronisation()) ); - - Amarok::Components::logger()->shortMessage( i18n( "Trying to synchronize subscriptions with gpodder.net" ) ); - } - else - m_timerSynchronizeSubscriptions->stop(); -} - -void -GpodderProvider::slotSuccessfulSubscriptionSynchronisation() -{ - DEBUG_BLOCK - - m_timestampSubscription = QDateTime::currentMSecsSinceEpoch(); - setSubscriptionTimestamp( m_timestampSubscription ); - - m_addList.clear(); - m_removeList.clear(); - - //In addition, the server MUST send any URLs that have been rewritten (sanitized, see bug:747) - //as a list of tuples with the key "update_urls". The client SHOULD parse this list and update - //the local subscription list accordingly (the server only sanitizes the URL, so the semantic - //"content" should stay the same and therefore the client can simply update the URL value - //locally and use it for future updates - updateLocalPodcasts( m_addRemoveResult->updateUrlsList() ); -} - -void -GpodderProvider::slotTrackChanged( Meta::TrackPtr track ) -{ - m_trackToSyncStatus = NULL; - - if( track != Meta::TrackPtr( 0 ) ) - { - //If the episode is from one of the gpodder subscribed podcasts, then we must keep looking it - if( ( this->possiblyContainsTrack( track->uidUrl() ) ) || - ( this->possiblyContainsTrack( track->uidUrl() ) && - The::playlistManager()->defaultPodcasts()->possiblyContainsTrack( track->uidUrl() ) - ) ) - { - m_trackToSyncStatus = track; - - QTimer::singleShot( 10000, this, SLOT(timerPrepareToSyncPodcastStatus()) ); - - //A bookmark will be created if we have a play status available, - //for current track, at m_episodeStatusMap - createPlayStatusBookmark(); - - return; - } - } - - m_timerGeneratePlayAction->stop(); - //EpisodeActions should be sent when the user clicks - //stops and doesn't resume listening in e.g. 1 minute - //Or when the user is not listening a podcast in e.g. 1 minute - m_timerSynchronizeStatus->start( 60000 ); -} - -void -GpodderProvider::slotTrackPositionChanged( qint64 position, bool userSeek ) -{ - Q_UNUSED( position ) - - //If the current track is in one of the subscribed gpodder channels and it's position - //is not at the beginning of the track, then we probably should sync it status. - if( m_trackToSyncStatus ) - { - if( userSeek ) - { - //Test if this track still playing after 10 seconds to avoid accidentally user changes - QTimer::singleShot( 10000, this, SLOT(timerPrepareToSyncPodcastStatus()) ); - } - } -} - -void GpodderProvider::slotPaused() -{ - m_timerGeneratePlayAction->stop(); - //EpisodeActions should be sent when the user clicks pause - //or stop and doesn't resume listening in e.g. 1 minute - m_timerSynchronizeStatus->start( 60000 ); -} - -void -GpodderProvider::timerSynchronizeSubscriptions() -{ - synchronizeSubscriptions(); -} - -void -GpodderProvider::timerSynchronizeStatus() -{ - synchronizeStatus(); -} - -void -GpodderProvider::timerPrepareToSyncPodcastStatus() -{ - if( The::engineController()->currentTrack() == m_trackToSyncStatus ) - { - EpisodeActionPtr tempEpisodeAction; - PodcastEpisodePtr tempEpisode = PodcastEpisodePtr::dynamicCast( m_trackToSyncStatus ); - - if( tempEpisode ) - { - qulonglong positionSeconds = The::engineController()->trackPosition(); - qulonglong lengthSeconds = The::engineController()->trackLength() / 1000; - - QString podcastUrl = resolvedPodcastUrl( tempEpisode ).url(); - - tempEpisodeAction = EpisodeActionPtr( - new EpisodeAction( QUrl( podcastUrl ), - QUrl( tempEpisode->uidUrl() ), - m_deviceName, - EpisodeAction::Play, - QDateTime::currentMSecsSinceEpoch(), - 1, - positionSeconds + 1, - lengthSeconds - ) ); - - //Any previous episodeAction, from the same podcast, will be replaced - m_uploadEpisodeStatusMap.insert( tempEpisode->uidUrl(), tempEpisodeAction ); - } - - //Starts to generate EpisodeActions - m_timerGeneratePlayAction->start( 30000 ); - } -} - -void GpodderProvider::timerGenerateEpisodeAction() -{ - //Create and update episode actions - if( The::engineController()->currentTrack() == m_trackToSyncStatus ) - { - EpisodeActionPtr tempEpisodeAction; - PodcastEpisodePtr tempEpisode = PodcastEpisodePtr::dynamicCast( m_trackToSyncStatus ); - - if( tempEpisode ) - { - qulonglong positionSeconds = The::engineController()->trackPosition(); - qulonglong lengthSeconds = The::engineController()->trackLength() / 1000; - - QString podcastUrl = resolvedPodcastUrl( tempEpisode ).url(); - - tempEpisodeAction = EpisodeActionPtr( - new EpisodeAction( QUrl( podcastUrl ), - QUrl( tempEpisode->uidUrl() ), - m_deviceName, - EpisodeAction::Play, - QDateTime::currentMSecsSinceEpoch(), - 1, - positionSeconds + 1, - lengthSeconds - ) ); - - //Any previous episodeAction, from the same podcast, will be replaced - m_uploadEpisodeStatusMap.insert( tempEpisode->uidUrl(), tempEpisodeAction ); - //Make local podcasts aware of new episodeActions - m_episodeStatusMap.insert( tempEpisode->uidUrl(), tempEpisodeAction ); - } - } -} - -void -GpodderProvider::requestDeviceUpdates() -{ - DEBUG_BLOCK - - if( Solid::Networking::status() == Solid::Networking::Unconnected ) - { - QTimer::singleShot( 10000, this, SLOT(requestDeviceUpdates()) ); - return; - } - - m_deviceUpdatesResult = - m_apiRequest->deviceUpdates( m_username, - m_deviceName, - 0 ); - - connect( m_deviceUpdatesResult.data(), SIGNAL(finished()), - SLOT(deviceUpdatesFinished()) ); - connect( m_deviceUpdatesResult.data(), - SIGNAL(requestError(QNetworkReply::NetworkError)), - SLOT(deviceUpdatesRequestError(QNetworkReply::NetworkError)) ); - connect( m_deviceUpdatesResult.data(), SIGNAL(parseError()), - SLOT(deviceUpdatesParseError()) ); -} - -void -GpodderProvider::deviceUpdatesFinished() -{ - DEBUG_BLOCK - - debug() << "DeviceUpdate timestamp: " << m_deviceUpdatesResult->timestamp(); - - //Channels to subscribe locally - foreach( mygpo::PodcastPtr podcast, m_deviceUpdatesResult->addList() ) - { - debug() << "Subscribing GPO channel: " << podcast->title() << ": " << podcast->url(); - - GpodderPodcastChannelPtr channel = - GpodderPodcastChannelPtr( new GpodderPodcastChannel( this, podcast ) ); - - //First we need to resolve redirection url's if there is any - requestUrlResolve( channel ); - } - - //Request the last episode status for every episode in gpodder.net - //subscribed podcasts - QTimer::singleShot( 1000, this, SLOT(requestEpisodeActionsInCascade()) ); - - //Only after all subscription changes are committed should we save the timestamp - m_timestampSubscription = m_deviceUpdatesResult->timestamp(); - setSubscriptionTimestamp( m_timestampSubscription ); -} - -void -GpodderProvider::continueDeviceUpdatesFinished() -{ - foreach( GpodderPodcastChannelPtr channel, m_resolvedChannelsToBeAdded ) - { - m_channelsToRequestActions.enqueue( channel->url() ); - - PodcastChannelPtr master; - PodcastChannelPtr slave; - - slave = this->addChannel( PodcastChannelPtr::dynamicCast( channel ) ); - - foreach( PodcastChannelPtr tempChannel, The::playlistManager()->defaultPodcasts()->channels() ) - if( tempChannel->url() == channel->url() ) - master = tempChannel; - - if( !master ) - master = The::playlistManager()->defaultPodcasts()->addChannel( slave ); - - //Create a playlist synchronization between master and slave - The::playlistManager()->setupSync( Playlists::PlaylistPtr::dynamicCast( master ), - Playlists::PlaylistPtr::dynamicCast( slave ) - ); - } - - m_resolvedChannelsToBeAdded.clear(); -} - -void -GpodderProvider::deviceUpdatesParseError() -{ - DEBUG_BLOCK - - QTimer::singleShot( 10000, this, SLOT(requestDeviceUpdates()) ); - - debug() << "deviceUpdates [Subscription Synchronization] - Parse error"; - Amarok::Components::logger()->shortMessage( i18n( "GPodder Service failed to get data from the server. Will retry in 10 seconds..." ) ); -} - -void -GpodderProvider::deviceUpdatesRequestError( QNetworkReply::NetworkError error ) -{ - DEBUG_BLOCK - - QTimer::singleShot( 10000, this, SLOT(requestDeviceUpdates()) ); - - debug() << "deviceUpdates [Subscription Synchronization] - Request error nr.: " << error; - Amarok::Components::logger()->shortMessage( i18n( "GPodder Service failed to get data from the server. Will retry in 10 seconds..." ) ); -} - -void -GpodderProvider::requestEpisodeActionsInCascade() -{ - DEBUG_BLOCK - - if( Solid::Networking::status() == Solid::Networking::Unconnected ) - { - QTimer::singleShot( 10000, this, SLOT(requestEpisodeActionsInCascade()) ); - return; - } - - //This function will download all episode actions for - //every podcast contained in m_channelsToRequestActions - if( !m_channelsToRequestActions.isEmpty() ) - { - QUrl url = m_channelsToRequestActions.head(); - m_episodeActionListResult = m_apiRequest->episodeActionsByPodcast( m_username, url.toString(), true ); - debug() << "Requesting actions for " << url.toString(); - connect( m_episodeActionListResult.data(), SIGNAL(finished()), - SLOT(episodeActionsInCascadeFinished()) ); - connect( m_episodeActionListResult.data(), - SIGNAL(requestError(QNetworkReply::NetworkError)), - SLOT(episodeActionsInCascadeRequestError(QNetworkReply::NetworkError)) ); - connect( m_episodeActionListResult.data(), SIGNAL(parseError()), - SLOT(episodeActionsInCascadeParseError()) ); - } - else - { - //We should try to upload cached EpisodeActions to gpodder.net - synchronizeStatus(); - } -} - -void -GpodderProvider::episodeActionsInCascadeFinished() -{ - DEBUG_BLOCK - - m_timestampStatus = m_episodeActionListResult->timestamp(); - - foreach( EpisodeActionPtr tempEpisodeAction, m_episodeActionListResult->list() ) - { - if( tempEpisodeAction->action() == EpisodeAction::Play ) - { - debug() << QString( "Adding a new play status to episode: %1" ) - .arg( tempEpisodeAction->episodeUrl().toString() ); - - m_episodeStatusMap.insert( tempEpisodeAction->episodeUrl(), tempEpisodeAction ); - - //A bookmark will be created if we have a play status available, - //for current track, at m_episodeStatusMap - createPlayStatusBookmark(); - } - else - { - PodcastChannelPtr channel; - PodcastEpisodePtr episode; - - foreach( PodcastChannelPtr tempChannel, m_channels ) - if( tempChannel->url() == tempEpisodeAction->podcastUrl() ) - { - channel = tempChannel; - - foreach( PodcastEpisodePtr tempEpisode, channel->episodes() ) - if( tempEpisode->uidUrl() == tempEpisodeAction->episodeUrl().toString() ) - episode = tempEpisode; - } - - if( channel && episode ) - { - if( tempEpisodeAction->action() == EpisodeAction::New ) - { - if( !episode ) - { - debug() << QString( "New episode to be added found: %1" ) - .arg( tempEpisodeAction->episodeUrl().toString() ); - - PodcastEpisodePtr tempEpisode; - tempEpisode = PodcastEpisodePtr( new PodcastEpisode() ); - tempEpisode->setUidUrl( tempEpisodeAction->episodeUrl() ); - tempEpisode->setChannel( PodcastChannelPtr::dynamicCast( channel ) ); - - channel->addEpisode( tempEpisode ); - } - else - { - debug() << QString( "Marking an existent episode as new: %1" ) - .arg( tempEpisodeAction->episodeUrl().toString() ); - - episode->setNew( true ); - } - } - else if( tempEpisodeAction->action() == EpisodeAction::Download ) - { - debug() << QString( "Adding a new download status to episode: %1" ) - .arg( tempEpisodeAction->episodeUrl().toString() ); - - } - else if( tempEpisodeAction->action() == EpisodeAction::Delete ) - { - debug() << QString( "Adding a new delete status to episode: %1" ) - .arg( tempEpisodeAction->episodeUrl().toString() ); - - } - - m_episodeStatusMap.insert( tempEpisodeAction->episodeUrl(), tempEpisodeAction ); - } - else - { - //For some reason the podcast and/or episode for this action - //wasn't found - debug() << QString( "Episode and/or channel not found" );; - } - - } - } - - //We must remove this podcast url and continue with the others - m_channelsToRequestActions.dequeue(); - - QTimer::singleShot( 100, this, SLOT(requestEpisodeActionsInCascade()) ); -} - -void -GpodderProvider::episodeActionsInCascadeParseError() -{ - DEBUG_BLOCK - - QTimer::singleShot( 10000, this, SLOT(requestEpisodeActionsInCascade()) ); - //If we fail to get EpisodeActions for this channel then we must put it - //at the end of the list. In order to be synced later on. - m_channelsToRequestActions.enqueue( m_channelsToRequestActions.dequeue() ); - - debug() << "episodeActionsInCascade [Status Synchronization] - Parse Error"; -} - -void -GpodderProvider::episodeActionsInCascadeRequestError( QNetworkReply::NetworkError error ) -{ - DEBUG_BLOCK - - QTimer::singleShot( 10000, this, SLOT(requestEpisodeActionsInCascade()) ); - //If we fail to get EpisodeActions for this channel then we must put it - //at the end of the list. In order to be synced later on. - m_channelsToRequestActions.enqueue( m_channelsToRequestActions.dequeue() ); - - debug() << "episodeActionsInCascade [Status Synchronization] - Request error nr.: " << error; -} - -void -GpodderProvider::updateLocalPodcasts( const QList > updatedUrls ) -{ - QList< QPair >::const_iterator tempUpdatedUrl = updatedUrls.begin(); - - for(; tempUpdatedUrl != updatedUrls.end(); ++tempUpdatedUrl ) - { - foreach( PodcastChannelPtr tempChannel, The::playlistManager()->defaultPodcasts()->channels() ) - { - if( tempChannel->url() == (*tempUpdatedUrl).first ) - tempChannel->setUrl( (*tempUpdatedUrl).second ); - } - - foreach( PodcastChannelPtr tempGpodderChannel, m_channels ) - { - if( tempGpodderChannel->url() == (*tempUpdatedUrl).first ) - tempGpodderChannel->setUrl( (*tempUpdatedUrl).second ); - } - } -} - -void -GpodderProvider::createPlayStatusBookmark() -{ - Meta::TrackPtr track = The::engineController()->currentTrack(); - - if( track ) - { - EpisodeActionPtr tempEpisodeAction = m_episodeStatusMap.value( track->uidUrl() ); - - //Create an AutoTimecode at the last position position, so the user always know where he stopped to listen - if( tempEpisodeAction && ( tempEpisodeAction->action() == EpisodeAction::Play ) ) - { - if( track && track->has() ) - { - QScopedPointer tcw( track->create() ); - qint64 positionMiliSeconds = tempEpisodeAction->position() * 1000; - - tcw->writeAutoTimecode( positionMiliSeconds ); - } - } - } -} - -void -GpodderProvider::requestUrlResolve( Podcasts::GpodderPodcastChannelPtr channel ) -{ - if( !channel ) - return; - - m_resolveUrlJob = KIO::get( channel->url(), KIO::Reload, KIO::HideProgressInfo ); - - connect( m_resolveUrlJob, SIGNAL(result(KJob*)), - SLOT(urlResolveFinished(KJob*)) ); - connect( m_resolveUrlJob, - SIGNAL(permanentRedirection(KIO::Job*,KUrl,KUrl)), - SLOT(urlResolvePermanentRedirection(KIO::Job*,KUrl,KUrl)) ); - - m_resolvedPodcasts.insert( m_resolveUrlJob, channel ); -} - -void -GpodderProvider::urlResolvePermanentRedirection( KIO::Job *job, const KUrl &fromUrl, const KUrl &toUrl ) -{ - DEBUG_BLOCK - - KIO::TransferJob *transferJob = dynamic_cast( job ); - GpodderPodcastChannelPtr channel = m_resolvedPodcasts.value( transferJob ); - - m_redirectionUrlMap.insert( toUrl, channel->url() ); - - channel->setUrl( toUrl ); - - debug() << fromUrl.url() << " was redirected to " << toUrl.url(); - - requestUrlResolve( channel ); -} - -void -GpodderProvider::urlResolveFinished( KJob * job ) -{ - KIO::TransferJob *transferJob = dynamic_cast( job ); - - if( transferJob && ( !( transferJob->isErrorPage() || job->error() ) ) ) - { - m_resolvedChannelsToBeAdded.push_back( m_resolvedPodcasts.value( transferJob ) ); - m_resolvedPodcasts.remove( transferJob ); - } - else - requestUrlResolve( m_resolvedPodcasts.value( transferJob ) ); - - if( m_resolvedPodcasts.empty() ) - continueDeviceUpdatesFinished(); - - m_resolveUrlJob = 0; -} - -void GpodderProvider::slotEpisodeDownloaded( PodcastEpisodePtr episode ) -{ - EpisodeActionPtr tempEpisodeAction; - - QString podcastUrl = resolvedPodcastUrl( episode ).url(); - - tempEpisodeAction = EpisodeActionPtr( - new EpisodeAction( QUrl( podcastUrl ), - QUrl( episode->uidUrl() ), - m_deviceName, - EpisodeAction::Download, - QDateTime::currentMSecsSinceEpoch(), - 0, - 0, - 0 - ) ); - - //Any previous episodeAction, from the same podcast, will be replaced - m_uploadEpisodeStatusMap.insert( episode->uidUrl(), tempEpisodeAction ); - - m_timerSynchronizeStatus->start( 60000 ); -} - -void GpodderProvider::slotEpisodeDeleted( PodcastEpisodePtr episode ) -{ - EpisodeActionPtr tempEpisodeAction; - - QString podcastUrl = resolvedPodcastUrl( episode ).url(); - - tempEpisodeAction = EpisodeActionPtr( - new EpisodeAction( QUrl( podcastUrl ), - QUrl( episode->uidUrl() ), - m_deviceName, - EpisodeAction::Delete, - QDateTime::currentMSecsSinceEpoch(), - 0, - 0, - 0 - ) ); - - //Any previous episodeAction, from the same podcast, will be replaced - m_uploadEpisodeStatusMap.insert( episode->uidUrl(), tempEpisodeAction ); - - m_timerSynchronizeStatus->start( 60000 ); -} - -void GpodderProvider::slotEpisodeMarkedAsNew( PodcastEpisodePtr episode ) -{ - EpisodeActionPtr tempEpisodeAction; - - QString podcastUrl = resolvedPodcastUrl( episode ).url(); - - tempEpisodeAction = EpisodeActionPtr( - new EpisodeAction( QUrl( podcastUrl ), - QUrl( episode->uidUrl() ), - m_deviceName, - EpisodeAction::New, - QDateTime::currentMSecsSinceEpoch(), - 0, - 0, - 0 - ) ); - - //Any previous episodeAction, from the same podcast, will be replaced - m_uploadEpisodeStatusMap.insert( episode->uidUrl(), tempEpisodeAction ); - - m_timerSynchronizeStatus->start( 60000 ); -} - -inline KConfigGroup -GpodderProvider::gpodderActionsConfig() const -{ - return Amarok::config( "GPodder Cached Episode Actions" ); -} - -void GpodderProvider::loadCachedEpisodeActions() -{ - DEBUG_BLOCK - - if( !gpodderActionsConfig().exists() ) - return; - - int action; - bool validActionType; - bool actionTypeConversion; - qulonglong timestamp = 0; - qulonglong started = 0; - qulonglong position = 0; - qulonglong total = 0; - QStringList actionsDetails; - EpisodeAction::ActionType actionType; - - foreach( QString episodeUrl, gpodderActionsConfig().keyList() ) - { - actionsDetails.clear(); - actionsDetails = gpodderActionsConfig().readEntry( episodeUrl ).split( ',' ); - - if( actionsDetails.count() != 6 ) - debug() << "There are less/more fields than expected."; - else - { - action = actionsDetails[1].toInt( &actionTypeConversion ); - - if( !actionTypeConversion ) - debug() << "Failed to convert actionType field to int."; - else - { - validActionType = true; - timestamp = actionsDetails[2].toULongLong(); - started = actionsDetails[3].toULongLong(); - position = actionsDetails[4].toULongLong(); - total = actionsDetails[5].toULongLong(); - - switch( action ) - { - case 0: actionType = EpisodeAction::Download; break; - case 1: actionType = EpisodeAction::Play; break; - case 2: actionType = EpisodeAction::Delete; break; - case 3: actionType = EpisodeAction::New; break; - default: validActionType = false; break; - } - - //We can't create a EpisodeAction if action isn't a valid alternative - if( !validActionType ) - debug() << "Action isn't a valid alternative."; - else - { - debug() << QString( "Loaded %1 action." ).arg( episodeUrl ); - - EpisodeActionPtr tempEpisodeAction = EpisodeActionPtr( - new EpisodeAction( QUrl( actionsDetails[0] ), - QUrl( episodeUrl ), - m_deviceName, - actionType, - timestamp, - started, - position, - total - ) ); - - //Any previous episodeAction, from the same podcast, will be replaced - m_uploadEpisodeStatusMap.insert( tempEpisodeAction->episodeUrl(), tempEpisodeAction ); - m_episodeStatusMap.insert( tempEpisodeAction->episodeUrl(), tempEpisodeAction ); - } - } - } - } - - //We should delete cached EpisodeActions, since we already loaded them - gpodderActionsConfig().deleteGroup(); - - synchronizeStatus(); -} - -void GpodderProvider::saveCachedEpisodeActions() -{ - DEBUG_BLOCK - - if( m_uploadEpisodeStatusMap.isEmpty() ) - return; - - int actionType; - QList actionsDetails; - - foreach( EpisodeActionPtr action, m_uploadEpisodeStatusMap.values() ) - { - actionsDetails.clear(); - actionsDetails.append( action->podcastUrl().toString() ); - - switch( action->action() ) - { - case EpisodeAction::Download: actionType = 0; break; - case EpisodeAction::Play: actionType = 1; break; - case EpisodeAction::Delete: actionType = 2; break; - case EpisodeAction::New: actionType = 3; break; - default: actionType = -1; break; - } - - actionsDetails.append( QString::number( actionType ) ); - actionsDetails.append( QString::number( action->timestamp() ) ); - actionsDetails.append( QString::number( action->started() ) ); - actionsDetails.append( QString::number( action->position() ) ); - actionsDetails.append( QString::number( action->total() ) ); - - gpodderActionsConfig().writeEntry( action->episodeUrl().toString(), actionsDetails ); - } -} - -inline KConfigGroup -GpodderProvider::gpodderPodcastsConfig() const -{ - return Amarok::config( "GPodder Cached Podcast Changes" ); -} - -void GpodderProvider::loadCachedPodcastsChanges() -{ - DEBUG_BLOCK - - if( !gpodderPodcastsConfig().exists() ) - return; - - QStringList podcastsUrlsToAdd; - QStringList podcastsUrlsToRemove; - - podcastsUrlsToAdd = gpodderPodcastsConfig().readEntry( "addList" ).split( ',' ); - podcastsUrlsToRemove = gpodderPodcastsConfig().readEntry( "removeList" ).split( ',' ); - - foreach( QString podcastUrl, podcastsUrlsToAdd ) - { - debug() << QString( "New channel to subscribe: %1" ).arg( podcastUrl ); - - m_addList.append( QUrl( podcastUrl ) ); - } - - foreach( QString podcastUrl, podcastsUrlsToRemove ) - { - debug() << QString( "New channel to unsubscribe: %1 action." ).arg( podcastUrl ); - - m_removeList.append( QUrl( podcastUrl ) ); - } - - //We should delete cached podcasts changes, since we already loaded them - gpodderPodcastsConfig().deleteGroup(); - - synchronizeSubscriptions(); -} - -void GpodderProvider::saveCachedPodcastsChanges() -{ - DEBUG_BLOCK - - if( !m_addList.isEmpty() ) - { - QStringList podcastUrlsToAdd; - - foreach( QUrl podcastUrl, m_addList ) - podcastUrlsToAdd.append( podcastUrl.toString() ); - - gpodderPodcastsConfig().writeEntry( "addList", podcastUrlsToAdd ); - } - - if( !m_removeList.isEmpty() ) - { - QStringList podcastsUrlsToRemove; - - foreach( QUrl podcastUrl, m_removeList ) - podcastsUrlsToRemove.append( podcastUrl.toString() ); - - gpodderPodcastsConfig().writeEntry( "removeList", podcastsUrlsToRemove ); - } -} - -KUrl GpodderProvider::resolvedPodcastUrl( const PodcastEpisodePtr episode ) -{ - KUrl podcastUrl = episode->channel()->url(); - - if( m_redirectionUrlMap.contains( podcastUrl ) ) - podcastUrl = m_redirectionUrlMap.value( podcastUrl ); - - return podcastUrl; -} diff --git a/amarok/src/services/gpodder/GpodderProvider.h b/amarok/src/services/gpodder/GpodderProvider.h deleted file mode 100644 index f5dc2682..00000000 --- a/amarok/src/services/gpodder/GpodderProvider.h +++ /dev/null @@ -1,183 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2011 Stefan Derkits * - * Copyright (c) 2011 Christian Wagner * - * Copyright (c) 2011 Felix Winter * - * Copyright (c) 2011 Lucas Lira Gomes * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef GPODDERPODCASTPROVIDER_H -#define GPODDERPODCASTPROVIDER_H - -#include "core/podcasts/PodcastProvider.h" -#include "core/podcasts/PodcastReader.h" -#include "GpodderPodcastMeta.h" -#include -#include -#include "playlistmanager/file/KConfigSyncRelStore.h" -#include "playlistmanager/PlaylistManager.h" - -#include -#include - -#include -#include -#include - -using namespace mygpo; - -class QAction; - -namespace Podcasts -{ -class GpodderProvider : public PodcastProvider -{ - Q_OBJECT -public: - GpodderProvider( const QString& username, const QString& devicename, ApiRequest *apiRequest ); - ~GpodderProvider(); - - //TrackProvider methods - bool possiblyContainsTrack( const KUrl &url ) const; - Meta::TrackPtr trackForUrl( const KUrl &url ); - - //PodcastProvider methods - /** Special function to get an episode for a given guid. - * - * note: this functions is required because KUrl does not preserve every possible guids. - * This means we can not use trackForUrl(). - * Problematic guids contain non-latin characters, percent encoded parts, capitals, etc. - */ - virtual PodcastEpisodePtr episodeForGuid( const QString &guid ); - - virtual void addPodcast( const KUrl &url ); - - virtual Podcasts::PodcastChannelPtr addChannel( Podcasts::PodcastChannelPtr channel ); - virtual Podcasts::PodcastEpisodePtr addEpisode( Podcasts::PodcastEpisodePtr episode ); - - virtual Podcasts::PodcastChannelList channels(); - - // PlaylistProvider methods - virtual QString prettyName() const; - virtual KIcon icon() const; - virtual Playlists::PlaylistList playlists(); - virtual void completePodcastDownloads(); - - /** Copy a playlist to the provider. - */ - virtual Playlists::PlaylistPtr addPlaylist( Playlists::PlaylistPtr playlist ); - virtual QActionList playlistActions( const Playlists::PlaylistList &playlists ); - -private slots: - void requestDeviceUpdates(); - void deviceUpdatesFinished(); - void continueDeviceUpdatesFinished(); - void deviceUpdatesParseError(); - void deviceUpdatesRequestError( QNetworkReply::NetworkError error ); - - void requestEpisodeActionsInCascade(); - void episodeActionsInCascadeFinished(); - void episodeActionsInCascadeParseError(); - void episodeActionsInCascadeRequestError( QNetworkReply::NetworkError error ); - - void timerGenerateEpisodeAction(); - void timerSynchronizeStatus(); - void timerSynchronizeSubscriptions(); - void timerPrepareToSyncPodcastStatus(); - - void slotRemoveChannels(); - void synchronizeStatusParseError(); - void synchronizeStatusRequestError( QNetworkReply::NetworkError error ); - void slotSuccessfulStatusSynchronisation(); - void slotSuccessfulSubscriptionSynchronisation(); - - void slotSyncPlaylistAdded( Playlists::PlaylistPtr playlist ); - void slotSyncPlaylistRemoved( Playlists::PlaylistPtr playlist ); - - void slotPaused(); - void slotTrackChanged( Meta::TrackPtr track ); - void slotTrackPositionChanged( qint64 position, bool userSeek ); - - void requestUrlResolve( GpodderPodcastChannelPtr channel ); - void urlResolvePermanentRedirection ( KIO::Job *job, const KUrl &fromUrl, - const KUrl &toUrl ); - void urlResolveFinished( KJob * ); - - void slotEpisodeDownloaded( Podcasts::PodcastEpisodePtr episode ); - void slotEpisodeDeleted( Podcasts::PodcastEpisodePtr episode ); - void slotEpisodeMarkedAsNew( Podcasts::PodcastEpisodePtr episode ); - -private: - QActionList channelActions( PodcastChannelList episodes ); - - ApiRequest *m_apiRequest; - const QString m_username; - const QString m_deviceName; - PodcastChannelList m_channels; - KIO::TransferJob *m_resolveUrlJob; - - AddRemoveResultPtr m_addRemoveResult; - DeviceUpdatesPtr m_deviceUpdatesResult; - AddRemoveResultPtr m_episodeActionsResult; - EpisodeActionListPtr m_episodeActionListResult; - - qulonglong m_timestampStatus; - qulonglong m_timestampSubscription; - - qulonglong subscriptionTimestamp(); - void setSubscriptionTimestamp( qulonglong newTimestamp ); - - void removeChannel( const QUrl &url ); - void createPlayStatusBookmark(); - - void synchronizeStatus(); - void synchronizeSubscriptions(); - void updateLocalPodcasts( const QList< QPair > updatedUrls ); - - KConfigGroup gpodderActionsConfig() const; - void loadCachedEpisodeActions(); - void saveCachedEpisodeActions(); - - KConfigGroup gpodderPodcastsConfig() const; - void loadCachedPodcastsChanges(); - void saveCachedPodcastsChanges(); - - QAction *m_removeAction; - - //Lists of podcasts to be added or removed from gpodder.net - QList m_addList; - QList m_removeList; - - KUrl resolvedPodcastUrl( const PodcastEpisodePtr episode ); - - QMap m_redirectionUrlMap; - QQueue m_channelsToRequestActions; - QMap m_resolvedPodcasts; - //Used as a temporary container for podcasts with already urls resolved - //before adding them to m_channels - QQueue m_resolvedChannelsToBeAdded; - - QMap m_episodeStatusMap; - QMap m_uploadEpisodeStatusMap; - - QTimer *m_timerGeneratePlayAction; - QTimer *m_timerSynchronizeStatus; - QTimer *m_timerSynchronizeSubscriptions; - - Meta::TrackPtr m_trackToSyncStatus; -}; - -} - -#endif diff --git a/amarok/src/services/gpodder/GpodderService.cpp b/amarok/src/services/gpodder/GpodderService.cpp deleted file mode 100644 index 9cc9a7b9..00000000 --- a/amarok/src/services/gpodder/GpodderService.cpp +++ /dev/null @@ -1,287 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 - 2011 Stefan Derkits * - * Copyright (c) 2010 - 2011 Christian Wagner * - * Copyright (c) 2010 - 2011 Felix Winter * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "GpodderService" - -#include "GpodderService.h" - -#include "core/podcasts/PodcastProvider.h" -#include "core/support/Debug.h" -#include "GpodderPodcastTreeItem.h" -#include "GpodderServiceConfig.h" -#include "GpodderServiceModel.h" -#include "GpodderServiceView.h" -#include "GpodderSortFilterProxyModel.h" -#include -#include -#include "playlistmanager/PlaylistManager.h" -#include "widgets/SearchWidget.h" - -#include -#include -#include -#include - -#include - -AMAROK_EXPORT_SERVICE_PLUGIN( gpodder, GpodderServiceFactory ) - -GpodderServiceFactory::GpodderServiceFactory( QObject *parent, const QVariantList &args ) - : ServiceFactory( parent, args ) -{ - KPluginInfo pluginInfo( "amarok_service_gpodder.desktop", "services" ); - pluginInfo.setConfig( config() ); - m_info = pluginInfo; -} - -void -GpodderServiceFactory::init() -{ - ServiceBase *service = createGpodderService(); - if( service ) - { - m_initialized = true; - emit newService( service ); - } -} - -QString -GpodderServiceFactory::name() -{ - return "gpodder.net"; -} - -KPluginInfo -GpodderServiceFactory::info() -{ - KPluginInfo pluginInfo( "amarok_service_gpodder.desktop", "services" ); - pluginInfo.setConfig( config() ); - return pluginInfo; -} - -KConfigGroup -GpodderServiceFactory::config() -{ - return Amarok::config( GpodderServiceConfig::configSectionName() ); -} - -void -GpodderServiceFactory::slotCreateGpodderService() -{ - //Until we can remove a service when networking gets disabled, only create it the first time. - if( !m_initialized ) - { - ServiceBase *service = createGpodderService(); - if( service ) - { - m_initialized = true; - emit newService( service ); - } - } -} - -void -GpodderServiceFactory::slotRemoveGpodderService() -{ - if( activeServices().isEmpty() ) - return; - - m_initialized = false; - emit removeService( activeServices().first() ); -} - -ServiceBase * -GpodderServiceFactory::createGpodderService() -{ - ServiceBase *service = new GpodderService( this, QLatin1String( "gpodder" ) ); - return service; -} - -GpodderService::GpodderService( GpodderServiceFactory *parent, const QString &name ) - : ServiceBase( name, parent, false ) - , m_inited( false ) - , m_apiRequest( 0 ) - , m_podcastProvider( 0 ) - , m_proxyModel( 0 ) - , m_subscribeButton( 0 ) - , m_selectionModel( 0 ) -{ - DEBUG_BLOCK - - setShortDescription( i18n( "gpodder.net: Podcast Directory Service" ) ); - setIcon( KIcon( "view-services-gpodder-amarok" ) ); - setLongDescription( - i18n( "gpodder.net is an online Podcast Directory & Synchonisation Service." ) ); - setImagePath( KStandardDirs::locate( "data", "amarok/images/mygpo.png" ) ); - - init(); -} - -GpodderService::~GpodderService() -{ - DEBUG_BLOCK - - if( m_podcastProvider ) - { - //Remove the provider - The::playlistManager()->removeProvider( m_podcastProvider ); - delete m_podcastProvider; - } - - if ( m_apiRequest ) - delete m_apiRequest; -} - -//This Method should only contain the most necessary things for initilazing the Service -void -GpodderService::init() -{ - DEBUG_BLOCK - - GpodderServiceConfig config; - - const QString &username = config.username(); - const QString &password = config.password(); - - if ( m_apiRequest ) - delete m_apiRequest; - - //We have to check this here too, since KWallet::openWallet() doesn't - //guarantee that it will always return a wallet. - //Notice that LastFm service does the same verification. - if ( !config.isDataLoaded() ) - { - debug() << "Failed to read gpodder credentials."; - m_apiRequest = new mygpo::ApiRequest( The::networkAccessManager() ); - } - else - { - if( config.enableProvider() ) - { - m_apiRequest = new mygpo::ApiRequest( username, - password, - The::networkAccessManager() ); - if( m_podcastProvider ) - delete m_podcastProvider; - - enableGpodderProvider( username ); - } - else - m_apiRequest = new mygpo::ApiRequest( The::networkAccessManager() ); - } - - setServiceReady( true ); - m_inited = true; -} - -//This Method should contain the rest of the Service Initialization (not soo necessary things, that -//can be done after the Object was created) -void -GpodderService::polish() -{ - DEBUG_BLOCK - - generateWidgetInfo(); - - if( m_polished ) - return; - - //do not allow this content to get added to the playlist. At least not for now - setPlayableTracks( false ); - - GpodderServiceView *view = new GpodderServiceView( this ); - view->setHeaderHidden( true ); - view->setFrameShape( QFrame::NoFrame ); - - // Was set true in OpmlDirectoryService, but I think we won't need this on true - view->setDragEnabled( false ); - view->setItemsExpandable( true ); - - view->setSortingEnabled( false ); - view->setEditTriggers( QAbstractItemView::NoEditTriggers ); - view->setDragDropMode( QAbstractItemView::NoDragDrop ); - - setView( view ); - - GpodderServiceModel *sourceModel = new GpodderServiceModel( m_apiRequest, this ); - - m_proxyModel = new GpodderSortFilterProxyModel( this ); - m_proxyModel->setDynamicSortFilter( true ); - m_proxyModel->setFilterCaseSensitivity( Qt::CaseInsensitive ); - - m_proxyModel->setSourceModel( sourceModel ); - - setModel( m_proxyModel ); - - m_selectionModel = view->selectionModel(); - - m_subscribeButton = new QPushButton(); - m_subscribeButton->setParent( m_bottomPanel ); - m_subscribeButton->setText( i18n( "Subscribe" ) ); - m_subscribeButton->setObjectName( "subscribeButton" ); - m_subscribeButton->setIcon( KIcon( "get-hot-new-stuff-amarok" ) ); - - m_subscribeButton->setEnabled( true ); - - connect( m_subscribeButton, SIGNAL(clicked()), this, SLOT(subscribe()) ); - - connect( m_searchWidget, SIGNAL(filterChanged(QString)), - m_proxyModel, SLOT(setFilterWildcard(QString)) ); - - m_polished = true; -} - -void -GpodderService::itemSelected( CollectionTreeItem * selectedItem ) -{ - Q_UNUSED( selectedItem ) - DEBUG_BLOCK - return; -} - -void -GpodderService::subscribe() -{ - QModelIndex index = m_proxyModel->mapToSource( m_selectionModel->currentIndex() ); - GpodderTreeItem *treeItem = static_cast( index.internalPointer() ); - - if( GpodderPodcastTreeItem *podcastTreeItem = qobject_cast( treeItem ) ) - { - Podcasts::PodcastProvider *podcastProvider = The::playlistManager()->defaultPodcasts(); - KUrl kUrl( podcastTreeItem->podcast()->url() ); - podcastProvider->addPodcast( kUrl ); - } -} - -void -GpodderService::enableGpodderProvider( const QString &username ) -{ - DEBUG_BLOCK - - QString deviceName = QLatin1String( "amarok-" ) % QHostInfo::localHostName(); - - debug() << QString( "Enabling GpodderProvider( Username: %1 - Device: %1 )" ) - .arg( username ) - .arg( deviceName ); - - m_podcastProvider = new Podcasts::GpodderProvider( username, deviceName, m_apiRequest ); - - //Add the gpodder's provider to the playlist manager - The::playlistManager()->addProvider( m_podcastProvider, PlaylistManager::PodcastChannel ); - -} diff --git a/amarok/src/services/gpodder/GpodderService.h b/amarok/src/services/gpodder/GpodderService.h deleted file mode 100644 index 391ed5c3..00000000 --- a/amarok/src/services/gpodder/GpodderService.h +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 - 2011 Stefan Derkits * - * Copyright (c) 2010 - 2011 Christian Wagner * - * Copyright (c) 2010 - 2011 Felix Winter * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef GPODDERSERVICE_H -#define GPODDERSERVICE_H - -#include "core/support/Amarok.h" -#include "GpodderProvider.h" -#include "services/ServiceBase.h" - -#include -#include - -class GpodderService; - -namespace The { GpodderService *gpodderService(); } - -class GpodderServiceFactory : public ServiceFactory -{ - Q_OBJECT - -public: - GpodderServiceFactory( QObject *parent, const QVariantList &args ); - virtual ~GpodderServiceFactory() {} - - virtual void init(); - virtual QString name(); - virtual KPluginInfo info(); - virtual KConfigGroup config(); - -private slots: - void slotCreateGpodderService(); - void slotRemoveGpodderService(); - -private: - ServiceBase *createGpodderService(); -}; - -class GpodderService : public ServiceBase -{ - Q_OBJECT - -public: - GpodderService( GpodderServiceFactory *parent, const QString &name ); - virtual ~GpodderService(); - -private slots: - void subscribe(); - void itemSelected( CollectionTreeItem *selectedItem ); - -private: - void init(); - void polish(); - - void enableGpodderProvider( const QString &username ); - - virtual Collections::Collection *collection() { return 0; } - - bool m_inited; - - mygpo::ApiRequest *m_apiRequest; - - Podcasts::GpodderProvider *m_podcastProvider; - - QSortFilterProxyModel *m_proxyModel; - - QPushButton *m_subscribeButton; - QItemSelectionModel *m_selectionModel; -}; - -#endif // GPODDERSERVICE_H diff --git a/amarok/src/services/gpodder/GpodderServiceConfig.cpp b/amarok/src/services/gpodder/GpodderServiceConfig.cpp deleted file mode 100644 index 2bfb01ff..00000000 --- a/amarok/src/services/gpodder/GpodderServiceConfig.cpp +++ /dev/null @@ -1,237 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Shane King * - * Copyright (c) 2009 Leo Franchi * - * Copyright (c) 2010 Stefan Derkits * - * Copyright (c) 2010 Christian Wagner * - * Copyright (c) 2010 Felix Winter * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "GPodderConfig" - -#include "GpodderServiceConfig.h" - -#include "App.h" -#include "core/support/Debug.h" - -#include -#include - -#include - -GpodderServiceConfig::GpodderServiceConfig() - : m_username( "" ) - , m_password( "" ) - , m_enableProvider( false ) - , m_ignoreWallet( false ) - , m_isDataLoaded( false ) - , m_askDiag( 0 ) - , m_wallet( 0 ) -{ - DEBUG_BLOCK - - load(); -} - -GpodderServiceConfig::~GpodderServiceConfig() -{ - DEBUG_BLOCK - - if( m_askDiag ) - m_askDiag->deleteLater(); - - if( m_wallet ) - m_wallet->deleteLater(); -} - -void -GpodderServiceConfig::load() -{ - DEBUG_BLOCK - debug() << "Load config"; - - KConfigGroup config = KGlobal::config()->group( configSectionName() ); - - m_enableProvider = config.readEntry( "enableProvider", false ); - m_ignoreWallet = config.readEntry( "ignoreWallet", false ); - - //We only want to load the wallet if the user has enabled features that require a user/pass - tryToOpenWallet(); - - if( m_wallet ) - { - if( !m_wallet->hasFolder( "Amarok" ) ) - m_wallet->createFolder( "Amarok" ); - - // do a one-time transfer - // can remove at some point in the future, post-2.2 - m_wallet->setFolder( "Amarok" ); - - if( m_wallet->readPassword( "gpodder_password", m_password ) != 0 ) - debug() << "Failed to read gpodder.net password from kwallet!"; - else - { - QByteArray rawUsername; - - if( m_wallet->readEntry( "gpodder_username", rawUsername ) != 0 ) - debug() << "Failed to read gpodder.net username from kwallet.. :("; - else - m_username = QString::fromUtf8( rawUsername ); - } - } - else if( m_ignoreWallet ) - { - m_username = config.readEntry( "username", QString() ); - m_password = config.readEntry( "password", QString() ); - } - else - debug() << "Failed to load the data."; - - m_isDataLoaded = !( m_username.isEmpty() || m_password.isEmpty() ); -} - -void -GpodderServiceConfig::save() -{ - DEBUG_BLOCK - - debug() << "Save config"; - - KConfigGroup config = KGlobal::config()->group( configSectionName() ); - - config.writeEntry( "enableProvider", m_enableProvider ); - config.writeEntry( "ignoreWallet", m_ignoreWallet ); - - //Whenever this function is called, we'll assume the user wants to - //change something, so blow away the subscription timestamp key - config.writeEntry( "subscriptionTimestamp", 0 ); - - //Maybe the wallet had already closed or m_enableProvider and m_ignoreWallet - //could had changed also. So we try to reopen the wallet if it's not open. - tryToOpenWallet(); - - if( m_wallet ) - { - m_wallet->setFolder( "Amarok" ); - - if( m_wallet->writeEntry( "gpodder_username", m_username.toUtf8() ) != 0 ) - debug() << "Failed to save gpodder.net username to kwallet!"; - - if( m_wallet->writePassword( "gpodder_password", m_password ) != 0 ) - debug() << "Failed to save gpodder.net pw to kwallet!"; - } - else if( m_ignoreWallet ) - { - config.writeEntry( "username", m_username ); - config.writeEntry( "password", m_password ); - } - else - { - if( m_enableProvider ) - { - debug() << "Couldnt access the wallet to save the gpodder.net credentials"; - askAboutMissingKWallet(); - } - else - debug() << "There isn't valid credentials to be saved"; - } - - config.sync(); -} - -void -GpodderServiceConfig::askAboutMissingKWallet() -{ - if ( !m_askDiag ) - { - m_askDiag = new KDialog( 0 ); - - m_askDiag->setCaption( i18n( "gpodder.net credentials" ) ); - m_askDiag->setMainWidget( new QLabel( i18n( "No running KWallet found. Would you like Amarok to save your gpodder.net credentials in plaintext?" ), m_askDiag ) ); - m_askDiag->setButtons( KDialog::Yes | KDialog::No ); - m_askDiag->setModal( true ); - - connect( m_askDiag, SIGNAL(yesClicked()), this, SLOT(textDialogYes()) ); - connect( m_askDiag, SIGNAL(noClicked()), this, SLOT(textDialogNo()) ); - } - - m_askDiag->exec(); -} - -void GpodderServiceConfig::tryToOpenWallet() -{ - DEBUG_BLOCK - - //We only want to load the wallet if the user has enabled features - //that require a user/pass - if( ( m_enableProvider ) && ( !m_ignoreWallet ) ) - { - debug() << "Opening wallet"; - - //Open wallet unless explicitly told not to - m_wallet = KWallet::Wallet::openWallet( - KWallet::Wallet::NetworkWallet(), - 0, KWallet::Wallet::Synchronous ); - } - else - { - debug() << "The wallet was ignored or is not needed."; - m_wallet = 0; - } -} - -void -GpodderServiceConfig::reset() -{ - debug() << "Reset config"; - - m_username = ""; - m_password = ""; - m_enableProvider = false; - m_ignoreWallet = false; -} - -void -GpodderServiceConfig::textDialogYes() //SLOT -{ - DEBUG_BLOCK - - if ( !m_ignoreWallet ) - { - KConfigGroup config = KGlobal::config()->group( configSectionName() ); - - m_ignoreWallet = true; - config.writeEntry( "ignoreWallet ", m_ignoreWallet ); - - config.sync(); - } -} - -void -GpodderServiceConfig::textDialogNo() //SLOT -{ - DEBUG_BLOCK - - if ( m_ignoreWallet ) - { - KConfigGroup config = KGlobal::config()->group( configSectionName() ); - - m_ignoreWallet = false; - config.writeEntry( "ignoreWallet ", m_ignoreWallet ); - - config.sync(); - } -} - -#include "moc_GpodderServiceConfig.cpp" diff --git a/amarok/src/services/gpodder/GpodderServiceConfig.h b/amarok/src/services/gpodder/GpodderServiceConfig.h deleted file mode 100644 index 90447fd3..00000000 --- a/amarok/src/services/gpodder/GpodderServiceConfig.h +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Shane King * - * Copyright (c) 2009 Leo Franchi * - * Copyright (c) 2010 Stefan Derkits * - * Copyright (c) 2010 Christian Wagner * - * Copyright (c) 2010 Felix Winter * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef GPODDERSERVICECONFIG_H -#define GPODDERSERVICECONFIG_H - -#include -#include - -namespace KWallet { class Wallet; } - -class KDialog; - -class GpodderServiceConfig : public QObject -{ - Q_OBJECT - -public: - static const char *configSectionName() { return "Service_gpodder"; } - - GpodderServiceConfig(); - ~GpodderServiceConfig(); - - void load(); - void save(); - void reset(); - - const QString &username() { return m_username; } - void setUsername( const QString &username ) { m_username = username; } - - const QString &password() { return m_password; } - void setPassword( const QString &password ) { m_password = password; } - - bool enableProvider() { return m_enableProvider; } - void setEnableProvider( bool enableProvider ) { m_enableProvider = enableProvider; } - - bool ignoreWallet() { return m_ignoreWallet; } - void setIgnoreWallet( bool ignoreWallet ) { m_ignoreWallet = ignoreWallet; } - - bool isDataLoaded() { return m_isDataLoaded; } - -private slots: - void textDialogYes(); - void textDialogNo(); - -private: - void askAboutMissingKWallet(); - void tryToOpenWallet(); - - QString m_username; - QString m_password; - bool m_enableProvider; //Enables PodcastProvider if correct LoginData given - bool m_ignoreWallet; - bool m_isDataLoaded; - - KDialog *m_askDiag; - KWallet::Wallet *m_wallet; -}; - -#endif // GPODDERSERVICECONFIG_H diff --git a/amarok/src/services/gpodder/GpodderServiceModel.cpp b/amarok/src/services/gpodder/GpodderServiceModel.cpp deleted file mode 100644 index f09f001c..00000000 --- a/amarok/src/services/gpodder/GpodderServiceModel.cpp +++ /dev/null @@ -1,397 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2011 Stefan Derkits * - * Copyright (c) 2011 Christian Wagner * - * Copyright (c) 2011 Felix Winter * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "GpodderServiceModel.h" - -#include "core/support/Debug.h" -#include "GpodderPodcastRequestHandler.h" -#include "GpodderPodcastTreeItem.h" -#include "GpodderServiceSettings.h" -#include "GpodderTagTreeItem.h" - -#include - -#include -#include -#include - -static const int s_numberItemsToLoad = 100; - -using namespace mygpo; - -GpodderServiceModel::GpodderServiceModel( ApiRequest *request, QObject *parent ) - : QAbstractItemModel( parent ) - , m_rootItem( 0 ) - , m_topTagsItem( 0 ) - , m_topPodcastsItem( 0 ) - , m_suggestedPodcastsItem( 0 ) - , m_topTags( 0 ) - , m_apiRequest( request ) -{ - GpodderServiceConfig config; - - m_rootItem = new GpodderTreeItem( ); - - m_topTagsItem = new GpodderTreeItem( m_rootItem, "Top Tags" ); - m_rootItem->appendChild( m_topTagsItem ); - - m_topPodcastsItem = new GpodderTreeItem( m_rootItem, "Top Podcasts" ); - m_rootItem->appendChild( m_topPodcastsItem ); - - if ( config.isDataLoaded() && config.enableProvider() ) - { - m_suggestedPodcastsItem = new GpodderTreeItem( m_rootItem, "Suggested Podcasts" ); - m_rootItem->appendChild( m_suggestedPodcastsItem ); - - } -} - -GpodderServiceModel::~GpodderServiceModel() -{ - delete m_rootItem; -} - -QModelIndex -GpodderServiceModel::index( int row, int column, const QModelIndex &parent ) const -{ - if( !hasIndex( row, column, parent ) ) - return QModelIndex(); - - GpodderTreeItem *parentItem; - - if( !parent.isValid() ) - parentItem = m_rootItem; - else - parentItem = static_cast( parent.internalPointer() ); - - if( parentItem == 0 ) - return QModelIndex(); - - GpodderTreeItem *childItem = parentItem->child( row ); - if( childItem ) - return createIndex( row, column, childItem ); - else - return QModelIndex(); -} - -QModelIndex -GpodderServiceModel::parent( const QModelIndex &index ) const -{ - if( !index.isValid() ) - return QModelIndex(); - - GpodderTreeItem *childItem = static_cast( index.internalPointer() ); - - if( childItem == 0 || childItem->isRoot() ) - return QModelIndex(); - - GpodderTreeItem *parentItem = childItem->parent(); - - if( parentItem == 0 ) - return QModelIndex(); - - int childIndex; - if( parentItem->isRoot() ) - return QModelIndex(); - else - childIndex = parentItem->parent()->children().indexOf( parentItem ); - - return createIndex( childIndex, 0, parentItem ); -} - -int -GpodderServiceModel::rowCount( const QModelIndex &parent ) const -{ - GpodderTreeItem *parentItem; - - if( !parent.isValid() ) - { - return m_rootItem->childCount(); - } - - parentItem = static_cast( parent.internalPointer() ); - - if( parentItem == 0 ) - return 0; - - return parentItem->childCount(); -} - -int -GpodderServiceModel::columnCount( const QModelIndex &parent ) const -{ - Q_UNUSED( parent ) - return 1; -} - -QVariant -GpodderServiceModel::data( const QModelIndex &index, int role ) const -{ - if( !index.isValid() ) - return QVariant(); - - if( role != Qt::DisplayRole ) - return QVariant(); - - GpodderTreeItem *item = static_cast( index.internalPointer() ); - if( item == 0 ) - { - return QVariant(); - } - - return item->displayData(); -} - -void -GpodderServiceModel::insertTagList() -{ - if( m_rootItem != 0 ) - { - beginInsertRows( createIndex( 0,0, m_topTagsItem), 0, m_topTags->list().count() - 1 ); - m_topTagsItem->appendTags( m_topTags ); - endInsertRows(); - } -} - -void -GpodderServiceModel::topTagsRequestError( QNetworkReply::NetworkError error ) -{ - DEBUG_BLOCK - - debug() << "Error in TopTags request: " << error; - - QTimer::singleShot( 20000, this, SLOT(requestTopTags()) ); -} - -void -GpodderServiceModel::topTagsParseError() -{ - DEBUG_BLOCK - - debug() << "Error while parsing TopTags"; - - QTimer::singleShot( 20000, this, SLOT(requestTopTags()) ); -} - -void -GpodderServiceModel::topPodcastsRequestError( QNetworkReply::NetworkError error ) -{ - DEBUG_BLOCK - - debug() << "Error in TopPodcasts request: " << error; - - QTimer::singleShot( 20000, this, SLOT(requestTopPodcasts()) ); -} - -void -GpodderServiceModel::topPodcastsParseError() -{ - DEBUG_BLOCK - - debug() << "Error while parsing TopPodcasts"; - - QTimer::singleShot( 20000, this, SLOT(requestTopPodcasts()) ); -} - -void -GpodderServiceModel::suggestedPodcastsRequestError( QNetworkReply::NetworkError error ) -{ - DEBUG_BLOCK - - debug() << "Error in suggestedPodcasts request: " << error; - - QTimer::singleShot( 20000, this, SLOT(requestSuggestedPodcasts()) ); -} - -void -GpodderServiceModel::suggestedPodcastsParseError() -{ - DEBUG_BLOCK - - debug() << "Error while parsing suggestedPodcasts"; - - QTimer::singleShot( 20000, this, SLOT(requestSuggestedPodcasts()) ); -} - -void -GpodderServiceModel::insertPodcastList( mygpo::PodcastListPtr podcasts, - const QModelIndex &parentItem ) -{ - DEBUG_BLOCK - - emit layoutAboutToBeChanged(); - beginInsertRows( parentItem, 0, podcasts->list().count() - 1 ); - GpodderTreeItem *item = static_cast( parentItem.internalPointer() ); - if( item != 0 ) - { - debug() << "Appending Podcasts..."; - item->appendPodcasts( podcasts ); - } - endInsertRows(); - - emit layoutChanged(); -} - -bool -GpodderServiceModel::hasChildren( const QModelIndex &parent ) const -{ - if( !parent.isValid() ) - return true; - - GpodderTreeItem *treeItem = static_cast( parent.internalPointer() ); - - if( treeItem == 0 ) - return false; - - if( treeItem->childCount() > 0 ) - return true; - - if( !qobject_cast( treeItem ) ) - { - return true; - } - else - { - return false; - } -} - -bool -GpodderServiceModel::canFetchMore( const QModelIndex &parent ) const -{ - // root item - if( !parent.isValid() ) - { - return !m_rootItem->hasChildren(); - } - - // already fetched or just started? - GpodderTreeItem *treeItem = static_cast( parent.internalPointer() ); - if( treeItem == 0 || treeItem->hasChildren() /* || m_currentFetchingMap.values().contains( parent ) */ ) - { - return false; - } - - // TagTreeItem - - if( qobject_cast( treeItem ) ) - { - if( Solid::Networking::status() == Solid::Networking::Unconnected ) - return false; - - return true; - } - return false; -} - -void -GpodderServiceModel::fetchMore( const QModelIndex &parent ) -{ - // root item - if( !parent.isValid() ) - { - requestTopTags(); - requestTopPodcasts(); - if ( m_suggestedPodcastsItem != 0 ) - requestSuggestedPodcasts(); - } - - GpodderTreeItem *treeItem = static_cast( parent.internalPointer() ); - - // TagTreeItem - if( GpodderTagTreeItem *tagTreeItem = qobject_cast( treeItem ) ) - { - m_rootItem->setHasChildren( true ); - tagTreeItem->setHasChildren( true ); - - mygpo::PodcastListPtr podcasts = - m_apiRequest->podcastsOfTag( s_numberItemsToLoad, tagTreeItem->tag()->tag() ); - GpodderPodcastRequestHandler *podcastRequestHandler = - new GpodderPodcastRequestHandler( podcasts, parent, this ); - connect( podcasts.data(), SIGNAL(finished()), podcastRequestHandler, SLOT(finished()) ); - connect( podcasts.data(), SIGNAL(requestError(QNetworkReply::NetworkError)), - podcastRequestHandler, SLOT(requestError(QNetworkReply::NetworkError)) ); - connect( podcasts.data(), SIGNAL(parseError()), podcastRequestHandler, SLOT(parseError()) ); - } - -} - -void -GpodderServiceModel::requestTopTags() -{ - if( Solid::Networking::status() == Solid::Networking::Unconnected ) - { - QTimer::singleShot( 10000, this, SLOT(requestTopTags()) ); - return; - } - - m_rootItem->setHasChildren( true ); - - m_topTags = m_apiRequest->topTags( s_numberItemsToLoad ); - connect( m_topTags.data(), SIGNAL(finished()), this, SLOT(insertTagList()) ); - connect( m_topTags.data(), SIGNAL(requestError(QNetworkReply::NetworkError)), - SLOT(topTagsRequestError(QNetworkReply::NetworkError)) ); - connect( m_topTags.data(), SIGNAL(parseError()), SLOT(topTagsParseError()) ); -} - -void -GpodderServiceModel::requestTopPodcasts() -{ - if( Solid::Networking::status() == Solid::Networking::Unconnected ) - { - QTimer::singleShot( 10000, this, SLOT(requestTopPodcasts()) ); - return; - } - - m_rootItem->setHasChildren( true ); - - mygpo::PodcastListPtr topPodcasts = m_apiRequest->toplist( s_numberItemsToLoad ); - GpodderPodcastRequestHandler *podcastRequestHandler = new GpodderPodcastRequestHandler( - topPodcasts, - createIndex( 0,0, m_topPodcastsItem ), - this ); - connect( topPodcasts.data(), SIGNAL(finished()), podcastRequestHandler, SLOT(finished()) ); - connect( topPodcasts.data(), SIGNAL(requestError(QNetworkReply::NetworkError)), - SLOT(topPodcastsRequestError(QNetworkReply::NetworkError)) ); - connect( topPodcasts.data(), SIGNAL(parseError()), SLOT(topPodcastsParseError()) ); -} - -void -GpodderServiceModel::requestSuggestedPodcasts() -{ - if( Solid::Networking::status() == Solid::Networking::Unconnected ) - { - QTimer::singleShot( 10000, this, SLOT(requestSuggestedPodcasts()) ); - return; - } - - m_rootItem->setHasChildren( true ); - - mygpo::PodcastListPtr topSuggestions = - m_apiRequest->suggestions( s_numberItemsToLoad ); - GpodderPodcastRequestHandler *podcastRequestHandler = new GpodderPodcastRequestHandler( - topSuggestions, - createIndex( 0,0, m_suggestedPodcastsItem ), - this ); - connect( topSuggestions.data(), SIGNAL(finished()), - podcastRequestHandler, SLOT(finished()) ); - connect( topSuggestions.data(), SIGNAL(requestError(QNetworkReply::NetworkError)), - SLOT(suggestedPodcastsRequestError(QNetworkReply::NetworkError)) ); - connect( topSuggestions.data(), SIGNAL(parseError()), - SLOT(suggestedPodcastsParseError()) ); -} diff --git a/amarok/src/services/gpodder/GpodderServiceModel.h b/amarok/src/services/gpodder/GpodderServiceModel.h deleted file mode 100644 index 7909c9e5..00000000 --- a/amarok/src/services/gpodder/GpodderServiceModel.h +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2011 Stefan Derkits * - * Copyright (c) 2011 Christian Wagner * - * Copyright (c) 2011 Felix Winter * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef GPODDERSERVICEMODEL_H_ -#define GPODDERSERVICEMODEL_H_ - -#include "GpodderTreeItem.h" -#include -#include -#include "NetworkAccessManagerProxy.h" - -#include -#include - -class GpodderTreeItem; - -class GpodderServiceModel: public QAbstractItemModel -{ - Q_OBJECT -public: - explicit GpodderServiceModel( mygpo::ApiRequest *request, QObject *parent = 0 ); - virtual ~GpodderServiceModel(); - - // QAbstractItemModel methods - virtual QModelIndex index( int row, int column, const QModelIndex &parent = QModelIndex() ) const; - virtual QModelIndex parent( const QModelIndex &index ) const; - virtual int rowCount( const QModelIndex &parent = QModelIndex() ) const; - virtual int columnCount( const QModelIndex &parent = QModelIndex() ) const; - virtual QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const; - virtual bool hasChildren( const QModelIndex &parent = QModelIndex() ) const; - - void insertPodcastList( mygpo::PodcastListPtr podcasts, const QModelIndex & parentItem ); - -private slots: - void topTagsRequestError( QNetworkReply::NetworkError error ); - void topTagsParseError(); - void insertTagList(); - - void topPodcastsRequestError( QNetworkReply::NetworkError error ); - void topPodcastsParseError(); - - void suggestedPodcastsRequestError( QNetworkReply::NetworkError error ); - void suggestedPodcastsParseError(); - - void requestTopTags(); - void requestTopPodcasts(); - void requestSuggestedPodcasts(); - -protected: - virtual bool canFetchMore( const QModelIndex &parent ) const; - virtual void fetchMore( const QModelIndex &parent ); - -private: - GpodderTreeItem *m_rootItem; - GpodderTreeItem *m_topTagsItem; - GpodderTreeItem *m_topPodcastsItem; - GpodderTreeItem *m_suggestedPodcastsItem; - //The gpodder.net topTags - mygpo::TagListPtr m_topTags; - mygpo::ApiRequest *m_apiRequest; -}; - -#endif /* GPODDERSERVICEMODEL_H_ */ diff --git a/amarok/src/services/gpodder/GpodderServiceSettings.cpp b/amarok/src/services/gpodder/GpodderServiceSettings.cpp deleted file mode 100644 index 81d666bd..00000000 --- a/amarok/src/services/gpodder/GpodderServiceSettings.cpp +++ /dev/null @@ -1,257 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Shane King * - * Copyright (c) 2010 Stefan Derkits * - * Copyright (c) 2010 Christian Wagner * - * Copyright (c) 2010 Felix Winter * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "GpodderServiceSettings" - -#include "GpodderServiceSettings.h" - -#include "core/podcasts/PodcastProvider.h" -#include "core/support/Amarok.h" -#include "core/support/Debug.h" -#include "NetworkAccessManagerProxy.h" -#include "playlistmanager/PlaylistManager.h" -#include "ui_GpodderConfigWidget.h" - -#include -#include -#include - -#include -#include -#include -#include -#include - -K_PLUGIN_FACTORY( GpodderServiceSettingsFactory, registerPlugin(); ) -K_EXPORT_PLUGIN( GpodderServiceSettingsFactory( "kcm_amarok_gpodder" ) ) - -GpodderServiceSettings::GpodderServiceSettings( QWidget *parent, const QVariantList &args ) - : KCModule( GpodderServiceSettingsFactory::componentData(), parent, args ) - , m_enableProvider( false ) - , m_createDevice( 0 ) -{ - debug() << "Creating gpodder.net config object"; - - m_configDialog = new Ui::GpodderConfigWidget; - m_configDialog->setupUi( this ); - - connect( m_configDialog->kcfg_GpodderUsername, - SIGNAL(textChanged(QString)), this, - SLOT(settingsChanged()) ); - connect( m_configDialog->kcfg_GpodderPassword, - SIGNAL(textChanged(QString)), this, - SLOT(settingsChanged()) ); - connect( m_configDialog->testLogin, SIGNAL(clicked()), this, - SLOT(testLogin()) ); - - load(); -} - -GpodderServiceSettings::~GpodderServiceSettings() -{ - if( m_createDevice ) - m_createDevice->deleteLater(); - - if( m_devices ) - m_devices->deleteLater(); - - delete m_configDialog; -} - -void -GpodderServiceSettings::save() -{ - m_config.setUsername( m_configDialog->kcfg_GpodderUsername->text() ); - m_config.setPassword( m_configDialog->kcfg_GpodderPassword->text() ); - m_config.setEnableProvider( m_enableProvider ); - m_config.setIgnoreWallet( false ); - - m_config.save(); - KCModule::save(); -} - -void -GpodderServiceSettings::testLogin() -{ - DEBUG_BLOCK - - if ( ( !m_configDialog->kcfg_GpodderUsername->text().isEmpty() ) && - ( !m_configDialog->kcfg_GpodderPassword->text().isEmpty() ) ) - { - - m_configDialog->testLogin->setEnabled( false ); - m_configDialog->testLogin->setText( i18n( "Testing..." ) ); - - mygpo::ApiRequest api( m_configDialog->kcfg_GpodderUsername->text(), - m_configDialog->kcfg_GpodderPassword->text(), - The::networkAccessManager() ); - m_devices = api.listDevices( m_configDialog->kcfg_GpodderUsername->text() ); - - connect( m_devices.data(), SIGNAL(finished()), SLOT(finished()) ); - connect( m_devices.data(), - SIGNAL(requestError(QNetworkReply::NetworkError)), - SLOT(onError(QNetworkReply::NetworkError)) ); - connect( m_devices.data(), SIGNAL(parseError()), SLOT(onParseError()) ); - } - else - { - KMessageBox::error( this, - i18n( "Either the username or the password is empty, please correct and try again." ), - i18n( "Failed" ) ); - } -} - -void -GpodderServiceSettings::finished() -{ - DEBUG_BLOCK - - debug() << "Authentication worked, got List of Devices, searching for Amarok Device"; - - m_configDialog->testLogin->setText( i18nc( "The operation completed as expected", "Success" ) ); - m_configDialog->testLogin->setEnabled( false ); - - bool deviceExists = false; - QList ptrList = m_devices->devicesList(); - mygpo::DevicePtr devPtr; - - QString hostname = QHostInfo::localHostName(); - QString deviceID = QLatin1String( "amarok-" ) % hostname; - - foreach( devPtr, ptrList ) - { - if( devPtr->id().compare( deviceID ) == 0 ) - { - deviceExists = true; - break; - } - } - if( !deviceExists ) - { - debug() << "Create new device " % deviceID; - - mygpo::ApiRequest api( m_configDialog->kcfg_GpodderUsername->text(), - m_configDialog->kcfg_GpodderPassword->text(), - The::networkAccessManager() ); - - m_createDevice = api.renameDevice( m_configDialog->kcfg_GpodderUsername->text(), - deviceID, - QLatin1String( "Amarok on " ) % hostname, - mygpo::Device::OTHER ); - - connect( m_createDevice, SIGNAL(finished()), - SLOT(deviceCreationFinished()) ); - connect( m_createDevice, SIGNAL(error(QNetworkReply::NetworkError)), - SLOT(deviceCreationError(QNetworkReply::NetworkError)) ); - } - else - { - debug() << "Amarok device was found and everything looks perfect"; - } -} - -void -GpodderServiceSettings::onError( QNetworkReply::NetworkError code ) -{ - DEBUG_BLOCK - - debug() << code; - - if( code == QNetworkReply::NoError ) - debug() << "No Error was found, but onError was called - should not happen"; - else if( code == QNetworkReply::AuthenticationRequiredError ) - { - debug() << "Authentication failed"; - - KMessageBox::error( this, - i18n( "Either the username or the password is incorrect, please correct and try again" ), - i18n( "Failed" ) ); - - m_configDialog->testLogin->setText( i18n( "&Test Login" ) ); - m_configDialog->testLogin->setEnabled( true ); - } - else - { - KMessageBox::error( this, - i18n( "Unable to connect to gpodder.net service or other error occurred." ), - i18n( "Failed" ) ); - - m_configDialog->testLogin->setText( i18n( "&Test Login" ) ); - m_configDialog->testLogin->setEnabled( true ); - } -} - -void -GpodderServiceSettings::onParseError() -{ - debug() << "Couldn't parse DeviceList, should not happen if gpodder.net is working correctly"; - - m_configDialog->testLogin->setText( i18n( "&Test Login" ) ); - m_configDialog->testLogin->setEnabled( true ); - - KMessageBox::error( this, i18n( "Error parsing the Reply, check if gpodder.net is working correctly and report a bug" ), i18n( "Failed" ) ); -} - -void -GpodderServiceSettings::deviceCreationFinished() -{ - debug() << "Creation of Amarok Device finished"; -} - -void -GpodderServiceSettings::deviceCreationError( QNetworkReply::NetworkError code ) -{ - debug() << "Error creating Amarok Device"; - debug() << code; - - m_configDialog->testLogin->setText( i18n( "&Test Login" ) ); - m_configDialog->testLogin->setEnabled( true ); -} - -void -GpodderServiceSettings::load() -{ - m_config.load(); - - m_configDialog->kcfg_GpodderUsername->setText( m_config.username() ); - m_configDialog->kcfg_GpodderPassword->setText( m_config.password() ); - m_enableProvider = m_config.enableProvider(); - - KCModule::load(); -} - -void -GpodderServiceSettings::defaults() -{ - m_config.reset(); - - m_configDialog->kcfg_GpodderUsername->setText( "" ); - m_configDialog->kcfg_GpodderPassword->setText( "" ); - m_enableProvider = false; -} - -void -GpodderServiceSettings::settingsChanged() -{ - m_configDialog->testLogin->setText( i18n( "&Test Login" ) ); - m_configDialog->testLogin->setEnabled( true ); - - m_enableProvider = true; - emit changed( true ); -} diff --git a/amarok/src/services/gpodder/GpodderServiceSettings.h b/amarok/src/services/gpodder/GpodderServiceSettings.h deleted file mode 100644 index 9098ad4e..00000000 --- a/amarok/src/services/gpodder/GpodderServiceSettings.h +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Shane King * - * Copyright (c) 2010 Stefan Derkits * - * Copyright (c) 2010 Christian Wagner * - * Copyright (c) 2010 Felix Winter * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef GPODDERSERVICESETTINGS_H -#define GPODDERSERVICESETTINGS_H - -#include "core/podcasts/PodcastMeta.h" -#include "GpodderServiceConfig.h" -#include - -#include - -#include - -namespace Ui { class GpodderConfigWidget; } - -class QListWidgetItem; - -class GpodderServiceSettings : public KCModule -{ - Q_OBJECT - -public: - explicit GpodderServiceSettings( QWidget *parent = 0, - const QVariantList &args = QVariantList() ); - - virtual ~GpodderServiceSettings(); - - virtual void save(); - virtual void load(); - virtual void defaults(); - -private slots: - void testLogin(); - - void finished(); - void onError( QNetworkReply::NetworkError code ); - void onParseError( ); - - void deviceCreationFinished(); - void deviceCreationError( QNetworkReply::NetworkError code ); - void settingsChanged(); - -private: - Ui::GpodderConfigWidget *m_configDialog; - GpodderServiceConfig m_config; - - mygpo::DeviceListPtr m_devices; - mygpo::AddRemoveResultPtr m_result; - bool m_enableProvider; - QNetworkReply *m_createDevice; -}; - -#endif // GPODDERSERVICESETTINGS_H diff --git a/amarok/src/services/gpodder/GpodderServiceView.cpp b/amarok/src/services/gpodder/GpodderServiceView.cpp deleted file mode 100644 index bf4ed26a..00000000 --- a/amarok/src/services/gpodder/GpodderServiceView.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2011 Stefan Derkits * - * Copyright (c) 2011 Christian Wagner * - * Copyright (c) 2011 Felix Winter * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "GpodderServiceView.h" - -GpodderServiceView::GpodderServiceView( QWidget *parent ) : - Amarok::PrettyTreeView( parent ) -{ -} diff --git a/amarok/src/services/gpodder/GpodderServiceView.h b/amarok/src/services/gpodder/GpodderServiceView.h deleted file mode 100644 index 9f4afd1b..00000000 --- a/amarok/src/services/gpodder/GpodderServiceView.h +++ /dev/null @@ -1,31 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2011 Stefan Derkits * - * Copyright (c) 2011 Christian Wagner * - * Copyright (c) 2011 Felix Winter * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef GPODDERSERVIECEVIEW_H_ -#define GPODDERSERVIECEVIEW_H_ - -#include "PrettyTreeView.h" - -class GpodderServiceView: public Amarok::PrettyTreeView -{ - Q_OBJECT -public: - explicit GpodderServiceView( QWidget *parent = 0 ); -}; - -#endif /* GPODDERSERVIECEVIEW_H_ */ diff --git a/amarok/src/services/gpodder/GpodderSortFilterProxyModel.cpp b/amarok/src/services/gpodder/GpodderSortFilterProxyModel.cpp deleted file mode 100644 index 2e78944d..00000000 --- a/amarok/src/services/gpodder/GpodderSortFilterProxyModel.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2011 Stefan Derkits * - * Copyright (c) 2011 Christian Wagner * - * Copyright (c) 2011 Felix Winter * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "GpodderSortFilterProxyModel.h" - -GpodderSortFilterProxyModel::GpodderSortFilterProxyModel( QObject *parent ) - : QSortFilterProxyModel( parent ) -{ -} - -GpodderSortFilterProxyModel::~GpodderSortFilterProxyModel() -{ -} - -bool GpodderSortFilterProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex &sourceParent ) const -{ - // Tag Items - if( !sourceParent.isValid() ) - { - return true; - } - - // Podcast Items - QModelIndex index = sourceModel()->index( sourceRow, 0, sourceParent ); - return sourceModel()->data( index ).toString().contains( filterRegExp() ); -} diff --git a/amarok/src/services/gpodder/GpodderSortFilterProxyModel.h b/amarok/src/services/gpodder/GpodderSortFilterProxyModel.h deleted file mode 100644 index 32b5bc86..00000000 --- a/amarok/src/services/gpodder/GpodderSortFilterProxyModel.h +++ /dev/null @@ -1,38 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2011 Stefan Derkits * - * Copyright (c) 2011 Christian Wagner * - * Copyright (c) 2011 Felix Winter * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef GPODDERSORTFILTERPROXYMODEL_H_ -#define GPODDERSORTFILTERPROXYMODEL_H_ - -#include "GpodderServiceModel.h" - -#include - -class GpodderSortFilterProxyModel : public QSortFilterProxyModel -{ - Q_OBJECT - -public: - GpodderSortFilterProxyModel( QObject *parent = 0 ); - virtual ~GpodderSortFilterProxyModel(); - -protected: - virtual bool filterAcceptsRow( int sourceRow, const QModelIndex &sourceParent ) const; -}; - -#endif /* GPODDERSORTFILTERPROXYMODEL_H_ */ diff --git a/amarok/src/services/gpodder/GpodderTagTreeItem.cpp b/amarok/src/services/gpodder/GpodderTagTreeItem.cpp deleted file mode 100644 index 51ab2a59..00000000 --- a/amarok/src/services/gpodder/GpodderTagTreeItem.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2011 Stefan Derkits * - * Copyright (c) 2011 Christian Wagner * - * Copyright (c) 2011 Felix Winter * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "GpodderTagTreeItem.h" - -#include "GpodderPodcastTreeItem.h" - -GpodderTagTreeItem::GpodderTagTreeItem( mygpo::TagPtr tag, GpodderTreeItem *parent ) : GpodderTreeItem( parent ), m_tag( tag ) -{ -} - - -GpodderTagTreeItem::~GpodderTagTreeItem() -{ -} - -QVariant GpodderTagTreeItem::displayData() const -{ - return m_tag->tag(); -} - -mygpo::TagPtr GpodderTagTreeItem::tag() const -{ - return m_tag; -} - diff --git a/amarok/src/services/gpodder/GpodderTagTreeItem.h b/amarok/src/services/gpodder/GpodderTagTreeItem.h deleted file mode 100644 index 59226d87..00000000 --- a/amarok/src/services/gpodder/GpodderTagTreeItem.h +++ /dev/null @@ -1,40 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2011 Stefan Derkits * - * Copyright (c) 2011 Christian Wagner * - * Copyright (c) 2011 Felix Winter * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef GPODDERTAGTREEITEM_H_ -#define GPODDERTAGTREEITEM_H_ - -#include "GpodderTreeItem.h" -#include - -#include - -class GpodderTagTreeItem: public GpodderTreeItem -{ - Q_OBJECT -public: - GpodderTagTreeItem( mygpo::TagPtr tag, GpodderTreeItem *parent = 0 ); - virtual ~GpodderTagTreeItem(); - virtual QVariant displayData() const; - mygpo::TagPtr tag() const; - -private: - mygpo::TagPtr m_tag; -}; - -#endif /* GPODDERTAGTREEITEM_H_ */ diff --git a/amarok/src/services/gpodder/GpodderTreeItem.cpp b/amarok/src/services/gpodder/GpodderTreeItem.cpp deleted file mode 100644 index d6f212b7..00000000 --- a/amarok/src/services/gpodder/GpodderTreeItem.cpp +++ /dev/null @@ -1,103 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2011 Stefan Derkits * - * Copyright (c) 2011 Christian Wagner * - * Copyright (c) 2011 Felix Winter * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "GpodderTreeItem.h" - -#include "GpodderPodcastTreeItem.h" -#include "GpodderServiceModel.h" -#include "GpodderTagTreeItem.h" - -GpodderTreeItem::GpodderTreeItem( GpodderTreeItem *parent, QString name ) - : QObject( parent ) - , m_parentItem( parent ) - , m_name( name ) - , m_hasChildren( false ) -{ -} - -GpodderTreeItem::~GpodderTreeItem() -{ - qDeleteAll( m_childItems ); -} - -void -GpodderTreeItem::appendChild( GpodderTreeItem *item ) -{ - m_childItems.append( item ); -} - -GpodderTreeItem * -GpodderTreeItem::child( int row ) -{ - return m_childItems.value( row ); -} - -bool -GpodderTreeItem::hasChildren() const -{ - return m_hasChildren; -} - -void -GpodderTreeItem::setHasChildren( bool hasChildren ) -{ - m_hasChildren = hasChildren; -} - -int -GpodderTreeItem::childCount() const -{ - return m_childItems.count(); -} - -GpodderTreeItem * -GpodderTreeItem::parent() const -{ - return m_parentItem; -} - -QVariant -GpodderTreeItem::displayData() const -{ - return m_name; -} - -bool -GpodderTreeItem::isRoot() const -{ - return ( m_parentItem == 0 ); -} - -void -GpodderTreeItem::appendTags( mygpo::TagListPtr tags ) -{ - foreach( mygpo::TagPtr tag, tags->list() ) - { - GpodderTagTreeItem *treeItem = new GpodderTagTreeItem( tag, this ); - appendChild( treeItem ); - } -} - -void -GpodderTreeItem::appendPodcasts( mygpo::PodcastListPtr podcasts ) -{ - foreach( mygpo::PodcastPtr podcast, podcasts->list() ) - { - appendChild( new GpodderPodcastTreeItem( podcast, this ) ); - } -} diff --git a/amarok/src/services/gpodder/GpodderTreeItem.h b/amarok/src/services/gpodder/GpodderTreeItem.h deleted file mode 100644 index d64b75c4..00000000 --- a/amarok/src/services/gpodder/GpodderTreeItem.h +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2011 Stefan Derkits * - * Copyright (c) 2011 Christian Wagner * - * Copyright (c) 2011 Felix Winter * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef GPODDERTREEITEM_H_ -#define GPODDERTREEITEM_H_ - -#include -#include - -#include -#include -#include - -class GpodderServiceModel; - -class GpodderTreeItem : public QObject -{ - Q_OBJECT -public: - GpodderTreeItem( GpodderTreeItem *parent = 0, QString name = "" ); - virtual ~GpodderTreeItem(); - - void appendChild( GpodderTreeItem *child ); - - GpodderTreeItem *child( int row ); - int childCount() const; - void setHasChildren( bool hasChildren ); - bool hasChildren() const; - - GpodderTreeItem *parent() const; - bool isRoot() const; - - - virtual QVariant displayData() const; - - virtual void appendTags( mygpo::TagListPtr tags ); - virtual void appendPodcasts( mygpo::PodcastListPtr podcasts ); -private: - QList m_childItems; - GpodderTreeItem *m_parentItem; - QString m_name; - bool m_hasChildren; -}; - -#endif /* GPODDERTREEITEM_H_ */ diff --git a/amarok/src/services/gpodder/amarok_service_gpodder.desktop b/amarok/src/services/gpodder/amarok_service_gpodder.desktop deleted file mode 100644 index 3ce0ee7f..00000000 --- a/amarok/src/services/gpodder/amarok_service_gpodder.desktop +++ /dev/null @@ -1,113 +0,0 @@ -[Desktop Entry] -Type=Service -ServiceTypes=KPluginInfo -Icon=view-services-gpodder-amarok -Name=gpodder.net -Name[bg]=gpodder.net -Name[bs]=gpodder.net -Name[ca]=gpodder.net -Name[ca@valencia]=gpodder.net -Name[cs]=gpodder.net -Name[da]=gpodder.net -Name[de]=gpodder.net -Name[el]=gpodder.net -Name[en_GB]=gpodder.net -Name[es]=gpodder.net -Name[et]=gpodder.net -Name[eu]=gpodder.net -Name[fi]=gpodder.net -Name[fr]=gpodder.net -Name[ga]=gpodder.net -Name[gl]=gpodder.net -Name[hu]=gpodder.net -Name[id]=gpodder.net -Name[it]=gpodder.net -Name[ja]=gpodder.net -Name[km]=gpodder.net -Name[lt]=gpodder.net -Name[lv]=gpodder.net -Name[nb]=gpodder.net -Name[nds]=gpodder.net -Name[nl]=gpodder.net -Name[pa]=gpodder.net -Name[pl]=gpodder.net -Name[pt]=gpodder.net -Name[pt_BR]=gpodder.net -Name[ro]=gpodder.net -Name[ru]=gpodder.net -Name[sk]=gpodder.net -Name[sl]=gpodder.net -Name[sr]=Гподер.нет -Name[sr@ijekavian]=Гподер.нет -Name[sr@ijekavianlatin]=gpodder.net -Name[sr@latin]=gpodder.net -Name[sv]=gpodder.net -Name[tr]=gpodder.net -Name[uk]=gpodder.net -Name[x-test]=xxgpodder.netxx -Name[zh_CN]=gpodder.net -Name[zh_TW]=gpodder.net -Comment=Podcast Service -Comment[bg]=Услуга за подкастове -Comment[bs]=Podcast usluga -Comment[ca]=Servei de podcasts -Comment[ca@valencia]=Servei de podcasts -Comment[cs]=Služba podcastů -Comment[da]=Podcast-tjeneste -Comment[de]=Podcast-Dienst -Comment[el]=Υπηρεσία Podcast -Comment[en_GB]=Podcast Service -Comment[es]=Servicio de podcast -Comment[et]=Podcastide teenus -Comment[eu]=Podcast-en zerbitzua -Comment[fi]=Podcast-palvelu -Comment[fr]=Service de podcasts -Comment[ga]=Seirbhís Phodchraolta -Comment[gl]=Servizo de podcast -Comment[hu]=Podcast szolgáltatás -Comment[id]=Layanan Podcast -Comment[it]=Servizio Podcast -Comment[ja]=ポッドキャストサービス -Comment[km]=សេវា​ផតខាស់ -Comment[lt]=Garso prenumeratų tarnyba -Comment[lv]=Podraižu serviss -Comment[nb]=Podkast-tjeneste -Comment[nds]=Podcast-Deenst -Comment[nl]=Podcast-service -Comment[pa]=ਪੋਡਕਾਸਟ ਸਰਵਿਸ -Comment[pl]=Usługa podcast -Comment[pt]=Serviço de 'Podcasts' -Comment[pt_BR]=Serviço de podcasts -Comment[ro]=Serviciu Podcast -Comment[ru]=Каталог подкастов -Comment[sk]=Podcast služba -Comment[sl]=Storitev za podcaste -Comment[sr]=Сервис подемисија -Comment[sr@ijekavian]=Сервис подемисија -Comment[sr@ijekavianlatin]=Servis podemisija -Comment[sr@latin]=Servis podemisija -Comment[sv]=Podsändningstjänst -Comment[tr]=Podcast Servisi -Comment[uk]=Служба трансляцій -Comment[x-test]=xxPodcast Servicexx -Comment[zh_CN]=播客服务 -Comment[zh_TW]=Podcast 服務 - -ServiceTypes=Amarok/Plugin - -X-KDE-Amarok-authors=Stefan Derkits, Christian Wagner, Felix Winter, Lucas Lira Gomes -X-KDE-Amarok-email=stefan@derkits.at, christian.wagner86@gmx.at, ixos01@gmail.com, x8lucas8x@gmail.com -X-KDE-Amarok-framework-version=72 -X-KDE-Amarok-name=gpodderService -X-KDE-Amarok-plugintype=service -X-KDE-Amarok-rank=100 -X-KDE-Amarok-version=1 - -X-KDE-PluginInfo-Author=Stefan Derkits, Christian Wagner, Felix Winter, Lucas Lira Gomes -X-KDE-PluginInfo-Email=stefan@derkits.at, christian.wagner86@gmx.at, ixos01@gmail.com, x8lucas8x@gmail.com -X-KDE-PluginInfo-Version=1.0 -X-KDE-PluginInfo-Category=Service -X-KDE-PluginInfo-License=GPL -X-KDE-PluginInfo-EnabledByDefault=false -X-KDE-Library=amarok_service_gpodder -X-KDE-PluginInfo-Name=amarok_service_gpodder diff --git a/amarok/src/services/gpodder/amarok_service_gpodder_config.desktop b/amarok/src/services/gpodder/amarok_service_gpodder_config.desktop deleted file mode 100644 index 043f2402..00000000 --- a/amarok/src/services/gpodder/amarok_service_gpodder_config.desktop +++ /dev/null @@ -1,92 +0,0 @@ -[Desktop Entry] -Icon=view-services-gpodder-amarok -Type=Service -ServiceTypes=Amarok/Plugin -X-KDE-ServiceTypes=KCModule - -X-KDE-Library=kcm_amarok_service_gpodder -X-KDE-ParentApp=amarok_service_gpodder -X-KDE-ParentComponents=amarok_service_gpodder - -Name=gpodder.net Service Config -Name[bs]=gpodder.net Postavka usluga -Name[ca]=Configuració del servei gpodder.net -Name[ca@valencia]=Configuració del servei gpodder.net -Name[cs]=Nastavení služby lgpodder.net -Name[da]=Konfiguration af tjenesten gpodder.net -Name[de]=Einrichtung von gpodder.net -Name[el]=Διαμόρφωση της υπηρεσίας gpodder.net -Name[en_GB]=gpodder.net Service Config -Name[es]=Configuración del servicio gpodder.net -Name[et]=gpodder.net-i teenuse seadistamine -Name[fi]=gpodder.net-palvelumääritykset -Name[fr]=Configuration du service « gpodder.net » -Name[ga]=Cumraíocht Sheirbhís gpodder.net -Name[gl]=Configuración do servizo gpodder.net -Name[hu]=A gpodder.net szolgáltatás beállítása -Name[id]=Konfig Layanan gpodder.net -Name[it]=Configurazione servizio gpodder.net -Name[ja]=gpodder.net サービスの設定 -Name[km]=កំណត់​រចនាសម្ព័ន្ធ​សេវាកម្ម gpodder.net -Name[lt]=gpodder.net Service nustatymai -Name[lv]=gpodder.net pakalpojuma konfigurācija -Name[nb]=Innstillinger for gpodder.net-tjenesten -Name[nl]=Instellingen van de service gpodder.net -Name[pl]=Ustawienia usługi gpodder.net -Name[pt]=Configuração do Serviço do gpodder.net -Name[pt_BR]=Configuração do serviço gpodder.net -Name[ro]=Configurare serviciu gpodder.net -Name[ru]=Настройка службы gpodder.net -Name[sk]=Nastavenie služby gpodder.net -Name[sl]=Nastavitev storitve gpodder.net -Name[sr]=Поставке за сервис Гподер.нет -Name[sr@ijekavian]=Поставке за сервис Гподер.нет -Name[sr@ijekavianlatin]=Postavke za servis gpodder.net -Name[sr@latin]=Postavke za servis gpodder.net -Name[sv]=Inställning av gpodder.net-tjänst -Name[tr]=gpodder.net Hizmet Yapılandırması -Name[uk]=Налаштування служби gpodder.net -Name[x-test]=xxgpodder.net Service Configxx -Name[zh_CN]=gpodder.net 服务配置 -Name[zh_TW]=gpodder.net 服務設定 -Comment=Configure gpodder.net Credentials -Comment[bs]=Postavi gpodder.net akreditiv -Comment[ca]=Configura les credencials de gpodder.net -Comment[ca@valencia]=Configura les credencials de gpodder.net -Comment[cs]=Nastavit přihlašovací údaje gpodder.net -Comment[da]=Indstil akkreditiver for gpodder.net -Comment[de]=Zugangsdaten zu gpodder.net einrichten -Comment[el]=Διαμόρφωση διαπιστευτηρίων gpodder.net -Comment[en_GB]=Configure gpodder.net Credentials -Comment[es]=Configurar credenciales de gpodder.net -Comment[et]=gpodder.net-i kasutajatunnuste määramine -Comment[fi]=Määritä gpodder.net-palvelun tilitiedot -Comment[fr]=Configuration des références de « gpodder.net » -Comment[ga]=Cumraigh dintiúir gpodder.net -Comment[gl]=Configurar as credenciais de gpodder.net -Comment[hu]=Bejelentkezési adatok beállítása a gpodder.net szolgáltatáshoz -Comment[id]=Atur surat kuasa gpodder.net -Comment[it]=Configura credenziali gpodder.net -Comment[ja]=gpodder.net の資格情報を設定 -Comment[km]=កំណត់​រចនាសម្ព័ន្ធ​ការ​អនុញ្ញាត​ gpodder.net -Comment[lt]=Konfigūruoti gpodder.net prisijungimo duomenis -Comment[lv]=Konfigurēt gpodder.net lietotāja kontu -Comment[nb]=Sett opp gpodder.net-akkreditiver -Comment[nl]=gpodder.net-credentials instellen -Comment[pl]=Ustawianie danych poufnych gpodder.net -Comment[pt]=Configurar as Credenciais do gpodder.net -Comment[pt_BR]=Configurar credenciais do gpodder.net -Comment[ro]=Configurează detaliile contului gpodder.net -Comment[ru]=Настройка учётной записи gpodder.net -Comment[sk]=Nastaviť osobné údaje pre gpodder.net -Comment[sl]=Nastavite poverila gpodder.net -Comment[sr]=Подесите акредитиве за Гподер -Comment[sr@ijekavian]=Подесите акредитиве за Гподер -Comment[sr@ijekavianlatin]=Podesite akreditive za gpodder -Comment[sr@latin]=Podesite akreditive za gpodder -Comment[sv]=Anpassa gpodder.net inloggningsinformation -Comment[tr]=gpodder.net üyelik ayarlarını yapılandır -Comment[uk]=Налаштувати реєстраційні дані у gpodder.net -Comment[x-test]=xxConfigure gpodder.net Credentialsxx -Comment[zh_CN]=配置 gpodder.net 证件 -Comment[zh_TW]=設定 gpodder.net 的憑證 diff --git a/amarok/src/services/gpodder/images/CMakeLists.txt b/amarok/src/services/gpodder/images/CMakeLists.txt deleted file mode 100644 index babfa197..00000000 --- a/amarok/src/services/gpodder/images/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -install( - FILES - mygpo.png - DESTINATION ${DATA_INSTALL_DIR}/amarok/images -) diff --git a/amarok/src/services/gpodder/images/mygpo.png b/amarok/src/services/gpodder/images/mygpo.png deleted file mode 100644 index 69d77402..00000000 Binary files a/amarok/src/services/gpodder/images/mygpo.png and /dev/null differ diff --git a/amarok/src/services/jamendo/CMakeLists.txt b/amarok/src/services/jamendo/CMakeLists.txt deleted file mode 100644 index 893b1283..00000000 --- a/amarok/src/services/jamendo/CMakeLists.txt +++ /dev/null @@ -1,39 +0,0 @@ - include_directories( - ../ - ../../ - ../../core-impl/collections - ../../statusbar - ${CMAKE_CURRENT_BINARY_DIR}/../.. - ${KDE4_INCLUDE_DIR} - ${QT_INCLUDES} ) - -add_subdirectory( images ) - -########### next target ############### - - set(amarok_service_jamendo_PART_SRCS - JamendoService.cpp - JamendoMeta.cpp - JamendoDatabaseHandler.cpp - JamendoXmlParser.cpp - JamendoInfoParser.cpp - ) - - kde4_add_plugin(amarok_service_jamendo ${amarok_service_jamendo_PART_SRCS}) - target_link_libraries(amarok_service_jamendo - amarokcore - amaroklib - amarokpud - ${KDE4_KDECORE_LIBS} - ${KDE4_KDEUI_LIBS} - ${KDE4_KIO_LIBS} - ${KDE4_THREADWEAVER_LIBS} - ) - - - install(TARGETS amarok_service_jamendo DESTINATION ${PLUGIN_INSTALL_DIR} ) - - -########### install files ############### - - install( FILES amarok_service_jamendo.desktop DESTINATION ${SERVICES_INSTALL_DIR}) diff --git a/amarok/src/services/jamendo/JamendoDatabaseHandler.cpp b/amarok/src/services/jamendo/JamendoDatabaseHandler.cpp deleted file mode 100644 index b44be2cd..00000000 --- a/amarok/src/services/jamendo/JamendoDatabaseHandler.cpp +++ /dev/null @@ -1,279 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "JamendoDatabaseHandler.h" - -#include "core-impl/storage/StorageManager.h" -#include "core/support/Debug.h" -#include - -using namespace Meta; - -JamendoDatabaseHandler::JamendoDatabaseHandler() -{ -} - -JamendoDatabaseHandler::~JamendoDatabaseHandler() -{ -} - -void -JamendoDatabaseHandler::createDatabase( ) -{ - //Get database instance - SqlStorage *db = StorageManager::instance()->sqlStorage(); - - - QString autoIncrement = "AUTO_INCREMENT"; - - // create table containing tracks - QString queryString = "CREATE TABLE jamendo_tracks (" - "id INTEGER PRIMARY KEY " + autoIncrement + ',' + - "name " + db->textColumnType() + ',' + - "track_number INTEGER," - "length INTEGER," - "preview_url " + db->exactTextColumnType() + ',' + - "album_id INTEGER," - "artist_id INTEGER ) ENGINE = MyISAM;"; - - debug() << "Creating jamendo_tracks: " << queryString; - - QStringList result = db->query( queryString ); - db->query( "CREATE INDEX jamendo_tracks_id ON jamendo_tracks(id);" ); - db->query( "CREATE INDEX jamendo_tracks_album_id ON jamendo_tracks(album_id);" ); - db->query( "CREATE INDEX jamendo_tracks_artist_id ON jamendo_tracks(artist_id);" ); - - //Create album table - queryString = "CREATE TABLE jamendo_albums (" - "id INTEGER PRIMARY KEY " + autoIncrement + ',' + - "name " + db->textColumnType() + ',' + - "description " + db->exactTextColumnType() + ',' + - "popularity FLOAT, " + - "cover_url " + db->exactTextColumnType() + ',' + - "launch_year Integer, " - "genre " + db->exactTextColumnType() + ',' + - "artist_id INTEGER, " - "mp3_torrent_url " + db->exactTextColumnType() + ',' + - "ogg_torrent_url " + db->exactTextColumnType() + " ) ENGINE = MyISAM;"; - - debug() << "Creating jamendo_albums: " << queryString; - - result = db->query( queryString ); - - db->query( "CREATE INDEX jamendo_albums_id ON jamendo_albums(id);" ); - db->query( "CREATE INDEX jamendo_albums_name ON jamendo_albums(name);" ); - db->query( "CREATE INDEX jamendo_albums_artist_id ON jamendo_albums(artist_id);" ); - - //Create artist table - queryString = "CREATE TABLE jamendo_artists (" - "id INTEGER PRIMARY KEY " + autoIncrement + ',' + - "name " + db->textColumnType() + ',' + - "description " + db->textColumnType() + ',' + - "country " + db->textColumnType() + ',' + - "photo_url " + db->textColumnType() + ',' + - "jamendo_url " + db->textColumnType() + ',' + - "home_url " + db->textColumnType() + ") ENGINE = MyISAM;"; - - debug() << "Creating jamendo_artists: " << queryString; - - result = db->query( queryString ); - - db->query( "CREATE INDEX jamendo_artists_id ON jamendo_artists(id);" ); - db->query( "CREATE INDEX jamendo_artists_name ON jamendo_artists(name);" ); - - //create genre table - queryString = "CREATE TABLE jamendo_genre (" - "id INTEGER PRIMARY KEY " + autoIncrement + ',' + - "name " + db->textColumnType() + ',' + - "album_id INTEGER" + ") ENGINE = MyISAM;"; - - debug() << "Creating jamendo_genres: " << queryString; - - result = db->query( queryString ); - - db->query( "CREATE INDEX jamendo_genre_id ON jamendo_genre(id);" ); - db->query( "CREATE INDEX jamendo_genre_name ON jamendo_genre(name);" ); - db->query( "CREATE INDEX jamendo_genre_album_id ON jamendo_genre(album_id);" ); -} - -void -JamendoDatabaseHandler::destroyDatabase( ) -{ - debug() << "Destroy Jamendo database "; - - SqlStorage *db = StorageManager::instance()->sqlStorage(); - - QStringList result = db->query( "DROP INDEX jamendo_tracks_id ON jamendo_tracks;"); - result = db->query( "DROP INDEX jamendo_tracks_artist_id ON jamendo_tracks;"); - result = db->query( "DROP INDEX jamendo_tracks_album_id ON jamendo_tracks;"); - result = db->query( "DROP INDEX jamendo_albums_id ON jamendo_albums;"); - result = db->query( "DROP INDEX jamendo_albums_name ON jamendo_albums;"); - result = db->query( "DROP INDEX jamendo_albums_artist_id ON jamendo_albums;"); - result = db->query( "DROP INDEX jamendo_artists_id ON jamendo_artists;"); - result = db->query( "DROP INDEX jamendo_artists_name ON jamendo_artists;"); - result = db->query( "DROP INDEX jamendo_genre_id ON jamendo_genre;"); - result = db->query( "DROP INDEX jamendo_genre_album_id ON jamendo_genre;"); - result = db->query( "DROP INDEX jamendo_genre_name ON jamendo_genre;"); - - - result = db->query( "DROP TABLE IF EXISTS jamendo_tracks;" ); - result = db->query( "DROP TABLE IF EXISTS jamendo_albums;" ); - result = db->query( "DROP TABLE IF EXISTS jamendo_artists;" ); - result = db->query( "DROP TABLE IF EXISTS jamendo_genre;" ); - - //FIXME: We only support sqlite currently. DbConnection no longer exists. -} - -int -JamendoDatabaseHandler::insertTrack( ServiceTrack *track ) -{ - JamendoTrack * jTrack = static_cast ( track ); - QString numberString; - - SqlStorage *db = StorageManager::instance()->sqlStorage(); - QString queryString = "INSERT INTO jamendo_tracks ( id, name, track_number, length, " - "album_id, artist_id, preview_url ) VALUES ( " - + QString::number( jTrack->id() ) + ", '" - + db->escape( jTrack->name() ) + "', " - + QString::number( jTrack->trackNumber() ) + ", " - + QString::number( jTrack->length() ) + ", " - + QString::number( jTrack->albumId() ) + ", " - + QString::number( jTrack->artistId() ) + ", '" - + db->escape( jTrack->uidUrl() ) + "' );"; - - // debug() << "Adding Jamendo track " << queryString; - int trackId = db->insert( queryString, NULL ); - - // Process moods: - - /* QStringList moods = track->getMoods(); - - foreach( QString mood, moods ) { - queryString = "INSERT INTO jamendo_moods ( track_id, mood ) VALUES ( " - + QString::number( trackId ) + ", '" - + db->escape( mood ) + "' );"; - - - //debug() << "Adding Jamendo mood: " << queryString; - db->insert( queryString, NULL ); - } -*/ - return trackId; -} - -int -JamendoDatabaseHandler::insertAlbum( ServiceAlbum *album ) -{ - JamendoAlbum * jAlbum = static_cast ( album ); - - QString queryString, popularity; - SqlStorage *sqlDb = StorageManager::instance()->sqlStorage(); - - popularity = QString::number( jAlbum->popularity() ); - if( popularity == "nan" ) // sometimes this seems to happen, I don't know why - popularity = '0'; - - queryString = "INSERT INTO jamendo_albums ( id, name, description, " - "popularity, cover_url, launch_year, genre, " - "artist_id, mp3_torrent_url, ogg_torrent_url ) VALUES ( " - + QString::number( jAlbum->id() ) + ", '" - + sqlDb->escape( jAlbum->name() ) + "', '" - + sqlDb->escape( jAlbum->description() )+ "', " - + popularity + ", '" - + sqlDb->escape( jAlbum->coverUrl() )+ "', " - + QString::number( jAlbum->launchYear() ) + ", '" - + sqlDb->escape( jAlbum->genre() )+ "', " - + QString::number( jAlbum->artistId() ) + ", '" - + sqlDb->escape( QString() ) + "', '" // Deprecated - + sqlDb->escape( QString() ) + "' );"; // Deprecated - - //debug() << "Adding Jamendo album " << queryString; - - return sqlDb->insert( queryString, QString() ); -} - - -int -JamendoDatabaseHandler::insertArtist( ServiceArtist *artist ) -{ - JamendoArtist * jArtist = static_cast ( artist ); - QString queryString; - SqlStorage *sqlDb = StorageManager::instance()->sqlStorage(); - queryString = "INSERT INTO jamendo_artists ( id, name, description, " - "country, photo_url, jamendo_url, home_url " - ") VALUES ( " - + QString::number( jArtist->id() ) + ", '" - + sqlDb->escape( jArtist->name() ) + "', '" - + sqlDb->escape( jArtist->description() ) + "', '" - + sqlDb->escape( jArtist->country() ) + "', '" - + sqlDb->escape( jArtist->photoURL() ) + "', '" - + sqlDb->escape( jArtist->jamendoURL() ) + "', '" - + sqlDb->escape( jArtist->homeURL() ) + "' );"; - - //debug() << "Adding Jamendo artist " << queryString; - - return sqlDb->insert( queryString, QString() ); -/* - QString m_country; - QString m_photoURL; - QString m_jamendoURL; - QString m_homeURL;*/ -} - -int JamendoDatabaseHandler::insertGenre(ServiceGenre * genre) -{ - QString queryString; - SqlStorage *sqlDb = StorageManager::instance()->sqlStorage(); - queryString = "INSERT INTO jamendo_genre ( album_id, name " - ") VALUES ( " - + QString::number ( genre->albumId() ) + ", '" - + sqlDb->escape( genre->name() ) + "' );"; - - //debug() << "Adding Jamendo genre " << queryString; - - return sqlDb->insert( queryString, 0 ); -} - -void -JamendoDatabaseHandler::begin( ) -{ - StorageManager *mgr = StorageManager::instance(); - QString queryString = "BEGIN;"; - mgr->sqlStorage()->query( queryString ); -} - -void -JamendoDatabaseHandler::commit( ) -{ - StorageManager *mgr = StorageManager::instance(); - QString queryString = "COMMIT;"; - mgr->sqlStorage()->query( queryString ); -} - -void -JamendoDatabaseHandler::trimGenres( int minCount ) -{ - QString query = QString("delete from jamendo_genre where name IN ( SELECT name from jamendo_genre GROUP BY jamendo_genre.name HAVING COUNT ( jamendo_genre.name ) < %1 );").arg( minCount ); - - SqlStorage *sqlDb = StorageManager::instance()->sqlStorage(); - sqlDb->query( query ); - - //also trim genre names that have only 1 or 2 chars - query = QString ("delete from jamendo_genre where name REGEXP '^.{1,2}$';" ); - sqlDb->query( query ); - -} - diff --git a/amarok/src/services/jamendo/JamendoDatabaseHandler.h b/amarok/src/services/jamendo/JamendoDatabaseHandler.h deleted file mode 100644 index 6208ff0c..00000000 --- a/amarok/src/services/jamendo/JamendoDatabaseHandler.h +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef JAMENDODATABASEHANDLER_H -#define JAMENDODATABASEHANDLER_H - -#include "JamendoMeta.h" - -#include -#include - -/** -* This class wraps the database operations needed by the JamendoBrowser -* -* @author Nikolaj Hald Nielsen -*/ -class JamendoDatabaseHandler -{ -public: - /** - * Private constructor (singleton pattern) - * @return Pointer to new object - */ - JamendoDatabaseHandler(); - - ~JamendoDatabaseHandler(); - - /** - * Creates the tables needed to store Jamendo info - */ - void createDatabase(); - - /** - * Destroys Jamendo tables - */ - void destroyDatabase(); - - /** - * Inserts a new track into the Jamendo database - * @param track pointer to the track to insert - * @return the database id of the newly inserted track - */ - int insertTrack( Meta::ServiceTrack *track ); - - /** - * inserts a new album into the Jamendo database - * @param album pointer to the album to insert - * @return the database id of the newly inserted album - */ - int insertAlbum( Meta::ServiceAlbum *album ); - - /** - * inserts a new artist into the Jamendo database - * @param artist pointer to the artist to insert - * @return the database id of the newly inserted artist - */ - int insertArtist( Meta::ServiceArtist *artist ); - - /** - * inserts a new genre into the Jamendo database - * @param genre pointer to the genre to insert - * @return the database id of the newly inserted genre - */ - int insertGenre( Meta::ServiceGenre *genre ); - - /** - * Begins a database transaction. Must be followed by a later call to commit() - */ - void begin(); - - /** - * Completes (executes) a database transaction. Must be preceded by a call to begin() - */ - void commit(); - - /** - * Remove all genres that are applied to too few albums in an attempt to weed out the worst mistags and - * speed up queries a bit! - * @param minCount cutoff value... - */ - void trimGenres( int minCount ); -}; - -#endif diff --git a/amarok/src/services/jamendo/JamendoInfoParser.cpp b/amarok/src/services/jamendo/JamendoInfoParser.cpp deleted file mode 100644 index e3374cd2..00000000 --- a/amarok/src/services/jamendo/JamendoInfoParser.cpp +++ /dev/null @@ -1,120 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "JamendoInfoParser.h" - -#include "core/support/Debug.h" -#include "JamendoMeta.h" - -#include - -using namespace Meta; - -JamendoInfoParser::JamendoInfoParser() - : InfoParserBase() -{ -} - -JamendoInfoParser::~JamendoInfoParser() -{ -} - -void -JamendoInfoParser::getInfo(ArtistPtr artist) -{ - DEBUG_BLOCK - JamendoArtist * jamendoArtist = dynamic_cast ( artist.data() ); - if ( jamendoArtist == 0) - return; - - QString description = jamendoArtist->description(); - - if ( description.isEmpty() ) - description = i18n( "No description available..." ); - - QString infoHtml = ""; - infoHtml += "
    "; - infoHtml += i18n( "Artist" ) + "

    "; - infoHtml += ""; - infoHtml += jamendoArtist->prettyName(); - infoHtml += "

    "; - - if ( !jamendoArtist->photoURL().isEmpty() ) - infoHtml += "photoURL() + - "\" align=\"middle\" border=\"1\">

    "; - - infoHtml += description; - infoHtml += "

    " + i18n( "From Jamendo.com" ) + "
    "; - infoHtml += ""; - - emit( info( infoHtml ) ); -} - -void -JamendoInfoParser::getInfo(AlbumPtr album) -{ - DEBUG_BLOCK - JamendoAlbum * jamendoAlbum = dynamic_cast ( album.data() ); - if ( jamendoAlbum == 0) return; - - QString description = jamendoAlbum->description(); - - if ( description.isEmpty() ) - description = i18n( "No description available..." ); - - - QString infoHtml = ""; - infoHtml += "
    "; - infoHtml += i18n( "Album" ) + "

    "; - infoHtml += ""; - infoHtml += jamendoAlbum->prettyName(); - infoHtml += "

    "; - - if ( !jamendoAlbum->coverUrl().isEmpty() ) - infoHtml += "coverUrl() + - "\" align=\"middle\" border=\"1\">

    "; - - infoHtml += description; - infoHtml += "

    " + i18n( "From Jamendo.com" ) + "
    "; - infoHtml += ""; - - emit( info( infoHtml ) ); -} - -void -JamendoInfoParser::getInfo(TrackPtr track) -{ - DEBUG_BLOCK - JamendoTrack * jamendoTrack = dynamic_cast ( track.data() ); - if ( jamendoTrack == 0) return; - - QString infoHtml = ""; - infoHtml += "
    "; - infoHtml += i18n( "Track" ) + "

    "; - infoHtml += ""; - infoHtml += jamendoTrack->prettyName(); - infoHtml += "

    "; - infoHtml += "

    " + i18n( "From Jamendo.com" ) + "
    "; - infoHtml += ""; - - emit( info( infoHtml ) ); -} - -#include "moc_JamendoInfoParser.cpp" - diff --git a/amarok/src/services/jamendo/JamendoInfoParser.h b/amarok/src/services/jamendo/JamendoInfoParser.h deleted file mode 100644 index dd76673e..00000000 --- a/amarok/src/services/jamendo/JamendoInfoParser.h +++ /dev/null @@ -1,42 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef JAMENDOINFOPARSER_H -#define JAMENDOINFOPARSER_H - -#include - -/** -Handles the fetching and processing of Jamendo specific information for meta items - - @author -*/ -class JamendoInfoParser : public InfoParserBase -{ -Q_OBJECT - -public: - JamendoInfoParser(); - - ~JamendoInfoParser(); - - - virtual void getInfo( Meta::ArtistPtr artist ); - virtual void getInfo( Meta::AlbumPtr album ); - virtual void getInfo( Meta::TrackPtr track ); -}; - -#endif diff --git a/amarok/src/services/jamendo/JamendoMeta.cpp b/amarok/src/services/jamendo/JamendoMeta.cpp deleted file mode 100644 index a2ba0f7a..00000000 --- a/amarok/src/services/jamendo/JamendoMeta.cpp +++ /dev/null @@ -1,310 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "JamendoMeta.h" - -#include "JamendoService.h" -#include "SvgHandler.h" - -#include "core/support/Debug.h" -#include - -#include - -using namespace Meta; - -JamendoMetaFactory::JamendoMetaFactory( const QString & dbPrefix, JamendoService * service ) - : ServiceMetaFactory( dbPrefix ) - , m_service( service ) -{ -} - -TrackPtr JamendoMetaFactory::createTrack( const QStringList & rows ) -{ - JamendoTrack * track = new JamendoTrack( rows ); - track->setService( m_service ); - return TrackPtr( track ); -} - -int -JamendoMetaFactory::getAlbumSqlRowCount() -{ - return ServiceMetaFactory::getAlbumSqlRowCount() + 6; -} - -QString -JamendoMetaFactory::getAlbumSqlRows() -{ - QString sqlRows = ServiceMetaFactory::getAlbumSqlRows(); - - sqlRows += ", "; - sqlRows += tablePrefix() + "_albums.popularity, "; - sqlRows += tablePrefix() + "_albums.cover_url, "; - sqlRows += tablePrefix() + "_albums.launch_year, "; - sqlRows += tablePrefix() + "_albums.genre, "; - sqlRows += tablePrefix() + "_albums.mp3_torrent_url, "; // Deprecated - sqlRows += tablePrefix() + "_albums.ogg_torrent_url "; // Deprecated - - return sqlRows; -} - -AlbumPtr -JamendoMetaFactory::createAlbum( const QStringList & rows ) -{ - JamendoAlbum * album = new JamendoAlbum( rows ); - album->setService( m_service ); - album->setSourceName( "Jamendo.com" ); - return AlbumPtr( album ); -} - -int -JamendoMetaFactory::getArtistSqlRowCount() -{ - return ServiceMetaFactory::getArtistSqlRowCount() + 4; -} - -QString -JamendoMetaFactory::getArtistSqlRows() -{ - QString sqlRows = ServiceMetaFactory::getArtistSqlRows(); - - sqlRows += ", "; - sqlRows += tablePrefix() + "_artists.country, "; - sqlRows += tablePrefix() + "_artists.photo_url, "; - sqlRows += tablePrefix() + "_artists.jamendo_url, "; - sqlRows += tablePrefix() + "_artists.home_url "; - - return sqlRows; -} - -ArtistPtr -JamendoMetaFactory::createArtist( const QStringList & rows ) -{ - JamendoArtist * artist = new JamendoArtist( rows ); - artist->setSourceName( "Jamendo.com" ); - return ArtistPtr( artist ); -} - -GenrePtr -JamendoMetaFactory::createGenre( const QStringList & rows ) -{ - JamendoGenre * genre = new JamendoGenre( rows ); - genre->setSourceName( "Jamendo.com" ); - return GenrePtr( genre ); -} - -//// JamendoTrack //// - -JamendoTrack::JamendoTrack( const QString &name ) - : ServiceTrack( name ) - , m_service ( 0 ) -{ -} - -JamendoTrack::JamendoTrack( const QStringList & resultRow ) - : ServiceTrack( resultRow ) - , m_service ( 0 ) -{ -} - -QString -Meta::JamendoTrack::sourceName() -{ - return "Jamendo.com"; -} - -QString -Meta::JamendoTrack::sourceDescription() -{ - return i18n( "A site where artists can freely share their music" ); -} - -QPixmap -Meta::JamendoTrack::emblem() -{ - return QPixmap( KStandardDirs::locate( "data", "amarok/images/emblem-jamendo.png" ) ); -} - - -QString JamendoTrack::scalableEmblem() -{ - return KStandardDirs::locate( "data", "amarok/images/emblem-jamendo-scalable.svgz" ); -} - -void -Meta::JamendoTrack::setService(JamendoService * service) -{ - m_service = service; -} - -QString JamendoTrack::type() const -{ - return "mp3"; -} - -//// JamendoArtist //// - -JamendoArtist::JamendoArtist( const QString &name ) - : ServiceArtist( name ) -{ -} - -JamendoArtist::JamendoArtist( const QStringList & resultRow ) - : ServiceArtist( resultRow ) -{ - m_country = resultRow[3]; - m_photoURL = resultRow[4]; - m_jamendoURL = resultRow[5]; - m_homeURL = resultRow[6]; -} - -void -JamendoArtist::setCountry( const QString & country ) -{ - m_country = country; -} - -QString -JamendoArtist::country() const -{ - return m_country; -} - - -void -JamendoArtist::setPhotoURL( const QString &photoURL ) -{ - m_photoURL = photoURL; -} - -QString -JamendoArtist::photoURL( ) const -{ - return m_photoURL; -} - -void -JamendoArtist::setHomeURL( const QString &homeURL ) -{ - m_homeURL = homeURL; -} - -QString -JamendoArtist::homeURL( ) const -{ - return m_homeURL; -} - -void -JamendoArtist::setJamendoURL( const QString & jamendoURL ) -{ - m_jamendoURL = jamendoURL; -} - -QString -JamendoArtist::jamendoURL() const -{ - return m_jamendoURL; -} - - -//// JamendoAlbum //// - -JamendoAlbum::JamendoAlbum( const QString &name ) - : ServiceAlbumWithCover( name ) -{ -} - -JamendoAlbum::JamendoAlbum( const QStringList & resultRow ) - : ServiceAlbumWithCover( resultRow ) -{ - m_popularity = resultRow[4].toFloat(); - m_coverURL = resultRow[5]; - m_launchYear = resultRow[6].toInt(); - m_genre = resultRow[7]; -} - -void -JamendoAlbum::setCoverUrl( const QString &coverURL ) -{ - m_coverURL = coverURL; -} - -QString -JamendoAlbum::coverUrl( ) const -{ - return m_coverURL; -} - -void -JamendoAlbum::setLaunchYear( int launchYear ) -{ - m_launchYear = launchYear; -} - -int -JamendoAlbum::launchYear( ) const -{ - return m_launchYear; -} - -void -JamendoAlbum::setGenre( const QString&genre ) -{ - m_genre = genre; -} - -QString -JamendoAlbum::genre( ) const -{ - return m_genre; -} - -void -JamendoAlbum::setPopularity( float popularity ) -{ - m_popularity = popularity; -} - -float -JamendoAlbum::popularity() const -{ - return m_popularity; -} - -void -Meta::JamendoAlbum::setService( JamendoService * service ) -{ - m_service = service; -} - -JamendoService * -Meta::JamendoAlbum::service() -{ - return m_service; -} - - -JamendoGenre::JamendoGenre( const QString & name ) - : ServiceGenre( name ) -{ -} - -JamendoGenre::JamendoGenre( const QStringList & resultRow ) - : ServiceGenre( resultRow ) -{ -} - diff --git a/amarok/src/services/jamendo/JamendoMeta.h b/amarok/src/services/jamendo/JamendoMeta.h deleted file mode 100644 index 4c36303c..00000000 --- a/amarok/src/services/jamendo/JamendoMeta.h +++ /dev/null @@ -1,182 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef JAMENDOMETA_H -#define JAMENDOMETA_H - - -#include "../ServiceMetaBase.h" -#include "../ServiceAlbumCoverDownloader.h" - -#include -#include -#include -#include - -class JamendoService; - -class JamendoMetaFactory : public ServiceMetaFactory -{ - -public: - JamendoMetaFactory( const QString &dbPrefix, JamendoService * service ); - virtual ~JamendoMetaFactory() {} - - //virtual int getTrackSqlRowCount(); - //virtual QString getTrackSqlRows(); - virtual Meta::TrackPtr createTrack( const QStringList &rows ); - - virtual int getAlbumSqlRowCount(); - virtual QString getAlbumSqlRows(); - virtual Meta::AlbumPtr createAlbum( const QStringList &rows ); - - virtual int getArtistSqlRowCount(); - virtual QString getArtistSqlRows(); - virtual Meta::ArtistPtr createArtist( const QStringList &rows ); - - //virtual int getGenreSqlRowCount(); - //virtual QString getGenreSqlRows(); - virtual Meta::GenrePtr createGenre( const QStringList &rows ); - -private: - - JamendoService * m_service; - -}; - - -namespace Meta -{ - -class JamendoTrack : public ServiceTrack -{ -public: - JamendoTrack( const QString &name ); - JamendoTrack( const QStringList &resultRow ); - - void setService( JamendoService * service ); - - virtual QString sourceName(); - virtual QString sourceDescription(); - virtual QPixmap emblem(); - virtual QString scalableEmblem(); - - /** - * Get the file type. - * Since jamendo uses interesting redirects, we cannot use the base implementation - * which relies on getting the file type from the url. - */ - virtual QString type() const; - - virtual bool isBookmarkable() const { return true; } - virtual QString collectionName() const { return "Jamendo.com"; } - virtual bool simpleFiltering() const { return false; } - -private: - JamendoService * m_service; -}; - - -class JamendoArtist : public ServiceArtist -{ -private: - - QString m_country; - QString m_photoURL; - QString m_jamendoURL; - QString m_homeURL; - -public: - JamendoArtist( const QString &name ); - JamendoArtist( const QStringList &resultRow ); - - void setPhotoURL( const QString &photoURL ); - QString photoURL() const; - - void setCountry( const QString &country ); - QString country() const; - - void setHomeURL( const QString &homeURL ); - QString homeURL() const; - - void setJamendoURL( const QString &jamendoURL ); - QString jamendoURL() const; - - virtual bool isBookmarkable() const { return true; } - virtual QString collectionName() const { return "Jamendo.com"; } - virtual bool simpleFiltering() const { return false; } -}; - - -class JamendoAlbum : public ServiceAlbumWithCover -{ -private: - float m_popularity; - QString m_coverURL; - int m_launchYear; - QString m_genre; - - -public: - JamendoAlbum( const QString &name ); - JamendoAlbum( const QStringList &resultRow ); - - - virtual QString downloadPrefix() const { return "jamendo"; } - - void setPopularity( float popularity ); - float popularity() const; - - virtual void setCoverUrl( const QString &coverURL ); - virtual QString coverUrl() const; - - virtual KUrl imageLocation( int size = 1 ) { Q_UNUSED( size ); return KUrl( coverUrl() ); } - - void setLaunchYear( int launchYear ); - int launchYear() const; - - void setGenre( const QString &genre ); - QString genre() const; - - void setService( JamendoService * store ); - JamendoService * service(); - - virtual bool isBookmarkable() const { return true; } - virtual QString collectionName() const { return "Jamendo.com"; } - virtual bool simpleFiltering() const { return false; } - -private: - JamendoService * m_service; - - -}; - -class JamendoGenre : public ServiceGenre -{ - -public: - JamendoGenre( const QString &name ); - JamendoGenre( const QStringList &resultRow ); - - virtual bool isBookmarkable() const { return true; } - virtual QString collectionName() const { return "Jamendo.com"; } - virtual bool simpleFiltering() const { return false; } - -}; - -} - -#endif diff --git a/amarok/src/services/jamendo/JamendoService.cpp b/amarok/src/services/jamendo/JamendoService.cpp deleted file mode 100644 index 0a989f78..00000000 --- a/amarok/src/services/jamendo/JamendoService.cpp +++ /dev/null @@ -1,298 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "JamendoService.h" - -#include "browsers/CollectionTreeItem.h" -#include "browsers/CollectionTreeView.h" -#include "browsers/SingleCollectionTreeItemModel.h" -#include "core-impl/collections/support/CollectionManager.h" -#include "core/support/Debug.h" -#include "core/support/Components.h" -#include "core/interfaces/Logger.h" -#include "EngineController.h" -#include "JamendoInfoParser.h" -#include "ServiceSqlRegistry.h" -#include "widgets/SearchWidget.h" - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -using namespace Meta; - -AMAROK_EXPORT_SERVICE_PLUGIN( jamendo, JamendoServiceFactory ) - -JamendoServiceFactory::JamendoServiceFactory( QObject *parent, const QVariantList &args ) - : ServiceFactory( parent, args ) -{ - KPluginInfo pluginInfo( "amarok_service_jamendo.desktop", "services" ); - pluginInfo.setConfig( config() ); - m_info = pluginInfo; -} - -void JamendoServiceFactory::init() -{ - ServiceBase* service = new JamendoService( this, "Jamendo.com" ); - m_initialized = true; - emit newService( service ); -} - -QString -JamendoServiceFactory::name() -{ - return "Jamendo.com"; -} - -KConfigGroup -JamendoServiceFactory::config() -{ - return Amarok::config( "Service_Jamendo" ); -} - -JamendoService::JamendoService( JamendoServiceFactory* parent, const QString & name) - : ServiceBase( name, parent ) - , m_currentAlbum( 0 ) - , m_xmlParser( 0 ) -{ - setShortDescription( i18n( "A archive of free, Creative Commons licensed music" ) ); - setIcon( KIcon( "view-services-jamendo-amarok" ) ); - - setLongDescription( i18n( "Jamendo.com puts artists and music lovers in touch with each other. The site allows artists to upload their own albums to share them with the world and users to download all of them for free. Listen to and download all Jamendo.com contents from within Amarok." ) ); - -setImagePath( KStandardDirs::locate( "data", "amarok/images/hover_info_jamendo.png" ) ); - - ServiceMetaFactory * metaFactory = new JamendoMetaFactory( "jamendo", this ); - ServiceSqlRegistry * registry = new ServiceSqlRegistry( metaFactory ); - m_collection = new Collections::ServiceSqlCollection( "jamendo", "Jamendo.com", metaFactory, registry ); - CollectionManager::instance()->addTrackProvider( m_collection ); - setServiceReady( true ); -} - -JamendoService::~JamendoService() -{ - DEBUG_BLOCK - - if( m_collection ) - { - CollectionManager::instance()->removeTrackProvider( m_collection ); - m_collection->deleteLater(); - m_collection = 0; - } - - //if currently running, stop it or we will get crashes - if( m_xmlParser ) { - m_xmlParser->requestAbort(); - delete m_xmlParser; - m_xmlParser = 0; - } -} - -void -JamendoService::polish() -{ - generateWidgetInfo(); - if ( m_polished ) - return; - - KHBox * bottomPanelLayout = new KHBox; - bottomPanelLayout->setParent( m_bottomPanel ); - - m_updateListButton = new QPushButton; - m_updateListButton->setParent( bottomPanelLayout ); - m_updateListButton->setText( i18nc( "Fetch new information from the website", "Update" ) ); - m_updateListButton->setObjectName( "updateButton" ); - m_updateListButton->setIcon( KIcon( "view-refresh-amarok" ) ); - - m_downloadButton = new QPushButton; - m_downloadButton->setParent( bottomPanelLayout ); - m_downloadButton->setText( i18n( "Download" ) ); - m_downloadButton->setObjectName( "downloadButton" ); - m_downloadButton->setIcon( KIcon( "download-amarok" ) ); - m_downloadButton->setEnabled( false ); - - connect( m_updateListButton, SIGNAL(clicked()), this, SLOT(updateButtonClicked()) ); - connect( m_downloadButton, SIGNAL(clicked()), this, SLOT(download()) ); - - setInfoParser( new JamendoInfoParser() ); - - QList levels; - levels << CategoryId::Genre << CategoryId::Artist << CategoryId::Album; - - setModel( new SingleCollectionTreeItemModel( m_collection, levels ) ); - - connect( m_contentView, SIGNAL(itemSelected(CollectionTreeItem*)), this, SLOT(itemSelected(CollectionTreeItem*)) ); - - QMenu *filterMenu = new QMenu( 0 ); - -// QAction *action = filterMenu->addAction( i18n("Artist") ); -// connect( action, SIGNAL(triggered(bool)), SLOT(sortByArtist()) ); -// -// action = filterMenu->addAction( i18n( "Artist / Album" ) ); -// connect( action, SIGNAL(triggered(bool)), SLOT(sortByArtistAlbum()) ); -// -// action = filterMenu->addAction( i18n( "Album" ) ); -// connect( action, SIGNAL(triggered(bool)), SLOT(sortByAlbum()) ); - - QAction *action = filterMenu->addAction( i18n( "Genre / Artist" ) ); - connect( action, SIGNAL(triggered(bool)), SLOT(sortByGenreArtist()) ); - - action = filterMenu->addAction( i18n( "Genre / Artist / Album" ) ); - connect( action, SIGNAL(triggered(bool)), SLOT(sortByGenreArtistAlbum()) ); - - KAction *filterMenuAction = new KAction( KIcon( "preferences-other" ), i18n( "Sort Options" ), this ); - filterMenuAction->setMenu( filterMenu ); - - m_searchWidget->toolBar()->addSeparator(); - m_searchWidget->toolBar()->addAction( filterMenuAction ); - - QToolButton *tbutton = qobject_cast< QToolButton* >( m_searchWidget->toolBar()->widgetForAction( filterMenuAction ) ); - if( tbutton ) - tbutton->setPopupMode( QToolButton::InstantPopup ); - -// m_menubar->show(); - - m_polished = true; -} - -void -JamendoService::updateButtonClicked() -{ - m_updateListButton->setEnabled( false ); - - debug() << "JamendoService: start downloading xml file"; - - KTemporaryFile tempFile; - tempFile.setSuffix( ".gz" ); - tempFile.setAutoRemove( false ); //file will be removed in JamendoXmlParser - if( !tempFile.open() ) - return; //error - m_tempFileName = tempFile.fileName(); - m_listDownloadJob = KIO::file_copy( - /* Deprecated */ KUrl( "http://imgjam.com/data/dbdump_artistalbumtrack.xml.gz" ), - KUrl( m_tempFileName ), 0700 , KIO::HideProgressInfo | KIO::Overwrite ); - - Amarok::Components::logger()->newProgressOperation( m_listDownloadJob, i18n( "Downloading Jamendo.com database..." ), this, SLOT(listDownloadCancelled()) ); - - connect( m_listDownloadJob, SIGNAL(result(KJob*)), - this, SLOT(listDownloadComplete(KJob*)) ); -} - -void -JamendoService::listDownloadComplete(KJob * downloadJob) -{ - if( downloadJob != m_listDownloadJob ) - return ; //not the right job, so let's ignore it - debug() << "JamendoService: xml file download complete"; - - m_listDownloadJob = 0; - //testing - if ( downloadJob->error() != 0 ) - { - //TODO: error handling here - m_updateListButton->setEnabled( true ); // otherwise button will remain inactive in case of error - return; - } - - Amarok::Components::logger()->shortMessage( i18n( "Updating the local Jamendo database." ) ); - debug() << "JamendoService: create xml parser"; - - if( m_xmlParser == 0 ) - m_xmlParser = new JamendoXmlParser( m_tempFileName ); - connect( m_xmlParser, SIGNAL(doneParsing()), SLOT(doneParsing()) ); - - ThreadWeaver::Weaver::instance()->enqueue( m_xmlParser ); - downloadJob->deleteLater(); -} - -void -JamendoService::listDownloadCancelled() -{ - m_listDownloadJob->kill(); - m_listDownloadJob = 0; - debug() << "Aborted xml download"; - - m_updateListButton->setEnabled( true ); -} - -void -JamendoService::doneParsing() -{ - debug() << "JamendoService: done parsing"; - m_updateListButton->setEnabled( true ); - // model->setGenre("All"); - //delete sender - sender()->deleteLater(); - m_xmlParser = 0; - m_collection->emitUpdated(); -} - -void -JamendoService::itemSelected( CollectionTreeItem * selectedItem ) -{ - DEBUG_BLOCK - - //we only enable the download button if there is only one item selected and it happens to - //be an album or a track - DataPtr dataPtr = selectedItem->data(); - - if ( typeid( *dataPtr.data() ) == typeid( JamendoTrack ) ) - { - debug() << "is right type (track)"; - JamendoTrack * track = static_cast ( dataPtr.data() ); - m_currentAlbum = static_cast ( track->album().data() ); - m_downloadButton->setEnabled( true ); - } - else if ( typeid( * dataPtr.data() ) == typeid( JamendoAlbum ) ) - { - m_currentAlbum = static_cast ( dataPtr.data() ); - debug() << "is right type (album) named " << m_currentAlbum->name(); - m_downloadButton->setEnabled( true ); - } - else - { - debug() << "is wrong type"; - m_downloadButton->setEnabled( false ); - } - return; -} - -void -JamendoService::download() // SLOT -{ - DEBUG_BLOCK - - if ( !m_polished ) - polish(); - - CollectionTreeView *treeView = static_cast( view() ); - treeView->copySelectedToLocalCollection(); -} - - -#include "moc_JamendoService.cpp" - diff --git a/amarok/src/services/jamendo/JamendoService.h b/amarok/src/services/jamendo/JamendoService.h deleted file mode 100644 index 62eeea44..00000000 --- a/amarok/src/services/jamendo/JamendoService.h +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef JAMENDOSERVICE_H -#define JAMENDOSERVICE_H - -#include "ServiceBase.h" -#include "JamendoDatabaseHandler.h" -#include "JamendoXmlParser.h" -#include "ServiceSqlCollection.h" - -#include "core/support/Amarok.h" -#include -#include - -class JamendoServiceFactory : public ServiceFactory -{ - Q_OBJECT - - public: - JamendoServiceFactory( QObject *parent, const QVariantList &args ); - virtual ~JamendoServiceFactory() {} - - virtual void init(); - virtual QString name(); - virtual KConfigGroup config(); - - virtual bool possiblyContainsTrack( const KUrl &url ) const { return url.url().contains( "jamendo.com", Qt::CaseInsensitive ); } -}; - -class JamendoService : public ServiceBase -{ - Q_OBJECT -public: - JamendoService( JamendoServiceFactory* parent, const QString &name ); - - ~JamendoService(); - - void polish(); - virtual Collections::Collection * collection() { return m_collection; } - -private slots: - void updateButtonClicked(); - void download(); - void listDownloadComplete( KJob* downloadJob); - void listDownloadCancelled(); - void doneParsing(); - - /** - * Checks if download button should be enabled - * @param selection the new selection - */ - void itemSelected( CollectionTreeItem * selectedItem ); - - -private: - //DatabaseDrivenContentModel * m_model; - QPushButton *m_updateListButton; - QPushButton *m_downloadButton; - KIO::FileCopyJob * m_listDownloadJob; - QString m_tempFileName; - Collections::ServiceSqlCollection * m_collection; - Meta::JamendoAlbum * m_currentAlbum; - - JamendoXmlParser * m_xmlParser; -}; - -#endif diff --git a/amarok/src/services/jamendo/JamendoXmlParser.cpp b/amarok/src/services/jamendo/JamendoXmlParser.cpp deleted file mode 100644 index cf3d002b..00000000 --- a/amarok/src/services/jamendo/JamendoXmlParser.cpp +++ /dev/null @@ -1,425 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "JamendoXmlParser.h" - -#include "core/support/Amarok.h" -#include "core/support/Debug.h" -#include "core/support/Components.h" -#include "core/interfaces/Logger.h" - -#include - -#include -#include - -using namespace Meta; - -static const QString COVERURL_BASE = "http://api.jamendo.com/get2/image/album/redirect/?id=%1&imagesize=100"; - -JamendoXmlParser::JamendoXmlParser( const QString &filename ) - : ThreadWeaver::Job() - , n_numberOfTransactions ( 0 ) - , n_maxNumberOfTransactions ( 5000 ) - , m_aborted( false ) -{ - DEBUG_BLOCK - - // From: http://www.linuxselfhelp.com/HOWTO/MP3-HOWTO-13.html#ss13.3 - m_id3GenreHash.insert( 0, "Blues" ); - m_id3GenreHash.insert( 1, "Classic Rock" ); - m_id3GenreHash.insert( 2, "Country" ); - m_id3GenreHash.insert( 3, "Dance" ); - m_id3GenreHash.insert( 4, "Disco" ); - m_id3GenreHash.insert( 5, "Funk" ); - m_id3GenreHash.insert( 6, "Grunge" ); - m_id3GenreHash.insert( 7, "Hip-Hop" ); - m_id3GenreHash.insert( 8, "Jazz" ); - m_id3GenreHash.insert( 9, "Metal" ); - m_id3GenreHash.insert( 10, "New Age" ); - m_id3GenreHash.insert( 11, "Oldies" ); - m_id3GenreHash.insert( 12, "Other" ); - m_id3GenreHash.insert( 13, "Pop" ); - m_id3GenreHash.insert( 14, "R&B" ); - m_id3GenreHash.insert( 15, "Rap" ); - m_id3GenreHash.insert( 16, "Reggae" ); - m_id3GenreHash.insert( 17, "Rock" ); - m_id3GenreHash.insert( 18, "Techno" ); - m_id3GenreHash.insert( 19, "Industrial" ); - m_id3GenreHash.insert( 20, "Alternative" ); - m_id3GenreHash.insert( 21, "Ska" ); - m_id3GenreHash.insert( 22, "Death Metal" ); - m_id3GenreHash.insert( 23, "Pranks" ); - m_id3GenreHash.insert( 24, "Soundtrack" ); - m_id3GenreHash.insert( 25, "Euro-Techno" ); - m_id3GenreHash.insert( 26, "Ambient" ); - m_id3GenreHash.insert( 27, "Trip-Hop" ); - m_id3GenreHash.insert( 28, "Vocal" ); - m_id3GenreHash.insert( 29, "Jazz+Funk" ); - m_id3GenreHash.insert( 30, "Fusion" ); - m_id3GenreHash.insert( 31, "Trance" ); - m_id3GenreHash.insert( 32, "Classical" ); - m_id3GenreHash.insert( 33, "Instrumental" ); - m_id3GenreHash.insert( 34, "Acid" ); - m_id3GenreHash.insert( 35, "House" ); - m_id3GenreHash.insert( 36, "Game" ); - m_id3GenreHash.insert( 37, "Sound Clip" ); - m_id3GenreHash.insert( 38, "Gospel" ); - m_id3GenreHash.insert( 39, "Noise" ); - m_id3GenreHash.insert( 40, "AlternRock" ); - m_id3GenreHash.insert( 41, "Bass" ); - m_id3GenreHash.insert( 42, "Soul" ); - m_id3GenreHash.insert( 43, "Punk" ); - m_id3GenreHash.insert( 44, "Space" ); - m_id3GenreHash.insert( 45, "Meditative" ); - m_id3GenreHash.insert( 46, "Instrumental Pop" ); - m_id3GenreHash.insert( 47, "Instrumental Rock" ); - m_id3GenreHash.insert( 48, "Ethnic" ); - m_id3GenreHash.insert( 49, "Gothic" ); - m_id3GenreHash.insert( 50, "Darkwave" ); - m_id3GenreHash.insert( 51, "Techno-Industrial" ); - m_id3GenreHash.insert( 52, "Electronic" ); - m_id3GenreHash.insert( 53, "Pop-Folk" ); - m_id3GenreHash.insert( 54, "Eurodance" ); - m_id3GenreHash.insert( 55, "Dream" ); - m_id3GenreHash.insert( 56, "Southern Rock" ); - m_id3GenreHash.insert( 57, "Comedy" ); - m_id3GenreHash.insert( 58, "Cult" ); - m_id3GenreHash.insert( 59, "Gangsta" ); - m_id3GenreHash.insert( 60, "Top 40" ); - m_id3GenreHash.insert( 61, "Christian Rap" ); - m_id3GenreHash.insert( 62, "Pop/Funk" ); - m_id3GenreHash.insert( 63, "Jungle" ); - m_id3GenreHash.insert( 64, "Native American" ); - m_id3GenreHash.insert( 65, "Cabaret" ); - m_id3GenreHash.insert( 66, "New Wave" ); - m_id3GenreHash.insert( 67, "Psychedelic" ); - m_id3GenreHash.insert( 68, "Rave" ); - m_id3GenreHash.insert( 69, "Showtunes" ); - m_id3GenreHash.insert( 70, "Trailer" ); - m_id3GenreHash.insert( 71, "Lo-Fi" ); - m_id3GenreHash.insert( 72, "Tribal" ); - m_id3GenreHash.insert( 73, "Acid Punk" ); - m_id3GenreHash.insert( 74, "Acid Jazz" ); - m_id3GenreHash.insert( 75, "Polka" ); - m_id3GenreHash.insert( 76, "Retro" ); - m_id3GenreHash.insert( 77, "Musical" ); - m_id3GenreHash.insert( 78, "Rock & Roll" ); - m_id3GenreHash.insert( 79, "Hard Rock" ); - - m_sFileName = filename; - albumTags.clear(); - m_dbHandler = new JamendoDatabaseHandler(); - connect( this, SIGNAL(done(ThreadWeaver::Job*)), SLOT(completeJob()) ); -} - -JamendoXmlParser::~JamendoXmlParser() -{ - DEBUG_BLOCK - m_reader.clear(); - delete m_dbHandler; -} - -void -JamendoXmlParser::run( ) -{ - if( m_aborted ) - return; - - readConfigFile( m_sFileName ); -} - -void -JamendoXmlParser::completeJob() -{ - if( m_aborted ) - return; - - Amarok::Components::logger()->longMessage( - i18ncp( "First part of: Jamendo.com database update complete. Added 3 tracks on 4 albums from 5 artists.", "Jamendo.com database update complete. Added 1 track on ", "Jamendo.com database update complete. Added %1 tracks on ", m_nNumberOfTracks) - + i18ncp( "Middle part of: Jamendo.com database update complete. Added 3 tracks on 4 albums from 5 artists.", "1 album from ", "%1 albums from ", m_nNumberOfAlbums) - + i18ncp( "Last part of: Jamendo.com database update complete. Added 3 tracks on 4 albums from 5 artists.", "1 artist.", "%1 artists.", m_nNumberOfArtists ) - , Amarok::Logger::Information ); - - debug() << "JamendoXmlParser: total number of artists: " << m_nNumberOfArtists; - debug() << "JamendoXmlParser: total number of albums: " << m_nNumberOfAlbums; - debug() << "JamendoXmlParser: total number of tracks: " << m_nNumberOfTracks; - emit doneParsing(); - deleteLater(); -} - -void -JamendoXmlParser::readConfigFile( const QString &filename ) -{ - if( m_aborted ) - return; - - m_nNumberOfTracks = 0; - m_nNumberOfAlbums = 0; - m_nNumberOfArtists = 0; - - if( !QFile::exists( filename ) ) - { - debug() << "jamendo xml file does not exist"; - return; - } - - QIODevice *file = KFilterDev::deviceForFile( filename, "application/x-gzip", true ); - - if( !file || !file->open( QIODevice::ReadOnly ) ) - { - debug() << "JamendoXmlParser::readConfigFile error reading file"; - return; - } - - m_reader.setDevice( file ); - - m_dbHandler->destroyDatabase(); - m_dbHandler->createDatabase(); - - m_dbHandler->begin(); //start transaction (MAJOR speedup!!) - while( !m_reader.atEnd() ) - { - m_reader.readNext(); - if( m_reader.isStartElement() ) - { - QStringRef localname = m_reader.name(); - if( localname == "artist" ) - { - readArtist(); - } - } - } - - - m_dbHandler->commit(); //complete transaction - //as genres are just user tags, remove any that are not applied to at least 10 albums to weed out the worst crap - //perhaps make this a config option - m_dbHandler->trimGenres( 10 ); - - file->close(); - delete file; - QFile::remove( filename ); -} - -void -JamendoXmlParser::readArtist() -{ - if( m_aborted ) - return; - - Q_ASSERT( m_reader.isStartElement() && m_reader.name() == "artist" ); - -// debug() << "Found artist: "; - m_nNumberOfArtists++; - - QString name; - QString description; - QString imageUrl; - QString jamendoUrl; - - while( !m_reader.atEnd() ) - { - m_reader.readNext(); - - if( m_reader.isEndElement() && m_reader.name() == "artist" ) - break; - if( m_reader.isStartElement() ) - { - QStringRef localname = m_reader.name(); - if( localname == "id" ) - m_currentArtistId = m_reader.readElementText().toInt(); - else if ( localname == "name" ) - name = m_reader.readElementText(); - else if( localname == "url" ) - jamendoUrl = m_reader.readElementText(); - else if( localname == "image" ) - imageUrl = m_reader.readElementText(); - else if( localname == "album" ) - readAlbum(); - } - } - - JamendoArtist currentArtist( name ); - currentArtist.setDescription( description ); - - currentArtist.setId( m_currentArtistId ); - currentArtist.setPhotoURL( imageUrl ); - currentArtist.setJamendoURL( jamendoUrl ); - - m_dbHandler->insertArtist( ¤tArtist ); - countTransaction(); - -// debug() << " Name: " << currentArtist.name(); -// debug() << " Id: " << currentArtist.id(); -// debug() << " Photo: " << currentArtist.photoURL(); -// debug() << " J_url: " << currentArtist.jamendoURL(); -// debug() << " H_url: " << currentArtist.homeURL(); -// debug() << " Decription: " << currentArtist.description(); - -} - -void -JamendoXmlParser::readAlbum() -{ - if( m_aborted ) - return; - - Q_ASSERT( m_reader.isStartElement() && m_reader.name() == "album" ); - - //debug() << "Found album: "; - - - QString name; - QString genre; - QString description; - QStringList tags; - QString coverUrl; - QString releaseDate; - - while( !m_reader.atEnd() ) - { - m_reader.readNext(); - - if( m_reader.isEndElement() && m_reader.name() == "album" ) - break; - if( m_reader.isStartElement() ) - { - QStringRef localname = m_reader.name(); - - if( localname == "id" ) - m_currentAlbumId = m_reader.readElementText().toInt(); - else if ( localname == "name" ) - name = m_reader.readElementText(); - else if( localname == "id3genre" ) - genre = m_id3GenreHash.value( m_reader.readElementText().toInt() ); - else if( localname == "releasedate" ) - releaseDate = m_reader.readElementText(); - else if( localname == "track" ) - readTrack(); -// else if ( currentChildElement.tagName() == "description" ) -// description = currentChildElement.text(); - //we use tags instad of genres for creating genres in the database, as the - //Jamendo.com genres are messy at best -// else if ( currentChildElement.tagName() == "tags" ) -// tags = currentChildElement.text().split(' ', QString::SkipEmptyParts); -// n = n.nextSibling(); - } - } - - //We really do not like albums with no genres, makes the service freeze, so simply ignore this. - if( !genre.isEmpty() && genre != "Unknown" ) - { - m_nNumberOfAlbums++; - JamendoAlbum currentAlbum( name ); - currentAlbum.setGenre( genre ); - currentAlbum.setDescription( description ); - currentAlbum.setId( m_currentAlbumId ); - currentAlbum.setArtistId( m_currentArtistId ); - currentAlbum.setLaunchYear( releaseDate.left( 4 ).toInt() ); - currentAlbum.setCoverUrl( COVERURL_BASE.arg( m_currentAlbumId ) ); - m_albumArtistMap.insert( currentAlbum.id(), currentAlbum.artistId() ); - - int newId = m_dbHandler->insertAlbum( ¤tAlbum ); - countTransaction(); - - //debug() << "inserting genre with album_id = " << newId << " and name = " << genreName; - ServiceGenre currentGenre( genre ); - currentGenre.setAlbumId( newId ); - m_dbHandler->insertGenre( ¤tGenre ); - countTransaction(); - } -} - -void -JamendoXmlParser::readTrack() -{ - if( m_aborted ) - return; - - Q_ASSERT( m_reader.isStartElement() && m_reader.name() == "track" ); - //debug() << "Found track: "; - m_nNumberOfTracks++; - - QString name; - QString id; - qint64 length = 0LL; - QString trackNumber; - QString genre; - - while( !m_reader.atEnd() ) - { - m_reader.readNext(); - - if( m_reader.isEndElement() && m_reader.name() == "track" ) - break; - if( m_reader.isStartElement() ) - { - QStringRef localname = m_reader.name(); - if( localname == "name" ) - name = m_reader.readElementText(); - else if( localname == "id" ) - id = m_reader.readElementText(); - else if( localname == "duration" ) - length = m_reader.readElementText().toFloat() * 1000; - else if ( localname == "numalbum" ) - trackNumber = m_reader.readElementText(); - else if ( localname == "id3genre" ) - genre = m_id3GenreHash.value( m_reader.readElementText().toInt() ); - } - } - - static const QString previewUrl = - "http://api.jamendo.com/get2/stream/track/redirect/?id=%1&streamencoding=mp32"; - - JamendoTrack currentTrack( name ); - currentTrack.setId( id.toInt() ); - currentTrack.setUidUrl( previewUrl.arg( id ) ); - currentTrack.setAlbumId( m_currentAlbumId ); - currentTrack.setArtistId( m_currentArtistId ); - currentTrack.setLength( length ); - currentTrack.setTrackNumber( trackNumber.toInt() ); - currentTrack.setGenre( genre ); - - if( m_albumArtistMap.contains( currentTrack.albumId() ) ) - currentTrack.setArtistId( m_albumArtistMap.value( currentTrack.albumId() ) ); - - // debug() << "inserting track with artist id: " << currentTrack.artistId(); - - m_dbHandler->insertTrack( ¤tTrack ); - countTransaction(); -} - -void -JamendoXmlParser::countTransaction() -{ - n_numberOfTransactions++; - if ( n_numberOfTransactions >= n_maxNumberOfTransactions ) - { - m_dbHandler->commit(); - m_dbHandler->begin(); - n_numberOfTransactions = 0; - } -} - -void -JamendoXmlParser::requestAbort() -{ - m_aborted = true; -} - -#include "moc_JamendoXmlParser.cpp" - diff --git a/amarok/src/services/jamendo/JamendoXmlParser.h b/amarok/src/services/jamendo/JamendoXmlParser.h deleted file mode 100644 index a63c6650..00000000 --- a/amarok/src/services/jamendo/JamendoXmlParser.h +++ /dev/null @@ -1,120 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef JAMENDOXMLPARSER_H -#define JAMENDOXMLPARSER_H - -#include "JamendoDatabaseHandler.h" - -#include - -#include -#include -#include -#include -#include - -/** -* Parser for the XML file from http://imgjam.com/data/dbdump_artistalbumtrack.xml.gz -* -* @author Nikolaj Hald Nielsen -*/ -class JamendoXmlParser : public ThreadWeaver::Job -{ - Q_OBJECT - -public: - - /** - * Constructor - * @param fileName The file to parse - * @return Pointer to new object - */ - JamendoXmlParser( const QString &fileName ); - - /** - * The function that starts the actual work. Inherited from ThreadWeaver::Job - * Note the work is performed in a separate thread - * @return Returns true on success and false on failure - */ - void run(); - - /** - * Destructor - * @return none - */ - ~JamendoXmlParser(); - - /** - * Reads, and starts parsing, file. Should not be used directly. - * @param filename The file to read - */ - void readConfigFile( const QString &filename ); - - virtual void requestAbort (); - - -signals: - - /** - * Signal emitted when parsing is complete. - */ - void doneParsing(); - -private slots: - /** - * Called when the job has completed. Is executed in the GUI thread - */ - void completeJob(); - -private: - - JamendoDatabaseHandler * m_dbHandler; - QXmlStreamReader m_reader; - QString m_sFileName; - - QMap albumTags; //used for applying genres to individual tracks - - int m_nNumberOfTracks; - int m_nNumberOfAlbums; - int m_nNumberOfArtists; - - /** - * Read a DOM element representing an artist - */ - void readArtist(); - /** - * Read a DOM element representing an album - */ - void readAlbum(); - /** - * Read a DOM element representing a track - */ - void readTrack(); - - void countTransaction(); - int m_currentArtistId; - int m_currentAlbumId; - - int n_numberOfTransactions; - int n_maxNumberOfTransactions; - QHash< int, QString > m_id3GenreHash; - QMap m_albumArtistMap; - - bool m_aborted; -}; - -#endif diff --git a/amarok/src/services/jamendo/amarok_service_jamendo.desktop b/amarok/src/services/jamendo/amarok_service_jamendo.desktop deleted file mode 100644 index c5e24c77..00000000 --- a/amarok/src/services/jamendo/amarok_service_jamendo.desktop +++ /dev/null @@ -1,130 +0,0 @@ -[Desktop Entry] -Type=Service -ServiceTypes=KPluginInfo -Icon=view-services-jamendo-amarok -Name=Jamendo -Name[bg]=Jamendo -Name[bs]=Jamendo -Name[ca]=Jamendo -Name[ca@valencia]=Jamendo -Name[cs]=Jamendo -Name[csb]=Jamendo -Name[da]=Jamendo -Name[de]=Jamendo -Name[el]=Jamendo -Name[en_GB]=Jamendo -Name[eo]=Jamendo -Name[es]=Jamendo -Name[et]=Jamendo -Name[eu]=Jamendo -Name[fi]=Jamendo -Name[fr]=Jamendo -Name[ga]=Jamendo -Name[gl]=Jamendo -Name[hu]=Jamendo -Name[id]=Jamendo -Name[is]=Jamendo -Name[it]=Jamendo -Name[ja]=Jamendo -Name[km]=Jamendo -Name[ko]=Jamendo -Name[lt]=Jamendo -Name[lv]=Jamendo -Name[mr]=जामेंदो -Name[nb]=Jamendo -Name[nds]=Jamendo -Name[nl]=Jamendo -Name[nn]=Jamendo -Name[pa]=ਜਾਮੀਂਡੋ -Name[pl]=Jamendo -Name[pt]=Jamendo -Name[pt_BR]=Jamendo -Name[ro]=Jamendo -Name[ru]=Jamendo -Name[sk]=Jamendo -Name[sl]=Jamendo -Name[sq]=Jamendo -Name[sr]=Џамендо -Name[sr@ijekavian]=Џамендо -Name[sr@ijekavianlatin]=Jamendo -Name[sr@latin]=Jamendo -Name[sv]=Jamendo -Name[th]=บริการ Jamendo -Name[tr]=Jamendo -Name[ug]=Jamendo -Name[uk]=Jamendo -Name[wa]=Jamendo -Name[x-test]=xxJamendoxx -Name[zh_CN]=Jamendo -Name[zh_TW]=Jamendo -Comment=Listen to and download music uploaded by independent artists -Comment[bg]=Слушане и сваляне на музика от независими изпълнители -Comment[bs]=Slušajte i preuzimajte muziku nezavisnih izvođača -Comment[ca]=Escolta i baixa música pujada per artistes independents -Comment[ca@valencia]=Escolta i baixa música pujada per artistes independents -Comment[cs]=Poslouchejte a stahujte hudbu nahranou nezávislými umělci -Comment[da]=Lyt til og download musik som er uploadet af uafhængige kunstnere -Comment[de]=Musik unabhängiger Interpreten hören und herunterladen -Comment[el]=Ακούστε και κατεβάστε μουσική ανεξάρτητων καλλιτεχνών -Comment[en_GB]=Listen to and download music uploaded by independent artists -Comment[es]=Escuchar y descargar música enviada por artistas independientes -Comment[et]=Sõltumatute esitajate muusika kuulamine ja allalaadimine -Comment[eu]=Entzun eta deskargatu musikari independenteek igotako musika -Comment[fi]=Kuuntele ja lataa itsenäisten artistien lähettämää musiikkia -Comment[fr]=Écouter et télécharger de la musique mise à disposition par des artistes indépendants -Comment[ga]=Éist le ceol uasluchtaithe ag ealaíontóirí neamhspleácha agus íosluchtaigh é freisin -Comment[gl]=Escoite e obteña música enviada por artistas independentes -Comment[he]=האזנה והורדת מוזיקה שהועלתה על ידי יוצרים עצמאיים -Comment[hu]=Független művészek által feltöltött zene hallgatása és letöltése -Comment[id]=Mendengar dan juga mengunduh musik yang diunggah oleh artis sendiri -Comment[is]=Hlusta á og hala niður tónlist frá sjálfstæðum óhaðum listamönnum -Comment[it]=Ascoltare e scaricare musica inviata da artisti indipendenti -Comment[ja]=無所属のアーティストによってアップロードされた音楽を聴いたりダウンロードしたりできます -Comment[km]=ស្ដាប់ និង​ទាញ​យក​តន្ត្រី​ដែល​បាន​ផ្ទុក​ឡើង​ដោយ​សិល្បករ​ឯករាជ្យ -Comment[ko]=독립된 가수가 만든 음악을 듣고 내려받기 -Comment[ku]=Muzîkên, alî yê hunermendê azad ve hatine bar kirin, guhdarî bike û bi daxe -Comment[lt]=Klausyti ir atsisiųsti muziką, atsiųstą nepriklausomų atlikėjų -Comment[lv]=Klausieties un lejupielādējiet mūziku, kuru augšupielādē neatkarīgie mākslinieki -Comment[nb]=Lytt til og last ned musikk som er lastet opp av uavhengige artister -Comment[nds]=Musik anhören un daalladen, de nich afhangig Künstlers hoochlaadt hebbt -Comment[nl]=Luister naar en download muziek die door onafhankelijke artiesten is vrijgegeven -Comment[nn]=Høyr på og last ned musikk lasta opp av uavhengige artistar -Comment[pl]=Słuchaj i pobieraj muzykę udostępnioną przez niezależnych wykonawców -Comment[pt]=Escutar e transferir as músicas enviadas por artistas independentes -Comment[pt_BR]=Ouça e baixe músicas enviadas por artistas independentes -Comment[ro]=Ascultă și descarcă muzică încărcată de artiști independenți -Comment[ru]=Прослушивание и загрузка музыки, предоставленной независимыми исполнителями -Comment[sk]=Počúvať a sťahovať hudbu nahranú nezávislými interpretmi -Comment[sl]=Poslušajte in prejmite glasbo, ki so jo ustvarili neodvisni glasbeniki -Comment[sr]=Слушајте и преузимајте музику независних извођача -Comment[sr@ijekavian]=Слушајте и преузимајте музику независних извођача -Comment[sr@ijekavianlatin]=Slušajte i preuzimajte muziku nezavisnih izvođača -Comment[sr@latin]=Slušajte i preuzimajte muziku nezavisnih izvođača -Comment[sv]=Lyssna på och ladda ner musik uppladdad av oberoende artister -Comment[th]=ฟังและดาวน์โหลดดนตรีที่ถูกอัปโหลดจากศิลปินอิสระต่าง ๆ -Comment[tr]=Bağımsız sanatçılar tarafından yüklenmiş müzikleri dinleyin ve indirin -Comment[uk]=Прослухайте і звантажте музику, записану незалежними виконавцями -Comment[wa]=Schoûter eyet aberweter del muzike eberwetêye pa des årtisses dislaxhîs -Comment[x-test]=xxListen to and download music uploaded by independent artistsxx -Comment[zh_CN]=收听并下载由独立艺术家上传的音乐 -Comment[zh_TW]=聆聽並下載由獨立藝人所上傳的音樂 - - -ServiceTypes=Amarok/Plugin - -X-KDE-Amarok-authors=Nikolaj Hald Nielsen -X-KDE-Amarok-email=nhnFreespirit@gmail.com -X-KDE-Amarok-framework-version=72 -X-KDE-Amarok-name=JamendoService -X-KDE-Amarok-plugintype=service -X-KDE-Amarok-rank=100 -X-KDE-Amarok-version=1 - -X-KDE-PluginInfo-Author=Nikolaj Hald Nielsen -X-KDE-PluginInfo-Email=nhnFreespirit@gmail.com -X-KDE-PluginInfo-Version=1.0 -X-KDE-PluginInfo-Category=Service -X-KDE-PluginInfo-License=GPL -X-KDE-PluginInfo-EnabledByDefault=true -X-KDE-Library=amarok_service_jamendo -X-KDE-PluginInfo-Name=amarok_service_jamendo diff --git a/amarok/src/services/jamendo/images/CMakeLists.txt b/amarok/src/services/jamendo/images/CMakeLists.txt deleted file mode 100644 index d791eacc..00000000 --- a/amarok/src/services/jamendo/images/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -install( - FILES - hover_info_jamendo.png - DESTINATION ${DATA_INSTALL_DIR}/amarok/images -) diff --git a/amarok/src/services/jamendo/images/hover_info_jamendo.png b/amarok/src/services/jamendo/images/hover_info_jamendo.png deleted file mode 100644 index b258c43d..00000000 Binary files a/amarok/src/services/jamendo/images/hover_info_jamendo.png and /dev/null differ diff --git a/amarok/src/services/lastfm/AvatarDownloader.cpp b/amarok/src/services/lastfm/AvatarDownloader.cpp deleted file mode 100644 index 05f16b75..00000000 --- a/amarok/src/services/lastfm/AvatarDownloader.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * Copyright (c) 2007 Casey Link * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "AvatarDownloader" - -#include "AvatarDownloader.h" -#include "core/support/Debug.h" - -#include - -AvatarDownloader::AvatarDownloader() -{ -} - -AvatarDownloader::~AvatarDownloader() -{ -} - -void -AvatarDownloader::downloadAvatar( const QString& username, const KUrl& url ) -{ - if( !url.isValid() ) - return; - - m_userAvatarUrls.insert( url, username ); - The::networkAccessManager()->getData( url, this, - SLOT(downloaded(KUrl,QByteArray,NetworkAccessManagerProxy::Error)) ); -} - -void -AvatarDownloader::downloaded( const KUrl &url, QByteArray data, NetworkAccessManagerProxy::Error e ) -{ - if( !m_userAvatarUrls.contains( url ) ) - return; - - const QString username = m_userAvatarUrls.take( url ); - if( e.code == QNetworkReply::NoError ) - { - QPixmap avatar; - if( avatar.loadFromData( data ) ) - emit avatarDownloaded( username, avatar ); - } - else - debug() << QString("Error: failed to download %1'savatar: %1").arg(username).arg(e.description); -} - -#include "moc_AvatarDownloader.cpp" diff --git a/amarok/src/services/lastfm/AvatarDownloader.h b/amarok/src/services/lastfm/AvatarDownloader.h deleted file mode 100644 index 75967b87..00000000 --- a/amarok/src/services/lastfm/AvatarDownloader.h +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Casey Link * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AVATAR_DOWNLOADER_H -#define AVATAR_DOWNLOADER_H - -#include "network/NetworkAccessManagerProxy.h" - -#include -#include - -class AvatarDownloader : public QObject -{ - Q_OBJECT - - public: - - /** - * Constructor. - */ - AvatarDownloader(); - - /** - * Destructor. - */ - ~AvatarDownloader(); - - /** - * Start the download - * @param url The url that should be downloaded. - */ - void downloadAvatar( const QString& username, const KUrl& url ); - - signals: - void avatarDownloaded( const QString &username, QPixmap avatar ); - - private slots: - /** - * Slot called when the network access manager finished a request - */ - void downloaded( const KUrl &url, QByteArray data, NetworkAccessManagerProxy::Error e ); - - private: - QHash m_userAvatarUrls; -}; -#endif diff --git a/amarok/src/services/lastfm/CMakeLists.txt b/amarok/src/services/lastfm/CMakeLists.txt deleted file mode 100644 index 9c0d3281..00000000 --- a/amarok/src/services/lastfm/CMakeLists.txt +++ /dev/null @@ -1,80 +0,0 @@ -include_directories( - ${LIBLASTFM_INCLUDE_DIR} -) - -add_subdirectory( images ) - -########### next target ############### - -set( amarok_service_lastfm_shared_SRCS - LastFmServiceConfig.cpp -) -add_library( amarok_service_lastfm_shared SHARED ${amarok_service_lastfm_shared_SRCS} ) -target_link_libraries( amarok_service_lastfm_shared - amarokcore - ${KDE4_KDECORE_LIBS} - ${KDE4_KDEUI_LIBS} -) -install( TARGETS amarok_service_lastfm_shared ${INSTALL_TARGETS_DEFAULT_ARGS} ) - -########### next target ############### - -set( amarok_service_lastfm_PART_SRCS - LastFmService.cpp - LastFmServiceCollection.cpp - ScrobblerAdapter.cpp - SynchronizationAdapter.cpp - SynchronizationTrack.cpp - LastFmTreeModel.cpp - LastFmTreeView.cpp - AvatarDownloader.cpp - - meta/LastFmMeta.cpp - meta/LastFmMultiPlayableCapability.cpp - meta/LastFmStreamInfoCapability.cpp - - biases/LastFmBias.cpp - biases/WeeklyTopBias.cpp - - SimilarArtistsAction.cpp - LoveTrackAction.cpp -) -kde4_add_plugin( amarok_service_lastfm ${amarok_service_lastfm_PART_SRCS} ) -target_link_libraries( amarok_service_lastfm - amarok_service_lastfm_shared - amarokcore - amaroklib - amarokpud - ${LIBLASTFM_LIBRARY} - ${KDE4_KDECORE_LIBS} - ${KDE4_KDEUI_LIBS} - ${KDE4_KIO_LIBS} - ${KDE4_SOLID_LIBRARY} - ${KDE4_THREADWEAVER_LIBS} - ${QT_QTNETWORK_LIBRARY} -) -install( TARGETS amarok_service_lastfm DESTINATION ${PLUGIN_INSTALL_DIR} ) - -########### next target ############### - -set(kcm_amarok_service_lastfm_PART_SRCS - LastFmServiceSettings.cpp - LastFmConfigWidget.ui -) -kde4_add_plugin( kcm_amarok_service_lastfm ${kcm_amarok_service_lastfm_PART_SRCS} ) -target_link_libraries( kcm_amarok_service_lastfm - amarok_service_lastfm_shared - amarokcore - amaroklib - ${LIBLASTFM_LIBRARY} - ${KDE4_KDEUI_LIBS} - ${KDE4_KUTILS_LIBS} - ${KDE4_KIO_LIBS} - ${QT_QTNETWORK_LIBRARY} ) -install( TARGETS kcm_amarok_service_lastfm DESTINATION ${PLUGIN_INSTALL_DIR} ) - -########### install files ############### - -install( FILES amarok_service_lastfm.desktop DESTINATION ${SERVICES_INSTALL_DIR} ) -install( FILES amarok_service_lastfm_config.desktop DESTINATION ${SERVICES_INSTALL_DIR} ) -install( FILES amaroklastfm.protocol DESTINATION ${SERVICES_INSTALL_DIR} ) diff --git a/amarok/src/services/lastfm/LastFmConfigWidget.ui b/amarok/src/services/lastfm/LastFmConfigWidget.ui deleted file mode 100644 index 4eda6867..00000000 --- a/amarok/src/services/lastfm/LastFmConfigWidget.ui +++ /dev/null @@ -1,232 +0,0 @@ - - - LastFmConfigWidget - - - - 0 - 0 - 450 - 460 - - - - - 1 - 1 - - - - - 0 - - - - - Last.fm Profile - - - - - - &Username: - - - false - - - kcfg_ScrobblerUsername - - - - - - - &Password: - - - false - - - kcfg_ScrobblerPassword - - - - - - - QLineEdit::Password - - - - - - - - - - - 0 - 0 - - - - <a href="http://www.last.fm:80/signup.php">Sign up to Last.fm</a> - - - true - - - true - - - - - - - &Test Login - - - - - - - - - - Why not join the <a href="http://www.last.fm:80/group/Amarok+Users">Amarok Last.fm group</a> and share your musical tastes with other Amarok users? - - - true - - - true - - - - - - - Qt::Vertical - - - - - - - Last.fm Services - - - - - - false - - - &Submit tracks - - - true - - - - - - - &Retrieve similar artists - - - false - - - - - - - &Use composer data if available in Last.fm as artist - - - false - - - - - - - Use Last.fm tags like <b>7 of 10 stars</b> to represent your Amarok ratings during statistics synchronization - - - Use fancy tags to represent ratings - - - - - - - <html>When scrobbling tracks to Last.fm, it autocorrects common errors in track tags like artist, album and title. Check this to be notified when this happens and what the autocorrection was</html> - - - Announce correction suggestions for track tags - - - - - - - - - <html>Check if you want certain tracks neither to be scrobbled nor to be updated to Last.fm now playing</html> - - - Do not scrobble tracks with label: - - - - - - - <html>Select a preferred label (or write a new one). Tracks with this label will not be scrobbled</html> - - - true - - - QComboBox::InsertAlphabetically - - - - - - - Qt::Horizontal - - - - - - - - - - - - - - KLineEdit - QLineEdit -
    klineedit.h
    -
    -
    - - kcfg_ScrobblerUsername - kcfg_ScrobblerPassword - testLogin - kcfg_SubmitPlayedSongs - kcfg_RetrieveSimilarArtists - - - klineedit.h - - - -
    diff --git a/amarok/src/services/lastfm/LastFmService.cpp b/amarok/src/services/lastfm/LastFmService.cpp deleted file mode 100644 index 48a92583..00000000 --- a/amarok/src/services/lastfm/LastFmService.cpp +++ /dev/null @@ -1,538 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Shane King * - * Copyright (c) 2008 Leo Franchi * - * Copyright (c) 2009 Casey Link * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "LastFmService" -#include "core/support/Debug.h" - -#include "LastFmService.h" - -#include "AvatarDownloader.h" -#include "EngineController.h" -#include "biases/LastFmBias.h" -#include "biases/WeeklyTopBias.h" -#include "LastFmServiceCollection.h" -#include "LastFmServiceConfig.h" -#include "LoveTrackAction.h" -#include "SimilarArtistsAction.h" -#include "LastFmTreeModel.h" -#include "LastFmTreeView.h" -#include "ScrobblerAdapter.h" -#include "GlobalCurrentTrackActions.h" -#include "core/support/Components.h" -#include "core/interfaces/Logger.h" -#include "meta/LastFmMeta.h" -#include "SynchronizationAdapter.h" -#include "statsyncing/Controller.h" -#include "widgets/SearchWidget.h" - -#include -#include - -#include -#include -#include -#include -#include //Qt::escape -#include - -#include - -AMAROK_EXPORT_SERVICE_PLUGIN( lastfm, LastFmServiceFactory ) - -QString md5( const QByteArray& src ) -{ - QByteArray const digest = QCryptographicHash::hash( src, QCryptographicHash::Md5 ); - return QString::fromLatin1( digest.toHex() ).rightJustified( 32, '0' ); -} - -LastFmServiceFactory::LastFmServiceFactory( QObject *parent, const QVariantList &args ) - : ServiceFactory( parent, args ) -{ - KPluginInfo pluginInfo( "amarok_service_lastfm.desktop", "services" ); - pluginInfo.setConfig( config() ); - m_info = pluginInfo; -} - -void -LastFmServiceFactory::init() -{ - ServiceBase *service = new LastFmService( this, "Last.fm" ); - m_initialized = true; - emit newService( service ); -} - -QString -LastFmServiceFactory::name() -{ - return "Last.fm"; -} - -KConfigGroup -LastFmServiceFactory::config() -{ - return Amarok::config( LastFmServiceConfig::configSectionName() ); -} - -bool -LastFmServiceFactory::possiblyContainsTrack( const KUrl &url ) const -{ - return url.protocol() == "lastfm"; -} - - -LastFmService::LastFmService( LastFmServiceFactory *parent, const QString &name ) - : ServiceBase( name, parent, false ) - , m_collection( 0 ) - , m_polished( false ) - , m_avatarLabel( 0 ) - , m_profile( 0 ) - , m_userinfo( 0 ) - , m_subscriber( false ) - , m_authenticateReply( 0 ) - , m_config( LastFmServiceConfig::instance() ) -{ - DEBUG_BLOCK - setShortDescription( i18n( "Last.fm: The social music revolution" ) ); - setIcon( KIcon( "view-services-lastfm-amarok" ) ); - setLongDescription( i18n( "Last.fm is a popular online service that provides personal radio stations and music recommendations. A personal listening station is tailored based on your listening habits and provides you with recommendations for new music. It is also possible to play stations with music that is similar to a particular artist as well as listen to streams from people you have added as friends or that Last.fm considers your musical \"neighbors\"" ) ); - setImagePath( KStandardDirs::locate( "data", "amarok/images/hover_info_lastfm.png" ) ); - - //We have no use for searching currently.. - m_searchWidget->setVisible( false ); - - // set the global static Lastfm::Ws stuff - lastfm::ws::ApiKey = Amarok::lastfmApiKey(); - lastfm::ws::SharedSecret = Amarok::lastfmApiSharedSecret(); - - // set the nam TWICE. Yes. It prevents liblastfm from deleting it, see their code - lastfm::setNetworkAccessManager( The::networkAccessManager() ); - lastfm::setNetworkAccessManager( The::networkAccessManager() ); - - // enable custom bias - m_biasFactories << new Dynamic::LastFmBiasFactory(); - Dynamic::BiasFactory::instance()->registerNewBiasFactory( m_biasFactories.last() ); - m_biasFactories << new Dynamic::WeeklyTopBiasFactory(); - Dynamic::BiasFactory::instance()->registerNewBiasFactory( m_biasFactories.last() ); - - // add the "play similar artists" action to all artist - The::globalCollectionActions()->addArtistAction( new SimilarArtistsAction( this ) ); - The::globalCollectionActions()->addTrackAction( new LoveTrackAction( this ) ); - - QAction *loveAction = new QAction( KIcon( "love-amarok" ), i18n( "Last.fm: Love" ), this ); - connect( loveAction, SIGNAL(triggered()), this, SLOT(love()) ); - loveAction->setShortcut( i18n( "Ctrl+L" ) ); - The::globalCurrentTrackActions()->addAction( loveAction ); - - connect( m_config.data(), SIGNAL(updated()), this, SLOT(slotReconfigure()) ); - QTimer::singleShot(0, this, SLOT(slotReconfigure())); // call reconfigure but only after constructor is finished (because it might call virtual methods) -} - -LastFmService::~LastFmService() -{ - DEBUG_BLOCK - using namespace Dynamic; - QMutableListIterator it( m_biasFactories ); - while( it.hasNext() ) - { - AbstractBiasFactory *factory = it.next(); - it.remove(); - - BiasFactory::instance()->removeBiasFactory( factory ); - delete factory; - } - - if( m_collection ) - { - CollectionManager::instance()->removeTrackProvider( m_collection ); - m_collection->deleteLater(); - m_collection = 0; - } - - StatSyncing::Controller *controller = Amarok::Components::statSyncingController(); - if( m_scrobbler && controller ) - controller->unregisterScrobblingService( StatSyncing::ScrobblingServicePtr( m_scrobbler.data() ) ); - if( m_synchronizationAdapter && controller ) - controller->unregisterProvider( m_synchronizationAdapter ); -} - -void -LastFmService::slotReconfigure() -{ - lastfm::ws::Username = m_config->username(); - bool ready = !m_config->username().isEmpty(); // core features require just username - - /* create ServiceCollection only once the username is known (remember, getting - * username from KWallet is async! */ - if( !m_collection && ready ) - { - m_collection = new Collections::LastFmServiceCollection( m_config->username() ); - CollectionManager::instance()->addTrackProvider( m_collection ); - } - - // create Model once the username is known, it depends on it implicitly - if( !model() && ready ) - { - setModel( new LastFmTreeModel( this ) ); - } - - setServiceReady( ready ); // emits ready(), which needs to be done *after* creating collection - - // now authenticate w/ last.fm and get our session key if we don't have one - if( !m_config->sessionKey().isEmpty() ) - { - debug() << __PRETTY_FUNCTION__ << "using saved session key for last.fm"; - continueReconfiguring(); - } - else if( !m_config->username().isEmpty() && !m_config->password().isEmpty() ) - { - debug() << __PRETTY_FUNCTION__ << "got no saved session key, authenticating with last.fm"; - - // discard any possible ongoing auth connections - if( m_authenticateReply ) - { - disconnect( m_authenticateReply, SIGNAL(finished()), this, SLOT(onAuthenticated()) ); - m_authenticateReply->abort(); - m_authenticateReply->deleteLater(); - m_authenticateReply = 0; - } - - const QString authToken = md5( QString( "%1%2" ).arg( m_config->username() ).arg( - md5( m_config->password().toUtf8() ) ).toUtf8() ); - QMap query; - query[ "method" ] = "auth.getMobileSession"; - query[ "username" ] = m_config->username(); - query[ "authToken" ] = authToken; - m_authenticateReply = lastfm::ws::post( query ); - connect( m_authenticateReply, SIGNAL(finished()), this, SLOT(onAuthenticated()) ); // calls continueReconfiguring() - } - else - { - debug() << __PRETTY_FUNCTION__ << "either last.fm username or password is empty"; - continueReconfiguring(); - } -} - -void -LastFmService::continueReconfiguring() -{ - StatSyncing::Controller *controller = Amarok::Components::statSyncingController(); - Q_ASSERT( controller ); - - lastfm::ws::SessionKey = m_config->sessionKey(); - // we also check username, KWallet may deliver it really late, but we need it - bool authenticated = serviceReady() && !m_config->sessionKey().isEmpty(); - - if( m_scrobbler && (!authenticated || !m_config->scrobble()) ) - { - debug() << __PRETTY_FUNCTION__ << "unregistering and destorying ScrobblerAdapter"; - controller->unregisterScrobblingService( StatSyncing::ScrobblingServicePtr( m_scrobbler.data() ) ); - m_scrobbler = 0; - } - else if( !m_scrobbler && authenticated && m_config->scrobble() ) - { - debug() << __PRETTY_FUNCTION__ << "creating and registering ScrobblerAdapter"; - m_scrobbler = new ScrobblerAdapter( "Amarok", m_config ); - controller->registerScrobblingService( StatSyncing::ScrobblingServicePtr( m_scrobbler.data() ) ); - } - - if( m_synchronizationAdapter && !authenticated ) - { - debug() << __PRETTY_FUNCTION__ << "unregistering and destorying SynchronizationAdapter"; - controller->unregisterProvider( m_synchronizationAdapter ); - m_synchronizationAdapter = 0; - } - else if( !m_synchronizationAdapter && authenticated ) - { - debug() << __PRETTY_FUNCTION__ << "creating and registering SynchronizationAdapter"; - m_synchronizationAdapter = new SynchronizationAdapter( m_config ); - controller->registerProvider( m_synchronizationAdapter ); - } - - // update possibly changed user info - QNetworkReply *reply = lastfm::User::getInfo(); - connect( reply, SIGNAL(finished()), SLOT(onGetUserInfo()) ); -} - -void -LastFmService::onAuthenticated() -{ - if( !m_authenticateReply ) - warning() << __PRETTY_FUNCTION__ << "null reply!"; - else - m_authenticateReply->deleteLater(); - - /* temporarily disconnect form config updates to prevent calling - * slotReconfigure() for the second time. */ - disconnect( m_config.data(), SIGNAL(updated()), this, SLOT(slotReconfigure()) ); - - switch( m_authenticateReply ? m_authenticateReply->error() : QNetworkReply::UnknownNetworkError ) - { - case QNetworkReply::NoError: - { - lastfm::XmlQuery lfm; - if( !lfm.parse( m_authenticateReply->readAll() ) || lfm.children( "error" ).size() > 0 ) - { - debug() << "error from authenticating with last.fm service:" << lfm.text(); - m_config->setSessionKey( QString() ); - m_config->save(); - break; - } - m_config->setSessionKey( lfm[ "session" ][ "key" ].text() ); - m_config->save(); - - break; - } - case QNetworkReply::AuthenticationRequiredError: - Amarok::Components::logger()->longMessage( i18nc("Last.fm: errorMessage", - "Either the username was not recognized, or the password was incorrect." ) ); - break; - - default: - Amarok::Components::logger()->longMessage( i18nc("Last.fm: errorMessage", - "There was a problem communicating with the Last.fm services. Please try again later." ) ); - break; - } - m_authenticateReply = 0; - - // connect back to config updates - connect( m_config.data(), SIGNAL(updated()), this, SLOT(slotReconfigure()) ); - continueReconfiguring(); -} - -void -LastFmService::onGetUserInfo() -{ - QNetworkReply *reply = qobject_cast( sender() ); - if( !reply ) - warning() << __PRETTY_FUNCTION__ << "null reply!"; - else - reply->deleteLater(); - - switch( reply ? reply->error() : QNetworkReply::UnknownNetworkError ) - { - case QNetworkReply::NoError: - { - lastfm::XmlQuery lfm; - if( lfm.parse( reply->readAll() ) ) { - m_country = lfm["user"]["country"].text(); - m_age = lfm["user"]["age"].text(); - m_gender = lfm["user"]["gender"].text(); - m_playcount = lfm["user"]["playcount"].text(); - m_subscriber = lfm["user"]["subscriber"].text() == "1"; - - debug() << "profile info " << m_country << " " << m_age << " " << m_gender << " " << m_playcount << " " << m_subscriber; - if( !lfm["user"][ "image" ].text().isEmpty() ) - { - debug() << "profile avatar: " <downloadAvatar( m_config->username(), url); - connect( downloader, SIGNAL(avatarDownloaded(QString,QPixmap)), - SLOT(onAvatarDownloaded(QString,QPixmap)) ); - } - updateProfileInfo(); - } - else - debug() << "Got exception in parsing from last.fm:" << lfm.parseError().message(); - break; - } - case QNetworkReply::AuthenticationRequiredError: - debug() << "Last.fm: errorMessage: Sorry, we don't recognise that username, or you typed the password incorrectly."; - break; - default: - debug() << "Last.fm: errorMessage: There was a problem communicating with the Last.fm services. Please try again later."; - break; - } -} - -void -LastFmService::onAvatarDownloaded( const QString &username, QPixmap avatar ) -{ - DEBUG_BLOCK - sender()->deleteLater(); - if( username == m_config->username() && !avatar.isNull() ) - { - LastFmTreeModel* lfm = dynamic_cast( model() ); - if( !lfm ) - return; - - int m = lfm->avatarSize(); - avatar = avatar.scaled( m, m, Qt::KeepAspectRatio, Qt::SmoothTransformation ); - lfm->prepareAvatar( avatar, m ); - m_avatar = avatar; - - if( m_avatarLabel ) - m_avatarLabel->setPixmap( m_avatar ); - } -} - -void -LastFmService::updateEditHint( int index ) -{ - if( !m_customStationEdit ) - return; - QString hint; - switch ( index ) { - case 0: - hint = i18n( "Enter an artist name" ); - break; - case 1: - hint = i18n( "Enter a tag" ); - break; - case 2: - hint = i18n( "Enter a Last.fm user name" ); - break; - default: - return; - } - m_customStationEdit->setClickMessage( hint ); -} - -void -LastFmService::updateProfileInfo() -{ - if( m_userinfo ) - { - m_userinfo->setText( i18n( "Username: %1", Qt::escape( m_config->username() ) ) ); - } - - if( m_profile && !m_playcount.isEmpty() ) - { - m_profile->setText( i18np( "Play Count: %1 play", "Play Count: %1 plays", m_playcount.toInt() ) ); - } -} - -void -LastFmService::polish() -{ - if( !m_polished ) - { - LastFmTreeView* view = new LastFmTreeView( this ); - view->setFrameShape( QFrame::NoFrame ); - view->setDragEnabled ( true ); - view->setSortingEnabled( false ); - view->setDragDropMode ( QAbstractItemView::DragOnly ); - setView( view ); - - //m_bottomPanel->setMaximumHeight( 300 ); - m_bottomPanel->hide(); - - m_topPanel->setMaximumHeight( 300 ); - KHBox * outerProfilebox = new KHBox( m_topPanel ); - outerProfilebox->setSpacing(1); - outerProfilebox->setMargin(0); - - m_avatarLabel = new QLabel(outerProfilebox); - if( !m_avatar ) - { - int m = LastFmTreeModel::avatarSize(); - m_avatarLabel->setPixmap( KIcon( "filename-artist-amarok" ).pixmap(m, m) ); - m_avatarLabel->setFixedSize( m, m ); - } - else - { - m_avatarLabel->setPixmap( m_avatar ); - m_avatarLabel->setFixedSize( m_avatar.width(), m_avatar.height() ); - m_avatarLabel->setMargin( 5 ); - } - - KVBox * innerProfilebox = new KVBox( outerProfilebox ); - innerProfilebox->setSpacing(0); - innerProfilebox->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ); - m_userinfo = new QLabel(innerProfilebox); - m_userinfo->setText( m_config->username() ); - m_profile = new QLabel(innerProfilebox); - m_profile->setText(QString()); - updateProfileInfo(); - - - QGroupBox *customStation = new QGroupBox( i18n( "Create a Custom Last.fm Station" ), m_topPanel ); - m_customStationCombo = new QComboBox; - QStringList choices; - choices << i18n( "Artist" ) << i18n( "Tag" ) << i18n( "User" ); - m_customStationCombo->insertItems(0, choices); - m_customStationEdit = new KLineEdit; - m_customStationEdit->setClearButtonShown( true ); - updateEditHint( m_customStationCombo->currentIndex() ); - m_customStationButton = new QPushButton; - m_customStationButton->setObjectName( "customButton" ); - m_customStationButton->setIcon( KIcon( "media-playback-start-amarok" ) ); - QHBoxLayout *hbox = new QHBoxLayout(); - hbox->addWidget(m_customStationCombo); - hbox->addWidget(m_customStationEdit); - hbox->addWidget(m_customStationButton); - customStation->setLayout(hbox); - - connect( m_customStationEdit, SIGNAL(returnPressed()), this, SLOT(playCustomStation()) ); - connect( m_customStationButton, SIGNAL(clicked()), this, SLOT(playCustomStation()) ); - connect( m_customStationCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(updateEditHint(int))); - - QList levels; - levels << CategoryId::Genre << CategoryId::Album; - m_polished = true; - } -} - -void -LastFmService::love() -{ - love( The::engineController()->currentTrack() ); -} - -void -LastFmService::love( Meta::TrackPtr track ) -{ - if( m_scrobbler ) - m_scrobbler->loveTrack( track ); -} - -void LastFmService::playCustomStation() -{ - DEBUG_BLOCK - QString text = m_customStationEdit->text(); - QString station; - debug() << "Selected combo " <currentIndex(); - switch ( m_customStationCombo->currentIndex() ) { - case 0: - station = "lastfm://artist/" + text + "/similarartists"; - break; - case 1: - station = "lastfm://globaltags/" + text; - break; - case 2: - station = "lastfm://user/" + text + "/personal"; - break; - default: - return; - } - - if ( !station.isEmpty() ) { - playLastFmStation( station ); - } -} - -void LastFmService::playLastFmStation( const KUrl &url ) -{ - Meta::TrackPtr track = CollectionManager::instance()->trackForUrl( url ); - The::playlistController()->insertOptioned( track, Playlist::OnPlayMediaAction ); -} - -Collections::Collection * LastFmService::collection() -{ - return m_collection; -} diff --git a/amarok/src/services/lastfm/LastFmService.h b/amarok/src/services/lastfm/LastFmService.h deleted file mode 100644 index 89b8823d..00000000 --- a/amarok/src/services/lastfm/LastFmService.h +++ /dev/null @@ -1,109 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Shane King * - * Copyright (c) 2008 Leo Franchi * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef LASTFMSERVICE_H -#define LASTFMSERVICE_H - -#include "services/ServiceBase.h" -#include "services/lastfm/LastFmServiceConfig.h" -#include "statsyncing/Provider.h" - - -namespace Collections { - class LastFmServiceCollection; -} -namespace Dynamic { - class AbstractBiasFactory; -} -class ScrobblerAdapter; -class KLineEdit; -class QComboBox; -class QLabel; -class QNetworkReply; - -class LastFmServiceFactory : public ServiceFactory -{ - Q_OBJECT - -public: - LastFmServiceFactory( QObject *parent, const QVariantList &args ); - - virtual void init(); - virtual QString name(); - virtual KConfigGroup config(); - - virtual bool possiblyContainsTrack( const KUrl &url ) const; -}; - -class LastFmService : public ServiceBase -{ - Q_OBJECT - -public: - LastFmService( LastFmServiceFactory* parent, const QString &name ); - virtual ~LastFmService(); - - virtual void polish(); - - virtual Collections::Collection * collection(); - - void love( Meta::TrackPtr track ); - -private slots: - void love(); - - void playCustomStation(); - void updateEditHint( int index ); - - void slotReconfigure(); - void onAuthenticated(); - void onGetUserInfo(); - void onAvatarDownloaded( const QString& username, QPixmap avatar ); - -private: - void continueReconfiguring(); - void playLastFmStation( const KUrl &url ); - void updateProfileInfo(); - - QExplicitlySharedDataPointer m_scrobbler; - StatSyncing::ProviderPtr m_synchronizationAdapter; - Collections::LastFmServiceCollection *m_collection; - QList m_biasFactories; - - bool m_polished; - QWidget *m_profileBox; - QLabel *m_avatarLabel; - QLabel *m_profile; - QLabel *m_userinfo; - QComboBox *m_globalComboBox; - KLineEdit *m_customStationEdit; - QPushButton *m_customStationButton; - QComboBox *m_customStationCombo; - - QString m_station; - QString m_age; - QString m_gender; - QString m_country; - QString m_playcount; - QPixmap m_avatar; - bool m_subscriber; - - QNetworkReply *m_authenticateReply; - LastFmServiceConfigPtr m_config; -}; - -#endif // LASTFMSERVICE_H diff --git a/amarok/src/services/lastfm/LastFmServiceCollection.cpp b/amarok/src/services/lastfm/LastFmServiceCollection.cpp deleted file mode 100644 index 246a1037..00000000 --- a/amarok/src/services/lastfm/LastFmServiceCollection.cpp +++ /dev/null @@ -1,326 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Shane King * - * Copyright (c) 2008 Nikolaj Hald Nielsen * - * Copyright (c) 2008 Leo Franchi * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "lastfm" - -#include "LastFmServiceCollection.h" -#include "meta/LastFmMeta.h" - -#include - -using namespace Collections; - -LastFmServiceCollection::LastFmServiceCollection( const QString &userName ) - : ServiceCollection( 0, "last.fm", "last.fm" ) -{ - DEBUG_BLOCK - Meta::ServiceGenre * userStreams = new Meta::ServiceGenre( i18n( "%1's Streams", userName ) ); - Meta::GenrePtr userStreamsPtr( userStreams ); - addGenre( userStreamsPtr ); - - Meta::ServiceGenre * globalTags = new Meta::ServiceGenre( i18n( "Global Tags" ) ); - Meta::GenrePtr globalTagsPtr( globalTags ); - addGenre( globalTagsPtr ); - - m_neighborsLoved = new Meta::ServiceGenre( i18n( "Neighbors' Loved Radio" ) ); - Meta::GenrePtr neighborsLovedPtr( m_neighborsLoved ); - addGenre( neighborsLovedPtr ); - - m_neighborsPersonal = new Meta::ServiceGenre( i18n( "Neighbors' Personal Radio" ) ); - Meta::GenrePtr neighborsPersonalPtr( m_neighborsPersonal ); - addGenre( neighborsPersonalPtr ); - - m_friendsLoved = new Meta::ServiceGenre( i18n( "Friends' Loved Radio" ) ); - Meta::GenrePtr friendsLovedPtr( m_friendsLoved ); - addGenre( friendsLovedPtr ); - - m_friendsPersonal = new Meta::ServiceGenre( i18n( "Friends' Personal Radio" ) ); - Meta::GenrePtr friendsPersonalPtr( m_friendsPersonal ); - addGenre( friendsPersonalPtr ); - - // Only show these if the user is a subscriber. - QStringList lastfmPersonal; - lastfmPersonal << "personal" << "recommended" << "loved" << "neighbours"; - - foreach( const QString &station, lastfmPersonal ) - { - LastFm::Track * track = new LastFm::Track( "lastfm://user/" + userName + "/" + station ); - Meta::TrackPtr trackPtr( track ); - userStreams->addTrack( trackPtr ); - addTrack( trackPtr ); - } - - QStringList lastfmGenres; - lastfmGenres << "Alternative" << "Ambient" << "Chill Out" << "Classical"<< "Dance" - << "Electronica" << "Favorites" << "Gospel" << "Heavy Metal" << "Hip Hop" - << "Indie Rock" << "Industrial" << "Japanese" << "Pop" << "Psytrance" - << "Rap" << "Rock" << "Soundtrack" << "Techno" << "Trance"; - - - foreach( const QString &genre, lastfmGenres ) - { - LastFm::Track * track = new LastFm::Track( "lastfm://globaltags/" + genre ); - Meta::TrackPtr trackPtr( track ); - globalTags->addTrack( trackPtr ); - addTrack( trackPtr ); - } - - QMap< QString, QString > params; - params[ "method" ] = "user.getNeighbours"; - params[ "user" ] = userName; - m_jobs[ "user.getNeighbours" ] = lastfm::ws::post( params ); - - connect( m_jobs[ "user.getNeighbours" ], SIGNAL(finished()), this, SLOT(slotAddNeighboursLoved()) ); - //connect( m_jobs[ "user.getNeighbours" ], SIGNAL(finished()), this, SLOT(slotAddNeighboursPersonal()) ); - // TODO TMP HACK why do i get exceptions there...!? - - params[ "method" ] = "user.getFriends"; - m_jobs[ "user.getFriends" ] = lastfm::ws::post( params ); - - connect( m_jobs[ "user.getFriends" ], SIGNAL(finished()), this, SLOT(slotAddFriendsLoved()) ); - //connect( m_jobs[ "user.getFriends" ], SIGNAL(finished()), this, SLOT(slotAddFriendsPersonal()) ); - - //TODO Automatically add simmilar artist streams for the users favorite artists. -} - -LastFmServiceCollection::~LastFmServiceCollection() -{ - DEBUG_BLOCK -} - -bool -LastFmServiceCollection::possiblyContainsTrack( const KUrl &url ) const -{ - return url.protocol() == "lastfm"; -} - - -Meta::TrackPtr -LastFmServiceCollection::trackForUrl( const KUrl &url ) -{ - return Meta::TrackPtr( new LastFm::Track( url.url() ) ); -} - - -QString -LastFmServiceCollection::collectionId() const -{ - return QLatin1String( "last.fm" ); -} - - -QString -LastFmServiceCollection::prettyName() const -{ - return i18n( "Last.fm" ); -} - -void LastFmServiceCollection::slotAddNeighboursLoved() -{ - DEBUG_BLOCK - if( !m_jobs[ "user.getNeighbours" ] ) - { - debug() << "BAD! got no result object"; - return; - } - switch (m_jobs[ "user.getNeighbours" ]->error()) - { - case QNetworkReply::NoError: - { - // iterate through each neighbour - lastfm::XmlQuery lfm; - if( lfm.parse( m_jobs[ "user.getNeighbours" ]->readAll() ) ) - { - foreach( const lastfm::XmlQuery &e, lfm[ "neighbours" ].children( "user" ) ) - { - const QString name = e[ "name" ].text(); - //debug() << "got neighbour!!! - " << name; - LastFm::Track *track = new LastFm::Track( "lastfm://user/" + name + "/loved" ); - Meta::TrackPtr trackPtr( track ); - m_neighborsLoved->addTrack( trackPtr ); - addTrack( trackPtr ); - } - - } - else - { - debug() << "Got exception in parsing from last.fm:" << lfm.parseError().message(); - } - break; - } - - case QNetworkReply::AuthenticationRequiredError: - debug() << "Last.fm: errorMessage: Sorry, we don't recognise that username, or you typed the password incorrectly."; - break; - - default: - debug() << "Last.fm: errorMessage: There was a problem communicating with the Last.fm services. Please try again later."; - break; - } - - m_jobs[ "user.getNeighbours" ]->deleteLater(); -} - -void LastFmServiceCollection::slotAddNeighboursPersonal() -{ - DEBUG_BLOCK - switch (m_jobs[ "user.getNeighbours" ]->error()) - { - case QNetworkReply::NoError: - { - // iterate through each neighbour - if( !m_jobs[ "user.getNeighbours" ] ) - { - debug() << "BAD! got no result object"; - return; - } - lastfm::XmlQuery lfm; - if( lfm.parse( m_jobs[ "user.getNeighbours" ]->readAll() ) ) - { - // iterate through each neighbour - foreach( const lastfm::XmlQuery &e, lfm[ "neighbours" ].children( "user" ) ) - { - const QString name = e[ "name" ].text(); - debug() << "got neighbour!!! - " << name; - LastFm::Track *track = new LastFm::Track( "lastfm://user/" + name + "/personal" ); - Meta::TrackPtr trackPtr( track ); - m_neighborsPersonal->addTrack( trackPtr ); - addTrack( trackPtr ); - } - - - // should be safe, as both slots SHOULD get called before we return to the event loop... - m_jobs[ "user.getNeighbours" ]->deleteLater(); - } - else - { - debug() << "Got exception in parsing from last.fm:" << lfm.parseError().message(); - } - break; - } - - case QNetworkReply::AuthenticationRequiredError: - debug() << "Last.fm: errorMessage: Sorry, we don't recognise that username, or you typed the password incorrectly."; - break; - - default: - debug() << "Last.fm: errorMessage: There was a problem communicating with the Last.fm services. Please try again later."; - break; - } - -} - -void LastFmServiceCollection::slotAddFriendsLoved() -{ - DEBUG_BLOCK - if( !m_jobs[ "user.getFriends" ] ) - { - debug() << "BAD! got no result object"; - return; - } - switch (m_jobs[ "user.getFriends" ]->error()) - { - case QNetworkReply::NoError: - { - lastfm::XmlQuery lfm; - if( lfm.parse( m_jobs[ "user.getFriends" ]->readAll() ) ) - { - foreach( const lastfm::XmlQuery &e, lfm[ "friends" ].children( "user" ) ) - { - const QString name = e[ "name" ].text(); - LastFm::Track *track = new LastFm::Track( "lastfm://user/" + name + "/loved" ); - Meta::TrackPtr trackPtr( track ); - m_friendsLoved->addTrack( trackPtr ); - addTrack( trackPtr ); - } - - } - else - { - debug() << "Got exception in parsing from last.fm:" << lfm.parseError().message(); - } - break; - } - - case QNetworkReply::AuthenticationRequiredError: - debug() << "Last.fm: errorMessage: Sorry, we don't recognise that username, or you typed the password incorrectly."; - break; - - default: - debug() << "Last.fm: errorMessage: There was a problem communicating with the Last.fm services. Please try again later."; - break; - } - - m_jobs[ "user.getFriends" ]->deleteLater(); -} - -void LastFmServiceCollection::slotAddFriendsPersonal() -{ - DEBUG_BLOCK - if( !m_jobs[ "user.getFriends" ] ) - { - debug() << "BAD! got no result object"; - return; - } - - switch (m_jobs[ "user.getFriends" ]->error()) - { - case QNetworkReply::NoError: - { - lastfm::XmlQuery lfm; - if( lfm.parse( m_jobs[ "user.getFriends" ]->readAll() ) ) - { - foreach( const lastfm::XmlQuery &e, lfm[ "friends" ].children( "user" ) ) - { - const QString name = e[ "name" ].text(); - LastFm::Track *track = new LastFm::Track( "lastfm://user/" + name + "/personal" ); - Meta::TrackPtr trackPtr( track ); - m_friendsPersonal->addTrack( trackPtr ); - addTrack( trackPtr ); - } - - } - else - { - debug() << "Got exception in parsing from last.fm:" << lfm.parseError().message(); - } - break; - } - - case QNetworkReply::AuthenticationRequiredError: - debug() << "Last.fm: errorMessage: Sorry, we don't recognise that username, or you typed the password incorrectly."; - break; - - default: - debug() << "Last.fm: errorMessage: There was a problem communicating with the Last.fm services. Please try again later."; - break; - } - - m_jobs[ "user.getFriends" ]->deleteLater(); -} - -QueryMaker* -LastFmServiceCollection::queryMaker() -{ - // TODO - //return new LastFmServiceQueryMaker( this ); - return ServiceCollection::queryMaker(); -} - -#include "moc_LastFmServiceCollection.cpp" - diff --git a/amarok/src/services/lastfm/LastFmServiceCollection.h b/amarok/src/services/lastfm/LastFmServiceCollection.h deleted file mode 100644 index 68a6d1ee..00000000 --- a/amarok/src/services/lastfm/LastFmServiceCollection.h +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Shane King * - * Copyright (c) 2008 Leo Franchi * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef LASTFMSERVICECOLLECTION_H -#define LASTFMSERVICECOLLECTION_H - -#include "services/ServiceCollection.h" - -class QNetworkReply; - -namespace Meta -{ - class ServiceGenre; -} - -namespace Collections { - -class LastFmServiceCollection : public ServiceCollection -{ - Q_OBJECT -public: - LastFmServiceCollection( const QString &userName ); - virtual ~LastFmServiceCollection(); - - virtual bool possiblyContainsTrack( const KUrl &url ) const; - virtual Meta::TrackPtr trackForUrl( const KUrl &url ); - - virtual QString collectionId() const; - virtual QString prettyName() const; - - virtual QueryMaker* queryMaker(); - -private slots: - void slotAddNeighboursLoved(); - void slotAddNeighboursPersonal(); - void slotAddFriendsLoved(); - void slotAddFriendsPersonal(); - -private: - QMap< QString, QNetworkReply* > m_jobs; - Meta::ServiceGenre *m_neighborsLoved; - Meta::ServiceGenre *m_neighborsPersonal; - Meta::ServiceGenre *m_friendsLoved; - Meta::ServiceGenre *m_friendsPersonal; -}; - -} //namespace Collections - -#endif // LASTFMSERVICECOLLECTION_H diff --git a/amarok/src/services/lastfm/LastFmServiceConfig.cpp b/amarok/src/services/lastfm/LastFmServiceConfig.cpp deleted file mode 100644 index 9912b223..00000000 --- a/amarok/src/services/lastfm/LastFmServiceConfig.cpp +++ /dev/null @@ -1,285 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Shane King * - * Copyright (c) 2009 Leo Franchi * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "lastfm" - -#include "LastFmServiceConfig.h" - -#include "App.h" -#include "core/support/Components.h" -#include "core/support/Debug.h" - -#include -#include - -#include -#include - -QWeakPointer LastFmServiceConfig::s_instance; - -LastFmServiceConfigPtr -LastFmServiceConfig::instance() -{ - Q_ASSERT( QThread::currentThread() == QCoreApplication::instance()->thread() ); - - LastFmServiceConfigPtr strongRef = s_instance.toStrongRef(); - if( strongRef ) - return strongRef; - - LastFmServiceConfigPtr newStrongRef( new LastFmServiceConfig() ); - s_instance = newStrongRef; - return newStrongRef; -} - -LastFmServiceConfig::LastFmServiceConfig() - : m_askDiag( 0 ) - , m_wallet( 0 ) -{ - DEBUG_BLOCK - - KConfigGroup config = KGlobal::config()->group( configSectionName() ); - m_sessionKey = config.readEntry( "sessionKey", QString() ); - m_scrobble = config.readEntry( "scrobble", defaultScrobble() ); - m_fetchSimilar = config.readEntry( "fetchSimilar", defaultFetchSimilar() ); - m_scrobbleComposer = config.readEntry( "scrobbleComposer", defaultScrobbleComposer() ); - m_useFancyRatingTags = config.readEntry( "useFancyRatingTags", defaultUseFancyRatingTags() ); - m_announceCorrections = config.readEntry( "announceCorrections", defaultAnnounceCorrections() ); - m_filterByLabel = config.readEntry( "filterByLabel", defaultFilterByLabel() ); - m_filteredLabel = config.readEntry( "filteredLabel", defaultFilteredLabel() ); - - if( config.hasKey( "kWalletUsage" ) ) - m_kWalletUsage = KWalletUsage( config.readEntry( "kWalletUsage", int( NoPasswordEnteredYet ) ) ); - else - { - // migrate from the old config that used "ignoreWallet" key set to yes/no - if( config.readEntry( "ignoreWallet", "" ) == "yes" ) - m_kWalletUsage = PasswordInAscii; - else if( config.hasKey( "scrobble" ) ) - // assume password was saved in KWallet if the config was once written - m_kWalletUsage = PasswodInKWallet; - else - m_kWalletUsage = NoPasswordEnteredYet; // config not yet saved, assume unused - } - - switch( m_kWalletUsage ) - { - case NoPasswordEnteredYet: - break; - case PasswodInKWallet: - openWalletToRead(); - break; - case PasswordInAscii: - m_username = config.readEntry( "username", QString() ); - m_password = config.readEntry( "password", QString() ); - break; - } -} - -LastFmServiceConfig::~LastFmServiceConfig() -{ - DEBUG_BLOCK - - if( m_askDiag ) - m_askDiag->deleteLater(); - if( m_wallet ) - m_wallet->deleteLater(); -} - -void LastFmServiceConfig::save() -{ - KConfigGroup config = KGlobal::config()->group( configSectionName() ); - - // if username and password is empty, reset to NoPasswordEnteredYet; this enables - // going from PasswordInAscii to PasswodInKWallet - if( m_username.isEmpty() && m_password.isEmpty() ) - { - m_kWalletUsage = NoPasswordEnteredYet; - config.deleteEntry( "username" ); // prevent possible stray credentials - config.deleteEntry( "password" ); - } - - config.writeEntry( "sessionKey", m_sessionKey ); - config.writeEntry( "scrobble", m_scrobble ); - config.writeEntry( "fetchSimilar", m_fetchSimilar ); - config.writeEntry( "scrobbleComposer", m_scrobbleComposer ); - config.writeEntry( "useFancyRatingTags", m_useFancyRatingTags ); - config.writeEntry( "announceCorrections", m_announceCorrections ); - config.writeEntry( "kWalletUsage", int( m_kWalletUsage ) ); - config.writeEntry( "filterByLabel", m_filterByLabel ); - config.writeEntry( "filteredLabel", m_filteredLabel ); - config.deleteEntry( "ignoreWallet" ); // remove old settings - - switch( m_kWalletUsage ) - { - case NoPasswordEnteredYet: - if( m_username.isEmpty() && m_password.isEmpty() ) - break; // stay in this state - // otherwise - case PasswodInKWallet: - openWalletToWrite(); - config.deleteEntry( "username" ); // prevent possible stray credentials - config.deleteEntry( "password" ); - break; - case PasswordInAscii: - config.writeEntry( "username", m_username ); - config.writeEntry( "password", m_password ); - break; - } - - config.sync(); - emit updated(); -} - -void -LastFmServiceConfig::openWalletToRead() -{ - if( m_wallet && m_wallet->isOpen() ) - { - slotWalletOpenedToRead( true ); - return; - } - - if( m_wallet ) - disconnect( m_wallet, 0, this, 0 ); - else - { - openWalletAsync(); - if( !m_wallet ) // can happen, see bug 322964 - { - slotWalletOpenedToRead( false ); - return; - } - } - connect( m_wallet, SIGNAL(walletOpened(bool)), SLOT(slotWalletOpenedToRead(bool)) ); -} - -void -LastFmServiceConfig::openWalletToWrite() -{ - if( m_wallet && m_wallet->isOpen() ) - { - slotWalletOpenedToWrite( true ); - return; - } - - if( m_wallet ) - disconnect( m_wallet, 0, this, 0 ); - else - { - openWalletAsync(); - if( !m_wallet ) // can happen, see bug 322964 - { - slotWalletOpenedToWrite( false ); - return; - } - } - connect( m_wallet, SIGNAL(walletOpened(bool)), SLOT(slotWalletOpenedToWrite(bool)) ); -} - -void -LastFmServiceConfig::openWalletAsync() -{ - Q_ASSERT( !m_wallet ); - using namespace KWallet; - m_wallet = Wallet::openWallet( Wallet::NetworkWallet(), 0, Wallet::Asynchronous ); -} - -void -LastFmServiceConfig::prepareOpenedWallet() -{ - if( !m_wallet->hasFolder( "Amarok" ) ) - m_wallet->createFolder( "Amarok" ); - m_wallet->setFolder( "Amarok" ); -} - -void -LastFmServiceConfig::slotWalletOpenedToRead( bool success ) -{ - if( !success ) - { - warning() << __PRETTY_FUNCTION__ << "failed to open wallet"; - QString message = i18n( "Failed to open KDE Wallet to read Last.fm credentials" ); - Amarok::Components::logger()->longMessage( message, Amarok::Logger::Warning ); - if( m_wallet ) - m_wallet->deleteLater(); // no point in having invalid wallet around - m_wallet = 0; - return; - } - - Q_ASSERT( m_wallet ); - prepareOpenedWallet(); - - if( m_wallet->readPassword( "lastfm_password", m_password ) > 0 ) - warning() << "Failed to read lastfm password from kwallet"; - QByteArray rawUsername; - if( m_wallet->readEntry( "lastfm_username", rawUsername ) > 0 ) - warning() << "Failed to read last.fm username from kwallet"; - else - m_username = QString::fromUtf8( rawUsername ); - emit updated(); -} - -void -LastFmServiceConfig::slotWalletOpenedToWrite( bool success ) -{ - if( !success ) - { - askAboutMissingKWallet(); - if( m_wallet ) - m_wallet->deleteLater(); // no point in having invalid wallet around - m_wallet = 0; - return; - } - - Q_ASSERT( m_wallet ); - prepareOpenedWallet(); - - if( m_wallet->writePassword( "lastfm_password", m_password ) > 0 ) - warning() << "Failed to save last.fm password to kwallet"; - if( m_wallet->writeEntry( "lastfm_username", m_username.toUtf8() ) > 0 ) - warning() << "Failed to save last.fm username to kwallet"; - - m_kWalletUsage = PasswodInKWallet; - KConfigGroup config = KGlobal::config()->group( configSectionName() ); - config.writeEntry( "kWalletUsage", int( m_kWalletUsage ) ); - config.sync(); -} - -void -LastFmServiceConfig::askAboutMissingKWallet() -{ - if ( !m_askDiag ) - { - m_askDiag = new KDialog( 0 ); - m_askDiag->setCaption( i18n( "Last.fm credentials" ) ); - m_askDiag->setMainWidget( new QLabel( i18n( "No running KWallet found. Would you like Amarok to save your Last.fm credentials in plaintext?" ) ) ); - m_askDiag->setButtons( KDialog::Yes | KDialog::No ); - - connect( m_askDiag, SIGNAL(yesClicked()), this, SLOT(slotStoreCredentialsInAscii()) ); - // maybe connect SIGNAL(noClicked()) to a message informing the user the password will - // be forgotten on Amarok restart - } - m_askDiag->show(); -} - -void -LastFmServiceConfig::slotStoreCredentialsInAscii() //SLOT -{ - DEBUG_BLOCK - m_kWalletUsage = PasswordInAscii; - save(); -} diff --git a/amarok/src/services/lastfm/LastFmServiceConfig.h b/amarok/src/services/lastfm/LastFmServiceConfig.h deleted file mode 100644 index 4b1552e9..00000000 --- a/amarok/src/services/lastfm/LastFmServiceConfig.h +++ /dev/null @@ -1,143 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Shane King * - * Copyright (c) 2009 Leo Franchi * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef LASTFMSERVICECONFIG_H -#define LASTFMSERVICECONFIG_H - -#include "services/lastfm/amarok_lastfm_shared_export.h" - -#include -#include -#include - -namespace KWallet { - class Wallet; -} -class KDialog; -class LastFmServiceConfig; -typedef QSharedPointer LastFmServiceConfigPtr; - -/** - * Configuration of the Last.fm plugin. Because some operations are async, you should - * connect to the updated() signal and listen to changes, especially ones to username, - * password or sessionKey. - */ -class AMAROK_LASTFM_SHARED_EXPORT LastFmServiceConfig : public QObject -{ - Q_OBJECT -public: - static const char *configSectionName() { return "Service_LastFm"; } - - /** - * Singleton pattern accessor. Not thread safe - must be called from the main - * thread. - */ - static LastFmServiceConfigPtr instance(); - - ~LastFmServiceConfig(); - - /** - * Saves the configuration back to the storage and notifies other users about - * the change. This method must be called after calling any of the set* methods. - */ - void save(); - - QString username() const { return m_username; } - void setUsername( const QString &username ) { m_username = username; } - - QString password() const { return m_password; } - void setPassword( const QString &password ) { m_password = password; } - - QString sessionKey() const { return m_sessionKey; } - void setSessionKey( const QString &sessionKey ) { m_sessionKey = sessionKey; } - - bool scrobble() const { return m_scrobble; } - static bool defaultScrobble() { return true; } - void setScrobble( bool scrobble ) { m_scrobble = scrobble; } - - bool fetchSimilar() const { return m_fetchSimilar; } - static bool defaultFetchSimilar() { return true; } - void setFetchSimilar( bool fetchSimilar ) { m_fetchSimilar = fetchSimilar; } - - bool scrobbleComposer() const { return m_scrobbleComposer; } - static bool defaultScrobbleComposer() { return false; } - void setScrobbleComposer( bool scrobbleComposer ) { m_scrobbleComposer = scrobbleComposer; } - - bool useFancyRatingTags() const { return m_useFancyRatingTags; } - static bool defaultUseFancyRatingTags() { return true; } - void setUseFancyRatingTags( bool useFancyRatingTags ) { m_useFancyRatingTags = useFancyRatingTags; } - - bool announceCorrections() const { return m_announceCorrections; } - static bool defaultAnnounceCorrections() { return true; } - void setAnnounceCorrections( bool announceCorrections ) { m_announceCorrections = announceCorrections; } - - bool filterByLabel() const { return m_filterByLabel; } - static bool defaultFilterByLabel() { return false; } - void setFilterByLabel( bool filterByLabel ) { m_filterByLabel = filterByLabel; } - - QString filteredLabel() const { return m_filteredLabel; } - static QString defaultFilteredLabel() { return QString(); } - void setFilteredLabel( const QString &filteredLabel ) { m_filteredLabel = filteredLabel; } - -signals: - /** - * Emitted when settings are changed. (after save() is called) - */ - void updated(); - -private slots: - void slotWalletOpenedToRead( bool success ); - void slotWalletOpenedToWrite( bool success ); - - void slotStoreCredentialsInAscii(); - -private: - Q_DISABLE_COPY( LastFmServiceConfig ) - LastFmServiceConfig(); - - void openWalletToRead(); - void openWalletToWrite(); - void openWalletAsync(); - void prepareOpenedWallet(); - void askAboutMissingKWallet(); - - // don't remove or reorder entires, would break saved config - enum KWalletUsage { - NoPasswordEnteredYet, - PasswodInKWallet, - PasswordInAscii - }; - - QString m_username; - QString m_password; - QString m_sessionKey; - bool m_scrobble; - bool m_fetchSimilar; - bool m_scrobbleComposer; - bool m_useFancyRatingTags; - bool m_announceCorrections; - bool m_filterByLabel; - QString m_filteredLabel; - KWalletUsage m_kWalletUsage; - - KDialog* m_askDiag; - KWallet::Wallet* m_wallet; - - static QWeakPointer s_instance; -}; - -#endif // LASTFMSERVICECONFIG_H diff --git a/amarok/src/services/lastfm/LastFmServiceSettings.cpp b/amarok/src/services/lastfm/LastFmServiceSettings.cpp deleted file mode 100644 index 2bbebbe9..00000000 --- a/amarok/src/services/lastfm/LastFmServiceSettings.cpp +++ /dev/null @@ -1,259 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Shane King * - * Copyright (c) 2013 Vedant Agarwala * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "LastFmServiceSettings" - -#include "LastFmServiceSettings.h" - -#include "core/collections/QueryMaker.h" -#include "core/meta/Meta.h" -#include "core/support/Amarok.h" -#include "core/support/Debug.h" -#include "core-impl/collections/support/CollectionManager.h" -#include "network/NetworkAccessManagerProxy.h" -#include "ui_LastFmConfigWidget.h" - -#include -#include -#include - -#include -#include - -#include - -K_PLUGIN_FACTORY( LastFmServiceSettingsFactory, registerPlugin(); ) -K_EXPORT_PLUGIN( LastFmServiceSettingsFactory( "kcm_amarok_lastfm" ) ) - -QString md5( const QByteArray& src ) -{ - QByteArray const digest = QCryptographicHash::hash( src, QCryptographicHash::Md5 ); - return QString::fromLatin1( digest.toHex() ).rightJustified( 32, '0' ); -} - - -LastFmServiceSettings::LastFmServiceSettings( QWidget *parent, const QVariantList &args ) - : KCModule( LastFmServiceSettingsFactory::componentData(), parent, args ) - , m_config( LastFmServiceConfig::instance() ) -{ - m_configDialog = new Ui::LastFmConfigWidget; - m_configDialog->setupUi( this ); - - connect( m_config.data(), SIGNAL(updated()), SLOT(onConfigUpdated()) ); - - connect( m_configDialog->kcfg_ScrobblerUsername, SIGNAL(textChanged(QString)), this, SLOT(settingsChanged()) ); - connect( m_configDialog->kcfg_ScrobblerPassword, SIGNAL(textChanged(QString)), this, SLOT(settingsChanged()) ); - connect( m_configDialog->kcfg_SubmitPlayedSongs, SIGNAL(stateChanged(int)), this, SLOT(settingsChanged()) ); - connect( m_configDialog->kcfg_RetrieveSimilarArtists, SIGNAL(stateChanged(int)), this, SLOT(settingsChanged()) ); - connect( m_configDialog->kcfg_ScrobbleComposer, SIGNAL(stateChanged(int)), this, SLOT(settingsChanged())); - connect( m_configDialog->kcfg_UseFancyRatingTags, SIGNAL(stateChanged(int)), this, SLOT(settingsChanged())); - connect( m_configDialog->kcfg_AnnounceCorrections, SIGNAL(stateChanged(int)), this, SLOT(settingsChanged()) ); - connect( m_configDialog->kcfg_FilterByLabel, SIGNAL(stateChanged(int)), this, SLOT(settingsChanged()) ); - connect( m_configDialog->kcfg_FilteredLabel, SIGNAL(currentIndexChanged(QString)), this, SLOT(settingsChanged()) ); - connect( m_configDialog->testLogin, SIGNAL(clicked()), this, SLOT(testLogin()) ); - - using namespace Collections; - - QueryMaker *query = CollectionManager::instance()->queryMaker(); - query->setQueryType( QueryMaker::Label ); - connect( query, SIGNAL(newResultReady(Meta::LabelList)), this, SLOT(addNewLabels(Meta::LabelList)) ); - query->setAutoDelete( true ); - query->run(); -} - -LastFmServiceSettings::~LastFmServiceSettings() -{ - delete m_configDialog; -} - -void -LastFmServiceSettings::save() -{ - QString dialogUser = m_configDialog->kcfg_ScrobblerUsername->text(); - QString dialogPass = m_configDialog->kcfg_ScrobblerPassword->text(); - - // clear the session key if credentials changed - if( m_config->username() != dialogUser || m_config->password() != dialogPass ) - m_config->setSessionKey( QString() ); - - m_config->setUsername( dialogUser ); - m_config->setPassword( dialogPass ); - m_config->setScrobble( m_configDialog->kcfg_SubmitPlayedSongs->isChecked() ); - m_config->setFetchSimilar( m_configDialog->kcfg_RetrieveSimilarArtists->isChecked() ); - m_config->setScrobbleComposer( m_configDialog->kcfg_ScrobbleComposer->isChecked() ); - m_config->setUseFancyRatingTags( m_configDialog->kcfg_UseFancyRatingTags->isChecked() ); - m_config->setAnnounceCorrections( m_configDialog->kcfg_AnnounceCorrections->isChecked() ); - m_config->setFilterByLabel( m_configDialog->kcfg_FilterByLabel->isChecked() ); - m_config->setFilteredLabel( m_configDialog->kcfg_FilteredLabel->currentText() ); - m_config->save(); - - KCModule::save(); -} - -void -LastFmServiceSettings::testLogin() -{ - m_configDialog->testLogin->setEnabled( false ); - m_configDialog->testLogin->setText( i18n( "Testing..." ) ); - // set the global static Lastfm::Ws stuff - lastfm::ws::ApiKey = Amarok::lastfmApiKey(); - lastfm::ws::SharedSecret = Amarok::lastfmApiSharedSecret(); - lastfm::ws::Username = m_configDialog->kcfg_ScrobblerUsername->text(); - if( lastfm::nam() != The::networkAccessManager() ) - lastfm::setNetworkAccessManager( The::networkAccessManager() ); - - debug() << "username:" << QString( QUrl::toPercentEncoding( lastfm::ws::Username ) ); - - const QString authToken = md5( QString( "%1%2" ).arg( m_configDialog->kcfg_ScrobblerUsername->text() ) - .arg( md5( m_configDialog->kcfg_ScrobblerPassword->text().toUtf8() ) ).toUtf8() ); - - // now authenticate w/ last.fm and get our session key - QMap query; - query[ "method" ] = "auth.getMobileSession"; - query[ "username" ] = m_configDialog->kcfg_ScrobblerUsername->text(); - query[ "authToken" ] = authToken; - m_authQuery = lastfm::ws::post( query ); - - connect( m_authQuery, SIGNAL(finished()), SLOT(onAuthenticated()) ); - connect( m_authQuery, SIGNAL(error(QNetworkReply::NetworkError)), SLOT(onError(QNetworkReply::NetworkError)) ); -} - -void -LastFmServiceSettings::onAuthenticated() -{ - lastfm::XmlQuery lfm; - lfm.parse( m_authQuery->readAll() ); - - switch( m_authQuery->error() ) - { - case QNetworkReply::NoError: - debug() << "NoError"; - if( lfm.children( "error" ).size() > 0 ) - { - debug() << "ERROR from last.fm:" << lfm.text(); - m_configDialog->testLogin->setText( i18nc( "The operation was rejected by the server", "Failed" ) ); - m_configDialog->testLogin->setEnabled( true ); - - } else - { - m_configDialog->testLogin->setText( i18nc( "The operation completed as expected", "Success" ) ); - m_configDialog->testLogin->setEnabled( false ); - m_configDialog->kcfg_SubmitPlayedSongs->setEnabled( true ); - } - break; - - case QNetworkReply::AuthenticationRequiredError: - debug() << "AuthenticationFailed"; - KMessageBox::error( this, i18n( "Either the username or the password is incorrect, please correct and try again" ), i18n( "Failed" ) ); - m_configDialog->testLogin->setText( i18n( "Test Login" ) ); - m_configDialog->testLogin->setEnabled( true ); - break; - - default: - debug() << "Unhandled QNetworkReply state, probably not important"; - } - m_authQuery->deleteLater(); -} - -void -LastFmServiceSettings::onError( QNetworkReply::NetworkError code ) -{ - if( code == QNetworkReply::NoError ) - return; - - if( code == QNetworkReply::AuthenticationRequiredError ) - { - onAuthenticated(); - return; - } - - KMessageBox::error( this, i18n( "Unable to connect to Last.fm service." ), i18n( "Failed" ) ); - m_configDialog->testLogin->setText( i18n( "Test Login" ) ); - m_configDialog->testLogin->setEnabled( true ); - - debug() << "Error occurred during network request: " << m_authQuery->errorString(); - m_authQuery->deleteLater(); -} - -void -LastFmServiceSettings::onConfigUpdated() -{ - load(); -} - -void -LastFmServiceSettings::load() -{ - m_configDialog->kcfg_ScrobblerUsername->setText( m_config->username() ); - m_configDialog->kcfg_ScrobblerPassword->setText( m_config->password() ); - m_configDialog->kcfg_SubmitPlayedSongs->setChecked( m_config->scrobble() ); - m_configDialog->kcfg_RetrieveSimilarArtists->setChecked( m_config->fetchSimilar() ); - m_configDialog->kcfg_ScrobbleComposer->setChecked( m_config->scrobbleComposer() ); - m_configDialog->kcfg_UseFancyRatingTags->setChecked( m_config->useFancyRatingTags() ); - m_configDialog->kcfg_AnnounceCorrections->setChecked( m_config->announceCorrections() ); - m_configDialog->kcfg_FilterByLabel->setChecked( m_config->filterByLabel() ); - m_configDialog->kcfg_FilteredLabel->setCurrentIndex( filteredLabelComboIndex( m_config->filteredLabel() ) ); - - if( !m_config->username().isEmpty() && !m_config->password().isEmpty() ) - m_configDialog->kcfg_SubmitPlayedSongs->setEnabled( true ); - - KCModule::load(); -} - -void -LastFmServiceSettings::defaults() -{ - m_configDialog->kcfg_SubmitPlayedSongs->setChecked( m_config->defaultScrobble() ); - m_configDialog->kcfg_RetrieveSimilarArtists->setChecked( m_config->defaultFetchSimilar() ); - m_configDialog->kcfg_ScrobbleComposer->setChecked( m_config->defaultScrobbleComposer() ); - m_configDialog->kcfg_UseFancyRatingTags->setChecked( m_config->defaultUseFancyRatingTags() ); - m_configDialog->kcfg_AnnounceCorrections->setChecked( m_config->defaultAnnounceCorrections() ); - m_configDialog->kcfg_FilterByLabel->setChecked( m_config->defaultFilterByLabel() ); - m_configDialog->kcfg_FilteredLabel->setCurrentIndex( filteredLabelComboIndex( m_config->defaultFilteredLabel() ) ); -} - -void -LastFmServiceSettings::settingsChanged() -{ - //TODO: Make pretty validation for username and password - //with error reporting - - m_configDialog->testLogin->setText( i18n( "&Test Login" ) ); - m_configDialog->testLogin->setEnabled( true ); - - emit changed( true ); -} - -void -LastFmServiceSettings::addNewLabels( const Meta::LabelList &labels ) -{ - foreach( const Meta::LabelPtr &label , labels ) - m_configDialog->kcfg_FilteredLabel->addItem( label->name() ); -} - -int -LastFmServiceSettings::filteredLabelComboIndex( const QString &label ) -{ - int index = m_configDialog->kcfg_FilteredLabel->findText( label ); - if( index == -1) - { - m_configDialog->kcfg_FilteredLabel->addItem( label ); - return m_configDialog->kcfg_FilteredLabel->findText( label ); - } - else - return index; -} diff --git a/amarok/src/services/lastfm/LastFmServiceSettings.h b/amarok/src/services/lastfm/LastFmServiceSettings.h deleted file mode 100644 index 82b9b006..00000000 --- a/amarok/src/services/lastfm/LastFmServiceSettings.h +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Shane King * - * Copyright (c) 2013 Vedant Agarwala * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef LASTFMSERVICESETTINGS_H -#define LASTFMSERVICESETTINGS_H - -#include "LastFmServiceConfig.h" -#include "core/meta/forward_declarations.h" // for using the Meta::LabelList - -#include - -#include - -namespace Ui { class LastFmConfigWidget; } - -class LastFmServiceSettings : public KCModule -{ - Q_OBJECT - -public: - explicit LastFmServiceSettings( QWidget *parent = 0, const QVariantList &args = QVariantList() ); - - virtual ~LastFmServiceSettings(); - - virtual void save(); - virtual void load(); - virtual void defaults(); - -private slots: - void testLogin(); - void onAuthenticated(); - void onError( QNetworkReply::NetworkError code ); - void onConfigUpdated(); - -private: - /** - * gets the index of the @param label in the QComboBox - * If the label doesn't exist in the list, its added and then the index is returned - */ - int filteredLabelComboIndex( const QString &label ); - - Ui::LastFmConfigWidget *m_configDialog; - LastFmServiceConfigPtr m_config; - - QNetworkReply* m_authQuery; - -private slots: - void settingsChanged(); - void addNewLabels( const Meta::LabelList &labels ); -}; - -#endif // LASTFMSERVICESETTINGS_H diff --git a/amarok/src/services/lastfm/LastFmTreeModel.cpp b/amarok/src/services/lastfm/LastFmTreeModel.cpp deleted file mode 100644 index 620e9729..00000000 --- a/amarok/src/services/lastfm/LastFmTreeModel.cpp +++ /dev/null @@ -1,711 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Casey Link * - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * Copyright (c) 2009 Mark Kretschmann * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "LastFmTreeModel" -#include "core/support/Debug.h" - -#include "LastFmTreeModel.h" - -#include "AvatarDownloader.h" -#include "core-impl/collections/support/CollectionManager.h" -#include "AmarokMimeData.h" - -#include - -#include - -#include -#include - -using namespace LastFm; - -LastFmTreeModel::LastFmTreeModel( QObject *parent ) - : QAbstractItemModel( parent ) -{ - m_rootItem = new LastFmTreeItem( LastFm::Root, "Hello" ); - setupModelData( m_rootItem ); - - QNetworkReply *reply; - reply = m_user.getNeighbours(); - connect(reply, SIGNAL(finished()), this, SLOT(slotAddNeighbors()) ); - - reply = m_user.getFriends(); - connect( reply, SIGNAL(finished()), this, SLOT(slotAddFriends()) ); - - reply = m_user.getTopTags(); - connect( reply, SIGNAL(finished()), this, SLOT(slotAddTags()) ); - - reply = m_user.getTopArtists(); - connect( reply, SIGNAL(finished()), this, SLOT(slotAddTopArtists()) ); -} - -LastFmTreeModel::~LastFmTreeModel() -{ - delete m_rootItem; -} - -void -LastFmTreeModel::slotAddNeighbors() -{ - QNetworkReply *reply = qobject_cast( sender() ); - if( !reply ) - { - debug() << __PRETTY_FUNCTION__ << "null reply!"; - return; - } - reply->deleteLater(); - - lastfm::XmlQuery lfm; - if( lfm.parse( reply->readAll() ) ) - { - QList children = lfm[ "neighbours" ].children( "user" ); - int start = m_myNeighbors->childCount(); - QModelIndex parent = index( m_myNeighbors->row(), 0 ); - beginInsertRows( parent, start, start + children.size() ); - - foreach( const lastfm::XmlQuery &e, children ) - { - const QString name = e[ "name" ].text(); - - LastFmTreeItem* neighbor = new LastFmTreeItem( mapTypeToUrl(LastFm::NeighborsChild, name), - LastFm::NeighborsChild, name, m_myNeighbors ); - KUrl avatarUrl( e[ QLatin1String("image size=small") ].text() ); - if( !avatarUrl.isEmpty() ) - neighbor->setAvatarUrl( avatarUrl ); - - m_myNeighbors->appendChild( neighbor ); - appendUserStations( neighbor, name ); - } - - endInsertRows(); - emit dataChanged( parent, parent ); - } - else - { - debug() << "Got exception in parsing from last.fm:" << lfm.parseError().message(); - return; - } -} - -void -LastFmTreeModel::slotAddFriends() -{ - QNetworkReply *reply = qobject_cast( sender() ); - if( !reply ) - { - debug() << __PRETTY_FUNCTION__ << "null reply!"; - return; - } - reply->deleteLater(); - - lastfm::XmlQuery lfm; - if( lfm.parse( reply->readAll() ) ) - { - QList children = lfm[ "friends" ].children( "user" ); - int start = m_myFriends->childCount(); - QModelIndex parent = index( m_myFriends->row(), 0 ); - beginInsertRows( parent, start, start + children.size() ); - - foreach( const lastfm::XmlQuery &e, children ) - { - const QString name = e[ "name" ].text(); - - LastFmTreeItem* afriend = new LastFmTreeItem( mapTypeToUrl(LastFm::FriendsChild, name), - LastFm::FriendsChild, name, m_myFriends ); - - KUrl avatarUrl( e[ QLatin1String("image size=small") ].text() ); - if( !avatarUrl.isEmpty() ) - afriend->setAvatarUrl( avatarUrl ); - - m_myFriends->appendChild( afriend ); - appendUserStations( afriend, name ); - } - - endInsertRows(); - emit dataChanged( parent, parent ); - } - else - { - debug() << "Got exception in parsing from last.fm:" << lfm.parseError().message(); - return; - } -} - -void -LastFmTreeModel::slotAddTags() -{ - QNetworkReply *reply = qobject_cast( sender() ); - if( !reply ) - { - debug() << __PRETTY_FUNCTION__ << "null reply!"; - return; - } - reply->deleteLater(); - - QMap listWithWeights = lastfm::Tag::list( reply ); - int start = m_myTags->childCount(); - QModelIndex parent = index( m_myTags->row(), 0 ); - beginInsertRows( parent, start, start + listWithWeights.size() ); - - QMapIterator it( listWithWeights ); - it.toBack(); - while( it.hasPrevious() ) - { - it.previous(); - int count = it.key(); - QString text = it.value(); - QString prettyText = i18nc( "%1 is Last.fm tag name, %2 is its usage count", - "%1 (%2)", text, count ); - - LastFmTreeItem *tag = new LastFmTreeItem( mapTypeToUrl( LastFm::MyTagsChild, text ), - LastFm::MyTagsChild, prettyText, m_myTags ); - m_myTags->appendChild( tag ); - } - - endInsertRows(); - emit dataChanged( parent, parent ); -} - -void -LastFmTreeModel::slotAddTopArtists() -{ - QNetworkReply *reply = qobject_cast( sender() ); - if( !reply ) - { - debug() << __PRETTY_FUNCTION__ << "null reply!"; - return; - } - reply->deleteLater(); - - QMultiMap playcountArtists; - lastfm::XmlQuery lfm; - if( lfm.parse( reply->readAll() ) ) - { - foreach( const lastfm::XmlQuery &e, lfm[ "topartists" ].children( "artist" ) ) - { - QString name = e[ "name" ].text(); - int playcount = e[ "playcount" ].text().toInt(); - playcountArtists.insert( playcount, name ); - } - } - else - { - debug() << "Got exception in parsing from last.fm:" << lfm.parseError().message(); - return; - } - - int start = m_myTopArtists->childCount(); - QModelIndex parent = index( m_myTopArtists->row(), 0 ); - beginInsertRows( parent, start, start + playcountArtists.size() ); - - QMapIterator it( playcountArtists ); - it.toBack(); - while( it.hasPrevious() ) - { - it.previous(); - int count = it.key(); - QString text = it.value(); - QString prettyText = i18ncp( "%2 is artist name, %1 is number of plays", - "%2 (%1 play)", "%2 (%1 plays)", count, text ); - - LastFmTreeItem *artist = new LastFmTreeItem( mapTypeToUrl( LastFm::ArtistsChild, text ), - LastFm::ArtistsChild, prettyText, m_myTopArtists ); - m_myTopArtists->appendChild( artist ); - } - - endInsertRows(); - emit dataChanged( parent, parent ); -} - -void -LastFmTreeModel::appendUserStations( LastFmTreeItem* item, const QString &user ) -{ - // no need to call begin/endInsertRows() or dataChanged(), we're being called inside - // beginInsertRows(). - LastFmTreeItem* personal = new LastFmTreeItem( mapTypeToUrl( LastFm::UserChildPersonal, user ), - LastFm::UserChildPersonal, i18n( "Personal Radio" ), item ); - LastFmTreeItem* neigh = new LastFmTreeItem( mapTypeToUrl( LastFm::UserChildNeighborhood, user ), - LastFm::UserChildNeighborhood, i18n( "Neighborhood" ), item ); - item->appendChild( personal ); - item->appendChild( neigh ); -} - -void -LastFmTreeModel::prepareAvatar( QPixmap &avatar, int size ) -{ - // This code is here to stop Qt from crashing on certain weirdly shaped avatars. - // We had a case were an avatar got a height of 1px after scaling and it would - // crash in the rendering code. This here just fills in the background with - // transparency first. - if( avatar.width() < size || avatar.height() < size ) - { - QImage finalAvatar( size, size, QImage::Format_ARGB32 ); - finalAvatar.fill( 0 ); - - QPainter p( &finalAvatar ); - QRect r; - - if( avatar.width() < size ) - r = QRect( ( size - avatar.width() ) / 2, 0, avatar.width(), avatar.height() ); - else - r = QRect( 0, ( size - avatar.height() ) / 2, avatar.width(), avatar.height() ); - - p.drawPixmap( r, avatar ); - p.end(); - - avatar = QPixmap::fromImage( finalAvatar ); - } -} - -void -LastFmTreeModel::onAvatarDownloaded( const QString &username, QPixmap avatar ) -{ - sender()->deleteLater(); - if( avatar.isNull() || avatar.height() <= 0 || avatar.width() <= 0 ) - return; - if( username == m_user.name() ) - return; - - int m = avatarSize(); - avatar = avatar.scaled( m, m, Qt::KeepAspectRatio, Qt::SmoothTransformation ); - prepareAvatar( avatar, m ); - m_avatars.insert( username, avatar ); - - // these 2 categories have a chance to be updated: - QList categories; - categories << m_myFriends << m_myNeighbors; - - // now go through all children of the categories and notify view as appropriate - foreach( LastFmTreeItem *category, categories ) - { - QModelIndex parentIdx = index( category->row(), 0 ); - for( int i = 0; i < category->childCount(); i++ ) - { - LastFmTreeItem *item = category->child( i ); - if( !item ) - continue; - - if( item->data() == username ) - { - QModelIndex idx = index( i, 0, parentIdx ); - emit dataChanged( idx, idx ); - break; // no user is twice in a single category - } - } - } -} - -QIcon -LastFmTreeModel::avatar( const QString &username, const KUrl &avatarUrl ) const -{ - KIcon defaultIcon( "filename-artist-amarok" ); - if( username.isEmpty() ) - return defaultIcon; - if( m_avatars.contains(username) ) - return m_avatars.value( username ); - if( !avatarUrl.isValid() ) - return defaultIcon; - - // insert placeholder so that we don't request the save avatar twice; - const_cast( this )->m_avatars.insert( username, defaultIcon ); - AvatarDownloader* downloader = new AvatarDownloader(); - downloader->downloadAvatar( username, avatarUrl ); - connect( downloader, SIGNAL(avatarDownloaded(QString,QPixmap)), - SLOT(onAvatarDownloaded(QString,QPixmap)) ); - return defaultIcon; -} - -int -LastFmTreeModel::columnCount( const QModelIndex &parent ) const -{ - Q_UNUSED( parent ) - return 1; -} - -int -LastFmTreeModel::avatarSize() -{ - return 32; -} - -QVariant -LastFmTreeModel::data( const QModelIndex &index, int role ) const -{ - if( !index.isValid() ) - return QVariant(); - - LastFmTreeItem *i = static_cast( index.internalPointer() ); - if( role == Qt::DisplayRole ) - switch( i->type() ) - { - case MyRecommendations: - return i18n( "My Recommendations" ); - case PersonalRadio: - return i18n( "My Radio Station" ); - case MixRadio: - return i18n( "My Mix Radio" ); - case NeighborhoodRadio: - return i18n( "My Neighborhood" ); - // case RecentlyPlayed: return tr("Recently Played"); - // case RecentlyLoved: return tr("Recently Loved"); - // case RecentlyBanned: return tr("Recently Banned"); - case TopArtists: - return i18n( "My Top Artists" ); - case MyTags: - return i18n( "My Tags" ); - case Friends: - return i18n( "Friends" ); - case Neighbors: - return i18n( "Neighbors" ); - // case History: return tr("History"); - - // case RecentlyPlayedTrack: return m_played.value( index.row() ); - // case RecentlyLovedTrack: return m_loved.value( index.row() ); - // case RecentlyBannedTrack: return m_banned.value( index.row() ); -// case MyTagsChild: return m_tags.value( index.row() ); - case FriendsChild: - case ArtistsChild: - case NeighborsChild: - case UserChildPersonal: - case UserChildNeighborhood: - case MyTagsChild: - return i->data(); - default: - break; - } - - if( role == Qt::DecorationRole ) - switch( i->type() ) - { - case MyRecommendations: - return KIcon( "lastfm-recommended-radio-amarok" ); - case TopArtists: - case PersonalRadio: - return KIcon( "lastfm-personal-radio-amarok" ); - case MixRadio: - return KIcon( "lastfm-mix-radio-amarok" ); - case NeighborhoodRadio: - return KIcon( "lastfm-neighbour-radio-amarok" ); - // case RecentlyPlayed: return KIcon( "lastfm-recent-tracks-amarok" ); - // case RecentlyLoved: return KIcon( "lastfm-recently-loved-amarok" ); - // case RecentlyBanned: return KIcon( "lastfm-recently-banned-amarok" ); - case MyTags: - return KIcon( "lastfm-my-tags-amarok" ); - case Friends: - return KIcon( "lastfm-my-friends-amarok" ); - case Neighbors: - return KIcon( "lastfm-my-neighbours-amarok" ); - - case RecentlyPlayedTrack: //FALL THROUGH - case RecentlyLovedTrack: //FALL THROUGH - case RecentlyBannedTrack: - return KIcon( "icon_track" ); - case MyTagsChild: - return KIcon( "lastfm-tag-amarok" ); - - case FriendsChild: - return avatar( i->data().toString(), i->avatarUrl() ); - case UserChildPersonal: - return KIcon( "lastfm-personal-radio-amarok" ); - case UserChildNeighborhood: - return KIcon( "lastfm-neighbour-radio-amarok" ); - - case NeighborsChild: - return avatar( i->data().toString(), i->avatarUrl() ); - - case HistoryStation: - return KIcon( "icon_radio" ); - - default: - break; - } - - if( role == LastFm::TrackRole ) - { - switch( i->type() ) - { - case LastFm::MyRecommendations: - case LastFm::PersonalRadio: - case LastFm::MixRadio: - case LastFm::NeighborhoodRadio: - case LastFm::FriendsChild: - case LastFm::NeighborsChild: - case LastFm::MyTagsChild: - case LastFm::ArtistsChild: - case LastFm::UserChildPersonal: - case LastFm::UserChildNeighborhood: - return QVariant::fromValue( i->track() ); - default: - break; - } - } - if( role == LastFm::TypeRole ) - return i->type(); - - return QVariant(); -} - -Qt::ItemFlags -LastFmTreeModel::flags( const QModelIndex &index ) const -{ - if( !index.isValid() ) - return 0; - - Qt::ItemFlags flags = Qt::ItemIsEnabled | Qt::ItemIsDropEnabled; - LastFmTreeItem *i = static_cast( index.internalPointer() ); - switch( i->type() ) - { - case MyRecommendations: - case PersonalRadio: - case MixRadio: - case NeighborhoodRadio: - case RecentlyPlayedTrack: - case RecentlyLovedTrack: - case RecentlyBannedTrack: - case MyTagsChild: - case FriendsChild: - case ArtistsChild: - case NeighborsChild: - case HistoryStation: - case UserChildPersonal: - case UserChildNeighborhood: - flags |= Qt::ItemIsSelectable; - break; - - default: - break; - } - - switch( i->type() ) - { - case UserChildPersonal: - case UserChildNeighborhood: - case MyTagsChild: - case ArtistsChild: - case MyRecommendations: - case PersonalRadio: - case MixRadio: - case NeighborhoodRadio: - flags |= Qt::ItemIsDragEnabled; - - default: - break; - } - - return flags; -} - -QModelIndex -LastFmTreeModel::index( int row, int column, const QModelIndex &parent ) -const -{ - if( !hasIndex( row, column, parent ) ) - return QModelIndex(); - - LastFmTreeItem *parentItem; - - if( !parent.isValid() ) - parentItem = m_rootItem; - else - parentItem = static_cast( parent.internalPointer() ); - - LastFmTreeItem *childItem = parentItem->child( row ); - if( childItem ) - return createIndex( row, column, childItem ); - else - return QModelIndex(); -} - -QModelIndex -LastFmTreeModel::parent( const QModelIndex &index ) const -{ - if( !index.isValid() ) - return QModelIndex(); - - LastFmTreeItem *childItem = static_cast( index.internalPointer() ); - LastFmTreeItem *parentItem = childItem->parent(); - - if( parentItem == m_rootItem ) - return QModelIndex(); - - return createIndex( parentItem->row(), 0, parentItem ); -} - -int -LastFmTreeModel::rowCount( const QModelIndex &parent ) const -{ - LastFmTreeItem *parentItem; - if( parent.column() > 0 ) - return 0; - - if( !parent.isValid() ) - parentItem = m_rootItem; - else - parentItem = static_cast( parent.internalPointer() ); - - return parentItem->childCount(); -} - -void -LastFmTreeModel::setupModelData( LastFmTreeItem *parent ) -{ - // no need to call beginInsertRows() here, this is only called from constructor - parent->appendChild( new LastFmTreeItem( mapTypeToUrl( LastFm::MyRecommendations ), LastFm::MyRecommendations, parent ) ); - parent->appendChild( new LastFmTreeItem( mapTypeToUrl( LastFm::PersonalRadio ), LastFm::PersonalRadio, parent ) ); - parent->appendChild( new LastFmTreeItem( mapTypeToUrl( LastFm::MixRadio ), LastFm::MixRadio, parent ) ); - parent->appendChild( new LastFmTreeItem( mapTypeToUrl( LastFm::NeighborhoodRadio ), LastFm::NeighborhoodRadio, parent ) ); - - m_myTopArtists = new LastFmTreeItem( LastFm::TopArtists, parent ); - parent->appendChild( m_myTopArtists ); - - m_myTags = new LastFmTreeItem( LastFm::MyTags, parent ); - parent->appendChild( m_myTags ); - - m_myFriends = new LastFmTreeItem( LastFm::Friends, parent ); - parent->appendChild( m_myFriends ); - - m_myNeighbors = new LastFmTreeItem( LastFm::Neighbors, parent ); - parent->appendChild( m_myNeighbors ); -} - -QString -LastFmTreeModel::mapTypeToUrl( LastFm::Type type, const QString &key ) -{ - QString const encoded_username = KUrl::toPercentEncoding( m_user.name() ); - switch( type ) - { - case MyRecommendations: - return "lastfm://user/" + encoded_username + "/recommended"; - case PersonalRadio: - return "lastfm://user/" + encoded_username + "/personal"; - case MixRadio: - return "lastfm://user/" + encoded_username + "/mix"; - case NeighborhoodRadio: - return "lastfm://user/" + encoded_username + "/neighbours"; - case MyTagsChild: - return "lastfm://usertags/" + encoded_username + "/" + KUrl::toPercentEncoding( key ); - case FriendsChild: - return "lastfm://user/" + KUrl::toPercentEncoding( key ) + "/personal"; - case ArtistsChild: - return "lastfm://artist/" + KUrl::toPercentEncoding( key ) + "/similarartists"; - case NeighborsChild: - return "lastfm://user/" + KUrl::toPercentEncoding( key ) + "/personal"; - case UserChildPersonal: - return "lastfm://user/" + KUrl::toPercentEncoding( key ) + "/personal"; - case UserChildNeighborhood: - return "lastfm://user/" + KUrl::toPercentEncoding( key ) + "/neighbours"; - default: - return ""; - } -} - -LastFmTreeItem::LastFmTreeItem( const LastFm::Type &type, const QVariant &data, LastFmTreeItem *parent ) - : mType( type ), parentItem( parent ), itemData( data ) -{ -} - -LastFmTreeItem::LastFmTreeItem( const LastFm::Type &type, LastFmTreeItem *parent ) - : mType( type ), parentItem( parent ) -{ - -} - -LastFmTreeItem::LastFmTreeItem( const QString &url, const LastFm::Type &type, LastFmTreeItem *parent ) - : mType( type ), parentItem( parent ), mUrl( url ) -{ - -} - -LastFmTreeItem::LastFmTreeItem( const QString &url, const LastFm::Type &type, const QVariant &data, LastFmTreeItem *parent ) - : mType( type ), parentItem( parent ), itemData( data ), mUrl( url ) -{ -} - -LastFmTreeItem::~LastFmTreeItem() -{ - qDeleteAll( childItems ); -} - -void -LastFmTreeItem::appendChild( LastFmTreeItem *item ) -{ - childItems.append( item ); -} - -LastFmTreeItem * -LastFmTreeItem::child( int row ) -{ - return childItems.value( row ); -} - -int -LastFmTreeItem::childCount() const -{ - return childItems.count(); -} - -QVariant -LastFmTreeItem::data() const -{ - return itemData; -} - -Meta::TrackPtr -LastFmTreeItem::track() const -{ - Meta::TrackPtr track; - if( mUrl.isEmpty() ) - return track; - - KUrl url( mUrl ); - track = CollectionManager::instance()->trackForUrl( url ); - - return track; -} - -LastFmTreeItem *LastFmTreeItem::parent() -{ - return parentItem; -} - -int -LastFmTreeItem::row() const -{ - if( parentItem ) - return parentItem->childItems.indexOf( const_cast( this ) ); - - return 0; -} - -QMimeData* -LastFmTreeModel::mimeData( const QModelIndexList &indices ) const -{ - debug() << "LASTFM drag items : " << indices.size(); - Meta::TrackList list; - foreach( const QModelIndex &item, indices ) - { - Meta::TrackPtr track = data( item, LastFm::TrackRole ).value< Meta::TrackPtr >(); - if( track ) - list << track; - } - qStableSort( list.begin(), list.end(), Meta::Track::lessThan ); - - AmarokMimeData *mimeData = new AmarokMimeData(); - mimeData->setTracks( list ); - return mimeData; -} diff --git a/amarok/src/services/lastfm/LastFmTreeModel.h b/amarok/src/services/lastfm/LastFmTreeModel.h deleted file mode 100644 index 691229d7..00000000 --- a/amarok/src/services/lastfm/LastFmTreeModel.h +++ /dev/null @@ -1,177 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Casey Link * - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * Copyright (c) 2009 Mark Kretschmann * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef LASTFMTREEMODEL_H -#define LASTFMTREEMODEL_H - -#include "core/meta/forward_declarations.h" - -#include - -#include -#include - -#include - -class QNetworkReply; - -namespace LastFm -{ -enum Type -{ - Root = 0, - MyRecommendations, - PersonalRadio, - MixRadio, - NeighborhoodRadio, - // RecentlyPlayed, - // RecentlyLoved, - // RecentlyBanned, - TopArtists, - MyTags, - Friends, - Neighbors, - - // History, - - RowCount, - - MyTagsChild, - FriendsChild, - NeighborsChild, - ArtistsChild, - RecentlyBannedTrack, - RecentlyPlayedTrack, - RecentlyLovedTrack, - HistoryStation, - - UserChildPersonal, - UserChildNeighborhood, - - TypeUnknown -}; - -enum Role -{ - StationUrlRole = Qt::UserRole, - UrlRole, - TrackRole, - TypeRole -}; - -enum SortOrder -{ - MostWeightOrder, - AscendingOrder, - DescendingOrder -}; - - -} - -class LastFmTreeItem; -class KUrl; -class WsReply; - - -class LastFmTreeModel : public QAbstractItemModel -{ - Q_OBJECT - -public: - explicit LastFmTreeModel( QObject *parent = 0 ); - ~LastFmTreeModel(); - - QVariant data( const QModelIndex &index, int role ) const; - Qt::ItemFlags flags( const QModelIndex &index ) const; - QModelIndex index( int row, int column, - const QModelIndex &parent = QModelIndex() ) const; - QModelIndex parent( const QModelIndex &index ) const; - int rowCount( const QModelIndex &parent = QModelIndex() ) const; - int columnCount( const QModelIndex &parent = QModelIndex() ) const; - static int avatarSize(); - void prepareAvatar( QPixmap& avatar, int size ); - - virtual QMimeData *mimeData( const QModelIndexList &indices ) const; - -private slots: - void onAvatarDownloaded( const QString& username, QPixmap ); - void slotAddNeighbors(); - void slotAddFriends(); - void slotAddTags(); - void slotAddTopArtists(); - -private: - void setupModelData( LastFmTreeItem *parent ); - - QIcon avatar( const QString &username, const KUrl &avatarUrl ) const; - QString mapTypeToUrl( LastFm::Type type, const QString &key = "" ); - - void appendUserStations( LastFmTreeItem* item, const QString& user ); - - lastfm::User m_user; - - LastFmTreeItem *m_rootItem; - LastFmTreeItem *m_myTags; - LastFmTreeItem *m_myFriends; - LastFmTreeItem *m_myNeighbors; - LastFmTreeItem *m_myTopArtists; - QHash m_avatars; -}; - -class LastFmTreeItem -{ -public: - LastFmTreeItem ( const LastFm::Type &type, const QVariant &data, LastFmTreeItem *parent = 0 ); - LastFmTreeItem ( const QString &url, const LastFm::Type &type, const QVariant &data, LastFmTreeItem *parent = 0 ); - explicit LastFmTreeItem ( const LastFm::Type &type, LastFmTreeItem *parent = 0 ); - LastFmTreeItem ( const QString &url, const LastFm::Type &type, LastFmTreeItem *parent = 0 ); - ~LastFmTreeItem(); - - void appendChild ( LastFmTreeItem *child ); - - LastFmTreeItem *child ( int row ); - int childCount() const; - QVariant data () const; - int row() const; - LastFmTreeItem *parent(); - Meta::TrackPtr track() const; - LastFm::Type type() const - { - return mType; - } - - KUrl avatarUrl() const - { - return avatar; - } - void setAvatarUrl( const KUrl &url ) - { - avatar = url; - } - -private: - QList childItems; - LastFm::Type mType; - LastFmTreeItem *parentItem; - QVariant itemData; - QString mUrl; - KUrl avatar; -}; - -#endif diff --git a/amarok/src/services/lastfm/LastFmTreeView.cpp b/amarok/src/services/lastfm/LastFmTreeView.cpp deleted file mode 100644 index 99ed50e5..00000000 --- a/amarok/src/services/lastfm/LastFmTreeView.cpp +++ /dev/null @@ -1,242 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Casey Link * - * Copyright (c) 2005-2007 Christian Muehlhaeuser, Last.fm Ltd * - * Copyright (c) 2005-2007 Max Howell, Last.fm Ltd * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "LastFmTreeView.h" - -#include "PopupDropperFactory.h" -#include "context/ContextView.h" -#include "context/popupdropper/libpud/PopupDropper.h" -#include "context/popupdropper/libpud/PopupDropperItem.h" -#include "core/meta/Meta.h" -#include "core/support/Debug.h" -#include "services/lastfm/LastFmTreeModel.h" // FIXME just for enums - -#include - -#include - -LastFmTreeView::LastFmTreeView ( QWidget* parent ) - : Amarok::PrettyTreeView ( parent ) - , m_timer ( 0 ) - , m_pd( 0 ) - , m_appendAction ( 0 ) - , m_loadAction ( 0 ) - , m_dragMutex() - , m_ongoingDrag( false ) -{ -// connect ( this, SIGNAL (activated(QModelIndex)), SLOT (onActivated(QModelIndex)) ); - - header()->hide(); -// setRootIsDecorated( false ); -} - - -LastFmTreeView::~LastFmTreeView() -{} - -void -LastFmTreeView::contextMenuEvent ( QContextMenuEvent* event ) -{ - m_currentItems.clear(); - foreach ( const QModelIndex &i, selectedIndexes() ) - { - if ( i.isValid() ) - m_currentItems << i; - } - if ( m_currentItems.isEmpty() ) - return; - QAction separator ( this ); - separator.setSeparator ( true ); - - QActionList actions = createBasicActions( m_currentItems ); - - actions += &separator; - KMenu menu; - foreach ( QAction * action, actions ) - menu.addAction ( action ); - - menu.exec ( event->globalPos() ); -} - -QActionList LastFmTreeView::createBasicActions( const QModelIndexList & indices ) -{ - Q_UNUSED( indices ) - QActionList actions; - QModelIndex index = currentIndex(); - QVariant type = model()->data(index, LastFm::TypeRole); - switch ( type.toInt() ) - { - case LastFm::MyRecommendations: - case LastFm::PersonalRadio: - case LastFm::MixRadio: - case LastFm::NeighborhoodRadio: - case LastFm::FriendsChild: - case LastFm::NeighborsChild: - case LastFm::MyTagsChild: - case LastFm::ArtistsChild: - case LastFm::UserChildPersonal: - case LastFm::UserChildNeighborhood: - { - if ( m_appendAction == 0 ) - { - m_appendAction = new QAction ( KIcon ( "media-track-add-amarok" ), i18n ( "&Add to Playlist" ), this ); - m_appendAction->setProperty( "popupdropper_svg_id", "append" ); - connect ( m_appendAction, SIGNAL (triggered()), this, SLOT (slotAppendChildTracks()) ); - } - - actions.append ( m_appendAction ); - - if ( m_loadAction == 0 ) - { - m_loadAction = new QAction ( KIcon ( "folder-open" ), i18nc ( "Replace the currently loaded tracks with these", "&Replace Playlist" ), this ); - m_appendAction->setProperty( "popupdropper_svg_id", "load" ); - connect ( m_loadAction, SIGNAL (triggered()), this, SLOT (slotReplacePlaylistByChildTracks()) ); - } - actions.append ( m_loadAction ); - } - default: - break; - } - return actions; -} - -void LastFmTreeView::mouseDoubleClickEvent( QMouseEvent *event ) -{ - QModelIndex index; - index = indexAt( event->pos() ); - - if( index.isValid() && index.internalPointer() ) - { - playChildTracks( index, Playlist::OnDoubleClickOnSelectedItems ); - } -} - -void -LastFmTreeView::startDrag(Qt::DropActions supportedActions) -{ - DEBUG_BLOCK - - //setSelectionMode( QAbstractItemView::NoSelection ); - - // When a parent item is dragged, startDrag() is called a bunch of times. Here we prevent that: - m_dragMutex.lock(); - if( m_ongoingDrag ) - { - m_dragMutex.unlock(); - return; - } - m_ongoingDrag = true; - m_dragMutex.unlock(); - - if( !m_pd ) - m_pd = The::popupDropperFactory()->createPopupDropper( Context::ContextView::self() ); - - if( m_pd && m_pd->isHidden() ) - { - - QModelIndexList indices = selectedIndexes(); - - QActionList actions = createBasicActions( indices ); - - QFont font; - font.setPointSize( 16 ); - font.setBold( true ); - - foreach( QAction * action, actions ) - m_pd->addItem( The::popupDropperFactory()->createItem( action ) ); - - - m_currentItems.clear(); - foreach( const QModelIndex &index, indices ) - { - if( index.isValid() && index.internalPointer() ) - m_currentItems << index; - } - - PopupDropperItem* subItem; - - PopupDropper * morePud = 0; - if ( actions.count() > 1 ) - { - morePud = The::popupDropperFactory()->createPopupDropper( 0, true ); - - foreach( QAction * action, actions ) - morePud->addItem( The::popupDropperFactory()->createItem( action ) ); - } - else - m_pd->addItem( The::popupDropperFactory()->createItem( actions[0] ) ); - - //TODO: Keep bugging i18n team about problems with 3 dots - if ( actions.count() > 1 ) - { - subItem = m_pd->addSubmenu( &morePud, i18n( "More..." ) ); - The::popupDropperFactory()->adjustItem( subItem ); - } - - m_pd->show(); - } - - QTreeView::startDrag( supportedActions ); - debug() << "After the drag!"; - - if( m_pd ) - { - debug() << "clearing PUD"; - connect( m_pd, SIGNAL(fadeHideFinished()), m_pd, SLOT(clear()) ); - m_pd->hide(); - } - - m_dragMutex.lock(); - m_ongoingDrag = false; - m_dragMutex.unlock(); -} - -void -LastFmTreeView::slotReplacePlaylistByChildTracks() -{ - playChildTracks( m_currentItems, Playlist::OnReplacePlaylistAction ); -} - -void -LastFmTreeView::slotAppendChildTracks() -{ - playChildTracks( m_currentItems, Playlist::OnAppendToPlaylistAction ); -} - -void -LastFmTreeView::playChildTracks( const QModelIndex &item, Playlist::AddOptions insertMode) -{ - QModelIndexList items; - items << item; - - playChildTracks( items, insertMode ); -} -void -LastFmTreeView::playChildTracks ( const QModelIndexList &items, Playlist::AddOptions insertMode ) -{ - debug() << "LASTFM current items : " << items.size(); - Meta::TrackList list; - foreach ( const QModelIndex &item, items ) - { - Meta::TrackPtr track = model()->data(item, LastFm::TrackRole).value< Meta::TrackPtr >(); - if ( track ) - list << track; - } - qStableSort ( list.begin(), list.end(), Meta::Track::lessThan ); - The::playlistController()->insertOptioned( list, insertMode ); -} diff --git a/amarok/src/services/lastfm/LastFmTreeView.h b/amarok/src/services/lastfm/LastFmTreeView.h deleted file mode 100644 index ba11327b..00000000 --- a/amarok/src/services/lastfm/LastFmTreeView.h +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Casey Link * - * Copyright (c) 2005-2007 Christian Muehlhaeuser, Last.fm Ltd * - * Copyright (c) 2005-2007 Max Howell, Last.fm Ltd * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef LASTFMTREEVIEW_H -#define LASTFMTREEVIEW_H - -#include "playlist/PlaylistController.h" -#include "widgets/PrettyTreeView.h" - -#include -#include -#include - -class LastFmTreeModel; - -class QAction; -class QContextMenuEvent; -class QMouseEvent; -class PopupDropper; - -typedef QList QActionList; - -class LastFmTreeView : public Amarok::PrettyTreeView -{ - Q_OBJECT - -public: - LastFmTreeView ( QWidget* parent = 0 ); - ~LastFmTreeView(); - -signals: - void statusMessage ( const QString& message ); - void plsShowRestState(); - void plsShowNowPlaying(); - -private slots: - void slotReplacePlaylistByChildTracks(); - void slotAppendChildTracks(); - -protected: - virtual void contextMenuEvent ( QContextMenuEvent* ); - void mouseDoubleClickEvent( QMouseEvent *event ); - void startDrag( Qt::DropActions supportedActions ); - -private: - enum ContextMenuActionType { ExecQMenu, DoQMenuDefaultAction }; - void playChildTracks ( const QModelIndex &item, Playlist::AddOptions insertMode ); - void playChildTracks ( const QModelIndexList &items, Playlist::AddOptions insertMode ); - QActionList createBasicActions( const QModelIndexList &indcies ); - - QTimer* m_timer; - LastFmTreeModel* m_model; - PopupDropper* m_pd; - QAction* m_appendAction; - QAction* m_loadAction; - QModelIndexList m_currentItems; - QMutex m_dragMutex; - bool m_ongoingDrag; -}; - -#endif diff --git a/amarok/src/services/lastfm/LoveTrackAction.cpp b/amarok/src/services/lastfm/LoveTrackAction.cpp deleted file mode 100644 index 4faf7e45..00000000 --- a/amarok/src/services/lastfm/LoveTrackAction.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "LoveTrackAction.h" - -#include "LastFmService.h" - -#include - -LoveTrackAction::LoveTrackAction( LastFmService * service ) - : GlobalCollectionTrackAction( i18n( "Last.fm: Love" ), service ) - , m_service( service ) -{ - setIcon( KIcon( "love-amarok") ); - setProperty( "popupdropper_svg_id", "lastfm" ); - - connect( this, SIGNAL(triggered(bool)), SLOT(slotTriggered()) ); -} - -void LoveTrackAction::slotTriggered() -{ - DEBUG_BLOCK - m_service->love( track() ); -} - - diff --git a/amarok/src/services/lastfm/LoveTrackAction.h b/amarok/src/services/lastfm/LoveTrackAction.h deleted file mode 100644 index a64b68c4..00000000 --- a/amarok/src/services/lastfm/LoveTrackAction.h +++ /dev/null @@ -1,42 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef LOVETRACKACTION_H -#define LOVETRACKACTION_H - -#include "GlobalCollectionActions.h" - -class LastFmService; - -/** -A last.fm specific global collection action for loving a track. - - @author Nikolaj Hald Nielsen -*/ -class LoveTrackAction : public GlobalCollectionTrackAction -{ - Q_OBJECT -public: - LoveTrackAction( LastFmService * service ); - -private slots: - void slotTriggered(); - -private: - LastFmService * m_service; -}; - -#endif diff --git a/amarok/src/services/lastfm/ScrobblerAdapter.cpp b/amarok/src/services/lastfm/ScrobblerAdapter.cpp deleted file mode 100644 index 06643438..00000000 --- a/amarok/src/services/lastfm/ScrobblerAdapter.cpp +++ /dev/null @@ -1,298 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Shane King * - * Copyright (c) 2008 Leo Franchi * - * Copyright (c) 2012 Matěj Laitl * - * Copyright (c) 2013 Vedant Agarwala * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "lastfm" - -#include "ScrobblerAdapter.h" - -#include "MainWindow.h" -#include "core/collections/Collection.h" -#include "core/interfaces/Logger.h" -#include "core/meta/Meta.h" -#include "core/meta/support/MetaConstants.h" -#include "core/support/Components.h" -#include "core/support/Debug.h" - -#include - -#include - -#include - -ScrobblerAdapter::ScrobblerAdapter( const QString &clientId, const LastFmServiceConfigPtr &config ) - : m_scrobbler( clientId ) - , m_config( config ) -{ - // work around a bug in liblastfm -- -it doesn't create its config dir, so when it - // tries to write the track cache, it fails silently. Last check: liblastfm 1.0.! - QList dirs; - dirs << lastfm::dir::runtimeData() << lastfm::dir::cache() << lastfm::dir::logs(); - foreach( const QDir &dir, dirs ) - { - if( !dir.exists() ) - { - debug() << "creating" << dir.absolutePath() << "directory for liblastfm"; - dir.mkpath( "." ); - } - } - - connect( The::mainWindow(), SIGNAL(loveTrack(Meta::TrackPtr)), - SLOT(loveTrack(Meta::TrackPtr)) ); - connect( The::mainWindow(), SIGNAL(banTrack(Meta::TrackPtr)), - SLOT(banTrack(Meta::TrackPtr)) ); - - connect( &m_scrobbler, SIGNAL(scrobblesSubmitted(QList)), - SLOT(slotScrobblesSubmitted(QList)) ); - connect( &m_scrobbler, SIGNAL(nowPlayingError(int,QString)), - SLOT(slotNowPlayingError(int,QString))); -} - -ScrobblerAdapter::~ScrobblerAdapter() -{ -} - -QString -ScrobblerAdapter::prettyName() const -{ - return i18n( "Last.fm" ); -} - -StatSyncing::ScrobblingService::ScrobbleError -ScrobblerAdapter::scrobble( const Meta::TrackPtr &track, double playedFraction, - const QDateTime &time ) -{ - Q_ASSERT( track ); - if( isToBeSkipped( track ) ) - { - debug() << "scrobble(): refusing track" << track->prettyUrl() - << "- contains label:" << m_config->filteredLabel() << "which is marked to be skipped"; - return SkippedByUser; - } - if( track->length() * qMin( 1.0, playedFraction ) < 30 * 1000 ) - { - debug() << "scrobble(): refusing track" << track->prettyUrl() << "- played time (" - << track->length() / 1000 << "*" << playedFraction << "s) shorter than 30 s"; - return TooShort; - } - int playcount = qRound( playedFraction ); - if( playcount <= 0 ) - { - debug() << "scrobble(): refusing track" << track->prettyUrl() << "- played " - << "fraction (" << playedFraction * 100 << "%) less than 50 %"; - return TooShort; - } - - lastfm::MutableTrack lfmTrack; - copyTrackMetadata( lfmTrack, track ); - // since liblastfm >= 1.0.3 it interprets following extra property: - lfmTrack.setExtra( "playCount", QString::number( playcount ) ); - lfmTrack.setTimeStamp( time.isValid() ? time : QDateTime::currentDateTime() ); - debug() << "scrobble: " << lfmTrack.artist() << "-" << lfmTrack.album() << "-" - << lfmTrack.title() << "source:" << lfmTrack.source() << "duration:" - << lfmTrack.duration(); - m_scrobbler.cache( lfmTrack ); - m_scrobbler.submit(); // since liblastfm 1.0.7, submit() is not called automatically upon cache() - switch( lfmTrack.scrobbleStatus() ) - { - case lastfm::Track::Cached: - case lastfm::Track::Submitted: - return NoError; - case lastfm::Track::Null: - case lastfm::Track::Error: - break; - } - return BadMetadata; -} - -void -ScrobblerAdapter::updateNowPlaying( const Meta::TrackPtr &track ) -{ - lastfm::MutableTrack lfmTrack; - if( track ) - { - if( isToBeSkipped( track ) ) - { - debug() << "updateNowPlaying(): refusing track" << track->prettyUrl() - << "- contains label:" << m_config->filteredLabel() << "which is marked to be skipped"; - return; - } - copyTrackMetadata( lfmTrack, track ); - debug() << "nowPlaying: " << lfmTrack.artist() << "-" << lfmTrack.album() << "-" - << lfmTrack.title() << "source:" << lfmTrack.source() << "duration:" - << lfmTrack.duration(); - m_scrobbler.nowPlaying( lfmTrack ); - } - else - { - debug() << "removeNowPlaying"; - QNetworkReply *reply = lfmTrack.removeNowPlaying(); // works even with empty lfmTrack - connect( reply, SIGNAL(finished()), reply, SLOT(deleteLater()) ); // don't leak - } -} - -void -ScrobblerAdapter::loveTrack( const Meta::TrackPtr &track ) // slot -{ - if( !track ) - return; - - lastfm::MutableTrack trackInfo; - copyTrackMetadata( trackInfo, track ); - trackInfo.love(); - Amarok::Components::logger()->shortMessage( i18nc( "As in Last.fm", "Loved Track: %1", track->prettyName() ) ); -} - -void -ScrobblerAdapter::banTrack( const Meta::TrackPtr &track ) // slot -{ - if( !track ) - return; - - lastfm::MutableTrack trackInfo; - copyTrackMetadata( trackInfo, track ); - trackInfo.ban(); - Amarok::Components::logger()->shortMessage( i18nc( "As in Last.fm", "Banned Track: %1", track->prettyName() ) ); -} - -void -ScrobblerAdapter::slotScrobblesSubmitted( const QList &tracks ) -{ - foreach( const lastfm::Track &track, tracks ) - { - switch( track.scrobbleStatus() ) - { - case lastfm::Track::Null: - warning() << "slotScrobblesSubmitted(): track" << track - << "has Null scrobble status, strange"; - break; - case lastfm::Track::Cached: - warning() << "slotScrobblesSubmitted(): track" << track - << "has Cached scrobble status, strange"; - break; - case lastfm::Track::Submitted: - if( track.corrected() && m_config->announceCorrections() ) - announceTrackCorrections( track ); - break; - case lastfm::Track::Error: - warning() << "slotScrobblesSubmitted(): error scrobbling track" << track - << ":" << track.scrobbleErrorText(); - break; - } - } -} - -void -ScrobblerAdapter::slotNowPlayingError( int code, const QString &message ) -{ - Q_UNUSED( code ) - warning() << "error updating Now Playing status:" << message; -} - -void -ScrobblerAdapter::copyTrackMetadata( lastfm::MutableTrack &to, const Meta::TrackPtr &track ) -{ - to.setTitle( track->name() ); - - QString artistOrComposer; - Meta::ComposerPtr composer = track->composer(); - if( m_config->scrobbleComposer() && composer ) - artistOrComposer = composer->name(); - Meta::ArtistPtr artist = track->artist(); - if( artistOrComposer.isEmpty() && artist ) - artistOrComposer = artist->name(); - to.setArtist( artistOrComposer ); - - Meta::AlbumPtr album = track->album(); - Meta::ArtistPtr albumArtist; - if( album ) - { - to.setAlbum( album->name() ); - albumArtist = album->hasAlbumArtist() ? album->albumArtist() : Meta::ArtistPtr(); - } - if( albumArtist ) - to.setAlbumArtist( albumArtist->name() ); - - to.setDuration( track->length() / 1000 ); - if( track->trackNumber() >= 0 ) - to.setTrackNumber( track->trackNumber() ); - - lastfm::Track::Source source = lastfm::Track::Player; - if( track->type() == "stream/lastfm" ) - source = lastfm::Track::LastFmRadio; - else if( track->type().startsWith( "stream" ) ) - source = lastfm::Track::NonPersonalisedBroadcast; - else if( track->collection() && track->collection()->collectionId() != "localCollection" ) - source = lastfm::Track::MediaDevice; - to.setSource( source ); -} - -static QString -printCorrected( qint64 field, const QString &original, const QString &corrected ) -{ - if( corrected.isEmpty() || original == corrected ) - return QString(); - return i18nc( "%1 is field name such as Album Name; %2 is the original value; %3 is " - "the corrected value", "%1 %2 should be corrected to " - "%3", Meta::i18nForField( field ), original, corrected ); -} - -static QString -printCorrected( qint64 field, const lastfm::AbstractType &original, const lastfm::AbstractType &corrected ) -{ - return printCorrected( field, original.toString(), corrected.toString() ); -} - -void -ScrobblerAdapter::announceTrackCorrections( const lastfm::Track &track ) -{ - static const lastfm::Track::Corrections orig = lastfm::Track::Original; - static const lastfm::Track::Corrections correct = lastfm::Track::Corrected; - - QString trackName = i18nc( "%1 is artist, %2 is title", "%1 - %2", - track.artist().name(), track.title() ); - QStringList lines; - lines << i18n( "Last.fm suggests that some tags of track %1 should be " - "corrected:", trackName ); - QString line; - line = printCorrected( Meta::valTitle, track.title( orig ), track.title( correct ) ); - if( !line.isEmpty() ) - lines << line; - line = printCorrected( Meta::valAlbum, track.album( orig ), track.album( correct ) ); - if( !line.isEmpty() ) - lines << line; - line = printCorrected( Meta::valArtist, track.artist( orig ), track.artist( correct ) ); - if( !line.isEmpty() ) - lines << line; - line = printCorrected( Meta::valAlbumArtist, track.albumArtist( orig ), track.albumArtist( correct ) ); - if( !line.isEmpty() ) - lines << line; - Amarok::Components::logger()->longMessage( lines.join( "
    " ) ); -} - -bool -ScrobblerAdapter::isToBeSkipped( const Meta::TrackPtr &track ) const -{ - Q_ASSERT( track ); - if( !m_config->filterByLabel() ) - return false; - foreach( const Meta::LabelPtr &label, track->labels() ) - if( label->name() == m_config->filteredLabel() ) - return true; - return false; -} diff --git a/amarok/src/services/lastfm/ScrobblerAdapter.h b/amarok/src/services/lastfm/ScrobblerAdapter.h deleted file mode 100644 index 8854446e..00000000 --- a/amarok/src/services/lastfm/ScrobblerAdapter.h +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Shane King * - * Copyright (c) 2008 Leo Franchi * - * Copyright (c) 2013 Vedant Agarwala * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef LASTFMSCROBBLERADAPTER_H -#define LASTFMSCROBBLERADAPTER_H - -#include "core/meta/forward_declarations.h" -#include "services/lastfm/LastFmServiceConfig.h" -#include "statsyncing/ScrobblingService.h" - -#include - -#include -#include - -class LastFmServiceConfig; - -class ScrobblerAdapter : public QObject, public StatSyncing::ScrobblingService -{ - Q_OBJECT - - public: - ScrobblerAdapter( const QString &clientId, const LastFmServiceConfigPtr &config ); - virtual ~ScrobblerAdapter(); - - public: - // ScrobblingService methods: - QString prettyName() const; - ScrobbleError scrobble( const Meta::TrackPtr &track, double playedFraction = 1.0, - const QDateTime &time = QDateTime() ); - void updateNowPlaying( const Meta::TrackPtr &track ); - - public slots: - // own methods - void loveTrack( const Meta::TrackPtr &track ); - void banTrack( const Meta::TrackPtr &track ); - - private slots: - void slotScrobblesSubmitted( const QList &tracks ); - void slotNowPlayingError( int code, const QString &message ); - - private: - /** - * Copies metadata from @param from to @param to. - */ - void copyTrackMetadata( lastfm::MutableTrack& to, const Meta::TrackPtr &from ); - - /** - * Announces Last.fm suggested @param track corrections to Amarok pop-up log. - */ - void announceTrackCorrections( const lastfm::Track &track ); - - /** - * Checks whether the @param track contains the m_config->skipLabel - * Also, returns false if "filterByLabel" is unchecked by user. - */ - bool isToBeSkipped( const Meta::TrackPtr &track ) const; - - lastfm::Audioscrobbler m_scrobbler; - LastFmServiceConfigPtr m_config; -}; - -#endif // LASTFMSCROBBLERADAPTER_H diff --git a/amarok/src/services/lastfm/SimilarArtistsAction.cpp b/amarok/src/services/lastfm/SimilarArtistsAction.cpp deleted file mode 100644 index a29cd937..00000000 --- a/amarok/src/services/lastfm/SimilarArtistsAction.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Dan Meltzer * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "SimilarArtistsAction.h" - -#include "core/meta/Meta.h" -#include "core-impl/collections/support/CollectionManager.h" -#include "playlist/PlaylistController.h" - -#include -#include - -SimilarArtistsAction::SimilarArtistsAction( QObject *parent ) - : GlobalCollectionArtistAction( i18n( "Play Similar Artists from Last.fm" ), parent ) -{ - connect( this, SIGNAL(triggered(bool)), SLOT(slotTriggered()) ); - - setIcon( KIcon("view-services-lastfm-amarok") ); - setProperty( "popupdropper_svg_id", "lastfm" ); -} - -void SimilarArtistsAction::slotTriggered() -{ - const QString url = "lastfm://artist/" + artist()->prettyName() + "/similarartists"; - Meta::TrackPtr lastfmtrack = CollectionManager::instance()->trackForUrl( KUrl( url ) ); - The::playlistController()->insertOptioned( lastfmtrack, Playlist::OnPlayMediaAction ); -} - -#include "moc_SimilarArtistsAction.cpp" diff --git a/amarok/src/services/lastfm/SimilarArtistsAction.h b/amarok/src/services/lastfm/SimilarArtistsAction.h deleted file mode 100644 index a8aa1a2e..00000000 --- a/amarok/src/services/lastfm/SimilarArtistsAction.h +++ /dev/null @@ -1,33 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Dan Meltzer * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef LASTFMSIMILARARTISTSACTION_H -#define LASTFMSIMILARARTISTSACTION_H - -#include "GlobalCollectionActions.h" - -class SimilarArtistsAction : public GlobalCollectionArtistAction -{ - Q_OBJECT -public: - SimilarArtistsAction( QObject *parent ); - - private slots: - void slotTriggered(); - -}; - -#endif diff --git a/amarok/src/services/lastfm/SynchronizationAdapter.cpp b/amarok/src/services/lastfm/SynchronizationAdapter.cpp deleted file mode 100644 index b7259937..00000000 --- a/amarok/src/services/lastfm/SynchronizationAdapter.cpp +++ /dev/null @@ -1,301 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "SynchronizationAdapter.h" - -#include "MetaValues.h" -#include "core/support/Debug.h" -#include "core/support/SemaphoreReleaser.h" -#include "services/lastfm/SynchronizationTrack.h" - -#include - -#include - -#include -#include - -const int SynchronizationAdapter::s_entriesPerQuery( 200 ); - -SynchronizationAdapter::SynchronizationAdapter( const LastFmServiceConfigPtr &config ) - : m_config( config ) -{ - connect( this, SIGNAL(startArtistSearch(int)), SLOT(slotStartArtistSearch(int)) ); - connect( this, SIGNAL(startTrackSearch(QString,int)), - SLOT(slotStartTrackSearch(QString,int)) ); - connect( this, SIGNAL(startTagSearch(QString,QString)), - SLOT(slotStartTagSearch(QString,QString)) ); -} - -SynchronizationAdapter::~SynchronizationAdapter() -{ -} - -QString -SynchronizationAdapter::id() const -{ - return "lastfm"; -} - -QString -SynchronizationAdapter::prettyName() const -{ - return i18n( "Last.fm" ); -} - -QString -SynchronizationAdapter::description() const -{ - return i18nc( "description of the Last.fm statistics synchronization provider", - "slows down track matching" ); -} - -KIcon -SynchronizationAdapter::icon() const -{ - return KIcon( "view-services-lastfm-amarok" ); -} - -qint64 -SynchronizationAdapter::reliableTrackMetaData() const -{ - return Meta::valArtist | Meta::valAlbum | Meta::valTitle; -} - -qint64 -SynchronizationAdapter::writableTrackStatsData() const -{ - bool useRating = m_config->useFancyRatingTags(); - return ( useRating ? Meta::valRating : 0 ) | Meta::valLabel; -} - -StatSyncing::Provider::Preference -SynchronizationAdapter::defaultPreference() -{ - return StatSyncing::Provider::Never; // don't overload Last.fm servers -} - -QSet -SynchronizationAdapter::artists() -{ - DEBUG_BLOCK - Q_ASSERT( m_semaphore.available() == 0 ); - emit startArtistSearch( 1 ); // Last.fm indexes from 1 - - m_semaphore.acquire(); - QSet ret = m_artists; - m_artists.clear(); // save memory - debug() << __PRETTY_FUNCTION__ << ret.count() << "artists total"; - return ret; -} - -StatSyncing::TrackList -SynchronizationAdapter::artistTracks( const QString &artistName ) -{ - /* This method should match track artists case-sensitively, but we don't do it. - * Last.fm webservice returns only the preferred capitalisation in artists(), so no - * duplicates threat us. */ - Q_ASSERT( m_semaphore.available() == 0 ); - emit startTrackSearch( artistName, 1 ); // Last.fm indexes from 1 - - m_semaphore.acquire(); - debug() << __PRETTY_FUNCTION__ << m_tracks.count() << "tracks from" << artistName - << m_tagQueue.count() << "of them have tags"; - - // fetch tags - QMutableListIterator it( m_tagQueue ); - while( it.hasNext() ) - { - StatSyncing::TrackPtr track = it.next(); - emit startTagSearch( track->artist(), track->name() ); - m_semaphore.acquire(); - it.remove(); - } - - StatSyncing::TrackList ret = m_tracks; - m_tracks.clear(); // save memory - m_tagQueue.clear(); // paranoia - return ret; -} - -void -SynchronizationAdapter::slotStartArtistSearch( int page ) -{ - QString user = m_config->username(); - QNetworkReply *reply = lastfm::Library::getArtists( user, s_entriesPerQuery, page ); - connect( reply, SIGNAL(finished()), SLOT(slotArtistsReceived()) ); -} - -void -SynchronizationAdapter::slotStartTrackSearch( QString artistName, int page ) -{ - lastfm::Artist artist( artistName ); - QString user = m_config->username(); - QNetworkReply *reply = lastfm::Library::getTracks( user, artist, s_entriesPerQuery, page ); - connect( reply, SIGNAL(finished()), SLOT(slotTracksReceived()) ); -} - -void -SynchronizationAdapter::slotStartTagSearch( QString artistName, QString trackName ) -{ - lastfm::MutableTrack track; - track.setArtist( artistName ); - track.setTitle( trackName ); - QNetworkReply *reply = track.getTags(); - connect( reply, SIGNAL(finished()), SLOT(slotTagsReceived()) ); -} - -void -SynchronizationAdapter::slotArtistsReceived() -{ - SemaphoreReleaser releaser( &m_semaphore ); - QNetworkReply *reply = qobject_cast( sender() ); - if( !reply ) - { - warning() << __PRETTY_FUNCTION__ << "cannot cast sender to QNetworkReply. (?)"; - return; - } - reply->deleteLater(); - - lastfm::XmlQuery lfm; - if( !lfm.parse( reply->readAll() ) ) - { - warning() << __PRETTY_FUNCTION__ << "Error parsing Last.fm reply:" << lfm.parseError().message(); - return; - } - lastfm::XmlQuery artists = lfm[ "artists" ]; - bool ok = false; - int page = artists.attribute( "page" ).toInt( &ok ); - if( !ok ) - { - warning() << __PRETTY_FUNCTION__ << "cannot read page number"; - return; - } - int totalPages = artists.attribute( "totalPages" ).toInt( &ok ); - if( !ok ) - { - warning() << __PRETTY_FUNCTION__ << "cannot read total number or pages"; - return; - } - debug() << __PRETTY_FUNCTION__ << "page" << page << "of" << totalPages; - - // following is based on lastfm::Artist::list(): - foreach( const lastfm::XmlQuery &xq, lfm.children( "artist" ) ) - { - lastfm::Artist artist( xq ); - m_artists.insert( artist.name() ); - } - - // Last.fm indexes from 1! - if( page < totalPages ) - { - releaser.dontRelease(); // don't release the semaphore yet - emit startArtistSearch( page + 1 ); - } -} - -void -SynchronizationAdapter::slotTracksReceived() -{ - SemaphoreReleaser releaser( &m_semaphore ); - QNetworkReply *reply = qobject_cast( sender() ); - if( !reply ) - { - warning() << __PRETTY_FUNCTION__ << "cannot cast sender to QNetworkReply. (?)"; - return; - } - reply->deleteLater(); - - lastfm::XmlQuery lfm; - if( !lfm.parse( reply->readAll() ) ) - { - warning() << __PRETTY_FUNCTION__ << "Error parsing Last.fm reply:" << lfm.parseError().message(); - return; - } - lastfm::XmlQuery tracks = lfm[ "tracks" ]; - bool ok = false; - int page = tracks.attribute( "page" ).toInt( &ok ); - if( !ok ) - { - warning() << __PRETTY_FUNCTION__ << "cannot read page number"; - return; - } - int totalPages = tracks.attribute( "totalPages" ).toInt( &ok ); - if( !ok ) - { - warning() << __PRETTY_FUNCTION__ << "cannot read total number or pages"; - return; - } - QString searchedArtist = tracks.attribute( "artist" ); - if( searchedArtist.isEmpty() ) - { - warning() << __PRETTY_FUNCTION__ << "searchedArtist in Last.fm reply is empty"; - return; - } - - // following is based on lastfm::Track::list(): - foreach( const lastfm::XmlQuery &xq, lfm.children( "track" ) ) - { - QString name = xq[ "name" ].text(); - int playCount = xq[ "playcount" ].text().toInt(); - int tagCount = xq[ "tagcount" ].text().toInt(); - QString artist = xq[ "artist" ][ "name" ].text(); - QString album = xq[ "album" ][ "name" ].text(); - - bool useRatings = m_config->useFancyRatingTags(); - StatSyncing::TrackPtr track( new SynchronizationTrack( artist, album, name, - playCount, useRatings ) ); - m_tracks.append( track ); - if( tagCount > 0 ) - m_tagQueue.append( track ); - } - - // Last.fm indexes from 1! - if( page < totalPages ) - { - releaser.dontRelease(); // don't release the semaphore yet - emit startTrackSearch( searchedArtist, page + 1 ); - } -} - -void -SynchronizationAdapter::slotTagsReceived() -{ - SemaphoreReleaser releaser( &m_semaphore ); - QNetworkReply *reply = qobject_cast( sender() ); - if( !reply ) - { - warning() << __PRETTY_FUNCTION__ << "cannot cast sender to QNetworkReply. (?)"; - return; - } - reply->deleteLater(); - - lastfm::XmlQuery lfm; - if( !lfm.parse( reply->readAll() ) ) - { - warning() << __PRETTY_FUNCTION__ << "Error parsing Last.fm reply:" << lfm.parseError().message(); - return; - } - QSet tags; - foreach( const lastfm::XmlQuery &xq, lfm.children( "tag" ) ) - { - tags.insert( xq[ "name" ].text() ); - } - Q_ASSERT( !m_tagQueue.isEmpty() ); - SynchronizationTrack *track = dynamic_cast( m_tagQueue.first().data() ); - Q_ASSERT( track ); - track->parseAndSaveLastFmTags( tags ); -} diff --git a/amarok/src/services/lastfm/SynchronizationAdapter.h b/amarok/src/services/lastfm/SynchronizationAdapter.h deleted file mode 100644 index 3908d746..00000000 --- a/amarok/src/services/lastfm/SynchronizationAdapter.h +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef SYNCHRONIZATIONADAPTER_H -#define SYNCHRONIZATIONADAPTER_H - -#include "services/lastfm/LastFmServiceConfig.h" -#include "statsyncing/Provider.h" - -#include - -class LastFmServiceConfig; - -class SynchronizationAdapter : public StatSyncing::Provider -{ - Q_OBJECT - - public: - /** - * @param user Last.fm username - */ - SynchronizationAdapter( const LastFmServiceConfigPtr &config ); - virtual ~SynchronizationAdapter(); - - virtual QString id() const; - virtual QString prettyName() const; - virtual QString description() const; - virtual KIcon icon() const; - virtual qint64 reliableTrackMetaData() const; - virtual qint64 writableTrackStatsData() const; - virtual Preference defaultPreference(); - virtual QSet artists(); - virtual StatSyncing::TrackList artistTracks( const QString &artistName ); - - signals: - /// hacks to create and start Last.fm queries in main eventloop - // Last.fm indexes from 1! - void startArtistSearch( int page ); - void startTrackSearch( QString artistName, int page ); - void startTagSearch( QString artistName, QString trackName ); - - private slots: - /// @see startArtistSearch - void slotStartArtistSearch( int page ); - void slotStartTrackSearch( QString artistName, int page ); - void slotStartTagSearch( QString artistName, QString trackName ); - - void slotArtistsReceived(); - void slotTracksReceived(); - void slotTagsReceived(); - - private: - LastFmServiceConfigPtr m_config; - - /** - * number of artist or track entries to request from Last.fm in earch webservice - * query. Last.fm default is 50; the greater the number, the faster the fetching - * (of long lists) is. On the other hand, Last.fm has own limit, 200 works well. - */ - static const int s_entriesPerQuery; - - QSet m_artists; - StatSyncing::TrackList m_tracks; - StatSyncing::TrackList m_tagQueue; // tracks waiting to be assigned tags - /** - * Semaphore for the simplified producer-consumer pattern, where - * slotArtistsReceived() is producer and artist() is consumer, or - * slotTracksReceived() is producer and artistTracks() is consumer, or - * slotTagsReceived() is producer and artistTracks() is consumer. - */ - QSemaphore m_semaphore; -}; - -#endif // SYNCHRONIZATIONADAPTER_H diff --git a/amarok/src/services/lastfm/SynchronizationTrack.cpp b/amarok/src/services/lastfm/SynchronizationTrack.cpp deleted file mode 100644 index 39c23c7e..00000000 --- a/amarok/src/services/lastfm/SynchronizationTrack.cpp +++ /dev/null @@ -1,255 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "SynchronizationTrack.h" - -#include "core/support/Debug.h" -#include "core/support/SemaphoreReleaser.h" - -#include -#include - -#include -#include - -SynchronizationTrack::SynchronizationTrack( QString artist, QString album, QString name, - int playCount, bool useFancyRatingTags ) - : m_artist( artist ) - , m_album( album ) - , m_name( name ) - , m_rating( 0 ) - , m_newRating( 0 ) - , m_playCount( playCount ) - , m_useFancyRatingTags( useFancyRatingTags ) -{ - // ensure this object is created in a main thread - Q_ASSERT( thread() == QCoreApplication::instance()->thread() ); - - connect( this, SIGNAL(startTagAddition(QStringList)), - SLOT(slotStartTagAddition(QStringList)) ); - connect( this, SIGNAL(startTagRemoval()), - SLOT(slotStartTagRemoval()) ); -} - -QString -SynchronizationTrack::name() const -{ - return m_name; -} - -QString -SynchronizationTrack::album() const -{ - return m_album; -} - -QString -SynchronizationTrack::artist() const -{ - return m_artist; -} - -int -SynchronizationTrack::rating() const -{ - return m_rating; -} - -void -SynchronizationTrack::setRating( int rating ) -{ - m_newRating = rating; -} - -QDateTime -SynchronizationTrack::firstPlayed() const -{ - return QDateTime(); // no support on Last.fm side yet -} - -QDateTime -SynchronizationTrack::lastPlayed() const -{ - return QDateTime(); // no support on Last.fm side yet -} - -int -SynchronizationTrack::playCount() const -{ - return m_playCount; -} - -QSet -SynchronizationTrack::labels() const -{ - return m_labels; -} - -void -SynchronizationTrack::setLabels( const QSet &labels ) -{ - m_newLabels = labels; -} - -void -SynchronizationTrack::commit() -{ - if( m_newRating == m_rating && m_newLabels == m_labels ) - return; - - const QSet existingLabels = m_labels | m_ratingLabels; - if( m_useFancyRatingTags ) - { - // implicitly we remove all ratingLabels here by not including them in m_newLabels - if( m_newRating > 0 ) - { - QString ratingLabel = QString( "%1 of 10 stars" ).arg( m_newRating ); - m_newLabels.insert( ratingLabel ); - m_ratingLabels = QSet() << ratingLabel; - } - } - else - m_newLabels |= m_ratingLabels; // preserve all rating labels - - QSet toAdd = m_newLabels - existingLabels; - QSet toRemove = existingLabels - m_newLabels; - - // first remove, than add Last.fm may limit number of track tags - if( !toRemove.isEmpty() ) - { - Q_ASSERT( m_semaphore.available() == 0 ); - m_tagsToRemove = toRemove.toList(); - emit startTagRemoval(); - m_semaphore.acquire(); // wait for the job to complete - m_tagsToRemove.clear(); - } - if( !toAdd.isEmpty() ) - { - Q_ASSERT( m_semaphore.available() == 0 ); - emit startTagAddition( toAdd.toList() ); - m_semaphore.acquire(); // wait for the job to complete - } - - m_rating = m_newRating; - m_labels = m_newLabels - m_ratingLabels; -} - -void -SynchronizationTrack::parseAndSaveLastFmTags( const QSet &tags ) -{ - m_labels.clear(); - m_ratingLabels.clear(); - m_rating = 0; - - // we still match and explicitly ignore rating tags even in m_useFancyRatingTags is false - QRegExp rx( "([0-9]{1,3}) of ([0-9]{1,3}) stars", Qt::CaseInsensitive ); - foreach( const QString &tag, tags ) - { - if( rx.exactMatch( tag ) ) - { - m_ratingLabels.insert( tag ); - QStringList texts = rx.capturedTexts(); - if( texts.count() != 3 ) - continue; - qreal numerator = texts.at( 1 ).toDouble(); - qreal denominator = texts.at( 2 ).toDouble(); - if( denominator == 0.0 ) - continue; - m_rating = qBound( 0, qRound( 10.0 * numerator / denominator ), 10 ); - } - else - m_labels.insert( tag ); - } - if( !m_useFancyRatingTags || m_ratingLabels.count() > 1 ) - m_rating = 0; // ambiguous or not requested - - m_newLabels = m_labels; - m_newRating = m_rating; -} - -void -SynchronizationTrack::slotStartTagAddition( QStringList tags ) -{ - lastfm::MutableTrack track; - track.setArtist( m_artist ); - track.setAlbum( m_album ); - track.setTitle( m_name ); - - if( tags.count() > 10 ) - tags = tags.mid( 0, 10 ); // Last.fm says 10 tags is max - QNetworkReply *reply = track.addTags( tags ); - connect( reply, SIGNAL(finished()), SLOT(slotTagsAdded()) ); -} - -void -SynchronizationTrack::slotStartTagRemoval() -{ - Q_ASSERT( m_tagsToRemove.count() ); - lastfm::MutableTrack track; - track.setArtist( m_artist ); - track.setAlbum( m_album ); - track.setTitle( m_name ); - - QNetworkReply *reply = track.removeTag( m_tagsToRemove.takeFirst() ); - connect( reply, SIGNAL(finished()), SLOT(slotTagRemoved()) ); -} - -void -SynchronizationTrack::slotTagsAdded() -{ - SemaphoreReleaser releaser( &m_semaphore ); - QNetworkReply *reply = qobject_cast( sender() ); - if( !reply ) - { - warning() << __PRETTY_FUNCTION__ << "cannot cast sender to QNetworkReply. (?)"; - return; - } - reply->deleteLater(); - - lastfm::XmlQuery lfm; - if( !lfm.parse( reply->readAll() ) ) - { - warning() << __PRETTY_FUNCTION__ << "error adding tags:" << lfm.parseError().message(); - return; - } -} - -void -SynchronizationTrack::slotTagRemoved() -{ - SemaphoreReleaser releaser( &m_semaphore ); - QNetworkReply *reply = qobject_cast( sender() ); - if( !reply ) - { - warning() << __PRETTY_FUNCTION__ << "cannot cast sender to QNetworkReply. (?)"; - return; - } - reply->deleteLater(); - - lastfm::XmlQuery lfm; - if( !lfm.parse( reply->readAll() ) ) - { - warning() << __PRETTY_FUNCTION__ << "error removing a tag:" << lfm.parseError().message(); - return; - } - - // remove the next one, sadly only one at a time can be removed - if( !m_tagsToRemove.isEmpty() ) - { - releaser.dontRelease(); - emit startTagRemoval(); - } -} diff --git a/amarok/src/services/lastfm/SynchronizationTrack.h b/amarok/src/services/lastfm/SynchronizationTrack.h deleted file mode 100644 index f79e22ff..00000000 --- a/amarok/src/services/lastfm/SynchronizationTrack.h +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef SYNCHRONIZATIONTRACK_H -#define SYNCHRONIZATIONTRACK_H - -#include "statsyncing/Track.h" - -#include - -/** - * A class that represents a track in Last.fm users library. Can be used to synchronize - * users's data with Last.fm through StatSyncing. - */ -class SynchronizationTrack : public QObject, public StatSyncing::Track -{ - Q_OBJECT - - public: - /** - * Create track used for synchronization with Last.fm. Can only be called from - * the main thread. - */ - SynchronizationTrack( QString artist, QString album, QString name, int playCount, bool useFancyRatingTags ); - - virtual QString name() const; - virtual QString album() const; - virtual QString artist() const; - virtual int rating() const; - virtual void setRating( int rating ); - virtual QDateTime firstPlayed() const; - virtual QDateTime lastPlayed() const; - virtual int playCount() const; - virtual QSet labels() const; - virtual void setLabels( const QSet &labels ); - virtual void commit(); - - /** - * Set tags from Last.fm, parse them into Amarok labels and rating - */ - void parseAndSaveLastFmTags( const QSet &tags ); - - signals: - /// hacks to create and start Last.fm queries in main eventloop - void startTagAddition( QStringList tags ); - void startTagRemoval(); - - private slots: - void slotStartTagAddition( QStringList tags ); - void slotStartTagRemoval(); - - void slotTagsAdded(); - void slotTagRemoved(); - - private: - QString m_artist; - QString m_album; - QString m_name; - int m_rating; - int m_newRating; - int m_playCount; - bool m_useFancyRatingTags; - QSet m_labels; - QSet m_newLabels; - QSet m_ratingLabels; - - QStringList m_tagsToRemove; - QSemaphore m_semaphore; -}; - -#endif // SYNCHRONIZATIONTRACK_H diff --git a/amarok/src/services/lastfm/amarok_lastfm_shared_export.h b/amarok/src/services/lastfm/amarok_lastfm_shared_export.h deleted file mode 100644 index 18261c1e..00000000 --- a/amarok/src/services/lastfm/amarok_lastfm_shared_export.h +++ /dev/null @@ -1,36 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Téo Mrnjavac * - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_LASTFM_SHARED_EXPORT_H -#define AMAROK_LASTFM_SHARED_EXPORT_H - -/* needed for KDE_EXPORT and KDE_IMPORT macros */ -#include - -#ifndef AMAROK_LASTFM_SHARED_EXPORT -# ifdef MAKE_AMAROK_SERVICE_LASTFM_SHARED_LIB - /* We are building this library */ -# define AMAROK_LASTFM_SHARED_EXPORT KDE_EXPORT - -# else - /* We are using this library */ -# define AMAROK_LASTFM_SHARED_EXPORT KDE_IMPORT - -# endif // MAKE_AMAROK_SERVICE_LASTFM_SHARED_LIB -#endif // AMAROK_LASTFM_SHARED_EXPORT - -#endif //AMAROK_LASTFM_SHARED_EXPORT_H diff --git a/amarok/src/services/lastfm/amarok_service_lastfm.desktop b/amarok/src/services/lastfm/amarok_service_lastfm.desktop deleted file mode 100644 index 5f6a2d6a..00000000 --- a/amarok/src/services/lastfm/amarok_service_lastfm.desktop +++ /dev/null @@ -1,126 +0,0 @@ -[Desktop Entry] -Type=Service -ServiceTypes=KPluginInfo -Icon=view-services-lastfm-amarok -Name=Last.fm -Name[bg]=Last.fm -Name[bs]=Last.fm -Name[ca]=Last.fm -Name[ca@valencia]=Last.fm -Name[cs]=Last.fm -Name[csb]=Last.fm -Name[da]=Last.fm -Name[de]=Last.fm -Name[el]=Last.fm -Name[en_GB]=Last.fm -Name[eo]=Last.fm -Name[es]=Last.fm -Name[et]=Last.fm -Name[eu]=Last.fm -Name[fi]=Last.fm -Name[fr]=Last.fm -Name[ga]=Last.fm -Name[gl]=Last.fm -Name[hu]=Last.fm -Name[id]=Last.fm -Name[is]=Last.fm -Name[it]=Last.fm -Name[ja]=Last.fm -Name[km]=Last.fm -Name[ko]=Last.fm -Name[lt]=Last.fm -Name[lv]=Last.fm -Name[nb]=Last.fm -Name[nds]=Last.fm -Name[nl]=Last.fm -Name[nn]=Last.fm -Name[pa]=Last.fm -Name[pl]=Last.fm -Name[pt]=Last.fm -Name[pt_BR]=Last.fm -Name[ro]=Last.fm -Name[ru]=Last.fm -Name[sk]=Last.fm -Name[sl]=Last.fm -Name[sq]=Last.fm -Name[sr]=ЛастФМ -Name[sr@ijekavian]=ЛастФМ -Name[sr@ijekavianlatin]=Last.fm -Name[sr@latin]=Last.fm -Name[sv]=Last.fm -Name[th]=บริการ Last.fm -Name[tr]=Last.fm -Name[ug]=Last.fm -Name[uk]=Last.fm -Name[wa]=Last.fm -Name[x-test]=xxLast.fmxx -Name[zh_CN]=Last.fm -Name[zh_TW]=Last.fm -Comment=A service that integrates Last.fm functionality into Amarok -Comment[bg]=Услуга, която вгражда Last.fm в Amarok -Comment[bs]=Servis koji ugrađuje LastFM‑ove mogućnosti u Amarok -Comment[ca]=Un servei que integra la funcionalitat de Last.fm en l'Amarok -Comment[ca@valencia]=Un servei que integra la funcionalitat de Last.fm en l'Amarok -Comment[cs]=Služba, která do Amaroku integruje funkcionalitu last.fm -Comment[da]=En tjeneste der integrerer Last.fm-funktionalitet i Amarok -Comment[de]=Ein Dienst zum Einbinden der Funktionen von Last.fm in Amarok -Comment[el]=Μία υπηρεσία που ενσωματώνει λειτουργίες του Last.fm στο Amarok -Comment[en_GB]=A service that integrates Last.fm functionality into Amarok -Comment[es]=Un servicio que integra la funcionalidad de Last.fm en Amarok -Comment[et]=Last.fm-i funktsioonid Amarokki lõimiv teenus -Comment[eu]=Last.fm-eko funtzionaltasuna Amarok.-en bateratzen duen zerbitzua -Comment[fi]=Last.fm-toiminnot Amarokiin yhdistävä palvelu -Comment[fr]=Un service intégrant des fonctionnalités de « Last.fm » dans Amarok -Comment[ga]=Seirbhís a chomhtháthaíonn feidhmiúlacht Last.fm le hAmarok -Comment[gl]=Un servizo que integra a funcionalidade de Last.fm en Amarok -Comment[hu]=A Last.fm funkcióit az Amarokba integráló szolgáltatás -Comment[id]=Layanan yang terintegrasi dengan Last.fm berfungsi di dalam Amarok -Comment[is]=Þjónusta sem fellir Last.fm aðgerðir inn í Amarok -Comment[it]=Un servizio che integra le funzionalità di Last.fm in Amarok -Comment[ja]=Last.fm の機能を Amarok に統合するサービス -Comment[km]=សេវា​ដែល​រួម​បញ្ចូល​មុខងារ Last.fm ទៅ​ក្នុង Amarok -Comment[ko]=Amarok에 last.fm 기능을 통합하는 서비스 -Comment[lt]=Ši tarnyba integruoja Last.fm funkcijas į Amaroką -Comment[lv]=Pakalpojums, kurš integrē last.fm atbalstu amarok -Comment[nb]=En tjeneste som integrerer funksjonalitet i Last.fm inn i Amarok -Comment[nds]=En Deenst, de Funkschonen vun "Last.fm" för Amarok praatstellt -Comment[nl]=Een dienst die Last.fm-functionaliteit in Amarok integreert -Comment[pl]=Usługa, która integruje funkcjonalność Last.fm z Amarokiem -Comment[pt]=Um serviço que integra a funcionalidade do Last.fm no Amarok -Comment[pt_BR]=Um serviço que adiciona a funcionalidade do Last.fm ao Amarok -Comment[ro]=Serviciu ce integrează funcționalitatea Last.fm în Amarok -Comment[ru]=Служба, добавляющая в Amarok взаимодействие с Last.fm -Comment[sk]=Služba, ktorá integruje funkcionalitu Last.fm do Amaroku -Comment[sl]=Storitev, ki vgradi zmožnosti Last.fm v Amarok -Comment[sr]=Сервис који уграђује ЛастФМ‑ове могућности у Амарок -Comment[sr@ijekavian]=Сервис који уграђује ЛастФМ‑ове могућности у Амарок -Comment[sr@ijekavianlatin]=Servis koji ugrađuje last.fm‑ove mogućnosti u Amarok -Comment[sr@latin]=Servis koji ugrađuje last.fm‑ove mogućnosti u Amarok -Comment[sv]=En tjänst som integrerar funktioner från Last.fm i Amarok -Comment[tr]=Last.fm işlevlerini Amarok ile bütünleştiren bir hizmet -Comment[uk]=Служба, яка інтегрує функціональність Last.fm до Amarok -Comment[x-test]=xxA service that integrates Last.fm functionality into Amarokxx -Comment[zh_CN]=一个在 Amarok 中集成 Last.fm 功能的服务 -Comment[zh_TW]=一種將 Last.fm 其功能性整合到 Amarok 中的服務 - - -ServiceTypes=Amarok/Plugin - -X-KDE-Library=amarok_service_lastfm - -X-KDE-Amarok-authors=Shane King -X-KDE-Amarok-email=kde@dontletsstart.com -X-KDE-Amarok-framework-version=72 -X-KDE-Amarok-name=LastFmService -X-KDE-Amarok-plugintype=service -X-KDE-Amarok-rank=100 -X-KDE-Amarok-version=1 - -X-KDE-PluginInfo-Author=Shane King -X-KDE-PluginInfo-Email=kde@dontletsstart.com -X-KDE-PluginInfo-Version=1.0 -X-KDE-PluginInfo-Category=Service -X-KDE-PluginInfo-License=GPL -X-KDE-PluginInfo-EnabledByDefault=true -X-KDE-Library=amarok_service_lastfm -X-KDE-PluginInfo-Name=amarok_service_lastfm diff --git a/amarok/src/services/lastfm/amarok_service_lastfm_config.desktop b/amarok/src/services/lastfm/amarok_service_lastfm_config.desktop deleted file mode 100644 index 110a079c..00000000 --- a/amarok/src/services/lastfm/amarok_service_lastfm_config.desktop +++ /dev/null @@ -1,119 +0,0 @@ -[Desktop Entry] -Icon=view-services-lastfm-amarok -Type=Service -ServiceTypes=Amarok/Plugin -X-KDE-ServiceTypes=KCModule - -X-KDE-Library=kcm_amarok_service_lastfm -X-KDE-ParentApp=amarok_service_lastfm -X-KDE-ParentComponents=amarok_service_lastfm - -Name=Last.fm Service Config -Name[be]=Настаўленне сервісу Last.fm -Name[bg]=Настройване на Last.fm -Name[bs]=Postavke Last.fm servisa -Name[ca]=Configuració del servei Last.fm -Name[ca@valencia]=Configuració del servei Last.fm -Name[cs]=Nastavení služby last.fm -Name[csb]=Kònfigùracëjô ùsłëżnotë Last.fm -Name[da]=Konfiguration af Last.fm-tjeneste -Name[de]=Einrichtung von Last.fm -Name[el]=Διαμόρφωση της υπηρεσίας Last.fm -Name[en_GB]=Last.fm Service Config -Name[eo]=Last.fm Serva Agordo -Name[es]=Configurar servicio Last.fm -Name[et]=Last.fm-i teenuse seadistamine -Name[eu]=Last.fm zerbitzuaren konfigurazioa -Name[fi]=Last.fm-palvelumääritykset -Name[fr]=Configuration du service « Last.fm » -Name[ga]=Cumraíocht Sheirbhís Last.fm -Name[gl]=Configuración do servizo Last.fm -Name[he]=הגדרת שירות Last.fm -Name[hne]=लास्ट.एफएम सेवा कान्फिग -Name[hu]=Last.fm szolgáltatás beállítása -Name[id]=Konfig Layanan Last.fm -Name[is]=Stillingar Last.fm þjónustu -Name[it]=Configurazione servizio Last.fm -Name[ja]=Last.fm サービスの設定 -Name[km]=កំណត់​រចនាសម្ព័ន្ធ​​សេវា Last.fm -Name[ko]=Last.fm 서비스 설정 -Name[ku]=Veavakirina Servisa Last.fm -Name[lt]=Last.fm tarnybos parinktys -Name[lv]=Last.gm pakalpojuma konfigurācija -Name[nb]=Innstillinger for last.fm -Name[nds]=Last.fm-Deenstinstellen -Name[nl]=Last.fm-dienst instellen -Name[nn]=Set opp Last.fm-teneste -Name[pa]=Last.fm ਸਰਵਿਸ ਸੰਰਚਨਾ -Name[pl]=Ustawienia usługi Last.fm -Name[pt]=Configuração do Serviço do Last.fm -Name[pt_BR]=Configuração do serviço Last.fm -Name[ro]=Configurare serviciu Last.fm -Name[ru]=Настройка службы Last.fm -Name[sk]=Konfigurácia služby Last.fm -Name[sl]=Nastavitev storitve Last.fm -Name[sr]=Поставке ЛастФМ‑овог сервиса -Name[sr@ijekavian]=Поставке ЛастФМ‑овог сервиса -Name[sr@ijekavianlatin]=Postavke last.fm‑ovog servisa -Name[sr@latin]=Postavke last.fm‑ovog servisa -Name[sv]=Inställning av Last.fm-tjänst -Name[th]=ปรับแต่งบริการ Last.fm -Name[tr]=Last.fm Hizmet Yapılandırması -Name[uk]=Налаштування служби Last.fm -Name[wa]=Apontiaedje do siervice Last.fm -Name[x-test]=xxLast.fm Service Configxx -Name[zh_CN]=Last.fm 服务配置 -Name[zh_TW]=Last.fm 服務設定 -Comment=Set up Last.fm username and password -Comment[bg]=Настройване на потребител и парола за Last.fm -Comment[bs]=Podesite korisničko ime i lozinku na LastFM‑u -Comment[ca]=Defineix el nom d'usuari i contrasenya del Last.fm -Comment[ca@valencia]=Defineix el nom d'usuari i contrasenya del Last.fm -Comment[cs]=Nastavit uživatelské jméno a heslo pro last.fm -Comment[csb]=Nastôwi miono brëkòwnika ë parolã z Last.fm -Comment[da]=Sæt brugernavn og adgangskode til Last.fm -Comment[de]=Einrichtung von Benutzername und Passwort für Last.fm -Comment[el]=Ορισμός του ονόματος χρήστη και κωδικού πρόσβασης του Last.fm -Comment[en_GB]=Set up Last.fm username and password -Comment[es]=Configurar el usuario y contraseña de Last.fm -Comment[et]=Last.fm-i kasutajanime ja parooli määramine -Comment[eu]=Konfiguratu Last.fm webguneko erabiltzaile-izena eta pasahitza -Comment[fi]=Määritä käyttäjätunnus ja salasana Last.fm-palveluun -Comment[fr]=Définir les nom d'utilisateur et mot de passe pour « Last.fm » -Comment[ga]=Socraigh ainm úsáideora agus focal faire Last.fm -Comment[gl]=Configura o nome de usuario e contrasinal de Last.fm -Comment[hne]=लास्ट.एफएम कमइया-नाम अउ पासवर्ड सेट करव -Comment[hu]=Last.fm-felhasználónév és -jelszó beállítása -Comment[id]=Persiapan nama pengguna dan kata sandi di Last.fm -Comment[is]=Setja upp Last.fm notendanafn og lykilorð -Comment[it]=Configura nome utente e password Last.fm -Comment[ja]=Last.fm のユーザ名とパスワードを設定 -Comment[km]=រៀបចំ​​ឈ្មោះ​អ្នក​ប្រើ និង​ពាក្យ​សម្ងាត់​របស់ Last.fm -Comment[ko]=Last.fm 사용자 이름과 암호 설정 -Comment[ku]=Navê bikarhêner û şîfreya Last.fm ava bike -Comment[lt]=Nurodyti last.fm naudotojo vardą ir slaptažodį -Comment[lv]=Uzstādīt Last.fm lietotāja vārdu un paroli -Comment[nb]=Innstillinger for brukernavn og passord i last.fm -Comment[nds]=Brukernaam un Passwoort för Last.fm fastleggen -Comment[nl]=Stel de gebruikersnaam en het wachtwoord voor Last.fm in -Comment[nn]=Set opp brukarnamn og passord til Last.fm -Comment[pa]=Last.fm ਯੂਜ਼ਰ ਨਾਂ ਅਤੇ ਪਾਸਵਰਡ ਸੈੱਟ ਕਰੋ -Comment[pl]=Ustaw nazwę użytkownika i hasło Last.fm -Comment[pt]=Configurar o utilizador e a senha do Last.fm -Comment[pt_BR]=Configura o nome de usuário e senha do Last.fm -Comment[ro]=Configurează utilizatorul și parola Last.fm -Comment[ru]=Укажите имя пользователя Last.fm и пароль -Comment[sk]=Nastaviť používateľské meno a heslo pre Last.fm -Comment[sl]=Nastavite uporabniško ime in geslo za Last.fm -Comment[sr]=Подесите корисничко име и лозинку на ЛастФМ‑у -Comment[sr@ijekavian]=Подесите корисничко име и лозинку на ЛастФМ‑у -Comment[sr@ijekavianlatin]=Podesite korisničko ime i lozinku na last.fm‑u -Comment[sr@latin]=Podesite korisničko ime i lozinku na last.fm‑u -Comment[sv]=Ställ in Last.fm användarnamn och lösenord -Comment[th]=ตั้งค่าชื่อผู้ใช้และรหัสผ่านของบริการ Last.fm -Comment[tr]=Last.fm kullanıcı adı ve parolasını ayarlar -Comment[uk]=Встановіть назву користувача і пароль Last.fm -Comment[wa]=Apontyî no d' uzeu eyet sicret di Last.fm -Comment[x-test]=xxSet up Last.fm username and passwordxx -Comment[zh_CN]=设置 Last.fm 的用户名和密码 -Comment[zh_TW]=設定 Last.fm 的使用者名稱與密碼 diff --git a/amarok/src/services/lastfm/amaroklastfm.protocol b/amarok/src/services/lastfm/amaroklastfm.protocol deleted file mode 100644 index 1e6d65dc..00000000 --- a/amarok/src/services/lastfm/amaroklastfm.protocol +++ /dev/null @@ -1,11 +0,0 @@ -[Protocol] -exec=amarok "%u" -protocol=lastfm -input=none -output=none -helper=true -listing= -reading=false -writing=false -makedir=false -deleting=false diff --git a/amarok/src/services/lastfm/biases/LastFmBias.cpp b/amarok/src/services/lastfm/biases/LastFmBias.cpp deleted file mode 100644 index 5b16c6f2..00000000 --- a/amarok/src/services/lastfm/biases/LastFmBias.cpp +++ /dev/null @@ -1,693 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Leo Franchi * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "LastFmBias" - -#include "LastFmBias.h" - -#include "core/meta/Meta.h" -#include "core/support/Amarok.h" -#include "core/support/Debug.h" -#include "core-impl/collections/support/CollectionManager.h" - -#include -#include - - -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include - -QString -Dynamic::LastFmBiasFactory::i18nName() const -{ return i18nc("Name of the \"Last.fm\" similar bias", "Last.fm similar"); } - -QString -Dynamic::LastFmBiasFactory::name() const -{ return Dynamic::LastFmBias::sName(); } - -QString -Dynamic::LastFmBiasFactory::i18nDescription() const -{ return i18nc("Description of the \"Last.fm\" bias", - "The \"Last.fm\" similar bias looks up tracks on Last.fm and only adds similar tracks."); } - -Dynamic::BiasPtr -Dynamic::LastFmBiasFactory::createBias() -{ return Dynamic::BiasPtr( new Dynamic::LastFmBias() ); } - - - -// ----- LastFmBias -------- - -Dynamic::LastFmBias::LastFmBias() - : SimpleMatchBias() - , m_match( SimilarArtist ) - , m_mutex( QMutex::Recursive ) -{ - loadDataFromFile(); -} - -Dynamic::LastFmBias::~LastFmBias() -{ - // TODO: kill all running queries -} - -void -Dynamic::LastFmBias::fromXml( QXmlStreamReader *reader ) -{ - while (!reader->atEnd()) { - reader->readNext(); - - if( reader->isStartElement() ) - { - QStringRef name = reader->name(); - if( name == "match" ) - m_match = matchForName( reader->readElementText(QXmlStreamReader::SkipChildElements) ); - else - { - debug()<<"Unexpected xml start element"<name()<<"in input"; - reader->skipCurrentElement(); - } - } - else if( reader->isEndElement() ) - { - break; - } - } -} - -void -Dynamic::LastFmBias::toXml( QXmlStreamWriter *writer ) const -{ - writer->writeTextElement( "match", nameForMatch( m_match ) ); -} - -QString -Dynamic::LastFmBias::sName() -{ - return "lastfm_similarartists"; -} - -QString -Dynamic::LastFmBias::name() const -{ - return Dynamic::LastFmBias::sName(); -} - -QString -Dynamic::LastFmBias::toString() const -{ - switch( m_match ) - { - case SimilarTrack: - return i18nc("Last.fm bias representation", - "Similar to the previous track (as reported by Last.fm)"); - case SimilarArtist: - return i18nc("Last.fm bias representation", - "Similar to the previous artist (as reported by Last.fm)"); - } - return QString(); -} - - -QWidget* -Dynamic::LastFmBias::widget( QWidget* parent ) -{ - QWidget *widget = new QWidget( parent ); - QVBoxLayout *layout = new QVBoxLayout( widget ); - - QLabel *imageLabel = new QLabel(); - imageLabel->setPixmap( QPixmap( KStandardDirs::locate( "data", "amarok/images/lastfm.png" ) ) ); - QLabel *label = new QLabel( i18n( "Last.fm thinks the track is similar to" ) ); - - QRadioButton *rb1 = new QRadioButton( i18n( "the previous track's artist" ) ); - QRadioButton *rb2 = new QRadioButton( i18n( "the previous track" ) ); - - rb1->setChecked( m_match == SimilarArtist ); - rb2->setChecked( m_match == SimilarTrack ); - - connect( rb1, SIGNAL(toggled(bool)), - this, SLOT(setMatchTypeArtist(bool)) ); - - layout->addWidget( imageLabel ); - layout->addWidget( label ); - layout->addWidget( rb1 ); - layout->addWidget( rb2 ); - - return widget; -} - -Dynamic::TrackSet -Dynamic::LastFmBias::matchingTracks( const Meta::TrackList& playlist, - int contextCount, int finalCount, - Dynamic::TrackCollectionPtr universe ) const -{ - Q_UNUSED( contextCount ); - Q_UNUSED( finalCount ); - - if( playlist.isEmpty() ) - return Dynamic::TrackSet( universe, true ); - - // determine the last track and artist - Meta::TrackPtr lastTrack = playlist.last(); - Meta::ArtistPtr lastArtist = lastTrack->artist(); - - m_currentTrack = lastTrack->name(); - m_currentArtist = lastArtist ? lastArtist->name() : QString(); - - { - QMutexLocker locker( &m_mutex ); - - if( m_match == SimilarArtist ) - { - if( m_currentArtist.isEmpty() ) - return Dynamic::TrackSet( universe, true ); - if( m_tracksMap.contains( m_currentArtist ) ) - return m_tracksMap.value( m_currentArtist ); - } - else if( m_match == SimilarTrack ) - { - if( m_currentTrack.isEmpty() ) - return Dynamic::TrackSet( universe, true ); - QString key = m_currentTrack + '|' + m_currentArtist; - if( m_tracksMap.contains( key ) ) - return m_tracksMap.value( key ); - } - } - - m_tracks = Dynamic::TrackSet( universe, false ); - QTimer::singleShot(0, - const_cast(this), - SLOT(newQuery())); // create the new query from my parent thread - - return Dynamic::TrackSet(); -} - - -bool -Dynamic::LastFmBias::trackMatches( int position, - const Meta::TrackList& playlist, - int contextCount ) const -{ - Q_UNUSED( contextCount ); - - if( position <= 0 || position >= playlist.count()) - return false; - - // determine the last track and artist - Meta::TrackPtr lastTrack = playlist[position-1]; - Meta::ArtistPtr lastArtist = lastTrack->artist(); - QString lastTrackName = lastTrack->name(); - QString lastArtistName = lastArtist ? lastArtist->name() : QString(); - - Meta::TrackPtr currentTrack = playlist[position]; - Meta::ArtistPtr currentArtist = currentTrack->artist(); - QString currentTrackName = currentTrack->name(); - QString currentArtistName = currentArtist ? currentArtist->name() : QString(); - - { - QMutexLocker locker( &m_mutex ); - - if( m_match == SimilarArtist ) - { - if( lastArtistName.isEmpty() ) - return true; - if( currentArtistName.isEmpty() ) - return false; - if( lastArtistName == currentArtistName ) - return true; - if( m_similarArtistMap.contains( lastArtistName ) ) - return m_similarArtistMap.value( lastArtistName ).contains( currentArtistName ); - } - else if( m_match == SimilarTrack ) - { - if( lastTrackName.isEmpty() ) - return true; - if( currentTrackName.isEmpty() ) - return false; - if( lastTrackName == currentTrackName ) - return true; - TitleArtistPair lastKey( lastTrackName, lastArtistName ); - TitleArtistPair currentKey( currentTrackName, currentArtistName ); - if( m_similarTrackMap.contains( lastKey ) ) - return m_similarTrackMap.value( lastKey ).contains( currentKey ); - } - } - - debug() << "didn't have a cached suggestions for track:" << lastTrackName; - return false; -} - - -void -Dynamic::LastFmBias::invalidate() -{ - SimpleMatchBias::invalidate(); - m_tracksMap.clear(); -} - -void -Dynamic::LastFmBias::newQuery() -{ - DEBUG_BLOCK; - - debug() << "similarArtists:"< similarTracks; - { - QMutexLocker locker( &m_mutex ); - if( m_match == SimilarArtist ) - { - if( m_similarArtistMap.contains( m_currentArtist ) ) - { - similarArtists = m_similarArtistMap.value( m_currentArtist ); - debug() << "for"<queryMaker() ); - - // - construct the query - m_qm->beginOr(); - if( m_match == SimilarArtist ) - { - foreach( const QString &name, similarArtists ) - { - m_qm->addFilter( Meta::valArtist, name, true, true ); - } - } - else if( m_match == SimilarTrack ) - { - foreach( const TitleArtistPair &name, similarTracks ) - { - m_qm->beginAnd(); - m_qm->addFilter( Meta::valTitle, name.first, true, true ); - m_qm->addFilter( Meta::valArtist, name.second, true, true ); - m_qm->endAndOr(); - } - } - m_qm->endAndOr(); - - m_qm->setQueryType( Collections::QueryMaker::Custom ); - m_qm->addReturnValue( Meta::valUniqueId ); - - connect( m_qm.data(), SIGNAL(newResultReady(QStringList)), - this, SLOT(updateReady(QStringList)) ); - connect( m_qm.data(), SIGNAL(queryDone()), - this, SLOT(updateFinished()) ); - - // - run the query - m_qm.data()->run(); -} - - -void Dynamic::LastFmBias::newSimilarQuery() -{ - DEBUG_BLOCK - - QMap< QString, QString > params; - // params[ "limit" ] = "70"; - if( m_match == SimilarArtist ) - { - params[ "method" ] = "artist.getSimilar"; - params[ "artist" ] = m_currentArtist; - QNetworkReply* request = lastfm::ws::get( params ); - connect( request, SIGNAL(finished()), - this, SLOT(similarArtistQueryDone()) ); - } - else if( m_match == SimilarTrack ) - { - // if( track->mb - // TODO add mbid if the track has one - params[ "method" ] = "track.getSimilar"; - params[ "artist" ] = m_currentArtist; - params[ "track" ] = m_currentTrack; - QNetworkReply* request = lastfm::ws::get( params ); - connect( request, SIGNAL(finished()), - this, SLOT(similarTrackQueryDone()) ); - } -} - - -void -Dynamic::LastFmBias::similarArtistQueryDone() // slot -{ - DEBUG_BLOCK - - QNetworkReply* reply = qobject_cast(sender()); - - if( !reply ) - { - queryFailed( "job was deleted from under us...wtf! blame the gerbils." ); - return; - } - reply->deleteLater(); - - QByteArray data = reply->readAll(); -// debug() << "artistQuery has data:" << data; - QDomDocument d; - if( !d.setContent( data ) ) - { - queryFailed( "Got invalid XML data from last.fm!" ); - return; - } - - QDomNodeList nodes = d.elementsByTagName( "artist" ); - QStringList similarArtists; - for( int i =0; i < nodes.size(); ++i ) - { - QDomElement n = nodes.at( i ).toElement(); - // n.firstChildElement( "match" ).text().toFloat() * 100, - similarArtists.append( n.firstChildElement( "name" ).text() ); - } - - QMutexLocker locker( &m_mutex ); - - m_similarArtistMap.insert( m_currentArtist, similarArtists ); - - saveDataToFile(); - - // -- try again to do the query - newQuery(); -} - -void Dynamic::LastFmBias::similarTrackQueryDone() -{ - DEBUG_BLOCK - - QNetworkReply* reply = qobject_cast(sender()); - - if( !reply ) - { - queryFailed( "who send this...wtf! blame the gerbils." ); - return; - } - reply->deleteLater(); - - // double match value, qpair title - artist - QMap< int, QPair > similar; - QByteArray data = reply->readAll(); -// debug() << "trackQuery has data:" << data; - QDomDocument d; - if( !d.setContent( data ) ) - { - queryFailed( "Got invalid XML data from last.fm!" ); - return; - } - - QDomNodeList nodes = d.elementsByTagName( "track" ); - QList similarTracks; - for( int i =0; i < nodes.size(); ++i ) - { - QDomElement n = nodes.at( i ).toElement(); - // n.firstChildElement( "match" ).text().toFloat() * 100, - TitleArtistPair pair( n.firstChildElement( "name" ).text(), - n.firstChildElement( "artist" ).firstChildElement( "name" ).text() ); - similarTracks.append( pair ); - } - - QMutexLocker locker( &m_mutex ); - - TitleArtistPair key( m_currentTrack, m_currentArtist ); - m_similarTrackMap.insert( key, similarTracks ); - - saveDataToFile(); - - // -- try again to do the query - newQuery(); -} - - -void -Dynamic::LastFmBias::queryFailed( const char *message ) -{ - debug() << message; - - m_tracks.reset( false ); - emit resultReady( m_tracks ); - return; -} - - -void -Dynamic::LastFmBias::saveDataToFile() const -{ - QFile file( Amarok::saveLocation() + "dynamic_lastfm_similar.xml" ); - if( !file.open( QIODevice::WriteOnly | QIODevice::Truncate ) ) - return; - - QXmlStreamWriter writer( &file ); - writer.setAutoFormatting( true ); - - writer.writeStartDocument(); - writer.writeStartElement( QLatin1String("lastfmSimilar") ); - - // -- write the similar artists - foreach( const QString& key, m_similarArtistMap.keys() ) - { - writer.writeStartElement( QLatin1String("similarArtist") ); - writer.writeTextElement( QLatin1String("artist"), key ); - foreach( const QString& name, m_similarArtistMap.value( key ) ) - { - writer.writeTextElement( QLatin1String("similar"), name ); - } - writer.writeEndElement(); - } - - // -- write the similar tracks - foreach( const TitleArtistPair& key, m_similarTrackMap.keys() ) - { - writer.writeStartElement( QLatin1String("similarTrack") ); - writer.writeStartElement( QLatin1String("track") ); - writer.writeTextElement( QLatin1String("title"), key.first ); - writer.writeTextElement( QLatin1String("artist"), key.second ); - writer.writeEndElement(); - - foreach( const TitleArtistPair& name, m_similarTrackMap.value( key ) ) - { - writer.writeStartElement( QLatin1String("similar") ); - writer.writeTextElement( QLatin1String("title"), name.first ); - writer.writeTextElement( QLatin1String("artist"), name.second ); - writer.writeEndElement(); - } - writer.writeEndElement(); - } - - writer.writeEndElement(); - writer.writeEndDocument(); -} - -void -Dynamic::LastFmBias::readSimilarArtists( QXmlStreamReader *reader ) -{ - QString key; - QList artists; - - while (!reader->atEnd()) { - reader->readNext(); - QStringRef name = reader->name(); - - if( reader->isStartElement() ) - { - if( name == QLatin1String("artist") ) - key = reader->readElementText(QXmlStreamReader::SkipChildElements); - else if( name == QLatin1String("similar") ) - artists.append( reader->readElementText(QXmlStreamReader::SkipChildElements) ); - else - reader->skipCurrentElement(); - } - else if( reader->isEndElement() ) - { - break; - } - } - - m_similarArtistMap.insert( key, artists ); -} - -Dynamic::LastFmBias::TitleArtistPair -Dynamic::LastFmBias::readTrack( QXmlStreamReader *reader ) -{ - TitleArtistPair track; - - while (!reader->atEnd()) { - reader->readNext(); - QStringRef name = reader->name(); - - if( reader->isStartElement() ) - { - if( name == QLatin1String("title") ) - track.first = reader->readElementText(QXmlStreamReader::SkipChildElements); - else if( name == QLatin1String("artist") ) - track.second = reader->readElementText(QXmlStreamReader::SkipChildElements); - else - reader->skipCurrentElement(); - } - else if( reader->isEndElement() ) - { - break; - } - } - - return track; -} - -void -Dynamic::LastFmBias::readSimilarTracks( QXmlStreamReader *reader ) -{ - TitleArtistPair key; - QList tracks; - - while (!reader->atEnd()) { - reader->readNext(); - QStringRef name = reader->name(); - - if( reader->isStartElement() ) - { - if( name == QLatin1String("track") ) - key = readTrack( reader ); - else if( name == QLatin1String("similar") ) - tracks.append( readTrack( reader ) ); - else - reader->skipCurrentElement(); - } - else if( reader->isEndElement() ) - { - break; - } - } - - m_similarTrackMap.insert( key, tracks ); -} - -void -Dynamic::LastFmBias::loadDataFromFile() -{ - m_similarArtistMap.clear(); - m_similarTrackMap.clear(); - - QFile file( Amarok::saveLocation() + "dynamic_lastfm_similar.xml" ); - - if( !file.exists() || - !file.open( QIODevice::ReadOnly ) ) - return; - - QXmlStreamReader reader( &file ); - - while (!reader.atEnd()) { - reader.readNext(); - - QStringRef name = reader.name(); - if( reader.isStartElement() ) - { - if( name == QLatin1String("lastfmSimilar") ) - { - ; // just recurse into the element - } - else if( name == QLatin1String("similarArtist") ) - { - readSimilarArtists( &reader ); - } - else if( name == QLatin1String("similarTrack") ) - { - readSimilarTracks( &reader ); - } - else - { - reader.skipCurrentElement(); - } - } - else if( reader.isEndElement() ) - { - break; - } - } -} - -Dynamic::LastFmBias::MatchType -Dynamic::LastFmBias::match() const -{ return m_match; } - -void -Dynamic::LastFmBias::setMatch( Dynamic::LastFmBias::MatchType value ) -{ - m_match = value; - invalidate(); - emit changed( BiasPtr(this) ); -} - -void -Dynamic::LastFmBias::setMatchTypeArtist( bool matchArtist ) -{ - setMatch( matchArtist ? SimilarArtist : SimilarTrack ); -} - -QString -Dynamic::LastFmBias::nameForMatch( Dynamic::LastFmBias::MatchType match ) -{ - switch( match ) - { - case SimilarArtist: return "artist"; - case SimilarTrack: return "track"; - } - return QString(); -} - -Dynamic::LastFmBias::MatchType -Dynamic::LastFmBias::matchForName( const QString &name ) -{ - if( name == "artist" ) return SimilarArtist; - else if( name == "track" ) return SimilarTrack; - else return SimilarArtist; -} - - - - -#include "moc_LastFmBias.cpp" diff --git a/amarok/src/services/lastfm/biases/LastFmBias.h b/amarok/src/services/lastfm/biases/LastFmBias.h deleted file mode 100644 index b7b18282..00000000 --- a/amarok/src/services/lastfm/biases/LastFmBias.h +++ /dev/null @@ -1,119 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Leo Franchi * - * Copyright (c) 2011 Ralf Engels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef LASTFM_BIAS_H -#define LASTFM_BIAS_H - -#include "dynamic/biases/TagMatchBias.h" - -#include - -namespace Dynamic -{ - - /** This is a bias which adds the suggested songs to the playlist. */ - class LastFmBias : public SimpleMatchBias - { - Q_OBJECT - - public: - - /** The tracks that are used for the matching */ - enum MatchType - { - SimilarArtist, - SimilarTrack - }; - - LastFmBias(); - ~LastFmBias(); - - virtual void fromXml( QXmlStreamReader *reader ); - virtual void toXml( QXmlStreamWriter *writer ) const; - - static QString sName(); - virtual QString name() const; - virtual QString toString() const; - - virtual QWidget* widget( QWidget* parent = 0 ); - - virtual Dynamic::TrackSet matchingTracks( const Meta::TrackList& playlist, - int contextCount, int finalCount, - Dynamic::TrackCollectionPtr universe ) const; - - virtual bool trackMatches( int position, - const Meta::TrackList& playlist, - int contextCount ) const; - - - MatchType match() const; - void setMatch( MatchType value ); - - public slots: - virtual void invalidate(); - - private slots: - virtual void newQuery(); - virtual void newSimilarQuery(); - - void similarArtistQueryDone(); - void similarTrackQueryDone(); - void queryFailed( const char *message ); - - void setMatchTypeArtist( bool matchArtist ); - - private: - /** The pair is used for the tracks */ - typedef QPair TitleArtistPair; - - static QString nameForMatch( MatchType match ); - static MatchType matchForName( const QString &name ); - - void saveDataToFile() const; - - void readSimilarArtists( QXmlStreamReader *reader ); - TitleArtistPair readTrack( QXmlStreamReader *reader ); - void readSimilarTracks( QXmlStreamReader *reader ); - void loadDataFromFile(); - - mutable QString m_currentArtist; - mutable QString m_currentTrack; - - MatchType m_match; - - mutable QMutex m_mutex; // mutex protecting all of the below structures - mutable QMap< QString, QStringList> m_similarArtistMap; - mutable QMap< TitleArtistPair, QList > m_similarTrackMap; - mutable QMap< QString, TrackSet> m_tracksMap; // for artist AND album - - private: - Q_DISABLE_COPY(LastFmBias) - }; - - - class LastFmBiasFactory : public Dynamic::AbstractBiasFactory - { - public: - virtual QString i18nName() const; - virtual QString name() const; - virtual QString i18nDescription() const; - virtual BiasPtr createBias(); - }; - -} - -#endif diff --git a/amarok/src/services/lastfm/biases/WeeklyTopBias.cpp b/amarok/src/services/lastfm/biases/WeeklyTopBias.cpp deleted file mode 100644 index e64c439e..00000000 --- a/amarok/src/services/lastfm/biases/WeeklyTopBias.cpp +++ /dev/null @@ -1,492 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Leo Franchi * - * Copyright (c) 2011 Ralf Engels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "WeeklyTopBias.h" - -#include "core/meta/Meta.h" -#include "core/support/Amarok.h" -#include "core/support/Debug.h" -#include "core-impl/collections/support/CollectionManager.h" - -#include - - -#include - -#include -#include -#include -#include -#include - -#include - -QString -Dynamic::WeeklyTopBiasFactory::i18nName() const -{ return i18nc("Name of the \"WeeklyTop\" bias", "Last.fm weekly top artist"); } - -QString -Dynamic::WeeklyTopBiasFactory::name() const -{ return Dynamic::WeeklyTopBias::sName(); } - -QString -Dynamic::WeeklyTopBiasFactory::i18nDescription() const -{ return i18nc("Description of the \"WeeklyTop\" bias", - "The \"WeeklyTop\" bias adds tracks that are in the weekly top chart of Last.fm."); } - -Dynamic::BiasPtr -Dynamic::WeeklyTopBiasFactory::createBias() -{ return Dynamic::BiasPtr( new Dynamic::WeeklyTopBias() ); } - - -// ----- WeeklyTopBias -------- - - -Dynamic::WeeklyTopBias::WeeklyTopBias() - : SimpleMatchBias() - , m_weeklyTimesJob( 0 ) -{ - m_range.from = QDateTime::currentDateTime(); - m_range.to = QDateTime::currentDateTime(); - loadFromFile(); -} - -Dynamic::WeeklyTopBias::~WeeklyTopBias() -{ } - - -void -Dynamic::WeeklyTopBias::fromXml( QXmlStreamReader *reader ) -{ - loadFromFile(); - - while (!reader->atEnd()) { - reader->readNext(); - - if( reader->isStartElement() ) - { - QStringRef name = reader->name(); - if( name == "from" ) - m_range.from = QDateTime::fromTime_t( reader->readElementText(QXmlStreamReader::SkipChildElements).toLong() ); - else if( name == "to" ) - m_range.to = QDateTime::fromTime_t( reader->readElementText(QXmlStreamReader::SkipChildElements).toLong() ); - else - { - debug()<<"Unexpected xml start element"<skipCurrentElement(); - } - } - else if( reader->isEndElement() ) - { - break; - } - } -} - -void -Dynamic::WeeklyTopBias::toXml( QXmlStreamWriter *writer ) const -{ - writer->writeTextElement( "from", QString::number( m_range.from.toTime_t() ) ); - writer->writeTextElement( "to", QString::number( m_range.to.toTime_t() ) ); -} - -QString -Dynamic::WeeklyTopBias::sName() -{ - return "lastfm_weeklytop"; -} - -QString -Dynamic::WeeklyTopBias::name() const -{ - return Dynamic::WeeklyTopBias::sName(); -} - -QString -Dynamic::WeeklyTopBias::toString() const -{ - return i18nc("WeeklyTopBias bias representation", - "Tracks from the Last.fm top lists from %1 to %2", m_range.from.toString(), m_range.to.toString() ); -} - -QWidget* -Dynamic::WeeklyTopBias::widget( QWidget* parent ) -{ - QWidget *widget = new QWidget( parent ); - QVBoxLayout *layout = new QVBoxLayout( widget ); - - QLabel *label = new QLabel( i18nc( "in WeeklyTopBias. Label for the date widget", "from:" ) ); - QDateTimeEdit *fromEdit = new QDateTimeEdit( QDate::currentDate().addDays( -7 ) ); - fromEdit->setMinimumDate( QDateTime::fromTime_t( 1111320001 ).date() ); // That's the first week in last fm - fromEdit->setMaximumDate( QDate::currentDate() ); - fromEdit->setCalendarPopup( true ); - if( m_range.from.isValid() ) - fromEdit->setDateTime( m_range.from ); - - connect( fromEdit, SIGNAL(dateTimeChanged(QDateTime)), - this, SLOT(fromDateChanged(QDateTime)) ); - label->setBuddy( fromEdit ); - layout->addWidget( label ); - layout->addWidget( fromEdit ); - - label = new QLabel( i18nc( "in WeeklyTopBias. Label for the date widget", "to:" ) ); - QDateTimeEdit *toEdit = new QDateTimeEdit( QDate::currentDate().addDays( -7 ) ); - toEdit->setMinimumDate( QDateTime::fromTime_t( 1111320001 ).date() ); // That's the first week in last fm - toEdit->setMaximumDate( QDate::currentDate() ); - toEdit->setCalendarPopup( true ); - if( m_range.to.isValid() ) - toEdit->setDateTime( m_range.to ); - - connect( toEdit, SIGNAL(dateTimeChanged(QDateTime)), - this, SLOT(toDateChanged(QDateTime)) ); - label->setBuddy( toEdit ); - layout->addWidget( label ); - layout->addWidget( toEdit ); - - return widget; -} - - -bool -Dynamic::WeeklyTopBias::trackMatches( int position, - const Meta::TrackList& playlist, - int contextCount ) const -{ - Q_UNUSED( contextCount ); - - if( position < 0 || position >= playlist.count()) - return false; - - // - determine the current artist - Meta::TrackPtr currentTrack = playlist[position-1]; - Meta::ArtistPtr currentArtist = currentTrack->artist(); - QString currentArtistName = currentArtist ? currentArtist->name() : QString(); - - // - collect all the artists - QStringList artists; - bool weeksMissing = false; - - uint fromTime = m_range.from.toTime_t(); - uint toTime = m_range.to.toTime_t(); - uint lastWeekTime = 0; - foreach( uint weekTime, m_weeklyFromTimes ) - { - if( weekTime > fromTime && weekTime < toTime && lastWeekTime ) - { - if( m_weeklyArtistMap.contains( lastWeekTime ) ) - { - artists.append( m_weeklyArtistMap.value( lastWeekTime ) ); - // debug() << "found already-saved data for week:" << lastWeekTime << m_weeklyArtistMap.value( lastWeekTime ); - } - else - { - weeksMissing = true; - } - } - - lastWeekTime = weekTime; - } - - if( weeksMissing ) - warning() << "didn't have a cached suggestions for weeks:" << m_range.from << "to" << m_range.to; - - return artists.contains( currentArtistName ); -} - -void -Dynamic::WeeklyTopBias::newQuery() -{ - DEBUG_BLOCK; - - // - check if we have week times - if( m_weeklyFromTimes.isEmpty() ) - { - newWeeklyTimesQuery(); - return; // not yet ready to do construct a query maker - } - - // - collect all the artists - QStringList artists; - bool weeksMissing = false; - - uint fromTime = m_range.from.toTime_t(); - uint toTime = m_range.to.toTime_t(); - uint lastWeekTime = 0; - foreach( uint weekTime, m_weeklyFromTimes ) - { - if( weekTime > fromTime && weekTime < toTime && lastWeekTime ) - { - if( m_weeklyArtistMap.contains( lastWeekTime ) ) - { - artists.append( m_weeklyArtistMap.value( lastWeekTime ) ); - // debug() << "found already-saved data for week:" << lastWeekTime << m_weeklyArtistMap.value( lastWeekTime ); - } - else - { - weeksMissing = true; - } - } - - lastWeekTime = weekTime; - } - - if( weeksMissing ) - { - newWeeklyArtistQuery(); - return; // not yet ready to construct a query maker - } - - // ok, I need a new query maker - m_qm.reset( CollectionManager::instance()->queryMaker() ); - - // - construct the query - m_qm->beginOr(); - foreach( const QString &artist, artists ) - { - // debug() << "adding artist to query:" << artist; - m_qm->addFilter( Meta::valArtist, artist, true, true ); - } - m_qm->endAndOr(); - - m_qm->setQueryType( Collections::QueryMaker::Custom ); - m_qm->addReturnValue( Meta::valUniqueId ); - - connect( m_qm.data(), SIGNAL(newResultReady(QStringList)), - this, SLOT(updateReady(QStringList)) ); - connect( m_qm.data(), SIGNAL(queryDone()), - this, SLOT(updateFinished()) ); - - // - run the query - m_qm.data()->run(); -} - -void -Dynamic::WeeklyTopBias::newWeeklyTimesQuery() -{ - DEBUG_BLOCK - - QMap< QString, QString > params; - params[ "method" ] = "user.getWeeklyChartList" ; - params[ "user" ] = lastfm::ws::Username; - - m_weeklyTimesJob = lastfm::ws::get( params ); - - connect( m_weeklyTimesJob, SIGNAL(finished()), - this, SLOT(weeklyTimesQueryFinished()) ); -} - - -void Dynamic::WeeklyTopBias::newWeeklyArtistQuery() -{ - DEBUG_BLOCK - debug() << "getting top artist info from" << m_range.from << "to" << m_range.to; - - // - check if we have week times - if( m_weeklyFromTimes.isEmpty() ) - { - newWeeklyTimesQuery(); - return; // not yet ready to do construct a query maker - } - - // fetch 5 at a time, so as to conform to lastfm api requirements - uint jobCount = m_weeklyArtistJobs.count(); - if( jobCount >= 5 ) - return; - - uint fromTime = m_range.from.toTime_t(); - uint toTime = m_range.to.toTime_t(); - uint lastWeekTime = 0; - foreach( uint weekTime, m_weeklyFromTimes ) - { - if( weekTime > fromTime && weekTime < toTime && lastWeekTime ) - { - if( m_weeklyArtistMap.contains( lastWeekTime ) ) - { - // we already have the data - } - else if( m_weeklyArtistJobs.contains( lastWeekTime ) ) - { - // we already fetch the data - } - else - { - QMap< QString, QString > params; - params[ "method" ] = "user.getWeeklyArtistChart"; - params[ "user" ] = lastfm::ws::Username; - params[ "from" ] = QString::number( lastWeekTime ); - params[ "to" ] = QString::number( m_weeklyToTimes[m_weeklyFromTimes.indexOf(lastWeekTime)] ); - - QNetworkReply* reply = lastfm::ws::get( params ); - connect( reply, SIGNAL(finished()), - this, SLOT(weeklyArtistQueryFinished()) ); - - m_weeklyArtistJobs.insert( lastWeekTime, reply ); - - jobCount++; - if( jobCount >= 5 ) - return; - } - } - - lastWeekTime = weekTime; - } -} - - -void -Dynamic::WeeklyTopBias::weeklyArtistQueryFinished() -{ - DEBUG_BLOCK - QNetworkReply *reply = qobject_cast( sender() ); - - if( !reply ) { - warning() << "Failed to get qnetwork reply in finished slot."; - return; - } - - - lastfm::XmlQuery lfm; - if( lfm.parse( reply->readAll() ) ) - { - // debug() << "got response:" << lfm; - QStringList artists; - for( int i = 0; i < lfm[ "weeklyartistchart" ].children( "artist" ).size(); i++ ) - { - if( i == 12 ) // only up to 12 artist. - break; - lastfm::XmlQuery artist = lfm[ "weeklyartistchart" ].children( "artist" ).at( i ); - artists.append( artist[ "name" ].text() ); - } - - uint week = QDomElement( lfm[ "weeklyartistchart" ] ).attribute( "from" ).toUInt(); - m_weeklyArtistMap.insert( week, artists ); - debug() << "got artists:" << artists << week; - - if( m_weeklyArtistJobs.contains( week) ) - { - m_weeklyArtistJobs.remove( week ); - } - else - { - warning() << "Got a reply for a week"<deleteLater(); - - saveDataToFile(); - newQuery(); // try again to get the tracks -} - -void -Dynamic::WeeklyTopBias::weeklyTimesQueryFinished() // SLOT -{ - DEBUG_BLOCK - if( !m_weeklyTimesJob ) - return; // argh. where does this come from - - QDomDocument doc; - if( !doc.setContent( m_weeklyTimesJob->readAll() ) ) - { - debug() << "couldn't parse XML from rangeJob!"; - return; - } - - QDomNodeList nodes = doc.elementsByTagName( "chart" ); - if( nodes.count() == 0 ) - { - debug() << "USER has no history! can't do this!"; - return; - } - - for( int i = 0; i < nodes.size(); i++ ) - { - QDomNode n = nodes.at( i ); - m_weeklyFromTimes.append( n.attributes().namedItem( "from" ).nodeValue().toUInt() ); - m_weeklyToTimes.append( n.attributes().namedItem( "to" ).nodeValue().toUInt() ); - - // debug() << "weeklyTimesResult"<deleteLater(); - - newQuery(); // try again to get the tracks -} - - -void -Dynamic::WeeklyTopBias::fromDateChanged( const QDateTime& d ) // SLOT -{ - if( d > m_range.to ) - return; - - m_range.from = d; - invalidate(); - emit changed( BiasPtr( this ) ); -} - - -void -Dynamic::WeeklyTopBias::toDateChanged( const QDateTime& d ) // SLOT -{ - if( d < m_range.from ) - return; - - m_range.to = d; - invalidate(); - emit changed( BiasPtr( this ) ); -} - - -void -Dynamic::WeeklyTopBias::loadFromFile() -{ - QFile file( Amarok::saveLocation() + "dynamic_lastfm_topweeklyartists.xml" ); - file.open( QIODevice::ReadOnly | QIODevice::Text ); - QTextStream in( &file ); - while( !in.atEnd() ) - { - QString line = in.readLine(); - m_weeklyArtistMap.insert( line.split( '#' )[ 0 ].toUInt(), line.split( '#' )[ 1 ].split( '^' ) ); - } - file.close(); -} - - -void -Dynamic::WeeklyTopBias::saveDataToFile() const -{ - QFile file( Amarok::saveLocation() + "dynamic_lastfm_topweeklyartists.xml" ); - file.open( QIODevice::Truncate | QIODevice::WriteOnly | QIODevice::Text ); - QTextStream out( &file ); - foreach( uint key, m_weeklyArtistMap.keys() ) - { - out << key << "#" << m_weeklyArtistMap[ key ].join( "^" ) << endl; - } - file.close(); - -} - - -#include "moc_WeeklyTopBias.cpp" diff --git a/amarok/src/services/lastfm/biases/WeeklyTopBias.h b/amarok/src/services/lastfm/biases/WeeklyTopBias.h deleted file mode 100644 index 56b6b8b3..00000000 --- a/amarok/src/services/lastfm/biases/WeeklyTopBias.h +++ /dev/null @@ -1,104 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Leo Franchi * - * Copyright (c) 2011 Ralf Engels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef WEEKLY_TOP_BIAS_H -#define WEEKLY_TOP_BIAS_H - -#include "dynamic/biases/TagMatchBias.h" - -class KJob; -class QNetworkReply; - -namespace Dynamic -{ - - /** - * This is a bias which allows the user to select a range of dates, and then - * adds to the playlist tracks/artists/albums that were on their last.fm top - * tracks during that time - * - */ - class WeeklyTopBias : public SimpleMatchBias - { - Q_OBJECT - - public: - struct DateRange - { - QDateTime from; - QDateTime to; - }; - - WeeklyTopBias(); - ~WeeklyTopBias(); - - virtual void fromXml( QXmlStreamReader *reader ); - virtual void toXml( QXmlStreamWriter *writer ) const; - - static QString sName(); - virtual QString name() const; - virtual QString toString() const; - - virtual QWidget* widget( QWidget* parent = 0 ); - - virtual bool trackMatches( int position, - const Meta::TrackList& playlist, - int contextCount ) const; - - - DateRange range() const; - void setRange( const DateRange &range ); - - private slots: - virtual void newQuery(); - void newWeeklyTimesQuery(); - void newWeeklyArtistQuery(); - - void weeklyTimesQueryFinished(); - void weeklyArtistQueryFinished(); - - void fromDateChanged( const QDateTime& ); - void toDateChanged( const QDateTime& ); - - private: - void loadFromFile(); - void saveDataToFile() const; - - DateRange m_range; - - // be able to warn the user - uint m_earliestDate; - - QList< uint > m_weeklyFromTimes; - QList< uint > m_weeklyToTimes; - QHash< uint, QStringList > m_weeklyArtistMap; - - QNetworkReply* m_weeklyTimesJob; - QHash< uint, QNetworkReply*> m_weeklyArtistJobs; - }; - - class WeeklyTopBiasFactory : public Dynamic::AbstractBiasFactory - { - public: - virtual QString i18nName() const; - virtual QString name() const; - virtual QString i18nDescription() const; - virtual BiasPtr createBias(); - }; -} - -#endif diff --git a/amarok/src/services/lastfm/images/CMakeLists.txt b/amarok/src/services/lastfm/images/CMakeLists.txt deleted file mode 100644 index 7b358e0d..00000000 --- a/amarok/src/services/lastfm/images/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -install( - FILES - hover_info_lastfm.png - DESTINATION ${DATA_INSTALL_DIR}/amarok/images -) - diff --git a/amarok/src/services/lastfm/images/hover_info_lastfm.png b/amarok/src/services/lastfm/images/hover_info_lastfm.png deleted file mode 100644 index 4e4aa01e..00000000 Binary files a/amarok/src/services/lastfm/images/hover_info_lastfm.png and /dev/null differ diff --git a/amarok/src/services/lastfm/meta/LastFmMeta.cpp b/amarok/src/services/lastfm/meta/LastFmMeta.cpp deleted file mode 100644 index d7874a66..00000000 --- a/amarok/src/services/lastfm/meta/LastFmMeta.cpp +++ /dev/null @@ -1,449 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Maximilian Kossick * - * Copyright (c) 2008 Shane King * - * Copyright (c) 2008 Leo Franchi * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "LastFmMeta.h" - -#include "EngineController.h" -#include "services/lastfm/meta/LastFmMeta_p.h" -#include "services/lastfm/meta/LastFmMultiPlayableCapability.h" -#include "services/lastfm/meta/LastFmStreamInfoCapability.h" - -#include - -#include -#include - -using namespace LastFm; - -Track::Track( const QString &lastFmUri ) - : QObject() - , Meta::Track() - , d( new Private() ) -{ - d->lastFmUri = QUrl( lastFmUri ); - d->t = this; - - init(); -} - -Track::Track( lastfm::Track track ) - : QObject() - , Meta::Track() - , d( new Private() ) -{ - d->t = this; - d->track = track.title(); - d->lastFmTrack = track; - QMap< QString, QString > params; - params[ "method" ] = "track.getInfo"; - params[ "artist" ] = track.artist(); - params[ "track" ] = track.title(); - - d->trackFetch = lastfm::ws::post( params ); - - connect( d->trackFetch, SIGNAL(finished()), SLOT(slotResultReady()) ); -} - - -Track::~Track() -{ - delete d; -} - -void Track::init( int id /* = -1*/ ) -{ - if( id != -1 ) - d->lastFmUri = QUrl( "lastfm://play/tracks/" + QString::number( id ) ); - d->length = 0; - - d->albumPtr = Meta::AlbumPtr( new LastFmAlbum( d ) ); - d->artistPtr = Meta::ArtistPtr( new LastFmArtist( d ) ); - d->genrePtr = Meta::GenrePtr( new LastFmGenre( d ) ); - d->composerPtr = Meta::ComposerPtr( new LastFmComposer( d ) ); - d->yearPtr = Meta::YearPtr( new LastFmYear( d ) ); - - QAction *banAction = new QAction( KIcon( "remove-amarok" ), i18n( "Last.fm: &Ban" ), this ); - banAction->setShortcut( i18n( "Ctrl+B" ) ); - banAction->setStatusTip( i18n( "Ban this track" ) ); - connect( banAction, SIGNAL(triggered()), this, SLOT(ban()) ); - m_trackActions.append( banAction ); - - QAction *skipAction = new QAction( KIcon( "media-seek-forward-amarok" ), i18n( "Last.fm: &Skip" ), this ); - skipAction->setShortcut( i18n( "Ctrl+S" ) ); - skipAction->setStatusTip( i18n( "Skip this track" ) ); - connect( skipAction, SIGNAL(triggered()), this, SIGNAL(skipTrack()) ); - m_trackActions.append( skipAction ); - - QThread *mainThread = QCoreApplication::instance()->thread(); - bool foreignThread = QThread::currentThread() != mainThread; - if( foreignThread ) - { - moveToThread( mainThread ); // the actions are children and are moved together with parent - d->moveToThread( mainThread ); - } -} - -QString -Track::name() const -{ - if( d->track.isEmpty() ) - { - return streamName(); - } - else - { - return d->track; - } -} - -QString -Track::sortableName() const -{ - // TODO - return name(); -} - -KUrl -Track::playableUrl() const -{ - return d->lastFmUri.toString(); -} - -KUrl -Track::internalUrl() const -{ - return KUrl( d->trackPath ); -} - -QString -Track::prettyUrl() const -{ - return d->lastFmUri.toString(); -} - -QString -Track::uidUrl() const -{ - return d->lastFmUri.toString(); -} - -QString -Track::notPlayableReason() const -{ - return networkNotPlayableReason(); -} - -Meta::AlbumPtr -Track::album() const -{ - return d->albumPtr; -} - -Meta::ArtistPtr -Track::artist() const -{ - return d->artistPtr; -} - -Meta::GenrePtr -Track::genre() const -{ - return d->genrePtr; -} - -Meta::ComposerPtr -Track::composer() const -{ - return d->composerPtr; -} - -Meta::YearPtr -Track::year() const -{ - return d->yearPtr; -} - -qreal -Track::bpm() const -{ - return -1.0; -} - -QString -Track::comment() const -{ - return QString(); -} - -int -Track::trackNumber() const -{ - return 0; -} - -int -Track::discNumber() const -{ - return 0; -} - -qint64 -Track::length() const -{ - return d->length; -} - -int -Track::filesize() const -{ - return 0; //stream -} - -int -Track::sampleRate() const -{ - return 0; //does the engine deliver this? -} - -int -Track::bitrate() const -{ - return 0; //does the engine deliver this?? -} - -QString -Track::type() const -{ - return "stream/lastfm"; -} - -bool -Track::inCollection() const -{ - return false; -} - -Collections::Collection* -Track::collection() const -{ - return 0; -} - -void -Track::setTrackInfo( const lastfm::Track &track ) -{ - if( !track.isNull() ) - d->setTrackInfo( track ); -} - -QString -Track::streamName() const -{ - // parse the url to get a name if we don't have a track name (ie we're not playing the station) - // do it as name rather than prettyname so it shows up nice in the playlist. - QStringList elements = d->lastFmUri.toString().split( '/', QString::SkipEmptyParts ); - if( elements.size() >= 2 && elements[0] == "lastfm:" ) - { - QString customPart = QUrl::fromPercentEncoding( elements[2].toUtf8() ); - - if( elements[1] == "globaltags" ) - { - // lastfm://globaltag/ - if( elements.size() >= 3 ) - return i18n( "Global Tag Radio: \"%1\"", customPart ); - } - else if( elements[1] == "usertags" ) - { - // lastfm://usertag/ - if( elements.size() >= 3 ) - return i18n( "User Tag Radio: \"%1\"", customPart ); - } - else if( elements[1] == "artist" ) - { - if( elements.size() >= 4 ) - { - // lastfm://artist//similarartists - if( elements[3] == "similarartists" ) - return i18n( "Similar Artists to \"%1\"", customPart ); - - // lastfm://artist//fans - else if( elements[3] == "fans" ) - return i18n( "Artist Fan Radio: \"%1\"", customPart ); - } - } - else if( elements[1] == "user" ) - { - if( elements.size() >= 4 ) - { - // lastfm://user//neighbours - if( elements[3] == "neighbours" ) - return i18n( "%1's Neighbor Radio", elements[2] ); - - // lastfm://user//personal - else if( elements[3] == "personal" ) - return i18n( "%1's Personal Radio", elements[2] ); - - // lastfm://user//mix - else if( elements[3] == "mix" ) - return i18n( "%1's Mix Radio", elements[2] ); - - // lastfm://user//recommended - else if( elements.size() < 5 && elements[3] == "recommended" ) - return i18n( "%1's Recommended Radio", elements[2] ); - - // lastfm://user//recommended/ - else if( elements.size() >= 5 && elements[3] == "recommended" ) - return i18n( "%1's Recommended Radio (Popularity %2)", elements[2], elements[4] ); - } - } - else if( elements[1] == "group" ) - { - // lastfm://group/ - if( elements.size() >= 3 ) - return i18n( "Group Radio: %1", elements[2] ); - } - else if( elements[1] == "play" ) - { - if( elements.size() >= 4 ) - { - // lastfm://play/tracks/ - if ( elements[2] == "tracks" ) - return i18n( "Track Radio" ); - - // lastfm://play/artists/ - else if ( elements[2] == "artists" ) - return i18n( "Artist Radio" ); - } - } - } - - return d->lastFmUri.toString(); -} - -void -Track::ban() -{ - DEBUG_BLOCK - d->wsReply = lastfm::MutableTrack( d->lastFmTrack ).ban(); - connect( d->wsReply, SIGNAL(finished()), this, SLOT(slotWsReply()) ); - if( The::engineController()->currentTrack() == this ) - emit skipTrack(); -} - -void Track::slotResultReady() -{ - if( d->trackFetch->error() == QNetworkReply::NoError ) - { - lastfm::XmlQuery lfm; - if( lfm.parse( d->trackFetch->readAll() ) ) - { - QString id = lfm[ "track" ][ "id" ].text(); - QString streamable = lfm[ "track" ][ "streamable" ].text(); - if( streamable.toInt() == 1 ) - init( id.toInt() ); - else - init(); - - } - else - { - debug() << "Got exception in parsing from last.fm:" << lfm.parseError().message(); - } - } else - { - init(); - } - d->trackFetch->deleteLater(); -} - - -void -Track::slotWsReply() -{ - if( d->wsReply->error() == QNetworkReply::NoError ) - { - //debug() << "successfully completed WS transaction"; - } else - { - debug() << "ERROR in last.fm ban!" << d->wsReply->error(); - } -} - -bool -Track::hasCapabilityInterface( Capabilities::Capability::Type type ) const -{ - return type == Capabilities::Capability::MultiPlayable || - type == Capabilities::Capability::SourceInfo || - type == Capabilities::Capability::Actions || - type == Capabilities::Capability::StreamInfo; -} - -Capabilities::Capability* -Track::createCapabilityInterface( Capabilities::Capability::Type type ) -{ - switch( type ) - { - case Capabilities::Capability::MultiPlayable: - return new LastFmMultiPlayableCapability( this ); - case Capabilities::Capability::SourceInfo: - return new ServiceSourceInfoCapability( this ); - case Capabilities::Capability::Actions: - return new Capabilities::ActionsCapability( m_trackActions ); - case Capabilities::Capability::StreamInfo: - return new LastFmStreamInfoCapability( this ); - default: - return 0; - } -} - -Meta::StatisticsPtr -Track::statistics() -{ - if( d->statsStore ) - return d->statsStore; - return Meta::Track::statistics(); -} - -QString LastFm::Track::sourceName() -{ - return "Last.fm"; -} - -QString LastFm::Track::sourceDescription() -{ - return i18n( "Last.fm is cool..." ); -} - -QPixmap LastFm::Track::emblem() -{ - if ( !d->track.isEmpty() ) - return QPixmap( KStandardDirs::locate( "data", "amarok/images/emblem-lastfm.png" ) ); - else - return QPixmap(); -} - -QString LastFm::Track::scalableEmblem() -{ - if ( !d->track.isEmpty() ) - return KStandardDirs::locate( "data", "amarok/images/emblem-lastfm-scalable.svg" ); - else - return QString(); -} - -#include "moc_LastFmMeta.cpp" -#include "moc_LastFmMeta_p.cpp" diff --git a/amarok/src/services/lastfm/meta/LastFmMeta.h b/amarok/src/services/lastfm/meta/LastFmMeta.h deleted file mode 100644 index 3d8e2752..00000000 --- a/amarok/src/services/lastfm/meta/LastFmMeta.h +++ /dev/null @@ -1,122 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Maximilian Kossick * - * Copyright (c) 2008 Shane King * - * Copyright (c) 2008 Leo Franchi * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_LASTFMMETA_H -#define AMAROK_LASTFMMETA_H - -#include "core/meta/Meta.h" -#include "core/capabilities/Capability.h" -#include "services/ServiceMetaBase.h" // for the SourceInfoProvider - -namespace lastfm { - class Track; -} - -namespace LastFm -{ - class Track : public QObject, public Meta::Track, public SourceInfoProvider - { - Q_OBJECT - public: - class Private; - - Track( const QString &lastFmUri ); - Track( lastfm::Track track ); //Convienience Constructor to allow constructing a Meta::LastFmTrack from a LastFmTrack (confusing?) - virtual ~Track(); - - // methods inherited from Meta::Base - virtual QString name() const; - virtual QString sortableName() const; - - // methods inherited from Meta::Track - virtual KUrl playableUrl() const; - virtual QString prettyUrl() const; - virtual QString uidUrl() const; - virtual QString notPlayableReason() const; - - virtual Meta::AlbumPtr album() const; - virtual Meta::ArtistPtr artist() const; - virtual Meta::GenrePtr genre() const; - virtual Meta::ComposerPtr composer() const; - virtual Meta::YearPtr year() const; - - virtual qreal bpm() const; - - virtual QString comment() const; - - virtual int trackNumber() const; - - virtual int discNumber() const; - - virtual qint64 length() const; - virtual int filesize() const; - virtual int sampleRate() const; - virtual int bitrate() const; - - virtual QString type() const; - - virtual bool inCollection() const; - virtual Collections::Collection *collection() const; - - virtual bool hasCapabilityInterface( Capabilities::Capability::Type type ) const; - virtual Capabilities::Capability* createCapabilityInterface( Capabilities::Capability::Type type ); - - virtual Meta::StatisticsPtr statistics(); - - // own methods: - void setTrackInfo( const lastfm::Track &trackInfo ); - - virtual QString sourceName(); - virtual QString sourceDescription(); - virtual QPixmap emblem(); - virtual QString scalableEmblem(); - - //LastFm specific methods, cast the object to LastFm::Track to use them - //you can cast the Track when type() returns "stream/lastfm" (or use a dynamic cast:) - KUrl internalUrl() const; // this returns the private temporary url to the .mp3, DO NOT USE, - // if you are asking, it has already expired - QString streamName() const; // A nice name for the stream.. - - public slots: - void ban(); - - private slots: - void slotResultReady(); - void slotWsReply(); - - signals: - void skipTrack(); // needed for communication with multiplayablecapability - - private: - void init( int id = -1 ); - //use a d-pointer because some code is going to work directly with LastFm::Track - Private * const d; - QList< QAction * > m_trackActions; - }; - - class LastFmProviderCapability : public Capabilities::Capability - { - public: - LastFmProviderCapability(); - ~LastFmProviderCapability(); - }; - - typedef KSharedPtr TrackPtr; -} - -#endif diff --git a/amarok/src/services/lastfm/meta/LastFmMeta_p.h b/amarok/src/services/lastfm/meta/LastFmMeta_p.h deleted file mode 100644 index b056d68f..00000000 --- a/amarok/src/services/lastfm/meta/LastFmMeta_p.h +++ /dev/null @@ -1,377 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Maximilian Kossick * - * Copyright (c) 2008 Leo Franchi * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_LASTFMMETA_P_H -#define AMAROK_LASTFMMETA_P_H - -#include "core/support/Debug.h" - -#include "amarokconfig.h" -#include "core/meta/Meta.h" -#include "core/support/Amarok.h" -#include "core-impl/support/TagStatisticsStore.h" - -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -namespace LastFm -{ - -class Track::Private : public QObject -{ - Q_OBJECT - - public: - Track *t; - lastfm::Track lastFmTrack; // this is how we love, ban, etc - QUrl trackPath; - QUrl lastFmUri; - - QImage albumArt; - QString artist; - QString album; - QString track; - qint64 length; - - //not sure what these are for but they exist in the LastFmBundle - QString albumUrl; - QString artistUrl; - QString trackUrl; - QString imageUrl; - - Meta::ArtistPtr artistPtr; - Meta::AlbumPtr albumPtr; - Meta::GenrePtr genrePtr; - Meta::ComposerPtr composerPtr; - Meta::YearPtr yearPtr; - - QNetworkReply* trackFetch; - QNetworkReply* wsReply; - - Meta::StatisticsPtr statsStore; - uint currentTrackStartTime; - - public: - Private() - : lastFmUri( QUrl() ) - , currentTrackStartTime( 0 ) - { - artist = QString ( "Last.fm" ); - } - - ~Private() - { - } - - void notifyObservers(); - - void setTrackInfo( const lastfm::Track &trackInfo ) - { - DEBUG_BLOCK - bool newTrackInfo = artist != trackInfo.artist() || - album != trackInfo.album() || - track != trackInfo.title(); - - - lastFmTrack = trackInfo; - artist = trackInfo.artist(); - album = trackInfo.album(); - track = trackInfo.title(); - length = trackInfo.duration() * 1000; - trackPath = trackInfo.url(); - - // need to reset other items - albumUrl = ""; - trackUrl = ""; - albumArt = QImage(); - - if( newTrackInfo ) - { - statsStore = new TagStatisticsStore( t ); - currentTrackStartTime = QDateTime::currentDateTime().toTime_t(); - } - - notifyObservers(); - - if( !trackInfo.isNull() ) - { - QMap< QString, QString > params; - params[ "method" ] = "track.getInfo"; - params[ "artist" ] = artist; - params[ "track" ] = track; - - m_userFetch = lastfm::ws::post( params ); - - connect( m_userFetch, SIGNAL( finished() ), SLOT( requestResult() ) ); - } - } - - public slots: - void requestResult( ) - { - if( !m_userFetch ) - return; - if( m_userFetch->error() == QNetworkReply::NoError ) - { - lastfm::XmlQuery lfm; - if( lfm.parse( m_userFetch->readAll() ) ) - { - albumUrl = lfm[ "track" ][ "album" ][ "url" ].text(); - trackUrl = lfm[ "track" ][ "url" ].text(); - artistUrl = lfm[ "track" ][ "artist" ][ "url" ].text(); - - notifyObservers(); - - imageUrl = lfm[ "track" ][ "album" ][ "image size=large" ].text(); - - if( !imageUrl.isEmpty() ) - { - KIO::Job* job = KIO::storedGet( KUrl( imageUrl ), KIO::Reload, KIO::HideProgressInfo ); - connect( job, SIGNAL( result( KJob* ) ), this, SLOT( fetchImageFinished( KJob* ) ) ); - } - } - else - { - debug() << "Got exception in parsing from last.fm:" << lfm.parseError().message(); - return; - } - } - - } - - void fetchImageFinished( KJob* job ) - { - if( job->error() == 0 ) - { - const int size = 100; - - QImage img = QImage::fromData( static_cast( job )->data() ); - if( !img.isNull() ) - { - img.scaled( size, size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation ); - - albumArt = img; - } - else - albumArt = QImage(); - } - else - { - //use default image - albumArt = QImage(); - } - notifyObservers(); - } - - private: - QNetworkReply* m_userFetch; - -}; - -// internal helper classes - -class LastFmArtist : public Meta::Artist -{ -public: - LastFmArtist( Track::Private *dptr ) - : Meta::Artist() - , d( dptr ) - {} - - Meta::TrackList tracks() - { - return Meta::TrackList(); - } - - QString name() const - { - if( d ) - return d->artist; - return QString( "Last.fm" ); - } - - Track::Private * const d; - - friend class Track::Private; -}; - -class LastFmAlbum : public Meta::Album -{ -public: - LastFmAlbum( Track::Private *dptr ) - : Meta::Album() - , d( dptr ) - {} - - bool isCompilation() const { return false; } - bool hasAlbumArtist() const { return false; } - Meta::ArtistPtr albumArtist() const { return Meta::ArtistPtr(); } - - Meta::TrackList tracks() - { - return Meta::TrackList(); - } - - QString name() const - { - if( d ) - return d->album; - return QString(); - } - - QImage image( int size ) const - { - if( !d || d->albumArt.isNull() ) - { - //return Meta::Album::image( size, withShadow ); - //TODO implement shadow - //TODO improve this - - if ( size <= 1 ) - size = 100; - QString sizeKey = QString::number( size ) + '@'; - - QImage image; - QDir cacheCoverDir = QDir( Amarok::saveLocation( "albumcovers/cache/" ) ); - if( cacheCoverDir.exists( sizeKey + "lastfm-default-cover.png" ) ) - image = QImage( cacheCoverDir.filePath( sizeKey + "lastfm-default-cover.png" ) ); - else - { - QImage orgImage = QImage( KStandardDirs::locate( "data", "amarok/images/lastfm-default-cover.png" ) ); //optimize this! - //scaled() does not change the original image but returns a scaled copy - image = orgImage.scaled( size, size, Qt::KeepAspectRatio, Qt::SmoothTransformation ); - image.save( cacheCoverDir.filePath( sizeKey + "lastfm-default-cover.png" ), "PNG" ); - } - - return image; - } - - - if( d->albumArt.width() != size && size > 0 ) - return d->albumArt.scaled( size, size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation ); - return d->albumArt; - } - - KUrl imageLocation( int size ) - { - Q_UNUSED( size ); - if( d && !d->imageUrl.isEmpty() ) - return KUrl( d->imageUrl ); - return KUrl(); - } - - // return true since we handle our own fetching - bool hasImage( int size = 1 ) const { Q_UNUSED( size ); return true; } - - Track::Private * const d; - - friend class Track::Private; -}; - -class LastFmGenre : public Meta::Genre -{ -public: - LastFmGenre( Track::Private *dptr ) - : Meta::Genre() - , d( dptr ) - {} - - QString name() const - { - return QString(); - } - - Meta::TrackList tracks() - { - return Meta::TrackList(); - } - - Track::Private * const d; - - friend class Track::Private; -}; - -class LastFmComposer : public Meta::Composer -{ -public: - LastFmComposer( Track::Private *dptr ) - : Meta::Composer() - , d( dptr ) - {} - - QString name() const - { - return QString(); - } - - Meta::TrackList tracks() - { - return Meta::TrackList(); - } - - Track::Private * const d; - - friend class Track::Private; -}; - -class LastFmYear : public Meta::Year -{ -public: - LastFmYear( Track::Private *dptr ) - : Meta::Year() - , d( dptr ) - {} - - QString name() const - { - return QString(); - } - - Meta::TrackList tracks() - { - return Meta::TrackList(); - } - - Track::Private * const d; - - friend class Track::Private; -}; - -void -Track::Private::notifyObservers() -{ - // TODO: only notify what actually has changed - t->notifyObservers(); - static_cast( t->album().data() )->notifyObservers(); - static_cast( t->artist().data() )->notifyObservers(); -} - -} - -#endif diff --git a/amarok/src/services/lastfm/meta/LastFmMultiPlayableCapability.cpp b/amarok/src/services/lastfm/meta/LastFmMultiPlayableCapability.cpp deleted file mode 100644 index 25e16f18..00000000 --- a/amarok/src/services/lastfm/meta/LastFmMultiPlayableCapability.cpp +++ /dev/null @@ -1,109 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Dan Meltzer * - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "LastFmMultiPlayableCapability.h" - -#include "EngineController.h" - -LastFmMultiPlayableCapability::LastFmMultiPlayableCapability( LastFm::Track *track ) - : Capabilities::MultiPlayableCapability() - , m_url( track->internalUrl() ) - , m_track( track ) -{ - connect( track, SIGNAL(skipTrack()), this, SLOT(skip()) ); - - Q_ASSERT( The::mainWindow() ); - connect( The::mainWindow(), SIGNAL(skipTrack()), SLOT(skip()) ); - - // we only update underlying Last.fm metadata once it starts playing, prevent wrong - // metadata Last.fm submissions etc. - Q_ASSERT( EngineController::instance() ); - connect( EngineController::instance(), SIGNAL(trackPlaying(Meta::TrackPtr)), - SLOT(slotTrackPlaying(Meta::TrackPtr)) ); -} - -LastFmMultiPlayableCapability::~LastFmMultiPlayableCapability() -{ -} - -void -LastFmMultiPlayableCapability::fetchFirst() -{ - DEBUG_BLOCK - m_tuner = new lastfm::RadioTuner( lastfm::RadioStation( m_track->uidUrl() ) ); - m_tuner->setParent( this ); // memory management - - connect( m_tuner, SIGNAL(trackAvailable()), SLOT(slotNewTrackAvailable()) ); - connect( m_tuner, SIGNAL(error(lastfm::ws::Error,QString)), - SLOT(error(lastfm::ws::Error)) ); -} - -void -LastFmMultiPlayableCapability::fetchNext() -{ - DEBUG_BLOCK - m_currentTrack = m_tuner->takeNextTrack(); - emit playableUrlFetched( m_currentTrack.url() ); -} - -void -LastFmMultiPlayableCapability::slotTrackPlaying( const Meta::TrackPtr &track ) -{ - // time to update underlying track with metadata - // warning: this depends on MetaProxy::Track operator== returning true - // between proxy and underlying track! - if( track == m_track ) - m_track->setTrackInfo( m_currentTrack ); -} - -void -LastFmMultiPlayableCapability::slotNewTrackAvailable() -{ - DEBUG_BLOCK - if( m_currentTrack.isNull() ) // we only force a track change at the beginning - { - fetchNext(); - // we update metadata immediatelly for the very first track - m_track->setTrackInfo( m_currentTrack ); - } -} - -void -LastFmMultiPlayableCapability::skip() -{ - DEBUG_BLOCK - fetchNext(); -} - -void -LastFmMultiPlayableCapability::error( lastfm::ws::Error e ) -{ - // last.fm is returning an AuthenticationFailed message when the user is not - // a subscriber, even if the credentials are OK - if( e == lastfm::ws::SubscribersOnly || e == lastfm::ws::AuthenticationFailed ) - { - Amarok::Components::logger()->longMessage( i18n( "To listen to Last.fm streams " - "and radio you need to be a paying Last.fm subscriber and you need to " - "stream from a supported " - "country. All other Last.fm features work fine." ) ); - } - else - { - Amarok::Components::logger()->longMessage( - i18n( "Error starting track from Last.fm radio" ) ); - } -} diff --git a/amarok/src/services/lastfm/meta/LastFmMultiPlayableCapability.h b/amarok/src/services/lastfm/meta/LastFmMultiPlayableCapability.h deleted file mode 100644 index cdfcb3b4..00000000 --- a/amarok/src/services/lastfm/meta/LastFmMultiPlayableCapability.h +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Shane King * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_MULTIPLAYABLECAPABILITYIMPL_P_H -#define AMAROK_MULTIPLAYABLECAPABILITYIMPL_P_H - -#include "core/interfaces/Logger.h" -#include "core/support/Components.h" -#include "core/support/Debug.h" -#include "MainWindow.h" -#include "LastFmMeta.h" -#include "core/meta/forward_declarations.h" -#include "core/capabilities/MultiPlayableCapability.h" - -#include - -#include -#include -#include -#include - -class LastFmMultiPlayableCapability : public Capabilities::MultiPlayableCapability -{ - Q_OBJECT - - public: - LastFmMultiPlayableCapability( LastFm::Track *track ); - virtual ~LastFmMultiPlayableCapability(); - - // Capabilities::MultiPlayableCapability methods - virtual void fetchFirst(); - virtual void fetchNext(); - - private slots: - void slotTrackPlaying( const Meta::TrackPtr &track ); - void slotNewTrackAvailable(); - void skip(); - void error( lastfm::ws::Error e ); - - private: - KUrl m_url; - LastFm::TrackPtr m_track; - - lastfm::Track m_currentTrack; - lastfm::RadioTuner *m_tuner; -}; - -#endif diff --git a/amarok/src/services/lastfm/meta/LastFmStreamInfoCapability.cpp b/amarok/src/services/lastfm/meta/LastFmStreamInfoCapability.cpp deleted file mode 100644 index 91ad6a9c..00000000 --- a/amarok/src/services/lastfm/meta/LastFmStreamInfoCapability.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Dan Meltzer * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "LastFmStreamInfoCapability.h" - -#include "LastFmMeta.h" - -LastFmStreamInfoCapability::LastFmStreamInfoCapability( LastFm::Track *track ) - : Capabilities::StreamInfoCapability() - , m_sourceTrack( track ) -{ -} - -LastFmStreamInfoCapability::~LastFmStreamInfoCapability() -{ -} - -QString -LastFmStreamInfoCapability::streamName() const -{ - return m_sourceTrack->streamName(); -} - -QString -LastFmStreamInfoCapability::streamSource() const -{ - return "last.fm"; -} diff --git a/amarok/src/services/lastfm/meta/LastFmStreamInfoCapability.h b/amarok/src/services/lastfm/meta/LastFmStreamInfoCapability.h deleted file mode 100644 index 6e4a3792..00000000 --- a/amarok/src/services/lastfm/meta/LastFmStreamInfoCapability.h +++ /dev/null @@ -1,41 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Dan Meltzer * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_LASTFMSTREAMINFOCAPABILITY_H -#define AMAROK_LASTFMSTREAMINFOCAPABILITY_H - -#include "core/capabilities/StreamInfoCapability.h" - -namespace LastFm -{ - class Track; -} -class LastFmStreamInfoCapability : public Capabilities::StreamInfoCapability -{ - Q_OBJECT - public: - LastFmStreamInfoCapability( LastFm::Track *track ); - ~LastFmStreamInfoCapability(); - - virtual QString streamName() const; - virtual QString streamSource() const; - - private: - LastFm::Track *m_sourceTrack; - -}; - -#endif diff --git a/amarok/src/services/magnatune/CMakeLists.txt b/amarok/src/services/magnatune/CMakeLists.txt deleted file mode 100644 index 2cbbb96f..00000000 --- a/amarok/src/services/magnatune/CMakeLists.txt +++ /dev/null @@ -1,75 +0,0 @@ -include_directories( - ../ - ../../ - ../../core-impl/collections - ../../statusbar - ${CMAKE_CURRENT_BINARY_DIR}/../../.. - ${KDE4_INCLUDE_DIR} - ${QT_INCLUDES} ) - -add_subdirectory( images ) - -########### next target ############### - -set(amarok_service_magnatune_PART_SRCS - MagnatuneActions.cpp - MagnatuneAlbumDownloader.cpp - MagnatuneCollectionLocation.cpp - MagnatuneConfig.cpp - MagnatuneDatabaseHandler.cpp - MagnatuneDatabaseWorker.cpp - MagnatuneDownloadDialog.cpp - MagnatuneDownloadInfo.cpp - MagnatuneInfoParser.cpp - MagnatuneMeta.cpp - MagnatuneNeedUpdateWidget.cpp - MagnatuneDownloadHandler.cpp - MagnatuneRedownloadDialog.cpp - MagnatuneRedownloadHandler.cpp - MagnatuneSqlCollection.cpp - MagnatuneStore.cpp - MagnatuneUrlRunner.cpp - MagnatuneXmlParser.cpp - MagnatuneDownloadDialogBase.ui - MagnatuneNeedUpdateWidget.ui - MagnatuneRedownloadDialogBase.ui - MagnatuneSignupDialogBase.ui -) - -kde4_add_plugin(amarok_service_magnatunestore ${amarok_service_magnatune_PART_SRCS}) -target_link_libraries(amarok_service_magnatunestore - amarokcore - amaroklib - ${KDE4_KDECORE_LIBS} - ${KDE4_KDEUI_LIBS} - ${KDE4_KIO_LIBS} - ${KDE4_THREADWEAVER_LIBS} -) - - -install(TARGETS amarok_service_magnatunestore DESTINATION ${PLUGIN_INSTALL_DIR} ) - -########### next target ############### - -set(kcm_amarok_service_magnatune_PART_SRCSS - MagnatuneSettingsModule.cpp - MagnatuneConfig.cpp - MagnatuneConfigWidget.ui -) - -kde4_add_plugin( kcm_amarok_service_magnatunestore ${kcm_amarok_service_magnatune_PART_SRCSS} ) - -target_link_libraries(kcm_amarok_service_magnatunestore - ${KDE4_KUTILS_LIBS} - ${QT_QTCORE_LIBRARY} - ${QT_QTGUI_LIBRARY} - ${KDE4_KDECORE_LIBRARY} - ${KDE4_KDEUI_LIBS} -) - -install(TARGETS kcm_amarok_service_magnatunestore DESTINATION ${PLUGIN_INSTALL_DIR}) - -########### install files ############### - -install( FILES amarok_service_magnatunestore.desktop DESTINATION ${SERVICES_INSTALL_DIR}) -install( FILES amarok_service_magnatunestore_config.desktop DESTINATION ${SERVICES_INSTALL_DIR}) diff --git a/amarok/src/services/magnatune/MagnatuneActions.cpp b/amarok/src/services/magnatune/MagnatuneActions.cpp deleted file mode 100644 index 204ff7d0..00000000 --- a/amarok/src/services/magnatune/MagnatuneActions.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "MagnatuneActions.h" -#include "SvgHandler.h" - -#include - -MagnatuneDownloadAction::MagnatuneDownloadAction( const QString &text, Meta::MagnatuneAlbum * album ) - : QAction( KIcon("download-amarok" ), text, album ) - , m_album( album ) -{ - setProperty( "popupdropper_svg_id", "append" ); - connect( this, SIGNAL(triggered(bool)), SLOT(slotTriggered()) ); -} - - -MagnatuneDownloadAction::~MagnatuneDownloadAction() -{ -} - -void MagnatuneDownloadAction::slotTriggered() -{ - DEBUG_BLOCK - m_album->download(); -} - - -MagnatuneAddToFavoritesAction::MagnatuneAddToFavoritesAction( const QString &text, Meta::MagnatuneAlbum * album ) - : QAction( KIcon("favorites" ), text, album ) - , m_album( album ) -{ - setProperty( "popupdropper_svg_id", "append" ); - connect( this, SIGNAL(triggered(bool)), SLOT(slotTriggered()) ); -} - - -MagnatuneAddToFavoritesAction::~MagnatuneAddToFavoritesAction() -{ -} - -void MagnatuneAddToFavoritesAction::slotTriggered() -{ - DEBUG_BLOCK - m_album->addToFavorites(); -} - -#include "moc_MagnatuneActions.cpp" diff --git a/amarok/src/services/magnatune/MagnatuneActions.h b/amarok/src/services/magnatune/MagnatuneActions.h deleted file mode 100644 index 09d8417e..00000000 --- a/amarok/src/services/magnatune/MagnatuneActions.h +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef MAGNATUNEACTIONS_H -#define MAGNATUNEACTIONS_H - -#include "MagnatuneMeta.h" - -#include - -/** -A simple QAction subclass for purchasing or downloading content from Magnatune - - @author Nikolaj Hald Nielsen -*/ -class MagnatuneDownloadAction : public QAction -{ - Q_OBJECT -public: - MagnatuneDownloadAction( const QString &text, Meta::MagnatuneAlbum * album ); - - ~MagnatuneDownloadAction(); - -private slots: - void slotTriggered(); - -private: - Meta::MagnatuneAlbum * m_album; - -}; - -/** -A simple QAction subclass for purchasing or downloading content from Magnatune - - @author Nikolaj Hald Nielsen -*/ -class MagnatuneAddToFavoritesAction : public QAction -{ - Q_OBJECT -public: - MagnatuneAddToFavoritesAction( const QString &text, Meta::MagnatuneAlbum * album ); - - ~MagnatuneAddToFavoritesAction(); - -private slots: - void slotTriggered(); - -private: - Meta::MagnatuneAlbum * m_album; - -}; - -#endif diff --git a/amarok/src/services/magnatune/MagnatuneAlbumDownloader.cpp b/amarok/src/services/magnatune/MagnatuneAlbumDownloader.cpp deleted file mode 100644 index f88492a5..00000000 --- a/amarok/src/services/magnatune/MagnatuneAlbumDownloader.cpp +++ /dev/null @@ -1,155 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2006,2007 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "MagnatuneAlbumDownloader.h" - -#include "core/support/Amarok.h" -#include "core/support/Components.h" -#include "core/support/Debug.h" -#include "core/interfaces/Logger.h" -#include "MagnatuneMeta.h" - - -#include -#include - -MagnatuneAlbumDownloader::MagnatuneAlbumDownloader() - : QObject() - , m_albumDownloadJob( 0 ) - , m_currentAlbumFileName() -{ - m_tempDir = new KTempDir(); -} - -MagnatuneAlbumDownloader::~MagnatuneAlbumDownloader() -{ - delete m_tempDir; - m_tempDir = 0; -} - -void -MagnatuneAlbumDownloader::downloadAlbum( MagnatuneDownloadInfo info ) -{ - DEBUG_BLOCK - - m_currentAlbumInfo = info; - - - KUrl downloadUrl = info.completeDownloadUrl(); - m_currentAlbumUnpackLocation = info.unpackLocation(); - debug() << "Download: " << downloadUrl.url() << " to: " << m_currentAlbumUnpackLocation; - - m_currentAlbumFileName = info.albumCode() + ".zip"; - - debug() << "Using temporary location: " << m_tempDir->name() + m_currentAlbumFileName; - - m_albumDownloadJob = KIO::file_copy( downloadUrl, KUrl( m_tempDir->name() + m_currentAlbumFileName ), -1, KIO::Overwrite | KIO::HideProgressInfo ); - - connect( m_albumDownloadJob, SIGNAL(result(KJob*)), SLOT(albumDownloadComplete(KJob*)) ); - - QString msgText; - if( !info.albumName().isEmpty() && !info.artistName().isEmpty() ) - { - msgText = i18n( "Downloading '%1' by %2 from Magnatune.com", info.albumName(), info.artistName() ); - } - else - { - msgText = i18n( "Downloading album from Magnatune.com" ); - } - - Amarok::Components::logger()->newProgressOperation( m_albumDownloadJob, msgText, this, SLOT(albumDownloadAborted()) ); -} - - - - -void -MagnatuneAlbumDownloader::albumDownloadComplete( KJob * downloadJob ) -{ - DEBUG_BLOCK - - debug() << "album download complete"; - - if ( !downloadJob->error() == 0 ) - { - //TODO: error handling here - return ; - } - if ( downloadJob != m_albumDownloadJob ) - return ; //not the right job, so let's ignore it - - const QString finalAlbumPath = m_currentAlbumUnpackLocation + '/' + m_currentAlbumInfo.artistName() + '/' + m_currentAlbumInfo.albumName(); - - //ok, now we have the .zip file downloaded. All we need is to unpack it to the desired location and add it to the collection. - - KZip kzip( m_tempDir->name() + m_currentAlbumFileName ); - - if ( !kzip.open( QIODevice::ReadOnly ) ) - { - Amarok::Components::logger()->shortMessage( i18n( "Magnatune download seems to have failed. Cannot read zip file" ) ); - emit( downloadComplete( false ) ); - return; - } - - debug() << m_tempDir->name() + m_currentAlbumFileName << " opened for decompression"; - - const KArchiveDirectory * directory = kzip.directory(); - - Amarok::Components::logger()->shortMessage( i18n( "Uncompressing Magnatune.com download..." ) ); - - //Is this really blocking with no progress status!? Why is it not a KJob? - - debug() << "decompressing to " << finalAlbumPath; - directory->copyTo( m_currentAlbumUnpackLocation ); - - debug() << "done!"; - - - - //now I really want to add the album cover to the same folder where I just unzipped the album... The - //only way of getting the actual location where the album was unpacked is using the artist and album names - - QString coverUrlString = m_currentAlbumInfo.coverUrl(); - - KUrl downloadUrl( coverUrlString.replace( "_200.jpg", ".jpg") ); - - debug() << "Adding cover " << downloadUrl.url() << " to collection at " << finalAlbumPath; - - m_albumDownloadJob = KIO::file_copy( downloadUrl, KUrl( finalAlbumPath + "/cover.jpg" ), -1, KIO::Overwrite | KIO::HideProgressInfo ); - - connect( m_albumDownloadJob, SIGNAL(result(KJob*)), SLOT(coverAddComplete(KJob*)) ); - - Amarok::Components::logger()->newProgressOperation( m_albumDownloadJob, i18n( "Adding album cover to collection" ), this, SLOT(coverAddAborted()) ); - - emit( downloadComplete( true ) ); - - -} - -void -MagnatuneAlbumDownloader::albumDownloadAborted( ) -{ - DEBUG_BLOCK - - m_albumDownloadJob->kill(); - m_albumDownloadJob = 0; - debug() << "Aborted album download"; - - emit( downloadComplete( false ) ); - -} - -#include "moc_MagnatuneAlbumDownloader.cpp" diff --git a/amarok/src/services/magnatune/MagnatuneAlbumDownloader.h b/amarok/src/services/magnatune/MagnatuneAlbumDownloader.h deleted file mode 100644 index a9f11bb5..00000000 --- a/amarok/src/services/magnatune/MagnatuneAlbumDownloader.h +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2006,2007 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef MAGNATUNEALBUMDOWNLOADER_H -#define MAGNATUNEALBUMDOWNLOADER_H - -#include "MagnatuneDownloadInfo.h" -#include "MagnatuneMeta.h" - -#include -#include - -#include - -#include -/** -This class encapsulates the downloading of an album once all required information has been retrieved - - @author Nikolaj Hald Nielsen -*/ -class MagnatuneAlbumDownloader: public QObject -{ -Q_OBJECT -public: - MagnatuneAlbumDownloader(); - - ~MagnatuneAlbumDownloader(); - -signals: - - /** - * This signal is emitted when a download is finished or cancelled - * @param success true is download completed, false if download was cancelled. - */ - void downloadComplete( bool success ); - -public slots: - /** - * Initiates the download of an album - * @param url A MagnatuneDownloadInfo object containing all needed information - */ - void downloadAlbum( MagnatuneDownloadInfo info ); - -protected: - - KIO::FileCopyJob * m_albumDownloadJob; - QString m_currentAlbumUnpackLocation; - QString m_currentAlbumFileName; - MagnatuneDownloadInfo m_currentAlbumInfo; - KTempDir * m_tempDir; - -protected slots: - /** - * Unzip the downloaded album - * @param downLoadJob - */ - void albumDownloadComplete( KJob* downloadJob ); - void albumDownloadAborted(); - - -}; - -#endif diff --git a/amarok/src/services/magnatune/MagnatuneCollectionLocation.cpp b/amarok/src/services/magnatune/MagnatuneCollectionLocation.cpp deleted file mode 100644 index 3939719f..00000000 --- a/amarok/src/services/magnatune/MagnatuneCollectionLocation.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "MagnatuneCollectionLocation.h" - -#include -#include - -#include - -using namespace Collections; - -MagnatuneCollectionLocation::MagnatuneCollectionLocation( MagnatuneSqlCollection *parentCollection ) - : ServiceCollectionLocation( parentCollection ) -{ -} - - -MagnatuneCollectionLocation::~MagnatuneCollectionLocation() -{ -} - -void MagnatuneCollectionLocation::showSourceDialog( const Meta::TrackList &tracks, bool removeSources ) -{ - KDialog dialog; - dialog.setCaption( i18n( "Preview Tracks" ) ); - dialog.setButtons( KDialog::Ok | KDialog::Cancel ); - - QLabel *label = new QLabel( i18n( "The tracks you are about to copy are Magnatune.com preview streams. For better quality and advert free streams, consider buying an album download. Remember that when buying from Magnatune the artist gets 50%. Also if you buy using Amarok, you support the Amarok project with 10%." ) ); - - label->setWordWrap ( true ); - label->setMaximumWidth( 400 ); - - dialog.setMainWidget( label ); - - dialog.exec(); - - if ( dialog.result() == QDialog::Rejected ) - abort(); - - CollectionLocation::showSourceDialog( tracks, removeSources ); // to get transcoding dialog -} diff --git a/amarok/src/services/magnatune/MagnatuneCollectionLocation.h b/amarok/src/services/magnatune/MagnatuneCollectionLocation.h deleted file mode 100644 index 734a690d..00000000 --- a/amarok/src/services/magnatune/MagnatuneCollectionLocation.h +++ /dev/null @@ -1,43 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef MAGNATUNECOLLECTIONLOCATION_H -#define MAGNATUNECOLLECTIONLOCATION_H - -#include "MagnatuneSqlCollection.h" -#include "ServiceCollectionLocation.h" - -namespace Collections { - -/** -A ServiceCollectionLocation subclass responsible for showing a small Magnatune specific dialog when copying tracks from Magnatune - - @author Nikolaj Hald Nielsen -*/ -class MagnatuneCollectionLocation : public ServiceCollectionLocation -{ -public: - MagnatuneCollectionLocation( MagnatuneSqlCollection *parentCollection ); - - virtual ~MagnatuneCollectionLocation(); - - virtual void showSourceDialog( const Meta::TrackList &tracks, bool removeSources ); - -}; - -} //namespace Collections - -#endif diff --git a/amarok/src/services/magnatune/MagnatuneConfig.cpp b/amarok/src/services/magnatune/MagnatuneConfig.cpp deleted file mode 100644 index 5842c631..00000000 --- a/amarok/src/services/magnatune/MagnatuneConfig.cpp +++ /dev/null @@ -1,230 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) version 3 or * - * any later version accepted by the membership of KDE e.V. (or its successor approved * - * by the membership of KDE e.V.), which shall act as a proxy defined in Section 14 of * - * version 3 of the license. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "MagnatuneConfig.h" -#include "MagnatuneMeta.h" - -#include -#include -#include -#include - -MagnatuneConfig::MagnatuneConfig() -{ - load(); -} - - -MagnatuneConfig::~MagnatuneConfig() -{ -} - -void -MagnatuneConfig::load() -{ - m_hasChanged = false; - - kDebug() << "load"; - KConfigGroup config = KGlobal::config()->group( "Service_Magnatune" ); - - m_isMember = config.readEntry( "isMember", false ); - - m_autoUpdate = config.readEntry( "autoUpdateDatabase", false ); - - m_membershipType = config.readEntry( "membershipType", -1 ); - - if( m_membershipType == -1 ) - { - //try to read the old style string version if that is present and valid. - QString oldMEmbershipType = config.readEntry( "membershipType", QString() ); - if( oldMEmbershipType.toLower() == "stream" ) - m_membershipType = MagnatuneConfig::STREAM; - else if ( oldMEmbershipType.toLower() == "download" ) - m_membershipType = MagnatuneConfig::DOWNLOAD; - else - m_membershipType = MagnatuneConfig::DOWNLOAD; - //default to download for now. - } - - m_username = config.readEntry( "username", QString() ); - m_password = config.readEntry( "password", QString() ); - m_email = config.readEntry( "email", QString() ); - - - qulonglong defaultLong = 0; - m_lastUpdateTimestamp = config.readEntry( "lastUpdate", defaultLong ); - - QString streamTypeString = config.readEntry( "streamType", QString() ); - - - //make ogg the default - if ( streamTypeString == "mp3" ) - m_streamType = MagnatuneMetaFactory::MP3; - else if ( streamTypeString == "lofi_mp3" ) - m_streamType = MagnatuneMetaFactory::LOFI; - else - m_streamType = MagnatuneMetaFactory::OGG; - -} - -void -MagnatuneConfig::save() -{ - kDebug() << "save"; - if ( m_hasChanged ) { - KConfigGroup config = KGlobal::config()->group( "Service_Magnatune" ); - - config.writeEntry( "isMember", m_isMember ); - config.writeEntry( "autoUpdateDatabase", m_autoUpdate ); - config.writeEntry( "membershipType", m_membershipType ); - config.writeEntry( "username", m_username ); - config.writeEntry( "password", m_password ); - config.writeEntry( "lastUpdate", QVariant( m_lastUpdateTimestamp ) ); - config.writeEntry( "email", m_email ); - - QString streamTypeString; - if ( m_streamType == MagnatuneMetaFactory::MP3 ) - streamTypeString = "mp3"; - else if ( m_streamType == MagnatuneMetaFactory::LOFI ) - streamTypeString = "lofi_mp3"; - else - streamTypeString = "ogg"; - - config.writeEntry( "streamType", streamTypeString ); - - } -} - -bool -MagnatuneConfig::isMember() -{ - return m_isMember; -} - -void -MagnatuneConfig::setIsMember( bool isMember ) -{ - m_hasChanged = true; - m_isMember = isMember; -} - -bool -MagnatuneConfig::autoUpdateDatabase() -{ - return m_autoUpdate; -} - -void -MagnatuneConfig::setAutoUpdateDatabase( bool value ) -{ - m_hasChanged = true; - m_autoUpdate = value; -} - -int -MagnatuneConfig::membershipType() -{ - return m_membershipType; -} - -void -MagnatuneConfig::setMembershipType( int membershipType ) -{ - m_hasChanged = true; - m_membershipType = membershipType; -} - -QString -MagnatuneConfig::membershipPrefix() -{ - QString prefix; - if( m_membershipType == MagnatuneConfig::STREAM ) - prefix = "stream"; - else - prefix = "download"; - - return prefix; -} - -QString -MagnatuneConfig::username() -{ - return m_username; -} - -QString -MagnatuneConfig::password() -{ - return m_password; -} - -void -MagnatuneConfig::setUsername( const QString &username ) -{ - m_hasChanged = true; - m_username = username; -} - -void -MagnatuneConfig::setPassword( const QString &password ) -{ - m_hasChanged = true; - m_password = password; -} - - -int -MagnatuneConfig::streamType() const -{ - return m_streamType; -} - - -void -MagnatuneConfig::setStreamType( int theValue ) -{ - m_streamType = theValue; -} - - -qulonglong -MagnatuneConfig::lastUpdateTimestamp() -{ - return m_lastUpdateTimestamp; -} - -void -MagnatuneConfig::setLastUpdateTimestamp( qulonglong timestamp ) -{ - m_hasChanged = true; - m_lastUpdateTimestamp = timestamp; -} - -QString -MagnatuneConfig::email() -{ - return m_email; -} - -void -MagnatuneConfig::setEmail( const QString &email ) -{ - m_email = email; - m_hasChanged = true; -} - diff --git a/amarok/src/services/magnatune/MagnatuneConfig.h b/amarok/src/services/magnatune/MagnatuneConfig.h deleted file mode 100644 index 552bcf86..00000000 --- a/amarok/src/services/magnatune/MagnatuneConfig.h +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) version 3 or * - * any later version accepted by the membership of KDE e.V. (or its successor approved * - * by the membership of KDE e.V.), which shall act as a proxy defined in Section 14 of * - * version 3 of the license. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef MAGNATUNECONFIG_H -#define MAGNATUNECONFIG_H - -#include - - -/** -Wrapper class for configuration options for the MagnatuneStore plugin - - @author -*/ -class MagnatuneConfig{ -public: - - enum - { - STREAM = 0, - DOWNLOAD = 1 - }; - - - MagnatuneConfig(); - - ~MagnatuneConfig(); - - void load(); - void save(); - - bool isMember(); - void setIsMember( bool isMember ); - - bool autoUpdateDatabase(); - void setAutoUpdateDatabase( bool value ); - - int membershipType(); - void setMembershipType( int membershipType ); - QString membershipPrefix(); - - QString email(); - void setEmail( const QString &email ); - - QString username(); - QString password(); - - void setUsername( const QString &username ); - void setPassword( const QString &password ); - - void setStreamType( int theValue ); - int streamType() const; - - qulonglong lastUpdateTimestamp(); - void setLastUpdateTimestamp( qulonglong timestamp ); - - -private: - - bool m_hasChanged; - bool m_autoUpdate; - QString m_username; - QString m_password; - int m_membershipType; - bool m_isMember; - int m_streamType; - QString m_email; - qulonglong m_lastUpdateTimestamp; - -}; - -#endif diff --git a/amarok/src/services/magnatune/MagnatuneConfigWidget.ui b/amarok/src/services/magnatune/MagnatuneConfigWidget.ui deleted file mode 100644 index 6aee2590..00000000 --- a/amarok/src/services/magnatune/MagnatuneConfigWidget.ui +++ /dev/null @@ -1,275 +0,0 @@ - - - MagnatuneConfigWidget - - - - 0 - 0 - 402 - 511 - - - - - - - Updates - - - - - - If you check this box, Amarok will periodically check for Magnatune database updates and download them automatically. - - - true - - - - - - - Update Magnatune database automatically - - - - - - - - - - Redownloads - - - - - - Enter your e-mail here to be able to redownload any previous purchase from Magnatune directly from within Amarok. - - - true - - - - - - - E-mail: - - - - - - - true - - - - - - - - - - - - - Membership Options - - - - - - I am a member - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Membership type: - - - - - - - false - - - - Stream - - - - - Download - - - - - - - - Username: - - - - - - - false - - - - - - - Password: - - - - - - - false - - - - - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'DejaVu Serif'; font-size:8pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans Serif';">For more information about the Magnatune.com memberships, and to sign up, go to </span><a href="http://magnatune.com/compare_plans?referal_id=amarok"><span style=" font-family:'Sans Serif'; text-decoration: underline; color:#0000ff;">http://magnatune.com/compare_plans</span></a></p></body></html> - - - true - - - true - - - - - - - - - - - 0 - 0 - - - - Stream Options - - - - - - Preview stream type: - - - - - - - - Ogg - - - - - High Quality Mp3 - - - - - Low Quality Mp3 - - - - - - - - - - - - KLineEdit - QLineEdit -
    klineedit.h
    -
    -
    - - - - isMemberCheckbox - toggled(bool) - typeComboBox - setEnabled(bool) - - - 76 - 51 - - - 252 - 81 - - - - - isMemberCheckbox - toggled(bool) - usernameEdit - setEnabled(bool) - - - 76 - 51 - - - 252 - 115 - - - - - isMemberCheckbox - toggled(bool) - passwordEdit - setEnabled(bool) - - - 76 - 51 - - - 252 - 150 - - - - -
    diff --git a/amarok/src/services/magnatune/MagnatuneDatabaseHandler.cpp b/amarok/src/services/magnatune/MagnatuneDatabaseHandler.cpp deleted file mode 100644 index c5cdedef..00000000 --- a/amarok/src/services/magnatune/MagnatuneDatabaseHandler.cpp +++ /dev/null @@ -1,310 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2006,2007 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "MagnatuneDatabaseHandler.h" - -#include -#include -#include - -using namespace Meta; - -MagnatuneDatabaseHandler::MagnatuneDatabaseHandler() -{} - - -MagnatuneDatabaseHandler::~MagnatuneDatabaseHandler() -{} - -void -MagnatuneDatabaseHandler::createDatabase( ) -{ - //Get database instance - SqlStorage *sqlDb = StorageManager::instance()->sqlStorage(); - - QString autoIncrement = "AUTO_INCREMENT"; - - // create table containing tracks - QString queryString = "CREATE TABLE magnatune_tracks (" - "id INTEGER PRIMARY KEY " + autoIncrement + ',' + - "name " + sqlDb->textColumnType() + ',' + - "track_number INTEGER," - "length INTEGER," - "album_id INTEGER," - "artist_id INTEGER," - "preview_lofi " + sqlDb->exactTextColumnType() + ',' + - "preview_ogg " + sqlDb->exactTextColumnType() + ',' + - "preview_url " + sqlDb->exactTextColumnType() + ") ENGINE = MyISAM;"; - - debug() << "Creating mangnatune_tracks: " << queryString; - - - QStringList result = sqlDb->query( queryString ); - - sqlDb->query( "CREATE INDEX magnatune_tracks_album_id ON magnatune_tracks(album_id);" ); - sqlDb->query( "CREATE INDEX magnatune_tracks_artist_id ON magnatune_tracks(artist_id);" ); - - //Create album table - queryString = "CREATE TABLE magnatune_albums (" - "id INTEGER PRIMARY KEY " + autoIncrement + ',' + - "name " + sqlDb->textColumnType() + ',' + - "year INTEGER," - "artist_id INTEGER," - "album_code " + sqlDb->textColumnType() + ',' + - "cover_url " + sqlDb->exactTextColumnType() + ',' + - "description " + sqlDb->exactTextColumnType() + ") ENGINE = MyISAM;"; - - debug() << "Creating Mangnatune_albums: " << queryString; - - result = sqlDb->query( queryString ); - - sqlDb->query( "CREATE INDEX magnatune_albums_name ON magnatune_albums(name);" ); - sqlDb->query( "CREATE INDEX magnatune_albums_artist_id ON magnatune_albums(artist_id);" ); - - - //Create artist table - queryString = "CREATE TABLE magnatune_artists (" - "id INTEGER PRIMARY KEY " + autoIncrement + ',' + - "name " + sqlDb->textColumnType() + ',' + - "artist_page " + sqlDb->exactTextColumnType() + ',' + - "description " + sqlDb->textColumnType() + ',' + - "photo_url " + sqlDb->exactTextColumnType() + ") ENGINE = MyISAM;"; - - debug() << "Creating mangnatune_artist: " << queryString; - - result = sqlDb->query( queryString ); - - sqlDb->query( "CREATE INDEX magnatune_artists_name ON magnatune_artists(name);" ); - - //create genre table - queryString = "CREATE TABLE magnatune_genre (" - "id INTEGER PRIMARY KEY " + autoIncrement + ',' + - "name " + sqlDb->textColumnType() + ',' + - "album_id INTEGER" + ") ENGINE = MyISAM;"; - - result = sqlDb->query( queryString ); - - sqlDb->query( "CREATE INDEX magnatune_genre_name ON magnatune_genre(name);" ); - sqlDb->query( "CREATE INDEX magnatune_genre_album_id ON magnatune_genre(album_id);" ); - - - //create moods table - queryString = "CREATE TABLE magnatune_moods (" - "id INTEGER PRIMARY KEY " + autoIncrement + ',' + - "track_id INTEGER," + - "mood " + sqlDb->textColumnType() + ") ENGINE = MyISAM;"; - - debug() << "Creating mangnatune_moods: " << queryString; - - result = sqlDb->query( queryString ); - - - -} - -void -MagnatuneDatabaseHandler::destroyDatabase( ) -{ - SqlStorage *sqlDb = StorageManager::instance()->sqlStorage(); - QStringList result = sqlDb->query( "DROP TABLE IF EXISTS magnatune_tracks;" ); - result = sqlDb->query( "DROP TABLE IF EXISTS magnatune_albums;" ); - result = sqlDb->query( "DROP TABLE IF EXISTS magnatune_artists;" ); - result = sqlDb->query( "DROP TABLE IF EXISTS magnatune_genre;" ); - result = sqlDb->query( "DROP TABLE IF EXISTS magnatune_moods;" ); - - - /* that would only work for db2/oracle. Other databases connect the index to the table (which we just dropped) - result = sqlDb->query( "DROP INDEX magnatune_tracks_artist_id;"); - result = sqlDb->query( "DROP INDEX magnatune_tracks_album_id;"); - result = sqlDb->query( "DROP INDEX magnatune_album_name;"); - result = sqlDb->query( "DROP INDEX magnatune_album_artist_id;"); - result = sqlDb->query( "DROP INDEX magnatune_artist_name;"); - result = sqlDb->query( "DROP INDEX magnatune_genre_album_id;"); - result = sqlDb->query( "DROP INDEX magnatune_genre_name;"); - */ - - /* if ( sqlDb->type() == DbConnection::postgresql ) - { - sqlDb->query( QString( "DROP SEQUENCE magnatune_track_seq;" ) ); - sqlDb->query( QString( "DROP SEQUENCE magnatune_album_seq;" ) ); - sqlDb->query( QString( "DROP SEQUENCE magnatune_artist_seq;" ) ); - sqlDb->query( QString( "DROP SEQUENCE magnatune_moods_seq;" ) ); - }*/ -} - -int -MagnatuneDatabaseHandler::insertTrack( ServiceTrack *track ) -{ - MagnatuneTrack * mTrack = static_cast ( track ); - - SqlStorage *sqlDb = StorageManager::instance()->sqlStorage(); - QString queryString = "INSERT INTO magnatune_tracks ( name, track_number, length, " - "album_id, artist_id, preview_lofi, preview_ogg, preview_url ) VALUES ( '" - + sqlDb->escape( mTrack->name()) + "', " - + QString::number( mTrack->trackNumber() ) + ", " - + QString::number( mTrack->length() * 1000 ) + ", " - + QString::number( mTrack->albumId() ) + ", " - + QString::number( mTrack->artistId() ) + ", '" - + sqlDb->escape( mTrack->lofiUrl() ) + "', '" - + sqlDb->escape( mTrack->oggUrl() ) + "', '" - + sqlDb->escape( mTrack->uidUrl() ) + "' );"; - - - // debug() << "Adding Magnatune track " << queryString; - int trackId = sqlDb->insert( queryString, NULL ); - - return trackId; - - -} - -int -MagnatuneDatabaseHandler::insertAlbum( ServiceAlbum *album ) -{ - - MagnatuneAlbum * mAlbum = static_cast ( album ); - - QString queryString; - SqlStorage *sqlDb = StorageManager::instance()->sqlStorage(); - queryString = "INSERT INTO magnatune_albums ( name, year, artist_id, " - "album_code, cover_url, description ) VALUES ( '" - + sqlDb->escape( sqlDb->escape( mAlbum->name() ) ) + "', " - + QString::number( mAlbum->launchYear() ) + ", " - + QString::number( mAlbum->artistId() ) + ", '" - + sqlDb->escape( mAlbum->albumCode() ) + "', '" - + sqlDb->escape( mAlbum->coverUrl() ) + "', '" - + sqlDb->escape( mAlbum->description() )+ "' );"; - - //debug() << "Adding Magnatune album " << queryString; - - return sqlDb->insert( queryString, 0 ); -} - - - -int -MagnatuneDatabaseHandler::insertArtist( ServiceArtist *artist ) -{ - MagnatuneArtist * mArtist = static_cast ( artist ); - - QString queryString; - SqlStorage *sqlDb = StorageManager::instance()->sqlStorage(); - queryString = "INSERT INTO magnatune_artists ( name, artist_page, description, " - "photo_url ) VALUES ( '" - + sqlDb->escape( mArtist->name() ) + "', '" - + sqlDb->escape( mArtist->magnatuneUrl()) + "', '" - + sqlDb->escape( mArtist->description() ) + "', '" - + sqlDb->escape( mArtist->photoUrl() ) + "' );"; - - //debug() << "Adding Magnatune artist " << queryString; - - return sqlDb->insert( queryString, 0 ); -} - - -void -MagnatuneDatabaseHandler::begin( ) -{ - - SqlStorage *sqlDb = StorageManager::instance()->sqlStorage(); - - QString queryString = "BEGIN;"; - - sqlDb->query( queryString ); -} - -void -MagnatuneDatabaseHandler::commit( ) -{ - SqlStorage *sqlDb = StorageManager::instance()->sqlStorage(); - QString queryString = "COMMIT;"; - - sqlDb->query( queryString ); - sqlDb->query( "FLUSH TABLES;" ); -} - -void MagnatuneDatabaseHandler::insertMoods(int trackId, const QStringList &moods) -{ - - QString queryString; - SqlStorage *sqlDb = StorageManager::instance()->sqlStorage(); - - foreach( const QString &mood, moods ) { - queryString = "INSERT INTO magnatune_moods ( track_id, mood ) VALUES ( " - + QString::number( trackId ) + ", '" - + sqlDb->escape( mood ) + "' );"; - - - //debug() << "Adding Magnatune mood: " << queryString; - sqlDb->insert( queryString, NULL ); - } -} - -int MagnatuneDatabaseHandler::getArtistIdByExactName(const QString & name) -{ - - SqlStorage *sqlDb = StorageManager::instance()->sqlStorage(); - - QString queryString = "SELECT id from magnatune_artists WHERE name='" + sqlDb->escape( name ) + "';"; - QStringList result = sqlDb->query( queryString ); - - //debug() << "Looking for id of artist " << name << ":"; - - if ( result.size() < 1 ) return -1; - int artistId = result.first().toInt(); - - //debug() << " Found: " << QString::number( artistId ) << ":"; - - return artistId; - -} - -int MagnatuneDatabaseHandler::getAlbumIdByAlbumCode(const QString & albumcode) -{ - SqlStorage *sqlDb = StorageManager::instance()->sqlStorage(); - - QString queryString = "SELECT id from magnatune_albums WHERE album_code='" + sqlDb->escape( albumcode ) + "';"; - QStringList result = sqlDb->query( queryString ); - - //debug() << "Looking for id of album " << albumcode << ":"; - - if ( result.size() < 1 ) return -1; - int albumId = result.first().toInt(); - - //debug() << " Found: " << QString::number( albumId ) << ":"; - - return albumId; -} - -int MagnatuneDatabaseHandler::insertGenre(ServiceGenre * genre) -{ - QString queryString; - SqlStorage *sqlDb = StorageManager::instance()->sqlStorage(); - queryString = "INSERT INTO magnatune_genre ( album_id, name " - ") VALUES ( " - + QString::number ( genre->albumId() ) + ", '" - + sqlDb->escape( genre->name() ) + "' );"; - - //debug() << "Adding Jamendo genre " << queryString; - - return sqlDb->insert( queryString, 0 ); -} - - - - - - diff --git a/amarok/src/services/magnatune/MagnatuneDatabaseHandler.h b/amarok/src/services/magnatune/MagnatuneDatabaseHandler.h deleted file mode 100644 index 41f3d628..00000000 --- a/amarok/src/services/magnatune/MagnatuneDatabaseHandler.h +++ /dev/null @@ -1,113 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2006,2007 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef MAGNATUNEDATABASEHANDLER_H -#define MAGNATUNEDATABASEHANDLER_H - -#include "MagnatuneMeta.h" - -#include -#include - -/** -* This class wraps the database operations needed by the MagnatuneStore -* Uses the singleton pattern -* -* @author Nikolaj Hald Nielsen -*/ -class MagnatuneDatabaseHandler { -public: - - - /** - * Private constructor (singleton pattern) - * @return Pointer to new object - */ - MagnatuneDatabaseHandler(); - - - ~MagnatuneDatabaseHandler(); - - /** - * Creates the tables needed to store Magnatune info - */ - void createDatabase(); - - /** - * Destroys Magnatune tables - */ - void destroyDatabase(); - - /** - * Inserts a new track into the Magnatune database - * @param track pointer to the track to insert - * @return the database id of the newly inserted track - */ - int insertTrack( Meta::ServiceTrack *track ); - - /** - * inserts a new album into the Magnatune database - * @param album pointer to the album to insert - * @return the database id of the newly inserted album - */ - int insertAlbum( Meta::ServiceAlbum *album ); - - /** - * inserts a new artist into the Magnatune database - * @param artist pointer to the artist to insert - * @return the database id of the newly inserted artist - */ - int insertArtist( Meta::ServiceArtist *artist ); - - /** - * inserts a new genre into the Magnatune database - * @param genre pointer to the genre to insert - * @return the database id of the newly inserted genre - */ - int insertGenre( Meta::ServiceGenre *genre ); - - - void insertMoods(int trackId, const QStringList &moods); - - /** - * Retrieves the id of a named artist - * @param name artist name to retrieve - * @return id of artist. -1 if no artist is found - */ - int getArtistIdByExactName(const QString &name); - - /** - * Retrieves the id of an album based on its unique album code. - * @param albumcode The album code. - * @return The id of the album, -1 if not foud. - */ - int getAlbumIdByAlbumCode( const QString &albumcode ); - - - - /** - * Begins a database transaction. Must be followed by a later call to commit() - */ - void begin(); - - /** - * Completes (executes) a database transaction. Must be preceded by a call to begin() - */ - void commit(); - -}; - -#endif diff --git a/amarok/src/services/magnatune/MagnatuneDatabaseWorker.cpp b/amarok/src/services/magnatune/MagnatuneDatabaseWorker.cpp deleted file mode 100644 index e5445871..00000000 --- a/amarok/src/services/magnatune/MagnatuneDatabaseWorker.cpp +++ /dev/null @@ -1,202 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "MagnatuneDatabaseWorker.h" - -#include -#include - -MagnatuneDatabaseWorker::MagnatuneDatabaseWorker() - : ThreadWeaver::Job() - , m_registry( 0 ) -{ - connect( this, SIGNAL(done(ThreadWeaver::Job*)), SLOT(completeJob()) ); -} - - -MagnatuneDatabaseWorker::~MagnatuneDatabaseWorker() -{ -} - - -void -MagnatuneDatabaseWorker::run() -{ - DEBUG_BLOCK - switch ( m_task ) { - case FETCH_MODS: - doFetchMoodMap(); - break; - case FETCH_MOODY_TRACKS: - doFetchTrackswithMood(); - break; - case ALBUM_BY_SKU: - doFetchAlbumBySku(); - break; - default: - break; - } -} - -void MagnatuneDatabaseWorker::completeJob() -{ - DEBUG_BLOCK - switch ( m_task ) { - case FETCH_MODS: - emit( gotMoodMap( m_moodMap ) ); - break; - case FETCH_MOODY_TRACKS: - emit( gotMoodyTracks( m_moodyTracks ) ); - break; - case ALBUM_BY_SKU: - emit( gotAlbumBySku( m_album ) ); - break; - default: - break; - } - deleteLater(); -} - - - - -void MagnatuneDatabaseWorker::fetchMoodMap() -{ - m_task = FETCH_MODS; - m_moodMap.clear(); -} - -void MagnatuneDatabaseWorker::fetchTrackswithMood( const QString &mood, int noOfTracks, ServiceSqlRegistry * registry ) -{ - m_task = FETCH_MOODY_TRACKS; - m_mood = mood; - m_noOfTracks = noOfTracks; - - m_registry = registry; - - m_moodyTracks.clear(); -} - -void MagnatuneDatabaseWorker::fetchAlbumBySku( const QString & sku, ServiceSqlRegistry * registry ) -{ - DEBUG_BLOCK - m_task = ALBUM_BY_SKU; - m_sku = sku; - m_registry = registry; -} - - -void MagnatuneDatabaseWorker::doFetchMoodMap() -{ - SqlStorage *sqlDb = StorageManager::instance()->sqlStorage(); - QString queryString = "select count( mood ), mood from magnatune_moods GROUP BY mood;"; - debug() << "Querying for moods: " << queryString; - QStringList result = sqlDb->query( queryString ); - debug() << "result: " << result; - - while ( !result.isEmpty() ) { - int count = result.takeFirst().toInt(); - QString string = result.takeFirst(); - m_moodMap.insert( string, count ); - } - -} - -void MagnatuneDatabaseWorker::doFetchTrackswithMood() -{ - SqlStorage *sqlDb = StorageManager::instance()->sqlStorage(); - - - - //ok, a huge join turned out to be _really_ slow, so lets chop up the query a bit... - - QString queryString = "SELECT DISTINCT track_id FROM magnatune_moods WHERE mood =\"" + m_mood + "\" ORDER BY RANDOM() LIMIT " + QString::number( m_noOfTracks, 10 ) + ';'; - - QStringList result = sqlDb->query( queryString ); - - int rowCount = ( m_registry->factory()->getTrackSqlRowCount() + - m_registry->factory()->getAlbumSqlRowCount() + - m_registry->factory()->getArtistSqlRowCount() + - m_registry->factory()->getGenreSqlRowCount() ); - - foreach( const QString &idString, result ) { - - QString queryString = "SELECT DISTINCT "; - - - queryString += m_registry->factory()->getTrackSqlRows() + ',' + - m_registry->factory()->getAlbumSqlRows() + ',' + - m_registry->factory()->getArtistSqlRows() + ',' + - m_registry->factory()->getGenreSqlRows(); - - queryString += " FROM magnatune_tracks LEFT JOIN magnatune_albums ON magnatune_tracks.album_id = magnatune_albums.id LEFT JOIN magnatune_artists ON magnatune_albums.artist_id = magnatune_artists.id LEFT JOIN magnatune_genre ON magnatune_genre.album_id = magnatune_albums.id"; - - queryString += " WHERE magnatune_tracks.id = " + idString; - queryString += " GROUP BY magnatune_tracks.id"; - - //debug() << "Querying for moody tracks: " << queryString; - - QStringList result = sqlDb->query( queryString ); - //debug() << "result: " << result; - - - - int resultRows = result.count() / rowCount; - - for( int i = 0; i < resultRows; i++ ) - { - QStringList row = result.mid( i*rowCount, rowCount ); - - Meta::TrackPtr trackptr = m_registry->getTrack( row ); - - m_moodyTracks.append( trackptr ); - } - } - -} - -void MagnatuneDatabaseWorker::doFetchAlbumBySku() -{ - DEBUG_BLOCK - - ServiceMetaFactory * metaFactory = m_registry->factory(); - - QString rows = metaFactory->getAlbumSqlRows() - + ',' - + metaFactory->getArtistSqlRows(); - - SqlStorage *sqlDb = StorageManager::instance()->sqlStorage(); - QString queryString = "SELECT " + rows + " FROM magnatune_albums LEFT JOIN magnatune_artists ON magnatune_albums.artist_id = magnatune_artists.id WHERE album_code = '" + m_sku + "';"; - debug() << "Querying for album: " << queryString; - QStringList result = sqlDb->query( queryString ); - debug() << "result: " << result; - - if ( result.count() == metaFactory->getAlbumSqlRowCount() + metaFactory->getArtistSqlRowCount() ) - { - Meta::AlbumPtr albumPtr = m_registry->getAlbum( result ); - //make a magnatune album out of this... - - m_album = dynamic_cast( albumPtr.data() ); - - } - else - { - m_album = 0; - } -} - -#include "moc_MagnatuneDatabaseWorker.cpp" - diff --git a/amarok/src/services/magnatune/MagnatuneDatabaseWorker.h b/amarok/src/services/magnatune/MagnatuneDatabaseWorker.h deleted file mode 100644 index d384aa52..00000000 --- a/amarok/src/services/magnatune/MagnatuneDatabaseWorker.h +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef MAGNATUNEDATABASEWORKER_H -#define MAGNATUNEDATABASEWORKER_H - -#include "MagnatuneMeta.h" - -#include "../ServiceSqlRegistry.h" - -#include - -/** -A small helper class to do some simple asynchroneous database queries - - @author Nikolaj Hald Nielsen -*/ - -class MagnatuneDatabaseWorker : public ThreadWeaver::Job -{ - Q_OBJECT -public: - MagnatuneDatabaseWorker(); - - ~MagnatuneDatabaseWorker(); - - void run(); - - void fetchMoodMap(); - void fetchTrackswithMood( const QString &mood, int noOfTracks, ServiceSqlRegistry * registry ); - void fetchAlbumBySku( const QString &sku, ServiceSqlRegistry * registry ); - -signals: - - void gotMoodMap( QMap map ); - void gotMoodyTracks( Meta::TrackList tracks ); - void gotAlbumBySku( Meta::MagnatuneAlbum * album ); - -private slots: - void completeJob(); - -private: - - void doFetchMoodMap(); - void doFetchTrackswithMood(); - void doFetchAlbumBySku(); - - enum taskType { FETCH_MODS, FETCH_MOODY_TRACKS, ALBUM_BY_SKU }; - - int m_task; - - QMap m_moodMap; - Meta::TrackList m_moodyTracks; - - QString m_mood; - QString m_sku; - int m_noOfTracks; - Meta::MagnatuneAlbum * m_album; - - ServiceSqlRegistry * m_registry; - - -}; - -#endif diff --git a/amarok/src/services/magnatune/MagnatuneDownloadDialog.cpp b/amarok/src/services/magnatune/MagnatuneDownloadDialog.cpp deleted file mode 100644 index 54e439fe..00000000 --- a/amarok/src/services/magnatune/MagnatuneDownloadDialog.cpp +++ /dev/null @@ -1,103 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2006,2007 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "MagnatuneDownloadDialog.h" - -#include "core/support/Amarok.h" -#include "core/support/Debug.h" - -#include -#include - - - - -MagnatuneDownloadDialog::MagnatuneDownloadDialog( QWidget *parent, Qt::WFlags fl ) - : QDialog( parent, fl ) -{ - setupUi(this); - downloadTargetURLRequester->fileDialog()->setMode( KFile::Directory ); - -} - -MagnatuneDownloadDialog::~MagnatuneDownloadDialog() -{ -} - - -void MagnatuneDownloadDialog::downloadButtonClicked( ) -{ - - if ( m_currentDownloadInfo.password().isEmpty() ) return; - - QString format = formatComboBox->currentText(); - QString path = downloadTargetURLRequester->url().url(); - - //store to config for next download: - KConfigGroup config = Amarok::config( "Service_Magnatune" ); - config.writeEntry( "Download Format", format ); - config.writeEntry( "Download Path", path ); - - m_currentDownloadInfo.setFormatSelection( format ); - - KUrl unpackLocation = downloadTargetURLRequester->url(); - unpackLocation.adjustPath( KUrl::AddTrailingSlash ); - m_currentDownloadInfo.setUnpackUrl( unpackLocation.directory( KUrl::ObeyTrailingSlash ) ); - - emit( downloadAlbum( m_currentDownloadInfo ) ); - - close(); - -} - -void MagnatuneDownloadDialog::setDownloadInfo( MagnatuneDownloadInfo info ) -{ - - m_currentDownloadInfo = info; - - DownloadFormatMap formatMap = info.formatMap(); - - DownloadFormatMap::Iterator it; - - for ( it = formatMap.begin(); it != formatMap.end(); ++it ) - { - formatComboBox->addItem( it.key() ); - } - - infoEdit->setText( info.downloadMessage() ); - - //restore format and path from last time, if any. - KConfigGroup config = Amarok::config("Service_Magnatune"); - QString format = config.readEntry( "Download Format", QString() ); - QString path = config.readEntry( "Download Path", QString() ); - - if ( !format.isEmpty() ) { - int index = formatComboBox->findText( format ); - if ( index != -1 ) - formatComboBox->setCurrentIndex( index ); - } - - if ( !path.isEmpty() ) { - downloadTargetURLRequester->setUrl( KUrl(path) ); - } - -} - -/*$SPECIALIZATION$*/ - - -#include "moc_MagnatuneDownloadDialog.cpp" - diff --git a/amarok/src/services/magnatune/MagnatuneDownloadDialog.h b/amarok/src/services/magnatune/MagnatuneDownloadDialog.h deleted file mode 100644 index b6c84e3a..00000000 --- a/amarok/src/services/magnatune/MagnatuneDownloadDialog.h +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2006,2007 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef MAGNATUNEDOWNLOADDIALOG_H -#define MAGNATUNEDOWNLOADDIALOG_H - -#include "ui_MagnatuneDownloadDialogBase.h" -#include "MagnatuneDownloadInfo.h" - -#include - - -/** - Dialog for choosing download format and location. Also displays additional info from Magnatune.com. - - @author Nikolaj Hald Nielsen -*/ -class MagnatuneDownloadDialog : public QDialog, public Ui::magnatuneDownloadDialogBase -{ - Q_OBJECT - -public: - /** - * Overridden constructor. - * @param parent Pointer to the parent QWidget. - * @param name Name of this widget. - * @param modal Sets modal state. - * @param fl Additional dialog flags. - */ - explicit MagnatuneDownloadDialog( QWidget* parent = 0, Qt::WFlags fl = 0 ); - - /** - * Destructor - */ - ~MagnatuneDownloadDialog(); - /*$PUBLIC_FUNCTIONS$*/ - - /** - * Sets the current download info - * @param the MagnatuneDownloadInfo class containing the information abut the - * download to display - */ - void setDownloadInfo( MagnatuneDownloadInfo info ); - -signals: - - /** - * Signal emitted when all needed info has been gathered and handler - * should start album download. - * @param completedInfo A DownloadInfo object containing all needed information - */ - void downloadAlbum( MagnatuneDownloadInfo completedInfo ); - -public slots: - /*$PUBLIC_SLOTS$*/ - -protected: - /*$PROTECTED_FUNCTIONS$*/ - MagnatuneDownloadInfo m_currentDownloadInfo; - -protected slots: - /*$PROTECTED_SLOTS$*/ - /** - * Slot for recieving notification when the download button is clicked. - */ - void downloadButtonClicked(); - -}; - -#endif - diff --git a/amarok/src/services/magnatune/MagnatuneDownloadDialogBase.ui b/amarok/src/services/magnatune/MagnatuneDownloadDialogBase.ui deleted file mode 100644 index e47a1570..00000000 --- a/amarok/src/services/magnatune/MagnatuneDownloadDialogBase.ui +++ /dev/null @@ -1,118 +0,0 @@ - - magnatuneDownloadDialogBase - - - - 0 - 0 - 526 - 568 - - - - Magnatune.com Album Download - - - - - - Download options - - - - - - Select Format: - - - false - - - - - - - - - - Download to: - - - false - - - - - - - - - - If you download to a location that is already being monitored by Amarok, the album will automatically be added to your collection. - - - Qt::AlignVCenter - - - true - - - - - - - - - - Magnatune info - - - - - - false - - - - - - - - - - &Download - - - - - - - - - KUrlRequester - QFrame -
    kurlrequester.h
    - 1 -
    -
    - - - - - downloadButton - clicked() - magnatuneDownloadDialogBase - downloadButtonClicked() - - - 262 - 547 - - - 262 - 283 - - - - -
    diff --git a/amarok/src/services/magnatune/MagnatuneDownloadHandler.cpp b/amarok/src/services/magnatune/MagnatuneDownloadHandler.cpp deleted file mode 100644 index 75d2f465..00000000 --- a/amarok/src/services/magnatune/MagnatuneDownloadHandler.cpp +++ /dev/null @@ -1,208 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2006,2007 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "MagnatuneDownloadHandler.h" - -#include "core/interfaces/Logger.h" -#include "core/support/Amarok.h" -#include "core/support/Components.h" -#include "core/support/Debug.h" -#include "MagnatuneDatabaseHandler.h" -#include "MagnatuneConfig.h" - -#include -#include - -#include -#include -#include - -using namespace Meta; - -MagnatuneDownloadHandler::MagnatuneDownloadHandler() - : QObject() - , m_downloadDialog( 0 ) - , m_albumDownloader( 0 ) - , m_currentAlbum( 0 ) - , m_membershipDownload( false ) -{ -} - - -MagnatuneDownloadHandler::~MagnatuneDownloadHandler() -{ - delete m_downloadDialog; - delete m_albumDownloader; -} - - -void MagnatuneDownloadHandler::downloadAlbum( MagnatuneAlbum * album ) -{ - DEBUG_BLOCK - m_currentAlbum = album; - - //do we have a membership that allows free downloads? - - MagnatuneConfig config; - - if ( config.isMember() && config.membershipType() == MagnatuneConfig::DOWNLOAD ) { - debug() << "membership download..."; - membershipDownload( config.membershipType(), config.username(), config.password() ); - } -} - - - -void MagnatuneDownloadHandler::membershipDownload( int membershipType, const QString &username, const QString &password ) -{ - QString type; - if( membershipType == MagnatuneConfig::STREAM ) - type = "stream"; - else - type = "download"; - - QString purchaseURL = "http://" + username + ":" + password + "@" + type + ".magnatune.com/buy/membership_free_dl_xml?sku=" + m_currentAlbum->albumCode() + "&id=amarok"; - - m_membershipDownload = true; - - m_resultDownloadJob = KIO::storedGet( KUrl( purchaseURL ), KIO::NoReload, KIO::HideProgressInfo ); - Amarok::Components::logger()->newProgressOperation( m_resultDownloadJob, - i18n( "Processing download" ) ); - connect( m_resultDownloadJob, SIGNAL(result(KJob*)), SLOT(xmlDownloadComplete(KJob*)) ); -} - -void MagnatuneDownloadHandler::xmlDownloadComplete( KJob * downloadJob ) -{ - - debug() << "xml download complete"; - - if ( !downloadJob->error() == 0 ) - { - //TODO: error handling here - debug() << "Job error... " << downloadJob->error(); - return ; - } - if ( downloadJob != m_resultDownloadJob ) { - debug() << "Wrong job..."; - return ; //not the right job, so let's ignore it - } - - KIO::StoredTransferJob* const storedJob = static_cast( downloadJob ); - QString resultXml = QString( storedJob->data() ); - - debug() << endl << endl << "result: " << resultXml; - - - if ( m_albumDownloader == 0 ) - { - m_albumDownloader = new MagnatuneAlbumDownloader(); - connect( m_albumDownloader, SIGNAL(downloadComplete(bool)), this, SLOT(albumDownloadComplete(bool)) ); - } - - if ( m_downloadDialog == 0 ) - { - m_downloadDialog = new MagnatuneDownloadDialog( m_parent ); - m_downloadDialog->setModal( true ); - connect( m_downloadDialog, SIGNAL(downloadAlbum(MagnatuneDownloadInfo)), m_albumDownloader, SLOT(downloadAlbum(MagnatuneDownloadInfo)) ); - //connect( m_downloadDialog, SIGNAL(rejected()), this, SLOT(albumPurchaseCancelled()) ); - - } - - - MagnatuneDownloadInfo downloadInfo; - if ( downloadInfo.initFromString( resultXml, m_membershipDownload ) ) - { - - downloadInfo.setAlbumCode( m_currentAlbum->albumCode() ); - downloadInfo.setCoverUrl( m_currentAlbum->coverUrl() ); - downloadInfo.setAlbumName( m_currentAlbum->prettyName() ); - downloadInfo.setArtistName( m_currentAlbum->albumArtist()->prettyName() ); - - if ( m_membershipDownload ) { - MagnatuneConfig config; - downloadInfo.setMembershipInfo( config.username(), config.password() ); - } else { - saveDownloadInfo( resultXml ); - } - - m_downloadDialog->setDownloadInfo( downloadInfo ); - //m_purchaseDialog->close(); - - - m_downloadDialog->show(); - } else { - - KMessageBox::information( m_parent, i18n( "There seems to be an error in the supplied membership information. Please correct this and try again."),i18n("Could not process download") ); - } -} - - -void MagnatuneDownloadHandler::setParent( QWidget * parent ) -{ - m_parent = parent; - -} - -void MagnatuneDownloadHandler::saveDownloadInfo( const QString &infoXml ) -{ - - MagnatuneDatabaseHandler dbHandler; - - QDir purchaseDir( Amarok::saveLocation( "magnatune.com/purchases/" ) ); - - debug() << "magnatune save location" << purchaseDir.absolutePath(); - - //if directory does not exist, create it - if ( ! purchaseDir.exists () ) - { - purchaseDir.mkdir( "." ); - } - - QString fileName = m_currentAlbum->albumArtist()->name() + " - " + m_currentAlbum->name(); - - QFile file( purchaseDir.absolutePath() + '/' + fileName ); - - //Skip if file already exists - if ( file.exists () ) - return ; - - //write info - if ( file.open( QIODevice::WriteOnly | QIODevice::Text ) ) - { - QTextStream stream( &file ); - stream << infoXml << "\n"; - file.close(); - } -} - -void MagnatuneDownloadHandler::albumDownloadComplete( bool success ) -{ - //cleanup time! - - debug() << "MagnatuneDownloadHandler::albumDownloadComplete"; - - delete m_downloadDialog; - m_downloadDialog = 0; - - emit( downloadCompleted( success ) ); - -} - - -#include "moc_MagnatuneDownloadHandler.cpp" - - - diff --git a/amarok/src/services/magnatune/MagnatuneDownloadHandler.h b/amarok/src/services/magnatune/MagnatuneDownloadHandler.h deleted file mode 100644 index b257440e..00000000 --- a/amarok/src/services/magnatune/MagnatuneDownloadHandler.h +++ /dev/null @@ -1,85 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2006,2007 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef MAGNATUNEDOWNLOADHANDLER_H -#define MAGNATUNEDOWNLOADHANDLER_H - -#include -#include -#include - -#include "MagnatuneAlbumDownloader.h" -#include "MagnatuneDownloadDialog.h" -#include "MagnatuneMeta.h" - - -/** -The main class responcible for handling of downloads from Magnatune.com - -@author Nikolaj Hald Nielsen -*/ -class MagnatuneDownloadHandler : public QObject -{ -Q_OBJECT -public: - MagnatuneDownloadHandler(); - ~MagnatuneDownloadHandler(); - - void setParent( QWidget * parent ); - /** - * Starts a download operation - * @param album The album to download - */ - void downloadAlbum( Meta::MagnatuneAlbum * album ); - -signals: - - void downloadCompleted( bool success ); - -private: - KIO::TransferJob * m_resultDownloadJob; - - //need a parent to pass to any dialogs we spawn - QWidget * m_parent; - MagnatuneDownloadDialog * m_downloadDialog; - MagnatuneAlbumDownloader * m_albumDownloader; - Meta::MagnatuneAlbum * m_currentAlbum; - QString m_currentAlbumCoverName; - bool m_membershipDownload; - - bool parseDownloadXml( const QString &xml ); - void membershipDownload( int membershipType, const QString &username, const QString &password ); - - /** - * This function saves the xml download info received from Magnatune.com after a - * successful download. This information can be used to later redownload a lost album, - * or acquire an album in a different file format. Note that no personal information - * or credit card number is stored. The information is saved to the amarok config - * directory in the sub folder magnatune.com/purchases. The name of each info file - * is genereated from the artist and album names. - * @param infoXml The info to store. - */ - void saveDownloadInfo(const QString &infoXml); - - -protected slots: - - void xmlDownloadComplete( KJob* downLoadJob ); - void albumDownloadComplete( bool success ); - -}; - -#endif diff --git a/amarok/src/services/magnatune/MagnatuneDownloadInfo.cpp b/amarok/src/services/magnatune/MagnatuneDownloadInfo.cpp deleted file mode 100644 index cbaf504f..00000000 --- a/amarok/src/services/magnatune/MagnatuneDownloadInfo.cpp +++ /dev/null @@ -1,357 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2006,2007 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "MagnatuneDownloadInfo.h" - -#include "core/support/Debug.h" - -#include - -#include -#include - - -MagnatuneDownloadInfo::MagnatuneDownloadInfo() -{ - m_selectedDownloadFormat.clear(); -} - - -MagnatuneDownloadInfo::~MagnatuneDownloadInfo() -{} - -bool -MagnatuneDownloadInfo::initFromString( const QString &downloadInfoString, bool membershipDownload ) -{ - - m_membershipDownload = membershipDownload; - //complete overkill to do a full SAX2 parser for this at the moment... I think.... - - // lets make sure that this is actually a valid result - - int testIndex = downloadInfoString.indexOf( "" ); - if ( testIndex == -1 ) - { - return false; - }; - - int startIndex; - int endIndex; - - if ( membershipDownload == false ) { - startIndex = downloadInfoString.indexOf( "", 0, Qt::CaseInsensitive ); - if ( startIndex != -1 ) - { - endIndex = downloadInfoString.indexOf( "", 0, Qt::CaseInsensitive ); - if ( endIndex != -1 ) - { - startIndex += 13; - - debug() << "found username: " << downloadInfoString.mid( startIndex, endIndex - startIndex ); - m_userName = downloadInfoString.mid( startIndex, endIndex - startIndex ); - } - else - { - return false; - } - } - else - { - return false; - } - - - startIndex = downloadInfoString.indexOf( "", 0, Qt::CaseInsensitive ); - if ( startIndex != -1 ) - { - endIndex = downloadInfoString.indexOf( "", 0, Qt::CaseInsensitive ); - if ( endIndex != -1 ) - { - startIndex += 13; - debug() << "found password: " << downloadInfoString.mid( startIndex, endIndex - startIndex ); - m_password = downloadInfoString.mid( startIndex, endIndex - startIndex ); - } - else - { - return false; - } - } - else - { - return false; - } - - } else { - m_userName.clear(); - m_password.clear(); - } - - - startIndex = downloadInfoString.indexOf( "", 0, Qt::CaseInsensitive ); - if ( startIndex != -1 ) - { - endIndex = downloadInfoString.indexOf( "", 0, Qt::CaseInsensitive ); - if ( endIndex != -1 ) - { - startIndex += 12; - debug() << "found wav"; - m_downloadFormats[ "Wav" ] = downloadInfoString.mid( startIndex, endIndex - startIndex ).replace( "&", "&" ); - - } - } - - startIndex = downloadInfoString.indexOf( "", 0, Qt::CaseInsensitive ); - if ( startIndex != -1 ) - { - endIndex = downloadInfoString.indexOf( "", 0, Qt::CaseInsensitive ); - if ( endIndex != -1 ) - { - startIndex += 16; - debug() << "found 128k mp3"; - m_downloadFormats[ "128 kbit/s MP3" ] = downloadInfoString.mid( startIndex, endIndex - startIndex ).replace( "&", "&" ); - - } - } - - startIndex = downloadInfoString.indexOf( "", 0, Qt::CaseInsensitive ); - if ( startIndex != -1 ) - { - endIndex = downloadInfoString.indexOf( "", 0, Qt::CaseInsensitive ); - if ( endIndex != -1 ) - { - startIndex += 12; - debug() << "found ogg-vorbis"; - m_downloadFormats[ "Ogg-Vorbis" ] = downloadInfoString.mid( startIndex, endIndex - startIndex ).replace( "&", "&" ); - - } - } - - startIndex = downloadInfoString.indexOf( "", 0, Qt::CaseInsensitive ); - if ( startIndex != -1 ) - { - endIndex = downloadInfoString.indexOf( "", 0, Qt::CaseInsensitive ); - if ( endIndex != -1 ) - { - startIndex += 12; - debug() << "found vbr mp3"; - m_downloadFormats[ "VBR MP3" ] = downloadInfoString.mid( startIndex, endIndex - startIndex ).replace( "&", "&" ); - - } - } - - startIndex = downloadInfoString.indexOf( "", 0, Qt::CaseInsensitive ); - if ( startIndex != -1 ) - { - endIndex = downloadInfoString.indexOf( "", 0, Qt::CaseInsensitive ); - if ( endIndex != -1 ) - { - startIndex += 13; - debug() << "found flac"; - m_downloadFormats[ "FLAC" ] = downloadInfoString.mid( startIndex, endIndex - startIndex ).replace( "&", "&" ); - - } - } - - startIndex = downloadInfoString.indexOf( "", 0, Qt::CaseInsensitive ); - if ( startIndex != -1 ) - { - endIndex = downloadInfoString.indexOf( "", 0, Qt::CaseInsensitive ); - if ( endIndex != -1 ) - { - startIndex += 9; - debug() << "found dl-message"; - m_downloadMessage = downloadInfoString.mid( startIndex, endIndex - startIndex ).replace( "&", "&" ); - } - } - - return true; -} - -bool -MagnatuneDownloadInfo::initFromRedownloadXml( const QDomElement &element ) -{ - - - m_artistName = element.firstChildElement( "artist" ).text(); - m_albumName = element.firstChildElement( "album" ).text(); - m_userName = element.firstChildElement( "username" ).text(); - m_password = element.firstChildElement( "password" ).text(); - m_albumCode = element.firstChildElement( "sku" ).text(); - m_coverUrl = element.firstChildElement( "cover" ).text(); - - //get formats - QDomNode formats = element.firstChildElement( "formats" ); - - QString wav_url = formats.firstChildElement( "wav_zip" ).text(); - m_downloadFormats[ "Wav" ] = wav_url; - QString mp3_url = formats.firstChildElement( "mp3_zip" ).text(); - m_downloadFormats[ "128 kbit/s MP3" ] = mp3_url; - QString vbr_url = formats.firstChildElement( "vbr_zip" ).text(); - m_downloadFormats[ "VBR MP3" ] = vbr_url; - QString ogg_url = formats.firstChildElement( "ogg_zip" ).text(); - m_downloadFormats[ "Ogg-Vorbis" ] = ogg_url; - QString flac_url = formats.firstChildElement( "flac_zip" ).text(); - m_downloadFormats[ "FLAC" ] = flac_url; - - - m_downloadMessage = i18n( "Redownload of a previously purchased album \"%1\" by \"%2\" from Magnatune.com.\n\nUsername: %3\nPassword: %4\n", m_albumName, m_artistName, m_userName, m_password ); - - return true; - -} - -QString -MagnatuneDownloadInfo::userName( ) -{ - return m_userName; -} - -QString -MagnatuneDownloadInfo::password( ) -{ - return m_password; -} - -QString -MagnatuneDownloadInfo::downloadMessage( ) -{ - return m_downloadMessage; -} - -DownloadFormatMap -MagnatuneDownloadInfo::formatMap() -{ - return m_downloadFormats; -} - -void -MagnatuneDownloadInfo::setFormatSelection( const QString &selectedFormat ) -{ - m_selectedDownloadFormat = selectedFormat; -} - -bool -MagnatuneDownloadInfo::isReadyForDownload( ) -{ - return !m_selectedDownloadFormat.isEmpty(); -} - -KUrl -MagnatuneDownloadInfo::completeDownloadUrl( ) -{ - QString url = m_downloadFormats[ m_selectedDownloadFormat ]; - KUrl downloadUrl(url); - downloadUrl.setUser(m_userName); - downloadUrl.setPass(m_password); - - return downloadUrl; -} - -void -MagnatuneDownloadInfo::setUnpackUrl( const QString &unpackUrl ) -{ - m_unpackUrl = unpackUrl; -} - -QString -MagnatuneDownloadInfo::unpackLocation( ) -{ - return m_unpackUrl; -} - - - -QString -MagnatuneDownloadInfo::albumCode() -{ - return m_albumCode; -} - - - -void -MagnatuneDownloadInfo::setAlbumCode( const QString &albumCode ) -{ - m_albumCode = albumCode; -} - -bool -MagnatuneDownloadInfo::isMembershipDownload() -{ - return m_membershipDownload; -} - -void -MagnatuneDownloadInfo::setMembershipInfo( const QString &username, const QString &password ) -{ - m_userName = username; - m_password = password; -} - -QString -MagnatuneDownloadInfo::albumName() -{ - return m_albumName; -} - -const QString -MagnatuneDownloadInfo::albumName() const -{ - return m_albumName; -} - -QString -MagnatuneDownloadInfo::artistName() -{ - return m_artistName; -} - -const QString -MagnatuneDownloadInfo::artistName() const -{ - return m_artistName; -} - -QString -MagnatuneDownloadInfo::coverUrl() -{ - return m_coverUrl; -} - -const QString -MagnatuneDownloadInfo::coverUrl() const -{ - return m_coverUrl; -} - -void -MagnatuneDownloadInfo::setAlbumName( const QString &albumName ) -{ - m_albumName = albumName; -} - -void -MagnatuneDownloadInfo::setArtistName( const QString &artistName ) -{ - m_artistName = artistName; -} - -void -MagnatuneDownloadInfo::setCoverUrl( const QString &coverUrl ) -{ - m_coverUrl = coverUrl; -} - diff --git a/amarok/src/services/magnatune/MagnatuneDownloadInfo.h b/amarok/src/services/magnatune/MagnatuneDownloadInfo.h deleted file mode 100644 index 2e8a3155..00000000 --- a/amarok/src/services/magnatune/MagnatuneDownloadInfo.h +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2006,2007 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef MAGNATUNE_DOWNLOAD_INFO_H -#define MAGNATUNE_DOWNLOAD_INFO_H - -#include - -#include -#include -#include - - -typedef QMap DownloadFormatMap; - -/** -Class for parsing and storing the info from a download xml file or string - - @author Nikolaj Hald Nielsen -*/ -class MagnatuneDownloadInfo{ -public: - MagnatuneDownloadInfo(); - ~MagnatuneDownloadInfo(); - - bool initFromString( const QString &downloadInfoString, bool membershipDownload ); - bool initFromRedownloadXml( const QDomElement &element ); - - void setMembershipInfo( const QString &username, const QString &password ); - bool isMembershipDownload(); - - DownloadFormatMap formatMap(); - QString userName(); - QString password(); - QString downloadMessage(); - QString albumCode(); - - QString albumName(); - QString artistName(); - QString coverUrl(); - const QString albumName() const; - const QString artistName() const; - const QString coverUrl() const; - - void setAlbumName( const QString &albumName ); - void setArtistName( const QString &artistName ); - void setCoverUrl( const QString &coverUrl ); - void setFormatSelection( const QString &selectedFormat ); - void setUnpackUrl( const QString &unpackUrl ); - void setAlbumCode( const QString & albumCode ); - bool isReadyForDownload(); - KUrl completeDownloadUrl(); - QString unpackLocation(); - - - -protected: - - DownloadFormatMap m_downloadFormats; - QString m_userName; - QString m_password; - QString m_downloadMessage; - - QString m_artistName; - QString m_albumName; - QString m_albumCode; - QString m_coverUrl; - - bool m_membershipDownload; - - //the following members are for storing the user selections regarding a download - QString m_unpackUrl; - QString m_selectedDownloadFormat; - -}; - -#endif diff --git a/amarok/src/services/magnatune/MagnatuneInfoParser.cpp b/amarok/src/services/magnatune/MagnatuneInfoParser.cpp deleted file mode 100644 index f69fd921..00000000 --- a/amarok/src/services/magnatune/MagnatuneInfoParser.cpp +++ /dev/null @@ -1,339 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "MagnatuneInfoParser.h" - -#include "core/support/Components.h" -#include "core/interfaces/Logger.h" -#include "MagnatuneConfig.h" - -#include - - -using namespace Meta; - -void MagnatuneInfoParser::getInfo(ArtistPtr artist) -{ - - showLoading( i18n( "Loading artist info..." ) ); - - MagnatuneArtist * magnatuneArtist = dynamic_cast( artist.data() ); - if ( magnatuneArtist == 0) return; - - // first get the entire artist html page - /* QString tempFile; - QString orgHtml;*/ - - m_infoDownloadJob = KIO::storedGet( magnatuneArtist->magnatuneUrl(), KIO::Reload, KIO::HideProgressInfo ); - Amarok::Components::logger()->newProgressOperation( m_infoDownloadJob, i18n( "Fetching %1 Artist Info", magnatuneArtist->prettyName() ) ); - connect( m_infoDownloadJob, SIGNAL(result(KJob*)), SLOT(artistInfoDownloadComplete(KJob*)) ); - -} - - -void MagnatuneInfoParser::getInfo(AlbumPtr album) -{ - - showLoading( i18n( "Loading album info..." ) ); - - MagnatuneAlbum * magnatuneAlbum = dynamic_cast( album.data() ); - - const QString artistName = album->albumArtist()->name(); - - QString infoHtml = ""; - - infoHtml += generateHomeLink(); - infoHtml += "
    "; - infoHtml += artistName; - infoHtml += "
    "; - infoHtml += magnatuneAlbum->name(); - infoHtml += "

    "; - infoHtml += "coverUrl() + - "\" align=\"middle\" border=\"1\">"; - - // Disable Genre line in Magnatune applet since, well, it doesn't actually put a genre there... - // Nikolaj, FYI: either the thumbnails aren't working, or they aren't getting through the proxy here. That would be odd, however, as the database and - // all HTML are coming through the proxy - //infoHtml += "

    " + i18n( "Genre: ");// + magnatuneAlbum-> - infoHtml += "
    " + i18n( "Release Year: %1", QString::number( magnatuneAlbum->launchYear() ) ); - - if ( !magnatuneAlbum->description().isEmpty() ) { - - //debug() << "MagnatuneInfoParser: Writing description: '" << album->getDescription() << "'"; - infoHtml += "

    " + i18n( "Description:" ) + "

    " + magnatuneAlbum->description(); - - } - - infoHtml += "



    " + i18n( "From Magnatune.com" ) + "
    "; - infoHtml += ""; - - emit ( info( infoHtml ) ); -} - -void MagnatuneInfoParser::getInfo(TrackPtr track) -{ - Q_UNUSED( track ); - return; -} - - - - -void -MagnatuneInfoParser::artistInfoDownloadComplete( KJob *downLoadJob ) -{ - - if ( !downLoadJob->error() == 0 ) - { - //TODO: error handling here - return ; - } - if ( downLoadJob != m_infoDownloadJob ) - return ; //not the right job, so let's ignore it - - - - QString infoString = ( (KIO::StoredTransferJob* ) downLoadJob )->data(); - //debug() << "MagnatuneInfoParser: Artist info downloaded: " << infoString; - infoString = extractArtistInfo( infoString ); - - //debug() << "html: " << trimmedInfo; - - emit ( info( infoString ) ); - -} - -QString -MagnatuneInfoParser::extractArtistInfo( const QString &artistPage ) -{ - QString trimmedHtml; - - - int sectionStart = artistPage.indexOf( "" ); - int sectionEnd = artistPage.indexOf( "", sectionStart ); - - trimmedHtml = artistPage.mid( sectionStart, sectionEnd - sectionStart ); - - int buyStartIndex = trimmedHtml.indexOf( "" ); - int buyEndIndex; - - //we are going to integrate the buying of music (I hope) so remove these links - - while ( buyStartIndex != -1 ) - { - buyEndIndex = trimmedHtml.indexOf( "", buyStartIndex ) + 18; - trimmedHtml.remove( buyStartIndex, buyEndIndex - buyStartIndex ); - buyStartIndex = trimmedHtml.indexOf( "", buyStartIndex ); - } - - - QString infoHtml = ""; - infoHtml += generateHomeLink(); - infoHtml += trimmedHtml; - infoHtml += ""; - - - return infoHtml; -} - -void MagnatuneInfoParser::getFrontPage() -{ - - if( !m_cachedFrontpage.isEmpty() ) - { - emit ( info( m_cachedFrontpage ) ); - return; - } - - showLoading( i18n( "Loading Magnatune.com frontpage..." ) ); - - m_pageDownloadJob = KIO::storedGet( KUrl( "http://magnatune.com/amarok_frontpage.html" ), KIO::Reload, KIO::HideProgressInfo ); - Amarok::Components::logger()->newProgressOperation( m_pageDownloadJob, i18n( "Fetching Magnatune.com front page" ) ); - connect( m_pageDownloadJob, SIGNAL(result(KJob*)), SLOT(frontpageDownloadComplete(KJob*)) ); -} - -void MagnatuneInfoParser::getFavoritesPage() -{ - MagnatuneConfig config; - - if ( !config.isMember() ) - return; - - showLoading( i18n( "Loading your Magnatune.com favorites page..." ) ); - - QString type; - if( config.membershipType() == MagnatuneConfig::STREAM ) - type = "stream"; - else - type = "download"; - - QString user = config.username(); - QString password = config.password(); - - QString url = "http://" + user + ":" + password + "@" + type.toLower() + ".magnatune.com/member/amarok_favorites.php"; - - m_pageDownloadJob = KIO::storedGet( KUrl( url ), KIO::Reload, KIO::HideProgressInfo ); - Amarok::Components::logger()->newProgressOperation( m_pageDownloadJob, i18n( "Loading your Magnatune.com favorites page..." ) ); - connect( m_pageDownloadJob, SIGNAL(result(KJob*)), SLOT(userPageDownloadComplete(KJob*)) ); -} - -void MagnatuneInfoParser::getRecommendationsPage() -{ - MagnatuneConfig config; - - if ( !config.isMember() ) - return; - - showLoading( i18n( "Loading your personal Magnatune.com recommendations page..." ) ); - - QString type; - if( config.membershipType() == MagnatuneConfig::STREAM ) - type = "stream"; - else - type = "download"; - - QString user = config.username(); - QString password = config.password(); - - QString url = "http://" + user + ":" + password + "@" + type.toLower() + ".magnatune.com/member/amarok_recommendations.php"; - - m_pageDownloadJob = KIO::storedGet( KUrl( url ), KIO::Reload, KIO::HideProgressInfo ); - Amarok::Components::logger()->newProgressOperation( m_pageDownloadJob, i18n( "Loading your personal Magnatune.com recommendations page..." ) ); - connect( m_pageDownloadJob, SIGNAL(result(KJob*)), SLOT(userPageDownloadComplete(KJob*)) ); -} - -void MagnatuneInfoParser::frontpageDownloadComplete( KJob * downLoadJob ) -{ - if ( !downLoadJob->error() == 0 ) - { - //TODO: error handling here - return ; - } - if ( downLoadJob != m_pageDownloadJob ) - return ; //not the right job, so let's ignore it - - QString infoString = ((KIO::StoredTransferJob* )downLoadJob)->data(); - - //insert menu - MagnatuneConfig config; - if( config.isMember() ) - infoString.replace( "", generateMemberMenu() ); - - //insert fancy amarok url links to the artists - infoString = createArtistLinks( infoString ); - - if( m_cachedFrontpage.isEmpty() ) - m_cachedFrontpage = infoString; - - emit ( info( infoString ) ); -} - -void MagnatuneInfoParser::userPageDownloadComplete( KJob * downLoadJob ) -{ - if ( !downLoadJob->error() == 0 ) - { - //TODO: error handling here - return ; - } - if ( downLoadJob != m_pageDownloadJob ) - return ; //not the right job, so let's ignore it - - - - QString infoString = ((KIO::StoredTransferJob* )downLoadJob)->data(); - - //insert menu - MagnatuneConfig config; - if( config.isMember() ) - infoString.replace( "", generateMemberMenu() ); - - //make sure that any pages that use the old command name "service_magnatune" replaces it with "service-magnatune" - infoString.replace( "service_magnatune", "service-magnatune" ); - - emit ( info( infoString ) ); -} - - -QString MagnatuneInfoParser::generateMemberMenu() -{ - QString homeUrl = "amarok://service-magnatune?command=show_home"; - QString favoritesUrl = "amarok://service-magnatune?command=show_favorites"; - QString recommendationsUrl = "amarok://service-magnatune?command=show_recommendations"; - - QString menu = "
    " - "[Home] " - "[Favorites] " - "[Recommendations] " - "
    "; - - return menu; -} - -QString -MagnatuneInfoParser::generateHomeLink() -{ - QString homeUrl = "amarok://service-magnatune?command=show_home"; - QString link = "
    " - "[Home] " - "
    "; - - return link; -} - -QString -MagnatuneInfoParser::createArtistLinks( const QString &page ) -{ - //the artist name is wrapped in artist - - QString returnPage = page; - - int startTokenLength = QString( "" ).length(); - - int offset = 0; - int startTokenIndex = page.indexOf( "", offset ); - int endTokenIndex = 0; - - while( startTokenIndex != -1 ) - { - endTokenIndex = page.indexOf( "", startTokenIndex ); - if( endTokenIndex == -1 ) - break; //bail out - - offset = endTokenIndex; - - //get the artist namespace - - int artistLength = endTokenIndex - ( startTokenIndex + startTokenLength ); - QString artist = page.mid( startTokenIndex + startTokenLength, artistLength ); - - //replace in the artist amarok url - - QString replaceString = "" + artist + ""; - QString artistLink = "" + artist + ""; - - returnPage = returnPage.replace( replaceString, artistLink ); - - startTokenIndex = page.indexOf( "", offset ); - } - - return returnPage; -} - - -#include "moc_MagnatuneInfoParser.cpp" - diff --git a/amarok/src/services/magnatune/MagnatuneInfoParser.h b/amarok/src/services/magnatune/MagnatuneInfoParser.h deleted file mode 100644 index 7904b67e..00000000 --- a/amarok/src/services/magnatune/MagnatuneInfoParser.h +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef MAGNATUNEINFOPARSER_H -#define MAGNATUNEINFOPARSER_H - -#include "../InfoParserBase.h" - -#include "MagnatuneMeta.h" - -#include -#include - -class MagnatuneStore; - -/** -Handles the fetching and processing of Jamendo specific information for meta items - - @author -*/ -class MagnatuneInfoParser : public InfoParserBase -{ -Q_OBJECT - -public: - MagnatuneInfoParser() - : InfoParserBase() {} - - ~MagnatuneInfoParser() {} - - - - virtual void getInfo( Meta::ArtistPtr artist ); - virtual void getInfo( Meta::AlbumPtr album ); - virtual void getInfo( Meta::TrackPtr track ); - - void getFrontPage(); - void getFavoritesPage(); - void getRecommendationsPage(); - -private slots: - - void artistInfoDownloadComplete( KJob *downLoadJob ); - void frontpageDownloadComplete( KJob *downLoadJob ); - void userPageDownloadComplete( KJob *downLoadJob ); - -private: - - QString extractArtistInfo( const QString &artistPage ); - QString generateMemberMenu(); - QString generateHomeLink(); - QString createArtistLinks( const QString &page ); - - KJob * m_infoDownloadJob; - KJob * m_pageDownloadJob; - - QString m_cachedFrontpage; - - -}; - -#endif - diff --git a/amarok/src/services/magnatune/MagnatuneMeta.cpp b/amarok/src/services/magnatune/MagnatuneMeta.cpp deleted file mode 100644 index d0ac2e90..00000000 --- a/amarok/src/services/magnatune/MagnatuneMeta.cpp +++ /dev/null @@ -1,394 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "MagnatuneMeta.h" -#include "MagnatuneStore.h" - -#include "core/support/Amarok.h" -#include "core/support/Debug.h" -#include "core-impl/support/UrlStatisticsStore.h" -#include "MagnatuneActions.h" -#include "MagnatuneConfig.h" -#include "SvgHandler.h" - -#include -#include - -#include - -using namespace Meta; - -MagnatuneMetaFactory::MagnatuneMetaFactory( const QString & dbPrefix, MagnatuneStore * store ) - : ServiceMetaFactory( dbPrefix ) - , m_membershipPrefix( QString() ) - , m_streamType( OGG ) - , m_userName( QString() ) - , m_password( QString() ) - , m_store( store ) -{} - -void MagnatuneMetaFactory::setMembershipInfo( const QString &prefix, const QString &userName, const QString &password ) -{ - m_membershipPrefix = prefix; - m_userName = userName; - m_password = password; -} - -void MagnatuneMetaFactory::setStreamType(int type) -{ - m_streamType = type; -} - - -int MagnatuneMetaFactory::getTrackSqlRowCount() -{ - return ServiceMetaFactory::getTrackSqlRowCount() + 2; -} - -QString MagnatuneMetaFactory::getTrackSqlRows() -{ - QString sqlRows = ServiceMetaFactory::getTrackSqlRows(); - - sqlRows += ", "; - sqlRows += tablePrefix() + "_tracks.preview_lofi, "; - sqlRows += tablePrefix() + "_tracks.preview_ogg "; - - return sqlRows; -} - -TrackPtr -MagnatuneMetaFactory::createTrack(const QStringList & rows) -{ - MagnatuneTrack *track = new MagnatuneTrack( rows ); - - if ( m_streamType == OGG ) { - track->setUidUrl( track->oggUrl() ); - } else if ( m_streamType == LOFI ) { - track->setUidUrl( track->lofiUrl() ); - } - track->setStatisticsProvider( Meta::StatisticsPtr( new UrlStatisticsStore( track ) ) ); - - if ( !m_membershipPrefix.isEmpty() ) { - QString url = track->uidUrl(); - url.replace( "http://he3.", "http://" + m_userName + ":" + m_password + "@" + m_membershipPrefix + "." ); - - if ( m_streamType == MP3 ) { - url.replace( ".mp3", "_nospeech.mp3" ); - } else if ( m_streamType == OGG ) { - url.replace( ".ogg", "_nospeech.ogg" ); - } - - track->setUidUrl( url ); - - if ( m_membershipPrefix == "download" ) - track->setDownloadMembership(); - } - - return Meta::TrackPtr( track ); -} - -int MagnatuneMetaFactory::getAlbumSqlRowCount() -{ - return ServiceMetaFactory::getAlbumSqlRowCount() + 3; -} - -QString MagnatuneMetaFactory::getAlbumSqlRows() -{ - QString sqlRows = ServiceMetaFactory::getAlbumSqlRows(); - - sqlRows += ", "; - sqlRows += tablePrefix() + "_albums.cover_url, "; - sqlRows += tablePrefix() + "_albums.year, "; - sqlRows += tablePrefix() + "_albums.album_code "; - - - return sqlRows; -} - -AlbumPtr MagnatuneMetaFactory::createAlbum(const QStringList & rows) -{ - MagnatuneAlbum * album = new MagnatuneAlbum( rows ); - album->setStore( m_store ); - - if ( m_membershipPrefix == "download" ) - album->setDownloadMembership(); - - album->setSourceName( "Magnatune.com" ); - return AlbumPtr( album ); -} - -int MagnatuneMetaFactory::getArtistSqlRowCount() -{ - return ServiceMetaFactory::getArtistSqlRowCount() + 2; -} - -QString MagnatuneMetaFactory::getArtistSqlRows() -{ - QString sqlRows = ServiceMetaFactory::getArtistSqlRows(); - - sqlRows += ", "; - sqlRows += tablePrefix() + "_artists.photo_url, "; - sqlRows += tablePrefix() + "_artists.artist_page "; - - return sqlRows; -} - -ArtistPtr MagnatuneMetaFactory::createArtist(const QStringList & rows) -{ - MagnatuneArtist * artist = new MagnatuneArtist( rows ); - artist->setSourceName( "Magnatune.com" ); - return ArtistPtr( artist ); - - -} - -GenrePtr MagnatuneMetaFactory::createGenre(const QStringList & rows) -{ - MagnatuneGenre * genre = new MagnatuneGenre( rows ); - genre->setSourceName( "Magnatune.com" ); - return GenrePtr( genre ); -} - - -/////////////////////////////////////////////////////////////////////////////// -// class MagnatuneTrack -/////////////////////////////////////////////////////////////////////////////// - -MagnatuneTrack::MagnatuneTrack( const QString &name ) - : ServiceTrack( name ) - , m_downloadMembership ( false ) -{} - -MagnatuneTrack::MagnatuneTrack(const QStringList & resultRow) - : ServiceTrack( resultRow ) - , m_downloadMembership ( false ) -{ - m_lofiUrl = resultRow[7]; - m_oggUrl = resultRow[8]; -} - -QString MagnatuneTrack::lofiUrl() -{ - return m_lofiUrl; -} - -void MagnatuneTrack::setLofiUrl(const QString & url) -{ - m_lofiUrl = url; -} - -QString Meta::MagnatuneTrack::oggUrl() const -{ - return m_oggUrl; -} - -void Meta::MagnatuneTrack::setOggUrl( const QString& url ) -{ - m_oggUrl = url; -} - -void Meta::MagnatuneTrack::setDownloadMembership() -{ - m_downloadMembership = true; -} - -QString Meta::MagnatuneTrack::sourceName() -{ - return "Magnatune.com"; -} - -QString Meta::MagnatuneTrack::sourceDescription() -{ - return i18n( "The non evil record label that is fair to artists and customers alike" ); -} - -QPixmap Meta::MagnatuneTrack::emblem() -{ - return QPixmap( KStandardDirs::locate( "data", "amarok/images/emblem-magnatune.png" ) ); -} - - -QList< QString > Meta::MagnatuneTrack::moods() -{ - return m_moods; -} - -void Meta::MagnatuneTrack::setMoods(QList< QString > moods) -{ - m_moods = moods; -} - -void Meta::MagnatuneTrack::download() -{ - DEBUG_BLOCK - MagnatuneAlbum * mAlbum = dynamic_cast ( album().data() ); - if ( mAlbum ) - mAlbum->store()->download( this ); -} - -void Meta::MagnatuneTrack::setAlbumPtr( Meta::AlbumPtr album ) -{ - ServiceTrack::setAlbumPtr( album ); - - //get year from magnatue album: - MagnatuneAlbum * ma = dynamic_cast( album.data() ); - if ( ma ) - { - YearPtr year = YearPtr( new ServiceYear( QString::number( ma->launchYear() ) ) ); - setYear( year ); - } -} - - -/////////////////////////////////////////////////////////////////////////////// -// class MagnatuneArtist -/////////////////////////////////////////////////////////////////////////////// - -MagnatuneArtist::MagnatuneArtist( const QString &name ) - : ServiceArtist( name ) -{} - -MagnatuneArtist::MagnatuneArtist(const QStringList & resultRow) - : ServiceArtist( resultRow ) -{ - m_photoUrl = resultRow[3]; - m_magnatuneUrl = resultRow[4]; -} - -void MagnatuneArtist::setPhotoUrl( const QString &photoUrl ) -{ - m_photoUrl = photoUrl; -} - -QString MagnatuneArtist::photoUrl( ) const -{ - return m_photoUrl; -} - -void MagnatuneArtist::setMagnatuneUrl( const QString & magnatuneUrl ) -{ - m_magnatuneUrl = magnatuneUrl; -} - -QString MagnatuneArtist::magnatuneUrl() const -{ - return m_magnatuneUrl; -} - - -/////////////////////////////////////////////////////////////////////////////// -// class MagnatuneAlbum -/////////////////////////////////////////////////////////////////////////////// - -MagnatuneAlbum::MagnatuneAlbum( const QString &name ) - : ServiceAlbumWithCover( name ) - , m_coverUrl() - , m_launchYear( 0 ) - , m_albumCode() - , m_store( 0 ) - , m_downloadMembership( false ) - -{} - -MagnatuneAlbum::MagnatuneAlbum(const QStringList & resultRow) - : ServiceAlbumWithCover( resultRow ) - , m_downloadMembership ( false ) -{ - m_coverUrl = resultRow[4]; - m_launchYear = resultRow[5].toInt(); - m_albumCode = resultRow[6]; - - m_store = 0; -} - -MagnatuneAlbum::~ MagnatuneAlbum() -{} - - -void MagnatuneAlbum::setLaunchYear( int launchYear ) -{ - m_launchYear = launchYear; -} - -int MagnatuneAlbum::launchYear( ) const -{ - return m_launchYear; -} - -void MagnatuneAlbum::setAlbumCode(const QString & albumCode) -{ - m_albumCode = albumCode; -} - -QString MagnatuneAlbum::albumCode() -{ - return m_albumCode; - -} - -void MagnatuneAlbum::setCoverUrl(const QString & coverUrl) -{ - m_coverUrl = coverUrl; -} - -QString MagnatuneAlbum::coverUrl() const -{ - return m_coverUrl; -} - -void Meta::MagnatuneAlbum::setStore(MagnatuneStore * store) -{ - m_store = store; -} - -MagnatuneStore * Meta::MagnatuneAlbum::store() -{ - return m_store; -} - -void Meta::MagnatuneAlbum::setDownloadMembership() -{ - DEBUG_BLOCK - m_downloadMembership = true; -} - -void Meta::MagnatuneAlbum::download() -{ - DEBUG_BLOCK - if ( store() ) - store()->download( this ); -} - -void Meta::MagnatuneAlbum::addToFavorites() -{ - DEBUG_BLOCK - if ( store() ) - store()->addToFavorites( albumCode() ); -} - -/////////////////////////////////////////////////////////////////////////////// -// class MagnatuneGenre -/////////////////////////////////////////////////////////////////////////////// - -MagnatuneGenre::MagnatuneGenre( const QString & name ) - : ServiceGenre( name ) -{} - -MagnatuneGenre::MagnatuneGenre( const QStringList & resultRow ) - : ServiceGenre( resultRow ) -{} - -#include "moc_MagnatuneMeta.cpp" diff --git a/amarok/src/services/magnatune/MagnatuneMeta.h b/amarok/src/services/magnatune/MagnatuneMeta.h deleted file mode 100644 index 49e00d59..00000000 --- a/amarok/src/services/magnatune/MagnatuneMeta.h +++ /dev/null @@ -1,194 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef MAGNATUNEMETA_H -#define MAGNATUNEMETA_H - - -#include "../ServiceMetaBase.h" -#include "../ServiceAlbumCoverDownloader.h" - -#include -#include -#include -#include - -class MagnatuneAlbumCoverDownloader; -class MagnatuneStore; - -namespace Meta -{ - -class MagnatuneTrack : public ServiceTrack -{ - Q_OBJECT -public: - MagnatuneTrack( const QString &name ); - MagnatuneTrack( const QStringList &resultRow ); - - QString lofiUrl(); - void setLofiUrl( const QString &url ); - - QList moods(); - void setMoods( QList moods ); - - void setDownloadMembership(); - - virtual QString sourceName(); - virtual QString sourceDescription(); - virtual QPixmap emblem(); - - virtual bool isBookmarkable() const { return true; } - virtual QString collectionName() const { return "Magnatune.com"; } - virtual bool simpleFiltering() const { return false; } - - void setOggUrl( const QString& url ); - QString oggUrl() const; - - void setAlbumPtr( Meta::AlbumPtr album ); - -public slots: - void download(); - -private: - QString m_lofiUrl; - QString m_oggUrl; - bool m_downloadMembership; - QList m_moods; -}; - - -class MagnatuneArtist : public ServiceArtist -{ -private: - - QString m_photoUrl; - QString m_magnatuneUrl; - -public: - MagnatuneArtist( const QString &name ); - MagnatuneArtist( const QStringList &resultRow ); - - void setPhotoUrl( const QString &photoUrl ); - QString photoUrl() const; - - void setMagnatuneUrl( const QString &url ); - QString magnatuneUrl() const; - - virtual bool isBookmarkable() const { return true; } - virtual QString collectionName() const { return "Magnatune.com"; } - virtual bool simpleFiltering() const { return false; } -}; - -class MagnatuneAlbum : public ServiceAlbumWithCover -{ - Q_OBJECT -private: - QString m_coverUrl; - int m_launchYear; - QString m_albumCode; - MagnatuneStore * m_store; - bool m_downloadMembership; - - -public: - MagnatuneAlbum( const QString &name ); - MagnatuneAlbum( const QStringList &resultRow ); - - ~MagnatuneAlbum(); - - virtual QString downloadPrefix() const { return "magnatune"; } - - void setLaunchYear( int launchYear ); - int launchYear() const; - - virtual void setCoverUrl( const QString &coverUrl ); - virtual QString coverUrl() const; - - virtual KUrl imageLocation( int size = 1 ) { Q_UNUSED( size ); return KUrl( coverUrl() ); } - - void setAlbumCode( const QString &albumCode ); - QString albumCode(); - - void setStore( MagnatuneStore * store ); - MagnatuneStore * store(); - - void setDownloadMembership(); - - virtual bool isBookmarkable() const { return true; } - virtual QString collectionName() const { return "Magnatune.com"; } - virtual bool simpleFiltering() const { return false; } - -public slots: - void download(); - void addToFavorites(); -}; - -class MagnatuneGenre : public ServiceGenre -{ - -public: - MagnatuneGenre( const QString &name ); - MagnatuneGenre( const QStringList &resultRow ); - - virtual bool isBookmarkable() const { return true; } - virtual QString collectionName() const { return "Magnatune.com"; } - virtual bool simpleFiltering() const { return false; } -}; - -} - -class MagnatuneMetaFactory : public ServiceMetaFactory -{ - - public: - enum { OGG = 0, MP3 = 1, LOFI = 2 }; - - MagnatuneMetaFactory( const QString &dbPrefix, MagnatuneStore * store ); - virtual ~MagnatuneMetaFactory() {} - - virtual int getTrackSqlRowCount(); - virtual QString getTrackSqlRows(); - virtual Meta::TrackPtr createTrack( const QStringList &rows ); - - virtual int getAlbumSqlRowCount(); - virtual QString getAlbumSqlRows(); - virtual Meta::AlbumPtr createAlbum( const QStringList &rows ); - - virtual int getArtistSqlRowCount(); - virtual QString getArtistSqlRows(); - virtual Meta::ArtistPtr createArtist( const QStringList &rows ); - - //virtual int getGenreSqlRowCount(); - //virtual QString getGenreSqlRows(); - virtual Meta::GenrePtr createGenre( const QStringList &rows ); - - //stuff for supporting the new membership services at Magnatune.com - - void setMembershipInfo ( const QString &prefix, const QString &userName, const QString &password ); - void setStreamType( int type ); - - private: - QString m_membershipPrefix; - int m_streamType; - - QString m_userName; - QString m_password; - MagnatuneStore * m_store; -}; - - -#endif diff --git a/amarok/src/services/magnatune/MagnatuneNeedUpdateWidget.cpp b/amarok/src/services/magnatune/MagnatuneNeedUpdateWidget.cpp deleted file mode 100644 index 044cf4b9..00000000 --- a/amarok/src/services/magnatune/MagnatuneNeedUpdateWidget.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Edward "hades" Toroshchin * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "MagnatuneNeedUpdateWidget.h" -#include "ui_MagnatuneNeedUpdateWidget.h" - -#include "MagnatuneConfig.h" - -#include - -MagnatuneNeedUpdateWidget::MagnatuneNeedUpdateWidget(QWidget *parent) : - QWidget(parent), ui(new Ui::MagnatuneNeedUpdateWidget) -{ - ui->setupUi(this); - - connect(ui->update, SIGNAL(clicked()), SLOT(startUpdate())); - connect(ui->autoUpdate, SIGNAL(stateChanged(int)), SLOT(saveSettings())); - - ui->autoUpdate->setCheckState( MagnatuneConfig().autoUpdateDatabase()? - Qt::Checked : Qt::Unchecked ); -} - -void -MagnatuneNeedUpdateWidget::enable() -{ - ui->update->setEnabled(true); -} - -void -MagnatuneNeedUpdateWidget::disable() -{ - ui->update->setEnabled(false); -} - -void -MagnatuneNeedUpdateWidget::startUpdate() -{ - disable(); - emit wantUpdate(); -} - -void -MagnatuneNeedUpdateWidget::saveSettings() -{ - DEBUG_BLOCK - - MagnatuneConfig config; - config.setAutoUpdateDatabase( ui->autoUpdate->checkState() == Qt::Checked ); - config.save(); -} diff --git a/amarok/src/services/magnatune/MagnatuneNeedUpdateWidget.h b/amarok/src/services/magnatune/MagnatuneNeedUpdateWidget.h deleted file mode 100644 index 032b0b45..00000000 --- a/amarok/src/services/magnatune/MagnatuneNeedUpdateWidget.h +++ /dev/null @@ -1,45 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Edward "hades" Toroshchin * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef MAGNATUNENEEDUPDATEWIDGET_H -#define MAGNATUNENEEDUPDATEWIDGET_H - -#include - -namespace Ui { class MagnatuneNeedUpdateWidget; } - -class MagnatuneNeedUpdateWidget : public QWidget -{ - Q_OBJECT -public: - explicit MagnatuneNeedUpdateWidget(QWidget *parent = 0); - -protected: - Ui::MagnatuneNeedUpdateWidget* ui; - -signals: - void wantUpdate(); - -public slots: - void enable(); - void disable(); - -protected slots: - void startUpdate(); - void saveSettings(); -}; - -#endif // MAGNATUNENEEDUPDATEWIDGET_H diff --git a/amarok/src/services/magnatune/MagnatuneNeedUpdateWidget.ui b/amarok/src/services/magnatune/MagnatuneNeedUpdateWidget.ui deleted file mode 100644 index a25f6cac..00000000 --- a/amarok/src/services/magnatune/MagnatuneNeedUpdateWidget.ui +++ /dev/null @@ -1,80 +0,0 @@ - - - MagnatuneNeedUpdateWidget - - - - 0 - 0 - 400 - 206 - - - - - 0 - 0 - - - - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - - - Update Magnatune database automatically - - - - - - - Click this button to download Magnatune database now. - - - true - - - - - - - Amarok needs to download Magnatune database in order to enable Magnatune store. - - - true - - - - - - - If you enable the following option, Amarok will check for Magnatune updates and download them automatically. You can always disable this option later in Magnatune service configuration. - - - true - - - - - - - Update - - - - - - - - - - - diff --git a/amarok/src/services/magnatune/MagnatuneRedownloadDialog.cpp b/amarok/src/services/magnatune/MagnatuneRedownloadDialog.cpp deleted file mode 100644 index 6ba4cfb3..00000000 --- a/amarok/src/services/magnatune/MagnatuneRedownloadDialog.cpp +++ /dev/null @@ -1,103 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2006,2007 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "MagnatuneRedownloadDialog.h" - -#include "core/support/Debug.h" - -#include - -MagnatuneRedownloadDialog::MagnatuneRedownloadDialog(QWidget* parent, const char* name, bool modal, Qt::WFlags fl) -: QDialog(parent, fl) -{ - setObjectName( name ); - setModal( modal ); - setupUi(this); - redownloadButton->setEnabled ( false ); - - redownloadListView->header()->setStretchLastSection( true ); - redownloadListView->setRootIsDecorated( false ); - connect( redownloadListView, SIGNAL(itemSelectionChanged()), SLOT(selectionChanged()) ); -} - -MagnatuneRedownloadDialog::~MagnatuneRedownloadDialog() -{ -} - -void MagnatuneRedownloadDialog::setRedownloadItems( const QStringList &items ) -{ - - QStringListIterator it(items); - while ( it.hasNext() ) { - - QString currentItem = it.next(); - debug() << "Adding item to redownload dialog: " << currentItem; - redownloadListView->addTopLevelItem( new QTreeWidgetItem( QStringList(currentItem) ) ); - } - - debug() << "Nothing more to add..."; - -} - -void MagnatuneRedownloadDialog::setRedownloadItems( QList previousPurchases ) -{ - m_infoMap.clear(); - - foreach( const MagnatuneDownloadInfo &prevPurchase, previousPurchases ) - { - const QString albumText = prevPurchase.artistName() + " - " + prevPurchase.albumName(); - QTreeWidgetItem *item = new QTreeWidgetItem( QStringList( albumText ) ); - m_infoMap.insert( item, prevPurchase ); - redownloadListView->addTopLevelItem( item ); - } - - -} - -void MagnatuneRedownloadDialog::redownload( ) -{ - - QTreeWidgetItem * current = redownloadListView->currentItem(); - if ( m_infoMap.keys().contains( current ) ) - { - emit( redownload( m_infoMap.value( current ) ) ); - } - - //emit ( redownload( redownloadListView->currentItem()->text( 0 ) ) ); - - hide(); -} - -void MagnatuneRedownloadDialog::reject( ) -{ - hide(); - emit(cancelled()); -} - -void MagnatuneRedownloadDialog::selectionChanged( ) -{ - if (redownloadListView->currentItem() != 0) { - redownloadButton->setEnabled ( true ); - } else { - redownloadButton->setEnabled ( false ); - } -} - -/*$SPECIALIZATION$*/ - - -#include "moc_MagnatuneRedownloadDialog.cpp" - diff --git a/amarok/src/services/magnatune/MagnatuneRedownloadDialog.h b/amarok/src/services/magnatune/MagnatuneRedownloadDialog.h deleted file mode 100644 index df3b1b42..00000000 --- a/amarok/src/services/magnatune/MagnatuneRedownloadDialog.h +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2006,2007 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef MAGNATUNE_REDOWNLOAD_DIALOG_H -#define MAGNATUNE_REDOWNLOAD_DIALOG_H - -#include "ui_MagnatuneRedownloadDialogBase.h" - -#include "MagnatuneDownloadInfo.h" - -#include - -class MagnatuneRedownloadDialog : public QDialog, public Ui::magnatuneReDownloadDialogBase -{ - Q_OBJECT - -public: - explicit MagnatuneRedownloadDialog( QWidget* parent = 0, const char* name = 0, bool modal = false, Qt::WFlags fl = 0 ); - ~MagnatuneRedownloadDialog(); - /*$PUBLIC_FUNCTIONS$*/ - - void setRedownloadItems( const QStringList &items ); - void setRedownloadItems( QList previousPurchases ); - -signals: - - void redownload( const QString &downloadInfoFileName ); - void redownload( MagnatuneDownloadInfo info ); - void cancelled(); - -public slots: - /*$PUBLIC_SLOTS$*/ - -protected: - QMap m_infoMap; - -protected slots: - /*$PROTECTED_SLOTS$*/ - void redownload(); - void selectionChanged(); - void reject(); - -}; - -#endif - diff --git a/amarok/src/services/magnatune/MagnatuneRedownloadDialogBase.ui b/amarok/src/services/magnatune/MagnatuneRedownloadDialogBase.ui deleted file mode 100644 index f5e081fa..00000000 --- a/amarok/src/services/magnatune/MagnatuneRedownloadDialogBase.ui +++ /dev/null @@ -1,103 +0,0 @@ - - magnatuneReDownloadDialogBase - - - - 0 - 0 - 475 - 432 - - - - Redownload manager - - - - - - These are the albums that you have previously downloaded: - - - false - - - - - - - Re&download - - - - - - - &Cancel - - - - - - - Qt::Horizontal - - - QSizePolicy::Expanding - - - - 170 - 20 - - - - - - - - - Artist - Album - - - - - - - - - - - redownloadButton - clicked() - magnatuneReDownloadDialogBase - redownload() - - - 20 - 20 - - - 20 - 20 - - - - - cancelButton - clicked() - magnatuneReDownloadDialogBase - reject() - - - 20 - 20 - - - 20 - 20 - - - - - diff --git a/amarok/src/services/magnatune/MagnatuneRedownloadHandler.cpp b/amarok/src/services/magnatune/MagnatuneRedownloadHandler.cpp deleted file mode 100644 index 4c8be824..00000000 --- a/amarok/src/services/magnatune/MagnatuneRedownloadHandler.cpp +++ /dev/null @@ -1,204 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2006,2007 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "MagnatuneRedownloadHandler.h" - -#include "MagnatuneConfig.h" -#include "core/support/Amarok.h" -#include "core/support/Debug.h" -#include "core/support/Components.h" -#include "core/interfaces/Logger.h" - -#include -#include - -#include "QDir" - - -MagnatuneRedownloadHandler::MagnatuneRedownloadHandler(QWidget * parent) -{ - m_parent = parent; - m_redownloadDialog = 0; - m_downloadDialog = 0; - m_albumDownloader = 0; -} - - -MagnatuneRedownloadHandler::~MagnatuneRedownloadHandler() -{ -} - -void -MagnatuneRedownloadHandler::showRedownloadDialog( ) -{ - fetchServerSideRedownloadList(); - return; -} - -QStringList -MagnatuneRedownloadHandler::GetPurchaseList( ) -{ - - debug() << "MagnatuneRedownloadHandler::GetPurchaseList( )"; - - QStringList returnList; - QDir purchaseInfoDir( Amarok::saveLocation( "magnatune.com/purchases/" ) ); - - if ( !purchaseInfoDir.exists () ) { - return returnList; - } - - purchaseInfoDir.setFilter( QDir::Files); - purchaseInfoDir.setSorting( QDir::Name ); - - const QFileInfoList list = purchaseInfoDir.entryInfoList(); - QFileInfoList::const_iterator it( list.begin() ); - QFileInfo fi; - - while ( it != list.end() ) { - fi = *it; - returnList.append( fi.fileName() ); - ++it; - } - debug() << "Done parsing previous purchases!"; - return returnList; - -} - -void MagnatuneRedownloadHandler::redownload( MagnatuneDownloadInfo info ) -{ - - if ( m_albumDownloader == 0 ) - { - m_albumDownloader = new MagnatuneAlbumDownloader(); - connect( m_albumDownloader, SIGNAL(downloadComplete(bool)), this, SLOT(albumDownloadComplete(bool)) ); - } - - - if (m_downloadDialog == 0) { - m_downloadDialog = new MagnatuneDownloadDialog(m_parent); - connect( m_downloadDialog, SIGNAL(downloadAlbum(MagnatuneDownloadInfo)), m_albumDownloader, SLOT(downloadAlbum(MagnatuneDownloadInfo)) ); - } - - debug() << "Showing download dialog"; - m_downloadDialog->setDownloadInfo( info ); - m_downloadDialog->show(); -} - -void -MagnatuneRedownloadHandler::selectionDialogCancelled( ) -{ - if (m_redownloadDialog != 0) { - m_redownloadDialog->hide(); - delete m_redownloadDialog; - m_redownloadDialog = 0; - } -} - -void -MagnatuneRedownloadHandler::albumDownloadComplete( bool success ) -{ - Q_UNUSED( success ); - //cleanup time! - - if (m_downloadDialog != 0) { - delete m_downloadDialog; - m_downloadDialog = 0; - } - if (m_albumDownloader != 0) { - delete m_albumDownloader; - m_albumDownloader = 0; - } - -} - -void -MagnatuneRedownloadHandler::fetchServerSideRedownloadList() -{ - - DEBUG_BLOCK - - //do we have an email set, if not, ask the user for one. - MagnatuneConfig config; - - QString email = config.email(); - - if ( email.isEmpty() ) - { - //TODO ask for the email - return; - } - - QString redownloadApiUrl = "http://magnatune.com/buy/redownload_xml?email=" + email; - - m_redownloadApiJob = KIO::storedGet( KUrl( redownloadApiUrl ), KIO::NoReload, KIO::HideProgressInfo ); - Amarok::Components::logger()->newProgressOperation( m_redownloadApiJob, i18n( "Getting list of previous Magnatune.com purchases" ) ); - connect( m_redownloadApiJob, SIGNAL(result(KJob*)), SLOT(redownloadApiResult(KJob*)) ); - -} - -void MagnatuneRedownloadHandler::redownloadApiResult( KJob* job ) -{ - -DEBUG_BLOCK - - if ( !job->error() == 0 ) - { - //TODO: error handling here - debug() << "Job error... " << job->error(); - return ; - } - if ( job != m_redownloadApiJob ) { - debug() << "Wrong job..."; - return ; //not the right job, so let's ignore it - } - - KIO::StoredTransferJob* const storedJob = static_cast( job ); - QString resultXml = QString( storedJob->data() ); - - debug() << endl << endl << "result: " << resultXml; - - - QList previousPurchasesInfoList; - - QDomDocument doc; - doc.setContent( resultXml ); - - QDomNodeList downloads = doc.elementsByTagName( "download" ); - for( int i = 0; i < downloads.size(); i++ ) - { - QDomElement downloadElement = downloads.item( i ).toElement(); - MagnatuneDownloadInfo info; - if ( info.initFromRedownloadXml( downloadElement ) ) - previousPurchasesInfoList << info; - } - - - if (m_redownloadDialog == 0) { - m_redownloadDialog = new MagnatuneRedownloadDialog( m_parent ); - //connect( m_redownloadDialog, SIGNAL(redownload(QString)), this, SLOT(redownload(QString)) ); - connect( m_redownloadDialog, SIGNAL(redownload(MagnatuneDownloadInfo)), this, SLOT(redownload(MagnatuneDownloadInfo)) ); - connect( m_redownloadDialog, SIGNAL(cancelled()), this, SLOT(selectionDialogCancelled()) ); - } - - m_redownloadDialog->setRedownloadItems( previousPurchasesInfoList ); - - m_redownloadDialog->show(); - -} - - -#include "moc_MagnatuneRedownloadHandler.cpp" diff --git a/amarok/src/services/magnatune/MagnatuneRedownloadHandler.h b/amarok/src/services/magnatune/MagnatuneRedownloadHandler.h deleted file mode 100644 index 79a5cdb3..00000000 --- a/amarok/src/services/magnatune/MagnatuneRedownloadHandler.h +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2006,2007 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef MAGNATUNE_REDOWNLOAD_HANDLER_H -#define MAGNATUNE_REDOWNLOAD_HANDLER_H - -#include "MagnatuneAlbumDownloader.h" -#include "MagnatuneDownloadDialog.h" -#include "MagnatuneDownloadInfo.h" -#include "MagnatuneRedownloadDialog.h" - -#include - -/** -This class handles the redownloading of previously downloaded albums - - @author Nikolaj Hald Nielsen -*/ - -class MagnatuneRedownloadHandler : public QObject { -Q_OBJECT -public: - MagnatuneRedownloadHandler(QWidget * parent); - - ~MagnatuneRedownloadHandler(); - - /** - * Calls forth the redownload dialog. - */ - void showRedownloadDialog(); - -signals: - - void reDownloadCompleted( bool success ); - -protected: - - QStringList GetPurchaseList( ); - - /** - * Attempt to get a list of previous purchases for an email. - * If set, use the email from the magnatune settings, otherwise, QueryMaker - * the user (and then save it to settings) - */ - void fetchServerSideRedownloadList(); - - QWidget * m_parent; - MagnatuneRedownloadDialog * m_redownloadDialog; - MagnatuneDownloadDialog * m_downloadDialog; - MagnatuneAlbumDownloader * m_albumDownloader; - - KIO::TransferJob * m_redownloadApiJob; - -protected slots: - - void redownload( MagnatuneDownloadInfo info ); - void selectionDialogCancelled(); - void albumDownloadComplete( bool success ); - void redownloadApiResult( KJob* job ); - - - -}; - -#endif diff --git a/amarok/src/services/magnatune/MagnatuneSettingsModule.cpp b/amarok/src/services/magnatune/MagnatuneSettingsModule.cpp deleted file mode 100644 index 4a94b6ba..00000000 --- a/amarok/src/services/magnatune/MagnatuneSettingsModule.cpp +++ /dev/null @@ -1,115 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) version 3 or * - * any later version accepted by the membership of KDE e.V. (or its successor approved * - * by the membership of KDE e.V.), which shall act as a proxy defined in Section 14 of * - * version 3 of the license. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "MagnatuneSettingsModule.h" - -#include "MagnatuneMeta.h" - -#include "ui_MagnatuneConfigWidget.h" - -#include - - - -K_PLUGIN_FACTORY( MagnatuneSettingsFactory, registerPlugin(); ) -K_EXPORT_PLUGIN( MagnatuneSettingsFactory( "kcm_amarok_magnatunestore" ) ) - -MagnatuneSettingsModule::MagnatuneSettingsModule( QWidget *parent, const QVariantList &args ) - : KCModule( MagnatuneSettingsFactory::componentData(), parent, args ) -{ - m_configDialog = new Ui::MagnatuneConfigWidget; - m_configDialog->setupUi( this ); - - m_configDialog->passwordEdit->setEchoMode( QLineEdit::Password ); - connect ( m_configDialog->usernameEdit, SIGNAL(textChanged(QString)), this, SLOT(settingsChanged()) ); - connect ( m_configDialog->passwordEdit, SIGNAL(textChanged(QString)), this, SLOT(settingsChanged()) ); - connect ( m_configDialog->emailEdit, SIGNAL(textChanged(QString)), this, SLOT(settingsChanged()) ); - connect ( m_configDialog->typeComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(settingsChanged()) ); - connect ( m_configDialog->isMemberCheckbox, SIGNAL(stateChanged(int)), this, SLOT(settingsChanged()) ); - connect ( m_configDialog->streamTypeComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(settingsChanged()) ); - connect ( m_configDialog->autoUpdateDatabase, SIGNAL(stateChanged(int)), this, SLOT(settingsChanged()) ); - - load(); - -} - - -MagnatuneSettingsModule::~MagnatuneSettingsModule() -{ - delete m_configDialog; -} - -void MagnatuneSettingsModule::save() -{ - m_config.setIsMember( m_configDialog->isMemberCheckbox->checkState() == Qt::Checked ); - m_config.setAutoUpdateDatabase( m_configDialog->autoUpdateDatabase->checkState() == Qt::Checked ); - - - int typeIndex = m_configDialog->typeComboBox->currentIndex(); - if( typeIndex == 0 ) - m_config.setMembershipType( MagnatuneConfig::STREAM ); - else - m_config.setMembershipType( MagnatuneConfig::DOWNLOAD ); - - m_config.setUsername( m_configDialog->usernameEdit->text() ); - m_config.setPassword( m_configDialog->passwordEdit->text() ); - m_config.setEmail( m_configDialog->emailEdit->text() ); - - - QString streamTypeString = m_configDialog->streamTypeComboBox->currentText(); - m_config.setStreamType( m_configDialog->streamTypeComboBox->currentIndex() ); - - m_config.save(); - KCModule::save(); - -} - -void MagnatuneSettingsModule::load() -{ - if ( m_config.isMember() ) - m_configDialog->isMemberCheckbox->setCheckState( Qt::Checked ); - else - m_configDialog->isMemberCheckbox->setCheckState( Qt::Unchecked ); - - m_configDialog->autoUpdateDatabase->setCheckState( m_config.autoUpdateDatabase()? - Qt::Checked : Qt::Unchecked ); - - int index = 0; - if ( m_config.membershipType() == MagnatuneConfig::STREAM ) index = 0; - else if ( m_config.membershipType() == MagnatuneConfig::DOWNLOAD ) index = 1; - - m_configDialog->typeComboBox->setCurrentIndex( index ); - m_configDialog->usernameEdit->setText( m_config.username() ); - m_configDialog->passwordEdit->setText( m_config.password() ); - m_configDialog->emailEdit->setText( m_config.email() ); - - m_configDialog->streamTypeComboBox->setCurrentIndex( m_config.streamType() ); - - KCModule::load(); -} - -void MagnatuneSettingsModule::defaults() -{ -} - -void MagnatuneSettingsModule::settingsChanged() -{ - emit changed( true ); -} - - diff --git a/amarok/src/services/magnatune/MagnatuneSettingsModule.h b/amarok/src/services/magnatune/MagnatuneSettingsModule.h deleted file mode 100644 index 4728a34e..00000000 --- a/amarok/src/services/magnatune/MagnatuneSettingsModule.h +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef MAGNATUNESETTINGSMODULE_H -#define MAGNATUNESETTINGSMODULE_H - -#include "MagnatuneConfig.h" - -#include - -namespace Ui { class MagnatuneConfigWidget; } - -/** -A KCM module to configure the Magnatune service - - @author -*/ -class MagnatuneSettingsModule : public KCModule -{ - Q_OBJECT -public: - explicit MagnatuneSettingsModule( QWidget *parent = 0, const QVariantList &args = QVariantList() ); - - ~MagnatuneSettingsModule(); - - virtual void save(); - virtual void load(); - virtual void defaults(); - -private slots: - - void settingsChanged(); - -private: - - MagnatuneConfig m_config; - Ui::MagnatuneConfigWidget * m_configDialog; - -}; - -#endif diff --git a/amarok/src/services/magnatune/MagnatuneSignupDialogBase.ui b/amarok/src/services/magnatune/MagnatuneSignupDialogBase.ui deleted file mode 100644 index ca8b1630..00000000 --- a/amarok/src/services/magnatune/MagnatuneSignupDialogBase.ui +++ /dev/null @@ -1,70 +0,0 @@ - - - SignupDialog - - - - 0 - 0 - 378 - 317 - - - - Magnatune.com member signup - - - - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Liberation Sans'; font-size:9pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">By becoming a Magnatune.com member, you get unlimited download access and can download any album from within Amarok with a single mouse click. By joining, you can also listen to all streaming tracks from Magnatune.com ad-free.</p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">The Amarok team gets 10% of your initial membership payment, so by joining, you are also supporting the development of Amarok.</p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">As always, the artists get 50% of your membership payment(s) distributed based on which artist you download and stream.</p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">To read more about Magnatune.com memberships, or to sign up, click here: <a href="http://magnatune.com/downloads?referal_id=amarok"><span style=" text-decoration: underline; color:#0057ae;">Membership Info</span></a> </p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">After joining, go to the Magnatune config in "Settings->Configure Amarok->Plugins" and enter your membership information. </p></body></html> - - - true - - - true - - - - - - - Close - - - - - - - - - closeButton - clicked() - SignupDialog - reject() - - - 170 - 271 - - - 170 - 143 - - - - - diff --git a/amarok/src/services/magnatune/MagnatuneSqlCollection.cpp b/amarok/src/services/magnatune/MagnatuneSqlCollection.cpp deleted file mode 100644 index 2f50e90a..00000000 --- a/amarok/src/services/magnatune/MagnatuneSqlCollection.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "MagnatuneSqlCollection.h" - -#include "core/support/Debug.h" -#include "MagnatuneCollectionLocation.h" -#include "MagnatuneMeta.h" - -using namespace Collections; - -MagnatuneSqlCollection::MagnatuneSqlCollection(const QString & id, const QString & prettyName, ServiceMetaFactory * metaFactory, ServiceSqlRegistry * registry) - : ServiceSqlCollection( id, prettyName, metaFactory, registry ) -{ -} - -Meta::TrackPtr MagnatuneSqlCollection::trackForUrl(const KUrl & url) -{ - //DEBUG_BLOCK - - QString pristineUrl = url.url(); - - if ( pristineUrl.startsWith( "http://magnatune.com/playlist_redirect.php?url=" ) ) { - - //if we are not a member of the right type, we need to preserve this or we will not be able to play the track. Actually... use the original url in any case so plays are attributed to the person whose playlist it is... - QString orgUrl = pristineUrl; - - int endIndex = pristineUrl.indexOf( "&key=" ); - - pristineUrl = pristineUrl.mid( 47, endIndex - 47 ); - - //debug() << "got redirected url: " << pristineUrl; - - - pristineUrl.remove( "_nospeech" ); - pristineUrl.replace( ".ogg", ".mp3" ); - pristineUrl.replace( "-lofi.mp3", ".mp3" ); - - pristineUrl.replace( QRegExp( "http://download" ), "http://he3" ); - pristineUrl.replace( QRegExp( "http://stream" ), "http://he3" ); - - //debug() << "after a quick makeover: " << pristineUrl; - - Meta::TrackPtr trackPtr = ServiceSqlCollection::trackForUrl( KUrl( pristineUrl ) ); - - if ( trackPtr ) { - Meta::ServiceTrack * mTrack = dynamic_cast< Meta::ServiceTrack * >( trackPtr.data() ); - if ( mTrack ) { - - mTrack->setUidUrl( orgUrl ); - } - } - - return trackPtr; - - } else { - - pristineUrl.remove( "_nospeech" ); - pristineUrl.replace( ".ogg", ".mp3" ); - pristineUrl.replace( "-lofi.mp3", ".mp3" ); - - pristineUrl.replace( QRegExp( ".*:.*@download" ), "http://he3" ); - pristineUrl.replace( QRegExp( ".*:.*@stream" ), "http://he3" ); - - return ServiceSqlCollection::trackForUrl( KUrl( pristineUrl ) ); - - } - -} - -CollectionLocation * MagnatuneSqlCollection::location() -{ - return new MagnatuneCollectionLocation( this ); -} - - - - diff --git a/amarok/src/services/magnatune/MagnatuneSqlCollection.h b/amarok/src/services/magnatune/MagnatuneSqlCollection.h deleted file mode 100644 index ccfc898c..00000000 --- a/amarok/src/services/magnatune/MagnatuneSqlCollection.h +++ /dev/null @@ -1,43 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef MAGNATUNESQLCOLLECTION_H -#define MAGNATUNESQLCOLLECTION_H - -#include "../ServiceSqlCollection.h" - -namespace Collections { - -/** -A simple ServiceSqlCollection subclass for providing a magnatune membership specific implementaion of trackForUrl - - @author Nikolaj Hald Nielsen -*/ -class MagnatuneSqlCollection : public ServiceSqlCollection -{ -public: - - MagnatuneSqlCollection( const QString &id, const QString &prettyName, ServiceMetaFactory * metaFactory, ServiceSqlRegistry * registry ); - - virtual Meta::TrackPtr trackForUrl( const KUrl &url ); - - virtual CollectionLocation* location(); - -}; - -} //namespace Collections - -#endif diff --git a/amarok/src/services/magnatune/MagnatuneStore.cpp b/amarok/src/services/magnatune/MagnatuneStore.cpp deleted file mode 100644 index 94116181..00000000 --- a/amarok/src/services/magnatune/MagnatuneStore.cpp +++ /dev/null @@ -1,755 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2006,2007 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "MagnatuneStore.h" - -#include "core/support/Amarok.h" -#include "core/support/Components.h" -#include "core/interfaces/Logger.h" -#include "amarokurls/AmarokUrlHandler.h" -#include "browsers/CollectionTreeItem.h" -#include "browsers/SingleCollectionTreeItemModel.h" -#include "EngineController.h" -#include "MagnatuneConfig.h" -#include "MagnatuneDatabaseWorker.h" -#include "MagnatuneInfoParser.h" -#include "MagnatuneNeedUpdateWidget.h" -#include "browsers/InfoProxy.h" -#include "MagnatuneUrlRunner.h" - -#include "ui_MagnatuneSignupDialogBase.h" - -#include "../ServiceSqlRegistry.h" -#include "core-impl/collections/support/CollectionManager.h" -#include "core/support/Debug.h" -#include "playlist/PlaylistModelStack.h" -#include "widgets/SearchWidget.h" - -#include -#include //locate() -#include -#include -#include - -#include -#include -#include -#include - -#include - -AMAROK_EXPORT_SERVICE_PLUGIN( magnatunestore, MagnatuneServiceFactory ) - -//////////////////////////////////////////////////////////////////////////////////////////////////////////// -// class MagnatuneServiceFactory -//////////////////////////////////////////////////////////////////////////////////////////////////////////// - -MagnatuneServiceFactory::MagnatuneServiceFactory( QObject *parent, const QVariantList &args ) - : ServiceFactory( parent, args ) -{ - KPluginInfo pluginInfo( "amarok_service_magnatunestore.desktop", "services" ); - pluginInfo.setConfig( config() ); - m_info = pluginInfo; -} - -void MagnatuneServiceFactory::init() -{ - DEBUG_BLOCK - MagnatuneStore* service = new MagnatuneStore( this, "Magnatune.com" ); - m_initialized = true; - emit newService( service ); -} - -QString MagnatuneServiceFactory::name() -{ - return "Magnatune.com"; -} - -KConfigGroup MagnatuneServiceFactory::config() -{ - return Amarok::config( "Service_Magnatune" ); -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////// -// class MagnatuneStore -//////////////////////////////////////////////////////////////////////////////////////////////////////////// - -MagnatuneStore::MagnatuneStore( MagnatuneServiceFactory* parent, const char *name ) - : ServiceBase( name, parent ) - , m_downloadHandler( 0 ) - , m_redownloadHandler( 0 ) - , m_needUpdateWidget( 0 ) - , m_downloadInProgress( 0 ) - , m_currentAlbum( 0 ) - , m_streamType( MagnatuneMetaFactory::OGG ) - , m_magnatuneTimestamp( 0 ) - , m_registry( 0 ) - , m_signupInfoWidget( 0 ) -{ - setObjectName(name); - DEBUG_BLOCK - //initTopPanel( ); - - setShortDescription( i18n( "\"Fair trade\" online music store" ) ); - setIcon( KIcon( "view-services-magnatune-amarok" ) ); - - // xgettext: no-c-format - setLongDescription( i18n( "Magnatune.com is a different kind of record company with the motto \"We are not evil!\" 50% of every purchase goes directly to the artist and if you purchase an album through Amarok, the Amarok project receives a 10% commission. Magnatune.com also offers \"all you can eat\" memberships that lets you download as much of their music as you like." ) ); - setImagePath( KStandardDirs::locate( "data", "amarok/images/hover_info_magnatune.png" ) ); - - - //initBottomPanel(); -// m_currentlySelectedItem = 0; - - m_polished = false; - //polish( ); //FIXME not happening when shown for some reason - - - //do this stuff now to make us function properly as a track provider on startup. The expensive stuff will - //not happen untill the model is added to the view anyway. - MagnatuneMetaFactory * metaFactory = new MagnatuneMetaFactory( "magnatune", this ); - - MagnatuneConfig config; - if ( config.isMember() ) { - setMembership( config.membershipType(), config.username(), config.password() ); - metaFactory->setMembershipInfo( config.membershipPrefix(), m_username, m_password ); - } - - setStreamType( config.streamType() ); - - metaFactory->setStreamType( m_streamType ); - m_registry = new ServiceSqlRegistry( metaFactory ); - m_collection = new Collections::MagnatuneSqlCollection( "magnatune", "Magnatune.com", metaFactory, m_registry ); - CollectionManager::instance()->addTrackProvider( m_collection ); - setServiceReady( true ); -} - -MagnatuneStore::~MagnatuneStore() -{ - CollectionManager::instance()->removeTrackProvider( m_collection ); - delete m_registry; - delete m_collection; -} - - -void MagnatuneStore::download( ) -{ - DEBUG_BLOCK - if ( m_downloadInProgress ) - return; - - if ( !m_polished ) - polish(); - - debug() << "here"; - - //check if we need to start a download or show the signup dialog - if( !m_isMember || m_membershipType != MagnatuneConfig::DOWNLOAD ) - { - showSignupDialog(); - return; - } - - m_downloadInProgress = true; - m_downloadAlbumButton->setEnabled( false ); - - if ( !m_downloadHandler ) - { - m_downloadHandler = new MagnatuneDownloadHandler(); - m_downloadHandler->setParent( this ); - connect( m_downloadHandler, SIGNAL(downloadCompleted(bool)), this, SLOT(downloadCompleted(bool)) ); - } - - if ( m_currentAlbum != 0 ) - m_downloadHandler->downloadAlbum( m_currentAlbum ); -} - - -void MagnatuneStore::download( Meta::MagnatuneTrack * track ) -{ - Meta::MagnatuneAlbum * album = dynamic_cast( track->album().data() ); - if ( album ) - download( album ); -} - -void MagnatuneStore::download( Meta::MagnatuneAlbum * album ) -{ - - DEBUG_BLOCK - if ( m_downloadInProgress ) - return; - - if ( !m_polished ) - polish(); - - m_downloadInProgress = true; - m_downloadAlbumButton->setEnabled( false ); - - if ( !m_downloadHandler ) - { - m_downloadHandler = new MagnatuneDownloadHandler(); - m_downloadHandler->setParent( this ); - connect( m_downloadHandler, SIGNAL(downloadCompleted(bool)), this, SLOT(downloadCompleted(bool)) ); - } - - m_downloadHandler->downloadAlbum( album ); -} - - -void MagnatuneStore::initTopPanel( ) -{ - - QMenu *filterMenu = new QMenu( 0 ); - - QAction *action = filterMenu->addAction( i18n("Artist") ); - connect( action, SIGNAL(triggered(bool)), SLOT(sortByArtist()) ); - - action = filterMenu->addAction( i18n( "Artist / Album" ) ); - connect( action, SIGNAL(triggered(bool)), SLOT(sortByArtistAlbum()) ); - - action = filterMenu->addAction( i18n( "Album" ) ) ; - connect( action, SIGNAL(triggered(bool)), SLOT(sortByAlbum()) ); - - action = filterMenu->addAction( i18n( "Genre / Artist" ) ); - connect( action, SIGNAL(triggered(bool)), SLOT(sortByGenreArtist()) ); - - action = filterMenu->addAction( i18n( "Genre / Artist / Album" ) ); - connect( action, SIGNAL(triggered(bool)), SLOT(sortByGenreArtistAlbum()) ); - - KAction *filterMenuAction = new KAction( KIcon( "preferences-other" ), i18n( "Sort Options" ), this ); - filterMenuAction->setMenu( filterMenu ); - - m_searchWidget->toolBar()->addSeparator(); - m_searchWidget->toolBar()->addAction( filterMenuAction ); - - QToolButton *tbutton = qobject_cast( m_searchWidget->toolBar()->widgetForAction( filterMenuAction ) ); - if( tbutton ) - tbutton->setPopupMode( QToolButton::InstantPopup ); - - QMenu * actionsMenu = new QMenu( 0 ); - - action = actionsMenu->addAction( i18n( "Re-download" ) ); - connect( action, SIGNAL(triggered(bool)), SLOT(processRedownload()) ); - - m_updateAction = actionsMenu->addAction( i18n( "Update Database" ) ); - connect( m_updateAction, SIGNAL(triggered(bool)), SLOT(updateButtonClicked()) ); - - KAction *actionsMenuAction = new KAction( KIcon( "list-add" ), i18n( "Tools" ), this ); - actionsMenuAction->setMenu( actionsMenu ); - - m_searchWidget->toolBar()->addAction( actionsMenuAction ); - - tbutton = qobject_cast( m_searchWidget->toolBar()->widgetForAction( actionsMenuAction ) ); - if( tbutton ) - tbutton->setPopupMode( QToolButton::InstantPopup ); - -} - -void MagnatuneStore::initBottomPanel() -{ - //m_bottomPanel->setMaximumHeight( 24 ); - - m_downloadAlbumButton = new QPushButton; - m_downloadAlbumButton->setParent( m_bottomPanel ); - - MagnatuneConfig config; - if ( config.isMember() && config.membershipType() == MagnatuneConfig::DOWNLOAD ) - { - m_downloadAlbumButton->setText( i18n( "Download Album" ) ); - m_downloadAlbumButton->setEnabled( false ); - } - else if ( config.isMember() ) - m_downloadAlbumButton->hide(); - else - { - m_downloadAlbumButton->setText( i18n( "Signup" ) ); - m_downloadAlbumButton->setEnabled( true ); - } - - m_downloadAlbumButton->setObjectName( "downloadButton" ); - m_downloadAlbumButton->setIcon( KIcon( "download-amarok" ) ); - - connect( m_downloadAlbumButton, SIGNAL(clicked()) , this, SLOT(download()) ); - - if ( !config.lastUpdateTimestamp() ) - { - m_needUpdateWidget = new MagnatuneNeedUpdateWidget(m_bottomPanel); - - connect( m_needUpdateWidget, SIGNAL(wantUpdate()), SLOT(updateButtonClicked()) ); - - m_downloadAlbumButton->setParent(0); - } -} - - -void MagnatuneStore::updateButtonClicked() -{ - DEBUG_BLOCK - m_updateAction->setEnabled( false ); - if ( m_needUpdateWidget ) - m_needUpdateWidget->disable(); - - updateMagnatuneList(); -} - - -bool MagnatuneStore::updateMagnatuneList() -{ - DEBUG_BLOCK - //download new list from magnatune - - debug() << "MagnatuneStore: start downloading xml file"; - - - KTemporaryFile tempFile; - tempFile.setSuffix( ".bz2" ); - tempFile.setAutoRemove( false ); // file will be removed in MagnatuneXmlParser - if( !tempFile.open() ) - { - return false; //error - } - - m_tempFileName = tempFile.fileName(); - - m_listDownloadJob = KIO::file_copy( KUrl( "http://magnatune.com/info/album_info_xml.bz2" ), KUrl( m_tempFileName ), 0700 , KIO::HideProgressInfo | KIO::Overwrite ); - Amarok::Components::logger()->newProgressOperation( m_listDownloadJob, i18n( "Downloading Magnatune.com database..." ), this, SLOT(listDownloadCancelled()) ); - - connect( m_listDownloadJob, SIGNAL(result(KJob*)), - this, SLOT(listDownloadComplete(KJob*)) ); - - - return true; -} - - -void MagnatuneStore::listDownloadComplete( KJob * downLoadJob ) -{ - DEBUG_BLOCK - debug() << "MagnatuneStore: xml file download complete"; - - if ( downLoadJob != m_listDownloadJob ) { - debug() << "wrong job, ignoring...."; - return ; //not the right job, so let's ignore it - } - - m_updateAction->setEnabled( true ); - - if ( downLoadJob->error() != 0 ) - { - debug() << "Got an error, bailing out: " << downLoadJob->errorString(); - //TODO: error handling here - return ; - } - - - Amarok::Components::logger()->shortMessage( i18n( "Updating the local Magnatune database." ) ); - MagnatuneXmlParser * parser = new MagnatuneXmlParser( m_tempFileName ); - parser->setDbHandler( new MagnatuneDatabaseHandler() ); - connect( parser, SIGNAL(doneParsing()), SLOT(doneParsing()) ); - - ThreadWeaver::Weaver::instance()->enqueue( parser ); -} - - -void MagnatuneStore::listDownloadCancelled( ) -{ - DEBUG_BLOCK - - m_listDownloadJob->kill(); - m_listDownloadJob = 0; - debug() << "Aborted xml download"; - - m_updateAction->setEnabled( true ); - if ( m_needUpdateWidget ) - m_needUpdateWidget->enable(); -} - - - -void MagnatuneStore::doneParsing() -{ - debug() << "MagnatuneStore: done parsing"; - m_collection->emitUpdated(); - - //update the last update timestamp - - MagnatuneConfig config; - if ( m_magnatuneTimestamp == 0 ) - config.setLastUpdateTimestamp( QDateTime::currentDateTime().toTime_t() ); - else - config.setLastUpdateTimestamp( m_magnatuneTimestamp ); - - config.save(); - - if ( m_needUpdateWidget ) - { - m_needUpdateWidget->setParent(0); - m_needUpdateWidget->deleteLater(); - m_needUpdateWidget = 0; - - m_downloadAlbumButton->setParent(m_bottomPanel); - } -} - - -void MagnatuneStore::processRedownload( ) -{ - debug() << "Process redownload"; - - if ( m_redownloadHandler == 0 ) - { - m_redownloadHandler = new MagnatuneRedownloadHandler( this ); - } - m_redownloadHandler->showRedownloadDialog(); -} - - -void MagnatuneStore::downloadCompleted( bool ) -{ - delete m_downloadHandler; - m_downloadHandler = 0; - - m_downloadAlbumButton->setEnabled( true ); - m_downloadInProgress = false; - - debug() << "Purchase operation complete"; - - //TODO: display some kind of success dialog here? -} - - -void MagnatuneStore::itemSelected( CollectionTreeItem * selectedItem ) -{ - DEBUG_BLOCK - - //only care if the user has a download membership - if( !m_isMember || m_membershipType != MagnatuneConfig::DOWNLOAD ) - return; - - //we only enable the purchase button if there is only one item selected and it happens to - //be an album or a track - Meta::DataPtr dataPtr = selectedItem->data(); - - if ( typeid( * dataPtr.data() ) == typeid( Meta::MagnatuneTrack ) ) { - - debug() << "is right type (track)"; - Meta::MagnatuneTrack * track = static_cast ( dataPtr.data() ); - m_currentAlbum = static_cast ( track->album().data() ); - m_downloadAlbumButton->setEnabled( true ); - - } else if ( typeid( * dataPtr.data() ) == typeid( Meta::MagnatuneAlbum ) ) { - - m_currentAlbum = static_cast ( dataPtr.data() ); - debug() << "is right type (album) named " << m_currentAlbum->name(); - - m_downloadAlbumButton->setEnabled( true ); - } else { - - debug() << "is wrong type"; - m_downloadAlbumButton->setEnabled( false ); - - } -} - - -void MagnatuneStore::addMoodyTracksToPlaylist( const QString &mood, int count ) -{ - MagnatuneDatabaseWorker * databaseWorker = new MagnatuneDatabaseWorker(); - databaseWorker->fetchTrackswithMood( mood, count, m_registry ); - connect( databaseWorker, SIGNAL(gotMoodyTracks(Meta::TrackList)), this, SLOT(moodyTracksReady(Meta::TrackList)) ); - - ThreadWeaver::Weaver::instance()->enqueue( databaseWorker ); -} - - -void MagnatuneStore::polish() -{ - DEBUG_BLOCK; - - if (!m_polished) { - m_polished = true; - - initTopPanel( ); - initBottomPanel(); - - QList levels; - levels << CategoryId::Genre << CategoryId::Artist << CategoryId::Album; - - m_magnatuneInfoParser = new MagnatuneInfoParser(); - - setInfoParser( m_magnatuneInfoParser ); - setModel( new SingleCollectionTreeItemModel( m_collection, levels ) ); - - connect( m_contentView, SIGNAL(itemSelected(CollectionTreeItem*)), this, SLOT(itemSelected(CollectionTreeItem*)) ); - - //add a custom url runner - - MagnatuneUrlRunner * runner = new MagnatuneUrlRunner(); - - connect( runner, SIGNAL(showFavorites()), this, SLOT(showFavoritesPage()) ); - connect( runner, SIGNAL(showHome()), this, SLOT(showHomePage()) ); - connect( runner, SIGNAL(showRecommendations()), this, SLOT(showRecommendationsPage()) ); - connect( runner, SIGNAL(buyOrDownload(QString)), this, SLOT(download(QString)) ); - connect( runner, SIGNAL(removeFromFavorites(QString)), this, SLOT(removeFromFavorites(QString)) ); - - The::amarokUrlHandler()->registerRunner( runner, runner->command() ); - } - - const KUrl url( KStandardDirs::locate( "data", "amarok/data/" ) ); - QString imagePath = url.url(); - - MagnatuneInfoParser * parser = dynamic_cast ( infoParser() ); - if ( parser ) - parser->getFrontPage(); - - //get a mood map we can show to the cloud view - - MagnatuneDatabaseWorker * databaseWorker = new MagnatuneDatabaseWorker(); - databaseWorker->fetchMoodMap(); - connect( databaseWorker, SIGNAL(gotMoodMap(QMap)), this, SLOT(moodMapReady(QMap)) ); - ThreadWeaver::Weaver::instance()->enqueue( databaseWorker ); - - if ( MagnatuneConfig().autoUpdateDatabase() ) - checkForUpdates(); -} - - - -void MagnatuneStore::setMembership( int type, const QString & username, const QString & password) -{ - m_isMember = true; - m_membershipType = type; - m_username = username; - m_password = password; -} - - -void MagnatuneStore::moodMapReady(QMap< QString, int > map) -{ - QVariantMap variantMap; - QList strings; - QList weights; - QVariantMap dbusActions; - - foreach( const QString &key, map.keys() ) { - - strings << key; - weights << map.value( key ); - - QString escapedKey = key; - escapedKey.replace( ' ', "%20" ); - QVariantMap action; - action["component"] = "/ServicePluginManager"; - action["function"] = "sendMessage"; - action["arg1"] = QString( "Magnatune.com"); - action["arg2"] = QString( "addMoodyTracks %1 10").arg( escapedKey ); - - dbusActions[key] = action; - - } - - variantMap["cloud_name"] = QVariant( "Magnatune Moods" ); - variantMap["cloud_strings"] = QVariant( strings ); - variantMap["cloud_weights"] = QVariant( weights ); - variantMap["cloud_actions"] = QVariant( dbusActions ); - - The::infoProxy()->setCloud( variantMap ); -} - - -void MagnatuneStore::setStreamType( int type ) -{ - m_streamType = type; -} - -void MagnatuneStore::checkForUpdates() -{ - m_updateTimestampDownloadJob = KIO::storedGet( KUrl( "http://magnatune.com/info/last_update_timestamp" ), KIO::Reload, KIO::HideProgressInfo ); - connect( m_updateTimestampDownloadJob, SIGNAL(result(KJob*)), SLOT(timestampDownloadComplete(KJob*)) ); -} - - -void MagnatuneStore::timestampDownloadComplete( KJob * job ) -{ - DEBUG_BLOCK - - if ( job->error() != 0 ) - { - //TODO: error handling here - return ; - } - if ( job != m_updateTimestampDownloadJob ) - return ; //not the right job, so let's ignore it - - - QString timestampString = ( ( KIO::StoredTransferJob* ) job )->data(); - debug() << "Magnatune timestamp: " << timestampString; - - bool ok; - qulonglong magnatuneTimestamp = timestampString.toULongLong( &ok ); - - MagnatuneConfig config; - qulonglong localTimestamp = config.lastUpdateTimestamp(); - - debug() << "Last update timestamp: " << QString::number( localTimestamp ); - - if ( ok && magnatuneTimestamp > localTimestamp ) { - m_magnatuneTimestamp = magnatuneTimestamp; - updateButtonClicked(); - } -} - - -void MagnatuneStore::moodyTracksReady( Meta::TrackList tracks ) -{ - DEBUG_BLOCK - The::playlistController()->insertOptioned( tracks, Playlist::Replace ); -} - - -QString MagnatuneStore::messages() -{ - QString text = i18n( "The Magnatune.com service accepts the following messages: \n\n\taddMoodyTracks mood count: Adds a number of random tracks with the specified mood to the playlist. The mood argument must have spaces escaped with %%20" ); - - return text; -} - - -QString MagnatuneStore::sendMessage( const QString & message ) -{ - QStringList args = message.split( ' ', QString::SkipEmptyParts ); - - if ( args.size() < 1 ) { - return i18n( "ERROR: No arguments supplied" ); - } - - if ( args[0] == "addMoodyTracks" ) { - if ( args.size() != 3 ) { - return i18n( "ERROR: Wrong number of arguments for addMoodyTracks" ); - } - - QString mood = args[1]; - mood = mood.replace( "%20", " " ); - - bool ok; - int count = args[2].toInt( &ok ); - - if ( !ok ) - return i18n( "ERROR: Parse error for argument 2 ( count )" ); - - addMoodyTracksToPlaylist( mood, count ); - - return i18n( "ok" ); - } - - return i18n( "ERROR: Unknown argument." ); -} - -void MagnatuneStore::showFavoritesPage() -{ - DEBUG_BLOCK - m_magnatuneInfoParser->getFavoritesPage(); -} - -void MagnatuneStore::showHomePage() -{ - DEBUG_BLOCK - m_magnatuneInfoParser->getFrontPage(); -} - -void MagnatuneStore::showRecommendationsPage() -{ - DEBUG_BLOCK - m_magnatuneInfoParser->getRecommendationsPage(); -} - -void MagnatuneStore::download( const QString &sku ) -{ - DEBUG_BLOCK - debug() << "sku: " << sku; - MagnatuneDatabaseWorker * databaseWorker = new MagnatuneDatabaseWorker(); - databaseWorker->fetchAlbumBySku( sku, m_registry ); - connect( databaseWorker, SIGNAL(gotAlbumBySku(Meta::MagnatuneAlbum*)), this, SLOT(download(Meta::MagnatuneAlbum*)) ); - - ThreadWeaver::Weaver::instance()->enqueue( databaseWorker ); -} - -void MagnatuneStore::addToFavorites( const QString &sku ) -{ - DEBUG_BLOCK - MagnatuneConfig config; - - if( !config.isMember() ) - return; - - QString url = "http://%1:%2@%3.magnatune.com/member/favorites?action=add_api&sku=%4"; - url = url.arg( config.username(), config.password(), config.membershipPrefix(), sku ); - - debug() << "favorites url: " << url; - - m_favoritesJob = KIO::storedGet( KUrl( url ), KIO::Reload, KIO::HideProgressInfo ); - connect( m_favoritesJob, SIGNAL(result(KJob*)), SLOT(favoritesResult(KJob*)) ); -} - -void MagnatuneStore::removeFromFavorites( const QString &sku ) -{ - DEBUG_BLOCK - MagnatuneConfig config; - - if( !config.isMember() ) - return; - - QString url = "http://%1:%2@%3.magnatune.com/member/favorites?action=remove_api&sku=%4"; - url = url.arg( config.username(), config.password(), config.membershipPrefix(), sku ); - - debug() << "favorites url: " << url; - - m_favoritesJob = KIO::storedGet( KUrl( url ), KIO::Reload, KIO::HideProgressInfo ); - connect( m_favoritesJob, SIGNAL(result(KJob*)), SLOT(favoritesResult(KJob*)) ); -} - -void MagnatuneStore::favoritesResult( KJob* addToFavoritesJob ) -{ - if( addToFavoritesJob != m_favoritesJob ) - return; - - QString result = m_favoritesJob->data(); - - Amarok::Components::logger()->longMessage( result ); - - //show the favorites page - showFavoritesPage(); -} - -void -MagnatuneStore::showSignupDialog() -{ - - if ( m_signupInfoWidget== 0 ) - { - m_signupInfoWidget = new QDialog; - Ui::SignupDialog ui; - ui.setupUi( m_signupInfoWidget ); - } - - m_signupInfoWidget->show(); -} - - - -#include "moc_MagnatuneStore.cpp" - - diff --git a/amarok/src/services/magnatune/MagnatuneStore.h b/amarok/src/services/magnatune/MagnatuneStore.h deleted file mode 100644 index c143d593..00000000 --- a/amarok/src/services/magnatune/MagnatuneStore.h +++ /dev/null @@ -1,242 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2006,2007 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROKMAGNATUNESTORE_H -#define AMAROKMAGNATUNESTORE_H - - -#include "core/support/Amarok.h" -#include "MagnatuneDownloadHandler.h" -#include "MagnatuneRedownloadHandler.h" -#include "MagnatuneXmlParser.h" -#include "MagnatuneDatabaseHandler.h" -#include "MagnatuneSqlCollection.h" - -#include "../ServiceBase.h" - -#include -#include - -#include -#include -#include -#include -#include - - -class MagnatuneInfoParser; -class MagnatuneNeedUpdateWidget; - -class MagnatuneServiceFactory : public ServiceFactory -{ - Q_OBJECT - - public: - MagnatuneServiceFactory( QObject *parent, const QVariantList &args ); - virtual ~MagnatuneServiceFactory() {} - - virtual void init(); - virtual QString name(); - virtual KConfigGroup config(); - - virtual bool possiblyContainsTrack( const KUrl &url ) const { return url.url().contains( "magnatune.com", Qt::CaseInsensitive ); } -}; - - -/** -Amarok browser that displays all the music available at magnatune.com and makes it available for previewing and purchasing. -Implemented as a singleton - -@author Nikolaj Hald Nielsen -*/ -class MagnatuneStore: public ServiceBase -{ - Q_OBJECT - -public: - /** - * Constructor - */ - MagnatuneStore( MagnatuneServiceFactory* parent, const char *name ); - /** - * Destructor - */ - ~MagnatuneStore(); - - void setMembership( int type, const QString &username, const QString &password ); - - /** - * OGG, MP3 or LOFI - */ - void setStreamType( int ); - - /** - * Do not do expensive initializations before we are actually shown - */ - void polish(); - // bool updateContextView(); - - virtual Collections::Collection * collection() { return m_collection; } - - virtual QString messages(); - virtual QString sendMessage( const QString &message ); - -public slots: - /** - * Slot for catching cancelled list downloads - */ - void listDownloadCancelled(); - - void download( Meta::MagnatuneTrack * track ); - - void download( Meta::MagnatuneAlbum * album ); - - void showFavoritesPage(); - void showHomePage(); - void showRecommendationsPage(); - - void addToFavorites( const QString &sku ); - void removeFromFavorites( const QString &sku ); - -private slots: - /** - * Slot called when the download album button is clicked. Starts a download - */ - void download(); - - void download( const QString &sku ); - - /** - * Slot for recieving notification that the update button has been clicked. - */ - void updateButtonClicked(); - - - /** - * Slot for recieving notification when the Magnatune xml file has been downloaded. - * Triggers a parse of the file to get the info added to the databse - * @param downLoadJob The calling download Job - */ - void listDownloadComplete( KJob* downLoadJob ); - - - /** - * Slot called when the parsing of the Magnatuin xml file is completed. - * Triggers an update of the list view and the genre combo box - */ - void doneParsing(); - - /** - * Starts the process of redownloading a previously bought album - */ - void processRedownload(); - - /** - * Slot for recieving notifications of completed download operations - * @param success Was the operation a success? - */ - void downloadCompleted( bool success ); - - - /** - * Adds all tracks with a common mood to the playlist - * @param mood The mood of the tracks to add - */ - void addMoodyTracksToPlaylist( const QString &mood, int count ); - - - /** - * Checks if download button should be enabled - * @param selection the new selection - * @param deseleted items that were previously selected but have been deselected - */ - void itemSelected( CollectionTreeItem * selectedItem ); - - - void moodMapReady( QMap map ); - void moodyTracksReady( Meta::TrackList tracks ); - - void timestampDownloadComplete( KJob * job ); - void favoritesResult( KJob* addToFavoritesJob ); - -private: - /** - * Helper function that initializes the button panel below the list view - */ - void initBottomPanel(); - - /** - * Helper function that initializes the genre selection panel above the list view - */ - void initTopPanel(); - - /** - * Starts downloading an updated track list xml file from - * http://magnatune.com/info/album_info.xml - * @return Currently always returns true - */ - bool updateMagnatuneList(); - - void checkForUpdates(); - - /** - * Adds a magnatune preview track to the playlist. - * @param item The track to add - */ - //void addTrackToPlaylist ( Meta::MagnatuneTrack *item ); - - void showSignupDialog(); - - static MagnatuneStore *s_instance; - - QString m_currentInfoUrl; - MagnatuneDownloadHandler *m_downloadHandler; - MagnatuneRedownloadHandler *m_redownloadHandler; - - QPushButton *m_downloadAlbumButton; - MagnatuneNeedUpdateWidget *m_needUpdateWidget; - - QAction * m_updateAction; - - bool m_downloadInProgress; - - Meta::MagnatuneAlbum * m_currentAlbum; - - KIO::FileCopyJob * m_listDownloadJob; - KIO::StoredTransferJob* m_updateTimestampDownloadJob; - KIO::StoredTransferJob* m_favoritesJob; - - Collections::MagnatuneSqlCollection * m_collection; - - QString m_tempFileName; - - bool m_isMember; - int m_membershipType; - QString m_username; - QString m_password; - - int m_streamType; - - qulonglong m_magnatuneTimestamp; - ServiceSqlRegistry * m_registry; - - MagnatuneInfoParser * m_magnatuneInfoParser; - - QDialog *m_signupInfoWidget; -}; - - -#endif diff --git a/amarok/src/services/magnatune/MagnatuneUrlRunner.cpp b/amarok/src/services/magnatune/MagnatuneUrlRunner.cpp deleted file mode 100644 index 352fc959..00000000 --- a/amarok/src/services/magnatune/MagnatuneUrlRunner.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "MagnatuneUrlRunner.h" - -#include - -MagnatuneUrlRunner::MagnatuneUrlRunner() - : QObject() - , AmarokUrlRunnerBase() -{ -} - -MagnatuneUrlRunner::~MagnatuneUrlRunner() -{ -} - -QString MagnatuneUrlRunner::command() const -{ - return "service-magnatune"; -} - -QString MagnatuneUrlRunner::prettyCommand() const -{ - return i18nc( "A type of command that triggers an action in the integrated Magnatune.com service", "Magnatune" ); -} - -KIcon MagnatuneUrlRunner::icon() const -{ - return KIcon( "view-services-magnatune-amarok" ); -} - -bool MagnatuneUrlRunner::run( AmarokUrl url ) -{ - DEBUG_BLOCK - if ( !url.isNull() ) - { - QString command = url.args().value( "command" ); - - if( command == "show_favorites" ) - { - emit( showFavorites() ); - } - else if ( command == "show_home" ) - { - emit( showHome() ); - } - else if ( command == "show_recommendations" ) - { - emit( showRecommendations() ); - } - else if ( command == "download" || command == "purchase" || command == "buy" ) - { - //allow some aliases for this command as the context might make one of - //them more appropriate. In any case, non and stream members will be given the - //purchase dialog and will have to pay, download members will get the - //free download - - if ( url.args().keys().contains( "sku" ) ) - { - QString sku = url.args().value( "sku" ); - emit( buyOrDownload( sku ) ); - } - } - else if ( command == "remove_favorite" ) - { - if ( url.args().keys().contains( "sku" ) ) - { - QString sku = url.args().value( "sku" ); - debug() << "remove from favorites sku: " << sku; - emit( removeFromFavorites( sku ) ); - } - } - - } - return true; -} - - -#include "moc_MagnatuneUrlRunner.cpp" diff --git a/amarok/src/services/magnatune/MagnatuneUrlRunner.h b/amarok/src/services/magnatune/MagnatuneUrlRunner.h deleted file mode 100644 index 0a06d315..00000000 --- a/amarok/src/services/magnatune/MagnatuneUrlRunner.h +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef MAGNATUNEURLRUNNER_H -#define MAGNATUNEURLRUNNER_H - -#include "amarokurls/AmarokUrlRunnerBase.h" - -#include - -#include - -/** - @author Nikolaj Hald Nielsen -*/ -class MagnatuneUrlRunner : public QObject, public AmarokUrlRunnerBase -{ - Q_OBJECT -public: - MagnatuneUrlRunner(); - - virtual ~MagnatuneUrlRunner(); - - virtual QString command() const; - virtual QString prettyCommand() const; - virtual KIcon icon() const; - virtual bool run( AmarokUrl url ); - -signals: - void showFavorites(); - void showHome(); - void showRecommendations(); - void buyOrDownload( const QString &sku ); - void removeFromFavorites( const QString &sku ); -}; - -#endif diff --git a/amarok/src/services/magnatune/MagnatuneXmlParser.cpp b/amarok/src/services/magnatune/MagnatuneXmlParser.cpp deleted file mode 100644 index 191fa4f0..00000000 --- a/amarok/src/services/magnatune/MagnatuneXmlParser.cpp +++ /dev/null @@ -1,416 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2006,2007 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "MagnatuneXmlParser.h" - -#include "core/support/Amarok.h" -#include "core/support/Debug.h" -#include "core/support/Components.h" -#include "core/interfaces/Logger.h" - -#include -#include -#include - -#include -#include - -using namespace Meta; - -MagnatuneXmlParser::MagnatuneXmlParser( const QString &filename ) - : ThreadWeaver::Job() -{ - m_sFileName = filename; - connect( this, SIGNAL(done(ThreadWeaver::Job*)), SLOT(completeJob()) ); -} - - -MagnatuneXmlParser::~MagnatuneXmlParser() -{ - QFile(m_sFileName).remove(); - qDeleteAll(m_currentAlbumTracksList); -} - -void -MagnatuneXmlParser::run() -{ - readConfigFile( m_sFileName ); -} - - -void -MagnatuneXmlParser::completeJob( ) -{ - Amarok::Components::logger()->longMessage( - i18ncp( "First part of: Magnatune.com database update complete. Database contains 3 tracks on 4 albums from 5 artists.", - "Magnatune.com database update complete. Database contains 1 track on ", - "Magnatune.com database update complete. Database contains %1 tracks on ", - m_nNumberOfTracks) - + i18ncp( "Middle part of: Magnatune.com database update complete. Database contains 3 tracks on 4 albums from 5 artists.", - "1 album from ", "%1 albums from ", m_nNumberOfAlbums) - + i18ncp( "Last part of: Magnatune.com database update complete. Database contains 3 tracks on 4 albums from 5 artists.", - "1 artist.", "%1 artists.", m_nNumberOfArtists ) - , Amarok::Logger::Information ); - - emit doneParsing(); - deleteLater(); -} - -void -MagnatuneXmlParser::readConfigFile( const QString &filename ) -{ - DEBUG_BLOCK - m_nNumberOfTracks = 0; - m_nNumberOfAlbums = 0; - m_nNumberOfArtists = 0; - - QDomDocument doc( "config" ); - - if ( !QFile::exists( filename ) ) - { - debug() << "Magnatune xml file does not exist"; - return; - } - - QIODevice *file = KFilterDev::deviceForFile( filename, "application/x-bzip2", true ); - if ( !file || !file->open( QIODevice::ReadOnly ) ) { - debug() << "MagnatuneXmlParser::readConfigFile error reading file"; - return ; - } - if ( !doc.setContent( file ) ) - { - debug() << "MagnatuneXmlParser::readConfigFile error parsing file"; - file->close(); - return ; - } - file->close(); - delete file; - - - m_dbHandler->destroyDatabase(); - m_dbHandler->createDatabase(); - - //run through all the elements - QDomElement docElem = doc.documentElement(); - - - m_dbHandler->begin(); //start transaction (MAJOR speedup!!) - parseElement( docElem ); - m_dbHandler->commit(); //complete transaction - - return ; -} - - -void -MagnatuneXmlParser::parseElement( const QDomElement &e ) -{ - QString sElementName = e.tagName(); - - sElementName == "Album" ? - parseAlbum( e ) : - parseChildren( e ); -} - - -void -MagnatuneXmlParser::parseChildren( const QDomElement &e ) -{ - QDomNode n = e.firstChild(); - - while ( !n.isNull() ) - { - if ( n.isElement() ) - parseElement( n.toElement() ); - - n = n.nextSibling(); - } -} - -void -MagnatuneXmlParser::parseAlbum( const QDomElement &e ) -{ - //DEBUG_BLOCK - QString sElementName; - - - QString name; - QString albumCode; - QStringList magnatuneGenres; - int launchYear = 0; - QString coverUrl; - QString description; - QString artistName; - QString artistDescription; - QString artistPhotoUrl; - QString mp3Genre; - QString artistPageUrl; - - - QDomNode n = e.firstChild(); - QDomElement childElement; - - while ( !n.isNull() ) - { - if ( n.isElement() ) - { - childElement = n.toElement(); - - QString sElementName = childElement.tagName(); - - - if ( sElementName == "albumname" ) - //printf(("|--+" + childElement.text() + "\n").toAscii()); - //m_currentAlbumItem = new MagnatuneListViewAlbumItem( m_currentArtistItem); - name = childElement.text(); - - - else if ( sElementName == "albumsku" ) - albumCode = childElement.text(); - - else if ( sElementName == "magnatunegenres" ) - magnatuneGenres = childElement.text().split(',', QString::SkipEmptyParts); - - else if ( sElementName == "launchdate" ) - { - QString dateString = childElement.text(); - QDate date = QDate::fromString( dateString, Qt::ISODate ); - launchYear = date.year(); - } - - else if ( sElementName == "cover_small" ) - coverUrl = childElement.text(); - - else if ( sElementName == "artist" ) - artistName = childElement.text(); - - else if ( sElementName == "artistdesc" ) - artistDescription = childElement.text(); - - else if ( sElementName == "artistphoto" ) - artistPhotoUrl = childElement.text() ; - - else if ( sElementName == "mp3genre" ) - mp3Genre = childElement.text(); - - else if ( sElementName == "home" ) - artistPageUrl = childElement.text(); - - else if ( sElementName == "Track" ) - parseTrack( childElement ); - - else if ( sElementName == "album_notes" ) - description = childElement.text(); - - } - - n = n.nextSibling(); - } - - m_pCurrentAlbum.reset(new MagnatuneAlbum( name )); - m_pCurrentAlbum->setAlbumCode( albumCode); - m_pCurrentAlbum->setLaunchYear( launchYear ); - m_pCurrentAlbum->setCoverUrl( coverUrl ); - m_pCurrentAlbum->setDescription( description ); - - - // now we should have gathered all info about current album (and artist)... - //Time to add stuff to the database - - //check if artist already exists, if not, create him/her/them/it - - - int artistId; - - - - if ( artistNameIdMap.contains( artistName ) ) - { - artistId = artistNameIdMap.value( artistName ); - } else { - //does not exist, lets create it... - m_pCurrentArtist.reset(new MagnatuneArtist( artistName )); - m_pCurrentArtist->setDescription( artistDescription ); - m_pCurrentArtist->setPhotoUrl( artistPhotoUrl ); - m_pCurrentArtist->setMagnatuneUrl( artistPageUrl ); - - //this is tricky in postgresql, returns id as 0 (we are within a transaction, might be the cause...) - artistId = m_dbHandler->insertArtist( m_pCurrentArtist.data() ); - - m_nNumberOfArtists++; - - if ( artistId == 0 ) - { - artistId = m_dbHandler->getArtistIdByExactName( m_pCurrentArtist->name() ); - } - - m_pCurrentArtist->setId( artistId ); - - artistNameIdMap.insert( m_pCurrentArtist->name() , artistId ); - - - } - - m_pCurrentAlbum->setArtistId( artistId ); - int albumId = m_dbHandler->insertAlbum( m_pCurrentAlbum.data() ); - if ( albumId == 0 ) // again, postgres can play tricks on us... - { - albumId = m_dbHandler->getAlbumIdByAlbumCode( m_pCurrentAlbum->albumCode() ); - } - - m_pCurrentAlbum->setId( albumId ); - - m_nNumberOfAlbums++; - - QList::iterator it; - for ( it = m_currentAlbumTracksList.begin(); it != m_currentAlbumTracksList.end(); ++it ) - { - - ( *it )->setAlbumId( m_pCurrentAlbum->id() ); - ( *it )->setArtistId( artistId ); - int trackId = m_dbHandler->insertTrack( ( *it ) ); - - - m_dbHandler->insertMoods( trackId, ( *it )->moods() ); - - m_nNumberOfTracks++; - } - - - // handle genres - - foreach( const QString &genreName, magnatuneGenres ) { - - //debug() << "inserting genre with album_id = " << albumId << " and name = " << genreName; - ServiceGenre currentGenre( genreName ); - currentGenre.setAlbumId( albumId ); - m_dbHandler->insertGenre( ¤tGenre ); - - } - - magnatuneGenres.clear(); - - qDeleteAll(m_currentAlbumTracksList); - m_currentAlbumTracksList.clear(); -} - - - -void -MagnatuneXmlParser::parseTrack( const QDomElement &e ) -{ - //DEBUG_BLOCK - m_currentTrackMoodList.clear(); - - QString trackName; - QString trackNumber; - QString streamingUrl; - - - QString sElementName; - QDomElement childElement; - - MagnatuneTrack * pCurrentTrack = new MagnatuneTrack( QString() ); - - QDomNode n = e.firstChild(); - - while ( !n.isNull() ) - { - - if ( n.isElement() ) - { - - childElement = n.toElement(); - - QString sElementName = childElement.tagName(); - - - if ( sElementName == "trackname" ) - { - pCurrentTrack->setTitle( childElement.text() ); - } - else if ( sElementName == "url" ) - { - pCurrentTrack->setUidUrl( childElement.text() ); - } - else if ( sElementName == "oggurl" ) - { - pCurrentTrack->setOggUrl( childElement.text() ); - } - else if ( sElementName == "mp3lofi" ) - { - pCurrentTrack->setLofiUrl( childElement.text() ); - } - else if ( sElementName == "tracknum" ) - { - pCurrentTrack->setTrackNumber( childElement.text().toInt() ); - } - else if ( sElementName == "seconds" ) - { - pCurrentTrack->setLength( childElement.text().toInt() ); - } - else if ( sElementName == "moods" ) - { - parseMoods( childElement ); - } - } - n = n.nextSibling(); - } - - pCurrentTrack->setMoods( m_currentTrackMoodList ); - m_currentAlbumTracksList.append( pCurrentTrack ); - -} - -void MagnatuneXmlParser::parseMoods( const QDomElement &e ) -{ - //DEBUG_BLOCK - QDomNode n = e.firstChild(); - - QDomElement childElement; - - while ( !n.isNull() ) - { - - if ( n.isElement() ) - { - - childElement = n.toElement(); - - QString sElementName = childElement.tagName(); - - if ( sElementName == "mood" ) - { - m_currentTrackMoodList.append( childElement.text() ); - } - else - { - //error, should not be here.... - } - - } - n = n.nextSibling(); - } - -} - -void MagnatuneXmlParser::setDbHandler(MagnatuneDatabaseHandler * dbHandler) -{ - m_dbHandler = dbHandler; -} - -#include "moc_MagnatuneXmlParser.cpp" - diff --git a/amarok/src/services/magnatune/MagnatuneXmlParser.h b/amarok/src/services/magnatune/MagnatuneXmlParser.h deleted file mode 100644 index 26039179..00000000 --- a/amarok/src/services/magnatune/MagnatuneXmlParser.h +++ /dev/null @@ -1,137 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2006,2007 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef MAGNATUNEXMLPARSER_H -#define MAGNATUNEXMLPARSER_H - -#include "MagnatuneDatabaseHandler.h" -#include "MagnatuneMeta.h" - -#include -#include -#include -#include -#include - -#include - -/** -* Parser for the XML file from http://magnatune.com/info/album_info.xml -* -* @author Nikolaj Hald Nielsen -*/ -class MagnatuneXmlParser : public ThreadWeaver::Job -{ - Q_OBJECT - -public: - - /** - * Constructor - * @param fileName The file to parse - * @return Pointer to new object - */ - MagnatuneXmlParser( const QString &fileName ); - - /** - * The function that starts the actual work. Inherited from ThreadWeaver::Job - * Note the work is performed in a separate thread - */ - void run(); - - /** - * Destructor - * @return none - */ - ~MagnatuneXmlParser(); - - /** - * Reads, and starts parsing, file. Should not be used directly. - * @param filename The file to read - */ - void readConfigFile( const QString &filename ); - - - void setDbHandler( MagnatuneDatabaseHandler * dbHandler ); - -signals: - - /** - * Signal emmited when parsing is complete. - */ - void doneParsing(); - - private slots: - - /** - * Called when the job has completed. Is executed in the GUI thread - */ - void completeJob(); - -private: - - QMap artistNameIdMap; - - QString m_currentArtist; - QString m_currentArtistGenre; - - /** - * Parses a DOM element - * @param e The element to parse - */ - void parseElement( const QDomElement &e ); - - /** - * Parses all children of a DOM element - * @param e The element whose children is to be parsed - */ - void parseChildren( const QDomElement &e ); - - /** - * Parse a DOM element representing an album - * @param e The album element to parse - */ - void parseAlbum( const QDomElement &e ); - - /** - * Parse a DOM element representing a track - * @param e The track element to parse - */ - void parseTrack( const QDomElement &e ); - - /** - * Parse the moods of a track - * @param e The moods element to parse - */ - void parseMoods( const QDomElement &e ); - - QScopedPointer m_pCurrentAlbum; - QScopedPointer m_pCurrentArtist; - QList m_currentAlbumTracksList; - QStringList m_currentTrackMoodList; - - QString m_sFileName; - - int m_nNumberOfTracks; - int m_nNumberOfAlbums; - int m_nNumberOfArtists; - - MagnatuneDatabaseHandler * m_dbHandler; - - -}; - -#endif diff --git a/amarok/src/services/magnatune/amarok_service_magnatunestore.desktop b/amarok/src/services/magnatune/amarok_service_magnatunestore.desktop deleted file mode 100644 index 540dcc0b..00000000 --- a/amarok/src/services/magnatune/amarok_service_magnatunestore.desktop +++ /dev/null @@ -1,134 +0,0 @@ -[Desktop Entry] -Type=Service -ServiceTypes=KPluginInfo -Icon=view-services-magnatune-amarok -Name=Magnatune Store -Name[bg]=Магазин Magnatune -Name[bs]=Magnatune prodavnica -Name[ca]=Botiga Magnatune -Name[ca@valencia]=Botiga Magnatune -Name[cs]=Obchod Magnatune -Name[csb]=Króm Magnatune -Name[da]=Magnatune-butikken -Name[de]=Magnatune-Online-Shop -Name[el]=Magnatune Store -Name[en_GB]=Magnatune Store -Name[eo]=Magnatune Vendejo -Name[es]=Tienda Magnatune -Name[et]=Magnatune pood -Name[eu]=Magnatune denda -Name[fi]=Magnatune-verkkokauppa -Name[fr]=Site de vente en ligne « Magnatune » -Name[ga]=Siopa Magnatune -Name[gl]=Tenda de Magnatune -Name[he]=חנות Magnatune -Name[hne]=मेगनाट्यून स्टोर -Name[hu]=Magnatune áruház -Name[id]=Magnatune Store -Name[is]=Magnatune verslun -Name[it]=Negozio Magnatune -Name[ja]=Magnatune ストア -Name[km]=ការ​ទុក Magnatune -Name[ko]=Magnatune 상점 -Name[ku]=Marketa Magnatune -Name[lt]=Magnatune parduotuvė -Name[lv]=Magnatune veikals -Name[nb]=Magnatune-butikken -Name[nds]=Magnatune -Name[nl]=Magnatune-winkel -Name[nn]=Magnatune-butikk -Name[pa]=Magnatune ਸਟੋਰ -Name[pl]=Sklep Magnatune -Name[pt]=Loja Magnatune -Name[pt_BR]=Loja Magnatune -Name[ro]=Magazin Magnatune -Name[ru]=Магазин Magnatune -Name[sk]=Obchod Magnatune -Name[sl]=Trgovina Magnatune -Name[sq]=Dyqani i Mangatune -Name[sr]=Магнатјунова продавница -Name[sr@ijekavian]=Магнатјунова продавница -Name[sr@ijekavianlatin]=Magnatuneova prodavnica -Name[sr@latin]=Magnatuneova prodavnica -Name[sv]=Magnatune butik -Name[th]=ร้านค้า Magnatune -Name[tr]=Magnatune Mağazası -Name[ug]=Magnatune دۇكىنى -Name[uk]=Магазин Magnatune -Name[wa]=Botike Magnatune -Name[x-test]=xxMagnatune Storexx -Name[zh_CN]=Magnatune 商店 -Name[zh_TW]=Magnatune 商店 -Comment=Preview and buy music from the non-evil Magnatune record label -Comment[bg]=Обзор и купуване на музика от Magnatune -Comment[bs]=Pregledajte i kupujte muziku od nezlobivog izdavača Magnatjuna -Comment[ca]=Vista prèvia i compra de música del segell de música Magnatune (non-evil) -Comment[ca@valencia]=Vista prèvia i compra de música del segell de música Magnatune (non-evil) -Comment[cs]=Poslechnout ukázku a koupit hudbu z Magnatune -Comment[da]=Prøvelyt og køb musik fra det ikke-onde pladeselskab Magnatune -Comment[de]=Musik des Musiklabels Magnatune probehören und herunterladen -Comment[el]=Ακούστε και αγοράστε μουσική από τη μη-διαβολική δισκογραφική εταιρεία Magnatune -Comment[en_GB]=Preview and buy music from the non-evil Magnatune record label -Comment[es]=Previsualizar y comprar música desde la discográfica no demoníaca Magnatune -Comment[et]=Kena firma Magnatune pakutava muusika eelvaatlus ja ostmine -Comment[eu]=Aurreikusi eta erosi musika Magnatune disko dendatik -Comment[fi]=Kuuntele ja osta musiikkia Magnatunesta (ei-niin-paha verkkokauppa :) -Comment[fr]=Écouter et acheter de la musique du label d'enregistrement équitable « Magnatune » -Comment[ga]=Brabhsáil agus ceannaigh ceol ó lipéad Magnatune nach bhfuil olc -Comment[gl]=Previsualice e merque música do selo discográfico Magnatune -Comment[hu]=Hallgasson bele zenébe és vásároljon zenét a gonoszságtól mentes Magnatune kiadótól -Comment[id]=Pratilik dan beli musik dari non-evil Magnatune record label -Comment[is]=Hlusta á og kaupa tónlist af vinalegu Magnatune útgáfunni -Comment[it]=Ascolta in anteprima e acquista musica dalla non-malefica etichetta discografica Magnatune -Comment[ja]=友好的な Magnatune レコードレーベルから音楽を試聴して購入できます -Comment[km]=មើល​ជា​មុន និង​ទិញ​តន្ត្រី​ពី​ស្លាក​កំណត់​ត្រា​ Magnatune ដែល​មិន​ខូច -Comment[ko]=Magnatune에서 만드는 음악을 미리 듣고 구입하기 -Comment[ku]=Pêşdîtina û kirîna muzîkê ji Magnatune -Comment[lt]=Perklausyti ir nusipirkti muziką iš įrašų kompanijos Magnatune, kurios šūkis „blogiui – ne“ -Comment[lv]=Priekšskatiet un pērciet mūziku no Magnatune ierakstu veikala -Comment[nb]=Prøvehør og kjøp musikk fra ikke-onde Magnatune musikkutgiver -Comment[nds]=Musik vun de "nich böse" Firma Magnatune proovhören un köpen -Comment[nl]=Luister naar en koop muziek van het niet-demonische Magnatude-platenlabel -Comment[nn]=Høyr på og kjøp musikk frå det ikkjevonde Magnatune-plateselskapet -Comment[pl]=Przeglądaj i kupuj muzykę z nie-diabelnego wydawnictwa Magnatune -Comment[pt]=Antever e comprar músicas da editor de discos não-maléfica Magnatune -Comment[pt_BR]=Ouça e compre músicas da gravadora boazinha Magnatune -Comment[ro]=Previzualizează și cumpără muzică de la casa de discuri ne-diabolică Magnatune -Comment[ru]=Просмотр и покупка музыки в звукозаписывающем лейбле Magnatune -Comment[sk]=Vypočuť a kúpiť hudbu z Magnatune -Comment[sl]=Poslušajte in kupite glasbo od prijazne založniške hiše Magnatune -Comment[sr]=Прегледајте и купујте музику од незлобивог издавача Магнатјуна -Comment[sr@ijekavian]=Прегледајте и купујте музику од незлобивог издавача Магнатјуна -Comment[sr@ijekavianlatin]=Pregledajte i kupujte muziku od nezlobivog izdavača Magnatunea -Comment[sr@latin]=Pregledajte i kupujte muziku od nezlobivog izdavača Magnatunea -Comment[sv]=Förhandsgranska och köp musik från det icke-onda skivbolaget Magnatune -Comment[th]=ฟังตัวอย่างและซื้อเพลงจากบริการ non-evil Magnatune record -Comment[tr]="Non-evil" Magnatune kayıt etiketinden müzik önizleyin ve satın alın -Comment[uk]=Прослухайте і купіть музику з ненав’язливої агенції звукозапису Magnatune -Comment[wa]=Prévey eyet atchter del muzike do nén må label d' eredjistraedje Magnatune -Comment[x-test]=xxPreview and buy music from the non-evil Magnatune record labelxx -Comment[zh_CN]=预览并购买来自不作恶的 Magnatune 唱片公司的音乐 -Comment[zh_TW]=從標為 non-evil 的 Magnatune 唱片標籤的音樂中,預聽並購買 - - -ServiceTypes=Amarok/Plugin - -X-KDE-Library=amarok_service_magnatunestore - -X-KDE-Amarok-authors=Nikolaj Hald Nielsen -X-KDE-Amarok-email=nhnFreespirit@gmail.com -X-KDE-Amarok-framework-version=72 -X-KDE-Amarok-name=MagnatuneStore -X-KDE-Amarok-plugintype=service -X-KDE-Amarok-rank=100 -X-KDE-Amarok-version=1 - -X-KDE-PluginInfo-Author=Nikolaj Hald Nielsen -X-KDE-PluginInfo-Email=nhnFreespirit@gmail.com -X-KDE-PluginInfo-Version=2.0 -X-KDE-PluginInfo-Category=Service -X-KDE-PluginInfo-License=GPL -X-KDE-PluginInfo-EnabledByDefault=true -X-KDE-Library=amarok_service_magnatunestore -X-KDE-PluginInfo-Name=amarok_service_magnatunestore - diff --git a/amarok/src/services/magnatune/amarok_service_magnatunestore_config.desktop b/amarok/src/services/magnatune/amarok_service_magnatunestore_config.desktop deleted file mode 100644 index 215152fd..00000000 --- a/amarok/src/services/magnatune/amarok_service_magnatunestore_config.desktop +++ /dev/null @@ -1,115 +0,0 @@ -[Desktop Entry] -Icon=view-services-magnatune-amarok -Type=Service -ServiceTypes=Amarok/Plugin -X-KDE-ServiceTypes=KCModule - -X-KDE-Library=kcm_amarok_service_magnatunestore -X-KDE-ParentApp=amarok_service_magnatunestore -X-KDE-ParentComponents=amarok_service_magnatunestore - -Name=MagnatuneStore Service Config -Name[bg]=Настройване на услугата MagnatuneStore -Name[bs]=Postava servisa Magnatune prodavnice -Name[ca]=Configuració del servei MagnatuneStore -Name[ca@valencia]=Configuració del servei MagnatuneStore -Name[cs]=Nastavení služby MagnatuneStore -Name[da]=Konfiguration af MagnatuneStore-tjenesten -Name[de]=Einrichtung von Magnatune -Name[el]=Διαμόρφωση υπηρεσίας MagnatuneStore -Name[en_GB]=MagnatuneStore Service Config -Name[eo]=MagnatuneStore Servo Agordo -Name[es]=Configurar servicio MagnatuneStore -Name[et]=MagnatuneStore teenuse seadistamine -Name[eu]=Magnature denda zerbitzuaren konfigurazioa -Name[fi]=Magnatune-verkkokaupan määritykset -Name[fr]=Configuration du service « MagnatuneStore » -Name[ga]=Cumraíocht Sheirbhís MagnatuneStore -Name[gl]=Configuracion do servizo da Tenda de Magnatune -Name[he]=הגדרת שירות Magnatune -Name[hu]=MagnatuneStore szolgáltatás beállítása -Name[id]=Konfig Layanan MagnatuneStore -Name[is]=Stillingar MagnatunaStore þjónustu -Name[it]=Configurazione servizio Magnatune -Name[ja]=Magnatune ストアサービスの設定 -Name[km]=កំណត់​រចនាសម្ព័ន្ធ​សេវា MagnatuneStore -Name[ko]=MagnatuneStore 서비스 설정 -Name[ku]=Veava kirina Servisa MagnatuneStore -Name[lt]=Magnatune parduotuvės tarnybos parinktys -Name[lv]=MagnatuneStore pakalpojuma konfigurācija -Name[nb]=Innstillinger for Magnatune-tjenesten -Name[nds]=MagnatuneStore-Deenstinstellen -Name[nl]=MagnatuneStore-dienst instellen -Name[nn]=Set opp MagnatuneStore-teneste -Name[pa]=MagnatuneStore ਸਰਵਿਸ ਸੰਰਚਨਾ -Name[pl]=Ustawienia usługi sklepu Magnatune -Name[pt]=Configuração do Serviço MagnatuneStore -Name[pt_BR]=Configuração do serviço MagnatuneStore -Name[ro]=Configurare serviciu MagnatuneStore -Name[ru]=Настройка службы Magnatune -Name[sk]=Konfigurácia služby MagnatuneStore -Name[sl]=Nastavitev storitve trgovine Magnatune -Name[sr]=Постава сервиса Магнатјунове продавнице -Name[sr@ijekavian]=Постава сервиса Магнатјунове продавнице -Name[sr@ijekavianlatin]=Postava servisa Magnatuneove prodavnice -Name[sr@latin]=Postava servisa Magnatuneove prodavnice -Name[sv]=Inställning av Magnatune butikstjänst -Name[th]=ปรับแต่งบริการ MagnatuneStore -Name[tr]=Magnatune Mağazası Hizmet Yapılandırması -Name[uk]=Налаштування служби MagnatuneStore -Name[wa]=Apontiaedje do siervice MagnatuneStore -Name[x-test]=xxMagnatuneStore Service Configxx -Name[zh_CN]=Magnatune 商店服务配置 -Name[zh_TW]=Magnatune商店服務設定 -Comment=Configure Magnatune store settings and memberships credentials -Comment[bg]=Настройване на членството в Magnatune -Comment[bs]=Postavke Magnatjunove prodavnice i članskih akreditiva -Comment[ca]=Configura els paràmetres de la botiga Magnatune i les credencials de soci -Comment[ca@valencia]=Configura els paràmetres de la botiga Magnatune i les credencials de soci -Comment[cs]=Nastavit nastavení a členské údaje pro obchod Magnatune -Comment[da]=Indstil opsætning af Magnatune-butikken og medlemsakkreditiver -Comment[de]=Einstellungen des Magnatune-Online-Shops und die Mitgliedschaft einrichten -Comment[el]=Διαμόρφωση ρυθμίσεων αποθήκευσης και διαπιστευτηρίων μελών στο Magnatune -Comment[en_GB]=Configure Magnatune store settings and memberships credentials -Comment[eo]=Agordas Magnatune vendejajn preferojn kaj membrecajn akreditaĵojn. -Comment[es]=Configurar preferencias de almacenamiento y credenciales de miembro de Magnatune -Comment[et]=Magnatune kaupluse seadistuste ja liikmesuse määramine -Comment[eu]=Konfiguratu Magnatune dendako ezarpenak eta kideen kredentzialak -Comment[fi]=Määritä Magnatunen asetukset ja jäsenyystiedot -Comment[fr]=Configurer les paramètres de la boutique « Magnatune » et les références de membre -Comment[ga]=Cumraigh socruithe siopa Magnatune agus do chuid dintiúr -Comment[gl]=Configura os parámetros da tenda Magnatune e as credenciais de membresía -Comment[hu]=A Magnatune áruház beállításainak módosítása, tagsági bejelentkezési adatok -Comment[id]=Atur pengaturan Magnatune store dan surat kuasa keanggotaan -Comment[is]=Setja inn auðkennisupplýsingar og stillingar fyrir Magnatune verslunina -Comment[it]=Configura le impostazione del negozio Magnatune e le credenziali di iscrizione -Comment[ja]=Magnatune ストアの設定と会員の資格情報を設定 -Comment[km]=កំណត់​រចនាសម្ព័ន្ធ​ការ​រក្សា​ទុក​ Magnatune និង​លិខិត​សម្គាល់​សមាជិក​ភាព -Comment[ko]=Magnatune 상점 및 회원 정보 설정 -Comment[ku]=Mîhengên marketa Magnatune û endam bûna vê ava bike -Comment[lt]=Keisti Magnatune parduotuvės parinktis ir prisijungimo duomenis -Comment[lv]=Konfigurējiet Magnatune veikala iestatījumus un reģistrācijas parametrus -Comment[nb]=Set opp innstillinger og medlemskapsinfo for Magnatune-butikken -Comment[nds]=Magnatune-Deenstinstellen un Liddmaatbeglöven instellen -Comment[nl]=Stel de configuratie en uw lidmaatschap voor de Magnatune-winkel in -Comment[nn]=Set opp Magnatune-innstillingar og medlemskap -Comment[pl]=Ustawienia sklepu Magnatune oraz dane członkowskie -Comment[pt]=Configurar as opções da loja Magnatune e as credenciais de inscrição -Comment[pt_BR]=Configurar as opções do Magnatune e credenciais de cadastramento -Comment[ro]=Configurează setările și detaliile contului în magazinul Magnatune -Comment[ru]=Указать параметры участия и настроить Magnatune -Comment[sk]=Konfigurovať nastavenia Magnatune obchodu a členské údaje -Comment[sl]=Nastavite nastavitve trgovine Magnatune in članska poverila -Comment[sr]=Поставке Магнатјунове продавнице и чланских акредитива -Comment[sr@ijekavian]=Поставке Магнатјунове продавнице и чланских акредитива -Comment[sr@ijekavianlatin]=Postavke Magnatuneove prodavnice i članskih akreditiva -Comment[sr@latin]=Postavke Magnatuneove prodavnice i članskih akreditiva -Comment[sv]=Anpassa Magnatune butiksinställningar och medlemskapsinformation -Comment[th]=ปรับแต่งการตั้งค่าและตัวรับรองสมาชิกภาพของร้านค้า Magnatune -Comment[tr]=Magnatune mağaza ve üyelik ayarlarını yapılandır -Comment[uk]=Налаштувати параметри і членських даних Magnatune -Comment[wa]=Apontyî les tchuzes del botike Magnatune eyet les credits des mimbes -Comment[x-test]=xxConfigure Magnatune store settings and memberships credentialsxx -Comment[zh_CN]=配置 Magnatune 商店的设置和会员证件 -Comment[zh_TW]=調整 Magnatune 商店設定與會員憑證 - diff --git a/amarok/src/services/magnatune/images/CMakeLists.txt b/amarok/src/services/magnatune/images/CMakeLists.txt deleted file mode 100644 index 4a42a3a6..00000000 --- a/amarok/src/services/magnatune/images/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -install( - FILES - hover_info_magnatune.png - DESTINATION ${DATA_INSTALL_DIR}/amarok/images -) diff --git a/amarok/src/services/magnatune/images/hover_info_magnatune.png b/amarok/src/services/magnatune/images/hover_info_magnatune.png deleted file mode 100644 index cecae4df..00000000 Binary files a/amarok/src/services/magnatune/images/hover_info_magnatune.png and /dev/null differ diff --git a/amarok/src/services/mp3tunes/CMakeLists.txt b/amarok/src/services/mp3tunes/CMakeLists.txt deleted file mode 100644 index 6344cca1..00000000 --- a/amarok/src/services/mp3tunes/CMakeLists.txt +++ /dev/null @@ -1,141 +0,0 @@ -if(OPENSSL_FOUND OR LIBGCRYPT_FOUND) -if(LIBXML2_FOUND AND CURL_FOUND) - if(LOUDMOUTH_FOUND AND GLIB2_FOUND AND GOBJECT_FOUND AND QT4_GLIB_SUPPORT) - include_directories( - ../ - ../../ - ../../core-impl/collections - ../../statusbar - ./libmp3tunes - ./harmonydaemon - ${LIBXML2_INCLUDE_DIR} - ${CURL_INCLUDE_DIRS} - ${CMAKE_CURRENT_BINARY_DIR}/../../.. - ${KDE4_INCLUDE_DIR} - ${QT_INCLUDES} - ) - ########### next target ############### - - include_directories( - ./harmonydaemon - ${GLIB2_INCLUDE_DIR} - ${GOBJECT_INCLUDE_DIR} - ${LOUDMOUTH_INCLUDE_DIRS} - ) - if(LIBGCRYPT_FOUND) - add_definitions(-DHAVE_LIBGCRYPT) - else(LIBGCRYPT_FOUND) - include_directories(${OPENSSL_INCLUDE_DIR}) - add_definitions(-DHAVE_OPENSSL) - endif(LIBGCRYPT_FOUND) - - set(amarok_service_mp3tunes_harmony_PART_SRCS - harmonydaemon/Mp3tunesHarmonyDownload.cpp - harmonydaemon/Mp3tunesHarmonyDaemon.cpp - harmonydaemon/Mp3tunesHarmonyClient.cpp - harmonydaemon/AmarokClient.cpp - harmonydaemon/main.cpp - libmp3tunes/md5.c - libmp3tunes/locker.c - libmp3tunes/harmony.c - ) - QT4_ADD_DBUS_ADAPTOR(amarok_service_mp3tunes_harmony_PART_SRCS - harmonydaemon/org.kde.amarok.Mp3tunesHarmonyDaemon.xml - harmonydaemon/Mp3tunesHarmonyDaemon.h - Mp3tunesHarmonyDaemon - ) - - add_executable(amarokmp3tunesharmonydaemon NOGUI - ${amarok_service_mp3tunes_harmony_PART_SRCS} - ) - - target_link_libraries(amarokmp3tunesharmonydaemon - amarokcore - amaroklib - ${KDE4_KDECORE_LIBS} - ${GLIB2_LIBRARIES} - ${GOBJECT_LIBRARIES} - ${LOUDMOUTH_LIBRARIES} - ${LIBXML2_LIBRARIES} - ${CURL_LIBRARIES} - ) - - if(LIBGCRYPT_FOUND) - target_link_libraries(amarokmp3tunesharmonydaemon ${LIBGCRYPT_LIBS}) - else(LIBGCRYPT_FOUND) - target_link_libraries(amarokmp3tunesharmonydaemon crypto ${OPENSSL_LIBRARIES}) - endif(LIBGCRYPT_FOUND) - - install(TARGETS amarokmp3tunesharmonydaemon ${INSTALL_TARGETS_DEFAULT_ARGS} ) - ########### next target ############### - - set(amarok_service_mp3tunes_PART_SRCS - Mp3tunesService.cpp - Mp3tunesServiceCollection.cpp - Mp3tunesServiceCollectionLocation.cpp - Mp3tunesServiceQueryMaker.cpp - Mp3tunesMeta.cpp - Mp3tunesConfig.cpp - Mp3tunesLockerMeta.cpp - Mp3tunesLocker.cpp - Mp3tunesWorkers.cpp - Mp3tunesHarmonyHandler.cpp - - libmp3tunes/locker.c - libmp3tunes/md5.c - ) - - QT4_ADD_DBUS_ADAPTOR(amarok_service_mp3tunes_PART_SRCS - org.kde.amarok.Mp3tunesHarmonyHandler.xml - Mp3tunesHarmonyHandler.h - Mp3tunesHarmonyHandler - ) - - kde4_add_plugin(amarok_service_mp3tunes ${amarok_service_mp3tunes_PART_SRCS}) - target_link_libraries(amarok_service_mp3tunes - amarokcore - amaroklib - ${KDE4_KDECORE_LIBS} - ${KDE4_KDEUI_LIBS} - ${KDE4_THREADWEAVER_LIBS} - ${LIBXML2_LIBRARIES} - ${CURL_LIBRARIES} - ${QT_QTNETWORK_LIBRARY} - ) - - if(LIBGCRYPT_FOUND) - target_link_libraries(amarok_service_mp3tunes ${LIBGCRYPT_LIBS}) - else(LIBGCRYPT_FOUND) - #${OPENSSL_LIBRARIES} returns -lssl, not -lcrypto. we only need -lcrypto. - target_link_libraries(amarok_service_mp3tunes crypto ${OPENSSL_LIBRARIES}) - endif(LIBGCRYPT_FOUND) - - - install(TARGETS amarok_service_mp3tunes DESTINATION ${PLUGIN_INSTALL_DIR} ) - - ########### next target ############### - - set(kcm_amarok_service_mp3tunes_PART_SRCSS - Mp3tunesSettingsModule.cpp - Mp3tunesConfig.cpp - ) - - kde4_add_ui_files( kcm_amarok_service_mp3tunes_PART_SRCSS Mp3tunesConfigWidget.ui ) - - - kde4_add_plugin( kcm_amarok_service_mp3tunes ${kcm_amarok_service_mp3tunes_PART_SRCSS} ) - - - target_link_libraries( kcm_amarok_service_mp3tunes ${QT_QTNETWORK_LIBRARY} ${KDE4_KDEUI_LIBS} ${KDE4_KUTILS_LIBS} ) - - install(TARGETS kcm_amarok_service_mp3tunes DESTINATION ${PLUGIN_INSTALL_DIR}) - - - ########### install files ############### - - install( FILES amarok_service_mp3tunes.desktop DESTINATION ${SERVICES_INSTALL_DIR}) - install( FILES amarok_service_mp3tunes_config.desktop DESTINATION ${SERVICES_INSTALL_DIR}) - endif(LOUDMOUTH_FOUND AND GLIB2_FOUND AND GOBJECT_FOUND AND QT4_GLIB_SUPPORT) -endif(LIBXML2_FOUND AND CURL_FOUND) -endif(OPENSSL_FOUND OR LIBGCRYPT_FOUND) - diff --git a/amarok/src/services/mp3tunes/Mp3tunesConfig.cpp b/amarok/src/services/mp3tunes/Mp3tunesConfig.cpp deleted file mode 100644 index 753bfb20..00000000 --- a/amarok/src/services/mp3tunes/Mp3tunesConfig.cpp +++ /dev/null @@ -1,177 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * Copyright (c) 2008 Casey Link * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "Mp3tunesConfig.h" - -#include -#include -#include -#include - -#include - -Mp3tunesConfig::Mp3tunesConfig() -{ - m_hasChanged = false; - load(); -} - - -Mp3tunesConfig::~Mp3tunesConfig() -{ -} - -void Mp3tunesConfig::load() -{ - kDebug( 14310 ) << "load"; - KConfigGroup config = KGlobal::config()->group( "Service_Mp3tunes" ); - m_email = config.readEntry( "email", QString() ); - m_password = config.readEntry( "password", QString() ); - m_identifier = config.readEntry( "identifier", QString() ); - m_pin = config.readEntry( "pin", QString() ); - m_harmonyEmail = config.readEntry( "harmonyEmail", QString() ); - m_partnerToken = config.readEntry( "partnerToken", QString( "4895500420" ) ); - m_harmonyEnabled = config.readEntry( "harmonyEnabled", false ); - - if( m_identifier.isEmpty() ) - { - foreach( const QNetworkInterface &iface, QNetworkInterface::allInterfaces() ) - { - QString addr = iface.hardwareAddress(); - if( addr != "00:00:00:00:00:00" ) { - addr.remove( ':' ); - kDebug( 14310 ) << "Using iface \"" << iface.name() << " addr: " << addr; - setIdentifier( addr + m_partnerToken ); - save(); - break; - } - } - } -} - -void Mp3tunesConfig::save() -{ - kDebug( 14310 ) << "save"; - if ( m_hasChanged ) { - KConfigGroup config = KGlobal::config()->group( "Service_Mp3tunes" ); - config.writeEntry( "email", m_email ); - config.writeEntry( "password", m_password ); - config.writeEntry( "identifier", m_identifier ); - config.writeEntry( "harmonyEnabled", m_harmonyEnabled ); - config.writeEntry( "partnerToken", m_partnerToken ); - config.writeEntry( "harmonyEmail", m_harmonyEmail ); - config.writeEntry( "pin", m_pin ); - } -} - -QString Mp3tunesConfig::email() -{ - return m_email; -} - -QString Mp3tunesConfig::password() -{ - return m_password; -} - -QString Mp3tunesConfig::partnerToken() -{ - return m_partnerToken; -} - -QString Mp3tunesConfig::identifier() -{ - return m_identifier; -} - -QString Mp3tunesConfig::pin() -{ - return m_pin; -} - -QString Mp3tunesConfig::harmonyEmail() -{ - return m_harmonyEmail; -} - -bool Mp3tunesConfig::harmonyEnabled() -{ - return m_harmonyEnabled; -} - -void Mp3tunesConfig::setHarmonyEnabled( bool enabled ) -{ - kDebug( 14310 ) << "set harmony"; - if ( enabled != m_harmonyEnabled ) { - m_harmonyEnabled = enabled; - m_hasChanged = true; - } -} - -void Mp3tunesConfig::setIdentifier( const QString &ident ) -{ - kDebug( 14310 ) << "set hwaddress"; - if ( ident != m_identifier ) { - m_identifier = ident; - m_hasChanged = true; - } -} - -void Mp3tunesConfig::setEmail( const QString &email ) -{ - kDebug( 14310 ) << "set email"; - if ( email != m_email ) { - m_email = email; - m_hasChanged = true; - } -} - -void Mp3tunesConfig::setPassword( const QString &password ) -{ - kDebug( 14310 ) << "set Password"; - if( password != m_password ) { - m_password = password; - m_hasChanged = true; - } -} - -void Mp3tunesConfig::setPartnerToken( const QString &token ) -{ - kDebug( 14310 ) << "set token"; - if( token != m_partnerToken ) { - m_partnerToken = token; - m_hasChanged = true; - } -} - -void Mp3tunesConfig::setPin( const QString &pin ) -{ - kDebug( 14310 ) << "set pin"; - if( pin != m_pin ) { - m_pin = pin; - m_hasChanged = true; - } -} - -void Mp3tunesConfig::setHarmonyEmail( const QString &harmonyEmail ) -{ - kDebug( 14310 ) << "set harmonyEmail"; - if( harmonyEmail != m_harmonyEmail ) { - m_harmonyEmail = harmonyEmail; - m_hasChanged = true; - } -} diff --git a/amarok/src/services/mp3tunes/Mp3tunesConfig.h b/amarok/src/services/mp3tunes/Mp3tunesConfig.h deleted file mode 100644 index 034a34c8..00000000 --- a/amarok/src/services/mp3tunes/Mp3tunesConfig.h +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * Copyright (c) 2008 Casey Link * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef MP3TUNESCONFIG_H -#define MP3TUNESCONFIG_H - -#include - -/** -A wrapper class for Mp3tunes service configuration - - @author -*/ -class Mp3tunesConfig{ -public: - - Mp3tunesConfig(); - - ~Mp3tunesConfig(); - - void load(); - void save(); - - QString email(); - QString password(); - QString identifier(); - QString partnerToken(); - QString pin(); - QString harmonyEmail(); - bool harmonyEnabled(); - - void setEmail( const QString &email ); - void setPassword( const QString &password ); - void setIdentifier( const QString &ident ); - void setHarmonyEnabled( bool enabled ); - void setPartnerToken( const QString &token ); - void setPin( const QString &pin ); - void setHarmonyEmail( const QString &harmonyEmail ); - -private: - - bool m_hasChanged; - bool m_harmonyEnabled; - QString m_email; - QString m_password; - QString m_identifier; - QString m_partnerToken; - QString m_pin; - QString m_harmonyEmail; - -}; - -#endif diff --git a/amarok/src/services/mp3tunes/Mp3tunesConfigWidget.ui b/amarok/src/services/mp3tunes/Mp3tunesConfigWidget.ui deleted file mode 100644 index 62a39973..00000000 --- a/amarok/src/services/mp3tunes/Mp3tunesConfigWidget.ui +++ /dev/null @@ -1,106 +0,0 @@ - - Mp3tunesConfigWidget - - - - 0 - 0 - 399 - 205 - - - - - - - MP3tunes Login - - - - - - E-Mail: - - - - - - - - - - Password: - - - - - - - - - - - - 0 - 0 - - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'DejaVu Sans'; font-size:10pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="https://shop.mp3tunes.com/myaccount/registration/"><span style=" text-decoration: underline; color:#0057ae;">Get an MP3tunes locker</span></a></p></body></html> - - - Qt::RichText - - - true - - - - - - - - - - - diff --git a/amarok/src/services/mp3tunes/Mp3tunesHarmonyHandler.cpp b/amarok/src/services/mp3tunes/Mp3tunesHarmonyHandler.cpp deleted file mode 100644 index bfebfe50..00000000 --- a/amarok/src/services/mp3tunes/Mp3tunesHarmonyHandler.cpp +++ /dev/null @@ -1,256 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Casey Link * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "Mp3tunesHarmonyHandler.h" -#include "mp3tunesharmonyhandleradaptor.h" -#include "App.h" -#include "core/support/Debug.h" - -#include -#include - -#include - - -Mp3tunesHarmonyHandler::Mp3tunesHarmonyHandler( QString identifier, - QString email, - QString pin ) - : QObject( kapp ) - , m_daemon( 0 ) - , m_identifier( identifier ) - , m_email( email ) - , m_pin( pin ) -{ - new Mp3tunesHarmonyHandlerAdaptor( this ); - QDBusConnection::sessionBus().registerObject("/Mp3tunesHarmonyHandler", this); - debug() << "All aboard the DBUS!"; -} -Mp3tunesHarmonyHandler::~Mp3tunesHarmonyHandler() -{ - stopDaemon(); - if( m_daemon ) - delete m_daemon; -} - -bool Mp3tunesHarmonyHandler::startDaemon() -{ - m_daemon = new AmarokProcess( this ); - if( m_email.isEmpty() && m_pin.isEmpty() ) - *m_daemon << "amarokmp3tunesharmonydaemon" << m_identifier; - else if( !m_email.isEmpty() && !m_pin.isEmpty() ) - *m_daemon << "amarokmp3tunesharmonydaemon" << m_identifier << m_email << m_pin; - m_daemon->setOutputChannelMode( KProcess::OnlyStdoutChannel ); - connect( m_daemon, SIGNAL(finished(int)), SLOT(slotFinished()) ); - connect( m_daemon, SIGNAL(error(QProcess::ProcessError)), SLOT(slotError(QProcess::ProcessError)) ); - m_daemon->start(); - sleep(3); // sleep for 3 seconds to allow the process to start and register. - return m_daemon->waitForStarted( -1 ); -} - -void Mp3tunesHarmonyHandler::stopDaemon() -{ - if( daemonRunning() ) - m_daemon->close(); -} - -void -Mp3tunesHarmonyHandler::slotFinished( ) -{ - m_daemon->deleteLater(); - m_daemon = 0; -} - -void -Mp3tunesHarmonyHandler::slotError( QProcess::ProcessError error ) -{ - if( error == QProcess::Crashed ) - { - //handleRestart(); - } -} - -bool Mp3tunesHarmonyHandler::daemonRunning() -{ - if( !m_daemon ) - return false; - debug() << "Daemon process is running"; - return true; -} - -bool Mp3tunesHarmonyHandler::daemonConnected() -{ - DEBUG_BLOCK - if( !daemonRunning() ) - return false; - QString name = "org.kde.amarok.Mp3tunesHarmonyDaemon-" + QString::number( m_daemon->pid() ); - debug() << "Making Dbus call about daemonConnected to: " << name; - QDBusMessage m = QDBusMessage::createMethodCall( name, - "/Mp3tunesHarmonyDaemon", - "", - "daemonConnected" ); - QDBusMessage response = QDBusConnection::sessionBus().call( m ); - if( response.type() == QDBusMessage::ErrorMessage ) - { - debug() << "Got ERROR response daemonConnected"; - debug() << response.errorName() << ": " << response.errorMessage(); - } - QList args = response.arguments(); - if( args.count() == 1) - { - if( args[0].toString() == "true" ) { - debug() << "Daemon Connected"; - return true; - } else if( args[0].toString() == "false" ) { - debug() << "Daemon Not Connected"; - return false; - } - } - debug() << "Unexpected DBUS return. " << args.count(); - return false; -} - -void Mp3tunesHarmonyHandler::makeConnection() -{ - DEBUG_BLOCK - if( !daemonRunning() ) - return; - QString name = "org.kde.amarok.Mp3tunesHarmonyDaemon-" + QString::number( m_daemon->pid() ); - debug() << "Making Dbus call about makeConnection to: " << name; - QDBusMessage m = QDBusMessage::createMethodCall( name, - "/Mp3tunesHarmonyDaemon", - "", - "makeConnection" ); - QDBusMessage response = QDBusConnection::sessionBus().call( m ); - if( response.type() == QDBusMessage::ErrorMessage ) - { - debug() << "Got ERROR response makeConnection"; - debug() << response.errorName() << ": " << response.errorMessage(); - } -} - -void Mp3tunesHarmonyHandler::breakConnection() -{ - DEBUG_BLOCK - if( !daemonRunning() ) - return; - QString name = "org.kde.amarok.Mp3tunesHarmonyDaemon-" + QString::number( m_daemon->pid() ); - //QString name = "org.kde.amarok.Mp3tunesHarmonyDaemon"; - debug() << "Making Dbus call about breakConnection to: " << name; - QDBusMessage m = QDBusMessage::createMethodCall( name, - "/Mp3tunesHarmonyDaemon", - "", - "breakConnection" ); - QDBusMessage response = QDBusConnection::sessionBus().call( m ); - if( response.type() == QDBusMessage::ErrorMessage ) - { - debug() << "Got ERROR response "; - debug() << response.errorName() << ": " << response.errorMessage(); - } -} - -QString Mp3tunesHarmonyHandler::pin() -{ - DEBUG_BLOCK - if( !daemonRunning() ) - return QString(); - QString name = "org.kde.amarok.Mp3tunesHarmonyDaemon-" + QString::number( m_daemon->pid() ); - //QString name = "org.kde.amarok.Mp3tunesHarmonyDaemon"; - debug() << "Making Dbus call about pin to: " << name; - QDBusMessage m = QDBusMessage::createMethodCall( name, - "/Mp3tunesHarmonyDaemon", - "", - "pin" ); - QDBusMessage response = QDBusConnection::sessionBus().call( m ); - if( response.type() == QDBusMessage::ErrorMessage ) - { - debug() << "Got ERROR response pin"; - debug() << response.errorName() << ": " << response.errorMessage(); - } - QList args = response.arguments(); - if( args.count() == 1) - { - return args[0].toString(); - } - return QString(); -} - -QString Mp3tunesHarmonyHandler::email() -{ - DEBUG_BLOCK - if( !daemonRunning() ) - return QString(); - QString name = "org.kde.amarok.Mp3tunesHarmonyDaemon-" + QString::number( m_daemon->pid() ); - //QString name = "org.kde.amarok.Mp3tunesHarmonyDaemon"; - debug() << "Making Dbus call about email to: " << name; - QDBusMessage m = QDBusMessage::createMethodCall( name, - "/Mp3tunesHarmonyDaemon", - "", - "email" ); - QDBusMessage response = QDBusConnection::sessionBus().call( m ); - if( response.type() == QDBusMessage::ErrorMessage ) - { - debug() << "Got ERROR response email"; - debug() << response.errorName() << ": " << response.errorMessage(); - } - QList args = response.arguments(); - if( args.count() == 1) - { - return args[0].toString(); - } - return QString(); -} - -void -Mp3tunesHarmonyHandler::emitError( const QString &error ) -{ - emit( signalError( error ) ); -} - -void -Mp3tunesHarmonyHandler::emitWaitingForEmail( const QString &pin ) -{ - emit( waitingForEmail( pin ) ); -} - -void -Mp3tunesHarmonyHandler::emitWaitingForPin() -{ - emit( waitingForPin() ); -} - -void -Mp3tunesHarmonyHandler::emitConnected() -{ - emit( connected() ); -} - -void -Mp3tunesHarmonyHandler::emitDisconnected() -{ - emit( disconnected() ); -} - -void -Mp3tunesHarmonyHandler::emitDownloadReady( const QVariantMap &download ) -{ - emit( downloadReady( download ) ); -} - -void -Mp3tunesHarmonyHandler::emitDownloadPending( const QVariantMap &download ) -{ - emit( downloadReady( download ) ); -} diff --git a/amarok/src/services/mp3tunes/Mp3tunesHarmonyHandler.h b/amarok/src/services/mp3tunes/Mp3tunesHarmonyHandler.h deleted file mode 100644 index 0d59f480..00000000 --- a/amarok/src/services/mp3tunes/Mp3tunesHarmonyHandler.h +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Casey Link * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef MP3TUNESHARMONYHANDLER_H -#define MP3TUNESHARMONYHANDLER_H - -#include "harmonydaemon/Mp3tunesHarmonyDownload.h" -#include "AmarokProcess.h" - -#include -#include -#include - - -class Mp3tunesHarmonyHandler : public QObject { - Q_OBJECT - Q_CLASSINFO("Amarok Harmony D-Bus Interface", "org.kde.amarok.Mp3tunesHarmonyHandler") - public: - explicit Mp3tunesHarmonyHandler( QString identifier, - QString email = QString(), - QString pin = QString() ); - ~Mp3tunesHarmonyHandler(); - - bool startDaemon(); - void stopDaemon(); - bool daemonRunning(); - bool daemonConnected(); - void makeConnection(); - void breakConnection(); - QString pin(); - QString email(); - - signals: - void waitingForEmail( const QString &pin ); - void waitingForPin(); - void connected(); - void disconnected(); - void signalError( const QString &error ); - void downloadReady( const QVariantMap &download ); - void downloadPending( const QVariantMap &download ); - - public slots: - virtual void emitError( const QString &error ); - virtual void emitWaitingForEmail( const QString &pin ); - virtual void emitWaitingForPin(); - virtual void emitConnected(); - virtual void emitDisconnected(); - virtual void emitDownloadReady( const QVariantMap &download ); - virtual void emitDownloadPending( const QVariantMap &download ); - - private slots: - void slotFinished(); - void slotError( QProcess::ProcessError error ); - - private: - AmarokProcess *m_daemon; - - QString m_identifier; - QString m_email; - QString m_pin; -}; -#endif diff --git a/amarok/src/services/mp3tunes/Mp3tunesLocker.cpp b/amarok/src/services/mp3tunes/Mp3tunesLocker.cpp deleted file mode 100644 index 5b7533d7..00000000 --- a/amarok/src/services/mp3tunes/Mp3tunesLocker.cpp +++ /dev/null @@ -1,620 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007,2008 Casey Link * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "Mp3tunesLocker.h" - -#include "core/support/Debug.h" - -#include -#include - -#include - - -Mp3tunesLocker::Mp3tunesLocker ( const QString & partnerToken ) -{ - DEBUG_BLOCK - m_locker = 0; - debug() << "Creating New Locker"; - QByteArray partner_token = partnerToken.toLatin1(); - debug() << "Wrapper Token: " << partnerToken; - mp3tunes_locker_init ( &m_locker, partner_token.constData() ); - debug() << "New Locker created"; -} - -Mp3tunesLocker::Mp3tunesLocker ( const QString & partnerToken, const QString & userName, -const QString & password ) -{ - QByteArray partner_token = partnerToken.toLatin1(); - mp3tunes_locker_init ( &m_locker, partner_token.constData() ); - - this->login ( userName, password ); -} - -Mp3tunesLocker::~Mp3tunesLocker() -{ - mp3tunes_locker_deinit ( &m_locker ); -} - -QString -Mp3tunesLocker::login ( const QString &userName, const QString &password ) -{ - DEBUG_BLOCK - QByteArray user = userName.toLatin1(); - QByteArray pw = password.toLatin1(); - //result = 0 Login successful - //result != 0 Login failed - debug() << "Wrapper Logging on with: " << userName << ":" << password; - int result = mp3tunes_locker_login ( m_locker, user.constData(), pw.constData() ); - - if ( result == 0 ) - { - //login successful - debug() << "Wrapper Login succeeded. result: " << result; - return this->sessionId(); - } - debug() << "Wrapper Login failed. result: " << result; - return QString(); //login failed -} - -QString -Mp3tunesLocker::login () -{ - return login( userName(), password() ); -} -bool -Mp3tunesLocker::sessionValid() const -{ - //result = 0 session valid - //result != 0 session invalid - int result = mp3tunes_locker_session_valid ( m_locker ); - if ( result == 0 ) - return true; - return false; -} - -QList -Mp3tunesLocker::artists() const -{ - DEBUG_BLOCK - QList artistsQList; // to be returned - mp3tunes_locker_artist_list_t *artists_list; - mp3tunes_locker_list_item_t *artist_item; - - //get the list of artists - mp3tunes_locker_artists ( m_locker, &artists_list ); - - artist_item = artists_list->first; // the current node - - //looping through the list of artists - while ( artist_item != 0 ) - { - // get the artist from the c lib - mp3tunes_locker_artist_t *artist = ( mp3tunes_locker_artist_t* ) artist_item->value; - //debug() << "Wrapper Artist: " << artist->artistName; - - //wrap it up - Mp3tunesLockerArtist artistWrapped ( artist ); - //and stick it in the QList - artistsQList.append ( artistWrapped ); - //advance to next artist - //debug() << "Going to next artist"; - artist_item = artist_item->next; - } - mp3tunes_locker_artist_list_deinit ( &artists_list ); - debug() << "Wrapper deinit Complete"; - return artistsQList; -} - -QList -Mp3tunesLocker::artistsSearch ( const QString &query ) const -{ - DEBUG_BLOCK - Mp3tunesSearchResult container; - container.searchFor = Mp3tunesSearchResult::ArtistQuery; - search ( container, query ); - return container.artistList; -} - -QList -Mp3tunesLocker::albums() const -{ - QList albumsQList; // to be returned - mp3tunes_locker_album_list_t *albums_list; - mp3tunes_locker_list_item_t *album_item; - - //get the list of albums - mp3tunes_locker_albums ( m_locker, &albums_list ); - - mp3tunes_locker_album_t *album; // the value holder - album_item = albums_list->first; // the current node - - //looping through the list of albums - while ( album_item != 0 ) - { - // get the album from the c lib - album = ( mp3tunes_locker_album_t* ) album_item->value; - //wrap it up and stick it in the QList - Mp3tunesLockerAlbum albumWrapped ( album ); - albumsQList.append ( albumWrapped ); - - album_item = album_item->next; - } - mp3tunes_locker_album_list_deinit ( &albums_list ); - - return albumsQList; -} - -QList -Mp3tunesLocker::albumsSearch ( const QString &query ) const -{ - Mp3tunesSearchResult container; - container.searchFor = Mp3tunesSearchResult::AlbumQuery; - search ( container, query ); - return container.albumList; -} - -QList -Mp3tunesLocker::albumsWithArtistId ( int artistId ) const -{ - QList albumsQList; // to be returned - mp3tunes_locker_album_list_t *albums_list; - mp3tunes_locker_list_item_t *album_item; - - //get the list of albums - mp3tunes_locker_albums_with_artist_id ( m_locker, &albums_list, artistId ); - - mp3tunes_locker_album_t *album; // the value holder - album_item = albums_list->first; // the current node - - //looping through the list of albums - while ( album_item != 0 ) - { - // get the album from the c lib - album = ( mp3tunes_locker_album_t* ) album_item->value; - //wrap it up - Mp3tunesLockerAlbum albumWrapped ( album ); - albumsQList.append ( albumWrapped ); - - album_item = album_item->next; - } - mp3tunes_locker_album_list_deinit ( &albums_list ); - - return albumsQList; -} - -QList -Mp3tunesLocker::playlists() const -{ - QList playlistsQList; // to be returned - - mp3tunes_locker_playlist_list_t *playlist_list; - mp3tunes_locker_list_item_t *playlist_item; - mp3tunes_locker_playlist_t *playlist; - - mp3tunes_locker_playlists ( this->m_locker, &playlist_list ); - - playlist_item = playlist_list->first; - while ( playlist_item != 0 ) - { - playlist = ( mp3tunes_locker_playlist_t* ) playlist_item->value; - - Mp3tunesLockerPlaylist playlistWrapped ( playlist ); - playlistsQList.append ( playlistWrapped ); - - playlist_item = playlist_item->next; - } - mp3tunes_locker_playlist_list_deinit ( &playlist_list ); - - return playlistsQList; -} - -QList -Mp3tunesLocker::tracks() const -{ - QList tracksQList; // to be returned - - mp3tunes_locker_track_list_t *tracks_list; - mp3tunes_locker_list_item_t *track_item; - mp3tunes_locker_track_t *track; - - mp3tunes_locker_tracks ( m_locker, &tracks_list ); - - track_item = tracks_list->first; - while ( track_item != 0 ) - { - track = ( mp3tunes_locker_track_t* ) track_item->value; - - Mp3tunesLockerTrack trackWrapped ( track ); - tracksQList.append ( trackWrapped ); - - track_item = track_item->next; - } - mp3tunes_locker_track_list_deinit ( &tracks_list ); - - return tracksQList; -} - -QList -Mp3tunesLocker::tracksSearch ( const QString &query ) const -{ - Mp3tunesSearchResult container; - container.searchFor = Mp3tunesSearchResult::TrackQuery; - search ( container, query ); - return container.trackList; -} - -QList -Mp3tunesLocker::tracksWithPlaylistId ( const QString & playlistId ) const -{ - QByteArray playlistid = playlistId.toLatin1(); - - QList tracksQList; // to be returned - - mp3tunes_locker_track_list_t *tracks_list; - mp3tunes_locker_list_item_t *track_item; - mp3tunes_locker_track_t *track; - - mp3tunes_locker_tracks_with_playlist_id ( m_locker, &tracks_list, playlistid.constData() ); - - track_item = tracks_list->first; - while ( track_item != 0 ) - { - track = ( mp3tunes_locker_track_t* ) track_item->value; - - Mp3tunesLockerTrack trackWrapped ( track ); - tracksQList.append ( trackWrapped ); - - track_item = track_item->next; - } - mp3tunes_locker_track_list_deinit ( &tracks_list ); - - return tracksQList; -} - -QList -Mp3tunesLocker::tracksWithAlbumId ( int albumId ) const -{ - QList tracksQList; // to be returned - - mp3tunes_locker_track_list_t *tracks_list; - mp3tunes_locker_list_item_t *track_item; - mp3tunes_locker_track_t *track; - - mp3tunes_locker_tracks_with_album_id ( m_locker, &tracks_list, albumId ); - - track_item = tracks_list->first; - while ( track_item != 0 ) - { - track = ( mp3tunes_locker_track_t* ) track_item->value; - - Mp3tunesLockerTrack trackWrapped ( track ); - tracksQList.append ( trackWrapped ); - - track_item = track_item->next; - } - mp3tunes_locker_track_list_deinit ( &tracks_list ); - - return tracksQList; -} - -QList -Mp3tunesLocker::tracksWithArtistId ( int artistId ) const -{ - QList tracksQList; // to be returned - - mp3tunes_locker_track_list_t *tracks_list; - mp3tunes_locker_list_item_t *track_item; - mp3tunes_locker_track_t *track; - - mp3tunes_locker_tracks_with_artist_id ( m_locker, &tracks_list, artistId ); - - track_item = tracks_list->first; - while ( track_item != 0 ) - { - track = ( mp3tunes_locker_track_t* ) track_item->value; - - Mp3tunesLockerTrack trackWrapped ( track ); - tracksQList.append ( trackWrapped ); - - track_item = track_item->next; - } - mp3tunes_locker_track_list_deinit ( &tracks_list ); - - return tracksQList; -} - -QList -Mp3tunesLocker::tracksWithFileKeys( QStringList filekeys ) const -{ - QString keys; - foreach( const QString &key, filekeys ) - { - keys.append(key); - keys.append(","); - } - keys.chop(1); - QByteArray file_keys = keys.toLatin1(); - - mp3tunes_locker_track_list_t* tracks_list = 0; - mp3tunes_locker_list_item_t* track_item = 0; - mp3tunes_locker_track_t *track = 0; - QList tracksQList; // to be returned, init'ed to null - tracksQList.clear(); - - if ( mp3tunes_locker_tracks_with_file_key ( m_locker, file_keys, &tracks_list ) - || !tracks_list ) - { - mp3tunes_locker_track_list_deinit ( &tracks_list ); - return tracksQList; - } - - track_item = tracks_list->first; - while ( track_item ) - { - track = ( mp3tunes_locker_track_t* ) track_item->value; - Mp3tunesLockerTrack trackWrapped ( track ); - tracksQList.append ( trackWrapped ); - - track_item = track_item->next; - } - - mp3tunes_locker_track_list_deinit ( &tracks_list ); - return tracksQList; -} - -Mp3tunesLockerTrack -Mp3tunesLocker::trackWithFileKey( const QString &filekey ) const -{ - DEBUG_BLOCK - QByteArray file_key = filekey.toLatin1(); - - mp3tunes_locker_track_t *track = 0; - mp3tunes_locker_track_with_file_key ( m_locker, file_key.constData(), &track ); - if ( !track ) - return Mp3tunesLockerTrack( 0 ); - - debug() << "Got track: " << track->trackTitle << " from filekey: " << filekey; - Mp3tunesLockerTrack trackWrapped ( track ); - free( track ); - debug() << "returning"; - return trackWrapped; -} - -bool -Mp3tunesLocker::search ( Mp3tunesSearchResult &container, const QString &query ) const -{ - // setup vars - mp3tunes_locker_artist_list_t *artists_list; - mp3tunes_locker_list_item_t *artist_item; - mp3tunes_locker_artist_t *artist; - - mp3tunes_locker_album_list_t *albums_list; - mp3tunes_locker_list_item_t *album_item; - mp3tunes_locker_album_t *album; - - mp3tunes_locker_track_list_t *tracks_list; - mp3tunes_locker_list_item_t *track_item; - mp3tunes_locker_track_t *track; - - if ( container.searchFor & Mp3tunesSearchResult::ArtistQuery ) - artists_list = 0; - - if ( container.searchFor & Mp3tunesSearchResult::AlbumQuery ) - albums_list = 0; - - if ( container.searchFor & Mp3tunesSearchResult::TrackQuery ) - tracks_list = 0; - - QByteArray search_query = query.toLatin1(); - - int res = mp3tunes_locker_search ( m_locker, &artists_list, &albums_list, - &tracks_list, search_query.constData() ); - - if ( res != 0 ) - { - if ( artists_list ) - free( artists_list ); - if ( albums_list ) - free( albums_list ); - if ( tracks_list ) - free( tracks_list ); - return false; - } - if ( !artists_list && ( container.searchFor & Mp3tunesSearchResult::ArtistQuery ) ) - { - if ( albums_list ) - free( albums_list ); - if ( tracks_list ) - free( tracks_list ); - - return false; - } - if ( !albums_list && ( container.searchFor & Mp3tunesSearchResult::AlbumQuery ) ) - { - if ( artists_list ) - free( artists_list ); - if ( tracks_list ) - free( tracks_list ); - - return false; - } - if ( !tracks_list && ( container.searchFor & Mp3tunesSearchResult::TrackQuery ) ) - { - if ( albums_list ) - free( albums_list ); - if ( artists_list ) - free( artists_list ); - - return false; - } - - if ( container.searchFor & Mp3tunesSearchResult::ArtistQuery ) - { - artist_item = artists_list->first; - while ( artist_item != 0 ) - { - artist = ( mp3tunes_locker_artist_t* ) artist_item->value; - - Mp3tunesLockerArtist artistWrapped ( artist ); - container.artistList.append ( artistWrapped ); - - artist_item = artist_item->next; - } - mp3tunes_locker_artist_list_deinit ( &artists_list ); - } - - if ( container.searchFor & Mp3tunesSearchResult::AlbumQuery ) - { - album_item = albums_list->first; - while ( album_item != 0 ) - { - album = ( mp3tunes_locker_album_t* ) album_item->value; - - Mp3tunesLockerAlbum albumWrapped ( album ); - container.albumList.append ( albumWrapped ); - - album_item = album_item->next; - } - mp3tunes_locker_album_list_deinit ( &albums_list ); - } - - if ( container.searchFor & Mp3tunesSearchResult::TrackQuery ) - { - track_item = tracks_list->first; - while ( track_item != 0 ) - { - track = ( mp3tunes_locker_track_t* ) track_item->value; - - Mp3tunesLockerTrack trackWrapped ( track ); - container.trackList.append ( trackWrapped ); - - track_item = track_item->next; - } - mp3tunes_locker_track_list_deinit ( &tracks_list ); - } - return true; -} - -bool -Mp3tunesLocker::uploadTrack ( const QString &path ) -{ - QByteArray track_path = path.toUtf8(); - - int res = mp3tunes_locker_upload_track ( m_locker, track_path.constData() ); - - return ( res == 0 ); -} - -QString -Mp3tunesLocker::fileKey ( const QString &path ) -{ - QByteArray fk_path = path.toLatin1(); - - char* file_key = mp3tunes_locker_generate_filekey ( fk_path.constData() ); - - return QString ( file_key ); -} - -bool -Mp3tunesLocker::lockerLoad( const QString &url ) -{ - QByteArray locker_url = url.toLatin1(); - - int res = mp3tunes_locker_load_track ( m_locker, locker_url.constData() ); - - return ( res == 0); -} - -QString -Mp3tunesLocker::userName() const -{ - return QString ( m_locker->username ); -} - -QString -Mp3tunesLocker::password() const -{ - return QString ( m_locker->password ); -} - -QString -Mp3tunesLocker::sessionId() const -{ - return QString ( m_locker->session_id ); -} - -QString -Mp3tunesLocker::firstName() const -{ - return QString ( m_locker->firstname ); -} - -QString -Mp3tunesLocker::lastName() const -{ - return QString ( m_locker->lastname ); -} - -QString -Mp3tunesLocker::nickName() const -{ - return QString ( m_locker->nickname ); -} - -QString -Mp3tunesLocker::partnerToken() const -{ - return QString ( m_locker->partner_token ); -} - -QString -Mp3tunesLocker::serverApi() const -{ - return QString ( m_locker->server_api ); -} - -QString -Mp3tunesLocker::serverContent() const -{ - return QString ( m_locker->server_content ); -} - -QString -Mp3tunesLocker::serverLogin() const -{ - return QString ( m_locker->server_login ); -} - -QString -Mp3tunesLocker::errorMessage() const -{ - if( m_locker->error_message != 0 ) - { - return QString ( m_locker->error_message ); - } - return QString(); -} -bool -Mp3tunesLocker::authenticated() const -{ - // do it in this order to avoid making an extra http request - if( sessionId().isEmpty() ) - return false; - else if( sessionValid() ) - return true; - return false; -} diff --git a/amarok/src/services/mp3tunes/Mp3tunesLocker.h b/amarok/src/services/mp3tunes/Mp3tunesLocker.h deleted file mode 100644 index 4b50bb55..00000000 --- a/amarok/src/services/mp3tunes/Mp3tunesLocker.h +++ /dev/null @@ -1,243 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007,2008 Casey Link * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef MP3TUNESLOCKER_H -#define MP3TUNESLOCKER_H - -extern "C" { - // Get libmp3tunes declarations - #include "libmp3tunes/locker.h" -} - -#include "Mp3tunesLockerMeta.h" - -#include -#include - -/** - * A psudeo type to encapsulate the various return types from a search query. - */ -class Mp3tunesSearchResult { - public: - enum SearchType { - ArtistQuery = 1, - AlbumQuery = 2, - TrackQuery = 4 - }; - QList artistList; - QList albumList; - QList trackList; - SearchType searchFor; -}; - -/** - * A wrapper class for the libmp3tunes locker object. - * @author Casey Link - */ -class Mp3tunesLocker { - public: - - /** - * Initialize the connection, but do not login. - * @param partnerToken your partnerToken to access the mp3tunes API. - */ - Mp3tunesLocker( const QString & partnerToken ); - - /** - * Initialize the connection, and login. - * for testing use demo@mp3tunes.com:demo - * @param partnerToken your partnerToken to access the mp3tunes API. - * @param userName the username - * @param password username's password - */ - Mp3tunesLocker( const QString & partnerToken, const QString & userName, const QString & password ); - - ~Mp3tunesLocker(); - - /** - * Logs into the locker. - * for testing use demo@mp3tunes.com:demo - * @param userName the username - * @param passowrd username's password - * @return if login successful, the sessionId is returned - * if login failed, an empty QString is returned - */ - QString login( const QString & userName, const QString & password ); - - /** - * Logs into the locker using stored credentials. - * Useful if a session is no longer valid. - * @return if login successful, the sessionId is returned - * if login failed, an empty QString is returned - */ - QString login(); - - /** - * Detects if a session has timed out. - * @return true, if session is still valid. - * false, if session is invalid. - */ - bool sessionValid() const; - - /** - * @return a list of all the artists in the locker - */ - QList artists() const; - - /** - * Searches the locker for artists containing the query. - * @param query the string to search for - * @return a list of all the artists in the locker containing the query - */ - QList artistsSearch( const QString &query ) const; - - /** - * @return a list of all the albums in the locker - */ - QList albums() const; - - /** - * Searches the locker for albums containing the query. - * @param query the string to search for - * @return a list of all the albums in the locker containing the query - */ - QList albumsSearch( const QString &query ) const; - - /** - * @param artistId the id of the artist to list albums for - * @return a QList of albums belonging to the supplied artist - */ - QList albumsWithArtistId( int artistId ) const; - - /** - * @return a list of all the playlists in the locker - */ - QList playlists() const; - - /** - * @return a list of all the tracks in the locker - */ - QList tracks() const; - - /** - * Searches the locker for tracks containing the query. - * @param query the string to search for - * @return a list of all the tracks in the locker containing the query - */ - QList tracksSearch( const QString &query ) const; - - /** - * @param playlistId a playlist id - * @return a list of all the tracks with playlistId - */ - QList tracksWithPlaylistId( const QString & playlistId) const; - - /** - * @param albumId an album id - * @return a list of all the tracks with albumId - */ - QList tracksWithAlbumId( int albumId ) const; - - /** - * @param artistId an artist Id - * @return a list of all the tracks with artistId - */ - QList tracksWithArtistId( int artistId ) const; - - /** - * Get a list of tracks from a list of filekeys. - * @param filekeys a list of filekeys - * @return a list of tracks that match the supplied filekeys. The returned list - * of tracks be in the same order as the supplied filekeys. - * Might return an empty List. - */ - QList tracksWithFileKeys( QStringList filekeys ) const; - - /** - * Get a single track from a single filekey. - * @param filekey the filekey to match to a track - * @return the track that matches the filekey. - */ - Mp3tunesLockerTrack trackWithFileKey( const QString &filekey ) const; - - /** - * Searches the Locker for tracks, albums, and/or artists. - * Which type it searches depends on the Mp3tunesSearchResult's - * searchFor passed to it. - * @pre Mp3tunesSearchResult's fields are initialized properly - * depending on the types (artist, track album) you want searched. - * Properly means: If you want a type searched initialize an empty - * QList and set the appropriate SearchType bit. - * @post The Mp3tunesSearchResult's fields will filled with the - * search results. If the search returned empty, then the - * QLists will be empty. - * @param container contains the QList's to be filled with search results - * @return true if search succeeded. Note: Zero search results is not failure. - * false if search failed. - */ - bool search( Mp3tunesSearchResult &container, const QString &query ) const; - - /** - * Uploads a track to the locker using HTTP Put. - * @param path the absolute filename of the track to upload - * @return true if upload succeeded - * false if upload failed - * @pre The track exists and is a filetype that mp3tunes accepts. - */ - bool uploadTrack( const QString &path ); - - /** - * Generates the file key identifier for a media file. - * @param path the absolute filename of the track - * @return the file key - * @pre The track exists and is a filetype that mp3tunes accepts. - */ - QString fileKey(const QString &path ); - - /** - * Loads a URL into the locker via the LockerLoad API. - * The URL may be password protected, as long as the username - * and password can be transferred in the URL to retrieve the - * file. Any access control based on user sessions cannot be - * used in locker loading. - * @param the full URL to the track - * @return true if the lockerload succeeded - * false if the lockerload failed. - * @pre The URL must be accessible by the MP3tunes servers, - * it is assumed that all the tracks in the file are - * non-DRM music files. - */ - bool lockerLoad( const QString &url ); - //TODO wrapper for mp3tunes_locker_generate_download_url_from_file_key - //TODO wrapper for mp3tunes_locker_generate_download_url_from_file_key_and_bitrate - //TODO wrapper for mp3tunes_locker_sync_down - - QString userName() const; - QString password() const; - QString sessionId() const; - QString firstName() const; - QString lastName() const; - QString nickName() const; - QString partnerToken() const; - QString serverApi() const; - QString serverContent() const; - QString serverLogin() const; - QString errorMessage() const; - bool authenticated() const; - private: - mp3tunes_locker_object_t *m_locker; -}; -#endif diff --git a/amarok/src/services/mp3tunes/Mp3tunesLockerMeta.cpp b/amarok/src/services/mp3tunes/Mp3tunesLockerMeta.cpp deleted file mode 100644 index c28c3395..00000000 --- a/amarok/src/services/mp3tunes/Mp3tunesLockerMeta.cpp +++ /dev/null @@ -1,286 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Casey Link * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "Mp3tunesLockerMeta.h" -#include "core/support/Debug.h" - -//////////////////////////////////////////////////////////////////////// -//ARTIST -Mp3tunesLockerArtist::Mp3tunesLockerArtist( mp3tunes_locker_artist_t *artist ) - : m_artistId( 0 ) - , m_artistName() - , m_artistSize( 0 ) - , m_albumCount( 0 ) - , m_trackCount( 0 ) -{ - if( !artist ) return; - - m_artistId = artist->artistId; - m_artistName = artist->artistName; - m_artistSize = artist->artistSize; - m_albumCount = artist->albumCount; - m_trackCount = artist->trackCount; -} - -Mp3tunesLockerArtist::~Mp3tunesLockerArtist() -{} - -int Mp3tunesLockerArtist::artistId() const -{ - return m_artistId; -} - -QString Mp3tunesLockerArtist::artistName() const -{ - return m_artistName; -} - -int Mp3tunesLockerArtist::artistSize() const -{ - return m_artistSize; -} - -int Mp3tunesLockerArtist::albumCount() const -{ - return m_albumCount; -} - -int Mp3tunesLockerArtist::trackCount() const -{ - return m_trackCount; -} -//////////////////////////////////////////////////////////////////////// -//ALBUM -Mp3tunesLockerAlbum::Mp3tunesLockerAlbum( mp3tunes_locker_album_t *album ) - : m_albumId( 0 ) - , m_albumTitle() - , m_artistId( 0 ) - , m_artistName() - , m_trackCount( 0 ) - , m_albumSize( 0 ) - , m_hasArt( false ) -{ - if( !album ) return; - - m_albumId = album->albumId; - m_albumTitle = album->albumTitle; - m_artistId = album->artistId; - m_artistName = album->artistName; - m_trackCount = album->trackCount; - m_albumSize = album->albumSize; - m_hasArt = album->hasArt; -} - -Mp3tunesLockerAlbum::~Mp3tunesLockerAlbum() -{} - -int Mp3tunesLockerAlbum::albumId() const -{ - return m_albumId; -} - -QString Mp3tunesLockerAlbum::albumTitle() const -{ - return m_albumTitle; -} - -int Mp3tunesLockerAlbum::artistId() const -{ - return m_artistId; -} - -QString Mp3tunesLockerAlbum::artistName() const -{ - return m_artistName; -} - -int Mp3tunesLockerAlbum::trackCount() const -{ - return m_trackCount; -} - -int Mp3tunesLockerAlbum::albumSize() const -{ - return m_albumSize; -} - -bool Mp3tunesLockerAlbum::hasArt() const -{ - return m_hasArt; -} -//////////////////////////////////////////////////////////////////////// -//TRACK -Mp3tunesLockerTrack::Mp3tunesLockerTrack( mp3tunes_locker_track_t *track ) - : m_trackId( 0 ) - , m_trackTitle() - , m_trackNumber( 0 ) - , m_trackLength( 0.0 ) - , m_trackFileName() - , m_trackFileKey() - , m_trackFileSize( 0 ) - , m_downloadUrl() - , m_playUrl() - , m_albumId( 0 ) - , m_albumTitle() - , m_albumYear( 0 ) - , m_artistName() - , m_artistId( 0 ) -{ - if ( !track ) return; - - m_trackTitle = track->trackTitle; - m_trackNumber = track->trackNumber; - m_trackLength = track->trackLength; - m_trackFileName = track->trackFileName; - m_trackFileKey = track->trackFileKey; - m_trackFileSize = track->trackFileSize; - m_downloadUrl = track->downloadURL; - m_playUrl = track->playURL; - m_albumId = track->albumId; - m_albumTitle = track->albumTitle; - m_albumYear = track->albumYear; - m_artistName = track->artistName; - m_artistId = track->artistId; -} - -Mp3tunesLockerTrack::~Mp3tunesLockerTrack() -{} - -int Mp3tunesLockerTrack::trackId() const -{ - return m_trackId; -} - -QString Mp3tunesLockerTrack::trackTitle() const -{ - return m_trackTitle; -} - -int Mp3tunesLockerTrack::trackNumber() const -{ - return m_trackNumber; -} - -float Mp3tunesLockerTrack::trackLength() const -{ - return m_trackLength; -} - -QString Mp3tunesLockerTrack::trackFileName() const -{ - return m_trackFileName; -} - -QString Mp3tunesLockerTrack::trackFileKey() const -{ - return m_trackFileKey; -} - -int Mp3tunesLockerTrack::trackFileSize() const -{ - return m_trackFileSize; -} - -QString Mp3tunesLockerTrack::downloadUrl() const -{ - return m_downloadUrl; -} - -QString Mp3tunesLockerTrack::playUrl() const -{ - return m_playUrl; -} - -int Mp3tunesLockerTrack::albumId() const -{ - return m_albumId; -} - -QString Mp3tunesLockerTrack::albumTitle() const -{ - return m_albumTitle; -} - -int Mp3tunesLockerTrack::albumYear() const -{ - return m_albumYear; -} - -QString Mp3tunesLockerTrack::artistName() const -{ - return m_artistName; -} - -int Mp3tunesLockerTrack::artistId() const -{ - return m_artistId; -} -//////////////////////////////////////////////////////////////////////// -//PLAYLIST -Mp3tunesLockerPlaylist::Mp3tunesLockerPlaylist( mp3tunes_locker_playlist_t *playlist ) -{ - m_playlist = ( mp3tunes_locker_playlist_t * ) malloc( sizeof( *playlist ) ); - memcpy( m_playlist, playlist, sizeof( *playlist ) ); - - m_playlist->playlistId = ( char * ) malloc( strlen( playlist->playlistId ) + 1 ); - strcpy( m_playlist->playlistId, playlist->playlistId ); - - m_playlist->playlistTitle = ( char * ) malloc( strlen( playlist->playlistTitle ) + 1 ); - strcpy( m_playlist->playlistTitle, playlist->playlistTitle ); - - m_playlist->title = ( char * ) malloc( strlen( playlist->title ) + 1 ); - strcpy( m_playlist->title, playlist->title ); - - m_playlist->fileName = ( char * ) malloc( strlen( playlist->fileName ) + 1 ); - strcpy( m_playlist->fileName, playlist->fileName ); -} -Mp3tunesLockerPlaylist::~Mp3tunesLockerPlaylist() -{ - free(m_playlist->fileName); - free(m_playlist->title); - free(m_playlist->playlistTitle); - free(m_playlist->playlistId); - free(m_playlist); -} - -QString Mp3tunesLockerPlaylist::playlistId() const -{ - return QString( m_playlist->playlistId ); -} - -QString Mp3tunesLockerPlaylist::playlistTitle() const{ - return QString( m_playlist->playlistTitle ); -} - -QString Mp3tunesLockerPlaylist::title() const -{ - return QString( m_playlist->title ); -} - -QString Mp3tunesLockerPlaylist::fileName() const -{ - return QString( m_playlist->fileName ); -} - -int Mp3tunesLockerPlaylist::fileCount() const -{ - return m_playlist->fileCount; -} - -int Mp3tunesLockerPlaylist::playlistSize() const -{ - return m_playlist->playlistSize; -} diff --git a/amarok/src/services/mp3tunes/Mp3tunesLockerMeta.h b/amarok/src/services/mp3tunes/Mp3tunesLockerMeta.h deleted file mode 100644 index 2c2fc68b..00000000 --- a/amarok/src/services/mp3tunes/Mp3tunesLockerMeta.h +++ /dev/null @@ -1,122 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Casey Link * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef MP3TUNESLOCKERMETA_H -#define MP3TUNESLOCKERMETA_H - -/** - * These are the c++ wrappers for the libmp3tunes meta types: - * artist, album, track, playlist - */ - -extern "C" { - // Get libmp3tunes declarations - #include "libmp3tunes/locker.h" -} - -#include -#include - -class Mp3tunesLockerPlaylist { - public: - Mp3tunesLockerPlaylist( mp3tunes_locker_playlist_t *playlist ); - ~Mp3tunesLockerPlaylist(); - - QString playlistId() const; - QString playlistTitle() const; - QString title() const; - QString fileName() const; - int fileCount() const; - int playlistSize() const; - private: - mp3tunes_locker_playlist_t *m_playlist; -}; - -class Mp3tunesLockerArtist { - public: - Mp3tunesLockerArtist( mp3tunes_locker_artist_t *artist ); - ~Mp3tunesLockerArtist(); - - int artistId() const; - QString artistName() const; - int artistSize() const; - int albumCount() const; - int trackCount() const; - private: - int m_artistId; - QString m_artistName; - int m_artistSize; - int m_albumCount; - int m_trackCount; -}; - -class Mp3tunesLockerAlbum { - public: - Mp3tunesLockerAlbum( mp3tunes_locker_album_t *album ); - ~Mp3tunesLockerAlbum(); - int albumId() const; - QString albumTitle() const; - int artistId() const; - QString artistName() const; - int trackCount() const; - int albumSize() const; - bool hasArt() const; - private: - int m_albumId; - QString m_albumTitle; - int m_artistId; - QString m_artistName; - int m_trackCount; - int m_albumSize; - bool m_hasArt; -}; - -class Mp3tunesLockerTrack { - public: - Mp3tunesLockerTrack( mp3tunes_locker_track_t *track = 0 ); - ~Mp3tunesLockerTrack(); - - int trackId() const; - QString trackTitle() const; - int trackNumber() const; - float trackLength() const; - QString trackFileName() const; - QString trackFileKey() const; - int trackFileSize() const; - QString downloadUrl() const; - QString playUrl() const; - int albumId() const; - QString albumTitle() const; - int albumYear() const; - QString artistName() const; - int artistId() const; - private: - int m_trackId; - QString m_trackTitle; - int m_trackNumber; - float m_trackLength; - QString m_trackFileName; - QString m_trackFileKey; - int m_trackFileSize; - QString m_downloadUrl; - QString m_playUrl; - int m_albumId; - QString m_albumTitle; - int m_albumYear; - QString m_artistName; - int m_artistId; -}; -#endif diff --git a/amarok/src/services/mp3tunes/Mp3tunesMeta.cpp b/amarok/src/services/mp3tunes/Mp3tunesMeta.cpp deleted file mode 100644 index 1d95ab7b..00000000 --- a/amarok/src/services/mp3tunes/Mp3tunesMeta.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * Copyright (c) 2007,2008 Casey Link * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "Mp3tunesMeta.h" - -#include "core/support/Amarok.h" - -#include -#include - -#include -using namespace Meta; - -Mp3TunesTrack::Mp3TunesTrack( const QString& title ) - : ServiceTrack( title ) - , m_filetype() -{ -} - -QString Mp3TunesTrack::type() const -{ - return "mp3"; -} - -void Mp3TunesTrack::setType( const QString &type ) -{ - m_filetype = type; -} - -QString Mp3TunesTrack::sourceName() { return "MP3tunes.com"; } -QString Mp3TunesTrack::sourceDescription() { return i18n( "Online music locker where you can safely store and access your music: http://mp3tunes.com" ); } -QPixmap Mp3TunesTrack::emblem() { return KStandardDirs::locate( "data", "amarok/images/emblem-mp3tunes.png" ); } - -//// Mp3TunesAlbum //// - -Mp3TunesAlbum::Mp3TunesAlbum( const QString &name ) - : ServiceAlbumWithCover( name ) -{ -} - -Mp3TunesAlbum::Mp3TunesAlbum(const QStringList & resultRow) - : ServiceAlbumWithCover( resultRow ) -{ -} - -Mp3TunesAlbum::~ Mp3TunesAlbum() -{ -} - -void Mp3TunesAlbum::setCoverUrl( const QString &coverURL ) -{ - m_coverURL = coverURL; -} - -QString Mp3TunesAlbum::coverUrl( ) const -{ - return m_coverURL; -} - diff --git a/amarok/src/services/mp3tunes/Mp3tunesMeta.h b/amarok/src/services/mp3tunes/Mp3tunesMeta.h deleted file mode 100644 index c8f9e976..00000000 --- a/amarok/src/services/mp3tunes/Mp3tunesMeta.h +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * Copyright (c) 2007,2008 Casey Link * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef MP3TUNESMETA_H -#define MP3TUNESMETA_H - -#include "../ServiceMetaBase.h" -#include "../ServiceAlbumCoverDownloader.h" - -#include - -#include -#include -#include -#include - - -namespace Meta -{ - -class Mp3TunesTrack : public ServiceTrack -{ - - public: - - Mp3TunesTrack( const QString& title ); - - virtual QString sourceName(); - virtual QString sourceDescription(); - virtual QPixmap emblem(); - virtual QString type() const; - void setType( const QString &type ); - private: - QString m_filetype; -}; - - -class Mp3TunesAlbum : public ServiceAlbumWithCover -{ -private: - QString m_coverURL; - -public: - Mp3TunesAlbum( const QString &name ); - Mp3TunesAlbum( const QStringList &resultRow ); - - ~Mp3TunesAlbum(); - - virtual QString downloadPrefix() const { return "mp3tunes"; } - - virtual void setCoverUrl( const QString &coverURL ); - virtual QString coverUrl() const; -}; - -} - -#endif diff --git a/amarok/src/services/mp3tunes/Mp3tunesService.cpp b/amarok/src/services/mp3tunes/Mp3tunesService.cpp deleted file mode 100644 index 4cea9a99..00000000 --- a/amarok/src/services/mp3tunes/Mp3tunesService.cpp +++ /dev/null @@ -1,381 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * Copyright (c) 2008 Casey Link * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "Mp3tunesService" - -#include "Mp3tunesService.h" - -#include "browsers/SingleCollectionTreeItemModel.h" -#include "core-impl/collections/support/CollectionManager.h" -#include "core/interfaces/Logger.h" -#include "core/support/Components.h" -#include "core/support/Debug.h" -#include "Mp3tunesConfig.h" - -#include -#include -#include - -#include - -AMAROK_EXPORT_SERVICE_PLUGIN( mp3tunes, Mp3tunesServiceFactory ) - -Mp3tunesServiceFactory::Mp3tunesServiceFactory( QObject *parent, const QVariantList &args ) - : ServiceFactory( parent, args ) -{ - KPluginInfo pluginInfo( "amarok_service_mp3tunes.desktop", "services" ); - pluginInfo.setConfig( config() ); - m_info = pluginInfo; -} - -void Mp3tunesServiceFactory::init() -{ - DEBUG_BLOCK - ServiceBase *service = createService(); - if( service ) - { - m_initialized = true; - emit newService( service ); - } -} - -ServiceBase* Mp3tunesServiceFactory::createService() -{ - Mp3tunesConfig config; - //The user activated the service, but didn't fill the email/password? Don't start it. - // if( config.email().isEmpty() || config.password().isEmpty() ) - // return 0; - ServiceBase* service = new Mp3tunesService( this, "MP3tunes.com", config.partnerToken(), config.email(), config.password(), config.harmonyEnabled() ); - return service; -} - -QString Mp3tunesServiceFactory::name() -{ - return "MP3tunes.com"; -} - -KConfigGroup Mp3tunesServiceFactory::config() -{ - return Amarok::config( "Service_Mp3tunes" ); -} - - -bool -Mp3tunesServiceFactory::possiblyContainsTrack(const KUrl & url) const -{ - QRegExp rx( "http://content.mp3tunes.com/storage/locker(?:get|play)/(.*)\\?(?:sid|partner_token)=.*" ) ; - int matches = rx.indexIn( url.url() ); - if( matches == -1 ) { - return false; // not a mp3tunes url - } - QStringList list = rx.capturedTexts(); - QString filekey = list.value( 1 ); // Because list[0] is the url itself. - if ( filekey.isEmpty() ) { - return false; - } - return true; // for now: if it's a mp3tunes url.. it's likely the track is in the locker -} - - -Mp3tunesService::Mp3tunesService( Mp3tunesServiceFactory* parent, const QString & name, const QString &token, const QString &email, const QString &password, bool harmonyEnabled ) - : ServiceBase( name, parent ) - , m_email( email ) - , m_password( password ) - , m_harmonyEnabled( harmonyEnabled ) - , m_partnerToken( token ) - , m_authenticated( false ) - , m_authenticationFailed( false ) - , m_sessionId ( QString() ) - , m_collection( 0 ) - , m_loginWorker( 0 ) - , m_harmony( 0 ) -{ - DEBUG_BLOCK - setShortDescription( i18n( "The MP3tunes Locker: Your Music Everywhere!" ) ); - setIcon( KIcon( "view-services-mp3tunes-amarok" ) ); - debug() << "Making new Locker Object"; - m_locker = new Mp3tunesLocker( "4895500420" ); - - debug() << "MP3tunes running automated authenticate. email: " << email << " pass: " << password; - authenticate( email, password ); - - if( m_harmonyEnabled ) { - enableHarmony(); - } - - polish(); -} - - -Mp3tunesService::~Mp3tunesService() -{ - - delete m_locker; -// delete m_daemon; - if( m_collection ) { - CollectionManager::instance()->removeTrackProvider( m_collection ); - delete m_collection; - } -} - - -void Mp3tunesService::polish() -{ - initTopPanel(); - initBottomPanel(); - - if ( !m_authenticated && !m_authenticationFailed ) - authenticate( m_email, m_password ); -} - -void Mp3tunesService::initTopPanel() -{ - m_menubar->clear(); - //Disable this menu bar until liblastfm is improved, and this feature can - //be implemented correctly. - /*QMenu * actionsMenu = m_menubar->addMenu( i18n( "AutoSync" ) ); - if( m_harmonyEnabled ) - { - QAction * action = new QAction( i18n( "Disable AutoSync" ), m_menubar ); - connect( action, SIGNAL(triggered(bool)), SLOT(disableHarmony()) ); - actionsMenu->addAction( action ); - } else { - QAction * action = new QAction( i18n( "Enable AutoSync" ), m_menubar ); - connect( action, SIGNAL(triggered(bool)), SLOT(enableHarmony()) ); - actionsMenu->addAction( action ); - } - - m_menubar->show();*/ -} - -void Mp3tunesService::initBottomPanel() -{ - m_bottomPanel->hide(); -} - -void Mp3tunesService::enableHarmony() - { - DEBUG_BLOCK - - if( !m_harmony ) - { - debug() << "Making new Daemon"; - Mp3tunesConfig config; - debug () << "Using identifier: " << config.identifier(); - - if( config.pin().isEmpty() ) - m_harmony = new Mp3tunesHarmonyHandler( config.identifier() ); //first time harmony login - else - m_harmony = new Mp3tunesHarmonyHandler( config.identifier(), //they're not harmony virgins - config.email(), - config.pin() ); -// qRegisterMetaType("Mp3tunesHarmonyDownload"); - - connect( m_harmony, SIGNAL(disconnected()), - this, SLOT(harmonyDisconnected())); - connect( m_harmony, SIGNAL(waitingForEmail(QString)), - this, SLOT(harmonyWaitingForEmail(QString)) ); - connect( m_harmony, SIGNAL(waitingForPin()), - this, SLOT(harmonyWaitingForPin()) ); - connect( m_harmony, SIGNAL(connected()), - this, SLOT(harmonyConnected()) ); - connect( m_harmony, SIGNAL(signalError(QString)), - this, SLOT(harmonyError(QString)) ); - connect( m_harmony, SIGNAL(downloadReady(QVariantMap)), - this, SLOT(harmonyDownloadReady(QVariantMap)) ); - connect( m_harmony, SIGNAL(downloadPending(QVariantMap)), - this, SLOT(harmonyDownloadPending(QVariantMap)) ); - - debug() << "starting harmony"; - m_harmony->startDaemon(); - if( m_harmony->daemonRunning() ) - { - debug() << "harmony started.. making connection"; - m_harmony->makeConnection(); - } - if( m_harmony->daemonConnected() ) - debug() << "harmony connected"; - else - debug() << "harmony failed to connected"; - - //Close your eyes. Cross your legs. Touch middle fingers to thumbs. Extend your arms. - //OOOooommmmm - } - - debug() << "Daemon running"; - m_harmonyEnabled = true; - Amarok::Components::logger()->shortMessage( i18n( "MP3tunes AutoSync Enabled" ) ); - polish(); - } - - void Mp3tunesService::disableHarmony() - { - DEBUG_BLOCK - if( !m_harmony ) - return; - - debug() << "stopping daemon"; - m_harmony->stopDaemon(); - m_harmony = 0; - m_harmonyEnabled = false; - polish(); - - Amarok::Components::logger()->shortMessage( i18n( "MP3tunes AutoSync Disabled" ) ); - } - -void Mp3tunesService::authenticate( const QString & uname, const QString & passwd ) -{ - DEBUG_BLOCK - if( m_loginWorker ) - return; - - if ( uname.isEmpty() || passwd.isEmpty() ) - return; - - m_loginWorker = new Mp3tunesLoginWorker( m_locker, uname, passwd); - //debug() << "Connecting finishedLogin -> authentication complete."; - - connect( m_loginWorker, SIGNAL(finishedLogin(QString)), this, - SLOT(authenticationComplete(QString)) ); - //debug() << "Connection complete. Enqueueing.."; - ThreadWeaver::Weaver::instance()->enqueue( m_loginWorker ); - //debug() << "LoginWorker queue"; - Amarok::Components::logger()->shortMessage( i18n( "Authenticating" ) ); - -} - - -void Mp3tunesService::authenticationComplete( const QString & sessionId ) -{ - DEBUG_BLOCK - m_loginWorker = 0; - debug() << "Authentication reply: " << sessionId; - if ( sessionId.isEmpty() ) - { - QString error = i18n("MP3tunes failed to Authenticate."); - if ( !m_locker->errorMessage().isEmpty() ) - { - error = m_locker->errorMessage(); // Not sure how to i18n this - } - Amarok::Components::logger()->longMessage( error ); - - setServiceReady( false ); - m_authenticationFailed = true; - } - else - { - m_sessionId = sessionId; - m_authenticated = true; - - m_collection = new Collections::Mp3tunesServiceCollection( this, m_sessionId, m_locker ); - CollectionManager::instance()->addTrackProvider( m_collection ); - QList levels; - levels << CategoryId::Artist << CategoryId::Album; - setModel( new SingleCollectionTreeItemModel( m_collection, levels ) ); - - setServiceReady( true ); - } - polish(); -} - -void Mp3tunesService::harmonyDisconnected() -{ - DEBUG_BLOCK - debug() << "Harmony Disconnected!"; - Amarok::Components::logger()->shortMessage( i18n( "MP3tunes Harmony: Disconnected" ) ); -} - -void Mp3tunesService::harmonyWaitingForEmail( const QString &pin ) -{ - DEBUG_BLOCK - debug() << "Waiting for user to input PIN: " << pin; - Amarok::Components::logger()->shortMessage( i18n( "MP3tunes Harmony: Waiting for PIN Input" ) ); - KMessageBox::information( this, - "Please go to mp3tunes.com/pin and enter the following pin.\n\tPIN: " + pin, - "MP3tunes Harmony", - QString(), - KMessageBox::AllowLink ); -} - -void Mp3tunesService::harmonyWaitingForPin() -{ - DEBUG_BLOCK - QString pin = m_harmony->pin(); - debug() << "Waiting for user to input PIN: " << pin; - Amarok::Components::logger()->shortMessage( i18n( "MP3tunes Harmony: Waiting for PIN Input" ) ); - KMessageBox::information( this, - "Please go to mp3tunes.com/pin and enter the following pin.\n\tPIN: " + pin, - "MP3tunes Harmony", - QString(), - KMessageBox::AllowLink ); -} - -void Mp3tunesService::harmonyConnected() -{ - DEBUG_BLOCK - debug() << "Harmony Connected!"; - Amarok::Components::logger()->shortMessage( i18n( "MP3tunes Harmony: Successfully Connected" ) ); - /* at this point since the user has input the pin, we will save the info - for later authentication*/ - Mp3tunesConfig config; - debug() << "Setting Config email: " << m_harmony->email() << " pin: " << m_harmony->pin(); - config.setHarmonyEmail( m_harmony->email() ); - config.setPin( m_harmony->pin() ); - config.save(); - -} - -void Mp3tunesService::harmonyError( const QString &error ) -{ - DEBUG_BLOCK - debug() << "Harmony Error: " << error; - Amarok::Components::logger()->longMessage( i18n( "MP3tunes Harmony Error\n%1", error ) ); -} - -void Mp3tunesService::harmonyDownloadReady( const QVariantMap &download ) -{ - DEBUG_BLOCK - debug() << "Got message about ready: " << download["trackTitle"].toString() << " by " << download["artistName"].toString() << " on " << download["albumTitle"].toString(); - foreach( Collections::Collection *coll, CollectionManager::instance()->collections().keys() ) { - if( coll && coll->isWritable() && m_collection ) - { - debug() << "got collection" << coll->prettyName(); - if ( coll->collectionId() == "localCollection") - { //TODO Allow user to choose which collection to sync down to. - debug() << "got local collection"; - Collections::CollectionLocation *dest = coll->location(); - Collections::CollectionLocation *source = m_collection->location(); - if( !m_collection->possiblyContainsTrack( download["url"].toString() ) ) - return; //TODO some sort of error handling - Meta::TrackPtr track( m_collection->trackForUrl( download["url"].toString() ) ); - source->prepareCopy( track, dest ); - break; - } - - } - } - -} - -void Mp3tunesService::harmonyDownloadPending( const QVariantMap &download ) -{ - DEBUG_BLOCK - debug() << "Got message about ready: " << download["trackTitle"].toString() << " by " << download["artistName"].toString() << " on " << download["albumTitle"].toString(); -} - -#include "moc_Mp3tunesService.cpp" - diff --git a/amarok/src/services/mp3tunes/Mp3tunesService.h b/amarok/src/services/mp3tunes/Mp3tunesService.h deleted file mode 100644 index 3fadd3eb..00000000 --- a/amarok/src/services/mp3tunes/Mp3tunesService.h +++ /dev/null @@ -1,134 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * Copyright (c) 2008 Casey Link * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef MP3TUNESSERVICE_H -#define MP3TUNESSERVICE_H - -#include "../ServiceBase.h" -#include "Mp3tunesServiceCollection.h" -#include "Mp3tunesLocker.h" -#include "Mp3tunesWorkers.h" -#include "harmonydaemon/Mp3tunesHarmonyDownload.h" -#include "Mp3tunesHarmonyHandler.h" -#include - -class Mp3tunesServiceFactory: public ServiceFactory -{ - Q_OBJECT - - public: - Mp3tunesServiceFactory( QObject *parent, const QVariantList &args ); - virtual ~Mp3tunesServiceFactory() {} - - virtual bool possiblyContainsTrack( const KUrl &url ) const; - - virtual void init(); - virtual QString name(); - virtual KConfigGroup config(); - - private: - ServiceBase* createService(); -}; - - -/** - A service for displaying, previewing and downloading music from Mp3tunes.com - @author -*/ -class Mp3tunesService : public ServiceBase -{ - -Q_OBJECT - -public: - explicit Mp3tunesService( Mp3tunesServiceFactory* parent, - const QString &name, - const QString &partnerToken, - const QString &email = QString(), - const QString &password = QString(), - bool harmonyEnabled = false ); - - ~Mp3tunesService(); - - /** - * Helper function to redraw the service's ui elements - */ - void polish(); - - virtual Collections::Collection * collection() { return m_collection; } - -private slots: - /** - * Enables harmony - */ - void enableHarmony(); - - /** - * Disables harmony - */ - void disableHarmony(); - - /** - * Logs the user into the locker, prompts them for a user/pass if not supplied - */ - void authenticate( const QString & uname = "", const QString & passwd = "" ); - - /** - * Handles authentication reply. - */ - void authenticationComplete( const QString & sessionId ); - - /** - * the daemon received the PIN. now that pin has to be presented to the user, - * so he/she (comments must be gender neutral) can add it to his/her mp3tunes - * account. - */ - void harmonyWaitingForEmail( const QString &pin ); - void harmonyWaitingForPin(); - void harmonyConnected(); - void harmonyDisconnected(); - void harmonyError( const QString &error ); - void harmonyDownloadReady( const QVariantMap &download ); - void harmonyDownloadPending( const QVariantMap &download ); - -private: - /** - * Helper function that draws the menu bar above the tree view - */ - void initTopPanel(); - - /** - * Helper function that draws the ui elements below the tree view - */ - void initBottomPanel(); - - QString m_email; - QString m_password; - bool m_harmonyEnabled; // if the user has enabled harmony - QString m_partnerToken; - - bool m_authenticated; // true if mp3tunes has authenticated successfully - bool m_authenticationFailed; - QString m_sessionId; // the mp3tunes sid - - Collections::Mp3tunesServiceCollection * m_collection; - Mp3tunesLoginWorker * m_loginWorker; // used to see if logging in has completed - Mp3tunesLocker * m_locker; // the actual locker - Mp3tunesHarmonyHandler * m_harmony; -}; - -#endif diff --git a/amarok/src/services/mp3tunes/Mp3tunesServiceCollection.cpp b/amarok/src/services/mp3tunes/Mp3tunesServiceCollection.cpp deleted file mode 100644 index 146293dd..00000000 --- a/amarok/src/services/mp3tunes/Mp3tunesServiceCollection.cpp +++ /dev/null @@ -1,164 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * Copyright (c) 2008 Casey Link * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "Mp3tunesServiceCollection.h" - -#include "Mp3tunesLockerMeta.h" -#include "Mp3tunesMeta.h" -#include "Mp3tunesServiceCollectionLocation.h" -#include "Mp3tunesServiceQueryMaker.h" -#include "Mp3tunesWorkers.h" -#include "core/support/Debug.h" - -#include - -#include - -using namespace Collections; - -Mp3tunesServiceCollection::Mp3tunesServiceCollection( ServiceBase * service, const QString -&sessionId, Mp3tunesLocker * locker ) - : ServiceCollection( service, "Mp3tunesCollection", "Mp3tunesCollection" ) - , m_sessionId( sessionId ) - , m_locker( locker ) -{ -} - - -Mp3tunesServiceCollection::~Mp3tunesServiceCollection() -{ -} - -QueryMaker * Mp3tunesServiceCollection::queryMaker() -{ - return new Mp3tunesServiceQueryMaker( m_locker, m_sessionId, this ); -} - -QString Mp3tunesServiceCollection::collectionId() const -{ - return QLatin1String( "MP3tunesLocker" ); -} - -QString Mp3tunesServiceCollection::prettyName() const -{ - return i18n( "MP3tunes Locker" ); -} - -bool -Mp3tunesServiceCollection::possiblyContainsTrack(const KUrl & url) const -{ - QRegExp rx( "http://content.mp3tunes.com/storage/locker(?:get|play)/(.*)\\?(?:sid|partner_token)=.*" ) ; - int matches = rx.indexIn( url.url() ); - if( matches == -1 ) { - return false; // not a mp3tunes url - } - return true; // for now: if it's a mp3tunes url.. it's likely the track is in the locker -} - -Meta::TrackPtr -Mp3tunesServiceCollection::trackForUrl( const KUrl & url ) -{ - DEBUG_BLOCK - if( !m_locker->authenticated() ) - m_locker->login(); - QRegExp rx( "http://content.mp3tunes.com/storage/locker(?:get|play)/(.*)\\?(?:sid|partner_token)=.*" ) ; - rx.indexIn( url.url() ); - QStringList list = rx.capturedTexts(); - QString filekey = list[1]; // Because list[0] is the url itself. - if ( filekey.isEmpty() ) { - debug() << "not a track"; - return Meta::TrackPtr(); // It's not an mp3tunes track - } - debug() << "filekey: " << filekey; - - Meta::Mp3TunesTrack * serviceTrack = new Meta::Mp3TunesTrack( QString() ); - serviceTrack->setUidUrl( url.url() ); - - Mp3tunesTrackFromFileKeyFetcher* trackFetcher = new Mp3tunesTrackFromFileKeyFetcher( m_locker, filekey ); - m_tracksFetching[filekey] = serviceTrack; - connect( trackFetcher, SIGNAL(trackFetched(Mp3tunesLockerTrack&)), this, SLOT(trackForUrlComplete(Mp3tunesLockerTrack&)) ); - //debug() << "Connection complete. Enqueueing.."; - ThreadWeaver::Weaver::instance()->enqueue( trackFetcher ); - //debug() << "m_trackFetcher queue"; - - return Meta::TrackPtr( serviceTrack ); -} - -void Mp3tunesServiceCollection::trackForUrlComplete( Mp3tunesLockerTrack &track ) -{ - DEBUG_BLOCK - //Lets get this thing - debug() << "got track: " << track.trackTitle(); - QString filekey = track.trackFileKey(); - if( !m_tracksFetching.contains( filekey ) ) { - debug() << "track not found in QMap"; - return; - } - Meta::Mp3TunesTrack * serviceTrack = m_tracksFetching.take( filekey ); - - //Building a Meta::Track - QString title = track.trackTitle().isEmpty() ? "Unknown" : track.trackTitle(); - serviceTrack->setTitle( title ); - serviceTrack->setId( track.trackId() ); - serviceTrack->setUidUrl( track.playUrl() ); //was: setUrl - serviceTrack->setDownloadableUrl( track.downloadUrl() ); - serviceTrack->setLength( track.trackLength() ); - serviceTrack->setTrackNumber( track.trackNumber() ); - serviceTrack->setYear( track.albumYear() ); - - //Building a Meta::Album - title = track.albumTitle().isEmpty() ? "Unknown" : track.albumTitle(); - Meta::Mp3TunesAlbum * serviceAlbum = new Meta::Mp3TunesAlbum( title ); - QString albumIdStr = QString::number( track.albumId() ); - serviceAlbum->setId( track.albumId() ); - - QString coverUrl = "http://content.mp3tunes.com/storage/albumartget/?alternative=1&partner_token=&sid="; - - coverUrl.replace( "", m_locker->sessionId() ); - coverUrl.replace( "", m_locker->partnerToken() ); - coverUrl.replace( "", albumIdStr ); - - serviceAlbum->setCoverUrl(coverUrl); - Meta::AlbumPtr albumPtr( serviceAlbum ); - serviceTrack->setAlbumPtr( albumPtr ); - - // Building a Meta::Artist - QString name = track.artistName().isEmpty() ? "Unknown" : track.artistName(); - Meta::ServiceArtist * serviceArtist = new Meta::ServiceArtist( name ); - serviceArtist->setId( track.artistId() ); - Meta::ArtistPtr artistPtr( serviceArtist ); - - serviceTrack->setArtist( artistPtr ); - serviceAlbum->setArtistName( name ); - serviceAlbum->setAlbumArtist( artistPtr ); -// serviceTrack->update( Meta::TrackPtr( serviceTrack ) ); -} - -Mp3tunesLocker* Mp3tunesServiceCollection::locker() const -{ - return m_locker; -} - -CollectionLocation* -Mp3tunesServiceCollection::location() -{ - return new Mp3tunesServiceCollectionLocation( this ); -} - -#include "moc_Mp3tunesServiceCollection.cpp" - - diff --git a/amarok/src/services/mp3tunes/Mp3tunesServiceCollection.h b/amarok/src/services/mp3tunes/Mp3tunesServiceCollection.h deleted file mode 100644 index f4abb9f5..00000000 --- a/amarok/src/services/mp3tunes/Mp3tunesServiceCollection.h +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * Copyright (c) 2008 Casey Link * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef MP3TUNESSERVICECOLLECTION_H -#define MP3TUNESSERVICECOLLECTION_H - -#include -#include "Mp3tunesLockerMeta.h" -#include "Mp3tunesMeta.h" -#include "Mp3tunesLocker.h" - -#include - -namespace Collections { - -class Mp3tunesServiceCollection : public ServiceCollection -{ - Q_OBJECT - -public: - Mp3tunesServiceCollection( ServiceBase * service, const QString &sessionId, - Mp3tunesLocker * locker ); - - virtual ~Mp3tunesServiceCollection(); - - virtual QueryMaker* queryMaker(); - - virtual QString collectionId() const; - virtual QString prettyName() const; - virtual CollectionLocation* location(); - Mp3tunesLocker* locker() const; - - virtual Meta::TrackPtr trackForUrl( const KUrl &url ); - virtual bool possiblyContainsTrack( const KUrl &url ) const; - -private slots: - /** - * Handles trackForUrl complete. - */ - void trackForUrlComplete( Mp3tunesLockerTrack &track ); - -private: - QString m_sessionId; - Mp3tunesLocker * m_locker; - QMap m_tracksFetching; // a list of tracks that are being fetched via trackForUrl and their associated threadweaver jobs -}; - -} //namespace Collections - -#endif diff --git a/amarok/src/services/mp3tunes/Mp3tunesServiceCollectionLocation.cpp b/amarok/src/services/mp3tunes/Mp3tunesServiceCollectionLocation.cpp deleted file mode 100644 index 6aaa66d2..00000000 --- a/amarok/src/services/mp3tunes/Mp3tunesServiceCollectionLocation.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Casey Link * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "Mp3tunesServiceCollectionLocation.h" - -#include "Mp3tunesWorkers.h" -#include "core/interfaces/Logger.h" -#include "core/support/Components.h" - -#include -#include - -#include "core/support/Debug.h" - -using namespace Collections; - -Mp3tunesServiceCollectionLocation::Mp3tunesServiceCollectionLocation( Mp3tunesServiceCollection *parentCollection ) - : ServiceCollectionLocation( parentCollection ) - , m_collection( parentCollection ) -{ - DEBUG_BLOCK -} - -Mp3tunesServiceCollectionLocation::~Mp3tunesServiceCollectionLocation() -{ -} - -QString Mp3tunesServiceCollectionLocation::prettyLocation() const -{ - return i18n( "MP3tunes Locker" ); -} - -bool Mp3tunesServiceCollectionLocation::isWritable() const -{ - return true; -} - -void Mp3tunesServiceCollectionLocation::copyUrlsToCollection ( - const QMap &sources, - const Transcoding::Configuration &configuration ) -{ - DEBUG_BLOCK - Q_UNUSED( configuration ); // TODO: we might support transcoding here - - QStringList urls; - QString error; - debug() << "sources has " << sources.count(); - foreach( const Meta::TrackPtr &track, sources.keys() ) - { - debug() << "copying " << sources[ track ] << " to mp3tunes locker"; - debug() << "file is at " << sources[ track ].pathOrUrl(); - - QString supported_types = "mp3 mp4 m4a m4b m4p aac wma ogg"; - - if( supported_types.contains( track->type() ) ) - { - - debug() << "Added " << sources[ track ].pathOrUrl() << " to queue."; - urls.push_back( sources[ track ].pathOrUrl() ); - - } - else - { - error = i18n( "Only the following types of tracks can be uploaded to MP3tunes: mp3, mp4, m4a, m4p, aac, wma, and ogg. " ); - debug() << "File type not supprted " << track->type(); - } - } - if( !error.isEmpty() ) - Amarok::Components::logger()->longMessage( error ); - Mp3tunesSimpleUploader * uploadWorker = new Mp3tunesSimpleUploader( m_collection->locker(), urls ); - connect( uploadWorker, SIGNAL(uploadComplete()), this, SLOT(slotCopyOperationFinished()) ); - ThreadWeaver::Weaver::instance()->enqueue( uploadWorker ); -} diff --git a/amarok/src/services/mp3tunes/Mp3tunesServiceCollectionLocation.h b/amarok/src/services/mp3tunes/Mp3tunesServiceCollectionLocation.h deleted file mode 100644 index 2b06cb4c..00000000 --- a/amarok/src/services/mp3tunes/Mp3tunesServiceCollectionLocation.h +++ /dev/null @@ -1,47 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Casey Link * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef MP3TUNESSERVICECOLLECTIONLOCATION_H -#define MP3TUNESSERVICECOLLECTIONLOCATION_H - -#include "ServiceCollectionLocation.h" -#include "Mp3tunesServiceCollection.h" - -#include -#include -#include - -namespace Collections { - -class Mp3tunesServiceCollectionLocation : public ServiceCollectionLocation -{ - Q_OBJECT - public: - Mp3tunesServiceCollectionLocation( Mp3tunesServiceCollection *parentCollection ); - virtual ~Mp3tunesServiceCollectionLocation(); - - virtual QString prettyLocation() const; - virtual bool isWritable() const; - virtual void copyUrlsToCollection( const QMap &sources, - const Transcoding::Configuration &configuration ); - - private: - Mp3tunesServiceCollection *m_collection; -}; - -} //namespace Collections - -#endif diff --git a/amarok/src/services/mp3tunes/Mp3tunesServiceQueryMaker.cpp b/amarok/src/services/mp3tunes/Mp3tunesServiceQueryMaker.cpp deleted file mode 100644 index 2d386f49..00000000 --- a/amarok/src/services/mp3tunes/Mp3tunesServiceQueryMaker.cpp +++ /dev/null @@ -1,465 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * Copyright (c) 2007 Adam Pigg * - * Copyright (c) 2007,2008 Casey Link * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "Mp3tunesServiceQueryMaker.h" - -#include "core/support/Amarok.h" -#include "core/support/Debug.h" -#include "Mp3tunesMeta.h" -#include "Mp3tunesWorkers.h" -#include "core-impl/collections/support/MemoryMatcher.h" - -#include -#include - -#include - -using namespace Collections; - -class Mp3tunesServiceQueryMaker::Private { -public: - enum QueryType { NONE, TRACK, ARTIST, ALBUM, COMPOSER, YEAR, GENRE, CUSTOM }; - QueryType type; - int maxsize; -}; - - -Mp3tunesServiceQueryMaker::Mp3tunesServiceQueryMaker( Mp3tunesServiceCollection * collection, const QString &sessionId ) - : DynamicServiceQueryMaker() - , m_storedTransferJob( 0 ) - , d( new Private ) - -{ - DEBUG_BLOCK - m_collection = collection; - m_sessionId = sessionId; - - d->type = Private::NONE; - d->maxsize = -1; -} - -Mp3tunesServiceQueryMaker::Mp3tunesServiceQueryMaker( Mp3tunesLocker * locker, const QString &sessionId, Mp3tunesServiceCollection * collection ) - : DynamicServiceQueryMaker() - , m_storedTransferJob( 0 ) - , d( new Private ) -{ - DEBUG_BLOCK - m_collection = collection; - m_sessionId = sessionId; - m_locker = locker; - - d->type = Private::NONE; - d->maxsize = -1; -} - -Mp3tunesServiceQueryMaker::~Mp3tunesServiceQueryMaker() -{ - delete d; -} - -void Mp3tunesServiceQueryMaker::run() -{ - DEBUG_BLOCK - if ( m_storedTransferJob != 0 ) - return; - - m_collection->acquireReadLock(); - //naive implementation, fix this - //note: we are not handling filtering yet - - if ( d->type == Private::NONE ) - //TODO error handling - return; - if ( d->type == Private::ARTIST ) - fetchArtists(); - else if ( d->type == Private::ALBUM ) - fetchAlbums(); - else if ( d->type == Private::TRACK ) - fetchTracks(); - - m_collection->releaseLock(); -} - - -void Mp3tunesServiceQueryMaker::abortQuery() -{} - -QueryMaker* -Mp3tunesServiceQueryMaker::setQueryType( QueryType type ) -{ - switch( type ) { - case QueryMaker::Artist: - case QueryMaker::AlbumArtist: - { - DEBUG_BLOCK - d->type = Private::ARTIST; - return this; - } - - case QueryMaker::Album: - { - DEBUG_BLOCK - d->type = Private::ALBUM; - return this; - } - - case QueryMaker::Track: - { - DEBUG_BLOCK - d->type = Private::TRACK; - return this; - } - - case QueryMaker::Genre: - case QueryMaker::Composer: - case QueryMaker::Year: - case QueryMaker::Custom: - case QueryMaker::None: - default: - //TODO: Implement. - return this; - } -} - - - -QueryMaker * Mp3tunesServiceQueryMaker::addMatch( const Meta::ArtistPtr & artist ) -{ - DEBUG_BLOCK - if ( m_parentAlbumId.isEmpty() ) { - const Meta::ServiceArtist * serviceArtist = static_cast< const Meta::ServiceArtist * >( artist.data() ); - m_parentArtistId = QString::number( serviceArtist->id() ); - debug() << "artist parent id set to: " << m_parentArtistId; - } - - return this; -} - -QueryMaker * Mp3tunesServiceQueryMaker::addMatch(const Meta::AlbumPtr & album) -{ - DEBUG_BLOCK - const Meta::ServiceAlbum * serviceAlbum = static_cast< const Meta::ServiceAlbum * >( album.data() ); - m_parentAlbumId = QString::number( serviceAlbum->id() ); - debug() << "album parent id set to: " << m_parentAlbumId; - m_parentArtistId.clear(); - - return this; -} - -void Mp3tunesServiceQueryMaker::handleResult() -{ - DEBUG_BLOCK -} - -void Mp3tunesServiceQueryMaker::handleResult( const Meta::ArtistList & artists ) -{ - DEBUG_BLOCK - - if ( d->maxsize >= 0 && artists.count() > d->maxsize ) { - emit newResultReady( artists.mid( 0, d->maxsize ) ); - } else { - emit newResultReady( artists ); - } -} - -void Mp3tunesServiceQueryMaker::handleResult( const Meta::AlbumList &albums ) -{ - DEBUG_BLOCK - - if ( d->maxsize >= 0 && albums.count() > d->maxsize ) { - emit newResultReady( albums.mid( 0, d->maxsize ) ); - } else { - emit newResultReady( albums ); - } -} - -void Mp3tunesServiceQueryMaker::handleResult(const Meta::TrackList & tracks) -{ - DEBUG_BLOCK - - if ( d->maxsize >= 0 && tracks.count() > d->maxsize ) { - emit newResultReady( tracks.mid( 0, d->maxsize ) ); - } else { - emit newResultReady( tracks ); - } -} - - -void Mp3tunesServiceQueryMaker::fetchArtists() -{ - DEBUG_BLOCK - if ( !m_artistFilter.isEmpty() ) - { - debug() << "Artist Filtering"; - Mp3tunesSearchMonkey * searchMonkey = new Mp3tunesSearchMonkey( m_locker, m_artistFilter, Mp3tunesSearchResult::ArtistQuery ); - connect( searchMonkey, SIGNAL(searchComplete(QList)), this, SLOT(artistDownloadComplete(QList)) ); - ThreadWeaver::Weaver::instance()->enqueue( searchMonkey ); //Go! - } else if( m_locker->sessionValid() ) - { - debug() << "Artist Fetching"; - Mp3tunesArtistFetcher * artistFetcher = new Mp3tunesArtistFetcher( m_locker ); - connect( artistFetcher, SIGNAL(artistsFetched(QList)), this, SLOT(artistDownloadComplete(QList)) ); - ThreadWeaver::Weaver::instance()->enqueue( artistFetcher ); - } -} - -void Mp3tunesServiceQueryMaker::fetchAlbums() -{ - DEBUG_BLOCK - - Meta::AlbumList albums; - - debug() << "Fetching Albums for parentArtist id: " << m_parentArtistId; - - if ( !m_parentArtistId.isEmpty() ) { - albums = matchAlbums( m_collection, m_collection->artistById( m_parentArtistId.toInt() ) ); - } else { - debug() << "parent id empty"; - return; - } - - if ( albums.count() > 0 ) { - handleResult( albums ); - } else if ( m_locker->sessionValid() ) { - Mp3tunesAlbumWithArtistIdFetcher * albumFetcher = new Mp3tunesAlbumWithArtistIdFetcher( m_locker, m_parentArtistId.toInt() ); - connect( albumFetcher, SIGNAL(albumsFetched(QList)), this, SLOT(albumDownloadComplete(QList)) ); - - ThreadWeaver::Weaver::instance()->enqueue( albumFetcher ); - } else { - debug() << "Session Invalid"; - } -} - -void Mp3tunesServiceQueryMaker::fetchTracks() -{ - DEBUG_BLOCK - - Meta::AlbumList albums; - Meta::TrackList tracks; - - debug() << "album parent id: " << m_parentAlbumId; - debug() << "artist parent id: " << m_parentArtistId; - - if ( !m_parentArtistId.isEmpty() ) { - ArtistMatcher artistMatcher( m_collection->artistById( m_parentArtistId.toInt() ) ); - tracks = artistMatcher.match( m_collection->trackMap().values() ); - } else if ( !m_parentAlbumId.isEmpty() ) { - AlbumMatcher albumMatcher( m_collection->albumById( m_parentAlbumId.toInt() ) ); - tracks = albumMatcher.match( m_collection->trackMap().values() ); - } else { - debug() << "parent id empty"; - return; - } - - if ( tracks.count() > 0 ) { - debug() << tracks.count() << " Tracks selected"; - handleResult( tracks ); - emit queryDone(); - } else if ( m_locker->sessionValid() ) { - if( !m_parentArtistId.isEmpty() ) { - debug() << "Creating track w/ artist id Fetch Worker"; - Mp3tunesTrackWithArtistIdFetcher * trackFetcher = new Mp3tunesTrackWithArtistIdFetcher( m_locker, m_parentArtistId.toInt() ); - connect( trackFetcher, SIGNAL(tracksFetched(QList)), this, SLOT(trackDownloadComplete(QList)) ); - ThreadWeaver::Weaver::instance()->enqueue( trackFetcher ); //Go! - } else if ( !m_parentAlbumId.isEmpty() ) { - debug() << "Creating track w/ album id Fetch Worker"; - Mp3tunesTrackWithAlbumIdFetcher * trackFetcher = new Mp3tunesTrackWithAlbumIdFetcher( m_locker, m_parentAlbumId.toInt() ); - connect( trackFetcher, SIGNAL(tracksFetched(QList)), this, SLOT(trackDownloadComplete(QList)) ); - ThreadWeaver::Weaver::instance()->enqueue( trackFetcher ); //Go! - } - } else { - debug() << "Session Invalid"; - return; - } -} - -void Mp3tunesServiceQueryMaker::artistDownloadComplete( QList artistList ) -{ - DEBUG_BLOCK - - Meta::ArtistList artists; - - debug() << "Received artists"; - foreach(const Mp3tunesLockerArtist &artist, artistList) { - Meta::ServiceArtist * serviceArtist = new Meta::ServiceArtist( artist.artistName() ); - - //debug() << "Adding artist: " << artist.artistName(); - - serviceArtist->setId( artist.artistId() ); - - Meta::ArtistPtr artistPtr( serviceArtist ); - - artists.push_back( artistPtr ); - - m_collection->acquireWriteLock(); - m_collection->addArtist( artistPtr ); - m_collection->releaseLock(); - - } - - handleResult( artists ); - emit queryDone(); - -} - -void Mp3tunesServiceQueryMaker::albumDownloadComplete( QList albumsList ) -{ - DEBUG_BLOCK - - debug() << "Received albums"; - - Meta::AlbumList albums; - foreach(const Mp3tunesLockerAlbum &album, albumsList) { - - QString title = album.albumTitle(); - if ( title.contains("* PlayMix") ) continue; - if ( title.isEmpty() ) title = "Unknown"; - - QString albumIdStr = QString::number( album.albumId() ); - int albumId = album.albumId(); - - bool hasArt = album.hasArt(); - - Meta::Mp3TunesAlbum * serviceAlbum = new Meta::Mp3TunesAlbum( title ); - - if ( hasArt ) - { - - QString coverUrl = "http://content.mp3tunes.com/storage/albumartget/?alternative=1&partner_token=&sid="; - - coverUrl.replace( "", m_locker->sessionId() ); - coverUrl.replace( "", m_locker->partnerToken() ); - coverUrl.replace( "", albumIdStr ); - - serviceAlbum->setCoverUrl(coverUrl); - } - - Meta::AlbumPtr albumPtr( serviceAlbum ); - - //debug() << "Adding album: " << title; - - serviceAlbum->setId( albumId ); - m_collection->acquireWriteLock(); - m_collection->addAlbum( albumPtr ); - m_collection->releaseLock(); - - Meta::ArtistPtr artistPtr = m_collection->artistById( album.artistId() ); - if ( artistPtr.data() != 0 ) - { - //debug() << "Found parent artist"; - serviceAlbum->setAlbumArtist( artistPtr ); - } - - albums.push_back( albumPtr ); - - } - - handleResult( albums ); - emit queryDone(); - -} - -void Mp3tunesServiceQueryMaker::trackDownloadComplete( QList tracksList ) -{ - DEBUG_BLOCK - //debug() << "Received Tracks"; - - Meta::TrackList tracks; - - //so lets figure out what we got here: - - foreach(const Mp3tunesLockerTrack &track, tracksList) - { - - QString title = track.trackTitle(); - if ( title.isEmpty() ) title = "Unknown"; - - Meta::Mp3TunesTrack * serviceTrack = new Meta::Mp3TunesTrack( title ); - Meta::TrackPtr trackPtr( serviceTrack ); - - // debug() << "Adding track: " << title; - - serviceTrack->setId( track.trackId() ); - - serviceTrack->setUidUrl( track.playUrl() ); - serviceTrack->setDownloadableUrl( track.downloadUrl() ); - - serviceTrack->setLength( track.trackLength() ); - - serviceTrack->setTrackNumber( track.trackNumber() ); - - serviceTrack->setYear( track.albumYear() ); - - debug() << "setting type: " << Amarok::extension( track.trackFileName() ); - serviceTrack->setType( Amarok::extension( track.trackFileName() ) ); - //debug() << "set type"; - m_collection->acquireWriteLock(); - //debug() << "adding track"; - m_collection->addTrack( trackPtr ); - //debug() << "added tracktrack"; - m_collection->releaseLock(); - QString albumId = QString::number( track.albumId() ); - QString artistId = QString::number( track.artistId() ); - - Meta::ArtistPtr artistPtr = m_collection->artistById( artistId.toInt() ); - if ( artistPtr.data() != 0 ) { - debug() << "Found parent artist"; - Meta::ServiceArtist *artist = dynamic_cast< Meta::ServiceArtist * > ( artistPtr.data() ); - serviceTrack->setArtist( artistPtr ); - artist->addTrack( trackPtr ); - } - - Meta::AlbumPtr albumPtr = m_collection->albumById( albumId.toInt() ); - if ( albumPtr.data() != 0 ) { - debug() << "Found parent album"; - Meta::ServiceAlbum *album = dynamic_cast< Meta::ServiceAlbum * > ( albumPtr.data() ); - serviceTrack->setAlbumPtr( albumPtr ); - album->addTrack( trackPtr ); - } - - tracks.push_back( trackPtr ); - } - - //ThreadWeaver::Weaver::instance()->dequeue( job ); - //job->deleteLater(); - - handleResult( tracks ); - emit queryDone(); - -} - -QueryMaker * Mp3tunesServiceQueryMaker::addFilter(qint64 value, const QString & filter, bool /*matchBegin*/, bool /*matchEnd*/) -{ - DEBUG_BLOCK - //debug() << "value: " << value; - //for now, only accept artist filters - if ( value == Meta::valArtist ) { - //debug() << "Filter: " << filter; - m_artistFilter = filter; - } - return this; -} - -int Mp3tunesServiceQueryMaker::validFilterMask() -{ - //we only supprt artist filters for now... - return ArtistFilter; -} - -#include "moc_Mp3tunesServiceQueryMaker.cpp" - diff --git a/amarok/src/services/mp3tunes/Mp3tunesServiceQueryMaker.h b/amarok/src/services/mp3tunes/Mp3tunesServiceQueryMaker.h deleted file mode 100644 index a45d3b9d..00000000 --- a/amarok/src/services/mp3tunes/Mp3tunesServiceQueryMaker.h +++ /dev/null @@ -1,105 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * Copyright (c) 2008 Casey Link * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef MP3TUNESSERVICEQUERYMAKER_H -#define MP3TUNESSERVICEQUERYMAKER_H - -#include "DynamicServiceQueryMaker.h" - -//#include "Mp3TunesMeta.h" -#include "Mp3tunesLocker.h" -#include "Mp3tunesServiceCollection.h" -#include "Mp3tunesWorkers.h" - -#include - -namespace ThreadWeaver -{ - class Job; -} - -namespace Collections { - -/** -A query maker for fetching external data - - @author -*/ -class Mp3tunesServiceQueryMaker : public DynamicServiceQueryMaker -{ -Q_OBJECT -public: - Mp3tunesServiceQueryMaker( Mp3tunesServiceCollection * collection, const QString &sessionId ); - Mp3tunesServiceQueryMaker( Mp3tunesLocker * locker, const QString &sessionId, Mp3tunesServiceCollection * collection ); - ~Mp3tunesServiceQueryMaker(); - - virtual void run(); - - // virtual void runQuery(); - virtual void abortQuery(); - - virtual QueryMaker* setQueryType( QueryType type ); - - using DynamicServiceQueryMaker::addMatch; - virtual QueryMaker* addMatch ( const Meta::ArtistPtr &artist ); - virtual QueryMaker* addMatch ( const Meta::AlbumPtr &album ); - - virtual QueryMaker* addFilter( qint64 value, const QString &filter, bool matchBegin = false, bool matchEnd = false ); - - virtual int validFilterMask(); - - //Methods "borrowed" from MemoryQueryMaker - void handleResult(); - void handleResult( const Meta::TrackList &tracks ); - void handleResult( const Meta::ArtistList &artists ); - void handleResult( const Meta::AlbumList &albums ); - - void fetchArtists(); - void fetchAlbums(); - void fetchTracks(); - -protected: - template - void emitProperResult( const ListType& list ); - - Mp3tunesServiceCollection * m_collection; - Mp3tunesLocker * m_locker; - KIO::StoredTransferJob * m_storedTransferJob; - - class Private; - Private * const d; - - QString m_sessionId; - QString m_parentAlbumId; - QString m_parentArtistId; - - QString m_artistFilter; - QString m_albumFilter; - QString m_trackFilter; - int m_filterType; - -public slots: - - void artistDownloadComplete( QList artists ); - void albumDownloadComplete( QList albums ); - void trackDownloadComplete( QList tracks ); - -}; - -} //namespace Collections - -#endif diff --git a/amarok/src/services/mp3tunes/Mp3tunesSettingsModule.cpp b/amarok/src/services/mp3tunes/Mp3tunesSettingsModule.cpp deleted file mode 100644 index 78dab8e8..00000000 --- a/amarok/src/services/mp3tunes/Mp3tunesSettingsModule.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * Copyright (c) 2008 Casey Link * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "Mp3tunesSettingsModule.h" - -#include "ui_Mp3tunesConfigWidget.h" - -#include - -K_PLUGIN_FACTORY( Mp3tunesSettingsFactory, registerPlugin(); ) -K_EXPORT_PLUGIN( Mp3tunesSettingsFactory( "kcm_amarok_mp3tunes" ) ) - -Mp3tunesSettingsModule::Mp3tunesSettingsModule( QWidget *parent, const QVariantList &args ) - : KCModule( Mp3tunesSettingsFactory::componentData(), parent, args ) -{ - m_configDialog = new Ui::Mp3tunesConfigWidget; - m_configDialog->setupUi( this ); - //m_configDialog->pinEdit->setReadOnly( true ); - - m_configDialog->passwordEdit->setEchoMode( QLineEdit::Password ); - connect ( m_configDialog->emailEdit, SIGNAL(textChanged(QString)), this, SLOT(settingsChanged()) ); - connect ( m_configDialog->passwordEdit, SIGNAL(textChanged(QString)), this, SLOT(settingsChanged()) ); - //connect ( m_configDialog->enableHarmony, SIGNAL(stateChanged(int)), this, SLOT(settingsChanged()) ); - - load(); -} - - -Mp3tunesSettingsModule::~Mp3tunesSettingsModule() -{ - delete m_configDialog; -} - - -void Mp3tunesSettingsModule::save() -{ - m_config.setEmail( m_configDialog->emailEdit->text() ); - m_config.setPassword( m_configDialog->passwordEdit->text() ); - //m_config.setPin( m_configDialog->pinEdit->text() ); - //m_config.setHarmonyEnabled( m_configDialog->enableHarmony->isChecked() ); - - m_config.save(); - KCModule::save(); -} - -void Mp3tunesSettingsModule::load() -{ - m_configDialog->emailEdit->setText( m_config.email() ); - m_configDialog->passwordEdit->setText( m_config.password() ); - //m_configDialog->enableHarmony->setChecked( m_config.harmonyEnabled() ); - //m_configDialog->pinEdit->setText( m_config.pin() ); - - KCModule::load(); -} - -void Mp3tunesSettingsModule::defaults() -{ - m_config.setEmail( QString() ); - m_config.setPassword( QString() ); - //m_config.setHarmonyEnabled( false ); - load(); -} - -void Mp3tunesSettingsModule::settingsChanged() -{ - emit changed( true ); -} - -#include "moc_Mp3tunesSettingsModule.cpp" diff --git a/amarok/src/services/mp3tunes/Mp3tunesSettingsModule.h b/amarok/src/services/mp3tunes/Mp3tunesSettingsModule.h deleted file mode 100644 index 90f16a93..00000000 --- a/amarok/src/services/mp3tunes/Mp3tunesSettingsModule.h +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * Copyright (c) 2008 Casey Link * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef MP3TUNESSETTINGSMODULE_H -#define MP3TUNESSETTINGSMODULE_H - -#include "Mp3tunesConfig.h" - -#include - -namespace Ui { class Mp3tunesConfigWidget; } - -/** -A KCM module for configuring the Mp3tunes service - - @author -*/ -class Mp3tunesSettingsModule : public KCModule -{ - Q_OBJECT -public: - explicit Mp3tunesSettingsModule( QWidget *parent = 0, const QVariantList &args = QVariantList() ); - - ~Mp3tunesSettingsModule(); - - virtual void save(); - virtual void load(); - virtual void defaults(); - - -private slots: - - void settingsChanged(); - -private: - - Mp3tunesConfig m_config; - Ui::Mp3tunesConfigWidget * m_configDialog; - -}; - -#endif diff --git a/amarok/src/services/mp3tunes/Mp3tunesWorkers.cpp b/amarok/src/services/mp3tunes/Mp3tunesWorkers.cpp deleted file mode 100644 index a7ebd36c..00000000 --- a/amarok/src/services/mp3tunes/Mp3tunesWorkers.cpp +++ /dev/null @@ -1,331 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007,2008 Casey Link * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "Mp3tunesWorkers.h" - -#include "core/interfaces/Logger.h" -#include "core/support/Components.h" -#include "core/support/Debug.h" -#include "Mp3tunesMeta.h" - -#include -#include - -Mp3tunesLoginWorker::Mp3tunesLoginWorker( Mp3tunesLocker* locker, - const QString & username, - const QString & password ) - : ThreadWeaver::Job() - , m_locker( locker ) - , m_sessionId() - , m_username( username ) - , m_password( password ) -{ - connect( this, SIGNAL(done(ThreadWeaver::Job*)), SLOT(completeJob()) ); -} - -Mp3tunesLoginWorker::~Mp3tunesLoginWorker() -{ -} - -void Mp3tunesLoginWorker::run() -{ - DEBUG_BLOCK - if(m_locker != 0) { - debug() << "Calling Locker login.."; - m_sessionId = m_locker->login(m_username, m_password); - debug() << "Login Complete. SessionId = " << m_sessionId; - } else { - debug() << "Locker is NULL"; - } -} - -void Mp3tunesLoginWorker::completeJob() -{ - DEBUG_BLOCK - debug() << "Login Job complete"; - emit( finishedLogin( m_sessionId ) ); - deleteLater(); -} -/* ARTIST FETCHER */ -Mp3tunesArtistFetcher::Mp3tunesArtistFetcher( Mp3tunesLocker * locker ) -{ - connect( this, SIGNAL(done(ThreadWeaver::Job*)), SLOT(completeJob()) ); - m_locker = locker; -} - -Mp3tunesArtistFetcher::~Mp3tunesArtistFetcher() -{ -} - -void Mp3tunesArtistFetcher::run() -{ - DEBUG_BLOCK - if(m_locker != 0) { - debug() << "Artist Fetch Start"; - QList list = m_locker->artists(); - debug() << "Artist Fetch End. Total artists: " << list.count(); - m_artists = list; - } else { - debug() << "Locker is NULL"; - } -} - -void Mp3tunesArtistFetcher::completeJob() -{ - emit( artistsFetched( m_artists ) ); - deleteLater(); -} - -/* ALBUM w/ Artist Id FETCHER */ -Mp3tunesAlbumWithArtistIdFetcher::Mp3tunesAlbumWithArtistIdFetcher( Mp3tunesLocker * locker, int artistId ) -{ - connect( this, SIGNAL(done(ThreadWeaver::Job*)), SLOT(completeJob()) ); - m_locker = locker; - m_artistId = artistId; -} - -Mp3tunesAlbumWithArtistIdFetcher::~Mp3tunesAlbumWithArtistIdFetcher() -{ -} - -void Mp3tunesAlbumWithArtistIdFetcher::run() -{ - DEBUG_BLOCK - if(m_locker != 0) { - debug() << "Album Fetch Start"; - QList list = m_locker->albumsWithArtistId( m_artistId ); - debug() << "Album Fetch End. Total albums: " << list.count(); - m_albums = list; - } else { - debug() << "Locker is NULL"; - } -} - -void Mp3tunesAlbumWithArtistIdFetcher::completeJob() -{ - emit( albumsFetched( m_albums ) ); - deleteLater(); -} - -/* TRACK w/ albumId FETCHER */ -Mp3tunesTrackWithAlbumIdFetcher::Mp3tunesTrackWithAlbumIdFetcher( Mp3tunesLocker * locker, int albumId ) -{ - DEBUG_BLOCK - connect( this, SIGNAL(done(ThreadWeaver::Job*)), SLOT(completeJob()) ); - m_locker = locker; - debug() << "Constructor albumId: " << albumId; - m_albumId = albumId; -} - -Mp3tunesTrackWithAlbumIdFetcher::~Mp3tunesTrackWithAlbumIdFetcher() -{ -} - -void Mp3tunesTrackWithAlbumIdFetcher::run() -{ - DEBUG_BLOCK - if(m_locker != 0) { - debug() << "Track Fetch Start for album " << m_albumId; - QList list = m_locker->tracksWithAlbumId( m_albumId ); - debug() << "Track Fetch End. Total tracks: " << list.count(); - m_tracks = list; - } else { - debug() << "Locker is NULL"; - } -} - -void Mp3tunesTrackWithAlbumIdFetcher::completeJob() -{ - DEBUG_BLOCK - emit( tracksFetched( m_tracks ) ); - deleteLater(); -} - -/* TRACK w/ artistId FETCHER */ -Mp3tunesTrackWithArtistIdFetcher::Mp3tunesTrackWithArtistIdFetcher( Mp3tunesLocker * locker, int artistId ) -{ - DEBUG_BLOCK - connect( this, SIGNAL(done(ThreadWeaver::Job*)), SLOT(completeJob()) ); - m_locker = locker; - debug() << "Constructor artistId: " << artistId; - m_artistId = artistId; -} - -Mp3tunesTrackWithArtistIdFetcher::~Mp3tunesTrackWithArtistIdFetcher() -{ -} - -void Mp3tunesTrackWithArtistIdFetcher::run() -{ - DEBUG_BLOCK - if(m_locker != 0) { - debug() << "Track Fetch Start for artist " << m_artistId; - QList list = m_locker->tracksWithArtistId( m_artistId ); - debug() << "Track Fetch End. Total tracks: " << list.count(); - m_tracks = list; - } else { - debug() << "Locker is NULL"; - } -} - -void Mp3tunesTrackWithArtistIdFetcher::completeJob() -{ - DEBUG_BLOCK - emit( tracksFetched( m_tracks ) ); - deleteLater(); -} - -/* SEARCH MONKEY */ -Mp3tunesSearchMonkey::Mp3tunesSearchMonkey( Mp3tunesLocker * locker, QString query, int searchFor ) -{ - DEBUG_BLOCK - connect( this, SIGNAL(done(ThreadWeaver::Job*)), SLOT(completeJob()) ); - m_locker = locker; - m_searchFor = searchFor; - m_query = query; -} - -Mp3tunesSearchMonkey::~Mp3tunesSearchMonkey() -{} - -void Mp3tunesSearchMonkey::run() -{ - DEBUG_BLOCK - if(m_locker != 0) { - Mp3tunesSearchResult container; - debug() << "Searching query: " << m_query << " bitmask: " << m_searchFor; - container.searchFor = (Mp3tunesSearchResult::SearchType) m_searchFor; - if( !m_locker->search(container, m_query) ) - { - //TODO proper error handling - debug() << "!!!Search Failed query: " << m_query << " bitmask: " << m_searchFor; - } - m_result = container; - } else { - debug() << "Locker is NULL"; - } -} - -void Mp3tunesSearchMonkey::completeJob() -{ - DEBUG_BLOCK - emit( searchComplete( m_result.artistList ) ); - emit( searchComplete( m_result.albumList ) ); - emit( searchComplete( m_result.trackList ) ); - deleteLater(); -} - -/* SIMPLE UPLOADER */ -Mp3tunesSimpleUploader:: Mp3tunesSimpleUploader( Mp3tunesLocker * locker, QStringList tracklist ) -{ - DEBUG_BLOCK - connect( this, SIGNAL(done(ThreadWeaver::Job*)), SLOT(completeJob()) ); - - m_locker = locker; - m_tracklist = tracklist; - - Amarok::Components::logger()->newProgressOperation( this, i18n( "Upload to MP3tunes Initiated" ), m_tracklist.count() ); - //TODO: port to Amarok::Logger signals -// connect( this, SIGNAL(incrementProgress()), The::statusBar(), SLOT(incrementProgress()), Qt::QueuedConnection ); -} - -Mp3tunesSimpleUploader::~Mp3tunesSimpleUploader() -{ - emit endProgressOperation( this ); -} - -void Mp3tunesSimpleUploader::run() -{ - DEBUG_BLOCK - if(m_locker == 0) - return; - if(m_tracklist.count() == 0) - { - debug() << "Track list was empty."; - return; - } - - debug() << "Starting upload of " << m_tracklist.count() << " tracks."; - int progress = 1; - foreach(const QString &track, m_tracklist) { - QString msg = i18n( "Uploading Track %1/%2", progress, m_tracklist.count() ); - debug() << msg; - //TODO: port to Amarok::Logger signals -// Amarok::Components::logger()->setProgressStatus( this, msg ); - emit ( incrementProgress() ); - debug() << "Uploading: " << track; - - bool result = false; - if( track.startsWith( "http" ) ) - { - debug() << "Remote file."; - result = m_locker->lockerLoad( track ); - } else { - debug() << "Local file."; - result = m_locker->uploadTrack( track ); - } - - if(result) { - debug() << "Uploaded Succeeded."; - } else { - debug() << "Uploaded Failed."; - debug() << "Error msg: " << m_locker->errorMessage(); - } - progress++; - } - debug() << "Upload loop complete"; -} - -void Mp3tunesSimpleUploader::completeJob() -{ - DEBUG_BLOCK - emit( uploadComplete() ); - deleteLater(); -} - -/* TRACK from filekey FETCHER */ -Mp3tunesTrackFromFileKeyFetcher::Mp3tunesTrackFromFileKeyFetcher( Mp3tunesLocker * locker, QString filekey ) -{ - DEBUG_BLOCK - connect( this, SIGNAL(done(ThreadWeaver::Job*)), SLOT(completeJob()) ); - m_locker = locker; - debug() << "Constructor filekey: " << filekey; - m_filekey = filekey; -} - -Mp3tunesTrackFromFileKeyFetcher::~Mp3tunesTrackFromFileKeyFetcher() -{ -} - -void Mp3tunesTrackFromFileKeyFetcher::run() -{ - DEBUG_BLOCK - if(m_locker != 0) { - debug() << "Track Fetch from filekey " << m_filekey; - Mp3tunesLockerTrack track = m_locker->trackWithFileKey( m_filekey ); - debug() << "Track Fetch from filekey End."; - m_track = track; - } else { - debug() << "Locker is NULL"; - } -} - -void Mp3tunesTrackFromFileKeyFetcher::completeJob() -{ - DEBUG_BLOCK - emit( trackFetched( m_track ) ); - deleteLater(); -} diff --git a/amarok/src/services/mp3tunes/Mp3tunesWorkers.h b/amarok/src/services/mp3tunes/Mp3tunesWorkers.h deleted file mode 100644 index 070da769..00000000 --- a/amarok/src/services/mp3tunes/Mp3tunesWorkers.h +++ /dev/null @@ -1,224 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007,2008 Casey Link * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef MP3TUNESWORKERS_H -#define MP3TUNESWORKERS_H - -#include "Mp3tunesLocker.h" - -#include -#include - -#include - -/** - * Allows for threading the logging in process. - */ -class Mp3tunesLoginWorker : public ThreadWeaver::Job -{ - Q_OBJECT - public: - Mp3tunesLoginWorker( Mp3tunesLocker* locker, const QString &username, const QString &password ); - ~Mp3tunesLoginWorker(); - - void run(); - - signals: - void finishedLogin( const QString &sessionId ); - - private slots: - void completeJob(); - - private: - Mp3tunesLocker* m_locker; - QString m_sessionId; - QString m_username; - QString m_password; -}; - -/** - * Allows for threading the artist fetching process - */ -class Mp3tunesArtistFetcher : public ThreadWeaver::Job -{ - Q_OBJECT - public: - Mp3tunesArtistFetcher( Mp3tunesLocker * locker ); - ~Mp3tunesArtistFetcher(); - - void run(); - - signals: - void artistsFetched( QList ); - - private slots: - void completeJob(); - - private: - Mp3tunesLocker* m_locker; - QList m_artists; -}; - -/** - * Allows for threading the albumWithArtistId fetching process - */ -class Mp3tunesAlbumWithArtistIdFetcher : public ThreadWeaver::Job -{ - Q_OBJECT - public: - Mp3tunesAlbumWithArtistIdFetcher( Mp3tunesLocker * locker, int artistId ); - ~Mp3tunesAlbumWithArtistIdFetcher(); - - void run(); - - signals: - void albumsFetched( QList ); - - private slots: - void completeJob(); - - private: - int m_artistId; - Mp3tunesLocker* m_locker; - QList m_albums; -}; - -/** - * Allows for threading the trackWithAlbumId fetching process - */ -class Mp3tunesTrackWithAlbumIdFetcher : public ThreadWeaver::Job -{ - Q_OBJECT - public: - Mp3tunesTrackWithAlbumIdFetcher( Mp3tunesLocker * locker, int albumId ); - ~Mp3tunesTrackWithAlbumIdFetcher(); - - void run(); - - signals: - void tracksFetched( QList ); - - private slots: - void completeJob(); - - private: - int m_albumId; - Mp3tunesLocker* m_locker; - QList m_tracks; -}; - -/** - * Allows for threading the trackWithArtistId fetching process - */ -class Mp3tunesTrackWithArtistIdFetcher : public ThreadWeaver::Job -{ - Q_OBJECT - public: - Mp3tunesTrackWithArtistIdFetcher( Mp3tunesLocker * locker, int artistId ); - ~Mp3tunesTrackWithArtistIdFetcher(); - - void run(); - - signals: - void tracksFetched( QList ); - - private slots: - void completeJob(); - - private: - int m_artistId; - Mp3tunesLocker* m_locker; - QList m_tracks; -}; - -/** - * Allows for threading the searching process - */ -class Mp3tunesSearchMonkey : public ThreadWeaver::Job -{ - Q_OBJECT - public: - Mp3tunesSearchMonkey( Mp3tunesLocker * locker, QString query, int searchFor ); - ~Mp3tunesSearchMonkey(); - - void run(); - - signals: - void searchComplete( QList ); - void searchComplete( QList ); - void searchComplete( QList ); - - private slots: - void completeJob(); - - private: - QString m_query; - int m_searchFor; - Mp3tunesLocker* m_locker; - Mp3tunesSearchResult m_result; -}; - -/** - * Allows for threading a track list upload - */ -class Mp3tunesSimpleUploader : public ThreadWeaver::Job -{ - Q_OBJECT - public: - Mp3tunesSimpleUploader( Mp3tunesLocker * locker, QStringList tracklist ); - ~Mp3tunesSimpleUploader(); - - void run(); - - signals: - void uploadComplete(); - void incrementProgress(); - void endProgressOperation( QObject * ); - - private slots: - void completeJob(); - - private: - Mp3tunesLocker* m_locker; - QStringList m_tracklist; -}; - -/** - * Allows for threading a track from filekey job. - */ -class Mp3tunesTrackFromFileKeyFetcher : public ThreadWeaver::Job -{ - Q_OBJECT - public: - Mp3tunesTrackFromFileKeyFetcher( Mp3tunesLocker * locker, QString filekey ); - ~Mp3tunesTrackFromFileKeyFetcher(); - - void run(); - - signals: - void trackFetched( Mp3tunesLockerTrack &track ); - - private slots: - void completeJob(); - - private: - Mp3tunesLocker* m_locker; - Mp3tunesLockerTrack m_track; - QString m_filekey; -}; - -#endif - diff --git a/amarok/src/services/mp3tunes/amarok_service_mp3tunes.desktop b/amarok/src/services/mp3tunes/amarok_service_mp3tunes.desktop deleted file mode 100644 index 49cd8a04..00000000 --- a/amarok/src/services/mp3tunes/amarok_service_mp3tunes.desktop +++ /dev/null @@ -1,116 +0,0 @@ -[Desktop Entry] -Type=Service -ServiceTypes=KPluginInfo -Icon=view-services-mp3tunes-amarok -Name=MP3tunes -Name[bg]=MP3tunes -Name[bs]=MP3 melodija -Name[ca]=MP3tunes -Name[ca@valencia]=MP3tunes -Name[cs]=MP3tunes -Name[da]=MP3tunes -Name[de]=MP3tunes -Name[el]=MP3tunes -Name[en_GB]=MP3tunes -Name[es]=MP3tunes -Name[et]=MP3tunes -Name[eu]=MP3tunes -Name[fi]=MP3tunes -Name[fr]=MP3tunes -Name[ga]=MP3tunes -Name[gl]=MP3tunes -Name[hu]=MP3tunes -Name[id]=MP3tunes -Name[is]=Mp3tunes -Name[it]=MP3tunes -Name[ja]=MP3tunes -Name[km]=MP3tunes -Name[ko]=MP3tunes -Name[lt]=MP3tunes -Name[lv]=Mp3tunes -Name[nb]=Mp3tunes -Name[nds]=MP3tunes -Name[nl]=MP3tunes -Name[pa]=MP3tunes -Name[pl]=MP3tunes -Name[pt]=MP3tunes -Name[pt_BR]=MP3tunes -Name[ro]=MP3tunes -Name[ru]=MP3tunes -Name[sk]=MP3tunes -Name[sl]=MP3tunes -Name[sr]=МП3‑тјунс -Name[sr@ijekavian]=МП3‑тјунс -Name[sr@ijekavianlatin]=MP3Tunes -Name[sr@latin]=MP3Tunes -Name[sv]=MP3tunes -Name[tr]=MP3tunes -Name[uk]=MP3tunes -Name[x-test]=xxMP3tunesxx -Name[zh_CN]=MP3tunes -Name[zh_TW]=Mp3tunes -Comment=Browse and listen to the music stored in your MP3tunes account -Comment[bg]=Преглед и слушане на музиката от сметката ви в MP3tunes -Comment[bs]=Pregledajte i slušajte muziku sa svog naloga na MP3‑tjunsu -Comment[ca]=Navegueu i escolteu la música emmagatzemada en el vostre compte de MP3tunes -Comment[ca@valencia]=Navegueu i escolteu la música emmagatzemada en el vostre compte de MP3tunes -Comment[cs]=Procházejte a poslouchejte hudbu uloženou na vašem mp3tunes účtu -Comment[da]=Gennemse og lyt til musik gemt på din MP3tunes-konto -Comment[de]=Musik durchsehen und anhören, die in Ihrem MP3tunes-Konto abgelegt ist -Comment[el]=Περιηγηθείτε και ακούστε τη μουσική που έχετε αποθηκευμένη στο λογαριασμό σας MP3tunes -Comment[en_GB]=Browse and listen to the music stored in your MP3tunes account -Comment[es]=Navegar y escuchar la música guardada en su cuenta MP3tunes -Comment[et]=Sinu MP3tunes'i kontole salvestatud muusika sirvimine ja kuulamine -Comment[eu]=Arakatu eta entzun zure MP3tunes kontuan gordetako musika -Comment[fi]=Selaa ja kuuntele MP3tunes-tilillesi tallennettua musiikkia -Comment[fr]=Parcourir et écouter la musique stockée sur votre compte « MP3tunes » -Comment[ga]=Brabhsáil agus éist leis an gceol i do chuntas MP3tunes -Comment[gl]=Navegar e escoitar a música gardada na súa conta MP3tunes -Comment[hu]=Az Ön MP3tunes-azonosítóján tárolt zene böngészése és hallgatása -Comment[id]=Melihat-lihat dan mendengarkan musik yang dibeli di akun MP3tune anda -Comment[is]=Skoða og hlusta á tónlistina sem þú geymir í Mp3tunes hólfinu þínu -Comment[it]=Sfoglia e ascolta la musica conservata nel tuo account MP3tunes -Comment[ja]=Mp3tunes アカウントに保存した音楽をブラウズし聴けます -Comment[km]=រក​មើល និង​ស្ដាប់​តន្ត្រី​ដែល​បាន​ផ្ទុក​ក្នុង​គណនី MP3tunes របស់​អ្នក -Comment[ko]=MP3tunes 계정에 저장되어 있는 음악을 탐색하고 듣기 -Comment[lt]=Naršyti ir klausytis muzikos iš MP3tunes paskyros -Comment[lv]=Pārlūkojiet un klausieties mūziku, kura glabājas jūsu MP3tunes lietotāja kontā -Comment[nb]=Bla gjennom og lytt til musikk som er lagret på Mp3tunes-kontoen din. -Comment[nds]=Musik vun Dien MP3Tunes-Konto dörkieken un anhören -Comment[nl]=Blader door en luister naar muziek opgeslagen op uw MP3tunes-account -Comment[pl]=Przeglądaj i słuchaj muzyki przechowywanej na twoim koncie MP3tunes -Comment[pt]=Navegar e escutar a música gravada na sua conta do MP3tunes -Comment[pt_BR]=Navegue e ouça as músicas armazenadas na sua conta do MP3tunes -Comment[ro]=Răsfoiți și ascultați muzica stocată în contul dumneavoastră MP3tunes -Comment[ru]=Обзор и прослушивание музыки, сохранённой в учётной записи MP3tunes -Comment[sk]=Prehliadať a počúvať hudbu uloženú na Vašom MP3tunes účte -Comment[sl]=Brskajte po glasbi, ki jo imate shranjeno na svojem računu MP3tunes, in jo poslušajte -Comment[sr]=Прегледајте и слушајте музику са свог налога на МП3‑тјунсу -Comment[sr@ijekavian]=Прегледајте и слушајте музику са свог налога на МП3‑тјунсу -Comment[sr@ijekavianlatin]=Pregledajte i slušajte muziku sa svog naloga na MP3Tunesu -Comment[sr@latin]=Pregledajte i slušajte muziku sa svog naloga na MP3Tunesu -Comment[sv]=Bläddra igenom och lyssna på musik lagrad på ditt Mp3tunes-konto -Comment[tr]=MP3tunes hesabınızdaki müzikleri inceleyin ve dinleyin -Comment[uk]=Перегляньте і прослухайте музику з вашого рахунку у MP3tunes -Comment[x-test]=xxBrowse and listen to the music stored in your MP3tunes accountxx -Comment[zh_CN]=浏览并收听储存在您的 MP3tunes 账户中的音乐 -Comment[zh_TW]=瀏覽並聆聽儲存在您 MP3tunes 帳戶中的音樂 - -ServiceTypes=Amarok/Plugin - -X-KDE-Amarok-authors=Nikolaj Hald Nielsen -X-KDE-Amarok-email=nhnFreespirit@gmail.com -X-KDE-Amarok-framework-version=72 -X-KDE-Amarok-name=Mp3tunesService -X-KDE-Amarok-plugintype=service -X-KDE-Amarok-rank=100 -X-KDE-Amarok-version=1 - -X-KDE-PluginInfo-Author=Nikolaj Hald Nielsen -X-KDE-PluginInfo-Email=nhnFreespirit@gmail.com -X-KDE-PluginInfo-Version=1.0 -X-KDE-PluginInfo-Category=Service -X-KDE-PluginInfo-License=GPL -X-KDE-PluginInfo-EnabledByDefault=false -X-KDE-Library=amarok_service_mp3tunes -X-KDE-PluginInfo-Name=amarok_service_mp3tunes diff --git a/amarok/src/services/mp3tunes/amarok_service_mp3tunes_config.desktop b/amarok/src/services/mp3tunes/amarok_service_mp3tunes_config.desktop deleted file mode 100644 index ef1d0728..00000000 --- a/amarok/src/services/mp3tunes/amarok_service_mp3tunes_config.desktop +++ /dev/null @@ -1,109 +0,0 @@ -[Desktop Entry] -Icon=view-services-mp3tunes-amarok -Type=Service -ServiceTypes=Amarok/Plugin -X-KDE-ServiceTypes=KCModule - -X-KDE-Library=kcm_amarok_service_mp3tunes -X-KDE-ParentApp=amarok_service_mp3tunes -X-KDE-ParentComponents=amarok_service_mp3tunes - -Name=MP3tunes Service Config -Name[bg]=Настройки на услугата MP3tunes -Name[bs]=Postavke MP3‑tjunsovog servisa -Name[ca]=Configuració del servei MP3tunes -Name[ca@valencia]=Configuració del servei MP3tunes -Name[cs]=Nastavení služby Mp3tunes -Name[da]=Konfiguration af MP3tunes-tjeneste -Name[de]=Einrichtung von MP3tunes -Name[el]=Διαμόρφωση υπηρεσίας MP3tunes -Name[en_GB]=MP3tunes Service Config -Name[es]=Configurar servicio MP3tunes -Name[et]=MP3Tunesi teenuse seadistamine -Name[eu]=Mp3tunes zerbitzuaren konfigurazioa -Name[fi]=MP3tunes-palvelumääritykset -Name[fr]=Configuration du service « MP3tunes » -Name[ga]=Cumraíocht Seirbhíse MP3tunes -Name[gl]=Configuración do servizo MP3tunes -Name[hu]=MP3tunes szolgáltatás beállítása -Name[id]=Konfig Layanan MP3tunes -Name[is]=Stillingar Mp3tunes þjónustu -Name[it]=Configurazione servizio MP3tunes -Name[ja]=Mp3tunes サービスの設定 -Name[km]=កំណត់​រចនាសម្ព័ន្ធ​សេវា MP3tunes -Name[ko]=MP3tunes 서비스 설정 -Name[lt]=MP3tunes tarnybos parinktys -Name[lv]=Mp3tunes pakalpojuma konfigurācija -Name[nb]=Innstillinger for Mp3tunes-tjenesten -Name[nds]=MP3Tunes-Deenstinstellen -Name[nl]=Mp3tunes-dienst instellingen -Name[pa]=Mp3tunes ਸਰਵਿਸ ਸੰਰਚਨਾ -Name[pl]=Ustawienia usługi MP3tunes -Name[pt]=Configuração do Serviço MP3tunes -Name[pt_BR]=Configuração do serviço MP3tunes -Name[ro]=Configurare serviciu MP3tunes -Name[ru]=Настройка службы MP3tunes -Name[sk]=Konfigurácia služby MP3tunes -Name[sl]=Nastavitev storitve MP3tunes -Name[sr]=Поставке МП3‑тјунсовог сервиса -Name[sr@ijekavian]=Поставке МП3‑тјунсовог сервиса -Name[sr@ijekavianlatin]=Postavke MP3Tunesovog servisa -Name[sr@latin]=Postavke MP3Tunesovog servisa -Name[sv]=Inställning av Mp3tunes-tjänst -Name[tr]=Mp3tunes Hizmet Yapılandırması -Name[uk]=Налаштування служби MP3tunes -Name[x-test]=xxMP3tunes Service Configxx -Name[zh_CN]=MP3tunes 服务配置 -Name[zh_TW]=Mp3tunes 服務設定 -Comment=Configure mp3tunes credentials -Comment[bg]=Настройване на mp3tunes -Comment[bs]=Podesite akreditive za MP3‑tjuns -Comment[ca]=Configura les credencials de mp3tunes -Comment[ca@valencia]=Configura les credencials de mp3tunes -Comment[cs]=Nastavit přihlašovací údaje Mp3tunes -Comment[da]=Indstil MP3tunes-akkreditiver -Comment[de]=Zugangsdaten zu Mp3tunes einrichten -Comment[el]=Διαμόρφωση διαπιστευτηρίων mp3tunes -Comment[en_GB]=Configure mp3tunes credentials -Comment[eo]=Agordi mp3tunes akreditaĵojn. -Comment[es]=Configurar credenciales de mp3tunes -Comment[et]=Mp3Tunesi kasutajatunnuste määramine -Comment[eu]=Konfiguratu mp3tunes-en kredentzialak -Comment[fi]=Määritä Mp3tunes-palvelun tilitiedot -Comment[fr]=Configuration des références « MP3tunes » -Comment[ga]=Cumraíocht dintiúir MP3tunes -Comment[gl]=Configura as credenciais de mp3tunes -Comment[hu]=Bejelentkezési adatok beállítása az MP3tunes szolgáltatáshoz -Comment[id]=Atur surat kuasa mp3tunes -Comment[is]=Stilla mp3tunes auðkenni -Comment[it]=Configura credenziali mp3tunes -Comment[ja]=Mp3tunes の資格情報を設定 -Comment[km]=កំណត់​រចនាសម្ព័ន្ធ​លិខិត​សម្គាល់​ mp3tunes -Comment[ko]=mp3tunes 개인 정보 설정 -Comment[ku]=Ewlayî yên mp3tunes ava bike -Comment[lt]=Keisti mp3tunes prisijungimo duomenis -Comment[lv]=Konfigurēt mp3tune lietotāja kontu -Comment[nb]=Sett opp mp3tunes akkreditiver -Comment[nds]=Anmelldaten för MP3Tunes instellen -Comment[nl]=Mp3tunes-gegevens instellen -Comment[nn]=Set opp MP3tunes-brukardetaljar -Comment[pl]=Ustawia dane Mp3tunes -Comment[pt]=Configurar as credenciais do mp3tunes -Comment[pt_BR]=Configurar credenciais do mp3tunes -Comment[ro]=Configurează detaliile contului mp3tunes -Comment[ru]=Настройки учётной записи Mp3tunes -Comment[sk]=Nastaviť osobné údaje pre mp3tunes -Comment[sl]=Nastavite podatke o računu na MP3tunes -Comment[sr]=Подесите акредитиве за МП3‑тјунс -Comment[sr@ijekavian]=Подесите акредитиве за МП3‑тјунс -Comment[sr@ijekavianlatin]=Podesite akreditive za MP3Tunes -Comment[sr@latin]=Podesite akreditive za MP3Tunes -Comment[sv]=Anpassa Mp3tunes identifieringsinformation -Comment[th]=ปรับแต่งตัวรับรองสมาชิกภาพของ mp3tunes -Comment[tr]=mp3tunes üyelik ayarlarını yapılandır -Comment[uk]=Налаштувати реєстраційні дані у mp3tunes -Comment[wa]=Aponteye les credits mp3tunes -Comment[x-test]=xxConfigure mp3tunes credentialsxx -Comment[zh_CN]=配置 Mp3tunes 证件 -Comment[zh_TW]=設定 mp3tunes 的憑證 - diff --git a/amarok/src/services/mp3tunes/harmonydaemon/AmarokClient.cpp b/amarok/src/services/mp3tunes/harmonydaemon/AmarokClient.cpp deleted file mode 100644 index 37a80d55..00000000 --- a/amarok/src/services/mp3tunes/harmonydaemon/AmarokClient.cpp +++ /dev/null @@ -1,122 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Casey Link * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "AmarokClient.h" - -#include -#include -#include - -Mp3tunesAmarokClient::Mp3tunesAmarokClient() : Mp3tunesHarmonyClient() -{} - -void Mp3tunesAmarokClient::dbusEmitMessage( const QString &message, const QString ¶m = QString() ) -{ - QString name = "org.kde.amarok"; - QDBusMessage m = QDBusMessage::createMethodCall( name, - "/Mp3tunesHarmonyHandler", - "", - message ); - if( !param.isEmpty() ) - { - QList args; - args.append( param ); - m.setArguments(args); - } - QDBusMessage response = QDBusConnection::sessionBus().call( m ); - if( response.type() == QDBusMessage::ErrorMessage ) - { - qDebug() << "Got ERROR response " << message; - qDebug() << response.errorName() << ": " << response.errorMessage(); - } -} - - -/* SLOTS */ -void -Mp3tunesAmarokClient::harmonyError( const QString &error ) -{ - qDebug() << "Received Error: " << error; -} - -void -Mp3tunesAmarokClient::harmonyWaitingForEmail( const QString &pin ) -{ - qDebug() << "Received HARMONY_WAITING_FOR_EMAIL " << pin; - dbusEmitMessage( "emitWaitingForEmail", pin ); -} - -void -Mp3tunesAmarokClient::harmonyWaitingForPin() -{ - qDebug() << "Received HARMONY_WAITING_FOR_PIN"; - dbusEmitMessage( "emitWaitingForPin" ); -} - -void -Mp3tunesAmarokClient::harmonyConnected() -{ - qDebug() << "Apparently Harmony is connected"; - dbusEmitMessage( "emitConnected" ); -} - -void -Mp3tunesAmarokClient::harmonyDisconnected() -{ - qDebug() << "Harmony said see ya later."; - dbusEmitMessage( "emitDisconnected" ); -} - -void -Mp3tunesAmarokClient::harmonyDownloadReady( const Mp3tunesHarmonyDownload &download ) -{ - qDebug() << "Got message about ready: " << download.trackTitle() << " by " << download.artistName() << " on " << download. albumTitle(); - QString name = "org.kde.amarok"; - QDBusMessage m = QDBusMessage::createMethodCall( name, - "/Mp3tunesHarmonyHandler", - "", - "emitDownloadReady" ); - QList args; - args.append( download.serialize() ); - m.setArguments(args); - QDBusMessage response = QDBusConnection::sessionBus().call( m ); - if( response.type() == QDBusMessage::ErrorMessage ) - { - qDebug() << "Got ERROR response harmonyDownloadReady"; - qDebug() << response.errorName() << ": " << response.errorMessage(); - } -} - -void -Mp3tunesAmarokClient::harmonyDownloadPending( const Mp3tunesHarmonyDownload &download ) -{ - qDebug() << "Got message about pending: " << download.trackTitle() << " by " << download.artistName() << " on " << download. albumTitle(); - qDebug() << "Got message about ready: " << download.trackTitle() << " by " << download.artistName() << " on " << download. albumTitle(); - QString name = "org.kde.amarok"; - QDBusMessage m = QDBusMessage::createMethodCall( name, - "/Mp3tunesHarmonyHandler", - "", - "emitDownloadPending" ); - QList args; - args.append( download.serialize() ); - m.setArguments(args); - QDBusMessage response = QDBusConnection::sessionBus().call( m ); - if( response.type() == QDBusMessage::ErrorMessage ) - { - qDebug() << "Got ERROR response harmonyDownloadPending"; - qDebug() << response.errorName() << ": " << response.errorMessage(); - } -} diff --git a/amarok/src/services/mp3tunes/harmonydaemon/AmarokClient.h b/amarok/src/services/mp3tunes/harmonydaemon/AmarokClient.h deleted file mode 100644 index 95559f23..00000000 --- a/amarok/src/services/mp3tunes/harmonydaemon/AmarokClient.h +++ /dev/null @@ -1,38 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Casey Link * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef MP3TUNESAMAROKCLIENT_H -#define MP3TUNESAMAROKCLIENT_H - -#include "Mp3tunesHarmonyClient.h" - -class Mp3tunesAmarokClient : public Mp3tunesHarmonyClient { - public: - Mp3tunesAmarokClient(); - - public slots: - virtual void harmonyError( const QString &error ); - virtual void harmonyWaitingForEmail( const QString &pin ); - virtual void harmonyWaitingForPin(); - virtual void harmonyConnected(); - virtual void harmonyDisconnected(); - virtual void harmonyDownloadReady( const Mp3tunesHarmonyDownload &download ); - virtual void harmonyDownloadPending( const Mp3tunesHarmonyDownload &download ); - private: - void dbusEmitMessage( const QString &message, const QString ¶m); -}; - -#endif diff --git a/amarok/src/services/mp3tunes/harmonydaemon/Mp3tunesHarmonyClient.cpp b/amarok/src/services/mp3tunes/harmonydaemon/Mp3tunesHarmonyClient.cpp deleted file mode 100644 index dc514c50..00000000 --- a/amarok/src/services/mp3tunes/harmonydaemon/Mp3tunesHarmonyClient.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Casey Link * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "Mp3tunesHarmonyClient.h" -#include -Mp3tunesHarmonyClient::Mp3tunesHarmonyClient() -{} - -/* SLOTS */ -void -Mp3tunesHarmonyClient::harmonyError( const QString &error ) -{ - qDebug() << "Received Error: " << error; -} - -void -Mp3tunesHarmonyClient::harmonyWaitingForEmail( const QString &pin ) -{ - qDebug() << "Received HARMONY_WAITING_FOR_EMAIL " << pin; -} - -void -Mp3tunesHarmonyClient::harmonyWaitingForPin() -{ - qDebug() << "Received HARMONY_WAITING_FOR_PIN"; -} - -void -Mp3tunesHarmonyClient::harmonyConnected() -{ - qDebug() << "Apparently Harmony is connected"; -} - -void -Mp3tunesHarmonyClient::harmonyDisconnected() -{ - qDebug() << "Harmony said see ya later."; -} - -void -Mp3tunesHarmonyClient::harmonyDownloadReady( const Mp3tunesHarmonyDownload &download ) -{ - qDebug() << "Got message about ready: " << download.trackTitle() << " by " << download.artistName() << " on " << download. albumTitle(); -} - -void -Mp3tunesHarmonyClient::harmonyDownloadPending( const Mp3tunesHarmonyDownload &download ) -{ - qDebug() << "Got message about pending: " << download.trackTitle() << " by " << download.artistName() << " on " << download. albumTitle(); -} diff --git a/amarok/src/services/mp3tunes/harmonydaemon/Mp3tunesHarmonyClient.h b/amarok/src/services/mp3tunes/harmonydaemon/Mp3tunesHarmonyClient.h deleted file mode 100644 index c3c67594..00000000 --- a/amarok/src/services/mp3tunes/harmonydaemon/Mp3tunesHarmonyClient.h +++ /dev/null @@ -1,38 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Casey Link * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef MP3TUNESHARMONYCLIENT_H -#define MP3TUNESHARMONYCLIENT_H - -#include "Mp3tunesHarmonyDownload.h" - -#include -class Mp3tunesHarmonyClient : public QObject { - Q_OBJECT - public: - Mp3tunesHarmonyClient(); - - public slots: - virtual void harmonyError( const QString &error ); - virtual void harmonyWaitingForEmail( const QString &pin ); - virtual void harmonyWaitingForPin(); - virtual void harmonyConnected(); - virtual void harmonyDisconnected(); - virtual void harmonyDownloadReady( const Mp3tunesHarmonyDownload &download ); - virtual void harmonyDownloadPending( const Mp3tunesHarmonyDownload &download ); -}; - -#endif diff --git a/amarok/src/services/mp3tunes/harmonydaemon/Mp3tunesHarmonyDaemon.cpp b/amarok/src/services/mp3tunes/harmonydaemon/Mp3tunesHarmonyDaemon.cpp deleted file mode 100644 index 9483a32a..00000000 --- a/amarok/src/services/mp3tunes/harmonydaemon/Mp3tunesHarmonyDaemon.cpp +++ /dev/null @@ -1,408 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Casey Link * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "Mp3tunesHarmonyDaemon.h" -#include "mp3tunesharmonydaemonadaptor.h" - -#ifndef statfs -#define statfs statvfs -#endif - -#include -#include - -Mp3tunesHarmonyDaemon::Mp3tunesHarmonyDaemon( QString identifier ) - : QCoreApplication( KCmdLineArgs::qtArgc(), KCmdLineArgs::qtArgv() ) - , m_identifier( identifier ) - , m_email( QString() ) - , m_pin( QString() ) - , m_gerr( 0 ) - , m_error( QString() ) - , m_started( false ) - , m_inited( false ) - , m_state( Mp3tunesHarmonyDaemon::DISCONNECTED ) -{ - allAboardTheDBus(); - init(); -} - -Mp3tunesHarmonyDaemon::Mp3tunesHarmonyDaemon( QString identifier, QString email, QString pin ) - : QCoreApplication( KCmdLineArgs::qtArgc(), KCmdLineArgs::qtArgv() ) - , m_identifier( identifier ) - , m_email( email ) - , m_pin( pin ) - , m_gerr( 0 ) - , m_error( QString() ) - , m_started( false ) - , m_inited( false ) - , m_state( Mp3tunesHarmonyDaemon::DISCONNECTED ) -{ - allAboardTheDBus(); - init(); -} - - -Mp3tunesHarmonyDaemon::~Mp3tunesHarmonyDaemon() -{ - breakConnection(); - delete m_harmony; - delete m_gerr; -} - -void -Mp3tunesHarmonyDaemon::setClient( Mp3tunesHarmonyClient *client ) -{ - m_client = client; - connect( this, SIGNAL(disconnected()), - m_client, SLOT(harmonyDisconnected())); - connect( this, SIGNAL(waitingForEmail(QString)), - m_client, SLOT(harmonyWaitingForEmail(QString)) ); - connect( this, SIGNAL(connected()), - m_client, SLOT(harmonyConnected()) ); - connect( this, SIGNAL(errorSignal(QString)), - m_client, SLOT(harmonyError(QString)) ); - connect( this, SIGNAL(downloadReady(Mp3tunesHarmonyDownload)), - m_client, SLOT(harmonyDownloadReady(Mp3tunesHarmonyDownload)) ); - connect( this, SIGNAL(downloadPending(Mp3tunesHarmonyDownload)), - m_client, SLOT(harmonyDownloadPending(Mp3tunesHarmonyDownload)) ); -} - -bool -Mp3tunesHarmonyDaemon::allAboardTheDBus() -{ - - setOrganizationName( "Amarok" ); - setOrganizationDomain( "amarok.kde.org" ); - setApplicationName( "Mp3tunes Harmony Daemon" ); - - QDBusConnectionInterface *bus = 0; - bus = QDBusConnection::sessionBus().interface(); - if( !bus ) { - qFatal("No dbus!!"); - ::exit(126); - return false; - } - QStringList parts = this->organizationDomain().split(QLatin1Char('.'), QString::SkipEmptyParts); - QString reversedDomain; - if (parts.isEmpty()) - reversedDomain = QLatin1String("local."); - else - foreach (const QString& s, parts) - { - reversedDomain.prepend(QLatin1Char('.')); - reversedDomain.prepend(s); - } - const QString pidSuffix = QString::number( applicationPid() ).prepend( QLatin1String("-") ); - const QString serviceName = reversedDomain + this->applicationName().remove( ' ' ) + pidSuffix; - if ( bus->registerService(serviceName) == QDBusConnectionInterface::ServiceNotRegistered ) { - qDebug() << "FATAL: Couldn't register name '" << serviceName << "' with DBUS - another process owns it already!" << endl; - ::exit(126); - return false; - } - qDebug() << "Registered service: " << serviceName; - new Mp3tunesHarmonyDaemonAdaptor( this ); - if ( QDBusConnection::sessionBus().registerObject( QLatin1String("/Mp3tunesHarmonyDaemon"), this ) ) - { - qDebug() << "Dbus registered"; - return true; - } else { - qDebug() << "Dbus not registered"; - return false; - } - -} - -bool -Mp3tunesHarmonyDaemon::daemonConnected() -{ - return m_started; -} - -bool -Mp3tunesHarmonyDaemon::breakConnection() -{ - if( !daemonConnected() ) { - qDebug() << "Daemon not connected"; - return true; - } - qDebug() << "Disconnecting Harmony"; - GError *err; - mp3tunes_harmony_disconnect(m_harmony, &err); - if (err) { - qDebug() << "Error disconnecting: " << err->message; - /* If there is an error disconnecting something has probably gone - * very wrong and reconnection should not be attempted till the user - * re-initiates it */ - } - return true; -} - -int -Mp3tunesHarmonyDaemon::init() -{ - - qDebug() << "Begin initing"; - /* g_type_init required for using the GObjects for Harmony. */ - g_type_init(); - - m_harmony = mp3tunes_harmony_new(); - - /* Set the error signal handler. */ - g_signal_connect( m_harmony, "error", - G_CALLBACK( signalErrorHandler ), this ); - /* Set the state change signal handler. */ - g_signal_connect( m_harmony, "state_change", - G_CALLBACK(signalStateChangeHandler ), this ); - /* Set the download signal handler. */ - g_signal_connect( m_harmony, "download_ready", - G_CALLBACK(signalDownloadReadyHandler ), this ); - g_signal_connect( m_harmony, "download_pending", - G_CALLBACK(signalDownloadPendingHandler ), this ); - - qDebug() << "Initing 1"; - - mp3tunes_harmony_set_identifier( m_harmony, convertToChar( m_identifier ) ); - - if( !m_email.isEmpty() ) - mp3tunes_harmony_set_email( m_harmony, convertToChar( m_email ) ); - if( !m_pin.isEmpty() ) - mp3tunes_harmony_set_pin( m_harmony, convertToChar( m_pin ) ); - - mp3tunes_harmony_set_device_attribute( m_harmony, "device-description", - "Amarok 2 Test Daemon"); - - - /* Linux specific variable for getting total and available sizes for the - * file system - */ - qDebug() << "Initing 2"; - - struct statfs fsstats; - unsigned long long total_bytes; - unsigned long long available_bytes; - - if ( statfs( ".", &fsstats ) != 0 ) { - perror( "statfs failed" ); - return -1; - } - - total_bytes = fsstats.f_bsize * fsstats.f_blocks; - available_bytes = fsstats.f_bsize * fsstats.f_bavail; - mp3tunes_harmony_set_device_attribute( m_harmony, "total-bytes", &total_bytes ); - mp3tunes_harmony_set_device_attribute( m_harmony, "available-bytes", - &available_bytes ); - - qDebug() << "Done initing"; - m_inited = true; - return 0; -} - -QString -Mp3tunesHarmonyDaemon::makeConnection() -{ - if( !m_inited ) - return "Daemon not init()ed yet. Connection not attempted."; - - m_gerr = 0; - mp3tunes_harmony_connect( m_harmony, &m_gerr ); - /* Check for errors on the connection */ - if ( m_gerr ) { - g_print( "Error: %s\n", m_gerr->message ); - } - - if ( m_gerr ) { - m_started = false; - return "Error: " + QString( m_gerr->message ); - } else { - m_started = true; - return "All good!"; - } -} - -QString -Mp3tunesHarmonyDaemon::pin() const -{ - return QString( mp3tunes_harmony_get_pin( m_harmony ) ); -} - -QString -Mp3tunesHarmonyDaemon::email() const -{ - return QString( mp3tunes_harmony_get_email( m_harmony ) ); -} - - -QString -Mp3tunesHarmonyDaemon::error() const -{ - return m_error; -} - -void -Mp3tunesHarmonyDaemon::setState( HarmonyState state ) -{ - m_state = state; -} - -void -Mp3tunesHarmonyDaemon::setError( const QString &error ) -{ - m_error = error; -} - -void -Mp3tunesHarmonyDaemon::emitError() -{ - emit( errorSignal( m_error ) ); -} - -void -Mp3tunesHarmonyDaemon::emitWaitingForEmail( const QString &pin ) -{ - emit( waitingForEmail( pin ) ); -} - -void -Mp3tunesHarmonyDaemon::emitWaitingForPin() -{ - emit( waitingForPin() ); -} - -void -Mp3tunesHarmonyDaemon::emitConnected() -{ - emit( connected() ); -} - -void -Mp3tunesHarmonyDaemon::emitDisconnected() -{ - emit( disconnected() ); -} - -void -Mp3tunesHarmonyDaemon::emitDownloadReady( const Mp3tunesHarmonyDownload &download ) -{ - emit( downloadReady( download ) ); -} -void -Mp3tunesHarmonyDaemon::emitDownloadPending( const Mp3tunesHarmonyDownload &download ) -{ - emit( downloadPending( download ) ); -} - -void -Mp3tunesHarmonyDaemon::signalErrorHandler(MP3tunesHarmony* harmony, gpointer null_pointer ) -{ - - GError *err = 0; - Q_UNUSED( null_pointer ) - g_print("Fatal Error: %s\n", harmony->error->message ); - theDaemon->setError( QString( harmony->error->message ) ); - theDaemon->emitError(); - mp3tunes_harmony_disconnect(harmony, &err); - if( err ) { - g_print( "Error disconnecting: %s\n", err->message ); - /* If there is an error disconnecting something has probably gone - * very wrong and reconnection should not be attempted till the user - * re-initiates it */ - return; - } -} -void -Mp3tunesHarmonyDaemon::signalStateChangeHandler( MP3tunesHarmony* harmony, guint32 state, - gpointer null_pointer ) -{ - qDebug() << "inside signalStateChangeHandler"; - Q_UNUSED( null_pointer ) - switch ( state ) { - case MP3TUNES_HARMONY_STATE_DISCONNECTED: - g_print( "Disconnected.\n" ); - qDebug() << "Disconnected"; - theDaemon->setState( Mp3tunesHarmonyDaemon::DISCONNECTED ); - theDaemon->emitDisconnected(); - /* Do nothing here */ - break; - case MP3TUNES_HARMONY_STATE_CONNECTED: - g_print( "Connected! Waiting for download requests!\n" ); - qDebug() << "Connected! Waiting for download requests!\n"; - theDaemon->setState( Mp3tunesHarmonyDaemon::CONNECTED ); - theDaemon->emitConnected(); - /* At this point, it would be best to store the pin, if you haven't - * already, and the email in some somewhat permenant storage for - * when reauthenticating. - */ - break; - case MP3TUNES_HARMONY_STATE_WAITING_FOR_PIN: - g_print( "Connection in process!\n" ); - qDebug() << "Connection in process!\n"; - theDaemon->setState( Mp3tunesHarmonyDaemon::WAITING_FOR_PIN ); - theDaemon->emitWaitingForPin(); - /* At this point, just update the user status. */ - break; - case MP3TUNES_HARMONY_STATE_WAITING_FOR_EMAIL: - g_print( "Please login to mp3tunes.com and add the pin '%s' to your devices.\n", - mp3tunes_harmony_get_pin( harmony ) ); - qDebug() << "Please login to mp3tunes.com and add the pin '%s' to your devices. " << mp3tunes_harmony_get_pin( harmony ); - theDaemon->setState( Mp3tunesHarmonyDaemon::WAITING_FOR_EMAIL ); - theDaemon->emitWaitingForEmail( theDaemon->pin() ); - /* At this point, it would be best to store the pin in case the - * network connection drops. As well, display to the user a status - * message to have them perform the website authentication action. - */ - break; - } -} - -void -Mp3tunesHarmonyDaemon::signalDownloadReadyHandler( MP3tunesHarmony* harmony, - gpointer void_mp3tunes_harmony_download, - gpointer null_pointer ) -{ - - Q_UNUSED( harmony ) - Q_UNUSED( null_pointer ) - mp3tunes_harmony_download_t *download = ( mp3tunes_harmony_download_t* ) - void_mp3tunes_harmony_download; - Mp3tunesHarmonyDownload wrappedDownload( download ); - theDaemon->emitDownloadReady( wrappedDownload ); - mp3tunes_harmony_download_deinit( &download ); -} - -void -Mp3tunesHarmonyDaemon::signalDownloadPendingHandler( MP3tunesHarmony* harmony, - gpointer void_mp3tunes_harmony_download, - gpointer null_pointer ) -{ - - Q_UNUSED( harmony ) - Q_UNUSED( null_pointer ) - mp3tunes_harmony_download_t *download = ( mp3tunes_harmony_download_t* ) - void_mp3tunes_harmony_download; - Mp3tunesHarmonyDownload wrappedDownload( download ); - theDaemon->emitDownloadPending( wrappedDownload ); - -} - -char * -Mp3tunesHarmonyDaemon::convertToChar ( const QString &source ) const -{ - QByteArray b = source.toAscii(); - const char *c_tok = b.constData(); - char * ret = ( char * ) malloc ( strlen ( c_tok ) + 1 ); - strcpy ( ret, c_tok ); - return ret; -} diff --git a/amarok/src/services/mp3tunes/harmonydaemon/Mp3tunesHarmonyDaemon.h b/amarok/src/services/mp3tunes/harmonydaemon/Mp3tunesHarmonyDaemon.h deleted file mode 100644 index 7b7cbd5e..00000000 --- a/amarok/src/services/mp3tunes/harmonydaemon/Mp3tunesHarmonyDaemon.h +++ /dev/null @@ -1,256 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Casey Link * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef MP3TUNESHARMONYDAEMON_H -#define MP3TUNESHARMONYDAEMON_H - -#include "Mp3tunesHarmonyDownload.h" -#include "Mp3tunesHarmonyClient.h" -#include - -#include -#include - -extern "C" { - // Get libmp3tunes declarations - #include "../libmp3tunes/harmony.h" - #include "../libmp3tunes/locker.h" - #include - #include - #include - #include - #include -} - -/** - * A daemon that receives notfications from mp3tunes' - * servers about new/changed tracks that can be synced. - * - * Because this classes implements libmp3tunes which uses - * GLIB's c-style callbacks, all the callbacks must be static. - * This requires some black magic on my part to keep the OO - * facade intact. The solution is a global variable: theDaemon - * delcared after this class. Your code must #define DEFINE_HARMONY - * and instantiate a new Mp3tunesHarmonyDaemon for theDaemon. - * @author Casey Link - */ -class Mp3tunesHarmonyDaemon : public QCoreApplication -{ - Q_OBJECT - Q_CLASSINFO("D-Bus Interface", "org.kde.amarok.Mp3tunesHarmonyDaemon") - - public: - /** - * For the first time run, before we have an email and pin to authenticate - */ - Mp3tunesHarmonyDaemon( QString identifier ); - /** - * For subsequent logins - */ - Mp3tunesHarmonyDaemon( QString identifier, QString email, QString pin ); - ~Mp3tunesHarmonyDaemon(); - - /** - * Stats the daemon by intiating the connection Harmony connection. - */ - int init(); - - /** - * Sets the client type that the daemon will send signals to. - */ - void setClient( Mp3tunesHarmonyClient *client ); - - /** - * The possible states the daemon can be in. - * Before init() it is DISONNECTED - */ - enum HarmonyState { - DISCONNECTED, - CONNECTED, - WAITING_FOR_PIN, - WAITING_FOR_EMAIL - }; - - /* - * Used by the static callbacks - * DO NOT CALL THESE METHODS - */ - void setState( HarmonyState state ); - void setError( const QString &error ); - - /* - * Used by the static callbacks - * DO NOT CALL THESE METHODS - */ - void emitError(); - void emitWaitingForEmail( const QString &pin ); - void emitWaitingForPin(); - void emitConnected(); - void emitDisconnected(); - void emitDownloadReady( const Mp3tunesHarmonyDownload &download ); - void emitDownloadPending( const Mp3tunesHarmonyDownload &download ); - - signals: - /* The actual signals that get emitted */ - void waitingForEmail( const QString &pin ); - void waitingForPin(); - void connected(); - void disconnected(); - void errorSignal( const QString &error ); - - /* signalDownloadReady - * this signal is emitted when a track is ready to be downloaded. - */ - void downloadReady( const Mp3tunesHarmonyDownload &download ); - - /* signalDownloadPending - * this signal is emitted as soon as a download message is received. - * it may or may not be ready. the library sends this signal before - * adding the download to its own queue - */ - void downloadPending( const Mp3tunesHarmonyDownload &download ); - public slots: - /** - * Returns the pin - */ - QString pin() const; - - /** - * Returns the Harmony Email used for authentication - */ - QString email() const; - - /** - * Returns the latest error message. - */ - QString error() const; - - /** - * Determines if the daemon is currently connected to the harmony servers. - * @return true if the daemon is connected. - * false if the daemon is not connected. - */ - bool daemonConnected(); - - /** - * Disconnects the daemon if it is connected. - * @return true if the daemon is disconnected OR if the daemon was disconnected - * false if the breaking the connect failed - */ - bool breakConnection(); - - QString makeConnection(); - - private: - - /* Error signal handler. - * - * This signal is emitted whenever there is a user fixable error from inside the - * library. Most of these errors are from inside of the Jabber library. - * - * Whenever this signal handler is called, harmony->error will be set to a valid - * GError pointer. The message field of that structure will contain the error - * and should be displayed to the user and the connection reset by calling - * mp3tunes_harmony_disconnect and a reconnection user initiated. - */ - static void signalErrorHandler( MP3tunesHarmony* harmony, gpointer null_pointer ); - - /* State change signal handler. - * - * This signal is emitted whenever the state of the connection changes during - * the Harmony authentication process. The state variable will be set to one of - * the values of harmony_state_t with the following meanings. - * - * MP3TUNES_HARMONY_STATE_DISCONNECTED: - * The connection to the server has been disconnected. Occurs a couple of - * times during the authentication process. Nothing to act on unless was - * already in the CONNECTED state. - * - * MP3TUNES_HARMONY_STATE_CONNECTED: - * The connection completed successfully. All to be done from here is to - * associate the download handler if needed and wait for download messages. - * - * MP3TUNES_HARMONY_STATE_WAITING_FOR_PIN: - * The client has authenticated and is waiting for the response to a - * harmonyPin message. Unless there is a problem with the Conductor this - * state should be left almost immediately and moved back into disconnected - * before going to WAITING_FOR_EMAIL. Useful for having a progress message - * during authentication. - * - * MP3TUNES_HARMONY_STATE_WAITING_FOR_EMAIL: - * The client has authenticated and is waiting for a response to the - * harmonyEmail message. In this state, the action to take is to display to - * the user the pin, found by calling mp3tunes_harmony_get_pin, and request - * for them to log into mp3tunes.com and have them add the pin to their - * devices tab. Upon receiving the reply to this you will be authenticated. - */ - static void signalStateChangeHandler( MP3tunesHarmony* harmony, guint32 state, gpointer null_pointer ); - - - /* signalDownloadReadyHandler - * this signal is emitted when a track is ready to be downloaded. - */ - static void signalDownloadReadyHandler( MP3tunesHarmony* harmony, gpointer void_mp3tunes_harmony_download, gpointer null_pointer ); - - /* signalDownloadPendingHandler - * this signal is emitted as soon as a download message is received. - * it may or may not be ready. the library sends this signal before - * adding the download to its own queue - */ - static void signalDownloadPendingHandler( MP3tunesHarmony* harmony, gpointer void_mp3tunes_harmony_download, gpointer null_pointer ); - - /** - * Converts a QString into a char* - */ - char* convertToChar( const QString &source ) const; - /** - * Inits the D-Dbus interface. - */ - bool allAboardTheDBus(); - - MP3tunesHarmony * m_harmony; - QString m_identifier; // the initial identifier used for authentication - QString m_email; //used for repeat authentication - QString m_pin; //used for repeat authentication - GError *m_gerr; // master GError - - QString m_error; // error message to display to user - bool m_started; // true if the connection has been established - bool m_inited; // true if the daemon is ready to connect - HarmonyState m_state; //current state of the harmony daemon - Mp3tunesHarmonyClient *m_client; // the daemon client -}; - - -/* - * The global variable used by the static callbacks. - * G_CALLBACK() requires a pointer to a member function, - * and because this is c++ that member function must be static. - * However, since I want to edit non-static members in those - * callbacks I created a workaround by defining a global variable, - * 'theDaemon', which is an instantiation of a Mp3tunesHarmonyDaemon - * and call mutators on it from the static callbacks. - */ -#ifdef DEFINE_HARMONY -#define HARMONY -#else -#define HARMONY extern -#endif - -HARMONY Mp3tunesHarmonyDaemon* theDaemon; - -#endif - diff --git a/amarok/src/services/mp3tunes/harmonydaemon/Mp3tunesHarmonyDownload.cpp b/amarok/src/services/mp3tunes/harmonydaemon/Mp3tunesHarmonyDownload.cpp deleted file mode 100644 index 3c9505b2..00000000 --- a/amarok/src/services/mp3tunes/harmonydaemon/Mp3tunesHarmonyDownload.cpp +++ /dev/null @@ -1,155 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Casey Link * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "Mp3tunesHarmonyDownload.h" - -Mp3tunesHarmonyDownload::Mp3tunesHarmonyDownload() - : m_fileKey() - , m_fileName() - , m_fileFormat() - , m_fileSize( 0 ) - , m_artistName() - , m_albumTitle() - , m_trackTitle() - , m_trackNumber( 0 ) - , m_deviceBitrate() - , m_fileBitrate() - , m_url() -{} - -Mp3tunesHarmonyDownload::Mp3tunesHarmonyDownload( mp3tunes_harmony_download_t *download ) -{ - - m_fileKey = download->file_key; - m_fileName = download->file_name; - m_fileFormat = download->file_format; - m_fileSize = download->file_size; - m_artistName = download->artist_name ; - if( download->album_title ) - m_albumTitle = download->album_title; - else - m_albumTitle.clear(); - - m_trackTitle = download->track_title; - m_trackNumber = download->track_number; - m_deviceBitrate = download->device_bitrate; - m_fileBitrate = download->file_bitrate; - if( download->url ) - m_url = download->url; - else - m_url.clear(); -} - -Mp3tunesHarmonyDownload::Mp3tunesHarmonyDownload( const QVariantMap &map ) -{ - m_fileKey = map["fileKey"].toString(); - m_fileName = map["fileName"].toString(); - m_fileFormat = map["fileFormat"].toString(); - m_fileSize = map["fileSize"].toInt(); - m_artistName = map["artistName"].toString(); - m_albumTitle = map["albumTitle"].toString(); - m_trackTitle = map["trackTitle"].toString(); - m_trackNumber = map["trackNumber"].toInt(); - m_deviceBitrate = map["deviceBitrate"].toString(); - m_fileBitrate = map["fileBitrate"].toString(); - m_url = map["url"].toString(); -} - -Mp3tunesHarmonyDownload::~Mp3tunesHarmonyDownload() -{} - -QString -Mp3tunesHarmonyDownload::fileKey() const -{ - return m_fileKey; -} - -QString -Mp3tunesHarmonyDownload::fileName() const -{ - return m_fileName; -} - -QString -Mp3tunesHarmonyDownload::fileFormat() const -{ - return m_fileFormat; -} - -unsigned int -Mp3tunesHarmonyDownload::fileSize() const -{ - return m_fileSize; -} - -QString -Mp3tunesHarmonyDownload::artistName() const -{ - return m_artistName; -} - -QString -Mp3tunesHarmonyDownload::albumTitle() const -{ - return m_albumTitle; -} - -QString -Mp3tunesHarmonyDownload::trackTitle() const -{ - return m_trackTitle; -} - -int -Mp3tunesHarmonyDownload::trackNumber() const -{ - return m_trackNumber; -} - -QString -Mp3tunesHarmonyDownload::deviceBitrate() const -{ - return m_deviceBitrate; -} - -QString -Mp3tunesHarmonyDownload::fileBitrate() const -{ - return m_fileBitrate; -} - -QString -Mp3tunesHarmonyDownload::url() const -{ - return m_url; -} - -QVariantMap Mp3tunesHarmonyDownload::serialize() const -{ - QVariantMap map; - map["fileKey"] = m_fileKey; - map["fileName"] = m_fileName; - map["fileFormat"] = m_fileFormat; - map["fileSize"] = m_fileSize; - map["artistName"] = m_artistName; - map["albumTitle"] = m_albumTitle; - map["trackTitle"] = m_trackTitle; - map["trackNumber"] = m_trackNumber; - map["deviceBitrate"] = m_deviceBitrate; - map["fileBitrate"] = m_fileBitrate; - map["url"] = m_url; - return map; -} diff --git a/amarok/src/services/mp3tunes/harmonydaemon/Mp3tunesHarmonyDownload.h b/amarok/src/services/mp3tunes/harmonydaemon/Mp3tunesHarmonyDownload.h deleted file mode 100644 index de0aa632..00000000 --- a/amarok/src/services/mp3tunes/harmonydaemon/Mp3tunesHarmonyDownload.h +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Casey Link * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef MP3TUNESHARMONYDOWNLOAD_H -#define MP3TUNESHARMONYDOWNLOAD_H - -#include -#include -extern "C" { - // Get libmp3tunes declarations - #include "../libmp3tunes/harmony.h" -} - -/** - * A wrapper class for the libmp3tunes harmony download object. - * It contains metadata for new tracks. - * @author Casey Link - */ -class Mp3tunesHarmonyDownload { - public: - /** - * Default constructor does nothing. - */ - Mp3tunesHarmonyDownload(); - Mp3tunesHarmonyDownload( const QVariantMap &map ); - Mp3tunesHarmonyDownload( mp3tunes_harmony_download_t *download ); - ~Mp3tunesHarmonyDownload(); - - QString fileKey() const; - QString fileName() const; - QString fileFormat() const; - unsigned int fileSize() const; - QString artistName() const; - QString albumTitle() const; - QString trackTitle() const; - int trackNumber() const; - QString deviceBitrate() const; - QString fileBitrate() const; - QString url() const; - QVariantMap serialize() const; - - private: - QString m_fileKey; - QString m_fileName; - QString m_fileFormat; - unsigned int m_fileSize; - QString m_artistName; - QString m_albumTitle; - QString m_trackTitle; - int m_trackNumber; - QString m_deviceBitrate; - QString m_fileBitrate; - QString m_url; -}; - -#endif - diff --git a/amarok/src/services/mp3tunes/harmonydaemon/main.cpp b/amarok/src/services/mp3tunes/harmonydaemon/main.cpp deleted file mode 100644 index dfc723f7..00000000 --- a/amarok/src/services/mp3tunes/harmonydaemon/main.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Casey Link * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef DEFINE_HARMONY -#define DEFINE_HARMONY -#endif -#include "Mp3tunesHarmonyDaemon.h" -#include "AmarokClient.h" -#include -#include -#include -#include -#include - -int main( int argc, char *argv[] ) -{ - const KAboutData about( "amarokmp3tunesharmonydaemon", "amarok", - ki18n( "Amarok's MP3tunes Harmony Daemon" ), "0.1", - ki18n( "Handles AutoSync for the MP3tunes service in Amarok." ), KAboutData::License_GPL, - ki18n( "(C) 2008, Casey Link" ), - ki18n( "IRC:\nserver: irc.freenode.net / channels: #amarok, #amarok.de, #amarok.es, #amarok.fr\n\nFeedback:\namarok@kde.org" ), - I18N_NOOP( "http://amarok.kde.org" ) ); - - KCmdLineArgs::reset(); - KCmdLineArgs::init( argc, argv, &about ); //calls KCmdLineArgs::addStdCmdLineOptions() - - KCmdLineOptions options; - options.add("+identifier", ki18n( "The identifier the daemon should use." )); - options.add("+[email]", ki18n( "The email to be used for authentication." )); - options.add("+[pin]", ki18n( "The pin to be used for authentication." )); - KCmdLineArgs::addCmdLineOptions( options ); //add our own options - - const KCmdLineArgs* const args = KCmdLineArgs::parsedArgs(); - - QString ident; - QString email; - QString pin; - if ( args->count() < 1 || args->count() > 3 ) - return -1; - if( args->count() > 0 ) - ident = args->arg( 0 ); - if( args->count() == 3 ) - { - email = args->arg( 1 ); - pin = args->arg( 2 ); - } - - if( email.isEmpty() && pin.isEmpty() ) - theDaemon = new Mp3tunesHarmonyDaemon( ident ); - else - theDaemon = new Mp3tunesHarmonyDaemon( ident, email, pin ); - - Mp3tunesAmarokClient *client = new Mp3tunesAmarokClient(); - theDaemon->setClient( client ); - qDebug() << "Starting main event loop"; - QCoreApplication::exec(); -} - - - - - diff --git a/amarok/src/services/mp3tunes/harmonydaemon/org.kde.amarok.Mp3tunesHarmonyDaemon.xml b/amarok/src/services/mp3tunes/harmonydaemon/org.kde.amarok.Mp3tunesHarmonyDaemon.xml deleted file mode 100644 index b98c6e1f..00000000 --- a/amarok/src/services/mp3tunes/harmonydaemon/org.kde.amarok.Mp3tunesHarmonyDaemon.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/amarok/src/services/mp3tunes/libmp3tunes/README b/amarok/src/services/mp3tunes/libmp3tunes/README deleted file mode 100644 index 96a8cb2a..00000000 --- a/amarok/src/services/mp3tunes/libmp3tunes/README +++ /dev/null @@ -1,12 +0,0 @@ -This is version 1.0 of the libmp3tunes API. It is LGPLed, but hasn't been released -as of this README's initial commit. The deps are as follows: - -libxml2 - locker.c -curl - locker.c -glib - harmony.c -gobject - harmony.c -loudmouth - harmony.c - -Ask Ramblurr (unnamedrambler@gmail.com) for the original src package including -build instructions and example code. - diff --git a/amarok/src/services/mp3tunes/libmp3tunes/harmony.c b/amarok/src/services/mp3tunes/libmp3tunes/harmony.c deleted file mode 100644 index ead03453..00000000 --- a/amarok/src/services/mp3tunes/libmp3tunes/harmony.c +++ /dev/null @@ -1,888 +0,0 @@ -/* - * Copyright (C) 2008 MP3tunes, LLC - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#include -#include -#include -#include -#include "harmony.h" - -G_DEFINE_TYPE(MP3tunesHarmony, mp3tunes_harmony, G_TYPE_OBJECT); - -char *str_replace(const char *search, const char *replace, char *subject); -gboolean harmony_format_email(char **email); - -void state_change_emit(MP3tunesHarmony *harmony, guint32 state); -void error_emit(MP3tunesHarmony *harmony, gint code, const gchar* message, GError* err); - -LmHandlerResult harmony_download_callback(LmMessageHandler* handler, LmConnection *connection, LmMessage *message, gpointer void_harmony); - -LmHandlerResult harmony_get_device_pin_callback(LmMessageHandler* handler, LmConnection *connection, LmMessage *message, gpointer void_harmony); -void harmony_get_device_pin(MP3tunesHarmony *harmony); - -LmHandlerResult harmony_get_device_email_callback(LmMessageHandler* handler, LmConnection *connection, LmMessage *message, gpointer void_harmony); -void harmony_get_device_email(MP3tunesHarmony *harmony); - -void authenticate_known_callback(LmConnection* connection, gboolean success, gpointer void_harmony); -void authenticate_new_callback(LmConnection* connection, gboolean success, gpointer void_harmony); -void authenticate_unknown_callback(LmConnection* connection, gboolean success, gpointer void_harmony); - -void rebuild_connection(MP3tunesHarmony* harmony); - -void open_connection_callback(LmConnection* connection, gboolean success, gpointer void_harmony); -gboolean open_connection(MP3tunesHarmony *harmony); - -gboolean close_connection(MP3tunesHarmony *harmony); - -char *str_replace(const char *search, const char *replace, char *subject) { - char *result, *tmp, *needle; - int count, length; - - length = strlen(subject); - if (strlen(search) < strlen(replace)) { - /* We need to increase the buffer size for result a bit */ - count = 0; - tmp = subject; - - while((needle = strstr(tmp, search))) { - tmp = needle + strlen(search); - count++; - } - - length += (strlen(replace) - strlen(search)) * count; - } - - result = (char *)malloc(sizeof(char)*(length+1)); - memset(result, 0, sizeof(char) * (length + 1)); - - tmp = subject; - while((needle = strstr(tmp, search))) { - length = needle-tmp; /* Length from current index in buffer to a match */ - strncat(result, tmp, length); /* put normal (unreplaced) string data into the new buffer */ - strcat(result, replace); /* then the replacement */ - tmp = needle + strlen(search); /* Jump past the replaced text and continue */ - } - - strcat(result, tmp); /* remaining data after the last match */ - return result; -} - -gboolean harmony_format_email(char **email) { - char *tmp; - char *tmp_two; - - if (*email == NULL) return FALSE; - - tmp = str_replace("@", "_AT_", *email); - free(*email); - - tmp_two = str_replace(".", "_DOT_", tmp); - free(tmp); - - *email = tmp_two; - - return TRUE; -} - -void state_change_emit(MP3tunesHarmony *harmony, guint32 state) { - g_signal_emit(harmony, MP3TUNES_HARMONY_GET_CLASS(harmony)->state_change_signal_id, 0, state); -} - -void error_emit(MP3tunesHarmony *harmony, gint code, const gchar* message, GError* err) { - if (err) { - g_propagate_error(&harmony->error, g_error_new(MP3TUNES_HARMONY_ERROR_DOMAIN, code, "%s: %s", message, err->message)); - } else { - g_propagate_error(&harmony->error, g_error_new(MP3TUNES_HARMONY_ERROR_DOMAIN, code, "%s", message)); - } - g_signal_emit(harmony, MP3TUNES_HARMONY_GET_CLASS(harmony)->error_signal_id, 0); -} - -void download_pending_emit(MP3tunesHarmony *harmony, mp3tunes_harmony_download_t* harmony_download) { - g_print("Signal ID: %d, Download: %p\n", MP3TUNES_HARMONY_GET_CLASS(harmony)->download_pending_signal_id, harmony_download); - g_signal_emit(harmony, MP3TUNES_HARMONY_GET_CLASS(harmony)->download_pending_signal_id, 0, harmony_download); -} - -void download_ready_emit(MP3tunesHarmony *harmony, mp3tunes_harmony_download_t* harmony_download) { - g_print("Signal ID: %d, Download: %p\n", MP3TUNES_HARMONY_GET_CLASS(harmony)->download_ready_signal_id, harmony_download); - g_signal_emit(harmony, MP3TUNES_HARMONY_GET_CLASS(harmony)->download_ready_signal_id, 0, harmony_download); -} - -gboolean mp3tunes_harmony_download_init(mp3tunes_harmony_download_t **harmony_download) { - mp3tunes_harmony_download_t* hd = *harmony_download = malloc(sizeof(mp3tunes_harmony_download_t)); - if (hd == NULL) { return FALSE; } - hd->file_key = NULL; - hd->file_name = NULL; - hd->file_format = NULL; - hd->file_size = 0; - hd->artist_name = NULL; - hd->album_title = NULL; - hd->track_title = NULL; - hd->track_number = 0; - hd->device_bitrate = NULL; - hd->file_bitrate = NULL; - hd->url = NULL; - return TRUE; -} - -gboolean mp3tunes_harmony_download_deinit(mp3tunes_harmony_download_t **harmony_download) { - mp3tunes_harmony_download_t* hd = *harmony_download; - if (hd->file_key) { free(hd->file_key); } - if (hd->file_name) { free(hd->file_name); } - if (hd->file_format) { free(hd->file_format); } - - if (hd->artist_name) { free(hd->artist_name); } - if (hd->album_title) { free(hd->album_title); } - if (hd->track_title) { free(hd->track_title); } - - if (hd->device_bitrate) { free(hd->device_bitrate); } - if (hd->file_bitrate) { free(hd->file_bitrate); } - - if (hd->url) { free(hd->url); } - free(hd); - return TRUE; -} - -void mp3tunes_harmony_download_set_file_key(mp3tunes_harmony_download_t *harmony_download, char* file_key) { - harmony_download->file_key = strdup(file_key); -} - -void mp3tunes_harmony_download_set_file_name(mp3tunes_harmony_download_t *harmony_download, char* file_name) { - harmony_download->file_name = strdup(file_name); -} - -void mp3tunes_harmony_download_set_file_format(mp3tunes_harmony_download_t *harmony_download, char* file_format) { - harmony_download->file_format = strdup(file_format); -} - -void mp3tunes_harmony_download_set_file_size(mp3tunes_harmony_download_t *harmony_download, unsigned int file_size) { - harmony_download->file_size = file_size; -} - -void mp3tunes_harmony_download_set_artist_name(mp3tunes_harmony_download_t *harmony_download, char* artist_name) { - harmony_download->artist_name = strdup(artist_name); -} - -void mp3tunes_harmony_download_set_album_title(mp3tunes_harmony_download_t *harmony_download, char* album_title) { - harmony_download->album_title = strdup(album_title); -} - -void mp3tunes_harmony_download_set_track_title(mp3tunes_harmony_download_t *harmony_download, char* track_title) { - harmony_download->track_title = strdup(track_title); -} - -void mp3tunes_harmony_download_set_track_number(mp3tunes_harmony_download_t *harmony_download, int track_number) { - harmony_download->track_number = track_number; -} - -void mp3tunes_harmony_download_set_device_bitrate(mp3tunes_harmony_download_t *harmony_download, char* device_bitrate) { - if (device_bitrate) { - harmony_download->device_bitrate = strdup(device_bitrate); - } -} - -void mp3tunes_harmony_download_set_file_bitrate(mp3tunes_harmony_download_t *harmony_download, char* file_bitrate) { - if (file_bitrate) { - harmony_download->file_bitrate = strdup(file_bitrate); - } -} - -void mp3tunes_harmony_download_set_url_using_locker(mp3tunes_harmony_download_t *harmony_download, mp3tunes_locker_object_t* mp3tunes_locker) { - if ((harmony_download->device_bitrate == NULL) || (atoi(harmony_download->device_bitrate)) == 0) { - harmony_download->url = mp3tunes_locker_generate_download_url_from_file_key(mp3tunes_locker, harmony_download->file_key); - } else { - harmony_download->url = mp3tunes_locker_generate_download_url_from_file_key_and_bitrate(mp3tunes_locker, harmony_download->file_key, harmony_download->device_bitrate); - } -} - -void harmony_reprocess_queue(MP3tunesHarmony *harmony) { - mp3tunes_harmony_download_t *harmony_download = g_queue_peek_head(harmony->download_queue); - while (harmony_download != NULL && harmony->sid_state == MP3TUNES_HARMONY_SID_STATE_READY) { - harmony_download = g_queue_pop_head(harmony->download_queue); - mp3tunes_harmony_download_set_url_using_locker(harmony_download, harmony->mp3tunes_locker); - download_ready_emit(harmony, harmony_download); - harmony_download = g_queue_peek_head(harmony->download_queue); - } -} - -LmHandlerResult harmony_get_session_id_callback(LmMessageHandler* handler, LmConnection *connection, LmMessage *message, gpointer void_harmony) { - char *session_id; - MP3tunesHarmony *harmony = MP3TUNES_HARMONY(void_harmony); - LmMessageNode *harmony_session_node; - - (void)handler; - (void)connection; - - harmony_session_node = lm_message_node_get_child(message->node, "sessionId"); - if (harmony_session_node) { - session_id = g_strdup(lm_message_node_get_value(harmony_session_node)); - harmony->mp3tunes_locker->session_id = session_id; - harmony->sid_state = MP3TUNES_HARMONY_SID_STATE_READY; - - harmony_reprocess_queue(harmony); - return LM_HANDLER_RESULT_REMOVE_MESSAGE; - } - return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS; -} - -void harmony_get_session_id(MP3tunesHarmony *harmony) { - LmMessage *message_out; - LmMessageHandler *handler; - LmMessageNode *message_out_node; - GError *err = NULL; - handler = lm_message_handler_new(harmony_get_session_id_callback, (gpointer)harmony, NULL); - - message_out = lm_message_new(MP3TUNES_HARMONY_CONDUCTOR, LM_MESSAGE_TYPE_IQ); - message_out_node = lm_message_node_add_child(message_out->node, "sessionId", NULL); - lm_message_node_set_attribute(message_out_node, "xmlns", MP3TUNES_HARMONY_XMLNS); - - lm_connection_send_with_reply(harmony->connection, - message_out, - handler, - &err); - lm_message_unref(message_out); - if (err != NULL) { - error_emit(harmony, MP3TUNES_HARMONY_ERROR_MISC, "Sending session id request failed", err); - return; - } - harmony->sid_state = MP3TUNES_HARMONY_SID_STATE_WAITING; -} - -mp3tunes_harmony_download_t* mp3tunes_harmony_download_queue_pop(MP3tunesHarmony *harmony) { - if (harmony->sid_state != MP3TUNES_HARMONY_SID_STATE_READY) { - return NULL; - } - return (mp3tunes_harmony_download_t*)g_queue_pop_head(harmony->download_queue); -} - -void mp3tunes_harmony_download_failed(MP3tunesHarmony* harmony, mp3tunes_harmony_download_t* harmony_download) { - harmony->mp3tunes_locker->session_id = NULL; - harmony->sid_state = MP3TUNES_HARMONY_SID_STATE_NONE; - g_queue_push_head(harmony->download_queue, harmony_download); - if (harmony->sid_state == MP3TUNES_HARMONY_SID_STATE_READY) { - harmony_get_session_id(harmony); - } -} - -void mp3tunes_harmony_download_cancel(MP3tunesHarmony* harmony, mp3tunes_harmony_download_t* harmony_download) { - g_queue_remove(harmony->download_queue, harmony_download); -} - -void mp3tunes_harmony_add_download_to_queue(MP3tunesHarmony *harmony, mp3tunes_harmony_download_t* harmony_download) { - g_queue_push_tail(harmony->download_queue, harmony_download); - if (harmony->sid_state == MP3TUNES_HARMONY_SID_STATE_NONE) { - harmony_get_session_id(harmony); - } else if (harmony->sid_state == MP3TUNES_HARMONY_SID_STATE_READY) { - harmony_download->url = mp3tunes_locker_generate_download_url_from_file_key(harmony->mp3tunes_locker, harmony_download->file_key); - download_ready_emit(harmony, harmony_download); - } -} - -void harmony_success_reply(LmConnection *connection, LmMessage *message, GError **err) { - LmMessage *message_out; - LmMessageNode *harmony_download_node; - LmMessageNode *message_out_node; - - message_out = lm_message_new_with_sub_type(MP3TUNES_HARMONY_CONDUCTOR, LM_MESSAGE_TYPE_IQ, LM_MESSAGE_SUB_TYPE_RESULT); - lm_message_node_set_attribute(message_out->node, "id", lm_message_node_get_attribute(message->node, "id")); - message_out_node = lm_message_node_add_child(message_out->node, "success", NULL); - - harmony_download_node = lm_message_node_get_child(message->node, "download"); - if (harmony_download_node) { - lm_message_node_set_attribute(message_out_node, "messageId", lm_message_node_get_attribute(harmony_download_node, "messageId")); - } - lm_message_node_set_attribute(message_out_node, "xmlns", MP3TUNES_HARMONY_XMLNS); - - lm_connection_send(connection, message_out, err); - lm_message_unref(message_out); -} - -LmHandlerResult harmony_iq_callback(LmMessageHandler* handler, LmConnection *connection, LmMessage *message, gpointer void_harmony) { - GError *err = NULL; - MP3tunesHarmony *harmony = MP3TUNES_HARMONY(void_harmony); - LmMessageNode *harmony_download_node, *harmony_email_node; - - mp3tunes_harmony_download_t *download; - gchar *email; - - (void)handler; - - harmony_download_node = lm_message_node_get_child(message->node, "download"); - if (harmony_download_node) { - mp3tunes_harmony_download_init(&download); - mp3tunes_harmony_download_set_file_key(download, (char*)lm_message_node_get_attribute(harmony_download_node, "fileKey")); - mp3tunes_harmony_download_set_file_name(download, (char*)lm_message_node_get_attribute(harmony_download_node, "fileName")); - mp3tunes_harmony_download_set_file_format(download, (char*)lm_message_node_get_attribute(harmony_download_node, "fileFormat")); - mp3tunes_harmony_download_set_file_size(download, atoi(lm_message_node_get_attribute(harmony_download_node, "fileSize"))); - mp3tunes_harmony_download_set_track_title(download, (char*)lm_message_node_get_attribute(harmony_download_node, "trackTitle")); - mp3tunes_harmony_download_set_artist_name(download, (char*)lm_message_node_get_attribute(harmony_download_node, "artistName")); - mp3tunes_harmony_download_set_album_title(download, (char*)lm_message_node_get_attribute(harmony_download_node, "albumTitle")); - mp3tunes_harmony_download_set_device_bitrate(download, (char*)lm_message_node_get_attribute(harmony_download_node, "deviceBitrate")); - mp3tunes_harmony_download_set_file_bitrate(download, (char*)lm_message_node_get_attribute(harmony_download_node, "fileBitrate")); - - download_pending_emit(harmony, download); - - mp3tunes_harmony_add_download_to_queue(harmony, download); - - harmony_success_reply(connection, message, &err); - - if (err != NULL) { - error_emit(harmony, MP3TUNES_HARMONY_ERROR_MISC, "Sending success reply failed", err); - } - return LM_HANDLER_RESULT_REMOVE_MESSAGE; - } - - harmony_email_node = lm_message_node_get_child(message->node, "email"); - if (harmony_email_node) { - email = g_strdup(lm_message_node_get_value(harmony_email_node)); - mp3tunes_harmony_set_email(harmony, email); - g_free(email); - harmony_success_reply(connection, message, &err); - if (err != NULL) { - error_emit(harmony, MP3TUNES_HARMONY_ERROR_MISC, "Sending success reply failed", err); - } - close_connection(harmony); - open_connection(harmony); - return LM_HANDLER_RESULT_REMOVE_MESSAGE; - } - - return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS; -} - -LmHandlerResult harmony_get_device_pin_callback(LmMessageHandler* handler, LmConnection *connection, LmMessage *message, gpointer void_harmony) { - char *pin; - MP3tunesHarmony *harmony = MP3TUNES_HARMONY(void_harmony); - LmMessageNode *harmony_pin_node; - - (void)handler; - (void)connection; - - harmony_pin_node = lm_message_node_get_child(message->node, "pin"); - if (harmony_pin_node) { - pin = g_strdup(lm_message_node_get_value(harmony_pin_node)); - mp3tunes_harmony_set_pin(harmony, pin); - g_free(pin); - close_connection(harmony); - open_connection(harmony); - return LM_HANDLER_RESULT_REMOVE_MESSAGE; - } - return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS; -} - -void harmony_get_device_pin(MP3tunesHarmony *harmony) { - LmMessage *message_out; - LmMessageNode *message_out_node; - LmMessageHandler *handler; - GError *err = NULL; - handler = lm_message_handler_new(harmony_get_device_pin_callback, (gpointer)harmony, NULL); - - message_out = lm_message_new_with_sub_type(MP3TUNES_HARMONY_CONDUCTOR, LM_MESSAGE_TYPE_IQ, LM_MESSAGE_SUB_TYPE_GET); - message_out_node = lm_message_node_add_child(message_out->node, "pin", NULL); - lm_message_node_set_attribute(message_out_node, "xmlns", MP3TUNES_HARMONY_XMLNS); - - lm_connection_send_with_reply(harmony->connection, - message_out, - handler, - &err); - lm_message_unref(message_out); - if (err != NULL) { - error_emit(harmony, MP3TUNES_HARMONY_ERROR_MISC, "Sending device pin request failed", err); - return; - } - - state_change_emit(harmony, MP3TUNES_HARMONY_STATE_WAITING_FOR_PIN); -} - -LmHandlerResult harmony_get_device_email_callback(LmMessageHandler* handler, LmConnection *connection, LmMessage *message, gpointer void_harmony) { - char *email; - MP3tunesHarmony *harmony = MP3TUNES_HARMONY(void_harmony); - LmMessageNode *harmony_email_node; - - (void)handler; - (void)connection; - - harmony_email_node = lm_message_node_get_child(message->node, "email"); - if (harmony_email_node) { - email = g_strdup(lm_message_node_get_value(harmony_email_node)); - sleep(2); /* - FIXME: This exists because mp3tunes website logins cannot - exceed 1 per second. When a device connects that has been - fully authenticated previously it will rapidly reconnect - three times as it grabs pin, then email, then connects completely. - */ - mp3tunes_harmony_set_email(harmony, email); - g_free(email); - close_connection(harmony); - open_connection(harmony); - return LM_HANDLER_RESULT_REMOVE_MESSAGE; - } - return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS; -} - -void harmony_get_device_email(MP3tunesHarmony *harmony) { - LmMessage *message_out; - LmMessageHandler *handler; - LmMessageNode *message_out_node; - GError *err = NULL; - handler = lm_message_handler_new(harmony_get_device_email_callback, (gpointer)harmony, NULL); - - message_out = lm_message_new(MP3TUNES_HARMONY_CONDUCTOR, LM_MESSAGE_TYPE_IQ); - message_out_node = lm_message_node_add_child(message_out->node, "email", NULL); - lm_message_node_set_attribute(message_out_node, "xmlns", MP3TUNES_HARMONY_XMLNS); - - lm_connection_send_with_reply(harmony->connection, - message_out, - handler, - &err); - lm_message_unref(message_out); - if (err != NULL) { - error_emit(harmony, MP3TUNES_HARMONY_ERROR_MISC, "Sending device email request failed", err); - return; - } - - state_change_emit(harmony, MP3TUNES_HARMONY_STATE_WAITING_FOR_EMAIL); -} - -void authenticate_known_callback(LmConnection* connection, gboolean success, gpointer void_harmony) { - GError *err = NULL; - MP3tunesHarmony *harmony = MP3TUNES_HARMONY(void_harmony); - (void)connection; - if (success) { - harmony->connected = TRUE; - state_change_emit(harmony, MP3TUNES_HARMONY_STATE_CONNECTED); - mp3tunes_harmony_send_device_status(harmony, &err); - if (err) { - error_emit(harmony, MP3TUNES_HARMONY_ERROR_MISC, "Sending device status failed", err); - } - } else { - error_emit(harmony, MP3TUNES_HARMONY_ERROR_MISC, "Authentication failed", NULL); - close_connection(harmony); - } -} - -void authenticate_new_callback(LmConnection* connection, gboolean success, gpointer void_harmony) { - MP3tunesHarmony *harmony = MP3TUNES_HARMONY(void_harmony); - (void)connection; - if (success) { - harmony_get_device_pin(harmony); - } else { - error_emit(harmony, MP3TUNES_HARMONY_ERROR_MISC, "Authentication failed", NULL); - close_connection(harmony); - } -} - -void authenticate_unknown_callback(LmConnection* connection, gboolean success, gpointer void_harmony) { - MP3tunesHarmony *harmony = MP3TUNES_HARMONY(void_harmony); - (void)connection; - if (success) { - harmony_get_device_email(harmony); - } else { - error_emit(harmony, MP3TUNES_HARMONY_ERROR_MISC, "Authentication failed", NULL); - close_connection(harmony); - } -} - -void open_connection_callback(LmConnection* connection, gboolean success, gpointer void_harmony) { - GError *err = NULL; - MP3tunesHarmony* harmony = MP3TUNES_HARMONY(void_harmony); - LmMessage *message; - - if (!success) { - error_emit(harmony, MP3TUNES_HARMONY_ERROR_MISC, "Failed to open connection", err); - return; - } - - message = lm_message_new_with_sub_type(NULL, - LM_MESSAGE_TYPE_PRESENCE, - LM_MESSAGE_SUB_TYPE_AVAILABLE); - lm_connection_send(connection, message, &err); - lm_message_unref(message); - if (err != NULL) { - error_emit(harmony, MP3TUNES_HARMONY_ERROR_MISC, "Sending presence message failed", err); - return; - } - - /* Authenticate, known */ - if (harmony->device_email != NULL && harmony->device_pin != NULL) { - if (!lm_connection_authenticate(connection, - harmony->device_formatted_email, - g_strdup_printf("PIN-%s", harmony->device_pin), - harmony->device_pin, - (LmResultFunction) authenticate_known_callback, - harmony, - NULL, - &err)) { - if (err != NULL) { - error_emit(harmony, MP3TUNES_HARMONY_ERROR_MISC, "Sending authentication failed", err); - } - return; - } - return; - } - - /* Authenticate, unknown */ - if (harmony->device_identifier != NULL && - harmony->device_pin != NULL && - strncmp(harmony->device_pin, "NULL", 4) != 0) { - if (!lm_connection_authenticate(connection, - harmony->device_identifier, - MP3TUNES_HARMONY_DEFAULT_PASSWORD, - harmony->device_pin, - (LmResultFunction) authenticate_unknown_callback, - harmony, - NULL, - &err)) { - if (err != NULL) { - error_emit(harmony, MP3TUNES_HARMONY_ERROR_MISC, "Sending authentication failed", err); - } - return; - } - return; - } - - /* Authenticate, new */ - if (harmony->device_identifier != NULL) { - if (!lm_connection_authenticate(connection, - harmony->device_identifier, - MP3TUNES_HARMONY_DEFAULT_PASSWORD, - harmony->device_pin, - (LmResultFunction) authenticate_new_callback, - harmony, - NULL, - &err)) { - if (err != NULL) { - error_emit(harmony, MP3TUNES_HARMONY_ERROR_MISC, "Sending authentication failed", err); - } - return; - } - return; - } - - error_emit(harmony, MP3TUNES_HARMONY_ERROR_MISC, "A device identifier is required to authenticate", NULL); - return; -} - -void rebuild_connection(MP3tunesHarmony* harmony) { - gchar* jid; - - /* - if (harmony->connection != NULL) { - lm_connection_unref(harmony->connection); - harmony->connection = NULL; - } - if (harmony->harmony_download_message_handler != NULL) { - lm_message_handler_unref(harmony->harmony_download_message_handler); - harmony->harmony_download_message_handler = NULL; - } - */ - harmony->connection = lm_connection_new(harmony->host); - harmony->harmony_iq_message_handler = lm_message_handler_new(harmony_iq_callback, harmony, NULL); - - lm_connection_set_port(harmony->connection, harmony->port); - - jid = mp3tunes_harmony_get_jid(harmony); - g_debug("Logging in with: %s", jid); - lm_connection_set_jid(harmony->connection, jid); - g_free(jid); - lm_connection_register_message_handler(harmony->connection, harmony->harmony_iq_message_handler, LM_MESSAGE_TYPE_IQ, LM_HANDLER_PRIORITY_LAST); -} - -gboolean open_connection(MP3tunesHarmony *harmony) { - GError *err = NULL; - - rebuild_connection(harmony); - - if (!lm_connection_is_open(harmony->connection)) { - lm_connection_open(harmony->connection, - (LmResultFunction) open_connection_callback, - harmony, - NULL, - &err); - - if (err != NULL) { - error_emit(harmony, MP3TUNES_HARMONY_ERROR_MISC, "Opening the connection failed", err); - return FALSE; - } - } - - return TRUE; -} - -gboolean close_connection(MP3tunesHarmony *harmony) { - GError *err = NULL; - - if (lm_connection_is_open(harmony->connection)) { - lm_connection_close(harmony->connection, &err); - lm_connection_unref(harmony->connection); - if (err != NULL) { - error_emit(harmony, MP3TUNES_HARMONY_ERROR_MISC, "Closing the connection failed", err); - return FALSE; - } -/* return TRUE; */ -/* state_change_emit(harmony, MP3TUNES_HARMONY_STATE_DISCONNECTED); */ - } - - return TRUE; -} - -gboolean mp3tunes_harmony_disconnect(MP3tunesHarmony *harmony, GError** err) { - gboolean success = close_connection(harmony); - harmony->connected = FALSE; - if (success == FALSE) { - err = &harmony->error; - return success; - } - return success; -} - -gboolean mp3tunes_harmony_connect(MP3tunesHarmony* harmony, GError** err) { - gboolean success = FALSE; - if (harmony->connected) { - return TRUE; - } - - success = open_connection(harmony); - - if (success == FALSE) { - err = &harmony->error; - mp3tunes_harmony_disconnect(harmony, err); - return success; - } - return success; -} - -void mp3tunes_harmony_send_device_status(MP3tunesHarmony *harmony, GError **err) { - LmMessage *message_out; - /*LmMessageHandler *handler;*/ - LmMessageNode* status_message; - - GList *current = NULL; - mp3tunes_harmony_device_attribute_t *da; - - char* name = NULL; - char* value = NULL; - - /*handler = lm_message_handler_new(harmony_get_device_email_callback, (gpointer)harmony, NULL);*/ - - message_out = lm_message_new_with_sub_type(MP3TUNES_HARMONY_CONDUCTOR, LM_MESSAGE_TYPE_IQ, LM_MESSAGE_SUB_TYPE_SET); - status_message = lm_message_node_add_child(message_out->node, "deviceStatus", NULL); - lm_message_node_set_attribute(status_message, "xmlns", MP3TUNES_HARMONY_XMLNS); - - current = g_list_first(harmony->device_attributes); - while (current != NULL) { - da = (mp3tunes_harmony_device_attribute_t*) current->data; - name = da->attribute_name; - if (da->attribute_value_type == MP3TUNES_HARMONY_DEVICE_ATTRIBUTE_TYPE_STRING) { - value = g_strdup(da->attribute_string_value); - } else if (da->attribute_value_type == MP3TUNES_HARMONY_DEVICE_ATTRIBUTE_TYPE_INT) { - value = g_strdup_printf("%lld", da->attribute_int_value); - } - lm_message_node_set_attribute(status_message, name, value); - g_free(value); - current = g_list_next(current); - } - - lm_connection_send(harmony->connection, message_out, err); - lm_message_unref(message_out); - if (err != NULL) { - return; - } -} - -void mp3tunes_harmony_set_identifier(MP3tunesHarmony *harmony, char *identifier) { - if (harmony->device_identifier != NULL) { - free(harmony->device_identifier); - } - harmony->device_identifier = g_strdup(identifier); -} - -void mp3tunes_harmony_set_pin(MP3tunesHarmony *harmony, const char *pin) { - if (harmony->device_pin != NULL) { - free(harmony->device_pin); - } - harmony->device_pin = g_strdup(pin); -} - -void mp3tunes_harmony_set_email(MP3tunesHarmony *harmony, char *email) { - if (harmony->device_email != NULL) { - free(harmony->device_email); - free(harmony->device_formatted_email); - } - harmony->device_email = g_strdup(email); - harmony->device_formatted_email = g_strdup(email); - harmony_format_email(&harmony->device_formatted_email); -} - -void mp3tunes_harmony_set_device_attribute(MP3tunesHarmony *harmony, const char *attribute, ...) { - va_list argp; - mp3tunes_harmony_device_attribute_t* da; - - GList *current = NULL; - mp3tunes_harmony_device_attribute_t *current_da; - - da = (mp3tunes_harmony_device_attribute_t*)malloc(sizeof(mp3tunes_harmony_device_attribute_t)); - if (da == NULL) - return; - - va_start(argp, attribute); - - if (strcmp(attribute, "device-description") == 0) { - da->attribute_name = g_strdup("deviceDescription"); - da->attribute_string_value = g_strdup(va_arg(argp, char *)); - da->attribute_value_type = MP3TUNES_HARMONY_DEVICE_ATTRIBUTE_TYPE_STRING; - } else if (strcmp(attribute, "total-bytes") == 0) { - da->attribute_name = g_strdup("total-bytes"); - da->attribute_int_value = va_arg(argp, long long int); - da->attribute_value_type = MP3TUNES_HARMONY_DEVICE_ATTRIBUTE_TYPE_INT; - } else if (strcmp(attribute, "available-bytes") == 0) { - da->attribute_name = g_strdup("available-bytes"); - da->attribute_int_value = va_arg(argp, long long int); - da->attribute_value_type = MP3TUNES_HARMONY_DEVICE_ATTRIBUTE_TYPE_INT; - } else { - va_end(argp); - free(da); - return; - } - - current = g_list_first(harmony->device_attributes); - while (current != NULL) { - current_da = (mp3tunes_harmony_device_attribute_t*) current->data; - if (strcmp((current_da->attribute_name), da->attribute_name) == 0) { - harmony->device_attributes = g_list_insert_before(harmony->device_attributes, current, da); - harmony->device_attributes = g_list_remove(harmony->device_attributes, current_da); - va_end(argp); - return; - } - current = g_list_next(current); - } - - harmony->device_attributes = g_list_prepend(harmony->device_attributes, da); - va_end(argp); - return; -} - -char *mp3tunes_harmony_get_identifier(MP3tunesHarmony *harmony) { - return harmony->device_identifier; -} - -char *mp3tunes_harmony_get_pin(MP3tunesHarmony *harmony) { - return harmony->device_pin; -} - -char *mp3tunes_harmony_get_email(MP3tunesHarmony *harmony) { - return harmony->device_email; -} - -char *mp3tunes_harmony_get_jid(MP3tunesHarmony *harmony) { - if (harmony->device_formatted_email != NULL && harmony->device_pin != NULL) { - return g_strdup_printf("%s@%s/%s", harmony->device_formatted_email, MP3TUNES_HARMONY_JID_HOST, harmony->device_pin); - } - if (harmony->device_identifier != NULL && - harmony->device_pin != NULL && - strncmp(harmony->device_pin, "NULL", 4) != 0) { - return g_strdup_printf("%s@%s/%s", harmony->device_identifier, MP3TUNES_HARMONY_JID_HOST, harmony->device_pin); - } - if (harmony->device_identifier != NULL) { - return g_strdup_printf("%s@%s/%s", harmony->device_identifier, MP3TUNES_HARMONY_JID_HOST, harmony->device_pin); - } - return NULL; -} - -MP3tunesHarmony *mp3tunes_harmony_new(void) { - return MP3TUNES_HARMONY(g_object_new(MP3TUNES_TYPE_HARMONY, NULL)); -} - -static void mp3tunes_harmony_class_init(MP3tunesHarmonyClass *klass) { - klass->state_change_signal_id = g_signal_new("state_change", - G_TYPE_FROM_CLASS(klass), - G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE, - 0, - NULL, - NULL, - g_cclosure_marshal_VOID__UINT, - G_TYPE_NONE, - 1, - G_TYPE_UINT); - - klass->error_signal_id = g_signal_new("error", - G_TYPE_FROM_CLASS(klass), - G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE, - 0, - NULL, - NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, - 0); - - klass->download_pending_signal_id = g_signal_new("download_pending", - G_TYPE_FROM_CLASS(klass), - G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE, - 0, - NULL, - NULL, - g_cclosure_marshal_VOID__POINTER, - G_TYPE_NONE, - 1, - G_TYPE_POINTER); - - klass->download_ready_signal_id = g_signal_new("download_ready", - G_TYPE_FROM_CLASS(klass), - G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE, - 0, - NULL, - NULL, - g_cclosure_marshal_VOID__POINTER, - G_TYPE_NONE, - 1, - G_TYPE_POINTER); -} - -static void mp3tunes_harmony_init(MP3tunesHarmony *self) { - char *port; - self->connected = FALSE; - - mp3tunes_locker_init(&self->mp3tunes_locker, "7794175043"); - - self->download_queue = g_queue_new(); - - self->sid_state = MP3TUNES_HARMONY_SID_STATE_NONE; - - self->error = NULL; - - self->device_identifier = NULL; - self->device_pin = NULL; - mp3tunes_harmony_set_pin(self, "NULL"); - self->device_email = NULL; - - self->device_attributes = NULL; - - self->host = getenv("MP3TUNES_HARMONY_HOST"); - if(self->host == NULL) { - self->host = MP3TUNES_HARMONY_HOST; - } - - port = getenv("MP3TUNES_HARMONY_PORT"); - if(port == NULL) { - self->port = MP3TUNES_HARMONY_PORT; - } else { - self->port = atoi(port); - free(port); - } - - self->connection = NULL; - self->harmony_iq_message_handler = NULL; -} diff --git a/amarok/src/services/mp3tunes/libmp3tunes/harmony.h b/amarok/src/services/mp3tunes/libmp3tunes/harmony.h deleted file mode 100644 index 1e4648b0..00000000 --- a/amarok/src/services/mp3tunes/libmp3tunes/harmony.h +++ /dev/null @@ -1,144 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 MP3tunes, LLC * - * * - * This program is free software; you can redistribute it and/or modify it under * - * the terms of the GNU Library General Public License as published by the Free * - * Software Foundation; either version 2.1 of the License, or (at your option) any * - * later version. * - * * - * This program 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 Library General Public License along with * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef __HARMONY_H -#define __HARMONY_H - -#include - -#include -#include -#include "locker.h" -#include "loudmouth/loudmouth.h" - -G_BEGIN_DECLS - - -#define MP3TUNES_HARMONY_HOST "harmony.mp3tunes.com" -#define MP3TUNES_HARMONY_JID_HOST "mp3tunes.com" -#define MP3TUNES_HARMONY_PORT 5222 -#define MP3TUNES_HARMONY_CONDUCTOR "harmony_conductor@mp3tunes.com/harmony" -#define MP3TUNES_HARMONY_DEFAULT_PASSWORD "harmony" -#define MP3TUNES_HARMONY_XMLNS "http://www.mp3tunes.com/api/harmony" - -enum { - MP3TUNES_HARMONY_ERROR_MISC -}; - -typedef enum { - MP3TUNES_HARMONY_STATE_DISCONNECTED, - MP3TUNES_HARMONY_STATE_CONNECTED, - MP3TUNES_HARMONY_STATE_WAITING_FOR_PIN, - MP3TUNES_HARMONY_STATE_WAITING_FOR_EMAIL -} mp3tunes_harmony_state_t; - -typedef enum { - MP3TUNES_HARMONY_SID_STATE_NONE, - MP3TUNES_HARMONY_SID_STATE_WAITING, - MP3TUNES_HARMONY_SID_STATE_READY -} mp3tunes_harmony_sid_state_t; - -typedef enum { - MP3TUNES_HARMONY_DEVICE_ATTRIBUTE_TYPE_STRING, - MP3TUNES_HARMONY_DEVICE_ATTRIBUTE_TYPE_INT -} mp3tunes_harmony_device_attribute_type_t; - -typedef struct { - char* attribute_name; - char* attribute_string_value; - long long int attribute_int_value; - mp3tunes_harmony_device_attribute_type_t attribute_value_type; -} mp3tunes_harmony_device_attribute_t; - -typedef struct { - char* file_key; - char* file_name; - char* file_format; - unsigned int file_size; - char* artist_name; - char* album_title; - char* track_title; - int track_number; - char* device_bitrate; - char* file_bitrate; - char* url; -} mp3tunes_harmony_download_t; - -int mp3tunes_harmony_download_init(mp3tunes_harmony_download_t **harmony_download_t); -int mp3tunes_harmony_download_deinit(mp3tunes_harmony_download_t **harmony_download_t); - -typedef struct { - GObject parent; - LmConnection *connection; - LmMessageHandler *harmony_iq_message_handler; - - mp3tunes_locker_object_t* mp3tunes_locker; - - GQueue *download_queue; - - gboolean connected; - char *device_identifier; - char *device_pin; - char *device_email; - char *device_formatted_email; - const char *host; - int port; - mp3tunes_harmony_sid_state_t sid_state; - GList *device_attributes; - GError *error; -} MP3tunesHarmony; - -typedef struct { - GObjectClass parent; - - guint state_change_signal_id; - guint error_signal_id; - guint download_pending_signal_id; - guint download_ready_signal_id; -} MP3tunesHarmonyClass; - -#define MP3TUNES_HARMONY_ERROR_DOMAIN g_quark_from_string("MP3TUNES_HARMONY") - -#define MP3TUNES_TYPE_HARMONY (mp3tunes_harmony_get_type ()) -#define MP3TUNES_HARMONY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MP3TUNES_TYPE_HARMONY, MP3tunesHarmony)) -#define MP3TUNES_HARMONY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MP3TUNES_TYPE_HARMONY, MP3tunesHarmonyClass)) -#define MP3TUNES_IS_HARMONY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),MP3TUNES_TYPE_HARMONY)) -#define MP3TUNES_IS_HARMONY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MP3TUNES_TYPE_HARMONY)) -#define MP3TUNES_HARMONY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MP3TUNES_TYPE_HARMONY, MP3tunesHarmonyClass)) - -MP3tunesHarmony* mp3tunes_harmony_new(void); -GType mp3tunes_harmony_get_type(void); - -void mp3tunes_harmony_set_pin(MP3tunesHarmony *harmony, const char *pin); -void mp3tunes_harmony_set_email(MP3tunesHarmony *harmony, char *email); -void mp3tunes_harmony_set_identifier(MP3tunesHarmony *harmony, char *email); -void mp3tunes_harmony_set_device_attribute(MP3tunesHarmony *harmony, const char *attribute, ...); - -char *mp3tunes_harmony_get_pin(MP3tunesHarmony *harmony); -char *mp3tunes_harmony_get_email(MP3tunesHarmony *harmony); -char *mp3tunes_harmony_get_identifier(MP3tunesHarmony *harmony); -char *mp3tunes_harmony_get_jid(MP3tunesHarmony *harmony); - -gboolean mp3tunes_harmony_connect(MP3tunesHarmony *harmony, GError** err); -gboolean mp3tunes_harmony_disconnect(MP3tunesHarmony *harmony, GError** err); - -void mp3tunes_harmony_send_device_status(MP3tunesHarmony *harmony, GError **err); - -mp3tunes_harmony_download_t* mp3tunes_harmony_download_queue_pop(MP3tunesHarmony *harmony); - -G_END_DECLS - -#endif diff --git a/amarok/src/services/mp3tunes/libmp3tunes/locker.c b/amarok/src/services/mp3tunes/libmp3tunes/locker.c deleted file mode 100644 index 04c7ce25..00000000 --- a/amarok/src/services/mp3tunes/libmp3tunes/locker.c +++ /dev/null @@ -1,1535 +0,0 @@ - /* - * Copyright (C) 2008 MP3tunes, LLC - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#endif -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "locker.h" -#include "md5.h" - -typedef struct { - char *data; - size_t size; - int offset; -} chunk_t; - -typedef struct { - CURL *curl; - char *url; -} request_t; - -void chunk_init(chunk_t** chunk) { - chunk_t *c = *chunk = (chunk_t*)malloc(sizeof(chunk_t)); - c->data = NULL; - c->size = 0; -} - -void chunk_set_data(chunk_t* chunk, char* data) { - chunk->data = data; - chunk->size = strlen(data); -} - -void chunk_deinit(chunk_t** chunk) { - chunk_t *c = *chunk; - free(c->data); - free(c); -} - -struct xml_xpath_s { - xmlDocPtr document; - xmlXPathContextPtr xpath_ctx; - xmlNodePtr context; -}; - -typedef struct xml_xpath_s xml_xpath_t; - -size_t write_chunk_callback( void *ptr, size_t size, size_t nmemb, void *data ) { - size_t realsize = size * nmemb; - chunk_t *chunk = (chunk_t *)data; - chunk->data = (char *)realloc( chunk->data, chunk->size + realsize + 1 ); - if( chunk->data != NULL ) { - memcpy( &(chunk->data[ chunk->size ]), ptr, realsize ); - chunk->size += realsize; - chunk->data[ chunk->size ] = 0; - } - - return realsize; -} - -xml_xpath_t* xml_xpath_init(xmlDocPtr document) { - xml_xpath_t *result = malloc(sizeof(xml_xpath_t)); - if (result == NULL) - return NULL; - - result->document = document; - result->xpath_ctx = xmlXPathNewContext(result->document); - if(result->xpath_ctx == NULL) { - xmlFreeDoc(result->document); - free(result); - return NULL; - } - result->context = NULL; - - return result; -} - -xml_xpath_t* xml_xpath_context_init(xml_xpath_t* xml_xpath, xmlNodePtr node) { - xml_xpath_t *result = malloc(sizeof(xml_xpath_t)); - if (result == NULL) - return NULL; - - result->document = xml_xpath->document; - result->xpath_ctx = xmlXPathNewContext(result->document); - if(result->xpath_ctx == NULL) { - xmlFreeDoc(result->document); - free(result); - return NULL; - } - result->xpath_ctx->node = node; - result->context = node; - - return result; -} - -void xml_xpath_deinit(xml_xpath_t* xml_xpath) { - xmlXPathFreeContext(xml_xpath->xpath_ctx); - if (xml_xpath->context == NULL) { - xmlFreeDoc(xml_xpath->document); - } - free(xml_xpath); -} - -xmlXPathObjectPtr xml_xpath_query(xml_xpath_t *xml_xpath, const char* xpath_expression) { - xmlXPathObjectPtr xpath_obj; - - xpath_obj = xmlXPathEvalExpression((xmlChar*)xpath_expression, xml_xpath->xpath_ctx); - if (xpath_obj == NULL) { - return NULL; - } - if (xpath_obj->type != XPATH_NODESET) { - xmlXPathFreeObject(xpath_obj); - return NULL; - } - return xpath_obj; -} - -char* xml_get_text_from_nodeset(xmlNodeSetPtr nodeset) { - xmlNodePtr node; - xmlNodePtr child; - int total_nodes; - char* result = NULL; - total_nodes = (nodeset) ? nodeset->nodeNr : 0; - - if (total_nodes != 1) { - return NULL; - } - - if (nodeset->nodeTab[0]->type != XML_ELEMENT_NODE) { - return NULL; - } - - node = nodeset->nodeTab[0]; - child = node->children; - while (child && (XML_TEXT_NODE != child->type)) - child = child->next; - if (child && (XML_TEXT_NODE == child->type)) { - result = strdup((char*)child->content); - } - return result; -} - -static char* xml_xpath_get_string(xml_xpath_t *xml_xpath, const char* xpath_expression) { - xmlXPathObjectPtr xpath_obj; - char* result = NULL; - - xpath_obj = xml_xpath_query(xml_xpath, xpath_expression); - if (xpath_obj == NULL) - return NULL; - - result = xml_get_text_from_nodeset(xpath_obj->nodesetval); - - xmlXPathFreeObject(xpath_obj); - - return result; -} - -int xml_xpath_get_integer(xml_xpath_t *xml_xpath, const char* xpath_expression) { - int result = 0; - char* str = xml_xpath_get_string(xml_xpath, xpath_expression); - if (str != NULL) { - result = atoi(str); - } - free(str); - return result; -} - -float xml_xpath_get_float(xml_xpath_t *xml_xpath, const char* xpath_expression) { - float result = 0.0; - char* str = xml_xpath_get_string(xml_xpath, xpath_expression); - if (str != NULL) { - result = atof(str); - } - free(str); - return result; -} - -int mp3tunes_locker_init( mp3tunes_locker_object_t **obj, const char *partner_token ) { - mp3tunes_locker_object_t *o = *obj = (mp3tunes_locker_object_t*)malloc(sizeof(mp3tunes_locker_object_t)); - memset(o, 0, sizeof(*o)); - - o->partner_token = strdup(partner_token); - o->session_id = NULL; - o->error_message = NULL; - - o->server_api = getenv("MP3TUNES_SERVER_API"); - if(o->server_api == NULL) { - o->server_api = strdup(MP3TUNES_SERVER_API_URL); - } - - o->server_content = getenv("MP3TUNES_SERVER_CONTENT"); - if(o->server_content == NULL) { - o->server_content = strdup(MP3TUNES_SERVER_CONTENT_URL); - } - - o->server_login = getenv("MP3TUNES_SERVER_LOGIN"); - if(o->server_login == NULL) { - o->server_login = strdup(MP3TUNES_SERVER_LOGIN_URL); - } - - return TRUE; -} - -int mp3tunes_locker_deinit( mp3tunes_locker_object_t **obj ) { - mp3tunes_locker_object_t *o = *obj; - free(o->partner_token); - free(o->session_id); - free(o->error_message); - free(o); - return TRUE; -} - -void mp3tunes_request_init(request_t **request) { - request_t *r = *request = malloc(sizeof(request_t)); - r->curl = curl_easy_init(); - r->url = NULL; -} - -void mp3tunes_request_deinit(request_t **request) { - request_t *r = *request; - curl_easy_cleanup(r->curl); - free(r->url); - free(r); -} - -static request_t* mp3tunes_locker_api_generate_request_valist(mp3tunes_locker_object_t *obj, int server, const char* path, const char* first_name, va_list argp) { - request_t *request; - char *server_url; - char *name, *value; - char *encoded_name, *encoded_value; - - mp3tunes_request_init(&request); - - switch (server) { - case MP3TUNES_SERVER_LOGIN: - server_url = obj->server_login; - break; - case MP3TUNES_SERVER_CONTENT: - server_url = obj->server_content; - break; - case MP3TUNES_SERVER_API: - server_url = obj->server_api; - break; - default: - mp3tunes_request_deinit(&request); - return NULL; - break; - } - - char *url = 0; - size_t url_size = asprintf(&url, "http://%s/%s?", server_url, path) +1; - name = (char*) first_name; - while (name) { - char *url_part; - - value = va_arg(argp, char*); - - encoded_name = curl_easy_escape(request->curl, name, 0); - encoded_value = curl_easy_escape(request->curl, value, 0); - size_t url_part_size = asprintf(&url_part, "%s=%s&", encoded_name, encoded_value); - curl_free(encoded_name); - curl_free(encoded_value); - - url = realloc(url, url_size += url_part_size); - strcat(url, url_part); - - name = va_arg(argp, char*); - } - - char *end_url_part = NULL; - size_t end_url_part_size = 0; - if (server != MP3TUNES_SERVER_LOGIN) { - if (obj->session_id != NULL) { - if (server == MP3TUNES_SERVER_API) { - end_url_part_size = asprintf(&end_url_part, "output=xml&sid=%s&partner_token=%s", obj->session_id, obj->partner_token); - } else { - end_url_part_size = asprintf(&end_url_part, "sid=%s&partner_token=%s", obj->session_id, obj->partner_token); - } - } else { - printf("Failed because of no session id\n"); - free(url); - mp3tunes_request_deinit(&request); - return NULL; - } - } else { - end_url_part_size = asprintf(&end_url_part, "output=xml&partner_token=%s", obj->partner_token); - } - url = realloc(url, url_size += end_url_part_size); - strcat(url, end_url_part); - - request->url = url; - return request; - -} - -static request_t* mp3tunes_locker_api_generate_request(mp3tunes_locker_object_t *obj, int server, const char* path, const char* first_name, ...) { - va_list argp; - request_t *request; - va_start(argp, first_name); - request = mp3tunes_locker_api_generate_request_valist(obj, server, path, first_name, argp); - va_end(argp); - return request; -} - -static xml_xpath_t* mp3tunes_locker_api_simple_fetch(mp3tunes_locker_object_t *obj, int server, const char* path, const char* first_name, ...) { - request_t *request; - CURLcode res; - chunk_t *chunk; - va_list argp; - - chunk_init(&chunk); - - va_start(argp, first_name); - - request = mp3tunes_locker_api_generate_request_valist(obj, server, path, first_name, argp); - - va_end(argp); - - if (request == NULL) { - chunk_deinit(&chunk); - return NULL; - } - - curl_easy_setopt( request->curl, CURLOPT_URL, request->url ); - curl_easy_setopt( request->curl, CURLOPT_WRITEFUNCTION, write_chunk_callback ); - curl_easy_setopt( request->curl, CURLOPT_WRITEDATA, (void *)chunk ); - curl_easy_setopt( request->curl, CURLOPT_USERAGENT, "liboboe/1.0" ); - curl_easy_setopt( request->curl, CURLOPT_NOPROGRESS, 1 ); - - res = curl_easy_perform(request->curl); -/* curl_easy_cleanup(request->curl); */ - mp3tunes_request_deinit(&request); - - if (res != CURLE_OK) { - chunk_deinit(&chunk); - return NULL; - } - - if (chunk->data == NULL) { - return NULL; - } - - /*printf("Fetch result:\n%s\n", chunk->data);*/ - - xmlDocPtr document = xmlParseDoc((xmlChar*)chunk->data); - - chunk_deinit(&chunk); - - if (document == NULL) { - return NULL; - } - - return xml_xpath_init(document); -} - -static xml_xpath_t* mp3tunes_locker_api_post_fetch(mp3tunes_locker_object_t *obj, int server, const char* path, char* post_data) { - request_t *request; - CURLcode res; - chunk_t *chunk; - - chunk_init(&chunk); - - request = mp3tunes_locker_api_generate_request(obj, server, path, NULL); - if (request == NULL) { - chunk_deinit(&chunk); - return NULL; - } - - curl_easy_setopt( request->curl, CURLOPT_URL, request->url ); - curl_easy_setopt( request->curl, CURLOPT_WRITEFUNCTION, write_chunk_callback ); - curl_easy_setopt( request->curl, CURLOPT_WRITEDATA, (void *)chunk ); - curl_easy_setopt( request->curl, CURLOPT_USERAGENT, "liboboe/1.0" ); - curl_easy_setopt( request->curl, CURLOPT_POSTFIELDS, post_data); - curl_easy_setopt( request->curl, CURLOPT_NOPROGRESS, 1 ); - - res = curl_easy_perform(request->curl); -/* curl_easy_cleanup(request->curl); */ - mp3tunes_request_deinit(&request); - - if (res != CURLE_OK) { - chunk_deinit(&chunk); - return NULL; - } - - if (chunk->data == NULL) { - return NULL; - } - - printf("Fetch result:\n%s\n", chunk->data); - - xmlDocPtr document = xmlParseDoc((xmlChar*)chunk->data); - - chunk_deinit(&chunk); - - if (document == NULL) { - return NULL; - } - - return xml_xpath_init(document); -} - -char* mp3tunes_locker_generate_download_url_from_file_key(mp3tunes_locker_object_t *obj, char *file_key) { - request_t *request; - char *path = malloc(256*sizeof(char)); - char *ret; - snprintf(path, 256, "storage/lockerget/%s", file_key); - request = mp3tunes_locker_api_generate_request(obj, MP3TUNES_SERVER_CONTENT, path, NULL); - ret = request->url; request->url = NULL; - free(path); - mp3tunes_request_deinit(&request); - return ret; -} - -char* mp3tunes_locker_generate_download_url_from_file_key_and_bitrate(mp3tunes_locker_object_t *obj, char *file_key, char* bitrate) { - request_t *request; - char *path = malloc(256*sizeof(char)); - char *ret; - snprintf(path, 256, "storage/lockerget/%s", file_key); - request = mp3tunes_locker_api_generate_request(obj, MP3TUNES_SERVER_CONTENT, path, "bitrate", bitrate, NULL); - ret = request->url; request->url = NULL; - free(path); - mp3tunes_request_deinit(&request); - return ret; -} - - -int mp3tunes_locker_login(mp3tunes_locker_object_t *obj, const char* username, const char* password) { - xml_xpath_t* xml_xpath; - char *status, *session_id; - - xml_xpath = mp3tunes_locker_api_simple_fetch(obj, MP3TUNES_SERVER_LOGIN, "api/v1/login/", "username", username, "password", password, NULL); - - if (xml_xpath == NULL) { - return -2; - } - - status = xml_xpath_get_string(xml_xpath, "/mp3tunes/status"); - - if (status[0] != '1') { - /*printf("status is %s\n", status);*/ - char* error = xml_xpath_get_string(xml_xpath, "/mp3tunes/errorMessage"); - /*printf("error is %s\n", error);*/ - obj->error_message = error; - free(status); - xml_xpath_deinit(xml_xpath); - return -1; - } - free(status); - - session_id = xml_xpath_get_string(xml_xpath, "/mp3tunes/session_id"); - obj->username = strdup(username); - obj->password = strdup(password); - obj->session_id = session_id; - xml_xpath_deinit(xml_xpath); - - return 0; -} - -int mp3tunes_locker_session_valid(mp3tunes_locker_object_t *obj) { - - request_t *request; - CURLcode res; - chunk_t *chunk; - - chunk_init(&chunk); - - request = mp3tunes_locker_api_generate_request(obj, MP3TUNES_SERVER_API, "api/v1/accountData", NULL); - if (request == NULL) { - chunk_deinit(&chunk); - return -1; - } - - curl_easy_setopt( request->curl, CURLOPT_URL, request->url ); - curl_easy_setopt( request->curl, CURLOPT_WRITEFUNCTION, write_chunk_callback ); - curl_easy_setopt( request->curl, CURLOPT_WRITEDATA, (void *)chunk ); - curl_easy_setopt( request->curl, CURLOPT_NOBODY, 1 ); - curl_easy_setopt( request->curl, CURLOPT_USERAGENT, "liboboe/1.0" ); - curl_easy_setopt( request->curl, CURLOPT_HEADER, 1 ); - curl_easy_setopt( request->curl, CURLOPT_NOPROGRESS, 1 ); - - res = curl_easy_perform(request->curl); -/* curl_easy_cleanup(request->curl); */ - mp3tunes_request_deinit(&request); - - if (res != CURLE_OK) { - chunk_deinit(&chunk); - return -1; - } - - if (chunk->data == NULL) { - return -1; - } - - char name[] = "X-MP3tunes-ErrorNo"; - char value[] = "401001"; - char *result = strstr (chunk->data, name); - if (result != 0) - { - int i = strcspn(result, "\n"); - char *result1 = malloc(i + 1); - if (result1 == NULL) - return -1; - - /* ensure result1 is null-terminated */ - snprintf(result1, i+1, "%s", result); - /*printf("Header String: %s\n", result1);*/ - result = strstr(result1, value); - free(result1); - if (result != 0) /* i.e., value could not be located hence there is no 404 error. */ - return -1; /* session is invalid*/ - } - - /*printf("Fetch result:\n%s\n", chunk->data);*/ - return 0; /* session is valid*/ -} - -int mp3tunes_locker_list_init(struct mp3tunes_locker_list_s **list) { - struct mp3tunes_locker_list_s *l = *list = (struct mp3tunes_locker_list_s*)malloc(sizeof(struct mp3tunes_locker_list_s)); - l->last_id = 0; - l->first = l->last = NULL; - return 0; -} - -int mp3tunes_locker_track_list_init(mp3tunes_locker_track_list_t **list) { - return mp3tunes_locker_list_init((struct mp3tunes_locker_list_s**)list); -} - -int mp3tunes_locker_artist_list_init(mp3tunes_locker_artist_list_t **list) { - return mp3tunes_locker_list_init((struct mp3tunes_locker_list_s**)list); -} - -int mp3tunes_locker_album_list_init(mp3tunes_locker_album_list_t **list) { - return mp3tunes_locker_list_init((struct mp3tunes_locker_list_s**)list); -} - -int mp3tunes_locker_playlist_list_init(mp3tunes_locker_playlist_list_t **list) { - return mp3tunes_locker_list_init((struct mp3tunes_locker_list_s**)list); -} - -int mp3tunes_locker_list_add(struct mp3tunes_locker_list_s **list, void* value) { - struct mp3tunes_locker_list_s *l = *list; - mp3tunes_locker_list_item_t *item = (mp3tunes_locker_list_item_t*)malloc(sizeof(mp3tunes_locker_list_item_t)); - item->id = l->last_id++; - item->prev = l->last; - item->next = NULL; - item->value = value; - - if (l->first) { - l->last = item->prev->next = item; - } else { - l->first = l->last = item; - } - - return 0; -} - -int mp3tunes_locker_track_list_add(mp3tunes_locker_track_list_t **list, mp3tunes_locker_track_t *track) { - return mp3tunes_locker_list_add((struct mp3tunes_locker_list_s**)list, (void*)track); -} - -int mp3tunes_locker_artist_list_add(mp3tunes_locker_artist_list_t **list, mp3tunes_locker_artist_t *artist) { - return mp3tunes_locker_list_add((struct mp3tunes_locker_list_s**)list, (void*)artist); -} - -int mp3tunes_locker_album_list_add(mp3tunes_locker_album_list_t **list, mp3tunes_locker_album_t *album) { - return mp3tunes_locker_list_add((struct mp3tunes_locker_list_s**)list, (void*)album); -} - -int mp3tunes_locker_playlist_list_add(mp3tunes_locker_playlist_list_t **list, mp3tunes_locker_playlist_t *album) { - return mp3tunes_locker_list_add((struct mp3tunes_locker_list_s**)list, (void*)album); -} - -int mp3tunes_locker_list_deinit(struct mp3tunes_locker_list_s **list) { - struct mp3tunes_locker_list_s *l = *list; - if (l) { - mp3tunes_locker_list_item_t *list_item = l->first; - while(l->first) { - list_item = l->first->next; - free(l->first); - l->first = list_item; - } - free(l); - return 0; - } - return -1; -} - -int mp3tunes_locker_track_list_deinit(mp3tunes_locker_track_list_t **track_list) { - mp3tunes_locker_track_list_t *list = *track_list; - mp3tunes_locker_list_item_t *track_item = list->first; - mp3tunes_locker_track_t *track; - - while (track_item != NULL) { - track = (mp3tunes_locker_track_t*)track_item->value; - free(track->trackTitle); - free(track->trackFileName); - free(track->trackFileKey); - free(track->downloadURL); - free(track->playURL); - free(track->albumTitle); - free(track->artistName); - - free(track); - track_item = track_item->next; - } - return mp3tunes_locker_list_deinit((struct mp3tunes_locker_list_s**)track_list); -} - -int mp3tunes_locker_artist_list_deinit(mp3tunes_locker_artist_list_t **artist_list) { - mp3tunes_locker_artist_list_t *list = *artist_list; - mp3tunes_locker_list_item_t *artist_item = list->first; - mp3tunes_locker_artist_t *artist; - - while (artist_item != NULL) { - artist = (mp3tunes_locker_artist_t*)artist_item->value; - free(artist->artistName); - - free(artist); - artist_item = artist_item->next; - } - return mp3tunes_locker_list_deinit((struct mp3tunes_locker_list_s**)artist_list); -} - -int mp3tunes_locker_album_list_deinit(mp3tunes_locker_album_list_t **album_list) { - mp3tunes_locker_album_list_t *list = *album_list; - mp3tunes_locker_list_item_t *album_item = list->first; - mp3tunes_locker_album_t *album; - - while (album_item != NULL) { - album = (mp3tunes_locker_album_t*)album_item->value; - free(album->albumTitle); - free(album->artistName); - - free(album); - album_item = album_item->next; - } - return mp3tunes_locker_list_deinit((struct mp3tunes_locker_list_s**)album_list); -} - -int mp3tunes_locker_playlist_list_deinit(mp3tunes_locker_playlist_list_t **playlist_list) { - mp3tunes_locker_playlist_list_t *list = *playlist_list; - mp3tunes_locker_list_item_t *playlist_item = list->first; - mp3tunes_locker_playlist_t *playlist; - - while (playlist_item != NULL) { - playlist = (mp3tunes_locker_playlist_t*)playlist_item->value; - free(playlist->playlistId); - free(playlist->playlistTitle); - free(playlist->title); - free(playlist->fileName); - - free(playlist); - playlist_item = playlist_item->next; - } - return mp3tunes_locker_list_deinit((struct mp3tunes_locker_list_s**)playlist_list); -} - -static int _mp3tunes_locker_tracks(mp3tunes_locker_object_t *obj, mp3tunes_locker_track_list_t **tracks, int artist_id, int album_id, const char* playlist_id) { - xml_xpath_t* xml_xpath; - xmlXPathObjectPtr xpath_obj; - xmlNodeSetPtr nodeset; - xmlNodePtr node; - int i; - char artist_id_s[15]; - char album_id_s[15]; - - if (playlist_id == NULL) { - if (artist_id == -1 && album_id == -1) { - xml_xpath = mp3tunes_locker_api_simple_fetch(obj, MP3TUNES_SERVER_API, "api/v1/lockerData/", "type", "track", NULL); - } else if (artist_id != -1 && album_id == -1) { - snprintf(artist_id_s, 15, "%d", artist_id); - xml_xpath = mp3tunes_locker_api_simple_fetch(obj, MP3TUNES_SERVER_API, "api/v1/lockerData/", "type", "track", "artist_id", artist_id_s, NULL); - } else if (artist_id == -1 && album_id != -1) { - snprintf(album_id_s, 15, "%d", album_id); - xml_xpath = mp3tunes_locker_api_simple_fetch(obj, MP3TUNES_SERVER_API, "api/v1/lockerData/", "type", "track", "album_id", album_id_s, NULL); - } else { - snprintf(artist_id_s, 15, "%d", artist_id); - snprintf(album_id_s, 15, "%d", album_id); - xml_xpath = mp3tunes_locker_api_simple_fetch(obj, MP3TUNES_SERVER_API, "api/v1/lockerData/", "type", "track", "artist_id", artist_id_s, "album_id", album_id_s, NULL); - } - } else { - xml_xpath = mp3tunes_locker_api_simple_fetch(obj, MP3TUNES_SERVER_API, "api/v1/lockerData/", "type", "track", "playlist_id", playlist_id, NULL); - } - - mp3tunes_locker_track_list_init(tracks); - - if (xml_xpath == NULL) { - return -1; - } - - xpath_obj = xml_xpath_query(xml_xpath, "/mp3tunes/trackList/item"); - - if (xpath_obj == NULL) { - return -1; - } - - nodeset = xpath_obj->nodesetval; - - for (i = 0; i < nodeset->nodeNr; i++) { - node = nodeset->nodeTab[i]; - xml_xpath_t* xml_xpath_context = xml_xpath_context_init(xml_xpath, node); - mp3tunes_locker_track_t *track = (mp3tunes_locker_track_t*)malloc(sizeof(mp3tunes_locker_track_t)); - memset(track, 0, sizeof(mp3tunes_locker_track_t)); - - track->trackId = xml_xpath_get_integer(xml_xpath_context, "trackId"); - track->trackTitle = xml_xpath_get_string(xml_xpath_context, "trackTitle"); - track->trackNumber = xml_xpath_get_integer(xml_xpath_context, "trackNumber"); - track->trackLength = xml_xpath_get_float(xml_xpath_context, "trackLength"); - track->trackFileName = xml_xpath_get_string(xml_xpath_context, "trackFileName"); - track->trackFileKey = xml_xpath_get_string(xml_xpath_context, "trackFileKey"); - track->trackFileSize = xml_xpath_get_integer(xml_xpath_context, "trackFileSize"); - track->downloadURL = xml_xpath_get_string(xml_xpath_context, "downloadURL"); - track->playURL = xml_xpath_get_string(xml_xpath_context, "playURL"); - track->albumId = xml_xpath_get_integer(xml_xpath_context, "albumId"); - track->albumTitle = xml_xpath_get_string(xml_xpath_context, "albumTitle"); - track->albumYear = xml_xpath_get_integer(xml_xpath_context, "albumYear"); - track->artistName = xml_xpath_get_string(xml_xpath_context, "artistName"); - track->artistId = xml_xpath_get_integer(xml_xpath_context, "artistId"); - - mp3tunes_locker_track_list_add(tracks, track); - xml_xpath_deinit(xml_xpath_context); - } - xmlXPathFreeObject(xpath_obj); - xml_xpath_deinit(xml_xpath); - return 0; -} - -int mp3tunes_locker_tracks_search( mp3tunes_locker_object_t *obj, mp3tunes_locker_track_list_t **tracks, char *search) { - xml_xpath_t* xml_xpath; - xmlXPathObjectPtr xpath_obj; - xmlNodeSetPtr nodeset; - xmlNodePtr node; - int i; - - xml_xpath = mp3tunes_locker_api_simple_fetch(obj, MP3TUNES_SERVER_API, "api/v1/lockerSearch", "type", "track", "s", search, NULL); - - mp3tunes_locker_track_list_init(tracks); - - if (xml_xpath == NULL) { - return -1; - } - - xpath_obj = xml_xpath_query(xml_xpath, "/mp3tunes/trackList/item"); - - if (xpath_obj == NULL) { - return -1; - } - - nodeset = xpath_obj->nodesetval; - - for (i = 0; i < nodeset->nodeNr; i++) { - node = nodeset->nodeTab[i]; - xml_xpath_t* xml_xpath_context = xml_xpath_context_init(xml_xpath, node); - mp3tunes_locker_track_t *track = (mp3tunes_locker_track_t*)malloc(sizeof(mp3tunes_locker_track_t)); - memset(track, 0, sizeof(mp3tunes_locker_track_t)); - - track->trackId = xml_xpath_get_integer(xml_xpath_context, "trackId"); - track->trackTitle = xml_xpath_get_string(xml_xpath_context, "trackTitle"); - track->trackNumber = xml_xpath_get_integer(xml_xpath_context, "trackNumber"); - track->trackLength = xml_xpath_get_float(xml_xpath_context, "trackLength"); - track->trackFileName = xml_xpath_get_string(xml_xpath_context, "trackFileName"); - track->trackFileKey = xml_xpath_get_string(xml_xpath_context, "trackFileKey"); - track->trackFileSize = xml_xpath_get_integer(xml_xpath_context, "trackFileSize"); - track->downloadURL = xml_xpath_get_string(xml_xpath_context, "downloadURL"); - track->playURL = xml_xpath_get_string(xml_xpath_context, "playURL"); - track->albumId = xml_xpath_get_integer(xml_xpath_context, "albumId"); - track->albumTitle = xml_xpath_get_string(xml_xpath_context, "albumTitle"); - track->albumYear = xml_xpath_get_integer(xml_xpath_context, "albumYear"); - track->artistName = xml_xpath_get_string(xml_xpath_context, "artistName"); - track->artistId = xml_xpath_get_integer(xml_xpath_context, "artistId"); - - mp3tunes_locker_track_list_add(tracks, track); - xml_xpath_deinit(xml_xpath_context); - } - xmlXPathFreeObject(xpath_obj); - xml_xpath_deinit(xml_xpath); - return 0; -} - - -int mp3tunes_locker_tracks(mp3tunes_locker_object_t *obj, mp3tunes_locker_track_list_t **tracks) { - return _mp3tunes_locker_tracks(obj, tracks, -1, -1, NULL); -} - -int mp3tunes_locker_tracks_with_artist_id(mp3tunes_locker_object_t *obj, mp3tunes_locker_track_list_t **tracks, int artist_id) { - return _mp3tunes_locker_tracks(obj, tracks, artist_id, -1, NULL); -} - -int mp3tunes_locker_tracks_with_album_id(mp3tunes_locker_object_t *obj, mp3tunes_locker_track_list_t **tracks, int album_id) { - return _mp3tunes_locker_tracks(obj, tracks, -1, album_id, NULL); -} - -int mp3tunes_locker_tracks_with_artist_id_and_album_id(mp3tunes_locker_object_t *obj, mp3tunes_locker_track_list_t **tracks, int artist_id, int album_id) { - return _mp3tunes_locker_tracks(obj, tracks, artist_id, album_id, NULL); -} - -int mp3tunes_locker_tracks_with_playlist_id(mp3tunes_locker_object_t *obj, mp3tunes_locker_track_list_t **tracks, const char* playlist_id) { - return _mp3tunes_locker_tracks(obj, tracks, -1, -1, playlist_id); -} - -int mp3tunes_locker_tracks_with_file_key( mp3tunes_locker_object_t *obj, const char *file_keys, mp3tunes_locker_track_list_t **tracks ) { - xml_xpath_t* xml_xpath; - xmlXPathObjectPtr xpath_obj; - xmlNodeSetPtr nodeset; - xmlNodePtr node; - int i; - - xml_xpath = mp3tunes_locker_api_simple_fetch(obj, MP3TUNES_SERVER_API, "api/v1/lockerData/", "type", "track", "key", file_keys, NULL); - - mp3tunes_locker_track_list_init(tracks); - - if (xml_xpath == NULL) { - return -1; - } - - xpath_obj = xml_xpath_query(xml_xpath, "/mp3tunes/trackList/item"); - - if (xpath_obj == NULL) { - return -1; - } - - nodeset = xpath_obj->nodesetval; - - for (i = 0; i < nodeset->nodeNr; i++) { - node = nodeset->nodeTab[i]; - xml_xpath_t* xml_xpath_context = xml_xpath_context_init(xml_xpath, node); - mp3tunes_locker_track_t *track = (mp3tunes_locker_track_t*)malloc(sizeof(mp3tunes_locker_track_t)); - memset(track, 0, sizeof(mp3tunes_locker_track_t)); - - track->trackId = xml_xpath_get_integer(xml_xpath_context, "trackId"); - track->trackTitle = xml_xpath_get_string(xml_xpath_context, "trackTitle"); - track->trackNumber = xml_xpath_get_integer(xml_xpath_context, "trackNumber"); - track->trackLength = xml_xpath_get_float(xml_xpath_context, "trackLength"); - track->trackFileName = xml_xpath_get_string(xml_xpath_context, "trackFileName"); - track->trackFileKey = xml_xpath_get_string(xml_xpath_context, "trackFileKey"); - track->trackFileSize = xml_xpath_get_integer(xml_xpath_context, "trackFileSize"); - track->downloadURL = xml_xpath_get_string(xml_xpath_context, "downloadURL"); - track->playURL = xml_xpath_get_string(xml_xpath_context, "playURL"); - track->albumId = xml_xpath_get_integer(xml_xpath_context, "albumId"); - track->albumTitle = xml_xpath_get_string(xml_xpath_context, "albumTitle"); - track->albumYear = xml_xpath_get_integer(xml_xpath_context, "albumYear"); - track->artistName = xml_xpath_get_string(xml_xpath_context, "artistName"); - track->artistId = xml_xpath_get_integer(xml_xpath_context, "artistId"); - - mp3tunes_locker_track_list_add(tracks, track); - xml_xpath_deinit(xml_xpath_context); - } - xmlXPathFreeObject(xpath_obj); - xml_xpath_deinit(xml_xpath); - return 0; - -} - -int mp3tunes_locker_track_with_file_key( mp3tunes_locker_object_t *obj, const char *file_key, mp3tunes_locker_track_t **track ) { - xml_xpath_t* xml_xpath; - xmlXPathObjectPtr xpath_obj; - xmlNodeSetPtr nodeset; - xmlNodePtr node; - - xml_xpath = mp3tunes_locker_api_simple_fetch(obj, MP3TUNES_SERVER_API, "api/v1/lockerData/", "type", "track", "key", file_key, NULL); - - if (xml_xpath == NULL) { - return -1; - } - - xpath_obj = xml_xpath_query(xml_xpath, "/mp3tunes/trackList/item"); - - if (xpath_obj == NULL) { - return -1; - } - - nodeset = xpath_obj->nodesetval; - if ( nodeset->nodeNr == 1) { - node = nodeset->nodeTab[0]; - - xml_xpath_t* xml_xpath_context = xml_xpath_context_init(xml_xpath, node); - mp3tunes_locker_track_t *t = *track = (mp3tunes_locker_track_t*)malloc(sizeof(mp3tunes_locker_track_t)); - - t->trackId = xml_xpath_get_integer(xml_xpath_context, "trackId"); - t->trackTitle = xml_xpath_get_string(xml_xpath_context, "trackTitle"); - t->trackNumber = xml_xpath_get_integer(xml_xpath_context, "trackNumber"); - t->trackLength = xml_xpath_get_float(xml_xpath_context, "trackLength"); - t->trackFileName = xml_xpath_get_string(xml_xpath_context, "trackFileName"); - t->trackFileKey = xml_xpath_get_string(xml_xpath_context, "trackFileKey"); - t->trackFileSize = xml_xpath_get_integer(xml_xpath_context, "trackFileSize"); - t->downloadURL = xml_xpath_get_string(xml_xpath_context, "downloadURL"); - t->playURL = xml_xpath_get_string(xml_xpath_context, "playURL"); - t->albumId = xml_xpath_get_integer(xml_xpath_context, "albumId"); - t->albumTitle = xml_xpath_get_string(xml_xpath_context, "albumTitle"); - t->albumYear = xml_xpath_get_integer(xml_xpath_context, "albumYear"); - t->artistName = xml_xpath_get_string(xml_xpath_context, "artistName"); - t->artistId = xml_xpath_get_integer(xml_xpath_context, "artistId"); - - xml_xpath_deinit(xml_xpath_context); - xmlXPathFreeObject(xpath_obj); - xml_xpath_deinit(xml_xpath); - return 0; - } - xmlXPathFreeObject(xpath_obj); - xml_xpath_deinit(xml_xpath); - return -1; -} - -int mp3tunes_locker_artists(mp3tunes_locker_object_t *obj, mp3tunes_locker_artist_list_t **artists) { - xml_xpath_t* xml_xpath; - xmlXPathObjectPtr xpath_obj; - xmlNodeSetPtr nodeset; - xmlNodePtr node; - int i; - - xml_xpath = mp3tunes_locker_api_simple_fetch(obj, MP3TUNES_SERVER_API, "api/v1/lockerData/", "type", "artist", NULL); - - mp3tunes_locker_artist_list_init(artists); - - if (xml_xpath == NULL) { - return -1; - } - - xpath_obj = xml_xpath_query(xml_xpath, "/mp3tunes/artistList/item"); - if (xpath_obj == NULL) { - return -1; - } - - nodeset = xpath_obj->nodesetval; - - for (i = 0; i < nodeset->nodeNr; i++) { - node = nodeset->nodeTab[i]; - xml_xpath_t* xml_xpath_context = xml_xpath_context_init(xml_xpath, node); - mp3tunes_locker_artist_t *artist = (mp3tunes_locker_artist_t*)malloc(sizeof(mp3tunes_locker_artist_t)); - memset(artist, 0, sizeof(mp3tunes_locker_artist_t)); - - artist->artistId = xml_xpath_get_integer(xml_xpath_context, "artistId"); - artist->artistName = xml_xpath_get_string(xml_xpath_context, "artistName"); - artist->artistSize = xml_xpath_get_integer(xml_xpath_context, "artistSize"); - artist->albumCount = xml_xpath_get_integer(xml_xpath_context, "albumCount"); - artist->trackCount = xml_xpath_get_integer(xml_xpath_context, "trackCount"); - - mp3tunes_locker_artist_list_add(artists, artist); - xml_xpath_deinit(xml_xpath_context); - } - xmlXPathFreeObject(xpath_obj); - xml_xpath_deinit(xml_xpath); - return 0; -} - -int mp3tunes_locker_artists_search( mp3tunes_locker_object_t *obj, mp3tunes_locker_artist_list_t **artists, char *search) { - xml_xpath_t* xml_xpath; - xmlXPathObjectPtr xpath_obj; - xmlNodeSetPtr nodeset; - xmlNodePtr node; - int i; - - xml_xpath = mp3tunes_locker_api_simple_fetch(obj, MP3TUNES_SERVER_API, "api/v1/lockerSearch", "type", "artist", "s", search, NULL); - mp3tunes_locker_artist_list_init(artists); - - if (xml_xpath == NULL) { - return -1; - } - - xpath_obj = xml_xpath_query(xml_xpath, "/mp3tunes/artistList/item"); - if (xpath_obj == NULL) { - return -1; - } - - nodeset = xpath_obj->nodesetval; - - for (i = 0; i < nodeset->nodeNr; i++) { - node = nodeset->nodeTab[i]; - xml_xpath_t* xml_xpath_context = xml_xpath_context_init(xml_xpath, node); - mp3tunes_locker_artist_t *artist = (mp3tunes_locker_artist_t*)malloc(sizeof(mp3tunes_locker_artist_t)); - memset(artist, 0, sizeof(mp3tunes_locker_artist_t)); - - artist->artistId = xml_xpath_get_integer(xml_xpath_context, "artistId"); - artist->artistName = xml_xpath_get_string(xml_xpath_context, "artistName"); - artist->artistSize = xml_xpath_get_integer(xml_xpath_context, "artistSize"); - artist->albumCount = xml_xpath_get_integer(xml_xpath_context, "albumCount"); - artist->trackCount = xml_xpath_get_integer(xml_xpath_context, "trackCount"); - - mp3tunes_locker_artist_list_add(artists, artist); - xml_xpath_deinit(xml_xpath_context); - } - xmlXPathFreeObject(xpath_obj); - xml_xpath_deinit(xml_xpath); - return 0; -} - - -int mp3tunes_locker_albums_with_artist_id(mp3tunes_locker_object_t *obj, mp3tunes_locker_album_list_t **albums, int artist_id) { - xml_xpath_t* xml_xpath; - xmlXPathObjectPtr xpath_obj; - xmlNodeSetPtr nodeset; - xmlNodePtr node; - int i; - char artist_id_string[15]; - - if (artist_id == -1) { - xml_xpath = mp3tunes_locker_api_simple_fetch(obj, MP3TUNES_SERVER_API, "api/v1/lockerData/", "type", "album", NULL); - } else { - snprintf(artist_id_string, 15, "%d", artist_id); - xml_xpath = mp3tunes_locker_api_simple_fetch(obj, MP3TUNES_SERVER_API, "api/v1/lockerData/", "type", "album", "artist_id", artist_id_string, NULL); - } - - mp3tunes_locker_album_list_init(albums); - - if (xml_xpath == NULL) { - return -1; - } - - xpath_obj = xml_xpath_query(xml_xpath, "/mp3tunes/albumList/item"); - - if (xpath_obj == NULL) { - return -1; - } - - nodeset = xpath_obj->nodesetval; - - for (i = 0; i < nodeset->nodeNr; i++) { - node = nodeset->nodeTab[i]; - xml_xpath_t* xml_xpath_context = xml_xpath_context_init(xml_xpath, node); - mp3tunes_locker_album_t *album = (mp3tunes_locker_album_t*)malloc(sizeof(mp3tunes_locker_album_t)); - memset(album, 0, sizeof(mp3tunes_locker_album_t)); - - album->albumId = xml_xpath_get_integer(xml_xpath_context, "albumId"); - album->albumTitle = xml_xpath_get_string(xml_xpath_context, "albumTitle"); - album->artistId = xml_xpath_get_integer(xml_xpath_context, "artistId"); - album->artistName = xml_xpath_get_string(xml_xpath_context, "artistName"); - album->trackCount = xml_xpath_get_integer(xml_xpath_context, "trackCount"); - album->albumSize = xml_xpath_get_integer(xml_xpath_context, "albumSize"); - album->hasArt = xml_xpath_get_integer(xml_xpath_context, "hasArt"); - - mp3tunes_locker_album_list_add(albums, album); - xml_xpath_deinit(xml_xpath_context); - } - xmlXPathFreeObject(xpath_obj); - xml_xpath_deinit(xml_xpath); - return 0; -} - -int mp3tunes_locker_albums(mp3tunes_locker_object_t *obj, mp3tunes_locker_album_list_t **albums) { - return mp3tunes_locker_albums_with_artist_id(obj, albums, -1); -} - -int mp3tunes_locker_albums_search( mp3tunes_locker_object_t *obj, mp3tunes_locker_album_list_t **albums, char *search) { - xml_xpath_t* xml_xpath; - xmlXPathObjectPtr xpath_obj; - xmlNodeSetPtr nodeset; - xmlNodePtr node; - int i; - - xml_xpath = mp3tunes_locker_api_simple_fetch(obj, MP3TUNES_SERVER_API, "api/v1/lockerSearch", "type", "album", "s", search, NULL); - - mp3tunes_locker_album_list_init(albums); - - if (xml_xpath == NULL) { - return -1; - } - - xpath_obj = xml_xpath_query(xml_xpath, "/mp3tunes/albumList/item"); - - if (xpath_obj == NULL) { - return -1; - } - - nodeset = xpath_obj->nodesetval; - - for (i = 0; i < nodeset->nodeNr; i++) { - node = nodeset->nodeTab[i]; - xml_xpath_t* xml_xpath_context = xml_xpath_context_init(xml_xpath, node); - mp3tunes_locker_album_t *album = (mp3tunes_locker_album_t*)malloc(sizeof(mp3tunes_locker_album_t)); - memset(album, 0, sizeof(mp3tunes_locker_album_t)); - - album->albumId = xml_xpath_get_integer(xml_xpath_context, "albumId"); - album->albumTitle = xml_xpath_get_string(xml_xpath_context, "albumTitle"); - album->artistId = xml_xpath_get_integer(xml_xpath_context, "artistId"); - album->artistName = xml_xpath_get_string(xml_xpath_context, "artistName"); - album->trackCount = xml_xpath_get_integer(xml_xpath_context, "trackCount"); - album->albumSize = xml_xpath_get_integer(xml_xpath_context, "albumSize"); - album->hasArt = xml_xpath_get_integer(xml_xpath_context, "hasArt"); - - mp3tunes_locker_album_list_add(albums, album); - xml_xpath_deinit(xml_xpath_context); - } - xmlXPathFreeObject(xpath_obj); - xml_xpath_deinit(xml_xpath); - return 0; -} - - - - -int mp3tunes_locker_playlists(mp3tunes_locker_object_t *obj, mp3tunes_locker_playlist_list_t **playlists) { - xml_xpath_t* xml_xpath; - xmlXPathObjectPtr xpath_obj; - xmlNodeSetPtr nodeset; - xmlNodePtr node; - int i; - - xml_xpath = mp3tunes_locker_api_simple_fetch(obj, MP3TUNES_SERVER_API, "api/v1/lockerData/", "type", "playlist", NULL); - - mp3tunes_locker_playlist_list_init(playlists); - - if (xml_xpath == NULL) { - return -1; - } - - xpath_obj =xml_xpath_query(xml_xpath, "/mp3tunes/playlistList/item"); - - if (xpath_obj == NULL) { - return -1; - } - - nodeset = xpath_obj->nodesetval; - - for (i = 0; i < nodeset->nodeNr; i++) { - node = nodeset->nodeTab[i]; - xml_xpath_t* xml_xpath_context = xml_xpath_context_init(xml_xpath, node); - mp3tunes_locker_playlist_t *playlist = (mp3tunes_locker_playlist_t*)malloc(sizeof(mp3tunes_locker_playlist_t)); - memset(playlist, 0, sizeof(mp3tunes_locker_playlist_t)); - - playlist->playlistId = xml_xpath_get_string(xml_xpath_context, "playlistId"); - playlist->playlistTitle = xml_xpath_get_string(xml_xpath_context, "playlistTitle"); - playlist->title = xml_xpath_get_string(xml_xpath_context, "title"); - playlist->fileName = xml_xpath_get_string(xml_xpath_context, "fileName"); - playlist->fileCount = xml_xpath_get_integer(xml_xpath_context, "fileCount"); - playlist->playlistSize = xml_xpath_get_integer(xml_xpath_context, "playlistSize"); - - mp3tunes_locker_playlist_list_add(playlists, playlist); - xml_xpath_deinit(xml_xpath_context); - } - xmlXPathFreeObject(xpath_obj); - xml_xpath_deinit(xml_xpath); - return 0; -} - -int mp3tunes_locker_search(mp3tunes_locker_object_t *obj, mp3tunes_locker_artist_list_t **artists, mp3tunes_locker_album_list_t **albums, mp3tunes_locker_track_list_t **tracks, const char *query) { - xml_xpath_t* xml_xpath; - - char type[20] = ""; - if( artists != NULL ) { - strcat( type, "artist," ); - } - if( albums != NULL ) { - strcat( type, "album," ); - } - if( tracks != NULL ) { - strcat( type, "track," ); - } - if( strlen(type) == 0 ) { - return -1; - } - /*printf("type: '%s' query: '%s'\n", placeholder, query);*/ - - xml_xpath = mp3tunes_locker_api_simple_fetch(obj, MP3TUNES_SERVER_API, "api/v1/lockerSearch", "type", type, "s", query, NULL); - if (xml_xpath == NULL) - return -1; - - if(artists != NULL) { - xmlXPathObjectPtr xpath_obj; - xmlNodeSetPtr nodeset; - xmlNodePtr node; - int i; - mp3tunes_locker_artist_list_init(artists); - - xpath_obj = xml_xpath_query(xml_xpath, "/mp3tunes/artistList/item"); - if (xpath_obj == NULL) { - return -1; - } - - nodeset = xpath_obj->nodesetval; - - for (i = 0; i < nodeset->nodeNr; i++) { - node = nodeset->nodeTab[i]; - xml_xpath_t* xml_xpath_context = xml_xpath_context_init(xml_xpath, node); - mp3tunes_locker_artist_t *artist = (mp3tunes_locker_artist_t*)malloc(sizeof(mp3tunes_locker_artist_t)); - memset(artist, 0, sizeof(mp3tunes_locker_artist_t)); - - artist->artistId = xml_xpath_get_integer(xml_xpath_context, "artistId"); - artist->artistName = xml_xpath_get_string(xml_xpath_context, "artistName"); - artist->artistSize = xml_xpath_get_integer(xml_xpath_context, "artistSize"); - artist->albumCount = xml_xpath_get_integer(xml_xpath_context, "albumCount"); - artist->trackCount = xml_xpath_get_integer(xml_xpath_context, "trackCount"); - - mp3tunes_locker_artist_list_add(artists, artist); - xml_xpath_deinit(xml_xpath_context); - } - xmlXPathFreeObject(xpath_obj); - } - - if( albums != NULL ) { - xmlXPathObjectPtr xpath_obj; - xmlNodeSetPtr nodeset; - xmlNodePtr node; - int i; - - mp3tunes_locker_album_list_init(albums); - - xpath_obj = xml_xpath_query(xml_xpath, "/mp3tunes/albumList/item"); - - if (xpath_obj == NULL) { - return -1; - } - - nodeset = xpath_obj->nodesetval; - - for (i = 0; i < nodeset->nodeNr; i++) { - node = nodeset->nodeTab[i]; - xml_xpath_t* xml_xpath_context = xml_xpath_context_init(xml_xpath, node); - mp3tunes_locker_album_t *album = (mp3tunes_locker_album_t*)malloc(sizeof(mp3tunes_locker_album_t)); - memset(album, 0, sizeof(mp3tunes_locker_album_t)); - - album->albumId = xml_xpath_get_integer(xml_xpath_context, "albumId"); - album->albumTitle = xml_xpath_get_string(xml_xpath_context, "albumTitle"); - album->artistId = xml_xpath_get_integer(xml_xpath_context, "artistId"); - album->artistName = xml_xpath_get_string(xml_xpath_context, "artistName"); - album->trackCount = xml_xpath_get_integer(xml_xpath_context, "trackCount"); - album->albumSize = xml_xpath_get_integer(xml_xpath_context, "albumSize"); - album->hasArt = xml_xpath_get_integer(xml_xpath_context, "hasArt"); - - mp3tunes_locker_album_list_add(albums, album); - xml_xpath_deinit(xml_xpath_context); - } - xmlXPathFreeObject(xpath_obj); - } - if( tracks != NULL) { - xmlXPathObjectPtr xpath_obj; - xmlNodeSetPtr nodeset; - xmlNodePtr node; - int i; - - mp3tunes_locker_track_list_init(tracks); - - xpath_obj = xml_xpath_query(xml_xpath, "/mp3tunes/trackList/item"); - - if (xpath_obj == NULL) { - return -1; - } - - nodeset = xpath_obj->nodesetval; - - for (i = 0; i < nodeset->nodeNr; i++) { - node = nodeset->nodeTab[i]; - xml_xpath_t* xml_xpath_context = xml_xpath_context_init(xml_xpath, node); - mp3tunes_locker_track_t *track = (mp3tunes_locker_track_t*)malloc(sizeof(mp3tunes_locker_track_t)); - memset(track, 0, sizeof(mp3tunes_locker_track_t)); - - track->trackId = xml_xpath_get_integer(xml_xpath_context, "trackId"); - track->trackTitle = xml_xpath_get_string(xml_xpath_context, "trackTitle"); - track->trackNumber = xml_xpath_get_integer(xml_xpath_context, "trackNumber"); - track->trackLength = xml_xpath_get_float(xml_xpath_context, "trackLength"); - track->trackFileName = xml_xpath_get_string(xml_xpath_context, "trackFileName"); - track->trackFileKey = xml_xpath_get_string(xml_xpath_context, "trackFileKey"); - track->trackFileSize = xml_xpath_get_integer(xml_xpath_context, "trackFileSize"); - track->downloadURL = xml_xpath_get_string(xml_xpath_context, "downloadURL"); - track->playURL = xml_xpath_get_string(xml_xpath_context, "playURL"); - track->albumId = xml_xpath_get_integer(xml_xpath_context, "albumId"); - track->albumTitle = xml_xpath_get_string(xml_xpath_context, "albumTitle"); - track->albumYear = xml_xpath_get_integer(xml_xpath_context, "albumYear"); - track->artistName = xml_xpath_get_string(xml_xpath_context, "artistName"); - track->artistId = xml_xpath_get_integer(xml_xpath_context, "artistId"); - - mp3tunes_locker_track_list_add(tracks, track); - xml_xpath_deinit(xml_xpath_context); - } - xmlXPathFreeObject(xpath_obj); - } - xml_xpath_deinit(xml_xpath); - return 0; -} - -int mp3tunes_locker_sync_down(mp3tunes_locker_object_t *obj, char* type, char* bytes_local, char* files_local, char* keep_local_files, char* playlist_id) { - xml_xpath_t* xml_xpath; - xmlBufferPtr buf; - xmlTextWriterPtr writer; - - buf = xmlBufferCreate(); - if (buf == NULL) { - return -1; - } - - writer = xmlNewTextWriterMemory(buf, 0); - - if (writer == NULL) { - return -1; - } - - if (xmlTextWriterStartDocument(writer, NULL, "UTF-8", NULL) < 0) { - return -1; - } - - if (xmlTextWriterStartElement(writer, BAD_CAST "sync") < 0) { - return -1; - } - - if (xmlTextWriterStartElement(writer, BAD_CAST "options") < 0) { - return -1; - } - - if (xmlTextWriterStartElement(writer, BAD_CAST "direction") < 0) { - return -1; - } - - if (xmlTextWriterWriteAttribute(writer, BAD_CAST "sync_down", BAD_CAST "1") < 0) { - return -1; - } - - if (xmlTextWriterEndElement(writer) < 0) { - return -1; - } - - if (xmlTextWriterStartElement(writer, BAD_CAST "file_sync") < 0) { - return -1; - } - - if (xmlTextWriterWriteAttribute(writer, BAD_CAST "type", BAD_CAST type) < 0) { - return -1; - } - - if (xmlTextWriterEndElement(writer) < 0) { - return -1; - } - - if (xmlTextWriterStartElement(writer, BAD_CAST "max") < 0) { - return -1; - } - - if (bytes_local) { - if (xmlTextWriterWriteAttribute(writer, BAD_CAST "bytes_local", BAD_CAST bytes_local) < 0) { - return -1; - } - } - - if (files_local) { - if (xmlTextWriterWriteAttribute(writer, BAD_CAST "files_local", BAD_CAST files_local) < 0) { - return -1; - } - } - - if (keep_local_files) { - if (xmlTextWriterWriteAttribute(writer, BAD_CAST "keep_local_files", BAD_CAST files_local) < 0) { - return -1; - } - } - - if (xmlTextWriterEndElement(writer) < 0) { - return -1; - } - - if (playlist_id) { - if (xmlTextWriterStartElement(writer, BAD_CAST "playlist") < 0) { - return -1; - } - - if (xmlTextWriterWriteAttribute(writer, BAD_CAST "id", BAD_CAST playlist_id) < 0) { - return -1; - } - - if (xmlTextWriterEndElement(writer) < 0) { - return -1; - } - } - - if (xmlTextWriterEndDocument(writer) < 0) { - return -1; - } - - xmlFreeTextWriter(writer); - - xml_xpath = mp3tunes_locker_api_post_fetch(obj, MP3TUNES_SERVER_API, "api/v1/lockerSync/", (char*)buf->content); - if( xml_xpath == NULL) - return -1; - - printf("Sync:\n%s\n", (const char *) buf->content); - - free(xml_xpath); - xmlBufferFree(buf); - return 0; -} - -int mp3tunes_locker_generate_track_from_file_key(mp3tunes_locker_object_t *obj, char *file_key, mp3tunes_locker_track_list_t **tracks ) { - xml_xpath_t* xml_xpath; - xmlXPathObjectPtr xpath_obj; - xmlNodeSetPtr nodeset; - xmlNodePtr node; - int i; - - xml_xpath = mp3tunes_locker_api_simple_fetch(obj, MP3TUNES_SERVER_API, "api/v1/lockerData/", "type", "track", "key", file_key, NULL); - - mp3tunes_locker_track_list_init(tracks); - - if (xml_xpath == NULL) { - return -1; - } - - xpath_obj = xml_xpath_query(xml_xpath, "/mp3tunes/trackList/item"); - - if (xpath_obj == NULL) { - return -1; - } - - nodeset = xpath_obj->nodesetval; - - for (i = 0; i < nodeset->nodeNr; i++) { - node = nodeset->nodeTab[i]; - xml_xpath_t* xml_xpath_context = xml_xpath_context_init(xml_xpath, node); - mp3tunes_locker_track_t *track = (mp3tunes_locker_track_t*)malloc(sizeof(mp3tunes_locker_track_t)); - memset(track, 0, sizeof(mp3tunes_locker_track_t)); - - track->trackId = xml_xpath_get_integer(xml_xpath_context, "trackId"); - track->trackTitle = xml_xpath_get_string(xml_xpath_context, "trackTitle"); - track->trackNumber = xml_xpath_get_integer(xml_xpath_context, "trackNumber"); - track->trackLength = xml_xpath_get_float(xml_xpath_context, "trackLength"); - track->trackFileName = xml_xpath_get_string(xml_xpath_context, "trackFileName"); - track->trackFileKey = xml_xpath_get_string(xml_xpath_context, "trackFileKey"); - track->trackFileSize = xml_xpath_get_integer(xml_xpath_context, "trackFileSize"); - track->downloadURL = xml_xpath_get_string(xml_xpath_context, "downloadURL"); - track->playURL = xml_xpath_get_string(xml_xpath_context, "playURL"); - track->albumId = xml_xpath_get_integer(xml_xpath_context, "albumId"); - track->albumTitle = xml_xpath_get_string(xml_xpath_context, "albumTitle"); - track->albumYear = xml_xpath_get_integer(xml_xpath_context, "albumYear"); - track->artistName = xml_xpath_get_string(xml_xpath_context, "artistName"); - track->artistId = xml_xpath_get_integer(xml_xpath_context, "artistId"); - - mp3tunes_locker_track_list_add(tracks, track); - xml_xpath_deinit(xml_xpath_context); - } - xmlXPathFreeObject(xpath_obj); - xml_xpath_deinit(xml_xpath); - return 0; - -} - -char* mp3tunes_locker_generate_filekey(const char *filename) { - return md5_calc_file_signature(filename); -} - -int mp3tunes_locker_upload_track(mp3tunes_locker_object_t *obj, const char *path) { - request_t *request; - FILE * hd_src ; - int hd ; - struct stat file_info; - char* file_key = mp3tunes_locker_generate_filekey(path); - - if (file_key == NULL) - return -1; - - /* get the file size of the local file */ - hd = open(path, O_RDONLY); - if (hd == -1) { - free(file_key); - return -1; - } - - fstat(hd, &file_info); - close(hd); - /* get a FILE * of the same file*/ - hd_src = fopen(path, "rb"); - - /* create the request url */ - char *url = malloc(256*sizeof(char)); - snprintf(url, 256, "storage/lockerput/%s", file_key); - free(file_key); - request = mp3tunes_locker_api_generate_request(obj, MP3TUNES_SERVER_CONTENT, url, NULL); - if (request == NULL) { - fclose(hd_src); - return -1; - } - - /*chunk_init(&chunk);*/ - /*curl_easy_setopt( request->curl, CURLOPT_READFUNCTION, read_callback);*/ - curl_easy_setopt( request->curl, CURLOPT_UPLOAD, 1L); - curl_easy_setopt( request->curl, CURLOPT_PUT, 1L); - curl_easy_setopt( request->curl, CURLOPT_URL, request->url); - curl_easy_setopt( request->curl, CURLOPT_READDATA, hd_src); - curl_easy_setopt( request->curl, CURLOPT_INFILESIZE_LARGE, (curl_off_t)file_info.st_size); - curl_easy_setopt( request->curl, CURLOPT_USERAGENT, "liboboe/1.0" ); - /*printf("uploading...\n");*/ - /* this returns a CURLcode which should probably be checked for success etc... */ - curl_easy_perform(request->curl); -/* curl_easy_cleanup(request->curl); */ - mp3tunes_request_deinit(&request); - free(url); - - fclose(hd_src); /* close the local file */ - return 0; -} - -int mp3tunes_locker_load_track(mp3tunes_locker_object_t *obj, const char *url) { - xml_xpath_t* xml_xpath; - char *status; - xml_xpath = mp3tunes_locker_api_simple_fetch(obj, MP3TUNES_SERVER_LOGIN, "api/v0/lockerLoad/", "email", obj->username, "url", url, "sid", obj->session_id, NULL); - - if (xml_xpath == NULL) { - return -2; - } - - status = xml_xpath_get_string(xml_xpath, "/mp3tunes/status"); - - if (status[0] != '1') { - /*printf("status is %s\n", status);*/ - char* error = xml_xpath_get_string(xml_xpath, "/mp3tunes/errorMessage"); - /*printf("error is %s\n", error);*/ - obj->error_message = error; - free(status); - xml_xpath_deinit(xml_xpath); - return -1; - } - free(status); - xml_xpath_deinit(xml_xpath); - - return 0; - -} diff --git a/amarok/src/services/mp3tunes/libmp3tunes/locker.h b/amarok/src/services/mp3tunes/libmp3tunes/locker.h deleted file mode 100644 index f84cd141..00000000 --- a/amarok/src/services/mp3tunes/libmp3tunes/locker.h +++ /dev/null @@ -1,142 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 MP3tunes, LLC * - * * - * This program is free software; you can redistribute it and/or modify it under * - * the terms of the GNU Library General Public License as published by the Free * - * Software Foundation; either version 2.1 of the License, or (at your option) any * - * later version. * - * * - * This program 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 Library General Public License along with * - * this program. If not, see . * - ****************************************************************************************/ - -/** - * \file oboe.h - * \brief The \e liboboe public header. - */ - -#ifndef __MP3TUNES_LOCKER_H__ -#define __MP3TUNES_LOCKER_H__ - -#ifndef TRUE -#define TRUE 1 -#define FALSE 0 -#endif - -#define MP3TUNES_SERVER_API_URL "ws.mp3tunes.com" -#define MP3TUNES_SERVER_CONTENT_URL "content.mp3tunes.com" -#define MP3TUNES_SERVER_LOGIN_URL "shop.mp3tunes.com" - -#define MP3TUNES_SERVER_API 0 -#define MP3TUNES_SERVER_CONTENT 1 -#define MP3TUNES_SERVER_LOGIN 2 - -typedef struct { - char *username, *password, *session_id, *firstname, *lastname, *nickname; - char *partner_token; - char *server_api, *server_content, *server_login; - char *error_message; -} mp3tunes_locker_object_t; - -struct mp3tunes_locker_list_item_s { - int id; - void *value; - struct mp3tunes_locker_list_item_s *prev; - struct mp3tunes_locker_list_item_s *next; -}; - -typedef struct mp3tunes_locker_list_item_s mp3tunes_locker_list_item_t; - -struct mp3tunes_locker_list_s { - int last_id; - mp3tunes_locker_list_item_t *first; - mp3tunes_locker_list_item_t *last; -}; - -typedef struct mp3tunes_locker_list_s mp3tunes_locker_track_list_t; -typedef struct mp3tunes_locker_list_s mp3tunes_locker_artist_list_t; -typedef struct mp3tunes_locker_list_s mp3tunes_locker_album_list_t; -typedef struct mp3tunes_locker_list_s mp3tunes_locker_playlist_list_t; - -typedef struct { - int trackId; - char *trackTitle; - int trackNumber; - float trackLength; - char *trackFileName; - char *trackFileKey; - int trackFileSize; - char *downloadURL; - char *playURL; - int albumId; - char *albumTitle; - int albumYear; - char *artistName; - int artistId; -} mp3tunes_locker_track_t; - -typedef struct { - int artistId; - char* artistName; - int artistSize; - int albumCount; - int trackCount; -} mp3tunes_locker_artist_t; - -typedef struct { - int albumId; - char *albumTitle; - int artistId; - char *artistName; - int trackCount; - int albumSize; - int hasArt; -} mp3tunes_locker_album_t; - -typedef struct { - char* playlistId; - char* playlistTitle; - char* title; - char* fileName; - int fileCount; - int playlistSize; -} mp3tunes_locker_playlist_t; - -int mp3tunes_locker_init( mp3tunes_locker_object_t **obj, const char *partner_token ); -int mp3tunes_locker_deinit( mp3tunes_locker_object_t **obj ); -int mp3tunes_locker_login( mp3tunes_locker_object_t *obj, const char* username, const char* password ); -int mp3tunes_locker_session_valid( mp3tunes_locker_object_t *obj ); -int mp3tunes_locker_artists( mp3tunes_locker_object_t *obj, mp3tunes_locker_artist_list_t **artists_return); -int mp3tunes_locker_artists_search( mp3tunes_locker_object_t *obj, mp3tunes_locker_artist_list_t **artists_return, char *query); -int mp3tunes_locker_albums_with_artist_id( mp3tunes_locker_object_t *obj, mp3tunes_locker_album_list_t **albums_return, int artist_id); -int mp3tunes_locker_albums( mp3tunes_locker_object_t *obj, mp3tunes_locker_album_list_t **albums_return); -int mp3tunes_locker_albums_search( mp3tunes_locker_object_t *obj, mp3tunes_locker_album_list_t **albums_return, char *query); -int mp3tunes_locker_playlists(mp3tunes_locker_object_t *obj, mp3tunes_locker_playlist_list_t **playlist_return); -int mp3tunes_locker_search(mp3tunes_locker_object_t *obj, mp3tunes_locker_artist_list_t **artists_return, mp3tunes_locker_album_list_t **albums_return, mp3tunes_locker_track_list_t **tracks_return, const char *query); - -int mp3tunes_locker_tracks( mp3tunes_locker_object_t *obj, mp3tunes_locker_track_list_t **tracks_return); -int mp3tunes_locker_tracks_search( mp3tunes_locker_object_t *obj, mp3tunes_locker_track_list_t **tracks_return, char *query); -int mp3tunes_locker_tracks_with_playlist_id( mp3tunes_locker_object_t *obj, mp3tunes_locker_track_list_t **tracks_return, const char* playlist_id); -int mp3tunes_locker_tracks_with_album_id( mp3tunes_locker_object_t *obj, mp3tunes_locker_track_list_t **tracks_return, int album_id); -int mp3tunes_locker_tracks_with_artist_id( mp3tunes_locker_object_t *obj, mp3tunes_locker_track_list_t **tracks_return, int artist_id); -int mp3tunes_locker_tracks_with_file_key( mp3tunes_locker_object_t *obj, const char *file_keys, mp3tunes_locker_track_list_t **tracks ); -int mp3tunes_locker_track_with_file_key( mp3tunes_locker_object_t *obj, const char *file_key, mp3tunes_locker_track_t **track ); - -int mp3tunes_locker_track_list_deinit( mp3tunes_locker_track_list_t** list ); -int mp3tunes_locker_artist_list_deinit( mp3tunes_locker_track_list_t** list ); -int mp3tunes_locker_album_list_deinit( mp3tunes_locker_track_list_t** list ); -int mp3tunes_locker_playlist_list_deinit( mp3tunes_locker_track_list_t** list ); - -char* mp3tunes_locker_generate_download_url_from_file_key(mp3tunes_locker_object_t *obj, char *file_key); -char* mp3tunes_locker_generate_download_url_from_file_key_and_bitrate(mp3tunes_locker_object_t *obj, char *file_key, char* bitrate); - -char* mp3tunes_locker_generate_filekey(const char *filename); -int mp3tunes_locker_upload_track(mp3tunes_locker_object_t *obj, const char *path); -int mp3tunes_locker_load_track(mp3tunes_locker_object_t *obj, const char *url); - -int mp3tunes_locker_sync_down(mp3tunes_locker_object_t *obj, char* type, char* bytes_local, char* files_local, char* keep_local_files, char* playlist_id); -#endif diff --git a/amarok/src/services/mp3tunes/libmp3tunes/md5.c b/amarok/src/services/mp3tunes/libmp3tunes/md5.c deleted file mode 100644 index 23bcafeb..00000000 --- a/amarok/src/services/mp3tunes/libmp3tunes/md5.c +++ /dev/null @@ -1,112 +0,0 @@ -#include - -#if defined(HAVE_LIBGCRYPT) -# include -#elif defined(HAVE_OPENSSL) -# include -#else -# error "You need either OpenSSL or GNU Libgcrypt to build this file" -#endif - -#include "md5.h" - -void md5_sig_to_string(void *signature, char *str, const int str_len) -{ - unsigned char *sig_p; - char *str_p, *max_p; - unsigned int high, low; - - str_p = str; - max_p = str + str_len; - - for (sig_p = (unsigned char *)signature; - sig_p < (unsigned char *)signature + MD5_SIZE; - sig_p++) { - high = *sig_p / 16; - low = *sig_p % 16; - /* account for 2 chars */ - if (str_p + 1 >= max_p) { - break; - } - *str_p++ = HEX_STRING[high]; - *str_p++ = HEX_STRING[low]; - } - /* account for 2 chars */ - if (str_p < max_p) { - *str_p++ = '\0'; - } -} - -char* md5_calc_file_signature(const char *filename) -{ - char buffer[4096]; - char* strsig; - int ret; - FILE *stream; -#ifdef HAVE_LIBGCRYPT - gcry_md_hd_t md5; - gcry_error_t err; - unsigned char* sig; -#else - MD5_CTX md5; - unsigned char sig[MD5_DIGEST_LENGTH]; -#endif - - stream = fopen(filename, "r"); - if (stream == NULL) { - perror(filename); - exit(1); - } -#ifdef HAVE_LIBGCRYPT - err = gcry_md_open(&md5, GCRY_MD_MD5, 0); - if (err) { - fprintf(stderr, "MD5 context creation failure: %s/%s", - gcry_strsource (err), gcry_strerror (err)); - fclose(stream); - return NULL; - } -#else - MD5_Init(&md5); -#endif - - /* iterate over file */ - while (1) { - /* read in from our file */ - ret = fread(buffer, sizeof(char), sizeof(buffer), stream); - if (ret <= 0) - break; - - /* process our buffer buffer */ -#ifdef HAVE_LIBGCRYPT - gcry_md_write(md5, buffer, ret); -#else - MD5_Update(&md5, buffer, ret); -#endif - } - -#ifdef HAVE_LIBGCRYPT - gcry_md_final(md5); - sig = gcry_md_read(md5, GCRY_MD_MD5); - if (!sig) { - fprintf(stderr, "Unable to calculate MD5 signature for %s", filename); - fclose(stream); - return NULL; - } -#else - MD5_Final(sig, &md5); -#endif - - if (stream != stdin) { - (void)fclose(stream); - } - - /* convert to string to print */ - strsig = (char*) malloc(16*2+1); - if (strsig) { - md5_sig_to_string(sig, strsig, 16*2+1); - /*(void)printf("%25s '%s'\n", "File key:", strsig);*/ - return strsig; - } else { - return NULL; - } -} diff --git a/amarok/src/services/mp3tunes/libmp3tunes/md5.h b/amarok/src/services/mp3tunes/libmp3tunes/md5.h deleted file mode 100644 index 65d66056..00000000 --- a/amarok/src/services/mp3tunes/libmp3tunes/md5.h +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 1995,1996 Free Software Foundation Inc. * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef _LIBMP3TUNES_MD5_H -#define _LIBMP3TUNES_MD5_H - -#include -#include - -#define MD5_SIZE 16 -#define HEX_STRING "0123456789abcdef" /* to convert to hex */ -/*#include */ - -/* - * md5_sig_to_string - * - * DESCRIPTION: - * - * Convert a MD5 signature in a 16 byte buffer into a hexadecimal string - * representation. - * - * RETURNS: - * - * None. - * - * ARGUMENTS: - * - * signature - a 16 byte buffer that contains the MD5 signature. - * - * str - a string of charactes which should be at least 33 bytes long (2 - * characters per MD5 byte and 1 for the \0). - * - * str_len - the length of the string. - */ -void md5_sig_to_string(void *signature, char *str, const int str_len); - -/* - * md5_calc_file_signature - * - * DESCRIPTION: - * - * Calculates MD5 signature of the specified file contents and returns - * hexadecimal representation of the signature. - * - * RETURNS: - * - * Hexadecimal representation of the signature of NULL if it could not be - * calculated. The returned pointer should be freed with the free() - * function when it is no longer needed. - * - * ARGUMENTS: - * - * filename - a path to the file which MD5 signature should be calculated. - */ -char* md5_calc_file_signature(const char *filename); - -#endif diff --git a/amarok/src/services/mp3tunes/org.kde.amarok.Mp3tunesHarmonyHandler.xml b/amarok/src/services/mp3tunes/org.kde.amarok.Mp3tunesHarmonyHandler.xml deleted file mode 100644 index 05246f91..00000000 --- a/amarok/src/services/mp3tunes/org.kde.amarok.Mp3tunesHarmonyHandler.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/amarok/src/services/opmldirectory/AddOpmlWidget.ui b/amarok/src/services/opmldirectory/AddOpmlWidget.ui deleted file mode 100644 index 6f1c368b..00000000 --- a/amarok/src/services/opmldirectory/AddOpmlWidget.ui +++ /dev/null @@ -1,113 +0,0 @@ - - - AddOpmlWidget - - - - 0 - 0 - 530 - 117 - - - - - 0 - 0 - - - - - 530 - 117 - - - - - - - QLayout::SetMinimumSize - - - 10 - - - - - Add a local or remote OPML file to be included in the list. - - - true - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 100 - 20 - - - - - - - - - - URL: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - Title: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - If left blank the title from the OPML will be used. - - - - - - - - KUrlRequester - QFrame -
    kurlrequester.h
    - 1 -
    - - KLineEdit - QLineEdit -
    klineedit.h
    -
    -
    - - - - changed() - slotChanged() - -
    diff --git a/amarok/src/services/opmldirectory/CMakeLists.txt b/amarok/src/services/opmldirectory/CMakeLists.txt deleted file mode 100644 index e332c1eb..00000000 --- a/amarok/src/services/opmldirectory/CMakeLists.txt +++ /dev/null @@ -1,37 +0,0 @@ - include_directories( - ../ - ../.. - ../../core-impl/collections - ../../statusbar - ${CMAKE_CURRENT_BINARY_DIR}/../../.. - ${KDE4_INCLUDE_DIR} - ${QT_INCLUDES} ) - -########### next target ############### - - set(amarok_service_opmldirectory_PART_SRCS - OpmlDirectoryService.cpp - OpmlDirectoryMeta.cpp - OpmlDirectoryInfoParser.cpp - OpmlDirectoryModel.cpp - OpmlDirectoryView.cpp - AddOpmlWidget.ui - ) - - kde4_add_plugin(amarok_service_opmldirectory ${amarok_service_opmldirectory_PART_SRCS}) - target_link_libraries(amarok_service_opmldirectory - amarokcore - amaroklib - ${KDE4_KDECORE_LIBS} - ${KDE4_KDEUI_LIBS} - ${KDE4_KIO_LIBS} - ${KDE4_THREADWEAVER_LIBS} - ) - - install(TARGETS amarok_service_opmldirectory DESTINATION ${PLUGIN_INSTALL_DIR} ) - - -########### install files ############### - - install( FILES amarok_service_opmldirectory.desktop DESTINATION ${SERVICES_INSTALL_DIR}) - install( FILES podcast_directory.opml DESTINATION ${DATA_INSTALL_DIR}/amarok/data) diff --git a/amarok/src/services/opmldirectory/OpmlDirectoryDatabaseHandler.cpp b/amarok/src/services/opmldirectory/OpmlDirectoryDatabaseHandler.cpp deleted file mode 100644 index 194291b7..00000000 --- a/amarok/src/services/opmldirectory/OpmlDirectoryDatabaseHandler.cpp +++ /dev/null @@ -1,160 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "OpmlDirectoryDatabaseHandler.h" - -#include "core-impl/collections/support/CollectionManager.h" -#include "core/support/Debug.h" -#include - -using namespace Meta; - -OpmlDirectoryDatabaseHandler::OpmlDirectoryDatabaseHandler() -{} - -OpmlDirectoryDatabaseHandler::~OpmlDirectoryDatabaseHandler() -{} - -void -OpmlDirectoryDatabaseHandler::createDatabase() -{ - //Get database instance - SqlStorage *db = CollectionManager::instance()->sqlStorage(); - - QString genreAutoIncrement = ""; - - // create table containing feeds - QString queryString = "CREATE TABLE opmldirectory_tracks (" - "id INTEGER PRIMARY KEY AUTO_INCREMENT, " - "name " + db->textColumnType() + ',' + - "track_number INTEGER," - "length INTEGER," - "preview_url " + db->exactTextColumnType() + ',' + - "album_id INTEGER," - "artist_id INTEGER ) ENGINE = MyISAM;"; - - debug() << "Creating opmldirectory_tracks: " << queryString; - - QStringList result = db->query( queryString ); - - db->query( "CREATE INDEX opmldirectory_tracks_id ON opmldirectory_tracks(id);" ); - db->query( "CREATE INDEX opmldirectory_tracks_album_id ON opmldirectory_tracks(album_id);" ); - - // create table containing categories - queryString = "CREATE TABLE opmldirectory_albums (" - "id INTEGER PRIMARY KEY AUTO_INCREMENT, " - "name " + db->textColumnType() + ',' + - "description " + db->exactTextColumnType() + ',' + - "artist_id INTEGER ) ENGINE = MyISAM;"; - - result = db->query( queryString ); - db->query( "CREATE INDEX opmldirectory_albums_name ON opmldirectory_albums(name);" ); - - - //HACK!! monster hack actually! We really need a default dummy artist or the service query maker screws up big time- - // we also need a dummy genre it would seem.... - - queryString = "CREATE TABLE opmldirectory_artists (" - "id INTEGER PRIMARY KEY AUTO_INCREMENT, " - "name " + db->textColumnType() + ',' + - "description " + db->exactTextColumnType() + ") ENGINE = MyISAM;"; - - result = db->query( queryString ); - - //now, insert a default artist - SqlStorage *sqlDb = CollectionManager::instance()->sqlStorage(); - queryString = "INSERT INTO opmldirectory_artists ( id, name, description " - ") VALUES ( 1, 'dummy', 'dummy' );"; - - sqlDb->insert( queryString, QString() ); - - //create genre table - queryString = "CREATE TABLE opmldirectory_genre (" - "id INTEGER PRIMARY KEY AUTO_INCREMENT, " - "name " + db->textColumnType() + ',' + - "album_id INTEGER ) ENGINE = MyISAM;"; - - result = db->query( queryString ); -} - -void -OpmlDirectoryDatabaseHandler::destroyDatabase() -{ - SqlStorage *db = CollectionManager::instance()->sqlStorage(); - QStringList result = db->query( "DROP TABLE IF EXISTS opmldirectory_tracks;" ); - result = db->query( "DROP TABLE IF EXISTS opmldirectory_albums;" ); - result = db->query( "DROP TABLE IF EXISTS opmldirectory_artists;" ); - result = db->query( "DROP TABLE IF EXISTS opmldirectory_genre;"); - - result = db->query( "DROP INDEX IF EXISTS opmldirectory_tracks_id;"); - result = db->query( "DROP INDEX IF EXISTS opmldirectory_tracks_artist_id;"); - result = db->query( "DROP INDEX IF EXISTS opmldirectory_album_name;"); -} - -int -OpmlDirectoryDatabaseHandler::insertTrack( ServiceTrackPtr track ) -{ - SqlStorage *sqlDb = CollectionManager::instance()->sqlStorage(); - QString queryString = "INSERT INTO opmldirectory_tracks ( name, track_number, length, " - "album_id, artist_id, preview_url ) VALUES ( '" - + sqlDb->escape( track->name() ) + "', " - + QString::number( 0 ) + ", " - + QString::number( 0 ) + ", " - + QString::number( track->albumId() ) + ", " - + QString::number( 1 ) + ", '" - + sqlDb->escape( track->uidUrl() ) + "' );"; - - int trackId = sqlDb->insert( queryString, NULL ); - - return trackId; -} - -int -OpmlDirectoryDatabaseHandler::insertAlbum( ServiceAlbumPtr album ) -{ - QString queryString; - SqlStorage *sqlDb = CollectionManager::instance()->sqlStorage(); - queryString = "INSERT INTO opmldirectory_albums ( name, description, " - "artist_id ) VALUES ( '" - + sqlDb->escape( album->name() ) + "', '" - + sqlDb->escape( album->description() ) + "', " - + QString::number( 1 ) + ");"; - - int newAlbumId = sqlDb->insert( queryString, QString() ); - - //create a dummy genre for this album - queryString = "INSERT INTO opmldirectory_genre ( album_id, name " - ") VALUES ( " + QString::number ( newAlbumId ) + ", 'dummy');"; - - return sqlDb->insert( queryString, 0 ); -} - -void -OpmlDirectoryDatabaseHandler::begin() -{ - CollectionManager *mgr = CollectionManager::instance(); - QString queryString = "BEGIN;"; - mgr->sqlStorage()->query( queryString ); -} - -void -OpmlDirectoryDatabaseHandler::commit() -{ - CollectionManager *mgr = CollectionManager::instance(); - QString queryString = "COMMIT;"; - mgr->sqlStorage()->query( queryString ); -} - diff --git a/amarok/src/services/opmldirectory/OpmlDirectoryDatabaseHandler.h b/amarok/src/services/opmldirectory/OpmlDirectoryDatabaseHandler.h deleted file mode 100644 index 075ca56a..00000000 --- a/amarok/src/services/opmldirectory/OpmlDirectoryDatabaseHandler.h +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef OPMLDIRECTORYDATABASEHANDLER_H -#define OPMLDIRECTORYDATABASEHANDLER_H - -#include "OpmlDirectoryMeta.h" - - -#include -#include - - -/** - * This class wraps the database operations needed by the OpmlDirectory - * - * @author Nikolaj Hald Nielsen - */ -class OpmlDirectoryDatabaseHandler { -public: - /** - * Private constructor (singleton pattern) - * @return Pointer to new object - */ - OpmlDirectoryDatabaseHandler(); - ~OpmlDirectoryDatabaseHandler(); - - /** - * Creates the tables needed to store OpmlDirectory info - */ - void createDatabase(); - - /** - * Destroys OpmlDirectory tables - */ - void destroyDatabase(); - - /** - * Inserts a new track into the OpmlDirectory database - * @param track pointer to the track to insert - * @return the database id of the newly inserted track - */ - int insertTrack( Meta::ServiceTrackPtr track ); - - /** - * inserts a new album into the OpmlDirectory database - * @param album pointer to the album to insert - * @return the database id of the newly inserted album - */ - int insertAlbum( Meta::ServiceAlbumPtr album ); - - /** - * Begins a database transaction. Must be followed by a later call to commit() - */ - void begin(); - - /** - * Completes (executes) a database transaction. Must be preceded by a call to begin() - */ - void commit(); - - /** - * Remove all genres that are applied to too few albums in an attempt to weed out the worst mistags and - * speed up queries a bit! - * @param minCount cutoff value... - */ - void trimGenres( int minCount ); -}; - -#endif diff --git a/amarok/src/services/opmldirectory/OpmlDirectoryDelegate.cpp b/amarok/src/services/opmldirectory/OpmlDirectoryDelegate.cpp deleted file mode 100644 index e440f93a..00000000 --- a/amarok/src/services/opmldirectory/OpmlDirectoryDelegate.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Bart Cerneels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "OpmlDirectoryDelegate.h" - -OpmlDirectoryDelegate::OpmlDirectoryDelegate(QObject *parent) : - QStyledItemDelegate(parent) -{ -} diff --git a/amarok/src/services/opmldirectory/OpmlDirectoryDelegate.h b/amarok/src/services/opmldirectory/OpmlDirectoryDelegate.h deleted file mode 100644 index f0cafebc..00000000 --- a/amarok/src/services/opmldirectory/OpmlDirectoryDelegate.h +++ /dev/null @@ -1,34 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Bart Cerneels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef OPMLDIRECTORYDELEGATE_H -#define OPMLDIRECTORYDELEGATE_H - -#include - -class OpmlDirectoryDelegate : public QStyledItemDelegate -{ - Q_OBJECT -public: - explicit OpmlDirectoryDelegate(QObject *parent = 0); - -signals: - -public slots: - -}; - -#endif // OPMLDIRECTORYDELEGATE_H diff --git a/amarok/src/services/opmldirectory/OpmlDirectoryInfoParser.cpp b/amarok/src/services/opmldirectory/OpmlDirectoryInfoParser.cpp deleted file mode 100644 index d6fcf49a..00000000 --- a/amarok/src/services/opmldirectory/OpmlDirectoryInfoParser.cpp +++ /dev/null @@ -1,129 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "OpmlDirectoryInfoParser.h" - -#include "core/support/Debug.h" -#include "core/support/Components.h" -#include "core/interfaces/Logger.h" -#include "OpmlDirectoryMeta.h" - -#include - -#include - -using namespace Meta; - -OpmlDirectoryInfoParser::OpmlDirectoryInfoParser() - : InfoParserBase() - , m_rssDownloadJob( 0 ) -{ -} - - -OpmlDirectoryInfoParser::~OpmlDirectoryInfoParser() -{ -} - -void OpmlDirectoryInfoParser::getInfo(ArtistPtr artist) -{ - AMAROK_NOTIMPLEMENTED - Q_UNUSED( artist ); -} - -void OpmlDirectoryInfoParser::getInfo(AlbumPtr album) -{ - AMAROK_NOTIMPLEMENTED - Q_UNUSED( album ); -} - -void OpmlDirectoryInfoParser::getInfo( TrackPtr track ) -{ - DEBUG_BLOCK - showLoading( i18n( "Loading Podcast Info..." ) ); - - OpmlDirectoryFeed * feed = dynamic_cast( track.data() ); - - if ( !feed ) return; - - debug() << "OpmlDirectoryInfoParser: getInfo about feed: " << feed->uidUrl(); - - m_rssDownloadJob = KIO::storedGet( feed->uidUrl(), KIO::Reload, KIO::HideProgressInfo ); - Amarok::Components::logger()->newProgressOperation( m_rssDownloadJob, - i18n( "Fetching Podcast Info" ) ); - connect( m_rssDownloadJob, SIGNAL(result(KJob*)), SLOT(rssDownloadComplete(KJob*)) ); -} - -void OpmlDirectoryInfoParser::rssDownloadComplete(KJob * downLoadJob) -{ - - if ( downLoadJob->error() ) - { - //TODO: error handling here - return ; - } - - if ( downLoadJob != m_rssDownloadJob ) - return ; //not the right job, so let's ignore it - - QString rssString = ((KIO::StoredTransferJob* ) downLoadJob)->data(); - - debug() << "rss: " << rssString; - - QDomDocument doc( "reply" ); - if ( !doc.setContent( rssString ) ) - { - debug() << "could not set reply document to given RSS string"; - return; - } - - //there might be an rss node, there might not... - - QDomElement element = doc.firstChildElement( "rss" ); - if ( !element.isNull() ) { - element = element.firstChildElement( "channel" ); - } else { - element = doc.firstChildElement( "channel" ); - } - - QString description = element.firstChildElement( "description" ).text(); - QString title = element.firstChildElement( "title" ).text(); - - QString imageUrl; - QDomElement image = element.firstChildElement( "image" ); - - if ( !image.isNull() ) - imageUrl = image.firstChildElement( "url" ).text(); - - QString infoHtml = ""; - - infoHtml += "
    "; - infoHtml += title; - infoHtml += "

    "; - - if ( !imageUrl.isEmpty() ) - infoHtml += ""; - - infoHtml += "

    " + description; - infoHtml += ""; - - emit ( info( infoHtml ) ); - - downLoadJob->deleteLater(); -} - -#include "moc_OpmlDirectoryInfoParser.cpp" diff --git a/amarok/src/services/opmldirectory/OpmlDirectoryInfoParser.h b/amarok/src/services/opmldirectory/OpmlDirectoryInfoParser.h deleted file mode 100644 index 1bf077f8..00000000 --- a/amarok/src/services/opmldirectory/OpmlDirectoryInfoParser.h +++ /dev/null @@ -1,49 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef OPMLDIRECTORYINFOPARSER_H -#define OPMLDIRECTORYINFOPARSER_H - -#include - -#include -#include - - -/** - * Handles the fetching and processing of Jamendo specific information for meta items - */ -class OpmlDirectoryInfoParser : public InfoParserBase -{ -Q_OBJECT - -public: - OpmlDirectoryInfoParser(); - ~OpmlDirectoryInfoParser(); - - virtual void getInfo( Meta::ArtistPtr artist ); - virtual void getInfo( Meta::AlbumPtr album ); - virtual void getInfo( Meta::TrackPtr track ); - -private: - KJob * m_rssDownloadJob; - -private slots: - void rssDownloadComplete( KJob *downLoadJob ); - -}; - -#endif diff --git a/amarok/src/services/opmldirectory/OpmlDirectoryMeta.cpp b/amarok/src/services/opmldirectory/OpmlDirectoryMeta.cpp deleted file mode 100644 index 7c2a8265..00000000 --- a/amarok/src/services/opmldirectory/OpmlDirectoryMeta.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "OpmlDirectoryMeta.h" - -#include "OpmlDirectoryService.h" - -#include "core/support/Debug.h" - -using namespace Meta; - -OpmlDirectoryMetaFactory::OpmlDirectoryMetaFactory( const QString & dbPrefix, OpmlDirectoryService * ) - : ServiceMetaFactory( dbPrefix ) -{ -} - -TrackPtr OpmlDirectoryMetaFactory::createTrack( const QStringList & rows ) -{ - return TrackPtr( new OpmlDirectoryFeed( rows ) ); -} - - -AlbumPtr OpmlDirectoryMetaFactory::createAlbum( const QStringList & rows ) -{ - return AlbumPtr( new OpmlDirectoryCategory( rows ) ); -} - - -//// OpmlDirectoryFeed //// - -OpmlDirectoryFeed::OpmlDirectoryFeed( const QString &name ) - : ServiceTrack( name ) -{ -} - -OpmlDirectoryFeed::OpmlDirectoryFeed( const QStringList & resultRow ) - : ServiceTrack( resultRow ) -{ -} - -OpmlDirectoryCategory::OpmlDirectoryCategory( const QString & name ) - : ServiceAlbum( name ) -{ -} - -OpmlDirectoryCategory::OpmlDirectoryCategory( const QStringList & resultRow ) - : ServiceAlbum( resultRow ) -{ -} - - - - - diff --git a/amarok/src/services/opmldirectory/OpmlDirectoryMeta.h b/amarok/src/services/opmldirectory/OpmlDirectoryMeta.h deleted file mode 100644 index a13f9a95..00000000 --- a/amarok/src/services/opmldirectory/OpmlDirectoryMeta.h +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef OPMLDIRECTORYMETA_H -#define OPMLDIRECTORYMETA_H - - -#include "../ServiceMetaBase.h" - -#include -#include -#include -#include - -class OpmlDirectoryService; - -class OpmlDirectoryMetaFactory : public ServiceMetaFactory -{ - public: - OpmlDirectoryMetaFactory( const QString &dbPrefix, OpmlDirectoryService *service ); - virtual ~OpmlDirectoryMetaFactory() {} - - virtual Meta::TrackPtr createTrack( const QStringList &rows ); - virtual Meta::AlbumPtr createAlbum( const QStringList &rows ); -}; - - -namespace Meta -{ -class OpmlDirectoryFeed; -class OpmlDirectoryCategory; - -typedef KSharedPtr OpmlDirectoryFeedPtr; -typedef KSharedPtr OpmlDirectoryCategoryPtr; -class OpmlDirectoryFeed : public ServiceTrack -{ - - -public: - OpmlDirectoryFeed( const QString &name ); - OpmlDirectoryFeed( const QStringList &resultRow ); -}; - -class OpmlDirectoryCategory : public ServiceAlbum -{ - public: - OpmlDirectoryCategory( const QString &name ); - OpmlDirectoryCategory( const QStringList &resultRow ); -}; - -} - - -#endif diff --git a/amarok/src/services/opmldirectory/OpmlDirectoryModel.cpp b/amarok/src/services/opmldirectory/OpmlDirectoryModel.cpp deleted file mode 100644 index e4c5d9f1..00000000 --- a/amarok/src/services/opmldirectory/OpmlDirectoryModel.cpp +++ /dev/null @@ -1,514 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Bart Cerneels . * - ****************************************************************************************/ - -#include "OpmlDirectoryModel.h" - -#include "core/support/Amarok.h" -#include "MainWindow.h" -#include "OpmlParser.h" -#include "OpmlWriter.h" -#include "core/support/Debug.h" -//included to access defaultPodcasts() -#include "playlistmanager/PlaylistManager.h" -#include "core/podcasts/PodcastProvider.h" - -#include "ui_AddOpmlWidget.h" - -#include - -#include - -#include - -OpmlDirectoryModel::OpmlDirectoryModel( KUrl outlineUrl, QObject *parent ) - : QAbstractItemModel( parent ) - , m_rootOpmlUrl( outlineUrl ) -{ - //fetchMore will be called by the view - m_addOpmlAction = new QAction( KIcon( "list-add" ), i18n( "Add OPML" ), this ); - connect( m_addOpmlAction, SIGNAL(triggered()), SLOT(slotAddOpmlAction()) ); - - m_addFolderAction = new QAction( KIcon( "folder-add" ), i18n( "Add Folder"), this ); - connect( m_addFolderAction, SIGNAL(triggered()), SLOT(slotAddFolderAction()) ); -} - -OpmlDirectoryModel::~OpmlDirectoryModel() -{ -} - -QModelIndex -OpmlDirectoryModel::index( int row, int column, const QModelIndex &parent ) const -{ - if( !parent.isValid() ) - { - if( m_rootOutlines.isEmpty() || m_rootOutlines.count() <= row ) - return QModelIndex(); - else - return createIndex( row, column, m_rootOutlines[row] ); - } - - OpmlOutline *parentOutline = static_cast( parent.internalPointer() ); - if( !parentOutline ) - return QModelIndex(); - - if( !parentOutline->hasChildren() || parentOutline->children().count() <= row ) - return QModelIndex(); - - return createIndex( row, column, parentOutline->children()[row] ); -} - -Qt::ItemFlags -OpmlDirectoryModel::flags( const QModelIndex &idx ) const -{ - if( !idx.isValid() ) - return Qt::ItemIsDropEnabled; - - OpmlOutline *outline = static_cast( idx.internalPointer() ); - if( outline && !outline->attributes().contains( "type" ) ) //probably a folder - return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsDragEnabled - | Qt::ItemIsDropEnabled; - - return QAbstractItemModel::flags( idx ); -} - -QModelIndex -OpmlDirectoryModel::parent( const QModelIndex &idx ) const -{ - if( !idx.isValid() ) - return QModelIndex(); - debug() << idx; - OpmlOutline *outline = static_cast( idx.internalPointer() ); - if( outline->isRootItem() ) - return QModelIndex(); - - OpmlOutline *parentOutline = outline->parent(); - int childIndex; - if( parentOutline->isRootItem() ) - childIndex = m_rootOutlines.indexOf( parentOutline ); - else - childIndex = parentOutline->parent()->children().indexOf( parentOutline ); - return createIndex( childIndex, 0, parentOutline ); -} - -int -OpmlDirectoryModel::rowCount( const QModelIndex &parent ) const -{ - if( !parent.isValid() ) - return m_rootOutlines.count(); - - OpmlOutline *outline = static_cast( parent.internalPointer() ); - - if( !outline || !outline->hasChildren() ) - return 0; - else - return outline->children().count(); -} - -bool -OpmlDirectoryModel::hasChildren( const QModelIndex &parent ) const -{ - debug() << parent; - if( !parent.isValid() ) - return !m_rootOutlines.isEmpty(); - - OpmlOutline *outline = static_cast( parent.internalPointer() ); - - if( !outline ) - return false; - - if( outline->hasChildren() ) - return true; - - return outline->attributes().value( "type" ) == "include"; -} - -int -OpmlDirectoryModel::columnCount( const QModelIndex &parent ) const -{ - Q_UNUSED(parent) - return 1; -} - -QVariant -OpmlDirectoryModel::data( const QModelIndex &idx, int role ) const -{ - if( !idx.isValid() ) - { - if( role == ActionRole ) - { - QList actions; - actions << m_addOpmlAction << m_addFolderAction; - return QVariant::fromValue( actions ); - } - return QVariant(); - } - - OpmlOutline *outline = static_cast( idx.internalPointer() ); - if( !outline ) - return QVariant(); - - switch( role ) - { - case Qt::DisplayRole: - return outline->attributes()["text"]; - case Qt::DecorationRole: - return m_imageMap.contains( outline ) ? m_imageMap.value( outline ) : QVariant(); - case ActionRole: - { - if( outline->opmlNodeType() == RegularNode ) //probably a folder - { - //store the index the new item should get added to - m_addOpmlAction->setData( QVariant::fromValue( idx ) ); - m_addFolderAction->setData( QVariant::fromValue( idx ) ); - return QVariant::fromValue( QActionList() << m_addOpmlAction << m_addFolderAction ); - } - } - default: - return QVariant(); - } - - return QVariant(); -} - -bool -OpmlDirectoryModel::setData( const QModelIndex &idx, const QVariant &value, int role ) -{ - Q_UNUSED(role); - - if( !idx.isValid() ) - return false; - - OpmlOutline *outline = static_cast( idx.internalPointer() ); - if( !outline ) - return false; - - outline->mutableAttributes()["text"] = value.toString(); - - saveOpml( m_rootOpmlUrl ); - - return true; -} - -bool -OpmlDirectoryModel::removeRows( int row, int count, const QModelIndex &parent ) -{ - if( !parent.isValid() ) - { - if( m_rootOutlines.count() >= ( row + count ) ) - { - beginRemoveRows( parent, row, row + count - 1 ); - for( int i = 0; i < count; i++ ) - m_rootOutlines.removeAt( row ); - endRemoveRows(); - saveOpml( m_rootOpmlUrl ); - return true; - } - - return false; - } - - OpmlOutline *outline = static_cast( parent.internalPointer() ); - if( !outline ) - return false; - - if( !outline->hasChildren() || outline->children().count() < ( row + count ) ) - return false; - - beginRemoveRows( parent, row, row + count -1 ); - for( int i = 0; i < count - 1; i++ ) - outline->mutableChildren().removeAt( row ); - endRemoveRows(); - - saveOpml( m_rootOpmlUrl ); - - return true; -} - -void -OpmlDirectoryModel::saveOpml( const KUrl &saveLocation ) -{ - if( !saveLocation.isLocalFile() ) - { - //TODO:implement - error() << "can not save OPML to remote location"; - return; - } - - QFile *opmlFile = new QFile( saveLocation.toLocalFile(), this ); - if( !opmlFile->open( QIODevice::WriteOnly | QIODevice::Truncate ) ) - { - error() << "could not open OPML file for writing " << saveLocation.url(); - return; - } - - QMap headerData; - //TODO: set header data such as date - - OpmlWriter *opmlWriter = new OpmlWriter( m_rootOutlines, headerData, opmlFile ); - connect( opmlWriter, SIGNAL(result(int)), SLOT(slotOpmlWriterDone(int)) ); - opmlWriter->run(); -} - -void -OpmlDirectoryModel::slotOpmlWriterDone( int result ) -{ - Q_UNUSED( result ) - - OpmlWriter *writer = qobject_cast( QObject::sender() ); - Q_ASSERT( writer ); - writer->device()->close(); - delete writer; -} - -OpmlNodeType -OpmlDirectoryModel::opmlNodeType( const QModelIndex &idx ) const -{ - OpmlOutline *outline = static_cast( idx.internalPointer() ); - return outline->opmlNodeType(); -} - -void -OpmlDirectoryModel::slotAddOpmlAction() -{ - QModelIndex parentIdx = QModelIndex(); - QAction *action = qobject_cast( sender() ); - if( action ) - { - parentIdx = action->data().value(); - } - - KDialog *dialog = new KDialog( The::mainWindow() ); - dialog->setCaption( i18nc( "Heading of Add OPML dialog", "Add OPML" ) ); - dialog->setButtons( KDialog::Ok | KDialog::Cancel ); - QWidget *opmlAddWidget = new QWidget( dialog ); - Ui::AddOpmlWidget widget; - widget.setupUi( opmlAddWidget ); - widget.urlEdit->setMode( KFile::File ); - dialog->setMainWidget( opmlAddWidget ); - - if( dialog->exec() != QDialog::Accepted ) - return; - - QString url = widget.urlEdit->url().url(); - QString title = widget.titleEdit->text(); - debug() << QString( "creating a new OPML outline with url = %1 and title \"%2\"." ).arg( url, title ); - OpmlOutline *outline = new OpmlOutline(); - outline->addAttribute( "type", "include" ); - outline->addAttribute( "url", url ); - if( !title.isEmpty() ) - outline->addAttribute( "text", title ); - - //Folder icon with down-arrow emblem - m_imageMap.insert( outline, KIcon( "folder", 0, QStringList( "go-down" ) ).pixmap( 24, 24 ) ); - - QModelIndex newIdx = addOutlineToModel( parentIdx, outline ); - //TODO: force the view to expand the folder (parentIdx) so the new node is shown - - //if the title is missing, start parsing the OPML so we can get it from the feed - if( outline->attributes().contains( "text" ) ) - saveOpml( m_rootOpmlUrl ); - else - fetchMore( newIdx ); //saves OPML after receiving the title. - - delete dialog; -} - -void -OpmlDirectoryModel::slotAddFolderAction() -{ - QModelIndex parentIdx = QModelIndex(); - QAction *action = qobject_cast( sender() ); - if( action ) - { - parentIdx = action->data().value(); - } - - OpmlOutline *outline = new OpmlOutline(); - outline->addAttribute( "text", i18n( "New Folder" ) ); - m_imageMap.insert( outline, KIcon( "folder" ).pixmap( 24, 24 ) ); - - addOutlineToModel( parentIdx, outline ); - //TODO: trigger edit of the new folder - - saveOpml( m_rootOpmlUrl ); -} - -bool -OpmlDirectoryModel::canFetchMore( const QModelIndex &parent ) const -{ - debug() << parent; - //already fetched or just started? - if( rowCount( parent ) || m_currentFetchingMap.values().contains( parent ) ) - return false; - if( !parent.isValid() ) - return m_rootOutlines.isEmpty(); - - OpmlOutline *outline = static_cast( parent.internalPointer() ); - - return outline && ( outline->attributes().value( "type" ) == "include" ); -} - -void -OpmlDirectoryModel::fetchMore( const QModelIndex &parent ) -{ - debug() << parent; - if( m_currentFetchingMap.values().contains( parent ) ) - { - error() << "trying to start second fetch job for same item"; - return; - } - KUrl urlToFetch; - if( !parent.isValid() ) - { - urlToFetch = m_rootOpmlUrl; - } - else - { - OpmlOutline *outline = static_cast( parent.internalPointer() ); - if( !outline ) - return; - if( outline->attributes().value( "type" ) != "include" ) - return; - urlToFetch = KUrl( outline->attributes()["url"] ); - } - - if( !urlToFetch.isValid() ) - return; - - OpmlParser *parser = new OpmlParser( urlToFetch ); - connect( parser, SIGNAL(headerDone()), SLOT(slotOpmlHeaderDone()) ); - connect( parser, SIGNAL(outlineParsed(OpmlOutline*)), - SLOT(slotOpmlOutlineParsed(OpmlOutline*)) ); - connect( parser, SIGNAL(doneParsing()), SLOT(slotOpmlParsingDone()) ); - - m_currentFetchingMap.insert( parser, parent ); - -// ThreadWeaver::Weaver::instance()->enqueue( parser ); - parser->run(); -} - -void -OpmlDirectoryModel::slotOpmlHeaderDone() -{ - OpmlParser *parser = qobject_cast( QObject::sender() ); - QModelIndex idx = m_currentFetchingMap.value( parser ); - - if( !idx.isValid() ) //header data of the root not required. - return; - - OpmlOutline *outline = static_cast( idx.internalPointer() ); - - if( !outline->attributes().contains("text") ) - { - if( parser->headerData().contains( "title" ) ) - outline->addAttribute( "text", parser->headerData()["title"] ); - else - outline->addAttribute( "text", parser->url().fileName() ); - - //force a view update - emit dataChanged( idx, idx ); - - saveOpml( m_rootOpmlUrl ); - } - -} - -void -OpmlDirectoryModel::slotOpmlOutlineParsed( OpmlOutline *outline ) -{ - OpmlParser *parser = qobject_cast( QObject::sender() ); - QModelIndex idx = m_currentFetchingMap.value( parser ); - - addOutlineToModel( idx, outline ); - - //TODO: begin image fetch - switch( outline->opmlNodeType() ) - { - case RegularNode: - m_imageMap.insert( outline, KIcon( "folder" ).pixmap( 24, 24 ) ); break; - case IncludeNode: - { - m_imageMap.insert( outline, - KIcon( "folder", 0, QStringList( "go-down" ) ).pixmap( 24, 24 ) - ); - break; - } - case RssUrlNode: - default: break; - } -} - -void -OpmlDirectoryModel::slotOpmlParsingDone() -{ - OpmlParser *parser = qobject_cast( QObject::sender() ); - m_currentFetchingMap.remove( parser ); - parser->deleteLater(); -} - -void -OpmlDirectoryModel::subscribe( const QModelIndexList &indexes ) const -{ - QList outlines; - - foreach( const QModelIndex &idx, indexes ) - outlines << static_cast( idx.internalPointer() ); - - foreach( const OpmlOutline *outline, outlines ) - { - if( !outline ) - continue; - - KUrl url; - if( outline->attributes().contains( "xmlUrl" ) ) - url = KUrl( outline->attributes()["xmlUrl"] ); - else if( outline->attributes().contains( "url" ) ) - url = KUrl( outline->attributes()["url"] ); - - if( url.isEmpty() ) - continue; - - The::playlistManager()->defaultPodcasts()->addPodcast( url ); - } -} - -QModelIndex -OpmlDirectoryModel::addOutlineToModel( QModelIndex parentIdx, OpmlOutline *outline ) -{ - int newRow = rowCount( parentIdx ); - beginInsertRows( parentIdx, newRow, newRow ); - - //no reparenting required when the item is already parented. - if( outline->isRootItem() ) - { - if( parentIdx.isValid() ) - { - OpmlOutline * parentOutline = static_cast( parentIdx.internalPointer() ); - Q_ASSERT(parentOutline); - - outline->setParent( parentOutline ); - parentOutline->addChild( outline ); - parentOutline->setHasChildren( true ); - } - else - { - m_rootOutlines << outline; - } - } - endInsertRows(); - - return index( newRow, 0, parentIdx ); -} diff --git a/amarok/src/services/opmldirectory/OpmlDirectoryModel.h b/amarok/src/services/opmldirectory/OpmlDirectoryModel.h deleted file mode 100644 index d804d2bd..00000000 --- a/amarok/src/services/opmldirectory/OpmlDirectoryModel.h +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Bart Cerneels . * - ****************************************************************************************/ - -#ifndef OPMLDIRECTORYMODEL_H -#define OPMLDIRECTORYMODEL_H - -#include "OpmlOutline.h" - -#include - -#include - -class OpmlParser; - -class QAction; -typedef QList QActionList; - -class OpmlDirectoryModel : public QAbstractItemModel -{ - Q_OBJECT -public: - //TODO: make these rols part of a common class in Amarok::. - enum - { - ActionRole = Qt::UserRole, //list of QActions for the index - DecorationUriRole, //a URI for the decoration to be fetched by the view. - CustomRoleOffset //first role that can be used by sublasses for their own data - }; - - explicit OpmlDirectoryModel( KUrl outlineUrl, QObject *parent = 0 ); - ~OpmlDirectoryModel(); - - // QAbstractItemModel methods - virtual QModelIndex index( int row, int column, const QModelIndex &parent = QModelIndex() ) const; - virtual Qt::ItemFlags flags( const QModelIndex &index ) const; - virtual QModelIndex parent( const QModelIndex &index ) const; - virtual int rowCount( const QModelIndex &parent = QModelIndex() ) const; - virtual bool hasChildren( const QModelIndex &parent = QModelIndex() ) const; - virtual int columnCount( const QModelIndex &parent = QModelIndex() ) const; - virtual QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const; - virtual bool setData( const QModelIndex &index, const QVariant &value, int role = Qt::EditRole ); - virtual bool removeRows( int row, int count, const QModelIndex &parent = QModelIndex() ); - - // OpmlDirectoryModel methods - virtual void saveOpml( const KUrl &saveLocation ); - virtual OpmlNodeType opmlNodeType( const QModelIndex &idx ) const; - - //TODO: extract these into OpmlPodcastDirectoryModel subclass - void subscribe( const QModelIndexList &indexes ) const; - -signals: - -public slots: - void slotAddOpmlAction(); - void slotAddFolderAction(); - -protected: - virtual bool canFetchMore( const QModelIndex &parent ) const; - virtual void fetchMore( const QModelIndex &parent ); - -private slots: - void slotOpmlHeaderDone(); - void slotOpmlOutlineParsed( OpmlOutline * ); - void slotOpmlParsingDone(); - void slotOpmlWriterDone( int result ); - -private: - QModelIndex addOutlineToModel( QModelIndex parentIdx, OpmlOutline *oultine ); - - KUrl m_rootOpmlUrl; - QList m_rootOutlines; - - QMap m_currentFetchingMap; - QMap m_imageMap; - - QAction *m_addOpmlAction; - QAction *m_addFolderAction; -}; - -Q_DECLARE_METATYPE(QActionList) -//we store these in a QVariant for the addFolder and addOpml actions -Q_DECLARE_METATYPE( QModelIndex ) - -#endif // OPMLDIRECTORYMODEL_H diff --git a/amarok/src/services/opmldirectory/OpmlDirectoryService.cpp b/amarok/src/services/opmldirectory/OpmlDirectoryService.cpp deleted file mode 100644 index 8ddb245c..00000000 --- a/amarok/src/services/opmldirectory/OpmlDirectoryService.cpp +++ /dev/null @@ -1,201 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "OpmlDirectoryService.h" - -#include "amarokurls/AmarokUrlHandler.h" -#include "core/support/Debug.h" -#include "core/support/Components.h" -#include "core/interfaces/Logger.h" -#include "browsers/CollectionTreeItem.h" -#include "browsers/SingleCollectionTreeItemModel.h" -#include "OpmlDirectoryInfoParser.h" -#include "OpmlDirectoryModel.h" -#include "OpmlDirectoryView.h" -#include "playlistmanager/PlaylistManager.h" -#include "core/podcasts/PodcastProvider.h" -#include "ServiceSqlRegistry.h" -#include "widgets/SearchWidget.h" - -#include -#include -#include - -#include - -using namespace Meta; - -AMAROK_EXPORT_SERVICE_PLUGIN( opmldirectory, OpmlDirectoryServiceFactory ) - -OpmlDirectoryServiceFactory::OpmlDirectoryServiceFactory( QObject *parent, const QVariantList &args ) - : ServiceFactory( parent, args ) -{ - KPluginInfo pluginInfo( "amarok_service_opmldirectory.desktop", "services" ); - pluginInfo.setConfig( config() ); - m_info = pluginInfo; -} - -void OpmlDirectoryServiceFactory::init() -{ - ServiceBase* service = new OpmlDirectoryService( this, "OpmlDirectory", i18n( "Podcast Directory" ) ); - m_initialized = true; - emit newService( service ); -} - - -QString OpmlDirectoryServiceFactory::name() -{ - return "OpmlDirectory"; -} - -KConfigGroup OpmlDirectoryServiceFactory::config() -{ - return Amarok::config( "Service_OpmlDirectory" ); -} - - -OpmlDirectoryService::OpmlDirectoryService( OpmlDirectoryServiceFactory* parent, const QString &name, const QString &prettyName ) - : ServiceBase( name, parent, false, prettyName ) -{ - setShortDescription( i18n( "A large listing of podcasts" ) ); - setIcon( KIcon( "view-services-opml-amarok" ) ); - - setLongDescription( i18n( "A comprehensive list of searchable podcasts that you can subscribe to directly from within Amarok." ) ); - - KIconLoader loader; - setImagePath( loader.iconPath( "view-services-opml-amarok", -128, true ) ); - - The::amarokUrlHandler()->registerRunner( this, command() ); - - setServiceReady( true ); -} - - -OpmlDirectoryService::~OpmlDirectoryService() -{ -} - -void OpmlDirectoryService::polish() -{ - generateWidgetInfo(); - if ( m_polished ) - return; - - //do not allow this content to get added to the playlist. At least not for now - setPlayableTracks( false ); - - //TODO: implement searching - m_searchWidget->setVisible( false ); - - OpmlDirectoryView* opmlView = new OpmlDirectoryView( this ); - opmlView->setHeaderHidden( true ); - opmlView->setFrameShape( QFrame::NoFrame ); - opmlView->setDragEnabled ( true ); - opmlView->setSortingEnabled( false ); - opmlView->setSelectionMode( QAbstractItemView::ExtendedSelection ); - opmlView->setDragDropMode ( QAbstractItemView::DragOnly ); - opmlView->setEditTriggers( QAbstractItemView::SelectedClicked | QAbstractItemView::EditKeyPressed ); - setView( opmlView ); - KUrl opmlLocation( Amarok::saveLocation() ); - opmlLocation.addPath( "podcast_directory.opml" ); - - if( !QFile::exists( opmlLocation.toLocalFile() ) ) - { - //copy from the standard data dir - KUrl schippedOpmlLocation( KStandardDirs::locate( "data", "amarok/data/" ) ); - schippedOpmlLocation.addPath( "podcast_directory.opml" ); - if( !QFile::copy( schippedOpmlLocation.toLocalFile(), opmlLocation.toLocalFile() ) ) - { - debug() << QString( "Failed to copy from %1 to %2" ) - .arg( schippedOpmlLocation.toLocalFile(), opmlLocation.toLocalFile() ); - //TODO: error box drawn in the view's area. - return; - } - } - - setModel( new OpmlDirectoryModel( opmlLocation, this ) ); - - m_subscribeButton = new QPushButton( m_bottomPanel ); - m_subscribeButton->setText( i18n( "Subscribe" ) ); - m_subscribeButton->setObjectName( "subscribeButton" ); - m_subscribeButton->setIcon( KIcon( "get-hot-new-stuff-amarok" ) ); - - m_subscribeButton->setEnabled( false ); - - connect( m_subscribeButton, SIGNAL(clicked()), this, SLOT(subscribe()) ); - - m_addOpmlButton = new QPushButton( m_bottomPanel ); - m_addOpmlButton->setText( i18n( "Add OPML" ) ); - m_addOpmlButton->setObjectName( "addOpmlButton" ); - m_addOpmlButton->setIcon( KIcon( "list-add-amarok" ) ); - - connect( m_addOpmlButton, SIGNAL(clicked()), model(), SLOT(slotAddOpmlAction()) ); - - connect( view()->selectionModel(), - SIGNAL(selectionChanged(QItemSelection,QItemSelection)), - SLOT(slotSelectionChanged(QItemSelection,QItemSelection)) - ); - - setInfoParser( new OpmlDirectoryInfoParser() ); - - m_polished = true; -} - -QString -OpmlDirectoryService::command() const -{ - return "service-podcastdirectory"; -} - -QString -OpmlDirectoryService::prettyCommand() const -{ - return i18n( "Add an OPML file to the list." ); -} - -bool -OpmlDirectoryService::run( AmarokUrl url ) -{ - //make sure this category is shown. - AmarokUrl( "amarok://navigate/internet/OpmlDirectory" ).run(); - if( url.path() == QLatin1String( "addOpml" ) ) - { - OpmlDirectoryModel *opmlModel = qobject_cast( model() ); - Q_ASSERT_X(opmlModel, "OpmlDirectoryService::run()", "fix if a proxy is used"); - - opmlModel->slotAddOpmlAction(); - return true; - } - - return false; -} - -void -OpmlDirectoryService::subscribe() -{ - OpmlDirectoryModel * opmlModel = dynamic_cast( model() ); - Q_ASSERT( opmlModel ); - opmlModel->subscribe( view()->selectionModel()->selectedIndexes() ); -} - -void -OpmlDirectoryService::slotSelectionChanged( const QItemSelection &selected, - const QItemSelection &deselected ) -{ - Q_UNUSED(selected) - Q_UNUSED(deselected) - m_subscribeButton->setEnabled( !view()->selectionModel()->selectedIndexes().isEmpty() ); -} diff --git a/amarok/src/services/opmldirectory/OpmlDirectoryService.h b/amarok/src/services/opmldirectory/OpmlDirectoryService.h deleted file mode 100644 index d678a7c3..00000000 --- a/amarok/src/services/opmldirectory/OpmlDirectoryService.h +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef OPMLDIRECTORYSERVICE_H -#define OPMLDIRECTORYSERVICE_H - - -#include "amarokurls/AmarokUrlRunnerBase.h" -#include "../ServiceBase.h" -#include "OpmlDirectoryDatabaseHandler.h" -#include "ServiceSqlCollection.h" - -#include "core/support/Amarok.h" -#include -#include - -class OpmlOutline; - -class OpmlDirectoryServiceFactory: public ServiceFactory -{ - Q_OBJECT - - public: - OpmlDirectoryServiceFactory( QObject *parent, const QVariantList &args ); - virtual ~OpmlDirectoryServiceFactory() {} - - virtual void init(); - virtual QString name(); - virtual KConfigGroup config(); -}; - -/** -A service for displaying, previewing and downloading music from OpmlDirectory.com - - @author -*/ -class OpmlDirectoryService : public ServiceBase, public AmarokUrlRunnerBase -{ - Q_OBJECT - public: - OpmlDirectoryService( OpmlDirectoryServiceFactory* parent, const QString &name, - const QString &prettyName ); - - ~OpmlDirectoryService(); - - void polish(); - - virtual Collections::Collection * collection() { return 0; } - - /* UrlRunnerBase methods */ - virtual QString command() const; - virtual QString prettyCommand() const; - virtual bool run( AmarokUrl url ); - virtual KIcon icon() const { return KIcon( "view-services-opml-amarok" ); } - - private slots: - void subscribe(); - void slotSelectionChanged( const QItemSelection &, const QItemSelection & ); - - private: - - QPushButton *m_addOpmlButton; - QPushButton *m_subscribeButton; - - int m_currentCategoryId; - - int m_numberOfFeeds; - int m_numberOfCategories; -}; - -#endif diff --git a/amarok/src/services/opmldirectory/OpmlDirectoryView.cpp b/amarok/src/services/opmldirectory/OpmlDirectoryView.cpp deleted file mode 100644 index da1bec95..00000000 --- a/amarok/src/services/opmldirectory/OpmlDirectoryView.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Bart Cerneels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "OpmlDirectoryView.h" - -#include "OpmlDirectoryModel.h" - -#include "core/support/Debug.h" - -#include - -#include - -OpmlDirectoryView::OpmlDirectoryView( QWidget *parent ) : - Amarok::PrettyTreeView(parent) -{ -} - -void -OpmlDirectoryView::contextMenuEvent( QContextMenuEvent *event ) -{ - QModelIndex idx = indexAt( event->pos() ); - - debug() << idx; - - event->accept(); - - QVariant data = model()->data( idx, OpmlDirectoryModel::ActionRole ); - QActionList actions = data.value(); - - if( actions.isEmpty() ) - { - return; - } - - KMenu menu; - foreach( QAction *action, actions ) - { - if( action ) - menu.addAction( action ); - } - - menu.exec( mapToGlobal( event->pos() ) ); - - //We keep the items that the actions need to be applied to in the actions private data. - //Clear the data from all actions now that the context menu has executed. - foreach( QAction *action, actions ) - action->setData( QVariant() ); -} - -void -OpmlDirectoryView::keyPressEvent( QKeyEvent *event ) -{ - switch( event->key() ) - { - case Qt::Key_Delete: - { - foreach( const QItemSelectionRange &range, selectionModel()->selection() ) - model()->removeRows( range.top(), range.height(), range.parent() ); - event->accept(); - return; - } - } - Amarok::PrettyTreeView::keyPressEvent( event ); -} - -QItemSelectionModel::SelectionFlags -OpmlDirectoryView::selectionCommand ( const QModelIndex &index, const QEvent *event ) const -{ - if( model()->hasChildren( index ) ) - return QItemSelectionModel::ClearAndSelect; - - return Amarok::PrettyTreeView::selectionCommand( index, event ); -} diff --git a/amarok/src/services/opmldirectory/OpmlDirectoryView.h b/amarok/src/services/opmldirectory/OpmlDirectoryView.h deleted file mode 100644 index 6a61a2be..00000000 --- a/amarok/src/services/opmldirectory/OpmlDirectoryView.h +++ /dev/null @@ -1,41 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Bart Cerneels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef OPMLDIRECTORYVIEW_H -#define OPMLDIRECTORYVIEW_H - -#include "widgets/PrettyTreeView.h" - -class QContextMenuEvent; -class QKeyEvent; - -class OpmlDirectoryView : public Amarok::PrettyTreeView -{ - Q_OBJECT - public: - explicit OpmlDirectoryView( QWidget *parent = 0 ); - - virtual void contextMenuEvent( QContextMenuEvent *event ); - virtual void keyPressEvent( QKeyEvent *event ); - - protected: - //reimplemented to allow only leaf nodes to be selected - virtual QItemSelectionModel::SelectionFlags selectionCommand( const QModelIndex &index, - const QEvent *event = 0 ) const; - -}; - -#endif // OPMLDIRECTORYVIEW_H diff --git a/amarok/src/services/opmldirectory/amarok_service_opmldirectory.desktop b/amarok/src/services/opmldirectory/amarok_service_opmldirectory.desktop deleted file mode 100644 index 93db90db..00000000 --- a/amarok/src/services/opmldirectory/amarok_service_opmldirectory.desktop +++ /dev/null @@ -1,127 +0,0 @@ -[Desktop Entry] -Type=Service -ServiceTypes=KPluginInfo -Icon=view-services-opml-amarok -Name=Podcast Directory -Name[bg]=Подкастове -Name[bs]=Podcast direktorij -Name[ca]=Directori de podcasts -Name[ca@valencia]=Directori de podcasts -Name[cs]=Adresář podcastů -Name[csb]=Katalog pòdcastów -Name[da]=Podcast-liste -Name[de]=Podcast-Verzeichnis -Name[el]=Κατάλογος Podcast -Name[en_GB]=Podcast Directory -Name[es]=Directorio de podcast -Name[et]=Podcastide kataloog -Name[eu]=Podcast-en direktorioa -Name[fi]=Podcast-kansio -Name[fr]=Dossier de podcasts -Name[ga]=Eolaire Podchraoltaí -Name[gl]=Directorio de Podcast -Name[hu]=Podcast Directory -Name[id]=Direktori Podcast -Name[is]=Podcast mappa -Name[it]=Podcast Directory -Name[ja]=ポッドキャストディレクトリ -Name[km]=ថត​ផតខាស់ -Name[ko]=팟캐스트 목록 -Name[lt]=Garso prenumeratų aplankas -Name[lv]=Podraižu katalogs -Name[nb]=Podkastkatalog -Name[nds]=Podcast-Orner -Name[nl]=Podcastmap -Name[nn]=Podkast-katalog -Name[pa]=ਪੋਡਕਾਸਟ ਡਾਇਰੈਕਟਰੀ -Name[pl]=Katalog podcastów -Name[pt]=Pasta de 'Podcasts' -Name[pt_BR]=Pasta de Podcast -Name[ro]=Director Podcast -Name[ru]=Каталог подкастов -Name[sk]=Priečinok podcastov -Name[sl]=Imenik podcastov -Name[sr]=Фасцикла подемисија -Name[sr@ijekavian]=Фасцикла подемисија -Name[sr@ijekavianlatin]=Fascikla podemisija -Name[sr@latin]=Fascikla podemisija -Name[sv]=Podsändningskatalog -Name[th]=ไดเรกทอรีพ็อดแคสต์ -Name[tr]=Podcast Dizini -Name[uk]=Каталог трансляцій -Name[wa]=Ridant des podcasts -Name[x-test]=xxPodcast Directoryxx -Name[zh_CN]=播客目录 -Name[zh_TW]=Podcast 資料夾 -Comment=Browse and subscribe to a huge list of podcasts -Comment[bg]=Разглеждане и абониране за голям брой подкастове -Comment[bs]=Pregledajte i pretplatite se na ogromnu listu podemisija -Comment[ca]=Navegueu i subscriviu-vos a una àmplia llista de podcasts -Comment[ca@valencia]=Navegueu i subscriviu-vos a una àmplia llista de podcasts -Comment[cs]=Prohlížení a registrace obrovského množství podcastů -Comment[da]=Gennemse og abonnér på en enorm liste over podcasts -Comment[de]=Eine umfangreiche Liste an Podcasts durchsehen und abonnieren -Comment[el]=Περιήγηση και εγγραφή σε μια τεράστια λίστα εκπομπών pod -Comment[en_GB]=Browse and subscribe to a huge list of podcasts -Comment[es]=Navegar y suscribirse a una enorme lista de podcast -Comment[et]=Tohutu hulga podcastide sirvimine ja tellimine -Comment[eu]=Arakatu eta harpidetu podcast-en zerrenda izugarrira -Comment[fi]=Ota käyttöön kattava valikoima podcasteja -Comment[fr]=Parcourir et s'inscrire à un énorme choix de podcasts -Comment[ga]=Brabhsáil agus liostáil le podchraoltaí ó liosta ollmhór -Comment[gl]=Navegue e subscrébase a unha lista enorme de podcasts -Comment[hu]=Böngészés egy óriási podcast-listában, feliratkozás podcastokra -Comment[id]=Melihat-lihat dan berlangganan daftar besar pada podcast -Comment[is]=Skoða og gerast áskrifandi að fjölmörgum podkast hlaðvörpum -Comment[it]=Sfoglia e registrati a un enorme elenco di podcast -Comment[ja]=広範なポッドキャストのリストをブラウズして購読できます -Comment[km]=រកមើល និង​ជាវ​ទៅ​បញ្ជី​ផតខាស់​ធំៗ -Comment[ko]=팟캐스트 목록을 보고 구독하기 -Comment[ku]=Binihêre û bibe endamê lîsteya mezin yê podcast ê -Comment[lt]=Naršyti ir užsisakyti podcast iš didžiulio sąrašo -Comment[lv]=Pārlūkojiet un pasūtiniet no milzīga podraižu saraksta -Comment[nb]=Bla gjennom og abonner på en veldig stor samling av podcasts -Comment[nds]=En groot List vun Podcasts dörkieken un bestellen -Comment[nl]=Blader door en luister naar een enorm aantal podcasts -Comment[nn]=Sjå gjennom og abonner på ei lang rekkje podkastar -Comment[pl]=Przeglądaj i zapisz się do ogromnej listy podcastów -Comment[pt]=Navegar e inscrever numa enorme lista de 'podcasts' -Comment[pt_BR]=Navegue e inscreva-se em uma lista enorme de podcasts -Comment[ro]=Răsfoiți și abonați-vă la o listă uriașă de podcasturi -Comment[ru]=Обзор и подписка на огромный список подкастов -Comment[sk]=Prehliadanie a registrácia obrovského množstva podcastov -Comment[sl]=Brskajte po obsežni zbirki podcastov in se naročite nanje -Comment[sr]=Прегледајте и претплатите се на огромну листу подемисија -Comment[sr@ijekavian]=Прегледајте и претплатите се на огромну листу подемисија -Comment[sr@ijekavianlatin]=Pregledajte i pretplatite se na ogromnu listu podemisija -Comment[sr@latin]=Pregledajte i pretplatite se na ogromnu listu podemisija -Comment[sv]=Bläddra i och prenumerera på en enorm samling podsändningar -Comment[th]=เรียกดูและขอรับข้อมูลรายการเพลงขนาดมหึมาของบริการพ็อดแคสต์ -Comment[tr]=Geniş bir podcast listesine gözat ve üye ol -Comment[uk]=Перегляньте і підпишіться на трансляції з величезного списку -Comment[wa]=Foyter eyet s' abouner a ene djivêye di podcast foû mezeure -Comment[x-test]=xxBrowse and subscribe to a huge list of podcastsxx -Comment[zh_CN]=浏览并订阅大量播客列表 -Comment[zh_TW]=瀏覽並訂閱大量的 podcast 清單 - - -ServiceTypes=Amarok/Plugin - -X-KDE-Library=amarok_service_opmldirectory - -X-KDE-Amarok-authors=Nikolaj Hald Nielsen -X-KDE-Amarok-email=nhnFreespirit@gmail.com -X-KDE-Amarok-framework-version=72 -X-KDE-Amarok-name=JamendoService -X-KDE-Amarok-plugintype=service -X-KDE-Amarok-rank=100 -X-KDE-Amarok-version=1 - -X-KDE-PluginInfo-Author=Nikolaj Hald Nielsen -X-KDE-PluginInfo-Email=nhnFreespirit@gmail.com -X-KDE-PluginInfo-Version=1.0 -X-KDE-PluginInfo-Category=Service -X-KDE-PluginInfo-License=GPL -X-KDE-PluginInfo-EnabledByDefault=true -X-KDE-Library=amarok_service_opmldirectory -X-KDE-PluginInfo-Name=amarok_service_opmldirectory diff --git a/amarok/src/services/opmldirectory/podcast_directory.opml b/amarok/src/services/opmldirectory/podcast_directory.opml deleted file mode 100644 index 70b8ada6..00000000 --- a/amarok/src/services/opmldirectory/podcast_directory.opml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/amarok/src/services/scriptable/ScriptableService.cpp b/amarok/src/services/scriptable/ScriptableService.cpp deleted file mode 100644 index 26d25fda..00000000 --- a/amarok/src/services/scriptable/ScriptableService.cpp +++ /dev/null @@ -1,419 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "ScriptableService.h" - -#include "scripting/scriptmanager/ScriptManager.h" -#include "browsers/CollectionTreeItem.h" -#include "browsers/SingleCollectionTreeItemModel.h" -#include "browsers/servicebrowser/ServiceBrowser.h" -#include "core/support/Amarok.h" -#include "core/support/Debug.h" -#include "services/scriptable/ScriptableServiceCollectionTreeModel.h" -#include "services/scriptable/ScriptableServiceInfoParser.h" -#include "widgets/SearchWidget.h" - -#include - -using namespace Meta; - -ScriptableService::ScriptableService( const QString & name ) - : ServiceBase( name, 0 ) - , m_polished( false ) - , m_name( name ) - , m_trackIdCounter( 0 ) - , m_albumIdCounter( 0 ) - , m_artistIdCounter( 0 ) - , m_genreIdCounter( 0 ) -{ - DEBUG_BLOCK - debug() << "creating ScriptableService " << name; - m_collection = 0; - m_bottomPanel->hide(); - -} - -ScriptableService::~ScriptableService() -{ - m_collection->deleteLater(); -} - -void ScriptableService::init( int levels, const QString & rootHtml, bool showSearchBar ) -{ - DEBUG_BLOCK - m_levels = levels; - m_rootHtml = rootHtml; - m_hasSearchBar = showSearchBar; - m_searchWidget->showAdvancedButton( false ); - setInfoParser( new ScriptableServiceInfoParser( m_name ) ); - m_collection = new Collections::ScriptableServiceCollection( m_name ); - m_collection->setLevels( levels ); - - if ( !showSearchBar ) - m_searchWidget->hide(); -} - -Collections::ServiceCollection * ScriptableService::collection() -{ - return m_collection; -} - - -int ScriptableService::insertItem( int level, int parentId, const QString & name, const QString & infoHtml, const QString & callbackData, const QString & playableUrl, - const QString & albumOverride, const QString & artistOverride, const QString & genreOverride, - const QString & composerOverride, int yearOverride, const QString &coverUrl ) -{ - - /* - please don't remove this block as I regularly need it for debugging - nhn - DEBUG_BLOCK - debug() << "level: " << level; - debug() << "parentId: " << parentId; - debug() << "name: " << name; - debug() << "infoHtml: " << infoHtml; - debug() << "callbackData: " << callbackData; - debug() << "playableUrl: " << playableUrl; - - debug() << "albumOverride: " << albumOverride; - debug() << "artistOverride: " << artistOverride; - debug() << "coverUrl: " << coverUrl;*/ - - if ( ( level +1 > m_levels ) || level < 0 ) - return -1; - - switch ( level ) { - - case 0: - { - if( !callbackData.isEmpty() || playableUrl.isEmpty() ) - return -1; - - KSharedPtr track( new ScriptableServiceTrack( name ) ); - track->setAlbumId( parentId ); - track->setUidUrl( playableUrl ); - track->setServiceName( m_name ); - track->setDescription( infoHtml ); - - if ( !m_customEmblem.isNull() ) - track->setServiceEmblem( m_customEmblem ); - else - track->setServiceEmblem( QPixmap( KStandardDirs::locate( "data", "amarok/images/emblem-scripted.png" ) ) ); - - if ( !m_customScalableEmblem.isEmpty() ) - track->setServiceScalableEmblem( m_customScalableEmblem ); - else - track->setServiceEmblem( KStandardDirs::locate( "data", "amarok/images/emblem-scripted-scalable.svgz" ) ); - - if ( !albumOverride.isEmpty() ) - track->setAlbumName( albumOverride ); - if ( !artistOverride.isEmpty() ) - track->setArtistName( artistOverride ); - if ( !genreOverride.isEmpty() ) - track->setGenreName( genreOverride ); - if ( !composerOverride.isEmpty() ) - track->setComposerName( composerOverride ); - if ( yearOverride != 0 ) - track->setYearNumber( yearOverride ); - if ( !coverUrl.isEmpty() ) - track->setCustomAlbumCoverUrl( coverUrl ); - - return addTrack( track.data() ); - break; - - } case 1: - { - if ( callbackData.isEmpty() || !playableUrl.isEmpty() ) - return -1; - - ScriptableServiceAlbum * album = new ScriptableServiceAlbum( name ); - album->setCallbackString( callbackData ); - album->setArtistId( parentId ); - album->setDescription( infoHtml ); - album->setServiceName( m_name ); - //debug() << "setting coverUrl: " << coverUrl; - album->setCoverUrl( coverUrl ); - - album->setServiceName( m_name ); - album->setDescription( infoHtml ); - - if ( !m_customEmblem.isNull() ) - album->setServiceEmblem( m_customEmblem ); - else - album->setServiceEmblem( QPixmap( KStandardDirs::locate( "data", "amarok/images/emblem-scripted.png" ) ) ); - - if ( !m_customScalableEmblem.isEmpty() ) - album->setServiceScalableEmblem( m_customScalableEmblem ); - else - album->setServiceEmblem( KStandardDirs::locate( "data", "amarok/images/emblem-scripted-scalable.svgz" ) ); - - return addAlbum( album ); - - } case 2: - { - if ( callbackData.isEmpty() || !playableUrl.isEmpty() ) - return -1; - - ScriptableServiceArtist * artist = new ScriptableServiceArtist( name ); - artist->setCallbackString( callbackData ); - artist->setGenreId( parentId ); - artist->setDescription( infoHtml ); - artist->setServiceName( m_name ); - - artist->setServiceName( m_name ); - artist->setDescription( infoHtml ); - - if ( !m_customEmblem.isNull() ) - artist->setServiceEmblem( m_customEmblem ); - else - artist->setServiceEmblem( QPixmap( KStandardDirs::locate( "data", "amarok/images/emblem-scripted.png" ) ) ); - - if ( !m_customScalableEmblem.isEmpty() ) - artist->setServiceScalableEmblem( m_customScalableEmblem ); - else - artist->setServiceEmblem( KStandardDirs::locate( "data", "amarok/images/emblem-scripted-scalable.svgz" ) ); - - - return addArtist( artist ); - - } case 3: - { - - if ( callbackData.isEmpty() || !playableUrl.isEmpty() || parentId != -1 ) - return -1; - - ScriptableServiceGenre * genre = new ScriptableServiceGenre( name ); - genre->setCallbackString( callbackData ); - genre->setDescription( infoHtml ); - genre->setServiceName( m_name ); - - genre->setServiceName( m_name ); - genre->setDescription( infoHtml ); - - if ( !m_customEmblem.isNull() ) - genre->setServiceEmblem( m_customEmblem ); - else - genre->setServiceEmblem( QPixmap( KStandardDirs::locate( "data", "amarok/images/emblem-scripted.png" ) ) ); - - if ( !m_customScalableEmblem.isEmpty() ) - genre->setServiceScalableEmblem( m_customScalableEmblem ); - else - genre->setServiceEmblem( KStandardDirs::locate( "data", "amarok/images/emblem-scripted-scalable.svgz" ) ); - - - return addGenre( genre ); - - } - } - return -1; -} - - -int ScriptableService::addTrack( ScriptableServiceTrack * track ) -{ - int artistId = -1; - int genreId = -1; - - TrackPtr trackPtr = TrackPtr( track ); - m_collection->acquireWriteLock(); - m_collection->addTrack( trackPtr ); - m_collection->releaseLock(); - - m_trackIdCounter++; - track->setId( m_trackIdCounter ); - - - int albumId = track->albumId(); - - //handle albums - if ( m_levels > 1 ) { - - if ( !m_ssAlbumIdMap.contains( albumId ) ){ - return -1; - } - - ScriptableServiceAlbum * album = m_ssAlbumIdMap.value( albumId ); - - track->setAlbum( album->prettyName() ); - track->setAlbumPtr( AlbumPtr( album ) ); - album->addTrack( trackPtr ); - - artistId = album->artistId(); - - } - - if ( m_levels > 2 ) { - - if ( !m_ssArtistIdMap.contains( artistId ) ) { - return -1; - } - - ScriptableServiceArtist * artist = m_ssArtistIdMap.value( artistId ); - track->setArtist( artist->prettyName() ); - track->setArtist( ArtistPtr( artist ) ); - artist->addTrack( trackPtr ); - - genreId = artist->genreId(); - } - - if ( m_levels == 4) { - - if ( !m_ssGenreIdMap.contains( genreId ) ) { - return -1; - } - - ScriptableServiceGenre * genre = m_ssGenreIdMap.value( genreId ); - track->setGenre( genre->prettyName() ); - track->setGenre( GenrePtr( genre ) ); - genre->addTrack( trackPtr ); - - } - - m_ssTrackIdMap.insert( m_trackIdCounter, track ); - m_collection->acquireWriteLock(); - m_collection->addTrack( trackPtr ); - m_collection->releaseLock(); - - //m_collection->emitUpdated(); - - return m_trackIdCounter; -} - -int ScriptableService::addAlbum( ScriptableServiceAlbum * album ) -{ - int artistId = album->artistId(); - if ( m_levels > 2 && !m_ssArtistIdMap.contains( artistId ) ) { - delete album; - return -1; - } - - album->setAlbumArtist( ArtistPtr( m_ssArtistIdMap.value( artistId ) ) ); - - AlbumPtr albumPtr = AlbumPtr( album ); - m_albumIdCounter++; - album->setId( m_albumIdCounter ); - m_ssAlbumIdMap.insert( m_albumIdCounter, album ); - m_collection->acquireWriteLock(); - m_collection->addAlbum( albumPtr ); - m_collection->releaseLock(); - //m_collection->emitUpdated(); - return m_albumIdCounter; -} - -int ScriptableService::addArtist( Meta::ScriptableServiceArtist * artist ) -{ - int genreId = artist->genreId(); - if ( m_levels > 3 && !m_ssGenreIdMap.contains( genreId ) ) { - delete artist; - return -1; - } - - ArtistPtr artistPtr = ArtistPtr( artist ); - m_artistIdCounter++; - artist->setId( m_artistIdCounter ); - m_ssArtistIdMap.insert( m_artistIdCounter, artist ); - m_collection->acquireWriteLock(); - m_collection->addArtist( artistPtr ); - m_collection->releaseLock(); - - return m_artistIdCounter; - -} - -int ScriptableService::addGenre( Meta::ScriptableServiceGenre * genre ) -{ - GenrePtr genrePtr = GenrePtr( genre ); - m_genreIdCounter++; - - //debug() << "adding genre: " << genre->name() << ", with id: " << m_genreIdCounter; - - genre->setId( m_genreIdCounter ); - m_ssGenreIdMap.insert( m_genreIdCounter, genre ); - m_collection->acquireWriteLock(); - m_collection->addGenre( genrePtr ); - m_collection->releaseLock(); - - return m_genreIdCounter; -} - -void ScriptableService::donePopulating( int parentId ) -{ - m_collection->donePopulating( parentId ); -} - -void ScriptableService::polish() -{ - - if ( !m_polished ) { - QList viewLevels; - - switch ( m_levels ) { - case 1: - break; - case 2: - viewLevels << CategoryId::Album; - break; - case 3: - viewLevels << CategoryId::Artist << CategoryId::Album; - break; - case 4: - viewLevels << CategoryId::Genre << CategoryId::Artist << CategoryId::Album; - break; - default: - return; - } - - m_contentView->setModel( new ScriptableServiceCollectionTreeModel( m_collection, viewLevels ) ); - m_polished = true; - - } - - infoChanged( m_rootHtml ); -} - -void ScriptableService::setCustomEmblem( const QPixmap &emblem ) -{ - m_customEmblem = emblem; -} - -QPixmap ScriptableService::customEmblem() -{ - return m_customEmblem; -} - - -QString ScriptableService::customScalableEmblem() -{ - return m_customScalableEmblem; -} - - -void ScriptableService::setCustomScalableEmblem ( const QString& emblemPath ) -{ - m_customScalableEmblem = emblemPath; -} - - - -void ScriptableService::setCurrentInfo( const QString & info ) -{ - infoChanged( info ); -} - - - -#include "moc_ScriptableService.cpp" - - diff --git a/amarok/src/services/scriptable/ScriptableService.h b/amarok/src/services/scriptable/ScriptableService.h deleted file mode 100644 index a814fdb4..00000000 --- a/amarok/src/services/scriptable/ScriptableService.h +++ /dev/null @@ -1,123 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROKSCRIPTABLESERVICE_H -#define AMAROKSCRIPTABLESERVICE_H - - -#include "core/support/Amarok.h" -#include "../ServiceBase.h" -#include "ScriptableServiceMeta.h" -#include "ScriptableServiceCollection.h" - - -/* internally, we use the following level mapping: - 0 = track - 1 = album - 2 = artist - 3 = genre - -but we do our best to make this invisible to the scripts -*/ - -typedef QMap ScriptableServiceTrackIdMap; -typedef QMap ScriptableServiceArtistIdMap; -typedef QMap ScriptableServiceAlbumIdMap; -typedef QMap ScriptableServiceGenreIdMap; - - -class ScriptableService : public ServiceBase -{ - Q_OBJECT - -public: - - /** - * Constructor - */ - ScriptableService( const QString &name ); - - /** - * Destructor - */ - ~ScriptableService(); - - void init( int levels, const QString &rootHtml, bool showSearchBar ); - - void polish(); - - Collections::ServiceCollection * collection(); - - int insertItem( int level, int parentId, const QString &name, const QString &infoHtml, const QString &callbackData, const QString &playableUrl, - const QString & albumOverride, const QString & artistOverride, const QString & genreOverride, - const QString & composerOverride, int yearOverride, const QString &coverUrl ); - - - - void donePopulating( int parentId ); - - void setCustomEmblem( const QPixmap &emblem ); - QPixmap customEmblem(); - - - void setCustomScalableEmblem( const QString &emblemPath ); - QString customScalableEmblem(); - - void setCurrentInfo( const QString & info ); - - int contentLevels() { return m_levels; } - bool hasSearchBar() { return m_hasSearchBar; } - -private slots: - - - //void treeItemSelected( const QModelIndex & index ); - //void infoChanged ( QString infoHtml ); - - -private: - - bool m_polished; - - QString m_name; - QString m_rootHtml; - - int m_levels; - bool m_hasSearchBar; - - int addTrack( Meta::ScriptableServiceTrack * track ); - int addAlbum( Meta::ScriptableServiceAlbum * album ); - int addArtist( Meta::ScriptableServiceArtist * artist ); - int addGenre( Meta::ScriptableServiceGenre * genre ); - - Collections::ScriptableServiceCollection * m_collection; - int m_trackIdCounter; - int m_albumIdCounter; - int m_artistIdCounter; - int m_genreIdCounter; - - ScriptableServiceTrackIdMap m_ssTrackIdMap; - ScriptableServiceAlbumIdMap m_ssAlbumIdMap; - ScriptableServiceArtistIdMap m_ssArtistIdMap; - ScriptableServiceGenreIdMap m_ssGenreIdMap; - - QPixmap m_customEmblem; - QString m_customScalableEmblem; - -}; - - -#endif diff --git a/amarok/src/services/scriptable/ScriptableServiceCollection.cpp b/amarok/src/services/scriptable/ScriptableServiceCollection.cpp deleted file mode 100644 index 71369d67..00000000 --- a/amarok/src/services/scriptable/ScriptableServiceCollection.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "ScriptableServiceCollection.h" - -#include "core/support/Debug.h" -#include "ScriptableServiceQueryMaker.h" - -using namespace Collections; - -ScriptableServiceCollection::ScriptableServiceCollection( const QString &name ) - : ServiceCollection( 0, name, name ) -{ - DEBUG_BLOCK - m_name = name; -} - - -ScriptableServiceCollection::~ScriptableServiceCollection() -{ -} - -Collections::QueryMaker * ScriptableServiceCollection::queryMaker() -{ - return new ScriptableServiceQueryMaker( this, m_name ); -} - -void ScriptableServiceCollection::donePopulating( int parentId ) -{ - DEBUG_BLOCK - Q_UNUSED( parentId ); - emit updateComplete(); -} - -void ScriptableServiceCollection::clear() -{ - acquireWriteLock(); - genreMap().clear(); - setGenreMap( GenreMap() ); - artistMap().clear(); - setArtistMap( ArtistMap() ); - albumMap().clear(); - setAlbumMap( AlbumMap() ); - trackMap().clear(); - setTrackMap( TrackMap() ); - releaseLock(); -} - diff --git a/amarok/src/services/scriptable/ScriptableServiceCollection.h b/amarok/src/services/scriptable/ScriptableServiceCollection.h deleted file mode 100644 index 42147ade..00000000 --- a/amarok/src/services/scriptable/ScriptableServiceCollection.h +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef DYNAMICSCRIPTABLESERVICECOLLECTION_H -#define DYNAMICSCRIPTABLESERVICECOLLECTION_H - -#include "../ServiceCollection.h" -#include "AmarokProcess.h" - -namespace Collections { - -/** -A collection that can call back a script to populate items as needed. - - @author -*/ -class ScriptableServiceCollection : public ServiceCollection -{ - Q_OBJECT -public: - ScriptableServiceCollection( const QString &name ); - - ~ScriptableServiceCollection(); - - virtual Collections::QueryMaker* queryMaker(); - - void donePopulating( int parentId ); - - void setLevels( int theValue ) { - m_levels = theValue; - } - - int levels() const { - return m_levels; - } - - void setLastFilter( const QString & filter ) { m_lastFilter = filter; } - QString lastFilter() { return m_lastFilter; } - - void clear(); - - signals: - void updateComplete(); - -private: - - QString m_name; - int m_levels; - QString m_lastFilter; - -}; - -} //namespace Collections - -#endif diff --git a/amarok/src/services/scriptable/ScriptableServiceCollectionTreeModel.cpp b/amarok/src/services/scriptable/ScriptableServiceCollectionTreeModel.cpp deleted file mode 100644 index b0fb5c4e..00000000 --- a/amarok/src/services/scriptable/ScriptableServiceCollectionTreeModel.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2013 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "ScriptableServiceCollectionTreeModel" - -#include "ScriptableServiceCollectionTreeModel.h" - -#include "AmarokMimeData.h" -#include "core/support/Debug.h" -#include "core-impl/collections/support/TextualQueryFilter.h" -#include "services/scriptable/ScriptableServiceMeta.h" -#include "services/scriptable/ScriptableServiceQueryMaker.h" - -ScriptableServiceCollectionTreeModel::ScriptableServiceCollectionTreeModel( - Collections::Collection *collection, - const QList &levelType ) - : SingleCollectionTreeItemModel( collection, levelType ) -{ -} - -QMimeData * -ScriptableServiceCollectionTreeModel::mimeData( const QList &items ) const -{ - // this is basically a copy of superclass method with a couple of changes: - // 1. we don't reuse tracks already in the model - // 2. we tell the querymaker to masquerade special tracks - - using namespace Collections; - Meta::TrackList tracks; - QList queries; - foreach( CollectionTreeItem *item, items ) - { - if( item->isTrackItem() ) - { - using namespace Meta; - const ScriptableServiceTrack *serviceTrack = - dynamic_cast( item->data().data() ); - if( !serviceTrack ) - { - error() << "failed to convert generic track" << item->data() << "to ScriptableServiceTrack"; - continue; - } - tracks << serviceTrack->playableTrack(); - continue; - } - - ScriptableServiceQueryMaker *qm = qobject_cast( item->queryMaker() ); - if( !qm ) - { - error() << "failed to convert generic QueryMaker to ScriptableService one"; - continue; - } - qm->setConvertToMultiTracks( true ); - for( CollectionTreeItem *tmp = item; tmp; tmp = tmp->parent() ) - tmp->addMatch( qm, levelCategory( tmp->level() - 1 ) ); - Collections::addTextualFilter( qm, m_currentFilter ); - queries.append( qm ); - } - - if( queries.isEmpty() && tracks.isEmpty() ) - return 0; - - AmarokMimeData *mimeData = new AmarokMimeData(); - mimeData->setTracks( tracks ); - mimeData->setQueryMakers( queries ); - mimeData->startQueries(); - return mimeData; -} diff --git a/amarok/src/services/scriptable/ScriptableServiceCollectionTreeModel.h b/amarok/src/services/scriptable/ScriptableServiceCollectionTreeModel.h deleted file mode 100644 index 03ad7175..00000000 --- a/amarok/src/services/scriptable/ScriptableServiceCollectionTreeModel.h +++ /dev/null @@ -1,40 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2013 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef SCRIPTABLESERVICECOLLECTIONTREEMODEL_H -#define SCRIPTABLESERVICECOLLECTIONTREEMODEL_H - -#include "browsers/SingleCollectionTreeItemModel.h" - -/** - * Tiny wrapper around SingleCollectionTreeItemModel that implements - * converting service tracks that are in fact playlist to MultiTracks (for mime data, - * with help of ScriptableServiceQueryMaker - */ -class ScriptableServiceCollectionTreeModel : public SingleCollectionTreeItemModel -{ - public: - ScriptableServiceCollectionTreeModel( Collections::Collection *collection, - const QList &levelType ); - - using SingleCollectionTreeItemModel::mimeData; // prevent warning - /** - * Overridden to masquerade playlist tracks as MultiTracks - */ - virtual QMimeData* mimeData( const QList &items ) const; -}; - -#endif // SCRIPTABLESERVICECOLLECTIONTREEMODEL_H diff --git a/amarok/src/services/scriptable/ScriptableServiceInfoParser.cpp b/amarok/src/services/scriptable/ScriptableServiceInfoParser.cpp deleted file mode 100644 index 4eb97a14..00000000 --- a/amarok/src/services/scriptable/ScriptableServiceInfoParser.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "ScriptableServiceInfoParser.h" - -#include "scripting/scriptmanager/ScriptManager.h" -#include "services/ServiceMetaBase.h" - -using namespace Meta; - -ScriptableServiceInfoParser::ScriptableServiceInfoParser( const QString &serviceName ) - : InfoParserBase() - , m_serviceName( serviceName ) -{ -} - - -ScriptableServiceInfoParser::~ScriptableServiceInfoParser() -{ -} - -void ScriptableServiceInfoParser::getInfo( ArtistPtr artist ) -{ - ScriptableServiceArtist * serviceArtist = dynamic_cast< ScriptableServiceArtist * >( artist.data() ); - if (serviceArtist == 0) return; - - emit( info( serviceArtist->description() ) ); - - if ( serviceArtist->description().isEmpty() ) - { - showLoading( i18n( "Loading info..." ) ); - ScriptManager::instance()->ServiceScriptRequestInfo( m_serviceName, serviceArtist->level(), serviceArtist->callbackString() ); - } -} - -void ScriptableServiceInfoParser::getInfo(AlbumPtr album) -{ - DEBUG_BLOCK - ScriptableServiceAlbum * serviceAlbum = dynamic_cast< ScriptableServiceAlbum * >( album.data() ); - if (serviceAlbum == 0) return; - - emit( info( serviceAlbum->description() ) ); - - if ( serviceAlbum->description().isEmpty() ) - { - showLoading( i18n( "Loading info..." ) ); - ScriptManager::instance()->ServiceScriptRequestInfo( m_serviceName, serviceAlbum->level(), serviceAlbum->callbackString() ); - } -} - -void ScriptableServiceInfoParser::getInfo(TrackPtr track) -{ - DEBUG_BLOCK - ScriptableServiceTrack * serviceTrack = dynamic_cast< ScriptableServiceTrack * >( track.data() ); - if (serviceTrack == 0) return; - - emit( info( serviceTrack->description() ) ); - - if ( serviceTrack->description().isEmpty() ) - { - showLoading( i18n( "Loading info..." ) ); - ScriptManager::instance()->ServiceScriptRequestInfo( m_serviceName, serviceTrack->level(), serviceTrack->callbackString() ); - } -} - -void ScriptableServiceInfoParser::getInfo( Meta::GenrePtr genre ) -{ - ScriptableServiceGenre * serviceGenre = dynamic_cast< ScriptableServiceGenre * >( genre.data() ); - if (serviceGenre == 0) return; - - emit( info( serviceGenre->description() ) ); - - if ( serviceGenre->description().isEmpty() ) - { - showLoading( i18n( "Loading info..." ) ); - ScriptManager::instance()->ServiceScriptRequestInfo( m_serviceName, serviceGenre->level(), serviceGenre->callbackString() ); - } -} diff --git a/amarok/src/services/scriptable/ScriptableServiceInfoParser.h b/amarok/src/services/scriptable/ScriptableServiceInfoParser.h deleted file mode 100644 index 3077a53b..00000000 --- a/amarok/src/services/scriptable/ScriptableServiceInfoParser.h +++ /dev/null @@ -1,47 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef SCRIPTABLESERVICEINFOPARSER_H -#define SCRIPTABLESERVICEINFOPARSER_H - -#include "../InfoParserBase.h" -#include "ScriptableServiceMeta.h" - -/** -Info parser for the scriptable services - - @author -*/ -class ScriptableServiceInfoParser : public InfoParserBase -{ -Q_OBJECT -public: - ScriptableServiceInfoParser( const QString &serviceName ); - - ~ScriptableServiceInfoParser(); - - - virtual void getInfo( Meta::GenrePtr genre ); - virtual void getInfo( Meta::ArtistPtr artist ); - virtual void getInfo( Meta::AlbumPtr album ) ; - virtual void getInfo( Meta::TrackPtr track ); - -private: - QString m_serviceName; - -}; - -#endif diff --git a/amarok/src/services/scriptable/ScriptableServiceManager.cpp b/amarok/src/services/scriptable/ScriptableServiceManager.cpp deleted file mode 100644 index 633cedc4..00000000 --- a/amarok/src/services/scriptable/ScriptableServiceManager.cpp +++ /dev/null @@ -1,187 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "ScriptableServiceManager.h" - - -#include "core-impl/collections/support/MemoryCollection.h" -#include "core/support/Debug.h" -#include "ScriptableServiceCollection.h" -#include "ScriptableServiceMeta.h" -#include "scripting/scriptmanager/ScriptManager.h" -#include "../ServiceMetaBase.h" -#include "browsers/servicebrowser/ServiceBrowser.h" - -#include - -using namespace Meta; - -ScriptableServiceManager * ScriptableServiceManager::s_instance = 0; - - -ScriptableServiceManager::ScriptableServiceManager() -{} - - -ScriptableServiceManager::~ScriptableServiceManager() -{ - DEBUG_BLOCK -} - - -bool ScriptableServiceManager::initService( const QString &name, int levels, const QString &shortDescription, const QString &rootHtml, bool showSearchBar ) { - - DEBUG_BLOCK - - debug() << "initializing scripted service: " << name; - - ScriptableService * service = new ScriptableService ( name ); - m_serviceMap[name] = service; - - service->setIcon( KIcon( "view-services-scripted-amarok" ) ); - service->setShortDescription( shortDescription ); - service->init( levels, rootHtml, showSearchBar ); - m_rootHtml = rootHtml; - - debug() << "emitting scripted service " << name; - emit addService( service ); - - return true; -} - - -int ScriptableServiceManager::insertItem( const QString &serviceName, int level, int parentId, const QString &name, const QString &infoHtml, const QString &callbackData, const QString &playableUrl, - const QString & albumOverride, const QString & artistOverride, const QString & genreOverride, - const QString & composerOverride, int yearOverride, const QString &coverUrl) -{ - if ( !m_serviceMap.contains( serviceName ) ) { - //invalid service name - return -1; - } - - return m_serviceMap[serviceName]->insertItem( level, parentId, name, infoHtml, callbackData, playableUrl, albumOverride, artistOverride, genreOverride, composerOverride, yearOverride, coverUrl ); - - //return -1; // FIXME: what should this return? -} - -void ScriptableServiceManager::setCurrentInfo( const QString &serviceName, const QString & info ) -{ - DEBUG_BLOCK - if ( !m_serviceMap.contains( serviceName ) ) { - //invalid service name - return; - } - - m_serviceMap[serviceName]->setCurrentInfo( info ); -} - - -void ScriptableServiceManager::donePopulating(const QString & serviceName, int parentId) -{ - DEBUG_BLOCK - debug() << "Service name: " << serviceName << ", parent id: " << parentId; - if ( !m_serviceMap.contains( serviceName ) ) { - //invalid service name - return; - } - - m_serviceMap[serviceName]->donePopulating( parentId ); -} - -void ScriptableServiceManager::removeRunningScript(const QString & name) -{ - if ( !m_serviceMap.contains( name ) ) { - debug() << "no such service to remove"; - return; - } - - //service gets deleted by serviceBrowser - ServiceBrowser::instance()->removeCategory( m_serviceMap.take( name ) ); -} - -void ScriptableServiceManager::setIcon( const QString & serviceName, const QPixmap & icon ) -{ - DEBUG_BLOCK - debug() << "service: " << serviceName; - if ( !m_serviceMap.contains( serviceName ) ) { - //invalid service name - debug() << "does not exist.... "; - return; - } - - - m_serviceMap[serviceName]->setIcon( KIcon( QIcon( icon ) ) ); - emit( serviceUpdated( m_serviceMap[serviceName] ) ); -} - -void ScriptableServiceManager::setEmblem( const QString & serviceName, const QPixmap & emblem ) -{ - if ( !m_serviceMap.contains( serviceName ) ) { - //invalid service name - return; - } - - m_serviceMap[serviceName]->setCustomEmblem( emblem ); - emit( serviceUpdated( m_serviceMap[serviceName] ) ); -} - - -void ScriptableServiceManager::setScalableEmblem ( const QString& serviceName, const QString& emblemPath ) -{ - if ( !m_serviceMap.contains( serviceName ) ) { - //invalid service name - return; - } - - m_serviceMap[serviceName]->setCustomScalableEmblem( emblemPath ); - emit( serviceUpdated( m_serviceMap[serviceName] ) ); -} - - -ScriptableService * ScriptableServiceManager::service(const QString &name) -{ - - if ( !m_serviceMap.contains( name ) ) { - return 0; - } - - return m_serviceMap[name]; -} - - -namespace The { - ScriptableServiceManager* - scriptableServiceManager() - { - if ( ScriptableServiceManager::s_instance == 0 ) - ScriptableServiceManager::s_instance = new ScriptableServiceManager(); - - return ScriptableServiceManager::s_instance; - } -} - - - - - - -#include "moc_ScriptableServiceManager.cpp" - - - - - - diff --git a/amarok/src/services/scriptable/ScriptableServiceManager.h b/amarok/src/services/scriptable/ScriptableServiceManager.h deleted file mode 100644 index c7c58b7b..00000000 --- a/amarok/src/services/scriptable/ScriptableServiceManager.h +++ /dev/null @@ -1,115 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROKSCRIPTABLESERVICEMANAGER_H -#define AMAROKSCRIPTABLESERVICEMANAGER_H - -#include "AmarokProcess.h" -#include "../ServiceBase.h" -#include "ScriptableService.h" - -#include -#include - -class ScriptableServiceManager; - -namespace The { - AMAROK_EXPORT ScriptableServiceManager* scriptableServiceManager(); -} - -class ScriptableServiceManager : public QObject -{ - Q_OBJECT - - friend ScriptableServiceManager* The::scriptableServiceManager(); - - public: - void removeRunningScript( const QString &name ); - ScriptableService * service( const QString &name ); - - - signals: - /** - * Signal emitted whenever a new service is ready to be added - * @param service The service to add - */ - void addService( ServiceBase * service ); - - void serviceUpdated( ServiceBase * service ); - - public slots: - - /** - * Initialzises a new service. This method is exported to DBUS - * @param name the name of the service to create. Mujst be the same as the name of the script - * @param levels How many levels of items should be added ( 1 - 4 ) - * @param rootHtml The html to display when the service is selected - * @return returns true if successful and false otherwise - */ - bool initService( const QString &name, int levels, const QString &shortDescription, const QString &rootHtml, bool showSearchBar ); - - /** - * Add a new item to a service - * @param serviceName The name of the service to add an item to - * @param level The level of this item - * @param parentId The id of the parent item that this item should be a child of ( -1 if no parent ) - * @param name The name of this item - * @param infoHtml The html info to display when this item is selected - * @param callbackData The callback data needed to let the script know how to populate this items children ( Empty string if leaf item ) - * @param playableUrl The url to play if added to the playlist ( Empty string if not leaf node ) - * @return the id of the created item ( or -1 on failure ) - */ - int insertItem( const QString &serviceName, int level, int parentId, const QString &name, const QString &infoHtml, const QString &callbackData, const QString &playableUrl, - const QString & albumOverride, const QString & artistOverride, const QString & genreOverride, - const QString & composerOverride, int yearOverride, const QString &coverUrl ); - - - /** - * Let the service know that the script has added all child nodes - * @param serviceName The service we have been adding items to - * @param parentId The id of the parent node - */ - void donePopulating( const QString &serviceName, int parentId ); - - void setIcon( const QString &serviceName, const QPixmap &icon ); - - void setEmblem( const QString &serviceName, const QPixmap &emblem ); - - void setScalableEmblem( const QString &serviceName, const QString &emblemPath ); - - void setCurrentInfo( const QString &serviceName, const QString &info ); - - - private: - - /** - * Constructor - */ - ScriptableServiceManager(); - - /** - * Destructor - */ - ~ScriptableServiceManager(); - - static ScriptableServiceManager * s_instance; - - QMap m_serviceMap; - QString m_rootHtml; -}; - -#endif - diff --git a/amarok/src/services/scriptable/ScriptableServiceMeta.cpp b/amarok/src/services/scriptable/ScriptableServiceMeta.cpp deleted file mode 100644 index 8e967856..00000000 --- a/amarok/src/services/scriptable/ScriptableServiceMeta.cpp +++ /dev/null @@ -1,364 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007-2009 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "ScriptableServiceMeta.h" -#include "ScriptableServiceMeta_p.h" - -#include "core/meta/support/PrivateMetaRegistry.h" -#include "core-impl/meta/multi/MultiTrack.h" -#include "core-impl/playlists/types/file/PlaylistFileSupport.h" -#include "services/scriptable/ScriptableService.h" -#include "services/scriptable/ScriptableServiceManager.h" - -using namespace Meta; - -ScriptableServiceMetaItem::ScriptableServiceMetaItem( int level ) - : m_callbackString( QString() ) - , m_level( level ) - , m_serviceName( QString() ) - , m_serviceDescription( QString() ) - , m_serviceEmblem( QPixmap() ) -{} - -void Meta::ScriptableServiceMetaItem::setCallbackString( const QString &callbackString ) -{ - m_callbackString = callbackString; -} - -QString Meta::ScriptableServiceMetaItem::callbackString() const -{ - return m_callbackString; -} - -int Meta::ScriptableServiceMetaItem::level() const -{ - return m_level; -} - -void Meta::ScriptableServiceMetaItem::setServiceName( const QString & name ) -{ - m_serviceName = name; -} - -void Meta::ScriptableServiceMetaItem::setServiceDescription( const QString & description ) -{ - m_serviceDescription = description; -} - -void Meta::ScriptableServiceMetaItem::setServiceEmblem( const QPixmap & emblem ) -{ - m_serviceEmblem = emblem; -} - -void Meta::ScriptableServiceMetaItem::setServiceScalableEmblem ( const QString& emblemPath ) -{ - m_serviceScalableEmblem = emblemPath; -} - - -/* ScriptableServiceTrack */ -ScriptableServiceTrack::ScriptableServiceTrack( const QString & name ) - : ServiceTrack( name ) - , ScriptableServiceMetaItem( 0 ) -{} - -ScriptableServiceTrack::ScriptableServiceTrack( const QStringList & resultRow ) - : ServiceTrack( resultRow ) - , ScriptableServiceMetaItem( 0 ) -{} - - -void Meta::ScriptableServiceTrack::setAlbumName( const QString &newAlbum ) -{ - Meta::AlbumPtr albumPtr = Meta::PrivateMetaRegistry::instance()->album( m_serviceName, newAlbum ); - if ( !albumPtr ) { - ScriptableServiceInternalAlbum * intAlbum = new ScriptableServiceInternalAlbum( newAlbum ); - intAlbum->setServiceName( m_serviceName ); - intAlbum->setServiceDescription( m_serviceDescription ); - intAlbum->setServiceEmblem( m_serviceEmblem ); - intAlbum->setServiceScalableEmblem( m_serviceScalableEmblem ); - albumPtr = Meta::AlbumPtr( intAlbum ); - Meta::PrivateMetaRegistry::instance()->insertAlbum( m_serviceName, newAlbum, albumPtr ); - } - - setAlbumPtr( albumPtr ); -} - -void Meta::ScriptableServiceTrack::setArtistName( const QString &newArtist ) -{ - Meta::ArtistPtr artistPtr = Meta::PrivateMetaRegistry::instance()->artist( m_serviceName, newArtist ); - if ( !artistPtr ) { - ScriptableServiceInternalArtist * intArtist = new ScriptableServiceInternalArtist( newArtist ); - intArtist->setServiceName( m_serviceName ); - intArtist->setServiceDescription( m_serviceDescription ); - intArtist->setServiceEmblem( m_serviceEmblem ); - intArtist->setServiceScalableEmblem( m_serviceScalableEmblem ); - artistPtr = Meta::ArtistPtr( intArtist ); - Meta::PrivateMetaRegistry::instance()->insertArtist( m_serviceName, newArtist, artistPtr ); - } - - setArtist( artistPtr ); -} - -void Meta::ScriptableServiceTrack::setGenreName( const QString &newGenre ) -{ - Meta::GenrePtr genrePtr = Meta::PrivateMetaRegistry::instance()->genre( m_serviceName, newGenre ); - if ( !genrePtr ) { - ScriptableServiceInternalGenre * intGenre = new ScriptableServiceInternalGenre( newGenre ); - intGenre->setServiceName( m_serviceName ); - intGenre->setServiceDescription( m_serviceDescription ); - intGenre->setServiceEmblem( m_serviceEmblem ); - intGenre->setServiceScalableEmblem( m_serviceScalableEmblem ); - genrePtr = Meta::GenrePtr( intGenre ); - Meta::PrivateMetaRegistry::instance()->insertGenre( m_serviceName, newGenre, genrePtr ); - } - - setGenre( genrePtr ); -} - -void Meta::ScriptableServiceTrack::setComposerName( const QString &newComposer ) -{ - Meta::ComposerPtr composerPtr = Meta::PrivateMetaRegistry::instance()->composer( m_serviceName, newComposer ); - if ( !composerPtr ) { - ScriptableServiceInternalComposer * intComposer = new ScriptableServiceInternalComposer( newComposer); - intComposer->setServiceName( m_serviceName ); - intComposer->setServiceDescription( m_serviceDescription ); - intComposer->setServiceEmblem( m_serviceEmblem ); - intComposer->setServiceScalableEmblem( m_serviceScalableEmblem ); - composerPtr = Meta::ComposerPtr( intComposer ); - Meta::PrivateMetaRegistry::instance()->insertComposer( m_serviceName, newComposer, composerPtr ); - } - - setComposer( composerPtr ); -} - -void Meta::ScriptableServiceTrack::setYearNumber( int newYear ) -{ - const QString yearString = QString::number( newYear ); - - Meta::YearPtr yearPtr = Meta::PrivateMetaRegistry::instance()->year( m_serviceName, yearString ); - if ( !yearPtr ) { - ScriptableServiceInternalYear * intYear = new ScriptableServiceInternalYear( yearString ); - intYear->setServiceName( m_serviceName ); - intYear->setServiceDescription( m_serviceDescription ); - intYear->setServiceEmblem( m_serviceEmblem ); - intYear->setServiceScalableEmblem( m_serviceScalableEmblem ); - yearPtr = Meta::YearPtr( intYear ); - Meta::PrivateMetaRegistry::instance()->insertYear( m_serviceName, yearString, yearPtr ); - } - - setYear( yearPtr ); -} - -void Meta::ScriptableServiceTrack::setCustomAlbumCoverUrl( const QString & coverurl ) -{ - DEBUG_BLOCK - if ( album() ) { - debug() << "one"; - ServiceAlbumWithCoverPtr albumWithCover = ServiceAlbumWithCoverPtr::dynamicCast( album() ); - if ( albumWithCover ) { - debug() << "two"; - albumWithCover->setCoverUrl( coverurl ); - } - } -} - - -QString Meta::ScriptableServiceTrack::sourceName() -{ - return m_serviceName; -} - -QString Meta::ScriptableServiceTrack::sourceDescription() -{ - return m_serviceDescription; -} - -QPixmap Meta::ScriptableServiceTrack::emblem() -{ - return m_serviceEmblem; -} - -QString Meta::ScriptableServiceTrack::scalableEmblem() -{ - return m_serviceScalableEmblem; -} - -void ScriptableServiceTrack::setUidUrl( const QString &url ) -{ - Meta::ServiceTrack::setUidUrl( url ); - - using namespace Playlists; - Meta::TrackPtr track( this ); - PlaylistPtr playlist = canExpand( track ) ? expand( track ) : PlaylistPtr(); - if( playlist ) - // since this is a playlist masqueurading as a single track, make a MultiTrack out of it: - m_playableTrack = Meta::TrackPtr( new Meta::MultiTrack( playlist ) ); - else - m_playableTrack = TrackPtr(); -} - -TrackPtr ScriptableServiceTrack::playableTrack() const -{ - return m_playableTrack ? m_playableTrack : TrackPtr( const_cast( this ) ); -} - - -/* DynamicScriptableAlbum */ -ScriptableServiceAlbum::ScriptableServiceAlbum( const QString & name ) - : ServiceAlbumWithCover( name ) - , ScriptableServiceMetaItem( 1 ) -{} - -ScriptableServiceAlbum::ScriptableServiceAlbum( const QStringList & resultRow ) - : ServiceAlbumWithCover( resultRow ) - , ScriptableServiceMetaItem( 1 ) -{} - -QString Meta::ScriptableServiceAlbum::sourceName() -{ - return m_serviceName; -} - -QString Meta::ScriptableServiceAlbum::sourceDescription() -{ - return m_serviceDescription; -} - -QPixmap Meta::ScriptableServiceAlbum::emblem() -{ - return m_serviceEmblem; -} - -QString Meta::ScriptableServiceAlbum::scalableEmblem() -{ - return m_serviceScalableEmblem; -} - -bool Meta::ScriptableServiceAlbum::isBookmarkable() const -{ - ScriptableService * service = The::scriptableServiceManager()->service( m_serviceName ); - if ( service ) - return service->hasSearchBar(); - else - return false; -} - - - -/* ScriptableServiceArtist */ -ScriptableServiceArtist::ScriptableServiceArtist( const QString & name ) - : ServiceArtist( name ) - , ScriptableServiceMetaItem( 2 ) - , m_genreId( 0 ) -{} - -ScriptableServiceArtist::ScriptableServiceArtist( const QStringList & resultRow ) - : ServiceArtist( resultRow ) - , ScriptableServiceMetaItem( 2 ) - , m_genreId( 0 ) -{} - - -void Meta::ScriptableServiceArtist::setGenreId(int genreId) -{ - m_genreId = genreId; -} - - -int Meta::ScriptableServiceArtist::genreId() const -{ - return m_genreId; -} - -QString Meta::ScriptableServiceArtist::sourceName() -{ - return m_serviceName; -} - -QString Meta::ScriptableServiceArtist::sourceDescription() -{ - return m_serviceDescription; -} - -QPixmap Meta::ScriptableServiceArtist::emblem() -{ - return m_serviceEmblem; -} - -QString Meta::ScriptableServiceArtist::scalableEmblem() -{ - return m_serviceScalableEmblem; -} - -bool Meta::ScriptableServiceArtist::isBookmarkable() const -{ - ScriptableService * service = The::scriptableServiceManager()->service( m_serviceName ); - if ( service ) - return service->hasSearchBar(); - else - return false; -} - - -/* ScriptableServiceGenre */ -ScriptableServiceGenre::ScriptableServiceGenre( const QString & name ) - : ServiceGenre( name ) - , ScriptableServiceMetaItem( 3 ) -{} - -ScriptableServiceGenre::ScriptableServiceGenre( const QStringList & resultRow ) - : ServiceGenre( resultRow ) - , ScriptableServiceMetaItem( 3 ) -{} - - -void Meta::ScriptableServiceGenre::setDescription(const QString & description) -{ - m_description = description; -} - -QString Meta::ScriptableServiceGenre::description() -{ - return m_description; -} - -QString Meta::ScriptableServiceGenre::sourceName() -{ - return m_serviceName; -} - -QString Meta::ScriptableServiceGenre::sourceDescription() -{ - return m_serviceDescription; -} - -QPixmap Meta::ScriptableServiceGenre::emblem() -{ - return m_serviceEmblem; -} - -QString Meta::ScriptableServiceGenre::scalableEmblem() -{ - return m_serviceScalableEmblem; -} - - - - - - - diff --git a/amarok/src/services/scriptable/ScriptableServiceMeta.h b/amarok/src/services/scriptable/ScriptableServiceMeta.h deleted file mode 100644 index 2db3951b..00000000 --- a/amarok/src/services/scriptable/ScriptableServiceMeta.h +++ /dev/null @@ -1,165 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007-2009 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef DYNAMICSCRIPTABLESERVICEMETA_H -#define DYNAMICSCRIPTABLESERVICEMETA_H - -#include "../ServiceMetaBase.h" -#include "../ServiceAlbumCoverDownloader.h" - -/** - Meta types for use in the dynamic scriptable service. Nearly identical to - the ServiceMetaBse types, except for a field for storing data to - pass to the script to fetch child items for Genres, Artists and Albums - and a level specifier - - @author Nikolaj Hald Nielsen -*/ - - -namespace Meta -{ - -class ScriptableServiceMetaItem -{ - public: - ScriptableServiceMetaItem( int level ); - - void setCallbackString( const QString &callbackString ); - QString callbackString() const; - int level() const; - - void setServiceName( const QString &name ); - void setServiceDescription( const QString &description ); - void setServiceEmblem( const QPixmap &emblem ); - void setServiceScalableEmblem( const QString &emblemPath ); - - protected: - /* - * This is arbitrary string data to pass back to the script. This can be whatever - * information the script needs to fetch the children of this item... - */ - QString m_callbackString; - int m_level; - QString m_serviceName; - QString m_serviceDescription; - QPixmap m_serviceEmblem; - QString m_serviceScalableEmblem; - -}; - -class ScriptableServiceTrack : public Meta::ServiceTrack, public ScriptableServiceMetaItem -{ - public: - ScriptableServiceTrack( const QString &name ); - ScriptableServiceTrack( const QStringList &resultRow ); - - virtual QString sourceName(); - virtual QString sourceDescription(); - virtual QPixmap emblem(); - virtual QString scalableEmblem(); - - void setAlbumName( const QString &newAlbum ); - void setArtistName( const QString &newArtist ); - void setGenreName( const QString &newGenre ); - void setComposerName( const QString &newComposer ); - void setYearNumber( int newYear ); - - void setCustomAlbumCoverUrl( const QString &coverurl ); - - virtual QString collectionName() const { return m_serviceName; } - virtual void setUidUrl( const QString &url ); - - /** - * If this track is in fact a remote playlist, return Meta::MultiTrack that wraps - * it here, else return pointer to self. - */ - Meta::TrackPtr playableTrack() const; - - private: - Meta::TrackPtr m_playableTrack; -}; - -class ScriptableServiceAlbum : public Meta::ServiceAlbumWithCover, public ScriptableServiceMetaItem -{ - public: - ScriptableServiceAlbum( const QString &name ); - ScriptableServiceAlbum( const QStringList &resultRow ); - - virtual QString downloadPrefix() const { return "script"; } - virtual void setCoverUrl( const QString &coverUrl ) { m_coverUrl = coverUrl; } - virtual QString coverUrl() const { return m_coverUrl; } - - virtual KUrl imageLocation( int size = 1 ) { Q_UNUSED( size ); return KUrl( coverUrl() ); } - - virtual QString sourceName(); - virtual QString sourceDescription(); - virtual QPixmap emblem(); - virtual QString scalableEmblem(); - - virtual bool isBookmarkable() const; - virtual QString collectionName() const { return m_serviceName; } - virtual bool simpleFiltering() const { return true; } - - private: - QString m_coverUrl; - -}; - -class ScriptableServiceArtist : public Meta::ServiceArtist, public ScriptableServiceMetaItem -{ - public: - ScriptableServiceArtist( const QString &name ); - ScriptableServiceArtist( const QStringList &resultRow ); - - void setGenreId( int artistId ); - int genreId() const; - - virtual QString sourceName(); - virtual QString sourceDescription(); - virtual QPixmap emblem(); - virtual QString scalableEmblem(); - - virtual bool isBookmarkable() const; - virtual QString collectionName() const { return m_serviceName; } - virtual bool simpleFiltering() const { return true; } - - private: - int m_genreId; -}; - - -class ScriptableServiceGenre : public Meta::ServiceGenre, public ScriptableServiceMetaItem -{ - public: - ScriptableServiceGenre( const QString &name ); - ScriptableServiceGenre( const QStringList &resultRow ); - - void setDescription( const QString &description ); - QString description(); - - virtual QString sourceName(); - virtual QString sourceDescription(); - virtual QPixmap emblem(); - virtual QString scalableEmblem(); - - private: - QString m_description; -}; - -} - -#endif diff --git a/amarok/src/services/scriptable/ScriptableServiceMeta_p.h b/amarok/src/services/scriptable/ScriptableServiceMeta_p.h deleted file mode 100644 index e6c59905..00000000 --- a/amarok/src/services/scriptable/ScriptableServiceMeta_p.h +++ /dev/null @@ -1,320 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Maximilian Kossick * - * Copyright (c) 2008 Peter ZHOU * - * Copyright (c) 2008-2009 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_SCRIPTABLE_SERVICE_META_P_H -#define AMAROK_SCRIPTABLE_SERVICE_META_P_H - - -#include "core/support/Debug.h" -#include "core/meta/Meta.h" -#include "core/capabilities/SourceInfoCapability.h" - -#include -#include -#include -#include - -#include - - - -// internal helper classes - - -/** - * Base class for the private meta types. This is used to give these private items source info capability which is neede in some cases,for instance when bookmarking. - */ -class ScriptableServiceInternalMetaItem -{ - public: - - QString serviceName() { return m_serviceName; } - QString serviceDescription() { return m_serviceDescription; } - QPixmap serviceEmblem() { return m_serviceEmblem; } - QString serviceScalableEmblem() { return m_serviceScalableEmblem; } - - void setServiceName( const QString &name ) { m_serviceName = name; } - void setServiceDescription( const QString &description ) { m_serviceDescription = description; } - void setServiceEmblem( const QPixmap &emblem ) { m_serviceEmblem = emblem; } - void setServiceScalableEmblem( const QString &emblemPath ) { m_serviceScalableEmblem = emblemPath; } - - protected: - QString m_serviceName; - QString m_serviceDescription; - QPixmap m_serviceEmblem; - QString m_serviceScalableEmblem; -}; - - -class AMAROK_EXPORT ScriptableServiceInternalSourceInfoCapability : public Capabilities::SourceInfoCapability -{ - public: - ScriptableServiceInternalSourceInfoCapability( ScriptableServiceInternalMetaItem * sourceInfoProvider ) - { - m_sourceInfoProvider = sourceInfoProvider; - } - ~ScriptableServiceInternalSourceInfoCapability() {}; - - QString sourceName() { return m_sourceInfoProvider->serviceName(); } - QString sourceDescription() { return m_sourceInfoProvider->serviceDescription(); } - QPixmap emblem() { return m_sourceInfoProvider->serviceEmblem(); } - QString scalableEmblem() { return m_sourceInfoProvider->serviceScalableEmblem(); } - - - private: - ScriptableServiceInternalMetaItem * m_sourceInfoProvider; - -}; - - -class ScriptableServiceInternalArtist : public Meta::Artist, public ScriptableServiceInternalMetaItem -{ - public: - ScriptableServiceInternalArtist( const QString &name = QString() ) - : Meta::Artist() - , m_name( name ) - {} - - Meta::TrackList tracks() - { - return Meta::TrackList(); - } - - QString name() const - { - if( !m_name.isEmpty() ) - return m_name; - else - return i18nc( "The value is not known", "Unknown" ); - } - - QString prettyName() const - { - return name(); - } - - virtual bool hasCapabilityInterface( Capabilities::Capability::Type type ) const - { - return ( type == Capabilities::Capability::SourceInfo ); - } - - virtual Capabilities::Capability* createCapabilityInterface( Capabilities::Capability::Type type ) - { - if ( type == Capabilities::Capability::SourceInfo ) - return new ScriptableServiceInternalSourceInfoCapability( this ); - return 0; - } - -private: - QString m_name; - -}; - -class ScriptableServiceInternalAlbum : public Meta::ServiceAlbumWithCover, public ScriptableServiceInternalMetaItem -{ - public: - ScriptableServiceInternalAlbum( const QString &name = QString() ) - : Meta::ServiceAlbumWithCover( QString() ) - , m_name( name ) - {} - - bool isCompilation() const - { - return false; - } - - bool hasAlbumArtist() const - { - return false; - } - - Meta::ArtistPtr albumArtist() const - { - return Meta::ArtistPtr(); - } - - Meta::TrackList tracks() - { - return Meta::TrackList(); - } - - QString name() const - { - if( !m_name.isEmpty() ) - return m_name; - else - return i18nc( "The value is not known", "Unknown" ); - } - - QString prettyName() const - { - return name(); - } - - virtual QString downloadPrefix() const { return "script"; } - virtual void setCoverUrl( const QString &coverUrl ) { m_coverUrl = coverUrl; } - virtual QString coverUrl() const { return m_coverUrl; } - - virtual KUrl imageLocation( int size = 1 ) { Q_UNUSED( size ); return KUrl( coverUrl() ); } - - virtual bool hasCapabilityInterface( Capabilities::Capability::Type type ) const - { - return ( type == Capabilities::Capability::SourceInfo ); - } - - virtual Capabilities::Capability* createCapabilityInterface( Capabilities::Capability::Type type ) - { - if ( type == Capabilities::Capability::SourceInfo ) - return new ScriptableServiceInternalSourceInfoCapability( this ); - return 0; - } - - private: - QString m_name; - QString m_coverUrl; -}; - -class ScriptableServiceInternalGenre : public Meta::Genre, public ScriptableServiceInternalMetaItem -{ - public: - ScriptableServiceInternalGenre( const QString &name = QString() ) - : Meta::Genre() - , m_name( name ) - {} - - Meta::TrackList tracks() - { - return Meta::TrackList(); - } - - QString name() const - { - if( !m_name.isEmpty() ) - return m_name; - else - return i18nc( "The value is not known", "Unknown" ); - } - - QString prettyName() const - { - return name(); - } - - virtual bool hasCapabilityInterface( Capabilities::Capability::Type type ) const - { - return ( type == Capabilities::Capability::SourceInfo ); - } - - virtual Capabilities::Capability* createCapabilityInterface( Capabilities::Capability::Type type ) - { - if ( type == Capabilities::Capability::SourceInfo ) - return new ScriptableServiceInternalSourceInfoCapability( this ); - return 0; - } - - private: - QString m_name; -}; - -class ScriptableServiceInternalComposer : public Meta::Composer, public ScriptableServiceInternalMetaItem -{ - public: - ScriptableServiceInternalComposer( const QString &name = QString() ) - : Meta::Composer() - , m_name( name ) - {} - - Meta::TrackList tracks() - { - return Meta::TrackList(); - } - - QString name() const - { - - if( !m_name.isEmpty() ) - return m_name; - else - return i18nc( "The value is not known", "Unknown" ); - } - - QString prettyName() const - { - return name(); - } - - virtual bool hasCapabilityInterface( Capabilities::Capability::Type type ) const - { - return ( type == Capabilities::Capability::SourceInfo ); - } - - virtual Capabilities::Capability* createCapabilityInterface( Capabilities::Capability::Type type ) - { - if ( type == Capabilities::Capability::SourceInfo ) - return new ScriptableServiceInternalSourceInfoCapability( this ); - return 0; - } - - private: - QString m_name; -}; - -class ScriptableServiceInternalYear : public Meta::Year, public ScriptableServiceInternalMetaItem -{ - public: - ScriptableServiceInternalYear( const QString &name = QString() ) - : Meta::Year() - , m_name( name ) - {} - - Meta::TrackList tracks() - { - return Meta::TrackList(); - } - - QString name() const - { - if( !m_name.isEmpty() ) - return m_name; - else - return i18nc( "The value is not known", "Unknown" ); - } - - QString prettyName() const - { - return name(); - } - - virtual bool hasCapabilityInterface( Capabilities::Capability::Type type ) const - { - return ( type == Capabilities::Capability::SourceInfo ); - } - - virtual Capabilities::Capability* createCapabilityInterface( Capabilities::Capability::Type type ) - { - if ( type == Capabilities::Capability::SourceInfo ) - return new ScriptableServiceInternalSourceInfoCapability( this ); - return 0; - } - - private: - QString m_name; -}; - - -#endif diff --git a/amarok/src/services/scriptable/ScriptableServiceQueryMaker.cpp b/amarok/src/services/scriptable/ScriptableServiceQueryMaker.cpp deleted file mode 100644 index e2be8e81..00000000 --- a/amarok/src/services/scriptable/ScriptableServiceQueryMaker.cpp +++ /dev/null @@ -1,462 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "ScriptableServiceQueryMaker" - -#include "ScriptableServiceQueryMaker.h" - -#include "core/meta/support/MetaConstants.h" -#include "core/support/Debug.h" -#include "core-impl/collections/support/MemoryMatcher.h" -#include "scripting/scriptmanager/ScriptManager.h" -#include "services/scriptable/ScriptableServiceMeta.h" - -#include - -using namespace Collections; - -struct ScriptableServiceQueryMaker::Private { - //don't change the order of items in this enum - enum QueryType { TRACK=1, ALBUM=2, ARTIST=3, GENRE=4, NONE=5 }; - QueryType type; - QueryType closestParent; - int maxsize; - QString callbackString; - int parentId; - AlbumQueryMode albumMode; - QString filter; - QString lastFilter; -}; - -ScriptableServiceQueryMaker::ScriptableServiceQueryMaker( ScriptableServiceCollection * collection, QString name ) - : DynamicServiceQueryMaker() - , d( new Private ) - , m_convertToMultiTracks( false ) -{ - setParent( collection ); - m_collection = collection; - m_name = name; - - connect( collection, SIGNAL(updateComplete()), this, SLOT(slotScriptComplete()) ); - - d->type = Private::NONE; - d->closestParent = Private::NONE; - d->maxsize = -1; - d->parentId = -1; - d->albumMode = AllAlbums; -} - -ScriptableServiceQueryMaker::~ScriptableServiceQueryMaker() -{ - delete d; -} - - -void ScriptableServiceQueryMaker::run() -{ - if ( d->albumMode == OnlyCompilations ) - return; - - if ( d->type == Private::NONE ) - //TODO error handling - return; - - if ( d->callbackString.isEmpty() ) - d->callbackString = "none"; - - - if ( d->type == Private::GENRE ) { - if ( ( m_collection->levels() == 4 ) && ( m_collection->lastFilter() != d->filter ) ) - { - m_collection->clear(); - } - QTimer::singleShot( 0, this, SLOT(fetchGenre()) ); - } - else if ( d->type == Private::ARTIST ) - { - if ( ( m_collection->levels() == 3 ) && ( m_collection->lastFilter() != d->filter ) ) - { - m_collection->clear(); - } - QTimer::singleShot( 0, this, SLOT(fetchArtists()) ); - } - else if ( d->type == Private::ALBUM ) - { - if ( ( m_collection->levels() == 2 ) && ( m_collection->lastFilter() != d->filter ) ) - { - m_collection->clear(); - } - QTimer::singleShot( 0, this, SLOT(fetchAlbums()) ); - } - else if ( d->type == Private::TRACK ) - { - if ( ( m_collection->levels() == 1 ) && ( m_collection->lastFilter() != d->filter ) ) - { - m_collection->clear(); - } - QTimer::singleShot( 0, this, SLOT(fetchTracks()) ); - } - -} - -void ScriptableServiceQueryMaker::abortQuery() -{ -} - -QueryMaker * ScriptableServiceQueryMaker::setQueryType( QueryType type ) -{ - switch( type ) { - case QueryMaker::Artist: - case QueryMaker::AlbumArtist: - d->type = Private::ARTIST; - return this; - - case QueryMaker::Album: - d->type = Private::ALBUM; - return this; - - case QueryMaker::Track: - d->type = Private::TRACK; - return this; - - case QueryMaker::Genre: - d->type = Private::GENRE; - return this; - - case QueryMaker::Composer: - case QueryMaker::Year: - case QueryMaker::Custom: - case QueryMaker::Label: - case QueryMaker::None: - //TODO: Implement. - return this; - } - - return this; -} - -QueryMaker * ScriptableServiceQueryMaker::addMatch( const Meta::GenrePtr &genre ) -{ - if ( d->closestParent > Private::GENRE ) - { - d->closestParent = Private::GENRE; - const Meta::ScriptableServiceGenre * scriptableGenre = static_cast< const Meta::ScriptableServiceGenre * >( genre.data() ); - d->callbackString = scriptableGenre->callbackString(); - d->parentId = scriptableGenre->id(); - } - return this; -} - -QueryMaker * ScriptableServiceQueryMaker::addMatch( const Meta::ArtistPtr & artist, QueryMaker::ArtistMatchBehaviour behaviour ) -{ - Q_UNUSED( behaviour ); - const Meta::ScriptableServiceArtist *scriptableArtist = dynamic_cast( artist.data() ); - if ( scriptableArtist && d->closestParent > Private::ARTIST ) - { - d->closestParent = Private::ARTIST; - d->callbackString = scriptableArtist->callbackString(); - d->parentId = scriptableArtist->id(); - } - return this; -} - -QueryMaker * ScriptableServiceQueryMaker::addMatch( const Meta::AlbumPtr & album ) -{ - if ( d->closestParent > Private::ALBUM ) - { - d->closestParent = Private::ALBUM; - debug() << "Here!"; - const Meta::ScriptableServiceAlbum * scriptableAlbum = static_cast< const Meta::ScriptableServiceAlbum * >( album.data() ); - d->callbackString = scriptableAlbum->callbackString(); - d->parentId = scriptableAlbum->id(); - } - return this; -} - -void -ScriptableServiceQueryMaker::setConvertToMultiTracks( bool convert ) -{ - m_convertToMultiTracks = convert; -} - -void ScriptableServiceQueryMaker::handleResult( const Meta::GenreList & genres ) -{ - if ( d->maxsize >= 0 && genres.count() > d->maxsize ) - emit newResultReady( genres.mid( 0, d->maxsize ) ); - else - emit newResultReady( genres ); -} - -void ScriptableServiceQueryMaker::handleResult( const Meta::AlbumList & albums ) -{ - if ( d->maxsize >= 0 && albums.count() > d->maxsize ) - emit newResultReady( albums.mid( 0, d->maxsize ) ); - else - emit newResultReady( albums ); -} - -void ScriptableServiceQueryMaker::handleResult( const Meta::ArtistList & artists ) -{ - if ( d->maxsize >= 0 && artists.count() > d->maxsize ) - emit newResultReady( artists.mid( 0, d->maxsize ) ); - else - emit newResultReady( artists ); -} - -void ScriptableServiceQueryMaker::handleResult( const Meta::TrackList &tracks ) -{ - Meta::TrackList ret; - if( m_convertToMultiTracks ) - { - foreach( const Meta::TrackPtr &track, tracks ) - { - using namespace Meta; - const ScriptableServiceTrack *serviceTrack = - dynamic_cast( track.data() ); - if( !serviceTrack ) - { - error() << "failed to convert generic track" << track.data() << "to ScriptableServiceTrack"; - continue; - } - ret << serviceTrack->playableTrack(); - } - } - else - ret = tracks; - - if ( d->maxsize >= 0 && ret.count() > d->maxsize ) - emit newResultReady( ret.mid( 0, d->maxsize ) ); - else - emit newResultReady( ret ); -} - -void ScriptableServiceQueryMaker::fetchGenre() -{ - DEBUG_BLOCK - Meta::GenreList genre = m_collection->genreMap().values(); - - if ( genre.count() > 0 ) - { - handleResult( genre ); - emit( queryDone() ); - } - else - //this is where we call the script to get it to add more stuff! - ScriptManager::instance()->ServiceScriptPopulate( m_name, 3, d->parentId, d->callbackString, d->filter ); -} - -void ScriptableServiceQueryMaker::fetchArtists() -{ - DEBUG_BLOCK - Meta::ArtistList artists; - - if ( d->parentId != -1 ) - { - Meta::GenrePtr genrePtr = m_collection->genreById( d->parentId ); - Meta::ScriptableServiceGenre * scGenre = dynamic_cast ( genrePtr.data() ); - if ( scGenre ) - { - Meta::ArtistList allArtists = m_collection->artistMap().values(); - - foreach ( Meta::ArtistPtr artistPtr, allArtists ) - { - Meta::ScriptableServiceArtist *scArtist = dynamic_cast ( artistPtr.data() ); - if ( scArtist && scArtist->genreId() == d->parentId ) - artists.append( artistPtr ); - } - } - } - - if ( artists.count() > 0 ) - { - handleResult( artists ); - emit( queryDone() ); - } - else - //this is where we call the script to get it to add more stuff! - ScriptManager::instance()->ServiceScriptPopulate( m_name, 2, d->parentId, d->callbackString, d->filter ); -} - -void ScriptableServiceQueryMaker::fetchAlbums() -{ - DEBUG_BLOCK - debug() << "parent id: " << d->parentId; - - if ( d->albumMode == OnlyCompilations) - return; - - Meta::AlbumList albums; - - if ( d->parentId != -1 ) - { - albums = matchAlbums( m_collection, m_collection->artistById( d->parentId ) ); - } - else - albums = m_collection->albumMap().values(); - if ( albums.count() > 0 ) - { - handleResult( albums ); - emit( queryDone() ); - } - else - //this is where we call the script to get it to add more stuff! - ScriptManager::instance()->ServiceScriptPopulate( m_name, 1, d->parentId, d->callbackString, d->filter ); -} - -void ScriptableServiceQueryMaker::fetchTracks() -{ - DEBUG_BLOCK - - Meta::TrackList tracks; - - debug() << "parent id: " << d->parentId; - - Meta::AlbumPtr album; - if ( d->parentId != -1 && ( album = m_collection->albumById( d->parentId ) ) ) - { - AlbumMatcher albumMatcher( album ); - tracks = albumMatcher.match( m_collection->trackMap().values() ); - } - else - tracks = m_collection->trackMap().values(); - - if ( tracks.count() > 0 ) { - handleResult( tracks ); - emit( queryDone() ); - } - else - //this is where we call the script to get it to add more stuff! - { - debug() << "i am sending signals!"; - ScriptManager::instance()->ServiceScriptPopulate( m_name, 0, d->parentId, d->callbackString, d->filter ); - } -} - -void ScriptableServiceQueryMaker::slotScriptComplete() -{ - DEBUG_BLOCK - - if ( d->type == Private::GENRE ) - { - Meta::GenreList genre = m_collection->genreMap().values(); - handleResult( genre ); - } - else if ( d->type == Private::ARTIST ) - { - Meta::ArtistList artists; - if ( d->parentId != -1 ) - { - Meta::GenrePtr genrePtr = m_collection->genreById( d->parentId ); - Meta::ScriptableServiceGenre * scGenre = dynamic_cast ( genrePtr.data() ); - if ( scGenre ) - { - Meta::ArtistList allArtists = m_collection->artistMap().values(); - - foreach ( Meta::ArtistPtr artistPtr, allArtists ) - { - Meta::ScriptableServiceArtist *scArtist = dynamic_cast ( artistPtr.data() ); - - if ( scArtist && scArtist->genreId() == d->parentId ) - artists.append( artistPtr ); - } - } - } - else - artists = m_collection->artistMap().values(); - debug() << "there are " << artists.count() << " artists"; - handleResult( artists ); - } - else if ( d->type == Private::ALBUM ) - { - Meta::AlbumList albums; - if ( d->parentId != -1 ) - { - albums = matchAlbums( m_collection, m_collection->artistById( d->parentId ) ); - } - else - albums = m_collection->albumMap().values(); - - debug() << "there are " << albums.count() << " albums"; - handleResult( albums ); - } - else if ( d->type == Private::TRACK ) - { - Meta::TrackList tracks; - if ( d->parentId != -1 ) - { - Meta::AlbumPtr album = m_collection->albumById( d->parentId ); - if( album ) - { - AlbumMatcher albumMatcher( album ); - tracks = albumMatcher.match( m_collection->trackMap().values() ); - } - } - else - tracks = m_collection->trackMap().values(); - debug() << "there are " << tracks.count() << " tracks"; - handleResult( tracks ); - } - emit( queryDone() ); -} - -QueryMaker * ScriptableServiceQueryMaker::setAlbumQueryMode( AlbumQueryMode mode ) -{ - d->albumMode = mode; - return this; -} - -QueryMaker * ScriptableServiceQueryMaker::addFilter( qint64 value, const QString & filter, bool matchBegin, bool matchEnd ) -{ - Q_UNUSED( matchBegin ) - Q_UNUSED( matchEnd ) - - DEBUG_BLOCK - - if ( value == Meta::valTitle ) - { - //I am sure there is a really good reason to add this space, as nothing works if it is removed, but WHY?!? - d->filter += filter + ' '; - d->filter = d->filter.replace( ' ', "%20" ); - } - - int level = 0; - - if ( d->type == Private::GENRE ) - level = 4; - if ( d->type == Private::ARTIST ) - level = 3; - else if ( d->type == Private::ALBUM ) - level = 2; - else if ( d->type == Private::TRACK ) - level = 1; - - // should only clear all if we are querying for a top level item - if ( m_collection->levels() == level ) - { - //we need to clear everything as we have no idea what the scripts wants to do... - //TODO: with KSharedPointers in use, does this leak!? - - debug() << "clear all!!!!!!!!!!!!!!"; - m_collection->clear(); - } - - d->lastFilter = d->filter; - m_collection->setLastFilter( d->filter ); - return this; - -} - -#include "moc_ScriptableServiceQueryMaker.cpp" diff --git a/amarok/src/services/scriptable/ScriptableServiceQueryMaker.h b/amarok/src/services/scriptable/ScriptableServiceQueryMaker.h deleted file mode 100644 index a727fae9..00000000 --- a/amarok/src/services/scriptable/ScriptableServiceQueryMaker.h +++ /dev/null @@ -1,93 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef SCRIPTABLESERVICEQUERYMAKER_H -#define SCRIPTABLESERVICEQUERYMAKER_H - -#include "../DynamicServiceQueryMaker.h" - -#include "core/meta/forward_declarations.h" - -#include "ScriptableServiceCollection.h" - -namespace Collections { - -/** - * A query maker for fetching external data from scripred services. - */ -class ScriptableServiceQueryMaker : public DynamicServiceQueryMaker -{ - Q_OBJECT - -public: - ScriptableServiceQueryMaker( ScriptableServiceCollection * collection, QString name ); - ~ScriptableServiceQueryMaker(); - - virtual void run(); - virtual void abortQuery(); - - virtual QueryMaker* setQueryType( QueryType type ); - - virtual QueryMaker* addFilter( qint64 value, const QString &filter, bool matchBegin = false, bool matchEnd = false ); - - using QueryMaker::addMatch; - virtual QueryMaker* addMatch( const Meta::GenrePtr &genre ); - virtual QueryMaker* addMatch( const Meta::ArtistPtr &artist, ArtistMatchBehaviour behaviour = TrackArtists ); - virtual QueryMaker* addMatch( const Meta::AlbumPtr &album ); - - virtual QueryMaker* setAlbumQueryMode( AlbumQueryMode mode ); - - // ScriptableServiceQueryMaker-specific methods - - /** - * Set to true if ScriptableServiceQueryMaker should convert tracks which are in - * fact playlists to Meta::MultiTrack instances to be playable. Defaults to false. - */ - void setConvertToMultiTracks( bool convert ); - -protected slots: - void slotScriptComplete( ); - -private slots: - void fetchGenre(); - void fetchArtists(); - void fetchAlbums(); - void fetchTracks(); - -protected: - void handleResult( const Meta::GenreList &genres ); - void handleResult( const Meta::ArtistList &artists ); - void handleResult( const Meta::AlbumList &albums ); - void handleResult( const Meta::TrackList &tracks ); - - ScriptableServiceCollection * m_collection; - AmarokProcIO * m_script; - - struct Private; - Private * const d; - - QString m_sessionId; - int m_parentAlbumId; - int m_parentArtistId; - -private: - QString m_name; - bool m_convertToMultiTracks; -}; - -} //namespace Collections - -#endif diff --git a/amarok/src/services/scriptable/shoutcast_service.rb b/amarok/src/services/scriptable/shoutcast_service.rb deleted file mode 100644 index 94db2df1..00000000 --- a/amarok/src/services/scriptable/shoutcast_service.rb +++ /dev/null @@ -1,75 +0,0 @@ - -# Simple script for testing the scriptable service browser -# by creating a simple dynamic shoutcast directory browser. -# when called with no arguments it creates the service, and -# when called with a parent node id and a genre, it populates that -# parent node with all stations in that genre -# -# (c) 2007 Nikolaj Hald Nielsen -# -# License: GNU General Public License V2 - - -require 'net/http' -require 'uri' - - - - -def parse_genre(nodeId, genre) - - puts "genre: " + genre - stations_xml = Net::HTTP.get(URI.parse('http://www.shoutcast.com/sbin/newxml.phtml?genre=' + genre) ) - station_elements = stations_xml.split("\n") - station_elements.each do |station| - station =~ /(<\/genre>)/# - - system("qdbus", "org.kde.amarok", "/ScriptableServiceManager", "insertDynamicElement", $2, script_command, $2, "A collection of streams in the " + genre + " genre", 0.to_s, "Shoutcast Streams") - - end - - `qdbus org.kde.amarok /ScriptableServiceManager updateComplete "Shoutcast Streams"` - -end - -if ARGV.size == 0 then - setup_service() -else - parse_genre(ARGV[0], ARGV[1]) -end - - - - - - - - - - diff --git a/amarok/src/statemanagement/ApplicationController.cpp b/amarok/src/statemanagement/ApplicationController.cpp deleted file mode 100644 index e334aca1..00000000 --- a/amarok/src/statemanagement/ApplicationController.cpp +++ /dev/null @@ -1,19 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "ApplicationController.h" - -#include "moc_ApplicationController.cpp" diff --git a/amarok/src/statemanagement/ApplicationController.h b/amarok/src/statemanagement/ApplicationController.h deleted file mode 100644 index b22d8a5a..00000000 --- a/amarok/src/statemanagement/ApplicationController.h +++ /dev/null @@ -1,39 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_APPLICATIONCONTROLLER_H -#define AMAROK_APPLICATIONCONTROLLER_H - -#include - -namespace Amarok -{ - -class ApplicationController : public QObject -{ - Q_OBJECT -public: - ApplicationController( QObject *parent ) : QObject( parent ) {} - virtual ~ ApplicationController() {} - -public slots: - virtual void start() = 0; - virtual void shutdown() = 0; -}; - -} - -#endif diff --git a/amarok/src/statemanagement/DefaultApplicationController.cpp b/amarok/src/statemanagement/DefaultApplicationController.cpp deleted file mode 100644 index 58867892..00000000 --- a/amarok/src/statemanagement/DefaultApplicationController.cpp +++ /dev/null @@ -1,104 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "DefaultApplicationController.h" - -#include "core/support/Components.h" -#include "EngineController.h" - -#include "core-impl/collections/support/CollectionLocationDelegateImpl.h" -#include "core-impl/logger/ProxyLogger.h" - -#include - -using namespace Amarok; - -DefaultApplicationController::DefaultApplicationController( QObject *parent ) - : ApplicationController( parent ) -{ - //there can be only one applicationcontroller - ApplicationController *oldController = Components::setApplicationController( this ); - Q_ASSERT( !oldController ); -} - -DefaultApplicationController::~DefaultApplicationController() -{ - Components::setApplicationController( 0 ); -} - -void -DefaultApplicationController::start() -{ - //construct all central components - initCoreServiceProxies(); - initSqlStorage(); - initEngineController(); - initCollectionManager(); - initCollectionLocationDelegate(); - -} - -void -DefaultApplicationController::shutdown() -{ - //destroy all central components instead of letting them be - //destroyed in a random order as static objects - - delete Components::setEngineController( 0 ); - delete Components::setCollectionLocationDelegate( 0 ); - delete Components::setLogger( 0 ); -} - -void -DefaultApplicationController::initCoreServiceProxies() -{ - //we have core services that (e.g. StatusBar) that - //basically all other components could sensibly use - //unfortunately some of these components are GUI - //components and can only be constructed quite late - //therefore we provide proxies here that won't do anything, but forward - //to the real implementation as soon as possible - Components::setLogger( new ProxyLogger() ); -} - -void -DefaultApplicationController::initSqlStorage() -{ - //SqlStorage should really be moved out of SqlCollection and into a separate plugin that - //can be loaded independently of the collection -} - -void -DefaultApplicationController::initEngineController() -{ - EngineController *controller = new EngineController(); - Components::setEngineController( controller ); - bool invoked = QMetaObject::invokeMethod( controller, "initializePhonon", Qt::DirectConnection ); - Q_ASSERT( invoked ); -} - -void -DefaultApplicationController::initCollectionManager() -{ - -} - -void -DefaultApplicationController::initCollectionLocationDelegate() -{ - Components::setCollectionLocationDelegate( new Collections::CollectionLocationDelegateImpl() ); -} - diff --git a/amarok/src/statemanagement/DefaultApplicationController.h b/amarok/src/statemanagement/DefaultApplicationController.h deleted file mode 100644 index 35dcdc49..00000000 --- a/amarok/src/statemanagement/DefaultApplicationController.h +++ /dev/null @@ -1,44 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_DEFAULTAPPLICATIONCONTROLLER_H -#define AMAROK_DEFAULTAPPLICATIONCONTROLLER_H - -#include "statemanagement/ApplicationController.h" - -namespace Amarok -{ - class DefaultApplicationController : public ApplicationController - { - Q_OBJECT - public: - DefaultApplicationController( QObject *parent ); - virtual ~ DefaultApplicationController(); - - public slots: - virtual void start(); - virtual void shutdown(); - - private: - void initCoreServiceProxies(); - void initSqlStorage(); - void initEngineController(); - void initCollectionManager(); - void initCollectionLocationDelegate(); - }; -} - -#endif diff --git a/amarok/src/statsyncing/Config.cpp b/amarok/src/statsyncing/Config.cpp deleted file mode 100644 index bcefec92..00000000 --- a/amarok/src/statsyncing/Config.cpp +++ /dev/null @@ -1,338 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "Config.h" - -#include "MetaValues.h" -#include "core/meta/support/MetaConstants.h" -#include "core/support/Amarok.h" - -#include -#include -#include - -#include -#include -#include - -namespace StatSyncing -{ - struct ProviderData { - ProviderData( QString id_, QString name_, QIcon icon_, bool online_, bool enabled_ ) - : id( id_ ), name( name_ ), icon( icon_ ), online( online_ ), enabled( enabled_ ) - {} - - QString id; - QString name; - QIcon icon; - bool online; - bool enabled; - }; -} - -using namespace StatSyncing; - -Config::Config( QObject *parent ) - : QAbstractListModel( parent ) - , m_checkedFields( 0 ) - , m_hasChanged( false ) -{ - read(); -} - -Config::~Config() -{ -} - -int -Config::rowCount( const QModelIndex &parent ) const -{ - return parent.isValid() ? 0 : m_providerData.count(); -} - -QVariant -Config::data( const QModelIndex &index, int role ) const -{ - if( !index.isValid() ) - return QVariant(); - if( index.row() < 0 || index.row() >= m_providerData.count() ) - return QVariant(); - if( index.column() != 0 ) - return QVariant(); - - const ProviderData &provider = m_providerData.at( index.row() ); - switch( role ) - { - case Qt::DisplayRole: - return provider.name; - case Qt::DecorationRole: - { - if( !provider.icon.isNull() ) - return provider.icon; - return KIcon( provider.online ? "image-missing" : "network-disconnect" ); - } - case Qt::CheckStateRole: - return provider.enabled ? Qt::Checked : Qt::Unchecked; - case ProviderIdRole: - return provider.id; - case Qt::ForegroundRole: - { - // we need to do this trick, because not having ItemIsEnabled in flags() has - // unwanded side-effects - QBrush brush; - QPalette::ColorGroup group = provider.online ? QPalette::Active : QPalette::Disabled; - brush.setColor( QPalette().color( group, QPalette::Text ) ); - return brush; - } - case Qt::ToolTipRole: - return provider.online ? QString() : i18n( "This collection is currently offline" ); - } - return QVariant(); -} - -bool -Config::setData( const QModelIndex &index, const QVariant &value, int role ) -{ - if( !index.isValid() ) - return false; - if( index.row() < 0 || index.row() >= m_providerData.count() ) - return false; - if( index.column() != 0 ) - return false; - if( role != Qt::CheckStateRole ) - return false; - - Qt::CheckState state = Qt::CheckState( value.toInt() ); - m_providerData[ index.row() ].enabled = ( state == Qt::Checked ) ? true : false; - m_hasChanged = true; - emit dataChanged( index, index ); - return true; -} - -Qt::ItemFlags -Config::flags( const QModelIndex &index ) const -{ - if( !index.isValid() ) - return Qt::ItemFlags(); - if( index.row() < 0 || index.row() >= m_providerData.count() ) - return Qt::ItemFlags(); - if( index.column() != 0 ) - return Qt::ItemFlags(); - - Qt::ItemFlags flags = Qt::ItemIsUserCheckable | Qt::ItemIsEnabled; - if( !m_providerData.at( index.row() ).online ) - flags |= Qt::ItemIsSelectable; - return flags; -} - -void -Config::updateProvider( const QString &id, const QString &name, const QIcon &icon, - bool online, bool enabled ) -{ - ProviderData providerData( id, name, icon, online, enabled ); - for( int i = 0; i < m_providerData.count(); i++ ) - { - if( m_providerData.at( i ).id == id ) - { - m_providerData[ i ] = providerData; - m_hasChanged = true; - emit dataChanged( index( i ), index( i ) ); - return; - } - } - beginInsertRows( QModelIndex(), m_providerData.count(), m_providerData.count() ); - m_providerData << providerData; - m_hasChanged = true; - endInsertRows(); -} - -void -Config::updateProvider( const QString &id, const QString &name, const QIcon &icon, - bool online ) -{ - updateProvider( id, name, icon, online, providerEnabled( id, false ) ); -} - -bool -Config::forgetProvider( const QString &id ) -{ - QMutableListIterator it( m_providerData ); - int i = 0; - while( it.hasNext() ) - { - if( it.next().id == id ) - { - if( it.value().online ) - continue; // refuse to forget online provider - beginRemoveRows( QModelIndex(), i, i ); - it.remove(); - m_hasChanged = true; - endRemoveRows(); - emit providerForgotten( id ); - return true; - } - i++; - } - return false; -} - -bool -Config::providerKnown( const QString &id ) const -{ - foreach( const ProviderData &data, m_providerData ) - { - if( data.id == id ) - return true; - } - return false; -} - -bool -Config::providerEnabled( const QString &id, bool aDefault ) const -{ - foreach( const ProviderData &data, m_providerData ) - { - if( data.id == id ) - return data.enabled; - } - return aDefault; -} - -bool -Config::providerOnline( const QString &id, bool aDefault ) const -{ - foreach( const ProviderData &data, m_providerData ) - { - if( data.id == id ) - return data.online; - } - return aDefault; -} - -QIcon -Config::providerIcon( const QString &id ) const -{ - foreach( const ProviderData &data, m_providerData ) - { - if( data.id == id ) - return data.icon; - } - return QIcon(); -} - -qint64 -Config::checkedFields() const -{ - return m_checkedFields; -} - -void -Config::setCheckedFields( qint64 fields ) -{ - m_checkedFields = fields; - m_hasChanged = true; -} - -QSet -Config::excludedLabels() const -{ - return m_excludedLabels; -} - -void -Config::setExcludedLabels( const QSet &labels ) -{ - m_excludedLabels = labels; - m_hasChanged = true; -} - -bool -Config::hasChanged() const -{ - return m_hasChanged; -} - -void -Config::read() -{ - KConfigGroup group = Amarok::config( "StatSyncing" ); - - QStringList providerIds = group.readEntry( "providerIds", QStringList() ); - QStringList providerNames = group.readEntry( "providerNames", QStringList() ); - QList providerEnabledStatuses = group.readEntry( "providerEnabledStatuses", QList() ); - int count = qMin( providerIds.count(), providerNames.count() ); - count = qMin( count, providerEnabledStatuses.count() ); - - beginResetModel(); - QList newData; - for( int i = 0; i < count; i++ ) - { - QString id = providerIds.at( i ); - newData << ProviderData( id, providerNames.at( i ), providerIcon( id ), - providerOnline( id ), providerEnabledStatuses.at( i ) ); - } - m_providerData = newData; - endResetModel(); - - m_checkedFields = 0; - QStringList fieldNames = group.readEntry( "checkedFields", QStringList( "FIRST" ) ); - if( fieldNames == QStringList( "FIRST" ) ) - m_checkedFields = Meta::valRating | Meta::valFirstPlayed | Meta::valLastPlayed | - Meta::valPlaycount | Meta::valLabel; - else - { - foreach( const QString &fieldName, fieldNames ) - m_checkedFields |= Meta::fieldForName( fieldName ); - } - - m_excludedLabels = group.readEntry( "excludedLabels", QStringList() ).toSet(); - - m_hasChanged = false; -} - -void -Config::save() -{ - QStringList providerIds; - QStringList providerNames; - QList providerEnabledStatuses; - foreach( const ProviderData &data, m_providerData ) - { - providerIds << data.id; - providerNames << data.name; - providerEnabledStatuses << data.enabled; - } - - KConfigGroup group = Amarok::config( "StatSyncing" ); - group.writeEntry( "providerIds", providerIds ); - group.writeEntry( "providerNames", providerNames ); - group.writeEntry( "providerEnabledStatuses", providerEnabledStatuses ); - - // prefer string representation for fwd compatibility and user-readability - QStringList fieldNames; - for( qint64 i = 0; i < 64; i++ ) - { - qint64 field = 1LL << i; - if( field & m_checkedFields ) - fieldNames << Meta::nameForField( field ); - } - group.writeEntry( "checkedFields", fieldNames ); - - group.writeEntry( "excludedLabels", m_excludedLabels.toList() ); - - group.sync(); - m_hasChanged = false; -} diff --git a/amarok/src/statsyncing/Config.h b/amarok/src/statsyncing/Config.h deleted file mode 100644 index 9871e749..00000000 --- a/amarok/src/statsyncing/Config.h +++ /dev/null @@ -1,139 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef STATSYNCING_CONFIG_H -#define STATSYNCING_CONFIG_H - -#include -#include - -class QIcon; - -namespace StatSyncing -{ - struct ProviderData; - - /** - * Class holding configuration for statistics synchronization, mainly a list of known - * and enabled providers. - */ - class Config : public QAbstractListModel - { - Q_OBJECT - - public: - enum { - ProviderIdRole = Qt::UserRole - }; - virtual ~Config(); - - // QAbstractListModel methods: - virtual int rowCount( const QModelIndex &parent = QModelIndex() ) const; - virtual QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const; - virtual bool setData( const QModelIndex &index, const QVariant &value, int role = Qt::EditRole ); - virtual Qt::ItemFlags flags( const QModelIndex &index ) const; - - // own methods: - /** - * Register a new provider or tell Config that provider has become - * online/offline. - */ - void updateProvider( const QString &id, const QString &name, const QIcon &icon, - bool online, bool enabled ); - // convenience overload - void updateProvider( const QString &id, const QString &name, const QIcon &icon, - bool online ); - - /** - * @return true if successfully removed, false if it didn't exist in first - * place or vas rejected because it is online. - */ - bool forgetProvider( const QString &id ); - - /** - * @return true if provider with id @param id was already registered sometime - * in the past (and not forgotten). - */ - bool providerKnown( const QString &id ) const; - - /** - * @return true if provider with id @param id is enabled. Returns - * @param aDefault when such provider is not known. - */ - bool providerEnabled( const QString &id, bool aDefault = false ) const; - - /** - * @return true if provider with id @param id is online. Returns - * @param aDefault when such provider is not known. - */ - bool providerOnline( const QString &id, bool aDefault = false ) const; - - QIcon providerIcon( const QString &id ) const; - - /** - * Binary OR of Meta::val* fields that should be synchronized in automatic - * synchronization. - */ - qint64 checkedFields() const; - - /** - * Set binary OR of Meta::val* fields to synchronize. - */ - void setCheckedFields( qint64 fields ); - - /** - * Get a list of labels that are black-listed from synchronization (not - * touched at all). - */ - QSet excludedLabels() const; - - /** - * Set which labels to exclude from synchronization. - */ - void setExcludedLabels( const QSet &labels ); - - /** - * Return true if configuration has changed since last saving or reading data. - */ - bool hasChanged() const; - - /** - * Reads config from disk. Discards any possible unsaved changes. - */ - void read(); - - /** - * Saves the config back to disk. - */ - void save(); - - signals: - void providerForgotten( const QString &id ); - - private: - friend class Controller; - - // Only StatSyncing::Controller can construct config - Config( QObject *parent = 0 ); - - QList m_providerData; - qint64 m_checkedFields; - QSet m_excludedLabels; - bool m_hasChanged; - }; -} - -#endif // STATSYNCING_CONFIG_H diff --git a/amarok/src/statsyncing/Controller.cpp b/amarok/src/statsyncing/Controller.cpp deleted file mode 100644 index 06b90121..00000000 --- a/amarok/src/statsyncing/Controller.cpp +++ /dev/null @@ -1,447 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "Controller.h" - -#include "EngineController.h" -#include "MainWindow.h" -#include "ProviderFactory.h" -#include "amarokconfig.h" -#include "core/interfaces/Logger.h" -#include "core/meta/Meta.h" -#include "core/support/Amarok.h" -#include "core/support/Components.h" -#include "core/support/Debug.h" -#include "statsyncing/Config.h" -#include "statsyncing/Process.h" -#include "statsyncing/ScrobblingService.h" -#include "statsyncing/collection/CollectionProvider.h" -#include "statsyncing/ui/CreateProviderDialog.h" -#include "statsyncing/ui/ConfigureProviderDialog.h" - -#include "MetaValues.h" - -#include - -#include - -using namespace StatSyncing; - -const int Controller::s_syncingTriggerTimeout( 5000 ); - -Controller::Controller( QObject* parent ) - : QObject( parent ) - , m_startSyncingTimer( new QTimer( this ) ) - , m_config( new Config( this ) ) - , m_updateNowPlayingTimer( new QTimer( this ) ) -{ - qRegisterMetaType(); - - m_startSyncingTimer->setSingleShot( true ); - connect( m_startSyncingTimer, SIGNAL(timeout()), SLOT(startNonInteractiveSynchronization()) ); - CollectionManager *manager = CollectionManager::instance(); - Q_ASSERT( manager ); - connect( manager, SIGNAL(collectionAdded(Collections::Collection*,CollectionManager::CollectionStatus)), - SLOT(slotCollectionAdded(Collections::Collection*,CollectionManager::CollectionStatus)) ); - connect( manager, SIGNAL(collectionRemoved(QString)), SLOT(slotCollectionRemoved(QString)) ); - delayedStartSynchronization(); - - EngineController *engine = Amarok::Components::engineController(); - Q_ASSERT( engine ); - connect( engine, SIGNAL(trackFinishedPlaying(Meta::TrackPtr,double)), - SLOT(slotTrackFinishedPlaying(Meta::TrackPtr,double)) ); - - m_updateNowPlayingTimer->setSingleShot( true ); - m_updateNowPlayingTimer->setInterval( 10000 ); // wait 10s before updating - // We connect the signals to (re)starting the timer to postpone the submission a - // little to prevent frequent updates of rapidly - changing metadata - connect( engine, SIGNAL(trackChanged(Meta::TrackPtr)), - m_updateNowPlayingTimer, SLOT(start()) ); - // following is needed for streams that don't emit newTrackPlaying on song change - connect( engine, SIGNAL(trackMetadataChanged(Meta::TrackPtr)), - m_updateNowPlayingTimer, SLOT(start()) ); - connect( m_updateNowPlayingTimer, SIGNAL(timeout()), - SLOT(slotUpdateNowPlayingWithCurrentTrack()) ); - // we need to reset m_lastSubmittedNowPlayingTrack when a track is played twice - connect( engine, SIGNAL(trackPlaying(Meta::TrackPtr)), - SLOT(slotResetLastSubmittedNowPlayingTrack()) ); -} - -Controller::~Controller() -{ -} - -QList -Controller::availableFields() -{ - // when fields are changed, please update translations in MetadataConfig::MetadataConfig() - return QList() << Meta::valRating << Meta::valFirstPlayed - << Meta::valLastPlayed << Meta::valPlaycount << Meta::valLabel; -} - -void -Controller::registerProvider( const ProviderPtr &provider ) -{ - QString id = provider->id(); - bool enabled = false; - if( m_config->providerKnown( id ) ) - enabled = m_config->providerEnabled( id, false ); - else - { - switch( provider->defaultPreference() ) - { - case Provider::Never: - case Provider::NoByDefault: - enabled = false; - break; - case Provider::Ask: - { - QString text = i18nc( "%1 is collection name", "%1 has an ability to " - "synchronize track meta-data such as play count or rating " - "with other collections. Do you want to keep %1 synchronized?\n\n" - "You can always change the decision in Amarok configuration.", - provider->prettyName() ); - enabled = KMessageBox::questionYesNo( The::mainWindow(), text ) == KMessageBox::Yes; - break; - } - case Provider::YesByDefault: - enabled = true; - break; - } - } - - // don't tell config about Never-by-default providers - if( provider->defaultPreference() != Provider::Never ) - { - m_config->updateProvider( id, provider->prettyName(), provider->icon(), true, enabled ); - m_config->save(); - } - m_providers.append( provider ); - connect( provider.data(), SIGNAL(updated()), SLOT(slotProviderUpdated()) ); - if( enabled ) - delayedStartSynchronization(); -} - -void -Controller::unregisterProvider( const ProviderPtr &provider ) -{ - disconnect( provider.data(), 0, this, 0 ); - if( m_config->providerKnown( provider->id() ) ) - { - m_config->updateProvider( provider->id(), provider->prettyName(), - provider->icon(), /* online */ false ); - m_config->save(); - } - m_providers.removeAll( provider ); -} - -void -Controller::setFactories( const QList &factories ) -{ - foreach( Plugins::PluginFactory *pFactory, factories ) - { - ProviderFactory *factory = qobject_cast( pFactory ); - if( !factory ) - continue; - - if( m_providerFactories.contains( factory->type() ) ) // we have it already - continue; - - m_providerFactories.insert( factory->type(), factory ); - } -} - -bool -Controller::hasProviderFactories() const -{ - return !m_providerFactories.isEmpty(); -} - -bool -Controller::providerIsConfigurable( const QString &id ) const -{ - ProviderPtr provider = findRegisteredProvider( id ); - return provider ? provider->isConfigurable() : false; -} - -QWidget* -Controller::providerConfigDialog( const QString &id ) const -{ - ProviderPtr provider = findRegisteredProvider( id ); - if( !provider || !provider->isConfigurable() ) - return 0; - - ConfigureProviderDialog *dialog - = new ConfigureProviderDialog( id, provider->configWidget(), - The::mainWindow() ); - - connect( dialog, SIGNAL(providerConfigured(QString,QVariantMap)), - SLOT(reconfigureProvider(QString,QVariantMap)) ); - connect( dialog, SIGNAL(finished()), dialog, SLOT(deleteLater()) ); - - return dialog; -} - -QWidget* -Controller::providerCreationDialog() const -{ - CreateProviderDialog *dialog = new CreateProviderDialog( The::mainWindow() ); - foreach( ProviderFactory * const factory, m_providerFactories ) - dialog->addProviderType( factory->type(), factory->prettyName(), - factory->icon(), factory->createConfigWidget() ); - - connect( dialog, SIGNAL(providerConfigured(QString,QVariantMap)), - SLOT(createProvider(QString,QVariantMap)) ); - connect( dialog, SIGNAL(finished()), dialog, SLOT(deleteLater()) ); - - return dialog; -} - -void -Controller::createProvider( QString type, QVariantMap config ) -{ - Q_ASSERT( m_providerFactories.contains( type ) ); - m_providerFactories[type]->createProvider( config ); -} - -void -Controller::reconfigureProvider( QString id, QVariantMap config ) -{ - ProviderPtr provider = findRegisteredProvider( id ); - if( provider ) - provider->reconfigure( config ); -} - -void -Controller::registerScrobblingService( const ScrobblingServicePtr &service ) -{ - if( m_scrobblingServices.contains( service ) ) - { - warning() << __PRETTY_FUNCTION__ << "scrobbling service" << service << "already registered"; - return; - } - m_scrobblingServices << service; -} - -void -Controller::unregisterScrobblingService( const ScrobblingServicePtr &service ) -{ - m_scrobblingServices.removeAll( service ); -} - -QList -Controller::scrobblingServices() const -{ - return m_scrobblingServices; -} - -Config * -Controller::config() -{ - return m_config; -} - -void -Controller::synchronize() -{ - synchronize( Process::Interactive ); -} - -void -Controller::scrobble( const Meta::TrackPtr &track, double playedFraction, const QDateTime &time ) -{ - foreach( ScrobblingServicePtr service, m_scrobblingServices ) - { - ScrobblingService::ScrobbleError error = service->scrobble( track, playedFraction, time ); - if( error == ScrobblingService::NoError ) - emit trackScrobbled( service, track ); - else - emit scrobbleFailed( service, track, error ); - } -} - -void -Controller::slotProviderUpdated() -{ - QObject *updatedProvider = sender(); - Q_ASSERT( updatedProvider ); - foreach( const ProviderPtr &provider, m_providers ) - { - if( provider.data() == updatedProvider ) - { - m_config->updateProvider( provider->id(), provider->prettyName(), - provider->icon(), true ); - m_config->save(); - } - } -} - -void -Controller::delayedStartSynchronization() -{ - if( m_startSyncingTimer->isActive() ) - m_startSyncingTimer->start( s_syncingTriggerTimeout ); // reset the timeout - else - { - m_startSyncingTimer->start( s_syncingTriggerTimeout ); - // we could as well connect to all m_providers updated signals, but this serves - // for now - CollectionManager *manager = CollectionManager::instance(); - Q_ASSERT( manager ); - connect( manager, SIGNAL(collectionDataChanged(Collections::Collection*)), - SLOT(delayedStartSynchronization()) ); - } -} - -void -Controller::slotCollectionAdded( Collections::Collection *collection, - CollectionManager::CollectionStatus status ) -{ - if( status != CollectionManager::CollectionEnabled ) - return; - ProviderPtr provider( new CollectionProvider( collection ) ); - registerProvider( provider ); -} - -void -Controller::slotCollectionRemoved( const QString &id ) -{ - // here we depend on StatSyncing::CollectionProvider returning identical id - // as collection - ProviderPtr provider = findRegisteredProvider( id ); - if( provider ) - unregisterProvider( provider ); -} - -void -Controller::startNonInteractiveSynchronization() -{ - CollectionManager *manager = CollectionManager::instance(); - Q_ASSERT( manager ); - disconnect( manager, SIGNAL(collectionDataChanged(Collections::Collection*)), - this, SLOT(delayedStartSynchronization()) ); - synchronize( Process::NonInteractive ); -} - -void Controller::synchronize( int intMode ) -{ - Process::Mode mode = Process::Mode( intMode ); - if( m_currentProcess ) - { - if( mode == StatSyncing::Process::Interactive ) - m_currentProcess.data()->raise(); - return; - } - - // read saved config - qint64 fields = m_config->checkedFields(); - if( mode == Process::NonInteractive && fields == 0 ) - return; // nothing to do - ProviderPtrSet checkedProviders; - foreach( ProviderPtr provider, m_providers ) - { - if( m_config->providerEnabled( provider->id(), false ) ) - checkedProviders.insert( provider ); - } - - ProviderPtrList usedProviders; - switch( mode ) - { - case Process::Interactive: - usedProviders = m_providers; - break; - case Process::NonInteractive: - usedProviders = checkedProviders.toList(); - break; - } - if( usedProviders.isEmpty() ) - return; // nothing to do - if( usedProviders.count() == 1 && usedProviders.first()->id() == "localCollection" ) - { - if( mode == StatSyncing::Process::Interactive ) - { - QString text = i18n( "You only seem to have the Local Collection. Statistics " - "synchronization only makes sense if there is more than one collection." ); - Amarok::Components::logger()->longMessage( text ); - } - return; - } - - m_currentProcess = new Process( m_providers, checkedProviders, fields, mode, this ); - m_currentProcess.data()->start(); -} - -void -Controller::slotTrackFinishedPlaying( const Meta::TrackPtr &track, double playedFraction ) -{ - if( !AmarokConfig::submitPlayedSongs() ) - return; - Q_ASSERT( track ); - scrobble( track, playedFraction ); -} - -void -Controller::slotResetLastSubmittedNowPlayingTrack() -{ - m_lastSubmittedNowPlayingTrack = Meta::TrackPtr(); -} - -void -Controller::slotUpdateNowPlayingWithCurrentTrack() -{ - EngineController *engine = Amarok::Components::engineController(); - if( !engine ) - return; - - Meta::TrackPtr track = engine->currentTrack(); // null track is okay - if( tracksVirtuallyEqual( track, m_lastSubmittedNowPlayingTrack ) ) - { - debug() << __PRETTY_FUNCTION__ << "this track already recently submitted, ignoring"; - return; - } - foreach( ScrobblingServicePtr service, m_scrobblingServices ) - { - service->updateNowPlaying( track ); - } - - m_lastSubmittedNowPlayingTrack = track; -} - -ProviderPtr -Controller::findRegisteredProvider( const QString &id ) const -{ - foreach( const ProviderPtr &provider, m_providers ) - if( provider->id() == id ) - return provider; - - return ProviderPtr( 0 ); -} - -bool -Controller::tracksVirtuallyEqual( const Meta::TrackPtr &first, const Meta::TrackPtr &second ) -{ - if( !first && !second ) - return true; // both null - if( !first || !second ) - return false; // exactly one is null - const QString firstAlbum = first->album() ? first->album()->name() : QString(); - const QString secondAlbum = second->album() ? second->album()->name() : QString(); - const QString firstArtist = first->artist() ? first->artist()->name() : QString(); - const QString secondArtist = second->artist() ? second->artist()->name() : QString(); - return first->name() == second->name() && - firstAlbum == secondAlbum && - firstArtist == secondArtist; -} diff --git a/amarok/src/statsyncing/Controller.h b/amarok/src/statsyncing/Controller.h deleted file mode 100644 index b2c48222..00000000 --- a/amarok/src/statsyncing/Controller.h +++ /dev/null @@ -1,240 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef STATSYNCING_CONTROLLER_H -#define STATSYNCING_CONTROLLER_H - -#include "amarok_export.h" -// for CollectionManager::CollectionStatus that cannont be fwd-declared -#include "core-impl/collections/support/CollectionManager.h" - -#include -#include - -class QTimer; - -namespace StatSyncing -{ - class Config; - class CreateProviderDialog; - class Process; - class Provider; - typedef QExplicitlySharedDataPointer ProviderPtr; - typedef QList ProviderPtrList; - class ProviderFactory; - class ScrobblingService; - typedef QExplicitlySharedDataPointer ScrobblingServicePtr; - - /** - * A singleton class that controls statistics synchronization and related tasks. - */ - class AMAROK_EXPORT Controller : public QObject - { - Q_OBJECT - - public: - explicit Controller( QObject *parent = 0 ); - ~Controller(); - - /** - * Return a list of Meta::val* fields that statistics synchronization can - * actually synchronize. - */ - static QList availableFields(); - - /** - * Register a StatSyncing::Provider with StatSyncing controller. This makes - * it possible to synchronize provider with other providers. You don't need - * to call this for Collections that are registered through CollectionManager - * (and marked as enabled there) as it is done automatically. - */ - virtual void registerProvider( const ProviderPtr &provider ); - - /** - * Forget about StatSyncing::Provider @param provider. - */ - virtual void unregisterProvider( const ProviderPtr &provider ); - - /** - * Handle plugin factories derived from ProviderFactory, used for creating - * multiple provider instances. This method is called by Amarok's plugin - * infrastructure. - */ - void setFactories( const QList &factories ); - - /** - * Returns true if any instantiable provider types are registered with the - * controller. - */ - bool hasProviderFactories() const; - - /** - * Returns true if the provider identified by @param id is configurable - */ - bool providerIsConfigurable( const QString &id ) const; - - /** - * Returns a configuration dialog for a provider identified by @param id . - * @returns 0 if there's no provider identified by id or the provider is not - * configurable, otherwise a pointer to the dialog constructed as a child of - * The::mainWindow - */ - QWidget *providerConfigDialog( const QString &id ) const; - - /** - * Returns a provider creation dialog, prepopulated with registered provider - * types. - * @returns a pointer to the dialog constructed as a child of The::mainWindow, - * and is a subclass of KAssistantDialog. - * - * @see StatSyncing::CreateProviderDialog - */ - QWidget *providerCreationDialog() const; - - /** - * Register ScrobblingService with StatSyncing controller. Controller then - * listens to EngineController and calls scrobble() etc. when user plays - * tracks. Also allows scrobbling for tracks played on just connected iPods. - * - * @param service - */ - void registerScrobblingService( const ScrobblingServicePtr &service ); - - /** - * Forget about ScrobblingService @param service - */ - void unregisterScrobblingService( const ScrobblingServicePtr &service ); - - /** - * Return a list of currently registered scrobbling services (in arbitrary - * order). - */ - QList scrobblingServices() const; - - /** - * Return StatSyncing configuration object that describes enabled and - * disabled statsyncing providers. You may not cache the pointer. - */ - Config *config(); - - public slots: - /** - * Start the whole synchronization machinery. This call returns quickly, - * way before the synchronization is finished. - */ - void synchronize(); - - /** - * Scrobble a track using all registered scrobbling services. They may check - * certain criteria such as track length and refuse to scrobble the track. - * - * @param track track to scrobble - * @param playedFraction fraction which has been actually played, or a number - * greater than 1 if the track was played multiple times - * (for example on a media device) - * @param time time when it was played, invalid QDateTime signifies that the - * track has been played just now. This is the default when the - * parameter is omitted. - */ - void scrobble( const Meta::TrackPtr &track, double playedFraction = 1.0, - const QDateTime &time = QDateTime() ); - - signals: - /** - * Emitted when a track passed to scrobble() is successfully queued for - * scrobbling submission. This signal is emitted for every scrobbling service. - * For each service, you either get this or scrobbleFailed(). - */ - void trackScrobbled( const ScrobblingServicePtr &service, const Meta::TrackPtr &track ); - - /** - * Emitted when a scrobbling service @service was unable to scrobble() a track. - * - * @param error is a ScrobblingService::ScrobbleError enum value. - */ - void scrobbleFailed( const ScrobblingServicePtr &service, const Meta::TrackPtr &track, int error ); - - private slots: - /** - * Creates new instance of provider type identified by @param type - * with configuration stored in @param config. - */ - void createProvider( QString type, QVariantMap config ); - - /** - * Reconfigures provider identified by @param id with configuration - * stored in @param config. - */ - void reconfigureProvider( QString id, QVariantMap config ); - - /** - * Can only be connected to provider changed() signal - */ - void slotProviderUpdated(); - /** - * Wait a few seconds and if no collectionUpdate() signal arrives until then, - * start synchronization. Otherwise postpone the synchronization for a few - * seconds. - */ - void delayedStartSynchronization(); - void slotCollectionAdded( Collections::Collection* collection, - CollectionManager::CollectionStatus status ); - void slotCollectionRemoved( const QString &id ); - void startNonInteractiveSynchronization(); - void synchronize( int mode ); - - void slotTrackFinishedPlaying( const Meta::TrackPtr &track, double playedFraction ); - void slotResetLastSubmittedNowPlayingTrack(); - void slotUpdateNowPlayingWithCurrentTrack(); - - private: - Q_DISABLE_COPY( Controller ) - - ProviderPtr findRegisteredProvider( const QString &id ) const; - - /** - * Return true if important metadata of both tracks is equal. - */ - bool tracksVirtuallyEqual( const Meta::TrackPtr &first, const Meta::TrackPtr &second ); - QMap m_providerFactories; - - // synchronization-related - ProviderPtrList m_providers; - QWeakPointer m_currentProcess; - QTimer *m_startSyncingTimer; - Config *m_config; - - /** - * When a new collection appears, StatSyncing::Controller will automatically - * trigger synchronization. It however waits s_syncingTriggerTimeout - * milliseconds to let the collection settle down. Moreover, if the newly - * added collection emits updated(), the timeout will run from start again. - * - * (reason: e.g. iPod Collectin appears quickly, but with no tracks, which - * are added gradually as they are parsed. This "ensures" we only start - * syncing as soon as all tracks are parsed.) - */ - static const int s_syncingTriggerTimeout; - - // scrobbling-related - QList m_scrobblingServices; - QTimer *m_updateNowPlayingTimer; - Meta::TrackPtr m_lastSubmittedNowPlayingTrack; - }; - -} // namespace StatSyncing - -#endif // STATSYNCING_CONTROLLER_H diff --git a/amarok/src/statsyncing/Options.cpp b/amarok/src/statsyncing/Options.cpp deleted file mode 100644 index 32cb1cc6..00000000 --- a/amarok/src/statsyncing/Options.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "Options.h" - -using namespace StatSyncing; - -Options::Options() - : m_syncedFields( 0 ) -{ -} - -qint64 -Options::syncedFields() const -{ - return m_syncedFields; -} - -void -Options::setSyncedFields( qint64 fields ) -{ - m_syncedFields = fields; -} - -QSet -Options::excludedLabels() const -{ - return m_excludedLabels; -} - -void -Options::setExcludedLabels( const QSet &labels ) -{ - m_excludedLabels = labels; -} diff --git a/amarok/src/statsyncing/Options.h b/amarok/src/statsyncing/Options.h deleted file mode 100644 index 63a868af..00000000 --- a/amarok/src/statsyncing/Options.h +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef STATSYNCING_OPTIONS_H -#define STATSYNCING_OPTIONS_H - -#include -#include - -namespace StatSyncing -{ - /** - * A container for options controlling how synchronization of two tracks is - * performed. - */ - class Options - { - public: - explicit Options(); - - /** - * Binary OR of Meta::val* fields that should be synced. - */ - qint64 syncedFields() const; - void setSyncedFields( qint64 fields ); - - /** - * A list of labels statsyncing should not touch at all. - */ - QSet excludedLabels() const; - void setExcludedLabels( const QSet &labels ); - - private: - qint64 m_syncedFields; - QSet m_excludedLabels; - }; - -} // namespace StatSyncing - -#endif // STATSYNCING_OPTIONS_H diff --git a/amarok/src/statsyncing/Process.cpp b/amarok/src/statsyncing/Process.cpp deleted file mode 100644 index b6bd3911..00000000 --- a/amarok/src/statsyncing/Process.cpp +++ /dev/null @@ -1,301 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "Process.h" - -#include "MainWindow.h" -#include "MetaValues.h" -#include "core/interfaces/Logger.h" -#include "core/support/Amarok.h" -#include "core/support/Debug.h" -#include "core/support/Components.h" -#include "statsyncing/Config.h" -#include "statsyncing/Controller.h" -#include "statsyncing/jobs/MatchTracksJob.h" -#include "statsyncing/jobs/SynchronizeTracksJob.h" -#include "statsyncing/models/MatchedTracksModel.h" -#include "statsyncing/models/ProvidersModel.h" -#include "statsyncing/models/SingleTracksModel.h" -#include "statsyncing/ui/ChooseProvidersPage.h" -#include "statsyncing/ui/MatchedTracksPage.h" - -#include -#include -#include - -using namespace StatSyncing; - -Process::Process( const ProviderPtrList &providers, const ProviderPtrSet &preSelectedProviders, - qint64 checkedFields, Process::Mode mode, QObject *parent ) - : QObject( parent ) - , m_mode( mode ) - , m_providersModel( new ProvidersModel( providers, preSelectedProviders, this ) ) - , m_checkedFields( checkedFields ) - , m_matchedTracksModel( 0 ) - , m_dialog( new KDialog() ) -{ - m_dialog.data()->setCaption( i18n( "Synchronize Statistics" ) ); - m_dialog.data()->setButtons( KDialog::None ); - m_dialog.data()->setInitialSize( QSize( 860, 500 ) ); - m_dialog.data()->restoreDialogSize( Amarok::config( "StatSyncingDialog" ) ); - // delete this process when user hits the close button - connect( m_dialog.data(), SIGNAL(finished()), SLOT(slotSaveSizeAndDelete()) ); - - /* we need to delete all QWidgets on application exit well before QApplication - * is destroyed. We however don't set MainWindow as parent as this would make - * StatSyncing dialog share taskbar entry with Amarok main window */ - connect( The::mainWindow(), SIGNAL(destroyed(QObject*)), SLOT(slotDeleteDialog()) ); -} - -Process::~Process() -{ - delete m_dialog.data(); // we cannot deleteLater, dialog references m_matchedTracksModel -} - -void -Process::start() -{ - if( m_mode == Interactive ) - { - m_providersPage = new ChooseProvidersPage(); - m_providersPage.data()->setFields( Controller::availableFields(), m_checkedFields ); - m_providersPage.data()->setProvidersModel( m_providersModel, m_providersModel->selectionModel() ); - - connect( m_providersPage.data(), SIGNAL(accepted()), SLOT(slotMatchTracks()) ); - connect( m_providersPage.data(), SIGNAL(rejected()), SLOT(slotSaveSizeAndDelete()) ); - m_dialog.data()->mainWidget()->hide(); // otherwise it may last as a ghost image - m_dialog.data()->setMainWidget( m_providersPage.data() ); // takes ownership - raise(); - } - else if( m_checkedFields ) - slotMatchTracks(); -} - -void -Process::raise() -{ - if( m_providersPage || m_tracksPage ) - { - m_dialog.data()->show(); - m_dialog.data()->activateWindow(); - m_dialog.data()->raise(); - } - else - m_mode = Interactive; // schedule dialog should be shown when something happens -} - -void -Process::slotMatchTracks() -{ - MatchTracksJob *job = new MatchTracksJob( m_providersModel->selectedProviders() ); - QString text = i18n( "Matching Tracks for Statistics Synchronization" ); - if( m_providersPage ) - { - ChooseProvidersPage *page = m_providersPage.data(); // too lazy to type - m_checkedFields = page->checkedFields(); - - page->disableControls(); - page->setProgressBarText( text ); - connect( job, SIGNAL(totalSteps(int)), page, SLOT(setProgressBarMaximum(int)) ); - connect( job, SIGNAL(incrementProgress()), page, SLOT(progressBarIncrementProgress()) ); - connect( page, SIGNAL(rejected()), job, SLOT(abort()) ); - connect( m_dialog.data(), SIGNAL(finished()), job, SLOT(abort()) ); - } - else // background operation - { - Amarok::Components::logger()->newProgressOperation( job, text, 100, job, SLOT(abort()) ); - } - - connect( job, SIGNAL(done(ThreadWeaver::Job*)), SLOT(slotTracksMatched(ThreadWeaver::Job*)) ); - connect( job, SIGNAL(done(ThreadWeaver::Job*)), job, SLOT(deleteLater()) ); - ThreadWeaver::Weaver::instance()->enqueue( job ); -} - -void -Process::slotTracksMatched( ThreadWeaver::Job *job ) -{ - MatchTracksJob *matchJob = dynamic_cast( job ); - if( !matchJob ) - { - error() << __PRETTY_FUNCTION__ << "Failed cast, should never happen"; - deleteLater(); - return; - } - if( !matchJob->success() ) - { - warning() << __PRETTY_FUNCTION__ << "MatchTracksJob failed"; - deleteLater(); - return; - } - StatSyncing::Controller *controller = Amarok::Components::statSyncingController(); - if( !controller ) - { - warning() << __PRETTY_FUNCTION__ << "StatSyncing::Controller disappeared"; - deleteLater(); - return; - } - - // remove fields that are not writable: - qint64 usedFields = m_checkedFields & m_providersModel->writableTrackStatsDataUnion(); - m_options.setSyncedFields( usedFields ); - m_options.setExcludedLabels( controller->config()->excludedLabels() ); - QList columns = QList() << Meta::valTitle; - foreach( qint64 field, Controller::availableFields() ) - { - if( field & usedFields ) - columns << field; - } - - m_matchedTracksModel = new MatchedTracksModel( matchJob->matchedTuples(), columns, - m_options, this ); - QList services = controller->scrobblingServices(); - // only fill in m_tracksToScrobble if there are actual scrobbling services available - m_tracksToScrobble = services.isEmpty() ? TrackList() : matchJob->tracksToScrobble(); - - if( m_matchedTracksModel->hasConflict() || m_mode == Interactive ) - { - m_tracksPage = new MatchedTracksPage(); - MatchedTracksPage *page = m_tracksPage.data(); // convenience - page->setProviders( matchJob->providers() ); - page->setMatchedTracksModel( m_matchedTracksModel ); - foreach( ProviderPtr provider, matchJob->providers() ) - { - if( !matchJob->uniqueTracks().value( provider ).isEmpty() ) - page->addUniqueTracksModel( provider, new SingleTracksModel( - matchJob->uniqueTracks().value( provider ), columns, m_options, page ) ); - if( !matchJob->excludedTracks().value( provider ).isEmpty() ) - page->addExcludedTracksModel( provider, new SingleTracksModel( - matchJob->excludedTracks().value( provider ), columns, m_options, page ) ); - } - page->setTracksToScrobble( m_tracksToScrobble, services ); - - connect( page, SIGNAL(back()), SLOT(slotBack()) ); - connect( page, SIGNAL(accepted()), SLOT(slotSynchronize()) ); - connect( page, SIGNAL(rejected()), SLOT(slotSaveSizeAndDelete()) ); - m_dialog.data()->mainWidget()->hide(); // otherwise it may last as a ghost image - m_dialog.data()->setMainWidget( page ); // takes ownership - raise(); - } - else // NonInteractive mode without conflict - slotSynchronize(); -} - -void -Process::slotBack() -{ - m_mode = Interactive; // reset mode, we're interactive from this point - start(); -} - -void -Process::slotSynchronize() -{ - // disconnect, otherwise we prematurely delete Process and thus m_matchedTracksModel - disconnect( m_dialog.data(), SIGNAL(finished()), this, SLOT(slotSaveSizeAndDelete()) ); - m_dialog.data()->close(); - - SynchronizeTracksJob *job = new SynchronizeTracksJob( - m_matchedTracksModel->matchedTuples(), m_tracksToScrobble, m_options ); - QString text = i18n( "Synchronizing Track Statistics" ); - Amarok::Components::logger()->newProgressOperation( job, text, 100, job, SLOT(abort()) ); - connect( job, SIGNAL(done(ThreadWeaver::Job*)), SLOT(slotLogSynchronization(ThreadWeaver::Job*)) ); - connect( job, SIGNAL(done(ThreadWeaver::Job*)), job, SLOT(deleteLater()) ); - ThreadWeaver::Weaver::instance()->enqueue( job ); -} - -void -Process::slotLogSynchronization( ThreadWeaver::Job *job ) -{ - deleteLater(); // our work is done - SynchronizeTracksJob *syncJob = qobject_cast( job ); - if( !syncJob ) - { - warning() << __PRETTY_FUNCTION__ << "syncJob is null"; - return; - } - - int updatedTracksCount = syncJob->updatedTracksCount(); - QMap > scrobbles = - syncJob->scrobbles(); - - QStringList providerNames; - foreach( ProviderPtr provider, m_providersModel->selectedProviders() ) - providerNames << "" + provider->prettyName() + ""; - QString providers = providerNames.join( i18nc( "comma between list words", ", " ) ); - - QStringList text = QStringList() << i18ncp( "%2 is a list of collection names", - "Synchronization of %2 done. One track was updated.", - "Synchronization of %2 done. %1 tracks were updated.", - updatedTracksCount, providers ); - - QMap scrobbleErrorCounts; - foreach( const ScrobblingServicePtr &provider, scrobbles.keys() ) - { - QString name = "" + provider->prettyName() + ""; - QMap &providerScrobbles = scrobbles[ provider ]; - - QMapIterator it( providerScrobbles ); - while( it.hasNext() ) - { - it.next(); - if( it.key() == ScrobblingService::NoError ) - text << i18np( "One track was queued for scrobbling to %2.", - "%1 tracks were queued for scrobbling to %2.", it.value(), name ); - else - scrobbleErrorCounts[ it.key() ] += it.value(); - } - } - if( scrobbleErrorCounts.value( ScrobblingService::TooShort ) ) - text << i18np( "One track's played time was too short to be scrobbled.", - "%1 tracks' played time was too short to be scrobbled.", - scrobbleErrorCounts[ ScrobblingService::TooShort ] ); - if( scrobbleErrorCounts.value( ScrobblingService::BadMetadata ) ) - text << i18np( "One track had insufficient metadata to be scrobbled.", - "%1 tracks had insufficient metadata to be scrobbled.", - scrobbleErrorCounts[ ScrobblingService::BadMetadata ] ); - if( scrobbleErrorCounts.value( ScrobblingService::FromTheFuture ) ) - text << i18np( "One track was reported to have been played in the future.", - "%1 tracks were reported to have been played in the future.", - scrobbleErrorCounts[ ScrobblingService::FromTheFuture ] ); - if( scrobbleErrorCounts.value( ScrobblingService::FromTheDistantPast ) ) - text << i18np( "One track was last played in too distant past to be scrobbled.", - "%1 tracks were last played in too distant past to be scrobbled.", - scrobbleErrorCounts[ ScrobblingService::FromTheDistantPast ] ); - if( scrobbleErrorCounts.value( ScrobblingService::SkippedByUser ) ) - text << i18np( "Scrobbling of one track was skipped as configured by the user.", - "Scrobbling of %1 tracks was skipped as configured by the user.", - scrobbleErrorCounts[ ScrobblingService::SkippedByUser ] ); - - Amarok::Components::logger()->longMessage( text.join( "
    \n" ) ); -} - -void -Process::slotSaveSizeAndDelete() -{ - if( m_dialog ) - { - KConfigGroup group = Amarok::config( "StatSyncingDialog" ); - m_dialog.data()->saveDialogSize( group ); - } - deleteLater(); -} - -void -Process::slotDeleteDialog() -{ - // we cannot use deleteLater(), we don't have spare eventloop iteration - delete m_dialog.data(); -} diff --git a/amarok/src/statsyncing/Process.h b/amarok/src/statsyncing/Process.h deleted file mode 100644 index ea45cb63..00000000 --- a/amarok/src/statsyncing/Process.h +++ /dev/null @@ -1,105 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef STATSYNCING_PROCESS_H -#define STATSYNCING_PROCESS_H - -#include "statsyncing/Options.h" -#include "statsyncing/Provider.h" - -#include -#include - -class KDialog; -namespace ThreadWeaver { - class Job; -} - -namespace StatSyncing -{ - class ChooseProvidersPage; - class MatchedTracksModel; - class MatchedTracksPage; - class ProvidersModel; - - /** - * Class that is responsible for one synchronization process from track matching - * to committing synchronized values back to storage. This class should live in a main - * thread and is event-based. - * - * Process auto-deletes itself when it is done with its work. - */ - class Process : public QObject - { - Q_OBJECT - - public: - enum Mode { - Interactive, - NonInteractive, - }; - - /** - * Creates the synchronization process that will offer user to synchronize - * @param fields of @param providers. If @param mode is Interactive, - * introductory dialog will be shown that allows subset of fields and - * providers to be chosen. Otherwise performs the syncing ing the background - * and shows a window only if conflict occurs. - */ - Process( const ProviderPtrList &providers, const ProviderPtrSet &preSelectedProviders, - qint64 checkedFields, Mode mode, QObject *parent = 0 ); - virtual ~Process(); - - public slots: - /** - * Starts the process. - */ - void start(); - - /** - * Raises and activates possible UI window related to this synchronization - * process. - */ - void raise(); - - private slots: - void slotMatchTracks(); - void slotTracksMatched( ThreadWeaver::Job *job ); - void slotBack(); - void slotSynchronize(); - void slotLogSynchronization( ThreadWeaver::Job *job ); - void slotSaveSizeAndDelete(); - void slotDeleteDialog(); - - private: - Q_DISABLE_COPY( Process ) - - Mode m_mode; - Options m_options; - ProvidersModel *m_providersModel; - qint64 m_checkedFields; - MatchedTracksModel *m_matchedTracksModel; - TrackList m_tracksToScrobble; - - // gets deleted when MainWindow is deleted - QWeakPointer m_dialog; - QWeakPointer m_providersPage; - QWeakPointer m_tracksPage; - }; - -} // namespace StatSyncing - -#endif // STATSYNCING_PROCESS_H diff --git a/amarok/src/statsyncing/Provider.cpp b/amarok/src/statsyncing/Provider.cpp deleted file mode 100644 index ffb1458f..00000000 --- a/amarok/src/statsyncing/Provider.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "Provider.h" - -#include - -using namespace StatSyncing; - -ProviderConfigWidget::ProviderConfigWidget( QWidget *parent, Qt::WindowFlags f ) - : QWidget( parent, f ) -{ -} - -ProviderConfigWidget::~ProviderConfigWidget() -{ -} - -Provider::Provider() -{ - // ensure this object is created in a main thread - Q_ASSERT( thread() == QCoreApplication::instance()->thread() ); -} - -Provider::~Provider() -{ -} - -QString -Provider::description() const -{ - return QString(); -} - -bool -Provider::isConfigurable() const -{ - return false; -} - -ProviderConfigWidget* -Provider::configWidget() -{ - return 0; -} - -void -Provider::reconfigure( const QVariantMap &config ) -{ - Q_UNUSED( config ) -} - -void -Provider::commitTracks() -{ -} diff --git a/amarok/src/statsyncing/Provider.h b/amarok/src/statsyncing/Provider.h deleted file mode 100644 index 3e831485..00000000 --- a/amarok/src/statsyncing/Provider.h +++ /dev/null @@ -1,190 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef STATSYNCING_PROVIDER_H -#define STATSYNCING_PROVIDER_H - -#include "amarok_export.h" -#include "statsyncing/Track.h" -#include "support/QSharedDataPointerMisc.h" // operator<() for ProviderPtr - -#include - -#include -#include -#include -#include -#include - -namespace StatSyncing -{ - /** - * A widget class used for configuring providers. - */ - class AMAROK_EXPORT ProviderConfigWidget : public QWidget - { - Q_OBJECT - - public: - explicit ProviderConfigWidget( QWidget *parent, Qt::WindowFlags f = 0 ); - virtual ~ProviderConfigWidget(); - - /** - * Return a QVariantMap holding configuration for the provider. Types stored - * in QVariantMap must be supported by @see KConfigGroup . - */ - virtual QVariantMap config() const = 0; - }; - - /** - * A class that can provide tracks for statistics synchronization. It can be backed - * by local Amarok collections or by online services such as Last.fm. - * - * Instances of subclasses are guaranteed to be created in the main thread. - * Providers are memory-managed as explicitly shared data, always use ProviderPtr - * to stora a reference to Provider. - */ - class AMAROK_EXPORT Provider : public QObject, public QSharedData - { - Q_OBJECT - - public: - Provider(); - virtual ~Provider(); - - /** - * Unique identifier for this collection; may be used as a key to store - * configuration; must be thread-safe - */ - virtual QString id() const = 0; - - /** - * User-visible name of the provider; must be thread-safe - */ - virtual QString prettyName() const = 0; - - /** - * User-visible short localized description. Default implementation returns - * an empy string. - */ - virtual QString description() const; - - /** - * Icon of this provider; must be thread-safe - */ - virtual KIcon icon() const = 0; - - /** - * Return true if this provider can be reconfigured after creation. Returns - * false by default. - */ - virtual bool isConfigurable() const; - - /** - * Return a ProviderConfigWidget of configuration widget for this provider. - * Returns a null pointer by default. Please note that Provider does *not* - * retain ownership of this pointer, therefore should always return a new - * instance. - */ - virtual ProviderConfigWidget *configWidget(); - - /** - * Reconfigure the provider using configuration stored in @param config. - * Does nothing by default. - */ - virtual void reconfigure( const QVariantMap &config ); - - /** - * Return binary OR of Meta::val* fields that this provider knows about its - * tracks. Must include at least: Meta::valTitle, Meta::valArtist and - * Meta::valAlbum. Optional fields: Meta::valComposer, Meta::valYear - * Meta::valTrackNr and Meta::valDiscNr - */ - virtual qint64 reliableTrackMetaData() const = 0; - - /** - * Return binary OR of Meta::val* fields that this provider can write back - * to tracks. Choose a combination of: Meta::valRating, valFirstPlayed, - * valLastPlayed, valPlaycount, valLabel. - */ - virtual qint64 writableTrackStatsData() const = 0; - - enum Preference { - Never, /// never synchronize automatically - NoByDefault, /// don't synchronize automatically by default - Ask, /// ask on first appearance whether to synchronize by default - YesByDefault /// enable auto syncing on first appearance without asking - /// intended only for Local Collection - }; - - /** - * Return if this provider should participate in synchronization by - * default even when the user does not actively add it. User can always - * disable providers even if they are checked by default. - */ - virtual Preference defaultPreference() = 0; - - /** - * Return a set of track artist names that appear in this provider. Multiple - * artists differing just in letter case are allowed, or rather mandated, - * because @see artistTracks() method is case-sensitive. - * - * This method must be called in non-main thread and is allowed to block for - * a longer time; it must be implemented in a reentrant manner. - */ - virtual QSet artists() = 0; - - /** - * Return a list of track delegates from (track) artist @param artistName that - * appear in this provider; the matching should be performed CASE-SENSITIVELY - * and should match the whole string, not just substring. If you have multiple - * variants of the artist name differing just in letter case, you should - * return all of the variants in @see artists(). - * - * This method must be called in non-main thread and is allowed to block for - * a longer time; it must be implemented in a reentrant manner. - */ - virtual TrackList artistTracks( const QString &artistName ) = 0; - - /** - * Write back statistics to the underlying storage for all updated tracks - * managed by this provider that weren't yet saved. Default implementation - * does nothing. - * - * Guaranteed to be (and must be) called from non-main thread. Can block for - * a longer time. - */ - virtual void commitTracks(); - - signals: - /** - * Emitted when some data such as prettyName() were updated. - */ - void updated(); - }; - - typedef QExplicitlySharedDataPointer ProviderPtr; - typedef QList ProviderPtrList; - typedef QSet ProviderPtrSet; - - /** - * Container for a set of track frovider lists, one for each provider - */ - typedef QMap PerProviderTrackList; - -} // namespace StatSyncing - -#endif // STATSYNCING_PROVIDER_H diff --git a/amarok/src/statsyncing/ProviderFactory.cpp b/amarok/src/statsyncing/ProviderFactory.cpp deleted file mode 100644 index f405bf24..00000000 --- a/amarok/src/statsyncing/ProviderFactory.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2013 Konrad Zemek * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "ProviderFactory.h" - -#include "Provider.h" - -using namespace StatSyncing; - -ProviderFactory::ProviderFactory( QObject *parent, const QVariantList &args ) - : Plugins::PluginFactory( parent, args ) -{ -} - -ProviderFactory::~ProviderFactory() -{ -} - -QString -ProviderFactory::description() const -{ - return QString(); -} diff --git a/amarok/src/statsyncing/ProviderFactory.h b/amarok/src/statsyncing/ProviderFactory.h deleted file mode 100644 index 9ec55400..00000000 --- a/amarok/src/statsyncing/ProviderFactory.h +++ /dev/null @@ -1,85 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2013 Konrad Zemek * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef STATSYNCING_PROVIDER_FACTORY_H -#define STATSYNCING_PROVIDER_FACTORY_H - -#include "amarok_export.h" -#include "core/support/PluginFactory.h" - -#include - -#include -#include - -namespace StatSyncing -{ - class Provider; - typedef QExplicitlySharedDataPointer ProviderPtr; - class ProviderConfigWidget; - - /** - * A class allowing the creation of multiple providers of the same type. - */ - class AMAROK_EXPORT ProviderFactory : public Plugins::PluginFactory - { - Q_OBJECT - - public: - ProviderFactory( QObject *parent, const QVariantList &args ); - virtual ~ProviderFactory(); - - /** - * A string that is unique to this provider factory. It may be used as a key - * in associative structures. - */ - virtual QString type() const = 0; - - /** - * The name of the type of created provider. This name will be displayed - * in the provider creation dialog. - */ - virtual QString prettyName() const = 0; - - /** - * User-visible short localized description. This is the default description - * of created providers. Default implementation returns an empy string. - */ - virtual QString description() const; - - /** - * The icon representing the type of created provider. This icon will be - * displayed in the provider creation dialog, and is the default icon - * of created providers. - */ - virtual KIcon icon() const = 0; - - /** - * New instance of configuration widget for the provider. Please note that - * ProviderFactory does *not* retain ownership of this pointer, therefore - * should always return a new instance. - */ - virtual ProviderConfigWidget *createConfigWidget() = 0; - - /** - * Create a new provider instance using configuration stored in @param config - */ - virtual ProviderPtr createProvider( QVariantMap config ) = 0; - }; - -} // namespace StatSyncing - -#endif // STATSYNCING_PROVIDER_H diff --git a/amarok/src/statsyncing/ScrobblingService.cpp b/amarok/src/statsyncing/ScrobblingService.cpp deleted file mode 100644 index b6b18671..00000000 --- a/amarok/src/statsyncing/ScrobblingService.cpp +++ /dev/null @@ -1,23 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "ScrobblingService.h" - -using namespace StatSyncing; - -ScrobblingService::~ScrobblingService() -{ -} diff --git a/amarok/src/statsyncing/ScrobblingService.h b/amarok/src/statsyncing/ScrobblingService.h deleted file mode 100644 index b5f31387..00000000 --- a/amarok/src/statsyncing/ScrobblingService.h +++ /dev/null @@ -1,95 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef STATSYNCING_SCROBBLINGSERVICE_H -#define STATSYNCING_SCROBBLINGSERVICE_H - -#include "amarok_export.h" -#include "support/QSharedDataPointerMisc.h" // operator<() for ScrobblingServicePtr - -#include -#include - -template class KSharedPtr; -namespace Meta { - class Track; - typedef KSharedPtr TrackPtr; -} - -namespace StatSyncing -{ - /** - * Abstract base class for classes that provide track play scrobbling to Last.fm or - * some similar service. - * - * This class is memory-managed as explicitly shared data, use ScrobblingServicePtr - * every time you store reference to this class. - */ - // virtual inheritance to fight dreaded diamond problem in last.fm class - // http://www.parashift.com/c++-faq-lite/mi-diamond.html - class AMAROK_EXPORT ScrobblingService : public virtual QSharedData - { - public: - virtual ~ScrobblingService(); - - enum ScrobbleError { - NoError, - TooShort, // to short song or too short played time - BadMetadata, // invalid artist, album, title... - FromTheFuture, - FromTheDistantPast, - SkippedByUser //track contains label to be skipped by user in lastfm config - }; - - /** - * Return (possibly) localized user-displayable pretty name identifying - * this scrobbling service. - */ - virtual QString prettyName() const = 0; - - /** - * Scrobble a track. Scrobbling service may check certain criteria such as - * track length and refuse to scrobble the track. - * - * @param track track to scrobble; you may assume it is non-null - * @param playedFraction fraction which has been actually played, or a number - * greater than 1 if the track was played multiple times - * (for example on a media device) - * @param time time when it was played, invalid QDateTime signifies that the - * track has been played just now. This is the default when the - * parameter is omitted. - */ - virtual ScrobbleError scrobble( const Meta::TrackPtr &track, double playedFraction = 1.0, - const QDateTime &time = QDateTime() ) = 0; - - /** - * Update the "Now Playing" info on the scrobbling site without scrobbling the - * track permanently. Scrobbler may check certain criteria and refuse to update - * Now Playing if they are not met. If track is null, it means that no track is - * playing and scrobbler shoudl clear the Now Playing status. You may safely - * assume this is not called too frequently. - * - * @param track that is currently playing or null if playbak was stopped - */ - virtual void updateNowPlaying( const Meta::TrackPtr &track ) = 0; - }; - - typedef QExplicitlySharedDataPointer ScrobblingServicePtr; -} - -Q_DECLARE_METATYPE( StatSyncing::ScrobblingServicePtr ) - -#endif // STATSYNCING_SCROBBLINGSERVICE_H diff --git a/amarok/src/statsyncing/SimpleTrack.cpp b/amarok/src/statsyncing/SimpleTrack.cpp deleted file mode 100644 index 47ed2370..00000000 --- a/amarok/src/statsyncing/SimpleTrack.cpp +++ /dev/null @@ -1,112 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2013 Konrad Zemek * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "SimpleTrack.h" - -using namespace StatSyncing; - -SimpleTrack::SimpleTrack( const Meta::FieldHash &metadata, const QSet &labels ) - : m_labels( labels ) - , m_metadata( metadata ) -{ -} - -SimpleTrack::~SimpleTrack() -{ -} - -QString -SimpleTrack::name() const -{ - return m_metadata.value( Meta::valTitle ).toString(); -} - -QString -SimpleTrack::album() const -{ - return m_metadata.value( Meta::valAlbum ).toString(); -} - -QString -SimpleTrack::artist() const -{ - return m_metadata.value( Meta::valArtist ).toString(); -} - -QString -SimpleTrack::composer() const -{ - return m_metadata.value( Meta::valComposer ).toString(); -} - -int -SimpleTrack::year() const -{ - return m_metadata.value( Meta::valYear ).toInt(); -} - -int -SimpleTrack::trackNumber() const -{ - return m_metadata.value( Meta::valTrackNr ).toInt(); -} - -int -SimpleTrack::discNumber() const -{ - return m_metadata.value( Meta::valDiscNr ).toInt(); -} - -QDateTime -SimpleTrack::firstPlayed() const -{ - return getDateTime( m_metadata.value( Meta::valFirstPlayed ) ); -} - -QDateTime -SimpleTrack::lastPlayed() const -{ - return getDateTime( m_metadata.value( Meta::valLastPlayed ) ); -} - -int -SimpleTrack::rating() const -{ - return m_metadata.value( Meta::valRating ).toInt(); -} - -int -SimpleTrack::playCount() const -{ - return m_metadata.value( Meta::valPlaycount ).toInt(); -} - -QSet -SimpleTrack::labels() const -{ - return m_labels; -} - -QDateTime -SimpleTrack::getDateTime( const QVariant &v ) const -{ - if( v.toDateTime().isValid() ) - return v.toDateTime(); - else if( v.toUInt() != 0 ) - return QDateTime::fromTime_t( v.toUInt() ); - else - return QDateTime(); -} diff --git a/amarok/src/statsyncing/SimpleTrack.h b/amarok/src/statsyncing/SimpleTrack.h deleted file mode 100644 index 99297c9c..00000000 --- a/amarok/src/statsyncing/SimpleTrack.h +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2013 Konrad Zemek * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef STATSYNCING_SIMPLE_TRACK_H -#define STATSYNCING_SIMPLE_TRACK_H - -#include "Track.h" - -#include "MetaValues.h" - -namespace StatSyncing { - -/** - * A simple implementation of @see StatSyncing::Track which wraps data contained - * in Meta::FieldHash @param metadata container, and for every function returns value - * corresponding to an adequate Meta::val* key. Labels are passed through @param labels . - * - * This class is thread safe only for reading operations. If you need read-write access, - * @see StatSyncing::SimpleWritableTrack can be used. - */ -class AMAROK_EXPORT SimpleTrack : public Track -{ -public: - explicit SimpleTrack( const Meta::FieldHash &metadata, - const QSet &labels = QSet() ); - virtual ~SimpleTrack(); - - virtual QString name() const; - virtual QString album() const; - virtual QString artist() const; - virtual QString composer() const; - virtual int year() const; - virtual int trackNumber() const; - virtual int discNumber() const; - - virtual QDateTime firstPlayed() const; - virtual QDateTime lastPlayed() const; - virtual int playCount() const; - virtual int rating() const; - - virtual QSet labels() const; - -protected: - QDateTime getDateTime( const QVariant &v ) const; - - QSet m_labels; - Meta::FieldHash m_metadata; -}; - -} // namespace StatSyncing - -#endif // STATSYNCING_SIMPLE_TRACK_H diff --git a/amarok/src/statsyncing/SimpleWritableTrack.cpp b/amarok/src/statsyncing/SimpleWritableTrack.cpp deleted file mode 100644 index efe950e7..00000000 --- a/amarok/src/statsyncing/SimpleWritableTrack.cpp +++ /dev/null @@ -1,134 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2013 Konrad Zemek * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "SimpleWritableTrack.h" - - -#include - -using namespace StatSyncing; - -SimpleWritableTrack::SimpleWritableTrack( const Meta::FieldHash &metadata, - const QSet &labels ) - : SimpleTrack( metadata, labels ) -{ - // Move statistics to separate container, so we don't have to lock for other metadata - foreach( const qint64 metaValue, metadata.keys() ) - { - switch( metaValue ) - { - case Meta::valFirstPlayed: - case Meta::valLastPlayed: - case Meta::valRating: - case Meta::valPlaycount: - m_metadata.remove( metaValue ); - m_statistics.insert( metaValue, metadata[metaValue] ); - break; - - default: - break; - } - } -} - -SimpleWritableTrack::~SimpleWritableTrack() -{ -} - -QDateTime -SimpleWritableTrack::firstPlayed() const -{ - QReadLocker lock( &m_lock ); - return getDateTime( m_statistics.value( Meta::valFirstPlayed ) ); -} - -void -SimpleWritableTrack::setFirstPlayed( const QDateTime &firstPlayed ) -{ - QWriteLocker lock( &m_lock ); - m_statistics.insert( Meta::valFirstPlayed, firstPlayed.isValid() - ? firstPlayed.toTime_t() : 0u ); - m_changes |= Meta::valFirstPlayed; -} - -QDateTime -SimpleWritableTrack::lastPlayed() const -{ - QReadLocker lock( &m_lock ); - return getDateTime( m_statistics.value( Meta::valLastPlayed ) ); -} - -void -SimpleWritableTrack::setLastPlayed( const QDateTime &lastPlayed ) -{ - QWriteLocker lock( &m_lock ); - m_statistics.insert( Meta::valLastPlayed, lastPlayed.isValid() - ? lastPlayed.toTime_t() : 0u ); - m_changes |= Meta::valLastPlayed; -} - -int -SimpleWritableTrack::rating() const -{ - QReadLocker lock( &m_lock ); - return m_statistics.value( Meta::valRating ).toInt(); -} - -void -SimpleWritableTrack::setRating( int rating ) -{ - QWriteLocker lock( &m_lock ); - m_statistics.insert( Meta::valRating, rating ); - m_changes |= Meta::valRating; -} - -int -SimpleWritableTrack::playCount() const -{ - QReadLocker lock( &m_lock ); - return m_statistics.value( Meta::valPlaycount ).toInt(); -} - -void -SimpleWritableTrack::setPlayCount( int playCount ) -{ - QWriteLocker lock( &m_lock ); - m_statistics.insert( Meta::valPlaycount, playCount ); - m_changes |= Meta::valPlaycount; -} - -QSet -SimpleWritableTrack::labels() const -{ - QReadLocker lock( &m_lock ); - return m_labels; -} - -void -SimpleWritableTrack::setLabels( const QSet &labels ) -{ - QWriteLocker lock( &m_lock ); - m_labels = labels; - m_changes |= Meta::valLabel; -} - -void -SimpleWritableTrack::commit() -{ - QWriteLocker lock( &m_lock ); - doCommit( m_changes ); - m_changes = 0; -} diff --git a/amarok/src/statsyncing/SimpleWritableTrack.h b/amarok/src/statsyncing/SimpleWritableTrack.h deleted file mode 100644 index f5504f5f..00000000 --- a/amarok/src/statsyncing/SimpleWritableTrack.h +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2013 Konrad Zemek * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef STATSYNCING_SIMPLE_WRITABLE_TRACK_H -#define STATSYNCING_SIMPLE_WRITABLE_TRACK_H - -#include "SimpleTrack.h" - -#include - -namespace StatSyncing { - -/** - * A simple implementation of @see StatSyncing::Track which wraps data contained - * in Meta::FieldHash @param metadata container, and for every function returns value - * corresponding to an adequate Meta::val* key. Labels are passed through @param labels . - * - * This class is suitable for read-write operations. If you only need read capabilities, - * consider using @see StatSyncing::SimpleTrack . - */ -class AMAROK_EXPORT SimpleWritableTrack : public SimpleTrack -{ -public: - explicit SimpleWritableTrack( const Meta::FieldHash &metadata, - const QSet &labels = QSet() ); - virtual ~SimpleWritableTrack(); - - virtual QDateTime firstPlayed() const; - - /** - * Sets the First Played statistic. This method saves @param firstPlayed in the form - * of unix timestamp. - */ - virtual void setFirstPlayed( const QDateTime &firstPlayed ); - - virtual QDateTime lastPlayed() const; - - /** - * Sets the Last Played statistic. This method saves @param lastPlayed in the form - * of unix timestamp. - */ - virtual void setLastPlayed( const QDateTime &lastPlayed ); - - virtual int playCount() const; - virtual void setPlayCount( int playCount ); - - virtual int rating() const; - virtual void setRating( int rating ); - - virtual QSet labels() const; - virtual void setLabels( const QSet &labels ); - - void commit(); - -protected: - /** - * You must reimplement this method to save statistics to the database. - * @param changes holds a bitmask of fields changed since last doCommit() call. - * Note that the changes already are visible in the track through getter methods. - * Label changes will be indicated by Meta::valLabel field. - * - * Also note that m_changeLock will already be write-locked when this method - * is called. - */ - virtual void doCommit( const qint64 changes ) = 0; - - Meta::FieldHash m_statistics; - - /** - * You must read-lock lock before reading, and write-lock before - * writing, m_labels, m_metadata and m_statistics members. - */ - mutable QReadWriteLock m_lock; - - /** - * A bitmask containing changed fields. Only modify this in set* methods, and only - * using bitwise-OR. - */ - qint64 m_changes; -}; - -} // namespace StatSyncing - -#endif // STATSYNCING_SIMPLE_WRITABLE_TRACK_H diff --git a/amarok/src/statsyncing/Track.cpp b/amarok/src/statsyncing/Track.cpp deleted file mode 100644 index b9c0a2e3..00000000 --- a/amarok/src/statsyncing/Track.cpp +++ /dev/null @@ -1,142 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "Track.h" - -#include "MetaValues.h" -#include "core/meta/Meta.h" - -using namespace StatSyncing; - -Track::Track() - : QSharedData() -{ -} - -Track::~Track() -{ -} - -QString -Track::composer() const -{ - return QString(); -} - -int -Track::year() const -{ - return 0; -} - -int -Track::trackNumber() const -{ - return 0; -} - -int -Track::discNumber() const -{ - return 0; -} - -bool Track::equals( const Track &other, qint64 fieldMask ) const -{ - if( fieldMask & Meta::valTitle && name().toLower() != other.name().toLower() ) - return false; - if( fieldMask & Meta::valAlbum && album().toLower() != other.album().toLower() ) - return false; - if( fieldMask & Meta::valArtist && artist().toLower() != other.artist().toLower() ) - return false; - if( fieldMask & Meta::valComposer && composer().toLower() != other.composer().toLower() ) - return false; - if( fieldMask & Meta::valYear && year() != other.year() ) - return false; - if( fieldMask & Meta::valTrackNr && trackNumber() != other.trackNumber() ) - return false; - if( fieldMask & Meta::valDiscNr && discNumber() != other.discNumber() ) - return false; - return true; -} - -bool -Track::lessThan( const Track &other, qint64 fieldMask ) const -{ - // artist > year > album > discNumber > trackNumber > composer > title - if( fieldMask & Meta::valArtist && artist().toLower() != other.artist().toLower() ) - return artist().toLower() < other.artist().toLower(); - if( fieldMask & Meta::valYear && year() != other.year() ) - return year() < other.year(); - if( fieldMask & Meta::valAlbum && album().toLower() != other.album().toLower() ) - return album().toLower() < other.album().toLower(); - if( fieldMask & Meta::valDiscNr && discNumber() != other.discNumber() ) - return discNumber() < other.discNumber(); - if( fieldMask & Meta::valTrackNr && trackNumber() != other.trackNumber() ) - return trackNumber() < other.trackNumber(); - if( fieldMask & Meta::valComposer && composer().toLower() != other.composer().toLower() ) - return composer().toLower() < other.composer().toLower(); - if( fieldMask & Meta::valTitle && name().toLower() != other.name().toLower() ) - return name().toLower() < other.name().toLower(); - return false; -} - -void -Track::setRating( int rating ) -{ - Q_UNUSED( rating ) -} - -void -Track::setFirstPlayed( const QDateTime &firstPlayed ) -{ - Q_UNUSED( firstPlayed ) -} - -void -Track::setLastPlayed( const QDateTime &lastPlayed ) -{ - Q_UNUSED( lastPlayed ) -} - -int -Track::recentPlayCount() const -{ - return 0; -} - -void -Track::setPlayCount( int playCount ) -{ - Q_UNUSED( playCount ) -} - -void -Track::setLabels( const QSet &labels ) -{ - Q_UNUSED( labels ) -} - -Meta::TrackPtr -Track::metaTrack() const -{ - return Meta::TrackPtr(); -} - -void -Track::commit() -{ -} diff --git a/amarok/src/statsyncing/Track.h b/amarok/src/statsyncing/Track.h deleted file mode 100644 index 7591cd68..00000000 --- a/amarok/src/statsyncing/Track.h +++ /dev/null @@ -1,210 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef STATSYNCING_TRACK_H -#define STATSYNCING_TRACK_H - -#include "amarok_export.h" - -#include - -#include -#include -#include -#include - -namespace Meta { - class Track; - typedef KSharedPtr TrackPtr; -} - -namespace StatSyncing -{ - /** - * Abstract representation of a track (either from Amarok or from scrobbling services). - * - * This class is used to perform track matching and synchronization. It must be - * implemented in a thread-safe way. For optimal track matching, all string fields - * should be trimmed of whitespace. - * - * Note: This will be probably morphed into Meta::Track someday, keep the interface - * compatible as much as possible. - */ - class AMAROK_EXPORT Track : public QSharedData - { - public: - Track(); - virtual ~Track(); - - /** - * Get track title - */ - virtual QString name() const = 0; - - /** - * Get title of the album of this track - */ - virtual QString album() const = 0; - - /** - * Get track artist name - */ - virtual QString artist() const = 0; - - /** - * Get composer name; default implementation returns empty string that also - * serves as a value for 'unknown' - */ - virtual QString composer() const; - - /** - * Get track release year, default implementation returns value of 0 that also - * serves as a value for 'unknown' - */ - virtual int year() const; - - /** - * Get track number within its disc, default implementation returns value of 0 - * that also serves as a value for 'unknown' - */ - virtual int trackNumber() const; - - /** - * Get disc number, default implementation returns value of 0 that also serves - * as a value for 'unknown' - */ - virtual int discNumber() const; - - /** - * Return true if 2 tracks delegated by this and @param other are equal based - * on field mask @param fieldMask (binary OR of MetaValue.h values) - */ - bool equals( const Track &other, qint64 fieldMask ) const; - - /** - * Return true if this track delegate is considered smaller than @param other - * based on field mask @param fieldMask (binary OR of MetaValue.h values) - */ - bool lessThan( const Track &other, qint64 fieldMask ) const; - - /** - * Get user-assigned rating on scale from 0 to 10; 0 means the track is not - * rated - return this value if you don't know the rating - */ - virtual int rating() const = 0; - /** - * Set user-assigned rating on scale from 0 to 10. Default implementation - * does nothing. - * @param rating the user-assigned rating - */ - virtual void setRating( int rating ); - - /** - * Get date when the track was first played or invalid date if this is not - * known or the track was not yet played - */ - virtual QDateTime firstPlayed() const = 0; - /** - * Set date when the track was first played. Default implementation does - * nothing. - * @param firstPlayed the date the track was first played - */ - virtual void setFirstPlayed( const QDateTime &firstPlayed ); - - /** - * Get date when the track was last played or invalid date if this is not - * known or the track was not yet played - */ - virtual QDateTime lastPlayed() const = 0; - /** - * Set date when the track was last played. Default implementation does - * nothing. - * @param lastPlayed the date the track was last played - */ - virtual void setLastPlayed( const QDateTime &lastPlayed ); - - /** - * Get count of the track plays; return 0 in doubt - */ - virtual int playCount() const = 0; - /** - * Return play count on device since it has been last connected to a computer. - * This number is _already_ _included_ in playcount()! - */ - virtual int recentPlayCount() const; - /** - * Set count of the track plays. Setting playcount must reset recent - * playcount to 0. Default implementation does nothing. - * @param playCount the count of the track plays - */ - virtual void setPlayCount( int playCount ); - - /** - * Get user-assigned track labels or empty set if there are none - */ - virtual QSet labels() const = 0; - /** - * Set user-assigned track labels. Default implementation does nothing. - * @param labels the track labels - */ - virtual void setLabels( const QSet &labels ); - - /** - * If this StatSyncing::Track represents a Meta::Track, this method returns a - * pointer to it, otherwise it should return return a null pointer. - * - * This is used to enable drag in views and to enable scrobbling. - * - * Default implementation returns null pointer. - */ - virtual Meta::TrackPtr metaTrack() const; - - /** - * Write back statistics to the underlying storage. You must call this function - * after calling any of the set* methods *and* you must you must call - * Provider::commitTracks() at some later point. The implementation may decide - * whether the actual writeback happens in set*, in commit() or in - * Provider::commitTracks() . Default implementation does nothing. - * - * Guaranteed to be (and must be) called from non-main thread. Can block for - * a longer time. - */ - virtual void commit(); - - private: - Q_DISABLE_COPY(Track) - }; - - typedef KSharedPtr TrackPtr; - typedef QList TrackList; - - /** - * Comparison function that compares track delegate pointer by pointed value. - * Useful if you want to semantically sort TrackDelegateList using qSort() - * - * @template param ControllingClass: class name that implements static - * ::comparisonFields() method that returns binary OR of Meta::val* fields - * (as qint64) that should be used when comparing tracks. - */ - template - bool trackDelegatePtrLessThan( const TrackPtr &first, const TrackPtr &second ) - { - return first->lessThan( *second, ControllingClass::comparisonFields() ); - } - -} // namespace StatSyncing - -#endif // STATSYNCING_TRACK_H diff --git a/amarok/src/statsyncing/TrackTuple.cpp b/amarok/src/statsyncing/TrackTuple.cpp deleted file mode 100644 index 7b21a853..00000000 --- a/amarok/src/statsyncing/TrackTuple.cpp +++ /dev/null @@ -1,455 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "TrackTuple.h" - -#include "MetaValues.h" -#include "core/support/Debug.h" -#include "statsyncing/Options.h" -#include "statsyncing/Provider.h" - -Q_DECLARE_METATYPE(QSet) - -using namespace StatSyncing; - -const QList TrackTuple::s_fields = QList() << Meta::valRating - << Meta::valFirstPlayed << Meta::valLastPlayed << Meta::valPlaycount << Meta::valLabel; - -TrackTuple::TrackTuple() -{ -} - -void -TrackTuple::insert( ProviderPtr provider, const TrackPtr &track ) -{ - m_map.insert( provider, track ); -} - -ProviderPtrList -TrackTuple::providers() const -{ - return m_map.keys(); -} - -ProviderPtr -TrackTuple::provider( int i ) const -{ - return m_map.keys().value( i ); -} - -TrackPtr -TrackTuple::track( const ProviderPtr &provider ) const -{ - Q_ASSERT( m_map.contains( provider ) ); - return m_map.value( provider ); -} - -int -TrackTuple::count() const -{ - return m_map.count(); -} - -bool -TrackTuple::isEmpty() const -{ - return m_map.isEmpty(); -} - -bool -TrackTuple::fieldUpdated( qint64 field, const Options &options, ProviderPtr provider ) const -{ - if( isEmpty() || - !(options.syncedFields() & field) || - ( provider && !m_map.contains( provider ) ) || - ( provider && !(provider->writableTrackStatsData() & field) ) ) - { - return false; - } - - switch( field ) - { - case Meta::valRating: - { - int rating = syncedRating( options ); - if( rating < 0 ) - return false; // unresolved conflict, not going to write that - if( provider ) - return track( provider )->rating() != rating; - - foreach( const ProviderPtr &prov, m_map.keys() ) - { - if( !(prov->writableTrackStatsData() & field ) ) - continue; // this provider doesn't even know how to write this field - if( track( prov )->rating() != rating ) - return true; - } - return false; - } - - case Meta::valFirstPlayed: - { - QDateTime firstPlayed = syncedFirstPlayed( options ); - if( provider ) - return track( provider )->firstPlayed() != firstPlayed; - - foreach( const ProviderPtr &prov, m_map.keys() ) - { - if( !(prov->writableTrackStatsData() & field ) ) - continue; // this provider doesn't even know how to write this field - if( track( prov )->firstPlayed() != firstPlayed ) - return true; - } - return false; - } - - case Meta::valLastPlayed: - { - QDateTime lastPlayed = syncedLastPlayed( options ); - if( provider ) - return track( provider )->lastPlayed() != lastPlayed; - - foreach( const ProviderPtr &prov, m_map.keys() ) - { - if( !(prov->writableTrackStatsData() & field ) ) - continue; // this provider doesn't even know how to write this field - if( track( prov )->lastPlayed() != lastPlayed ) - return true; - } - return false; - } - - case Meta::valPlaycount: - { - int playcount = syncedPlaycount( options ); - if( provider ) - return track( provider )->playCount() != playcount; - - foreach( const ProviderPtr &prov, m_map.keys() ) - { - if( !(prov->writableTrackStatsData() & field ) ) - continue; // this provider doesn't even know how to write this field - if( track( prov )->playCount() != playcount ) - return true; - } - return false; - } - - case Meta::valLabel: - { - bool hasConflict = true; - QSet labels = syncedLabels( options, m_labelProviders, hasConflict ); - if( hasConflict ) - return false; // unresolved conflict, not going to write that - if( provider ) - return track( provider )->labels() - options.excludedLabels() != labels; - - foreach( const ProviderPtr &prov, m_map.keys() ) - { - if( !(prov->writableTrackStatsData() & field ) ) - continue; // this provider doesn't even know how to write this field - if( track( prov )->labels() - options.excludedLabels() != labels ) - return true; - } - return false; - } - } - return false; -} - -bool -TrackTuple::hasUpdate( const Options &options ) const -{ - foreach( qint64 field, s_fields ) - { - if( fieldUpdated( field, options ) ) - return true; - } - return false; -} - -bool -TrackTuple::fieldHasConflict( qint64 field, const Options& options, bool includeResolved ) const -{ - switch( field ) - { - case Meta::valRating: - // we must disregard currently selected rating provider for includeResolved = true - return syncedRating( options, includeResolved ? ProviderPtr() : m_ratingProvider ) < 0; - case Meta::valLabel: - { - bool hasConflict = false; - // we must disregard currently selected label providers for includeResolved = true - syncedLabels( options, includeResolved ? ProviderPtrSet() : m_labelProviders , hasConflict ); - return hasConflict; - } - } - return false; -} - -bool -TrackTuple::hasConflict( const Options &options ) const -{ - return fieldHasConflict( Meta::valRating, options ) - || fieldHasConflict( Meta::valLabel, options ); -} - -ProviderPtr -TrackTuple::ratingProvider() const -{ - return m_ratingProvider; -} - -void -TrackTuple::setRatingProvider( const ProviderPtr &provider ) -{ - if( !provider || m_map.contains( provider ) ) - m_ratingProvider = provider; -} - -ProviderPtrSet -TrackTuple::labelProviders() const -{ - return m_labelProviders; -} - -void -TrackTuple::setLabelProviders( const ProviderPtrSet &providers ) -{ - m_labelProviders.clear(); - foreach( const ProviderPtr &provider, providers ) - { - if( m_map.contains( provider ) ) - m_labelProviders.insert( provider ); - } -} - -int -TrackTuple::syncedRating( const Options &options ) const -{ - return syncedRating( options, m_ratingProvider ); -} - -int -TrackTuple::syncedRating( const Options &options, ProviderPtr ratingProvider ) const -{ - if( isEmpty() || !(options.syncedFields() & Meta::valRating) ) - return 0; - if( ratingProvider ) // a provider has been chosen - return track( ratingProvider )->rating(); - - // look for conflict: - int candidate = -1; // rating candidate - QMapIterator it( m_map ); - while( it.hasNext() ) - { - it.next(); - int rating = it.value()->rating(); - - // take rating candidate only from rated tracks or from rating-writable collections - bool canWriteRating = it.key()->writableTrackStatsData() & Meta::valRating; - if( candidate < 0 ) - { - if( rating > 0 || canWriteRating ) - candidate = rating; - continue; // nothing to do in this loop iteration in either case - } - - if( rating <= 0 && !canWriteRating ) - // skip unrated songs from colls with not-writable rating - continue; - - if( rating != candidate ) - return -1; - } - // if candidate == -1, it means there are no colls with writable or non-zero rating - return qMax( 0, candidate ); -} - -QDateTime -TrackTuple::syncedFirstPlayed( const Options &options ) const -{ - QDateTime first; - if( isEmpty() || !(options.syncedFields() & Meta::valFirstPlayed) ) - return first; - foreach( TrackPtr track, m_map ) - { - QDateTime trackFirstPlayed = track->firstPlayed(); - if( !trackFirstPlayed.isValid() ) - continue; - if( !first.isValid() || trackFirstPlayed < first ) - first = trackFirstPlayed; - } - return first; -} - -QDateTime -TrackTuple::syncedLastPlayed( const Options &options ) const -{ - QDateTime last; - if( isEmpty() || !(options.syncedFields() & Meta::valLastPlayed) ) - return last; - foreach( TrackPtr track, m_map ) - { - QDateTime trackLastPlayed = track->lastPlayed(); - if( !trackLastPlayed.isValid() ) - continue; - if( !last.isValid() || trackLastPlayed > last ) - last = trackLastPlayed; - } - return last; -} - -int -TrackTuple::syncedPlaycount( const Options &options ) const -{ - if( isEmpty() || !(options.syncedFields() & Meta::valPlaycount) ) - return 0; - int max = 0; - int sumRecent = 0; - foreach( TrackPtr track, m_map ) - { - int recent = track->recentPlayCount(); - sumRecent += recent; - max = qMax( max, track->playCount() - recent ); - } - return max + sumRecent; -} - -QSet -TrackTuple::syncedLabels( const Options &options ) const -{ - bool dummy = false; - return syncedLabels( options, m_labelProviders, dummy ); -} - -QSet -TrackTuple::syncedLabels( const Options &options, const ProviderPtrSet &labelProviders, bool &hasConflict ) const -{ - hasConflict = false; - QSet labelsCandidate; - if( isEmpty() || !(options.syncedFields() & Meta::valLabel) ) - return labelsCandidate; - if( !labelProviders.isEmpty() ) // providers have been chosen - { - foreach( const ProviderPtr &provider, labelProviders ) - labelsCandidate |= track( provider )->labels(); - return labelsCandidate - options.excludedLabels(); - } - - // look for conflict: - bool labelsCandidateAlreadySet = false; - QMapIterator it( m_map ); - while( it.hasNext() ) - { - it.next(); - QSet labels = it.value()->labels() - options.excludedLabels(); - - // take labels candidate only from labelled tracks or from label-writable collections - bool canWriteLabels = it.key()->writableTrackStatsData() & Meta::valLabel; - if( !labelsCandidateAlreadySet ) - { - if( !labels.isEmpty() || canWriteLabels ) - { - labelsCandidate = labels; - labelsCandidateAlreadySet = true; - } - continue; // nothing to do in this loop iteration in either case - } - - if( labels.isEmpty() && !canWriteLabels ) - // skip unlabelled songs from colls with not-writable labels - continue; - - if( labels != labelsCandidate ) - { - hasConflict = true; - return QSet(); - } - } - return labelsCandidate; -} - -ProviderPtrSet -TrackTuple::synchronize( const Options &options ) const -{ - ProviderPtrSet updatedProviders; - foreach( qint64 field, s_fields ) - { - // catches if field should not be at all updated (either no change or not in options ) - if( !fieldUpdated( field, options ) ) - continue; - - QVariant synced; - switch( field ) - { - case Meta::valRating: - synced = syncedRating( options ); break; - case Meta::valFirstPlayed: - synced = syncedFirstPlayed( options ); break; - case Meta::valLastPlayed: - synced = syncedLastPlayed( options ); break; - case Meta::valPlaycount: - synced = syncedPlaycount( options ); break; - case Meta::valLabel: - synced.setValue >( syncedLabels( options ) ); break; - default: - warning() << __PRETTY_FUNCTION__ << "unhandled first switch"; - } - - QMapIterator it( m_map ); - while( it.hasNext() ) - { - it.next(); - ProviderPtr provider = it.key(); - // we have special case for playcount because it needs to we written even if - // apparently unchanged to reset possible nonzero recentPlayCount - if( field != Meta::valPlaycount && !fieldUpdated( field, options, provider ) ) - continue; // nothing to do for this field and provider - - updatedProviders.insert( provider ); - TrackPtr track = it.value(); - switch( field ) - { - case Meta::valRating: - track->setRating( synced.toInt() ); break; - case Meta::valFirstPlayed: - track->setFirstPlayed( synced.toDateTime() ); break; - case Meta::valLastPlayed: - track->setLastPlayed( synced.toDateTime() ); break; - case Meta::valPlaycount: - track->setPlayCount( synced.toInt() ); break; - case Meta::valLabel: - { - QSet desiredLabels = synced.value >(); - /* add back blacklisted labels; we say we don't touch them, so we - * should neither add them (handled in syncedLabels()) nor remove them - * (handled here) - */ - desiredLabels |= track->labels() & options.excludedLabels(); - track->setLabels( desiredLabels ); - break; - } - default: - warning() << __PRETTY_FUNCTION__ << "unhandled second switch"; - } - } - } - - foreach( const ProviderPtr &provider, updatedProviders ) - track( provider )->commit(); - return updatedProviders; -} diff --git a/amarok/src/statsyncing/TrackTuple.h b/amarok/src/statsyncing/TrackTuple.h deleted file mode 100644 index 44d9d16b..00000000 --- a/amarok/src/statsyncing/TrackTuple.h +++ /dev/null @@ -1,157 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef STATSYNCING_TRACKTUPLE_H -#define STATSYNCING_TRACKTUPLE_H - -#include "statsyncing/Provider.h" -#include "statsyncing/Track.h" - -#include - -namespace StatSyncing -{ - class Options; - - /** - * Smallest element of synchronization, a container for provider-to-one-track map with - * methods to perform statistics synchronization and querying methods. - */ - class TrackTuple - { - public: - /** - * Constructs an empty tuple. - */ - TrackTuple(); - - /** - * Inserts a track into this tuple; if it already contains a track from @param - * provider, the old track si replaced with the new one. - * - * It does make sense to only add tracks that are in some sence equal to tracks - * alredy present in the tuple. - */ - void insert( ProviderPtr provider, const TrackPtr &track ); - - /** - * Returns a list of providers that have tracks in this tuple. - */ - ProviderPtrList providers() const; - - /** - * Returns provider of the i-th track in this tuple. If i is out of bounds, - * returns null. - */ - ProviderPtr provider( int i ) const; - - /** - * Returns track associated with @provider provider. Asserts that there's - * a track from @param provider - */ - TrackPtr track( const ProviderPtr &provider ) const; - - /** - * Returns a number of tracks in this tuple. - */ - int count() const; - - /** - * Returns true if there are no tracks in the tuple, false otherwise. - */ - bool isEmpty() const; - - /** - * Return true if Meta::val* field @param field is going to be updated. - * If @param provider is null, returns true if at least one child track - * is going to be updated; otherwise works on a track from @param provider. - */ - bool fieldUpdated( qint64 field, const Options &options, ProviderPtr provider = ProviderPtr() ) const; - - /** - * Return true if there's at least one field going to be updated. - */ - bool hasUpdate( const Options &options ) const; - - /** - * Returns true if there's a (perhaps resolved) conflict in field &field - */ - bool fieldHasConflict( qint64 field, const Options &options, bool includeResolved = true ) const; - - /** - * Return true if there's a (perhaps resolved) conflict in this tuple. - */ - bool hasConflict( const Options &options ) const; - - /** - * Returns a provider whose track's rating will be used in case of conflict. - * Will be null if rating provider hasn't been explicitly set. - */ - ProviderPtr ratingProvider() const; - - /** - * Sets the rating provider. Only accepts null provider or a provider of one - * track in this tuple. - */ - void setRatingProvider( const ProviderPtr &provider ); - - /** - * Returns providers whose labels will be OR-ed together in case of conflict. - * Will be empty if no provider hasn't been explicitly set. - */ - ProviderPtrSet labelProviders() const; - - /** - * Sets label providers. Only accepts empty set a or a set of providers that - * are contained in this tuple. - */ - void setLabelProviders( const ProviderPtrSet &providers ); - - /** - * Return synchronized rating. Specifically, returns -1 if there's unsolved - * rating conflict. - */ - int syncedRating( const Options &options ) const; - QDateTime syncedFirstPlayed( const Options &options ) const; - QDateTime syncedLastPlayed( const Options &options ) const; - int syncedPlaycount( const Options &options ) const; - QSet syncedLabels( const Options &options ) const; - - /** - * Perform actual synchronization. For each track, only sets fields that are - * in fieldUpdated( .., .., provider). Specifically this method does not write - * ratings or labels if there's unresolved rating/label conflict. Can only be - * called from non-main thread and may block for longer time. - * - * @return a set of providers that had their track updated - */ - ProviderPtrSet synchronize( const Options &options ) const; - - private: - int syncedRating( const Options &options, ProviderPtr ratingProvider ) const; - // @param hasConflict is set to true or false - QSet syncedLabels( const Options &options, const ProviderPtrSet &labelProviders, - bool &hasConflict ) const; - - static const QList s_fields; /// list of Meta::val* fields capable of syncing - QMap m_map; - ProviderPtr m_ratingProvider; /// source of rating in the event of conflict - ProviderPtrSet m_labelProviders; /// sources of labels in the event of conflict - }; - -} // namespace StatSyncing - -#endif // STATSYNCING_TRACKTUPLE_H diff --git a/amarok/src/statsyncing/collection/CollectionProvider.cpp b/amarok/src/statsyncing/collection/CollectionProvider.cpp deleted file mode 100644 index a26cec63..00000000 --- a/amarok/src/statsyncing/collection/CollectionProvider.cpp +++ /dev/null @@ -1,187 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "CollectionProvider.h" - -#include "MetaValues.h" -#include "amarokconfig.h" -#include "core/collections/Collection.h" -#include "core/collections/QueryMaker.h" -#include "core/meta/Meta.h" -#include "statsyncing/collection/CollectionTrack.h" - -using namespace StatSyncing; - -CollectionProvider::CollectionProvider( Collections::Collection *collection ) - : m_coll( collection ) -{ - Q_ASSERT( m_coll ); - connect( collection, SIGNAL(updated()), SIGNAL(updated()) ); - connect( this, SIGNAL(startArtistSearch()), SLOT(slotStartArtistSearch()) ); - connect( this, SIGNAL(startTrackSearch(QString)), SLOT(slotStartTrackSearch(QString)) ); -} - -CollectionProvider::~CollectionProvider() -{ -} - -QString -CollectionProvider::id() const -{ - return m_coll ? m_coll.data()->collectionId() : QString(); -} - -QString -CollectionProvider::prettyName() const -{ - return m_coll ? m_coll.data()->prettyName() : QString(); -} - -KIcon -CollectionProvider::icon() const -{ - return m_coll ? m_coll.data()->icon() : KIcon(); -} - -qint64 -CollectionProvider::reliableTrackMetaData() const -{ - if( id().startsWith("amarok-nepomuk:") ) - return Meta::valTitle | Meta::valArtist | Meta::valAlbum | Meta::valComposer | - Meta::valTrackNr; - else - return Meta::valTitle | Meta::valArtist | Meta::valAlbum | - Meta::valComposer | Meta::valYear | Meta::valTrackNr | Meta::valDiscNr; -} - -qint64 -CollectionProvider::writableTrackStatsData() const -{ - // TODO: this is unreliable and hacky, but serves for now: - if( id() == "localCollection" ) - return Meta::valRating | Meta::valFirstPlayed | Meta::valLastPlayed | Meta::valPlaycount | Meta::valLabel; - else - return Meta::valRating | Meta::valFirstPlayed | Meta::valLastPlayed | Meta::valPlaycount; -} - -Provider::Preference -CollectionProvider::defaultPreference() -{ - // currently only Local Collection and iPod one have good syncing capabilities - if( id() == "localCollection" ) - return YesByDefault; - if( id().startsWith( "amarok-ipodtrackuid" ) ) - return Ask; - return NoByDefault; -} - -QSet -CollectionProvider::artists() -{ - if( !m_coll ) - return QSet(); - - m_foundArtists.clear(); - emit startArtistSearch(); - m_queryMakerSemaphore.acquire(); // blocks until slotQueryDone() releases the semaphore - QSet ret = m_foundArtists; - m_foundArtists.clear(); // don't waste memory - - return ret; -} - -TrackList -CollectionProvider::artistTracks( const QString &artistName ) -{ - if( !m_coll ) - return TrackList(); - - m_foundTracks.clear(); - emit startTrackSearch( artistName ); - m_queryMakerSemaphore.acquire(); // blocks until slotQueryDone() releases the semaphore - TrackList ret = m_foundTracks; - m_foundTracks.clear(); // don't waste memory - m_currentArtistName.clear(); - - return ret; -} - -void -CollectionProvider::slotStartArtistSearch() -{ - if( !m_coll ) - { - m_queryMakerSemaphore.release(); // prevent deadlock - return; - } - - Collections::QueryMaker *qm = m_coll.data()->queryMaker(); - qm->setAutoDelete( true ); - qm->setQueryType( Collections::QueryMaker::Artist ); - connect( qm, SIGNAL(newResultReady(Meta::ArtistList)), - SLOT(slotNewResultReady(Meta::ArtistList)) ); - connect( qm, SIGNAL(queryDone()), SLOT(slotQueryDone()) ); - qm->run(); -} - -void -CollectionProvider::slotStartTrackSearch( QString artistName ) -{ - if( !m_coll ) - { - m_queryMakerSemaphore.release(); // prevent deadlock - return; - } - - Collections::QueryMaker *qm = m_coll.data()->queryMaker(); - qm->setAutoDelete( true ); - qm->setQueryType( Collections::QueryMaker::Track ); - m_currentArtistName = artistName; - qm->addFilter( Meta::valArtist, m_currentArtistName, true, true ); - connect( qm, SIGNAL(newResultReady(Meta::TrackList)), - SLOT(slotNewResultReady(Meta::TrackList)) ); - connect( qm, SIGNAL(queryDone()), SLOT(slotQueryDone()) ); - qm->run(); -} - -void -CollectionProvider::slotNewResultReady( Meta::ArtistList list ) -{ - foreach( const Meta::ArtistPtr &artist, list ) - { - m_foundArtists.insert( artist->name() ); - } -} - -void -CollectionProvider::slotNewResultReady( Meta::TrackList list ) -{ - foreach( Meta::TrackPtr track, list ) - { - Meta::ArtistPtr artistPtr = track->artist(); - QString artist = artistPtr ? artistPtr->name() : QString(); - // QueryMaker interface is case-insensitive and cannot be configured otherwise. - // StatSyncing::Provicer interface is case-sensitive, so we must filter here - if( artist == m_currentArtistName ) - m_foundTracks.append( TrackPtr( new CollectionTrack( track ) ) ); - } -} - -void -CollectionProvider::slotQueryDone() -{ - m_queryMakerSemaphore.release(); // unblock method in a worker thread -} diff --git a/amarok/src/statsyncing/collection/CollectionProvider.h b/amarok/src/statsyncing/collection/CollectionProvider.h deleted file mode 100644 index d785b435..00000000 --- a/amarok/src/statsyncing/collection/CollectionProvider.h +++ /dev/null @@ -1,88 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef STATSYNCING_COLLECTIONPROVIDER_H -#define STATSYNCING_COLLECTIONPROVIDER_H - -#include "core/meta/forward_declarations.h" -#include "statsyncing/Provider.h" - -#include - -namespace Collections { - class Collection; -} - -namespace StatSyncing -{ - /** - * Provider that has Collections::Colections as a back-end. - */ - class CollectionProvider : public Provider - { - Q_OBJECT - - public: - /** - * Construct provider that has @param collection as a back-end. - */ - CollectionProvider( Collections::Collection *collection ); - virtual ~CollectionProvider(); - - virtual QString id() const; - virtual QString prettyName() const; - virtual KIcon icon() const; - virtual qint64 reliableTrackMetaData() const; - virtual qint64 writableTrackStatsData() const; - virtual Preference defaultPreference(); - virtual QSet artists(); - virtual TrackList artistTracks( const QString &artistName ); - - signals: - /// hacks to create and start QueryMaker in main eventloop - void startArtistSearch(); - void startTrackSearch( QString artistName ); - - private slots: - /// @see startArtistSearch - void slotStartArtistSearch(); - void slotStartTrackSearch( QString artistName ); - - void slotNewResultReady( Meta::ArtistList list ); - void slotNewResultReady( Meta::TrackList list ); - void slotQueryDone(); - - private: - Q_DISABLE_COPY(CollectionProvider) - - /// collection can disappear at any time, use weak pointer to notice it - QWeakPointer m_coll; - QSet m_foundArtists; - QString m_currentArtistName; - TrackList m_foundTracks; - /** - * Semaphore for the simplified producer-consumer pattern, where - * slotNewResultReady( ArtistList ) along with slotQueryDone() is producer - * and artists() is consumer, or - * slotNewResultReady( TrackList ) along with slotQueryDone() is producer - * and artistTracks() is consumer. - */ - QSemaphore m_queryMakerSemaphore; - }; - -} // namespace StatSyncing - -#endif // STATSYNCING_COLLECTIONPROVIDER_H diff --git a/amarok/src/statsyncing/collection/CollectionTrack.cpp b/amarok/src/statsyncing/collection/CollectionTrack.cpp deleted file mode 100644 index 299c40c6..00000000 --- a/amarok/src/statsyncing/collection/CollectionTrack.cpp +++ /dev/null @@ -1,201 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "CollectionTrack.h" - -#include "core/meta/Meta.h" -#include "core/meta/Statistics.h" -#include "core/support/Debug.h" - -using namespace StatSyncing; - -CollectionTrack::CollectionTrack( Meta::TrackPtr track ) - : m_track( track ) - , m_trackStats( track->statistics() ) - , m_beginUpdateAlreadyCalled( false ) -{ - Q_ASSERT( m_track ); - Q_ASSERT( m_trackStats ); -} - -CollectionTrack::~CollectionTrack() -{ -} - -QString -CollectionTrack::name() const -{ - return m_track->name(); -} - -QString -CollectionTrack::album() const -{ - Meta::AlbumPtr album = m_track->album(); - return album ? album->name() : QString(); -} - -QString -CollectionTrack::artist() const -{ - Meta::ArtistPtr artist = m_track->artist(); - return artist ? artist->name() : QString(); -} - -QString -CollectionTrack::composer() const -{ - Meta::ComposerPtr composer = m_track->composer(); - return composer ? composer->name() : QString(); -} - -int -CollectionTrack::year() const -{ - Meta::YearPtr year = m_track->year(); - return year ? year->year() : 0; -} - -int -CollectionTrack::trackNumber() const -{ - return m_track->trackNumber(); -} - -int -CollectionTrack::discNumber() const -{ - return m_track->discNumber(); -} - -int -CollectionTrack::rating() const -{ - return qBound( 0, m_trackStats->rating(), 10 ); -} - -void -CollectionTrack::setRating( int rating ) -{ - beginUpdate(); - m_trackStats->setRating( rating ); -} - -QDateTime -CollectionTrack::firstPlayed() const -{ - return m_trackStats->firstPlayed(); -} - -void -CollectionTrack::setFirstPlayed( const QDateTime &firstPlayed ) -{ - beginUpdate(); - m_trackStats->setFirstPlayed( firstPlayed ); -} - -QDateTime -CollectionTrack::lastPlayed() const -{ - return m_trackStats->lastPlayed(); -} - -void -CollectionTrack::setLastPlayed( const QDateTime &lastPlayed ) -{ - beginUpdate(); - m_trackStats->setLastPlayed( lastPlayed ); -} - -int -CollectionTrack::playCount() const -{ - return m_trackStats->playCount(); -} - -int -CollectionTrack::recentPlayCount() const -{ - return m_trackStats->recentPlayCount(); -} - -void -CollectionTrack::setPlayCount( int playCount ) -{ - beginUpdate(); - m_trackStats->setPlayCount( playCount ); -} - -QSet -CollectionTrack::labels() const -{ - Meta::LabelList labels = m_track->labels(); - QSet labelNames; - foreach( Meta::LabelPtr label, labels ) - labelNames.insert( label->name() ); - return labelNames; -} - -void -CollectionTrack::setLabels( const QSet &labels ) -{ - QSet existingLabels; - QMap existingLabelsMap; - foreach( const Meta::LabelPtr &label, m_track->labels() ) - { - existingLabels.insert( label->name() ); - existingLabelsMap.insert( label->name(), label ); - } - - QSet toRemove = existingLabels - labels; - foreach( const QString &labelName, toRemove ) - { - Q_ASSERT( existingLabelsMap.contains( labelName ) ); - m_track->removeLabel( existingLabelsMap.value( labelName ) ); - } - - QSet toAdd = labels - existingLabels; - foreach( const QString &labelName, toAdd ) - { - m_track->addLabel( labelName ); - } -} - -Meta::TrackPtr -CollectionTrack::metaTrack() const -{ - return m_track; -} - -void -CollectionTrack::commit() -{ - if( !m_beginUpdateAlreadyCalled ) - return; - - m_trackStats->endUpdate(); - m_beginUpdateAlreadyCalled = false; -} - -void -CollectionTrack::beginUpdate() -{ - if( m_beginUpdateAlreadyCalled ) - return; - - m_trackStats->beginUpdate(); - m_beginUpdateAlreadyCalled = true; -} diff --git a/amarok/src/statsyncing/collection/CollectionTrack.h b/amarok/src/statsyncing/collection/CollectionTrack.h deleted file mode 100644 index 109f004a..00000000 --- a/amarok/src/statsyncing/collection/CollectionTrack.h +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef STATSYNCING_COLLECTIONTRACK_H -#define STATSYNCING_COLLECTIONTRACK_H - -#include "core/meta/forward_declarations.h" -#include "statsyncing/Track.h" - -namespace StatSyncing -{ - - class CollectionTrack : public Track - { - public: - explicit CollectionTrack( Meta::TrackPtr track ); - virtual ~CollectionTrack(); - - virtual QString name() const; - virtual QString album() const; - virtual QString artist() const; - virtual QString composer() const; - virtual int year() const; - virtual int trackNumber() const; - virtual int discNumber() const; - - virtual int rating() const; - virtual void setRating( int rating ); - virtual QDateTime firstPlayed() const; - virtual void setFirstPlayed( const QDateTime &firstPlayed ); - virtual QDateTime lastPlayed() const; - virtual void setLastPlayed( const QDateTime &lastPlayed ); - virtual int playCount() const; - virtual int recentPlayCount() const; - virtual void setPlayCount( int playCount ); - virtual QSet labels() const; - virtual void setLabels( const QSet &labels ); - - virtual Meta::TrackPtr metaTrack() const; - virtual void commit(); - - private: - Q_DISABLE_COPY( CollectionTrack ) - - /** - * Calls m_trackStats->beginUpdate() if it hasn't been already called - */ - void beginUpdate(); - - Meta::TrackPtr m_track; - Meta::StatisticsPtr m_trackStats; - bool m_beginUpdateAlreadyCalled; - }; - -} // namespace StatSyncing - -#endif // STATSYNCING_COLLECTIONTRACK_H diff --git a/amarok/src/statsyncing/jobs/MatchTracksJob.cpp b/amarok/src/statsyncing/jobs/MatchTracksJob.cpp deleted file mode 100644 index 772a93a7..00000000 --- a/amarok/src/statsyncing/jobs/MatchTracksJob.cpp +++ /dev/null @@ -1,289 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "StatSyncing" - -#include "MatchTracksJob.h" - -#include "MetaValues.h" -#include "core/meta/Meta.h" - -using namespace StatSyncing; - -#undef VERBOSE_DEBUG -#ifdef VERBOSE_DEBUG -#include "core/support/Debug.h" -static void printPerProviderTrackList( const PerProviderTrackList &providerTracks, - const QString *fromArtist = 0L ) -{ - foreach( ProviderPtr provider, providerTracks.keys() ) - { - if( fromArtist ) - debug() << provider->prettyName() << "tracks from" << *fromArtist; - else - debug() << provider->prettyName() << "tracks"; - foreach( TrackPtr track, providerTracks.value( provider ) ) - { - debug() << " " << track->artist() << "-" << track->album() << "-" << track->name(); - } - } -} - -#include "core/meta/support/MetaConstants.h" -static QString comparisonFieldNames( qint64 fields ) -{ - QStringList names; - for( qint64 value = 1; value < Meta::valCustom; value *= 2 ) - { - if( value & fields ) - { - names << Meta::i18nForField( value ); - } - } - return names.join( ", " ); -} - -QDebug operator<<( QDebug dbg, const ProviderPtr &provider ) -{ - dbg.nospace() << "ProviderPtr(" << provider->prettyName() << ")"; - return dbg.space(); -} - -QDebug operator<<( QDebug dbg, const TrackPtr &track ) -{ - dbg.nospace() << "TrackPtr(" << track->artist() << " - " << track->name() << ")"; - return dbg.space(); -} -#endif - -qint64 MatchTracksJob::s_comparisonFields( 0 ); - -qint64 -MatchTracksJob::comparisonFields() -{ - return s_comparisonFields; -} - -MatchTracksJob::MatchTracksJob( const ProviderPtrList &providers, QObject *parent ) - : Job( parent ) - , m_abort( false ) - , m_providers( providers ) -{ -} - -ProviderPtrList -MatchTracksJob::providers() const -{ - return m_providers; -} - -bool -MatchTracksJob::success() const -{ - return !m_abort; -} - -void -MatchTracksJob::abort() -{ - m_abort = true; -} - -// work-around macro vs. template argument clash in foreach -typedef QMultiMap ArtistProviders; - -void MatchTracksJob::run() -{ - const qint64 possibleFields = Meta::valTitle | Meta::valArtist | Meta::valAlbum | - Meta::valComposer | Meta::valYear | Meta::valTrackNr | Meta::valDiscNr; - const qint64 requiredFields = Meta::valTitle | Meta::valArtist | Meta::valAlbum; - s_comparisonFields = possibleFields; - - // map of lowercase artist names to a list of providers that contain it plus their - // preferred representation of the artist name - QMap > providerArtists; - foreach( ProviderPtr provider, m_providers ) - { - QSet artists = provider->artists(); - foreach( const QString &artist, artists ) - providerArtists[ artist.toLower() ].insert( provider, artist ); - s_comparisonFields &= provider->reliableTrackMetaData(); - } - Q_UNUSED( requiredFields ) // silence gcc warning about unused var in non-debug build - Q_ASSERT( ( s_comparisonFields & requiredFields ) == requiredFields ); - emit totalSteps( providerArtists.size() ); -#ifdef VERBOSE_DEBUG - debug() << "Matching using:" << comparisonFieldNames( s_comparisonFields ).toLocal8Bit().constData(); -#endif - - foreach( const ArtistProviders &artistProviders, providerArtists ) - { - if( m_abort ) - break; - matchTracksFromArtist( artistProviders ); - emit incrementProgress(); - } - emit endProgressOperation( this ); - -#ifdef VERBOSE_DEBUG - debug(); - int tupleCount = m_matchedTuples.count(); - debug() << "Found" << tupleCount << "tuples of matched tracks from multiple collections"; - foreach( ProviderPtr provider, m_providers ) - { - const TrackList uniqueList = m_uniqueTracks.value( provider ); - const TrackList excludedList = m_excludedTracks.value( provider ); - debug() << provider->prettyName() << "has" << uniqueList.count() << "unique tracks +" - << excludedList.count() << "duplicate tracks +" << m_matchedTrackCounts[ provider ] - << " matched =" << uniqueList.count() + excludedList.count() + m_matchedTrackCounts[ provider ]; - } -#endif -} - -void -MatchTracksJob::matchTracksFromArtist( const QMultiMap &providerArtists ) -{ -#ifdef VERBOSE_DEBUG - DEBUG_BLOCK - debug() << "providerArtists:" << providerArtists; -#endif - PerProviderTrackList providerTracks; - foreach( ProviderPtr provider, providerArtists.uniqueKeys() ) - { - TrackList trackList; - foreach( const QString &artist, providerArtists.values( provider ) ) - trackList << provider->artistTracks( artist ); - if( trackList.isEmpty() ) - continue; // don't add empty lists to providerTracks - // the sorting is important and makes our matching algorithm work - qSort( trackList.begin(), trackList.end(), trackDelegatePtrLessThan ); - - scanForScrobblableTracks( trackList ); - providerTracks[ provider ] = trackList; - } - -#ifdef VERBOSE_DEBUG - debug() << "providerTracks:" << providerTracks; - QScopedPointer debugBlockPointer; - if( providerTracks.keys().count() > 1 ) - { - debugBlockPointer.reset( new Debug::Block( __PRETTY_FUNCTION__ ) ); - printPerProviderTrackList( providerTracks ); - } -#endif - - // if only one (or less) non-empty provider is left, we're done - while( providerTracks.keys().count() > 1 ) - { - TrackPtr firstTrack = findSmallestTrack( providerTracks ); - PerProviderTrackList equalTracks = takeTracksEqualTo( firstTrack, providerTracks ); - Q_ASSERT( !equalTracks.isEmpty() ); - - // optimization: continue early if there's only one provider left - if( equalTracks.keys().count() <= 1 ) - { - ProviderPtr provider = equalTracks.keys().first(); - m_uniqueTracks[ provider ].append( equalTracks[ provider ] ); - continue; - } - -#ifdef VERBOSE_DEBUG - debug(); - debug() << "First track:" << firstTrack->artist() << "-" << firstTrack->album() << "-" << firstTrack->name(); - debug() << "Tracks no greater than first track:"; - printPerProviderTrackList( equalTracks ); -#endif - - TrackTuple matchedTuple; - foreach( ProviderPtr provider, equalTracks.keys() ) - { - int listSize = equalTracks[ provider ].size(); - Q_ASSERT( listSize >= 1 ); - if( listSize == 1 ) - matchedTuple.insert( provider, equalTracks[ provider ].at( 0 ) ); - else - m_excludedTracks[ provider ].append( equalTracks[ provider ] ); - } - - if( matchedTuple.count() > 1 ) - // good, we've found track that matches! - addMatchedTuple( matchedTuple ); - else if( matchedTuple.count() == 1 ) - { - // only one provider - ProviderPtr provider = matchedTuple.provider( 0 ); - m_uniqueTracks[ provider ].append( matchedTuple.track( provider ) ); - } - } - - if( !providerTracks.isEmpty() ) // some tracks from one provider left - { - ProviderPtr provider = providerTracks.keys().first(); - m_uniqueTracks[ provider ].append( providerTracks[ provider ] ); - } -} - -TrackPtr -MatchTracksJob::findSmallestTrack( const PerProviderTrackList &providerTracks ) -{ - TrackPtr smallest; - foreach( const TrackList &list, providerTracks ) - { - if( !smallest || list.first()->lessThan( *smallest, s_comparisonFields ) ) - smallest = list.first(); - } - Q_ASSERT( smallest ); - return smallest; -} - -PerProviderTrackList -MatchTracksJob::takeTracksEqualTo( const TrackPtr &track, - PerProviderTrackList &providerTracks ) -{ - PerProviderTrackList ret; - foreach( ProviderPtr provider, providerTracks.keys() ) - { - while( !providerTracks[ provider ].isEmpty() && - track->equals( *providerTracks[ provider ].first(), s_comparisonFields ) ) - { - ret[ provider ].append( providerTracks[ provider ].takeFirst() ); - } - if( providerTracks[ provider ].isEmpty() ) - providerTracks.remove( provider ); - } - return ret; -} - -void -MatchTracksJob::addMatchedTuple( const TrackTuple &tuple ) -{ - m_matchedTuples.append( tuple ); - foreach( ProviderPtr provider, tuple.providers() ) - { - m_matchedTrackCounts[ provider ]++; - } -} - -void -MatchTracksJob::scanForScrobblableTracks( const TrackList &trackList ) -{ - foreach( const TrackPtr &track, trackList ) - { - // ScrobblingServices take Meta::Track, ensure there is an underlying one - if( track->recentPlayCount() > 0 && track->metaTrack() ) - m_tracksToScrobble << track; - } -} diff --git a/amarok/src/statsyncing/jobs/MatchTracksJob.h b/amarok/src/statsyncing/jobs/MatchTracksJob.h deleted file mode 100644 index ad71605a..00000000 --- a/amarok/src/statsyncing/jobs/MatchTracksJob.h +++ /dev/null @@ -1,158 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef STATSYNCING_MATCHTRACKSJOB_H -#define STATSYNCING_MATCHTRACKSJOB_H - -#include "statsyncing/Provider.h" -#include "statsyncing/TrackTuple.h" - -#include - -#include - -namespace StatSyncing -{ - /** - * Threadweaver job that matches tracks of multiple Providers. - * Because comparisonFields() needs to be static, only one instance of this class is - * allowed to exist at given time. - */ - class MatchTracksJob : public ThreadWeaver::Job - { - Q_OBJECT - - public: - MatchTracksJob( const ProviderPtrList &providers, QObject *parent = 0 ); - - virtual bool success() const; - - /** - * Binary OR of MetaValues.h Meta::val* flags that are used to compare tracks - * from different providers. Guaranteed to contain at least artist, album, - * title. Valid only after run() has been called. - */ - static qint64 comparisonFields(); - - /** - * Return a list of providers participating in the matching - */ - ProviderPtrList providers() const; - - // results: - const QList &matchedTuples() const { return m_matchedTuples; } - const PerProviderTrackList &uniqueTracks() const { return m_uniqueTracks; } - const PerProviderTrackList &excludedTracks() const { return m_excludedTracks; } - const TrackList &tracksToScrobble() const { return m_tracksToScrobble; } - - public slots: - /** - * Abort the job as soon as possible. - */ - void abort(); - - signals: - /** - * Emitted when matcher gets to know total number of steps it will take to - * match all tracks. - */ - void totalSteps( int steps ); - - /** - * Emitted when one progress step has been finished. - */ - void incrementProgress(); - - /** - * Emitted from worker thread when all time-consuming operations are done. - */ - void endProgressOperation( QObject *owner ); - - protected: - virtual void run(); - - private: - /** - * Queries each provider from @param artistProviders for tracks from artist - * they specify and separates them into m_uniqueTracks, m_excludedTracks and - * m_matchedTuples. - */ - void matchTracksFromArtist( const QMultiMap &artistProviders ); - - /** - * Finds the "smallest" track among provider track lists; assumes individual - * lists are already sorted and non-empty - */ - TrackPtr findSmallestTrack( const PerProviderTrackList &providerTracks ); - - /** - * Takes tracks from each provider that are equal to @param track. - * If a list from @param delegateTracks becomes empty, whole entry for that - * provider is removed from @param delegateTracks. - */ - PerProviderTrackList takeTracksEqualTo( const TrackPtr &track, - PerProviderTrackList &providerTracks ); - - /** - * Adds @param tuple to m_matchedTuples and updated m_matchedTrackCounts - */ - void addMatchedTuple( const TrackTuple &tuple ); - - /** - * Scan for tracks in @param trackList eligible for scrobbling and add them to - * m_tracksToScrobble. - */ - void scanForScrobblableTracks( const TrackList &trackList ); - - /** - * Must be static because comparisonFields needs to be static. - * @see comparisonFields() - */ - static qint64 s_comparisonFields; - - bool m_abort; - ProviderPtrList m_providers; - - /** - * Per-provider list of tracks that are unique to that provider - */ - PerProviderTrackList m_uniqueTracks; - - /** - * Per-provider list of tracks that have been excluded from synchronization - * for various reasons, e.g. for being duplicate within that provider - */ - PerProviderTrackList m_excludedTracks; - - /** - * Our raison d'etre: tuples of matched tracks - */ - QList m_matchedTuples; - - /** - * Tracks with non-zero recent playCount, eligible for being scrobbled. - */ - TrackList m_tracksToScrobble; - - /** - * Per-provider count of matched tracks - */ - QMap m_matchedTrackCounts; - }; - -} // namespace StatSyncing - -#endif // STATSYNCING_MATCHTRACKSJOB_H diff --git a/amarok/src/statsyncing/jobs/SynchronizeTracksJob.cpp b/amarok/src/statsyncing/jobs/SynchronizeTracksJob.cpp deleted file mode 100644 index 9ddf0c2c..00000000 --- a/amarok/src/statsyncing/jobs/SynchronizeTracksJob.cpp +++ /dev/null @@ -1,151 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "SynchronizeTracksJob.h" - -#include "core/meta/Meta.h" -#include "core/meta/Statistics.h" -#include "core/support/Components.h" -#include "core/support/Debug.h" -#include "statsyncing/Controller.h" -#include "statsyncing/TrackTuple.h" - -#include - -using namespace StatSyncing; - -static const int denom = 20; // emit incementProgress() signal each N tracks -static const int fuzz = denom / 2; - -SynchronizeTracksJob::SynchronizeTracksJob( const QList &tuples, - const TrackList &tracksToScrobble, - const Options &options, QObject *parent ) - : Job( parent ) - , m_abort( false ) - , m_tuples( tuples ) - , m_tracksToScrobble( tracksToScrobble ) - , m_updatedTracksCount( 0 ) - , m_options( options ) -{ -} - -void -SynchronizeTracksJob::abort() -{ - m_abort = true; -} - -void -SynchronizeTracksJob::run() -{ - emit totalSteps( ( m_tuples.size() + fuzz ) / denom ); - - Controller *controller = Amarok::Components::statSyncingController(); - if( controller ) - { - connect( this, SIGNAL(scrobble(Meta::TrackPtr,double,QDateTime)), - controller, SLOT(scrobble(Meta::TrackPtr,double,QDateTime)) ); - // we don't run an event loop, we must use direct connection for controller to talk to us - connect( controller, SIGNAL(trackScrobbled(ScrobblingServicePtr,Meta::TrackPtr)), - SLOT(slotTrackScrobbled(ScrobblingServicePtr,Meta::TrackPtr)), - Qt::DirectConnection ); - connect( controller, SIGNAL(scrobbleFailed(ScrobblingServicePtr,Meta::TrackPtr,int)), - SLOT(slotScrobbleFailed(ScrobblingServicePtr,Meta::TrackPtr,int)), - Qt::DirectConnection ); - } - else - warning() << __PRETTY_FUNCTION__ << "StatSyncing::Controller not available!"; - - // first, queue tracks for scrobbling, because after syncing their recent playcount is - // reset - foreach( const TrackPtr &track, m_tracksToScrobble ) - { - Meta::TrackPtr metaTrack = track->metaTrack(); - int playcount = track->recentPlayCount(); - if( metaTrack && playcount > 0 ) - { - m_scrobbledTracks << metaTrack; - emit scrobble( metaTrack, playcount, track->lastPlayed() ); - } - } - - ProviderPtrSet updatedProviders; - int i = 0; - foreach( const TrackTuple &tuple, m_tuples ) - { - if( m_abort ) - break; - - // no point in checking for hasUpdate() here, synchronize() is witty enough - const ProviderPtrSet tupleUpdatedProviders = tuple.synchronize( m_options ); - updatedProviders |= tupleUpdatedProviders; - m_updatedTracksCount += tupleUpdatedProviders.count(); - if( ( i + fuzz ) % denom == 0 ) - emit incrementProgress(); - i++; - } - - foreach( ProviderPtr provider, updatedProviders ) - provider->commitTracks(); - - - // we need to reset playCount of scrobbled tracks to reset their recent play count - foreach( Meta::TrackPtr track, m_scrobbledTracks ) - { - Meta::StatisticsPtr statistics = track->statistics(); - statistics->setPlayCount( statistics->playCount() ); - } - - if( !m_tracksToScrobble.isEmpty() ) - // wait 3 seconds so that we have chance to catch slotTrackScrobbled().. - thread()->msleep( 3000 ); - if( controller ) - disconnect( controller, SIGNAL(trackScrobbled(ScrobblingServicePtr,Meta::TrackPtr)), this, 0 ); - disconnect( controller, SIGNAL(scrobbleFailed(ScrobblingServicePtr,Meta::TrackPtr,int)), this, 0 ); - - emit endProgressOperation( this ); -} - -void -SynchronizeTracksJob::slotTrackScrobbled( const ScrobblingServicePtr &service, - const Meta::TrackPtr &track ) -{ - slotScrobbleFailed( service, track, ScrobblingService::NoError ); -} - -void -SynchronizeTracksJob::slotScrobbleFailed( const ScrobblingServicePtr &service, - const Meta::TrackPtr &track, int error ) -{ - // only count tracks scrobbled by us. Still chance for false-positives, though - if( m_scrobbledTracks.contains( track ) ) - { - ScrobblingService::ScrobbleError errorEnum = ScrobblingService::ScrobbleError( error ); - m_scrobbles[ service ][ errorEnum ]++; - } -} - -int -SynchronizeTracksJob::updatedTracksCount() const -{ - return m_updatedTracksCount; -} - -QMap > -SynchronizeTracksJob::scrobbles() -{ - return m_scrobbles; -} diff --git a/amarok/src/statsyncing/jobs/SynchronizeTracksJob.h b/amarok/src/statsyncing/jobs/SynchronizeTracksJob.h deleted file mode 100644 index efa77368..00000000 --- a/amarok/src/statsyncing/jobs/SynchronizeTracksJob.h +++ /dev/null @@ -1,105 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef STATSYNCING_SYNCHRONIZETRACKSJOB_H -#define STATSYNCING_SYNCHRONIZETRACKSJOB_H - -#include "core/meta/forward_declarations.h" -#include "statsyncing/Options.h" -#include "statsyncing/ScrobblingService.h" -#include "statsyncing/Track.h" - -#include - -#include - -namespace StatSyncing -{ - class TrackTuple; - - /** - * A job to call TrackTuple::synchronize() in order not to make delays in the main - * loop. - */ - class SynchronizeTracksJob : public ThreadWeaver::Job - { - Q_OBJECT - - public: - explicit SynchronizeTracksJob( const QList &tuples, - const TrackList &trackToScrobble, - const Options &options, QObject *parent = 0 ); - - /** - * Return count of tracks that were updated during synchronization - */ - int updatedTracksCount() const; - - /** - * Return scrobble counts per scrobbling service and their status. - */ - QMap > scrobbles(); - - public slots: - /** - * Abort the job as soon as possible. - */ - void abort(); - - signals: - /** - * Emitted when matcher gets to know total number of steps it will take to - * match all tracks. - */ - void totalSteps( int steps ); - - /** - * Emitted when one progress step has been finished. - */ - void incrementProgress(); - - /** - * Emitted from worker thread when all time-consuming operations are done. - */ - void endProgressOperation( QObject *owner ); - - /** - * Helper to cross thread boundary between this worker thread and main thread - * where StatSyncing::Controller lives. - */ - void scrobble( const Meta::TrackPtr &track, double playedFraction, - const QDateTime &time ); - - protected: - virtual void run(); - - private slots: - void slotTrackScrobbled( const ScrobblingServicePtr &service, const Meta::TrackPtr &track ); - void slotScrobbleFailed( const ScrobblingServicePtr &service, const Meta::TrackPtr &track, int error ); - - private: - bool m_abort; - QList m_tuples; - TrackList m_tracksToScrobble; - QSet m_scrobbledTracks; - QMap > m_scrobbles; - int m_updatedTracksCount; - const Options m_options; - }; - -} // namespace StatSyncing - -#endif // STATSYNCING_SYNCHRONIZETRACKSJOB_H diff --git a/amarok/src/statsyncing/models/CommonModel.cpp b/amarok/src/statsyncing/models/CommonModel.cpp deleted file mode 100644 index 43ea4378..00000000 --- a/amarok/src/statsyncing/models/CommonModel.cpp +++ /dev/null @@ -1,215 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "CommonModel.h" - -#include "MetaValues.h" -#include "core/meta/support/MetaConstants.h" -#include "core/support/Debug.h" -#include "statsyncing/Options.h" - -#include -#include - -#include -#include - -using namespace StatSyncing; - -const QSize CommonModel::s_ratingSize( 5*16, 16 ); - -CommonModel::CommonModel( const QList &columns, const Options &options ) - : m_columns( columns ) - , m_options( options ) -{ - Q_ASSERT( m_columns.value( 0 ) == Meta::valTitle ); -} - -QVariant -CommonModel::headerData( int section, Qt::Orientation orientation, int role ) const -{ - if( orientation != Qt::Horizontal || section < 0 || section >= m_columns.count() ) - return QVariant(); - qint64 field = m_columns.at( section ); - switch( role ) - { - case Qt::DisplayRole: - return Meta::i18nForField( field ); - case Qt::SizeHintRole: - return sizeHintData( field ); - case ResizeModeRole: - switch( field ) - { - case Meta::valTitle: - return QHeaderView::Stretch; - case Meta::valRating: - case Meta::valFirstPlayed: - case Meta::valLastPlayed: - case Meta::valPlaycount: - return QHeaderView::ResizeToContents; - default: - return QHeaderView::Interactive; - } - case FieldRole: - return field; - } - return QVariant(); -} - -QVariant -CommonModel::sizeHintData( qint64 field ) const -{ - switch( field ) - { - case Meta::valRating: - { - static QSize size; - if( size.isValid() ) // optimization - return size; - QStyleOptionViewItemV4 opt; - opt.features = QStyleOptionViewItemV2::HasDisplay - | QStyleOptionViewItemV2::HasCheckIndicator - | QStyleOptionViewItemV2::HasDecoration; - opt.state = QStyle::State_Enabled; - opt.decorationSize = s_ratingSize; - - const QWidget *widget = opt.widget; - QStyle *style = widget ? widget->style() : QApplication::style(); - size = style->sizeFromContents( QStyle::CT_ItemViewItem, &opt, QSize(), widget ); - return size; - } - case Meta::valFirstPlayed: - case Meta::valLastPlayed: - { - static QSize size; - if( size.isValid() ) // optimization - return size; - QStyleOptionViewItemV4 opt; - opt.features = QStyleOptionViewItemV2::HasDisplay; - opt.state = QStyle::State_Enabled; - opt.text = "88.88.8888 88:88"; - - QStyle *style = QApplication::style(); - size = style->sizeFromContents( QStyle::CT_ItemViewItem, &opt, QSize(), 0 ); - return size; - } - case Meta::valPlaycount: - { - static QSize size; - if( size.isValid() ) // optimization - return size; - QStyleOptionViewItemV4 opt; - opt.features = QStyleOptionViewItemV2::HasDisplay; - opt.state = QStyle::State_Enabled; - opt.text = "888 (88)"; - opt.font.setBold( true ); - - QStyle *style = QApplication::style(); - size = style->sizeFromContents( QStyle::CT_ItemViewItem, &opt, QSize(), 0 ); - return size; - } - } - return QVariant(); -} - -QVariant -CommonModel::textAlignmentData( qint64 field ) const -{ - switch( field ) - { - case Meta::valRating: - case Meta::valFirstPlayed: - case Meta::valLastPlayed: - case Meta::valPlaycount: - return Qt::AlignRight; - } - return QVariant(); -} - -QVariant -CommonModel::trackData( const TrackPtr &track, qint64 field, int role ) const -{ - switch( role ) - { - case Qt::DisplayRole: - switch( field ) - { - case Meta::valTitle: - return trackTitleData( track ); - case Meta::valRating: - return track->rating(); - case Meta::valFirstPlayed: - return track->firstPlayed(); - case Meta::valLastPlayed: - return track->lastPlayed(); - case Meta::valPlaycount: - { - int recent = track->recentPlayCount(); - return recent ? QVariant( i18nc( "%1 is play count and %2 is recent play count", - "%1 (%2)", track->playCount(), recent ) ) : QVariant( track->playCount() ); - } - case Meta::valLabel: - return QStringList( ( track->labels() - m_options.excludedLabels() ).toList() ).join( i18nc( - "comma between list words", ", " ) ); - default: - return QString( "Unknown field!" ); - } - break; - case Qt::ToolTipRole: - switch( field ) - { - case Meta::valTitle: - return trackToolTipData( track ); - case Meta::valPlaycount: - return i18np( "Played %2 times of which one play is recent and unique " - "to this source", "Played %2 times of which %1 plays are recent " - "and unique to this source", track->recentPlayCount(), track->playCount() ); - case Meta::valLabel: - { - QSet labels = track->labels() - m_options.excludedLabels(); - QSet excludedLabels = track->labels() & m_options.excludedLabels(); - QStringList texts; - if( !labels.isEmpty() ) - texts << i18n( "Labels: %1", QStringList( labels.toList() ).join( i18nc( - "comma between list words", ", " ) ) ); - if( !excludedLabels.isEmpty() ) - texts << i18n( "Ignored labels: %1", QStringList( excludedLabels.toList() ).join( i18nc( - "comma between list words", ", " ) ) ); - return texts.isEmpty() ? QVariant() : texts.join( "\n" ); - } - } - break; - case Qt::TextAlignmentRole: - return textAlignmentData( field ); - case Qt::SizeHintRole: - return sizeHintData( field ); - case FieldRole: - return field; - } - return QVariant(); -} - -QVariant -CommonModel::trackTitleData( const TrackPtr &track ) const -{ - return i18n( "%1 - %2 - %3", track->artist(), track->album(), track->name() ); -} - -QVariant -CommonModel::trackToolTipData( const TrackPtr &track ) const -{ - return trackTitleData( track ); // TODO nicer toolTip, display more fields -} diff --git a/amarok/src/statsyncing/models/CommonModel.h b/amarok/src/statsyncing/models/CommonModel.h deleted file mode 100644 index 9e43ef5f..00000000 --- a/amarok/src/statsyncing/models/CommonModel.h +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef STATSYNCING_COMMONMODEL_H -#define STATSYNCING_COMMONMODEL_H - -#include "statsyncing/Options.h" -#include "statsyncing/Track.h" - -#include -#include - -namespace StatSyncing -{ - /** - * Helper class for {Matched,Single}TracksModel's to avoid code duplication - */ - class CommonModel - { - public: - enum { - ResizeModeRole = Qt::UserRole, - FieldRole, - UserRole - }; - static const QSize s_ratingSize; - - explicit CommonModel( const QList &columns, const Options &options ); - - QVariant headerData( int section, Qt::Orientation orientation, - int role = Qt::DisplayRole ) const; - - protected: - QVariant sizeHintData( qint64 field ) const; - QVariant textAlignmentData( qint64 field ) const; - - QVariant trackData( const TrackPtr &track, qint64 field, int role ) const; - QVariant trackTitleData( const TrackPtr &track ) const; - QVariant trackToolTipData( const TrackPtr &track ) const; - - QList m_columns; - Options m_options; - }; - -} // namespace StatSyncing - -#endif // STATSYNCING_COMMONMODEL_H diff --git a/amarok/src/statsyncing/models/MatchedTracksModel.cpp b/amarok/src/statsyncing/models/MatchedTracksModel.cpp deleted file mode 100644 index d7a35703..00000000 --- a/amarok/src/statsyncing/models/MatchedTracksModel.cpp +++ /dev/null @@ -1,409 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "MatchedTracksModel.h" - -#include "MetaValues.h" -#include "core/meta/support/MetaConstants.h" -#include "core/support/Debug.h" -#include "statsyncing/TrackTuple.h" - -#include -#include - -using namespace StatSyncing; - -static const int tupleIndexIndernalId = -1; - -MatchedTracksModel::MatchedTracksModel( const QList &matchedTuples, - const QList &columns, const Options &options, QObject *parent ) - : QAbstractItemModel( parent ) - , CommonModel( columns, options ) - , m_matchedTuples( matchedTuples ) -{ - m_titleColumn = m_columns.indexOf( Meta::valTitle ); -} - -QModelIndex -MatchedTracksModel::index( int row, int column, const QModelIndex &parent ) const -{ - if( !parent.isValid() && column >= 0 && column < m_columns.count() ) - return createIndex( row, column, tupleIndexIndernalId ); - if( parent.internalId() == tupleIndexIndernalId && - parent.row() >= 0 && parent.row() < m_matchedTuples.count() && - parent.column() == m_titleColumn && - row >= 0 && row < m_matchedTuples.at( parent.row() ).count() && - column >=0 && column < m_columns.count() ) - { - return createIndex( row, column, parent.row() ); - } - return QModelIndex(); -} - -QModelIndex -MatchedTracksModel::parent( const QModelIndex &child ) const -{ - if( !child.isValid() || child.internalId() == tupleIndexIndernalId ) - return QModelIndex(); - return createIndex( child.internalId(), m_titleColumn, tupleIndexIndernalId ); -} - -bool -MatchedTracksModel::hasChildren( const QModelIndex &parent ) const -{ - if( !parent.isValid() ) - return !m_matchedTuples.isEmpty(); - if( parent.internalId() == tupleIndexIndernalId && - parent.row() >= 0 && parent.row() < m_matchedTuples.count() && - parent.column() == m_titleColumn ) - { - return true; // we expect only nonempty tuples - } - return false; // leaf node -} - -int -MatchedTracksModel::rowCount( const QModelIndex &parent ) const -{ - if( !parent.isValid() ) - return m_matchedTuples.count(); - if( parent.internalId() == tupleIndexIndernalId && - parent.column() == m_titleColumn ) - return m_matchedTuples.value( parent.row() ).count(); // handles invalid row numbers gracefully - return 0; // parent is leaf node -} - -int -MatchedTracksModel::columnCount( const QModelIndex &parent ) const -{ - if( !parent.isValid() || - ( parent.internalId() == tupleIndexIndernalId && parent.column() == m_titleColumn ) ) - { - return m_columns.count(); - } - return 0; // parent is leaf node -} - -QVariant -MatchedTracksModel::headerData( int section, Qt::Orientation orientation, int role ) const -{ - return CommonModel::headerData( section, orientation, role ); -} - -QVariant -MatchedTracksModel::data( const QModelIndex &index, int role ) const -{ - if( !index.isValid() || index.column() < 0 || index.column() >= m_columns.count() ) - return QVariant(); - - qint64 field = m_columns.at( index.column() ); - if( index.internalId() == tupleIndexIndernalId ) - { - TrackTuple tuple = m_matchedTuples.value( index.row() ); - if( tuple.isEmpty() ) - return QVariant(); - return tupleData( tuple, field, role ); - } - else if( index.internalId() >= 0 && index.internalId() < m_matchedTuples.count() ) - { - TrackTuple tuple = m_matchedTuples.value( index.internalId() ); - ProviderPtr provider = tuple.provider( index.row() ); - if( !provider ) - return QVariant(); - return trackData( provider, tuple, field, role ); - } - return QVariant(); -} - -bool -MatchedTracksModel::setData( const QModelIndex &idx, const QVariant &value, int role ) -{ - if( !idx.isValid() || idx.internalId() < 0 || - idx.internalId() >= m_matchedTuples.count() || - role != Qt::CheckStateRole ) - { - return false; - } - qint64 field = m_columns.value( idx.column() ); - TrackTuple &tuple = m_matchedTuples[ idx.internalId() ]; // we need reference - ProviderPtr provider = tuple.provider( idx.row() ); - if( !provider ) - return false; - - switch( field ) - { - case Meta::valRating: - switch( Qt::CheckState( value.toInt() ) ) - { - case Qt::Checked: - tuple.setRatingProvider( provider ); - break; - case Qt::Unchecked: - tuple.setRatingProvider( ProviderPtr() ); - break; - default: - return false; - } - break; - case Meta::valLabel: - { - ProviderPtrSet labelProviders = tuple.labelProviders(); - switch( Qt::CheckState( value.toInt() ) ) - { - case Qt::Checked: - labelProviders.insert( provider ); - tuple.setLabelProviders( labelProviders ); - break; - case Qt::Unchecked: - labelProviders.remove( provider ); - tuple.setLabelProviders( labelProviders ); - break; - default: - return false; - } - break; - } - default: - return false; - } - - // parent changes: - QModelIndex parent = idx.parent(); - QModelIndex parentRating = index( parent.row(), idx.column(), parent.parent() ); - emit dataChanged( parentRating, parentRating ); - - // children change: - QModelIndex topLeft = index( 0, idx.column(), parent ); - QModelIndex bottomRight = index( tuple.count() - 1, idx.column(), parent ); - emit dataChanged( topLeft, bottomRight ); - return true; -} - -Qt::ItemFlags -MatchedTracksModel::flags( const QModelIndex &index ) const -{ - // many false positives here, but no-one is hurt - return QAbstractItemModel::flags( index ) | Qt::ItemIsUserCheckable; -} - -const QList & -MatchedTracksModel::matchedTuples() -{ - return m_matchedTuples; -} - -bool -MatchedTracksModel::hasUpdate() const -{ - foreach( const TrackTuple &tuple, m_matchedTuples ) - { - if( tuple.hasUpdate( m_options ) ) - return true; - } - return false; -} - -bool -MatchedTracksModel::hasConflict( int i ) const -{ - if( i >= 0 ) - return m_matchedTuples.value( i ).hasConflict( m_options ); - foreach( const TrackTuple &tuple, m_matchedTuples ) - { - if( tuple.hasConflict( m_options ) ) - return true; - } - return false; -} - -void -MatchedTracksModel::takeRatingsFrom( const ProviderPtr &provider ) -{ - for( int i = 0; i < m_matchedTuples.count(); i++ ) - { - TrackTuple &tuple = m_matchedTuples[ i ]; // we need reference - if( !tuple.fieldHasConflict( Meta::valRating, m_options ) ) - continue; - - if( tuple.ratingProvider() == provider ) - continue; // short-cut - tuple.setRatingProvider( provider ); // does nothing if non-null provider isn't in tuple - - // parent changes: - int ratingColumn = m_columns.indexOf( Meta::valRating ); - QModelIndex parentRating = index( i, ratingColumn ); - emit dataChanged( parentRating, parentRating ); - - // children change: - QModelIndex parent = index( i, 0 ); - QModelIndex topLeft = index( 0, ratingColumn, parent ); - QModelIndex bottomRight = index( tuple.count() - 1, ratingColumn, parent ); - emit dataChanged( topLeft, bottomRight ); - } -} - -void -MatchedTracksModel::includeLabelsFrom( const ProviderPtr &provider ) -{ - if( !provider ) - return; // has no sense - for( int i = 0; i < m_matchedTuples.count(); i++ ) - { - TrackTuple &tuple = m_matchedTuples[ i ]; // we need reference - if( !tuple.fieldHasConflict( Meta::valLabel, m_options ) ) - continue; - ProviderPtrSet providers = tuple.labelProviders(); - providers.insert( provider ); - - if( providers == tuple.labelProviders() ) - continue; // short-cut - tuple.setLabelProviders( providers ); // does nothing if provider isn't in tuple - - // parent changes: - int ratingColumn = m_columns.indexOf( Meta::valRating ); - QModelIndex parentRating = index( i, ratingColumn ); - emit dataChanged( parentRating, parentRating ); - - // children change: - QModelIndex parent = index( i, 0 ); - QModelIndex topLeft = index( 0, ratingColumn, parent ); - QModelIndex bottomRight = index( tuple.count() - 1, ratingColumn, parent ); - emit dataChanged( topLeft, bottomRight ); - } -} - -void -MatchedTracksModel::excludeLabelsFrom( const ProviderPtr &provider ) -{ - for( int i = 0; i < m_matchedTuples.count(); i++ ) - { - TrackTuple &tuple = m_matchedTuples[ i ]; // we need reference - if( !tuple.fieldHasConflict( Meta::valLabel, m_options ) ) - continue; - ProviderPtrSet providers = tuple.labelProviders(); - if( provider ) - // normal more, remove one provider - providers.remove( provider ); - else - // reset mode, clear providers - providers.clear(); - - if( providers == tuple.labelProviders() ) - continue; // short-cut - tuple.setLabelProviders( providers ); // does nothing if provider isn't in tuple - - // parent changes: - int ratingColumn = m_columns.indexOf( Meta::valRating ); - QModelIndex parentRating = index( i, ratingColumn ); - emit dataChanged( parentRating, parentRating ); - - // children change: - QModelIndex parent = index( i, 0 ); - QModelIndex topLeft = index( 0, ratingColumn, parent ); - QModelIndex bottomRight = index( tuple.count() - 1, ratingColumn, parent ); - emit dataChanged( topLeft, bottomRight ); - } -} - -QVariant -MatchedTracksModel::tupleData( const TrackTuple &tuple, qint64 field, int role ) const -{ - ProviderPtr firstProvider = tuple.provider( 0 ); - TrackPtr first = tuple.track( firstProvider ); - switch( role ) - { - case Qt::DisplayRole: - switch( field ) - { - case Meta::valTitle: - return trackTitleData( first ); - case Meta::valRating: - return tuple.syncedRating( m_options ); - case Meta::valFirstPlayed: - return tuple.syncedFirstPlayed( m_options ); - case Meta::valLastPlayed: - return tuple.syncedLastPlayed( m_options ); - case Meta::valPlaycount: - return tuple.syncedPlaycount( m_options ); - case Meta::valLabel: - if( tuple.fieldHasConflict( field, m_options, /* includeResolved */ false ) ) - return -1; // display same icon as for rating conflict - return QStringList( tuple.syncedLabels( m_options ).toList() ).join( - i18nc( "comma between list words", ", " ) ); - default: - return QString( "Unknown field!" ); - } - break; - case Qt::ToolTipRole: - switch( field ) - { - case Meta::valTitle: - return trackToolTipData( first ); // TODO way to specify which additional meta-data to display - case Meta::valLabel: - return QStringList( tuple.syncedLabels( m_options ).toList() ).join( - i18nc( "comma between list words", ", " ) ); - } - break; - case Qt::BackgroundRole: - if( tuple.fieldUpdated( field, m_options ) ) - return KColorScheme( QPalette::Active ).background( KColorScheme::PositiveBackground ); - break; - case Qt::TextAlignmentRole: - return textAlignmentData( field ); - case Qt::SizeHintRole: - return sizeHintData( field ); - case CommonModel::FieldRole: - return field; - case TupleFlagsRole: - int flags = tuple.hasUpdate( m_options ) ? HasUpdate : 0; - flags |= tuple.hasConflict( m_options ) ? HasConflict : 0; - return flags; - } - return QVariant(); -} - -QVariant -MatchedTracksModel::trackData( ProviderPtr provider, const TrackTuple &tuple, - qint64 field, int role ) const -{ - TrackPtr track = tuple.track( provider ); - - if( role == Qt::DisplayRole && field == Meta::valTitle ) - return provider->prettyName(); - else if( role == Qt::DecorationRole && field == Meta::valTitle ) - return provider->icon(); - // no special background if the field in whole tuple is not updated - else if( role == Qt::BackgroundRole && tuple.fieldUpdated( field, m_options ) ) - { - KColorScheme::BackgroundRole backgroundRole = - tuple.fieldUpdated( field, m_options, provider ) ? KColorScheme::NegativeBackground - : KColorScheme::PositiveBackground; - return KColorScheme( QPalette::Active ).background( backgroundRole ); - } - else if( role == Qt::CheckStateRole && tuple.fieldHasConflict( field, m_options ) ) - { - switch( field ) - { - case Meta::valRating: - return ( tuple.ratingProvider() == provider ) ? Qt::Checked : Qt::Unchecked; - case Meta::valLabel: - return ( tuple.labelProviders().contains( provider ) ) ? Qt::Checked : Qt::Unchecked; - default: - warning() << __PRETTY_FUNCTION__ << "this should be never reached"; - } - } - return trackData( track, field, role ); -} diff --git a/amarok/src/statsyncing/models/MatchedTracksModel.h b/amarok/src/statsyncing/models/MatchedTracksModel.h deleted file mode 100644 index d8e3f3f7..00000000 --- a/amarok/src/statsyncing/models/MatchedTracksModel.h +++ /dev/null @@ -1,134 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef STATSYNCING_MATCHEDTRACKSMODEL_H -#define STATSYNCING_MATCHEDTRACKSMODEL_H - -#include "statsyncing/Provider.h" -#include "statsyncing/models/CommonModel.h" - -#include - -namespace StatSyncing -{ - class TrackTuple; - - /** - * Model that provides data about matched tracks that should participate in statistics - * synchronization. - */ - class MatchedTracksModel : public QAbstractItemModel, protected CommonModel - { - Q_OBJECT - - public: - enum { - TupleFlagsRole = CommonModel::UserRole, - }; - - /** - * Flags for track tuple status - */ - enum TupleFlag { - HasConflict = 1 << 0, /// there is at least one potential rating conflict - HasUpdate = 1 << 1, /// there is at least one field going to be updated - }; - - /** - * Construct model of matched tracks. - * - * @param matchedTuples list of matched track tuples - * @param columns list of Meta::val* fields that will form columns of the model - * must include Meta::valTitle, may include: valRating, - * valFirstPlayed, valLastPlayed, valPlaycount, valLabel. - * @param options options for synchronizing individual tracks - */ - MatchedTracksModel( const QList &matchedTuples, - const QList &columns, const Options &options, - QObject *parent = 0 ); - - QModelIndex index( int row, int column, - const QModelIndex &parent = QModelIndex() ) const; - QModelIndex parent( const QModelIndex &child ) const; - - bool hasChildren( const QModelIndex &parent = QModelIndex() ) const; - int rowCount( const QModelIndex &parent = QModelIndex() ) const; - int columnCount( const QModelIndex &parent = QModelIndex() ) const; - - QVariant headerData( int section, Qt::Orientation orientation, - int role = Qt::DisplayRole ) const; - QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const; - bool setData( const QModelIndex &index, const QVariant &value, int role = Qt::EditRole ); - Qt::ItemFlags flags( const QModelIndex &index ) const; - - // MatchedTracksModel-specific methods: - /** - * Return a list of matched tuples, the same passed to model constructor, but - * some may be changed, e.g. conflict-resolved etc. - */ - const QList &matchedTuples(); - - /** - * Return true if at least one of the tuple is going to be updated. Warning: - * can depend on whether a conflict of one tuple is resolved or not. - */ - bool hasUpdate() const; - - /** - * Return true if given or at least one tuple has potential conflict. - * @param i if >= 0, queries tuple at position i; otherwise match any tuple - */ - bool hasConflict( int i = -1 ) const; - - /** - * Go through all tuples with (both resolved and unresolved) rating conflict - * and (re)set their preferred rating provider to @param provider. Null - * @param provider resets all tuples to "undecided". If @param provider is - * not null and given tuple has no track from provider, its state remains - * unchanged. - */ - void takeRatingsFrom( const ProviderPtr &provider ); - - /** - * Go through all tuples with (both resolved and unresolved) labels conflict - * and add @param provider to list of their label sources. Tracks that don't - * have @param provider in their providers remain unchanged. - */ - void includeLabelsFrom( const ProviderPtr &provider ); - - /** - * Go through all tuples with (both resolved and unresolved) labels conflict - * and remove @param provider from their list of label sources. Tracks that - * don't have @param provider in their label sources remain unchanged. - * - * If @param provider is null, this methods resets all tubles to "undecided" - * wrt labels (clears their list of label sources). - */ - void excludeLabelsFrom( const ProviderPtr &provider ); - - private: - QVariant tupleData( const TrackTuple &tuple, qint64 field, int role ) const; - QVariant trackData( ProviderPtr provider, const TrackTuple &tuple, - qint64 field, int role ) const; - using CommonModel::trackData; - - QList m_matchedTuples; - int m_titleColumn; - }; - -} // namespace StatSyncing - -#endif // STATSYNCING_MATCHEDTRACKSMODEL_H diff --git a/amarok/src/statsyncing/models/ProvidersModel.cpp b/amarok/src/statsyncing/models/ProvidersModel.cpp deleted file mode 100644 index d321097f..00000000 --- a/amarok/src/statsyncing/models/ProvidersModel.cpp +++ /dev/null @@ -1,142 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "ProvidersModel.h" - -#include "core/meta/support/MetaConstants.h" -#include "statsyncing/Provider.h" - -#include - -#include - -using namespace StatSyncing; - -ProvidersModel::ProvidersModel( const ProviderPtrList &providers, - const ProviderPtrSet &preSelectedProviders, QObject *parent ) - : QAbstractListModel( parent ) - , m_providers( providers ) - , m_selectionModel( new QItemSelectionModel( this, this ) ) -{ - // TODO: sort providers - - // selection defaults to model's tick state - for( int i = 0; i < m_providers.count(); i++ ) - { - if( preSelectedProviders.contains( m_providers.at( i ) ) ) - { - QModelIndex idx = index( i ); - m_selectionModel->select( idx, QItemSelectionModel::Select ); - } - } - connect( m_selectionModel, SIGNAL(selectionChanged(QItemSelection,QItemSelection)), - SIGNAL(selectedProvidersChanged()) ); -} - -ProvidersModel::~ProvidersModel() -{ -} - -QVariant -ProvidersModel::data( const QModelIndex &index, int role ) const -{ - if( !index.isValid() || index.column() != 0 || - index.row() < 0 || index.row() >= m_providers.count() ) - { - return QVariant(); - } - ProviderPtr provider = m_providers.at( index.row() ); - switch( role ) - { - case Qt::DisplayRole: - if( provider->description().isEmpty() ) - return provider->prettyName(); - return i18nc( "%1: name, %2: description", "%1 (%2)", provider->prettyName(), - provider->description() ); - case Qt::DecorationRole: - return provider->icon(); - case Qt::ToolTipRole: - return i18n( "Can match tracks by: %1\nCan synchronize: %2", - fieldsToString( provider->reliableTrackMetaData() ), - fieldsToString( provider->writableTrackStatsData() ) ); - } - return QVariant(); -} - -int -ProvidersModel::rowCount( const QModelIndex &parent ) const -{ - return parent.isValid() ? 0 : m_providers.count(); -} - -ProviderPtrList -ProvidersModel::selectedProviders() const -{ - ProviderPtrList ret; - // preserve order, so do it the hard way - for( int i = 0; i < rowCount(); i++ ) - { - QModelIndex idx = index( i, 0 ); - if( m_selectionModel->isSelected( idx ) ) - ret << m_providers.at( i ); - } - return ret; -} - -qint64 -ProvidersModel::reliableTrackMetadataIntersection() const -{ - if( selectedProviders().isEmpty() ) - return 0; - QListIterator it( selectedProviders() ); - qint64 fields = it.next()->reliableTrackMetaData(); - while( it.hasNext() ) - fields &= it.next()->reliableTrackMetaData(); - return fields; -} - -qint64 -ProvidersModel::writableTrackStatsDataUnion() const -{ - qint64 fields = 0; - foreach( const ProviderPtr &provider, selectedProviders() ) - { - fields |= provider->writableTrackStatsData(); - } - return fields; -} - -QItemSelectionModel * -ProvidersModel::selectionModel() const -{ - return m_selectionModel; -} - -QString -ProvidersModel::fieldsToString( qint64 fields ) const -{ - QStringList fieldNames; - for( qint64 i = 0; i < 64; i++ ) - { - qint64 field = 1LL << i; - if( !( field & fields ) ) - continue; - QString name = Meta::i18nForField( field ); - if( !name.isEmpty() ) - fieldNames << name; - } - return fieldNames.join( i18nc( "comma between list words", ", " ) ); -} diff --git a/amarok/src/statsyncing/models/ProvidersModel.h b/amarok/src/statsyncing/models/ProvidersModel.h deleted file mode 100644 index 4faf38b3..00000000 --- a/amarok/src/statsyncing/models/ProvidersModel.h +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef STATSYNCING_PROVIDERSMODEL_H -#define STATSYNCING_PROVIDERSMODEL_H - -#include "statsyncing/Provider.h" - -#include -#include -#include - -class QItemSelectionModel; - -namespace StatSyncing -{ - class ProvidersModel : public QAbstractListModel - { - Q_OBJECT - - public: - ProvidersModel( const ProviderPtrList &providers, - const ProviderPtrSet &preSelectedProviders, QObject *parent = 0 ); - virtual ~ProvidersModel(); - - // QAbstractItemModel methods: - QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const; - int rowCount( const QModelIndex &parent = QModelIndex() ) const; - - // ProvidersModel methods: - ProviderPtrList selectedProviders() const; - - /** - * Return binary OR of fields that are reliable for track matching across - * selected providers. - */ - qint64 reliableTrackMetadataIntersection() const; - - /** - * Return binary OR of fields that at least one selected providers can write - */ - qint64 writableTrackStatsDataUnion() const; - - /** - * You must assign this selection model to your view so that selectedProviders - * gives accurate results. ProvidersModel owns the selection model. - */ - QItemSelectionModel *selectionModel() const; - - /** - * Returns fields bit-field as i18n'ed string of comma separated field names. - */ - QString fieldsToString( qint64 fields ) const; - - signals: - void selectedProvidersChanged(); - - private: - ProviderPtrList m_providers; - QItemSelectionModel *m_selectionModel; - }; -} // namespace StatSyncing - -#endif // STATSYNCING_PROVIDERSMODEL_H diff --git a/amarok/src/statsyncing/models/SingleTracksModel.cpp b/amarok/src/statsyncing/models/SingleTracksModel.cpp deleted file mode 100644 index 21aca160..00000000 --- a/amarok/src/statsyncing/models/SingleTracksModel.cpp +++ /dev/null @@ -1,99 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "SingleTracksModel.h" - -#include "AmarokMimeData.h" -#include "MetaValues.h" -#include "core/meta/support/MetaConstants.h" - -using namespace StatSyncing; - -SingleTracksModel::SingleTracksModel( const TrackList &tracks, - const QList &columns, const Options &options, - QObject *parent ) - : QAbstractTableModel( parent ) - , CommonModel( columns, options ) - , m_tracks( tracks ) -{ -} - -int -SingleTracksModel::rowCount( const QModelIndex &parent ) const -{ - return parent.isValid() ? 0 : m_tracks.count(); -} - -int -SingleTracksModel::columnCount( const QModelIndex &parent ) const -{ - return parent.isValid() ? 0 : m_columns.count(); -} - -QVariant -SingleTracksModel::headerData( int section, Qt::Orientation orientation, int role ) const -{ - return CommonModel::headerData( section, orientation, role ); -} - -QVariant -SingleTracksModel::data( const QModelIndex &index, int role ) const -{ - if( !index.isValid() || - index.row() < 0 || index.row() >= m_tracks.count() || - index.column() < 0 || index.column() >= m_columns.count() ) - { - return QVariant(); - } - - qint64 field = m_columns.at( index.column() ); - const TrackPtr &track = m_tracks.at( index.row() ); - return trackData( track, field, role ); -} - -Qt::ItemFlags -SingleTracksModel::flags( const QModelIndex &index ) const -{ - return QAbstractItemModel::flags( index ) | Qt::ItemIsDragEnabled; -} - -QStringList -SingleTracksModel::mimeTypes() const -{ - return QStringList() << AmarokMimeData::TRACK_MIME << "text/uri-list" << "text/plain"; -} - -QMimeData * -SingleTracksModel::mimeData( const QModelIndexList &indexes ) const -{ - Meta::TrackList tracks; - foreach( const QModelIndex &idx, indexes ) - { - if( idx.isValid() && idx.row() >= 0 && idx.row() < m_tracks.count() && - idx.column() == 0 ) - { - Meta::TrackPtr metaTrack = m_tracks.at( idx.row() )->metaTrack(); - if( metaTrack ) - tracks << metaTrack; - } - } - if( tracks.isEmpty() ) - return 0; - - AmarokMimeData *mime = new AmarokMimeData(); - mime->setTracks( tracks ); - return mime; -} diff --git a/amarok/src/statsyncing/models/SingleTracksModel.h b/amarok/src/statsyncing/models/SingleTracksModel.h deleted file mode 100644 index 99fcf44c..00000000 --- a/amarok/src/statsyncing/models/SingleTracksModel.h +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef STATSYNCING_SINGLETRACKSMODEL_H -#define STATSYNCING_SINGLETRACKSMODEL_H - -#include "statsyncing/Track.h" -#include "statsyncing/models/CommonModel.h" - -#include - -namespace StatSyncing -{ - /** - * Model that provides data about single tracks that for some radon didn't end up - * in synchronization. - */ - class SingleTracksModel : public QAbstractTableModel, protected CommonModel - { - Q_OBJECT - - public: - /** - * Construct model of single tracks. - * - * @param matchedTuples list of tracks - * @param columns list of Meta::val* fields that will form columns of the model - * must include Meta::valTitle, may include: valRating, - * valFirstPlayed, valLastPlayed, valPlaycount, valLabel. - */ - SingleTracksModel( const TrackList &tracks, const QList &columns, - const Options &options, QObject *parent = 0 ); - - int rowCount( const QModelIndex &parent = QModelIndex() ) const; - int columnCount( const QModelIndex &parent = QModelIndex() ) const; - - QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const; - - QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const; - Qt::ItemFlags flags( const QModelIndex &index ) const; - - QStringList mimeTypes() const; - QMimeData *mimeData( const QModelIndexList &indexes ) const; - - private: - TrackList m_tracks; - }; - -} // namespace StatSyncing - -#endif // STATSYNCING_SINGLETRACKSMODEL_H diff --git a/amarok/src/statsyncing/ui/ChooseProvidersPage.cpp b/amarok/src/statsyncing/ui/ChooseProvidersPage.cpp deleted file mode 100644 index 3862cc42..00000000 --- a/amarok/src/statsyncing/ui/ChooseProvidersPage.cpp +++ /dev/null @@ -1,184 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "ChooseProvidersPage.h" - -#include "App.h" -#include "core/meta/support/MetaConstants.h" -#include "statsyncing/models/ProvidersModel.h" - -#include - -#include - -using namespace StatSyncing; - -ChooseProvidersPage::ChooseProvidersPage( QWidget *parent, Qt::WindowFlags f ) - : QWidget( parent, f ) - , m_providersModel( 0 ) -{ - setupUi( this ); - KGuiItem configure = KStandardGuiItem::configure(); - configure.setText( i18n( "Configure Synchronization..." ) ); - buttonBox->addButton( configure, QDialogButtonBox::ActionRole, this, SLOT(openConfiguration()) ); - buttonBox->addButton( KGuiItem( i18n( "Next" ), "go-next" ), QDialogButtonBox::AcceptRole ); - connect( buttonBox, SIGNAL(accepted()), SIGNAL(accepted()) ); - connect( buttonBox, SIGNAL(rejected()), SIGNAL(rejected()) ); - progressBar->hide(); -} - -ChooseProvidersPage::~ChooseProvidersPage() -{ -} - -void -ChooseProvidersPage::setFields( const QList &fields, qint64 checkedFields ) -{ - QLayout *fieldsLayout = fieldsBox->layout(); - foreach( qint64 field, fields ) - { - QString name = Meta::i18nForField( field ); - QCheckBox *checkBox = new QCheckBox( name ); - fieldsLayout->addWidget( checkBox ); - checkBox->setCheckState( ( field & checkedFields ) ? Qt::Checked : Qt::Unchecked ); - checkBox->setProperty( "field", field ); - connect( checkBox, SIGNAL(stateChanged(int)), SIGNAL(checkedFieldsChanged()) ); - } - fieldsLayout->addItem( new QSpacerItem( 0, 0, QSizePolicy::Expanding ) ); - - connect( this, SIGNAL(checkedFieldsChanged()), SLOT(updateEnabledFields()) ); - updateEnabledFields(); -} - -qint64 -ChooseProvidersPage::checkedFields() const -{ - qint64 ret = 0; - QLayout *fieldsLayout = fieldsBox->layout(); - for( int i = 0; i < fieldsLayout->count(); i++ ) - { - QCheckBox *checkBox = qobject_cast( fieldsLayout->itemAt( i )->widget() ); - if( !checkBox ) - continue; - if( checkBox->isChecked() && checkBox->property( "field" ).canConvert() ) - ret |= checkBox->property( "field" ).value(); - } - return ret; -} - -void -ChooseProvidersPage::setProvidersModel( ProvidersModel *model, QItemSelectionModel *selectionModel ) -{ - m_providersModel = model; - providersView->setModel( model ); - providersView->setSelectionModel( selectionModel ); - - connect( model, SIGNAL(selectedProvidersChanged()), SLOT(updateMatchedLabel()) ); - connect( model, SIGNAL(selectedProvidersChanged()), SLOT(updateEnabledFields()) ); - updateMatchedLabel(); - updateEnabledFields(); -} - -void -ChooseProvidersPage::disableControls() -{ - // disable checkboxes - QLayout *fieldsLayout = fieldsBox->layout(); - for( int i = 0; i < fieldsLayout->count(); i++ ) - { - QWidget *widget = fieldsLayout->itemAt( i )->widget(); - if( widget ) - widget->setEnabled( false ); - } - - // disable view - providersView->setEnabled( false ); - - // disable all but Cancel button - foreach( QAbstractButton *button, buttonBox->buttons() ) - { - if( buttonBox->buttonRole( button ) != QDialogButtonBox::RejectRole ) - button->setEnabled( false ); - } -} - -void -ChooseProvidersPage::setProgressBarText( const QString &text ) -{ - progressBar->setFormat( text ); - progressBar->show(); -} - -void -ChooseProvidersPage::setProgressBarMaximum( int maximum ) -{ - progressBar->setMaximum( maximum ); - progressBar->show(); -} - -void -ChooseProvidersPage::progressBarIncrementProgress() -{ - progressBar->setValue( progressBar->value() + 1 ); - progressBar->show(); -} - -void -ChooseProvidersPage::updateMatchedLabel() -{ - qint64 fields = m_providersModel->reliableTrackMetadataIntersection(); - QString fieldNames = m_providersModel->fieldsToString( fields ); - matchLabel->setText( i18n( "Tracks matched by: %1", fieldNames ) ); -} - -void -ChooseProvidersPage::updateEnabledFields() -{ - if( !m_providersModel ) - return; - - qint64 writableFields = m_providersModel->writableTrackStatsDataUnion(); - QLayout *fieldsLayout = fieldsBox->layout(); - for( int i = 0; i < fieldsLayout->count(); i++ ) - { - QWidget *checkBox = fieldsLayout->itemAt( i )->widget(); - if( !checkBox || !checkBox->property( "field" ).canConvert() ) - continue; - qint64 field = checkBox->property( "field" ).value(); - bool enabled = writableFields & field; - checkBox->setEnabled( enabled ); - QString text = i18nc( "%1 is field name such as Rating", "No selected collection " - "supports writing %1 - it doesn't make sense to synchronize it.", - Meta::i18nForField( field ) ); - checkBox->setToolTip( enabled ? QString() : text ); - } - - QAbstractButton *nextButton = 0; - foreach( QAbstractButton *button, buttonBox->buttons() ) - { - if( buttonBox->buttonRole( button ) == QDialogButtonBox::AcceptRole ) - nextButton = button; - } - if( nextButton ) - nextButton->setEnabled( writableFields != 0 ); -} - -void ChooseProvidersPage::openConfiguration() -{ - App *app = App::instance(); - if( app ) - app->slotConfigAmarok( "MetadataConfig" ); -} diff --git a/amarok/src/statsyncing/ui/ChooseProvidersPage.h b/amarok/src/statsyncing/ui/ChooseProvidersPage.h deleted file mode 100644 index 99b7216d..00000000 --- a/amarok/src/statsyncing/ui/ChooseProvidersPage.h +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef STATSYNCING_CHOOSEPROVIDERSPAGE_H -#define STATSYNCING_CHOOSEPROVIDERSPAGE_H - -#include "ui_ChooseProvidersPage.h" - -namespace StatSyncing -{ - class ProvidersModel; - - class ChooseProvidersPage : public QWidget, private Ui::ChooseProvidersPage - { - Q_OBJECT - - public: - explicit ChooseProvidersPage( QWidget *parent = 0, Qt::WindowFlags f = 0 ); - virtual ~ChooseProvidersPage(); - - void setFields( const QList &fields, qint64 checkedFields ); - qint64 checkedFields() const; - - /** - * Sets the model of providers to choose from. ChooseProvidersPage does _not_ - * take ownership of the model or the selection model. - */ - void setProvidersModel( ProvidersModel *model, QItemSelectionModel *selectionModel ); - - public slots: - void disableControls(); - void setProgressBarText( const QString &text ); - void setProgressBarMaximum( int maximum ); - void progressBarIncrementProgress(); - - signals: - void checkedFieldsChanged(); - - /** - * Emitted when user clicks the Next button. - */ - void accepted(); - - /** - * Emitted when user pushes the Cancel button. - */ - void rejected(); - - private slots: - void updateMatchedLabel(); - void updateEnabledFields(); - void openConfiguration(); - - private: - ProvidersModel *m_providersModel; - }; -} // namespace StatSyncing - -#endif // STATSYNCING_CHOOSEPROVIDERSPAGE_H diff --git a/amarok/src/statsyncing/ui/ChooseProvidersPage.ui b/amarok/src/statsyncing/ui/ChooseProvidersPage.ui deleted file mode 100644 index f3e57819..00000000 --- a/amarok/src/statsyncing/ui/ChooseProvidersPage.ui +++ /dev/null @@ -1,79 +0,0 @@ - - - ChooseProvidersPage - - - - 0 - 0 - 640 - 440 - - - - - - - Select Collections to Synchronize - - - - - - QAbstractItemView::MultiSelection - - - - 32 - 32 - - - - - - - - Tracks matched by: <placeholder> - - - true - - - - - - - - - - Select Fields to Synchronize - - - - - - - - - - - - - - - QDialogButtonBox::Cancel - - - - - - - - KDialogButtonBox - QDialogButtonBox -

    kdialogbuttonbox.h
    - - - - - diff --git a/amarok/src/statsyncing/ui/ConfigureProviderDialog.cpp b/amarok/src/statsyncing/ui/ConfigureProviderDialog.cpp deleted file mode 100644 index 6cedd8a8..00000000 --- a/amarok/src/statsyncing/ui/ConfigureProviderDialog.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2013 Konrad Zemek * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "ConfigureProviderDialog.h" - -#include "statsyncing/Provider.h" - -#include - -#include -#include -#include - -namespace StatSyncing -{ - -ConfigureProviderDialog::ConfigureProviderDialog( const QString &providerId, - QWidget *configWidget, QWidget *parent, - Qt::WindowFlags f ) - : KDialog( parent, f ) - , m_providerId( providerId ) -{ - setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Fixed ); - setWindowTitle( i18n( "Configure Synchronization Target" ) ); - setModal( true ); - showButton( KDialog::Help, false ); - - setMainWidget( configWidget ); - - connect( this, SIGNAL(accepted()), SLOT(slotAccepted()) ); -} - -ConfigureProviderDialog::~ConfigureProviderDialog() -{ -} - -void -ConfigureProviderDialog::slotAccepted() -{ - const ProviderConfigWidget *configWidget = - qobject_cast( mainWidget() ); - - emit providerConfigured( m_providerId, configWidget->config() ); -} - -} // namespace StatSyncing diff --git a/amarok/src/statsyncing/ui/ConfigureProviderDialog.h b/amarok/src/statsyncing/ui/ConfigureProviderDialog.h deleted file mode 100644 index 51fd8653..00000000 --- a/amarok/src/statsyncing/ui/ConfigureProviderDialog.h +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2013 Konrad Zemek * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef STATSYNCING_CONFIGURE_PROVIDER_DIALOG_H -#define STATSYNCING_CONFIGURE_PROVIDER_DIALOG_H - -#include - -#include -#include -#include -#include - -#include - -namespace StatSyncing -{ - - class ProviderConfigWidget; - - class ConfigureProviderDialog : public KDialog - { - Q_OBJECT - - public: - explicit ConfigureProviderDialog( const QString &providerId, QWidget *configWidget, - QWidget *parent = 0, Qt::WindowFlags f = 0 ); - virtual ~ConfigureProviderDialog(); - - signals: - void providerConfigured( QString id, QVariantMap config ); - - private: - QString m_providerId; - - private slots: - void slotAccepted(); - }; - -} // namespace StatSyncing - -#endif // STATSYNCING_CONFIGURE_PROVIDER_DIALOG_H diff --git a/amarok/src/statsyncing/ui/CreateProviderDialog.cpp b/amarok/src/statsyncing/ui/CreateProviderDialog.cpp deleted file mode 100644 index 800a847d..00000000 --- a/amarok/src/statsyncing/ui/CreateProviderDialog.cpp +++ /dev/null @@ -1,134 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2013 Konrad Zemek * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "CreateProviderDialog.h" - -#include "statsyncing/Controller.h" -#include "statsyncing/Provider.h" -#include "core/support/Components.h" - -#include - -#include -#include -#include - -namespace StatSyncing -{ - -CreateProviderDialog::CreateProviderDialog( QWidget *parent, Qt::WindowFlags f ) - : KAssistantDialog( parent, f ) -{ - setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Minimum ); - setWindowTitle( i18n( "Add Synchronization Target" ) ); - setModal( true ); - showButton( KDialog::Help, false ); - - m_providerButtons.setExclusive( true ); - m_layout = new QVBoxLayout; - - QWidget *providerTypeWidget = new QWidget; - QVBoxLayout *mainLayout = new QVBoxLayout; - - QLabel *warning = new QLabel( i18n( "" - "Important: before synchronizing tracks with a " - "file-based target always make sure that " - "the database file is not currently in use!" ) ); - warning->setWordWrap( true ); - mainLayout->addLayout( m_layout ); - mainLayout->addSpacing( 10 ); - mainLayout->addStretch(); - mainLayout->addWidget( warning ); - - providerTypeWidget->setLayout( mainLayout ); - - m_providerTypePage = new KPageWidgetItem( providerTypeWidget, - i18n( "Choose Target Type" ) ); - providerTypeWidget->hide(); - addPage( m_providerTypePage ); - - connect( this, SIGNAL(accepted()), SLOT(slotAccepted()) ); -} - -CreateProviderDialog::~CreateProviderDialog() -{ -} - -void -CreateProviderDialog::addProviderType( const QString &id, const QString &prettyName, - const KIcon &icon, - ProviderConfigWidget *configWidget ) -{ - QRadioButton *providerTypeButton = new QRadioButton; - providerTypeButton->setText( prettyName ); - providerTypeButton->setIcon( icon ); - - m_providerButtons.addButton( providerTypeButton ); - m_idForButton.insert( providerTypeButton, id ); - - m_layout->insertWidget( buttonInsertPosition( prettyName ), providerTypeButton ); - - KPageWidgetItem *configPage = - new KPageWidgetItem( configWidget, i18n( "Configure Target" ) ); - m_configForButton.insert( providerTypeButton, configPage ); - addPage( configPage ); - setAppropriate( configPage, false ); - - connect( providerTypeButton, SIGNAL(toggled(bool)), - SLOT(providerButtonToggled(bool)) ); - - if( !m_providerButtons.checkedButton() ) - providerTypeButton->setChecked( true ); -} - -int -CreateProviderDialog::buttonInsertPosition( const QString &prettyName ) -{ - for( int i = 0; i < m_layout->count(); ++i ) - { - const QRadioButton * const button = - dynamic_cast( m_layout->itemAt( i )->widget() ); - - if( button != 0 && prettyName.localeAwareCompare( button->text() ) <= 0 ) - return i; - } - - // Nothing found, place the button at the end - return -1; -} - -void -CreateProviderDialog::providerButtonToggled( bool checked ) -{ - KPageWidgetItem *configPage = m_configForButton[sender()]; - setAppropriate( configPage, checked ); -} - -void -CreateProviderDialog::slotAccepted() -{ - QAbstractButton *checkedButton = m_providerButtons.checkedButton(); - if( !checkedButton ) return; - - const QString id = m_idForButton[checkedButton]; - KPageWidgetItem *configPage = m_configForButton[checkedButton]; - const ProviderConfigWidget *configWidget = - qobject_cast( configPage->widget() ); - - emit providerConfigured( id, configWidget->config() ); -} - -} // namespace StatSyncing diff --git a/amarok/src/statsyncing/ui/CreateProviderDialog.h b/amarok/src/statsyncing/ui/CreateProviderDialog.h deleted file mode 100644 index ec709581..00000000 --- a/amarok/src/statsyncing/ui/CreateProviderDialog.h +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2013 Konrad Zemek * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef STATSYNCING_CREATE_PROVIDER_DIALOG_H -#define STATSYNCING_CREATE_PROVIDER_DIALOG_H - -#include - -#include -#include -#include -#include - -#include - -class QVBoxLayout; - -namespace StatSyncing -{ - - class ProviderConfigWidget; - - class CreateProviderDialog : public KAssistantDialog - { - Q_OBJECT - - public: - explicit CreateProviderDialog( QWidget *parent = 0, Qt::WindowFlags f = 0 ); - virtual ~CreateProviderDialog(); - - public slots: - void addProviderType( const QString &id, const QString &prettyName, const KIcon &icon, - ProviderConfigWidget *configWidget ); - - signals: - void providerConfigured( const QString &id, const QVariantMap &config ); - - private: - int buttonInsertPosition( const QString &prettyName ); - - QButtonGroup m_providerButtons; - QMap m_idForButton; - QMap m_configForButton; - KPageWidgetItem *m_providerTypePage; - QVBoxLayout *m_layout; - - private slots: - void providerButtonToggled( bool checked ); - void slotAccepted(); - }; - -} // namespace StatSyncing - -#endif // STATSYNCING_CREATE_PROVIDER_DIALOG_H diff --git a/amarok/src/statsyncing/ui/MatchedTracksPage.cpp b/amarok/src/statsyncing/ui/MatchedTracksPage.cpp deleted file mode 100644 index c6bf4cd5..00000000 --- a/amarok/src/statsyncing/ui/MatchedTracksPage.cpp +++ /dev/null @@ -1,528 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "MatchedTracksPage.h" - -#include "App.h" -#include "core/meta/support/MetaConstants.h" -#include "core/support/Debug.h" -#include "statsyncing/TrackTuple.h" -#include "statsyncing/models/MatchedTracksModel.h" -#include "statsyncing/ui/TrackDelegate.h" - -#include -#include - -#include -#include -#include -#include - -// needed for QCombobox payloads: -Q_DECLARE_METATYPE( StatSyncing::ProviderPtr ) - -namespace StatSyncing -{ - class SortFilterProxyModel : public QSortFilterProxyModel - { - public: - SortFilterProxyModel( QObject *parent = 0 ) - : QSortFilterProxyModel( parent ) - , m_tupleFilter( -1 ) - { - // filer all columns, accept when at least one column matches: - setFilterKeyColumn( -1 ); - } - - /** - * Filter tuples based on their MatchedTracksModel::TupleFlag flag. Set to -1 - * to accept tuples with any flags. - */ - void setTupleFilter( int filter ) - { - m_tupleFilter = filter; - invalidateFilter(); - sort( sortColumn(), sortOrder() ); // this doesn't happen automatically - } - - protected: - bool filterAcceptsRow( int source_row, const QModelIndex &source_parent ) const - { - if( source_parent.isValid() ) - return true; // we match all child items, we filter only root ones - if( m_tupleFilter != -1 ) - { - QModelIndex index = sourceModel()->index( source_row, 0, source_parent ); - int flags = sourceModel()->data( index, MatchedTracksModel::TupleFlagsRole ).toInt(); - if( !(flags & m_tupleFilter) ) - return false; - } - return QSortFilterProxyModel::filterAcceptsRow( source_row, source_parent ); - } - - bool lessThan( const QModelIndex &left, const QModelIndex &right ) const - { - if( left.parent().isValid() ) // we are comparing childs, special mode: - { - // take providers, e.g. reset column to 0 - QModelIndex l = sourceModel()->index( left.row(), 0, left.parent() ); - QModelIndex r = sourceModel()->index( right.row(), 0, right.parent() ); - QString leftProvider = sourceModel()->data( l, Qt::DisplayRole ).toString(); - QString rightProvider = sourceModel()->data( r, Qt::DisplayRole ).toString(); - - // make this sorting ignore the sort order, always sort acsendingly: - if( sortOrder() == Qt::AscendingOrder ) - return leftProvider.localeAwareCompare( rightProvider ) < 0; - else - return leftProvider.localeAwareCompare( rightProvider ) > 0; - } - return QSortFilterProxyModel::lessThan( left, right ); - } - - private: - int m_tupleFilter; - }; -} - -using namespace StatSyncing; - -MatchedTracksPage::MatchedTracksPage( QWidget *parent, Qt::WindowFlags f ) - : QWidget( parent, f ) - , m_matchedTracksModel( 0 ) -{ - setupUi( this ); - // this group box is only shown upon setTracksToScrobble() call - scrobblingGroupBox->hide(); - - m_matchedProxyModel = new SortFilterProxyModel( this ); - m_uniqueProxyModel = new QSortFilterProxyModel( this ); - m_excludedProxyModel = new QSortFilterProxyModel( this ); - -#define SETUP_MODEL( proxyModel, name, Name ) \ - proxyModel->setSortLocaleAware( true ); \ - proxyModel->setSortCaseSensitivity( Qt::CaseInsensitive ); \ - proxyModel->setFilterCaseSensitivity( Qt::CaseInsensitive ); \ - connect( proxyModel, SIGNAL(modelReset()), SLOT(refresh##Name##StatusText()) ); \ - connect( proxyModel, SIGNAL(rowsInserted(QModelIndex,int,int)), SLOT(refresh##Name##StatusText()) ); \ - connect( proxyModel, SIGNAL(rowsRemoved(QModelIndex,int,int)), SLOT(refresh##Name##StatusText()) ); \ - name##TreeView->setModel( m_##name##ProxyModel ); \ - name##TreeView->setItemDelegate( new TrackDelegate( name##TreeView ) ); \ - connect( name##FilterLine, SIGNAL(textChanged(QString)), proxyModel, SLOT(setFilterFixedString(QString)) ); \ - name##TreeView->header()->setStretchLastSection( false ); \ - name##TreeView->header()->setDefaultSectionSize( 80 ); - - SETUP_MODEL( m_matchedProxyModel, matched, Matched ) - SETUP_MODEL( m_uniqueProxyModel, unique, Unique ) - SETUP_MODEL( m_excludedProxyModel, excluded, Excluded ) -#undef SETUP_MODEL - - connect( uniqueFilterCombo, SIGNAL(currentIndexChanged(int)), - SLOT(changeUniqueTracksProvider(int)) ); - connect( excludedFilterCombo, SIGNAL(currentIndexChanged(int)), - SLOT(changeExcludedTracksProvider(int)) ); - - KGuiItem configure = KStandardGuiItem::configure(); - configure.setText( i18n( "Configure Synchronization..." ) ); - buttonBox->addButton( configure, QDialogButtonBox::ActionRole, this, SLOT(openConfiguration()) ); - KPushButton *back = buttonBox->addButton( KStandardGuiItem::back(), - QDialogButtonBox::ActionRole ); - buttonBox->addButton( KGuiItem( i18n( "Synchronize" ), "document-save" ), - QDialogButtonBox::AcceptRole ); - connect( back, SIGNAL(clicked(bool)), SIGNAL(back()) ); - connect( buttonBox, SIGNAL(accepted()), SIGNAL(accepted()) ); - connect( buttonBox, SIGNAL(rejected()), SIGNAL(rejected()) ); - - tabWidget->setTabEnabled( 1, false );; - tabWidget->setTabToolTip( 1, i18n( "There are no tracks unique to one of the sources " - "participating in the synchronization" ) ); - tabWidget->setTabEnabled( 2, false ); - tabWidget->setTabToolTip( 2, i18n( "There are no tracks excluded from " - "synchronization" ) ); - - QMenu *menu = new QMenu( matchedExpandButton ); - menu->addAction( i18n( "Expand Tracks With Conflicts" ), this, SLOT(expand()) )->setData( - MatchedTracksModel::HasConflict ); - menu->addAction( i18n( "Expand Updated" ), this, SLOT(expand()) )->setData( - MatchedTracksModel::HasUpdate ); - menu->addAction( i18n( "Expand All" ), this, SLOT(expand()) )->setData( 0 ); - matchedExpandButton->setMenu( menu ); - - menu = new QMenu( matchedCollapseButton ); - menu->addAction( i18n( "Collapse Tracks Without Conflicts" ), this, SLOT(collapse()) )->setData( - MatchedTracksModel::HasConflict ); - menu->addAction( i18n( "Collapse Not Updated" ), this, SLOT(collapse()) )->setData( - MatchedTracksModel::HasUpdate ); - menu->addAction( i18n( "Collapse All" ), this, SLOT(collapse()) )->setData( 0 ); - matchedCollapseButton->setMenu( menu ); -} - -MatchedTracksPage::~MatchedTracksPage() -{ -} - -void -MatchedTracksPage::setProviders( const ProviderPtrList &providers ) -{ - // populate menu of the "Take Ratings From" button - QMenu *takeRatingsMenu = new QMenu( matchedRatingsButton ); - foreach( const ProviderPtr &provider, providers ) - { - QAction *action = takeRatingsMenu->addAction( provider->icon(), provider->prettyName(), - this, SLOT(takeRatingsFrom()) ); - action->setData( QVariant::fromValue( provider ) ); - } - takeRatingsMenu->addAction( i18n( "Reset All Ratings to Undecided" ), this, SLOT(takeRatingsFrom()) ); - matchedRatingsButton->setMenu( takeRatingsMenu ); - matchedRatingsButton->setIcon( KIcon( Meta::iconForField( Meta::valRating ) ) ); - - // populate menu of the "Labels" button - QMenu *labelsMenu = new QMenu( matchedLabelsButton ); - foreach( const ProviderPtr &provider, providers ) - { - QString text = i18nc( "%1 is collection name", "Include Labels from %1", provider->prettyName() ); - QAction *action = labelsMenu->addAction( provider->icon(), text, this, SLOT(includeLabelsFrom()) ); - action->setData( QVariant::fromValue( provider ) ); - - text = i18nc( "%1 is collection name", "Exclude Labels from %1", provider->prettyName() ); - action = labelsMenu->addAction( provider->icon(), text, this, SLOT(excludeLabelsFrom()) ); - action->setData( QVariant::fromValue( provider ) ); - } - labelsMenu->addAction( i18n( "Reset All Labels to Undecided (Don't Synchronize Them)" ), - this, SLOT(excludeLabelsFrom()) ); - matchedLabelsButton->setMenu( labelsMenu ); - matchedLabelsButton->setIcon( KIcon( Meta::iconForField( Meta::valLabel ) ) ); -} - -void -MatchedTracksPage::setMatchedTracksModel( MatchedTracksModel *model ) -{ - m_matchedTracksModel = model; - Q_ASSERT( m_matchedTracksModel ); - m_matchedProxyModel->setSourceModel( m_matchedTracksModel ); - - setHeaderSizePoliciesFromModel( matchedTreeView->header(), m_matchedTracksModel ); - m_matchedProxyModel->sort( 0, Qt::AscendingOrder ); - // initially, expand tuples with conflicts: - expand( MatchedTracksModel::HasConflict ); - - connect( m_matchedProxyModel, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)), - SLOT(rememberExpandedState(QModelIndex,int,int)) ); - connect( m_matchedProxyModel, SIGNAL(rowsInserted(QModelIndex,int,int)), - SLOT(restoreExpandedState(QModelIndex,int,int)) ); - - // re-fill combo box and disable choices without tracks - bool hasConflict = m_matchedTracksModel->hasConflict(); - matchedFilterCombo->clear(); - matchedFilterCombo->addItem( i18n( "All Tracks" ), -1 ); - matchedFilterCombo->addItem( i18n( "Updated Tracks" ), int( MatchedTracksModel::HasUpdate ) ); - matchedFilterCombo->addItem( i18n( "Tracks With Conflicts" ), int( MatchedTracksModel::HasConflict ) ); - QStandardItemModel *comboModel = dynamic_cast( matchedFilterCombo->model() ); - int bestIndex = 0; - if( comboModel ) - { - bestIndex = 2; - if( !hasConflict ) - { - comboModel->item( 2 )->setFlags( Qt::NoItemFlags ); - matchedFilterCombo->setItemData( 2, i18n( "There are no tracks with conflicts" ), - Qt::ToolTipRole ); - bestIndex = 1; - if( !m_matchedTracksModel->hasUpdate() ) - { - comboModel->item( 1 )->setFlags( Qt::NoItemFlags ); - matchedFilterCombo->setItemData( 1, i18n( "There are no tracks going to be " - "updated" ), Qt::ToolTipRole ); - bestIndex = 0; // no other possibility - } - } - } - - matchedFilterCombo->setCurrentIndex( bestIndex ); - changeMatchedTracksFilter( bestIndex ); - connect( matchedFilterCombo, SIGNAL(currentIndexChanged(int)), SLOT(changeMatchedTracksFilter(int)) ); - - matchedRatingsButton->setEnabled( hasConflict ); - matchedLabelsButton->setEnabled( hasConflict ); -} - -void -MatchedTracksPage::addUniqueTracksModel( ProviderPtr provider, QAbstractItemModel *model ) -{ - bool first = m_uniqueTracksModels.isEmpty(); - m_uniqueTracksModels.insert( provider, model ); - uniqueFilterCombo->addItem( provider->icon(), provider->prettyName(), - QVariant::fromValue( provider ) ); - - if( first ) - { - tabWidget->setTabEnabled( 1, true ); - tabWidget->setTabToolTip( 1, i18n( "Tracks that are unique to their sources" ) ); - setHeaderSizePoliciesFromModel( uniqueTreeView->header(), model ); - uniqueFilterCombo->setCurrentIndex( 0 ); - m_uniqueProxyModel->sort( 0, Qt::AscendingOrder ); - } -} - -void -MatchedTracksPage::addExcludedTracksModel( ProviderPtr provider, QAbstractItemModel *model ) -{ - bool first = m_excludedTracksModels.isEmpty(); - m_excludedTracksModels.insert( provider, model ); - excludedFilterCombo->addItem( provider->icon(), provider->prettyName(), - QVariant::fromValue( provider ) ); - - if( first ) - { - tabWidget->setTabEnabled( 2, true ); - tabWidget->setTabToolTip( 2, i18n( "Tracks that have been excluded from " - "synchronization due to ambiguity" ) ); - setHeaderSizePoliciesFromModel( excludedTreeView->header(), model ); - excludedFilterCombo->setCurrentIndex( 0 ); - m_excludedProxyModel->sort( 0, Qt::AscendingOrder ); - } -} - -void -MatchedTracksPage::setTracksToScrobble( const TrackList &tracksToScrobble, - const QList &services ) -{ - int tracks = tracksToScrobble.count(); - int plays = 0; - foreach( const TrackPtr &track, tracksToScrobble ) - { - plays += track->recentPlayCount(); - } - QStringList serviceNames; - foreach( const ScrobblingServicePtr &service, services ) - { - serviceNames << "" + service->prettyName() + ""; - } - - if( plays ) - { - QString playsText = i18np( "One play", "%1 plays", plays ); - QString text = i18ncp( "%2 is the 'X plays message above'", - "%2 of one track will be scrobbled to %3.", - "%2 of %1 tracks will be scrobbled to %3.", tracks, playsText, - serviceNames.join( i18nc( "comma between list words", ", " ) ) ); - scrobblingLabel->setText( text ); - scrobblingGroupBox->show(); - } - else - scrobblingGroupBox->hide(); -} - -void -MatchedTracksPage::changeMatchedTracksFilter( int index ) -{ - int filter = matchedFilterCombo->itemData( index ).toInt(); - m_matchedProxyModel->setTupleFilter( filter ); -} - -void -MatchedTracksPage::changeUniqueTracksProvider( int index ) -{ - ProviderPtr provider = uniqueFilterCombo->itemData( index ).value(); - m_uniqueProxyModel->setSourceModel( m_uniqueTracksModels.value( provider ) ); - // trigger re-sort, Qt doesn't do that automatically apparently - m_uniqueProxyModel->sort( m_uniqueProxyModel->sortColumn(), m_uniqueProxyModel->sortOrder() ); -} - -void -MatchedTracksPage::changeExcludedTracksProvider( int index ) -{ - ProviderPtr provider = excludedFilterCombo->itemData( index ).value(); - m_excludedProxyModel->setSourceModel( m_excludedTracksModels.value( provider ) ); - // trigger re-sort, Qt doesn't do that automatically apparently - m_excludedProxyModel->sort( m_excludedProxyModel->sortColumn(), m_excludedProxyModel->sortOrder() ); -} - -void -MatchedTracksPage::refreshMatchedStatusText() -{ - refreshStatusTextHelper( m_matchedProxyModel, matchedStatusBar ); -} - -void -MatchedTracksPage::refreshUniqueStatusText() -{ - refreshStatusTextHelper( m_uniqueProxyModel, uniqueStatusBar ); -} - -void -MatchedTracksPage::refreshExcludedStatusText() -{ - refreshStatusTextHelper( m_excludedProxyModel, excludedStatusBar ); -} - -void -MatchedTracksPage::refreshStatusTextHelper( QSortFilterProxyModel *topModel , QLabel *label ) -{ - int bottomModelRows = topModel->sourceModel() ? - topModel->sourceModel()->rowCount() : 0; - int topModelRows = topModel->rowCount(); - - QString bottomText = i18np( "%1 track", "%1 tracks", bottomModelRows ); - if( topModelRows == bottomModelRows ) - label->setText( bottomText ); - else - { - QString text = i18nc( "%2 is the above '%1 track(s)' message", "Showing %1 out " - "of %2", topModelRows, bottomText ); - label->setText( text ); - } -} - -void -MatchedTracksPage::rememberExpandedState( const QModelIndex &parent, int start, int end ) -{ - if( parent.isValid() ) - return; - for( int topModelRow = start; topModelRow <= end; topModelRow++ ) - { - QModelIndex topModelIndex = m_matchedProxyModel->index( topModelRow, 0 ); - int bottomModelRow = m_matchedProxyModel->mapToSource( topModelIndex ).row(); - if( matchedTreeView->isExpanded( topModelIndex ) ) - m_expandedTuples.insert( bottomModelRow ); - else - m_expandedTuples.remove( bottomModelRow ); - } -} - -void -MatchedTracksPage::restoreExpandedState( const QModelIndex &parent, int start, int end ) -{ - if( parent.isValid() ) - return; - for( int topModelRow = start; topModelRow <= end; topModelRow++ ) - { - QModelIndex topIndex = m_matchedProxyModel->index( topModelRow, 0 ); - int bottomModelRow = m_matchedProxyModel->mapToSource( topIndex ).row(); - if( m_expandedTuples.contains( bottomModelRow ) ) - matchedTreeView->expand( topIndex ); - } -} - -void -MatchedTracksPage::takeRatingsFrom() -{ - QAction *action = qobject_cast( sender() ); - if( !action ) - { - warning() << __PRETTY_FUNCTION__ << "must only be called from QAction"; - return; - } - - // provider may be null, it means "reset all ratings to undecided" - ProviderPtr provider = action->data().value(); - m_matchedTracksModel->takeRatingsFrom( provider ); -} - -void -MatchedTracksPage::includeLabelsFrom() -{ - QAction *action = qobject_cast( sender() ); - if( !action ) - { - warning() << __PRETTY_FUNCTION__ << "must only be called from QAction"; - return; - } - - ProviderPtr provider = action->data().value(); - if( provider ) // no sense with null provider - m_matchedTracksModel->includeLabelsFrom( provider ); -} - -void -MatchedTracksPage::excludeLabelsFrom() -{ - QAction *action = qobject_cast( sender() ); - if( !action ) - { - warning() << __PRETTY_FUNCTION__ << "must only be called from QAction"; - return; - } - - // provider may be null, it means "reset all labels to undecided" - ProviderPtr provider = action->data().value(); - m_matchedTracksModel->excludeLabelsFrom( provider ); -} - -void -MatchedTracksPage::expand( int onlyWithTupleFlags ) -{ - if( onlyWithTupleFlags < 0 ) - { - QAction *action = qobject_cast( sender() ); - if( action ) - onlyWithTupleFlags = action->data().toInt(); - else - onlyWithTupleFlags = 0; - } - - for( int i = 0; i < m_matchedProxyModel->rowCount(); i++ ) - { - QModelIndex idx = m_matchedProxyModel->index( i, 0 ); - if( matchedTreeView->isExpanded( idx ) ) - continue; - - int flags = idx.data( MatchedTracksModel::TupleFlagsRole ).toInt(); - if( ( flags & onlyWithTupleFlags ) == onlyWithTupleFlags ) - matchedTreeView->expand( idx ); - } -} - -void -MatchedTracksPage::collapse() -{ - int excludingFlags; - QAction *action = qobject_cast( sender() ); - if( action ) - excludingFlags = action->data().toInt(); - else - excludingFlags = 0; - - for( int i = 0; i < m_matchedProxyModel->rowCount(); i++ ) - { - QModelIndex idx = m_matchedProxyModel->index( i, 0 ); - if( !matchedTreeView->isExpanded( idx ) ) - continue; - - int flags = idx.data( MatchedTracksModel::TupleFlagsRole ).toInt(); - if( ( flags & excludingFlags ) == 0 ) - matchedTreeView->collapse( idx ); - } -} - -void -MatchedTracksPage::openConfiguration() -{ - App *app = App::instance(); - if( app ) - app->slotConfigAmarok( "MetadataConfig" ); -} - -void -MatchedTracksPage::setHeaderSizePoliciesFromModel( QHeaderView *header, QAbstractItemModel *model ) -{ - for( int column = 0; column < model->columnCount(); column++ ) - { - QVariant headerData = model->headerData( column, Qt::Horizontal, - CommonModel::ResizeModeRole ); - QHeaderView::ResizeMode mode = QHeaderView::ResizeMode( headerData.toInt() ); - header->setResizeMode( column, mode ); - } -} diff --git a/amarok/src/statsyncing/ui/MatchedTracksPage.h b/amarok/src/statsyncing/ui/MatchedTracksPage.h deleted file mode 100644 index e217a43c..00000000 --- a/amarok/src/statsyncing/ui/MatchedTracksPage.h +++ /dev/null @@ -1,121 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef STATSYNCING_MATCHEDTRACKSPAGE_H -#define STATSYNCING_MATCHEDTRACKSPAGE_H - -#include "ui_MatchedTracksPage.h" -#include "statsyncing/Provider.h" -#include "statsyncing/ScrobblingService.h" - -class QSortFilterProxyModel; - -namespace StatSyncing -{ - class MatchedTracksModel; - class SortFilterProxyModel; - - class MatchedTracksPage : public QWidget, private Ui::MatchedTracksPage - { - Q_OBJECT - - public: - explicit MatchedTracksPage( QWidget *parent = 0, Qt::WindowFlags f = 0 ); - virtual ~MatchedTracksPage(); - - /** - * Set provider, you must call this before showing the widget. - */ - void setProviders( const ProviderPtrList &providers ); - - /** - * Set mathed tracks model. MatchedTracksPage does _not_ take ownership of - * the pointer. - */ - void setMatchedTracksModel( MatchedTracksModel *model ); - - /** - * Add unique tracks model. MatchedTracksPage does _not_ take ownership of the - * model pointer. - */ - void addUniqueTracksModel( ProviderPtr provider, QAbstractItemModel *model ); - - /** - * Add excluded tracks model. MatchedTracksPage does _not_ take ownership of - * the model pointer. - */ - void addExcludedTracksModel( ProviderPtr provider, QAbstractItemModel *model ); - - /** - * Set a list of tracks that are going to be scrobbled - */ - void setTracksToScrobble( const TrackList &tracksToScrobble, const QList &services ); - - signals: - /** - * Emitted when user pushes the Back button. - */ - void back(); - - /** - * Emitted when user clicks the Synchronize button. - */ - void accepted(); - - /** - * Emitted when user pushes the Cancel button. - */ - void rejected(); - - private slots: - void changeMatchedTracksFilter( int index ); - - void changeUniqueTracksProvider( int index ); - void changeExcludedTracksProvider( int index ); - - void refreshMatchedStatusText(); - void refreshUniqueStatusText(); - void refreshExcludedStatusText(); - - void rememberExpandedState( const QModelIndex &parent, int start, int end ); - void restoreExpandedState( const QModelIndex &parent, int start, int end ); - - void takeRatingsFrom(); - void includeLabelsFrom(); - void excludeLabelsFrom(); - - void expand( int onlyWithTupleFlags = -1 ); - void collapse(); - - void openConfiguration(); - - private: - void refreshStatusTextHelper( QSortFilterProxyModel *topModel, QLabel *label ); - static void setHeaderSizePoliciesFromModel( QHeaderView *header, QAbstractItemModel *model ); - Q_DISABLE_COPY( MatchedTracksPage ) - - QSet m_expandedTuples; - SortFilterProxyModel *m_matchedProxyModel; - QSortFilterProxyModel *m_uniqueProxyModel; - QSortFilterProxyModel *m_excludedProxyModel; - MatchedTracksModel *m_matchedTracksModel; - QMap m_uniqueTracksModels; - QMap m_excludedTracksModels; - }; - -} // namespace StatSyncing - -#endif // STATSYNCING_MATCHEDTRACKSPAGE_H diff --git a/amarok/src/statsyncing/ui/MatchedTracksPage.ui b/amarok/src/statsyncing/ui/MatchedTracksPage.ui deleted file mode 100644 index 9ba62757..00000000 --- a/amarok/src/statsyncing/ui/MatchedTracksPage.ui +++ /dev/null @@ -1,308 +0,0 @@ - - - MatchedTracksPage - - - - 0 - 0 - 641 - 465 - - - - - - - 0 - - - - Matched Tracks - - - - - - - - Filter Tracks... - - - true - - - - - - - - - - - - true - - - true - - - true - - - true - - - true - - - - - - - - - Affects all applicable tracks, not just shown ones - - - Take Ratings From - - - QToolButton::InstantPopup - - - Qt::ToolButtonTextBesideIcon - - - true - - - - - - - Affects all applicable tracks, not just shown ones - - - Labels - - - QToolButton::InstantPopup - - - Qt::ToolButtonTextBesideIcon - - - true - - - - - - - Qt::Vertical - - - - - - - Expand - - - QToolButton::InstantPopup - - - Qt::ToolButtonTextBesideIcon - - - true - - - - - - - Collapse - - - QToolButton::InstantPopup - - - Qt::ToolButtonTextBesideIcon - - - true - - - - - - - Qt::AlignRight|Qt::AlignTop|Qt::AlignTrailing - - - - - - - - - - Unique Tracks - - - - - - - - Filter Tracks... - - - true - - - - - - - - - - - - QAbstractItemView::DragOnly - - - true - - - QAbstractItemView::ExtendedSelection - - - true - - - true - - - true - - - true - - - - - - - Qt::AlignRight|Qt::AlignTop|Qt::AlignTrailing - - - - - - - - Excluded Tracks - - - - - - - - Filter Tracks... - - - true - - - - - - - - - - - - QAbstractItemView::DragOnly - - - true - - - QAbstractItemView::ExtendedSelection - - - true - - - true - - - true - - - true - - - - - - - Qt::AlignRight|Qt::AlignTop|Qt::AlignTrailing - - - - - - - - - - - Scrobbling - - - - - - 1234 plays of 123 tracks will be scrobbled to Last.fm [placeholder] - - - - - - - - - - QDialogButtonBox::Cancel - - - - - - - - KDialogButtonBox - QDialogButtonBox -
    kdialogbuttonbox.h
    -
    - - KLineEdit - QLineEdit -
    klineedit.h
    -
    - - KSeparator - QFrame -
    kseparator.h
    -
    -
    - - -
    diff --git a/amarok/src/statsyncing/ui/TrackDelegate.cpp b/amarok/src/statsyncing/ui/TrackDelegate.cpp deleted file mode 100644 index aa518b96..00000000 --- a/amarok/src/statsyncing/ui/TrackDelegate.cpp +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "TrackDelegate.h" - -#include "MetaValues.h" -#include "core/support/Debug.h" -#include "statsyncing/models/CommonModel.h" - -#include -#include -#include -#include - -#include -#include -#include - -using namespace StatSyncing; - -TrackDelegate::TrackDelegate( QObject *parent ) - : QStyledItemDelegate( parent ) -{ -} - -void -TrackDelegate::paint( QPainter *painter, const QStyleOptionViewItem &option, - const QModelIndex &index ) const -{ - qint64 field = index.data( CommonModel::FieldRole ).value(); - QVariant data = index.data(); - // display the icon even for label conflicts: - if( ( field == Meta::valRating || field == Meta::valLabel ) && - data.type() == QVariant::Int ) - { - // following is largely inspired by QStyledItemDelegate::paint() - QStyleOptionViewItemV4 opt = option; - initStyleOption( &opt, index ); - - QPixmap starsPixmap( CommonModel::s_ratingSize ); - starsPixmap.fill( Qt::transparent ); - { - KRatingPainter ratingPainter; - int rating = data.toInt(); - int hoverRating = -1; - if( rating < 0 ) // unresolved conflict - { - rating = 0; - ratingPainter.setIcon( KIcon( "status_unknown" ) ); - ratingPainter.setEnabled( false ); - ratingPainter.setMaxRating( 2 ); - } - QPainter starsPainter( &starsPixmap ); - ratingPainter.paint( &starsPainter, QRect( QPoint( 0, 0 ), - CommonModel::s_ratingSize ), rating, hoverRating ); - } - - opt.text.clear(); - opt.features |= QStyleOptionViewItemV2::HasDecoration; - opt.decorationSize = CommonModel::s_ratingSize; - opt.decorationAlignment = Qt::AlignRight | Qt::AlignVCenter; - opt.decorationPosition = QStyleOptionViewItem::Right; - opt.icon = QIcon( starsPixmap ); - - const QWidget *widget = opt.widget; - QStyle *style = widget ? widget->style() : QApplication::style(); - style->drawControl( QStyle::CE_ItemViewItem, &opt, painter, widget ); - } - else - QStyledItemDelegate::paint( painter, option, index ); -} - -QString -TrackDelegate::displayText( const QVariant &value, const QLocale &locale ) const -{ - if( value.type() == QVariant::DateTime ) - { - KLocale *klocale = KGlobal::locale(); - QDateTime date = value.toDateTime(); - return date.isValid() ? klocale->formatDateTime( date, KLocale::FancyShortDate ) - : QString(); - } - return QStyledItemDelegate::displayText( value, locale ); -} diff --git a/amarok/src/statsyncing/ui/TrackDelegate.h b/amarok/src/statsyncing/ui/TrackDelegate.h deleted file mode 100644 index 09b5cb15..00000000 --- a/amarok/src/statsyncing/ui/TrackDelegate.h +++ /dev/null @@ -1,35 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef STATSYNCING_TRACKDELEGATE_H -#define STATSYNCING_TRACKDELEGATE_H - -#include - -namespace StatSyncing -{ - class TrackDelegate : public QStyledItemDelegate - { - public: - explicit TrackDelegate( QObject *parent = 0 ); - - void paint( QPainter *painter, const QStyleOptionViewItem &option, - const QModelIndex &index ) const; - QString displayText( const QVariant &value, const QLocale &locale ) const; - }; -} - -#endif // STATSYNCING_TRACKDELEGATE_H diff --git a/amarok/src/statusbar/CompoundProgressBar.cpp b/amarok/src/statusbar/CompoundProgressBar.cpp deleted file mode 100644 index 78bcb711..00000000 --- a/amarok/src/statusbar/CompoundProgressBar.cpp +++ /dev/null @@ -1,272 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "CompoundProgressBar.h" - -#include "core/support/Debug.h" - -#include -#include - -#include -#include - -CompoundProgressBar::CompoundProgressBar( QWidget *parent ) - : ProgressBar( parent ) - , m_mutex( QMutex::Recursive ) -{ - m_progressDetailsWidget = new PopupWidget( parent ); - m_progressDetailsWidget->hide(); - - connect( cancelButton(), SIGNAL(clicked()), this, SLOT(cancelAll()) ); -} - -CompoundProgressBar::~CompoundProgressBar() -{ - delete m_progressDetailsWidget; - m_progressDetailsWidget = 0; -} - -void CompoundProgressBar::addProgressBar( ProgressBar *childBar, QObject *owner ) -{ - QMutexLocker locker( &m_mutex ); - - m_progressMap.insert( owner, childBar ); - m_progressDetailsWidget->layout()->addWidget( childBar ); - if( m_progressDetailsWidget->width() < childBar->width() ) - m_progressDetailsWidget->setMinimumWidth( childBar->width() ); - - m_progressDetailsWidget->setMinimumHeight( childBar->height() * m_progressMap.count() + 8 ); - - m_progressDetailsWidget->reposition(); - - connect( childBar, SIGNAL(percentageChanged(int)), - SLOT(childPercentageChanged()) ); - connect( childBar, SIGNAL(cancelled(ProgressBar*)), - SLOT(childBarCancelled(ProgressBar*)) ); - connect( childBar, SIGNAL(complete(ProgressBar*)), - SLOT(childBarComplete(ProgressBar*)) ); - connect( owner, SIGNAL(destroyed(QObject*)), SLOT(slotObjectDestroyed(QObject*)) ); - - if( m_progressMap.count() == 1 ) - { - setDescription( childBar->descriptionLabel()->text() ); - cancelButton()->setToolTip( i18n( "Abort" ) ); - } - else - { - setDescription( i18n( "Multiple background tasks running (click to show)" ) ); - cancelButton()->setToolTip( i18n( "Abort all background tasks" ) ); - } - - cancelButton()->setHidden( false ); -} - -void CompoundProgressBar::endProgressOperation( QObject *owner ) -{ - QMutexLocker locker( &m_mutex ); - - if( !m_progressMap.contains( owner ) ) - return ; - - childBarComplete( m_progressMap.value( owner ) ); -} - -void -CompoundProgressBar::slotIncrementProgress() -{ - incrementProgress( sender() ); -} - -void CompoundProgressBar::incrementProgress( const QObject *owner ) -{ - QMutexLocker locker( &m_mutex ); - - if( !m_progressMap.contains( owner ) ) - return ; - - m_progressMap.value( owner )->setValue( m_progressMap.value( owner )->value() + 1 ); -} - -void CompoundProgressBar::setProgress( const QObject *owner, int steps ) -{ - QMutexLocker locker( &m_mutex ); - - if( !m_progressMap.contains( owner ) ) - return ; - - m_progressMap.value( owner )->setValue( steps ); -} - -void -CompoundProgressBar::mousePressEvent( QMouseEvent *event ) -{ - QMutexLocker locker( &m_mutex ); - - if( m_progressDetailsWidget->isHidden() ) - { - if( m_progressMap.count() ) - showDetails(); - } - else - { - hideDetails(); - } - - event->accept(); -} - -void CompoundProgressBar::setProgressTotalSteps( const QObject *owner, int value ) -{ - QMutexLocker locker( &m_mutex ); - - if( !m_progressMap.contains( owner ) ) - return ; - - m_progressMap.value( owner )->setMaximum( value ); -} - -void CompoundProgressBar::setParent( QWidget *parent ) -{ - QMutexLocker locker( &m_mutex ); - - delete m_progressDetailsWidget; - m_progressDetailsWidget = new PopupWidget( parent ); - m_progressDetailsWidget->hide(); - - ProgressBar::setParent( parent ); -} - - -void CompoundProgressBar::setProgressStatus( const QObject *owner, const QString &text ) -{ - QMutexLocker locker( &m_mutex ); - - if( !m_progressMap.contains( owner ) ) - return ; - - m_progressMap.value( owner )->setDescription( text ); -} - -void CompoundProgressBar::childPercentageChanged() -{ - progressBar()->setValue( calcCompoundPercentage() ); -} - -void CompoundProgressBar::childBarCancelled( ProgressBar *childBar ) -{ - childBarFinished( childBar ); -} - -void CompoundProgressBar::childBarComplete( ProgressBar *childBar ) -{ - childBarFinished( childBar ); -} - -void CompoundProgressBar::slotObjectDestroyed( QObject *object ) -{ - QMutexLocker locker( &m_mutex ); - - if( m_progressMap.contains( object ) ) - { - childBarFinished( m_progressMap.value( object ) ); - } -} - -void CompoundProgressBar::childBarFinished( ProgressBar *bar ) -{ - QMutexLocker locker( &m_mutex ); - - QObject *owner = const_cast( m_progressMap.key( bar ) ); - owner->disconnect( this ); - owner->disconnect( bar ); - m_progressMap.remove( owner ); - m_progressDetailsWidget->layout()->removeWidget( bar ); - m_progressDetailsWidget->setFixedHeight( bar->height() * m_progressMap.count() + 8 ); - m_progressDetailsWidget->reposition(); - delete bar; - - if( m_progressMap.count() == 1 ) - { - //only one job still running, so no need to use the details widget any more. - //Also set the text to the description of - //the job instead of the "Multiple background tasks running" text. - setDescription( m_progressMap.values().at( 0 )->descriptionLabel()->text() ); - cancelButton()->setToolTip( i18n( "Abort" ) ); - hideDetails(); - } - else if( m_progressMap.empty() ) - { - progressBar()->setValue( 0 ); - hideDetails(); - emit( allDone() ); - return; - } - else - { - setDescription( i18n( "Multiple background tasks running (click to show)" ) ); - cancelButton()->setToolTip( i18n( "Abort all background tasks" ) ); - } - - progressBar()->setValue( calcCompoundPercentage() ); -} - -int CompoundProgressBar::calcCompoundPercentage() -{ - QMutexLocker locker( &m_mutex ); - - int count = m_progressMap.count(); - int total = 0; - - foreach( ProgressBar *currentBar, m_progressMap ) - total += currentBar->percentage(); - - return count == 0 ? 0 : total / count; -} - -void CompoundProgressBar::cancelAll() -{ - QMutexLocker locker( &m_mutex ); - - foreach( ProgressBar *currentBar, m_progressMap ) - currentBar->cancel(); -} - -void CompoundProgressBar::showDetails() -{ - QMutexLocker locker( &m_mutex ); - - m_progressDetailsWidget->raise(); - - //Hack to make sure it has the right height first time it is shown... - m_progressDetailsWidget->setFixedHeight( - m_progressMap.values().at( 0 )->height() * m_progressMap.count() + 8 ); - m_progressDetailsWidget->reposition(); - m_progressDetailsWidget->show(); -} - -void CompoundProgressBar::hideDetails() -{ - m_progressDetailsWidget->hide(); -} - -void CompoundProgressBar::toggleDetails() -{ - if( m_progressDetailsWidget->isVisible() ) - hideDetails(); - else - showDetails(); -} diff --git a/amarok/src/statusbar/CompoundProgressBar.h b/amarok/src/statusbar/CompoundProgressBar.h deleted file mode 100644 index 38c4ed14..00000000 --- a/amarok/src/statusbar/CompoundProgressBar.h +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef COMPOUNDPROGRESSBAR_H -#define COMPOUNDPROGRESSBAR_H - -#include "statusbar/ProgressBar.h" -#include "statusbar/PopupWidget.h" - -#include -#include -#include -#include - -/** - * A progress bar that wraps a number of simple progress bars and displays their - * overall progress. Also features an expanded mode that allows the user to view - * and canceld individual operations - */ -class AMAROK_EXPORT CompoundProgressBar : public ProgressBar -{ - Q_OBJECT -public: - CompoundProgressBar( QWidget *parent ); - - ~CompoundProgressBar(); - - void addProgressBar( ProgressBar *progressBar, QObject *owner ); - - void incrementProgress( const QObject *owner ); - void setProgressTotalSteps( const QObject *owner, int value ); - void setProgressStatus( const QObject *owner, const QString &text ); - void setProgress( const QObject *owner, int steps ); - - /* reimplemented from QWidget for correct positioning of progressDetailsWidget */ - virtual void setParent( QWidget *parent ); - - /* reimplemented from QWidget to open/close the details widget */ - virtual void mousePressEvent( QMouseEvent *event ); - -public slots: - void endProgressOperation( QObject *owner ); - void slotIncrementProgress(); - -signals: - void allDone(); - -protected slots: - void cancelAll(); - void toggleDetails(); - - void childPercentageChanged( ); - void childBarCancelled( ProgressBar *progressBar ); - void childBarComplete( ProgressBar *progressBar ); - - void slotObjectDestroyed( QObject *object ); - -private: - void showDetails(); - void hideDetails(); - - void childBarFinished( ProgressBar *bar ); - - int calcCompoundPercentage(); - - QMap< const QObject *, ProgressBar *> m_progressMap; - PopupWidget *m_progressDetailsWidget; - QMutex m_mutex; // protecting m_progressMap consistency -}; - -#endif diff --git a/amarok/src/statusbar/KJobProgressBar.cpp b/amarok/src/statusbar/KJobProgressBar.cpp deleted file mode 100644 index a46ec0ec..00000000 --- a/amarok/src/statusbar/KJobProgressBar.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "KJobProgressBar.h" - -KJobProgressBar::KJobProgressBar( QWidget *parent, KJob * job ) - : ProgressBar( parent ) -{ - connect( job, SIGNAL(percent(KJob*,ulong)), SLOT(updateJobStatus(KJob*,ulong)) ); - connect( job, SIGNAL(result(KJob*)), SLOT(delayedDone()) ); - connect( job, SIGNAL(infoMessage(KJob*,QString,QString)), SLOT(infoMessage(KJob*,QString,QString)) ); -} - - -KJobProgressBar::~KJobProgressBar() -{ -} - -void KJobProgressBar::updateJobStatus( KJob * job, unsigned long value ) -{ - Q_UNUSED( job ); - setValue( value ); - emit( percentageChanged( percentage() ) ); -} - -void KJobProgressBar::infoMessage( KJob* job, QString plain, QString rich ) -{ - Q_UNUSED( job ); - Q_UNUSED( rich ); - setDescription( plain ); -} - - -#include "moc_KJobProgressBar.cpp" diff --git a/amarok/src/statusbar/KJobProgressBar.h b/amarok/src/statusbar/KJobProgressBar.h deleted file mode 100644 index 5f0110f1..00000000 --- a/amarok/src/statusbar/KJobProgressBar.h +++ /dev/null @@ -1,40 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_KJOB_PROGRESS_BAR_H -#define AMAROK_KJOB_PROGRESS_BAR_H - -#include "statusbar/ProgressBar.h" - -#include - -/** - * A specialized progress bar that takes a KJob in the constructor and keeps itself updated - */ -class KJobProgressBar : public ProgressBar -{ - Q_OBJECT - - public: - KJobProgressBar( QWidget *parent, KJob * job ); - ~KJobProgressBar(); - - private slots: - void updateJobStatus( KJob*, unsigned long ); - void infoMessage( KJob*, QString plain, QString rich ); -}; - -#endif diff --git a/amarok/src/statusbar/LongMessageWidget.cpp b/amarok/src/statusbar/LongMessageWidget.cpp deleted file mode 100644 index 4cefff22..00000000 --- a/amarok/src/statusbar/LongMessageWidget.cpp +++ /dev/null @@ -1,153 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Nikolaj Hald Nielsen * - * Copyright (c) 2005 Max Howell * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "LongMessageWidget.h" - -#include "core/support/Debug.h" - -#include - -#include -#include -#include -#include - - -LongMessageWidget::LongMessageWidget( QWidget *anchor, const QString &message, - Amarok::Logger::MessageType type ) - : PopupWidget( anchor ) - , m_counter( 0 ) - , m_timeout( 6000 ) -{ - DEBUG_BLOCK - Q_UNUSED( type ) - - setFrameStyle( QFrame::StyledPanel | QFrame::Raised ); - - setContentsMargins( 4, 4, 4, 4 ); - - setMinimumWidth( 26 ); - setMinimumHeight( 26 ); - setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding ); - - QPalette p = QToolTip::palette(); - setPalette( p ); - - KHBox *hbox = new KHBox( this ); - layout()->addWidget( hbox ); - - hbox->setSpacing( 12 ); - - m_countdownFrame = new CountdownFrame( hbox ); - m_countdownFrame->setObjectName( "counterVisual" ); - m_countdownFrame->setFixedWidth( fontMetrics().width( "X" ) ); - m_countdownFrame->setFrameStyle( QFrame::Plain | QFrame::Box ); - QPalette pal; - pal.setColor( m_countdownFrame->foregroundRole(), p.dark().color() ); - m_countdownFrame->setPalette( pal ); - - QLabel *alabel = new QLabel( message, hbox ); - alabel->setWordWrap( true ); - alabel->setOpenExternalLinks( true ); - alabel->setObjectName( "label" ); - alabel->setTextFormat( Qt::RichText ); - alabel->setTextInteractionFlags( Qt::TextBrowserInteraction ); - alabel->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Preferred ); - alabel->setPalette( p ); - - hbox = new KHBox( this ); - layout()->addWidget( hbox ); - - KPushButton *button = new KPushButton( KStandardGuiItem::close(), hbox ); - button->setObjectName( "closeButton" ); - connect( button, SIGNAL(clicked()), SLOT(close()) ); - - reposition(); - - show(); - m_timerId = startTimer( m_timeout / m_countdownFrame->height() ); -} - -LongMessageWidget::~LongMessageWidget() -{} - -void LongMessageWidget::close() -{ - hide(); - emit( closed() ); -} - -void LongMessageWidget::timerEvent( QTimerEvent* ) -{ - if( !m_timeout ) - { - killTimer( m_timerId ); - return; - } - - CountdownFrame *&h = m_countdownFrame; - - if( m_counter < h->height() - 3 ) - { - h->setFilledRatio(( float ) m_counter / ( float ) h->height() ); - h->repaint(); - } - - if( !testAttribute( Qt::WA_UnderMouse ) ) - m_counter++; - - if( m_counter > h->height() ) - { - killTimer( m_timerId ); - h->setFilledRatio( 1 ); - h->repaint(); - close(); - } - else - { - killTimer( m_timerId ); - m_timerId = startTimer( m_timeout / h->height() ); - } -} - -////////////////////////////////////////////////////////////////////////////// -// class CountdownFrame -////////////////////////////////////////////////////////////////////////////// - -CountdownFrame::CountdownFrame( QWidget *parent ) - : QFrame( parent ) - , m_filled( 0.0 ) -{} - -void CountdownFrame::setFilledRatio( float filled ) -{ - m_filled = filled; -} - -void CountdownFrame::paintEvent( QPaintEvent *e ) -{ - QFrame::paintEvent( e ); - - QPalette p = palette(); - p.setCurrentColorGroup( QPalette::Active ); - - QPainter( this ).fillRect( 2, m_filled * height() , width() - 4, height() - - ( m_filled * height() ) , p.highlight() - ); -} - -#include "moc_LongMessageWidget.cpp" diff --git a/amarok/src/statusbar/LongMessageWidget.h b/amarok/src/statusbar/LongMessageWidget.h deleted file mode 100644 index dbdd2c12..00000000 --- a/amarok/src/statusbar/LongMessageWidget.h +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Nikolaj Hald Nielsen * - * Copyright (c) 2005 Max Howell * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef LONGMESSAGEWIDGET_H -#define LONGMESSAGEWIDGET_H - -#include "PopupWidget.h" -#include "core/interfaces/Logger.h" - -class CountdownFrame : public QFrame -{ -public: - CountdownFrame( QWidget *parent = 0 ); - void setFilledRatio( float filled ); // 0 to 1 - - virtual void paintEvent( QPaintEvent *e ); - -protected: - float m_filled; -}; - -/** A widget for displaying a long message as an overlay -*/ -class LongMessageWidget : public PopupWidget -{ - Q_OBJECT -public: - LongMessageWidget( QWidget *anchor, const QString &message, Amarok::Logger::MessageType type ); - - ~LongMessageWidget(); - -signals: - void closed(); - -protected: - void timerEvent( QTimerEvent * ); - -private slots: - void close(); - -private: - CountdownFrame *m_countdownFrame; - int m_counter; - int m_timeout; - int m_timerId; - -}; - -#endif diff --git a/amarok/src/statusbar/NetworkProgressBar.cpp b/amarok/src/statusbar/NetworkProgressBar.cpp deleted file mode 100644 index d5562f76..00000000 --- a/amarok/src/statusbar/NetworkProgressBar.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Rick W. Chen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "NetworkProgressBar.h" - -NetworkProgressBar::NetworkProgressBar( QWidget *parent, QNetworkReply *reply ) - : ProgressBar( parent ) -{ - connect( reply, SIGNAL(error(QNetworkReply::NetworkError)), SLOT(infoMessage(QNetworkReply::NetworkError)) ); - connect( reply, SIGNAL(finished()), SLOT(delayedDone()) ); - connect( reply, SIGNAL(destroyed()), SLOT(delayedDone()) ); - - switch( reply->operation() ) - { - case QNetworkAccessManager::HeadOperation: - case QNetworkAccessManager::GetOperation: - connect( reply, SIGNAL(downloadProgress(qint64,qint64)), SLOT(progressChanged(qint64,qint64)) ); - break; - - case QNetworkAccessManager::PutOperation: - case QNetworkAccessManager::PostOperation: - connect( reply, SIGNAL(uploadProgress(qint64,qint64)), SLOT(progressChanged(qint64,qint64)) ); - break; - - default: - break; - } -} - -NetworkProgressBar::~NetworkProgressBar() -{ -} - -void NetworkProgressBar::progressChanged( qint64 bytesChanged, qint64 bytesTotal ) -{ - qreal percent = qreal(bytesChanged) / bytesTotal; - setValue( int(percent) * 100 ); -} - -void NetworkProgressBar::infoMessage( QNetworkReply::NetworkError code ) -{ - if( code != QNetworkReply::NoError ) - { - QNetworkReply *reply = qobject_cast( sender() ); - setDescription( reply->errorString() ); - } -} - -#include "moc_NetworkProgressBar.cpp" diff --git a/amarok/src/statusbar/NetworkProgressBar.h b/amarok/src/statusbar/NetworkProgressBar.h deleted file mode 100644 index f9a5096f..00000000 --- a/amarok/src/statusbar/NetworkProgressBar.h +++ /dev/null @@ -1,40 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Rick W. Chen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_NETWORK_PROGRESS_BAR_H -#define AMAROK_NETWORK_PROGRESS_BAR_H - -#include "statusbar/ProgressBar.h" - -#include - -/** - * A specialized progress bar that takes a QNetworkReply in the constructor and keeps itself updated - */ -class NetworkProgressBar : public ProgressBar -{ - Q_OBJECT - - public: - NetworkProgressBar( QWidget *parent, QNetworkReply *reply ); - ~NetworkProgressBar(); - - private slots: - void progressChanged( qint64 bytesChanged, qint64 bytesTotal ); - void infoMessage( QNetworkReply::NetworkError code ); -}; - -#endif diff --git a/amarok/src/statusbar/PopupWidget.cpp b/amarok/src/statusbar/PopupWidget.cpp deleted file mode 100644 index a56d552d..00000000 --- a/amarok/src/statusbar/PopupWidget.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "PopupWidget.h" - -#include "MainWindow.h" - -#include "core/support/Debug.h" - - -PopupWidget::PopupWidget( QWidget *anchor, const QString &name ) - : KVBox( The::mainWindow() ) -{ - Q_UNUSED( name ); - Q_UNUSED( anchor ); - - setBackgroundRole( QPalette::Window ); - setAutoFillBackground( true ); - - setFrameStyle( QFrame::Box ); - - setMinimumWidth( 26 ); - setMinimumHeight( 26 ); - - setContentsMargins( 4, 4, 4, 4 ); - setSpacing( 0 ); - setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); - - reposition(); -} - -PopupWidget::~PopupWidget() -{ - DEBUG_BLOCK -} - -void PopupWidget::reposition() -{ - adjustSize(); - - //HACK: put longmessage popup in the bottom right of the window. - QPoint p; - p.setX( The::mainWindow()->width() - width() ); - p.setY( The::mainWindow()->height() - height() ); - move( p ); -} diff --git a/amarok/src/statusbar/PopupWidget.h b/amarok/src/statusbar/PopupWidget.h deleted file mode 100644 index b202a696..00000000 --- a/amarok/src/statusbar/PopupWidget.h +++ /dev/null @@ -1,31 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef POPUPWIDGET_H -#define POPUPWIDGET_H - -#include - -class PopupWidget : public KVBox -{ -public: - explicit PopupWidget( QWidget *anchor, const QString &name = QString() ); - ~PopupWidget(); - - void reposition(); -}; - -#endif diff --git a/amarok/src/statusbar/ProgressBar.cpp b/amarok/src/statusbar/ProgressBar.cpp deleted file mode 100644 index dd6d40ba..00000000 --- a/amarok/src/statusbar/ProgressBar.cpp +++ /dev/null @@ -1,126 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "statusbar/ProgressBar.h" - -#include "core/support/Debug.h" -#include "MainWindow.h" - -#include - -#include -#include - -ProgressBar::ProgressBar( QWidget *parent ) - : QFrame( parent ) -{ - setFixedHeight( 30 ); - setContentsMargins( 0, 0, 0, 4 ); - - QVBoxLayout *box = new QVBoxLayout; - box->setMargin( 0 ); - box->setSpacing( 3 ); - - QHBoxLayout *descriptionLayout = new QHBoxLayout; - descriptionLayout->setMargin( 0 ); - descriptionLayout->setSpacing( 2 ); - - m_descriptionLabel = new QLabel; - m_descriptionLabel->setWordWrap( true ); - //add with stretchfactor 1 so it takes up more space then the cancel button - descriptionLayout->addWidget( m_descriptionLabel, 1 ); - - m_cancelButton = new QToolButton; - m_cancelButton->setIcon( KIcon( "dialog-cancel-amarok" ) ); - m_cancelButton->setToolTip( i18n( "Abort" ) ); - m_cancelButton->setHidden( true ); - m_cancelButton->setFixedWidth( 16 ); - m_cancelButton->setFixedHeight( 16 ); - m_cancelButton->setAutoFillBackground( false ); - m_cancelButton->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ); - descriptionLayout->addWidget( m_cancelButton ); - descriptionLayout->setAlignment( m_cancelButton, Qt::AlignRight ); - - box->addLayout( descriptionLayout ); - - m_progressBar = new QProgressBar; - m_progressBar->setMinimum( 0 ); - m_progressBar->setMaximum( 100 ); - m_progressBar->setFixedHeight( 5 ); - m_progressBar->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); - m_progressBar->setTextVisible( false ); - box->addWidget( m_progressBar ); - box->setAlignment( m_progressBar, Qt::AlignBottom ); - - setLayout( box ); -} - - -ProgressBar::~ProgressBar() -{ -} - -void -ProgressBar::setDescription( const QString &description ) -{ - m_descriptionLabel->setText( description ); - -} - -ProgressBar * -ProgressBar::setAbortSlot( QObject *receiver, const char *slot, Qt::ConnectionType type ) -{ - cancelButton()->setHidden( false ); - if( receiver ) - connect( this, SIGNAL(cancelled()), receiver, slot, type ); - connect( cancelButton(), SIGNAL(clicked()), this, SLOT(cancel()) ); - - return this; -} - -void ProgressBar::cancel() -{ - DEBUG_BLOCK - debug() << "cancelling operation: " << m_descriptionLabel->text(); - emit( cancelled() ); - emit( cancelled( this ) ); -} - -void ProgressBar::setValue( int percentage ) -{ - progressBar()->setValue( percentage ); - emit( percentageChanged( percentage ) ); - - //this safety check has to be removed as KJobs sometimes start out - //by showing 100%, thus removing the progress info before it even gets started - /*if ( percentage == m_progressBar->maximum() ) - QTimer::singleShot( POST_COMPLETION_DELAY, this, SLOT(delayedDone()) );*/ -} - -void ProgressBar::delayedDone() -{ - emit( complete( this ) ); -} - -int ProgressBar::percentage() -{ - if( m_progressBar->maximum() == 100 ) - return m_progressBar->value(); - return (int)( ( (float) m_progressBar->value() / (float)m_progressBar->maximum() ) * 100.0 ); -} - - -#include "moc_ProgressBar.cpp" diff --git a/amarok/src/statusbar/ProgressBar.h b/amarok/src/statusbar/ProgressBar.h deleted file mode 100644 index a546c2a6..00000000 --- a/amarok/src/statusbar/ProgressBar.h +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef PROGRESSBAR_H -#define PROGRESSBAR_H - -#include "amarok_export.h" - -#include - -#include -#include -#include -#include -#include - -#define POST_COMPLETION_DELAY 2000 - -/** - * A widget that encapsulates a progress bar, a description string and a cancel button. - */ -class AMAROK_EXPORT ProgressBar : public QFrame -{ - Q_OBJECT - - public: - ProgressBar( QWidget *parent ); - ~ProgressBar(); - - void setDescription( const QString &description ); - ProgressBar *setAbortSlot( QObject *receiver, const char *slot, - Qt::ConnectionType type = Qt::AutoConnection ); - - QToolButton *cancelButton() { return m_cancelButton; } - QProgressBar *progressBar() { return m_progressBar; } - QLabel *descriptionLabel() { return m_descriptionLabel; } - - int maximum() { return m_progressBar->maximum(); } - void setMaximum( int max ) { m_progressBar->setMaximum( max ); } - int value() { return m_progressBar->value(); } - void setValue( int value ); - int percentage(); - - public slots: - void cancel(); - void delayedDone(); - void slotTotalSteps( int steps ) { m_progressBar->setMaximum( steps ); } - - signals: - void cancelled( ProgressBar * ); - void cancelled(); - void complete( ProgressBar * ); - void percentageChanged( int ); - - private: - QToolButton *m_cancelButton; - QProgressBar *m_progressBar; - QLabel *m_descriptionLabel; -}; - -#endif diff --git a/amarok/src/support/QSharedDataPointerMisc.h b/amarok/src/support/QSharedDataPointerMisc.h deleted file mode 100644 index f22a07e9..00000000 --- a/amarok/src/support/QSharedDataPointerMisc.h +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef QSHAREDDATAPOINTERMISC -#define QSHAREDDATAPOINTERMISC - -#include -#include - -/** - * @brief QSharedDataPointerMisc.h - * - * Qt doesn't provide operator<, operator== and qHash() for - * Q{,Explicitly}SharedDataPointer. - * - * Define those so that you can use Q{,Explicitly}SharedDataPointers in QMaps, - * QHashes etc. - * - * QMap needs operator< for key, however - * QExplicitlySharedDataPointer silently coerces to bool, which gives really - * hard to find bugs, because it makes QMap with it useless. - */ - -/** - * Define trivial comparison operator for QSharedDataPointer so that it doesn't - * coerce to bool. - */ -template -Q_INLINE_TEMPLATE bool operator<( const QSharedDataPointer &l, const QSharedDataPointer &r ) -{ - return l.data() < r.data(); -} - -/** - * Define trivial comparison operator for QExplicitlySharedDataPointer so - * that it doesn't coerce to bool. - */ -template -Q_INLINE_TEMPLATE bool operator<( const QExplicitlySharedDataPointer &l, const QExplicitlySharedDataPointer &r ) -{ - return l.data() < r.data(); -} - -/** - * Define trivial equivalence operator for QSharedDataPointer so that it can - * be used in Qt containers. - */ -template -Q_INLINE_TEMPLATE bool operator==( const QSharedDataPointer &l, const QSharedDataPointer &r ) -{ - return l.data() == r.data(); -} - -/** - * Define trivial equivalence operator for QExplicitlySharedDataPointer so - * that it can be used in Qt containers. - */ -template -Q_INLINE_TEMPLATE bool operator==( const QExplicitlySharedDataPointer &l, const QExplicitlySharedDataPointer &r ) -{ - return l.data() == r.data(); -} - -/** - * Define trivial qHash() for QSharedDataPointer so that it can - * be used in Qt containers. - */ -template -Q_INLINE_TEMPLATE uint qHash( const QSharedDataPointer &ptr ) -{ - return qHash( ptr.data() ); -} - -/** - * Define trivial qHash() for QExplicitlySharedDataPointer so that it can be - * used in Qt containers. - */ -template -Q_INLINE_TEMPLATE uint qHash( const QExplicitlySharedDataPointer &ptr ) -{ - return qHash( ptr.data() ); -} - -#endif // QSHAREDDATAPOINTERMISC diff --git a/amarok/src/synchronization/MasterSlaveSynchronizationJob.cpp b/amarok/src/synchronization/MasterSlaveSynchronizationJob.cpp deleted file mode 100644 index 1979701b..00000000 --- a/amarok/src/synchronization/MasterSlaveSynchronizationJob.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "MasterSlaveSynchronizationJob.h" - -#include "core/collections/Collection.h" -#include "core/collections/CollectionLocation.h" -#include "core/support/Debug.h" - -MasterSlaveSynchronizationJob::MasterSlaveSynchronizationJob() - : SynchronizationBaseJob() - , m_master( 0 ) - , m_slave( 0 ) -{ - -} - -MasterSlaveSynchronizationJob::~MasterSlaveSynchronizationJob() -{ -} - -void -MasterSlaveSynchronizationJob::setMaster( Collections::Collection *master ) -{ - m_master = master; - setCollectionA( master ); -} - -void -MasterSlaveSynchronizationJob::setSlave( Collections::Collection *slave ) -{ - m_slave = slave; - setCollectionB( slave ); -} - -void -MasterSlaveSynchronizationJob::doSynchronization( const Meta::TrackList &tracks, InSet syncDirection, Collections::Collection *collA, Collections::Collection *collB ) -{ - DEBUG_BLOCK - if( !( syncDirection == OnlyInA || syncDirection == OnlyInB ) ) - { - debug() << "warning, received an unexpected syncDirection"; - return; - } - if( !( m_master == collA || m_master == collB ) || !( m_slave == collA || m_slave == collB ) ) - { - debug() << "warning, received an unknown collection"; - return; - } - if( !m_slave->isWritable() ) - { - debug() << "Error: slave collection " << m_slave->collectionId() << " is not writable"; - return; - } - if( ( syncDirection == OnlyInA && collA == m_master ) || ( syncDirection == OnlyInB && collB == m_master ) ) - { - debug() << "Master " << m_master->collectionId() << " has to sync " << tracks.count() << " track(s) to " << m_slave->collectionId(); - Collections::CollectionLocation *masterLoc = m_master->location(); - Collections::CollectionLocation *slaveLoc = m_slave->location(); - masterLoc->prepareCopy( tracks, slaveLoc ); - } - else - { - //we have tested for the correct synDirections and the correct collections above, - //so these are definitely the tracks that have to be removed from the slave - debug() << "Delete " << tracks.count() << " track(s) from slave " << m_slave->collectionId(); - //do some more stuff, and *really* show a confirmation dialog - Collections::CollectionLocation *slaveLoc = m_slave->location(); - slaveLoc->prepareRemove( tracks ); - } -} diff --git a/amarok/src/synchronization/MasterSlaveSynchronizationJob.h b/amarok/src/synchronization/MasterSlaveSynchronizationJob.h deleted file mode 100644 index f83df91b..00000000 --- a/amarok/src/synchronization/MasterSlaveSynchronizationJob.h +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef MASTERSLAVESYNCHRONIZATIONJOB_H -#define MASTERSLAVESYNCHRONIZATIONJOB_H - -#include "SynchronizationBaseJob.h" - -namespace Amarok -{ - class Collection; -} - -/** - * @class MasterSlaveSynchronizationJob - * Ensures that the slave collection - * contains exactly the same tracks as the master collection, i.e. it - * adds tracks that are in master but not in slave to slave and removes - * tracks that are in slave but not in master from slave. - */ -class MasterSlaveSynchronizationJob : public SynchronizationBaseJob -{ - Q_OBJECT - public: - MasterSlaveSynchronizationJob(); - ~MasterSlaveSynchronizationJob(); - - //master/slave are not settable in the ctor - //to make explicit which collection is the master and which is the slave - //for this synchronization - void setMaster( Collections::Collection *master ); - void setSlave( Collections::Collection *slave ); - - protected: - void doSynchronization( const Meta::TrackList &tracks, InSet syncDirection, Collections::Collection *collA, Collections::Collection *collB ); - - private: - Collections::Collection *m_master; - Collections::Collection *m_slave; -}; - -#endif diff --git a/amarok/src/synchronization/OneWaySynchronizationJob.cpp b/amarok/src/synchronization/OneWaySynchronizationJob.cpp deleted file mode 100644 index 99f504ce..00000000 --- a/amarok/src/synchronization/OneWaySynchronizationJob.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "OneWaySynchronizationJob.h" - -#include "core/collections/Collection.h" -#include "core/collections/CollectionLocation.h" -#include "core/support/Debug.h" -#include "core/meta/Meta.h" - -OneWaySynchronizationJob::OneWaySynchronizationJob() - : SynchronizationBaseJob() - , m_source( 0 ) - , m_target( 0 ) -{ -} - -OneWaySynchronizationJob::~OneWaySynchronizationJob() -{ - //nothing to do -} - -void -OneWaySynchronizationJob::setSource( Collections::Collection *source ) -{ - m_source = source; - setCollectionA( source ); -} - -void -OneWaySynchronizationJob::setTarget( Collections::Collection *target ) -{ - m_target = target; - //this will be slightly inefficient as SynchronizationBaseJob will figure out - //the tracks that are in target but not in source, even though we do not care about - //those. - setCollectionB( target ); -} - -void -OneWaySynchronizationJob::doSynchronization( const Meta::TrackList &tracks, InSet syncDirection, Collections::Collection *collA, Collections::Collection* collB ) -{ - DEBUG_BLOCK - if( !( syncDirection == OnlyInA || syncDirection == OnlyInB ) ) - { - debug() << "warning, received an unexpected syncDirection"; - return; - } - if( !( m_source == collA || m_source == collB ) || !( m_target == collA || m_target == collB ) ) - { - debug() << "warning, received an unknown collection"; - return; - } - if( ( syncDirection == OnlyInA && collA == m_source ) || ( syncDirection == OnlyInB && collB == m_source ) ) - { - debug() << "Master " << m_source->collectionId() << " has to sync " << tracks.count() << " track(s) to " << m_target->collectionId(); - //show confirmation dialog, actually do stuff - Collections::CollectionLocation *locSource = m_source->location(); - Collections::CollectionLocation *locTarget = m_target->location(); - if( !locTarget->isWritable() ) - { - debug() << "target collection " << m_target->collectionId() << " is not writable, what am I doing here?"; - locSource->deleteLater(); - locTarget->deleteLater(); - return; - } - //might be nice to ask the user if the tracks should really be copied here... - - //although not named particularly well, this method actually starts the workflow too - locSource->prepareCopy( tracks, locTarget ); - //the collection locations will take care of the remaining work flow, we are done - } -} diff --git a/amarok/src/synchronization/OneWaySynchronizationJob.h b/amarok/src/synchronization/OneWaySynchronizationJob.h deleted file mode 100644 index 78bcc046..00000000 --- a/amarok/src/synchronization/OneWaySynchronizationJob.h +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef ONEWAYSYNCHRONIZATIONJOB_H -#define ONEWAYSYNCHRONIZATIONJOB_H - -#include "SynchronizationBaseJob.h" - -namespace Amarok -{ - class Collection; -} -/** - * @class OneWaySynchronizationJob - * Ensures that all tracks that are in the - * source collection are present in the target collection as well, i.e. - * it adds tracks that are in source but not in target to target. It does - * not remove any tracks from target. It is one half of UnionJob. -*/ -class OneWaySynchronizationJob : public SynchronizationBaseJob -{ - Q_OBJECT -public: - OneWaySynchronizationJob(); - ~OneWaySynchronizationJob(); - - //source/target are not settable in the ctor - //to make explicit which collection is the source and which is the target - //for this synchronization - void setSource( Collections::Collection *source ); - void setTarget( Collections::Collection *target ); - -protected: - void doSynchronization( const Meta::TrackList &tracks, InSet syncDirection, Collections::Collection *collA, Collections::Collection *collB ); - -private: - Collections::Collection *m_source; - Collections::Collection *m_target; -}; - -#endif // ONEWAYSYNCHRONIZATIONJOB_H diff --git a/amarok/src/synchronization/SynchronizationBaseJob.cpp b/amarok/src/synchronization/SynchronizationBaseJob.cpp deleted file mode 100644 index 62cd968a..00000000 --- a/amarok/src/synchronization/SynchronizationBaseJob.cpp +++ /dev/null @@ -1,518 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "SynchronizationBaseJob.h" - -#include "core/collections/Collection.h" -#include "core/collections/QueryMaker.h" -#include "core/meta/Meta.h" -#include "core/meta/support/MetaConstants.h" -#include "core/support/Debug.h" - -#include -#include -#include - -//this class might cause SqlQueryMaker to generate very large SQL statements -//see http://dev.mysql.com/doc/refman/5.0/en/packet-too-large.html -//if it turns out that the generated SQL query is too large - -SynchronizationBaseJob::SynchronizationBaseJob() - : QObject() - , m_state( NotStarted ) - , m_currentResultCount( 0 ) - , m_collectionA( 0 ) - , m_collectionB( 0 ) -{ - connect( &m_timer, SIGNAL(timeout()), this, SLOT(timeout()) ); - //abort syncing if both queries have not returned within 30 seconds for a given state - //probably needs to be adjusted during testing - m_timer.setInterval( 30000 ); - m_timer.setSingleShot( true ); -} - -SynchronizationBaseJob::~SynchronizationBaseJob() -{ - //nothing to do -} - -void -SynchronizationBaseJob::setCollectionA( Collections::Collection *collection ) -{ - m_collectionA = collection; -} - -void -SynchronizationBaseJob::setCollectionB( Collections::Collection *collection ) -{ - m_collectionB = collection; -} - -void -SynchronizationBaseJob::setFilter( const QString &filter ) -{ - Q_UNUSED( filter ) -} - -Collections::QueryMaker* -SynchronizationBaseJob::createQueryMaker( Collections::Collection *collection ) -{ - //TODO: apply filters. This allows us to only sync a subset of a collection - Collections::QueryMaker *qm = collection->queryMaker(); - qm->setAutoDelete( true ); - m_queryMakers.insert( qm, collection ); - return qm; -} - -void -SynchronizationBaseJob::synchronize() -{ - DEBUG_BLOCK - if( !m_collectionA || !m_collectionB ) - { - debug() << "aborting synchronization, at least one collecton is missing"; - deleteLater(); - return; - } - m_state = ComparingArtists; - setupArtistQuery( m_collectionA )->run(); - setupArtistQuery( m_collectionB )->run(); - m_timer.start(); -} - -void -SynchronizationBaseJob::timeout() -{ - const QMetaObject *mo = metaObject(); - QMetaEnum me = mo->enumerator( mo->indexOfEnumerator( "State" ) ); - debug() << "syncing aborted due to a timeout in state " << me.valueToKey( m_state ); - deleteLater(); -} - -void -SynchronizationBaseJob::slotQueryDone() -{ - DEBUG_BLOCK; - m_currentResultCount += 1; - if( m_currentResultCount < 2 ) - return; - m_currentResultCount = 0; - - m_timer.stop(); - switch( m_state ) - { - case ComparingArtists: - { - m_state = ComparingAlbums; - handleArtistResult(); - break; - } - case ComparingAlbums: - { - m_state = ComparingTracks; - handleAlbumResult(); - break; - } - case ComparingTracks: - { - m_state = Syncing; - handleTrackResult(); - break; - } - default: - { - const QMetaObject *mo = metaObject(); - QMetaEnum me = mo->enumerator( mo->indexOfEnumerator( "State" ) ); - debug() << "detected state " << me.valueToKey( m_state ) << " in slotQueryDone(), do not know how to handle this. Aborting"; - deleteLater(); - break; - } - } -} - -Collections::QueryMaker* -SynchronizationBaseJob::setupArtistQuery( Collections::Collection *coll ) -{ - Collections::QueryMaker *qm = createQueryMaker( coll ); - qm->setQueryType( Collections::QueryMaker::Artist ); - connect( qm, SIGNAL(queryDone()), this, SLOT(slotQueryDone()), Qt::QueuedConnection ); - connect( qm, SIGNAL(newResultReady(Meta::ArtistList)), this, SLOT(slotResultReady(Meta::ArtistList)), Qt::QueuedConnection ); - return qm; -} - -Collections::QueryMaker* -SynchronizationBaseJob::setupAlbumQuery( Collections::Collection *coll ) -{ - Collections::QueryMaker *qm = createQueryMaker( coll ); - qm->setQueryType( Collections::QueryMaker::Album ); - connect( qm, SIGNAL(queryDone()), this, SLOT(slotQueryDone()), Qt::QueuedConnection ); - connect( qm, SIGNAL(newResultReady(Meta::AlbumList)), this, SLOT(slotResultReady(Meta::AlbumList)), Qt::QueuedConnection ); - return qm; -} - -Collections::QueryMaker* -SynchronizationBaseJob::setupTrackQuery( Collections::Collection *coll ) -{ - Collections::QueryMaker *qm = createQueryMaker( coll ); - qm->setQueryType( Collections::QueryMaker::Track ); - connect( qm, SIGNAL(queryDone()), this, SLOT(slotQueryDone()), Qt::QueuedConnection ); - connect( qm, SIGNAL(newResultReady(Meta::TrackList)), this, SLOT(slotResultReady(Meta::TrackList)), Qt::QueuedConnection ); - return qm; -} - -void -SynchronizationBaseJob::slotResultReady( const Meta::ArtistList &artists ) -{ - DEBUG_BLOCK; - Collections::Collection *senderColl = m_queryMakers.value( qobject_cast(sender()) ); - QSet artistSet; - foreach( const Meta::ArtistPtr &artist, artists ) - { - if( artist ) - artistSet.insert( artist->name() ); - } - if( senderColl == m_collectionA ) - { - m_artistsA.unite( artistSet ); - } - else if( senderColl == m_collectionB ) - { - m_artistsB.unite( artistSet ); - } - else - { - //huh? how did we get here? - } -} - -void -SynchronizationBaseJob::slotResultReady( const Meta::AlbumList &albums ) -{ - DEBUG_BLOCK - Collections::Collection *senderColl = m_queryMakers.value( qobject_cast(sender()) ); - QSet albumSet; - foreach( const Meta::AlbumPtr &albumPtr, albums ) - { - albumSet.insert( Meta::AlbumKey( albumPtr ) ); - } - if( senderColl == m_collectionA ) - { - m_albumsA.unite( albumSet ); - } - else if( senderColl == m_collectionB ) - { - m_albumsB.unite( albumSet ); - } - else - { - //huh? how did we get here? - } -} - -void -SynchronizationBaseJob::slotResultReady( const Meta::TrackList &tracks ) -{ - DEBUG_BLOCK - Collections::Collection *senderColl = m_queryMakers.value( qobject_cast(sender()) ); - if( senderColl == m_collectionA ) - { - - foreach( const Meta::TrackPtr &track, tracks ) - { - Meta::TrackKey key( track ); - m_tracksA.insert( key ); - m_keyToTrackA.insert( key, track ); - } - } - else if( senderColl == m_collectionB ) - { - foreach( const Meta::TrackPtr &track, tracks ) - { - Meta::TrackKey key( track ); - m_tracksB.insert( key ); - m_keyToTrackB.insert( key, track ); - } - } - else - { - //huh? how did we get here? - } -} - -void -SynchronizationBaseJob::handleArtistResult() -{ - DEBUG_BLOCK - QSet artistsOnlyInA = m_artistsA - m_artistsB; - QSet artistsOnlyInB = m_artistsB - m_artistsA; - QSet artistsInBoth = m_artistsA & m_artistsB; - foreach( const QString &artist, artistsOnlyInA ) - { - m_artistResult.insert( artist, OnlyInA ); - } - foreach( const QString &artist, artistsOnlyInB ) - { - m_artistResult.insert( artist, OnlyInB ); - } - foreach( const QString &artist, artistsInBoth ) - { - m_artistResult.insert( artist, InBoth ); - } - Collections::QueryMaker *qmA = setupAlbumQuery( m_collectionA ); - Collections::QueryMaker *qmB = setupAlbumQuery( m_collectionB ); - //we are going to exclude artists below, so make sure we exclude all of them by setting the QMs to And mode - qmA->beginAnd(); - qmB->beginAnd(); - QHashIterator iter( m_artistResult ); - while( iter.hasNext() ) - { - iter.next(); - QString artist = iter.key(); - InSet currentStatus = iter.value(); - if( currentStatus == OnlyInA ) - { - qmA->excludeFilter( Meta::valArtist, artist, true, true ); - } - if( currentStatus == OnlyInB ) - { - qmB->excludeFilter( Meta::valArtist, artist, true, true ); - } - } - qmA->endAndOr(); - qmB->endAndOr(); - m_timer.start(); - qmA->run(); - qmB->run(); -} - -void -SynchronizationBaseJob::handleAlbumResult() -{ - DEBUG_BLOCK - QSet albumsOnlyInA = m_albumsA - m_albumsB; - QSet albumsOnlyInB = m_albumsB - m_albumsA; - QSet albumsInBoth = m_albumsA & m_albumsB; - - foreach( const Meta::AlbumKey &album, albumsOnlyInA ) - { - m_albumResult.insert( album, OnlyInA ); - } - foreach( const Meta::AlbumKey &album, albumsOnlyInB ) - { - m_albumResult.insert( album, OnlyInB ); - } - foreach( const Meta::AlbumKey &album, albumsInBoth ) - { - m_albumResult.insert( album, InBoth ); - } - Collections::QueryMaker *qmA = setupTrackQuery( m_collectionA ); - Collections::QueryMaker *qmB = setupTrackQuery( m_collectionB ); - qmA->beginAnd(); - qmB->beginAnd(); - { - QHashIterator iter( m_artistResult ); - while( iter.hasNext() ) - { - iter.next(); - QString artist = iter.key(); - InSet currentStatus = iter.value(); - if( currentStatus == OnlyInA ) - { - qmA->excludeFilter( Meta::valArtist, artist, true, true ); - } - if( currentStatus == OnlyInB ) - { - qmB->excludeFilter( Meta::valArtist, artist, true, true ); - } - } - } - { - QHashIterator iter( m_albumResult ); - while( iter.hasNext() ) - { - iter.next(); - Meta::AlbumKey album = iter.key(); - InSet currentStatus = iter.value(); - if( currentStatus == OnlyInA ) - { - qmA->beginOr(); - qmA->excludeFilter( Meta::valAlbum, album.albumName(), true, true ); - qmA->excludeFilter( Meta::valAlbumArtist, album.artistName(), true, true ); - qmA->endAndOr(); - } - if( currentStatus == OnlyInB ) - { - qmB->beginOr(); - qmB->excludeFilter( Meta::valAlbum, album.albumName(), true, true ); - qmB->excludeFilter( Meta::valAlbumArtist, album.artistName(), true, true ); - qmB->endAndOr(); - } - } - } - qmA->endAndOr(); - qmB->endAndOr(); - m_timer.start(); - qmA->run(); - qmB->run(); -} - -void -SynchronizationBaseJob::handleTrackResult() -{ - DEBUG_BLOCK - QSet tracksOnlyInA = m_tracksA - m_tracksB; - QSet tracksOnlyInB = m_tracksB - m_tracksA; - - foreach( const Meta::TrackKey &key, tracksOnlyInA ) - { - m_trackResultOnlyInA << m_keyToTrackA.value( key ); - } - foreach( const Meta::TrackKey &key, tracksOnlyInB ) - { - m_trackResultOnlyInB << m_keyToTrackB.value( key ); - } - - //we have to make sure that we do not start queries that will return *all* tracks of the collection - //because we did not add any filter to it - bool haveToStartQueryA = false; - bool haveToStartQueryB = false; - - //we do not care about tracks in both collections - Collections::QueryMaker *qmA = createQueryMaker( m_collectionA ); - Collections::QueryMaker *qmB = createQueryMaker( m_collectionB ); - qmA->setQueryType( Collections::QueryMaker::Track ); - qmB->setQueryType( Collections::QueryMaker::Track ); - qmA->beginOr(); - qmB->beginOr(); - { - QHashIterator iter( m_artistResult ); - while( iter.hasNext() ) - { - iter.next(); - QString artist = iter.key(); - InSet currentStatus = iter.value(); - if( currentStatus == OnlyInA ) - { - qmA->addFilter( Meta::valArtist, artist, true, true ); - haveToStartQueryA = true; - } - if( currentStatus == OnlyInB ) - { - qmB->addFilter( Meta::valArtist, artist, true, true ); - haveToStartQueryB = true; - } - } - } - { - QHashIterator iter( m_albumResult ); - while( iter.hasNext() ) - { - iter.next(); - Meta::AlbumKey album = iter.key(); - InSet currentStatus = iter.value(); - if( currentStatus == OnlyInA ) - { - qmA->beginAnd(); - qmA->addFilter( Meta::valAlbum, album.albumName(), true, true ); - qmA->addFilter( Meta::valAlbumArtist, album.artistName(), true, true ); - qmA->endAndOr(); - haveToStartQueryA = true; - } - if( currentStatus == OnlyInB ) - { - qmB->beginAnd(); - qmB->addFilter( Meta::valAlbum, album.albumName(), true, true ); - qmB->addFilter( Meta::valAlbumArtist, album.artistName(), true, true ); - qmB->endAndOr(); - haveToStartQueryB = true; - } - } - } - qmA->endAndOr(); - qmB->endAndOr(); - connect( qmA, SIGNAL(newResultReady(Meta::TrackList)), this, SLOT(slotSyncTracks(Meta::TrackList)) ); - connect( qmB, SIGNAL(newResultReady(Meta::TrackList)), this, SLOT(slotSyncTracks(Meta::TrackList)) ); - connect( qmA, SIGNAL(queryDone()), this, SLOT(slotSyncQueryDone()) ); - connect( qmB, SIGNAL(queryDone()), this, SLOT(slotSyncQueryDone()) ); - m_timer.start(); - if( haveToStartQueryA ) - { - qmA->run(); - } - else - { - delete qmA; - m_currentResultCount += 1; - } - if( haveToStartQueryB ) - { - qmB->run(); - } - else - { - delete qmB; - m_currentResultCount += 1; - } - if( !( haveToStartQueryA || haveToStartQueryB ) ) - { - slotSyncQueryDone(); - } -} - -void -SynchronizationBaseJob::slotSyncTracks( const Meta::TrackList &tracks ) -{ - DEBUG_BLOCK - Collections::Collection *senderColl = m_queryMakers.value( qobject_cast(sender()) ); - if( senderColl == m_collectionA ) - { - m_trackResultOnlyInA << tracks; - } - else if( senderColl == m_collectionB ) - { - m_trackResultOnlyInB << tracks; - } - else - { - //huh? - debug() << "received data from unknown collection"; - } -} - -void -SynchronizationBaseJob::slotSyncQueryDone() -{ - DEBUG_BLOCK; - m_currentResultCount += 1; - if( m_currentResultCount < 2 ) - return; - m_currentResultCount = 0; - - m_timer.stop(); - if( m_state == Syncing ) - { - doSynchronization( m_trackResultOnlyInA, OnlyInA, m_collectionA, m_collectionB ); - doSynchronization( m_trackResultOnlyInB, OnlyInB, m_collectionA, m_collectionB ); - deleteLater(); - } - else - { - const QMetaObject *mo = metaObject(); - QMetaEnum me = mo->enumerator( mo->indexOfEnumerator( "State" ) ); - debug() << "detected state " << me.valueToKey( m_state ) << " in slotSyncQueryDone(), do not know how to handle this. Aborting"; - deleteLater(); - } -} diff --git a/amarok/src/synchronization/SynchronizationBaseJob.h b/amarok/src/synchronization/SynchronizationBaseJob.h deleted file mode 100644 index 54619b4b..00000000 --- a/amarok/src/synchronization/SynchronizationBaseJob.h +++ /dev/null @@ -1,122 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef SYNCHRONIZATIONBASEJOB_H -#define SYNCHRONIZATIONBASEJOB_H - -#include "core/meta/forward_declarations.h" -#include "core/meta/support/MetaKeys.h" - -#include -#include -#include -#include -#include -#include - -namespace Collections { - class Collection; - class QueryMaker; -} - -class SynchronizationBaseJob : public QObject -{ - Q_OBJECT - Q_ENUMS( State ) - Q_ENUMS( InSet ) - public: - enum State - { - NotStarted, - ComparingArtists, - ComparingAlbums, - ComparingTracks, - Syncing - }; - - enum InSet - { - OnlyInA, - OnlyInB, - InBoth - }; - - SynchronizationBaseJob(); - ~SynchronizationBaseJob(); - - void setFilter( const QString &filter ); - - - public slots: - virtual void synchronize(); - - private slots: - void slotResultReady( const Meta::TrackList &artists ); - void slotResultReady( const Meta::AlbumList &albums ); - void slotResultReady( const Meta::ArtistList &tracks ); - void slotQueryDone(); - void slotSyncTracks( const Meta::TrackList &tracks ); - void slotSyncQueryDone(); - - void timeout(); - - protected: - void setCollectionA( Collections::Collection *collection ); - void setCollectionB( Collections::Collection *collection ); - - /** - * perform the actual synchronization in this method. - * SynchronizationBaseJob will delete itself afterwards. - */ - virtual void doSynchronization( const Meta::TrackList &tracks, InSet syncDirection, Collections::Collection *collA, Collections::Collection *collB ) = 0; - - private: - Collections::QueryMaker* createQueryMaker( Collections::Collection *collection ); - - void handleAlbumResult(); - void handleArtistResult(); - void handleTrackResult(); - - private: - Collections::QueryMaker* setupArtistQuery( Collections::Collection *coll ); - Collections::QueryMaker* setupAlbumQuery( Collections::Collection *coll ); - Collections::QueryMaker* setupTrackQuery( Collections::Collection *coll ); - - State m_state; - int m_currentResultCount; - Collections::Collection *m_collectionA; - Collections::Collection *m_collectionB; - - /** All the query makers we created and the collection they belong to. */ - QHash m_queryMakers; - - QSet m_artistsA; - QSet m_artistsB; - QSet m_albumsA; - QSet m_albumsB; - QSet m_tracksA; - QSet m_tracksB; - QHash m_keyToTrackA; - QHash m_keyToTrackB; - QHash m_artistResult; - QHash m_albumResult; - Meta::TrackList m_trackResultOnlyInA; - Meta::TrackList m_trackResultOnlyInB; - QTimer m_timer; -}; - -#endif - diff --git a/amarok/src/synchronization/UnionJob.cpp b/amarok/src/synchronization/UnionJob.cpp deleted file mode 100644 index 8602044f..00000000 --- a/amarok/src/synchronization/UnionJob.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "UnionJob.h" - -#include "core/collections/Collection.h" -#include "core/collections/CollectionLocation.h" -#include "core/support/Debug.h" - -UnionJob::UnionJob( Collections::Collection *collA, Collections::Collection *collB ) - : SynchronizationBaseJob() -{ - DEBUG_BLOCK - setCollectionA( collA ); - setCollectionB( collB ); -} - -UnionJob::~UnionJob() -{ - //nothing to do -} - -void -UnionJob::doSynchronization( const Meta::TrackList &tracks, InSet syncDirection, Collections::Collection *collA, Collections::Collection *collB ) -{ - DEBUG_BLOCK - if( !( syncDirection == OnlyInA || syncDirection == OnlyInB ) ) - { - debug() << "warning, received an unexpected syncDirection"; - return; - } - Collections::Collection *from = ( syncDirection == OnlyInA ? collA : collB ); - Collections::Collection *to = ( syncDirection == OnlyInA ? collB : collA ); - - debug() << "Collection " << from->collectionId() << " has to sync " << tracks.count() << " track(s) to " << to->collectionId(); - //show confirmation dialog, actually do stuff - Collections::CollectionLocation *fromLoc = from->location(); - Collections::CollectionLocation *toLoc = to->location(); - - if( !toLoc->isWritable() ) - { - debug() << "Collection " << to->collectionId() << " is not writable"; - fromLoc->deleteLater(); - toLoc->deleteLater(); - } - else - { - fromLoc->prepareCopy( tracks, toLoc ); - } -} diff --git a/amarok/src/synchronization/UnionJob.h b/amarok/src/synchronization/UnionJob.h deleted file mode 100644 index 8c566f3d..00000000 --- a/amarok/src/synchronization/UnionJob.h +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef UNIONJOB_H -#define UNIONJOB_H - -#include "SynchronizationBaseJob.h" - -#include "core/meta/forward_declarations.h" - -#include -#include -#include - -namespace Amarok -{ - class Collection; -} - -/** - * @class UnionJob - * As the result of this job both collections contain the union - * of the tracks in both collections, i.e. it adds tracks that are in - * collection A but not in collection B to B and tracks that are in B but - * not in A to A. It does not remove tracks from either A or B. - */ -class UnionJob : public SynchronizationBaseJob -{ - Q_OBJECT - public: - UnionJob( Collections::Collection *collA, Collections::Collection *collB ); - virtual ~UnionJob(); - - protected: - void doSynchronization( const Meta::TrackList &tracks, InSet syncDirection, Collections::Collection *collA, Collections::Collection *collB ); -}; - - -#endif diff --git a/amarok/src/toolbar/CurrentTrackToolbar.cpp b/amarok/src/toolbar/CurrentTrackToolbar.cpp deleted file mode 100644 index 330f421c..00000000 --- a/amarok/src/toolbar/CurrentTrackToolbar.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "CurrentTrackToolbar.h" - -#include "EngineController.h" -#include "GlobalCurrentTrackActions.h" -#include "core/capabilities/ActionsCapability.h" -#include "core/capabilities/BookmarkThisCapability.h" -#include "core/meta/Meta.h" - - -CurrentTrackToolbar::CurrentTrackToolbar( QWidget * parent ) - : QToolBar( parent ) -{ - setToolButtonStyle( Qt::ToolButtonIconOnly ); - setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Preferred ); - //setIconDimensions( 16 ); - setContentsMargins( 0, 0, 0, 0 ); - - EngineController *engine = The::engineController(); - - connect( engine, SIGNAL(trackChanged(Meta::TrackPtr)), - this, SLOT(handleAddActions()) ); -} - -CurrentTrackToolbar::~CurrentTrackToolbar() -{} - -void CurrentTrackToolbar::handleAddActions() -{ - clear(); - - Meta::TrackPtr track = The::engineController()->currentTrack(); - - foreach( QAction* action, The::globalCurrentTrackActions()->actions() ) - addAction( action ); - - if( track ) - { - QScopedPointer< Capabilities::ActionsCapability > ac( track->create() ); - if( ac ) - { - QList currentTrackActions = ac->actions(); - foreach( QAction *action, currentTrackActions ) - { - if( !action->parent() ) - action->setParent( this ); - addAction( action ); - } - } - - QScopedPointer< Capabilities::BookmarkThisCapability > btc( track->create() ); - if( btc && btc->bookmarkAction() ) - addAction( btc->bookmarkAction() ); - } -} diff --git a/amarok/src/toolbar/CurrentTrackToolbar.h b/amarok/src/toolbar/CurrentTrackToolbar.h deleted file mode 100644 index 931df50a..00000000 --- a/amarok/src/toolbar/CurrentTrackToolbar.h +++ /dev/null @@ -1,37 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef CURRENTTRACKTOOLBAR_H -#define CURRENTTRACKTOOLBAR_H - -#include - -/** A toolbar that contains the CurrentTrackActions of the currently playing track. -*/ -class CurrentTrackToolbar : public QToolBar -{ - Q_OBJECT - -public: - CurrentTrackToolbar( QWidget * parent ); - - ~CurrentTrackToolbar(); - -protected slots: - void handleAddActions(); -}; - -#endif diff --git a/amarok/src/toolbar/MainToolbar.cpp b/amarok/src/toolbar/MainToolbar.cpp deleted file mode 100644 index 57904e02..00000000 --- a/amarok/src/toolbar/MainToolbar.cpp +++ /dev/null @@ -1,1029 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Thomas Luebking * - * Copyright (c) 2010 Mark Kretschmann * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "MainToolbar" - -#include "MainToolbar.h" - -#include "App.h" -#include "ActionClasses.h" -#include "core/support/Amarok.h" -#include "core/support/Debug.h" -#include "EngineController.h" -#include "GlobalCurrentTrackActions.h" -#include "MainWindow.h" -#include "SvgHandler.h" -#include "amarokconfig.h" -#include "amarokurls/AmarokUrl.h" -#include "amarokurls/AmarokUrlHandler.h" -#include "core/capabilities/ActionsCapability.h" -#include "core/capabilities/BookmarkThisCapability.h" -#include "core/meta/Meta.h" -#include "core/meta/support/MetaUtility.h" -#include "core-impl/capabilities/timecode/TimecodeLoadCapability.h" -#include "playlist/PlaylistActions.h" -#include "playlist/PlaylistModelStack.h" -#include "playlist/PlaylistController.h" -#include "widgets/AnimatedLabelStack.h" -#include "widgets/PlayPauseButton.h" -#include "widgets/SliderWidget.h" -#include "widgets/TrackActionButton.h" -#include "widgets/VolumeDial.h" - -#include -#include -#include - -#include -#include - -#include -#include -#include - -// #define prev_next_role QPalette::Link -#define prev_next_role foregroundRole() -static const int prevOpacity = 128; -static const int nextOpacity = 160; - -static const int icnSize = 48; - -static const int leftRightSpacer = 15; -static const int timeLabelMargin = 6; -static const int skipPadding = 6; -static const int skipMargin = 20; -static const int constant_progress_ratio_minimum_width = 640; -static const int space_between_tracks_and_slider = 2; -static const float track_fontsize_factor = 1.1f; -static const int track_action_spacing = 6; - - -MainToolbar::MainToolbar( QWidget *parent ) - : QToolBar( i18n( "Main Toolbar" ), parent ) - , m_lastTime( -1 ) - , m_trackBarAnimationTimer( 0 ) -{ - DEBUG_BLOCK - setObjectName( "MainToolbar" ); - - m_promoString = i18n( "Rediscover Your Music" ); - - // control padding between buttons and labels, it's style controlled by default - layout()->setSpacing( 0 ); - - EngineController *engine = The::engineController(); - - setIconSize( QSize( icnSize, icnSize ) ); - - QWidget *spacerWidget = new QWidget(this); - spacerWidget->setFixedWidth( leftRightSpacer ); - addWidget( spacerWidget ); - - m_playPause = new PlayPauseButton; - m_playPause->setPlaying( engine->isPlaying() ); - m_playPause->setFixedSize( icnSize, icnSize ); - addWidget( m_playPause ); - connect( m_playPause, SIGNAL(toggled(bool)), engine, SLOT(playPause()) ); - - QWidget *info = new QWidget(this); - QVBoxLayout *vl = new QVBoxLayout( info ); - - QFont fnt = QApplication::font(); // don't use the toolbar font. Often small to support icons only. - if( fnt.pointSize() > 0 ) - fnt.setPointSize( qRound(fnt.pointSize() * track_fontsize_factor) ); - const int fntH = QFontMetrics( QApplication::font() ).height(); - - m_skip_left = The::svgHandler()->renderSvg( "tiny_skip_left", 80*fntH/128, fntH, "tiny_skip_left" ); - m_skip_right = The::svgHandler()->renderSvg( "tiny_skip_right", 80*fntH/128, fntH, "tiny_skip_right" ); - - m_prev.key = 0; - m_prev.label = new AnimatedLabelStack(QStringList(), info); - m_prev.label->setFont( fnt ); - if( layoutDirection() == Qt::LeftToRight ) - m_prev.label->setPadding( m_skip_right.width() + skipPadding + skipMargin, 0 ); - else - m_prev.label->setPadding( 0, m_skip_right.width() + skipPadding + skipMargin ); - m_prev.label->setAlign( Qt::AlignLeft ); - m_prev.label->setAnimated( false ); - m_prev.label->setOpacity( prevOpacity ); - m_prev.label->installEventFilter( this ); - m_prev.label->setForegroundRole( prev_next_role ); - connect( m_prev.label, SIGNAL(clicked(QString)), The::playlistActions(), SLOT(back()) ); - - m_current.label = new AnimatedLabelStack( QStringList( m_promoString ), info ); - m_current.label->setFont( fnt ); - m_current.label->setPadding( 24, 24 ); - m_current.label->setBold( true ); - m_current.label->setLayout( new QHBoxLayout ); - m_current.label->installEventFilter( this ); - connect( m_current.label, SIGNAL(clicked(QString)), - Amarok::actionCollection()->action("show_active_track"), SLOT(trigger()) ); - - m_next.key = 0; - m_next.label = new AnimatedLabelStack(QStringList(), info); - m_next.label->setFont( fnt ); - if( layoutDirection() == Qt::LeftToRight ) - m_next.label->setPadding( 0, m_skip_left.width() + skipPadding + skipMargin ); - else - m_next.label->setPadding( m_skip_left.width() + skipPadding + skipMargin, 0 ); - m_next.label->setAlign( Qt::AlignRight ); - m_next.label->setAnimated( false ); - m_next.label->setOpacity( nextOpacity ); - m_next.label->installEventFilter( this ); - m_next.label->setForegroundRole( prev_next_role ); - connect( m_next.label, SIGNAL(clicked(QString)), The::playlistActions(), SLOT(next()) ); - - m_dummy.label = new AnimatedLabelStack(QStringList(), info); - m_next.label->setFont( fnt ); - m_dummy.label->hide(); - - vl->addItem( m_trackBarSpacer = new QSpacerItem(0, m_current.label->minimumHeight(), QSizePolicy::MinimumExpanding, QSizePolicy::Fixed ) ); - - vl->addSpacing( space_between_tracks_and_slider ); - - connect( m_prev.label, SIGNAL(pulsing(bool)), m_current.label, SLOT(setStill(bool)) ); - connect( m_next.label, SIGNAL(pulsing(bool)), m_current.label, SLOT(setStill(bool)) ); - - m_timeLabel = new QLabel( info ); - m_timeLabel->setAlignment( Qt::AlignVCenter | Qt::AlignRight ); - - m_slider = new Amarok::TimeSlider( info ); - connect( m_slider, SIGNAL(sliderReleased(int)), The::engineController(), SLOT(seekTo(int)) ); - connect( m_slider, SIGNAL(valueChanged(int)), SLOT(setLabelTime(int)) ); - connect( App::instance(), SIGNAL(settingsChanged()), SLOT(layoutProgressBar()) ); - - m_remainingTimeLabel = new QLabel( info ); - m_remainingTimeLabel->setAlignment( Qt::AlignVCenter | Qt::AlignLeft ); - - const int pbsH = qMax( m_timeLabel->sizeHint().height(), m_slider->sizeHint().height() ); - vl->addItem( m_progressBarSpacer = new QSpacerItem(0, pbsH, QSizePolicy::MinimumExpanding, QSizePolicy::Fixed ) ); - - addWidget( info ); - - m_volume = new VolumeDial( this ); - m_volume->setRange( 0, 100); - m_volume->setValue( engine->volume() ); - m_volume->setMuted( engine->isMuted() ); - m_volume->setFixedSize( icnSize, icnSize ); - m_volume->addWheelProxies( QList() << this << info - << m_prev.label << m_current.label << m_next.label - << m_timeLabel << m_remainingTimeLabel ); - - addWidget( m_volume ); - connect( engine, SIGNAL(volumeChanged(int)), m_volume, SLOT(setValue(int)) ); - connect( m_volume, SIGNAL(valueChanged(int)), engine, SLOT(setVolume(int)) ); - connect( m_volume, SIGNAL(muteToggled(bool)), engine, SLOT(setMuted(bool)) ); - - spacerWidget = new QWidget(this); - spacerWidget->setFixedWidth( leftRightSpacer ); - addWidget( spacerWidget ); -} - -void -MainToolbar::addBookmark( const QString &name, int milliSeconds ) -{ - if( m_slider ) - m_slider->drawTriangle( name, milliSeconds, false ); -} - -// Moves the label towards its target position by 2/3rds of the remaining distance -static void adjustLabelPos( QWidget *label, int targetX ) -{ - QRect r = label->geometry(); - int d = targetX - r.x(); - if( d ) - { - r.translate( qMin( qAbs(d), r.width()/6 ) * (d > 0 ? 1 : -1), 0 ); - label->setGeometry( r ); - } -} - -void -MainToolbar::animateTrackLabels() -{ - bool done = true; - - int off = -m_current.label->parentWidget()->geometry().x(); - adjustLabelPos( m_prev.label, m_prev.rect.x() + off ); - m_prev.label->setOpacity( prevOpacity ); - if(done) - done = m_prev.label->geometry().x() == m_prev.rect.x() + off; - - adjustLabelPos( m_current.label, m_current.rect.x() + off ); - if(done) - done = m_current.label->geometry().x() == m_current.rect.x() + off; - - adjustLabelPos( m_next.label, m_next.rect.x() + off ); - m_next.label->setOpacity( nextOpacity ); - if(done) - done = m_next.label->geometry().x() == m_next.rect.x() + off; - - adjustLabelPos( m_dummy.label, m_dummy.targetX ); - if( m_dummy.label->geometry().x() == m_dummy.targetX ) - m_dummy.label->hide(); - else - done = false; - - if( done ) - { - killTimer( m_trackBarAnimationTimer ); - setCurrentTrackActionsVisible( true ); - m_trackBarAnimationTimer = 0; - } -} - -void -MainToolbar::stopped() -{ - m_slider->setValue( m_slider->minimum() ); - m_slider->update(); // necessary to clean the moodbar... - setLabelTime( -1 ); - m_playPause->setPlaying( false ); -} - -void -MainToolbar::paused() -{ - m_playPause->setPlaying( false ); -} - -void -MainToolbar::playing() -{ - m_playPause->setPlaying( true ); -} - -void -MainToolbar::volumeChanged( int percent ) -{ - m_volume->setValue( percent ); -} - -void -MainToolbar::muteStateChanged( bool mute ) -{ - m_volume->setMuted( mute ); -} - -void -MainToolbar::layoutProgressBar() -{ - const int limit = constant_progress_ratio_minimum_width; - const QRect r = m_progressBarSpacer->geometry(); - - const int bw = AmarokConfig::showMoodbarInSlider() ? 10 : 6; - int w = bw; - if( size().width() < limit ) - { - w = (limit<<7)/size().width(); - w = w*w*w*bw; - w /= (1<<21); - } - - w = r.width() / w; - int tlW = m_timeLabel->width(); - if( tlW + timeLabelMargin > w ) - w = tlW; - int rtlW = m_remainingTimeLabel->width(); - if( rtlW + timeLabelMargin > w ) - w = rtlW; - - QRect pb = r.adjusted( w, 0, -w, 0 ); - m_slider->setGeometry( pb ); - - QRect tlR( 0, 0, tlW, r.height() ); - QRect rtlR( 0, 0, rtlW, r.height() ); - - if( layoutDirection() == Qt::LeftToRight ) - { - tlR.moveTopRight( pb.topLeft() - QPoint( timeLabelMargin, 0 ) ); - rtlR.moveTopLeft( pb.topRight() + QPoint( timeLabelMargin, 0 ) ); - } - else - { - rtlR.moveTopRight( pb.topLeft() - QPoint( timeLabelMargin, 0 ) ); - tlR.moveTopLeft( pb.topRight() + QPoint( timeLabelMargin, 0 ) ); - } - - m_timeLabel->setGeometry( tlR ); - m_remainingTimeLabel->setGeometry( rtlR ); -} - -void -MainToolbar::layoutTrackBar() -{ - m_dummy.label->hide(); - // this is the label parenting widge ("info") offset - const QPoint off = m_current.label->parentWidget()->geometry().topLeft(); - QRect r = m_trackBarSpacer->geometry(); - r.setWidth( r.width() / 3); - int d = r.width(); - - if( layoutDirection() == Qt::RightToLeft ) - { - d = -d; - r.moveRight( m_trackBarSpacer->geometry().right() ); - } - - m_prev.rect = r.translated( off ); - m_prev.label->setGeometry( r ); - m_prev.label->setOpacity( prevOpacity ); - - r.translate( d, 0 ); - m_current.rect = r.translated( off ); - m_current.label->setGeometry( r ); - - r.translate( d, 0 ); - m_next.rect = r.translated( off ); - m_next.label->setGeometry( r ); - m_next.label->setOpacity( nextOpacity ); - - setCurrentTrackActionsVisible( true ); -} - -void -MainToolbar::updateCurrentTrackActions() -{ - // wipe layout ================ - QLayoutItem *item; - while ( (item = m_current.label->layout()->takeAt(0)) ) - { - delete item->widget(); - delete item; - } - - // collect actions ================ - QList actions; - - foreach( QAction* action, The::globalCurrentTrackActions()->actions() ) - actions << action; - - Meta::TrackPtr track = The::engineController()->currentTrack(); - if( track ) - { - QScopedPointer< Capabilities::ActionsCapability > ac( track->create() ); - if( ac ) - actions << ac->actions(); - - QScopedPointer< Capabilities::BookmarkThisCapability > btc( track->create() ); - if( btc && btc->bookmarkAction() ) - actions << btc->bookmarkAction(); - } - - QHBoxLayout *hbl = static_cast( m_current.label->layout() ); - hbl->setContentsMargins( 0, 0, 0, 0 ); - hbl->setSpacing( track_action_spacing ); - - TrackActionButton *btn; - const int n = actions.count() / 2; - for ( int i = 0; i < actions.count(); ++i ) - { - if( i == n ) - hbl->addStretch( 10 ); - btn = new TrackActionButton( m_current.label, actions.at(i) ); - if( !actions.at(i)->parent() ) // see documentation of ActionsCapability::actions - actions.at(i)->setParent(btn); - btn->installEventFilter( this ); - hbl->addWidget( btn ); - } -} - -#define HAS_TAG(_TAG_) track->_TAG_() && !track->_TAG_()->name().isEmpty() -#define TAG(_TAG_) track->_TAG_()->prettyName() -#define CONTAINS_TAG(_TAG_) contains( TAG(_TAG_), Qt::CaseInsensitive ) - -static QStringList metadata( Meta::TrackPtr track ) -{ - QStringList list; - if( track ) - { - bool noTags = false; - QString title = track->prettyName(); - if(( noTags = title.isEmpty() )) // should not happen - title = track->prettyUrl(); - if(( noTags = title.isEmpty() )) // should never happen - title = track->playableUrl().url(); - if(( noTags = title.isEmpty() )) // sth's MEGA wrong ;-) - title = "???"; - - // no tags -> probably filename. try to strip the suffix - if( noTags || track->name().isEmpty() ) - { - noTags = true; - int dot = title.lastIndexOf('.'); - if( dot > 0 && title.length() - dot < 6 ) - title = title.left( dot ); - } - - // the track has no tags, is long or contains tags other than the titlebar - // ==> separate - if( noTags || title.length() > 50 || - (HAS_TAG(artist) && title.CONTAINS_TAG(artist)) || - (HAS_TAG(composer) && title.CONTAINS_TAG(composer)) || - (HAS_TAG(album) && title.CONTAINS_TAG(album)) ) - { - // this will split "all-in-one" filename tags - QRegExp rx("(\\s+-\\s+|\\s*;\\s*|\\s*:\\s*)"); - list << title.split( rx, QString::SkipEmptyParts ); - QList::iterator i = list.begin(); - bool ok; - while ( i != list.end() ) - { - // check whether this entry is only a number, i.e. probably year or track # - i->toInt( &ok ); - if( ok ) - i = list.erase( i ); - else - ++i; - } - } - else // plain title - { - list << title; - } - - if( HAS_TAG(artist) && !list.CONTAINS_TAG(artist) ) - list << TAG(artist); - else if( HAS_TAG(composer) && !list.CONTAINS_TAG(composer) ) - list << TAG(composer); - if( HAS_TAG(album) && !list.CONTAINS_TAG(album) ) - list << TAG(album); - - /* other tags - string year - string genre - double score - int rating - qint64 length // ms - int sampleRate - int bitrate - int trackNumber - int discNumber - uint lastPlayed - uint firstPlayed - int playCount - QString type - bool inCollection - */ - } - return list; -} - -#undef HAS_TAG -#undef TAG -#undef CONTAINS_TAG - -void -MainToolbar::updatePrevAndNext() -{ - if( !The::engineController()->currentTrack() ) - { - m_prev.key = 0L; - m_prev.label->setForegroundRole( foregroundRole() ); - m_prev.label->setOpacity( 96 ); - m_prev.label->setData( QStringList() ); // << "[ " + i18n("Previous") + " ]" ); - m_prev.label->setCursor( Qt::ArrowCursor ); - m_next.key = 0L; - m_next.label->setForegroundRole( foregroundRole() ); - m_next.label->setOpacity( 96 ); - m_next.label->setData( QStringList() ); // << "[ " + i18n("Next") + " ]" ); - m_next.label->setCursor( Qt::ArrowCursor ); - m_current.label->setUpdatesEnabled( true ); - return; - } - - // NOTICE: i don't like this, but the order is important. - // Reason is the (current) behaviour of the RandomTrackNavigator - // when the playlist is completed it will clear the history and reshuffle - // to be able to sneakpeak the next track, it's necessary to trigger this with this query - // if we'd query the previous track first, we'd get a track that's actually no more present after - // the next track query. by this order we'll get a 0L track, what's also the navigators opinion - // about its queue :-\ // - bool needUpdate = false; - bool hadKey = bool(m_next.key); - Meta::TrackPtr track = The::playlistActions()->likelyNextTrack(); - m_next.key = track ? track.data() : 0L; - m_next.label->setForegroundRole( prev_next_role ); - m_next.label->setOpacity( nextOpacity ); - m_next.label->setData( metadata( track ) ); - m_next.label->setCursor( track ? Qt::PointingHandCursor : Qt::ArrowCursor ); - if( hadKey != bool(m_next.key) ) - needUpdate = true; - - hadKey = bool(m_prev.key); - track = The::playlistActions()->likelyPrevTrack(); - m_prev.key = track ? track.data() : 0L; - m_prev.label->setForegroundRole( prev_next_role ); - m_next.label->setOpacity( prevOpacity ); - m_prev.label->setData( metadata( track ) ); - m_prev.label->setCursor( track ? Qt::PointingHandCursor : Qt::ArrowCursor ); - if( hadKey != bool(m_prev.key) ) - needUpdate = true; - - // we may have disabled it as otherwise the current label gets updated one eventcycle before prev & next - // see ::engineTrackChanged() - m_current.label->setUpdatesEnabled( true ); - - if( needUpdate ) - update(); - - // unanimated change, probably by sliding the bar - fix label positions - if( !m_trackBarAnimationTimer ) - layoutTrackBar(); -} - -void -MainToolbar::updateBookmarks( const QString *BookmarkName ) -{ - // DEBUG_BLOCK - m_slider->clearTriangles(); - if( Meta::TrackPtr track = The::engineController()->currentTrack() ) - { - if( track->has() ) - { - Capabilities::TimecodeLoadCapability *tcl = track->create(); - BookmarkList list = tcl->loadTimecodes(); - // debug() << "found " << list.count() << " timecodes on this track"; - foreach( AmarokUrlPtr url, list ) - { - if( url->command() == "play" && url->args().keys().contains( "pos" ) ) - { - int pos = url->args().value( "pos" ).toDouble() * 1000; - debug() << "showing timecode: " << url->name() << " at " << pos ; - m_slider->drawTriangle( url->name(), pos, ( BookmarkName && BookmarkName == url->name() ) ); - } - } - delete tcl; - } - } -} - -void -MainToolbar::trackChanged( Meta::TrackPtr track ) -{ - if( !isVisible() || (m_trackBarAnimationTimer && track && track.data() == m_current.key) ) - return; - if( m_trackBarAnimationTimer ) - { - killTimer( m_trackBarAnimationTimer ); - m_trackBarAnimationTimer = 0; - } - - if( track ) - { - m_current.key = track.data(); - m_current.uidUrl = track->uidUrl(); - m_current.label->setUpdatesEnabled( false ); - m_current.label->setData( metadata( track ) ); - m_current.label->setCursor( Qt::PointingHandCursor ); - - // If all labels are in position and this is a single step for or back, we perform a slide - // on the other two labels, i.e. e.g. move the prev to current label position and current - // to the next and the animate the move into their target positions - QRect r = m_trackBarSpacer->geometry(); - r.setWidth( r.width() / 3 ); - int d = r.width(); - - if( layoutDirection() == Qt::RightToLeft ) - { - d = -d; - r.moveRight( m_trackBarSpacer->geometry().right() ); - } - - if( isVisible() && m_current.label->geometry().x() == r.x() + d ) - { - if( m_current.key == m_next.key && m_current.key != m_prev.key ) - { - setCurrentTrackActionsVisible( false ); - - // left - m_dummy.targetX = r.x() - d; -// if( d < 0 ) // rtl -// m_dummy.targetX -= d; - m_dummy.label->setGeometry( r ); - m_dummy.label->setData( m_prev.label->data() ); - m_dummy.label->show(); - // center - r.translate( d, 0 ); - m_prev.label->setGeometry( r ); - // right - r.translate( d, 0 ); - m_current.label->setGeometry( r ); - m_next.label->setGeometry( r ); - m_next.label->setOpacity( 0 ); - m_next.label->raise(); - - animateTrackLabels(); - m_trackBarAnimationTimer = startTimer( 40 ); - } - else if( m_current.key == m_prev.key ) - { - setCurrentTrackActionsVisible( false ); - - // left - m_prev.label->setGeometry( r ); - m_current.label->setGeometry( r ); - // center - r.translate( d, 0 ); - m_next.label->setGeometry( r ); - - // right - r.translate( d, 0 ); - m_dummy.targetX = r.x() + d; - m_dummy.label->setGeometry( r ); - m_dummy.label->setData( m_next.label->data() ); - m_dummy.label->show(); - - m_prev.label->setOpacity( 0 ); - m_prev.label->raise(); - - animateTrackLabels(); - m_trackBarAnimationTimer = startTimer( 40 ); - } - } - trackLengthChanged( The::engineController()->trackLength() ); - } - else - { - // no track - setLabelTime( -1 ); - m_slider->setValue( m_slider->minimum() ); - m_current.key = 0L; - m_current.uidUrl.clear(); - m_current.label->setData( QStringList( m_promoString ) ); - m_current.label->setCursor( Qt::ArrowCursor ); - } - - updateCurrentTrackActions(); - - m_trackBarSpacer->changeSize(0, m_current.label->minimumHeight(), QSizePolicy::MinimumExpanding, QSizePolicy::Fixed ); - const int pbsH = qMax( m_timeLabel->sizeHint().height(), m_slider->sizeHint().height() ); - m_progressBarSpacer->changeSize(0, pbsH, QSizePolicy::MinimumExpanding, QSizePolicy::Fixed ); - - QTimer::singleShot( 0, this, SLOT(updatePrevAndNext()) ); -} - -void -MainToolbar::trackLengthChanged( qint64 ms ) -{ - m_slider->setRange( 0, ms ); - m_slider->setEnabled( ms > 0 ); - - // get the urlid of the current track as the engine might stop and start several times - // when skipping last.fm tracks, so we need to know if we are still on the same track... - if( Meta::TrackPtr track = The::engineController()->currentTrack() ) - m_current.uidUrl = track->uidUrl(); - - updateBookmarks( 0 ); -} - -void -MainToolbar::trackPositionChanged( qint64 position, bool /*userSeek*/ ) -{ - if( m_slider->isEnabled() ) - m_slider->setSliderValue( position ); - else - setLabelTime( position ); -} - -void -MainToolbar::showEvent( QShowEvent *ev ) -{ - EngineController *engine = The::engineController(); - - connect( engine, SIGNAL(stopped(qint64,qint64)), - this, SLOT(stopped()) ); - connect( engine, SIGNAL(paused()), - this, SLOT(paused()) ); - connect( engine, SIGNAL(trackPlaying(Meta::TrackPtr)), - this, SLOT(playing()) ); - - connect( engine, SIGNAL(trackChanged(Meta::TrackPtr)), - this, SLOT(trackChanged(Meta::TrackPtr)) ); - connect( engine, SIGNAL(trackMetadataChanged(Meta::TrackPtr)), - this, SLOT(trackChanged(Meta::TrackPtr)) ); - connect( engine, SIGNAL(trackLengthChanged(qint64)), - this, SLOT(trackLengthChanged(qint64)) ); - connect( engine, SIGNAL(trackPositionChanged(qint64,bool)), - this, SLOT(trackPositionChanged(qint64,bool)) ); - connect( engine, SIGNAL(volumeChanged(int)), - this, SLOT(volumeChanged(int)) ); - connect( engine, SIGNAL(muteStateChanged(bool)), - this, SLOT(muteStateChanged(bool)) ); - - // We need the three changed signals: - // 1. the playlist changes (PlaylistController) - // 2. the sorting of the playlist changed (Playlist) - // 3. The navigator changed to e.g. dynamic mode (PlaylistActions) - - connect( The::playlistController(), SIGNAL(changed()), - this, SLOT(updatePrevAndNext()) ); - - connect( The::playlist()->qaim(), SIGNAL(queueChanged()), - this, SLOT(updatePrevAndNext()) ); - - connect( The::playlistActions(), SIGNAL(navigatorChanged()), - this, SLOT(updatePrevAndNext()) ); - - connect( The::amarokUrlHandler(), SIGNAL(timecodesUpdated(const QString*)), - this, SLOT(updateBookmarks(const QString*)) ); - connect( The::amarokUrlHandler(), SIGNAL(timecodeAdded(QString,int)), - this, SLOT(addBookmark(QString,int)) ); - - QToolBar::showEvent( ev ); - trackChanged( The::engineController()->currentTrack() ); - layoutTrackBar(); - layoutProgressBar(); - m_playPause->setPlaying( The::engineController()->isPlaying() ); - trackPositionChanged( engine->trackPositionMs(), false ); // Refresh slider on restore -} - - -void -MainToolbar::hideEvent( QHideEvent *ev ) -{ - QToolBar::hideEvent( ev ); - - disconnect( The::engineController(), 0, this, 0 ); - - disconnect( The::playlistController(), SIGNAL(changed()), - this, SLOT(updatePrevAndNext()) ); - - disconnect( The::playlist()->qaim(), SIGNAL(queueChanged()), - this, SLOT(updatePrevAndNext()) ); - - disconnect( The::playlistActions(), SIGNAL(navigatorChanged()), - this, SLOT(updatePrevAndNext()) ); - - disconnect( The::amarokUrlHandler(), SIGNAL(timecodesUpdated(const QString*)), - this, SLOT(updateBookmarks(const QString*)) ); - disconnect( The::amarokUrlHandler(), SIGNAL(timecodeAdded(QString,int)), - this, SLOT(addBookmark(QString,int)) ); -} - -void -MainToolbar::paintEvent( QPaintEvent *ev ) -{ - // let the style paint draghandles and in doubt override the shadow from above - QToolBar::paintEvent( ev ); - - // skip icons - QPainter p( this ); - Skip *left = &m_prev; - Skip *right = &m_next; - - if( layoutDirection() == Qt::RightToLeft ) - { - left = &m_next; - right = &m_prev; - } - - if( left->key ) - p.drawPixmap( left->rect.left() + skipMargin, - left->rect.y() + ( left->rect.height() - m_skip_left.height() ) /2, - m_skip_left ); - if( right->key ) - p.drawPixmap( right->rect.right() - ( m_skip_right.width() + skipMargin ), - right->rect.y() + ( right->rect.height() - m_skip_right.height() ) /2, - m_skip_right ); - p.end(); -} - - -void -MainToolbar::resizeEvent( QResizeEvent *ev ) -{ - if( ev->size().width() > 0 && ev->size().width() != ev->oldSize().width() ) - { - layoutProgressBar(); - layoutTrackBar(); - } -} - -void -MainToolbar::setCurrentTrackActionsVisible( bool vis ) -{ - if( m_current.actionsVisible == vis ) - return; - m_current.actionsVisible = vis; - QLayoutItem *item; - for ( int i = 0; i < m_current.label->layout()->count(); ++i ) - { - item = m_current.label->layout()->itemAt( i ); - if( item->widget() ) - item->widget()->setVisible( vis ); - } -} - -const char * timeString[4] = { "3:33", "33:33", "3:33:33", "33:33:33" }; - -static inline int -timeFrame( int secs ) -{ - if( secs < 10*60 ) // 9:59 - return 0; - if( secs < 60*60 ) // 59:59 - return 1; - if( secs < 10*60*60 ) // 9:59:59 - return 2; - return 3; // 99:59:59 -} - -void -MainToolbar::setLabelTime( int ms ) -{ - bool relayout = false; - if( ms < 0 ) // clear - { - m_timeLabel->hide(); - m_remainingTimeLabel->hide(); - m_lastTime = -1; - m_lastRemainingTime = -1; - relayout = true; - } - else if( isVisible() ) // no need to do expensive stuff - it's updated every second anyway - { - - const int secs = ms/1000; - const int remainingSecs = m_slider->maximum() > 0 ? (m_slider->maximum() - ms) / 1000 : 0; - - if( secs == m_lastTime && remainingSecs == m_lastRemainingTime ) - return; - - m_timeLabel->setText( Meta::secToPrettyTime( secs ) ); - - // -- determine fix the timeLabel width at a sensible maximum - int tf = timeFrame( secs ); - if( m_lastTime < 0 || tf != timeFrame( m_lastTime ) ) - { - const int w = QFontMetrics( m_timeLabel->font() ).width( timeString[tf] ); - m_timeLabel->setFixedWidth( w ); - relayout = true; - } - m_timeLabel->show(); - - if( remainingSecs > 0 ) - { - m_remainingTimeLabel->setText( '-' + Meta::secToPrettyTime( remainingSecs ) ); - tf = timeFrame( remainingSecs ); - if( m_lastRemainingTime < 0 || tf != timeFrame( m_lastRemainingTime ) ) - { - const int w = QFontMetrics( m_remainingTimeLabel->font() ).width( QString("-") + timeString[tf] ); - m_remainingTimeLabel->setFixedWidth( w ); - relayout = true; - } - m_remainingTimeLabel->show(); - } - else - m_remainingTimeLabel->hide(); - - m_lastTime = secs; - m_lastRemainingTime = remainingSecs; - - } - - if(relayout) - layoutProgressBar(); -} - -void -MainToolbar::timerEvent( QTimerEvent *ev ) -{ - if( ev->timerId() == m_trackBarAnimationTimer ) - animateTrackLabels(); - else - QToolBar::timerEvent( ev ); -} - -bool -MainToolbar::eventFilter( QObject *o, QEvent *ev ) -{ - if( ev->type() == QEvent::MouseMove ) - { - QMouseEvent *mev = static_cast(ev); - if( mev->buttons() & Qt::LeftButton ) - if( o == m_current.label || o == m_prev.label || o == m_next.label ) - { - setCurrentTrackActionsVisible( false ); - const int x = mev->globalPos().x(); - int d = x - m_drag.lastX; - m_drag.lastX = x; - const int globalDist = qAbs( x - m_drag.startX ); - if( globalDist > m_drag.max ) - m_drag.max = globalDist; - if( globalDist > m_prev.label->width() ) - return false; // constrain to one item width - - m_current.label->setGeometry( m_current.label->geometry().translated( d, 0 ) ); - m_prev.label->setGeometry( m_prev.label->geometry().translated( d, 0 ) ); - m_next.label->setGeometry( m_next.label->geometry().translated( d, 0 ) ); - } - return false; - } - if( ev->type() == QEvent::MouseButtonPress ) - { - QMouseEvent *mev = static_cast(ev); - if( mev->button() == Qt::LeftButton ) - if( o == m_current.label || o == m_prev.label || o == m_next.label ) - { - static_cast(o)->setCursor( Qt::SizeHorCursor ); - m_drag.max = 0; - m_drag.lastX = m_drag.startX = mev->globalPos().x(); - } - return false; - } - if( ev->type() == QEvent::MouseButtonRelease ) - { - QMouseEvent *mev = static_cast(ev); - if( mev->button() == Qt::LeftButton ) - if( o == m_current.label || o == m_prev.label || o == m_next.label ) - { - const int x = mev->globalPos().x(); - const int d = m_drag.startX - x; - QRect r = m_trackBarSpacer->geometry(); - const int limit = r.width()/5; // 1/3 is too much, 1/6 to few - - // reset cursor - AnimatedLabelStack *l = static_cast(o); - l->setCursor( l->data().isEmpty() ? Qt::ArrowCursor : Qt::PointingHandCursor ); - - // if this was a _real_ drag, silently release the mouse - const bool silentRelease = m_drag.max > 25; - if( silentRelease ) - { // this is a drag, release secretly - o->blockSignals( true ); - o->removeEventFilter( this ); - QMouseEvent mre( QEvent::MouseButtonRelease, mev->pos(), mev->globalPos(), - Qt::LeftButton, Qt::LeftButton, Qt::NoModifier ); - QCoreApplication::sendEvent( o, &mre ); - o->installEventFilter( this ); - o->blockSignals( false ); - } - - // if moved "far enough" jump to prev/next track - // NOTICE the labels shall snap back _after_ the track has changed (in case) - // as this is not reliable, we force a timered snapback sa well - if( d > limit ) - { - The::playlistActions()->next(); - QTimer::singleShot(500, this, SLOT(layoutTrackBar()) ); - } - else if( d < -limit ) - { - The::playlistActions()->back(); - QTimer::singleShot(500, this, SLOT(layoutTrackBar()) ); - } - else - layoutTrackBar(); - - return silentRelease; - } - return false; - } - - if( ev->type() == QEvent::Enter ) - { - if(o == m_next.label && m_next.key) - m_next.label->setOpacity( 255 ); - else if(o == m_prev.label && m_prev.key) - m_prev.label->setOpacity( 255 ); - else if( o->parent() == m_current.label ) // trackaction - { - QEvent e( QEvent::Leave ); - QCoreApplication::sendEvent( m_current.label, &e ); - } - return false; - } - if( ev->type() == QEvent::Leave ) - { - if(o == m_next.label && m_next.key) - m_next.label->setOpacity( nextOpacity ); - else if(o == m_prev.label && m_prev.key) - m_prev.label->setOpacity( prevOpacity ); - else if( o->parent() == m_current.label && // trackaction - m_current.label->rect().contains( m_current.label->mapFromGlobal(QCursor::pos()) ) ) - { - QEvent e( QEvent::Enter ); - QCoreApplication::sendEvent( m_current.label, &e ); - } - return false; - } - return false; -} - - -#include "moc_MainToolbar.cpp" diff --git a/amarok/src/toolbar/MainToolbar.h b/amarok/src/toolbar/MainToolbar.h deleted file mode 100644 index 77f21e8e..00000000 --- a/amarok/src/toolbar/MainToolbar.h +++ /dev/null @@ -1,124 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Thomas Luebking * - * Copyright (c) 2010 Mark Kretschmann * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef MAINTOOLBAR3G_H -#define MAINTOOLBAR3G_H - -class AnimatedLabelStack; -class PlayPauseButton; -class QBoxLayout; -class QLabel; -class QSpacerItem; -class VolumeDial; - -namespace Amarok { class TimeSlider; } - -#include "core/meta/forward_declarations.h" -#include - -class MainToolbar : public QToolBar -{ - Q_OBJECT - -public: - MainToolbar( QWidget *parent = 0 ); - -protected: - bool eventFilter( QObject *o, QEvent *ev ); - void showEvent( QShowEvent *ev ); - void hideEvent( QHideEvent *ev ); - void paintEvent( QPaintEvent *ev ); - void resizeEvent( QResizeEvent *ev ); - void timerEvent( QTimerEvent *ev ); - -private: - void animateTrackLabels(); - void setCurrentTrackActionsVisible( bool ); - void updateCurrentTrackActions(); - -private slots: - void stopped(); - void paused(); - void playing(); - void trackChanged( Meta::TrackPtr track ); - void trackLengthChanged( qint64 ms ); - void trackPositionChanged( qint64 position, bool userSeek ); - - void muteStateChanged( bool mute ); - void volumeChanged( int percent ); - void addBookmark( const QString &name, int milliSeconds ); - void layoutProgressBar(); - void layoutTrackBar(); - void setLabelTime( int ms ); - void updateBookmarks( const QString *BookmarkName ); - void updatePrevAndNext(); - -private: - PlayPauseButton *m_playPause; - - QSpacerItem *m_trackBarSpacer; - QSpacerItem *m_progressBarSpacer; - - QPixmap m_skip_left, m_skip_right; - - struct Current - { - Current() : label(0), key(0), actionsVisible(false) {} - AnimatedLabelStack *label; - void* key; - QString uidUrl; - bool actionsVisible; - QRect rect; - } m_current; - - struct Skip - { - Skip() : label(0), key(0) {} - AnimatedLabelStack *label; - void* key; - QRect rect; - }; - - Skip m_next, m_prev; - - struct Dummy - { - Dummy() : label(0), targetX(0) {} - AnimatedLabelStack *label; - int targetX; - } m_dummy; - - QLabel *m_timeLabel, *m_remainingTimeLabel; - Amarok::TimeSlider *m_slider; - - VolumeDial *m_volume; - - int m_lastTime; - int m_lastRemainingTime; - - struct - { - int startX; - int lastX; - int max; - } m_drag; - int m_trackBarAnimationTimer; - - QString m_promoString; -}; - -#endif diff --git a/amarok/src/toolbar/SlimToolbar.cpp b/amarok/src/toolbar/SlimToolbar.cpp deleted file mode 100644 index 04b7d448..00000000 --- a/amarok/src/toolbar/SlimToolbar.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * Copyright (c) 2009 Mark Kretschmann * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "SlimToolbar.h" - -#include "ActionClasses.h" -#include "core/support/Amarok.h" -#include "EngineController.h" -#include "VolumePopupButton.h" - -#include "widgets/ProgressWidget.h" - -#include -#include -#include -#include - -#include -#include - -SlimToolbar::SlimToolbar( QWidget * parent ) - : QToolBar( i18n( "Slim Toolbar" ), parent ) - , m_currentTrackToolbar( 0 ) - , m_volumePopupButton( 0 ) -{ - setObjectName( "Slim Toolbar" ); - - setIconSize( QSize( 28, 28 ) ); - layout()->setSpacing( 0 ); - setContentsMargins( 0, 0, 0, 0 ); - - addAction( Amarok::actionCollection()->action( "prev" ) ); - addAction( Amarok::actionCollection()->action( "play_pause" ) ); - addAction( Amarok::actionCollection()->action( "stop" ) ); - addAction( Amarok::actionCollection()->action( "next" ) ); - - m_currentTrackToolbar = new CurrentTrackToolbar( 0 ); - - addWidget( m_currentTrackToolbar ); - - ProgressWidget *progressWidget = new ProgressWidget( 0 ); - addWidget( progressWidget ); - - - QToolBar *volumeToolBar = new QToolBar( this ); - volumeToolBar->setIconSize( QSize( 22, 22 ) ); - volumeToolBar->setContentsMargins( 0, 0, 0, 0 ); - m_volumePopupButton = new VolumePopupButton( this ); - volumeToolBar->addWidget( m_volumePopupButton ); - addWidget( volumeToolBar ); - - installEventFilter( this ); -} - -SlimToolbar::~SlimToolbar() -{} - -bool -SlimToolbar::eventFilter( QObject* object, QEvent* event ) -{ - // This makes it possible to change volume by using the mouse wheel anywhere on the toolbar - if( event->type() == QEvent::Wheel && object == this ) - { - kapp->sendEvent( m_volumePopupButton, event ); - return true; - } - - return QToolBar::eventFilter( object, event ); -} - -#include "moc_SlimToolbar.cpp" - diff --git a/amarok/src/toolbar/SlimToolbar.h b/amarok/src/toolbar/SlimToolbar.h deleted file mode 100644 index 2a89a19c..00000000 --- a/amarok/src/toolbar/SlimToolbar.h +++ /dev/null @@ -1,46 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * Copyright (c) 2009 Mark Kretschmann * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef SLIMTOOLBAR_H -#define SLIMTOOLBAR_H - -#include "CurrentTrackToolbar.h" - -#include - -class QEvent; -class VolumePopupButton; - -/** - An new toolbar implementation. -*/ -class SlimToolbar : public QToolBar -{ - Q_OBJECT - -public: - SlimToolbar( QWidget * parent ); - ~SlimToolbar(); - - virtual bool eventFilter( QObject* object, QEvent* event ); - -private: - CurrentTrackToolbar * m_currentTrackToolbar; - VolumePopupButton* m_volumePopupButton; -}; - -#endif diff --git a/amarok/src/toolbar/VolumePopupButton.cpp b/amarok/src/toolbar/VolumePopupButton.cpp deleted file mode 100644 index e06d2388..00000000 --- a/amarok/src/toolbar/VolumePopupButton.cpp +++ /dev/null @@ -1,163 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * Copyright (c) 2009 Mark Kretschmann * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "VolumePopupButton.h" - -#include "ActionClasses.h" -#include "EngineController.h" -#include "core/support/Amarok.h" -#include "widgets/SliderWidget.h" - -#include -#include - -#include -#include -#include -#include -#include -#include - - -VolumePopupButton::VolumePopupButton( QWidget * parent ) - : QToolButton( parent ) -{ - //create the volume popup - m_volumeMenu = new QMenu( this ); - - KVBox * mainBox = new KVBox( this ); - - m_volumeLabel= new QLabel( mainBox ); - m_volumeLabel->setAlignment( Qt::AlignHCenter ); - - KHBox * sliderBox = new KHBox( mainBox ); - m_volumeSlider = new Amarok::VolumeSlider( Amarok::VOLUME_MAX, sliderBox, false ); - m_volumeSlider->setFixedHeight( 170 ); - mainBox->setMargin( 0 ); - mainBox->setSpacing( 0 ); - sliderBox->setSpacing( 0 ); - sliderBox->setMargin( 0 ); - mainBox->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Fixed ); - sliderBox->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Fixed ); - - EngineController* ec = The::engineController(); - - QWidgetAction * sliderActionWidget = new QWidgetAction( this ); - sliderActionWidget->setDefaultWidget( mainBox ); - - connect( m_volumeSlider, SIGNAL(sliderMoved(int)), ec, SLOT(setVolume(int)) ); - connect( m_volumeSlider, SIGNAL(sliderReleased(int)), ec, SLOT(setVolume(int)) ); - - QToolBar *muteBar = new QToolBar( QString(), mainBox ); - muteBar->setContentsMargins( 0, 0, 0, 0 ); - muteBar->setIconSize( QSize( 16, 16 ) ); - m_muteAction = new QAction( KIcon( "audio-volume-muted" ), QString(), muteBar ); - m_muteAction->setCheckable ( true ); - m_muteAction->setChecked( ec->isMuted() ); - - connect( m_muteAction, SIGNAL(toggled(bool)), ec, SLOT(setMuted(bool)) ); - - m_volumeMenu->addAction( sliderActionWidget ); - muteBar->addAction( m_muteAction ); - - //set correct icon and label initially - volumeChanged( ec->volume() ); - - connect( ec, SIGNAL(volumeChanged(int)), - this, SLOT(volumeChanged(int)) ); - - connect( ec, SIGNAL(muteStateChanged(bool)), - this, SLOT(muteStateChanged(bool)) ); - -} - -void -VolumePopupButton::volumeChanged( int newVolume ) -{ - if ( newVolume < 34 ) - setIcon( KIcon( "audio-volume-low" ) ); - else if ( newVolume < 67 ) - setIcon( KIcon( "audio-volume-medium" ) ); - else - setIcon( KIcon( "audio-volume-high" ) ); - - m_volumeLabel->setText( QString::number( newVolume ) + '%' ); - - if( newVolume != m_volumeSlider->value() ) - m_volumeSlider->setValue( newVolume ); - - //make sure to uncheck mute toolbar when moving slider - if ( newVolume ) - m_muteAction->setChecked( false ); - - const KLocalizedString tip = m_muteAction->isChecked() ? ki18n( "Volume: %1% (muted)" ) : ki18n( "Volume: %1%" ); - setToolTip( tip.subs( newVolume ).toString() ); -} - -void -VolumePopupButton::muteStateChanged( bool muted ) -{ - const int volume = The::engineController()->volume(); - - if ( muted ) - { - setIcon( KIcon( "audio-volume-muted" ) ); - setToolTip( i18n( "Volume: %1% (muted)", volume ) ); - } - else - { - volumeChanged( volume ); - } - - m_muteAction->setChecked( muted ); -} - -void -VolumePopupButton::mouseReleaseEvent( QMouseEvent * event ) -{ - if( event->button() == Qt::LeftButton ) - { - if ( m_volumeMenu->isVisible() ) - m_volumeMenu->hide(); - else - { - const QPoint pos( 0, height() ); - m_volumeMenu->exec( mapToGlobal( pos ) ); - } - } - else if( event->button() == Qt::MidButton ) - { - The::engineController()->toggleMute(); - } - - QToolButton::mouseReleaseEvent( event ); -} - -void -VolumePopupButton::wheelEvent( QWheelEvent * event ) -{ - //debug() << "delta: " << event->delta(); - event->accept(); - - EngineController* const ec = The::engineController(); - - const int volume = qBound( 0, ec->volume() + event->delta() / 40 , 100 ); - ec->setVolume( volume ); -} - - -#include "moc_VolumePopupButton.cpp" diff --git a/amarok/src/toolbar/VolumePopupButton.h b/amarok/src/toolbar/VolumePopupButton.h deleted file mode 100644 index 239e90c0..00000000 --- a/amarok/src/toolbar/VolumePopupButton.h +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * Copyright (c) 2009 Mark Kretschmann * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef VOLUMEPOPUPBUTTON_H -#define VOLUMEPOPUPBUTTON_H - -#include - -class QAction; -class QEvent; -class QLabel; -class QMenu; -class QMouseEvent; -class QWheelEvent; - -namespace Amarok { class VolumeSlider; } - - -class VolumePopupButton : public QToolButton -{ - Q_OBJECT - -public: - VolumePopupButton( QWidget * parent ); - -protected: - virtual void mouseReleaseEvent( QMouseEvent * event ); - virtual void wheelEvent( QWheelEvent * event ); - -private Q_SLOTS: - void volumeChanged( int newVolume ); - void muteStateChanged( bool muted ); - -private: - QLabel * m_volumeLabel; - QMenu * m_volumeMenu; - Amarok::VolumeSlider * m_volumeSlider; - QAction * m_muteAction; -}; - -#endif // VOLUMEPOPUPBUTTON_H diff --git a/amarok/src/transcoding/CMakeLists.txt b/amarok/src/transcoding/CMakeLists.txt deleted file mode 100644 index d8c0c2cd..00000000 --- a/amarok/src/transcoding/CMakeLists.txt +++ /dev/null @@ -1,36 +0,0 @@ - -include_directories( - . - ${CMAKE_SOURCE_DIR}/src - ${CMAKE_SOURCE_DIR}/utilities - ${CMAKE_BINARY_DIR}/src - ${KDE4_INCLUDE_DIR} - ${QT_INCLUDES} -) - -set(amarok_transcoding_SRCS - TranscodingJob.cpp - TranscodingAssistantDialog.cpp - TranscodingOptionsStackedWidget.cpp - TranscodingPropertyWidget.cpp - TranscodingPropertySliderWidget.cpp - TranscodingSelectConfigWidget.cpp - TranscodingAssistantDialog.ui -) - -add_library(amarok-transcoding SHARED ${amarok_transcoding_SRCS}) - -target_link_libraries(amarok-transcoding - ${KDE4_KDECORE_LIBS} - ${KDE4_KDEUI_LIBS} - ${KDE4_KIO_LIBS} - ${KDE4_THREADWEAVER_LIBS} - ${QT_QTCORE_LIBRARY} - ${QT_QTGUI_LIBRARY} - ${CMAKE_THREAD_LIBS_INIT} - amarokcore -) - -set_target_properties(amarok-transcoding PROPERTIES VERSION 1.0.0 SOVERSION 1 ) -install(TARGETS amarok-transcoding ${INSTALL_TARGETS_DEFAULT_ARGS} ) - diff --git a/amarok/src/transcoding/TranscodingAssistantDialog.cpp b/amarok/src/transcoding/TranscodingAssistantDialog.cpp deleted file mode 100644 index cee343bb..00000000 --- a/amarok/src/transcoding/TranscodingAssistantDialog.cpp +++ /dev/null @@ -1,218 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Téo Mrnjavac * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "TranscodingAssistantDialog.h" - -#include "TranscodingJob.h" -#include "core/transcoding/TranscodingController.h" - -#include -#include -#include - -using namespace Transcoding; - -AssistantDialog::AssistantDialog( const QStringList &playableFileTypes, bool saveSupported, - Collections::CollectionLocationDelegate::OperationType operation, - const QString &destCollectionName, - const Configuration &prevConfiguration, - QWidget *parent ) - : KDialog( parent, Qt::Dialog ) - , m_configuration( JUST_COPY ) - , m_save( false ) - , m_playableFileTypes( playableFileTypes ) -{ - DEBUG_BLOCK - Q_UNUSED( destCollectionName ) // keep it in signature, may be useful in future - - QWidget *uiBase = new QWidget( this ); - setMainWidget( uiBase); - ui.setupUi( uiBase ); - setModal( true ); - setWindowTitle( i18n( "Transcode Tracks" ) ); - setMinimumSize( 590, 340 ); - setMaximumWidth( 590 ); - setSizePolicy( QSizePolicy::Preferred, QSizePolicy::MinimumExpanding ); - - setButtons( Ok|Cancel ); - button( Ok )->setText( i18n( "Transc&ode" ) ); - button( Ok )->setEnabled( false ); - - QString explanatoryText; - KIcon justCopyIcon; - QString justCopyText; - QString justCopyDescription; - switch( operation ) - { - case Collections::CollectionLocationDelegate::Copy: - explanatoryText = i18n( - "While copying, you can choose to transcode your music files into another " - "format with an encoder (codec). This can be done to save space or to " - "make your files readable by a portable music player or a particular " - "software program." ); - justCopyIcon = KIcon( "edit-copy" ); - justCopyText = i18n( "&Copy" ); - justCopyDescription = i18n( "Just copy the tracks without transcoding them." ); - break; - case Collections::CollectionLocationDelegate::Move: - explanatoryText = i18n( - "While moving, you can choose to transcode your music files into another " - "format with an encoder (codec). This can be done to save space or to " - "make your files readable by a portable music player or a particular " - "software program. Only successfully transcoded files will be removed " - "from their original location." ); - justCopyIcon = KIcon( "go-jump" ); // Dolphin uses this icon for "move" - justCopyText = i18n( "&Move" ); - justCopyDescription = i18n( "Just move the tracks without transcoding them." ); - break; - } - ui.explanatoryTextLabel->setText( explanatoryText ); - - ui.justCopyButton->setIcon( justCopyIcon ); - ui.justCopyButton->setText( justCopyText ); - ui.justCopyButton->setDescription( justCopyDescription ); - ui.justCopyButton->setMinimumHeight( ui.justCopyButton->iconSize().height() + 2*10 ); //we make room for the pretty icon - connect( ui.justCopyButton, SIGNAL(clicked()), - this, SLOT(onJustCopyClicked()) ); - - //Let's set up the codecs page... - populateFormatList(); - connect( ui.formatListWidget, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), - this, SLOT(onFormatSelect(QListWidgetItem*)) ); - - ui.formatIconLabel->hide(); - ui.formatNameLabel->hide(); - connect( button( Ok ), SIGNAL(clicked()), - this, SLOT(onTranscodeClicked()) ); - - ui.rememberCheckBox->setChecked( m_save ); - ui.rememberCheckBox->setEnabled( saveSupported ); - connect( ui.rememberCheckBox, SIGNAL(toggled(bool)), - this, SLOT(onRememberToggled(bool)) ); - - switch( prevConfiguration.trackSelection() ) //restore the previously selected TrackSelection radio button - { - case Configuration::TranscodeUnlessSameType: - ui.transcodeUnlessSameTypeRadioButton->setChecked( true ); - break; - case Configuration::TranscodeOnlyIfNeeded: - ui.transcodeOnlyIfNeededRadioButton->setChecked( true ); - break; - case Configuration::TranscodeAll: - ui.transcodeAllRadioButton->setChecked( true ); - } - - ui.transcodeAllRadioButton->setEnabled( false ); - ui.transcodeUnlessSameTypeRadioButton->setEnabled( false ); - ui.transcodeOnlyIfNeededRadioButton->setEnabled( false ); -} - -void -AssistantDialog::populateFormatList() -{ - QSet available = Amarok::Components::transcodingController()->availableEncoders(); - - // Add a note if no encoder is found - ui.groupBox->setEnabled( !available.isEmpty() ); - ui.encoderNotFoundLabel->setVisible( available.isEmpty() ); - - foreach( Encoder encoder, Amarok::Components::transcodingController()->allEncoders() ) - { - if( encoder == INVALID || encoder == JUST_COPY ) - continue; // skip "fake" encoders - Format *format = Amarok::Components::transcodingController()->format( encoder ); - - QListWidgetItem *item = new QListWidgetItem( format->icon(), format->prettyName() ); - item->setToolTip( format->description() ); - item->setData( Qt::UserRole, encoder ); - - // can be disabled due to unavailabilty - bool enabled = available.contains( encoder ); - if( !enabled ) - item->setToolTip( i18nc( "Tooltip of a disabled transcoding encoder option", - "Not currently available on your system." ) ); - - // or because not supported by target collection - if( enabled && !m_playableFileTypes.isEmpty() ) - { - enabled = m_playableFileTypes.contains( format->fileExtension() ); - if( !enabled ) - item->setToolTip( i18n( "Target collection indicates this format would not be playable." ) ); - } - - Qt::ItemFlags flags = item->flags(); - if( !enabled ) - item->setFlags( flags & ~Qt::ItemIsEnabled ); - ui.formatListWidget->addItem( item ); - } -} - -void -AssistantDialog::onJustCopyClicked() //SLOT -{ - KDialog::done( KDialog::Accepted ); -} - -void -AssistantDialog::onTranscodeClicked() //SLOT -{ - m_configuration = ui.transcodingOptionsStackedWidget->configuration( trackSelection() ); - KDialog::done( KDialog::Accepted ); -} - -void -AssistantDialog::onFormatSelect( QListWidgetItem *item ) //SLOT -{ - if( item ) - { - ui.formatIconLabel->show(); - ui.formatNameLabel->show(); - Encoder encoder = static_cast< Encoder >( item->data( Qt::UserRole ).toInt() ); - const Format *format = Amarok::Components::transcodingController()->format( encoder ); - ui.formatIconLabel->setPixmap( format->icon().pixmap( 32, 32 ) ); - ui.formatNameLabel->setText( format->prettyName() ); - ui.formatIconLabel->setToolTip( format->description() ); - ui.formatIconLabel->setWhatsThis( format->description() ); - ui.formatNameLabel->setToolTip( format->description() ); - ui.formatNameLabel->setWhatsThis( format->description() ); - ui.transcodingOptionsStackedWidget->switchPage( encoder ); - - ui.transcodeAllRadioButton->setEnabled( true ); - ui.transcodeUnlessSameTypeRadioButton->setEnabled( true ); - ui.transcodeOnlyIfNeededRadioButton->setEnabled( true ); - - button( Ok )->setEnabled( true ); - } -} - -void -AssistantDialog::onRememberToggled( bool checked ) //SLOT -{ - m_save = checked; -} - -Configuration::TrackSelection -AssistantDialog::trackSelection() const -{ - if( ui.transcodeOnlyIfNeededRadioButton->isChecked() ) - return Configuration::TranscodeOnlyIfNeeded; - else if( ui.transcodeUnlessSameTypeRadioButton->isChecked() ) - return Configuration::TranscodeUnlessSameType; - else - return Configuration::TranscodeAll; -} - -#include "moc_TranscodingAssistantDialog.cpp" diff --git a/amarok/src/transcoding/TranscodingAssistantDialog.h b/amarok/src/transcoding/TranscodingAssistantDialog.h deleted file mode 100644 index 0acb7015..00000000 --- a/amarok/src/transcoding/TranscodingAssistantDialog.h +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Téo Mrnjavac * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef TRANSCODING_ASSISTANTDIALOG_H -#define TRANSCODING_ASSISTANTDIALOG_H - -#include "amarok_transcoding_export.h" -#include "transcoding/ui_TranscodingAssistantDialog.h" -#include "core/collections/CollectionLocationDelegate.h" -#include "core/support/Debug.h" -#include "core/transcoding/TranscodingFormat.h" -#include "core/transcoding/TranscodingConfiguration.h" - -#include - -class QListWidget; - -namespace Transcoding -{ - -/** - * A KDialog for initiating a transcoding operation. - * @author Téo Mrnjavac - */ -class AMAROK_TRANSCODING_EXPORT AssistantDialog : public KDialog -{ - Q_OBJECT -public: - /** - * Create transcoding assistant dialog. Only encoders that encode to one of the - * @param playableFileTypes will be enabled. - * @param saveSupported true if transcoding config preference can be saved - * @param operation whether this is copying or moving - * @param destCollectionName name of the destination collection - */ - AssistantDialog( const QStringList &playableFileTypes, bool saveSupported, - Collections::CollectionLocationDelegate::OperationType operation, - const QString &destCollectionName, - const Configuration &prevConfiguration, - QWidget *parent = 0 ); - - Configuration configuration() const { return m_configuration; } - - /** - * Return true if user wants to remember this configuration per destination collection - */ - bool shouldSave() const { return m_save; } - -private: - inline void populateFormatList(); - Configuration::TrackSelection trackSelection() const; - - Configuration m_configuration; - bool m_save; - QStringList m_playableFileTypes; - Ui::AssistantDialog ui; - -private slots: - void onJustCopyClicked(); - void onTranscodeClicked(); - void onFormatSelect( QListWidgetItem *item ); - void onRememberToggled( bool checked ); -}; - -} //namespace Transcoding - -#endif //TRANSCODING_ASSISTANTDIALOG_H diff --git a/amarok/src/transcoding/TranscodingAssistantDialog.ui b/amarok/src/transcoding/TranscodingAssistantDialog.ui deleted file mode 100644 index 7b95671d..00000000 --- a/amarok/src/transcoding/TranscodingAssistantDialog.ui +++ /dev/null @@ -1,291 +0,0 @@ - - - AssistantDialog - - - - 0 - 0 - 499 - 432 - - - - - 0 - 0 - - - - - 460 - 280 - - - - - 3 - - - 4 - - - 2 - - - 4 - - - 4 - - - - - [ explanatory text ] this is a placeholder this is a placeholder this is a placeholder this is a placeholder this is a placeholder this is a placeholder this is a placeholder this is a placeholder this is a placeholder this is a placeholder. - - - Qt::AlignJustify|Qt::AlignTop - - - true - - - 2 - - - - - - - Qt::Horizontal - - - - - - - - 0 - 0 - - - - Copy/Move placeholder - - - - 32 - 32 - - - - <placeholder text> - - - - - - - Transcode - - - - - - - - - 0 - 0 - - - - - 160 - 0 - - - - - 160 - 16777215 - - - - Qt::ScrollBarAlwaysOff - - - true - - - - 22 - 22 - - - - false - - - - - - - 0 - - - - - 6 - - - 3 - - - - - - 0 - 0 - - - - - 32 - 32 - - - - - 32 - 32 - - - - - - - - - - - Qt::Horizontal - - - QSizePolicy::Minimum - - - - 10 - 20 - - - - - - - - - 0 - 0 - - - - - 75 - true - - - - Format Name - - - - - - - - - - 0 - 1 - - - - - - - - - - - - Transcode all tracks to the selected format - - - Transcode all tracks to the selected format - - - Transcode all tracks - - - - - - - Transcode tracks only when needed for playability in the destination collection - - - Transcode tracks only when needed for playability in the destination collection - - - Transcode only when needed for playability - - - - - - - Transcode only when source and destination file formats different - - - Transcode only when source and destination file formats different - - - Transcode only when source and destination formats are different - - - - - - - - - - <b>Note:</b> No encoder is available. If you want to transcode tracks please install <i>ffmpeg</i> or <i>libav</i> package (with <i>ffmpeg</i> wrapper) with appropriate encoders. Otherwise you may check <i>Remember this choice for the next time</i> option in order to skip this dialog for future transfers. - - - true - - - - - - - Remember this choice for the next time - - - - - - - - Transcoding::OptionsStackedWidget - QWidget -
    transcoding/TranscodingOptionsStackedWidget.h
    - 1 -
    -
    - - -
    diff --git a/amarok/src/transcoding/TranscodingJob.cpp b/amarok/src/transcoding/TranscodingJob.cpp deleted file mode 100644 index 8fe0dd6a..00000000 --- a/amarok/src/transcoding/TranscodingJob.cpp +++ /dev/null @@ -1,179 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Téo Mrnjavac * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "TranscodingJob.h" - -#include "core/support/Debug.h" -#include "core/transcoding/TranscodingController.h" - -#include - -#include -#include - -namespace Transcoding -{ - -Job::Job( const KUrl &src, - const KUrl &dest, - const Transcoding::Configuration &configuration, - QObject *parent ) - : KJob( parent ) - , m_src( src ) - , m_dest( dest ) - , m_configuration( configuration ) - , m_duration( -1 ) -{ - init(); -} - -Job::Job( KUrl &src, - const Transcoding::Configuration &configuration, - QObject *parent ) - : KJob( parent ) - , m_src( src ) - , m_dest( src ) - , m_configuration( configuration ) - , m_duration( -1 ) -{ - QString fileExtension = Amarok::Components::transcodingController()->format( configuration.encoder() )->fileExtension(); - if( !( fileExtension.isEmpty() ) ) - { - QString destPath = src.path(); - destPath.truncate( destPath.lastIndexOf( '.' ) + 1 ); - destPath.append( fileExtension ); - m_dest.setPath( destPath ); - } - init(); -} - -void -Job::init() -{ - m_transcoder = new KProcess( this ); - - m_transcoder->setOutputChannelMode( KProcess::MergedChannels ); - - //First the executable... - m_transcoder->setProgram( "ffmpeg" ); - //... prevent ffmpeg from being interactive when destination file already exists. We - // would use -n to exit immediatelly, but libav's ffmpeg doesn't support it, so we - // check for destination file existence manually and pass -y (overwrite) to avoid - // race condition - *m_transcoder << QString( "-y" ); - //... then we'd have the infile configuration followed by "-i" and the infile path... - *m_transcoder << QString( "-i" ) - << m_src.path(); - //... and finally, outfile configuration followed by the outfile path. - const Transcoding::Format *format = Amarok::Components::transcodingController()->format( m_configuration.encoder() ); - *m_transcoder << format->ffmpegParameters( m_configuration ) - << m_dest.path(); - - connect( m_transcoder, SIGNAL(readyRead()), - this, SLOT(processOutput()) ); - connect( m_transcoder, SIGNAL(finished(int,QProcess::ExitStatus)), - this, SLOT(transcoderDone(int,QProcess::ExitStatus)) ); -} - -void -Job::start() -{ - DEBUG_BLOCK - if( QFile::exists( m_dest.path() ) ) - { - debug() << "Not starting ffmpeg encoder, file already exists:" << m_dest.path(); - QTimer::singleShot( 0, this, SLOT(transcoderDone()) ); - } - else - { - QString commandline = QString( "'" ) + m_transcoder->program().join("' '") + QString( "'" ); - debug()<< "Calling" << commandline.toLocal8Bit().constData(); - m_transcoder->start(); - } -} - -void -Job::transcoderDone( int exitCode, QProcess::ExitStatus exitStatus ) //SLOT -{ - if( exitCode == 0 && exitStatus == QProcess::NormalExit ) - debug() << "YAY, transcoding done!"; - else - { - debug() << "NAY, transcoding fail!"; - setError( KJob::UserDefinedError ); - setErrorText( QString( "Calling `" ) + m_transcoder->program().join(" ") + "` failed" ); - } - emitResult(); -} - -void -Job::processOutput() -{ - QString output = QString::fromLocal8Bit( m_transcoder->readAllStandardOutput().data() ); - if( output.simplified().isEmpty() ) - return; - foreach( const QString &line, output.split( QChar( '\n' ) ) ) - debug() << "ffmpeg:" << line.toLocal8Bit().constData(); - - if( m_duration == -1 ) - { - m_duration = computeDuration( output ); - if( m_duration >= 0 ) - setTotalAmount( KJob::Bytes, m_duration ); //Nothing better than bytes I can think of - } - - qint64 progress = computeProgress( output ); - if( progress > -1 ) - setProcessedAmount( KJob::Bytes, progress ); -} - -inline qint64 -Job::computeDuration( const QString &output ) -{ - //We match something like "Duration: 00:04:33.60" - QRegExp matchDuration( "Duration: (\\d{2,}):(\\d{2}):(\\d{2})\\.(\\d{2})" ); - - if( output.contains( matchDuration ) ) - { - //duration is in csec - qint64 duration = matchDuration.cap( 1 ).toLong() * 60 * 60 * 100 + - matchDuration.cap( 2 ).toInt() * 60 * 100 + - matchDuration.cap( 3 ).toInt() * 100 + - matchDuration.cap( 4 ).toInt(); - return duration; - } - else - return -1; -} - -inline qint64 -Job::computeProgress( const QString &output ) -{ - //Output is like size= 323kB time=18.10 bitrate= 146.0kbits/s - //We're going to use the "time" column, which counts the elapsed time in seconds. - QRegExp matchTime( "time=(\\d+)\\.(\\d{2})" ); - - if( output.contains( matchTime ) ) - { - qint64 time = matchTime.cap( 1 ).toLong() * 100 + - matchTime.cap( 2 ).toInt(); - return time; - } - else - return -1; -} - -} //namespace Transcoding diff --git a/amarok/src/transcoding/TranscodingJob.h b/amarok/src/transcoding/TranscodingJob.h deleted file mode 100644 index 6170c2a3..00000000 --- a/amarok/src/transcoding/TranscodingJob.h +++ /dev/null @@ -1,110 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Téo Mrnjavac * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef TRANSCODING_JOB_H -#define TRANSCODING_JOB_H - -#include "amarok_transcoding_export.h" -#include "core/transcoding/TranscodingConfiguration.h" - -#include -#include - -#include - -namespace Transcoding -{ - -/** - * A KJob that transcodes an audio stream from a file into another file with a different - * codec and container format. - * @author Téo Mrnjavac - */ -class AMAROK_TRANSCODING_EXPORT Job : public KJob -{ - Q_OBJECT -public: - /** - * Constructor. Creates a Transcoding::Job and fills in the source, destination and - * encoder parameters. The job does not start automatically. - * @param src the path of the source file. - * @param dest the path of the destination file, to be created. - * @param configuration the string of parameters to be fed to the encoder. This implementation - * uses the FFmpeg executable, @see http://ffmpeg.org/ffmpeg-doc.html#SEC6 - * @param the parent QObject. - */ - explicit Job( const KUrl &src, - const KUrl &dest, - const Transcoding::Configuration &configuration, - QObject *parent = 0 ); - - /** - * Convenience constructor. Creates a Transcoding::Job with the destination file to be - * placed in the same directory as the source. - */ - explicit Job( KUrl &src, - const Transcoding::Configuration &configuration, - QObject *parent = 0 ); - - /** - * Sets the path of the source file. - * @param src the path of the source file. - */ - void setSource( const KUrl &src ); - - /** - * Sets the path of the destination file, to be created. - * @param dest the path of the destination file. - */ - void setDestination( const KUrl &dest ); - - /** - * Starts the transcoding job. - */ - void start(); - - /** - * Get the source url. - */ - KUrl srcUrl() const { return m_src; } - - /** - * Get the destination url. - */ - KUrl destUrl() const { return m_dest; } - -private slots: - void processOutput(); - /** - * Default arguments are for convenience (read: lazyness) so that this can be - * connected to QTimer::singleShot() - */ - void transcoderDone( int exitCode = -1, QProcess::ExitStatus exitStatus = QProcess::CrashExit ); - void init(); - -private: - inline qint64 computeDuration( const QString &output ); - inline qint64 computeProgress( const QString &output ); - KUrl m_src; - KUrl m_dest; - Transcoding::Configuration m_configuration; - KProcess *m_transcoder; - qint64 m_duration; //in csec -}; - -} //namespace Transcoding - -#endif //TRANSCODING_JOB_H diff --git a/amarok/src/transcoding/TranscodingOptionsStackedWidget.cpp b/amarok/src/transcoding/TranscodingOptionsStackedWidget.cpp deleted file mode 100644 index 8a4bdc0d..00000000 --- a/amarok/src/transcoding/TranscodingOptionsStackedWidget.cpp +++ /dev/null @@ -1,110 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Téo Mrnjavac * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "TranscodingOptionsStackedWidget.h" - -#include "core/support/Debug.h" -#include "core/transcoding/TranscodingProperty.h" -#include "core/transcoding/TranscodingController.h" - -#include -#include - -#include -#include -#include - -namespace Transcoding -{ - -OptionsStackedWidget::OptionsStackedWidget( QWidget *parent ) - : QStackedWidget( parent ) -{ - initWelcomePage(); - foreach( const Encoder &encoder, Amarok::Components::transcodingController()->availableEncoders() ) - { - Format *format = Amarok::Components::transcodingController()->format( encoder ); - m_pagesMap.insert( encoder, initCodecPage( format ) ); - } -} - -void -OptionsStackedWidget::initWelcomePage() -{ - QWidget *welcomeWidget = new QWidget( this ); - QVBoxLayout *vbl = new QVBoxLayout( welcomeWidget ); - vbl->addStretch(); - QHBoxLayout *hbl = new QHBoxLayout( welcomeWidget ); - vbl->addLayout( hbl ); - hbl->addStretch(); - QLabel *arrow = new QLabel( welcomeWidget ); - arrow->setPixmap( KIcon( "arrow-left" ).pixmap( 16, 16 ) ); - QLabel *message = new QLabel( i18n( - "In order to configure the parameters of the transcoding operation, please " - "pick an encoder from the list." ), this ); - message->setWordWrap( true ); - hbl->addWidget( arrow ); - hbl->addWidget( message ); - hbl->addStretch(); - vbl->addStretch(); - - insertWidget( 0, welcomeWidget ); -} - -int -OptionsStackedWidget::initCodecPage( Format *format ) -{ - m_propertyWidgetsMap.insert( format->encoder(), QList< PropertyWidget * >() ); - - QWidget *codecWidget = new QWidget( this ); - - QVBoxLayout *mainLayout = new QVBoxLayout( codecWidget ); - mainLayout->addStretch( 1 ); - - foreach( Property property, format->propertyList() ) - { - PropertyWidget *propertyWidget = PropertyWidget::create( property, codecWidget ); - mainLayout->addWidget( propertyWidget->widget() ); - m_propertyWidgetsMap[ format->encoder() ].append( propertyWidget ); - debug() << "Created config widget for " << format->prettyName() - << ", element " << property.name(); - } - - return addWidget( codecWidget ); -} - -const Configuration -OptionsStackedWidget::configuration( const Configuration::TrackSelection trackSelection ) const -{ - Encoder encoder = m_pagesMap.key( currentIndex() ); - Configuration configuration = Configuration( encoder, trackSelection ); - - foreach( PropertyWidget *propertyWidget, m_propertyWidgetsMap.value( encoder ) ) - { - configuration.addProperty( propertyWidget->name(), propertyWidget->value() ); - } - - return configuration; -} - -void -OptionsStackedWidget::switchPage( Encoder encoder) -{ - setCurrentIndex( m_pagesMap.value( encoder ) ); - emit formatChanged( encoder ); -} - -} //namespace Transcoding diff --git a/amarok/src/transcoding/TranscodingOptionsStackedWidget.h b/amarok/src/transcoding/TranscodingOptionsStackedWidget.h deleted file mode 100644 index d658ca55..00000000 --- a/amarok/src/transcoding/TranscodingOptionsStackedWidget.h +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Téo Mrnjavac * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef TRANSCODING_OPTIONSSTACKEDWIDGET_H -#define TRANSCODING_OPTIONSSTACKEDWIDGET_H - -#include "core/transcoding/TranscodingFormat.h" -#include "core/transcoding/TranscodingConfiguration.h" -#include "TranscodingPropertyWidget.h" - -#include -#include - -namespace Transcoding -{ - -class OptionsStackedWidget : public QStackedWidget -{ - Q_OBJECT -public: - explicit OptionsStackedWidget( QWidget *parent = 0 ); - - const Configuration configuration( const Configuration::TrackSelection trackSelection ) const; - -signals: - void formatChanged( Encoder encoder ); - -public slots: - void switchPage( Encoder encoder ); - -private: - void initWelcomePage(); - - /** - * Initializes a transcoding format configuration page on the stacked widget. - * @param encoder the encoder enum value. - * @return the index of the page where the configuration widget was initialized. - */ - int initCodecPage( Format *format ); - - QMap< Encoder, int > m_pagesMap; - QMap< Encoder, QList< PropertyWidget * > > m_propertyWidgetsMap; -}; - -} //namespace Transcoding - -#endif //TRANSCODING_OPTIONSSTACKEDWIDGET_H diff --git a/amarok/src/transcoding/TranscodingPropertySliderWidget.cpp b/amarok/src/transcoding/TranscodingPropertySliderWidget.cpp deleted file mode 100644 index 44944c65..00000000 --- a/amarok/src/transcoding/TranscodingPropertySliderWidget.cpp +++ /dev/null @@ -1,111 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Téo Mrnjavac * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "TranscodingPropertySliderWidget.h" - -#include "core/support/Debug.h" - -#include "KLocalizedString" - -#include - -namespace Transcoding -{ - -PropertySliderWidget::PropertySliderWidget( Property property, QWidget * parent ) - : QWidget( parent ) - , m_property( property ) -{ - m_name = property.name(); - - QBoxLayout *mainLayout; - m_mainLabel = new QLabel( m_property.prettyName(), this ); - m_mainLabel->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred ); - - mainLayout = new QVBoxLayout( this ); - QBoxLayout *secondaryTopLayout = new QHBoxLayout( this ); - QBoxLayout *secondaryBotLayout = new QHBoxLayout( this ); - mainLayout->addWidget( m_mainLabel ); - mainLayout->addLayout( secondaryTopLayout ); - mainLayout->addLayout( secondaryBotLayout ); - secondaryTopLayout->addSpacing( 5 ); - - m_mainEdit = new QSlider( this ); - m_mainEdit->setOrientation( Qt::Horizontal ); - m_mainEdit->setRange( m_property.min(), m_property.max() ); - - m_mainEdit->setValue( m_property.defaultValue().toInt() ); - m_mainEdit->setTickPosition( QSlider::TicksBelow ); - m_mainEdit->setTickInterval( 1 ); - m_mainEdit->setPageStep( 2 ); - m_mainEdit->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred ); - secondaryTopLayout->addWidget( m_mainEdit, 3 ); - - secondaryTopLayout->addSpacing( 5 ); - - QLabel *leftLabel = new QLabel( m_property.endLabels().at( 0 ), this ); - secondaryBotLayout->addWidget( leftLabel, 1 ); - - m_midLabel = new QLabel( QString::number( m_mainEdit->value() ), this ); - { - QFont font = m_midLabel->font(); - font.setBold( true ); - m_midLabel->setFont( font ); - } - connect( m_mainEdit, SIGNAL(valueChanged(int)), - this, SLOT(onSliderChanged(int)) ); - - QLabel *rightLabel = new QLabel( m_property.endLabels().at( 1 ), this ); - rightLabel->setAlignment( Qt::AlignRight | Qt::AlignVCenter ); - secondaryBotLayout->addWidget( rightLabel, 1 ); - - mainLayout->addWidget( m_midLabel ); - - onSliderChanged( m_property.defaultValue().toInt() ); - - QString description = m_property.description(); - m_mainEdit->setToolTip( description ); - m_mainLabel->setToolTip( description ); - m_mainEdit->setWhatsThis( description ); - m_mainLabel->setWhatsThis( description ); - - m_mainLabel->setBuddy( m_mainEdit ); - m_midLabel->setAlignment( Qt::AlignHCenter | Qt::AlignVCenter ); -} - -void -PropertySliderWidget::onSliderChanged( int value ) //SLOT -{ - QString newText; - if( !m_property.valueLabels().isEmpty() && - m_property.valueLabels().size() == qAbs( m_property.max() - m_property.min() ) + 1 ) - newText = m_property.valueLabels().at( value - qMin( m_property.min(), m_property.max() ) ); - else - newText = QString::number( value ); - - if( value == m_property.defaultValue().toInt() ) - newText += i18n( " (recommended)" ); - - m_midLabel->setText( newText ); -} - -QVariant -PropertySliderWidget::value() const -{ - return m_mainEdit->value(); -} - -} //namespace Transcoding diff --git a/amarok/src/transcoding/TranscodingPropertySliderWidget.h b/amarok/src/transcoding/TranscodingPropertySliderWidget.h deleted file mode 100644 index 01f16b8d..00000000 --- a/amarok/src/transcoding/TranscodingPropertySliderWidget.h +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Téo Mrnjavac * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef TRANSCODING_PROPERTYSLIDERWIDGET_H -#define TRANSCODING_PROPERTYSLIDERWIDGET_H - -#include "transcoding/TranscodingPropertyWidget.h" - -#include -#include - -namespace Transcoding -{ - -/** - * Provides a single QSlider-based widget for configuring a given Transcoding::Property. - * @author Téo Mrnjavac - */ -class PropertySliderWidget : public QWidget, public PropertyWidget -{ - Q_OBJECT -public: - explicit PropertySliderWidget( Property property, QWidget * parent = 0 ); - - QVariant value() const; - - QWidget *widget() { return qobject_cast< QWidget *>( this ); } - -private slots: - void onSliderChanged( int value ); - -private: - QLabel *m_mainLabel; - QSlider *m_mainEdit; - QLabel *m_midLabel; - Property m_property; -}; - -} //namespace Transcoding - -#endif //TRANSCODING_PROPERTYSLIDERWIDGET_H diff --git a/amarok/src/transcoding/TranscodingPropertyWidget.cpp b/amarok/src/transcoding/TranscodingPropertyWidget.cpp deleted file mode 100644 index 2d13e0a5..00000000 --- a/amarok/src/transcoding/TranscodingPropertyWidget.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Téo Mrnjavac * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "TranscodingPropertyWidget.h" - -#include "TranscodingPropertySliderWidget.h" - -#include "core/support/Debug.h" - -namespace Transcoding -{ - -PropertyWidget * -PropertyWidget::create( Property &property, QWidget * parent ) -{ - switch( property.type() ) - { - case Property::TRADEOFF: - return new PropertySliderWidget( property, parent ); - default: - debug() << "Muy bad!"; - return 0; - } -} - -} //namespace Transcoding diff --git a/amarok/src/transcoding/TranscodingPropertyWidget.h b/amarok/src/transcoding/TranscodingPropertyWidget.h deleted file mode 100644 index 1df0c51b..00000000 --- a/amarok/src/transcoding/TranscodingPropertyWidget.h +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Téo Mrnjavac * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef TRANSCODING_PROPERTYWIDGET_H -#define TRANSCODING_PROPERTYWIDGET_H - -#include "core/transcoding/TranscodingProperty.h" - -#include - -namespace Transcoding -{ - -/** - * Provides the interface for a generic configuration editing widget for a given - * Transcoding::Property. - * @author Téo Mrnjavac - */ -class PropertyWidget -{ -public: - static PropertyWidget * create( Property &property, QWidget * parent = 0 ); - - virtual ~PropertyWidget(){} - - virtual QByteArray name() const { return m_name; } - - virtual QVariant value() const = 0; - - virtual QWidget *widget() = 0; - -protected: - QByteArray m_name; -}; - -} //namespace Transcoding - -#endif //TRANSCODING_PROPERTYWIDGET_H diff --git a/amarok/src/transcoding/TranscodingSelectConfigWidget.cpp b/amarok/src/transcoding/TranscodingSelectConfigWidget.cpp deleted file mode 100644 index 34dcc190..00000000 --- a/amarok/src/transcoding/TranscodingSelectConfigWidget.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "TranscodingSelectConfigWidget.h" - -#include -#include - -using namespace Transcoding; - - -SelectConfigWidget::SelectConfigWidget( QWidget *parent ) - : QComboBox( parent ) - , m_passedChoice( INVALID ) -{ -} - -void -SelectConfigWidget::fillInChoices( const Configuration &savedConfiguration ) -{ - clear(); - addItem( KIcon( "edit-copy" ), i18n( "Never" ), JustCopy ); - addItem( KIcon( "view-choose" ), i18n( "Ask before each transfer" ), Invalid ); - if( savedConfiguration.isValid() ) - { - if( !savedConfiguration.isJustCopy() ) - { - Configuration temp = savedConfiguration; - temp.setTrackSelection( Configuration::TranscodeAll ); - addItem( KIcon( "audio-x-generic" ), temp.prettyName(), - TranscodeAll ); - temp.setTrackSelection( Configuration::TranscodeUnlessSameType ); - addItem( KIcon( "audio-x-generic" ), temp.prettyName(), - TranscodeUnlessSameType ); - temp.setTrackSelection( Configuration::TranscodeOnlyIfNeeded ); - addItem( KIcon( "audio-x-generic" ),temp.prettyName(), - TranscodeOnlyIfNeeded ); - setCurrentIndex( savedConfiguration.trackSelection() + 2 ); - } - } - else - setCurrentIndex( count() - 1 ); - - m_passedChoice = savedConfiguration; -} - -Configuration -SelectConfigWidget::currentChoice() const -{ - Configuration invalid( INVALID, m_passedChoice.trackSelection() ); - Configuration passedChoice = m_passedChoice; - if( currentIndex() < 0 ) - return invalid; - Choice choice = Choice( itemData( currentIndex() ).toInt() ); - switch( choice ) - { - case JustCopy: - return Configuration( JUST_COPY ); - case Invalid: - return invalid; - case TranscodeAll: - passedChoice.setTrackSelection( Configuration::TranscodeAll ); - return passedChoice; - case TranscodeUnlessSameType: - passedChoice.setTrackSelection( Configuration::TranscodeUnlessSameType ); - return passedChoice; - case TranscodeOnlyIfNeeded: - passedChoice.setTrackSelection( Configuration::TranscodeOnlyIfNeeded ); - return passedChoice; - } - return invalid; -} - -bool -SelectConfigWidget::hasChanged() const -{ - return currentIndex() < 0 || m_passedChoice != currentChoice(); -} - -#include "moc_TranscodingSelectConfigWidget.cpp" diff --git a/amarok/src/transcoding/TranscodingSelectConfigWidget.h b/amarok/src/transcoding/TranscodingSelectConfigWidget.h deleted file mode 100644 index dd459698..00000000 --- a/amarok/src/transcoding/TranscodingSelectConfigWidget.h +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef TRANSCODINGSELECTCONFIGWIDGET_H -#define TRANSCODINGSELECTCONFIGWIDGET_H - -#include "amarok_transcoding_export.h" -#include "core/transcoding/TranscodingConfiguration.h" - -#include - -namespace Transcoding -{ - - /** - * Convenience QComboBox subclass that can be used in collection configuration dialogs - * to let user change/unset current transcoding preference for transferring tracks. - */ - class AMAROK_TRANSCODING_EXPORT SelectConfigWidget : public QComboBox - { - Q_OBJECT - - public: - explicit SelectConfigWidget( QWidget *parent = 0 ); - - /** - * Fills the combobox widget with appropriate transcoding configurations. - * "Just copy" and "Ask every time" options are always present. - * - * @param savedConfiguration current saved configuration or invalid one if no - * saved config exists. - */ - void fillInChoices( const Configuration &savedConfiguration ); - - /** - * Get current choice. Will return invalid configuration if called before - * @see fillInChoices() - */ - Configuration currentChoice() const; - - /** - * Return true if currently selected choice is different from one that was - * passed to fillInChoices() - */ - bool hasChanged() const; - - private: - enum Choice { - TranscodeAll, - TranscodeUnlessSameType, - TranscodeOnlyIfNeeded, - JustCopy, - Invalid - }; - - Q_DISABLE_COPY(SelectConfigWidget) - Configuration m_passedChoice; - }; - -} // namespace Transcoding - -#endif // TRANSCODINGSELECTCONFIGWIDGET_H diff --git a/amarok/src/transcoding/amarok_transcoding_export.h b/amarok/src/transcoding/amarok_transcoding_export.h deleted file mode 100644 index 401b95c1..00000000 --- a/amarok/src/transcoding/amarok_transcoding_export.h +++ /dev/null @@ -1,35 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Téo Mrnjavac * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_TRANSCODING_EXPORT_H -#define AMAROK_TRANSCODING_EXPORT_H - -/* needed for KDE_EXPORT and KDE_IMPORT macros */ -#include - -#ifndef AMAROK_TRANSCODING_EXPORT -# ifdef MAKE_AMAROK_TRANSCODING_LIB - /* We are building this library */ -# define AMAROK_TRANSCODING_EXPORT KDE_EXPORT - -# else - /* We are using this library */ -# define AMAROK_TRANSCODING_EXPORT KDE_IMPORT - -# endif//MAKE_TRANSCODING_LIB -#endif// AMAROK_EXPORT - -#endif //AMAROK_TRANSCODING_EXPORT_H diff --git a/amarok/src/widgets/AlbumBreadcrumbWidget.cpp b/amarok/src/widgets/AlbumBreadcrumbWidget.cpp deleted file mode 100644 index f34d3609..00000000 --- a/amarok/src/widgets/AlbumBreadcrumbWidget.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Rick W. Chen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "AlbumBreadcrumbWidget.h" - -#include "core/meta/Meta.h" -#include "widgets/BreadcrumbItemButton.h" - -#include -#include - -AlbumBreadcrumbWidget::AlbumBreadcrumbWidget( const Meta::AlbumPtr album, QWidget *parent ) - : KHBox( parent ) - , m_album( album ) -{ - const KIcon artistIcon = KIcon( "filename-artist-amarok" ); - const KIcon albumIcon = KIcon( "filename-album-amarok" ); - new BreadcrumbItemMenuButton( this ); - m_artistButton = new BreadcrumbItemButton( artistIcon, QString(), this ); - new BreadcrumbItemMenuButton( this ); - m_albumButton = new BreadcrumbItemButton( albumIcon, QString(), this ); - - QWidget *spacer = new QWidget( this ); - - setStretchFactor( m_artistButton, 1 ); - setStretchFactor( m_albumButton, 1 ); - setStretchFactor( spacer, 1 ); - - connect( m_artistButton, SIGNAL(clicked()), SLOT(artistClicked()) ); - connect( m_albumButton, SIGNAL(clicked()), SLOT(albumClicked()) ); - - updateBreadcrumbs(); -} - -AlbumBreadcrumbWidget::~AlbumBreadcrumbWidget() -{ -} - -void AlbumBreadcrumbWidget::setAlbum( const Meta::AlbumPtr album ) -{ - m_album = album; - updateBreadcrumbs(); -} - -void AlbumBreadcrumbWidget::updateBreadcrumbs() -{ - const QString &album = m_album->prettyName(); - const QString &artist = m_album->hasAlbumArtist() ? m_album->albumArtist()->prettyName() - : i18n( "Various Artists" ); - m_artistButton->setText( artist ); - m_albumButton->setText( album ); -} - -void AlbumBreadcrumbWidget::artistClicked() -{ - if( m_album->hasAlbumArtist() ) - emit artistClicked( m_album->albumArtist()->name() ); -} - -void AlbumBreadcrumbWidget::albumClicked() -{ - emit albumClicked( m_album->name() ); -} - -#include "moc_AlbumBreadcrumbWidget.cpp" diff --git a/amarok/src/widgets/AlbumBreadcrumbWidget.h b/amarok/src/widgets/AlbumBreadcrumbWidget.h deleted file mode 100644 index 11cb5ddb..00000000 --- a/amarok/src/widgets/AlbumBreadcrumbWidget.h +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Rick W. Chen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_ALBUMBREADCRUMBWIDGET_H -#define AMAROK_ALBUMBREADCRUMBWIDGET_H - -#include "core/meta/forward_declarations.h" - -#include - -class BreadcrumbItemButton; - -/** - * This simple widget shows a breadcrumb-like display of one artist and one - * album. Clicking on the artist or album emits signals containing their meta - * objects and names. - * - * It looks like this: - * \code - * +-------------------------------+ - * | > X artist > Y album | - * +-------------------------------+ - * where X and Y are generic artist and album icons respectively. - * \endcode - * - * TODO: list artists/albums when clicking on the '>' to be more useful - */ -class AlbumBreadcrumbWidget : public KHBox -{ - Q_OBJECT - -public: - explicit AlbumBreadcrumbWidget( const Meta::AlbumPtr album, QWidget *parent = 0 ); - ~AlbumBreadcrumbWidget(); - - void setAlbum( const Meta::AlbumPtr album ); - -signals: - void artistClicked( const QString& ); - void albumClicked( const QString& ); - -private slots: - void artistClicked(); - void albumClicked(); - -private: - Meta::AlbumPtr m_album; - BreadcrumbItemButton *m_artistButton; - BreadcrumbItemButton *m_albumButton; - - void updateBreadcrumbs(); -}; - -#endif /* AMAROK_ALBUMBREADCRUMBWIDGET_H */ diff --git a/amarok/src/widgets/AmarokDockWidget.cpp b/amarok/src/widgets/AmarokDockWidget.cpp deleted file mode 100644 index 5a243a9e..00000000 --- a/amarok/src/widgets/AmarokDockWidget.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 Pulic License for more details. * - * * - * You should have received a copy of the GNU General Public License along with * - * this program. If not, see . * - ****************************************************************************************/ - -#include "AmarokDockWidget.h" - -AmarokDockWidget::AmarokDockWidget( const QString & title, QWidget * parent, Qt::WindowFlags flags ) - : QDockWidget( title, parent, flags ) - , m_polished( false ) -{ - m_dummyTitleBarWidget = new QWidget( this ); - connect( this, SIGNAL(visibilityChanged(bool)), SLOT(slotVisibilityChanged(bool)) ); -} - -void AmarokDockWidget::slotVisibilityChanged( bool visible ) -{ - if( visible ) - ensurePolish(); -} - -void AmarokDockWidget::ensurePolish() -{ - if( !m_polished ) - { - polish(); - m_polished = true; - } -} - -void AmarokDockWidget::setMovable( bool movable ) -{ - if( movable ) - { - const QFlags features = QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable | QDockWidget::DockWidgetClosable; - setTitleBarWidget( 0 ); - setFeatures( features ); - } - else - { - const QFlags features = QDockWidget::NoDockWidgetFeatures; - setTitleBarWidget( m_dummyTitleBarWidget ); - setFeatures( features ); - } -} - -#include "moc_AmarokDockWidget.cpp" diff --git a/amarok/src/widgets/AmarokDockWidget.h b/amarok/src/widgets/AmarokDockWidget.h deleted file mode 100644 index 5d64b2af..00000000 --- a/amarok/src/widgets/AmarokDockWidget.h +++ /dev/null @@ -1,44 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 Pulic License for more details. * - * * - * You should have received a copy of the GNU General Public License along with * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROKDOCKWIDGET_H -#define AMAROKDOCKWIDGET_H - -#include -#include - -class AmarokDockWidget : public QDockWidget -{ - Q_OBJECT - -public: - explicit AmarokDockWidget( const QString & title, QWidget * parent = 0, Qt::WindowFlags flags = 0 ); - - void setMovable( bool movable ); - -protected slots: - void slotVisibilityChanged( bool visible ); - -protected: - virtual void polish() = 0; - void ensurePolish(); - - bool m_polished; - - QWidget * m_dummyTitleBarWidget; -}; - -#endif // AMAROKDOCKWIDGET_H diff --git a/amarok/src/widgets/AnalyzerWidget.cpp b/amarok/src/widgets/AnalyzerWidget.cpp deleted file mode 100644 index e44948b6..00000000 --- a/amarok/src/widgets/AnalyzerWidget.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2004 Mark Kretschmann * - * Copyright (c) 2007 Dan Meltzer * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "AnalyzerWidget.h" - -#include "core/support/Amarok.h" -#include "amarokconfig.h" -#include "core/support/Debug.h" -#include "analyzerbase.h" -#include "socketserver.h" - -#include -#include -#include - -AnalyzerWidget::AnalyzerWidget( QWidget *parent ) - : QWidget( parent ) - , m_child( 0 ) -{ - setObjectName( "AnalyzerWidget" ); - setToolTip( i18n( "Click for more analyzers" ) ); - setContentsMargins(0,0,0,0); - changeAnalyzer(); -} - -void -AnalyzerWidget::resizeEvent( QResizeEvent *) -{ - m_child->resize( size() ); -} - -void AnalyzerWidget::changeAnalyzer() -{ - delete m_child; - m_child = Analyzer::Factory::createPlaylistAnalyzer( this ); - m_child->setObjectName( "ToolBarAnalyzer" ); - m_child->resize( size() ); - m_child->show(); -} - -void -AnalyzerWidget::mousePressEvent( QMouseEvent *e) -{ - if( e->button() == Qt::LeftButton ) { - AmarokConfig::setCurrentAnalyzer( AmarokConfig::currentAnalyzer() + 1 ); - changeAnalyzer(); - } -} - -void -AnalyzerWidget::contextMenuEvent( QContextMenuEvent *e) -{ -#if defined HAVE_LIBVISUAL - KMenu menu; - menu.addAction( KIcon( "view-media-visualization-amarok" ), i18n("&Visualizations"), - Vis::Selector::instance(), SLOT(show()) ); - - menu.exec( mapToGlobal( e->pos() ) ); -#else - Q_UNUSED(e); -#endif -} - -#include "moc_AnalyzerWidget.cpp" diff --git a/amarok/src/widgets/AnalyzerWidget.h b/amarok/src/widgets/AnalyzerWidget.h deleted file mode 100644 index c9636f03..00000000 --- a/amarok/src/widgets/AnalyzerWidget.h +++ /dev/null @@ -1,40 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2004 Mark Kretschmann * - * Copyright (c) 2007 Dan Meltzer * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef ANALYZERWIDGET_H -#define ANALYZERWIDGET_H - -#include - -/* -* A Widget to display our analyzers in. -*/ -class AnalyzerWidget : public QWidget -{ - Q_OBJECT - public: - AnalyzerWidget( QWidget *parent ); - protected: - virtual void resizeEvent( QResizeEvent* ); - virtual void mousePressEvent( QMouseEvent* ); - virtual void contextMenuEvent( QContextMenuEvent* ); - private: - void changeAnalyzer(); - QWidget *m_child; -}; - -#endif diff --git a/amarok/src/widgets/AnimatedLabelStack.cpp b/amarok/src/widgets/AnimatedLabelStack.cpp deleted file mode 100644 index 111b702e..00000000 --- a/amarok/src/widgets/AnimatedLabelStack.cpp +++ /dev/null @@ -1,403 +0,0 @@ -/**************************************************************************************** -* Copyright (c) 2009 Thomas Luebking * -* Copyright (c) 2010 Mark Kretschmann * -* * -* This program 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 2 of the License, or (at your option) any later * -* version. * -* * -* This program 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 * -* this program. If not, see . * -****************************************************************************************/ - -#include "AnimatedLabelStack.h" - -#include -#include -#include - -static const int frameTime = 50; -static const int normalDisplayTime = 7000; - -AnimatedLabelStack::AnimatedLabelStack( const QStringList &data, QWidget *p, Qt::WindowFlags f ): QWidget(p, f) - , m_align(Qt::AlignCenter) - , m_animTimer(0) - , m_sleepTimer(0) - , m_time(0) - , m_fadeTime(300) - , m_displayTime(normalDisplayTime) - , m_index(0) - , m_visibleIndex(0) - , m_opacity(255) - , m_targetOpacity(255) - , m_animated(true) - , m_pulsating(false) - , m_pulseRequested(false) - , m_explicit(false) - , m_isClick(false) -{ - setContentsMargins( 0, 0, 0, 0 ); - setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding); - setData( data ); -} - -void -AnimatedLabelStack::activateOnEnter() -{ - if ( m_data.isEmpty() || !underMouse() || m_pulsating || m_explicit ) - return; - if ( m_animated ) - { - m_pulseRequested = true; - if ( m_time > m_fadeTime && m_time < (m_displayTime - m_fadeTime) ) - m_time = m_displayTime - m_fadeTime; - wakeUp(); - } - else - setPulsating( true ); -} - -void -AnimatedLabelStack::ensureAnimationStatus() -{ - if ( m_data.count() > 1 && ( m_animated || m_pulsating ) ) - { - wakeUp(); - } - else - { - if ( m_animTimer ) - { - killTimer( m_animTimer ); - m_animTimer = 0; - } - if ( m_sleepTimer ) - { - killTimer( m_sleepTimer ); - m_sleepTimer = 0; - } - m_opacity = m_targetOpacity; - update(); - } -} - -void -AnimatedLabelStack::enterEvent( QEvent * ) -{ - // wait a short time, then pulse through entries - m_explicit = false; - QTimer::singleShot(300, this, SLOT(activateOnEnter()) ); -} - -void -AnimatedLabelStack::hideEvent( QHideEvent *e ) -{ - QWidget::hideEvent( e ); - if ( m_animTimer ) - { - killTimer( m_animTimer ); - m_animTimer = 0; - } - if ( m_sleepTimer ) - { - killTimer( m_sleepTimer ); - m_sleepTimer = 0; - } - m_opacity = m_targetOpacity; -} - -void -AnimatedLabelStack::leaveEvent( QEvent * ) -{ - m_explicit = false; - m_pulseRequested = false; -} - -void -AnimatedLabelStack::mousePressEvent( QMouseEvent *me ) -{ - if ( me->button() != Qt::LeftButton || m_data.isEmpty() ) - return; - - m_isClick = true; - me->accept(); -} - -void -AnimatedLabelStack::mouseReleaseEvent( QMouseEvent *me ) -{ - if ( me->button() != Qt::LeftButton || m_data.isEmpty() ) - return; - - me->accept(); - if ( m_isClick && underMouse() ) - { - m_isClick = false; - if ( !m_data.isEmpty() ) - emit clicked ( m_data.at( m_visibleIndex ) ); - } -} - -void -AnimatedLabelStack::paintEvent( QPaintEvent * pe ) -{ - if ( m_data.isEmpty() ) - return; - - QPainter p(this); - p.setClipRegion( pe->region() ); - - QColor c( palette().color( foregroundRole() ) ); - c.setAlpha( m_targetOpacity ); - - if ( m_animTimer ) // currently animated - { - if ( m_opacity != m_targetOpacity ) // we're in transition period - { - if ( !m_pulsating ) - { - c.setAlpha( qAbs(m_targetOpacity - m_opacity) ); - p.setPen( c ); - int index = m_visibleIndex - 1; - if (index < 0) - index = m_data.count() - 1; - - p.drawText( textRect(), m_align | Qt::TextSingleLine, elidedText( m_data.at( index ) ) ); - } - - c.setAlpha( m_opacity ); - } - } - - p.setPen( c ); - p.drawText( textRect(), m_align | Qt::TextSingleLine, elidedText( m_data.at( m_visibleIndex ) ) ); - p.end(); -} - -void -AnimatedLabelStack::showEvent( QShowEvent *e ) -{ - ensureAnimationStatus(); - QWidget::showEvent( e ); -} - - -QString -AnimatedLabelStack::elidedText( const QString& text ) const -{ - const QFontMetrics fontMetrics( font() ); - - QString newText = fontMetrics.elidedText( text, Qt::ElideRight, textRect().width() - 2 ); - - // Insert a whitespace between text and "..." (looks nicer) - if( newText != text ) - newText.insert( newText.length() -1, ' ' ); - - - return newText; -} - -void -AnimatedLabelStack::pulse( int /*cycles*/, int /*minimum*/ ) -{ - //TODO: handle parameters... - activateOnEnter(); -} - -void -AnimatedLabelStack::setAlign( Qt::Alignment align ) -{ - m_align = Qt::AlignVCenter; - if ( align & Qt::AlignLeft ) - m_align |= Qt::AlignLeft; - else if ( align & Qt::AlignRight ) - m_align |= Qt::AlignRight; - else - m_align = Qt::AlignCenter; -} - - -void -AnimatedLabelStack::setAnimated( bool on ) -{ - m_animated = on; - ensureAnimationStatus(); -} - -void -AnimatedLabelStack::setBold( bool bold ) -{ - QFont fnt = font(); - fnt.setBold(bold); - setFont(fnt); - setMinimumHeight( QFontMetrics(fnt).height() + 4 ); -} - -void -AnimatedLabelStack::setData( const QStringList &data ) -{ - if ( data == m_data ) - return; - m_data = data; - m_time = 0; - m_index = 0; - m_visibleIndex = 0; - ensureAnimationStatus(); - update(); -} - -void -AnimatedLabelStack::setPadding( int left, int right ) -{ - m_padding[0] = left; - m_padding[1] = right; - update(); -} - -void -AnimatedLabelStack::setPulsating( bool on ) -{ - if ( m_pulseRequested == on && m_pulsating == on ) - return; - m_pulseRequested = on; - m_pulsating = on; - if ( m_pulsating ) - { - m_displayTime = 1200; - m_fadeTime = 300; - if ( m_time > m_fadeTime && m_time < m_displayTime - m_fadeTime ) - m_time = m_displayTime - m_fadeTime + 1; // for instant reaction - } - else - { - m_displayTime = normalDisplayTime; - m_fadeTime = 300; - if ( !m_animated ) - m_time = m_fadeTime + 1; - } - ensureAnimationStatus(); - emit pulsing( on ); -} - -void -AnimatedLabelStack::sleep( int ms ) -{ - if ( m_animTimer ) - { - killTimer( m_animTimer ); - m_animTimer = 0; - } - if ( !m_sleepTimer ) - m_sleepTimer = startTimer( ms ); -} - -void -AnimatedLabelStack::wakeUp() -{ - if ( m_sleepTimer ) - { - killTimer( m_sleepTimer ); - m_sleepTimer = 0; - } - if ( !m_animTimer ) - m_animTimer = startTimer( frameTime ); -} - -void -AnimatedLabelStack::timerEvent( QTimerEvent * te ) -{ - - if ( !isVisible() ) - return; - if ( te->timerId() == m_sleepTimer ) - wakeUp(); - else if ( te->timerId() != m_animTimer ) - return; - - if ( m_explicit ) - return; // the user explicitly altered content by wheeling, don't take it away - - if ( m_time < m_fadeTime || m_time > (m_displayTime - m_fadeTime) ) - update(); - - m_time += frameTime; - if ( m_time > m_displayTime ) - { - m_time = 0; - if ( m_pulsating && !m_pulseRequested ) - m_visibleIndex = m_index; - else - { - ++m_visibleIndex; - if ( m_visibleIndex >= m_data.count() ) - m_visibleIndex = 0; - } - if ( !m_pulsating ) - m_index = m_visibleIndex; - } - - if ( m_time < m_fadeTime ) // fade in - { - if ( m_pulseRequested && !m_pulsating ) - setPulsating( true ); - m_opacity = m_targetOpacity*m_time/m_fadeTime; - wakeUp(); - } - else if ( m_pulsating && m_time > (m_displayTime - m_fadeTime) ) // fade out - { - m_opacity = m_targetOpacity*(m_displayTime - m_time)/m_fadeTime; - wakeUp(); - } - else // (ensure) no fade - { - if ( !m_pulsating && m_time < (m_displayTime - m_fadeTime) ) - { - m_time = m_displayTime - m_fadeTime + 1; - sleep( m_time ); - } - - m_opacity = m_targetOpacity; // to be sure - - if ( m_pulsating && !m_pulseRequested && m_index == m_visibleIndex ) - setPulsating( false ); - } -} - -void -AnimatedLabelStack::wheelEvent( QWheelEvent * we ) -{ - if ( we->modifiers() & Qt::ControlModifier ) - { - we->accept(); - if ( m_data.count() < 2 ) - return; - - setPulsating( false ); - - if ( we->delta() < 0 ) - { - ++m_visibleIndex; - if ( m_visibleIndex >= m_data.count() ) - m_visibleIndex = 0; - } - else - { - --m_visibleIndex; - if ( m_visibleIndex < 0 ) - m_visibleIndex = m_data.count() - 1; - } - m_index = m_visibleIndex; - m_time = m_fadeTime + 1; - m_explicit = true; - update(); - } - else - we->ignore(); -} - -#include "moc_AnimatedLabelStack.cpp" diff --git a/amarok/src/widgets/AnimatedLabelStack.h b/amarok/src/widgets/AnimatedLabelStack.h deleted file mode 100644 index 5c343587..00000000 --- a/amarok/src/widgets/AnimatedLabelStack.h +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************************** -* Copyright (c) 2009 Thomas Luebking * -* Copyright (c) 2010 Mark Kretschmann * -* * -* This program 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 2 of the License, or (at your option) any later * -* version. * -* * -* This program 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 * -* this program. If not, see . * -****************************************************************************************/ - -#ifndef ANIMATEDLABELSTACK_H -#define ANIMATEDLABELSTACK_H - -#include - -class AnimatedLabelStack : public QWidget -{ - Q_OBJECT - -public: - explicit AnimatedLabelStack( const QStringList &data, QWidget *parent = 0, Qt::WindowFlags f = 0 ); - inline const QStringList &data() const { return m_data; } - inline int opacity() { return m_targetOpacity; } - void pulse( int cycles = -1, int minimum = 3 ); - void setAlign( Qt::Alignment ); - void setBold( bool bold ); - void setData( const QStringList &data ); - inline void setOpacity( int alpha ) { m_targetOpacity = qMin(qMax(0, alpha), 255); } - void setPadding( int left, int right ); - /** - The rect that's actually available for the tex, i.e. honoring the padding - */ - inline QRect textRect() const { return rect().adjusted( m_padding[0], 0, -m_padding[1], 0 ); } - -public slots: - void setAnimated( bool on = true ); - inline void setStill( bool off = true ) { setAnimated( !off ); } - -signals: - void pulsing( bool ); - void clicked( const QString ¤t ); - -protected: - void enterEvent( QEvent * ); - void hideEvent( QHideEvent * ); - void leaveEvent( QEvent * ); - void paintEvent( QPaintEvent * ); - void mouseReleaseEvent( QMouseEvent * ); - void mousePressEvent( QMouseEvent * ); - void showEvent( QShowEvent * ); - void timerEvent( QTimerEvent * ); - void wheelEvent( QWheelEvent * ); - -private: - void ensureAnimationStatus(); - void setPulsating( bool on ); - void sleep( int ms ); - void wakeUp(); - -private slots: - void activateOnEnter(); - -private: - /** - * Creates an elided version of a string that fits in this widget. - * - * @return elided version of given string - */ - QString elidedText( const QString& text ) const; - - Qt::Alignment m_align; - int m_animTimer, m_sleepTimer; - int m_time, m_fadeTime, m_displayTime; - int m_index, m_visibleIndex; - int m_opacity, m_targetOpacity; - bool m_animated, m_pulsating, m_pulseRequested, m_explicit; - int m_isClick; - int m_padding[2]; - QStringList m_data; -}; - - -#endif // end include guard diff --git a/amarok/src/widgets/BookmarkPopup.cpp b/amarok/src/widgets/BookmarkPopup.cpp deleted file mode 100644 index 68d3a033..00000000 --- a/amarok/src/widgets/BookmarkPopup.cpp +++ /dev/null @@ -1,217 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Casey Link * - * Copyright (c) 2009 Simon Bühler * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "BookmarkPopup.h" - -#include "SvgHandler.h" -#include "amarokurls/BookmarkModel.h" -#include "core/support/Debug.h" -#include "widgets/BookmarkTriangle.h" - -#include - -#include -#include - -BookmarkPopup::BookmarkPopup ( QWidget* parent, QString label, BookmarkTriangle* triangle ) - : QWidget ( parent ) - , m_label ( label ) - , m_triangle ( triangle ) - -{ - m_timer = new QTimer ( this ); - connect ( m_timer, SIGNAL (timeout()), this, SLOT (hideTimerAction()) ); - - m_displayNeeded = true; - m_hasMouseOver = false; - m_overDelete = false; - m_isEditMode = false; - - m_deleteIcon = KIcon ( "edit-delete" ); - adjustWidth(); - - m_edit = new QLineEdit ( m_label, 0 ); - m_edit->setVisible ( false ); - m_edit->setAlignment ( Qt::AlignHCenter ); - connect ( m_edit, SIGNAL (returnPressed()), this, SLOT (editValueChanged()) ); - - QVBoxLayout * layout = new QVBoxLayout; - layout->setContentsMargins ( 1, 0, 0, 0 ); - layout->addSpacing ( m_lineHeight + 2 ); - layout->addWidget ( m_edit ); - setLayout ( layout ); - setMouseTracking ( true ); - setFocusPolicy(Qt::StrongFocus); -} - -QSize BookmarkPopup::sizeHint() const -{ - return QSize ( m_width, m_height ); -} - -QSizePolicy BookmarkPopup::sizePolicy() const -{ - return QSizePolicy ( QSizePolicy::Preferred, QSizePolicy::Minimum ); -} - -QSize BookmarkPopup::minimumSizeHint() const -{ - return QSize ( m_width, m_height ); -} - -void BookmarkPopup::adjustWidth() -{ - //calculate height and width - const int margin = 3; - QFontMetrics fm ( font() ); - m_lineHeight = fm.height(); - int line1Width = fm.width ( i18n ( "Bookmark" ) ) + 40; //padding and space for delete icon - int line2Width = fm.width ( m_label ) + 8 ; - m_height = 44; - m_width = qMax ( line1Width, line2Width ) + 2 * margin; - resize ( m_width, m_height ); - m_deleteIconRect = QRect ( m_width - 20, 4, 16, 16 ); -} - -void BookmarkPopup::paintEvent ( QPaintEvent* event ) -{ - QPainter p ( this ); - p.setRenderHint ( QPainter::Antialiasing ); - p.setBrush ( Qt::white ); - p.setOpacity ( 0.85 ); - QPen pen = QPen ( Qt::black ); - pen.setCosmetic ( true ); - p.setPen ( pen ); - QRect rect = QRect ( 0,0, m_width, m_height ); - p.drawRoundedRect ( rect, 5, 5 ); - - if ( m_overDelete ) p.setOpacity ( m_overDelete ? 1 : 0.1 ); - p.drawPixmap ( m_deleteIconRect.x(), m_deleteIconRect.y(), m_deleteIcon.pixmap ( 16 ) ); - - p.setOpacity ( 1 ); - p.drawPixmap ( 5, 1, The::svgHandler()->renderSvg ( "bookmarks", 6, 20, "bookmarks" ) ); - - p.setPen ( Qt::gray ); - rect = QRect ( 15, 3, m_width, m_lineHeight ); - p.drawText ( rect, Qt::AlignLeft, i18n ( "Bookmark" ) ); - - if ( m_isEditMode ) // paint Label or render QLineEdit - { - event->accept(); - } - else - { - p.setPen ( Qt::black ); - rect = QRect ( 0, m_lineHeight + 8, m_width, m_lineHeight ); - p.drawText ( rect, Qt::AlignCenter, m_label ); - } - -} - -void BookmarkPopup::mouseReleaseEvent ( QMouseEvent * event ) -{ - if ( event->button() == Qt::LeftButton ) - { - if ( isOverDeleteIcon ( event->pos() ) ) // handle close - { - m_triangle->deleteBookmark(); - return; - } - if ( isOverTitleLabel ( event->pos() ) ) // handle click in editable Area - { - if ( m_isEditMode ) - return; - - m_isEditMode = true; // switch to Editmode - m_edit->setVisible ( m_isEditMode ); - m_edit->setFocus(); - update(); - return; - } - // other clicks discard changes and leave Editmode - m_isEditMode = false; - m_edit->setVisible ( m_isEditMode ); - m_edit->setText( m_label ); - update(); - } -} - -void BookmarkPopup::mouseMoveEvent ( QMouseEvent * event ) -{ - // Monitor for DeleteIcon highlighting - bool state = isOverDeleteIcon ( event->pos() ); - if ( state != m_overDelete ) - { - m_overDelete = state; - this->update(); - } -} - -void BookmarkPopup::enterEvent ( QEvent* ) -{ - m_hasMouseOver = true; -} - -void BookmarkPopup::leaveEvent ( QEvent* ) -{ - m_hasMouseOver = false; - startHideTimer(); - -} - -void BookmarkPopup::displayNeeded ( bool value ) -{ - m_displayNeeded = value; - if ( !m_displayNeeded ) startHideTimer(); -} - -void BookmarkPopup::hideTimerAction ( ) -{ - if ( m_hasMouseOver || m_isEditMode || m_displayNeeded ) - return; - - m_timer->stop(); - hide(); -} - -void BookmarkPopup::editValueChanged() -{ - if ( m_label != m_edit->text() && m_edit->text().trimmed().length() > 0 ) - { - BookmarkModel::instance()->renameBookmark( m_label, m_edit->text().trimmed() ); - return; - } - m_isEditMode = false; - m_edit->setVisible ( m_isEditMode ); - update(); -} - -void BookmarkPopup::startHideTimer() -{ - m_timer->start ( 500 ); -} - -bool BookmarkPopup::isOverDeleteIcon ( QPoint pos ) -{ - return m_deleteIconRect.contains ( pos ); -} - - -bool BookmarkPopup::isOverTitleLabel ( QPoint pos ) -{ - return ( pos.y() > m_lineHeight +2 ); -} diff --git a/amarok/src/widgets/BookmarkPopup.h b/amarok/src/widgets/BookmarkPopup.h deleted file mode 100644 index c2a50d5c..00000000 --- a/amarok/src/widgets/BookmarkPopup.h +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Casey Link * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef BOOKMARKPOPUP_H -#define BOOKMARKPOPUP_H - -#include -#include -#include -#include - -#include - -class BookmarkTriangle; - -class BookmarkPopup : public QWidget -{ - Q_OBJECT - -public: - BookmarkPopup ( QWidget* parent, QString label, BookmarkTriangle* triangle ); - - virtual QSize sizeHint () const; - virtual QSizePolicy sizePolicy () const; - virtual QSize minimumSizeHint () const; - - virtual void mouseReleaseEvent ( QMouseEvent * event ); - virtual void mouseMoveEvent ( QMouseEvent * event ); - virtual void enterEvent ( QEvent* ); - virtual void leaveEvent ( QEvent* ); - - virtual void displayNeeded ( bool value ); - -protected: - - virtual void paintEvent ( QPaintEvent* event ); - -protected slots: - virtual void editValueChanged(); - virtual void hideTimerAction(); - -private: - - bool isOverDeleteIcon ( QPoint arg1 ); - bool isOverTitleLabel ( QPoint arg1 ); - - void adjustWidth (); - void startHideTimer (); - - QTimer *m_timer; - QString m_label; - KIcon m_deleteIcon; - QRect m_deleteIconRect; - QLineEdit *m_edit; - int m_width; - BookmarkTriangle *m_triangle; - int m_height; - int m_lineHeight; - - bool m_displayNeeded; - bool m_hasMouseOver; - bool m_overDelete; - bool m_isEditMode; - - -}; - -#endif // BOOKMARKPOPUP_H diff --git a/amarok/src/widgets/BookmarkTriangle.cpp b/amarok/src/widgets/BookmarkTriangle.cpp deleted file mode 100644 index 0bfac675..00000000 --- a/amarok/src/widgets/BookmarkTriangle.cpp +++ /dev/null @@ -1,188 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Casey Link * - * Copyright (c) 2009 Mark Kretschmann * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "BookmarkTriangle.h" - -#include "EngineController.h" -#include "MainWindow.h" -#include "SvgHandler.h" -#include "amarokurls/BookmarkModel.h" -#include "amarokurls/PlayUrlGenerator.h" -#include "core/meta/Meta.h" -#include "core/meta/support/MetaUtility.h" -#include "core/support/Debug.h" - -#include - -#include -#include -#include -#include - -BookmarkTriangle::BookmarkTriangle ( QWidget *parent, int milliseconds, QString name, - int sliderwidth, bool showPopup ) - : QWidget ( parent ), - m_mseconds ( milliseconds ), - m_name ( name ), - m_sliderwidth ( sliderwidth ), - m_showPopup ( showPopup ), - m_tooltip ( 0 ) -{ -} - -BookmarkTriangle::~BookmarkTriangle() -{ - DEBUG_BLOCK - if (m_tooltip) - m_tooltip->deleteLater(); -} - -QSize BookmarkTriangle::sizeHint() const -{ - return QSize ( 10, 10 ); -} - -QSizePolicy BookmarkTriangle::sizePolicy() const -{ - return QSizePolicy ( QSizePolicy::Fixed, QSizePolicy::Fixed ); -} - -QSize BookmarkTriangle::minimumSizeHint() const -{ - return QSize ( 10, 10 ); -} - -int BookmarkTriangle::getTimeValue() -{ - return m_mseconds; -} - -void BookmarkTriangle::paintEvent ( QPaintEvent* ) -{ - QPainter p ( this ); - p.drawPixmap ( 0, 0, The::svgHandler()->renderSvg ( "blue_triangle", 10 , 10, "blue_triangle" ) ); // TODO: This doesn't work -} - -void BookmarkTriangle::showEvent ( QShowEvent * event ) -{ - Q_UNUSED( event ); //FIXME: event->accept() should probably be called - - if ( m_showPopup ) - { - m_showPopup = false; // Force immediate Popup Display after editing - initPopup(); - } -} - -void BookmarkTriangle::mousePressEvent ( QMouseEvent * event ) -{ - event->accept(); - m_offset = event->pos(); - m_pos = this->x(); -} - -void BookmarkTriangle::mouseMoveEvent ( QMouseEvent * event ) -{ - event->accept(); - int distance_x = event->x() - m_offset.x(); - QPoint pt(distance_x, 0); - move(mapToParent( pt )); -} - -void BookmarkTriangle::mouseReleaseEvent ( QMouseEvent * event ) -{ - event->accept(); - - if( this->x() == m_pos ){ - emit clicked ( m_mseconds ); - } - else - { - if( this->x() < 0 || this->x() > m_sliderwidth ) - { - this->setGeometry(m_pos, 1, 11, 11); - this->update(); - } - else{ - qreal percentage = (qreal) ( this->x() ) / (qreal) m_sliderwidth; - long trackLength = The::engineController()->trackLength(); - qint64 trackPosition = trackLength * percentage; - moveBookmark( trackPosition, m_name ); - } - } -} - -void BookmarkTriangle::moveBookmark ( qint64 newMilliseconds, QString name ) -{ - hidePopup(); - Meta::TrackPtr track = The::engineController()->currentTrack(); - PlayUrlGenerator::instance()->moveTrackBookmark( track, newMilliseconds, name ); -} - -void BookmarkTriangle::deleteBookmark () -{ - DEBUG_BLOCK - - debug() << "Name: " << m_name; - hidePopup(); - BookmarkModel::instance()->deleteBookmark ( m_name ); - -} - -void BookmarkTriangle::enterEvent ( QEvent * event ) -{ - DEBUG_BLOCK - Q_UNUSED ( event ) - - emit focused ( m_mseconds ); - initPopup(); -} - -void BookmarkTriangle::leaveEvent ( QEvent * event ) -{ - DEBUG_BLOCK - Q_UNUSED ( event ) - if (m_tooltip) - m_tooltip->displayNeeded(false); -} - -void BookmarkTriangle::initPopup() -{ - if ( !m_tooltip ) m_tooltip = new BookmarkPopup ( The::mainWindow(), m_name , this ); - // Keep existing tooltip alive - m_tooltip->displayNeeded(true); - - QPoint pt = mapTo ( The::mainWindow(), QPoint ( 0, 0 ) ); - // Calculate x position where the tooltip is fully visible - int offsetX = pt.x() + m_tooltip->width() - The::mainWindow()->width(); - if ( offsetX < 0 ) offsetX = 0; - // Calculate y position above - int offsetY = - m_tooltip->height() - 2; - // Not enough space? put it below - if ( pt.y() <= m_tooltip->height() + 2 ) offsetY = this->height() + 2; - m_tooltip->move ( pt.x() - offsetX, pt.y() + offsetY ); - - m_tooltip->show(); -} - -void BookmarkTriangle::hidePopup() -{ - if ( m_tooltip ) m_tooltip->hide(); -} -#include "moc_BookmarkTriangle.cpp" - diff --git a/amarok/src/widgets/BookmarkTriangle.h b/amarok/src/widgets/BookmarkTriangle.h deleted file mode 100644 index 077f1d49..00000000 --- a/amarok/src/widgets/BookmarkTriangle.h +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Casey Link * - * Copyright (c) 2009 Mark Kretschmann . * - ****************************************************************************************/ - -#ifndef BOOKMARKTRIANGLE_H -#define BOOKMARKTRIANGLE_H - -#include "BookmarkPopup.h" - -#include - -#include -#include -#include - -class QSize; -class QSizePolicy; - - -class BookmarkTriangle : public QWidget -{ - Q_OBJECT -public: - BookmarkTriangle( QWidget *parent, int milliseconds, QString name, int sliderwidth, - bool showPopup = false ); - ~BookmarkTriangle(); - virtual QSize sizeHint() const; - virtual QSizePolicy sizePolicy() const; - virtual QSize minimumSizeHint() const; - - virtual void showEvent ( QShowEvent * event ); - virtual void mousePressEvent ( QMouseEvent * event ); - virtual void mouseMoveEvent ( QMouseEvent * event ); - virtual void mouseReleaseEvent (QMouseEvent *); - virtual void enterEvent ( QEvent * event ); - virtual void leaveEvent ( QEvent * event ); - virtual void paintEvent ( QPaintEvent* ); - - virtual void hidePopup(); - - /** - * Updates the position of the bookmark named @param name to @param newMiliseconds. - * - * The name should be a valid existing bookmark name and should include the trailing - * "- m:ss" - */ - virtual void moveBookmark( qint64 newMilliseconds, QString name ); - - virtual void deleteBookmark(); - virtual int getTimeValue(); - -signals: - void clicked ( int ); - void focused ( int ); - -private: - void initPopup(); - - int m_mseconds; /// position of the bookmark on the slider in terms of milliseconds - QString m_name; /// name of the bookmark - int m_sliderwidth; /// width of the slider on which the bookmark will appear - bool m_showPopup; /// used to determine whether to show the Pop-up on focussing the bookmark - BookmarkPopup* m_tooltip; /// the tooltip that appears on focussing the bookmark - QPoint m_offset; /// used while moving the bookmark, holds the position of the bookmark before moving - int m_pos; /// used while moving the bookmark, holds the x co-ordinate of the bookmark after moving -}; -#endif // BOOKMARKTRIANGLE_H diff --git a/amarok/src/widgets/BreadcrumbItemButton.cpp b/amarok/src/widgets/BreadcrumbItemButton.cpp deleted file mode 100644 index 85619b21..00000000 --- a/amarok/src/widgets/BreadcrumbItemButton.cpp +++ /dev/null @@ -1,330 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2006 Peter Penz * - * Copyright (c) 2006 Aaron Seigo * - * Copyright (c) 2009 Seb Ruiz * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "BreadcrumbItemButton.h" - -#include "amarokurls/AmarokUrlAction.h" -#include "amarokurls/AmarokUrlHandler.h" -#include "core/support/Amarok.h" - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -BreadcrumbItemButton::BreadcrumbItemButton( QWidget *parent ) - : Amarok::ElidingButton( parent ) - , m_displayHint( 0 ) -{ - init(); -} - -BreadcrumbItemButton::BreadcrumbItemButton( const QString &text, QWidget *parent ) - : Amarok::ElidingButton( text, parent ) - , m_displayHint( 0 ) -{ - init(); -} - -BreadcrumbItemButton::BreadcrumbItemButton( const QIcon &icon, const QString &text, QWidget *parent ) - : Amarok::ElidingButton( icon, text, parent ) - , m_displayHint( 0 ) -{ - init(); -} - -void -BreadcrumbItemButton::init() -{ - setFocusPolicy( Qt::NoFocus ); - setDisplayHintEnabled( HoverHint, false ); -} - -BreadcrumbItemButton::~BreadcrumbItemButton() -{ -} - -void -BreadcrumbItemButton::setActive( const bool active ) -{ - setDisplayHintEnabled( ActiveHint, active ); - - QFont f = font(); - f.setBold( active ); - setFont( f ); -} - -void -BreadcrumbItemButton::setDisplayHintEnabled( DisplayHint hint, bool enable ) -{ - if( enable ) - m_displayHint = m_displayHint | hint; - else - m_displayHint = m_displayHint & ~hint; - - update(); -} - -bool -BreadcrumbItemButton::isDisplayHintEnabled( DisplayHint hint ) const -{ - return (m_displayHint & hint) > 0; -} - -void -BreadcrumbItemButton::enterEvent( QEvent* event ) -{ - QPushButton::enterEvent( event ); - setDisplayHintEnabled( HoverHint, true ); - update(); -} - -void -BreadcrumbItemButton::leaveEvent( QEvent* event ) -{ - QPushButton::leaveEvent( event ); - setDisplayHintEnabled( HoverHint, false ); - update(); -} - -void -BreadcrumbItemButton::paintEvent( QPaintEvent* event ) -{ - Q_UNUSED(event); - - QPainter painter(this); - - const int buttonHeight = height(); - int buttonWidth = width(); - int preferredWidth = sizeHint().width(); - if (preferredWidth < minimumWidth()) { - preferredWidth = minimumWidth(); - } - if (buttonWidth > preferredWidth) { - buttonWidth = preferredWidth; - } - drawHoverBackground(&painter); - - int left, top, right, bottom; - getContentsMargins ( &left, &top, &right, &bottom ); - const int padding = 2; - int xoffset; - - if( !icon().isNull() ) - { - const int iconWidth = iconSize().width(); - const int iconHeight = iconSize().height(); - const int iconTop = ( (buttonHeight - top - bottom) - iconHeight ) / 2; - const QRect iconRect( left + padding, iconTop, iconWidth, iconHeight ); - painter.drawPixmap( iconRect, icon().pixmap( iconSize() ) ); - xoffset = left + (padding * 2) + iconWidth; - } - else - xoffset = left + (padding * 2); - - const QRect textRect( xoffset, top, buttonWidth, buttonHeight); - painter.drawText(textRect, Qt::AlignVCenter, text()); -} - - -void -BreadcrumbItemButton::drawHoverBackground(QPainter* painter) -{ - const bool isHovered = isDisplayHintEnabled( HoverHint ); - - if( isHovered ) - { - // QColor backgroundColor = palette().color(QPalette::Highlight); - // TODO: the backgroundColor should be applied to the style - QStyleOptionViewItemV4 option; - option.initFrom(this); - option.state = QStyle::State_Enabled | QStyle::State_MouseOver; - option.viewItemPosition = QStyleOptionViewItemV4::OnlyOne; - style()->drawPrimitive( QStyle::PE_PanelItemViewItem, &option, painter, this ); - } -} - -QColor -BreadcrumbItemButton::foregroundColor() const -{ - const bool isHighlighted = isDisplayHintEnabled( HoverHint ); - const bool isActive = isDisplayHintEnabled( ActiveHint ); - - QColor foregroundColor = palette().color( foregroundRole() ); - if( !isActive && !isHighlighted ) - foregroundColor.setAlpha( 180 ); - - return foregroundColor; -} - -QSize -BreadcrumbItemButton::sizeHint() const -{ - QSize size = Amarok::ElidingButton::sizeHint(); - int width = 8; - if( !icon().isNull() ) - { - width += iconSize().width(); - } - if( !text().isEmpty() ) - { - QFontMetrics fm( font() ); - width += fm.width( text() ); - } - size.setWidth( width ); - return size; -} - - -BreadcrumbItemMenuButton::BreadcrumbItemMenuButton( QWidget* parent ) - : BreadcrumbItemButton( parent ) -{ - setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ); -} - -void -BreadcrumbItemMenuButton::paintEvent( QPaintEvent* event ) -{ - Q_UNUSED(event); - - QPainter painter(this); - drawHoverBackground(&painter); - - const QColor fgColor = foregroundColor(); - - QStyleOption option; - option.initFrom(this); - option.rect = QRect(0, 0, width(), height()); - option.palette = palette(); - option.palette.setColor(QPalette::Text, fgColor); - option.palette.setColor(QPalette::WindowText, fgColor); - option.palette.setColor(QPalette::ButtonText, fgColor); - - if (layoutDirection() == Qt::LeftToRight) { - style()->drawPrimitive(QStyle::PE_IndicatorArrowRight, &option, &painter, this); - } else { - style()->drawPrimitive(QStyle::PE_IndicatorArrowLeft, &option, &painter, this); - } -} - - - -BreadcrumbUrlMenuButton::BreadcrumbUrlMenuButton( const QString &urlsCommand, QWidget *parent ) - : BreadcrumbItemButton( KIcon( "bookmark-new-list" ), QString(), parent ) - , m_urlsCommand( urlsCommand ) - , m_copyToClipboardAction( 0 ) -{ - setToolTip( i18n( "List and run bookmarks, or create new ones" ) ); - - connect( this, SIGNAL(clicked(bool)), this, SLOT(showMenu()) ); -} - -BreadcrumbUrlMenuButton::~BreadcrumbUrlMenuButton() -{ -} - -void -BreadcrumbUrlMenuButton::generateMenu( const QPoint &pos ) -{ - - DEBUG_BLOCK - - BookmarkList list = The::amarokUrlHandler()->urlsByCommand( m_urlsCommand ); - - QMenu * menu = new QMenu(); - menu->setTitle( i18n("Amarok Bookmarks" ) ); - - if( m_urlsCommand == "navigate" ) - menu->addAction( Amarok::actionCollection()->action( "bookmark_browser" ) ); - else if( m_urlsCommand == "playlist" ) - { - menu->addAction( Amarok::actionCollection()->action( "bookmark_playlistview" ) ); - debug()<<"Adding bookmark playlist action"; - } - else if( m_urlsCommand == "context" ) - { - menu->addAction( Amarok::actionCollection()->action( "bookmark_contextview" ) ); - debug()<<"Adding bookmark context view action"; - } - else - warning()<<"Bad URL command."; - - if( !m_copyToClipboardAction ) - { - m_copyToClipboardAction = new QAction( KIcon( "klipper" ), i18n( "Copy Current View Bookmark to Clipboard" ), this ); - connect( m_copyToClipboardAction, SIGNAL(triggered(bool)), this, SLOT(copyCurrentToClipboard()) ); - } - - menu->addAction( m_copyToClipboardAction ); - - menu->addAction( Amarok::actionCollection()->action( "bookmark_manager" ) ); - - menu->addSeparator(); - - foreach( AmarokUrlPtr url, list ) - { - menu->addAction( new AmarokUrlAction( url, menu ) ); - } - - debug() << "showing menu at " << pos; - menu->exec( pos ); - delete menu; - -} - -void -BreadcrumbUrlMenuButton::showMenu() -{ - QPoint pos( 0, height() ); - generateMenu( mapToGlobal( pos ) ); -} - -void -BreadcrumbUrlMenuButton::copyCurrentToClipboard() -{ - - QString urlString; - - if( m_urlsCommand == "navigate" ) - { - AmarokUrl url = The::amarokUrlHandler()->createBrowserViewBookmark(); - urlString = url.url(); - } - else if( m_urlsCommand == "playlist" ) - { - AmarokUrl url = The::amarokUrlHandler()->createPlaylistViewBookmark(); - urlString = url.url(); - } - else if( m_urlsCommand == "context" ) - { - AmarokUrl url = The::amarokUrlHandler()->createContextViewBookmark(); - urlString = url.url(); - } - - QApplication::clipboard()->setText( urlString ); - -} - -#include "moc_BreadcrumbItemButton.cpp" diff --git a/amarok/src/widgets/BreadcrumbItemButton.h b/amarok/src/widgets/BreadcrumbItemButton.h deleted file mode 100644 index d38c6f3a..00000000 --- a/amarok/src/widgets/BreadcrumbItemButton.h +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2006 Peter Penz * - * Copyright (c) 2006 Aaron Seigo * - * Copyright (c) 2009 Seb Ruiz * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef BREADCRUMBITEMBUTTON_P_H -#define BREADCRUMBITEMBUTTON_P_H - -#include - -#include "widgets/ElidingButton.h" - -class KUrl; -class QEvent; -class KUrlNavigator; - -/** - * @brief Base class for buttons of the URL navigator. - * - * Each button of the URL navigator contains an URL, which - * is set as soon as the button has been clicked. - */ -class BreadcrumbItemButton : public Amarok::ElidingButton -{ - Q_OBJECT - - public: - BreadcrumbItemButton( QWidget* parent ); - BreadcrumbItemButton( const QString &text, QWidget *parent ); - BreadcrumbItemButton( const QIcon &icon, const QString &text, QWidget *parent ); - virtual ~BreadcrumbItemButton(); - - void setActive( const bool active ); - - virtual QSize sizeHint() const; - - protected: - enum DisplayHint - { - ActiveHint = 1, - HoverHint = 2 - }; - - void setDisplayHintEnabled(DisplayHint hint, bool enable); - bool isDisplayHintEnabled(DisplayHint hint) const; - - virtual void enterEvent(QEvent* event); - virtual void leaveEvent(QEvent* event); - - virtual void paintEvent(QPaintEvent* event); - virtual void drawHoverBackground(QPainter* painter); - - /** Returns the foreground color by respecting the current display hint. */ - QColor foregroundColor() const; - - private: - void init(); - int m_displayHint; -}; - -class BreadcrumbItemMenuButton : public BreadcrumbItemButton -{ - Q_OBJECT - - public: - explicit BreadcrumbItemMenuButton( QWidget* parent ); - virtual ~BreadcrumbItemMenuButton() { } - - protected: - virtual void paintEvent(QPaintEvent* event); -}; - -class BreadcrumbUrlMenuButton : public BreadcrumbItemButton -{ - Q_OBJECT - public: - BreadcrumbUrlMenuButton( const QString &urlsCommand, QWidget *parent ); - virtual ~BreadcrumbUrlMenuButton(); - - public slots: - void generateMenu( const QPoint &pos ); - - protected slots: - void showMenu(); - void copyCurrentToClipboard(); - - - private: - QString m_urlsCommand; - QAction * m_copyToClipboardAction; - -}; - -#endif diff --git a/amarok/src/widgets/ClearSpinBox.cpp b/amarok/src/widgets/ClearSpinBox.cpp deleted file mode 100644 index b2eb4215..00000000 --- a/amarok/src/widgets/ClearSpinBox.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2011 Sergey Ivanov <123kash@gmail.com> * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - - -#include "ClearSpinBox.h" - -ClearSpinBox::ClearSpinBox( QWidget* parent ) - : QSpinBox( parent ) -{ -} - -QValidator::State -ClearSpinBox::validate( QString &input, int &pos ) const -{ - return input.isEmpty() ? QValidator::Acceptable : QSpinBox::validate( input, pos ); -} - -int -ClearSpinBox::valueFromText( const QString &text ) const -{ - return text.isEmpty() ? minimum() : QSpinBox::valueFromText( text ); -} - -QString -ClearSpinBox::textFromValue( int val ) const -{ - return ( val == minimum() ) ? QString() : QSpinBox::textFromValue( val ); -} - diff --git a/amarok/src/widgets/ClearSpinBox.h b/amarok/src/widgets/ClearSpinBox.h deleted file mode 100644 index b7dc71bf..00000000 --- a/amarok/src/widgets/ClearSpinBox.h +++ /dev/null @@ -1,35 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2011 Sergey Ivanov <123kash@gmail.com> * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - - -#ifndef CLEARSPINBOX_H -#define CLEARSPINBOX_H - -#include - - -class ClearSpinBox : public QSpinBox -{ - public: - ClearSpinBox( QWidget* parent = 0 ); - - protected: - virtual QValidator::State validate( QString &input, int &pos ) const; - virtual int valueFromText( const QString& text ) const; - virtual QString textFromValue( int val ) const; -}; - -#endif // CLEARSPINBOX_H diff --git a/amarok/src/widgets/ComboBox.cpp b/amarok/src/widgets/ComboBox.cpp deleted file mode 100644 index 91df0011..00000000 --- a/amarok/src/widgets/ComboBox.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Seb Ruiz * - * Copyright (c) 2010 Rick W. Chen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "ComboBox.h" - -#include - -namespace Amarok -{ - -ComboBox::ComboBox( QWidget *parent ) - : KComboBox( parent ) -{ - setEditable( true ); -} - -void ComboBox::keyPressEvent( QKeyEvent *event ) -{ - if( event->key() == Qt::Key_Escape ) - { - event->accept(); - clearEditText(); - return; - } - else if( event->key() == Qt::Key_Down ) - { - event->accept(); - emit downPressed(); - return; - } - KComboBox::keyPressEvent( event ); -} - -} // namespace AMAROK - -#include "moc_ComboBox.cpp" diff --git a/amarok/src/widgets/ComboBox.h b/amarok/src/widgets/ComboBox.h deleted file mode 100644 index 40515062..00000000 --- a/amarok/src/widgets/ComboBox.h +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Seb Ruiz * - * Copyright (c) 2010 Rick W. Chen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_COMBO_BOX_H -#define AMAROK_COMBO_BOX_H - -#include //baseclass - -class QKeyEvent; - -namespace Amarok -{ - -/** - * The Amarok::ComboBox class implements a few enhancements to an editable KComboBox. - * Namely: - * 1. Pressing the escape key clears the edit text - * 2. Pressing down emits the downPressed signal - * 3. Pressing enter adds the current text to the completion popup - */ -class ComboBox : public KComboBox -{ - Q_OBJECT - - public: - ComboBox( QWidget *parent = 0 ); - virtual ~ComboBox() {}; - - protected: - virtual void keyPressEvent( QKeyEvent *event ); - - signals: - void downPressed(); -}; - -} // namespace AMAROK - -#endif // AMAROK_COMBO_BOX_H diff --git a/amarok/src/widgets/CoverLabel.cpp b/amarok/src/widgets/CoverLabel.cpp deleted file mode 100644 index b905f6f6..00000000 --- a/amarok/src/widgets/CoverLabel.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2004 Mark Kretschmann * - * Copyright (c) 2004 Stefan Bogner * - * Copyright (c) 2004 Max Howell * - * Copyright (c) 2007 Dan Meltzer * - * Copyright (c) 2009 Martin Sandsmark * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "CoverLabel.h" - -CoverLabel::CoverLabel( QWidget * parent, Qt::WindowFlags f ) - : QLabel( parent, f) -{} - -void CoverLabel::setInformation( const QString &artist, const QString &album ) -{ - m_artist = artist; - m_album = album; -} - -void CoverLabel::mouseReleaseEvent( QMouseEvent *pEvent ) -{ - if( pEvent->button() == Qt::LeftButton || pEvent->button() == Qt::RightButton ) - { -// Amarok::coverContextMenu( this, pEvent->globalPos(), m_albumPtr, false ); - } -} - diff --git a/amarok/src/widgets/CoverLabel.h b/amarok/src/widgets/CoverLabel.h deleted file mode 100644 index 89f95d52..00000000 --- a/amarok/src/widgets/CoverLabel.h +++ /dev/null @@ -1,41 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2004 Mark Kretschmann * - * Copyright (c) 2004 Stefan Bogner * - * Copyright (c) 2007 Dan Meltzer * - * Copyright (c) 2009 Martin Sandsmark * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_COVERLABEL_H -#define AMAROK_COVERLABEL_H - -#include -#include - -class CoverLabel : public QLabel -{ -public: - explicit CoverLabel( QWidget * parent, Qt::WindowFlags f = 0 ); - - void setInformation( const QString &artist, const QString &album ); - -protected: - virtual void mouseReleaseEvent( QMouseEvent *pEvent ); - -private: - QString m_artist; - QString m_album; -}; - -#endif /* AMAROK_COVERLABEL_H */ diff --git a/amarok/src/widgets/EditDeleteComboBoxView.cpp b/amarok/src/widgets/EditDeleteComboBoxView.cpp deleted file mode 100644 index 6950107d..00000000 --- a/amarok/src/widgets/EditDeleteComboBoxView.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "EditDeleteComboBoxView.h" - -#include "core/support/Debug.h" -#include "EditDeleteDelegate.h" - -#include -#include - -EditDeleteComboBoxView::EditDeleteComboBoxView( QWidget* parent ) - : QListView( parent ) -{ -} - -void EditDeleteComboBoxView::mousePressEvent( QMouseEvent *event ) -{ - DEBUG_BLOCK - - QModelIndex index = indexAt( event->pos() ); - QPoint mousePressPos = event->pos(); - mousePressPos.rx() += horizontalOffset(); - mousePressPos.ry() += verticalOffset(); - - if ( EditDeleteDelegate::hitsEdit( mousePressPos, rectForIndex( index ) ) ) - emit( editItem( index.data().toString() ) ); - else if ( EditDeleteDelegate::hitsDelete( mousePressPos, rectForIndex( index ) ) ) - emit( deleteItem( index.data().toString() ) ); - - QListView::mousePressEvent( event ); -} - -#include "moc_EditDeleteComboBoxView.cpp" diff --git a/amarok/src/widgets/EditDeleteComboBoxView.h b/amarok/src/widgets/EditDeleteComboBoxView.h deleted file mode 100644 index 8028c4f0..00000000 --- a/amarok/src/widgets/EditDeleteComboBoxView.h +++ /dev/null @@ -1,42 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef EDITDELETECOMBOBOXVIEW_H -#define EDITDELETECOMBOBOXVIEW_H - -#include - -/** - * A specialized QListView class needed for detecting mouse clicks on the "buttons" - * on the items in the popup. - * @author Nikolaj Hald Nielsen - */ -class EditDeleteComboBoxView : public QListView -{ - Q_OBJECT - - public: - EditDeleteComboBoxView( QWidget* parent = 0 ); - - signals: - void editItem( const QString &itemName ); - void deleteItem( const QString &itemName ); - - protected: - virtual void mousePressEvent( QMouseEvent* ); -}; - -#endif diff --git a/amarok/src/widgets/EditDeleteDelegate.cpp b/amarok/src/widgets/EditDeleteDelegate.cpp deleted file mode 100644 index adae4d80..00000000 --- a/amarok/src/widgets/EditDeleteDelegate.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "EditDeleteDelegate.h" - -#include "core/support/Debug.h" - -#include - -#include -#include - -#define ICON_WIDTH 16 -#define MARGIN 3 - - -EditDeleteDelegate::EditDeleteDelegate( QObject * parent ) - : QStyledItemDelegate( parent ) -{ -} - -void EditDeleteDelegate::paint( QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index ) const -{ - int y = option.rect.y(); - - //use normal painting, sizeHint has ensured that we have enough room for both text and icons. - QStyledItemDelegate::paint( painter, option, index ); - - int iconOffset = option.rect.width() - ( MARGIN * 3 + ICON_WIDTH * 2 ); - - if ( option.state & QStyle::State_Selected ) - { - //paint our custom stuff in the leftover space - //but only if this is the item that the mouse is over... - - const KIcon editIcon( "configure" ); - const KIcon deleteIcon( "edit-delete" ); - - QPixmap editPixmap = editIcon.pixmap( ICON_WIDTH, ICON_WIDTH ); - QPixmap deletePixmap = deleteIcon.pixmap( ICON_WIDTH, ICON_WIDTH ); - - painter->drawPixmap( iconOffset + MARGIN, y, ICON_WIDTH, ICON_WIDTH, editPixmap ); - painter->drawPixmap( iconOffset + MARGIN *2 + ICON_WIDTH, y, ICON_WIDTH, ICON_WIDTH, deletePixmap ); - } -} - -QSize EditDeleteDelegate::sizeHint( const QStyleOptionViewItem & option, const QModelIndex & index ) const -{ - const QSize orgSize = QStyledItemDelegate::sizeHint( option, index ); - const QSize addSize( MARGIN * 3 + ICON_WIDTH * 2, 0 ); - - return orgSize + addSize; -} - -bool EditDeleteDelegate::hitsEdit( const QPoint &point, const QRect &rect ) -{ - DEBUG_BLOCK - //we considder the icon to be full height, so we just count from the right edge. - int right = ( rect.x() + rect.width() ) - ( MARGIN * 2 + ICON_WIDTH ); - int left = right - ICON_WIDTH; - return ( point.x() > left ) && ( point.x() < right ); -} - -bool EditDeleteDelegate::hitsDelete( const QPoint &point, const QRect &rect ) -{ - DEBUG_BLOCK - //we considder the icon to be full height, so we just count from the right edge. - int right = ( rect.x() + rect.width() ) - MARGIN; - int left = right - ICON_WIDTH; - return ( point.x() > left ) && ( point.x() < right ); -} - diff --git a/amarok/src/widgets/EditDeleteDelegate.h b/amarok/src/widgets/EditDeleteDelegate.h deleted file mode 100644 index f0d044e0..00000000 --- a/amarok/src/widgets/EditDeleteDelegate.h +++ /dev/null @@ -1,38 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef EDITDELETEDELEGATE_H -#define EDITDELETEDELEGATE_H - -#include - -/** - A special delegate with buttons for editing and deleting the current entry. - @author Nikolaj Hald Nielsen -*/ -class EditDeleteDelegate : public QStyledItemDelegate -{ - public: - EditDeleteDelegate( QObject *parent ); - - virtual void paint ( QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index ) const; - virtual QSize sizeHint ( const QStyleOptionViewItem & option, const QModelIndex & index ) const; - - static bool hitsEdit( const QPoint &point, const QRect &rect ); - static bool hitsDelete( const QPoint &point, const QRect &rect ); -}; - -#endif diff --git a/amarok/src/widgets/ElidingButton.cpp b/amarok/src/widgets/ElidingButton.cpp deleted file mode 100644 index b833ba63..00000000 --- a/amarok/src/widgets/ElidingButton.cpp +++ /dev/null @@ -1,131 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * Copyright (c) 2009 Seb Ruiz * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "ElidingButton.h" - -#include "core/support/Debug.h" - -#include - -namespace Amarok { - -ElidingButton::ElidingButton( QWidget *parent ) - : QPushButton( parent ) -{ - init(); -} - -ElidingButton::ElidingButton( const QString & text, QWidget * parent ) - : QPushButton( text, parent ) - , m_fullText( text ) -{ - init(); -} - -ElidingButton::ElidingButton( const QIcon & icon, const QString & text, QWidget * parent ) - : QPushButton( icon, text, parent ) - , m_fullText( text ) -{ - init(); -} - -ElidingButton::~ElidingButton() -{ -} - -void ElidingButton::init() -{ - m_isElided = false; - int width = iconSize().width() + 4; - if( !text().isEmpty() ) - { - QFontMetrics fm( font() ); - width += fm.width( QLatin1String( "XX" ) ) / 2; - } - setMinimumWidth( width ); -} - -QSizePolicy ElidingButton::sizePolicy() const -{ - //This has got to be the mother of all hacks... - //If the text is currently elided, the button should try to get more space. If not elided - //then the button has all the space it needs and should really not try to expand beyond this. - //Since the size hint depends on the actual text shown (which is very short when elided) we - //cannot depend on this for making the button grow again... - if( !m_isElided ) - return QSizePolicy( QSizePolicy::Maximum, QSizePolicy::Fixed ); - - return QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); -} - -bool ElidingButton::isElided() const -{ - return m_isElided; -} - -void ElidingButton::resizeEvent( QResizeEvent *event ) -{ - elideText( event->size() ); - QPushButton::resizeEvent( event ); -} - -void ElidingButton::setText( const QString &text ) -{ - m_fullText = text; - elideText( size() ); - // elideText will call QPushButton::setText() -} - -void ElidingButton::elideText( const QSize &widgetSize ) -{ - const int width = widgetSize.width(); - const int iconWidth = icon().isNull() ? 0 : iconSize().width(); - - int left, top, right, bottom; - getContentsMargins( &left, &top, &right, &bottom ); - int padding = left + right + 4; - int textWidth = width - ( iconWidth + padding ); - - QFontMetrics fm( font() ); - QString elidedText = fm.elidedText( m_fullText, Qt::ElideRight, textWidth ); - QPushButton::setText( elidedText ); - - bool elided = ( elidedText != m_fullText ); - - // If there is no tooltip set, then we set it to be the full text when elided, - // and clear it if the button is no longer elided. - const QString tip = toolTip(); - if( elided && tip.isEmpty() ) - setToolTip( m_fullText ); - else if( !elided && tip == m_fullText ) - setToolTip( QString() ); - - if( elided ) - setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); - else - setSizePolicy( QSizePolicy::Maximum, QSizePolicy::Fixed ); - - if( m_isElided != elided ) - { - m_isElided = elided; - emit( sizePolicyChanged() ); - } -} - -} - -#include "moc_ElidingButton.cpp" diff --git a/amarok/src/widgets/ElidingButton.h b/amarok/src/widgets/ElidingButton.h deleted file mode 100644 index ffde7570..00000000 --- a/amarok/src/widgets/ElidingButton.h +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * Copyright (c) 2009 Seb Ruiz * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef ELIDINGBUTTON_H -#define ELIDINGBUTTON_H - -#include -#include -#include -#include - -namespace Amarok -{ - /** - * This is a reimplementaiton of a QPushButton that elides text if stretched below - * its optimal width. The icon (if any) will always remain visible. - */ - class ElidingButton : public QPushButton - { - Q_OBJECT - - public: - ElidingButton( QWidget *parent ); - ElidingButton( const QString & text, QWidget *parent ); - ElidingButton( const QIcon & icon, const QString & text, QWidget *parent ); - ~ElidingButton(); - - bool isElided() const; - QSizePolicy sizePolicy() const; - - virtual void setText( const QString &text ); - virtual void resizeEvent( QResizeEvent *event ); - - signals: - void sizePolicyChanged(); - - private: - void init(); - void elideText( const QSize &widgetSize ); - - QString m_fullText; - bool m_isElided; - }; -} - -#endif diff --git a/amarok/src/widgets/FilenameLayoutWidget.cpp b/amarok/src/widgets/FilenameLayoutWidget.cpp deleted file mode 100644 index 8d189cf6..00000000 --- a/amarok/src/widgets/FilenameLayoutWidget.cpp +++ /dev/null @@ -1,457 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Téo Mrnjavac * - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * Copyright (c) 2009 Daniel Dewald * - * Copyright (c) 2012 Ralf Engels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "FilenameLayoutWidget.h" -#include "TokenDropTarget.h" -#include "TokenPool.h" - -#include "amarokconfig.h" - -#include "MetaValues.h" -#include "core/support/Amarok.h" -#include "core/support/Debug.h" -#include "core/meta/support/MetaConstants.h" - -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -// the order of these strings depends on the order of the -// Type enum. -static const QStringList typeElements = ( QStringList() -<< QString() -<< QLatin1String("%ignore%") -<< QLatin1String("%track%") -<< QLatin1String("%title%") -<< QLatin1String("%artist%") -<< QLatin1String("%composer%") -<< QLatin1String("%year%") -<< QLatin1String("%album%") -<< QLatin1String("%albumartist%") -<< QLatin1String("%comment%") -<< QLatin1String("%genre%") -<< QLatin1String("%filetype%") -<< QLatin1String("%folder%") -<< QLatin1String("%initial%") -<< QLatin1String("%discnumber%") -<< QLatin1String(" ") -<< QLatin1String("/") -<< QLatin1String(".") -<< QLatin1String("-") -<< QLatin1String("_") -<< QLatin1String("%collectionroot%") ); - -using namespace Meta; - -// ------------------------- FilenameLayoutWidget ------------------- - -FilenameLayoutWidget::FilenameLayoutWidget( QWidget *parent ) - : QWidget( parent ) - , m_advancedMode( false ) -{ - m_mainLayout = new QVBoxLayout( this ); - m_mainLayout->setContentsMargins( 0, 0, 0, 0 ); - - QGroupBox* schemeGroup = new QGroupBox( i18n("Scheme"), this ); - QVBoxLayout* schemeGroupLayout = new QVBoxLayout( schemeGroup ); - - // --- presets - QHBoxLayout* presetLayout1 = new QHBoxLayout(); - - QLabel* presetLabel = new QLabel( i18n("Preset:"), this ); - presetLayout1->addWidget( presetLabel, 0 ); - - m_presetCombo = new QComboBox( this ); - m_presetCombo->setWhatsThis( i18n("A list of selectable filename scheme/format presets." ) ); - presetLayout1->addWidget( m_presetCombo, 1 ); - - // - the preset buttons - m_addPresetButton = new QPushButton( i18n("Add preset"), this ); - m_addPresetButton->setToolTip( i18n("Saves the current scheme/format above as a preset.") ); - presetLayout1->addWidget( m_addPresetButton, 0 ); - - m_updatePresetButton = new QPushButton( i18n("Update preset"), this ); - presetLayout1->addWidget( m_updatePresetButton, 0 ); - - m_removePresetButton = new QPushButton( i18n("Remove preset"), this ); - m_removePresetButton->setToolTip( i18n("Removes the currently selected format preset") ); - presetLayout1->addWidget( m_removePresetButton, 0 ); - - schemeGroupLayout->addLayout( presetLayout1 ); - - // --- stacked widget - m_schemeStack = new QStackedWidget( this ); - - // -- simple schema - QWidget* simpleLayoutWidget = new QWidget( this ); - QVBoxLayout *simpleLayout = new QVBoxLayout( simpleLayoutWidget ); - - // a token pool - m_tokenPool = new TokenPool( this ); - simpleLayout->addWidget( m_tokenPool, 1 ); - - // token drop target inside a frame - QFrame* dropTargetFrame = new QFrame( this ); - dropTargetFrame->setFrameShape(QFrame::StyledPanel); - dropTargetFrame->setFrameShadow(QFrame::Sunken); - m_dropTarget = new TokenDropTarget( this ); - m_dropTarget->setRowLimit( 1 ); - - m_schemaLineLayout = new QHBoxLayout(); - m_schemaLineLayout->setSpacing( 0 ); - m_schemaLineLayout->setContentsMargins( 0, 0, 0, 0 ); - m_schemaLineLayout->addWidget( m_dropTarget ); - dropTargetFrame->setLayout( m_schemaLineLayout ); - simpleLayout->addWidget( dropTargetFrame, 0 ); - - m_schemeStack->addWidget( simpleLayoutWidget ); - - // -- advanced schema - QWidget* advancedLayoutWidget = new QWidget( this ); - QVBoxLayout *advancedLayout = new QVBoxLayout( advancedLayoutWidget ); - - m_syntaxLabel = new QLabel( this ); // placeholder for format description - advancedLayout->addWidget( m_syntaxLabel ); - - m_filenameLayoutEdit = new KLineEdit( this ); - advancedLayout->addWidget( m_filenameLayoutEdit ); - - m_schemeStack->addWidget( advancedLayoutWidget ); - - schemeGroupLayout->addWidget( m_schemeStack ); - - m_advancedButton = new QPushButton( i18n("Advanced"), this ); - schemeGroupLayout->addWidget( m_advancedButton ); - - // -- - - m_mainLayout->addWidget( schemeGroup ); - - connect( m_tokenPool, SIGNAL(onDoubleClick(Token*)), - m_dropTarget, SLOT(insertToken(Token*)) ); - connect( m_advancedButton, SIGNAL(clicked()), - this, SLOT(toggleAdvancedMode()) ); - connect( m_dropTarget, SIGNAL(changed()), - this, SIGNAL(schemeChanged()) ); - connect( m_dropTarget, SIGNAL(changed()), - this, SLOT(slotUpdatePresetButton()) ); - connect( m_addPresetButton, SIGNAL(clicked(bool)), - this, SLOT(slotAddFormat()) ); - connect( m_removePresetButton, SIGNAL(clicked(bool)), - this, SLOT(slotRemoveFormat()) ); - connect( m_updatePresetButton, SIGNAL(clicked(bool)), - this, SLOT(slotUpdateFormat()) ); - - connect( m_filenameLayoutEdit, SIGNAL(textChanged(QString)), - this, SIGNAL(schemeChanged()) ); -debug() << "st3.1"; -} - -Token* -FilenameLayoutWidget::createToken(qint64 value) const -{ - struct TokenDefinition - { - QString name; - QString iconName; - Type value; - }; - - static const TokenDefinition tokenDefinitions[] = { - { i18nForField( valTrackNr ), iconForField( valTrackNr ), TrackNumber }, - { i18nForField( valDiscNr ), iconForField( valDiscNr ), DiscNumber }, - { i18nForField( valTitle ), iconForField( valTitle ), Title }, - { i18nForField( valArtist ), iconForField( valArtist ), Artist }, - { i18nForField( valComposer ), iconForField( valComposer ), Composer }, - { i18nForField( valYear ), iconForField( valYear ), Year }, - { i18nForField( valAlbum ), iconForField( valAlbum ), Album }, - { i18nForField( valAlbumArtist ), iconForField( valAlbumArtist ), AlbumArtist }, - { i18nForField( valComment ), iconForField( valComment ), Comment }, - { i18nForField( valGenre ), iconForField( valGenre ), Genre }, - { i18nForField( valFormat ), iconForField( valFormat ), FileType }, - - { i18n( "Ignore" ), "filename-ignore-amarok", Ignore }, - { i18n( "Folder" ), "filename-folder-amarok", Folder }, - { i18nc( "Artist's Initial", "Initial" ), "filename-initial-amarok", Initial }, - - { "/", "filename-slash-amarok", Slash }, - { "_", "filename-underscore-amarok", Underscore }, - { "-", "filename-dash-amarok", Dash }, - { ".", "filename-dot-amarok", Dot }, - { " ", "filename-space-amarok", Space }, - { i18n( "Collection root" ), "drive-harddisk", CollectionRoot }, - { QString(), 0, Space } - }; - - for( int i = 0; !tokenDefinitions[i].name.isNull(); ++i ) - { - if( value == tokenDefinitions[i].value ) - { - return new Token( tokenDefinitions[i].name, - tokenDefinitions[i].iconName, - static_cast(tokenDefinitions[i].value) ); - } - } - - return 0; -} - -Token* -FilenameLayoutWidget::createStaticToken(qint64 value) const -{ - Token* token = createToken( value ); - token->setEnabled( false ); - token->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Preferred ); - - return token; -} - -//Stores the configuration when the dialog is accepted. -void -FilenameLayoutWidget::onAccept() //SLOT -{ - slotSaveFormatList(); -} - -QString -FilenameLayoutWidget::getParsableScheme() const -{ - QString scheme = m_advancedMode ? m_filenameLayoutEdit->text() : dropTargetScheme(); - - Amarok::config( m_configCategory ).writeEntry( "Custom Scheme", scheme ); - return scheme; -} - -// attempts to set the scheme -void FilenameLayoutWidget::setScheme(const QString& scheme) -{ - m_filenameLayoutEdit->setText( scheme ); - inferScheme( scheme ); - - slotUpdatePresetButton(); - emit schemeChanged(); -} - - - -//Handles the modifications to the dialog to toggle between advanced and basic editing mode. -void -FilenameLayoutWidget::toggleAdvancedMode() -{ - setAdvancedMode( !m_advancedMode ); -} - -//handles switching between basic and advanced mode -void -FilenameLayoutWidget::setAdvancedMode( bool isAdvanced ) -{ - setScheme( getParsableScheme() ); // setScheme set's both the edit and the drop target - m_advancedMode = isAdvanced; - - if( isAdvanced ) - { - m_advancedButton->setText( i18n( "&Basic..." ) ); - m_schemeStack->setCurrentIndex( 1 ); - } - else // set Basic mode - { - m_advancedButton->setText( i18n( "&Advanced..." ) ); - m_schemeStack->setCurrentIndex( 0 ); - } - - QString entryValue = m_advancedMode ? "Advanced" : "Basic"; - - Amarok::config( m_configCategory ).writeEntry( "Mode", entryValue ); -} - - -QString -FilenameLayoutWidget::dropTargetScheme() const -{ - QString parsableScheme = ""; - - QList< Token *> list = m_dropTarget->tokensAtRow(); - - foreach( Token *token, list ) - { - parsableScheme += typeElements[token->value()]; - } - - return parsableScheme; -} - -void -FilenameLayoutWidget::inferScheme( const QString &s ) //SLOT -{ - DEBUG_BLOCK - - debug() << "infering scheme: " << s; - - m_dropTarget->clear(); - for( int i = 0; i < s.size(); ) - { - // - search if there is a type with the matching string - // representation. - bool found = false; - for( int j = 1; j < typeElements.size() && !found; j++ ) - { - int typeNameLength = typeElements[j].length(); - Type type = static_cast(j); - if( s.midRef( i, typeNameLength ) == typeElements[j] ) - { - m_dropTarget->insertToken( createToken( type ) ); - i += typeNameLength; - found = true; - } - } - - if( !found ) - { - debug() << "'" << s.at(i) << "' can't be represented as TokenLayoutWidget Token"; - ++i; // skip junk - } - } -} - -void -FilenameLayoutWidget::populateConfiguration() -{ - QString mode = Amarok::config( m_configCategory ).readEntry( "Mode" ); - setAdvancedMode( mode == QLatin1String( "Advanced" ) ); - - setScheme( Amarok::config( m_configCategory ).readEntryUntranslated( "Custom Scheme" ) ); - - populateFormatList(); -} - - -void -FilenameLayoutWidget::populateFormatList() -{ - DEBUG_BLOCK - - // items are stored in the config list in the following format: - // Label#DELIM#format string#DELIM#selected - // the last item to have the third parameter is the default selected preset - // the third param isnis optional - QStringList presets_raw; - int selected_index = -1; - m_presetCombo->clear(); - presets_raw = AmarokConfig::formatPresets(); - // presets_raw = Amarok::config( m_configCategory ).readEntry( QString::fromLatin1( "Format Presets" ), QStringList() ); - - debug() << "--- got preset for" << m_configCategory << presets_raw; - - foreach( const QString &str, presets_raw ) - { - QStringList items; - items = str.split( "#DELIM#", QString::SkipEmptyParts ); - if( items.size() < 2 ) - continue; - m_presetCombo->addItem( items.at( 0 ), items.at( 1 ) ); // Label, format string - if( items.size() == 3 ) - selected_index = m_presetCombo->findData( items.at( 1 ) ); - } - - if( selected_index > 0 ) - m_presetCombo->setCurrentIndex( selected_index ); - - slotFormatPresetSelected( selected_index ); - connect( m_presetCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(slotFormatPresetSelected(int)) ); -} - -void -FilenameLayoutWidget::slotUpdatePresetButton() -{ - QString comboScheme = m_presetCombo->itemData( m_presetCombo->currentIndex() ). toString(); - m_updatePresetButton->setEnabled( comboScheme != getParsableScheme() ); -} - -void -FilenameLayoutWidget::slotSaveFormatList() -{ - if( !m_formatListModified ) - return; - - QStringList presets; - int n = m_presetCombo->count(); - int current_idx = m_presetCombo->currentIndex(); - - for( int i = 0; i < n; ++i ) - { - QString item; - if( i == current_idx ) - item = "%1#DELIM#%2#DELIM#selected"; - else - item = "%1#DELIM#%2"; - - QString scheme = m_presetCombo->itemData( i ).toString(); - QString label = m_presetCombo->itemText( i ); - item = item.arg( label, scheme ); - presets.append( item ); - } - - Amarok::config( m_configCategory ).writeEntry( QString::fromLatin1( "Format Presets" ), presets ); -} - -void -FilenameLayoutWidget::slotFormatPresetSelected( int index ) -{ - QString scheme = m_presetCombo->itemData( index ).toString(); - setScheme( scheme ); -} - -void -FilenameLayoutWidget::slotAddFormat() -{ - bool ok = false; - QString name = KInputDialog::getText( i18n( "New Format Preset" ), i18n( "Preset Name" ), i18n( "New Preset" ), &ok, this ); - if( !ok ) - return; // user canceled. - - QString format = getParsableScheme(); - m_presetCombo->insertItem(0, name, format); - m_presetCombo->setCurrentIndex( 0 ); - m_formatListModified = true; -} - -void -FilenameLayoutWidget::slotRemoveFormat() -{ - int idx = m_presetCombo->currentIndex(); - m_presetCombo->removeItem( idx ); - m_formatListModified = true; -} - -void -FilenameLayoutWidget::slotUpdateFormat() -{ - int idx = m_presetCombo->currentIndex(); - QString formatString = getParsableScheme(); - m_presetCombo->setItemData( idx, formatString ); - m_updatePresetButton->setEnabled( false ); - m_formatListModified = true; -} diff --git a/amarok/src/widgets/FilenameLayoutWidget.h b/amarok/src/widgets/FilenameLayoutWidget.h deleted file mode 100644 index 9fb2678f..00000000 --- a/amarok/src/widgets/FilenameLayoutWidget.h +++ /dev/null @@ -1,155 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Téo Mrnjavac * - * Copyright (c) 2009 Daniel Dewald * - * Copyright (c) 2012 Ralf Engels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef FILENAMELAYOUTDIALOG_H -#define FILENAMELAYOUTDIALOG_H - -#include "amarok_export.h" - -#include - -class Token; -class TokenPool; -class TokenDropTarget; - -class QFileInfo; -class QStackedWidget; -class QLabel; -class QFrame; -class QComboBox; -class QPushButton; -class QVBoxLayout; -class QHBoxLayout; - -class KLineEdit; - -//Holds the TokenLayoutWidget and TokenPool and handles their interaction. Also holds a number of case and substitution options for the filename scheme. -class AMAROK_EXPORT FilenameLayoutWidget : public QWidget -{ - Q_OBJECT - - public: - - enum Type - { - Unknown = 0 - , Ignore - , TrackNumber - , Title - , Artist - , Composer - , Year - , Album - , AlbumArtist - , Comment - , Genre - , FileType - , Folder - , Initial - , DiscNumber - , Space - , Slash - , Dot - , Dash - , Underscore - , CollectionRoot - }; - - - explicit FilenameLayoutWidget( QWidget *parent = 0 ); - virtual ~FilenameLayoutWidget() {} - - QString getParsableScheme() const; - - void setScheme( const QString &scheme ); - - - public slots: - virtual void onAccept(); - - signals: - /** emitted when either the scheme, option checkboxes or the replace edits change */ - void schemeChanged(); - - private slots: - void toggleAdvancedMode(); - - /* Updates the update preset button */ - void slotUpdatePresetButton(); - void slotSaveFormatList(); - void slotFormatPresetSelected( int ); - void slotAddFormat(); - void slotRemoveFormat(); - void slotUpdateFormat(); - - private: - /** Set the advanced mode, blending out several "advanced" widgets */ - void setAdvancedMode( bool isAdvanced ); - - /* Iterates over the elements of the TokenLayoutWidget bar - (really over the elements of a QList that stores the indexes - of the tokens) and generates a string that TagGuesser can digest. */ - QString dropTargetScheme() const; - - /** Fills the m_dropTarget according to the given string scheme. */ - void inferScheme( const QString &scheme ); - - bool m_formatListModified; - bool m_advancedMode; - - protected: - - /** Set's several configuration options. - Don't move this function to the constructor. It calls virtuals. */ - void populateConfiguration(); - - /** Populates the preset combo box */ - void populateFormatList(); - - virtual Token* createToken(qint64 value) const; - - /** Returns a styled token to be used in as pre and - postfix on the schema editing line. */ - virtual Token* createStaticToken(qint64 value) const; - - QVBoxLayout *m_mainLayout; - - QComboBox *m_presetCombo; - QPushButton *m_addPresetButton; - QPushButton *m_updatePresetButton; - QPushButton *m_removePresetButton; - - QPushButton *m_advancedButton; - - TokenPool *m_tokenPool; - QStackedWidget *m_schemeStack; - QHBoxLayout *m_schemaLineLayout; - TokenDropTarget *m_dropTarget; - - QLabel *m_syntaxLabel; - QFrame *m_filenameLayout; - KLineEdit *m_filenameLayoutEdit; - - - /** The name of the category used for storing the configuration */ - QString m_configCategory; -}; - - -#endif //FILENAMELAYOUTDIALOG_H - diff --git a/amarok/src/widgets/FlowLayout.cpp b/amarok/src/widgets/FlowLayout.cpp deleted file mode 100644 index 108486b3..00000000 --- a/amarok/src/widgets/FlowLayout.cpp +++ /dev/null @@ -1,128 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2004-2008 Trolltech ASA * - * * - * This program 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 2 of the License, or (at your option) version 3 or any * - * later version publicly approved by Trolltech ASA (or its successor, if any) and the * - * KDE Free Qt Foundation. * - * * - * This program 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 * - * this program. If not, see . * - * * - * In addition, Trolltech gives you certain additional rights as described in the * - * Trolltech GPL Exception version 1.2 which can be found at * - * http://www.trolltech.com/products/qt/gplexception/ * - ****************************************************************************************/ - -#include "FlowLayout.h" - - FlowLayout::FlowLayout(QWidget *parent, int margin, int spacing) - : QLayout(parent) -{ - setMargin(margin); - setSpacing(spacing); -} - - FlowLayout::FlowLayout(int spacing) -{ - setSpacing(spacing); -} - - FlowLayout::~FlowLayout() -{ - QLayoutItem *item; - while ((item = takeAt(0))) - delete item; -} - - void FlowLayout::addItem(QLayoutItem *item) -{ - itemList.append(item); -} - - int FlowLayout::count() const -{ - return itemList.size(); -} - - QLayoutItem *FlowLayout::itemAt(int index) const -{ - return itemList.value(index); -} - - QLayoutItem *FlowLayout::takeAt(int index) -{ - if (index >= 0 && index < itemList.size()) - return itemList.takeAt(index); - else - return 0; -} - - Qt::Orientations FlowLayout::expandingDirections() const -{ - return 0; -} - - bool FlowLayout::hasHeightForWidth() const -{ - return true; -} - - int FlowLayout::heightForWidth(int width) const -{ - int height = doLayout(QRect(0, 0, width, 0), true); - return height; -} - - void FlowLayout::setGeometry(const QRect &rect) -{ - QLayout::setGeometry(rect); - doLayout(rect, false); -} - - QSize FlowLayout::sizeHint() const -{ - return minimumSize(); -} - - QSize FlowLayout::minimumSize() const -{ - QSize size; - QLayoutItem *item; - foreach (item, itemList) - size = size.expandedTo(item->minimumSize()); - - size += QSize(2*margin(), 2*margin()); - return size; -} - - int FlowLayout::doLayout(const QRect &rect, bool testOnly) const -{ - int x = rect.x(); - int y = rect.y(); - int lineHeight = 0; - - QLayoutItem *item; - foreach (item, itemList) { - int nextX = x + item->sizeHint().width() + spacing(); - if (nextX - spacing() > rect.right() && lineHeight > 0) { - x = rect.x(); - y = y + lineHeight + spacing(); - nextX = x + item->sizeHint().width() + spacing(); - lineHeight = 0; - } - - if (!testOnly) - item->setGeometry(QRect(QPoint(x, y), item->sizeHint())); - - x = nextX; - lineHeight = qMax(lineHeight, item->sizeHint().height()); - } - return y + lineHeight - rect.y(); -} - diff --git a/amarok/src/widgets/FlowLayout.h b/amarok/src/widgets/FlowLayout.h deleted file mode 100644 index 2fda8347..00000000 --- a/amarok/src/widgets/FlowLayout.h +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2004-2008 Trolltech ASA * - * * - * This program 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 2 of the License, or (at your option) version 3 or any * - * later version publicly approved by Trolltech ASA (or its successor, if any) and the * - * KDE Free Qt Foundation. * - * * - * This program 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 * - * this program. If not, see . * - * * - * In addition, Trolltech gives you certain additional rights as described in the * - * Trolltech GPL Exception version 1.2 which can be found at * - * http://www.trolltech.com/products/qt/gplexception/ * - ****************************************************************************************/ - -#ifndef FLOWLAYOUT_H -#define FLOWLAYOUT_H - - -#include "amarok_export.h" - -#include -#include -#include - - - - class AMAROK_EXPORT FlowLayout : public QLayout -{ - public: - explicit FlowLayout(QWidget *parent, int margin = 0, int spacing = -1); - FlowLayout(int spacing = -1); - ~FlowLayout(); - - void addItem(QLayoutItem *item); - Qt::Orientations expandingDirections() const; - bool hasHeightForWidth() const; - int heightForWidth(int) const; - int count() const; - QLayoutItem *itemAt(int index) const; - QSize minimumSize() const; - void setGeometry(const QRect &rect); - QSize sizeHint() const; - QLayoutItem *takeAt(int index); - - private: - int doLayout(const QRect &rect, bool testOnly) const; - - QList itemList; -}; - -#endif diff --git a/amarok/src/widgets/HintLineEdit.cpp b/amarok/src/widgets/HintLineEdit.cpp deleted file mode 100644 index 1fe623a3..00000000 --- a/amarok/src/widgets/HintLineEdit.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2006 Martin Aumueller * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "HintLineEdit.h" - -#include - -#include -#include - -HintLineEdit::HintLineEdit( const QString &hint, const QString &text, QWidget *parent ) - : KLineEdit( text, 0 ) - , m_vbox( new KVBox( parent ) ) -{ - init(); - m_hint->setText( hint ); -} - -HintLineEdit::HintLineEdit( const QString &text, QWidget *parent ) - : KLineEdit( text, 0 ) - , m_vbox( new KVBox( parent ) ) -{ - init(); -} - -HintLineEdit::HintLineEdit( QWidget *parent ) - : KLineEdit( 0 ) - , m_vbox( new KVBox( parent ) ) -{ - init(); -} - -void -HintLineEdit::init() -{ - setParent( m_vbox ); - show(); - m_hint = new QLabel( m_vbox ); - //m_hint->setBuddy( this ); - m_hint->setFocusPolicy( Qt::NoFocus ); - QFont font; - font.setPointSize( font.pointSize() - 2); - m_hint->setFont( font ); -} - -HintLineEdit::~HintLineEdit() -{ - setParent( 0 ); - delete m_vbox; -} - -void -HintLineEdit::setHint( const QString &hint ) -{ - m_hint->setText( hint ); -} - -QObject * -HintLineEdit::parent() -{ - return m_vbox->parent(); -} - -#include "moc_HintLineEdit.cpp" diff --git a/amarok/src/widgets/HintLineEdit.h b/amarok/src/widgets/HintLineEdit.h deleted file mode 100644 index e7b8aad7..00000000 --- a/amarok/src/widgets/HintLineEdit.h +++ /dev/null @@ -1,46 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2006 Martin Aumueller * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef HINTLINEEDIT_H -#define HINTLINEEDIT_H - -#include //baseclass - -class KVBox; -class QLabel; -class QWidget; - -class HintLineEdit : public KLineEdit -{ - Q_OBJECT - -public: - explicit HintLineEdit( const QString &hint, const QString &text, QWidget *parent = 0 ); - explicit HintLineEdit( const QString &text, QWidget *parent = 0 ); - HintLineEdit( QWidget *parent = 0 ); - - virtual ~HintLineEdit(); - virtual QObject *parent(); - virtual void setHint( const QString &hint ); - -private: - void init(); - - KVBox *m_vbox; - QLabel *m_hint; -}; - -#endif diff --git a/amarok/src/widgets/HorizontalDivider.cpp b/amarok/src/widgets/HorizontalDivider.cpp deleted file mode 100644 index c93376e3..00000000 --- a/amarok/src/widgets/HorizontalDivider.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "HorizontalDivider.h" -#include "SvgHandler.h" - -#include - -HorizontalDivider::HorizontalDivider( QWidget * parent ) - : QWidget( parent ) -{ - setFixedHeight( 2 ); -} - - -HorizontalDivider::~HorizontalDivider() -{ -} - -void HorizontalDivider::paintEvent( QPaintEvent * event ) -{ - Q_UNUSED( event ) - - QPainter p( this ); - - p.drawPixmap( 0, 0, The::svgHandler()->renderSvg( "divider_bottom", rect().width(), 1, "divider_bottom" ) ); - p.drawPixmap( 0, 1, The::svgHandler()->renderSvg( "divider_top", rect().width(), 1, "divider_top" ) ); -} - - diff --git a/amarok/src/widgets/HorizontalDivider.h b/amarok/src/widgets/HorizontalDivider.h deleted file mode 100644 index b37f8581..00000000 --- a/amarok/src/widgets/HorizontalDivider.h +++ /dev/null @@ -1,39 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef HORIZONTALDIVIDER_H -#define HORIZONTALDIVIDER_H - -#include - -/** -A simple divider widget that draws the svg divider elements. - - @author Nikolaj Hald Nielsen -*/ -class HorizontalDivider : public QWidget -{ -public: - HorizontalDivider( QWidget * parent ); - - ~HorizontalDivider(); - -protected: - virtual void paintEvent ( QPaintEvent* event ); - -}; - -#endif diff --git a/amarok/src/widgets/IconButton.cpp b/amarok/src/widgets/IconButton.cpp deleted file mode 100644 index 00dd7b24..00000000 --- a/amarok/src/widgets/IconButton.cpp +++ /dev/null @@ -1,163 +0,0 @@ -/**************************************************************************************** -* Copyright (c) 2009 Thomas Luebking * -* * -* This program 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 2 of the License, or (at your option) any later * -* version. * -* * -* This program 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 * -* this program. If not, see . * -****************************************************************************************/ - -#include "IconButton.h" -#include "SvgHandler.h" - -#include -#include -#include -#include -#include - -IconButton::IconButton( QWidget *parent ) : QWidget( parent ) - , m_isClick( false ) -{ - m_anim.step = 0; - m_anim.timer = 0; - setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ); - - // cannot use paletteChanged() from the palette handler directly since the - // svg handler also watches it for retinting. So upon palette change, we are - // called first and the old svg icons will be used. - connect( The::svgHandler(), SIGNAL(retinted()), SLOT(svgRetinted()) ); -} - -void IconButton::setIcon( const QImage &img, int steps ) -{ - m_anim.step = 0; - m_anim.steps = steps; - - m_icon = img; - m_oldIcon = steps ? m_buffer.image : QImage(); - - if ( m_anim.timer ) - killTimer( m_anim.timer ); - if ( steps ) - m_anim.timer = startTimer( 40 ); - else - updateIconBuffer(); - repaint(); -} - - -void IconButton::mousePressEvent( QMouseEvent *me ) -{ - me->accept(); - m_isClick = true; -} - -void IconButton::mouseReleaseEvent( QMouseEvent *me ) -{ - me->accept(); - if ( m_isClick && rect().contains( me->pos() ) ) - { - m_isClick = false; - emit clicked(); - } -} - -void IconButton::paintEvent( QPaintEvent * ) -{ - QPainter p(this); - p.drawPixmap( 0,0, m_buffer.pixmap ); - p.end(); -} - -void IconButton::svgRetinted() -{ - reloadContent( size() ); -} - -void IconButton::resizeEvent( QResizeEvent *re ) -{ - if( width() != height() ) - resize( height(), height() ); - else - { - reloadContent( re->size() ); - QWidget::resizeEvent( re ); - } -} - -QSize IconButton::sizeHint() const -{ - if ( QToolBar *toolBar = qobject_cast( parentWidget() ) ) - return toolBar->iconSize(); - - return QSize( 32, 32 ); -} - -void IconButton::timerEvent( QTimerEvent *te ) -{ - if ( te->timerId() != m_anim.timer ) - return; - - ++m_anim.step; - updateIconBuffer(); - if ( m_anim.step >= m_anim.steps ) - { - killTimer( m_anim.timer ); - m_anim.timer = 0; - m_oldIcon = QImage(); - } - repaint(); -} - -static QImage adjusted( QImage img, const QSize &sz ) -{ - if ( img.size() == sz ) - return img; - QImage ret( sz, QImage::Format_ARGB32_Premultiplied ); - ret.fill( Qt::transparent ); - QPainter p( &ret ); - p.drawImage( (ret.width() - img.width()) /2, (ret.height() - img.height()) /2, img ); - p.end(); - return ret; -} - -static inline QImage interpolated( const QImage &img1, const QImage &img2, int a1, int a2 ) -{ - const int a = a1 + a2; - if (!a) - return img1.copy(); - - QImage img( img1.size(), img1.format() ); - - const uchar *src[2] = { img1.bits(), img2.bits() }; - uchar *dst = img.bits(); - const int n = img.width()*img.height()*4; - for ( int i = 0; i < n; ++i ) - { - *dst = ((*src[0]*a1 + *src[1]*a2)/a) & 0xff; - ++dst; ++src[0]; ++src[1]; - } - return img; -} - -void IconButton::updateIconBuffer() -{ - if ( m_anim.step >= m_anim.steps ) - m_buffer.image = adjusted( m_icon, size() ); - else - m_buffer.image = interpolated( adjusted( m_oldIcon, size() ), adjusted( m_icon, size() ), - m_anim.steps - m_anim.step, m_anim.step ); - - m_buffer.pixmap = QPixmap::fromImage( m_buffer.image ); -} - - -#include "moc_IconButton.cpp" diff --git a/amarok/src/widgets/IconButton.h b/amarok/src/widgets/IconButton.h deleted file mode 100644 index a8d6e145..00000000 --- a/amarok/src/widgets/IconButton.h +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************************** -* Copyright (c) 2009 Thomas Luebking * -* * -* This program 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 2 of the License, or (at your option) any later * -* version. * -* * -* This program 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 * -* this program. If not, see . * -****************************************************************************************/ - -#ifndef ICONBUTTON_H -#define ICONBUTTON_H - -#include -#include -#include - -class IconButton : public QWidget -{ - Q_OBJECT - -public: - IconButton( QWidget *parent = 0 ); - virtual QSize sizeHint() const; - void setIcon( const QImage &img, int steps = 0 ); - -signals: - void clicked(); - -protected: - virtual void mousePressEvent( QMouseEvent * ); - virtual void mouseReleaseEvent( QMouseEvent * ); - virtual void paintEvent( QPaintEvent * ); - virtual void resizeEvent(QResizeEvent *); - virtual void timerEvent ( QTimerEvent * ); - - /** - Reload the content for the given size - The iconbutton preserves a square size, so sz.width() == sz.height() - */ - virtual void reloadContent( const QSize &sz ) = 0; - -protected slots: - void svgRetinted(); - -private: - void updateIconBuffer(); - - bool m_isClick; - struct - { - int step; - int steps; - int timer; - } m_anim; - - struct - { - QImage image; - QPixmap pixmap; - } m_buffer; - - QImage m_icon, m_oldIcon; -}; - - -#endif // end include guard diff --git a/amarok/src/widgets/LineEdit.cpp b/amarok/src/widgets/LineEdit.cpp deleted file mode 100644 index a616c656..00000000 --- a/amarok/src/widgets/LineEdit.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Seb Ruiz * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "LineEdit.h" - -#include - -namespace Amarok -{ - -LineEdit::LineEdit( QWidget *parent ) - : KLineEdit( parent ) -{ -} - -void LineEdit::keyPressEvent( QKeyEvent *event ) -{ - if( event->key() == Qt::Key_Escape ) - { - event->accept(); - clear(); - return; - } - else if( event->key() == Qt::Key_Down ) - { - event->accept(); - emit downPressed(); - return; - } - else if ( event->key() == Qt::Key_Up ) - { - event->accept(); - emit upPressed(); - return; - } - KLineEdit::keyPressEvent( event ); -} - -} - -#include "moc_LineEdit.cpp" diff --git a/amarok/src/widgets/LineEdit.h b/amarok/src/widgets/LineEdit.h deleted file mode 100644 index 12be184d..00000000 --- a/amarok/src/widgets/LineEdit.h +++ /dev/null @@ -1,49 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Seb Ruiz * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_LINE_EDIT_H -#define AMAROK_LINE_EDIT_H - -#include //baseclass - -class QKeyEvent; - -namespace Amarok -{ - /** - * The Amarok::LineEdit class implements a few enhancements to KLineEdit - * Namely: - * 1. Pressing the escape key clears the contents - * 2. Pressing down emits the downPressed signal - * 3. Pressing up emits the upPressed signal - */ - class LineEdit : public KLineEdit - { - Q_OBJECT - - public: - LineEdit( QWidget *parent = 0 ); - virtual ~LineEdit() {}; - - void keyPressEvent( QKeyEvent *event ); - - signals: - void downPressed(); - void upPressed(); - }; -} - -#endif diff --git a/amarok/src/widgets/MetaQueryWidget.cpp b/amarok/src/widgets/MetaQueryWidget.cpp deleted file mode 100644 index 59cee29a..00000000 --- a/amarok/src/widgets/MetaQueryWidget.cpp +++ /dev/null @@ -1,1211 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Daniel Caleb Jones * - * Copyright (c) 2009 Mark Kretschmann * - * Copyright (c) 2010 Ralf Engels * - * * - * This program 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 2 of the License, or (at your option) version 3 or * - * any later version accepted by the membership of KDE e.V. (or its successor approved * - * by the membership of KDE e.V.), which shall act as a proxy defined in Section 14 of * - * version 3 of the license. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "core-impl/collections/support/CollectionManager.h" -#include "core/collections/MetaQueryMaker.h" -#include "core/collections/QueryMaker.h" -#include "widgets/MetaQueryWidget.h" -#include "widgets/kdatecombo.h" -#include "FileType.h" - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -using namespace Amarok; - -static const int maxHours = 24; - -TimeDistanceWidget::TimeDistanceWidget( QWidget *parent ) - : QWidget( parent ) -{ - m_timeEdit = new KIntSpinBox(this); - m_timeEdit->setMinimum( 0 ); - m_timeEdit->setMaximum( 600 ); - - m_unitSelection = new KComboBox(this); - connect( m_timeEdit, SIGNAL(valueChanged(int)), this, SLOT(slotUpdateComboBoxLabels(int)) ); - for (int i = 0; i < 7; ++i) { - m_unitSelection->addItem( QString() ); - } - slotUpdateComboBoxLabels( 0 ); - - QHBoxLayout *hLayout = new QHBoxLayout(this); - hLayout->setContentsMargins(0, 0, 0, 0); - hLayout->addWidget( m_timeEdit ); - hLayout->addWidget( m_unitSelection ); -} - -qint64 TimeDistanceWidget::timeDistance() const -{ - qint64 time = m_timeEdit->value(); - switch( m_unitSelection->currentIndex() ) - { - case 6: - time *= 365*24*60*60; // years - break; - case 5: - time *= 30*24*60*60; // months - break; - case 4: - time *= 7*24*60*60; // weeks - break; - case 3: - time *= 24; // days - case 2: - time *= 60; // hours - case 1: - time *= 60; // minutes - } - - return time; -} - -void TimeDistanceWidget::setTimeDistance( qint64 value ) -{ - // as we don't store the time unit we try to reconstuct it - int unit = 0; - if( value > 600 || !(value % 60) ) { - unit = 1; - value /= 60; - - if( value > 600 || !(value % 60) ) { - unit = 2; - value /= 60; - - if( value > 72 || !(value % 24) ) { - unit = 3; - value /= 24; - - if( !(value % 365) ) { - unit = 6; - value /= 365; - } else if( !(value % 30) ) { - unit = 5; - value /= 30; - } else if( !(value % 7) ) { - unit = 4; - value /= 7; - } - } - } - } - - m_unitSelection->setCurrentIndex( unit ); - m_timeEdit->setValue( value ); -} - -void TimeDistanceWidget::connectChanged( QObject *receiver, const char *slot ) -{ - connect( m_timeEdit, SIGNAL(valueChanged(QString)), receiver, slot ); - connect( m_unitSelection, SIGNAL(currentIndexChanged(int)), receiver, slot ); -} - - -void TimeDistanceWidget::slotUpdateComboBoxLabels( int value ) -{ - m_unitSelection->setItemText(0, i18np("second", "seconds", value)); - m_unitSelection->setItemText(1, i18np("minute", "minutes", value)); - m_unitSelection->setItemText(2, i18np("hour", "hours", value)); - m_unitSelection->setItemText(3, i18np("day", "days", value)); - m_unitSelection->setItemText(4, i18np("week", "weeks", value)); - m_unitSelection->setItemText(5, i18np("month", "months", value)); - m_unitSelection->setItemText(6, i18np("year", "years", value)); -} - -void -MetaQueryWidget::Filter::setField( qint64 newField ) -{ - if( m_field == newField ) - return; - - // -- reset the value and the condition if the new filter has another type - if( MetaQueryWidget::isNumeric( m_field ) != MetaQueryWidget::isNumeric( newField ) ) - { - value.clear(); - if( MetaQueryWidget::isNumeric( newField ) ) - condition = Equals; - else - condition = Contains; - } - if( !MetaQueryWidget::isDate( m_field ) && MetaQueryWidget::isDate( newField ) ) - { - numValue = QDateTime::currentDateTime().toTime_t(); - numValue2 = QDateTime::currentDateTime().toTime_t(); - } - else - { - numValue = 0; - numValue2 = 0; - } - - if (numValue < minimumValue( newField ) || numValue > maximumValue( newField ) ) - numValue = defaultValue( newField ); - - if (numValue2 < minimumValue( newField ) || numValue2 > maximumValue( newField ) ) - numValue2 = defaultValue( newField ); - - m_field = newField; -} - -qint64 -MetaQueryWidget::Filter::minimumValue( quint64 field ) -{ - switch( field ) - { - case Meta::valYear: return 1900; - case Meta::valTrackNr: return 0; - case Meta::valDiscNr: return 0; - case Meta::valBpm: return 60; - case Meta::valBitrate: return 60; - case Meta::valSamplerate: return 8000; - case Meta::valFilesize: return 0; - case Meta::valScore: return 0; - case Meta::valPlaycount: return 0; - case Meta::valRating: return 0; - case Meta::valLength: return 0; - default: return 0; - } -} - -qint64 -MetaQueryWidget::Filter::maximumValue( quint64 field ) -{ - switch( field ) - { - case Meta::valYear: return 2300; - case Meta::valTrackNr: return 100; - case Meta::valDiscNr: return 10; - case Meta::valBpm: return 200; - case Meta::valBitrate: return 2000; - case Meta::valSamplerate: return 48000; - case Meta::valFilesize: return 1000; - case Meta::valScore: return 100; - case Meta::valPlaycount: return 1000; - case Meta::valRating: return 10; - case Meta::valLength: return maxHours * 60 * 60 - 1; - default: return 0; - } -} - -qint64 -MetaQueryWidget::Filter::defaultValue( quint64 field ) -{ - switch( field ) - { - case Meta::valYear: return 1976; - case Meta::valTrackNr: return 0; - case Meta::valDiscNr: return 0; - case Meta::valBpm: return 80; - case Meta::valBitrate: return 160; - case Meta::valSamplerate: return 44100; - case Meta::valFilesize: return 10; - case Meta::valScore: return 0; - case Meta::valPlaycount: return 00; - case Meta::valRating: return 0; - case Meta::valLength: return 3 * 60 + 59; - default: return 0; - } -} - -MetaQueryWidget::MetaQueryWidget( QWidget* parent, bool onlyNumeric, bool noCondition ) - : QWidget( parent ) - , m_onlyNumeric( onlyNumeric ) - , m_noCondition( noCondition ) - , m_settingFilter( false ) - , m_andLabel(0) - , m_compareSelection(0) - , m_valueSelection1(0) - , m_valueSelection2(0) -{ - // note: we are using the strange layout structure because the KRatingWidget size depends on the height. - m_layoutMain = new QVBoxLayout( this ); - m_layoutMain->setContentsMargins(0, 0, 0, 0); - - makeFieldSelection(); - m_layoutMain->addWidget( m_fieldSelection ); - - m_layoutValue = new QHBoxLayout(); - m_layoutMain->addLayout(m_layoutValue); - - m_layoutValueLabels = new QVBoxLayout(); - m_layoutValue->addLayout(m_layoutValueLabels, 0); - m_layoutValueValues = new QVBoxLayout(); - m_layoutValue->addLayout(m_layoutValueValues, 1); - - if( m_onlyNumeric ) - m_filter.setField( Meta::valYear ); - else - m_filter.setField( 0 ); - - setFilter(m_filter); -} - -MetaQueryWidget::~MetaQueryWidget() -{ -} - -MetaQueryWidget::Filter -MetaQueryWidget::filter() const -{ - // special handling for between - if( m_filter.condition == Contains ) - { - Filter f = m_filter; - f.numValue = qMin(m_filter.numValue, m_filter.numValue2) - 1; - f.numValue2 = qMax(m_filter.numValue, m_filter.numValue2) + 1; - } - return m_filter; -} - -void -MetaQueryWidget::setFilter( const MetaQueryWidget::Filter &value ) -{ - m_settingFilter = true; - m_filter = value; - - int index = m_fieldSelection->findData( int(m_filter.field()) ); - m_fieldSelection->setCurrentIndex( index == -1 ? 0 : index ); - - if( !m_noCondition ) - makeCompareSelection(); - makeValueSelection(); - setValueSelection(); - - m_settingFilter = false; - emit changed(m_filter); -} - -static void addIconItem( KComboBox *box, qint64 field ) -{ - QString icon = Meta::iconForField( field ); - QString text = Meta::i18nForField( field ); - if( icon.isEmpty() ) - box->addItem( text, field ); - else - box->addItem( KIcon( icon ), text, field ); -} - -void -MetaQueryWidget::makeFieldSelection() -{ - m_fieldSelection = new KComboBox( this ); - if (!m_onlyNumeric) - { - m_fieldSelection->addItem( i18n( "Simple Search" ), 0 ); - addIconItem( m_fieldSelection, Meta::valUrl ); - // note: what about directory? - addIconItem( m_fieldSelection, Meta::valTitle ); - addIconItem( m_fieldSelection, Meta::valArtist ); - addIconItem( m_fieldSelection, Meta::valAlbumArtist ); - addIconItem( m_fieldSelection, Meta::valAlbum ); - addIconItem( m_fieldSelection, Meta::valGenre ); - addIconItem( m_fieldSelection, Meta::valComposer ); - } - addIconItem( m_fieldSelection, Meta::valYear ); - if (!m_onlyNumeric) - addIconItem( m_fieldSelection, Meta::valComment ); - addIconItem( m_fieldSelection, Meta::valTrackNr ); - addIconItem( m_fieldSelection, Meta::valDiscNr ); - addIconItem( m_fieldSelection, Meta::valBpm ); - addIconItem( m_fieldSelection, Meta::valLength ); - addIconItem( m_fieldSelection, Meta::valBitrate ); - addIconItem( m_fieldSelection, Meta::valSamplerate ); - addIconItem( m_fieldSelection, Meta::valFilesize ); - if (!m_onlyNumeric) - addIconItem( m_fieldSelection, Meta::valFormat ); - addIconItem( m_fieldSelection, Meta::valCreateDate ); - addIconItem( m_fieldSelection, Meta::valScore ); - addIconItem( m_fieldSelection, Meta::valRating ); - addIconItem( m_fieldSelection, Meta::valFirstPlayed ); - addIconItem( m_fieldSelection, Meta::valLastPlayed ); - addIconItem( m_fieldSelection, Meta::valPlaycount ); - if (!m_onlyNumeric) - addIconItem( m_fieldSelection, Meta::valLabel ); - addIconItem( m_fieldSelection, Meta::valModified ); - connect( m_fieldSelection, SIGNAL(currentIndexChanged(int)), this, SLOT(fieldChanged(int)) ); -} - -void -MetaQueryWidget::fieldChanged( int i ) -{ - if( m_settingFilter ) - return; - - qint64 field = 0; - if( i<0 || i>=m_fieldSelection->count() ) - field = m_fieldSelection->itemData( 0 ).toInt(); - else - field = m_fieldSelection->itemData( i ).toInt(); - - m_filter.setField( field ); - - // in the fieldChanged slot we assume that the field was really changed, - // so we don't have a problem with throwing away all the old widgets - - if( !m_noCondition ) - makeCompareSelection(); - makeValueSelection(); - - setValueSelection(); - - emit changed(m_filter); -} - -void -MetaQueryWidget::compareChanged( int index ) -{ - FilterCondition condition = FilterCondition( m_compareSelection->itemData( index ).toInt() ); - - if( m_filter.condition == condition ) - return; // nothing to do - - if( m_filter.isDate() ) - { - if( ( condition == OlderThan || condition == NewerThan ) - && m_filter.condition != OlderThan && m_filter.condition != NewerThan - ) - { - // fix some inaccuracies caused by the conversion absoulte/relative time specifications - // this is actually just for visual consistency - int unit = 0; - qint64 value = QDateTime::currentDateTime().toTime_t() - m_filter.numValue; - if( value > 600 || !(value % 60) ) { - unit = 1; - value /= 60; - - if( value > 600 || !(value % 60) ) { - unit = 2; - value /= 60; - - if( value > 72 || !(value % 24) ) { - unit = 3; - value /= 24; - - if( !(value % 365) ) { - unit = 6; - value /= 365; - } else if( !(value % 30) ) { - unit = 5; - value /= 30; - } else if( !(value % 7) ) { - unit = 4; - value /= 7; - } - } - } - } - switch( unit ) - { - case 6: - value *= 365*24*60*60; // years - break; - case 5: - value *= 30*24*60*60; // months - break; - case 4: - value *= 7*24*60*60; // weeks - break; - case 3: - value *= 24; // days - case 2: - value *= 60; // hours - case 1: - value *= 60; // minutes - } - m_filter.numValue = value; - } - else if( condition != OlderThan && condition != NewerThan - && ( m_filter.condition == OlderThan || m_filter.condition == NewerThan ) - ) - { - m_filter.numValue = QDateTime::currentDateTime().toTime_t() - m_filter.numValue; - } - } - - m_filter.condition = condition; - - // need to re-generate the value selection fields - makeValueSelection(); - - setValueSelection(); - - emit changed(m_filter); -} - -void -MetaQueryWidget::valueChanged( const QString& value ) -{ - m_filter.value = value; - - emit changed(m_filter); -} - -void -MetaQueryWidget::numValueChanged( int value ) -{ - m_filter.numValue = value; - - emit changed(m_filter); -} - -void -MetaQueryWidget::numValue2Changed( int value ) -{ - m_filter.numValue2 = value; - - emit changed(m_filter); -} - -void -MetaQueryWidget::numValueChanged( qint64 value ) -{ - m_filter.numValue = value; - - emit changed(m_filter); -} - -void -MetaQueryWidget::numValue2Changed( qint64 value ) -{ - m_filter.numValue2 = value; - - emit changed(m_filter); -} - -void -MetaQueryWidget::numValueChanged( const QTime& value ) -{ - m_filter.numValue = qAbs( value.secsTo( QTime(0,0,0) ) ); - - emit changed(m_filter); -} - -void -MetaQueryWidget::numValue2Changed( const QTime& value ) -{ - m_filter.numValue2 = qAbs( value.secsTo( QTime(0,0,0) ) ); - - emit changed(m_filter); -} - -void -MetaQueryWidget::numValueDateChanged() -{ - KDateCombo* dateSelection = qobject_cast( sender() ); - if( dateSelection ) - { - QDate date; - dateSelection->getDate( &date ); - m_filter.numValue = QDateTime( date ).toTime_t(); - - emit changed(m_filter); - } -} - -void -MetaQueryWidget::numValue2DateChanged() -{ - KDateCombo* dateSelection = qobject_cast( sender() ); - if( dateSelection ) - { - QDate date; - dateSelection->getDate( &date ); - m_filter.numValue2 = QDateTime( date ).toTime_t(); - - emit changed(m_filter); - } -} - -void -MetaQueryWidget::numValueTimeDistanceChanged() -{ - if( !sender() ) - return; - - // static_cast. Remember: the TimeDistanceWidget does not have a Q_OBJECT macro - TimeDistanceWidget* distanceSelection = static_cast( sender()->parent() ); - if( distanceSelection ) - { - m_filter.numValue = distanceSelection->timeDistance(); - - emit changed(m_filter); - } -} - -void -MetaQueryWidget::numValueFormatChanged(int index) -{ - KComboBox* combo = static_cast(sender()); - if( combo ) { - m_filter.numValue = combo->itemData( index ).toInt(); - - emit changed(m_filter); - } -} - -void -MetaQueryWidget::setValueSelection() -{ - if( m_compareSelection ) - m_layoutValueLabels->addWidget( m_compareSelection ); - - if( m_filter.condition == Between ) - { - delete m_andLabel; // delete the old label - m_andLabel = new QLabel( i18n( "and" ), this ); - m_layoutValueLabels->addWidget( m_andLabel ); - } - else - { - delete m_andLabel; - m_andLabel = 0; - } - - if( m_valueSelection1 ) - m_layoutValueValues->addWidget( m_valueSelection1 ); - - if( m_valueSelection2 ) - m_layoutValueValues->addWidget( m_valueSelection2 ); -} - - -void -MetaQueryWidget::makeCompareSelection() -{ - delete m_compareSelection; - m_compareSelection = 0; - - qint64 field = m_filter.field(); - - if( field == Meta::valFormat ) - return; // the field is fixed - - else if( isDate(field) ) - { - m_compareSelection = new KComboBox(); - m_compareSelection->addItem( conditionToString( Equals, field ), (int)Equals ); - m_compareSelection->addItem( conditionToString( LessThan, field ), (int)LessThan ); - m_compareSelection->addItem( conditionToString( GreaterThan, field ), (int)GreaterThan ); - m_compareSelection->addItem( conditionToString( Between, field ), (int)Between ); - m_compareSelection->addItem( conditionToString( OlderThan, field ), (int)OlderThan ); - m_compareSelection->addItem( conditionToString( NewerThan, field ), (int)NewerThan ); - } - else if( isNumeric(field) ) - { - m_compareSelection = new KComboBox(); - m_compareSelection->addItem( conditionToString( Equals, field ), (int)Equals ); - m_compareSelection->addItem( conditionToString( LessThan, field ), (int)LessThan ); - m_compareSelection->addItem( conditionToString( GreaterThan, field ), (int)GreaterThan ); - m_compareSelection->addItem( conditionToString( Between, field ), (int)Between ); - } - else - { - m_compareSelection = new KComboBox(); - m_compareSelection->addItem( conditionToString( Contains, field ), (int)Contains ); - m_compareSelection->addItem( conditionToString( Equals, field ), (int)Equals ); - } - - // -- select the correct entry (even if the condition is not one of the selection) - int index = m_compareSelection->findData( int(m_filter.condition) ); - if( index == -1 ) - { - index = 0; - m_filter.condition = FilterCondition(m_compareSelection->itemData( index ).toInt()); - compareChanged(index); - } - m_compareSelection->setCurrentIndex( index == -1 ? 0 : index ); - - connect( m_compareSelection, SIGNAL(currentIndexChanged(int)), - SLOT(compareChanged(int)) ); -} - -void -MetaQueryWidget::makeValueSelection() -{ - delete m_valueSelection1; - m_valueSelection1 = 0; - delete m_valueSelection2; - m_valueSelection2 = 0; - - qint64 field = m_filter.field(); - if( field == Meta::valUrl ) - makeFilenameSelection(); - else if( field == Meta::valTitle ) - // We,re not going to populate this. There tends to be too many titles. - makeGenericComboSelection( true, 0 ); - else if( field == Meta::valArtist || - field == Meta::valAlbumArtist || - field == Meta::valAlbum || - field == Meta::valGenre || - field == Meta::valComposer ) - makeMetaComboSelection( field ); - else if( field == Meta::valYear ) - makeGenericNumberSelection( field ); - else if( field == Meta::valComment ) - makeGenericComboSelection( true, 0 ); - else if( field == Meta::valTrackNr ) - makeGenericNumberSelection( field ); - else if( field == Meta::valDiscNr ) - makeGenericNumberSelection( field ); - else if( field == Meta::valBpm ) - makeGenericNumberSelection( field ); - else if( field == Meta::valLength ) - makeLengthSelection(); - else if( field == Meta::valBitrate ) - makeGenericNumberSelection( field, i18nc("Unit for data rate kilo bit per seconds", "kbps") ); - else if( field == Meta::valSamplerate ) - makeGenericNumberSelection( field, i18nc("Unit for sample rate", "Hz") ); - else if( field == Meta::valFilesize ) - makeGenericNumberSelection( field, i18nc("Unit for file size in mega byte", "MiB") ); - else if( field == Meta::valFormat ) - makeFormatComboSelection(); - else if( field == Meta::valCreateDate ) - makeDateTimeSelection(); - else if( field == Meta::valScore ) - makeGenericNumberSelection( field ); - else if( field == Meta::valRating ) - makeRatingSelection(); - else if( field == Meta::valFirstPlayed ) - makeDateTimeSelection(); - else if( field == Meta::valLastPlayed ) - makeDateTimeSelection(); - else if( field == Meta::valPlaycount ) - makeGenericNumberSelection( field ); - else if( field == Meta::valLabel ) - makeGenericComboSelection( true, 0 ); - else if( field == Meta::valModified ) - makeDateTimeSelection(); - else // e.g. the simple search - makeGenericComboSelection( true, 0 ); -} - -void -MetaQueryWidget::makeGenericComboSelection( bool editable, Collections::QueryMaker* populateQuery ) -{ - KComboBox* combo = new KComboBox( this ); - combo->setEditable( editable ); - - if( populateQuery != 0 ) - { - m_runningQueries.insert(populateQuery, QWeakPointer(combo)); - connect( populateQuery, SIGNAL(newResultReady(QStringList)), - SLOT(populateComboBox(QStringList)) ); - connect( populateQuery, SIGNAL(queryDone()), - SLOT(comboBoxPopulated()) ); - - populateQuery->run(); - } - combo->setEditText( m_filter.value ); - - connect( combo, SIGNAL(editTextChanged(QString)), - SLOT(valueChanged(QString)) ); - - combo->completionObject()->setIgnoreCase( true ); - combo->setCompletionMode( KGlobalSettings::CompletionPopup ); - combo->setInsertPolicy( QComboBox::InsertAtTop ); - m_valueSelection1 = combo; -} - -void -MetaQueryWidget::makeMetaComboSelection( qint64 field ) -{ - Collections::QueryMaker* qm = CollectionManager::instance()->queryMaker(); - qm->setQueryType( Collections::QueryMaker::Custom ); - qm->addReturnValue( field ); - qm->setAutoDelete( true ); - makeGenericComboSelection( true, qm ); -} - -void -MetaQueryWidget::populateComboBox( QStringList results ) -{ - QObject* query = sender(); - if( !query ) - return; - - QWeakPointer combo = m_runningQueries.value(query); - if( combo.isNull() ) - return; - - // note: adding items seems to reset the edit text, so we have - // to take care of that. - disconnect( combo.data(), 0, this, 0 ); - - // want the results unique and sorted - const QSet dataSet = results.toSet(); - QStringList dataList = dataSet.toList(); - dataList.sort(); - combo.data()->addItems( dataList ); - - KCompletion* comp = combo.data()->completionObject(); - comp->setItems( dataList ); - - // reset the text and re-enable the signal - combo.data()->setEditText( m_filter.value ); - connect( combo.data(), SIGNAL(editTextChanged(QString)), - SLOT(valueChanged(QString)) ); -} - -void -MetaQueryWidget::makeFormatComboSelection() -{ - KComboBox* combo = new KComboBox( this ); - combo->setSizePolicy( QSizePolicy::Ignored, QSizePolicy::Preferred ); - QStringList filetypes = Amarok::FileTypeSupport::possibleFileTypes(); - for (int listpos=0;listposaddItem(filetypes.at(listpos),listpos); - } - - int index = m_fieldSelection->findData( (int)m_filter.numValue ); - combo->setCurrentIndex( index == -1 ? 0 : index ); - - connect( combo, - SIGNAL(currentIndexChanged(int)), - SLOT(numValueFormatChanged(int)) ); - - m_valueSelection1 = combo; -} - -void -MetaQueryWidget::comboBoxPopulated() -{ - QObject* query = sender(); - if( !query ) - return; - - m_runningQueries.remove( query ); -} - -void -MetaQueryWidget::makeFilenameSelection() -{ - // Don't populate the combobox. Too many urls. - makeGenericComboSelection( true, 0 ); -} - - -void -MetaQueryWidget::makeRatingSelection() -{ - KRatingWidget* ratingWidget = new KRatingWidget(); - ratingWidget->setRating( (int)m_filter.numValue ); - connect( ratingWidget, SIGNAL(ratingChanged(int)), - this, SLOT(numValueChanged(int)) ); - - m_valueSelection1 = ratingWidget; - - if( m_filter.condition != Between ) - return; - - // second KRatingWidget for the between selection - KRatingWidget* ratingWidget2 = new KRatingWidget(); - ratingWidget2->setRating( (int)m_filter.numValue2 ); - connect( ratingWidget2, SIGNAL(ratingChanged(int)), - this, SLOT(numValue2Changed(int)) ); - - m_valueSelection2 = ratingWidget2; -} - - -void -MetaQueryWidget::makeLengthSelection() -{ - QString displayFormat = i18nc( "time format for specifying track length - hours, minutes, seconds", "h:m:ss" ); - QTimeEdit* timeSpin = new QTimeEdit(); - timeSpin->setDisplayFormat( displayFormat ); - timeSpin->setMinimumTime( QTime( 0, 0, 0 ) ); - timeSpin->setMaximumTime( QTime( maxHours - 1, 59, 59 ) ); - timeSpin->setTime( QTime().addSecs( m_filter.numValue ) ); - - connect( timeSpin, SIGNAL(timeChanged(QTime)), - SLOT(numValueChanged(QTime)) ); - - m_valueSelection1 = timeSpin; - - if( m_filter.condition != Between ) - return; - - QTimeEdit* timeSpin2 = new QTimeEdit(); - timeSpin2->setDisplayFormat( displayFormat ); - timeSpin2->setMinimumTime( QTime( 0, 0, 0 ) ); - timeSpin2->setMaximumTime( QTime( maxHours - 1, 59, 59 ) ); - timeSpin2->setTime( QTime().addSecs( m_filter.numValue2 ) ); - - connect( timeSpin2, SIGNAL(timeChanged(QTime)), - SLOT(numValue2Changed(QTime)) ); - - m_valueSelection2 = timeSpin2; -} - -void -MetaQueryWidget::makeGenericNumberSelection( qint64 field, const QString& unit ) -{ - KIntSpinBox* spin = new KIntSpinBox(); - spin->setMinimum( Filter::minimumValue( field ) ); - spin->setMaximum( Filter::maximumValue( field ) ); - if( !unit.isEmpty() ) - spin->setSuffix( ' ' + unit ); - spin->setValue( m_filter.numValue ); - - connect( spin, SIGNAL(valueChanged(int)), - this, SLOT(numValueChanged(int)) ); - - m_valueSelection1 = spin; - - if( m_filter.condition != Between ) - return; - - // second spin box for the between selection - KIntSpinBox* spin2 = new KIntSpinBox(); - spin2->setMinimum( Filter::minimumValue( field ) ); - spin2->setMaximum( Filter::maximumValue( field ) ); - if( !unit.isEmpty() ) - spin2->setSuffix( ' ' + unit ); - spin2->setValue( m_filter.numValue2 ); - - connect( spin2, SIGNAL(valueChanged(int)), - this, SLOT(numValue2Changed(int)) ); - - m_valueSelection2 = spin2; -} - - -void -MetaQueryWidget::makeDateTimeSelection() -{ - if( m_filter.condition == OlderThan || m_filter.condition == NewerThan ) - { - TimeDistanceWidget* distanceSelection = new TimeDistanceWidget(); - distanceSelection->setTimeDistance( m_filter.numValue ); - - distanceSelection->connectChanged( this, SLOT(numValueTimeDistanceChanged())); - - m_valueSelection1 = distanceSelection; - } - else - { - KDateCombo* dateSelection = new KDateCombo(); - QDateTime dt; -// if( m_filter.condition == Contains || m_filter.condition == Equals ) -// dt = QDateTime::currentDateTime(); -// else -// dt.setTime_t( m_filter.numValue ); - dt.setTime_t( m_filter.numValue ); - dateSelection->setDate( dt.date() ); - - connect( dateSelection, SIGNAL(currentIndexChanged(int)), - SLOT(numValueDateChanged()) ); - - m_valueSelection1 = dateSelection; - - if( m_filter.condition != Between ) - return; - - // second KDateCombo for the between selection - KDateCombo* dateSelection2 = new KDateCombo(); - dt.setTime_t( m_filter.numValue2 ); - dateSelection2->setDate( dt.date() ); - - connect( dateSelection2, SIGNAL(currentIndexChanged(int)), - SLOT(numValue2DateChanged()) ); - - m_valueSelection2 = dateSelection2; - } -} - - -bool -MetaQueryWidget::isNumeric( qint64 field ) -{ - switch( field ) - { - case Meta::valYear: - case Meta::valTrackNr: - case Meta::valDiscNr: - case Meta::valBpm: - case Meta::valLength: - case Meta::valBitrate: - case Meta::valSamplerate: - case Meta::valFilesize: - case Meta::valFormat: - case Meta::valCreateDate: - case Meta::valScore: - case Meta::valRating: - case Meta::valFirstPlayed: - case Meta::valLastPlayed: - case Meta::valPlaycount: - case Meta::valModified: - return true; - default: - return false; - } -} - -bool -MetaQueryWidget::isDate( qint64 field ) -{ - switch( field ) - { - case Meta::valCreateDate: - case Meta::valFirstPlayed: - case Meta::valLastPlayed: - case Meta::valModified: - return true; - default: - return false; - } -} - -QString -MetaQueryWidget::conditionToString( FilterCondition condition, qint64 field ) -{ - if( isDate(field) ) - { - switch( condition ) - { - case LessThan: - return i18nc( "The date lies before the given fixed date", "before" ); - case Equals: - return i18nc( "The date is the same as the given fixed date", "on" ); - case GreaterThan: - return i18nc( "The date is after the given fixed date", "after" ); - case Between: - return i18nc( "The date is between the given fixed dates", "between" ); - case OlderThan: - return i18nc( "The date lies before the given time interval", "older than" ); - case NewerThan: - return i18nc( "The date lies after the given time interval", "newer than" ); - default: - ; // fall through - } - } - else if( isNumeric(field) ) - { - switch( condition ) - { - case LessThan: - return i18n("less than"); - case Equals: - return i18nc("a numerical tag (like year or track number) equals a value","equals"); - case GreaterThan: - return i18n("greater than"); - case Between: - return i18nc( "a numerical tag (like year or track number) is between two values", "between" ); - default: - ; // fall through - } - } - else - { - switch( condition ) - { - case Equals: - return i18nc("an alphabetical tag (like title or artist name) equals some string","equals"); - case Contains: - return i18nc("an alphabetical tag (like title or artist name) contains some string", "contains"); - default: - ; // fall through - } - } - return QString( i18n("unknown comparison") ); -} - -QString -MetaQueryWidget::Filter::fieldToString() const -{ - return Meta::shortI18nForField( m_field ); -} - -QString MetaQueryWidget::Filter::toString( bool invert ) const -{ - // this member is called when there is a keyword that needs numeric attributes - QString strValue1 = value; - QString strValue2 = value; - - if( m_field == Meta::valFormat ) - { - strValue1 = Amarok::FileTypeSupport::toString( Amarok::FileType( numValue )); - } - else if( m_field == Meta::valRating ) - { - strValue1 = QString::number( (float)numValue / 2 ); - strValue2 = QString::number( (float)numValue2 / 2 ); - } - else if( isDate() ) - { - if( condition == OlderThan || condition == NewerThan ) - { - strValue1 = QString::number( numValue ); - strValue2 = QString::number( numValue2 ); - } - else - { - KLocalizedDate localizedDate1( QDateTime::fromTime_t(numValue).date() ); - strValue1 = localizedDate1.formatDate( KLocale::ShortDate ); - KLocalizedDate localizedDate2( QDateTime::fromTime_t(numValue2).date() ); - strValue2 = localizedDate2.formatDate( KLocale::ShortDate ); - } - } - else if( isNumeric() ) - { - if (numValue < numValue2) // two values are only used for "between". We want to order them by size - { - strValue1 = QString::number( numValue ); - strValue2 = QString::number( numValue2 ); - } - else - { - strValue1 = QString::number( numValue2 ); - strValue2 = QString::number( numValue ); - } - } - - QString result; - if( m_field ) - result = fieldToString() + ':'; - - switch( condition ) - { - case Equals: - { - if( isNumeric() ) - result += strValue1; - else - result += '=' + QString( "\"%1\"" ).arg( value ); - if( invert ) - result.prepend( QChar('-') ); - break; - } - - case GreaterThan: - { - result += '>' + strValue1; - if( invert ) - result.prepend( QChar('-') ); - break; - } - - case LessThan: - { - result +='<' + strValue1; - if( invert ) - result.prepend( QChar('-') ); - break; - } - - case Between: - { - if( invert ) - result = QString( "%1<%2 OR %1>%3" ).arg( result, strValue1, strValue2 ); - else - result = QString( "%1>%2 AND %1<%3" ).arg( result, strValue1, strValue2 ); - break; - } - - case OlderThan: - case NewerThan: - { - // a human readable time.. - QChar strUnit = 's'; - qint64 value = numValue; - if( !(value % 60) ) { - strUnit = 'M'; - value /= 60; - - if( !(value % 60) ) { - strUnit = 'h'; - value /= 60; - - if( !(value % 24) ) { - strUnit = 'd'; - value /= 24; - - if( !(value % 365) ) { - strUnit = 'y'; - value /= 365; - } else if( !(value % 30) ) { - strUnit = 'm'; - value /= 30; - } else if( !(value % 7) ) { - strUnit = 'w'; - value /= 7; - } - } - } - } - - if( condition == OlderThan ) - result += '>' + QString::number(value) + strUnit; - else - result += '<' + QString::number(value) + strUnit; - if( invert ) - result.prepend( QChar('-') ); - break; - } - - case Contains: - { - result += QString( "\"%1\"" ).arg( value ); - if( invert ) - result.prepend( QChar('-') ); - break; - } - } - - return result; -} - -bool -MetaQueryWidget::isFieldSelectorHidden() const -{ - return m_fieldSelection->isHidden(); -} - -void -MetaQueryWidget::setFieldSelectorHidden( const bool hidden ) -{ - m_fieldSelection->setVisible( !hidden ); -} - -void -MetaQueryWidget::setField( const qint64 field ) -{ - int index = m_fieldSelection->findData( field ); - m_fieldSelection->setCurrentIndex( index == -1 ? 0 : index ); -} - -#include "MetaQueryWidget.moc" - diff --git a/amarok/src/widgets/MetaQueryWidget.h b/amarok/src/widgets/MetaQueryWidget.h deleted file mode 100644 index 7b9ca698..00000000 --- a/amarok/src/widgets/MetaQueryWidget.h +++ /dev/null @@ -1,223 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Daniel Caleb Jones * - * Copyright (c) 2009 Mark Kretschmann * - * Copyright (c) 2010 Ralf Engels * - * * - * This program 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 2 of the License, or (at your option) version 3 or * - * any later version accepted by the membership of KDE e.V. (or its successor approved * - * by the membership of KDE e.V.), which shall act as a proxy defined in Section 14 of * - * version 3 of the license. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_METAQUERY_H -#define AMAROK_METAQUERY_H - -#include -#include -#include "core/meta/forward_declarations.h" -#include "core/meta/support/MetaConstants.h" - -class QFrame; -class QGridLayout; -class QHBoxLayout; -class QVBoxLayout; -class QLabel; -class QToolButton; -class KComboBox; -class KIntSpinBox; -class KToolBar; -class KVBox; - -namespace Collections -{ - class QueryMaker; -} - -/** - * A class that allows to select a time distance. - */ -class TimeDistanceWidget : public QWidget -{ - Q_OBJECT - -public: - TimeDistanceWidget( QWidget *parent = 0 ); - qint64 timeDistance() const; - void setTimeDistance( qint64 value ); - void connectChanged( QObject *receiver, const char *slot ); - -protected: - KIntSpinBox *m_timeEdit; - KComboBox *m_unitSelection; - -private slots: - void slotUpdateComboBoxLabels( int value ); -}; - -class MetaQueryWidget : public QWidget -{ - Q_PROPERTY( bool hideFieldSelector READ isFieldSelectorHidden WRITE setFieldSelectorHidden ) - - Q_OBJECT - - public: - /** Creates a MetaQueryWidget which can be used to select one meta query filter. - * @param onlyNumeric If set to true the widget will only display numeric fields. - * @param noCondition If set to true no condition can be selected. - */ - explicit MetaQueryWidget( QWidget* parent = 0, bool onlyNumeric = false, bool noCondition = false ); - ~MetaQueryWidget(); - - enum FilterCondition - { - Equals = 0, - GreaterThan = 1, - LessThan = 2, - Between = 3, - OlderThan = 4, - NewerThan = 5, - Contains = 6 - }; - - struct Filter - { - Filter() - : m_field( 0 ) - , numValue( 0 ) - , numValue2( 0 ) - , condition( Contains ) - {} - - qint64 field() const { return m_field; } - void setField( qint64 newField ); - - /** Returns a textual representation of the field. - */ - QString fieldToString() const; - - /** Returns a textual representation of the filter. - * Used for the edit filter dialog (or for debugging) - */ - QString toString( bool invert = false ) const; - - bool isNumeric() const - { return MetaQueryWidget::isNumeric( m_field ); } - - bool isDate() const - { return MetaQueryWidget::isDate( m_field ); } - - /** Returns the minimum allowed value for the field type */ - static qint64 minimumValue( quint64 field ); - static qint64 maximumValue( quint64 field ); - static qint64 defaultValue( quint64 field ); - - private: - qint64 m_field; - - public: - QString value; - qint64 numValue; - qint64 numValue2; - FilterCondition condition; - }; - - /** Returns the current filter value. - */ - Filter filter() const; - - /** Returns true if the given field is a numeric field */ - static bool isNumeric( qint64 field ); - - /** Returns true if the given field is a date field */ - static bool isDate( qint64 field ); - - /** Returns a localized text of the condition. - @param field Needed in order to test whether the field is a date, numeric or a string since the texts differ slightly - */ - static QString conditionToString( FilterCondition condition, qint64 field ); - - - public slots: - void setFilter(const MetaQueryWidget::Filter &value); - - void setField( const qint64 field ); - /** Field Selector combo box visibility state - */ - bool isFieldSelectorHidden() const; - void setFieldSelectorHidden( const bool hidden ); - - signals: - void changed(const MetaQueryWidget::Filter &value); - - private slots: - void fieldChanged( int ); - void compareChanged( int ); - void valueChanged( const QString& ); - void numValueChanged( int ); - void numValue2Changed( int ); - void numValueChanged( qint64 ); - void numValue2Changed( qint64 ); - void numValueChanged( const QTime& ); - void numValue2Changed( const QTime& ); - void numValueDateChanged(); - void numValue2DateChanged(); - void numValueTimeDistanceChanged(); - void numValueFormatChanged( int ); - - void populateComboBox( QStringList ); - void comboBoxPopulated(); - - private: - void makeFieldSelection(); - - /** Adds the value selection widgets to the layout. - * Adds m_compareSelection, m_valueSelection1, m_valueSelection2 to the layout. - */ - void setValueSelection(); - - void makeCompareSelection(); - void makeValueSelection(); - - void makeGenericComboSelection( bool editable, Collections::QueryMaker* populateQuery ); - void makeMetaComboSelection( qint64 field ); - - void makeFormatComboSelection(); - void makeGenericNumberSelection( qint64 field, const QString& unit = "" ); - void makePlaycountSelection(); - void makeRatingSelection(); - void makeLengthSelection(); - void makeDateTimeSelection(); - void makeFilenameSelection(); - - bool m_onlyNumeric; - bool m_noCondition; - - bool m_settingFilter; // if set to true we are just setting the filter - - QVBoxLayout* m_layoutMain; - QHBoxLayout* m_layoutValue; - QVBoxLayout* m_layoutValueLabels; - QVBoxLayout* m_layoutValueValues; - - KComboBox* m_fieldSelection; - QLabel* m_andLabel; - KComboBox* m_compareSelection; - QWidget* m_valueSelection1; - QWidget* m_valueSelection2; - - Filter m_filter; - - QMap< QObject*, QWeakPointer > m_runningQueries; -}; - -#endif - diff --git a/amarok/src/widgets/Osd.cpp b/amarok/src/widgets/Osd.cpp deleted file mode 100644 index 4a9f0508..00000000 --- a/amarok/src/widgets/Osd.cpp +++ /dev/null @@ -1,866 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2004 Christian Muehlhaeuser * - * Copyright (c) 2004-2006 Seb Ruiz * - * Copyright (c) 2004,2005 Max Howell * - * Copyright (c) 2005 Gabor Lehel * - * Copyright (c) 2008-2013 Mark Kretschmann * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "OSD" - -#include "Osd.h" - -#include "EngineController.h" -#include "KNotificationBackend.h" -#include "PaletteHandler.h" -#include "SvgHandler.h" -#include "amarokconfig.h" -#include "core/meta/Meta.h" -#include "core/meta/Statistics.h" -#include "core/meta/support/MetaUtility.h" -#include "core/support/Amarok.h" -#include "core/support/Debug.h" -#include "widgets/StarManager.h" - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -namespace ShadowEngine -{ - QImage makeShadow( const QPixmap &textPixmap, const QColor &bgColor ); -} - -namespace Amarok -{ - inline QImage icon() { return QImage( KIconLoader::global()->iconPath( "amarok", -KIconLoader::SizeHuge ) ); } -} - -OSDWidget::OSDWidget( QWidget *parent, const char *name ) - : QWidget( parent ) - , m_duration( 2000 ) - , m_timer( new QTimer( this ) ) - , m_alignment( Middle ) - , m_screen( 0 ) - , m_yOffset( MARGIN ) - , m_rating( 0 ) - , m_volume( The::engineController()->volume() ) - , m_showVolume( false ) - , m_hideWhenFullscreenWindowIsActive( false ) - , m_fadeTimeLine( new QTimeLine( FADING_DURATION, this ) ) -{ - Qt::WindowFlags flags; - flags = Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint; - // The best of both worlds. On Windows, setting the widget as a popup avoids a task manager entry. On linux, a popup steals focus. - // Therefore we go need to do it platform specific :( - - //This is no longer true. Qt::Window steals focus on X11, Qt:Tool does not. Not sure if we even need the ifdefs any more... - #ifdef Q_OS_WIN - flags |= Qt::Tool; - #else - flags |= Qt::Tool | Qt::X11BypassWindowManagerHint; - #endif - setWindowFlags( flags ); - setObjectName( name ); - setFocusPolicy( Qt::NoFocus ); - - #ifdef Q_WS_X11 - KWindowSystem::setType( winId(), NET::Notification ); - #endif - - m_timer->setSingleShot( true ); - connect( m_timer, SIGNAL(timeout()), SLOT(hide()) ); - - m_fadeTimeLine->setUpdateInterval( 30 ); //~33 frames per second - connect( m_fadeTimeLine, SIGNAL(valueChanged(qreal)), SLOT(setFadeOpacity(qreal)) ); - - //or crashes, KWindowSystem bug I think, crashes in QWidget::icon() - kapp->setTopWidget( this ); -} - -OSDWidget::~OSDWidget() -{ - DEBUG_BLOCK -} - -void -OSDWidget::show( const QString &text, const QImage &newImage ) -{ - DEBUG_BLOCK - m_showVolume = false; - if ( !newImage.isNull() ) - { - m_cover = newImage; - int w = m_scaledCover.width(); - int h = m_scaledCover.height(); - m_scaledCover = QPixmap::fromImage( m_cover.scaled( w, h, Qt::IgnoreAspectRatio, Qt::SmoothTransformation ) ); - } - else - m_cover = Amarok::icon(); - - m_text = text; - show(); -} - -void -OSDWidget::show() -{ - if ( !isTemporaryDisabled() ) - { - QWidget::show(); - - if( windowOpacity() == 0.0 && KWindowSystem::compositingActive() ) - { - m_fadeTimeLine->setDirection( QTimeLine::Forward ); - m_fadeTimeLine->start(); - } - // Skip fading if OSD is already visible or if compositing is disabled - else - { - m_fadeTimeLine->stop(); - setWindowOpacity( maxOpacity() ); - } - } -} - -void -OSDWidget::hide() -{ - if( KWindowSystem::compositingActive() ) - { - m_fadeTimeLine->setDirection( QTimeLine::Backward ); - m_fadeTimeLine->start(); - } - else - { - QWidget::hide(); - } -} - -bool -OSDWidget::isTemporaryDisabled() const -{ - // Check if the OSD should not be shown, - // if a fullscreen window is focused. - if ( m_hideWhenFullscreenWindowIsActive ) - { - return Amarok::KNotificationBackend::instance()->isFullscreenWindowActive(); - } - - return false; -} - -void -OSDWidget::ratingChanged( const QString& path, int rating ) -{ - Meta::TrackPtr track = The::engineController()->currentTrack(); - if( !track ) - return; - if( track->playableUrl().isLocalFile() && track->playableUrl().path() == path ) - ratingChanged( rating ); -} - -void -OSDWidget::ratingChanged( const short rating ) -{ - m_text = '\n' + i18n( "Rating changed" ); - setRating( rating ); //Checks isEnabled() before doing anything - - show(); -} - -void -OSDWidget::volumeChanged( int volume ) -{ - m_volume = volume; - - if ( isEnabled() ) - { - m_showVolume = true; - const KLocalizedString text = The::engineController()->isMuted() ? ki18n( "Volume: %1% (muted)" ) : ki18n( "Volume: %1%" ); - m_text = text.subs( m_volume ).toString(); - - show(); - } -} - -void -OSDWidget::setVisible( bool visible ) -{ - if ( visible ) - { - if ( !isEnabled() || m_text.isEmpty() ) - return; - - const uint margin = fontMetrics().width( 'x' ); - - const QRect newGeometry = determineMetrics( margin ); - - if( newGeometry.width() > 0 && newGeometry.height() > 0 ) - { - m_margin = margin; - m_size = newGeometry.size(); - setGeometry( newGeometry ); - QWidget::setVisible( visible ); - - if( m_duration ) //duration 0 -> stay forever - m_timer->start( m_duration ); //calls hide() - } - else - warning() << "Attempted to make an invalid sized OSD\n"; - - update(); - } - else - QWidget::setVisible( visible ); -} - -QRect -OSDWidget::determineMetrics( const int M ) -{ - // sometimes we only have a tiddly cover - const QSize minImageSize = m_cover.size().boundedTo( QSize( 100, 100 ) ); - - // determine a sensible maximum size, don't cover the whole desktop or cross the screen - const QSize margin( ( M + MARGIN ) * 2, ( M + MARGIN ) * 2 ); //margins - const QSize image = m_cover.isNull() ? QSize( 0, 0 ) : minImageSize; - const QSize max = QApplication::desktop()->screen( m_screen )->size() - margin; - - // If we don't do that, the boundingRect() might not be suitable for drawText() (Qt issue N67674) - m_text.replace( QRegExp( " +\n" ), "\n" ); - // remove consecutive line breaks - m_text.replace( QRegExp( "\n+" ), "\n" ); - - // The osd cannot be larger than the screen - QRect rect = fontMetrics().boundingRect( 0, 0, max.width() - image.width(), max.height(), - Qt::AlignCenter, m_text ); - rect.adjust( 0, 0, SHADOW_SIZE * 2, SHADOW_SIZE * 2 ); // the shadow needs some space - - if( m_showVolume ) - { - static const QString tmp = QString ("******").insert( 3, - ( i18n("Volume: 100% (muted)" ) ) ); - - QRect tmpRect = fontMetrics().boundingRect( 0, 0, - max.width() - image.width(), max.height() - fontMetrics().height(), - Qt::AlignCenter, tmp ); - tmpRect.setHeight( tmpRect.height() + fontMetrics().height() / 2 ); - - rect = tmpRect; - - if ( The::engineController()->isMuted() ) - m_cover = The::svgHandler()->renderSvg( "Muted", 100, 100, "Muted" ).toImage(); - else if( m_volume > 66 ) - m_cover = The::svgHandler()->renderSvg( "Volume", 100, 100, "Volume" ).toImage(); - else if ( m_volume > 33 ) - m_cover = The::svgHandler()->renderSvg( "Volume_mid", 100, 100, "Volume_mid" ).toImage(); - else - m_cover = The::svgHandler()->renderSvg( "Volume_low", 100, 100, "Volume_low" ).toImage(); - } - // Don't show both volume and rating - else if( m_rating ) - { - QPixmap* star = StarManager::instance()->getStar( 1 ); - if( rect.width() < star->width() * 5 ) - rect.setWidth( star->width() * 5 ); //changes right edge position - rect.setHeight( rect.height() + star->height() + M ); //changes bottom edge pos - } - - if( !m_cover.isNull() ) - { - const int availableWidth = max.width() - rect.width() - M; //WILL be >= (minImageSize.width() - M) - - m_scaledCover = QPixmap::fromImage( - m_cover.scaled( - qMin( availableWidth, m_cover.width() ), - qMin( rect.height(), m_cover.height() ), - Qt::KeepAspectRatio, Qt::SmoothTransformation - ) - ); //this will force us to be with our bounds - - - const int widthIncludingImage = rect.width() - + m_scaledCover.width() - + M; //margin between text + image - - rect.setWidth( widthIncludingImage ); - } - - // expand in all directions by M - rect.adjust( -M, -M, M, M ); - - const QSize newSize = rect.size(); - const QRect screen = QApplication::desktop()->screenGeometry( m_screen ); - QPoint newPos( MARGIN, m_yOffset ); - - switch( m_alignment ) - { - case Left: - break; - - case Right: - newPos.rx() = screen.width() - MARGIN - newSize.width(); - break; - - case Center: - newPos.ry() = ( screen.height() - newSize.height() ) / 2; - - //FALL THROUGH - - case Middle: - newPos.rx() = ( screen.width() - newSize.width() ) / 2; - break; - } - - //ensure we don't dip below the screen - if ( newPos.y() + newSize.height() > screen.height() - MARGIN ) - newPos.ry() = screen.height() - MARGIN - newSize.height(); - - // correct for screen position - newPos += screen.topLeft(); - - return QRect( newPos, rect.size() ); -} - -void -OSDWidget::paintEvent( QPaintEvent *e ) -{ - QRect rect( QPoint(), m_size ); - - QColor shadowColor; - { - int h, s, v; - palette().color( QPalette::Normal, QPalette::WindowText ).getHsv( &h, &s, &v ); - shadowColor = v > 128 ? Qt::black : Qt::white; - } - - const int align = Qt::AlignCenter; - - QPainter p( this ); - p.setRenderHints( QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform | QPainter::HighQualityAntialiasing ); - p.setClipRect( e->rect() ); - - QPixmap background = The::svgHandler()->renderSvgWithDividers( "service_list_item", width(), height(), "service_list_item" ); - p.drawPixmap( 0, 0, background ); - - //p.setPen( Qt::white ); // Revert this when the background can be colorized again. - rect.adjust( m_margin, m_margin, -m_margin, -m_margin ); // subtract margins - - if( !m_cover.isNull() ) - { - QRect r( rect ); - r.setTop( ( m_size.height() - m_scaledCover.height() ) / 2 ); - r.setSize( m_scaledCover.size() ); - - p.drawPixmap( r.topLeft(), m_scaledCover ); - - rect.setLeft( rect.left() + m_scaledCover.width() + m_margin ); - } - - int graphicsHeight = 0; - - if( !m_showVolume && m_rating > 0 && !m_paused ) - { - // TODO: Check if we couldn't use a KRatingPainter instead - QPixmap* star = StarManager::instance()->getStar( m_rating/2 ); - QRect r( rect ); - - //Align to center... - r.setLeft( ( rect.left() + rect.width() / 2 ) - star->width() * m_rating / 4 ); - r.setTop( rect.bottom() - star->height() ); - graphicsHeight += star->height() + m_margin; - - const bool half = m_rating % 2; - - if( half ) - { - QPixmap* halfStar = StarManager::instance()->getHalfStar( m_rating / 2 + 1 ); - p.drawPixmap( r.left() + star->width() * ( m_rating / 2 ), r.top(), *halfStar ); - star = StarManager::instance()->getStar( m_rating / 2 + 1 ); - } - - for( int i = 0; i < m_rating / 2; i++ ) - { - p.drawPixmap( r.left() + i * star->width(), r.top(), *star ); - } - } - - rect.setBottom( rect.bottom() - graphicsHeight ); - - // Draw "shadow" text effect (black outline) (currently it's up to five pixel in every dir.) - QPixmap pixmap( rect.size() ); - pixmap.fill( Qt::black ); - - QPainter p2( &pixmap ); - p2.setFont( font() ); - p2.setPen( Qt::white ); - p2.setBrush( Qt::white ); - p2.drawText( QRect( QPoint( SHADOW_SIZE, SHADOW_SIZE ), - QSize( rect.size().width() - SHADOW_SIZE * 2, - rect.size().height() - SHADOW_SIZE * 2 ) ), - align, m_text ); - p2.end(); - - p.drawImage( rect.topLeft(), ShadowEngine::makeShadow( pixmap, shadowColor ) ); - - p.setPen( palette().color( QPalette::Active, QPalette::WindowText ) ); - - p.drawText( rect.adjusted( SHADOW_SIZE, SHADOW_SIZE, - -SHADOW_SIZE, -SHADOW_SIZE ), align, m_text ); -} - -void -OSDWidget::changeEvent( QEvent *event ) -{ - QWidget::changeEvent( event ); - - if( event->type() == QEvent::PaletteChange ) - if( !AmarokConfig::osdUseCustomColors() ) - unsetColors(); // Use new palette's colors -} - -void -OSDWidget::mousePressEvent( QMouseEvent* ) -{ - hide(); -} - -void -OSDWidget::unsetColors() -{ - setPalette( The::paletteHandler()->palette() ); -} - -void -OSDWidget::setTextColor(const QColor& color) -{ - QPalette palette = this->palette(); - palette.setColor( QPalette::Active, QPalette::WindowText, color ); - setPalette(palette); -} - -void -OSDWidget::setScreen( int screen ) -{ - const int n = QApplication::desktop()->screenCount(); - m_screen = ( screen >= n ) ? n - 1 : screen; -} - -void -OSDWidget::setFadeOpacity( qreal value ) -{ - setWindowOpacity( value * maxOpacity() ); - - if( value == 0.0 ) - { - QWidget::hide(); - } -} - -void -OSDWidget::setFontScale( int scale ) -{ - double fontScale = static_cast( scale ) / 100.0; - - // update font, reuse old one - QFont newFont( font() ); - newFont.setPointSizeF( defaultPointSize() * fontScale ); - setFont( newFont ); -} - -void -OSDWidget::setHideWhenFullscreenWindowIsActive( bool hide ) -{ - m_hideWhenFullscreenWindowIsActive = hide; -} - - -///////////////////////////////////////////////////////////////////////////////////////// -// Class OSDPreviewWidget -///////////////////////////////////////////////////////////////////////////////////////// - -OSDPreviewWidget::OSDPreviewWidget( QWidget *parent ) - : OSDWidget( parent ) - , m_dragging( false ) -{ - setObjectName( "osdpreview" ); - setDuration( 0 ); - setImage( Amarok::icon() ); - setTranslucent( AmarokConfig::osdUseTranslucency() ); - setText( i18n( "On-Screen-Display preview\nDrag to reposition" ) ); -} - -void -OSDPreviewWidget::mousePressEvent( QMouseEvent *event ) -{ - m_dragYOffset = event->pos(); - - if( event->button() == Qt::LeftButton && !m_dragging ) - { - grabMouse( Qt::SizeAllCursor ); - m_dragging = true; - } -} - -void -OSDPreviewWidget::setUseCustomColors(const bool use, const QColor& fg) -{ - if( use ) - setTextColor( fg ); - else - unsetColors(); -} - -void -OSDPreviewWidget::mouseReleaseEvent( QMouseEvent * /*event*/ ) -{ - if( m_dragging ) - { - m_dragging = false; - releaseMouse(); - - emit positionChanged(); - } -} - -void -OSDPreviewWidget::mouseMoveEvent( QMouseEvent *e ) -{ - if( m_dragging && this == mouseGrabber() ) - { - // Here we implement a "snap-to-grid" like positioning system for the preview widget - - const QRect screenRect = QApplication::desktop()->screenGeometry( screen() ); - const uint hcenter = screenRect.width() / 2; - const uint eGlobalPosX = e->globalPos().x() - screenRect.left(); - const uint snapZone = screenRect.width() / 24; - - QPoint destination = e->globalPos() - m_dragYOffset - screenRect.topLeft(); - int maxY = screenRect.height() - height() - MARGIN; - if( destination.y() < MARGIN ) - destination.ry() = MARGIN; - if( destination.y() > maxY ) - destination.ry() = maxY; - - if( eGlobalPosX < ( hcenter - snapZone ) ) - { - setAlignment(Left); - destination.rx() = MARGIN; - } - else if( eGlobalPosX > ( hcenter + snapZone ) ) - { - setAlignment(Right); - destination.rx() = screenRect.width() - MARGIN - width(); - } - else { - const uint eGlobalPosY = e->globalPos().y() - screenRect.top(); - const uint vcenter = screenRect.height() / 2; - - destination.rx() = hcenter - width() / 2; - - if( eGlobalPosY >= ( vcenter - snapZone ) && eGlobalPosY <= ( vcenter + snapZone ) ) - { - setAlignment(Center); - destination.ry() = vcenter - height() / 2; - } - else - setAlignment(Middle); - } - - destination += screenRect.topLeft(); - move( destination ); - - // compute current Position && Y-offset - QDesktopWidget *desktop = QApplication::desktop(); - const int currentScreen = desktop->screenNumber( pos() ); - - // set new data - OSDWidget::setScreen( currentScreen ); - setYOffset( y() ); - } -} - - -///////////////////////////////////////////////////////////////////////////////////////// -// Class OSD -///////////////////////////////////////////////////////////////////////////////////////// - -Amarok::OSD* Amarok::OSD::s_instance = 0; - -Amarok::OSD* -Amarok::OSD::instance() -{ - return s_instance ? s_instance : new OSD(); -} - -void -Amarok::OSD::destroy() -{ - if ( s_instance ) - { - delete s_instance; - s_instance = 0; - } -} - -Amarok::OSD::OSD() - : OSDWidget( 0 ) -{ - s_instance = this; - - EngineController* const engine = The::engineController(); - - if( engine->isPlaying() ) - trackPlaying( engine->currentTrack() ); - - connect( engine, SIGNAL(trackPlaying(Meta::TrackPtr)), - this, SLOT(trackPlaying(Meta::TrackPtr)) ); - connect( engine, SIGNAL(stopped(qint64,qint64)), - this, SLOT(stopped()) ); - connect( engine, SIGNAL(paused()), - this, SLOT(paused()) ); - - connect( engine, SIGNAL(trackMetadataChanged(Meta::TrackPtr)), - this, SLOT(metadataChanged()) ); - connect( engine, SIGNAL(albumMetadataChanged(Meta::AlbumPtr)), - this, SLOT(metadataChanged()) ); - - connect( engine, SIGNAL(volumeChanged(int)), - this, SLOT(volumeChanged(int)) ); - - connect( engine, SIGNAL(muteStateChanged(bool)), - this, SLOT(muteStateChanged(bool)) ); - -} - -Amarok::OSD::~OSD() -{} - -void -Amarok::OSD::show( Meta::TrackPtr track ) //slot -{ - setAlignment( static_cast( AmarokConfig::osdAlignment() ) ); - setYOffset( AmarokConfig::osdYOffset() ); - - QString text; - if( !track || track->playableUrl().isEmpty() ) - { - text = i18n( "No track playing" ); - setRating( 0 ); // otherwise stars from last rating change are visible - } - else - { - setRating( track->statistics()->rating() ); - text = track->prettyName(); - if( track->artist() && !track->artist()->prettyName().isEmpty() ) - text = track->artist()->prettyName() + " - " + text; - if( track->album() && !track->album()->prettyName().isEmpty() ) - text += "\n (" + track->album()->prettyName() + ") "; - else - text += '\n'; - if( track->length() > 0 ) - text += Meta::msToPrettyTime( track->length() ); - } - - if( text.isEmpty() ) - text = track->playableUrl().fileName(); - - if( text.startsWith( "- " ) ) //When we only have a title tag, _something_ prepends a fucking hyphen. Remove that. - text = text.mid( 2 ); - - if( text.isEmpty() ) //still - text = i18n("No information available for this track"); - - QImage image; - if( track && track->album() ) - image = The::svgHandler()->imageWithBorder( track->album(), 100, 5 ).toImage(); - - OSDWidget::show( text, image ); -} - -void -Amarok::OSD::applySettings() -{ - DEBUG_BLOCK - - setAlignment( static_cast( AmarokConfig::osdAlignment() ) ); - setDuration( AmarokConfig::osdDuration() ); - setEnabled( AmarokConfig::osdEnabled() ); - setYOffset( AmarokConfig::osdYOffset() ); - setScreen( AmarokConfig::osdScreen() ); - setFontScale( AmarokConfig::osdFontScaling() ); - setHideWhenFullscreenWindowIsActive( AmarokConfig::osdHideOnFullscreen() ); - - if( AmarokConfig::osdUseCustomColors() ) - setTextColor( AmarokConfig::osdTextColor() ); - else - unsetColors(); - - setTranslucent( AmarokConfig::osdUseTranslucency() ); -} - -void -Amarok::OSD::forceToggleOSD() -{ - if ( !isVisible() ) - { - const bool b = isEnabled(); - setEnabled( true ); - show( The::engineController()->currentTrack() ); - setEnabled( b ); - } - else - hide(); -} - -void -Amarok::OSD::muteStateChanged( bool mute ) -{ - Q_UNUSED( mute ) - - volumeChanged( The::engineController()->volume() ); -} - -void -Amarok::OSD::trackPlaying( Meta::TrackPtr track ) -{ - m_currentTrack = track; - - setPaused(false); - show( m_currentTrack ); -} - -void -Amarok::OSD::stopped() -{ - setImage( QImage( KIconLoader::global()->iconPath( "amarok", -KIconLoader::SizeHuge ) ) ); - setRating( 0 ); // otherwise stars from last rating change are visible - OSDWidget::show( i18n( "Stopped" ) ); - setPaused(false); -} - -void -Amarok::OSD::paused() -{ - setImage( QImage( KIconLoader::global()->iconPath( "amarok", -KIconLoader::SizeHuge ) ) ); - setRating( 0 ); // otherwise stars from last rating change are visible - OSDWidget::show( i18n( "Paused" ) ); - setPaused(true); -} - -void -Amarok::OSD::metadataChanged() -{ - // this also covers all cases where a stream get's new metadata. - show( m_currentTrack ); -} - - -/* Code copied from kshadowengine.cpp - * - * Copyright (C) 2003 Laur Ivan - * - * Many thanks to: - * - Bernardo Hung for the enhanced shadow - * algorithm (currently used) - * - Tim Jansen for the API updates and fixes. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -namespace ShadowEngine -{ - // Not sure, doesn't work above 10 - static const int MULTIPLICATION_FACTOR = 3; - // Multiplication factor for pixels directly above, under, or next to the text - static const double AXIS_FACTOR = 2.0; - // Multiplication factor for pixels diagonal to the text - static const double DIAGONAL_FACTOR = 0.1; - // Self explanatory - static const int MAX_OPACITY = 200; - - double decay( QImage&, int, int ); - - QImage makeShadow( const QPixmap& textPixmap, const QColor &bgColor ) - { - const int w = textPixmap.width(); - const int h = textPixmap.height(); - const int bgr = bgColor.red(); - const int bgg = bgColor.green(); - const int bgb = bgColor.blue(); - - int alphaShadow; - - // This is the source pixmap - QImage img = textPixmap.toImage(); - - QImage result( w, h, QImage::Format_ARGB32 ); - result.fill( 0 ); // fill with black - - static const int M = OSDWidget::SHADOW_SIZE; - for( int i = M; i < w - M; i++) { - for( int j = M; j < h - M; j++ ) - { - alphaShadow = (int) decay( img, i, j ); - - result.setPixel( i,j, qRgba( bgr, bgg , bgb, qMin( MAX_OPACITY, alphaShadow ) ) ); - } - } - - return result; - } - - double decay( QImage& source, int i, int j ) - { - //if ((i < 1) || (j < 1) || (i > source.width() - 2) || (j > source.height() - 2)) - // return 0; - - double alphaShadow; - alphaShadow =(qGray(source.pixel(i-1,j-1)) * DIAGONAL_FACTOR + - qGray(source.pixel(i-1,j )) * AXIS_FACTOR + - qGray(source.pixel(i-1,j+1)) * DIAGONAL_FACTOR + - qGray(source.pixel(i ,j-1)) * AXIS_FACTOR + - 0 + - qGray(source.pixel(i ,j+1)) * AXIS_FACTOR + - qGray(source.pixel(i+1,j-1)) * DIAGONAL_FACTOR + - qGray(source.pixel(i+1,j )) * AXIS_FACTOR + - qGray(source.pixel(i+1,j+1)) * DIAGONAL_FACTOR) / MULTIPLICATION_FACTOR; - - return alphaShadow; - } -} - -#include "moc_Osd.cpp" diff --git a/amarok/src/widgets/Osd.h b/amarok/src/widgets/Osd.h deleted file mode 100644 index 36401153..00000000 --- a/amarok/src/widgets/Osd.h +++ /dev/null @@ -1,214 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2003 Christian Muehlhaeuser * - * Copyright (c) 2008-2013 Mark Kretschmann * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_OSD_H -#define AMAROK_OSD_H - -#include "core/meta/forward_declarations.h" - -#include -#include -#include -#include //baseclass - -#define OSD_WINDOW_OPACITY 0.74 - -class QTimeLine; - -class OSDWidget : public QWidget -{ - Q_OBJECT - - public: - enum Alignment { Left, Middle, Center, Right }; - - /** shadow size in every direction */ - static const int SHADOW_SIZE = 5; - - static const int FADING_DURATION = 400; //ms - - public slots: - /** calls setText() then show(), after setting image if needed */ - void show( const QString &text, const QImage &newImage = QImage() ); - - void ratingChanged( const short rating ); - void ratingChanged( const QString& path, int rating ); - void volumeChanged( int volume ); - - /** reimplemented, show the OSD */ - virtual void show(); - /** reimplemented, hide the OSD */ - virtual void hide(); - - virtual void setVisible( bool visible ); - - /** - * For the sake of simplicity, when these settings are - * changed they do not take effect until the next time - * the OSD is shown! - * - * To force an update call show(); - */ - void setDuration( int ms ) { m_duration = ms; } - void setTextColor( const QColor &color ); - - inline uint yOffset() const { return m_yOffset; } - void setYOffset( int y ) { m_yOffset = y; } - - inline int alignment() const { return m_alignment; } - void setAlignment( Alignment alignment ) { m_alignment = alignment; } - - inline int screen() const { return m_screen; } - void setScreen( int screen ); - - void setPaused( bool paused ) { m_paused = paused; } - void setImage( const QImage &image ) { m_cover = image; } - void setText( const QString &text ) { m_text = text; } - void setRating( const short rating ) { m_rating = rating; } - void setTranslucent( bool enabled ) { m_translucent = enabled; setWindowOpacity( maxOpacity() ); } - void setFadeOpacity( qreal value ); - void setFontScale( int scale ); - void setHideWhenFullscreenWindowIsActive( bool hide ); - - protected: - explicit OSDWidget( QWidget *parent, const char *name = "osd" ); - virtual ~OSDWidget(); - - // work-around to get default point size on this platform, Qt API does not offer this directly - inline qreal defaultPointSize() const { return QFont(font().family()).pointSizeF(); } - - inline qreal maxOpacity() const { return m_translucent ? OSD_WINDOW_OPACITY : 1.0; } - - /** determine new size and position */ - QRect determineMetrics( const int marginMetric ); - - /** - * @short Checks if the OSD is temporary disabled. - * This is usually the case if the OSD should not be shown - * if a fullscreen application is active (@see m_hideWhenFullscreenWindowIsActive) - * (where the OSD could steal focus). - */ - bool isTemporaryDisabled() const; - - /** resets the colours to defaults */ - void unsetColors(); - - // Reimplemented from QWidget - virtual void paintEvent( QPaintEvent* ); - virtual void mousePressEvent( QMouseEvent* ); - virtual void changeEvent( QEvent* ); - - /** distance from screen edge */ - static const int MARGIN = 15; - - private: - uint m_margin; - QSize m_size; - int m_duration; - QTimer *m_timer; - Alignment m_alignment; - int m_screen; - uint m_yOffset; - short m_rating; - int m_volume; - bool m_showVolume; - QString m_text; - QImage m_cover; - QPixmap m_scaledCover; - bool m_paused; - bool m_hideWhenFullscreenWindowIsActive; - QTimeLine* m_fadeTimeLine; - bool m_translucent; -}; - - -class OSDPreviewWidget : public OSDWidget -{ - Q_OBJECT - -public: - OSDPreviewWidget( QWidget *parent ); - -public slots: - void setTextColor( const QColor &color ) { OSDWidget::setTextColor( color ); doUpdate(); } - void setScreen( int screen ) { OSDWidget::setScreen( screen ); doUpdate(); } - void setFontScale( int scale ) { OSDWidget::setFontScale( scale ); doUpdate(); } - void setTranslucent( bool enabled ) { OSDWidget::setTranslucent( enabled ); doUpdate(); } - - void setUseCustomColors( const bool use, const QColor &fg ); - - virtual void hide() { QWidget::hide(); } - -private: - inline void doUpdate() { if( !isHidden() ) show(); } - -signals: - void positionChanged(); - -protected: - void mousePressEvent( QMouseEvent * ); - void mouseReleaseEvent( QMouseEvent * ); - void mouseMoveEvent( QMouseEvent * ); - -private: - bool m_dragging; - QPoint m_dragYOffset; -}; - - - -namespace Amarok -{ - class OSD : public OSDWidget - { - Q_OBJECT - - public: - static OSD* instance(); - static void destroy(); - - void applySettings(); - virtual void show( Meta::TrackPtr track ); - - // Don't hide baseclass methods - prevent compiler warnings - virtual void show() { OSDWidget::show(); } - - protected slots: - void muteStateChanged( bool mute ); - void trackPlaying( Meta::TrackPtr track ); - void stopped(); - void paused(); - void metadataChanged(); - - public slots: - /** - * When user pushs global shortcut or uses script to toggle - * even if it is disabled() - */ - void forceToggleOSD(); - - private: - OSD(); - ~OSD(); - - static OSD* s_instance; - - Meta::TrackPtr m_currentTrack; - }; -} - -#endif /*AMAROK_OSD_H*/ diff --git a/amarok/src/widgets/PixmapViewer.cpp b/amarok/src/widgets/PixmapViewer.cpp deleted file mode 100644 index 90e6f8a8..00000000 --- a/amarok/src/widgets/PixmapViewer.cpp +++ /dev/null @@ -1,123 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2005 Eyal Lotem * - * Copyright (c) 2005 Alexandre Pereira de Oliveira * - * Copyright (c) 2007 Seb Ruiz * - * Copyright (c) 2009 Pascal Pollet * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "PixmapViewer.h" - -#include - -#include - -#include -#include -#include -#include - - -PixmapViewer::PixmapViewer( QWidget *parent, const QPixmap &pix, int screenNumber ) - : QWidget( parent ) - , m_pixmap( pix ) -{ - m_zoomFactor = 1.0; // initial zoom - - int screenWidth = KApplication::desktop()->availableGeometry( screenNumber ).width(); - int screenHeight = KApplication::desktop()->availableGeometry( screenNumber ).height(); - if( screenWidth < m_pixmap.width() || screenHeight < m_pixmap.height() ) - { - qreal zoomFactorX = qreal(screenWidth) / m_pixmap.width(); - qreal zoomFactorY = qreal(screenHeight) / m_pixmap.height(); - m_zoomFactor = qMin( zoomFactorX, zoomFactorY ) * 0.8; - } - setMinimumSize( m_pixmap.width() * m_zoomFactor, m_pixmap.height() * m_zoomFactor ); -} - -PixmapViewer::~PixmapViewer() -{ -} - -qreal -PixmapViewer::zoomFactor() const -{ - return m_zoomFactor; -} - -void -PixmapViewer::setZoomFactor( qreal f ) -{ - int w, h; - - if( f == m_zoomFactor ) - return; - - m_zoomFactor = f; - emit( zoomFactorChanged( m_zoomFactor ) ); - - w = m_pixmap.width() * m_zoomFactor; - h = m_pixmap.height() * m_zoomFactor; - setMinimumSize( w, h ); - - QWidget *p = dynamic_cast( parent() ); - if( p ) - resize( p->width(), p->height() ); -} - -void -PixmapViewer::paintEvent( QPaintEvent *event ) -{ - int xoffset, yoffset; - - if( width() > m_pixmap.width() * m_zoomFactor ) - { - xoffset = ( width() - m_pixmap.width() * m_zoomFactor ) / 2; - } - else - { - xoffset = 0; - } - - if( height() > m_pixmap.height() * m_zoomFactor ) - { - yoffset = ( height() - m_pixmap.height() * m_zoomFactor ) / 2; - } - else - { - yoffset = 0; - } - - QPainter p( this ); - p.save(); - p.translate( xoffset, yoffset ); - p.scale( m_zoomFactor, m_zoomFactor ); - p.drawPixmap( 0, 0, m_pixmap ); - p.restore(); - - event->accept(); -} - -void -PixmapViewer::wheelEvent( QWheelEvent *event ) -{ - qreal f = m_zoomFactor + 0.001 * event->delta(); - qreal ratio = 32.0 / m_pixmap.width(); - if( f < ratio ) - f = ratio; - setZoomFactor( f ); - event->accept(); -} - -#include "moc_PixmapViewer.cpp" diff --git a/amarok/src/widgets/PixmapViewer.h b/amarok/src/widgets/PixmapViewer.h deleted file mode 100644 index 81d7d4ca..00000000 --- a/amarok/src/widgets/PixmapViewer.h +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2005 Eyal Lotem * - * Copyright (c) 2007 Seb Ruiz * - * Copyright (c) 2009 Pascal Pollet * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef PIXMAPVIEWER_H -#define PIXMAPVIEWER_H - -#include -#include -#include -#include - -class QMouseEvent; -class QPixmap; - -class PixmapViewer : public QWidget -{ - Q_OBJECT - Q_PROPERTY( qreal zoomFactor READ zoomFactor WRITE setZoomFactor NOTIFY zoomFactorChanged ) - -public: - PixmapViewer( QWidget *parent, const QPixmap &pixmap, int screenNumber ); - virtual ~PixmapViewer(); - - qreal zoomFactor() const; - -public slots: - void setZoomFactor( qreal f ); - -signals: - void zoomFactorChanged( qreal ); - -protected: - void paintEvent( QPaintEvent *event ); - void wheelEvent( QWheelEvent *event ); - -private: - const QPixmap m_pixmap; - qreal m_zoomFactor; -}; - -#endif diff --git a/amarok/src/widgets/PlayPauseButton.cpp b/amarok/src/widgets/PlayPauseButton.cpp deleted file mode 100644 index 1bed497d..00000000 --- a/amarok/src/widgets/PlayPauseButton.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************************** -* Copyright (c) 2009 Thomas Luebking * -* * -* This program 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 2 of the License, or (at your option) any later * -* version. * -* * -* This program 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 * -* this program. If not, see . * -****************************************************************************************/ - -#include "PlayPauseButton.h" - -#include "SvgHandler.h" - -#include - -#include -#include - - -PlayPauseButton::PlayPauseButton( QWidget *parent ) : IconButton( parent ) - , m_isPlaying( false ) -{ - connect (this, SIGNAL(clicked()), this, SLOT(toggle()) ); - setToolTip( i18n( "Play" ) ); -} - -void PlayPauseButton::enterEvent( QEvent * ) -{ - setIcon( m_isPlaying ? m_icon.pause[1] : m_icon.play[1], 3 ); -} - -void PlayPauseButton::leaveEvent( QEvent * ) -{ - setIcon( m_isPlaying ? m_icon.pause[0] : m_icon.play[0], 6 ); -} - -void PlayPauseButton::mousePressEvent( QMouseEvent *me ) -{ - setIcon( m_isPlaying ? m_icon.pause[0] : m_icon.play[0] ); - IconButton::mousePressEvent( me ); -} - -void PlayPauseButton::toggle() -{ - emit toggled( !m_isPlaying ); -} - -void PlayPauseButton::reloadContent( const QSize &sz ) -{ - const int width = sz.width(); - const int height = sz.height(); - //NOTICE this is a bit cumbersome, as Qt renders faster to images than to pixmaps - // However we need the Image and generate the pixmap ourself - maybe extend the SvgHandler API - m_icon.play[0] = The::svgHandler()->renderSvg( "PLAYpause", width, height, "PLAYpause", true ).toImage(); - m_icon.play[1] = The::svgHandler()->renderSvg( "PLAYpause_active", width, height, "PLAYpause_active", true ).toImage(); - m_icon.pause[0] = The::svgHandler()->renderSvg( "playPAUSE", width, height, "playPAUSE", true ).toImage(); - m_icon.pause[1] = The::svgHandler()->renderSvg( "playPAUSE_active", width, height, "playPAUSE_active", true ).toImage(); - if( layoutDirection() == Qt::RightToLeft ) - { - for ( int i = 0; i < 2; ++i ) - { - m_icon.play[i] = m_icon.play[i].mirrored( true, false ); - m_icon.pause[i] = m_icon.pause[i].mirrored( true, false ); - } - } - setIcon( m_isPlaying ? m_icon.pause[underMouse()] : m_icon.play[underMouse()] ); -} - -void PlayPauseButton::setPlaying( bool playing ) -{ - if ( m_isPlaying == playing ) - return; - - setToolTip( playing ? i18n( "Pause" ) : i18n( "Play" ) ); - - m_isPlaying = playing; - setIcon( m_isPlaying ? m_icon.pause[underMouse()] : m_icon.play[underMouse()], 4 ); -} - -#include "moc_PlayPauseButton.cpp" diff --git a/amarok/src/widgets/PlayPauseButton.h b/amarok/src/widgets/PlayPauseButton.h deleted file mode 100644 index ffd393de..00000000 --- a/amarok/src/widgets/PlayPauseButton.h +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************************** -* Copyright (c) 2009 Thomas Luebking * -* * -* This program 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 2 of the License, or (at your option) any later * -* version. * -* * -* This program 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 * -* this program. If not, see . * -****************************************************************************************/ - -#ifndef PLAYPAUSEBUTTON_H -#define PLAYPAUSEBUTTON_H - -#include "IconButton.h" - -#include - -class PlayPauseButton : public IconButton -{ - Q_OBJECT - -public: - PlayPauseButton( QWidget *parent = 0 ); - inline bool playing() const { return m_isPlaying; } - void setPlaying( bool playing ); - -signals: - void toggled(bool playing); - -protected: - void enterEvent( QEvent * ); - void leaveEvent( QEvent * ); - void mousePressEvent( QMouseEvent * ); - void reloadContent( const QSize &sz ); - -private slots: - void toggle(); - -private: - bool m_isPlaying; - struct - { - QImage play[2], pause[2]; - } m_icon; -}; - - -#endif // end include guard diff --git a/amarok/src/widgets/PrettyTreeDelegate.cpp b/amarok/src/widgets/PrettyTreeDelegate.cpp deleted file mode 100644 index ebe90de5..00000000 --- a/amarok/src/widgets/PrettyTreeDelegate.cpp +++ /dev/null @@ -1,328 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * Copyright (c) 2008 Mark Kretschmann * - * Copyright (c) 2009 Seb Ruiz * - * Copyright (c) 2013 Ralf Engels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "PrettyTreeDelegate.h" - -#include "App.h" -#include "widgets/PrettyTreeRoles.h" -#include "widgets/PrettyTreeView.h" - -#include - -#include -#include -#include -#include -#include -#include -#include - -Q_DECLARE_METATYPE( QAction* ) -Q_DECLARE_METATYPE( QList ) - -#define CAPACITYRECT_MIN_HEIGHT 12 -#define CAPACITYRECT_MAX_HEIGHT 18 - -using namespace Amarok; - -/** - * A structure to hold some pixel metrics from style, to allow code sharing - */ -struct PixelSizes -{ - explicit PixelSizes( const QStyle *style ) - : verticalSpace( qMax( style->pixelMetric( QStyle::PM_LayoutVerticalSpacing ), 1 ) ) - , largeIconSize( style->pixelMetric( QStyle::PM_LargeIconSize ) ) - , expanderIconSize( style->pixelMetric( QStyle::PM_MenuButtonIndicator ) ) - , smallIconSize( style->pixelMetric( QStyle::PM_ListViewIconSize ) ) - , frameHMargin( style->pixelMetric( QStyle::PM_FocusFrameHMargin ) ) - , frameVMargin( style->pixelMetric( QStyle::PM_FocusFrameVMargin ) ) - , frameExtraMargin( largeIconSize / 4 ) // to give top items a little more space - , iconSpacing( style->pixelMetric( QStyle::PM_FocusFrameHMargin ) ) - {} - - const int verticalSpace; - const int largeIconSize; - const int expanderIconSize; - const int smallIconSize; - const int frameHMargin; - const int frameVMargin; - const int frameExtraMargin; - const int iconSpacing; -}; - -PrettyTreeDelegate::PrettyTreeDelegate( PrettyTreeView *view ) - : QStyledItemDelegate( view ) - , m_view( view ) - , m_normalFm( 0 ) - , m_bigFm( 0 ) - , m_smallFm( 0 ) -{ - Q_ASSERT( m_view ); -} - -PrettyTreeDelegate::~PrettyTreeDelegate() -{ - delete m_normalFm; - delete m_bigFm; - delete m_smallFm; -} - -void -PrettyTreeDelegate::paint( QPainter *painter, const QStyleOptionViewItem &option, - const QModelIndex &index ) const -{ - const bool hasCover = index.data( PrettyTreeRoles::HasCoverRole ).toBool(); - - if( hasCover || - index.parent().isValid() ) // not a root item - { - QStyledItemDelegate::paint( painter, option, index ); - return; - } - - updateFonts( option ); - QStyle *style = m_view->style(); - - PixelSizes s( style ); - const bool isRTL = QApplication::isRightToLeft(); - const bool hasCapacity = index.data( PrettyTreeRoles::HasCapacityRole ).toBool(); - const int actionCount = index.data( PrettyTreeRoles::DecoratorRoleCount ).toInt(); - - QRect remainingRect( option.rect ); - remainingRect.adjust( s.frameHMargin, s.frameVMargin + s.frameExtraMargin, - -s.frameHMargin, -s.frameVMargin - s.frameExtraMargin ); - - painter->save(); - style->drawPrimitive( QStyle::PE_PanelItemViewItem, &option, painter ); - - if ( option.state & QStyle::State_Selected ) - painter->setPen( App::instance()->palette().highlightedText().color() ); - else - painter->setPen( App::instance()->palette().text().color() ); - - painter->setRenderHint( QPainter::Antialiasing ); - - // -- the icon - const int iconYPadding = ( remainingRect.height() - s.largeIconSize ) / 2; - QPoint iconPos( remainingRect.topLeft() + QPoint( 0, iconYPadding ) ); - if( isRTL ) - iconPos.setX( remainingRect.right() - s.largeIconSize ); - - painter->drawPixmap( iconPos, - index.data( Qt::DecorationRole ).value().pixmap( s.largeIconSize, s.largeIconSize ) ); - - if( isRTL ) - remainingRect.adjust( 0, 0, - s.largeIconSize - s.iconSpacing, 0 ); - else - remainingRect.adjust( s.largeIconSize + s.iconSpacing, 0, 0, 0 ); - - // -- expander option (the small arrow) - QStyleOption expanderOption( option ); - expanderOption.rect = remainingRect; - QStyle::PrimitiveElement expandedPrimitive; - if( isRTL ) - { - expandedPrimitive = QStyle::PE_IndicatorArrowRight; - } - else - { - expandedPrimitive = QStyle::PE_IndicatorArrowLeft; - expanderOption.rect.setLeft( expanderOption.rect.right() - s.expanderIconSize ); - } - - expanderOption.rect.setWidth( s.expanderIconSize ); - if( m_view->model()->hasChildren( index ) ) - { - if( m_view->isExpanded( index ) ) - style->drawPrimitive( QStyle::PE_IndicatorArrowDown, &expanderOption, painter ); - else - style->drawPrimitive( expandedPrimitive, &expanderOption, painter ); - } - - // always subtract the expander size in order to align all the rest - if( isRTL ) - remainingRect.adjust( s.expanderIconSize + s.iconSpacing, 0, 0, 0 ); - else - remainingRect.adjust( 0, 0, - s.expanderIconSize - s.iconSpacing, 0 ); - - // -- title - QRect titleRect( remainingRect ); - titleRect.setHeight( qMax( m_bigFm->height(), s.smallIconSize ) + s.verticalSpace ); - - QString titleText = index.data( Qt::DisplayRole ).toString(); - titleText = m_bigFm->elidedText( titleText, Qt::ElideRight, titleRect.width() ); - - painter->setFont( m_bigFont ); - painter->drawText( titleRect, titleText ); - - const bool isHover = option.state & QStyle::State_MouseOver; - - // -- actions icons - if( isHover && ( actionCount > 0 ) ) - { - const QList actions = - index.data( PrettyTreeRoles::DecoratorRole ).value >(); - - /* The views that have models with action icons set mouse tracking to true, their - * mouseMoveEvent calls update() which triggers repaints if the mouse moves so - * that we always get updated mouse positions */ - QPoint cursorPos = m_view->viewport()->mapFromGlobal( QCursor::pos() ); - QAction *pressedDecoratorAction = m_view->pressedDecoratorAction(); - - for( int i = 0; i < actions.count(); i++ ) - { - QRect iconRect( decoratorRect( option.rect, i ) ); - QIcon::State state = ( actions.at( i ) == pressedDecoratorAction ) ? QIcon::On : QIcon::Off; - QIcon::Mode mode; - if( pressedDecoratorAction ) // if currently inside mouse press - { - mode = ( state == QIcon::On ) ? QIcon::Active : QIcon::Normal; - const int shrinkBy = iconRect.contains( cursorPos ) && state == QIcon::On - ? iconRect.width() / 16 : 0; - iconRect.adjust( shrinkBy, shrinkBy, -2 * shrinkBy, -2 * shrinkBy ); - } - else - mode = iconRect.contains( cursorPos ) ? QIcon::Active : QIcon::Normal; - actions[i]->icon().paint( painter, iconRect, Qt::AlignCenter, mode, state ); - } - } - - painter->setFont( m_smallFont ); // we want smaller font for both subtitle and capacity bar - //show the bylinetext or the capacity (if available) when hovering - if( isHover && hasCapacity ) - { - qreal bytesUsed = index.data( PrettyTreeRoles::UsedCapacityRole ).toReal(); - qreal bytesTotal = index.data( PrettyTreeRoles::TotalCapacityRole ).toReal(); - const int percentage = (bytesTotal > 0.0) ? qRound( 100.0 * bytesUsed / bytesTotal ) : 100; - - KCapacityBar capacityBar( KCapacityBar::DrawTextInline ); - capacityBar.setValue( percentage ); - capacityBar.setText( i18nc( "Example: 3.5 GB free (unit is part of %1)", "%1 free", - KGlobal::locale()->formatByteSize( bytesTotal - bytesUsed, 1 ) ) ); - - QRect capacityRect( remainingRect ); - capacityRect.setTop( titleRect.bottom() ); - capacityRect.setHeight( qBound( CAPACITYRECT_MIN_HEIGHT, - capacityBar.minimumSizeHint().height(), - qMin( CAPACITYRECT_MAX_HEIGHT, capacityRect.height() ) ) ); - - capacityBar.drawCapacityBar( painter, capacityRect ); - } - else - { - QRectF textRect( remainingRect ); - textRect.setTop( titleRect.bottom() ); - textRect.setHeight( remainingRect.height() - titleRect.height() ); - - QString byLineText = index.data( PrettyTreeRoles::ByLineRole ).toString(); - byLineText = m_smallFm->elidedText( byLineText, Qt::ElideRight, textRect.width() ); - - painter->drawText( textRect, byLineText ); - } - - painter->restore(); -} - -QSize -PrettyTreeDelegate::sizeHint( const QStyleOptionViewItem &option, - const QModelIndex &index ) const -{ - // note: the QStyledItemDelegage::sizeHint seems to be extremly slow. don't call it - - updateFonts( option ); - QStyle *style = m_view->style(); - - PixelSizes s( style ); - int viewportWidth = m_view->viewport()->width(); - int normalHeight = s.frameVMargin + qMax( s.smallIconSize, m_normalFm->height() ) + s.frameVMargin; - - const bool hasCover = index.data( PrettyTreeRoles::HasCoverRole ).toBool(); - - // -- determine if we have an album - if( hasCover ) - return QSize( viewportWidth, qMax( normalHeight, s.largeIconSize + s.frameVMargin * 2 ) ); - - // -- not top level. this is a normal item - if( index.parent().isValid() ) - return QSize( viewportWidth, normalHeight ); - - // -- ok, we have a top level item - const bool hasCapacity = index.data( PrettyTreeRoles::HasCapacityRole ).toBool(); - - QSize iconSize( s.largeIconSize, s.largeIconSize ); - QSize expanderSize( s.expanderIconSize, s.expanderIconSize ); - QSize titleSize( m_bigFm->boundingRect( index.data( Qt::DisplayRole ).toString() ).size() ); - QSize byLineSize( m_smallFm->boundingRect( index.data( PrettyTreeRoles::ByLineRole ).toString() ).size() ); - QSize capacitySize( hasCapacity ? 10 : 0, hasCapacity ? CAPACITYRECT_MIN_HEIGHT : 0 ); - - int layoutWidth = s.frameHMargin + - iconSize.width() + s.iconSpacing + - qMax( titleSize.width(), byLineSize.width() ) + expanderSize.width() + - s.frameHMargin; - - layoutWidth = qMax( viewportWidth, layoutWidth ); - - int layoutHeight = s.frameVMargin + s.frameExtraMargin + - qMax( titleSize.height(), s.smallIconSize ) + s.verticalSpace + - qMax( capacitySize.height(), byLineSize.height() ) + - s.frameExtraMargin + s.frameVMargin; - - return QSize( layoutWidth, layoutHeight ); -} - -QRect -PrettyTreeDelegate::decoratorRect( const QRect &itemRect, int nr ) const -{ - PixelSizes s( m_view->style() ); - const bool isRTL = QApplication::isRightToLeft(); - - int y = itemRect.top() + s.frameVMargin + s.frameExtraMargin; - int xOffset = s.frameHMargin + s.expanderIconSize + s.iconSpacing + ( s.smallIconSize + s.iconSpacing ) * nr; - int x; - - if( isRTL ) - x = itemRect.left() + xOffset; - else - x = itemRect.right() - xOffset - s.smallIconSize; - - return QRect( QPoint( x, y ), QSize( s.smallIconSize, s.smallIconSize ) ); -} - -void -PrettyTreeDelegate::updateFonts( const QStyleOptionViewItem &option ) const -{ - if( m_normalFm && m_bigFm && m_smallFm && option.font == m_originalFont ) - return; - - m_originalFont = option.font; - - delete m_normalFm; - m_normalFm = new QFontMetrics( m_originalFont ); - - m_bigFont = m_originalFont; - m_bigFont.setBold( true ); - delete m_bigFm; - m_bigFm = new QFontMetrics( m_bigFont ); - - m_smallFont = m_originalFont; - m_smallFont.setPointSize( m_smallFont.pointSize() - 1 ); - delete m_smallFm; - m_smallFm = new QFontMetrics( m_smallFont ); -} diff --git a/amarok/src/widgets/PrettyTreeDelegate.h b/amarok/src/widgets/PrettyTreeDelegate.h deleted file mode 100644 index 34f6c0bd..00000000 --- a/amarok/src/widgets/PrettyTreeDelegate.h +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Nikolaj Hald Nielsen * - * Copyright (c) 2008 Mark Kretschmann * - * Copyright (c) 2009 Seb Ruiz * - * Copyright (c) 2013 Ralf Engels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_PRETTY_TREE_DELEGATE_H -#define AMAROK_PRETTY_TREE_DELEGATE_H - -#include -#include -#include - -namespace Amarok { - class PrettyTreeView; -} -class QFontMetrics; - -/** A delegate used for the browser. - This delegate has the following specialities: - It will handle the hasCoverRole and will draw a bigger item for the cover. - It will handle the byLineRole and will draw an extra big item with a second - line of text - Also this big item will have an expander arrow if needed and capacities and - actions. -*/ -class PrettyTreeDelegate : public QStyledItemDelegate -{ - Q_OBJECT - - public: - PrettyTreeDelegate( Amarok::PrettyTreeView *view ); - ~PrettyTreeDelegate(); - - void paint( QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index ) const; - QSize sizeHint( const QStyleOptionViewItem &option, const QModelIndex &index ) const; - - /** Returns the rectangle where the action icon with the specific nr is located. */ - QRect decoratorRect( const QRect &itemRect, int nr ) const; - - private: - /** Verify and if needed update the buffered fonts and font metrics. */ - void updateFonts( const QStyleOptionViewItem &option ) const; - - Amarok::PrettyTreeView *m_view; - - mutable QFont m_originalFont; - mutable QFont m_bigFont; - mutable QFont m_smallFont; - - mutable QFontMetrics *m_normalFm; - mutable QFontMetrics *m_bigFm; - mutable QFontMetrics *m_smallFm; -}; - -#endif diff --git a/amarok/src/widgets/PrettyTreeRoles.h b/amarok/src/widgets/PrettyTreeRoles.h deleted file mode 100644 index 89eab0d6..00000000 --- a/amarok/src/widgets/PrettyTreeRoles.h +++ /dev/null @@ -1,48 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2013 Ralf Engels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_PRETTY_TREE_ROLES_H -#define AMAROK_PRETTY_TREE_ROLES_H - -namespace PrettyTreeRoles -{ - /** Roles used for the PrettyTreeDelegate and some models. - The numbers start at the strange index to reduce the possibility that - different roles from different models clash. - */ - enum CustomRolesId - { - SortRole = Qt::UserRole + 51, - FilterRole = Qt::UserRole + 52, - ByLineRole = Qt::UserRole + 53, - /** Boolean value whether given collection knows about used and total capacity */ - HasCapacityRole = Qt::UserRole + 54, - /** Number of bytes used by music and other files in collection (float) */ - UsedCapacityRole = Qt::UserRole + 55, - /** Total capacity of the collection in bytes (float) */ - TotalCapacityRole = Qt::UserRole + 56, - /** The number of collection actions */ - DecoratorRoleCount = Qt::UserRole + 57, - - /** The collection actions */ - DecoratorRole = Qt::UserRole + 58, - - /** True if the item has a cover that should be displayed */ - HasCoverRole = Qt::UserRole + 59 - }; -} - -#endif diff --git a/amarok/src/widgets/PrettyTreeView.cpp b/amarok/src/widgets/PrettyTreeView.cpp deleted file mode 100644 index fb4bcb38..00000000 --- a/amarok/src/widgets/PrettyTreeView.cpp +++ /dev/null @@ -1,261 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "PrettyTreeView.h" - -#include "PaletteHandler.h" -#include "SvgHandler.h" -#include "widgets/PrettyTreeRoles.h" -#include "widgets/PrettyTreeDelegate.h" - -#include - -#include -#include -#include -#include -#include - -Q_DECLARE_METATYPE( QAction* ) -Q_DECLARE_METATYPE( QList ) - -using namespace Amarok; - -PrettyTreeView::PrettyTreeView( QWidget *parent ) - : QTreeView( parent ) - , m_decoratorActionPressed( 0 ) -{ - setAlternatingRowColors( true ); - setFrameStyle( QFrame::StyledPanel | QFrame::Sunken ); - - The::paletteHandler()->updateItemView( this ); - connect( The::paletteHandler(), SIGNAL(newPalette(QPalette)), SLOT(newPalette(QPalette)) ); - -#ifdef Q_WS_MAC - // for some bizarre reason w/ some styles on mac per-pixel scrolling is slower than - // per-item - setVerticalScrollMode( QAbstractItemView::ScrollPerItem ); - setHorizontalScrollMode( QAbstractItemView::ScrollPerItem ); -#else - // Scrolling per item is really not smooth and looks terrible - setVerticalScrollMode( QAbstractItemView::ScrollPerPixel ); - setHorizontalScrollMode( QAbstractItemView::ScrollPerPixel ); -#endif - - setAnimated( KGlobalSettings::graphicEffectsLevel() != KGlobalSettings::NoEffects ); -} - -PrettyTreeView::~PrettyTreeView() -{ -} - -void -PrettyTreeView::edit( const QModelIndex &index ) -{ - QTreeView::edit( index ); -} - -bool -PrettyTreeView::edit( const QModelIndex &index, QAbstractItemView::EditTrigger trigger, QEvent *event ) -{ - QModelIndex parent = index.parent(); - while( parent.isValid() ) - { - expand( parent ); - parent = parent.parent(); - } - return QAbstractItemView::edit( index, trigger, event ); -} - -void -PrettyTreeView::drawRow( QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index ) const -{ - QTreeView::drawRow( painter, option, index ); - - const int width = option.rect.width(); - const int height = option.rect.height(); - - if( height > 0 ) - { - QPixmap background = The::svgHandler()->renderSvgWithDividers( - "service_list_item", width, height, "service_list_item" ); - - painter->save(); - painter->drawPixmap( option.rect.topLeft().x(), option.rect.topLeft().y(), background ); - painter->restore(); - } -} - -void -PrettyTreeView::mouseMoveEvent( QMouseEvent *event ) -{ - // swallow the mouse move event in case the press was started on decorator action icon - if( m_decoratorActionPressed ) - event->accept(); - else - QTreeView::mouseMoveEvent( event ); - - // Make sure we repaint the item for the collection action buttons - const QModelIndex index = indexAt( event->pos() ); - const int actionsCount = index.data( PrettyTreeRoles::DecoratorRoleCount ).toInt(); - if( actionsCount ) - update( index ); -} - -void -PrettyTreeView::mousePressEvent( QMouseEvent *event ) -{ - const QModelIndex index = indexAt( event->pos() ); - - // reset state variables on every mouse button press - m_expandCollapsePressedAt.reset(); - m_decoratorActionPressed = 0; - - // if root is decorated, it doesn't show any actions - QAction *action = rootIsDecorated() ? 0 : decoratorActionAt( index, event->pos() ); - if( action && - event->button() == Qt::LeftButton && - event->modifiers() == Qt::NoModifier && - state() == QTreeView::NoState ) - { - m_decoratorActionPressed = action; - update( index ); // trigger repaint to change icon effect - event->accept(); - return; - } - - bool prevExpandState = isExpanded( index ); - - // This will toggle the expansion of the current item when clicking - // on the fold marker but not on the item itself. Required here to - // enable dragging. - QTreeView::mousePressEvent( event ); - - // if we press left mouse button on valid item which did not cause the expansion, - // set m_expandCollapsePressedAt so that mouseReleaseEvent can perform the - // expansion/collapsing - if( index.isValid() && - prevExpandState == isExpanded( index ) && - event->button() == Qt::LeftButton && - event->modifiers() == Qt::NoModifier && - state() == QTreeView::NoState ) - { - m_expandCollapsePressedAt.reset( new QPoint( event->pos() ) ); - } -} - -void -PrettyTreeView::mouseReleaseEvent( QMouseEvent *event ) -{ - const QModelIndex index = indexAt( event->pos() ); - // we want to reset m_expandCollapsePressedAt in either case, but still need its value - QScopedPointer expandCollapsePressedAt( m_expandCollapsePressedAt.take() ); - // ditto for m_decoratorActionPressed - QAction *decoratorActionPressed = m_decoratorActionPressed; - m_decoratorActionPressed = 0; - - // if root is decorated, it doesn't show any actions - QAction *action = rootIsDecorated() ? 0 : decoratorActionAt( index, event->pos() ); - if( action && - action == decoratorActionPressed && - event->button() == Qt::LeftButton && - event->modifiers() == Qt::NoModifier ) - { - action->trigger(); - update( index ); // trigger repaint to change icon effect - event->accept(); - return; - } - - if( index.isValid() && - event->button() == Qt::LeftButton && - event->modifiers() == Qt::NoModifier && - state() == QTreeView::NoState && - expandCollapsePressedAt && - ( *expandCollapsePressedAt - event->pos() ).manhattanLength() < QApplication::startDragDistance() && - KGlobalSettings::singleClick() && - model()->hasChildren( index ) ) - { - setExpanded( index, !isExpanded( index ) ); - event->accept(); - return; - } - - QTreeView::mouseReleaseEvent( event ); -} - -bool -PrettyTreeView::viewportEvent( QEvent *event ) -{ - if( event->type() == QEvent::ToolTip ) - { - QHelpEvent *helpEvent = static_cast( event ); - const QModelIndex index = indexAt( helpEvent->pos() ); - // if root is decorated, it doesn't show any actions - QAction *action = rootIsDecorated() ? 0 : decoratorActionAt( index, helpEvent->pos() ); - if( action ) - { - QToolTip::showText( helpEvent->globalPos(), action->toolTip() ); - event->accept(); - return true; - } - } - - // swallow the mouse hover event in case the press was started on decorator action icon - // friend mouse move event is handled in mouseMoveEvent and triggers repaints - if( event->type() == QEvent::HoverMove && m_decoratorActionPressed ) - { - event->accept(); - return true; - } - - return QAbstractItemView::viewportEvent( event ); -} - -QAction * -PrettyTreeView::decoratorActionAt( const QModelIndex &index, const QPoint &pos ) -{ - const int actionsCount = index.data( PrettyTreeRoles::DecoratorRoleCount ).toInt(); - if( actionsCount <= 0 ) - return 0; - - PrettyTreeDelegate* ptd = qobject_cast( itemDelegate( index ) ); - if( !ptd ) - return 0; - - QList actions = index.data( PrettyTreeRoles::DecoratorRole ).value >(); - QRect rect = visualRect( index ); - - for( int i = 0; i < actions.count(); i++ ) - if( ptd->decoratorRect( rect, i ).contains( pos ) ) - return actions.at( i ); - - return 0; -} - -QAction * -PrettyTreeView::pressedDecoratorAction() const -{ - return m_decoratorActionPressed; -} - -void -PrettyTreeView::newPalette( const QPalette & palette ) -{ - Q_UNUSED( palette ) - The::paletteHandler()->updateItemView( this ); - reset(); // redraw all potential delegates -} diff --git a/amarok/src/widgets/PrettyTreeView.h b/amarok/src/widgets/PrettyTreeView.h deleted file mode 100644 index 853abc71..00000000 --- a/amarok/src/widgets/PrettyTreeView.h +++ /dev/null @@ -1,114 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_PRETTYTREEVIEW_H -#define AMAROK_PRETTYTREEVIEW_H - -#include "amarok_export.h" - -#include - -namespace Amarok -{ - /** - * A utility QTreeView subcass that handles: - * - drawing nice (svg themed) rows - * - palette changes - * - nicer expanding/collapsing interaction even when single click is used - * - decorator actions for root level items when isRootDecorated() is false - * - * If you use decorator actions, don't forget to set mouseTracking to true as - * PrettyTreeView doesn't do it automatically as it would be too costly for models - * that don't use the actions. - * - * @author: Nikolaj Hald Nielsen - */ - class AMAROK_EXPORT PrettyTreeView : public QTreeView - { - Q_OBJECT - - public: - PrettyTreeView( QWidget *parent = 0 ); - virtual ~PrettyTreeView(); - - public slots: - /* There is a need to overload even this edit() variant, otherwise it hides - * QAbstactItemView's implementation. Note that it is NOT safe to do anything - * special in this method, as it is not virtual. - * bool edit( const QModelIndex &index, EditTrigger trigger, QEvent *event ) - * IS virtual. */ - void edit( const QModelIndex &index ); - - /** - * Return pointer to decorator action which was most recently mouse-pressed - * or null it mouse buttom was released since then. Used by PrettyTreeDelegate. - */ - QAction *pressedDecoratorAction() const; - - protected: - bool edit( const QModelIndex &index, EditTrigger trigger, QEvent *event ); - void drawRow( QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index ) const; - - /** - * Reimplemented to trigger item redraw in case mouse is over an item which - * has decorator actions. - */ - void mouseMoveEvent( QMouseEvent *event ); - - /** - * Reimplemented to handle expanding with single-click mouse setting event - * when it is clicked outside the arrow and for consistency with - * mouseReleaseEvent() in case of decorator actions. - */ - void mousePressEvent( QMouseEvent *event ); - - /** - * Reimplemented to handle expanding with single-click mouse setting event - * when it is clicked outside the arrow and to handle clicking on decorator - * actions */ - void mouseReleaseEvent( QMouseEvent *event ); - - /** - * Reimplemented to show proper tooltips for decorator actions. - */ - bool viewportEvent( QEvent *event ); - - /** - * Get dectorator action (little action icon as seen for example in collection - * items in collection browser) of index @p idx under mouse position @p pos. - */ - QAction *decoratorActionAt( const QModelIndex &idx, const QPoint &pos ); - - private slots: - virtual void newPalette( const QPalette &palette ); - - private: - /** - * Position (relative to this widget) where the mouse button was pressed to - * trigger expand/collapse, or null pointer where expand/collapse shouldn't - * be handled in mouseReleaseEvent() - */ - QScopedPointer m_expandCollapsePressedAt; - - /** - * Pointer to decorator action which was pressed in mousePressEvent() or null - * pointer if no action was pressed in the most recent mouse press - */ - QAction *m_decoratorActionPressed; - }; -} - -#endif diff --git a/amarok/src/widgets/ProgressWidget.cpp b/amarok/src/widgets/ProgressWidget.cpp deleted file mode 100644 index f01130b0..00000000 --- a/amarok/src/widgets/ProgressWidget.cpp +++ /dev/null @@ -1,283 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Dan Meltzer * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "ProgressWidget.h" - -#include "amarokconfig.h" -#include "core/support/Debug.h" -#include "EngineController.h" -#include "SliderWidget.h" -#include "TimeLabel.h" -#include "amarokurls/AmarokUrl.h" -#include "amarokurls/AmarokUrlHandler.h" -#include "core/meta/Meta.h" -#include "core/meta/support/MetaUtility.h" -#include "core-impl/capabilities/timecode/TimecodeLoadCapability.h" - -#include - -#include -#include - -ProgressWidget::ProgressWidget( QWidget *parent ) - : QWidget( parent ) -{ - QHBoxLayout *box = new QHBoxLayout( this ); - setLayout( box ); - box->setMargin( 0 ); - box->setSpacing( 4 ); - - m_slider = new Amarok::TimeSlider( this ); - m_slider->setToolTip( i18n( "Track Progress" ) ); - m_slider->setMaximumSize( 600000, 20 ); - - m_timeLabelLeft = new TimeLabel( this ); - - m_timeLabelRight = new TimeLabel( this ); - m_timeLabelRight->setAlignment( Qt::AlignRight ); - - updateTimeLabelTooltips(); - - m_timeLabelLeft->setShowTime( false ); - m_timeLabelLeft->setAlignment( Qt::AlignRight ); - m_timeLabelRight->setShowTime( false ); - m_timeLabelRight->setAlignment( Qt::AlignLeft ); - m_timeLabelLeft->show(); - m_timeLabelRight->show(); - - box->addSpacing( 3 ); - box->addWidget( m_timeLabelLeft ); - box->addWidget( m_slider ); - box->addWidget( m_timeLabelRight ); - - EngineController *engine = The::engineController(); - - if( engine->isPaused() ) - paused(); - else if( engine->isPlaying() ) - trackPlaying(); - else - stopped(); - - connect( engine, SIGNAL(stopped(qint64,qint64)), - this, SLOT(stopped()) ); - connect( engine, SIGNAL(paused()), - this, SLOT(paused()) ); - connect( engine, SIGNAL(trackPlaying(Meta::TrackPtr)), - this, SLOT(trackPlaying()) ); - connect( engine, SIGNAL(trackLengthChanged(qint64)), - this, SLOT(trackLengthChanged(qint64)) ); - connect( engine, SIGNAL(trackPositionChanged(qint64,bool)), - this, SLOT(trackPositionChanged(qint64)) ); - - connect( m_slider, SIGNAL(sliderReleased(int)), - engine, SLOT(seekTo(int)) ); - - connect( m_slider, SIGNAL(valueChanged(int)), - SLOT(drawTimeDisplay(int)) ); - - setBackgroundRole( QPalette::BrightText ); - - connect ( The::amarokUrlHandler(), SIGNAL(timecodesUpdated(const QString*)), - this, SLOT(redrawBookmarks(const QString*)) ); - connect ( The::amarokUrlHandler(), SIGNAL(timecodeAdded(QString,int)), - this, SLOT(addBookmark(QString,int)) ); -} - -void -ProgressWidget::addBookmark( const QString &name, int milliSeconds ) -{ - addBookmark( name, milliSeconds, false ); -} - -void -ProgressWidget::addBookmark( const QString &name, int milliSeconds, bool showPopup ) -{ - DEBUG_BLOCK - if ( m_slider ) - m_slider->drawTriangle( name, milliSeconds, showPopup ); -} - -void -ProgressWidget::updateTimeLabelTooltips() -{ - TimeLabel *elapsedLabel = AmarokConfig::leftTimeDisplayRemaining() ? m_timeLabelRight : m_timeLabelLeft; - TimeLabel *remainingLabel = AmarokConfig::leftTimeDisplayRemaining() ? m_timeLabelLeft : m_timeLabelRight; - - elapsedLabel->setToolTip( i18n( "The amount of time elapsed in current track" ) ); - remainingLabel->setToolTip( i18n( "The amount of time remaining in current track" ) ); -} - -void -ProgressWidget::drawTimeDisplay( int ms ) //SLOT -{ - if ( !isVisible() ) - return; - - const qint64 trackLength = The::engineController()->trackLength(); - - //sometimes the engine gives negative position and track length values for streams - //which causes the time sliders to show 'interesting' values like -322:0-35:0-59 - int seconds = qMax(0, ms / 1000); - int remainingSeconds = qMax(0, int((trackLength - ms) / 1000)); - - QString sSeconds = Meta::secToPrettyTime( seconds ); - QString sRemainingSeconds = '-' + Meta::secToPrettyTime( remainingSeconds ); - - if( AmarokConfig::leftTimeDisplayRemaining() ) - { - m_timeLabelLeft->setText( sRemainingSeconds ); - m_timeLabelLeft->setEnabled( remainingSeconds > 0 ); - - m_timeLabelRight->setText( sSeconds ); - m_timeLabelRight->setEnabled( seconds > 0 ); - } - else - { - m_timeLabelRight->setText( sRemainingSeconds ); - m_timeLabelRight->setEnabled( remainingSeconds > 0 ); - - m_timeLabelLeft->setText( sSeconds ); - m_timeLabelLeft->setEnabled( seconds > 0 ); - } -} - -void -ProgressWidget::stopped() -{ - m_slider->setEnabled( false ); - m_slider->setMinimum( 0 ); //needed because setMaximum() calls with bogus values can change minValue - m_slider->setMaximum( 0 ); - m_timeLabelLeft->setEnabled( false ); - m_timeLabelLeft->setEnabled( false ); - m_timeLabelLeft->setShowTime( false ); - m_timeLabelRight->setShowTime( false ); - - m_currentUrlId.clear(); - m_slider->clearTriangles(); -} - -void -ProgressWidget::paused() -{ - // I am wondering, is there a way that the track can get paused - // directly? - m_timeLabelLeft->setEnabled( true ); - m_timeLabelRight->setEnabled( true ); -} - -void -ProgressWidget::trackPlaying() -{ - m_timeLabelLeft->setEnabled( true ); - m_timeLabelLeft->setEnabled( true ); - m_timeLabelLeft->setShowTime( true ); - m_timeLabelRight->setShowTime( true ); - - //in some cases (for streams mostly), we do not get an event for track length changes once - //loading is done, causing maximum() to return 0 at when playback starts. In this case we need - //to make sure that maximum is set correctly or the slider will not move. - trackLengthChanged( The::engineController()->trackLength() ); -} - -void -ProgressWidget::trackLengthChanged( qint64 milliseconds ) -{ - m_slider->setMinimum( 0 ); - m_slider->setMaximum( milliseconds ); - - const int timeLength = Meta::msToPrettyTime( milliseconds ).length() + 1; // account for - in remaining time - QFontMetrics tFm( m_timeLabelRight->font() ); - const int labelSize = tFm.width(QChar('0')) * timeLength; - - //set the sizes of the labesl to the max needed by the length of the track - //this way the progressbar will not change size during playback of a track - m_timeLabelRight->setFixedWidth( labelSize ); - m_timeLabelLeft->setFixedWidth( labelSize ); - - //get the urlid of the current track as the engine might stop and start several times - //when skipping lst.fm tracks, so we need to know if we are still on the same track... - if ( The::engineController()->currentTrack() ) - m_currentUrlId = The::engineController()->currentTrack()->uidUrl(); - - redrawBookmarks(); -} - -void -ProgressWidget::trackPositionChanged( qint64 position ) -{ - m_slider->setSliderValue( position ); - - // update the enabled state. Phonon determines isSeekable somtimes too late. - m_slider->setEnabled( (m_slider->maximum() > 0) && The::engineController()->isSeekable() ); - if ( !m_slider->isEnabled() ) - drawTimeDisplay( position ); -} - - -void -ProgressWidget::redrawBookmarks( const QString *BookmarkName ) -{ - DEBUG_BLOCK - m_slider->clearTriangles(); - if ( The::engineController()->currentTrack() ) - { - Meta::TrackPtr track = The::engineController()->currentTrack(); - if ( track->has() ) - { - Capabilities::TimecodeLoadCapability *tcl = track->create(); - BookmarkList list = tcl->loadTimecodes(); - debug() << "found " << list.count() << " timecodes on this track"; - foreach( AmarokUrlPtr url, list ) - { - if ( url->command() == "play" ) - { - - if ( url->args().keys().contains( "pos" ) ) - { - int pos = url->args().value( "pos" ).toDouble() * 1000; - debug() << "showing timecode: " << url->name() << " at " << pos ; - addBookmark( url->name(), pos, ( BookmarkName && BookmarkName == url->name() )); - } - } - } - delete tcl; - } - } -} - -void ProgressWidget::mousePressEvent(QMouseEvent* e) -{ - QWidget* widgetUnderCursor = childAt(e->pos()); - if( widgetUnderCursor == m_timeLabelLeft || - widgetUnderCursor == m_timeLabelRight ) - { - // user clicked on one of the time labels, switch display - AmarokConfig::setLeftTimeDisplayRemaining( !AmarokConfig::leftTimeDisplayRemaining() ); - drawTimeDisplay( The::engineController()->trackPositionMs() ); - updateTimeLabelTooltips(); - } - - QWidget::mousePressEvent(e); -} - -QSize ProgressWidget::sizeHint() const -{ - //int height = fontMetrics().boundingRect( "123456789:-" ).height(); - return QSize( width(), 12 ); -} - -#include "moc_ProgressWidget.cpp" diff --git a/amarok/src/widgets/ProgressWidget.h b/amarok/src/widgets/ProgressWidget.h deleted file mode 100644 index 42fb2153..00000000 --- a/amarok/src/widgets/ProgressWidget.h +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Dan Meltzer * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_PROGRESSWIDGET_H -#define AMAROK_PROGRESSWIDGET_H - -#include "core/meta/forward_declarations.h" - -#include - -#include -#include -#include -#include - -class TimeLabel; -namespace Amarok { class TimeSlider; } - -class ProgressWidget : public QWidget -{ - Q_OBJECT - - public: - ProgressWidget( QWidget* ); - - virtual QSize sizeHint() const; - void addBookmark( const QString &name, int milliSeconds , bool instantDisplayPopUp ); - Amarok::TimeSlider* slider() const { return m_slider; } - - public slots: - void drawTimeDisplay( int position ); - - protected slots: - void stopped(); - void paused(); - void trackPlaying(); - void trackLengthChanged( qint64 milliseconds ); - void trackPositionChanged( qint64 position ); - - protected: - virtual void mousePressEvent( QMouseEvent * ); - - private slots: - void addBookmark( const QString &name, int milliSeconds ); - void redrawBookmarks(const QString *BookmarkName = 0); - - private: - void updateTimeLabelTooltips(); - - TimeLabel *m_timeLabelLeft; - TimeLabel *m_timeLabelRight; - Amarok::TimeSlider *m_slider; - QString m_currentUrlId; -}; - -#endif - diff --git a/amarok/src/widgets/SearchWidget.cpp b/amarok/src/widgets/SearchWidget.cpp deleted file mode 100644 index 527c015e..00000000 --- a/amarok/src/widgets/SearchWidget.cpp +++ /dev/null @@ -1,286 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Dan Meltzer * - * Copyright (c) 2011 Sven Krohlas * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "SearchWidget.h" -#include "core/support/Debug.h" -#include "dialogs/EditFilterDialog.h" - -#include - -#include -#include -#include - -#include -#include -#include -#include - -#include - -SearchWidget::SearchWidget( QWidget *parent, bool advanced ) - : QWidget( parent ) - , m_sw( 0 ) - , m_filterAction( 0 ) - , m_timeout( 500 ) - , m_runningSearches( 0 ) -{ - setContentsMargins( 0, 0, 0, 0 ); - KHBox *searchBox = new KHBox( this ); - searchBox->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Fixed ); - - m_sw = new Amarok::ComboBox( searchBox ); - m_sw->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); - m_sw->setFrame( true ); - m_sw->setCompletionMode( KGlobalSettings::CompletionPopup ); - m_sw->completionObject()->setIgnoreCase( true ); - m_sw->setToolTip( i18n( "Enter space-separated terms to search." ) ); - m_sw->addItem( KStandardGuiItem::find().icon(), QString() ); - connect( m_sw, SIGNAL(activated(int)), SLOT(onComboItemActivated(int)) ); - connect( m_sw, SIGNAL(editTextChanged(QString)), SLOT(resetFilterTimeout()) ); - connect( m_sw, SIGNAL(returnPressed()), SLOT(filterNow()) ); // filterNow() calls addCompletion() - connect( m_sw, SIGNAL(returnPressed()), SIGNAL(returnPressed()) ); - connect( m_sw, SIGNAL(downPressed()), SLOT(advanceFocus()) ); - - QVBoxLayout *layout = new QVBoxLayout(); - layout->addWidget( searchBox ); - layout->setContentsMargins( 0, 0, 0, 0 ); - setLayout( layout ); - setClickMessage( i18n( "Enter search terms here" ) ); - - m_toolBar = new QToolBar( searchBox ); - m_toolBar->setFixedHeight( m_sw->sizeHint().height() ); - - if( advanced ) - { - m_filterAction = new QAction( KIcon( "document-properties" ), i18n( "Edit filter" ), this ); - m_filterAction->setObjectName( "filter" ); - m_toolBar->addAction( m_filterAction ); - - connect( m_filterAction, SIGNAL(triggered()), this, SLOT(slotShowFilterEditor()) ); - } - - m_filterTimer.setSingleShot( true ); - connect( &m_filterTimer, SIGNAL(timeout()), SLOT(filterNow()) ); - - m_animationTimer.setInterval( 500 ); - connect( &m_animationTimer, SIGNAL(timeout()), this, SLOT(nextAnimationTick()) ); -} - -void -SearchWidget::resetFilterTimeout() -{ - m_filterTimer.start( m_timeout ); -} - -void -SearchWidget::filterNow() -{ - m_filterTimer.stop(); - addCompletion( m_sw->currentText() ); - emit filterChanged( m_sw->currentText() ); -} - -void -SearchWidget::advanceFocus() -{ - focusNextChild(); -} - -void -SearchWidget::addCompletion( const QString &text ) -{ - int index = m_sw->findText( text ); - if( index == -1 ) - { - m_sw->addItem( KStandardGuiItem::find().icon(), text ); - m_sw->completionObject()->addItem( text ); - } - - index = m_sw->findText( text ); - m_sw->setCurrentIndex( index ); -} - -void -SearchWidget::onComboItemActivated( int index ) -{ - // if data of UserRole exists, use that as the actual filter string - const QString userFilter = m_sw->itemData( index ).toString(); - if( userFilter.isEmpty() ) - m_sw->setEditText( m_sw->itemText(index) ); - else - m_sw->setEditText( userFilter ); -} - -void -SearchWidget::slotShowFilterEditor() -{ - EditFilterDialog *fd = new EditFilterDialog( this, m_sw->currentText() ); - fd->setAttribute( Qt::WA_DeleteOnClose ); - m_filterAction->setEnabled( false ); - - connect( fd, SIGNAL(filterChanged(QString)), m_sw, SLOT(setEditText(QString)) ); - connect( fd, SIGNAL(finished(int)), this, SLOT(slotFilterEditorFinished(int)) ); - - fd->show(); -} - -void -SearchWidget::slotFilterEditorFinished( int result ) -{ - m_filterAction->setEnabled( true ); - - if( result && !m_sw->currentText().isEmpty() ) // result == QDialog::Accepted - addCompletion( m_sw->currentText() ); -} - -QToolBar * -SearchWidget::toolBar() -{ - return m_toolBar; -} - -void -SearchWidget::showAdvancedButton( bool show ) -{ - if( show ) - { - if( m_filterAction != 0 ) - { - m_filterAction = new QAction( KIcon( "document-properties" ), i18n( "Edit filter" ), this ); - m_filterAction->setObjectName( "filter" ); - m_toolBar->addAction( m_filterAction ); - connect( m_filterAction, SIGNAL(triggered()), this, SLOT(slotShowFilterEditor()) ); - } - } - else - { - delete m_filterAction; - m_filterAction = 0; - } -} - -void -SearchWidget::setClickMessage( const QString &message ) -{ - KLineEdit *edit = qobject_cast( m_sw->lineEdit() ); - edit->setClickMessage( message ); -} - -void -SearchWidget::setTimeout( quint16 newTimeout ) -{ - m_timeout = newTimeout; -} - -// public slots: - -void -SearchWidget::setSearchString( const QString &searchString ) -{ - if( searchString != currentText() ) { - m_sw->setEditText( searchString ); - filterNow(); - } -} - -void -SearchWidget::searchStarted() -{ - m_runningSearches++; - - // start the animation - if( !m_animationTimer.isActive() ) - { - m_sw->setItemIcon( m_sw->currentIndex(), QIcon( KStandardDirs::locate( "data", "amarok/images/loading1.png" ) ) ); - m_currentFrame = 0; - m_animationTimer.start(); - } - - // If another search is running it might still have a part of the animation set as its icon. - // As the currentIndex() has changed we don't know which one. We now have to iterate through - // all of them and set the icon correctly. It's not as bad as it sounds: the number is quite - // limited. - - for( int i = 0; i < m_sw->count(); i++ ) - { - if( i != m_sw->currentIndex() ) // not the current one, which should be animated! - m_sw->setItemIcon( i, KStandardGuiItem::find().icon() ); - } -} - -void -SearchWidget::searchEnded() -{ - if( m_runningSearches > 0 ) // just to be sure... - m_runningSearches--; - - // stop the animation - if( m_runningSearches == 0 ) - { - m_animationTimer.stop(); - saveLineEditStatus(); - m_sw->setItemIcon( m_sw->currentIndex(), KStandardGuiItem::find().icon() ); - restoreLineEditStatus(); - } -} - - -// private slots: - -void -SearchWidget::nextAnimationTick() -{ - saveLineEditStatus(); - - // switch frames - if( m_currentFrame == 0 ) - m_sw->setItemIcon( m_sw->currentIndex(), QIcon( KStandardDirs::locate( "data", "amarok/images/loading2.png" ) ) ); - else - m_sw->setItemIcon( m_sw->currentIndex(), QIcon( KStandardDirs::locate( "data", "amarok/images/loading1.png" ) ) ); - - restoreLineEditStatus(); - m_currentFrame = !m_currentFrame; -} - - -// private: - -void -SearchWidget::restoreLineEditStatus() -{ - // restore text changes made by the user - m_sw->setEditText( m_text ); - - if( m_hasSelectedText ) - m_sw->lineEdit()->setSelection( m_selectionStart, m_selectionLength ); // also sets cursor - else - m_sw->lineEdit()->setCursorPosition( m_cursorPosition ); -} - -void -SearchWidget::saveLineEditStatus() -{ - // save text changes made by the user - m_text = m_sw->lineEdit()->text(); - m_cursorPosition = m_sw->cursorPosition(); - m_hasSelectedText = m_sw->lineEdit()->hasSelectedText(); - m_selectionStart = m_sw->lineEdit()->selectionStart(); - m_selectionLength = m_sw->lineEdit()->selectedText().length(); -} - -#include "moc_SearchWidget.cpp" diff --git a/amarok/src/widgets/SearchWidget.h b/amarok/src/widgets/SearchWidget.h deleted file mode 100644 index 664d1381..00000000 --- a/amarok/src/widgets/SearchWidget.h +++ /dev/null @@ -1,135 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Dan Meltzer * - * Copyright (c) 2011 Sven Krohlas * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef SEARCHWIDGET_H -#define SEARCHWIDGET_H - -#include "amarok_export.h" -#include "ComboBox.h" - -#include -#include - -class QToolBar; -class KPushButton; -// A Custom Widget that can be used globally to implement -// searching a treeview. - -class AMAROK_EXPORT SearchWidget : public QWidget -{ - Q_OBJECT - public: - /** Creates a search widget. - @param advanced If true generates a button that opens a edit filter dialog. - */ - explicit SearchWidget( QWidget *parent, bool advanced = true ); - - QString currentText() const { return m_sw->currentText(); } - Amarok::ComboBox *comboBox() { return m_sw; } - - /** - * Sets the timout length after which the filterChanged() signal will be fired automatically. - * @param newTimeout timeout in milliseconds. - */ - void setTimeout( quint16 newTimeout ); - - QToolBar* toolBar(); - - void showAdvancedButton( bool show ); - - /** - * Sets the string that will be visible when the ComboBox's edit text is empty. - * @param message the string that will be visible when the ComboBox's edit text is empty. - */ - void setClickMessage( const QString &message ); - - public slots: - void setSearchString( const QString &searchString = QString() ); - - /** - * Tells the widget that a search operation has started. As a consequence the - * "search" icon changes to a progress animation. - * - * Note: You can call this slot several times if you ahve several search operations - * simultaneously. The widget has an internal counter to track them. - */ - void searchStarted(); - - /** - * Tells the widget that a search operation has ended. As a consequence the - * progress animation will be changed back to a search icon iff no other search - * operation is in progress. - */ - void searchEnded(); - - signals: - /** - * Emitted when the filter value was changed. - * Note: This signal might be delayed while the user is typing - */ - void filterChanged( const QString &filter ); - - /** - * Emitted when the user hits enter after after typing in the filter. It is - * guaranteed that filterChanged() with the current text was emitted previously. - */ - void returnPressed(); - - private slots: - void resetFilterTimeout(); - void filterNow(); - void advanceFocus(); - - void addCompletion( const QString &text ); - void nextAnimationTick(); - void onComboItemActivated( int index ); - void slotShowFilterEditor(); - void slotFilterEditorFinished( int result ); - - private: - Amarok::ComboBox *m_sw; - QAction *m_filterAction; - QToolBar *m_toolBar; - QTimer m_animationTimer; - QTimer m_filterTimer; - quint16 m_timeout; - bool m_currentFrame; - unsigned int m_runningSearches; - - // required to save/restore line edit status - QString m_text; - int m_cursorPosition; - bool m_hasSelectedText; - int m_selectionStart; - int m_selectionLength; - - /** - * Restore the status of the internal line edit (text, selection, cursor position). - * Crete a snapshot with saveLineEditStatus() before using this method. - * Required to keep user changes during animations. - */ - void restoreLineEditStatus(); - - /** - * Save the status of the internal line edit (text, selection, cursor position) to - * restore it later with restoreLineEditStatus(). - * Required to keep user changes during animations. - */ - void saveLineEditStatus(); -}; - -#endif diff --git a/amarok/src/widgets/SliderWidget.cpp b/amarok/src/widgets/SliderWidget.cpp deleted file mode 100644 index 3063d2f7..00000000 --- a/amarok/src/widgets/SliderWidget.cpp +++ /dev/null @@ -1,419 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2003-2009 Mark Kretschmann * - * Copyright (c) 2005 Gabor Lehel * - * Copyright (c) 2008 Dan Meltzer * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "SliderWidget.h" - -#include - -#include "core/support/Amarok.h" -#include "amarokurls/AmarokUrlHandler.h" -#include "amarokconfig.h" -#include "App.h" -#include "BookmarkTriangle.h" -#include "core/support/Debug.h" -#include "EngineController.h" -#include "core/meta/support/MetaUtility.h" -#include "SvgHandler.h" -#include "ProgressWidget.h" - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -Amarok::Slider::Slider( Qt::Orientation orientation, uint max, QWidget *parent ) - : QSlider( orientation, parent ) - , m_sliding( false ) - , m_outside( false ) - , m_prevValue( 0 ) - , m_needsResize( true ) -{ - setMouseTracking( true ); - setRange( 0, max ); - setAttribute( Qt::WA_NoMousePropagation, true ); - setAttribute( Qt::WA_Hover, true ); - if ( orientation == Qt::Vertical ) - { - setInvertedAppearance( true ); - setInvertedControls( true ); - } -} - -QRect -Amarok::Slider::sliderHandleRect( const QRect &slider, qreal percent ) const -{ - QRect rect; - const bool inverse = ( orientation() == Qt::Horizontal ) ? - ( invertedAppearance() != (layoutDirection() == Qt::RightToLeft) ) : - ( !invertedAppearance() ); - - if( m_usingCustomStyle) - rect = The::svgHandler()->sliderKnobRect( slider, percent, inverse ); - else - { - if ( inverse ) - percent = 1.0 - percent; - const int handleSize = style()->pixelMetric( QStyle::PM_SliderControlThickness ); - rect = QRect( 0, 0, handleSize, handleSize ); - rect.moveTo( slider.x() + qRound( ( slider.width() - handleSize ) * percent ), slider.y() + 1 ); - } - - return rect; -} - -void -Amarok::Slider::wheelEvent( QWheelEvent *e ) -{ - DEBUG_BLOCK - - if( orientation() == Qt::Vertical ) - { - // Will be handled by the parent widget - e->ignore(); - return; - } - - // Position Slider (horizontal) - // only used for progress slider now! - int step = e->delta() * 24; - int nval = value() + step; - nval = qMax(nval, minimum()); - nval = qMin(nval, maximum()); - - QSlider::setValue( nval ); - - emit sliderReleased( value() ); -} - -void -Amarok::Slider::mouseMoveEvent( QMouseEvent *e ) -{ - if ( m_sliding ) - { - //feels better, but using set value of 20 is bad of course - QRect rect( -20, -20, width()+40, height()+40 ); - - if ( orientation() == Qt::Horizontal && !rect.contains( e->pos() ) ) - { - if ( !m_outside ) - { - QSlider::setValue( m_prevValue ); - //if mouse released outside of slider, emit sliderMoved to previous value - emit sliderMoved( m_prevValue ); - } - m_outside = true; - } - else - { - m_outside = false; - slideEvent( e ); - emit sliderMoved( value() ); - } - } - else - QSlider::mouseMoveEvent( e ); -} - -void -Amarok::Slider::slideEvent( QMouseEvent *e ) -{ - QRect knob; - if ( maximum() > minimum() ) - knob = sliderHandleRect( rect(), ((qreal)value()) / ( maximum() - minimum() ) ); - - int position; - int span; - - if( orientation() == Qt::Horizontal ) - { - position = e->pos().x() - knob.width() / 2; - span = width() - knob.width(); - } - else - { - position = e->pos().y() - knob.height() / 2; - span = height() - knob.height(); - } - - const bool inverse = ( orientation() == Qt::Horizontal ) ? - ( invertedAppearance() != (layoutDirection() == Qt::RightToLeft) ) : - ( !invertedAppearance() ); - const int val = QStyle::sliderValueFromPosition( minimum(), maximum(), position, span, inverse ); - QSlider::setValue( val ); -} - -void -Amarok::Slider::mousePressEvent( QMouseEvent *e ) -{ - m_sliding = true; - m_prevValue = value(); - - QRect knob; - if ( maximum() > minimum() ) - knob = sliderHandleRect( rect(), ((qreal)value()) / ( maximum() - minimum() ) ); - if ( !knob.contains( e->pos() ) ) - mouseMoveEvent( e ); -} - -void -Amarok::Slider::mouseReleaseEvent( QMouseEvent* ) -{ - if( !m_outside && value() != m_prevValue ) - emit sliderReleased( value() ); - - m_sliding = false; - m_outside = false; -} - -void -Amarok::Slider::setValue( int newValue ) -{ - //don't adjust the slider while the user is dragging it! - if ( !m_sliding || m_outside ) - QSlider::setValue( newValue ); - else - m_prevValue = newValue; -} - -void Amarok::Slider::paintCustomSlider( QPainter *p, bool paintMoodbar ) -{ - qreal percent = 0.0; - if ( maximum() > minimum() ) - percent = ((qreal)value()) / ( maximum() - minimum() ); - QStyleOptionSlider opt; - initStyleOption( &opt ); - if ( m_sliding || - ( underMouse() && sliderHandleRect( rect(), percent ).contains( mapFromGlobal(QCursor::pos()) ) ) ) - { - opt.activeSubControls |= QStyle::SC_SliderHandle; - } - The::svgHandler()->paintCustomSlider( p, &opt, percent, paintMoodbar ); -} - - -////////////////////////////////////////////////////////////////////////////////////////// -/// CLASS VolumeSlider -////////////////////////////////////////////////////////////////////////////////////////// - -Amarok::VolumeSlider::VolumeSlider( uint max, QWidget *parent, bool customStyle ) - : Amarok::Slider( customStyle ? Qt::Horizontal : Qt::Vertical, max, parent ) -{ - m_usingCustomStyle = customStyle; - setFocusPolicy( Qt::NoFocus ); - setInvertedAppearance( false ); - setInvertedControls( false ); -} - -void -Amarok::VolumeSlider::mousePressEvent( QMouseEvent *e ) -{ - if( e->button() != Qt::RightButton ) - { - Amarok::Slider::mousePressEvent( e ); - slideEvent( e ); - } -} - -void -Amarok::VolumeSlider::contextMenuEvent( QContextMenuEvent *e ) -{ - QMenu menu; - menu.setTitle( i18n( "Volume" ) ); - menu.addAction( i18n( "100%" ) )->setData( 100 ); - menu.addAction( i18n( "80%" ) )->setData( 80 ); - menu.addAction( i18n( "60%" ) )->setData( 60 ); - menu.addAction( i18n( "40%" ) )->setData( 40 ); - menu.addAction( i18n( "20%" ) )->setData( 20 ); - menu.addAction( i18n( "0%" ) )->setData( 0 ); - - /* - // TODO: Phonon - menu.addSeparator(); - menu.addAction( KIcon( "view-media-equalizer-amarok" ), i18n( "&Equalizer" ), kapp, SLOT(slotConfigEqualizer()) )->setData( -1 ); - */ - - QAction* a = menu.exec( mapToGlobal( e->pos() ) ); - if( a ) - { - const int n = a->data().toInt(); - if( n >= 0 ) - { - QSlider::setValue( n ); - emit sliderReleased( n ); - } - } -} - -void -Amarok::VolumeSlider::wheelEvent( QWheelEvent *e ) -{ - const uint step = e->delta() / Amarok::VOLUME_SENSITIVITY; - QSlider::setValue( QSlider::value() + step ); - - emit sliderReleased( value() ); -} - -void -Amarok::VolumeSlider::paintEvent( QPaintEvent *event ) -{ - if( m_usingCustomStyle ) - { - QPainter p( this ); - paintCustomSlider( &p ); - p.end(); - return; - } - - QSlider::paintEvent( event ); -} - - -////////////////////////////////////////////////////////////////////////////////////////// -////////////////////////////////// TIMESLIDER //////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////////////////// - -Amarok::TimeSlider::TimeSlider( QWidget *parent ) - : Amarok::Slider( Qt::Horizontal, 0, parent ) - , m_triangles() - , m_knobX( 0.0 ) -{ - m_usingCustomStyle = true; - setFocusPolicy( Qt::NoFocus ); -} - -void -Amarok::TimeSlider::setSliderValue( int value ) -{ - Amarok::Slider::setValue( value ); -} - -void -Amarok::TimeSlider::paintEvent( QPaintEvent *pe ) -{ - QPainter p( this ); - p.setClipRegion( pe->region() ); - paintCustomSlider( &p, AmarokConfig::showMoodbarInSlider() ); - p.end(); - -} - -void Amarok::TimeSlider::resizeEvent(QResizeEvent * event) -{ - Amarok::Slider::resizeEvent( event ); - The::amarokUrlHandler()->updateTimecodes(); -} - -void Amarok::TimeSlider::sliderChange( SliderChange change ) -{ - if ( change == SliderValueChange || change == SliderRangeChange ) - { - int oldKnobX = m_knobX; - qreal percent = 0.0; - if ( maximum() > minimum() ) - percent = ((qreal)value()) / ( maximum() - minimum() ); - QRect knob = sliderHandleRect( rect(), percent ); - m_knobX = knob.x(); - - if (oldKnobX < m_knobX) - update( oldKnobX, knob.y(), knob.right() + 1 - oldKnobX, knob.height() ); - else if (oldKnobX > m_knobX) - update( m_knobX, knob.y(), oldKnobX + knob.width(), knob.height() ); - } - else - Amarok::Slider::sliderChange( change ); // calls update() -} - -void Amarok::TimeSlider::drawTriangle( const QString& name, int milliSeconds, bool showPopup ) -{ - DEBUG_BLOCK - int sliderHeight = height() - ( s_sliderInsertY * 2 ); - int sliderLeftWidth = sliderHeight / 3; - - // This mess converts the # of seconds into the pixel width value where the triangle should be drawn - int x_pos = ( ( ( double ) milliSeconds - ( double ) minimum() ) / ( maximum() - minimum() ) ) * ( width() - ( sliderLeftWidth + sliderLeftWidth + s_sliderInsertX * 2 ) ); - debug() << "drawing triangle at " << x_pos; - BookmarkTriangle * tri = new BookmarkTriangle( this, milliSeconds, name, width(), showPopup ); - connect( tri, SIGNAL(clicked(int)), SLOT(slotTriangleClicked(int)) ); - connect( tri, SIGNAL(focused(int)), SLOT(slotTriangleFocused(int)) ); - m_triangles << tri; - tri->setGeometry( x_pos + 6 /* to center the point */, 1 /*y*/, 11, 11 ); // 6 = hard coded border width - tri->show(); -} - -void Amarok::TimeSlider::slotTriangleClicked( int seconds ) -{ - emit sliderReleased( seconds ); -} - -void Amarok::TimeSlider::slotTriangleFocused( int seconds ) -{ - QList::iterator i; - for( i = m_triangles.begin(); i != m_triangles.end(); ++i ){ - if( (*i)->getTimeValue() != seconds ) - (*i)->hidePopup(); - } -} - -void Amarok::TimeSlider::clearTriangles() -{ - QList::iterator i; - for( i = m_triangles.begin(); i != m_triangles.end(); ++i ){ - (*i)->deleteLater(); - } - m_triangles.clear(); -} - -void Amarok::TimeSlider::mousePressEvent( QMouseEvent *event ) -{ - if( !The::engineController()->isSeekable() ) - return; // Eat the event,, it's not possible to seek - Amarok::Slider::mousePressEvent( event ); -} - -bool Amarok::TimeSlider::event( QEvent * event ) -{ - if( event->type() == QEvent::ToolTip ) - { - // Make a QHelpEvent out of this - QHelpEvent * helpEvent = dynamic_cast( event ); - if( helpEvent ) - { - - //figure out "percentage" of the track length that the mouse is hovering over the slider - qreal percentage = (qreal) helpEvent->x() / (qreal) width(); - long trackLength = The::engineController()->trackLength(); - int trackPosition = trackLength * percentage; - - // Update tooltip to show the track position under the cursor - setToolTip( i18nc( "Tooltip shown when the mouse is over the progress slider, representing the position in the currently playing track that Amarok will seek to if you click the mouse. Keep it concise.", "Jump to: %1", Meta::msToPrettyTime( trackPosition ) ) ); - } - } - - return QWidget::event( event ); -} - - -#include "moc_SliderWidget.cpp" diff --git a/amarok/src/widgets/SliderWidget.h b/amarok/src/widgets/SliderWidget.h deleted file mode 100644 index 6754731c..00000000 --- a/amarok/src/widgets/SliderWidget.h +++ /dev/null @@ -1,137 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2003-2009 Mark Kretschmann * - * Copyright (c) 2005 Gabor Lehel * - * Copyright (c) 2008 Dan Meltzer * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef SLIDERWIDGET_H -#define SLIDERWIDGET_H - -#include -#include -#include -#include - -class QPalette; -class QTimer; -class BookmarkTriangle; - - -namespace Amarok -{ - class Slider : public QSlider - { - Q_OBJECT - - public: - explicit Slider( Qt::Orientation, uint max = 0, QWidget* parent = 0 ); - - virtual void setValue( int ); - - signals: - //we emit this when the user has specifically changed the slider - //so connect to it if valueChanged() is too generic - //Qt also emits valueChanged( int ) - void sliderReleased( int ); - - protected: - virtual void wheelEvent( QWheelEvent* ); - virtual void mouseMoveEvent( QMouseEvent* ); - virtual void mouseReleaseEvent( QMouseEvent* ); - virtual void mousePressEvent( QMouseEvent* ); - virtual void slideEvent( QMouseEvent* ); - QRect sliderHandleRect( const QRect &slider, qreal percent ) const; - virtual void resizeEvent( QResizeEvent * ) { m_needsResize = true; } - - void paintCustomSlider( QPainter *p, bool paintMoodbar = false ); - - bool m_sliding; - bool m_usingCustomStyle; - - static const int s_borderWidth = 6; - static const int s_borderHeight = 6; - - static const int s_sliderInsertX = 5; - static const int s_sliderInsertY = 5; - - private: - - bool m_outside; - int m_prevValue; - bool m_needsResize; - - QPixmap m_topLeft; - QPixmap m_topRight; - QPixmap m_top; - QPixmap m_bottomRight; - QPixmap m_right; - QPixmap m_bottomLeft; - QPixmap m_bottom; - QPixmap m_left; - - Q_DISABLE_COPY( Slider ) - }; - - class VolumeSlider: public Slider - { - Q_OBJECT - - public: - explicit VolumeSlider( uint max, QWidget *parent, bool customStyle = true ); - - // VolumePopupButton needs to access this - virtual void wheelEvent( QWheelEvent *e ); - - protected: - virtual void paintEvent( QPaintEvent* ); - virtual void mousePressEvent( QMouseEvent* ); - virtual void contextMenuEvent( QContextMenuEvent* ); - - private: - Q_DISABLE_COPY( VolumeSlider ) - }; - - class TimeSlider : public Amarok::Slider - { - Q_OBJECT - - public: - TimeSlider( QWidget *parent ); - - void setSliderValue( int value ); - void drawTriangle( const QString &name, int milliSeconds, bool showPopup = false); - void clearTriangles(); - - protected: - virtual void paintEvent( QPaintEvent* ); - virtual void mousePressEvent( QMouseEvent* ); - virtual void resizeEvent( QResizeEvent * event ); - virtual void sliderChange( SliderChange change ); - virtual bool event( QEvent * event ); - - private slots: - void slotTriangleClicked( int ); - void slotTriangleFocused( int ); - - private: - Q_DISABLE_COPY( TimeSlider ) - - QList m_triangles; - int m_knobX; // The position of the current indicator. - }; -} - -#endif - diff --git a/amarok/src/widgets/StackedWidget.h b/amarok/src/widgets/StackedWidget.h deleted file mode 100644 index 1b19ad1f..00000000 --- a/amarok/src/widgets/StackedWidget.h +++ /dev/null @@ -1,46 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROKSTACKEDWIDGET_H -#define AMAROKSTACKEDWIDGET_H - -#include - -namespace Amarok { - -/** -A simple QStackedWidget subclass with transparent background - - @author Nikolaj Hald Nielsen -*/ -class StackedWidget : public QStackedWidget -{ -public: - StackedWidget( QWidget * parent = 0 ) - : QStackedWidget( parent ) {} - - ~StackedWidget( ) {} - -protected: - virtual void paintEvent( QPaintEvent * ) - { - } - -}; - -} - -#endif diff --git a/amarok/src/widgets/StarManager.cpp b/amarok/src/widgets/StarManager.cpp deleted file mode 100644 index 37de2a3c..00000000 --- a/amarok/src/widgets/StarManager.cpp +++ /dev/null @@ -1,168 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Jeff Mitchell * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "StarManager.h" - -#include "core/support/Amarok.h" -#include -#include "core/support/Debug.h" -#include "MainWindow.h" - -#include -#include //KGlobal::dirs() - -#include -#include - - -StarManager* StarManager::s_instance = 0; - -StarManager* StarManager::instance() -{ - return s_instance ? s_instance : new StarManager( The::mainWindow() ); -} - -StarManager::StarManager( QObject* parent ) - : QObject( parent ) -{ - DEBUG_BLOCK - - s_instance = this; - - /*if( AmarokConfig::customRatingsColors() ) - AmarokConfig::setCustomRatingsColors( false ); - m_colors[0] = AmarokConfig::starColorOne(); - m_colors[1] = AmarokConfig::starColorTwo(); - m_colors[2] = AmarokConfig::starColorThree(); - m_colors[3] = AmarokConfig::starColorFour(); - m_colors[4] = AmarokConfig::starColorFive(); - m_halfStarColor = AmarokConfig::starColorHalf();*/ - m_margin = 1; - m_height = 20; - reinitStars(); -} - -StarManager::~StarManager() -{ - DEBUG_BLOCK -} - -void -StarManager::reinitStars( int height, int margin ) -{ - if( height != -1 ) - m_height = height; - if( margin != -1 ) - m_margin = margin; - - int hval = m_height + m_margin * 2 - 4 + ( ( m_height % 2 ) ? 1 : 0 ); - QImage star = QImage( KStandardDirs::locate( "data", "amarok/images/star.png" ) ).scaled( hval, hval, Qt::IgnoreAspectRatio, Qt::SmoothTransformation ); - m_star = star.copy(); - m_starPix = QPixmap::fromImage( star ); - m_greyedStar = star.copy(); - KIconEffect::toGray( m_greyedStar, 1.0 ); - m_greyedStarPix = QPixmap::fromImage( m_greyedStar ); - QImage half = QImage( KStandardDirs::locate( "data", "amarok/images/smallstar.png" ) ).scaled( hval, hval, Qt::IgnoreAspectRatio, Qt::SmoothTransformation ); - m_halfStar = half.copy(); - /*if( AmarokConfig::customRatingsColors() ) - KIconEffect::colorize( m_halfStar, m_halfStarColor, 1.0 );*/ - m_halfStarPix = QPixmap::fromImage( m_halfStar ); - - QImage tempstar; - QImage temphalfstar; - for( int i = 0; i < 5; i++ ) - { - tempstar = star.copy(); - temphalfstar = half.copy(); - /*if( AmarokConfig::customRatingsColors() ) - { - KIconEffect::colorize( tempstar, m_colors[i], 1.0 ); - if( !AmarokConfig::fixedHalfStarColor() ) - KIconEffect::colorize( temphalfstar, m_colors[i], 1.0 ); - }*/ - m_images[i] = tempstar.copy(); - m_halfimages[i] = temphalfstar.copy(); - m_pixmaps[i] = QPixmap::fromImage( tempstar ); - m_halfpixmaps[i] = QPixmap::fromImage( temphalfstar ); - tempstar = QImage(); - temphalfstar = QImage(); - } - //TODO:PORT -// if( Playlist::instance() ) Playlist::instance()->qscrollview()->viewport()->update(); -/*PORT 2.0 - if( CollectionView::instance() && - CollectionView::instance()->viewMode() == CollectionView::modeFlatView ) - CollectionView::instance()->triggerUpdate(); */ - emit ratingsColorsChanged(); -} - -QPixmap* -StarManager::getStar( int num ) -{ - if( num < 1 || num > 5 ) - return &m_starPix; - else - return &m_pixmaps[num - 1]; -} - -QImage& -StarManager::getStarImage( int num ) -{ - if( num < 1 || num > 5 ) - return m_star; - else - return m_images[num - 1]; -} - -QPixmap* -StarManager::getHalfStar( int num ) -{ - /*if( AmarokConfig::fixedHalfStarColor() || num == -1 ) - return &m_halfStarPix; - else*/ - if( num < 1 || num > 5 ) - return &m_starPix; - else - return &m_halfpixmaps[num - 1]; -} - -QImage& -StarManager::getHalfStarImage( int num ) -{ - /*if( AmarokConfig::fixedHalfStarColor() || num == -1 ) - return m_halfStar; - else*/ - return m_halfimages[num - 1]; -} - -bool -StarManager::setColor( int starNum, const QColor &color ) -{ - if( starNum < 1 || starNum > 5 ) - return false; - m_colors[starNum - 1] = color; - return true; -} - -bool -StarManager::setHalfColor( const QColor &color ) -{ - m_halfStarColor = color; - return true; -} - -#include "moc_StarManager.cpp" - diff --git a/amarok/src/widgets/StarManager.h b/amarok/src/widgets/StarManager.h deleted file mode 100644 index 91a40d3a..00000000 --- a/amarok/src/widgets/StarManager.h +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Jeff Mitchell * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_STAR_MANAGER_H -#define AMAROK_STAR_MANAGER_H - -#include -#include - -/** - * TODO: only used in Osd.cpp, remove! We can paint stars using KRatingWidget - */ -class StarManager : public QObject -{ - Q_OBJECT - - public: - static StarManager *instance(); - - QPixmap* getStar( int num ); - QPixmap* getGreyStar() { return &m_greyedStarPix; } - QPixmap* getHalfStar( int num = -1 ); - QImage& getStarImage( int num ); - QImage& getGreyStarImage() { return m_greyedStar; } - QImage& getHalfStarImage( int num = -1 ); - - bool setColor( int starNum, const QColor &color ); - bool setHalfColor( const QColor &color ); - - void reinitStars( int height = -1, int margin = -1 ); - - signals: - void ratingsColorsChanged(); - - private: - StarManager( QObject* parent ); - ~StarManager(); - - static StarManager* s_instance; - - int m_height; - int m_margin; - - //cached stars...why both? For faster conversion when drawing context browser - QPixmap m_starPix; - QImage m_star; - QPixmap m_greyedStarPix; - QImage m_greyedStar; - QPixmap m_halfStarPix; - QImage m_halfStar; - - QImage m_images[5]; - QImage m_halfimages[5]; - QPixmap m_pixmaps[5]; - QPixmap m_halfpixmaps[5]; - - QColor m_colors[5]; - QColor m_halfStarColor; -}; - -#endif - diff --git a/amarok/src/widgets/TimeLabel.cpp b/amarok/src/widgets/TimeLabel.cpp deleted file mode 100644 index 2be74997..00000000 --- a/amarok/src/widgets/TimeLabel.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2005 Max Howell * - * Copyright (c) 2011 Kevin Funk * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - - -#include "TimeLabel.h" - -#include "amarokconfig.h" -#include "EngineController.h" - -#include -#include -#include - -#include -#include -#include - -TimeLabel::TimeLabel(QWidget* parent) - : QLabel( " 0:00:00 ", parent ) -{ - setFont( KGlobalSettings::fixedFont() ); - setSizePolicy( QSizePolicy::Maximum, QSizePolicy::Fixed ); -} - -QSize -TimeLabel::sizeHint() const -{ - return fontMetrics().boundingRect( KGlobal::locale()->negativeSign() + KGlobal::locale()->formatTime( QTime( 0, 0, 0 ), true, true ) ).size(); -} - -void -TimeLabel::setShowTime(bool showTime) { - m_showTime = showTime; - if( !showTime ) - { - QLabel::setText( "" ); - } -} - -bool TimeLabel::showTime() const -{ - return m_showTime; -} - -void -TimeLabel::setText(const QString& text) -{ - if( m_showTime ) - QLabel::setText( text ); -} - -#include "moc_TimeLabel.cpp" diff --git a/amarok/src/widgets/TimeLabel.h b/amarok/src/widgets/TimeLabel.h deleted file mode 100644 index f42daaf4..00000000 --- a/amarok/src/widgets/TimeLabel.h +++ /dev/null @@ -1,45 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2005 Max Howell * - * Copyright (c) 2011 Kevin Funk * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_TIMELABEL_H -#define AMAROK_TIMELABEL_H - -#include - -class QMouseEvent; - -class TimeLabel : public QLabel -{ - Q_OBJECT - -public: - explicit TimeLabel( QWidget *parent ); - - bool showTime() const; - void setShowTime( bool showTime ); - - // hide base-class function - void setText( const QString &text ); - -protected: - virtual QSize sizeHint() const; - -private: - bool m_showTime; -}; - -#endif /*AMAROK_TIMELABEL_H*/ diff --git a/amarok/src/widgets/Token.cpp b/amarok/src/widgets/Token.cpp deleted file mode 100644 index 1137fa0e..00000000 --- a/amarok/src/widgets/Token.cpp +++ /dev/null @@ -1,279 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Téo Mrnjavac * - * Copyright (c) 2008-2009 Seb Ruiz * - * Copyright (c) 2009 Roman Jarosz * - * Copyright (c) 2009 Daniel Dewald * - * Copyright (c) 2012 Ralf Engels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "Token.h" -#include "TokenDropTarget.h" - -#include - -#include -#include -#include - -#include -#include -#include -#include - - -Token* -TokenFactory::createToken(const QString & text, const QString & iconName, qint64 value, QWidget * parent) const -{ - return new Token( text, iconName, value, parent ); -} - -Token* -TokenFactory::createTokenFromMime( const QMimeData* mimeData, QWidget* parent ) const -{ - // decode the stream created in Token::mimeData - QByteArray itemData = mimeData->data( Token::mimeType() ); - QDataStream dataStream(&itemData, QIODevice::ReadOnly); - - QString tokenName; - QString tokenIconName; - qint64 tokenValue; - QColor tokenTextColor; - - dataStream >> tokenName; - dataStream >> tokenIconName; - dataStream >> tokenValue; - dataStream >> tokenTextColor; - - Token* token = createToken( tokenName, tokenIconName, tokenValue, parent ); - token->setTextColor( tokenTextColor ); - - return token; -} - - -Token::Token( const QString &name, const QString &iconName, qint64 value, QWidget *parent ) - : QWidget( parent ) - , m_name( name ) - , m_icon( KIcon( iconName ) ) - , m_iconName( iconName ) - , m_value( value ) - , m_customColor( false ) -{ - setFocusPolicy( Qt::StrongFocus ); - - // Note: We set all the margins because we need a quite small size. - // Vertically for the EditPlaylistLayoutDialog and horizontally for - // the OrganizeTracksDialog - - m_label = new QLabel( this ); - m_label->setAlignment( Qt::AlignCenter ); - m_label->setContentsMargins( 0, 0, 0, 0 ); - m_label->setMargin( 0 ); - m_label->setText( name ); - - m_iconContainer = new QLabel( this ); - m_iconContainer->setContentsMargins( 0, 0, 0, 0 ); - m_iconContainer->setMargin( 0 ); - QPixmap pixmap = QPixmap( icon().pixmap( 16, 16 ) ); - m_iconContainer->setPixmap( pixmap ); - - QHBoxLayout *hlayout = new QHBoxLayout( this ); - hlayout->setSpacing( 3 ); - hlayout->setContentsMargins( 3, 0, 3, 0 ); // to allow the label to overwrite the border if space get's tight - hlayout->addWidget( m_iconContainer ); - hlayout->addWidget( m_label ); - setLayout( hlayout ); - - updateCursor(); -} - -QString -Token::name() const -{ - return m_name; -} - -qint64 -Token::value() const -{ - return m_value; -} - -KIcon -Token::icon() const -{ - return m_icon; -} - -QString Token::iconName() const -{ - return m_iconName; -} - -QColor Token::textColor() const -{ - return m_label->palette().color( QPalette::WindowText ); -} - -void -Token::setTextColor( QColor textColor ) -{ - m_customColor = true; - if( textColor == this->textColor() ) - return; - QPalette myPalette( m_label->palette() ); - myPalette.setColor( QPalette::WindowText, textColor ); - m_label->setPalette( myPalette ); -} - -QMimeData* -Token::mimeData() const -{ - QByteArray itemData; - - QDataStream dataStream( &itemData, QIODevice::WriteOnly ); - dataStream << name() << iconName() << value() << textColor(); - - QMimeData *mimeData = new QMimeData; - mimeData->setData( mimeType(), itemData ); - - return mimeData; -} - -QString -Token::mimeType() -{ - return QLatin1String( "application/x-amarok-tag-token" ); -} - -QSize -Token::sizeHint() const -{ - QSize result = QWidget::sizeHint(); - result += QSize( 6, 6 ); // the border - - return result; -} - -QSize -Token::minimumSizeHint() const -{ - QSize result = QWidget::minimumSizeHint(); - - return result; -} - -void -Token::changeEvent( QEvent *event ) -{ - QWidget::changeEvent( event ); - if( !event || event->type() == QEvent::EnabledChange ) - updateCursor(); -} - -void -Token::focusInEvent( QFocusEvent* event ) -{ - QWidget::focusInEvent( event ); - emit gotFocus( this ); -} - -void -Token::updateCursor() -{ - if( isEnabled() ) - setCursor( Qt::OpenHandCursor ); - else - unsetCursor(); -} - -void -Token::mousePressEvent( QMouseEvent* event ) -{ - if( event->button() == Qt::LeftButton ) - m_startPos = event->pos(); //store the start position - QWidget::mousePressEvent( event ); //feed it to parent's event -} - -void -Token::mouseMoveEvent( QMouseEvent* event ) -{ - if( isEnabled() && - event->buttons() & Qt::LeftButton ) - { - int distance = ( event->pos() - m_startPos ).manhattanLength(); - if ( distance >= KApplication::startDragDistance() ) - performDrag(); - } - QWidget::mouseMoveEvent( event ); -} - -//Handles the creation of a QDrag object that carries the (text-only) QDataStream from an item in TokenPool -void -Token::performDrag() -{ - bool stacked = parentWidget() && qobject_cast( parentWidget() ); // true if token originated from a TokenDropTarget. - if( stacked ) - hide(); - - Token *token = this; - - QDrag *drag = new QDrag( this ); - drag->setMimeData( mimeData() ); - - // icon for pointer - QPixmap pixmap( token->size() ); - token->render( &pixmap ); - drag->setPixmap( pixmap ); - drag->setHotSpot ( pixmap.rect().center() ); - - Qt::DropAction dropAction = drag->exec( Qt::MoveAction | Qt::CopyAction, Qt::CopyAction ); - - if( dropAction != Qt::MoveAction && dropAction != Qt::CopyAction ) // dragged out and not just dragged to another position. - { - // TODO: nice poof animation? ;-) - token->deleteLater(); - } - -} - -void Token::paintEvent(QPaintEvent *pe) -{ - Q_UNUSED( pe ) - - QPainter p( this ); - p.setBrush( Qt::NoBrush ); - p.setRenderHint( QPainter::Antialiasing ); - QColor c; - if( isEnabled() && hasFocus() ) - { - c = palette().color( QPalette::Highlight ); - } - else if( isEnabled() ) - { - c = palette().color( foregroundRole() ); - c.setAlpha( c.alpha() * 0.5 ); - } - else - { - c = palette().color( foregroundRole() ); - c.setAlpha( c.alpha() * 0.3 ); - } - p.setPen( QPen( c, 2 ) ); - p.drawRoundedRect( rect().adjusted(1,1,-1,-1), 4, 4 ); - p.end(); -} - - diff --git a/amarok/src/widgets/Token.h b/amarok/src/widgets/Token.h deleted file mode 100644 index 1cc96fa3..00000000 --- a/amarok/src/widgets/Token.h +++ /dev/null @@ -1,117 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Téo Mrnjavac * - * Copyright (c) 2008-2009 Seb Ruiz * - * Copyright (c) 2009 Daniel Dewald * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_TOKEN_H -#define AMAROK_TOKEN_H - -#include -#include -#include -#include - -class Token; -class QMimeData; - -/** The token factory is used by the TokenDropTarget to create suitable Token objects. - The TokenWithLayout class has it's own TokenFactory to be used with the EditFilterDialog. -*/ -class TokenFactory -{ - -public: - virtual ~TokenFactory() {} - virtual Token* createToken( const QString &text, const QString &iconName, qint64 value, QWidget* parent = 0 ) const; - virtual Token* createTokenFromMime( const QMimeData* mimeData, QWidget* parent = 0 ) const; -}; - -/** A widget that is used in the FilenameLayoutWidget to display part of a filename - It is drag&droppable in the TokenDropTarget from the TokenPool widget. - - Note: A disabled token cannot be dragged. See setEnabled(). -*/ -class Token : public QWidget -{ - Q_OBJECT - - public: - - explicit Token( const QString &text, const QString &iconName, qint64 value, QWidget *parent = 0 ); - - KIcon icon() const; - QString iconName() const; - QString name() const; - qint64 value() const; - - QColor textColor() const; - void setTextColor( QColor textColor ); - - /** Return true if somebody has previously set the text color */ - bool hasCustomColor() const { return m_customColor; }; - - /** Returns the mime data for this token. - Caller has to free the QMimeData object. - */ - QMimeData* mimeData() const; - - /** Returns the mime type for an amarok tag token */ - static QString mimeType(); - - QSize sizeHint() const; - QSize minimumSizeHint() const; - - signals: - void changed(); - - /** Emitted when the token get's the focus */ - void gotFocus( Token* thisToken ); - - protected: - /** overloaded to update the cursor in case the token is set to inactive */ - void changeEvent( QEvent* event = 0 ); - - void focusInEvent( QFocusEvent* event ); - - void updateCursor(); - - /** Handles start of drag. */ - void mousePressEvent( QMouseEvent* event ); - - /** Handles start of drag. */ - void mouseMoveEvent( QMouseEvent* event ); - - void paintEvent(QPaintEvent *pe); - - void performDrag(); - - protected: - QString m_name; - KIcon m_icon; - QString m_iconName; - qint64 m_value; // TODO: make this more typesave - bool m_customColor; - - QLabel *m_iconContainer; - QLabel *m_label; - - /** Position of the mouse press event - (used for drag and drop) */ - QPoint m_startPos; -}; - -#endif // AMAROK_TOKEN_H - diff --git a/amarok/src/widgets/TokenDropTarget.cpp b/amarok/src/widgets/TokenDropTarget.cpp deleted file mode 100644 index 715cf834..00000000 --- a/amarok/src/widgets/TokenDropTarget.cpp +++ /dev/null @@ -1,392 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Thomas Lbking * - * Copyright (c) 2012 Ralf Engels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "TokenDropTarget.h" - -#include "Token.h" -#include "TokenPool.h" -#include "core/support/Debug.h" - -#include - -#include -#include -#include - - -TokenDropTarget::TokenDropTarget( QWidget *parent ) - : QWidget( parent ) - , m_rowLimit( 0 ) - , m_rows( 0 ) - , m_horizontalStretch( false ) // DANGER: m_horizontalStretch is used as int in the following code, assuming that true == 1 - , m_verticalStretch( true ) - , m_tokenFactory( new TokenFactory() ) -{ - setAcceptDrops( true ); - - QBoxLayout* mainLayout = new QVBoxLayout( this ); - mainLayout->setSpacing( 0 ); - mainLayout->addStretch( 1 ); // the vertical stretch - - mainLayout->setContentsMargins( 0, 0, 0, 0 ); -} - -TokenDropTarget::~TokenDropTarget() -{ - delete m_tokenFactory; -} - -QSize -TokenDropTarget::sizeHint() const -{ - QSize result = QWidget::sizeHint(); - - // we need at least space for the "empty" text. - int h = fontMetrics().height(); - result = result.expandedTo( QSize( 36 * h, 2 * h ) ); - - return result; -} - -QSize -TokenDropTarget::minimumSizeHint() const -{ - QSize result = QWidget::minimumSizeHint(); - - // we need at least space for the "empty" text. - int h = fontMetrics().height(); - result = result.expandedTo( QSize( 36 * h, 2 * h ) ); - - return result; -} - - -QHBoxLayout * -TokenDropTarget::appendRow() -{ - QHBoxLayout *box = new QHBoxLayout; - box->setSpacing( 0 ); - if( m_horizontalStretch ) - box->addStretch(); - static_cast(layout())->insertLayout( rows(), box ); - m_rows++; - return box; -} - -void -TokenDropTarget::clear() -{ - QList< Token *> allTokens = tokensAtRow(); - foreach( Token* token, allTokens ) - delete token; -} - -int -TokenDropTarget::count() const -{ - int c = 0; - for( int row = rows() - 1; row >= 0; --row ) - if( QBoxLayout *box = qobject_cast( layout()->itemAt( row )->layout() ) ) - c += box->count() - m_horizontalStretch; - - return c; -} - -void -TokenDropTarget::setRowLimit( uint r ) -{ - // if we have more than one row we have a stretch at the end. - QBoxLayout *mainLayout = qobject_cast( layout() ); - if( ( r == 1 ) && (m_rowLimit != 1 ) ) - mainLayout->takeAt( mainLayout->count() - 1 ); - else if( ( r != 1 ) && (m_rowLimit == 1 ) ) - mainLayout->addStretch( 1 ); // the vertical stretch - - m_rowLimit = r; -} - -void -TokenDropTarget::deleteEmptyRows() -{ - DEBUG_BLOCK; - - for( int row = rows() - 1; row >= 0; --row ) - { - QBoxLayout *box = qobject_cast( layout()->itemAt( row )->layout() ); - if( box && box->count() < ( 1 + m_horizontalStretch ) ) // sic! last is spacer - { - delete layout()->takeAt( row ); - m_rows--; - } - } - update(); // this removes empty layouts somehow for deleted tokens. don't remove -} - -QList< Token *> -TokenDropTarget::tokensAtRow( int row ) -{ - DEBUG_BLOCK; - - int lower = 0; - int upper = (int)rows(); - if( row > -1 && row < (int)rows() ) - { - lower = row; - upper = row + 1; - } - - QList< Token *> list; - Token *token; - for( row = lower; row < upper; ++row ) - if ( QHBoxLayout *rowBox = qobject_cast( layout()->itemAt( row )->layout() ) ) - { - for( int col = 0; col < rowBox->count() - m_horizontalStretch; ++col ) - if ( ( token = qobject_cast( rowBox->itemAt( col )->widget() ) ) ) - list << token; - } - - debug() << "Row:"<(token->parent() ) ) { - debug() << "Copying token" << token->name(); - token = m_tokenFactory->createToken( token->name(), - token->iconName(), - token->value() ); - } - - token->setParent( this ); - - // - validate row - if ( row < 0 && rowLimit() && rows() >= rowLimit() ) - row = rowLimit() - 1; // want to append, but we can't so use the last row instead - - QBoxLayout *box; - if( row < 0 || row >= (int)rows() ) - box = appendRow(); - else - box = qobject_cast( layout()->itemAt( row )->layout() ); - - // - validate col - if( col < 0 || col > box->count() - ( 1 + m_horizontalStretch ) ) - col = box->count() - m_horizontalStretch; - - // - copy the token if it belongs to a token pool (fix BR 296136) - if( qobject_cast(token->parent() ) ) { - debug() << "Copying token" << token->name(); - token = m_tokenFactory->createToken( token->name(), - token->iconName(), - token->value() ); - } - - box->insertWidget( col, token ); - token->show(); - - connect( token, SIGNAL(changed()), this, SIGNAL(changed()) ); - connect( token, SIGNAL(gotFocus(Token*)), this, SIGNAL(tokenSelected(Token*)) ); - connect( token, SIGNAL(destroyed(QObject*)), this, SIGNAL(changed()) ); - connect( token, SIGNAL(destroyed(QObject*)), this, SLOT(deleteEmptyRows()) ); - - emit changed(); -} - - -Token* -TokenDropTarget::tokenAt( const QPoint &pos ) const -{ - for( uint row = 0; row < rows(); ++row ) - if( QBoxLayout *rowBox = qobject_cast( layout()->itemAt( row )->layout() ) ) - for( int col = 0; col < rowBox->count(); ++col ) - if( QWidget *kid = rowBox->itemAt( col )->widget() ) - { - if( kid->geometry().contains( pos ) ) - return qobject_cast(kid); - } - return 0; -} - -void -TokenDropTarget::drop( Token *token, const QPoint &pos ) -{ - DEBUG_BLOCK; - - if ( !token ) - return; - - // find the token at the position. - QWidget *child = childAt( pos ); - Token *targetToken = qobject_cast(child); // tokenAt( pos ); - if( !targetToken && child && child->parent() ) // sometimes we get the label of the token. - targetToken = qobject_cast( child->parent() ); - - // unlayout in case of move - if( QBoxLayout *box = rowBox( token ) ) - { - box->removeWidget( token ); - deleteEmptyRows(); // a row could now be empty due to a move - } - - if( targetToken ) - { // we hit a sibling, -> prepend - QPoint idx; - rowBox( targetToken, &idx ); - - if( rowLimit() != 1 && rowLimit() < m_rows && idx.y() == (int)m_rows - 1 && - pos.y() > targetToken->geometry().y() + ( targetToken->height() * 2 / 3 ) ) - insertToken( token, idx.y() + 1, idx.x()); - else if( pos.x() > targetToken->geometry().x() + targetToken->width() / 2 ) - insertToken( token, idx.y(), idx.x() + 1); - else - insertToken( token, idx.y(), idx.x() ); - } - else - { - insertToken( token ); - } - - token->setFocus( Qt::OtherFocusReason ); // select the new token right away -} - -void -TokenDropTarget::dragEnterEvent( QDragEnterEvent *event ) -{ - if( event->mimeData()->hasFormat( Token::mimeType() ) ) - event->acceptProposedAction(); -} - -void -TokenDropTarget::dropEvent( QDropEvent *event ) -{ - if( event->mimeData()->hasFormat( Token::mimeType() ) ) - { - event->acceptProposedAction(); - - Token *token = qobject_cast( event->source() ); - - if ( !token ) // decode the stream created in TokenPool::dropEvent - token = m_tokenFactory->createTokenFromMime( event->mimeData(), this ); - - // - copy the token if it belongs to a token pool (fix BR 296136) - if( qobject_cast(token->parent() ) ) { - token = m_tokenFactory->createToken( token->name(), - token->iconName(), - token->value() ); - } - - if( token ) - drop( token, event->pos() ); - } -} - -void -TokenDropTarget::paintEvent(QPaintEvent *pe) -{ - QWidget::paintEvent(pe); - if (count()) - return; - QPainter p(this); - QColor c = palette().color(foregroundRole()); - c.setAlpha(c.alpha()*64/255); - p.setPen(c); - p.drawText(rect(), Qt::AlignCenter | Qt::TextWordWrap, i18n("Drag in and out items from above.")); - p.end(); -} - -int -TokenDropTarget::row( Token *token ) const -{ - for( uint row = 0; row <= rows(); ++row ) - { - QBoxLayout *box = qobject_cast( layout()->itemAt( row )->layout() ); - if ( box && ( box->indexOf( token ) ) > -1 ) - return row; - } - return -1; -} - -QBoxLayout * -TokenDropTarget::rowBox( QWidget *w, QPoint *idx ) const -{ - QBoxLayout *box = 0; - int col; - for( uint row = 0; row < rows(); ++row ) - { - box = qobject_cast( layout()->itemAt( row )->layout() ); - if ( box && ( col = box->indexOf( w ) ) > -1 ) - { - if ( idx ) - { - idx->setX( col ); - idx->setY( row ); - } - return box; - } - } - return NULL; -} - -QBoxLayout * -TokenDropTarget::rowBox( const QPoint &pt ) const -{ - QBoxLayout *box = 0; - for( uint row = 0; row < rows(); ++row ) - { - box = qobject_cast( layout()->itemAt( row )->layout() ); - if ( !box ) - continue; - for ( int col = 0; col < box->count(); ++col ) - { - if ( QWidget *w = box->itemAt( col )->widget() ) - { - const QRect &geo = w->geometry(); - if ( geo.y() <= pt.y() && geo.bottom() >= pt.y() ) - return box; - break; // yes - all widgets are supposed of equal height. we checked on, we checked all - } - } - } - return NULL; -} - -void -TokenDropTarget::setCustomTokenFactory( TokenFactory * factory ) -{ - delete m_tokenFactory; - m_tokenFactory = factory; -} - -void -TokenDropTarget::setVerticalStretch( bool value ) -{ - if( value == m_verticalStretch ) - return; - - m_verticalStretch = value; - - if( m_verticalStretch ) - qobject_cast( layout() )->addStretch( 1 ); - else - delete layout()->takeAt( layout()->count() - 1 ); -} - - diff --git a/amarok/src/widgets/TokenDropTarget.h b/amarok/src/widgets/TokenDropTarget.h deleted file mode 100644 index 3b7f9b32..00000000 --- a/amarok/src/widgets/TokenDropTarget.h +++ /dev/null @@ -1,135 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Thomas Lbking * - * Copyright (c) 2012 Ralf Engels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef TOKENDROPTARGET_H -#define TOKENDROPTARGET_H - -#include - -class QBoxLayout; -class QHBoxLayout; -class QDropEvent; -class Token; -class TokenDragger; -class TokenFactory; - -/** A widget that accepts dragging Tokens into it. - Used in several dialogs within Amarok e.g. the FilenameLayoutWidget and the - LayoutEditWidget. - - The DropTarget can have one or more rows, limited by the rowLimit. -*/ -class TokenDropTarget : public QWidget -{ - Q_OBJECT -public: - explicit TokenDropTarget( QWidget *parent = 0 ); - virtual ~TokenDropTarget(); - - QSize sizeHint() const; - QSize minimumSizeHint() const; - - /** Removes all tokens from the drop target. */ - void clear(); - - /** Returns the total number of all tokens contained in this drop traget. */ - int count() const; - - /** Returns the row and column position of the \p token. */ - QPoint index( Token* token ) const; - - /** Returns the row of the given \p Token or -1 if not found. */ - int row ( Token* ) const; - - /** Returns the number of rows that this layout has. */ - uint rows() const { return m_rows; }; - - /** Returns the maximum allowed number of rows. - A number of 0 means that the row count is not limited at all. - */ - uint rowLimit() const { return m_rowLimit; } - void setRowLimit( uint r ); - - /** Set a custom factory that creates tokens. - The default factory is the one that creates normal tokens. - LayoutEditWidget set's this for the factory that creates StyledTokens. - - The factory will be deleted by the TokenDropTarget. - */ - void setCustomTokenFactory( TokenFactory * factory ); - - void setVerticalStretch( bool value ); - - /** Returns all the tokens from the specified row. - If row == -1 returns all tokens. */ - QList< Token *> tokensAtRow( int row = -1 ); - -public slots: - /** Insert the token at the given row and col position. - The token will be reparented for the TokenDropTarget. - */ - void insertToken( Token*, int row = -1, int col = -1 ); // -1 -> append to last row - - void deleteEmptyRows(); -signals: - void changed(); - - /** Emitted if a new token got the focus. */ - void tokenSelected( Token* ); - -protected: - void dragEnterEvent( QDragEnterEvent *event ); - void dropEvent( QDropEvent *event ); - - /** Draws a "drop here" text if empty */ - void paintEvent(QPaintEvent *); - - /** Return the enclosing box layout and the row and column position of the widget \p w. */ - QBoxLayout *rowBox( QWidget *w, QPoint *idx = 0 ) const; - - /** Return the box layout at the position \p pt. */ - QBoxLayout *rowBox( const QPoint &pt ) const; - -private: - QHBoxLayout *appendRow(); - - /** Returns the token at the given global position */ - Token* tokenAt( const QPoint &pos ) const; - - void drop( Token*, const QPoint &pos = QPoint(0,0) ); - -private: - /** Maximum number of allowed rows. - If 0 the number is unlimited. */ - uint m_rowLimit; - - /** contains the number of real rows - (using the layout is not very practical in that since it seems that the layout - adds at least one empty entry by itself if it's empty) */ - uint m_rows; - - /** True if stretch are inserted at the ends of every row. */ - bool m_horizontalStretch; - - /** True if a stretch is inserted as a last row. - For now we always have a vertical stretch if the m_rowLimit > 1 */ - bool m_verticalStretch; - - TokenFactory *m_tokenFactory; -}; - -#endif diff --git a/amarok/src/widgets/TokenPool.cpp b/amarok/src/widgets/TokenPool.cpp deleted file mode 100644 index df6b6ddf..00000000 --- a/amarok/src/widgets/TokenPool.cpp +++ /dev/null @@ -1,152 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Téo Mrnjavac * - * Copyright (c) 2009 Seb Ruiz * - * Copyright (c) 2009 Thomas Lbking * - * Copyright (c) 2009 Daniel Dewald * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "TokenPool.h" - -#include - -#include - -#include "core/support/Debug.h" - -TokenPool::TokenPool( QWidget *parent ) - : KListWidget( parent ) -{ - setAcceptDrops( true ); - setWrapping( true ); - setResizeMode( QListView::Adjust ); -} - -void -TokenPool::addToken( Token * token ) -{ - token->setParent( this ); - token->setVisible( false ); - - QListWidgetItem *item = new QListWidgetItem( token->icon(), token->name() ); - if( token->hasCustomColor() ) // don't override the default tooltip color if possible. This very easily produces black test on black tooltip background - { - item->setData( Qt::ForegroundRole, token->textColor() ); - item->setToolTip( "textColor().name() + "\">" + token->name() + "" ); - } - else - { - item->setToolTip( token->name() ); - } - addItem( item ); - - token->setParent( this ); - token->hide(); - m_itemTokenMap.insert( item, token ); -} - -QSize -TokenPool::sizeHint() const -{ - int h = iconSize().height(); - if (h <= 0) { - h = style()->pixelMetric(QStyle::PM_SmallIconSize, 0, this); - } - - // we are planning the size for three columns of token text - // with eight rows (note: we might get less than eight rows if because - // of the space the border and the scroll bar uses). - return QSize(fontMetrics().width(QLatin1String("Artist's Initial")) * 3, - h * 8 ); -} - -// Executed on doubleclick of the TokenPool, emits signal onDoubleClick( QString ) -// that connects to TokenLayoutWidget::addToken( QString ) -void -TokenPool::mouseDoubleClickEvent( QMouseEvent *event ) -{ - QListWidgetItem *tokenItem = itemAt( event->pos() ); - if( tokenItem ) - emit onDoubleClick( m_itemTokenMap.value( tokenItem ) ); -} - -//Executed on mouse press, handles start of drag. -void -TokenPool::mousePressEvent( QMouseEvent *event ) -{ - if( event->button() == Qt::LeftButton ) - m_startPos = event->pos(); //store the start position - KListWidget::mousePressEvent( event ); //feed it to parent's event -} - -//Executed on mouse move, handles start of drag. -void -TokenPool::mouseMoveEvent( QMouseEvent *event ) -{ - if( event->buttons() & Qt::LeftButton ) - { - int distance = ( event->pos() - m_startPos ).manhattanLength(); - if ( distance >= KApplication::startDragDistance() ) - performDrag(); - } - KListWidget::mouseMoveEvent( event ); -} - -void -TokenPool::dragEnterEvent( QDragEnterEvent *event ) -{ - QObject *source = event->source(); - if( source != this && event->mimeData()->hasFormat( Token::mimeType() ) ) - { - event->setDropAction( Qt::MoveAction ); - event->accept(); - } -} - -void -TokenPool::dropEvent( QDropEvent *event ) -{ - Q_UNUSED( event ) - //does nothing, I want the item to be deleted and not dragged here -} - -//Handles the creation of a QDrag object that carries the (text-only) QDataStream from an item in TokenPool -void -TokenPool::performDrag() -{ - QListWidgetItem *item = currentItem(); - - if( item ) - { - Token *token = m_itemTokenMap.value( item ); - - QDrag *drag = new QDrag( this ); - drag->setMimeData( token->mimeData() ); - - // -- icon for pointer - // since the TokenPools tokens are invisible we need to resize them before drawing - // in the pixmap buffer - token->resize( token->sizeHint() ); - - // now draw in the pixmap buffer - QPixmap pixmap( token->size() ); - token->render( &pixmap ); - drag->setPixmap( pixmap ); - drag->setHotSpot ( pixmap.rect().center() ); - - drag->exec( Qt::MoveAction | Qt::CopyAction, Qt::CopyAction ); - } -} - -#include "moc_TokenPool.cpp" diff --git a/amarok/src/widgets/TokenPool.h b/amarok/src/widgets/TokenPool.h deleted file mode 100644 index 63892bd6..00000000 --- a/amarok/src/widgets/TokenPool.h +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Téo Mrnjavac * - * Copyright (c) 2009 Seb Ruiz * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef TOKENPOOL_H -#define TOKENPOOL_H - -#include "Token.h" - -#include -#include - -//Holds a number of icons representing parts of the filename that will become tokens when dropped on the TokenLayoutWidget. -class TokenPool : public KListWidget -{ - Q_OBJECT - - public: - TokenPool( QWidget *parent = 0 ); - - /** Adds the \p token into the token pool. - The TokenPool takes ownership of the token. - Note: The color of the token representation is determined by the text color of the token at the time - it is added. - */ - void addToken( Token * token ); - - QSize sizeHint() const; - protected: - void mouseDoubleClickEvent( QMouseEvent *event ); - - /** Handles start of drag. */ - void mousePressEvent( QMouseEvent *event ); - - /** Handles start of drag. */ - void mouseMoveEvent( QMouseEvent *event ); - void dragEnterEvent( QDragEnterEvent *event ); - // void dragMoveEvent( QDragMoveEvent *event ); - void dropEvent( QDropEvent *event ); - - signals: - /** Emitted if somebody double clicks a token. - The token parameter belongs to the token pool. Don't reparent it. - */ - void onDoubleClick( Token *token ); - - private: - void performDrag(); - - /** Position of the mouse press event - (used for drag and drop) */ - QPoint m_startPos; - - QMap m_itemTokenMap; -}; - -#endif - diff --git a/amarok/src/widgets/TokenWithLayout.cpp b/amarok/src/widgets/TokenWithLayout.cpp deleted file mode 100644 index 4a03d430..00000000 --- a/amarok/src/widgets/TokenWithLayout.cpp +++ /dev/null @@ -1,319 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * Copyright (c) 2009 Roman Jarosz * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "TokenWithLayout.h" - -#include "core/support/Debug.h" -#include "TokenDropTarget.h" -#include "playlist/layouts/LayoutEditDialog.h" - -#include -#include -#include - -#include -#include -#include -#include -#include - -Wrench::Wrench( QWidget *parent ) : QLabel( parent ) -{ - setCursor( Qt::ArrowCursor ); - setPixmap( KIcon( "configure" ).pixmap( 64 ) ); - setScaledContents( true ); - setMargin( 4 ); -} - -void Wrench::enterEvent( QEvent * ) -{ - setMargin( 1 ); - update(); -} - -void Wrench::leaveEvent( QEvent * ) -{ - setMargin( 4 ); - update(); -} - -void Wrench::mousePressEvent( QMouseEvent * ) -{ - setMargin( 4 ); - update(); - emit clicked(); -} - -void Wrench::mouseReleaseEvent( QMouseEvent * ) -{ - setMargin( 1 ); - update(); - emit clicked(); -} - -void Wrench::paintEvent( QPaintEvent *pe ) -{ - QPainter p( this ); - QColor c = palette().color( backgroundRole() ); - p.setPen( Qt::NoPen ); - c = palette().color( backgroundRole() ); - c.setAlpha( 212 ); - p.setBrush( c ); - p.setRenderHint( QPainter::Antialiasing ); - p.drawEllipse( rect() ); - p.end(); - QLabel::paintEvent( pe ); -} - - -const QString ActionBoldName = QLatin1String( "ActionBold" ); -const QString ActionItalicName = QLatin1String( "ActionItalic" ); -const QString ActionAlignLeftName = QLatin1String( "ActionAlignLeft" ); -const QString ActionAlignCenterName = QLatin1String( "ActionAlignCenter" ); -const QString ActionAlignRightName = QLatin1String( "ActionAlignRight" ); - -Token * TokenWithLayoutFactory::createToken( const QString &text, const QString &iconName, qint64 value, QWidget *parent ) const -{ - return new TokenWithLayout( text, iconName, value, parent ); -} - -QWeakPointer TokenWithLayout::m_dialog; - -TokenWithLayout::TokenWithLayout( const QString &text, const QString &iconName, qint64 value, QWidget *parent ) - : Token( text, iconName, value, parent ) - , m_width( 0.0 ), m_wrenchTimer( 0 ) -{ - m_widthForced = m_width > 0.0; - m_alignment = Qt::AlignCenter; - m_bold = false; - m_italic = false; - m_underline = false; - m_wrench = new Wrench( this ); - m_wrench->installEventFilter( this ); - m_wrench->hide(); - connect ( m_wrench, SIGNAL(clicked()), this, SLOT(showConfig()) ); - setFocusPolicy( Qt::ClickFocus ); -} - - -TokenWithLayout::~TokenWithLayout() -{ - delete m_wrench; -} - -void TokenWithLayout::enterEvent( QEvent *e ) -{ - QWidget *win = window(); - const int sz = 2*height(); - QPoint pt = mapTo( win, rect().topLeft() ); - - m_wrench->setParent( win ); - m_wrench->setFixedSize( sz, sz ); - m_wrench->move( pt - QPoint( m_wrench->width()/3, m_wrench->height()/3 ) ); - m_wrench->setCursor( Qt::PointingHandCursor ); - m_wrench->raise(); - m_wrench->show(); - - Token::enterEvent( e ); -} - -bool TokenWithLayout::eventFilter( QObject *o, QEvent *e ) -{ - if ( e->type() == QEvent::Leave && o == m_wrench ) - { - if ( m_wrenchTimer ) - killTimer( m_wrenchTimer ); - m_wrenchTimer = startTimer( 40 ); - } - return false; -} - -void TokenWithLayout::leaveEvent( QEvent *e ) -{ - Token::leaveEvent( e ); - if ( m_wrenchTimer ) - killTimer( m_wrenchTimer ); - m_wrenchTimer = startTimer( 40 ); -} - -void TokenWithLayout::showConfig() -{ - if( !m_dialog ) - m_dialog = new LayoutEditDialog( window() ); - m_dialog.data()->setToken( this ); - if( !m_dialog.data()->isVisible() ) - { - m_dialog.data()->adjustSize(); - QPoint pt = mapToGlobal( rect().bottomLeft() ); - pt.setY( pt.y() + 9 ); - if ( parentWidget() ) - pt.setX( parentWidget()->mapToGlobal( QPoint( 0, 0 ) ).x() + ( parentWidget()->width() - m_dialog.data()->QDialog::width() ) / 2 ); - m_dialog.data()->move( pt ); - } - m_dialog.data()->show(); // ensures raise in doubt - QTimerEvent te( m_wrenchTimer ); - timerEvent( &te ); // it's not like we'd get a leave event when the child dialog pops in between... -} - -void TokenWithLayout::timerEvent( QTimerEvent *te ) -{ - if ( te->timerId() == m_wrenchTimer ) - { - killTimer( m_wrenchTimer ); - m_wrenchTimer = 0; - - QRegion rgn; - rgn |= QRect( mapToGlobal( QPoint( 0, 0 ) ), QWidget::size() ); - rgn |= QRect( m_wrench->mapToGlobal( QPoint( 0, 0 ) ), m_wrench->size() ); - if ( !rgn.contains( QCursor::pos() ) ) - m_wrench->hide(); - } - Token::timerEvent( te ); -} - -Qt::Alignment TokenWithLayout::alignment() -{ - return m_alignment; -} - -void TokenWithLayout::setAlignment( Qt::Alignment alignment ) -{ - if ( m_alignment == alignment ) - return; - - m_alignment = alignment; - m_label->setAlignment( alignment ); - emit changed(); -} - -void TokenWithLayout::setAlignLeft( bool b ) -{ - if (b) - setAlignment( Qt::AlignLeft ); -} - -void TokenWithLayout::setAlignCenter( bool b ) -{ - if (b) - setAlignment( Qt::AlignCenter ); -} - -void TokenWithLayout::setAlignRight( bool b ) -{ - if (b) - setAlignment( Qt::AlignRight ); -} - -bool TokenWithLayout::bold() const -{ - return m_bold; -} - -void TokenWithLayout::setBold( bool bold ) -{ - if ( m_bold == bold ) - return; - - m_bold = bold; - QFont font = m_label->font(); - font.setBold( bold ); - m_label->setFont( font ); - emit changed(); -} - -void TokenWithLayout::setPrefix( const QString& string ) -{ - if ( m_prefix == string ) - return; - if ( string == i18n( "[prefix]" ) ) - m_prefix.clear(); - else - m_prefix = string; - emit changed(); -} - -void TokenWithLayout::setSuffix( const QString& string ) -{ - if ( m_suffix == string ) - return; - if ( string == i18n( "[suffix]" ) ) - m_suffix.clear(); - else - m_suffix = string; - emit changed(); -} - -void TokenWithLayout::setWidth( int size ) -{ - m_width = qMax( qMin( 1.0, size/100.0 ), 0.0 ) ; - if ( m_width > 0.0 ) - m_widthForced = true; - - emit changed(); -} - -void TokenWithLayout::setWidthForced( bool on ) -{ - m_widthForced = on; -} - -qreal TokenWithLayout::width() const -{ - return m_width; -} - -bool TokenWithLayout::italic() const -{ - return m_italic; -} - -bool TokenWithLayout::underline() const -{ - return m_underline; -} - -void TokenWithLayout::setItalic( bool italic ) -{ - if ( m_italic == italic ) - return; - - m_italic = italic; - QFont font = m_label->font(); - font.setItalic( italic ); - m_label->setFont( font ); - - emit changed(); -} - -void TokenWithLayout::setUnderline( bool underline ) -{ - if( m_underline == underline ) - return; - - m_underline = underline; - QFont font = m_label->font(); - font.setUnderline( underline ); - m_label->setFont( font ); - - emit changed(); -} - - -#include "moc_TokenWithLayout.cpp" - - - diff --git a/amarok/src/widgets/TokenWithLayout.h b/amarok/src/widgets/TokenWithLayout.h deleted file mode 100644 index ce05dbec..00000000 --- a/amarok/src/widgets/TokenWithLayout.h +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef TOKENWITHLAYOUT_H -#define TOKENWITHLAYOUT_H - -#include "widgets/Token.h" - -#include - -class LayoutEditDialog; - -class Wrench : public QLabel -{ - Q_OBJECT -public: - Wrench( QWidget *parent ); -protected: - void enterEvent(QEvent *); - void leaveEvent(QEvent *); - void mousePressEvent( QMouseEvent *e ); - void mouseReleaseEvent( QMouseEvent *e ); - void paintEvent( QPaintEvent *pe ); -signals: - void clicked(); -}; - -class TokenWithLayoutFactory : public TokenFactory -{ -public: - virtual Token * createToken( const QString &text, const QString &iconName, qint64 value, QWidget *parent = 0 ) const; -}; - -/** -An extended Token with controls for layouting the token and getting layout values for use outside the Token. - - @author Nikolaj Hald Nielsen -*/ -class TokenWithLayout : public Token -{ - Q_OBJECT -public: - TokenWithLayout( const QString &text, const QString &iconName, qint64 value, QWidget *parent = 0 ); - ~TokenWithLayout(); - - Qt::Alignment alignment(); - void setAlignment( Qt::Alignment alignment ); - - bool bold() const; - bool italic() const; - bool underline() const; - inline qreal size() const { return width(); } - qreal width() const; - inline bool widthForced() const { return m_widthForced; } - inline QString prefix() const { return m_prefix; } - inline QString suffix() const { return m_suffix; } - -public slots: - void setAlignLeft( bool ); - void setAlignCenter( bool ); - void setAlignRight( bool ); - void setBold( bool bold ); - void setItalic( bool italic ); - void setUnderline( bool underline ); - void setPrefix( const QString& ); - void setSuffix( const QString& ); - void setWidth( int width ); - void setWidthForced( bool ); - -protected: - virtual void enterEvent(QEvent *); - virtual bool eventFilter( QObject*, QEvent* ); - virtual void leaveEvent(QEvent *); - virtual void timerEvent( QTimerEvent* ); - -private slots: - void showConfig(); - -private: - - Qt::Alignment m_alignment; - bool m_bold; - bool m_italic; - bool m_underline; - bool m_widthForced; - qreal m_width; - QString m_prefix, m_suffix; - Wrench *m_wrench; - int m_wrenchTimer; - static QWeakPointer m_dialog; - -}; - -#endif diff --git a/amarok/src/widgets/TrackActionButton.cpp b/amarok/src/widgets/TrackActionButton.cpp deleted file mode 100644 index 1ff3ee6c..00000000 --- a/amarok/src/widgets/TrackActionButton.cpp +++ /dev/null @@ -1,146 +0,0 @@ -/**************************************************************************************** -* Copyright (c) 2009 Thomas Luebking * -* * -* This program 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 2 of the License, or (at your option) any later * -* version. * -* * -* This program 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 * -* this program. If not, see . * -****************************************************************************************/ - -#include "TrackActionButton.h" - -#include -#include -#include - -TrackActionButton::TrackActionButton( QWidget *parent, const QAction *act ) : IconButton( parent ) -{ - if ( act ) - setAction( act ); - if ( parent ) - parent->installEventFilter( this ); - // this is during the labelslide - so we wait a short time with image processing ;-) - QTimer::singleShot( 1200, this, SLOT(init()) ); -} - -bool TrackActionButton::eventFilter( QObject *o, QEvent *e ) -{ - if ( o == parentWidget() ) - { - if ( e->type() == QEvent::Enter ) - setIcon( m_icon.image[1], 3 ); - else if ( e->type() == QEvent::Leave ) - setIcon( m_icon.image[0], 6 ); - } - return false; -} - -void TrackActionButton::enterEvent( QEvent *e ) -{ - setIcon( m_icon.image[2], 3 ); - IconButton::enterEvent( e ); -} - -void TrackActionButton::init() -{ - reloadContent( size() ); -} - -void TrackActionButton::leaveEvent( QEvent *e ) -{ - setIcon( m_icon.image[1], 6 ); - IconButton::leaveEvent( e ); -} - -void TrackActionButton::reloadContent( const QSize &sz ) -{ - if ( sz.isNull() ) - return; - int r,g,b; - palette().color(foregroundRole()).getRgb(&r,&g,&b); - - m_icon.image[2] = m_icon.icon.pixmap( sz ).toImage(); - QImage img = m_icon.image[2].convertToFormat(QImage::Format_ARGB32); - int n = img.width() * img.height(); - - const uchar *bits = img.bits(); - QRgb *pixel = (QRgb*)(const_cast(bits)); - - // this creates a (slightly) translucent monochromactic version of the - // image using the foreground color - // the gray value is turned into the opacity -#define ALPHA qAlpha(pixel[i]) -#define GRAY qGray(pixel[i]) - if ( qMax( qMax(r,g), b ) > 128 ) // value > 50%, bright foreground - for (int i = 0; i < n; ++i) - pixel[i] = qRgba( r,g,b, ( ALPHA * ( (160*GRAY) / 255 ) ) / 255 ); - else // inverse - for (int i = 0; i < n; ++i) - pixel[i] = qRgba( r,g,b, ( ALPHA * ( (160*(255-GRAY)) / 255 ) ) / 255 ); - - // premultiplied is much faster on painting / alphablending - m_icon.image[1] = img.convertToFormat(QImage::Format_ARGB32_Premultiplied); - - // and a very translucent variant - for (int i = 0; i < n; ++i) - pixel[i] = qRgba(r,g,b, ALPHA/3); - -#undef ALPHA -#undef GRAY - - m_icon.image[0] = img.convertToFormat(QImage::Format_ARGB32_Premultiplied); - - int i = 0; - if ( underMouse() ) - i = 2; - else if ( !parentWidget() || parentWidget()->underMouse() ) - i = 1; - - setIcon( m_icon.image[i] ); -} - -void TrackActionButton::setAction( const QAction *act ) -{ - disconnect( SIGNAL(clicked()) ); - m_action = act; - if ( act ) - { - m_icon.icon = act->icon(); - setToolTip( act->toolTip() ); - connect ( this, SIGNAL(clicked()), act, SLOT(trigger()) ); - connect ( act, SIGNAL(changed()), SLOT(updateAction()) ); - } - else - { - m_icon.icon = QIcon(); - setToolTip( QString() ); - } -} - -QSize TrackActionButton::sizeHint() const -{ - return QSize( 16, 16 ); -} - -void TrackActionButton::updateAction() -{ - if ( QAction *act = qobject_cast(sender()) ) - { - if ( act == m_action ) - { - m_icon.icon = act->icon(); - setToolTip( act->toolTip() ); - } - else // old action, stop listening - disconnect ( act, SIGNAL(changed()), this, SLOT(updateAction()) ); - } -} - -#include "moc_TrackActionButton.cpp" diff --git a/amarok/src/widgets/TrackActionButton.h b/amarok/src/widgets/TrackActionButton.h deleted file mode 100644 index 64c830de..00000000 --- a/amarok/src/widgets/TrackActionButton.h +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************************** -* Copyright (c) 2009 Thomas Luebking * -* * -* This program 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 2 of the License, or (at your option) any later * -* version. * -* * -* This program 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 * -* this program. If not, see . * -****************************************************************************************/ - -#ifndef TRACKACTIONBUTTON_H -#define TRACKACTIONBUTTON_H - -class QAction; - -#include "IconButton.h" -#include -#include - -class TrackActionButton : public IconButton -{ - Q_OBJECT - -public: - explicit TrackActionButton( QWidget *parent = 0, const QAction *act = 0 ); - void setAction( const QAction *act ); - QSize sizeHint() const; -protected: - bool eventFilter( QObject *o, QEvent *e ); - void enterEvent( QEvent * ); - void leaveEvent( QEvent * ); - void reloadContent( const QSize &sz ); -private slots: - void updateAction(); - void init(); -private: - struct - { - QImage image[3]; - QIcon icon; - } m_icon; - const QAction *m_action; -}; - - -#endif // end include guard diff --git a/amarok/src/widgets/TrackSelectWidget.cpp b/amarok/src/widgets/TrackSelectWidget.cpp deleted file mode 100644 index dbcda11d..00000000 --- a/amarok/src/widgets/TrackSelectWidget.cpp +++ /dev/null @@ -1,99 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008-2010 Soren Harward * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#define DEBUG_PREFIX "TrackSelectWidget" - -#include "TrackSelectWidget.h" - -#include "amarokconfig.h" -#include "browsers/CollectionTreeItem.h" -#include "browsers/CollectionTreeItemModel.h" -#include "browsers/CollectionTreeView.h" -#include "core/meta/Meta.h" -#include "core/support/Amarok.h" -#include "core/support/Debug.h" -#include "widgets/PrettyTreeDelegate.h" - -#include -#include -#include - -#include - -TrackSelectWidget::TrackSelectWidget( QWidget* parent ) - : KVBox( parent ) -{ - DEBUG_BLOCK - m_label = new KSqueezedTextLabel( this ); - m_label->hide(); // TODO: decide whether the label should be shown or not - m_label->setTextElideMode( Qt::ElideRight ); - setData( Meta::DataPtr() ); - - m_view = new CollectionTreeView( this ); - m_view->setRootIsDecorated( false ); - m_view->setFrameShape( QFrame::NoFrame ); - - m_view->setItemDelegate( new PrettyTreeDelegate( m_view ) ); - - QList levelNumbers = Amarok::config( "Collection Browser" ).readEntry( "TreeCategory", QList() ); - QList levels; - foreach( int levelNumber, levelNumbers ) - levels << CategoryId::CatMenuId( levelNumber ); - if ( levels.isEmpty() ) - levels << CategoryId::Artist << CategoryId::Album; - m_model = new CollectionTreeItemModel( levels ); - m_model->setParent( this ); - m_view->setModel( m_model ); - - connect( m_view, SIGNAL(itemSelected(CollectionTreeItem*)), - this, SLOT(recvNewSelection(CollectionTreeItem*)) ); -} - -TrackSelectWidget::~TrackSelectWidget() {} - -void TrackSelectWidget::setData( const Meta::DataPtr& data ) -{ - debug() << "setting label to" << dataToLabel( data ); - m_label->setText( i18n("Checkpoint: %1", dataToLabel( data ) ) ); -} - -void -TrackSelectWidget::recvNewSelection( CollectionTreeItem* item ) -{ - if ( item && item->isDataItem() ) { - Meta::DataPtr data = item->data(); - if ( data != Meta::DataPtr() ) { - setData( data ); - debug() << "new selection" << data->prettyName(); - emit selectionChanged( data ); - } - } -} - -const QString TrackSelectWidget::dataToLabel( const Meta::DataPtr& data ) const -{ - if ( data != Meta::DataPtr() ) { - if ( Meta::TrackPtr track = Meta::TrackPtr::dynamicCast( data ) ) { - return QString( i18n("Track: %1", track->prettyName() ) ); - } else if ( Meta::AlbumPtr album = Meta::AlbumPtr::dynamicCast( data ) ) { - return QString( i18n("Album: %1", album->prettyName() ) ); - } else if ( Meta::ArtistPtr artist = Meta::ArtistPtr::dynamicCast( data ) ) { - return QString( i18n("Artist: %1", artist->prettyName() ) ); - } - // TODO: can things other than tracks, artists, and albums end up here? - } - return QString( i18n("empty") ); -} diff --git a/amarok/src/widgets/TrackSelectWidget.h b/amarok/src/widgets/TrackSelectWidget.h deleted file mode 100644 index 5f6f7f64..00000000 --- a/amarok/src/widgets/TrackSelectWidget.h +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008-2010 Soren Harward * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_TRACK_SELECT_WIDGET_H -#define AMAROK_TRACK_SELECT_WIDGET_H - -#include "core/meta/forward_declarations.h" - -#include - -#include - -class CollectionTreeItem; -class CollectionTreeItemModel; -class CollectionTreeView; - -class KSqueezedTextLabel; - -class TrackSelectWidget: public KVBox -{ - Q_OBJECT - - public: - TrackSelectWidget( QWidget* parent ); - ~TrackSelectWidget(); - - void setData( const Meta::DataPtr& ); - - signals: - void selectionChanged( const Meta::DataPtr& ); - - private slots: - void recvNewSelection( CollectionTreeItem* ); - - private: - CollectionTreeView* m_view; - CollectionTreeItemModel* m_model; - KSqueezedTextLabel* m_label; - - const QString dataToLabel( const Meta::DataPtr& ) const; -}; - -#endif // AMAROK_TRACK_SELECT_WIDGET_H diff --git a/amarok/src/widgets/VolumeDial.cpp b/amarok/src/widgets/VolumeDial.cpp deleted file mode 100644 index 2c7fb25f..00000000 --- a/amarok/src/widgets/VolumeDial.cpp +++ /dev/null @@ -1,344 +0,0 @@ -/**************************************************************************************** -* Copyright (c) 2009 Thomas Luebking * -* * -* This program 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 2 of the License, or (at your option) any later * -* version. * -* * -* This program 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 * -* this program. If not, see . * -****************************************************************************************/ - -#include "VolumeDial.h" - -#include "PaletteHandler.h" -#include "SvgHandler.h" - -#include -#include -#include -#include -#include -#include - -#include -#include - -#include - -VolumeDial::VolumeDial( QWidget *parent ) : QDial( parent ) - , m_isClick( false ) - , m_isDown( false ) - , m_muted( false ) -{ - m_anim.step = 0; - m_anim.timer = 0; - setMouseTracking( true ); - - connect ( this, SIGNAL(valueChanged(int)), SLOT(valueChangedSlot(int)) ); - connect( The::paletteHandler(), SIGNAL(newPalette(QPalette)), SLOT(paletteChanged(QPalette)) ); -} - -void VolumeDial::addWheelProxies( QList proxies ) -{ - foreach ( QWidget *proxy, proxies ) - { - if ( !m_wheelProxies.contains( proxy ) ) - { - proxy->installEventFilter( this ); - connect ( proxy, SIGNAL(destroyed(QObject*)), this, SLOT(removeWheelProxy(QObject*)) ); - m_wheelProxies << proxy; - } - } -} - -void VolumeDial::paletteChanged( const QPalette &palette ) -{ - const QColor &fg = palette.color( foregroundRole() ); - const QColor &hg = palette.color( QPalette::Highlight ); - const qreal contrast = KColorUtils::contrastRatio( hg, palette.color( backgroundRole() ) ); - m_highlightColor = KColorUtils::mix( hg, fg, 1.0 - contrast/3.0 ); - renderIcons(); -} - -void VolumeDial::enterEvent( QEvent * ) -{ - startFade(); -} - -// NOTICE: we intercept wheelEvents for ourself to prevent the tooltip hiding on them, -// see ::wheelEvent() -// this is _NOT_ redundant to the code in MainToolbar.cpp -bool VolumeDial::eventFilter( QObject *o, QEvent *e ) -{ - if ( e->type() == QEvent::Wheel && !static_cast(e)->modifiers() ) - { - if ( o == this || m_wheelProxies.contains( static_cast( o ) ) ) - { - QWheelEvent *wev = static_cast(e); - if ( o != this ) - { - QPoint pos( 0, 0 ); // the event needs to be on us or nothing will happen - QWheelEvent nwev( pos, mapToGlobal( pos ), wev->delta(), wev->buttons(), wev->modifiers() ); - wheelEvent( &nwev ); - } - else - wheelEvent( wev ); - return true; - } - else // we're not needed globally anymore - qApp->removeEventFilter( this ); - } - return false; -} - -void VolumeDial::leaveEvent( QEvent * ) -{ - startFade(); -} - -static bool onRing( const QRect &r, const QPoint &p ) -{ - const QPoint c = r.center(); - const int dx = p.x() - c.x(); - const int dy = p.y() - c.y(); - return sqrt(dx*dx + dy*dy) > r.width()/4; -} - -void VolumeDial::mouseMoveEvent( QMouseEvent *me ) -{ - if ( me->buttons() == Qt::NoButton ) - setCursor( onRing( rect(), me->pos() ) ? Qt::PointingHandCursor : Qt::ArrowCursor ); - else if ( m_isClick ) - me->accept(); - else - QDial::mouseMoveEvent( me ); -} - -void VolumeDial::mousePressEvent( QMouseEvent *me ) -{ - if ( me->button() != Qt::LeftButton ) - { - QDial::mousePressEvent( me ); - return; - } - - m_isClick = !onRing( rect(), me->pos() ); - - if ( m_isClick ) - update(); // hide the ring - else - { - setCursor( Qt::PointingHandCursor ); // hint dragging - QDial::mousePressEvent( me ); // this will directly jump to the proper position - } - - // for value changes caused by mouseevent we'll only let our adjusted value changes be emitted - // see ::sliderChange() - m_formerValue = value(); - blockSignals( true ); -} - -void VolumeDial::mouseReleaseEvent( QMouseEvent *me ) -{ - if ( me->button() != Qt::LeftButton ) - return; - - blockSignals( false ); // free signals - setCursor( Qt::ArrowCursor ); - setSliderDown( false ); - - if ( m_isClick ) - { - m_isClick = !onRing( rect(), me->pos() ); - if ( m_isClick ) - emit muteToggled( !m_muted ); - } - - m_isClick = false; -} - -void VolumeDial::paintEvent( QPaintEvent * ) -{ - QPainter p( this ); - int icon = m_muted ? 0 : 3; - if ( icon && value() < 66 ) - icon = value() < 33 ? 1 : 2; - p.drawPixmap( 0,0, m_icon[ icon ] ); - if ( !m_isClick ) - { - p.setPen( QPen( m_sliderGradient, 3, Qt::SolidLine, Qt::RoundCap ) ); - p.setRenderHint( QPainter::Antialiasing ); - p.drawArc( rect().adjusted(4,4,-4,-4), -110*16, - value()*320*16 / (maximum() - minimum()) ); - } - p.end(); -} - -void VolumeDial::removeWheelProxy( QObject *w ) -{ - m_wheelProxies.removeOne( static_cast(w) ); -} - -void VolumeDial::resizeEvent( QResizeEvent *re ) -{ - if( width() != height() ) - resize( height(), height() ); - else - QDial::resizeEvent( re ); - - if( re->size() != re->oldSize() ) - { - renderIcons(); - m_sliderGradient = QPixmap( size() ); - updateSliderGradient(); - update(); - } -} - -void VolumeDial::renderIcons() -{ - m_icon[0] = The::svgHandler()->renderSvg( "Muted", width(), height(), "Muted", true ); - m_icon[1] = The::svgHandler()->renderSvg( "Volume_low", width(), height(), "Volume_low", true ); - m_icon[2] = The::svgHandler()->renderSvg( "Volume_mid", width(), height(), "Volume_mid", true ); - m_icon[3] = The::svgHandler()->renderSvg( "Volume", width(), height(), "Volume", true ); - if( layoutDirection() == Qt::RightToLeft ) - { - for ( int i = 0; i < 4; ++i ) - m_icon[i] = QPixmap::fromImage( m_icon[i].toImage().mirrored( true, false ) ); - } -} - -void VolumeDial::startFade() -{ - if ( m_anim.timer ) - killTimer( m_anim.timer ); - m_anim.timer = startTimer( 40 ); -} - -void VolumeDial::stopFade() -{ - killTimer( m_anim.timer ); - m_anim.timer = 0; - if ( m_anim.step < 0 ) - m_anim.step = 0; - else if ( m_anim.step > 6 ) - m_anim.step = 6; -} - -void VolumeDial::timerEvent( QTimerEvent *te ) -{ - if ( te->timerId() != m_anim.timer ) - return; - if ( underMouse() ) // fade in - { - m_anim.step += 2; - if ( m_anim.step > 5 ) - stopFade(); - } - else // fade out - { - --m_anim.step; - if ( m_anim.step < 1 ) - stopFade(); - } - updateSliderGradient(); - repaint(); -} - -void VolumeDial::updateSliderGradient() -{ - m_sliderGradient.fill( Qt::transparent ); - QColor c = m_highlightColor; - if ( !m_anim.step ) - { - c.setAlpha( 99 ); - m_sliderGradient.fill( c ); - return; - } - - QConicalGradient cg( m_sliderGradient.rect().center(), -90 ); - - c.setAlpha( 99 + m_anim.step*156/6 ); - cg.setColorAt( 0, c ); - c.setAlpha( 99 + m_anim.step*42/6 ); - cg.setColorAt( 1, c ); - - QPainter p( &m_sliderGradient ); - p.fillRect( m_sliderGradient.rect(), cg ); - p.end(); -} - -void VolumeDial::wheelEvent( QWheelEvent *wev ) -{ - QDial::wheelEvent( wev ); - wev->accept(); - - const QPoint tooltipPosition = mapToGlobal( rect().translated( 7, -22 ).bottomLeft() ); - QToolTip::showText( tooltipPosition, toolTip() ); - - // NOTICE: this is a bit tricky. - // the ToolTip "QTipLabel" just installed a global eventfilter that intercepts various - // events and hides itself on them. Therefore every even wheelevent will close the tip - // ("works - works not - works - works not - ...") - // so we post-install our own global eventfilter to handle wheel events meant for us bypassing - // the ToolTip eventfilter - - // first remove to prevent multiple installations but ensure we're on top of the ToolTip filter - qApp->removeEventFilter( this ); - // it's ultimately removed in the timer triggered ::hideToolTip() slot - qApp->installEventFilter( this ); -} - -void VolumeDial::setMuted( bool mute ) -{ - m_muted = mute; - - setToolTip( m_muted ? i18n( "Muted" ) : i18n( "Volume: %1%", value() ) ); - update(); -} - -QSize VolumeDial::sizeHint() const -{ - if ( QToolBar *toolBar = qobject_cast( parentWidget() ) ) - return toolBar->iconSize(); - - return QDial::sizeHint(); -} - -void VolumeDial::sliderChange( SliderChange change ) -{ - if ( change == SliderValueChange && isSliderDown() && signalsBlocked() ) - { - int d = value() - m_formerValue; - if ( d && d < 33 && d > -33 ) // don't allow real "jumps" > 1/3 - { - if ( d > 5 ) // ease movement - d = 5; - else if ( d < -5 ) - d = -5; - m_formerValue += d; - blockSignals( false ); - emit sliderMoved( m_formerValue ); - emit valueChanged( m_formerValue ); - blockSignals( true ); - } - if ( d ) - setValue( m_formerValue ); - } - QDial::sliderChange(change); -} - -void VolumeDial::valueChangedSlot( int v ) -{ - m_isClick = false; - - setToolTip( m_muted ? i18n( "Muted" ) : i18n( "Volume: %1%", v ) ); - update(); -} - -#include "moc_VolumeDial.cpp" diff --git a/amarok/src/widgets/VolumeDial.h b/amarok/src/widgets/VolumeDial.h deleted file mode 100644 index f706cf2b..00000000 --- a/amarok/src/widgets/VolumeDial.h +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************************** -* Copyright (c) 2009 Thomas Luebking * -* * -* This program 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 2 of the License, or (at your option) any later * -* version. * -* * -* This program 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 * -* this program. If not, see . * -****************************************************************************************/ - -#ifndef VOLUMEDIAL_H -#define VOLUMEDIAL_H - -#include - - -class VolumeDial : public QDial -{ - Q_OBJECT - -public: - VolumeDial( QWidget *parent = 0 ); - /** - Add a list of widgets that should not hide the tooltip on wheelevents, but instead cause - wheelevents on the dial - You do NOT have to remove them on deconstruction. - */ - void addWheelProxies( QList proxies ); - QSize sizeHint() const; - -public slots: - /** - Remove an added wheelproxy. The slot is automatically bound to the widgets deconstruction - signal when added. You don't have to do that. - */ - void removeWheelProxy( QObject * ); - void setMuted( bool mute ); - -signals: - void muteToggled( bool mute ); - -protected: - void enterEvent( QEvent * ); - bool eventFilter( QObject *o, QEvent *e ); - void leaveEvent( QEvent * ); - void paintEvent( QPaintEvent * ); - void mouseMoveEvent( QMouseEvent * ); - void mousePressEvent( QMouseEvent * ); - void mouseReleaseEvent( QMouseEvent * ); - void resizeEvent(QResizeEvent *); - void sliderChange( SliderChange change ); - void timerEvent ( QTimerEvent * ); - friend class MainToolbar; - void wheelEvent( QWheelEvent * ); - -private: - void startFade(); - void stopFade(); - void renderIcons(); - void updateSliderGradient(); - -private slots: - void paletteChanged( const QPalette &palette ); - void valueChangedSlot( int ); - -private: - QPixmap m_icon[4]; - QPixmap m_sliderGradient; - int m_formerValue; - QList m_wheelProxies; - struct - { - int step; - int timer; - } m_anim; - bool m_isClick, m_isDown, m_muted; - QColor m_highlightColor; -}; - -#endif // end include guard diff --git a/amarok/src/widgets/kdatecombo.cpp b/amarok/src/widgets/kdatecombo.cpp deleted file mode 100644 index 0fbbe445..00000000 --- a/amarok/src/widgets/kdatecombo.cpp +++ /dev/null @@ -1,144 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Daniel Caleb Jones * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "kdatecombo.h" - -#include "moc_kdatecombo.cpp" - -#include -//Added by qt3to4: -#include -#include - -#include -#include -#include -#include -#include - -KDateCombo::KDateCombo(QWidget *parent) : QComboBox(parent) -{ - setEditable( false ); - - QDate date = QDate::currentDate(); - initObject(date); -} - -KDateCombo::KDateCombo(const QDate & date, QWidget *parent) : QComboBox(parent) -{ - setEditable( false ); - - initObject(date); -} - -void KDateCombo::initObject(const QDate & date) -{ - setValidator(0); - popupFrame = new KPopupFrame(this); - popupFrame->installEventFilter(this); - datePicker = new KDatePicker(date, popupFrame); - datePicker->setMinimumSize(datePicker->sizeHint()); - datePicker->installEventFilter(this); - popupFrame->setMainWidget(datePicker); - setDate(date); - - connect(datePicker, SIGNAL(dateSelected(QDate)), this, SLOT(dateEnteredEvent(QDate))); - connect(datePicker, SIGNAL(dateEntered(QDate)), this, SLOT(dateEnteredEvent(QDate))); -} - -KDateCombo::~KDateCombo() -{ - delete datePicker; - delete popupFrame; -} - -QString KDateCombo::date2String(const QDate & date) -{ - return(KGlobal::locale()->formatDate(date, KLocale::ShortDate)); -} - -QDate & KDateCombo::string2Date(const QString & str, QDate *qd) -{ - return *qd = KGlobal::locale()->readDate(str); -} - -QDate & KDateCombo::getDate(QDate *currentDate) -{ - return string2Date(currentText(), currentDate); -} - -bool KDateCombo::setDate(const QDate & newDate) -{ - if (newDate.isValid()) - { - if (count()) - clear(); - addItem(date2String(newDate)); - return true; - } - return false; -} - -void KDateCombo::dateEnteredEvent(const QDate &newDate) -{ - QDate tempDate = newDate; - if (!tempDate.isValid()) - tempDate = datePicker->date(); - popupFrame->hide(); - setDate(tempDate); -} - -void KDateCombo::mousePressEvent (QMouseEvent * e) -{ - if (e->button() & Qt::LeftButton) - { - if (rect().contains( e->pos())) - { - QDate tempDate; - getDate(& tempDate); - datePicker->setDate(tempDate); - popupFrame->popup(mapToGlobal(QPoint(0, height()))); - } - } -} - -bool KDateCombo::eventFilter (QObject*, QEvent* e) -{ - if ( e->type() == QEvent::MouseButtonPress ) - { - QMouseEvent *me = (QMouseEvent *)e; - QPoint p = mapFromGlobal( me->globalPos() ); - if (rect().contains( p ) ) - { - QTimer::singleShot(10, this, SLOT(dateEnteredEvent())); - return true; - } - } - else if ( e->type() == QEvent::KeyRelease ) - { - QKeyEvent *k = (QKeyEvent *)e; - - if (k->key()==Qt::Key_Escape) { - popupFrame->hide(); - return true; - } - else { - return false; - } - } - - return false; -} diff --git a/amarok/src/widgets/kdatecombo.h b/amarok/src/widgets/kdatecombo.h deleted file mode 100644 index 57cb2f0d..00000000 --- a/amarok/src/widgets/kdatecombo.h +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2008 Daniel Caleb Jones * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef KDATECOMBO_H -#define KDATECOMBO_H - -#include -#include -#include - -/** - *@author Beppe Grimaldi - */ - -class KDatePicker; -class KPopupFrame; - -class KDateCombo : public QComboBox { - Q_OBJECT - -public: - KDateCombo(QWidget *parent=0); - explicit KDateCombo(const QDate & date, QWidget *parent=0); - ~KDateCombo(); - - QDate & getDate(QDate *currentDate); - bool setDate(const QDate & newDate); - -private: - KPopupFrame * popupFrame; - KDatePicker * datePicker; - - void initObject(const QDate & date); - - QString date2String(const QDate &); - QDate & string2Date(const QString &, QDate * ); - -protected: - bool eventFilter (QObject*, QEvent*); - virtual void mousePressEvent (QMouseEvent * e); - -protected Q_SLOTS: - void dateEnteredEvent(const QDate &d=QDate()); -}; - -#endif diff --git a/amarok/tests/CMakeLists.txt b/amarok/tests/CMakeLists.txt deleted file mode 100644 index dbe1d837..00000000 --- a/amarok/tests/CMakeLists.txt +++ /dev/null @@ -1,151 +0,0 @@ -set( EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR} ) - -find_package(Googlemock REQUIRED) -macro_log_feature( GOOGLEMOCK_FOUND "gmock" "Used in Amarok's tests." "http://code.google.com/p/googlemock/" TRUE "1.4" "" ) - -set( AMAROK_SOURCE_TREE ${CMAKE_SOURCE_DIR}/src ) -set( AMAROK_TEST_TREE ${CMAKE_SOURCE_DIR}/tests ) -set( AMAROK_UTILITY_TREE ${CMAKE_SOURCE_DIR}/utilities ) -set( AMAROK_UTILITIES_DIR ${CMAKE_BINARY_DIR}/utilities ) -set( STRESS_TEST_TRACK_COUNT 20000 ) - -configure_file(config-amarok-test.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-amarok-test.h ) - -include_directories( - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_SOURCE_DIR}/src - ${CMAKE_BINARY_DIR}/src - ${GOOGLEMOCK_INCLUDE_DIR} ) - -add_subdirectory( amarokurls ) -add_subdirectory( browsers ) -add_subdirectory( context ) -add_subdirectory( core ) -add_subdirectory( core-impl ) -add_subdirectory( dynamic ) -if( ${CMAKE_SYSTEM_NAME} MATCHES "Linux" ) -add_subdirectory( importers ) -endif( ${CMAKE_SYSTEM_NAME} MATCHES "Linux" ) -add_subdirectory( playlist ) -add_subdirectory( playlistmanager ) -add_subdirectory( timecode ) -add_subdirectory( scanner ) -add_subdirectory( services ) -add_subdirectory( synchronization ) - -#------------------------ Test Amarok namespace ----------------------------- - -set( testamarok_SRCS - TestAmarok.cpp - ${AMAROK_SOURCE_TREE}/core/support/Amarok.cpp - ) - -kde4_add_unit_test( testamarok ${testamarok_SRCS} ) - -target_link_libraries( testamarok - ${KDE4_KDECORE_LIBS} - ${KDE4_KDEUI_LIBS} - ${KDE4_KIO_LIBS} - ${QT_QTTEST_LIBRARY} - amarokcore - amaroklib - ) - -#------------------------ Test CaseConverter ----------------------------- - -set( testcaseconverter_SRCS - TestCaseConverter.cpp - ${AMAROK_SOURCE_TREE}/CaseConverter.cpp - ) - -kde4_add_unit_test( testcaseconverter ${testcaseconverter_SRCS} ) - -target_link_libraries(testcaseconverter ${KDE4_KDECORE_LIBS} ${QT_QTTEST_LIBRARY} amarokcore) - -#------------------------ Test Debug ----------------------------- - -add_definitions(-DDEBUG_OVERRIDE_ELAPSED_TIME=4.9) -set( testdebug_SRCS - TestDebug.cpp - ${AMAROK_SOURCE_TREE}/core/support/Debug.cpp - ) - -kde4_add_unit_test( testdebug ${testdebug_SRCS} ) -target_link_libraries(testdebug ${KDE4_KDECORE_LIBS} ${QT_QTTEST_LIBRARY} amarokcore ) - -#------------------------ Test EngineController ----------------------------- - -set( testenginecontroller_SRCS TestEngineController.cpp ) -kde4_add_unit_test( testenginecontroller ${testenginecontroller_SRCS} ) -target_link_libraries( testenginecontroller ${KDE4_THREADWEAVER_LIBS} ${KDE4_KDECORE_LIBS} ${QT_QTTEST_LIBRARY} amaroklib amarokcore ) - -#------------------------ Test Expression ----------------------------- - -set( testexpression_SRCS - TestExpression.cpp - ${AMAROK_SOURCE_TREE}/core-impl/collections/support/Expression.cpp - ) - -kde4_add_unit_test( testexpression ${testexpression_SRCS} ) - -target_link_libraries(testexpression ${KDE4_KDECORE_LIBS} ${QT_QTTEST_LIBRARY}) - -#------------------------ Test QStringx ----------------------------- - -set( testqstringx_SRCS - TestQStringx.cpp - ${AMAROK_SOURCE_TREE}/QStringx.cpp - ) - -kde4_add_unit_test( testqstringx ${testqstringx_SRCS} ) - -target_link_libraries(testqstringx ${KDE4_KDECORE_LIBS} ${QT_QTTEST_LIBRARY}) - -#------------------------ Test SmartPointerList ----------------------------- - -set( testsmartpointerlist_SRCS - TestSmartPointerList.cpp - ${AMAROK_SOURCE_TREE}/core/support/SmartPointerList.cpp - ) - -kde4_add_unit_test( testsmartpointerlist ${testsmartpointerlist_SRCS} ) - -target_link_libraries(testsmartpointerlist ${KDE4_KDECORE_LIBS} ${QT_QTTEST_LIBRARY}) - -#------------------------ Test TagGuesser ----------------------------- - -set( testtagguesser_SRCS - TestTagGuesser.cpp - ${CMAKE_SOURCE_DIR}/shared/TagsFromFileNameGuesser.cpp - ${AMAROK_SOURCE_TREE}/dialogs/TagGuesser.cpp - ) - -kde4_add_unit_test( testtagguesser ${testtagguesser_SRCS} ) - -target_link_libraries(testtagguesser ${KDE4_KDECORE_LIBS} ${KDE4_KDEUI_LIBS} ${QT_QTTEST_LIBRARY} amarokcore) - -#------------------------ Test TrackOrganizer ----------------------------- - -set( testtrackorganizer_SRCS - TestTrackOrganizer.cpp - ${AMAROK_SOURCE_TREE}/dialogs/TrackOrganizer.cpp - ${AMAROK_SOURCE_TREE}/core/meta/Meta.cpp - ${AMAROK_SOURCE_TREE}/QStringx.cpp - ${GOOGLEMOCK_SRCS} - ) - -kde4_add_unit_test( testtrackorganizer ${testtrackorganizer_SRCS} ) - -# Since Google recommends not to distribute a pre-compiled gtest library -# we have to build it our own -if(GOOGLEMOCK_GTEST_SOURCES) - add_subdirectory( ${GOOGLEMOCK_GTEST_SOURCES} gtest ) -endif(GOOGLEMOCK_GTEST_SOURCES) - -add_dependencies( testtrackorganizer amarokcore ) -add_dependencies( testtrackorganizer amaroklib ) -add_dependencies( testtrackorganizer gtest ) - -target_link_libraries( testtrackorganizer amarokcore amaroklib ${KDE4_KDECORE_LIBS} ${KDE4_KDEUI_LIBS} ${KDE4_SOLID_LIBRARY} ${QT_QTTEST_LIBRARY} ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${GOOGLEMOCK_LIBRARIES}) - diff --git a/amarok/tests/CollectionTestImpl.h b/amarok/tests/CollectionTestImpl.h deleted file mode 100644 index e40f2ced..00000000 --- a/amarok/tests/CollectionTestImpl.h +++ /dev/null @@ -1,155 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Maximilian Kossick * - * Copyright (c) 2013 Konrad Zemek * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef COLLECTIONTESTIMPL_H -#define COLLECTIONTESTIMPL_H - -#include "core/collections/Collection.h" -#include "core/collections/CollectionLocation.h" -#include "core-impl/collections/support/MemoryCollection.h" -#include "core-impl/collections/support/MemoryQueryMaker.h" - -#include -#include - -namespace Collections { - -/** - * A simple Collections::Collection implementation based on MemoryCollection - */ -class CollectionTestImpl : public Collection -{ -public: - CollectionTestImpl( const QString &collectionId ) - : Collection() - , id( collectionId ) - , mc( new MemoryCollection() ) - { - } - - QueryMaker* queryMaker() - { - return new MemoryQueryMaker( mc.toWeakRef(), id ); - } - - KIcon icon() const - { - return KIcon(); - } - - QString collectionId() const - { - return id; - } - - QString prettyName() const - { - return id; - } - - CollectionLocation *location() - { - return new CollectionLocationTestImpl( mc, this ); - } - - bool possiblyContainsTrack( const KUrl &url ) const - { - return findTrackForUrl( url ); - } - - Meta::TrackPtr trackForUrl( const KUrl &url ) - { - return findTrackForUrl( url ); - } - - QString id; - QSharedPointer mc; - -private: - Meta::TrackPtr findTrackForUrl( const KUrl &url ) const - { - QReadLocker( mc->mapLock() ); - - foreach( const Meta::TrackPtr track, mc->trackMap().values() ) - if( track->playableUrl() == url ) - return track; - - return Meta::TrackPtr( 0 ); - } - - class CollectionLocationTestImpl : public CollectionLocation - { - public: - CollectionLocationTestImpl( QSharedPointer mc, - Collection *parentCollection ) - : CollectionLocation( parentCollection ) - , m_mc( mc ) - { - } - - QString prettyLocation() const - { - return "/" + collection()->prettyName(); - } - - bool isWritable() const - { - return true; - } - - void copyUrlsToCollection( const QMap &sources, - const Transcoding::Configuration &configuration ) - { - Q_UNUSED( configuration ); - - QWriteLocker( m_mc->mapLock() ); - - foreach( Meta::TrackPtr track, sources.keys() ) - { - m_mc->addTrack( track ); - transferSuccessful( track ); - } - - slotCopyOperationFinished(); - } - - bool insert( const Meta::TrackPtr &track, const QString &url ) - { - Q_UNUSED( url ); - - QWriteLocker( m_mc->mapLock() ); - - if( m_mc->trackMap().contains( track->uidUrl() ) ) - return false; - - m_mc->addTrack( track ); - return true; - } - - QStringList actualLocation() const - { - return QStringList() << prettyLocation(); - } - - private: - QSharedPointer m_mc; - }; -}; - -} //namespace Collections - -#endif diff --git a/amarok/tests/MetaNotificationSpy.cpp b/amarok/tests/MetaNotificationSpy.cpp deleted file mode 100644 index 49a8b7bf..00000000 --- a/amarok/tests/MetaNotificationSpy.cpp +++ /dev/null @@ -1,162 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "MetaNotificationSpy.h" - -#include "core/meta/Meta.h" -#include "core/meta/Observer.h" - -class MetaNotificationSpyPrivate : public Meta::Observer -{ -public: - MetaNotificationSpyPrivate() - : Meta::Observer() {} - - virtual ~MetaNotificationSpyPrivate() {} - - virtual void metadataChanged( Meta::TrackPtr track ) { trackNotifications << track; } - virtual void metadataChanged( Meta::ArtistPtr artist ) { artistNotifications << artist; } - virtual void metadataChanged( Meta::AlbumPtr album ) { albumNotifications << album; } - virtual void metadataChanged( Meta::GenrePtr genre ) { genreNotifications << genre; } - virtual void metadataChanged( Meta::ComposerPtr composer ) { composerNotifications << composer; } - virtual void metadataChanged( Meta::YearPtr year ) { yearNotifications << year; } - - Meta::TrackList trackNotifications; - Meta::AlbumList albumNotifications; - Meta::ArtistList artistNotifications; - Meta::GenreList genreNotifications; - Meta::ComposerList composerNotifications; - Meta::YearList yearNotifications; -}; - -MetaNotificationSpy::MetaNotificationSpy() - : d( new MetaNotificationSpyPrivate() ) -{ -//nothing to do -} - -MetaNotificationSpy::MetaNotificationSpy( const Meta::TrackPtr &track ) - : d( new MetaNotificationSpyPrivate() ) -{ - d->subscribeTo( track ); -} - -MetaNotificationSpy::MetaNotificationSpy( const Meta::AlbumPtr &album ) - : d( new MetaNotificationSpyPrivate() ) -{ - d->subscribeTo( album ); -} - -MetaNotificationSpy::MetaNotificationSpy( const Meta::ArtistPtr &artist ) - : d( new MetaNotificationSpyPrivate() ) -{ - d->subscribeTo( artist ); -} - -MetaNotificationSpy::MetaNotificationSpy( const Meta::ComposerPtr &composer ) - : d( new MetaNotificationSpyPrivate() ) -{ - d->subscribeTo( composer ); -} - -MetaNotificationSpy::MetaNotificationSpy( const Meta::GenrePtr &genre ) - : d( new MetaNotificationSpyPrivate() ) -{ - d->subscribeTo( genre ); -} - -MetaNotificationSpy::MetaNotificationSpy( const Meta::YearPtr &year ) - : d( new MetaNotificationSpyPrivate() ) -{ - d->subscribeTo( year ); -} - -MetaNotificationSpy::~MetaNotificationSpy() -{ - delete d; -} - -void -MetaNotificationSpy::subscribeTo(const Meta::AlbumPtr &album) -{ - d->subscribeTo( album ); -} - -void -MetaNotificationSpy::subscribeTo(const Meta::ArtistPtr &artist) -{ - d->subscribeTo( artist ); -} - -void -MetaNotificationSpy::subscribeTo(const Meta::ComposerPtr &composer) -{ - d->subscribeTo( composer ); -} - -void -MetaNotificationSpy::subscribeTo(const Meta::GenrePtr &genre) -{ - d->subscribeTo( genre ); -} - -void -MetaNotificationSpy::subscribeTo(const Meta::TrackPtr &track) -{ - d->subscribeTo( track ); -} - -void -MetaNotificationSpy::subscribeTo(const Meta::YearPtr &year) -{ - d->subscribeTo( year ); -} - -Meta::TrackList -MetaNotificationSpy::notificationsFromTracks() const -{ - return d->trackNotifications; -} - -Meta::AlbumList -MetaNotificationSpy::notificationsFromAlbums() const -{ - return d->albumNotifications; -} - -Meta::ArtistList -MetaNotificationSpy::notificationsFromArtists() const -{ - return d->artistNotifications; -} - -Meta::ComposerList -MetaNotificationSpy::notificationsFromComposers() const -{ - return d->composerNotifications; -} - -Meta::GenreList -MetaNotificationSpy::notificationsFromGenres() const -{ - return d->genreNotifications; -} - -Meta::YearList -MetaNotificationSpy::notificationsFromYears() const -{ - return d->yearNotifications; -} diff --git a/amarok/tests/MetaNotificationSpy.h b/amarok/tests/MetaNotificationSpy.h deleted file mode 100644 index e68c4281..00000000 --- a/amarok/tests/MetaNotificationSpy.h +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef METANOTIFICATIONSPY_H -#define METANOTIFICATIONSPY_H - -#include "core/meta/forward_declarations.h" - -class MetaNotificationSpyPrivate; - -class MetaNotificationSpy -{ -public: - explicit MetaNotificationSpy(); - explicit MetaNotificationSpy( const Meta::TrackPtr &track ); - explicit MetaNotificationSpy( const Meta::ArtistPtr &artist ); - explicit MetaNotificationSpy( const Meta::AlbumPtr &album ); - explicit MetaNotificationSpy( const Meta::GenrePtr &genre ); - explicit MetaNotificationSpy( const Meta::ComposerPtr &composer ); - explicit MetaNotificationSpy( const Meta::YearPtr &year ); - ~ MetaNotificationSpy(); - - void subscribeTo( const Meta::TrackPtr &track ); - void subscribeTo( const Meta::AlbumPtr &album ); - void subscribeTo( const Meta::ArtistPtr &artist ); - void subscribeTo( const Meta::GenrePtr &genre ); - void subscribeTo( const Meta::YearPtr &year ); - void subscribeTo( const Meta::ComposerPtr &composer ); - - Meta::TrackList notificationsFromTracks() const; - Meta::AlbumList notificationsFromAlbums() const; - Meta::ArtistList notificationsFromArtists() const; - Meta::GenreList notificationsFromGenres() const; - Meta::YearList notificationsFromYears() const; - Meta::ComposerList notificationsFromComposers() const; - -private: - MetaNotificationSpyPrivate * const d; -}; - -#endif // METANOTIFICATIONSPY_H diff --git a/amarok/tests/TestAmarok.cpp b/amarok/tests/TestAmarok.cpp deleted file mode 100644 index e9c35199..00000000 --- a/amarok/tests/TestAmarok.cpp +++ /dev/null @@ -1,341 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2009 Sven Krohlas * - * * - * This program 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 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#include "TestAmarok.h" -#include "core/support/Amarok.h" -#include "config-amarok-test.h" - -#include -#include -#include - -#include - -QTEST_KDEMAIN_CORE( TestAmarok ) - -TestAmarok::TestAmarok() -{} - -QString -TestAmarok::dataPath( const QString &relPath ) -{ - return QDir::toNativeSeparators( QString( AMAROK_TEST_DIR ) + '/' + relPath ); -} - -void TestAmarok::testAsciiPath() -{ - QCOMPARE( Amarok::asciiPath( "" ), QString( "" ) ); - QCOMPARE( Amarok::asciiPath( "/home/sven" ), QString( "/home/sven" ) ); - - QCOMPARE( Amarok::asciiPath( QString::fromUtf8( "/äöü" ) ), QString( "/___" ) ); - QCOMPARE( Amarok::asciiPath( QString::fromUtf8( "/äöütest" ) ), QString( "/___test" ) ); - QCOMPARE( Amarok::asciiPath( QString::fromUtf8( "/äöü/test" ) ), QString( "/___/test" ) ); - QCOMPARE( Amarok::asciiPath( QString::fromUtf8( "/123/" ) ), QString( "/123/" ) ); - QCOMPARE( Amarok::asciiPath( QString::fromUtf8( "/.hidden" ) ), QString( "/.hidden" ) ); - QCOMPARE( Amarok::asciiPath( QString::fromUtf8( "/here be dragons" ) ), QString( "/here be dragons" ) ); - QCOMPARE( Amarok::asciiPath( QString::fromUtf8( "/!important/some%20stuff/what's this?" ) ), QString( "/!important/some%20stuff/what's this?" ) ); - - /* 0x7F = 127 = DEL control character, explicitly ok on *nix file systems */ - QCOMPARE( Amarok::asciiPath( QString( "/abc" ) + QChar( 0x7F ) + ".1" ), QString( QString( "/abc" ) + QChar( 0x7F ) + ".1" ) ); - - /* random control character: ok */ - QCOMPARE( Amarok::asciiPath( QString( "/abc" ) + QChar( 0x07 ) + ".1" ), QString( QString( "/abc" ) + QChar( 0x07 ) + ".1" ) ); - - /* null byte is not ok */ - QCOMPARE( Amarok::asciiPath( QString( "/abc" ) + QChar( 0x00 ) + ".1" ), QString( "/abc_.1" ) ); -} - -void TestAmarok::testCleanPath() -{ - /* no changes expected here */ - QCOMPARE( Amarok::cleanPath( QString( "" ) ), QString( "" ) ); - QCOMPARE( Amarok::cleanPath( QString( "abcdefghijklmnopqrstuvwxyz" ) ), QString( "abcdefghijklmnopqrstuvwxyz" ) ); - QCOMPARE( Amarok::cleanPath( QString( "ABCDEFGHIJKLMNOPQRSTUVWXYZ" ) ), QString( "ABCDEFGHIJKLMNOPQRSTUVWXYZ" ) ); - QCOMPARE( Amarok::cleanPath( QString( "/\\.,-+" ) ), QString( "/\\.,-+" ) ); - - /* German */ - QCOMPARE( Amarok::cleanPath( QString::fromUtf8( "äöüß" ) ), QString( "aeoeuess" ) ); - QCOMPARE( Amarok::cleanPath( QString::fromUtf8( "ÄÖÜß" ) ), QString( "AeOeUess" ) ); // capital ß only exists in theory in the German language, but had been defined some time ago, iirc - - /* French */ - QCOMPARE( Amarok::cleanPath( QString::fromUtf8( "áàéèêô" ) ), QString( "aaeeeo" ) ); - QCOMPARE( Amarok::cleanPath( QString::fromUtf8( "ÁÀÉÈÊÔ" ) ), QString( "AAEEEO" ) ); - QCOMPARE( Amarok::cleanPath( QString::fromUtf8( "æ" ) ), QString( "ae" ) ); - QCOMPARE( Amarok::cleanPath( QString::fromUtf8( "Æ" ) ), QString( "AE" ) ); - - /* Czech and other east European languages */ - QCOMPARE( Amarok::cleanPath( QString::fromUtf8( "çńǹýỳź" ) ), QString( "cnnyyz" ) ); - QCOMPARE( Amarok::cleanPath( QString::fromUtf8( "ÇŃǸÝỲŹ" ) ), QString( "CNNYYZ" ) ); - QCOMPARE( Amarok::cleanPath( QString::fromUtf8( "ěĺľôŕřůž" ) ), QString( "ellorruz" ) ); - QCOMPARE( Amarok::cleanPath( QString::fromUtf8( "ÁČĎÉĚÍŇÓŘŠŤÚŮÝŽ" ) ), QString( "ACDEEINORSTUUYZ" ) ); - - /* Skandinavian languages */ - QCOMPARE( Amarok::cleanPath( QString::fromUtf8( "åø" ) ), QString( "aoe" ) ); - QCOMPARE( Amarok::cleanPath( QString::fromUtf8( "ÅØ" ) ), QString( "AOE" ) ); - - /* Spanish */ - QCOMPARE( Amarok::cleanPath( QString::fromUtf8( "ñóÿ" ) ), QString( "noy" ) ); - QCOMPARE( Amarok::cleanPath( QString::fromUtf8( "ÑÓŸ" ) ), QString( "NOY" ) ); - - /* add missing ones here */ -} - -void TestAmarok::testComputeScore() -{ - QVERIFY( 50 < Amarok::computeScore( 50, 1, 1 ) ); // greater score if played completely - QVERIFY( 0 < Amarok::computeScore( 0, 1, 1 ) ); // handle 0 score - QVERIFY( 50 > Amarok::computeScore( 50, 1, 0.1 ) ); // lower score if aborted early - QVERIFY( 50 > Amarok::computeScore( 50, 1, 0 ) ); // handle 0% played fraction - QVERIFY( 50 > Amarok::computeScore( 50, 0, 0 ) ); // handle 0 playcount -} - -void TestAmarok::testConciseTimeSince() -{ - QCOMPARE( Amarok::conciseTimeSince( 0 ).isEmpty(), false ); - QCOMPARE( Amarok::conciseTimeSince( 10 ).isEmpty(), false ); - QCOMPARE( Amarok::conciseTimeSince( 100 ).isEmpty(), false ); - QCOMPARE( Amarok::conciseTimeSince( 1000 ).isEmpty(), false ); - /* any other good ideas what to test here? */ -} - - -void TestAmarok::testExtension() -{ - QCOMPARE( Amarok::extension( "" ), QString( "" ) ); - QCOMPARE( Amarok::extension( "..." ), QString( "" ) ); - QCOMPARE( Amarok::extension( "test" ), QString( "" ) ); - QCOMPARE( Amarok::extension( "test." ), QString( "" ) ); - QCOMPARE( Amarok::extension( "test.mp3" ), QString( "mp3" ) ); - QCOMPARE( Amarok::extension( "test.mP3" ), QString( "mp3" ) ); - QCOMPARE( Amarok::extension( "test.MP3" ), QString( "mp3" ) ); - QCOMPARE( Amarok::extension( "test.longextension" ), QString( "longextension" ) ); - QCOMPARE( Amarok::extension( "test.long.extension" ), QString( "extension" ) ); - QCOMPARE( Amarok::extension( "test.m" ), QString( "m" ) ); - QCOMPARE( Amarok::extension( QString::fromUtf8( "test.äöü" ) ), QString::fromUtf8( "äöü" ) ); - QCOMPARE( Amarok::extension( QString::fromUtf8( "test.ÄÖÜ" ) ), QString::fromUtf8( "äöü" ) ); - QCOMPARE( Amarok::extension( "..test.mp3" ), QString( "mp3" ) ); - QCOMPARE( Amarok::extension( "..te st.mp3" ), QString( "mp3" ) ); - QCOMPARE( Amarok::extension( "..te st.m p3" ), QString( "m p3" ) ); -} - -void TestAmarok::testManipulateThe() -{ - QString teststring; - - Amarok::manipulateThe( teststring = "", true ); - QCOMPARE( teststring, QString( "" ) ); - - Amarok::manipulateThe( teststring = "", false ); - QCOMPARE( teststring, QString( "" ) ); - - Amarok::manipulateThe( teststring = 'A', true ); - QCOMPARE( teststring, QString( "A" ) ); - - Amarok::manipulateThe( teststring = 'A', false ); - QCOMPARE( teststring, QString( "A" ) ); - - Amarok::manipulateThe( teststring = "ABC", true ); - QCOMPARE( teststring, QString( "ABC" ) ); - - Amarok::manipulateThe( teststring = "ABC", false ); - QCOMPARE( teststring, QString( "ABC" ) ); - - Amarok::manipulateThe( teststring = "The Eagles", true ); - QCOMPARE( teststring, QString( "Eagles, The" ) ); - - Amarok::manipulateThe( teststring = "Eagles, The", false ); - QCOMPARE( teststring, QString( "The Eagles" ) ); - - Amarok::manipulateThe( teststring = "The The", true ); - QCOMPARE( teststring, QString( "The, The" ) ); - - Amarok::manipulateThe( teststring = "The, The", false ); - QCOMPARE( teststring, QString( "The The" ) ); - - Amarok::manipulateThe( teststring = "Something else", true ); - QCOMPARE( teststring, QString( "Something else" ) ); - - Amarok::manipulateThe( teststring = "The Äöü", true ); - QCOMPARE( teststring, QString( "Äöü, The" ) ); - - Amarok::manipulateThe( teststring = QString::fromUtf8( "Äöü, The" ), false ); - QCOMPARE( teststring, QString::fromUtf8( "The Äöü" ) ); -} - -void TestAmarok::testSaveLocation() -{ - QString saveLocation = Amarok::saveLocation(); - QDir saveLocationDir( saveLocation ); - - QCOMPARE( saveLocationDir.exists(), true ); - QCOMPARE( QDir::isAbsolutePath( saveLocation ), true ); - QCOMPARE( saveLocationDir.isReadable(), true ); - /* any other good ideas what to test here? */ -} - -void TestAmarok::testVerboseTimeSince() -{ - /* There are two overloaded variants of this function */ - QCOMPARE( Amarok::verboseTimeSince( 0 ).isEmpty(), false ); - QCOMPARE( Amarok::verboseTimeSince( QDateTime::fromTime_t( 0 ) ).isEmpty(), false ); - - QCOMPARE( Amarok::verboseTimeSince( 10 ).isEmpty(), false ); - QCOMPARE( Amarok::verboseTimeSince( QDateTime::fromTime_t( 10 ) ).isEmpty(), false ); - - QCOMPARE( Amarok::verboseTimeSince( 100 ).isEmpty(), false ); - QCOMPARE( Amarok::verboseTimeSince( QDateTime::fromTime_t( 100 ) ).isEmpty(), false ); - - QCOMPARE( Amarok::verboseTimeSince( 1000 ).isEmpty(), false ); - QCOMPARE( Amarok::verboseTimeSince( QDateTime::fromTime_t( 1000 ) ).isEmpty(), false ); - /* any other good ideas what to test here? */ -} - -void TestAmarok::testVfatPath() -{ - QCOMPARE( Amarok::vfatPath( "" ), QString( "" ) ); - - /* allowed characters */ - QCOMPARE( Amarok::vfatPath( "abcdefghijklmnopqrstuvwxyz" ), QString( "abcdefghijklmnopqrstuvwxyz" ) ); - QCOMPARE( Amarok::vfatPath( "ABCDEFGHIJKLMNOPQRSTUVWXYZ" ), QString( "ABCDEFGHIJKLMNOPQRSTUVWXYZ" ) ); - QCOMPARE( Amarok::vfatPath( "0123456789" ), QString( "0123456789" ) ); - QCOMPARE( Amarok::vfatPath( "! # $ % & ' ( ) - @ ^ _ ` { } ~" ), QString( "! # $ % & ' ( ) - @ ^ _ ` { } ~" ) ); - - /* only allowed in long file names */ - QCOMPARE( Amarok::vfatPath( "+,.;=[]" ), QString( "+,.;=()" ) ); - - /* illegal characters, without / and \ (see later tests) */ - QCOMPARE( Amarok::vfatPath( "\"_*_:_<_>_?_|" ), QString( "_____________" ) ); - - /* illegal control characters: 0-31, 127 */ - QCOMPARE( Amarok::vfatPath( QString( "abc" ) + QChar( 0x00 ) + QChar( 0x01 ) + QChar( 0x02 ) + ".1" ), QString( "abc___.1" ) ); - QCOMPARE( Amarok::vfatPath( QString( "abc" ) + QChar( 0x03 ) + QChar( 0x04 ) + QChar( 0x05 ) + ".1" ), QString( "abc___.1" ) ); - QCOMPARE( Amarok::vfatPath( QString( "abc" ) + QChar( 0x06 ) + QChar( 0x07 ) + QChar( 0x08 ) + ".1" ), QString( "abc___.1" ) ); - QCOMPARE( Amarok::vfatPath( QString( "abc" ) + QChar( 0x09 ) + QChar( 0x0A ) + QChar( 0x0B ) + ".1" ), QString( "abc___.1" ) ); - QCOMPARE( Amarok::vfatPath( QString( "abc" ) + QChar( 0x0C ) + QChar( 0x0D ) + QChar( 0x0E ) + ".1" ), QString( "abc___.1" ) ); - - QCOMPARE( Amarok::vfatPath( QString( "abc" ) + QChar( 0x0F ) + QChar( 0x10 ) + QChar( 0x11 ) + ".1" ), QString( "abc___.1" ) ); - QCOMPARE( Amarok::vfatPath( QString( "abc" ) + QChar( 0x12 ) + QChar( 0x13 ) + QChar( 0x14 ) + ".1" ), QString( "abc___.1" ) ); - QCOMPARE( Amarok::vfatPath( QString( "abc" ) + QChar( 0x15 ) + QChar( 0x16 ) + QChar( 0x17 ) + ".1" ), QString( "abc___.1" ) ); - QCOMPARE( Amarok::vfatPath( QString( "abc" ) + QChar( 0x18 ) + QChar( 0x19 ) + QChar( 0x1A ) + ".1" ), QString( "abc___.1" ) ); - QCOMPARE( Amarok::vfatPath( QString( "abc" ) + QChar( 0x1B ) + QChar( 0x1C ) + QChar( 0x1D ) + ".1" ), QString( "abc___.1" ) ); - QCOMPARE( Amarok::vfatPath( QString( "abc" ) + QChar( 0x1E ) + QChar( 0x7F ) + ".1" ), QString( "abc__.1" ) ); // 0x7F = 127 = DEL control character - - /* trailing spaces in extension, directory and file names are being ignored (!) */ - QCOMPARE( Amarok::vfatPath( "test " ), QString( "test _" ) ); - QCOMPARE( Amarok::vfatPath( " test " ), QString( " test _" ) ); - QCOMPARE( Amarok::vfatPath( "test.ext " ), QString( "test.ext _" ) ); - QCOMPARE( Amarok::vfatPath( "test .ext " ), QString( "test _.ext _" ) ); - QCOMPARE( Amarok::vfatPath( " test .ext " ), QString( " test _.ext _" ) ); // yes, really! - -#ifdef Q_WS_WIN // interpret / as part of the name, not directory separator - QCOMPARE( Amarok::vfatPath( "\\some\\folder \\" ), QString( "\\some\\folder _\\" ) ); - QCOMPARE( Amarok::vfatPath( "\\some \\folder \\" ), QString( "\\some _\\folder _\\" ) ); - QCOMPARE( Amarok::vfatPath( "\\...some \\ev il \\folders...\\" ), QString( "\\...some _\\ev il _\\folders...\\" ) ); - QCOMPARE( Amarok::vfatPath( "\\some\\fol/der \\" ), QString( "\\some\\fol_der _\\" ) ); -#else // interpret \ as part of the name, not directory separator - QCOMPARE( Amarok::vfatPath( "/some/folder /" ), QString( "/some/folder _/" ) ); - QCOMPARE( Amarok::vfatPath( "/some /folder /" ), QString( "/some _/folder _/" ) ); - QCOMPARE( Amarok::vfatPath( "/...some /ev il /folders.../" ), QString( "/...some _/ev il _/folders.../" ) ); - QCOMPARE( Amarok::vfatPath( "/some/fol\\der /" ), QString( "/some/fol_der _/" ) ); -#endif - - /* Stepping deeper into M$ hell: reserved device names - * See http://msdn.microsoft.com/en-us/library/aa365247(VS.85).aspx */ - QCOMPARE( Amarok::vfatPath( "CLOCK$" ), QString( "_CLOCK$" ) ); - /* this one IS allowed according to - * http://en.wikipedia.org/w/index.php?title=Filename&oldid=303934888#Comparison_of_file_name_limitations */ - QCOMPARE( Amarok::vfatPath( "CLOCK$.ext" ), QString( "CLOCK$.ext" ) ); - - QCOMPARE( Amarok::vfatPath( "CON" ), QString( "_CON" ) ); - QCOMPARE( Amarok::vfatPath( "CON.ext" ), QString( "_CON.ext" ) ); - - QCOMPARE( Amarok::vfatPath( "PRN" ), QString( "_PRN" ) ); - QCOMPARE( Amarok::vfatPath( "PRN.ext" ), QString( "_PRN.ext" ) ); - - QCOMPARE( Amarok::vfatPath( "AUX" ), QString( "_AUX" ) ); - QCOMPARE( Amarok::vfatPath( "AUX.ext" ), QString( "_AUX.ext" ) ); - - QCOMPARE( Amarok::vfatPath( "NUL" ), QString( "_NUL" ) ); - QCOMPARE( Amarok::vfatPath( "NUL.ext" ), QString( "_NUL.ext" ) ); - - QCOMPARE( Amarok::vfatPath( "COM1" ), QString( "_COM1" ) ); - QCOMPARE( Amarok::vfatPath( "COM1.ext" ), QString( "_COM1.ext" ) ); - - QCOMPARE( Amarok::vfatPath( "COM2" ), QString( "_COM2" ) ); - QCOMPARE( Amarok::vfatPath( "COM2.ext" ), QString( "_COM2.ext" ) ); - - QCOMPARE( Amarok::vfatPath( "COM3" ), QString( "_COM3" ) ); - QCOMPARE( Amarok::vfatPath( "COM3.ext" ), QString( "_COM3.ext" ) ); - - QCOMPARE( Amarok::vfatPath( "COM4" ), QString( "_COM4" ) ); - QCOMPARE( Amarok::vfatPath( "COM4.ext" ), QString( "_COM4.ext" ) ); - - QCOMPARE( Amarok::vfatPath( "COM5" ), QString( "_COM5" ) ); - QCOMPARE( Amarok::vfatPath( "COM5.ext" ), QString( "_COM5.ext" ) ); - - QCOMPARE( Amarok::vfatPath( "COM6" ), QString( "_COM6" ) ); - QCOMPARE( Amarok::vfatPath( "COM6.ext" ), QString( "_COM6.ext" ) ); - - QCOMPARE( Amarok::vfatPath( "COM7" ), QString( "_COM7" ) ); - QCOMPARE( Amarok::vfatPath( "COM7.ext" ), QString( "_COM7.ext" ) ); - - QCOMPARE( Amarok::vfatPath( "COM8" ), QString( "_COM8" ) ); - QCOMPARE( Amarok::vfatPath( "COM8.ext" ), QString( "_COM8.ext" ) ); - - QCOMPARE( Amarok::vfatPath( "COM9" ), QString( "_COM9" ) ); - QCOMPARE( Amarok::vfatPath( "COM9.ext" ), QString( "_COM9.ext" ) ); - - QCOMPARE( Amarok::vfatPath( "LPT1" ), QString( "_LPT1" ) ); - QCOMPARE( Amarok::vfatPath( "LPT1.ext" ), QString( "_LPT1.ext" ) ); - - QCOMPARE( Amarok::vfatPath( "LPT2" ), QString( "_LPT2" ) ); - QCOMPARE( Amarok::vfatPath( "LPT2.ext" ), QString( "_LPT2.ext" ) ); - - QCOMPARE( Amarok::vfatPath( "LPT3" ), QString( "_LPT3" ) ); - QCOMPARE( Amarok::vfatPath( "LPT3.ext" ), QString( "_LPT3.ext" ) ); - - QCOMPARE( Amarok::vfatPath( "LPT4" ), QString( "_LPT4" ) ); - QCOMPARE( Amarok::vfatPath( "LPT4.ext" ), QString( "_LPT4.ext" ) ); - - QCOMPARE( Amarok::vfatPath( "LPT5" ), QString( "_LPT5" ) ); - QCOMPARE( Amarok::vfatPath( "LPT5.ext" ), QString( "_LPT5.ext" ) ); - - QCOMPARE( Amarok::vfatPath( "LPT6" ), QString( "_LPT6" ) ); - QCOMPARE( Amarok::vfatPath( "LPT6.ext" ), QString( "_LPT6.ext" ) ); - - QCOMPARE( Amarok::vfatPath( "LPT7" ), QString( "_LPT7" ) ); - QCOMPARE( Amarok::vfatPath( "LPT7.ext" ), QString( "_LPT7.ext" ) ); - - QCOMPARE( Amarok::vfatPath( "LPT8" ), QString( "_LPT8" ) ); - QCOMPARE( Amarok::vfatPath( "LPT8.ext" ), QString( "_LPT8.ext" ) ); - - QCOMPARE( Amarok::vfatPath( "LPT9" ), QString( "_LPT9" ) ); - QCOMPARE( Amarok::vfatPath( "LPT9.ext" ), QString( "_LPT9.ext" ) ); - - /* Device names in different cases: */ - QCOMPARE( Amarok::vfatPath( "con" ), QString( "_con" ) ); - QCOMPARE( Amarok::vfatPath( "con.ext" ), QString( "_con.ext" ) ); - - QCOMPARE( Amarok::vfatPath( "cON" ), QString( "_cON" ) ); - QCOMPARE( Amarok::vfatPath( "cON.ext" ), QString( "_cON.ext" ) ); - - /* This one is ok :) */ - QCOMPARE( Amarok::vfatPath( "CONCERT" ), QString( "CONCERT" ) ); - QCOMPARE( Amarok::vfatPath( "CONCERT.ext" ), QString( "CONCERT.ext" ) ); -} diff --git a/amarok/tests/TestAmarok.h b/amarok/tests/TestAmarok.h deleted file mode 100644 index 2db85091..00000000 --- a/amarok/tests/TestAmarok.h +++ /dev/null @@ -1,47 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2009 Sven Krohlas * - * * - * This program 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 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#ifndef TESTAMAROK_H -#define TESTAMAROK_H - -#include - -class TestAmarok : public QObject -{ -Q_OBJECT - -public: - TestAmarok(); - -private slots: - void testAsciiPath(); - void testCleanPath(); - void testComputeScore(); - void testConciseTimeSince(); - void testExtension(); - void testManipulateThe(); - void testSaveLocation(); - void testVerboseTimeSince(); - void testVfatPath(); - -private: - QString dataPath( const QString &relPath ); -}; - -#endif // TESTAMAROK_H diff --git a/amarok/tests/TestCaseConverter.cpp b/amarok/tests/TestCaseConverter.cpp deleted file mode 100644 index a0a0be12..00000000 --- a/amarok/tests/TestCaseConverter.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2009 Sven Krohlas * - * * - * This program 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 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#include "TestCaseConverter.h" - -#include "CaseConverter.h" - -#include - -#include - -QTEST_KDEMAIN_CORE( TestCaseConverter ) - -TestCaseConverter::TestCaseConverter() -{ -} - -void TestCaseConverter::testToCapitalizedCase() -{ - QCOMPARE( Amarok::CaseConverter::toCapitalizedCase( "" ), QString( "" ) ); - - QCOMPARE( Amarok::CaseConverter::toCapitalizedCase( "A" ), QString( "A" ) ); - QCOMPARE( Amarok::CaseConverter::toCapitalizedCase( "a" ), QString( "A" ) ); - QCOMPARE( Amarok::CaseConverter::toCapitalizedCase( "A tale of true love" ), QString( "A Tale Of True Love" ) ); - QCOMPARE( Amarok::CaseConverter::toCapitalizedCase( "A horse with no name" ), QString( "A Horse With No Name" ) ); - QCOMPARE( Amarok::CaseConverter::toCapitalizedCase( "riding on a dead horse" ), QString( "Riding On A Dead Horse" ) ); - // ätest -> Ätest - QCOMPARE( Amarok::CaseConverter::toCapitalizedCase( QChar( 0x00E4 ) + QString( "test" ) ), QChar( 0x00C4 ) + QString( "test" ) ); - QCOMPARE( Amarok::CaseConverter::toCapitalizedCase( "a an in of on" ), QString( "A An In Of On" ) ); -} - -void TestCaseConverter::testToTitleCase() -{ - QCOMPARE( Amarok::CaseConverter::toTitleCase( "" ), QString( "" ) ); - - QCOMPARE( Amarok::CaseConverter::toTitleCase( "A" ), QString( "A" ) ); - QCOMPARE( Amarok::CaseConverter::toTitleCase( "a" ), QString( "A" ) ); - QCOMPARE( Amarok::CaseConverter::toTitleCase( "a tale of true love" ), QString( "A Tale of True Love" ) ); - QCOMPARE( Amarok::CaseConverter::toTitleCase( "a horse with no name" ), QString( "A Horse With No Name" ) ); - QCOMPARE( Amarok::CaseConverter::toTitleCase( "riding on a dead horse" ), QString( "Riding on a Dead Horse" ) ); - // ätest -> Ätest - QCOMPARE( Amarok::CaseConverter::toTitleCase( QChar( 0x00E4 ) + QString( "test" ) ), QChar( 0x00C4 ) + QString( "test" ) ); - QCOMPARE( Amarok::CaseConverter::toTitleCase( "a a an in of on" ), QString( "A a an in of on" ) ); -} diff --git a/amarok/tests/TestCaseConverter.h b/amarok/tests/TestCaseConverter.h deleted file mode 100644 index 48f33c89..00000000 --- a/amarok/tests/TestCaseConverter.h +++ /dev/null @@ -1,37 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2009 Sven Krohlas * - * * - * This program 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 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#ifndef TESTCASECONVERTER_H -#define TESTCASECONVERTER_H - -#include - -class TestCaseConverter : public QObject -{ -Q_OBJECT - -public: - TestCaseConverter(); - -private slots: - void testToCapitalizedCase(); - void testToTitleCase(); -}; - -#endif // TESTCASECONVERTER_H diff --git a/amarok/tests/TestDebug.cpp b/amarok/tests/TestDebug.cpp deleted file mode 100644 index f0906616..00000000 --- a/amarok/tests/TestDebug.cpp +++ /dev/null @@ -1,170 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2010 Rick W. Chen * - * * - * This program 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 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#define DEBUG_PREFIX "TestDebug" - -#include "core/support/Debug.h" -#include "config-amarok-test.h" - -#include -#include - -class TestDebug : public QObject -{ -Q_OBJECT - -public: - TestDebug() {} - -private slots: - void benchDebugBlock(); - void benchDebugBlock_data(); - -private: - void work( bool debugEnabled, bool colorEnabled ); - void work2( bool debugEnabled, bool colorEnabled ); - - enum BeginOrEnd { - Begin, - End - }; - void expectMessage( const QString &message, bool debugEnabled ); - void expectBeginEnd( BeginOrEnd type, const QString &message, bool debugEnabled, - bool colorEnabled ); - QString colorize( const QString &string, int colorIndex, bool colorEnabled ); - - static QString m_indent; -}; - -QString TestDebug::m_indent; - -void TestDebug::benchDebugBlock_data() -{ - QTest::addColumn("debugEnabled"); - QTest::addColumn("colorEnabled"); - - QTest::newRow("debug with color") << true << true; - QTest::newRow("debug nocolor") << true << false; - QTest::newRow("nodebug with color") << false << true; - QTest::newRow("nodebug nocolor") << false << false; -} - -void TestDebug::benchDebugBlock() -{ - QFETCH(bool, debugEnabled); - QFETCH(bool, colorEnabled); - - Debug::setDebugEnabled( debugEnabled ); - Debug::setColoredDebug( colorEnabled ); - - QVERIFY( Debug::debugEnabled() == debugEnabled ); - QVERIFY( Debug::debugColorEnabled() == colorEnabled ); - - QBENCHMARK_ONCE { - work( debugEnabled, colorEnabled ); - } -} - -void TestDebug::work( bool debugEnabled, bool colorEnabled ) -{ - expectBeginEnd( Begin, __PRETTY_FUNCTION__, debugEnabled, colorEnabled ); - DEBUG_BLOCK - expectMessage( "level 1", debugEnabled ); - debug() << "level 1"; - - for( int i = 0; i < 100; ++i ) - { - expectBeginEnd( Begin, __PRETTY_FUNCTION__, debugEnabled, colorEnabled ); - DEBUG_BLOCK - expectMessage( "level 2", debugEnabled ); - debug() << "level 2"; - work2( debugEnabled, colorEnabled ); - expectBeginEnd( End, __PRETTY_FUNCTION__, debugEnabled, colorEnabled ); - } - expectBeginEnd( End, __PRETTY_FUNCTION__, debugEnabled, colorEnabled ); -} - -void TestDebug::work2( bool debugEnabled, bool colorEnabled ) -{ - expectBeginEnd( Begin, __PRETTY_FUNCTION__, debugEnabled, colorEnabled ); - DEBUG_BLOCK - for( int j = 0; j < 10; ++j ) - { - expectMessage( "limbo", debugEnabled ); - debug() << "limbo"; - } - expectBeginEnd( End, __PRETTY_FUNCTION__, debugEnabled, colorEnabled ); -} - -void -TestDebug::expectMessage( const QString &message, bool debugEnabled ) -{ - if( !debugEnabled ) - return; - QString exp = QString( "%1:%2 [%3] %4 " ).arg( "amarok", m_indent, DEBUG_PREFIX, message ); - QTest::ignoreMessage( QtDebugMsg, exp.toLocal8Bit() ); -} - -void -TestDebug::expectBeginEnd( TestDebug::BeginOrEnd type, const QString &message, - bool debugEnabled, bool colorEnabled ) -{ - static int colorIndex = 0; - static QStack colorStack; - if( !debugEnabled ) - return; - - QString beginEnd; - QString took; - if( type == Begin ) - { - beginEnd = "BEGIN:"; - colorStack.push( colorIndex ); - colorIndex = (colorIndex + 1) % 5; - } - else - { - beginEnd = "END__:"; - double duration = DEBUG_OVERRIDE_ELAPSED_TIME; - took = ' ' + colorize( QString( "[Took: %1s]" ).arg( duration, 0, 'g', 2 ), - colorStack.top(), colorEnabled ); - m_indent.truncate( m_indent.length() - 2 ); - } - QString exp = QString( "%1:%2 %3 %4%5 " ).arg( "amarok", m_indent, colorize( beginEnd, - colorStack.top(), colorEnabled ), message, took ); - QTest::ignoreMessage( QtDebugMsg, exp.toLocal8Bit() ); - if( type == Begin ) - m_indent.append( " " ); - else - colorStack.pop(); -} - -QString -TestDebug::colorize( const QString &string, int colorIndex, bool colorEnabled ) -{ - static int colors[] = { 1, 2, 4, 5, 6 }; // from Debug.cpp - if( !colorEnabled ) - return string; - return QString( "\x1b[00;3%1m%2\x1b[00;39m" ).arg( QString::number(colors[colorIndex]), string ); -} - - -QTEST_MAIN( TestDebug ) - -#include "TestDebug.moc" diff --git a/amarok/tests/TestEngineController.cpp b/amarok/tests/TestEngineController.cpp deleted file mode 100644 index 74124b2b..00000000 --- a/amarok/tests/TestEngineController.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "TestEngineController.h" - -#include "EngineController.h" -#include "core/support/Components.h" - -#include -#include -#include - -#include - -QTEST_KDEMAIN_CORE( TestEngineController ) - -class CallSupportedMimeTypesJob : public ThreadWeaver::Job -{ - protected: - void run() - { - EngineController *ec = Amarok::Components::engineController(); - QVERIFY( ec ); - QStringList types = ec->supportedMimeTypes(); - QVERIFY( !types.isEmpty() ); - } -}; - -void -TestEngineController::init() -{ - // the test depend on EngineController being used for the first time - QVERIFY( Amarok::Components::engineController() == 0 ); - Amarok::Components::setEngineController( new EngineController() ); -} - -void -TestEngineController::cleanup() -{ - // we cannot simply call WeaverInterface::finish(), it stops event loop - if( !ThreadWeaver::Weaver::instance()->isIdle() ) - QVERIFY2( QTest::kWaitForSignal( ThreadWeaver::Weaver::instance(), - SIGNAL(finished()), 5000 ), "threads did not finish in timeout" ); - delete Amarok::Components::setEngineController( 0 ); -} - -void -TestEngineController::testSupportedMimeTypesInMainThread() -{ - EngineController *ec = Amarok::Components::engineController(); - QVERIFY( ec ); - QStringList types = ec->supportedMimeTypes(); - QVERIFY( !types.isEmpty() ); -} - -void -TestEngineController::testSupportedMimeTypesInAnotherThread() -{ - ThreadWeaver::Job *job = new CallSupportedMimeTypesJob(); - ThreadWeaver::Weaver::instance()->enqueue( job ); -} diff --git a/amarok/tests/TestEngineController.h b/amarok/tests/TestEngineController.h deleted file mode 100644 index 66735c15..00000000 --- a/amarok/tests/TestEngineController.h +++ /dev/null @@ -1,34 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Matěj Laitl * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef TESTENGINECONTROLLER_H -#define TESTENGINECONTROLLER_H - -#include - -class TestEngineController : public QObject -{ - Q_OBJECT - - private slots: - void init(); // called before each test - void cleanup(); // called after each test - - void testSupportedMimeTypesInMainThread(); - void testSupportedMimeTypesInAnotherThread(); -}; - -#endif // TESTENGINECONTROLLER_H diff --git a/amarok/tests/TestExpression.cpp b/amarok/tests/TestExpression.cpp deleted file mode 100644 index 594642b1..00000000 --- a/amarok/tests/TestExpression.cpp +++ /dev/null @@ -1,152 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2009 Sven Krohlas * - * * - * This program 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 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#include "TestExpression.h" - -#include "core/support/Debug.h" -#include "core-impl/collections/support/Expression.h" - -#include - -#include - -QTEST_KDEMAIN_CORE( TestExpression ) - -//required for Debug.h -QMutex Debug::mutex; - -TestExpression::TestExpression() -{ -} - -void TestExpression::testParse() -{ - ParsedExpression result; - expression_element element; - result = ExpressionParser::parse( "" ); - QCOMPARE( result.isEmpty(), true ); - - result = ExpressionParser::parse( "love artist:cure album:\"Best of\" year:<1990 playcount:>2 -score:<50" ); - int i = 6; - QCOMPARE( result.size(), i ); - - while( !result.isEmpty() ) - { - element = result.takeFirst().takeFirst(); - - if( element.text == "love" ) - { - QCOMPARE( element.field, QString( "" ) ); - QCOMPARE( element.negate, false ); - QVERIFY( element.match == expression_element::Contains ); - } - - else if( element.text == "cure" ) - { - QCOMPARE( element.field, QString( "artist" ) ); - QCOMPARE( element.negate, false ); - QVERIFY( element.match == expression_element::Contains ); - } - - else if( element.text == "Best of" ) - { - QCOMPARE( element.field, QString( "album" ) ); - QCOMPARE( element.negate, false ); - QVERIFY( element.match == expression_element::Contains ); - } - - else if( element.text == "1990" ) - { - QCOMPARE( element.field, QString( "year" ) ); - QCOMPARE( element.negate, false ); - QVERIFY( element.match == expression_element::Less ); - } - - else if( element.text == "2" ) - { - QCOMPARE( element.field, QString( "playcount" ) ); - QCOMPARE( element.negate, false ); - QVERIFY( element.match == expression_element::More ); - } - - else if( element.text == "50" ) - { - QCOMPARE( element.field, QString( "score" ) ); - QCOMPARE( element.negate, true ); - QVERIFY( element.match == expression_element::Less ); - } - - i--; - QCOMPARE( result.size(), i ); - } - - /* another more complex one */ - result = ExpressionParser::parse( "artist:cure OR album:\"Best of\" OR year:2009" ); - i = 1; - QCOMPARE( result.size(), i ); // only 1 or_list - - QList elementList; - - if( !result.isEmpty() ) - elementList = result.at(0); - - QCOMPARE( elementList.size(), 3 ); - - while( !elementList.isEmpty() ) - { - element = elementList.takeFirst(); - - if( element.text == "cure" ) - { - QCOMPARE( element.field, QString( "artist" ) ); - QCOMPARE( element.negate, false ); - QVERIFY( element.match == expression_element::Contains ); - } - - else if( element.text == "Best of" ) - { - QCOMPARE( element.field, QString( "album" ) ); - QCOMPARE( element.negate, false ); - QVERIFY( element.match == expression_element::Contains ); - } - - else if( element.text == "2009" ) - { - QCOMPARE( element.field, QString( "year" ) ); - QCOMPARE( element.negate, false ); - QVERIFY( element.match == expression_element::Contains ); - } - } -} - -void TestExpression::testIsAdvancedExpression() -{ - QCOMPARE( ExpressionParser::isAdvancedExpression( "" ), false ); - - QCOMPARE( ExpressionParser::isAdvancedExpression( "test" ), false ); - QCOMPARE( ExpressionParser::isAdvancedExpression( "foo bar" ), false ); - QCOMPARE( ExpressionParser::isAdvancedExpression( "\"foo bar\"" ), true ); - QCOMPARE( ExpressionParser::isAdvancedExpression( "artist:cure" ), true ); - QCOMPARE( ExpressionParser::isAdvancedExpression( "year:<1990" ), true ); - QCOMPARE( ExpressionParser::isAdvancedExpression( "artist:cure year:<1990" ), true ); - QCOMPARE( ExpressionParser::isAdvancedExpression( "artist:cure AND year:<1990" ), true ); - QCOMPARE( ExpressionParser::isAdvancedExpression( "artist:cure OR year:<1990" ), true ); - QCOMPARE( ExpressionParser::isAdvancedExpression( "-artist:madonna" ), true ); - QCOMPARE( ExpressionParser::isAdvancedExpression( "album:\"Best of\"" ), true ); -} diff --git a/amarok/tests/TestExpression.h b/amarok/tests/TestExpression.h deleted file mode 100644 index c91ecba6..00000000 --- a/amarok/tests/TestExpression.h +++ /dev/null @@ -1,37 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2009 Sven Krohlas * - * * - * This program 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 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#ifndef TESTEXPRESSION_H -#define TESTEXPRESSION_H - -#include - -class TestExpression : public QObject -{ -Q_OBJECT - -public: - TestExpression(); - -private slots: - void testParse(); - void testIsAdvancedExpression(); -}; - -#endif // TESTEXPRESSION_H diff --git a/amarok/tests/TestQStringx.cpp b/amarok/tests/TestQStringx.cpp deleted file mode 100644 index 9dd032b9..00000000 --- a/amarok/tests/TestQStringx.cpp +++ /dev/null @@ -1,174 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2009 Sven Krohlas * - * * - * This program 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 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#include "TestQStringx.h" - -#include "core/support/Debug.h" - -#include -#include -#include - -#include - -QTEST_KDEMAIN_CORE( TestQStringx ) - -//required for Debug.h -QMutex Debug::mutex; - -TestQStringx::TestQStringx() -{ -} - -void TestQStringx::testArgs() -{ - QStringList testArgs; - - m_testString = ""; - QCOMPARE( m_testString.args( testArgs ) , QString( "" ) ); - - m_testString = "test"; - QCOMPARE( m_testString.args( testArgs ), QString( "test" ) ); - - m_testString = ""; - testArgs.append( "test" ); - QCOMPARE( m_testString.args( testArgs ), QString( "" ) ); - - m_testString = "test%12abc"; - QCOMPARE( m_testString.args( testArgs ) , QString( "testtestabc" ) ); - - m_testString = "%12test abc"; - QCOMPARE( m_testString.args( testArgs ) , QString( "testtest abc" ) ); - - m_testString = "te%st%12abc"; - QCOMPARE( m_testString.args( testArgs ) , QString( "te%sttestabc" ) ); - - testArgs.clear(); - testArgs.append( "test" ); - testArgs.append( "abc" ); - m_testString = "test%12abc%2xyz"; - QCOMPARE( m_testString.args( testArgs ) , QString( "testtestabcabcxyz" ) ); - - m_testString = "%12test%23abc"; - QCOMPARE( m_testString.args( testArgs ) , QString( "testtestabcabc" ) ); -} - -void TestQStringx::testNamedArgs() -{ - QMap testArgs; - - m_testString = ""; - QCOMPARE( m_testString.namedArgs( testArgs ) , QString( "" ) ); - - m_testString = "test"; - QCOMPARE( m_testString.namedArgs( testArgs ) , QString( "test" ) ); - - testArgs[ "artist" ] = "Pornophonique"; - m_testString = "test"; - QCOMPARE( m_testString.namedArgs( testArgs ) , QString( "test" ) ); - - m_testString = "artist: %artist%"; - QCOMPARE( m_testString.namedArgs( testArgs ) , QString( "artist: Pornophonique" ) ); - - m_testString = "artist: %artist% - %album%"; - QCOMPARE( m_testString.namedArgs( testArgs ) , QString( "artist: Pornophonique - " ) ); - - testArgs[ "album" ] = "8-Bit Lagerfeuer"; - QCOMPARE( m_testString.namedArgs( testArgs ) , QString( "artist: Pornophonique - 8-Bit Lagerfeuer" ) ); - - m_testString = "%artist%: %artist% - %album%"; - QCOMPARE( m_testString.namedArgs( testArgs ) , QString( "Pornophonique: Pornophonique - 8-Bit Lagerfeuer" ) ); - - testArgs[ "year" ] = "2007"; - QCOMPARE( m_testString.namedArgs( testArgs ) , QString( "Pornophonique: Pornophonique - 8-Bit Lagerfeuer" ) ); -} - -void TestQStringx::testNamedOptArgs() -{ - QMap testArgs; - - m_testString = ""; - QCOMPARE( m_testString.namedOptArgs( testArgs ) , QString( "" ) ); - - m_testString = "test"; - QCOMPARE( m_testString.namedOptArgs( testArgs ) , QString( "test" ) ); - - m_testString = "%test%"; - QCOMPARE( m_testString.namedOptArgs( testArgs ) , QString( "" ) ); - - m_testString = "{ %test% }"; - QCOMPARE( m_testString.namedOptArgs( testArgs ) , QString( "" ) ); - - m_testString = "test{%test%}"; - QCOMPARE( m_testString.namedOptArgs( testArgs ) , QString( "test" ) ); - - m_testString = "{test{%test%}}"; - QCOMPARE( m_testString.namedOptArgs( testArgs ) , QString( "test" ) ); - - m_testString = "%test%{%test%}"; - QCOMPARE( m_testString.namedOptArgs( testArgs ) , QString( "" ) ); - - m_testString = "test%test% "; - QCOMPARE( m_testString.namedOptArgs( testArgs ) , QString( "test " ) ); - - testArgs[ "artist" ] = "All:My:Faults"; - m_testString = "%artist%"; - QCOMPARE( m_testString.namedOptArgs( testArgs ) , QString( "All:My:Faults" ) ); - - m_testString = "{%test% }{%artist%}"; - QCOMPARE( m_testString.namedOptArgs( testArgs ) , QString( "All:My:Faults" ) ); - - m_testString = "{%test% {%artist%}}"; - QCOMPARE( m_testString.namedOptArgs( testArgs ) , QString( "" ) ); - - m_testString = "{%artist% {%test%}}"; - QCOMPARE( m_testString.namedOptArgs( testArgs ) , QString( "All:My:Faults " ) ); - - testArgs[ "track" ] = "Some track"; - m_testString = "{%test% {%artist%}}%track%"; - QCOMPARE( m_testString.namedOptArgs( testArgs ) , QString( "Some track" ) ); - - m_testString = "{%artist% {%track%}} %test%"; - QCOMPARE( m_testString.namedOptArgs( testArgs ) , QString( "All:My:Faults Some track " ) ); - - testArgs[ "test" ] = ""; - m_testString = "{%test%}"; - QCOMPARE( m_testString.namedOptArgs( testArgs ) , QString( "" ) ); - - m_testString = "before{%test%}"; - QCOMPARE( m_testString.namedOptArgs( testArgs ) , QString( "before" ) ); - - m_testString = "{%test%}after"; - QCOMPARE( m_testString.namedOptArgs( testArgs ) , QString( "after" ) ); - - m_testString = "before{%test%}after"; - QCOMPARE( m_testString.namedOptArgs( testArgs ) , QString( "beforeafter" ) ); - - m_testString = "{%test% }{%artist%}"; - QCOMPARE( m_testString.namedOptArgs( testArgs ) , QString( "All:My:Faults" ) ); - - m_testString = "{%test% {%artist%}}"; - QCOMPARE( m_testString.namedOptArgs( testArgs ) , QString( "" ) ); - - m_testString = "{%artist% {%test%}}"; - QCOMPARE( m_testString.namedOptArgs( testArgs ) , QString( "All:My:Faults " ) ); - - m_testString = "[%test2%:test {%artist%}%test%{ [%test%]}]"; - QCOMPARE( m_testString.namedOptArgs( testArgs ), QString( "test All:My:Faults Unknown test" ) ); -} diff --git a/amarok/tests/TestQStringx.h b/amarok/tests/TestQStringx.h deleted file mode 100644 index 9e620995..00000000 --- a/amarok/tests/TestQStringx.h +++ /dev/null @@ -1,43 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2009 Sven Krohlas * - * * - * This program 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 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#ifndef TESTQSTRINGX_H -#define TESTQSTRINGX_H - -#include "QStringx.h" - -#include - -class TestQStringx : public QObject -{ -Q_OBJECT - -public: - TestQStringx(); - -private slots: - void testArgs(); - void testNamedArgs(); - void testNamedOptArgs(); - -private: - Amarok::QStringx m_testString; -}; - -#endif // TESTQSTRINGX_H diff --git a/amarok/tests/TestSmartPointerList.cpp b/amarok/tests/TestSmartPointerList.cpp deleted file mode 100644 index 84c71100..00000000 --- a/amarok/tests/TestSmartPointerList.cpp +++ /dev/null @@ -1,137 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2009 Max Howell * - * * - * This program 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 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#include "TestSmartPointerList.h" - -#include "core/support/SmartPointerList.h" - -#include -#include - -#include - -QTEST_KDEMAIN_CORE( TestSmartPointerList ) - -// use a macro, as we don't want to test copy ctor early -#define THREE_TIMERS( x ) SmartPointerList x; x << new QTimer << new QTimer << new QTimer - -TestSmartPointerList::TestSmartPointerList() -{ -} - -void TestSmartPointerList::testCount() -{ - THREE_TIMERS( objects ); - QCOMPARE( objects.count(), 3 ); -} - -void TestSmartPointerList::testCopy() -{ - THREE_TIMERS( objects1 ); - SmartPointerList objects2 = objects1; - - for (int x = 0; x < 3; ++x) - QVERIFY( objects1[x] == objects2[x] ); - - QCOMPARE( objects1.count(), 3 ); - QCOMPARE( objects2.count(), 3 ); - delete objects1.last(); - QCOMPARE( objects1.count(), 2 ); - QCOMPARE( objects2.count(), 2 ); -} - -void TestSmartPointerList::testCopyAndThenDelete() -{ - THREE_TIMERS( os1 ); - SmartPointerList* os2 = new SmartPointerList( os1 ); - SmartPointerList os3( *os2 ); - - delete os2; - - QCOMPARE( os1.count(), 3 ); - QCOMPARE( os3.count(), 3 ); - - delete os1[1]; - - QCOMPARE( os1.count(), 2 ); - QCOMPARE( os3.count(), 2 ); -} - -void TestSmartPointerList::testRemove() -{ - THREE_TIMERS( objects ); - delete objects.last(); - QCOMPARE( objects.count(), 2 ); -} - -void TestSmartPointerList::testRemoveAt() -{ - THREE_TIMERS( os ); - QTimer* t = os[1]; - os.removeAt( 1 ); - os << t; - QCOMPARE( os.count(), 3 ); - delete t; - QCOMPARE( os.count(), 2 ); -} - -void TestSmartPointerList::testMultipleOrgasms() -{ - THREE_TIMERS( os ); - for (int x = 0; x < 10; ++x) - os << os.last(); - QCOMPARE( os.count(), 13 ); - delete os.last(); - QCOMPARE( os.count(), 2 ); -} - -void TestSmartPointerList::testForeach() -{ - THREE_TIMERS( objects ); - int x = 0; - foreach (QTimer* o, objects) { - (void) o; - x++; - } - QCOMPARE( x, 3 ); -} - -void TestSmartPointerList::testOperatorPlus() -{ - THREE_TIMERS( os1 ); - SmartPointerList os2 = os1; - - QCOMPARE( (os1 + os2).count(), 6 ); - delete os1.last(); - QCOMPARE( (os1 + os2).count(), 4 ); -} - -void TestSmartPointerList::testOperatorPlusEquals() -{ - THREE_TIMERS( os ); - os += os; - os += os; - QCOMPARE( os.count(), 12 ); - QTimer* t = os.takeLast(); - QCOMPARE( os.count(), 11 ); - delete t; - QCOMPARE( os.count(), 8 ); -} - -#include "moc_TestSmartPointerList.cpp" diff --git a/amarok/tests/TestSmartPointerList.h b/amarok/tests/TestSmartPointerList.h deleted file mode 100644 index c110c110..00000000 --- a/amarok/tests/TestSmartPointerList.h +++ /dev/null @@ -1,44 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2009 Max Howell * - * * - * This program 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 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#ifndef TESTSMARTPOINTERLIST_H -#define TESTSMARTPOINTERLIST_H - -#include - -class TestSmartPointerList : public QObject -{ -Q_OBJECT - -public: - TestSmartPointerList(); - -private slots: - void testCount(); - void testCopy(); - void testCopyAndThenDelete(); - void testRemove(); - void testRemoveAt(); - void testMultipleOrgasms(); - void testForeach(); - void testOperatorPlus(); - void testOperatorPlusEquals(); -}; - -#endif // TESTSMARTPOINTERLIST_H diff --git a/amarok/tests/TestTagGuesser.cpp b/amarok/tests/TestTagGuesser.cpp deleted file mode 100644 index 620ff985..00000000 --- a/amarok/tests/TestTagGuesser.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2010 Casey Link * - * * - * This program 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 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#include "TestTagGuesser.h" - -#include "dialogs/TagGuesser.h" -#include "MetaValues.h" - -#include - -#include - -QTEST_KDEMAIN_CORE( TestTagGuesser ) - -TestTagGuesser::TestTagGuesser() -{ -} - -void TestTagGuesser::init() -{ - mTagGuesser = new TagGuesser; -} - -void TestTagGuesser::cleanup() -{ - delete mTagGuesser; -} - - -void TestTagGuesser::testStandard() -{ - mTagGuesser->setFilename( "01 - Artist - Title.mp3" ); - mTagGuesser->setSchema( "%track% - %artist% - %title%.%ignore%" ); - QVERIFY( mTagGuesser->guess() ); - - QMap tags = mTagGuesser->tags(); - QCOMPARE( tags[Meta::valArtist], QString( "Artist" ) ); - QCOMPARE( tags[Meta::valTitle], QString( "Title" ) ); - QCOMPARE( tags[Meta::valTrackNr], QString( "01" ) ); -} - -void TestTagGuesser::testDotInFilename() -{ - // based off bug 225743 - // https://bugs.kde.org/show_bug.cgi?id=225743 - mTagGuesser->setFilename( "03.Moloko - Sing It back.mp3" ); - mTagGuesser->setSchema( "%track%.%artist% - %title%.%ignore%" ); - QVERIFY( mTagGuesser->guess() ); - - QMap tags = mTagGuesser->tags(); - QCOMPARE( tags[Meta::valArtist], QString( "Moloko" ) ); - QCOMPARE( tags[Meta::valTitle], QString( "Sing It back" ) ); - QCOMPARE( tags[Meta::valTrackNr], QString( "03" ) ); -} diff --git a/amarok/tests/TestTagGuesser.h b/amarok/tests/TestTagGuesser.h deleted file mode 100644 index bed09b58..00000000 --- a/amarok/tests/TestTagGuesser.h +++ /dev/null @@ -1,43 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2010 Casey Link * - * * - * This program 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 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#ifndef TESTTAGGUESSER_H -#define TESTTAGGUESSER_H - -#include - -class TagGuesser; - -class TestTagGuesser : public QObject -{ -Q_OBJECT -public: - TestTagGuesser(); - -private slots: - void init(); - void cleanup(); - void testStandard(); - void testDotInFilename(); - -private: - TagGuesser* mTagGuesser; -}; - -#endif // TESTTAGGUESSER_H diff --git a/amarok/tests/TestTrackOrganizer.cpp b/amarok/tests/TestTrackOrganizer.cpp deleted file mode 100644 index 1e0de6c2..00000000 --- a/amarok/tests/TestTrackOrganizer.cpp +++ /dev/null @@ -1,183 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2010 Casey Link * - * Copyright (c) 2010 Maximilian Kossick * - * * - * This program 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 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#include "TestTrackOrganizer.h" - -#include "dialogs/TrackOrganizer.h" -#include "core/support/Debug.h" - -#include "CollectionTestImpl.h" - -#include "mocks/MockTrack.h" -#include "mocks/MockAlbum.h" -#include "mocks/MockArtist.h" - -#include - -#include -#include - -using ::testing::Return; -using ::testing::AnyNumber; - -QTEST_KDEMAIN_CORE( TestTrackOrganizer ) - -namespace Collections { - -class MyCollectionTestImpl : public CollectionTestImpl -{ -public: - MyCollectionTestImpl( const QString &id ) : CollectionTestImpl( id ) {} - -}; - -} //namespace Collections - -TestTrackOrganizer::TestTrackOrganizer() -{ - -} - -void TestTrackOrganizer::init() -{ - mColl = new Collections::MyCollectionTestImpl("A"); -} - -void TestTrackOrganizer::cleanup() -{ - delete mColl; - delete mTrackOrganizer; -} - -void TestTrackOrganizer::testBasic() -{ - - mTracks = makeTracks( 10 ); - mTrackOrganizer = new TrackOrganizer( mTracks, this ); - QString folder = "/home/user/Music" ; - mTrackOrganizer->setFormatString( "%collectionroot%/%artist%/%album%/%track%-%title%.%filetype%" ); - mTrackOrganizer->setFolderPrefix( folder ); - QMap dests = mTrackOrganizer->getDestinations(); - QVERIFY( dests.size() == 10 ); - - foreach( Meta::TrackPtr track, mTracks ) - { - QVERIFY( dests.contains( track ) ); - QString format = "%1/%2/%3/%4-%5.%6"; - QString trackNum = QString("%1").arg( track->trackNumber(), 2, 10, QChar('0') ); - QString result = format.arg( folder, track->artist()->prettyName(), track->album()->prettyName(), trackNum, track->prettyName(), "mp3"); - QCOMPARE( dests.value( track ), result ); - } -} - -Meta::TrackPtr TestTrackOrganizer::makeMockTrack( const QString &trackName, const QString &artistName, const QString &albumName, int trackNumber ) -{ - Meta::MockTrack *track = new Meta::MockTrack(); - ::testing::Mock::AllowLeak( track ); - Meta::TrackPtr trackPtr( track ); - EXPECT_CALL( *track, name() ).Times( AnyNumber() ).WillRepeatedly( Return( trackName ) ); - EXPECT_CALL( *track, prettyName() ).Times( AnyNumber() ).WillRepeatedly( Return( trackName ) ); - EXPECT_CALL( *track, uidUrl() ).Times( AnyNumber() ).WillRepeatedly( Return( trackName + '_' + artistName + '_' + albumName ) ); - EXPECT_CALL( *track, playableUrl() ).Times( AnyNumber() ).WillRepeatedly( Return( KUrl( '/' + track->uidUrl() ) ) ); - EXPECT_CALL( *track, trackNumber() ).Times( AnyNumber() ).WillRepeatedly( Return( trackNumber ) ); - EXPECT_CALL( *track, type() ).Times( AnyNumber() ).WillRepeatedly( Return( "mp3" ) ); - EXPECT_CALL( *track, composer() ).Times( AnyNumber() ).WillRepeatedly( Return( Meta::ComposerPtr() ) ); - EXPECT_CALL( *track, year() ).Times( AnyNumber() ).WillRepeatedly( Return( Meta::YearPtr() ) ); - EXPECT_CALL( *track, genre() ).Times( AnyNumber() ).WillRepeatedly( Return( Meta::GenrePtr() ) ); - EXPECT_CALL( *track, discNumber() ).Times( AnyNumber() ).WillRepeatedly( Return( 0 ) ); - EXPECT_CALL( *track, rating() ).Times( AnyNumber() ).WillRepeatedly( Return( 0 ) ); - EXPECT_CALL( *track, filesize() ).Times( AnyNumber() ).WillRepeatedly( Return( 0 ) ); - EXPECT_CALL( *track, length() ).Times( AnyNumber() ).WillRepeatedly( Return( 0 ) ); - EXPECT_CALL( *track, comment() ).Times( AnyNumber() ).WillRepeatedly( Return( "" ) ); - - mColl->mc->addTrack( trackPtr ); - - Meta::AlbumPtr albumPtr = mColl->mc->albumMap().value( albumName, QString() /* no album artist */ ); - Meta::MockAlbum *album; - Meta::TrackList albumTracks; - if( albumPtr ) - { - album = dynamic_cast( albumPtr.data() ); - if( !album ) - { - qFatal("expected a Meta::MockAlbum"); -// QFAIL( "expected a Meta::MockAlbum" ); - return trackPtr; - } - albumTracks = albumPtr->tracks(); - } - else - { - album = new Meta::MockAlbum(); - ::testing::Mock::AllowLeak( album ); - albumPtr = Meta::AlbumPtr( album ); - EXPECT_CALL( *album, name() ).Times( AnyNumber() ).WillRepeatedly( Return( albumName ) ); - EXPECT_CALL( *album, prettyName() ).Times( AnyNumber() ).WillRepeatedly( Return( albumName ) ); - EXPECT_CALL( *album, hasAlbumArtist() ).Times( AnyNumber() ).WillRepeatedly( Return( false ) ); - EXPECT_CALL( *album, albumArtist() ).Times( AnyNumber() ).WillRepeatedly( Return( Meta::ArtistPtr() ) ); - EXPECT_CALL( *album, isCompilation() ).Times( AnyNumber() ).WillRepeatedly( Return( false ) ); - mColl->mc->addAlbum( albumPtr ); - } - albumTracks << trackPtr; - EXPECT_CALL( *album, tracks() ).Times( AnyNumber() ).WillRepeatedly( Return( albumTracks ) ); - - EXPECT_CALL( *track, album() ).Times( AnyNumber() ).WillRepeatedly( Return( albumPtr ) ); - - Meta::ArtistPtr artistPtr = mColl->mc->artistMap().value( artistName ); - Meta::MockArtist *artist; - Meta::TrackList artistTracks; - if( artistPtr ) - { - artist = dynamic_cast( artistPtr.data() ); - if( !artist ) - { - qFatal("expected a Meta::MockArtist"); -// QFAIL( "expected a Meta::MockArtist" ); - return trackPtr; - } - artistTracks = artistPtr->tracks(); - } - else - { - artist = new Meta::MockArtist(); - ::testing::Mock::AllowLeak( artist ); - artistPtr = Meta::ArtistPtr( artist ); - EXPECT_CALL( *artist, name() ).Times( AnyNumber() ).WillRepeatedly( Return( artistName ) ); - EXPECT_CALL( *artist, prettyName() ).Times( AnyNumber() ).WillRepeatedly( Return( artistName ) ); - mColl->mc->addArtist( artistPtr ); - } - artistTracks << trackPtr; - EXPECT_CALL( *artist, tracks() ).Times( AnyNumber() ).WillRepeatedly( Return( artistTracks ) ); - EXPECT_CALL( *track, artist() ).Times( AnyNumber() ).WillRepeatedly( Return( artistPtr ) ); - return trackPtr; -} - -Meta::TrackList TestTrackOrganizer::makeTracks( int numTracks ) -{ - Meta::TrackList tracks; - for( int i = 1; i <= numTracks; ++i ) - { - QString title = "Title" + QString::number(i); - Meta::TrackPtr t = makeMockTrack( title, "Artist1", "Album1", i ); - if( t ) - tracks << t; - } - return tracks; -} diff --git a/amarok/tests/TestTrackOrganizer.h b/amarok/tests/TestTrackOrganizer.h deleted file mode 100644 index 47fc22be..00000000 --- a/amarok/tests/TestTrackOrganizer.h +++ /dev/null @@ -1,49 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2010 Casey Link * - * * - * This program 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 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#ifndef TESTTRACKORGANIZER_H -#define TESTTRACKORGANIZER_H - -#include "CollectionTestImpl.h" - -#include - -class TrackOrganizer; - -class TestTrackOrganizer : public QObject -{ -Q_OBJECT -public: - TestTrackOrganizer(); - -private slots: - void init(); - void cleanup(); - void testBasic(); - -private: - Meta::TrackList makeTracks( int numTracks ); - Meta::TrackPtr makeMockTrack( const QString &trackName, const QString &artistName, const QString &albumName, int tracknumber ); - - TrackOrganizer* mTrackOrganizer; - Collections::CollectionTestImpl *mColl; - Meta::TrackList mTracks; -}; - -#endif // TESTTRACKORGANIZER_H diff --git a/amarok/tests/amarokurls/CMakeLists.txt b/amarok/tests/amarokurls/CMakeLists.txt deleted file mode 100644 index 6c5ed8f4..00000000 --- a/amarok/tests/amarokurls/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -include_directories( - ${AMAROK_TEST_TREE} - ${CMAKE_BINARY_DIR}/tests - ) - -set( testamarokurls_SRCS TestAmarokUrls.cpp ) -kde4_add_unit_test( testamarokurls ${testamarokurls_SRCS} ) -target_link_libraries( testamarokurls amarokcore amaroklib ${KDE4_KDECORE_LIBS} ${QT_QTTEST_LIBRARY} ) - diff --git a/amarok/tests/amarokurls/TestAmarokUrls.cpp b/amarok/tests/amarokurls/TestAmarokUrls.cpp deleted file mode 100644 index 554b8962..00000000 --- a/amarok/tests/amarokurls/TestAmarokUrls.cpp +++ /dev/null @@ -1,99 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 Pulic License for more details. * - * * - * You should have received a copy of the GNU General Public License along with * - * this program. If not, see . * - ****************************************************************************************/ - -#include "TestAmarokUrls.h" - -#include "core/support/Components.h" -#include "EngineController.h" - -#include "config-amarok-test.h" - -#include "amarokurls/AmarokUrl.h" -#include "amarokurls/AmarokUrlHandler.h" - -#include - -#include - -QTEST_KDEMAIN_CORE( TestAmarokUrls ) - -TestAmarokUrls::TestAmarokUrls() - : QObject() -{ - //apparently the engine controller is needed somewhere, or we will get a crash... - EngineController *controller = new EngineController(); - Amarok::Components::setEngineController( controller ); -} - -void -TestAmarokUrls::testConstructUrl() -{ - - AmarokUrl url; - - url.setCommand( "navigate" ); - url.setPath( "collections" ); - url.setArg( "filter", "artist:\"Code Monkeys\"" ); - url.setArg( "levels", "artist-album" ); - - QCOMPARE( url.command(), QString( "navigate" ) ); - QCOMPARE( url.path(), QString( "collections" ) ); - QCOMPARE( url.args().size(), 2 ); - QVERIFY( url.args().keys().contains( "filter" ) ); - QVERIFY( url.args().keys().contains( "levels" ) ); - QCOMPARE( url.args().value( "filter" ), QString( "artist:\"Code Monkeys\"" ) ); - QCOMPARE( url.args().value( "levels" ), QString( "artist-album") ); - - QCOMPARE( url.prettyCommand(), The::amarokUrlHandler()->prettyCommand( "navigate" ) ); - - -} - - -void -TestAmarokUrls::testUrlFromString() -{ - - AmarokUrl url( "amarok://navigate/collections?filter=artist:\"Code Monkeys\"&levels=artist-album" ); - - QCOMPARE( url.command(), QString( "navigate" ) ); - QCOMPARE( url.path(), QString( "collections" ) ); - QCOMPARE( url.args().size(), 2 ); - QVERIFY( url.args().keys().contains( "filter" ) ); - QVERIFY( url.args().keys().contains( "levels" ) ); - QCOMPARE( url.args().value( "filter" ), QString( "artist:\"Code Monkeys\"" ) ); - QCOMPARE( url.args().value( "levels" ), QString( "artist-album") ); - - QCOMPARE( url.prettyCommand(), The::amarokUrlHandler()->prettyCommand( "navigate" ) ); - -} - -void TestAmarokUrls::testEncoding() -{ - QString urlString( "amarok://navigate/collections?filter=artist:\"Code Monkeys\"&levels=artist-album" ); - AmarokUrl url( urlString ); - - QUrl qUrl( urlString ); - - QCOMPARE( url.url(), QString( qUrl.toEncoded() ) ); - - - //check that we do not "double encode" anything - AmarokUrl url2( "amarok://navigate/collections?filter=artist:%22Code%20Monkeys%22&levels=artist-album" ); - QCOMPARE( url2.url(), QString( qUrl.toEncoded() ) ); -} - - diff --git a/amarok/tests/amarokurls/TestAmarokUrls.h b/amarok/tests/amarokurls/TestAmarokUrls.h deleted file mode 100644 index 387449cd..00000000 --- a/amarok/tests/amarokurls/TestAmarokUrls.h +++ /dev/null @@ -1,35 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 Pulic License for more details. * - * * - * You should have received a copy of the GNU General Public License along with * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef TESTAMAROKURLS_H -#define TESTAMAROKURLS_H - -#include -#include - -class TestAmarokUrls : public QObject -{ - Q_OBJECT -public: - TestAmarokUrls(); - -private slots: - void testConstructUrl(); - void testUrlFromString(); - void testEncoding(); -}; - -#endif // TESTAMAROKURLS_H diff --git a/amarok/tests/browsers/CMakeLists.txt b/amarok/tests/browsers/CMakeLists.txt deleted file mode 100644 index 3a7f773d..00000000 --- a/amarok/tests/browsers/CMakeLists.txt +++ /dev/null @@ -1,32 +0,0 @@ -include_directories( - .. - ${AMAROK_SOURCE_TREE} - ${CMAKE_BINARY_DIR}/src - ${AMAROK_COLLECTION_SUPPORT_DIR} - ${KDE4_INCLUDE_DIR} - ${QT_INCLUDES} - ${GOOGLEMOCK_INCLUDE_DIR} - ) - -#------------------------ TestMasterSlaveSynchronizationJob ----------------------------- - -set( testsinglecollectiontreeitemmodel_SRCS - TestSingleCollectionTreeItemModel.cpp - ${GOOGLEMOCK_SRCS} - ) - -kde4_add_unit_test( testsinglecollectiontreeitemmodel ${testsinglecollectiontreeitemmodel_SRCS} ) - -add_dependencies( testsinglecollectiontreeitemmodel amarokcore ) -add_dependencies( testsinglecollectiontreeitemmodel amaroklib ) - -target_link_libraries(testsinglecollectiontreeitemmodel - amarokcore - amaroklib - ${KDE4_KDECORE_LIBS} - ${KDE4_KDEUI_LIBS} - ${QT_QTGUI_LIBRARY} - ${KDE4_THREADWEAVER_LIBS} - ${QT_QTTEST_LIBRARY} - ${QT_QTCORE_LIBRARY} - ${GOOGLEMOCK_LIBRARIES}) diff --git a/amarok/tests/browsers/TestSingleCollectionTreeItemModel.cpp b/amarok/tests/browsers/TestSingleCollectionTreeItemModel.cpp deleted file mode 100644 index 2b0c52a5..00000000 --- a/amarok/tests/browsers/TestSingleCollectionTreeItemModel.cpp +++ /dev/null @@ -1,353 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "TestSingleCollectionTreeItemModel.h" - -#include "core/meta/Meta.h" -#include "browsers/CollectionTreeItemModelBase.h" -#include "browsers/SingleCollectionTreeItemModel.h" - -#include "CollectionTestImpl.h" -#include "mocks/MockTrack.h" -#include "mocks/MockAlbum.h" -#include "mocks/MockArtist.h" - -#include -#include -#include -#include - -#include -#include - -#include - -#include - -using ::testing::Return; -using ::testing::AnyNumber; -using ::testing::_; - -QTEST_KDEMAIN( TestSingleCollectionTreeItemModel, GUI ) - -void addMockTrack( Collections::CollectionTestImpl *coll, const QString &trackName, const QString &artistName, const QString &albumName ) -{ - Meta::MockTrack *track = new Meta::MockTrack(); - ::testing::Mock::AllowLeak( track ); - Meta::TrackPtr trackPtr( track ); - EXPECT_CALL( *track, name() ).Times( AnyNumber() ).WillRepeatedly( Return( trackName ) ); - EXPECT_CALL( *track, prettyName() ).Times( AnyNumber() ).WillRepeatedly( Return( trackName ) ); - EXPECT_CALL( *track, uidUrl() ).Times( AnyNumber() ).WillRepeatedly( Return( trackName + '_' + artistName + '_' + albumName ) ); - EXPECT_CALL( *track, playableUrl() ).Times( AnyNumber() ).WillRepeatedly( Return( KUrl( '/' + track->uidUrl() ) ) ); - EXPECT_CALL( *track, composer() ).Times( AnyNumber() ).WillRepeatedly( Return( Meta::ComposerPtr() ) ); - EXPECT_CALL( *track, genre() ).Times( AnyNumber() ).WillRepeatedly( Return( Meta::GenrePtr() ) ); - EXPECT_CALL( *track, year() ).Times( AnyNumber() ).WillRepeatedly( Return( Meta::YearPtr() ) ); - coll->mc->addTrack( trackPtr ); - - Meta::AlbumPtr albumPtr = coll->mc->albumMap().value( albumName, QString() /* no album artist */ ); - Meta::MockAlbum *album; - Meta::TrackList albumTracks; - if( albumPtr ) - { - album = dynamic_cast( albumPtr.data() ); - if( !album ) - { - QFAIL( "expected a Meta::MockAlbum" ); - return; - } - albumTracks = albumPtr->tracks(); - } - else - { - album = new Meta::MockAlbum(); - ::testing::Mock::AllowLeak( album ); - albumPtr = Meta::AlbumPtr( album ); - EXPECT_CALL( *album, name() ).Times( AnyNumber() ).WillRepeatedly( Return( albumName ) ); - EXPECT_CALL( *album, prettyName() ).Times( AnyNumber() ).WillRepeatedly( Return( albumName ) ); - EXPECT_CALL( *album, hasAlbumArtist() ).Times( AnyNumber() ).WillRepeatedly( Return( false ) ); - EXPECT_CALL( *album, isCompilation() ).Times( AnyNumber() ).WillRepeatedly( Return( false ) ); //inconsistent - coll->mc->addAlbum( albumPtr ); - } - albumTracks << trackPtr; - EXPECT_CALL( *album, tracks() ).Times( AnyNumber() ).WillRepeatedly( Return( albumTracks ) ); - - EXPECT_CALL( *track, album() ).Times( AnyNumber() ).WillRepeatedly( Return( albumPtr ) ); - - Meta::ArtistPtr artistPtr = coll->mc->artistMap().value( artistName ); - Meta::MockArtist *artist; - Meta::TrackList artistTracks; - if( artistPtr ) - { - artist = dynamic_cast( artistPtr.data() ); - if( !artist ) - { - QFAIL( "expected a Meta::MockArtist" ); - return; - } - artistTracks = artistPtr->tracks(); - } - else - { - artist = new Meta::MockArtist(); - ::testing::Mock::AllowLeak( artist ); - artistPtr = Meta::ArtistPtr( artist ); - EXPECT_CALL( *artist, name() ).Times( AnyNumber() ).WillRepeatedly( Return( artistName ) ); - EXPECT_CALL( *artist, prettyName() ).Times( AnyNumber() ).WillRepeatedly( Return( artistName ) ); - coll->mc->addArtist( artistPtr ); - } - artistTracks << trackPtr; - EXPECT_CALL( *artist, tracks() ).Times( AnyNumber() ).WillRepeatedly( Return( artistTracks ) ); - EXPECT_CALL( *track, artist() ).Times( AnyNumber() ).WillRepeatedly( Return( artistPtr ) ); - EXPECT_CALL( *album, albumArtist() ).Times( AnyNumber() ).WillRepeatedly( Return( artistPtr ) ); -} - -TestSingleCollectionTreeItemModel::TestSingleCollectionTreeItemModel() : QObject() -{ - KCmdLineArgs::init( KGlobal::activeComponent().aboutData() ); - ::testing::InitGoogleMock( &KCmdLineArgs::qtArgc(), KCmdLineArgs::qtArgv() ); - qRegisterMetaType(); - qRegisterMetaType(); - qRegisterMetaType(); - qRegisterMetaType(); -} - -TestSingleCollectionTreeItemModel::~TestSingleCollectionTreeItemModel() -{ -} - -void -TestSingleCollectionTreeItemModel::initTestCase() -{ - qRegisterMetaType(); - qRegisterMetaType(); - qRegisterMetaType(); - qRegisterMetaType(); -} - -#define loadChildren( itemModel, idx ) \ -{ \ - if( itemModel->canFetchMore( idx ) ) { \ - itemModel->fetchMore( idx ); \ - QVERIFY( QTest::kWaitForSignal( itemModel, SIGNAL(allQueriesFinished(bool)), 5000 ) ); \ - } \ -} - -void -TestSingleCollectionTreeItemModel::testAddNewArtist() -{ - Collections::CollectionTestImpl *coll = new Collections::CollectionTestImpl( "test" ); - addMockTrack( coll, "track1", "artist1", "album1" ); - - QList levels; - levels<< CategoryId::Artist << CategoryId::Album; - - SingleCollectionTreeItemModel *model = new SingleCollectionTreeItemModel( coll, levels ); - - loadChildren( model, QModelIndex() ); - - QCOMPARE( model->rowCount( QModelIndex() ), 1 ); - - { - QModelIndex artist1Index = model->index( 0, 0, QModelIndex() ); - QCOMPARE( model->data( artist1Index, Qt::DisplayRole ).toString(), QString( "artist1" ) ); - } - - addMockTrack( coll, "track2", "artist2", "album2" ); - - model->slotFilter(); - - loadChildren( model, QModelIndex() ); - - QCOMPARE( model->rowCount( QModelIndex() ), 2 ); - - QSet artists; - - QModelIndex idx1 = model->index( 0, 0, QModelIndex() ); - artists << model->data( idx1, Qt::DisplayRole ).toString(); - - QModelIndex idx2 = model->index( 1, 0, QModelIndex() ); - artists << model->data( idx2, Qt::DisplayRole ).toString(); - - { - QSet expected; - expected << "artist1" << "artist2"; - QCOMPARE( artists, expected ); - } - - delete model; - delete coll; -} - -void -TestSingleCollectionTreeItemModel::testRemoveArtist() -{ - Collections::CollectionTestImpl *coll = new Collections::CollectionTestImpl( "test" ); - addMockTrack( coll, "track1", "artist1", "album1" ); - addMockTrack( coll, "track2", "artist2", "album2" ); - - QList levels; - levels<< CategoryId::Artist << CategoryId::Album; - - SingleCollectionTreeItemModel *model = new SingleCollectionTreeItemModel( coll, levels ); - - loadChildren( model, QModelIndex() ); - - QCOMPARE( model->rowCount( QModelIndex() ), 2 ); - - { - QSet artists; - - QModelIndex idx1 = model->index( 0, 0, QModelIndex() ); - artists << model->data( idx1, Qt::DisplayRole ).toString(); - - QModelIndex idx2 = model->index( 1, 0, QModelIndex() ); - artists << model->data( idx2, Qt::DisplayRole ).toString(); - - QSet expected; - expected << "artist1" << "artist2"; - QCOMPARE( artists, expected ); - } - - ArtistMap map = coll->mc->artistMap(); - map.remove( "artist2" ); //album and track are still part of the collection - coll->mc->setArtistMap( map ); - - model->slotFilter(); - - loadChildren( model, QModelIndex() ); - - QCOMPARE( model->rowCount( QModelIndex() ), 1 ); - - { - QModelIndex artist1Index = model->index( 0, 0, QModelIndex() ); - QCOMPARE( model->data( artist1Index, Qt::DisplayRole ).toString(), QString( "artist1" ) ); - } - - delete model; - delete coll; -} - -void -TestSingleCollectionTreeItemModel::testAddTrack() -{ - Collections::CollectionTestImpl *coll = new Collections::CollectionTestImpl( "test" ); - addMockTrack( coll, "track1", "artist1", "album1" ); - addMockTrack( coll, "track2", "artist2", "album2" ); - - QList levels; - levels<< CategoryId::Artist << CategoryId::Album; - - SingleCollectionTreeItemModel *model = new SingleCollectionTreeItemModel( coll, levels ); - - loadChildren( model, QModelIndex() ); - - QCOMPARE( model->rowCount( QModelIndex() ), 2 ); - - { - QSet artists; - - QModelIndex idx1 = model->index( 0, 0, QModelIndex() ); - artists << model->data( idx1, Qt::DisplayRole ).toString(); - - QModelIndex idx2 = model->index( 1, 0, QModelIndex() ); - artists << model->data( idx2, Qt::DisplayRole ).toString(); - - QSet expected; - expected << "artist1" << "artist2"; - QCOMPARE( artists, expected ); - } - - for( int i = 0; i < 2; i++ ) - { - QModelIndex parent = model->index( i, 0, QModelIndex() ); - loadChildren( model, parent ); - QCOMPARE( model->rowCount( parent ), 1 ); - - QModelIndex subParent = model->index( 0, 0, parent ); - loadChildren( model, subParent ); - QCOMPARE( model->rowCount( subParent ), 1 ); - } - - addMockTrack( coll, "track3", "artist1", "album1" ); - - model->slotFilter(); - - QTest::qWait( 30 ); - - loadChildren( model, QModelIndex() ); - - QCOMPARE( model->rowCount( QModelIndex() ), 2 ); - - for( int i = 0; i < 2; i++ ) - { - QModelIndex parent = model->index( i, 0, QModelIndex() ); - loadChildren( model, parent ); - QCOMPARE( model->rowCount( parent ), 1 ); - - QString name = model->data( parent, Qt::DisplayRole ).toString(); - int count = (name == "artist1" ? 2 : 1 ); - - QModelIndex subParent = model->index( 0, 0, parent ); - loadChildren( model, subParent ); - QCOMPARE( model->rowCount( subParent ), count ); - } - - delete model; - delete coll; -} - -void -TestSingleCollectionTreeItemModel::testRemoveTrack() -{ - -} - -void -TestSingleCollectionTreeItemModel::testAddTrackWithFilter() -{ - Collections::CollectionTestImpl *coll = new Collections::CollectionTestImpl( "test" ); - addMockTrack( coll, "track1", "artist1", "album1" ); - - QList levels; - levels << CategoryId::Artist << CategoryId::Album; - - SingleCollectionTreeItemModel *model = new SingleCollectionTreeItemModel( coll, levels ); - - loadChildren( model, QModelIndex() ); - QCOMPARE( model->rowCount( QModelIndex() ), 1 ); - - { - QModelIndex artist1Index = model->index( 0, 0, QModelIndex() ); - QCOMPARE( model->data( artist1Index, Qt::DisplayRole ).toString(), QString( "artist1" ) ); - } - - addMockTrack( coll, "track2", "artist2", "album2" ); - model->setCurrentFilter( "track2" ); - model->slotFilter(); - loadChildren( model, QModelIndex() ); - QCOMPARE( model->rowCount( QModelIndex() ), 1 ); - - model->setCurrentFilter( QString() ); - model->slotFilter(); - loadChildren( model, QModelIndex() ); - QCOMPARE( model->rowCount( QModelIndex() ), 2 ); - - QModelIndex idx1 = model->index( 0, 0, QModelIndex() ); - QCOMPARE( model->data( idx1, Qt::DisplayRole ).toString(), QString( "artist2" ) ); - - delete model; - delete coll; -} diff --git a/amarok/tests/browsers/TestSingleCollectionTreeItemModel.h b/amarok/tests/browsers/TestSingleCollectionTreeItemModel.h deleted file mode 100644 index bc91d015..00000000 --- a/amarok/tests/browsers/TestSingleCollectionTreeItemModel.h +++ /dev/null @@ -1,40 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef TESTSINGLECOLLECTIONTREEITEMMODEL_H -#define TESTSINGLECOLLECTIONTREEITEMMODEL_H - -#include - -class TestSingleCollectionTreeItemModel : public QObject -{ - Q_OBJECT -public: - TestSingleCollectionTreeItemModel(); - ~TestSingleCollectionTreeItemModel(); - -private slots: - void initTestCase(); - - void testAddNewArtist(); - void testRemoveArtist(); - void testRemoveTrack(); - void testAddTrack(); - - void testAddTrackWithFilter(); -}; - -#endif diff --git a/amarok/tests/config-amarok-test.h.cmake b/amarok/tests/config-amarok-test.h.cmake deleted file mode 100644 index f3eb57b1..00000000 --- a/amarok/tests/config-amarok-test.h.cmake +++ /dev/null @@ -1,11 +0,0 @@ -/* config-amarok-test.h. Generated by cmake from config-amarok-test.h.cmake */ - -/* The root of the test data in Amarok's source tree. Use this if you have to access uninstalled test data */ -#define AMAROK_TEST_DIR "${AMAROK_TEST_TREE}" - -/*The number of tracks that are used for the SqlCollection performance tests/stress tests. - It should be a multiple of 1000, check the unit tests to see why*/ - #define AMAROK_SQLCOLLECTION_STRESS_TEST_TRACK_COUNT ${STRESS_TEST_TRACK_COUNT} - -/*The location of the built utilities in the tree */ -#define AMAROK_OVERRIDE_UTILITIES_PATH "${AMAROK_UTILITIES_DIR}" \ No newline at end of file diff --git a/amarok/tests/context/CMakeLists.txt b/amarok/tests/context/CMakeLists.txt deleted file mode 100644 index 92a20833..00000000 --- a/amarok/tests/context/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -add_subdirectory( engines ) - diff --git a/amarok/tests/context/engines/CMakeLists.txt b/amarok/tests/context/engines/CMakeLists.txt deleted file mode 100644 index 9a7d8db0..00000000 --- a/amarok/tests/context/engines/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -include_directories( - ${AMAROK_SOURCE_TREE}/context/engines/upcomingevents - ${AMAROK_SOURCE_TREE}/context/applets/upcomingevents - ${AMAROK_SOURCE_TREE}/context/engines/similarartists - ${AMAROK_SOURCE_TREE}/context/applets/similarartists - ${AMAROK_COLLECTION_SUPPORT_DIR} - ${KDE4_INCLUDE_DIR} - ${QT_INCLUDES} -) - -if(LIBLASTFM_FOUND) - add_subdirectory( similarartists ) - add_subdirectory( upcomingevents ) -endif(LIBLASTFM_FOUND) diff --git a/amarok/tests/context/engines/ContextView.cpp b/amarok/tests/context/engines/ContextView.cpp deleted file mode 100644 index bde70a59..00000000 --- a/amarok/tests/context/engines/ContextView.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007-2008 Leo Franchi * - * Copyright (c) 2008 William Viana Soares * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -/* - Significant parts of this code is inspired and/or copied from KDE plasma sources, - available at kdebase/workspace/plasma -*/ - -#include "ContextView.h" -#include - -namespace Context -{ - -ContextView* ContextView::s_self = 0; - - -ContextView::ContextView() -{ - qDebug() << "=============================youhou========================================="; -} - -ContextView::~ContextView() -{} - -ContextView* ContextView::self() -{ - if( !s_self ) s_self = new ContextView(); - return s_self; -} - -} // Context namespace diff --git a/amarok/tests/context/engines/ContextView.h b/amarok/tests/context/engines/ContextView.h deleted file mode 100644 index 66bf93d7..00000000 --- a/amarok/tests/context/engines/ContextView.h +++ /dev/null @@ -1,49 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2007 Leo Franchi * - * Copyright (c) 2008 William Viana Soares * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -/* - Significant parts of this code is inspired and/or copied from KDE Plasma sources, - available at kdebase/workspace/libs/plasma -*/ - -#ifndef AMAROK_CONTEXT_VIEW_H -#define AMAROK_CONTEXT_VIEW_H - -#include "context/ContextObserver.h" - -namespace Context -{ - -class AMAROK_EXPORT ContextView : public ContextSubject -{ - -public: - ContextView(); - ~ContextView(); - - /** - * Singleton pattern accessor. - */ - static ContextView* self(); - -private: - static ContextView* s_self; -}; - -} // Context namespace - -#endif diff --git a/amarok/tests/context/engines/TestDataEngine.cpp b/amarok/tests/context/engines/TestDataEngine.cpp deleted file mode 100644 index f629e388..00000000 --- a/amarok/tests/context/engines/TestDataEngine.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/**************************************************************************************** -* Copyright (c) 2010 Nathan Sala * -* * -* This program 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 2 of the License, or (at your option) any later * -* version. * -* * -* This program 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 * -* this program. If not, see . * -****************************************************************************************/ - -#include "TestDataEngine.h" -#include - - -TestDataEngine::TestDataEngine( QObject* parent ):QObject(parent) - //: m_containment(Plasma::Containment()), - //m_contextView(Context::ContextView(&m_containment, 0)) -{ -// qDebug() << " coucou "; -// m_contextWidget = new ContextWidget(0); -// m_contextWidget->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); -// m_contextWidget->setSpacing( 0 ); -// m_contextWidget->setFrameShape( QFrame::NoFrame ); -// m_contextWidget->setFrameShadow( QFrame::Sunken ); -// m_contextWidget->setMinimumSize( 100, 100 ); -// qDebug() << " coucou 1\n"; -// m_contextScene = new Plasma::Corona(this); -// qDebug() << " coucou 2\n"; -// m_containment = m_contextScene->addContainment(QString("testlol")); -// qDebug() << " coucou 3\n"; -// m_contextView = new Context::ContextView(m_containment, m_contextScene, NULL); -} diff --git a/amarok/tests/context/engines/TestDataEngine.h b/amarok/tests/context/engines/TestDataEngine.h deleted file mode 100644 index 9da2bfd5..00000000 --- a/amarok/tests/context/engines/TestDataEngine.h +++ /dev/null @@ -1,32 +0,0 @@ -/**************************************************************************************** -* Copyright (c) 2010 Nathan Sala * -* * -* This program 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 2 of the License, or (at your option) any later * -* version. * -* * -* This program 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 * -* this program. If not, see . * -****************************************************************************************/ - -#ifndef TESTDATAENGINE_H -#define TESTDATAENGINE_H - -#include "ContextView.h" - -#include - -class TestDataEngine : public QObject -{ - public: - TestDataEngine(QObject* parent = 0); - - private: -}; - -#endif //TESTDATAENGINE_H diff --git a/amarok/tests/context/engines/TestDataEngineBlackBox.cpp b/amarok/tests/context/engines/TestDataEngineBlackBox.cpp deleted file mode 100644 index b80cf700..00000000 --- a/amarok/tests/context/engines/TestDataEngineBlackBox.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************************** -* Copyright (c) 2010 Nathan Sala * -* * -* This program 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 2 of the License, or (at your option) any later * -* version. * -* * -* This program 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 * -* this program. If not, see . * -****************************************************************************************/ - -#include "TestDataEngineBlackBox.h" -#include - -TestDataEngineBlackBox::TestDataEngineBlackBox(QString identifier) -{ - Plasma::DataEngine* engine = 0; - // load the engine, add it to the engines - QString constraint = QString("[X-KDE-PluginInfo-Name] == '" + identifier + '\'').arg(identifier); - KService::List offers = KServiceTypeTrader::self()->query("Plasma/DataEngine", constraint); - QString error; - - if (!offers.isEmpty()) { - QVariantList allArgs; - allArgs << offers.first()->storageId(); - QString api = offers.first()->property("X-Plasma-API").toString(); - if (api.isEmpty()) { - if (offers.first()) { - KPluginLoader plugin(*offers.first()); - if (Plasma::isPluginVersionCompatible(plugin.pluginVersion())) { - engine = offers.first()->createInstance(0, allArgs, &error); - } - } - } else { - engine = new Plasma::DataEngine(0, offers.first()); - } - } - - m_engine = engine; -} - - -TestDataEngineBlackBox::~TestDataEngineBlackBox() -{ - delete m_engine; -} diff --git a/amarok/tests/context/engines/TestDataEngineBlackBox.h b/amarok/tests/context/engines/TestDataEngineBlackBox.h deleted file mode 100644 index 54fb6d5a..00000000 --- a/amarok/tests/context/engines/TestDataEngineBlackBox.h +++ /dev/null @@ -1,36 +0,0 @@ -/**************************************************************************************** -* Copyright (c) 2010 Nathan Sala * -* * -* This program 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 2 of the License, or (at your option) any later * -* version. * -* * -* This program 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 * -* this program. If not, see . * -****************************************************************************************/ - -#ifndef TESTDATAENGINEBLACKBOX_H -#define TESTDATAENGINEBLACKBOX_H -#include -#include - -/** - * This class provides a method to perform unit tests on data engines - * by retrieving the DataEngine through the KDE plugin manager - */ -class TestDataEngineBlackBox -{ - public: - TestDataEngineBlackBox( const QString identifier); - ~TestDataEngineBlackBox(); - - protected: - Plasma::DataEngine* m_engine; -}; - -#endif // TESTDATAENGINEBLACKBOX_H diff --git a/amarok/tests/context/engines/similarartists/CMakeLists.txt b/amarok/tests/context/engines/similarartists/CMakeLists.txt deleted file mode 100644 index 4511d8c7..00000000 --- a/amarok/tests/context/engines/similarartists/CMakeLists.txt +++ /dev/null @@ -1,25 +0,0 @@ -include_directories( - ${AMAROK_SOURCE_TREE}/context/engines/similarartists - ${AMAROK_SOURCE_TREE}/context/applets/similarartists - ${AMAROK_SOURCE_TREE}/network - ${AMAROK_TEST_TREE}/context/engines - ${AMAROK_COLLECTION_SUPPORT_DIR} - ${KDE4_INCLUDE_DIR} - ${QT_INCLUDES} -) - - -set( testsimilarartistsengine_SRCS - TestSimilarArtistsEngine.cpp - ${AMAROK_TEST_TREE}/context/engines/ContextView.cpp - ${AMAROK_TEST_TREE}/context/engines/TestDataEngine.cpp - ${AMAROK_SOURCE_TREE}/context/ContextObserver.cpp - ${AMAROK_SOURCE_TREE}/context/engines/similarartists/SimilarArtistsEngine.cpp - ${AMAROK_SOURCE_TREE}/context/applets/similarartists/SimilarArtist.cpp -) - -kde4_add_unit_test( testsimilarartistsengine ${testsimilarartistsengine_SRCS} ) - -add_dependencies( testsimilarartistsengine amaroklib) - -target_link_libraries( testsimilarartistsengine amarokcore amaroklib ${KDE4_KDECORE_LIBS} ${KDE4_KDEUI_LIBS} ${KDE4_KIO_LIBS} ${KDE4_PLASMA_LIBS} ${LIBLASTFM_LIBRARY} ${QT_QTTEST_LIBRARY}) diff --git a/amarok/tests/context/engines/similarartists/TestSimilarArtistsEngine.cpp b/amarok/tests/context/engines/similarartists/TestSimilarArtistsEngine.cpp deleted file mode 100644 index e46ab99b..00000000 --- a/amarok/tests/context/engines/similarartists/TestSimilarArtistsEngine.cpp +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************************** -* Copyright (c) 2009 Manuel Campomanes * -* Copyright (c) 2009 Nathan Sala * -* * -* This program 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 2 of the License, or (at your option) any later * -* version. * -* * -* This program 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 * -* this program. If not, see . * -****************************************************************************************/ - -#include "TestSimilarArtistsEngine.h" - -#include "context/engines/similarartists/SimilarArtistsEngine.h" -#include "core/support/Components.h" -#include "EngineController.h" - -#include - -#include - -QTEST_KDEMAIN_CORE( TestSimilarArtistsEngine ) - -TestSimilarArtistsEngine::TestSimilarArtistsEngine(QObject* parent) - : QObject(parent) -{ - -} - -void -TestSimilarArtistsEngine::initTestCase() -{ - //apparently the engine controller is needed somewhere, or we will get a crash... - EngineController *controller = new EngineController(); - Amarok::Components::setEngineController( controller ); - bool invoked = QMetaObject::invokeMethod( controller, "initializePhonon", Qt::DirectConnection ); - Q_ASSERT( invoked ); - - //Write here initializations - QList args; - m_engine = new SimilarArtistsEngine(0, args); -} - - -void -TestSimilarArtistsEngine::testDataEngineMethod() -{ - //Tests on the engine - QVERIFY(1 == 1); -} - -void -TestSimilarArtistsEngine::cleanupTestCase() -{ - //Write here cleaning - delete m_engine; -} - -#include "moc_TestSimilarArtistsEngine.cpp" diff --git a/amarok/tests/context/engines/similarartists/TestSimilarArtistsEngine.h b/amarok/tests/context/engines/similarartists/TestSimilarArtistsEngine.h deleted file mode 100644 index 3e8b677d..00000000 --- a/amarok/tests/context/engines/similarartists/TestSimilarArtistsEngine.h +++ /dev/null @@ -1,39 +0,0 @@ -/**************************************************************************************** -* Copyright (c) 2009 Manuel Campomanes * -* Copyright (c) 2009 Nathan Sala * -* * -* This program 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 2 of the License, or (at your option) any later * -* version. * -* * -* This program 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 * -* this program. If not, see . * -****************************************************************************************/ - -#ifndef TESTSIMILARARTISTSENGINE_H -#define TESTSIMILARARTISTSENGINE_H - -#include - -class SimilarArtistsEngine; - -class TestSimilarArtistsEngine : public QObject -{ - Q_OBJECT - public: - TestSimilarArtistsEngine(QObject* parent = 0); - private slots: - void initTestCase(); - void testDataEngineMethod(); - void cleanupTestCase(); - - private: - SimilarArtistsEngine* m_engine; -}; - -#endif // TESTSIMILARARTISTSENGINE_H diff --git a/amarok/tests/context/engines/upcomingevents/CMakeLists.txt b/amarok/tests/context/engines/upcomingevents/CMakeLists.txt deleted file mode 100644 index 9ef66e28..00000000 --- a/amarok/tests/context/engines/upcomingevents/CMakeLists.txt +++ /dev/null @@ -1,28 +0,0 @@ -add_subdirectory( data ) - -include_directories( - ${AMAROK_SOURCE_TREE}/context/engines/upcomingevents - ${AMAROK_SOURCE_TREE}/context/applets/upcomingevents - ${AMAROK_SOURCE_TREE}/context - ${AMAROK_TEST_TREE}/context/engines - ${AMAROK_COLLECTION_SUPPORT_DIR} - ${KDE4_INCLUDE_DIR} - ${QT_INCLUDES} -) - - -set( testupcomingeventsengine_SRCS - TestUpcomingEventsEngine.cpp - ${AMAROK_TEST_TREE}/context/engines/ContextView.cpp - ${AMAROK_TEST_TREE}/context/engines/TestDataEngine.cpp - ${AMAROK_SOURCE_TREE}/context/ContextObserver.cpp - ${AMAROK_SOURCE_TREE}/context/engines/upcomingevents/UpcomingEventsEngine.cpp - ${AMAROK_SOURCE_TREE}/context/applets/upcomingevents/LastFmEvent.cpp - ${AMAROK_SOURCE_TREE}/context/applets/upcomingevents/LastFmEventXmlParser.cpp -) - -kde4_add_unit_test( testupcomingeventsengine ${testupcomingeventsengine_SRCS} ) - -add_dependencies( testupcomingeventsengine amaroklib) - -target_link_libraries( testupcomingeventsengine amarokcore amaroklib ${KDE4_KDECORE_LIBS} ${KDE4_PLASMA_LIBS} ${KDE4_KDEUI_LIBS} ${KDE4_KIO_LIBS} ${QT_QTTEST_LIBRARY}) diff --git a/amarok/tests/context/engines/upcomingevents/TestUpcomingEventsEngine.cpp b/amarok/tests/context/engines/upcomingevents/TestUpcomingEventsEngine.cpp deleted file mode 100644 index d9771d98..00000000 --- a/amarok/tests/context/engines/upcomingevents/TestUpcomingEventsEngine.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/*************************************************************************************** -* Copyright (c) 2009 Nathan Sala * -* Copyright (c) 2010 Oleksandr Khayrullin * -* * -* This program 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 2 of the License, or (at your option) any later * -* version. * -* * -* This program 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 * -* this program. If not, see . * -****************************************************************************************/ - -#include "TestUpcomingEventsEngine.h" - -#include "core/support/Components.h" -#include "ContextObserver.h" -#include "EngineController.h" -#include "UpcomingEventsEngine.h" - -#include -#include - -QTEST_KDEMAIN_CORE( TestUpcomingEventsEngine ) - - -TestUpcomingEventsEngine::TestUpcomingEventsEngine(QObject* parent) - : TestDataEngine(parent) -{ -} - - -void -TestUpcomingEventsEngine::initTestCase() -{ - //apparently the engine controller is needed somewhere, or we will get a crash... - EngineController *controller = new EngineController(); - Amarok::Components::setEngineController( controller ); - bool invoked = QMetaObject::invokeMethod( controller, "initializePhonon", Qt::DirectConnection ); - Q_ASSERT( invoked ); - - //Write here initializations - QList args; - m_engine = new UpcomingEventsEngine(this, args); -} - -void -TestUpcomingEventsEngine::testDataEngineMethod() -{ - //Tests on the engine - QVERIFY(1 == 1); -} - -void -TestUpcomingEventsEngine::cleanupTestCase() -{ - //Write here cleaning - delete m_engine; - m_engine = 0; -} - -#include "moc_TestUpcomingEventsEngine.cpp" diff --git a/amarok/tests/context/engines/upcomingevents/TestUpcomingEventsEngine.h b/amarok/tests/context/engines/upcomingevents/TestUpcomingEventsEngine.h deleted file mode 100644 index a740e733..00000000 --- a/amarok/tests/context/engines/upcomingevents/TestUpcomingEventsEngine.h +++ /dev/null @@ -1,41 +0,0 @@ -/**************************************************************************************** -* Copyright (c) 2009 Nathan Sala * -* * -* This program 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 2 of the License, or (at your option) any later * -* version. * -* * -* This program 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 * -* this program. If not, see . * -****************************************************************************************/ - -#ifndef TESTUPCOMINGEVENTSENGINE_H -#define TESTUPCOMINGEVENTSENGINE_H - -#include -#include - -class UpcomingEventsEngine; - -class TestUpcomingEventsEngine : public TestDataEngine -{ - Q_OBJECT - - public: - TestUpcomingEventsEngine(QObject* parent = 0); - - private slots: - void initTestCase(); - void testDataEngineMethod(); - void cleanupTestCase(); - - private: - UpcomingEventsEngine* m_engine; -}; - -#endif // TESTUPCOMINGEVENTSENGINE_H diff --git a/amarok/tests/context/engines/upcomingevents/data/CMakeLists.txt b/amarok/tests/context/engines/upcomingevents/data/CMakeLists.txt deleted file mode 100644 index 26ce0d8f..00000000 --- a/amarok/tests/context/engines/upcomingevents/data/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -install( - FILES - response_ok.xml - response_fail_1.xml - response_fail_2.xml - DESTINATION ${PROJECT_BINARY_DIR} -) diff --git a/amarok/tests/context/engines/upcomingevents/data/response_fail_1.xml b/amarok/tests/context/engines/upcomingevents/data/response_fail_1.xml deleted file mode 100644 index 5cc5e57e..00000000 --- a/amarok/tests/context/engines/upcomingevents/data/response_fail_1.xml +++ /dev/null @@ -1,110 +0,0 @@ - - - - 1285206 - Live 105's Not So Silent Night - - Muse - 30 Seconds to Mars - AFI - Metric - Vampire Weekend - Muse - - - 8956524 - Oracle Arena - - OAKLAND, CA - United States - 7000 Coliseum Way - 94621 - - 37.750414 - -122.204498 - - - http://www.last.fm/venue/8956524+Oracle+Arena - - - http://userserve-ak.last.fm/serve/34/19546721.jpg - http://userserve-ak.last.fm/serve/64/19546721.jpg - http://userserve-ak.last.fm/serve/126/19546721.jpg - http://userserve-ak.last.fm/serve/252/19546721.jpg - http://userserve-ak.last.fm/serve/_/19546721/Oracle+Arena+goldenstatearena3.jpg - - Fri, 11 Dec 2009 16:05:01 - - http://userserve-ak.last.fm/serve/34/37215285.jpg - http://userserve-ak.last.fm/serve/64/37215285.jpg - http://userserve-ak.last.fm/serve/126/37215285.jpg - http://userserve-ak.last.fm/serve/252/37215285.jpg - 27 - 0 - lastfm:event=1285206 - http://www.last.fm/event/1285206+Live+105%27s+Not+So+Silent+Night - http://www.live105.com/pages/5547224.php - - 0 - - rock - alternative - - - - 1285310 - Not So Silent Night 2009 - - Muse - 30 Seconds to Mars - AFI - Metric - Vampire Weekend - DJ Miles - Scene of Action - Muse - - - 8791838 - Oracle Arena - - Oakland - United States - 7000 Coliseum Way - 94621 - - 37.750414 - -122.204498 - - - http://www.last.fm/venue/8791838+Oracle+Arena - http://www.coliseum.com/index.php - - http://userserve-ak.last.fm/serve/34/7534395.jpg - http://userserve-ak.last.fm/serve/64/7534395.jpg - http://userserve-ak.last.fm/serve/126/7534395.jpg - http://userserve-ak.last.fm/serve/252/7534395.jpg - http://userserve-ak.last.fm/serve/_/7534395/Oracle+Arena+goldenstatearena31.jpg - - Fri, 11 Dec 2009 17:33:01 -
    Live 105's annual holiday show!
    - http://userserve-ak.last.fm/serve/34/347209.jpg - http://userserve-ak.last.fm/serve/64/347209.jpg - http://userserve-ak.last.fm/serve/126/347209.jpg - http://userserve-ak.last.fm/serve/252/347209.jpg - 72 - 0 - lastfm:event=1285310 - http://www.last.fm/event/1285310+Not+So+Silent+Night+2009 - http://www.live105.com/ - - http://www.last.fm/affiliate/byid/29/1285310/19/ - - 0 - - rock - alternative - -
    -
    -
    \ No newline at end of file diff --git a/amarok/tests/context/engines/upcomingevents/data/response_fail_2.xml b/amarok/tests/context/engines/upcomingevents/data/response_fail_2.xml deleted file mode 100644 index 5cc5e57e..00000000 --- a/amarok/tests/context/engines/upcomingevents/data/response_fail_2.xml +++ /dev/null @@ -1,110 +0,0 @@ - - - - 1285206 - Live 105's Not So Silent Night - - Muse - 30 Seconds to Mars - AFI - Metric - Vampire Weekend - Muse - - - 8956524 - Oracle Arena - - OAKLAND, CA - United States - 7000 Coliseum Way - 94621 - - 37.750414 - -122.204498 - - - http://www.last.fm/venue/8956524+Oracle+Arena - - - http://userserve-ak.last.fm/serve/34/19546721.jpg - http://userserve-ak.last.fm/serve/64/19546721.jpg - http://userserve-ak.last.fm/serve/126/19546721.jpg - http://userserve-ak.last.fm/serve/252/19546721.jpg - http://userserve-ak.last.fm/serve/_/19546721/Oracle+Arena+goldenstatearena3.jpg - - Fri, 11 Dec 2009 16:05:01 - - http://userserve-ak.last.fm/serve/34/37215285.jpg - http://userserve-ak.last.fm/serve/64/37215285.jpg - http://userserve-ak.last.fm/serve/126/37215285.jpg - http://userserve-ak.last.fm/serve/252/37215285.jpg - 27 - 0 - lastfm:event=1285206 - http://www.last.fm/event/1285206+Live+105%27s+Not+So+Silent+Night - http://www.live105.com/pages/5547224.php - - 0 - - rock - alternative - - - - 1285310 - Not So Silent Night 2009 - - Muse - 30 Seconds to Mars - AFI - Metric - Vampire Weekend - DJ Miles - Scene of Action - Muse - - - 8791838 - Oracle Arena - - Oakland - United States - 7000 Coliseum Way - 94621 - - 37.750414 - -122.204498 - - - http://www.last.fm/venue/8791838+Oracle+Arena - http://www.coliseum.com/index.php - - http://userserve-ak.last.fm/serve/34/7534395.jpg - http://userserve-ak.last.fm/serve/64/7534395.jpg - http://userserve-ak.last.fm/serve/126/7534395.jpg - http://userserve-ak.last.fm/serve/252/7534395.jpg - http://userserve-ak.last.fm/serve/_/7534395/Oracle+Arena+goldenstatearena31.jpg - - Fri, 11 Dec 2009 17:33:01 -
    Live 105's annual holiday show!
    - http://userserve-ak.last.fm/serve/34/347209.jpg - http://userserve-ak.last.fm/serve/64/347209.jpg - http://userserve-ak.last.fm/serve/126/347209.jpg - http://userserve-ak.last.fm/serve/252/347209.jpg - 72 - 0 - lastfm:event=1285310 - http://www.last.fm/event/1285310+Not+So+Silent+Night+2009 - http://www.live105.com/ - - http://www.last.fm/affiliate/byid/29/1285310/19/ - - 0 - - rock - alternative - -
    -
    -
    \ No newline at end of file diff --git a/amarok/tests/context/engines/upcomingevents/data/response_ok.xml b/amarok/tests/context/engines/upcomingevents/data/response_ok.xml deleted file mode 100644 index 5cc5e57e..00000000 --- a/amarok/tests/context/engines/upcomingevents/data/response_ok.xml +++ /dev/null @@ -1,110 +0,0 @@ - - - - 1285206 - Live 105's Not So Silent Night - - Muse - 30 Seconds to Mars - AFI - Metric - Vampire Weekend - Muse - - - 8956524 - Oracle Arena - - OAKLAND, CA - United States - 7000 Coliseum Way - 94621 - - 37.750414 - -122.204498 - - - http://www.last.fm/venue/8956524+Oracle+Arena - - - http://userserve-ak.last.fm/serve/34/19546721.jpg - http://userserve-ak.last.fm/serve/64/19546721.jpg - http://userserve-ak.last.fm/serve/126/19546721.jpg - http://userserve-ak.last.fm/serve/252/19546721.jpg - http://userserve-ak.last.fm/serve/_/19546721/Oracle+Arena+goldenstatearena3.jpg - - Fri, 11 Dec 2009 16:05:01 - - http://userserve-ak.last.fm/serve/34/37215285.jpg - http://userserve-ak.last.fm/serve/64/37215285.jpg - http://userserve-ak.last.fm/serve/126/37215285.jpg - http://userserve-ak.last.fm/serve/252/37215285.jpg - 27 - 0 - lastfm:event=1285206 - http://www.last.fm/event/1285206+Live+105%27s+Not+So+Silent+Night - http://www.live105.com/pages/5547224.php - - 0 - - rock - alternative - - - - 1285310 - Not So Silent Night 2009 - - Muse - 30 Seconds to Mars - AFI - Metric - Vampire Weekend - DJ Miles - Scene of Action - Muse - - - 8791838 - Oracle Arena - - Oakland - United States - 7000 Coliseum Way - 94621 - - 37.750414 - -122.204498 - - - http://www.last.fm/venue/8791838+Oracle+Arena - http://www.coliseum.com/index.php - - http://userserve-ak.last.fm/serve/34/7534395.jpg - http://userserve-ak.last.fm/serve/64/7534395.jpg - http://userserve-ak.last.fm/serve/126/7534395.jpg - http://userserve-ak.last.fm/serve/252/7534395.jpg - http://userserve-ak.last.fm/serve/_/7534395/Oracle+Arena+goldenstatearena31.jpg - - Fri, 11 Dec 2009 17:33:01 -
    Live 105's annual holiday show!
    - http://userserve-ak.last.fm/serve/34/347209.jpg - http://userserve-ak.last.fm/serve/64/347209.jpg - http://userserve-ak.last.fm/serve/126/347209.jpg - http://userserve-ak.last.fm/serve/252/347209.jpg - 72 - 0 - lastfm:event=1285310 - http://www.last.fm/event/1285310+Not+So+Silent+Night+2009 - http://www.live105.com/ - - http://www.last.fm/affiliate/byid/29/1285310/19/ - - 0 - - rock - alternative - -
    -
    -
    \ No newline at end of file diff --git a/amarok/tests/core-impl/CMakeLists.txt b/amarok/tests/core-impl/CMakeLists.txt deleted file mode 100644 index 8e248977..00000000 --- a/amarok/tests/core-impl/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -add_subdirectory( collections ) -add_subdirectory( logger ) -add_subdirectory( meta ) -add_subdirectory( playlists ) -add_subdirectory( support ) diff --git a/amarok/tests/core-impl/collections/CMakeLists.txt b/amarok/tests/core-impl/collections/CMakeLists.txt deleted file mode 100644 index 42ffb0c3..00000000 --- a/amarok/tests/core-impl/collections/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -add_subdirectory( aggregate ) -add_subdirectory( db/sql ) -add_subdirectory( support ) diff --git a/amarok/tests/core-impl/collections/aggregate/CMakeLists.txt b/amarok/tests/core-impl/collections/aggregate/CMakeLists.txt deleted file mode 100644 index 3c85b349..00000000 --- a/amarok/tests/core-impl/collections/aggregate/CMakeLists.txt +++ /dev/null @@ -1,36 +0,0 @@ -include_directories( - ${AMAROK_TEST_TREE} - ${AMAROK_SOURCE_TREE} - ${AMAROK_UTILITY_TREE} - ${CMAKE_BINARY_DIR}/src - ${CMAKE_BINARY_DIR}/tests - ${AMAROK_COLLECTION_SUPPORT_DIR} - ${KDE4_INCLUDE_DIR} - ${QT_INCLUDES} - ${GOOGLEMOCK_INCLUDE_DIR} - ) - -#------------------------------- TestAggregateMeta ------------------------------- - -kde4_add_unit_test( testaggregatemeta - TestAggregateMeta.cpp - ${GOOGLEMOCK_SRCS} - ) - -add_dependencies( testaggregatemeta amarokconfig_h ) -add_dependencies( testaggregatemeta amarokcore ) -add_dependencies( testaggregatemeta amaroklib) - -if(APPLE) - SET_TARGET_PROPERTIES( testaggregatemeta PROPERTIES LINK_FLAGS "-undefined dynamic_lookup" ) -endif(APPLE) - -target_link_libraries( testaggregatemeta - amarokcore - amaroklib - ${KDE4_KDECORE_LIBS} - ${KDE4_KDEUI_LIBS} - ${QT_QTTEST_LIBRARY} - ${QT_QTCORE_LIBRARY} - ${GOOGLEMOCK_LIBRARIES} -) diff --git a/amarok/tests/core-impl/collections/aggregate/TestAggregateMeta.cpp b/amarok/tests/core-impl/collections/aggregate/TestAggregateMeta.cpp deleted file mode 100644 index e1a3bc8e..00000000 --- a/amarok/tests/core-impl/collections/aggregate/TestAggregateMeta.cpp +++ /dev/null @@ -1,516 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "TestAggregateMeta.h" - -#include "core/capabilities/OrganiseCapability.h" -#include "core/meta/Meta.h" -#include "core/meta/TrackEditor.h" -#include "core/support/Debug.h" -#include "core-impl/collections/aggregate/AggregateCollection.h" -#include "core-impl/collections/aggregate/AggregateMeta.h" - -#include "mocks/MetaMock.h" -#include "mocks/MockTrack.h" - -#include -#include - -#include -#include - -#include - -#include - -QTEST_KDEMAIN_CORE( TestAggregateMeta ) - -TestAggregateMeta::TestAggregateMeta() -{ - KCmdLineArgs::init( KGlobal::activeComponent().aboutData() ); - ::testing::InitGoogleMock( &KCmdLineArgs::qtArgc(), KCmdLineArgs::qtArgv() ); -} - -class MyTrackMock : public MetaMock -{ -public: - MyTrackMock() : MetaMock( QVariantMap() ) {} - - bool hasCapabilityInterface( Capabilities::Capability::Type type ) const - { - bool result = results.value( type ); - results.remove( type ); - return result; - } - - Capabilities::Capability* createCapabilityInterface(Capabilities::Capability::Type type) - { - Capabilities::Capability* cap = capabilities.value( type ); - capabilities.remove( type ); - return cap; - } - - Meta::TrackEditorPtr editor() - { - return trackEditors.isEmpty() ? Meta::TrackEditorPtr() : trackEditors.takeFirst(); - } - - mutable QMap results; - mutable QMap capabilities; - QList trackEditors; -}; - -class MyAlbumMock : public MockAlbum -{ -public: - MyAlbumMock() : MockAlbum( "testAlbum" ) {} - - bool hasCapabilityInterface( Capabilities::Capability::Type type ) const - { - bool result = results.value( type ); - results.remove( type ); - return result; - } - - Capabilities::Capability* createCapabilityInterface(Capabilities::Capability::Type type) - { - Capabilities::Capability* cap = capabilities.value( type ); - capabilities.remove( type ); - return cap; - } - - - mutable QMap results; - mutable QMap capabilities; -}; - -class MyArtistMock : public MockArtist -{ -public: - MyArtistMock() : MockArtist( "testArtist" ) {} - - bool hasCapabilityInterface( Capabilities::Capability::Type type ) const - { - bool result = results.value( type ); - results.remove( type ); - return result; - } - - Capabilities::Capability* createCapabilityInterface(Capabilities::Capability::Type type) - { - Capabilities::Capability* cap = capabilities.value( type ); - capabilities.remove( type ); - return cap; - } - - - mutable QMap results; - mutable QMap capabilities; -}; - -class MyGenreMock : public MockGenre -{ -public: - MyGenreMock() : MockGenre( "testGenre" ) {} - - bool hasCapabilityInterface( Capabilities::Capability::Type type ) const - { - bool result = results.value( type ); - results.remove( type ); - return result; - } - - Capabilities::Capability* createCapabilityInterface(Capabilities::Capability::Type type) - { - Capabilities::Capability* cap = capabilities.value( type ); - capabilities.remove( type ); - return cap; - } - - - mutable QMap results; - mutable QMap capabilities; -}; - -class MyComposerMock : public MockComposer -{ -public: - MyComposerMock() : MockComposer( "testComposer" ) {} - - bool hasCapabilityInterface( Capabilities::Capability::Type type ) const - { - bool result = results.value( type ); - results.remove( type ); - return result; - } - - Capabilities::Capability* createCapabilityInterface(Capabilities::Capability::Type type) - { - Capabilities::Capability* cap = capabilities.value( type ); - capabilities.remove( type ); - return cap; - } - - - mutable QMap results; - mutable QMap capabilities; -}; - -class MyYearMock : public MockYear -{ -public: - MyYearMock() : MockYear( "testYear" ) {} - - bool hasCapabilityInterface( Capabilities::Capability::Type type ) const - { - bool result = results.value( type ); - results.remove( type ); - return result; - } - - Capabilities::Capability* createCapabilityInterface(Capabilities::Capability::Type type) - { - Capabilities::Capability* cap = capabilities.value( type ); - capabilities.remove( type ); - return cap; - } - - - mutable QMap results; - mutable QMap capabilities; -}; - -class MyOrganiseCapability : public Capabilities::OrganiseCapability -{ -public: - void deleteTrack() {} -}; - -void -TestAggregateMeta::testHasCapabilityOnSingleTrack() -{ - MyTrackMock *mock = new MyTrackMock(); - QMap results; - results.insert( Capabilities::Capability::Buyable, false ); - results.insert( Capabilities::Capability::BookmarkThis, true ); - mock->results = results; - - Meta::TrackPtr ptr( mock ); - - Meta::AggregateTrack cut( 0, ptr ); - - QVERIFY( cut.hasCapabilityInterface( Capabilities::Capability::BookmarkThis ) ); - QVERIFY( !cut.hasCapabilityInterface( Capabilities::Capability::Buyable ) ); - QCOMPARE( mock->results.count(), 0 ); -} - -void -TestAggregateMeta::testCreateCapabilityOnSingleTrack() -{ - MyTrackMock *mock = new MyTrackMock(); - QMap capabilities; - capabilities.insert( Capabilities::Capability::Buyable, 0 ); - Capabilities::Capability *cap = new MyOrganiseCapability(); - capabilities.insert( Capabilities::Capability::Organisable, cap ); - - mock->capabilities = capabilities; - - Meta::TrackPtr ptr( mock ); - - Meta::AggregateTrack cut( 0, ptr ); - - QVERIFY( ! cut.createCapabilityInterface( Capabilities::Capability::Buyable ) ); - QCOMPARE( cut.createCapabilityInterface( Capabilities::Capability::Organisable ), cap ); - QCOMPARE( mock->capabilities.count(), 0 ); - delete cap; -} - -void -TestAggregateMeta::testHasCapabilityOnSingleAlbum() -{ - MyAlbumMock *mock = new MyAlbumMock(); - QMap results; - results.insert( Capabilities::Capability::Buyable, false ); - results.insert( Capabilities::Capability::BookmarkThis, true ); - mock->results = results; - - Meta::AlbumPtr ptr( mock ); - - Meta::AggregateAlbum album( 0, ptr ); - - QVERIFY( album.hasCapabilityInterface( Capabilities::Capability::BookmarkThis ) ); - QVERIFY( !album.hasCapabilityInterface( Capabilities::Capability::Buyable ) ); - QCOMPARE( mock->results.count(), 0 ); -} - -void -TestAggregateMeta::testCreateCapabilityOnSingleAlbum() -{ - MyAlbumMock *mock = new MyAlbumMock(); - QMap capabilities; - capabilities.insert( Capabilities::Capability::Buyable, 0 ); - Capabilities::Capability *cap = new MyOrganiseCapability(); - capabilities.insert( Capabilities::Capability::Organisable, cap ); - - mock->capabilities = capabilities; - - Meta::AlbumPtr ptr( mock ); - - Meta::AggregateAlbum album( 0, ptr ); - - QVERIFY( ! album.createCapabilityInterface( Capabilities::Capability::Buyable ) ); - QCOMPARE( album.createCapabilityInterface( Capabilities::Capability::Organisable ), cap ); - QCOMPARE( mock->capabilities.count(), 0 ); - delete cap; -} - -void -TestAggregateMeta::testHasCapabilityOnSingleArtist() -{ - MyArtistMock *mock = new MyArtistMock(); - QMap results; - results.insert( Capabilities::Capability::Buyable, false ); - results.insert( Capabilities::Capability::BookmarkThis, true ); - mock->results = results; - - Meta::ArtistPtr ptr( mock ); - - Meta::AggregateArtist artist( 0, ptr ); - - QVERIFY( artist.hasCapabilityInterface( Capabilities::Capability::BookmarkThis ) ); - QVERIFY( !artist.hasCapabilityInterface( Capabilities::Capability::Buyable ) ); - QCOMPARE( mock->results.count(), 0 ); -} - -void -TestAggregateMeta::testCreateCapabilityOnSingleArtist() -{ - MyArtistMock *mock = new MyArtistMock(); - QMap capabilities; - capabilities.insert( Capabilities::Capability::Buyable, 0 ); - Capabilities::Capability *cap = new MyOrganiseCapability(); - capabilities.insert( Capabilities::Capability::Organisable, cap ); - - mock->capabilities = capabilities; - - Meta::ArtistPtr ptr( mock ); - - Meta::AggregateArtist artist( 0, ptr ); - - QVERIFY( ! artist.createCapabilityInterface( Capabilities::Capability::Buyable ) ); - QCOMPARE( artist.createCapabilityInterface( Capabilities::Capability::Organisable ), cap ); - QCOMPARE( mock->capabilities.count(), 0 ); - delete cap; -} - -void -TestAggregateMeta::testHasCapabilityOnSingleComposer() -{ - MyComposerMock *mock = new MyComposerMock(); - QMap results; - results.insert( Capabilities::Capability::Buyable, false ); - results.insert( Capabilities::Capability::BookmarkThis, true ); - mock->results = results; - - Meta::ComposerPtr ptr( mock ); - - Meta::AggregateComposer cut( 0, ptr ); - - QVERIFY( cut.hasCapabilityInterface( Capabilities::Capability::BookmarkThis ) ); - QVERIFY( !cut.hasCapabilityInterface( Capabilities::Capability::Buyable ) ); - QCOMPARE( mock->results.count(), 0 ); -} - -void -TestAggregateMeta::testCreateCapabilityOnSingleComposer() -{ - MyComposerMock *mock = new MyComposerMock(); - QMap capabilities; - capabilities.insert( Capabilities::Capability::Buyable, 0 ); - Capabilities::Capability *cap = new MyOrganiseCapability(); - capabilities.insert( Capabilities::Capability::Organisable, cap ); - - mock->capabilities = capabilities; - - Meta::ComposerPtr ptr( mock ); - - Meta::AggregateComposer cut( 0, ptr ); - - QVERIFY( ! cut.createCapabilityInterface( Capabilities::Capability::Buyable ) ); - QCOMPARE( cut.createCapabilityInterface( Capabilities::Capability::Organisable ), cap ); - QCOMPARE( mock->capabilities.count(), 0 ); - delete cap; -} - -void -TestAggregateMeta::testHasCapabilityOnSingleGenre() -{ - MyGenreMock *mock = new MyGenreMock(); - QMap results; - results.insert( Capabilities::Capability::Buyable, false ); - results.insert( Capabilities::Capability::BookmarkThis, true ); - mock->results = results; - - Meta::GenrePtr ptr( mock ); - - Meta::AggregateGenre cut( 0, ptr ); - - QVERIFY( cut.hasCapabilityInterface( Capabilities::Capability::BookmarkThis ) ); - QVERIFY( !cut.hasCapabilityInterface( Capabilities::Capability::Buyable ) ); - QCOMPARE( mock->results.count(), 0 ); -} - -void -TestAggregateMeta::testCreateCapabilityOnSingleGenre() -{ - MyGenreMock *mock = new MyGenreMock(); - QMap capabilities; - capabilities.insert( Capabilities::Capability::Buyable, 0 ); - Capabilities::Capability *cap = new MyOrganiseCapability(); - capabilities.insert( Capabilities::Capability::Organisable, cap ); - - mock->capabilities = capabilities; - - Meta::GenrePtr ptr( mock ); - - Meta::AggregateGenre cut( 0, ptr ); - - QVERIFY( ! cut.createCapabilityInterface( Capabilities::Capability::Buyable ) ); - QCOMPARE( cut.createCapabilityInterface( Capabilities::Capability::Organisable ), cap ); - QCOMPARE( mock->capabilities.count(), 0 ); - delete cap; -} - -void -TestAggregateMeta::testHasCapabilityOnSingleYear() -{ - MyYearMock *mock = new MyYearMock(); - QMap results; - results.insert( Capabilities::Capability::Buyable, false ); - results.insert( Capabilities::Capability::BookmarkThis, true ); - mock->results = results; - - Meta::YearPtr ptr( mock ); - - Meta::AggreagateYear cut( 0, ptr ); - - QVERIFY( cut.hasCapabilityInterface( Capabilities::Capability::BookmarkThis ) ); - QVERIFY( !cut.hasCapabilityInterface( Capabilities::Capability::Buyable ) ); - QCOMPARE( mock->results.count(), 0 ); -} - -void -TestAggregateMeta::testCreateCapabilityOnSingleYear() -{ - MyYearMock *mock = new MyYearMock(); - QMap capabilities; - capabilities.insert( Capabilities::Capability::Buyable, 0 ); - Capabilities::Capability *cap = new MyOrganiseCapability(); - capabilities.insert( Capabilities::Capability::Organisable, cap ); - - mock->capabilities = capabilities; - - Meta::YearPtr ptr( mock ); - - Meta::AggreagateYear cut( 0, ptr ); - - QVERIFY( ! cut.createCapabilityInterface( Capabilities::Capability::Buyable ) ); - QCOMPARE( cut.createCapabilityInterface( Capabilities::Capability::Organisable ), cap ); - QCOMPARE( mock->capabilities.count(), 0 ); - delete cap; -} - -class MyTrackEditor : public Meta::TrackEditor -{ -public: - MyTrackEditor() : Meta::TrackEditor() - , beginCallCount(0) - , endCallcount(0) {} - virtual void setAlbum( const QString &newAlbum ) { Q_UNUSED( newAlbum ) } - virtual void setAlbumArtist( const QString &newAlbumArtist ) { Q_UNUSED( newAlbumArtist ) } - virtual void setArtist( const QString &newArtist ) { Q_UNUSED( newArtist ) } - virtual void setComposer( const QString &newComposer ) { Q_UNUSED( newComposer ) }; - virtual void setGenre( const QString &newGenre ) { Q_UNUSED( newGenre ) }; - virtual void setYear( int newYear ) { Q_UNUSED( newYear ) }; - virtual void setTitle( const QString &newTitle ) { Q_UNUSED( newTitle ) }; - virtual void setComment( const QString &newComment ) { Q_UNUSED( newComment ) }; - virtual void setTrackNumber( int newTrackNumber ) { Q_UNUSED( newTrackNumber ) }; - virtual void setDiscNumber( int newDiscNumber ) { Q_UNUSED( newDiscNumber ) }; - virtual void setBpm( const qreal newBpm ) { Q_UNUSED( newBpm ) }; - virtual void beginUpdate() { beginCallCount++; }; - virtual void endUpdate() { endCallcount++; }; - - int beginCallCount; - int endCallcount; -}; - -void -TestAggregateMeta::testEditableCapabilityOnMultipleTracks() -{ - MyTrackMock *mock1 = new MyTrackMock(); - MyTrackMock *mock2 = new MyTrackMock(); - KSharedPtr cap1 ( new MyTrackEditor() ); - KSharedPtr cap2 ( new MyTrackEditor() ); - mock1->trackEditors << Meta::TrackEditorPtr( cap1.data() ); - mock2->trackEditors << Meta::TrackEditorPtr( cap2.data() ); - - Meta::TrackPtr ptr1( mock1 ); - Meta::TrackPtr ptr2( mock2 ); - - Collections::AggregateCollection *collection = new Collections::AggregateCollection(); - - QSignalSpy spy( collection, SIGNAL(updated())); - QVERIFY( spy.isValid() ); - - Meta::AggregateTrack cut( collection, ptr1 ); - cut.add( ptr2 ); - - Meta::TrackEditorPtr editCap = cut.editor(); - QVERIFY( editCap ); - - QCOMPARE( cap1->beginCallCount, 0 ); - QCOMPARE( cap2->beginCallCount, 0 ); - editCap->beginUpdate(); - QCOMPARE( cap1->beginCallCount, 1 ); - QCOMPARE( cap2->beginCallCount, 1 ); - - QCOMPARE( cap1->endCallcount, 0 ); - QCOMPARE( cap2->endCallcount, 0 ); - editCap->endUpdate(); - QCOMPARE( cap1->endCallcount, 1 ); - QCOMPARE( cap2->endCallcount, 1 ); - - //the signal is delayed a bit, but that is ok - QTest::qWait( 50 ); - //required so that the colleection browser refreshes itself - QCOMPARE( spy.count(), 1 ); -} - -using ::testing::Return; -using ::testing::AnyNumber; - -void -TestAggregateMeta::testPrettyUrl() -{ - Meta::MockTrack *mock = new ::testing::NiceMock(); - EXPECT_CALL( *mock, prettyUrl() ).Times( AnyNumber() ).WillRepeatedly( Return( "foo" ) ); - - Meta::TrackPtr trackPtr( mock ); - - Meta::AggregateTrack track( 0, trackPtr ); - - QCOMPARE( track.prettyUrl(), QString( "foo" ) ); -} diff --git a/amarok/tests/core-impl/collections/aggregate/TestAggregateMeta.h b/amarok/tests/core-impl/collections/aggregate/TestAggregateMeta.h deleted file mode 100644 index 06a7e7d1..00000000 --- a/amarok/tests/core-impl/collections/aggregate/TestAggregateMeta.h +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef TESTAGGREGATEMETA_H -#define TESTAGGREGATEMETA_H - -#include - -class TestAggregateMeta : public QObject -{ - Q_OBJECT -public: - TestAggregateMeta(); - -private slots: - void testHasCapabilityOnSingleTrack(); - void testCreateCapabilityOnSingleTrack(); - - void testHasCapabilityOnSingleAlbum(); - void testCreateCapabilityOnSingleAlbum(); - - void testHasCapabilityOnSingleArtist(); - void testCreateCapabilityOnSingleArtist(); - - void testHasCapabilityOnSingleGenre(); - void testCreateCapabilityOnSingleGenre(); - - void testHasCapabilityOnSingleComposer(); - void testCreateCapabilityOnSingleComposer(); - - void testHasCapabilityOnSingleYear(); - void testCreateCapabilityOnSingleYear(); - - void testEditableCapabilityOnMultipleTracks(); - - void testPrettyUrl(); -}; - -#endif // TESTAGGREGATEMETA_H diff --git a/amarok/tests/core-impl/collections/db/sql/CMakeLists.txt b/amarok/tests/core-impl/collections/db/sql/CMakeLists.txt deleted file mode 100644 index 89a1f679..00000000 --- a/amarok/tests/core-impl/collections/db/sql/CMakeLists.txt +++ /dev/null @@ -1,150 +0,0 @@ - -# macro function to build a test target. -# -# we are linking agains the mysql collection and mysql embedded storage plugin (except on OSX where this is not possible) -macro(add_database_test test_target test_sources) - add_definitions(${MYSQL_CFLAGS}) - - if(APPLE) - #one cannot link to plugins on OS X. As a workaround, add anything relevant that goes into the mysqle plugin to each test - set( test_sources_internal - ${test_sources} - ${AMAROK_SOURCE_TREE}/core-impl/storage/sql/MySqlStorage.cpp - ${AMAROK_SOURCE_TREE}/core-impl/storage/sql/mysqlestorage/MySqlEmbeddedStorage.cpp ) - endif(APPLE) - - - kde4_add_unit_test( ${test_target} TESTNAME ${test_target} ${test_sources} ${test_sources_internal} ) - - if(APPLE) - SET_TARGET_PROPERTIES(${test_target} PROPERTIES LINK_FLAGS "-undefined dynamic_lookup") - endif(APPLE) - - # TODO: I don't think that we need to manually add dependencies here (Ralf) - add_dependencies( ${test_target} amarokconfig_h ) - add_dependencies( ${test_target} amarokcore ) - add_dependencies( ${test_target} amaroklib) - add_dependencies( ${test_target} amarok-sqlcollection) - if(NOT APPLE) - add_dependencies( ${test_target} amarok_collection-mysqlcollection amarok_storage-mysqlestorage ) - endif(NOT APPLE) - - target_link_libraries(${test_target} - amarokshared - amarokcore - amaroklib - amarok-sqlcollection - ${KDE4_KDECORE_LIBS} - ${KDE4_KIO_LIBS} - ${KDE4_THREADWEAVER_LIBS} - ${KDE4_KDEUI_LIBS} - ${QT_QTTEST_LIBRARY} - ${QT_QTCORE_LIBRARY} - ${MYSQL_EMBEDDED_LIBRARIES} - ${CMAKE_DL_LIBS} - ${ZLIB_LIBRARIES} - ${GOOGLEMOCK_LIBRARIES}) - - if(NOT APPLE) - target_link_libraries( ${test_target} amarok_collection-mysqlcollection amarok_storage-mysqlestorage ) - endif(NOT APPLE) - -endmacro(add_database_test) - - -include_directories( - ${AMAROK_TEST_TREE} - ${AMAROK_SOURCE_TREE} - ${AMAROK_SOURCE_TREE}/core-impl/collections/db/sql - ${AMAROK_SOURCE_TREE}/core-impl/logger - ${AMAROK_UTILITY_TREE} - ${CMAKE_BINARY_DIR}/src - ${CMAKE_BINARY_DIR}/tests - ${AMAROK_COLLECTION_SUPPORT_DIR} - ${KDE4_INCLUDE_DIR} - ${QT_INCLUDES} - ${MYSQL_INCLUDE_DIR} - ) - -#------------------------------- DatabaseUpdater Test ------------------------------- - -set( databaseupdatertest_SRCS - TestDatabaseUpdater.cpp - ${GOOGLEMOCK_SRCS} - ) - -add_database_test( testsqldatabaseupdater "${databaseupdatertest_SRCS}" ) - -#-------------------------------- Test SqlAlbum ----------------------- - -set( testsqlalbum_SRCS - TestSqlAlbum.cpp - ${GOOGLEMOCK_SRCS} - ) - -add_database_test( testsqlalbum "${testsqlalbum_SRCS}" ) - -#-------------------------------- Test SqlArtist ----------------------- - -set( testsqlartist_SRCS - TestSqlArtist.cpp - ${GOOGLEMOCK_SRCS} - ) - - -add_database_test( testsqlartist "${testsqlartist_SRCS}" ) -#-------------------------------- Test SqlCollection ----------------------- - -set( testsqlcollection_SRCS - TestSqlCollection.cpp - ${GOOGLEMOCK_SRCS} - ) - - -add_database_test( testsqlcollection "${testsqlcollection_SRCS}" ) - -#-------------------------------- Test SqlQueryMaker ----------------------- - -set( testsqlquerymaker_SRCS - TestSqlQueryMaker.cpp - ${GOOGLEMOCK_SRCS} - ) - - -add_database_test( testsqlquerymaker "${testsqlquerymaker_SRCS}" ) - -#-------------------------------- Test SqlScanManager ----------------------- - -set( testsqlscanmanager_SRCS - TestSqlScanManager.cpp - ${GOOGLEMOCK_SRCS} - ) - -add_database_test( testsqlscanmanager "${testsqlscanmanager_SRCS}" ) - -#-------------------------------- Test SqlTrack ----------------------- - -set( testsqltrack_SRCS - TestSqlTrack.cpp - ${AMAROK_TEST_TREE}/MetaNotificationSpy.cpp - ${GOOGLEMOCK_SRCS} - ) - - -add_database_test( testsqltrack "${testsqltrack_SRCS}" ) - -#-------------------------------- Test SqlCollectionLocation ----------------------- - -set( testsqlcollectionlocation_SRCS - TestSqlCollectionLocation.cpp - ${AMAROK_SOURCE_TREE}/core/interfaces/Logger.cpp - ${AMAROK_SOURCE_TREE}/core-impl/logger/ProxyLogger.cpp - ${GOOGLEMOCK_SRCS} - ) - -add_database_test( testsqlcollectionlocation "${testsqlcollectionlocation_SRCS}" ) - -if(NOT WIN32 AND NOT APPLE) - target_link_libraries( testsqlcollectionlocation crypt pthread ) -endif(NOT WIN32 AND NOT APPLE) - diff --git a/amarok/tests/core-impl/collections/db/sql/ScanManagerMock.h b/amarok/tests/core-impl/collections/db/sql/ScanManagerMock.h deleted file mode 100644 index 17b2f70d..00000000 --- a/amarok/tests/core-impl/collections/db/sql/ScanManagerMock.h +++ /dev/null @@ -1,37 +0,0 @@ - -/**************************************************************************************** - * Copyright (c) 2010 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef SCANMANAGERMOCK_H -#define SCANMANAGERMOCK_H - -#include - -#include - -class ScanManagerMock : public ScanManager -{ -public: - - MOCK_METHOD1( setBlockScan, void( bool ) ); - MOCK_METHOD1( isDirInCollection, bool( const QString& ) ); - - MOCK_METHOD0( startFullScan, void() ); - MOCK_METHOD1( startIncrementalScan, void( const QString& ) ); - MOCK_METHOD1( abort, void( const QString& ) ); -}; - -#endif diff --git a/amarok/tests/core-impl/collections/db/sql/SqlMountPointManagerMock.h b/amarok/tests/core-impl/collections/db/sql/SqlMountPointManagerMock.h deleted file mode 100644 index c7000408..00000000 --- a/amarok/tests/core-impl/collections/db/sql/SqlMountPointManagerMock.h +++ /dev/null @@ -1,104 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef SQLMOUNTPOINTMANAGERMOCK_H -#define SQLMOUNTPOINTMANAGERMOCK_H - -#include "core-impl/collections/db/MountPointManager.h" -#include "core-impl/collections/db/sql/SqlCollection.h" - -#include -#include - -//Note: this class will probably break horribly on win32 - -class SqlMountPointManagerMock : public MountPointManager -{ -public: - - SqlMountPointManagerMock( QObject *parent, SqlStorage *storage ) - : MountPointManager( parent, storage ) - { - } - - int getIdForUrl( const KUrl &url ) - { - QString path = url.path(); - foreach( int id, m_mountPoints.keys() ) - { - if( path.startsWith( m_mountPoints.value( id ) ) ) - { - return id; - } - } - - return -1; - } - - virtual QString getAbsolutePath ( const int deviceId, const QString& relativePath ) const - { - if( deviceId == -1 ) - return relativePath.right( relativePath.length() -1 ); - else - { - return m_mountPoints.value( deviceId ) + relativePath.right( relativePath.length() -1 ); - } - } - - virtual QString getRelativePath( const int deviceId, const QString& absolutePath ) const - { - if( deviceId == -1 ) - return '.' + absolutePath; - else - { - QString mp = m_mountPoints.value( deviceId ); - return '.' + absolutePath.right( mp.length() ); - } - } - - IdList getMountedDeviceIds() const - { - IdList result; - result << -1; - result << m_mountPoints.keys(); - return result; - } - - virtual QStringList collectionFolders() const - { - return m_folders; - } - - void setCollectionFolders( const QStringList &folders ) - { - m_folders = folders; - } - - void emitDeviceAdded( int id ) - { - emit deviceAdded( id ); - } - - void emitDeviceRemoved( int id ) - { - emit deviceRemoved( id ); - } - - QMap m_mountPoints; - QStringList m_folders; -}; - -#endif // SQLMOUNTPOINTMANAGERMOCK_H diff --git a/amarok/tests/core-impl/collections/db/sql/TestDatabaseUpdater.cpp b/amarok/tests/core-impl/collections/db/sql/TestDatabaseUpdater.cpp deleted file mode 100644 index 7a4c78bc..00000000 --- a/amarok/tests/core-impl/collections/db/sql/TestDatabaseUpdater.cpp +++ /dev/null @@ -1,157 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "TestDatabaseUpdater.h" - -#include "SqlCollection.h" -#include "DatabaseUpdater.h" -#include "core-impl/storage/sql/mysqlestorage/MySqlEmbeddedStorage.h" - -#include - -#include -#include - -#include - -QTEST_KDEMAIN_CORE( DatabaseUpdaterTest ) - - -DatabaseUpdaterTest::DatabaseUpdaterTest() - : QObject() -{ -} - -void -DatabaseUpdaterTest::initTestCase() -{ - m_tmpDir = new KTempDir(); - m_storage = new MySqlEmbeddedStorage(); - QVERIFY( m_storage->init( m_tmpDir->name() ) ); - m_collection = new Collections::SqlCollection( m_storage ); -} - -void -DatabaseUpdaterTest::cleanupTestCase() -{ - delete m_collection; - //m_storage is deleted by SqlCollection - delete m_tmpDir; -} - -void -DatabaseUpdaterTest::cleanup() -{ - m_storage->query( "BEGIN" ); - m_storage->query( "TRUNCATE TABLE tracks;" ); - m_storage->query( "TRUNCATE TABLE albums;" ); - m_storage->query( "TRUNCATE TABLE artists;" ); - m_storage->query( "TRUNCATE TABLE composers;" ); - m_storage->query( "TRUNCATE TABLE genres;" ); - m_storage->query( "TRUNCATE TABLE years;" ); - m_storage->query( "TRUNCATE TABLE urls;" ); - m_storage->query( "TRUNCATE TABLE directories;" ); - m_storage->query( "COMMIT" ); -} - -void -DatabaseUpdaterTest::testNeedsUpdate() -{ - // SqlCollection updates the table by itself - DatabaseUpdater updater( m_collection ); - - m_storage->query( QString( "UPDATE admin SET version = %1 WHERE component = 'DB_VERSION';" ).arg( updater.expectedDatabaseVersion() - 1 ) ); - - QVERIFY( updater.needsUpdate() ); - QVERIFY( updater.update() ); - QVERIFY( !updater.needsUpdate() ); -} - -void -DatabaseUpdaterTest::testNeedsNoUpdate() -{ - // SqlCollection updates the table by itself - DatabaseUpdater updater( m_collection ); - - QVERIFY( !updater.needsUpdate() ); - QVERIFY( !updater.update() ); -} - -void -DatabaseUpdaterTest::testDeleteAllRedundant() -{ - //setup base data - m_storage->query( "INSERT INTO artists(id, name) VALUES (1, 'trackArtist');" ); - m_storage->query( "INSERT INTO artists(id, name) VALUES (2, 'albumArtist');" ); - m_storage->query( "INSERT INTO artists(id, name) VALUES (3, 'invalidArtist');" ); - - m_storage->query( "INSERT INTO composers(id, name) VALUES (1, 'composer');" ); - m_storage->query( "INSERT INTO composers(id, name) VALUES (2, 'invalidComposer');" ); - m_storage->query( "INSERT INTO genres(id, name) VALUES (1, 'genre');" ); - m_storage->query( "INSERT INTO genres(id, name) VALUES (2, 'invalidGenre');" ); - m_storage->query( "INSERT INTO years(id, name) VALUES (1, '1');" ); - m_storage->query( "INSERT INTO years(id, name) VALUES (2, '2');" ); - - m_storage->query( "INSERT INTO albums(id,name,artist) VALUES (1, 'album1', 2);" ); - m_storage->query( "INSERT INTO albums(id,name,artist) VALUES (2, 'albumInvalidAlbum',1);" ); - - m_storage->query( "INSERT INTO urls(id, deviceid, rpath, uniqueid ) VALUES (1, -1, './track1.mp3', 'uid://1');" ); - m_storage->query( "INSERT INTO urls(id, deviceid, rpath, uniqueid ) VALUES (2, -1, './invalidTrack.mp3', 'uid://2');" ); - - m_storage->query( "INSERT INTO tracks(id,url,title,artist,album,genre,year,composer) " - "VALUES (1,1,'track1',1,1,1,1,1 );" ); - - DatabaseUpdater updater( m_collection ); - updater.deleteAllRedundant("album"); - updater.deleteAllRedundant("artist"); - updater.deleteAllRedundant("genre"); - updater.deleteAllRedundant("composer"); - updater.deleteAllRedundant("url"); - updater.deleteAllRedundant("year"); - - QStringList count; - count = m_storage->query( "SELECT COUNT(*) FROM albums;" ); - QCOMPARE( count.first().toInt(), 1 ); - count = m_storage->query( "SELECT COUNT(*) FROM artists;" ); - QCOMPARE( count.first().toInt(), 2 ); - count = m_storage->query( "SELECT COUNT(*) FROM genres;" ); - QCOMPARE( count.first().toInt(), 1 ); - count = m_storage->query( "SELECT COUNT(*) FROM composers;" ); - QCOMPARE( count.first().toInt(), 1 ); - count = m_storage->query( "SELECT COUNT(*) FROM urls;" ); - QCOMPARE( count.first().toInt(), 1 ); - count = m_storage->query( "SELECT COUNT(*) FROM years;" ); - QCOMPARE( count.first().toInt(), 1 ); -} - -void -DatabaseUpdaterTest::testCheckTables() -{ - DatabaseUpdater updater( m_collection ); - updater.checkTables(); // just execute it to get test coverage -} - -void -DatabaseUpdaterTest::testCreatePermanentTables() -{ - // actually the collection will call updater.update itself - // after the update we should have 18 tables - - QStringList tables = m_storage->query( "select table_name from INFORMATION_SCHEMA.tables WHERE table_schema='amarok'" ); - QCOMPARE( tables.count(), 18 ); -} - -#include "moc_TestDatabaseUpdater.cpp" diff --git a/amarok/tests/core-impl/collections/db/sql/TestDatabaseUpdater.h b/amarok/tests/core-impl/collections/db/sql/TestDatabaseUpdater.h deleted file mode 100644 index bbeeaaf4..00000000 --- a/amarok/tests/core-impl/collections/db/sql/TestDatabaseUpdater.h +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef DATABASEUPDATERTEST_H -#define DATABASEUPDATERTEST_H - -#include - -#include - -class MySqlEmbeddedStorage; - -namespace Collections { - class SqlCollection; -} - -class DatabaseUpdaterTest : public QObject -{ - Q_OBJECT -public: - DatabaseUpdaterTest(); - -private slots: - void initTestCase(); - void cleanupTestCase(); - - void cleanup(); - - void testNeedsUpdate(); - void testNeedsNoUpdate(); - void testDeleteAllRedundant(); - void testCheckTables(); - void testCreatePermanentTables(); - -private: - Collections::SqlCollection *m_collection; - MySqlEmbeddedStorage *m_storage; - KTempDir *m_tmpDir; -}; - -#endif // DATABASEUPDATERTEST_H diff --git a/amarok/tests/core-impl/collections/db/sql/TestSqlAlbum.cpp b/amarok/tests/core-impl/collections/db/sql/TestSqlAlbum.cpp deleted file mode 100644 index 7a4c0fe7..00000000 --- a/amarok/tests/core-impl/collections/db/sql/TestSqlAlbum.cpp +++ /dev/null @@ -1,421 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Maximilian Kossick * - * Copyright (c) 2010 Ralf Engels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "TestSqlAlbum.h" - -#include "core/meta/Meta.h" -#include "core-impl/storage/sql/mysqlestorage/MySqlEmbeddedStorage.h" -#include "SqlCollection.h" -#include "SqlMountPointManagerMock.h" - -#include "core/capabilities/ActionsCapability.h" -#include "core/capabilities/BookmarkThisCapability.h" - -#include -#include - -#include - -QTEST_KDEMAIN_CORE( TestSqlAlbum ) - -TestSqlAlbum::TestSqlAlbum() - : QObject() - , m_collection( 0 ) - , m_storage( 0 ) - , m_tmpDir( 0 ) -{ -} - -TestSqlAlbum::~TestSqlAlbum() -{ } - -void -TestSqlAlbum::initTestCase() -{ - m_tmpDir = new KTempDir(); - m_storage = new MySqlEmbeddedStorage(); - QVERIFY( m_storage->init( m_tmpDir->name() ) ); - m_collection = new Collections::SqlCollection( m_storage ); - m_collection->setMountPointManager( new SqlMountPointManagerMock( this, m_storage ) ); -} - -void -TestSqlAlbum::cleanupTestCase() -{ - delete m_collection; - //m_storage is deleted by SqlCollection - delete m_tmpDir; -} - -void -TestSqlAlbum::init() -{ - //setup base data - m_storage->query( "INSERT INTO artists(id, name) VALUES (1, 'artist1');" ); - m_storage->query( "INSERT INTO artists(id, name) VALUES (2, 'artist2');" ); - m_storage->query( "INSERT INTO artists(id, name) VALUES (3, 'artist3');" ); - - m_storage->query( "INSERT INTO composers(id, name) VALUES (1, 'composer1');" ); - m_storage->query( "INSERT INTO genres(id, name) VALUES (1, 'genre1');" ); - m_storage->query( "INSERT INTO years(id, name) VALUES (1, '1');" ); - - m_storage->query( "INSERT INTO directories(id, deviceid, dir) VALUES (1, -1, './');" ); - - m_storage->query( "INSERT INTO urls(id, deviceid, rpath, directory, uniqueid) VALUES (1, -1, './IDoNotExist.mp3', 1, 'uid://1');" ); - m_storage->query( "INSERT INTO urls(id, deviceid, rpath, directory, uniqueid) VALUES (2, -1, './IDoNotExistAsWell.mp3', 1, 'uid://2');" ); - m_storage->query( "INSERT INTO urls(id, deviceid, rpath, directory, uniqueid) VALUES (3, -1, './MeNeither.mp3', 1, 'uid:/3');" ); - m_storage->query( "INSERT INTO urls(id, deviceid, rpath, directory, uniqueid) VALUES (4, -1, './MeNeitherToo.mp3', 1, 'uid:/4');" ); - - m_collection->registry()->emptyCache(); -} - -void -TestSqlAlbum::cleanup() -{ - m_storage->query( "TRUNCATE TABLE years;" ); - m_storage->query( "TRUNCATE TABLE genres;" ); - m_storage->query( "TRUNCATE TABLE composers;" ); - m_storage->query( "TRUNCATE TABLE albums;" ); - m_storage->query( "TRUNCATE TABLE artists;" ); - m_storage->query( "TRUNCATE TABLE tracks;" ); - m_storage->query( "TRUNCATE TABLE urls;" ); - m_storage->query( "TRUNCATE TABLE directories;" ); - m_storage->query( "TRUNCATE TABLE urls_labels;" ); -} - -void -TestSqlAlbum::testTracks() -{ - m_storage->query( "INSERT INTO albums(id,name,artist) VALUES (1, 'album1',1);" ); - m_storage->query( "INSERT INTO albums(id,name,artist) VALUES (2, 'album2',1);" ); - m_storage->query( "INSERT INTO tracks(id,url,title,artist,album,genre,year,composer) " - "VALUES (1,1,'track1',1,1,1,1,1 );" ); - m_storage->query( "INSERT INTO tracks(id,url,title,artist,album,genre,year,composer) " - "VALUES (2,2,'track2',1,1,1,1,1 );" ); - m_storage->query( "INSERT INTO tracks(id,url,title,artist,album,genre,year,composer) " - "VALUES (3,3,'trackInOtherAlbum',1,2,1,1,1 );" ); - - Meta::AlbumPtr album = m_collection->registry()->getAlbum( 1 ); - Meta::SqlAlbum *sqlAlbum = static_cast( album.data() ); - - // check two tracks - Meta::TrackList tracks = sqlAlbum->tracks(); - QCOMPARE( sqlAlbum->tracks().count(), 2 ); - - // remove one track - Meta::SqlTrack *sqlTrack = static_cast( tracks.first().data() ); - sqlTrack->setAlbum( "newAlbum" ); - QCOMPARE( sqlAlbum->tracks().count(), 1 ); -} - -void -TestSqlAlbum::testIsCompilation() -{ - m_storage->query( "INSERT INTO albums(id,name,artist) VALUES (1, 'album1',1);" ); - m_storage->query( "INSERT INTO tracks(id,url,title,artist,album,genre,year,composer) " - "VALUES (1,1,'track1',1,1,1,1,1 );" ); - - m_storage->query( "INSERT INTO albums(id,name,artist) VALUES (2, 'compilation',NULL);" ); - m_storage->query( "INSERT INTO tracks(id,url,title,artist,album,genre,year,composer) " - "VALUES (2,2,'track2',1,1,1,1,1 );" ); - - Meta::AlbumPtr album = m_collection->registry()->getAlbum( 1 ); - QVERIFY( !album->isCompilation() ); - QVERIFY( album->hasAlbumArtist() ); - - album = m_collection->registry()->getAlbum( 2 ); - QVERIFY( album->isCompilation() ); - QVERIFY( !album->hasAlbumArtist() ); -} - -void -TestSqlAlbum::testAlbumArtist() -{ - m_storage->query( "INSERT INTO albums(id,name,artist) VALUES (1, 'album1',1);" ); - - Meta::AlbumPtr album = m_collection->registry()->getAlbum( 1 ); - QVERIFY( !album->isCompilation() ); - QVERIFY( album->hasAlbumArtist() ); - QVERIFY( album->albumArtist() ); - QCOMPARE( album->albumArtist()->name(), QString( "artist1" ) ); -} - -void -TestSqlAlbum::testImage() -{ - m_storage->query( "INSERT INTO albums(id,name,artist) VALUES (1, 'imageTestAlbum',1);" ); - - Meta::AlbumPtr album = m_collection->registry()->getAlbum( 1 ); - Meta::SqlAlbum *sqlAlbum = static_cast( album.data() ); - sqlAlbum->setSuppressImageAutoFetch( true ); - - QVERIFY( !album->hasImage() ); - QVERIFY( !album->hasImage(100) ); - QVERIFY( !album->hasImage(0) ); - - QVERIFY( album->canUpdateImage() ); - - // set an image - sqlAlbum->setImage( QImage( QSize(100, 100), QImage::Format_Mono ) ); - QVERIFY( album->hasImage() ); - QVERIFY( album->hasImage(100) ); - QVERIFY( album->hasImage(0) ); - QCOMPARE( album->image(47).width(), 47 ); - QString largeImagePath = album->imageLocation().path(); - QVERIFY( QFile::exists( largeImagePath ) ); - - // remove the image - album->removeImage(); - QVERIFY( !album->hasImage() ); - QVERIFY( !album->hasImage(100) ); - QVERIFY( !album->hasImage(0) ); - QVERIFY( !QFile::exists( largeImagePath ) ); - - // IMPROVEMENT: also test embedded image and an image outside the cache directory -} - -void -TestSqlAlbum::testCapabilities() -{ - Meta::AlbumPtr album = m_collection->registry()->getAlbum( "Test album", "test artist" ); - - QVERIFY( album->hasCapabilityInterface( Capabilities::Capability::Actions ) ); - Capabilities::ActionsCapability *ac = album->create(); - QVERIFY( ac ); - QVERIFY( ac->actions().count() > 4 ); - - QVERIFY( album->hasCapabilityInterface( Capabilities::Capability::BookmarkThis ) ); - Capabilities::BookmarkThisCapability *btc = album->create(); - QVERIFY( btc ); - QVERIFY( btc->bookmarkAction() ); - - // need to delete the actions. They hold pointers that prevent the registry from cleaning - // it's state. - foreach( QAction *action, ac->actions() ) - delete action; - delete btc->bookmarkAction(); - delete ac; - delete btc; -} - -void -TestSqlAlbum::testSetCompilationWithoutExistingCompilation() -{ - m_storage->query( "INSERT INTO albums(id,name,artist) VALUES (1, 'album1',1);" ); - m_storage->query( "INSERT INTO tracks(id,url,title,artist,album,genre,year,composer) " - "VALUES (1,1,'track1',1,1,1,1,1 );" ); - - Meta::TrackPtr track = m_collection->registry()->getTrack( 1 ); - Meta::AlbumPtr album = track->album(); - Meta::SqlAlbum *sqlAlbum = static_cast( album.data() ); - QVERIFY( album->hasAlbumArtist() ); - QVERIFY( !album->isCompilation() ); - QCOMPARE( sqlAlbum->id(), 1 ); - QCOMPARE( album->tracks().count(), 1 ); - sqlAlbum->setCompilation( true ); - - // now the track should be in the compilation - album = track->album(); - sqlAlbum = static_cast( album.data() ); - QCOMPARE( sqlAlbum->id(), 2 ); // a new album - QVERIFY( !album->hasAlbumArtist() ); - QVERIFY( album->isCompilation() ); -} - -void -TestSqlAlbum::testSetCompilationWithExistingCompilation() -{ - m_storage->query( "INSERT INTO albums(id,name,artist) VALUES (1, 'albumAndCompilation1',1);" ); - m_storage->query( "INSERT INTO albums(id,name) VALUES (2, 'albumAndCompilation1');" ); - m_storage->query( "INSERT INTO tracks(id,url,title,artist,album,genre,year,composer) " - "VALUES (1,1,'track1',1,1,1,1,1 );" ); - Meta::AlbumPtr compilation = m_collection->registry()->getAlbum( 2 ); - QVERIFY( compilation->isCompilation() ); - - Meta::TrackPtr track = m_collection->registry()->getTrack( 1 ); - Meta::AlbumPtr album = track->album(); - Meta::SqlAlbum *sqlAlbum = static_cast( album.data() ); - QVERIFY( album->hasAlbumArtist() ); - QVERIFY( !album->isCompilation() ); - QCOMPARE( sqlAlbum->id(), 1 ); - QCOMPARE( album->tracks().count(), 1 ); - sqlAlbum->setCompilation( true ); - - // now the track should be in the compilation - album = track->album(); - sqlAlbum = static_cast( album.data() ); - QCOMPARE( sqlAlbum->id(), 2 ); // the exisitng compilation album - QVERIFY( !album->hasAlbumArtist() ); - QVERIFY( album->isCompilation() ); - QCOMPARE( album, compilation ); //track returns new album, but the same object that we retrieved above - - QStringList albumResult = m_storage->query( "SELECT name, artist FROM albums WHERE id = 1" ); -} - -void -TestSqlAlbum::testUnsetCompilationWithoutExistingAlbum() -{ - m_storage->query( "INSERT INTO albums(id,name,artist) VALUES (1, 'album1',NULL);" ); - m_storage->query( "INSERT INTO tracks(id,url,title,artist,album,genre,year,composer) " - "VALUES (1,1,'track1',1,1,1,1,1 );" ); - - Meta::TrackPtr track = m_collection->registry()->getTrack( 1 ); - Meta::AlbumPtr album = track->album(); - Meta::SqlAlbum *sqlAlbum = static_cast( album.data() ); - QVERIFY( !album->hasAlbumArtist() ); - QVERIFY( album->isCompilation() ); - sqlAlbum->setCompilation( false ); - - // now the track should be in a normal album - album = track->album(); - sqlAlbum = static_cast( album.data() ); - QVERIFY( album->hasAlbumArtist() ); - QVERIFY( !album->isCompilation() ); - QCOMPARE( album->name(), QString( "album1" ) ); //album name did not change - QCOMPARE( album->albumArtist()->name(), track->artist()->name() ); //artist is the same -} - -void -TestSqlAlbum::testUnsetCompilationWithExistingAlbum() -{ - m_storage->query( "INSERT INTO albums(id,name,artist) VALUES (1, 'albumAndCompilation1',NULL);" ); - m_storage->query( "INSERT INTO albums(id,name,artist) VALUES (2, 'albumAndCompilation1',1);" ); - m_storage->query( "INSERT INTO tracks(id,url,title,artist,album,genre,year,composer) " - "VALUES (1,1,'track1',1,1,1,1,1 );" ); - - Meta::TrackPtr track = m_collection->registry()->getTrack( 1 ); - Meta::AlbumPtr compilation = track->album(); - Meta::SqlAlbum *sqlCompilation = static_cast( compilation.data() ); - QVERIFY( compilation->isCompilation() ); - sqlCompilation->setCompilation( false ); - - // now the track should be in a normal album - Meta::AlbumPtr album = track->album(); - Meta::SqlAlbum *sqlAlbum = static_cast( album.data() ); - QCOMPARE( sqlAlbum->id(), 2 ); // the albums should be the already existing one - QVERIFY( album->hasAlbumArtist() ); - QVERIFY( !album->isCompilation() ); - QCOMPARE( album->name(), compilation->name() ); //album name did not change - QCOMPARE( album->albumArtist()->name(), track->artist()->name() ); //artist is the same -} - -void -TestSqlAlbum::testUnsetCompilationWithMultipleExistingAlbums() -{ - m_storage->query( "INSERT INTO albums(id,name,artist) VALUES (1,'albumAndCompilation1',NULL);" ); - m_storage->query( "INSERT INTO albums(id,name,artist) VALUES (2,'albumAndCompilation1',1);" ); - m_storage->query( "INSERT INTO albums(id,name,artist) VALUES (3,'albumAndCompilation1',2);" ); - m_storage->query( "INSERT INTO tracks(id,url,title,artist,album,genre,year,composer) " - "VALUES (1,1,'track1',1,1,1,1,1 );" ); - m_storage->query( "INSERT INTO tracks(id,url,title,artist,album,genre,year,composer) " - "VALUES (2,2,'track2',2,3,1,1,1 );" ); - m_storage->query( "INSERT INTO tracks(id,url,title,artist,album,genre,year,composer) " - "VALUES (3,3,'track3',1,2,1,1,1 );" ); - - Meta::TrackPtr track = m_collection->registry()->getTrack( 1 ); - Meta::AlbumPtr compilation = track->album(); - Meta::SqlAlbum *sqlCompilation = static_cast( compilation.data() ); - QVERIFY( compilation->isCompilation() ); - sqlCompilation->setCompilation( false ); - - Meta::AlbumPtr album; - Meta::SqlAlbum *sqlAlbum; - - // now the tracks should be in a normal album - album = track->album(); - sqlAlbum = static_cast( album.data() ); - QVERIFY( album->hasAlbumArtist() ); - QVERIFY( !album->isCompilation() ); - QCOMPARE( album->name(), compilation->name() ); //album name did not change - QCOMPARE( album->albumArtist()->name(), track->artist()->name() ); //artist is the same - QCOMPARE( sqlAlbum->id(), 2 ); // the albums should be the already existing one - - // tracks 2 and 3 should just stay -} - -void -TestSqlAlbum::testUnsetCompilationWithArtistAFeaturingB() -{ - m_storage->query( "INSERT INTO artists(id,name) VALUES (4,'artist1 feat. artist2');" ); - - m_storage->query( "INSERT INTO albums(id,name,artist) VALUES (1,'albumAndCompilation1',NULL);" ); - m_storage->query( "INSERT INTO albums(id,name,artist) VALUES (2,'albumAndCompilation1',1);" ); - - m_storage->query( "INSERT INTO tracks(id,url,title,artist,album,genre,year,composer) " - "VALUES (1,1,'track1',4,1,1,1,1 );" ); - m_storage->query( "INSERT INTO tracks(id,url,title,artist,album,genre,year,composer) " - "VALUES (2,2,'track2',1,2,1,1,1 );" ); - - Meta::TrackPtr track = m_collection->registry()->getTrack( 1 ); - Meta::AlbumPtr compilation = track->album(); - Meta::SqlAlbum *sqlCompilation = static_cast( compilation.data() ); - QVERIFY( compilation->isCompilation() ); - sqlCompilation->setCompilation( false ); - - Meta::AlbumPtr album; - Meta::SqlAlbum *sqlAlbum; - - // now the tracks should be in a normal album - album = track->album(); - sqlAlbum = static_cast( album.data() ); - QVERIFY( album->hasAlbumArtist() ); - QVERIFY( !album->isCompilation() ); - QCOMPARE( album->name(), compilation->name() ); //album name did not change - QCOMPARE( track->artist()->name(), QString( "artist1 feat. artist2" ) ); - QCOMPARE( album->albumArtist()->name(), QString("artist1") ); // artist is the same - QCOMPARE( sqlAlbum->id(), 2 ); // the albums should be the already existing one -} - -void -TestSqlAlbum::testUnsetCompilationWithMultipleArtists() -{ - m_storage->query( "INSERT INTO albums(id,name,artist) VALUES (1,'album1',NULL);" ); - - m_storage->query( "INSERT INTO tracks(id,url,title,artist,album,genre,year,composer) " - "VALUES (1,1,'track1',1,1,1,1,1 );" ); - m_storage->query( "INSERT INTO tracks(id,url,title,artist,album,genre,year,composer) " - "VALUES (2,2,'track2',2,1,1,1,1 );" ); - - Meta::TrackPtr track = m_collection->registry()->getTrack( 1 ); - Meta::AlbumPtr compilation = track->album(); - Meta::SqlAlbum *sqlCompilation = static_cast( compilation.data() ); - QVERIFY( compilation->isCompilation() ); - sqlCompilation->setCompilation( false ); - - Meta::AlbumPtr album; - Meta::SqlAlbum *sqlAlbum; - - // now the tracks should be in a normal album - album = track->album(); - sqlAlbum = static_cast( album.data() ); - QVERIFY( album->hasAlbumArtist() ); - QVERIFY( !album->isCompilation() ); - QCOMPARE( album->name(), compilation->name() ); //album name did not change - QCOMPARE( album->albumArtist()->name(), track->artist()->name() ); //artist is the same - QVERIFY( sqlAlbum->id() != 1 ); // the albums should be a new one - - track = m_collection->registry()->getTrack( 2 ); - album = track->album(); - sqlAlbum = static_cast( album.data() ); - QVERIFY( album->hasAlbumArtist() ); - QVERIFY( !album->isCompilation() ); - QCOMPARE( album->name(), compilation->name() ); //album name did not change - QCOMPARE( album->albumArtist()->name(), track->artist()->name() ); //artist is the same - QVERIFY( sqlAlbum->id() != 1 ); // the albums should be a new one -} - -#include "moc_TestSqlAlbum.cpp" diff --git a/amarok/tests/core-impl/collections/db/sql/TestSqlAlbum.h b/amarok/tests/core-impl/collections/db/sql/TestSqlAlbum.h deleted file mode 100644 index 93480e15..00000000 --- a/amarok/tests/core-impl/collections/db/sql/TestSqlAlbum.h +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef TESTSQLALBUM_H -#define TESTSQLALBUM_H - -#include - -#include - -class MySqlEmbeddedStorage; -class SqlRegistry; - -namespace Collections { - class SqlCollection; -} - -class TestSqlAlbum : public QObject -{ - Q_OBJECT -public: - TestSqlAlbum(); - ~TestSqlAlbum(); - -private slots: - void initTestCase(); - void cleanupTestCase(); - - void init(); - void cleanup(); - - void testTracks(); - void testIsCompilation(); - void testAlbumArtist(); - void testImage(); - - void testCapabilities(); - - void testSetCompilationWithoutExistingCompilation(); - void testSetCompilationWithExistingCompilation(); - void testUnsetCompilationWithoutExistingAlbum(); - void testUnsetCompilationWithExistingAlbum(); - void testUnsetCompilationWithMultipleExistingAlbums(); - - void testUnsetCompilationWithArtistAFeaturingB(); - void testUnsetCompilationWithMultipleArtists(); - -private: - Collections::SqlCollection *m_collection; - MySqlEmbeddedStorage *m_storage; - KTempDir *m_tmpDir; -}; - -#endif // TESTSQLALBUM_H diff --git a/amarok/tests/core-impl/collections/db/sql/TestSqlArtist.cpp b/amarok/tests/core-impl/collections/db/sql/TestSqlArtist.cpp deleted file mode 100644 index 4d0e4f69..00000000 --- a/amarok/tests/core-impl/collections/db/sql/TestSqlArtist.cpp +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "TestSqlArtist.h" - -#include "DefaultSqlQueryMakerFactory.h" -#include "core/meta/Meta.h" -#include "core-impl/storage/sql/mysqlestorage/MySqlEmbeddedStorage.h" -#include "SqlCollection.h" -#include "SqlMountPointManagerMock.h" - -#include - -QTEST_KDEMAIN_CORE( TestSqlArtist ) - -TestSqlArtist::TestSqlArtist() - : QObject() - , m_collection( 0 ) - , m_storage( 0 ) - , m_tmpDir( 0 ) -{ -} - -void -TestSqlArtist::initTestCase() -{ - m_tmpDir = new KTempDir(); - m_storage = new MySqlEmbeddedStorage(); - QVERIFY( m_storage->init( m_tmpDir->name() ) ); - m_collection = new Collections::SqlCollection( m_storage ); - m_collection->setMountPointManager( new SqlMountPointManagerMock( this, m_storage ) ); -} - -void -TestSqlArtist::cleanupTestCase() -{ - delete m_collection; - //m_storage is deleted by SqlCollection - delete m_tmpDir; -} - -void -TestSqlArtist::init() -{ - //setup base data - m_storage->query( "INSERT INTO artists(id, name) VALUES (1, 'The Foo');" ); - m_storage->query( "INSERT INTO artists(id, name) VALUES (2, 'No The Foo');" ); - m_storage->query( "INSERT INTO artists(id, name) VALUES (3, 'artist3');" ); - - m_storage->query( "INSERT INTO composers(id, name) VALUES (1, 'composer1');" ); - m_storage->query( "INSERT INTO genres(id, name) VALUES (1, 'genre1');" ); - m_storage->query( "INSERT INTO years(id, name) VALUES (1, '1');" ); - - m_storage->query( "INSERT INTO urls(id, deviceid, rpath, uniqueid ) VALUES (1, -1, './IDoNotExist.mp3', 'uid://1');" ); - m_storage->query( "INSERT INTO urls(id, deviceid, rpath, uniqueid ) VALUES (2, -1, './IDoNotExistAsWell.mp3', 'uid://2');" ); - m_storage->query( "INSERT INTO urls(id, deviceid, rpath, uniqueid ) VALUES (3, -1, './MeNeither.mp3', 'uid:/3');" ); -} - -void -TestSqlArtist::cleanup() -{ - m_storage->query( "TRUNCATE TABLE years;" ); - m_storage->query( "TRUNCATE TABLE genres;" ); - m_storage->query( "TRUNCATE TABLE composers;" ); - m_storage->query( "TRUNCATE TABLE albums;" ); - m_storage->query( "TRUNCATE TABLE artists;" ); - m_storage->query( "TRUNCATE TABLE tracks;" ); - m_storage->query( "TRUNCATE TABLE urls;" ); - m_storage->query( "TRUNCATE TABLE labels;" ); - m_storage->query( "TRUNCATE TABLE urls_labels;" ); -} - -void -TestSqlArtist::testSortableName() -{ - Meta::ArtistPtr artistWithThe = m_collection->registry()->getArtist( 1 ); - QCOMPARE( artistWithThe->sortableName(), QString( "Foo, The" ) ); - - Meta::ArtistPtr artistWithoutThe = m_collection->registry()->getArtist( 2 ); - QCOMPARE( artistWithoutThe->sortableName(), QString( "No The Foo" ) ); -} - - -#include "moc_TestSqlArtist.cpp" diff --git a/amarok/tests/core-impl/collections/db/sql/TestSqlArtist.h b/amarok/tests/core-impl/collections/db/sql/TestSqlArtist.h deleted file mode 100644 index 83ef7a68..00000000 --- a/amarok/tests/core-impl/collections/db/sql/TestSqlArtist.h +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef TESTSQLARTIST_H -#define TESTSQLARTIST_H - -#include -#include - -class MySqlEmbeddedStorage; - -namespace Collections { - class SqlCollection; -} - -class TestSqlArtist : public QObject -{ - Q_OBJECT -public: - TestSqlArtist(); - -private slots: - void initTestCase(); - void cleanupTestCase(); - - void init(); - void cleanup(); - - void testSortableName(); - -private: - Collections::SqlCollection *m_collection; - MySqlEmbeddedStorage *m_storage; - KTempDir *m_tmpDir; - - public: -}; - -#endif // TESTSQLARTIST_H diff --git a/amarok/tests/core-impl/collections/db/sql/TestSqlCollection.cpp b/amarok/tests/core-impl/collections/db/sql/TestSqlCollection.cpp deleted file mode 100644 index c1028b17..00000000 --- a/amarok/tests/core-impl/collections/db/sql/TestSqlCollection.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "TestSqlCollection.h" - -#include -#include -#include -#include - -#include "SqlMountPointManagerMock.h" - -#include - -#include - -QTEST_KDEMAIN_CORE( TestSqlCollection ) - -TestSqlCollection::TestSqlCollection() -{ -} - -void -TestSqlCollection::initTestCase() -{ - m_tmpDir = new KTempDir(); - m_storage = new MySqlEmbeddedStorage(); - QVERIFY( m_storage->init( m_tmpDir->name() ) ); - m_collection = new Collections::SqlCollection( m_storage ); - m_mpmMock = new SqlMountPointManagerMock( this, m_storage ); - m_collection->setMountPointManager( m_mpmMock ); - - m_storage->query( "INSERT INTO urls(id, deviceid, rpath) VALUES (1, 1, './IDoNotExist.mp3');" ); - m_storage->query( "INSERT INTO urls(id, deviceid, rpath) VALUES (2, 2, './IDoNotExistAsWell.mp3');" ); - - m_storage->query( "INSERT INTO tracks(id, url,title) VALUES ( 1,1,'test1');" ); -} - -void -TestSqlCollection::cleanupTestCase() -{ - delete m_collection; - //m_mpMock is deleted by SqlCollection - //m_storage is deleted by SqlCollection - delete m_tmpDir; - -} - -void -TestSqlCollection::testDeviceAddedWithTracks() -{ - QSignalSpy spy( m_collection, SIGNAL(updated())); - m_mpmMock->emitDeviceAdded( 1 ); - QCOMPARE( spy.count(), 1 ); -} - -void -TestSqlCollection::testDeviceAddedWithoutTracks() -{ - QSignalSpy spy( m_collection, SIGNAL(updated())); - m_mpmMock->emitDeviceAdded( 2 ); - QCOMPARE( spy.count(), 0 ); -} - -void -TestSqlCollection::testDeviceRemovedWithTracks() -{ - QSignalSpy spy( m_collection, SIGNAL(updated())); - m_mpmMock->emitDeviceRemoved( 1 ); - QCOMPARE( spy.count(), 1 ); -} - -void -TestSqlCollection::testDeviceRemovedWithoutTracks() -{ - QSignalSpy spy( m_collection, SIGNAL(updated())); - m_mpmMock->emitDeviceRemoved( 0 ); - QCOMPARE( spy.count(), 0 ); -} - -#include "moc_TestSqlCollection.cpp" diff --git a/amarok/tests/core-impl/collections/db/sql/TestSqlCollection.h b/amarok/tests/core-impl/collections/db/sql/TestSqlCollection.h deleted file mode 100644 index 3da0f9bc..00000000 --- a/amarok/tests/core-impl/collections/db/sql/TestSqlCollection.h +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef TESTSQLCOLLECTION_H -#define TESTSQLCOLLECTION_H - -#include - -#include - -class SqlMountPointManagerMock; -class MySqlEmbeddedStorage; - -namespace Collections { - class SqlCollection; -} - -class TestSqlCollection : public QObject -{ - Q_OBJECT - -public: - TestSqlCollection(); - -private slots: - void initTestCase(); - void cleanupTestCase(); - - void testDeviceAddedWithTracks(); - void testDeviceAddedWithoutTracks(); - void testDeviceRemovedWithTracks(); - void testDeviceRemovedWithoutTracks(); - -private: - Collections::SqlCollection *m_collection; - SqlMountPointManagerMock *m_mpmMock; - MySqlEmbeddedStorage *m_storage; - KTempDir *m_tmpDir; -}; - -#endif // TESTSQLCOLLECTION_H diff --git a/amarok/tests/core-impl/collections/db/sql/TestSqlCollectionLocation.cpp b/amarok/tests/core-impl/collections/db/sql/TestSqlCollectionLocation.cpp deleted file mode 100644 index 0274498e..00000000 --- a/amarok/tests/core-impl/collections/db/sql/TestSqlCollectionLocation.cpp +++ /dev/null @@ -1,281 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "TestSqlCollectionLocation.h" - -#include "DatabaseUpdater.h" -#include "core/support/Debug.h" -#include "core/support/Components.h" -#include "core-impl/logger/ProxyLogger.h" -#include "DefaultSqlQueryMakerFactory.h" -#include "core/meta/Meta.h" -#include "core-impl/storage/sql/mysqlestorage/MySqlEmbeddedStorage.h" -#include "SqlCollection.h" -#include "SqlCollectionLocation.h" -#include "SqlRegistry.h" -#include "SqlMountPointManagerMock.h" -#include "core/collections/MockCollectionLocationDelegate.h" - -#include "config-amarok-test.h" - -#include -#include -#include - -#include -#include - -#include - -#include - -using ::testing::AnyNumber; -using ::testing::Return; -using ::testing::_; - -/** A SqlCollectionLocation that claims writing is possible even though it doesn't have - * a valid directory. - */ -class MySqlCollectionLocation : public Collections::SqlCollectionLocation -{ -public: - MySqlCollectionLocation( Collections::SqlCollection *coll ) : Collections::SqlCollectionLocation( coll ) {} - virtual ~MySqlCollectionLocation() {} - - bool isWritable() const { return true; } -}; - -class MyOrganizeCollectionDelegate : public OrganizeCollectionDelegate -{ -public: - MyOrganizeCollectionDelegate() : OrganizeCollectionDelegate(), overwrite( false ), migrate( false ) {} - virtual ~ MyOrganizeCollectionDelegate() {} - - void setTracks( const Meta::TrackList &tracks ) { Q_UNUSED( tracks ) } - void setFolders( const QStringList &folders ) { Q_UNUSED( folders ) } - void setIsOrganizing( bool organizing ) { Q_UNUSED( organizing ) } - void setTranscodingConfiguration(const Transcoding::Configuration &configuration) - { Q_UNUSED( configuration ) } - void setCaption( const QString& ) {} - - void show() { emit accepted(); } - - bool overwriteDestinations() const { return overwrite; } - QMap destinations() const { return dests; } - bool migrateLabels() const { return migrate; } - - bool overwrite; - bool migrate; - QMap dests; -}; - -class MyOrganizeCollectionDelegateFactory : public OrganizeCollectionDelegateFactory -{ -public: - MyOrganizeCollectionDelegateFactory( OrganizeCollectionDelegate *d ) - : OrganizeCollectionDelegateFactory() - , delegate( d ) {} - virtual ~ MyOrganizeCollectionDelegateFactory() {} - - //warning: SqlCollectionLocation will delete the delegate - OrganizeCollectionDelegate* createDelegate() { return delegate; } - - OrganizeCollectionDelegate *delegate; -}; - - - -QTEST_KDEMAIN_CORE( TestSqlCollectionLocation ) - -TestSqlCollectionLocation::TestSqlCollectionLocation() - : QObject() - , m_collection( 0 ) - , m_storage( 0 ) - , m_tmpDir( 0 ) -{ - KCmdLineArgs::init( KGlobal::activeComponent().aboutData() ); - ::testing::InitGoogleMock( &KCmdLineArgs::qtArgc(), KCmdLineArgs::qtArgv() ); -} - -void -TestSqlCollectionLocation::initTestCase() -{ - Amarok::Components::setLogger( new ProxyLogger() ); - m_tmpDir = new KTempDir(); - m_storage = new MySqlEmbeddedStorage(); - QVERIFY( m_storage->init( m_tmpDir->name() ) ); - m_collection = new Collections::SqlCollection( m_storage ); - SqlMountPointManagerMock *mock = new SqlMountPointManagerMock( this, m_storage ); - mock->setCollectionFolders( QStringList() << m_tmpDir->name() ); // the target folder needs to have enough space and be writable - m_collection->setMountPointManager( mock ); - - // I just need the table and not the whole playlist manager - m_storage->query( QString( "CREATE TABLE playlist_tracks (" - " id " + m_storage->idType() + - ", playlist_id INTEGER " - ", track_num INTEGER " - ", url " + m_storage->exactTextColumnType() + - ", title " + m_storage->textColumnType() + - ", album " + m_storage->textColumnType() + - ", artist " + m_storage->textColumnType() + - ", length INTEGER " - ", uniqueid " + m_storage->textColumnType(128) + ") ENGINE = MyISAM;" ) ); -} - -void -TestSqlCollectionLocation::cleanupTestCase() -{ - delete m_collection; - delete Amarok::Components::setLogger( 0 ); - //m_storage is deleted by SqlCollection - delete m_tmpDir; -} - -void -TestSqlCollectionLocation::init() -{ - //setup base data - m_storage->query( "INSERT INTO artists(id, name) VALUES (1, 'artist1');" ); - m_storage->query( "INSERT INTO artists(id, name) VALUES (2, 'artist2');" ); - m_storage->query( "INSERT INTO artists(id, name) VALUES (3, 'artist3');" ); - - m_storage->query( "INSERT INTO albums(id,name,artist) VALUES(1,'album1',1);" ); - m_storage->query( "INSERT INTO albums(id,name,artist) VALUES(2,'album2',1);" ); - m_storage->query( "INSERT INTO albums(id,name,artist) VALUES(3,'album3',2);" ); - - m_storage->query( "INSERT INTO composers(id, name) VALUES (1, 'composer1');" ); - m_storage->query( "INSERT INTO genres(id, name) VALUES (1, 'genre1');" ); - m_storage->query( "INSERT INTO years(id, name) VALUES (1, '1');" ); - - m_storage->query( "INSERT INTO directories(id,deviceid,dir) VALUES (1, -1, '." + m_tmpDir->name() + "ab/')"); - m_storage->query( "INSERT INTO directories(id,deviceid,dir) VALUES (2, -1, '." + m_tmpDir->name() + "b/')"); - m_storage->query( "INSERT INTO directories(id,deviceid,dir) VALUES (3, -1, '." + m_tmpDir->name() + "c/')"); - - m_storage->query( QString( "INSERT INTO urls(id, deviceid, rpath, uniqueid, directory ) VALUES (1, -1, '%1', 'uid://1', 1);" ).arg( setupFileInTempDir( "ab/IDoNotExist.mp3" ) ) ); - m_storage->query( QString( "INSERT INTO urls(id, deviceid, rpath, uniqueid, directory ) VALUES (2, -1, '%1', 'uid://2', 2);" ).arg( setupFileInTempDir( "b/IDoNotExistAsWell.mp3") ) ); - m_storage->query( QString( "INSERT INTO urls(id, deviceid, rpath, uniqueid, directory ) VALUES (3, -1, '%1', 'uid:/3', 3);" ).arg( setupFileInTempDir( "c/MeNeither.mp3" ) ) ); - - m_storage->query( "INSERT INTO tracks(id,url,title,comment,artist,album,genre,year,composer) " - "VALUES(1,1,'track1','comment1',1,1,1,1,1);" ); - m_storage->query( "INSERT INTO tracks(id,url,title,comment,artist,album,genre,year,composer) " - "VALUES(2,2,'track2','comment2',1,2,1,1,1);" ); - m_storage->query( "INSERT INTO tracks(id,url,title,comment,artist,album,genre,year,composer) " - "VALUES(3,3,'track3','comment3',2,3,1,1,1);" ); - - m_collection->registry()->emptyCache(); -} - -void -TestSqlCollectionLocation::cleanup() -{ - delete Amarok::Components::setCollectionLocationDelegate( 0 ); - m_storage->query( "TRUNCATE TABLE years;" ); - m_storage->query( "TRUNCATE TABLE genres;" ); - m_storage->query( "TRUNCATE TABLE composers;" ); - m_storage->query( "TRUNCATE TABLE albums;" ); - m_storage->query( "TRUNCATE TABLE artists;" ); - m_storage->query( "TRUNCATE TABLE tracks;" ); - m_storage->query( "TRUNCATE TABLE urls;" ); - m_storage->query( "TRUNCATE TABLE labels;" ); - m_storage->query( "TRUNCATE TABLE urls_labels;" ); - m_storage->query( "TRUNCATE TABLE directories;" ); -} - -void -TestSqlCollectionLocation::testOrganizingCopiesLabels() -{ - { - Collections::MockCollectionLocationDelegate *d = new Collections::MockCollectionLocationDelegate(); - EXPECT_CALL( *d, reallyMove( _, _ ) ).Times( AnyNumber() ).WillRepeatedly( Return( true ) ); - EXPECT_CALL( *d, transcode( _, _, _, _, _ ) ).WillOnce( Return( - Transcoding::Configuration( Transcoding::INVALID ) ) ); - Amarok::Components::setCollectionLocationDelegate( d ); - } - - { - Meta::TrackPtr track = m_collection->registry()->getTrackFromUid( "uid://1" ); - QVERIFY( track ); - QVERIFY( track->playableUrl().path().endsWith( "ab/IDoNotExist.mp3" ) ); - - track->addLabel( "test" ); - - QCOMPARE( track->labels().count(), 1 ); - - Collections::SqlCollectionLocation *source = new MySqlCollectionLocation( m_collection ); - Collections::SqlCollectionLocation *dest = new MySqlCollectionLocation( m_collection ); - - { - MyOrganizeCollectionDelegate *delegate = new MyOrganizeCollectionDelegate(); - delegate->overwrite = true; - delegate->migrate = true; - delegate->dests.insert( track, m_tmpDir->name() + "b/IDoNotExist.mp3" ); - dest->setOrganizeCollectionDelegateFactory( new MyOrganizeCollectionDelegateFactory( delegate ) ); - } - - source->prepareMove( track, dest ); - - QTest::kWaitForSignal( source, SIGNAL(destroyed(QObject*)), 1000 ); - - QCOMPARE( track->labels().count(), 1 ); - QVERIFY( track->playableUrl().path().endsWith( "b/IDoNotExist.mp3" ) ); - } - - //force a reload from the database - m_collection->registry()->emptyCache(); - - { - // Meta::TrackPtr track = m_collection->registry()->getTrack( m_tmpDir->name() + "b/IDoNotExist.mp3" ); - Meta::TrackPtr track = m_collection->registry()->getTrack(1); - QVERIFY( track ); - QVERIFY( track->playableUrl().path().endsWith( "b/IDoNotExist.mp3" ) ); - // TODO: check that the db urls entry really specifies the exiting directories entry - QCOMPARE( track->labels().count(), 1 ); - } -} - -void -TestSqlCollectionLocation::testCopiesLabelFromExternalTracks() -{ - -} - -void -TestSqlCollectionLocation::testCopyTrackToDirectoryWithExistingTracks() -{ - -} - -QString -TestSqlCollectionLocation::setupFileInTempDir( const QString &relativeName ) -{ - QString absoluteName = m_tmpDir->name() + relativeName; - - //TODO: unix specific - //create directory where necessary - int index = absoluteName.lastIndexOf( QDir::separator() ); - if(index > 0 ) - { - QString dir = absoluteName.left( index ); - QProcess::execute( "mkdir", QStringList() << "-p" << dir ); - } - else - { - qDebug() << "huh? index was " << index << " relative name was " << relativeName << " tmpDir " << m_tmpDir->name(); - } - - QProcess::execute( "touch", QStringList() << absoluteName ); - return '.' + absoluteName; -} diff --git a/amarok/tests/core-impl/collections/db/sql/TestSqlCollectionLocation.h b/amarok/tests/core-impl/collections/db/sql/TestSqlCollectionLocation.h deleted file mode 100644 index 10f30745..00000000 --- a/amarok/tests/core-impl/collections/db/sql/TestSqlCollectionLocation.h +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef TESTSQLCOLLECTIONLOCATION_H -#define TESTSQLCOLLECTIONLOCATION_H - -#include - -#include - -class MySqlEmbeddedStorage; -namespace Collections -{ - class SqlCollection; -} -class SqlRegistry; - -class TestSqlCollectionLocation : public QObject -{ - Q_OBJECT -public: - TestSqlCollectionLocation(); - -private slots: - void initTestCase(); - void cleanupTestCase(); - - void init(); - void cleanup(); - - void testOrganizingCopiesLabels(); - void testCopiesLabelFromExternalTracks(); - void testCopyTrackToDirectoryWithExistingTracks(); - -private: - QString setupFileInTempDir( const QString &relativeName ); - -private: - Collections::SqlCollection *m_collection; - MySqlEmbeddedStorage *m_storage; - KTempDir *m_tmpDir; -}; - -#endif // TESTSQLCOLLECTIONLOCATION_H diff --git a/amarok/tests/core-impl/collections/db/sql/TestSqlQueryMaker.cpp b/amarok/tests/core-impl/collections/db/sql/TestSqlQueryMaker.cpp deleted file mode 100644 index 4cf53d06..00000000 --- a/amarok/tests/core-impl/collections/db/sql/TestSqlQueryMaker.cpp +++ /dev/null @@ -1,1027 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "TestSqlQueryMaker.h" - -#include "core/support/Debug.h" - -#include "DatabaseUpdater.h" -#include "SqlCollection.h" -#include "SqlQueryMaker.h" -#include "SqlRegistry.h" -#include "core-impl/storage/sql/mysqlestorage/MySqlEmbeddedStorage.h" - -#include "SqlMountPointManagerMock.h" - -#include - -#include - -using namespace Collections; - -QTEST_KDEMAIN_CORE( TestSqlQueryMaker ) - -//required for QTest, this is not done in Querymaker.h -Q_DECLARE_METATYPE( Collections::QueryMaker::QueryType ) -Q_DECLARE_METATYPE( Collections::QueryMaker::NumberComparison ) -Q_DECLARE_METATYPE( Collections::QueryMaker::ReturnFunction ) -Q_DECLARE_METATYPE( Collections::QueryMaker::AlbumQueryMode ) -Q_DECLARE_METATYPE( Collections::QueryMaker::LabelQueryMode ) - -TestSqlQueryMaker::TestSqlQueryMaker() -{ - qRegisterMetaType(); - qRegisterMetaType(); - qRegisterMetaType(); - qRegisterMetaType(); - qRegisterMetaType(); - qRegisterMetaType(); - qRegisterMetaType(); - qRegisterMetaType(); - qRegisterMetaType(); - qRegisterMetaType(); - qRegisterMetaType(); - qRegisterMetaType(); - qRegisterMetaType(); - qRegisterMetaType(); - qRegisterMetaType(); - qRegisterMetaType(); - qRegisterMetaType(); - qRegisterMetaType(); - qRegisterMetaType(); -} - -void -TestSqlQueryMaker::initTestCase() -{ - m_tmpDir = new KTempDir(); - m_storage = new MySqlEmbeddedStorage(); - QVERIFY( m_storage->init( m_tmpDir->name() ) ); - m_collection = new Collections::SqlCollection( m_storage ); - - QMap mountPoints; - mountPoints.insert( 1, "/foo" ); - mountPoints.insert( 2, "/bar" ); - - m_mpm = new SqlMountPointManagerMock( this, m_storage ); - m_mpm->m_mountPoints = mountPoints; - - m_collection->setMountPointManager( m_mpm ); - - //setup test data - m_storage->query( "INSERT INTO artists(id, name) VALUES (1, 'artist1');" ); - m_storage->query( "INSERT INTO artists(id, name) VALUES (2, 'artist2');" ); - m_storage->query( "INSERT INTO artists(id, name) VALUES (3, 'artist3');" ); - - m_storage->query( "INSERT INTO albums(id,name,artist) VALUES(1,'album1',1);" ); - m_storage->query( "INSERT INTO albums(id,name,artist) VALUES(2,'album2',1);" ); - m_storage->query( "INSERT INTO albums(id,name,artist) VALUES(3,'album3',2);" ); - m_storage->query( "INSERT INTO albums(id,name,artist) VALUES(4,'album4',NULL);" ); - m_storage->query( "INSERT INTO albums(id,name,artist) VALUES(5,'album4',3);" ); - - m_storage->query( "INSERT INTO composers(id, name) VALUES (1, 'composer1');" ); - m_storage->query( "INSERT INTO composers(id, name) VALUES (2, 'composer2');" ); - m_storage->query( "INSERT INTO composers(id, name) VALUES (3, 'composer3');" ); - - m_storage->query( "INSERT INTO genres(id, name) VALUES (1, 'genre1');" ); - m_storage->query( "INSERT INTO genres(id, name) VALUES (2, 'genre2');" ); - m_storage->query( "INSERT INTO genres(id, name) VALUES (3, 'genre3');" ); - - m_storage->query( "INSERT INTO years(id, name) VALUES (1, '1');" ); - m_storage->query( "INSERT INTO years(id, name) VALUES (2, '2');" ); - m_storage->query( "INSERT INTO years(id, name) VALUES (3, '3');" ); - - m_storage->query( "INSERT INTO directories(id, deviceid, dir) VALUES (1, -1, './');" ); - - m_storage->query( "INSERT INTO urls(id, deviceid, rpath, directory, uniqueid) VALUES (1, -1, './IDoNotExist.mp3', 1, '1');" ); - m_storage->query( "INSERT INTO urls(id, deviceid, rpath, directory, uniqueid) VALUES (2, -1, './IDoNotExistAsWell.mp3', 1, '2');" ); - m_storage->query( "INSERT INTO urls(id, deviceid, rpath, directory, uniqueid) VALUES (3, -1, './MeNeither.mp3', 1, '3');" ); - m_storage->query( "INSERT INTO urls(id, deviceid, rpath, directory, uniqueid) VALUES (4, 2, './NothingHere.mp3', 1, '4');" ); - m_storage->query( "INSERT INTO urls(id, deviceid, rpath, directory, uniqueid) VALUES (5, 1, './GuessWhat.mp3', 1, '5');" ); - m_storage->query( "INSERT INTO urls(id, deviceid, rpath, directory, uniqueid) VALUES (6, 2, './LookItsA.flac', 1, '6');" ); - - m_storage->query( "INSERT INTO tracks(id,url,title,comment,artist,album,genre,year,composer) " - "VALUES(1,1,'track1','comment1',1,1,1,1,1);" ); - m_storage->query( "INSERT INTO tracks(id,url,title,comment,artist,album,genre,year,composer) " - "VALUES(2,2,'track2','comment2',1,2,1,1,1);" ); - m_storage->query( "INSERT INTO tracks(id,url,title,comment,artist,album,genre,year,composer) " - "VALUES(3,3,'track3','comment3',3,4,1,1,1);" ); - m_storage->query( "INSERT INTO tracks(id,url,title,comment,artist,album,genre,year,composer) " - "VALUES(4,4,'track4','comment4',2,3,3,3,3);" ); - m_storage->query( "INSERT INTO tracks(id,url,title,comment,artist,album,genre,year,composer) " - "VALUES(5,5,'track5','',3,5,2,2,2);" ); - m_storage->query( "INSERT INTO tracks(id,url,title,comment,artist,album,genre,year,composer) " - "VALUES(6,6,'track6','',1,4,2,2,2);" ); - - m_storage->query( "INSERT INTO statistics(url,createdate,accessdate,score,rating,playcount) " - "VALUES(1,1000,10000, 50.0,2,100);" ); - m_storage->query( "INSERT INTO statistics(url,createdate,accessdate,score,rating,playcount) " - "VALUES(2,2000,30000, 70.0,9,50);" ); - m_storage->query( "INSERT INTO statistics(url,createdate,accessdate,score,rating,playcount) " - "VALUES(3,4000,20000, 60.0,4,10);" ); - - m_storage->query( "INSERT INTO labels(id,label) VALUES (1,'labelA'), (2,'labelB'),(3,'test');" ); - m_storage->query( "INSERT INTO urls_labels(url,label) VALUES (1,1),(1,2),(2,2),(3,3),(4,3),(4,2);" ); - -} - -void -TestSqlQueryMaker::cleanupTestCase() -{ - delete m_collection; - //m_storage is deleted by SqlCollection - delete m_tmpDir; - -} - -void -TestSqlQueryMaker::cleanup() -{ - m_collection->setMountPointManager( m_mpm ); -} - -void -TestSqlQueryMaker::testQueryAlbums() -{ - Collections::SqlQueryMaker qm( m_collection ); - qm.setBlocking( true ); - qm.setAlbumQueryMode( Collections::QueryMaker::AllAlbums ); - qm.setQueryType( Collections::QueryMaker::Album ); - qm.run(); - QCOMPARE( qm.albums().count(), 5 ); -} - -void -TestSqlQueryMaker::testQueryArtists() -{ - Collections::SqlQueryMaker qm( m_collection ); - qm.setBlocking( true ); - qm.setQueryType( Collections::QueryMaker::Artist ); - qm.run(); - QCOMPARE( qm.artists().count(), 3 ); -} - -void -TestSqlQueryMaker::testQueryComposers() -{ - Collections::SqlQueryMaker qm( m_collection ); - qm.setBlocking( true ); - qm.setQueryType( Collections::QueryMaker::Composer ); - qm.run(); - QCOMPARE( qm.composers().count(), 3 ); -} - -void -TestSqlQueryMaker::testQueryGenres() -{ - Collections::SqlQueryMaker qm( m_collection ); - qm.setBlocking( true ); - qm.setQueryType( Collections::QueryMaker::Genre ); - qm.run(); - QCOMPARE( qm.genres().count(), 3 ); -} - -void -TestSqlQueryMaker::testQueryYears() -{ - Collections::SqlQueryMaker qm( m_collection ); - qm.setBlocking( true ); - qm.setQueryType( Collections::QueryMaker::Year ); - qm.run(); - QCOMPARE( qm.years().count(), 3 ); -} - -void -TestSqlQueryMaker::testQueryTracks() -{ - Collections::SqlQueryMaker qm( m_collection ); - qm.setBlocking( true ); - qm.setQueryType( Collections::QueryMaker::Track ); - qm.run(); - QCOMPARE( qm.tracks().count(), 6 ); -} - -void -TestSqlQueryMaker::testAlbumQueryMode() -{ - { - Collections::SqlQueryMaker qm( m_collection ); - qm.setBlocking( true ); - qm.setAlbumQueryMode( Collections::QueryMaker::OnlyCompilations ); - qm.setQueryType( Collections::QueryMaker::Album ); - qm.run(); - QCOMPARE( qm.albums().count(), 1 ); - } - - { - Collections::SqlQueryMaker qm( m_collection ); - qm.setBlocking( true ); - qm.setAlbumQueryMode( Collections::QueryMaker::OnlyNormalAlbums ); - qm.setQueryType( Collections::QueryMaker::Album ); - qm.run(); - QCOMPARE( qm.albums().count(), 4 ); - } - - { - Collections::SqlQueryMaker qm( m_collection ); - qm.setBlocking( true ); - qm.setQueryType( Collections::QueryMaker::Track ); - qm.setAlbumQueryMode( Collections::QueryMaker::OnlyCompilations ); - qm.run(); - QCOMPARE( qm.tracks().count(), 2 ); - } - - { - Collections::SqlQueryMaker qm( m_collection ); - qm.setBlocking( true ); - qm.setQueryType( Collections::QueryMaker::Track ); - qm.setAlbumQueryMode( Collections::QueryMaker::OnlyNormalAlbums ); - qm.run(); - QCOMPARE( qm.tracks().count(), 4 ); - } - - { - Collections::SqlQueryMaker qm( m_collection ); - qm.setBlocking( true ); - qm.setQueryType( Collections::QueryMaker::Artist ); - qm.setAlbumQueryMode( Collections::QueryMaker::OnlyCompilations ); - qm.run(); - QCOMPARE( qm.artists().count() , 2 ); - } - - { - Collections::SqlQueryMaker qm( m_collection ); - qm.setBlocking( true ); - qm.setQueryType( Collections::QueryMaker::Artist ); - qm.setAlbumQueryMode( Collections::QueryMaker::OnlyNormalAlbums ); - qm.run(); - QCOMPARE( qm.artists().count(), 3 ); - } - - { - Collections::SqlQueryMaker qm( m_collection ); - qm.setBlocking( true ); - qm.setAlbumQueryMode( Collections::QueryMaker::OnlyCompilations ); - qm.setQueryType( Collections::QueryMaker::Genre ); - qm.run(); - QCOMPARE( qm.genres().count(), 2 ); - } - - { - Collections::SqlQueryMaker qm( m_collection ); - qm.setBlocking( true ); - qm.setAlbumQueryMode( Collections::QueryMaker::OnlyNormalAlbums ); - qm.setQueryType( Collections::QueryMaker::Genre ); - qm.run(); - QCOMPARE( qm.genres().count(), 3 ); - } - -} - -void -TestSqlQueryMaker::testDeleteQueryMakerWithRunningQuery() -{ - int iteration = 0; - bool queryNotDoneYet = true; - - //wait one second per query in total, that should be enough for it to complete - do - { - Collections::SqlQueryMaker *qm = new Collections::SqlQueryMaker( m_collection ); - QSignalSpy spy( qm, SIGNAL(queryDone()) ); - qm->setQueryType( Collections::QueryMaker::Track ); - qm->addFilter( Meta::valTitle, QString::number( iteration), false, false ); - qm->run(); - //wait 10 msec more per iteration, might have to be tweaked - if( iteration > 0 ) - { - QTest::qWait( 10 * iteration ); - } - delete qm; - queryNotDoneYet = ( spy.count() == 0 ); - if( iteration > 50 ) - { - break; - } - iteration++; - } while ( queryNotDoneYet ); - qDebug() << "Iterations: " << iteration; -} - -void -TestSqlQueryMaker::testAsyncAlbumQuery() -{ - Collections::QueryMaker *qm = new Collections::SqlQueryMaker( m_collection ); - qm->setQueryType( Collections::QueryMaker::Album ); - QSignalSpy doneSpy1( qm, SIGNAL(queryDone())); - QSignalSpy resultSpy1( qm, SIGNAL(newResultReady(Meta::AlbumList))); - - qm->run(); - - QTest::kWaitForSignal( qm, SIGNAL(queryDone()), 1000 ); - - QCOMPARE( resultSpy1.count(), 1 ); - QList args1 = resultSpy1.takeFirst(); - QVERIFY( args1.value(0).canConvert() ); - QCOMPARE( args1.value(0).value().count(), 5 ); - QCOMPARE( doneSpy1.count(), 1); - delete qm; - - qm = new Collections::SqlQueryMaker( m_collection ); - qm->setQueryType( Collections::QueryMaker::Album ); - QSignalSpy doneSpy2( qm, SIGNAL(queryDone())); - QSignalSpy resultSpy2( qm, SIGNAL(newResultReady(Meta::AlbumList))); - qm->addFilter( Meta::valAlbum, "foo" ); //should result in no match - - qm->run(); - - QTest::kWaitForSignal( qm, SIGNAL(queryDone()), 1000 ); - - QCOMPARE( resultSpy2.count(), 1 ); - QList args2 = resultSpy2.takeFirst(); - QVERIFY( args2.value(0).canConvert() ); - QCOMPARE( args2.value(0).value().count(), 0 ); - QCOMPARE( doneSpy2.count(), 1); -} - -void -TestSqlQueryMaker::testAsyncArtistQuery() -{ - Collections::QueryMaker *qm = new Collections::SqlQueryMaker( m_collection ); - qm->setQueryType( Collections::QueryMaker::Artist ); - QSignalSpy doneSpy1( qm, SIGNAL(queryDone())); - QSignalSpy resultSpy1( qm, SIGNAL(newResultReady(Meta::ArtistList))); - - qm->run(); - - QTest::kWaitForSignal( qm, SIGNAL(queryDone()), 1000 ); - - QCOMPARE( resultSpy1.count(), 1 ); - QList args1 = resultSpy1.takeFirst(); - QVERIFY( args1.value(0).canConvert() ); - QCOMPARE( args1.value(0).value().count(), 3 ); - QCOMPARE( doneSpy1.count(), 1); - delete qm; - - qm = new Collections::SqlQueryMaker( m_collection ); - qm->setQueryType( Collections::QueryMaker::Artist ); - QSignalSpy doneSpy2( qm, SIGNAL(queryDone())); - QSignalSpy resultSpy2( qm, SIGNAL(newResultReady(Meta::ArtistList))); - qm->addFilter( Meta::valArtist, "foo" ); //should result in no match - - qm->run(); - - QTest::kWaitForSignal( qm, SIGNAL(queryDone()), 1000 ); - - QCOMPARE( resultSpy2.count(), 1 ); - QList args2 = resultSpy2.takeFirst(); - QVERIFY( args2.value(0).canConvert() ); - QCOMPARE( args2.value(0).value().count(), 0 ); - QCOMPARE( doneSpy2.count(), 1); -} - -void -TestSqlQueryMaker::testAsyncComposerQuery() -{ - Collections::QueryMaker *qm = new Collections::SqlQueryMaker( m_collection ); - qm->setQueryType( Collections::QueryMaker::Composer ); - QSignalSpy doneSpy1( qm, SIGNAL(queryDone())); - QSignalSpy resultSpy1( qm, SIGNAL(newResultReady(Meta::ComposerList))); - - qm->run(); - - QTest::kWaitForSignal( qm, SIGNAL(queryDone()), 1000 ); - - QCOMPARE( resultSpy1.count(), 1 ); - QList args1 = resultSpy1.takeFirst(); - QVERIFY( args1.value(0).canConvert() ); - QCOMPARE( args1.value(0).value().count(), 3 ); - QCOMPARE( doneSpy1.count(), 1); - - delete qm; - - qm = new Collections::SqlQueryMaker( m_collection ); - qm->setQueryType( Collections::QueryMaker::Composer ); - QSignalSpy doneSpy2( qm, SIGNAL(queryDone())); - QSignalSpy resultSpy2( qm, SIGNAL(newResultReady(Meta::ComposerList))); - qm->addFilter( Meta::valComposer, "foo" ); //should result in no match - - qm->run(); - - QTest::kWaitForSignal( qm, SIGNAL(queryDone()), 1000 ); - - QCOMPARE( resultSpy2.count(), 1 ); - QList args2 = resultSpy2.takeFirst(); - QVERIFY( args2.value(0).canConvert() ); - QCOMPARE( args2.value(0).value().count(), 0 ); - QCOMPARE( doneSpy2.count(), 1); -} - -void -TestSqlQueryMaker::testAsyncTrackQuery() -{ - Collections::QueryMaker *qm = new Collections::SqlQueryMaker( m_collection ); - qm->setQueryType( Collections::QueryMaker::Track ); - QSignalSpy doneSpy1( qm, SIGNAL(queryDone())); - QSignalSpy resultSpy1( qm, SIGNAL(newResultReady(Meta::TrackList))); - - qm->run(); - - QTest::kWaitForSignal( qm, SIGNAL(queryDone()), 1000 ); - - QCOMPARE( resultSpy1.count(), 1 ); - QList args1 = resultSpy1.takeFirst(); - QVERIFY( args1.value(0).canConvert() ); - QCOMPARE( args1.value(0).value().count(), 6 ); - QCOMPARE( doneSpy1.count(), 1); - - delete qm; - - qm = new Collections::SqlQueryMaker( m_collection ); - qm->setQueryType( Collections::QueryMaker::Track ); - QSignalSpy doneSpy2( qm, SIGNAL(queryDone())); - QSignalSpy resultSpy2( qm, SIGNAL(newResultReady(Meta::TrackList))); - qm->addFilter( Meta::valTitle, "foo" ); //should result in no match - - qm->run(); - - QTest::kWaitForSignal( qm, SIGNAL(queryDone()), 1000 ); - - QCOMPARE( resultSpy2.count(), 1 ); - QList args2 = resultSpy2.takeFirst(); - QVERIFY( args2.value(0).canConvert() ); - QCOMPARE( args2.value(0).value().count(), 0 ); - QCOMPARE( doneSpy2.count(), 1); -} - -void -TestSqlQueryMaker::testAsyncGenreQuery() -{ - Collections::QueryMaker *qm = new Collections::SqlQueryMaker( m_collection ); - qm->setQueryType( Collections::QueryMaker::Genre ); - QSignalSpy doneSpy1( qm, SIGNAL(queryDone())); - QSignalSpy resultSpy1( qm, SIGNAL(newResultReady(Meta::GenreList))); - - qm->run(); - - QTest::kWaitForSignal( qm, SIGNAL(queryDone()), 1000 ); - - QCOMPARE( resultSpy1.count(), 1 ); - QList args1 = resultSpy1.takeFirst(); - QVERIFY( args1.value(0).canConvert() ); - QCOMPARE( args1.value(0).value().count(), 3 ); - QCOMPARE( doneSpy1.count(), 1); - - delete qm; - - qm = new Collections::SqlQueryMaker( m_collection ); - qm->setQueryType( Collections::QueryMaker::Genre ); - QSignalSpy doneSpy2( qm, SIGNAL(queryDone())); - QSignalSpy resultSpy2( qm, SIGNAL(newResultReady(Meta::GenreList))); - qm->addFilter( Meta::valGenre, "foo" ); //should result in no match - - qm->run(); - - QTest::kWaitForSignal( qm, SIGNAL(queryDone()), 1000 ); - - QCOMPARE( resultSpy2.count(), 1 ); - QList args2 = resultSpy2.takeFirst(); - QVERIFY( args2.value(0).canConvert() ); - QCOMPARE( args2.value(0).value().count(), 0 ); - QCOMPARE( doneSpy2.count(), 1); -} - -void -TestSqlQueryMaker::testAsyncYearQuery() -{ - Collections::QueryMaker *qm = new Collections::SqlQueryMaker( m_collection ); - qm->setQueryType( Collections::QueryMaker::Year ); - QSignalSpy doneSpy1( qm, SIGNAL(queryDone())); - QSignalSpy resultSpy1( qm, SIGNAL(newResultReady(Meta::YearList))); - - qm->run(); - - QTest::kWaitForSignal( qm, SIGNAL(queryDone()), 1000 ); - - QCOMPARE( resultSpy1.count(), 1 ); - QList args1 = resultSpy1.takeFirst(); - QVERIFY( args1.value(0).canConvert() ); - QCOMPARE( args1.value(0).value().count(), 3 ); - QCOMPARE( doneSpy1.count(), 1); - - delete qm; - - qm = new Collections::SqlQueryMaker( m_collection ); - qm->setQueryType( Collections::QueryMaker::Year ); - QSignalSpy doneSpy2( qm, SIGNAL(queryDone())); - QSignalSpy resultSpy2( qm, SIGNAL(newResultReady(Meta::YearList))); - qm->addFilter( Meta::valYear, "foo" ); //should result in no match - - qm->run(); - - QTest::kWaitForSignal( qm, SIGNAL(queryDone()), 1000 ); - - QCOMPARE( resultSpy2.count(), 1 ); - QList args2 = resultSpy2.takeFirst(); - QVERIFY( args2.value(0).canConvert() ); - QCOMPARE( args2.value(0).value().count(), 0 ); - QCOMPARE( doneSpy2.count(), 1); -} - -void -TestSqlQueryMaker::testAsyncCustomQuery() -{ - Collections::QueryMaker *qm = new Collections::SqlQueryMaker( m_collection ); - qm->setQueryType( Collections::QueryMaker::Custom ); - qm->addReturnFunction( Collections::QueryMaker::Count, Meta::valTitle ); - QSignalSpy doneSpy1( qm, SIGNAL(queryDone())); - QSignalSpy resultSpy1( qm, SIGNAL(newResultReady(QStringList))); - - qm->run(); - - QTest::kWaitForSignal( qm, SIGNAL(queryDone()), 1000 ); - - QCOMPARE( resultSpy1.count(), 1 ); - QList args1 = resultSpy1.takeFirst(); - QVERIFY( args1.value(0).canConvert() ); - QCOMPARE( args1.value(0).value().count(), 1 ); - QCOMPARE( args1.value(0).value().first(), QString( "6" ) ); - QCOMPARE( doneSpy1.count(), 1); - - delete qm; - - qm = new Collections::SqlQueryMaker( m_collection ); - qm->setQueryType( Collections::QueryMaker::Custom ); - qm->addReturnFunction( Collections::QueryMaker::Count, Meta::valTitle ); - QSignalSpy doneSpy2( qm, SIGNAL(queryDone())); - QSignalSpy resultSpy2( qm, SIGNAL(newResultReady(QStringList))); - qm->addFilter( Meta::valTitle, "foo" ); //should result in no match - - qm->run(); - - QTest::kWaitForSignal( qm, SIGNAL(queryDone()), 1000 ); - - QCOMPARE( resultSpy2.count(), 1 ); - QList args2 = resultSpy2.takeFirst(); - QVERIFY( args2.value(0).canConvert() ); - QCOMPARE( args2.value(0).value().count(), 1 ); - QCOMPARE( args2.value(0).value().first(), QString( "0" ) ); - QCOMPARE( doneSpy2.count(), 1); -} - -void -TestSqlQueryMaker::testFilter_data() -{ - QTest::addColumn( "type" ); - QTest::addColumn( "value" ); - QTest::addColumn( "filter" ); - QTest::addColumn( "matchBeginning" ); - QTest::addColumn( "matchEnd" ); - QTest::addColumn( "count" ); - - QTest::newRow( "track match all titles" ) << Collections::QueryMaker::Track << Meta::valTitle << "track" << false << false << 6; - QTest::newRow( "track match all title beginnings" ) << Collections::QueryMaker::Track << Meta::valTitle << "track" << true << false << 6; - QTest::newRow( "track match one title beginning" ) << Collections::QueryMaker::Track << Meta::valTitle << "track1" << true << false << 1; - QTest::newRow( "track match one title end" ) << Collections::QueryMaker::Track << Meta::valTitle << "rack2" << false << true << 1; - QTest::newRow( "track match title on both ends" ) << Collections::QueryMaker::Track << Meta::valTitle << "track3" << true << true << 1; - QTest::newRow( "track match artist" ) << Collections::QueryMaker::Track << Meta::valArtist << "artist1" << false << false << 3; - QTest::newRow( "artist match artist" ) << Collections::QueryMaker::Artist << Meta::valArtist << "artist1" << true << true << 1; - QTest::newRow( "album match artist" ) << Collections::QueryMaker::Album << Meta::valArtist << "artist3" << false << false << 2; - QTest::newRow( "track match genre" ) << Collections::QueryMaker::Track << Meta::valGenre << "genre1" << false << false << 3; - QTest::newRow( "genre match genre" ) << Collections::QueryMaker::Genre << Meta::valGenre << "genre1" << false << false << 1; - QTest::newRow( "track match composer" ) << Collections::QueryMaker::Track << Meta::valComposer << "composer2" << false << false << 2; - QTest::newRow( "composer match composer" ) << Collections::QueryMaker::Composer << Meta::valComposer << "composer2" << false << false << 1; - QTest::newRow( "track match year" ) << Collections::QueryMaker::Track << Meta::valYear << "2" << true << true << 2; - QTest::newRow( "year match year" ) << Collections::QueryMaker::Year << Meta::valYear << "1" << false << false << 1; - QTest::newRow( "album match album" ) << Collections::QueryMaker::Album << Meta::valAlbum << "album1" << false << false << 1; - QTest::newRow( "track match album" ) << Collections::QueryMaker::Track << Meta::valAlbum << "album1" << false << false << 1; - QTest::newRow( "track match albumartit" ) << Collections::QueryMaker::Track << Meta::valAlbumArtist << "artist1" << false << false << 2; - QTest::newRow( "album match albumartist" ) << Collections::QueryMaker::Album << Meta::valAlbumArtist << "artist2" << false << false << 1; - QTest::newRow( "album match all albumartists" ) << Collections::QueryMaker::Album << Meta::valAlbumArtist << "artist" << true << false << 4; - QTest::newRow( "genre match albumartist" ) << Collections::QueryMaker::Genre << Meta::valAlbumArtist << "artist1" << false << false << 1; - QTest::newRow( "year match albumartist" ) << Collections::QueryMaker::Year << Meta::valAlbumArtist << "artist1" << false << false << 1; - QTest::newRow( "composer match albumartist" ) << Collections::QueryMaker::Composer << Meta::valAlbumArtist << "artist1" << false << false << 1; - QTest::newRow( "genre match title" ) << Collections::QueryMaker::Genre << Meta::valTitle << "track1" << false << false << 1; - QTest::newRow( "composer match title" ) << Collections::QueryMaker::Composer << Meta::valTitle << "track1" << false << false << 1; - QTest::newRow( "year match title" ) << Collections::QueryMaker::Year << Meta::valTitle << "track1" << false << false << 1; - QTest::newRow( "album match title" ) << Collections::QueryMaker::Album << Meta::valTitle << "track1" << false << false << 1; - QTest::newRow( "artist match title" ) << Collections::QueryMaker::Artist << Meta::valTitle << "track1" << false << false << 1; - QTest::newRow( "track match comment" ) << Collections::QueryMaker::Track << Meta::valComment << "comment" << true << false << 4; - QTest::newRow( "track match url" ) << Collections::QueryMaker::Track << Meta::valUrl << "Exist" << false << false << 2; - QTest::newRow( "album match comment" ) << Collections::QueryMaker::Track << Meta::valComment << "comment1" << true << true << 1; -} - -void -TestSqlQueryMaker::checkResultCount( Collections::SqlQueryMaker* qm, - Collections::QueryMaker::QueryType type, int count ) { - switch( type ) { - case QueryMaker::Track: QCOMPARE( qm->tracks().count(), count ); break; - case QueryMaker::Artist: QCOMPARE( qm->artists().count(), count ); break; - case QueryMaker::Album: QCOMPARE( qm->albums().count(), count ); break; - case QueryMaker::Genre: QCOMPARE( qm->genres().count(), count ); break; - case QueryMaker::Composer: QCOMPARE( qm->composers().count(), count ); break; - case QueryMaker::Year: QCOMPARE( qm->years().count(), count ); break; - case QueryMaker::Label: QCOMPARE( qm->labels().count(), count ); break; - default: - ; // do nothing - } -} - -void -TestSqlQueryMaker::testFilter() -{ - QFETCH( Collections::QueryMaker::QueryType, type ); - QFETCH( qint64, value ); - QFETCH( QString, filter ); - QFETCH( bool, matchBeginning ); - QFETCH( bool, matchEnd ); - QFETCH( int, count ); - - Collections::SqlQueryMaker qm( m_collection ); - qm.setBlocking( true ); - qm.setQueryType( type ); - - qm.addFilter( value, filter, matchBeginning, matchEnd ); - - qm.run(); - - checkResultCount( &qm, type, count ); -} - -void -TestSqlQueryMaker::testDynamicCollection() -{ - //this will not crash as we reset the correct mock in cleanup() - SqlMountPointManagerMock mpm( this, m_storage ); - - QMap mountPoints; - - mpm.m_mountPoints = mountPoints; - - m_collection->setMountPointManager( &mpm ); - - Collections::SqlQueryMaker trackQm( m_collection ); - trackQm.setQueryType( Collections::QueryMaker::Track ); - trackQm.setBlocking( true ); - trackQm.run(); - QCOMPARE( trackQm.tracks().count(), 3 ); - - mpm.m_mountPoints.insert( 1, "/foo" ); - - Collections::SqlQueryMaker trackQm2( m_collection ); - trackQm2.setQueryType( Collections::QueryMaker::Track ); - trackQm2.setBlocking( true ); - trackQm2.run(); - QCOMPARE( trackQm2.tracks().count(), 4 ); - - Collections::SqlQueryMaker artistQm( m_collection ); - artistQm.setQueryType( Collections::QueryMaker::Artist ); - artistQm.setBlocking( true ); - artistQm.run(); - QCOMPARE( artistQm.artists().count(), 2 ); - - Collections::SqlQueryMaker albumQm( m_collection ); - albumQm.setQueryType( Collections::QueryMaker::Album ); - albumQm.setBlocking( true ); - albumQm.run(); - QCOMPARE( albumQm.albums().count(), 4 ); - - Collections::SqlQueryMaker genreQm( m_collection ); - genreQm.setQueryType( Collections::QueryMaker::Genre ); - genreQm.setBlocking( true ); - genreQm.run(); - QCOMPARE( genreQm.genres().count(), 2 ); - - Collections::SqlQueryMaker composerQm( m_collection ); - composerQm.setQueryType( Collections::QueryMaker::Composer ); - composerQm.setBlocking( true ); - composerQm.run(); - QCOMPARE( composerQm.composers().count(), 2 ); - - Collections::SqlQueryMaker yearQm( m_collection ); - yearQm.setQueryType( Collections::QueryMaker::Year ); - yearQm.setBlocking( true ); - yearQm.run(); - QCOMPARE( yearQm.years().count(), 2 ); - -} - -void -TestSqlQueryMaker::testSpecialCharacters_data() -{ - QTest::addColumn( "filter" ); - QTest::addColumn( "like" ); - - QTest::newRow( "slash in filter w/o like" ) << "AC/DC" << false; - QTest::newRow( "slash in filter w/ like" ) << "AC/DC" << true; - QTest::newRow( "backslash in filter w/o like" ) << "AC\\DC" << false; - QTest::newRow( "backslash in filter w like" ) << "AC\\DC" << true; - QTest::newRow( "quote in filter w/o like" ) << "Foo'Bar" << false; - QTest::newRow( "quote in filter w like" ) << "Foo'Bar" << true; - QTest::newRow( "% in filter w/o like" ) << "Foo%Bar" << false; - QTest::newRow( "% in filter w/ like" ) << "Foo%Bar" << true; - QTest::newRow( "filter ending with % w/o like" ) << "Foo%" << false; - QTest::newRow( "filter ending with % w like" ) << "Foo%" << true; - QTest::newRow( "filter beginning with % w/o like" ) << "%Foo" << false; - QTest::newRow( "filter beginning with % w/o like" ) << "%Foo" << true; - QTest::newRow( "\" in filter w/o like" ) << "Foo\"Bar" << false; - QTest::newRow( "\" in filter w like" ) << "Foo\"Bar" << true; - QTest::newRow( "_ in filter w/o like" ) << "track_" << false; - QTest::newRow( "_ in filter w/ like" ) << "track_" << true; - QTest::newRow( "filter with two consecutive backslashes w/o like" ) << "Foo\\\\Bar" << false; - QTest::newRow( "filter with two consecutive backslashes w like" ) << "Foo\\\\Bar" << true; - QTest::newRow( "filter with backslash% w/o like" ) << "FooBar\\%" << false; - QTest::newRow( "filter with backslash% w like" ) << "FooBar\\%" << true; -} - -void -TestSqlQueryMaker::testSpecialCharacters() -{ - QFETCH( QString, filter ); - QFETCH( bool, like ); - - QString insertTrack = QString( "INSERT INTO tracks(id,url,title,comment,artist,album,genre,year,composer) " - "VALUES(999,999,'%1','',1,1,1,1,1);").arg( m_storage->escape( filter ) ); - - //there is a unique index on TRACKS.URL - m_storage->query( "INSERT INTO urls(id, deviceid, rpath, directory, uniqueid) VALUES(999, -1, './foobar.mp3', 1, '999');"); - m_storage->query( insertTrack ); - - QCOMPARE( m_storage->query( "select count(*) from urls where id = 999" ).first(), QString("1") ); - QCOMPARE( m_storage->query( "select count(*) from tracks where id = 999" ).first(), QString("1") ); - - Collections::SqlQueryMaker qm( m_collection ); - qm.setBlocking( true ); - qm.setQueryType( Collections::QueryMaker::Track ); - qm.addFilter( Meta::valTitle, filter, !like, !like ); - - qm.run(); - - m_storage->query( "DELETE FROM urls WHERE id = 999;" ); - m_storage->query( "DELETE FROM tracks WHERE id = 999;" ); - - QCOMPARE( qm.tracks().count(), 1 ); -} - -void -TestSqlQueryMaker::testNumberFilter_data() -{ - QTest::addColumn( "type" ); - QTest::addColumn( "value" ); - QTest::addColumn( "filter" ); - QTest::addColumn( "comparison" ); - QTest::addColumn( "exclude" ); - QTest::addColumn( "count" ); - - QTest::newRow( "include rating greater 4" ) << Collections::QueryMaker::Track << Meta::valRating << 4 << Collections::QueryMaker::GreaterThan << false << 1; - QTest::newRow( "exclude rating smaller 4" ) << Collections::QueryMaker::Album << Meta::valRating << 4 << Collections::QueryMaker::LessThan << true << 4; - QTest::newRow( "exclude tracks first played later than 2000" ) << Collections::QueryMaker::Track << Meta::valFirstPlayed << 2000 << Collections::QueryMaker::GreaterThan << true << 5; - //having never been played does not mean played before 20000 - QTest::newRow( "include last played before 20000" ) << Collections::QueryMaker::Track << Meta::valLastPlayed << 20000 << Collections::QueryMaker::LessThan << false << 1; - QTest::newRow( "playcount equals 100" ) << Collections::QueryMaker::Album << Meta::valPlaycount << 100 << Collections::QueryMaker::Equals << false << 1; - //should include unplayed songs - QTest::newRow( "playcount != 50" ) << Collections::QueryMaker::Track << Meta::valPlaycount << 50 << Collections::QueryMaker::Equals << true << 5; - QTest::newRow( "score greater 60" ) << Collections::QueryMaker::Genre << Meta::valScore << 60 << Collections::QueryMaker::GreaterThan << false << 1; -} - -void -TestSqlQueryMaker::testNumberFilter() -{ - - QFETCH( Collections::QueryMaker::QueryType, type ); - QFETCH( qint64, value ); - QFETCH( int, filter ); - QFETCH( bool, exclude ); - QFETCH( Collections::QueryMaker::NumberComparison, comparison ); - QFETCH( int, count ); - - Collections::SqlQueryMaker qm( m_collection ); - qm.setBlocking( true ); - qm.setQueryType( type ); - - if( exclude ) - qm.excludeNumberFilter( value, filter, comparison ); - else - qm.addNumberFilter( value, filter, comparison ); - - qm.run(); - - checkResultCount( &qm, type, count ); -} - -void -TestSqlQueryMaker::testReturnFunctions_data() -{ - QTest::addColumn( "function" ); - QTest::addColumn( "value" ); - QTest::addColumn( "result" ); - - QTest::newRow( "count tracks" ) << Collections::QueryMaker::Count << Meta::valTitle << QString( "6" ); - QTest::newRow( "sum of playcount" ) << Collections::QueryMaker::Sum << Meta::valPlaycount << QString( "160" ); - QTest::newRow( "min score" ) << Collections::QueryMaker::Min << Meta::valScore << QString( "50" ); - QTest::newRow( "max rating" ) << Collections::QueryMaker::Max << Meta::valRating << QString( "9" ); -} - -void -TestSqlQueryMaker::testReturnFunctions() -{ - QFETCH( Collections::QueryMaker::ReturnFunction, function ); - QFETCH( qint64, value ); - QFETCH( QString, result ); - - Collections::SqlQueryMaker qm( m_collection ); - qm.setBlocking( true ); - qm.setQueryType( Collections::QueryMaker::Custom ); - qm.addReturnFunction( function, value ); - - qm.run(); - - QCOMPARE( qm.customData().first(), result ); -} - -void -TestSqlQueryMaker::testLabelMatch() -{ - Meta::LabelPtr label = m_collection->registry()->getLabel( "labelB" ); - Collections::SqlQueryMaker qm( m_collection ); - qm.setBlocking( true ); - qm.setQueryType( QueryMaker::Track ); - qm.addMatch( label ); - qm.run(); - - QCOMPARE( qm.tracks().count(), 3 ); -} - -void -TestSqlQueryMaker::testMultipleLabelMatches() -{ - Meta::LabelPtr labelB = m_collection->registry()->getLabel( "labelB" ); - Meta::LabelPtr labelA = m_collection->registry()->getLabel( "labelA" ); - Collections::SqlQueryMaker qm( m_collection ); - qm.setBlocking( true ); - qm.setQueryType( QueryMaker::Track ); - qm.addMatch( labelB ); - qm.addMatch( labelA ); - qm.run(); - - QCOMPARE( qm.tracks().count(), 1 ); -} - -void -TestSqlQueryMaker::testQueryTypesWithLabelMatching_data() -{ - QTest::addColumn( "type" ); - QTest::addColumn( "result" ); - - QTest::newRow( "query tracks" ) << Collections::QueryMaker::Track << 1; - QTest::newRow( "query albums" ) << Collections::QueryMaker::Album << 1; - QTest::newRow( "query artists" ) << Collections::QueryMaker::Artist << 1; - QTest::newRow( "query genre" ) << Collections::QueryMaker::Genre << 1; - QTest::newRow( "query composers" ) << Collections::QueryMaker::Composer << 1; - QTest::newRow( "query years" ) << Collections::QueryMaker::Year << 1; - QTest::newRow( "query labels" ) << Collections::QueryMaker::Label << 2; -} - -void -TestSqlQueryMaker::testQueryTypesWithLabelMatching() -{ - - QFETCH( Collections::QueryMaker::QueryType, type ); - QFETCH( int, result ); - - Meta::LabelPtr labelB = m_collection->registry()->getLabel( "labelB" ); - Meta::LabelPtr labelA = m_collection->registry()->getLabel( "labelA" ); - Collections::SqlQueryMaker qm( m_collection ); - qm.setBlocking( true ); - qm.setQueryType( type ); - qm.addMatch( labelB ); - qm.addMatch( labelA ); - qm.run(); - - checkResultCount( &qm, type, result ); -} - -void -TestSqlQueryMaker::testFilterOnLabelsAndCombination() -{ - Collections::SqlQueryMaker qm( m_collection ); - qm.setBlocking( true ); - qm.setQueryType( Collections::QueryMaker::Track ); - qm.beginAnd(); - qm.addFilter( Meta::valLabel, "labelB", true, true ); - qm.addFilter( Meta::valLabel, "labelA", false, false ); - qm.endAndOr(); - qm.run(); - - QCOMPARE( qm.tracks().count(), 1 ); -} - -void -TestSqlQueryMaker::testFilterOnLabelsOrCombination() -{ - Collections::SqlQueryMaker qm( m_collection ); - qm.setBlocking( true ); - qm.setQueryType( Collections::QueryMaker::Track ); - qm.beginOr(); - qm.addFilter( Meta::valLabel, "labelB", true, true ); - qm.addFilter( Meta::valLabel, "labelA", false, false ); - qm.endAndOr(); - qm.run(); - - QCOMPARE( qm.tracks().count(), 3 ); -} - -void -TestSqlQueryMaker::testFilterOnLabelsNegationAndCombination() -{ - Collections::SqlQueryMaker qm( m_collection ); - qm.setBlocking( true ); - qm.setQueryType( Collections::QueryMaker::Track ); - qm.beginAnd(); - qm.excludeFilter( Meta::valLabel, "labelB", true, true ); - qm.excludeFilter( Meta::valLabel, "labelA", false, false ); - qm.endAndOr(); - qm.run(); - - QCOMPARE( qm.tracks().count(), 3 ); -} - -void -TestSqlQueryMaker::testFilterOnLabelsNegationOrCombination() -{ - Collections::SqlQueryMaker qm( m_collection ); - qm.setBlocking( true ); - qm.setQueryType( Collections::QueryMaker::Track ); - qm.beginOr(); - qm.excludeFilter( Meta::valLabel, "labelB", true, true ); - qm.excludeFilter( Meta::valLabel, "labelA", false, false ); - qm.endAndOr(); - qm.run(); - - QCOMPARE( qm.tracks().count(), 5 ); -} - -void -TestSqlQueryMaker::testComplexLabelsFilter() -{ - Collections::SqlQueryMaker qm( m_collection ); - qm.setBlocking( true ); - qm.setQueryType( Collections::QueryMaker::Track ); - qm.beginOr(); - qm.addFilter( Meta::valLabel, "test", true, true ); - qm.beginAnd(); - qm.addFilter( Meta::valLabel, "labelB", false, false ); - qm.excludeFilter( Meta::valLabel, "labelA", false, true ); - qm.endAndOr(); - qm.endAndOr(); - qm.run(); - - QCOMPARE( qm.tracks().count(), 3 ); -} - -void -TestSqlQueryMaker::testLabelQueryMode_data() -{ - QTest::addColumn( "type" ); - QTest::addColumn( "labelMode" ); - QTest::addColumn( "albumMode" ); - QTest::addColumn( "result" ); - - QTest::newRow( "labels with querymode WithoutLabels" ) << QueryMaker::Label << QueryMaker::OnlyWithoutLabels << QueryMaker::AllAlbums << 0; - QTest::newRow( "tracks with labels" ) << QueryMaker::Track << QueryMaker::OnlyWithLabels << QueryMaker::AllAlbums << 4; - QTest::newRow( "Compilations with labels" ) << QueryMaker::Album << QueryMaker::OnlyWithLabels << QueryMaker::OnlyCompilations << 1; - QTest::newRow( "Compilations without labels" ) << QueryMaker::Album << QueryMaker::OnlyWithoutLabels << QueryMaker::OnlyCompilations << 1; -} - -void -TestSqlQueryMaker::testLabelQueryMode() -{ - QFETCH( QueryMaker::QueryType, type ); - QFETCH( QueryMaker::LabelQueryMode, labelMode ); - QFETCH( QueryMaker::AlbumQueryMode, albumMode ); - QFETCH( int, result ); - - SqlQueryMaker qm( m_collection ); - qm.setBlocking( true ); - qm.setQueryType( type ); - qm.setAlbumQueryMode( albumMode ); - qm.setLabelQueryMode( labelMode ); - qm.run(); - - checkResultCount( &qm, type, result ); -} - -#include "moc_TestSqlQueryMaker.cpp" diff --git a/amarok/tests/core-impl/collections/db/sql/TestSqlQueryMaker.h b/amarok/tests/core-impl/collections/db/sql/TestSqlQueryMaker.h deleted file mode 100644 index b9703b28..00000000 --- a/amarok/tests/core-impl/collections/db/sql/TestSqlQueryMaker.h +++ /dev/null @@ -1,102 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef TESTSQLQUERYMAKER_H -#define TESTSQLQUERYMAKER_H - -#include -#include - -#include - -class MySqlEmbeddedStorage; -class SqlMountPointManagerMock; - -namespace Collections { - class SqlCollection; - class SqlQueryMaker; -} - -class TestSqlQueryMaker : public QObject -{ - Q_OBJECT -public: - TestSqlQueryMaker(); - -private slots: - void initTestCase(); - void cleanupTestCase(); - - void cleanup(); - - void testQueryTracks(); - void testQueryAlbums(); - void testQueryGenres(); - void testQueryYears(); - void testQueryComposers(); - void testQueryArtists(); - void testAlbumQueryMode(); - - void testDeleteQueryMakerWithRunningQuery(); - - void testAsyncTrackQuery(); - void testAsyncArtistQuery(); - void testAsyncGenreQuery(); - void testAsyncComposerQuery(); - void testAsyncAlbumQuery(); - void testAsyncYearQuery(); - void testAsyncCustomQuery(); - - void testFilter(); - void testFilter_data(); - - void testDynamicCollection(); - - void testSpecialCharacters_data(); - void testSpecialCharacters(); - - void testNumberFilter(); - void testNumberFilter_data(); - - void testReturnFunctions_data(); - void testReturnFunctions(); - - void testLabelMatch(); - void testMultipleLabelMatches(); - - void testQueryTypesWithLabelMatching_data(); - void testQueryTypesWithLabelMatching(); - - void testFilterOnLabelsAndCombination(); - void testFilterOnLabelsOrCombination(); - void testFilterOnLabelsNegationAndCombination(); - void testFilterOnLabelsNegationOrCombination(); - void testComplexLabelsFilter(); - - void testLabelQueryMode_data(); - void testLabelQueryMode(); - -private: - void checkResultCount( Collections::SqlQueryMaker* qm, - Collections::QueryMaker::QueryType type, int count ); - - Collections::SqlCollection *m_collection; - SqlMountPointManagerMock *m_mpm; - MySqlEmbeddedStorage *m_storage; - KTempDir *m_tmpDir; -}; - -#endif // TESTSQLQUERYMAKER_H diff --git a/amarok/tests/core-impl/collections/db/sql/TestSqlScanManager.cpp b/amarok/tests/core-impl/collections/db/sql/TestSqlScanManager.cpp deleted file mode 100644 index 217d4e4c..00000000 --- a/amarok/tests/core-impl/collections/db/sql/TestSqlScanManager.cpp +++ /dev/null @@ -1,1623 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Maximilian Kossick * - * Copyright (c) 2010 Ralf Engels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "TestSqlScanManager.h" - -#include "amarokconfig.h" -#include "MetaTagLib.h" -#include "scanner/GenericScanManager.h" -#include "core-impl/collections/db/sql/SqlCollection.h" -#include "core-impl/collections/db/sql/SqlQueryMaker.h" -#include "core-impl/collections/db/sql/SqlRegistry.h" -#include "core-impl/storage/sql/mysqlestorage/MySqlEmbeddedStorage.h" - -#include "config-amarok-test.h" -#include "SqlMountPointManagerMock.h" - -#include - -#include -#include -#include - -QTEST_KDEMAIN_CORE( TestSqlScanManager ) - -TestSqlScanManager::TestSqlScanManager() - : QObject() -{ - QString help = i18n("Amarok"); // prevent a bug when the scanner is the first thread creating a translator -} - -void -TestSqlScanManager::initTestCase() -{ - // setenv( "LC_ALL", "", 1 ); // this breakes the test - // Amarok does not force LC_ALL=C but obviously the test does it which - // will prevent scanning of files with umlauts. - - //Tell GenericScanManager that we want to use the recently built scanner, not an installed version. - const QString overridePath = QString( AMAROK_OVERRIDE_UTILITIES_PATH ); - qApp->setProperty( "overrideUtilitiesPath", overridePath ); - - // that is the original mp3 file that we use to generate the "real" tracks - m_sourcePath = QDir::toNativeSeparators( QString( AMAROK_TEST_DIR ) + "/data/audio/Platz 01.mp3" ); - QVERIFY( QFile::exists( m_sourcePath ) ); - - m_tmpDatabaseDir = new KTempDir(); - QVERIFY( m_tmpDatabaseDir->exists() ); - m_storage = new MySqlEmbeddedStorage(); - QVERIFY( m_storage->init( m_tmpDatabaseDir->name() ) ); - - m_collection = new Collections::SqlCollection( m_storage ); - connect( m_collection, SIGNAL(updated()), this, SLOT(slotCollectionUpdated()) ); - - // TODO: change the mock mount point manager so that it doesn't pull - // in all the devices. Not much of a mock like this. - SqlMountPointManagerMock *mock = new SqlMountPointManagerMock( this, m_storage ); - m_collection->setMountPointManager( mock ); - m_scanManager = m_collection->scanManager(); - - AmarokConfig::setScanRecursively( true ); - AmarokConfig::setMonitorChanges( false ); - - // switch on writing back so that we can create the test files with all the information - AmarokConfig::setWriteBack( true ); - AmarokConfig::setWriteBackStatistics( true ); - AmarokConfig::setWriteBackCover( true ); - - // I just need the table and not the whole playlist manager - /* - m_storage->query( QString( "CREATE TABLE playlist_tracks (" - " id " + m_storage->idType() + - ", playlist_id INTEGER " - ", track_num INTEGER " - ", url " + m_storage->exactTextColumnType() + - ", title " + m_storage->textColumnType() + - ", album " + m_storage->textColumnType() + - ", artist " + m_storage->textColumnType() + - ", length INTEGER " - ", uniqueid " + m_storage->textColumnType(128) + ") ENGINE = MyISAM;" ) ); - */ -} - -void -TestSqlScanManager::cleanupTestCase() -{ - // aborts a ThreadWeaver job that would otherwise cause next statement to stall - delete m_collection; - - // we cannot simply call WeaverInterface::finish(), it stops event loop - if( !ThreadWeaver::Weaver::instance()->isIdle() ) - QVERIFY2( QTest::kWaitForSignal( ThreadWeaver::Weaver::instance(), - SIGNAL(finished()), 5000 ), "threads did not finish in timeout" ); - - //m_storage is deleted by SqlCollection - delete m_tmpDatabaseDir; -} - -void -TestSqlScanManager::init() -{ - m_tmpCollectionDir = new KTempDir(); - QVERIFY( m_tmpCollectionDir->exists() ); - - QStringList collectionFolders; - collectionFolders << m_tmpCollectionDir->name(); - m_collection->mountPointManager()->setCollectionFolders( collectionFolders ); -} - -void -TestSqlScanManager::cleanup() -{ - m_scanManager->abort(); - - m_storage->query( "BEGIN" ); - m_storage->query( "TRUNCATE TABLE tracks;" ); - m_storage->query( "TRUNCATE TABLE albums;" ); - m_storage->query( "TRUNCATE TABLE artists;" ); - m_storage->query( "TRUNCATE TABLE composers;" ); - m_storage->query( "TRUNCATE TABLE genres;" ); - m_storage->query( "TRUNCATE TABLE years;" ); - m_storage->query( "TRUNCATE TABLE urls;" ); - m_storage->query( "TRUNCATE TABLE statistics;" ); - m_storage->query( "TRUNCATE TABLE directories;" ); - m_storage->query( "COMMIT" ); - m_collection->registry()->emptyCache(); - - delete m_tmpCollectionDir; -} - -void -TestSqlScanManager::testScanSingle() -{ - m_collectionUpdatedCount = 0; - createSingleTrack(); - fullScanAndWait(); - - QVERIFY( m_collectionUpdatedCount > 0 ); - - // -- check the commit - Meta::TrackPtr track = m_collection->registry()->getTrack( 1 ); - QVERIFY( track ); - QCOMPARE( track->name(), QString("Theme From Armageddon") ); - QVERIFY( track->artist() ); - QCOMPARE( track->artist()->name(), QString("Soundtrack & Theme Orchestra") ); - QVERIFY( track->album() ); - QCOMPARE( track->album()->name(), QString("Big Screen Adventures") ); - QVERIFY( track->album()->albumArtist() ); - QCOMPARE( track->album()->albumArtist()->name(), QString("Theme Orchestra") ); - QVERIFY( !track->album()->isCompilation() ); // One single track is not compilation - QCOMPARE( track->composer()->name(), QString("Unknown Composer") ); - QCOMPARE( track->comment(), QString("Amazon.com Song ID: 210541237") ); - QCOMPARE( track->year()->year(), 2009 ); - QCOMPARE( track->type(), QString("mp3") ); - QCOMPARE( track->trackNumber(), 28 ); - QCOMPARE( track->bitrate(), 256 ); - QCOMPARE( track->length(), qint64(12000) ); - QCOMPARE( track->sampleRate(), 44100 ); - QCOMPARE( track->filesize(), 389679 ); - QDateTime aDate = QDateTime::currentDateTime(); - QVERIFY( track->createDate().secsTo( aDate ) < 5 ); // I just imported the file - QVERIFY( track->createDate().secsTo( aDate ) >= 0 ); - QVERIFY( track->modifyDate().secsTo( aDate ) < 5 ); // I just wrote the file - QVERIFY( track->modifyDate().secsTo( aDate ) >= 0 ); - Meta::StatisticsPtr statistics = track->statistics(); - qFuzzyCompare( statistics->score(), 0.875 ); - QCOMPARE( statistics->playCount(), 5 ); - QVERIFY( !statistics->firstPlayed().isValid() ); - QVERIFY( !statistics->lastPlayed().isValid() ); - QVERIFY( track->createDate().isValid() ); - - // -- check that a further scan doesn't change anything - m_collectionUpdatedCount = 0; - - fullScanAndWait(); - - QCOMPARE( m_collectionUpdatedCount, 0 ); -} - -void -TestSqlScanManager::testScanDirectory() -{ - createAlbum(); - fullScanAndWait(); - - // -- check the commit - Meta::AlbumPtr album; - album = m_collection->registry()->getAlbum( "Thriller", "Michael Jackson" ); - QVERIFY( album ); - QCOMPARE( album->name(), QString("Thriller") ); - QCOMPARE( album->tracks().count(), 9 ); - QVERIFY( !album->isCompilation() ); - QVERIFY( !album->hasImage() ); -} - -void -TestSqlScanManager::testDuplicateUid() -{ - Meta::FieldHash values; - - // create two tracks with same uid - values.clear(); - values.insert( Meta::valUniqueId, QVariant("c6c29f50279ab9523a0f44928bc1e96b") ); - values.insert( Meta::valUrl, QVariant("track1.mp3") ); - values.insert( Meta::valTitle, QVariant("Track 1") ); - createTrack( values ); - - values.clear(); - values.insert( Meta::valUniqueId, QVariant("c6c29f50279ab9523a0f44928bc1e96b") ); - values.insert( Meta::valUrl, QVariant("track2.mp3") ); - values.insert( Meta::valTitle, QVariant("Track 2") ); - createTrack( values ); - - fullScanAndWait(); - - // -- check the commit (the database needs to have been updated correctly) - m_collection->registry()->emptyCache(); - - // -- both tracks should be present - Meta::AlbumPtr album; - album = m_collection->registry()->getAlbum( 1 ); - QVERIFY( album ); - QVERIFY( album->tracks().count() >= 1 ); -} - -void -TestSqlScanManager::testLongUid() -{ - Meta::FieldHash values; - - // create two tracks with different very long - values.clear(); - values.insert( Meta::valUniqueId, QVariant("c6c29f50279ab9523a0f44928bc1e96c6c29f50279ab9523a0f44928bc1e96c6c29f50279ab9523a0f44928bc1e96c6c29f50279ab9523a0f44928bc1e96c6c29f50279ab9523a0f44928bc1e96c6c29f50279ab9523a0f44928bc1e96c6c29f50279ab9523a0f44928bc1e96c6c29f50279ab9523a0f44928bc1e96c6c29f50279ab9523a0f44928bc1e96c6c29f50279ab9523a0f44928bc1e96c6c29f50279ab9523a0f44928bc1e96c6c29f50279ab9523a0f44928bc1e96c6c29f50279ab9523a0f44928bc1e96c6c29f50279ab9523a0f44928bc1e96bbbbbbbbbbbbbbc6c29f50279ab9523a0f44928bc1e96b1") ); - values.insert( Meta::valUrl, QVariant("track1.mp3") ); - values.insert( Meta::valTitle, QVariant("Track 1") ); - createTrack( values ); - - values.clear(); - values.insert( Meta::valUniqueId, QVariant("c6c29f50279ab9523a0f44928bc1e96c6c29f50279ab9523a0f44928bc1e96c6c29f50279ab9523a0f44928bc1e96c6c29f50279ab9523a0f44928bc1e96c6c29f50279ab9523a0f44928bc1e96c6c29f50279ab9523a0f44928bc1e96c6c29f50279ab9523a0f44928bc1e96c6c29f50279ab9523a0f44928bc1e96c6c29f50279ab9523a0f44928bc1e96c6c29f50279ab9523a0f44928bc1e96c6c29f50279ab9523a0f44928bc1e96c6c29f50279ab9523a0f44928bc1e96c6c29f50279ab9523a0f44928bc1e96c6c29f50279ab9523a0f44928bc1e96bbbbbbbbbbbbbbc6c29f50279ab9523a0f44928bc1e96b2") ); - values.insert( Meta::valUrl, QVariant("track2.mp3") ); - values.insert( Meta::valTitle, QVariant("Track 2") ); - createTrack( values ); - - fullScanAndWait(); - - // -- check the commit (the database needs to have been updated correctly) - m_collection->registry()->emptyCache(); - - // both tracks should be present - Meta::AlbumPtr album; - album = m_collection->registry()->getAlbum( 1 ); - QVERIFY( album ); - QCOMPARE( album->tracks().count(), 2 ); -} - - -void -TestSqlScanManager::testCompilation() -{ - createAlbum(); - createCompilation(); - createCompilationLookAlikeAlbum(); - - Meta::FieldHash values; - - // create one compilation track - values.clear(); - values.insert( Meta::valUniqueId, QVariant("c6c29f50279ab9523a0f44928bc1e96b") ); - values.insert( Meta::valUrl, QVariant("Amazon MP3/The Sum Of All Fears (O.S.T.)/The Sum of All Fears/01 - If We Could Remember (O.S.T. LP Version).mp3") ); - values.insert( Meta::valTitle, QVariant("If We Could Remember (O.S.T. LP Version)") ); - values.insert( Meta::valArtist, QVariant("The Sum Of All Fears (O.S.T.)/Yolanda Adams") ); - values.insert( Meta::valAlbum, QVariant("The Sum of All Fears") ); - values.insert( Meta::valCompilation, QVariant(true) ); - createTrack( values ); - - // create one various artists track - values.clear(); - values.insert( Meta::valUniqueId, QVariant("6ae759476c34256ff1d06f0b5c964d75") ); - values.insert( Meta::valUrl, QVariant("The Cross Of Changes/06 - The Dream Of The Dolphin.mp3") ); - values.insert( Meta::valTitle, QVariant("The Dream Of The Dolphin") ); - values.insert( Meta::valArtist, QVariant("Various Artists") ); - values.insert( Meta::valAlbum, QVariant("The Cross Of Changes") ); - values.insert( Meta::valCompilation, QVariant(false) ); - createTrack( values ); - - // create two tracks in the same directory with different albums - values.clear(); - values.insert( Meta::valUniqueId, QVariant("7957bc25521c1dc91351d497321c27a6") ); - values.insert( Meta::valUrl, QVariant("01 - Solid.mp3") ); - values.insert( Meta::valTitle, QVariant("Solid") ); - values.insert( Meta::valArtist, QVariant("Ashford & Simpson") ); - values.insert( Meta::valAlbum, QVariant("Solid") ); - createTrack( values ); - - // create one none compilation track - values.clear(); - values.insert( Meta::valUniqueId, QVariant("b88c3405cfee64c50768b75eb6e3feea") ); - values.insert( Meta::valUrl, QVariant("In-Mood feat. Juliette - The Last Unicorn (Elemental Radio Mix).mp3") ); - values.insert( Meta::valTitle, QVariant("The Last Unicorn (Elemental Radio Mix)") ); - values.insert( Meta::valArtist, QVariant("In-Mood") ); - values.insert( Meta::valAlbum, QVariant("The Last Unicorn") ); - createTrack( values ); - - fullScanAndWait(); - - // -- check the commit - Meta::AlbumPtr album; - - album = m_collection->registry()->getAlbum( "Thriller", "Michael Jackson" ); - QCOMPARE( album->tracks().count(), 9 ); - QVERIFY( !album->isCompilation() ); - - album = m_collection->registry()->getAlbum( "Top Gun", QString() ); - QCOMPARE( album->name(), QString("Top Gun") ); - QCOMPARE( album->tracks().count(), 10 ); - QVERIFY( album->isCompilation() ); - - album = m_collection->registry()->getAlbum( "The Sum of All Fears", QString() ); - QCOMPARE( album->tracks().count(), 1 ); - QVERIFY( album->isCompilation() ); - - album = m_collection->registry()->getAlbum( "The Cross Of Changes", QString() ); - QCOMPARE( album->tracks().count(), 1 ); - QVERIFY( album->isCompilation() ); // the album is by various artists - - album = m_collection->registry()->getAlbum( "Solid", "Ashford & Simpson" ); - QCOMPARE( album->tracks().count(), 1 ); - QVERIFY( !album->isCompilation() ); - - album = m_collection->registry()->getAlbum( "The Last Unicorn", "In-Mood" ); - QCOMPARE( album->tracks().count(), 1 ); - QVERIFY( !album->isCompilation() ); - - // this album is a little tricky because it has some nasty special characters in it. - Meta::TrackPtr track = m_collection->registry()->getTrackFromUid( m_collection->uidUrlProtocol() + "://" + "0969ea6128444e128cfcac95207bd525" ); - QVERIFY( track ); - album = track->album(); - QCOMPARE( album->tracks().count(), 13 ); - QVERIFY( !album->isCompilation() ); -} - -void -TestSqlScanManager::testBlock() -{ - /** TODO: do we need blocking at all? - - createSingleTrack(); - Meta::TrackPtr track; - - m_scanManager->blockScan(); // block the incremental scanning - m_scanManager->requestFullScan(); - - QTest::qWait( 100 ); - track = m_collection->registry()->getTrack( 1 ); - QVERIFY( !track ); - QVERIFY( !m_scanManager->isRunning() ); - - m_scanManager->unblockScan(); // block the incremental scanning - // now the actual behaviour is not defined. - // it might or might not continue with the old scan - - waitScannerFinished(); // in case it does continue after all - */ -} - -void -TestSqlScanManager::testAddDirectory() -{ - createAlbum(); - fullScanAndWait(); - - createCompilation(); - fullScanAndWait(); - - // -- check the commit - Meta::AlbumPtr album = m_collection->registry()->getAlbum( "Thriller", "Michael Jackson" ); - QCOMPARE( album->tracks().count(), 9 ); - QVERIFY( !album->isCompilation() ); - - album = m_collection->registry()->getAlbum( "Top Gun", QString() ); - QVERIFY( album ); - QCOMPARE( album->tracks().count(), 10 ); - QVERIFY( album->isCompilation() ); -} - -void -TestSqlScanManager::testRemoveDir() -{ - Meta::AlbumPtr album; - - createAlbum(); - createCompilation(); - fullScanAndWait(); - - // -- check the commit - album = m_collection->registry()->getAlbum( "Thriller", "Michael Jackson" ); - QVERIFY( album ); - QCOMPARE( album->tracks().count(), 9 ); - QVERIFY( !album->isCompilation() ); - - album = m_collection->registry()->getAlbum( "Top Gun", QString() ); - QVERIFY( album ); - QCOMPARE( album->tracks().count(), 10 ); - QVERIFY( album->isCompilation() ); - - // -- remove one album - - album = m_collection->registry()->getAlbum( "Top Gun", QString() ); - QVERIFY( album ); - foreach( Meta::TrackPtr t, album->tracks() ) - QVERIFY( QFile::remove( t->playableUrl().path() ) ); - QVERIFY( QDir( m_tmpCollectionDir->name() ).rmdir( QFileInfo( album->tracks().first()->playableUrl().path() ).path() ) ); - - fullScanAndWait(); - - // this one is still here - album = m_collection->registry()->getAlbum( "Thriller", "Michael Jackson" ); - QVERIFY( album ); - QCOMPARE( album->tracks().count(), 9 ); - QVERIFY( !album->isCompilation() ); - - // this one is gone - album = m_collection->registry()->getAlbum( "Top Gun", QString() ); - QVERIFY( album ); - QCOMPARE( album->tracks().count(), 0 ); - - // -- remove the second album - // this time it's a directory inside a directory - album = m_collection->registry()->getAlbum( "Thriller", "Michael Jackson" ); - QVERIFY( album ); - QCOMPARE( album->tracks().count(), 9 ); - foreach( Meta::TrackPtr t, album->tracks() ) - QVERIFY( QFile::remove( t->playableUrl().path() ) ); - - QVERIFY( QDir( m_tmpCollectionDir->name() ).rmdir( QFileInfo( album->tracks().first()->playableUrl().path() ).path() ) ); - - incrementalScanAndWait(); - - // this time both are gone - album = m_collection->registry()->getAlbum( "Thriller", "Michael Jackson" ); - QVERIFY( album ); - QCOMPARE( album->tracks().count(), 0 ); - album = m_collection->registry()->getAlbum( "Top Gun", QString() ); - QVERIFY( album ); - QCOMPARE( album->tracks().count(), 0 ); - -} - -void -TestSqlScanManager::testUidChangeMoveDirectoryIncrementalScan() -{ - createAlbum(); - fullScanAndWait(); - - Meta::AlbumPtr album; - Meta::TrackList tracks; - - // -- check the commit - album = m_collection->registry()->getAlbum( "Thriller", "Michael Jackson" ); - QVERIFY( album ); - tracks = album->tracks(); - QCOMPARE( tracks.count(), 9 ); - QCOMPARE( tracks.first()->uidUrl(), QString("amarok-sqltrackuid://1dc7022c52a3e4c51b46577da9b3c8ff") ); - QVERIFY( !album->isCompilation() ); - - // change all the track uids in a silly way - QHash uidChanges; // uid hashed with track number - foreach( const Meta::TrackPtr &track, tracks ) - { - Meta::FieldHash uidChange; - QString uid = track->uidUrl().remove( QString("amarok-sqltrackuid://") ); - QStringRef left = uid.leftRef( 10 ); - QStringRef right = uid.rightRef( uid.size() - left.size() ); - QString newUid = QString("%1%2").arg( right.toString(), left.toString() ); - uidChange.insert( Meta::valUniqueId, newUid ); - uidChanges.insert( track->trackNumber(), newUid ); - - KUrl url = track->playableUrl(); - QVERIFY( url.isLocalFile() ); - Meta::Tag::writeTags( url.path(), uidChange, true ); - } - - // move album directory - const KUrl oldUrl = tracks.first()->playableUrl(); - const QString base = m_tmpCollectionDir->name() + "Pop"; - QVERIFY( QFile::rename( base, base + "Albums" ) ); - - // do an incremental scan - incrementalScanAndWait(); - - // recheck album - album = m_collection->registry()->getAlbum( "Thriller", "Michael Jackson" ); - QVERIFY( album ); - tracks = album->tracks(); - QCOMPARE( tracks.count(), 9 ); - - // check changed uids - foreach( const Meta::TrackPtr &track, tracks ) - { - QString uid = track->uidUrl().remove( QString("amarok-sqltrackuid://") ); - QCOMPARE( uid, uidChanges.value( track->trackNumber() ) ); - } -} - -void -TestSqlScanManager::testRemoveTrack() -{ - Meta::AlbumPtr album; - Meta::TrackPtr track; - QDateTime aDate = QDateTime::currentDateTime(); - - createAlbum(); - fullScanAndWait(); - - // -- check the commit - album = m_collection->registry()->getAlbum( "Thriller", "Michael Jackson" ); - QVERIFY( album ); - QCOMPARE( album->tracks().count(), 9 ); - QVERIFY( !album->isCompilation() ); - track = album->tracks().first(); // the tracks are sorted, so this is always the same track - QCOMPARE( track->trackNumber(), 1 ); - QVERIFY( !track->statistics()->firstPlayed().isValid() ); - static_cast(track.data())->setFirstPlayed( aDate ); - - // -- remove one track - QVERIFY( QFile::remove( track->playableUrl().path() ) ); - - fullScanAndWait(); - - // -- check that the track is really gone - QCOMPARE( album->tracks().count(), 8 ); -} - -void -TestSqlScanManager::testMove() -{ - createAlbum(); - createCompilation(); - - // we use the created and first played attributes for identifying the moved tracks. - // currently those are not written back to the track - - Meta::AlbumPtr album; - Meta::TrackPtr track; - QDateTime aDate = QDateTime::currentDateTime(); - - fullScanAndWait(); - - // -- check the commit - album = m_collection->registry()->getAlbum( "Thriller", "Michael Jackson" ); - QVERIFY( album ); - QCOMPARE( album->tracks().count(), 9 ); - QVERIFY( !album->isCompilation() ); - track = album->tracks().first(); - QCOMPARE( track->trackNumber(), 1 ); - QDateTime createDate = track->createDate(); - QDateTime modifyDate = track->modifyDate(); - - // --- move one track - static_cast(track.data())->setFirstPlayed( aDate ); - const QString targetPath = m_tmpCollectionDir->name() + "moved.mp3"; - QVERIFY( QFile::rename( track->playableUrl().path(), targetPath ) ); - - fullScanAndWait(); - - // -- check that the track is moved - QVERIFY( createDate == track->createDate() ); // create date should not have changed - QVERIFY( modifyDate == track->modifyDate() ); // we just changed the track. it should have changed - QCOMPARE( track->statistics()->firstPlayed(), aDate ); - QCOMPARE( track->playableUrl().path(), targetPath ); - - // --- move a directory - album = m_collection->registry()->getAlbum( "Top Gun", QString() ); - QVERIFY( album ); - QCOMPARE( album->tracks().count(), 10 ); - track = album->tracks().first(); - KUrl oldUrl = track->playableUrl(); - - QVERIFY( QFile::rename( m_tmpCollectionDir->name() + "Top Gun", - m_tmpCollectionDir->name() + "Top Gun - Soundtrack" ) ); - - // do an incremental scan - incrementalScanAndWait(); - - // check that the track is now moved (but still the old object) - QCOMPARE( album->tracks().count(), 10 ); // no doublicate tracks - QVERIFY( oldUrl != track->playableUrl() ); -} - -void -TestSqlScanManager::testFeat() -{ - Meta::FieldHash values; - - // create one compilation track - values.clear(); - values.insert( Meta::valUniqueId, QVariant("b88c3405cfee64c50768b75eb6e3feea") ); - values.insert( Meta::valUrl, QVariant("In-Mood feat. Juliette - The Last Unicorn (Elemental Radio Mix).mp3") ); - values.insert( Meta::valTitle, QVariant("The Last Unicorn (Elemental Radio Mix)") ); - values.insert( Meta::valArtist, QVariant("In-Mood feat. Juliette") ); - values.insert( Meta::valAlbum, QVariant("The Last Unicorn") ); - createTrack( values ); - - fullScanAndWait(); - - // -- check the commit - Meta::AlbumPtr album; - album = m_collection->registry()->getAlbum( "The Last Unicorn", "In-Mood" ); - QVERIFY( album ); - QCOMPARE( album->tracks().count(), 1 ); -} - -void -TestSqlScanManager::testAlbumImage() -{ - createSingleTrack(); - createAlbum(); - createCompilation(); - - // put an image into the album directory - QString imageSourcePath = QDir::toNativeSeparators( QString( AMAROK_TEST_DIR ) + "/data/playlists/no-playlist.png" ); - QVERIFY( QFile::exists( imageSourcePath ) ); - QString targetPath; - targetPath = m_tmpCollectionDir->name() + "Pop/Thriller/cover.png"; - QVERIFY( QFile::copy( m_sourcePath, targetPath ) ); - - // put an image into the compilation directory - targetPath = m_tmpCollectionDir->name() + "Top Gun/front.png"; - QVERIFY( QFile::copy( m_sourcePath, targetPath ) ); - - // set an embedded image - targetPath = m_tmpCollectionDir->name() + "Various Artists/Big Screen Adventures/28 - Theme From Armageddon.mp3"; - Meta::Tag::setEmbeddedCover( targetPath, QImage( 200, 200, QImage::Format_RGB32 ) ); - - fullScanAndWait(); - - // -- check the commit - Meta::AlbumPtr album; - - album = m_collection->registry()->getAlbum( "Thriller", "Michael Jackson" ); - QVERIFY( album ); - QVERIFY( album->hasImage() ); - - album = m_collection->registry()->getAlbum( "Top Gun", QString() ); - QVERIFY( album ); - QVERIFY( album->hasImage() ); - - album = m_collection->registry()->getAlbum( "Big Screen Adventures", "Theme Orchestra" ); - QVERIFY( album ); - QVERIFY( album->hasImage() ); -} - -void -TestSqlScanManager::testMerges() -{ - // songs from same album but different directory - // check that images are merged - // check that old image is not overwritten - - Meta::FieldHash values; - - values.clear(); - values.insert( Meta::valUniqueId, QVariant("123456d040d5dd9b5b45c1494d84cc82") ); - values.insert( Meta::valUrl, QVariant("Various Artists/Big Screen Adventures/28 - Theme From Armageddon.mp3") ); - values.insert( Meta::valFormat, QVariant("1") ); - values.insert( Meta::valTitle, QVariant("Unnamed track") ); - values.insert( Meta::valArtist, QVariant("Unknown artist") ); - createTrack( values ); - - // -- check the commit - fullScanAndWait(); - - Meta::TrackPtr track = m_collection->registry()->getTrack( 1 ); - QVERIFY( track ); - QCOMPARE( track->name(), QString("Unnamed track") ); - - // -- now overwrite the track with changed information and a new uid - // - remove one track - QVERIFY( QFile::remove( track->playableUrl().path() ) ); - - values.clear(); - values.insert( Meta::valUniqueId, QVariant("794b1bd040d5dd9b5b45c1494d84cc82") ); - values.insert( Meta::valUrl, QVariant("Various Artists/Big Screen Adventures/28 - Theme From Armageddon.mp3") ); - values.insert( Meta::valFormat, QVariant("1") ); - values.insert( Meta::valTitle, QVariant("Theme From Armageddon") ); - values.insert( Meta::valArtist, QVariant("Soundtrack & Theme Orchestra") ); - values.insert( Meta::valAlbum, QVariant("Big Screen Adventures") ); - values.insert( Meta::valComposer, QVariant("Unknown Composer") ); - values.insert( Meta::valComment, QVariant("Amazon.com Song ID: 210541237") ); - values.insert( Meta::valGenre, QVariant("Broadway & Vocalists") ); - values.insert( Meta::valYear, QVariant(2009) ); - values.insert( Meta::valTrackNr, QVariant(28) ); - values.insert( Meta::valScore, QVariant(0.875) ); - values.insert( Meta::valPlaycount, QVariant(5) ); - createTrack( values ); - - fullScanAndWait(); - - // -- check the commit - QCOMPARE( track->name(), QString("Theme From Armageddon") ); - QVERIFY( track->artist() ); - QCOMPARE( track->artist()->name(), QString("Soundtrack & Theme Orchestra") ); - QVERIFY( track->album() ); - QCOMPARE( track->album()->name(), QString("Big Screen Adventures") ); - QCOMPARE( track->composer()->name(), QString("Unknown Composer") ); - QCOMPARE( track->comment(), QString("Amazon.com Song ID: 210541237") ); - QCOMPARE( track->year()->year(), 2009 ); - QCOMPARE( track->type(), QString("mp3") ); - QCOMPARE( track->trackNumber(), 28 ); - QCOMPARE( track->bitrate(), 256 ); - QCOMPARE( track->length(), qint64(12000) ); - QCOMPARE( track->sampleRate(), 44100 ); - QCOMPARE( track->filesize(), 389679 ); - Meta::StatisticsPtr statistics = track->statistics(); - qFuzzyCompare( statistics->score(), 0.875 ); - QCOMPARE( statistics->playCount(), 5 ); - QVERIFY( !statistics->firstPlayed().isValid() ); - QVERIFY( !statistics->lastPlayed().isValid() ); - QVERIFY( track->createDate().isValid() ); - - - // -- now do an incremental scan - createAlbum(); // add a new album - incrementalScanAndWait(); - - // -- check the commit - Meta::AlbumPtr album; - - // the old track is still there - album = m_collection->registry()->getAlbum( "Big Screen Adventures", "Soundtrack & Theme Orchestra" ); - QVERIFY( album ); - QCOMPARE( album->tracks().count(), 1 ); - - // the new album is now here - album = m_collection->registry()->getAlbum( "Thriller", "Michael Jackson" ); - QVERIFY( album ); - QCOMPARE( album->tracks().count(), 9 ); - QVERIFY( !album->isCompilation() ); -} - -void -TestSqlScanManager::testLargeInsert() -{ - if( qgetenv("AMAROK_RUN_LONG_TESTS").isNull() ) - QSKIP( "takes too long to be run by default;\nDefine AMAROK_RUN_LONG_TESTS " - "environment variable to run all tests.", SkipAll ); - // the old large insert test was misleading as the problems with - // the insertion started upwards of 20000 tracks. - // - // For now here are the "ok" numbers on a sensible fast computer: - // Scanning 10000 files <3 min - // Committing 10000 files <30 sec - // Scanning 50000 files <13 min - // Committing 50000 files <1 min - - QDateTime aDate = QDateTime::currentDateTime(); - - // -- create the input data - QByteArray byteArray; - QBuffer *buffer = new QBuffer(&byteArray); - buffer->open(QIODevice::ReadWrite); - - QXmlStreamWriter writer( buffer ); - - writer.writeStartElement( "scanner" ); - - int trackCount = 0; - - // some simulated normal albums - for( int dirId = 0; dirId < 2000; dirId++ ) - { - writer.writeStartElement( "directory" ); - writer.writeTextElement( "path", QString::number(dirId) ); - writer.writeTextElement( "rpath", '/' + QString::number(dirId) ); - writer.writeTextElement( "mtime", QString::number(aDate.toTime_t()) ); - - for( int trackId = 0; trackId < 20; trackId++ ) - { - writer.writeStartElement( "track" ); - writer.writeTextElement( "uniqueid", "uid" + QString::number(trackCount) ); - writer.writeTextElement( "path", "/path" + QString::number(trackCount) ); - writer.writeTextElement( "rpath", "path" + QString::number(trackCount) ); - trackCount++; - writer.writeTextElement( "title", "track" + QString::number(trackCount) ); - writer.writeTextElement( "artist", "artist" + QString::number(dirId) ); - writer.writeTextElement( "album", QString::number(dirId) ); - writer.writeEndElement(); - } - - writer.writeEndElement(); - } - - // a simulated genre folders - for( int dirId = 0; dirId < 7; dirId++ ) - { - writer.writeStartElement( "directory" ); - writer.writeTextElement( "path", "genre" + QString::number(dirId) ); - writer.writeTextElement( "rpath", "/genre" + QString::number(dirId) ); - writer.writeTextElement( "mtime", QString::number(aDate.toTime_t()) ); - - for( int albumId = 0; albumId < 1000; albumId++ ) - { - writer.writeStartElement( "track" ); - writer.writeTextElement( "uniqueid", "uid" + QString::number(trackCount) ); - writer.writeTextElement( "path", "/path" + QString::number(trackCount) ); - writer.writeTextElement( "rpath", "path" + QString::number(trackCount) ); - trackCount++; - writer.writeTextElement( "title", "track" + QString::number(trackCount) ); - writer.writeTextElement( "artist", - "artist" + QString::number(dirId) + - "xx" + QString::number(albumId) ); - writer.writeTextElement( "album", - "genre album" + QString::number(dirId) + - "xx" + QString::number(albumId) ); - writer.writeEndElement(); - } - - writer.writeEndElement(); - } - - // A simulated amarok 1.4 collection folder - for( int dirId = 0; dirId < 3000; dirId++ ) - { - writer.writeStartElement( "directory" ); - writer.writeTextElement( "path", "collection" + QString::number(dirId) ); - writer.writeTextElement( "rpath", "/collection" + QString::number(dirId) ); - writer.writeTextElement( "mtime", QString::number(aDate.toTime_t()) ); - - writer.writeStartElement( "track" ); - writer.writeTextElement( "uniqueid", "uid" + QString::number(trackCount) ); - writer.writeTextElement( "path", "/path" + QString::number(trackCount) ); - writer.writeTextElement( "rpath", "path" + QString::number(trackCount) ); - trackCount++; - writer.writeTextElement( "title", "track" + QString::number(trackCount) ); - writer.writeTextElement( "artist", "album artist" + QString::number(dirId % 200) ); - writer.writeTextElement( "album", "album" + QString::number(dirId % 300) ); - writer.writeEndElement(); - - writer.writeEndElement(); - } - - writer.writeEndElement(); - - aDate = QDateTime::currentDateTime(); - // -- feed the scanner in batch mode - buffer->seek( 0 ); - importAndWait( buffer ); - - qDebug() << "performance test secs:"<< aDate.secsTo( QDateTime::currentDateTime() ); - - QVERIFY( aDate.secsTo( QDateTime::currentDateTime() ) < 120 ); - - // -- get all tracks - Collections::SqlQueryMaker *qm = static_cast< Collections::SqlQueryMaker* >( m_collection->queryMaker() ); - qm->setQueryType( Collections::QueryMaker::Track ); - qm->setBlocking( true ); - qm->run(); - Meta::TrackList tracks = qm->tracks(); - delete qm; - - for( int i = 0; i < trackCount; i++ ) - { - Meta::TrackPtr track = m_collection->registry()->getTrackFromUid( m_collection->uidUrlProtocol() + "://uid" + QString::number(i) ); - QVERIFY( track ); - } - - qDebug() << "performance test secs:"<< aDate.secsTo( QDateTime::currentDateTime() ) << "tracks:" << trackCount; - QCOMPARE( tracks.count(), trackCount ); - - // -- scan the input a second time. that should be a lot faster (but currently isn't) - aDate = QDateTime::currentDateTime(); - // -- feed the scanner in batch mode - buffer = new QBuffer(&byteArray); // the old scanner deleted the old buffer. - buffer->open(QIODevice::ReadWrite); - importAndWait( buffer ); - - qDebug() << "performance test secs:"<< aDate.secsTo( QDateTime::currentDateTime() ); - - QVERIFY( aDate.secsTo( QDateTime::currentDateTime() ) < 80 ); -} - -void -TestSqlScanManager::testIdentifyCompilationInMultipleDirectories() -{ - // Compilations where each is track is from a different artist - // are often stored as one track per directory, e.g. - // /artistA/compilation/track1 - // /artistB/compilation/track2 - // - // this is how Amarok 1 (after using Organize Collection) and iTunes are storing - // these albums on disc - // the bad thing is that Amarok 1 (as far as I know) didn't set the id3 tags - - Meta::FieldHash values; - - values.insert( Meta::valUniqueId, QVariant("5ef9fede5b3f98deb088b33428b0398e") ); - values.insert( Meta::valUrl, QVariant("Kenny Loggins/Top Gun/Top Gun - 01 - Kenny Loggins - Danger Zone.mp3") ); - values.insert( Meta::valFormat, QVariant("1") ); - values.insert( Meta::valTitle, QVariant("Danger Zone") ); - values.insert( Meta::valArtist, QVariant("Kenny Loggins") ); - values.insert( Meta::valAlbum, QVariant("Top Gun") ); - values.insert( Meta::valTrackNr, QVariant("1") ); - createTrack( values ); - - values.clear(); - values.insert( Meta::valUniqueId, QVariant("3e3970f52b0eda3f2a8c1b3a8c8d39ea") ); - values.insert( Meta::valUrl, QVariant("Cheap Trick/Top Gun/Top Gun - 02 - Cheap Trick - Mighty Wings.mp3") ); - values.insert( Meta::valTitle, QVariant("Mighty Wings") ); - values.insert( Meta::valArtist, QVariant("Cheap Trick") ); - values.insert( Meta::valAlbum, QVariant("Top Gun") ); - createTrack( values ); - - values.clear(); - values.insert( Meta::valUniqueId, QVariant("6ea0bbd97ad8068df58ad75a81f271f7") ); - values.insert( Meta::valUrl, QVariant("Kenny Loggins/Top Gun/Top Gun - 03 - Kenny Loggins - Playing With The Boys.mp3") ); - values.insert( Meta::valTitle, QVariant("Playing With The Boys") ); - values.insert( Meta::valArtist, QVariant("Kenny Loggins") ); - values.insert( Meta::valAlbum, QVariant("Top Gun") ); - createTrack( values ); - - values.clear(); - values.insert( Meta::valUniqueId, QVariant("f3ac2e15288361d779a0ae813a2018ba") ); - values.insert( Meta::valUrl, QVariant("Teena Marie/Top Gun/Top Gun - 04 - Teena Marie - Lead Me On.mp3") ); - values.insert( Meta::valTitle, QVariant("Lead Me On") ); - values.insert( Meta::valArtist, QVariant("Teena Marie") ); - values.insert( Meta::valAlbum, QVariant("Top Gun") ); - createTrack( values ); - - fullScanAndWait(); - - // -- check the commit - Meta::AlbumPtr album = m_collection->registry()->getAlbum( "Top Gun", QString() ); - QVERIFY( album ); - QCOMPARE( album->name(), QString("Top Gun") ); - QCOMPARE( album->tracks().count(), 4 ); - QVERIFY( album->isCompilation() ); -} - -void -TestSqlScanManager::testAlbumArtistMerges() -{ - // three tracks with the same artist but different album artist. - // (one is unset) - // Those should end up in different albums. - - Meta::FieldHash values; - - values.insert( Meta::valUniqueId, QVariant("1ef9fede5b3f98deb088b33428b0398e") ); - values.insert( Meta::valUrl, QVariant("test1/song1.mp3") ); - values.insert( Meta::valTitle, QVariant("title1") ); - values.insert( Meta::valArtist, QVariant("artist") ); - values.insert( Meta::valAlbumArtist, QVariant("albumArtist1") ); - values.insert( Meta::valAlbum, QVariant("test1") ); - createTrack( values ); - - values.clear(); - values.insert( Meta::valUniqueId, QVariant("2ef9fede5b3f98deb088b33428b0398b") ); - values.insert( Meta::valUrl, QVariant("test1/song2.mp3") ); - values.insert( Meta::valTitle, QVariant("title2") ); - values.insert( Meta::valArtist, QVariant("artist") ); - values.insert( Meta::valAlbumArtist, QVariant("albumArtist2") ); - values.insert( Meta::valAlbum, QVariant("test1") ); - createTrack( values ); - - values.clear(); - values.insert( Meta::valUniqueId, QVariant("3ef9fede5b3f98deb088b33428b0398c") ); - values.insert( Meta::valUrl, QVariant("test1/song3.mp3") ); - values.insert( Meta::valTitle, QVariant("title3") ); - values.insert( Meta::valArtist, QVariant("artist") ); - values.insert( Meta::valAlbum, QVariant("test1") ); - createTrack( values ); - - fullScanAndWait(); - - // -- check the commit - Meta::AlbumPtr album; - - album = m_collection->registry()->getAlbum( "test1", QString() ); - QVERIFY( album ); - QCOMPARE( album->name(), QString("test1") ); - QCOMPARE( album->tracks().count(), 1 ); - QVERIFY( album->isCompilation() ); - - album = m_collection->registry()->getAlbum( "test1", QString("albumArtist1") ); - QVERIFY( album ); - QCOMPARE( album->name(), QString("test1") ); - QCOMPARE( album->tracks().count(), 1 ); - QVERIFY( !album->isCompilation() ); - - album = m_collection->registry()->getAlbum( "test1", QString("albumArtist2") ); - QVERIFY( album ); - QCOMPARE( album->name(), QString("test1") ); - QCOMPARE( album->tracks().count(), 1 ); - QVERIFY( !album->isCompilation() ); -} - -void -TestSqlScanManager::testCrossRenaming() -{ - createAlbum(); - - // we use the created and first played attributes for identifying the moved tracks. - // currently those are not written back to the track - - Meta::AlbumPtr album; - Meta::TrackPtr track; - - fullScanAndWait(); - - // -- check the commit - album = m_collection->registry()->getAlbum( "Thriller", "Michael Jackson" ); - QVERIFY( album ); - QCOMPARE( album->tracks().count(), 9 ); - QVERIFY( !album->isCompilation() ); - - // --- cross-rename two track - track = album->tracks().at( 0 ); - static_cast(track.data())->setRating( 1 ); - QString path1 = track->playableUrl().path(); - - track = album->tracks().at( 1 ); - static_cast(track.data())->setRating( 2 ); - QString path2 = track->playableUrl().path(); - - QString targetPath = m_tmpCollectionDir->name() + "moved.mp3"; - QVERIFY( QFile::rename( path2, targetPath ) ); - QVERIFY( QFile::rename( path1, path2 ) ); - QVERIFY( QFile::rename( targetPath, path1 ) ); - - fullScanAndWait(); - - // -- check that the tracks are moved correctly - album = m_collection->registry()->getAlbum( "Thriller", "Michael Jackson" ); - QVERIFY( album ); - QCOMPARE( album->tracks().count(), 9 ); - - track = album->tracks().at( 0 ); - QCOMPARE( track->statistics()->rating(), 1 ); - QCOMPARE( track->playableUrl().path(), path2 ); - - track = album->tracks().at( 1 ); - QCOMPARE( track->statistics()->rating(), 2 ); - QCOMPARE( track->playableUrl().path(), path1 ); -} - - -void -TestSqlScanManager::slotCollectionUpdated() -{ - m_collectionUpdatedCount++; -} - -void -TestSqlScanManager::fullScanAndWait() -{ - QScopedPointer csc( m_collection->create()); - if( csc ) - { - csc->startFullScan(); - waitScannerFinished(); - } -} - -void -TestSqlScanManager::incrementalScanAndWait() -{ - // incremental scans use the modification time of the file system. - // this time is only in seconds, so to be sure that the incremental scan - // works we need to wait at least one second. - QTest::qWait( 1000 ); - - QScopedPointer csc( m_collection->create()); - if( csc ) - csc->startIncrementalScan(); - - waitScannerFinished(); -} - -void -TestSqlScanManager::importAndWait( QIODevice* input ) -{ - QScopedPointer csc( m_collection->create()); - if( csc ) - csc->import( input, 0 ); - - waitScannerFinished(); -} - -void -TestSqlScanManager::waitScannerFinished() -{ - QVERIFY( m_scanManager->isRunning() ); - QSignalSpy succeedSpy( m_scanManager, SIGNAL(succeeded()) ); - QSignalSpy failSpy( m_scanManager, SIGNAL(failed(QString)) ); - - // connect the result signal *after* the spies to ensure they are updated first - connect( m_scanManager, SIGNAL(succeeded()), this, SIGNAL(scanManagerResult()) ); - connect( m_scanManager, SIGNAL(failed(QString)), this, SIGNAL(scanManagerResult())); - const bool ok = QTest::kWaitForSignal( this, SIGNAL(scanManagerResult()), 60*1000 ); - disconnect( m_scanManager, SIGNAL(succeeded()), this, SIGNAL(scanManagerResult()) ); - disconnect( m_scanManager, SIGNAL(failed(QString)), this, SIGNAL(scanManagerResult()) ); - QVERIFY2( ok, "Scan Manager timed out without a result" ); - - if( failSpy.count() > 0 ) - { - QStringList errors; - foreach( const QList &arguments, static_cast > >( failSpy ) ) - errors << arguments.value( 0 ).toString(); - // this will fire each time: - qWarning() << "ScanManager failed with an error:" << errors.join( ", " ); - } - QCOMPARE( qMakePair( succeedSpy.count(), failSpy.count() ), qMakePair( 1, 0 ) ); - - QVERIFY( !m_scanManager->isRunning() ); -} - -void -TestSqlScanManager::createTrack( const Meta::FieldHash &values ) -{ - // -- copy the file from our original - QVERIFY( values.contains( Meta::valUrl ) ); - const QString targetPath = m_tmpCollectionDir->name() + values.value( Meta::valUrl ).toString(); - QVERIFY( QDir( m_tmpCollectionDir->name() ).mkpath( QFileInfo( values.value( Meta::valUrl ).toString() ).path() ) ); - - QVERIFY( QFile::copy( m_sourcePath, targetPath ) ); - - // -- set all the values that we need - Meta::Tag::writeTags( targetPath, values, true ); -} - -void -TestSqlScanManager::createSingleTrack() -{ - Meta::FieldHash values; - - values.insert( Meta::valUniqueId, QVariant("794b1bd040d5dd9b5b45c1494d84cc82") ); - values.insert( Meta::valUrl, QVariant("Various Artists/Big Screen Adventures/28 - Theme From Armageddon.mp3") ); - values.insert( Meta::valFormat, QVariant("1") ); - values.insert( Meta::valTitle, QVariant("Theme From Armageddon") ); - values.insert( Meta::valArtist, QVariant("Soundtrack & Theme Orchestra") ); - values.insert( Meta::valAlbumArtist, QVariant("Theme Orchestra") ); - values.insert( Meta::valAlbum, QVariant("Big Screen Adventures") ); - values.insert( Meta::valComposer, QVariant("Unknown Composer") ); - values.insert( Meta::valComment, QVariant("Amazon.com Song ID: 210541237") ); - values.insert( Meta::valGenre, QVariant("Broadway & Vocalists") ); - values.insert( Meta::valYear, QVariant(2009) ); - values.insert( Meta::valTrackNr, QVariant(28) ); - // values.insert( Meta::valBitrate, QVariant(216) ); // the bitrate can not be set. it's computed - // values.insert( Meta::valLength, QVariant(184000) ); // also can't be set - // values.insert( Meta::valSamplerate, QVariant(44100) ); // again - // values.insert( Meta::valFilesize, QVariant(5094892) ); // again - values.insert( Meta::valScore, QVariant(0.875) ); - values.insert( Meta::valPlaycount, QVariant(5) ); - // TODO: set an embedded cover - - createTrack( values ); -} - -void -TestSqlScanManager::createAlbum() -{ - Meta::FieldHash values; - - values.insert( Meta::valUniqueId, QVariant("1dc7022c52a3e4c51b46577da9b3c8ff") ); - values.insert( Meta::valUrl, QVariant("Pop/Thriller/Thriller - 01 - Michael Jackson - Track01.mp3") ); - values.insert( Meta::valTitle, QVariant("Wanna Be Startin' Somethin'") ); - values.insert( Meta::valArtist, QVariant("Michael Jackson") ); - values.insert( Meta::valAlbum, QVariant("Thriller") ); - values.insert( Meta::valYear, QVariant(1982) ); - values.insert( Meta::valTrackNr, QVariant(1) ); - createTrack( values ); - - values.clear(); - values.insert( Meta::valUniqueId, QVariant("1dc708934a3e4c51b46577da9b3ab11") ); - values.insert( Meta::valUrl, QVariant("Pop/Thriller/Thriller - 02 - Michael Jackson - Track02.mp3") ); - values.insert( Meta::valTitle, QVariant("Baby Be Mine") ); - values.insert( Meta::valArtist, QVariant("Michael Jackson") ); - values.insert( Meta::valAlbum, QVariant("Thriller") ); - values.insert( Meta::valYear, QVariant(1982) ); - values.insert( Meta::valTrackNr, QVariant(2) ); - createTrack( values ); - - values.clear(); - values.insert( Meta::valUniqueId, QVariant("15a6b1bf79747fdc8e9c6b6f06203017") ); - values.insert( Meta::valUrl, QVariant("Pop/Thriller/Thriller - 03 - Michael Jackson - Track03.mp3") ); - values.insert( Meta::valTitle, QVariant("The Girl Is Mine") ); - values.insert( Meta::valArtist, QVariant("Michael Jackson") ); - values.insert( Meta::valAlbum, QVariant("Thriller") ); - values.insert( Meta::valYear, QVariant(1982) ); - values.insert( Meta::valTrackNr, QVariant(3) ); - createTrack( values ); - - values.clear(); - values.insert( Meta::valUniqueId, QVariant("4aba4c8b1d1893c03c112cc3c01221e9") ); - values.insert( Meta::valUrl, QVariant("Pop/Thriller/Thriller - 04 - Michael Jackson - Track04.mp3") ); - values.insert( Meta::valTitle, QVariant("Thriller") ); - values.insert( Meta::valArtist, QVariant("Michael Jackson") ); - values.insert( Meta::valAlbum, QVariant("Thriller") ); - values.insert( Meta::valYear, QVariant(1982) ); - values.insert( Meta::valTrackNr, QVariant(4) ); - createTrack( values ); - - values.clear(); - values.insert( Meta::valUniqueId, QVariant("cb44d2a3d8053829b04672723bf0bd6e") ); - values.insert( Meta::valUrl, QVariant("Pop/Thriller/Thriller - 05 - Michael Jackson - Track05.mp3") ); - values.insert( Meta::valTitle, QVariant("Beat It") ); - values.insert( Meta::valArtist, QVariant("Michael Jackson") ); - values.insert( Meta::valAlbum, QVariant("Thriller") ); - values.insert( Meta::valYear, QVariant(1982) ); - values.insert( Meta::valTrackNr, QVariant(5) ); - createTrack( values ); - - values.clear(); - values.insert( Meta::valUniqueId, QVariant("eba1858eeeb3c6d97fe3385200114d86") ); - values.insert( Meta::valUrl, QVariant("Pop/Thriller/Thriller - 06 - Michael Jackson - Track06.mp3") ); - values.insert( Meta::valTitle, QVariant("Billy Jean") ); - values.insert( Meta::valArtist, QVariant("Michael Jackson") ); - values.insert( Meta::valAlbum, QVariant("Thriller") ); - values.insert( Meta::valYear, QVariant(1982) ); - values.insert( Meta::valTrackNr, QVariant(6) ); - createTrack( values ); - - values.clear(); - values.insert( Meta::valUniqueId, QVariant("4623850290998486b0f7b39a2719904e") ); - values.insert( Meta::valUrl, QVariant("Pop/Thriller/Thriller - 07 - Michael Jackson - Track07.mp3") ); - values.insert( Meta::valTitle, QVariant("Human Nature") ); - values.insert( Meta::valArtist, QVariant("Michael Jackson") ); - values.insert( Meta::valAlbum, QVariant("Thriller") ); - values.insert( Meta::valYear, QVariant(1982) ); - values.insert( Meta::valTrackNr, QVariant(7) ); - createTrack( values ); - - values.clear(); - values.insert( Meta::valUniqueId, QVariant("6d9a7de13af1e16bb13a6208e44b046d") ); - values.insert( Meta::valUrl, QVariant("Pop/Thriller/Thriller - 08 - Michael Jackson - Track08.mp3") ); - values.insert( Meta::valTitle, QVariant("P.Y.T. (Pretty Young Thing)") ); - values.insert( Meta::valArtist, QVariant("Michael Jackson") ); - values.insert( Meta::valAlbum, QVariant("Thriller") ); - values.insert( Meta::valYear, QVariant(1982) ); - values.insert( Meta::valTrackNr, QVariant(8) ); - createTrack( values ); - - values.clear(); - values.insert( Meta::valUniqueId, QVariant("91cf9a7c0d255399f9f6babfacae432b") ); - values.insert( Meta::valUrl, QVariant("Pop/Thriller/Thriller - 09 - Michael Jackson - Track09.mp3") ); - values.insert( Meta::valTitle, QVariant("The Lady In My Life") ); - values.insert( Meta::valArtist, QVariant("Michael Jackson") ); - values.insert( Meta::valAlbum, QVariant("Thriller") ); - values.insert( Meta::valYear, QVariant(1982) ); - values.insert( Meta::valTrackNr, QVariant(9) ); - createTrack( values ); -} - -void -TestSqlScanManager::createCompilation() -{ - // a compilation without the compilation flags values.insert( Meta::valCompilation, QVariant(true) ); - Meta::FieldHash values; - - values.insert( Meta::valUniqueId, QVariant("5ef9fede5b3f98deb088b33428b0398e") ); - values.insert( Meta::valUrl, QVariant("Top Gun/Top Gun - 01 - Kenny Loggins - Danger Zone.mp3") ); - values.insert( Meta::valFormat, QVariant("1") ); - values.insert( Meta::valTitle, QVariant("Danger Zone") ); - values.insert( Meta::valArtist, QVariant("Kenny Loggins") ); - values.insert( Meta::valAlbum, QVariant("Top Gun") ); - createTrack( values ); - - values.clear(); - values.insert( Meta::valUniqueId, QVariant("3e3970f52b0eda3f2a8c1b3a8c8d39ea") ); - values.insert( Meta::valUrl, QVariant("Top Gun/Top Gun - 02 - Cheap Trick - Mighty Wings.mp3") ); - values.insert( Meta::valTitle, QVariant("Mighty Wings") ); - values.insert( Meta::valArtist, QVariant("Cheap Trick") ); - values.insert( Meta::valAlbum, QVariant("Top Gun") ); - createTrack( values ); - - values.clear(); - values.insert( Meta::valUniqueId, QVariant("6ea0bbd97ad8068df58ad75a81f271f7") ); - values.insert( Meta::valUrl, QVariant("Top Gun/Top Gun - 03 - Kenny Loggins - Playing With The Boys.mp3") ); - values.insert( Meta::valTitle, QVariant("Playing With The Boys") ); - values.insert( Meta::valArtist, QVariant("Kenny Loggins") ); - values.insert( Meta::valAlbum, QVariant("Top Gun") ); - createTrack( values ); - - values.clear(); - values.insert( Meta::valUniqueId, QVariant("f3ac2e15288361d779a0ae813a2018ba") ); - values.insert( Meta::valUrl, QVariant("Top Gun/Top Gun - 04 - Teena Marie - Lead Me On.mp3") ); - values.insert( Meta::valTitle, QVariant("Lead Me On") ); - values.insert( Meta::valArtist, QVariant("Teena Marie") ); - values.insert( Meta::valAlbum, QVariant("Top Gun") ); - createTrack( values ); - - values.clear(); - values.insert( Meta::valUniqueId, QVariant("ffe2bb3e6e2f698983c95e40937545ff") ); - values.insert( Meta::valUrl, QVariant("Top Gun/Top Gun - 05 - Berlin - Take My Breath Away (Love Theme From _Top Gun_).mp3") ); - values.insert( Meta::valTitle, QVariant("Take My Breath Away (Love Theme From "Top Gun")") ); - values.insert( Meta::valArtist, QVariant("Berlin") ); - values.insert( Meta::valAlbum, QVariant("Top Gun") ); - createTrack( values ); - - values.clear(); - values.insert( Meta::valUniqueId, QVariant("c871dba16f92483898bcd6a1ed1bc14f") ); - values.insert( Meta::valUrl, QVariant("Top Gun/Top Gun - 06 - Miami Sound Machine - Hot Summer Nights.mp3") ); - values.insert( Meta::valTitle, QVariant("Hot Summer Nights") ); - values.insert( Meta::valArtist, QVariant("Miami Sound Machine") ); - values.insert( Meta::valAlbum, QVariant("Top Gun") ); - createTrack( values ); - - values.clear(); - values.insert( Meta::valUniqueId, QVariant("80d157c36ed334192ed8df4c01bf0d4e") ); - values.insert( Meta::valUrl, QVariant("Top Gun/Top Gun - 07 - Loverboy - Heaven In Your Eyes.mp3") ); - values.insert( Meta::valTitle, QVariant("Heaven In Your Eyes") ); - values.insert( Meta::valArtist, QVariant("Loverboy") ); - values.insert( Meta::valAlbum, QVariant("Top Gun") ); - createTrack( values ); - - values.clear(); - values.insert( Meta::valUniqueId, QVariant("1fe5897cdea860348c3a5eb40d47c382") ); - values.insert( Meta::valUrl, QVariant("Top Gun/Top Gun - 08 - Larry Greene - Through The Fire.mp3") ); - values.insert( Meta::valTitle, QVariant("Through The Fire") ); - values.insert( Meta::valArtist, QVariant("Larry Greene") ); - values.insert( Meta::valAlbum, QVariant("Top Gun") ); - createTrack( values ); - - values.clear(); - values.insert( Meta::valUniqueId, QVariant("e0eacff604bfe38b5c275b45aa4f5323") ); - values.insert( Meta::valUrl, QVariant("Top Gun/Top Gun - 09 - Marietta - Destination Unknown.mp3") ); - values.insert( Meta::valTitle, QVariant("Destination Unknown") ); - values.insert( Meta::valArtist, QVariant("Marietta") ); - values.insert( Meta::valAlbum, QVariant("Top Gun") ); - createTrack( values ); - - values.clear(); - values.insert( Meta::valUniqueId, QVariant("9f1b00dab2df7537b6c5b2be9f08b220") ); - values.insert( Meta::valUrl, QVariant("Top Gun/Top Gun - 10 - Harold Faltermeyer & Steve Stevens - Top Gun Anthem.mp3") ); - values.insert( Meta::valTitle, QVariant("Top Gun Anthem") ); - values.insert( Meta::valArtist, QVariant("Harold Faltermeyer & Steve Stevens") ); - values.insert( Meta::valAlbum, QVariant("Top Gun") ); - createTrack( values ); -} - -void -TestSqlScanManager::createCompilationLookAlikeAlbum() -{ - Meta::FieldHash values; - - // Some systems have problems with the umlauts in the file names. - // That is the case where the system encoding when compiling does not - // match the one of the file system. - // the following is the original filename - // values.insert( Meta::valUrl, QVariant( "Glen Hansard & Markéta Irglová/Once/01 Glen Hansard & Markéta Irglová - Falling Slowly.mp3" ) ); - - values.insert( Meta::valUniqueId, QVariant( "8375aa24e0e0434ca0c36e382b6f188c" ) ); - values.insert( Meta::valUrl, QVariant( "Glen Hansard & Marketa Irglova/Once/01 Glen Hansard & Marketa Irglova - Falling Slowly.mp3" ) ); - values.insert( Meta::valFormat, QVariant( "1" ) ); - values.insert( Meta::valTitle, QVariant( "Falling Slowly" ) ); - values.insert( Meta::valArtist, QVariant( "Glen Hansard & Markéta Irglová" ) ); - values.insert( Meta::valAlbum, QVariant( "Once" ) ); - values.insert( Meta::valAlbumArtist, QVariant( "Glen Hansard & Markéta Irglová" ) ); - values.insert( Meta::valTrackNr, QVariant( "1" ) ); - createTrack( values ); - - values.insert( Meta::valUniqueId, QVariant( "ff3f82b1c2e1434d9d1a7b6aec67ac9c" ) ); - values.insert( Meta::valUrl, QVariant( "Glen Hansard & Marketa Irglova/Once/02 Glen Hansard & Marketa Irglova - If You Want Me.mp3" ) ); - values.insert( Meta::valFormat, QVariant( "1" ) ); - values.insert( Meta::valTitle, QVariant( "If You Want Me" ) ); - values.insert( Meta::valArtist, QVariant( "Glen Hansard & Markéta Irglová" ) ); - values.insert( Meta::valAlbum, QVariant( "Once" ) ); - values.insert( Meta::valAlbumArtist, QVariant( "Glen Hansard & Markéta Irglová" ) ); - values.insert( Meta::valTrackNr, QVariant( "2" ) ); - createTrack( values ); - - values.insert( Meta::valUniqueId, QVariant( "8fb2396f8d974f6196d2b2ef93ba2551" ) ); - values.insert( Meta::valUrl, QVariant( "Glen Hansard & Marketa Irglova/Once/03 Glen Hansard - Broken Hearted Hoover Fixer Sucker Guy.mp3" ) ); - values.insert( Meta::valFormat, QVariant( "1" ) ); - values.insert( Meta::valTitle, QVariant( "Broken Hearted Hoover Fixer Sucker Guy" ) ); - values.insert( Meta::valArtist, QVariant( "Glen Hansard" ) ); - values.insert( Meta::valAlbum, QVariant( "Once" ) ); - values.insert( Meta::valAlbumArtist, QVariant( "Glen Hansard & Markéta Irglová" ) ); - values.insert( Meta::valTrackNr, QVariant( "3" ) ); - createTrack( values ); - - values.insert( Meta::valUniqueId, QVariant( "3a211546b91c4bf7a4ec9d41325e5a01" ) ); - values.insert( Meta::valUrl, QVariant( "Glen Hansard & Marketa Irglova/Once/04 Glen Hansard & Marketa Irglova - When Your Mind's Made Up.mp3" ) ); - values.insert( Meta::valFormat, QVariant( "1" ) ); - values.insert( Meta::valTitle, QVariant( "When Your Mind's Made Up" ) ); - values.insert( Meta::valArtist, QVariant( "Glen Hansard & Markéta Irglová" ) ); - values.insert( Meta::valAlbum, QVariant( "Once" ) ); - values.insert( Meta::valAlbumArtist, QVariant( "Glen Hansard & Markéta Irglová" ) ); - values.insert( Meta::valTrackNr, QVariant( "4" ) ); - createTrack( values ); - - values.insert( Meta::valUniqueId, QVariant( "e7a1ed52777c437582a217cd29cc35f7" ) ); - values.insert( Meta::valUrl, QVariant( "Glen Hansard & Marketa Irglova/Once/05 Glen Hansard - Lies.mp3" ) ); - values.insert( Meta::valFormat, QVariant( "1" ) ); - values.insert( Meta::valTitle, QVariant( "Lies" ) ); - values.insert( Meta::valArtist, QVariant( "Glen Hansard" ) ); - values.insert( Meta::valAlbum, QVariant( "Once" ) ); - values.insert( Meta::valAlbumArtist, QVariant( "Glen Hansard & Markéta Irglová" ) ); - values.insert( Meta::valTrackNr, QVariant( "5" ) ); - createTrack( values ); - - values.insert( Meta::valUniqueId, QVariant( "e0c88a85884d40c899522cd733718d9e" ) ); - values.insert( Meta::valUrl, QVariant( "Glen Hansard & Marketa Irglova/Once/06 Interference - Gold.mp3" ) ); - values.insert( Meta::valFormat, QVariant( "1" ) ); - values.insert( Meta::valTitle, QVariant( "Gold" ) ); - values.insert( Meta::valArtist, QVariant( "Interference" ) ); - values.insert( Meta::valAlbum, QVariant( "Once" ) ); - values.insert( Meta::valAlbumArtist, QVariant( "Glen Hansard & Markéta Irglová" ) ); - values.insert( Meta::valTrackNr, QVariant( "6" ) ); - createTrack( values ); - - values.insert( Meta::valUniqueId, QVariant( "0969ea6128444e128cfcac95207bd525" ) ); - values.insert( Meta::valUrl, QVariant( "Glen Hansard & Marketa Irglova/Once/07 Marketa Irglova - The Hill.mp3" ) ); - values.insert( Meta::valFormat, QVariant( "1" ) ); - values.insert( Meta::valTitle, QVariant( "The Hill" ) ); - values.insert( Meta::valArtist, QVariant( "Markéta Irglová" ) ); - values.insert( Meta::valAlbum, QVariant( "Once" ) ); - values.insert( Meta::valAlbumArtist, QVariant( "Glen Hansard & Markéta Irglová" ) ); - values.insert( Meta::valTrackNr, QVariant( "7" ) ); - createTrack( values ); - - values.insert( Meta::valUniqueId, QVariant( "c1d6eff3cb6c42eaa0d63e186ef1b749" ) ); - values.insert( Meta::valUrl, QVariant( "Glen Hansard & Marketa Irglova/Once/08 Glen Hansard - Fallen From the Sky.mp3" ) ); - values.insert( Meta::valFormat, QVariant( "1" ) ); - values.insert( Meta::valTitle, QVariant( "Fallen From the Sky" ) ); - values.insert( Meta::valArtist, QVariant( "Glen Hansard" ) ); - values.insert( Meta::valAlbum, QVariant( "Once" ) ); - values.insert( Meta::valAlbumArtist, QVariant( "Glen Hansard & Markéta Irglová" ) ); - values.insert( Meta::valTrackNr, QVariant( "8" ) ); - createTrack( values ); - - values.insert( Meta::valUniqueId, QVariant( "b6611dbccd0e49bca8db5dc598b7bf4f" ) ); - values.insert( Meta::valUrl, QVariant( "Glen Hansard & Marketa Irglova/Once/09 Glen Hansard - Leave.mp3" ) ); - values.insert( Meta::valFormat, QVariant( "1" ) ); - values.insert( Meta::valTitle, QVariant( "Leave" ) ); - values.insert( Meta::valArtist, QVariant( "Glen Hansard" ) ); - values.insert( Meta::valAlbum, QVariant( "Once" ) ); - values.insert( Meta::valAlbumArtist, QVariant( "Glen Hansard & Markéta Irglová" ) ); - values.insert( Meta::valTrackNr, QVariant( "9" ) ); - createTrack( values ); - - values.insert( Meta::valUniqueId, QVariant( "46873076087f48dda553fc5ebd3c0fb6" ) ); - values.insert( Meta::valUrl, QVariant( "Glen Hansard & Marketa Irglova/Once/10 Glen Hansard - Trying to Pull Myself Away.mp3" ) ); - values.insert( Meta::valFormat, QVariant( "1" ) ); - values.insert( Meta::valTitle, QVariant( "Trying to Pull Myself Away" ) ); - values.insert( Meta::valArtist, QVariant( "Glen Hansard" ) ); - values.insert( Meta::valAlbum, QVariant( "Once" ) ); - values.insert( Meta::valAlbumArtist, QVariant( "Glen Hansard & Markéta Irglová" ) ); - values.insert( Meta::valTrackNr, QVariant( "10" ) ); - createTrack( values ); - - values.insert( Meta::valUniqueId, QVariant( "ea29de7b131c4cf28df177a8cda990ee" ) ); - values.insert( Meta::valUrl, QVariant( "Glen Hansard & Marketa Irglova/Once/11 Glen Hansard - All the Way Down.mp3" ) ); - values.insert( Meta::valFormat, QVariant( "1" ) ); - values.insert( Meta::valTitle, QVariant( "All the Way Down" ) ); - values.insert( Meta::valArtist, QVariant( "Glen Hansard" ) ); - values.insert( Meta::valAlbum, QVariant( "Once" ) ); - values.insert( Meta::valAlbumArtist, QVariant( "Glen Hansard & Markéta Irglová" ) ); - values.insert( Meta::valTrackNr, QVariant( "11" ) ); - createTrack( values ); - - values.insert( Meta::valUniqueId, QVariant( "66259801d8ba4d50a2dfdf0129bc8792" ) ); - values.insert( Meta::valUrl, QVariant( "Glen Hansard & Marketa Irglova/Once/12 Glen Hansard & Marketa Irglova - Once.mp3" ) ); - values.insert( Meta::valFormat, QVariant( "1" ) ); - values.insert( Meta::valTitle, QVariant( "Once" ) ); - values.insert( Meta::valArtist, QVariant( "Glen Hansard & Markéta Irglová" ) ); - values.insert( Meta::valAlbum, QVariant( "Once" ) ); - values.insert( Meta::valAlbumArtist, QVariant( "Glen Hansard & Markéta Irglová" ) ); - values.insert( Meta::valTrackNr, QVariant( "12" ) ); - createTrack( values ); - - values.insert( Meta::valUniqueId, QVariant( "a654e8c5afb14de7b55b6548ac02f724" ) ); - values.insert( Meta::valUrl, QVariant( "Glen Hansard & Marketa Irglova/Once/13 Glen Hansard - Say It to Me Now.mp3" ) ); - values.insert( Meta::valFormat, QVariant( "1" ) ); - values.insert( Meta::valTitle, QVariant( "Say It to Me Now" ) ); - values.insert( Meta::valArtist, QVariant( "Glen Hansard" ) ); - values.insert( Meta::valAlbum, QVariant( "Once" ) ); - values.insert( Meta::valAlbumArtist, QVariant( "Glen Hansard & Markéta Irglová" ) ); - values.insert( Meta::valTrackNr, QVariant( "13" ) ); - createTrack( values ); -} - -void -TestSqlScanManager::createCompilationTrack() -{ - Meta::FieldHash values; - - values.insert( Meta::valUniqueId, QVariant("c6c29f50279ab9523a0f44928bc1e96b") ); - values.insert( Meta::valUrl, QVariant("Amazon MP3/The Sum Of All Fears (O.S.T.)/The Sum of All Fears/01 - If We Could Remember (O.S.T. LP Version).mp3") ); - values.insert( Meta::valFormat, QVariant("1") ); - values.insert( Meta::valTitle, QVariant("If We Could Remember (O.S.T. LP Version)") ); - values.insert( Meta::valArtist, QVariant("The Sum Of All Fears (O.S.T.)/Yolanda Adams") ); - values.insert( Meta::valAlbumArtist, QVariant("The Sum Of All Fears (O.S.T.)") ); - values.insert( Meta::valAlbum, QVariant("The Sum of All Fears") ); - values.insert( Meta::valComment, QVariant("Amazon.com Song ID: 203452096") ); - values.insert( Meta::valGenre, QVariant("Soundtracks") ); - values.insert( Meta::valYear, QVariant("2002") ); - values.insert( Meta::valTrackNr, QVariant("1") ); - values.insert( Meta::valComposer, QVariant("Jerry Goldsmith") ); - values.insert( Meta::valScore, QVariant("0.875") ); - values.insert( Meta::valPlaycount, QVariant("6") ); - createTrack( values ); - - values.clear(); - values.insert( Meta::valUniqueId, QVariant("2188afd457cd75a363905f411966b9a0") ); - values.insert( Meta::valUrl, QVariant("The Cross Of Changes/01 - Second Chapter.mp3") ); - values.insert( Meta::valFormat, QVariant(1) ); - values.insert( Meta::valTitle, QVariant("Second Chapter") ); - values.insert( Meta::valArtist, QVariant("Enigma") ); - values.insert( Meta::valAlbumArtist, QVariant("Enigma") ); - values.insert( Meta::valAlbum, QVariant("The Cross Of Changes") ); - values.insert( Meta::valComment, QVariant("Amazon.com Song ID: 201985325") ); - values.insert( Meta::valGenre, QVariant("Pop") ); - values.insert( Meta::valYear, QVariant(2004) ); - values.insert( Meta::valTrackNr, QVariant(1) ); - values.insert( Meta::valComposer, QVariant("Curly M.C.") ); - values.insert( Meta::valScore, QVariant("0.54") ); - values.insert( Meta::valPlaycount, QVariant("2") ); - - values.insert( Meta::valUniqueId, QVariant("637bee4fd456d2ff9eafe65c71ba192e") ); - values.insert( Meta::valUrl, QVariant("The Cross Of Changes/02 - The Eyes Of Truth.mp3") ); - values.insert( Meta::valFormat, QVariant("1") ); - values.insert( Meta::valTitle, QVariant("The Eyes Of Truth") ); - values.insert( Meta::valArtist, QVariant("Enigma") ); - values.insert( Meta::valAlbumArtist, QVariant("Enigma") ); - values.insert( Meta::valAlbum, QVariant("The Cross Of Changes") ); - values.insert( Meta::valComment, QVariant("Amazon.com Song ID: 201985326") ); - values.insert( Meta::valGenre, QVariant("Pop") ); - values.insert( Meta::valYear, QVariant("2004") ); - values.insert( Meta::valTrackNr, QVariant("2") ); - values.insert( Meta::valComposer, QVariant("Curly M.C.") ); - values.insert( Meta::valScore, QVariant("0.928572") ); - values.insert( Meta::valPlaycount, QVariant("1286469632") ); - - values.insert( Meta::valUniqueId, QVariant("b4206da4bc0335d76c2bbc5d4c1b164c") ); - values.insert( Meta::valUrl, QVariant("The Cross Of Changes/03 - Return To Innocence.mp3") ); - values.insert( Meta::valFormat, QVariant("1") ); - values.insert( Meta::valTitle, QVariant("Return To Innocence") ); - values.insert( Meta::valArtist, QVariant("Enigma") ); - values.insert( Meta::valAlbumArtist, QVariant("Enigma") ); - values.insert( Meta::valAlbum, QVariant("The Cross Of Changes") ); - values.insert( Meta::valComment, QVariant("Amazon.com Song ID: 201985327") ); - values.insert( Meta::valGenre, QVariant("Pop") ); - values.insert( Meta::valYear, QVariant("2004") ); - values.insert( Meta::valTrackNr, QVariant("3") ); - values.insert( Meta::valComposer, QVariant("Curly M.C.") ); - values.insert( Meta::valScore, QVariant("0.75") ); - values.insert( Meta::valPlaycount, QVariant("1286469888") ); - - values.insert( Meta::valUniqueId, QVariant("eb0061602f52d67140fd465dc275fbf2") ); - values.insert( Meta::valUrl, QVariant("The Cross Of Changes/04 - I Love You...I'Ll Kill You.mp3") ); - values.insert( Meta::valFormat, 1 ); - values.insert( Meta::valTitle, QVariant("I Love You...I'Ll Kill You") ); - values.insert( Meta::valArtist, QVariant("Enigma") ); - values.insert( Meta::valAlbumArtist, QVariant("Enigma") ); - values.insert( Meta::valAlbum, QVariant("The Cross Of Changes") ); - values.insert( Meta::valComment, QVariant("Amazon.com Song ID: 201985328") ); - values.insert( Meta::valGenre, QVariant("Pop") ); - values.insert( Meta::valYear, QVariant(2004) ); - values.insert( Meta::valTrackNr, QVariant(4) ); - values.insert( Meta::valComposer, QVariant("Curly M.C.") ); - values.insert( Meta::valScore, QVariant(0.5) ); - values.insert( Meta::valPlaycount, QVariant(1286470656) ); - - values.insert( Meta::valUniqueId, QVariant("94dabc09509379646458f62bee7e41ed") ); - values.insert( Meta::valUrl, QVariant("The Cross Of Changes/05 - Silent Warrior.mp3") ); - values.insert( Meta::valFormat, 1 ); - values.insert( Meta::valTitle, QVariant("Silent Warrior") ); - values.insert( Meta::valArtist, QVariant("Enigma") ); - values.insert( Meta::valAlbumArtist, QVariant("Enigma") ); - values.insert( Meta::valAlbum, QVariant("The Cross Of Changes") ); - values.insert( Meta::valComment, QVariant("Amazon.com Song ID: 201985329") ); - values.insert( Meta::valGenre, QVariant("Pop") ); - values.insert( Meta::valYear, QVariant(2004) ); - values.insert( Meta::valTrackNr, QVariant(5) ); - values.insert( Meta::valComposer, QVariant("Curly M.C.") ); - values.insert( Meta::valScore, QVariant(0.96875) ); - values.insert( Meta::valPlaycount, QVariant(6) ); - - values.insert( Meta::valUniqueId, QVariant("6ae759476c34256ff1d06f0b5c964d75") ); - values.insert( Meta::valUrl, QVariant("The Cross Of Changes/06 - The Dream Of The Dolphin.mp3") ); - values.insert( Meta::valTitle, QVariant("The Dream Of The Dolphin") ); - values.insert( Meta::valArtist, QVariant("Enigma") ); - values.insert( Meta::valAlbumArtist, QVariant("Enigma") ); - values.insert( Meta::valAlbum, QVariant("The Cross Of Changes") ); - values.insert( Meta::valComment, QVariant("Amazon.com Song ID: 201985330") ); - values.insert( Meta::valGenre, QVariant("Pop") ); - values.insert( Meta::valYear, QVariant("2004") ); - values.insert( Meta::valTrackNr, QVariant(6) ); - values.insert( Meta::valComposer, QVariant("Curly M.C.") ); - values.insert( Meta::valScore, QVariant(0.5) ); - values.insert( Meta::valPlaycount, QVariant(2) ); - - values.insert( Meta::valUniqueId, QVariant("7957bc25521c1dc91351d497321c27a6") ); - values.insert( Meta::valUrl, QVariant("Amazon MP3/Ashford & Simpson/Solid/01 - Solid.mp3") ); - values.insert( Meta::valTitle, QVariant("Solid") ); - values.insert( Meta::valArtist, QVariant("Ashford & Simpson") ); - values.insert( Meta::valAlbumArtist, QVariant("Ashford & Simpson") ); - values.insert( Meta::valAlbum, QVariant("Solid") ); - values.insert( Meta::valComment, QVariant("Amazon.com Song ID: 202265871") ); - values.insert( Meta::valGenre, QVariant("Pop") ); - values.insert( Meta::valYear, QVariant(2007) ); - values.insert( Meta::valTrackNr, QVariant(1) ); - values.insert( Meta::valComposer, QVariant("Valerie Simpson") ); - values.insert( Meta::valRating, QVariant(0.898438) ); - values.insert( Meta::valScore, QVariant(0.875) ); - values.insert( Meta::valPlaycount, QVariant(12) ); -} - - diff --git a/amarok/tests/core-impl/collections/db/sql/TestSqlScanManager.h b/amarok/tests/core-impl/collections/db/sql/TestSqlScanManager.h deleted file mode 100644 index 7cb24709..00000000 --- a/amarok/tests/core-impl/collections/db/sql/TestSqlScanManager.h +++ /dev/null @@ -1,181 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Maximilian Kossick * - * Copyright (c) 2010, 2013 Ralf Engels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef TESTSQLSCANMANAGER_H -#define TESTSQLSCANMANAGER_H - -#include - -#include "core/meta/support/MetaConstants.h" - -#include - -class MySqlEmbeddedStorage; -class GenericScanManager; - -class QIODevice; - -namespace Collections { - class SqlCollection; -} - -/** Test the ScanManager, the SqlScanResultProcessor and the amarokcollectionscanner itself. - Note: currently this test is using the installed amarokcollectionscanner and not - the one from util/collectionscanner. - */ -class TestSqlScanManager : public QObject -{ - Q_OBJECT -public: - TestSqlScanManager(); - -signals: - void scanManagerResult(); - -private slots: - void initTestCase(); - void cleanupTestCase(); - - void init(); - void cleanup(); - /** - * Check that a single insert really inserts all the information - */ - void testScanSingle(); - - /** - * Check that fully scanning a directory works - */ - void testScanDirectory(); - - /** - * Check that duplicate uids are handled correctly - */ - void testDuplicateUid(); - - /** - * Check that very long uids don't produce wrong sql queries - */ - void testLongUid(); - - - /** - * Check that detecting compilations works - * Test also compilation/no compilation tags - */ - void testCompilation(); - - /** - * Check that a blocked scan really does nothing. - */ - void testBlock(); - - /** - * Test adding a whole directory (incremental scan) - */ - void testAddDirectory(); - - /** - * Test rescanning and detecting a removed directory (incremental) - */ - void testRemoveDir(); - - /** - * Test rescanning and detecting a removed track (incremental) - * Will also check that the statistics are not deleted. - */ - void testRemoveTrack(); - - /** - * Test rescanning and detecting a moved track or directory - */ - void testMove(); - - /** - * Test "feat" artist and albums - */ - void testFeat(); - - /** - * Test images - */ - void testAlbumImage();; - - /** - * Test merging of the result with an incremental scan. - * New files should be added to existing albums. - * Existing files should be merged. - */ - void testMerges(); - - void testLargeInsert(); - - void testIdentifyCompilationInMultipleDirectories(); - - void testUidChangeMoveDirectoryIncrementalScan(); - - /** Test that Amarok respects the album artist from the tags. - * (BR: 216759) - */ - void testAlbumArtistMerges(); - - /** Test that two tracks getting their filename exchanged are still - * handled correctly, ratings and all (BR: 272802) - */ - void testCrossRenaming(); - - void slotCollectionUpdated(); - -private: - void fullScanAndWait(); - void incrementalScanAndWait(); - void importAndWait( QIODevice* import ); - - void waitScannerFinished(); - - /** - Creates a track in the m_tmpCollectionDir with the given values. - Meta::valUrl gives the relative path to the target track. - */ - void createTrack( const Meta::FieldHash &values ); - void createSingleTrack(); - - /** Creates a default album. - Meaning that album artist tag is not set, all songs are in one directory and the artist is the same for all the tracks. - */ - void createAlbum(); - void createCompilation(); - void createCompilationTrack(); - - /** - * Album that looks alike compillation: various track's artists - * but single album artist and no compillation flag. - */ - void createCompilationLookAlikeAlbum(); - - int m_collectionUpdatedCount; - - MySqlEmbeddedStorage *m_storage; - KTempDir *m_tmpDatabaseDir; - KTempDir *m_tmpCollectionDir; - QString m_sourcePath; // the path to the template .mp3 file - - Collections::SqlCollection *m_collection; - GenericScanManager *m_scanManager; -}; - -#endif // TESTSQLSCANMANAGER_H diff --git a/amarok/tests/core-impl/collections/db/sql/TestSqlTrack.cpp b/amarok/tests/core-impl/collections/db/sql/TestSqlTrack.cpp deleted file mode 100644 index d2f7377c..00000000 --- a/amarok/tests/core-impl/collections/db/sql/TestSqlTrack.cpp +++ /dev/null @@ -1,560 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "TestSqlTrack.h" - -#include "DefaultSqlQueryMakerFactory.h" -#include "core/meta/Meta.h" -#include "core-impl/storage/sql/mysqlestorage/MySqlEmbeddedStorage.h" - -#include "SqlCollection.h" -#include "SqlMeta.h" -#include "SqlRegistry.h" -#include "SqlMountPointManagerMock.h" - -#include "MetaNotificationSpy.h" - -#include -#include - -#include - -QTEST_KDEMAIN_CORE( TestSqlTrack ) - -TestSqlTrack::TestSqlTrack() - : QObject() - , m_collection( 0 ) - , m_storage( 0 ) - , m_tmpDir( 0 ) -{ -} - -void -TestSqlTrack::initTestCase() -{ - m_tmpDir = new KTempDir(); - m_storage = new MySqlEmbeddedStorage(); - QVERIFY( m_storage->init( m_tmpDir->name() ) ); - m_collection = new Collections::SqlCollection( m_storage ); - m_collection->setMountPointManager( new SqlMountPointManagerMock( this, m_storage ) ); - - // I just need the table and not the whole playlist manager - m_storage->query( QString( "CREATE TABLE playlist_tracks (" - " id " + m_storage->idType() + - ", playlist_id INTEGER " - ", track_num INTEGER " - ", url " + m_storage->exactTextColumnType() + - ", title " + m_storage->textColumnType() + - ", album " + m_storage->textColumnType() + - ", artist " + m_storage->textColumnType() + - ", length INTEGER " - ", uniqueid " + m_storage->textColumnType(128) + ") ENGINE = MyISAM;" ) ); - -} - -void -TestSqlTrack::cleanupTestCase() -{ - delete m_collection; - //m_storage is deleted by SqlCollection - delete m_tmpDir; -} - -void -TestSqlTrack::init() -{ - //setup base data - m_storage->query( "INSERT INTO artists(id, name) VALUES (1, 'artist1');" ); - m_storage->query( "INSERT INTO artists(id, name) VALUES (2, 'artist2');" ); - m_storage->query( "INSERT INTO artists(id, name) VALUES (3, 'artist3');" ); - - m_storage->query( "INSERT INTO albums(id,name,artist) VALUES(1,'album1',1);" ); - m_storage->query( "INSERT INTO albums(id,name,artist) VALUES(2,'album2',1);" ); - m_storage->query( "INSERT INTO albums(id,name,artist) VALUES(3,'album3',2);" ); - m_storage->query( "INSERT INTO albums(id,name,artist) VALUES(4,'album-compilation',0);" ); - - m_storage->query( "INSERT INTO composers(id, name) VALUES (1, 'composer1');" ); - m_storage->query( "INSERT INTO composers(id, name) VALUES (2, 'composer2');" ); - m_storage->query( "INSERT INTO composers(id, name) VALUES (3, 'composer3');" ); - - m_storage->query( "INSERT INTO genres(id, name) VALUES (1, 'genre1');" ); - m_storage->query( "INSERT INTO genres(id, name) VALUES (2, 'genre2');" ); - m_storage->query( "INSERT INTO genres(id, name) VALUES (3, 'genre3');" ); - - m_storage->query( "INSERT INTO years(id, name) VALUES (1, '1');" ); - m_storage->query( "INSERT INTO years(id, name) VALUES (2, '2');" ); - m_storage->query( "INSERT INTO years(id, name) VALUES (3, '3');" ); - - m_storage->query( "INSERT INTO directories(id, deviceid, dir) VALUES (1, -1, './');" ); - - m_storage->query( "INSERT INTO urls(id, deviceid, rpath, directory, uniqueid) VALUES (1, -1, './IDoNotExist.mp3', 1, '1');" ); - m_storage->query( "INSERT INTO urls(id, deviceid, rpath, directory, uniqueid) VALUES (2, -1, './IDoNotExistAsWell.mp3', 1, '2');" ); - m_storage->query( "INSERT INTO urls(id, deviceid, rpath, directory, uniqueid) VALUES (3, -1, './MeNeither.mp3', 1, '3');" ); - m_storage->query( "INSERT INTO urls(id, deviceid, rpath, directory, uniqueid) VALUES (4, -1, './NothingHere.mp3', 1, '4');" ); - - m_storage->query( "INSERT INTO tracks(id,url,title,comment,artist,album,genre,year,composer) " - "VALUES(1,1,'track1','comment1',1,1,1,1,1);" ); - m_storage->query( "INSERT INTO tracks(id,url,title,comment,artist,album,genre,year,composer) " - "VALUES(2,2,'track2','comment2',1,2,1,1,1);" ); - - m_collection->registry()->emptyCache(); -} - -void -TestSqlTrack::cleanup() -{ - m_storage->query( "TRUNCATE TABLE years;" ); - m_storage->query( "TRUNCATE TABLE genres;" ); - m_storage->query( "TRUNCATE TABLE composers;" ); - m_storage->query( "TRUNCATE TABLE albums;" ); - m_storage->query( "TRUNCATE TABLE artists;" ); - m_storage->query( "TRUNCATE TABLE tracks;" ); - m_storage->query( "TRUNCATE TABLE urls;" ); - m_storage->query( "TRUNCATE TABLE directories;" ); - m_storage->query( "TRUNCATE TABLE statistics;" ); - m_storage->query( "TRUNCATE TABLE labels;" ); - m_storage->query( "TRUNCATE TABLE urls_labels;" ); -} - - -void -TestSqlTrack::setAllValues( Meta::SqlTrack *track ) -{ - track->setTitle( "New Title" ); - track->setAlbum( "New Album" ); - track->setArtist( "New Artist" ); - track->setComposer( "New Composer" ); - track->setYear( 1999 ); - track->setGenre( "New Genre" ); - - track->setUrl( -1, "./new_url", 2 ); - - track->setBpm( 32.0 ); - track->setComment( "New Comment" ); - - track->setScore( 64.0 ); - track->setRating( 5 ); - - track->setLength( 5000 ); - track->setSampleRate( 4400 ); - track->setBitrate( 128 ); - - track->setTrackNumber( 4 ); - track->setDiscNumber( 1 ); - - track->setFirstPlayed( QDateTime::fromTime_t(100) ); - track->setLastPlayed( QDateTime::fromTime_t(200) ); - track->setPlayCount( 20 ); - - Meta::ReplayGainTag modes[] = { Meta::ReplayGain_Track_Gain, - Meta::ReplayGain_Track_Peak, - Meta::ReplayGain_Album_Gain, - Meta::ReplayGain_Album_Peak }; - - for( int i=0; i<4; i++ ) - track->setReplayGain( modes[i], qreal(i) ); - - track->addLabel( "New Label" ); -} - -void -TestSqlTrack::getAllValues( Meta::SqlTrack *track ) -{ - QCOMPARE( track->name(), QString( "New Title" ) ); - QCOMPARE( track->album()->name(), QString( "New Album" ) ); - QCOMPARE( track->artist()->name(), QString( "New Artist" ) ); - QCOMPARE( track->composer()->name(), QString( "New Composer" ) ); - QCOMPARE( track->year()->name(), QString( "1999" ) ); - QCOMPARE( track->genre()->name(), QString( "New Genre" ) ); - - QCOMPARE( track->playableUrl().path(), QString( "/new_url" ) ); - QCOMPARE( track->bpm(), 32.0 ); - QCOMPARE( track->comment(), QString( "New Comment" ) ); - - QCOMPARE( track->score(), 64.0 ); - QCOMPARE( track->rating(), 5 ); - - QCOMPARE( track->length(), qint64(5000) ); - QCOMPARE( track->sampleRate(), 4400 ); - QCOMPARE( track->bitrate(), 128 ); - - QCOMPARE( track->trackNumber(), 4 ); - QCOMPARE( track->discNumber(), 1 ); - - QCOMPARE( track->firstPlayed(), QDateTime::fromTime_t(100) ); - QCOMPARE( track->lastPlayed(), QDateTime::fromTime_t(200) ); - QCOMPARE( track->playCount(), 20 ); - - Meta::ReplayGainTag modes[] = { Meta::ReplayGain_Track_Gain, - Meta::ReplayGain_Track_Peak, - Meta::ReplayGain_Album_Gain, - Meta::ReplayGain_Album_Peak }; - - for( int i=0; i<4; i++ ) - QCOMPARE( track->replayGain( modes[i] ), qreal(i) ); - - QVERIFY( track->labels().count() > 0 ); - QVERIFY( track->labels().contains( m_collection->registry()->getLabel("New Label") ) ); -} - -/** Check that the registry always returns the same track pointer */ -void -TestSqlTrack::testGetTrack() -{ - { - Meta::TrackPtr track1 = m_collection->registry()->getTrack( 1 ); - Meta::TrackPtr track2 = m_collection->registry()->getTrack( "/IDoNotExist.mp3" ); - Meta::TrackPtr track3 = m_collection->registry()->getTrackFromUid( "1" ); - - QVERIFY( track1 ); - QVERIFY( track1 == track2 ); - QVERIFY( track1 == track3 ); - } - - // and also after empty cache - m_collection->registry()->emptyCache(); - - // changed order... - { - Meta::TrackPtr track2 = m_collection->registry()->getTrack( "/IDoNotExist.mp3" ); - Meta::TrackPtr track3 = m_collection->registry()->getTrackFromUid( "1" ); - Meta::TrackPtr track1 = m_collection->registry()->getTrack( 1 ); - - QVERIFY( track1 ); - QVERIFY( track1 == track2 ); - QVERIFY( track1 == track3 ); - } - - // do again creating a new track - cleanup(); - m_collection->registry()->emptyCache(); - - // changed order... - { - Meta::TrackPtr track1 = m_collection->registry()->getTrack( -1, "./newTrack.mp3", 2, "amarok-sqltrackuid://newuid" ); - Meta::SqlTrack *sqlTrack1 = static_cast( track1.data() ); - sqlTrack1->setBpm( 100 ); // have to commit the new track - - QVERIFY( track1 ); - QCOMPARE( track1->playableUrl().path(), QString("/newTrack.mp3" )); - QCOMPARE( track1->uidUrl(), QString("amarok-sqltrackuid://newuid" )); - } - - m_collection->registry()->emptyCache(); - - // changed order... - { - Meta::TrackPtr track1 = m_collection->registry()->getTrackFromUid("amarok-sqltrackuid://newuid"); - - QVERIFY( track1 ); - QCOMPARE( track1->playableUrl().path(), QString("/newTrack.mp3" )); - QCOMPARE( track1->uidUrl(), QString("amarok-sqltrackuid://newuid" )); - QCOMPARE( track1->bpm(), 100.0 ); - } -} - -void -TestSqlTrack::testSetAllValuesSingleNotExisting() -{ - { - // get a new track - Meta::TrackPtr track1 = m_collection->registry()->getTrack( -1, "./IamANewTrack.mp3", 1, "1e34fb213489" ); - - QSignalSpy spy( m_collection, SIGNAL(updated())); - MetaNotificationSpy metaSpy; - metaSpy.subscribeTo( track1 ); - - Meta::SqlTrack *sqlTrack1 = static_cast( track1.data() ); - setAllValues( sqlTrack1 ); - getAllValues( sqlTrack1 ); - - // new track should have an up-to-date create time (not more than 3 seconds old) - QVERIFY( track1->createDate().secsTo(QDateTime::currentDateTime()) < 3 ); - - QVERIFY( metaSpy.notificationsFromTracks().count() > 1 ); // we should be notified about the changes - } - - // and also after empty cache - m_collection->registry()->emptyCache(); - - { - Meta::TrackPtr track1 = m_collection->registry()->getTrack( "/new_url" ); - Meta::SqlTrack *sqlTrack1 = static_cast( track1.data() ); - QVERIFY( track1 ); - getAllValues( sqlTrack1 ); - } -} - -/** Set all track values but before that create them in the registry. */ -void -TestSqlTrack::testSetAllValuesSingleExisting() -{ - { - Meta::GenrePtr genre = m_collection->registry()->getGenre( "New Genre" ); - Meta::ComposerPtr composer = m_collection->registry()->getComposer( "New Composer" ); - Meta::YearPtr year = m_collection->registry()->getYear( 1999 ); - Meta::AlbumPtr album = m_collection->registry()->getAlbum( "New Album", "New Artist" ); - m_collection->registry()->getLabel( "New Label" ); - - Meta::TrackPtr track1 = m_collection->registry()->getTrack( "/IDoNotExist.mp3" ); - - Meta::SqlTrack *sqlTrack1 = static_cast( track1.data() ); - setAllValues( sqlTrack1 ); - getAllValues( sqlTrack1 ); - - // check that the existing object are really updated with the new tracklist - QCOMPARE( genre->tracks().count(), 1 ); - QCOMPARE( genre->tracks().first().data(), track1.data() ); - - QCOMPARE( composer->tracks().count(), 1 ); - QCOMPARE( composer->tracks().first().data(), track1.data() ); - - QCOMPARE( year->tracks().count(), 1 ); - QCOMPARE( year->tracks().first().data(), track1.data() ); - - // the logic, how renaming the track artist influences its album is still - // unfinished. For sure the track must be in an album with the defined - // name - QCOMPARE( sqlTrack1->album()->name(), QString("New Album") ); - QCOMPARE( sqlTrack1->album()->tracks().count(), 1 ); - QCOMPARE( sqlTrack1->album()->tracks().first().data(), track1.data() ); - } - - // and also after empty cache - m_collection->registry()->emptyCache(); - - { - Meta::TrackPtr track1 = m_collection->registry()->getTrack( "/new_url" ); - Meta::SqlTrack *sqlTrack1 = static_cast( track1.data() ); - QVERIFY( track1 ); - getAllValues( sqlTrack1 ); - - Meta::GenrePtr genre = m_collection->registry()->getGenre( "New Genre" ); - Meta::ComposerPtr composer = m_collection->registry()->getComposer( "New Composer" ); - Meta::YearPtr year = m_collection->registry()->getYear( 1999 ); - Meta::AlbumPtr album = m_collection->registry()->getAlbum( "New Album", "New Artist" ); - - // check that the existing object are really updated with the new tracklist - QCOMPARE( genre->tracks().count(), 1 ); - QCOMPARE( genre->tracks().first().data(), track1.data() ); - - QCOMPARE( composer->tracks().count(), 1 ); - QCOMPARE( composer->tracks().first().data(), track1.data() ); - - QCOMPARE( year->tracks().count(), 1 ); - QCOMPARE( year->tracks().first().data(), track1.data() ); - - // the logic, how renaming the track artist influences its album is still - // unfinished. For sure the track must be in an album with the defined - // name - QCOMPARE( sqlTrack1->album()->name(), QString("New Album") ); - QCOMPARE( sqlTrack1->album()->tracks().count(), 1 ); - QCOMPARE( sqlTrack1->album()->tracks().first().data(), track1.data() ); - } -} - -void -TestSqlTrack::testSetAllValuesBatch() -{ - { - Meta::TrackPtr track1 = m_collection->registry()->getTrack( "/IDoNotExist.mp3" ); - Meta::SqlTrack *sqlTrack1 = static_cast( track1.data() ); - - QSignalSpy spy( m_collection, SIGNAL(updated())); - MetaNotificationSpy metaSpy; - metaSpy.subscribeTo( track1 ); - - sqlTrack1->beginUpdate(); - - setAllValues( sqlTrack1 ); - QCOMPARE( metaSpy.notificationsFromTracks().count(), 1 ); // add label does one notify - - sqlTrack1->endUpdate(); - QCOMPARE( metaSpy.notificationsFromTracks().count(), 2 ); // only one notificate for all the changes - - getAllValues( sqlTrack1 ); - } - - // and also after empty cache - m_collection->registry()->emptyCache(); - - { - Meta::TrackPtr track1 = m_collection->registry()->getTrack( "/new_url" ); - Meta::SqlTrack *sqlTrack1 = static_cast( track1.data() ); - QVERIFY( track1 ); - getAllValues( sqlTrack1 ); - } -} - -void -TestSqlTrack::testUnsetValues() -{ - { - Meta::TrackPtr track1 = m_collection->registry()->getTrack( "/IDoNotExist.mp3" ); - Meta::SqlTrack *sqlTrack1 = static_cast( track1.data() ); - - setAllValues( sqlTrack1 ); - - // now unset the values again - sqlTrack1->setAlbum( "" ); - sqlTrack1->setArtist( "" ); - sqlTrack1->setComposer( "" ); - sqlTrack1->setYear( 0 ); // it is not clear what an empty year exactly is - sqlTrack1->setGenre( "" ); - - // note: Amarok is still not clear if an empty artist means track->artist() == 0 - QVERIFY( !track1->album() || track1->album()->name().isEmpty() ); - QVERIFY( !track1->artist() || track1->artist()->name().isEmpty() ); - QVERIFY( !track1->composer() || track1->composer()->name().isEmpty() ); - QVERIFY( !track1->year() || track1->year()->year() == 0 ); - QVERIFY( !track1->genre() || track1->genre()->name().isEmpty() ); - } - - // and also after empty cache - m_collection->registry()->emptyCache(); - - { - Meta::TrackPtr track1 = m_collection->registry()->getTrack( "/new_url" ); - QVERIFY( track1 ); - QVERIFY( !track1->album() || track1->album()->name().isEmpty() ); - QVERIFY( !track1->artist() || track1->artist()->name().isEmpty() ); - QVERIFY( !track1->composer() || track1->composer()->name().isEmpty() ); - QVERIFY( !track1->year() || track1->year()->year() == 0 ); - QVERIFY( !track1->genre() || track1->genre()->name().isEmpty() ); - } -} - -void -TestSqlTrack::testFinishedPlaying() -{ - Meta::TrackPtr track1 = m_collection->registry()->getTrack( "/IDoNotExist.mp3" ); - Meta::SqlTrack *sqlTrack1 = static_cast( track1.data() ); - - sqlTrack1->setLength( 5000 ); - - QCOMPARE( sqlTrack1->score(), 0.0 ); - QCOMPARE( sqlTrack1->playCount(), 0 ); - QVERIFY( !sqlTrack1->firstPlayed().isValid() ); - QVERIFY( !sqlTrack1->lastPlayed().isValid() ); - - // now play the track not really - sqlTrack1->finishedPlaying( 0.1 ); - - // can't do a statement about the score here - QCOMPARE( sqlTrack1->playCount(), 0 ); - QVERIFY( !sqlTrack1->firstPlayed().isValid() ); - QVERIFY( !sqlTrack1->lastPlayed().isValid() ); - - // and now really play it - sqlTrack1->finishedPlaying( 1.0 ); - - QVERIFY( sqlTrack1->score() > 0.0 ); - QCOMPARE( sqlTrack1->playCount(), 1 ); - QVERIFY( sqlTrack1->firstPlayed().secsTo( QDateTime::currentDateTime() ) < 2 ); - QVERIFY( sqlTrack1->lastPlayed().secsTo( QDateTime::currentDateTime() ) < 2 ); -} - - -void -TestSqlTrack::testAlbumRemaingsNonCompilationAfterChangingAlbumName() -{ - m_storage->query( "INSERT INTO tracks(id,url,title,artist,album,genre,year,composer) " - "VALUES (3,3,'track1',1,1,1,1,1 );" ); - m_storage->query( "INSERT INTO tracks(id,url,title,artist,album,genre,year,composer) " - "VALUES (4,4,'track2',1,1,1,1,1 );" ); - - Meta::TrackPtr track1 = m_collection->registry()->getTrack( 3 ); - Meta::TrackPtr track2 = m_collection->registry()->getTrack( 4 ); - - QCOMPARE( track1->album()->name(), QString( "album1" ) ); - QVERIFY( track1->album()->hasAlbumArtist() ); - QCOMPARE( track1->album().data(), track2->album().data() ); - - Meta::SqlTrack *sqlTrack1 = static_cast( track1.data() ); - sqlTrack1->setAlbum( "album2" ); - Meta::SqlTrack *sqlTrack2 = static_cast( track2.data() ); - sqlTrack2->beginUpdate(); - sqlTrack2->setAlbum( "album2" ); - sqlTrack2->endUpdate(); - - QCOMPARE( track1->album()->name(), QString( "album2" ) ); - QVERIFY( track1->album()->hasAlbumArtist() ); - QVERIFY( track1->album() == track2->album() ); -} - -void -TestSqlTrack::testAlbumRemainsCompilationAfterChangingAlbumName() -{ - m_storage->query( "INSERT INTO tracks(id,url,title,artist,album,genre,year,composer) " - "VALUES (3,3,'track1',1,4,1,1,1 );" ); - m_storage->query( "INSERT INTO tracks(id,url,title,artist,album,genre,year,composer) " - "VALUES (4,4,'track2',1,4,1,1,1 );" ); - - Meta::TrackPtr track1 = m_collection->registry()->getTrack( 3 ); - Meta::TrackPtr track2 = m_collection->registry()->getTrack( 4 ); - - QVERIFY( track1 ); - QVERIFY( track1->album() ); - QVERIFY( track2 ); - QVERIFY( track2->album() ); - QCOMPARE( track1->album()->name(), QString( "album-compilation" ) ); - QVERIFY( track1->album()->isCompilation() ); - QVERIFY( track1->album().data() == track2->album().data() ); - - Meta::SqlTrack *sqlTrack1 = static_cast( track1.data() ); - Meta::SqlTrack *sqlTrack2 = static_cast( track2.data() ); - sqlTrack1->setAlbum( "album2" ); - sqlTrack2->beginUpdate(); - sqlTrack2->setAlbum( "album2" ); - sqlTrack2->endUpdate(); - - QCOMPARE( track1->album()->name(), QString( "album2" ) ); - QVERIFY( track1->album()->isCompilation() ); - QVERIFY( track1->album() == track2->album() ); -} - -void -TestSqlTrack::testRemoveLabelFromTrack() -{ - Meta::TrackPtr track = m_collection->registry()->getTrack( "/IDoNotExist.mp3" ); - Meta::LabelPtr label = m_collection->registry()->getLabel( "A" ); - track->addLabel( label ); - QCOMPARE( track->labels().count(), 1 ); - - track->removeLabel( label ); - QCOMPARE( track->labels().count(), 0 ); - - QStringList urlsLabelsCount = m_storage->query( "SELECT COUNT(*) FROM urls_labels;" ); - QCOMPARE( urlsLabelsCount.first().toInt(), 0 ); -} - -void -TestSqlTrack::testRemoveLabelFromTrackWhenNotInCache() -{ - m_storage->query( "INSERT INTO labels(id,label) VALUES (1,'A');" ); - m_storage->query( "INSERT INTO urls_labels(url,label) VALUES (1,1);" ); - - Meta::TrackPtr track = m_collection->registry()->getTrack( "/IDoNotExist.mp3" ); - Meta::LabelPtr label = m_collection->registry()->getLabel( "A" ); - - track->removeLabel( label ); - QCOMPARE( track->labels().count(), 0 ); - - QStringList urlsLabelsCount = m_storage->query( "SELECT COUNT(*) FROM urls_labels;" ); - QCOMPARE( urlsLabelsCount.first().toInt(), 0 ); -} - -#include "moc_TestSqlTrack.cpp" diff --git a/amarok/tests/core-impl/collections/db/sql/TestSqlTrack.h b/amarok/tests/core-impl/collections/db/sql/TestSqlTrack.h deleted file mode 100644 index 2832fcbe..00000000 --- a/amarok/tests/core-impl/collections/db/sql/TestSqlTrack.h +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef TESTSQLTRACK_H -#define TESTSQLTRACK_H - -#include - -#include - -class MySqlEmbeddedStorage; -class SqlRegistry; - -namespace Collections { - class SqlCollection; -} -namespace Meta { - class SqlTrack; -} - -class TestSqlTrack : public QObject -{ - Q_OBJECT - -public: - TestSqlTrack(); - -private slots: - void initTestCase(); - void cleanupTestCase(); - - void init(); - void cleanup(); - - void testGetTrack(); - - void testSetAllValuesSingleNotExisting(); - void testSetAllValuesSingleExisting(); - void testSetAllValuesBatch(); - - void testUnsetValues(); - - void testFinishedPlaying(); - - void testAlbumRemainsCompilationAfterChangingAlbumName(); - void testAlbumRemaingsNonCompilationAfterChangingAlbumName(); - void testRemoveLabelFromTrack(); - void testRemoveLabelFromTrackWhenNotInCache(); - -private: - void setAllValues( Meta::SqlTrack *track ); - void getAllValues( Meta::SqlTrack *track ); - - Collections::SqlCollection *m_collection; - MySqlEmbeddedStorage *m_storage; - KTempDir *m_tmpDir; -}; - -#endif // TESTSQLTRACK_H diff --git a/amarok/tests/core-impl/collections/support/CMakeLists.txt b/amarok/tests/core-impl/collections/support/CMakeLists.txt deleted file mode 100644 index a023acc9..00000000 --- a/amarok/tests/core-impl/collections/support/CMakeLists.txt +++ /dev/null @@ -1,56 +0,0 @@ -include_directories( - ${AMAROK_TEST_TREE} - ${AMAROK_SOURCE_TREE} - ${AMAROK_SOURCE_TREE}/core-impl/collections/support - ${AMAROK_UTILITY_TREE} - ${CMAKE_BINARY_DIR}/src - ${CMAKE_BINARY_DIR}/tests - ${AMAROK_COLLECTION_SUPPORT_DIR} - ${KDE4_INCLUDE_DIR} - ${QT_INCLUDES} - ${GOOGLEMOCK_INCLUDE_DIR} - ) - -#------------------------------- TestMemoryQueryMaker ------------------------------- - -set( testmemoryquerymaker_SRCS - TestMemoryQueryMaker.cpp - ${GOOGLEMOCK_SRCS} - ) - -kde4_add_unit_test( testmemoryquerymaker ${testmemoryquerymaker_SRCS} ) - -if(APPLE) - SET_TARGET_PROPERTIES(testmemoryquerymaker PROPERTIES LINK_FLAGS "-undefined dynamic_lookup") -endif(APPLE) -add_dependencies( testmemoryquerymaker amarokcore ) -add_dependencies( testmemoryquerymaker amaroklib ) -target_link_libraries(testmemoryquerymaker - amarokcore - amaroklib - ${KDE4_KDECORE_LIBS} - ${QT_QTGUI_LIBRARY} - ${KDE4_THREADWEAVER_LIBS} - ${QT_QTTEST_LIBRARY} - ${QT_QTCORE_LIBRARY} - ${GOOGLEMOCK_LIBRARIES}) - -#-------------------------------- Test ArtistHelper ----------------------- - -set( testartisthelper_SRCS - TestArtistHelper.cpp - ${AMAROK_SOURCE_TREE}/core-impl/collections/support/ArtistHelper.cpp - ) - - -kde4_add_unit_test( testartisthelper ${testartisthelper_SRCS} ) - - if(APPLE) - SET_TARGET_PROPERTIES(testartisthelper PROPERTIES LINK_FLAGS "-undefined dynamic_lookup") - endif(APPLE) - -target_link_libraries( testartisthelper - ${QT_QTTEST_LIBRARY} - ${QT_QTCORE_LIBRARY} - ${KDE4_KDECORE_LIBS}) - diff --git a/amarok/tests/core-impl/collections/support/TestArtistHelper.cpp b/amarok/tests/core-impl/collections/support/TestArtistHelper.cpp deleted file mode 100644 index ce25ce4e..00000000 --- a/amarok/tests/core-impl/collections/support/TestArtistHelper.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "TestArtistHelper.h" - -#include - -#include - -QTEST_KDEMAIN_CORE( TestArtistHelper ) - -TestArtistHelper::TestArtistHelper() : QObject() -{ - -} - -void -TestArtistHelper::testRealTrackArtist_data() -{ - QTest::addColumn( "artistTag" ); - QTest::addColumn( "realArtist" ); - - QTest::newRow( "no ft." ) << "Artist A" << "Artist A"; - QTest::newRow( "A ft. B") << "A ft. B" << "A"; - QTest::newRow( "A feat. B" ) << "A feat. B" << "A"; - QTest::newRow( "A featuring B" ) << "A featuring B" << "A"; - QTest::newRow( "A f. B" ) << "A f. B" << "A"; - //QTest::newRow( "artist including ft. string" ) << "Aft.B" << "Aft.B"; //not possible according to ML discussion - QTest::newRow( "empty A, return original string" ) << " featuring B" << " featuring B"; - QTest::newRow( "A (feat. B)" ) << "A (feat. B )" << "A"; - QTest::newRow( "A [feat. B]" ) << "A [feat. B]" << "A"; -} - -void -TestArtistHelper::testRealTrackArtist() -{ - QFETCH( QString, artistTag ); - QFETCH( QString, realArtist ); - - QCOMPARE( ArtistHelper::realTrackArtist( artistTag ), realArtist ); -} - -#include "moc_TestArtistHelper.cpp" diff --git a/amarok/tests/core-impl/collections/support/TestArtistHelper.h b/amarok/tests/core-impl/collections/support/TestArtistHelper.h deleted file mode 100644 index 2fab4fa3..00000000 --- a/amarok/tests/core-impl/collections/support/TestArtistHelper.h +++ /dev/null @@ -1,33 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef TESTARTISTHELPER_H -#define TESTARTISTHELPER_H - -#include - -class TestArtistHelper : public QObject -{ - Q_OBJECT -public: - TestArtistHelper(); - -private slots: - void testRealTrackArtist_data(); - void testRealTrackArtist(); -}; - -#endif diff --git a/amarok/tests/core-impl/collections/support/TestMemoryQueryMaker.cpp b/amarok/tests/core-impl/collections/support/TestMemoryQueryMaker.cpp deleted file mode 100644 index 12166ab9..00000000 --- a/amarok/tests/core-impl/collections/support/TestMemoryQueryMaker.cpp +++ /dev/null @@ -1,299 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Maximilian Kossick * - * Copyright (c) 2011 Ralf Engels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "TestMemoryQueryMaker.h" - -#include "mocks/MetaMock.h" -#include "mocks/MockTrack.h" - -#include "FileType.h" - -#include -#include -#include - -#include -#include - -#include - -#include - -using ::testing::AnyNumber; -using ::testing::Return; - -QTEST_KDEMAIN_CORE( TestMemoryQueryMaker ) - -TestMemoryQueryMaker::TestMemoryQueryMaker() -{ - KCmdLineArgs::init( KGlobal::activeComponent().aboutData() ); - ::testing::InitGoogleMock( &KCmdLineArgs::qtArgc(), KCmdLineArgs::qtArgv() ); - qRegisterMetaType(); - qRegisterMetaType(); - qRegisterMetaType(); -} - -void -TestMemoryQueryMaker::initTestCase() -{ - // prepare a memory collection with some test data - m_mc = QSharedPointer( new Collections::MemoryCollection() ); - - MetaMock *track; - - QVariantMap map; - map.insert( Meta::Field::UNIQUEID, "1" ); - map.insert( Meta::Field::TITLE, "Skater Boy" ); - map.insert( Meta::Field::RATING, 3 ); -// map.insert( Meta::Field::TYPE, int(Amarok::Mp3) ); - map.insert( Meta::Field::TRACKNUMBER, 3 ); - track = new MetaMock( map ); - track->m_artist = new MockArtist("Avril Lavigne"); - track->m_album = new MockAlbum("Let Go"); - m_mc->addTrack( Meta::TrackPtr( track ) ); - - map.insert( Meta::Field::UNIQUEID, "2" ); - map.insert( Meta::Field::TITLE, "Substitute" ); - map.insert( Meta::Field::RATING, 4 ); - // map.insert( Meta::Field::TYPE, int(Amarok::Ogg) ); - map.insert( Meta::Field::TRACKNUMBER, 1 ); - track = new MetaMock( map ); - track->m_artist = new MockArtist("Clout" ); - track->m_album = new MockAlbum("Substitute" ); - m_mc->addTrack( Meta::TrackPtr( track ) ); - - map.insert( Meta::Field::UNIQUEID, "3" ); - map.insert( Meta::Field::TITLE, "I Say A Little Prayer" ); - map.insert( Meta::Field::RATING, 2 ); - // map.insert( Meta::Field::TYPE, int(Amarok::Wma) ); - map.insert( Meta::Field::TRACKNUMBER, 1 ); - map.insert( Meta::Field::DISCNUMBER, 2 ); - track = new MetaMock( map ); - track->m_artist = new MockArtist("The Bosshoss" ); - track->m_album = new MockAlbum("Rodeo Radio" ); - m_mc->addTrack( Meta::TrackPtr( track ) ); -} - -void TestMemoryQueryMaker::cleanupTestCase() -{ -} - -void -TestMemoryQueryMaker::testDeleteQueryMakerWhileQueryIsRunning() -{ - QSharedPointer mc( new Collections::MemoryCollection() ); - mc->addTrack( Meta::TrackPtr( new MetaMock( QVariantMap() ))); - mc->addTrack( Meta::TrackPtr( new MetaMock( QVariantMap() ))); - Meta::MockTrack *mock = new Meta::MockTrack(); - EXPECT_CALL( *mock, uidUrl() ).Times( AnyNumber() ).WillRepeatedly( Return( "track3" ) ); - Meta::TrackPtr trackPtr( mock ); - mc->addTrack( trackPtr ); - - Collections::MemoryQueryMaker *qm = new Collections::MemoryQueryMaker( mc.toWeakRef(), "test" ); - qm->setQueryType( Collections::QueryMaker::Track ); - - qm->run(); - delete qm; - //we cannot wait for a signal here.... - //QTest::qWait( 500 ); -} - -void -TestMemoryQueryMaker::testDeleteCollectionWhileQueryIsRunning() -{ - QSharedPointer mc( new Collections::MemoryCollection() ); - mc->addTrack( Meta::TrackPtr( new MetaMock( QVariantMap() ))); - mc->addTrack( Meta::TrackPtr( new MetaMock( QVariantMap() ))); - - Collections::MemoryQueryMaker *qm = new Collections::MemoryQueryMaker( mc, "test" ); - qm->setQueryType( Collections::QueryMaker::Track ); - - QSignalSpy spy( qm, SIGNAL(queryDone())); - - qm->run(); - mc.clear(); - QTest::qWait( 500 ); - QCOMPARE( spy.count(), 1 ); - - delete qm; -} - -class TestStringMemoryFilter : public StringMemoryFilter -{ -public: - TestStringMemoryFilter() : StringMemoryFilter() {} - -protected: - QString value( Meta::TrackPtr track ) const { Q_UNUSED(track); return "abcdef"; } - -}; - -void -TestMemoryQueryMaker::testStringMemoryFilterSpeedFullMatch() -{ - //Test 1: match complete string - TestStringMemoryFilter filter1; - filter1.setFilter( QString( "abcdef" ), true, true ); - - QBENCHMARK { - filter1.filterMatches( Meta::TrackPtr() ); - } -} - -void -TestMemoryQueryMaker::testStringMemoryFilterSpeedMatchBegin() -{ - //Test 2: match beginning of string - TestStringMemoryFilter filter2; - filter2.setFilter( QString( "abcd" ), true, false ); - - QBENCHMARK { - filter2.filterMatches( Meta::TrackPtr() ); - } -} - -void -TestMemoryQueryMaker::testStringMemoryFilterSpeedMatchEnd() -{ - //Test 3: match end of string - TestStringMemoryFilter filter3; - filter3.setFilter( QString( "cdef" ), false, true ); - - QBENCHMARK { - filter3.filterMatches( Meta::TrackPtr() ); - } -} - -void -TestMemoryQueryMaker::testStringMemoryFilterSpeedMatchAnywhere() -{ - //Test 4: match anywhere in string - TestStringMemoryFilter filter4; - filter4.setFilter( QString( "bcde" ), false, false ); - - QBENCHMARK { - filter4.filterMatches( Meta::TrackPtr() ); - } -} - -Meta::TrackList -TestMemoryQueryMaker::executeQueryMaker( Collections::QueryMaker *qm ) -{ - QSignalSpy doneSpy1( qm, SIGNAL(queryDone())); - QSignalSpy resultSpy1( qm, SIGNAL(newResultReady(Meta::TrackList))); - - qm->setQueryType( Collections::QueryMaker::Track ); - qm->run(); - - QTest::kWaitForSignal( qm, SIGNAL(queryDone()), 1000 ); - - if( resultSpy1.count() != 1 ) return Meta::TrackList(); - if( doneSpy1.count() != 1 ) return Meta::TrackList(); - - QList args1 = resultSpy1.takeFirst(); - if( !args1.value(0).canConvert() ) return Meta::TrackList(); - - delete qm; - - return args1.value(0).value(); -} - - -void -TestMemoryQueryMaker::testFilterTitle() -{ - Meta::TrackList tracks; - - // -- just get all the tracks - Collections::MemoryQueryMaker *qm = new Collections::MemoryQueryMaker( m_mc.toWeakRef(), "test" ); - tracks = executeQueryMaker( qm ); - QCOMPARE( tracks.count(), 3 ); - - // -- filter for title - qm = new Collections::MemoryQueryMaker( m_mc.toWeakRef(), "test" ); - qm->addFilter( Meta::valTitle, "Skater", true, false ); - tracks = executeQueryMaker( qm ); - QCOMPARE( tracks.count(), 1 ); - QCOMPARE( tracks.first()->name(), QString("Skater Boy" ) ); - - // -- filter for album - qm = new Collections::MemoryQueryMaker( m_mc.toWeakRef(), "test" ); - qm->addFilter( Meta::valAlbum, "S", false, false ); - tracks = executeQueryMaker( qm ); - QCOMPARE( tracks.count(), 1 ); - QCOMPARE( tracks.first()->name(), QString("Substitute" ) ); - - // -- filter for artist - qm = new Collections::MemoryQueryMaker( m_mc.toWeakRef(), "test" ); - qm->addFilter( Meta::valArtist, "Lavigne", false, true ); - tracks = executeQueryMaker( qm ); - QCOMPARE( tracks.count(), 1 ); - QCOMPARE( tracks.first()->name(), QString("Skater Boy" ) ); -} - -void -TestMemoryQueryMaker::testFilterRating() -{ - Meta::TrackList tracks; - Collections::MemoryQueryMaker *qm = 0; - - // -- filter for Rating - qm = new Collections::MemoryQueryMaker( m_mc.toWeakRef(), "test" ); - qm->addNumberFilter( Meta::valRating, 3, Collections::QueryMaker::Equals ); - tracks = executeQueryMaker( qm ); - QCOMPARE( tracks.count(), 1 ); - QCOMPARE( tracks.first()->name(), QString("Skater Boy" ) ); - - // -- filter for Rating - qm = new Collections::MemoryQueryMaker( m_mc.toWeakRef(), "test" ); - qm->addNumberFilter( Meta::valRating, 4, Collections::QueryMaker::LessThan ); - tracks = executeQueryMaker( qm ); - QCOMPARE( tracks.count(), 2 ); -} - -void -TestMemoryQueryMaker::testFilterAnd() -{ - Meta::TrackList tracks; - Collections::MemoryQueryMaker *qm = 0; - - qm = new Collections::MemoryQueryMaker( m_mc.toWeakRef(), "test" ); - qm->beginAnd(); - qm->addNumberFilter( Meta::valTrackNr, 1, Collections::QueryMaker::Equals ); - qm->addFilter( Meta::valAlbum, "o", false, false ); - qm->endAndOr(); - tracks = executeQueryMaker( qm ); - QCOMPARE( tracks.count(), 1 ); - QCOMPARE( tracks.first()->album()->name(), QString("Rodeo Radio" ) ); -} - -void -TestMemoryQueryMaker::testFilterFormat() -{ - Meta::TrackList tracks; - Collections::MemoryQueryMaker *qm = 0; - - // -- filter for title - qm = new Collections::MemoryQueryMaker( m_mc.toWeakRef(), "test" ); - qm->addNumberFilter( Meta::valFormat, - int(Amarok::Mp3), - Collections::QueryMaker::Equals ); - tracks = executeQueryMaker( qm ); - QCOMPARE( tracks.count(), 0 ); -} - - diff --git a/amarok/tests/core-impl/collections/support/TestMemoryQueryMaker.h b/amarok/tests/core-impl/collections/support/TestMemoryQueryMaker.h deleted file mode 100644 index c3f0770d..00000000 --- a/amarok/tests/core-impl/collections/support/TestMemoryQueryMaker.h +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Maximilian Kossick * - * Copyright (c) 2011 Ralf Engels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef TESTMEMORYQUERYMAKER_H -#define TESTMEMORYQUERYMAKER_H - -#include - -#include "core/meta/forward_declarations.h" -#include "core/collections/QueryMaker.h" - -#include "core-impl/collections/support/MemoryCollection.h" -#include "core-impl/collections/support/MemoryFilter.h" -#include "core-impl/collections/support/MemoryQueryMaker.h" - - -class TestMemoryQueryMaker : public QObject -{ - Q_OBJECT -public: - TestMemoryQueryMaker(); - -private slots: - void initTestCase(); - void cleanupTestCase(); - - void testDeleteQueryMakerWhileQueryIsRunning(); - void testDeleteCollectionWhileQueryIsRunning(); - - void testStringMemoryFilterSpeedFullMatch(); - void testStringMemoryFilterSpeedMatchBegin(); - void testStringMemoryFilterSpeedMatchEnd(); - void testStringMemoryFilterSpeedMatchAnywhere(); - - void testFilterTitle(); - void testFilterRating(); - void testFilterAnd(); - void testFilterFormat(); - -private: - Meta::TrackList executeQueryMaker( Collections::QueryMaker *qm ); - - QSharedPointer m_mc; -}; - -#endif // TESTMEMORYQUERYMAKER_H diff --git a/amarok/tests/core-impl/logger/CMakeLists.txt b/amarok/tests/core-impl/logger/CMakeLists.txt deleted file mode 100644 index 3d04c5ce..00000000 --- a/amarok/tests/core-impl/logger/CMakeLists.txt +++ /dev/null @@ -1,32 +0,0 @@ -include_directories( - ${AMAROK_TEST_TREE} - ${AMAROK_SOURCE_TREE} - ${AMAROK_UTILITY_TREE} - ${CMAKE_BINARY_DIR}/src - ${CMAKE_BINARY_DIR}/tests - ${KDE4_INCLUDE_DIR} - ${QT_INCLUDES} - ${GOOGLEMOCK_INCLUDE_DIR} - ) - -#------------------------ Test ProxyLogger ----------------------------- - -set( testproxylogger_SRCS - TestProxyLogger.cpp - ${AMAROK_SOURCE_TREE}/core/interfaces/Logger.cpp - ${AMAROK_SOURCE_TREE}/core-impl/logger/ProxyLogger.cpp - ${GOOGLEMOCK_SRCS} - ) - - -kde4_add_unit_test( testproxylogger - ${testproxylogger_SRCS} - ) - -target_link_libraries( testproxylogger - ${KDE4_KDECORE_LIBS} - ${QT_QTTEST_LIBRARY} - ${QT_QTCORE_LIBRARY} - ${KDE4_THREADWEAVER_LIBS} - ${GOOGLEMOCK_LIBRARIES} - ${CMAKE_DL_LIBS}) diff --git a/amarok/tests/core-impl/logger/TestProxyLogger.cpp b/amarok/tests/core-impl/logger/TestProxyLogger.cpp deleted file mode 100644 index f3a60738..00000000 --- a/amarok/tests/core-impl/logger/TestProxyLogger.cpp +++ /dev/null @@ -1,179 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "TestProxyLogger.h" - -#include "core/interfaces/Logger.h" -#include "core-impl/logger/ProxyLogger.h" - -#include "mocks/MockLogger.h" - -#include -#include -#include -#include - -#include - -#include - -#include - -QTEST_KDEMAIN_CORE( TestProxyLogger ) - -using ::testing::Return; -using ::testing::AnyNumber; -using ::testing::_; -using ::testing::Mock; - -static ProxyLogger *s_logger; - -class DummyJob : public KJob -{ -public: - virtual void start() {} -}; - -TestProxyLogger::TestProxyLogger() -{ - KCmdLineArgs::init( KGlobal::activeComponent().aboutData() ); - ::testing::InitGoogleMock( &KCmdLineArgs::qtArgc(), KCmdLineArgs::qtArgv() ); -} - -void -TestProxyLogger::init() -{ - s_logger = 0; -} - -void -TestProxyLogger::cleanup() -{ - delete s_logger; -} - -class ProgressJob : public ThreadWeaver::Job -{ -public: - ProgressJob() : deleteJob( false ), deleteObject( false ) {} - void run() { - KJob *job = new DummyJob(); - QObject *obj = new QObject(); - s_logger->newProgressOperation( job, QString( "foo" ), obj, "foo()" ); - - if( deleteJob ) delete job; - if( deleteObject ) delete obj; - } - - bool deleteJob; - bool deleteObject; -}; - -void -TestProxyLogger::testDoNotForwardDeletedJob() -{ - s_logger = new ProxyLogger(); - - Amarok::MockLogger *mock = new Amarok::MockLogger(); - EXPECT_CALL( *mock, newProgressOperation( An(), _, _, _, _ ) ).Times( 0 ); - - s_logger->setLogger( mock ); - - ProgressJob *job = new ProgressJob(); - job->deleteJob = true; - ThreadWeaver::Weaver::instance()->enqueue( job ); - - QTest::qSleep( 10 ); //ensure that the job has time to run - QTest::qWait( 20 ); //give the ProxyLogger-internal timer time to fire - - QVERIFY( Mock::VerifyAndClearExpectations( &mock ) ); - delete mock; -} - -void -TestProxyLogger::testDoNotForwardDeletedSlot() -{ - s_logger = new ProxyLogger(); - - Amarok::MockLogger *mock = new Amarok::MockLogger(); - EXPECT_CALL( *mock, newProgressOperation( An(), _, 0, 0, _ ) ).Times( 1 ).WillOnce( Return() ); - - s_logger->setLogger( mock ); - - ProgressJob *job = new ProgressJob(); - job->deleteObject = true; - ThreadWeaver::Weaver::instance()->enqueue( job ); - - QTest::qSleep( 10 ); //ensure that the job has time to run - QTest::qWait( 20 ); //give the ProxyLogger-internal timer time to fire - - QVERIFY( Mock::VerifyAndClearExpectations( &mock ) ); - delete mock; -} - -void -TestProxyLogger::testForwardLongMessage() -{ - s_logger = new ProxyLogger(); - - Amarok::MockLogger *mock = new Amarok::MockLogger(); - EXPECT_CALL( *mock, longMessage( _, _ ) ).Times( 1 ).WillOnce( Return() ); - - s_logger->setLogger( mock ); - - s_logger->longMessage( "foo", Amarok::Logger::Information ); - - QTest::qWait( 20 ); - - QVERIFY( Mock::VerifyAndClearExpectations( &mock ) ); - delete mock; -} - -void -TestProxyLogger::testForwardProgressOperation() -{ - s_logger = new ProxyLogger(); - - Amarok::MockLogger *mock = new Amarok::MockLogger(); - EXPECT_CALL( *mock, newProgressOperation( An(), _, _, _, _ ) ).Times( 1 ).WillOnce( Return() ); - - s_logger->setLogger( mock ); - - s_logger->newProgressOperation( new DummyJob(), QString( "foo" ) ); - - QTest::qWait( 20 ); - - QVERIFY( Mock::VerifyAndClearExpectations( &mock ) ); - delete mock; -} - -void -TestProxyLogger::testForwardShortMessage() -{ - s_logger = new ProxyLogger(); - - Amarok::MockLogger *mock = new Amarok::MockLogger(); - EXPECT_CALL( *mock, shortMessage( _ ) ).Times( 1 ).WillOnce( Return() ); - - s_logger->setLogger( mock ); - - s_logger->shortMessage( "foo" ); - - QTest::qWait( 20 ); - - QVERIFY( Mock::VerifyAndClearExpectations( &mock ) ); - delete mock; -} diff --git a/amarok/tests/core-impl/logger/TestProxyLogger.h b/amarok/tests/core-impl/logger/TestProxyLogger.h deleted file mode 100644 index d46ec91c..00000000 --- a/amarok/tests/core-impl/logger/TestProxyLogger.h +++ /dev/null @@ -1,39 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef TEST_PROXY_LOGGER_H -#define TEST_PROXY_LOGGER_H - -#include - -class TestProxyLogger : public QObject -{ - Q_OBJECT -public: - TestProxyLogger(); - -private slots: - void init(); - void cleanup(); - - void testForwardShortMessage(); - void testForwardLongMessage(); - void testForwardProgressOperation(); - void testDoNotForwardDeletedJob(); - void testDoNotForwardDeletedSlot(); -}; - -#endif diff --git a/amarok/tests/core-impl/meta/CMakeLists.txt b/amarok/tests/core-impl/meta/CMakeLists.txt deleted file mode 100644 index 2fa21043..00000000 --- a/amarok/tests/core-impl/meta/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -include_directories( - ${AMAROK_TEST_TREE} - ${CMAKE_BINARY_DIR}/tests - ) - - -add_subdirectory( cue ) -add_subdirectory( file ) -add_subdirectory( multi ) diff --git a/amarok/tests/core-impl/meta/cue/CMakeLists.txt b/amarok/tests/core-impl/meta/cue/CMakeLists.txt deleted file mode 100644 index e55eabd8..00000000 --- a/amarok/tests/core-impl/meta/cue/CMakeLists.txt +++ /dev/null @@ -1,38 +0,0 @@ -include_directories( - ${AMAROK_TEST_TREE} - ${AMAROK_SOURCE_TREE} - ${AMAROK_UTILITY_TREE} - ${CMAKE_BINARY_DIR}/src - ${CMAKE_BINARY_DIR}/tests - ${AMAROK_COLLECTION_SUPPORT_DIR} - ${KDE4_INCLUDE_DIR} - ${QT_INCLUDES} - ${GOOGLEMOCK_INCLUDE_DIR} - ) - -#------------------------ Test CueFileSupport ----------------------------- - -set( testcuefilesupport_SRCS - TestCueFileSupport.cpp - ${AMAROK_SOURCE_TREE}/core/capabilities/BoundedPlaybackCapability.cpp - ${AMAROK_SOURCE_TREE}/core-impl/meta/cue/CueFileSupport.cpp - ${AMAROK_SOURCE_TREE}/core-impl/meta/timecode/TimecodeMeta.cpp - ${AMAROK_SOURCE_TREE}/core-impl/capabilities/timecode/TimecodeBoundedPlaybackCapability.cpp - ${GOOGLEMOCK_SRCS} - ) - -kde4_add_unit_test( testcuefilesupport ${testcuefilesupport_SRCS} ) - -add_dependencies( testcuefilesupport amarokcore ) -add_dependencies( testcuefilesupport amaroklib) - -target_link_libraries( testcuefilesupport - amarokcore - amaroklib - ${KDE4_KDECORE_LIBS} - ${KDE4_KDEUI_LIBS} - ${QT_QTTEST_LIBRARY} - ${QT_QTCORE_LIBRARY} - ${GOOGLEMOCK_LIBRARIES} - ${CMAKE_DL_LIBS}) - diff --git a/amarok/tests/core-impl/meta/cue/TestCueFileSupport.cpp b/amarok/tests/core-impl/meta/cue/TestCueFileSupport.cpp deleted file mode 100644 index eb94e48f..00000000 --- a/amarok/tests/core-impl/meta/cue/TestCueFileSupport.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 Pulic License for more details. * - * * - * You should have received a copy of the GNU General Public License along with * - * this program. If not, see . * - ****************************************************************************************/ - -#include "TestCueFileSupport.h" - -#include "config-amarok-test.h" -#include "core-impl/meta/cue/CueFileSupport.h" - -#include - -#include - -#include - -QTEST_KDEMAIN_CORE( TestCueFileSupport ) - -using namespace MetaCue; - -TestCueFileSupport::TestCueFileSupport() - : QObject() -{ -} - -void TestCueFileSupport::testLocateCueFile() -{ - //Check that we find the right .cue file and that it passes the validator - KUrl cueTestUrl = dataPath( "data/cue/testsheet01-iso8859-1.cue" ); - KUrl cueResultUrl = CueFileSupport::locateCueSheet( cueTestUrl ); - - QVERIFY( !cueResultUrl.url().isEmpty() ); - QCOMPARE( cueResultUrl.url(), cueTestUrl.url() ); - - //Check that a nonexisting cue file returns an empty url - KUrl testUrl = dataPath( "data/cue/test_silence.ogg" ); - cueResultUrl = CueFileSupport::locateCueSheet( testUrl ); - - QVERIFY( cueResultUrl.isEmpty() ); - - //Check that an existing but invalid cue file returns an empty url - testUrl = dataPath( "data/cue/invalid.cue" ); - cueResultUrl = CueFileSupport::locateCueSheet( testUrl ); - - QVERIFY( cueResultUrl.isEmpty() ); -} - -void TestCueFileSupport::testIso88591Cue() -{ - KUrl testUrl = dataPath( "data/cue/testsheet01-iso8859-1.cue" ); - KUrl testTrackUrl = QString( "Die Toten Hosen - In aller Stille (2008).mp3" ); - CueFileItemMap cueItemMap = CueFileSupport::loadCueFile( testUrl, testTrackUrl, 48000 ); - - QCOMPARE( cueItemMap.size(), 14 ); - QCOMPARE( cueItemMap.value( cueItemMap.keys()[2] ).title(), QString( "Disco" ) ); - QCOMPARE( cueItemMap.value( cueItemMap.keys()[2] ).artist(), QString( "Die Toten Hosen" ) ); -} - -void TestCueFileSupport::testUtf8Cue() -{ - KUrl testUrl = dataPath( "data/cue/testsheet01-utf8.cue" ); - KUrl testTrackUrl = QString( "Die Toten Hosen - In aller Stille (2008).mp3" ); - CueFileItemMap cueItemMap = CueFileSupport::loadCueFile( testUrl, testTrackUrl, 48000 ); - - QCOMPARE( cueItemMap.size(), 14 ); - QCOMPARE( cueItemMap.value( cueItemMap.keys()[6] ).title(), QString( "Ertrinken" ) ); - QCOMPARE( cueItemMap.value( cueItemMap.keys()[6] ).artist(), QString( "Die Toten Hosen" ) ); -} - -QString TestCueFileSupport::dataPath( const QString &relPath ) -{ - return QDir::toNativeSeparators( QString( AMAROK_TEST_DIR ) + '/' + relPath ); -} diff --git a/amarok/tests/core-impl/meta/cue/TestCueFileSupport.h b/amarok/tests/core-impl/meta/cue/TestCueFileSupport.h deleted file mode 100644 index c05fc4ca..00000000 --- a/amarok/tests/core-impl/meta/cue/TestCueFileSupport.h +++ /dev/null @@ -1,39 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 Pulic License for more details. * - * * - * You should have received a copy of the GNU General Public License along with * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef TESTCUEFILESUPPORT_H -#define TESTCUEFILESUPPORT_H - -#include -#include - -class TestCueFileSupport : public QObject -{ -Q_OBJECT - -public: - TestCueFileSupport(); - -private slots: - void testLocateCueFile(); - void testIso88591Cue(); - void testUtf8Cue(); - -private: - QString dataPath( const QString &relPath ); -}; - -#endif // TESTCUEFILESUPPORT_H diff --git a/amarok/tests/core-impl/meta/file/CMakeLists.txt b/amarok/tests/core-impl/meta/file/CMakeLists.txt deleted file mode 100644 index 4e8cf5cc..00000000 --- a/amarok/tests/core-impl/meta/file/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -#------------------------ Test MetaFileTrack ----------------------------- - -set( testmetafiletrack_SRCS TestMetaFileTrack.cpp ) -kde4_add_unit_test( testmetafiletrack ${testmetafiletrack_SRCS} ) -target_link_libraries( testmetafiletrack ${QT_QTTEST_LIBRARY} ${KDE4_KDECORE_LIBS} ${QT_QTCORE_LIBRARY} amarokcore amaroklib ) diff --git a/amarok/tests/core-impl/meta/file/TestMetaFileTrack.cpp b/amarok/tests/core-impl/meta/file/TestMetaFileTrack.cpp deleted file mode 100644 index 9c2138c7..00000000 --- a/amarok/tests/core-impl/meta/file/TestMetaFileTrack.cpp +++ /dev/null @@ -1,457 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2009 Sven Krohlas * - * * - * This program 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 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#include "TestMetaFileTrack.h" - -#include "config-amarok-test.h" -#include "amarokconfig.h" - -#include - -#include -#include -#include -#include -#include - -#include - -QTEST_KDEMAIN_CORE( TestMetaFileTrack ) - -TestMetaFileTrack::TestMetaFileTrack() - : m_tmpDir( 0 ) -{} - -void TestMetaFileTrack::initTestCase() -{ - m_tmpDir = new KTempDir(); - QVERIFY( m_tmpDir->exists() ); - - m_origTrackPath = QString( AMAROK_TEST_DIR ) + "/data/audio/Platz 01.mp3"; - QVERIFY( QFile::exists( m_origTrackPath ) ); -} - -void TestMetaFileTrack::cleanupTestCase() -{ - delete m_tmpDir; -} - -void TestMetaFileTrack::init() -{ - static const QString tmpFileNameBase( "tempfile.mp3" ); - static int i = 0; - // create new file name for every test: we need to start with clean statistics - m_tmpFileName = QString( "%1%2-%3" ).arg( m_tmpDir->name() ).arg( i++ ).arg( tmpFileNameBase ); - QVERIFY( QFile::copy( m_origTrackPath, m_tmpFileName ) ); - - m_track = new MetaFile::Track( m_tmpFileName ); - QVERIFY( m_track ); -} - -void TestMetaFileTrack::testNameAndSetTitle() -{ - // why aren't those called set/getTitle? - QCOMPARE( m_track->name(), QString( "Platz 01" ) ); - - m_track->setTitle( "" ); - //when there is no title, we default to using the filename without extension - QCOMPARE( m_track->name(), QString( "tempfile" ) ); - - m_track->setTitle( "test" ); - QCOMPARE( m_track->name(), QString( "test" ) ); - - m_track->setTitle( "Another Test" ); - QCOMPARE( m_track->name(), QString( "Another Test" ) ); - - m_track->setTitle( "Some Umlauts: äöü" ); - QCOMPARE( m_track->name(), QString( "Some Umlauts: äöü" ) ); - - m_track->setTitle( "Platz 01" ); - QCOMPARE( m_track->name(), QString( "Platz 01" ) ); -} - -void TestMetaFileTrack::testPrettyName() -{ - QCOMPARE( m_track->prettyName(), QString( "Platz 01" ) ); - - m_track->setTitle( "" ); - //when there is no title, we default to using the filename without extension - QCOMPARE( m_track->prettyName(), QString( "tempfile" ) ); - - m_track->setTitle( "test" ); - QCOMPARE( m_track->prettyName(), QString( "test" ) ); - - m_track->setTitle( "Another Test" ); - QCOMPARE( m_track->prettyName(), QString( "Another Test" ) ); - - m_track->setTitle( "Some Umlauts: äöü" ); - QCOMPARE( m_track->prettyName(), QString( "Some Umlauts: äöü" ) ); - - m_track->setTitle( "Platz 01" ); - QCOMPARE( m_track->prettyName(), QString( "Platz 01" ) ); -} - -void TestMetaFileTrack::testSortableName() -{ - QCOMPARE( m_track->sortableName(), QString( "Platz 01" ) ); - - m_track->setTitle( "test" ); - QCOMPARE( m_track->sortableName(), QString( "test" ) ); - - m_track->setTitle( "Another Test" ); - QCOMPARE( m_track->sortableName(), QString( "Another Test" ) ); - - m_track->setTitle( "Some Umlauts: äöü" ); - QCOMPARE( m_track->sortableName(), QString( "Some Umlauts: äöü" ) ); - - m_track->setTitle( "Platz 01" ); - QCOMPARE( m_track->sortableName(), QString( "Platz 01" ) ); -} - -void TestMetaFileTrack::testPlayableUrl() -{ - const KUrl tempUrl = m_track->playableUrl(); - QCOMPARE( tempUrl.toLocalFile(), m_tmpFileName ); -} - -void TestMetaFileTrack::testPrettyUrl() -{ - KUrl tempUrl; - tempUrl = m_track->prettyUrl(); - QCOMPARE( tempUrl.toLocalFile(), m_tmpFileName ); -} - -void TestMetaFileTrack::testUidUrl() -{ - KUrl tempUrl; - tempUrl = m_track->uidUrl(); - QCOMPARE( tempUrl.toLocalFile(), m_tmpFileName ); -} - -void TestMetaFileTrack::testIsPlayable() -{ - QVERIFY( m_track->isPlayable() ); -} - -void TestMetaFileTrack::testIsEditable() -{ - QVERIFY( m_track->isEditable() ); - - QFile testFile( m_tmpFileName ); - - QVERIFY( testFile.setPermissions( 0x0000 ) ); - /* When the tests are run as root under Linux, the file is accessible even when it - * has no permission bits set. Just skip one verify in this case in order not to - * break whole test. */ - if( !QFileInfo( testFile ).isReadable() ) - QVERIFY( !m_track->isEditable() ); - - QVERIFY( testFile.setPermissions( QFile::ReadOwner | QFile::WriteOwner ) ); - QVERIFY( m_track->isEditable() ); -} - -void TestMetaFileTrack::testSetGetAlbum() -{ - QCOMPARE( m_track->album().data()->name(), QString( "" ) ); - - m_track->setAlbum( "test" ); - QCOMPARE( m_track->album().data()->name(), QString( "test" ) ); - - m_track->setAlbum( "Another Test" ); - QCOMPARE( m_track->album().data()->name(), QString( "Another Test" ) ); - - m_track->setAlbum( "Some Umlauts: äöü" ); - QCOMPARE( m_track->album().data()->name(), QString( "Some Umlauts: äöü" ) ); - - m_track->setAlbum( "" ); - QCOMPARE( m_track->album().data()->name(), QString( "" ) ); -} - -void TestMetaFileTrack::testSetGetArtist() -{ - QCOMPARE( m_track->artist().data()->name(), QString( "Free Music Charts" ) ); - - m_track->setArtist( "" ); - QCOMPARE( m_track->artist()->name(), QString( "" ) ); - - m_track->setArtist( "test" ); - QCOMPARE( m_track->artist()->name(), QString( "test" ) ); - - m_track->setArtist( "Another Test" ); - QCOMPARE( m_track->artist()->name(), QString( "Another Test" ) ); - - m_track->setArtist( "Some Umlauts: äöü" ); - QCOMPARE( m_track->artist()->name(), QString( "Some Umlauts: äöü" ) ); - - m_track->setArtist( "Free Music Charts" ); - QCOMPARE( m_track->artist().data()->name(), QString( "Free Music Charts" ) ); -} - -void TestMetaFileTrack::testSetGetGenre() -{ - QCOMPARE( m_track->genre().data()->name(), QString( "Vocal" ) ); - - m_track->setGenre( "rock" ); - QCOMPARE( m_track->genre().data()->name(), QString( "rock" ) ); - - m_track->setGenre( "rock / pop" ); - QCOMPARE( m_track->genre().data()->name(), QString( "rock / pop" ) ); - - m_track->setGenre( "Some Umlauts: äöü" ); - QCOMPARE( m_track->genre().data()->name(), QString( "Some Umlauts: äöü" ) ); - - m_track->setGenre( "" ); - QCOMPARE( m_track->genre().data()->name(), QString( "" ) ); - - m_track->setGenre( "28 Vocal" ); - QCOMPARE( m_track->genre().data()->name(), QString( "28 Vocal" ) ); -} - -void TestMetaFileTrack::testSetGetComposer() -{ - QCOMPARE( m_track->composer().data()->name(), QString( "" ) ); - - m_track->setComposer( "test" ); - QCOMPARE( m_track->composer().data()->name(), QString( "test" ) ); - - m_track->setComposer( "Ludwig Van Beethoven" ); - QCOMPARE( m_track->composer().data()->name(), QString( "Ludwig Van Beethoven" ) ); - - m_track->setComposer( "Georg Friedrich Händel" ); - QCOMPARE( m_track->composer().data()->name(), QString( "Georg Friedrich Händel" ) ); - - m_track->setComposer( "" ); - QCOMPARE( m_track->composer().data()->name(), QString( "" ) ); -} - -void TestMetaFileTrack::testSetGetYear() -{ - QCOMPARE( m_track->composer().data()->name(), QString( "" ) ); - - m_track->setComposer( "test" ); - QCOMPARE( m_track->composer().data()->name(), QString( "test" ) ); - - m_track->setComposer( "2009" ); - QCOMPARE( m_track->composer().data()->name(), QString( "2009" ) ); - - m_track->setComposer( "1" ); - QCOMPARE( m_track->composer().data()->name(), QString( "1" ) ); - - m_track->setComposer( "0" ); - QCOMPARE( m_track->composer().data()->name(), QString( "0" ) ); - - m_track->setComposer( "-1" ); - QCOMPARE( m_track->composer().data()->name(), QString( "-1" ) ); - - m_track->setComposer( "" ); - QCOMPARE( m_track->composer().data()->name(), QString( "" ) ); -} - -void TestMetaFileTrack::testSetGetComment() -{ - QCOMPARE( m_track->comment(), QString( "" ) ); - - m_track->setComment( "test" ); - QCOMPARE( m_track->comment(), QString( "test" ) ); - - m_track->setComment( "2009" ); - QCOMPARE( m_track->comment(), QString( "2009" ) ); - - m_track->setComment( QString::fromUtf8( "Some Umlauts: äöü" ) ); - QCOMPARE( m_track->comment(), QString::fromUtf8( "Some Umlauts: äöü" ) ); - - m_track->setComment( "" ); - QCOMPARE( m_track->comment(), QString( "" ) ); -} - -void TestMetaFileTrack::testSetGetScore() -{ - // try with write back enabled... - AmarokConfig::setWriteBackStatistics( true ); - - Meta::StatisticsPtr statistics = m_track->statistics(); - QCOMPARE( statistics->score(), 0.0 ); - - /* now the code actually stores the score in track and then it reads it back. - * the precision it uses is pretty low and it was failing the qFuzzyCompare - * Just make it use qFuzzyCompare() */ - - statistics->setScore( 3 ); - QCOMPARE( float( statistics->score() ), float( 3.0 ) ); - - statistics->setScore( 12.55 ); - QCOMPARE( float( statistics->score() ), float( 12.55 ) ); - - statistics->setScore( 100 ); - QCOMPARE( float( statistics->score() ), float( 100.0 ) ); - - statistics->setScore( 0 ); - QCOMPARE( float( statistics->score() ), float( 0.0 ) ); - - // and with writeback disabled - AmarokConfig::setWriteBackStatistics( false ); - - statistics->setScore( 3 ); - QCOMPARE( float( statistics->score() ), float( 0.0 ) ); - - statistics->setScore( 12.55 ); - QCOMPARE( float( statistics->score() ), float( 0.0 ) ); -} - -void TestMetaFileTrack::testSetGetRating() -{ - // try with write back enabled... - AmarokConfig::setWriteBackStatistics( true ); - - Meta::StatisticsPtr statistics = m_track->statistics(); - QCOMPARE( m_track->statistics()->rating(), 0 ); - - m_track->statistics()->setRating( 1 ); - QCOMPARE( m_track->statistics()->rating(), 1 ); - - m_track->statistics()->setRating( 23 ); - QCOMPARE( m_track->statistics()->rating(), 23 ); // should this be possible? - - m_track->statistics()->setRating( 0 ); - QCOMPARE( m_track->statistics()->rating(), 0 ); - - // and with writeback disabled - AmarokConfig::setWriteBackStatistics( false ); - - m_track->statistics()->setRating( 1 ); - QCOMPARE( m_track->statistics()->rating(), 0 ); - - m_track->statistics()->setRating( 23 ); - QCOMPARE( m_track->statistics()->rating(), 0 ); -} - -void TestMetaFileTrack::testSetGetTrackNumber() -{ - QCOMPARE( m_track->trackNumber(), 0 ); - - m_track->setTrackNumber( 1 ); - QCOMPARE( m_track->trackNumber(), 1 ); - - m_track->setTrackNumber( 23 ); - QCOMPARE( m_track->trackNumber(), 23 ); - - m_track->setTrackNumber( -12 ); - QCOMPARE( m_track->trackNumber(), -12 ); // should this be possible? - - m_track->setTrackNumber( 0 ); - QCOMPARE( m_track->trackNumber(), 0 ); -} - -void TestMetaFileTrack::testSetGetDiscNumber() -{ - QCOMPARE( m_track->discNumber(), 0 ); - - m_track->setDiscNumber( 1 ); - QCOMPARE( m_track->discNumber(), 1 ); - - m_track->setDiscNumber( 23 ); - QCOMPARE( m_track->discNumber(), 23 ); - - m_track->setDiscNumber( -12 ); - QCOMPARE( m_track->discNumber(), -12 ); // should this be possible? - - m_track->setDiscNumber( 0 ); - QCOMPARE( m_track->discNumber(), 0 ); -} - -void TestMetaFileTrack::testLength() -{ - QCOMPARE( m_track->length(), 12000LL ); -} - -void TestMetaFileTrack::testFilesize() -{ - QCOMPARE( m_track->filesize(), 389454 ); -} - -void TestMetaFileTrack::testSampleRate() -{ - QCOMPARE( m_track->sampleRate(), 44100 ); -} - -void TestMetaFileTrack::testBitrate() -{ - QCOMPARE( m_track->bitrate(), 256 ); -} - -void TestMetaFileTrack::testSetGetLastPlayed() -{ - QSKIP( "lastPlayed reading/saving not (yet) available in MetaFile::Track", SkipAll ); - QCOMPARE( m_track->statistics()->lastPlayed(), QDateTime() ); - - m_track->finishedPlaying( 1.0 ); - QVERIFY( m_track->statistics()->lastPlayed().isValid() ); -} - -void TestMetaFileTrack::testSetGetFirstPlayed() -{ - QSKIP( "firstPlayed reading/saving not (yet) available in MetaFile::Track", SkipAll ); - QCOMPARE( m_track->statistics()->firstPlayed(), QDateTime() ); - - m_track->finishedPlaying( 1.0 ); - QVERIFY( m_track->statistics()->firstPlayed().isValid() ); -} - -void TestMetaFileTrack::testSetGetPlayCount() -{ - // try with write back enabled... - AmarokConfig::setWriteBackStatistics( true ); - - QCOMPARE( m_track->statistics()->playCount(), 0 ); - - m_track->finishedPlaying( 1.0 ); - QCOMPARE( m_track->statistics()->playCount(), 1 ); - - m_track->statistics()->setPlayCount( 0 ); - QCOMPARE( m_track->statistics()->playCount(), 0 ); - - // and with writeback disabled - AmarokConfig::setWriteBackStatistics( false ); - - m_track->finishedPlaying( 1.0 ); - QCOMPARE( m_track->statistics()->playCount(), 0 ); - - m_track->statistics()->setPlayCount( 12 ); - QCOMPARE( m_track->statistics()->playCount(), 0 ); -} - -void TestMetaFileTrack::testReplayGain() -{ - QCOMPARE( int(m_track->replayGain( Meta::ReplayGain_Track_Gain ) * 1000), -6655 ); - QCOMPARE( int(m_track->replayGain( Meta::ReplayGain_Album_Gain ) * 1000), -6655 ); - QCOMPARE( int(m_track->replayGain( Meta::ReplayGain_Track_Peak ) * 10000), 41263 ); - QCOMPARE( int(m_track->replayGain( Meta::ReplayGain_Album_Peak ) * 10000), 41263 ); -} - -void TestMetaFileTrack::testType() -{ - QCOMPARE( m_track->type(), QString( "mp3" ) ); -} - -void TestMetaFileTrack::testCreateDate() -{ - QFileInfo fi( m_tmpFileName ); - QDateTime created = fi.created(); - QCOMPARE( m_track->createDate(), created ); -} diff --git a/amarok/tests/core-impl/meta/file/TestMetaFileTrack.h b/amarok/tests/core-impl/meta/file/TestMetaFileTrack.h deleted file mode 100644 index 08bb2e4b..00000000 --- a/amarok/tests/core-impl/meta/file/TestMetaFileTrack.h +++ /dev/null @@ -1,84 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2009 Sven Krohlas * - * * - * This program 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 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#ifndef TESTMETAFILETRACK_H -#define TESTMETAFILETRACK_H - -#include "core-impl/meta/file/File.h" - -#include -#include - -class KTempDir; - -class TestMetaFileTrack : public QObject -{ -Q_OBJECT - -public: - TestMetaFileTrack(); - -private slots: - void initTestCase(); - void cleanupTestCase(); - - void init(); - - // methods inherited from Meta::Base - void testNameAndSetTitle(); - void testPrettyName(); - void testSortableName(); - - // methods inherited from Meta::Track - void testPlayableUrl(); - void testPrettyUrl(); - void testUidUrl(); - - void testIsPlayable(); - void testIsEditable(); - - void testSetGetAlbum(); - void testSetGetArtist(); - void testSetGetGenre(); - void testSetGetComposer(); - void testSetGetYear(); - void testSetGetComment(); - void testSetGetScore(); - void testSetGetRating(); - void testSetGetTrackNumber(); - void testSetGetDiscNumber(); - void testLength(); - void testFilesize(); - void testSampleRate(); - void testBitrate(); - void testSetGetLastPlayed(); - void testSetGetFirstPlayed(); - void testSetGetPlayCount(); - void testReplayGain(); - void testType(); - void testCreateDate(); - -private: - MetaFile::TrackPtr m_track; - KTempDir *m_tmpDir; - QString m_tmpFileName; - QString m_origTrackPath; -}; - -#endif // TESTMETAFILETRACK_H diff --git a/amarok/tests/core-impl/meta/multi/CMakeLists.txt b/amarok/tests/core-impl/meta/multi/CMakeLists.txt deleted file mode 100644 index 61babf51..00000000 --- a/amarok/tests/core-impl/meta/multi/CMakeLists.txt +++ /dev/null @@ -1,46 +0,0 @@ -include_directories( - ${AMAROK_TEST_TREE} - ${AMAROK_SOURCE_TREE} - ${AMAROK_UTILITY_TREE} - ${CMAKE_BINARY_DIR}/src - ${CMAKE_BINARY_DIR}/tests - ${AMAROK_COLLECTION_SUPPORT_DIR} - ${KDE4_INCLUDE_DIR} - ${QT_INCLUDES} - ${GOOGLEMOCK_INCLUDE_DIR} - ) - -#------------------------ Test MetaMultiTrack ----------------------------- - -set( testmetamultitrack_SRCS - TestMetaMultiTrack.cpp - ${AMAROK_SOURCE_TREE}/EngineController.cpp - ${AMAROK_SOURCE_TREE}/core/capabilities/BoundedPlaybackCapability.cpp - ${AMAROK_SOURCE_TREE}/core/capabilities/MultiSourceCapability.cpp - ${AMAROK_SOURCE_TREE}/core-impl/meta/multi/MultiTrack.cpp - ${AMAROK_SOURCE_TREE}/core-impl/capabilities/multisource/MultiSourceCapabilityImpl.cpp - ${AMAROK_SOURCE_TREE}/playback/PowerManager.cpp - ${GOOGLEMOCK_SRCS} - ) - - -kde4_add_unit_test( testmetamultitrack - ${testmetamultitrack_SRCS} - ) - -add_dependencies( testmetamultitrack amarokcore ) -add_dependencies( testmetamultitrack amaroklib ) - -target_link_libraries( testmetamultitrack - amarokcore - amaroklib - ${KDE4_KDECORE_LIBS} - ${KDE4_KDEUI_LIBS} - ${KDE4_KIO_LIBS} - ${KDE4_PHONON_LIBRARY} - ${KDE4_SOLID_LIBS} - ${KDE4_THREADWEAVER_LIBS} - ${QT_QTTEST_LIBRARY} - ${QT_QTCORE_LIBRARY} - ${GOOGLEMOCK_LIBRARIES} - ${CMAKE_DL_LIBS}) diff --git a/amarok/tests/core-impl/meta/multi/TestMetaMultiTrack.cpp b/amarok/tests/core-impl/meta/multi/TestMetaMultiTrack.cpp deleted file mode 100644 index 05250871..00000000 --- a/amarok/tests/core-impl/meta/multi/TestMetaMultiTrack.cpp +++ /dev/null @@ -1,175 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2009 Sven Krohlas * - * * - * This program 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 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#include "TestMetaMultiTrack.h" - -#include "core/support/Components.h" -#include "EngineController.h" -#include "config-amarok-test.h" -#include "core-impl/collections/support/CollectionManager.h" -#include "core-impl/meta/multi/MultiTrack.h" -#include "core-impl/playlists/types/file/PlaylistFileSupport.h" - -#include -#include -#include - -#include -#include - -QTEST_KDEMAIN( TestMetaMultiTrack, GUI ) - -TestMetaMultiTrack::TestMetaMultiTrack() - : m_testMultiTrack( 0 ) -{ -} - -void -TestMetaMultiTrack::tracksLoaded( Playlists::PlaylistPtr playlist ) -{ - emit tracksLoadedSignal( playlist ); -} - -void TestMetaMultiTrack::initTestCase() -{ - qRegisterMetaType( "Meta::TrackPtr" ); - - //apparently the engine controller is needed somewhere, or we will get a crash... - EngineController *controller = new EngineController(); - Amarok::Components::setEngineController( controller ); - - /* Collection manager needs to be instantiated in the main thread, but - * MetaProxy::Tracks used by playlist may trigger its creation in a different thread. - * Pre-create it explicitly */ - CollectionManager::instance(); - - const QString path = QString( AMAROK_TEST_DIR ) + "/data/playlists/test.pls"; - const QFileInfo file( QDir::toNativeSeparators( path ) ); - QVERIFY( file.exists() ); - const QString filePath = file.absoluteFilePath(); - m_playlist = Playlists::loadPlaylistFile( filePath ).data(); - QVERIFY( m_playlist ); // no playlist -> no test. that's life ;) - subscribeTo( m_playlist ); - m_playlist->triggerTrackLoad(); - if( m_playlist->trackCount() < 0 ) - QVERIFY( QTest::kWaitForSignal( this, SIGNAL(tracksLoadedSignal(Playlists::PlaylistPtr)), 5000 ) ); - - QCOMPARE( m_playlist->name(), QString("test.pls") ); - QCOMPARE( m_playlist->trackCount(), 4 ); - - // now wait for all MetaProxy::Tracks to actually load their real tracks: - NotifyObserversWaiter wainter( m_playlist->tracks().toSet() ); - QVERIFY( QTest::kWaitForSignal( &wainter, SIGNAL(done()), 5000 ) ); -} - -void -TestMetaMultiTrack::cleanupTestCase() -{ - // Wait for other jobs, like MetaProxys fetching meta data, to finish - ThreadWeaver::Weaver::instance()->finish(); -} - -void TestMetaMultiTrack::init() -{ - m_testMultiTrack = new Meta::MultiTrack( m_playlist ); -} - -void TestMetaMultiTrack::cleanup() -{ - delete m_testMultiTrack; -} - -void TestMetaMultiTrack::testSources() -{ - QStringList sources = m_testMultiTrack->sources(); - QCOMPARE( sources.size(), 4 ); - QCOMPARE( sources.at( 0 ), QString( "http://85.214.44.27:8000" ) ); - QCOMPARE( sources.at( 1 ), QString( "http://217.20.121.40:8000" ) ); - QCOMPARE( sources.at( 2 ), QString( "http://85.214.44.27:8100" ) ); - QCOMPARE( sources.at( 3 ), QString( "http://85.214.44.27:8200" ) ); -} - -void TestMetaMultiTrack::testSetSourceCurrentNextUrl() -{ - QCOMPARE( m_testMultiTrack->current(), 0 ); - QCOMPARE( m_testMultiTrack->playableUrl(), KUrl( "http://85.214.44.27:8000" ) ); - QCOMPARE( m_testMultiTrack->nextUrl(), KUrl( "http://217.20.121.40:8000" ) ); - - m_testMultiTrack->setSource( 1 ); - QCOMPARE( m_testMultiTrack->current(), 1 ); - QCOMPARE( m_testMultiTrack->playableUrl(), KUrl( "http://217.20.121.40:8000" ) ); - QCOMPARE( m_testMultiTrack->nextUrl(), KUrl( "http://85.214.44.27:8100" ) ); - - m_testMultiTrack->setSource( 2 ); - QCOMPARE( m_testMultiTrack->current(), 2 ); - QCOMPARE( m_testMultiTrack->playableUrl(), KUrl( "http://85.214.44.27:8100" ) ); - QCOMPARE( m_testMultiTrack->nextUrl(), KUrl( "http://85.214.44.27:8200" ) ); - - m_testMultiTrack->setSource( 3 ); - QCOMPARE( m_testMultiTrack->current(), 3 ); - QCOMPARE( m_testMultiTrack->playableUrl(), KUrl( "http://85.214.44.27:8200" ) ); - QCOMPARE( m_testMultiTrack->nextUrl(), KUrl() ); - - m_testMultiTrack->setSource( 4 ); - QCOMPARE( m_testMultiTrack->current(), 3 ); - m_testMultiTrack->setSource( -1 ); - QCOMPARE( m_testMultiTrack->current(), 3 ); -} - -void TestMetaMultiTrack::testHasCapabilityInterface() -{ - QVERIFY( m_testMultiTrack->hasCapabilityInterface( Capabilities::Capability::MultiSource ) ); -} - -NotifyObserversWaiter::NotifyObserversWaiter( const QSet &tracks, QObject *parent ) - : QObject( parent ) - , m_tracks( tracks ) -{ - // we need to filter already resovled tracks in the next event loop iteration because - // the user wouldn't be able to get the done() signal yet. - QTimer::singleShot( 0, this, SLOT(slotFilterResovled()) ); -} - -void -NotifyObserversWaiter::slotFilterResovled() -{ - QMutexLocker locker( &m_mutex ); - QMutableSetIterator it( m_tracks ); - while( it.hasNext() ) - { - const Meta::TrackPtr &track = it.next(); - const MetaProxy::Track *proxyTrack = dynamic_cast( track.data() ); - Q_ASSERT( proxyTrack ); - if( proxyTrack->isResolved() ) - it.remove(); - else - subscribeTo( track ); - } - if( m_tracks.isEmpty() ) - emit done(); -} - -void -NotifyObserversWaiter::metadataChanged( Meta::TrackPtr track ) -{ - QMutexLocker locker( &m_mutex ); - m_tracks.remove( track ); - if( m_tracks.isEmpty() ) - emit done(); -} diff --git a/amarok/tests/core-impl/meta/multi/TestMetaMultiTrack.h b/amarok/tests/core-impl/meta/multi/TestMetaMultiTrack.h deleted file mode 100644 index 30166f2e..00000000 --- a/amarok/tests/core-impl/meta/multi/TestMetaMultiTrack.h +++ /dev/null @@ -1,85 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2009 Sven Krohlas * - * * - * This program 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 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#ifndef TESTMETAMULTITRACK_H -#define TESTMETAMULTITRACK_H - -#include "core/meta/Observer.h" -#include "core/playlists/Playlist.h" - -#include - -namespace Meta { - class MultiTrack; -} - -class TestMetaMultiTrack : public QObject, private Playlists::PlaylistObserver -{ -Q_OBJECT - -public: - TestMetaMultiTrack(); - - virtual void tracksLoaded( Playlists::PlaylistPtr playlist ); - -signals: - void tracksLoadedSignal( Playlists::PlaylistPtr playlist ); - -private slots: - void initTestCase(); - void cleanupTestCase(); - - void init(); - void cleanup(); - - void testSources(); - void testSetSourceCurrentNextUrl(); - void testHasCapabilityInterface(); - -private: - Playlists::PlaylistPtr m_playlist; - Meta::MultiTrack *m_testMultiTrack; -}; - -/** - * A helper class that waits until all tracks have called notifyObservers at least once - * and then emits a signal done() - */ -class NotifyObserversWaiter : public QObject, private Meta::Observer -{ - Q_OBJECT - - public: - NotifyObserversWaiter( const QSet &tracks, QObject *parent = 0 ); - - signals: - void done(); - - private slots: - void slotFilterResovled(); - - private: - using Observer::metadataChanged; // silence gcc warning - virtual void metadataChanged( Meta::TrackPtr track ); - - QSet m_tracks; - QMutex m_mutex; -}; - -#endif // TESTMETAMULTITRACK_H diff --git a/amarok/tests/core-impl/playlists/CMakeLists.txt b/amarok/tests/core-impl/playlists/CMakeLists.txt deleted file mode 100644 index 3a2d2787..00000000 --- a/amarok/tests/core-impl/playlists/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -add_subdirectory( types ) diff --git a/amarok/tests/core-impl/playlists/types/CMakeLists.txt b/amarok/tests/core-impl/playlists/types/CMakeLists.txt deleted file mode 100644 index f646ccca..00000000 --- a/amarok/tests/core-impl/playlists/types/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -add_subdirectory( file ) diff --git a/amarok/tests/core-impl/playlists/types/file/CMakeLists.txt b/amarok/tests/core-impl/playlists/types/file/CMakeLists.txt deleted file mode 100644 index c3c82fcf..00000000 --- a/amarok/tests/core-impl/playlists/types/file/CMakeLists.txt +++ /dev/null @@ -1,40 +0,0 @@ -include_directories( . - ${AMAROK_TEST_TREE} - ${CMAKE_BINARY_DIR}/src - ${CMAKE_BINARY_DIR}/tests - ${KDE4_INCLUDE_DIR} -) - -#------------------------ Test ASXPlaylist ----------------------------- - -set( testasxplaylist_SRCS asx/TestASXPlaylist.cpp ) -kde4_add_unit_test( testasxplaylist ${testasxplaylist_SRCS} ) -target_link_libraries( testasxplaylist ${KDE4_THREADWEAVER_LIBS} ${KDE4_KDECORE_LIBS} ${QT_QTTEST_LIBRARY} ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} amarokcore amaroklib ) - -#------------------------ Test M3UPlaylist ----------------------------- - -set( testm3uplaylist_SRCS m3u/TestM3UPlaylist.cpp ) -kde4_add_unit_test( testm3uplaylist ${testm3uplaylist_SRCS} ) -target_link_libraries( testm3uplaylist ${KDE4_THREADWEAVER_LIBS} ${KDE4_KDECORE_LIBS} ${QT_QTTEST_LIBRARY} ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} amarokcore amaroklib ) - -#------------------------ Test PLSPlaylist ----------------------------- - -set( testplsplaylist_SRCS pls/TestPLSPlaylist.cpp ) -kde4_add_unit_test( testplsplaylist ${testplsplaylist_SRCS} ) -target_link_libraries( testplsplaylist ${KDE4_THREADWEAVER_LIBS} ${KDE4_KDECORE_LIBS} ${QT_QTTEST_LIBRARY} ${QT_QTCORE_LIBRARY} amarokcore amaroklib ) - -#------------------------ Test XSPFPLAYLIST ----------------------------- - -set( testxspfplaylist_SRCS xspf/TestXSPFPlaylist.cpp ) -kde4_add_unit_test( testxspfplaylist ${testxspfplaylist_SRCS} ) -target_link_libraries( testxspfplaylist ${KDE4_THREADWEAVER_LIBS} ${KDE4_KDECORE_LIBS} ${QT_QTTEST_LIBRARY} ${QT_QTCORE_LIBRARY} amarokcore amaroklib ) - -#------------------------ Test PlaylistFileSupport ----------------------------- - -set( testplaylistfilesupport_SRCS - TestPlaylistFileSupport.cpp - ${AMAROK_SOURCE_TREE}/core-impl/playlists/types/file/PlaylistFileSupport.cpp - ) -kde4_add_unit_test( testplaylistfilesupport ${testplaylistfilesupport_SRCS} ) -target_link_libraries( testplaylistfilesupport ${KDE4_KDECORE_LIBS} ${KDE4_KIO_LIBS} ${QT_QTTEST_LIBRARY} ${QT_QTCORE_LIBRARY} amarokcore amaroklib ) - diff --git a/amarok/tests/core-impl/playlists/types/file/TestPlaylistFileSupport.cpp b/amarok/tests/core-impl/playlists/types/file/TestPlaylistFileSupport.cpp deleted file mode 100644 index 315f0252..00000000 --- a/amarok/tests/core-impl/playlists/types/file/TestPlaylistFileSupport.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2009 Sven Krohlas * - * * - * This program 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 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#include "TestPlaylistFileSupport.h" -#include "config-amarok-test.h" -#include "core-impl/playlists/types/file/PlaylistFileSupport.h" -#include "core/playlists/PlaylistFormat.h" - -#include -#include - -#include - -QTEST_KDEMAIN_CORE( TestPlaylistFileSupport ) - -TestPlaylistFileSupport::TestPlaylistFileSupport() -{} - -void TestPlaylistFileSupport::initTestCase() -{ - const QDir dir( QDir::toNativeSeparators( QString( AMAROK_TEST_DIR ) + "/data/playlists" ) ); - QVERIFY( dir.exists() ); - m_testPlaylistPath = dir.absolutePath(); -} - -void TestPlaylistFileSupport::testGetFormat() -{ - QCOMPARE( Playlists::getFormat( m_testPlaylistPath + "test.asx" ), Playlists::ASX ); - QCOMPARE( Playlists::getFormat( m_testPlaylistPath + "test.m3u" ), Playlists::M3U ); - QCOMPARE( Playlists::getFormat( m_testPlaylistPath + "test.pls" ), Playlists::PLS ); - QCOMPARE( Playlists::getFormat( m_testPlaylistPath + "test.ram" ), Playlists::RAM ); - QCOMPARE( Playlists::getFormat( m_testPlaylistPath + "test.smil" ), Playlists::SMIL ); - // TODO: Playlists::XML <- what kind of playlist format is that? example? - QCOMPARE( Playlists::getFormat( m_testPlaylistPath + "test.xspf" ), Playlists::XSPF ); - QCOMPARE( Playlists::getFormat( m_testPlaylistPath + "no-playlist.png" ), Playlists::Unknown ); - QCOMPARE( Playlists::getFormat( m_testPlaylistPath + "no-playlist.png" ), Playlists::NotPlaylist ); -} - -void TestPlaylistFileSupport::testIsPlaylist() -{ - QCOMPARE( Playlists::isPlaylist( m_testPlaylistPath + "test.asx" ), true ); - QCOMPARE( Playlists::isPlaylist( m_testPlaylistPath + "test.m3u" ), true ); - QCOMPARE( Playlists::isPlaylist( m_testPlaylistPath + "test.pls" ), true ); - QCOMPARE( Playlists::isPlaylist( m_testPlaylistPath + "test.ram" ), true ); - QCOMPARE( Playlists::isPlaylist( m_testPlaylistPath + "test.smil" ), true ); - // TODO: Playlists::XML <- what kind of playlist format is that? example? - QCOMPARE( Playlists::isPlaylist( m_testPlaylistPath + "test.xspf" ), true ); - QCOMPARE( Playlists::isPlaylist( m_testPlaylistPath + "no-playlist.png" ), false ); -} - -#include "moc_TestPlaylistFileSupport.cpp" diff --git a/amarok/tests/core-impl/playlists/types/file/TestPlaylistFileSupport.h b/amarok/tests/core-impl/playlists/types/file/TestPlaylistFileSupport.h deleted file mode 100644 index 22135a55..00000000 --- a/amarok/tests/core-impl/playlists/types/file/TestPlaylistFileSupport.h +++ /dev/null @@ -1,43 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2009 Sven Krohlas * - * * - * This program 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 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#ifndef TESTPLAYLISTFILESUPPORT_H -#define TESTPLAYLISTFILESUPPORT_H - -#include -#include - -class TestPlaylistFileSupport : public QObject -{ -Q_OBJECT - -public: - TestPlaylistFileSupport(); - -private slots: - void initTestCase(); - void testGetFormat(); - void testIsPlaylist(); - -private: - QString m_testPlaylistPath; -}; - - -#endif // TESTPLAYLISTFILESUPPORT_H diff --git a/amarok/tests/core-impl/playlists/types/file/asx/TestASXPlaylist.cpp b/amarok/tests/core-impl/playlists/types/file/asx/TestASXPlaylist.cpp deleted file mode 100644 index f6d99033..00000000 --- a/amarok/tests/core-impl/playlists/types/file/asx/TestASXPlaylist.cpp +++ /dev/null @@ -1,159 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2013 Tatjana Gornak * - * * - * This program 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 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#include "TestASXPlaylist.h" - -#include "config-amarok-test.h" -#include "core/support/Components.h" -#include "core-impl/collections/support/CollectionManager.h" -#include "core-impl/playlists/types/file/asx/ASXPlaylist.h" -#include "EngineController.h" - -#include - -#include -#include -#include -#include - -#include -#include -#include - -QTEST_KDEMAIN_CORE( TestASXPlaylist ) - -TestASXPlaylist::TestASXPlaylist() -{ - KGlobal::locale(); -} - -QString -TestASXPlaylist::dataPath( const QString &relPath ) -{ - return QDir::toNativeSeparators( QString( AMAROK_TEST_DIR ) + '/' + relPath ); -} - -void -TestASXPlaylist::initTestCase() -{ - // EngineController is used in a connection in MetaProxy::Track; avoid null sender - // warning - EngineController *controller = new EngineController(); - Amarok::Components::setEngineController( controller ); - - qRegisterMetaType( "Meta::TrackPtr" ); - - /* Collection manager needs to be instantiated in the main thread, but - * MetaProxy::Tracks used by playlist may trigger its creation in a different thread. - * Pre-create it explicitly */ - CollectionManager::instance(); - - const KUrl url = dataPath( "data/playlists/test.asx" ); - QFile playlistFile1( url.toLocalFile() ); - QTextStream playlistStream; - - QString tempPath = KStandardDirs::locateLocal( "tmp", "test.asx" ); - QFile::remove( tempPath ); - QVERIFY( QFile::copy( url.toLocalFile(), tempPath ) ); - QVERIFY( QFile::exists( tempPath ) ); - - QVERIFY( playlistFile1.open( QFile::ReadOnly ) ); - playlistStream.setDevice( &playlistFile1 ); - QVERIFY( playlistStream.device() ); - - m_testPlaylist = new Playlists::ASXPlaylist( tempPath ); - QVERIFY( m_testPlaylist ); - QVERIFY( m_testPlaylist->load( playlistStream ) ); - QCOMPARE( m_testPlaylist->tracks().size(), 1 ); - playlistFile1.close(); -} - -void -TestASXPlaylist::cleanupTestCase() -{ - // Wait for other jobs, like MetaProxys fetching meta data, to finish - ThreadWeaver::Weaver::instance()->finish(); - - delete m_testPlaylist; - delete Amarok::Components::setEngineController( 0 ); -} - -void -TestASXPlaylist::testSetAndGetName() -{ - QCOMPARE( m_testPlaylist->prettyName(), QString( "test.asx" ) ); - - QCOMPARE( m_testPlaylist->name(), QString( "test.asx" ) ); - - m_testPlaylist->setName( "set name test.asx" ); - QCOMPARE( m_testPlaylist->name(), QString( "set name test.asx" ) ); - - m_testPlaylist->setName( "set name test aäoöuüß.asx" ); - QCOMPARE( m_testPlaylist->name(), QString( "set name test aäoöuüß.asx" ) ); - - m_testPlaylist->setName( "test" ); - m_testPlaylist->setName( "" ); - QCOMPARE( m_testPlaylist->name(), QString( "test.asx" ) ); -} - -void -TestASXPlaylist::testTracks() -{ - Meta::TrackList tracklist = m_testPlaylist->tracks(); - - QCOMPARE( tracklist.size(), 1 ); - QCOMPARE( tracklist.at( 0 ).data()->name(), QString( ":: Willkommen bei darkerradio - Tune in, turn on, burn out" ) ); -} - -void -TestASXPlaylist::testUidUrl() -{ - QString tempPath = KStandardDirs::locateLocal( "tmp", "test.asx" ); - //we have chaged the name around so much, better reset it - m_testPlaylist->setName( "test" ); - QCOMPARE( m_testPlaylist->uidUrl().pathOrUrl(), tempPath ); -} - -void -TestASXPlaylist::testSetAndGetGroups() -{ - QStringList grouplist; - QStringList newGrouplist; - - grouplist = m_testPlaylist->groups(); - QCOMPARE( grouplist.size(), 0 ); - - newGrouplist.append( "test" ); - m_testPlaylist->setGroups( newGrouplist ); - grouplist = m_testPlaylist->groups(); - QCOMPARE( grouplist.size(), 1 ); - QCOMPARE( grouplist.at(0), QString( "test" ) ); -} - -void -TestASXPlaylist::testIsWritable() -{ - QVERIFY( m_testPlaylist->isWritable() ); -} - -void -TestASXPlaylist::testSave() -{ - QVERIFY( m_testPlaylist->save( false ) ); -} diff --git a/amarok/tests/core-impl/playlists/types/file/asx/TestASXPlaylist.h b/amarok/tests/core-impl/playlists/types/file/asx/TestASXPlaylist.h deleted file mode 100644 index b5929d9f..00000000 --- a/amarok/tests/core-impl/playlists/types/file/asx/TestASXPlaylist.h +++ /dev/null @@ -1,51 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2013 Tatjana Gornak * - * * - * This program 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 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#ifndef TESTASXPLAYLIST_H -#define TESTASXPLAYLIST_H - -#include -#include - -namespace Playlists { class ASXPlaylist; } - -class TestASXPlaylist : public QObject -{ -Q_OBJECT - -public: - TestASXPlaylist(); - -private slots: - void initTestCase(); - void cleanupTestCase(); - - void testSetAndGetName(); - void testTracks(); - void testUidUrl(); - void testSetAndGetGroups(); - void testIsWritable(); - void testSave(); - -private: - Playlists::ASXPlaylist *m_testPlaylist; - QString dataPath( const QString &relPath = QString() ); -}; - -#endif // TESTASXPLAYLIST_H diff --git a/amarok/tests/core-impl/playlists/types/file/m3u/TestM3UPlaylist.cpp b/amarok/tests/core-impl/playlists/types/file/m3u/TestM3UPlaylist.cpp deleted file mode 100644 index 42765f40..00000000 --- a/amarok/tests/core-impl/playlists/types/file/m3u/TestM3UPlaylist.cpp +++ /dev/null @@ -1,145 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2009 Sven Krohlas * - * * - * This program 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 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#include "TestM3UPlaylist.h" -#include "config-amarok-test.h" -#include "core-impl/collections/support/CollectionManager.h" -#include "core-impl/playlists/types/file/m3u/M3UPlaylist.h" - -#include - -#include -#include -#include -#include - -#include -#include -#include - -QTEST_KDEMAIN_CORE( TestM3UPlaylist ) - -TestM3UPlaylist::TestM3UPlaylist() -{ - KGlobal::locale(); -} - -QString -TestM3UPlaylist::dataPath( const QString &relPath ) -{ - return QDir::toNativeSeparators( QString( AMAROK_TEST_DIR ) + '/' + relPath ); -} - -void TestM3UPlaylist::initTestCase() -{ - qRegisterMetaType( "Meta::TrackPtr" ); - - /* Collection manager needs to be instantiated in the main thread, but - * MetaProxy::Tracks used by playlist may trigger its creation in a different thread. - * Pre-create it explicitly */ - CollectionManager::instance(); - - const KUrl url = dataPath( "data/playlists/test.m3u" ); - QFile playlistFile1( url.toLocalFile() ); - QTextStream playlistStream; - - QString tempPath = KStandardDirs::locateLocal( "tmp", "test.m3u" ); - QFile::remove( tempPath ); - QVERIFY( QFile::copy( url.toLocalFile(), tempPath ) ); - QVERIFY( QFile::exists( tempPath ) ); - - QVERIFY( playlistFile1.open( QFile::ReadOnly ) ); - playlistStream.setDevice( &playlistFile1 ); - QVERIFY( playlistStream.device() ); - - m_testPlaylist = new Playlists::M3UPlaylist( tempPath ); - QVERIFY( m_testPlaylist ); - QVERIFY( m_testPlaylist->load( playlistStream ) ); - QCOMPARE( m_testPlaylist->tracks().size(), 10 ); - playlistFile1.close(); -} - -void TestM3UPlaylist::cleanupTestCase() -{ - // Wait for other jobs, like MetaProxys fetching meta data, to finish - ThreadWeaver::Weaver::instance()->finish(); - - delete m_testPlaylist; -} - -void TestM3UPlaylist::testSetAndGetName() -{ - QCOMPARE( m_testPlaylist->prettyName(), QString( "test.m3u" ) ); - - QCOMPARE( m_testPlaylist->name(), QString( "test.m3u" ) ); - - m_testPlaylist->setName( "set name test" ); - QCOMPARE( m_testPlaylist->name(), QString( "set name test.m3u" ) ); - - m_testPlaylist->setName( "set name test aäoöuüß.m3u" ); - QCOMPARE( m_testPlaylist->name(), QString( "set name test aäoöuüß.m3u" ) ); - - m_testPlaylist->setName( "test" ); - m_testPlaylist->setName( "" ); - QCOMPARE( m_testPlaylist->name(), QString( "test.m3u" ) ); -} - -void TestM3UPlaylist::testTracks() -{ - Meta::TrackList tracklist = m_testPlaylist->tracks(); - - QCOMPARE( tracklist.size(), 10 ); - QCOMPARE( tracklist.at( 0 ).data()->name(), QString( "Platz 01" ) ); - QCOMPARE( tracklist.at( 1 ).data()->name(), QString( "Platz 02" ) ); - QCOMPARE( tracklist.at( 2 ).data()->name(), QString( "Platz 03" ) ); - QCOMPARE( tracklist.at( 9 ).data()->name(), QString( "Platz 10" ) ); -} - -void TestM3UPlaylist::testUidUrl() -{ - QString tempPath = KStandardDirs::locateLocal( "tmp", "test.m3u" ); - //we have chaged the name around so much, better reset it - m_testPlaylist->setName( "test" ); - QCOMPARE( m_testPlaylist->uidUrl().pathOrUrl(), tempPath ); -} - -void TestM3UPlaylist::testSetAndGetGroups() -{ - QStringList grouplist; - QStringList newGrouplist; - - grouplist = m_testPlaylist->groups(); - QCOMPARE( grouplist.size(), 0 ); - - newGrouplist.append( "test" ); - m_testPlaylist->setGroups( newGrouplist ); - grouplist = m_testPlaylist->groups(); - QCOMPARE( grouplist.size(), 1 ); - QCOMPARE( grouplist.at(0), QString( "test" ) ); -} - -void TestM3UPlaylist::testIsWritable() -{ - QVERIFY( m_testPlaylist->isWritable() ); -} - -void TestM3UPlaylist::testSave() -{ - QVERIFY( m_testPlaylist->save( false ) ); -} diff --git a/amarok/tests/core-impl/playlists/types/file/m3u/TestM3UPlaylist.h b/amarok/tests/core-impl/playlists/types/file/m3u/TestM3UPlaylist.h deleted file mode 100644 index c4d8a9d1..00000000 --- a/amarok/tests/core-impl/playlists/types/file/m3u/TestM3UPlaylist.h +++ /dev/null @@ -1,51 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2009 Sven Krohlas * - * * - * This program 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 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#ifndef TESTM3UPLAYLIST_H -#define TESTM3UPLAYLIST_H - -#include -#include - -namespace Playlists { class M3UPlaylist; } - -class TestM3UPlaylist : public QObject -{ -Q_OBJECT - -public: - TestM3UPlaylist(); - -private slots: - void initTestCase(); - void cleanupTestCase(); - - void testSetAndGetName(); - void testTracks(); - void testUidUrl(); - void testSetAndGetGroups(); - void testIsWritable(); - void testSave(); - -private: - Playlists::M3UPlaylist *m_testPlaylist; - QString dataPath( const QString &relPath = QString() ); -}; - -#endif // TESTM3UPLAYLIST_H diff --git a/amarok/tests/core-impl/playlists/types/file/pls/TestPLSPlaylist.cpp b/amarok/tests/core-impl/playlists/types/file/pls/TestPLSPlaylist.cpp deleted file mode 100644 index 6e7e6975..00000000 --- a/amarok/tests/core-impl/playlists/types/file/pls/TestPLSPlaylist.cpp +++ /dev/null @@ -1,135 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2009 Sven Krohlas * - * * - * This program 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 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#include "TestPLSPlaylist.h" - -#include "core/support/Components.h" -#include "config-amarok-test.h" -#include "core-impl/collections/support/CollectionManager.h" -#include "core-impl/playlists/types/file/pls/PLSPlaylist.h" -#include "EngineController.h" - -#include -#include -#include - -#include -#include -#include - -QTEST_KDEMAIN_CORE( TestPLSPlaylist ) - -TestPLSPlaylist::TestPLSPlaylist() -{} - -QString -TestPLSPlaylist::dataPath( const QString &relPath ) -{ - return QDir::toNativeSeparators( QString( AMAROK_TEST_DIR ) + '/' + relPath ); -} - -void TestPLSPlaylist::initTestCase() -{ - // EngineController is used in a connection in MetaProxy::Track; avoid null sender - // warning - EngineController *controller = new EngineController(); - Amarok::Components::setEngineController( controller ); - - qRegisterMetaType( "Meta::TrackPtr" ); - - /* Collection manager needs to be instantiated in the main thread, but - * MetaProxy::Tracks used by playlist may trigger its creation in a different thread. - * Pre-create it explicitly */ - CollectionManager::instance(); - - const QString testPls = "data/playlists/test.pls"; - const KUrl url = dataPath( testPls ); - QFile playlistFile1( url.toLocalFile() ); - QTextStream playlistStream; - - QString tempPath = KStandardDirs::locateLocal( "tmp", "test.pls" ); - QFile::remove( tempPath ); - QVERIFY( QFile::copy( url.toLocalFile(), tempPath ) ); - QVERIFY( QFile::exists( tempPath ) ); - - QVERIFY( playlistFile1.open( QFile::ReadOnly ) ); - playlistStream.setDevice( &playlistFile1 ); - QVERIFY( playlistStream.device() ); - - m_testPlaylist1 = new Playlists::PLSPlaylist( tempPath ); - QVERIFY( m_testPlaylist1 ); - QVERIFY( m_testPlaylist1->load( playlistStream ) ); - QCOMPARE( m_testPlaylist1->tracks().size(), 4 ); - playlistFile1.close(); -} - -void TestPLSPlaylist::cleanupTestCase() -{ - // Wait for other jobs, like MetaProxys fetching meta data, to finish - ThreadWeaver::Weaver::instance()->finish(); - - delete m_testPlaylist1; - delete Amarok::Components::setEngineController( 0 ); -} - -void TestPLSPlaylist::testSetAndGetName() -{ - QCOMPARE( m_testPlaylist1->name(), QString( "test.pls" ) ); - - m_testPlaylist1->setName( "set name test" ); - QCOMPARE( m_testPlaylist1->name(), QString( "set name test.pls" ) ); - - m_testPlaylist1->setName( "set name test aäoöuüß" ); - QCOMPARE( m_testPlaylist1->name(), QString( "set name test aäoöuüß.pls" ) ); - - m_testPlaylist1->setName( "test" ); - m_testPlaylist1->setName( "" ); - QCOMPARE( m_testPlaylist1->name(), QString( "test.pls" ) ); -} - -void TestPLSPlaylist::testPrettyName() -{ - QCOMPARE( m_testPlaylist1->prettyName(), QString( "test.pls" ) ); -} - -void TestPLSPlaylist::testTracks() -{ - Meta::TrackList tracklist = m_testPlaylist1->tracks(); - - QCOMPARE( tracklist.at( 0 ).data()->name(), QString( "::darkerradio:: - DIE Alternative im Netz ::www.darkerradio.de:: Tune In, Turn On, Burn Out!" ) ); - QCOMPARE( tracklist.at( 1 ).data()->name(), QString( "::darkerradio:: - DIE Alternative im Netz ::www.darkerradio.de:: Tune In, Turn On, Burn Out!" ) ); - QCOMPARE( tracklist.at( 2 ).data()->name(), QString( "::darkerradio:: - DIE Alternative im Netz ::www.darkerradio.de:: Tune In, Turn On, Burn Out!" ) ); - QCOMPARE( tracklist.at( 3 ).data()->name(), QString( "::darkerradio:: - DIE Alternative im Netz ::www.darkerradio.de:: Tune In, Turn On, Burn Out!" ) ); -} - -void TestPLSPlaylist::testUidUrl() -{ - QString tempPath = KStandardDirs::locateLocal( "tmp", "test.pls" ); - m_testPlaylist1->setName( "test" ); - QCOMPARE( m_testPlaylist1->uidUrl().pathOrUrl(), tempPath ); -} -void TestPLSPlaylist::testIsWritable() -{ - QVERIFY( m_testPlaylist1->isWritable() ); -} - -void TestPLSPlaylist::testSave() -{ - QVERIFY( m_testPlaylist1->save( false ) ); -} diff --git a/amarok/tests/core-impl/playlists/types/file/pls/TestPLSPlaylist.h b/amarok/tests/core-impl/playlists/types/file/pls/TestPLSPlaylist.h deleted file mode 100644 index 75928bec..00000000 --- a/amarok/tests/core-impl/playlists/types/file/pls/TestPLSPlaylist.h +++ /dev/null @@ -1,53 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2009 Sven Krohlas * - * * - * This program 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 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#ifndef TESTPLSPLAYLIST_H -#define TESTPLSPLAYLIST_H - -#include -#include - -namespace Playlists { -class PLSPlaylist; -} - -class TestPLSPlaylist : public QObject -{ -Q_OBJECT - -public: - TestPLSPlaylist(); - -private slots: - void initTestCase(); - void cleanupTestCase(); - - void testSetAndGetName(); - void testPrettyName(); - void testTracks(); - void testUidUrl(); - void testIsWritable(); - void testSave(); - -private: - Playlists::PLSPlaylist *m_testPlaylist1; - QString dataPath( const QString &relPath ); -}; - -#endif // TESTPLSPLAYLIST_H diff --git a/amarok/tests/core-impl/playlists/types/file/xspf/TestXSPFPlaylist.cpp b/amarok/tests/core-impl/playlists/types/file/xspf/TestXSPFPlaylist.cpp deleted file mode 100644 index bb405dac..00000000 --- a/amarok/tests/core-impl/playlists/types/file/xspf/TestXSPFPlaylist.cpp +++ /dev/null @@ -1,336 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2009 Sven Krohlas * - * * - * This program 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 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#include "TestXSPFPlaylist.h" - -#include "config-amarok-test.h" -#include "EngineController.h" -#include "core/support/Components.h" -#include "core-impl/collections/support/CollectionManager.h" -#include "core-impl/playlists/types/file/xspf/XSPFPlaylist.h" - -#include -#include -#include - -#include -#include -#include -#include - -QTEST_KDEMAIN_CORE( TestXSPFPlaylist ) - -TestXSPFPlaylist::TestXSPFPlaylist() -{} - -QString -TestXSPFPlaylist::dataPath( const QString &relPath ) -{ - return QDir::toNativeSeparators( QString( AMAROK_TEST_DIR ) + '/' + relPath ); -} - - -void TestXSPFPlaylist::initTestCase() -{ - // EngineController is used in a connection in MetaProxy::Track; avoid null sender - // warning - EngineController *controller = new EngineController(); - Amarok::Components::setEngineController( controller ); - - qRegisterMetaType( "Meta::TrackPtr" ); - - /* Collection manager needs to be instantiated in the main thread, but - * MetaProxy::Tracks used by playlist may trigger its creation in a different thread. - * Pre-create it explicitly */ - CollectionManager::instance(); - - const QString testXspf = "data/playlists/test.xspf"; - const KUrl url = dataPath( testXspf ); - QFile playlistFile1( url.toLocalFile() ); - QTextStream playlistStream1; - - QVERIFY( playlistFile1.open( QFile::ReadOnly ) ); - playlistStream1.setDevice( &playlistFile1 ); - QVERIFY( playlistStream1.device() ); - - qDebug() << "got playlist path: " << url.url(); - - //we need to copy this laylist file to a temp dir as some of the tests we do will delete/overwrite it - QString tempPath = KStandardDirs::locateLocal( "tmp", "test.xspf" ); - qDebug() << "got temp path: " << tempPath; - QFile::remove( tempPath ); - QVERIFY( QFile::copy( url.toLocalFile(), tempPath ) ); - QVERIFY( QFile::exists( tempPath ) ); - - m_testPlaylist1 = new Playlists::XSPFPlaylist( tempPath ); - QVERIFY( m_testPlaylist1 ); - QVERIFY( m_testPlaylist1->load( playlistStream1 ) ); -} - -void TestXSPFPlaylist::cleanupTestCase() -{ - QFile::remove( KStandardDirs::locateLocal( "tmp", "test.xspf" ) ); - // Wait for other jobs, like MetaProxys fetching meta data, to finish - ThreadWeaver::Weaver::instance()->finish(); - - delete m_testPlaylist1; - delete Amarok::Components::setEngineController( 0 ); -} - -void TestXSPFPlaylist::testSetAndGetName() -{ - QCOMPARE( m_testPlaylist1->name(), QString( "my playlist" ) ); - - m_testPlaylist1->setName( "test" ); - QCOMPARE( m_testPlaylist1->name(), QString( "test" ) ); - - m_testPlaylist1->setName( "test aäoöuüß" ); - QCOMPARE( m_testPlaylist1->name(), QString( "test aäoöuüß" ) ); - - m_testPlaylist1->setName( "" ); - QCOMPARE( m_testPlaylist1->name(), QString( "" ) ); -} - -void TestXSPFPlaylist::prettyName() -{ - QCOMPARE( m_testPlaylist1->prettyName(), QString( "" ) ); -} - -void TestXSPFPlaylist::testSetAndGetTracks() -{ - Meta::TrackList tracklist = m_testPlaylist1->tracks(); - - QCOMPARE( tracklist.size(), 23 ); - QCOMPARE( tracklist.at( 0 ).data()->name(), QString( "Sunset" ) ); - QCOMPARE( tracklist.at( 1 ).data()->name(), QString( "Heaven" ) ); - QCOMPARE( tracklist.at( 2 ).data()->name(), QString( "Liquid Sun" ) ); - QCOMPARE( tracklist.at( 3 ).data()->name(), QString( "Restrained Mind" ) ); - QCOMPARE( tracklist.at( 22 ).data()->name(), QString( "Trash Bag" ) ); -} - -void TestXSPFPlaylist::testSetAndGetTitle() -{ - QCOMPARE( m_testPlaylist1->title(), QString( "" ) ); - - m_testPlaylist1->setTitle( "test" ); - QCOMPARE( m_testPlaylist1->title(), QString( "test" ) ); - - m_testPlaylist1->setTitle( "test aäoöuüß" ); - QCOMPARE( m_testPlaylist1->title(), QString( "test aäoöuüß" ) ); - - m_testPlaylist1->setTitle( "" ); - QCOMPARE( m_testPlaylist1->title(), QString( "" ) ); -} - -void TestXSPFPlaylist::testSetAndGetCreator() -{ - QCOMPARE( m_testPlaylist1->creator(), QString( "" ) ); - - m_testPlaylist1->setCreator( "test" ); - QCOMPARE( m_testPlaylist1->creator(), QString( "test" ) ); - - m_testPlaylist1->setCreator( "test aäoöuüß" ); - QCOMPARE( m_testPlaylist1->creator(), QString( "test aäoöuüß" ) ); - - m_testPlaylist1->setCreator( "" ); - QCOMPARE( m_testPlaylist1->creator(), QString( "" ) ); -} - -void TestXSPFPlaylist::testSetAndGetAnnotation() -{ - QCOMPARE( m_testPlaylist1->annotation(), QString( "" ) ); - - m_testPlaylist1->setAnnotation( "test" ); - QCOMPARE( m_testPlaylist1->annotation(), QString( "test" ) ); - - m_testPlaylist1->setAnnotation( "test aäoöuüß" ); - QCOMPARE( m_testPlaylist1->annotation(), QString( "test aäoöuüß" ) ); - - m_testPlaylist1->setAnnotation( "" ); - QCOMPARE( m_testPlaylist1->annotation(), QString( "" ) ); -} - -void TestXSPFPlaylist::testSetAndGetInfo() -{ - KUrl testUrl; - - QCOMPARE( m_testPlaylist1->info().pathOrUrl(), QString( "" ) ); - - testUrl = "http://amarok.kde.org"; - m_testPlaylist1->setInfo( testUrl ); - QCOMPARE( m_testPlaylist1->info().pathOrUrl(), KUrl( testUrl ).pathOrUrl() ); - - testUrl = "http://öko.de"; - m_testPlaylist1->setInfo( testUrl ); - QCOMPARE( m_testPlaylist1->info().pathOrUrl(), KUrl( testUrl ).pathOrUrl() ); - - testUrl = ""; - m_testPlaylist1->setInfo( testUrl ); - QCOMPARE( m_testPlaylist1->info().pathOrUrl(), KUrl( "" ).pathOrUrl() ); -} - -void TestXSPFPlaylist::testSetAndGetLocation() -{ - KUrl testUrl; - - QCOMPARE( m_testPlaylist1->location().pathOrUrl(), QString( "" ) ); - - testUrl = "http://amarok.kde.org"; - m_testPlaylist1->setLocation( testUrl ); - QCOMPARE( m_testPlaylist1->location().pathOrUrl(), KUrl( testUrl ).pathOrUrl() ); - - testUrl = "http://öko.de"; - m_testPlaylist1->setLocation( testUrl ); - QCOMPARE( m_testPlaylist1->location().pathOrUrl(), KUrl( testUrl ).pathOrUrl() ); - - testUrl = ""; - m_testPlaylist1->setLocation( testUrl ); - QCOMPARE( m_testPlaylist1->location().pathOrUrl(), KUrl( "" ).pathOrUrl() ); -} - -void TestXSPFPlaylist::testSetAndGetIdentifier() -{ - QCOMPARE( m_testPlaylist1->identifier(), QString( "" ) ); - - m_testPlaylist1->setIdentifier( "test" ); - QCOMPARE( m_testPlaylist1->identifier(), QString( "test" ) ); - - m_testPlaylist1->setIdentifier( "test aäoöuüß" ); - QCOMPARE( m_testPlaylist1->identifier(), QString( "test aäoöuüß" ) ); - - m_testPlaylist1->setIdentifier( "" ); - QCOMPARE( m_testPlaylist1->identifier(), QString( "" ) ); -} - -void TestXSPFPlaylist::testSetAndGetImage() -{ - KUrl testUrl; - - QCOMPARE( m_testPlaylist1->image().pathOrUrl(), QString( "" ) ); - - testUrl = "http://amarok.kde.org"; - m_testPlaylist1->setImage( testUrl ); - QCOMPARE( m_testPlaylist1->image().pathOrUrl(), KUrl( testUrl ).pathOrUrl() ); - - testUrl = "http://öko.de"; - m_testPlaylist1->setImage( testUrl ); - QCOMPARE( m_testPlaylist1->image().pathOrUrl(), KUrl( testUrl ).pathOrUrl() ); - - testUrl = ""; - m_testPlaylist1->setImage( testUrl ); - QCOMPARE( m_testPlaylist1->image().pathOrUrl(), KUrl( "" ).pathOrUrl() ); -} - -void TestXSPFPlaylist::testSetAndGetDate() -{ - QDateTime testDateTime; - QCOMPARE( m_testPlaylist1->date().toString(), QString( "" ) ); - - testDateTime = QDateTime::fromString( "2009/08/13 13:57:18", "yyyy/MM/dd hh:mm:ss" ); - m_testPlaylist1->setDate( testDateTime ); - QCOMPARE( m_testPlaylist1->date(), testDateTime ); - - testDateTime = QDateTime::fromString( "", "" ); - m_testPlaylist1->setDate( testDateTime ); - QCOMPARE( m_testPlaylist1->date(), testDateTime ); -} - -void TestXSPFPlaylist::testSetAndGetLicense() -{ - KUrl testUrl; - - QCOMPARE( m_testPlaylist1->license().pathOrUrl(), QString( "" ) ); - - testUrl = "http://amarok.kde.org"; - m_testPlaylist1->setLicense( testUrl ); - QCOMPARE( m_testPlaylist1->license().pathOrUrl(), KUrl( testUrl ).pathOrUrl() ); - - testUrl = "http://öko.de"; - m_testPlaylist1->setLicense( testUrl ); - QCOMPARE( m_testPlaylist1->license().pathOrUrl(), KUrl( testUrl ).pathOrUrl() ); - - testUrl = ""; - m_testPlaylist1->setLicense( testUrl ); - QCOMPARE( m_testPlaylist1->license().pathOrUrl(), KUrl( "" ).pathOrUrl() ); -} - -void TestXSPFPlaylist::testSetAndGetAttribution() -{ - KUrl testUrl; - - QCOMPARE( m_testPlaylist1->attribution().size(), 0 ); - - testUrl = "http://amarok.kde.org"; - m_testPlaylist1->setAttribution( testUrl ); - QCOMPARE( m_testPlaylist1->attribution().size(), 1 ); - QCOMPARE( m_testPlaylist1->attribution().at( 0 ).pathOrUrl(), KUrl( testUrl ).pathOrUrl() ); - - testUrl = "http://öko.de"; - m_testPlaylist1->setAttribution( testUrl ); - QCOMPARE( m_testPlaylist1->attribution().size(), 2 ); - QCOMPARE( m_testPlaylist1->attribution().at( 0 ).pathOrUrl(), KUrl( testUrl ).pathOrUrl() ); - QCOMPARE( m_testPlaylist1->attribution().at( 1 ).pathOrUrl(), KUrl( "http://amarok.kde.org" ).pathOrUrl() ); - - testUrl = "http://test.com"; - m_testPlaylist1->setAttribution( testUrl, false ); - QCOMPARE( m_testPlaylist1->attribution().size(), 1 ); - QCOMPARE( m_testPlaylist1->attribution().at( 0 ).pathOrUrl(), KUrl( testUrl ).pathOrUrl() ); - - testUrl = ""; - m_testPlaylist1->setAttribution( testUrl ); - QCOMPARE( m_testPlaylist1->attribution().size(), 1 ); // empty url won't be added, but size is 1 from last addition -} - -void TestXSPFPlaylist::testSetAndGetLink() -{ - KUrl testUrl; - - QCOMPARE( m_testPlaylist1->link().pathOrUrl(), QString( "" ) ); - - testUrl = "http://amarok.kde.org"; - m_testPlaylist1->setLink( testUrl ); - QCOMPARE( m_testPlaylist1->link().pathOrUrl(), KUrl( testUrl ).pathOrUrl() ); - - testUrl = "http://öko.de"; - m_testPlaylist1->setLink( testUrl ); - QCOMPARE( m_testPlaylist1->link().pathOrUrl(), KUrl( testUrl ).pathOrUrl() ); - - testUrl = ""; - m_testPlaylist1->setLink( testUrl ); - QCOMPARE( m_testPlaylist1->link().pathOrUrl(), QString( "" ) ); -} - -void TestXSPFPlaylist::testUidUrl() -{ - QString tempPath = KStandardDirs::locateLocal( "tmp", "test.xspf" ); - - //we have chaged the name around so much, better reset it - m_testPlaylist1->setName( "test" ); - QCOMPARE( m_testPlaylist1->uidUrl().pathOrUrl(), tempPath ); -} - -void TestXSPFPlaylist::testIsWritable() -{ - QVERIFY( m_testPlaylist1->isWritable() ); -} - -void TestXSPFPlaylist::testSave() -{ - QVERIFY( m_testPlaylist1->save( false ) ); -} diff --git a/amarok/tests/core-impl/playlists/types/file/xspf/TestXSPFPlaylist.h b/amarok/tests/core-impl/playlists/types/file/xspf/TestXSPFPlaylist.h deleted file mode 100644 index d409d870..00000000 --- a/amarok/tests/core-impl/playlists/types/file/xspf/TestXSPFPlaylist.h +++ /dev/null @@ -1,64 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2009 Sven Krohlas * - * * - * This program 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 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#ifndef TESTXSPFPLAYLIST_H -#define TESTXSPFPLAYLIST_H - -#include -#include - -namespace Playlists { - class XSPFPlaylist; -} - -class TestXSPFPlaylist : public QObject -{ -Q_OBJECT - -public: - TestXSPFPlaylist(); - -private slots: - void initTestCase(); - void cleanupTestCase(); - - void testSetAndGetName(); - void prettyName(); - void testSetAndGetTracks(); - void testSetAndGetTitle(); - void testSetAndGetCreator(); - void testSetAndGetAnnotation(); - void testSetAndGetInfo(); - void testSetAndGetLocation(); - void testSetAndGetIdentifier(); - void testSetAndGetImage(); - void testSetAndGetDate(); - void testSetAndGetLicense(); - void testSetAndGetAttribution(); - void testSetAndGetLink(); - void testUidUrl(); - void testIsWritable(); - void testSave(); - -private: - Playlists::XSPFPlaylist *m_testPlaylist1; - QString dataPath( const QString &relPath ); -}; - -#endif // TESTXSPFPLAYLIST_H diff --git a/amarok/tests/core-impl/support/CMakeLists.txt b/amarok/tests/core-impl/support/CMakeLists.txt deleted file mode 100644 index 93ee3f48..00000000 --- a/amarok/tests/core-impl/support/CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ -#------------------------ Test TrackLoader ----------------------------- - -kde4_add_unit_test( testtrackloader TestTrackLoader.cpp ) - -target_link_libraries( testtrackloader - amarokcore - amaroklib - ${KDE4_KDECORE_LIBS} - ${QT_QTTEST_LIBRARY} - ${QT_QTCORE_LIBRARY} - ${KDE4_THREADWEAVER_LIBS} -) diff --git a/amarok/tests/core-impl/support/TestTrackLoader.cpp b/amarok/tests/core-impl/support/TestTrackLoader.cpp deleted file mode 100644 index ce369e25..00000000 --- a/amarok/tests/core-impl/support/TestTrackLoader.cpp +++ /dev/null @@ -1,170 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2009 Sven Krohlas * - * Copyright (c) 2013 Matěj Laitl * - * * - * This program 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 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#include "TestTrackLoader.h" - -#include "config-amarok-test.h" -#include "core/meta/Meta.h" -#include "core-impl/collections/support/CollectionManager.h" -#include "core-impl/meta/proxy/MetaProxy.h" -#include "core-impl/playlists/types/file/PlaylistFileSupport.h" -#include "core-impl/support/TrackLoader.h" - -#include -#include - -QTEST_KDEMAIN_CORE( TestTrackLoader ) - -void -TestTrackLoader::initTestCase() -{ - qRegisterMetaType(); - qRegisterMetaType(); - CollectionManager::instance(); // create in the main thread - KGlobal::locale(); // ditto -} - -void -TestTrackLoader::cleanupTestCase() -{ - // Wait for other jobs, like MetaProxys fetching meta data, to finish - ThreadWeaver::Weaver::instance()->finish(); -} - -void -TestTrackLoader::testFullMetadataInit() -{ - typedef QPair StringIntPair; - QList pathsCounts; - pathsCounts << qMakePair( dataPath( "data/audio/album" ), 3 ) - << qMakePair( dataPath( "data/audio/album2" ), 2 ) - << qMakePair( dataPath( "data/playlists/test.asx" ), 1 ) - << qMakePair( dataPath( "data/playlists/test.m3u" ), 10 ) - << qMakePair( dataPath( "data/playlists/test.pls" ), 4 ) - << qMakePair( dataPath( "data/playlists/test.xspf" ), 23 ); - - // it is more probable to get unresolved MetaProxy::Track for small runs: - foreach( const StringIntPair &pair, pathsCounts ) - { - TrackLoader *loader = new TrackLoader( TrackLoader::FullMetadataRequired ); - QSignalSpy spy( loader, SIGNAL(finished(Meta::TrackList)) ); - loader->init( KUrl( pair.first ) ); - if( spy.isEmpty() ) - QVERIFY2( QTest::kWaitForSignal( loader, SIGNAL(finished(Meta::TrackList)), 5000 ), - "loader did not finish within timeout" ); - - Meta::TrackList found = spy.first().first().value(); - QCOMPARE( found.count(), pair.second ); - foreach( const Meta::TrackPtr &track, found ) - { - MetaProxy::TrackPtr proxyTrack = MetaProxy::TrackPtr::dynamicCast( track ); - if( !proxyTrack ) - { - qDebug() << track->prettyUrl() << "is not a MetaProxy::Track. Strange and we cannot test it"; - continue; - } - QVERIFY2( proxyTrack->isResolved(), proxyTrack->prettyUrl().toLocal8Bit().data() ); - } - } -} - -void -TestTrackLoader::testInit() -{ - TrackLoader *loader1 = new TrackLoader(); - QSignalSpy spy1( loader1, SIGNAL(finished(Meta::TrackList)) ); - loader1->init( KUrl( dataPath( "data/audio" ) ) ); // test the convenience overload - if( spy1.isEmpty() ) - QVERIFY2( QTest::kWaitForSignal( loader1, SIGNAL(finished(Meta::TrackList)), 5000 ), - "loader1 did not finish within timeout" ); - Meta::TrackList found = spy1.first().first().value(); - QCOMPARE( found.count(), 15 ); - QVERIFY2( found.at( 0 )->uidUrl().endsWith( "audio/album/Track01.ogg" ), found.at( 0 )->uidUrl().toLocal8Bit().data() ); - QVERIFY2( found.at( 1 )->uidUrl().endsWith( "audio/album/Track02.ogg" ), found.at( 1 )->uidUrl().toLocal8Bit().data() ); - QVERIFY2( found.at( 2 )->uidUrl().endsWith( "audio/album/Track03.ogg" ), found.at( 2 )->uidUrl().toLocal8Bit().data() ); - QVERIFY2( found.at( 3 )->uidUrl().endsWith( "audio/album2/Track01.ogg" ), found.at( 3 )->uidUrl().toLocal8Bit().data() ); - QVERIFY2( found.at( 4 )->uidUrl().endsWith( "audio/album2/Track02.ogg" ), found.at( 4 )->uidUrl().toLocal8Bit().data() ); - QVERIFY2( found.at( 5 )->uidUrl().endsWith( "audio/Platz%2001.mp3" ), found.at( 5 )->uidUrl().toLocal8Bit().data() ); - QVERIFY2( found.at( 10 )->uidUrl().endsWith( "audio/Platz%2006.mp3" ), found.at( 10 )->uidUrl().toLocal8Bit().data() ); - QVERIFY2( found.at( 14 )->uidUrl().endsWith( "audio/Platz%2010.mp3" ), found.at( 14 )->uidUrl().toLocal8Bit().data() ); - - TrackLoader *loader2 = new TrackLoader(); - QSignalSpy spy2( loader2, SIGNAL(finished(Meta::TrackList)) ); - loader2->init( QList() << KUrl( dataPath( "data/audio/album2" ) ) ); - if( spy2.isEmpty() ) - QVERIFY2( QTest::kWaitForSignal( loader2, SIGNAL(finished(Meta::TrackList)), 5000 ), - "loader2 did not finish within timeout" ); - found = spy2.first().first().value(); - QCOMPARE( found.count(), 2 ); - QVERIFY2( found.at( 0 )->uidUrl().endsWith( "audio/album2/Track01.ogg" ), found.at( 0 )->uidUrl().toLocal8Bit().data() ); - QVERIFY2( found.at( 1 )->uidUrl().endsWith( "audio/album2/Track02.ogg" ), found.at( 1 )->uidUrl().toLocal8Bit().data() ); -} - -void -TestTrackLoader::testInitWithPlaylists() -{ - TrackLoader *loader = new TrackLoader(); - QSignalSpy spy( loader, SIGNAL(finished(Meta::TrackList)) ); - QList urls; - urls << KUrl( dataPath( "data/playlists/test.asx" ) ) - << KUrl( dataPath( "data/audio/album" ) ) - << KUrl( dataPath( "data/playlists/test.xspf" ) ); - loader->init( urls ); - if( spy.isEmpty() ) - QVERIFY2( QTest::kWaitForSignal( loader, SIGNAL(finished(Meta::TrackList)), 5000 ), - "loader did not finish within timeout" ); - - Meta::TrackList found = spy.first().first().value(); - QCOMPARE( found.count(), 1 + 3 + 23 ); - QCOMPARE( found.at( 0 )->uidUrl(), QString( "http://85.214.44.27:8000" ) ); // test.asx playlist - QVERIFY( found.at( 1 )->uidUrl().endsWith( "/audio/album/Track01.ogg" ) ); // "audio/album" folder - QVERIFY( found.at( 2 )->uidUrl().endsWith( "/audio/album/Track02.ogg" ) ); - QVERIFY( found.at( 3 )->uidUrl().endsWith( "/audio/album/Track03.ogg" ) ); - QCOMPARE( found.at( 4 )->uidUrl(), QString( "http://he3.magnatune.com/all/01-Sunset-Ammonite.ogg" ) ); // start of test.xspf playlist - QCOMPARE( found.at( 5 )->uidUrl(), QString( "http://he3.magnatune.com/all/02-Heaven-Ammonite.ogg" ) ); -} - -void -TestTrackLoader::testDirectlyPassingPlaylists() -{ - using namespace Playlists; - TrackLoader *loader = new TrackLoader(); - QSignalSpy spy( loader, SIGNAL(finished(Meta::TrackList)) ); - PlaylistList playlists; - playlists << PlaylistPtr::staticCast( loadPlaylistFile( KUrl( dataPath( "data/playlists/test.asx" ) ) ) ) - << PlaylistPtr::staticCast( loadPlaylistFile( KUrl( dataPath( "data/playlists/test.xspf" ) ) ) ); - loader->init( playlists ); - if( spy.isEmpty() ) - QVERIFY2( QTest::kWaitForSignal( loader, SIGNAL(finished(Meta::TrackList)), 5000 ), - "loader did not finish within timeout" ); - - Meta::TrackList found = spy.first().first().value(); - QCOMPARE( found.count(), 1 + 23 ); - QCOMPARE( found.at( 0 )->uidUrl(), QString( "http://85.214.44.27:8000" ) ); // test.asx playlist - QCOMPARE( found.at( 1 )->uidUrl(), QString( "http://he3.magnatune.com/all/01-Sunset-Ammonite.ogg" ) ); // start of test.xspf playlist - QCOMPARE( found.at( 2 )->uidUrl(), QString( "http://he3.magnatune.com/all/02-Heaven-Ammonite.ogg" ) ); - -} - -QString -TestTrackLoader::dataPath( const QString &relPath ) -{ - return QDir::toNativeSeparators( QString( AMAROK_TEST_DIR ) + '/' + relPath ); -} diff --git a/amarok/tests/core-impl/support/TestTrackLoader.h b/amarok/tests/core-impl/support/TestTrackLoader.h deleted file mode 100644 index 8fac7298..00000000 --- a/amarok/tests/core-impl/support/TestTrackLoader.h +++ /dev/null @@ -1,44 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2009 Sven Krohlas * - * Copyright (c) 2013 Matěj Laitl * - * * - * This program 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 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#ifndef TESTTRACKLOADER_H -#define TESTTRACKLOADER_H - -#include - -class TestTrackLoader : public QObject -{ - Q_OBJECT - - private slots: - void initTestCase(); - void cleanupTestCase(); - - // this in intentionally on top so that it is executed first - void testFullMetadataInit(); - void testInit(); - void testInitWithPlaylists(); - void testDirectlyPassingPlaylists(); - - private: - QString dataPath( const QString &relPath ); -}; - -#endif // TESTTRACKLOADER_H diff --git a/amarok/tests/core/CMakeLists.txt b/amarok/tests/core/CMakeLists.txt deleted file mode 100644 index f3e5c64d..00000000 --- a/amarok/tests/core/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -add_subdirectory( capabilities ) -add_subdirectory( collections ) -add_subdirectory( interfaces ) -add_subdirectory( meta ) -add_subdirectory( playlists ) diff --git a/amarok/tests/core/capabilities/CMakeLists.txt b/amarok/tests/core/capabilities/CMakeLists.txt deleted file mode 100644 index ee70cd6f..00000000 --- a/amarok/tests/core/capabilities/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -include_directories( . - ${AMAROK_TEST_TREE} - ${CMAKE_BINARY_DIR}/tests -) - -#------------------------ Test ActionsCapability ----------------------------- - -set( testactionscapability_SRCS TestActionsCapability.cpp ) -kde4_add_unit_test( testactionscapability ${testactionscapability_SRCS} ) -target_link_libraries( testactionscapability ${KDE4_KDECORE_LIBS} ${QT_QTGUI_LIBRARY} ${QT_QTTEST_LIBRARY} amarokcore amaroklib ) diff --git a/amarok/tests/core/capabilities/TestActionsCapability.cpp b/amarok/tests/core/capabilities/TestActionsCapability.cpp deleted file mode 100644 index 60b3768a..00000000 --- a/amarok/tests/core/capabilities/TestActionsCapability.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Jasneet Singh Bhatti * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "TestActionsCapability.h" - -#include - -#include - -QTEST_KDEMAIN_CORE( TestActionsCapability ) - -TestActionsCapability::TestActionsCapability() -{ -} - -void -TestActionsCapability::testActions() -{ - QAction *action1 = new QAction( this ); - QAction *action2 = new QAction( this ); - QAction *action3 = new QAction( this ); - QAction *action4 = new QAction( this ); - QAction *action5 = new QAction( this ); - - QList actions; - actions<actions() == actions ); -} - -void -TestActionsCapability::testCapabilityInterfaceType() -{ - QList actions; - - Capabilities::ActionsCapability *actions_capability = new Capabilities::ActionsCapability( actions ); - QVERIFY( actions_capability ); - - QVERIFY( actions_capability->capabilityInterfaceType() == Capabilities::Capability::Actions ); -} - -#include "moc_TestActionsCapability.cpp" diff --git a/amarok/tests/core/capabilities/TestActionsCapability.h b/amarok/tests/core/capabilities/TestActionsCapability.h deleted file mode 100644 index 8801f85f..00000000 --- a/amarok/tests/core/capabilities/TestActionsCapability.h +++ /dev/null @@ -1,43 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Jasneet Singh Bhatti * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef TESTACTIONSCAPABILITY_H -#define TESTACTIONSCAPABILITY_H - -#include "amarok_export.h" -#include "core/capabilities/Capability.h" - -#include -#include -#include - -#include - -class TestActionsCapability : public QObject -{ - Q_OBJECT - -public: - TestActionsCapability(); - -private slots: - void testActions(); - void testCapabilityInterfaceType(); - -private: - QList< QAction* > m_actions; -}; - -#endif // TESTACTIONSCAPABILITY_H diff --git a/amarok/tests/core/collections/CMakeLists.txt b/amarok/tests/core/collections/CMakeLists.txt deleted file mode 100644 index 376c0cc2..00000000 --- a/amarok/tests/core/collections/CMakeLists.txt +++ /dev/null @@ -1,51 +0,0 @@ -add_subdirectory( support ) - -include_directories( - .. - ${AMAROK_SOURCE_TREE} - ${AMAROK_SOURCE_TREE}/collection - ${AMAROK_SOURCE_TREE}/meta - ${CMAKE_BINARY_DIR}/src - ${AMAROK_COLLECTION_SUPPORT_DIR} - ${KDE4_INCLUDE_DIR} - ${QT_INCLUDES} - ${GOOGLEMOCK_INCLUDE_DIR} - ) - -#------------------------ Test CollectionLocation ----------------------------- - -set( testcollectionlocation_SRCS - CollectionLocationTest.cpp - ${GOOGLEMOCK_SRCS} - ) - -kde4_add_unit_test( testcollectionlocation TESTNAME amarok-testcollectionlocation ${testcollectionlocation_SRCS} ) - -add_dependencies( testcollectionlocation amarokconfig_h ) -add_dependencies( testcollectionlocation amarokcore) -add_dependencies( testcollectionlocation amaroklib) - -if(APPLE) - SET_TARGET_PROPERTIES(testcollectionlocation PROPERTIES LINK_FLAGS "-undefined dynamic_lookup") -endif(APPLE) - -target_link_libraries(testcollectionlocation - amarokcore - amaroklib - ${KDE4_KDECORE_LIBS} - ${KDE4_KDEUI_LIBS} - ${KDE4_KIO_LIBS} - ${QT_QTTEST_LIBRARY} - ${GOOGLEMOCK_LIBRARIES}) - -#------------------------ Test Collection ----------------------------- - -set( testcollection_SRCS TestCollection.cpp ) -kde4_add_unit_test( testcollection ${testcollection_SRCS} ) -target_link_libraries( testcollection ${KDE4_KDECORE_LIBS} ${KDE4_KDEUI_LIBS} ${QT_QTTEST_LIBRARY} amarokcore ) - -#------------------------ Test QueryMaker ----------------------------- - -set( testquerymaker_SRCS TestQueryMaker.cpp ../../mocks/MockQueryMaker.cpp ) -kde4_add_unit_test( testquerymaker ${testquerymaker_SRCS} ) -target_link_libraries( testquerymaker ${KDE4_KDECORE_LIBS} ${QT_QTGUI_LIBRARY} ${QT_QTTEST_LIBRARY} amarokcore ) diff --git a/amarok/tests/core/collections/CollectionLocationTest.cpp b/amarok/tests/core/collections/CollectionLocationTest.cpp deleted file mode 100644 index 82defc23..00000000 --- a/amarok/tests/core/collections/CollectionLocationTest.cpp +++ /dev/null @@ -1,186 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009,2010 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "CollectionLocationTest.h" - -#include "core/support/Components.h" -#include "core/collections/CollectionLocation.h" -#include "core/support/Debug.h" -#include "core/meta/support/MetaConstants.h" -#include "../tests/mocks/MetaMock.h" -#include "MockCollectionLocationDelegate.h" - -#include -#include - -#include -#include - -#include - -#include - -QTEST_KDEMAIN_CORE( CollectionLocationTest ) - -using ::testing::Return; -using ::testing::AnyNumber; -using ::testing::_; - -CollectionLocationTest::CollectionLocationTest() -{ - KCmdLineArgs::init( KGlobal::activeComponent().aboutData() ); - ::testing::InitGoogleMock( &KCmdLineArgs::qtArgc(), KCmdLineArgs::qtArgv() ); - qRegisterMetaType(); - qRegisterMetaType(); - qRegisterMetaType(); -} - -namespace Collections { - -class TestRemoveCL : public CollectionLocation -{ -public: - - void removeUrlsFromCollection( const Meta::TrackList &tracks ) - { - count += tracks.count(); - slotRemoveOperationFinished(); - } - - MOCK_CONST_METHOD0( isWritable, bool() ); - MOCK_CONST_METHOD0( isOrganizable, bool() ); - - int count; -}; - -} //namespace Collections - -void CollectionLocationTest::testSuccessfulCopy() -{ - Collections::MockCollectionLocationDelegate *cld = new Collections::MockCollectionLocationDelegate(); - EXPECT_CALL( *cld, reallyDelete( _, _) ).Times( AnyNumber() ).WillRepeatedly( Return( true ) ); - Amarok::Components::setCollectionLocationDelegate( cld ); - - Collections::TestRemoveCL *cl = new Collections::TestRemoveCL(); - EXPECT_CALL( *cl, isWritable() ).Times( AnyNumber() ).WillRepeatedly( Return( true ) ); - cl->setProperty( "removeSources", true ); - cl->count = 0; - QVariantMap map; - map.insert( Meta::Field::URL, KUrl( "file:///IDoNotExist.mp3" ) ); - Meta::TrackPtr file1( new MetaMock( map ) ); - cl->transferSuccessful( file1 ); - - QVERIFY2( cl->metaObject()->invokeMethod( cl, "slotFinishCopy", Qt::DirectConnection ), "Calling slot failed" ); - QCOMPARE( cl->count, 1 ); - QVERIFY( QTest::kWaitForSignal( cl, SIGNAL(destroyed()), 500 ) ); - delete Amarok::Components::setCollectionLocationDelegate( 0 ); -} - -void CollectionLocationTest::testFailedCopy() -{ - Collections::MockCollectionLocationDelegate *cld = new Collections::MockCollectionLocationDelegate(); - EXPECT_CALL( *cld, reallyDelete( _, _) ).Times( AnyNumber() ).WillRepeatedly( Return( true ) ); - EXPECT_CALL( *cld, errorDeleting( _, _ ) ).Times( AnyNumber() ); - Amarok::Components::setCollectionLocationDelegate( cld ); - - Collections::TestRemoveCL *cl = new Collections::TestRemoveCL(); - EXPECT_CALL( *cl, isWritable() ).Times( AnyNumber() ).WillRepeatedly( Return( true ) ); - cl->setProperty( "removeSources", true ); - cl->count = 0; - QVariantMap map; - map.insert( Meta::Field::URL, KUrl( "file:///IDoNotExist.mp3" ) ); - Meta::TrackPtr file1( new MetaMock( map ) ); - cl->transferError( file1, "Test of CollectionLocation" ); - - QVERIFY2( cl->metaObject()->invokeMethod( cl, "slotFinishCopy", Qt::DirectConnection ), "Calling slot failed" ); - QCOMPARE( cl->count, 0 ); - QVERIFY( QTest::kWaitForSignal( cl, SIGNAL(destroyed()), 500 ) ); - delete Amarok::Components::setCollectionLocationDelegate( 0 ); -} - -void CollectionLocationTest::testCopyMultipleTracks() -{ - Collections::MockCollectionLocationDelegate *cld = new Collections::MockCollectionLocationDelegate(); - EXPECT_CALL( *cld, reallyDelete( _, _) ).Times( AnyNumber() ).WillRepeatedly( Return( true ) ); - EXPECT_CALL( *cld, errorDeleting( _, _ ) ).Times( AnyNumber() ); - Amarok::Components::setCollectionLocationDelegate( cld ); - - Collections::TestRemoveCL *cl = new Collections::TestRemoveCL(); - EXPECT_CALL( *cl, isWritable() ).Times( AnyNumber() ).WillRepeatedly( Return( true ) ); - - cl->setProperty( "removeSources", true ); - cl->count = 0; - QVariantMap map; - map.insert( Meta::Field::URL, KUrl( "file:///IDoNotExist.mp3" ) ); - Meta::TrackPtr file1( new MetaMock( map ) ); - map.insert( Meta::Field::URL, KUrl( "file:///IDoNotExistAsWell.mp3" ) ); - Meta::TrackPtr file2( new MetaMock( map ) ); - map.insert( Meta::Field::URL, KUrl( "file:///IDoNotExistAsWell.mp3" ) ); - Meta::TrackPtr file3( new MetaMock( map ) ); - cl->transferError( file1, "Test of CollectionLocation" ); - cl->transferSuccessful( file2 ); - cl->transferSuccessful( file3 ); - - cl->metaObject()->invokeMethod( cl, "slotFinishCopy", Qt::DirectConnection ); - QCOMPARE( cl->count, 2 ); - QVERIFY( QTest::kWaitForSignal( cl, SIGNAL(destroyed()), 500 ) ); - delete Amarok::Components::setCollectionLocationDelegate( 0 ); -} - -void CollectionLocationTest::testFailedCopyWithIncorrectUsageOfCopySuccesful() -{ - Collections::MockCollectionLocationDelegate *cld = new Collections::MockCollectionLocationDelegate(); - EXPECT_CALL( *cld, reallyDelete( _, _) ).Times( AnyNumber() ).WillRepeatedly( Return( true ) ); - EXPECT_CALL( *cld, errorDeleting( _, _ ) ).Times( AnyNumber() ); - Amarok::Components::setCollectionLocationDelegate( cld ); - - Collections::TestRemoveCL *cl = new Collections::TestRemoveCL(); - EXPECT_CALL( *cl, isWritable() ).Times( AnyNumber() ).WillRepeatedly( Return( true ) ); - cl->setProperty( "removeSources", true ); - cl->count = 0; - QVariantMap map; - map.insert( Meta::Field::URL, KUrl( "file:///IDoNotExist.mp3" ) ); - Meta::TrackPtr file1( new MetaMock( map ) ); - cl->transferError( file1, "Test of CollectionLocation" ); - cl->transferSuccessful( file1 ); - - cl->metaObject()->invokeMethod( cl, "slotFinishCopy", Qt::DirectConnection ); - QVERIFY2( cl->count == 0, "Expected no call to remove"); - - QVERIFY( QTest::kWaitForSignal( cl, SIGNAL(destroyed()), 500 ) ); - delete Amarok::Components::setCollectionLocationDelegate( 0 ); - - cld = new Collections::MockCollectionLocationDelegate(); - EXPECT_CALL( *cld, reallyDelete( _, _) ).Times( AnyNumber() ).WillRepeatedly( Return( true ) ); - EXPECT_CALL( *cld, errorDeleting( _, _ ) ).Times( AnyNumber() ); - Amarok::Components::setCollectionLocationDelegate( cld ); - - cl = new Collections::TestRemoveCL(); - EXPECT_CALL( *cl, isWritable() ).Times( AnyNumber() ).WillRepeatedly( Return( true ) ); - cl->setProperty( "removeSources", true ); - cl->count = 0; - file1 = Meta::TrackPtr( new MetaMock( map ) ); - cl->transferSuccessful( file1 ); - cl->transferError( file1, "Test of CollectionLocation" ); - - cl->metaObject()->invokeMethod( cl, "slotFinishCopy", Qt::DirectConnection ); - QVERIFY2( cl->count == 0, "Expected no call to remove after reversed method call"); - QVERIFY( QTest::kWaitForSignal( cl, SIGNAL(destroyed()), 500 ) ); - delete Amarok::Components::setCollectionLocationDelegate( 0 ); -} - -#include "moc_CollectionLocationTest.cpp" - diff --git a/amarok/tests/core/collections/CollectionLocationTest.h b/amarok/tests/core/collections/CollectionLocationTest.h deleted file mode 100644 index 784ff923..00000000 --- a/amarok/tests/core/collections/CollectionLocationTest.h +++ /dev/null @@ -1,37 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef COLLECTIONLOCATIONTEST_H -#define COLLECTIONLOCATIONTEST_H - -#include - -class CollectionLocationTest : public QObject -{ - Q_OBJECT -public: - CollectionLocationTest(); - -private slots: - - void testSuccessfulCopy(); - void testFailedCopy(); - void testCopyMultipleTracks(); - void testFailedCopyWithIncorrectUsageOfCopySuccesful(); - -}; - -#endif // COLLECTIONLOCATIONTEST_H diff --git a/amarok/tests/core/collections/MockCollectionLocationDelegate.h b/amarok/tests/core/collections/MockCollectionLocationDelegate.h deleted file mode 100644 index a2f45047..00000000 --- a/amarok/tests/core/collections/MockCollectionLocationDelegate.h +++ /dev/null @@ -1,47 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - - - - - -#ifndef MOCKCOLLECTIONLOCATIONDELEGATE_H -#define MOCKCOLLECTIONLOCATIONDELEGATE_H - -#include "core/collections/CollectionLocationDelegate.h" - -#undef kWarning // WORKAROUND: Prevent symbols clash with KDE's kWarning macro -#include - -namespace Collections { - -class MockCollectionLocationDelegate : public CollectionLocationDelegate -{ -public: - MOCK_CONST_METHOD2( reallyDelete, bool( CollectionLocation *loc, const Meta::TrackList &tracks ) ); - MOCK_CONST_METHOD2( reallyMove, bool( CollectionLocation *loc, const Meta::TrackList &tracks ) ); - MOCK_CONST_METHOD2( reallyTrash, bool( CollectionLocation *loc, const Meta::TrackList &tracks ) ); - MOCK_CONST_METHOD2( errorDeleting, void( CollectionLocation *loc, const Meta::TrackList &tracks ) ); - MOCK_CONST_METHOD1( notWriteable, void( CollectionLocation *loc ) ); - MOCK_CONST_METHOD1( deleteEmptyDirs, bool( CollectionLocation *loc ) ); - MOCK_CONST_METHOD5( transcode, Transcoding::Configuration( - const QStringList &playableFileTypes, bool *remember, OperationType operation, - const QString &destCollectionName, const Transcoding::Configuration &prevConfiguration ) ); -}; - -} //namespace Collections - -#endif diff --git a/amarok/tests/core/collections/TestCollection.cpp b/amarok/tests/core/collections/TestCollection.cpp deleted file mode 100644 index 72a8b3bb..00000000 --- a/amarok/tests/core/collections/TestCollection.cpp +++ /dev/null @@ -1,167 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Jasneet Singh Bhatti * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "TestCollection.h" - -#include "core/capabilities/ActionsCapability.h" -#include "core/capabilities/BookmarkThisCapability.h" -#include "core/collections/Collection.h" -#include "core/collections/CollectionLocation.h" - -#include -#include - -using namespace Collections; - -/** - * Ad-hoc mock to test location() method of Collection - */ -class CollectionMock : public Collection -{ - public: - /** - * Mock implementations of pure virtual methods of class Collections::Collection - * to enable creation of an instance of this mock class - * - * NOT TO BE USED ANYWHERE IN THE TEST - */ - virtual QueryMaker *queryMaker() - { - Q_ASSERT_X( false, __PRETTY_FUNCTION__, "should not be called"); - return 0; - } - - virtual QString collectionId() const - { - Q_ASSERT_X( false, __PRETTY_FUNCTION__, "should not be called"); - return QString(); - } - - virtual QString prettyName() const - { - Q_ASSERT_X( false, __PRETTY_FUNCTION__, "should not be called"); - return QString(); - } - - virtual KIcon icon() const - { - Q_ASSERT_X( false, __PRETTY_FUNCTION__, "should not be called"); - return KIcon(); - } -}; - -/** - * Ad-hoc mock to reimplement isWritable() and isOrganizable() methods of - * CollectionLocation to incorporate multiple test cases - */ -class CollectionLocationMock : public CollectionLocation -{ - public: - virtual bool isWritable() const - { - QFETCH( bool, isWritable ); - return isWritable; - } - - virtual bool isOrganizable() const - { - QFETCH( bool, isOrganizable ); - return isOrganizable; - } -}; - -/** - * Ad-hoc mock to test isWritable() and isOrganizable() methods of Collection - * with multiple test cases - */ -class TestingCollectionMock : public CollectionMock -{ - public: - virtual Collections::CollectionLocation *location() - { - return new CollectionLocationMock(); - } -}; - - -QTEST_KDEMAIN_CORE( TestCollection ) - -void -TestCollection::initTestCase() -{ - m_collection1 = new CollectionMock(); - m_collection2 = new TestingCollectionMock(); - m_trackProvider = new TrackProvider(); -} - -void -TestCollection::cleanupTestCase() -{ - delete( m_collection1 ); - delete( m_collection2 ); - delete( m_trackProvider ); -} - -// TrackProvider -void -TestCollection::testTrackForUrl() -{ - // Always returns a shared pointer pointing to null by default - KUrl url; - QVERIFY( m_trackProvider->trackForUrl( url ).isNull() ); -} - -// Collection -void -TestCollection::testLocation() -{ - CollectionLocation *collectionLocation = m_collection1->location(); - QVERIFY( collectionLocation ); - delete( collectionLocation ); -} - -void -TestCollection::testIsWritable_data() -{ - QTest::addColumn( "isWritable" ); - - QTest::newRow( "true value" ) << true; - QTest::newRow( "false value" ) << false; -} - -void -TestCollection::testIsWritable() -{ - CollectionLocationMock *collectionLocationMock = new CollectionLocationMock(); - QCOMPARE( m_collection2->isWritable(), collectionLocationMock->isWritable() ); - delete( collectionLocationMock ); -} - -void -TestCollection::testIsOrganizable_data() -{ - QTest::addColumn( "isOrganizable" ); - - QTest::newRow( "true value" ) << true; - QTest::newRow( "false value" ) << false; -} - -void -TestCollection::testIsOrganizable() -{ - CollectionLocationMock *collectionLocationMock = new CollectionLocationMock(); - QCOMPARE( m_collection2->isOrganizable(), collectionLocationMock->isOrganizable() ); - delete( collectionLocationMock ); -} diff --git a/amarok/tests/core/collections/TestCollection.h b/amarok/tests/core/collections/TestCollection.h deleted file mode 100644 index b13590b4..00000000 --- a/amarok/tests/core/collections/TestCollection.h +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Jasneet Singh Bhatti * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef TESTCOLLECTION_H -#define TESTCOLLECTION_H - -#include - -namespace Collections -{ - class Collection; - class TrackProvider; - -class TestCollection : public QObject -{ - Q_OBJECT - - private slots: - void initTestCase(); - void cleanupTestCase(); - - // TrackProvider - void testTrackForUrl(); - - //Collection - void testLocation(); - - /** - * Contains different return values for isWritable() to be tested with - */ - void testIsWritable_data(); - void testIsWritable(); - - /** - * Contains different return values for isWritable() to be tested with - */ - void testIsOrganizable_data(); - void testIsOrganizable(); - - private: - Collection *m_collection1, *m_collection2; - TrackProvider *m_trackProvider; -}; - -} //namespace Collections - -#endif // TESTCOLLECTION_H diff --git a/amarok/tests/core/collections/TestQueryMaker.cpp b/amarok/tests/core/collections/TestQueryMaker.cpp deleted file mode 100644 index 37b24fc8..00000000 --- a/amarok/tests/core/collections/TestQueryMaker.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Jasneet Singh Bhatti * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "TestQueryMaker.h" - -#include "mocks/MockQueryMaker.h" - -#include - -#include - -using namespace Collections; - - -QTEST_KDEMAIN_CORE( TestQueryMaker ) - -void -TestQueryMaker::initTestCase() -{ - m_mockQueryMaker = new MockQueryMaker(); - QVERIFY( m_mockQueryMaker ); -} - -void -TestQueryMaker::cleanupTestCase() -{ - delete m_mockQueryMaker; -} - -void -TestQueryMaker::testSetAutoDelete_data() -{ - QTest::addColumn( "autoDelete" ); - - QTest::newRow( "true value" ) << true; - QTest::newRow( "false value" ) << false; -} - -void -TestQueryMaker::testSetAutoDelete() -{ - QFETCH( bool, autoDelete ); - - QSignalSpy spyQueryDone( m_mockQueryMaker, SIGNAL(queryDone()) ); - QSignalSpy spyDestroyed( m_mockQueryMaker, SIGNAL(destroyed()) ); - - m_mockQueryMaker->setAutoDelete( autoDelete ); - QVERIFY( m_mockQueryMaker ); - - m_mockQueryMaker->emitQueryDone(); - - // Ensure that queryDone() was indeed emitted - QCOMPARE( spyQueryDone.count(), 1 ); - - if( autoDelete ) - { - // Signal queryDone() is connected to slot deleteLater() - // and the destroyed() signal is emitted - QCOMPARE( spyDestroyed.count(), 1 ); - } - else - { - // Signal queryDone() is disconnected from slot deleteLater() - // and no destroyed() signal is emitted - QCOMPARE( spyDestroyed.count(), 0 ); - } -} diff --git a/amarok/tests/core/collections/TestQueryMaker.h b/amarok/tests/core/collections/TestQueryMaker.h deleted file mode 100644 index cec41eee..00000000 --- a/amarok/tests/core/collections/TestQueryMaker.h +++ /dev/null @@ -1,39 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Jasneet Singh Bhatti * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef TESTQUERYMAKER_H -#define TESTQUERYMAKER_H - -#include - -class MockQueryMaker; - -class TestQueryMaker : public QObject -{ - Q_OBJECT - - private slots: - void initTestCase(); - void cleanupTestCase(); - - // Data driven testing of setAutoDelete - void testSetAutoDelete_data(); - void testSetAutoDelete(); - - private: - MockQueryMaker *m_mockQueryMaker; -}; - -#endif // TESTQUERYMAKER_H diff --git a/amarok/tests/core/collections/support/CMakeLists.txt b/amarok/tests/core/collections/support/CMakeLists.txt deleted file mode 100644 index cd87fad4..00000000 --- a/amarok/tests/core/collections/support/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -include_directories( . - ${AMAROK_TEST_TREE} - ${CMAKE_BINARY_DIR}/tests -) - -#------------------------ Test TrackForUrlWorker ----------------------------- - -set( testtrackforurlworker_SRCS TestTrackForUrlWorker.cpp ../../../mocks/MockTrackForUrlWorker.cpp ) -kde4_add_unit_test( testtrackforurlworker ${testtrackforurlworker_SRCS} ) -target_link_libraries( testtrackforurlworker ${KDE4_KDECORE_LIBS} ${QT_QTTEST_LIBRARY} ${KDE4_THREADWEAVER_LIBS} amarokcore amaroklib ) diff --git a/amarok/tests/core/collections/support/TestTrackForUrlWorker.cpp b/amarok/tests/core/collections/support/TestTrackForUrlWorker.cpp deleted file mode 100644 index 918394f0..00000000 --- a/amarok/tests/core/collections/support/TestTrackForUrlWorker.cpp +++ /dev/null @@ -1,122 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Jasneet Singh Bhatti * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "TestTrackForUrlWorker.h" - -#include "config-amarok-test.h" -#include "core/meta/Meta.h" -#include "core-impl/collections/support/CollectionManager.h" -#include "mocks/MockTrackForUrlWorker.h" - -#include -#include -#include -#include - -#include -#include - -QTEST_KDEMAIN_CORE( TestTrackForUrlWorker ) - -void -TestTrackForUrlWorker::initTestCase() -{ - // To make queued signals/slots work with custom payload - qRegisterMetaType( "Meta::TrackPtr" ); - qRegisterMetaType( "ThreadWeaver::Job*" ); -} - -QString -TestTrackForUrlWorker::dataPath( const QString &relPath ) -{ - return QDir::toNativeSeparators( QString( AMAROK_TEST_DIR ) + '/' + relPath ); -} - -void -TestTrackForUrlWorker::testCompleteJobKUrl_data() -{ - testCompleteJobInternal_data(); -} - -void -TestTrackForUrlWorker::testCompleteJobKUrl() -{ - KUrl url; - - MockTrackForUrlWorker *trackForUrlWorker = new MockTrackForUrlWorker( url ); - QVERIFY( trackForUrlWorker ); - - testCompleteJobInternal( trackForUrlWorker ); -} - -void TestTrackForUrlWorker::testCompleteJobQString_data() -{ - testCompleteJobInternal_data(); -} - -void -TestTrackForUrlWorker::testCompleteJobQString() -{ - QString url; - - MockTrackForUrlWorker *trackForUrlWorker = new MockTrackForUrlWorker( url ); - QVERIFY( trackForUrlWorker ); - - testCompleteJobInternal( trackForUrlWorker ); -} - -void -TestTrackForUrlWorker::testCompleteJobInternal_data() -{ - QTest::addColumn( "track" ); - - QTest::newRow( "track 1" ) << CollectionManager::instance()->trackForUrl( dataPath( "data/audio/album/Track01.ogg" ) ); - QTest::newRow( "track 2" ) << CollectionManager::instance()->trackForUrl( dataPath( "data/audio/album/Track02.ogg" ) ); - QTest::newRow( "track 3" ) << CollectionManager::instance()->trackForUrl( dataPath( "data/audio/album/Track03.ogg" ) ); -} - -void -TestTrackForUrlWorker::testCompleteJobInternal( MockTrackForUrlWorker *trackForUrlWorker ) -{ - // Connect finishedLookup with setEmittedTrack() that will store the emitted track - connect( trackForUrlWorker, SIGNAL(finishedLookup(Meta::TrackPtr)), - this, SLOT(setEmittedTrack(Meta::TrackPtr)) ); - - QSignalSpy spyFinishedLookup( trackForUrlWorker, SIGNAL(finishedLookup(Meta::TrackPtr)) ); - - // Enqueue the job for execution and verify that it emits done when finished, which triggers completeJob - ThreadWeaver::Weaver::instance()->enqueue( trackForUrlWorker ); - bool receivedDone = QTest::kWaitForSignal( trackForUrlWorker, SIGNAL(done(ThreadWeaver::Job*)), 1000 ); - QVERIFY( receivedDone ); - - // Verify that finishedLookup was emitted - QCOMPARE( spyFinishedLookup.count(), 1 ); - - // Verify that the track emitted with finishedLookup is indeed the track set by run() - QFETCH( Meta::TrackPtr, track ); - QCOMPARE( m_emittedTrack, track ); - - // Check for emission of the destroyed signal after deferred delete ( deleteLater ) - bool receivedDestroyed = QTest::kWaitForSignal( trackForUrlWorker, SIGNAL(destroyed()), 1000 ); - QVERIFY( receivedDestroyed ); -} - -void -TestTrackForUrlWorker::setEmittedTrack( Meta::TrackPtr track ) -{ - m_emittedTrack = track; -} - -#include "moc_TestTrackForUrlWorker.cpp" diff --git a/amarok/tests/core/collections/support/TestTrackForUrlWorker.h b/amarok/tests/core/collections/support/TestTrackForUrlWorker.h deleted file mode 100644 index 0e619249..00000000 --- a/amarok/tests/core/collections/support/TestTrackForUrlWorker.h +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Jasneet Singh Bhatti * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef TESTTRACKFORURLWORKER_H -#define TESTTRACKFORURLWORKER_H - -#include "core/meta/forward_declarations.h" - -#include - -class MockTrackForUrlWorker; - -class TestTrackForUrlWorker : public QObject -{ - Q_OBJECT - - public slots: - /** - * Stores the track emitted with finishedLookup - */ - void setEmittedTrack( Meta::TrackPtr track ); - - private slots: - void initTestCase(); - - /** - * Test slot completeJob() for both KUrl and QString types of urls - */ - void testCompleteJobKUrl(); - void testCompleteJobQString(); - - /** - * Both use testCompleteJobInternal_data() to add test data to avoid redundancy - */ - void testCompleteJobKUrl_data(); - void testCompleteJobQString_data(); - - private: - /** - * This method does the main testing - */ - void testCompleteJobInternal( MockTrackForUrlWorker *trackForUrlWorker ); - - void testCompleteJobInternal_data(); - - /** - * For portability while specifying path for fetching tracks from disk - */ - QString dataPath( const QString &relPath ); - - Meta::TrackPtr m_emittedTrack; -}; - -#endif // TESTTRACKFORURLWORKER_H diff --git a/amarok/tests/core/interfaces/CMakeLists.txt b/amarok/tests/core/interfaces/CMakeLists.txt deleted file mode 100644 index 1a782a27..00000000 --- a/amarok/tests/core/interfaces/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -include_directories( . - ${AMAROK_TEST_TREE} - ${CMAKE_BINARY_DIR}/tests -) - -#------------------------ Test MetaCapability ----------------------------- - -set( testmetacapability_SRCS TestMetaCapability.cpp ) -kde4_add_unit_test( testmetacapability ${testmetacapability_SRCS} ) -target_link_libraries( testmetacapability ${KDE4_KDECORE_LIBS} ${QT_QTGUI_LIBRARY} ${QT_QTTEST_LIBRARY} amarokcore ) diff --git a/amarok/tests/core/interfaces/TestMetaCapability.cpp b/amarok/tests/core/interfaces/TestMetaCapability.cpp deleted file mode 100644 index 6462ffae..00000000 --- a/amarok/tests/core/interfaces/TestMetaCapability.cpp +++ /dev/null @@ -1,111 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Jasneet Singh Bhatti * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "TestMetaCapability.h" - -#include "core/capabilities/ActionsCapability.h" -#include "core/capabilities/BookmarkThisCapability.h" -#include "core/capabilities/CollectionScanCapability.h" -#include "core/capabilities/MultiSourceCapability.h" -#include "core/interfaces/MetaCapability.h" - -#include - -#include - -/** - * Ad-hoc mock to test MetaCapability - */ -class MetaCapabilityMock : public MetaCapability -{ - public: - static Capabilities::ActionsCapability *actionsCapability; - static Capabilities::BookmarkThisCapability *bookmarkThisCapability; - - virtual bool hasCapabilityInterface( Capabilities::Capability::Type type ) const - { - switch( type ) - { - case Capabilities::Capability::Actions: - case Capabilities::Capability::BookmarkThis: - return true; - default: - break; - } - return false; - } - - virtual Capabilities::Capability *createCapabilityInterface( Capabilities::Capability::Type type ) - { - switch( type ) - { - case Capabilities::Capability::Actions: - return actionsCapability; - case Capabilities::Capability::BookmarkThis: - return bookmarkThisCapability; - default: - break; - } - return 0; - } - - private: - static QAction *action; - static QList actionsList; -}; - -QAction *MetaCapabilityMock::action = new QAction( 0 ); -QList MetaCapabilityMock::actionsList; - -// Create the static instances to be returned for testing -Capabilities::ActionsCapability *MetaCapabilityMock::actionsCapability = new Capabilities::ActionsCapability( actionsList ); -Capabilities::BookmarkThisCapability *MetaCapabilityMock::bookmarkThisCapability= new Capabilities::BookmarkThisCapability( action ); - -QTEST_KDEMAIN_CORE( TestMetaCapability ) - -TestMetaCapability::TestMetaCapability() -{ -} - -void -TestMetaCapability::testHas() -{ - MetaCapability *metaCapability = new MetaCapabilityMock(); - QVERIFY( metaCapability ); - - // these capabilities should be provided - QVERIFY( metaCapability->has() == true ); - QVERIFY( metaCapability->has() == true ); - - // these should not - QVERIFY( metaCapability->has() == false ); - QVERIFY( metaCapability->has() == false ); -} - -void -TestMetaCapability::testCreate() -{ - MetaCapability *metaCapability = new MetaCapabilityMock(); - QVERIFY( metaCapability ); - - // these capabilities should be provided - // check that the correct instances are returned - QVERIFY( metaCapability->create() == MetaCapabilityMock::actionsCapability ); - QVERIFY( metaCapability->create() == MetaCapabilityMock::bookmarkThisCapability ); - - // these should not - QVERIFY( metaCapability->create() == 0 ); - QVERIFY( metaCapability->create() == 0 ); -} diff --git a/amarok/tests/core/interfaces/TestMetaCapability.h b/amarok/tests/core/interfaces/TestMetaCapability.h deleted file mode 100644 index 3421f9d3..00000000 --- a/amarok/tests/core/interfaces/TestMetaCapability.h +++ /dev/null @@ -1,43 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Jasneet Singh Bhatti * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef TESTMETACAPABILITY_H -#define TESTMETACAPABILITY_H - -#include - -class TestMetaCapability : public QObject -{ - Q_OBJECT - - public: - TestMetaCapability(); - - private slots: - /** - * Test whether has() properly delegates work to hasCapabilityInterface() - */ - void testHas(); - - /** - * Test whether create() properly delegates work to createCapabilityInterface() - */ - void testCreate(); - - /* hasCapabilityInterface() and createCapabilityInterface() are both meant to be - * overridden in the subclasses, so no need to test them here. */ -}; - -#endif // TESTMETACAPABILITY_H diff --git a/amarok/tests/core/meta/CMakeLists.txt b/amarok/tests/core/meta/CMakeLists.txt deleted file mode 100644 index c4f0cb33..00000000 --- a/amarok/tests/core/meta/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -add_subdirectory( support ) - -#------------------------ Test MetaTrack ----------------------------- - -set( testmetatrack_SRCS TestMetaTrack.cpp ) -kde4_add_unit_test( testmetatrack ${testmetatrack_SRCS} ) -target_link_libraries( testmetatrack ${KDE4_KDECORE_LIBS} ${QT_QTGUI_LIBRARY} ${QT_QTTEST_LIBRARY} amarokcore amaroklib ) diff --git a/amarok/tests/core/meta/TestMetaTrack.cpp b/amarok/tests/core/meta/TestMetaTrack.cpp deleted file mode 100644 index 2e6a0d7a..00000000 --- a/amarok/tests/core/meta/TestMetaTrack.cpp +++ /dev/null @@ -1,265 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2009 Sven Krohlas * - * * - * This program 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 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#include "TestMetaTrack.h" - -#include "amarokconfig.h" -#include "config-amarok-test.h" -#include "core/meta/Meta.h" -#include "core/meta/Statistics.h" -#include "core-impl/collections/support/CollectionManager.h" - -#include - -#include - -QTEST_KDEMAIN( TestMetaTrack, GUI ) - -TestMetaTrack::TestMetaTrack() - : m_trackPath( dataPath( "/data/audio/Platz 01.mp3" ) ) -{} - -TestMetaTrack::~TestMetaTrack() -{ -} - -QString -TestMetaTrack::dataPath( const QString &relPath ) -{ - return QDir::toNativeSeparators( QString( AMAROK_TEST_DIR ) + '/' + relPath ); -} - -void TestMetaTrack::initTestCase() -{ - QString oldPath = m_trackPath; - m_trackPath = m_tempDir.name() + "TestMetaTrack-testTrack.mp3"; - QVERIFY( QFile::copy( oldPath, m_trackPath ) ); - - m_testTrack1 = CollectionManager::instance()->trackForUrl( m_trackPath ); - - // If the pointer is 0, it makes no sense to continue. We would crash with a qFatal(). - QVERIFY2( m_testTrack1, "The pointer to the test track is 0." ); - - // we need to enable this, otherwise testSetAndGetScore, testSetAndGetRating fails - AmarokConfig::setWriteBackStatistics( true ); -} - -void TestMetaTrack::testPrettyName() -{ - QCOMPARE( m_testTrack1->prettyName(), QString( "Platz 01" ) ); -} - -void TestMetaTrack::testPlayableUrl() -{ - QCOMPARE( m_testTrack1->playableUrl().pathOrUrl(), m_trackPath ); -} - -void TestMetaTrack::testPrettyUrl() -{ - QCOMPARE( m_testTrack1->prettyUrl(), m_trackPath ); -} - -void TestMetaTrack::testUidUrl() -{ - QCOMPARE( m_testTrack1->uidUrl(), KUrl( m_trackPath ).url() ); -} - -void TestMetaTrack::testIsPlayable() -{ - QCOMPARE( m_testTrack1->isPlayable(), true ); -} - -void TestMetaTrack::testAlbum() -{ - QCOMPARE( m_testTrack1->album().data()->name() , QString( "" ) ); -} - -void TestMetaTrack::testArtist() -{ - QCOMPARE( m_testTrack1->artist().data()->name(), QString( "Free Music Charts" ) ); -} - -void TestMetaTrack::testComposer() -{ - QCOMPARE( m_testTrack1->composer().data()->name(), QString( "" ) ); -} - -void TestMetaTrack::testGenre() -{ - QCOMPARE( m_testTrack1->genre().data()->name(), QString( "Vocal" ) ); -} - -void TestMetaTrack::testYear() -{ - QCOMPARE( m_testTrack1->year().data()->name(), QString( "2010" ) ); -} - -void TestMetaTrack::testComment() -{ - QCOMPARE( m_testTrack1->comment(), QString( "" ) ); -} - -void TestMetaTrack::testSetAndGetScore() -{ - Meta::StatisticsPtr statistics = m_testTrack1->statistics(); - QCOMPARE( statistics->score(), 0.0 ); - - /* now the code actually stores the score in track and then it reads it back. - * the precision it uses is pretty low and it was failing the qFuzzyCompare - * Just make it use qFuzzyCompare() */ - - statistics->setScore( 3 ); - QCOMPARE( float( statistics->score() ), float( 3.0 ) ); - - statistics->setScore( 12.55 ); - QCOMPARE( float( statistics->score() ), float( 12.55 ) ); - - statistics->setScore( 100 ); - QCOMPARE( float( statistics->score() ), float( 100.0 ) ); - - statistics->setScore( 0 ); - QCOMPARE( float( statistics->score() ), float( 0.0 ) ); -} - -void TestMetaTrack::testSetAndGetRating() -{ - Meta::StatisticsPtr statistics = m_testTrack1->statistics(); - QCOMPARE( statistics->rating(), 0 ); - - statistics->setRating( 3 ); - QCOMPARE( statistics->rating(), 3 ); - - statistics->setRating( 10 ); - QCOMPARE( statistics->rating(), 10 ); - - statistics->setRating( 0 ); - QCOMPARE( statistics->rating(), 0 ); -} - -void TestMetaTrack::testLength() -{ - QCOMPARE( m_testTrack1->length(), 12000LL ); -} - -void TestMetaTrack::testFilesize() -{ - QCOMPARE( m_testTrack1->filesize(), 389454 ); -} - -void TestMetaTrack::testSampleRate() -{ - QCOMPARE( m_testTrack1->sampleRate(), 44100 ); -} - -void TestMetaTrack::testBitrate() -{ - QCOMPARE( m_testTrack1->bitrate(), 256 ); -} - -void TestMetaTrack::testTrackNumber() -{ - QCOMPARE( m_testTrack1->trackNumber(), 0 ); -} - -void TestMetaTrack::testDiscNumber() -{ - QCOMPARE( m_testTrack1->discNumber(), 0 ); -} - -void TestMetaTrack::testLastPlayed() -{ - QCOMPARE( m_testTrack1->statistics()->lastPlayed().toTime_t(), 4294967295U ); // portability? -} - -void TestMetaTrack::testFirstPlayed() -{ - QCOMPARE( m_testTrack1->statistics()->firstPlayed().toTime_t(), 4294967295U ); // portability? -} - -void TestMetaTrack::testPlayCount() -{ - QCOMPARE( m_testTrack1->statistics()->playCount(), 0 ); -} - -void TestMetaTrack::testReplayGain() -{ - QCOMPARE( int(m_testTrack1->replayGain( Meta::ReplayGain_Track_Gain ) * 1000), -6655 ); - QCOMPARE( int(m_testTrack1->replayGain( Meta::ReplayGain_Album_Gain ) * 1000), -6655 ); - QCOMPARE( int(m_testTrack1->replayGain( Meta::ReplayGain_Track_Peak ) * 10000), 41263 ); - QCOMPARE( int(m_testTrack1->replayGain( Meta::ReplayGain_Album_Peak ) * 10000), 41263 ); -} - -void TestMetaTrack::testType() -{ - QCOMPARE( m_testTrack1->type(), QString( "mp3" ) ); -} - -void TestMetaTrack::testInCollection() -{ - QVERIFY( !m_testTrack1->inCollection() ); -} - -void TestMetaTrack::testCollection() -{ - QVERIFY( !m_testTrack1->collection() ); -} - -void TestMetaTrack::testSetAndGetCachedLyrics() -{ - /* TODO: setCachedLyrics is not yet implemented - QCOMPARE( m_testTrack1->cachedLyrics(), QString( "" ) ); - - m_testTrack1->setCachedLyrics( "test" ); - QCOMPARE( m_testTrack1->cachedLyrics(), QString( "test" ) ); - - m_testTrack1->setCachedLyrics( "aäaüoöß" ); - QCOMPARE( m_testTrack1->cachedLyrics(), QString( "aäaüoöß" ) ); - - m_testTrack1->setCachedLyrics( "" ); - QCOMPARE( m_testTrack1->cachedLyrics(), QString( "" ) ); - */ -} - -void TestMetaTrack::testOperatorEquals() -{ - QVERIFY( m_testTrack1 == m_testTrack1 ); - QVERIFY( m_testTrack1 != m_testTrack2 ); -} - -void TestMetaTrack::testLessThan() -{ - Meta::TrackPtr albumTrack1, albumTrack2, albumTrack3; - - albumTrack1 = CollectionManager::instance()->trackForUrl( dataPath( "data/audio/album/Track01.ogg" ) ); - albumTrack2 = CollectionManager::instance()->trackForUrl( dataPath( "data/audio/album/Track02.ogg" ) ); - albumTrack3 = CollectionManager::instance()->trackForUrl( dataPath( "data/audio/album/Track03.ogg" ) ); - - QVERIFY( albumTrack1 ); - QVERIFY( albumTrack2 ); - QVERIFY( albumTrack3 ); - - QVERIFY( !Meta::Track::lessThan( m_testTrack1, m_testTrack1 ) ); - - QVERIFY( Meta::Track::lessThan( albumTrack1, albumTrack2 ) ); - QVERIFY( Meta::Track::lessThan( albumTrack2, albumTrack3 ) ); - QVERIFY( Meta::Track::lessThan( albumTrack1, albumTrack3 ) ); - QVERIFY( !Meta::Track::lessThan( albumTrack3, albumTrack2 ) ); - QVERIFY( !Meta::Track::lessThan( albumTrack3, albumTrack1 ) ); - QVERIFY( !Meta::Track::lessThan( albumTrack3, albumTrack3 ) ); -} diff --git a/amarok/tests/core/meta/TestMetaTrack.h b/amarok/tests/core/meta/TestMetaTrack.h deleted file mode 100644 index 90f6304a..00000000 --- a/amarok/tests/core/meta/TestMetaTrack.h +++ /dev/null @@ -1,82 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2009 Sven Krohlas * - * * - * This program 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 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#ifndef TESTMETATRACK_H -#define TESTMETATRACK_H - -#include "core/meta/forward_declarations.h" - -#include -#include -#include - -class TestMetaTrack : public QObject -{ -Q_OBJECT - -public: - TestMetaTrack(); - ~TestMetaTrack(); - -private slots: - void initTestCase(); - - void testPrettyName(); - void testPlayableUrl(); - void testPrettyUrl(); - void testUidUrl(); - - void testIsPlayable(); - void testAlbum(); - void testArtist(); - void testComposer(); - void testGenre(); - void testYear(); - - void testComment(); - void testSetAndGetScore(); - void testSetAndGetRating(); - void testLength(); - void testFilesize(); - void testSampleRate(); - void testBitrate(); - void testTrackNumber(); - void testDiscNumber(); - void testLastPlayed(); - void testFirstPlayed(); - void testPlayCount(); - void testReplayGain(); - void testType(); - - void testInCollection(); - void testCollection(); - void testSetAndGetCachedLyrics(); - void testOperatorEquals(); - void testLessThan(); - -private: - Meta::TrackPtr m_testTrack1; - Meta::TrackPtr m_testTrack2; - QString m_trackPath; - KTempDir m_tempDir; - - QString dataPath( const QString &relPath ); -}; - -#endif // TESTMETATRACK_H diff --git a/amarok/tests/core/meta/support/CMakeLists.txt b/amarok/tests/core/meta/support/CMakeLists.txt deleted file mode 100644 index 726b0255..00000000 --- a/amarok/tests/core/meta/support/CMakeLists.txt +++ /dev/null @@ -1,28 +0,0 @@ -include_directories( . - ${AMAROK_TEST_TREE} - ${CMAKE_BINARY_DIR}/tests -) - -#------------------------ Test MetaAlbumKey ----------------------------- - -set( testmetaalbumkey_SRCS TestMetaAlbumKey.cpp ) -kde4_add_unit_test( testmetaalbumkey ${testmetaalbumkey_SRCS} ) -target_link_libraries( testmetaalbumkey ${KDE4_KDECORE_LIBS} ${QT_QTTEST_LIBRARY} amarokcore amaroklib ) - -#------------------------ Test MetaTrackKey ----------------------------- - -set( testmetatrackkey_SRCS TestMetaTrackKey.cpp ) -kde4_add_unit_test( testmetatrackkey ${testmetatrackkey_SRCS} ) -target_link_libraries( testmetatrackkey ${KDE4_KDECORE_LIBS} ${QT_QTTEST_LIBRARY} amarokcore amaroklib ) - -#------------------------ Test PrivateMetaRegistry ----------------------------- - -set( testprivatemetaregistry_SRCS TestPrivateMetaRegistry.cpp ) -kde4_add_unit_test( testprivatemetaregistry ${testprivatemetaregistry_SRCS} ) -target_link_libraries( testprivatemetaregistry ${KDE4_KDECORE_LIBS} ${QT_QTTEST_LIBRARY} amarokcore amaroklib ) - -#------------------------ Test MetaConstants ----------------------------- - -set( testmetaconstants_SRCS TestMetaConstants.cpp ../../../../shared/FileType.cpp ) -kde4_add_unit_test( testmetaconstants ${testmetaconstants_SRCS} ) -target_link_libraries( testmetaconstants ${KDE4_KDECORE_LIBS} ${QT_QTGUI_LIBRARY} ${QT_QTTEST_LIBRARY} amarokcore amaroklib ) diff --git a/amarok/tests/core/meta/support/TestMetaAlbumKey.cpp b/amarok/tests/core/meta/support/TestMetaAlbumKey.cpp deleted file mode 100644 index 6b8cbeb5..00000000 --- a/amarok/tests/core/meta/support/TestMetaAlbumKey.cpp +++ /dev/null @@ -1,116 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Jasneet Singh Bhatti * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "TestMetaAlbumKey.h" - -#include "config-amarok-test.h" -#include "core/meta/Meta.h" -#include "core/meta/support/MetaKeys.h" -#include "core-impl/collections/support/CollectionManager.h" - -#include - -QTEST_KDEMAIN_CORE( TestMetaAlbumKey ) - -TestMetaAlbumKey::~TestMetaAlbumKey() -{ -} - -void -TestMetaAlbumKey::initTestCase() -{ - // Artist Name - Amarok Album Name - Amarok Test Album - m_track1 = CollectionManager::instance()->trackForUrl( dataPath( "data/audio/album/Track01.ogg" ) ); - - // Artist Name - Amarok Album Name - Amarok Test Album 2 - m_track2 = CollectionManager::instance()->trackForUrl( dataPath( "data/audio/album2/Track01.ogg" ) ); - - // Artist Name - Amarok 2 Album Name - Amarok Test Album 2 - m_track3 = CollectionManager::instance()->trackForUrl( dataPath( "data/audio/album2/Track02.ogg" ) ); - - m_album1 = m_track1->album(); - m_album2 = m_track2->album(); - m_album3 = m_track3->album(); -} - -QString -TestMetaAlbumKey::dataPath( const QString &relPath ) -{ - return QDir::toNativeSeparators( QString( AMAROK_TEST_DIR ) + '/' + relPath ); -} - -void -TestMetaAlbumKey::testAlbumKey() -{ - Meta::AlbumKey albumKey1( m_album1 ); - - QCOMPARE( albumKey1.m_albumName, m_album1->name() ); - QCOMPARE( albumKey1.m_artistName, m_album1->albumArtist()->name() ); -} - -void -TestMetaAlbumKey::testOperatorAssignment() -{ - // For Constructor : AlbumKey( const AlbumPtr &album ) - Meta::AlbumKey albumKey1( m_album1 ), albumKey2( m_album2 ), tempAlbumKey; - - QVERIFY( !( albumKey1 == albumKey2 ) ); - - tempAlbumKey = albumKey1; - QCOMPARE( albumKey1, tempAlbumKey ); - - // For Constructor : AlbumKey( const QString &name, const QString &artistName ) - Meta::AlbumKey albumKey3( "Artist 1", "Album 1" ), albumKey4( "Artist 2", "Album 2" ); - - QVERIFY( !( albumKey1 == albumKey2 ) ); - - tempAlbumKey = albumKey1; - QCOMPARE( albumKey1, tempAlbumKey ); -} - -void -TestMetaAlbumKey::testOperatorLessThan() -{ - // For Constructor : AlbumKey( const AlbumPtr &album ) - Meta::AlbumKey albumKey1( m_album1 ), albumKey2( m_album2 ), albumKey3( m_album3 ); - - // Same artist name, different album name - QVERIFY( albumKey1 < albumKey2 ); - - // Same artist name, same album name - QVERIFY( !( albumKey1 < albumKey1 ) ); - - // Different artist name, same album name - QVERIFY( albumKey2 < albumKey3 ); - - // Different artist name, different album name - QVERIFY( albumKey1 < albumKey3 ); - - // For Constructor : AlbumKey( const QString &name, const QString &artistName ) - Meta::AlbumKey albumKey4( "Artist 1", "Album 1" ), albumKey5( "Artist 1", "Album 2" ), - albumKey6( "Artist 2", "Album 2" ); - - // Same artist name, different album name - QVERIFY( albumKey4 < albumKey5 ); - - // Same artist name, same album name - QVERIFY( !( albumKey4 < albumKey4 ) ); - - // Different artist name, same album name - QVERIFY( albumKey5 < albumKey6 ); - - // Different artist name, different album name - QVERIFY( albumKey4 < albumKey6 ); -} diff --git a/amarok/tests/core/meta/support/TestMetaAlbumKey.h b/amarok/tests/core/meta/support/TestMetaAlbumKey.h deleted file mode 100644 index b3fb35ef..00000000 --- a/amarok/tests/core/meta/support/TestMetaAlbumKey.h +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Jasneet Singh Bhatti * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef TESTMETAALBUMKEY_H -#define TESTMETAALBUMKEY_H - -#include "core/meta/forward_declarations.h" - -#include - -class TestMetaAlbumKey : public QObject -{ - Q_OBJECT - - public: - ~TestMetaAlbumKey(); - - private slots: - void initTestCase(); - - /** - * Test constructor AlbumKey( const AlbumPtr &album ) - */ - void testAlbumKey(); - void testOperatorAssignment(); - void testOperatorLessThan(); - - private: - /** - * For portability in fetching tracks from disk - */ - QString dataPath( const QString &relPath ); - - Meta::TrackPtr m_track1, m_track2, m_track3; - Meta::AlbumPtr m_album1, m_album2, m_album3; -}; - -#endif // TESTMETAALBUMKEY_H diff --git a/amarok/tests/core/meta/support/TestMetaConstants.cpp b/amarok/tests/core/meta/support/TestMetaConstants.cpp deleted file mode 100644 index f645281f..00000000 --- a/amarok/tests/core/meta/support/TestMetaConstants.cpp +++ /dev/null @@ -1,616 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Jasneet Singh Bhatti * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "TestMetaConstants.h" - -#include "core/meta/support/MetaConstants.h" -#include "mocks/MetaMock.h" -#include "MetaValues.h" -#include "FileType.h" - -#include -#include - -using namespace Meta; - -QTEST_KDEMAIN_CORE( TestMetaConstants ) - -/* Just for clarification. This is not how you would normally write an auto test. - You don't write a switch just to test if the switch returns the correct values. - - You also don't test localized texts, since you would have to run the test - in all available languages. There are other methods to test if you missed to - translate something. This is not it. - - In my case the test failed three times. Always a false positive. -*/ - -void -TestMetaConstants::dataNameField() -{ - QTest::addColumn( "field" ); - QTest::addColumn( "name" ); - - QTest::newRow( "anything" ) << qint64( 0 ) << "anything"; - QTest::newRow( "filename" ) << Meta::valUrl << "filename"; - QTest::newRow( "title" ) << Meta::valTitle << "title"; - QTest::newRow( "artist" ) << Meta::valArtist << "artist"; - QTest::newRow( "album" ) << Meta::valAlbum << "album"; - QTest::newRow( "genre" ) << Meta::valGenre << "genre"; - QTest::newRow( "composer" ) << Meta::valComposer << "composer"; - QTest::newRow( "year" ) << Meta::valYear << "year"; - QTest::newRow( "comment" ) << Meta::valComment << "comment"; - QTest::newRow( "discnumber" ) << Meta::valDiscNr << "discnumber"; - QTest::newRow( "bpm" ) << Meta::valBpm << "bpm"; - QTest::newRow( "length" ) << Meta::valLength << "length"; - QTest::newRow( "bitrate" ) << Meta::valBitrate << "bitrate"; - QTest::newRow( "samplerate" ) << Meta::valSamplerate << "samplerate"; - QTest::newRow( "filesize" ) << Meta::valFilesize << "filesize"; - QTest::newRow( "format" ) << Meta::valFormat << "format"; - QTest::newRow( "added" ) << Meta::valCreateDate << "added"; - QTest::newRow( "score" ) << Meta::valScore << "score"; - QTest::newRow( "rating" ) << Meta::valRating << "rating"; - QTest::newRow( "firstplay" ) << Meta::valFirstPlayed << "firstplay"; - QTest::newRow( "lastplay" ) << Meta::valLastPlayed << "lastplay"; - QTest::newRow( "playcount" ) << Meta::valPlaycount << "playcount"; - QTest::newRow( "uniqueid" ) << Meta::valUniqueId << "uniqueid"; - - QTest::newRow( "trackgain" ) << Meta::valTrackGain << "trackgain"; - QTest::newRow( "trackgainpeak" ) << Meta::valTrackGainPeak << "trackgainpeak"; - QTest::newRow( "albumgain" ) << Meta::valAlbumGain << "albumgain"; - QTest::newRow( "albumgainpeak" ) << Meta::valAlbumGainPeak << "albumgainpeak"; - - QTest::newRow( "albumartist" ) << Meta::valAlbumArtist << "albumartist"; - QTest::newRow( "label" ) << Meta::valLabel << "label"; - QTest::newRow( "modified" ) << Meta::valModified << "modified"; -} - -void -TestMetaConstants::testNameForField_data() -{ - dataNameField(); - - // Some test cases that can't be shared - QTest::newRow( "tracknr" ) << Meta::valTrackNr << "tracknr"; - QTest::newRow( "default" ) << qint64( -1 ) << ""; -} - -void -TestMetaConstants::testNameForField() -{ - QFETCH( qint64, field ); - QFETCH( QString, name ); - - QCOMPARE( nameForField( field ), name ); -} - -void -TestMetaConstants::testFieldForName_data() -{ - dataNameField(); - - // Some test cases that can't be shared - QTest::newRow( "codec" ) << Meta::valFormat << "codec"; - QTest::newRow( "first" ) << Meta::valFirstPlayed << "first"; - QTest::newRow( "played" ) << Meta::valLastPlayed << "played"; - QTest::newRow( "tracknumber" ) << Meta::valTrackNr << "tracknumber"; - - // Mixed case - QTest::newRow( "Filename" ) << Meta::valUrl << "Filename"; - QTest::newRow( "TrackGain" ) << Meta::valTrackGain << "TrackGain"; - - // No match - QTest::newRow( "noMatch" ) << qint64( 0 ) << "noMatch"; - - QTest::newRow( "shortI18nForField( 0 )" ) << qint64( 0 ) << shortI18nForField( 0 ); - QTest::newRow( "shortI18nForField( Meta::valUrl )" ) << Meta::valUrl << shortI18nForField( Meta::valUrl ); - QTest::newRow( "shortI18nForField( Meta::valTitle )" ) << Meta::valTitle << shortI18nForField( Meta::valTitle ); - QTest::newRow( "shortI18nForField( Meta::valArtist )" ) << Meta::valArtist << shortI18nForField( Meta::valArtist ); - QTest::newRow( "shortI18nForField( Meta::valAlbum )" ) << Meta::valAlbum << shortI18nForField( Meta::valAlbum ); - QTest::newRow( "shortI18nForField( Meta::valGenre )" ) << Meta::valGenre << shortI18nForField( Meta::valGenre ); - QTest::newRow( "shortI18nForField( Meta::valComposer )" ) << Meta::valComposer << shortI18nForField( Meta::valComposer ); - QTest::newRow( "shortI18nForField( Meta::valYear )" ) << Meta::valYear << shortI18nForField( Meta::valYear ); - QTest::newRow( "shortI18nForField( Meta::valComment )" ) << Meta::valComment << shortI18nForField( Meta::valComment ); - QTest::newRow( "shortI18nForField( Meta::valDiscNr )" ) << Meta::valDiscNr << shortI18nForField( Meta::valDiscNr ); - QTest::newRow( "shortI18nForField( Meta::valBpm )" ) << Meta::valBpm << shortI18nForField( Meta::valBpm ); - QTest::newRow( "shortI18nForField( Meta::valLength )" ) << Meta::valLength << shortI18nForField( Meta::valLength ); - QTest::newRow( "shortI18nForField( Meta::valBitrate )" ) << Meta::valBitrate << shortI18nForField( Meta::valBitrate ); - QTest::newRow( "shortI18nForField( Meta::valSamplerate )" ) << Meta::valSamplerate << shortI18nForField( Meta::valSamplerate ); - QTest::newRow( "shortI18nForField( Meta::valFilesize )" ) << Meta::valFilesize << shortI18nForField( Meta::valFilesize ); - QTest::newRow( "shortI18nForField( Meta::valFormat )" ) << Meta::valFormat << shortI18nForField( Meta::valFormat ); - QTest::newRow( "shortI18nForField( Meta::valCreateDate )" ) << Meta::valCreateDate << shortI18nForField( Meta::valCreateDate ); - QTest::newRow( "shortI18nForField( Meta::valScore )" ) << Meta::valScore << shortI18nForField( Meta::valScore ); - QTest::newRow( "shortI18nForField( Meta::valRating )" ) << Meta::valRating << shortI18nForField( Meta::valRating ); - QTest::newRow( "shortI18nForField( Meta::valFirstPlayed )" ) << Meta::valFirstPlayed << shortI18nForField( Meta::valFirstPlayed ); - QTest::newRow( "shortI18nForField( Meta::valLastPlayed )" ) << Meta::valLastPlayed << shortI18nForField( Meta::valLastPlayed ); - QTest::newRow( "shortI18nForField( Meta::valPlaycount )" ) << Meta::valPlaycount << shortI18nForField( Meta::valPlaycount ); - QTest::newRow( "shortI18nForField( Meta::valUniqueId )" ) << Meta::valUniqueId << shortI18nForField( Meta::valUniqueId ); - - QTest::newRow( "shortI18nForField( Meta::valTrackGain )" ) << Meta::valTrackGain << shortI18nForField( Meta::valTrackGain ); - QTest::newRow( "shortI18nForField( Meta::valTrackGainPeak )" ) << Meta::valTrackGainPeak << shortI18nForField( Meta::valTrackGainPeak ); - QTest::newRow( "shortI18nForField( Meta::valAlbumGain )" ) << Meta::valAlbumGain << shortI18nForField( Meta::valAlbumGain ); - QTest::newRow( "shortI18nForField( Meta::valAlbumGainPeak )" ) << Meta::valAlbumGainPeak << shortI18nForField( Meta::valAlbumGainPeak ); - - QTest::newRow( "shortI18nForField( Meta::valAlbumArtist )" ) << Meta::valAlbumArtist << shortI18nForField( Meta::valAlbumArtist ); - QTest::newRow( "shortI18nForField( Meta::valLabel )" ) << Meta::valLabel << shortI18nForField( Meta::valLabel ); - QTest::newRow( "shortI18nForField( Meta::valModified )" ) << Meta::valModified << shortI18nForField( Meta::valModified ); - - QTest::newRow( "shortI18nForField( Meta::valFormat )" ) << Meta::valFormat << shortI18nForField( Meta::valFormat ); - QTest::newRow( "shortI18nForField( Meta::valFirstPlayed )" ) << Meta::valFirstPlayed << shortI18nForField( Meta::valFirstPlayed ); - QTest::newRow( "shortI18nForField( Meta::valLastPlayed )" ) << Meta::valLastPlayed << shortI18nForField( Meta::valLastPlayed ); - QTest::newRow( "shortI18nForField( Meta::valTrackNr )" ) << Meta::valTrackNr << shortI18nForField( Meta::valTrackNr ); -} - -void -TestMetaConstants::testFieldForName() -{ - QFETCH( QString, name ); - QFETCH( qint64, field ); - - QCOMPARE( fieldForName( name ), field ); - - // Uppercase should also work - QCOMPARE( fieldForName( name.toUpper() ), field ); -} - -void -TestMetaConstants::testI18nForField_data() -{ - QTest::addColumn( "field" ); - QTest::addColumn( "localized" ); - - QTest::newRow( "anything" ) << qint64( 0 ) << i18nc( "The field name in case nothing specific is selected e.g. in the automatic playlist generator", "anything" ); - QTest::newRow( "filename" ) << Meta::valUrl << i18nc( "The name of the file this track is stored in", "File Name" ); - QTest::newRow( "title" ) << Meta::valTitle << i18n( "Title" ); - QTest::newRow( "artist" ) << Meta::valArtist << i18n( "Artist" ); - QTest::newRow( "album" ) << Meta::valAlbum << i18n( "Album" ); - QTest::newRow( "genre" ) << Meta::valGenre << i18n( "Genre" ); - QTest::newRow( "composer" ) << Meta::valComposer << i18n( "Composer" ); - QTest::newRow( "year" ) << Meta::valYear << i18n( "Year" ); - QTest::newRow( "comment" ) << Meta::valComment << i18n( "Comment" ); - QTest::newRow( "tracknumber" ) << Meta::valTrackNr << i18n( "Track Number" ); - QTest::newRow( "discnumber" ) << Meta::valDiscNr << i18n( "Disc Number" ); - QTest::newRow( "bpm" ) << Meta::valBpm << i18n( "Bpm" ); - QTest::newRow( "length" ) << Meta::valLength << i18n( "Length" ); - QTest::newRow( "bitrate" ) << Meta::valBitrate << i18n( "Bit Rate" ); - QTest::newRow( "samplerate" ) << Meta::valSamplerate << i18n( "Sample Rate" ); - QTest::newRow( "filesize" ) << Meta::valFilesize << i18n( "File Size" ); - QTest::newRow( "format" ) << Meta::valFormat << i18n( "Format" ); - QTest::newRow( "added" ) << Meta::valCreateDate << i18n( "Added to Collection" ); - QTest::newRow( "score" ) << Meta::valScore << i18n( "Score" ); - QTest::newRow( "rating" ) << Meta::valRating << i18n( "Rating" ); - QTest::newRow( "firstplay" ) << Meta::valFirstPlayed << i18n( "First Played" ); - QTest::newRow( "lastplay" ) << Meta::valLastPlayed << i18n( "Last Played" ); - QTest::newRow( "playcount" ) << Meta::valPlaycount << i18n( "Playcount" ); - QTest::newRow( "uniqueid" ) << Meta::valUniqueId << i18n( "Unique Id" ); - - QTest::newRow( "trackgain" ) << Meta::valTrackGain << i18n( "Track Gain" ); - QTest::newRow( "trackgainpeak" ) << Meta::valTrackGainPeak << i18n( "Track Gain Peak" ); - QTest::newRow( "albumgain" ) << Meta::valAlbumGain << i18n( "Album Gain" ); - QTest::newRow( "albumgainpeak" ) << Meta::valAlbumGainPeak << i18n( "Album Gain Peak" ); - - QTest::newRow( "albumartist" ) << Meta::valAlbumArtist << i18n( "Album Artist" ); - QTest::newRow( "label" ) << Meta::valLabel << i18n( "Label" ); - QTest::newRow( "modified" ) << Meta::valModified << i18n( "Last Modified" ); - QTest::newRow( "default" ) << qint64( -1 ) << QString(); -} - -void -TestMetaConstants::testI18nForField() -{ - QFETCH( qint64, field ); - QFETCH( QString, localized ); - - QCOMPARE( i18nForField( field ), localized ); -} - -void -TestMetaConstants::testShortI18nForField_data() -{ - QTest::addColumn( "field" ); - QTest::addColumn( "shortname" ); - - QTest::newRow( "anything" ) << qint64( 0 ) << i18nc("The field name in case nothing specific is selected e.g. in the automatic playlist generator. Use a one word translation.", "anything"); - QTest::newRow( "filename" ) << Meta::valUrl << i18nc("One word translation used in the collection filter. The name of the file this track is stored in", "filename" ); - QTest::newRow( "title" ) << Meta::valTitle << i18nc("One word translation used in the collection filter", "title"); - QTest::newRow( "artist" ) << Meta::valArtist << i18nc("One word translation used in the collection filter", "artist"); - QTest::newRow( "album" ) << Meta::valAlbum << i18nc("One word translation used in the collection filter", "album"); - QTest::newRow( "genre" ) << Meta::valGenre << i18nc("One word translation used in the collection filter", "genre"); - QTest::newRow( "composer" ) << Meta::valComposer << i18nc("One word translation used in the collection filter", "composer"); - QTest::newRow( "year" ) << Meta::valYear << i18nc("One word translation used in the collection filter", "year"); - QTest::newRow( "comment" ) << Meta::valComment << i18nc("One word translation used in the collection filter", "comment"); - QTest::newRow( "tracknumber" ) << Meta::valTrackNr << i18nc("One word translation used in the collection filter", "tracknumber"); - QTest::newRow( "discnumber" ) << Meta::valDiscNr << i18nc("One word translation used in the collection filter", "discnumber"); - QTest::newRow( "bpm" ) << Meta::valBpm << i18nc("One word translation used in the collection filter", "bpm"); - QTest::newRow( "length" ) << Meta::valLength << i18nc("One word translation used in the collection filter", "length"); - QTest::newRow( "bitrate" ) << Meta::valBitrate << i18nc("One word translation used in the collection filter", "bitrate"); - QTest::newRow( "samplerate" ) << Meta::valSamplerate << i18nc("One word translation used in the collection filter", "samplerate"); - QTest::newRow( "filesize" ) << Meta::valFilesize << i18nc("One word translation used in the collection filter", "filesize"); - QTest::newRow( "format" ) << Meta::valFormat << i18nc("One word translation used in the collection filter", "format"); - QTest::newRow( "added" ) << Meta::valCreateDate << i18nc("One word translation used in the collection filter", "added"); - QTest::newRow( "score" ) << Meta::valScore << i18nc("One word translation used in the collection filter", "score"); - QTest::newRow( "rating" ) << Meta::valRating << i18nc("One word translation used in the collection filter", "rating"); - QTest::newRow( "firstplay" ) << Meta::valFirstPlayed << i18nc("One word translation used in the collection filter. First played time / access date", "firstplay"); - QTest::newRow( "lastplay" ) << Meta::valLastPlayed << i18nc("One word translation used in the collection filter. Last played time / access date", "lastplay"); - QTest::newRow( "playcount" ) << Meta::valPlaycount << i18nc("One word translation used in the collection filter", "playcount"); - QTest::newRow( "uniqueid" ) << Meta::valUniqueId << i18nc("One word translation used in the collection filter", "uniqueid"); - - QTest::newRow( "trackgain" ) << Meta::valTrackGain << i18nc("One word translation used in the collection filter", "trackgain"); - QTest::newRow( "trackgainpeak" ) << Meta::valTrackGainPeak << i18nc("One word translation used in the collection filter", "trackgainpeak"); - QTest::newRow( "albumgain" ) << Meta::valAlbumGain << i18nc("One word translation used in the collection filter", "albumgain"); - QTest::newRow( "albumgainpeak" ) << Meta::valAlbumGainPeak << i18nc("One word translation used in the collection filter", "albumgainpeak"); - - QTest::newRow( "albumartist" ) << Meta::valAlbumArtist << i18nc("One word translation used in the collection filter", "albumartist"); - QTest::newRow( "label" ) << Meta::valLabel << i18nc("One word translation used in the collection filter", "label"); - QTest::newRow( "modified" ) << Meta::valModified << i18nc("One word translation used in the collection filter", "modified"); - QTest::newRow( "default" ) << qint64( -1 ) << QString(); -} - -void -TestMetaConstants::testShortI18nForField() -{ - QFETCH( qint64, field ); - QFETCH( QString, shortname ); - - QCOMPARE( shortI18nForField( field ), shortname ); -} - -void -TestMetaConstants::dataPlaylistNameField() -{ - QTest::addColumn( "field" ); - QTest::addColumn( "playlist" ); - - QTest::newRow( "anything" ) << qint64( 0 ) << "anything"; - QTest::newRow( "url" ) << Meta::valUrl << "url"; - QTest::newRow( "title" ) << Meta::valTitle << "title"; - QTest::newRow( "artist" ) << Meta::valArtist << "artist name"; - QTest::newRow( "album" ) << Meta::valAlbum << "album name"; - QTest::newRow( "genre" ) << Meta::valGenre << "genre"; - QTest::newRow( "composer" ) << Meta::valComposer << "composer"; - QTest::newRow( "year" ) << Meta::valYear << "year"; - QTest::newRow( "comment" ) << Meta::valComment << "comment"; - QTest::newRow( "tracknumber" ) << Meta::valTrackNr << "track number"; - QTest::newRow( "discnumber" ) << Meta::valDiscNr << "disc number"; - QTest::newRow( "bpm" ) << Meta::valBpm << "bpm"; - QTest::newRow( "length" ) << Meta::valLength << "length"; - QTest::newRow( "bitrate" ) << Meta::valBitrate << "bit rate"; - QTest::newRow( "samplerate" ) << Meta::valSamplerate << "sample rate"; - QTest::newRow( "filesize" ) << Meta::valFilesize << "file size"; - QTest::newRow( "format" ) << Meta::valFormat << "format"; - QTest::newRow( "createdate" ) << Meta::valCreateDate << "create date"; - QTest::newRow( "score" ) << Meta::valScore << "score"; - QTest::newRow( "rating" ) << Meta::valRating << "rating"; - QTest::newRow( "firstplay" ) << Meta::valFirstPlayed << "first played"; - QTest::newRow( "lastplay" ) << Meta::valLastPlayed << "last played"; - QTest::newRow( "playcount" ) << Meta::valPlaycount << "play count"; - QTest::newRow( "uniqueid" ) << Meta::valUniqueId << "unique id"; - - QTest::newRow( "trackgain" ) << Meta::valTrackGain << "track gain"; - QTest::newRow( "trackgainpeak" ) << Meta::valTrackGainPeak << "track gain peak"; - QTest::newRow( "albumgain" ) << Meta::valAlbumGain << "album gain"; - QTest::newRow( "albumgainpeak" ) << Meta::valAlbumGainPeak << "album gain peak"; - - QTest::newRow( "albumartist" ) << Meta::valAlbumArtist << "album artist name"; - QTest::newRow( "label" ) << Meta::valLabel << "label"; - QTest::newRow( "modified" ) << Meta::valModified << "modified"; -} - -void -TestMetaConstants::testPlaylistNameForField_data() -{ - dataPlaylistNameField(); - - // Test case that can't be shared - QTest::newRow( "default" ) << qint64( -1 ) << ""; -} - -void -TestMetaConstants::testPlaylistNameForField() -{ - QFETCH( qint64, field ); - QFETCH( QString, playlist ); - - QCOMPARE( playlistNameForField( field ), playlist ); -} - -void -TestMetaConstants::testFieldForPlaylistName_data() -{ - dataPlaylistNameField(); - - // Some test cases that can't be shared - QTest::newRow( "nomatch" ) << qint64( 0 ) << "nomatch"; - - // Playlist name should not be in uppercase or mixed case, returns 0 - QTest::newRow( "NOMATCH" ) << qint64( 0 ) << "NOMATCH"; - QTest::newRow( "noMatch" ) << qint64( 0 ) << "noMatch"; -} - -void -TestMetaConstants::testFieldForPlaylistName() -{ - QFETCH( QString, playlist ); - QFETCH( qint64, field ); - - QCOMPARE( fieldForPlaylistName( playlist ), field ); -} - -void -TestMetaConstants::testIconForField_data() -{ - QTest::addColumn( "field" ); - QTest::addColumn( "icon" ); - - QTest::newRow( "url" ) << Meta::valUrl << "filename-space-amarok"; - QTest::newRow( "title" ) << Meta::valTitle << "filename-title-amarok"; - QTest::newRow( "artist" ) << Meta::valArtist << "filename-artist-amarok"; - QTest::newRow( "albumartist" ) << Meta::valAlbumArtist << "filename-artist-amarok"; - QTest::newRow( "album" ) << Meta::valAlbum << "filename-album-amarok"; - QTest::newRow( "genre" ) << Meta::valGenre << "filename-genre-amarok"; - QTest::newRow( "composer" ) << Meta::valComposer << "filename-composer-amarok"; - QTest::newRow( "year" ) << Meta::valYear << "filename-year-amarok"; - QTest::newRow( "modified" ) << Meta::valModified << "filename-year-amarok"; - QTest::newRow( "createdate" ) << Meta::valCreateDate << "filename-year-amarok"; - QTest::newRow( "comment" ) << Meta::valComment << "amarok_comment"; - QTest::newRow( "playcount" ) << Meta::valPlaycount << "amarok_playcount"; - QTest::newRow( "tracknumber" ) << Meta::valTrackNr << "filename-track-amarok"; - QTest::newRow( "discnumber" ) << Meta::valDiscNr << "filename-discnumber-amarok"; - QTest::newRow( "bpm" ) << Meta::valBpm << "filename-bpm-amarok"; - QTest::newRow( "length" ) << Meta::valLength << "chronometer"; - QTest::newRow( "bitrate" ) << Meta::valBitrate << "audio-x-generic"; - QTest::newRow( "samplerate" ) << Meta::valSamplerate << "filename-sample-rate"; - QTest::newRow( "format" ) << Meta::valFormat << "filename-filetype-amarok"; - QTest::newRow( "score" ) << Meta::valScore << "emblem-favorite"; - QTest::newRow( "rating" ) << Meta::valRating << "rating"; - QTest::newRow( "firstplay" ) << Meta::valFirstPlayed << "filename-last-played"; - QTest::newRow( "lastplay" ) << Meta::valLastPlayed << "filename-last-played"; - QTest::newRow( "label" ) << Meta::valLabel << "label-amarok"; - QTest::newRow( "filesize" ) << Meta::valFilesize << "info-amarok"; - QTest::newRow( "default" ) << qint64( -1 ) << ""; -} - -void -TestMetaConstants::testIconForField() -{ - QFETCH( qint64, field ); - QFETCH( QString, icon ); - - QCOMPARE( iconForField( field ), icon ); - -} - -void -TestMetaConstants::testValueForField() -{ - Meta::TrackPtr trackPtr; - - // When track is null, an invalid QVariant is returned - trackPtr = 0; - QVERIFY( !valueForField( 0, trackPtr ).isValid() ); - - // Set up mock track details and create mock track - QVariantMap trackData; - trackData[ Meta::Field::URL ] = KUrl( "file:///test/url" ); - trackData[ Meta::Field::TITLE ] = "test track"; - trackData[ Meta::Field::COMMENT ] = "test comment" ; - trackData[ Meta::Field::TRACKNUMBER ] = 1; - trackData[ Meta::Field::DISCNUMBER ] = 1; - trackData[ Meta::Field::BPM ] = qreal( 1 ); - trackData[ Meta::Field::LENGTH ] = qint64( 1 ); - trackData[ Meta::Field::BITRATE ] = 1; - trackData[ Meta::Field::SAMPLERATE ] = 1; - trackData[ Meta::Field::FILESIZE ] = 1; - trackData[ Meta::Field::SCORE ] = double( 1 ); - trackData[ Meta::Field::RATING ] = 1; - trackData[ Meta::Field::FIRST_PLAYED ] = QDateTime( QDate( 2012, 1, 1) ); - trackData[ Meta::Field::LAST_PLAYED ] = QDateTime( QDate( 2012, 1, 1) ); - trackData[ Meta::Field::PLAYCOUNT ] = 1; - trackData[ Meta::Field::UNIQUEID ] = "test uid"; - - MetaMock *testTrack = new MetaMock( trackData ); - - // Associate track with album, artist, etc. - MockAlbum *testAlbum = new MockAlbum( "test album" ); - MockArtist *testArtist = new MockArtist( "test artist" ); - MockComposer *testComposer = new MockComposer( "test composer" ); - MockGenre *testGenre = new MockGenre( "test genre" ); - MockYear *testYear = new MockYear( "2012" ); - MockLabel *testLabel1 = new MockLabel( "test label 1"); - MockLabel *testLabel2 = new MockLabel( "test label 2" ); - MockLabel *testLabel3 = new MockLabel( "test label 3" ); - - // For valAlbumArtist - testAlbum->m_albumArtist = testArtist; - - testTrack->m_album = testAlbum; - testTrack->m_artist = testArtist; - testTrack->m_composer = testComposer; - testTrack->m_genre = testGenre; - testTrack->m_year = testYear; - testTrack->m_labels << Meta::LabelPtr( testLabel1 ) - << Meta::LabelPtr( testLabel2 ) - << Meta::LabelPtr( testLabel3 ); - - // Make the track pointer point to the created track - trackPtr = Meta::TrackPtr( testTrack ); - - // Case 0 - QVariant trackValue = valueForField( qint64( 0 ), trackPtr ); - QVERIFY( trackValue.toStringList().contains( trackData.value( Meta::Field::URL ).value().path() - + trackData.value( Meta::Field::TITLE ).toString() - + trackData.value( Meta::Field::COMMENT ).toString() ) ); - QVERIFY( trackValue.toStringList().contains( testAlbum->name() ) ); - QVERIFY( trackValue.toStringList().contains( testArtist->name() ) ); - QVERIFY( trackValue.toStringList().contains( testGenre->name() ) ); - - // Case Meta::valUrl - trackValue = valueForField( Meta::valUrl, trackPtr ); - QVERIFY( trackValue.toString() == trackData.value( Meta::Field::URL ).value().path() ); - - // Case Meta::valTitle - trackValue = valueForField( Meta::valTitle, trackPtr ); - QVERIFY( trackValue.toString() == trackData.value( Meta::Field::TITLE ).toString() ); - - // Case Meta::valArtist for non-null artist - trackValue = valueForField( Meta::valArtist, trackPtr ); - QVERIFY( trackValue.toString() == testArtist->name() ); - - // Case Meta::valAlbum for non-null album - trackValue = valueForField( Meta::valAlbum, trackPtr ); - QVERIFY( trackValue.toString() == testAlbum->name() ); - - // Case Meta::valComposer for non-null composer - trackValue = valueForField( Meta::valComposer, trackPtr ); - QVERIFY( trackValue.toString() == testComposer->name() ); - - // Case Meta::valGenre for non-null genre - trackValue = valueForField( Meta::valGenre, trackPtr ); - QVERIFY( trackValue.toString() == testGenre->name() ); - - // Case Meta::valYear for non-null year - trackValue = valueForField( Meta::valYear, trackPtr ); - QVERIFY( trackValue.toInt() == testYear->name().toInt() ); - - // Case Meta::valComment - trackValue = valueForField( Meta::valComment, trackPtr ); - QVERIFY( trackValue.toString() == trackData.value( Meta::Field::COMMENT ).toString() ); - - // Case Meta::valTrackNr - trackValue = valueForField( Meta::valTrackNr, trackPtr ); - QVERIFY( trackValue.toInt() == trackData.value( Meta::Field::TRACKNUMBER ).toInt() ); - - // Case Meta::valDiscNr - trackValue = valueForField( Meta::valDiscNr, trackPtr ); - QVERIFY( trackValue.toInt() == trackData.value( Meta::Field::DISCNUMBER ).toInt() ); - - // Case Meta::valBpm - trackValue = valueForField( Meta::valBpm, trackPtr ); - QVERIFY( trackValue.toDouble() == trackData.value( Meta::Field::BPM ).toDouble() ); - - // Case Meta::valLength - trackValue = valueForField( Meta::valLength, trackPtr ); - QVERIFY( trackValue.toInt() == trackData.value( Meta::Field::LENGTH ).toInt()); - - // Case Meta::valBitrate - trackValue = valueForField( Meta::valBitrate, trackPtr ); - QVERIFY( trackValue.toInt() == trackData.value( Meta::Field::BITRATE ).toInt() ); - - // Case Meta::valSamplerate - trackValue = valueForField( Meta::valSamplerate, trackPtr ); - QVERIFY( trackValue.toInt() == trackData.value( Meta::Field::SAMPLERATE ).toInt() ); - - // Case Meta::valFilesize - trackValue = valueForField( Meta::valFilesize, trackPtr ); - QVERIFY( trackValue.toInt() == trackData.value( Meta::Field::FILESIZE ).toInt() ); - - // Case Meta::valFormat - trackValue = valueForField( Meta::valFormat, trackPtr ); - QVERIFY( trackValue.toInt() == int( Amarok::FileTypeSupport::fileType(trackPtr->type() ) ) ); - - // Case Meta::valCreateDate - trackValue = valueForField( Meta::valCreateDate, trackPtr ); - QVERIFY( trackValue.toDateTime().isNull() ); - - // Case Meta::valScore - trackValue = valueForField( Meta::valScore, trackPtr ); - QVERIFY( trackValue.toInt() == trackData.value( Meta::Field::SCORE ).toInt() ); - - // Case Meta::valRating - trackValue = valueForField( Meta::valRating, trackPtr ); - QVERIFY( trackValue.toInt() == trackData.value( Meta::Field::RATING ).toInt() ); - - // Case Meta::valFirstPlayed - trackValue = valueForField( Meta::valFirstPlayed, trackPtr ); - QVERIFY( trackValue.toDateTime() == trackData.value( Meta::Field::FIRST_PLAYED ).toDateTime() ); - - // Case Meta::valLastPlayed - trackValue = valueForField( Meta::valLastPlayed, trackPtr ); - QVERIFY( trackValue.toDateTime() == trackData.value( Meta::Field::LAST_PLAYED ).toDateTime() ); - - // Case Meta::valFilesize - trackValue = valueForField( Meta::valPlaycount, trackPtr ); - QVERIFY( trackValue.toInt() == trackData.value( Meta::Field::PLAYCOUNT ).toInt() ); - - // Case Meta::valUniqueId - trackValue = valueForField( Meta::valUniqueId, trackPtr ); - QVERIFY( trackValue.toString() == trackData.value( Meta::Field::UNIQUEID ).toString() ); - - // Case Meta::valTrackGain - trackValue = valueForField( Meta::valTrackGain, trackPtr ); - QVERIFY( trackValue.toString() == "track gain" ); - - // Case Meta::valTrackGainPeak - trackValue = valueForField( Meta::valTrackGainPeak, trackPtr ); - QVERIFY( trackValue.toString() == "track gain peak" ); - - // Case Meta::valAlbumGainGain - trackValue = valueForField( Meta::valAlbumGain, trackPtr ); - QVERIFY( trackValue.toString() == "album gain" ); - - // Case Meta::valAlbumGain - trackValue = valueForField( Meta::valAlbumGainPeak, trackPtr ); - QVERIFY( trackValue.toString() == "album gain peak" ); - - // Case Meta::valAlbumArtist - trackValue = valueForField( Meta::valAlbumArtist, trackPtr ); - QVERIFY( trackValue.toString() == testAlbum->albumArtist()->name() ); - - // Case Meta::valLabel, order of the label names remains same - trackValue = valueForField( Meta::valLabel, trackPtr ); - QStringList labelNames; - labelNames << testLabel1->name() << testLabel2->name() << testLabel3->name(); - QVERIFY( trackValue.toStringList() == labelNames ); - - // Case Meta::valModified - trackValue = valueForField( Meta::valModified, trackPtr ); - QVERIFY( trackValue.toDateTime().isNull() ); - - // Default, returns an invalid QVariant - trackValue = valueForField( qint64( -1 ), trackPtr ); - QVERIFY( !trackValue.isValid() ); - - // Cases with null artist, album, etc. where an invalid QVariant is returned - testAlbum->m_albumArtist = 0; - testTrack->m_album = 0; - testTrack->m_artist = 0; - testTrack->m_composer = 0; - testTrack->m_genre = 0; - testTrack->m_year = 0; - - // Case Meta::valArtist for null artist - trackValue = valueForField( Meta::valArtist, trackPtr ); - QVERIFY( !trackValue.isValid() ); - - // Case Meta::valAlbum for null album - trackValue = valueForField( Meta::valAlbum, trackPtr ); - QVERIFY( !trackValue.isValid() ); - - // Case Meta::valComposer for null composer - trackValue = valueForField( Meta::valComposer, trackPtr ); - QVERIFY( !trackValue.isValid() ); - - // Case Meta::valGenre for null genre - trackValue = valueForField( Meta::valGenre, trackPtr ); - QVERIFY( !trackValue.isValid() ); - - // Case Meta::valYear for null year - trackValue = valueForField( Meta::valYear, trackPtr ); - QVERIFY( !trackValue.isValid() ); - - // Case Meta::valAlbumArtist for null album artist - trackValue = valueForField( Meta::valAlbumArtist, trackPtr ); - QVERIFY( !trackValue.isValid() ); -} diff --git a/amarok/tests/core/meta/support/TestMetaConstants.h b/amarok/tests/core/meta/support/TestMetaConstants.h deleted file mode 100644 index ba26cf78..00000000 --- a/amarok/tests/core/meta/support/TestMetaConstants.h +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Jasneet Singh Bhatti * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef TESTMETACONSTANTS_H -#define TESTMETACONSTANTS_H - -#include - -class TestMetaConstants : public QObject -{ - Q_OBJECT - - private slots: - // Data driven tests - void testNameForField_data(); - void testNameForField(); - void testFieldForName_data(); - void testFieldForName(); - void testI18nForField_data(); - void testI18nForField(); - void testShortI18nForField_data(); - void testShortI18nForField(); - void testPlaylistNameForField_data(); - void testPlaylistNameForField(); - void testFieldForPlaylistName_data(); - void testFieldForPlaylistName(); - void testIconForField_data(); - void testIconForField(); - - // Uses Mock classes for testing - void testValueForField(); - - private: - // Test data shared by testNameForField and testFieldForName - void dataNameField(); - - // Test data shared by testPlaylistNameForField and testFieldForPlaylistName - void dataPlaylistNameField(); -}; - -#endif // TESTMETACONSTANTS_H diff --git a/amarok/tests/core/meta/support/TestMetaTrackKey.cpp b/amarok/tests/core/meta/support/TestMetaTrackKey.cpp deleted file mode 100644 index 962e490a..00000000 --- a/amarok/tests/core/meta/support/TestMetaTrackKey.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Jasneet Singh Bhatti * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "TestMetaTrackKey.h" - -#include "config-amarok-test.h" -#include "core/meta/Meta.h" -#include "core/meta/support/MetaKeys.h" -#include "core-impl/collections/support/CollectionManager.h" - -#include - -QTEST_KDEMAIN_CORE( TestMetaTrackKey ) - -QString -TestMetaTrackKey::dataPath( const QString &relPath ) -{ - return QDir::toNativeSeparators( QString( AMAROK_TEST_DIR ) + '/' + relPath ); -} - -void -TestMetaTrackKey::testTrackKey() -{ - Meta::TrackPtr track; - track = CollectionManager::instance()->trackForUrl( dataPath( "data/audio/album/Track01.ogg" ) ); - - Meta::TrackKey trackKey1( track ); - - QCOMPARE( trackKey1.m_trackName, track->name() ); - QCOMPARE( trackKey1.m_discNumber, track->discNumber() ); - QCOMPARE( trackKey1.m_trackNumber, track->trackNumber() ); - QCOMPARE( trackKey1.m_artistName, track->artist()->name() ); - QCOMPARE( trackKey1.m_albumName, track->album()->name() ); -} - -void -TestMetaTrackKey::testOperatorAssignment() -{ - Meta::TrackPtr track; - track = CollectionManager::instance()->trackForUrl( dataPath( "data/audio/album/Track01.ogg" ) ); - - Meta::TrackKey trackKey1( track ), trackKey2; - - QVERIFY( !( trackKey1 == trackKey2 ) ); - - trackKey2 = trackKey1; - - QCOMPARE( trackKey1, trackKey2 ); -} diff --git a/amarok/tests/core/meta/support/TestMetaTrackKey.h b/amarok/tests/core/meta/support/TestMetaTrackKey.h deleted file mode 100644 index cec5099c..00000000 --- a/amarok/tests/core/meta/support/TestMetaTrackKey.h +++ /dev/null @@ -1,40 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Jasneet Singh Bhatti * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef TESTMETATRACKKEY_H -#define TESTMETATRACKKEY_H - -#include - -class TestMetaTrackKey : public QObject -{ - Q_OBJECT - - private slots: - /** - * Test constructor TrackKey( const TrackPtr &track ) - */ - void testTrackKey(); - void testOperatorAssignment(); - - private: - /** - * For portability in fetching tracks from disk - */ - QString dataPath( const QString &relPath ); - -}; - -#endif // TESTMETATRACKKEY_H diff --git a/amarok/tests/core/meta/support/TestPrivateMetaRegistry.cpp b/amarok/tests/core/meta/support/TestPrivateMetaRegistry.cpp deleted file mode 100644 index b9e878b7..00000000 --- a/amarok/tests/core/meta/support/TestPrivateMetaRegistry.cpp +++ /dev/null @@ -1,175 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Jasneet Singh Bhatti * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "TestPrivateMetaRegistry.h" - -#include "config-amarok-test.h" -#include "core/meta/Meta.h" -#include "core/meta/support/PrivateMetaRegistry.h" -#include "core-impl/collections/support/CollectionManager.h" - -#include - -using namespace Meta; - -QTEST_KDEMAIN_CORE( TestPrivateMetaRegistry ) - -TestPrivateMetaRegistry::~TestPrivateMetaRegistry() -{ -} - -void -TestPrivateMetaRegistry::initTestCase() -{ - m_track1 = CollectionManager::instance()->trackForUrl( datapath( "data/audio/album/Track01.ogg" ) ); - m_track2 = CollectionManager::instance()->trackForUrl( datapath( "data/audio/album/Track02.ogg" ) ); - m_track3 = CollectionManager::instance()->trackForUrl( datapath( "data/audio/Platz 01.mp3" ) ); - m_track4 = CollectionManager::instance()->trackForUrl( datapath( "data/audio/Platz 02.mp3" ) ); - m_track5 = CollectionManager::instance()->trackForUrl( datapath( "data/audio/Platz 03.mp3" ) ); -} - -QString -TestPrivateMetaRegistry::datapath( const QString& relPath ) -{ - return QDir::toNativeSeparators( QString( AMAROK_TEST_DIR ) + '/' + relPath ); -} - -void -TestPrivateMetaRegistry::createTestData() -{ - QTest::addColumn( "owner" ); - QTest::addColumn( "key" ); - QTest::addColumn( "track" ); - QTest::addColumn( "album" ); - QTest::addColumn( "artist" ); - QTest::addColumn( "composer" ); - QTest::addColumn( "genre" ); - QTest::addColumn( "year" ); - - QTest::newRow( "Track01.ogg" ) << "Amarok" << "Amarok Test Album" << m_track1 << m_track1->album() - << m_track1->artist() << m_track1->composer() - << m_track1->genre() << m_track1->year(); - - QTest::newRow( "Track02.ogg" ) << "Amarok" << "Amarok Test Album" << m_track2 << m_track2->album() - << m_track2->artist() << m_track2->composer() - << m_track2->genre() << m_track2->year(); - - QTest::newRow( "Platz 01.mp3" ) << "Amarok" << "No album" << m_track3 << m_track3->album() - << m_track3->artist() << m_track3->composer() - << m_track3->genre() << m_track3->year(); - - QTest::newRow( "Platz 02.mp3" ) << "Amarok" << "No album" << m_track4 << m_track4->album() - << m_track4->artist() << m_track4->composer() - << m_track4->genre() << m_track4->year(); - - QTest::newRow( "Platz 03.mp3" ) << "owner" << "No album" << m_track5 << m_track5->album() - << m_track5->artist() << m_track5->composer() - << m_track5->genre() << m_track5->year(); -} - -void -TestPrivateMetaRegistry::testInsertAlbum_data() -{ - createTestData(); -} - -void -TestPrivateMetaRegistry::testInsertAlbum() -{ - QFETCH( QString, owner ); - QFETCH( QString, key ); - QFETCH( AlbumPtr, album ); - PrivateMetaRegistry::instance()->insertAlbum( owner, key, album ); - - QCOMPARE( PrivateMetaRegistry::instance()->album( owner, key ), album ); -} - -void -TestPrivateMetaRegistry::testInsertArtist_data() -{ - createTestData(); -} - -void -TestPrivateMetaRegistry::testInsertArtist() -{ - QFETCH( QString, owner ); - QFETCH( QString, key ); - QFETCH( ArtistPtr, artist ); - PrivateMetaRegistry::instance()->insertArtist( owner, key, artist ); - - QCOMPARE( PrivateMetaRegistry::instance()->artist( owner, key ), artist ); -} - -void -TestPrivateMetaRegistry::testInsertComposer_data() -{ - createTestData(); -} - -void -TestPrivateMetaRegistry::testInsertComposer() -{ - QFETCH( QString, owner ); - QFETCH( QString, key ); - QFETCH( ComposerPtr, composer ); - PrivateMetaRegistry::instance()->insertComposer( owner, key, composer ); - - QCOMPARE( PrivateMetaRegistry::instance()->composer( owner, key ), composer ); -} - -void -TestPrivateMetaRegistry::testInsertGenre_data() -{ - createTestData(); -} - -void -TestPrivateMetaRegistry::testInsertGenre() -{ - QFETCH( QString, owner ); - QFETCH( QString, key ); - QFETCH( GenrePtr, genre ); - PrivateMetaRegistry::instance()->insertGenre( owner, key, genre ); - - QCOMPARE( PrivateMetaRegistry::instance()->genre( owner, key ), genre ); -} - -void -TestPrivateMetaRegistry::testInsertYear_data() -{ - createTestData(); -} - -void -TestPrivateMetaRegistry::testInsertYear() -{ - QFETCH( QString, owner ); - QFETCH( QString, key ); - QFETCH( YearPtr, year ); - PrivateMetaRegistry::instance()->insertYear( owner, key, year ); - - QCOMPARE( PrivateMetaRegistry::instance()->year( owner, key ), year ); -} - -void -TestPrivateMetaRegistry::testNull() -{ - QVERIFY( !PrivateMetaRegistry::instance()->album( "invalid", "invalid" ) ); - QVERIFY( !PrivateMetaRegistry::instance()->artist( "invalid", "invalid" ) ); - QVERIFY( !PrivateMetaRegistry::instance()->composer( "invalid", "invalid" ) ); - QVERIFY( !PrivateMetaRegistry::instance()->genre( "invalid", "invalid" ) ); - QVERIFY( !PrivateMetaRegistry::instance()->year( "invalid", "invalid" ) ); -} diff --git a/amarok/tests/core/meta/support/TestPrivateMetaRegistry.h b/amarok/tests/core/meta/support/TestPrivateMetaRegistry.h deleted file mode 100644 index 320e2808..00000000 --- a/amarok/tests/core/meta/support/TestPrivateMetaRegistry.h +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Jasneet Singh Bhatti * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef TESTMETAPRIVATEMETAREGISTRY_H -#define TESTMETAPRIVATEMETAREGISTRY_H - -#include "core/meta/forward_declarations.h" - -#include - -using namespace Meta; - -class TestPrivateMetaRegistry : public QObject -{ - Q_OBJECT - - public: - ~TestPrivateMetaRegistry(); - - private slots: - void initTestCase(); - - /** - * Data driven testing - */ - void testInsertAlbum_data(); - void testInsertAlbum(); - void testInsertArtist_data(); - void testInsertArtist(); - void testInsertComposer_data(); - void testInsertComposer(); - void testInsertGenre_data(); - void testInsertGenre(); - void testInsertYear_data(); - void testInsertYear(); - - /** - * Test if the getters correctly return a pointer to null for a non-existing - * combination of owner and key. - * This is done in a separate method to avoid repetition of this verification - * for each instance of the test data - */ - void testNull(); - - private: - /** - * For portability in fetching tracks from disk - */ - QString datapath( const QString &relPath ); - - /** - * All _data() methods use this to create test data - */ - void createTestData(); - - /** - * Test tracks required for generating test data - */ - TrackPtr m_track1, m_track2, m_track3, m_track4, m_track5; -}; - -#endif // TESTMETAPRIVATEMETAREGISTRY_H diff --git a/amarok/tests/core/playlists/CMakeLists.txt b/amarok/tests/core/playlists/CMakeLists.txt deleted file mode 100644 index 43217901..00000000 --- a/amarok/tests/core/playlists/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -include_directories( . - ${AMAROK_TEST_TREE} - ${CMAKE_BINARY_DIR}/tests -) - -#------------------------ Test PlaylistFormat ----------------------------- - -set( testplaylistformat_SRCS TestPlaylistFormat.cpp ) -kde4_add_unit_test( testplaylistformat ${testplaylistformat_SRCS} ) -target_link_libraries( testplaylistformat ${KDE4_KDECORE_LIBS} ${QT_QTTEST_LIBRARY} amarokcore amaroklib ) - -#------------------------ Test PlaylistObserver ----------------------------- - -set( testplaylistobserver_SRCS - TestPlaylistObserver.cpp - ${AMAROK_SOURCE_TREE}/core/playlists/Playlist.cpp - ) -kde4_add_unit_test( testplaylistobserver ${testplaylistobserver_SRCS} ) -target_link_libraries( testplaylistobserver ${KDE4_THREADWEAVER_LIBS} ${KDE4_KDECORE_LIBS} ${QT_QTTEST_LIBRARY} ${QT_QTCORE_LIBRARY} amarokcore amaroklib ) diff --git a/amarok/tests/core/playlists/TestPlaylistFormat.cpp b/amarok/tests/core/playlists/TestPlaylistFormat.cpp deleted file mode 100644 index d853aa95..00000000 --- a/amarok/tests/core/playlists/TestPlaylistFormat.cpp +++ /dev/null @@ -1,111 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Jasneet Singh Bhatti * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "TestPlaylistFormat.h" - -#include "core/playlists/PlaylistFormat.h" - -#include - -#include - -// so that PlaylistFormat can be used in QTest::addColumn() -Q_DECLARE_METATYPE( Playlists::PlaylistFormat ) - -QTEST_KDEMAIN_CORE( TestPlaylistFormat ) - -TestPlaylistFormat::TestPlaylistFormat() -{ -} - -void -TestPlaylistFormat::testGetFormat_data() -{ - QTest::addColumn( "filename" ); - QTest::addColumn( "playlistFormat" ); - - // valid formats - QTest::newRow( "m3u" ) << "playlist.m3u" << Playlists::M3U; - QTest::newRow( "m3u8" ) << "playlist.m3u8" << Playlists::M3U; - QTest::newRow( "pls" ) << "playlist.pls" << Playlists::PLS; - QTest::newRow( "ram" ) << "playlist.ram" << Playlists::RAM; - QTest::newRow( "smil" ) << "playlist.smil" << Playlists::SMIL; - QTest::newRow( "asx" ) << "playlist.asx" << Playlists::ASX; - QTest::newRow( "wax" ) << "playlist.wax" << Playlists::ASX; - QTest::newRow( "xml" ) << "playlist.xml" << Playlists::XML; - QTest::newRow( "xspf" ) << "playlist.xspf" << Playlists::XSPF; - - // unknown or invalid formats - QTest::newRow( "vlc" ) << "playlist.vlc" << Playlists::Unknown; - QTest::newRow( "invalidformat" ) << "playlist.invalidformat" << Playlists::NotPlaylist; - QTest::newRow( "dotted invalid" ) << "this.is.an.invalid.format" << Playlists::NotPlaylist; - QTest::newRow( "trailing dot" ) << "this.is.an.invalid.format.with.trailing.dot." << Playlists::NotPlaylist; - QTest::newRow( "no dot" ) << "NoDots" << Playlists::NotPlaylist; - QTest::newRow( "empty string" ) << "" << Playlists::NotPlaylist; -} - -void -TestPlaylistFormat::testGetFormat() -{ - QFETCH( QString, filename ); - QFETCH( Playlists::PlaylistFormat, playlistFormat ); - KUrl url( "amarok:///playlists/" ); - - url.setFileName( filename ); - QCOMPARE( Playlists::getFormat( url ), playlistFormat ); - // file extensions in capitals must also pass this test - url.setFileName( filename.toUpper() ); - QCOMPARE( Playlists::getFormat( url ), playlistFormat ); -} - -void -TestPlaylistFormat::testIsPlaylist_data() -{ - QTest::addColumn( "filename" ); - QTest::addColumn( "isPlaylist" ); - - // valid formats - QTest::newRow( "m3u" ) << "playlist.m3u" << true; - QTest::newRow( "m3u8" ) << "playlist.m3u8" << true; - QTest::newRow( "pls" ) << "playlist.pls" << true; - QTest::newRow( "ram" ) << "playlist.ram" << true; - QTest::newRow( "smil" ) << "playlist.smil" << true; - QTest::newRow( "asx" ) << "playlist.asx" << true; - QTest::newRow( "wax" ) << "playlist.wax" << true; - QTest::newRow( "xml" ) << "playlist.xml" << true; - QTest::newRow( "xspf" ) << "playlist.xspf" << true; - - // unknown or invalid formats - QTest::newRow( "vlc" ) << "playlist.vlc" << false; - QTest::newRow( "invalidformat" ) << "playlist.invalidformat" << false; - QTest::newRow( "dotted invalid" ) << "this.is.an.invalid.format" << false; - QTest::newRow( "trailing dot" ) << "this.is.an.invalid.format.with.trailing.dot." << false; - QTest::newRow( "no dot" ) << "NoDots" << false; - QTest::newRow( "empty string" ) << "" << false; -} - -void -TestPlaylistFormat::testIsPlaylist() -{ - QFETCH( QString, filename ); - QFETCH( bool, isPlaylist ); - KUrl url( "amarok:///playlists/" ); - - url.setFileName( filename ); - QCOMPARE( Playlists::isPlaylist( url ), isPlaylist ); - // file extensions in capitals must also pass this test - url.setFileName( filename.toUpper() ); - QCOMPARE( Playlists::isPlaylist( url ), isPlaylist ); -} diff --git a/amarok/tests/core/playlists/TestPlaylistFormat.h b/amarok/tests/core/playlists/TestPlaylistFormat.h deleted file mode 100644 index fa121baa..00000000 --- a/amarok/tests/core/playlists/TestPlaylistFormat.h +++ /dev/null @@ -1,42 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Jasneet Singh Bhatti * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef TESTPLAYLISTFORMAT_H -#define TESTPLAYLISTFORMAT_H - -#include - -class TestPlaylistFormat : public QObject -{ - Q_OBJECT - - public: - TestPlaylistFormat(); - - private slots: - void testGetFormat_data(); - /** - * Check if the correct extension format for the playlist file is returned - */ - void testGetFormat(); - - void testIsPlaylist_data(); - /** - * Check if the extension format of the playlist file is supported or not - */ - void testIsPlaylist(); -}; - -#endif // TESTPLAYLISTFORMAT_H diff --git a/amarok/tests/core/playlists/TestPlaylistObserver.cpp b/amarok/tests/core/playlists/TestPlaylistObserver.cpp deleted file mode 100644 index 09fb1d72..00000000 --- a/amarok/tests/core/playlists/TestPlaylistObserver.cpp +++ /dev/null @@ -1,143 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Tatjana Gornak * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "TestPlaylistObserver.h" - -#include "EngineController.h" -#include "config-amarok-test.h" -#include "core/support/Components.h" -#include "core-impl/collections/support/CollectionManager.h" -#include "core-impl/playlists/types/file/xspf/XSPFPlaylist.h" - -#include -#include -#include -#include -#include -#include - -#include - -#include - -QTEST_KDEMAIN_CORE( TestPlaylistObserver ) - -TestPlaylistObserver::TestPlaylistObserver() - : m_observer( 0 ) -{ -} - -QString -TestPlaylistObserver::dataPath( const QString &relPath ) -{ - return QDir::toNativeSeparators( QString( AMAROK_TEST_DIR ) + "/data/playlists/" + relPath ); -} - -void -TestPlaylistObserver::initTestCase() -{ - KGlobal::locale(); - EngineController *controller = new EngineController(); - Amarok::Components::setEngineController( controller ); - CollectionManager::instance(); - - qRegisterMetaType( "Meta::TrackPtr" ); -} - -void -TestPlaylistObserver::cleanupTestCase() -{ - // Wait for other jobs, like MetaProxys fetching meta data, to finish - ThreadWeaver::Weaver::instance()->finish(); - - delete Amarok::Components::setEngineController( 0 ); -} - -void -TestPlaylistObserver::init() -{ - const QString testXspf = "test.xspf"; - const KUrl url = dataPath( testXspf ); - - m_testPlaylist = new Playlists::XSPFPlaylist( url ); - - // test that behaviour before loading is correct - QCOMPARE( m_testPlaylist->name(), QString( "test.xspf" ) ); - QCOMPARE( m_testPlaylist->trackCount(), -1 ); - - m_observer = new Observer(); - m_observer->subscribeTo( m_testPlaylist ); -} - -void -TestPlaylistObserver::cleanup() -{ - delete m_observer; - m_observer = 0; - m_testPlaylist = 0; -} - -void -TestPlaylistObserver::testMetadataChanged( ) -{ - QSKIP( "Functionality this test tests has not yet been implemented", SkipAll ); - QSignalSpy spy( m_observer, SIGNAL(metadataChangedSignal()) ); - m_testPlaylist->triggerTrackLoad(); - QVERIFY( QTest::kWaitForSignal( m_observer, SIGNAL(tracksLoadedSignal()), 10000 ) ); - - QVERIFY( spy.count() > 0 ); - // changed methadata means that we should get new name - QCOMPARE( m_testPlaylist->name(), QString( "my playlist" ) ); -} - -void -TestPlaylistObserver::testTracksLoaded() -{ - m_testPlaylist->triggerTrackLoad(); - QVERIFY( QTest::kWaitForSignal( m_observer, SIGNAL(tracksLoadedSignal()), 10000 ) ); - - QCOMPARE( m_testPlaylist->trackCount(), 23 ); -} - -void -TestPlaylistObserver::testTrackAdded( ) -{ - QSignalSpy spy( m_observer, SIGNAL(trackAddedSignal()) ); - m_testPlaylist->triggerTrackLoad(); - QVERIFY( QTest::kWaitForSignal( m_observer, SIGNAL(tracksLoadedSignal()), 10000 ) ); - - QCOMPARE( spy.count(), 23 ); -} - -void -TestPlaylistObserver::testTrackRemoved() -{ - m_testPlaylist->triggerTrackLoad(); - QVERIFY( QTest::kWaitForSignal( m_observer, SIGNAL(tracksLoadedSignal()), 10000 ) ); - - QString newName = "test playlist written to.xspf"; - m_testPlaylist->setName( newName ); // don't overwrite original playlist - QSignalSpy spy( m_observer, SIGNAL(trackRemovedSignal()) ); - m_testPlaylist->removeTrack( -1 ); // no effect - m_testPlaylist->removeTrack( 0 ); // has effect - m_testPlaylist->removeTrack( 22 ); // no effect, too far - m_testPlaylist->removeTrack( 21 ); // has effect - QCOMPARE( m_testPlaylist->trackCount(), 21 ); - QCOMPARE( spy.count(), 2 ); - - qDebug() << dataPath( newName ); - QVERIFY( QFile::remove( dataPath( newName ) ) ); -} diff --git a/amarok/tests/core/playlists/TestPlaylistObserver.h b/amarok/tests/core/playlists/TestPlaylistObserver.h deleted file mode 100644 index 503ed719..00000000 --- a/amarok/tests/core/playlists/TestPlaylistObserver.h +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Tatjana Gornak * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef TESTPLAYLISTOBSERVER_H -#define TESTPLAYLISTOBSERVER_H - -#include "core/playlists/Playlist.h" - -#include -#include -#include - -class Observer : public QObject, public Playlists::PlaylistObserver -{ - Q_OBJECT - - public: - virtual void metadataChanged( Playlists::PlaylistPtr ) - { - emit metadataChangedSignal(); - } - virtual void tracksLoaded( Playlists::PlaylistPtr ) - { - emit tracksLoadedSignal(); - } - virtual void trackAdded( Playlists::PlaylistPtr, Meta::TrackPtr, int ) - { - emit trackAddedSignal(); - } - virtual void trackRemoved( Playlists::PlaylistPtr, int ) - { - emit trackRemovedSignal(); - } - - signals: - void metadataChangedSignal(); - void tracksLoadedSignal(); - void trackAddedSignal(); - void trackRemovedSignal(); -}; - -class TestPlaylistObserver : public QObject -{ - Q_OBJECT - - public: - TestPlaylistObserver(); - - private slots: - void initTestCase(); - void cleanupTestCase(); - - void init(); - void cleanup(); - - void testMetadataChanged(); - void testTracksLoaded(); - void testTrackAdded(); - void testTrackRemoved(); - - private: - QString dataPath( const QString &relPath ); - - Playlists::PlaylistPtr m_testPlaylist; - Observer *m_observer; -}; - -#endif // TESTPLAYLISTOBSERVER_H diff --git a/amarok/tests/data/audio/Platz 01.mp3 b/amarok/tests/data/audio/Platz 01.mp3 deleted file mode 100644 index bff017c7..00000000 Binary files a/amarok/tests/data/audio/Platz 01.mp3 and /dev/null differ diff --git a/amarok/tests/data/audio/Platz 02.mp3 b/amarok/tests/data/audio/Platz 02.mp3 deleted file mode 100644 index 8ceee83a..00000000 Binary files a/amarok/tests/data/audio/Platz 02.mp3 and /dev/null differ diff --git a/amarok/tests/data/audio/Platz 03.mp3 b/amarok/tests/data/audio/Platz 03.mp3 deleted file mode 100644 index 852488f1..00000000 Binary files a/amarok/tests/data/audio/Platz 03.mp3 and /dev/null differ diff --git a/amarok/tests/data/audio/Platz 04.mp3 b/amarok/tests/data/audio/Platz 04.mp3 deleted file mode 100644 index 56b00eb4..00000000 Binary files a/amarok/tests/data/audio/Platz 04.mp3 and /dev/null differ diff --git a/amarok/tests/data/audio/Platz 05.mp3 b/amarok/tests/data/audio/Platz 05.mp3 deleted file mode 100644 index 4a9d9a72..00000000 Binary files a/amarok/tests/data/audio/Platz 05.mp3 and /dev/null differ diff --git a/amarok/tests/data/audio/Platz 06.mp3 b/amarok/tests/data/audio/Platz 06.mp3 deleted file mode 100644 index 961b7f16..00000000 Binary files a/amarok/tests/data/audio/Platz 06.mp3 and /dev/null differ diff --git a/amarok/tests/data/audio/Platz 07.mp3 b/amarok/tests/data/audio/Platz 07.mp3 deleted file mode 100644 index 4c7dfb58..00000000 Binary files a/amarok/tests/data/audio/Platz 07.mp3 and /dev/null differ diff --git a/amarok/tests/data/audio/Platz 08.mp3 b/amarok/tests/data/audio/Platz 08.mp3 deleted file mode 100644 index b5c72989..00000000 Binary files a/amarok/tests/data/audio/Platz 08.mp3 and /dev/null differ diff --git a/amarok/tests/data/audio/Platz 09.mp3 b/amarok/tests/data/audio/Platz 09.mp3 deleted file mode 100644 index d83c613e..00000000 Binary files a/amarok/tests/data/audio/Platz 09.mp3 and /dev/null differ diff --git a/amarok/tests/data/audio/Platz 10.mp3 b/amarok/tests/data/audio/Platz 10.mp3 deleted file mode 100644 index 1aa5ec09..00000000 Binary files a/amarok/tests/data/audio/Platz 10.mp3 and /dev/null differ diff --git a/amarok/tests/data/audio/album/Track01.ogg b/amarok/tests/data/audio/album/Track01.ogg deleted file mode 100644 index 3f4fbb39..00000000 Binary files a/amarok/tests/data/audio/album/Track01.ogg and /dev/null differ diff --git a/amarok/tests/data/audio/album/Track02.ogg b/amarok/tests/data/audio/album/Track02.ogg deleted file mode 100644 index 969bc404..00000000 Binary files a/amarok/tests/data/audio/album/Track02.ogg and /dev/null differ diff --git a/amarok/tests/data/audio/album/Track03.ogg b/amarok/tests/data/audio/album/Track03.ogg deleted file mode 100644 index a9fdb5a7..00000000 Binary files a/amarok/tests/data/audio/album/Track03.ogg and /dev/null differ diff --git a/amarok/tests/data/audio/album2/Track01.ogg b/amarok/tests/data/audio/album2/Track01.ogg deleted file mode 100644 index bd713dcc..00000000 Binary files a/amarok/tests/data/audio/album2/Track01.ogg and /dev/null differ diff --git a/amarok/tests/data/audio/album2/Track02.ogg b/amarok/tests/data/audio/album2/Track02.ogg deleted file mode 100644 index 88009cf8..00000000 Binary files a/amarok/tests/data/audio/album2/Track02.ogg and /dev/null differ diff --git a/amarok/tests/data/cue/invalid.cue b/amarok/tests/data/cue/invalid.cue deleted file mode 100644 index 5dd91889..00000000 --- a/amarok/tests/data/cue/invalid.cue +++ /dev/null @@ -1,9 +0,0 @@ -sdfasf -asdf -asdf -asdf -awd -fa -sdfadsfa -sdfa -sdf \ No newline at end of file diff --git a/amarok/tests/data/cue/test_silence.ogg b/amarok/tests/data/cue/test_silence.ogg deleted file mode 100644 index 5f8f788b..00000000 Binary files a/amarok/tests/data/cue/test_silence.ogg and /dev/null differ diff --git a/amarok/tests/data/cue/testsheet01-iso8859-1.cue b/amarok/tests/data/cue/testsheet01-iso8859-1.cue deleted file mode 100644 index 9ec80bcc..00000000 --- a/amarok/tests/data/cue/testsheet01-iso8859-1.cue +++ /dev/null @@ -1,45 +0,0 @@ -PERFORMER "Die Toten Hosen" -TITLE "In aller Stille (2008)" -FILE "Die Toten Hosen - In aller Stille (2008).mp3" MP3 - TRACK 01 AUDIO - TITLE "Strom" - INDEX 01 00:00:00 - TRACK 02 AUDIO - TITLE "Innen alles neu" - INDEX 01 02:48:06 - TRACK 03 AUDIO - TITLE "Disco" - INDEX 01 05:45:27 - TRACK 04 AUDIO - TITLE "Teil von mir" - INDEX 01 09:07:42 - TRACK 05 AUDIO - TITLE "Auflsen" - INDEX 01 12:07:69 - TRACK 06 AUDIO - TITLE "Leben ist tdlich" - INDEX 01 15:27:40 - TRACK 07 AUDIO - TITLE "Ertrinken" - INDEX 01 18:54:40 - TRACK 08 AUDIO - TITLE "Alles was war" - INDEX 01 23:07:58 - TRACK 09 AUDIO - TITLE "Pessimist" - INDEX 01 26:13:32 - TRACK 10 AUDIO - TITLE "Wir bleiben stumm" - INDEX 01 29:00:44 - TRACK 11 AUDIO - TITLE "Die letzte Schlacht" - INDEX 01 32:34:44 - TRACK 12 AUDIO - TITLE "Tauschen gegen dich" - INDEX 01 35:38:37 - TRACK 13 AUDIO - TITLE "Angst" - INDEX 01 38:54:67 - TRACK 14 AUDIO - TITLE "Bonus Track" - INDEX 01 42:06:30 diff --git a/amarok/tests/data/cue/testsheet01-utf8.cue b/amarok/tests/data/cue/testsheet01-utf8.cue deleted file mode 100644 index 1df8b7aa..00000000 --- a/amarok/tests/data/cue/testsheet01-utf8.cue +++ /dev/null @@ -1,45 +0,0 @@ -PERFORMER "Die Toten Hosen" -TITLE "In aller Stille (2008)" -FILE "Die Toten Hosen - In aller Stille (2008).mp3" MP3 - TRACK 01 AUDIO - TITLE "Strom" - INDEX 01 00:00:00 - TRACK 02 AUDIO - TITLE "Innen alles neu" - INDEX 01 02:48:06 - TRACK 03 AUDIO - TITLE "Disco" - INDEX 01 05:45:27 - TRACK 04 AUDIO - TITLE "Teil von mir" - INDEX 01 09:07:42 - TRACK 05 AUDIO - TITLE "Auflösen" - INDEX 01 12:07:69 - TRACK 06 AUDIO - TITLE "Leben ist tödlich" - INDEX 01 15:27:40 - TRACK 07 AUDIO - TITLE "Ertrinken" - INDEX 01 18:54:40 - TRACK 08 AUDIO - TITLE "Alles was war" - INDEX 01 23:07:58 - TRACK 09 AUDIO - TITLE "Pessimist" - INDEX 01 26:13:32 - TRACK 10 AUDIO - TITLE "Wir bleiben stumm" - INDEX 01 29:00:44 - TRACK 11 AUDIO - TITLE "Die letzte Schlacht" - INDEX 01 32:34:44 - TRACK 12 AUDIO - TITLE "Tauschen gegen dich" - INDEX 01 35:38:37 - TRACK 13 AUDIO - TITLE "Angst" - INDEX 01 38:54:67 - TRACK 14 AUDIO - TITLE "Bonus Track" - INDEX 01 42:06:30 diff --git a/amarok/tests/data/playlists/no-playlist.png b/amarok/tests/data/playlists/no-playlist.png deleted file mode 100644 index 69cf21a7..00000000 Binary files a/amarok/tests/data/playlists/no-playlist.png and /dev/null differ diff --git a/amarok/tests/data/playlists/test.asx b/amarok/tests/data/playlists/test.asx deleted file mode 100644 index 3a8ba9a8..00000000 --- a/amarok/tests/data/playlists/test.asx +++ /dev/null @@ -1,8 +0,0 @@ - - -:: Willkommen bei darkerradio - Tune in, turn on, burn out -darkerradio - - - - \ No newline at end of file diff --git a/amarok/tests/data/playlists/test.m3u b/amarok/tests/data/playlists/test.m3u deleted file mode 100644 index 04e3eebd..00000000 --- a/amarok/tests/data/playlists/test.m3u +++ /dev/null @@ -1,25 +0,0 @@ -#EXTM3U -# Note: the M3U playlist is verifying that the -# files actually exist when reading the -# playlist. So the path has to be valid. -#EXTINF:12,Free Music Charts - Platz 01 -../audio/Platz 01.mp3 -#EXTINF:8,Free Music Charts - Platz 02 -../audio/Platz 02.mp3 -#EXTINF:9,Free Music Charts - Platz 03 -../audio/Platz 03.mp3 -#EXTINF:12,Free Music Charts - Platz 04 -../audio/Platz 04.mp3 -#EXTINF:8,Free Music Charts - Platz 05 -../audio/Platz 05.mp3 -#EXTINF:9,Free Music Charts - Platz 06 -../audio/Platz 06.mp3 -#EXTINF:10,Free Music Charts - Platz 07 -../audio/Platz 07.mp3 -#EXTINF:13,Free Music Charts - Platz 08 -../audio/Platz 08.mp3 -#EXTINF:13,Free Music Charts - Platz 09 -../audio/Platz 09.mp3 -#EXTINF:12,Free Music Charts - Platz 10 -../audio/Platz 10.mp3 - diff --git a/amarok/tests/data/playlists/test.pls b/amarok/tests/data/playlists/test.pls deleted file mode 100644 index 18a4c536..00000000 --- a/amarok/tests/data/playlists/test.pls +++ /dev/null @@ -1,11 +0,0 @@ -audio/x-scpls pls -[playlist] -numberofentries=4 -File1=http://85.214.44.27:8000 -Title1=::darkerradio:: - DIE Alternative im Netz ::www.darkerradio.de:: Tune In, Turn On, Burn Out! -File2=http://217.20.121.40:8000 -Title2=::darkerradio:: - DIE Alternative im Netz ::www.darkerradio.de:: Tune In, Turn On, Burn Out! -File3=http://85.214.44.27:8100 -Title3=::darkerradio:: - DIE Alternative im Netz ::www.darkerradio.de:: Tune In, Turn On, Burn Out! -File4=http://85.214.44.27:8200 -Title4=::darkerradio:: - DIE Alternative im Netz ::www.darkerradio.de:: Tune In, Turn On, Burn Out! \ No newline at end of file diff --git a/amarok/tests/data/playlists/test.ram b/amarok/tests/data/playlists/test.ram deleted file mode 100644 index 6da15f36..00000000 --- a/amarok/tests/data/playlists/test.ram +++ /dev/null @@ -1 +0,0 @@ -http://85.214.44.27:8000/listen.pls \ No newline at end of file diff --git a/amarok/tests/data/playlists/test.smil b/amarok/tests/data/playlists/test.smil deleted file mode 100644 index d69a47ee..00000000 --- a/amarok/tests/data/playlists/test.smil +++ /dev/null @@ -1,74 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/amarok/tests/data/playlists/test.xspf b/amarok/tests/data/playlists/test.xspf deleted file mode 100644 index 05221cee..00000000 --- a/amarok/tests/data/playlists/test.xspf +++ /dev/null @@ -1,213 +0,0 @@ - - - my playlist - - - http://he3.magnatune.com/all/01-Sunset-Ammonite.ogg - http://he3.magnatune.com/all/01-Sunset-Ammonite.ogg - Sunset - Ammonite - Reconnection - 1 - 191000 - - - http://he3.magnatune.com/all/02-Heaven-Ammonite.ogg - http://he3.magnatune.com/all/02-Heaven-Ammonite.ogg - Heaven - Ammonite - Reconnection - 2 - 337000 - - - http://he3.magnatune.com/all/03-Liquid%20Sun-Ammonite.ogg - http://he3.magnatune.com/all/03-Liquid%20Sun-Ammonite.ogg - Liquid Sun - Ammonite - Reconnection - 3 - 383000 - - - http://he3.magnatune.com/all/04-Restrained%20Mind-Ammonite.ogg - http://he3.magnatune.com/all/04-Restrained%20Mind-Ammonite.ogg - Restrained Mind - Ammonite - Reconnection - 4 - 308000 - - - http://he3.magnatune.com/all/05-Rapture-Ammonite.ogg - http://he3.magnatune.com/all/05-Rapture-Ammonite.ogg - Rapture - Ammonite - Reconnection - 5 - 255000 - - - http://he3.magnatune.com/all/06-Calm-Ammonite.ogg - http://he3.magnatune.com/all/06-Calm-Ammonite.ogg - Calm - Ammonite - Reconnection - 6 - 301000 - - - http://he3.magnatune.com/all/07-Angel%20(hold%20on...)-Ammonite.ogg - http://he3.magnatune.com/all/07-Angel%20(hold%20on...)-Ammonite.ogg - Angel (hold on...) - Ammonite - Reconnection - 7 - 432000 - - - http://he3.magnatune.com/all/08-Broken-Ammonite.ogg - http://he3.magnatune.com/all/08-Broken-Ammonite.ogg - Broken - Ammonite - Reconnection - 8 - 257000 - - - http://he3.magnatune.com/all/09-Open%20Road-Ammonite.ogg - http://he3.magnatune.com/all/09-Open%20Road-Ammonite.ogg - Open Road - Ammonite - Reconnection - 9 - 343000 - - - http://he3.magnatune.com/all/10-Distant%20Love-Ammonite.ogg - http://he3.magnatune.com/all/10-Distant%20Love-Ammonite.ogg - Distant Love - Ammonite - Reconnection - 10 - 384000 - - - http://he3.magnatune.com/all/11-Touch-Ammonite.ogg - http://he3.magnatune.com/all/11-Touch-Ammonite.ogg - Touch - Ammonite - Reconnection - 11 - 571000 - - - http://he3.magnatune.com/all/12-Reconnection%20(outro)-Ammonite.ogg - http://he3.magnatune.com/all/12-Reconnection%20(outro)-Ammonite.ogg - Reconnection (outro) - Ammonite - Reconnection - 12 - 163000 - - - http://he3.magnatune.com/all/01--Should%20Be--Arthur%20Yoria.ogg - http://he3.magnatune.com/all/01--Should%20Be--Arthur%20Yoria.ogg - Should Be - Arthur Yoria - Handshake Smiles - 1 - 174000 - - - http://he3.magnatune.com/all/02--Clean%20For%20Free--Arthur%20Yoria.ogg - http://he3.magnatune.com/all/02--Clean%20For%20Free--Arthur%20Yoria.ogg - Clean For Free - Arthur Yoria - Handshake Smiles - 2 - 198000 - - - http://he3.magnatune.com/all/03--Handshake%20Smiles--Arthur%20Yoria.ogg - http://he3.magnatune.com/all/03--Handshake%20Smiles--Arthur%20Yoria.ogg - Handshake Smiles - Arthur Yoria - Handshake Smiles - 3 - 157000 - - - http://he3.magnatune.com/all/04--Jimmy's%20Rig--Arthur%20Yoria.ogg - http://he3.magnatune.com/all/04--Jimmy's%20Rig--Arthur%20Yoria.ogg - Jimmy's Rig - Arthur Yoria - Handshake Smiles - 4 - 177000 - - - http://he3.magnatune.com/all/05--Love%20Song%20in%20G--Arthur%20Yoria.ogg - http://he3.magnatune.com/all/05--Love%20Song%20in%20G--Arthur%20Yoria.ogg - Love Song in G - Arthur Yoria - Handshake Smiles - 5 - 221000 - - - http://he3.magnatune.com/all/06--Cuttin%20a%20Rug--Arthur%20Yoria.ogg - http://he3.magnatune.com/all/06--Cuttin%20a%20Rug--Arthur%20Yoria.ogg - Cuttin a Rug - Arthur Yoria - Handshake Smiles - 6 - 230000 - - - http://he3.magnatune.com/all/07--Sandy--Arthur%20Yoria.ogg - http://he3.magnatune.com/all/07--Sandy--Arthur%20Yoria.ogg - Sandy - Arthur Yoria - Handshake Smiles - 7 - 261000 - - - http://he3.magnatune.com/all/08--I%20Told%20You%20Not%20to%20Write%20Again--Arthur%20Yoria.ogg - http://he3.magnatune.com/all/08--I%20Told%20You%20Not%20to%20Write%20Again--Arthur%20Yoria.ogg - I Told You Not to Write Again - Arthur Yoria - Handshake Smiles - 8 - 227000 - - - http://he3.magnatune.com/all/09--Fool%20Me%20Again--Arthur%20Yoria.ogg - http://he3.magnatune.com/all/09--Fool%20Me%20Again--Arthur%20Yoria.ogg - Fool Me Again - Arthur Yoria - Handshake Smiles - 9 - 169000 - - - http://he3.magnatune.com/all/10--Rim%20Job--Arthur%20Yoria.ogg - http://he3.magnatune.com/all/10--Rim%20Job--Arthur%20Yoria.ogg - Rim Job - Arthur Yoria - Handshake Smiles - 10 - 246000 - - - http://he3.magnatune.com/all/11--Trash%20Bag--Arthur%20Yoria.ogg - http://he3.magnatune.com/all/11--Trash%20Bag--Arthur%20Yoria.ogg - Trash Bag - Arthur Yoria - Handshake Smiles - 11 - 297000 - - - diff --git a/amarok/tests/data/services/amazon/searchresponse.xml b/amarok/tests/data/services/amazon/searchresponse.xml deleted file mode 100644 index 8d2e4942..00000000 --- a/amarok/tests/data/services/amazon/searchresponse.xml +++ /dev/null @@ -1,489 +0,0 @@ - - - - - B001SW8TFC - The Cure - Greatest Hits - 989 - http://ecx.images-amazon.com/images/I/51L5Z-JXB3L._SL500_SS110_.jpg - - - B00666RKLE - The Cure - Bestival Live 2011 - 699 - http://ecx.images-amazon.com/images/I/61p6dd%2BShZL._SL500_SS110_.jpg - - - B003TZV8T0 - The Cure - Staring At The Sea - The Singles - 599 - http://ecx.images-amazon.com/images/I/51LN4o1DxYL._SL500_SS110_.jpg - - - B0045M8SDK - The Cure - Kiss Me, Kiss Me, Kiss Me - 599 - http://ecx.images-amazon.com/images/I/411ncIcC8vL._SL500_SS110_.jpg - - - B001SVN2NM - The Cure - Pornography - 599 - http://ecx.images-amazon.com/images/I/418turaImmL._SL500_SS110_.jpg - - - - B001SW3X58 - The Cure - Greatest Hits - B001SW8TFC - Lullaby - 99 - - - - B001SW8U92 - The Cure - Greatest Hits - B001SW8TFC - Friday I'm In Love - 99 - - - - B001SW8UI8 - The Cure - Greatest Hits - B001SW8TFC - Boys Don't Cry - 99 - - - - B001SWAZR2 - The Cure - Greatest Hits - B001SW8TFC - The Lovecats - 99 - - - - B001SWAXGA - The Cure - Greatest Hits - B001SW8TFC - Just Like Heaven - 99 - - - - B001SW3VXC - The Cure - Greatest Hits - B001SW8TFC - A Forest - 99 - - - - B001SWAYV4 - The Cure - Greatest Hits - B001SW8TFC - Lovesong - 99 - - - - B001SW6RHO - The Cure - Greatest Hits - B001SW8TFC - Close To Me - 99 - - - - B001SW53VU - The Cure - Greatest Hits - B001SW8TFC - Inbetween Days - 99 - - - - B003VW26FG - The Cure - 12" 80s Classics - B003VW9H8A - Lullaby - 99 - - - - B001SW8WDG - The Cure - Greatest Hits - B001SW8TFC - Why Can't I Be You? - 99 - - - - B0040BP98I - The Cure - Galore - The Singles 1987-1997 - B0040BROFO - Pictures Of You - 99 - - - - B00655JFDW - Jah Cure - Heart And Soul Riddim - B00655JD3Y - From My Heart - 99 - - - - B002VCWOJK - Jah Cure - The Universal Cure - B002VCULQ8 - Call On Me - 99 - http://ecx.images-amazon.com/images/I/51TnF-PKCcL._SL500_AA240_.jpg - - - B005K0DFX4 - The Cure - Boys Don't Cry - B005K0DFR0 - Boys Don't Cry - 99 - - - - B003MJM5XG - The Cure - Disintegration (Deluxe Edition) - B003MJQB9A - Plainsong (Remastered) - 99 - - - - B001SQ4WDG - The Cure - Seventeen Seconds - B001SQ6ZEK - A Forest - 99 - - - - B003TY24YO - The Cure - Join The Dots - The B-Sides & Rarities - B003TY21DS - Burn - 99 - - - - B004QMDJHY - The Cure - The Cure - Greatest Hits (Deluxe Sound & Vision) PAL - B004QM84TM - Friday I'm In Love (Album Version) - 99 - - - - B001SPPPGK - The Cure - Faith [Deluxe] - B001SPPMXG - Charlotte Sometimes - 99 - - - - B001SWAZJA - The Cure - Greatest Hits - B001SW8TFC - The Walk - 99 - - - - B004UQSCY6 - The Cure - Disintegration (Remastered) - B004UQSB8I - Lullaby - 99 - - - - B003TZT6LM - The Cure - Staring At The Sea - The Singles - B003TZV8T0 - A Forest - 99 - - - - B0049BARAE - The Cure - Greatest Hits - B0049B5GKU - A Forest (Acoustic Version) - 99 - - - - B0045MAPUY - The Cure - Kiss Me, Kiss Me, Kiss Me - B0045M8SDK - Hot Hot Hot!!! - 99 - - - - B003TZWXYO - The Cure - Staring At The Sea - The Singles - B003TZV8T0 - Charlotte Sometimes - 99 - - - - B004UQJ678 - The Cure - Disintegration (Remastered) - B004UQSB8I - Pictures Of You - 99 - - - - B003MJQD84 - The Cure - Disintegration (Deluxe Edition) - B003MJQB9A - Pictures Of You (RS Home Instrumental Demo) - 99 - - - - B001SQ5L9K - The Cure - Wish - B001SQ9PUQ - Friday I'm In Love - 99 - - - - B004QM85LO - The Cure - The Cure - Greatest Hits (Deluxe Sound & Vision) PAL - B004QM84TM - Lullaby - 99 - - - - B003TZRKE2 - The Cure - Staring At The Sea - The Singles - B003TZV8T0 - A Night Like This - 99 - - - - B0045MAP9U - The Cure - Kiss Me, Kiss Me, Kiss Me - B0045M8SDK - Why Can't I Be You? - 99 - - - - B003MJM612 - The Cure - Disintegration (Deluxe Edition) - B003MJQB9A - Pictures Of You (Remastered) - 99 - - - - B003MJOAPM - The Cure - Disintegration (Deluxe Edition) - B003MJQB9A - Fascination Street (Remastered) - 99 - - - - B001SVTDUI - The Cure - Faith - B001SVX1H4 - Faith - 99 - - - - B0045M6YD6 - The Cure - Kiss Me, Kiss Me, Kiss Me - B0045M8SDK - Just Like Heaven - 99 - - - - B001SQGPUE - The Cure - Wild Mood Swings - B001SQA686 - Gone! - 99 - - - - B001SPU4NY - The Cure - Seventeen Seconds [Deluxe] - B001SPQ6AE - A Forest - 99 - http://ecx.images-amazon.com/images/I/41NtuP%2BqlYL._SL500_AA240_.jpg - - - B00666RQCM - The Cure - Bestival Live 2011 - B00666RKLE - Just Like Heaven (Bestival Live 2011) - 89 - http://ecx.images-amazon.com/images/I/61p6dd%2BShZL._SL500_AA240_.jpg - - - B001SW3V3W - The Cure - Greatest Hits - B001SW8TFC - Mint Car - 99 - - - - B005K0DH1O - The Cure - Boys Don't Cry - B005K0DFR0 - Killing An Arab - 99 - - - - B001SQ6ZCW - The Cure - Wild Mood Swings - B001SQA686 - Want - 99 - - - - B001SQ5MCG - The Cure - Wish - B001SQ9PUQ - To Wish Impossible Things - 99 - - - - B001SPPN6W - The Cure - Faith [Deluxe] - B001SPPMXG - All Cats Are Grey - 99 - - - - B001SQ45Y2 - The Cure - The Head On The Door - B001SQ8B2Y - Kyoto Song - 99 - - - - B001SVR7CO - The Cure - Greatest Hits - B001SW8TFC - Cut Here - 99 - - - - B0045M5TQ4 - The Cure - Kiss Me, Kiss Me, Kiss Me - B0045M8SDK - The Kiss - 99 - - - - B001SVNNRW - The Cure - Three Imaginary Boys - B001SVHLE8 - 10:15 Saturday Night - 99 - - - - B001SQBK4K - The Cure - Wish - B001SQ9PUQ - Cut - 99 - - - - B001SQBJQE - The Cure - Wish - B001SQ9PUQ - From The Edge Of The Deep Green Sea - 99 - - \ No newline at end of file diff --git a/amarok/tests/dynamic/CMakeLists.txt b/amarok/tests/dynamic/CMakeLists.txt deleted file mode 100644 index c169732f..00000000 --- a/amarok/tests/dynamic/CMakeLists.txt +++ /dev/null @@ -1,63 +0,0 @@ -macro(link_database_test test_target) - - add_definitions(${MYSQL_CFLAGS}) - - if(APPLE) - SET_TARGET_PROPERTIES(${test_target} PROPERTIES LINK_FLAGS "-undefined dynamic_lookup") - endif(APPLE) - - add_dependencies( ${test_target} amarokconfig_h ) - add_dependencies( ${test_target} amarokcore ) - add_dependencies( ${test_target} amaroklib) - - target_link_libraries(${test_target} - amarokcore - amaroklib - ${KDE4_KDECORE_LIBS} - ${KDE4_KIO_LIBS} - ${KDE4_THREADWEAVER_LIBS} - ${KDE4_KDEUI_LIBS} - ${QT_QTTEST_LIBRARY} - ${QT_QTCORE_LIBRARY} - ${MYSQL_LIBRARIES} - ${CMAKE_DL_LIBS} -# ${TAGLIB-EXTRAS_LIBRARIES} -# ${TAGLIB_LIBRARIES} - ${ZLIB_LIBRARIES}) - -endmacro(link_database_test) - - -include_directories( - ${AMAROK_TEST_TREE} - ${AMAROK_SOURCE_TREE} - # ${AMAROK_SOURCE_TREE}/core-impl/logger - ${AMAROK_UTILITY_TREE} - ${CMAKE_BINARY_DIR}/src - ${CMAKE_BINARY_DIR}/src/dynamic - ${CMAKE_BINARY_DIR}/tests - ${AMAROK_COLLECTION_SUPPORT_DIR} - ${KDE4_INCLUDE_DIR} - ${QT_INCLUDES} - ${MYSQL_INCLUDE_DIR} - ) - -#------------------------------- DynamicModel Test ------------------------------- - -set( dynamicmodel_SRCS - TestDynamicModel.cpp - ) - -kde4_add_unit_test( testdynamicmodel TESTNAME testdynamicmodel ${dynamicmodel_SRCS} ) -link_database_test( testdynamicmodel ) - -#------------------------------- TrackSet Test ------------------------------- - -set( trackset_SRCS - TestTrackSet.cpp - ) - -kde4_add_unit_test( testtrackset TESTNAME testtrackset ${trackset_SRCS} ) -link_database_test( testtrackset ) - - diff --git a/amarok/tests/dynamic/TestDynamicModel.cpp b/amarok/tests/dynamic/TestDynamicModel.cpp deleted file mode 100644 index c8229fc7..00000000 --- a/amarok/tests/dynamic/TestDynamicModel.cpp +++ /dev/null @@ -1,357 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2011 Ralf Engels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "TestDynamicModel.h" - -#include "dynamic/Bias.h" -#include "dynamic/BiasedPlaylist.h" -#include "dynamic/DynamicModel.h" - -#include "core/support/Amarok.h" -#include "core/support/Debug.h" - -#include -#include - -#include -#include - -#include - -Q_DECLARE_METATYPE(QModelIndex); - -KTempDir *s_tmpDir = 0; - -// We return a special saveLocation. -QString Amarok::saveLocation( const QString &directory ) -{ - return s_tmpDir->name() + directory; -} - -QTEST_KDEMAIN( TestDynamicModel, GUI ) - -TestDynamicModel::TestDynamicModel() -{ - qRegisterMetaType(); -} - -void -TestDynamicModel::init() -{ - s_tmpDir = new KTempDir(); -} - -void -TestDynamicModel::cleanup() -{ - delete s_tmpDir; -} - -void -TestDynamicModel::testData() -{ - Dynamic::DynamicModel *model = Dynamic::DynamicModel::instance(); - - // load from the empty directory - model->loadPlaylists(); - - // now we should have the four default playlists - QModelIndex playlistIndex = model->index( 0, 0 ); - QCOMPARE( model->data( playlistIndex ).toString(), QString("Random") ); - QCOMPARE( model->data( playlistIndex, Qt::EditRole ).toString(), QString("Random") ); - QVERIFY( model->data( playlistIndex, Dynamic::DynamicModel::PlaylistRole ).isValid() ); - QVERIFY( !model->data( playlistIndex, Dynamic::DynamicModel::BiasRole ).isValid() ); - - QModelIndex biasIndex = model->index( 0, 0, playlistIndex ); - QVERIFY( !model->data( biasIndex ).toString().isEmpty() ); - QVERIFY( !model->data( biasIndex, Dynamic::DynamicModel::PlaylistRole ).isValid() ); - QVERIFY( model->data( biasIndex, Dynamic::DynamicModel::BiasRole ).isValid() ); -} - -void -TestDynamicModel::testPlaylistIndex() -{ - Dynamic::DynamicModel *model = Dynamic::DynamicModel::instance(); - - // load from the empty directory - model->loadPlaylists(); - - // now we should have the four default playlists - QCOMPARE( model->rowCount(), 4 ); - QCOMPARE( model->columnCount(), 1 ); - - // -- random playlist with one bias - QModelIndex playlistIndex = model->index( 0, 0 ); - QModelIndex biasIndex = model->index( 0, 0, playlistIndex ); - - QCOMPARE( model->rowCount( playlistIndex ), 1 ); - QCOMPARE( model->rowCount( biasIndex ), 0 ); - QCOMPARE( playlistIndex.parent(), QModelIndex() ); - QCOMPARE( biasIndex.parent(), playlistIndex ); - - // -- albumplay playlist with bias structure - playlistIndex = model->index( 2, 0 ); - biasIndex = model->index( 0, 0, playlistIndex ); - QModelIndex subBiasIndex = model->index( 1, 0, biasIndex ); - - QCOMPARE( model->rowCount( playlistIndex ), 1 ); - QCOMPARE( model->rowCount( biasIndex ), 2 ); - QCOMPARE( model->rowCount( subBiasIndex ), 0 ); - QCOMPARE( playlistIndex.parent(), QModelIndex() ); - QCOMPARE( biasIndex.parent(), playlistIndex ); - QCOMPARE( subBiasIndex.parent(), biasIndex ); - - - // and now the non-model index functions: - model->setActivePlaylist( 2 ); - Dynamic::DynamicPlaylist* playlist = model->activePlaylist(); - playlistIndex = model->index( model->activePlaylistIndex(), 0 ); - QCOMPARE( model->index( playlist ), playlistIndex ); - - Dynamic::BiasPtr bias = qobject_cast(playlist)->bias(); - biasIndex = model->index( 0, 0, playlistIndex ); - QCOMPARE( model->index( bias ), biasIndex ); - - Dynamic::BiasPtr subBias = qobject_cast(bias.data())->biases().at(0); - subBiasIndex = model->index( 0, 0, biasIndex ); - QCOMPARE( model->index( subBias ), subBiasIndex ); -} - -void -TestDynamicModel::testSlots() -{ - Dynamic::DynamicModel *model = Dynamic::DynamicModel::instance(); - - // load from the empty directory - model->loadPlaylists(); - - QSignalSpy spy1( model, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)) ); - QSignalSpy spy2( model, SIGNAL(rowsRemoved(QModelIndex,int,int)) ); - QSignalSpy spy3( model, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)) ); - QSignalSpy spy4( model, SIGNAL(rowsInserted(QModelIndex,int,int)) ); - - // -- removeAt with playlist - QModelIndex playlistIndex = model->index( 1, 0 ); - QString oldName = model->data( playlistIndex ).toString(); - - model->removeAt( playlistIndex ); - - QCOMPARE( spy1.count(), 1 ); - QCOMPARE( spy3.count(), 0 ); - QList args1 = spy1.takeFirst(); - QVERIFY( args1.value(0).canConvert() ); - QCOMPARE( args1.value(0).value(), QModelIndex() ); - QCOMPARE( args1.value(1).toInt(), 1 ); - QCOMPARE( args1.value(2).toInt(), 1 ); - QCOMPARE( spy2.count(), 1 ); - spy2.takeFirst(); - - // name should be different - playlistIndex = model->index( 1, 0 ); - QVERIFY( model->data( playlistIndex ).toString() != oldName ); - - QCOMPARE( model->rowCount(), 3 ); - - // -- removeAt with bias - playlistIndex = model->index( 1, 0 ); - QModelIndex biasIndex = model->index( 0, 0, playlistIndex ); - QModelIndex subBiasIndex = model->index( 0, 0, biasIndex ); - QCOMPARE( model->rowCount( biasIndex ), 2 ); - - model->removeAt( subBiasIndex ); - - QCOMPARE( spy1.count(), 1 ); - QCOMPARE( spy3.count(), 0 ); - args1 = spy1.takeFirst(); - QCOMPARE( args1.count(), 3 ); - QVERIFY( args1.value(0).canConvert() ); - QCOMPARE( args1.value(0).value(), biasIndex ); - QCOMPARE( args1.value(1).toInt(), 0 ); - QCOMPARE( args1.value(2).toInt(), 0 ); - QCOMPARE( spy2.count(), 1 ); - spy2.takeFirst(); - - QCOMPARE( model->rowCount( biasIndex ), 1 ); - QCOMPARE( model->rowCount(), 3 ); // only the bias was removed - - // -- cloneAt with level 2 bias - playlistIndex = model->index( 1, 0 ); - - biasIndex = model->index( 0, 0, playlistIndex ); - subBiasIndex = model->index( 0, 0, biasIndex ); - QCOMPARE( model->rowCount( biasIndex ), 1 ); - - QModelIndex resultIndex = model->cloneAt(subBiasIndex); - QCOMPARE( resultIndex.row(), 1 ); - QCOMPARE( resultIndex.parent(), biasIndex ); - - QCOMPARE( spy3.count(), 1 ); - args1 = spy3.takeFirst(); - QVERIFY( args1.value(0).canConvert() ); - QCOMPARE( args1.value(0).value(), biasIndex ); - QCOMPARE( args1.value(1).toInt(), 1 ); - QCOMPARE( args1.value(2).toInt(), 1 ); - QCOMPARE( spy4.count(), 1 ); - spy4.takeFirst(); - - QCOMPARE( model->rowCount( biasIndex ), 2 ); - QCOMPARE( model->rowCount(), 3 ); // only the bias was cloned - - // -- newPlaylist - QCOMPARE( spy1.count(), 0 ); - QCOMPARE( spy3.count(), 0 ); - - QCOMPARE( model->rowCount(), 3 ); - resultIndex = model->newPlaylist(); - QCOMPARE( model->rowCount(), 4 ); - - QCOMPARE( resultIndex.row(), 3 ); - QCOMPARE( resultIndex.parent(), QModelIndex() ); - - QCOMPARE( spy1.count(), 0 ); - QCOMPARE( spy3.count(), 1 ); - args1 = spy3.takeFirst(); - QVERIFY( args1.value(0).canConvert() ); - QCOMPARE( args1.value(0).value(), QModelIndex() ); - QCOMPARE( args1.value(1).toInt(), 3 ); - QCOMPARE( args1.value(2).toInt(), 3 ); - QCOMPARE( spy4.count(), 1 ); - spy4.takeFirst(); - - // -- cloneAt with playlist - playlistIndex = model->index( 1, 0 ); - - QCOMPARE( model->rowCount(), 4 ); - resultIndex = model->cloneAt(playlistIndex); - QCOMPARE( model->rowCount(), 5 ); - - QCOMPARE( resultIndex.row(), 4 ); - QCOMPARE( resultIndex.parent(), QModelIndex() ); - QCOMPARE( model->rowCount( resultIndex ), 1 ); - - QCOMPARE( spy3.count(), 1 ); - args1 = spy3.takeFirst(); - QVERIFY( args1.value(0).canConvert() ); - QCOMPARE( args1.value(0).value(), QModelIndex() ); - QCOMPARE( args1.value(1).toInt(), 4 ); - QCOMPARE( args1.value(2).toInt(), 4 ); - QCOMPARE( spy4.count(), 1 ); - spy4.takeFirst(); -} - -QModelIndex -TestDynamicModel::serializeUnserialize( const QModelIndex& index ) -{ - Dynamic::DynamicModel *model = Dynamic::DynamicModel::instance(); - - QByteArray bytes; - QDataStream stream( &bytes, QIODevice::WriteOnly ); - model->serializeIndex( &stream, index ); - - QDataStream stream2( &bytes, QIODevice::ReadOnly ); - return model->unserializeIndex( &stream2 ); -} - -void -TestDynamicModel::testSerializeIndex() -{ - Dynamic::DynamicModel *model = Dynamic::DynamicModel::instance(); - - // load from the empty directory - model->loadPlaylists(); - - QModelIndex playlistIndex = model->index( 2, 0 ); - QModelIndex biasIndex = model->index( 0, 0, playlistIndex ); - QModelIndex subBiasIndex = model->index( 0, 0, biasIndex ); - - QCOMPARE( QModelIndex(), serializeUnserialize( QModelIndex() ) ); - QCOMPARE( biasIndex, serializeUnserialize( biasIndex ) ); - QCOMPARE( subBiasIndex, serializeUnserialize( subBiasIndex ) ); -} - -void -TestDynamicModel::testDnD() -{ - Dynamic::DynamicModel *model = Dynamic::DynamicModel::instance(); - - // load from the empty directory - model->loadPlaylists(); - - // -- copy a playlist - QModelIndex playlistIndex = model->index( 2, 0 ); - QModelIndexList indexes; - indexes << playlistIndex; - int oldRowCount = model->rowCount(); - QString oldName = model->data( playlistIndex ).toString(); - QMimeData* data = model->mimeData( indexes ); - QVERIFY( model->dropMimeData( data, Qt::CopyAction, 0, 0, QModelIndex() ) ); - - QCOMPARE( model->rowCount(), oldRowCount + 1 ); - playlistIndex = model->index( 0, 0 ); - QCOMPARE( oldName, model->data( playlistIndex ).toString() ); - delete data; - - // -- move a playlist (to the end) - playlistIndex = model->index( 0, 0 ); - indexes.clear(); - indexes << playlistIndex; - - oldRowCount = model->rowCount(); - oldName = model->data( playlistIndex ).toString(); - data = model->mimeData( indexes ); - QVERIFY( model->dropMimeData( data, Qt::MoveAction, oldRowCount, 0, QModelIndex() ) ); - - QCOMPARE( model->rowCount(), oldRowCount ); - playlistIndex = model->index( oldRowCount - 1, 0 ); - QCOMPARE( oldName, model->data( playlistIndex ).toString() ); - delete data; - - - // -- copy a bias - // TODO - QModelIndex biasIndex = model->index( 0, 0, playlistIndex ); - QModelIndex subBiasIndex = model->index( 0, 0, biasIndex ); - -} - -void -TestDynamicModel::testRemoveActive() -{ - Dynamic::DynamicModel *model = Dynamic::DynamicModel::instance(); - - // load from the empty directory - model->loadPlaylists(); - QCOMPARE( model->rowCount(), 4 ); - - // -- try to remove the active playlist - model->setActivePlaylist( 2 ); - QCOMPARE( model->activePlaylistIndex(), 2 ); - Dynamic::DynamicPlaylist* pl = model->activePlaylist(); - - model->removeAt( model->index( pl ) ); - QCOMPARE( model->rowCount(), 3 ); - QVERIFY( model->activePlaylist() != pl ); - - // -- now remove all playlists remaining three playlists - model->removeAt( model->index( model->activePlaylist() ) ); - model->removeAt( model->index( model->activePlaylist() ) ); - model->removeAt( model->index( model->activePlaylist() ) ); - - QCOMPARE( model->rowCount(), 0 ); - QCOMPARE( model->activePlaylist(), static_cast(0) ); -} - -#include "moc_TestDynamicModel.cpp" diff --git a/amarok/tests/dynamic/TestDynamicModel.h b/amarok/tests/dynamic/TestDynamicModel.h deleted file mode 100644 index b1e4b7db..00000000 --- a/amarok/tests/dynamic/TestDynamicModel.h +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2011 Ralf Engels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef TESTDYNAMICMODEL_H -#define TESTDYNAMICMODEL_H - -#include -#include - -class TestDynamicModel : public QObject -{ - Q_OBJECT -public: - TestDynamicModel(); - -private slots: - void init(); - void cleanup(); - - /** Test the data function for root, playlists and biases */ - void testData(); - - /** Test all the different index operations. */ - void testPlaylistIndex(); - - /** Test the different slots for the DynamicModel class */ - void testSlots(); - - /** Test that serializing the playlists and biases returns the original data */ - void testSerializeIndex(); - - /** Test th dropMimeData functions */ - void testDnD(); - - /** Test removing active and non-active playlists */ - void testRemoveActive(); - -private: - QModelIndex serializeUnserialize( const QModelIndex& index ); -}; - -#endif diff --git a/amarok/tests/dynamic/TestTrackSet.cpp b/amarok/tests/dynamic/TestTrackSet.cpp deleted file mode 100644 index 1a5f03fc..00000000 --- a/amarok/tests/dynamic/TestTrackSet.cpp +++ /dev/null @@ -1,197 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2011 Ralf Engels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "TestTrackSet.h" - -#include "dynamic/TrackSet.h" - -#include "core/support/Amarok.h" -#include "core/support/Debug.h" - -#include - -QTEST_KDEMAIN_CORE( TestTrackSet ) - -TestTrackSet::TestTrackSet() -{ - QStringList testUids; - testUids << "uid-1" << "uid-2" << "uid-3" << "uid-4" << "uid-5" << "uid-6"; - m_trackCollection = new Dynamic::TrackCollection( testUids ); - - QCOMPARE( m_trackCollection->count(), 6 ); -} - -void -TestTrackSet::init() -{ } - -void -TestTrackSet::cleanup() -{ - QCOMPARE( m_trackCollection->count(), 6 ); -} - -void -TestTrackSet::testOutstanding() -{ - Dynamic::TrackSet set; - QCOMPARE( set.isOutstanding(), true ); - - Dynamic::TrackSet set2( m_trackCollection, true ); - QCOMPARE( set2.isOutstanding(), false ); -} - -void -TestTrackSet::testEmptyFull() -{ - Dynamic::TrackSet set2( m_trackCollection, true ); - QCOMPARE( set2.isEmpty(), false ); - QCOMPARE( set2.isFull(), true ); - - set2.reset( false ); - QCOMPARE( set2.isEmpty(), true ); - QCOMPARE( set2.isFull(), false ); - - set2.reset( true ); - QCOMPARE( set2.isEmpty(), false ); - QCOMPARE( set2.isFull(), true ); - - - QCOMPARE( set2.contains("uid-1"), true ); - QStringList testUids; - testUids << "uid-1"; - set2.subtract( testUids ); - QCOMPARE( set2.isEmpty(), false ); - QCOMPARE( set2.isFull(), false ); - QCOMPARE( set2.contains("uid-1"), false ); - - Dynamic::TrackSet set3( m_trackCollection, false ); - QCOMPARE( set3.isEmpty(), true ); - QCOMPARE( set3.isFull(), false ); -} - -void -TestTrackSet::testUnite() -{ - Dynamic::TrackSet set( m_trackCollection, false ); - - // -- use string lists - QStringList testUids; - testUids << "uid-1" << "uid-2"; - set.unite( testUids ); - - QCOMPARE( set.contains("uid-1"), true ); - QCOMPARE( set.contains("uid-2"), true ); - QCOMPARE( set.contains("uid-3"), false ); - - QStringList testUids2; - testUids2 << "uid-2" << "uid-3"; - set.unite( testUids2 ); - - QCOMPARE( set.contains("uid-1"), true ); - QCOMPARE( set.contains("uid-2"), true ); - QCOMPARE( set.contains("uid-3"), true ); - - // -- use another set - QStringList testUids3; - testUids3 << "uid-3" << "uid-4"; - Dynamic::TrackSet set2( m_trackCollection, false ); - set2.unite( testUids3 ); - - set.unite( set2 ); - QCOMPARE( set.contains("uid-2"), true ); - QCOMPARE( set.contains("uid-3"), true ); - QCOMPARE( set.contains("uid-4"), true ); - QCOMPARE( set.contains("uid-5"), false ); -} - -void -TestTrackSet::testIntersect() -{ - Dynamic::TrackSet set( m_trackCollection, true ); - - // -- use string lists - QStringList testUids; - testUids << "uid-1" << "uid-2"; - set.intersect( testUids ); - - QCOMPARE( set.contains("uid-1"), true ); - QCOMPARE( set.contains("uid-2"), true ); - QCOMPARE( set.contains("uid-3"), false ); - - QStringList testUids2; - testUids2 << "uid-2" << "uid-3"; - set.intersect( testUids2 ); - - QCOMPARE( set.contains("uid-1"), false ); - QCOMPARE( set.contains("uid-2"), true ); - QCOMPARE( set.contains("uid-3"), false ); - - // -- use another set - QStringList testUids3; - testUids3 << "uid-2" << "uid-3"; - Dynamic::TrackSet set2( m_trackCollection, false ); - set2.unite( testUids3 ); - - set.intersect( set2 ); - QCOMPARE( set.contains("uid-2"), true ); - QCOMPARE( set.contains("uid-3"), false ); - QCOMPARE( set.contains("uid-4"), false ); -} - -void -TestTrackSet::testSubtract() -{ - Dynamic::TrackSet set( m_trackCollection, true ); - - // -- use string lists - QStringList testUids; - testUids << "uid-1" << "uid-2"; - set.subtract( testUids ); - - QCOMPARE( set.contains("uid-1"), false ); - QCOMPARE( set.contains("uid-2"), false ); - QCOMPARE( set.contains("uid-3"), true ); - - QStringList testUids2; - testUids2 << "uid-2" << "uid-3"; - set.subtract( testUids2 ); - - QCOMPARE( set.contains("uid-1"), false ); - QCOMPARE( set.contains("uid-2"), false ); - QCOMPARE( set.contains("uid-3"), false ); - QCOMPARE( set.contains("uid-4"), true ); - - // -- use another set - QStringList testUids3; - testUids3 << "uid-3" << "uid-4"; - Dynamic::TrackSet set2( m_trackCollection, false ); - set2.unite( testUids3 ); - - set.subtract( set2 ); - QCOMPARE( set.contains("uid-3"), false ); - QCOMPARE( set.contains("uid-4"), false ); - QCOMPARE( set.contains("uid-5"), true ); - -} - -void -TestTrackSet::testEqual() -{ - -} - -#include "moc_TestTrackSet.cpp" diff --git a/amarok/tests/dynamic/TestTrackSet.h b/amarok/tests/dynamic/TestTrackSet.h deleted file mode 100644 index 7efa4930..00000000 --- a/amarok/tests/dynamic/TestTrackSet.h +++ /dev/null @@ -1,48 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2011 Ralf Engels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef TESTDYNAMICMODEL_H -#define TESTDYNAMICMODEL_H - -#include "dynamic/TrackSet.h" - -#include - -class TestTrackSet : public QObject -{ - Q_OBJECT -public: - TestTrackSet(); - -private slots: - void init(); - void cleanup(); - - void testOutstanding(); - - void testEmptyFull(); - - void testUnite(); - void testIntersect(); - void testSubtract(); - - void testEqual(); - -private: - Dynamic::TrackCollectionPtr m_trackCollection; -}; - -#endif diff --git a/amarok/tests/htmlgenerator/AmarokTest.xsl b/amarok/tests/htmlgenerator/AmarokTest.xsl deleted file mode 100644 index 6ee6203d..00000000 --- a/amarok/tests/htmlgenerator/AmarokTest.xsl +++ /dev/null @@ -1,80 +0,0 @@ - - - - - - - - -

    - Unit test results for: - - -

    - -
    - - - -

    - Qt Version: - -


    -
    - - - -

    - Test Function Name: - - - -

    - - - Pass - - - - FAIL at line: - -

    - -

      - -
    • - File: - -
      - Line: - -

      -
    • -
      -

    -
    -
    -

    - -
    - - -
    - - diff --git a/amarok/tests/htmlgenerator/html_generator.rb b/amarok/tests/htmlgenerator/html_generator.rb deleted file mode 100755 index b1414c2e..00000000 --- a/amarok/tests/htmlgenerator/html_generator.rb +++ /dev/null @@ -1,59 +0,0 @@ -#!/usr/bin/env ruby -######################################################################################## -# HTML generator for Amarok's unit tests. # -# This program transforms test output from XML to HTML, using a XSL stylesheet. # -# # -# Copyright (c) 2009 Mark Kretschmann # -# # -# This program 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 2 of the License, or (at your option) any later # -# version. # -# # -# This program 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 # -# this program. If not, see . # -######################################################################################## - -require 'xml/libxml' -require 'xml/libxslt' - - -XSL_FILE = 'AmarokTest.xsl' -OUTPUT_FILE = 'Amarok.html' - -out = "" - -files = Dir["**/*.xml"].sort - -# Generate menu -out += "

    Unit Tests



    " - -files.each do |path| - begin - xslt = XML::XSLT.new - xslt.xsl = XSL_FILE - xslt.xml = path - out += "" - out += xslt.serve - out += "




    " - rescue - print "exception" - end -end - - -# Save to file -File.new( OUTPUT_FILE, File::CREAT | File::RDWR | File::TRUNC ).write(out) - - -print out - diff --git a/amarok/tests/importers/CMakeLists.txt b/amarok/tests/importers/CMakeLists.txt deleted file mode 100644 index 50c80821..00000000 --- a/amarok/tests/importers/CMakeLists.txt +++ /dev/null @@ -1,159 +0,0 @@ -add_custom_target( importers_files - ${CMAKE_COMMAND} -E copy_directory "${AMAROK_TEST_TREE}/importers/files" "${CMAKE_BINARY_DIR}/tests/importers_files" - VERBATIM -) - -set( testimporterscommon_LIBS - amaroklib - amarokcore - ${KDE4_KDEUI_LIBS} - ${KDE4_KIO_LIBS} - ${KDE4_THREADWEAVER_LIBS} - ${QT_QTSQL_LIBRARY} - ${QT_QTTEST_LIBRARY} - ${GOOGLEMOCK_LIBRARIES} -) - -#------------------------ Test ImporterManager ---------------------------- - -set( testimportermanager_SRCS - TestImporterManager.cpp - ImporterMocks.cpp - ${GOOGLEMOCK_SRCS} -) - -kde4_add_unit_test( testimportermanager ${testimportermanager_SRCS} ) -target_link_libraries( testimportermanager ${testimporterscommon_LIBS} ) - -#------------------------ Test ImporterProvider --------------------------- - -set( testimporterprovider_SRCS - TestImporterProvider.cpp - ImporterMocks.cpp - ${GOOGLEMOCK_SRCS} -) - -kde4_add_unit_test( testimporterprovider ${testimporterprovider_SRCS} ) -target_link_libraries( testimporterprovider ${testimporterscommon_LIBS} ) - -#------------------------ Test SimpleImporterConfigWidget ----------------- - -set( testsimpleimporterconfigwidget_SRCS TestSimpleImporterConfigWidget.cpp ) -kde4_add_unit_test( testsimpleimporterconfigwidget - ${testsimpleimporterconfigwidget_SRCS} ) -target_link_libraries( testsimpleimporterconfigwidget ${testimporterscommon_LIBS} ) - -#------------------------ Test AmarokImporter ----------------------------- - -set( testamarokimporter_SRCS - TestImporterBase.cpp - TestAmarokImporter.cpp - ${AMAROK_SOURCE_TREE}/importers/amarok/AmarokConfigWidget.cpp - ${AMAROK_SOURCE_TREE}/importers/amarok/AmarokManager.cpp - ${AMAROK_SOURCE_TREE}/importers/amarok/AmarokProvider.cpp - ${AMAROK_SOURCE_TREE}/importers/amarok/AmarokEmbeddedSqlConnection.cpp - ${AMAROK_SOURCE_TREE}/importers/amarok/AmarokTrack.cpp -) -kde4_add_ui_files( testamarokimporter_SRCS - ${AMAROK_SOURCE_TREE}/importers/amarok/AmarokConfigWidget.ui -) - -kde4_add_unit_test( testamarokimporter ${testamarokimporter_SRCS} ) -add_dependencies( testamarokimporter importers_files ) -target_link_libraries( testamarokimporter - amarok_importer-amarok - ${testimporterscommon_LIBS} -) - -#------------------------ Test BansheeImporter ------------------------------- - -set( testbansheeimporter_SRCS - TestImporterBase.cpp - TestBansheeImporter.cpp - ${AMAROK_SOURCE_TREE}/importers/banshee/BansheeConfigWidget.cpp - ${AMAROK_SOURCE_TREE}/importers/banshee/BansheeManager.cpp - ${AMAROK_SOURCE_TREE}/importers/banshee/BansheeProvider.cpp - ${AMAROK_SOURCE_TREE}/importers/banshee/BansheeTrack.cpp -) - -kde4_add_unit_test( testbansheeimporter ${testbansheeimporter_SRCS} ) -add_dependencies( testbansheeimporter importers_files ) -target_link_libraries( testbansheeimporter - amarok_importer-banshee - ${testimporterscommon_LIBS} -) - -#------------------------ Test ClementineImporter ---------------------------- - -set( testclementineimporter_SRCS - TestImporterBase.cpp - TestClementineImporter.cpp - ${AMAROK_SOURCE_TREE}/importers/clementine/ClementineConfigWidget.cpp - ${AMAROK_SOURCE_TREE}/importers/clementine/ClementineManager.cpp - ${AMAROK_SOURCE_TREE}/importers/clementine/ClementineProvider.cpp - ${AMAROK_SOURCE_TREE}/importers/clementine/ClementineTrack.cpp -) - -kde4_add_unit_test( testclementineimporter ${testclementineimporter_SRCS} ) -add_dependencies( testclementineimporter importers_files ) -target_link_libraries( testclementineimporter - amarok_importer-clementine - ${testimporterscommon_LIBS} -) - -#------------------------ Test FastForwardImporter ------------------------ - -set( testfastforwardimporter_SRCS - TestImporterBase.cpp - TestFastForwardImporter.cpp - ${AMAROK_SOURCE_TREE}/importers/fastforward/FastForwardConfigWidget.cpp - ${AMAROK_SOURCE_TREE}/importers/fastforward/FastForwardManager.cpp - ${AMAROK_SOURCE_TREE}/importers/fastforward/FastForwardProvider.cpp - ${AMAROK_SOURCE_TREE}/importers/fastforward/FastForwardTrack.cpp -) -kde4_add_ui_files( testfastforwardimporter_SRCS - ${AMAROK_SOURCE_TREE}/importers/fastforward/FastForwardConfigWidget.ui -) - -kde4_add_unit_test( testfastforwardimporter ${testfastforwardimporter_SRCS} ) -add_dependencies( testfastforwardimporter importers_files ) -target_link_libraries( testfastforwardimporter - amarok_importer-fastforward - ${testimporterscommon_LIBS} -) - -#------------------------ Test ITunesImporter ----------------------------- - -set( testitunesimporter_SRCS - TestImporterBase.cpp - TestITunesImporter.cpp - ${AMAROK_SOURCE_TREE}/importers/itunes/ITunesConfigWidget.cpp - ${AMAROK_SOURCE_TREE}/importers/itunes/ITunesManager.cpp - ${AMAROK_SOURCE_TREE}/importers/itunes/ITunesProvider.cpp - ${AMAROK_SOURCE_TREE}/importers/itunes/ITunesTrack.cpp -) - -kde4_add_unit_test( testitunesimporter ${testitunesimporter_SRCS} ) -add_dependencies( testitunesimporter importers_files ) -target_link_libraries( testitunesimporter - amarok_importer-itunes - ${testimporterscommon_LIBS} -) - -#------------------------ Test RhythmboxImporter ----------------------------- - -set( testrhytmboximporter_SRCS - TestImporterBase.cpp - TestRhythmboxImporter.cpp - ${AMAROK_SOURCE_TREE}/importers/rhythmbox/RhythmboxConfigWidget.cpp - ${AMAROK_SOURCE_TREE}/importers/rhythmbox/RhythmboxManager.cpp - ${AMAROK_SOURCE_TREE}/importers/rhythmbox/RhythmboxProvider.cpp - ${AMAROK_SOURCE_TREE}/importers/rhythmbox/RhythmboxTrack.cpp -) - -kde4_add_unit_test( testrhytmboximporter ${testrhytmboximporter_SRCS} ) -add_dependencies( testrhytmboximporter importers_files ) -target_link_libraries( testrhytmboximporter - amarok_importer-rhythmbox - ${testimporterscommon_LIBS} -) diff --git a/amarok/tests/importers/ImporterMocks.cpp b/amarok/tests/importers/ImporterMocks.cpp deleted file mode 100644 index 0b003c8b..00000000 --- a/amarok/tests/importers/ImporterMocks.cpp +++ /dev/null @@ -1,121 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2013 Konrad Zemek * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "ImporterMocks.h" - -#include "EngineController.h" -#include "core/support/Amarok.h" -#include "core/support/Components.h" - -using namespace ::testing; - -MockProvider::MockProvider( const QVariantMap &config, StatSyncing::ImporterManager *manager ) - : StatSyncing::ImporterProvider( config, manager ) -{ -} - -QVariantMap -MockProvider::config() const -{ - return m_config; -} - -StatSyncing::ImporterManager* -MockProvider::manager() const -{ - return m_manager; -} - -MockManager::MockManager() - : StatSyncing::ImporterManager( 0, QVariantList() ) -{ -} - -StatSyncing::ProviderPtrMap -MockManager::providers() -{ - return m_providers; -} - -StatSyncing::ImporterProviderPtr -MockManager::concreteNewInstance( const QVariantMap &cfg ) -{ - return StatSyncing::ImporterProviderPtr( new NiceMock( cfg, this ) ); -} - -void -MockManager::providerForgottenProxy( const QString &providerId ) -{ - return StatSyncing::ImporterManager::slotProviderForgotten( providerId ); -} - -MockController::MockController( QObject *parent ) - : StatSyncing::Controller( parent ) -{ -} - -void -ImporterMocks::initTestCase() -{ - DefaultValue::Set( QString() ); - DefaultValue::Set( KIcon() ); - DefaultValue::Set( KPluginInfo() ); - - m_engineController = new EngineController; - Amarok::Components::setEngineController( m_engineController ); -} - -void -ImporterMocks::init() -{ - m_mockManager = new NiceMock; - ON_CALL( *m_mockManager, newInstance( _ ) ) - .WillByDefault( Invoke( m_mockManager, &MockManager::concreteNewInstance ) ); - - ON_CALL( *m_mockManager, type() ).WillByDefault( Return( "randomType" ) ); - - QVariantMap cfg; - cfg["uid"] = QString( "providerUid" ); - m_mockProvider = new NiceMock( cfg, m_mockManager ); - - m_mockController = new NiceMock; - Amarok::Components::setStatSyncingController( m_mockController ); -} - -void -ImporterMocks::cleanup() -{ - delete m_mockProvider; - m_mockProvider = 0; - - delete m_mockManager; - m_mockManager = 0; - - Amarok::Components::setStatSyncingController( 0 ); - delete m_mockController; - m_mockController = 0; - - Amarok::config( "Importers" ).deleteGroup(); -} - -void -ImporterMocks::cleanupTestCase() -{ - Amarok::Components::setEngineController( 0 ); - delete m_engineController; -} - -#include "moc_ImporterMocks.cpp" diff --git a/amarok/tests/importers/ImporterMocks.h b/amarok/tests/importers/ImporterMocks.h deleted file mode 100644 index 7e0eae62..00000000 --- a/amarok/tests/importers/ImporterMocks.h +++ /dev/null @@ -1,92 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2013 Konrad Zemek * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef IMPORTER_MOCKS_H -#define IMPORTER_MOCKS_H - -#include "importers/ImporterManager.h" -#include "importers/ImporterProvider.h" -#include "statsyncing/Controller.h" - -#include - -class EngineController; -namespace StatSyncing -{ - class Controller; -} - -class MockProvider : public StatSyncing::ImporterProvider -{ -public: - MockProvider( const QVariantMap &config, StatSyncing::ImporterManager *manager ); - QVariantMap config() const; - StatSyncing::ImporterManager *manager() const; - - MOCK_CONST_METHOD0( reliableTrackMetaData, qint64() ); - MOCK_CONST_METHOD0( writableTrackStatsData, qint64() ); - MOCK_METHOD0( artists, QSet() ); - MOCK_METHOD1( artistTracks, StatSyncing::TrackList(const QString&) ); -}; - -class MockManager : public StatSyncing::ImporterManager -{ -public: - MockManager(); - - StatSyncing::ProviderPtrMap providers(); - StatSyncing::ImporterProviderPtr concreteNewInstance( const QVariantMap &cfg ); - void providerForgottenProxy( const QString &providerId ); - - using StatSyncing::ImporterManager::managerConfig; - using StatSyncing::ImporterManager::providerConfig; - - MOCK_CONST_METHOD0( type, QString() ); - MOCK_CONST_METHOD0( description, QString() ); - MOCK_CONST_METHOD0( prettyName, QString() ); - MOCK_CONST_METHOD0( icon, KIcon() ); - MOCK_METHOD1( configWidget, StatSyncing::ProviderConfigWidget*(const QVariantMap&) ); - MOCK_CONST_METHOD0( pluginInfo, KPluginInfo() ); - MOCK_METHOD1( newInstance, StatSyncing::ImporterProviderPtr(const QVariantMap&) ); -}; - -class MockController : public StatSyncing::Controller -{ -public: - MockController( QObject *parent = 0 ); - - MOCK_METHOD1( registerProvider, void(const StatSyncing::ProviderPtr&) ); - MOCK_METHOD1( unregisterProvider, void(const StatSyncing::ProviderPtr&) ); -}; - -class ImporterMocks : public QObject -{ - Q_OBJECT - -protected: - EngineController *m_engineController; - MockController *m_mockController; - MockManager *m_mockManager; - MockProvider *m_mockProvider; - -private slots: - void initTestCase(); - void init(); - void cleanup(); - void cleanupTestCase(); -}; - -#endif // IMPORTER_MOCKS_H diff --git a/amarok/tests/importers/TestAmarokImporter.cpp b/amarok/tests/importers/TestAmarokImporter.cpp deleted file mode 100644 index fd04a248..00000000 --- a/amarok/tests/importers/TestAmarokImporter.cpp +++ /dev/null @@ -1,224 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2013 Konrad Zemek * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "TestAmarokImporter.h" - -#include "MetaValues.h" -#include "importers/amarok/AmarokConfigWidget.h" -#include "importers/amarok/AmarokManager.h" -#include "importers/amarok/AmarokProvider.h" - -#include - -Q_DECLARE_METATYPE( QProcess::ProcessError ) -QTEST_KDEMAIN( TestAmarokImporter, GUI ) - -using namespace StatSyncing; - -ProviderPtr -TestAmarokImporter::getProvider() -{ - QVariantMap cfg = AmarokConfigWidget( QVariantMap() ).config(); - cfg.insert( "name", "Amarok2Test" ); - cfg.insert( "embedded", true ); - cfg.insert( "dbPath", QCoreApplication::applicationDirPath() + - "/importers_files/amarok2_mysqle" ); - - return ProviderPtr( new AmarokProvider( cfg, 0 ) ); -} - -ProviderPtr -TestAmarokImporter::getWritableProvider() -{ - QDir base( QCoreApplication::applicationDirPath() ); - QDir files( base.filePath( "importers_files" ) ); - QDir tmp( base.filePath( "importers_tmp" ) ); - - foreach( const QString &subdir, - QList() << "amarok2_mysqle" << "amarok2_mysqle/amarok" ) - { - tmp.mkpath( subdir ); - - QDir src( files.filePath( subdir ) ); - QDir dst( tmp.filePath( subdir ) ); - - foreach( const QString &filename, src.entryList( QStringList(), QDir::Files ) ) - { - QFile( dst.filePath( filename ) ).remove(); - QFile( src.filePath( filename ) ).copy( dst.filePath( filename ) ); - } - } - - QVariantMap cfg = AmarokConfigWidget( QVariantMap() ).config(); - cfg.insert( "name", "Amarok2Test" ); - cfg.insert( "embedded", true ); - cfg.insert( "dbPath", tmp.filePath( "amarok2_mysqle" ) ); - - return ProviderPtr( new AmarokProvider( cfg, 0 ) ); -} - -qint64 -TestAmarokImporter::reliableStatistics() const -{ - return Meta::valFirstPlayed | Meta::valLastPlayed | Meta::valRating - | Meta::valPlaycount | Meta::valLabel; -} - -void -TestAmarokImporter::initTestCase() -{ - qRegisterMetaType(); -} - -void -TestAmarokImporter::init() -{ - m_cfg = AmarokConfigWidget( QVariantMap() ).config(); - m_cfg.insert( "embedded", true ); -} - -void -TestAmarokImporter::configWidgetShouldOnlyShowFieldsRelevantToConnection() -{ - AmarokConfigWidget widget( m_cfg ); - - const QList remoteConfigWidgets = QList() - << widget.m_databaseName << widget.m_hostname << widget.m_port - << widget.m_password << widget.m_username; - - widget.m_connectionType->setCurrentIndex( AmarokConfigWidget::Embedded ); - QVERIFY( !widget.m_databaseLocation->isHidden() ); - foreach( QWidget *w, remoteConfigWidgets ) - QVERIFY( w->isHidden() ); - - widget.m_connectionType->setCurrentIndex( AmarokConfigWidget::External ); - QVERIFY( widget.m_databaseLocation->isHidden() ); - foreach( QWidget *w, remoteConfigWidgets ) - QVERIFY( !w->isHidden() ); -} - -void -TestAmarokImporter::configWidgetShouldNotSetDriver() -{ - AmarokConfigWidget widget( m_cfg ); - - widget.m_connectionType->setCurrentIndex( AmarokConfigWidget::Embedded ); - QVERIFY( !widget.config().contains( "dbDriver" ) ); - - widget.m_connectionType->setCurrentIndex( AmarokConfigWidget::External ); - QVERIFY( !widget.config().contains( "dbDriver" ) ); -} - -void -TestAmarokImporter::configWidgetShouldShowExternalAsDefault() -{ - QVariantMap cfg; - AmarokConfigWidget widget( cfg ); - QCOMPARE( widget.m_connectionType->currentIndex(), - static_cast( AmarokConfigWidget::External ) ); -} - -void -TestAmarokImporter::configWidgetShouldNotBreakOnNonsenseInitialValues() -{ - m_cfg.insert( "dbName", QColor( Qt::red ) ); - m_cfg.insert( "dbPort", "nonsensePort" ); - m_cfg.insert( "dbPath", reinterpret_cast( this ) ); - - AmarokConfigWidget widget( m_cfg ); - - QVERIFY( !widget.m_databaseName->text().isEmpty() ); - QVERIFY( !widget.m_databaseLocation->text().isEmpty() ); -} - -void -TestAmarokImporter::configWidgetShouldReadSavedConfig() -{ - m_cfg.insert( "embedded", true ); - m_cfg.insert( "dbName", "MyName" ); - m_cfg.insert( "dbPort", 19 ); - m_cfg.insert( "name", "theName" ); - AmarokConfigWidget widget( m_cfg ); - - QCOMPARE( widget.m_connectionType->currentIndex(), - static_cast( AmarokConfigWidget::Embedded ) ); - - QCOMPARE( widget.m_databaseName->text(), QString( "MyName" ) ); - QCOMPARE( widget.m_port->value(), 19 ); - QCOMPARE( widget.m_targetName->text(), QString( "theName" ) ); - - m_cfg.insert( "embedded", false ); - AmarokConfigWidget widgetExternal( m_cfg ); - - QCOMPARE( widgetExternal.m_connectionType->currentIndex(), - static_cast( AmarokConfigWidget::External ) ); -} - -void -TestAmarokImporter::providerShouldIgnoreConfigsDbDriver() -{ - if( !QFileInfo( "/usr/bin/mysqld" ).isExecutable() ) - QSKIP( "/usr/bin/mysqld is not executable", SkipAll ); - - m_cfg.insert( "dbDriver", "QPSQL" ); - m_cfg.insert( "dbPath", QCoreApplication::applicationDirPath() + - "/importers_files/amarok2_mysqle" ); - - AmarokProvider provider( m_cfg, 0 ); - - // The database isn't accessible by QPSQL driver, but it still should work - QVERIFY( !provider.artists().empty() ); -} - -void -TestAmarokImporter::providerShouldHandleNonexistentDbDir() -{ - m_cfg.insert( "dbPath", "/Im/sure/this/wont/exist" ); - - AmarokProvider provider( m_cfg, 0 ); - QVERIFY( provider.artists().isEmpty() ); -} - -void -TestAmarokImporter::providerShouldHandleInvalidDbDir() -{ - m_cfg.insert( "dbPath", QApplication::applicationDirPath() ); - - AmarokProvider provider( m_cfg, 0 ); - QVERIFY( provider.artists().isEmpty() ); -} - -void -TestAmarokImporter::providerShouldHandleExternalConnectionError() -{ - m_cfg.insert( "dbHost", "I hope this isn't a valid hostname" ); - - AmarokProvider provider( m_cfg, 0 ); - QVERIFY( provider.artists().isEmpty() ); -} - -void -TestAmarokImporter::providerShouldHandleErroneousConfigValues() -{ - m_cfg.insert( "dbDriver", 19 ); - m_cfg.insert( "dbName", QColor( Qt::red ) ); - m_cfg.insert( "dbPort", "nonsensePort" ); - - AmarokProvider provider( m_cfg, 0 ); - QVERIFY( provider.artists().isEmpty() ); -} - -#include "moc_TestAmarokImporter.cpp" diff --git a/amarok/tests/importers/TestAmarokImporter.h b/amarok/tests/importers/TestAmarokImporter.h deleted file mode 100644 index 84e75ac1..00000000 --- a/amarok/tests/importers/TestAmarokImporter.h +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2013 Konrad Zemek * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef TEST_AMAROK_IMPORTER -#define TEST_AMAROK_IMPORTER - -#include "TestImporterBase.h" - -#include - -class TestAmarokImporter : public TestImporterBase -{ - Q_OBJECT - -private: - QVariantMap m_cfg; - -protected: - virtual StatSyncing::ProviderPtr getProvider(); - virtual StatSyncing::ProviderPtr getWritableProvider(); - virtual qint64 reliableStatistics() const; - -private slots: - void initTestCase(); - void init(); - - void configWidgetShouldOnlyShowFieldsRelevantToConnection(); - void configWidgetShouldNotSetDriver(); - void configWidgetShouldShowExternalAsDefault(); - void configWidgetShouldNotBreakOnNonsenseInitialValues(); - void configWidgetShouldReadSavedConfig(); - - void providerShouldIgnoreConfigsDbDriver(); - void providerShouldHandleNonexistentDbDir(); - void providerShouldHandleInvalidDbDir(); - void providerShouldHandleExternalConnectionError(); - void providerShouldHandleErroneousConfigValues(); -}; - -#endif // TEST_AMAROK_IMPORTER diff --git a/amarok/tests/importers/TestBansheeImporter.cpp b/amarok/tests/importers/TestBansheeImporter.cpp deleted file mode 100644 index 6e13ad64..00000000 --- a/amarok/tests/importers/TestBansheeImporter.cpp +++ /dev/null @@ -1,109 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2013 Konrad Zemek * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "TestBansheeImporter.h" - -#include "MetaValues.h" -#include "importers/banshee/BansheeConfigWidget.h" -#include "importers/banshee/BansheeProvider.h" - -#include - -QTEST_KDEMAIN( TestBansheeImporter, GUI ) - -using namespace StatSyncing; - -ProviderPtr -TestBansheeImporter::getProvider() -{ - QVariantMap cfg = BansheeConfigWidget( QVariantMap() ).config(); - cfg.insert( "dbPath", QApplication::applicationDirPath() - + "/importers_files/banshee.db" ); - - return ProviderPtr( new BansheeProvider( cfg, 0 ) ); -} - -ProviderPtr -TestBansheeImporter::getWritableProvider() -{ - QDir base( QCoreApplication::applicationDirPath() ); - base.mkpath( "importers_tmp" ); - - const QString dst = base.filePath( "importers_tmp/banshee.db" ); - QFile( dst ).remove(); - QFile( base.filePath( "importers_files/banshee.db" ) ).copy( dst ); - - QVariantMap cfg = BansheeConfigWidget( QVariantMap() ).config(); - cfg.insert( "dbPath", dst ); - - return ProviderPtr( new BansheeProvider( cfg, 0 ) ); -} - -qint64 -TestBansheeImporter::reliableStatistics() const -{ - return Meta::valLastPlayed | Meta::valPlaycount | Meta::valRating; -} - -bool -TestBansheeImporter::hasOddRatings() const -{ - return false; -} - -void -TestBansheeImporter::init() -{ - m_cfg = BansheeConfigWidget( QVariantMap() ).config(); -} - -void -TestBansheeImporter::providerShouldHandleNonexistentDbFile() -{ - m_cfg.insert( "dbPath", "/wdawd\\wdadwgd/das4hutyf" ); - - BansheeProvider provider( m_cfg, 0 ); - QVERIFY( provider.artists().isEmpty() ); -} - -void -TestBansheeImporter::providerShouldHandleInvalidDbFile() -{ - m_cfg.insert( "dbPath", QApplication::applicationFilePath() ); - - BansheeProvider provider( m_cfg, 0 ); - QVERIFY( provider.artists().isEmpty() ); -} - -void -TestBansheeImporter::providerShouldHandleErroneousConfigValues() -{ - m_cfg.insert( "dbPath", "\\wd%aw@d/sdsd2'vodk0-=$$" ); - m_cfg.insert( "name", QColor( Qt::white ) ); - - BansheeProvider provider( m_cfg, 0 ); - QVERIFY( provider.artists().isEmpty() ); -} - -void -TestBansheeImporter::artistTracksShouldNotReturnTracksNotFromPrimarySource() -{ - ProviderPtr provider( getProvider() ); - - const QString artist = "wrongSource"; - QVERIFY( provider->artists().contains( artist ) ); - QVERIFY( provider->artistTracks( artist ).isEmpty() ); -} diff --git a/amarok/tests/importers/TestBansheeImporter.h b/amarok/tests/importers/TestBansheeImporter.h deleted file mode 100644 index 8166c835..00000000 --- a/amarok/tests/importers/TestBansheeImporter.h +++ /dev/null @@ -1,47 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2013 Konrad Zemek * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef TEST_BANSHEE_IMPORTER -#define TEST_BANSHEE_IMPORTER - -#include "TestImporterBase.h" - -#include - -class TestBansheeImporter : public TestImporterBase -{ - Q_OBJECT - -protected: - StatSyncing::ProviderPtr getProvider(); - StatSyncing::ProviderPtr getWritableProvider(); - qint64 reliableStatistics() const; - bool hasOddRatings() const; - -private: - QVariantMap m_cfg; - -private slots: - void init(); - - void providerShouldHandleNonexistentDbFile(); - void providerShouldHandleInvalidDbFile(); - void providerShouldHandleErroneousConfigValues(); - - void artistTracksShouldNotReturnTracksNotFromPrimarySource(); -}; - -#endif // TEST_BANSHEE_IMPORTER diff --git a/amarok/tests/importers/TestClementineImporter.cpp b/amarok/tests/importers/TestClementineImporter.cpp deleted file mode 100644 index 80a8b06c..00000000 --- a/amarok/tests/importers/TestClementineImporter.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2013 Konrad Zemek * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "TestClementineImporter.h" - -#include "MetaValues.h" -#include "importers/clementine/ClementineConfigWidget.h" -#include "importers/clementine/ClementineProvider.h" - -#include - -QTEST_KDEMAIN( TestClementineImporter, GUI ) - -using namespace StatSyncing; - -ProviderPtr -TestClementineImporter::getProvider() -{ - QVariantMap cfg = ClementineConfigWidget( QVariantMap() ).config(); - cfg.insert( "dbPath", QApplication::applicationDirPath() - + "/importers_files/clementine.db" ); - - return ProviderPtr( new ClementineProvider( cfg, 0 ) ); -} - -ProviderPtr -TestClementineImporter::getWritableProvider() -{ - QDir base( QCoreApplication::applicationDirPath() ); - base.mkpath( "importers_tmp" ); - - const QString dst = base.filePath( "importers_tmp/clementine.db" ); - QFile( dst ).remove(); - QFile( base.filePath( "importers_files/clementine.db" ) ).copy( dst ); - - QVariantMap cfg = ClementineConfigWidget( QVariantMap() ).config(); - cfg.insert( "dbPath", dst ); - - return ProviderPtr( new ClementineProvider( cfg, 0 ) ); -} - -qint64 -TestClementineImporter::reliableStatistics() const -{ - return Meta::valLastPlayed | Meta::valRating | Meta::valPlaycount; -} - -void -TestClementineImporter::init() -{ - m_cfg = ClementineConfigWidget( QVariantMap() ).config(); -} - -void -TestClementineImporter::providerShouldHandleNonexistentDbFile() -{ - m_cfg.insert( "dbPath", "/wdawd\\wdadwgd/das4hutyf" ); - - ClementineProvider provider( m_cfg, 0 ); - QVERIFY( provider.artists().isEmpty() ); -} - -void -TestClementineImporter::providerShouldHandleInvalidDbFile() -{ - m_cfg.insert( "dbPath", QApplication::applicationFilePath() ); - - ClementineProvider provider( m_cfg, 0 ); - QVERIFY( provider.artists().isEmpty() ); -} - -void -TestClementineImporter::providerShouldHandleErroneousConfigValues() -{ - m_cfg.insert( "dbPath", "\\wd%aw@d/sdsd2'vodk0-=$$" ); - m_cfg.insert( "name", QColor( Qt::white ) ); - - ClementineProvider provider( m_cfg, 0 ); - QVERIFY( provider.artists().isEmpty() ); -} diff --git a/amarok/tests/importers/TestClementineImporter.h b/amarok/tests/importers/TestClementineImporter.h deleted file mode 100644 index 34273206..00000000 --- a/amarok/tests/importers/TestClementineImporter.h +++ /dev/null @@ -1,44 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2013 Konrad Zemek * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef TEST_CLEMENTINE_IMPORTER -#define TEST_CLEMENTINE_IMPORTER - -#include "TestImporterBase.h" - -#include - -class TestClementineImporter : public TestImporterBase -{ - Q_OBJECT - -protected: - StatSyncing::ProviderPtr getProvider(); - StatSyncing::ProviderPtr getWritableProvider(); - qint64 reliableStatistics() const; - -private: - QVariantMap m_cfg; - -private slots: - void init(); - - void providerShouldHandleNonexistentDbFile(); - void providerShouldHandleInvalidDbFile(); - void providerShouldHandleErroneousConfigValues(); -}; - -#endif // TEST_CLEMENTINE_IMPORTER diff --git a/amarok/tests/importers/TestFastForwardImporter.cpp b/amarok/tests/importers/TestFastForwardImporter.cpp deleted file mode 100644 index b66ac259..00000000 --- a/amarok/tests/importers/TestFastForwardImporter.cpp +++ /dev/null @@ -1,194 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2013 Konrad Zemek * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "TestFastForwardImporter.h" - -#include "MetaValues.h" -#include "importers/fastforward/FastForwardConfigWidget.h" -#include "importers/fastforward/FastForwardProvider.h" - -#include - -QTEST_KDEMAIN( TestFastForwardImporter, GUI ) - -using namespace StatSyncing; - -ProviderPtr -TestFastForwardImporter::getProvider() -{ - QVariantMap cfg = FastForwardConfigWidget( QVariantMap() ).config(); - cfg.insert( "dbDriver", "QSQLITE" ); - cfg.insert( "dbPath", QCoreApplication::applicationDirPath() + - "/importers_files/collection.db" ); - - return ProviderPtr( new FastForwardProvider( cfg, 0 ) ); -} - -ProviderPtr -TestFastForwardImporter::getWritableProvider() -{ - QDir base( QCoreApplication::applicationDirPath() ); - base.mkpath( "importers_tmp" ); - - const QString dst = base.filePath( "importers_tmp/collection.db" ); - QFile( dst ).remove(); - QFile( base.filePath( "importers_files/collection.db" ) ).copy( dst ); - - QVariantMap cfg = FastForwardConfigWidget( QVariantMap() ).config(); - cfg.insert( "dbDriver", "QSQLITE" ); - cfg.insert( "dbPath", dst ); - - return ProviderPtr( new FastForwardProvider( cfg, 0 ) ); -} - -qint64 -TestFastForwardImporter::reliableStatistics() const -{ - return Meta::valFirstPlayed | Meta::valLastPlayed | Meta::valRating - | Meta::valPlaycount | Meta::valLabel; -} - -void -TestFastForwardImporter::init() -{ - m_cfg = FastForwardConfigWidget( QVariantMap() ).config(); -} - -void -TestFastForwardImporter::configWidgetShouldOnlyShowFieldsRelevantToConnection() -{ - FastForwardConfigWidget widget( m_cfg ); - - const QList remoteConfigWidgets = QList() - << widget.m_databaseName << widget.m_hostname << widget.m_port - << widget.m_password << widget.m_username; - - widget.m_connectionType->setCurrentIndex( FastForwardConfigWidget::QSQLITE ); - QVERIFY( !widget.m_databaseLocation->isHidden() ); - foreach( QWidget *w, remoteConfigWidgets ) - QVERIFY( w->isHidden() ); - - widget.m_connectionType->setCurrentIndex( FastForwardConfigWidget::QMYSQL ); - QVERIFY( widget.m_databaseLocation->isHidden() ); - foreach( QWidget *w, remoteConfigWidgets ) - QVERIFY( !w->isHidden() ); - - widget.m_connectionType->setCurrentIndex( FastForwardConfigWidget::QPSQL ); - QVERIFY( widget.m_databaseLocation->isHidden() ); - foreach( QWidget *w, remoteConfigWidgets ) - QVERIFY( !w->isHidden() ); -} - -void -TestFastForwardImporter::configWidgetShouldSetDriverNameAsConfigResult() -{ - FastForwardConfigWidget widget( m_cfg ); - - widget.m_connectionType->setCurrentIndex( FastForwardConfigWidget::QSQLITE ); - QCOMPARE( widget.config().value( "dbDriver" ).toString(), - QString( "QSQLITE" ) ); - - widget.m_connectionType->setCurrentIndex( FastForwardConfigWidget::QMYSQL ); - QCOMPARE( widget.config().value( "dbDriver" ).toString(), - QString( "QMYSQL" ) ); - - widget.m_connectionType->setCurrentIndex( FastForwardConfigWidget::QPSQL ); - QCOMPARE( widget.config().value( "dbDriver" ).toString(), - QString( "QPSQL" ) ); -} - -void -TestFastForwardImporter::configWidgetShouldShowSqliteAsDefault() -{ - FastForwardConfigWidget widget( m_cfg ); - QCOMPARE( widget.m_connectionType->currentIndex(), - static_cast( FastForwardConfigWidget::QSQLITE ) ); -} - -void -TestFastForwardImporter::configWidgetShouldNotBreakOnNonsenseInitialValues() -{ - m_cfg.insert( "dbDriver", 19 ); - m_cfg.insert( "dbName", QColor( Qt::red ) ); - m_cfg.insert( "dbPort", "nonsensePort" ); - - FastForwardConfigWidget widget( m_cfg ); - QVERIFY( !widget.m_databaseName->text().isEmpty() ); - - const QList validDrivers = QList() - << "QSQLITE" << "QMYSQL" << "QPSQL"; - - QVERIFY( validDrivers.contains( widget.config().value( "dbDriver" ).toString() ) ); -} - -void -TestFastForwardImporter::configWidgetShouldReadSavedConfig() -{ - m_cfg.insert( "dbDriver", "QPSQL" ); - m_cfg.insert( "dbName", "MyName" ); - m_cfg.insert( "dbPort", 19 ); - m_cfg.insert( "name", "theName" ); - - FastForwardConfigWidget widget( m_cfg ); - - QCOMPARE( widget.m_connectionType->currentIndex(), - static_cast( FastForwardConfigWidget::QPSQL ) ); - - QCOMPARE( widget.m_databaseName->text(), QString( "MyName" ) ); - QCOMPARE( widget.m_port->value(), 19 ); - QCOMPARE( widget.m_targetName->text(), QString( "theName" ) ); -} - -void -TestFastForwardImporter::providerShouldHandleNonexistentDbFile() -{ - m_cfg.insert( "dbPath", "/Im/sure/this/wont/exist" ); - - FastForwardProvider provider( m_cfg, 0 ); - QVERIFY( provider.artists().isEmpty() ); -} - -void -TestFastForwardImporter::providerShouldHandleInvalidDbFile() -{ - m_cfg.insert( "dbPath", QApplication::applicationFilePath() ); - - FastForwardProvider provider( m_cfg, 0 ); - QVERIFY( provider.artists().isEmpty() ); -} - -void -TestFastForwardImporter::providerShouldHandleExternalConnectionError() -{ - m_cfg.insert( "dbDriver", "QMYSQL" ); - m_cfg.insert( "dbHost", "I hope this isn't a valid hostname" ); - - FastForwardProvider provider( m_cfg, 0 ); - QVERIFY( provider.artists().isEmpty() ); -} - -void -TestFastForwardImporter::providerShouldHandleErroneousConfigValues() -{ - m_cfg.insert( "dbDriver", 19 ); - m_cfg.insert( "dbName", QColor( Qt::red ) ); - m_cfg.insert( "dbPort", "nonsensePort" ); - - FastForwardProvider provider( m_cfg, 0 ); - QVERIFY( provider.artists().isEmpty() ); -} - -#include "moc_TestFastForwardImporter.cpp" diff --git a/amarok/tests/importers/TestFastForwardImporter.h b/amarok/tests/importers/TestFastForwardImporter.h deleted file mode 100644 index aa54328a..00000000 --- a/amarok/tests/importers/TestFastForwardImporter.h +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2013 Konrad Zemek * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef TEST_FAST_FORWARD_IMPORTER -#define TEST_FAST_FORWARD_IMPORTER - -#include "TestImporterBase.h" - -#include - -class TestFastForwardImporter : public TestImporterBase -{ - Q_OBJECT - -private: - QVariantMap m_cfg; - -protected: - virtual StatSyncing::ProviderPtr getProvider(); - virtual StatSyncing::ProviderPtr getWritableProvider(); - virtual qint64 reliableStatistics() const; - -private slots: - void init(); - - void configWidgetShouldOnlyShowFieldsRelevantToConnection(); - void configWidgetShouldSetDriverNameAsConfigResult(); - void configWidgetShouldShowSqliteAsDefault(); - void configWidgetShouldNotBreakOnNonsenseInitialValues(); - void configWidgetShouldReadSavedConfig(); - - void providerShouldHandleNonexistentDbFile(); - void providerShouldHandleInvalidDbFile(); - void providerShouldHandleExternalConnectionError(); - void providerShouldHandleErroneousConfigValues(); -}; - -#endif // TEST_FAST_FORWARD_IMPORTER diff --git a/amarok/tests/importers/TestITunesImporter.cpp b/amarok/tests/importers/TestITunesImporter.cpp deleted file mode 100644 index 4de7756a..00000000 --- a/amarok/tests/importers/TestITunesImporter.cpp +++ /dev/null @@ -1,110 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2013 Konrad Zemek * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "TestITunesImporter.h" - -#include "MetaValues.h" -#include "importers/itunes/ITunesConfigWidget.h" -#include "importers/itunes/ITunesProvider.h" - -#include - -QTEST_KDEMAIN( TestITunesImporter, GUI ) - -using namespace StatSyncing; - -ProviderPtr -TestITunesImporter::getProvider() -{ - QVariantMap cfg = ITunesConfigWidget( QVariantMap() ).config(); - cfg.insert( "dbPath", QApplication::applicationDirPath() - + "/importers_files/iTunes_Music_Library.xml" ); - - return ProviderPtr( new ITunesProvider( cfg, 0 ) ); -} - -ProviderPtr -TestITunesImporter::getWritableProvider() -{ - QDir base( QCoreApplication::applicationDirPath() ); - base.mkpath( "importers_tmp" ); - - const QString dst = base.filePath( "importers_tmp/iTunes_Music_Library.xml" ); - QFile( dst ).remove(); - QFile( base.filePath( "importers_files/iTunes_Music_Library.xml" ) ).copy( dst ); - - QVariantMap cfg = ITunesConfigWidget( QVariantMap() ).config(); - cfg.insert( "dbPath", dst); - - return ProviderPtr( new ITunesProvider( cfg, 0 ) ); -} - -qint64 -TestITunesImporter::reliableStatistics() const -{ - return Meta::valLastPlayed | Meta::valRating | Meta::valPlaycount; -} - -bool -TestITunesImporter::hasOddRatings() const -{ - return false; // iTunes actually *has* odd ratings, as it's rating value is in range - // 0-100, but it represents ratings as multipliers of 20. -} - -void -TestITunesImporter::init() -{ - m_cfg = ITunesConfigWidget( QVariantMap() ).config(); -} - -void -TestITunesImporter::providerShouldHandleNonexistentDbFile() -{ - m_cfg.insert( "dbPath", "/wdawd\\wdadwgd/das4hutyf" ); - - ITunesProvider provider( m_cfg, 0 ); - QVERIFY( provider.artists().isEmpty() ); -} - -void -TestITunesImporter::providerShouldHandleInvalidDbFile() -{ - m_cfg.insert( "dbPath", QApplication::applicationFilePath() ); - - ITunesProvider provider( m_cfg, 0 ); - QVERIFY( provider.artists().isEmpty() ); -} - -void -TestITunesImporter::providerShouldHandleErroneousConfigValues() -{ - m_cfg.insert( "dbPath", "\\wd%aw@d/sdsd2'vodk0-=$$" ); - m_cfg.insert( "name", QColor( Qt::white ) ); - - ITunesProvider provider( m_cfg, 0 ); - QVERIFY( provider.artists().isEmpty() ); -} - -void -TestITunesImporter::providerShouldHandleIllFormedDbFile() -{ - m_cfg.insert( "dbPath", QApplication::applicationDirPath() - + "/importers_files/illFormedLibrary.xml" ); - - ITunesProvider provider( m_cfg, 0 ); - QVERIFY( provider.artistTracks( "NonSuch" ).empty() ); -} diff --git a/amarok/tests/importers/TestITunesImporter.h b/amarok/tests/importers/TestITunesImporter.h deleted file mode 100644 index acdaf294..00000000 --- a/amarok/tests/importers/TestITunesImporter.h +++ /dev/null @@ -1,46 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2013 Konrad Zemek * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef TEST_ITUNES_IMPORTER -#define TEST_ITUNES_IMPORTER - -#include "TestImporterBase.h" - -#include - -class TestITunesImporter : public TestImporterBase -{ - Q_OBJECT - -protected: - StatSyncing::ProviderPtr getProvider(); - StatSyncing::ProviderPtr getWritableProvider(); - qint64 reliableStatistics() const; - bool hasOddRatings() const; - -private: - QVariantMap m_cfg; - -private slots: - void init(); - - void providerShouldHandleNonexistentDbFile(); - void providerShouldHandleInvalidDbFile(); - void providerShouldHandleErroneousConfigValues(); - void providerShouldHandleIllFormedDbFile(); -}; - -#endif // TEST_ITUNES_IMPORTER diff --git a/amarok/tests/importers/TestImporterBase.cpp b/amarok/tests/importers/TestImporterBase.cpp deleted file mode 100644 index 1c7c9b36..00000000 --- a/amarok/tests/importers/TestImporterBase.cpp +++ /dev/null @@ -1,970 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2013 Konrad Zemek * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include - -#include "MetaValues.h" -#include "core/meta/support/MetaConstants.h" -#include "statsyncing/Provider.h" -#include "statsyncing/Track.h" - -#include - -using namespace StatSyncing; - -TestImporterBase::TestImporterBase() -{ - // This is normally set in App.cpp - QTextCodec *utf8codec = QTextCodec::codecForName( "UTF-8" ); - QTextCodec::setCodecForCStrings( utf8codec ); -} - -ProviderPtr -TestImporterBase::getWritableProvider() -{ - return getProvider(); -} - -bool -TestImporterBase::hasOddRatings() const -{ - return true; -} - -#define skipIfNoSupport( fieldmask, metavalue ) \ -{ \ - if( !( fieldmask & metavalue ) ) \ - { \ - const QString msg = QString( "Tested provider does not support %1 metadata" ) \ - .arg( Meta::nameForField( metavalue ) ); \ - QSKIP( msg.toLocal8Bit().constData(), SkipAll ); \ - } \ -} do {} while(false) - -#define amarokProviderSkipIfNoMysqld( provider ) \ - if( QString( provider->prettyName() ) == "Amarok2Test" ) \ - if( !QFileInfo( "/usr/bin/mysqld" ).isExecutable() ) \ - QSKIP( "/usr/bin/mysqld not executable, skipping Amarok provider tests", \ - SkipAll ) - -void -TestImporterBase::titleShouldBeCaseSensitive() -{ - ProviderPtr provider( getProvider() ); - amarokProviderSkipIfNoMysqld( provider ); - - const QString artist = "caseSensitiveTitle"; - QVERIFY( provider->artists().contains( artist ) ); - - QSet trackNames; - foreach( const TrackPtr &track, provider->artistTracks( artist ) ) - trackNames.insert( track->name() ); - - QCOMPARE( trackNames.size(), 3 ); - QVERIFY( trackNames.contains( "title" ) ); - QVERIFY( trackNames.contains( "Title" ) ); - QVERIFY( trackNames.contains( "tiTle" ) ); -} - -void -TestImporterBase::artistShouldBeCaseSensitive() -{ - ProviderPtr provider( getProvider() ); - amarokProviderSkipIfNoMysqld( provider ); - - const QVector artists = QVector() - << "caseSensitiveArtist" << "casesensitiveartist" << "caseSensitiveartist"; - - foreach( const QString &artist, artists ) - { - const TrackList tracks = provider->artistTracks( artist ); - QCOMPARE( tracks.size(), 1 ); - QCOMPARE( tracks.front()->artist(), artist ); - } -} - -void -TestImporterBase::albumShouldBeCaseSensitive() -{ - ProviderPtr provider( getProvider() ); - amarokProviderSkipIfNoMysqld( provider ); - - const QString artist = "caseSensitiveAlbum"; - QVERIFY( provider->artists().contains( artist ) ); - - QSet trackAlbums; - foreach( const TrackPtr &track, provider->artistTracks( artist ) ) - trackAlbums.insert( track->album() ); - - QCOMPARE( trackAlbums.size(), 3 ); - QVERIFY( trackAlbums.contains( "album" ) ); - QVERIFY( trackAlbums.contains( "Album" ) ); - QVERIFY( trackAlbums.contains( "alBum" ) ); -} - -void -TestImporterBase::composerShouldBeCaseSensitive() -{ - ProviderPtr provider( getProvider() ); - amarokProviderSkipIfNoMysqld( provider ); - skipIfNoSupport( provider->reliableTrackMetaData(), Meta::valComposer ); - - const QString artist = "caseSensitiveComposer"; - QVERIFY( provider->artists().contains( artist ) ); - - QSet trackComposers; - foreach( const TrackPtr &track, provider->artistTracks( artist ) ) - trackComposers.insert( track->composer() ); - - QCOMPARE( trackComposers.size(), 3 ); - QVERIFY( trackComposers.contains( "composer" ) ); - QVERIFY( trackComposers.contains( "Composer" ) ); - QVERIFY( trackComposers.contains( "comPoser" ) ); -} - -void -TestImporterBase::titleShouldSupportUTF() -{ - ProviderPtr provider( getProvider() ); - amarokProviderSkipIfNoMysqld( provider ); - - const QString artist = "utfTitle"; - QVERIFY( provider->artists().contains( artist ) ); - - const TrackList tracks = provider->artistTracks( artist ); - QCOMPARE( tracks.size(), 1 ); - QCOMPARE( tracks.front()->name(), QString::fromWCharArray( L"\xF906\xF907\xF908" ) ); -} - -void -TestImporterBase::artistShouldSupportUTF() -{ - ProviderPtr provider( getProvider() ); - amarokProviderSkipIfNoMysqld( provider ); - - const QString artist = QString::fromWCharArray( L"utf\xF909\xF90A\xF90B" ); - QVERIFY( provider->artists().contains( artist ) ); - - const TrackList tracks = provider->artistTracks( artist ); - QCOMPARE( tracks.size(), 1 ); - QCOMPARE( tracks.front()->artist(), artist ); -} - -void -TestImporterBase::albumShouldSupportUTF() -{ - ProviderPtr provider( getProvider() ); - amarokProviderSkipIfNoMysqld( provider ); - - const QString artist = "utfAlbum"; - QVERIFY( provider->artists().contains( artist ) ); - - const TrackList tracks = provider->artistTracks( artist ); - QCOMPARE( tracks.size(), 1 ); - QCOMPARE( tracks.front()->album(), QString::fromWCharArray( L"\xF903\xF904\xF905" ) ); -} - -void -TestImporterBase::composerShouldSupportUTF() -{ - ProviderPtr provider( getProvider() ); - amarokProviderSkipIfNoMysqld( provider ); - skipIfNoSupport( provider->reliableTrackMetaData(), Meta::valComposer ); - - const QString artist = "utfComposer"; - QVERIFY( provider->artists().contains( artist ) ); - - const TrackList tracks = provider->artistTracks( artist ); - QCOMPARE( tracks.size(), 1 ); - QCOMPARE( tracks.front()->composer(), - QString::fromWCharArray( L"\xF900\xF901\xF902" ) ); -} - -void -TestImporterBase::titleShouldSupportMultipleWords() -{ - ProviderPtr provider( getProvider() ); - amarokProviderSkipIfNoMysqld( provider ); - - const QString artist = "multiWordTitle"; - QVERIFY( provider->artists().contains( artist ) ); - - const TrackList tracks = provider->artistTracks( artist ); - QCOMPARE( tracks.size(), 1 ); - QCOMPARE( tracks.front()->name(), QString( "ti tl e" ) ); -} - -void -TestImporterBase::artistShouldSupportMultipleWords() -{ - ProviderPtr provider( getProvider() ); - amarokProviderSkipIfNoMysqld( provider ); - - const QString artist = "multi Word Artist"; - QVERIFY( provider->artists().contains( artist ) ); - - const TrackList tracks = provider->artistTracks( artist ); - QCOMPARE( tracks.size(), 1 ); - QCOMPARE( tracks.front()->artist(), artist ); -} - -void -TestImporterBase::albumShouldSupportMultipleWords() -{ - ProviderPtr provider( getProvider() ); - amarokProviderSkipIfNoMysqld( provider ); - - const QString artist = "multiWordAlbum"; - QVERIFY( provider->artists().contains( artist ) ); - - const TrackList tracks = provider->artistTracks( artist ); - QCOMPARE( tracks.size(), 1 ); - QCOMPARE( tracks.front()->album(), QString( "al b um" ) ); -} - -void -TestImporterBase::composerShouldSupportMultipleWords() -{ - ProviderPtr provider( getProvider() ); - amarokProviderSkipIfNoMysqld( provider ); - skipIfNoSupport( provider->reliableTrackMetaData(), Meta::valComposer ); - - const QString artist = "multiWordComposer"; - QVERIFY( provider->artists().contains( artist ) ); - - const TrackList tracks = provider->artistTracks( artist ); - QCOMPARE( tracks.size(), 1 ); - QCOMPARE( tracks.front()->composer(), QString( "com po ser" ) ); -} - -void -TestImporterBase::titleShouldBeWhitespaceTrimmed() -{ - ProviderPtr provider( getProvider() ); - amarokProviderSkipIfNoMysqld( provider ); - - const QString artist = "trimTitle"; - QVERIFY( provider->artists().contains( artist ) ); - - QSet trackNames; - foreach( const TrackPtr &track, provider->artistTracks( artist ) ) - trackNames.insert( track->name() ); - - QCOMPARE( trackNames.size(), 3 ); - QVERIFY( trackNames.contains( "title1" ) ); - QVERIFY( trackNames.contains( "title2" ) ); - QVERIFY( trackNames.contains( "title3" ) ); -} - -void -TestImporterBase::artistShouldBeWhitespaceTrimmed() -{ - ProviderPtr provider( getProvider() ); - amarokProviderSkipIfNoMysqld( provider ); - - const QString artist = "trimArtist"; - QVERIFY( provider->artists().contains( artist ) ); - - const TrackList tracks = provider->artistTracks( artist ); - QCOMPARE( tracks.size(), 3 ); - - foreach( const TrackPtr &track, tracks ) - QCOMPARE( track->artist(), artist ); -} - -void -TestImporterBase::albumShouldBeWhitespaceTrimmed() -{ - ProviderPtr provider( getProvider() ); - amarokProviderSkipIfNoMysqld( provider ); - - const QString artist = "trimAlbum"; - QVERIFY( provider->artists().contains( artist ) ); - - const TrackList tracks = provider->artistTracks( artist ); - QCOMPARE( tracks.size(), 3 ); - - foreach( const TrackPtr &track, tracks ) - QCOMPARE( track->album(), QString( "album" ) ); -} - -void -TestImporterBase::composerShouldBeWhitespaceTrimmed() -{ - ProviderPtr provider( getProvider() ); - amarokProviderSkipIfNoMysqld( provider ); - skipIfNoSupport( provider->reliableTrackMetaData(), Meta::valComposer ); - - const QString artist = "trimComposer"; - QVERIFY( provider->artists().contains( artist ) ); - - const TrackList tracks = provider->artistTracks( artist ); - QCOMPARE( tracks.size(), 3 ); - - foreach( const TrackPtr &track, tracks ) - QCOMPARE( track->composer(), QString( "composer" ) ); -} - -void -TestImporterBase::albumShouldBeUnsetIfTagIsUnset() -{ - ProviderPtr provider( getProvider() ); - amarokProviderSkipIfNoMysqld( provider ); - - const QString artist = "albumUnset"; - QVERIFY( provider->artists().contains( artist ) ); - - const TrackList tracks = provider->artistTracks( artist ); - QCOMPARE( tracks.size(), 1 ); - QCOMPARE( tracks.front()->album(), QString() ); -} - -void -TestImporterBase::composerShouldBeUnsetIfTagIsUnset() -{ - ProviderPtr provider( getProvider() ); - amarokProviderSkipIfNoMysqld( provider ); - skipIfNoSupport( provider->reliableTrackMetaData(), Meta::valComposer ); - - const QString artist = "composerUnset"; - QVERIFY( provider->artists().contains( artist ) ); - - const TrackList tracks = provider->artistTracks( artist ); - QCOMPARE( tracks.size(), 1 ); - QCOMPARE( tracks.front()->composer(), QString() ); -} - -void -TestImporterBase::yearShouldBeUnsetIfTagIsUnset() -{ - ProviderPtr provider( getProvider() ); - amarokProviderSkipIfNoMysqld( provider ); - skipIfNoSupport( provider->reliableTrackMetaData(), Meta::valYear ); - - const QString artist = "yearUnset"; - QVERIFY( provider->artists().contains( artist ) ); - - const TrackList tracks = provider->artistTracks( artist ); - QCOMPARE( tracks.size(), 1 ); - QCOMPARE( tracks.front()->year(), 0 ); -} - -void -TestImporterBase::trackShouldBeUnsetIfTagIsUnset() -{ - ProviderPtr provider( getProvider() ); - amarokProviderSkipIfNoMysqld( provider ); - skipIfNoSupport( provider->reliableTrackMetaData(), Meta::valTrackNr ); - - const QString artist = "trackUnset"; - QVERIFY( provider->artists().contains( artist ) ); - - const TrackList tracks = provider->artistTracks( artist ); - QCOMPARE( tracks.size(), 1 ); - QCOMPARE( tracks.front()->trackNumber(), 0 ); -} - -void -TestImporterBase::discShouldBeUnsetIfTagIsUnset() -{ - ProviderPtr provider( getProvider() ); - amarokProviderSkipIfNoMysqld( provider ); - skipIfNoSupport( provider->reliableTrackMetaData(), Meta::valDiscNr ); - - const QString artist = "discUnset"; - QVERIFY( provider->artists().contains( artist ) ); - - const TrackList tracks = provider->artistTracks( artist ); - QCOMPARE( tracks.size(), 1 ); - QCOMPARE( tracks.front()->discNumber(), 0 ); -} - -void -TestImporterBase::checkStatistics( const QString &artist ) -{ - ProviderPtr provider( getProvider() ); - amarokProviderSkipIfNoMysqld( provider ); - QVERIFY( provider->artists().contains( artist ) ); - - QMap trackForName; - foreach( const TrackPtr &track, provider->artistTracks( artist ) ) - trackForName.insert( track->name(), track ); - - const QString testName( QTest::currentDataTag() ); - QCOMPARE( trackForName.size(), 10 ); - QVERIFY( trackForName.contains( testName ) ); - - const TrackPtr &track = trackForName.value( testName ); - - if( reliableStatistics() & Meta::valFirstPlayed ) - QTEST( track->firstPlayed(), "firstPlayed" ); - if( reliableStatistics() & Meta::valLastPlayed ) - QTEST( track->lastPlayed(), "lastPlayed" ); - if( reliableStatistics() & Meta::valPlaycount ) - QTEST( track->playCount(), "playCount" ); - - if( reliableStatistics() & Meta::valRating ) - { - QFETCH( int, rating ); - if( !hasOddRatings() && (rating & 1) ) - ++rating; - - QCOMPARE( track->rating(), rating ); - } -} - -void -TestImporterBase::tracksShouldHaveStatistics_data() -{ - QTest::addColumn ( "firstPlayed" ); - QTest::addColumn ( "lastPlayed" ); - QTest::addColumn ( "rating" ); - QTest::addColumn ( "playCount" ); - - QVector d; - for( uint t = 0; t < 20; ++t ) - d.push_back( QDateTime::fromTime_t( 1378125780u + t ) ); - - QTest::newRow( "title0" ) << d[ 0] << d[ 1] << 1 << 20; - QTest::newRow( "title1" ) << d[ 2] << d[ 3] << 2 << 15; - QTest::newRow( "title2" ) << d[ 4] << d[ 5] << 3 << 14; - QTest::newRow( "title3" ) << d[ 6] << d[ 7] << 4 << 13; - QTest::newRow( "title4" ) << d[ 8] << d[ 9] << 5 << 11; - QTest::newRow( "title5" ) << d[10] << d[11] << 6 << 10; - QTest::newRow( "title6" ) << d[12] << d[13] << 7 << 7; - QTest::newRow( "title7" ) << d[14] << d[15] << 8 << 5; - QTest::newRow( "title8" ) << d[16] << d[17] << 9 << 3; - QTest::newRow( "title9" ) << d[18] << d[19] << 10 << 2; -} - -void -TestImporterBase::tracksShouldHaveStatistics() -{ - checkStatistics( "testStatistics" ); -} - -void -TestImporterBase::tracksShouldBehaveNicelyWithNoStatistics_data() -{ - QTest::addColumn ( "firstPlayed" ); - QTest::addColumn ( "lastPlayed" ); - QTest::addColumn ( "rating" ); - QTest::addColumn ( "playCount" ); - - QVector d; - for( uint t = 0; t < 20; ++t ) - d.push_back( QDateTime::fromTime_t( 1378125780u + t ) ); - - QTest::newRow( "title0" ) << QDateTime() << QDateTime() << 0 << 0; - QTest::newRow( "title1" ) << QDateTime() << d[ 3] << 2 << 15; - QTest::newRow( "title2" ) << QDateTime() << QDateTime() << 3 << 14; - QTest::newRow( "title3" ) << QDateTime() << d[ 7] << 0 << 13; - QTest::newRow( "title4" ) << QDateTime() << QDateTime() << 5 << 0; - QTest::newRow( "title5" ) << d[10] << d[11] << 6 << 10; - QTest::newRow( "title6" ) << d[12] << QDateTime() << 0 << 7; - QTest::newRow( "title7" ) << d[14] << d[15] << 8 << 5; - QTest::newRow( "title8" ) << d[16] << QDateTime() << 9 << 0; - QTest::newRow( "title9" ) << d[18] << d[19] << 0 << 2; -} - -void -TestImporterBase::tracksShouldBehaveNicelyWithNoStatistics() -{ - checkStatistics( "testStatisticsNotSet" ); -} - -void TestImporterBase::labels( const ProviderPtr &provider, const QString &trackName ) -{ - m_lbl.clear(); - - const QString artist = "testStatistics"; - - QVERIFY( provider->artists().contains( artist ) ); - - QMap trackForName; - foreach( const TrackPtr &track, provider->artistTracks( artist ) ) - { - QVERIFY( !trackForName.contains( track->name() ) ); - trackForName.insert( track->name(), track ); - } - - QVERIFY( trackForName.contains( trackName ) ); - m_lbl = trackForName.value( trackName )->labels(); -} - -void -TestImporterBase::tracksShouldWorkWithSingleLabel() -{ - ProviderPtr provider( getProvider() ); - amarokProviderSkipIfNoMysqld( provider ); - skipIfNoSupport( reliableStatistics(), Meta::valLabel ); - - labels( provider, "title0" ); - - QCOMPARE( m_lbl.size(), 1 ); - QVERIFY( m_lbl.contains( "singleTag" ) ); -} - -void -TestImporterBase::tracksShouldWorkWithMultipleLabels() -{ - ProviderPtr provider( getProvider() ); - amarokProviderSkipIfNoMysqld( provider ); - skipIfNoSupport( reliableStatistics(), Meta::valLabel ); - - labels( provider, "title1" ); - - QCOMPARE( m_lbl.size(), 2 ); - QVERIFY( m_lbl.contains( "multiple" ) ); - QVERIFY( m_lbl.contains( "tags" ) ); -} - -void -TestImporterBase::tracksShouldWorkWithCaseSensitiveLabels() -{ - ProviderPtr provider( getProvider() ); - amarokProviderSkipIfNoMysqld( provider ); - skipIfNoSupport( reliableStatistics(), Meta::valLabel ); - - labels( provider, "title2" ); - - QCOMPARE( m_lbl.size(), 2 ); - QVERIFY( m_lbl.contains( "caseSensitive" ) ); - QVERIFY( m_lbl.contains( "casesensitive" ) ); -} - -void -TestImporterBase::tracksShouldWorkWithUTFLabels() -{ - ProviderPtr provider( getProvider() ); - amarokProviderSkipIfNoMysqld( provider ); - skipIfNoSupport( reliableStatistics(), Meta::valLabel ); - - labels( provider, "title3" ); - - QCOMPARE( m_lbl.size(), 1 ); - QVERIFY( m_lbl.contains( QString::fromWCharArray( L"\x2622" ) ) ); -} - -void -TestImporterBase::providerShouldReturnNoTracksForNonexistentArtist() -{ - ProviderPtr provider( getProvider() ); - amarokProviderSkipIfNoMysqld( provider ); - - const QString artist = "I'mNotHere"; - QVERIFY( !provider->artists().contains( artist ) ); - QVERIFY( provider->artistTracks( artist ).isEmpty() ); -} - -void -TestImporterBase::providerShouldNotBreakOnLittleBobbyTables() -{ - ProviderPtr provider( getProvider() ); - amarokProviderSkipIfNoMysqld( provider ); - - const QString artist = "Robert'); DROP TABLE students;--"; - QVERIFY( !provider->artists().contains( artist ) ); - QVERIFY( provider->artistTracks( artist ).isEmpty() ); -} - -static TrackPtr -trackForName( ProviderPtr &provider, const QString &name, const QString &artist ) -{ - foreach( const TrackPtr &track, provider->artistTracks( artist ) ) - if( track->name() == name ) - return track; - - return TrackPtr( 0 ); -} - -static Meta::FieldHash -saveData( const TrackPtr &track ) -{ - Meta::FieldHash data; - data.insert( Meta::valTitle, track->name() ); - data.insert( Meta::valArtist, track->artist() ); - data.insert( Meta::valAlbum, track->album() ); - data.insert( Meta::valComposer, track->composer() ); - data.insert( Meta::valTrackNr, track->trackNumber() ); - data.insert( Meta::valDiscNr, track->discNumber() ); - data.insert( Meta::valFirstPlayed, track->firstPlayed() ); - data.insert( Meta::valLastPlayed, track->lastPlayed() ); - data.insert( Meta::valRating, track->rating() ); - data.insert( Meta::valPlaycount, track->playCount() ); - data.insert( Meta::valLabel, QStringList( track->labels().toList() ) ); - return data; -} - -static void -verifyEqualExcept( const Meta::FieldHash &lhs, const TrackPtr &track, - const qint64 except ) -{ - const QList fields = QList() << Meta::valTitle << Meta::valArtist - << Meta::valAlbum << Meta::valComposer << Meta::valTrackNr - << Meta::valDiscNr << Meta::valFirstPlayed - << Meta::valLastPlayed << Meta::valRating - << Meta::valPlaycount << Meta::valLabel; - - const Meta::FieldHash rhs = saveData( track ); - foreach( const qint64 field, fields ) - if( !( except & field ) ) - QCOMPARE( lhs.value( field ), rhs.value( field ) ); -} - -void -TestImporterBase::commitAfterSettingAllStatisticsShouldSaveThem_data() -{ - QTest::addColumn( "title" ); - QTest::addColumn( "artist" ); - QTest::addColumn( "newFirstPlayed" ); - QTest::addColumn( "newLastPlayed" ); - QTest::addColumn( "newRating" ); - QTest::addColumn( "newPlayCount" ); - QTest::addColumn( "newLabels" ); - - const uint now = QDateTime::currentDateTime().toTime_t(); - - QTest::newRow( "Replace all" ) << "title0" << "testStatistics" - << QDateTime::fromTime_t( now - 100 ) - << QDateTime::fromTime_t( now + 100 ) - << 9 << 25 << ( QStringList() << "teh" << "lab'ls" ); - - QTest::newRow( "Add all" ) << "title0" << "testStatisticsNotSet" - << QDateTime::fromTime_t( now - 100 ) - << QDateTime::fromTime_t( now + 100 ) - << 9 << 25 << ( QStringList() << "teh" << "lab'ls" ); - - QTest::newRow( "Add some 1" ) << "title2" << "testStatisticsNotSet" - << QDateTime::fromTime_t( now - 100 ) - << QDateTime::fromTime_t( now + 100 ) - << 9 << 25 << ( QStringList() << "teh" << "lab'ls" ); - - QTest::newRow( "Add some 1" ) << "title4" << "testStatisticsNotSet" - << QDateTime::fromTime_t( now - 100 ) - << QDateTime::fromTime_t( now + 100 ) - << 9 << 25 << ( QStringList() << "teh" << "lab'ls" ); - - QTest::newRow( "Add some 1" ) << "title6" << "testStatisticsNotSet" - << QDateTime::fromTime_t( now - 100 ) - << QDateTime::fromTime_t( now + 100 ) - << 9 << 25 << ( QStringList() << "teh" << "lab'ls" ); -} - -void -TestImporterBase::commitAfterSettingAllStatisticsShouldSaveThem() -{ - ProviderPtr provider( getWritableProvider() ); - amarokProviderSkipIfNoMysqld( provider ); - - QFETCH( QString, title ); - QFETCH( QString, artist ); - TrackPtr track = trackForName( provider, title, artist ); - QVERIFY( track ); - - const Meta::FieldHash data = saveData( track ); - - if( provider->writableTrackStatsData() & Meta::valFirstPlayed ) - { - QFETCH( QDateTime, newFirstPlayed ); - track->setFirstPlayed( newFirstPlayed ); - } - if( provider->writableTrackStatsData() & Meta::valLastPlayed ) - { - QFETCH( QDateTime, newLastPlayed ); - track->setLastPlayed( newLastPlayed ); - } - if( provider->writableTrackStatsData() & Meta::valRating ) - { - QFETCH( int, newRating ); - track->setRating( newRating ); - } - if( provider->writableTrackStatsData() & Meta::valPlaycount ) - { - QFETCH( int, newPlayCount ); - track->setPlayCount( newPlayCount ); - } - if( provider->writableTrackStatsData() & Meta::valLabel ) - { - QFETCH( QStringList, newLabels ); - track->setLabels( newLabels.toSet() ); - } - - track->commit(); - provider->commitTracks(); - - track = trackForName( provider, title, artist ); - QVERIFY( track ); - - if( provider->writableTrackStatsData() & Meta::valFirstPlayed ) - { - QFETCH( QDateTime, newFirstPlayed ); - QCOMPARE( track->firstPlayed(), newFirstPlayed ); - } - if( provider->writableTrackStatsData() & Meta::valLastPlayed ) - { - QFETCH( QDateTime, newLastPlayed ); - QCOMPARE( track->lastPlayed(), newLastPlayed ); - } - if( provider->writableTrackStatsData() & Meta::valRating ) - { - QFETCH( int, newRating ); - if( !hasOddRatings() && (newRating & 1) ) - ++newRating; - QCOMPARE( track->rating(), newRating ); - } - if( provider->writableTrackStatsData() & Meta::valPlaycount ) - { - QFETCH( int, newPlayCount ); - QCOMPARE( track->playCount(), newPlayCount ); - } - if( provider->writableTrackStatsData() & Meta::valLabel ) - { - QFETCH( QStringList, newLabels ); - QCOMPARE( track->labels(), newLabels.toSet() ); - } - - verifyEqualExcept( data, track, Meta::valFirstPlayed | Meta::valLastPlayed | - Meta::valRating | Meta::valPlaycount | Meta::valLabel ); -} - -void -TestImporterBase::commitAfterSettingFirstPlayedShouldSaveIt_data() -{ - QTest::addColumn( "title" ); - QTest::addColumn( "newFirstPlayed" ); - - const uint now = QDateTime::currentDateTime().toTime_t(); - - QTest::newRow( "Add stat 1" ) << "title0" << QDateTime::fromTime_t( now ); - QTest::newRow( "Add stat 2" ) << "title1" << QDateTime::fromTime_t( now + 2 ); - QTest::newRow( "Add stat 3" ) << "title2" << QDateTime::fromTime_t( now + 3 ); - - QTest::newRow( "Replace stat 1" ) << "title5" << QDateTime::fromTime_t( now + 11 ); - QTest::newRow( "Replace stat 2" ) << "title6" << QDateTime::fromTime_t( now + 13 ); - QTest::newRow( "Replace stat 3" ) << "title7" << QDateTime::fromTime_t( now + 17 ); - - QTest::newRow( "Remove stat 1" ) << "title5" << QDateTime(); - QTest::newRow( "Remove stat 2" ) << "title6" << QDateTime(); - QTest::newRow( "Remove stat 3" ) << "title7" << QDateTime(); -} - -void -TestImporterBase::commitAfterSettingFirstPlayedShouldSaveIt() -{ - ProviderPtr provider( getWritableProvider() ); - amarokProviderSkipIfNoMysqld( provider ); - skipIfNoSupport( provider->writableTrackStatsData(), Meta::valFirstPlayed ); - - QFETCH( QString, title ); - QFETCH( QDateTime, newFirstPlayed ); - - TrackPtr track = trackForName( provider, title, "testStatisticsNotSet" ); - QVERIFY( track ); - - const Meta::FieldHash data = saveData( track ); - track->setFirstPlayed( newFirstPlayed ); - track->commit(); - provider->commitTracks(); - - track = trackForName( provider, title, "testStatisticsNotSet" ); - QVERIFY( track ); - QCOMPARE( track->firstPlayed(), newFirstPlayed ); - verifyEqualExcept( data, track, Meta::valFirstPlayed ); -} - -void -TestImporterBase::commitAfterSettingLastPlayedShouldSaveIt_data() -{ - QTest::addColumn( "title" ); - QTest::addColumn( "newLastPlayed" ); - - const uint now = QDateTime::currentDateTime().toTime_t(); - - QTest::newRow( "Add stat 1" ) << "title0" << QDateTime::fromTime_t( now ); - QTest::newRow( "Add stat 2" ) << "title2" << QDateTime::fromTime_t( now + 2 ); - QTest::newRow( "Add stat 3" ) << "title4" << QDateTime::fromTime_t( now + 3 ); - - QTest::newRow( "Replace stat 1" ) << "title1" << QDateTime::fromTime_t( now + 11 ); - QTest::newRow( "Replace stat 2" ) << "title3" << QDateTime::fromTime_t( now + 13 ); - QTest::newRow( "Replace stat 3" ) << "title5" << QDateTime::fromTime_t( now + 17 ); - - QTest::newRow( "Remove stat 1" ) << "title1" << QDateTime(); - QTest::newRow( "Remove stat 2" ) << "title3" << QDateTime(); - QTest::newRow( "Remove stat 3" ) << "title5" << QDateTime(); -} - -void -TestImporterBase::commitAfterSettingLastPlayedShouldSaveIt() -{ - ProviderPtr provider( getWritableProvider() ); - amarokProviderSkipIfNoMysqld( provider ); - skipIfNoSupport( provider->writableTrackStatsData(), Meta::valLastPlayed ); - - QFETCH( QString, title ); - QFETCH( QDateTime, newLastPlayed ); - - TrackPtr track = trackForName( provider, title, "testStatisticsNotSet" ); - QVERIFY( track ); - - const Meta::FieldHash data = saveData( track ); - track->setLastPlayed( newLastPlayed ); - track->commit(); - provider->commitTracks(); - - track = trackForName( provider, title, "testStatisticsNotSet" ); - QVERIFY( track ); - QCOMPARE( track->lastPlayed(), newLastPlayed ); - verifyEqualExcept( data, track, Meta::valLastPlayed ); -} - -void -TestImporterBase::commitAfterSettingRatingShouldSaveIt_data() -{ - QTest::addColumn( "title" ); - QTest::addColumn( "newRating" ); - - QTest::newRow( "Add stat 1" ) << "title0" << 2; - QTest::newRow( "Add stat 2" ) << "title3" << 3; - QTest::newRow( "Add stat 3" ) << "title6" << 5; - - QTest::newRow( "Replace stat 1" ) << "title1" << 1; - QTest::newRow( "Replace stat 2" ) << "title2" << 3; - QTest::newRow( "Replace stat 3" ) << "title4" << 6; - - QTest::newRow( "Remove stat 1" ) << "title1" << 0; - QTest::newRow( "Remove stat 2" ) << "title2" << 0; - QTest::newRow( "Remove stat 3" ) << "title4" << 0; -} - -void -TestImporterBase::commitAfterSettingRatingShouldSaveIt() -{ - ProviderPtr provider( getWritableProvider() ); - amarokProviderSkipIfNoMysqld( provider ); - skipIfNoSupport( provider->writableTrackStatsData(), Meta::valRating ); - - QFETCH( QString, title ); - QFETCH( int, newRating ); - - TrackPtr track = trackForName( provider, title, "testStatisticsNotSet" ); - QVERIFY( track ); - - const Meta::FieldHash data = saveData( track ); - track->setRating( newRating ); - track->commit(); - provider->commitTracks(); - - if( !hasOddRatings() && (newRating & 1) ) - ++newRating; - - track = trackForName( provider, title, "testStatisticsNotSet" ); - QVERIFY( track ); - QCOMPARE( track->rating(), newRating ); - verifyEqualExcept( data, track, Meta::valRating ); -} - -void -TestImporterBase::commitAfterSettingPlaycountShouldSaveIt_data() -{ - QTest::addColumn( "title" ); - QTest::addColumn( "newPlayCount" ); - - QTest::newRow( "Add stat 1" ) << "title0" << 13; - QTest::newRow( "Add stat 2" ) << "title4" << 17; - QTest::newRow( "Add stat 3" ) << "title8" << 23; - - QTest::newRow( "Replace stat 1" ) << "title1" << 1; - QTest::newRow( "Replace stat 2" ) << "title2" << 3; - QTest::newRow( "Replace stat 3" ) << "title3" << 6; - - QTest::newRow( "Remove stat 1" ) << "title1" << 0; - QTest::newRow( "Remove stat 2" ) << "title2" << 0; - QTest::newRow( "Remove stat 3" ) << "title3" << 0; -} - -void -TestImporterBase::commitAfterSettingPlaycountShouldSaveIt() -{ - ProviderPtr provider( getWritableProvider() ); - amarokProviderSkipIfNoMysqld( provider ); - skipIfNoSupport( provider->writableTrackStatsData(), Meta::valPlaycount ); - - QFETCH( QString, title ); - QFETCH( int, newPlayCount ); - - TrackPtr track = trackForName( provider, title, "testStatisticsNotSet" ); - QVERIFY( track ); - - const Meta::FieldHash data = saveData( track ); - track->setPlayCount( newPlayCount ); - track->commit(); - provider->commitTracks(); - - track = trackForName( provider, title, "testStatisticsNotSet" ); - QVERIFY( track ); - QCOMPARE( track->playCount(), newPlayCount ); - verifyEqualExcept( data, track, Meta::valPlaycount ); -} - -void -TestImporterBase::commitAfterSettingLabelsShouldSaveThem_data() -{ - QTest::addColumn( "title" ); - QTest::addColumn( "newLabels" ); - - QTest::newRow( "Add new label" ) << "title4" << ( QStringList() << "singleTag2" ); - QTest::newRow( "Add existing label" ) << "title5" << ( QStringList() << "singleTag" ); - QTest::newRow( "Add labels" ) << "title6" << ( QStringList() << "multi" << "labels" ); - QTest::newRow( "Add existing labels" ) << "title7" - << ( QStringList() << "multiple" << "labels" ); - QTest::newRow( "Add case-sensitive labels" ) << "title8" - << ( QStringList() << "cs" << "Cs" ); - - QTest::newRow( "Replace all labels" ) << "title1" << ( QStringList() << "a" << "l" ); - QTest::newRow( "Replace some labels" ) << "title1" - << ( QStringList() << "a" << "tags" ); - QTest::newRow( "Add additional labels" ) << "title1" - << ( QStringList() << "multiple" << "tags" << "2" ); - - QTest::newRow( "Remove labels 1" ) << "title0" << QStringList(); - QTest::newRow( "Remove labels 2" ) << "title1" << QStringList(); - QTest::newRow( "Remove labels 3" ) << "title2" << QStringList(); -} - -void -TestImporterBase::commitAfterSettingLabelsShouldSaveThem() -{ - ProviderPtr provider( getWritableProvider() ); - amarokProviderSkipIfNoMysqld( provider ); - skipIfNoSupport( provider->writableTrackStatsData(), Meta::valLabel ); - - QFETCH( QString, title ); - QFETCH( QStringList, newLabels ); - - TrackPtr track = trackForName( provider, title, "testStatistics" ); - QVERIFY( track ); - - const Meta::FieldHash data = saveData( track ); - track->setLabels( newLabels.toSet() ); - track->commit(); - provider->commitTracks(); - - track = trackForName( provider, title, "testStatistics" ); - QVERIFY( track ); - QCOMPARE( track->labels(), newLabels.toSet() ); - verifyEqualExcept( data, track, Meta::valLabel ); -} diff --git a/amarok/tests/importers/TestImporterBase.h b/amarok/tests/importers/TestImporterBase.h deleted file mode 100644 index 22dafb17..00000000 --- a/amarok/tests/importers/TestImporterBase.h +++ /dev/null @@ -1,161 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2013 Konrad Zemek * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef TEST_IMPORTER_BASE -#define TEST_IMPORTER_BASE - -#include -#include -#include - -namespace StatSyncing -{ - class Provider; - typedef QExplicitlySharedDataPointer ProviderPtr; -} - -/** - * A base class for Importer tests. It relies on convention to thoroughly test - * a provider. It uses the provider returned by @see TestImporterBase::provider() - * pure virtual method, which should be initialized with a database containing tracks - * found in tests/importers/files/testcollection . Additionally, some of these tracks - * must have their statistics set in the following way: - * - * title, artist, firstPlayed, lastPlayed, rating, playcount - * title0, testStatistics, 1378125780, 1378125781, 1, 20 - * title1, testStatistics, 1378125782, 1378125783, 2, 15 - * title2, testStatistics, 1378125784, 1378125785, 3, 14 - * title3, testStatistics, 1378125786, 1378125787, 4, 13 - * title4, testStatistics, 1378125788, 1378125789, 5, 11 - * title5, testStatistics, 1378125790, 1378125791, 6, 10 - * title6, testStatistics, 1378125792, 1378125793, 7, 7 - * title7, testStatistics, 1378125794, 1378125795, 8, 5 - * title8, testStatistics, 1378125796, 1378125797, 9, 3 - * title9, testStatistics, 1378125798, 1378125799, 10, 2 - * - * title, artist, firstPlayed, lastPlayed, rating, playcount - * title0, testStatisticsNotSet, , , , - * title1, testStatisticsNotSet, , 1378125783, 2, 15 - * title2, testStatisticsNotSet, , , 3, 14 - * title3, testStatisticsNotSet, , 1378125787, , 13 - * title4, testStatisticsNotSet, , , 5, - * title5, testStatisticsNotSet, 1378125790, 1378125791, 6, 10 - * title6, testStatisticsNotSet, 1378125792, , , 7 - * title7, testStatisticsNotSet, 1378125794, 1378125795, 8, 5 - * title8, testStatisticsNotSet, 1378125796, , 9, - * title9, testStatisticsNotSet, 1378125798, 1378125799, , 2 - * - * title, artist, labels - * title0, testStatistics, 'singleTag' - * title1, testStatistics, 'multiple', 'tags' - * title2, testStatistics, 'caseSensitive', 'casesensitive' - * title3, testStatistics, '☢' - */ -class TestImporterBase : public QObject -{ - Q_OBJECT - -public: - TestImporterBase(); - -protected: - /** - * This method should return provider already configured for testing. - */ - virtual StatSyncing::ProviderPtr getProvider() = 0; - - /** - * This method should return a provider ready for writing. The database used should - * be a temporary copy. - */ - virtual StatSyncing::ProviderPtr getWritableProvider(); - - /** - * Return a binary or of Meta::val* representing statistics suported - * by the provider being tested. - */ - virtual qint64 reliableStatistics() const = 0; - - /** - * Returns true if the provider is capable of expressing odd-number ratings - * (half-stars). Otherwise tests treat a half-star like a whole star (i.e. - * a song normally with a rating 3 is assumed to have a rating 4). - */ - virtual bool hasOddRatings() const; - -private: - void checkStatistics( const QString &artist ); - void labels( const StatSyncing::ProviderPtr &provider, const QString &trackName ); - - QSet m_lbl; - -private slots: - void titleShouldBeCaseSensitive(); - void artistShouldBeCaseSensitive(); - void albumShouldBeCaseSensitive(); - void composerShouldBeCaseSensitive(); - - void titleShouldSupportUTF(); - void artistShouldSupportUTF(); - void albumShouldSupportUTF(); - void composerShouldSupportUTF(); - - void titleShouldSupportMultipleWords(); - void artistShouldSupportMultipleWords(); - void albumShouldSupportMultipleWords(); - void composerShouldSupportMultipleWords(); - - void titleShouldBeWhitespaceTrimmed(); - void artistShouldBeWhitespaceTrimmed(); - void albumShouldBeWhitespaceTrimmed(); - void composerShouldBeWhitespaceTrimmed(); - - void albumShouldBeUnsetIfTagIsUnset(); - void composerShouldBeUnsetIfTagIsUnset(); - void yearShouldBeUnsetIfTagIsUnset(); - void trackShouldBeUnsetIfTagIsUnset(); - void discShouldBeUnsetIfTagIsUnset(); - - void tracksShouldHaveStatistics_data(); - void tracksShouldHaveStatistics(); - - void tracksShouldBehaveNicelyWithNoStatistics_data(); - void tracksShouldBehaveNicelyWithNoStatistics(); - - void tracksShouldWorkWithSingleLabel(); - void tracksShouldWorkWithMultipleLabels(); - void tracksShouldWorkWithCaseSensitiveLabels(); - void tracksShouldWorkWithUTFLabels(); - - void providerShouldReturnNoTracksForNonexistentArtist(); - void providerShouldNotBreakOnLittleBobbyTables(); - - // Write capabilities - void commitAfterSettingAllStatisticsShouldSaveThem_data(); - void commitAfterSettingAllStatisticsShouldSaveThem(); - void commitAfterSettingFirstPlayedShouldSaveIt_data(); - void commitAfterSettingFirstPlayedShouldSaveIt(); - void commitAfterSettingLastPlayedShouldSaveIt_data(); - void commitAfterSettingLastPlayedShouldSaveIt(); - void commitAfterSettingRatingShouldSaveIt_data(); - void commitAfterSettingRatingShouldSaveIt(); - void commitAfterSettingPlaycountShouldSaveIt_data(); - void commitAfterSettingPlaycountShouldSaveIt(); - void commitAfterSettingLabelsShouldSaveThem_data(); - void commitAfterSettingLabelsShouldSaveThem(); -}; - -#endif // TEST_IMPORTER_BASE diff --git a/amarok/tests/importers/TestImporterManager.cpp b/amarok/tests/importers/TestImporterManager.cpp deleted file mode 100644 index 0ec6ad3f..00000000 --- a/amarok/tests/importers/TestImporterManager.cpp +++ /dev/null @@ -1,256 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2013 Konrad Zemek * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "TestImporterManager.h" - -#include "core/support/Amarok.h" -#include "core/support/Components.h" - -#include - -#include - -QTEST_KDEMAIN_CORE( TestImporterManager ) - -using namespace ::testing; - -void -TestImporterManager::initShouldSetInfo() -{ - KPluginInfo expectedInfo( "testinfo", "services" ); - EXPECT_CALL( *m_mockManager, pluginInfo() ).WillOnce( Return( expectedInfo ) ); - - m_mockManager->init(); - QCOMPARE( m_mockManager->info(), expectedInfo ); -} - -void -TestImporterManager::initShouldLoadSettings() -{ - QVariantMap config; - config["uid"] = QString( "TestId" ); - config["custom"] = QString( "custom" ); - - { - NiceMock mock; - - EXPECT_CALL( mock, newInstance( Eq(config) ) ).WillOnce( Invoke( &mock, &MockManager::concreteNewInstance ) ); - EXPECT_CALL( mock, type() ).WillRepeatedly( Return( QString( "TestMockManager" ) ) ); - - mock.init(); - mock.createProvider( config ); - } - - EXPECT_CALL( *m_mockManager, newInstance( Eq(config) ) ); - EXPECT_CALL( *m_mockManager, type() ).WillRepeatedly( Return( QString( "TestMockManager" ) ) ); - - m_mockManager->init(); -} - -void -TestImporterManager::creatingProviderShouldSetConfigAndParent() -{ - QVariantMap cfg; - cfg["customField"] = QString( "I'm custom" ); - - m_mockManager->init(); - StatSyncing::ProviderPtr providerPtr = m_mockManager->createProvider( cfg ); - - QVERIFY( dynamic_cast(providerPtr.data())->config().contains( "customField" ) ); - QCOMPARE( dynamic_cast(providerPtr.data())->manager(), m_mockManager ); -} - -void -TestImporterManager::creatingProviderShouldSaveSettings() -{ - QVariantMap cfg; - cfg["uid"] = QString( "TestId" ); - cfg["custom"] = QString( "custom" ); - - EXPECT_CALL( *m_mockManager, type() ).WillRepeatedly( Return( QString( "TestMockManager" ) ) ); - - m_mockManager->init(); - m_mockManager->createProvider( cfg ); - - KConfigGroup group = m_mockManager->providerConfig( "TestId" ); - QVERIFY( group.exists() ); - QCOMPARE( group.readEntry( "uid", QString() ), QString( "TestId" ) ); - QCOMPARE( group.readEntry( "custom", QString() ), QString( "custom" ) ); -} - -void -TestImporterManager::creatingProviderShouldSaveGeneratedId() -{ - EXPECT_CALL( *m_mockManager, type() ).WillRepeatedly( Return( QString( "TestMockManager" ) ) ); - - QVERIFY( !m_mockManager->managerConfig().exists() ); - - m_mockManager->init(); - StatSyncing::ProviderPtr provider = m_mockManager->createProvider( QVariantMap() ); - - KConfigGroup group = m_mockManager->managerConfig(); - QVERIFY( group.exists() ); - QVERIFY( !group.groupList().empty() ); - - group = m_mockManager->providerConfig( provider ); - QVERIFY( group.exists() ); - QCOMPARE( group.readEntry( "uid", QString() ), provider->id() ); -} - -void -TestImporterManager::creatingConfigWidgetShouldDelegate() -{ - StatSyncing::ProviderConfigWidget *ptr = reinterpret_cast( 0x19 ); - - EXPECT_CALL( *m_mockManager, configWidget( QVariantMap() ) ).WillOnce( Return( ptr ) ); - - m_mockManager->init(); - QCOMPARE( m_mockManager->createConfigWidget(), ptr ); -} - -void -TestImporterManager::createConfigWidgetShouldNotCrashOnNull() -{ - StatSyncing::ProviderConfigWidget *ptr = 0; - - EXPECT_CALL( *m_mockManager, configWidget(_) ) - .WillOnce( Return( ptr ) ); - - m_mockManager->init(); - QCOMPARE( m_mockManager->createConfigWidget(), ptr ); -} - -void -TestImporterManager::createProviderShouldNotCrashOnNull() -{ - m_mockManager->init(); - - EXPECT_CALL( *m_mockManager, newInstance(_) ) - .WillOnce( Return( StatSyncing::ProviderPtr( 0 ) ) ); - - QVERIFY( !m_mockManager->createProvider( QVariantMap() ) ); -} - -void -TestImporterManager::createProviderShouldReplaceProviderIfExists() -{ - m_mockManager->init(); - - EXPECT_CALL( *m_mockController, registerProvider(_) ).Times( 2 ); - - StatSyncing::ProviderPtr provider = m_mockManager->createProvider( QVariantMap() ); - - QVERIFY( m_mockManager->providers().contains( provider->id() ) ); - QCOMPARE( m_mockManager->providers()[provider->id()], provider ); - - EXPECT_CALL( *m_mockController, unregisterProvider( provider ) ); - - QVariantMap cfg; - cfg.insert( "uid", provider->id() ); - StatSyncing::ProviderPtr replaceProvider = m_mockManager->createProvider( cfg ); - - QCOMPARE( m_mockManager->providers()[provider->id()], replaceProvider ); -} - -void -TestImporterManager::createProviderShouldRegisterProvider() -{ - QVariantMap cfg; - cfg["uid"] = "uid"; - StatSyncing::ImporterProviderPtr providerPtr( new NiceMock( cfg, m_mockManager ) ); - - m_mockManager->init(); - - EXPECT_CALL( *m_mockManager, newInstance(_) ).WillOnce( Return( providerPtr ) ); - EXPECT_CALL( *m_mockController, registerProvider( Eq(providerPtr) ) ); - - m_mockManager->createProvider( QVariantMap() ); -} - -void -TestImporterManager::forgetProviderShouldUnregisterProvider() -{ - m_mockManager->init(); - - EXPECT_CALL( *m_mockController, registerProvider(_) ); - - StatSyncing::ProviderPtr providerPtr = m_mockManager->createProvider( QVariantMap() ); - - EXPECT_CALL( *m_mockController, unregisterProvider( Eq(providerPtr) ) ); - m_mockManager->providerForgottenProxy( providerPtr->id() ); -} - -void -TestImporterManager::forgetProviderShouldForgetConfig() -{ - QVariantMap cfg; - cfg.insert( "uid", "TestId" ); - - EXPECT_CALL( *m_mockManager, type() ).WillRepeatedly( - Return( QString( "TestMockManager" ) ) ); - - m_mockManager->init(); - StatSyncing::ProviderPtr providerPtr = m_mockManager->createProvider( cfg ); - - KConfigGroup group = m_mockManager->providerConfig( providerPtr ); - QVERIFY( group.exists() ); - QVERIFY( group.hasKey( "uid" ) ); - - m_mockManager->providerForgottenProxy( providerPtr->id() ); - - QVERIFY( !m_mockManager->providerConfig( providerPtr ).exists() ); -} - -void -TestImporterManager::forgetProviderShouldHangleInvalidId() -{ - EXPECT_CALL( *m_mockController, unregisterProvider(_) ).Times( 0 ); - - m_mockManager->init(); - m_mockManager->providerForgottenProxy( QString() ); -} - -void -TestImporterManager::forgetProviderShouldNotCauseOtherProvidersToBeForgotten() -{ - m_mockManager->init(); - - StatSyncing::ProviderPtr providerPtr1 = m_mockManager->createProvider( QVariantMap() ); - StatSyncing::ProviderPtr providerPtr2 = m_mockManager->createProvider( QVariantMap() ); - - QVERIFY( m_mockManager->providerConfig( providerPtr1 ).exists() ); - QVERIFY( m_mockManager->providerConfig( providerPtr2 ).exists() ); - - m_mockManager->providerForgottenProxy( providerPtr1->id() ); - - QVERIFY( !m_mockManager->providerConfig( providerPtr1 ).exists() ); - QVERIFY( m_mockManager->providerConfig( providerPtr2 ).exists() ); -} - -void -TestImporterManager::managerShouldHandleMultipleProviders() -{ - EXPECT_CALL( *m_mockController, registerProvider(_) ).Times( 10 ); - - QList providerPtrs; - for( int i = 0; i < 10; ++i ) - providerPtrs << m_mockManager->createProvider( QVariantMap() ); - - foreach( const StatSyncing::ProviderPtr &providerPtr, providerPtrs ) - QVERIFY( m_mockManager->providers().contains( providerPtr->id() ) ); -} - -#include "moc_TestImporterManager.cpp" diff --git a/amarok/tests/importers/TestImporterManager.h b/amarok/tests/importers/TestImporterManager.h deleted file mode 100644 index ef87d07f..00000000 --- a/amarok/tests/importers/TestImporterManager.h +++ /dev/null @@ -1,44 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2013 Konrad Zemek * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef TEST_IMPORTER_MANAGER -#define TEST_IMPORTER_MANAGER - -#include "ImporterMocks.h" - -class TestImporterManager : public ImporterMocks -{ - Q_OBJECT - -private slots: - void initShouldSetInfo(); - void initShouldLoadSettings(); - void creatingProviderShouldSetConfigAndParent(); - void creatingProviderShouldSaveSettings(); - void creatingProviderShouldSaveGeneratedId(); - void creatingConfigWidgetShouldDelegate(); - void createConfigWidgetShouldNotCrashOnNull(); - void createProviderShouldNotCrashOnNull(); - void createProviderShouldReplaceProviderIfExists(); - void createProviderShouldRegisterProvider(); - void forgetProviderShouldUnregisterProvider(); - void forgetProviderShouldForgetConfig(); - void forgetProviderShouldHangleInvalidId(); - void forgetProviderShouldNotCauseOtherProvidersToBeForgotten(); - void managerShouldHandleMultipleProviders(); -}; - -#endif // TEST_IMPORTER_MANAGER diff --git a/amarok/tests/importers/TestImporterProvider.cpp b/amarok/tests/importers/TestImporterProvider.cpp deleted file mode 100644 index c7a99814..00000000 --- a/amarok/tests/importers/TestImporterProvider.cpp +++ /dev/null @@ -1,135 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2013 Konrad Zemek * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "TestImporterProvider.h" - -#include "core/support/Amarok.h" -#include "core/support/Components.h" - -#include - -QTEST_KDEMAIN_CORE( TestImporterProvider ) - -using namespace ::testing; - -void -TestImporterProvider::constructorShouldSetConfigAndManager() -{ - QVariantMap cfg; - cfg["nanananana"] = QString( "Batman" ); - MockProvider provider( cfg, m_mockManager ); - - QVERIFY( provider.config().contains( QString( "nanananana" ) ) ); - QCOMPARE( provider.manager(), m_mockManager ); -} - -void -TestImporterProvider::constructorShouldSetUidIfNotSet() -{ - QVERIFY( !MockProvider( QVariantMap(), 0 ).id().isEmpty() ); -} - -void -TestImporterProvider::idShouldReturnConfiguredId() -{ - QVariantMap cfg; - cfg["uid"] = QString( "Joker" ); - - QCOMPARE( MockProvider( cfg, 0 ).config(), cfg ); -} - -void -TestImporterProvider::descriptionShouldDelegateToManager() -{ - EXPECT_CALL( *m_mockManager, description() ).WillOnce( Return( QString( "Ivy" ) ) ); - QCOMPARE( m_mockProvider->description(), QString( "Ivy" ) ); -} - -void -TestImporterProvider::iconShouldDelegateToManager() -{ - EXPECT_CALL( *m_mockManager, icon() ).WillOnce( Return( KIcon( "amarok" ) ) ); - QCOMPARE( m_mockProvider->icon().name(), KIcon( "amarok" ).name() ); -} - -void -TestImporterProvider::nameShouldReturnConfiguredName() -{ - QVariantMap cfg; - cfg["uid"] = QString( "Bane" ); - cfg["name"] = QString( "Ra's" ); - MockProvider provider( cfg, m_mockManager ); - - QCOMPARE( provider.prettyName(), QString( "Ra's" ) ); -} - -void -TestImporterProvider::nameShouldNotCrashIfNameIsNotConfigured() -{ - QVariantMap cfg; - cfg["uid"] = QString( "TwoFace" ); - MockProvider provider( cfg, m_mockManager ); - - QCOMPARE( provider.prettyName(), QString() ); -} - -void -TestImporterProvider::isConfigurableShouldReturnTrue() -{ - QVERIFY( m_mockProvider->isConfigurable() ); -} - -void -TestImporterProvider::configWidgetShouldDelegateToManager() -{ - StatSyncing::ProviderConfigWidget *widget = 0; - EXPECT_CALL( *m_mockManager, configWidget( Eq(m_mockProvider->config()) ) ) - .WillOnce( Return( widget ) ); - QCOMPARE( m_mockProvider->configWidget(), widget ); -} - -void -TestImporterProvider::reconfigureShouldEmitSignal() -{ - QVariantMap cfg = m_mockProvider->config(); - cfg["customField"] = QString( "Selena" ); - - QSignalSpy spy( m_mockProvider, SIGNAL(reconfigurationRequested(QVariantMap)) ); - m_mockProvider->reconfigure( cfg ); - - QCOMPARE( spy.count(), 1 ); - QCOMPARE( spy.takeFirst().at( 0 ).toMap(), cfg ); -} - -void -TestImporterProvider::reconfigureShouldNotEmitSignalOnDifferentUid() -{ - QVariantMap cfg; - cfg["uid"] = "Different"; - - QSignalSpy spy( m_mockProvider, SIGNAL(reconfigurationRequested(QVariantMap)) ); - m_mockProvider->reconfigure( cfg ); - - QCOMPARE( spy.count(), 0 ); -} - -void -TestImporterProvider::defaultPreferenceShouldReturnNoByDefault() -{ - QCOMPARE( m_mockProvider->defaultPreference(), StatSyncing::Provider::NoByDefault ); -} - -#include "moc_TestImporterProvider.cpp" diff --git a/amarok/tests/importers/TestImporterProvider.h b/amarok/tests/importers/TestImporterProvider.h deleted file mode 100644 index 1cc476e6..00000000 --- a/amarok/tests/importers/TestImporterProvider.h +++ /dev/null @@ -1,41 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2013 Konrad Zemek * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef TEST_IMPORTER_MANAGER -#define TEST_IMPORTER_MANAGER - -#include "ImporterMocks.h" - -class TestImporterProvider : public ImporterMocks -{ - Q_OBJECT - -private slots: - void constructorShouldSetConfigAndManager(); - void constructorShouldSetUidIfNotSet(); - void idShouldReturnConfiguredId(); - void descriptionShouldDelegateToManager(); - void iconShouldDelegateToManager(); - void nameShouldReturnConfiguredName(); - void nameShouldNotCrashIfNameIsNotConfigured(); - void isConfigurableShouldReturnTrue(); - void configWidgetShouldDelegateToManager(); - void reconfigureShouldEmitSignal(); - void reconfigureShouldNotEmitSignalOnDifferentUid(); - void defaultPreferenceShouldReturnNoByDefault(); -}; - -#endif // TEST_IMPORTER_MANAGER diff --git a/amarok/tests/importers/TestRhythmboxImporter.cpp b/amarok/tests/importers/TestRhythmboxImporter.cpp deleted file mode 100644 index d5f166bc..00000000 --- a/amarok/tests/importers/TestRhythmboxImporter.cpp +++ /dev/null @@ -1,109 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2013 Konrad Zemek * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "TestRhythmboxImporter.h" - -#include "MetaValues.h" -#include "importers/rhythmbox/RhythmboxConfigWidget.h" -#include "importers/rhythmbox/RhythmboxProvider.h" - -#include - -QTEST_KDEMAIN( TestRhythmboxImporter, GUI ) - -using namespace StatSyncing; - -ProviderPtr -TestRhythmboxImporter::getProvider() -{ - QVariantMap cfg = RhythmboxConfigWidget( QVariantMap() ).config(); - cfg.insert( "dbPath", QApplication::applicationDirPath() - + "/importers_files/rhythmdb.xml" ); - - return ProviderPtr( new RhythmboxProvider( cfg, 0 ) ); -} - -ProviderPtr -TestRhythmboxImporter::getWritableProvider() -{ - QDir base( QCoreApplication::applicationDirPath() ); - base.mkpath( "importers_tmp" ); - - const QString dst = base.filePath( "importers_tmp/rhythmdb.xml" ); - QFile( dst ).remove(); - QFile( base.filePath( "importers_files/rhythmdb.xml" ) ).copy( dst ); - - QVariantMap cfg = RhythmboxConfigWidget( QVariantMap() ).config(); - cfg.insert( "dbPath", dst ); - - return ProviderPtr( new RhythmboxProvider( cfg, 0 ) ); -} - -qint64 -TestRhythmboxImporter::reliableStatistics() const -{ - return Meta::valLastPlayed | Meta::valRating | Meta::valPlaycount; -} - -bool -TestRhythmboxImporter::hasOddRatings() const -{ - return false; -} - -void -TestRhythmboxImporter::init() -{ - m_cfg = RhythmboxConfigWidget( QVariantMap() ).config(); -} - -void -TestRhythmboxImporter::providerShouldHandleNonexistentDbFile() -{ - m_cfg.insert( "dbPath", "/wdawd\\wdadwgd/das4hutyf" ); - - RhythmboxProvider provider( m_cfg, 0 ); - QVERIFY( provider.artists().isEmpty() ); -} - -void -TestRhythmboxImporter::providerShouldHandleInvalidDbFile() -{ - m_cfg.insert( "dbPath", QApplication::applicationFilePath() ); - - RhythmboxProvider provider( m_cfg, 0 ); - QVERIFY( provider.artists().isEmpty() ); -} - -void -TestRhythmboxImporter::providerShouldHandleErroneousConfigValues() -{ - m_cfg.insert( "dbPath", "\\wd%aw@d/sdsd2'vodk0-=$$" ); - m_cfg.insert( "name", QColor( Qt::white ) ); - - RhythmboxProvider provider( m_cfg, 0 ); - QVERIFY( provider.artists().isEmpty() ); -} - -void -TestRhythmboxImporter::providerShouldHandleIllFormedDbFile() -{ - m_cfg.insert( "dbPath", QApplication::applicationDirPath() - + "/importers_files/illFormedLibrary.xml" ); - - RhythmboxProvider provider( m_cfg, 0 ); - QVERIFY( provider.artistTracks( "NonSuch" ).empty() ); -} diff --git a/amarok/tests/importers/TestRhythmboxImporter.h b/amarok/tests/importers/TestRhythmboxImporter.h deleted file mode 100644 index 0c557990..00000000 --- a/amarok/tests/importers/TestRhythmboxImporter.h +++ /dev/null @@ -1,46 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2013 Konrad Zemek * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef TEST_RHYTHMBOX_IMPORTER -#define TEST_RHYTHMBOX_IMPORTER - -#include "TestImporterBase.h" - -#include - -class TestRhythmboxImporter : public TestImporterBase -{ - Q_OBJECT - -protected: - StatSyncing::ProviderPtr getProvider(); - StatSyncing::ProviderPtr getWritableProvider(); - qint64 reliableStatistics() const; - bool hasOddRatings() const; - -private: - QVariantMap m_cfg; - -private slots: - void init(); - - void providerShouldHandleNonexistentDbFile(); - void providerShouldHandleInvalidDbFile(); - void providerShouldHandleErroneousConfigValues(); - void providerShouldHandleIllFormedDbFile(); -}; - -#endif // TEST_RHYTHMBOX_IMPORTER diff --git a/amarok/tests/importers/TestSimpleImporterConfigWidget.cpp b/amarok/tests/importers/TestSimpleImporterConfigWidget.cpp deleted file mode 100644 index 2f6ac3a7..00000000 --- a/amarok/tests/importers/TestSimpleImporterConfigWidget.cpp +++ /dev/null @@ -1,249 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2013 Konrad Zemek * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "TestSimpleImporterConfigWidget.h" - -#include "importers/SimpleImporterConfigWidget.h" - -#include -#include -#include -#include - -#include - -QTEST_KDEMAIN( TestSimpleImporterConfigWidget, GUI ) - -using namespace StatSyncing; - -void -TestSimpleImporterConfigWidget::constructorShouldCreateTargetNameRow() -{ - SimpleImporterConfigWidget widget( "testTargetName", QVariantMap() ); - - const QLabel *label = 0; - const QLineEdit *field = 0; - - foreach( const QObject *obj, widget.children() ) - { - if( qobject_cast( obj ) ) - label = qobject_cast( obj ); - else if( qobject_cast( obj ) ) - field = qobject_cast( obj ); - } - - QVERIFY( label ); - QVERIFY( field ); - - QVERIFY( !label->text().isEmpty() ); - QCOMPARE( label->buddy(), field ); -} - -void -TestSimpleImporterConfigWidget::targetNameShouldBeSetToDefaultValue() -{ - const QString targetName = "testTargetName"; - SimpleImporterConfigWidget widget( targetName, QVariantMap() ); - - const QLineEdit *field = 0; - foreach( const QObject *obj, widget.children() ) - if( qobject_cast( obj ) ) - field = qobject_cast( obj ); - - QVERIFY( field ); - QCOMPARE( field->text(), targetName ); -} - -void -TestSimpleImporterConfigWidget::targetNameShouldBeSetToConfigValueIfExists() -{ - const QString targetName = "nameOverride"; - - QVariantMap cfg; - cfg.insert( "name", targetName ); - - SimpleImporterConfigWidget widget( "testTargetName", cfg ); - - const QLineEdit *field = 0; - foreach( const QObject *obj, widget.children() ) - if( qobject_cast( obj ) ) - field = qobject_cast( obj ); - - QVERIFY( field ); - QCOMPARE( field->text(), targetName ); -} - -void -TestSimpleImporterConfigWidget::addFieldShouldTakeFieldOwnership() -{ - QPointer lineEdit( new QLineEdit() ); - - { - SimpleImporterConfigWidget widget( "testTargetName", QVariantMap() ); - widget.addField( "configVal", "label", lineEdit.data(), "text" ); - - QVERIFY( !lineEdit.isNull() ); - } - - QVERIFY( lineEdit.isNull() ); -} - -void -TestSimpleImporterConfigWidget::addFieldShouldAddNewRow() -{ - SimpleImporterConfigWidget widget( "testTargetName", QVariantMap() ); - - QWidget *field = new QLineEdit; - widget.addField( "configVal", "testLabel", field, "text" ); - - bool foundField = false; - bool foundLabel = false; - - foreach( const QObject *obj, widget.children() ) - { - if( obj == field ) - foundField = true; - else if( const QLabel *candidate = qobject_cast( obj ) ) - if( candidate->text() == "testLabel" ) - foundLabel = true; - } - - QVERIFY( foundField ); - QVERIFY( foundLabel ); -} - -void -TestSimpleImporterConfigWidget::addFieldShouldAssociateLabelWithField() -{ - SimpleImporterConfigWidget widget( "testTargetName", QVariantMap() ); - - QWidget *field = new QLineEdit; - widget.addField( "configVal", "testLabel", field, "text" ); - - const QLabel *label = 0; - foreach( const QObject *obj, widget.children() ) - if( const QLabel *candidate = qobject_cast( obj ) ) - if( candidate->text() == "testLabel" ) - label = candidate; - - QVERIFY( label ); - QCOMPARE( label->buddy(), field ); -} - -void -TestSimpleImporterConfigWidget::addFieldShouldNotBreakOnNullField() -{ - SimpleImporterConfigWidget widget( "testTargetName", QVariantMap() ); - widget.addField( "configVal", "testLabel", 0, "text" ); -} - -void -TestSimpleImporterConfigWidget::addedFieldShouldNotModifyFieldValueIfConfigDoesNotExist() -{ - SimpleImporterConfigWidget widget( "testTargetName", QVariantMap() ); - - const QString value = "myValue"; - QLineEdit *field = new QLineEdit( value ); - widget.addField( "configVal", "testLabel", field, "text" ); - - QCOMPARE( field->text(), value ); -} - -void -TestSimpleImporterConfigWidget::addedFieldShouldBeSetToConfigValueIfExists() -{ - const QString configName = "configVal"; - const QString value = "myValue"; - - QVariantMap cfg; - cfg.insert( configName, value ); - SimpleImporterConfigWidget widget( "testTargetName", cfg ); - - QLineEdit *field = new QLineEdit( "overrideMe" ); - widget.addField( configName, "testLabel", field, "text" ); - - QCOMPARE( field->text(), value ); -} - -void -TestSimpleImporterConfigWidget::addedFieldShouldNotBreakOnValueSetIfPropertyDoesNotExist() -{ - const QString configName = "configVal"; - - QVariantMap cfg; - cfg.insert( configName, "value" ); - SimpleImporterConfigWidget widget( "testTargetName", cfg ); - - widget.addField( configName, "testLabel", new QLineEdit, "There's No Such Property" ); -} - -void -TestSimpleImporterConfigWidget::configShouldContainName() -{ - const QString name = "testTargetName"; - SimpleImporterConfigWidget widget( name, QVariantMap() ); - - QCOMPARE( widget.config().value( "name" ).toString(), name ); -} - -void -TestSimpleImporterConfigWidget::configShouldNotBreakOnNullField() -{ - const QString configName = "configVal"; - - SimpleImporterConfigWidget widget( "testTargetName", QVariantMap() ); - widget.addField( configName, "testLabel", 0, "text" ); - - QVERIFY( widget.config().value( configName ).toString().isEmpty() ); -} - -void -TestSimpleImporterConfigWidget::configShouldContainAddedFieldsValues() -{ - SimpleImporterConfigWidget widget( "testTargetName", QVariantMap() ); - - QLineEdit *lineEdit = new QLineEdit; - lineEdit->setText( "textValue" ); - - QSpinBox *spinBox = new QSpinBox; - spinBox->setValue( 57 ); - - QComboBox *comboBox = new QComboBox; - comboBox->insertItem( 0, "item1" ); - comboBox->insertItem( 1, "item2" ); - comboBox->insertItem( 2, "item3" ); - comboBox->setCurrentIndex( 1 ); - - widget.addField( "text", "text", lineEdit, "text" ); - widget.addField( "int", "int", spinBox, "value" ); - widget.addField( "combo", "combo", comboBox, "currentText" ); - - const QVariantMap cfg = widget.config(); - QCOMPARE( cfg.value( "text" ).toString(), QString( "textValue" ) ); - QCOMPARE( cfg.value( "int" ).toInt(), 57 ); - QCOMPARE( cfg.value( "combo" ).toString(), QString( "item2" ) ); -} - -void -TestSimpleImporterConfigWidget::configShouldNotBreakOnNonexistentProperty() -{ - const QString configName = "configName"; - - SimpleImporterConfigWidget widget( "testTargetName", QVariantMap() ); - widget.addField( configName, "label", new QLineEdit, "No property" ); - - QVERIFY( widget.config().value( configName ).toString().isEmpty() ); -} diff --git a/amarok/tests/importers/TestSimpleImporterConfigWidget.h b/amarok/tests/importers/TestSimpleImporterConfigWidget.h deleted file mode 100644 index dcfab7a1..00000000 --- a/amarok/tests/importers/TestSimpleImporterConfigWidget.h +++ /dev/null @@ -1,46 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2013 Konrad Zemek * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef TEST_SIMPLE_IMPORTER_CONFIG_WIDGET -#define TEST_SIMPLE_IMPORTER_CONFIG_WIDGET - -#include - -class TestSimpleImporterConfigWidget : public QObject -{ - Q_OBJECT - -private slots: - void constructorShouldCreateTargetNameRow(); - void targetNameShouldBeSetToDefaultValue(); - void targetNameShouldBeSetToConfigValueIfExists(); - - void addFieldShouldTakeFieldOwnership(); - void addFieldShouldAddNewRow(); - void addFieldShouldAssociateLabelWithField(); - void addFieldShouldNotBreakOnNullField(); - - void addedFieldShouldNotModifyFieldValueIfConfigDoesNotExist(); - void addedFieldShouldBeSetToConfigValueIfExists(); - void addedFieldShouldNotBreakOnValueSetIfPropertyDoesNotExist(); - - void configShouldContainName(); - void configShouldNotBreakOnNullField(); - void configShouldContainAddedFieldsValues(); - void configShouldNotBreakOnNonexistentProperty(); -}; - -#endif // TEST_SIMPLE_IMPORTER_CONFIG_WIDGET diff --git a/amarok/tests/importers/files/README b/amarok/tests/importers/files/README deleted file mode 100644 index c0bb45bc..00000000 --- a/amarok/tests/importers/files/README +++ /dev/null @@ -1,17 +0,0 @@ -The files in this directory are used for importers' acceptance tests. -These are database files created by different media players, describing -music files found in ./testcollection directory. -Because the database files all describe the same set of tracks, -associated importers can be tested by the same set of generic tests -(contained in ../TestImporterBase.cpp). - -Music files contained in ./testcollection/ are only stored to ease -creation of database files for any future importing targets, or -modification of current database files in case of schema changes, etc. -These files are tiny (< the block size) mp3 tracks containing various -id3v2 tags. - -When creating a new database file, in addition to importing files -from ./testcollection/ , please follow the directions outlined in -../TestImporterBase.h - diff --git a/amarok/tests/importers/files/amarok2_mysqle/amarok/admin.MYD b/amarok/tests/importers/files/amarok2_mysqle/amarok/admin.MYD deleted file mode 100644 index d596e974..00000000 Binary files a/amarok/tests/importers/files/amarok2_mysqle/amarok/admin.MYD and /dev/null differ diff --git a/amarok/tests/importers/files/amarok2_mysqle/amarok/admin.MYI b/amarok/tests/importers/files/amarok2_mysqle/amarok/admin.MYI deleted file mode 100644 index 1f867a81..00000000 Binary files a/amarok/tests/importers/files/amarok2_mysqle/amarok/admin.MYI and /dev/null differ diff --git a/amarok/tests/importers/files/amarok2_mysqle/amarok/admin.frm b/amarok/tests/importers/files/amarok2_mysqle/amarok/admin.frm deleted file mode 100644 index 0e0089d3..00000000 Binary files a/amarok/tests/importers/files/amarok2_mysqle/amarok/admin.frm and /dev/null differ diff --git a/amarok/tests/importers/files/amarok2_mysqle/amarok/albums.MYD b/amarok/tests/importers/files/amarok2_mysqle/amarok/albums.MYD deleted file mode 100644 index 8f70d402..00000000 Binary files a/amarok/tests/importers/files/amarok2_mysqle/amarok/albums.MYD and /dev/null differ diff --git a/amarok/tests/importers/files/amarok2_mysqle/amarok/albums.MYI b/amarok/tests/importers/files/amarok2_mysqle/amarok/albums.MYI deleted file mode 100644 index eaccf7eb..00000000 Binary files a/amarok/tests/importers/files/amarok2_mysqle/amarok/albums.MYI and /dev/null differ diff --git a/amarok/tests/importers/files/amarok2_mysqle/amarok/albums.frm b/amarok/tests/importers/files/amarok2_mysqle/amarok/albums.frm deleted file mode 100644 index c09da824..00000000 Binary files a/amarok/tests/importers/files/amarok2_mysqle/amarok/albums.frm and /dev/null differ diff --git a/amarok/tests/importers/files/amarok2_mysqle/amarok/amazon.MYD b/amarok/tests/importers/files/amarok2_mysqle/amarok/amazon.MYD deleted file mode 100644 index e69de29b..00000000 diff --git a/amarok/tests/importers/files/amarok2_mysqle/amarok/amazon.MYI b/amarok/tests/importers/files/amarok2_mysqle/amarok/amazon.MYI deleted file mode 100644 index 5daf8baa..00000000 Binary files a/amarok/tests/importers/files/amarok2_mysqle/amarok/amazon.MYI and /dev/null differ diff --git a/amarok/tests/importers/files/amarok2_mysqle/amarok/amazon.frm b/amarok/tests/importers/files/amarok2_mysqle/amarok/amazon.frm deleted file mode 100644 index 598d6abe..00000000 Binary files a/amarok/tests/importers/files/amarok2_mysqle/amarok/amazon.frm and /dev/null differ diff --git a/amarok/tests/importers/files/amarok2_mysqle/amarok/artists.MYD b/amarok/tests/importers/files/amarok2_mysqle/amarok/artists.MYD deleted file mode 100644 index 156b3257..00000000 Binary files a/amarok/tests/importers/files/amarok2_mysqle/amarok/artists.MYD and /dev/null differ diff --git a/amarok/tests/importers/files/amarok2_mysqle/amarok/artists.MYI b/amarok/tests/importers/files/amarok2_mysqle/amarok/artists.MYI deleted file mode 100644 index 7aab477f..00000000 Binary files a/amarok/tests/importers/files/amarok2_mysqle/amarok/artists.MYI and /dev/null differ diff --git a/amarok/tests/importers/files/amarok2_mysqle/amarok/artists.frm b/amarok/tests/importers/files/amarok2_mysqle/amarok/artists.frm deleted file mode 100644 index 8f8baa96..00000000 Binary files a/amarok/tests/importers/files/amarok2_mysqle/amarok/artists.frm and /dev/null differ diff --git a/amarok/tests/importers/files/amarok2_mysqle/amarok/bookmark_groups.MYD b/amarok/tests/importers/files/amarok2_mysqle/amarok/bookmark_groups.MYD deleted file mode 100644 index e69de29b..00000000 diff --git a/amarok/tests/importers/files/amarok2_mysqle/amarok/bookmark_groups.MYI b/amarok/tests/importers/files/amarok2_mysqle/amarok/bookmark_groups.MYI deleted file mode 100644 index d55148cc..00000000 Binary files a/amarok/tests/importers/files/amarok2_mysqle/amarok/bookmark_groups.MYI and /dev/null differ diff --git a/amarok/tests/importers/files/amarok2_mysqle/amarok/bookmark_groups.frm b/amarok/tests/importers/files/amarok2_mysqle/amarok/bookmark_groups.frm deleted file mode 100644 index 01f7be34..00000000 Binary files a/amarok/tests/importers/files/amarok2_mysqle/amarok/bookmark_groups.frm and /dev/null differ diff --git a/amarok/tests/importers/files/amarok2_mysqle/amarok/bookmarks.MYD b/amarok/tests/importers/files/amarok2_mysqle/amarok/bookmarks.MYD deleted file mode 100644 index e69de29b..00000000 diff --git a/amarok/tests/importers/files/amarok2_mysqle/amarok/bookmarks.MYI b/amarok/tests/importers/files/amarok2_mysqle/amarok/bookmarks.MYI deleted file mode 100644 index c211d47e..00000000 Binary files a/amarok/tests/importers/files/amarok2_mysqle/amarok/bookmarks.MYI and /dev/null differ diff --git a/amarok/tests/importers/files/amarok2_mysqle/amarok/bookmarks.frm b/amarok/tests/importers/files/amarok2_mysqle/amarok/bookmarks.frm deleted file mode 100644 index 78c38999..00000000 Binary files a/amarok/tests/importers/files/amarok2_mysqle/amarok/bookmarks.frm and /dev/null differ diff --git a/amarok/tests/importers/files/amarok2_mysqle/amarok/composers.MYD b/amarok/tests/importers/files/amarok2_mysqle/amarok/composers.MYD deleted file mode 100644 index b03c1f30..00000000 Binary files a/amarok/tests/importers/files/amarok2_mysqle/amarok/composers.MYD and /dev/null differ diff --git a/amarok/tests/importers/files/amarok2_mysqle/amarok/composers.MYI b/amarok/tests/importers/files/amarok2_mysqle/amarok/composers.MYI deleted file mode 100644 index 0798619e..00000000 Binary files a/amarok/tests/importers/files/amarok2_mysqle/amarok/composers.MYI and /dev/null differ diff --git a/amarok/tests/importers/files/amarok2_mysqle/amarok/composers.frm b/amarok/tests/importers/files/amarok2_mysqle/amarok/composers.frm deleted file mode 100644 index 971f308f..00000000 Binary files a/amarok/tests/importers/files/amarok2_mysqle/amarok/composers.frm and /dev/null differ diff --git a/amarok/tests/importers/files/amarok2_mysqle/amarok/db.opt b/amarok/tests/importers/files/amarok2_mysqle/amarok/db.opt deleted file mode 100644 index 16221b85..00000000 --- a/amarok/tests/importers/files/amarok2_mysqle/amarok/db.opt +++ /dev/null @@ -1,2 +0,0 @@ -default-character-set=utf8 -default-collation=utf8_bin diff --git a/amarok/tests/importers/files/amarok2_mysqle/amarok/devices.MYD b/amarok/tests/importers/files/amarok2_mysqle/amarok/devices.MYD deleted file mode 100644 index a738c8f7..00000000 Binary files a/amarok/tests/importers/files/amarok2_mysqle/amarok/devices.MYD and /dev/null differ diff --git a/amarok/tests/importers/files/amarok2_mysqle/amarok/devices.MYI b/amarok/tests/importers/files/amarok2_mysqle/amarok/devices.MYI deleted file mode 100644 index 12e4b3db..00000000 Binary files a/amarok/tests/importers/files/amarok2_mysqle/amarok/devices.MYI and /dev/null differ diff --git a/amarok/tests/importers/files/amarok2_mysqle/amarok/devices.frm b/amarok/tests/importers/files/amarok2_mysqle/amarok/devices.frm deleted file mode 100644 index e1c908aa..00000000 Binary files a/amarok/tests/importers/files/amarok2_mysqle/amarok/devices.frm and /dev/null differ diff --git a/amarok/tests/importers/files/amarok2_mysqle/amarok/directories.MYD b/amarok/tests/importers/files/amarok2_mysqle/amarok/directories.MYD deleted file mode 100644 index 3a6d203e..00000000 Binary files a/amarok/tests/importers/files/amarok2_mysqle/amarok/directories.MYD and /dev/null differ diff --git a/amarok/tests/importers/files/amarok2_mysqle/amarok/directories.MYI b/amarok/tests/importers/files/amarok2_mysqle/amarok/directories.MYI deleted file mode 100644 index 4d79a399..00000000 Binary files a/amarok/tests/importers/files/amarok2_mysqle/amarok/directories.MYI and /dev/null differ diff --git a/amarok/tests/importers/files/amarok2_mysqle/amarok/directories.frm b/amarok/tests/importers/files/amarok2_mysqle/amarok/directories.frm deleted file mode 100644 index 134f81ac..00000000 Binary files a/amarok/tests/importers/files/amarok2_mysqle/amarok/directories.frm and /dev/null differ diff --git a/amarok/tests/importers/files/amarok2_mysqle/amarok/genres.MYD b/amarok/tests/importers/files/amarok2_mysqle/amarok/genres.MYD deleted file mode 100644 index 8a5fdf8e..00000000 Binary files a/amarok/tests/importers/files/amarok2_mysqle/amarok/genres.MYD and /dev/null differ diff --git a/amarok/tests/importers/files/amarok2_mysqle/amarok/genres.MYI b/amarok/tests/importers/files/amarok2_mysqle/amarok/genres.MYI deleted file mode 100644 index e10cae83..00000000 Binary files a/amarok/tests/importers/files/amarok2_mysqle/amarok/genres.MYI and /dev/null differ diff --git a/amarok/tests/importers/files/amarok2_mysqle/amarok/genres.frm b/amarok/tests/importers/files/amarok2_mysqle/amarok/genres.frm deleted file mode 100644 index 8c60c4d8..00000000 Binary files a/amarok/tests/importers/files/amarok2_mysqle/amarok/genres.frm and /dev/null differ diff --git a/amarok/tests/importers/files/amarok2_mysqle/amarok/images.MYD b/amarok/tests/importers/files/amarok2_mysqle/amarok/images.MYD deleted file mode 100644 index e69de29b..00000000 diff --git a/amarok/tests/importers/files/amarok2_mysqle/amarok/images.MYI b/amarok/tests/importers/files/amarok2_mysqle/amarok/images.MYI deleted file mode 100644 index dec5edb6..00000000 Binary files a/amarok/tests/importers/files/amarok2_mysqle/amarok/images.MYI and /dev/null differ diff --git a/amarok/tests/importers/files/amarok2_mysqle/amarok/images.frm b/amarok/tests/importers/files/amarok2_mysqle/amarok/images.frm deleted file mode 100644 index 92146e6e..00000000 Binary files a/amarok/tests/importers/files/amarok2_mysqle/amarok/images.frm and /dev/null differ diff --git a/amarok/tests/importers/files/amarok2_mysqle/amarok/labels.MYD b/amarok/tests/importers/files/amarok2_mysqle/amarok/labels.MYD deleted file mode 100644 index 79300488..00000000 Binary files a/amarok/tests/importers/files/amarok2_mysqle/amarok/labels.MYD and /dev/null differ diff --git a/amarok/tests/importers/files/amarok2_mysqle/amarok/labels.MYI b/amarok/tests/importers/files/amarok2_mysqle/amarok/labels.MYI deleted file mode 100644 index 5d518ea7..00000000 Binary files a/amarok/tests/importers/files/amarok2_mysqle/amarok/labels.MYI and /dev/null differ diff --git a/amarok/tests/importers/files/amarok2_mysqle/amarok/labels.frm b/amarok/tests/importers/files/amarok2_mysqle/amarok/labels.frm deleted file mode 100644 index 932592de..00000000 Binary files a/amarok/tests/importers/files/amarok2_mysqle/amarok/labels.frm and /dev/null differ diff --git a/amarok/tests/importers/files/amarok2_mysqle/amarok/lyrics.MYD b/amarok/tests/importers/files/amarok2_mysqle/amarok/lyrics.MYD deleted file mode 100644 index e69de29b..00000000 diff --git a/amarok/tests/importers/files/amarok2_mysqle/amarok/lyrics.MYI b/amarok/tests/importers/files/amarok2_mysqle/amarok/lyrics.MYI deleted file mode 100644 index 32f3c0b7..00000000 Binary files a/amarok/tests/importers/files/amarok2_mysqle/amarok/lyrics.MYI and /dev/null differ diff --git a/amarok/tests/importers/files/amarok2_mysqle/amarok/lyrics.frm b/amarok/tests/importers/files/amarok2_mysqle/amarok/lyrics.frm deleted file mode 100644 index 7e04fa02..00000000 Binary files a/amarok/tests/importers/files/amarok2_mysqle/amarok/lyrics.frm and /dev/null differ diff --git a/amarok/tests/importers/files/amarok2_mysqle/amarok/playlist_groups.MYD b/amarok/tests/importers/files/amarok2_mysqle/amarok/playlist_groups.MYD deleted file mode 100644 index e69de29b..00000000 diff --git a/amarok/tests/importers/files/amarok2_mysqle/amarok/playlist_groups.MYI b/amarok/tests/importers/files/amarok2_mysqle/amarok/playlist_groups.MYI deleted file mode 100644 index 2571bac7..00000000 Binary files a/amarok/tests/importers/files/amarok2_mysqle/amarok/playlist_groups.MYI and /dev/null differ diff --git a/amarok/tests/importers/files/amarok2_mysqle/amarok/playlist_groups.frm b/amarok/tests/importers/files/amarok2_mysqle/amarok/playlist_groups.frm deleted file mode 100644 index b160fe5d..00000000 Binary files a/amarok/tests/importers/files/amarok2_mysqle/amarok/playlist_groups.frm and /dev/null differ diff --git a/amarok/tests/importers/files/amarok2_mysqle/amarok/playlist_tracks.MYD b/amarok/tests/importers/files/amarok2_mysqle/amarok/playlist_tracks.MYD deleted file mode 100644 index e69de29b..00000000 diff --git a/amarok/tests/importers/files/amarok2_mysqle/amarok/playlist_tracks.MYI b/amarok/tests/importers/files/amarok2_mysqle/amarok/playlist_tracks.MYI deleted file mode 100644 index f2f04fe7..00000000 Binary files a/amarok/tests/importers/files/amarok2_mysqle/amarok/playlist_tracks.MYI and /dev/null differ diff --git a/amarok/tests/importers/files/amarok2_mysqle/amarok/playlist_tracks.frm b/amarok/tests/importers/files/amarok2_mysqle/amarok/playlist_tracks.frm deleted file mode 100644 index cf499a5b..00000000 Binary files a/amarok/tests/importers/files/amarok2_mysqle/amarok/playlist_tracks.frm and /dev/null differ diff --git a/amarok/tests/importers/files/amarok2_mysqle/amarok/playlists.MYD b/amarok/tests/importers/files/amarok2_mysqle/amarok/playlists.MYD deleted file mode 100644 index e69de29b..00000000 diff --git a/amarok/tests/importers/files/amarok2_mysqle/amarok/playlists.MYI b/amarok/tests/importers/files/amarok2_mysqle/amarok/playlists.MYI deleted file mode 100644 index 923a1651..00000000 Binary files a/amarok/tests/importers/files/amarok2_mysqle/amarok/playlists.MYI and /dev/null differ diff --git a/amarok/tests/importers/files/amarok2_mysqle/amarok/playlists.frm b/amarok/tests/importers/files/amarok2_mysqle/amarok/playlists.frm deleted file mode 100644 index 05123dac..00000000 Binary files a/amarok/tests/importers/files/amarok2_mysqle/amarok/playlists.frm and /dev/null differ diff --git a/amarok/tests/importers/files/amarok2_mysqle/amarok/podcastchannels.MYD b/amarok/tests/importers/files/amarok2_mysqle/amarok/podcastchannels.MYD deleted file mode 100644 index e69de29b..00000000 diff --git a/amarok/tests/importers/files/amarok2_mysqle/amarok/podcastchannels.MYI b/amarok/tests/importers/files/amarok2_mysqle/amarok/podcastchannels.MYI deleted file mode 100644 index 00aca245..00000000 Binary files a/amarok/tests/importers/files/amarok2_mysqle/amarok/podcastchannels.MYI and /dev/null differ diff --git a/amarok/tests/importers/files/amarok2_mysqle/amarok/podcastchannels.frm b/amarok/tests/importers/files/amarok2_mysqle/amarok/podcastchannels.frm deleted file mode 100644 index 595a0634..00000000 Binary files a/amarok/tests/importers/files/amarok2_mysqle/amarok/podcastchannels.frm and /dev/null differ diff --git a/amarok/tests/importers/files/amarok2_mysqle/amarok/podcastepisodes.MYD b/amarok/tests/importers/files/amarok2_mysqle/amarok/podcastepisodes.MYD deleted file mode 100644 index e69de29b..00000000 diff --git a/amarok/tests/importers/files/amarok2_mysqle/amarok/podcastepisodes.MYI b/amarok/tests/importers/files/amarok2_mysqle/amarok/podcastepisodes.MYI deleted file mode 100644 index c5992c1c..00000000 Binary files a/amarok/tests/importers/files/amarok2_mysqle/amarok/podcastepisodes.MYI and /dev/null differ diff --git a/amarok/tests/importers/files/amarok2_mysqle/amarok/podcastepisodes.frm b/amarok/tests/importers/files/amarok2_mysqle/amarok/podcastepisodes.frm deleted file mode 100644 index a3363631..00000000 Binary files a/amarok/tests/importers/files/amarok2_mysqle/amarok/podcastepisodes.frm and /dev/null differ diff --git a/amarok/tests/importers/files/amarok2_mysqle/amarok/statistics.MYD b/amarok/tests/importers/files/amarok2_mysqle/amarok/statistics.MYD deleted file mode 100644 index 37681165..00000000 Binary files a/amarok/tests/importers/files/amarok2_mysqle/amarok/statistics.MYD and /dev/null differ diff --git a/amarok/tests/importers/files/amarok2_mysqle/amarok/statistics.MYI b/amarok/tests/importers/files/amarok2_mysqle/amarok/statistics.MYI deleted file mode 100644 index 110793da..00000000 Binary files a/amarok/tests/importers/files/amarok2_mysqle/amarok/statistics.MYI and /dev/null differ diff --git a/amarok/tests/importers/files/amarok2_mysqle/amarok/statistics.frm b/amarok/tests/importers/files/amarok2_mysqle/amarok/statistics.frm deleted file mode 100644 index 0917e583..00000000 Binary files a/amarok/tests/importers/files/amarok2_mysqle/amarok/statistics.frm and /dev/null differ diff --git a/amarok/tests/importers/files/amarok2_mysqle/amarok/statistics_permanent.MYD b/amarok/tests/importers/files/amarok2_mysqle/amarok/statistics_permanent.MYD deleted file mode 100644 index e69de29b..00000000 diff --git a/amarok/tests/importers/files/amarok2_mysqle/amarok/statistics_permanent.MYI b/amarok/tests/importers/files/amarok2_mysqle/amarok/statistics_permanent.MYI deleted file mode 100644 index b0a4c3fd..00000000 Binary files a/amarok/tests/importers/files/amarok2_mysqle/amarok/statistics_permanent.MYI and /dev/null differ diff --git a/amarok/tests/importers/files/amarok2_mysqle/amarok/statistics_permanent.frm b/amarok/tests/importers/files/amarok2_mysqle/amarok/statistics_permanent.frm deleted file mode 100644 index 66af3ca1..00000000 Binary files a/amarok/tests/importers/files/amarok2_mysqle/amarok/statistics_permanent.frm and /dev/null differ diff --git a/amarok/tests/importers/files/amarok2_mysqle/amarok/statistics_tag.MYD b/amarok/tests/importers/files/amarok2_mysqle/amarok/statistics_tag.MYD deleted file mode 100644 index e69de29b..00000000 diff --git a/amarok/tests/importers/files/amarok2_mysqle/amarok/statistics_tag.MYI b/amarok/tests/importers/files/amarok2_mysqle/amarok/statistics_tag.MYI deleted file mode 100644 index 254bab55..00000000 Binary files a/amarok/tests/importers/files/amarok2_mysqle/amarok/statistics_tag.MYI and /dev/null differ diff --git a/amarok/tests/importers/files/amarok2_mysqle/amarok/statistics_tag.frm b/amarok/tests/importers/files/amarok2_mysqle/amarok/statistics_tag.frm deleted file mode 100644 index ce20f3bd..00000000 Binary files a/amarok/tests/importers/files/amarok2_mysqle/amarok/statistics_tag.frm and /dev/null differ diff --git a/amarok/tests/importers/files/amarok2_mysqle/amarok/tracks.MYD b/amarok/tests/importers/files/amarok2_mysqle/amarok/tracks.MYD deleted file mode 100644 index d8ce14a1..00000000 Binary files a/amarok/tests/importers/files/amarok2_mysqle/amarok/tracks.MYD and /dev/null differ diff --git a/amarok/tests/importers/files/amarok2_mysqle/amarok/tracks.MYI b/amarok/tests/importers/files/amarok2_mysqle/amarok/tracks.MYI deleted file mode 100644 index ea9a3ef3..00000000 Binary files a/amarok/tests/importers/files/amarok2_mysqle/amarok/tracks.MYI and /dev/null differ diff --git a/amarok/tests/importers/files/amarok2_mysqle/amarok/tracks.frm b/amarok/tests/importers/files/amarok2_mysqle/amarok/tracks.frm deleted file mode 100644 index 81358f67..00000000 Binary files a/amarok/tests/importers/files/amarok2_mysqle/amarok/tracks.frm and /dev/null differ diff --git a/amarok/tests/importers/files/amarok2_mysqle/amarok/urls.MYD b/amarok/tests/importers/files/amarok2_mysqle/amarok/urls.MYD deleted file mode 100644 index cb183de0..00000000 Binary files a/amarok/tests/importers/files/amarok2_mysqle/amarok/urls.MYD and /dev/null differ diff --git a/amarok/tests/importers/files/amarok2_mysqle/amarok/urls.MYI b/amarok/tests/importers/files/amarok2_mysqle/amarok/urls.MYI deleted file mode 100644 index 033fe494..00000000 Binary files a/amarok/tests/importers/files/amarok2_mysqle/amarok/urls.MYI and /dev/null differ diff --git a/amarok/tests/importers/files/amarok2_mysqle/amarok/urls.frm b/amarok/tests/importers/files/amarok2_mysqle/amarok/urls.frm deleted file mode 100644 index 405c28ee..00000000 Binary files a/amarok/tests/importers/files/amarok2_mysqle/amarok/urls.frm and /dev/null differ diff --git a/amarok/tests/importers/files/amarok2_mysqle/amarok/urls_labels.MYD b/amarok/tests/importers/files/amarok2_mysqle/amarok/urls_labels.MYD deleted file mode 100644 index ecd2b951..00000000 Binary files a/amarok/tests/importers/files/amarok2_mysqle/amarok/urls_labels.MYD and /dev/null differ diff --git a/amarok/tests/importers/files/amarok2_mysqle/amarok/urls_labels.MYI b/amarok/tests/importers/files/amarok2_mysqle/amarok/urls_labels.MYI deleted file mode 100644 index 5f6fb2a0..00000000 Binary files a/amarok/tests/importers/files/amarok2_mysqle/amarok/urls_labels.MYI and /dev/null differ diff --git a/amarok/tests/importers/files/amarok2_mysqle/amarok/urls_labels.frm b/amarok/tests/importers/files/amarok2_mysqle/amarok/urls_labels.frm deleted file mode 100644 index 1ef74d78..00000000 Binary files a/amarok/tests/importers/files/amarok2_mysqle/amarok/urls_labels.frm and /dev/null differ diff --git a/amarok/tests/importers/files/amarok2_mysqle/amarok/years.MYD b/amarok/tests/importers/files/amarok2_mysqle/amarok/years.MYD deleted file mode 100644 index 5f33385e..00000000 Binary files a/amarok/tests/importers/files/amarok2_mysqle/amarok/years.MYD and /dev/null differ diff --git a/amarok/tests/importers/files/amarok2_mysqle/amarok/years.MYI b/amarok/tests/importers/files/amarok2_mysqle/amarok/years.MYI deleted file mode 100644 index dc0c2a39..00000000 Binary files a/amarok/tests/importers/files/amarok2_mysqle/amarok/years.MYI and /dev/null differ diff --git a/amarok/tests/importers/files/amarok2_mysqle/amarok/years.frm b/amarok/tests/importers/files/amarok2_mysqle/amarok/years.frm deleted file mode 100644 index 5aac2725..00000000 Binary files a/amarok/tests/importers/files/amarok2_mysqle/amarok/years.frm and /dev/null differ diff --git a/amarok/tests/importers/files/amarok2_mysqle/aria_log.00000001 b/amarok/tests/importers/files/amarok2_mysqle/aria_log.00000001 deleted file mode 100644 index a4eaac38..00000000 Binary files a/amarok/tests/importers/files/amarok2_mysqle/aria_log.00000001 and /dev/null differ diff --git a/amarok/tests/importers/files/amarok2_mysqle/aria_log_control b/amarok/tests/importers/files/amarok2_mysqle/aria_log_control deleted file mode 100644 index 3b3442c2..00000000 Binary files a/amarok/tests/importers/files/amarok2_mysqle/aria_log_control and /dev/null differ diff --git a/amarok/tests/importers/files/amarok2_mysqle/mysql-bin.index b/amarok/tests/importers/files/amarok2_mysqle/mysql-bin.index deleted file mode 100644 index e69de29b..00000000 diff --git a/amarok/tests/importers/files/banshee.db b/amarok/tests/importers/files/banshee.db deleted file mode 100644 index a813b6e5..00000000 Binary files a/amarok/tests/importers/files/banshee.db and /dev/null differ diff --git a/amarok/tests/importers/files/clementine.db b/amarok/tests/importers/files/clementine.db deleted file mode 100644 index 2fa91c54..00000000 Binary files a/amarok/tests/importers/files/clementine.db and /dev/null differ diff --git a/amarok/tests/importers/files/collection.db b/amarok/tests/importers/files/collection.db deleted file mode 100644 index 588fa8b3..00000000 Binary files a/amarok/tests/importers/files/collection.db and /dev/null differ diff --git a/amarok/tests/importers/files/iTunes_Music_Library.xml b/amarok/tests/importers/files/iTunes_Music_Library.xml deleted file mode 100644 index c00ecd36..00000000 --- a/amarok/tests/importers/files/iTunes_Music_Library.xml +++ /dev/null @@ -1,2165 +0,0 @@ - - - - - Major Version1 - Minor Version1 - Date2013-09-02T15:29:20Z - Application Version11.0.4 - Features5 - Show Content Ratings - Music Folderfile://localhost/C:/Documents%20and%20Settings/Konrad/My%20Documents/My%20Music/iTunes/iTunes%20Media/ - Library Persistent ID16428B78086CAFA8 - Tracks - - 116 - - Track ID116 - NametiTle - ArtistcaseSensitiveTitle - Composercomposer - Albumalbum - KindMPEG audio file - Size2176 - Total Time216 - Disc Number1 - Track Number1 - Year2000 - Date Modified2013-09-02T14:59:23Z - Date Added2013-09-02T15:22:24Z - Bit Rate8 - Sample Rate8000 - Persistent ID9C4544E092B77348 - Track TypeFile - Locationfile://localhost/E:/testcollection/caseSensitiveTitle3.mp3 - File Folder Count-1 - Library Folder Count-1 - - 118 - - Track ID118 - Nametitle - ArtistutfComposer - Composer豈更車 - Albumalbum - KindMPEG audio file - Size2176 - Total Time216 - Disc Number1 - Track Number1 - Year2000 - Date Modified2013-09-02T14:59:23Z - Date Added2013-09-02T15:22:24Z - Bit Rate8 - Sample Rate8000 - Persistent ID410455F247B2741E - Track TypeFile - Locationfile://localhost/E:/testcollection/utfComposer.mp3 - File Folder Count-1 - Library Folder Count-1 - - 120 - - Track ID120 - Nametitle - ArtistcaseSensitiveartist - Composercomposer - Albumalbum - KindMPEG audio file - Size2176 - Total Time216 - Disc Number1 - Track Number1 - Year2000 - Date Modified2013-09-02T14:59:23Z - Date Added2013-09-02T15:22:24Z - Bit Rate8 - Sample Rate8000 - Persistent ID4F76B4B39B505439 - Track TypeFile - Locationfile://localhost/E:/testcollection/caseSensitiveArtist3.mp3 - File Folder Count-1 - Library Folder Count-1 - - 122 - - Track ID122 - Nametitle1 - ArtisttrimAlbum - Composercomposer - Albumalbum - KindMPEG audio file - Size2176 - Total Time216 - Disc Number1 - Track Number1 - Year2000 - Date Modified2013-09-02T14:59:23Z - Date Added2013-09-02T15:22:24Z - Bit Rate8 - Sample Rate8000 - Persistent IDC4C27279B7563A02 - Track TypeFile - Locationfile://localhost/E:/testcollection/trimAlbum1.mp3 - File Folder Count-1 - Library Folder Count-1 - - 124 - - Track ID124 - Nametitle0 - ArtisttestStatistics - Composercomposer - Albumalbum - KindMPEG audio file - Size2176 - Total Time216 - Disc Number1 - Track Number1 - Year2000 - Date Modified2013-09-02T14:59:23Z - Date Added2013-09-02T15:22:24Z - Bit Rate8 - Sample Rate8000 - Rating20 - Play Date UTC2013-09-02T12:43:01Z - Play Count20 - Album Rating60 - Album Rating Computed - Persistent ID310D1121DBB1D083 - Track TypeFile - Locationfile://localhost/E:/testcollection/testStatistics0.mp3 - File Folder Count-1 - Library Folder Count-1 - - 126 - - Track ID126 - Nametitle - Artistcasesensitiveartist - Composercomposer - Albumalbum - KindMPEG audio file - Size2176 - Total Time216 - Disc Number1 - Track Number1 - Year2000 - Date Modified2013-09-02T14:59:23Z - Date Added2013-09-02T15:22:24Z - Bit Rate8 - Sample Rate8000 - Persistent ID872D683092CF2F10 - Track TypeFile - Locationfile://localhost/E:/testcollection/caseSensitiveArtist2.mp3 - File Folder Count-1 - Library Folder Count-1 - - 128 - - Track ID128 - Nametitle - ArtistcaseSensitiveTitle - Composercomposer - Albumalbum - KindMPEG audio file - Size2176 - Total Time216 - Disc Number1 - Track Number1 - Year2000 - Date Modified2013-09-02T14:59:23Z - Date Added2013-09-02T15:22:24Z - Bit Rate8 - Sample Rate8000 - Persistent IDF57A1400408D8B55 - Track TypeFile - Locationfile://localhost/E:/testcollection/caseSensitiveTitle1.mp3 - File Folder Count-1 - Library Folder Count-1 - - 130 - - Track ID130 - Nametitle8 - ArtisttestStatistics - Composercomposer - Albumalbum - KindMPEG audio file - Size2176 - Total Time216 - Disc Number1 - Track Number1 - Year2000 - Date Modified2013-09-02T14:59:23Z - Date Added2013-09-02T15:22:24Z - Bit Rate8 - Sample Rate8000 - Rating100 - Play Date UTC2013-09-02T12:43:17Z - Play Count3 - Album Rating60 - Album Rating Computed - Persistent ID02F109EA912BAB55 - Track TypeFile - Locationfile://localhost/E:/testcollection/testStatistics8.mp3 - File Folder Count-1 - Library Folder Count-1 - - 132 - - Track ID132 - Nametitle - ArtistcaseSensitiveComposer - ComposercomPoser - Albumalbum - KindMPEG audio file - Size2176 - Total Time216 - Disc Number1 - Track Number1 - Year2000 - Date Modified2013-09-02T14:59:23Z - Date Added2013-09-02T15:22:24Z - Bit Rate8 - Sample Rate8000 - Persistent ID3A2577A9FDCE5B30 - Track TypeFile - Locationfile://localhost/E:/testcollection/caseSensitiveComposer3.mp3 - File Folder Count-1 - Library Folder Count-1 - - 134 - - Track ID134 - Nametitle9 - ArtisttestStatistics - Composercomposer - Albumalbum - KindMPEG audio file - Size2176 - Total Time216 - Disc Number1 - Track Number1 - Year2000 - Date Modified2013-09-02T14:59:23Z - Date Added2013-09-02T15:22:24Z - Bit Rate8 - Sample Rate8000 - Rating100 - Play Date UTC2013-09-02T12:43:19Z - Play Count2 - Album Rating60 - Album Rating Computed - Persistent IDDCA1B1B3822A3C37 - Track TypeFile - Locationfile://localhost/E:/testcollection/testStatistics9.mp3 - File Folder Count-1 - Library Folder Count-1 - - 136 - - Track ID136 - Nametitle - ArtistmultiWordAlbum - Composercomposer - Albumal b um - KindMPEG audio file - Size2048 - Total Time216 - Disc Number1 - Track Number1 - Year2000 - Date Modified2013-09-02T14:58:09Z - Date Added2013-09-02T15:22:24Z - Bit Rate8 - Sample Rate8000 - Persistent IDE65FC558CA37254A - Track TypeFile - Locationfile://localhost/E:/testcollection/multiWordAlbum.mp3 - File Folder Count-1 - Library Folder Count-1 - - 138 - - Track ID138 - Nametitle - ArtistutfAlbum - Composercomposer - Album賈滑串 - KindMPEG audio file - Size2048 - Total Time216 - Disc Number1 - Track Number1 - Year2000 - Date Modified2013-09-02T14:58:09Z - Date Added2013-09-02T15:22:24Z - Bit Rate8 - Sample Rate8000 - Persistent ID8BB83BA2541524DC - Track TypeFile - Locationfile://localhost/E:/testcollection/utfAlbum.mp3 - File Folder Count-1 - Library Folder Count-1 - - 140 - - Track ID140 - Nametitle3 - ArtisttrimTitle - Composercomposer - Albumalbum - KindMPEG audio file - Size2176 - Total Time216 - Disc Number1 - Track Number1 - Year2000 - Date Modified2013-09-02T14:59:23Z - Date Added2013-09-02T15:22:24Z - Bit Rate8 - Sample Rate8000 - Persistent ID974D0661D5521111 - Track TypeFile - Locationfile://localhost/E:/testcollection/trimTitle3.mp3 - File Folder Count-1 - Library Folder Count-1 - - 142 - - Track ID142 - Nametitle1 - ArtisttestStatisticsNotSet - Composercomposer - Albumalbum - KindMPEG audio file - Size2176 - Total Time216 - Disc Number1 - Track Number1 - Year2000 - Date Modified2013-09-02T14:59:23Z - Date Added2013-09-02T15:22:24Z - Bit Rate8 - Sample Rate8000 - Rating20 - Play Date UTC2013-09-02T12:43:03Z - Play Count15 - Album Rating60 - Album Rating Computed - Persistent IDAFB3F7B03639127A - Track TypeFile - Locationfile://localhost/E:/testcollection/testStatisticsNotSet1.mp3 - File Folder Count-1 - Library Folder Count-1 - - 144 - - Track ID144 - Nametitle0 - ArtisttestStatisticsNotSet - Composercomposer - Albumalbum - KindMPEG audio file - Size2176 - Total Time216 - Disc Number1 - Track Number1 - Year2000 - Date Modified2013-09-02T14:59:23Z - Date Added2013-09-02T15:22:24Z - Bit Rate8 - Sample Rate8000 - Album Rating60 - Album Rating Computed - Persistent IDE17AA29323D46DAC - Track TypeFile - Locationfile://localhost/E:/testcollection/testStatisticsNotSet0.mp3 - File Folder Count-1 - Library Folder Count-1 - - 146 - - Track ID146 - Nametitle3 - ArtisttestStatisticsNotSet - Composercomposer - Albumalbum - KindMPEG audio file - Size2176 - Total Time216 - Disc Number1 - Track Number1 - Year2000 - Date Modified2013-09-02T14:59:23Z - Date Added2013-09-02T15:22:24Z - Bit Rate8 - Sample Rate8000 - Play Date UTC2013-09-02T12:43:07Z - Play Count13 - Album Rating60 - Album Rating Computed - Persistent ID564482C866A43259 - Track TypeFile - Locationfile://localhost/E:/testcollection/testStatisticsNotSet3.mp3 - File Folder Count-1 - Library Folder Count-1 - - 148 - - Track ID148 - Nametitle6 - ArtisttestStatisticsNotSet - Composercomposer - Albumalbum - KindMPEG audio file - Size2176 - Total Time216 - Disc Number1 - Track Number1 - Year2000 - Date Modified2013-09-02T14:59:23Z - Date Added2013-09-02T15:22:24Z - Bit Rate8 - Sample Rate8000 - Play Count7 - Album Rating60 - Album Rating Computed - Persistent ID85BF17C2FB7200CF - Track TypeFile - Locationfile://localhost/E:/testcollection/testStatisticsNotSet6.mp3 - File Folder Count-1 - Library Folder Count-1 - - 150 - - Track ID150 - Nametitle2 - ArtisttrimTitle - Composercomposer - Albumalbum - KindMPEG audio file - Size2176 - Total Time216 - Disc Number1 - Track Number1 - Year2000 - Date Modified2013-09-02T14:59:23Z - Date Added2013-09-02T15:22:24Z - Bit Rate8 - Sample Rate8000 - Persistent ID61B53817E34E9B29 - Track TypeFile - Locationfile://localhost/E:/testcollection/trimTitle2.mp3 - File Folder Count-1 - Library Folder Count-1 - - 152 - - Track ID152 - Nametitle7 - ArtisttestStatisticsNotSet - Composercomposer - Albumalbum - KindMPEG audio file - Size2176 - Total Time216 - Disc Number1 - Track Number1 - Year2000 - Date Modified2013-09-02T14:59:23Z - Date Added2013-09-02T15:22:24Z - Bit Rate8 - Sample Rate8000 - Rating80 - Play Date UTC2013-09-02T12:43:15Z - Play Count5 - Album Rating60 - Album Rating Computed - Persistent ID6740FCCC0F8AB121 - Track TypeFile - Locationfile://localhost/E:/testcollection/testStatisticsNotSet7.mp3 - File Folder Count-1 - Library Folder Count-1 - - 154 - - Track ID154 - Nametitle2 - ArtisttrimComposer - Composercomposer - Albumalbum - KindMPEG audio file - Size2176 - Total Time216 - Disc Number1 - Track Number1 - Year2000 - Date Modified2013-09-02T14:59:23Z - Date Added2013-09-02T15:22:24Z - Bit Rate8 - Sample Rate8000 - Persistent ID7118F54A65FA31FA - Track TypeFile - Locationfile://localhost/E:/testcollection/trimComposer2.mp3 - File Folder Count-1 - Library Folder Count-1 - - 156 - - Track ID156 - Nametitle2 - ArtisttestStatisticsNotSet - Composercomposer - Albumalbum - KindMPEG audio file - Size2176 - Total Time216 - Disc Number1 - Track Number1 - Year2000 - Date Modified2013-09-02T14:59:23Z - Date Added2013-09-02T15:22:24Z - Bit Rate8 - Sample Rate8000 - Rating40 - Play Count14 - Album Rating60 - Album Rating Computed - Persistent ID359EBF1851185CFB - Track TypeFile - Locationfile://localhost/E:/testcollection/testStatisticsNotSet2.mp3 - File Folder Count-1 - Library Folder Count-1 - - 158 - - Track ID158 - Nametitle - Artistmulti Word Artist - Composercomposer - Albumalbum - KindMPEG audio file - Size2176 - Total Time216 - Disc Number1 - Track Number1 - Year2000 - Date Modified2013-09-02T14:59:23Z - Date Added2013-09-02T15:22:24Z - Bit Rate8 - Sample Rate8000 - Persistent ID413668C3831F9C2C - Track TypeFile - Locationfile://localhost/E:/testcollection/multiWordArtist.mp3 - File Folder Count-1 - Library Folder Count-1 - - 160 - - Track ID160 - Nametitle3 - ArtisttrimAlbum - Composercomposer - Albumalbum - KindMPEG audio file - Size2176 - Total Time216 - Disc Number1 - Track Number1 - Year2000 - Date Modified2013-09-02T14:59:23Z - Date Added2013-09-02T15:22:24Z - Bit Rate8 - Sample Rate8000 - Persistent ID4C7FBD31700F9A4E - Track TypeFile - Locationfile://localhost/E:/testcollection/trimAlbum3.mp3 - File Folder Count-1 - Library Folder Count-1 - - 162 - - Track ID162 - Nametitle3 - ArtisttrimComposer - Composercomposer - Albumalbum - KindMPEG audio file - Size2176 - Total Time216 - Disc Number1 - Track Number1 - Year2000 - Date Modified2013-09-02T14:59:23Z - Date Added2013-09-02T15:22:25Z - Bit Rate8 - Sample Rate8000 - Persistent ID048E7935566E891F - Track TypeFile - Locationfile://localhost/E:/testcollection/trimComposer3.mp3 - File Folder Count-1 - Library Folder Count-1 - - 164 - - Track ID164 - Nametitle4 - ArtisttestStatisticsNotSet - Composercomposer - Albumalbum - KindMPEG audio file - Size2176 - Total Time216 - Disc Number1 - Track Number1 - Year2000 - Date Modified2013-09-02T14:59:23Z - Date Added2013-09-02T15:22:25Z - Bit Rate8 - Sample Rate8000 - Rating60 - Album Rating60 - Album Rating Computed - Persistent IDA057EFC447490F91 - Track TypeFile - Locationfile://localhost/E:/testcollection/testStatisticsNotSet4.mp3 - File Folder Count-1 - Library Folder Count-1 - - 166 - - Track ID166 - NameTitle - ArtistcaseSensitiveTitle - Composercomposer - Albumalbum - KindMPEG audio file - Size2176 - Total Time216 - Disc Number1 - Track Number1 - Year2000 - Date Modified2013-09-02T14:59:23Z - Date Added2013-09-02T15:22:25Z - Bit Rate8 - Sample Rate8000 - Persistent ID8D4546409D4DB84E - Track TypeFile - Locationfile://localhost/E:/testcollection/caseSensitiveTitle2.mp3 - File Folder Count-1 - Library Folder Count-1 - - 168 - - Track ID168 - Name句龜龜 - ArtistutfTitle - Composercomposer - Albumalbum - KindMPEG audio file - Size2176 - Total Time216 - Disc Number1 - Track Number1 - Year2000 - Date Modified2013-09-02T14:59:23Z - Date Added2013-09-02T15:22:25Z - Bit Rate8 - Sample Rate8000 - Persistent ID20ECA6634A854A3A - Track TypeFile - Locationfile://localhost/E:/testcollection/utfTitle.mp3 - File Folder Count-1 - Library Folder Count-1 - - 170 - - Track ID170 - Nametitle - ArtistcomposerUnset - Albumalbum - KindMPEG audio file - Size2176 - Total Time216 - Disc Number1 - Track Number1 - Year2000 - Date Modified2013-09-02T14:59:23Z - Date Added2013-09-02T15:22:25Z - Bit Rate8 - Sample Rate8000 - Persistent IDAB28F650F3137E7E - Track TypeFile - Locationfile://localhost/E:/testcollection/composerUnset.mp3 - File Folder Count-1 - Library Folder Count-1 - - 172 - - Track ID172 - Nametitle - ArtistcaseSensitiveComposer - Composercomposer - Albumalbum - KindMPEG audio file - Size2176 - Total Time216 - Disc Number1 - Track Number1 - Year2000 - Date Modified2013-09-02T14:59:23Z - Date Added2013-09-02T15:22:25Z - Bit Rate8 - Sample Rate8000 - Persistent ID18F4C584EE4EE369 - Track TypeFile - Locationfile://localhost/E:/testcollection/caseSensitiveComposer1.mp3 - File Folder Count-1 - Library Folder Count-1 - - 174 - - Track ID174 - Nametitle3 - ArtisttestStatistics - Composercomposer - Albumalbum - KindMPEG audio file - Size2176 - Total Time216 - Disc Number1 - Track Number1 - Year2000 - Date Modified2013-09-02T14:59:23Z - Date Added2013-09-02T15:22:25Z - Bit Rate8 - Sample Rate8000 - Rating40 - Play Date UTC2013-09-02T12:43:07Z - Play Count13 - Album Rating60 - Album Rating Computed - Persistent IDA27AC4A0DABDF01A - Track TypeFile - Locationfile://localhost/E:/testcollection/testStatistics3.mp3 - File Folder Count-1 - Library Folder Count-1 - - 176 - - Track ID176 - Nametitle - ArtistcaseSensitiveAlbum - Composercomposer - Albumalbum - KindMPEG audio file - Size2176 - Total Time216 - Disc Number1 - Track Number1 - Year2000 - Date Modified2013-09-02T14:59:23Z - Date Added2013-09-02T15:22:25Z - Bit Rate8 - Sample Rate8000 - Persistent IDB81D1487AD4061FC - Track TypeFile - Locationfile://localhost/E:/testcollection/caseSensitiveAlbum1.mp3 - File Folder Count-1 - Library Folder Count-1 - - 178 - - Track ID178 - Nametitle9 - ArtisttestStatisticsNotSet - Composercomposer - Albumalbum - KindMPEG audio file - Size2176 - Total Time216 - Disc Number1 - Track Number1 - Year2000 - Date Modified2013-09-02T14:59:23Z - Date Added2013-09-02T15:22:25Z - Bit Rate8 - Sample Rate8000 - Play Date UTC2013-09-02T12:43:19Z - Play Count2 - Album Rating60 - Album Rating Computed - Persistent IDAC94F88145ED0B7E - Track TypeFile - Locationfile://localhost/E:/testcollection/testStatisticsNotSet9.mp3 - File Folder Count-1 - Library Folder Count-1 - - 180 - - Track ID180 - Nametitle1 - ArtisttestStatistics - Composercomposer - Albumalbum - KindMPEG audio file - Size2176 - Total Time216 - Disc Number1 - Track Number1 - Year2000 - Date Modified2013-09-02T14:59:23Z - Date Added2013-09-02T15:22:25Z - Bit Rate8 - Sample Rate8000 - Rating20 - Play Date UTC2013-09-02T12:43:03Z - Play Count15 - Album Rating60 - Album Rating Computed - Persistent ID0F0CFF42836492BD - Track TypeFile - Locationfile://localhost/E:/testcollection/testStatistics1.mp3 - File Folder Count-1 - Library Folder Count-1 - - 182 - - Track ID182 - Nametitle1 - ArtisttrimComposer - Composercomposer - Albumalbum - KindMPEG audio file - Size2176 - Total Time216 - Disc Number1 - Track Number1 - Year2000 - Date Modified2013-09-02T14:59:23Z - Date Added2013-09-02T15:22:25Z - Bit Rate8 - Sample Rate8000 - Persistent IDEBDFA6DBF5583054 - Track TypeFile - Locationfile://localhost/E:/testcollection/trimComposer1.mp3 - File Folder Count-1 - Library Folder Count-1 - - 184 - - Track ID184 - Nametitle5 - ArtisttestStatistics - Composercomposer - Albumalbum - KindMPEG audio file - Size2176 - Total Time216 - Disc Number1 - Track Number1 - Year2000 - Date Modified2013-09-02T14:59:23Z - Date Added2013-09-02T15:22:25Z - Bit Rate8 - Sample Rate8000 - Rating60 - Play Date UTC2013-09-02T12:43:11Z - Play Count10 - Album Rating60 - Album Rating Computed - Persistent ID8BD228EE500E23C6 - Track TypeFile - Locationfile://localhost/E:/testcollection/testStatistics5.mp3 - File Folder Count-1 - Library Folder Count-1 - - 186 - - Track ID186 - Nametitle3 - ArtisttrimArtist - Composercomposer - Albumalbum - KindMPEG audio file - Size2176 - Total Time216 - Disc Number1 - Track Number1 - Year2000 - Date Modified2013-09-02T14:59:23Z - Date Added2013-09-02T15:22:25Z - Bit Rate8 - Sample Rate8000 - Persistent IDD248FA28468B9DD1 - Track TypeFile - Locationfile://localhost/E:/testcollection/trimArtist3.mp3 - File Folder Count-1 - Library Folder Count-1 - - 188 - - Track ID188 - Nametitle - ArtisttrackUnset - Composercomposer - Albumalbum - KindMPEG audio file - Size2176 - Total Time216 - Disc Number1 - Year2000 - Date Modified2013-09-02T14:59:23Z - Date Added2013-09-02T15:22:25Z - Bit Rate8 - Sample Rate8000 - Persistent ID1FFF8E518949072A - Track TypeFile - Locationfile://localhost/E:/testcollection/trackUnset.mp3 - File Folder Count-1 - Library Folder Count-1 - - 190 - - Track ID190 - Nametitle - ArtistcaseSensitiveAlbum - Composercomposer - AlbumalBum - KindMPEG audio file - Size2048 - Total Time216 - Disc Number1 - Track Number1 - Year2000 - Date Modified2013-09-02T14:58:09Z - Date Added2013-09-02T15:22:25Z - Bit Rate8 - Sample Rate8000 - Persistent IDBCDBC923E4C2AE23 - Track TypeFile - Locationfile://localhost/E:/testcollection/caseSensitiveAlbum3.mp3 - File Folder Count-1 - Library Folder Count-1 - - 192 - - Track ID192 - Nametitle - ArtistcaseSensitiveAlbum - Composercomposer - AlbumAlbum - KindMPEG audio file - Size2048 - Total Time216 - Disc Number1 - Track Number1 - Year2000 - Date Modified2013-09-02T14:58:09Z - Date Added2013-09-02T15:22:25Z - Bit Rate8 - Sample Rate8000 - Persistent ID3D5E436DECDB9A71 - Track TypeFile - Locationfile://localhost/E:/testcollection/caseSensitiveAlbum2.mp3 - File Folder Count-1 - Library Folder Count-1 - - 194 - - Track ID194 - Nametitle - ArtistalbumUnset - Composercomposer - KindMPEG audio file - Size2048 - Total Time216 - Disc Number1 - Track Number1 - Year2000 - Date Modified2013-09-02T14:58:09Z - Date Added2013-09-02T15:22:25Z - Bit Rate8 - Sample Rate8000 - Persistent ID2682D6CCAB1DEA9A - Track TypeFile - Locationfile://localhost/E:/testcollection/albumUnset.mp3 - File Folder Count-1 - Library Folder Count-1 - - 196 - - Track ID196 - Nametitle1 - ArtisttrimTitle - Composercomposer - Albumalbum - KindMPEG audio file - Size2176 - Total Time216 - Disc Number1 - Track Number1 - Year2000 - Date Modified2013-09-02T14:59:23Z - Date Added2013-09-02T15:22:25Z - Bit Rate8 - Sample Rate8000 - Persistent IDB37C19B0DBC3CCA1 - Track TypeFile - Locationfile://localhost/E:/testcollection/trimTitle1.mp3 - File Folder Count-1 - Library Folder Count-1 - - 198 - - Track ID198 - Nametitle - Artistutf契金喇 - Composercomposer - Albumalbum - KindMPEG audio file - Size2176 - Total Time216 - Disc Number1 - Track Number1 - Year2000 - Date Modified2013-09-02T14:59:23Z - Date Added2013-09-02T15:22:25Z - Bit Rate8 - Sample Rate8000 - Persistent IDD7A3616513CBF735 - Track TypeFile - Locationfile://localhost/E:/testcollection/utfArtist.mp3 - File Folder Count-1 - Library Folder Count-1 - - 200 - - Track ID200 - Nametitle6 - ArtisttestStatistics - Composercomposer - Albumalbum - KindMPEG audio file - Size2176 - Total Time216 - Disc Number1 - Track Number1 - Year2000 - Date Modified2013-09-02T14:59:23Z - Date Added2013-09-02T15:22:25Z - Bit Rate8 - Sample Rate8000 - Rating80 - Play Date UTC2013-09-02T12:43:13Z - Play Count7 - Album Rating60 - Album Rating Computed - Persistent IDFAAB8DBCBA3187B6 - Track TypeFile - Locationfile://localhost/E:/testcollection/testStatistics6.mp3 - File Folder Count-1 - Library Folder Count-1 - - 202 - - Track ID202 - Nametitle2 - ArtisttrimAlbum - Composercomposer - Albumalbum - KindMPEG audio file - Size2176 - Total Time216 - Disc Number1 - Track Number1 - Year2000 - Date Modified2013-09-02T14:59:23Z - Date Added2013-09-02T15:22:25Z - Bit Rate8 - Sample Rate8000 - Persistent IDF3D5775B7C35FE2E - Track TypeFile - Locationfile://localhost/E:/testcollection/trimAlbum2.mp3 - File Folder Count-1 - Library Folder Count-1 - - 204 - - Track ID204 - Nametitle7 - ArtisttestStatistics - Composercomposer - Albumalbum - KindMPEG audio file - Size2176 - Total Time216 - Disc Number1 - Track Number1 - Year2000 - Date Modified2013-09-02T14:59:23Z - Date Added2013-09-02T15:22:25Z - Bit Rate8 - Sample Rate8000 - Rating80 - Play Date UTC2013-09-02T12:43:15Z - Play Count5 - Album Rating60 - Album Rating Computed - Persistent ID227AAAED879E849C - Track TypeFile - Locationfile://localhost/E:/testcollection/testStatistics7.mp3 - File Folder Count-1 - Library Folder Count-1 - - 206 - - Track ID206 - Nametitle2 - ArtisttestStatistics - Composercomposer - Albumalbum - KindMPEG audio file - Size2176 - Total Time216 - Disc Number1 - Track Number1 - Year2000 - Date Modified2013-09-02T14:59:23Z - Date Added2013-09-02T15:22:25Z - Bit Rate8 - Sample Rate8000 - Rating40 - Play Date UTC2013-09-02T12:43:05Z - Play Count14 - Album Rating60 - Album Rating Computed - Persistent IDD90761E0075E2144 - Track TypeFile - Locationfile://localhost/E:/testcollection/testStatistics2.mp3 - File Folder Count-1 - Library Folder Count-1 - - 208 - - Track ID208 - Nametitle - ArtistdiscUnset - Composercomposer - Albumalbum - KindMPEG audio file - Size2176 - Total Time216 - Track Number1 - Year2000 - Date Modified2013-09-02T14:59:23Z - Date Added2013-09-02T15:22:25Z - Bit Rate8 - Sample Rate8000 - Persistent ID75D999FB49869085 - Track TypeFile - Locationfile://localhost/E:/testcollection/discUnset.mp3 - File Folder Count-1 - Library Folder Count-1 - - 210 - - Track ID210 - Nametitle - ArtistmultiWordComposer - Composercom po ser - Albumalbum - KindMPEG audio file - Size2176 - Total Time216 - Disc Number1 - Track Number1 - Year2000 - Date Modified2013-09-02T14:59:23Z - Date Added2013-09-02T15:22:25Z - Bit Rate8 - Sample Rate8000 - Persistent IDF416FD4E792C7C6B - Track TypeFile - Locationfile://localhost/E:/testcollection/multiWordComposer.mp3 - File Folder Count-1 - Library Folder Count-1 - - 212 - - Track ID212 - Nametitle - ArtistyearUnset - Composercomposer - Albumalbum - KindMPEG audio file - Size2176 - Total Time216 - Disc Number1 - Track Number1 - Date Modified2013-09-02T14:59:23Z - Date Added2013-09-02T15:22:25Z - Bit Rate8 - Sample Rate8000 - Persistent ID15D669AE232ACE72 - Track TypeFile - Locationfile://localhost/E:/testcollection/yearUnset.mp3 - File Folder Count-1 - Library Folder Count-1 - - 214 - - Track ID214 - Nametitle1 - ArtisttrimArtist - Composercomposer - Albumalbum - KindMPEG audio file - Size2176 - Total Time216 - Disc Number1 - Track Number1 - Year2000 - Date Modified2013-09-02T14:59:23Z - Date Added2013-09-02T15:22:25Z - Bit Rate8 - Sample Rate8000 - Persistent IDC3F535D470DF1082 - Track TypeFile - Locationfile://localhost/E:/testcollection/trimArtist1.mp3 - File Folder Count-1 - Library Folder Count-1 - - 216 - - Track ID216 - Nameti tl e - ArtistmultiWordTitle - Composercomposer - Albumalbum - KindMPEG audio file - Size2176 - Total Time216 - Disc Number1 - Track Number1 - Year2000 - Date Modified2013-09-02T14:59:23Z - Date Added2013-09-02T15:22:25Z - Bit Rate8 - Sample Rate8000 - Persistent ID04B7CD0859D15BDD - Track TypeFile - Locationfile://localhost/E:/testcollection/multiWordTitle.mp3 - File Folder Count-1 - Library Folder Count-1 - - 218 - - Track ID218 - Nametitle5 - ArtisttestStatisticsNotSet - Composercomposer - Albumalbum - KindMPEG audio file - Size2176 - Total Time216 - Disc Number1 - Track Number1 - Year2000 - Date Modified2013-09-02T14:59:23Z - Date Added2013-09-02T15:22:25Z - Bit Rate8 - Sample Rate8000 - Rating60 - Play Date UTC2013-09-02T12:43:11Z - Play Count10 - Album Rating60 - Album Rating Computed - Persistent ID2D7623288F33DD38 - Track TypeFile - Locationfile://localhost/E:/testcollection/testStatisticsNotSet5.mp3 - File Folder Count-1 - Library Folder Count-1 - - 220 - - Track ID220 - Nametitle - ArtistcaseSensitiveArtist - Composercomposer - Albumalbum - KindMPEG audio file - Size2176 - Total Time216 - Disc Number1 - Track Number1 - Year2000 - Date Modified2013-09-02T14:59:23Z - Date Added2013-09-02T15:22:25Z - Bit Rate8 - Sample Rate8000 - Persistent ID2FCAB01EA3725FD0 - Track TypeFile - Locationfile://localhost/E:/testcollection/caseSensitiveArtist1.mp3 - File Folder Count-1 - Library Folder Count-1 - - 222 - - Track ID222 - Nametitle4 - ArtisttestStatistics - Composercomposer - Albumalbum - KindMPEG audio file - Size2176 - Total Time216 - Disc Number1 - Track Number1 - Year2000 - Date Modified2013-09-02T14:59:23Z - Date Added2013-09-02T15:22:25Z - Bit Rate8 - Sample Rate8000 - Rating60 - Play Date UTC2013-09-02T12:43:09Z - Play Count11 - Album Rating60 - Album Rating Computed - Persistent IDCC635B1EA661E29C - Track TypeFile - Locationfile://localhost/E:/testcollection/testStatistics4.mp3 - File Folder Count-1 - Library Folder Count-1 - - 224 - - Track ID224 - Nametitle2 - ArtisttrimArtist - Composercomposer - Albumalbum - KindMPEG audio file - Size2176 - Total Time216 - Disc Number1 - Track Number1 - Year2000 - Date Modified2013-09-02T14:59:23Z - Date Added2013-09-02T15:22:25Z - Bit Rate8 - Sample Rate8000 - Persistent IDB42F5B676CE1136D - Track TypeFile - Locationfile://localhost/E:/testcollection/trimArtist2.mp3 - File Folder Count-1 - Library Folder Count-1 - - 226 - - Track ID226 - Nametitle - ArtistcaseSensitiveComposer - ComposerComposer - Albumalbum - KindMPEG audio file - Size2176 - Total Time216 - Disc Number1 - Track Number1 - Year2000 - Date Modified2013-09-02T14:59:23Z - Date Added2013-09-02T15:22:25Z - Bit Rate8 - Sample Rate8000 - Persistent ID4D7DA3EC7BC180E7 - Track TypeFile - Locationfile://localhost/E:/testcollection/caseSensitiveComposer2.mp3 - File Folder Count-1 - Library Folder Count-1 - - 228 - - Track ID228 - Nametitle8 - ArtisttestStatisticsNotSet - Composercomposer - Albumalbum - KindMPEG audio file - Size2176 - Total Time216 - Disc Number1 - Track Number1 - Year2000 - Date Modified2013-09-02T14:59:23Z - Date Added2013-09-02T15:22:25Z - Bit Rate8 - Sample Rate8000 - Rating100 - Album Rating60 - Album Rating Computed - Persistent ID8F27E3D579B1E1E3 - Track TypeFile - Locationfile://localhost/E:/testcollection/testStatisticsNotSet8.mp3 - File Folder Count-1 - Library Folder Count-1 - - - Playlists - - - NameLibrary - Master - Playlist ID230 - Playlist Persistent ID58AA79A7B403AD56 - Visible - All Items - Playlist Items - - - Track ID194 - - - Track ID176 - - - Track ID190 - - - Track ID192 - - - Track ID120 - - - Track ID126 - - - Track ID220 - - - Track ID132 - - - Track ID172 - - - Track ID226 - - - Track ID116 - - - Track ID128 - - - Track ID166 - - - Track ID170 - - - Track ID208 - - - Track ID158 - - - Track ID136 - - - Track ID210 - - - Track ID216 - - - Track ID124 - - - Track ID180 - - - Track ID206 - - - Track ID174 - - - Track ID222 - - - Track ID184 - - - Track ID200 - - - Track ID204 - - - Track ID130 - - - Track ID134 - - - Track ID144 - - - Track ID142 - - - Track ID156 - - - Track ID146 - - - Track ID164 - - - Track ID218 - - - Track ID148 - - - Track ID152 - - - Track ID228 - - - Track ID178 - - - Track ID188 - - - Track ID122 - - - Track ID202 - - - Track ID160 - - - Track ID214 - - - Track ID224 - - - Track ID186 - - - Track ID182 - - - Track ID154 - - - Track ID162 - - - Track ID196 - - - Track ID150 - - - Track ID140 - - - Track ID138 - - - Track ID118 - - - Track ID168 - - - Track ID198 - - - Track ID212 - - - - - NameMusic - Playlist ID381 - Playlist Persistent ID0C0DCD261FA17D1B - Distinguished Kind4 - Music - All Items - Playlist Items - - - Track ID194 - - - Track ID176 - - - Track ID190 - - - Track ID192 - - - Track ID120 - - - Track ID126 - - - Track ID220 - - - Track ID132 - - - Track ID172 - - - Track ID226 - - - Track ID116 - - - Track ID128 - - - Track ID166 - - - Track ID170 - - - Track ID208 - - - Track ID158 - - - Track ID136 - - - Track ID210 - - - Track ID216 - - - Track ID124 - - - Track ID180 - - - Track ID206 - - - Track ID174 - - - Track ID222 - - - Track ID184 - - - Track ID200 - - - Track ID204 - - - Track ID130 - - - Track ID134 - - - Track ID144 - - - Track ID142 - - - Track ID156 - - - Track ID146 - - - Track ID164 - - - Track ID218 - - - Track ID148 - - - Track ID152 - - - Track ID228 - - - Track ID178 - - - Track ID188 - - - Track ID122 - - - Track ID202 - - - Track ID160 - - - Track ID214 - - - Track ID224 - - - Track ID186 - - - Track ID182 - - - Track ID154 - - - Track ID162 - - - Track ID196 - - - Track ID150 - - - Track ID140 - - - Track ID138 - - - Track ID118 - - - Track ID168 - - - Track ID198 - - - Track ID212 - - - - - NameMovies - Playlist ID441 - Playlist Persistent ID5C5B1D16B9E2AD4E - Distinguished Kind2 - Movies - All Items - - - NameTV Shows - Playlist ID444 - Playlist Persistent ID48F67A8CF036AF31 - Distinguished Kind3 - TV Shows - All Items - - - Name90’s Music - Playlist ID290 - Playlist Persistent IDC7893A49EE16332A - Distinguished Kind200 - All Items - Smart Info - - AQEAAwAAAAIAAAAZAAAAAAAAAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAA== - - Smart Criteria - - U0xzdAABAAEAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcAAAEAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABEAAAAAAAAB8YAAAAAAAAAAAAAAAAAAAAB - AAAAAAAAB88AAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQEA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABgFNMc3QAAQAB - AAAAAgAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA8AAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAARAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAB - AAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAPAAABAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEQAAAAAAAAAIAAAAAAAAAAA - AAAAAAAAAAEAAAAAAAAAIAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAA== - - - - NameClassical Music - Playlist ID368 - Playlist Persistent ID6696E6DE6401D610 - Distinguished Kind206 - All Items - Smart Info - - AQEAAwAAAAIAAAAZAAAAAAAAAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAA== - - Smart Criteria - - U0xzdAABAAEAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAQAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGAU0xzdAABAAEAAAACAAAAAQAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAADwAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAABEAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAB - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA8AAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAARAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAg - AAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEBAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABVxTTHN0AAEAAQAAABEAAAAB - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAACAEAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAABIAQwBsAGEAcwBzAGkAYwBhAGwAAAAIAQAAAQAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEABLAGwAYQBzAHMAaQBlAGsAAAAI - AQAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEgBD - AGwAYQBzAHMAaQBxAHUAZQAAAAgBAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAOAEsAbABhAHMAcwBpAGsAAAAIAQAAAQAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEABDAGwAYQBzAHMAaQBjAGEAAAAI - AQAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACjCv - MOkwtzDDMK8AAAAIAQAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAADgBDAGwA4QBzAGkAYwBhAAAACAEAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAASwBsAGEAcwBzAGkAcwBrAAAACAEAAAEAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAQwBsAOEAcwBz - AGkAYwBhAAAACAEAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAABIASwBsAGEAcwBzAGkAcwBrAHQAAAAIAQAAAQAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGAQaBDsEMARBBEEEOARHBDUEQQQ6BDAETwAA - AAgBAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAS - AEsAbABhAHMAeQBjAHoAbgBhAAAACAEAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAABIASwBsAGEAcwBzAGkAbgBlAG4AAAAIAQAAAQAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADABLAGwAYQBzAGkAawAA - AAgBAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAU - AEsAbABhAHMAcwB6AGkAawB1AHMAAAAIAQAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAFgBWAOEBfgBuAOEAIABoAHUAZABiAGEAAAAIAQAAAQAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgZDBkQGJwYz - BkoGQwZK - - - - NameMy Top Rated - Playlist ID293 - Playlist Persistent ID997D9D4371BACF41 - Distinguished Kind201 - All Items - Smart Info - - AQEAAwAAAAIAAAAZAAAAAAAAAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAA== - - Smart Criteria - - U0xzdAABAAEAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABkAAAAQAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABEAAAAAAAAADwAAAAAAAAAAAAAAAAAAAAB - AAAAAAAAADwAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAA= - - Playlist Items - - - Track ID200 - - - Track ID204 - - - Track ID130 - - - Track ID134 - - - Track ID152 - - - Track ID228 - - - - - NameRecently Added - Playlist ID308 - Playlist Persistent IDCD8CEBBEF1172C3A - Distinguished Kind204 - All Items - Smart Info - - AQEAAwAAAAIAAAAZAAAAAAAAAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAA== - - Smart Criteria - - U0xzdAABAAEAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAIAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABELa4tri2uLa7//////////gAAAAAACTqA - La4tri2uLa4AAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA5AgAAAQAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAARAAAAAAAAAAB - AAAAAAAAAAAAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAA - AAAAAAAA - - Playlist Items - - - Track ID194 - - - Track ID176 - - - Track ID190 - - - Track ID192 - - - Track ID120 - - - Track ID126 - - - Track ID220 - - - Track ID132 - - - Track ID172 - - - Track ID226 - - - Track ID116 - - - Track ID128 - - - Track ID166 - - - Track ID170 - - - Track ID208 - - - Track ID158 - - - Track ID136 - - - Track ID210 - - - Track ID216 - - - Track ID124 - - - Track ID180 - - - Track ID206 - - - Track ID174 - - - Track ID222 - - - Track ID184 - - - Track ID200 - - - Track ID204 - - - Track ID130 - - - Track ID134 - - - Track ID144 - - - Track ID142 - - - Track ID156 - - - Track ID146 - - - Track ID164 - - - Track ID218 - - - Track ID148 - - - Track ID152 - - - Track ID228 - - - Track ID178 - - - Track ID188 - - - Track ID122 - - - Track ID202 - - - Track ID160 - - - Track ID214 - - - Track ID224 - - - Track ID186 - - - Track ID182 - - - Track ID154 - - - Track ID162 - - - Track ID196 - - - Track ID150 - - - Track ID140 - - - Track ID138 - - - Track ID118 - - - Track ID168 - - - Track ID198 - - - Track ID212 - - - - - NameRecently Played - Playlist ID305 - Playlist Persistent ID366EB5723D65A254 - Distinguished Kind203 - All Items - Smart Info - - AQEAAwAAAAIAAAAZAAAAAAAAAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAA== - - Smart Criteria - - U0xzdAABAAEAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABcAAAIAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABELa4tri2uLa7//////////gAAAAAACTqA - La4tri2uLa4AAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA5AgAAAQAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAARAAAAAAAAAAB - AAAAAAAAAAAAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAA - AAAAAAAA - - - - NameTop 25 Most Played - Playlist ID302 - Playlist Persistent ID4A32BAEF5CDA7558 - Distinguished Kind202 - All Items - Smart Info - - AQEBAwAAABkAAAAZAAAAAAAAAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAA== - - Smart Criteria - - U0xzdAABAAEAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADkCAAABAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABEAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAB - AAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAWAAAAEAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAARAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAA - AAAAAAAA - - - - - diff --git a/amarok/tests/importers/files/illFormedLibrary.xml b/amarok/tests/importers/files/illFormedLibrary.xml deleted file mode 100644 index a277b9fc..00000000 --- a/amarok/tests/importers/files/illFormedLibrary.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/amarok/tests/importers/files/rhythmdb.xml b/amarok/tests/importers/files/rhythmdb.xml deleted file mode 100644 index 3a1adae1..00000000 --- a/amarok/tests/importers/files/rhythmdb.xml +++ /dev/null @@ -1,903 +0,0 @@ - - - - title1 - Nieznany - trimComposer - album - 1 - 1 - 2048 - file:///home/konrad/kde/src/amarok/tests/importers/files/testcollection/trimComposer1.mp3 - 1378127799 - 1378136869 - 8 - 0 - audio/mpeg - - - title2 - Nieznany - trimComposer - album - 1 - 1 - 2048 - file:///home/konrad/kde/src/amarok/tests/importers/files/testcollection/trimComposer2.mp3 - 1378127799 - 1378136869 - 8 - 0 - audio/mpeg - - - title3 - Nieznany - trimComposer - album - 1 - 1 - 2048 - file:///home/konrad/kde/src/amarok/tests/importers/files/testcollection/trimComposer3.mp3 - 1378127799 - 1378136869 - 8 - 0 - audio/mpeg - - - title - Nieznany - utf契金喇 - album - 1 - 1 - 2048 - file:///home/konrad/kde/src/amarok/tests/importers/files/testcollection/utfArtist.mp3 - 1378127503 - 1378136866 - 8 - 0 - audio/mpeg - - - title - Nieznany - caseSensitiveAlbum - alBum - 1 - 1 - 2048 - file:///home/konrad/kde/src/amarok/tests/importers/files/testcollection/caseSensitiveAlbum3.mp3 - 1378127085 - 1378136867 - 8 - 0 - audio/mpeg - - - title - Nieznany - caseSensitiveAlbum - Album - 1 - 1 - 2048 - file:///home/konrad/kde/src/amarok/tests/importers/files/testcollection/caseSensitiveAlbum2.mp3 - 1378127085 - 1378136867 - 8 - 0 - audio/mpeg - - - title - Nieznany - caseSensitiveAlbum - album - 1 - 1 - 2048 - file:///home/konrad/kde/src/amarok/tests/importers/files/testcollection/caseSensitiveAlbum1.mp3 - 1378127085 - 1378136867 - 8 - 0 - audio/mpeg - - - ti tl e - Nieznany - multiWordTitle - album - 1 - 1 - 2048 - file:///home/konrad/kde/src/amarok/tests/importers/files/testcollection/multiWordTitle.mp3 - 1378127570 - 1378136870 - 8 - 0 - audio/mpeg - - - title - Nieznany - casesensitiveartist - album - 1 - 1 - 2048 - file:///home/konrad/kde/src/amarok/tests/importers/files/testcollection/caseSensitiveArtist2.mp3 - 1378127001 - 1378136867 - 8 - 0 - audio/mpeg - - - title0 - Nieznany - testStatisticsNotSet - album - 1 - 1 - 2048 - file:///home/konrad/kde/src/amarok/tests/importers/files/testcollection/testStatisticsNotSet0.mp3 - 1378128039 - 1378136865 - 8 - 0 - audio/mpeg - - - title8 - Nieznany - testStatisticsNotSet - album - 1 - 1 - 2048 - file:///home/konrad/kde/src/amarok/tests/importers/files/testcollection/testStatisticsNotSet8.mp3 - 1378128039 - 1378136868 - 5 - 8 - 0 - audio/mpeg - - - title6 - Nieznany - testStatisticsNotSet - album - 1 - 1 - 2048 - file:///home/konrad/kde/src/amarok/tests/importers/files/testcollection/testStatisticsNotSet6.mp3 - 1378128039 - 1378136865 - 7 - 8 - 0 - audio/mpeg - - - title1 - Nieznany - testStatisticsNotSet - album - 1 - 1 - 2048 - file:///home/konrad/kde/src/amarok/tests/importers/files/testcollection/testStatisticsNotSet1.mp3 - 1378128039 - 1378136865 - 1 - 15 - 1378125783 - 8 - 0 - audio/mpeg - - - title9 - Nieznany - testStatisticsNotSet - album - 1 - 1 - 2048 - file:///home/konrad/kde/src/amarok/tests/importers/files/testcollection/testStatisticsNotSet9.mp3 - 1378128039 - 1378136868 - 2 - 1378125799 - 8 - 0 - audio/mpeg - - - title3 - Nieznany - testStatisticsNotSet - album - 1 - 1 - 2048 - file:///home/konrad/kde/src/amarok/tests/importers/files/testcollection/testStatisticsNotSet3.mp3 - 1378128039 - 1378136865 - 13 - 1378125787 - 8 - 0 - audio/mpeg - - - title4 - Nieznany - testStatisticsNotSet - album - 1 - 1 - 2048 - file:///home/konrad/kde/src/amarok/tests/importers/files/testcollection/testStatisticsNotSet4.mp3 - 1378128039 - 1378136865 - 3 - 8 - 0 - audio/mpeg - - - title7 - Nieznany - testStatisticsNotSet - album - 1 - 1 - 2048 - file:///home/konrad/kde/src/amarok/tests/importers/files/testcollection/testStatisticsNotSet7.mp3 - 1378128039 - 1378136868 - 4 - 5 - 1378125795 - 8 - 0 - audio/mpeg - - - title2 - Nieznany - testStatisticsNotSet - album - 1 - 1 - 2048 - file:///home/konrad/kde/src/amarok/tests/importers/files/testcollection/testStatisticsNotSet2.mp3 - 1378128039 - 1378136865 - 2 - 14 - 8 - 0 - audio/mpeg - - - title5 - Nieznany - testStatisticsNotSet - album - 1 - 1 - 2048 - file:///home/konrad/kde/src/amarok/tests/importers/files/testcollection/testStatisticsNotSet5.mp3 - 1378128039 - 1378136865 - 3 - 10 - 1378125791 - 8 - 0 - audio/mpeg - - - title - Nieznany - composerUnset - album - 1 - 1 - 2048 - file:///home/konrad/kde/src/amarok/tests/importers/files/testcollection/composerUnset.mp3 - 1378127842 - 1378136869 - 8 - 0 - audio/mpeg - - - title2 - Nieznany - trimAlbum - album - 1 - 1 - 2048 - file:///home/konrad/kde/src/amarok/tests/importers/files/testcollection/trimAlbum2.mp3 - 1378127799 - 1378136869 - 8 - 0 - audio/mpeg - - - title1 - Nieznany - trimAlbum - album - 1 - 1 - 2048 - file:///home/konrad/kde/src/amarok/tests/importers/files/testcollection/trimAlbum1.mp3 - 1378127799 - 1378136869 - 8 - 0 - audio/mpeg - - - title3 - Nieznany - trimAlbum - album - 1 - 1 - 2048 - file:///home/konrad/kde/src/amarok/tests/importers/files/testcollection/trimAlbum3.mp3 - 1378127799 - 1378136869 - 8 - 0 - audio/mpeg - - - title - Nieznany - caseSensitiveComposer - album - 1 - 1 - 2048 - file:///home/konrad/kde/src/amarok/tests/importers/files/testcollection/caseSensitiveComposer1.mp3 - 1378127185 - 1378136867 - 8 - 0 - audio/mpeg - - - title - Nieznany - caseSensitiveComposer - album - 1 - 1 - 2048 - file:///home/konrad/kde/src/amarok/tests/importers/files/testcollection/caseSensitiveComposer3.mp3 - 1378127185 - 1378136867 - 8 - 0 - audio/mpeg - - - title - Nieznany - caseSensitiveComposer - album - 1 - 1 - 2048 - file:///home/konrad/kde/src/amarok/tests/importers/files/testcollection/caseSensitiveComposer2.mp3 - 1378127185 - 1378136867 - 8 - 0 - audio/mpeg - - - 句龜龜 - Nieznany - utfTitle - album - 1 - 1 - 2048 - file:///home/konrad/kde/src/amarok/tests/importers/files/testcollection/utfTitle.mp3 - 1378127503 - 1378136866 - 8 - 0 - audio/mpeg - - - title - Nieznany - yearUnset - album - 1 - 1 - 2048 - file:///home/konrad/kde/src/amarok/tests/importers/files/testcollection/yearUnset.mp3 - 1378127862 - 1378136868 - 8 - 0 - audio/mpeg - - - title - Nieznany - albumUnset - 1 - 1 - 2048 - file:///home/konrad/kde/src/amarok/tests/importers/files/testcollection/albumUnset.mp3 - 1378127827 - 1378136869 - 8 - 0 - audio/mpeg - - - title1 - Nieznany - testStatistics - album - 1 - 1 - 2048 - file:///home/konrad/kde/src/amarok/tests/importers/files/testcollection/testStatistics1.mp3 - 1378128039 - 1378136868 - 1 - 15 - 1378125783 - 8 - 0 - audio/mpeg - - - title2 - Nieznany - testStatistics - album - 1 - 1 - 2048 - file:///home/konrad/kde/src/amarok/tests/importers/files/testcollection/testStatistics2.mp3 - 1378128039 - 1378136866 - 2 - 14 - 1378125785 - 8 - 0 - audio/mpeg - - - title5 - Nieznany - testStatistics - album - 1 - 1 - 2048 - file:///home/konrad/kde/src/amarok/tests/importers/files/testcollection/testStatistics5.mp3 - 1378128039 - 1378136866 - 3 - 10 - 1378125791 - 8 - 0 - audio/mpeg - - - title4 - Nieznany - testStatistics - album - 1 - 1 - 2048 - file:///home/konrad/kde/src/amarok/tests/importers/files/testcollection/testStatistics4.mp3 - 1378128039 - 1378136866 - 3 - 11 - 1378125789 - 8 - 0 - audio/mpeg - - - title0 - Nieznany - testStatistics - album - 1 - 1 - 2048 - file:///home/konrad/kde/src/amarok/tests/importers/files/testcollection/testStatistics0.mp3 - 1378128039 - 1378136868 - 1 - 20 - 1378125781 - 8 - 0 - audio/mpeg - - - title6 - Nieznany - testStatistics - album - 1 - 1 - 2048 - file:///home/konrad/kde/src/amarok/tests/importers/files/testcollection/testStatistics6.mp3 - 1378128039 - 1378136866 - 4 - 7 - 1378125793 - 8 - 0 - audio/mpeg - - - title7 - Nieznany - testStatistics - album - 1 - 1 - 2048 - file:///home/konrad/kde/src/amarok/tests/importers/files/testcollection/testStatistics7.mp3 - 1378128039 - 1378136866 - 4 - 5 - 1378125795 - 8 - 0 - audio/mpeg - - - title3 - Nieznany - testStatistics - album - 1 - 1 - 2048 - file:///home/konrad/kde/src/amarok/tests/importers/files/testcollection/testStatistics3.mp3 - 1378128039 - 1378125787 - 2 - 13 - 1378125787 - 8 - 0 - audio/mpeg - - - title8 - Nieznany - testStatistics - album - 1 - 1 - 2048 - file:///home/konrad/kde/src/amarok/tests/importers/files/testcollection/testStatistics8.mp3 - 1378128039 - 1378136866 - 5 - 3 - 1378125797 - 8 - 0 - audio/mpeg - - - title9 - Nieznany - testStatistics - album - 1 - 1 - 2048 - file:///home/konrad/kde/src/amarok/tests/importers/files/testcollection/testStatistics9.mp3 - 1378128039 - 1378136865 - 5 - 2 - 1378125799 - 8 - 0 - audio/mpeg - - - title - Nieznany - utfComposer - album - 1 - 1 - 2048 - file:///home/konrad/kde/src/amarok/tests/importers/files/testcollection/utfComposer.mp3 - 1378127503 - 1378136871 - 8 - 0 - audio/mpeg - - - title3 - Nieznany - trimArtist - album - 1 - 1 - 2048 - file:///home/konrad/kde/src/amarok/tests/importers/files/testcollection/trimArtist3.mp3 - 1378127709 - 1378136869 - 8 - 0 - audio/mpeg - - - title1 - Nieznany - trimArtist - album - 1 - 1 - 2048 - file:///home/konrad/kde/src/amarok/tests/importers/files/testcollection/trimArtist1.mp3 - 1378127709 - 1378136870 - 8 - 0 - audio/mpeg - - - title2 - Nieznany - trimArtist - album - 1 - 1 - 2048 - file:///home/konrad/kde/src/amarok/tests/importers/files/testcollection/trimArtist2.mp3 - 1378127709 - 1378136870 - 8 - 0 - audio/mpeg - - - title - Nieznany - multiWordAlbum - al b um - 1 - 1 - 2048 - file:///home/konrad/kde/src/amarok/tests/importers/files/testcollection/multiWordAlbum.mp3 - 1378127570 - 1378136870 - 8 - 0 - audio/mpeg - - - tiTle - Nieznany - caseSensitiveTitle - album - 1 - 1 - 2048 - file:///home/konrad/kde/src/amarok/tests/importers/files/testcollection/caseSensitiveTitle3.mp3 - 1378127001 - 1378136871 - 8 - 0 - audio/mpeg - - - title - Nieznany - caseSensitiveTitle - album - 1 - 1 - 2048 - file:///home/konrad/kde/src/amarok/tests/importers/files/testcollection/caseSensitiveTitle1.mp3 - 1378126856 - 1378136868 - 8 - 0 - audio/mpeg - - - Title - Nieznany - caseSensitiveTitle - album - 1 - 1 - 2048 - file:///home/konrad/kde/src/amarok/tests/importers/files/testcollection/caseSensitiveTitle2.mp3 - 1378127001 - 1378136868 - 8 - 0 - audio/mpeg - - - title - Nieznany - caseSensitiveArtist - album - 1 - 1 - 2048 - file:///home/konrad/kde/src/amarok/tests/importers/files/testcollection/caseSensitiveArtist1.mp3 - 1378127001 - 1378136867 - 8 - 0 - audio/mpeg - - - title - Nieznany - trackUnset - album - 1 - 2048 - file:///home/konrad/kde/src/amarok/tests/importers/files/testcollection/trackUnset.mp3 - 1378127875 - 1378136868 - 8 - 0 - audio/mpeg - - - title - Nieznany - caseSensitiveartist - album - 1 - 1 - 2048 - file:///home/konrad/kde/src/amarok/tests/importers/files/testcollection/caseSensitiveArtist3.mp3 - 1378127001 - 1378136867 - 8 - 0 - audio/mpeg - - - title2 - Nieznany - trimTitle - album - 1 - 1 - 2048 - file:///home/konrad/kde/src/amarok/tests/importers/files/testcollection/trimTitle2.mp3 - 1378127696 - 1378136870 - 8 - 0 - audio/mpeg - - - title1 - Nieznany - trimTitle - album - 1 - 1 - 2048 - file:///home/konrad/kde/src/amarok/tests/importers/files/testcollection/trimTitle1.mp3 - 1378127696 - 1378136870 - 8 - 0 - audio/mpeg - - - title3 - Nieznany - trimTitle - album - 1 - 1 - 2048 - file:///home/konrad/kde/src/amarok/tests/importers/files/testcollection/trimTitle3.mp3 - 1378127696 - 1378136870 - 8 - 0 - audio/mpeg - - - title - Nieznany - discUnset - album - 1 - 2048 - file:///home/konrad/kde/src/amarok/tests/importers/files/testcollection/discUnset.mp3 - 1378127886 - 1378136868 - 8 - 0 - audio/mpeg - - - title - Nieznany - multiWordComposer - album - 1 - 1 - 2048 - file:///home/konrad/kde/src/amarok/tests/importers/files/testcollection/multiWordComposer.mp3 - 1378127570 - 1378136870 - 8 - 0 - audio/mpeg - - - title - Nieznany - utfAlbum - 賈滑串 - 1 - 1 - 2048 - file:///home/konrad/kde/src/amarok/tests/importers/files/testcollection/utfAlbum.mp3 - 1378127503 - 1378136866 - 8 - 0 - audio/mpeg - - - title - Nieznany - multi Word Artist - album - 1 - 1 - 2048 - file:///home/konrad/kde/src/amarok/tests/importers/files/testcollection/multiWordArtist.mp3 - 1378127570 - 1378136870 - 8 - 0 - audio/mpeg - - diff --git a/amarok/tests/importers/files/testcollection/albumUnset.mp3 b/amarok/tests/importers/files/testcollection/albumUnset.mp3 deleted file mode 100644 index ad2a3082..00000000 Binary files a/amarok/tests/importers/files/testcollection/albumUnset.mp3 and /dev/null differ diff --git a/amarok/tests/importers/files/testcollection/caseSensitiveAlbum1.mp3 b/amarok/tests/importers/files/testcollection/caseSensitiveAlbum1.mp3 deleted file mode 100644 index 6e12d6f9..00000000 Binary files a/amarok/tests/importers/files/testcollection/caseSensitiveAlbum1.mp3 and /dev/null differ diff --git a/amarok/tests/importers/files/testcollection/caseSensitiveAlbum2.mp3 b/amarok/tests/importers/files/testcollection/caseSensitiveAlbum2.mp3 deleted file mode 100644 index 629ceac3..00000000 Binary files a/amarok/tests/importers/files/testcollection/caseSensitiveAlbum2.mp3 and /dev/null differ diff --git a/amarok/tests/importers/files/testcollection/caseSensitiveAlbum3.mp3 b/amarok/tests/importers/files/testcollection/caseSensitiveAlbum3.mp3 deleted file mode 100644 index 433d5c34..00000000 Binary files a/amarok/tests/importers/files/testcollection/caseSensitiveAlbum3.mp3 and /dev/null differ diff --git a/amarok/tests/importers/files/testcollection/caseSensitiveArtist1.mp3 b/amarok/tests/importers/files/testcollection/caseSensitiveArtist1.mp3 deleted file mode 100644 index 023f6cef..00000000 Binary files a/amarok/tests/importers/files/testcollection/caseSensitiveArtist1.mp3 and /dev/null differ diff --git a/amarok/tests/importers/files/testcollection/caseSensitiveArtist2.mp3 b/amarok/tests/importers/files/testcollection/caseSensitiveArtist2.mp3 deleted file mode 100644 index 60f12656..00000000 Binary files a/amarok/tests/importers/files/testcollection/caseSensitiveArtist2.mp3 and /dev/null differ diff --git a/amarok/tests/importers/files/testcollection/caseSensitiveArtist3.mp3 b/amarok/tests/importers/files/testcollection/caseSensitiveArtist3.mp3 deleted file mode 100644 index 57432575..00000000 Binary files a/amarok/tests/importers/files/testcollection/caseSensitiveArtist3.mp3 and /dev/null differ diff --git a/amarok/tests/importers/files/testcollection/caseSensitiveComposer1.mp3 b/amarok/tests/importers/files/testcollection/caseSensitiveComposer1.mp3 deleted file mode 100644 index 8d1601d9..00000000 Binary files a/amarok/tests/importers/files/testcollection/caseSensitiveComposer1.mp3 and /dev/null differ diff --git a/amarok/tests/importers/files/testcollection/caseSensitiveComposer2.mp3 b/amarok/tests/importers/files/testcollection/caseSensitiveComposer2.mp3 deleted file mode 100644 index e53512ca..00000000 Binary files a/amarok/tests/importers/files/testcollection/caseSensitiveComposer2.mp3 and /dev/null differ diff --git a/amarok/tests/importers/files/testcollection/caseSensitiveComposer3.mp3 b/amarok/tests/importers/files/testcollection/caseSensitiveComposer3.mp3 deleted file mode 100644 index eafb7a59..00000000 Binary files a/amarok/tests/importers/files/testcollection/caseSensitiveComposer3.mp3 and /dev/null differ diff --git a/amarok/tests/importers/files/testcollection/caseSensitiveTitle1.mp3 b/amarok/tests/importers/files/testcollection/caseSensitiveTitle1.mp3 deleted file mode 100644 index f2d4e0c9..00000000 Binary files a/amarok/tests/importers/files/testcollection/caseSensitiveTitle1.mp3 and /dev/null differ diff --git a/amarok/tests/importers/files/testcollection/caseSensitiveTitle2.mp3 b/amarok/tests/importers/files/testcollection/caseSensitiveTitle2.mp3 deleted file mode 100644 index 6fa15d04..00000000 Binary files a/amarok/tests/importers/files/testcollection/caseSensitiveTitle2.mp3 and /dev/null differ diff --git a/amarok/tests/importers/files/testcollection/caseSensitiveTitle3.mp3 b/amarok/tests/importers/files/testcollection/caseSensitiveTitle3.mp3 deleted file mode 100644 index 75fafe63..00000000 Binary files a/amarok/tests/importers/files/testcollection/caseSensitiveTitle3.mp3 and /dev/null differ diff --git a/amarok/tests/importers/files/testcollection/composerUnset.mp3 b/amarok/tests/importers/files/testcollection/composerUnset.mp3 deleted file mode 100644 index c8c9e1c2..00000000 Binary files a/amarok/tests/importers/files/testcollection/composerUnset.mp3 and /dev/null differ diff --git a/amarok/tests/importers/files/testcollection/discUnset.mp3 b/amarok/tests/importers/files/testcollection/discUnset.mp3 deleted file mode 100644 index f1f3de88..00000000 Binary files a/amarok/tests/importers/files/testcollection/discUnset.mp3 and /dev/null differ diff --git a/amarok/tests/importers/files/testcollection/multiWordAlbum.mp3 b/amarok/tests/importers/files/testcollection/multiWordAlbum.mp3 deleted file mode 100644 index ce04866c..00000000 Binary files a/amarok/tests/importers/files/testcollection/multiWordAlbum.mp3 and /dev/null differ diff --git a/amarok/tests/importers/files/testcollection/multiWordArtist.mp3 b/amarok/tests/importers/files/testcollection/multiWordArtist.mp3 deleted file mode 100644 index b6c29c46..00000000 Binary files a/amarok/tests/importers/files/testcollection/multiWordArtist.mp3 and /dev/null differ diff --git a/amarok/tests/importers/files/testcollection/multiWordComposer.mp3 b/amarok/tests/importers/files/testcollection/multiWordComposer.mp3 deleted file mode 100644 index ec2dcd0a..00000000 Binary files a/amarok/tests/importers/files/testcollection/multiWordComposer.mp3 and /dev/null differ diff --git a/amarok/tests/importers/files/testcollection/multiWordTitle.mp3 b/amarok/tests/importers/files/testcollection/multiWordTitle.mp3 deleted file mode 100644 index 2c8ed9d8..00000000 Binary files a/amarok/tests/importers/files/testcollection/multiWordTitle.mp3 and /dev/null differ diff --git a/amarok/tests/importers/files/testcollection/testStatistics0.mp3 b/amarok/tests/importers/files/testcollection/testStatistics0.mp3 deleted file mode 100644 index e09bf7e0..00000000 Binary files a/amarok/tests/importers/files/testcollection/testStatistics0.mp3 and /dev/null differ diff --git a/amarok/tests/importers/files/testcollection/testStatistics1.mp3 b/amarok/tests/importers/files/testcollection/testStatistics1.mp3 deleted file mode 100644 index 3c399f3e..00000000 Binary files a/amarok/tests/importers/files/testcollection/testStatistics1.mp3 and /dev/null differ diff --git a/amarok/tests/importers/files/testcollection/testStatistics2.mp3 b/amarok/tests/importers/files/testcollection/testStatistics2.mp3 deleted file mode 100644 index 9510cc60..00000000 Binary files a/amarok/tests/importers/files/testcollection/testStatistics2.mp3 and /dev/null differ diff --git a/amarok/tests/importers/files/testcollection/testStatistics3.mp3 b/amarok/tests/importers/files/testcollection/testStatistics3.mp3 deleted file mode 100644 index b8cb7c31..00000000 Binary files a/amarok/tests/importers/files/testcollection/testStatistics3.mp3 and /dev/null differ diff --git a/amarok/tests/importers/files/testcollection/testStatistics4.mp3 b/amarok/tests/importers/files/testcollection/testStatistics4.mp3 deleted file mode 100644 index 87954535..00000000 Binary files a/amarok/tests/importers/files/testcollection/testStatistics4.mp3 and /dev/null differ diff --git a/amarok/tests/importers/files/testcollection/testStatistics5.mp3 b/amarok/tests/importers/files/testcollection/testStatistics5.mp3 deleted file mode 100644 index 4306a708..00000000 Binary files a/amarok/tests/importers/files/testcollection/testStatistics5.mp3 and /dev/null differ diff --git a/amarok/tests/importers/files/testcollection/testStatistics6.mp3 b/amarok/tests/importers/files/testcollection/testStatistics6.mp3 deleted file mode 100644 index eb6821a8..00000000 Binary files a/amarok/tests/importers/files/testcollection/testStatistics6.mp3 and /dev/null differ diff --git a/amarok/tests/importers/files/testcollection/testStatistics7.mp3 b/amarok/tests/importers/files/testcollection/testStatistics7.mp3 deleted file mode 100644 index 6d1b553a..00000000 Binary files a/amarok/tests/importers/files/testcollection/testStatistics7.mp3 and /dev/null differ diff --git a/amarok/tests/importers/files/testcollection/testStatistics8.mp3 b/amarok/tests/importers/files/testcollection/testStatistics8.mp3 deleted file mode 100644 index dee15aa0..00000000 Binary files a/amarok/tests/importers/files/testcollection/testStatistics8.mp3 and /dev/null differ diff --git a/amarok/tests/importers/files/testcollection/testStatistics9.mp3 b/amarok/tests/importers/files/testcollection/testStatistics9.mp3 deleted file mode 100644 index a2550e18..00000000 Binary files a/amarok/tests/importers/files/testcollection/testStatistics9.mp3 and /dev/null differ diff --git a/amarok/tests/importers/files/testcollection/testStatisticsNotSet0.mp3 b/amarok/tests/importers/files/testcollection/testStatisticsNotSet0.mp3 deleted file mode 100644 index 70d4ae26..00000000 Binary files a/amarok/tests/importers/files/testcollection/testStatisticsNotSet0.mp3 and /dev/null differ diff --git a/amarok/tests/importers/files/testcollection/testStatisticsNotSet1.mp3 b/amarok/tests/importers/files/testcollection/testStatisticsNotSet1.mp3 deleted file mode 100644 index 3fa202ca..00000000 Binary files a/amarok/tests/importers/files/testcollection/testStatisticsNotSet1.mp3 and /dev/null differ diff --git a/amarok/tests/importers/files/testcollection/testStatisticsNotSet2.mp3 b/amarok/tests/importers/files/testcollection/testStatisticsNotSet2.mp3 deleted file mode 100644 index 585981f3..00000000 Binary files a/amarok/tests/importers/files/testcollection/testStatisticsNotSet2.mp3 and /dev/null differ diff --git a/amarok/tests/importers/files/testcollection/testStatisticsNotSet3.mp3 b/amarok/tests/importers/files/testcollection/testStatisticsNotSet3.mp3 deleted file mode 100644 index 3f02bd6c..00000000 Binary files a/amarok/tests/importers/files/testcollection/testStatisticsNotSet3.mp3 and /dev/null differ diff --git a/amarok/tests/importers/files/testcollection/testStatisticsNotSet4.mp3 b/amarok/tests/importers/files/testcollection/testStatisticsNotSet4.mp3 deleted file mode 100644 index 83678865..00000000 Binary files a/amarok/tests/importers/files/testcollection/testStatisticsNotSet4.mp3 and /dev/null differ diff --git a/amarok/tests/importers/files/testcollection/testStatisticsNotSet5.mp3 b/amarok/tests/importers/files/testcollection/testStatisticsNotSet5.mp3 deleted file mode 100644 index 73cbd2a4..00000000 Binary files a/amarok/tests/importers/files/testcollection/testStatisticsNotSet5.mp3 and /dev/null differ diff --git a/amarok/tests/importers/files/testcollection/testStatisticsNotSet6.mp3 b/amarok/tests/importers/files/testcollection/testStatisticsNotSet6.mp3 deleted file mode 100644 index 8d8c533a..00000000 Binary files a/amarok/tests/importers/files/testcollection/testStatisticsNotSet6.mp3 and /dev/null differ diff --git a/amarok/tests/importers/files/testcollection/testStatisticsNotSet7.mp3 b/amarok/tests/importers/files/testcollection/testStatisticsNotSet7.mp3 deleted file mode 100644 index e1d4f04d..00000000 Binary files a/amarok/tests/importers/files/testcollection/testStatisticsNotSet7.mp3 and /dev/null differ diff --git a/amarok/tests/importers/files/testcollection/testStatisticsNotSet8.mp3 b/amarok/tests/importers/files/testcollection/testStatisticsNotSet8.mp3 deleted file mode 100644 index fde3b36c..00000000 Binary files a/amarok/tests/importers/files/testcollection/testStatisticsNotSet8.mp3 and /dev/null differ diff --git a/amarok/tests/importers/files/testcollection/testStatisticsNotSet9.mp3 b/amarok/tests/importers/files/testcollection/testStatisticsNotSet9.mp3 deleted file mode 100644 index 9ac330b9..00000000 Binary files a/amarok/tests/importers/files/testcollection/testStatisticsNotSet9.mp3 and /dev/null differ diff --git a/amarok/tests/importers/files/testcollection/trackUnset.mp3 b/amarok/tests/importers/files/testcollection/trackUnset.mp3 deleted file mode 100644 index ccbf3efd..00000000 Binary files a/amarok/tests/importers/files/testcollection/trackUnset.mp3 and /dev/null differ diff --git a/amarok/tests/importers/files/testcollection/trimAlbum1.mp3 b/amarok/tests/importers/files/testcollection/trimAlbum1.mp3 deleted file mode 100644 index 22a36c5a..00000000 Binary files a/amarok/tests/importers/files/testcollection/trimAlbum1.mp3 and /dev/null differ diff --git a/amarok/tests/importers/files/testcollection/trimAlbum2.mp3 b/amarok/tests/importers/files/testcollection/trimAlbum2.mp3 deleted file mode 100644 index 2c8f23bf..00000000 Binary files a/amarok/tests/importers/files/testcollection/trimAlbum2.mp3 and /dev/null differ diff --git a/amarok/tests/importers/files/testcollection/trimAlbum3.mp3 b/amarok/tests/importers/files/testcollection/trimAlbum3.mp3 deleted file mode 100644 index e25f8010..00000000 Binary files a/amarok/tests/importers/files/testcollection/trimAlbum3.mp3 and /dev/null differ diff --git a/amarok/tests/importers/files/testcollection/trimArtist1.mp3 b/amarok/tests/importers/files/testcollection/trimArtist1.mp3 deleted file mode 100644 index e482a876..00000000 Binary files a/amarok/tests/importers/files/testcollection/trimArtist1.mp3 and /dev/null differ diff --git a/amarok/tests/importers/files/testcollection/trimArtist2.mp3 b/amarok/tests/importers/files/testcollection/trimArtist2.mp3 deleted file mode 100644 index 7aab1c10..00000000 Binary files a/amarok/tests/importers/files/testcollection/trimArtist2.mp3 and /dev/null differ diff --git a/amarok/tests/importers/files/testcollection/trimArtist3.mp3 b/amarok/tests/importers/files/testcollection/trimArtist3.mp3 deleted file mode 100644 index 8edd694e..00000000 Binary files a/amarok/tests/importers/files/testcollection/trimArtist3.mp3 and /dev/null differ diff --git a/amarok/tests/importers/files/testcollection/trimComposer1.mp3 b/amarok/tests/importers/files/testcollection/trimComposer1.mp3 deleted file mode 100644 index 32e583e3..00000000 Binary files a/amarok/tests/importers/files/testcollection/trimComposer1.mp3 and /dev/null differ diff --git a/amarok/tests/importers/files/testcollection/trimComposer2.mp3 b/amarok/tests/importers/files/testcollection/trimComposer2.mp3 deleted file mode 100644 index 6e5590e5..00000000 Binary files a/amarok/tests/importers/files/testcollection/trimComposer2.mp3 and /dev/null differ diff --git a/amarok/tests/importers/files/testcollection/trimComposer3.mp3 b/amarok/tests/importers/files/testcollection/trimComposer3.mp3 deleted file mode 100644 index 5549ecf2..00000000 Binary files a/amarok/tests/importers/files/testcollection/trimComposer3.mp3 and /dev/null differ diff --git a/amarok/tests/importers/files/testcollection/trimTitle1.mp3 b/amarok/tests/importers/files/testcollection/trimTitle1.mp3 deleted file mode 100644 index 1dc25004..00000000 Binary files a/amarok/tests/importers/files/testcollection/trimTitle1.mp3 and /dev/null differ diff --git a/amarok/tests/importers/files/testcollection/trimTitle2.mp3 b/amarok/tests/importers/files/testcollection/trimTitle2.mp3 deleted file mode 100644 index 88a49cb7..00000000 Binary files a/amarok/tests/importers/files/testcollection/trimTitle2.mp3 and /dev/null differ diff --git a/amarok/tests/importers/files/testcollection/trimTitle3.mp3 b/amarok/tests/importers/files/testcollection/trimTitle3.mp3 deleted file mode 100644 index ffce222a..00000000 Binary files a/amarok/tests/importers/files/testcollection/trimTitle3.mp3 and /dev/null differ diff --git a/amarok/tests/importers/files/testcollection/utfAlbum.mp3 b/amarok/tests/importers/files/testcollection/utfAlbum.mp3 deleted file mode 100644 index 25465e1a..00000000 Binary files a/amarok/tests/importers/files/testcollection/utfAlbum.mp3 and /dev/null differ diff --git a/amarok/tests/importers/files/testcollection/utfArtist.mp3 b/amarok/tests/importers/files/testcollection/utfArtist.mp3 deleted file mode 100644 index 6432b9db..00000000 Binary files a/amarok/tests/importers/files/testcollection/utfArtist.mp3 and /dev/null differ diff --git a/amarok/tests/importers/files/testcollection/utfComposer.mp3 b/amarok/tests/importers/files/testcollection/utfComposer.mp3 deleted file mode 100644 index c8437c85..00000000 Binary files a/amarok/tests/importers/files/testcollection/utfComposer.mp3 and /dev/null differ diff --git a/amarok/tests/importers/files/testcollection/utfTitle.mp3 b/amarok/tests/importers/files/testcollection/utfTitle.mp3 deleted file mode 100644 index ec9147d3..00000000 Binary files a/amarok/tests/importers/files/testcollection/utfTitle.mp3 and /dev/null differ diff --git a/amarok/tests/importers/files/testcollection/yearUnset.mp3 b/amarok/tests/importers/files/testcollection/yearUnset.mp3 deleted file mode 100644 index 8440237c..00000000 Binary files a/amarok/tests/importers/files/testcollection/yearUnset.mp3 and /dev/null differ diff --git a/amarok/tests/mocks/MetaMock.h b/amarok/tests/mocks/MetaMock.h deleted file mode 100644 index 5e1bd0d0..00000000 --- a/amarok/tests/mocks/MetaMock.h +++ /dev/null @@ -1,177 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef METAMOCK_H -#define METAMOCK_H - -#include "core/meta/Meta.h" -#include "core/meta/Statistics.h" -#include "core/meta/support/MetaConstants.h" - -#include -#include - -/** - * This class provides simple mocks for meta classes. - * it will look for the keys defined in meta/MetaConstants.h - * in the given QVariantMap and return those values in the respective methods. - */ -class MetaMock : public Meta::Track, Meta::Statistics -{ -public: - MetaMock( const QVariantMap &data ) : Meta::Track(), m_data( data ), m_labels( Meta::LabelList() ) {} - virtual ~MetaMock() {} - - Meta::AlbumPtr album() const { return m_album; } - Meta::YearPtr year() const { return m_year; } - Meta::GenrePtr genre() const { return m_genre; } - Meta::ArtistPtr artist() const { return m_artist; } - Meta::ComposerPtr composer() const { return m_composer; } - - QString name() const { return m_data.value( Meta::Field::TITLE ).toString(); } - QString prettyName() const { return name(); } - KUrl playableUrl() const { return m_data.value( Meta::Field::URL ).value(); } - QString prettyUrl() const { return playableUrl().url(); } - QString uidUrl() const { return m_data.value( Meta::Field::UNIQUEID ).toString(); } - QString notPlayableReason() const { return QString( "dummy reason" ); } - QString comment() const { return m_data.value( Meta::Field::COMMENT ).toString(); } - qreal bpm() const { return m_data.value( Meta::Field::BPM ).toDouble(); } - qint64 length() const { return m_data.value( Meta::Field::LENGTH ).toInt(); } - int filesize() const { return m_data.value( Meta::Field::FILESIZE ).toInt(); } - int sampleRate() const { return m_data.value( Meta::Field::SAMPLERATE ).toInt(); } - int bitrate() const { return m_data.value( Meta::Field::BITRATE ).toInt(); } - QDateTime createDate() const { return QDateTime(); } //field missing - int trackNumber() const { return m_data.value( Meta::Field::TRACKNUMBER ).toInt(); } - int discNumber() const { return m_data.value( Meta::Field::DISCNUMBER ).toInt(); } - QString type() const { return "Mock"; } - - Meta::LabelList labels() const { return m_labels; } - - virtual Meta::StatisticsPtr statistics() { return Meta::StatisticsPtr( this ); } - - // Meta::Statistics getters - double score() const { return m_data.value( Meta::Field::SCORE ).toDouble(); } - int rating() const { return m_data.value( Meta::Field::RATING ).toInt(); } - QDateTime firstPlayed() const { return m_data.value( Meta::Field::FIRST_PLAYED ).toDateTime(); } - QDateTime lastPlayed() const { return m_data.value( Meta::Field::LAST_PLAYED ).toDateTime(); } - int playCount() const { return m_data.value( Meta::Field::PLAYCOUNT ).toInt(); } - - // Meta::Statistics setters - void setScore( double newScore ) { m_data[Meta::Field::SCORE].setValue( newScore ); } - void setRating( int newRating ) { m_data[Meta::Field::RATING].setValue( newRating ); } - void setFirstPlayed( const QDateTime &date ) { m_data[Meta::Field::FIRST_PLAYED].setValue( date ); } - void setLastPlayed( const QDateTime &date ) { m_data[Meta::Field::LAST_PLAYED].setValue( date ); } - void setPlayCount( int newPlayCount ) { m_data[Meta::Field::PLAYCOUNT].setValue( newPlayCount ); } - -public: - QVariantMap m_data; - Meta::ArtistPtr m_artist; - Meta::AlbumPtr m_album; - Meta::GenrePtr m_genre; - Meta::YearPtr m_year; - Meta::ComposerPtr m_composer; - Meta::LabelList m_labels; -}; - -class MockYear : public Meta::Year -{ -public: - MockYear( const QString &name ) - : Meta::Year() - , m_name( name ) {} - - QString name() const { return m_name; } - QString prettyName() const { return m_name; } - Meta::TrackList tracks() { return Meta::TrackList(); } - - QString m_name; -}; - -class MockGenre : public Meta::Genre -{ -public: - MockGenre( const QString &name ) - : Meta::Genre() - , m_name( name ) {} - - QString name() const { return m_name; } - QString prettyName() const { return m_name; } - Meta::TrackList tracks() { return Meta::TrackList(); } - - QString m_name; -}; - -class MockComposer : public Meta::Composer -{ -public: - MockComposer( const QString &name ) - : Meta::Composer() - , m_name( name ) {} - - QString name() const { return m_name; } - QString prettyName() const { return m_name; } - Meta::TrackList tracks() { return Meta::TrackList(); } - - QString m_name; -}; - -class MockArtist : public Meta::Artist -{ -public: - MockArtist( const QString &name ) - : Meta::Artist() - , m_name( name ) {} - - QString name() const { return m_name; } - QString prettyName() const { return m_name; } - Meta::TrackList tracks() { return Meta::TrackList(); } - Meta::AlbumList albums() { return Meta::AlbumList(); } - - QString m_name; -}; - -class MockAlbum : public Meta::Album -{ -public: - MockAlbum( const QString &name, const Meta::ArtistPtr &albumArtist = Meta::ArtistPtr() ) - : Meta::Album() - , m_name( name ) - , m_albumArtist( albumArtist ) {} - - QString name() const { return m_name; } - QString prettyName() const { return m_name; } - Meta::TrackList tracks() { return Meta::TrackList(); } - bool hasAlbumArtist() const { return ( m_albumArtist ) ? true : false; } - Meta::ArtistPtr albumArtist() const { return m_albumArtist; } - bool isCompilation() const { return !hasAlbumArtist(); } - - QString m_name; - Meta::ArtistPtr m_albumArtist; -}; - -class MockLabel : public Meta::Label -{ - public: - MockLabel( const QString &name ) - : Meta::Label() - , m_name( name ) {} - - QString name() const { return m_name; } - - QString m_name; -}; - -#endif // METAMOCK_H diff --git a/amarok/tests/mocks/MockAlbum.h b/amarok/tests/mocks/MockAlbum.h deleted file mode 100644 index 1840ab21..00000000 --- a/amarok/tests/mocks/MockAlbum.h +++ /dev/null @@ -1,39 +0,0 @@ - -/**************************************************************************************** - * Copyright (c) 2010 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef META_MOCKALBUM_H -#define META_MOCKALBUM_H - -#include - -#include "core/meta/Meta.h" - -namespace Meta -{ -class MockAlbum : public Meta::Album -{ - public: - MOCK_CONST_METHOD0( name, QString() ); - MOCK_CONST_METHOD0( prettyName, QString() ); - MOCK_METHOD0( tracks, Meta::TrackList() ); - MOCK_CONST_METHOD0( isCompilation, bool() ); - MOCK_CONST_METHOD0( hasAlbumArtist, bool() ); - MOCK_CONST_METHOD0( albumArtist, Meta::ArtistPtr() ); -}; -} - -#endif diff --git a/amarok/tests/mocks/MockArtist.h b/amarok/tests/mocks/MockArtist.h deleted file mode 100644 index 37c1236e..00000000 --- a/amarok/tests/mocks/MockArtist.h +++ /dev/null @@ -1,37 +0,0 @@ - -/**************************************************************************************** - * Copyright (c) 2010 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef META_MOCKARTIST_H -#define META_MOCKARTIST_H - -#include - -#include "core/meta/Meta.h" - -namespace Meta -{ -class MockArtist : public Meta::Artist -{ - public: - MOCK_CONST_METHOD0( name, QString() ); - MOCK_CONST_METHOD0( prettyName, QString() ); - MOCK_METHOD0( tracks, Meta::TrackList() ); - MOCK_METHOD0( albums, Meta::AlbumList() ); -}; -} - -#endif diff --git a/amarok/tests/mocks/MockComposer.h b/amarok/tests/mocks/MockComposer.h deleted file mode 100644 index c52df45c..00000000 --- a/amarok/tests/mocks/MockComposer.h +++ /dev/null @@ -1,36 +0,0 @@ - -/**************************************************************************************** - * Copyright (c) 2010 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef META_MOCKCOMPOSER_H -#define META_MOCKCOMPOSER_H - -#include - -#include "core/meta/Meta.h" - -namespace Meta -{ -class MockComposer : public Meta::Composer -{ - public: - MOCK_CONST_METHOD0( name, QString() ); - MOCK_CONST_METHOD0( prettyName, QString() ); - MOCK_METHOD0( tracks, Meta::TrackList() ); -}; -} - -#endif diff --git a/amarok/tests/mocks/MockGenre.h b/amarok/tests/mocks/MockGenre.h deleted file mode 100644 index 5643531a..00000000 --- a/amarok/tests/mocks/MockGenre.h +++ /dev/null @@ -1,36 +0,0 @@ - -/**************************************************************************************** - * Copyright (c) 2010 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef META_MOCKGENRE_H -#define META_MOCKGENRE_H - -#include - -#include "core/meta/Meta.h" - -namespace Meta -{ -class MockGenre : public Meta::Genre -{ - public: - MOCK_CONST_METHOD0( name, QString() ); - MOCK_CONST_METHOD0( prettyName, QString() ); - MOCK_METHOD0( tracks, Meta::TrackList() ); -}; -} - -#endif diff --git a/amarok/tests/mocks/MockLogger.h b/amarok/tests/mocks/MockLogger.h deleted file mode 100644 index 4e29434c..00000000 --- a/amarok/tests/mocks/MockLogger.h +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_MOCKLOGGER_H -#define AMAROK_MOCKLOGGER_H - -#include - -#include "core/interfaces/Logger.h" - -using ::testing::Return; -using ::testing::An; -using ::testing::_; - -namespace Amarok -{ - class MockLogger : public Amarok::Logger - { - public: - MockLogger() : Amarok::Logger() - { - ON_CALL( *this, shortMessage( _ ) ).WillByDefault( Return() ); - ON_CALL( *this, longMessage( _, _ ) ).WillByDefault( Return() ); - ON_CALL( *this, newProgressOperation( An(), _, _, _, _ ) ).WillByDefault( Return() ); - ON_CALL( *this, newProgressOperation( An(), _, _, _, _ ) ).WillByDefault( Return() ); - ON_CALL( *this, newProgressOperation( An(), _, _, _, _, _ ) ).WillByDefault( Return() ); - } - - MOCK_METHOD1( shortMessage, void( const QString& ) ); - MOCK_METHOD2( longMessage, void( const QString&, Amarok::Logger::MessageType ) ); - MOCK_METHOD5( newProgressOperation, void( KJob*, const QString&, QObject*, const char*, - Qt::ConnectionType ) ); - MOCK_METHOD5( newProgressOperation, void( QNetworkReply*, const QString&, QObject*, - const char*, Qt::ConnectionType ) ); - MOCK_METHOD6( newProgressOperation, void( QObject *, const QString&, int, QObject*, - const char*, Qt::ConnectionType ) ); - }; -} - -#endif - diff --git a/amarok/tests/mocks/MockQueryMaker.cpp b/amarok/tests/mocks/MockQueryMaker.cpp deleted file mode 100644 index 0ea23175..00000000 --- a/amarok/tests/mocks/MockQueryMaker.cpp +++ /dev/null @@ -1,21 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Jasneet Singh Bhatti * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "MockQueryMaker.h" - -MockQueryMaker::~MockQueryMaker() -{ -} - diff --git a/amarok/tests/mocks/MockQueryMaker.h b/amarok/tests/mocks/MockQueryMaker.h deleted file mode 100644 index 55c2c859..00000000 --- a/amarok/tests/mocks/MockQueryMaker.h +++ /dev/null @@ -1,186 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Jasneet Singh Bhatti * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef COLLECTIONS_MOCKQUERYMAKER -#define COLLECTIONS_MOCKQUERYMAKER - -#include "core/collections/QueryMaker.h" - -using namespace Collections; - -/** - * Ad-hoc mock to test the QueryMaker class - */ -class MockQueryMaker : public QueryMaker -{ - Q_OBJECT - - public: - /** - * For the vtable generated by the compiler - */ - virtual ~MockQueryMaker(); - - /** - * To prevent QueryMaker::addMatch( const Meta::LabelPtr& ) from being hidden - */ - using QueryMaker::addMatch; - - /** - * Mock implementations of pure virtual methods of class Collections::QueryMaker - * to enable creation of an instance of this mock class - * - * NOT TO BE USED ANYWHERE IN THE TEST - */ - virtual void run() - { - Q_ASSERT_X( false, __PRETTY_FUNCTION__, "should not be called"); - } - - virtual void abortQuery() - { - Q_ASSERT_X( false, __PRETTY_FUNCTION__, "should not be called"); - } - - virtual QueryMaker *setQueryType( QueryType ) - { - Q_ASSERT_X( false, __PRETTY_FUNCTION__, "should not be called"); - return 0; - } - - virtual QueryMaker *addReturnValue( qint64 ) - { - Q_ASSERT_X( false, __PRETTY_FUNCTION__, "should not be called"); - return 0; - } - - virtual QueryMaker *addReturnFunction( ReturnFunction, qint64 ) - { - Q_ASSERT_X( false, __PRETTY_FUNCTION__, "should not be called"); - return 0; - } - - virtual QueryMaker *orderBy( qint64, bool ) - { - Q_ASSERT_X( false, __PRETTY_FUNCTION__, "should not be called"); - return 0; - } - - virtual QueryMaker *addMatch( const Meta::TrackPtr& ) - { - Q_ASSERT_X( false, __PRETTY_FUNCTION__, "should not be called"); - return 0; - } - - virtual QueryMaker *addMatch( const Meta::ArtistPtr& , ArtistMatchBehaviour ) - { - Q_ASSERT_X( false, __PRETTY_FUNCTION__, "should not be called"); - return 0; - } - - virtual QueryMaker *addMatch( const Meta::AlbumPtr& ) - { - Q_ASSERT_X( false, __PRETTY_FUNCTION__, "should not be called"); - return 0; - } - - virtual QueryMaker *addMatch( const Meta::ComposerPtr& ) - { - Q_ASSERT_X( false, __PRETTY_FUNCTION__, "should not be called"); - return 0; - } - - virtual QueryMaker *addMatch( const Meta::GenrePtr& ) - { - Q_ASSERT_X( false, __PRETTY_FUNCTION__, "should not be called"); - return 0; - } - - virtual QueryMaker *addMatch( const Meta::YearPtr& ) - { - Q_ASSERT_X( false, __PRETTY_FUNCTION__, "should not be called"); - return 0; - } - - virtual QueryMaker *addFilter( qint64, const QString&, bool, bool ) - { - Q_ASSERT_X( false, __PRETTY_FUNCTION__, "should not be called"); - return 0; - } - - virtual QueryMaker *excludeFilter( qint64, const QString&, bool, bool ) - { - Q_ASSERT_X( false, __PRETTY_FUNCTION__, "should not be called"); - return 0; - } - - virtual QueryMaker *addNumberFilter( qint64, qint64, NumberComparison ) - { - Q_ASSERT_X( false, __PRETTY_FUNCTION__, "should not be called"); - return 0; - } - - virtual QueryMaker *excludeNumberFilter( qint64, qint64, NumberComparison ) - { - Q_ASSERT_X( false, __PRETTY_FUNCTION__, "should not be called"); - return 0; - } - - virtual QueryMaker *limitMaxResultSize( int ) - { - Q_ASSERT_X( false, __PRETTY_FUNCTION__, "should not be called"); - return 0; - } - - virtual QueryMaker *beginAnd() - { - Q_ASSERT_X( false, __PRETTY_FUNCTION__, "should not be called"); - return 0; - } - - virtual QueryMaker *beginOr() - { - Q_ASSERT_X( false, __PRETTY_FUNCTION__, "should not be called"); - return 0; - } - - virtual QueryMaker *endAndOr() - { - Q_ASSERT_X( false, __PRETTY_FUNCTION__, "should not be called"); - return 0; - } - - /** - * This method helps to determine if queryDone() has been connected/disconnected - * with slot deleteLater() - */ - virtual void emitQueryDone() - { - emit queryDone(); - } - - public slots: - /** - * Overrides the default deleteLater() slot provided by QObject since the default - * slot implements a deferred delete of the object and is not easily testable - * We only need to test if the slot is triggered or not - */ - virtual void deleteLater() - { - emit destroyed(); - } -}; - -#endif // COLLECTIONS_MOCKQUERYMAKER_H diff --git a/amarok/tests/mocks/MockTrack.h b/amarok/tests/mocks/MockTrack.h deleted file mode 100644 index fec6ef24..00000000 --- a/amarok/tests/mocks/MockTrack.h +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef META_MOCKTRACK_H -#define META_MOCKTRACK_H - -#undef kWarning // WORKAROUND: Prevent symbols clash with KDE's kWarning macro -#include - -#include "core/meta/Meta.h" - -using ::testing::Return; - -namespace Meta -{ -class MockTrack : public Meta::Track -{ - public: - MockTrack() : Meta::Track() - { - ON_CALL( *this, name() ).WillByDefault( Return( "" ) ); - ON_CALL( *this, notPlayableReason() ).WillByDefault( Return( QString() ) ); - ON_CALL( *this, artist() ).WillByDefault( Return( Meta::ArtistPtr() ) ); - ON_CALL( *this, album() ).WillByDefault( Return( Meta::AlbumPtr() ) ); - ON_CALL( *this, genre() ).WillByDefault( Return( Meta::GenrePtr() ) ); - ON_CALL( *this, year() ).WillByDefault( Return( Meta::YearPtr() ) ); - ON_CALL( *this, composer() ).WillByDefault( Return( Meta::ComposerPtr() ) ); - } - - MOCK_CONST_METHOD0( name, QString() ); - MOCK_CONST_METHOD0( prettyName, QString() ); - MOCK_CONST_METHOD0( playableUrl, KUrl() ); - MOCK_CONST_METHOD0( prettyUrl, QString() ); - MOCK_CONST_METHOD0( uidUrl, QString() ); - MOCK_CONST_METHOD0( notPlayableReason, QString() ); - MOCK_CONST_METHOD0( album, Meta::AlbumPtr() ); - MOCK_CONST_METHOD0( artist, Meta::ArtistPtr() ); - MOCK_CONST_METHOD0( composer, Meta::ComposerPtr() ); - MOCK_CONST_METHOD0( genre, Meta::GenrePtr() ); - MOCK_CONST_METHOD0( year, Meta::YearPtr() ); - MOCK_CONST_METHOD0( bpm, qreal() ); - MOCK_CONST_METHOD0( comment, QString() ); - MOCK_CONST_METHOD0( score, double() ); - MOCK_METHOD1( setScore, void(double score) ); - MOCK_CONST_METHOD0( rating, int() ); - MOCK_METHOD1( setRating, void(int rating) ); - MOCK_CONST_METHOD0( length, qint64() ); - MOCK_CONST_METHOD0( filesize, int() ); - MOCK_CONST_METHOD0( sampleRate, int() ); - MOCK_CONST_METHOD0( bitrate, int() ); - MOCK_CONST_METHOD0( createDate, QDateTime() ); - MOCK_CONST_METHOD0( trackNumber, int() ); - MOCK_CONST_METHOD0( discNumber, int() ); - MOCK_CONST_METHOD0( lastPlayed, QDateTime() ); - MOCK_CONST_METHOD0( firstPlayed, QDateTime() ); - MOCK_CONST_METHOD0( playCount, int() ); - MOCK_CONST_METHOD1( replayGain, qreal(Meta::ReplayGainTag mode) ); - MOCK_CONST_METHOD0( type, QString() ); - MOCK_METHOD0( prepareToPlay, void() ); - MOCK_METHOD1( finishedPlaying, void( double playedFraction ) ); - MOCK_CONST_METHOD0( inCollection, bool() ); - MOCK_CONST_METHOD0( collection, Collections::Collection*() ); - MOCK_CONST_METHOD0( cachedLyrics, QString() ); -}; -} - -#endif diff --git a/amarok/tests/mocks/MockTrackForUrlWorker.cpp b/amarok/tests/mocks/MockTrackForUrlWorker.cpp deleted file mode 100644 index 5e67d5f5..00000000 --- a/amarok/tests/mocks/MockTrackForUrlWorker.cpp +++ /dev/null @@ -1,35 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Jasneet Singh Bhatti * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "MockTrackForUrlWorker.h" - -#include "core/meta/Meta.h" - -MockTrackForUrlWorker::MockTrackForUrlWorker( const KUrl &url ) - : TrackForUrlWorker( url ) -{ -} - -MockTrackForUrlWorker::MockTrackForUrlWorker( const QString &url ) - : TrackForUrlWorker( url ) -{ -} - -void -MockTrackForUrlWorker::run() -{ - QFETCH( Meta::TrackPtr, track ); - m_track = track; -} diff --git a/amarok/tests/mocks/MockTrackForUrlWorker.h b/amarok/tests/mocks/MockTrackForUrlWorker.h deleted file mode 100644 index 76098a0e..00000000 --- a/amarok/tests/mocks/MockTrackForUrlWorker.h +++ /dev/null @@ -1,40 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Jasneet Singh Bhatti * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef MOCKTRACKFORURLWORKER_H -#define MOCKTRACKFORURLWORKER_H - -#include "core/collections/support/TrackForUrlWorker.h" - -#include - -using namespace Amarok; - -class MockTrackForUrlWorker : public TrackForUrlWorker -{ - Q_OBJECT - - public: - MockTrackForUrlWorker(const KUrl &url); - MockTrackForUrlWorker(const QString &url); - - /** - * Mock implementation that fetches the track from QTest data-driven testing - * variable named track and assigns it to m_track - */ - virtual void run(); -}; - -#endif // MOCKTRACKFORURLWORKER_H diff --git a/amarok/tests/mocks/MockYear.h b/amarok/tests/mocks/MockYear.h deleted file mode 100644 index 0ec85c67..00000000 --- a/amarok/tests/mocks/MockYear.h +++ /dev/null @@ -1,36 +0,0 @@ - -/**************************************************************************************** - * Copyright (c) 2010 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef META_MOCKYEAR_H -#define META_MOCKYEAR_H - -#include - -#include "core/meta/Meta.h" - -namespace Meta -{ -class MockYear : public Meta::Year -{ - public: - MOCK_CONST_METHOD0( name, QString() ); - MOCK_CONST_METHOD0( prettyName, QString() ); - MOCK_METHOD0( tracks, Meta::TrackList() ); -}; -} - -#endif diff --git a/amarok/tests/mocks/SqlStorageMock.cpp b/amarok/tests/mocks/SqlStorageMock.cpp deleted file mode 100644 index 54c6d2d2..00000000 --- a/amarok/tests/mocks/SqlStorageMock.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "SqlStorageMock.h" - -OrderedSqlStorageMock::OrderedSqlStorageMock( const QList > &queries) - : SqlStorage() - , m_queries(queries) -{ -} - -OrderedSqlStorageMock::~OrderesSqlStorageMock() -{ -} - -bool -OrderedSqlStorageMock::allQueriesRun() const -{ - return m_queries.isEmpty(); -} - -QStringList -OrderedSqlStorageMock::query( const QString &query ) -{ - QVERIFY( !m_queries.isEmpty() ); - QPair pair = m_queries.takeFirst(); - QCOMPARE( query, pair.first ); - QVariant value = pair.second; - QVERIFY(value.canConvert(QVariant::StringList)); - return value.toStringList(); -} - -int -OrderedSqlStorageMock::insert(const QString &statement, const QString &table) -{ - QVERIFY( !m_queries.isEmpty() ); - QPair pair = m_queries.takeFirst(); - QCOMPARE( statement, pair.first ); - QVariant value = pair.second; - QVERIFY(value.canConvert(QVariant::Int)); - return value.toInt(); -} - -RandomSqlStorageMock::RandomSqlStorageMock( const QVariantMap &queries ) - : SqlStorage() - , m_queries() -{ - foreach( QString key, queries.keys() ) - { - m_queries.insert( key.toLower(), queries.value( key ) ); - } -} - -RandomSqlStorageMock::~RandomSqlStorageMock() -{ -} - -bool -RandomSqlStorageMock::allQueriesRun() const -{ - return m_queries.isEmpty(); -} - -QStringList -RandomSqlStorageMock::query( const QString &query ) -{ - QVERIFY2( m_queries.contains( query.toLower() ), "Received an unknown query in query()" ); - QVariant value = m_queries.value( query ); - QVERIFY(value.canConvert(QVariant::StringList)); - return value.toStringList(); -} - -int -RandomSqlStorageMock::insert(const QString &statement, const QString &table) -{ - QVERIFY2( m_queries.contains( statement.toLower() ), "Received an unknown query in insert()" ); - QVariant value = m_queries.value( statement ); - QVERIFY(value.canConvert(QVariant::Int)); - return value.toInt(); -} diff --git a/amarok/tests/mocks/SqlStorageMock.h b/amarok/tests/mocks/SqlStorageMock.h deleted file mode 100644 index 723787a4..00000000 --- a/amarok/tests/mocks/SqlStorageMock.h +++ /dev/null @@ -1,104 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef SQLSTORAGEMOCK_H -#define SQLSTORAGEMOCK_H - -#include "core/storage/SqlStorage.h" - -#include -#include -#include -#include -#include -#include - -class OrderedSqlStorageMock -{ -public: - OrderedSqlStorageMock( const QList > queries ); - virtual ~OrderesSqlStorageMock(); - - virtual int sqlDatabasePriority() const { return 0; } - - virtual QString type() const { return "RandomSqlStorageMock"; } - - virtual QString escape( const QString &text ) const { return text; } - - virtual QStringList query( const QString &query ); - virtual int insert( const QString &statement, const QString &table ); - - virtual QString boolTrue() const { return "1"; } - virtual QString boolFalse() const { return "0"; } - - /** - use this type for auto incrementing integer primary keys. - */ - virtual QString idType() const { QFAIL( "idType not implemented" ); return QString(); } - - virtual QString textColumnType( int length = 255 ) const { QFAIL( "textColumnType not implemented" ); return QString(); } - virtual QString exactTextColumnType( int length = 1000 ) const { QFAIL( "exactTextColumnType not implemented" ); return QString(); } - //the below value may have to be decreased even more for different indexes; only time will tell - virtual QString exactIndexableTextColumnType( int length = 324 ) const { QFAIL( "exactIdexableTextColumnType not implemented" ); return QString(); } - virtual QString longTextColumnType() const { QFAIL( "longTextColumnType not implemented" ); return QString(); } - virtual QString randomFunc() const { QFAIL( "ramdomFunc not implemented" ); return QString(); } - - //Mock specific method - bool allQueriesRun() const; - -private: - QList > m_queries; -}; - -class RandomSqlStorageMock : public SqlStorage -{ -public: - RandomSqlStorageMock( const QVariantMap &queries ); - virtual ~RandomSqlStorageMock(); - - virtual int sqlDatabasePriority() const { return 0; } - - virtual QString type() const { return "RandomSqlStorageMock"; } - - virtual QString escape( const QString &text ) const { return text; } - - virtual QStringList query( const QString &query ); - virtual int insert( const QString &statement, const QString &table ); - - virtual QString boolTrue() const { return "1"; } - virtual QString boolFalse() const { return "0"; } - - /** - use this type for auto incrementing integer primary keys. - */ - virtual QString idType() const { QFAIL( "idType not implemented" ); return QString(); } - - virtual QString textColumnType( int length = 255 ) const { QFAIL( "textColumnType not implemented" ); return QString(); } - virtual QString exactTextColumnType( int length = 1000 ) const { QFAIL( "exactTextColumnType not implemented" ); return QString(); } - //the below value may have to be decreased even more for different indexes; only time will tell - virtual QString exactIndexableTextColumnType( int length = 324 ) const { QFAIL( "exactIdexableTextColumnType not implemented" ); return QString(); } - virtual QString longTextColumnType() const { QFAIL( "longTextColumnType not implemented" ); return QString(); } - virtual QString randomFunc() const { QFAIL( "ramdomFunc not implemented" ); return QString(); } - - //Mock specific method - bool allQueriesRun() const; - -private: - QVariantMap m_queries; - -}; - -#endif // SQLSTORAGEMOCK_H diff --git a/amarok/tests/mpristest.py b/amarok/tests/mpristest.py deleted file mode 100644 index d14ebda1..00000000 --- a/amarok/tests/mpristest.py +++ /dev/null @@ -1,65 +0,0 @@ -import subprocess -import time -import unittest - -import dbus - -APPNAME = "amarok" -MPRIS_OBJECT_PATH = "/org/mpris/MediaPlayer2" -MPRIS_PREFIX = "org.mpris.MediaPlayer2" - -ROOT_IFACE = MPRIS_PREFIX -PLAYER_IFACE = MPRIS_PREFIX + ".Player" - -def get_mpris_object(): - bus = dbus.SessionBus() - return bus.get_object(MPRIS_PREFIX + "." + APPNAME, MPRIS_OBJECT_PATH) - -def start_player(): - devnull = file("/dev/null", "a") - player = subprocess.Popen(["amarok", "--nofork"], stderr=devnull, stdout=devnull) - time.sleep(10) - return player - -def stop_player(player): - player.terminate() - player.wait() - -class TestMediaPlayer2(unittest.TestCase): - def check_property(self, props, key, expected_value): - value = props[key] - self.assertEquals(value, expected_value) - del props[key] - - def check_has_property(self, props, key): - self.assert_(key in props) - del props[key] - - def test_properties(self): - player = start_player() - try: - mpris = get_mpris_object() - props = mpris.GetAll(ROOT_IFACE) - self.check_property(props, "CanQuit", True) - self.check_property(props, "CanRaise", True) - self.check_property(props, "HasTrackList", False) - self.check_property(props, "Identity", "Amarok") - self.check_property(props, "DesktopEntry", "amarok") - self.check_has_property(props, "SupportedUriSchemes") - self.check_has_property(props, "SupportedMimeTypes") - self.assertEquals(len(props), 0) - finally: - stop_player(player) - - def test_quit(self): - player = start_player() - mpris = get_mpris_object() - mpris.Quit() - start = time.time() - while time.time() < start + 60 * 5 and player.poll() is None: - time.sleep(.5) - if player.poll() is None: - stop_player(player) - self.fail("Player not stopped") - -unittest.main() diff --git a/amarok/tests/playlist/CMakeLists.txt b/amarok/tests/playlist/CMakeLists.txt deleted file mode 100644 index 47e55a62..00000000 --- a/amarok/tests/playlist/CMakeLists.txt +++ /dev/null @@ -1,52 +0,0 @@ -include_directories( - ${AMAROK_TEST_TREE} - ${AMAROK_SOURCE_TREE} - ${AMAROK_UTILITY_TREE} - ${CMAKE_BINARY_DIR}/src - ${CMAKE_BINARY_DIR}/tests - ${AMAROK_COLLECTION_SUPPORT_DIR} - ${KDE4_INCLUDE_DIR} - ${QT_INCLUDES} - ${GOOGLEMOCK_INCLUDE_DIR} - ) - -#------------------------ Test CueFileSupport ----------------------------- - -set( testplaylistmodels_SRCS - TestPlaylistModels.cpp - ${AMAROK_SOURCE_TREE}/EngineController.cpp - ${AMAROK_SOURCE_TREE}/core/capabilities/BoundedPlaybackCapability.cpp - ${AMAROK_SOURCE_TREE}/core/capabilities/MultiSourceCapability.cpp - ${AMAROK_SOURCE_TREE}/playback/PowerManager.cpp - ${AMAROK_SOURCE_TREE}/playlist/PlaylistDefines.cpp - ${AMAROK_SOURCE_TREE}/playlist/PlaylistModel.cpp - ${AMAROK_SOURCE_TREE}/playlist/PlaylistModelStack.cpp - ${AMAROK_SOURCE_TREE}/playlist/proxymodels/ProxyBase.cpp - ${AMAROK_SOURCE_TREE}/playlist/proxymodels/GroupingProxy.cpp - ${AMAROK_SOURCE_TREE}/playlist/proxymodels/SearchProxy.cpp - ${AMAROK_SOURCE_TREE}/playlist/proxymodels/SortAlgorithms.cpp - ${AMAROK_SOURCE_TREE}/playlist/proxymodels/SortFilterProxy.cpp - ${AMAROK_SOURCE_TREE}/playlist/proxymodels/SortScheme.cpp - ${AMAROK_SOURCE_TREE}/core-impl/playlists/types/file/PlaylistFileSupport.cpp - ${AMAROK_SOURCE_TREE}/playlist/PlaylistItem.cpp - ${AMAROK_SOURCE_TREE}/core/support/Amarok.cpp - ${GOOGLEMOCK_SRCS} -) - -kde4_add_unit_test( testplaylistmodels ${testplaylistmodels_SRCS} ) - -add_dependencies( testplaylistmodels amaroklib ) - -target_link_libraries( testplaylistmodels - amarokcore - amaroklib - ${KDE4_KDECORE_LIBS} - ${KDE4_KDEUI_LIBS} - ${KDE4_KIO_LIBS} - ${KDE4_PHONON_LIBRARY} - ${KDE4_SOLID_LIBS} - ${QT_QTTEST_LIBRARY} - ${QT_QTCORE_LIBRARY} - ${GOOGLEMOCK_LIBRARIES} - ${CMAKE_DL_LIBS} -) diff --git a/amarok/tests/playlist/TestPlaylistModels.cpp b/amarok/tests/playlist/TestPlaylistModels.cpp deleted file mode 100644 index ae096010..00000000 --- a/amarok/tests/playlist/TestPlaylistModels.cpp +++ /dev/null @@ -1,235 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 Pulic License for more details. * - * * - * You should have received a copy of the GNU General Public License along with * - * this program. If not, see . * - ****************************************************************************************/ - -#include "TestPlaylistModels.h" - -#include "core/support/Components.h" -#include "EngineController.h" - -#include "playlist/PlaylistActions.h" -#include "playlist/PlaylistController.h" -#include "playlist/PlaylistModelStack.h" -#include "playlist/PlaylistModel.h" -#include "playlist/UndoCommands.h" - -#include "mocks/MetaMock.h" -#include "mocks/MockTrack.h" - -#include - -#include -#include -#include - -using namespace Playlist; - -QTEST_KDEMAIN( TestPlaylistModels, GUI ) - - -TestPlaylistModels::TestPlaylistModels() - : QObject() -{ -} - -void TestPlaylistModels::initTestCase() -{ - //apparently the engine controller is needed somewhere, or we will get a crash... - EngineController *controller = new EngineController(); - Amarok::Components::setEngineController( controller ); - - // Initialize playlistAction before we set the playlist, lest our playlist be overwritten with Art Of Nations - The::playlistActions(); - The::playlistController()->removeRow( 0 ); - - //we want to add a few tracks to the playlist so we can test sorting, filtering and so on. So first create a bunch of dummy tracks we can use. - - Meta::TrackList tracks; - - QVariantMap map1; - map1.insert( Meta::Field::TITLE, QString( "Cool as honey" ) ); - MetaMock * metaMock = new MetaMock( map1 ); - metaMock->m_artist = new MockArtist( "Bonzai Bees" ); - metaMock->m_album = new MockAlbum( "The Hive", metaMock->m_artist ); - tracks << Meta::TrackPtr( metaMock ); - - QVariantMap map2; - map2.insert( Meta::Field::TITLE, QString( "xTreme buzzing sound" ) ); - metaMock = new MetaMock( map2 ); - metaMock->m_artist = new MockArtist( "Bonzai Bees" ); - metaMock->m_album = new MockAlbum( "The Hive", metaMock->m_artist ); - tracks << Meta::TrackPtr( metaMock ); - - QVariantMap map3; - map3.insert( Meta::Field::TITLE, QString( "Alphabet soup" ) ); - metaMock = new MetaMock( map3 ); - metaMock->m_artist = new MockArtist( "Grumpy Grizzlies" ); - metaMock->m_album = new MockAlbum( "The Hive", metaMock->m_artist ); - tracks << Meta::TrackPtr( metaMock ); - - QVariantMap map4; - map4.insert( Meta::Field::TITLE, QString( "Zlick" ) ); - metaMock = new MetaMock( map4 ); - metaMock->m_artist = new MockArtist( "Grumpy Grizzlies" ); - metaMock->m_album = new MockAlbum( "Nice Long Nap", metaMock->m_artist ); - tracks << Meta::TrackPtr( metaMock ); - - QVariantMap map5; - map5.insert( Meta::Field::TITLE, QString( "23 hours is not enough" ) ); - metaMock = new MetaMock( map5 ); - metaMock->m_artist = new MockArtist( "Grumpy Grizzlies" ); - metaMock->m_album = new MockAlbum( "Nice Long Nap", metaMock->m_artist ); - tracks << Meta::TrackPtr( metaMock ); - - QVariantMap map6; - map6.insert( Meta::Field::TITLE, QString( "1 song to rule them all" ) ); - metaMock = new MetaMock( map6 ); - metaMock->m_artist = new MockArtist( "Bonzai Bees" ); - metaMock->m_album = new MockAlbum( "Pretty Flowers", metaMock->m_artist ); - tracks << Meta::TrackPtr( metaMock ); - - QVariantMap map7; - map7.insert( Meta::Field::TITLE, QString( "zz ambience sound" ) ); - metaMock = new MetaMock( map7 ); - // note: no artist, no album! - tracks << Meta::TrackPtr( metaMock ); - - The::playlistController()->insertTracks( 0, tracks ); - - QCOMPARE( The::playlist()->trackAt( 3 )->prettyName(), QString( "Zlick" ) ); -} - -void TestPlaylistModels::cleanup() -{ - SortScheme scheme = SortScheme(); - ModelStack::instance()->sortProxy()->updateSortMap( scheme ); - ModelStack::instance()->filterProxy()->clearSearchTerm(); -} - -void TestPlaylistModels::testSorting() -{ - //simple sort by title - //******************************// - - SortScheme scheme = SortScheme(); - scheme.addLevel( SortLevel( Playlist::Title, Qt::AscendingOrder ) ); - ModelStack::instance()->sortProxy()->updateSortMap( scheme ); - - AbstractModel * topModel = The::playlist(); - - QCOMPARE( topModel->trackAt( 0 )->prettyName(), QString( "1 song to rule them all" ) ); - QCOMPARE( topModel->trackAt( 1 )->prettyName(), QString( "23 hours is not enough" ) ); - QCOMPARE( topModel->trackAt( 2 )->prettyName(), QString( "Alphabet soup" ) ); - QCOMPARE( topModel->trackAt( 3 )->prettyName(), QString( "Cool as honey" ) ); - QCOMPARE( topModel->trackAt( 4 )->prettyName(), QString( "xTreme buzzing sound" ) ); - QCOMPARE( topModel->trackAt( 5 )->prettyName(), QString( "Zlick" ) ); - - - //Sort by Artist - Album - Title - //******************************// - - SortScheme scheme2 = SortScheme(); - - scheme2.addLevel( SortLevel( Playlist::Artist, Qt::AscendingOrder ) ); - scheme2.addLevel( SortLevel( Playlist::Album, Qt::AscendingOrder ) ); - scheme2.addLevel( SortLevel( Playlist::Title, Qt::AscendingOrder ) ); - - QCOMPARE( scheme2.length(), 3 ); - - ModelStack::instance()->sortProxy()->updateSortMap( scheme2 ); - topModel->qaim()->revert(); - - // the one without artist or album comes first - QCOMPARE( topModel->trackAt( 0 )->prettyName(), QString( "zz ambience sound" ) ); - QCOMPARE( topModel->trackAt( 1 )->prettyName(), QString( "1 song to rule them all" ) ); - QCOMPARE( topModel->trackAt( 2 )->prettyName(), QString( "Cool as honey" ) ); - QCOMPARE( topModel->trackAt( 3 )->prettyName(), QString( "xTreme buzzing sound" ) ); - QCOMPARE( topModel->trackAt( 4 )->prettyName(), QString( "23 hours is not enough" ) ); - QCOMPARE( topModel->trackAt( 5 )->prettyName(), QString( "Zlick" ) ); - QCOMPARE( topModel->trackAt( 6 )->prettyName(), QString( "Alphabet soup" ) ); - - //reverse some stuff - //******************************// - - SortScheme scheme3 = SortScheme(); - - scheme3.addLevel( SortLevel( Playlist::Artist, Qt::AscendingOrder ) ); - scheme3.addLevel( SortLevel( Playlist::Album, Qt::DescendingOrder ) ); - scheme3.addLevel( SortLevel( Playlist::Title, Qt::AscendingOrder ) ); - - ModelStack::instance()->sortProxy()->updateSortMap( scheme3 ); - topModel->qaim()->revert(); - - QCOMPARE( topModel->trackAt( 0 )->prettyName(), QString( "zz ambience sound" ) ); - QCOMPARE( topModel->trackAt( 1 )->prettyName(), QString( "Cool as honey" ) ); - QCOMPARE( topModel->trackAt( 2 )->prettyName(), QString( "xTreme buzzing sound" ) ); - QCOMPARE( topModel->trackAt( 3 )->prettyName(), QString( "1 song to rule them all" ) ); - QCOMPARE( topModel->trackAt( 4 )->prettyName(), QString( "Alphabet soup" ) ); - QCOMPARE( topModel->trackAt( 5 )->prettyName(), QString( "23 hours is not enough" ) ); - QCOMPARE( topModel->trackAt( 6 )->prettyName(), QString( "Zlick" ) ); - - //Sort by album when tracks have same album name and different artists - //******************************// - - SortScheme scheme4 = SortScheme(); - - scheme4.addLevel( SortLevel( Playlist::Album, Qt::AscendingOrder ) ); - scheme4.addLevel( SortLevel( Playlist::Title, Qt::AscendingOrder ) ); - - ModelStack::instance()->sortProxy()->updateSortMap( scheme4 ); - topModel->qaim()->revert(); - - QCOMPARE( topModel->trackAt( 0 )->prettyName(), QString( "zz ambience sound" ) ); - QCOMPARE( topModel->trackAt( 1 )->prettyName(), QString( "23 hours is not enough" ) ); - QCOMPARE( topModel->trackAt( 2 )->prettyName(), QString( "Zlick" ) ); - QCOMPARE( topModel->trackAt( 3 )->prettyName(), QString( "1 song to rule them all" ) ); - QCOMPARE( topModel->trackAt( 4 )->prettyName(), QString( "Cool as honey" ) ); - QCOMPARE( topModel->trackAt( 5 )->prettyName(), QString( "xTreme buzzing sound" ) ); - QCOMPARE( topModel->trackAt( 6 )->prettyName(), QString( "Alphabet soup" ) ); -} - -void TestPlaylistModels::testFiltering() -{ - ModelStack::instance()->filterProxy()->showOnlyMatches( true ); - ModelStack::instance()->filterProxy()->find( "ou" ); - ModelStack::instance()->filterProxy()->filterUpdated(); - - AbstractModel * topModel = The::playlist(); - - QCOMPARE( topModel->qaim()->rowCount(), 4 ); - QCOMPARE( topModel->trackAt( 0 )->prettyName(), QString( "xTreme buzzing sound" ) ); - QCOMPARE( topModel->trackAt( 1 )->prettyName(), QString( "Alphabet soup" ) ); - QCOMPARE( topModel->trackAt( 2 )->prettyName(), QString( "23 hours is not enough" ) ); - QCOMPARE( topModel->trackAt( 3 )->prettyName(), QString( "zz ambience sound" ) ); - //TODO: More advanced filtering tests go here - -} - -void TestPlaylistModels::testSearching() -{ -} - -void TestPlaylistModels::testShuffling() -{ - Meta::TrackList oldTrackList = The::playlist()->tracks(); - - The::playlistActions()->shuffle(); - - QVERIFY( oldTrackList != The::playlist()->tracks() ); - - The::playlistController()->undo(); - - QCOMPARE( oldTrackList, The::playlist()->tracks() ); -} diff --git a/amarok/tests/playlist/TestPlaylistModels.h b/amarok/tests/playlist/TestPlaylistModels.h deleted file mode 100644 index a501135c..00000000 --- a/amarok/tests/playlist/TestPlaylistModels.h +++ /dev/null @@ -1,37 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Nikolaj Hald Nielsen * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 Pulic License for more details. * - * * - * You should have received a copy of the GNU General Public License along with * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef TESTPLAYLISTMODELS_H -#define TESTPLAYLISTMODELS_H - -#include - -class TestPlaylistModels : public QObject -{ -Q_OBJECT -public: - TestPlaylistModels(); - -private slots: - void initTestCase(); - void cleanup(); - void testSorting(); - void testFiltering(); - void testSearching(); - void testShuffling(); -}; - -#endif // TESTPLAYLISTMODELS_H diff --git a/amarok/tests/playlistmanager/CMakeLists.txt b/amarok/tests/playlistmanager/CMakeLists.txt deleted file mode 100644 index d4a328d3..00000000 --- a/amarok/tests/playlistmanager/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -if(KDE4_BUILD_TESTS) - add_subdirectory( file ) - add_subdirectory( sql ) -endif() diff --git a/amarok/tests/playlistmanager/file/CMakeLists.txt b/amarok/tests/playlistmanager/file/CMakeLists.txt deleted file mode 100644 index d9cd31ae..00000000 --- a/amarok/tests/playlistmanager/file/CMakeLists.txt +++ /dev/null @@ -1,25 +0,0 @@ -include_directories( . - ${AMAROK_TEST_TREE} - ${AMAROK_SOURCE_TREE}/statusbar - ${AMAROK_SOURCE_TREE}/collection - ${CMAKE_BINARY_DIR}/tests - ${CMAKE_BINARY_DIR}/src -) - -#------------------------ Test PlaylistFileProvider ----------------------------- - -set( testplaylistfileprovider_SRCS - TestPlaylistFileProvider.cpp - ${AMAROK_SOURCE_TREE}/playlistmanager/file/PlaylistFileProvider.cpp - ${AMAROK_SOURCE_TREE}/playlist/PlaylistDefines.cpp - ${AMAROK_SOURCE_TREE}/playlist/PlaylistModelStack.cpp - ${AMAROK_SOURCE_TREE}/playlist/proxymodels/GroupingProxy.cpp - ${AMAROK_SOURCE_TREE}/playlist/proxymodels/ProxyBase.cpp - ${AMAROK_SOURCE_TREE}/playlist/proxymodels/SearchProxy.cpp - ${AMAROK_SOURCE_TREE}/playlist/proxymodels/SortFilterProxy.cpp - ${AMAROK_SOURCE_TREE}/playlist/proxymodels/SortAlgorithms.cpp - ${AMAROK_SOURCE_TREE}/playlist/proxymodels/SortScheme.cpp - ${AMAROK_SOURCE_TREE}/core-impl/playlists/types/file/PlaylistFileSupport.cpp - ) -kde4_add_unit_test( testplaylistfileprovider ${testplaylistfileprovider_SRCS} ) -target_link_libraries( testplaylistfileprovider ${KDE4_KDEUI_LIBS} ${KDE4_KIO_LIBS} ${QT_QTTEST_LIBRARY} ${QT_QTCORE_LIBRARY} amarokcore amaroklib ) diff --git a/amarok/tests/playlistmanager/file/TestPlaylistFileProvider.cpp b/amarok/tests/playlistmanager/file/TestPlaylistFileProvider.cpp deleted file mode 100644 index 8f7a4e52..00000000 --- a/amarok/tests/playlistmanager/file/TestPlaylistFileProvider.cpp +++ /dev/null @@ -1,153 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2009 Sven Krohlas * - * * - * This program 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 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#include "TestPlaylistFileProvider.h" - -#include "config-amarok-test.h" -#include "core/support/Amarok.h" -#include "core-impl/collections/support/CollectionManager.h" -#include "playlistmanager/file/PlaylistFileProvider.h" - -#include -#include - -#include -#include -#include - -QTEST_KDEMAIN( TestPlaylistFileProvider, GUI ) - -TestPlaylistFileProvider::TestPlaylistFileProvider() -{} - -void TestPlaylistFileProvider::initTestCase() -{ - m_testPlaylistFileProvider = new Playlists::PlaylistFileProvider(); - QVERIFY( m_testPlaylistFileProvider ); - - removeConfigPlaylistEntries(); - removeTestPlaylist(); - m_testPlaylistFileProvider->deletePlaylists( m_testPlaylistFileProvider->playlists() ); -} - -void TestPlaylistFileProvider::cleanupTestCase() -{ - removeTestPlaylist(); - removeConfigPlaylistEntries(); - delete m_testPlaylistFileProvider; -} - -void TestPlaylistFileProvider::testPlaylists() -{ - Playlists::PlaylistList tempList = m_testPlaylistFileProvider->playlists(); - QCOMPARE( tempList.size(), 0 ); -} - -void TestPlaylistFileProvider::testSave_data() -{ - QTest::addColumn("name"); - QTest::addColumn("result"); - - QTest::newRow("no extension, should default to xspf") << "Amarok Test Playlist" << "Amarok Test Playlist.xspf"; - QTest::newRow("directory separators '\\' and '/' in file name are being replaced by '-'") << "amarok/playlist" << "amarok-playlist.xspf"; - QTest::newRow("directory separators '\\' and '/' in file name are being replaced by '-'") << "amarok\\playlist" << "amarok-playlist.xspf"; - QTest::newRow("xspf") << "Amarok Test Playlist.xspf" << "Amarok Test Playlist.xspf"; - QTest::newRow("m3u") << "Amarok Test Playlist.m3u" << "Amarok Test Playlist.m3u"; - QTest::newRow("pls") << "Amarok Test Playlist.pls" << "Amarok Test Playlist.pls"; - QTest::newRow("playlist name with dot in it (BR 290318)") << "Amarok Test Playlist. With dots." << "Amarok Test Playlist. With dots..xspf"; -} - -void TestPlaylistFileProvider::testSave() -{ - Meta::TrackList tempTrackList; - const KUrl trackUrl = dataPath( "data/audio/Platz 01.mp3" ); - tempTrackList.append( CollectionManager::instance()->trackForUrl( trackUrl ) ); - QCOMPARE( tempTrackList.size(), 1 ); - - QFETCH(QString, name); - QFETCH(QString, result); - - Playlists::PlaylistPtr testPlaylist = m_testPlaylistFileProvider->save( tempTrackList, name ); - QVERIFY( testPlaylist ); - - QVERIFY( QFile::exists( Amarok::saveLocation( "playlists" ) + result ) ); - QCOMPARE( testPlaylist->name(), QString( result ) ); - QCOMPARE( testPlaylist->tracks().size(), 1 ); - QFile::remove( Amarok::saveLocation( "playlists" ) + result ); -} - -void TestPlaylistFileProvider::testImportAndDeletePlaylists() -{ - m_testPlaylistFileProvider->deletePlaylists( m_testPlaylistFileProvider->playlists() ); - Playlists::PlaylistList tempList = m_testPlaylistFileProvider->playlists(); - QCOMPARE( tempList.size(), 0 ); - - QVERIFY( QFile::exists( dataPath( "data/playlists/test.m3u" ) ) ); - QFile::copy( dataPath( "data/playlists/test.m3u" ), QDir::tempPath() + QDir::separator() + "test.m3u" ); - QVERIFY( QFile::exists( QDir::tempPath() + QDir::separator() + "test.m3u" ) ); - - QVERIFY( m_testPlaylistFileProvider->import( QDir::tempPath() + QDir::separator() + "test.m3u" ) ); - tempList = m_testPlaylistFileProvider->playlists(); - QCOMPARE( tempList.size(), 1 ); - - m_testPlaylistFileProvider->deletePlaylists( tempList ); - tempList = m_testPlaylistFileProvider->playlists(); - QCOMPARE( tempList.size(), 0 ); -} - -void TestPlaylistFileProvider::testRename() -{ - m_testPlaylistFileProvider->deletePlaylists( m_testPlaylistFileProvider->playlists() ); - Playlists::PlaylistList tempList = m_testPlaylistFileProvider->playlists(); - QCOMPARE( tempList.size(), 0 ); - - QVERIFY( QFile::exists( dataPath( "data/playlists/test.m3u" ) ) ); - QFile::copy( dataPath( "data/playlists/test.m3u" ), QDir::tempPath() + QDir::separator() + "test.m3u" ); - QVERIFY( QFile::exists( QDir::tempPath() + QDir::separator() + "test.m3u" ) ); - - QVERIFY( m_testPlaylistFileProvider->import( QDir::tempPath() + QDir::separator() + "test.m3u" ) ); - tempList = m_testPlaylistFileProvider->playlists(); - QCOMPARE( tempList.size(), 1 ); - - m_testPlaylistFileProvider->renamePlaylist( tempList.at( 0 ), "New Test Name" ); - tempList = m_testPlaylistFileProvider->playlists(); - QCOMPARE( tempList.at( 0 )->name(), QString( "New Test Name.m3u" ) ); - - m_testPlaylistFileProvider->deletePlaylists( tempList ); - tempList = m_testPlaylistFileProvider->playlists(); - QCOMPARE( tempList.size(), 0 ); -} - -QString TestPlaylistFileProvider::dataPath( const QString &relPath ) -{ - return QDir::toNativeSeparators( QString( AMAROK_TEST_DIR ) + '/' + relPath ); -} - -void TestPlaylistFileProvider::removeTestPlaylist() -{ - const QString m3u = Amarok::saveLocation( "playlists" ) + "Amarok Test Playlist.m3u"; - if( QFile::exists( m3u ) ) - QFile::remove( m3u ); -} - -void TestPlaylistFileProvider::removeConfigPlaylistEntries() -{ - KConfigGroup config = Amarok::config( "Loaded Playlist Files" ); - config.deleteGroup(); -} diff --git a/amarok/tests/playlistmanager/file/TestPlaylistFileProvider.h b/amarok/tests/playlistmanager/file/TestPlaylistFileProvider.h deleted file mode 100644 index c2aa6878..00000000 --- a/amarok/tests/playlistmanager/file/TestPlaylistFileProvider.h +++ /dev/null @@ -1,53 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2009 Sven Krohlas * - * * - * This program 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 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#ifndef TESTPLAYLISTFILEPROVIDER_H -#define TESTPLAYLISTFILEPROVIDER_H - -#include -#include - -namespace Playlists { - class PlaylistFileProvider; -} - -class TestPlaylistFileProvider : public QObject -{ -Q_OBJECT - -public: - TestPlaylistFileProvider(); - -private slots: - void initTestCase(); - void cleanupTestCase(); - void testPlaylists(); - void testSave_data(); - void testSave(); - void testImportAndDeletePlaylists(); - void testRename(); - -private: - void removeTestPlaylist(); - void removeConfigPlaylistEntries(); - Playlists::PlaylistFileProvider *m_testPlaylistFileProvider; - QString dataPath( const QString &relPath ); -}; - -#endif // TESTPLAYLISTFILEPROVIDER_H diff --git a/amarok/tests/playlistmanager/sql/CMakeLists.txt b/amarok/tests/playlistmanager/sql/CMakeLists.txt deleted file mode 100644 index c801d4ac..00000000 --- a/amarok/tests/playlistmanager/sql/CMakeLists.txt +++ /dev/null @@ -1,21 +0,0 @@ -include_directories( . - ${AMAROK_SOURCE_TREE}/collection - ${AMAROK_SOURCE_TREE}/browsers/playlistbrowser - ${CMAKE_BINARY_DIR}/src - ${CMAKE_BINARY_DIR}/tests -) - -#------------------------ Test SqlUserPlaylistProvider ----------------------------- - -set( testsqluserplaylistprovider_SRCS - TestSqlUserPlaylistProvider.cpp - ${AMAROK_SOURCE_TREE}/playlistmanager/sql/SqlUserPlaylistProvider.cpp - ${AMAROK_SOURCE_TREE}/playlistmanager/sql/SqlPlaylistGroup.cpp - ${AMAROK_SOURCE_TREE}/playlistmanager/sql/SqlPlaylist.cpp - ${AMAROK_SOURCE_TREE}/core-impl/meta/timecode/TimecodeMeta.cpp - ${AMAROK_SOURCE_TREE}/core-impl/capabilities/timecode/TimecodeBoundedPlaybackCapability.cpp - ${AMAROK_SOURCE_TREE}/core/capabilities/BoundedPlaybackCapability.cpp - ${AMAROK_SOURCE_TREE}/core-impl/playlists/types/file/PlaylistFileSupport.cpp - ) -kde4_add_unit_test( testsqluserplaylistprovider ${testsqluserplaylistprovider_SRCS} ) -target_link_libraries( testsqluserplaylistprovider ${KDE4_KDEUI_LIBS} ${KDE4_KIO_LIBS} ${QT_QTTEST_LIBRARY} ${QT_QTCORE_LIBRARY} amarokcore amaroklib ) diff --git a/amarok/tests/playlistmanager/sql/TestSqlUserPlaylistProvider.cpp b/amarok/tests/playlistmanager/sql/TestSqlUserPlaylistProvider.cpp deleted file mode 100644 index dfc651eb..00000000 --- a/amarok/tests/playlistmanager/sql/TestSqlUserPlaylistProvider.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2009 Sven Krohlas * - * * - * This program 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 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#include "TestSqlUserPlaylistProvider.h" - -#include "EngineController.h" -#include "config-amarok-test.h" -#include "core/meta/Meta.h" -#include "core/support/Components.h" -#include "core-impl/collections/support/CollectionManager.h" -#include "playlistmanager/sql/SqlUserPlaylistProvider.h" - -#include -#include - -#include - -QTEST_KDEMAIN( TestSqlUserPlaylistProvider, GUI ) - -TestSqlUserPlaylistProvider::TestSqlUserPlaylistProvider() -{} - -QString -TestSqlUserPlaylistProvider::dataPath( const QString &relPath ) -{ - return QDir::toNativeSeparators( QString( AMAROK_TEST_DIR ) + '/' + relPath ); -} - -void TestSqlUserPlaylistProvider::initTestCase() -{ - m_testSqlUserPlaylistProvider = new Playlists::SqlUserPlaylistProvider( true ); - m_testSqlUserPlaylistProvider->deletePlaylists( m_testSqlUserPlaylistProvider->playlists() ); -} - -void TestSqlUserPlaylistProvider::cleanupTestCase() -{ - delete m_testSqlUserPlaylistProvider; -} - -void TestSqlUserPlaylistProvider::testPlaylists() -{ - Playlists::PlaylistList tempList = m_testSqlUserPlaylistProvider->playlists(); - QCOMPARE( tempList.size(), 0 ); -} - -void TestSqlUserPlaylistProvider::testSave() -{ - Meta::TrackList tempTrackList; - KUrl trackUrl; - trackUrl = dataPath( "data/audio/Platz 01.mp3" ); - tempTrackList.append( CollectionManager::instance()->trackForUrl( trackUrl ) ); - - Playlists::PlaylistPtr testPlaylist = - m_testSqlUserPlaylistProvider->save( tempTrackList, "Amarok Test Playlist" ); - - QCOMPARE( testPlaylist->name(), QString( "Amarok Test Playlist" ) ); - QCOMPARE( testPlaylist->tracks().size(), 1 ); - - Playlists::PlaylistList tempList = m_testSqlUserPlaylistProvider->playlists(); - QCOMPARE( tempList.size(), 1 ); -} - -void TestSqlUserPlaylistProvider::testRename() -{ - Playlists::PlaylistList tempList = m_testSqlUserPlaylistProvider->playlists(); - m_testSqlUserPlaylistProvider->renamePlaylist( tempList.at( 0 ), "New Test Name" ); - QCOMPARE( tempList.at( 0 )->name(), QString( "New Test Name" ) ); -} - -void TestSqlUserPlaylistProvider::testDelete() -{ - Playlists::PlaylistList tempList = m_testSqlUserPlaylistProvider->playlists(); - m_testSqlUserPlaylistProvider->deletePlaylists( tempList ); - QCOMPARE( m_testSqlUserPlaylistProvider->playlists().size(), 0 ); -} diff --git a/amarok/tests/playlistmanager/sql/TestSqlUserPlaylistProvider.h b/amarok/tests/playlistmanager/sql/TestSqlUserPlaylistProvider.h deleted file mode 100644 index 284fa4bd..00000000 --- a/amarok/tests/playlistmanager/sql/TestSqlUserPlaylistProvider.h +++ /dev/null @@ -1,50 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2009 Sven Krohlas * - * * - * This program 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 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#ifndef TESTSQLUSERPLAYLISTPROVIDER_H -#define TESTSQLUSERPLAYLISTPROVIDER_H - -#include -#include - -namespace Playlists { - class SqlUserPlaylistProvider; -} - -class TestSqlUserPlaylistProvider : public QObject -{ -Q_OBJECT - -public: - TestSqlUserPlaylistProvider(); - -private slots: - void initTestCase(); - void cleanupTestCase(); - void testPlaylists(); - void testSave(); - void testRename(); - void testDelete(); - -private: - Playlists::SqlUserPlaylistProvider *m_testSqlUserPlaylistProvider; - QString dataPath( const QString &relPath ); -}; - -#endif // TESTSQLUSERPLAYLISTPROVIDER_H diff --git a/amarok/tests/qt-modeltest/modeltest.cpp b/amarok/tests/qt-modeltest/modeltest.cpp deleted file mode 100644 index df65bb85..00000000 --- a/amarok/tests/qt-modeltest/modeltest.cpp +++ /dev/null @@ -1,539 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2007 Trolltech ASA. All rights reserved. -** -** This file is part of the Qt Concurrent project on Trolltech Labs. -** -** This file may be used under the terms of the GNU General Public -** License version 2.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of -** this file. Please review the following information to ensure GNU -** General Public Licensing requirements will be met: -** http://www.trolltech.com/products/qt/opensource.html -** -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://www.trolltech.com/products/qt/licensing.html or contact the -** sales department at sales@trolltech.com. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -****************************************************************************/ - -#include - -#include "modeltest.h" - -Q_DECLARE_METATYPE(QModelIndex) - -/*! - Connect to all of the models signals. Whenever anything happens recheck everything. -*/ -ModelTest::ModelTest(QAbstractItemModel *_model, QObject *parent) : QObject(parent), model(_model), fetchingMore(false) -{ - Q_ASSERT(model); - - connect(model, SIGNAL(columnsAboutToBeInserted(QModelIndex,int,int)), - this, SLOT(runAllTests())); - connect(model, SIGNAL(columnsAboutToBeRemoved(QModelIndex,int,int)), - this, SLOT(runAllTests())); - connect(model, SIGNAL(columnsInserted(QModelIndex,int,int)), - this, SLOT(runAllTests())); - connect(model, SIGNAL(columnsRemoved(QModelIndex,int,int)), - this, SLOT(runAllTests())); - connect(model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), - this, SLOT(runAllTests())); - connect(model, SIGNAL(headerDataChanged(Qt::Orientation,int,int)), - this, SLOT(runAllTests())); - connect(model, SIGNAL(layoutAboutToBeChanged()), this, SLOT(runAllTests())); - connect(model, SIGNAL(layoutChanged()), this, SLOT(runAllTests())); - connect(model, SIGNAL(modelReset()), this, SLOT(runAllTests())); - connect(model, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)), - this, SLOT(runAllTests())); - connect(model, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)), - this, SLOT(runAllTests())); - connect(model, SIGNAL(rowsInserted(QModelIndex,int,int)), - this, SLOT(runAllTests())); - connect(model, SIGNAL(rowsRemoved(QModelIndex,int,int)), - this, SLOT(runAllTests())); - - // Special checks for inserting/removing - connect(model, SIGNAL(layoutAboutToBeChanged()), - this, SLOT(layoutAboutToBeChanged())); - connect(model, SIGNAL(layoutChanged()), - this, SLOT(layoutChanged())); - - connect(model, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)), - this, SLOT(rowsAboutToBeInserted(QModelIndex,int,int))); - connect(model, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)), - this, SLOT(rowsAboutToBeRemoved(QModelIndex,int,int))); - connect(model, SIGNAL(rowsInserted(QModelIndex,int,int)), - this, SLOT(rowsInserted(QModelIndex,int,int))); - connect(model, SIGNAL(rowsRemoved(QModelIndex,int,int)), - this, SLOT(rowsRemoved(QModelIndex,int,int))); - - runAllTests(); -} - -void ModelTest::runAllTests() -{ - if (fetchingMore) - return; - nonDestructiveBasicTest(); - rowCount(); - columnCount(); - hasIndex(); - index(); - parent(); - data(); -} - -/*! - nonDestructiveBasicTest tries to call a number of the basic functions (not all) - to make sure the model doesn't outright segfault, testing the functions that makes sense. -*/ -void ModelTest::nonDestructiveBasicTest() -{ - Q_ASSERT(model->buddy(QModelIndex()) == QModelIndex()); - model->canFetchMore(QModelIndex()); - Q_ASSERT(model->columnCount(QModelIndex()) >= 0); - Q_ASSERT(model->data(QModelIndex()) == QVariant()); - fetchingMore = true; - model->fetchMore(QModelIndex()); - fetchingMore = false; - Qt::ItemFlags flags = model->flags(QModelIndex()); - Q_ASSERT(flags == Qt::ItemIsDropEnabled || flags == 0); - model->hasChildren(QModelIndex()); - model->hasIndex(0, 0); - model->headerData(0, Qt::Horizontal); - model->index(0, 0); - Q_ASSERT(model->index(-1, -1) == QModelIndex()); - model->itemData(QModelIndex()); - QVariant cache; - model->match(QModelIndex(), -1, cache); - model->mimeTypes(); - Q_ASSERT(model->parent(QModelIndex()) == QModelIndex()); - Q_ASSERT(model->rowCount() >= 0); - QVariant variant; - model->setData(QModelIndex(), variant, -1); - model->setHeaderData(-1, Qt::Horizontal, QVariant()); - model->setHeaderData(0, Qt::Horizontal, QVariant()); - model->setHeaderData(999999, Qt::Horizontal, QVariant()); - QMap roles; - model->sibling(0, 0, QModelIndex()); - model->span(QModelIndex()); - model->supportedDropActions(); -} - -/*! - Tests model's implementation of QAbstractItemModel::rowCount() and hasChildren() - - Models that are dynamically populated are not as fully tested here. - */ -void ModelTest::rowCount() -{ - // check top row - QModelIndex topIndex = model->index(0, 0, QModelIndex()); - int rows = model->rowCount(topIndex); - Q_ASSERT(rows >= 0); - if (rows > 0) - Q_ASSERT(model->hasChildren(topIndex) == true); - - QModelIndex secondLevelIndex = model->index(0, 0, topIndex); - if (secondLevelIndex.isValid()) { // not the top level - // check a row count where parent is valid - rows = model->rowCount(secondLevelIndex); - Q_ASSERT(rows >= 0); - if (rows > 0) - Q_ASSERT(model->hasChildren(secondLevelIndex) == true); - } - - // The models rowCount() is tested more extensively in checkChildren(), - // but this catches the big mistakes -} - -/*! - Tests model's implementation of QAbstractItemModel::columnCount() and hasChildren() - */ -void ModelTest::columnCount() -{ - // check top row - QModelIndex topIndex = model->index(0, 0, QModelIndex()); - Q_ASSERT(model->columnCount(topIndex) >= 0); - - // check a column count where parent is valid - QModelIndex childIndex = model->index(0, 0, topIndex); - if (childIndex.isValid()) - Q_ASSERT(model->columnCount(childIndex) >= 0); - - // columnCount() is tested more extensively in checkChildren(), - // but this catches the big mistakes -} - -/*! - Tests model's implementation of QAbstractItemModel::hasIndex() - */ -void ModelTest::hasIndex() -{ - // Make sure that invalid values returns an invalid index - Q_ASSERT(model->hasIndex(-2, -2) == false); - Q_ASSERT(model->hasIndex(-2, 0) == false); - Q_ASSERT(model->hasIndex(0, -2) == false); - - int rows = model->rowCount(); - int columns = model->columnCount(); - - // check out of bounds - Q_ASSERT(model->hasIndex(rows, columns) == false); - Q_ASSERT(model->hasIndex(rows + 1, columns + 1) == false); - - if (rows > 0) - Q_ASSERT(model->hasIndex(0, 0) == true); - - // hasIndex() is tested more extensively in checkChildren(), - // but this catches the big mistakes -} - -/*! - Tests model's implementation of QAbstractItemModel::index() - */ -void ModelTest::index() -{ - // Make sure that invalid values returns an invalid index - Q_ASSERT(model->index(-2, -2) == QModelIndex()); - Q_ASSERT(model->index(-2, 0) == QModelIndex()); - Q_ASSERT(model->index(0, -2) == QModelIndex()); - - int rows = model->rowCount(); - int columns = model->columnCount(); - - if (rows == 0) - return; - - // Catch off by one errors - Q_ASSERT(model->index(rows, columns) == QModelIndex()); - Q_ASSERT(model->index(0, 0).isValid() == true); - - // Make sure that the same index is *always* returned - QModelIndex a = model->index(0, 0); - QModelIndex b = model->index(0, 0); - Q_ASSERT(a == b); - - // index() is tested more extensively in checkChildren(), - // but this catches the big mistakes -} - -/*! - Tests model's implementation of QAbstractItemModel::parent() - */ -void ModelTest::parent() -{ - // Make sure the model wont crash and will return an invalid QModelIndex - // when asked for the parent of an invalid index. - Q_ASSERT(model->parent(QModelIndex()) == QModelIndex()); - - if (model->rowCount() == 0) - return; - - // Column 0 | Column 1 | - // QModelIndex() | | - // \- topIndex | topIndex1 | - // \- childIndex | childIndex1 | - - // Common error test #1, make sure that a top level index has a parent - // that is a invalid QModelIndex. - QModelIndex topIndex = model->index(0, 0, QModelIndex()); - Q_ASSERT(model->parent(topIndex) == QModelIndex()); - - // Common error test #2, make sure that a second level index has a parent - // that is the first level index. - if (model->rowCount(topIndex) > 0) { - QModelIndex childIndex = model->index(0, 0, topIndex); - Q_ASSERT(model->parent(childIndex) == topIndex); - } - - // Common error test #3, the second column should NOT have the same children - // as the first column in a row. - // Usually the second column shouldn't have children. - QModelIndex topIndex1 = model->index(0, 1, QModelIndex()); - if (model->rowCount(topIndex1) > 0) { - QModelIndex childIndex = model->index(0, 0, topIndex); - QModelIndex childIndex1 = model->index(0, 0, topIndex1); - Q_ASSERT(childIndex != childIndex1); - } - - // Full test, walk n levels deep through the model making sure that all - // parent's children correctly specify their parent. - checkChildren(QModelIndex()); -} - -/*! - Called from the parent() test. - - A model that returns an index of parent X should also return X when asking - for the parent of the index. - - This recursive function does pretty extensive testing on the whole model in an - effort to catch edge cases. - - This function assumes that rowCount(), columnCount() and index() already work. - If they have a bug it will point it out, but the above tests should have already - found the basic bugs because it is easier to figure out the problem in - those tests then this one. - */ -void ModelTest::checkChildren(const QModelIndex &parent, int currentDepth) -{ - // First just try walking back up the tree. - QModelIndex p = parent; - while (p.isValid()) - p = p.parent(); - - // For models that are dynamically populated - if (model->canFetchMore(parent)) { - fetchingMore = true; - model->fetchMore(parent); - fetchingMore = false; - } - - int rows = model->rowCount(parent); - int columns = model->columnCount(parent); - - if (rows > 0) - Q_ASSERT(model->hasChildren(parent)); - - // Some further testing against rows(), columns(), and hasChildren() - Q_ASSERT(rows >= 0); - Q_ASSERT(columns >= 0); - if (rows > 0) - Q_ASSERT(model->hasChildren(parent) == true); - - //qDebug() << "parent:" << model->data(parent).toString() << "rows:" << rows - // << "columns:" << columns << "parent column:" << parent.column(); - - Q_ASSERT(model->hasIndex(rows + 1, 0, parent) == false); - for (int r = 0; r < rows; ++r) { - if (model->canFetchMore(parent)) { - fetchingMore = true; - model->fetchMore(parent); - fetchingMore = false; - } - Q_ASSERT(model->hasIndex(r, columns + 1, parent) == false); - for (int c = 0; c < columns; ++c) { - Q_ASSERT(model->hasIndex(r, c, parent) == true); - QModelIndex index = model->index(r, c, parent); - // rowCount() and columnCount() said that it existed... - Q_ASSERT(index.isValid() == true); - - // index() should always return the same index when called twice in a row - QModelIndex modifiedIndex = model->index(r, c, parent); - Q_ASSERT(index == modifiedIndex); - - // Make sure we get the same index if we request it twice in a row - QModelIndex a = model->index(r, c, parent); - QModelIndex b = model->index(r, c, parent); - Q_ASSERT(a == b); - - // Some basic checking on the index that is returned - Q_ASSERT(index.model() == model); - Q_ASSERT(index.row() == r); - Q_ASSERT(index.column() == c); - // While you can technically return a QVariant usually this is a sign - // of an bug in data() Disable if this really is ok in your model. - //Q_ASSERT(model->data(index, Qt::DisplayRole).isValid() == true); - - // If the next test fails here is some somewhat useful debug you play with. - /* - if (model->parent(index) != parent) { - qDebug() << r << c << currentDepth << model->data(index).toString() - << model->data(parent).toString(); - qDebug() << index << parent << model->parent(index); - // And a view that you can even use to show the model. - //QTreeView view; - //view.setModel(model); - //view.show(); - }*/ - - // Check that we can get back our real parent. - QModelIndex p = model->parent(index); - //qDebug() << "child:" << index; - //qDebug() << p; - //qDebug() << parent; - Q_ASSERT(model->parent(index) == parent); - - // recursively go down the children - if (model->hasChildren(index) && currentDepth < 10 ) { - //qDebug() << r << c << "has children" << model->rowCount(index); - checkChildren(index, ++currentDepth); - }/* else { if (currentDepth >= 10) qDebug() << "checked 10 deep"; };*/ - - // make sure that after testing the children that the index doesn't change. - QModelIndex newerIndex = model->index(r, c, parent); - Q_ASSERT(index == newerIndex); - } - } -} - -/*! - Tests model's implementation of QAbstractItemModel::data() - */ -void ModelTest::data() -{ - // Invalid index should return an invalid qvariant - Q_ASSERT(!model->data(QModelIndex()).isValid()); - - if (model->rowCount() == 0) - return; - - // A valid index should have a valid QVariant data - Q_ASSERT(model->index(0, 0).isValid()); - - // shouldn't be able to set data on an invalid index - Q_ASSERT(model->setData(QModelIndex(), QLatin1String("foo"), Qt::DisplayRole) == false); - - // General Purpose roles that should return a QString - QVariant variant = model->data(model->index(0, 0), Qt::ToolTipRole); - if (variant.isValid()) { - Q_ASSERT(qVariantCanConvert(variant)); - } - variant = model->data(model->index(0, 0), Qt::StatusTipRole); - if (variant.isValid()) { - Q_ASSERT(qVariantCanConvert(variant)); - } - variant = model->data(model->index(0, 0), Qt::WhatsThisRole); - if (variant.isValid()) { - Q_ASSERT(qVariantCanConvert(variant)); - } - - // General Purpose roles that should return a QSize - variant = model->data(model->index(0, 0), Qt::SizeHintRole); - if (variant.isValid()) { - Q_ASSERT(qVariantCanConvert(variant)); - } - - // General Purpose roles that should return a QFont - QVariant fontVariant = model->data(model->index(0, 0), Qt::FontRole); - if (fontVariant.isValid()) { - Q_ASSERT(qVariantCanConvert(fontVariant)); - } - - // Check that the alignment is one we know about - QVariant textAlignmentVariant = model->data(model->index(0, 0), Qt::TextAlignmentRole); - if (textAlignmentVariant.isValid()) { - int alignment = textAlignmentVariant.toInt(); - Q_ASSERT(alignment == Qt::AlignLeft || - alignment == Qt::AlignRight || - alignment == Qt::AlignHCenter || - alignment == Qt::AlignJustify || - alignment == Qt::AlignTop || - alignment == Qt::AlignBottom || - alignment == Qt::AlignVCenter || - alignment == Qt::AlignCenter || - alignment == Qt::AlignAbsolute || - alignment == Qt::AlignLeading || - alignment == Qt::AlignTrailing); - } - - // General Purpose roles that should return a QColor - QVariant colorVariant = model->data(model->index(0, 0), Qt::BackgroundColorRole); - if (colorVariant.isValid()) { - Q_ASSERT(qVariantCanConvert(colorVariant)); - } - - colorVariant = model->data(model->index(0, 0), Qt::TextColorRole); - if (colorVariant.isValid()) { - Q_ASSERT(qVariantCanConvert(colorVariant)); - } - - // Check that the "check state" is one we know about. - QVariant checkStateVariant = model->data(model->index(0, 0), Qt::CheckStateRole); - if (checkStateVariant.isValid()) { - int state = checkStateVariant.toInt(); - Q_ASSERT(state == Qt::Unchecked || - state == Qt::PartiallyChecked || - state == Qt::Checked); - } -} - -/*! - Store what is about to be inserted to make sure it actually happens - - \sa rowsInserted() - */ -void ModelTest::rowsAboutToBeInserted(const QModelIndex &parent, int start, int end) -{ - Q_UNUSED(end); - Changing c; - c.parent = parent; - c.oldSize = model->rowCount(parent); - c.last = model->data(model->index(start - 1, 0, parent)); - c.next = model->data(model->index(start, 0, parent)); - insert.push(c); -} - -/*! - Confirm that what was said was going to happen actually did - - \sa rowsAboutToBeInserted() - */ -void ModelTest::rowsInserted(const QModelIndex & parent, int start, int end) -{ - Changing c = insert.pop(); - Q_ASSERT(c.parent == parent); - Q_ASSERT(c.oldSize + (end - start + 1) == model->rowCount(parent)); - Q_ASSERT(c.last == model->data(model->index(start - 1, 0, c.parent))); - /* - if (c.next != model->data(model->index(end + 1, 0, c.parent))) { - qDebug() << start << end; - for (int i=0; i < model->rowCount(); ++i) - qDebug() << model->index(i, 0).data().toString(); - qDebug() << c.next << model->data(model->index(end + 1, 0, c.parent)); - } - */ - Q_ASSERT(c.next == model->data(model->index(end + 1, 0, c.parent))); -} - -void ModelTest::layoutAboutToBeChanged() -{ - for (int i = 0; i < qBound(0, model->rowCount(), 100); ++i) - changing.append(QPersistentModelIndex(model->index(i, 0))); -} - -void ModelTest::layoutChanged() -{ - for (int i = 0; i < changing.count(); ++i) { - QPersistentModelIndex p = changing[i]; - Q_ASSERT(p == model->index(p.row(), p.column(), p.parent())); - } - changing.clear(); -} - -/*! - Store what is about to be inserted to make sure it actually happens - - \sa rowsRemoved() - */ -void ModelTest::rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end) -{ - Changing c; - c.parent = parent; - c.oldSize = model->rowCount(parent); - c.last = model->data(model->index(start - 1, 0, parent)); - c.next = model->data(model->index(end + 1, 0, parent)); - remove.push(c); -} - -/*! - Confirm that what was said was going to happen actually did - - \sa rowsAboutToBeRemoved() - */ -void ModelTest::rowsRemoved(const QModelIndex & parent, int start, int end) -{ - Changing c = remove.pop(); - Q_ASSERT(c.parent == parent); - Q_ASSERT(c.oldSize - (end - start + 1) == model->rowCount(parent)); - Q_ASSERT(c.last == model->data(model->index(start - 1, 0, c.parent))); - Q_ASSERT(c.next == model->data(model->index(start, 0, c.parent))); -} - diff --git a/amarok/tests/qt-modeltest/modeltest.h b/amarok/tests/qt-modeltest/modeltest.h deleted file mode 100644 index 38b6b2be..00000000 --- a/amarok/tests/qt-modeltest/modeltest.h +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2007 Trolltech ASA. All rights reserved. -** -** This file is part of the Qt Concurrent project on Trolltech Labs. -** -** This file may be used under the terms of the GNU General Public -** License version 2.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of -** this file. Please review the following information to ensure GNU -** General Public Licensing requirements will be met: -** http://www.trolltech.com/products/qt/opensource.html -** -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://www.trolltech.com/products/qt/licensing.html or contact the -** sales department at sales@trolltech.com. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -****************************************************************************/ - -#ifndef MODELTEST_H -#define MODELTEST_H - -#include -#include -#include - -class ModelTest : public QObject -{ - Q_OBJECT - -public: - ModelTest(QAbstractItemModel *model, QObject *parent = 0); - -private Q_SLOTS: - void nonDestructiveBasicTest(); - void rowCount(); - void columnCount(); - void hasIndex(); - void index(); - void parent(); - void data(); - -protected Q_SLOTS: - void runAllTests(); - void layoutAboutToBeChanged(); - void layoutChanged(); - void rowsAboutToBeInserted(const QModelIndex &parent, int start, int end); - void rowsInserted(const QModelIndex & parent, int start, int end); - void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end); - void rowsRemoved(const QModelIndex & parent, int start, int end); - -private: - void checkChildren(const QModelIndex &parent, int currentDepth = 0); - - QAbstractItemModel *model; - - struct Changing - { - QModelIndex parent; - int oldSize; - QVariant last; - QVariant next; - }; - QStack insert; - QStack remove; - - bool fetchingMore; - - QList changing; -}; - -#endif diff --git a/amarok/tests/scanner/CMakeLists.txt b/amarok/tests/scanner/CMakeLists.txt deleted file mode 100644 index 347b5e2c..00000000 --- a/amarok/tests/scanner/CMakeLists.txt +++ /dev/null @@ -1,59 +0,0 @@ -macro(add_database_test test_target test_sources) - if(APPLE) - #one cannot link to plugins on OS X. As a workaround, add anything relevant that goes into the mysqle plugin to each test - set( test_sources_internal - ${test_sources} ) - endif(APPLE) - - kde4_add_unit_test( ${test_target} TESTNAME ${test_target} - ${test_sources} - ${test_sources_internal} - ${GOOGLEMOCK_SRCS} - ) - - if(APPLE) - SET_TARGET_PROPERTIES(${test_target} PROPERTIES LINK_FLAGS "-undefined dynamic_lookup") - endif(APPLE) - - add_dependencies( ${test_target} amarokconfig_h ) - add_dependencies( ${test_target} amarokcore ) - add_dependencies( ${test_target} amaroklib) - add_dependencies( ${test_target} amarokshared) - - target_link_libraries(${test_target} - amarokcore - amaroklib - amarokshared - ${KDE4_KDECORE_LIBS} - ${KDE4_KIO_LIBS} - ${KDE4_THREADWEAVER_LIBS} - ${KDE4_KDEUI_LIBS} - ${QT_QTTEST_LIBRARY} - ${QT_QTCORE_LIBRARY} - ${CMAKE_DL_LIBS} - ${ZLIB_LIBRARIES} - ${GOOGLEMOCK_LIBRARIES}) - -endmacro(add_database_test) - - -include_directories( - ${AMAROK_TEST_TREE} - ${AMAROK_SOURCE_TREE} - ${AMAROK_SOURCE_TREE}/core-impl/logger - ${AMAROK_UTILITY_TREE} - ${CMAKE_BINARY_DIR}/src - ${CMAKE_BINARY_DIR}/tests - ${AMAROK_COLLECTION_SUPPORT_DIR} - ${KDE4_INCLUDE_DIR} - ${QT_INCLUDES} - ) - -#-------------------------------- Test SqlScanManager ----------------------- - -set( testgenericscanmanager_SRCS - TestGenericScanManager.cpp - ) - -add_database_test( testgenericscanmanager "${testgenericscanmanager_SRCS}" ) - diff --git a/amarok/tests/scanner/TestGenericScanManager.cpp b/amarok/tests/scanner/TestGenericScanManager.cpp deleted file mode 100644 index 5f2daf8e..00000000 --- a/amarok/tests/scanner/TestGenericScanManager.cpp +++ /dev/null @@ -1,380 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Maximilian Kossick * - * Copyright (c) 2010-2013 Ralf Engels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "TestGenericScanManager.h" - -#include "amarokconfig.h" -#include "MetaTagLib.h" -#include "scanner/GenericScanManager.h" - -#include "config-amarok-test.h" - -#include - -#include -#include -#include - -QTEST_KDEMAIN_CORE( TestGenericScanManager ) - -TestGenericScanManager::TestGenericScanManager() - : QObject() -{ - // QString help = i18n("Amarok"); // prevent a bug when the scanner is the first thread creating a translator -} - -void -TestGenericScanManager::initTestCase() -{ - // setenv( "LC_ALL", "", 1 ); // this breakes the test - // Amarok does not force LC_ALL=C but obviously the test does it which - // will prevent scanning of files with umlauts. - - // that is the original mp3 file that we use to generate the "real" tracks - m_sourcePath = QDir::toNativeSeparators( QString( AMAROK_TEST_DIR ) + "/data/audio/Platz 01.mp3" ); - QVERIFY( QFile::exists( m_sourcePath ) ); - - m_scanManager = new GenericScanManager( this ); - - connect( m_scanManager, SIGNAL(started(GenericScanManager::ScanType)), - SLOT(slotStarted(GenericScanManager::ScanType)) ); - connect( m_scanManager, SIGNAL(directoryCount(int)), SLOT(slotDirectoryCount(int)) ); - connect( m_scanManager, SIGNAL(directoryScanned(QSharedPointer)), - SLOT(slotDirectoryScanned(QSharedPointer)) ); - connect( m_scanManager, SIGNAL(succeeded()), SLOT(slotSucceeded()) ); - connect( m_scanManager, SIGNAL(failed(QString)), SLOT(slotFailed(QString)) ); - - AmarokConfig::setScanRecursively( true ); - AmarokConfig::setMonitorChanges( false ); - - // switch on writing back so that we can create the test files with all the information - AmarokConfig::setWriteBack( true ); - AmarokConfig::setWriteBackStatistics( true ); - AmarokConfig::setWriteBackCover( true ); -} - -void -TestGenericScanManager::cleanupTestCase() -{ } - -void -TestGenericScanManager::init() -{ - m_tmpCollectionDir = new KTempDir(); - QVERIFY( m_tmpCollectionDir->exists() ); - - QStringList collectionFolders; - collectionFolders << m_tmpCollectionDir->name(); - - m_started = false; - m_finished = false; - - m_scannedDirsCount = 0; - m_scannedTracksCount = 0; - m_scannedCoversCount = 0; -} - -void -TestGenericScanManager::cleanup() -{ - m_scanManager->abort(); - delete m_tmpCollectionDir; -} - -void -TestGenericScanManager::testScanSingle() -{ - createSingleTrack(); - fullScanAndWait(); - - QCOMPARE( m_scannedDirsCount, 3 ); - QCOMPARE( m_scannedTracksCount, 1 ); - QCOMPARE( m_scannedCoversCount, 0 ); -} - -void -TestGenericScanManager::testScanDirectory() -{ - createAlbum(); - fullScanAndWait(); - - // -- check the commit - QCOMPARE( m_scannedDirsCount, 3 ); - QCOMPARE( m_scannedTracksCount, 9 ); - QCOMPARE( m_scannedCoversCount, 0 ); -} - -void -TestGenericScanManager::testRestartScanner() -{ -#ifndef QT_NO_DEBUG - createAlbum(); - - // the scanner crashes at a special file: - Meta::FieldHash values; - values.clear(); - values.insert( Meta::valUniqueId, QVariant("c6c29f50279ab9523a0f44928bc1e96b") ); - values.insert( Meta::valUrl, QVariant("Thriller/crash_amarok_here.ogg") ); - createTrack( values ); - - fullScanAndWait(); - - // -- check the commit - QCOMPARE( m_scannedDirsCount, 4 ); - QCOMPARE( m_scannedTracksCount, 9 ); - QCOMPARE( m_scannedCoversCount, 0 ); - -#else - QSKIP( "Collection scanner only crashes in debug build.", SkipAll ); -#endif -} - -void -TestGenericScanManager::testAlbumImage() -{ - createSingleTrack(); - createAlbum(); - - // put an image into the album directory - QString imageSourcePath = QDir::toNativeSeparators( QString( AMAROK_TEST_DIR ) + "/data/playlists/no-playlist.png" ); - QVERIFY( QFile::exists( imageSourcePath ) ); - QString targetPath; - targetPath = m_tmpCollectionDir->name() + "Pop/Thriller/cover.png"; - QVERIFY( QFile::copy( m_sourcePath, targetPath ) ); - - // set an embedded image - targetPath = m_tmpCollectionDir->name() + "Various Artists/Big Screen Adventures/28 - Theme From Armageddon.mp3"; - Meta::Tag::setEmbeddedCover( targetPath, QImage( 200, 200, QImage::Format_RGB32 ) ); - - fullScanAndWait(); - - // -- check the commit - QCOMPARE( m_scannedDirsCount, 5 ); - QCOMPARE( m_scannedTracksCount, 10 ); - QCOMPARE( m_scannedCoversCount, 1 ); -} - -void -TestGenericScanManager::slotStarted( GenericScanManager::ScanType type ) -{ - Q_UNUSED( type ); - - QVERIFY( !m_started ); - QVERIFY( !m_finished ); - - m_started = true; -} - -void -TestGenericScanManager::slotDirectoryCount( int count ) -{ - Q_UNUSED( count ); - - QVERIFY( m_started ); - QVERIFY( !m_finished ); -} - -void -TestGenericScanManager::slotDirectoryScanned( QSharedPointer dir ) -{ - QVERIFY( m_started ); - QVERIFY( !m_finished ); - - m_scannedDirsCount += 1; - m_scannedTracksCount += dir->tracks().count(); - m_scannedCoversCount += dir->covers().count(); -} - -void -TestGenericScanManager::slotSucceeded() -{ - QVERIFY( m_started ); - QVERIFY( !m_finished ); - - m_finished = true; -} - -void -TestGenericScanManager::slotFailed( const QString& message ) -{ - Q_UNUSED( message ); - - QVERIFY( m_started ); - QVERIFY( !m_finished ); - - m_finished = true; -} - -void -TestGenericScanManager::fullScanAndWait() -{ - QList urls; - urls << KUrl::fromPath( m_tmpCollectionDir->name() ); - - m_scanManager->requestScan( urls ); - waitScannerFinished(); - - QVERIFY( m_started ); - QVERIFY( m_finished ); -} - -void -TestGenericScanManager::waitScannerFinished() -{ - QVERIFY( m_scanManager->isRunning() ); - QVERIFY2( QTest::kWaitForSignal( m_scanManager, SIGNAL(succeeded()), 60*1000 ), - "ScanManager didn't finish scan within timeout" ); - QVERIFY( !m_scanManager->isRunning() ); -} - -void -TestGenericScanManager::createTrack( const Meta::FieldHash &values ) -{ - // -- copy the file from our original - QVERIFY( values.contains( Meta::valUrl ) ); - const QString targetPath = m_tmpCollectionDir->name() + values.value( Meta::valUrl ).toString(); - QVERIFY( QDir( m_tmpCollectionDir->name() ).mkpath( QFileInfo( values.value( Meta::valUrl ).toString() ).path() ) ); - - QVERIFY( QFile::copy( m_sourcePath, targetPath ) ); - - // -- set all the values that we need - Meta::Tag::writeTags( targetPath, values, true ); -} - -void -TestGenericScanManager::createSingleTrack() -{ - Meta::FieldHash values; - - values.insert( Meta::valUniqueId, QVariant("794b1bd040d5dd9b5b45c1494d84cc82") ); - values.insert( Meta::valUrl, QVariant("Various Artists/Big Screen Adventures/28 - Theme From Armageddon.mp3") ); - values.insert( Meta::valFormat, QVariant("1") ); - values.insert( Meta::valTitle, QVariant("Theme From Armageddon") ); - values.insert( Meta::valArtist, QVariant("Soundtrack & Theme Orchestra") ); - values.insert( Meta::valAlbumArtist, QVariant("Theme Orchestra") ); - values.insert( Meta::valAlbum, QVariant("Big Screen Adventures") ); - values.insert( Meta::valComposer, QVariant("Unknown Composer") ); - values.insert( Meta::valComment, QVariant("Amazon.com Song ID: 210541237") ); - values.insert( Meta::valGenre, QVariant("Broadway & Vocalists") ); - values.insert( Meta::valYear, QVariant(2009) ); - values.insert( Meta::valTrackNr, QVariant(28) ); - // values.insert( Meta::valBitrate, QVariant(216) ); // the bitrate can not be set. it's computed - // values.insert( Meta::valLength, QVariant(184000) ); // also can't be set - // values.insert( Meta::valSamplerate, QVariant(44100) ); // again - // values.insert( Meta::valFilesize, QVariant(5094892) ); // again - values.insert( Meta::valScore, QVariant(0.875) ); - values.insert( Meta::valPlaycount, QVariant(5) ); - // TODO: set an embedded cover - - createTrack( values ); -} - -void -TestGenericScanManager::createAlbum() -{ - Meta::FieldHash values; - - values.insert( Meta::valUniqueId, QVariant("1dc7022c52a3e4c51b46577da9b3c8ff") ); - values.insert( Meta::valUrl, QVariant("Pop/Thriller/Thriller - 01 - Michael Jackson - Track01.mp3") ); - values.insert( Meta::valTitle, QVariant("Wanna Be Startin' Somethin'") ); - values.insert( Meta::valArtist, QVariant("Michael Jackson") ); - values.insert( Meta::valAlbum, QVariant("Thriller") ); - values.insert( Meta::valYear, QVariant(1982) ); - values.insert( Meta::valTrackNr, QVariant(1) ); - createTrack( values ); - - values.clear(); - values.insert( Meta::valUniqueId, QVariant("1dc708934a3e4c51b46577da9b3ab11") ); - values.insert( Meta::valUrl, QVariant("Pop/Thriller/Thriller - 02 - Michael Jackson - Track02.mp3") ); - values.insert( Meta::valTitle, QVariant("Baby Be Mine") ); - values.insert( Meta::valArtist, QVariant("Michael Jackson") ); - values.insert( Meta::valAlbum, QVariant("Thriller") ); - values.insert( Meta::valYear, QVariant(1982) ); - values.insert( Meta::valTrackNr, QVariant(2) ); - createTrack( values ); - - values.clear(); - values.insert( Meta::valUniqueId, QVariant("15a6b1bf79747fdc8e9c6b6f06203017") ); - values.insert( Meta::valUrl, QVariant("Pop/Thriller/Thriller - 03 - Michael Jackson - Track03.mp3") ); - values.insert( Meta::valTitle, QVariant("The Girl Is Mine") ); - values.insert( Meta::valArtist, QVariant("Michael Jackson") ); - values.insert( Meta::valAlbum, QVariant("Thriller") ); - values.insert( Meta::valYear, QVariant(1982) ); - values.insert( Meta::valTrackNr, QVariant(3) ); - createTrack( values ); - - values.clear(); - values.insert( Meta::valUniqueId, QVariant("4aba4c8b1d1893c03c112cc3c01221e9") ); - values.insert( Meta::valUrl, QVariant("Pop/Thriller/Thriller - 04 - Michael Jackson - Track04.mp3") ); - values.insert( Meta::valTitle, QVariant("Thriller") ); - values.insert( Meta::valArtist, QVariant("Michael Jackson") ); - values.insert( Meta::valAlbum, QVariant("Thriller") ); - values.insert( Meta::valYear, QVariant(1982) ); - values.insert( Meta::valTrackNr, QVariant(4) ); - createTrack( values ); - - values.clear(); - values.insert( Meta::valUniqueId, QVariant("cb44d2a3d8053829b04672723bf0bd6e") ); - values.insert( Meta::valUrl, QVariant("Pop/Thriller/Thriller - 05 - Michael Jackson - Track05.mp3") ); - values.insert( Meta::valTitle, QVariant("Beat It") ); - values.insert( Meta::valArtist, QVariant("Michael Jackson") ); - values.insert( Meta::valAlbum, QVariant("Thriller") ); - values.insert( Meta::valYear, QVariant(1982) ); - values.insert( Meta::valTrackNr, QVariant(5) ); - createTrack( values ); - - values.clear(); - values.insert( Meta::valUniqueId, QVariant("eba1858eeeb3c6d97fe3385200114d86") ); - values.insert( Meta::valUrl, QVariant("Pop/Thriller/Thriller - 06 - Michael Jackson - Track06.mp3") ); - values.insert( Meta::valTitle, QVariant("Billy Jean") ); - values.insert( Meta::valArtist, QVariant("Michael Jackson") ); - values.insert( Meta::valAlbum, QVariant("Thriller") ); - values.insert( Meta::valYear, QVariant(1982) ); - values.insert( Meta::valTrackNr, QVariant(6) ); - createTrack( values ); - - values.clear(); - values.insert( Meta::valUniqueId, QVariant("4623850290998486b0f7b39a2719904e") ); - values.insert( Meta::valUrl, QVariant("Pop/Thriller/Thriller - 07 - Michael Jackson - Track07.mp3") ); - values.insert( Meta::valTitle, QVariant("Human Nature") ); - values.insert( Meta::valArtist, QVariant("Michael Jackson") ); - values.insert( Meta::valAlbum, QVariant("Thriller") ); - values.insert( Meta::valYear, QVariant(1982) ); - values.insert( Meta::valTrackNr, QVariant(7) ); - createTrack( values ); - - values.clear(); - values.insert( Meta::valUniqueId, QVariant("6d9a7de13af1e16bb13a6208e44b046d") ); - values.insert( Meta::valUrl, QVariant("Pop/Thriller/Thriller - 08 - Michael Jackson - Track08.mp3") ); - values.insert( Meta::valTitle, QVariant("P.Y.T. (Pretty Young Thing)") ); - values.insert( Meta::valArtist, QVariant("Michael Jackson") ); - values.insert( Meta::valAlbum, QVariant("Thriller") ); - values.insert( Meta::valYear, QVariant(1982) ); - values.insert( Meta::valTrackNr, QVariant(8) ); - createTrack( values ); - - values.clear(); - values.insert( Meta::valUniqueId, QVariant("91cf9a7c0d255399f9f6babfacae432b") ); - values.insert( Meta::valUrl, QVariant("Pop/Thriller/Thriller - 09 - Michael Jackson - Track09.mp3") ); - values.insert( Meta::valTitle, QVariant("The Lady In My Life") ); - values.insert( Meta::valArtist, QVariant("Michael Jackson") ); - values.insert( Meta::valAlbum, QVariant("Thriller") ); - values.insert( Meta::valYear, QVariant(1982) ); - values.insert( Meta::valTrackNr, QVariant(9) ); - createTrack( values ); -} - diff --git a/amarok/tests/scanner/TestGenericScanManager.h b/amarok/tests/scanner/TestGenericScanManager.h deleted file mode 100644 index d7bde1f4..00000000 --- a/amarok/tests/scanner/TestGenericScanManager.h +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Maximilian Kossick * - * Copyright (c) 2010-2013 Ralf Engels * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef TESTGENERICSCANMANAGER_H -#define TESTGENERICSCANMANAGER_H - -#include "scanner/GenericScanManager.h" -#include "core/meta/support/MetaConstants.h" - -#include - -#include - -/** Test the GenericScanManager and the scanner job - */ -class TestGenericScanManager : public QObject -{ - Q_OBJECT - -public: - TestGenericScanManager(); - -private slots: - void initTestCase(); - void cleanupTestCase(); - - void init(); - void cleanup(); - - /** - * Check that a single insert really inserts all the information - */ - void testScanSingle(); - - /** - * Check that fully scanning a directory works - */ - void testScanDirectory(); - - /** - * Check that the scanner continues if crashed - */ - void testRestartScanner(); - - /** - * Test images - */ - void testAlbumImage();; - - -public slots: - void slotStarted( GenericScanManager::ScanType type ); - void slotDirectoryCount( int count ); - void slotDirectoryScanned( QSharedPointer dir ); - void slotSucceeded(); - void slotFailed( const QString& message ); - -private: - void fullScanAndWait(); - void waitScannerFinished(); - - /** - Creates a track in the m_tmpCollectionDir with the given values. - Meta::valUrl gives the relative path to the target track. - */ - void createTrack( const Meta::FieldHash &values ); - void createSingleTrack(); - void createAlbum(); - - bool m_started; - bool m_finished; - - int m_scannedDirsCount; - int m_scannedTracksCount; - int m_scannedCoversCount; - - KTempDir *m_tmpCollectionDir; - QString m_sourcePath; // the path to the template .mp3 file - - GenericScanManager *m_scanManager; -}; - -#endif // TESTGENERICSCANMANAGER_H diff --git a/amarok/tests/services/CMakeLists.txt b/amarok/tests/services/CMakeLists.txt deleted file mode 100644 index 0bfaa93c..00000000 --- a/amarok/tests/services/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -add_subdirectory( amazon ) diff --git a/amarok/tests/services/amazon/CMakeLists.txt b/amarok/tests/services/amazon/CMakeLists.txt deleted file mode 100644 index 02d53b68..00000000 --- a/amarok/tests/services/amazon/CMakeLists.txt +++ /dev/null @@ -1,154 +0,0 @@ -include_directories( - ${Amarok_SOURCE_DIR}/src/core-impl/collections - ${Amarok_SOURCE_DIR}/src/services - ${AMAROK_TEST_TREE} - ${CMAKE_BINARY_DIR}/tests - ) - -#------------------------ Test AmazonConfig ------------------------------- - -set( testamazonconfig_SRCS - TestAmazonConfig.cpp - ${AMAROK_SOURCE_TREE}/services/amazon/AmazonConfig.cpp - ) - -kde4_add_unit_test( testamazonconfig ${testamazonconfig_SRCS} ) -target_link_libraries( testamazonconfig ${KDE4_KDECORE_LIBS} ${QT_QTTEST_LIBRARY} ) - - -#------------------------ Test AmazonMetaFactory ------------------------------- - -set( testamazonmetafactory_SRCS - TestAmazonMetaFactory.cpp - ${AMAROK_SOURCE_TREE}/services/amazon/AmazonMeta.cpp - ) - -kde4_add_unit_test( testamazonmetafactory ${testamazonmetafactory_SRCS} ) -target_link_libraries( testamazonmetafactory -${KDE4_KDECORE_LIBS} -${KDE4_KDEUI_LIBS} -${QT_QTTEST_LIBRARY} -${QT_QTCORE_LIBRARY} -amarokcore -amaroklib ) - - - -#------------------------ Test AmazonShoppingCart -------------------------- - -set( testamazonshoppingcart_SRCS - TestAmazonShoppingCart.cpp - ${AMAROK_SOURCE_TREE}/services/amazon/AmazonConfig.cpp - ${AMAROK_SOURCE_TREE}/services/amazon/AmazonShoppingCart.cpp - ${AMAROK_SOURCE_TREE}/services/amazon/AmazonShoppingCartItem.cpp - ${GOOGLEMOCK_SRCS} - ) - -kde4_add_unit_test( testamazonshoppingcart ${testamazonshoppingcart_SRCS} ) -target_link_libraries( testamazonshoppingcart -${GOOGLEMOCK_LIBRARIES} -${QT_QTTEST_LIBRARY} -${KDE4_KDECORE_LIBS} -amarokcore ) - - -#------------------------ Test AmazonShoppingCartItem ---------------------- - -set( testamazonshoppingcartitem_SRCS -TestAmazonShoppingCartItem.cpp -${AMAROK_SOURCE_TREE}/services/amazon/AmazonShoppingCartItem.cpp - ) - -kde4_add_unit_test( testamazonshoppingcartitem ${testamazonshoppingcartitem_SRCS} ) -target_link_libraries( testamazonshoppingcartitem ${KDE4_KDECORE_LIBS} ${QT_QTTEST_LIBRARY} ) - - -#------------------------ Test Meta::AmazonAlbum --------------------------------- - -set( testamazonalbum_SRCS -TestAmazonAlbum.cpp -${AMAROK_SOURCE_TREE}/services/amazon/AmazonMeta.cpp - ) - -kde4_add_unit_test( testamazonalbum ${testamazonalbum_SRCS} ) -target_link_libraries( testamazonalbum -${KDE4_KDECORE_LIBS} -${KDE4_KDEUI_LIBS} -${QT_QTTEST_LIBRARY} -${QT_QTCORE_LIBRARY} -amarokcore -amaroklib ) - - - -#------------------------ Test Meta::AmazonArtist --------------------------------- - -set( testamazonartist_SRCS -TestAmazonArtist.cpp -${AMAROK_SOURCE_TREE}/services/amazon/AmazonMeta.cpp - ) - -kde4_add_unit_test( testamazonartist ${testamazonartist_SRCS} ) -target_link_libraries( testamazonartist -${KDE4_KDECORE_LIBS} -${KDE4_KDEUI_LIBS} -${QT_QTTEST_LIBRARY} -${QT_QTCORE_LIBRARY} -amarokcore -amaroklib ) - - -#------------------------ Test Meta::AmazonItem --------------------------------- - -set( testamazonitem_SRCS -TestAmazonItem.cpp -${AMAROK_SOURCE_TREE}/services/amazon/AmazonMeta.cpp - ) - -kde4_add_unit_test( testamazonitem ${testamazonitem_SRCS} ) -target_link_libraries( testamazonitem -${KDE4_KDECORE_LIBS} -${KDE4_KDEUI_LIBS} -${QT_QTTEST_LIBRARY} -${QT_QTCORE_LIBRARY} -amarokcore -amaroklib ) - - -#------------------------ Test Meta::AmazonTrack --------------------------------- - -set( testamazontrack_SRCS -TestAmazonTrack.cpp -${AMAROK_SOURCE_TREE}/services/amazon/AmazonMeta.cpp - ) - -kde4_add_unit_test( testamazontrack ${testamazontrack_SRCS} ) -target_link_libraries( testamazontrack -${KDE4_KDECORE_LIBS} -${KDE4_KDEUI_LIBS} -${QT_QTTEST_LIBRARY} -${QT_QTCORE_LIBRARY} -amarokcore -amaroklib ) - - -#------------------------ Test AmazonParser -------------------------------------- - -set( testamazonparser_SRCS -TestAmazonParser.cpp -${AMAROK_SOURCE_TREE}/services/amazon/AmazonCollection.cpp -${AMAROK_SOURCE_TREE}/services/amazon/AmazonConfig.cpp -${AMAROK_SOURCE_TREE}/services/amazon/AmazonMeta.cpp -${AMAROK_SOURCE_TREE}/services/amazon/AmazonParser.cpp - ) - -kde4_add_unit_test( testamazonparser ${testamazonparser_SRCS} ) -target_link_libraries( testamazonparser -${KDE4_KDECORE_LIBS} -${KDE4_KDEUI_LIBS} -${KDE4_THREADWEAVER_LIBS} -${QT_QTTEST_LIBRARY} -${QT_QTCORE_LIBRARY} -${QT_QTXML_LIBRARY} -amarokcore -amaroklib ) diff --git a/amarok/tests/services/amazon/TestAmazonAlbum.cpp b/amarok/tests/services/amazon/TestAmazonAlbum.cpp deleted file mode 100644 index 54fdc5bd..00000000 --- a/amarok/tests/services/amazon/TestAmazonAlbum.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Sven Krohlas * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 Pulic License for more details. * - * * - * You should have received a copy of the GNU General Public License along with * - * this program. If not, see . * - ****************************************************************************************/ - -#include "TestAmazonAlbum.h" - -#include "services/amazon/AmazonMeta.h" - -#include - -#include - -QTEST_KDEMAIN( TestAmazonAlbum, GUI ) - -TestAmazonAlbum::TestAmazonAlbum() : - QObject() -{ -} - -void -TestAmazonAlbum::testSetAndGetCoverUrl() -{ - QStringList list, list2; - list << "id" << "name" << "description" << "artistID" << "price" << "coverUrl" << "ASIN"; - list2 << "23" << "name" << "description" << "42" << "price" << "coverUrl" << "ASIN"; - Meta::AmazonAlbum album( list ); - Meta::AmazonAlbum album2( list2 ); - - QCOMPARE( album.id(), 0 ); - QCOMPARE( album.name(), QString( "name" ) ); - QCOMPARE( album.description(), QString( "description" ) ); - QCOMPARE( album.artistId(), 0 ); - QCOMPARE( album.price(), QString( "price" ) ); - QCOMPARE( album.coverUrl(), QString( "coverUrl" ) ); - QCOMPARE( album.asin(), QString( "ASIN" ) ); - - QCOMPARE( album2.id(), 23 ); - QCOMPARE( album2.artistId(), 42 ); - - album.setCoverUrl( "http://ecx.images-amazon.com/images/I/61aUtzxMIWL._SL500_SS110_.jpg" ); - QCOMPARE( album.coverUrl(), QString( "http://ecx.images-amazon.com/images/I/61aUtzxMIWL._SL500_SS110_.jpg" ) ); -} diff --git a/amarok/tests/services/amazon/TestAmazonAlbum.h b/amarok/tests/services/amazon/TestAmazonAlbum.h deleted file mode 100644 index a0663cc9..00000000 --- a/amarok/tests/services/amazon/TestAmazonAlbum.h +++ /dev/null @@ -1,32 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Sven Krohlas * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 Pulic License for more details. * - * * - * You should have received a copy of the GNU General Public License along with * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef TESTAMAZONALBUM_H -#define TESTAMAZONALBUM_H - -#include - -class TestAmazonAlbum : public QObject -{ - Q_OBJECT -public: - TestAmazonAlbum(); - -private slots: - void testSetAndGetCoverUrl(); -}; - -#endif // TESTAMAZONALBUM_H diff --git a/amarok/tests/services/amazon/TestAmazonArtist.cpp b/amarok/tests/services/amazon/TestAmazonArtist.cpp deleted file mode 100644 index 7ad1ac70..00000000 --- a/amarok/tests/services/amazon/TestAmazonArtist.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Sven Krohlas * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 Pulic License for more details. * - * * - * You should have received a copy of the GNU General Public License along with * - * this program. If not, see . * - ****************************************************************************************/ - -#include "TestAmazonArtist.h" - -#include "services/amazon/AmazonMeta.h" - -#include - -#include - -QTEST_KDEMAIN( TestAmazonArtist, GUI ) - -TestAmazonArtist::TestAmazonArtist() : - QObject() -{ -} - -void -TestAmazonArtist::testConstructor() -{ - QStringList list, list2; - list << "id" << "name" << "description"; - list2 << "23" << "name" << "description"; - Meta::AmazonArtist artist( list ); - Meta::AmazonArtist artist2( list2 ); - - QCOMPARE( artist.id(), 0 ); - QCOMPARE( artist.name(), QString( "name" ) ); - QCOMPARE( artist.description(), QString( "description" ) ); - - QCOMPARE( artist2.id(), 23 ); -} diff --git a/amarok/tests/services/amazon/TestAmazonArtist.h b/amarok/tests/services/amazon/TestAmazonArtist.h deleted file mode 100644 index 842c3e05..00000000 --- a/amarok/tests/services/amazon/TestAmazonArtist.h +++ /dev/null @@ -1,32 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Sven Krohlas * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 Pulic License for more details. * - * * - * You should have received a copy of the GNU General Public License along with * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef TESTAMAZONARTIST_H -#define TESTAMAZONARTIST_H - -#include - -class TestAmazonArtist : public QObject -{ - Q_OBJECT -public: - TestAmazonArtist(); - -private slots: - void testConstructor(); -}; - -#endif // TESTAMAZONARTIST_H diff --git a/amarok/tests/services/amazon/TestAmazonConfig.cpp b/amarok/tests/services/amazon/TestAmazonConfig.cpp deleted file mode 100644 index 66eb2a6d..00000000 --- a/amarok/tests/services/amazon/TestAmazonConfig.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Sven Krohlas * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 Pulic License for more details. * - * * - * You should have received a copy of the GNU General Public License along with * - * this program. If not, see . * - ****************************************************************************************/ - -#include "TestAmazonConfig.h" - -#include "services/amazon/AmazonConfig.h" - -#include - -#include - -QTEST_KDEMAIN_CORE( TestAmazonConfig ) - -TestAmazonConfig::TestAmazonConfig() : - QObject() -{ -} - -void -TestAmazonConfig::testSetAndGetCountry() -{ - QString country = AmazonConfig::instance()->country(); // to restore the config later - - AmazonConfig::instance()->setCountry( "de" ); - QCOMPARE( AmazonConfig::instance()->country(), QString( "de" ) ); - - AmazonConfig::instance()->setCountry( "co.uk" ); - QCOMPARE( AmazonConfig::instance()->country(), QString( "co.uk" ) ); - - AmazonConfig::instance()->setCountry( country ); -} diff --git a/amarok/tests/services/amazon/TestAmazonConfig.h b/amarok/tests/services/amazon/TestAmazonConfig.h deleted file mode 100644 index c11048dd..00000000 --- a/amarok/tests/services/amazon/TestAmazonConfig.h +++ /dev/null @@ -1,32 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Sven Krohlas * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 Pulic License for more details. * - * * - * You should have received a copy of the GNU General Public License along with * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef TESTAMAZONCONFIG_H -#define TESTAMAZONCONFIG_H - -#include - -class TestAmazonConfig : public QObject -{ - Q_OBJECT -public: - TestAmazonConfig(); - -private slots: - void testSetAndGetCountry(); -}; - -#endif // TESTAMAZONCONFIG_H diff --git a/amarok/tests/services/amazon/TestAmazonItem.cpp b/amarok/tests/services/amazon/TestAmazonItem.cpp deleted file mode 100644 index ab3f8806..00000000 --- a/amarok/tests/services/amazon/TestAmazonItem.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Sven Krohlas * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 Pulic License for more details. * - * * - * You should have received a copy of the GNU General Public License along with * - * this program. If not, see . * - ****************************************************************************************/ - -#include "TestAmazonItem.h" - -#include "services/amazon/AmazonMeta.h" - -#include - -#include - -QTEST_KDEMAIN( TestAmazonItem, GUI ) - -TestAmazonItem::TestAmazonItem() : - QObject() -{ -} - -void -TestAmazonItem::testSetAndGetAsin() -{ - Meta::AmazonItem item; - - item.setAsin( "" ); - QCOMPARE( item.asin(), QString( "" ) ); - - item.setAsin( "B003MJQB9A" ); - QCOMPARE( item.asin(), QString( "B003MJQB9A" ) ); -} - -void -TestAmazonItem::testSetAndGetPrice() -{ - Meta::AmazonItem item; - - item.setPrice( "" ); - QCOMPARE( item.price(), QString( "" ) ); - - item.setPrice( "GRATIS" ); - QCOMPARE( item.price(), QString( "GRATIS" ) ); - - item.setPrice( "99" ); - QCOMPARE( item.price(), QString( "99" ) ); -} diff --git a/amarok/tests/services/amazon/TestAmazonItem.h b/amarok/tests/services/amazon/TestAmazonItem.h deleted file mode 100644 index 6b5f25e9..00000000 --- a/amarok/tests/services/amazon/TestAmazonItem.h +++ /dev/null @@ -1,33 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Sven Krohlas * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 Pulic License for more details. * - * * - * You should have received a copy of the GNU General Public License along with * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef TESTAMAZONITEM_H -#define TESTAMAZONITEM_H - -#include - -class TestAmazonItem : public QObject -{ - Q_OBJECT -public: - TestAmazonItem(); - -private slots: - void testSetAndGetAsin(); - void testSetAndGetPrice(); -}; - -#endif // TESTAMAZONITEM_H diff --git a/amarok/tests/services/amazon/TestAmazonMetaFactory.cpp b/amarok/tests/services/amazon/TestAmazonMetaFactory.cpp deleted file mode 100644 index d695f0b7..00000000 --- a/amarok/tests/services/amazon/TestAmazonMetaFactory.cpp +++ /dev/null @@ -1,129 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Sven Krohlas * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 Pulic License for more details. * - * * - * You should have received a copy of the GNU General Public License along with * - * this program. If not, see . * - ****************************************************************************************/ - -#include "TestAmazonMetaFactory.h" - -#include "services/amazon/AmazonMeta.h" - -#include - -#include - -QTEST_KDEMAIN( TestAmazonMetaFactory, GUI ) - -TestAmazonMetaFactory::TestAmazonMetaFactory() : - QObject() -{ -} - -void -TestAmazonMetaFactory::testCreateAlbum() -{ - QStringList list, list2; - list << "id" << "name" << "description" << "artistID" << "price" << "coverUrl" << "ASIN"; - list2 << "23" << "name" << "description" << "42" << "price" << "coverUrl" << "ASIN"; - - AmazonMetaFactory factory( "Amazontest" ); - Meta::AlbumPtr albumPtr = factory.createAlbum( list ); - Meta::AlbumPtr albumPtr2 = factory.createAlbum( list2 ); - - QVERIFY( albumPtr ); - QVERIFY( albumPtr2 ); - - Meta::AmazonAlbum* amazonAlbum = dynamic_cast( albumPtr.data() ); - Meta::AmazonAlbum* amazonAlbum2 = dynamic_cast( albumPtr2.data() ); - - QVERIFY( amazonAlbum ); - QVERIFY( amazonAlbum2 ); - - QCOMPARE( amazonAlbum->id(), 0 ); - QCOMPARE( amazonAlbum->name(), QString( "name" ) ); - QCOMPARE( amazonAlbum->description(), QString( "description" ) ); - QCOMPARE( amazonAlbum->artistId(), 0 ); - QCOMPARE( amazonAlbum->price(), QString( "price" ) ); - QCOMPARE( amazonAlbum->coverUrl(), QString( "coverUrl" ) ); - QCOMPARE( amazonAlbum->asin(), QString( "ASIN" ) ); - - QCOMPARE( amazonAlbum2->id(), 23 ); - QCOMPARE( amazonAlbum2->artistId(), 42 ); -} - -void -TestAmazonMetaFactory::testCreateArtist() -{ - QStringList list, list2; - list << "id" << "name" << "description"; - list2 << "23" << "name" << "description"; - - AmazonMetaFactory factory( "Amazontest" ); - Meta::ArtistPtr artistPtr = factory.createArtist( list ); - Meta::ArtistPtr artistPtr2 = factory.createArtist( list2 ); - - QVERIFY( artistPtr ); - QVERIFY( artistPtr2 ); - - Meta::AmazonArtist* amazonArtist = dynamic_cast( artistPtr.data() ); - Meta::AmazonArtist* amazonArtist2 = dynamic_cast( artistPtr2.data() ); - - QVERIFY( amazonArtist ); - QVERIFY( amazonArtist2 ); - - QCOMPARE( amazonArtist->id(), 0 ); - QCOMPARE( amazonArtist->name(), QString( "name" ) ); - QCOMPARE( amazonArtist->description(), QString( "description" ) ); - - QCOMPARE( amazonArtist2->id(), 23 ); -} - -void -TestAmazonMetaFactory::testCreateTrack() -{ - QStringList list, list2; - list << "id" << "name" << "trackNumber" << "length" << "playableUrl" << "albumId" << "artistId" << "price" << "ASIN"; - list2 << "23" << "name" << "5" << "300" << "http://www.amazon.de/gp/dmusic/get_sample_url.html?ASIN=B007NV28OK" << "42" << "12" << "99" << "B007NV28OK"; - - AmazonMetaFactory factory( "Amazontest" ); - Meta::TrackPtr trackPtr = factory.createTrack( list ); - Meta::TrackPtr trackPtr2 = factory.createTrack( list2 ); - - QVERIFY( trackPtr ); - QVERIFY( trackPtr2 ); - - Meta::AmazonTrack* amazonTrack = dynamic_cast( trackPtr.data() ); - Meta::AmazonTrack* amazonTrack2 = dynamic_cast( trackPtr2.data() ); - - QVERIFY( amazonTrack ); - QVERIFY( amazonTrack2 ); - - QCOMPARE( amazonTrack->id(), 0 ); - QCOMPARE( amazonTrack->name(), QString( "name" ) ); - QCOMPARE( amazonTrack->trackNumber(), 0 ); - QCOMPARE( amazonTrack->length(), (qint64)0 ); - QCOMPARE( amazonTrack->playableUrl(), KUrl( "playableUrl" ) ); - QCOMPARE( amazonTrack->albumId(), 0 ); - QCOMPARE( amazonTrack->artistId(), 0 ); - QCOMPARE( amazonTrack->price(), QString( "price" ) ); - QCOMPARE( amazonTrack->asin(), QString( "ASIN" ) ); - - QCOMPARE( amazonTrack2->id(), 23 ); - QCOMPARE( amazonTrack2->trackNumber(), 5 ); - QCOMPARE( amazonTrack2->length(), (qint64)300 ); - QCOMPARE( amazonTrack2->playableUrl(), KUrl( "http://www.amazon.de/gp/dmusic/get_sample_url.html?ASIN=B007NV28OK" ) ); - QCOMPARE( amazonTrack2->albumId(), 42 ); - QCOMPARE( amazonTrack2->artistId(), 12 ); - QCOMPARE( amazonTrack2->price(), QString( "99" ) ); - QCOMPARE( amazonTrack2->asin(), QString( "B007NV28OK" ) ); -} diff --git a/amarok/tests/services/amazon/TestAmazonMetaFactory.h b/amarok/tests/services/amazon/TestAmazonMetaFactory.h deleted file mode 100644 index 6eaff5d1..00000000 --- a/amarok/tests/services/amazon/TestAmazonMetaFactory.h +++ /dev/null @@ -1,34 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Sven Krohlas * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 Pulic License for more details. * - * * - * You should have received a copy of the GNU General Public License along with * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef TESTAMAZONMETAFACTORY_H -#define TESTAMAZONMETAFACTORY_H - -#include - -class TestAmazonMetaFactory : public QObject -{ - Q_OBJECT -public: - TestAmazonMetaFactory(); - -private slots: - void testCreateAlbum(); - void testCreateArtist(); - void testCreateTrack(); -}; - -#endif // TESTAMAZONMETAFACTORY_H diff --git a/amarok/tests/services/amazon/TestAmazonParser.cpp b/amarok/tests/services/amazon/TestAmazonParser.cpp deleted file mode 100644 index b6d05759..00000000 --- a/amarok/tests/services/amazon/TestAmazonParser.cpp +++ /dev/null @@ -1,141 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Sven Krohlas * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 Pulic License for more details. * - * * - * You should have received a copy of the GNU General Public License along with * - * this program. If not, see . * - ****************************************************************************************/ - -#include "config-amarok-test.h" - -#include "TestAmazonParser.h" - -#include "ServiceBase.h" - -#include -#include -#include - -#include - -QTEST_KDEMAIN( TestAmazonParser, GUI ) - -TestAmazonParser::TestAmazonParser() - :AmazonParser( QDir::tempPath() + QDir::separator() + "searchresponse.xml", - new Collections::AmazonCollection( (ServiceBase*)NULL, "amazon", "MP3 Music Store" ), // HACK... - new AmazonMetaFactory( "amazon" ) ) -{ -} - -void -TestAmazonParser::testRun() -{ - // AmazonParser deletes the xml after parsing, so we have to make a copy - QFile testFile( QDir::toNativeSeparators( QString( AMAROK_TEST_DIR ) + "/data/services/amazon/searchresponse.xml" ) ); - QVERIFY( testFile.copy( QDir::tempPath() + QDir::separator() + "searchresponse.xml" ) ); - - // parse searchresponse.xml - run(); - - // test the result - QMap &artistIDMap = m_collection->artistIDMap(); - QCOMPARE( artistIDMap.size(), 2 ); - QCOMPARE( artistIDMap.key( 1 ), QString( "The Cure" ) ); - QCOMPARE( artistIDMap.key( 2 ), QString( "Jah Cure" ) ); - - QMap &albumIDMap = m_collection->albumIDMap(); - QCOMPARE( albumIDMap.size(), 23 ); - QCOMPARE( albumIDMap.key( 1 ), QString( "B001SW8TFC" ) ); - QCOMPARE( albumIDMap.key( 23 ), QString( "B001SVHLE8" ) ); - - QMap &trackIDMap = m_collection->trackIDMap(); - QCOMPARE( trackIDMap.size(), 50 ); - QCOMPARE( trackIDMap.key( 1 ), QString( "B001SW3X58" ) ); - QCOMPARE( trackIDMap.key( 50 ), QString( "B001SQBJQE" ) ); - - // let's check some tracks - Meta::AmazonTrack* track; - - track = dynamic_cast( m_collection->trackById( 1 ).data() ); - QVERIFY( track ); - QCOMPARE( track->asin(), QString( "B001SW3X58" ) ); - QCOMPARE( track->name(), QString( "Lullaby" ) ); - QCOMPARE( track->price(), QString( "99" ) ); - QCOMPARE( track->artistId(), 1 ); - QCOMPARE( track->albumId(), 1 ); - - track = dynamic_cast( m_collection->trackById( 2 ).data() ); - QVERIFY( track ); - QCOMPARE( track->asin(), QString( "B001SW8U92" ) ); - QCOMPARE( track->name(), QString( "Friday I'm In Love" ) ); - QCOMPARE( track->price(), QString( "99" ) ); - QCOMPARE( track->artistId(), 1 ); - QCOMPARE( track->albumId(), 1 ); - - track = dynamic_cast( m_collection->trackById( 50 ).data() ); - QVERIFY( track ); - QCOMPARE( track->asin(), QString( "B001SQBJQE" ) ); - QCOMPARE( track->name(), QString( "From The Edge Of The Deep Green Sea" ) ); - QCOMPARE( track->price(), QString( "99" ) ); - QCOMPARE( track->artistId(), 1 ); - QCOMPARE( track->albumId(), 18 ); - - - // let's check some albums - Meta::AmazonAlbum* album; - - album = dynamic_cast( m_collection->albumById( 1 ).data() ); - QVERIFY( album ); - QCOMPARE( album->asin(), QString( "B001SW8TFC" ) ); - QCOMPARE( album->coverUrl(), QString( "http://ecx.images-amazon.com/images/I/51L5Z-JXB3L._SL500_SS110_.jpg" ) ); - QCOMPARE( album->name(), QString( "Greatest Hits" ) ); - QCOMPARE( album->price(), QString( "989" ) ); - - album = dynamic_cast( m_collection->albumById( 2 ).data() ); - QVERIFY( album ); - QCOMPARE( album->asin(), QString( "B00666RKLE" ) ); - QCOMPARE( album->coverUrl(), QString( "http://ecx.images-amazon.com/images/I/61p6dd%2BShZL._SL500_AA240_.jpg" ) ); - QCOMPARE( album->name(), QString( "Bestival Live 2011" ) ); - QCOMPARE( album->price(), QString( "699" ) ); - - album = dynamic_cast( m_collection->albumById( 3 ).data() ); - QVERIFY( album ); - QCOMPARE( album->asin(), QString( "B003TZV8T0" ) ); - QCOMPARE( album->coverUrl(), QString( "http://ecx.images-amazon.com/images/I/51LN4o1DxYL._SL500_SS110_.jpg" ) ); - QCOMPARE( album->name(), QString( "Staring At The Sea - The Singles" ) ); - QCOMPARE( album->price(), QString( "599" ) ); - - album = dynamic_cast( m_collection->albumById( 4 ).data() ); - QVERIFY( album ); - QCOMPARE( album->asin(), QString( "B0045M8SDK" ) ); - QCOMPARE( album->coverUrl(), QString( "http://ecx.images-amazon.com/images/I/411ncIcC8vL._SL500_SS110_.jpg" ) ); - QCOMPARE( album->name(), QString( "Kiss Me, Kiss Me, Kiss Me" ) ); - QCOMPARE( album->price(), QString( "599" ) ); - - album = dynamic_cast( m_collection->albumById( 5 ).data() ); - QVERIFY( album ); - QCOMPARE( album->asin(), QString( "B001SVN2NM" ) ); - QCOMPARE( album->coverUrl(), QString( "http://ecx.images-amazon.com/images/I/418turaImmL._SL500_SS110_.jpg" ) ); - QCOMPARE( album->name(), QString( "Pornography" ) ); - QCOMPARE( album->price(), QString( "599" ) ); - - album = dynamic_cast( m_collection->albumById( 23 ).data() ); - QVERIFY( album ); - QCOMPARE( album->asin(), QString( "B001SVHLE8" ) ); - QCOMPARE( album->coverUrl(), QString( "" ) ); - QCOMPARE( album->name(), QString( "Three Imaginary Boys" ) ); - QCOMPARE( album->price(), QString( "" ) ); - - m_collection->clear(); - QCOMPARE( artistIDMap.size(), 0 ); - QCOMPARE( albumIDMap.size(), 0 ); - QCOMPARE( trackIDMap.size(), 0 ); -} diff --git a/amarok/tests/services/amazon/TestAmazonParser.h b/amarok/tests/services/amazon/TestAmazonParser.h deleted file mode 100644 index 8a714987..00000000 --- a/amarok/tests/services/amazon/TestAmazonParser.h +++ /dev/null @@ -1,36 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Sven Krohlas * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 Pulic License for more details. * - * * - * You should have received a copy of the GNU General Public License along with * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef TESTAMAZONPARSER_H -#define TESTAMAZONPARSER_H - -#include "amazon/AmazonParser.h" - -/* This one is not a unit test... - It tests xml parsing and the collection in one run, as the two of them are very tightly - coupled together. The result is imho ugly as hell. But it works.*/ - -class TestAmazonParser : public AmazonParser -{ - Q_OBJECT -public: - TestAmazonParser(); - -private slots: - void testRun(); -}; - -#endif // TESTAMAZONPARSER_H diff --git a/amarok/tests/services/amazon/TestAmazonShoppingCart.cpp b/amarok/tests/services/amazon/TestAmazonShoppingCart.cpp deleted file mode 100644 index fa3bdb9d..00000000 --- a/amarok/tests/services/amazon/TestAmazonShoppingCart.cpp +++ /dev/null @@ -1,170 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Sven Krohlas * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 Pulic License for more details. * - * * - * You should have received a copy of the GNU General Public License along with * - * this program. If not, see . * - ****************************************************************************************/ - -#include "TestAmazonShoppingCart.h" - -#include "core/support/Components.h" -#include "mocks/MockLogger.h" -#include "services/amazon/AmazonConfig.h" -#include "services/amazon/AmazonShoppingCart.h" -#include "services/amazon/AmazonShoppingCartItem.h" - -#include - -#include - -QTEST_KDEMAIN_CORE( TestAmazonShoppingCart ) - -TestAmazonShoppingCart::TestAmazonShoppingCart() : - QObject() -{ -} - -void -TestAmazonShoppingCart::initTestCase() -{ - // AmazonShoppingCart::add() calls Amarok::Components::logger()->longMessage() - Amarok::Components::setLogger( new Amarok::MockLogger() ); -} - -void -TestAmazonShoppingCart::cleanupTestCase() -{ - delete Amarok::Components::setLogger( 0 ); -} - -void -TestAmazonShoppingCart::testAdd() -{ - QCOMPARE( AmazonShoppingCart::instance()->size(), 0 ); - AmazonShoppingCart::instance()->add( "ASIN", "price", "name" ); - QCOMPARE( AmazonShoppingCart::instance()->size(), 1 ); - - AmazonShoppingCartItem item = AmazonShoppingCart::instance()->at( 0 ); - QCOMPARE( item.asin(), QString( "ASIN" ) ); - QCOMPARE( item.price(), QString( "price" ) ); - QCOMPARE( item.prettyName(), QString( "name" ) ); - - AmazonShoppingCart::instance()->add( "something", "99", "something" ); - QCOMPARE( AmazonShoppingCart::instance()->size(), 2 ); -} - -void -TestAmazonShoppingCart::testClear() -{ - AmazonShoppingCart::instance()->clear(); - QCOMPARE( AmazonShoppingCart::instance()->size(), 0 ); - - AmazonShoppingCart::instance()->add( "ASIN", "price", "name" ); - AmazonShoppingCart::instance()->add( "something", "99", "something" ); - QCOMPARE( AmazonShoppingCart::instance()->size(), 2 ); - - AmazonShoppingCart::instance()->clear(); - QCOMPARE( AmazonShoppingCart::instance()->size(), 0 ); -} - -void -TestAmazonShoppingCart::testStringList() -{ - // for numerical prices (eg available and non free items) the output depends on the locale - - // no crash on empty cart - AmazonShoppingCart::instance()->stringList(); - - AmazonShoppingCart::instance()->add( "ASIN", "price", "name" ); - QString result = AmazonShoppingCart::instance()->stringList().at( 0 ); - QCOMPARE( result, QString( "name (price)" ) ); - - AmazonShoppingCart::instance()->add( "ASIN2", "price2", "name2" ); - result = AmazonShoppingCart::instance()->stringList().at( 1 ); - QCOMPARE( result, QString( "name2 (price2)" ) ); -} - -void -TestAmazonShoppingCart::testPrice() -{ - AmazonShoppingCart::instance()->clear(); - QCOMPARE( AmazonShoppingCart::instance()->price(), QString( "0" ) ); - - AmazonShoppingCart::instance()->add( "ASIN", "0", "name" ); - QCOMPARE( AmazonShoppingCart::instance()->price(), QString( "0" ) ); - - AmazonShoppingCart::instance()->add( "ASIN", "GRATIS", "name" ); - QCOMPARE( AmazonShoppingCart::instance()->price(), QString( "0" ) ); - - AmazonShoppingCart::instance()->add( "ASIN", "99", "name" ); - QCOMPARE( AmazonShoppingCart::instance()->price(), QString( "99" ) ); - - AmazonShoppingCart::instance()->add( "ASIN", "1", "name" ); - QCOMPARE( AmazonShoppingCart::instance()->price(), QString( "100" ) ); - - AmazonShoppingCart::instance()->add( "ASIN", "1790", "name" ); - QCOMPARE( AmazonShoppingCart::instance()->price(), QString( "1890" ) ); -} - -void -TestAmazonShoppingCart::testRemove() -{ - AmazonShoppingCart::instance()->clear(); - QCOMPARE( AmazonShoppingCart::instance()->size(), 0 ); - - // removing some items that do not exist -> no crash - AmazonShoppingCart::instance()->remove( 0 ); - AmazonShoppingCart::instance()->remove( 1 ); - AmazonShoppingCart::instance()->remove( 42 ); - AmazonShoppingCart::instance()->remove( -3 ); - - AmazonShoppingCart::instance()->add( "ASIN", "price", "name" ); - QCOMPARE( AmazonShoppingCart::instance()->size(), 1 ); - AmazonShoppingCart::instance()->remove( 0 ); - QCOMPARE( AmazonShoppingCart::instance()->size(), 0 ); - - AmazonShoppingCart::instance()->add( "ASIN", "price", "name" ); - AmazonShoppingCart::instance()->add( "ASIN", "price", "name" ); - AmazonShoppingCart::instance()->add( "ASIN", "price", "name" ); - QCOMPARE( AmazonShoppingCart::instance()->size(), 3 ); - AmazonShoppingCart::instance()->remove( 1 ); - QCOMPARE( AmazonShoppingCart::instance()->size(), 2 ); - AmazonShoppingCart::instance()->remove( 1 ); - QCOMPARE( AmazonShoppingCart::instance()->size(), 1 ); -} - -void -TestAmazonShoppingCart::testCheckoutUrl() -{ - AmazonShoppingCart::instance()->clear(); - QString country = AmazonConfig::instance()->country(); // to restore the config later - AmazonConfig::instance()->setCountry( "de" ); // so we have a fixed, well known result string - - QUrl result = AmazonShoppingCart::instance()->checkoutUrl(); - QCOMPARE( result, QUrl() ); - - result = AmazonShoppingCart::instance()->checkoutUrl( "B003MJQB9A" ); - QCOMPARE( result, QUrl( "http://www.mp3-music-store.de/index.php?apikey=27274503cb405cb1929f353fc507f09c&redirect=true&method=CreateCart&Location=de&Player=amarok&ASINs[]=B003MJQB9A" ) ); - - AmazonShoppingCart::instance()->add( "B003MJQB9A", "price", "name" ); - result = AmazonShoppingCart::instance()->checkoutUrl(); - QCOMPARE( result, QUrl( "http://www.mp3-music-store.de/index.php?apikey=27274503cb405cb1929f353fc507f09c&redirect=true&method=CreateCart&Location=de&Player=amarok&ASINs[]=B003MJQB9A" ) ); - - AmazonShoppingCart::instance()->add( "B007XBRH3C", "price", "name" ); - result = AmazonShoppingCart::instance()->checkoutUrl(); - QCOMPARE( result, QUrl( "http://www.mp3-music-store.de/index.php?apikey=27274503cb405cb1929f353fc507f09c&redirect=true&method=CreateCart&Location=de&Player=amarok&ASINs[]=B003MJQB9A&ASINs[]=B007XBRH3C" ) ); - - result = AmazonShoppingCart::instance()->checkoutUrl( "B003MJQB9A" ); - QCOMPARE( result, QUrl( "http://www.mp3-music-store.de/index.php?apikey=27274503cb405cb1929f353fc507f09c&redirect=true&method=CreateCart&Location=de&Player=amarok&ASINs[]=B003MJQB9A" ) ); - - AmazonConfig::instance()->setCountry( country ); -} diff --git a/amarok/tests/services/amazon/TestAmazonShoppingCart.h b/amarok/tests/services/amazon/TestAmazonShoppingCart.h deleted file mode 100644 index e873674d..00000000 --- a/amarok/tests/services/amazon/TestAmazonShoppingCart.h +++ /dev/null @@ -1,40 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Sven Krohlas * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 Pulic License for more details. * - * * - * You should have received a copy of the GNU General Public License along with * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef TESTAMAZONSHOPPINGCART_H -#define TESTAMAZONSHOPPINGCART_H - -#include - -class TestAmazonShoppingCart : public QObject -{ - Q_OBJECT -public: - TestAmazonShoppingCart(); - -private slots: - void initTestCase(); - void cleanupTestCase(); - - void testAdd(); - void testClear(); - void testStringList(); - void testPrice(); - void testRemove(); - void testCheckoutUrl(); -}; - -#endif // TESTAMAZONSHOPPINGCART_H diff --git a/amarok/tests/services/amazon/TestAmazonShoppingCartItem.cpp b/amarok/tests/services/amazon/TestAmazonShoppingCartItem.cpp deleted file mode 100644 index c9b55fc8..00000000 --- a/amarok/tests/services/amazon/TestAmazonShoppingCartItem.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Sven Krohlas * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 Pulic License for more details. * - * * - * You should have received a copy of the GNU General Public License along with * - * this program. If not, see . * - ****************************************************************************************/ - -#include "TestAmazonShoppingCartItem.h" - -#include "services/amazon/AmazonShoppingCartItem.h" - -#include - -#include - -QTEST_KDEMAIN_CORE( TestAmazonShoppingCartItem ) - -TestAmazonShoppingCartItem::TestAmazonShoppingCartItem() : - QObject() -{ -} - -void -TestAmazonShoppingCartItem::testAsin() -{ - AmazonShoppingCartItem item( "", "price", "prettyName" ); - QCOMPARE( item.asin(), QString( "" ) ); - - AmazonShoppingCartItem item2( "B003MJQB9A", "price", "prettyName" ); - QCOMPARE( item2.asin(), QString( "B003MJQB9A" ) ); -} - -void -TestAmazonShoppingCartItem::testPrettyName() -{ - AmazonShoppingCartItem item( "ASIN", "price", "" ); - QCOMPARE( item.prettyName(), QString( "" ) ); - - AmazonShoppingCartItem item2( "ASIN", "price", "The Cure - Disintegration" ); - QCOMPARE( item2.prettyName(), QString( "The Cure - Disintegration" ) ); -} - -void -TestAmazonShoppingCartItem::testPrice() -{ - AmazonShoppingCartItem item( "ASIN", "", "prettyName" ); - QCOMPARE( item.price(), QString( "" ) ); - - AmazonShoppingCartItem item2( "ASIN", "99", "prettyName" ); - QCOMPARE( item2.price(), QString( "99" ) ); -} diff --git a/amarok/tests/services/amazon/TestAmazonShoppingCartItem.h b/amarok/tests/services/amazon/TestAmazonShoppingCartItem.h deleted file mode 100644 index 894312f5..00000000 --- a/amarok/tests/services/amazon/TestAmazonShoppingCartItem.h +++ /dev/null @@ -1,34 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Sven Krohlas * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 Pulic License for more details. * - * * - * You should have received a copy of the GNU General Public License along with * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef TESTAMAZONSHOPPINGCARTITEM_H -#define TESTAMAZONSHOPPINGCARTITEM_H - -#include - -class TestAmazonShoppingCartItem : public QObject -{ - Q_OBJECT -public: - TestAmazonShoppingCartItem(); - -private slots: - void testAsin(); - void testPrettyName(); - void testPrice(); -}; - -#endif // TESTAMAZONSHOPPINGCARTITEM_H diff --git a/amarok/tests/services/amazon/TestAmazonTrack.cpp b/amarok/tests/services/amazon/TestAmazonTrack.cpp deleted file mode 100644 index c9a4a9cc..00000000 --- a/amarok/tests/services/amazon/TestAmazonTrack.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Sven Krohlas * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 Pulic License for more details. * - * * - * You should have received a copy of the GNU General Public License along with * - * this program. If not, see . * - ****************************************************************************************/ - -#include "TestAmazonTrack.h" - -#include "services/amazon/AmazonMeta.h" - -#include - -#include - -QTEST_KDEMAIN( TestAmazonTrack, GUI ) - -TestAmazonTrack::TestAmazonTrack() : - QObject() -{ -} - -void -TestAmazonTrack::testConstructor() -{ - QStringList list, list2; - list << "id" << "name" << "trackNumber" << "length" << "playableUrl" << "albumId" << "artistId" << "price" << "ASIN"; - list2 << "23" << "name" << "5" << "300" << "http://www.amazon.de/gp/dmusic/get_sample_url.html?ASIN=B007NV28OK" << "42" << "12" << "99" << "B007NV28OK"; - Meta::AmazonTrack track( list ); - Meta::AmazonTrack track2( list2 ); - - QCOMPARE( track.id(), 0 ); - QCOMPARE( track.name(), QString( "name" ) ); - QCOMPARE( track.trackNumber(), 0 ); - QCOMPARE( track.length(), (qint64)0 ); - QCOMPARE( track.playableUrl(), KUrl( "playableUrl" ) ); - QCOMPARE( track.albumId(), 0 ); - QCOMPARE( track.artistId(), 0 ); - QCOMPARE( track.price(), QString( "price" ) ); - QCOMPARE( track.asin(), QString( "ASIN" ) ); - - QCOMPARE( track2.id(), 23 ); - QCOMPARE( track2.trackNumber(), 5 ); - QCOMPARE( track2.length(), (qint64)300 ); - QCOMPARE( track2.playableUrl(), KUrl( "http://www.amazon.de/gp/dmusic/get_sample_url.html?ASIN=B007NV28OK" ) ); - QCOMPARE( track2.albumId(), 42 ); - QCOMPARE( track2.artistId(), 12 ); - QCOMPARE( track2.price(), QString( "99" ) ); - QCOMPARE( track2.asin(), QString( "B007NV28OK" ) ); -} - -void -TestAmazonTrack::testEmblem() -{ - QStringList list; - list << "id" << "name" << "trackNumber" << "length" << "playableUrl" << "albumId" << "artistId" << "price" << "ASIN"; - Meta::AmazonTrack track( list ); - - QSKIP("Emblem is only available once Amarok is installed.", SkipSingle); - QVERIFY( !track.emblem().isNull() ); -} diff --git a/amarok/tests/services/amazon/TestAmazonTrack.h b/amarok/tests/services/amazon/TestAmazonTrack.h deleted file mode 100644 index 16db49d9..00000000 --- a/amarok/tests/services/amazon/TestAmazonTrack.h +++ /dev/null @@ -1,33 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Sven Krohlas * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 Pulic License for more details. * - * * - * You should have received a copy of the GNU General Public License along with * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef TESTAMAZONTRACK_H -#define TESTAMAZONTRACK_H - -#include - -class TestAmazonTrack : public QObject -{ - Q_OBJECT -public: - TestAmazonTrack(); - -private slots: - void testConstructor(); - void testEmblem(); -}; - -#endif // TESTAMAZONTRACK_H diff --git a/amarok/tests/synchronization/CMakeLists.txt b/amarok/tests/synchronization/CMakeLists.txt deleted file mode 100644 index 4a2ec93b..00000000 --- a/amarok/tests/synchronization/CMakeLists.txt +++ /dev/null @@ -1,88 +0,0 @@ - -include_directories( - .. - ${AMAROK_SOURCE_TREE} - ${CMAKE_BINARY_DIR}/src - ${AMAROK_COLLECTION_SUPPORT_DIR} - ${KDE4_INCLUDE_DIR} - ${QT_INCLUDES} - ${GOOGLEMOCK_INCLUDE_DIR} - ) - -#------------------------ TestMasterSlaveSynchronizationJob ----------------------------- - -set( testmasterslave_SRCS - TestMasterSlaveSynchronizationJob.cpp - ${AMAROK_SOURCE_TREE}/synchronization/SynchronizationBaseJob.cpp - ${AMAROK_SOURCE_TREE}/synchronization/MasterSlaveSynchronizationJob.cpp - ${GOOGLEMOCK_SRCS} -) - -kde4_add_unit_test( testmasterslavesynchronizationjob ${testmasterslave_SRCS} ) - -add_dependencies( testmasterslavesynchronizationjob amarokcore ) -add_dependencies( testmasterslavesynchronizationjob amaroklib ) - -target_link_libraries(testmasterslavesynchronizationjob - amarokcore - amaroklib - ${KDE4_KDECORE_LIBS} - ${KDE4_KIO_LIBS} - ${KDE4_SOLID_LIBRARY} - ${QT_QTGUI_LIBRARY} - ${KDE4_THREADWEAVER_LIBS} - ${QT_QTTEST_LIBRARY} - ${QT_QTCORE_LIBRARY} - ${GOOGLEMOCK_LIBRARIES}) - -#------------------------ TestUnionJob ----------------------------- - -set( testunion_SRCS - TestUnionJob.cpp - ${AMAROK_SOURCE_TREE}/synchronization/SynchronizationBaseJob.cpp - ${AMAROK_SOURCE_TREE}/synchronization/UnionJob.cpp - ${GOOGLEMOCK_SRCS} -) - -kde4_add_unit_test( testunionjob ${testunion_SRCS} ) -add_dependencies( testunionjob amarokcore ) -add_dependencies( testunionjob amaroklib ) - -target_link_libraries(testunionjob - amarokcore - amaroklib - ${KDE4_KDECORE_LIBS} - ${KDE4_KIO_LIBS} - ${KDE4_KDEUI_LIBS} - ${KDE4_SOLID_LIBRARY} - ${QT_QTGUI_LIBRARY} - ${KDE4_THREADWEAVER_LIBS} - ${QT_QTTEST_LIBRARY} - ${QT_QTCORE_LIBRARY} - ${GOOGLEMOCK_LIBRARIES}) - -#------------------------ TestOneWaySynchronizationJob ----------------------------- - -set( testonewaysynchronization_SRCS - TestOneWaySynchronizationJob.cpp - ${AMAROK_SOURCE_TREE}/synchronization/SynchronizationBaseJob.cpp - ${AMAROK_SOURCE_TREE}/synchronization/OneWaySynchronizationJob.cpp - ${GOOGLEMOCK_SRCS} -) - -kde4_add_unit_test( testonewaysynchronizationjob ${testonewaysynchronization_SRCS} ) -add_dependencies( testonewaysynchronizationjob amarokcore ) -add_dependencies( testonewaysynchronizationjob amaroklib ) - -target_link_libraries(testonewaysynchronizationjob - amarokcore - amaroklib - ${KDE4_KDECORE_LIBS} - ${KDE4_KIO_LIBS} - ${KDE4_KDEUI_LIBS} - ${KDE4_SOLID_LIBRARY} - ${QT_QTGUI_LIBRARY} - ${KDE4_THREADWEAVER_LIBS} - ${QT_QTTEST_LIBRARY} - ${QT_QTCORE_LIBRARY} - ${GOOGLEMOCK_LIBRARIES}) diff --git a/amarok/tests/synchronization/TestMasterSlaveSynchronizationJob.cpp b/amarok/tests/synchronization/TestMasterSlaveSynchronizationJob.cpp deleted file mode 100644 index b8b59c40..00000000 --- a/amarok/tests/synchronization/TestMasterSlaveSynchronizationJob.cpp +++ /dev/null @@ -1,445 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "TestMasterSlaveSynchronizationJob.h" - -#include "core/support/Debug.h" -#include "core/collections/CollectionLocation.h" -#include "core/collections/CollectionLocationDelegate.h" -#include "core/support/Components.h" -#include "synchronization/MasterSlaveSynchronizationJob.h" - -#include "CollectionTestImpl.h" -#include "core/collections/MockCollectionLocationDelegate.h" -#include "mocks/MockTrack.h" -#include "mocks/MockAlbum.h" -#include "mocks/MockArtist.h" - -#include -#include - -#include - -#include - -QTEST_KDEMAIN_CORE( TestMasterSlaveSynchronizationJob ) - -using ::testing::Return; -using ::testing::AnyNumber; -using ::testing::_; - -static int trackCopyCount; -static int trackRemoveCount; - -namespace Collections { - -class MyCollectionLocation : public CollectionLocation -{ -public: - Collections::CollectionTestImpl *coll; - - QString prettyLocation() const { return "foo"; } - bool isWritable() const { return true; } - - void removeUrlsFromCollection( const Meta::TrackList &sources ) - { - trackRemoveCount += sources.count(); - coll->mc->acquireWriteLock(); - TrackMap map = coll->mc->trackMap(); - foreach( const Meta::TrackPtr &track, sources ) - map.remove( track->uidUrl() ); - coll->mc->setTrackMap( map ); - coll->mc->releaseLock(); - slotRemoveOperationFinished(); - } - - void copyUrlsToCollection(const QMap &sources, const Transcoding::Configuration& conf) - { - Q_UNUSED( conf ) - trackCopyCount = sources.count(); - foreach( const Meta::TrackPtr &track, sources.keys() ) - { - coll->mc->addTrack( track ); - } - } -}; - -class MyCollectionTestImpl : public CollectionTestImpl -{ -public: - MyCollectionTestImpl( const QString &id ) : CollectionTestImpl( id ) {} - - CollectionLocation* location() - { - MyCollectionLocation *r = new MyCollectionLocation(); - r->coll = this; - return r; - } -}; - -} //namespace Collections - -void addMockTrack( Collections::CollectionTestImpl *coll, const QString &trackName, const QString &artistName, const QString &albumName ) -{ - Meta::MockTrack *track = new Meta::MockTrack(); - ::testing::Mock::AllowLeak( track ); - Meta::TrackPtr trackPtr( track ); - EXPECT_CALL( *track, name() ).Times( AnyNumber() ).WillRepeatedly( Return( trackName ) ); - EXPECT_CALL( *track, uidUrl() ).Times( AnyNumber() ).WillRepeatedly( Return( trackName + '_' + artistName + '_' + albumName ) ); - EXPECT_CALL( *track, playableUrl() ).Times( AnyNumber() ).WillRepeatedly( Return( KUrl( '/' + track->uidUrl() ) ) ); - coll->mc->addTrack( trackPtr ); - - Meta::AlbumPtr albumPtr = coll->mc->albumMap().value( albumName, QString() /* no album artist */ ); - Meta::MockAlbum *album; - Meta::TrackList albumTracks; - if( albumPtr ) - { - album = dynamic_cast( albumPtr.data() ); - if( !album ) - { - QFAIL( "expected a Meta::MockAlbum" ); - return; - } - albumTracks = albumPtr->tracks(); - } - else - { - album = new Meta::MockAlbum(); - ::testing::Mock::AllowLeak( album ); - albumPtr = Meta::AlbumPtr( album ); - EXPECT_CALL( *album, name() ).Times( AnyNumber() ).WillRepeatedly( Return( albumName ) ); - EXPECT_CALL( *album, hasAlbumArtist() ).Times( AnyNumber() ).WillRepeatedly( Return( false ) ); - EXPECT_CALL( *album, albumArtist() ).Times( AnyNumber() ).WillRepeatedly( Return( Meta::ArtistPtr() ) ); - coll->mc->addAlbum( albumPtr ); - } - albumTracks << trackPtr; - EXPECT_CALL( *album, tracks() ).Times( AnyNumber() ).WillRepeatedly( Return( albumTracks ) ); - - EXPECT_CALL( *track, album() ).Times( AnyNumber() ).WillRepeatedly( Return( albumPtr ) ); - - Meta::ArtistPtr artistPtr = coll->mc->artistMap().value( artistName ); - Meta::MockArtist *artist; - Meta::TrackList artistTracks; - if( artistPtr ) - { - artist = dynamic_cast( artistPtr.data() ); - if( !artist ) - { - QFAIL( "expected a Meta::MockArtist" ); - return; - } - artistTracks = artistPtr->tracks(); - } - else - { - artist = new Meta::MockArtist(); - ::testing::Mock::AllowLeak( artist ); - artistPtr = Meta::ArtistPtr( artist ); - EXPECT_CALL( *artist, name() ).Times( AnyNumber() ).WillRepeatedly( Return( artistName ) ); - coll->mc->addArtist( artistPtr ); - } - artistTracks << trackPtr; - EXPECT_CALL( *artist, tracks() ).Times( AnyNumber() ).WillRepeatedly( Return( artistTracks ) ); - EXPECT_CALL( *track, artist() ).Times( AnyNumber() ).WillRepeatedly( Return( artistPtr ) ); -} - -TestMasterSlaveSynchronizationJob::TestMasterSlaveSynchronizationJob() -{ - KCmdLineArgs::init( KGlobal::activeComponent().aboutData() ); - ::testing::InitGoogleMock( &KCmdLineArgs::qtArgc(), KCmdLineArgs::qtArgv() ); - qRegisterMetaType(); - qRegisterMetaType(); - qRegisterMetaType(); -} - -void -TestMasterSlaveSynchronizationJob::init() -{ - trackCopyCount = 0; - trackRemoveCount = 0; -} - -void -TestMasterSlaveSynchronizationJob::testAddTracksToEmptySlave() -{ - Collections::CollectionTestImpl *master = new Collections::MyCollectionTestImpl( "master" ); - Collections::CollectionTestImpl *slave = new Collections::MyCollectionTestImpl( "slave" ); - - //setup master - addMockTrack( master, "track1", "artist1", "album1" ); - QCOMPARE( master->mc->trackMap().count(), 1 ); - QCOMPARE( slave->mc->trackMap().count(), 0 ); - QCOMPARE( trackCopyCount, 0 ); - QCOMPARE( trackRemoveCount, 0 ); - - MasterSlaveSynchronizationJob *job = new MasterSlaveSynchronizationJob(); - job->setMaster( master ); - job->setSlave( slave ); - job->synchronize(); - QTest::kWaitForSignal( job, SIGNAL(destroyed()), 1000 ); - - QCOMPARE( trackCopyCount, 1 ); - QCOMPARE( trackRemoveCount, 0 ); - QCOMPARE( master->mc->trackMap().count(), 1 ); - QCOMPARE( slave->mc->trackMap().count(), 1 ); - delete master; - delete slave; -} - -void -TestMasterSlaveSynchronizationJob::testAddSingleTrack() -{ - Collections::CollectionTestImpl *master = new Collections::MyCollectionTestImpl( "master" ); - Collections::CollectionTestImpl *slave = new Collections::MyCollectionTestImpl( "slave" ); - - //setup - addMockTrack( master, "track1", "artist1", "album1" ); - addMockTrack( slave, "track1", "artist1", "album1" ); - addMockTrack( master, "track2", "artist1", "album1" ); - - QCOMPARE( master->mc->trackMap().count(), 2 ); - QCOMPARE( slave->mc->trackMap().count(), 1 ); - QCOMPARE( trackCopyCount, 0 ); - QCOMPARE( trackRemoveCount, 0 ); - - //test - MasterSlaveSynchronizationJob *job = new MasterSlaveSynchronizationJob(); - job->setMaster( master ); - job->setSlave( slave ); - job->synchronize(); - QTest::kWaitForSignal( job, SIGNAL(destroyed()), 1000 ); - - //verify - QCOMPARE( trackCopyCount, 1 ); - QCOMPARE( trackRemoveCount, 0 ); - QCOMPARE( master->mc->trackMap().count(), 2 ); - QCOMPARE( slave->mc->trackMap().count(), 2 ); - - delete master; - delete slave; -} - -void -TestMasterSlaveSynchronizationJob::testAddAlbum() -{ - Collections::CollectionTestImpl *master = new Collections::MyCollectionTestImpl( "master" ); - Collections::CollectionTestImpl *slave = new Collections::MyCollectionTestImpl( "slave" ); - - //setup - addMockTrack( master, "track1", "artist1", "album1" ); - addMockTrack( slave, "track1", "artist1", "album1" ); - addMockTrack( master, "track1", "artist1", "album2" ); - - QCOMPARE( master->mc->trackMap().count(), 2 ); - QCOMPARE( slave->mc->trackMap().count(), 1 ); - QCOMPARE( trackCopyCount, 0 ); - QCOMPARE( trackRemoveCount, 0 ); - - //test - MasterSlaveSynchronizationJob *job = new MasterSlaveSynchronizationJob(); - job->setMaster( master ); - job->setSlave( slave ); - job->synchronize(); - QTest::kWaitForSignal( job, SIGNAL(destroyed()), 1000 ); - - //verify - QCOMPARE( trackCopyCount, 1 ); - QCOMPARE( trackRemoveCount, 0 ); - QCOMPARE( master->mc->trackMap().count(), 2 ); - QCOMPARE( slave->mc->trackMap().count(), 2 ); - - delete master; - delete slave; -} - -void -TestMasterSlaveSynchronizationJob::testAddArtist() -{ - Collections::CollectionTestImpl *master = new Collections::MyCollectionTestImpl( "master" ); - Collections::CollectionTestImpl *slave = new Collections::MyCollectionTestImpl( "slave" ); - - //setup - addMockTrack( master, "track1", "artist1", "album1" ); - addMockTrack( slave, "track1", "artist1", "album1" ); - addMockTrack( master, "track1", "artist2", "album1" ); - - QCOMPARE( master->mc->trackMap().count(), 2 ); - QCOMPARE( slave->mc->trackMap().count(), 1 ); - QCOMPARE( trackCopyCount, 0 ); - QCOMPARE( trackRemoveCount, 0 ); - - //test - MasterSlaveSynchronizationJob *job = new MasterSlaveSynchronizationJob(); - job->setMaster( master ); - job->setSlave( slave ); - job->synchronize(); - QTest::kWaitForSignal( job, SIGNAL(destroyed()), 1000 ); - - //verify - QCOMPARE( trackCopyCount, 1 ); - QCOMPARE( trackRemoveCount, 0 ); - QCOMPARE( master->mc->trackMap().count(), 2 ); - QCOMPARE( slave->mc->trackMap().count(), 2 ); - - delete master; - delete slave; -} - -void -TestMasterSlaveSynchronizationJob::testRemoveSingleTrack() -{ - Collections::CollectionTestImpl *master = new Collections::MyCollectionTestImpl( "master" ); - Collections::CollectionTestImpl *slave = new Collections::MyCollectionTestImpl( "slave" ); - - Collections::MockCollectionLocationDelegate *delegate = new Collections::MockCollectionLocationDelegate(); - EXPECT_CALL( *delegate, reallyDelete( _, _) ).Times( AnyNumber() ).WillRepeatedly( Return( true ) ); - Amarok::Components::setCollectionLocationDelegate( delegate ); - - //setup - addMockTrack( master, "track1", "artist1", "album1" ); - addMockTrack( slave, "track1", "artist1", "album1" ); - addMockTrack( slave, "track2", "artist1", "album1" ); - - QCOMPARE( master->mc->trackMap().count(), 1 ); - QCOMPARE( slave->mc->trackMap().count(), 2 ); - QCOMPARE( trackCopyCount, 0 ); - QCOMPARE( trackRemoveCount, 0 ); - - //test - MasterSlaveSynchronizationJob *job = new MasterSlaveSynchronizationJob(); - job->setMaster( master ); - job->setSlave( slave ); - job->synchronize(); - QTest::kWaitForSignal( job, SIGNAL(destroyed()), 1000 ); - - //verify - QCOMPARE( trackCopyCount, 0 ); - QCOMPARE( trackRemoveCount, 1 ); - QCOMPARE( master->mc->trackMap().count(), 1 ); - QCOMPARE( slave->mc->trackMap().count(), 1 ); - - delete master; - delete slave; - delete Amarok::Components::setCollectionLocationDelegate( 0 ); -} - -void -TestMasterSlaveSynchronizationJob::testRemoveAlbum() -{ - Collections::CollectionTestImpl *master = new Collections::MyCollectionTestImpl( "master" ); - Collections::CollectionTestImpl *slave = new Collections::MyCollectionTestImpl( "slave" ); - - Collections::MockCollectionLocationDelegate *delegate = new Collections::MockCollectionLocationDelegate(); - EXPECT_CALL( *delegate, reallyDelete( _, _) ).Times( AnyNumber() ).WillRepeatedly( Return( true ) ); - Amarok::Components::setCollectionLocationDelegate( delegate ); - - //setup - addMockTrack( master, "track1", "artist1", "album1" ); - addMockTrack( slave, "track1", "artist1", "album1" ); - addMockTrack( slave, "track1", "artist1", "album2" ); - - QCOMPARE( master->mc->trackMap().count(), 1 ); - QCOMPARE( slave->mc->trackMap().count(), 2 ); - QCOMPARE( trackCopyCount, 0 ); - QCOMPARE( trackRemoveCount, 0 ); - - //test - MasterSlaveSynchronizationJob *job = new MasterSlaveSynchronizationJob(); - job->setMaster( master ); - job->setSlave( slave ); - job->synchronize(); - QTest::kWaitForSignal( job, SIGNAL(destroyed()), 1000 ); - - //verify - QCOMPARE( trackCopyCount, 0 ); - QCOMPARE( trackRemoveCount, 1 ); - QCOMPARE( master->mc->trackMap().count(), 1 ); - QCOMPARE( slave->mc->trackMap().count(), 1 ); - - delete master; - delete slave; - delete Amarok::Components::setCollectionLocationDelegate( 0 ); -} - -void -TestMasterSlaveSynchronizationJob::testRemoveArtist() -{ - Collections::CollectionTestImpl *master = new Collections::MyCollectionTestImpl( "master" ); - Collections::CollectionTestImpl *slave = new Collections::MyCollectionTestImpl( "slave" ); - - Collections::MockCollectionLocationDelegate *delegate = new Collections::MockCollectionLocationDelegate(); - EXPECT_CALL( *delegate, reallyDelete( _, _) ).Times( AnyNumber() ).WillRepeatedly( Return( true ) ); - Amarok::Components::setCollectionLocationDelegate( delegate ); - - //setup - addMockTrack( master, "track1", "artist1", "album1" ); - addMockTrack( slave, "track1", "artist1", "album1" ); - addMockTrack( slave, "track1", "artist2", "album1" ); - - QCOMPARE( master->mc->trackMap().count(), 1 ); - QCOMPARE( slave->mc->trackMap().count(), 2 ); - QCOMPARE( trackCopyCount, 0 ); - QCOMPARE( trackRemoveCount, 0 ); - - //test - MasterSlaveSynchronizationJob *job = new MasterSlaveSynchronizationJob(); - job->setMaster( master ); - job->setSlave( slave ); - job->synchronize(); - QTest::kWaitForSignal( job, SIGNAL(destroyed()), 1000 ); - - //verify - QCOMPARE( trackCopyCount, 0 ); - QCOMPARE( trackRemoveCount, 1 ); - QCOMPARE( master->mc->trackMap().count(), 1 ); - QCOMPARE( slave->mc->trackMap().count(), 1 ); - - delete master; - delete slave; - delete Amarok::Components::setCollectionLocationDelegate( 0 ); -} - -void -TestMasterSlaveSynchronizationJob::testEmptyMaster() -{ - Collections::CollectionTestImpl *master = new Collections::MyCollectionTestImpl( "master" ); - Collections::CollectionTestImpl *slave = new Collections::MyCollectionTestImpl( "slave" ); - - Collections::MockCollectionLocationDelegate *delegate = new Collections::MockCollectionLocationDelegate(); - EXPECT_CALL( *delegate, reallyDelete( _, _) ).Times( AnyNumber() ).WillRepeatedly( Return( true ) ); - Amarok::Components::setCollectionLocationDelegate( delegate ); - - //setup master - addMockTrack( slave, "track1", "artist1", "album1" ); - QCOMPARE( master->mc->trackMap().count(), 0 ); - QCOMPARE( slave->mc->trackMap().count(), 1 ); - QCOMPARE( trackCopyCount, 0 ); - QCOMPARE( trackRemoveCount, 0 ); - - MasterSlaveSynchronizationJob *job = new MasterSlaveSynchronizationJob(); - job->setMaster( master ); - job->setSlave( slave ); - job->synchronize(); - QTest::kWaitForSignal( job, SIGNAL(destroyed()), 1000 ); - - QCOMPARE( trackCopyCount, 0 ); - QCOMPARE( trackRemoveCount, 1 ); - QCOMPARE( master->mc->trackMap().count(), 0 ); - QCOMPARE( slave->mc->trackMap().count(), 0 ); - delete master; - delete slave; - delete Amarok::Components::setCollectionLocationDelegate( 0 ); -} diff --git a/amarok/tests/synchronization/TestMasterSlaveSynchronizationJob.h b/amarok/tests/synchronization/TestMasterSlaveSynchronizationJob.h deleted file mode 100644 index e65a3928..00000000 --- a/amarok/tests/synchronization/TestMasterSlaveSynchronizationJob.h +++ /dev/null @@ -1,41 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef TESTMASTERSLAVESYNCHRONIZATIONJOB_H -#define TESTMASTERSLAVESYNCHRONIZATIONJOB_H - -#include - -class TestMasterSlaveSynchronizationJob : public QObject -{ - Q_OBJECT -public: - TestMasterSlaveSynchronizationJob(); - -private slots: - void init(); - - void testAddTracksToEmptySlave(); - void testAddSingleTrack(); - void testAddAlbum(); - void testAddArtist(); - void testRemoveSingleTrack(); - void testRemoveAlbum(); - void testRemoveArtist(); - void testEmptyMaster(); -}; - -#endif diff --git a/amarok/tests/synchronization/TestOneWaySynchronizationJob.cpp b/amarok/tests/synchronization/TestOneWaySynchronizationJob.cpp deleted file mode 100644 index ce7a2b55..00000000 --- a/amarok/tests/synchronization/TestOneWaySynchronizationJob.cpp +++ /dev/null @@ -1,326 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "TestOneWaySynchronizationJob.h" - -#include "core/support/Debug.h" -#include "core/collections/CollectionLocation.h" -#include "synchronization/OneWaySynchronizationJob.h" - -#include "CollectionTestImpl.h" -#include "mocks/MockTrack.h" -#include "mocks/MockAlbum.h" -#include "mocks/MockArtist.h" - -#include -#include - -#include - -#include - -QTEST_KDEMAIN_CORE( TestOneWaySynchronizationJob ) - -using ::testing::Return; -using ::testing::AnyNumber; - - -static int trackCopyCount; - -namespace Collections { - -class MyCollectionLocation : public CollectionLocation -{ -public: - Collections::CollectionTestImpl *coll; - - QString prettyLocation() const { return "foo"; } - bool isWritable() const { return true; } - void copyUrlsToCollection(const QMap &sources, const Transcoding::Configuration& conf) - { - Q_UNUSED( conf ) - // qDebug() << "adding " << sources.count() << " tracks to " << coll->collectionId(); - trackCopyCount = sources.count(); - foreach( const Meta::TrackPtr &track, sources.keys() ) - { - coll->mc->addTrack( track ); - } - } -}; - -class MyCollectionTestImpl : public CollectionTestImpl -{ -public: - MyCollectionTestImpl( const QString &id ) : CollectionTestImpl( id ) {} - - CollectionLocation* location() - { - MyCollectionLocation *r = new MyCollectionLocation(); - r->coll = this; - return r; - } -}; - -} //namespace Collections - -void addMockTrack( Collections::CollectionTestImpl *coll, const QString &trackName, const QString &artistName, const QString &albumName ) -{ - Meta::MockTrack *track = new Meta::MockTrack(); - ::testing::Mock::AllowLeak( track ); - Meta::TrackPtr trackPtr( track ); - EXPECT_CALL( *track, name() ).Times( AnyNumber() ).WillRepeatedly( Return( trackName ) ); - EXPECT_CALL( *track, uidUrl() ).Times( AnyNumber() ).WillRepeatedly( Return( trackName + '_' + artistName + '_' + albumName ) ); - EXPECT_CALL( *track, playableUrl() ).Times( AnyNumber() ).WillRepeatedly( Return( KUrl( '/' + track->uidUrl() ) ) ); - EXPECT_CALL( *track, composer() ).Times( AnyNumber() ).WillRepeatedly( Return( Meta::ComposerPtr() ) ); - EXPECT_CALL( *track, genre() ).Times( AnyNumber() ).WillRepeatedly( Return( Meta::GenrePtr() ) ); - EXPECT_CALL( *track, year() ).Times( AnyNumber() ).WillRepeatedly( Return( Meta::YearPtr() ) ); - coll->mc->addTrack( trackPtr ); - - Meta::AlbumPtr albumPtr = coll->mc->albumMap().value( albumName, QString() /* no album artist */ ); - Meta::MockAlbum *album; - Meta::TrackList albumTracks; - if( albumPtr ) - { - album = dynamic_cast( albumPtr.data() ); - if( !album ) - { - QFAIL( "expected a Meta::MockAlbum" ); - return; - } - albumTracks = albumPtr->tracks(); - } - else - { - album = new Meta::MockAlbum(); - ::testing::Mock::AllowLeak( album ); - albumPtr = Meta::AlbumPtr( album ); - EXPECT_CALL( *album, name() ).Times( AnyNumber() ).WillRepeatedly( Return( albumName ) ); - EXPECT_CALL( *album, hasAlbumArtist() ).Times( AnyNumber() ).WillRepeatedly( Return( false ) ); - EXPECT_CALL( *album, albumArtist() ).Times( AnyNumber() ).WillRepeatedly( Return( Meta::ArtistPtr() ) ); - coll->mc->addAlbum( albumPtr ); - } - albumTracks << trackPtr; - EXPECT_CALL( *album, tracks() ).Times( AnyNumber() ).WillRepeatedly( Return( albumTracks ) ); - - EXPECT_CALL( *track, album() ).Times( AnyNumber() ).WillRepeatedly( Return( albumPtr ) ); - - Meta::ArtistPtr artistPtr = coll->mc->artistMap().value( artistName ); - Meta::MockArtist *artist; - Meta::TrackList artistTracks; - if( artistPtr ) - { - artist = dynamic_cast( artistPtr.data() ); - if( !artist ) - { - QFAIL( "expected a Meta::MockArtist" ); - return; - } - artistTracks = artistPtr->tracks(); - } - else - { - artist = new Meta::MockArtist(); - ::testing::Mock::AllowLeak( artist ); - artistPtr = Meta::ArtistPtr( artist ); - EXPECT_CALL( *artist, name() ).Times( AnyNumber() ).WillRepeatedly( Return( artistName ) ); - coll->mc->addArtist( artistPtr ); - } - artistTracks << trackPtr; - EXPECT_CALL( *artist, tracks() ).Times( AnyNumber() ).WillRepeatedly( Return( artistTracks ) ); - EXPECT_CALL( *track, artist() ).Times( AnyNumber() ).WillRepeatedly( Return( artistPtr ) ); - EXPECT_CALL( *album, albumArtist() ).Times( AnyNumber() ).WillRepeatedly( Return( artistPtr ) ); -} - -TestOneWaySynchronizationJob::TestOneWaySynchronizationJob() : QObject() -{ - KCmdLineArgs::init( KGlobal::activeComponent().aboutData() ); - ::testing::InitGoogleMock( &KCmdLineArgs::qtArgc(), KCmdLineArgs::qtArgv() ); - qRegisterMetaType(); - qRegisterMetaType(); - qRegisterMetaType(); -} - -void -TestOneWaySynchronizationJob::init() -{ - trackCopyCount = 0; -} - -void -TestOneWaySynchronizationJob::testAddTrackToTarget() -{ - Collections::CollectionTestImpl *source = new Collections::MyCollectionTestImpl( "source" ); - Collections::CollectionTestImpl *target = new Collections::MyCollectionTestImpl( "target" ); - - addMockTrack( source, "track1", "artist1", "album1" ); - addMockTrack( source, "track2", "artist1", "album1" ); - addMockTrack( target, "track1", "artist1", "album1" ); - - QCOMPARE( trackCopyCount, 0 ); - QCOMPARE( source->mc->trackMap().count(), 2 ); - QCOMPARE( target->mc->trackMap().count(), 1 ); - - OneWaySynchronizationJob *job = new OneWaySynchronizationJob(); - job->setSource( source ); - job->setTarget( target ); - job->synchronize(); - QTest::kWaitForSignal( job, SIGNAL(destroyed()), 1000 ); - - QCOMPARE( trackCopyCount, 1 ); - QCOMPARE( source->mc->trackMap().count(), 2 ); - QCOMPARE( target->mc->trackMap().count(), 2 ); - - delete source, - delete target; -} - -void -TestOneWaySynchronizationJob::testAddAlbumToTarget() -{ - Collections::CollectionTestImpl *source = new Collections::MyCollectionTestImpl( "source" ); - Collections::CollectionTestImpl *target = new Collections::MyCollectionTestImpl( "target" ); - - addMockTrack( source, "track1", "artist1", "album1" ); - addMockTrack( source, "track1", "artist1", "album2" ); - addMockTrack( target, "track1", "artist1", "album1" ); - - QCOMPARE( trackCopyCount, 0 ); - QCOMPARE( source->mc->trackMap().count(), 2 ); - QCOMPARE( target->mc->trackMap().count(), 1 ); - - OneWaySynchronizationJob *job = new OneWaySynchronizationJob(); - job->setSource( source ); - job->setTarget( target ); - job->synchronize(); - QTest::kWaitForSignal( job, SIGNAL(destroyed()), 1000 ); - - QCOMPARE( trackCopyCount, 1 ); - QCOMPARE( source->mc->trackMap().count(), 2 ); - QCOMPARE( target->mc->trackMap().count(), 2 ); - - delete source, - delete target; -} - -void -TestOneWaySynchronizationJob::testAddArtistToTarget() -{ - Collections::CollectionTestImpl *source = new Collections::MyCollectionTestImpl( "source" ); - Collections::CollectionTestImpl *target = new Collections::MyCollectionTestImpl( "target" ); - - addMockTrack( source, "track1", "artist1", "album1" ); - addMockTrack( source, "track1", "artist2", "album1" ); - addMockTrack( target, "track1", "artist1", "album1" ); - - QCOMPARE( trackCopyCount, 0 ); - QCOMPARE( source->mc->trackMap().count(), 2 ); - QCOMPARE( target->mc->trackMap().count(), 1 ); - - OneWaySynchronizationJob *job = new OneWaySynchronizationJob(); - job->setSource( source ); - job->setTarget( target ); - job->synchronize(); - QTest::kWaitForSignal( job, SIGNAL(destroyed()), 1000 ); - - QCOMPARE( trackCopyCount, 1 ); - QCOMPARE( source->mc->trackMap().count(), 2 ); - QCOMPARE( target->mc->trackMap().count(), 2 ); - - delete source, - delete target; -} - -void -TestOneWaySynchronizationJob::testEmptyTarget() -{ - Collections::CollectionTestImpl *source = new Collections::MyCollectionTestImpl( "source" ); - Collections::CollectionTestImpl *target = new Collections::MyCollectionTestImpl( "target" ); - - addMockTrack( source, "track1", "artist1", "album1" ); - addMockTrack( source, "track2", "artist1", "album1" ); - - QCOMPARE( trackCopyCount, 0 ); - QCOMPARE( source->mc->trackMap().count(), 2 ); - QCOMPARE( target->mc->trackMap().count(), 0 ); - - OneWaySynchronizationJob *job = new OneWaySynchronizationJob(); - job->setSource( source ); - job->setTarget( target ); - job->synchronize(); - QTest::kWaitForSignal( job, SIGNAL(destroyed()), 1000 ); - - QCOMPARE( trackCopyCount, 2 ); - QCOMPARE( source->mc->trackMap().count(), 2 ); - QCOMPARE( target->mc->trackMap().count(), 2 ); - - delete source, - delete target; -} - -void -TestOneWaySynchronizationJob::testEmptySourceWithNonEmptyTarget() -{ - Collections::CollectionTestImpl *source = new Collections::MyCollectionTestImpl( "source" ); - Collections::CollectionTestImpl *target = new Collections::MyCollectionTestImpl( "target" ); - - addMockTrack( target, "track1", "artist1", "album1" ); - - QCOMPARE( trackCopyCount, 0 ); - QCOMPARE( source->mc->trackMap().count(), 0 ); - QCOMPARE( target->mc->trackMap().count(), 1 ); - - OneWaySynchronizationJob *job = new OneWaySynchronizationJob(); - job->setSource( source ); - job->setTarget( target ); - job->synchronize(); - QTest::kWaitForSignal( job, SIGNAL(destroyed()), 1000 ); - - QCOMPARE( trackCopyCount, 0 ); - QCOMPARE( source->mc->trackMap().count(), 0 ); - QCOMPARE( target->mc->trackMap().count(), 1 ); - - delete source, - delete target; -} - -void -TestOneWaySynchronizationJob::testNoActionNecessary() -{ - Collections::CollectionTestImpl *source = new Collections::MyCollectionTestImpl( "source" ); - Collections::CollectionTestImpl *target = new Collections::MyCollectionTestImpl( "target" ); - - addMockTrack( source, "track1", "artist1", "album1" ); - addMockTrack( source, "track2", "artist1", "album1" ); - addMockTrack( target, "track1", "artist1", "album1" ); - addMockTrack( target, "track2", "artist1", "album1" ); - - QCOMPARE( trackCopyCount, 0 ); - QCOMPARE( source->mc->trackMap().count(), 2 ); - QCOMPARE( target->mc->trackMap().count(), 2 ); - - OneWaySynchronizationJob *job = new OneWaySynchronizationJob(); - job->setSource( source ); - job->setTarget( target ); - job->synchronize(); - QTest::kWaitForSignal( job, SIGNAL(destroyed()), 1000 ); - - QCOMPARE( trackCopyCount, 0 ); - QCOMPARE( source->mc->trackMap().count(), 2 ); - QCOMPARE( target->mc->trackMap().count(), 2 ); - - delete source, - delete target; -} diff --git a/amarok/tests/synchronization/TestOneWaySynchronizationJob.h b/amarok/tests/synchronization/TestOneWaySynchronizationJob.h deleted file mode 100644 index 73cb0905..00000000 --- a/amarok/tests/synchronization/TestOneWaySynchronizationJob.h +++ /dev/null @@ -1,39 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef TESTONEWAYSYNCHRONIZATIONJOB_H -#define TESTONEWAYSYNCHRONIZATIONJOB_H - -#include - -class TestOneWaySynchronizationJob : public QObject -{ - Q_OBJECT -public: - TestOneWaySynchronizationJob(); - -private slots: - void init(); - - void testEmptyTarget(); - void testEmptySourceWithNonEmptyTarget(); - void testAddTrackToTarget(); - void testAddAlbumToTarget(); - void testAddArtistToTarget(); - void testNoActionNecessary(); -}; - -#endif diff --git a/amarok/tests/synchronization/TestUnionJob.cpp b/amarok/tests/synchronization/TestUnionJob.cpp deleted file mode 100644 index 2343577e..00000000 --- a/amarok/tests/synchronization/TestUnionJob.cpp +++ /dev/null @@ -1,266 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "TestUnionJob.h" - -#include "core/support/Debug.h" -#include "core/collections/CollectionLocation.h" -#include "synchronization/UnionJob.h" - -#include "CollectionTestImpl.h" -#include "mocks/MockTrack.h" -#include "mocks/MockAlbum.h" -#include "mocks/MockArtist.h" - -#include -#include - -#include - -#include - -#include - -QTEST_KDEMAIN_CORE( TestUnionJob ) - -using ::testing::Return; -using ::testing::AnyNumber; - -static QList trackCopyCount; - -namespace Collections { - -class MyCollectionLocation : public CollectionLocation -{ -public: - Collections::CollectionTestImpl *coll; - - QString prettyLocation() const { return "foo"; } - bool isWritable() const { return true; } - bool remove( const Meta::TrackPtr &track ) - { - coll->mc->acquireWriteLock(); - //theoretically we should clean up the other maps as well... - TrackMap map = coll->mc->trackMap(); - map.remove( track->uidUrl() ); - coll->mc->setTrackMap( map ); - coll->mc->releaseLock(); - return true; - } - void copyUrlsToCollection(const QMap &sources, const Transcoding::Configuration& conf) - { - Q_UNUSED( conf ) - trackCopyCount << sources.count(); - foreach( const Meta::TrackPtr &track, sources.keys() ) - { - coll->mc->addTrack( track ); - } - } -}; - -class MyCollectionTestImpl : public CollectionTestImpl -{ -public: - MyCollectionTestImpl( const QString &id ) : CollectionTestImpl( id ) {} - - CollectionLocation* location() - { - MyCollectionLocation *r = new MyCollectionLocation(); - r->coll = this; - return r; - } -}; - -} //namespace Collections - -void addMockTrack( Collections::CollectionTestImpl *coll, const QString &trackName, const QString &artistName, const QString &albumName ) -{ - Meta::MockTrack *track = new Meta::MockTrack(); - ::testing::Mock::AllowLeak( track ); - Meta::TrackPtr trackPtr( track ); - EXPECT_CALL( *track, name() ).Times( AnyNumber() ).WillRepeatedly( Return( trackName ) ); - EXPECT_CALL( *track, uidUrl() ).Times( AnyNumber() ).WillRepeatedly( Return( trackName + '_' + artistName + '_' + albumName ) ); - EXPECT_CALL( *track, playableUrl() ).Times( AnyNumber() ).WillRepeatedly( Return( KUrl( '/' + track->uidUrl() ) ) ); - coll->mc->addTrack( trackPtr ); - - Meta::AlbumPtr albumPtr = coll->mc->albumMap().value( albumName, QString() /* no album artist */ ); - Meta::MockAlbum *album; - Meta::TrackList albumTracks; - if( albumPtr ) - { - album = dynamic_cast( albumPtr.data() ); - if( !album ) - { - QFAIL( "expected a Meta::MockAlbum" ); - return; - } - albumTracks = albumPtr->tracks(); - } - else - { - album = new Meta::MockAlbum(); - ::testing::Mock::AllowLeak( album ); - albumPtr = Meta::AlbumPtr( album ); - EXPECT_CALL( *album, name() ).Times( AnyNumber() ).WillRepeatedly( Return( albumName ) ); - EXPECT_CALL( *album, hasAlbumArtist() ).Times( AnyNumber() ).WillRepeatedly( Return( false ) ); - EXPECT_CALL( *album, albumArtist() ).Times( AnyNumber() ).WillRepeatedly( Return( Meta::ArtistPtr() ) ); - coll->mc->addAlbum( albumPtr ); - } - albumTracks << trackPtr; - EXPECT_CALL( *album, tracks() ).Times( AnyNumber() ).WillRepeatedly( Return( albumTracks ) ); - - EXPECT_CALL( *track, album() ).Times( AnyNumber() ).WillRepeatedly( Return( albumPtr ) ); - - Meta::ArtistPtr artistPtr = coll->mc->artistMap().value( artistName ); - Meta::MockArtist *artist; - Meta::TrackList artistTracks; - if( artistPtr ) - { - artist = dynamic_cast( artistPtr.data() ); - if( !artist ) - { - QFAIL( "expected a Meta::MockArtist" ); - return; - } - artistTracks = artistPtr->tracks(); - } - else - { - artist = new Meta::MockArtist(); - ::testing::Mock::AllowLeak( artist ); - artistPtr = Meta::ArtistPtr( artist ); - EXPECT_CALL( *artist, name() ).Times( AnyNumber() ).WillRepeatedly( Return( artistName ) ); - coll->mc->addArtist( artistPtr ); - } - artistTracks << trackPtr; - EXPECT_CALL( *artist, tracks() ).Times( AnyNumber() ).WillRepeatedly( Return( artistTracks ) ); - EXPECT_CALL( *track, artist() ).Times( AnyNumber() ).WillRepeatedly( Return( artistPtr ) ); -} - -TestUnionJob::TestUnionJob() : QObject() -{ - KCmdLineArgs::init( KGlobal::activeComponent().aboutData() ); - ::testing::InitGoogleMock( &KCmdLineArgs::qtArgc(), KCmdLineArgs::qtArgv() ); - qRegisterMetaType(); - qRegisterMetaType(); - qRegisterMetaType(); -} - -void -TestUnionJob::init() -{ - trackCopyCount.clear(); -} - -void -TestUnionJob::testEmptyA() -{ - Collections::CollectionTestImpl *collA = new Collections::MyCollectionTestImpl("A"); - Collections::CollectionTestImpl *collB = new Collections::MyCollectionTestImpl("B"); - - addMockTrack( collB, "track1", "artist1", "album1" ); - QCOMPARE( collA->mc->trackMap().count(), 0 ); - QCOMPARE( collB->mc->trackMap().count(), 1 ); - QVERIFY( trackCopyCount.isEmpty() ); - - UnionJob *job = new UnionJob( collA, collB ); - job->synchronize(); - QTest::kWaitForSignal( job, SIGNAL(destroyed()), 1000 ); - - QCOMPARE( trackCopyCount.size(), 1 ); - QVERIFY( trackCopyCount.contains( 1 ) ); - QCOMPARE( collA->mc->trackMap().count(), 1 ); - QCOMPARE( collB->mc->trackMap().count(), 1 ); - - delete collA; - delete collB; -} - -void -TestUnionJob::testEmptyB() -{ - Collections::CollectionTestImpl *collA = new Collections::MyCollectionTestImpl("A"); - Collections::CollectionTestImpl *collB = new Collections::MyCollectionTestImpl("B"); - - addMockTrack( collA, "track1", "artist1", "album1" ); - QCOMPARE( collA->mc->trackMap().count(), 1 ); - QCOMPARE( collB->mc->trackMap().count(), 0 ); - QVERIFY( trackCopyCount.isEmpty() ); - - UnionJob *job = new UnionJob( collA, collB ); - job->synchronize(); - QTest::kWaitForSignal( job, SIGNAL(destroyed()), 1000 ); - - QCOMPARE( trackCopyCount.size(), 1 ); - QVERIFY( trackCopyCount.contains( 1 ) ); - QCOMPARE( collA->mc->trackMap().count(), 1 ); - QCOMPARE( collB->mc->trackMap().count(), 1 ); - - delete collA; - delete collB; -} - -void -TestUnionJob::testAddTrackToBoth() -{ - Collections::CollectionTestImpl *collA = new Collections::MyCollectionTestImpl("A"); - Collections::CollectionTestImpl *collB = new Collections::MyCollectionTestImpl("B"); - - addMockTrack( collA, "track1", "artist1", "album1" ); - addMockTrack( collB, "track2", "artist2", "album2" ); - QCOMPARE( collA->mc->trackMap().count(), 1 ); - QCOMPARE( collB->mc->trackMap().count(), 1 ); - QVERIFY( trackCopyCount.isEmpty() ); - - UnionJob *job = new UnionJob( collA, collB ); - job->synchronize(); - QTest::kWaitForSignal( job, SIGNAL(destroyed()), 1000 ); - - QCOMPARE( trackCopyCount.size(), 2 ); - QCOMPARE( trackCopyCount.at( 0 ), 1 ); - QCOMPARE( trackCopyCount.at( 1 ), 1 ); - QCOMPARE( collA->mc->trackMap().count(), 2 ); - QCOMPARE( collB->mc->trackMap().count(), 2 ); - - delete collA; - delete collB; -} - -void -TestUnionJob::testTrackAlreadyInBoth() -{ - Collections::CollectionTestImpl *collA = new Collections::MyCollectionTestImpl("A"); - Collections::CollectionTestImpl *collB = new Collections::MyCollectionTestImpl("B"); - - addMockTrack( collA, "track1", "artist1", "album1" ); - addMockTrack( collB, "track1", "artist1", "album1" ); - addMockTrack( collB, "track2", "artist2", "album2" ); - QCOMPARE( collA->mc->trackMap().count(), 1 ); - QCOMPARE( collB->mc->trackMap().count(), 2 ); - QVERIFY( trackCopyCount.isEmpty() ); - - UnionJob *job = new UnionJob( collA, collB ); - job->synchronize(); - QTest::kWaitForSignal( job, SIGNAL(destroyed()), 1000 ); - - QCOMPARE( trackCopyCount.size(), 1 ); - QVERIFY( trackCopyCount.contains( 1 ) ); - QCOMPARE( collA->mc->trackMap().count(), 2 ); - QCOMPARE( collB->mc->trackMap().count(), 2 ); - - delete collA; - delete collB; -} diff --git a/amarok/tests/synchronization/TestUnionJob.h b/amarok/tests/synchronization/TestUnionJob.h deleted file mode 100644 index 1dbaee31..00000000 --- a/amarok/tests/synchronization/TestUnionJob.h +++ /dev/null @@ -1,42 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Maximilian Kossick * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef TESTUNIONJOB_H -#define TESTUNIONJOB_H - -#include - -class TestUnionJob : public QObject -{ - Q_OBJECT -public: - TestUnionJob(); - -private slots: - void init(); - - void testEmptyA(); - void testEmptyB(); - void testAddTrackToBoth(); - void testTrackAlreadyInBoth(); - //void testAddAlbumToBoth(); - //void testAlbumAlreadyInBoth(); - //void testAddArtistToBoth(); - //void testAddArtistAlreadyInBoth(); -}; - - -#endif diff --git a/amarok/tests/timecode/CMakeLists.txt b/amarok/tests/timecode/CMakeLists.txt deleted file mode 100644 index 7e7c55ff..00000000 --- a/amarok/tests/timecode/CMakeLists.txt +++ /dev/null @@ -1,18 +0,0 @@ -include_directories( . - ${AMAROK_TEST_TREE} - ${CMAKE_BINARY_DIR}/src - ${CMAKE_BINARY_DIR}/tests -) -#------------------------ Test TimecodeTrackProvider ----------------------------- - -set( testtimecodetrackprovider_SRCS - TestTimecodeTrackProvider.cpp - ${AMAROK_SOURCE_TREE}/core-impl/meta/timecode/TimecodeTrackProvider.cpp - ${AMAROK_SOURCE_TREE}/core-impl/meta/timecode/TimecodeMeta.cpp - ${AMAROK_SOURCE_TREE}/core-impl/capabilities/timecode/TimecodeBoundedPlaybackCapability.cpp - ${AMAROK_SOURCE_TREE}/core/capabilities/BoundedPlaybackCapability.cpp - ) - -kde4_add_unit_test( testtimecodetrackprovider ${testtimecodetrackprovider_SRCS} ) - -target_link_libraries(testtimecodetrackprovider ${KDE4_KDECORE_LIBS} ${QT_QTTEST_LIBRARY} ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} amarokcore amaroklib ) diff --git a/amarok/tests/timecode/TestTimecodeTrackProvider.cpp b/amarok/tests/timecode/TestTimecodeTrackProvider.cpp deleted file mode 100644 index 54311ddd..00000000 --- a/amarok/tests/timecode/TestTimecodeTrackProvider.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2009 Sven Krohlas * - * * - * This program 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 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#include "TestTimecodeTrackProvider.h" - -#include "config-amarok-test.h" -#include "core/meta/Meta.h" -#include "core-impl/meta/timecode/TimecodeTrackProvider.h" - -#include - -#include - -QTEST_KDEMAIN_CORE( TestTimecodeTrackProvider ) - -TestTimecodeTrackProvider::TestTimecodeTrackProvider() -{} - -void TestTimecodeTrackProvider::initTestCase() -{ - m_testProvider = new TimecodeTrackProvider(); -} - -void TestTimecodeTrackProvider::cleanupTestCase() -{ - delete m_testProvider; -} - -QString -TestTimecodeTrackProvider::dataPath( const QString &relPath ) -{ - return QDir::toNativeSeparators( QString( AMAROK_TEST_DIR ) + '/' + relPath ); -} - -void TestTimecodeTrackProvider::testPossiblyContainsTrack() -{ - QVERIFY( !m_testProvider->possiblyContainsTrack( KUrl( "file:///home/test/test.mp3" ) ) ); - QVERIFY( m_testProvider->possiblyContainsTrack( KUrl( "file:///home/test/test.mp3:0-23" ) ) ); - QVERIFY( m_testProvider->possiblyContainsTrack( KUrl( "file:///home/test/test.mp3:23-42" ) ) ); - QVERIFY( m_testProvider->possiblyContainsTrack( KUrl( "file:///home/test/test.mp3:42-23" ) ) ); - QVERIFY( !m_testProvider->possiblyContainsTrack( KUrl( "file:///home/test/test.mp3:-12-42" ) ) ); -} - -void TestTimecodeTrackProvider::testTrackForUrl() -{ - KUrl testUrl; - testUrl = dataPath( "data/audio/album/" ); - testUrl.addPath( "Track01.ogg:23-42" ); - - Meta::TrackPtr resultTrack = m_testProvider->trackForUrl( testUrl ); - - QVERIFY( resultTrack ); - - QCOMPARE( resultTrack->playableUrl().pathOrUrl(), dataPath( "data/audio/album/Track01.ogg" ) ); -} diff --git a/amarok/tests/timecode/TestTimecodeTrackProvider.h b/amarok/tests/timecode/TestTimecodeTrackProvider.h deleted file mode 100644 index 36ac545f..00000000 --- a/amarok/tests/timecode/TestTimecodeTrackProvider.h +++ /dev/null @@ -1,46 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2009 Sven Krohlas * - * * - * This program 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 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#ifndef TESTTIMECODETRACKPROVIDER_H -#define TESTTIMECODETRACKPROVIDER_H - -#include -#include - -class TimecodeTrackProvider; - -class TestTimecodeTrackProvider : public QObject -{ -Q_OBJECT - -public: - TestTimecodeTrackProvider(); - -private slots: - void initTestCase(); - void cleanupTestCase(); - void testPossiblyContainsTrack(); - void testTrackForUrl(); - -private: - TimecodeTrackProvider *m_testProvider; - QString dataPath( const QString &relPath ); -}; - -#endif // TESTTIMECODETRACKPROVIDER_H diff --git a/amarok/utilities/CMakeLists.txt b/amarok/utilities/CMakeLists.txt deleted file mode 100644 index 7aaaf930..00000000 --- a/amarok/utilities/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -add_subdirectory( afttagger ) -add_subdirectory( amzdownloader ) -add_subdirectory( collectionscanner ) diff --git a/amarok/utilities/afttagger/AFTTagger.cpp b/amarok/utilities/afttagger/AFTTagger.cpp deleted file mode 100644 index 2d2c8bc3..00000000 --- a/amarok/utilities/afttagger/AFTTagger.cpp +++ /dev/null @@ -1,812 +0,0 @@ -/* - * Copyright (c) 2008-2009 Jeff Mitchell - * Qt4QStringToTString and TStringToQString macros Copyright 2002-2008 by Scott Wheeler, wheeler@kde.org, licensed under LGPL 2.1 - * - * This program 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 2 of the License, or - * (at your option) any later version. - * - * This program 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 this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include "AFTTagger.h" -#include "SafeFileSaver.h" - -//Taglib -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wnon-virtual-dtor" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#pragma GCC diagnostic pop - -#include -#include -#include -#include -#include -#include - -#include - -//QT4-happy versions -#define Qt4QStringToTString(s) TagLib::String(s.toUtf8().data(), TagLib::String::UTF8) - -static int s_currentVersion = 1; - -int main( int argc, char *argv[] ) -{ - AFTTagger tagger( argc, argv ); - return tagger.exec(); -} - -AFTTagger::AFTTagger( int &argc, char **argv ) - :QCoreApplication( argc, argv ) - , m_delete( false ) - , m_newid( false ) - , m_quiet( false ) - , m_recurse( false ) - , m_verbose( false ) - , m_fileFolderList() - , m_time() - , m_textStream( stderr ) -{ - - setObjectName( "amarok_afttagger" ); - - readArgs(); - - QString terms; - if( !m_quiet ) - { - m_textStream << qPrintable( tr( "TERMS OF USE:\n\n" - "This program has been extensively tested and errs on the side of safety wherever possible.\n\n" - "With that being said, since this program can modify thousands or hundreds of thousands of files\n" - "at a time, here is the obligatory warning text:\n\n" - "This program makes use of multiple libraries not written by the author, and as such neither\n" - "the author nor the Amarok project can or do take any responsibility for any damage that may\n" - "occur to your files through the use of this program.\n\n" - "If you want more information, please see http://community.kde.org/Amarok/Development/AFT\n\n" - "If you agree to be bound by these terms of use, enter 'y' or 'Y', or anything else to exit:\n" ) ); - - m_textStream.flush(); - std::string response; - std::cin >> response; - std::cin.get(); - - if( response != "y" && response != "Y") - { - m_textStream << tr( "INFO: Terms not accepted; exiting..." ) << endl; - ::exit( 1 ); - } - } - - qsrand(QDateTime::currentDateTime().toTime_t()); - m_time.start(); - - foreach( const QString &path, m_fileFolderList ) - processPath( path ); - - m_textStream << tr( "INFO: All done, exiting..." ) << endl; - ::exit( 0 ); -} - -void -AFTTagger::processPath( const QString &path ) -{ - QFileInfo info( path ); - if( !info.isDir() && !info.isFile() ) - { - if( m_verbose ) - m_textStream << tr( "INFO: Skipping %1 because it is neither a directory nor file." ).arg( path ) << endl; - return; - } - if( info.isDir() ) - { - if( !m_recurse ) - { - if( m_verbose ) - m_textStream << tr( "INFO: Skipping %1 because it is a directory and recursion is not specified." ).arg( path ) << endl; - return; - } - else - { - if( m_verbose ) - m_textStream << tr( "INFO: Processing directory %1" ).arg( path ) << endl; - foreach( const QString &pathEntry, QDir( path ).entryList() ) - { - if( pathEntry != "." && pathEntry != ".." ) - processPath( QDir( path ).canonicalPath() + '/' + pathEntry ); - } - } - } - else //isFile() - { - QString filePath = info.absoluteFilePath(); - - -#ifdef COMPLEX_TAGLIB_FILENAME - const wchar_t *encodedName = reinterpret_cast< const wchar_t *>(filePath.utf16()); -#else - QByteArray fileName = QFile::encodeName( filePath ); - const char *encodedName = fileName.constData(); -#endif - - TagLib::FileRef fileRef = TagLib::FileRef( encodedName, true, TagLib::AudioProperties::Fast ); - - if( fileRef.isNull() ) - { - if( m_verbose ) - m_textStream << tr( "INFO: file %1 not able to be opened by TagLib" ).arg( filePath ) << endl; - return; - } - - m_textStream << tr( "INFO: Processing file %1" ).arg( filePath ) << endl; - - SafeFileSaver sfs( filePath ); - sfs.setVerbose( false ); - sfs.setPrefix( "amarok-afttagger" ); - QString tempFilePath = sfs.prepareToSave(); - if( tempFilePath.isEmpty() ) - { - m_textStream << tr( "Error: could not create temporary file when processing %1" ).arg( filePath ) << endl; - return; - } - - if( m_verbose ) - m_textStream << tr( "INFO: Temporary file is at %1").arg( tempFilePath ) << endl; - -#ifdef COMPLEX_TAGLIB_FILENAME - const wchar_t *encodedName = reinterpret_cast< const wchar_t * >(tempFilePath.utf16()); -#else - QByteArray tempFileName = QFile::encodeName( tempFilePath ); - const char *tempEncodedName = tempFileName.constData(); -#endif - - bool saveNecessary = false; - - TagLib::FileRef tempFileRef = TagLib::FileRef( tempEncodedName, true, TagLib::AudioProperties::Fast ); - if( TagLib::MPEG::File *file = dynamic_cast( tempFileRef.file() ) ) - saveNecessary = handleMPEG( file ); - else if( TagLib::Ogg::File *file = dynamic_cast( tempFileRef.file() ) ) - saveNecessary = handleOgg( file ); - else if( TagLib::FLAC::File *file = dynamic_cast( tempFileRef.file() ) ) - saveNecessary = handleFLAC( file ); - else if( TagLib::MPC::File *file = dynamic_cast( tempFileRef.file() ) ) - saveNecessary = handleMPC( file ); - else if( TagLib::MP4::File *file = dynamic_cast( tempFileRef.file() ) ) - saveNecessary = handleMP4( file ); - else - { - if( m_verbose ) - m_textStream << tr( "INFO: File not able to be parsed by TagLib or wrong kind (currently this program only supports MPEG, Ogg MP4, MPC, and FLAC files), cleaning up temp file" ) << endl; - if( !sfs.cleanupSave() ) - m_textStream << tr( "WARNING: file at %1 could not be cleaned up; check for strays" ).arg( filePath ) << endl; - return; - } - if( saveNecessary ) - { - if( m_verbose ) - m_textStream << tr( "INFO: Safe-saving file" ) << endl; - if( !sfs.doSave() ) - m_textStream << tr( "WARNING: file at %1 could not be saved" ).arg( filePath ) << endl; - } - if( m_verbose ) - m_textStream << tr( "INFO: Cleaning up..." ) << endl; - if( !sfs.cleanupSave() ) - m_textStream << tr( "WARNING: file at %1 could not be cleaned up; check for strays" ).arg( filePath ) << endl; - return; - } -} - -bool -AFTTagger::handleMPEG( TagLib::MPEG::File *file ) -{ - if( file->readOnly() ) - { - m_textStream << tr( "ERROR: File is read-only or could not be opened" ) << endl; - return false; - } - - QString uid; - bool newUid = false; - bool nothingfound = true; - if( m_verbose ) - m_textStream << tr( "INFO: File is a MPEG file, opening..." ) << endl; - if ( file->ID3v2Tag( true ) ) - { - if( file->ID3v2Tag()->frameListMap()["UFID"].isEmpty() ) - { - if( m_verbose ) - m_textStream << tr( "INFO: No UFID frames found" ) << endl; - - if( m_delete ) - return false; - - newUid = true; - } - else - { - if( m_verbose ) - m_textStream << tr( "INFO: Found existing UFID frames, parsing" ) << endl; - TagLib::ID3v2::FrameList frameList = file->ID3v2Tag()->frameListMap()["UFID"]; - TagLib::ID3v2::FrameList::Iterator iter; - if( m_verbose ) - m_textStream << tr( "INFO: Frame list size is %1" ).arg( frameList.size() ) << endl; - for( iter = frameList.begin(); iter != frameList.end(); ++iter ) - { - TagLib::ID3v2::UniqueFileIdentifierFrame* currFrame = dynamic_cast(*iter); - if( currFrame ) - { - QString owner = TStringToQString( currFrame->owner() ).toUpper(); - if( owner.startsWith( "AMAROK - REDISCOVER YOUR MUSIC" ) ) - { - nothingfound = false; - if( m_verbose ) - m_textStream << tr( "INFO: Removing old-style ATF identifier" ) << endl; - - iter = frameList.erase( iter ); - file->ID3v2Tag()->removeFrame( currFrame ); - file->save(); - if( !m_delete ) - newUid = true; - else - return true; - } - if( owner.startsWith( "AMAROK 2 AFT" ) ) - { - nothingfound = false; - if( m_verbose ) - m_textStream << tr( "INFO: Found an existing AFT identifier: %1" ).arg( TStringToQString( TagLib::String( currFrame->identifier() ) ) ) << endl; - - if( m_delete ) - { - iter = frameList.erase( iter ); - if( m_verbose ) - m_textStream << tr( "INFO: Removing current AFT frame" ) << endl; - file->ID3v2Tag()->removeFrame( currFrame ); - file->save(); - return true; - } - - int version = owner.at( 13 ).digitValue(); - if( version < s_currentVersion ) - { - if( m_verbose ) - m_textStream << tr( "INFO: Upgrading AFT identifier from version %1 to version %2" ).arg( version, s_currentVersion ) << endl; - uid = upgradeUID( version, TStringToQString( TagLib::String( currFrame->identifier() ) ) ); - if( m_verbose ) - m_textStream << tr( "INFO: Removing current AFT frame" ) << endl; - iter = frameList.erase( iter ); - file->ID3v2Tag()->removeFrame( currFrame ); - newUid = true; - } - else if( version == s_currentVersion && m_newid ) - { - if( m_verbose ) - m_textStream << tr( "INFO: New IDs specified to be generated, doing so" ) << endl; - iter = frameList.erase( iter ); - file->ID3v2Tag()->removeFrame( currFrame ); - newUid = true; - } - else - { - if( m_verbose ) - m_textStream << tr( "INFO: ID is current" ) << endl; - } - } - } - } - } - if( newUid || ( nothingfound && !m_delete ) ) - { - QString ourId = QString( "Amarok 2 AFTv" + QString::number( s_currentVersion ) + " - amarok.kde.org" ); - if( uid.isEmpty() ) - uid = createCurrentUID( file ); - if( m_verbose ) - m_textStream << tr( "INFO: Adding new frame and saving file with UID: %1" ).arg( uid ) << endl; - file->ID3v2Tag()->addFrame( new TagLib::ID3v2::UniqueFileIdentifierFrame( - Qt4QStringToTString( ourId ), Qt4QStringToTString( uid ).data( TagLib::String::Latin1 ) ) ); - file->save(); - return true; - } - } - return false; -} - -bool -AFTTagger::handleOgg( TagLib::Ogg::File *file ) -{ - if( file->readOnly() ) - { - m_textStream << tr( "ERROR: File is read-only or could not be opened" ) << endl; - return false; - } - - TagLib::Ogg::XiphComment *comment = dynamic_cast( file->tag() ); - - if( !comment ) - return false; - - if( handleXiphComment( comment, file ) ) - { - file->save(); - return true; - } - - return false; -} - -bool -AFTTagger::handleFLAC( TagLib::FLAC::File *file ) -{ - if( file->readOnly() ) - { - m_textStream << tr( "ERROR: File is read-only or could not be opened" ) << endl; - return false; - } - - TagLib::Ogg::XiphComment *comment = file->xiphComment( true ); - if( !comment ) - return false; - - if( handleXiphComment( comment, file ) ) - { - file->save(); - return true; - } - - return false; -} - -bool -AFTTagger::handleXiphComment( TagLib::Ogg::XiphComment *comment, TagLib::File *file ) -{ - QString uid; - bool newUid = false; - bool nothingfound = true; - TagLib::StringList toRemove; - if( m_verbose ) - m_textStream << tr( "INFO: File has a XiphComment, opening..." ) << endl; - - if( comment->fieldListMap().isEmpty() ) - { - if( m_verbose ) - m_textStream << tr( "INFO: No fields found in XiphComment" ) << endl; - - if( m_delete ) - return false; - } - else - { - if( m_verbose ) - m_textStream << tr( "INFO: Found existing XiphComment frames, parsing" ) << endl; - TagLib::Ogg::FieldListMap fieldListMap = comment->fieldListMap(); - - if( m_verbose ) - m_textStream << tr( "INFO: fieldListMap size is %1" ).arg( fieldListMap.size() ) << endl; - - TagLib::Ogg::FieldListMap::Iterator iter; - for( iter = fieldListMap.begin(); iter != fieldListMap.end(); ++iter ) - { - TagLib::String key = iter->first; - QString qkey = TStringToQString( key ).toUpper(); - if( qkey.startsWith( "AMAROK - REDISCOVER YOUR MUSIC" ) ) - { - nothingfound = false; - - if( m_verbose ) - m_textStream << tr( "INFO: Removing old-style ATF identifier %1" ).arg( qkey ) << endl; - - toRemove.append( key ); - if( !m_delete ) - newUid = true; - } - else if( qkey.startsWith( "AMAROK 2 AFT" ) ) - { - nothingfound = false; - - if( m_verbose ) - m_textStream << tr( "INFO: Found an existing AFT identifier: %1" ).arg( qkey ) << endl; - - if( m_delete ) - { - toRemove.append( key ); - if( m_verbose ) - m_textStream << tr( "INFO: Removing current AFT frame" ) << endl; - } - else - { - int version = qkey.at( 13 ).digitValue(); - if( m_verbose ) - m_textStream << tr( "INFO: AFT identifier is version %1" ).arg( version ) << endl; - if( version < s_currentVersion ) - { - if( m_verbose ) - m_textStream << tr( "INFO: Upgrading AFT identifier from version %1 to version %2" ).arg( version, s_currentVersion ) << endl; - uid = upgradeUID( version, TStringToQString( fieldListMap[key].front() ) ); - if( m_verbose ) - m_textStream << tr( "INFO: Removing current AFT frame" ) << endl; - toRemove.append( key ); - newUid = true; - } - else if( version == s_currentVersion && m_newid ) - { - if( m_verbose ) - m_textStream << tr( "INFO: New IDs specified to be generated, doing so" ) << endl; - toRemove.append( key ); - newUid = true; - } - else - { - if( m_verbose ) - m_textStream << tr( "INFO: ID is current" ) << endl; - return false; - } - } - } - } - for( TagLib::StringList::ConstIterator iter = toRemove.begin(); iter != toRemove.end(); ++iter ) - comment->removeField( *iter ); - } - if( newUid || ( nothingfound && !m_delete ) ) - { - QString ourId = QString( "Amarok 2 AFTv" + QString::number( s_currentVersion ) + " - amarok.kde.org" ); - if( uid.isEmpty() ) - uid = createCurrentUID( file ); - if( m_verbose ) - m_textStream << tr( "INFO: Adding new field and saving file with UID: %1" ).arg( uid ) << endl; - comment->addField( Qt4QStringToTString( ourId ), Qt4QStringToTString( uid ) ); - return true; - } - else if( toRemove.size() ) - return true; - - return false; -} - -bool -AFTTagger::handleMPC( TagLib::MPC::File *file ) -{ - if( file->readOnly() ) - { - m_textStream << tr( "ERROR: File is read-only or could not be opened" ) << endl; - return false; - } - - QString uid; - bool newUid = false; - bool nothingfound = true; - TagLib::StringList toRemove; - if( m_verbose ) - m_textStream << tr( "INFO: File is a MPC file, opening..." ) << endl; - - if( file->APETag() ) - { - const TagLib::APE::ItemListMap &itemsMap = file->APETag()->itemListMap(); - if( itemsMap.isEmpty() ) - { - m_textStream << tr( "INFO: No fields found in APE tags." ) << endl; - - if( m_delete ) - return false; - } - - for( TagLib::APE::ItemListMap::ConstIterator it = itemsMap.begin(); it != itemsMap.end(); ++it ) - { - TagLib::String key = it->first; - QString qkey = TStringToQString( key ).toUpper(); - if( qkey.startsWith( "AMAROK - REDISCOVER YOUR MUSIC" ) ) - { - nothingfound = false; - - if( m_verbose ) - m_textStream << tr( "INFO: Removing old-style ATF identifier %1" ).arg( qkey ) << endl; - - toRemove.append( key ); - if( !m_delete ) - newUid = true; - } - else if( qkey.startsWith( "AMAROK 2 AFT" ) ) - { - nothingfound = false; - - if( m_verbose ) - m_textStream << tr( "INFO: Found an existing AFT identifier: %1" ).arg( qkey ) << endl; - - if( m_delete ) - { - toRemove.append( key ); - if( m_verbose ) - m_textStream << tr( "INFO: Removing current AFT frame" ) << endl; - } - else - { - int version = qkey.at( 13 ).digitValue(); - if( m_verbose ) - m_textStream << tr( "INFO: AFT identifier is version %1" ).arg( version ) << endl; - if( version < s_currentVersion ) - { - if( m_verbose ) - m_textStream << tr( "INFO: Upgrading AFT identifier from version %1 to version %2" ).arg( version, s_currentVersion ) << endl; - uid = upgradeUID( version, TStringToQString( itemsMap[ key ].toString() ) ); - if( m_verbose ) - m_textStream << tr( "INFO: Removing current AFT frame" ) << endl; - toRemove.append( key ); - newUid = true; - } - else if( version == s_currentVersion && m_newid ) - { - if( m_verbose ) - m_textStream << tr( "INFO: New IDs specified to be generated, doing so" ) << endl; - toRemove.append( key ); - newUid = true; - } - else - { - if( m_verbose ) - m_textStream << tr( "INFO: ID is current" ) << endl; - return false; - } - } - } - } - for( TagLib::StringList::ConstIterator it = toRemove.begin(); it != toRemove.end(); ++it ) - file->APETag()->removeItem( *it ); - } - - if( newUid || ( nothingfound && !m_delete ) ) - { - QString ourId = QString( "Amarok 2 AFTv" + QString::number( s_currentVersion ) + " - amarok.kde.org" ); - if( uid.isEmpty() ) - uid = createCurrentUID( file ); - if( m_verbose ) - m_textStream << tr( "INFO: Adding new field and saving file with UID: %1" ).arg( uid ) << endl; - file->APETag()->addValue( Qt4QStringToTString( ourId.toUpper() ), Qt4QStringToTString( uid ) ); - file->save(); - return true; - } - else if( toRemove.size() ) - { - file->save(); - return true; - } - - return false; -} - -bool -AFTTagger::handleMP4( TagLib::MP4::File *file ) -{ - if( file->readOnly() ) - { - m_textStream << tr( "ERROR: File is read-only or could not be opened" ) << endl; - return false; - } - - QString uid; - bool newUid = false; - bool nothingfound = true; - TagLib::StringList toRemove; - if( m_verbose ) - m_textStream << tr( "INFO: File is a MP4 file, opening..." ) << endl; - - TagLib::MP4::ItemListMap &itemsMap = file->tag()->itemListMap(); - if( !itemsMap.isEmpty() ) - { - for( TagLib::MP4::ItemListMap::Iterator it = itemsMap.begin(); it != itemsMap.end(); ++it ) - { - TagLib::String key = it->first; - const QString qkey = TStringToQString( key ).toUpper(); - if( qkey.contains( "AMAROK - REDISCOVER YOUR MUSIC" ) ) - { - nothingfound = false; - - if( m_verbose ) - m_textStream << tr( "INFO: Removing old-style ATF identifier %1" ).arg( key.toCString() ) << endl; - - toRemove.append( key ); - if( !m_delete ) - newUid = true; - } - else if( qkey.contains( "AMAROK 2 AFT" ) ) - { - nothingfound = false; - - if( m_verbose ) - m_textStream << tr( "INFO: Found an existing AFT identifier: %1" ).arg( key.toCString() ) << endl; - - if( m_delete ) - { - toRemove.append( key ); - if( m_verbose ) - m_textStream << tr( "INFO: Removing current AFT frame" ) << endl; - } - else - { - int version = qkey.at( qkey.indexOf( "AMAROK 2 AFT" ) + 13 ).digitValue(); - if( m_verbose ) - m_textStream << tr( "INFO: AFT identifier is version %1" ).arg( version ) << endl; - if( version < s_currentVersion ) - { - if( m_verbose ) - m_textStream << tr( "INFO: Upgrading AFT identifier from version %1 to version %2" ) - .arg( QString::number( version ), QString::number( s_currentVersion ) ) - << endl; - uid = upgradeUID( version, TStringToQString( itemsMap[ key ].toStringList().toString() ) ); - if( m_verbose ) - m_textStream << tr( "INFO: Removing current AFT frame" ) << endl; - toRemove.append( key ); - newUid = true; - } - else if( version == s_currentVersion && m_newid ) - { - if( m_verbose ) - m_textStream << tr( "INFO: New IDs specified to be generated, doing so" ) << endl; - toRemove.append( key ); - newUid = true; - } - else - { - if( m_verbose ) - m_textStream << tr( "INFO: ID is current" ) << endl; - return false; - } - } - } - } - for( TagLib::StringList::ConstIterator it = toRemove.begin(); it != toRemove.end(); ++it ) - itemsMap.erase( *it ); - } - - if( newUid || ( nothingfound && !m_delete ) ) - { - QString ourId = QString( "Amarok 2 AFTv" + QString::number( s_currentVersion ) + " - amarok.kde.org" ); - if( uid.isEmpty() ) - uid = createCurrentUID( file ); - if( m_verbose ) - m_textStream << tr( "INFO: Adding new field and saving file with UID: %1" ).arg( uid ) << endl; - itemsMap.insert( Qt4QStringToTString( QString( "----:com.apple.iTunes:" + ourId ) ), - TagLib::StringList( Qt4QStringToTString( uid ) ) ); - file->save(); - return true; - } - else if( toRemove.size() ) - { - file->save(); - return true; - } - - return false; -} - - - -QString -AFTTagger::createCurrentUID( TagLib::File *file ) -{ - return createV1UID( file ); -} - -QString -AFTTagger::createV1UID( TagLib::File *file ) -{ - QCryptographicHash md5( QCryptographicHash::Md5 ); - QByteArray size; - md5.addData( size.setNum( (qulonglong)(file->length()) ) ); - md5.addData( QString::number( m_time.elapsed() ).toAscii() ); - md5.addData( QString::number( qrand() ).toAscii() ); - md5.addData( QString::number( qrand() ).toAscii() ); - md5.addData( QString::number( qrand() ).toAscii() ); - md5.addData( QString::number( qrand() ).toAscii() ); - md5.addData( QString::number( qrand() ).toAscii() ); - md5.addData( QString::number( m_time.elapsed() ).toAscii() ); - return QString( md5.result().toHex() ); -} - -QString -AFTTagger::upgradeUID( int version, QString currValue ) -{ - Q_UNUSED(version) - return currValue + "abcd"; -} - -void -AFTTagger::readArgs() -{ - QStringList argslist = arguments(); - if( argslist.size() < 2 ) - displayHelp(); - bool nomore = false; - int argnum = 0; - foreach( const QString &arg, argslist ) - { - ++argnum; - if( arg.isEmpty() || argnum == 1 ) - continue; - if( nomore ) - { - m_fileFolderList.append( arg ); - } - else if( arg.startsWith( "--" ) ) - { - QString myarg = QString( arg ).remove( 0, 2 ); - if ( myarg == "recurse" || myarg == "recursively" ) - m_recurse = true; - else if( myarg == "verbose" ) - m_verbose = true; - else if( myarg == "quiet" ) - m_quiet = true; - else if( myarg == "newid" ) - m_newid = true; - else if( myarg == "delete" ) - m_delete = true; - else - displayHelp(); - } - else if( arg.startsWith( '-' ) ) - { - QString myarg = QString( arg ).remove( 0, 1 ); - int pos = 0; - while( pos < myarg.length() ) - { - if( myarg[pos] == 'd' ) - m_delete = true; - else if( myarg[pos] == 'n' ) - m_newid = true; - else if( myarg[pos] == 'q' ) - m_quiet = true; - else if( myarg[pos] == 'r' ) - m_recurse = true; - else if( myarg[pos] == 'v' ) - m_verbose = true; - else - displayHelp(); - - ++pos; - } - } - else - { - nomore = true; - m_fileFolderList.append( arg ); - } - } -} - -void -AFTTagger::displayHelp() -{ - m_textStream << tr( "Amarok AFT Tagger" ) << endl << endl; - m_textStream << tr( "IRC:\nserver: irc.freenode.net / channels: #amarok, #amarok.de, #amarok.es, #amarok.fr\n\nFeedback:\namarok@kde.org" ) << endl << endl; - m_textStream << tr( "Usage: amarok_afttagger [options] +File/Folder(s)" ) << endl << endl; - m_textStream << tr( "User-modifiable Options:" ) << endl; - m_textStream << tr( "+File/Folder(s) : Files or folders to tag" ) << endl; - m_textStream << tr( "-h, --help : This help text" ) << endl; - m_textStream << tr( "-r, --recursive : Process files and folders recursively" ) << endl; - m_textStream << tr( "-d, --delete : Remove AFT tag" ) << endl; - m_textStream << tr( "-n --newid : Replace any existing ID with a new one" ) << endl; - m_textStream << tr( "-v, --verbose : Verbose output" ) << endl; - m_textStream << tr( "-q, --quiet : Quiet output; Implies that you accept the terms of use" ) << endl; - m_textStream.flush(); - ::exit( 0 ); -} diff --git a/amarok/utilities/afttagger/AFTTagger.h b/amarok/utilities/afttagger/AFTTagger.h deleted file mode 100644 index ecd39387..00000000 --- a/amarok/utilities/afttagger/AFTTagger.h +++ /dev/null @@ -1,75 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2008-2009 Jeff Mitchell * - * * - * This program 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 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#ifndef AFTTAGGER_H -#define AFTTAGGER_H - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -/** - * @class AFTTagger - * @short Inserts AFT tags into directories and files - */ - -class AFTTagger : public QCoreApplication -{ - -public: - AFTTagger( int &argc, char **argv ); - - ~AFTTagger() {}; - - void processPath( const QString &path ); - bool handleMPEG( TagLib::MPEG::File *file ); - bool handleMPC( TagLib::MPC::File *file ); - bool handleMP4( TagLib::MP4::File *file ); - bool handleOgg( TagLib::Ogg::File *file ); - bool handleFLAC( TagLib::FLAC::File *file ); - bool handleXiphComment( TagLib::Ogg::XiphComment *comment, TagLib::File *file ); - QString createCurrentUID( TagLib::File *file ); - QString createV1UID( TagLib::File *file ); - QString upgradeUID( int version, QString currValue ); - void readArgs(); - void displayHelp(); - - bool m_delete; - bool m_newid; - bool m_quiet; - bool m_recurse; - bool m_verbose; - QStringList m_fileFolderList; - QTime m_time; - QTextStream m_textStream; - -}; - - -#endif // AFTTAGGER_H - diff --git a/amarok/utilities/afttagger/CMakeLists.txt b/amarok/utilities/afttagger/CMakeLists.txt deleted file mode 100644 index 6b5bfb4e..00000000 --- a/amarok/utilities/afttagger/CMakeLists.txt +++ /dev/null @@ -1,33 +0,0 @@ -include_directories( ../ - ${QT_INCLUDES} - ${TAGLIB_INCLUDES} - ) - -add_definitions(${TAGLIB_CFLAGS}) - -set(amarok_afttagger_SRCS - SafeFileSaver.cpp - AFTTagger.cpp -) - -add_executable(amarok_afttagger ${amarok_afttagger_SRCS} ) - -if( TAGLIB-EXTRAS_FOUND ) - include_directories(${TAGLIB-EXTRAS_INCLUDES}) - add_definitions(${TAGLIB-EXTRAS_CFLAGS}) - target_link_libraries(amarok_afttagger ${TAGLIB-EXTRAS_LIBRARIES}) -endif( TAGLIB-EXTRAS_FOUND ) - -target_link_libraries(amarok_afttagger - ${QT_QTCORE_LIBRARY} - ${TAGLIB_LIBRARIES} - ) - - -if(APPLE) - SET_TARGET_PROPERTIES(amarok_afttagger PROPERTIES LINK_FLAGS "-undefined dynamic_lookup") - # install to app bundle on os x, otherwise amarok fails to load it - install(TARGETS amarok_afttagger DESTINATION ${BUNDLE_INSTALL_DIR}/Amarok.app/Contents/MacOS ) -else(APPLE) - install(TARGETS amarok_afttagger RUNTIME DESTINATION ${BIN_INSTALL_DIR} ) -endif(APPLE) diff --git a/amarok/utilities/afttagger/SafeFileSaver.cpp b/amarok/utilities/afttagger/SafeFileSaver.cpp deleted file mode 100644 index 2e65e8f2..00000000 --- a/amarok/utilities/afttagger/SafeFileSaver.cpp +++ /dev/null @@ -1,256 +0,0 @@ -/* - * Copyright (c) 2008-2009 Jeff Mitchell - * - * This program 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 2 of the License, or - * (at your option) any later version. - * - * This program 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 this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include "SafeFileSaver.h" - -#include -#include -#include -#include -#include - -#ifdef Q_WS_WIN -#include -#else -#include -#include -#endif - -SafeFileSaver::SafeFileSaver( const QString &origPath ) - : m_origPath( origPath ) - , m_tempSavePath() - , m_origRenamedSavePath() - , m_cleanupNeeded( false ) - , m_verbose( false ) - , m_prefix( "safefilesaver" ) -{ -} - -SafeFileSaver::~SafeFileSaver() -{ - if( m_cleanupNeeded ) - cleanupSave(); -} - -QString -SafeFileSaver::prepareToSave() -{ - if( m_verbose ) - qDebug() << "prepareToSave start"; - m_cleanupNeeded = true; - QCryptographicHash md5sum( QCryptographicHash::Md5 ); - - QString pid; -#ifdef Q_WS_WIN - pid.setNum( _getpid() ); -#else - pid.setNum( getpid() ); -#endif - - int length = 8; - //The following snippet of code is copied from kdelibs, and is copyright Matthias Kalle Dalheimer, Charles Samuels, Joseph Wenninger, and maybe more - QString str; str.resize( length ); - int i = 0; - while( length-- ) - { - int r = qrand() % 62; - r+=48; - if( r > 57 ) r+=7; - if( r > 90 ) r+=6; - str[i++] = char( r ); - } - - QString randomString = str; - - m_tempSavePath = m_origPath + '.' + m_prefix + "temp.pid-" + pid + ".random-" + randomString + '.' + QFileInfo( m_origPath ).suffix(); - m_origRenamedSavePath = m_origPath + '.' + m_prefix + "original.pid-" + pid + ".random-" + randomString + '.' + QFileInfo( m_origPath ).suffix(); - - - if( m_verbose ) - qDebug() << "Copying original file " << m_origPath << " to copy at " << m_tempSavePath << " and caluclating MD5"; - - if( !QFile::copy( m_origPath, m_tempSavePath ) ) - { - if( m_verbose ) - qDebug() << "Could not copy the file. Check that you have sufficient permissions/disk space " - "and that the destination path does not already exist!"; - return QString(); - } - - QFile tempFile( m_tempSavePath ); - if( !tempFile.open( QIODevice::ReadOnly | QIODevice::Unbuffered ) ) - { - if( m_verbose ) - qDebug() << "Could not open temp file for MD5 calculation!"; - return QString(); - } - - md5sum.addData( tempFile.readLine() ); - m_tempSaveDigest = md5sum.result().toHex(); - - tempFile.close(); - - //By this point, we have the following: - //The original file is copied at path m_tempSavePath - //We have generated what will be the filename to rename the original to in m_origRenamedSavePath - //We have successfully copied the original file to the temp location - //We've calculated the md5sum of the original file - - if( m_verbose ) - qDebug() << "MD5 sum of temp file: " << m_tempSaveDigest; - - //Now, we have a MD5 sum of the original file at the time of copying saved in m_tempSaveDigest - - return m_tempSavePath; -} - -bool -SafeFileSaver::doSave() -{ - if( m_verbose ) - qDebug() << "doSave start"; - //TODO: much commenting needed. For now this pretty much follows algorithm laid out in bug 131353, - //but isn't useable since I need to find a good way to switch the file path with taglib, or a good way - //to get all the metadata copied over. - - m_cleanupNeeded = true; - - QCryptographicHash md5sum( QCryptographicHash::Md5 ); - - QString origRenamedDigest; - - if( m_tempSavePath.isEmpty() || m_tempSaveDigest.isEmpty() || m_origRenamedSavePath.isEmpty() ) - { - if( m_verbose) - qDebug() << "You must run prepareToSave() and it must return successfully before calling doSave()!"; - return false; - } - - if( m_verbose ) - qDebug() << "Renaming original file to temporary name " << m_origRenamedSavePath; - - if( !QFile::rename( m_origPath, m_origRenamedSavePath ) ) - { - if( m_verbose ) - qDebug() << "Could not move original!"; - failRemoveCopy( false ); - return false; - } - - if( m_verbose ) - qDebug() << "Calculating MD5 of " << m_origRenamedSavePath; - - QFile origRenamedFile( m_origRenamedSavePath ); - if( !origRenamedFile.open( QIODevice::ReadOnly | QIODevice::Unbuffered ) ) - { - if( m_verbose ) - qDebug() << "Could not open temporary file!"; - failRemoveCopy( true ); - return false; - } - - md5sum.addData( origRenamedFile.readLine() ); - origRenamedDigest = md5sum.result().toHex(); - origRenamedFile.close(); - - if( m_verbose ) - qDebug() << "md5sum of original renamed file: " << origRenamedDigest; - - if( origRenamedDigest != m_tempSaveDigest ) - { - if( m_verbose ) - qDebug() << "Original checksum did not match current checksum!"; - failRemoveCopy( true ); - return false; - } - - if( m_verbose ) - qDebug() << "Renaming temp file to original's filename"; - - if( !QFile::rename( m_tempSavePath, m_origPath ) ) - { - if( m_verbose ) - qDebug() << "Could not rename new file to original!"; - failRemoveCopy( true ); - return false; - } - - if( m_verbose ) - qDebug() << "Deleting original"; - - if( !QFile::remove( m_origRenamedSavePath ) ) - { - if( m_verbose ) - qDebug() << "Could not delete the original file!"; - return false; - } - - if( m_verbose ) - qDebug() << "Save done, returning true!"; - - return true; -} - -void -SafeFileSaver::failRemoveCopy( bool revert ) -{ - if( m_verbose ) - qDebug() << "failRemoveCopy start"; - if( !QFile::remove( m_tempSavePath ) ) - { - if( m_verbose ) - qDebug() << "Could not delete the temporary file!"; - } - - if( !revert ) - return; - - if( m_verbose ) - qDebug() << "Reverting original file to original filename!"; - if( !QFile::rename( m_origRenamedSavePath, m_origPath ) ) - { - if( m_verbose ) - qDebug() << "Could not revert file to original filename!"; - } -} - -bool -SafeFileSaver::cleanupSave() -{ - if( m_verbose ) - qDebug() << "cleanupSave start"; - bool dirty = false; - - if( !m_tempSavePath.isEmpty() && QFile::exists( m_tempSavePath ) ) - { - if( !QFile::remove( m_tempSavePath ) ) - { - dirty = true; - if( m_verbose ) - qDebug() << "Could not delete the temporary file!"; - } - } - - m_tempSavePath.clear(); - m_origRenamedSavePath.clear(); - m_tempSaveDigest.clear(); - - m_cleanupNeeded = false; - return !dirty; -} - diff --git a/amarok/utilities/afttagger/SafeFileSaver.h b/amarok/utilities/afttagger/SafeFileSaver.h deleted file mode 100644 index d21a76f6..00000000 --- a/amarok/utilities/afttagger/SafeFileSaver.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2008 Jeff Mitchell - * - * This program 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 2 of the License, or - * (at your option) any later version. - * - * This program 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 this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#ifndef SAFEFILESAVER_H -#define SAFEFILESAVER_H - -#include -#include - -/** - * @class SafeFileSaver - * @author Jeff Mitchell - */ - -class SafeFileSaver -{ -public: - SafeFileSaver( const QString &origPath ); - ~SafeFileSaver(); - - QString prepareToSave(); - bool doSave(); - void failRemoveCopy( bool revert ); - bool cleanupSave(); - - void setVerbose( bool verbose ) { m_verbose = verbose; } - void setPrefix( const QString &prefix ) { if( !prefix.isEmpty() ) m_prefix = prefix; } - -private: - QString m_origPath; - QString m_tempSavePath; - QString m_origRenamedSavePath; - QString m_tempSaveDigest; - bool m_cleanupNeeded; - bool m_verbose; - QString m_prefix; -}; - -#endif - diff --git a/amarok/utilities/amzdownloader/AmzDownloader.cpp b/amarok/utilities/amzdownloader/AmzDownloader.cpp deleted file mode 100644 index e6771de1..00000000 --- a/amarok/utilities/amzdownloader/AmzDownloader.cpp +++ /dev/null @@ -1,201 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Sven Krohlas * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "AmzDownloader.h" - -#include -#include -#include - -AmzDownloader::AmzDownloader( QWidget* parent ) : - QDialog( parent ), - ui( new Ui::AmzDownloader ) -{ - m_downloadDir = QDesktopServices::storageLocation( QDesktopServices::MusicLocation ); - - // parse arguments - QStringList arguments = QApplication::arguments(); - - if( arguments.contains( "--amz" ) ) - { - int position = arguments.indexOf( "--amz" ); - - while( ( position + 1 < arguments.size() ) ) - { - if( !arguments.at( position + 1 ).startsWith( "--" ) ) - m_amzList += arguments.at( position + 1 ); - else - break; - - position++; - } - } - - checkAmzList(); - - if( arguments.contains( "--output-dir" ) ) - { - int position = arguments.indexOf( "--output-dir" ); - - if( ( position + 1 <= arguments.size() ) && !arguments.at( position + 1 ).startsWith( "--" ) && m_downloadDir.exists( arguments.at( position + 1 ) ) ) - m_downloadDir = arguments.at( position + 1 ); - } - - ui->setupUi( this ); - ui->downloadDirectoryEdit->setText( m_downloadDir.absolutePath() ); - - if( !m_amzList.isEmpty() ) - ui->amzFileEdit->setText( m_amzList.at( 0 ) ); - - connect( ui->quitButton, SIGNAL(clicked()), this, SLOT(quitClicked()) ); - connect( ui->selectAmzButton, SIGNAL(clicked()), this, SLOT(selectAmzClicked()) ); - connect( ui->selectDirectoryButton, SIGNAL(clicked()), this, SLOT(selectDirectoryClicked()) ); - connect( ui->startButton, SIGNAL(clicked()), this, SLOT(startClicked()) ); -} - -AmzDownloader::~AmzDownloader() -{ - delete ui; -} - - -// public slots - -void -AmzDownloader::quitClicked() -{ - QApplication::quit(); -} - -void -AmzDownloader::selectAmzClicked() -{ - QFileDialog fileDialog( this ); - fileDialog.setAcceptMode( QFileDialog::AcceptOpen ); - fileDialog.setFileMode( QFileDialog::ExistingFile ); - fileDialog.setNameFilter( tr( "Amazon MP3 Purchase Playlist (*.amz)" ) ); - - if( !m_amzList.isEmpty() ) - fileDialog.setDirectory( m_amzList.at( 0 ) ); - - if( fileDialog.exec() ) - { - m_amzList = fileDialog.selectedFiles(); - ui->amzFileEdit->setText( m_amzList.at( 0 ) ); - } -} - -void -AmzDownloader::selectDirectoryClicked() -{ - QFileDialog fileDialog( this ); - fileDialog.setAcceptMode( QFileDialog::AcceptOpen ); - fileDialog.setFileMode( QFileDialog::Directory ); - fileDialog.setOptions( QFileDialog::ShowDirsOnly ); - fileDialog.setDirectory( m_downloadDir ); - - if( fileDialog.exec() ) - { - m_downloadDir = fileDialog.selectedFiles().at( 0 ); - ui->downloadDirectoryEdit->setText( m_downloadDir.absolutePath() ); - } -} - -void -AmzDownloader::startClicked() -{ - QStringList arguments; - arguments << "-d" << m_downloadDir.absolutePath(); - arguments << m_amzList; - - m_clamzProcess.setProcessChannelMode( QProcess::MergedChannels ); - m_clamzProcess.start( "clamz", arguments ); - - connect( &m_clamzProcess, SIGNAL(error()), this, SLOT(clamzError()) ); - connect( &m_clamzProcess, SIGNAL(readyRead()), this, SLOT(clamzOutputAvailable()) ); - connect( &m_clamzProcess, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(clamzFinished(int,QProcess::ExitStatus)) ); - - ui->selectAmzButton->setDisabled( true ); - ui->startButton->setDisabled( true ); - ui->selectDirectoryButton->setDisabled( true ); -} - - -// private - -void -AmzDownloader:: checkAmzList() -{ - m_amzList.removeDuplicates(); - QStringList errorList, tmpList = m_amzList; - - for( int i = 0; i < m_amzList.size(); i++ ) - { - if( !QFile::exists( m_amzList.at( i ) ) ) - { - errorList << m_amzList.at( i ); - tmpList.removeOne( m_amzList.at( i ) ); - } - } - - m_amzList = tmpList; - - if( !errorList.isEmpty() ) - { - QMessageBox errorBox; - QString errorMsg; - - errorMsg = tr( "The following files do not exist: " ); - - for( int i = 0; i < errorList.size(); i++ ) - errorMsg += '\n' + errorList.at( i ); - - errorBox.warning( this, tr( "Some files are not available" ), errorMsg ); - } -} - - -// private slots - -void -AmzDownloader::clamzError() -{ - if( m_clamzProcess.error() == QProcess::FailedToStart ) - QMessageBox::warning( this, tr( "Unable to start clamz" ), tr( "Unable to start clamz. has it been installed correctly?" ) ); - else - QMessageBox::warning( this, tr( "Unexpected error" ), tr( "Unexpected error downloading with clamz. This should not have happened..." ) ); -} - -void -AmzDownloader::clamzFinished( int exitCode, QProcess::ExitStatus exitStatus ) -{ - Q_UNUSED( exitStatus ); - - if( exitCode == 0 ) - QMessageBox::information( this, tr( "Download finished" ), tr( "Download finished successfully. Have fun listening to your music." ) ); - else - QMessageBox::warning( this, tr( "Download failed" ), tr( "Please check the progress output for further information." ) ); - - ui->selectAmzButton->setDisabled( false ); - ui->startButton->setDisabled( false ); - ui->selectDirectoryButton->setDisabled( false ); -} - -void -AmzDownloader::clamzOutputAvailable() -{ - ui->progressBrowser->append( m_clamzProcess.readAll() ); -} diff --git a/amarok/utilities/amzdownloader/AmzDownloader.h b/amarok/utilities/amzdownloader/AmzDownloader.h deleted file mode 100644 index 0071b60e..00000000 --- a/amarok/utilities/amzdownloader/AmzDownloader.h +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Sven Krohlas * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMZDOWNLOADER_H -#define AMZDOWNLOADER_H - -#include "ui_AmzDownloader.h" - -#include -#include -#include - -class AmzDownloader : public QDialog -{ - Q_OBJECT - -public: - explicit AmzDownloader( QWidget *parent = 0 ); - ~AmzDownloader(); - -public slots: - void selectAmzClicked(); - void selectDirectoryClicked(); - void startClicked(); - void quitClicked(); - -private: - void checkAmzList(); - - Ui::AmzDownloader* ui; - QStringList m_amzList; - QDir m_downloadDir; - QProcess m_clamzProcess; - -private slots: - void clamzError(); - void clamzFinished( int exitCode, QProcess::ExitStatus exitStatus ); - void clamzOutputAvailable(); -}; - -#endif // AMZDOWNLOADER_H diff --git a/amarok/utilities/amzdownloader/AmzDownloader.ui b/amarok/utilities/amzdownloader/AmzDownloader.ui deleted file mode 100644 index e66073df..00000000 --- a/amarok/utilities/amzdownloader/AmzDownloader.ui +++ /dev/null @@ -1,139 +0,0 @@ - - - AmzDownloader - - - - 0 - 0 - 348 - 387 - - - - - 0 - 0 - - - - AMZ Downloader - - - - - - - - - - - Download directory: - - - - - - - - - true - - - - - - - Select - - - - - - - - - AMZ file: - - - - - - - - - true - - - - - - - Select - - - - - - - - - Download progress: - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Start - - - - - - - Quit - - - - - - - - - - - - - diff --git a/amarok/utilities/amzdownloader/CMakeLists.txt b/amarok/utilities/amzdownloader/CMakeLists.txt deleted file mode 100644 index 28d7bf98..00000000 --- a/amarok/utilities/amzdownloader/CMakeLists.txt +++ /dev/null @@ -1,38 +0,0 @@ -macro_optional_find_package( SharedMimeInfo ) - -include_directories( ../ - ${CMAKE_SOURCE_DIR} - ${QT_INCLUDES} - ${CMAKE_CURRENT_BINARY_DIR} - ) - -########### next target ############### -set( amzdownloader_UI - AmzDownloader.ui -) - -set( amzdownloader_SRCS - main.cpp - AmzDownloader.cpp -) - -set( amzdownloader_MOC_HDRS - AmzDownloader.h -) - -qt4_wrap_ui( amzdownloader_SRCS ${amzdownloader_UI} ) - -add_executable( amzdownloader ${amzdownloader_SRCS} ${amzdownloader_MOC}) - -target_link_libraries( amzdownloader - ${QT_QTGUI_LIBRARY} - ${QT_QTCORE_LIBRARY} - ) - -install( TARGETS amzdownloader RUNTIME DESTINATION ${BIN_INSTALL_DIR} ) -install( PROGRAMS amzdownloader.desktop DESTINATION ${XDG_APPS_INSTALL_DIR} ) - -if( SHAREDMIMEINFO_FOUND ) - install( FILES amzdownloader.xml DESTINATION ${XDG_MIME_INSTALL_DIR} ) - update_xdg_mimetypes( ${XDG_MIME_INSTALL_DIR} ) -endif( SHAREDMIMEINFO_FOUND ) diff --git a/amarok/utilities/amzdownloader/amzdownloader.desktop b/amarok/utilities/amzdownloader/amzdownloader.desktop deleted file mode 100644 index bcc0a15a..00000000 --- a/amarok/utilities/amzdownloader/amzdownloader.desktop +++ /dev/null @@ -1,83 +0,0 @@ -[Desktop Entry] -Type=Application -Name=AMZ Downloader -Name[bs]=AMZ Downloader -Name[ca]=AMZ Downloader -Name[ca@valencia]=AMZ Downloader -Name[cs]=Stahovač AMZ -Name[da]=AMZ-downloader -Name[de]=AMZ-Downloader -Name[el]=AMZ πρόγραμμα λήψης -Name[en_GB]=AMZ Downloader -Name[es]=Descargador AMZ -Name[et]=AMZ allalaadija -Name[fi]=AMZ Downloader -Name[fr]=Application de téléchargement « AMZ » -Name[ga]=Íosluchtóir AMZ -Name[gl]=Descargador AMZ -Name[hu]=AMZ letöltő -Name[id]=Pengunduh AMZ -Name[it]=AMZ Downloader -Name[lt]=AMZ atsiuntėjas -Name[lv]=AMZ lejupielādētājs -Name[nb]=AMZ nedlaster -Name[nl]=AMZ-downloader -Name[pa]=AMZ ਡਾਊਨਲੋਡਰ -Name[pl]=Program pobierający AMZ -Name[pt]=Transferência do AMZ -Name[pt_BR]=AMZ Downloader -Name[ro]=Descărcător AMZ -Name[sk]=Sťahovač AMZ -Name[sl]=Prejemnik AMZ -Name[sr]=АМЗ‑преузимач -Name[sr@ijekavian]=АМЗ‑преузимач -Name[sr@ijekavianlatin]=AMZ‑preuzimač -Name[sr@latin]=AMZ‑preuzimač -Name[sv]=AMZ-nerladdning -Name[tr]=AMZ İndirici -Name[uk]=Звантажувач AMZ -Name[x-test]=xxAMZ Downloaderxx -Name[zh_CN]=AMZ 下载器 -Name[zh_TW]=AMZ 下載器 -Comment=Download with AMZ Downloader -Comment[bs]=Skini sa AMZ Downloaderom -Comment[ca]=Baixa amb AMZ Downloader -Comment[ca@valencia]=Baixa amb AMZ Downloader -Comment[cs]=Stáhnout stahovačem AMZ -Comment[da]=Download med AMZ-downloader -Comment[de]=Herunterladen mit AMZ-Downloader -Comment[el]=Λήψη με το πρόγραμμα AMZ -Comment[en_GB]=Download with AMZ Downloader -Comment[es]=Descargar con el descargador AMZ -Comment[et]=Allalaadimine AMZ allalaadijaga -Comment[fi]=Lataa AMZ Downloaderilla -Comment[fr]=Télécharger avec l'application de téléchargement « AMZ » -Comment[ga]=Íosluchtaigh le hÍosluchtóir AMZ -Comment[gl]=Descargar co descargador AMZ -Comment[hu]=Letöltés az AMZ letöltővel -Comment[id]=Mengunduh dengan Pengunduh AMZ -Comment[it]=Scarica con AMZ Downloader -Comment[lt]=Atsiųsti su AMZ atsiuntėju -Comment[lv]=Lejupielādēt ar AMZ lejupielādētāju -Comment[nb]=Last ned med AMZ-nedlaster -Comment[nl]=Met AMZ-downloader downloaden -Comment[pl]=Pobieraj z programem pobierającym AMZ -Comment[pt]=Transferir com o AMZ -Comment[pt_BR]=Baixar com o AMZ Downloader -Comment[ro]=Descarcă cu AMZ Downloader -Comment[sk]=Stiahnuť so sťahovačom AMZ -Comment[sl]=Prejmi s prejemnikom AMZ -Comment[sr]=Преузимајте АМЗ‑преузимачем -Comment[sr@ijekavian]=Преузимајте АМЗ‑преузимачем -Comment[sr@ijekavianlatin]=Preuzimajte AMZ‑preuzimačem -Comment[sr@latin]=Preuzimajte AMZ‑preuzimačem -Comment[sv]=Ladda ner med AMZ-nerladdning -Comment[tr]=AMZ İndirici ile indir -Comment[uk]=Звантажити за допомогою звантажувача AMZ -Comment[x-test]=xxDownload with AMZ Downloaderxx -Comment[zh_CN]=使用 AMZ 下载器下载 -Comment[zh_TW]=用 AMZ 下載器來下載 -ServiceTypes=audio/x-amzxml,audio/x-amzaudio -Exec=amzdownloader --amz %f -Icon=download -Categories=Qt;KDE;AudioVideo;Audio; diff --git a/amarok/utilities/amzdownloader/amzdownloader.xml b/amarok/utilities/amzdownloader/amzdownloader.xml deleted file mode 100644 index 82d9528c..00000000 --- a/amarok/utilities/amzdownloader/amzdownloader.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - -Amazon MP3 Purchase Playlist - - - diff --git a/amarok/utilities/amzdownloader/main.cpp b/amarok/utilities/amzdownloader/main.cpp deleted file mode 100644 index a9e68061..00000000 --- a/amarok/utilities/amzdownloader/main.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2012 Sven Krohlas * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "AmzDownloader.h" - -#include - -int -main( int argc, char *argv[] ) -{ - QApplication a( argc, argv ); - - // let's rock! - AmzDownloader w; - w.show(); - - return a.exec(); -} diff --git a/amarok/utilities/collectionscanner/CMakeLists.txt b/amarok/utilities/collectionscanner/CMakeLists.txt deleted file mode 100644 index 007c0d1c..00000000 --- a/amarok/utilities/collectionscanner/CMakeLists.txt +++ /dev/null @@ -1,24 +0,0 @@ -include_directories( ${QT_INCLUDES} ) - -########### next target ############### - -qt4_automoc( CollectionScanner.cpp ) - -set(amarokcollectionscanner_SRCS - CollectionScanner.cpp -) - -add_executable(amarokcollectionscanner ${amarokcollectionscanner_SRCS} ${libchardet_SRCS}) - -target_link_libraries(amarokcollectionscanner - ${QT_QTCORE_LIBRARY} - amarokshared -) - -if(APPLE) - SET_TARGET_PROPERTIES(amarokcollectionscanner PROPERTIES LINK_FLAGS "-undefined dynamic_lookup") - # install to app bundle on os x, otherwise amarok fails to load it - install(TARGETS amarokcollectionscanner DESTINATION ${BUNDLE_INSTALL_DIR}/amarok.app/Contents/MacOS ) -else(APPLE) - install(TARGETS amarokcollectionscanner RUNTIME DESTINATION ${BIN_INSTALL_DIR} ) -endif(APPLE) diff --git a/amarok/utilities/collectionscanner/CollectionScanner.cpp b/amarok/utilities/collectionscanner/CollectionScanner.cpp deleted file mode 100644 index 16eaac69..00000000 --- a/amarok/utilities/collectionscanner/CollectionScanner.cpp +++ /dev/null @@ -1,439 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2003-2005 Max Howell * - * (C) 2003-2010 Mark Kretschmann * - * (C) 2005-2007 Alexandre Oliveira * - * (C) 2008 Dan Meltzer * - * (C) 2008-2009 Jeff Mitchell * - * * - * This program 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 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#include "CollectionScanner.h" - -#include "Version.h" // for AMAROK_VERSION -#include "collectionscanner/BatchFile.h" -#include "collectionscanner/Directory.h" -#include "collectionscanner/Track.h" - -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#ifdef Q_OS_LINUX -// for ioprio -#include -#include -enum { - IOPRIO_CLASS_NONE, - IOPRIO_CLASS_RT, - IOPRIO_CLASS_BE, - IOPRIO_CLASS_IDLE -}; - -enum { - IOPRIO_WHO_PROCESS = 1, - IOPRIO_WHO_PGRP, - IOPRIO_WHO_USER -}; -#define IOPRIO_CLASS_SHIFT 13 -#endif - - -int -main( int argc, char *argv[] ) -{ - CollectionScanner::Scanner scanner( argc, argv ); - return scanner.exec(); -} - -CollectionScanner::Scanner::Scanner( int &argc, char **argv ) - : QCoreApplication( argc, argv ) - , m_charset( false ) - , m_newerTime(0) - , m_incremental( false ) - , m_recursively( false ) - , m_restart( false ) - , m_idlePriority( false ) -{ - setObjectName( "amarokcollectionscanner" ); - - readArgs(); - - if( m_idlePriority ) - { - bool ioPriorityWorked = false; -#if defined(Q_OS_LINUX) && defined(SYS_ioprio_set) - // try setting the idle priority class - ioPriorityWorked = ( syscall( SYS_ioprio_set, IOPRIO_WHO_PROCESS, 0, - IOPRIO_CLASS_IDLE << IOPRIO_CLASS_SHIFT ) >= 0 ); - // try setting the lowest priority in the best-effort priority class (the default class) - if( !ioPriorityWorked ) - ioPriorityWorked = ( syscall( SYS_ioprio_set, IOPRIO_WHO_PROCESS, 0, - 7 | ( IOPRIO_CLASS_BE << IOPRIO_CLASS_SHIFT ) ) >= 0 ); -#endif - if( !ioPriorityWorked && QThread::currentThread() ) - QThread::currentThread()->setPriority( QThread::IdlePriority ); - } -} - - -CollectionScanner::Scanner::~Scanner() -{ -} - -void -CollectionScanner::Scanner::readBatchFile( const QString &path ) -{ - QFile batchFile( path ); - - if( !batchFile.exists() ) - error( tr( "File \"%1\" not found." ).arg( path ) ); - - if( !batchFile.open( QIODevice::ReadOnly ) ) - error( tr( "Could not open file \"%1\"." ).arg( path ) ); - - BatchFile batch( path ); - foreach( const QString &str, batch.directories() ) - { - m_folders.append( str ); - } - - foreach( const CollectionScanner::BatchFile::TimeDefinition &def, batch.timeDefinitions() ) - { - m_mTimes.insert( def.first, def.second ); - } -} - -void -CollectionScanner::Scanner::readNewerTime( const QString &path ) -{ - QFileInfo file( path ); - - if( !file.exists() ) - error( tr( "File \"%1\" not found." ).arg( path ) ); - - m_newerTime = qMax( m_newerTime, file.lastModified().toTime_t() ); -} - - -void -CollectionScanner::Scanner::doJob() //SLOT -{ - QFile xmlFile; - xmlFile.open( stdout, QIODevice::WriteOnly ); - QXmlStreamWriter xmlWriter( &xmlFile ); - xmlWriter.setAutoFormatting( true ); - - // get a list of folders to scan. We do it even if resuming because we don't want - // to save the (perhaps very big) list of directories into shared memory, bug 327812 - QStringList entries; - { - QSet entriesSet; - - foreach( QString dir, m_folders ) // krazy:exclude=foreach - { - if( dir.isEmpty() ) - //apparently somewhere empty strings get into the mix - //which results in a full-system scan! Which we can't allow - continue; - - // Make sure that all paths are absolute, not relative - if( QDir::isRelativePath( dir ) ) - dir = QDir::cleanPath( QDir::currentPath() + '/' + dir ); - - if( !dir.endsWith( '/' ) ) - dir += '/'; - - addDir( dir, &entriesSet ); // checks m_recursively - } - - entries = entriesSet.toList(); - qSort( entries ); // the sort is crucial because of restarts and lastDirectory handling - } - - if( m_restart ) - { - m_scanningState.readFull(); - QString lastEntry = m_scanningState.lastDirectory(); - - int index = entries.indexOf( lastEntry ); - if( index >= 0 ) - // strip already processed entries, but *keep* the lastEntry - entries = entries.mid( index ); - else - qWarning() << Q_FUNC_INFO << "restarting scan after a crash, but lastDirectory" - << lastEntry << "not found in folders to scan (size" << entries.size() - << "). Starting scanning from the beginning."; - } - else // first attempt - { - m_scanningState.writeFull(); // just trigger write to initialise memory - - xmlWriter.writeStartDocument(); - xmlWriter.writeStartElement("scanner"); - xmlWriter.writeAttribute("count", QString::number( entries.count() ) ); - if( m_incremental ) - xmlWriter.writeAttribute("incremental", QString()); - // write some information into the file and close previous tag - xmlWriter.writeComment("Created by amarokcollectionscanner " AMAROK_VERSION " on "+QDateTime::currentDateTime().toString()); - xmlFile.flush(); - } - - // --- now do the scanning - foreach( const QString &path, entries ) - { - CollectionScanner::Directory dir( path, &m_scanningState, - m_incremental && !isModified( path ) ); - - xmlWriter.writeStartElement( "directory" ); - dir.toXml( &xmlWriter ); - xmlWriter.writeEndElement(); - xmlFile.flush(); - } - - // --- write the end element (must be done by hand as we might not have written the start element when restarting) - xmlFile.write("\n\n"); - - quit(); -} - -void -CollectionScanner::Scanner::addDir( const QString& dir, QSet* entries ) -{ - // Linux specific, but this fits the 90% rule - if( dir.startsWith( "/dev" ) || dir.startsWith( "/sys" ) || dir.startsWith( "/proc" ) ) - return; - - if( entries->contains( dir ) ) - return; - - QDir d( dir ); - if( !d.exists() ) - { - QTextStream stream( stderr ); - stream << "Directory \""<insert( dir ); - - if( !m_recursively ) - return; // finished - - d.setFilter( QDir::NoDotAndDotDot | QDir::Dirs ); - QFileInfoList fileInfos = d.entryInfoList(); - - foreach( const QFileInfo &fi, fileInfos ) - { - if( !fi.exists() ) - continue; - - const QFileInfo &f = fi.isSymLink() ? QFileInfo( fi.symLinkTarget() ) : fi; - - if( !f.exists() ) - continue; - - if( f.isDir() ) - { - addDir( QString( f.absoluteFilePath() + '/' ), entries ); - } - } -} - -bool -CollectionScanner::Scanner::isModified( const QString& dir ) -{ - QFileInfo info( dir ); - if( !info.exists() ) - return false; - - uint lastModified = info.lastModified().toTime_t(); - - if( m_mTimes.contains( dir ) ) - return m_mTimes.value( dir ) != lastModified; - else - return m_newerTime < lastModified; -} - -void -CollectionScanner::Scanner::readArgs() -{ - QStringList argslist = arguments(); - if( argslist.size() < 2 ) - displayHelp(); - - bool missingArg = false; - - for( int argnum = 1; argnum < argslist.count(); argnum++ ) - { - QString arg = argslist.at( argnum ); - - if( arg.startsWith( "--" ) ) - { - QString myarg = QString( arg ).remove( 0, 2 ); - if( myarg == "newer" ) - { - if( argslist.count() > argnum + 1 ) - readNewerTime( argslist.at( argnum + 1 ) ); - else - missingArg = true; - argnum++; - } - else if( myarg == "batch" ) - { - if( argslist.count() > argnum + 1 ) - readBatchFile( argslist.at( argnum + 1 ) ); - else - missingArg = true; - argnum++; - } - else if( myarg == "sharedmemory" ) - { - if( argslist.count() > argnum + 1 ) - m_scanningState.setKey( argslist.at( argnum + 1 ) ); - else - missingArg = true; - argnum++; - } - else if( myarg == "version" ) - displayVersion(); - else if( myarg == "incremental" ) - m_incremental = true; - else if( myarg == "recursive" ) - m_recursively = true; - else if( myarg == "restart" ) - m_restart = true; - else if( myarg == "idlepriority" ) - m_idlePriority = true; - else if( myarg == "charset" ) - m_charset = true; - else - displayHelp(); - - } - else if( arg.startsWith( '-' ) ) - { - QString myarg = QString( arg ).remove( 0, 1 ); - int pos = 0; - while( pos < myarg.length() ) - { - if( myarg[pos] == 'r' ) - m_recursively = true; - else if( myarg[pos] == 'v' ) - displayVersion(); - else if( myarg[pos] == 's' ) - m_restart = true; - else if( myarg[pos] == 'c' ) - m_charset = true; - else if( myarg[pos] == 'i' ) - m_incremental = true; - else - displayHelp(); - - ++pos; - } - } - else - { - if( !arg.isEmpty() ) - m_folders.append( arg ); - } - } - - if( missingArg ) - displayHelp( tr( "Missing argument for option %1" ).arg( argslist.last() ) ); - - - CollectionScanner::Track::setUseCharsetDetector( m_charset ); - - // Start the actual scanning job - QTimer::singleShot( 0, this, SLOT(doJob()) ); -} - -void -CollectionScanner::Scanner::error( const QString &str ) -{ - QTextStream stream( stderr ); - stream << str << endl; - stream.flush(); - - // Nothing else to do, so we exit directly - ::exit( 0 ); -} - -/** This function is called by Amarok to verify that Amarok an Scanner versions match */ -void -CollectionScanner::Scanner::displayVersion() -{ - QTextStream stream( stdout ); - stream << AMAROK_VERSION << endl; - stream.flush(); - - // Nothing else to do, so we exit directly - ::exit( 0 ); -} - -void -CollectionScanner::Scanner::displayHelp( const QString &error ) -{ - QTextStream stream( error.isEmpty() ? stdout : stderr ); - stream << error - << tr( "Amarok Collection Scanner\n" - "Scans directories and outputs a xml file with the results.\n" - "For more information see http://community.kde.org/Amarok/Development/BatchMode\n\n" - "Usage: amarokcollectionscanner [options] \n" - "User-modifiable Options:\n" - " : list of folders to scan\n" - "-h, --help : This help text\n" - "-v, --version : Print the version of this tool\n" - "-r, --recursive : Scan folders recursively\n" - "-i, --incremental : Incremental scan (modified folders only)\n" - "-s, --restart : After a crash, restart the scanner in its last position\n" - " --idlepriority : Run at idle priority\n" - " --sharedmemory : A shared memory segment to be used for restarting a scan\n" - " --newer : Only scan directories if modification time is newer than \n" - " Only useful in incremental scan mode\n" - " --batch : Add the directories from the batch xml file\n" - " batch file format should look like this:\n" - " \n" - " \n" - " /absolute/path/of/directory\n" - " 1234 (this is optional)\n" - " \n" - " \n" - " You can also use a previous scan result for that.\n" - ) - << endl; - stream.flush(); - - ::exit(0); -} - -#include "moc_CollectionScanner.cpp" - diff --git a/amarok/utilities/collectionscanner/CollectionScanner.h b/amarok/utilities/collectionscanner/CollectionScanner.h deleted file mode 100644 index b81442ab..00000000 --- a/amarok/utilities/collectionscanner/CollectionScanner.h +++ /dev/null @@ -1,99 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2003-2010 Mark Kretschmann * - * (C) 2008 Dan Meltzer * - * (C) 2008-2009 Jeff Mitchell * - * * - * This program 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 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#ifndef COLLECTIONSCANNER_H -#define COLLECTIONSCANNER_H - -#include "collectionscanner/ScanningState.h" - -#include -#include -#include -#include -#include - -namespace CollectionScanner -{ - -/** - * @class Scanner - * @short Scans directories and builds the Collection - */ -class Scanner : public QCoreApplication -{ - Q_OBJECT - -public: - Scanner( int &argc, char **argv ); - ~Scanner(); - - /** Reads the batch file and adds the content to m_folders and m_Times */ - void readBatchFile( const QString &path ); - - /** Get's the modified time from the given file and set's m_newerTime according */ - void readNewerTime( const QString &path ); - -private slots: - void doJob(); - -private: - void addDir( const QString& dir, QSet *entries ); - - /** Returns true if the track is modified. - * Modification is determined first by m_mTimes and (if not found) - * then by m_newerTime - */ - bool isModified( const QString& dir ); - - void readArgs(); - - /** Displays the error message and exits */ - void error( const QString &str ); - - /** Displays the version and exits */ - void displayVersion(); - - /** Displays the help and an optional error message and exits */ - void displayHelp( const QString &error = QString() ); - - bool m_charset; - QStringList m_folders; - - uint m_newerTime; - QHash m_mTimes; - - bool m_incremental; - bool m_recursively; - bool m_restart; - bool m_idlePriority; - - QString m_mtimeFile; - ScanningState m_scanningState; - - - // Disable copy constructor and assignment - Scanner( const Scanner& ); - Scanner& operator= ( const Scanner& ); -}; - -} - -#endif // COLLECTIONSCANNER_H diff --git a/amarok/utilities/collectionscanner/charset-detector/include/chardet.h b/amarok/utilities/collectionscanner/charset-detector/include/chardet.h deleted file mode 100644 index 83188437..00000000 --- a/amarok/utilities/collectionscanner/charset-detector/include/chardet.h +++ /dev/null @@ -1,118 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Universal charset detector code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 2001 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Kohei TAKETA - * Jim Huang - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ -#ifndef ___CHARDET_H___ -#define ___CHARDET_H___ - -#include - -#define CHARDET_RESULT_OK 0 -#define CHARDET_RESULT_NOMEMORY (-1) -#define CHARDET_RESULT_INVALID_DETECTOR (-2) - -#define CHARDET_MAX_ENCODING_NAME 64 - - -typedef void* chardet_t; - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Create an encoding detector. - * @param pdet [out] pointer to a chardet_t variable that receives - * the encoding detector handle. - * @return CHARDET_RESULT_OK if succeeded. CHARDET_RESULT_NOMEMORY otherwise. - */ -int chardet_create(chardet_t* pdet); - -/** - * Destroy an encoding detector. - * @param det [in] the encoding detector handle to be destroyed. - */ -void chardet_destroy(chardet_t det); - -/** - * Feed data to an encoding detector. - * @param det [in] the encoding detector handle - * @param data [in] data - * @param len [in] length of data in bytes. - * @return CHARDET_RESULT_OK if succeeded. - * CHARSET_RESULT_NOMEMORY if running out of memory. - * CHARDET_RESULT_INVALID_DETECTOR if det was invalid. - */ -int chardet_handle_data(chardet_t det, const char* data, unsigned int len); - -/** - * Notify an end of data to an encoding detctor. - * @param det [in] the encoding detector handle - * @return CHARDET_RESULT_OK if succeeded. - * CHARDET_RESULT_INVALID_DETECTOR if det was invalid. - */ -int chardet_data_end(chardet_t det); - -/** - * Reset an encoding detector. - * @param det [in] the encoding detector handle - * @return CHARDET_RESULT_OK if succeeded. - * CHARDET_RESULT_INVALID_DETECTOR if det was invalid. - */ -int chardet_reset(chardet_t det); - -/** - * Get the name of encoding that was detected. - * @param det [in] the encoding detector handle - * @param namebuf [in/out] pointer to a buffer that receives the name of - * detected encoding. A valid encoding name or an empty string - * will be written to namebuf. If an empty strng was written, - * the detector could not detect any encoding. - * Written strings will always be NULL-terminated. - * @param buflen [in] length of namebuf - * @return CHARDET_RESULT_OK if succeeded. - * CHARDET_RESULT_NOMEMORY if namebuf was too small to store - * the entire encoding name. - * CHARDET_RESULT_INVALID_DETECTOR if det was invalid. - */ -int chardet_get_charset(chardet_t det, char* namebuf, unsigned int buflen); - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/amarok/utilities/collectionscanner/charset-detector/src/CharDistribution.cpp b/amarok/utilities/collectionscanner/charset-detector/src/CharDistribution.cpp deleted file mode 100644 index 93066339..00000000 --- a/amarok/utilities/collectionscanner/charset-detector/src/CharDistribution.cpp +++ /dev/null @@ -1,110 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#pragma GCC visibility push(hidden) - -#include "CharDistribution.h" - -#include "JISFreq.tab" -#include "Big5Freq.tab" -#include "EUCKRFreq.tab" -#include "EUCTWFreq.tab" -#include "GB2312Freq.tab" - -#define SURE_YES 0.99f -#define SURE_NO 0.01f - -//return confidence base on received data -float CharDistributionAnalysis::GetConfidence() -{ - //if we didn't receive any character in our consideration range, return negative answer - if (mTotalChars <= 0) - return SURE_NO; - - if (mTotalChars != mFreqChars) { - float r = mFreqChars / ((mTotalChars - mFreqChars) * mTypicalDistributionRatio); - - if (r < SURE_YES) - return r; - } - //normalize confidence, (we don't want to be 100% sure) - return SURE_YES; -} - -EUCTWDistributionAnalysis::EUCTWDistributionAnalysis() -{ - mCharToFreqOrder = EUCTWCharToFreqOrder; - mTableSize = EUCTW_TABLE_SIZE; - mTypicalDistributionRatio = EUCTW_TYPICAL_DISTRIBUTION_RATIO; -} - -EUCKRDistributionAnalysis::EUCKRDistributionAnalysis() -{ - mCharToFreqOrder = EUCKRCharToFreqOrder; - mTableSize = EUCKR_TABLE_SIZE; - mTypicalDistributionRatio = EUCKR_TYPICAL_DISTRIBUTION_RATIO; -} - -GB2312DistributionAnalysis::GB2312DistributionAnalysis() -{ - mCharToFreqOrder = GB2312CharToFreqOrder; - mTableSize = GB2312_TABLE_SIZE; - mTypicalDistributionRatio = GB2312_TYPICAL_DISTRIBUTION_RATIO; -} - -Big5DistributionAnalysis::Big5DistributionAnalysis() -{ - mCharToFreqOrder = Big5CharToFreqOrder; - mTableSize = BIG5_TABLE_SIZE; - mTypicalDistributionRatio = BIG5_TYPICAL_DISTRIBUTION_RATIO; -} - -SJISDistributionAnalysis::SJISDistributionAnalysis() -{ - mCharToFreqOrder = JISCharToFreqOrder; - mTableSize = JIS_TABLE_SIZE; - mTypicalDistributionRatio = JIS_TYPICAL_DISTRIBUTION_RATIO; -} - -EUCJPDistributionAnalysis::EUCJPDistributionAnalysis() -{ - mCharToFreqOrder = JISCharToFreqOrder; - mTableSize = JIS_TABLE_SIZE; - mTypicalDistributionRatio = JIS_TYPICAL_DISTRIBUTION_RATIO; -} - -#pragma GCC visibility pop diff --git a/amarok/utilities/collectionscanner/charset-detector/src/CharDistribution.h b/amarok/utilities/collectionscanner/charset-detector/src/CharDistribution.h deleted file mode 100644 index 4571a4d0..00000000 --- a/amarok/utilities/collectionscanner/charset-detector/src/CharDistribution.h +++ /dev/null @@ -1,238 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef CharDistribution_h__ -#define CharDistribution_h__ - -#include "nscore.h" - -#define ENOUGH_DATA_THRESHOLD 1024 - -class CharDistributionAnalysis -{ -public: - CharDistributionAnalysis() : mCharToFreqOrder(0), mTableSize(0) - , mTypicalDistributionRatio(0.0) {Reset();} - virtual ~CharDistributionAnalysis() {} - - //feed a block of data and do distribution analysis - void HandleData(const char* aBuf, PRUint32 aLen) {(void)aBuf; (void)aLen;} - - //Feed a character with known length - void HandleOneChar(const char* aStr, PRUint32 aCharLen) - { - PRInt32 order; - - //we only care about 2-bytes character in our distribution analysis - order = (aCharLen == 2) ? GetOrder(aStr) : -1; - - if (order >= 0) - { - mTotalChars++; - //order is valid - if ((PRUint32)order < mTableSize) - { - if (512 > mCharToFreqOrder[order]) - mFreqChars++; - } - } - }; - - //return confidence base on existing data - float GetConfidence(); - - //Reset analyser, clear any state - void Reset(void) - { - mDone = PR_FALSE; - mTotalChars = 0; - mFreqChars = 0; - }; - - //This function is for future extension. Caller can use this function to control - //analyser's behavior - void SetOpion(){}; - - //It is not necessary to receive all data to draw conclusion. For charset detection, - // certain amount of data is enough - PRBool GotEnoughData() {return mTotalChars > ENOUGH_DATA_THRESHOLD;}; - -protected: - //we do not handle character base on its original encoding string, but - //convert this encoding string to a number, here called order. - //This allow multiple encoding of a language to share one frequency table - virtual PRInt32 GetOrder(const char* str) {(void)str; return -1;}; - - //If this flag is set to PR_TRUE, detection is done and conclusion has been made - PRBool mDone; - - //The number of characters whose frequency order is less than 512 - PRUint32 mFreqChars; - - //Total character encounted. - PRUint32 mTotalChars; - - //Mapping table to get frequency order from char order (get from GetOrder()) - const PRInt16 *mCharToFreqOrder; - - //Size of above table - PRUint32 mTableSize; - - //This is a constant value varies from language to language, it is used in - //calculating confidence. See my paper for further detail. - float mTypicalDistributionRatio; -}; - - -class EUCTWDistributionAnalysis: public CharDistributionAnalysis -{ -public: - EUCTWDistributionAnalysis(); -protected: - - //for euc-TW encoding, we are interested - // first byte range: 0xc4 -- 0xfe - // second byte range: 0xa1 -- 0xfe - //no validation needed here. State machine has done that - PRInt32 GetOrder(const char* str) - { if ((unsigned char)*str >= (unsigned char)0xc4) - return 94*((unsigned char)str[0]-(unsigned char)0xc4) + (unsigned char)str[1] - (unsigned char)0xa1; - else - return -1; - }; -}; - - -class EUCKRDistributionAnalysis : public CharDistributionAnalysis -{ -public: - EUCKRDistributionAnalysis(); -protected: - //for euc-KR encoding, we are interested - // first byte range: 0xb0 -- 0xfe - // second byte range: 0xa1 -- 0xfe - //no validation needed here. State machine has done that - PRInt32 GetOrder(const char* str) - { if ((unsigned char)*str >= (unsigned char)0xb0) - return 94*((unsigned char)str[0]-(unsigned char)0xb0) + (unsigned char)str[1] - (unsigned char)0xa1; - else - return -1; - }; -}; - -class GB2312DistributionAnalysis : public CharDistributionAnalysis -{ -public: - GB2312DistributionAnalysis(); -protected: - //for GB2312 encoding, we are interested - // first byte range: 0xb0 -- 0xfe - // second byte range: 0xa1 -- 0xfe - //no validation needed here. State machine has done that - PRInt32 GetOrder(const char* str) - { if ((unsigned char)*str >= (unsigned char)0xb0 && (unsigned char)str[1] >= (unsigned char)0xa1) - return 94*((unsigned char)str[0]-(unsigned char)0xb0) + (unsigned char)str[1] - (unsigned char)0xa1; - else - return -1; - }; -}; - - -class Big5DistributionAnalysis : public CharDistributionAnalysis -{ -public: - Big5DistributionAnalysis(); -protected: - //for big5 encoding, we are interested - // first byte range: 0xa4 -- 0xfe - // second byte range: 0x40 -- 0x7e , 0xa1 -- 0xfe - //no validation needed here. State machine has done that - PRInt32 GetOrder(const char* str) - { if ((unsigned char)*str >= (unsigned char)0xa4) - if ((unsigned char)str[1] >= (unsigned char)0xa1) - return 157*((unsigned char)str[0]-(unsigned char)0xa4) + (unsigned char)str[1] - (unsigned char)0xa1 +63; - else - return 157*((unsigned char)str[0]-(unsigned char)0xa4) + (unsigned char)str[1] - (unsigned char)0x40; - else - return -1; - }; -}; - -class SJISDistributionAnalysis : public CharDistributionAnalysis -{ -public: - SJISDistributionAnalysis(); -protected: - //for sjis encoding, we are interested - // first byte range: 0x81 -- 0x9f , 0xe0 -- 0xfe - // second byte range: 0x40 -- 0x7e, 0x81 -- oxfe - //no validation needed here. State machine has done that - PRInt32 GetOrder(const char* str) - { - PRInt32 order; - if ((unsigned char)*str >= (unsigned char)0x81 && (unsigned char)*str <= (unsigned char)0x9f) - order = 188 * ((unsigned char)str[0]-(unsigned char)0x81); - else if ((unsigned char)*str >= (unsigned char)0xe0 && (unsigned char)*str <= (unsigned char)0xef) - order = 188 * ((unsigned char)str[0]-(unsigned char)0xe0 + 31); - else - return -1; - order += (unsigned char)*(str+1) - 0x40; - if ((unsigned char)str[1] > (unsigned char)0x7f) - order--; - return order; - }; -}; - -class EUCJPDistributionAnalysis : public CharDistributionAnalysis -{ -public: - EUCJPDistributionAnalysis(); -protected: - //for euc-JP encoding, we are interested - // first byte range: 0xa0 -- 0xfe - // second byte range: 0xa1 -- 0xfe - //no validation needed here. State machine has done that - PRInt32 GetOrder(const char* str) - { if ((unsigned char)*str >= (unsigned char)0xa0) - return 94*((unsigned char)str[0]-(unsigned char)0xa1) + (unsigned char)str[1] - (unsigned char)0xa1; - else - return -1; - }; -}; - -#endif //CharDistribution_h__ - diff --git a/amarok/utilities/collectionscanner/charset-detector/src/JpCntx.cpp b/amarok/utilities/collectionscanner/charset-detector/src/JpCntx.cpp deleted file mode 100644 index 776b1939..00000000 --- a/amarok/utilities/collectionscanner/charset-detector/src/JpCntx.cpp +++ /dev/null @@ -1,233 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#pragma GCC visibility push(hidden) - -#include "nscore.h" -#include "JpCntx.h" - -//This is hiragana 2-char sequence table, the number in each cell represents its frequency category -char jp2CharContext[83][83] = -{ -{ 0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1,}, -{ 2,4,0,4,0,3,0,4,0,3,4,4,4,2,4,3,3,4,3,2,3,3,4,2,3,3,3,2,4,1,4,3,3,1,5,4,3,4,3,4,3,5,3,0,3,5,4,2,0,3,1,0,3,3,0,3,3,0,1,1,0,4,3,0,3,3,0,4,0,2,0,3,5,5,5,5,4,0,4,1,0,3,4,}, -{ 0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,}, -{ 0,4,0,5,0,5,0,4,0,4,5,4,4,3,5,3,5,1,5,3,4,3,4,4,3,4,3,3,4,3,5,4,4,3,5,5,3,5,5,5,3,5,5,3,4,5,5,3,1,3,2,0,3,4,0,4,2,0,4,2,1,5,3,2,3,5,0,4,0,2,0,5,4,4,5,4,5,0,4,0,0,4,4,}, -{ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,}, -{ 0,3,0,4,0,3,0,3,0,4,5,4,3,3,3,3,4,3,5,4,4,3,5,4,4,3,4,3,4,4,4,4,5,3,4,4,3,4,5,5,4,5,5,1,4,5,4,3,0,3,3,1,3,3,0,4,4,0,3,3,1,5,3,3,3,5,0,4,0,3,0,4,4,3,4,3,3,0,4,1,1,3,4,}, -{ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,}, -{ 0,4,0,3,0,3,0,4,0,3,4,4,3,2,2,1,2,1,3,1,3,3,3,3,3,4,3,1,3,3,5,3,3,0,4,3,0,5,4,3,3,5,4,4,3,4,4,5,0,1,2,0,1,2,0,2,2,0,1,0,0,5,2,2,1,4,0,3,0,1,0,4,4,3,5,4,3,0,2,1,0,4,3,}, -{ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,}, -{ 0,3,0,5,0,4,0,2,1,4,4,2,4,1,4,2,4,2,4,3,3,3,4,3,3,3,3,1,4,2,3,3,3,1,4,4,1,1,1,4,3,3,2,0,2,4,3,2,0,3,3,0,3,1,1,0,0,0,3,3,0,4,2,2,3,4,0,4,0,3,0,4,4,5,3,4,4,0,3,0,0,1,4,}, -{ 1,4,0,4,0,4,0,4,0,3,5,4,4,3,4,3,5,4,3,3,4,3,5,4,4,4,4,3,4,2,4,3,3,1,5,4,3,2,4,5,4,5,5,4,4,5,4,4,0,3,2,2,3,3,0,4,3,1,3,2,1,4,3,3,4,5,0,3,0,2,0,4,5,5,4,5,4,0,4,0,0,5,4,}, -{ 0,5,0,5,0,4,0,3,0,4,4,3,4,3,3,3,4,0,4,4,4,3,4,3,4,3,3,1,4,2,4,3,4,0,5,4,1,4,5,4,4,5,3,2,4,3,4,3,2,4,1,3,3,3,2,3,2,0,4,3,3,4,3,3,3,4,0,4,0,3,0,4,5,4,4,4,3,0,4,1,0,1,3,}, -{ 0,3,1,4,0,3,0,2,0,3,4,4,3,1,4,2,3,3,4,3,4,3,4,3,4,4,3,2,3,1,5,4,4,1,4,4,3,5,4,4,3,5,5,4,3,4,4,3,1,2,3,1,2,2,0,3,2,0,3,1,0,5,3,3,3,4,3,3,3,3,4,4,4,4,5,4,2,0,3,3,2,4,3,}, -{ 0,2,0,3,0,1,0,1,0,0,3,2,0,0,2,0,1,0,2,1,3,3,3,1,2,3,1,0,1,0,4,2,1,1,3,3,0,4,3,3,1,4,3,3,0,3,3,2,0,0,0,0,1,0,0,2,0,0,0,0,0,4,1,0,2,3,2,2,2,1,3,3,3,4,4,3,2,0,3,1,0,3,3,}, -{ 0,4,0,4,0,3,0,3,0,4,4,4,3,3,3,3,3,3,4,3,4,2,4,3,4,3,3,2,4,3,4,5,4,1,4,5,3,5,4,5,3,5,4,0,3,5,5,3,1,3,3,2,2,3,0,3,4,1,3,3,2,4,3,3,3,4,0,4,0,3,0,4,5,4,4,5,3,0,4,1,0,3,4,}, -{ 0,2,0,3,0,3,0,0,0,2,2,2,1,0,1,0,0,0,3,0,3,0,3,0,1,3,1,0,3,1,3,3,3,1,3,3,3,0,1,3,1,3,4,0,0,3,1,1,0,3,2,0,0,0,0,1,3,0,1,0,0,3,3,2,0,3,0,0,0,0,0,3,4,3,4,3,3,0,3,0,0,2,3,}, -{ 2,3,0,3,0,2,0,1,0,3,3,4,3,1,3,1,1,1,3,1,4,3,4,3,3,3,0,0,3,1,5,4,3,1,4,3,2,5,5,4,4,4,4,3,3,4,4,4,0,2,1,1,3,2,0,1,2,0,0,1,0,4,1,3,3,3,0,3,0,1,0,4,4,4,5,5,3,0,2,0,0,4,4,}, -{ 0,2,0,1,0,3,1,3,0,2,3,3,3,0,3,1,0,0,3,0,3,2,3,1,3,2,1,1,0,0,4,2,1,0,2,3,1,4,3,2,0,4,4,3,1,3,1,3,0,1,0,0,1,0,0,0,1,0,0,0,0,4,1,1,1,2,0,3,0,0,0,3,4,2,4,3,2,0,1,0,0,3,3,}, -{ 0,1,0,4,0,5,0,4,0,2,4,4,2,3,3,2,3,3,5,3,3,3,4,3,4,2,3,0,4,3,3,3,4,1,4,3,2,1,5,5,3,4,5,1,3,5,4,2,0,3,3,0,1,3,0,4,2,0,1,3,1,4,3,3,3,3,0,3,0,1,0,3,4,4,4,5,5,0,3,0,1,4,5,}, -{ 0,2,0,3,0,3,0,0,0,2,3,1,3,0,4,0,1,1,3,0,3,4,3,2,3,1,0,3,3,2,3,1,3,0,2,3,0,2,1,4,1,2,2,0,0,3,3,0,0,2,0,0,0,1,0,0,0,0,2,2,0,3,2,1,3,3,0,2,0,2,0,0,3,3,1,2,4,0,3,0,2,2,3,}, -{ 2,4,0,5,0,4,0,4,0,2,4,4,4,3,4,3,3,3,1,2,4,3,4,3,4,4,5,0,3,3,3,3,2,0,4,3,1,4,3,4,1,4,4,3,3,4,4,3,1,2,3,0,4,2,0,4,1,0,3,3,0,4,3,3,3,4,0,4,0,2,0,3,5,3,4,5,2,0,3,0,0,4,5,}, -{ 0,3,0,4,0,1,0,1,0,1,3,2,2,1,3,0,3,0,2,0,2,0,3,0,2,0,0,0,1,0,1,1,0,0,3,1,0,0,0,4,0,3,1,0,2,1,3,0,0,0,0,0,0,3,0,0,0,0,0,0,0,4,2,2,3,1,0,3,0,0,0,1,4,4,4,3,0,0,4,0,0,1,4,}, -{ 1,4,1,5,0,3,0,3,0,4,5,4,4,3,5,3,3,4,4,3,4,1,3,3,3,3,2,1,4,1,5,4,3,1,4,4,3,5,4,4,3,5,4,3,3,4,4,4,0,3,3,1,2,3,0,3,1,0,3,3,0,5,4,4,4,4,4,4,3,3,5,4,4,3,3,5,4,0,3,2,0,4,4,}, -{ 0,2,0,3,0,1,0,0,0,1,3,3,3,2,4,1,3,0,3,1,3,0,2,2,1,1,0,0,2,0,4,3,1,0,4,3,0,4,4,4,1,4,3,1,1,3,3,1,0,2,0,0,1,3,0,0,0,0,2,0,0,4,3,2,4,3,5,4,3,3,3,4,3,3,4,3,3,0,2,1,0,3,3,}, -{ 0,2,0,4,0,3,0,2,0,2,5,5,3,4,4,4,4,1,4,3,3,0,4,3,4,3,1,3,3,2,4,3,0,3,4,3,0,3,4,4,2,4,4,0,4,5,3,3,2,2,1,1,1,2,0,1,5,0,3,3,2,4,3,3,3,4,0,3,0,2,0,4,4,3,5,5,0,0,3,0,2,3,3,}, -{ 0,3,0,4,0,3,0,1,0,3,4,3,3,1,3,3,3,0,3,1,3,0,4,3,3,1,1,0,3,0,3,3,0,0,4,4,0,1,5,4,3,3,5,0,3,3,4,3,0,2,0,1,1,1,0,1,3,0,1,2,1,3,3,2,3,3,0,3,0,1,0,1,3,3,4,4,1,0,1,2,2,1,3,}, -{ 0,1,0,4,0,4,0,3,0,1,3,3,3,2,3,1,1,0,3,0,3,3,4,3,2,4,2,0,1,0,4,3,2,0,4,3,0,5,3,3,2,4,4,4,3,3,3,4,0,1,3,0,0,1,0,0,1,0,0,0,0,4,2,3,3,3,0,3,0,0,0,4,4,4,5,3,2,0,3,3,0,3,5,}, -{ 0,2,0,3,0,0,0,3,0,1,3,0,2,0,0,0,1,0,3,1,1,3,3,0,0,3,0,0,3,0,2,3,1,0,3,1,0,3,3,2,0,4,2,2,0,2,0,0,0,4,0,0,0,0,0,0,0,0,0,0,0,2,1,2,0,1,0,1,0,0,0,1,3,1,2,0,0,0,1,0,0,1,4,}, -{ 0,3,0,3,0,5,0,1,0,2,4,3,1,3,3,2,1,1,5,2,1,0,5,1,2,0,0,0,3,3,2,2,3,2,4,3,0,0,3,3,1,3,3,0,2,5,3,4,0,3,3,0,1,2,0,2,2,0,3,2,0,2,2,3,3,3,0,2,0,1,0,3,4,4,2,5,4,0,3,0,0,3,5,}, -{ 0,3,0,3,0,3,0,1,0,3,3,3,3,0,3,0,2,0,2,1,1,0,2,0,1,0,0,0,2,1,0,0,1,0,3,2,0,0,3,3,1,2,3,1,0,3,3,0,0,1,0,0,0,0,0,2,0,0,0,0,0,2,3,1,2,3,0,3,0,1,0,3,2,1,0,4,3,0,1,1,0,3,3,}, -{ 0,4,0,5,0,3,0,3,0,4,5,5,4,3,5,3,4,3,5,3,3,2,5,3,4,4,4,3,4,3,4,5,5,3,4,4,3,4,4,5,4,4,4,3,4,5,5,4,2,3,4,2,3,4,0,3,3,1,4,3,2,4,3,3,5,5,0,3,0,3,0,5,5,5,5,4,4,0,4,0,1,4,4,}, -{ 0,4,0,4,0,3,0,3,0,3,5,4,4,2,3,2,5,1,3,2,5,1,4,2,3,2,3,3,4,3,3,3,3,2,5,4,1,3,3,5,3,4,4,0,4,4,3,1,1,3,1,0,2,3,0,2,3,0,3,0,0,4,3,1,3,4,0,3,0,2,0,4,4,4,3,4,5,0,4,0,0,3,4,}, -{ 0,3,0,3,0,3,1,2,0,3,4,4,3,3,3,0,2,2,4,3,3,1,3,3,3,1,1,0,3,1,4,3,2,3,4,4,2,4,4,4,3,4,4,3,2,4,4,3,1,3,3,1,3,3,0,4,1,0,2,2,1,4,3,2,3,3,5,4,3,3,5,4,4,3,3,0,4,0,3,2,2,4,4,}, -{ 0,2,0,1,0,0,0,0,0,1,2,1,3,0,0,0,0,0,2,0,1,2,1,0,0,1,0,0,0,0,3,0,0,1,0,1,1,3,1,0,0,0,1,1,0,1,1,0,0,0,0,0,2,0,0,0,0,0,0,0,0,1,1,2,2,0,3,4,0,0,0,1,1,0,0,1,0,0,0,0,0,1,1,}, -{ 0,1,0,0,0,1,0,0,0,0,4,0,4,1,4,0,3,0,4,0,3,0,4,0,3,0,3,0,4,1,5,1,4,0,0,3,0,5,0,5,2,0,1,0,0,0,2,1,4,0,1,3,0,0,3,0,0,3,1,1,4,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,}, -{ 1,4,0,5,0,3,0,2,0,3,5,4,4,3,4,3,5,3,4,3,3,0,4,3,3,3,3,3,3,2,4,4,3,1,3,4,4,5,4,4,3,4,4,1,3,5,4,3,3,3,1,2,2,3,3,1,3,1,3,3,3,5,3,3,4,5,0,3,0,3,0,3,4,3,4,4,3,0,3,0,2,4,3,}, -{ 0,1,0,4,0,0,0,0,0,1,4,0,4,1,4,2,4,0,3,0,1,0,1,0,0,0,0,0,2,0,3,1,1,1,0,3,0,0,0,1,2,1,0,0,1,1,1,1,0,1,0,0,0,1,0,0,3,0,0,0,0,3,2,0,2,2,0,1,0,0,0,2,3,2,3,3,0,0,0,0,2,1,0,}, -{ 0,5,1,5,0,3,0,3,0,5,4,4,5,1,5,3,3,0,4,3,4,3,5,3,4,3,3,2,4,3,4,3,3,0,3,3,1,4,4,3,4,4,4,3,4,5,5,3,2,3,1,1,3,3,1,3,1,1,3,3,2,4,5,3,3,5,0,4,0,3,0,4,4,3,5,3,3,0,3,4,0,4,3,}, -{ 0,5,0,5,0,3,0,2,0,4,4,3,5,2,4,3,3,3,4,4,4,3,5,3,5,3,3,1,4,0,4,3,3,0,3,3,0,4,4,4,4,5,4,3,3,5,5,3,2,3,1,2,3,2,0,1,0,0,3,2,2,4,4,3,1,5,0,4,0,3,0,4,3,1,3,2,1,0,3,3,0,3,3,}, -{ 0,4,0,5,0,5,0,4,0,4,5,5,5,3,4,3,3,2,5,4,4,3,5,3,5,3,4,0,4,3,4,4,3,2,4,4,3,4,5,4,4,5,5,0,3,5,5,4,1,3,3,2,3,3,1,3,1,0,4,3,1,4,4,3,4,5,0,4,0,2,0,4,3,4,4,3,3,0,4,0,0,5,5,}, -{ 0,4,0,4,0,5,0,1,1,3,3,4,4,3,4,1,3,0,5,1,3,0,3,1,3,1,1,0,3,0,3,3,4,0,4,3,0,4,4,4,3,4,4,0,3,5,4,1,0,3,0,0,2,3,0,3,1,0,3,1,0,3,2,1,3,5,0,3,0,1,0,3,2,3,3,4,4,0,2,2,0,4,4,}, -{ 2,4,0,5,0,4,0,3,0,4,5,5,4,3,5,3,5,3,5,3,5,2,5,3,4,3,3,4,3,4,5,3,2,1,5,4,3,2,3,4,5,3,4,1,2,5,4,3,0,3,3,0,3,2,0,2,3,0,4,1,0,3,4,3,3,5,0,3,0,1,0,4,5,5,5,4,3,0,4,2,0,3,5,}, -{ 0,5,0,4,0,4,0,2,0,5,4,3,4,3,4,3,3,3,4,3,4,2,5,3,5,3,4,1,4,3,4,4,4,0,3,5,0,4,4,4,4,5,3,1,3,4,5,3,3,3,3,3,3,3,0,2,2,0,3,3,2,4,3,3,3,5,3,4,1,3,3,5,3,2,0,0,0,0,4,3,1,3,3,}, -{ 0,1,0,3,0,3,0,1,0,1,3,3,3,2,3,3,3,0,3,0,0,0,3,1,3,0,0,0,2,2,2,3,0,0,3,2,0,1,2,4,1,3,3,0,0,3,3,3,0,1,0,0,2,1,0,0,3,0,3,1,0,3,0,0,1,3,0,2,0,1,0,3,3,1,3,3,0,0,1,1,0,3,3,}, -{ 0,2,0,3,0,2,1,4,0,2,2,3,1,1,3,1,1,0,2,0,3,1,2,3,1,3,0,0,1,0,4,3,2,3,3,3,1,4,2,3,3,3,3,1,0,3,1,4,0,1,1,0,1,2,0,1,1,0,1,1,0,3,1,3,2,2,0,1,0,0,0,2,3,3,3,1,0,0,0,0,0,2,3,}, -{ 0,5,0,4,0,5,0,2,0,4,5,5,3,3,4,3,3,1,5,4,4,2,4,4,4,3,4,2,4,3,5,5,4,3,3,4,3,3,5,5,4,5,5,1,3,4,5,3,1,4,3,1,3,3,0,3,3,1,4,3,1,4,5,3,3,5,0,4,0,3,0,5,3,3,1,4,3,0,4,0,1,5,3,}, -{ 0,5,0,5,0,4,0,2,0,4,4,3,4,3,3,3,3,3,5,4,4,4,4,4,4,5,3,3,5,2,4,4,4,3,4,4,3,3,4,4,5,5,3,3,4,3,4,3,3,4,3,3,3,3,1,2,2,1,4,3,3,5,4,4,3,4,0,4,0,3,0,4,4,4,4,4,1,0,4,2,0,2,4,}, -{ 0,4,0,4,0,3,0,1,0,3,5,2,3,0,3,0,2,1,4,2,3,3,4,1,4,3,3,2,4,1,3,3,3,0,3,3,0,0,3,3,3,5,3,3,3,3,3,2,0,2,0,0,2,0,0,2,0,0,1,0,0,3,1,2,2,3,0,3,0,2,0,4,4,3,3,4,1,0,3,0,0,2,4,}, -{ 0,0,0,4,0,0,0,0,0,0,1,0,1,0,2,0,0,0,0,0,1,0,2,0,1,0,0,0,0,0,3,1,3,0,3,2,0,0,0,1,0,3,2,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,4,0,2,0,0,0,0,0,0,2,}, -{ 0,2,1,3,0,2,0,2,0,3,3,3,3,1,3,1,3,3,3,3,3,3,4,2,2,1,2,1,4,0,4,3,1,3,3,3,2,4,3,5,4,3,3,3,3,3,3,3,0,1,3,0,2,0,0,1,0,0,1,0,0,4,2,0,2,3,0,3,3,0,3,3,4,2,3,1,4,0,1,2,0,2,3,}, -{ 0,3,0,3,0,1,0,3,0,2,3,3,3,0,3,1,2,0,3,3,2,3,3,2,3,2,3,1,3,0,4,3,2,0,3,3,1,4,3,3,2,3,4,3,1,3,3,1,1,0,1,1,0,1,0,1,0,1,0,0,0,4,1,1,0,3,0,3,1,0,2,3,3,3,3,3,1,0,0,2,0,3,3,}, -{ 0,0,0,0,0,0,0,0,0,0,3,0,2,0,3,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,3,0,3,0,3,1,0,1,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,2,0,2,3,0,0,0,0,0,0,0,0,3,}, -{ 0,2,0,3,1,3,0,3,0,2,3,3,3,1,3,1,3,1,3,1,3,3,3,1,3,0,2,3,1,1,4,3,3,2,3,3,1,2,2,4,1,3,3,0,1,4,2,3,0,1,3,0,3,0,0,1,3,0,2,0,0,3,3,2,1,3,0,3,0,2,0,3,4,4,4,3,1,0,3,0,0,3,3,}, -{ 0,2,0,1,0,2,0,0,0,1,3,2,2,1,3,0,1,1,3,0,3,2,3,1,2,0,2,0,1,1,3,3,3,0,3,3,1,1,2,3,2,3,3,1,2,3,2,0,0,1,0,0,0,0,0,0,3,0,1,0,0,2,1,2,1,3,0,3,0,0,0,3,4,4,4,3,2,0,2,0,0,2,4,}, -{ 0,0,0,1,0,1,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,2,2,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,3,1,0,0,0,0,0,0,0,3,}, -{ 0,3,0,3,0,2,0,3,0,3,3,3,2,3,2,2,2,0,3,1,3,3,3,2,3,3,0,0,3,0,3,2,2,0,2,3,1,4,3,4,3,3,2,3,1,5,4,4,0,3,1,2,1,3,0,3,1,1,2,0,2,3,1,3,1,3,0,3,0,1,0,3,3,4,4,2,1,0,2,1,0,2,4,}, -{ 0,1,0,3,0,1,0,2,0,1,4,2,5,1,4,0,2,0,2,1,3,1,4,0,2,1,0,0,2,1,4,1,1,0,3,3,0,5,1,3,2,3,3,1,0,3,2,3,0,1,0,0,0,0,0,0,1,0,0,0,0,4,0,1,0,3,0,2,0,1,0,3,3,3,4,3,3,0,0,0,0,2,3,}, -{ 0,0,0,1,0,0,0,0,0,0,2,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,1,0,0,1,0,0,0,0,0,3,}, -{ 0,1,0,3,0,4,0,3,0,2,4,3,1,0,3,2,2,1,3,1,2,2,3,1,1,1,2,1,3,0,1,2,0,1,3,2,1,3,0,5,5,1,0,0,1,3,2,1,0,3,0,0,1,0,0,0,0,0,3,4,0,1,1,1,3,2,0,2,0,1,0,2,3,3,1,2,3,0,1,0,1,0,4,}, -{ 0,0,0,1,0,3,0,3,0,2,2,1,0,0,4,0,3,0,3,1,3,0,3,0,3,0,1,0,3,0,3,1,3,0,3,3,0,0,1,2,1,1,1,0,1,2,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,2,2,1,2,0,0,2,0,0,0,0,2,3,3,3,3,0,0,0,0,1,4,}, -{ 0,0,0,3,0,3,0,0,0,0,3,1,1,0,3,0,1,0,2,0,1,0,0,0,0,0,0,0,1,0,3,0,2,0,2,3,0,0,2,2,3,1,2,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,2,0,0,0,0,2,3,}, -{ 2,4,0,5,0,5,0,4,0,3,4,3,3,3,4,3,3,3,4,3,4,4,5,4,5,5,5,2,3,0,5,5,4,1,5,4,3,1,5,4,3,4,4,3,3,4,3,3,0,3,2,0,2,3,0,3,0,0,3,3,0,5,3,2,3,3,0,3,0,3,0,3,4,5,4,5,3,0,4,3,0,3,4,}, -{ 0,3,0,3,0,3,0,3,0,3,3,4,3,2,3,2,3,0,4,3,3,3,3,3,3,3,3,0,3,2,4,3,3,1,3,4,3,4,4,4,3,4,4,3,2,4,4,1,0,2,0,0,1,1,0,2,0,0,3,1,0,5,3,2,1,3,0,3,0,1,2,4,3,2,4,3,3,0,3,2,0,4,4,}, -{ 0,3,0,3,0,1,0,0,0,1,4,3,3,2,3,1,3,1,4,2,3,2,4,2,3,4,3,0,2,2,3,3,3,0,3,3,3,0,3,4,1,3,3,0,3,4,3,3,0,1,1,0,1,0,0,0,4,0,3,0,0,3,1,2,1,3,0,4,0,1,0,4,3,3,4,3,3,0,2,0,0,3,3,}, -{ 0,3,0,4,0,1,0,3,0,3,4,3,3,0,3,3,3,1,3,1,3,3,4,3,3,3,0,0,3,1,5,3,3,1,3,3,2,5,4,3,3,4,5,3,2,5,3,4,0,1,0,0,0,0,0,2,0,0,1,1,0,4,2,2,1,3,0,3,0,2,0,4,4,3,5,3,2,0,1,1,0,3,4,}, -{ 0,5,0,4,0,5,0,2,0,4,4,3,3,2,3,3,3,1,4,3,4,1,5,3,4,3,4,0,4,2,4,3,4,1,5,4,0,4,4,4,4,5,4,1,3,5,4,2,1,4,1,1,3,2,0,3,1,0,3,2,1,4,3,3,3,4,0,4,0,3,0,4,4,4,3,3,3,0,4,2,0,3,4,}, -{ 1,4,0,4,0,3,0,1,0,3,3,3,1,1,3,3,2,2,3,3,1,0,3,2,2,1,2,0,3,1,2,1,2,0,3,2,0,2,2,3,3,4,3,0,3,3,1,2,0,1,1,3,1,2,0,0,3,0,1,1,0,3,2,2,3,3,0,3,0,0,0,2,3,3,4,3,3,0,1,0,0,1,4,}, -{ 0,4,0,4,0,4,0,0,0,3,4,4,3,1,4,2,3,2,3,3,3,1,4,3,4,0,3,0,4,2,3,3,2,2,5,4,2,1,3,4,3,4,3,1,3,3,4,2,0,2,1,0,3,3,0,0,2,0,3,1,0,4,4,3,4,3,0,4,0,1,0,2,4,4,4,4,4,0,3,2,0,3,3,}, -{ 0,0,0,1,0,4,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,3,2,0,0,1,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,2,}, -{ 0,2,0,3,0,4,0,4,0,1,3,3,3,0,4,0,2,1,2,1,1,1,2,0,3,1,1,0,1,0,3,1,0,0,3,3,2,0,1,1,0,0,0,0,0,1,0,2,0,2,2,0,3,1,0,0,1,0,1,1,0,1,2,0,3,0,0,0,0,1,0,0,3,3,4,3,1,0,1,0,3,0,2,}, -{ 0,0,0,3,0,5,0,0,0,0,1,0,2,0,3,1,0,1,3,0,0,0,2,0,0,0,1,0,0,0,1,1,0,0,4,0,0,0,2,3,0,1,4,1,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,1,0,0,0,0,0,0,0,2,0,0,3,0,0,0,0,0,3,}, -{ 0,2,0,5,0,5,0,1,0,2,4,3,3,2,5,1,3,2,3,3,3,0,4,1,2,0,3,0,4,0,2,2,1,1,5,3,0,0,1,4,2,3,2,0,3,3,3,2,0,2,4,1,1,2,0,1,1,0,3,1,0,1,3,1,2,3,0,2,0,0,0,1,3,5,4,4,4,0,3,0,0,1,3,}, -{ 0,4,0,5,0,4,0,4,0,4,5,4,3,3,4,3,3,3,4,3,4,4,5,3,4,5,4,2,4,2,3,4,3,1,4,4,1,3,5,4,4,5,5,4,4,5,5,5,2,3,3,1,4,3,1,3,3,0,3,3,1,4,3,4,4,4,0,3,0,4,0,3,3,4,4,5,0,0,4,3,0,4,5,}, -{ 0,4,0,4,0,3,0,3,0,3,4,4,4,3,3,2,4,3,4,3,4,3,5,3,4,3,2,1,4,2,4,4,3,1,3,4,2,4,5,5,3,4,5,4,1,5,4,3,0,3,2,2,3,2,1,3,1,0,3,3,3,5,3,3,3,5,4,4,2,3,3,4,3,3,3,2,1,0,3,2,1,4,3,}, -{ 0,4,0,5,0,4,0,3,0,3,5,5,3,2,4,3,4,0,5,4,4,1,4,4,4,3,3,3,4,3,5,5,2,3,3,4,1,2,5,5,3,5,5,2,3,5,5,4,0,3,2,0,3,3,1,1,5,1,4,1,0,4,3,2,3,5,0,4,0,3,0,5,4,3,4,3,0,0,4,1,0,4,4,}, -{ 1,3,0,4,0,2,0,2,0,2,5,5,3,3,3,3,3,0,4,2,3,4,4,4,3,4,0,0,3,4,5,4,3,3,3,3,2,5,5,4,5,5,5,4,3,5,5,5,1,3,1,0,1,0,0,3,2,0,4,2,0,5,2,3,2,4,1,3,0,3,0,4,5,4,5,4,3,0,4,2,0,5,4,}, -{ 0,3,0,4,0,5,0,3,0,3,4,4,3,2,3,2,3,3,3,3,3,2,4,3,3,2,2,0,3,3,3,3,3,1,3,3,3,0,4,4,3,4,4,1,1,4,4,2,0,3,1,0,1,1,0,4,1,0,2,3,1,3,3,1,3,4,0,3,0,1,0,3,1,3,0,0,1,0,2,0,0,4,4,}, -{ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,}, -{ 0,3,0,3,0,2,0,3,0,1,5,4,3,3,3,1,4,2,1,2,3,4,4,2,4,4,5,0,3,1,4,3,4,0,4,3,3,3,2,3,2,5,3,4,3,2,2,3,0,0,3,0,2,1,0,1,2,0,0,0,0,2,1,1,3,1,0,2,0,4,0,3,4,4,4,5,2,0,2,0,0,1,3,}, -{ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,1,1,0,0,1,1,0,0,0,4,2,1,1,0,1,0,3,2,0,0,3,1,1,1,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,1,0,0,0,2,0,0,0,1,4,0,4,2,1,0,0,0,0,0,1,}, -{ 0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,1,0,0,0,0,0,0,1,0,1,0,0,0,0,3,1,0,0,0,2,0,2,1,0,0,1,2,1,0,1,1,0,0,3,0,0,0,0,0,0,0,0,0,0,0,1,3,1,0,0,0,0,0,1,0,0,2,1,0,0,0,0,0,0,0,0,2,}, -{ 0,4,0,4,0,4,0,3,0,4,4,3,4,2,4,3,2,0,4,4,4,3,5,3,5,3,3,2,4,2,4,3,4,3,1,4,0,2,3,4,4,4,3,3,3,4,4,4,3,4,1,3,4,3,2,1,2,1,3,3,3,4,4,3,3,5,0,4,0,3,0,4,3,3,3,2,1,0,3,0,0,3,3,}, -{ 0,4,0,3,0,3,0,3,0,3,5,5,3,3,3,3,4,3,4,3,3,3,4,4,4,3,3,3,3,4,3,5,3,3,1,3,2,4,5,5,5,5,4,3,4,5,5,3,2,2,3,3,3,3,2,3,3,1,2,3,2,4,3,3,3,4,0,4,0,2,0,4,3,2,2,1,2,0,3,0,0,4,1,}, -}; - -#define MINIMUM_DATA_THRESHOLD 4 - -void JapaneseContextAnalysis::HandleData(const char* aBuf, PRUint32 aLen) -{ - PRUint32 charLen; - PRInt32 order; - PRUint32 i; - - if (mDone) - return; - - //The buffer we got is byte oriented, and a character may span in more than one - //buffers. In case the last one or two bytes in the last buffer is not complete, we - //record how many bytes are needed to complete that character and skip those bytes here. - //We can choose to record those bytes as well and analyze the character once it - //is complete, but since a character will not make much difference, by skipping - //this character we will simplify our logic and improve performance. - for (i = mNeedToSkipCharNum; i < aLen; ) - { - order = GetOrder(aBuf+i, &charLen); - i+= charLen; - if (i > aLen){ - mNeedToSkipCharNum = i - aLen; - mLastCharOrder = -1; - } - else - { - if (order != -1 && mLastCharOrder != -1) - { - mTotalRel ++; - if (mTotalRel > MAX_REL_THRESHOLD) - { - mDone = PR_TRUE; - break; - } - mRelSample[int(jp2CharContext[mLastCharOrder][order])]++; - } - mLastCharOrder = order; - } - } - - return; -} - -void JapaneseContextAnalysis::Reset(void) -{ - mTotalRel = 0; - for (PRUint32 i = 0; i < NUM_OF_CATEGORY; i++) - mRelSample[i] = 0; - mNeedToSkipCharNum = 0; - mLastCharOrder = -1; - mDone = PR_FALSE; -} -#define DONT_KNOW (float)-1 - -float JapaneseContextAnalysis::GetConfidence() -{ - //This is just one way to calculate confidence. It works well for me. - if (mTotalRel > MINIMUM_DATA_THRESHOLD) - return ((float)(mTotalRel - mRelSample[0]))/mTotalRel; - else - return (float)DONT_KNOW; -} - - -PRInt32 SJISContextAnalysis::GetOrder(const char* str, PRUint32 *charLen) -{ - //find out current char's byte length - if (((unsigned char)*str >= (unsigned char)0x81 && (unsigned char)*str <= (unsigned char)0x9f) || - ((unsigned char)*str >= (unsigned char)0xe0 && (unsigned char)*str <= (unsigned char)0xfc) ) - *charLen = 2; - else - *charLen = 1; - - //return its order if it is hiragana - if (*str == '\202' && - (unsigned char)*(str+1) >= (unsigned char)0x9f && - (unsigned char)*(str+1) <= (unsigned char)0xf1) - return (unsigned char)*(str+1) - (unsigned char)0x9f; - return -1; -} - -PRInt32 EUCJPContextAnalysis::GetOrder(const char* str, PRUint32 *charLen) -{ - //find out current char's byte length - if ((unsigned char)*str == (unsigned char)0x8e || - ((unsigned char)*str >= (unsigned char)0xa1 && - (unsigned char)*str <= (unsigned char)0xfe)) - *charLen = 2; - else if ((unsigned char)*str == (unsigned char)0x8f) - *charLen = 3; - else - *charLen = 1; - - //return its order if it is hiragana - if ((unsigned char)*str == (unsigned char)0xa4 && - (unsigned char)*(str+1) >= (unsigned char)0xa1 && - (unsigned char)*(str+1) <= (unsigned char)0xf3) - return (unsigned char)*(str+1) - (unsigned char)0xa1; - return -1; -} - -#pragma GCC visibility pop diff --git a/amarok/utilities/collectionscanner/charset-detector/src/JpCntx.h b/amarok/utilities/collectionscanner/charset-detector/src/JpCntx.h deleted file mode 100644 index c3cc9edc..00000000 --- a/amarok/utilities/collectionscanner/charset-detector/src/JpCntx.h +++ /dev/null @@ -1,138 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef __JPCNTX_H__ -#define __JPCNTX_H__ - -#define NUM_OF_CATEGORY 6 - -#include "nscore.h" - -#define ENOUGH_REL_THRESHOLD 100 -#define MAX_REL_THRESHOLD 1000 - -//hiragana frequency category table -extern char jp2CharContext[83][83]; - -class JapaneseContextAnalysis -{ -public: - JapaneseContextAnalysis() {Reset();} - virtual ~JapaneseContextAnalysis() {} - - void HandleData(const char* aBuf, PRUint32 aLen); - - void HandleOneChar(const char* aStr, PRUint32 aCharLen) - { - PRInt32 order; - - //if we received enough data, stop here - if (mTotalRel > MAX_REL_THRESHOLD) mDone = PR_TRUE; - if (mDone) return; - - //Only 2-bytes characters are of our interest - order = (aCharLen == 2) ? GetOrder(aStr) : -1; - if (order != -1 && mLastCharOrder != -1) - { - mTotalRel++; - //count this sequence to its category counter - mRelSample[int(jp2CharContext[mLastCharOrder][order])]++; - } - mLastCharOrder = order; - }; - - float GetConfidence(); - void Reset(void); - void SetOpion(){}; - PRBool GotEnoughData() {return mTotalRel > ENOUGH_REL_THRESHOLD;}; - -protected: - virtual PRInt32 GetOrder(const char* str, PRUint32 *charLen) = 0; - virtual PRInt32 GetOrder(const char* str) = 0; - - //category counters, each interger counts sequence in its category - PRUint32 mRelSample[NUM_OF_CATEGORY]; - - //total sequence received - PRUint32 mTotalRel; - - //The order of previous char - PRInt32 mLastCharOrder; - - //if last byte in current buffer is not the last byte of a character, we - //need to know how many byte to skip in next buffer. - PRUint32 mNeedToSkipCharNum; - - //If this flag is set to PR_TRUE, detection is done and conclusion has been made - PRBool mDone; -}; - - -class SJISContextAnalysis : public JapaneseContextAnalysis -{ - //SJISContextAnalysis(){}; -protected: - PRInt32 GetOrder(const char* str, PRUint32 *charLen); - - PRInt32 GetOrder(const char* str) - { - //We only interested in Hiragana, so first byte is '\202' - if (*str == '\202' && - (unsigned char)*(str+1) >= (unsigned char)0x9f && - (unsigned char)*(str+1) <= (unsigned char)0xf1) - return (unsigned char)*(str+1) - (unsigned char)0x9f; - return -1; - }; -}; - -class EUCJPContextAnalysis : public JapaneseContextAnalysis -{ -protected: - PRInt32 GetOrder(const char* str, PRUint32 *charLen); - PRInt32 GetOrder(const char* str) - //We only interested in Hiragana, so first byte is '\244' - { - if (*str == '\244' && - (unsigned char)*(str+1) >= (unsigned char)0xa1 && - (unsigned char)*(str+1) <= (unsigned char)0xf3) - return (unsigned char)*(str+1) - (unsigned char)0xa1; - return -1; - }; -}; - -#endif /* __JPCNTX_H__ */ - diff --git a/amarok/utilities/collectionscanner/charset-detector/src/LangBulgarianModel.cpp b/amarok/utilities/collectionscanner/charset-detector/src/LangBulgarianModel.cpp deleted file mode 100644 index 8395cf7b..00000000 --- a/amarok/utilities/collectionscanner/charset-detector/src/LangBulgarianModel.cpp +++ /dev/null @@ -1,250 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#pragma GCC visibility push(hidden) - -#include "nsSBCharSetProber.h" -/**************************************************************** -255: Control characters that usually does not exist in any text -254: Carriage/Return -253: symbol (punctuation) that does not belong to word -252: 0 - 9 - -*****************************************************************/ - -//Character Mapping Table: -//this talbe is modified base on win1251BulgarianCharToOrderMap, so -//only number <64 is sure valid - -unsigned char Latin5_BulgarianCharToOrderMap[] = -{ -255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, //00 -255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, //10 -+253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, //20 -252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, //30 -253, 77, 90, 99,100, 72,109,107,101, 79,185, 81,102, 76, 94, 82, //40 -110,186,108, 91, 74,119, 84, 96,111,187,115,253,253,253,253,253, //50 -253, 65, 69, 70, 66, 63, 68,112,103, 92,194,104, 95, 86, 87, 71, //60 -116,195, 85, 93, 97,113,196,197,198,199,200,253,253,253,253,253, //70 -194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209, //80 -210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225, //90 - 81,226,227,228,229,230,105,231,232,233,234,235,236, 45,237,238, //a0 - 31, 32, 35, 43, 37, 44, 55, 47, 40, 59, 33, 46, 38, 36, 41, 30, //b0 - 39, 28, 34, 51, 48, 49, 53, 50, 54, 57, 61,239, 67,240, 60, 56, //c0 - 1, 18, 9, 20, 11, 3, 23, 15, 2, 26, 12, 10, 14, 6, 4, 13, //d0 - 7, 8, 5, 19, 29, 25, 22, 21, 27, 24, 17, 75, 52,241, 42, 16, //e0 - 62,242,243,244, 58,245, 98,246,247,248,249,250,251, 91,252,253, //f0 -}; - -unsigned char win1251BulgarianCharToOrderMap[] = -{ -255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, //00 -255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, //10 -+253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, //20 -252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, //30 -253, 77, 90, 99,100, 72,109,107,101, 79,185, 81,102, 76, 94, 82, //40 -110,186,108, 91, 74,119, 84, 96,111,187,115,253,253,253,253,253, //50 -253, 65, 69, 70, 66, 63, 68,112,103, 92,194,104, 95, 86, 87, 71, //60 -116,195, 85, 93, 97,113,196,197,198,199,200,253,253,253,253,253, //70 -206,207,208,209,210,211,212,213,120,214,215,216,217,218,219,220, //80 -221, 78, 64, 83,121, 98,117,105,222,223,224,225,226,227,228,229, //90 - 88,230,231,232,233,122, 89,106,234,235,236,237,238, 45,239,240, //a0 - 73, 80,118,114,241,242,243,244,245, 62, 58,246,247,248,249,250, //b0 - 31, 32, 35, 43, 37, 44, 55, 47, 40, 59, 33, 46, 38, 36, 41, 30, //c0 - 39, 28, 34, 51, 48, 49, 53, 50, 54, 57, 61,251, 67,252, 60, 56, //d0 - 1, 18, 9, 20, 11, 3, 23, 15, 2, 26, 12, 10, 14, 6, 4, 13, //e0 - 7, 8, 5, 19, 29, 25, 22, 21, 27, 24, 17, 75, 52,253, 42, 16, //f0 -}; - -//Model Table: -//total sequences: 100% -//first 512 sequences: 96.9392% -//first 1024 sequences:3.0618% -//rest sequences: 0.2992% -//negative sequences: 0.0020% -char BulgarianLangModel[] = -{ -0,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,3,3,3,3,3,3,3,3,2,3,3,3,3,3, -3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,0,3,3,3,2,2,3,2,2,1,2,2, -3,1,3,3,2,3,3,3,3,3,3,3,3,3,3,3,3,0,3,3,3,3,3,3,3,3,3,3,0,3,0,1, -0,0,0,0,0,0,0,0,0,0,1,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1, -3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,3,2,3,3,3,3,3,3,3,3,0,3,1,0, -0,1,0,0,0,0,0,0,0,0,1,1,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1, -3,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,1,3,2,3,3,3,3,3,3,3,3,0,3,0,0, -0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -3,2,3,3,2,3,3,3,3,3,3,3,3,3,3,3,3,1,3,2,3,3,3,3,3,3,3,3,0,3,0,0, -0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -3,3,3,3,3,3,3,3,3,3,3,2,3,2,2,1,3,3,3,3,2,2,2,1,1,2,0,1,0,1,0,0, -0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,1, -3,3,3,3,3,3,3,2,3,2,2,3,3,1,1,2,3,3,2,3,3,3,3,2,1,2,0,2,0,3,0,0, -0,0,0,0,0,0,0,1,0,0,2,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,1, -3,3,3,3,3,3,3,1,3,3,3,3,3,2,3,2,3,3,3,3,3,2,3,3,1,3,0,3,0,2,0,0, -0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1, -3,3,3,3,3,3,3,3,1,3,3,2,3,3,3,1,3,3,2,3,2,2,2,0,0,2,0,2,0,2,0,0, -0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,1, -3,3,3,3,3,3,3,3,3,0,3,3,3,2,2,3,3,3,1,2,2,3,2,1,1,2,0,2,0,0,0,0, -1,0,0,0,0,0,0,0,0,0,2,0,0,1,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1, -3,3,3,3,3,3,3,2,3,3,1,2,3,2,2,2,3,3,3,3,3,2,2,3,1,2,0,2,1,2,0,0, -0,0,0,0,0,0,0,0,0,0,3,0,0,1,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,1, -3,3,3,3,3,1,3,3,3,3,3,2,3,3,3,2,3,3,2,3,2,2,2,3,1,2,0,1,0,1,0,0, -0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1, -3,3,3,3,3,3,3,3,3,3,3,1,1,1,2,2,1,3,1,3,2,2,3,0,0,1,0,1,0,1,0,0, -0,0,0,1,0,0,0,0,1,0,2,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1, -3,3,3,3,3,2,2,3,2,2,3,1,2,1,1,1,2,3,1,3,1,2,2,0,1,1,1,1,0,1,0,0, -0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1, -3,3,3,3,3,1,3,2,2,3,3,1,2,3,1,1,3,3,3,3,1,2,2,1,1,1,0,2,0,2,0,1, -0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1, -3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,2,2,3,3,3,2,2,1,1,2,0,2,0,1,0,0, -0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1, -3,0,1,2,1,3,3,2,3,3,3,3,3,2,3,2,1,0,3,1,2,1,2,1,2,3,2,1,0,1,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -1,1,1,2,3,3,3,3,3,3,3,3,3,3,3,3,0,0,3,1,3,3,2,3,3,2,2,2,0,1,0,0, -0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -2,3,3,3,3,0,3,3,3,3,3,2,1,1,2,1,3,3,0,3,1,1,1,1,3,2,0,1,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1, -3,3,2,2,2,3,3,3,3,3,3,3,3,3,3,3,1,1,3,1,3,3,2,3,2,2,2,3,0,2,0,0, -0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -3,3,3,3,3,2,3,3,2,2,3,2,1,1,1,1,1,3,1,3,1,1,0,0,0,1,0,0,0,1,0,0, -0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0, -3,3,3,3,3,2,3,2,0,3,2,0,3,0,2,0,0,2,1,3,1,0,0,1,0,0,0,1,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1, -3,3,3,3,2,1,1,1,1,2,1,1,2,1,1,1,2,2,1,2,1,1,1,0,1,1,0,1,0,1,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1, -3,3,3,3,2,1,3,1,1,2,1,3,2,1,1,0,1,2,3,2,1,1,1,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -2,3,3,3,3,2,2,1,0,1,0,0,1,0,0,0,2,1,0,3,0,0,1,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1, -3,3,3,2,3,2,3,3,1,3,2,1,1,1,2,1,1,2,1,3,0,1,0,0,0,1,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -3,1,1,2,2,3,3,2,3,2,2,2,3,1,2,2,1,1,2,1,1,2,2,0,1,1,0,1,0,2,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -3,3,3,3,2,1,3,1,0,2,2,1,3,2,1,0,0,2,0,2,0,1,0,0,0,0,0,0,0,1,0,0, -0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1, -3,3,3,3,3,3,1,2,0,2,3,1,2,3,2,0,1,3,1,2,1,1,1,0,0,1,0,0,2,2,2,3, -2,2,2,2,1,2,1,1,2,2,1,1,2,0,1,1,1,0,0,1,1,0,0,1,1,0,0,0,1,1,0,1, -3,3,3,3,3,2,1,2,2,1,2,0,2,0,1,0,1,2,1,2,1,1,0,0,0,1,0,1,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,1, -3,3,2,3,3,1,1,3,1,0,3,2,1,0,0,0,1,2,0,2,0,1,0,0,0,1,0,1,2,1,2,2, -1,1,1,1,1,1,1,2,2,2,1,1,1,1,1,1,1,0,1,2,1,1,1,0,0,0,0,0,1,1,0,0, -3,1,0,1,0,2,3,2,2,2,3,2,2,2,2,2,1,0,2,1,2,1,1,1,0,1,2,1,2,2,2,1, -1,1,2,2,2,2,1,2,1,1,0,1,2,1,2,2,2,1,1,1,0,1,1,1,1,2,0,1,0,0,0,0, -2,3,2,3,3,0,0,2,1,0,2,1,0,0,0,0,2,3,0,2,0,0,0,0,0,1,0,0,2,0,1,2, -2,1,2,1,2,2,1,1,1,2,1,1,1,0,1,2,2,1,1,1,1,1,0,1,1,1,0,0,1,2,0,0, -3,3,2,2,3,0,2,3,1,1,2,0,0,0,1,0,0,2,0,2,0,0,0,1,0,1,0,1,2,0,2,2, -1,1,1,1,2,1,0,1,2,2,2,1,1,1,1,1,1,1,0,1,1,1,0,0,0,0,0,0,1,1,0,0, -2,3,2,3,3,0,0,3,0,1,1,0,1,0,0,0,2,2,1,2,0,0,0,0,0,0,0,0,2,0,1,2, -2,2,1,1,1,1,1,2,2,2,1,0,2,0,1,0,1,0,0,1,0,1,0,0,1,0,0,0,0,1,0,0, -3,3,3,3,2,2,2,2,2,0,2,1,1,1,1,2,1,2,1,1,0,2,0,1,0,1,0,0,2,0,1,2, -1,1,1,1,1,1,1,2,2,1,1,0,2,0,1,0,2,0,0,1,1,1,0,0,2,0,0,0,1,1,0,0, -2,3,3,3,3,1,0,0,0,0,0,0,0,0,0,0,2,0,0,1,1,0,0,0,0,0,0,1,2,0,1,2, -2,2,2,1,1,2,1,1,2,2,2,1,2,0,1,1,1,1,1,1,0,1,1,1,1,0,0,1,1,1,0,0, -2,3,3,3,3,0,2,2,0,2,1,0,0,0,1,1,1,2,0,2,0,0,0,3,0,0,0,0,2,0,2,2, -1,1,1,2,1,2,1,1,2,2,2,1,2,0,1,1,1,0,1,1,1,1,0,2,1,0,0,0,1,1,0,0, -2,3,3,3,3,0,2,1,0,0,2,0,0,0,0,0,1,2,0,2,0,0,0,0,0,0,0,0,2,0,1,2, -1,1,1,2,1,1,1,1,2,2,2,0,1,0,1,1,1,0,0,1,1,1,0,0,1,0,0,0,0,1,0,0, -3,3,2,2,3,0,1,0,1,0,0,0,0,0,0,0,1,1,0,3,0,0,0,0,0,0,0,0,1,0,2,2, -1,1,1,1,1,2,1,1,2,2,1,2,2,1,0,1,1,1,1,1,0,1,0,0,1,0,0,0,1,1,0,0, -3,1,0,1,0,2,2,2,2,3,2,1,1,1,2,3,0,0,1,0,2,1,1,0,1,1,1,1,2,1,1,1, -1,2,2,1,2,1,2,2,1,1,0,1,2,1,2,2,1,1,1,0,0,1,1,1,2,1,0,1,0,0,0,0, -2,1,0,1,0,3,1,2,2,2,2,1,2,2,1,1,1,0,2,1,2,2,1,1,2,1,1,0,2,1,1,1, -1,2,2,2,2,2,2,2,1,2,0,1,1,0,2,1,1,1,1,1,0,0,1,1,1,1,0,1,0,0,0,0, -2,1,1,1,1,2,2,2,2,1,2,2,2,1,2,2,1,1,2,1,2,3,2,2,1,1,1,1,0,1,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -2,2,2,3,2,0,1,2,0,1,2,1,1,0,1,0,1,2,1,2,0,0,0,1,1,0,0,0,1,0,0,2, -1,1,0,0,1,1,0,1,1,1,1,0,2,0,1,1,1,0,0,1,1,0,0,0,0,1,0,0,0,1,0,0, -2,0,0,0,0,1,2,2,2,2,2,2,2,1,2,1,1,1,1,1,1,1,0,1,1,1,1,1,2,1,1,1, -1,2,2,2,2,1,1,2,1,2,1,1,1,0,2,1,2,1,1,1,0,2,1,1,1,1,0,1,0,0,0,0, -3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0, -1,1,0,1,0,1,1,1,1,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -2,2,2,3,2,0,0,0,0,1,0,0,0,0,0,0,1,1,0,2,0,0,0,0,0,0,0,0,1,0,1,2, -1,1,1,1,1,1,0,0,2,2,2,2,2,0,1,1,0,1,1,1,1,1,0,0,1,0,0,0,1,1,0,1, -2,3,1,2,1,0,1,1,0,2,2,2,0,0,1,0,0,1,1,1,1,0,0,0,0,0,0,0,1,0,1,2, -1,1,1,1,2,1,1,1,1,1,1,1,1,0,1,1,0,1,0,1,0,1,0,0,1,0,0,0,0,1,0,0, -2,2,2,2,2,0,0,2,0,0,2,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,2,0,2,2, -1,1,1,1,1,0,0,1,2,1,1,0,1,0,1,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0, -1,2,2,2,2,0,0,2,0,1,1,0,0,0,1,0,0,2,0,2,0,0,0,0,0,0,0,0,0,0,1,1, -0,0,0,1,1,1,1,1,1,1,1,1,1,0,1,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0, -1,2,2,3,2,0,0,1,0,0,1,0,0,0,0,0,0,1,0,2,0,0,0,1,0,0,0,0,0,0,0,2, -1,1,0,0,1,0,0,0,1,1,0,0,1,0,1,1,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0, -2,1,2,2,2,1,2,1,2,2,1,1,2,1,1,1,0,1,1,1,1,2,0,1,0,1,1,1,1,0,1,1, -1,1,2,1,1,1,1,1,1,0,0,1,2,1,1,1,1,1,1,0,0,1,1,1,0,0,0,0,0,0,0,0, -1,0,0,1,3,1,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -2,2,2,2,1,0,0,1,0,2,0,0,0,0,0,1,1,1,0,1,0,0,0,0,0,0,0,0,2,0,0,1, -0,2,0,1,0,0,1,1,2,0,1,0,1,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0, -1,2,2,2,2,0,1,1,0,2,1,0,1,1,1,0,0,1,0,2,0,1,0,0,0,0,0,0,0,0,0,1, -0,1,0,0,1,0,0,0,1,1,0,0,1,0,0,1,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0, -2,2,2,2,2,0,0,1,0,0,0,1,0,1,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,1, -0,1,0,1,1,1,0,0,1,1,1,0,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0, -2,0,1,0,0,1,2,1,1,1,1,1,1,2,2,1,0,0,1,0,1,0,0,0,0,1,1,1,1,0,0,0, -1,1,2,1,1,1,1,0,0,0,1,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -2,2,1,2,1,0,0,1,0,0,0,0,0,0,0,0,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,1, -0,0,0,0,0,0,0,0,1,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -1,0,0,1,2,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0, -0,1,1,0,1,1,1,0,0,1,0,0,1,0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0, -1,0,1,0,0,1,1,1,1,1,1,1,1,1,1,1,0,0,1,0,2,0,0,2,0,1,0,0,1,0,0,1, -1,1,0,0,1,1,0,1,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,1,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0, -1,1,1,1,1,1,1,2,0,0,0,0,0,0,2,1,0,1,1,0,0,1,1,1,0,1,0,0,0,0,0,0, -2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,1,0,1,1,1,1,1,0,1,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1, -}; - -SequenceModel Latin5BulgarianModel = -{ - Latin5_BulgarianCharToOrderMap, - BulgarianLangModel, - (float)0.969392, - PR_FALSE, - "ISO-8859-5" -}; - -SequenceModel Win1251BulgarianModel = -{ - win1251BulgarianCharToOrderMap, - BulgarianLangModel, - (float)0.969392, - PR_FALSE, - "windows-1251" -}; - -#pragma GCC visibility pop - diff --git a/amarok/utilities/collectionscanner/charset-detector/src/LangCyrillicModel.cpp b/amarok/utilities/collectionscanner/charset-detector/src/LangCyrillicModel.cpp deleted file mode 100644 index 23ccd3cd..00000000 --- a/amarok/utilities/collectionscanner/charset-detector/src/LangCyrillicModel.cpp +++ /dev/null @@ -1,360 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#pragma GCC visibility push(hidden) - -#include "nsSBCharSetProber.h" - - - -//KOI8-R language model -//Character Mapping Table: -unsigned char KOI8R_CharToOrderMap[] = -{ -255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, //00 -255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, //10 -+253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, //20 -252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, //30 -253,142,143,144,145,146,147,148,149,150,151,152, 74,153, 75,154, //40 -155,156,157,158,159,160,161,162,163,164,165,253,253,253,253,253, //50 -253, 71,172, 66,173, 65,174, 76,175, 64,176,177, 77, 72,178, 69, //60 - 67,179, 78, 73,180,181, 79,182,183,184,185,253,253,253,253,253, //70 -191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206, //80 -207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222, //90 -223,224,225, 68,226,227,228,229,230,231,232,233,234,235,236,237, //a0 -238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253, //b0 - 27, 3, 21, 28, 13, 2, 39, 19, 26, 4, 23, 11, 8, 12, 5, 1, //c0 - 15, 16, 9, 7, 6, 14, 24, 10, 17, 18, 20, 25, 30, 29, 22, 54, //d0 - 59, 37, 44, 58, 41, 48, 53, 46, 55, 42, 60, 36, 49, 38, 31, 34, //e0 - 35, 43, 45, 32, 40, 52, 56, 33, 61, 62, 51, 57, 47, 63, 50, 70, //f0 -}; - -unsigned char win1251_CharToOrderMap[] = -{ -255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, //00 -255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, //10 -+253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, //20 -252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, //30 -253,142,143,144,145,146,147,148,149,150,151,152, 74,153, 75,154, //40 -155,156,157,158,159,160,161,162,163,164,165,253,253,253,253,253, //50 -253, 71,172, 66,173, 65,174, 76,175, 64,176,177, 77, 72,178, 69, //60 - 67,179, 78, 73,180,181, 79,182,183,184,185,253,253,253,253,253, //70 -191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206, -207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222, -223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238, -239,240,241,242,243,244,245,246, 68,247,248,249,250,251,252,253, - 37, 44, 33, 46, 41, 48, 56, 51, 42, 60, 36, 49, 38, 31, 34, 35, - 45, 32, 40, 52, 53, 55, 58, 50, 57, 63, 70, 62, 61, 47, 59, 43, - 3, 21, 10, 19, 13, 2, 24, 20, 4, 23, 11, 8, 12, 5, 1, 15, - 9, 7, 6, 14, 39, 26, 28, 22, 25, 29, 54, 18, 17, 30, 27, 16, -}; - -unsigned char latin5_CharToOrderMap[] = -{ -255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, //00 -255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, //10 -+253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, //20 -252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, //30 -253,142,143,144,145,146,147,148,149,150,151,152, 74,153, 75,154, //40 -155,156,157,158,159,160,161,162,163,164,165,253,253,253,253,253, //50 -253, 71,172, 66,173, 65,174, 76,175, 64,176,177, 77, 72,178, 69, //60 - 67,179, 78, 73,180,181, 79,182,183,184,185,253,253,253,253,253, //70 -191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206, -207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222, -223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238, - 37, 44, 33, 46, 41, 48, 56, 51, 42, 60, 36, 49, 38, 31, 34, 35, - 45, 32, 40, 52, 53, 55, 58, 50, 57, 63, 70, 62, 61, 47, 59, 43, - 3, 21, 10, 19, 13, 2, 24, 20, 4, 23, 11, 8, 12, 5, 1, 15, - 9, 7, 6, 14, 39, 26, 28, 22, 25, 29, 54, 18, 17, 30, 27, 16, -239, 68,240,241,242,243,244,245,246,247,248,249,250,251,252,255, -}; - -unsigned char macCyrillic_CharToOrderMap[] = -{ -255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, //00 -255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, //10 -+253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, //20 -252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, //30 -253,142,143,144,145,146,147,148,149,150,151,152, 74,153, 75,154, //40 -155,156,157,158,159,160,161,162,163,164,165,253,253,253,253,253, //50 -253, 71,172, 66,173, 65,174, 76,175, 64,176,177, 77, 72,178, 69, //60 - 67,179, 78, 73,180,181, 79,182,183,184,185,253,253,253,253,253, //70 - 37, 44, 33, 46, 41, 48, 56, 51, 42, 60, 36, 49, 38, 31, 34, 35, - 45, 32, 40, 52, 53, 55, 58, 50, 57, 63, 70, 62, 61, 47, 59, 43, -191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206, -207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222, -223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238, -239,240,241,242,243,244,245,246,247,248,249,250,251,252, 68, 16, - 3, 21, 10, 19, 13, 2, 24, 20, 4, 23, 11, 8, 12, 5, 1, 15, - 9, 7, 6, 14, 39, 26, 28, 22, 25, 29, 54, 18, 17, 30, 27,255, -}; - -unsigned char IBM855_CharToOrderMap[] = -{ -255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, //00 -255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, //10 -+253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, //20 -252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, //30 -253,142,143,144,145,146,147,148,149,150,151,152, 74,153, 75,154, //40 -155,156,157,158,159,160,161,162,163,164,165,253,253,253,253,253, //50 -253, 71,172, 66,173, 65,174, 76,175, 64,176,177, 77, 72,178, 69, //60 - 67,179, 78, 73,180,181, 79,182,183,184,185,253,253,253,253,253, //70 -191,192,193,194, 68,195,196,197,198,199,200,201,202,203,204,205, -206,207,208,209,210,211,212,213,214,215,216,217, 27, 59, 54, 70, - 3, 37, 21, 44, 28, 58, 13, 41, 2, 48, 39, 53, 19, 46,218,219, -220,221,222,223,224, 26, 55, 4, 42,225,226,227,228, 23, 60,229, -230,231,232,233,234,235, 11, 36,236,237,238,239,240,241,242,243, - 8, 49, 12, 38, 5, 31, 1, 34, 15,244,245,246,247, 35, 16,248, - 43, 9, 45, 7, 32, 6, 40, 14, 52, 24, 56, 10, 33, 17, 61,249, -250, 18, 62, 20, 51, 25, 57, 30, 47, 29, 63, 22, 50,251,252,255, -}; - -unsigned char IBM866_CharToOrderMap[] = -{ -255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, //00 -255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, //10 -+253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, //20 -252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, //30 -253,142,143,144,145,146,147,148,149,150,151,152, 74,153, 75,154, //40 -155,156,157,158,159,160,161,162,163,164,165,253,253,253,253,253, //50 -253, 71,172, 66,173, 65,174, 76,175, 64,176,177, 77, 72,178, 69, //60 - 67,179, 78, 73,180,181, 79,182,183,184,185,253,253,253,253,253, //70 - 37, 44, 33, 46, 41, 48, 56, 51, 42, 60, 36, 49, 38, 31, 34, 35, - 45, 32, 40, 52, 53, 55, 58, 50, 57, 63, 70, 62, 61, 47, 59, 43, - 3, 21, 10, 19, 13, 2, 24, 20, 4, 23, 11, 8, 12, 5, 1, 15, -191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206, -207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222, -223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238, - 9, 7, 6, 14, 39, 26, 28, 22, 25, 29, 54, 18, 17, 30, 27, 16, -239, 68,240,241,242,243,244,245,246,247,248,249,250,251,252,255, -}; - -//Model Table: -//total sequences: 100% -//first 512 sequences: 97.6601% -//first 1024 sequences: 2.3389% -//rest sequences: 0.1237% -//negative sequences: 0.0009% -char RussianLangModel[] = -{ -0,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,1,3,3,3,3,1,3,3,3,2,3,2,3,3, -3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,0,3,2,2,2,2,2,0,0,2, -3,3,3,2,3,3,3,3,3,3,3,3,3,3,2,3,3,0,0,3,3,3,3,3,3,3,3,3,2,3,2,0, -0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -3,3,3,2,2,3,3,3,3,3,3,3,3,3,2,3,3,0,0,3,3,3,3,3,3,3,3,2,3,3,1,0, -0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -3,2,3,2,3,3,3,3,3,3,3,3,3,3,3,3,3,0,0,3,3,3,3,3,3,3,3,3,3,3,2,1, -0,0,0,0,0,0,0,2,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,3,3,0,0,3,3,3,3,3,3,3,3,3,3,3,2,1, -0,0,0,0,0,1,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -3,3,3,3,3,3,3,3,2,2,2,3,1,3,3,1,3,3,3,3,2,2,3,0,2,2,2,3,3,2,1,0, -0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0, -3,3,3,3,3,3,2,3,3,3,3,3,2,2,3,2,3,3,3,2,1,2,2,0,1,2,2,2,2,2,2,0, -0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0, -3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,3,0,2,2,3,3,2,1,2,0, -0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,1,0,0,2,0,0,0,0,0,0,0,0,0, -3,3,3,3,3,3,2,3,3,1,2,3,2,2,3,2,3,3,3,3,2,2,3,0,3,2,2,3,1,1,1,0, -0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -3,3,3,3,3,3,3,3,2,2,3,3,3,3,3,2,3,3,3,3,2,2,2,0,3,3,3,2,2,2,2,0, -0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -3,3,3,3,3,3,3,3,3,3,2,3,2,3,3,3,3,3,3,2,3,2,2,0,1,3,2,1,2,2,1,0, -0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0, -3,3,3,3,3,3,3,3,3,3,3,2,1,1,3,0,1,1,1,1,2,1,1,0,2,2,2,1,2,0,1,0, -0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -3,3,3,3,3,3,2,3,3,2,2,2,2,1,3,2,3,2,3,2,1,2,2,0,1,1,2,1,2,1,2,0, -0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -3,3,3,3,3,3,3,3,3,3,3,3,2,2,3,2,3,3,3,2,2,2,2,0,2,2,2,2,3,1,1,0, -0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0, -3,2,3,2,2,3,3,3,3,3,3,3,3,3,1,3,2,0,0,3,3,3,3,2,3,3,3,3,2,3,2,0, -0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -2,3,3,3,3,3,2,2,3,3,0,2,1,0,3,2,3,2,3,0,0,1,2,0,0,1,0,1,2,1,1,0, -0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -3,0,3,0,2,3,3,3,3,2,3,3,3,3,1,2,2,0,0,2,3,2,2,2,3,2,3,2,2,3,0,0, -0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -3,2,3,0,2,3,2,3,0,1,2,3,3,2,0,2,3,0,0,2,3,2,2,0,1,3,1,3,2,2,1,0, -0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -3,1,3,0,2,3,3,3,3,3,3,3,3,2,1,3,2,0,0,2,2,3,3,3,2,3,3,0,2,2,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -3,3,3,3,3,3,2,2,3,3,2,2,2,3,3,0,0,1,1,1,1,1,2,0,0,1,1,1,1,0,1,0, -0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -3,3,3,3,3,3,2,2,3,3,3,3,3,3,3,0,3,2,3,3,2,3,2,0,2,1,0,1,1,0,1,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0, -3,3,3,3,3,3,2,3,3,3,2,2,2,2,3,1,3,2,3,1,1,2,1,0,2,2,2,2,1,3,1,0, -0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0, -2,2,3,3,3,3,3,1,2,2,1,3,1,0,3,0,0,3,0,0,0,1,1,0,1,2,1,0,0,0,0,0, -0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -3,2,2,1,1,3,3,3,2,2,1,2,2,3,1,1,2,0,0,2,2,1,3,0,0,2,1,1,2,1,1,0, -0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -3,2,3,3,3,3,1,2,2,2,1,2,1,3,3,1,1,2,1,2,1,2,2,0,2,0,0,1,1,0,1,0, -0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -2,3,3,3,3,3,2,1,3,2,2,3,2,0,3,2,0,3,0,1,0,1,1,0,0,1,1,1,1,0,1,0, -0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -3,3,2,3,3,3,2,2,2,3,3,1,2,1,2,1,0,1,0,1,1,0,1,0,0,2,1,1,1,0,1,0, -0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0, -3,1,1,2,1,2,3,3,2,2,1,2,2,3,0,2,1,0,0,2,2,3,2,1,2,2,2,2,2,3,1,0, -0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -3,3,3,3,3,1,1,0,1,1,2,2,1,1,3,0,0,1,3,1,1,1,0,0,0,1,0,1,1,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -2,1,3,3,3,2,0,0,0,2,1,0,1,0,2,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -2,0,1,0,0,2,3,2,2,2,1,2,2,2,1,2,1,0,0,1,1,1,0,2,0,1,1,1,0,0,1,1, -1,0,0,0,0,0,1,2,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0, -2,3,3,3,3,0,0,0,0,1,0,0,0,0,3,0,1,2,1,0,0,0,0,0,0,0,1,1,0,0,1,1, -1,0,1,0,1,2,0,0,1,1,2,1,0,1,1,1,1,0,1,1,1,1,0,1,0,0,1,0,0,1,1,0, -2,2,3,2,2,2,3,1,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,0,1,0,1,1,1,0,2,1, -1,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,0,1,0,1,1,0,1,1,1,0,1,1,0, -3,3,3,2,2,2,2,3,2,2,1,1,2,2,2,2,1,1,3,1,2,1,2,0,0,1,1,0,1,0,2,1, -1,1,1,1,1,2,1,0,1,1,1,1,0,1,0,0,1,1,0,0,1,0,1,0,0,1,0,0,0,1,1,0, -2,0,0,1,0,3,2,2,2,2,1,2,1,2,1,2,0,0,0,2,1,2,2,1,1,2,2,0,1,1,0,2, -1,1,1,1,1,0,1,1,1,2,1,1,1,2,1,0,1,2,1,1,1,1,0,1,1,1,0,0,1,0,0,1, -1,3,2,2,2,1,1,1,2,3,0,0,0,0,2,0,2,2,1,0,0,0,0,0,0,1,0,0,0,0,1,1, -1,0,1,1,0,1,0,1,1,0,1,1,0,2,0,0,1,1,0,0,1,0,0,0,0,0,0,0,0,1,1,0, -2,3,2,3,2,1,2,2,2,2,1,0,0,0,2,0,0,1,1,0,0,0,0,0,0,0,1,1,0,0,2,1, -1,1,2,1,0,2,0,0,1,0,1,0,0,1,0,0,1,1,0,1,1,0,0,0,0,0,1,0,0,0,0,0, -3,0,0,1,0,2,2,2,3,2,2,2,2,2,2,2,0,0,0,2,1,2,1,1,1,2,2,0,0,0,1,2, -1,1,1,1,1,0,1,2,1,1,1,1,1,1,1,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0,0,1, -2,3,2,3,3,2,0,1,1,1,0,0,1,0,2,0,1,1,3,1,0,0,0,0,0,0,0,1,0,0,2,1, -1,1,1,1,1,1,1,0,1,0,1,1,1,1,0,1,1,1,0,0,1,1,0,1,0,0,0,0,0,0,1,0, -2,3,3,3,3,1,2,2,2,2,0,1,1,0,2,1,1,1,2,1,0,1,1,0,0,1,0,1,0,0,2,0, -0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -2,3,3,3,2,0,0,1,1,2,2,1,0,0,2,0,1,1,3,0,0,1,0,0,0,0,0,1,0,1,2,1, -1,1,2,0,1,1,1,0,1,0,1,1,0,1,0,1,1,1,1,0,1,0,0,0,0,0,0,1,0,1,1,0, -1,3,2,3,2,1,0,0,2,2,2,0,1,0,2,0,1,1,1,0,1,0,0,0,3,0,1,1,0,0,2,1, -1,1,1,0,1,1,0,0,0,0,1,1,0,1,0,0,2,1,1,0,1,0,0,0,1,0,1,0,0,1,1,0, -3,1,2,1,1,2,2,2,2,2,2,1,2,2,1,1,0,0,0,2,2,2,0,0,0,1,2,1,0,1,0,1, -2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,2,1,1,1,0,1,0,1,1,0,1,1,1,0,0,1, -3,0,0,0,0,2,0,1,1,1,1,1,1,1,0,1,0,0,0,1,1,1,0,1,0,1,1,0,0,1,0,1, -1,1,0,0,1,0,0,0,1,0,1,1,0,0,1,0,1,0,1,0,0,0,0,1,0,0,0,1,0,0,0,1, -1,3,3,2,2,0,0,0,2,2,0,0,0,1,2,0,1,1,2,0,0,0,0,0,0,0,0,1,0,0,2,1, -0,1,1,0,0,1,1,0,0,0,1,1,0,1,1,0,1,1,0,0,1,0,0,0,0,0,0,0,0,0,1,0, -2,3,2,3,2,0,0,0,0,1,1,0,0,0,2,0,2,0,2,0,0,0,0,0,1,0,0,1,0,0,1,1, -1,1,2,0,1,2,1,0,1,1,2,1,1,1,1,1,2,1,1,0,1,0,0,1,1,1,1,1,0,1,1,0, -1,3,2,2,2,1,0,0,2,2,1,0,1,2,2,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,1,1, -0,0,1,1,0,1,1,0,0,1,1,0,1,1,0,0,1,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0, -1,0,0,1,0,2,3,1,2,2,2,2,2,2,1,1,0,0,0,1,0,1,0,2,1,1,1,0,0,0,0,1, -1,1,0,1,1,0,1,1,1,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0, -2,0,2,0,0,1,0,3,2,1,2,1,2,2,0,1,0,0,0,2,1,0,0,2,1,1,1,1,0,2,0,2, -2,1,1,1,1,1,1,1,1,1,1,1,1,2,1,0,1,1,1,1,0,0,0,1,1,1,1,0,1,0,0,1, -1,2,2,2,2,1,0,0,1,0,0,0,0,0,2,0,1,1,1,1,0,0,0,0,1,0,1,2,0,0,2,0, -1,0,1,1,1,2,1,0,1,0,1,1,0,0,1,0,1,1,1,0,1,0,0,0,1,0,0,1,0,1,1,0, -2,1,2,2,2,0,3,0,1,1,0,0,0,0,2,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1, -0,0,0,1,1,1,0,0,1,0,1,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0, -1,2,2,3,2,2,0,0,1,1,2,0,1,2,1,0,1,0,1,0,0,1,0,0,0,0,0,0,0,0,0,1, -0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,1,1,0,0,1,0,0,0,0,0,0,0,0,1,1,0, -2,2,1,1,2,1,2,2,2,2,2,1,2,2,0,1,0,0,0,1,2,2,2,1,2,1,1,1,1,1,2,1, -1,1,1,1,1,1,1,1,1,1,0,0,1,1,1,0,1,1,1,0,0,0,0,1,1,1,0,1,1,0,0,1, -1,2,2,2,2,0,1,0,2,2,0,0,0,0,2,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,2,0, -0,0,1,0,0,1,0,0,0,0,1,0,1,1,0,0,1,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0, -0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -1,2,2,2,2,0,0,0,2,2,2,0,1,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1, -0,1,1,0,0,1,1,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -1,2,2,2,2,0,0,0,0,1,0,0,1,1,2,0,0,0,0,1,0,1,0,0,1,0,0,2,0,0,0,1, -0,0,1,0,0,1,0,0,0,1,1,0,0,0,0,0,1,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0, -1,2,2,2,1,1,2,0,2,1,1,1,1,0,2,2,0,0,0,0,0,0,0,0,0,1,1,0,0,0,1,1, -0,0,1,0,1,1,0,0,0,0,1,0,0,0,0,0,1,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0, -1,0,2,1,2,0,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0, -0,0,1,0,1,1,0,0,0,0,1,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0, -1,0,0,0,0,2,0,1,2,1,0,1,1,1,0,1,0,0,0,1,0,1,0,0,1,0,1,0,0,0,0,1, -0,0,0,0,0,1,0,0,1,1,0,0,1,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1, -2,2,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1, -1,0,0,0,1,0,0,0,1,1,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,1,0,0,0,0,0, -2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1, -1,1,1,0,1,0,1,0,0,1,1,1,1,0,0,0,1,0,0,0,0,1,0,0,0,1,0,1,0,0,0,0, -1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1, -1,1,0,1,1,0,1,0,1,0,0,0,0,1,1,0,1,1,0,0,0,0,0,1,0,1,1,0,1,0,0,0, -0,1,1,1,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0, -}; - - -SequenceModel Koi8rModel = -{ - KOI8R_CharToOrderMap, - RussianLangModel, - (float)0.976601, - PR_FALSE, - "KOI8-R" -}; - -SequenceModel Win1251Model = -{ - win1251_CharToOrderMap, - RussianLangModel, - (float)0.976601, - PR_FALSE, - "windows-1251" -}; - -SequenceModel Latin5Model = -{ - latin5_CharToOrderMap, - RussianLangModel, - (float)0.976601, - PR_FALSE, - "ISO-8859-5" -}; - -SequenceModel MacCyrillicModel = -{ - macCyrillic_CharToOrderMap, - RussianLangModel, - (float)0.976601, - PR_FALSE, - "x-mac-cyrillic" -}; - -SequenceModel Ibm866Model = -{ - IBM866_CharToOrderMap, - RussianLangModel, - (float)0.976601, - PR_FALSE, - "IBM866" -}; - -SequenceModel Ibm855Model = -{ - IBM855_CharToOrderMap, - RussianLangModel, - (float)0.976601, - PR_FALSE, - "IBM855" -}; - -#pragma GCC visibility pop - diff --git a/amarok/utilities/collectionscanner/charset-detector/src/LangGreekModel.cpp b/amarok/utilities/collectionscanner/charset-detector/src/LangGreekModel.cpp deleted file mode 100644 index 64817f90..00000000 --- a/amarok/utilities/collectionscanner/charset-detector/src/LangGreekModel.cpp +++ /dev/null @@ -1,249 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#pragma GCC visibility push(hidden) - -#include "nsSBCharSetProber.h" -/**************************************************************** -255: Control characters that usually does not exist in any text -254: Carriage/Return -253: symbol (punctuation) that does not belong to word -252: 0 - 9 - -*****************************************************************/ - -//Character Mapping Table: -unsigned char Latin7_CharToOrderMap[] = -{ -255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, //00 -255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, //10 -+253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, //20 -252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, //30 -253, 82,100,104, 94, 98,101,116,102,111,187,117, 92, 88,113, 85, //40 - 79,118,105, 83, 67,114,119, 95, 99,109,188,253,253,253,253,253, //50 -253, 72, 70, 80, 81, 60, 96, 93, 89, 68,120, 97, 77, 86, 69, 55, //60 - 78,115, 65, 66, 58, 76,106,103, 87,107,112,253,253,253,253,253, //70 -255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, //80 -255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, //90 -+253,233, 90,253,253,253,253,253,253,253,253,253,253, 74,253,253, //a0 -253,253,253,253,247,248, 61, 36, 46, 71, 73,253, 54,253,108,123, //b0 -110, 31, 51, 43, 41, 34, 91, 40, 52, 47, 44, 53, 38, 49, 59, 39, //c0 - 35, 48,250, 37, 33, 45, 56, 50, 84, 57,120,121, 17, 18, 22, 15, //d0 -124, 1, 29, 20, 21, 3, 32, 13, 25, 5, 11, 16, 10, 6, 30, 4, //e0 - 9, 8, 14, 7, 2, 12, 28, 23, 42, 24, 64, 75, 19, 26, 27,253, //f0 -}; - - - -unsigned char win1253_CharToOrderMap[] = -{ -255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, //00 -255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, //10 -+253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, //20 -252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, //30 -253, 82,100,104, 94, 98,101,116,102,111,187,117, 92, 88,113, 85, //40 - 79,118,105, 83, 67,114,119, 95, 99,109,188,253,253,253,253,253, //50 -253, 72, 70, 80, 81, 60, 96, 93, 89, 68,120, 97, 77, 86, 69, 55, //60 - 78,115, 65, 66, 58, 76,106,103, 87,107,112,253,253,253,253,253, //70 -255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, //80 -255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, //90 -+253,233, 61,253,253,253,253,253,253,253,253,253,253, 74,253,253, //a0 -253,253,253,253,247,253,253, 36, 46, 71, 73,253, 54,253,108,123, //b0 -110, 31, 51, 43, 41, 34, 91, 40, 52, 47, 44, 53, 38, 49, 59, 39, //c0 - 35, 48,250, 37, 33, 45, 56, 50, 84, 57,120,121, 17, 18, 22, 15, //d0 -124, 1, 29, 20, 21, 3, 32, 13, 25, 5, 11, 16, 10, 6, 30, 4, //e0 - 9, 8, 14, 7, 2, 12, 28, 23, 42, 24, 64, 75, 19, 26, 27,253, //f0 -}; - -//Model Table: -//total sequences: 100% -//first 512 sequences: 98.2851% -//first 1024 sequences:1.7001% -//rest sequences: 0.0359% -//negative sequences: 0.0148% -char GreekLangModel[] = -{ -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,3,2,2,3,3,3,3,3,3,3,3,1,3,3,3,0,2,2,3,3,0,3,0,3,2,0,3,3,3,0, -3,0,0,0,2,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,3,3,3,3,3,0,3,3,0,3,2,3,3,0,3,2,3,3,3,0,0,3,0,3,0,3,3,2,0,0,0, -2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0, -0,2,3,2,2,3,3,3,3,3,3,3,3,0,3,3,3,3,0,2,3,3,0,3,3,3,3,2,3,3,3,0, -2,0,0,0,2,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,2,3,3,2,3,3,3,3,3,3,3,3,3,3,3,3,0,2,1,3,3,3,3,2,3,3,2,3,3,2,0, -0,0,0,0,2,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,3,3,3,3,0,3,3,3,3,3,3,0,3,3,0,3,3,3,3,3,3,3,3,3,3,0,3,2,3,3,0, -2,0,1,0,2,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0, -0,3,3,3,3,3,2,3,0,0,0,0,3,3,0,3,1,3,3,3,0,3,3,0,3,3,3,3,0,0,0,0, -2,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,3,3,3,3,3,0,3,0,3,3,3,3,3,0,3,2,2,2,3,0,2,3,3,3,3,3,2,3,3,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,3,3,3,3,3,3,2,2,2,3,3,3,3,0,3,1,3,3,3,3,2,3,3,3,3,3,3,3,2,2,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,3,3,3,3,3,2,0,3,0,0,0,3,3,2,3,3,3,3,3,0,0,3,2,3,0,2,3,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,3,0,3,3,3,3,0,0,3,3,0,2,3,0,3,0,3,3,3,0,0,3,0,3,0,2,2,3,3,0,0, -0,0,1,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,3,3,3,3,3,2,0,3,2,3,3,3,3,0,3,3,3,3,3,0,3,3,2,3,2,3,3,2,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,3,3,2,3,2,3,3,3,3,3,3,0,2,3,2,3,2,2,2,3,2,3,3,2,3,0,2,2,2,3,0, -2,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,3,0,0,0,3,3,3,2,3,3,0,0,3,0,3,0,0,0,3,2,0,3,0,3,0,0,2,0,2,0, -0,0,0,0,2,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,3,3,3,3,0,3,3,3,3,3,3,0,3,3,0,3,0,0,0,3,3,0,3,3,3,0,0,1,2,3,0, -3,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,3,3,3,3,3,2,0,0,3,2,2,3,3,0,3,3,3,3,3,2,1,3,0,3,2,3,3,2,1,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,3,3,0,2,3,3,3,3,3,3,0,0,3,0,3,0,0,0,3,3,0,3,2,3,0,0,3,3,3,0, -3,0,0,0,2,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,3,3,3,3,0,3,3,3,3,3,3,0,0,3,0,3,0,0,0,3,2,0,3,2,3,0,0,3,2,3,0, -2,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,3,1,2,2,3,3,3,3,3,3,0,2,3,0,3,0,0,0,3,3,0,3,0,2,0,0,2,3,1,0, -2,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,3,0,3,3,3,3,0,3,0,3,3,2,3,0,3,3,3,3,3,3,0,3,3,3,0,2,3,0,0,3,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,3,0,3,3,3,0,0,3,0,0,0,3,3,0,3,0,2,3,3,0,0,3,0,3,0,3,3,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,3,0,0,0,3,3,3,3,3,3,0,0,3,0,2,0,0,0,3,3,0,3,0,3,0,0,2,0,2,0, -0,0,0,0,1,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,3,3,3,3,3,3,0,3,0,2,0,3,2,0,3,2,3,2,3,0,0,3,2,3,2,3,3,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,3,0,0,2,3,3,3,3,3,0,0,0,3,0,2,1,0,0,3,2,2,2,0,3,0,0,2,2,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,3,0,3,3,3,2,0,3,0,3,0,3,3,0,2,1,2,3,3,0,0,3,0,3,0,3,3,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,2,3,3,3,0,3,3,3,3,3,3,0,2,3,0,3,0,0,0,2,1,0,2,2,3,0,0,2,2,2,0, -0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,3,0,0,2,3,3,3,2,3,0,0,1,3,0,2,0,0,0,0,3,0,1,0,2,0,0,1,1,1,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,3,3,3,3,3,1,0,3,0,0,0,3,2,0,3,2,3,3,3,0,0,3,0,3,2,2,2,1,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,3,0,3,3,3,0,0,3,0,0,0,0,2,0,2,3,3,2,2,2,2,3,0,2,0,2,2,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,3,3,3,3,2,0,0,0,0,0,0,2,3,0,2,0,2,3,2,0,0,3,0,3,0,3,1,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,3,2,3,3,2,2,3,0,2,0,3,0,0,0,2,0,0,0,0,1,2,0,2,0,2,0, -0,2,0,2,0,2,2,0,0,1,0,2,2,2,0,2,2,2,0,2,2,2,0,0,2,0,0,1,0,0,0,0, -0,2,0,3,3,2,0,0,0,0,0,0,1,3,0,2,0,2,2,2,0,0,2,0,3,0,0,2,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,3,0,2,3,2,0,2,2,0,2,0,2,2,0,2,0,2,2,2,0,0,0,0,0,0,2,3,0,0,0,2, -0,1,2,0,0,0,0,2,2,0,0,0,2,1,0,2,2,0,0,0,0,0,0,1,0,2,0,0,0,0,0,0, -0,0,2,1,0,2,3,2,2,3,2,3,2,0,0,3,3,3,0,0,3,2,0,0,0,1,1,0,2,0,2,2, -0,2,0,2,0,2,2,0,0,2,0,2,2,2,0,2,2,2,2,0,0,2,0,0,0,2,0,1,0,0,0,0, -0,3,0,3,3,2,2,0,3,0,0,0,2,2,0,2,2,2,1,2,0,0,1,2,2,0,0,3,0,0,0,2, -0,1,2,0,0,0,1,2,0,0,0,0,0,0,0,2,2,0,1,0,0,2,0,0,0,2,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,2,3,3,2,2,0,0,0,2,0,2,3,3,0,2,0,0,0,0,0,0,2,2,2,0,2,2,0,2,0,2, -0,2,2,0,0,2,2,2,2,1,0,0,2,2,0,2,0,0,2,0,0,0,0,0,0,2,0,0,0,0,0,0, -0,2,0,3,2,3,0,0,0,3,0,0,2,2,0,2,0,2,2,2,0,0,2,0,0,0,0,0,0,0,0,2, -0,0,2,2,0,0,2,2,2,0,0,0,0,0,0,2,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,2,0,0,3,2,0,2,2,2,2,2,0,0,0,2,0,0,0,0,2,0,1,0,0,2,0,1,0,0,0, -0,2,2,2,0,2,2,0,1,2,0,2,2,2,0,2,2,2,2,1,2,2,0,0,2,0,0,0,0,0,0,0, -0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0, -0,2,0,2,0,2,2,0,0,0,0,1,2,1,0,0,2,2,0,0,2,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,3,2,3,0,0,2,0,0,0,2,2,0,2,0,0,0,1,0,0,2,0,2,0,2,2,0,0,0,0, -0,0,2,0,0,0,0,2,2,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0, -0,2,2,3,2,2,0,0,0,0,0,0,1,3,0,2,0,2,2,0,0,0,1,0,2,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,2,0,2,0,3,2,0,2,0,0,0,0,0,0,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1, -0,0,2,0,0,0,0,1,1,0,0,2,1,2,0,2,2,0,1,0,0,1,0,0,0,2,0,0,0,0,0,0, -0,3,0,2,2,2,0,0,2,0,0,0,2,0,0,0,2,3,0,2,0,0,0,0,0,0,2,2,0,0,0,2, -0,1,2,0,0,0,1,2,2,1,0,0,0,2,0,0,2,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,2,1,2,0,2,2,0,2,0,0,2,0,0,0,0,1,2,1,0,2,1,0,0,0,0,0,0,0,0,0,0, -0,0,2,0,0,0,3,1,2,2,0,2,0,0,0,0,2,0,0,0,2,0,0,3,0,0,0,0,2,2,2,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,2,1,0,2,0,1,2,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,1,0,0,0,0,0,0,2, -0,2,2,0,0,2,2,2,2,2,0,1,2,0,0,0,2,2,0,1,0,2,0,0,2,2,0,0,0,0,0,0, -0,0,0,0,1,0,0,0,0,0,0,0,3,0,0,2,0,0,0,0,0,0,0,0,2,0,2,0,0,0,0,2, -0,1,2,0,0,0,0,2,2,1,0,1,0,1,0,2,2,2,1,0,0,0,0,0,0,1,0,0,0,0,0,0, -0,2,0,1,2,0,0,0,0,0,0,0,0,0,0,2,0,0,2,2,0,0,0,0,1,0,0,0,0,0,0,2, -0,2,2,0,0,0,0,2,2,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,2,0,0,2,0,0,0, -0,2,2,2,2,0,0,0,3,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,2,0,0,0,0,0,0,1, -0,0,2,0,0,0,0,1,2,0,0,0,0,0,0,2,2,1,1,0,0,0,0,0,0,1,0,0,0,0,0,0, -0,2,0,2,2,2,0,0,2,0,0,0,0,0,0,0,2,2,2,0,0,0,2,0,0,0,0,0,0,0,0,2, -0,0,1,0,0,0,0,2,1,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0, -0,3,0,2,0,0,0,0,0,0,0,0,2,0,0,0,0,0,2,0,0,0,0,0,0,0,2,0,0,0,0,2, -0,0,2,0,0,0,0,2,2,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,2,0,2,2,1,0,0,0,0,0,0,2,0,0,2,0,2,2,2,0,0,0,0,0,0,2,0,0,0,0,2, -0,0,2,0,0,2,0,2,2,0,0,0,0,2,0,2,0,0,0,0,0,2,0,0,0,2,0,0,0,0,0,0, -0,0,3,0,0,0,2,2,0,2,2,0,0,0,0,0,2,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,2,0,0,0,0,0, -0,2,2,2,2,2,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,1, -0,0,0,0,0,0,0,2,1,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,2,2,0,0,0,0,0,2,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0, -0,2,0,0,0,2,0,0,0,0,0,1,0,0,0,0,2,2,0,0,0,1,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,2,0,0,0, -0,2,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,1,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,2,0,2,0,0,0, -0,0,0,0,0,0,0,0,2,1,0,0,0,0,0,0,2,0,0,0,1,2,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -}; - -SequenceModel Latin7Model = -{ - Latin7_CharToOrderMap, - GreekLangModel, - (float)0.982851, - PR_FALSE, - "ISO-8859-7" -}; - -SequenceModel Win1253Model = -{ - win1253_CharToOrderMap, - GreekLangModel, - (float)0.982851, - PR_FALSE, - "windows-1253" -}; - -#pragma GCC visibility pop - diff --git a/amarok/utilities/collectionscanner/charset-detector/src/LangHebrewModel.cpp b/amarok/utilities/collectionscanner/charset-detector/src/LangHebrewModel.cpp deleted file mode 100644 index ce2fbec6..00000000 --- a/amarok/utilities/collectionscanner/charset-detector/src/LangHebrewModel.cpp +++ /dev/null @@ -1,222 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Universal charset detector code. - * - * The Initial Developer of the Original Code is - * Simon Montagu - * Portions created by the Initial Developer are Copyright (C) 2005 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Shoshannah Forbes - * Shy Shalom - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#pragma GCC visibility push(hidden) - -#include "nsSBCharSetProber.h" - - -/**************************************************************** -255: Control characters that usually does not exist in any text -254: Carriage/Return -253: symbol (punctuation) that does not belong to word -252: 0 - 9 - -*****************************************************************/ - -//Windows-1255 language model -//Character Mapping Table: -unsigned char win1255_CharToOrderMap[] = -{ -255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, //00 -255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, //10 -+253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, //20 -252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, //30 -253, 69, 91, 79, 80, 92, 89, 97, 90, 68,111,112, 82, 73, 95, 85, //40 - 78,121, 86, 71, 67,102,107, 84,114,103,115,253,253,253,253,253, //50 -253, 50, 74, 60, 61, 42, 76, 70, 64, 53,105, 93, 56, 65, 54, 49, //60 - 66,110, 51, 43, 44, 63, 81, 77, 98, 75,108,253,253,253,253,253, //70 -124,202,203,204,205, 40, 58,206,207,208,209,210,211,212,213,214, -215, 83, 52, 47, 46, 72, 32, 94,216,113,217,109,218,219,220,221, - 34,116,222,118,100,223,224,117,119,104,125,225,226, 87, 99,227, -106,122,123,228, 55,229,230,101,231,232,120,233, 48, 39, 57,234, - 30, 59, 41, 88, 33, 37, 36, 31, 29, 35,235, 62, 28,236,126,237, -238, 38, 45,239,240,241,242,243,127,244,245,246,247,248,249,250, - 9, 8, 20, 16, 3, 2, 24, 14, 22, 1, 25, 15, 4, 11, 6, 23, - 12, 19, 13, 26, 18, 27, 21, 17, 7, 10, 5,251,252,128, 96,253, -}; - -//Model Table: -//total sequences: 100% -//first 512 sequences: 98.4004% -//first 1024 sequences: 1.5981% -//rest sequences: 0.087% -//negative sequences: 0.0015% -char HebrewLangModel[] = -{ -0,3,3,3,3,3,3,3,3,3,3,2,3,3,3,3,3,3,3,3,3,3,3,2,3,2,1,2,0,1,0,0, -3,0,3,1,0,0,1,3,2,0,1,1,2,0,2,2,2,1,1,1,1,2,1,1,1,2,0,0,2,2,0,1, -3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2, -1,2,1,2,1,2,0,0,2,0,0,0,0,0,1,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,1,0, -3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2, -1,2,1,3,1,1,0,0,2,0,0,0,1,0,1,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0, -3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,0,1,2,2,1,3, -1,2,1,1,2,2,0,0,2,2,0,0,0,0,1,0,1,0,0,0,1,0,0,0,0,0,0,1,0,1,1,0, -3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,3,3,2,2,2,2,3,2, -1,2,1,2,2,2,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,1,0, -3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,3,3,2,3,2,2,3,2,2,2,1,2,2,2,2, -1,2,1,1,2,2,0,1,2,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0, -3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,0,2,2,2,2,2, -0,2,0,2,2,2,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,1,0, -3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,3,0,2,2,2, -0,2,1,2,2,2,0,0,2,1,0,0,0,0,1,0,1,0,0,0,0,0,0,2,0,0,0,0,0,0,1,0, -3,3,3,3,3,3,3,3,3,3,3,2,3,3,3,3,3,3,3,3,3,3,3,3,3,2,1,2,3,2,2,2, -1,2,1,2,2,2,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,1,0, -3,3,3,3,3,3,3,3,3,2,3,3,3,2,3,3,3,3,3,3,3,3,3,3,3,3,3,1,0,2,0,2, -0,2,1,2,2,2,0,0,1,2,0,0,0,0,1,0,1,0,0,0,0,0,0,1,0,0,0,2,0,0,1,0, -3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,3,2,3,2,2,3,2,1,2,1,1,1, -0,1,1,1,1,1,3,0,1,0,0,0,0,2,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0, -3,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,0,1,1,0,0,1,0,0,1,0,0,0,0, -0,0,1,0,0,0,0,0,2,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2, -0,2,0,1,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0, -3,3,3,3,3,3,3,3,3,2,3,3,3,2,1,2,3,3,2,3,3,3,3,2,3,2,1,2,0,2,1,2, -0,2,0,2,2,2,0,0,1,2,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0, -3,3,3,3,3,3,3,3,3,2,3,3,3,1,2,2,3,3,2,3,2,3,2,2,3,1,2,2,0,2,2,2, -0,2,1,2,2,2,0,0,1,2,0,0,0,0,1,0,0,0,0,0,1,0,0,1,0,0,0,1,0,0,1,0, -3,3,3,3,3,3,3,3,3,3,3,3,3,2,3,3,3,2,3,3,2,2,2,3,3,3,3,1,3,2,2,2, -0,2,0,1,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0, -3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,3,3,3,2,3,2,2,2,1,2,2,0,2,2,2,2, -0,2,0,2,2,2,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0, -3,3,3,3,3,3,3,3,3,3,3,2,3,3,3,1,3,2,3,3,2,3,3,2,2,1,2,2,2,2,2,2, -0,2,1,2,1,2,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,1,0, -3,3,3,3,3,3,2,3,2,3,3,2,3,3,3,3,2,3,2,3,3,3,3,3,2,2,2,2,2,2,2,1, -0,2,0,1,2,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,1,0, -3,3,3,3,3,3,3,3,3,2,1,2,3,3,3,3,3,3,3,2,3,2,3,2,1,2,3,0,2,1,2,2, -0,2,1,1,2,1,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,2,0, -3,3,3,3,3,3,3,3,3,2,3,3,3,3,2,1,3,1,2,2,2,1,2,3,3,1,2,1,2,2,2,2, -0,1,1,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,2,0,0,0,0,0,0,0,0, -3,3,3,3,3,3,3,3,3,3,0,2,3,3,3,1,3,3,3,1,2,2,2,2,1,1,2,2,2,2,2,2, -0,2,0,1,1,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,1,0, -3,3,3,3,3,3,2,3,3,3,2,2,3,3,3,2,1,2,3,2,3,2,2,2,2,1,2,1,1,1,2,2, -0,2,1,1,1,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0, -3,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,0,0,1,0,0,0,0,0, -1,0,1,0,0,0,0,0,2,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -3,3,3,3,3,2,3,3,2,3,1,2,2,2,2,3,2,3,1,1,2,2,1,2,2,1,1,0,2,2,2,2, -0,1,0,1,2,2,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,1,0, -3,0,0,1,1,0,1,0,0,1,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,2,0, -0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -3,0,1,0,1,0,1,1,0,1,1,0,0,0,1,1,0,1,1,1,0,0,0,0,0,0,1,0,0,0,0,0, -0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -3,0,0,0,1,1,0,1,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0, -3,2,2,1,2,2,2,2,2,2,2,1,2,2,1,2,2,1,1,1,1,1,1,1,1,2,1,1,0,3,3,3, -0,3,0,2,2,2,2,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0, -2,2,2,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,2,2,1,2,2,2,1,1,1,2,0,1, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -2,2,2,2,2,2,2,2,2,2,2,1,2,2,2,2,2,2,2,2,2,2,2,0,2,2,0,0,0,0,0,0, -0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -2,3,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,2,1,0,2,1,0, -0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -3,1,1,1,1,1,1,1,1,1,1,0,0,1,1,1,1,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0, -0,3,1,1,2,2,2,2,2,1,2,2,2,1,1,2,2,2,2,2,2,2,1,2,2,1,0,1,1,1,1,0, -0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -3,2,1,1,1,1,2,1,1,2,1,0,1,1,1,1,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0, -0,0,2,0,0,0,0,0,0,0,0,1,1,0,0,0,0,1,1,0,0,1,1,0,0,0,0,0,0,1,0,0, -2,1,1,2,2,2,2,2,2,2,2,2,2,2,1,2,2,2,2,2,1,2,1,2,1,1,1,1,0,0,0,0, -0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -1,2,1,2,2,2,2,2,2,2,2,2,2,1,2,1,2,1,1,2,1,1,1,2,1,2,1,2,0,1,0,1, -0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,3,1,2,2,2,1,2,2,2,2,2,2,2,2,1,2,1,1,1,1,1,1,2,1,2,1,1,0,1,0,1, -0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -2,1,2,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2, -0,2,0,1,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0, -3,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -2,1,1,1,1,1,1,1,0,1,1,0,1,0,0,1,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,2,0,1,1,1,0,1,0,0,0,1,1,0,1,1,0,0,0,0,0,1,1,0,0, -0,1,1,1,2,1,2,2,2,0,2,0,2,0,1,1,2,1,1,1,1,2,1,0,1,1,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0, -1,0,1,0,0,0,0,0,1,0,1,2,2,0,1,0,0,1,1,2,2,1,2,0,2,0,0,0,1,2,0,1, -2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,2,0,2,1,2,0,2,0,0,1,1,1,1,1,1,0,1,0,0,0,1,0,0,1, -2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,1,0,0,0,0,0,1,0,2,1,1,0,1,0,0,1,1,1,2,2,0,0,1,0,0,0,1,0,0,1, -1,1,2,1,0,1,1,1,0,1,0,1,1,1,1,0,0,0,1,0,1,0,0,0,0,0,0,0,0,2,2,1, -0,2,0,1,2,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -2,1,0,0,1,0,1,1,1,1,0,0,0,0,0,1,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -1,1,1,1,1,1,1,1,1,2,1,0,1,1,1,1,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,1,1,1,0,1,1,0,1,0,0,0,1,1,0,1, -2,0,1,0,1,0,1,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,1,0,1,1,1,0,1,0,0,1,1,2,1,1,2,0,1,0,0,0,1,1,0,1, -1,0,0,1,0,0,1,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,1,0,1,1,2,0,1,0,0,0,0,2,1,1,2,0,2,0,0,0,1,1,0,1, -1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,1,0,2,1,1,0,1,0,0,2,2,1,2,1,1,0,1,0,0,0,1,1,0,1, -2,0,1,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,1,2,2,0,0,0,0,0,1,1,0,1,0,0,1,0,0,0,0,1,0,1, -1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,1,2,2,0,0,0,0,2,1,1,1,0,2,1,1,0,0,0,2,1,0,1, -1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,1,0,1,1,2,0,1,0,0,1,1,0,2,1,1,0,1,0,0,0,1,1,0,1, -2,2,1,1,1,0,1,1,0,1,1,0,1,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,1,0,2,1,1,0,1,0,0,1,1,0,1,2,1,0,2,0,0,0,1,1,0,1, -2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0, -0,1,0,0,2,0,2,1,1,0,1,0,1,0,0,1,0,0,0,0,1,0,0,0,1,0,0,0,0,0,1,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,1,0,1,1,2,0,1,0,0,1,1,1,0,1,0,0,1,0,0,0,1,0,0,1, -1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -1,0,0,0,0,0,0,0,1,0,1,1,0,0,1,0,0,2,1,1,1,1,1,0,1,0,0,0,0,1,0,1, -0,1,1,1,2,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,1,2,1,0,0,0,0,0,1,1,1,1,1,0,1,0,0,0,1,1,0,0, -}; - -SequenceModel Win1255Model = -{ - win1255_CharToOrderMap, - HebrewLangModel, - (float)0.984004, - PR_FALSE, - "windows-1255" -}; - -#pragma GCC visibility pop diff --git a/amarok/utilities/collectionscanner/charset-detector/src/LangHungarianModel.cpp b/amarok/utilities/collectionscanner/charset-detector/src/LangHungarianModel.cpp deleted file mode 100644 index f53ef67c..00000000 --- a/amarok/utilities/collectionscanner/charset-detector/src/LangHungarianModel.cpp +++ /dev/null @@ -1,247 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#pragma GCC visibility push(hidden) - -#include "nsSBCharSetProber.h" -/**************************************************************** -255: Control characters that usually does not exist in any text -254: Carriage/Return -253: symbol (punctuation) that does not belong to word -252: 0 - 9 - -*****************************************************************/ - -//Character Mapping Table: -unsigned char Latin2_HungarianCharToOrderMap[] = -{ -255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, //00 -255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, //10 -+253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, //20 -252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, //30 -253, 28, 40, 54, 45, 32, 50, 49, 38, 39, 53, 36, 41, 34, 35, 47, - 46, 71, 43, 33, 37, 57, 48, 64, 68, 55, 52,253,253,253,253,253, -253, 2, 18, 26, 17, 1, 27, 12, 20, 9, 22, 7, 6, 13, 4, 8, - 23, 67, 10, 5, 3, 21, 19, 65, 62, 16, 11,253,253,253,253,253, -159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174, -175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190, -191,192,193,194,195,196,197, 75,198,199,200,201,202,203,204,205, - 79,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220, -221, 51, 81,222, 78,223,224,225,226, 44,227,228,229, 61,230,231, -232,233,234, 58,235, 66, 59,236,237,238, 60, 69, 63,239,240,241, - 82, 14, 74,242, 70, 80,243, 72,244, 15, 83, 77, 84, 30, 76, 85, -245,246,247, 25, 73, 42, 24,248,249,250, 31, 56, 29,251,252,253, -}; - -unsigned char win1250HungarianCharToOrderMap[] = -{ -255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, //00 -255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, //10 -+253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, //20 -252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, //30 -253, 28, 40, 54, 45, 32, 50, 49, 38, 39, 53, 36, 41, 34, 35, 47, - 46, 72, 43, 33, 37, 57, 48, 64, 68, 55, 52,253,253,253,253,253, -253, 2, 18, 26, 17, 1, 27, 12, 20, 9, 22, 7, 6, 13, 4, 8, - 23, 67, 10, 5, 3, 21, 19, 65, 62, 16, 11,253,253,253,253,253, -161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176, -177,178,179,180, 78,181, 69,182,183,184,185,186,187,188,189,190, -191,192,193,194,195,196,197, 76,198,199,200,201,202,203,204,205, - 81,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220, -221, 51, 83,222, 80,223,224,225,226, 44,227,228,229, 61,230,231, -232,233,234, 58,235, 66, 59,236,237,238, 60, 70, 63,239,240,241, - 84, 14, 75,242, 71, 82,243, 73,244, 15, 85, 79, 86, 30, 77, 87, -245,246,247, 25, 74, 42, 24,248,249,250, 31, 56, 29,251,252,253, -}; - -//Model Table: -//total sequences: 100% -//first 512 sequences: 94.7368% -//first 1024 sequences:5.2623% -//rest sequences: 0.8894% -//negative sequences: 0.0009% -char HungarianLangModel[] = -{ -0,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, -3,3,3,3,3,3,3,3,3,3,2,3,3,3,3,3,3,3,3,2,2,3,3,1,1,2,2,2,2,2,1,2, -3,2,2,3,3,3,3,3,2,3,3,3,3,3,3,1,2,3,3,3,3,2,3,3,1,1,3,3,0,1,1,1, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0, -3,2,1,3,3,3,3,3,2,3,3,3,3,3,1,1,2,3,3,3,3,3,3,3,1,1,3,2,0,1,1,1, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0, -3,3,3,3,3,3,3,3,3,3,3,1,1,2,3,3,3,1,3,3,3,3,3,1,3,3,2,2,0,3,2,3, -0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0, -3,3,3,3,3,3,2,3,3,3,2,3,3,2,3,3,3,3,3,2,3,3,2,2,3,2,3,2,0,3,2,2, -0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0, -3,3,3,3,3,3,2,3,3,3,3,3,2,3,3,3,1,2,3,2,2,3,1,2,3,3,2,2,0,3,3,3, -0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0, -3,3,3,3,3,3,3,3,3,3,2,2,3,3,3,3,3,3,2,3,3,3,3,2,3,3,3,3,0,2,3,2, -0,0,0,1,1,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0, -3,3,3,3,3,3,3,3,3,3,3,1,1,1,3,3,2,1,3,2,2,3,2,1,3,2,2,1,0,3,3,1, -0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0, -3,2,2,3,3,3,3,3,1,2,3,3,3,3,1,2,1,3,3,3,3,2,2,3,1,1,3,2,0,1,1,1, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0, -3,3,3,3,3,3,3,3,2,2,3,3,3,3,3,2,1,3,3,3,3,3,2,2,1,3,3,3,0,1,1,2, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0, -3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,3,3,3,2,3,3,2,3,3,3,2,0,3,2,3, -0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,1,0, -3,3,3,3,3,3,2,3,3,3,2,3,2,3,3,3,1,3,2,2,2,3,1,1,3,3,1,1,0,3,3,2, -0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0, -3,3,3,3,3,3,3,2,3,3,3,2,3,2,3,3,3,2,3,3,3,3,3,1,2,3,2,2,0,2,2,2, -0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0, -3,3,3,2,2,2,3,1,3,3,2,2,1,3,3,3,1,1,3,1,2,3,2,3,2,2,2,1,0,2,2,2, -0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0, -3,1,1,3,3,3,3,3,1,2,3,3,3,3,1,2,1,3,3,3,2,2,3,2,1,0,3,2,0,1,1,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -3,1,1,3,3,3,3,3,1,2,3,3,3,3,1,1,0,3,3,3,3,0,2,3,0,0,2,1,0,1,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -3,3,3,3,3,3,2,2,3,3,2,2,2,2,3,3,0,1,2,3,2,3,2,2,3,2,1,2,0,2,2,2, -0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0, -3,3,3,3,3,3,1,2,3,3,3,2,1,2,3,3,2,2,2,3,2,3,3,1,3,3,1,1,0,2,3,2, -0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0, -3,3,3,1,2,2,2,2,3,3,3,1,1,1,3,3,1,1,3,1,1,3,2,1,2,3,1,1,0,2,2,2, -0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0, -3,3,3,2,1,2,1,1,3,3,1,1,1,1,3,3,1,1,2,2,1,2,1,1,2,2,1,1,0,2,2,1, -0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0, -3,3,3,1,1,2,1,1,3,3,1,0,1,1,3,3,2,0,1,1,2,3,1,0,2,2,1,0,0,1,3,2, -0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0, -3,2,1,3,3,3,3,3,1,2,3,2,3,3,2,1,1,3,2,3,2,1,2,2,0,1,2,1,0,0,1,1, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0, -3,3,3,3,2,2,2,2,3,1,2,2,1,1,3,3,0,3,2,1,2,3,2,1,3,3,1,1,0,2,1,3, -0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0, -3,3,3,2,2,2,3,2,3,3,3,2,1,1,3,3,1,1,1,2,2,3,2,3,2,2,2,1,0,2,2,1, -0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0, -1,0,0,3,3,3,3,3,0,0,3,3,2,3,0,0,0,2,3,3,1,0,1,2,0,0,1,1,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -3,1,2,3,3,3,3,3,1,2,3,3,2,2,1,1,0,3,3,2,2,1,2,2,1,0,2,2,0,1,1,1, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -3,3,2,2,1,3,1,2,3,3,2,2,1,1,2,2,1,1,1,1,3,2,1,1,1,1,2,1,0,1,2,1, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0, -2,3,3,1,1,1,1,1,3,3,3,0,1,1,3,3,1,1,1,1,1,2,2,0,3,1,1,2,0,2,1,1, -0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0, -3,1,0,1,2,1,2,2,0,1,2,3,1,2,0,0,0,2,1,1,1,1,1,2,0,0,1,1,0,0,0,0, -1,2,1,2,2,2,1,2,1,2,0,2,0,2,2,1,1,2,1,1,2,1,1,1,0,1,0,0,0,1,1,0, -1,1,1,2,3,2,3,3,0,1,2,2,3,1,0,1,0,2,1,2,2,0,1,1,0,0,1,1,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -1,0,0,3,3,2,2,1,0,0,3,2,3,2,0,0,0,1,1,3,0,0,1,1,0,0,2,1,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -3,1,1,2,2,3,3,1,0,1,3,2,3,1,1,1,0,1,1,1,1,1,3,1,0,0,2,2,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -3,1,1,1,2,2,2,1,0,1,2,3,3,2,0,0,0,2,1,1,1,2,1,1,1,0,1,1,1,0,0,0, -1,2,2,2,2,2,1,1,1,2,0,2,1,1,1,1,1,2,1,1,1,1,1,1,0,1,1,1,0,0,1,1, -3,2,2,1,0,0,1,1,2,2,0,3,0,1,2,1,1,0,0,1,1,1,0,1,1,1,1,0,2,1,1,1, -2,2,1,1,1,2,1,2,1,1,1,1,1,1,1,2,1,1,1,2,3,1,1,1,1,1,1,1,1,1,0,1, -2,3,3,0,1,0,0,0,3,3,1,0,0,1,2,2,1,0,0,0,0,2,0,0,1,1,1,0,2,1,1,1, -2,1,1,1,1,1,1,2,1,1,0,1,1,0,1,1,1,0,1,2,1,1,0,1,1,1,1,1,1,1,0,1, -2,3,3,0,1,0,0,0,2,2,0,0,0,0,1,2,2,0,0,0,0,1,0,0,1,1,0,0,2,0,1,0, -2,1,1,1,1,2,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,2,0,1,1,1,1,1,0,1, -3,2,2,0,1,0,1,0,2,3,2,0,0,1,2,2,1,0,0,1,1,1,0,0,2,1,0,1,2,2,1,1, -2,1,1,1,1,1,1,2,1,1,1,1,1,1,0,2,1,0,1,1,0,1,1,1,0,1,1,2,1,1,0,1, -2,2,2,0,0,1,0,0,2,2,1,1,0,0,2,1,1,0,0,0,1,2,0,0,2,1,0,0,2,1,1,1, -2,1,1,1,1,2,1,2,1,1,1,2,2,1,1,2,1,1,1,2,1,1,1,1,1,1,1,1,1,1,0,1, -1,2,3,0,0,0,1,0,3,2,1,0,0,1,2,1,1,0,0,0,0,2,1,0,1,1,0,0,2,1,2,1, -1,1,0,0,0,1,0,1,1,1,1,1,2,0,0,1,0,0,0,2,0,0,1,1,1,1,1,1,1,1,0,1, -3,0,0,2,1,2,2,1,0,0,2,1,2,2,0,0,0,2,1,1,1,0,1,1,0,0,1,1,2,0,0,0, -1,2,1,2,2,1,1,2,1,2,0,1,1,1,1,1,1,1,1,1,2,1,1,0,0,1,1,1,1,0,0,1, -1,3,2,0,0,0,1,0,2,2,2,0,0,0,2,2,1,0,0,0,0,3,1,1,1,1,0,0,2,1,1,1, -2,1,0,1,1,1,0,1,1,1,1,1,1,1,0,2,1,0,0,1,0,1,1,0,1,1,1,1,1,1,0,1, -2,3,2,0,0,0,1,0,2,2,0,0,0,0,2,1,1,0,0,0,0,2,1,0,1,1,0,0,2,1,1,0, -2,1,1,1,1,2,1,2,1,2,0,1,1,1,0,2,1,1,1,2,1,1,1,1,0,1,1,1,1,1,0,1, -3,1,1,2,2,2,3,2,1,1,2,2,1,1,0,1,0,2,2,1,1,1,1,1,0,0,1,1,0,1,1,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -2,2,2,0,0,0,0,0,2,2,0,0,0,0,2,2,1,0,0,0,1,1,0,0,1,2,0,0,2,1,1,1, -2,2,1,1,1,2,1,2,1,1,0,1,1,1,1,2,1,1,1,2,1,1,1,1,0,1,2,1,1,1,0,1, -1,0,0,1,2,3,2,1,0,0,2,0,1,1,0,0,0,1,1,1,1,0,1,1,0,0,1,0,0,0,0,0, -1,2,1,2,1,2,1,1,1,2,0,2,1,1,1,0,1,2,0,0,1,1,1,0,0,0,0,0,0,0,0,0, -2,3,2,0,0,0,0,0,1,1,2,1,0,0,1,1,1,0,0,0,0,2,0,0,1,1,0,0,2,1,1,1, -2,1,1,1,1,1,1,2,1,0,1,1,1,1,0,2,1,1,1,1,1,1,0,1,0,1,1,1,1,1,0,1, -1,2,2,0,1,1,1,0,2,2,2,0,0,0,3,2,1,0,0,0,1,1,0,0,1,1,0,1,1,1,0,0, -1,1,0,1,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,2,1,1,1,0,0,1,1,1,0,1,0,1, -2,1,0,2,1,1,2,2,1,1,2,1,1,1,0,0,0,1,1,0,1,1,1,1,0,0,1,1,1,0,0,0, -1,2,2,2,2,2,1,1,1,2,0,2,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,0,0,0,1,0, -1,2,3,0,0,0,1,0,2,2,0,0,0,0,2,2,0,0,0,0,0,1,0,0,1,0,0,0,2,0,1,0, -2,1,1,1,1,1,0,2,0,0,0,1,2,1,1,1,1,0,1,2,0,1,0,1,0,1,1,1,0,1,0,1, -2,2,2,0,0,0,1,0,2,1,2,0,0,0,1,1,2,0,0,0,0,1,0,0,1,1,0,0,2,1,0,1, -2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,0,1,1,1,1,1,0,1, -1,2,2,0,0,0,1,0,2,2,2,0,0,0,1,1,0,0,0,0,0,1,1,0,2,0,0,1,1,1,0,1, -1,0,1,1,1,1,1,1,0,1,1,1,1,0,0,1,0,0,1,1,0,1,0,1,1,1,1,1,0,0,0,1, -1,0,0,1,0,1,2,1,0,0,1,1,1,2,0,0,0,1,1,0,1,0,1,1,0,0,1,0,0,0,0,0, -0,2,1,2,1,1,1,1,1,2,0,2,0,1,1,0,1,2,1,0,1,1,1,0,0,0,0,0,0,1,0,0, -2,1,1,0,1,2,0,0,1,1,1,0,0,0,1,1,0,0,0,0,0,1,0,0,1,0,0,0,2,1,0,1, -2,2,1,1,1,1,1,2,1,1,0,1,1,1,1,2,1,1,1,2,1,1,0,1,0,1,1,1,1,1,0,1, -1,2,2,0,0,0,0,0,1,1,0,0,0,0,2,1,0,0,0,0,0,2,0,0,2,2,0,0,2,0,0,1, -2,1,1,1,1,1,1,1,0,1,1,0,1,1,0,1,0,0,0,1,1,1,1,0,0,1,1,1,1,0,0,1, -1,1,2,0,0,3,1,0,2,1,1,1,0,0,1,1,1,0,0,0,1,1,0,0,0,1,0,0,1,0,1,0, -1,2,1,0,1,1,1,2,1,1,0,1,1,1,1,1,0,0,0,1,1,1,1,1,0,1,0,0,0,1,0,0, -2,1,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,1,0,0,0,1,0,0,0,0,2,0,0,0, -2,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,2,1,1,0,0,1,1,1,1,1,0,1, -2,1,1,1,2,1,1,1,0,1,1,2,1,0,0,0,0,1,1,1,1,0,1,0,0,0,0,1,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -1,1,0,1,1,1,1,1,0,0,1,1,2,1,0,0,0,1,1,0,0,0,1,1,0,0,1,0,1,0,0,0, -1,2,1,1,1,1,1,1,1,1,0,1,0,1,1,1,1,1,1,0,1,1,1,0,0,0,0,0,0,1,0,0, -2,0,0,0,1,1,1,1,0,0,1,1,0,0,0,0,0,1,1,1,2,0,0,1,0,0,1,0,1,0,0,0, -0,1,1,1,1,1,1,1,1,2,0,1,1,1,1,0,1,1,1,0,1,1,1,0,0,0,0,0,0,0,0,0, -1,0,0,1,1,1,1,1,0,0,2,1,0,1,0,0,0,1,0,1,0,0,0,0,0,0,1,0,0,0,0,0, -0,1,1,1,1,1,1,0,1,1,0,1,0,1,1,0,1,1,0,0,1,1,1,0,0,0,0,0,0,0,0,0, -1,0,0,1,1,1,0,0,0,0,1,0,2,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0, -0,1,1,1,1,1,0,0,1,1,0,1,0,1,0,0,1,1,1,0,1,1,1,0,0,0,0,0,0,0,0,0, -0,0,0,1,0,0,0,0,0,0,1,1,2,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,1,1,1,0,1,0,0,1,1,0,1,0,1,1,0,1,1,1,0,1,1,1,0,0,0,0,0,0,0,0,0, -2,1,1,1,1,1,1,1,1,1,1,0,0,1,1,1,0,0,1,0,0,1,0,1,0,1,1,1,0,0,1,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -1,0,0,1,1,1,1,0,0,0,1,1,1,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0, -0,1,1,1,1,1,1,0,1,1,0,1,0,1,0,0,1,1,0,0,1,1,0,0,0,0,0,0,0,0,0,0, -}; - -SequenceModel Latin2HungarianModel = -{ - Latin2_HungarianCharToOrderMap, - HungarianLangModel, - (float)0.947368, - PR_TRUE, - "ISO-8859-2" -}; - -SequenceModel Win1250HungarianModel = -{ - win1250HungarianCharToOrderMap, - HungarianLangModel, - (float)0.947368, - PR_TRUE, - "windows-1250" -}; - -#pragma GCC visibility pop - diff --git a/amarok/utilities/collectionscanner/charset-detector/src/LangThaiModel.cpp b/amarok/utilities/collectionscanner/charset-detector/src/LangThaiModel.cpp deleted file mode 100644 index e2ae9f4d..00000000 --- a/amarok/utilities/collectionscanner/charset-detector/src/LangThaiModel.cpp +++ /dev/null @@ -1,226 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#pragma GCC visibility push(hidden) - -#include "nsSBCharSetProber.h" - - -/**************************************************************** -255: Control characters that usually does not exist in any text -254: Carriage/Return -253: symbol (punctuation) that does not belong to word -252: 0 - 9 - -*****************************************************************/ - -//The following result for thai was collected from a limited sample (1M). - -//Character Mapping Table: -unsigned char TIS620CharToOrderMap[] = -{ -255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, //00 -255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, //10 -+253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, //20 -252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, //30 -253,182,106,107,100,183,184,185,101, 94,186,187,108,109,110,111, //40 -188,189,190, 89, 95,112,113,191,192,193,194,253,253,253,253,253, //50 -253, 64, 72, 73,114, 74,115,116,102, 81,201,117, 90,103, 78, 82, //60 - 96,202, 91, 79, 84,104,105, 97, 98, 92,203,253,253,253,253,253, //70 -209,210,211,212,213, 88,214,215,216,217,218,219,220,118,221,222, -223,224, 99, 85, 83,225,226,227,228,229,230,231,232,233,234,235, -236, 5, 30,237, 24,238, 75, 8, 26, 52, 34, 51,119, 47, 58, 57, - 49, 53, 55, 43, 20, 19, 44, 14, 48, 3, 17, 25, 39, 62, 31, 54, - 45, 9, 16, 2, 61, 15,239, 12, 42, 46, 18, 21, 76, 4, 66, 63, - 22, 10, 1, 36, 23, 13, 40, 27, 32, 35, 86,240,241,242,243,244, - 11, 28, 41, 29, 33,245, 50, 37, 6, 7, 67, 77, 38, 93,246,247, - 68, 56, 59, 65, 69, 60, 70, 80, 71, 87,248,249,250,251,252,253, -}; - - - - -//Model Table: -//total sequences: 100% -//first 512 sequences: 92.6386% -//first 1024 sequences:7.3177% -//rest sequences: 1.0230% -//negative sequences: 0.0436% -char ThaiLangModel[] = -{ -0,1,3,3,3,3,0,0,3,3,0,3,3,0,3,3,3,3,3,3,3,3,0,0,3,3,3,0,3,3,3,3, -0,3,3,0,0,0,1,3,0,3,3,2,3,3,0,1,2,3,3,3,3,0,2,0,2,0,0,3,2,1,2,2, -3,0,3,3,2,3,0,0,3,3,0,3,3,0,3,3,3,3,3,3,3,3,3,0,3,2,3,0,2,2,2,3, -0,2,3,0,0,0,0,1,0,1,2,3,1,1,3,2,2,0,1,1,0,0,1,0,0,0,0,0,0,0,1,1, -3,3,3,2,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,3,3,2,3,2,3,3,2,2,2, -3,1,2,3,0,3,3,2,2,1,2,3,3,1,2,0,1,3,0,1,0,0,1,0,0,0,0,0,0,0,1,1, -3,3,2,2,3,3,3,3,1,2,3,3,3,3,3,2,2,2,2,3,3,2,2,3,3,2,2,3,2,3,2,2, -3,3,1,2,3,1,2,2,3,3,1,0,2,1,0,0,3,1,2,1,0,0,1,0,0,0,0,0,0,1,0,1, -3,3,3,3,3,3,2,2,3,3,3,3,2,3,2,2,3,3,2,2,3,2,2,2,2,1,1,3,1,2,1,1, -3,2,1,0,2,1,0,1,0,1,1,0,1,1,0,0,1,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0, -3,3,3,2,3,2,3,3,2,2,3,2,3,3,2,3,1,1,2,3,2,2,2,3,2,2,2,2,2,1,2,1, -2,2,1,1,3,3,2,1,0,1,2,2,0,1,3,0,0,0,1,1,0,0,0,0,0,2,3,0,0,2,1,1, -3,3,2,3,3,2,0,0,3,3,0,3,3,0,2,2,3,1,2,2,1,1,1,0,2,2,2,0,2,2,1,1, -0,2,1,0,2,0,0,2,0,1,0,0,1,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,1,0, -3,3,2,3,3,2,0,0,3,3,0,2,3,0,2,1,2,2,2,2,1,2,0,0,2,2,2,0,2,2,1,1, -0,2,1,0,2,0,0,2,0,1,1,0,1,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0, -3,3,2,3,2,3,2,0,2,2,1,3,2,1,3,2,1,2,3,2,2,3,0,2,3,2,2,1,2,2,2,2, -1,2,2,0,0,0,0,2,0,1,2,0,1,1,1,0,1,0,3,1,1,0,0,0,0,0,0,0,0,0,1,0, -3,3,2,3,3,2,3,2,2,2,3,2,2,3,2,2,1,2,3,2,2,3,1,3,2,2,2,3,2,2,2,3, -3,2,1,3,0,1,1,1,0,2,1,1,1,1,1,0,1,0,1,1,0,0,0,0,0,0,0,0,0,2,0,0, -1,0,0,3,0,3,3,3,3,3,0,0,3,0,2,2,3,3,3,3,3,0,0,0,1,1,3,0,0,0,0,2, -0,0,1,0,0,0,0,0,0,0,2,3,0,0,0,3,0,2,0,0,0,0,0,3,0,0,0,0,0,0,0,0, -2,0,3,3,3,3,0,0,2,3,0,0,3,0,3,3,2,3,3,3,3,3,0,0,3,3,3,0,0,0,3,3, -0,0,3,0,0,0,0,2,0,0,2,1,1,3,0,0,1,0,0,2,3,0,1,0,0,0,0,0,0,0,1,0, -3,3,3,3,2,3,3,3,3,3,3,3,1,2,1,3,3,2,2,1,2,2,2,3,1,1,2,0,2,1,2,1, -2,2,1,0,0,0,1,1,0,1,0,1,1,0,0,0,0,0,1,1,0,0,1,0,0,0,0,0,0,0,0,0, -3,0,2,1,2,3,3,3,0,2,0,2,2,0,2,1,3,2,2,1,2,1,0,0,2,2,1,0,2,1,2,2, -0,1,1,0,0,0,0,1,0,1,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0, -3,3,3,3,2,1,3,3,1,1,3,0,2,3,1,1,3,2,1,1,2,0,2,2,3,2,1,1,1,1,1,2, -3,0,0,1,3,1,2,1,2,0,3,0,0,0,1,0,3,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0, -3,3,1,1,3,2,3,3,3,1,3,2,1,3,2,1,3,2,2,2,2,1,3,3,1,2,1,3,1,2,3,0, -2,1,1,3,2,2,2,1,2,1,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2, -3,3,2,3,2,3,3,2,3,2,3,2,3,3,2,1,0,3,2,2,2,1,2,2,2,1,2,2,1,2,1,1, -2,2,2,3,0,1,3,1,1,1,1,0,1,1,0,2,1,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0, -3,3,3,3,2,3,2,2,1,1,3,2,3,2,3,2,0,3,2,2,1,2,0,2,2,2,1,2,2,2,2,1, -3,2,1,2,2,1,0,2,0,1,0,0,1,1,0,0,0,0,0,1,1,0,1,0,0,0,0,0,0,0,0,1, -3,3,3,3,3,2,3,1,2,3,3,2,2,3,0,1,1,2,0,3,3,2,2,3,0,1,1,3,0,0,0,0, -3,1,0,3,3,0,2,0,2,1,0,0,3,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -3,3,3,2,3,2,3,3,0,1,3,1,1,2,1,2,1,1,3,1,1,0,2,3,1,1,1,1,1,1,1,1, -3,1,1,2,2,2,2,1,1,1,0,0,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1, -3,2,2,1,1,2,1,3,3,2,3,2,2,3,2,2,3,1,2,2,1,2,0,3,2,1,2,2,2,2,2,1, -3,2,1,2,2,2,1,1,1,1,0,0,1,1,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0, -3,3,3,3,3,3,3,3,1,3,3,0,2,1,0,3,2,0,0,3,1,0,1,1,0,1,0,0,0,0,0,1, -1,0,0,1,0,3,2,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -3,0,2,2,2,3,0,0,1,3,0,3,2,0,3,2,2,3,3,3,3,3,1,0,2,2,2,0,2,2,1,2, -0,2,3,0,0,0,0,1,0,1,0,0,1,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1, -3,0,2,3,1,3,3,2,3,3,0,3,3,0,3,2,2,3,2,3,3,3,0,0,2,2,3,0,1,1,1,3, -0,0,3,0,0,0,2,2,0,1,3,0,1,2,2,2,3,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1, -3,2,3,3,2,0,3,3,2,2,3,1,3,2,1,3,2,0,1,2,2,0,2,3,2,1,0,3,0,0,0,0, -3,0,0,2,3,1,3,0,0,3,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -3,1,3,2,2,2,1,2,0,1,3,1,1,3,1,3,0,0,2,1,1,1,1,2,1,1,1,0,2,1,0,1, -1,2,0,0,0,3,1,1,0,0,0,0,1,0,1,0,0,1,0,1,0,0,0,0,0,3,1,0,0,0,1,0, -3,3,3,3,2,2,2,2,2,1,3,1,1,1,2,0,1,1,2,1,2,1,3,2,0,0,3,1,1,1,1,1, -3,1,0,2,3,0,0,0,3,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,2,3,0,3,3,0,2,0,0,0,0,0,0,0,3,0,0,1,0,0,0,0,0,0,0,0,0,0,0, -0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,2,3,1,3,0,0,1,2,0,0,2,0,3,3,2,3,3,3,2,3,0,0,2,2,2,0,0,0,2,2, -0,0,1,0,0,0,0,3,0,0,0,0,2,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0, -0,0,0,3,0,2,0,0,0,0,0,0,0,0,0,0,1,2,3,1,3,3,0,0,1,0,3,0,0,0,0,0, -0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -3,3,1,2,3,1,2,3,1,0,3,0,2,2,1,0,2,1,1,2,0,1,0,0,1,1,1,1,0,1,0,0, -1,0,0,0,0,1,1,0,3,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -3,3,3,3,2,1,0,1,1,1,3,1,2,2,2,2,2,2,1,1,1,1,0,3,1,0,1,3,1,1,1,1, -1,1,0,2,0,1,3,1,1,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,2,0,1, -3,0,2,2,1,3,3,2,3,3,0,1,1,0,2,2,1,2,1,3,3,1,0,0,3,2,0,0,0,0,2,1, -0,1,0,0,0,0,1,2,0,1,1,3,1,1,2,2,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0, -0,0,3,0,0,1,0,0,0,3,0,0,3,0,3,1,0,1,1,1,3,2,0,0,0,3,0,0,0,0,2,0, -0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,2,0,0,0,0,0,0,0,0,0, -3,3,1,3,2,1,3,3,1,2,2,0,1,2,1,0,1,2,0,0,0,0,0,3,0,0,0,3,0,0,0,0, -3,0,0,1,1,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -3,0,1,2,0,3,3,3,2,2,0,1,1,0,1,3,0,0,0,2,2,0,0,0,0,3,1,0,1,0,0,0, -0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -3,0,2,3,1,2,0,0,2,1,0,3,1,0,1,2,0,1,1,1,1,3,0,0,3,1,1,0,2,2,1,1, -0,2,0,0,0,0,0,1,0,1,0,0,1,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -3,0,0,3,1,2,0,0,2,2,0,1,2,0,1,0,1,3,1,2,1,0,0,0,2,0,3,0,0,0,1,0, -0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -3,0,1,1,2,2,0,0,0,2,0,2,1,0,1,1,0,1,1,1,2,1,0,0,1,1,1,0,2,1,1,1, -0,1,1,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,1,0,1, -0,0,0,2,0,1,3,1,1,1,1,0,0,0,0,3,2,0,1,0,0,0,1,2,0,0,0,1,0,0,0,0, -0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,3,3,3,3,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -1,0,2,3,2,2,0,0,0,1,0,0,0,0,2,3,2,1,2,2,3,0,0,0,2,3,1,0,0,0,1,1, -0,0,1,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1,1,0,1,0,0,0,0,0,0,0,0,0, -3,3,2,2,0,1,0,0,0,0,2,0,2,0,1,0,0,0,1,1,0,0,0,2,1,0,1,0,1,1,0,0, -0,1,0,2,0,0,1,0,3,0,1,0,0,0,2,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -3,3,1,0,0,1,0,0,0,0,0,1,1,2,0,0,0,0,1,0,0,1,3,1,0,0,0,0,1,1,0,0, -0,1,0,0,0,0,3,0,0,0,0,0,0,3,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0, -3,3,1,1,1,1,2,3,0,0,2,1,1,1,1,1,0,2,1,1,0,0,0,2,1,0,1,2,1,1,0,1, -2,1,0,3,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -1,3,1,0,0,0,0,0,0,0,3,0,0,0,3,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,1, -0,0,0,2,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -3,3,2,0,0,0,0,0,0,1,2,1,0,1,1,0,2,0,0,1,0,0,2,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,2,0,0,0,1,3,0,1,0,0,0,2,0,0,0,0,0,0,0,1,2,0,0,0,0,0, -3,3,0,0,1,1,2,0,0,1,2,1,0,1,1,1,0,1,1,0,0,2,1,1,0,1,0,0,1,1,1,0, -0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0, -2,2,2,1,0,0,0,0,1,0,0,0,0,3,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0, -2,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -2,3,0,0,1,1,0,0,0,2,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -1,1,0,1,2,0,1,2,0,0,1,1,0,2,0,1,0,0,1,0,0,0,0,1,0,0,0,2,0,0,0,0, -1,0,0,1,0,1,1,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,1,0,0,0,0,0,0,0,1,1,0,1,1,0,2,1,3,0,0,0,0,1,1,0,0,0,0,0,0,0,3, -1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -2,0,1,0,1,0,0,2,0,0,2,0,0,1,1,2,0,0,1,1,0,0,0,1,0,0,0,1,1,0,0,0, -1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0, -1,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,1,1,0,0,0, -2,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -2,0,0,0,0,2,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,3,0,0,0, -2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,1,0,0,0,0, -1,0,0,0,0,0,0,0,0,1,0,0,0,0,2,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,1,1,0,0,2,1,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -}; - - -SequenceModel TIS620ThaiModel = -{ - TIS620CharToOrderMap, - ThaiLangModel, - (float)0.926386, - PR_FALSE, - "TIS-620" -}; - -#pragma GCC visibility pop - diff --git a/amarok/utilities/collectionscanner/charset-detector/src/impl.cpp b/amarok/utilities/collectionscanner/charset-detector/src/impl.cpp deleted file mode 100644 index 29cab581..00000000 --- a/amarok/utilities/collectionscanner/charset-detector/src/impl.cpp +++ /dev/null @@ -1,197 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Universal charset detector code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 2001 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Kohei TAKETA - * Jim Huang - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -// NOTE: commented out to fix compilation with gcc-4.3 -// (also a corresponding "pop" in the end) -//#pragma GCC visibility push(hidden) - -#include "chardet.h" -#include "nscore.h" -#include "nsUniversalDetector.h" -#include -#include - -#ifdef _WIN32 -# include -#endif - - -//#ifdef _MANAGED -//#pragma managed(push, off) -//#endif - - -class DllDetector : public nsUniversalDetector -{ -protected: - char *charset_; - -public: - DllDetector() - : nsUniversalDetector() - { - charset_ = NULL; - } - - virtual ~DllDetector() - { - if (charset_) delete charset_; - } - - virtual void Report(const char* charset) - { - charset_ = strdup(charset); - } - - virtual void Reset() - { - nsUniversalDetector::Reset(); - charset_ = strdup(""); - } - - const char* GetCharset() const - { - return charset_; - } -}; - - -#ifdef _WIN32 -BOOL APIENTRY DllMain( HMODULE hModule, - DWORD ul_reason_for_call, - LPVOID lpReserved - ) -{ - return TRUE; -} -#endif - - -int chardet_create(chardet_t* pdet) -{ - if (!pdet) return CHARDET_RESULT_NOMEMORY; - - *pdet = reinterpret_cast(new DllDetector); - if (*pdet) { - return CHARDET_RESULT_OK; - } else { - return CHARDET_RESULT_NOMEMORY; - } -} - - -void chardet_destroy(chardet_t det) -{ - if (det) { - delete reinterpret_cast(det); - } -} - - -int chardet_handle_data(chardet_t det, const char* data, unsigned int len) -{ - if (det) { - nsresult ret = reinterpret_cast(det)->HandleData(data, (PRUint32)len); - if (ret == NS_OK) { - return CHARDET_RESULT_OK; - } else { - return CHARDET_RESULT_NOMEMORY; - } - } else { - return CHARDET_RESULT_INVALID_DETECTOR; - } -} - - -int chardet_data_end(chardet_t det) -{ - if (det) { - reinterpret_cast(det)->DataEnd(); - return CHARDET_RESULT_OK; - } else { - return CHARDET_RESULT_INVALID_DETECTOR; - } -} - - -int chardet_reset(chardet_t det) -{ - if (det) { - reinterpret_cast(det)->Reset(); - return CHARDET_RESULT_OK; - } else { - return CHARDET_RESULT_INVALID_DETECTOR; - } -} - - -int chardet_get_charset(chardet_t det, char* namebuf, unsigned int buflen) -{ - if (det) { - if (!namebuf) return CHARDET_RESULT_NOMEMORY; - - const char* name = reinterpret_cast(det)->GetCharset(); - if (name == NULL || *name == 0) { - // could not detect encoding - if (buflen > 0) { - *namebuf = 0; - return CHARDET_RESULT_OK; - } else { - return CHARDET_RESULT_NOMEMORY; - } - } else { - // encoding detected - if (buflen >= strlen(name)+1) { - strcpy(namebuf, name); - return CHARDET_RESULT_OK; - } else { - return CHARDET_RESULT_NOMEMORY; - } - } - } else { - return CHARDET_RESULT_INVALID_DETECTOR; - } -} - - -//#ifdef _MANAGED -//#pragma managed(pop) -//#endif - -//#pragma GCC visibility pop - diff --git a/amarok/utilities/collectionscanner/charset-detector/src/nsBig5Prober.cpp b/amarok/utilities/collectionscanner/charset-detector/src/nsBig5Prober.cpp deleted file mode 100644 index 2f6e2a3d..00000000 --- a/amarok/utilities/collectionscanner/charset-detector/src/nsBig5Prober.cpp +++ /dev/null @@ -1,97 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#pragma GCC visibility push(hidden) - -#include "nsBig5Prober.h" - -void nsBig5Prober::Reset(void) -{ - mCodingSM->Reset(); - mState = eDetecting; - mDistributionAnalyser.Reset(); -} - -nsProbingState nsBig5Prober::HandleData(const char* aBuf, PRUint32 aLen) -{ - nsSMState codingState; - - for (PRUint32 i = 0; i < aLen; i++) - { - codingState = mCodingSM->NextState(aBuf[i]); - if (codingState == eError) - { - mState = eNotMe; - break; - } - if (codingState == eItsMe) - { - mState = eFoundIt; - break; - } - if (codingState == eStart) - { - PRUint32 charLen = mCodingSM->GetCurrentCharLen(); - - if (i == 0) - { - mLastChar[1] = aBuf[0]; - mDistributionAnalyser.HandleOneChar(mLastChar, charLen); - } - else - mDistributionAnalyser.HandleOneChar(aBuf+i-1, charLen); - } - } - - mLastChar[0] = aBuf[aLen-1]; - - if (mState == eDetecting) - if (mDistributionAnalyser.GotEnoughData() && GetConfidence() > SHORTCUT_THRESHOLD) - mState = eFoundIt; - - return mState; -} - -float nsBig5Prober::GetConfidence(void) -{ - float distribCf = mDistributionAnalyser.GetConfidence(); - - return (float)distribCf; -} - -#pragma GCC visibility pop - diff --git a/amarok/utilities/collectionscanner/charset-detector/src/nsBig5Prober.h b/amarok/utilities/collectionscanner/charset-detector/src/nsBig5Prober.h deleted file mode 100644 index b2d73945..00000000 --- a/amarok/utilities/collectionscanner/charset-detector/src/nsBig5Prober.h +++ /dev/null @@ -1,69 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef nsBig5Prober_h__ -#define nsBig5Prober_h__ - -#include "nsCharSetProber.h" -#include "nsCodingStateMachine.h" -#include "CharDistribution.h" - -class nsBig5Prober: public nsCharSetProber, nsCharSetProberHelper { -public: - nsBig5Prober(void){mCodingSM = new nsCodingStateMachine(&Big5SMModel); - Reset();}; - virtual ~nsBig5Prober(void){delete mCodingSM;}; - nsProbingState HandleData(const char* aBuf, PRUint32 aLen); - const char* GetCharSetName() {return "Big5";}; - nsProbingState GetState(void) {return mState;}; - void Reset(void); - float GetConfidence(void); - void SetOpion() {}; - -protected: - void GetDistribution(PRUint32 aCharLen, const char* aStr); - - nsCodingStateMachine* mCodingSM; - nsProbingState mState; - - //Big5ContextAnalysis mContextAnalyser; - Big5DistributionAnalysis mDistributionAnalyser; -}; - - -#endif /* nsBig5Prober_h__ */ - diff --git a/amarok/utilities/collectionscanner/charset-detector/src/nsCharSetProber.cpp b/amarok/utilities/collectionscanner/charset-detector/src/nsCharSetProber.cpp deleted file mode 100644 index 4b6a0238..00000000 --- a/amarok/utilities/collectionscanner/charset-detector/src/nsCharSetProber.cpp +++ /dev/null @@ -1,130 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Universal charset detector code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 2001 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Shy Shalom - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#pragma GCC visibility push(hidden) - -#include "nsCharSetProber.h" -#include "prmem.h" - -//This filter applies to all scripts which do not use English characters -PRBool nsCharSetProber::FilterWithoutEnglishLetters(const char* aBuf, PRUint32 aLen, char** newBuf, PRUint32& newLen) -{ - char *newptr; - char *prevPtr, *curPtr; - - PRBool meetMSB = PR_FALSE; - newptr = *newBuf = (char*)PR_Malloc(aLen); - if (!newptr) - return PR_FALSE; - - for (curPtr = prevPtr = (char*)aBuf; curPtr < aBuf+aLen; curPtr++) - { - if (*curPtr & 0x80) - { - meetMSB = PR_TRUE; - } - else if (*curPtr < 'A' || (*curPtr > 'Z' && *curPtr < 'a') || *curPtr > 'z') - { - //current char is a symbol, most likely a punctuation. we treat it as segment delimiter - if (meetMSB && curPtr > prevPtr) - //this segment contains more than single symbol, and it has upper ASCII, we need to keep it - { - while (prevPtr < curPtr) *newptr++ = *prevPtr++; - prevPtr++; - *newptr++ = ' '; - meetMSB = PR_FALSE; - } - else //ignore current segment. (either because it is just a symbol or just an English word) - prevPtr = curPtr+1; - } - } - if (meetMSB && curPtr > prevPtr) - while (prevPtr < curPtr) *newptr++ = *prevPtr++; - - newLen = newptr - *newBuf; - - return PR_TRUE; -} - -//This filter applies to all scripts which contain both English characters and upper ASCII characters. -PRBool nsCharSetProber::FilterWithEnglishLetters(const char* aBuf, PRUint32 aLen, char** newBuf, PRUint32& newLen) -{ - //do filtering to reduce load to probers - char *newptr; - char *prevPtr, *curPtr; - PRBool isInTag = PR_FALSE; - - newptr = *newBuf = (char*)PR_Malloc(aLen); - if (!newptr) - return PR_FALSE; - - for (curPtr = prevPtr = (char*)aBuf; curPtr < aBuf+aLen; curPtr++) - { - if (*curPtr == '>') - isInTag = PR_FALSE; - else if (*curPtr == '<') - isInTag = PR_TRUE; - - if (!(*curPtr & 0x80) && - (*curPtr < 'A' || (*curPtr > 'Z' && *curPtr < 'a') || *curPtr > 'z') ) - { - if (curPtr > prevPtr && !isInTag) // Current segment contains more than just a symbol - // and it is not inside a tag, keep it. - { - while (prevPtr < curPtr) *newptr++ = *prevPtr++; - prevPtr++; - *newptr++ = ' '; - } - else - prevPtr = curPtr+1; - } - } - - // If the current segment contains more than just a symbol - // and it is not inside a tag then keep it. - if (!isInTag) - while (prevPtr < curPtr) - *newptr++ = *prevPtr++; - - newLen = newptr - *newBuf; - - return PR_TRUE; -} - -#pragma GCC visibility pop - diff --git a/amarok/utilities/collectionscanner/charset-detector/src/nsCharSetProber.h b/amarok/utilities/collectionscanner/charset-detector/src/nsCharSetProber.h deleted file mode 100644 index b1383347..00000000 --- a/amarok/utilities/collectionscanner/charset-detector/src/nsCharSetProber.h +++ /dev/null @@ -1,81 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Universal charset detector code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 2001 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Shy Shalom - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ -#ifndef nsCharSetProber_h__ -#define nsCharSetProber_h__ - -#include "nscore.h" - -//#define DEBUG_chardet // Uncomment this for debug dump. - -typedef enum { - eDetecting = 0, //We are still detecting, no sure answer yet, but caller can ask for confidence. - eFoundIt = 1, //That's a positive answer - eNotMe = 2 //Negative answer -} nsProbingState; - -#define SHORTCUT_THRESHOLD (float)0.95 - -class nsCharSetProber { -public: - virtual ~nsCharSetProber() {}; - virtual const char* GetCharSetName() = 0; - virtual nsProbingState HandleData(const char* aBuf, PRUint32 aLen) = 0; - virtual nsProbingState GetState(void) = 0; - virtual void Reset(void) = 0; - virtual float GetConfidence(void) = 0; - virtual void SetOpion() = 0; - -#ifdef DEBUG_chardet - virtual void DumpStatus() {}; -#endif - - // Helper functions used in the Latin1 and Group probers. - // both functions Allocate a new buffer for newBuf. This buffer should be - // freed by the caller using PR_FREEIF. - // Both functions return PR_FALSE in case of memory allocation failure. - static PRBool FilterWithoutEnglishLetters(const char* aBuf, PRUint32 aLen, char** newBuf, PRUint32& newLen); - static PRBool FilterWithEnglishLetters(const char* aBuf, PRUint32 aLen, char** newBuf, PRUint32& newLen); -}; - -class nsCharSetProberHelper { -public: - nsCharSetProberHelper() { mLastChar[0] = mLastChar[1] = 0; } -protected: - char mLastChar[2]; -}; -#endif /* nsCharSetProber_h__ */ diff --git a/amarok/utilities/collectionscanner/charset-detector/src/nsCodingStateMachine.h b/amarok/utilities/collectionscanner/charset-detector/src/nsCodingStateMachine.h deleted file mode 100644 index d5d49d79..00000000 --- a/amarok/utilities/collectionscanner/charset-detector/src/nsCodingStateMachine.h +++ /dev/null @@ -1,110 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ -#ifndef nsCodingStateMachine_h__ -#define nsCodingStateMachine_h__ - -#include "nsPkgInt.h" - -typedef enum { - eStart = 0, - eError = 1, - eItsMe = 2 -} nsSMState; - -#define GETCLASS(c) GETFROMPCK(((unsigned char)(c)), mModel->classTable) - -//state machine model -typedef struct -{ - nsPkgInt classTable; - PRUint32 classFactor; - nsPkgInt stateTable; - const PRUint32* charLenTable; - const char* name; -} SMModel; - -class nsCodingStateMachine { -public: - nsCodingStateMachine(SMModel* sm){ - mCurrentState = eStart; - mCurrentCharLen = 0; - mCurrentBytePos = 0; - mModel = sm; - }; - nsSMState NextState(char c){ - //for each byte we get its class , if it is first byte, we also get byte length - PRUint32 byteCls = GETCLASS(c); - if (mCurrentState == eStart) - { - mCurrentBytePos = 0; - mCurrentCharLen = mModel->charLenTable[byteCls]; - } - //from byte's class and stateTable, we get its next state - mCurrentState=(nsSMState)GETFROMPCK(mCurrentState*(mModel->classFactor)+byteCls, - mModel->stateTable); - mCurrentBytePos++; - return mCurrentState; - }; - PRUint32 GetCurrentCharLen(void) {return mCurrentCharLen;}; - void Reset(void) {mCurrentState = eStart;}; - const char * GetCodingStateMachine() {return mModel->name;}; - -protected: - nsSMState mCurrentState; - PRUint32 mCurrentCharLen; - PRUint32 mCurrentBytePos; - - SMModel *mModel; -}; - -extern SMModel UTF8SMModel; -extern SMModel Big5SMModel; -extern SMModel EUCJPSMModel; -extern SMModel EUCKRSMModel; -extern SMModel EUCTWSMModel; -extern SMModel GB18030SMModel; -extern SMModel SJISSMModel; -extern SMModel UCS2BESMModel; - - -extern SMModel HZSMModel; -extern SMModel ISO2022CNSMModel; -extern SMModel ISO2022JPSMModel; -extern SMModel ISO2022KRSMModel; - -#endif /* nsCodingStateMachine_h__ */ - diff --git a/amarok/utilities/collectionscanner/charset-detector/src/nsEUCJPProber.cpp b/amarok/utilities/collectionscanner/charset-detector/src/nsEUCJPProber.cpp deleted file mode 100644 index 3e002ce5..00000000 --- a/amarok/utilities/collectionscanner/charset-detector/src/nsEUCJPProber.cpp +++ /dev/null @@ -1,108 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -// for japanese encoding, obeserve characteristic: -// 1, kana character (or hankaku?) often have hight frequency of appereance -// 2, kana character often exist in group -// 3, certain combination of kana is never used in japanese language - -#pragma GCC visibility push(hidden) - -#include "nsEUCJPProber.h" - -void nsEUCJPProber::Reset(void) -{ - mCodingSM->Reset(); - mState = eDetecting; - mContextAnalyser.Reset(); - mDistributionAnalyser.Reset(); -} - -nsProbingState nsEUCJPProber::HandleData(const char* aBuf, PRUint32 aLen) -{ - nsSMState codingState; - - for (PRUint32 i = 0; i < aLen; i++) - { - codingState = mCodingSM->NextState(aBuf[i]); - if (codingState == eError) - { - mState = eNotMe; - break; - } - if (codingState == eItsMe) - { - mState = eFoundIt; - break; - } - if (codingState == eStart) - { - PRUint32 charLen = mCodingSM->GetCurrentCharLen(); - - if (i == 0) - { - mLastChar[1] = aBuf[0]; - mContextAnalyser.HandleOneChar(mLastChar, charLen); - mDistributionAnalyser.HandleOneChar(mLastChar, charLen); - } - else - { - mContextAnalyser.HandleOneChar(aBuf+i-1, charLen); - mDistributionAnalyser.HandleOneChar(aBuf+i-1, charLen); - } - } - } - - mLastChar[0] = aBuf[aLen-1]; - - if (mState == eDetecting) - if (mContextAnalyser.GotEnoughData() && GetConfidence() > SHORTCUT_THRESHOLD) - mState = eFoundIt; - - return mState; -} - -float nsEUCJPProber::GetConfidence(void) -{ - float contxtCf = mContextAnalyser.GetConfidence(); - float distribCf = mDistributionAnalyser.GetConfidence(); - - return (contxtCf > distribCf ? contxtCf : distribCf); -} - -#pragma GCC visibility pop - diff --git a/amarok/utilities/collectionscanner/charset-detector/src/nsEUCJPProber.h b/amarok/utilities/collectionscanner/charset-detector/src/nsEUCJPProber.h deleted file mode 100644 index cdbc9186..00000000 --- a/amarok/utilities/collectionscanner/charset-detector/src/nsEUCJPProber.h +++ /dev/null @@ -1,73 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -// for S-JIS encoding, obeserve characteristic: -// 1, kana character (or hankaku?) often have hight frequency of appereance -// 2, kana character often exist in group -// 3, certain combination of kana is never used in japanese language - -#ifndef nsEUCJPProber_h__ -#define nsEUCJPProber_h__ - -#include "nsCharSetProber.h" -#include "nsCodingStateMachine.h" -#include "JpCntx.h" -#include "CharDistribution.h" - -class nsEUCJPProber: public nsCharSetProber, nsCharSetProberHelper { -public: - nsEUCJPProber(void){mCodingSM = new nsCodingStateMachine(&EUCJPSMModel); - Reset();}; - virtual ~nsEUCJPProber(void){delete mCodingSM;}; - nsProbingState HandleData(const char* aBuf, PRUint32 aLen); - const char* GetCharSetName() {return "EUC-JP";}; - nsProbingState GetState(void) {return mState;}; - void Reset(void); - float GetConfidence(void); - void SetOpion() {}; - -protected: - nsCodingStateMachine* mCodingSM; - nsProbingState mState; - - EUCJPContextAnalysis mContextAnalyser; - EUCJPDistributionAnalysis mDistributionAnalyser; -}; - - -#endif /* nsEUCJPProber_h__ */ - diff --git a/amarok/utilities/collectionscanner/charset-detector/src/nsEUCKRProber.cpp b/amarok/utilities/collectionscanner/charset-detector/src/nsEUCKRProber.cpp deleted file mode 100644 index 77ad3651..00000000 --- a/amarok/utilities/collectionscanner/charset-detector/src/nsEUCKRProber.cpp +++ /dev/null @@ -1,100 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#pragma GCC visibility push(hidden) - -#include "nsEUCKRProber.h" - -void nsEUCKRProber::Reset(void) -{ - mCodingSM->Reset(); - mState = eDetecting; - mDistributionAnalyser.Reset(); - //mContextAnalyser.Reset(); -} - -nsProbingState nsEUCKRProber::HandleData(const char* aBuf, PRUint32 aLen) -{ - nsSMState codingState; - - for (PRUint32 i = 0; i < aLen; i++) - { - codingState = mCodingSM->NextState(aBuf[i]); - if (codingState == eError) - { - mState = eNotMe; - break; - } - if (codingState == eItsMe) - { - mState = eFoundIt; - break; - } - if (codingState == eStart) - { - PRUint32 charLen = mCodingSM->GetCurrentCharLen(); - - if (i == 0) - { - mLastChar[1] = aBuf[0]; - mDistributionAnalyser.HandleOneChar(mLastChar, charLen); - } - else - mDistributionAnalyser.HandleOneChar(aBuf+i-1, charLen); - } - } - - mLastChar[0] = aBuf[aLen-1]; - - if (mState == eDetecting) - if (mDistributionAnalyser.GotEnoughData() && GetConfidence() > SHORTCUT_THRESHOLD) - mState = eFoundIt; -// else -// mDistributionAnalyser.HandleData(aBuf, aLen); - - return mState; -} - -float nsEUCKRProber::GetConfidence(void) -{ - float distribCf = mDistributionAnalyser.GetConfidence(); - - return (float)distribCf; -} - -#pragma GCC visibility pop - diff --git a/amarok/utilities/collectionscanner/charset-detector/src/nsEUCKRProber.h b/amarok/utilities/collectionscanner/charset-detector/src/nsEUCKRProber.h deleted file mode 100644 index 8b5385b5..00000000 --- a/amarok/utilities/collectionscanner/charset-detector/src/nsEUCKRProber.h +++ /dev/null @@ -1,69 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef nsEUCKRProber_h__ -#define nsEUCKRProber_h__ - -#include "nsCharSetProber.h" -#include "nsCodingStateMachine.h" -#include "CharDistribution.h" - -class nsEUCKRProber: public nsCharSetProber, nsCharSetProberHelper { -public: - nsEUCKRProber(void){mCodingSM = new nsCodingStateMachine(&EUCKRSMModel); - Reset();}; - virtual ~nsEUCKRProber(void){delete mCodingSM;}; - nsProbingState HandleData(const char* aBuf, PRUint32 aLen); - const char* GetCharSetName() {return "EUC-KR";}; - nsProbingState GetState(void) {return mState;}; - void Reset(void); - float GetConfidence(void); - void SetOpion() {}; - -protected: - void GetDistribution(PRUint32 aCharLen, const char* aStr); - - nsCodingStateMachine* mCodingSM; - nsProbingState mState; - - //EUCKRContextAnalysis mContextAnalyser; - EUCKRDistributionAnalysis mDistributionAnalyser; -}; - - -#endif /* nsEUCKRProber_h__ */ - diff --git a/amarok/utilities/collectionscanner/charset-detector/src/nsEUCTWProber.cpp b/amarok/utilities/collectionscanner/charset-detector/src/nsEUCTWProber.cpp deleted file mode 100644 index a97183a5..00000000 --- a/amarok/utilities/collectionscanner/charset-detector/src/nsEUCTWProber.cpp +++ /dev/null @@ -1,100 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#pragma GCC visibility push(hidden) - -#include "nsEUCTWProber.h" - -void nsEUCTWProber::Reset(void) -{ - mCodingSM->Reset(); - mState = eDetecting; - mDistributionAnalyser.Reset(); - //mContextAnalyser.Reset(); -} - -nsProbingState nsEUCTWProber::HandleData(const char* aBuf, PRUint32 aLen) -{ - nsSMState codingState; - - for (PRUint32 i = 0; i < aLen; i++) - { - codingState = mCodingSM->NextState(aBuf[i]); - if (codingState == eError) - { - mState = eNotMe; - break; - } - if (codingState == eItsMe) - { - mState = eFoundIt; - break; - } - if (codingState == eStart) - { - PRUint32 charLen = mCodingSM->GetCurrentCharLen(); - - if (i == 0) - { - mLastChar[1] = aBuf[0]; - mDistributionAnalyser.HandleOneChar(mLastChar, charLen); - } - else - mDistributionAnalyser.HandleOneChar(aBuf+i-1, charLen); - } - } - - mLastChar[0] = aBuf[aLen-1]; - - if (mState == eDetecting) - if (mDistributionAnalyser.GotEnoughData() && GetConfidence() > SHORTCUT_THRESHOLD) - mState = eFoundIt; -// else -// mDistributionAnalyser.HandleData(aBuf, aLen); - - return mState; -} - -float nsEUCTWProber::GetConfidence(void) -{ - float distribCf = mDistributionAnalyser.GetConfidence(); - - return (float)distribCf; -} - -#pragma GCC visibility pop - diff --git a/amarok/utilities/collectionscanner/charset-detector/src/nsEUCTWProber.h b/amarok/utilities/collectionscanner/charset-detector/src/nsEUCTWProber.h deleted file mode 100644 index 8605ce14..00000000 --- a/amarok/utilities/collectionscanner/charset-detector/src/nsEUCTWProber.h +++ /dev/null @@ -1,69 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef nsEUCTWProber_h__ -#define nsEUCTWProber_h__ - -#include "nsCharSetProber.h" -#include "nsCodingStateMachine.h" -#include "CharDistribution.h" - -class nsEUCTWProber: public nsCharSetProber, nsCharSetProberHelper { -public: - nsEUCTWProber(void){mCodingSM = new nsCodingStateMachine(&EUCTWSMModel); - Reset();}; - virtual ~nsEUCTWProber(void){delete mCodingSM;}; - nsProbingState HandleData(const char* aBuf, PRUint32 aLen); - const char* GetCharSetName() {return "x-euc-tw";}; - nsProbingState GetState(void) {return mState;}; - void Reset(void); - float GetConfidence(void); - void SetOpion() {}; - -protected: - void GetDistribution(PRUint32 aCharLen, const char* aStr); - - nsCodingStateMachine* mCodingSM; - nsProbingState mState; - - //EUCTWContextAnalysis mContextAnalyser; - EUCTWDistributionAnalysis mDistributionAnalyser; -}; - - -#endif /* nsEUCTWProber_h__ */ - diff --git a/amarok/utilities/collectionscanner/charset-detector/src/nsEscCharsetProber.cpp b/amarok/utilities/collectionscanner/charset-detector/src/nsEscCharsetProber.cpp deleted file mode 100644 index fd954a72..00000000 --- a/amarok/utilities/collectionscanner/charset-detector/src/nsEscCharsetProber.cpp +++ /dev/null @@ -1,110 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#pragma GCC visibility push(hidden) - -#include "nsEscCharsetProber.h" - -nsEscCharSetProber::nsEscCharSetProber(void) -{ - mCodingSM[0] = new nsCodingStateMachine(&HZSMModel); - mCodingSM[1] = new nsCodingStateMachine(&ISO2022CNSMModel); - mCodingSM[2] = new nsCodingStateMachine(&ISO2022JPSMModel); - mCodingSM[3] = new nsCodingStateMachine(&ISO2022KRSMModel); - mActiveSM = NUM_OF_ESC_CHARSETS; - mState = eDetecting; - mDetectedCharset = nsnull; -} - -nsEscCharSetProber::~nsEscCharSetProber(void) -{ - for (PRUint32 i = 0; i < NUM_OF_ESC_CHARSETS; i++) - delete mCodingSM[i]; -} - -void nsEscCharSetProber::Reset(void) -{ - mState = eDetecting; - for (PRUint32 i = 0; i < NUM_OF_ESC_CHARSETS; i++) - mCodingSM[i]->Reset(); - mActiveSM = NUM_OF_ESC_CHARSETS; - mDetectedCharset = nsnull; -} - -nsProbingState nsEscCharSetProber::HandleData(const char* aBuf, PRUint32 aLen) -{ - nsSMState codingState; - PRInt32 j; - PRUint32 i; - - for ( i = 0; i < aLen && mState == eDetecting; i++) - { - for (j = mActiveSM-1; j>= 0; j--) - { - //byte is feed to all active state machine - codingState = mCodingSM[j]->NextState(aBuf[i]); - if (codingState == eError) - { - //got negative answer for this state machine, make it inactive - mActiveSM--; - if (mActiveSM == 0) - { - mState = eNotMe; - return mState; - } - else if (j != (PRInt32)mActiveSM) - { - nsCodingStateMachine* t; - t = mCodingSM[mActiveSM]; - mCodingSM[mActiveSM] = mCodingSM[j]; - mCodingSM[j] = t; - } - } - else if (codingState == eItsMe) - { - mState = eFoundIt; - mDetectedCharset = mCodingSM[j]->GetCodingStateMachine(); - return mState; - } - } - } - - return mState; -} - -#pragma GCC visibility pop - diff --git a/amarok/utilities/collectionscanner/charset-detector/src/nsEscCharsetProber.h b/amarok/utilities/collectionscanner/charset-detector/src/nsEscCharsetProber.h deleted file mode 100644 index 5df54279..00000000 --- a/amarok/utilities/collectionscanner/charset-detector/src/nsEscCharsetProber.h +++ /dev/null @@ -1,67 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef nsEscCharSetProber_h__ -#define nsEscCharSetProber_h__ - -#include "nsCharSetProber.h" -#include "nsCodingStateMachine.h" - -#define NUM_OF_ESC_CHARSETS 4 - -class nsEscCharSetProber: public nsCharSetProber { -public: - nsEscCharSetProber(void); - virtual ~nsEscCharSetProber(void); - nsProbingState HandleData(const char* aBuf, PRUint32 aLen); - const char* GetCharSetName() {return mDetectedCharset;}; - nsProbingState GetState(void) {return mState;}; - void Reset(void); - float GetConfidence(void){return (float)0.99;}; - void SetOpion() {}; - -protected: - void GetDistribution(PRUint32 aCharLen, const char* aStr); - - nsCodingStateMachine* mCodingSM[NUM_OF_ESC_CHARSETS] ; - PRUint32 mActiveSM; - nsProbingState mState; - const char * mDetectedCharset; -}; - -#endif /* nsEscCharSetProber_h__ */ - diff --git a/amarok/utilities/collectionscanner/charset-detector/src/nsEscSM.cpp b/amarok/utilities/collectionscanner/charset-detector/src/nsEscSM.cpp deleted file mode 100644 index 4e54fc87..00000000 --- a/amarok/utilities/collectionscanner/charset-detector/src/nsEscSM.cpp +++ /dev/null @@ -1,268 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#pragma GCC visibility push(hidden) - -#include "nsCodingStateMachine.h" - -static PRUint32 HZ_cls[ 256 / 8 ] = { -PCK4BITS(1,0,0,0,0,0,0,0), // 00 - 07 -PCK4BITS(0,0,0,0,0,0,0,0), // 08 - 0f -PCK4BITS(0,0,0,0,0,0,0,0), // 10 - 17 -PCK4BITS(0,0,0,1,0,0,0,0), // 18 - 1f -PCK4BITS(0,0,0,0,0,0,0,0), // 20 - 27 -PCK4BITS(0,0,0,0,0,0,0,0), // 28 - 2f -PCK4BITS(0,0,0,0,0,0,0,0), // 30 - 37 -PCK4BITS(0,0,0,0,0,0,0,0), // 38 - 3f -PCK4BITS(0,0,0,0,0,0,0,0), // 40 - 47 -PCK4BITS(0,0,0,0,0,0,0,0), // 48 - 4f -PCK4BITS(0,0,0,0,0,0,0,0), // 50 - 57 -PCK4BITS(0,0,0,0,0,0,0,0), // 58 - 5f -PCK4BITS(0,0,0,0,0,0,0,0), // 60 - 67 -PCK4BITS(0,0,0,0,0,0,0,0), // 68 - 6f -PCK4BITS(0,0,0,0,0,0,0,0), // 70 - 77 -PCK4BITS(0,0,0,4,0,5,2,0), // 78 - 7f -PCK4BITS(1,1,1,1,1,1,1,1), // 80 - 87 -PCK4BITS(1,1,1,1,1,1,1,1), // 88 - 8f -PCK4BITS(1,1,1,1,1,1,1,1), // 90 - 97 -PCK4BITS(1,1,1,1,1,1,1,1), // 98 - 9f -PCK4BITS(1,1,1,1,1,1,1,1), // a0 - a7 -PCK4BITS(1,1,1,1,1,1,1,1), // a8 - af -PCK4BITS(1,1,1,1,1,1,1,1), // b0 - b7 -PCK4BITS(1,1,1,1,1,1,1,1), // b8 - bf -PCK4BITS(1,1,1,1,1,1,1,1), // c0 - c7 -PCK4BITS(1,1,1,1,1,1,1,1), // c8 - cf -PCK4BITS(1,1,1,1,1,1,1,1), // d0 - d7 -PCK4BITS(1,1,1,1,1,1,1,1), // d8 - df -PCK4BITS(1,1,1,1,1,1,1,1), // e0 - e7 -PCK4BITS(1,1,1,1,1,1,1,1), // e8 - ef -PCK4BITS(1,1,1,1,1,1,1,1), // f0 - f7 -PCK4BITS(1,1,1,1,1,1,1,1) // f8 - ff -}; - - -static PRUint32 HZ_st [ 6] = { -PCK4BITS(eStart,eError, 3,eStart,eStart,eStart,eError,eError),//00-07 -PCK4BITS(eError,eError,eError,eError,eItsMe,eItsMe,eItsMe,eItsMe),//08-0f -PCK4BITS(eItsMe,eItsMe,eError,eError,eStart,eStart, 4,eError),//10-17 -PCK4BITS( 5,eError, 6,eError, 5, 5, 4,eError),//18-1f -PCK4BITS( 4,eError, 4, 4, 4,eError, 4,eError),//20-27 -PCK4BITS( 4,eItsMe,eStart,eStart,eStart,eStart,eStart,eStart) //28-2f -}; - -static const PRUint32 HZCharLenTable[] = {0, 0, 0, 0, 0, 0}; - -SMModel HZSMModel = { - {eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, HZ_cls }, - 6, - {eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, HZ_st }, - HZCharLenTable, - "HZ-GB-2312", -}; - - -static PRUint32 ISO2022CN_cls [ 256 / 8 ] = { -PCK4BITS(2,0,0,0,0,0,0,0), // 00 - 07 -PCK4BITS(0,0,0,0,0,0,0,0), // 08 - 0f -PCK4BITS(0,0,0,0,0,0,0,0), // 10 - 17 -PCK4BITS(0,0,0,1,0,0,0,0), // 18 - 1f -PCK4BITS(0,0,0,0,0,0,0,0), // 20 - 27 -PCK4BITS(0,3,0,0,0,0,0,0), // 28 - 2f -PCK4BITS(0,0,0,0,0,0,0,0), // 30 - 37 -PCK4BITS(0,0,0,0,0,0,0,0), // 38 - 3f -PCK4BITS(0,0,0,4,0,0,0,0), // 40 - 47 -PCK4BITS(0,0,0,0,0,0,0,0), // 48 - 4f -PCK4BITS(0,0,0,0,0,0,0,0), // 50 - 57 -PCK4BITS(0,0,0,0,0,0,0,0), // 58 - 5f -PCK4BITS(0,0,0,0,0,0,0,0), // 60 - 67 -PCK4BITS(0,0,0,0,0,0,0,0), // 68 - 6f -PCK4BITS(0,0,0,0,0,0,0,0), // 70 - 77 -PCK4BITS(0,0,0,0,0,0,0,0), // 78 - 7f -PCK4BITS(2,2,2,2,2,2,2,2), // 80 - 87 -PCK4BITS(2,2,2,2,2,2,2,2), // 88 - 8f -PCK4BITS(2,2,2,2,2,2,2,2), // 90 - 97 -PCK4BITS(2,2,2,2,2,2,2,2), // 98 - 9f -PCK4BITS(2,2,2,2,2,2,2,2), // a0 - a7 -PCK4BITS(2,2,2,2,2,2,2,2), // a8 - af -PCK4BITS(2,2,2,2,2,2,2,2), // b0 - b7 -PCK4BITS(2,2,2,2,2,2,2,2), // b8 - bf -PCK4BITS(2,2,2,2,2,2,2,2), // c0 - c7 -PCK4BITS(2,2,2,2,2,2,2,2), // c8 - cf -PCK4BITS(2,2,2,2,2,2,2,2), // d0 - d7 -PCK4BITS(2,2,2,2,2,2,2,2), // d8 - df -PCK4BITS(2,2,2,2,2,2,2,2), // e0 - e7 -PCK4BITS(2,2,2,2,2,2,2,2), // e8 - ef -PCK4BITS(2,2,2,2,2,2,2,2), // f0 - f7 -PCK4BITS(2,2,2,2,2,2,2,2) // f8 - ff -}; - - -static PRUint32 ISO2022CN_st [ 8] = { -PCK4BITS(eStart, 3,eError,eStart,eStart,eStart,eStart,eStart),//00-07 -PCK4BITS(eStart,eError,eError,eError,eError,eError,eError,eError),//08-0f -PCK4BITS(eError,eError,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe),//10-17 -PCK4BITS(eItsMe,eItsMe,eItsMe,eError,eError,eError, 4,eError),//18-1f -PCK4BITS(eError,eError,eError,eItsMe,eError,eError,eError,eError),//20-27 -PCK4BITS( 5, 6,eError,eError,eError,eError,eError,eError),//28-2f -PCK4BITS(eError,eError,eError,eItsMe,eError,eError,eError,eError),//30-37 -PCK4BITS(eError,eError,eError,eError,eError,eItsMe,eError,eStart) //38-3f -}; - -static const PRUint32 ISO2022CNCharLenTable[] = {0, 0, 0, 0, 0, 0, 0, 0, 0}; - -SMModel ISO2022CNSMModel = { - {eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, ISO2022CN_cls }, - 9, - {eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, ISO2022CN_st }, - ISO2022CNCharLenTable, - "ISO-2022-CN", -}; - -static PRUint32 ISO2022JP_cls [ 256 / 8 ] = { -PCK4BITS(2,0,0,0,0,0,0,0), // 00 - 07 -PCK4BITS(0,0,0,0,0,0,2,2), // 08 - 0f -PCK4BITS(0,0,0,0,0,0,0,0), // 10 - 17 -PCK4BITS(0,0,0,1,0,0,0,0), // 18 - 1f -PCK4BITS(0,0,0,0,7,0,0,0), // 20 - 27 -PCK4BITS(3,0,0,0,0,0,0,0), // 28 - 2f -PCK4BITS(0,0,0,0,0,0,0,0), // 30 - 37 -PCK4BITS(0,0,0,0,0,0,0,0), // 38 - 3f -PCK4BITS(6,0,4,0,8,0,0,0), // 40 - 47 -PCK4BITS(0,9,5,0,0,0,0,0), // 48 - 4f -PCK4BITS(0,0,0,0,0,0,0,0), // 50 - 57 -PCK4BITS(0,0,0,0,0,0,0,0), // 58 - 5f -PCK4BITS(0,0,0,0,0,0,0,0), // 60 - 67 -PCK4BITS(0,0,0,0,0,0,0,0), // 68 - 6f -PCK4BITS(0,0,0,0,0,0,0,0), // 70 - 77 -PCK4BITS(0,0,0,0,0,0,0,0), // 78 - 7f -PCK4BITS(2,2,2,2,2,2,2,2), // 80 - 87 -PCK4BITS(2,2,2,2,2,2,2,2), // 88 - 8f -PCK4BITS(2,2,2,2,2,2,2,2), // 90 - 97 -PCK4BITS(2,2,2,2,2,2,2,2), // 98 - 9f -PCK4BITS(2,2,2,2,2,2,2,2), // a0 - a7 -PCK4BITS(2,2,2,2,2,2,2,2), // a8 - af -PCK4BITS(2,2,2,2,2,2,2,2), // b0 - b7 -PCK4BITS(2,2,2,2,2,2,2,2), // b8 - bf -PCK4BITS(2,2,2,2,2,2,2,2), // c0 - c7 -PCK4BITS(2,2,2,2,2,2,2,2), // c8 - cf -PCK4BITS(2,2,2,2,2,2,2,2), // d0 - d7 -PCK4BITS(2,2,2,2,2,2,2,2), // d8 - df -PCK4BITS(2,2,2,2,2,2,2,2), // e0 - e7 -PCK4BITS(2,2,2,2,2,2,2,2), // e8 - ef -PCK4BITS(2,2,2,2,2,2,2,2), // f0 - f7 -PCK4BITS(2,2,2,2,2,2,2,2) // f8 - ff -}; - - -static PRUint32 ISO2022JP_st [ 9] = { -PCK4BITS(eStart, 3,eError,eStart,eStart,eStart,eStart,eStart),//00-07 -PCK4BITS(eStart,eStart,eError,eError,eError,eError,eError,eError),//08-0f -PCK4BITS(eError,eError,eError,eError,eItsMe,eItsMe,eItsMe,eItsMe),//10-17 -PCK4BITS(eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eError,eError),//18-1f -PCK4BITS(eError, 5,eError,eError,eError, 4,eError,eError),//20-27 -PCK4BITS(eError,eError,eError, 6,eItsMe,eError,eItsMe,eError),//28-2f -PCK4BITS(eError,eError,eError,eError,eError,eError,eItsMe,eItsMe),//30-37 -PCK4BITS(eError,eError,eError,eItsMe,eError,eError,eError,eError),//38-3f -PCK4BITS(eError,eError,eError,eError,eItsMe,eError,eStart,eStart) //40-47 -}; - -static const PRUint32 ISO2022JPCharLenTable[] = {0, 0, 0, 0, 0, 0, 0, 0}; - -SMModel ISO2022JPSMModel = { - {eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, ISO2022JP_cls }, - 10, - {eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, ISO2022JP_st }, - ISO2022JPCharLenTable, - "ISO-2022-JP", -}; - -static PRUint32 ISO2022KR_cls [ 256 / 8 ] = { -PCK4BITS(2,0,0,0,0,0,0,0), // 00 - 07 -PCK4BITS(0,0,0,0,0,0,0,0), // 08 - 0f -PCK4BITS(0,0,0,0,0,0,0,0), // 10 - 17 -PCK4BITS(0,0,0,1,0,0,0,0), // 18 - 1f -PCK4BITS(0,0,0,0,3,0,0,0), // 20 - 27 -PCK4BITS(0,4,0,0,0,0,0,0), // 28 - 2f -PCK4BITS(0,0,0,0,0,0,0,0), // 30 - 37 -PCK4BITS(0,0,0,0,0,0,0,0), // 38 - 3f -PCK4BITS(0,0,0,5,0,0,0,0), // 40 - 47 -PCK4BITS(0,0,0,0,0,0,0,0), // 48 - 4f -PCK4BITS(0,0,0,0,0,0,0,0), // 50 - 57 -PCK4BITS(0,0,0,0,0,0,0,0), // 58 - 5f -PCK4BITS(0,0,0,0,0,0,0,0), // 60 - 67 -PCK4BITS(0,0,0,0,0,0,0,0), // 68 - 6f -PCK4BITS(0,0,0,0,0,0,0,0), // 70 - 77 -PCK4BITS(0,0,0,0,0,0,0,0), // 78 - 7f -PCK4BITS(2,2,2,2,2,2,2,2), // 80 - 87 -PCK4BITS(2,2,2,2,2,2,2,2), // 88 - 8f -PCK4BITS(2,2,2,2,2,2,2,2), // 90 - 97 -PCK4BITS(2,2,2,2,2,2,2,2), // 98 - 9f -PCK4BITS(2,2,2,2,2,2,2,2), // a0 - a7 -PCK4BITS(2,2,2,2,2,2,2,2), // a8 - af -PCK4BITS(2,2,2,2,2,2,2,2), // b0 - b7 -PCK4BITS(2,2,2,2,2,2,2,2), // b8 - bf -PCK4BITS(2,2,2,2,2,2,2,2), // c0 - c7 -PCK4BITS(2,2,2,2,2,2,2,2), // c8 - cf -PCK4BITS(2,2,2,2,2,2,2,2), // d0 - d7 -PCK4BITS(2,2,2,2,2,2,2,2), // d8 - df -PCK4BITS(2,2,2,2,2,2,2,2), // e0 - e7 -PCK4BITS(2,2,2,2,2,2,2,2), // e8 - ef -PCK4BITS(2,2,2,2,2,2,2,2), // f0 - f7 -PCK4BITS(2,2,2,2,2,2,2,2) // f8 - ff -}; - - -static PRUint32 ISO2022KR_st [ 5] = { -PCK4BITS(eStart, 3,eError,eStart,eStart,eStart,eError,eError),//00-07 -PCK4BITS(eError,eError,eError,eError,eItsMe,eItsMe,eItsMe,eItsMe),//08-0f -PCK4BITS(eItsMe,eItsMe,eError,eError,eError, 4,eError,eError),//10-17 -PCK4BITS(eError,eError,eError,eError, 5,eError,eError,eError),//18-1f -PCK4BITS(eError,eError,eError,eItsMe,eStart,eStart,eStart,eStart) //20-27 -}; - -static const PRUint32 ISO2022KRCharLenTable[] = {0, 0, 0, 0, 0, 0}; - -SMModel ISO2022KRSMModel = { - {eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, ISO2022KR_cls }, - 6, - {eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, ISO2022KR_st }, - ISO2022KRCharLenTable, - "ISO-2022-KR", -}; - -#pragma GCC visibility pop - diff --git a/amarok/utilities/collectionscanner/charset-detector/src/nsGB2312Prober.cpp b/amarok/utilities/collectionscanner/charset-detector/src/nsGB2312Prober.cpp deleted file mode 100644 index 52d8f10c..00000000 --- a/amarok/utilities/collectionscanner/charset-detector/src/nsGB2312Prober.cpp +++ /dev/null @@ -1,105 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -// for S-JIS encoding, obeserve characteristic: -// 1, kana character (or hankaku?) often have hight frequency of appereance -// 2, kana character often exist in group -// 3, certain combination of kana is never used in japanese language - -#pragma GCC visibility push(hidden) - -#include "nsGB2312Prober.h" - -void nsGB18030Prober::Reset(void) -{ - mCodingSM->Reset(); - mState = eDetecting; - mDistributionAnalyser.Reset(); - //mContextAnalyser.Reset(); -} - -nsProbingState nsGB18030Prober::HandleData(const char* aBuf, PRUint32 aLen) -{ - nsSMState codingState; - - for (PRUint32 i = 0; i < aLen; i++) - { - codingState = mCodingSM->NextState(aBuf[i]); - if (codingState == eError) - { - mState = eNotMe; - break; - } - if (codingState == eItsMe) - { - mState = eFoundIt; - break; - } - if (codingState == eStart) - { - PRUint32 charLen = mCodingSM->GetCurrentCharLen(); - - if (i == 0) - { - mLastChar[1] = aBuf[0]; - mDistributionAnalyser.HandleOneChar(mLastChar, charLen); - } - else - mDistributionAnalyser.HandleOneChar(aBuf+i-1, charLen); - } - } - - mLastChar[0] = aBuf[aLen-1]; - - if (mState == eDetecting) - if (mDistributionAnalyser.GotEnoughData() && GetConfidence() > SHORTCUT_THRESHOLD) - mState = eFoundIt; -// else -// mDistributionAnalyser.HandleData(aBuf, aLen); - - return mState; -} - -float nsGB18030Prober::GetConfidence(void) -{ - float distribCf = mDistributionAnalyser.GetConfidence(); - - return (float)distribCf; -} - -#pragma GCC visibility pop - diff --git a/amarok/utilities/collectionscanner/charset-detector/src/nsGB2312Prober.h b/amarok/utilities/collectionscanner/charset-detector/src/nsGB2312Prober.h deleted file mode 100644 index 20f92098..00000000 --- a/amarok/utilities/collectionscanner/charset-detector/src/nsGB2312Prober.h +++ /dev/null @@ -1,71 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef nsGB2312Prober_h__ -#define nsGB2312Prober_h__ - -#include "nsCharSetProber.h" -#include "nsCodingStateMachine.h" -#include "CharDistribution.h" - -// We use gb18030 to replace gb2312, because 18030 is a superset. - -class nsGB18030Prober: public nsCharSetProber, nsCharSetProberHelper { -public: - nsGB18030Prober(void){mCodingSM = new nsCodingStateMachine(&GB18030SMModel); - Reset();}; - virtual ~nsGB18030Prober(void){delete mCodingSM;}; - nsProbingState HandleData(const char* aBuf, PRUint32 aLen); - const char* GetCharSetName() {return "gb18030";}; - nsProbingState GetState(void) {return mState;}; - void Reset(void); - float GetConfidence(void); - void SetOpion() {}; - -protected: - void GetDistribution(PRUint32 aCharLen, const char* aStr); - - nsCodingStateMachine* mCodingSM; - nsProbingState mState; - - //GB2312ContextAnalysis mContextAnalyser; - GB2312DistributionAnalysis mDistributionAnalyser; -}; - - -#endif /* nsGB2312Prober_h__ */ - diff --git a/amarok/utilities/collectionscanner/charset-detector/src/nsHebrewProber.cpp b/amarok/utilities/collectionscanner/charset-detector/src/nsHebrewProber.cpp deleted file mode 100644 index 2a72a476..00000000 --- a/amarok/utilities/collectionscanner/charset-detector/src/nsHebrewProber.cpp +++ /dev/null @@ -1,199 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Universal charset detector code. - * - * The Initial Developer of the Original Code is - * Shy Shalom - * Portions created by the Initial Developer are Copyright (C) 2005 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#pragma GCC visibility push(hidden) - -#include "nsHebrewProber.h" -#include - -// windows-1255 / ISO-8859-8 code points of interest -#define FINAL_KAF ('\xea') -#define NORMAL_KAF ('\xeb') -#define FINAL_MEM ('\xed') -#define NORMAL_MEM ('\xee') -#define FINAL_NUN ('\xef') -#define NORMAL_NUN ('\xf0') -#define FINAL_PE ('\xf3') -#define NORMAL_PE ('\xf4') -#define FINAL_TSADI ('\xf5') -#define NORMAL_TSADI ('\xf6') - -// Minimum Visual vs Logical final letter score difference. -// If the difference is below this, don't rely solely on the final letter score distance. -#define MIN_FINAL_CHAR_DISTANCE (5) - -// Minimum Visual vs Logical model score difference. -// If the difference is below this, don't rely at all on the model score distance. -#define MIN_MODEL_DISTANCE (0.01) - -#define VISUAL_HEBREW_NAME ("ISO-8859-8") -#define LOGICAL_HEBREW_NAME ("windows-1255") - -PRBool nsHebrewProber::isFinal(char c) -{ - return ((c == FINAL_KAF) || (c == FINAL_MEM) || (c == FINAL_NUN) || (c == FINAL_PE) || (c == FINAL_TSADI)); -} - -PRBool nsHebrewProber::isNonFinal(char c) -{ - return ((c == NORMAL_KAF) || (c == NORMAL_MEM) || (c == NORMAL_NUN) || (c == NORMAL_PE)); - // The normal Tsadi is not a good Non-Final letter due to words like - // 'lechotet' (to chat) containing an apostrophe after the tsadi. This - // apostrophe is converted to a space in FilterWithoutEnglishLetters causing - // the Non-Final tsadi to appear at an end of a word even though this is not - // the case in the original text. - // The letters Pe and Kaf rarely display a related behavior of not being a - // good Non-Final letter. Words like 'Pop', 'Winamp' and 'Mubarak' for - // example legally end with a Non-Final Pe or Kaf. However, the benefit of - // these letters as Non-Final letters outweighs the damage since these words - // are quite rare. -} - -/** HandleData - * Final letter analysis for logical-visual decision. - * Look for evidence that the received buffer is either logical Hebrew or - * visual Hebrew. - * The following cases are checked: - * 1) A word longer than 1 letter, ending with a final letter. This is an - * indication that the text is laid out "naturally" since the final letter - * really appears at the end. +1 for logical score. - * 2) A word longer than 1 letter, ending with a Non-Final letter. In normal - * Hebrew, words ending with Kaf, Mem, Nun, Pe or Tsadi, should not end with - * the Non-Final form of that letter. Exceptions to this rule are mentioned - * above in isNonFinal(). This is an indication that the text is laid out - * backwards. +1 for visual score - * 3) A word longer than 1 letter, starting with a final letter. Final letters - * should not appear at the beginning of a word. This is an indication that - * the text is laid out backwards. +1 for visual score. - * - * The visual score and logical score are accumulated throughout the text and - * are finally checked against each other in GetCharSetName(). - * No checking for final letters in the middle of words is done since that case - * is not an indication for either Logical or Visual text. - * - * The input buffer should not contain any white spaces that are not (' ') - * or any low-ascii punctuation marks. - */ -nsProbingState nsHebrewProber::HandleData(const char* aBuf, PRUint32 aLen) -{ - // Both model probers say it's not them. No reason to continue. - if (GetState() == eNotMe) - return eNotMe; - - const char *curPtr, *endPtr = aBuf+aLen; - char cur; - - for (curPtr = (char*)aBuf; curPtr < endPtr; ++curPtr) - { - cur = *curPtr; - if (cur == ' ') // We stand on a space - a word just ended - { - if (mBeforePrev != ' ') // *(curPtr-2) was not a space so prev is not a 1 letter word - { - if (isFinal(mPrev)) // case (1) [-2:not space][-1:final letter][cur:space] - ++mFinalCharLogicalScore; - else if (isNonFinal(mPrev)) // case (2) [-2:not space][-1:Non-Final letter][cur:space] - ++mFinalCharVisualScore; - } - } - else // Not standing on a space - { - if ((mBeforePrev == ' ') && (isFinal(mPrev)) && (cur != ' ')) // case (3) [-2:space][-1:final letter][cur:not space] - ++mFinalCharVisualScore; - } - mBeforePrev = mPrev; - mPrev = cur; - } - - // Forever detecting, till the end or until both model probers return eNotMe (handled above). - return eDetecting; -} - -// Make the decision: is it Logical or Visual? -const char* nsHebrewProber::GetCharSetName() -{ - // If the final letter score distance is dominant enough, rely on it. - PRInt32 finalsub = mFinalCharLogicalScore - mFinalCharVisualScore; - if (finalsub >= MIN_FINAL_CHAR_DISTANCE) - return LOGICAL_HEBREW_NAME; - if (finalsub <= -(MIN_FINAL_CHAR_DISTANCE)) - return VISUAL_HEBREW_NAME; - - // It's not dominant enough, try to rely on the model scores instead. - float modelsub = mLogicalProb->GetConfidence() - mVisualProb->GetConfidence(); - if (modelsub > MIN_MODEL_DISTANCE) - return LOGICAL_HEBREW_NAME; - if (modelsub < -(MIN_MODEL_DISTANCE)) - return VISUAL_HEBREW_NAME; - - // Still no good, back to final letter distance, maybe it'll save the day. - if (finalsub < 0) - return VISUAL_HEBREW_NAME; - - // (finalsub > 0 - Logical) or (don't know what to do) default to Logical. - return LOGICAL_HEBREW_NAME; -} - - -void nsHebrewProber::Reset(void) -{ - mFinalCharLogicalScore = 0; - mFinalCharVisualScore = 0; - - // mPrev and mBeforePrev are initialized to space in order to simulate a word - // delimiter at the beginning of the data - mPrev = ' '; - mBeforePrev = ' '; -} - -nsProbingState nsHebrewProber::GetState(void) -{ - // Remain active as long as any of the model probers are active. - if ((mLogicalProb->GetState() == eNotMe) && (mVisualProb->GetState() == eNotMe)) - return eNotMe; - return eDetecting; -} - -#ifdef DEBUG_chardet -void nsHebrewProber::DumpStatus() -{ - printf(" HEB: %d - %d [Logical-Visual score]\r\n", mFinalCharLogicalScore, mFinalCharVisualScore); -} -#endif - -#pragma GCC visibility pop - diff --git a/amarok/utilities/collectionscanner/charset-detector/src/nsHebrewProber.h b/amarok/utilities/collectionscanner/charset-detector/src/nsHebrewProber.h deleted file mode 100644 index 9bb3a003..00000000 --- a/amarok/utilities/collectionscanner/charset-detector/src/nsHebrewProber.h +++ /dev/null @@ -1,176 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Universal charset detector code. - * - * The Initial Developer of the Original Code is - * Shy Shalom - * Portions created by the Initial Developer are Copyright (C) 2005 - * the Initial Developer: All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef nsHebrewProber_h__ -#define nsHebrewProber_h__ - -#include "nsSBCharSetProber.h" - -// This prober doesn't actually recognize a language or a charset. -// It is a helper prober for the use of the Hebrew model probers -class nsHebrewProber: public nsCharSetProber -{ -public: - nsHebrewProber(void) :mLogicalProb(0), mVisualProb(0) { Reset(); } - - virtual ~nsHebrewProber(void) {} - virtual nsProbingState HandleData(const char* aBuf, PRUint32 aLen); - virtual const char* GetCharSetName(); - virtual void Reset(void); - - virtual nsProbingState GetState(void); - - virtual float GetConfidence(void) { return (float)0.0; } - virtual void SetOpion() {}; - - void SetModelProbers(nsCharSetProber *logicalPrb, nsCharSetProber *visualPrb) - { mLogicalProb = logicalPrb; mVisualProb = visualPrb; } - -#ifdef DEBUG_chardet - virtual void DumpStatus(); -#endif - -protected: - static PRBool isFinal(char c); - static PRBool isNonFinal(char c); - - PRInt32 mFinalCharLogicalScore, mFinalCharVisualScore; - - // The two last characters seen in the previous buffer. - char mPrev, mBeforePrev; - - // These probers are owned by the group prober. - nsCharSetProber *mLogicalProb, *mVisualProb; -}; - -/** - * ** General ideas of the Hebrew charset recognition ** - * - * Four main charsets exist in Hebrew: - * "ISO-8859-8" - Visual Hebrew - * "windows-1255" - Logical Hebrew - * "ISO-8859-8-I" - Logical Hebrew - * "x-mac-hebrew" - ?? Logical Hebrew ?? - * - * Both "ISO" charsets use a completely identical set of code points, whereas - * "windows-1255" and "x-mac-hebrew" are two different proper supersets of - * these code points. windows-1255 defines additional characters in the range - * 0x80-0x9F as some misc punctuation marks as well as some Hebrew-specific - * diacritics and additional 'Yiddish' ligature letters in the range 0xc0-0xd6. - * x-mac-hebrew defines similar additional code points but with a different - * mapping. - * - * As far as an average Hebrew text with no diacritics is concerned, all four - * charsets are identical with respect to code points. Meaning that for the - * main Hebrew alphabet, all four map the same values to all 27 Hebrew letters - * (including final letters). - * - * The dominant difference between these charsets is their directionality. - * "Visual" directionality means that the text is ordered as if the renderer is - * not aware of a BIDI rendering algorithm. The renderer sees the text and - * draws it from left to right. The text itself when ordered naturally is read - * backwards. A buffer of Visual Hebrew generally looks like so: - * "[last word of first line spelled backwards] [whole line ordered backwards - * and spelled backwards] [first word of first line spelled backwards] - * [end of line] [last word of second line] ... etc' " - * adding punctuation marks, numbers and English text to visual text is - * naturally also "visual" and from left to right. - * - * "Logical" directionality means the text is ordered "naturally" according to - * the order it is read. It is the responsibility of the renderer to display - * the text from right to left. A BIDI algorithm is used to place general - * punctuation marks, numbers and English text in the text. - * - * Texts in x-mac-hebrew are almost impossible to find on the Internet. From - * what little evidence I could find, it seems that its general directionality - * is Logical. - * - * To sum up all of the above, the Hebrew probing mechanism knows about two - * charsets: - * Visual Hebrew - "ISO-8859-8" - backwards text - Words and sentences are - * backwards while line order is natural. For charset recognition purposes - * the line order is unimportant (In fact, for this implementation, even - * word order is unimportant). - * Logical Hebrew - "windows-1255" - normal, naturally ordered text. - * - * "ISO-8859-8-I" is a subset of windows-1255 and doesn't need to be - * specifically identified. - * "x-mac-hebrew" is also identified as windows-1255. A text in x-mac-hebrew - * that contain special punctuation marks or diacritics is displayed with - * some unconverted characters showing as question marks. This problem might - * be corrected using another model prober for x-mac-hebrew. Due to the fact - * that x-mac-hebrew texts are so rare, writing another model prober isn't - * worth the effort and performance hit. - * - * *** The Prober *** - * - * The prober is divided between two nsSBCharSetProbers and an nsHebrewProber, - * all of which are managed, created, fed data, inquired and deleted by the - * nsSBCSGroupProber. The two nsSBCharSetProbers identify that the text is in - * fact some kind of Hebrew, Logical or Visual. The final decision about which - * one is it is made by the nsHebrewProber by combining final-letter scores - * with the scores of the two nsSBCharSetProbers to produce a final answer. - * - * The nsSBCSGroupProber is responsible for stripping the original text of HTML - * tags, English characters, numbers, low-ASCII punctuation characters, spaces - * and new lines. It reduces any sequence of such characters to a single space. - * The buffer fed to each prober in the SBCS group prober is pure text in - * high-ASCII. - * The two nsSBCharSetProbers (model probers) share the same language model: - * Win1255Model. - * The first nsSBCharSetProber uses the model normally as any other - * nsSBCharSetProber does, to recognize windows-1255, upon which this model was - * built. The second nsSBCharSetProber is told to make the pair-of-letter - * lookup in the language model backwards. This in practice exactly simulates - * a visual Hebrew model using the windows-1255 logical Hebrew model. - * - * The nsHebrewProber is not using any language model. All it does is look for - * final-letter evidence suggesting the text is either logical Hebrew or visual - * Hebrew. Disjointed from the model probers, the results of the nsHebrewProber - * alone are meaningless. nsHebrewProber always returns 0.00 as confidence - * since it never identifies a charset by itself. Instead, the pointer to the - * nsHebrewProber is passed to the model probers as a helper "Name Prober". - * When the Group prober receives a positive identification from any prober, - * it asks for the name of the charset identified. If the prober queried is a - * Hebrew model prober, the model prober forwards the call to the - * nsHebrewProber to make the final decision. In the nsHebrewProber, the - * decision is made according to the final-letters scores maintained and Both - * model probers scores. The answer is returned in the form of the name of the - * charset identified, either "windows-1255" or "ISO-8859-8". - * - */ -#endif /* nsHebrewProber_h__ */ diff --git a/amarok/utilities/collectionscanner/charset-detector/src/nsLatin1Prober.cpp b/amarok/utilities/collectionscanner/charset-detector/src/nsLatin1Prober.cpp deleted file mode 100644 index 28708f25..00000000 --- a/amarok/utilities/collectionscanner/charset-detector/src/nsLatin1Prober.cpp +++ /dev/null @@ -1,185 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Universal charset detector code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 2001 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Shy Shalom - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#pragma GCC visibility push(hidden) - -#include "nsLatin1Prober.h" -#include "prmem.h" -#include - -#define UDF 0 // undefined -#define OTH 1 //other -#define ASC 2 // ascii capital letter -#define ASS 3 // ascii small letter -#define ACV 4 // accent capital vowel -#define ACO 5 // accent capital other -#define ASV 6 // accent small vowel -#define ASO 7 // accent small other -#define CLASS_NUM 8 // total classes - -static unsigned char Latin1_CharToClass[] = -{ - OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, // 00 - 07 - OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, // 08 - 0F - OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, // 10 - 17 - OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, // 18 - 1F - OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, // 20 - 27 - OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, // 28 - 2F - OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, // 30 - 37 - OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, // 38 - 3F - OTH, ASC, ASC, ASC, ASC, ASC, ASC, ASC, // 40 - 47 - ASC, ASC, ASC, ASC, ASC, ASC, ASC, ASC, // 48 - 4F - ASC, ASC, ASC, ASC, ASC, ASC, ASC, ASC, // 50 - 57 - ASC, ASC, ASC, OTH, OTH, OTH, OTH, OTH, // 58 - 5F - OTH, ASS, ASS, ASS, ASS, ASS, ASS, ASS, // 60 - 67 - ASS, ASS, ASS, ASS, ASS, ASS, ASS, ASS, // 68 - 6F - ASS, ASS, ASS, ASS, ASS, ASS, ASS, ASS, // 70 - 77 - ASS, ASS, ASS, OTH, OTH, OTH, OTH, OTH, // 78 - 7F - OTH, UDF, OTH, ASO, OTH, OTH, OTH, OTH, // 80 - 87 - OTH, OTH, ACO, OTH, ACO, UDF, ACO, UDF, // 88 - 8F - UDF, OTH, OTH, OTH, OTH, OTH, OTH, OTH, // 90 - 97 - OTH, OTH, ASO, OTH, ASO, UDF, ASO, ACO, // 98 - 9F - OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, // A0 - A7 - OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, // A8 - AF - OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, // B0 - B7 - OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, // B8 - BF - ACV, ACV, ACV, ACV, ACV, ACV, ACO, ACO, // C0 - C7 - ACV, ACV, ACV, ACV, ACV, ACV, ACV, ACV, // C8 - CF - ACO, ACO, ACV, ACV, ACV, ACV, ACV, OTH, // D0 - D7 - ACV, ACV, ACV, ACV, ACV, ACO, ACO, ACO, // D8 - DF - ASV, ASV, ASV, ASV, ASV, ASV, ASO, ASO, // E0 - E7 - ASV, ASV, ASV, ASV, ASV, ASV, ASV, ASV, // E8 - EF - ASO, ASO, ASV, ASV, ASV, ASV, ASV, OTH, // F0 - F7 - ASV, ASV, ASV, ASV, ASV, ASO, ASO, ASO, // F8 - FF -}; - - -/* 0 : illegal - 1 : very unlikely - 2 : normal - 3 : very likely -*/ -static unsigned char Latin1ClassModel[] = -{ -/* UDF OTH ASC ASS ACV ACO ASV ASO */ -/*UDF*/ 0, 0, 0, 0, 0, 0, 0, 0, -/*OTH*/ 0, 3, 3, 3, 3, 3, 3, 3, -/*ASC*/ 0, 3, 3, 3, 3, 3, 3, 3, -/*ASS*/ 0, 3, 3, 3, 1, 1, 3, 3, -/*ACV*/ 0, 3, 3, 3, 1, 2, 1, 2, -/*ACO*/ 0, 3, 3, 3, 3, 3, 3, 3, -/*ASV*/ 0, 3, 1, 3, 1, 1, 1, 3, -/*ASO*/ 0, 3, 1, 3, 1, 1, 3, 3, -}; - -void nsLatin1Prober::Reset(void) -{ - mState = eDetecting; - mLastCharClass = OTH; - for (int i = 0; i < FREQ_CAT_NUM; i++) - mFreqCounter[i] = 0; -} - - -nsProbingState nsLatin1Prober::HandleData(const char* aBuf, PRUint32 aLen) -{ - char *newBuf1 = 0; - PRUint32 newLen1 = 0; - - if (!FilterWithEnglishLetters(aBuf, aLen, &newBuf1, newLen1)) { - newBuf1 = (char*)aBuf; - newLen1 = aLen; - } - - unsigned char charClass; - unsigned char freq; - for (PRUint32 i = 0; i < newLen1; i++) - { - charClass = Latin1_CharToClass[(unsigned char)newBuf1[i]]; - freq = Latin1ClassModel[mLastCharClass*CLASS_NUM + charClass]; - if (freq == 0) { - mState = eNotMe; - break; - } - mFreqCounter[freq]++; - mLastCharClass = charClass; - } - - if (newBuf1 != aBuf) - PR_FREEIF(newBuf1); - - return mState; -} - -float nsLatin1Prober::GetConfidence(void) -{ - if (mState == eNotMe) - return 0.01f; - - float confidence; - PRUint32 total = 0; - for (PRInt32 i = 0; i < FREQ_CAT_NUM; i++) - total += mFreqCounter[i]; - - if(!total) - confidence = 0.0f; - else - { - confidence = mFreqCounter[3]*1.0f / total; - confidence -= mFreqCounter[1]*20.0f/total; - } - - if (confidence < 0.0f) - confidence = 0.0f; - - // lower the confidence of latin1 so that other more accurate detector - // can take priority. - confidence *= 0.50f; - - return confidence; -} - -#ifdef DEBUG_chardet -void nsLatin1Prober::DumpStatus() -{ - printf(" Latin1Prober: %1.3f [%s]\r\n", GetConfidence(), GetCharSetName()); -} -#endif - -#pragma GCC visibility pop - diff --git a/amarok/utilities/collectionscanner/charset-detector/src/nsLatin1Prober.h b/amarok/utilities/collectionscanner/charset-detector/src/nsLatin1Prober.h deleted file mode 100644 index 103d271b..00000000 --- a/amarok/utilities/collectionscanner/charset-detector/src/nsLatin1Prober.h +++ /dev/null @@ -1,70 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Universal charset detector code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 2001 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Shy Shalom - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef nsLatin1Prober_h__ -#define nsLatin1Prober_h__ - -#include "nsCharSetProber.h" - -#define FREQ_CAT_NUM 4 - -class nsLatin1Prober: public nsCharSetProber { -public: - nsLatin1Prober(void){Reset();}; - virtual ~nsLatin1Prober(void){}; - nsProbingState HandleData(const char* aBuf, PRUint32 aLen); - const char* GetCharSetName() {return "windows-1252";}; - nsProbingState GetState(void) {return mState;}; - void Reset(void); - float GetConfidence(void); - void SetOpion() {}; - -#ifdef DEBUG_chardet - virtual void DumpStatus(); -#endif - -protected: - - nsProbingState mState; - char mLastCharClass; - PRUint32 mFreqCounter[FREQ_CAT_NUM]; -}; - - -#endif /* nsLatin1Prober_h__ */ - diff --git a/amarok/utilities/collectionscanner/charset-detector/src/nsMBCSGroupProber.cpp b/amarok/utilities/collectionscanner/charset-detector/src/nsMBCSGroupProber.cpp deleted file mode 100644 index a3701696..00000000 --- a/amarok/utilities/collectionscanner/charset-detector/src/nsMBCSGroupProber.cpp +++ /dev/null @@ -1,215 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Universal charset detector code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 2001 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Shy Shalom - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#pragma GCC visibility push(hidden) - -#include -#include "prmem.h" - -#include "nsMBCSGroupProber.h" - -#ifdef DEBUG_chardet -char *ProberName[] = -{ - "UTF8", - "SJIS", - "EUCJP", - "GB18030", - "EUCKR", - "Big5", - "EUCTW", -}; - -#endif - -nsMBCSGroupProber::nsMBCSGroupProber() -{ - mProbers[0] = new nsUTF8Prober(); - mProbers[1] = new nsSJISProber(); - mProbers[2] = new nsEUCJPProber(); - mProbers[3] = new nsGB18030Prober(); - mProbers[4] = new nsEUCKRProber(); - mProbers[5] = new nsBig5Prober(); - mProbers[6] = new nsEUCTWProber(); - Reset(); -} - -nsMBCSGroupProber::~nsMBCSGroupProber() -{ - for (PRUint32 i = 0; i < NUM_OF_PROBERS; i++) - { - delete mProbers[i]; - } -} - -const char* nsMBCSGroupProber::GetCharSetName() -{ - if (mBestGuess == -1) - { - GetConfidence(); - if (mBestGuess == -1) - mBestGuess = 0; - } - return mProbers[mBestGuess]->GetCharSetName(); -} - -void nsMBCSGroupProber::Reset(void) -{ - mActiveNum = 0; - for (PRUint32 i = 0; i < NUM_OF_PROBERS; i++) - { - if (mProbers[i]) - { - mProbers[i]->Reset(); - mIsActive[i] = PR_TRUE; - ++mActiveNum; - } - else - mIsActive[i] = PR_FALSE; - } - mBestGuess = -1; - mState = eDetecting; -} - -nsProbingState nsMBCSGroupProber::HandleData(const char* aBuf, PRUint32 aLen) -{ - nsProbingState st; - PRUint32 i; - - //do filtering to reduce load to probers - char *highbyteBuf; - char *hptr; - PRBool keepNext = PR_TRUE; //assume previous is not ascii, it will do no harm except add some noise - hptr = highbyteBuf = (char*)PR_Malloc(aLen); - if (!hptr) - return mState; - for (i = 0; i < aLen; i++) - { - if (aBuf[i] & 0x80) - { - *hptr++ = aBuf[i]; - keepNext = PR_TRUE; - } - else - { - //if previous is highbyte, keep this even it is a ASCII - if (keepNext) - { - *hptr++ = aBuf[i]; - keepNext = PR_FALSE; - } - } - } - - for (i = 0; i < NUM_OF_PROBERS; i++) - { - if (!mIsActive[i]) - continue; - st = mProbers[i]->HandleData(highbyteBuf, hptr - highbyteBuf); - if (st == eFoundIt) - { - mBestGuess = i; - mState = eFoundIt; - break; - } - else if (st == eNotMe) - { - mIsActive[i] = PR_FALSE; - mActiveNum--; - if (mActiveNum <= 0) - { - mState = eNotMe; - break; - } - } - } - - PR_FREEIF(highbyteBuf); - - return mState; -} - -float nsMBCSGroupProber::GetConfidence(void) -{ - PRUint32 i; - float bestConf = 0.0, cf; - - switch (mState) - { - case eFoundIt: - return (float)0.99; - case eNotMe: - return (float)0.01; - default: - for (i = 0; i < NUM_OF_PROBERS; i++) - { - if (!mIsActive[i]) - continue; - cf = mProbers[i]->GetConfidence(); - if (bestConf < cf) - { - bestConf = cf; - mBestGuess = i; - } - } - } - return bestConf; -} - -#ifdef DEBUG_chardet -void nsMBCSGroupProber::DumpStatus() -{ - PRUint32 i; - float cf; - - GetConfidence(); - for (i = 0; i < NUM_OF_PROBERS; i++) - { - if (!mIsActive[i]) - printf(" MBCS inactive: [%s] (confidence is too low).\r\n", ProberName[i]); - else - { - cf = mProbers[i]->GetConfidence(); - printf(" MBCS %1.3f: [%s]\r\n", cf, ProberName[i]); - } - } -} -#endif - -#pragma GCC visibility pop - diff --git a/amarok/utilities/collectionscanner/charset-detector/src/nsMBCSGroupProber.h b/amarok/utilities/collectionscanner/charset-detector/src/nsMBCSGroupProber.h deleted file mode 100644 index af22b1a5..00000000 --- a/amarok/utilities/collectionscanner/charset-detector/src/nsMBCSGroupProber.h +++ /dev/null @@ -1,75 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef nsMBCSGroupProber_h__ -#define nsMBCSGroupProber_h__ - -#include "nsSJISProber.h" -#include "nsUTF8Prober.h" -#include "nsEUCJPProber.h" -#include "nsGB2312Prober.h" -#include "nsEUCKRProber.h" -#include "nsBig5Prober.h" -#include "nsEUCTWProber.h" - -#define NUM_OF_PROBERS 7 - -class nsMBCSGroupProber: public nsCharSetProber { -public: - nsMBCSGroupProber(); - virtual ~nsMBCSGroupProber(); - nsProbingState HandleData(const char* aBuf, PRUint32 aLen); - const char* GetCharSetName(); - nsProbingState GetState(void) {return mState;}; - void Reset(void); - float GetConfidence(void); - void SetOpion() {}; - -#ifdef DEBUG_chardet - void DumpStatus(); -#endif - -protected: - nsProbingState mState; - nsCharSetProber* mProbers[NUM_OF_PROBERS]; - PRBool mIsActive[NUM_OF_PROBERS]; - PRInt32 mBestGuess; - PRUint32 mActiveNum; -}; - -#endif /* nsMBCSGroupProber_h__ */ - diff --git a/amarok/utilities/collectionscanner/charset-detector/src/nsMBCSSM.cpp b/amarok/utilities/collectionscanner/charset-detector/src/nsMBCSSM.cpp deleted file mode 100644 index 33b5a9ac..00000000 --- a/amarok/utilities/collectionscanner/charset-detector/src/nsMBCSSM.cpp +++ /dev/null @@ -1,631 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#pragma GCC visibility push(hidden) - -#include "nsCodingStateMachine.h" - -/* -Modification from frank tang's original work: -. 0x00 is allowed as a legal character. Since some web pages contains this char in - text stream. -*/ - -// BIG5 - -static PRUint32 BIG5_cls [ 256 / 8 ] = { -//PCK4BITS(0,1,1,1,1,1,1,1), // 00 - 07 -PCK4BITS(1,1,1,1,1,1,1,1), // 00 - 07 //allow 0x00 as legal value -PCK4BITS(1,1,1,1,1,1,0,0), // 08 - 0f -PCK4BITS(1,1,1,1,1,1,1,1), // 10 - 17 -PCK4BITS(1,1,1,0,1,1,1,1), // 18 - 1f -PCK4BITS(1,1,1,1,1,1,1,1), // 20 - 27 -PCK4BITS(1,1,1,1,1,1,1,1), // 28 - 2f -PCK4BITS(1,1,1,1,1,1,1,1), // 30 - 37 -PCK4BITS(1,1,1,1,1,1,1,1), // 38 - 3f -PCK4BITS(2,2,2,2,2,2,2,2), // 40 - 47 -PCK4BITS(2,2,2,2,2,2,2,2), // 48 - 4f -PCK4BITS(2,2,2,2,2,2,2,2), // 50 - 57 -PCK4BITS(2,2,2,2,2,2,2,2), // 58 - 5f -PCK4BITS(2,2,2,2,2,2,2,2), // 60 - 67 -PCK4BITS(2,2,2,2,2,2,2,2), // 68 - 6f -PCK4BITS(2,2,2,2,2,2,2,2), // 70 - 77 -PCK4BITS(2,2,2,2,2,2,2,1), // 78 - 7f -PCK4BITS(4,4,4,4,4,4,4,4), // 80 - 87 -PCK4BITS(4,4,4,4,4,4,4,4), // 88 - 8f -PCK4BITS(4,4,4,4,4,4,4,4), // 90 - 97 -PCK4BITS(4,4,4,4,4,4,4,4), // 98 - 9f -PCK4BITS(4,3,3,3,3,3,3,3), // a0 - a7 -PCK4BITS(3,3,3,3,3,3,3,3), // a8 - af -PCK4BITS(3,3,3,3,3,3,3,3), // b0 - b7 -PCK4BITS(3,3,3,3,3,3,3,3), // b8 - bf -PCK4BITS(3,3,3,3,3,3,3,3), // c0 - c7 -PCK4BITS(3,3,3,3,3,3,3,3), // c8 - cf -PCK4BITS(3,3,3,3,3,3,3,3), // d0 - d7 -PCK4BITS(3,3,3,3,3,3,3,3), // d8 - df -PCK4BITS(3,3,3,3,3,3,3,3), // e0 - e7 -PCK4BITS(3,3,3,3,3,3,3,3), // e8 - ef -PCK4BITS(3,3,3,3,3,3,3,3), // f0 - f7 -PCK4BITS(3,3,3,3,3,3,3,0) // f8 - ff -}; - - -static PRUint32 BIG5_st [ 3] = { -PCK4BITS(eError,eStart,eStart, 3,eError,eError,eError,eError),//00-07 -PCK4BITS(eError,eError,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eError),//08-0f -PCK4BITS(eError,eStart,eStart,eStart,eStart,eStart,eStart,eStart) //10-17 -}; - -static const PRUint32 Big5CharLenTable[] = {0, 1, 1, 2, 0}; - -SMModel Big5SMModel = { - {eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, BIG5_cls }, - 5, - {eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, BIG5_st }, - Big5CharLenTable, - "Big5", -}; - -static PRUint32 EUCJP_cls [ 256 / 8 ] = { -//PCK4BITS(5,4,4,4,4,4,4,4), // 00 - 07 -PCK4BITS(4,4,4,4,4,4,4,4), // 00 - 07 -PCK4BITS(4,4,4,4,4,4,5,5), // 08 - 0f -PCK4BITS(4,4,4,4,4,4,4,4), // 10 - 17 -PCK4BITS(4,4,4,5,4,4,4,4), // 18 - 1f -PCK4BITS(4,4,4,4,4,4,4,4), // 20 - 27 -PCK4BITS(4,4,4,4,4,4,4,4), // 28 - 2f -PCK4BITS(4,4,4,4,4,4,4,4), // 30 - 37 -PCK4BITS(4,4,4,4,4,4,4,4), // 38 - 3f -PCK4BITS(4,4,4,4,4,4,4,4), // 40 - 47 -PCK4BITS(4,4,4,4,4,4,4,4), // 48 - 4f -PCK4BITS(4,4,4,4,4,4,4,4), // 50 - 57 -PCK4BITS(4,4,4,4,4,4,4,4), // 58 - 5f -PCK4BITS(4,4,4,4,4,4,4,4), // 60 - 67 -PCK4BITS(4,4,4,4,4,4,4,4), // 68 - 6f -PCK4BITS(4,4,4,4,4,4,4,4), // 70 - 77 -PCK4BITS(4,4,4,4,4,4,4,4), // 78 - 7f -PCK4BITS(5,5,5,5,5,5,5,5), // 80 - 87 -PCK4BITS(5,5,5,5,5,5,1,3), // 88 - 8f -PCK4BITS(5,5,5,5,5,5,5,5), // 90 - 97 -PCK4BITS(5,5,5,5,5,5,5,5), // 98 - 9f -PCK4BITS(5,2,2,2,2,2,2,2), // a0 - a7 -PCK4BITS(2,2,2,2,2,2,2,2), // a8 - af -PCK4BITS(2,2,2,2,2,2,2,2), // b0 - b7 -PCK4BITS(2,2,2,2,2,2,2,2), // b8 - bf -PCK4BITS(2,2,2,2,2,2,2,2), // c0 - c7 -PCK4BITS(2,2,2,2,2,2,2,2), // c8 - cf -PCK4BITS(2,2,2,2,2,2,2,2), // d0 - d7 -PCK4BITS(2,2,2,2,2,2,2,2), // d8 - df -PCK4BITS(0,0,0,0,0,0,0,0), // e0 - e7 -PCK4BITS(0,0,0,0,0,0,0,0), // e8 - ef -PCK4BITS(0,0,0,0,0,0,0,0), // f0 - f7 -PCK4BITS(0,0,0,0,0,0,0,5) // f8 - ff -}; - - -static PRUint32 EUCJP_st [ 5] = { -PCK4BITS( 3, 4, 3, 5,eStart,eError,eError,eError),//00-07 -PCK4BITS(eError,eError,eError,eError,eItsMe,eItsMe,eItsMe,eItsMe),//08-0f -PCK4BITS(eItsMe,eItsMe,eStart,eError,eStart,eError,eError,eError),//10-17 -PCK4BITS(eError,eError,eStart,eError,eError,eError, 3,eError),//18-1f -PCK4BITS( 3,eError,eError,eError,eStart,eStart,eStart,eStart) //20-27 -}; - -static const PRUint32 EUCJPCharLenTable[] = {2, 2, 2, 3, 1, 0}; - -SMModel EUCJPSMModel = { - {eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, EUCJP_cls }, - 6, - {eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, EUCJP_st }, - EUCJPCharLenTable, - "EUC-JP", -}; - -static PRUint32 EUCKR_cls [ 256 / 8 ] = { -//PCK4BITS(0,1,1,1,1,1,1,1), // 00 - 07 -PCK4BITS(1,1,1,1,1,1,1,1), // 00 - 07 -PCK4BITS(1,1,1,1,1,1,0,0), // 08 - 0f -PCK4BITS(1,1,1,1,1,1,1,1), // 10 - 17 -PCK4BITS(1,1,1,0,1,1,1,1), // 18 - 1f -PCK4BITS(1,1,1,1,1,1,1,1), // 20 - 27 -PCK4BITS(1,1,1,1,1,1,1,1), // 28 - 2f -PCK4BITS(1,1,1,1,1,1,1,1), // 30 - 37 -PCK4BITS(1,1,1,1,1,1,1,1), // 38 - 3f -PCK4BITS(1,1,1,1,1,1,1,1), // 40 - 47 -PCK4BITS(1,1,1,1,1,1,1,1), // 48 - 4f -PCK4BITS(1,1,1,1,1,1,1,1), // 50 - 57 -PCK4BITS(1,1,1,1,1,1,1,1), // 58 - 5f -PCK4BITS(1,1,1,1,1,1,1,1), // 60 - 67 -PCK4BITS(1,1,1,1,1,1,1,1), // 68 - 6f -PCK4BITS(1,1,1,1,1,1,1,1), // 70 - 77 -PCK4BITS(1,1,1,1,1,1,1,1), // 78 - 7f -PCK4BITS(0,0,0,0,0,0,0,0), // 80 - 87 -PCK4BITS(0,0,0,0,0,0,0,0), // 88 - 8f -PCK4BITS(0,0,0,0,0,0,0,0), // 90 - 97 -PCK4BITS(0,0,0,0,0,0,0,0), // 98 - 9f -PCK4BITS(0,2,2,2,2,2,2,2), // a0 - a7 -PCK4BITS(2,2,2,2,2,3,3,3), // a8 - af -PCK4BITS(2,2,2,2,2,2,2,2), // b0 - b7 -PCK4BITS(2,2,2,2,2,2,2,2), // b8 - bf -PCK4BITS(2,2,2,2,2,2,2,2), // c0 - c7 -PCK4BITS(2,3,2,2,2,2,2,2), // c8 - cf -PCK4BITS(2,2,2,2,2,2,2,2), // d0 - d7 -PCK4BITS(2,2,2,2,2,2,2,2), // d8 - df -PCK4BITS(2,2,2,2,2,2,2,2), // e0 - e7 -PCK4BITS(2,2,2,2,2,2,2,2), // e8 - ef -PCK4BITS(2,2,2,2,2,2,2,2), // f0 - f7 -PCK4BITS(2,2,2,2,2,2,2,0) // f8 - ff -}; - - -static PRUint32 EUCKR_st [ 2] = { -PCK4BITS(eError,eStart, 3,eError,eError,eError,eError,eError),//00-07 -PCK4BITS(eItsMe,eItsMe,eItsMe,eItsMe,eError,eError,eStart,eStart) //08-0f -}; - -static const PRUint32 EUCKRCharLenTable[] = {0, 1, 2, 0}; - -SMModel EUCKRSMModel = { - {eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, EUCKR_cls }, - 4, - {eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, EUCKR_st }, - EUCKRCharLenTable, - "EUC-KR", -}; - -static PRUint32 EUCTW_cls [ 256 / 8 ] = { -//PCK4BITS(0,2,2,2,2,2,2,2), // 00 - 07 -PCK4BITS(2,2,2,2,2,2,2,2), // 00 - 07 -PCK4BITS(2,2,2,2,2,2,0,0), // 08 - 0f -PCK4BITS(2,2,2,2,2,2,2,2), // 10 - 17 -PCK4BITS(2,2,2,0,2,2,2,2), // 18 - 1f -PCK4BITS(2,2,2,2,2,2,2,2), // 20 - 27 -PCK4BITS(2,2,2,2,2,2,2,2), // 28 - 2f -PCK4BITS(2,2,2,2,2,2,2,2), // 30 - 37 -PCK4BITS(2,2,2,2,2,2,2,2), // 38 - 3f -PCK4BITS(2,2,2,2,2,2,2,2), // 40 - 47 -PCK4BITS(2,2,2,2,2,2,2,2), // 48 - 4f -PCK4BITS(2,2,2,2,2,2,2,2), // 50 - 57 -PCK4BITS(2,2,2,2,2,2,2,2), // 58 - 5f -PCK4BITS(2,2,2,2,2,2,2,2), // 60 - 67 -PCK4BITS(2,2,2,2,2,2,2,2), // 68 - 6f -PCK4BITS(2,2,2,2,2,2,2,2), // 70 - 77 -PCK4BITS(2,2,2,2,2,2,2,2), // 78 - 7f -PCK4BITS(0,0,0,0,0,0,0,0), // 80 - 87 -PCK4BITS(0,0,0,0,0,0,6,0), // 88 - 8f -PCK4BITS(0,0,0,0,0,0,0,0), // 90 - 97 -PCK4BITS(0,0,0,0,0,0,0,0), // 98 - 9f -PCK4BITS(0,3,4,4,4,4,4,4), // a0 - a7 -PCK4BITS(5,5,1,1,1,1,1,1), // a8 - af -PCK4BITS(1,1,1,1,1,1,1,1), // b0 - b7 -PCK4BITS(1,1,1,1,1,1,1,1), // b8 - bf -PCK4BITS(1,1,3,1,3,3,3,3), // c0 - c7 -PCK4BITS(3,3,3,3,3,3,3,3), // c8 - cf -PCK4BITS(3,3,3,3,3,3,3,3), // d0 - d7 -PCK4BITS(3,3,3,3,3,3,3,3), // d8 - df -PCK4BITS(3,3,3,3,3,3,3,3), // e0 - e7 -PCK4BITS(3,3,3,3,3,3,3,3), // e8 - ef -PCK4BITS(3,3,3,3,3,3,3,3), // f0 - f7 -PCK4BITS(3,3,3,3,3,3,3,0) // f8 - ff -}; - - -static PRUint32 EUCTW_st [ 6] = { -PCK4BITS(eError,eError,eStart, 3, 3, 3, 4,eError),//00-07 -PCK4BITS(eError,eError,eError,eError,eError,eError,eItsMe,eItsMe),//08-0f -PCK4BITS(eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eError,eStart,eError),//10-17 -PCK4BITS(eStart,eStart,eStart,eError,eError,eError,eError,eError),//18-1f -PCK4BITS( 5,eError,eError,eError,eStart,eError,eStart,eStart),//20-27 -PCK4BITS(eStart,eError,eStart,eStart,eStart,eStart,eStart,eStart) //28-2f -}; - -static const PRUint32 EUCTWCharLenTable[] = {0, 0, 1, 2, 2, 2, 3}; - -SMModel EUCTWSMModel = { - {eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, EUCTW_cls }, - 7, - {eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, EUCTW_st }, - EUCTWCharLenTable, - "x-euc-tw", -}; - -/* obsolete GB2312 by gb18030 -static PRUint32 GB2312_cls [ 256 / 8 ] = { -//PCK4BITS(0,1,1,1,1,1,1,1), // 00 - 07 -PCK4BITS(1,1,1,1,1,1,1,1), // 00 - 07 -PCK4BITS(1,1,1,1,1,1,0,0), // 08 - 0f -PCK4BITS(1,1,1,1,1,1,1,1), // 10 - 17 -PCK4BITS(1,1,1,0,1,1,1,1), // 18 - 1f -PCK4BITS(1,1,1,1,1,1,1,1), // 20 - 27 -PCK4BITS(1,1,1,1,1,1,1,1), // 28 - 2f -PCK4BITS(1,1,1,1,1,1,1,1), // 30 - 37 -PCK4BITS(1,1,1,1,1,1,1,1), // 38 - 3f -PCK4BITS(1,1,1,1,1,1,1,1), // 40 - 47 -PCK4BITS(1,1,1,1,1,1,1,1), // 48 - 4f -PCK4BITS(1,1,1,1,1,1,1,1), // 50 - 57 -PCK4BITS(1,1,1,1,1,1,1,1), // 58 - 5f -PCK4BITS(1,1,1,1,1,1,1,1), // 60 - 67 -PCK4BITS(1,1,1,1,1,1,1,1), // 68 - 6f -PCK4BITS(1,1,1,1,1,1,1,1), // 70 - 77 -PCK4BITS(1,1,1,1,1,1,1,1), // 78 - 7f -PCK4BITS(1,0,0,0,0,0,0,0), // 80 - 87 -PCK4BITS(0,0,0,0,0,0,0,0), // 88 - 8f -PCK4BITS(0,0,0,0,0,0,0,0), // 90 - 97 -PCK4BITS(0,0,0,0,0,0,0,0), // 98 - 9f -PCK4BITS(0,2,2,2,2,2,2,2), // a0 - a7 -PCK4BITS(2,2,3,3,3,3,3,3), // a8 - af -PCK4BITS(2,2,2,2,2,2,2,2), // b0 - b7 -PCK4BITS(2,2,2,2,2,2,2,2), // b8 - bf -PCK4BITS(2,2,2,2,2,2,2,2), // c0 - c7 -PCK4BITS(2,2,2,2,2,2,2,2), // c8 - cf -PCK4BITS(2,2,2,2,2,2,2,2), // d0 - d7 -PCK4BITS(2,2,2,2,2,2,2,2), // d8 - df -PCK4BITS(2,2,2,2,2,2,2,2), // e0 - e7 -PCK4BITS(2,2,2,2,2,2,2,2), // e8 - ef -PCK4BITS(2,2,2,2,2,2,2,2), // f0 - f7 -PCK4BITS(2,2,2,2,2,2,2,0) // f8 - ff -}; - - -static PRUint32 GB2312_st [ 2] = { -PCK4BITS(eError,eStart, 3,eError,eError,eError,eError,eError),//00-07 -PCK4BITS(eItsMe,eItsMe,eItsMe,eItsMe,eError,eError,eStart,eStart) //08-0f -}; - -static const PRUint32 GB2312CharLenTable[] = {0, 1, 2, 0}; - -SMModel GB2312SMModel = { - {eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, GB2312_cls }, - 4, - {eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, GB2312_st }, - GB2312CharLenTable, - "GB2312", -}; -*/ - -// the following state machine data was created by perl script in -// intl/chardet/tools. It should be the same as in PSM detector. -static PRUint32 GB18030_cls [ 256 / 8 ] = { -PCK4BITS(1,1,1,1,1,1,1,1), // 00 - 07 -PCK4BITS(1,1,1,1,1,1,0,0), // 08 - 0f -PCK4BITS(1,1,1,1,1,1,1,1), // 10 - 17 -PCK4BITS(1,1,1,0,1,1,1,1), // 18 - 1f -PCK4BITS(1,1,1,1,1,1,1,1), // 20 - 27 -PCK4BITS(1,1,1,1,1,1,1,1), // 28 - 2f -PCK4BITS(3,3,3,3,3,3,3,3), // 30 - 37 -PCK4BITS(3,3,1,1,1,1,1,1), // 38 - 3f -PCK4BITS(2,2,2,2,2,2,2,2), // 40 - 47 -PCK4BITS(2,2,2,2,2,2,2,2), // 48 - 4f -PCK4BITS(2,2,2,2,2,2,2,2), // 50 - 57 -PCK4BITS(2,2,2,2,2,2,2,2), // 58 - 5f -PCK4BITS(2,2,2,2,2,2,2,2), // 60 - 67 -PCK4BITS(2,2,2,2,2,2,2,2), // 68 - 6f -PCK4BITS(2,2,2,2,2,2,2,2), // 70 - 77 -PCK4BITS(2,2,2,2,2,2,2,4), // 78 - 7f -PCK4BITS(5,6,6,6,6,6,6,6), // 80 - 87 -PCK4BITS(6,6,6,6,6,6,6,6), // 88 - 8f -PCK4BITS(6,6,6,6,6,6,6,6), // 90 - 97 -PCK4BITS(6,6,6,6,6,6,6,6), // 98 - 9f -PCK4BITS(6,6,6,6,6,6,6,6), // a0 - a7 -PCK4BITS(6,6,6,6,6,6,6,6), // a8 - af -PCK4BITS(6,6,6,6,6,6,6,6), // b0 - b7 -PCK4BITS(6,6,6,6,6,6,6,6), // b8 - bf -PCK4BITS(6,6,6,6,6,6,6,6), // c0 - c7 -PCK4BITS(6,6,6,6,6,6,6,6), // c8 - cf -PCK4BITS(6,6,6,6,6,6,6,6), // d0 - d7 -PCK4BITS(6,6,6,6,6,6,6,6), // d8 - df -PCK4BITS(6,6,6,6,6,6,6,6), // e0 - e7 -PCK4BITS(6,6,6,6,6,6,6,6), // e8 - ef -PCK4BITS(6,6,6,6,6,6,6,6), // f0 - f7 -PCK4BITS(6,6,6,6,6,6,6,0) // f8 - ff -}; - - -static PRUint32 GB18030_st [ 6] = { -PCK4BITS(eError,eStart,eStart,eStart,eStart,eStart, 3,eError),//00-07 -PCK4BITS(eError,eError,eError,eError,eError,eError,eItsMe,eItsMe),//08-0f -PCK4BITS(eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eError,eError,eStart),//10-17 -PCK4BITS( 4,eError,eStart,eStart,eError,eError,eError,eError),//18-1f -PCK4BITS(eError,eError, 5,eError,eError,eError,eItsMe,eError),//20-27 -PCK4BITS(eError,eError,eStart,eStart,eStart,eStart,eStart,eStart) //28-2f -}; - -// To be accurate, the length of class 6 can be either 2 or 4. -// But it is not necessary to discriminate between the two since -// it is used for frequency analysis only, and we are validing -// each code range there as well. So it is safe to set it to be -// 2 here. -static const PRUint32 GB18030CharLenTable[] = {0, 1, 1, 1, 1, 1, 2}; - -SMModel GB18030SMModel = { - {eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, GB18030_cls }, - 7, - {eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, GB18030_st }, - GB18030CharLenTable, - "GB18030", -}; - -// sjis - -static PRUint32 SJIS_cls [ 256 / 8 ] = { -//PCK4BITS(0,1,1,1,1,1,1,1), // 00 - 07 -PCK4BITS(1,1,1,1,1,1,1,1), // 00 - 07 -PCK4BITS(1,1,1,1,1,1,0,0), // 08 - 0f -PCK4BITS(1,1,1,1,1,1,1,1), // 10 - 17 -PCK4BITS(1,1,1,0,1,1,1,1), // 18 - 1f -PCK4BITS(1,1,1,1,1,1,1,1), // 20 - 27 -PCK4BITS(1,1,1,1,1,1,1,1), // 28 - 2f -PCK4BITS(1,1,1,1,1,1,1,1), // 30 - 37 -PCK4BITS(1,1,1,1,1,1,1,1), // 38 - 3f -PCK4BITS(2,2,2,2,2,2,2,2), // 40 - 47 -PCK4BITS(2,2,2,2,2,2,2,2), // 48 - 4f -PCK4BITS(2,2,2,2,2,2,2,2), // 50 - 57 -PCK4BITS(2,2,2,2,2,2,2,2), // 58 - 5f -PCK4BITS(2,2,2,2,2,2,2,2), // 60 - 67 -PCK4BITS(2,2,2,2,2,2,2,2), // 68 - 6f -PCK4BITS(2,2,2,2,2,2,2,2), // 70 - 77 -PCK4BITS(2,2,2,2,2,2,2,1), // 78 - 7f -PCK4BITS(3,3,3,3,3,3,3,3), // 80 - 87 -PCK4BITS(3,3,3,3,3,3,3,3), // 88 - 8f -PCK4BITS(3,3,3,3,3,3,3,3), // 90 - 97 -PCK4BITS(3,3,3,3,3,3,3,3), // 98 - 9f -//0xa0 is illegal in sjis encoding, but some pages does -//contain such byte. We need to be more error forgiven. -PCK4BITS(2,2,2,2,2,2,2,2), // a0 - a7 -PCK4BITS(2,2,2,2,2,2,2,2), // a8 - af -PCK4BITS(2,2,2,2,2,2,2,2), // b0 - b7 -PCK4BITS(2,2,2,2,2,2,2,2), // b8 - bf -PCK4BITS(2,2,2,2,2,2,2,2), // c0 - c7 -PCK4BITS(2,2,2,2,2,2,2,2), // c8 - cf -PCK4BITS(2,2,2,2,2,2,2,2), // d0 - d7 -PCK4BITS(2,2,2,2,2,2,2,2), // d8 - df -PCK4BITS(3,3,3,3,3,3,3,3), // e0 - e7 -PCK4BITS(3,3,3,3,3,4,4,4), // e8 - ef -PCK4BITS(4,4,4,4,4,4,4,4), // f0 - f7 -PCK4BITS(4,4,4,4,4,0,0,0) // f8 - ff -}; - - -static PRUint32 SJIS_st [ 3] = { -PCK4BITS(eError,eStart,eStart, 3,eError,eError,eError,eError),//00-07 -PCK4BITS(eError,eError,eError,eError,eItsMe,eItsMe,eItsMe,eItsMe),//08-0f -PCK4BITS(eItsMe,eItsMe,eError,eError,eStart,eStart,eStart,eStart) //10-17 -}; - -static const PRUint32 SJISCharLenTable[] = {0, 1, 1, 2, 0, 0}; - -SMModel SJISSMModel = { - {eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, SJIS_cls }, - 6, - {eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, SJIS_st }, - SJISCharLenTable, - "Shift_JIS", -}; - - -static PRUint32 UCS2BE_cls [ 256 / 8 ] = { -PCK4BITS(0,0,0,0,0,0,0,0), // 00 - 07 -PCK4BITS(0,0,1,0,0,2,0,0), // 08 - 0f -PCK4BITS(0,0,0,0,0,0,0,0), // 10 - 17 -PCK4BITS(0,0,0,3,0,0,0,0), // 18 - 1f -PCK4BITS(0,0,0,0,0,0,0,0), // 20 - 27 -PCK4BITS(0,3,3,3,3,3,0,0), // 28 - 2f -PCK4BITS(0,0,0,0,0,0,0,0), // 30 - 37 -PCK4BITS(0,0,0,0,0,0,0,0), // 38 - 3f -PCK4BITS(0,0,0,0,0,0,0,0), // 40 - 47 -PCK4BITS(0,0,0,0,0,0,0,0), // 48 - 4f -PCK4BITS(0,0,0,0,0,0,0,0), // 50 - 57 -PCK4BITS(0,0,0,0,0,0,0,0), // 58 - 5f -PCK4BITS(0,0,0,0,0,0,0,0), // 60 - 67 -PCK4BITS(0,0,0,0,0,0,0,0), // 68 - 6f -PCK4BITS(0,0,0,0,0,0,0,0), // 70 - 77 -PCK4BITS(0,0,0,0,0,0,0,0), // 78 - 7f -PCK4BITS(0,0,0,0,0,0,0,0), // 80 - 87 -PCK4BITS(0,0,0,0,0,0,0,0), // 88 - 8f -PCK4BITS(0,0,0,0,0,0,0,0), // 90 - 97 -PCK4BITS(0,0,0,0,0,0,0,0), // 98 - 9f -PCK4BITS(0,0,0,0,0,0,0,0), // a0 - a7 -PCK4BITS(0,0,0,0,0,0,0,0), // a8 - af -PCK4BITS(0,0,0,0,0,0,0,0), // b0 - b7 -PCK4BITS(0,0,0,0,0,0,0,0), // b8 - bf -PCK4BITS(0,0,0,0,0,0,0,0), // c0 - c7 -PCK4BITS(0,0,0,0,0,0,0,0), // c8 - cf -PCK4BITS(0,0,0,0,0,0,0,0), // d0 - d7 -PCK4BITS(0,0,0,0,0,0,0,0), // d8 - df -PCK4BITS(0,0,0,0,0,0,0,0), // e0 - e7 -PCK4BITS(0,0,0,0,0,0,0,0), // e8 - ef -PCK4BITS(0,0,0,0,0,0,0,0), // f0 - f7 -PCK4BITS(0,0,0,0,0,0,4,5) // f8 - ff -}; - - -static PRUint32 UCS2BE_st [ 7] = { -PCK4BITS( 5, 7, 7,eError, 4, 3,eError,eError),//00-07 -PCK4BITS(eError,eError,eError,eError,eItsMe,eItsMe,eItsMe,eItsMe),//08-0f -PCK4BITS(eItsMe,eItsMe, 6, 6, 6, 6,eError,eError),//10-17 -PCK4BITS( 6, 6, 6, 6, 6,eItsMe, 6, 6),//18-1f -PCK4BITS( 6, 6, 6, 6, 5, 7, 7,eError),//20-27 -PCK4BITS( 5, 8, 6, 6,eError, 6, 6, 6),//28-2f -PCK4BITS( 6, 6, 6, 6,eError,eError,eStart,eStart) //30-37 -}; - -static const PRUint32 UCS2BECharLenTable[] = {2, 2, 2, 0, 2, 2}; - -SMModel UCS2BESMModel = { - {eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, UCS2BE_cls }, - 6, - {eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, UCS2BE_st }, - UCS2BECharLenTable, - "UTF-16BE", -}; - -static PRUint32 UCS2LE_cls [ 256 / 8 ] = { -PCK4BITS(0,0,0,0,0,0,0,0), // 00 - 07 -PCK4BITS(0,0,1,0,0,2,0,0), // 08 - 0f -PCK4BITS(0,0,0,0,0,0,0,0), // 10 - 17 -PCK4BITS(0,0,0,3,0,0,0,0), // 18 - 1f -PCK4BITS(0,0,0,0,0,0,0,0), // 20 - 27 -PCK4BITS(0,3,3,3,3,3,0,0), // 28 - 2f -PCK4BITS(0,0,0,0,0,0,0,0), // 30 - 37 -PCK4BITS(0,0,0,0,0,0,0,0), // 38 - 3f -PCK4BITS(0,0,0,0,0,0,0,0), // 40 - 47 -PCK4BITS(0,0,0,0,0,0,0,0), // 48 - 4f -PCK4BITS(0,0,0,0,0,0,0,0), // 50 - 57 -PCK4BITS(0,0,0,0,0,0,0,0), // 58 - 5f -PCK4BITS(0,0,0,0,0,0,0,0), // 60 - 67 -PCK4BITS(0,0,0,0,0,0,0,0), // 68 - 6f -PCK4BITS(0,0,0,0,0,0,0,0), // 70 - 77 -PCK4BITS(0,0,0,0,0,0,0,0), // 78 - 7f -PCK4BITS(0,0,0,0,0,0,0,0), // 80 - 87 -PCK4BITS(0,0,0,0,0,0,0,0), // 88 - 8f -PCK4BITS(0,0,0,0,0,0,0,0), // 90 - 97 -PCK4BITS(0,0,0,0,0,0,0,0), // 98 - 9f -PCK4BITS(0,0,0,0,0,0,0,0), // a0 - a7 -PCK4BITS(0,0,0,0,0,0,0,0), // a8 - af -PCK4BITS(0,0,0,0,0,0,0,0), // b0 - b7 -PCK4BITS(0,0,0,0,0,0,0,0), // b8 - bf -PCK4BITS(0,0,0,0,0,0,0,0), // c0 - c7 -PCK4BITS(0,0,0,0,0,0,0,0), // c8 - cf -PCK4BITS(0,0,0,0,0,0,0,0), // d0 - d7 -PCK4BITS(0,0,0,0,0,0,0,0), // d8 - df -PCK4BITS(0,0,0,0,0,0,0,0), // e0 - e7 -PCK4BITS(0,0,0,0,0,0,0,0), // e8 - ef -PCK4BITS(0,0,0,0,0,0,0,0), // f0 - f7 -PCK4BITS(0,0,0,0,0,0,4,5) // f8 - ff -}; - - -static PRUint32 UCS2LE_st [ 7] = { -PCK4BITS( 6, 6, 7, 6, 4, 3,eError,eError),//00-07 -PCK4BITS(eError,eError,eError,eError,eItsMe,eItsMe,eItsMe,eItsMe),//08-0f -PCK4BITS(eItsMe,eItsMe, 5, 5, 5,eError,eItsMe,eError),//10-17 -PCK4BITS( 5, 5, 5,eError, 5,eError, 6, 6),//18-1f -PCK4BITS( 7, 6, 8, 8, 5, 5, 5,eError),//20-27 -PCK4BITS( 5, 5, 5,eError,eError,eError, 5, 5),//28-2f -PCK4BITS( 5, 5, 5,eError, 5,eError,eStart,eStart) //30-37 -}; - -static const PRUint32 UCS2LECharLenTable[] = {2, 2, 2, 2, 2, 2}; - -SMModel UCS2LESMModel = { - {eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, UCS2LE_cls }, - 6, - {eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, UCS2LE_st }, - UCS2LECharLenTable, - "UTF-16LE", -}; - - -static PRUint32 UTF8_cls [ 256 / 8 ] = { -//PCK4BITS(0,1,1,1,1,1,1,1), // 00 - 07 -PCK4BITS(1,1,1,1,1,1,1,1), // 00 - 07 //allow 0x00 as a legal value -PCK4BITS(1,1,1,1,1,1,0,0), // 08 - 0f -PCK4BITS(1,1,1,1,1,1,1,1), // 10 - 17 -PCK4BITS(1,1,1,0,1,1,1,1), // 18 - 1f -PCK4BITS(1,1,1,1,1,1,1,1), // 20 - 27 -PCK4BITS(1,1,1,1,1,1,1,1), // 28 - 2f -PCK4BITS(1,1,1,1,1,1,1,1), // 30 - 37 -PCK4BITS(1,1,1,1,1,1,1,1), // 38 - 3f -PCK4BITS(1,1,1,1,1,1,1,1), // 40 - 47 -PCK4BITS(1,1,1,1,1,1,1,1), // 48 - 4f -PCK4BITS(1,1,1,1,1,1,1,1), // 50 - 57 -PCK4BITS(1,1,1,1,1,1,1,1), // 58 - 5f -PCK4BITS(1,1,1,1,1,1,1,1), // 60 - 67 -PCK4BITS(1,1,1,1,1,1,1,1), // 68 - 6f -PCK4BITS(1,1,1,1,1,1,1,1), // 70 - 77 -PCK4BITS(1,1,1,1,1,1,1,1), // 78 - 7f -PCK4BITS(2,2,2,2,3,3,3,3), // 80 - 87 -PCK4BITS(4,4,4,4,4,4,4,4), // 88 - 8f -PCK4BITS(4,4,4,4,4,4,4,4), // 90 - 97 -PCK4BITS(4,4,4,4,4,4,4,4), // 98 - 9f -PCK4BITS(5,5,5,5,5,5,5,5), // a0 - a7 -PCK4BITS(5,5,5,5,5,5,5,5), // a8 - af -PCK4BITS(5,5,5,5,5,5,5,5), // b0 - b7 -PCK4BITS(5,5,5,5,5,5,5,5), // b8 - bf -PCK4BITS(0,0,6,6,6,6,6,6), // c0 - c7 -PCK4BITS(6,6,6,6,6,6,6,6), // c8 - cf -PCK4BITS(6,6,6,6,6,6,6,6), // d0 - d7 -PCK4BITS(6,6,6,6,6,6,6,6), // d8 - df -PCK4BITS(7,8,8,8,8,8,8,8), // e0 - e7 -PCK4BITS(8,8,8,8,8,9,8,8), // e8 - ef -PCK4BITS(10,11,11,11,11,11,11,11), // f0 - f7 -PCK4BITS(12,13,13,13,14,15,0,0) // f8 - ff -}; - - -static PRUint32 UTF8_st [ 26] = { -PCK4BITS(eError,eStart,eError,eError,eError,eError, 12, 10),//00-07 -PCK4BITS( 9, 11, 8, 7, 6, 5, 4, 3),//08-0f -PCK4BITS(eError,eError,eError,eError,eError,eError,eError,eError),//10-17 -PCK4BITS(eError,eError,eError,eError,eError,eError,eError,eError),//18-1f -PCK4BITS(eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe),//20-27 -PCK4BITS(eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe),//28-2f -PCK4BITS(eError,eError, 5, 5, 5, 5,eError,eError),//30-37 -PCK4BITS(eError,eError,eError,eError,eError,eError,eError,eError),//38-3f -PCK4BITS(eError,eError,eError, 5, 5, 5,eError,eError),//40-47 -PCK4BITS(eError,eError,eError,eError,eError,eError,eError,eError),//48-4f -PCK4BITS(eError,eError, 7, 7, 7, 7,eError,eError),//50-57 -PCK4BITS(eError,eError,eError,eError,eError,eError,eError,eError),//58-5f -PCK4BITS(eError,eError,eError,eError, 7, 7,eError,eError),//60-67 -PCK4BITS(eError,eError,eError,eError,eError,eError,eError,eError),//68-6f -PCK4BITS(eError,eError, 9, 9, 9, 9,eError,eError),//70-77 -PCK4BITS(eError,eError,eError,eError,eError,eError,eError,eError),//78-7f -PCK4BITS(eError,eError,eError,eError,eError, 9,eError,eError),//80-87 -PCK4BITS(eError,eError,eError,eError,eError,eError,eError,eError),//88-8f -PCK4BITS(eError,eError, 12, 12, 12, 12,eError,eError),//90-97 -PCK4BITS(eError,eError,eError,eError,eError,eError,eError,eError),//98-9f -PCK4BITS(eError,eError,eError,eError,eError, 12,eError,eError),//a0-a7 -PCK4BITS(eError,eError,eError,eError,eError,eError,eError,eError),//a8-af -PCK4BITS(eError,eError, 12, 12, 12,eError,eError,eError),//b0-b7 -PCK4BITS(eError,eError,eError,eError,eError,eError,eError,eError),//b8-bf -PCK4BITS(eError,eError,eStart,eStart,eStart,eStart,eError,eError),//c0-c7 -PCK4BITS(eError,eError,eError,eError,eError,eError,eError,eError) //c8-cf -}; - -static const PRUint32 UTF8CharLenTable[] = {0, 1, 0, 0, 0, 0, 2, 3, - 3, 3, 4, 4, 5, 5, 6, 6 }; - -SMModel UTF8SMModel = { - {eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, UTF8_cls }, - 16, - {eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, UTF8_st }, - UTF8CharLenTable, - "UTF-8", -}; - -#pragma GCC visibility pop - diff --git a/amarok/utilities/collectionscanner/charset-detector/src/nsPkgInt.h b/amarok/utilities/collectionscanner/charset-detector/src/nsPkgInt.h deleted file mode 100644 index 7617d6c9..00000000 --- a/amarok/utilities/collectionscanner/charset-detector/src/nsPkgInt.h +++ /dev/null @@ -1,89 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef nsPkgInt_h__ -#define nsPkgInt_h__ -#include "nscore.h" - -typedef enum { - eIdxSft4bits = 3, - eIdxSft8bits = 2, - eIdxSft16bits = 1 -} nsIdxSft; - -typedef enum { - eSftMsk4bits = 7, - eSftMsk8bits = 3, - eSftMsk16bits = 1 -} nsSftMsk; - -typedef enum { - eBitSft4bits = 2, - eBitSft8bits = 3, - eBitSft16bits = 4 -} nsBitSft; - -typedef enum { - eUnitMsk4bits = 0x0000000FL, - eUnitMsk8bits = 0x000000FFL, - eUnitMsk16bits = 0x0000FFFFL -} nsUnitMsk; - -typedef struct nsPkgInt { - nsIdxSft idxsft; - nsSftMsk sftmsk; - nsBitSft bitsft; - nsUnitMsk unitmsk; - PRUint32 *data; -} nsPkgInt; - - -#define PCK16BITS(a,b) ((PRUint32)(((b) << 16) | (a))) - -#define PCK8BITS(a,b,c,d) PCK16BITS( ((PRUint32)(((b) << 8) | (a))), \ - ((PRUint32)(((d) << 8) | (c)))) - -#define PCK4BITS(a,b,c,d,e,f,g,h) PCK8BITS( ((PRUint32)(((b) << 4) | (a))), \ - ((PRUint32)(((d) << 4) | (c))), \ - ((PRUint32)(((f) << 4) | (e))), \ - ((PRUint32)(((h) << 4) | (g))) ) - -#define GETFROMPCK(i, c) \ - (((((c).data)[(i)>>(c).idxsft])>>(((i)&(c).sftmsk)<<(c).bitsft))&(c).unitmsk) - -#endif /* nsPkgInt_h__ */ - diff --git a/amarok/utilities/collectionscanner/charset-detector/src/nsSBCSGroupProber.cpp b/amarok/utilities/collectionscanner/charset-detector/src/nsSBCSGroupProber.cpp deleted file mode 100644 index 7c7c6c75..00000000 --- a/amarok/utilities/collectionscanner/charset-detector/src/nsSBCSGroupProber.cpp +++ /dev/null @@ -1,228 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Universal charset detector code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 2001 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Shy Shalom - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#pragma GCC visibility push(hidden) - -#include -#include "prmem.h" - -#include "nsSBCharSetProber.h" -#include "nsSBCSGroupProber.h" - -#include "nsHebrewProber.h" - -nsSBCSGroupProber::nsSBCSGroupProber() -{ - mProbers[0] = new nsSingleByteCharSetProber(&Win1251Model); - mProbers[1] = new nsSingleByteCharSetProber(&Koi8rModel); - mProbers[2] = new nsSingleByteCharSetProber(&Latin5Model); - mProbers[3] = new nsSingleByteCharSetProber(&MacCyrillicModel); - mProbers[4] = new nsSingleByteCharSetProber(&Ibm866Model); - mProbers[5] = new nsSingleByteCharSetProber(&Ibm855Model); - mProbers[6] = new nsSingleByteCharSetProber(&Latin7Model); - mProbers[7] = new nsSingleByteCharSetProber(&Win1253Model); - mProbers[8] = new nsSingleByteCharSetProber(&Latin5BulgarianModel); - mProbers[9] = new nsSingleByteCharSetProber(&Win1251BulgarianModel); - - nsHebrewProber *hebprober = new nsHebrewProber(); - // Notice: Any change in these indexes - 10,11,12 must be reflected - // in the code below as well. - mProbers[10] = hebprober; - mProbers[11] = new nsSingleByteCharSetProber(&Win1255Model, PR_FALSE, hebprober); // Logical Hebrew - mProbers[12] = new nsSingleByteCharSetProber(&Win1255Model, PR_TRUE, hebprober); // Visual Hebrew - // Tell the Hebrew prober about the logical and visual probers - if (mProbers[10] && mProbers[11] && mProbers[12]) // all are not null - { - hebprober->SetModelProbers(mProbers[11], mProbers[12]); - } - else // One or more is null. avoid any Hebrew probing, null them all - { - for (PRUint32 i = 10; i <= 12; ++i) - { - delete mProbers[i]; - mProbers[i] = 0; - } - } - - // disable latin2 before latin1 is available, otherwise all latin1 - // will be detected as latin2 because of their similarity. - //mProbers[10] = new nsSingleByteCharSetProber(&Latin2HungarianModel); - //mProbers[11] = new nsSingleByteCharSetProber(&Win1250HungarianModel); - - Reset(); -} - -nsSBCSGroupProber::~nsSBCSGroupProber() -{ - for (PRUint32 i = 0; i < NUM_OF_SBCS_PROBERS; i++) - { - delete mProbers[i]; - } -} - - -const char* nsSBCSGroupProber::GetCharSetName() -{ - //if we have no answer yet - if (mBestGuess == -1) - { - GetConfidence(); - //no charset seems positive - if (mBestGuess == -1) - //we will use default. - mBestGuess = 0; - } - return mProbers[mBestGuess]->GetCharSetName(); -} - -void nsSBCSGroupProber::Reset(void) -{ - mActiveNum = 0; - for (PRUint32 i = 0; i < NUM_OF_SBCS_PROBERS; i++) - { - if (mProbers[i]) // not null - { - mProbers[i]->Reset(); - mIsActive[i] = PR_TRUE; - ++mActiveNum; - } - else - mIsActive[i] = PR_FALSE; - } - mBestGuess = -1; - mState = eDetecting; -} - - -nsProbingState nsSBCSGroupProber::HandleData(const char* aBuf, PRUint32 aLen) -{ - nsProbingState st; - PRUint32 i; - char *newBuf1 = 0; - PRUint32 newLen1 = 0; - - //apply filter to original buffer, and we got new buffer back - //depend on what script it is, we will feed them the new buffer - //we got after applying proper filter - //this is done without any consideration to KeepEnglishLetters - //of each prober since as of now, there are no probers here which - //recognize languages with English characters. - if (!FilterWithoutEnglishLetters(aBuf, aLen, &newBuf1, newLen1)) - goto done; - - if (newLen1 == 0) - goto done; // Nothing to see here, move on. - - for (i = 0; i < NUM_OF_SBCS_PROBERS; i++) - { - if (!mIsActive[i]) - continue; - st = mProbers[i]->HandleData(newBuf1, newLen1); - if (st == eFoundIt) - { - mBestGuess = i; - mState = eFoundIt; - break; - } - else if (st == eNotMe) - { - mIsActive[i] = PR_FALSE; - mActiveNum--; - if (mActiveNum <= 0) - { - mState = eNotMe; - break; - } - } - } - -done: - PR_FREEIF(newBuf1); - - return mState; -} - -float nsSBCSGroupProber::GetConfidence(void) -{ - PRUint32 i; - float bestConf = 0.0, cf; - - switch (mState) - { - case eFoundIt: - return (float)0.99; //sure yes - case eNotMe: - return (float)0.01; //sure no - default: - for (i = 0; i < NUM_OF_SBCS_PROBERS; i++) - { - if (!mIsActive[i]) - continue; - cf = mProbers[i]->GetConfidence(); - if (bestConf < cf) - { - bestConf = cf; - mBestGuess = i; - } - } - } - return bestConf; -} - -#ifdef DEBUG_chardet -void nsSBCSGroupProber::DumpStatus() -{ - PRUint32 i; - float cf; - - cf = GetConfidence(); - printf(" SBCS Group Prober --------begin status \r\n"); - for (i = 0; i < NUM_OF_SBCS_PROBERS; i++) - { - if (!mIsActive[i]) - printf(" inactive: [%s] (i.e. confidence is too low).\r\n", mProbers[i]->GetCharSetName()); - else - mProbers[i]->DumpStatus(); - } - printf(" SBCS Group found best match [%s] confidence %f.\r\n", - mProbers[mBestGuess]->GetCharSetName(), cf); -} -#endif - -#pragma GCC visibility pop - diff --git a/amarok/utilities/collectionscanner/charset-detector/src/nsSBCSGroupProber.h b/amarok/utilities/collectionscanner/charset-detector/src/nsSBCSGroupProber.h deleted file mode 100644 index 56a8e1c2..00000000 --- a/amarok/utilities/collectionscanner/charset-detector/src/nsSBCSGroupProber.h +++ /dev/null @@ -1,70 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Universal charset detector code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 2001 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Shy Shalom - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef nsSBCSGroupProber_h__ -#define nsSBCSGroupProber_h__ - - -#define NUM_OF_SBCS_PROBERS 13 - -class nsCharSetProber; -class nsSBCSGroupProber: public nsCharSetProber { -public: - nsSBCSGroupProber(); - virtual ~nsSBCSGroupProber(); - nsProbingState HandleData(const char* aBuf, PRUint32 aLen); - const char* GetCharSetName(); - nsProbingState GetState(void) {return mState;}; - void Reset(void); - float GetConfidence(void); - void SetOpion() {}; - -#ifdef DEBUG_chardet - void DumpStatus(); -#endif - -protected: - nsProbingState mState; - nsCharSetProber* mProbers[NUM_OF_SBCS_PROBERS]; - PRBool mIsActive[NUM_OF_SBCS_PROBERS]; - PRInt32 mBestGuess; - PRUint32 mActiveNum; -}; - -#endif /* nsSBCSGroupProber_h__ */ - diff --git a/amarok/utilities/collectionscanner/charset-detector/src/nsSBCharSetProber.cpp b/amarok/utilities/collectionscanner/charset-detector/src/nsSBCharSetProber.cpp deleted file mode 100644 index 3cace1e4..00000000 --- a/amarok/utilities/collectionscanner/charset-detector/src/nsSBCharSetProber.cpp +++ /dev/null @@ -1,132 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Universal charset detector code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 2001 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Shy Shalom - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#pragma GCC visibility push(hidden) - -#include -#include "nsSBCharSetProber.h" - -nsProbingState nsSingleByteCharSetProber::HandleData(const char* aBuf, PRUint32 aLen) -{ - unsigned char order; - - for (PRUint32 i = 0; i < aLen; i++) - { - order = mModel->charToOrderMap[(unsigned char)aBuf[i]]; - - if (order < SYMBOL_CAT_ORDER) - mTotalChar++; - if (order < SAMPLE_SIZE) - { - mFreqChar++; - - if (mLastOrder < SAMPLE_SIZE) - { - mTotalSeqs++; - if (!mReversed) - ++(mSeqCounters[int(mModel->precedenceMatrix[mLastOrder*SAMPLE_SIZE+order])]); - else // reverse the order of the letters in the lookup - ++(mSeqCounters[int(mModel->precedenceMatrix[order*SAMPLE_SIZE+mLastOrder])]); - } - } - mLastOrder = order; - } - - if (mState == eDetecting) - if (mTotalSeqs > SB_ENOUGH_REL_THRESHOLD) - { - float cf = GetConfidence(); - if (cf > POSITIVE_SHORTCUT_THRESHOLD) - mState = eFoundIt; - else if (cf < NEGATIVE_SHORTCUT_THRESHOLD) - mState = eNotMe; - } - - return mState; -} - -void nsSingleByteCharSetProber::Reset(void) -{ - mState = eDetecting; - mLastOrder = 255; - for (PRUint32 i = 0; i < NUMBER_OF_SEQ_CAT; i++) - mSeqCounters[i] = 0; - mTotalSeqs = 0; - mTotalChar = 0; - mFreqChar = 0; -} - -//#define NEGATIVE_APPROACH 1 - -float nsSingleByteCharSetProber::GetConfidence(void) -{ -#ifdef NEGATIVE_APPROACH - if (mTotalSeqs > 0) - if (mTotalSeqs > mSeqCounters[NEGATIVE_CAT]*10 ) - return ((float)(mTotalSeqs - mSeqCounters[NEGATIVE_CAT]*10))/mTotalSeqs * mFreqChar / mTotalChar; - return (float)0.01; -#else //POSITIVE_APPROACH - float r; - - if (mTotalSeqs > 0) { - r = ((float)1.0) * mSeqCounters[POSITIVE_CAT] / mTotalSeqs / mModel->mTypicalPositiveRatio; - r = r*mFreqChar/mTotalChar; - if (r >= (float)1.00) - r = (float)0.99; - return r; - } - return (float)0.01; -#endif -} - -const char* nsSingleByteCharSetProber::GetCharSetName() -{ - if (!mNameProber) - return mModel->charsetName; - return mNameProber->GetCharSetName(); -} - -#ifdef DEBUG_chardet -void nsSingleByteCharSetProber::DumpStatus() -{ - printf(" SBCS: %1.3f [%s]\r\n", GetConfidence(), GetCharSetName()); -} -#endif - -#pragma GCC visibility pop - diff --git a/amarok/utilities/collectionscanner/charset-detector/src/nsSBCharSetProber.h b/amarok/utilities/collectionscanner/charset-detector/src/nsSBCharSetProber.h deleted file mode 100644 index 82117e25..00000000 --- a/amarok/utilities/collectionscanner/charset-detector/src/nsSBCharSetProber.h +++ /dev/null @@ -1,124 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Universal charset detector code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 2001 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Shy Shalom - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ -#ifndef nsSingleByteCharSetProber_h__ -#define nsSingleByteCharSetProber_h__ - -#include "nsCharSetProber.h" - -#define SAMPLE_SIZE 64 -#define SB_ENOUGH_REL_THRESHOLD 1024 -#define POSITIVE_SHORTCUT_THRESHOLD (float)0.95 -#define NEGATIVE_SHORTCUT_THRESHOLD (float)0.05 -#define SYMBOL_CAT_ORDER 250 -#define NUMBER_OF_SEQ_CAT 4 -#define POSITIVE_CAT (NUMBER_OF_SEQ_CAT-1) -#define NEGATIVE_CAT 0 - -typedef struct -{ - unsigned char *charToOrderMap; // [256] table use to find a char's order - char *precedenceMatrix; // [SAMPLE_SIZE][SAMPLE_SIZE]; table to find a 2-char sequence's frequency - float mTypicalPositiveRatio; // = freqSeqs / totalSeqs - PRBool keepEnglishLetter; // says if this script contains English characters (not implemented) - const char* charsetName; -} SequenceModel; - - -class nsSingleByteCharSetProber : public nsCharSetProber{ -public: - nsSingleByteCharSetProber(SequenceModel *model) - :mModel(model), mReversed(PR_FALSE), mNameProber(0) { Reset(); } - nsSingleByteCharSetProber(SequenceModel *model, PRBool reversed, nsCharSetProber* nameProber) - :mModel(model), mReversed(reversed), mNameProber(nameProber) { Reset(); } - - virtual const char* GetCharSetName(); - virtual nsProbingState HandleData(const char* aBuf, PRUint32 aLen); - virtual nsProbingState GetState(void) {return mState;}; - virtual void Reset(void); - virtual float GetConfidence(void); - virtual void SetOpion() {}; - - // This feature is not implemented yet. any current language model - // contain this parameter as PR_FALSE. No one is looking at this - // parameter or calling this method. - // Moreover, the nsSBCSGroupProber which calls the HandleData of this - // prober has a hard-coded call to FilterWithoutEnglishLetters which gets rid - // of the English letters. - PRBool KeepEnglishLetters() {return mModel->keepEnglishLetter;}; // (not implemented) - -#ifdef DEBUG_chardet - virtual void DumpStatus(); -#endif - -protected: - nsProbingState mState; - const SequenceModel *mModel; - const PRBool mReversed; // PR_TRUE if we need to reverse every pair in the model lookup - - //char order of last character - unsigned char mLastOrder; - - PRUint32 mTotalSeqs; - PRUint32 mSeqCounters[NUMBER_OF_SEQ_CAT]; - - PRUint32 mTotalChar; - //characters that fall in our sampling range - PRUint32 mFreqChar; - - // Optional auxiliary prober for name decision. created and destroyed by the GroupProber - nsCharSetProber* mNameProber; - -}; - - -extern SequenceModel Koi8rModel; -extern SequenceModel Win1251Model; -extern SequenceModel Latin5Model; -extern SequenceModel MacCyrillicModel; -extern SequenceModel Ibm866Model; -extern SequenceModel Ibm855Model; -extern SequenceModel Latin7Model; -extern SequenceModel Win1253Model; -extern SequenceModel Latin5BulgarianModel; -extern SequenceModel Win1251BulgarianModel; -extern SequenceModel Latin2HungarianModel; -extern SequenceModel Win1250HungarianModel; -extern SequenceModel Win1255Model; - -#endif /* nsSingleByteCharSetProber_h__ */ - diff --git a/amarok/utilities/collectionscanner/charset-detector/src/nsSJISProber.cpp b/amarok/utilities/collectionscanner/charset-detector/src/nsSJISProber.cpp deleted file mode 100644 index 92d2a014..00000000 --- a/amarok/utilities/collectionscanner/charset-detector/src/nsSJISProber.cpp +++ /dev/null @@ -1,107 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -// for S-JIS encoding, obeserve characteristic: -// 1, kana character (or hankaku?) often have hight frequency of appereance -// 2, kana character often exist in group -// 3, certain combination of kana is never used in japanese language - -#pragma GCC visibility push(hidden) - -#include "nsSJISProber.h" - -void nsSJISProber::Reset(void) -{ - mCodingSM->Reset(); - mState = eDetecting; - mContextAnalyser.Reset(); - mDistributionAnalyser.Reset(); -} - -nsProbingState nsSJISProber::HandleData(const char* aBuf, PRUint32 aLen) -{ - nsSMState codingState; - - for (PRUint32 i = 0; i < aLen; i++) - { - codingState = mCodingSM->NextState(aBuf[i]); - if (codingState == eError) - { - mState = eNotMe; - break; - } - if (codingState == eItsMe) - { - mState = eFoundIt; - break; - } - if (codingState == eStart) - { - PRUint32 charLen = mCodingSM->GetCurrentCharLen(); - if (i == 0) - { - mLastChar[1] = aBuf[0]; - mContextAnalyser.HandleOneChar(mLastChar+2-charLen, charLen); - mDistributionAnalyser.HandleOneChar(mLastChar, charLen); - } - else - { - mContextAnalyser.HandleOneChar(aBuf+i+1-charLen, charLen); - mDistributionAnalyser.HandleOneChar(aBuf+i-1, charLen); - } - } - } - - mLastChar[0] = aBuf[aLen-1]; - - if (mState == eDetecting) - if (mContextAnalyser.GotEnoughData() && GetConfidence() > SHORTCUT_THRESHOLD) - mState = eFoundIt; - - return mState; -} - -float nsSJISProber::GetConfidence(void) -{ - float contxtCf = mContextAnalyser.GetConfidence(); - float distribCf = mDistributionAnalyser.GetConfidence(); - - return (contxtCf > distribCf ? contxtCf : distribCf); -} - -#pragma GCC visibility pop - diff --git a/amarok/utilities/collectionscanner/charset-detector/src/nsSJISProber.h b/amarok/utilities/collectionscanner/charset-detector/src/nsSJISProber.h deleted file mode 100644 index 57abb9cc..00000000 --- a/amarok/utilities/collectionscanner/charset-detector/src/nsSJISProber.h +++ /dev/null @@ -1,74 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -// for S-JIS encoding, obeserve characteristic: -// 1, kana character (or hankaku?) often have hight frequency of appereance -// 2, kana character often exist in group -// 3, certain combination of kana is never used in japanese language - -#ifndef nsSJISProber_h__ -#define nsSJISProber_h__ - -#include "nsCharSetProber.h" -#include "nsCodingStateMachine.h" -#include "JpCntx.h" -#include "CharDistribution.h" - - -class nsSJISProber: public nsCharSetProber, nsCharSetProberHelper { -public: - nsSJISProber(void){mCodingSM = new nsCodingStateMachine(&SJISSMModel); - Reset();}; - virtual ~nsSJISProber(void){delete mCodingSM;}; - nsProbingState HandleData(const char* aBuf, PRUint32 aLen); - const char* GetCharSetName() {return "Shift_JIS";}; - nsProbingState GetState(void) {return mState;}; - void Reset(void); - float GetConfidence(void); - void SetOpion() {}; - -protected: - nsCodingStateMachine* mCodingSM; - nsProbingState mState; - - SJISContextAnalysis mContextAnalyser; - SJISDistributionAnalysis mDistributionAnalyser; -}; - - -#endif /* nsSJISProber_h__ */ - diff --git a/amarok/utilities/collectionscanner/charset-detector/src/nsUTF8Prober.cpp b/amarok/utilities/collectionscanner/charset-detector/src/nsUTF8Prober.cpp deleted file mode 100644 index 5bc45e43..00000000 --- a/amarok/utilities/collectionscanner/charset-detector/src/nsUTF8Prober.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#pragma GCC visibility push(hidden) - -#include "nsUTF8Prober.h" - -void nsUTF8Prober::Reset(void) -{ - mCodingSM->Reset(); - mNumOfMBChar = 0; - mState = eDetecting; -} - -nsProbingState nsUTF8Prober::HandleData(const char* aBuf, PRUint32 aLen) -{ - nsSMState codingState; - - for (PRUint32 i = 0; i < aLen; i++) - { - codingState = mCodingSM->NextState(aBuf[i]); - if (codingState == eError) - { - mState = eNotMe; - break; - } - if (codingState == eItsMe) - { - mState = eFoundIt; - break; - } - if (codingState == eStart) - { - if (mCodingSM->GetCurrentCharLen() >= 2) - mNumOfMBChar++; - } - } - - if (mState == eDetecting) - if (GetConfidence() > SHORTCUT_THRESHOLD) - mState = eFoundIt; - return mState; -} - -#define ONE_CHAR_PROB (float)0.50 - -float nsUTF8Prober::GetConfidence(void) -{ - float unlike = (float)0.99; - - if (mNumOfMBChar < 6) - { - for (PRUint32 i = 0; i < mNumOfMBChar; i++) - unlike *= ONE_CHAR_PROB; - return (float)1.0 - unlike; - } - else - return (float)0.99; -} - -#pragma GCC visibility pop - diff --git a/amarok/utilities/collectionscanner/charset-detector/src/nsUTF8Prober.h b/amarok/utilities/collectionscanner/charset-detector/src/nsUTF8Prober.h deleted file mode 100644 index 9ead2236..00000000 --- a/amarok/utilities/collectionscanner/charset-detector/src/nsUTF8Prober.h +++ /dev/null @@ -1,64 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef nsUTF8Prober_h__ -#define nsUTF8Prober_h__ - -#include "nsCharSetProber.h" -#include "nsCodingStateMachine.h" - -class nsUTF8Prober: public nsCharSetProber { -public: - nsUTF8Prober(){mNumOfMBChar = 0; - mCodingSM = new nsCodingStateMachine(&UTF8SMModel); - Reset(); }; - virtual ~nsUTF8Prober(){delete mCodingSM;}; - nsProbingState HandleData(const char* aBuf, PRUint32 aLen); - const char* GetCharSetName() {return "UTF-8";}; - nsProbingState GetState(void) {return mState;}; - void Reset(void); - float GetConfidence(void); - void SetOpion() {}; - -protected: - nsCodingStateMachine* mCodingSM; - nsProbingState mState; - PRUint32 mNumOfMBChar; -}; - -#endif /* nsUTF8Prober_h__ */ - diff --git a/amarok/utilities/collectionscanner/charset-detector/src/nsUniversalDetector.cpp b/amarok/utilities/collectionscanner/charset-detector/src/nsUniversalDetector.cpp deleted file mode 100644 index 64315cb0..00000000 --- a/amarok/utilities/collectionscanner/charset-detector/src/nsUniversalDetector.cpp +++ /dev/null @@ -1,285 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Universal charset detector code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 2001 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Shy Shalom - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#pragma GCC visibility push(hidden) - -#include "nscore.h" - -#include "nsUniversalDetector.h" - -#include "nsMBCSGroupProber.h" -#include "nsSBCSGroupProber.h" -#include "nsEscCharsetProber.h" -#include "nsLatin1Prober.h" - -nsUniversalDetector::nsUniversalDetector() -{ - mDone = PR_FALSE; - mBestGuess = -1; //illegal value as signal - mInTag = PR_FALSE; - mEscCharSetProber = nsnull; - - mStart = PR_TRUE; - mDetectedCharset = nsnull; - mGotData = PR_FALSE; - mInputState = ePureAscii; - mLastChar = '\0'; - - PRUint32 i; - for (i = 0; i < NUM_OF_CHARSET_PROBERS; i++) - mCharSetProbers[i] = nsnull; -} - -nsUniversalDetector::~nsUniversalDetector() -{ - for (PRInt32 i = 0; i < NUM_OF_CHARSET_PROBERS; i++) - if (mCharSetProbers[i]) - delete mCharSetProbers[i]; - if (mEscCharSetProber) - delete mEscCharSetProber; -} - -void -nsUniversalDetector::Reset() -{ - mDone = PR_FALSE; - mBestGuess = -1; //illegal value as signal - mInTag = PR_FALSE; - - mStart = PR_TRUE; - mDetectedCharset = nsnull; - mGotData = PR_FALSE; - mInputState = ePureAscii; - mLastChar = '\0'; - - if (mEscCharSetProber) - mEscCharSetProber->Reset(); - - PRUint32 i; - for (i = 0; i < NUM_OF_CHARSET_PROBERS; i++) - if (mCharSetProbers[i]) - mCharSetProbers[i]->Reset(); -} - -//--------------------------------------------------------------------- -#define SHORTCUT_THRESHOLD (float)0.95 -#define MINIMUM_THRESHOLD (float)0.20 - -nsresult nsUniversalDetector::HandleData(const char* aBuf, PRUint32 aLen) -{ - if(mDone) - return NS_OK; - - if (aLen > 0) - mGotData = PR_TRUE; - - //If the data starts with BOM, we know it is UTF - if (mStart) - { - mStart = PR_FALSE; - if (aLen > 3) - switch (aBuf[0]) - { - case '\xEF': - if (('\xBB' == aBuf[1]) && ('\xBF' == aBuf[2])) - // EF BB BF UTF-8 encoded BOM - mDetectedCharset = "UTF-8"; - break; - case '\xFE': - if (('\xFF' == aBuf[1]) && ('\x00' == aBuf[2]) && ('\x00' == aBuf[3])) - // FE FF 00 00 UCS-4, unusual octet order BOM (3412) - mDetectedCharset = "X-ISO-10646-UCS-4-3412"; - else if ('\xFF' == aBuf[1]) - // FE FF UTF-16, big endian BOM - mDetectedCharset = "UTF-16BE"; - break; - case '\x00': - if (('\x00' == aBuf[1]) && ('\xFE' == aBuf[2]) && ('\xFF' == aBuf[3])) - // 00 00 FE FF UTF-32, big-endian BOM - mDetectedCharset = "UTF-32BE"; - else if (('\x00' == aBuf[1]) && ('\xFF' == aBuf[2]) && ('\xFE' == aBuf[3])) - // 00 00 FF FE UCS-4, unusual octet order BOM (2143) - mDetectedCharset = "X-ISO-10646-UCS-4-2143"; - break; - case '\xFF': - if (('\xFE' == aBuf[1]) && ('\x00' == aBuf[2]) && ('\x00' == aBuf[3])) - // FF FE 00 00 UTF-32, little-endian BOM - mDetectedCharset = "UTF-32LE"; - else if ('\xFE' == aBuf[1]) - // FF FE UTF-16, little endian BOM - mDetectedCharset = "UTF-16LE"; - break; - } // switch - - if (mDetectedCharset) - { - mDone = PR_TRUE; - return NS_OK; - } - } - - PRUint32 i; - for (i = 0; i < aLen; i++) - { - //other than 0xa0, if every othe character is ascii, the page is ascii - if (aBuf[i] & '\x80' && aBuf[i] != '\xA0') //Since many Ascii only page contains NBSP - { - //we got a non-ascii byte (high-byte) - if (mInputState != eHighbyte) - { - //adjust state - mInputState = eHighbyte; - - //kill mEscCharSetProber if it is active - if (mEscCharSetProber) { - delete mEscCharSetProber; - mEscCharSetProber = nsnull; - } - - //start multibyte and singlebyte charset prober - if (nsnull == mCharSetProbers[0]) - mCharSetProbers[0] = new nsMBCSGroupProber; - if (nsnull == mCharSetProbers[1]) - mCharSetProbers[1] = new nsSBCSGroupProber; - if (nsnull == mCharSetProbers[2]) - mCharSetProbers[2] = new nsLatin1Prober; - - if ((nsnull == mCharSetProbers[0]) || - (nsnull == mCharSetProbers[1]) || - (nsnull == mCharSetProbers[2])) - return NS_ERROR_OUT_OF_MEMORY; - } - } - else - { - //ok, just pure ascii so far - if ( ePureAscii == mInputState && - (aBuf[i] == '\033' || (aBuf[i] == '{' && mLastChar == '~')) ) - { - //found escape character or HZ "~{" - mInputState = eEscAscii; - } - mLastChar = aBuf[i]; - } - } - - nsProbingState st; - switch (mInputState) - { - case eEscAscii: - if (nsnull == mEscCharSetProber) { - mEscCharSetProber = new nsEscCharSetProber; - if (nsnull == mEscCharSetProber) - return NS_ERROR_OUT_OF_MEMORY; - } - st = mEscCharSetProber->HandleData(aBuf, aLen); - if (st == eFoundIt) - { - mDone = PR_TRUE; - mDetectedCharset = mEscCharSetProber->GetCharSetName(); - } - break; - case eHighbyte: - for (i = 0; i < NUM_OF_CHARSET_PROBERS; i++) - { - st = mCharSetProbers[i]->HandleData(aBuf, aLen); - if (st == eFoundIt) - { - mDone = PR_TRUE; - mDetectedCharset = mCharSetProbers[i]->GetCharSetName(); - return NS_OK; - } - } - break; - - default: //pure ascii - ;//do nothing here - } - return NS_OK; -} - - -//--------------------------------------------------------------------- -void nsUniversalDetector::DataEnd() -{ - if (!mGotData) - { - // we haven't got any data yet, return immediately - // caller program sometimes call DataEnd before anything has been sent to detector - return; - } - - if (mDetectedCharset) - { - mDone = PR_TRUE; - Report(mDetectedCharset); - return; - } - - switch (mInputState) - { - case eHighbyte: - { - float proberConfidence; - float maxProberConfidence = (float)0.0; - PRInt32 maxProber = 0; - - for (PRInt32 i = 0; i < NUM_OF_CHARSET_PROBERS; i++) - { - proberConfidence = mCharSetProbers[i]->GetConfidence(); - if (proberConfidence > maxProberConfidence) - { - maxProberConfidence = proberConfidence; - maxProber = i; - } - } - //do not report anything because we are not confident of it, that's in fact a negative answer - if (maxProberConfidence > MINIMUM_THRESHOLD) - Report(mCharSetProbers[maxProber]->GetCharSetName()); - } - break; - case eEscAscii: - break; - default: - ; - } - return; -} - -#pragma GCC visibility pop - diff --git a/amarok/utilities/collectionscanner/charset-detector/src/nsUniversalDetector.h b/amarok/utilities/collectionscanner/charset-detector/src/nsUniversalDetector.h deleted file mode 100644 index 36f3fa03..00000000 --- a/amarok/utilities/collectionscanner/charset-detector/src/nsUniversalDetector.h +++ /dev/null @@ -1,75 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef nsUniversalDetector_h__ -#define nsUniversalDetector_h__ - -class nsCharSetProber; - -#define NUM_OF_CHARSET_PROBERS 3 - -typedef enum { - ePureAscii = 0, - eEscAscii = 1, - eHighbyte = 2 -} nsInputState; - -class nsUniversalDetector { -public: - nsUniversalDetector(); - virtual ~nsUniversalDetector(); - virtual nsresult HandleData(const char* aBuf, PRUint32 aLen); - virtual void DataEnd(void); - -protected: - virtual void Report(const char* aCharset) = 0; - virtual void Reset(); - nsInputState mInputState; - PRBool mDone; - PRBool mInTag; - PRBool mStart; - PRBool mGotData; - char mLastChar; - const char * mDetectedCharset; - PRInt32 mBestGuess; - - nsCharSetProber *mCharSetProbers[NUM_OF_CHARSET_PROBERS]; - nsCharSetProber *mEscCharSetProber; -}; - -#endif - diff --git a/amarok/utilities/collectionscanner/charset-detector/src/nscore.h b/amarok/utilities/collectionscanner/charset-detector/src/nscore.h deleted file mode 100644 index 83d74856..00000000 --- a/amarok/utilities/collectionscanner/charset-detector/src/nscore.h +++ /dev/null @@ -1,57 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Universal charset detector code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 2001 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Kohei TAKETA - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ -#ifndef nsDummyCore_h__ -#define nsDummyCore_h__ - -typedef bool PRBool; -typedef int PRInt32; -typedef unsigned int PRUint32; -typedef short PRInt16; -typedef unsigned short PRUint16; - -#define PR_FALSE false -#define PR_TRUE true -#define nsnull 0 - - -enum nsresult -{ - NS_OK, - NS_ERROR_OUT_OF_MEMORY -}; - -#endif diff --git a/amarok/utilities/collectionscanner/charset-detector/src/prmem.h b/amarok/utilities/collectionscanner/charset-detector/src/prmem.h deleted file mode 100644 index cff6c7a1..00000000 --- a/amarok/utilities/collectionscanner/charset-detector/src/prmem.h +++ /dev/null @@ -1,49 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Universal charset detector code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 2001 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Kohei TAKETA - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ -#ifndef nsDummyPrmem_h__ -#define nsDummyPrmem_h__ - -#include - -inline void* PR_Malloc(size_t len) -{ - return malloc(len); -} - -#define PR_FREEIF(p) do { if (p) delete p; } while(0) - -#endif diff --git a/amarok/utilities/collectionscanner/charset-detector/src/tables/Big5Freq.tab b/amarok/utilities/collectionscanner/charset-detector/src/tables/Big5Freq.tab deleted file mode 100644 index fd6b0e00..00000000 --- a/amarok/utilities/collectionscanner/charset-detector/src/tables/Big5Freq.tab +++ /dev/null @@ -1,943 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -// Big5 frequency table -// by Taiwan's Mandarin Promotion Council -// - -/****************************************************************************** - * 128 --> 0.42261 - * 256 --> 0.57851 - * 512 --> 0.74851 - * 1024 --> 0.89384 - * 2048 --> 0.97583 - * - * Idea Distribution Ratio = 0.74851/(1-0.74851) =2.98 - * Random Distribution Ration = 512/(5401-512)=0.105 - * - * Typical Distribution Ratio about 25% of Ideal one, still much higher than RDR - *****************************************************************************/ - -#define BIG5_TYPICAL_DISTRIBUTION_RATIO (float)0.75 - - -//Char to FreqOrder table , -#define BIG5_TABLE_SIZE 5376 - -static const PRInt16 Big5CharToFreqOrder[] = -{ - 1,1801,1506, 255,1431, 198, 9, 82, 6,5008, 177, 202,3681,1256,2821, 110, // 16 -3814, 33,3274, 261, 76, 44,2114, 16,2946,2187,1176, 659,3971, 26,3451,2653, // 32 -1198,3972,3350,4202, 410,2215, 302, 590, 361,1964, 8, 204, 58,4510,5009,1932, // 48 - 63,5010,5011, 317,1614, 75, 222, 159,4203,2417,1480,5012,3555,3091, 224,2822, // 64 -3682, 3, 10,3973,1471, 29,2787,1135,2866,1940, 873, 130,3275,1123, 312,5013, // 80 -4511,2052, 507, 252, 682,5014, 142,1915, 124, 206,2947, 34,3556,3204, 64, 604, // 96 -5015,2501,1977,1978, 155,1991, 645, 641,1606,5016,3452, 337, 72, 406,5017, 80, // 112 - 630, 238,3205,1509, 263, 939,1092,2654, 756,1440,1094,3453, 449, 69,2987, 591, // 128 - 179,2096, 471, 115,2035,1844, 60, 50,2988, 134, 806,1869, 734,2036,3454, 180, // 144 - 995,1607, 156, 537,2907, 688,5018, 319,1305, 779,2145, 514,2379, 298,4512, 359, // 160 -2502, 90,2716,1338, 663, 11, 906,1099,2553, 20,2441, 182, 532,1716,5019, 732, // 176 -1376,4204,1311,1420,3206, 25,2317,1056, 113, 399, 382,1950, 242,3455,2474, 529, // 192 -3276, 475,1447,3683,5020, 117, 21, 656, 810,1297,2300,2334,3557,5021, 126,4205, // 208 - 706, 456, 150, 613,4513, 71,1118,2037,4206, 145,3092, 85, 835, 486,2115,1246, // 224 -1426, 428, 727,1285,1015, 800, 106, 623, 303,1281,5022,2128,2359, 347,3815, 221, // 240 -3558,3135,5023,1956,1153,4207, 83, 296,1199,3093, 192, 624, 93,5024, 822,1898, // 256 -2823,3136, 795,2065, 991,1554,1542,1592, 27, 43,2867, 859, 139,1456, 860,4514, // 272 - 437, 712,3974, 164,2397,3137, 695, 211,3037,2097, 195,3975,1608,3559,3560,3684, // 288 -3976, 234, 811,2989,2098,3977,2233,1441,3561,1615,2380, 668,2077,1638, 305, 228, // 304 -1664,4515, 467, 415,5025, 262,2099,1593, 239, 108, 300, 200,1033, 512,1247,2078, // 320 -5026,5027,2176,3207,3685,2682, 593, 845,1062,3277, 88,1723,2038,3978,1951, 212, // 336 - 266, 152, 149, 468,1899,4208,4516, 77, 187,5028,3038, 37, 5,2990,5029,3979, // 352 -5030,5031, 39,2524,4517,2908,3208,2079, 55, 148, 74,4518, 545, 483,1474,1029, // 368 -1665, 217,1870,1531,3138,1104,2655,4209, 24, 172,3562, 900,3980,3563,3564,4519, // 384 - 32,1408,2824,1312, 329, 487,2360,2251,2717, 784,2683, 4,3039,3351,1427,1789, // 400 - 188, 109, 499,5032,3686,1717,1790, 888,1217,3040,4520,5033,3565,5034,3352,1520, // 416 -3687,3981, 196,1034, 775,5035,5036, 929,1816, 249, 439, 38,5037,1063,5038, 794, // 432 -3982,1435,2301, 46, 178,3278,2066,5039,2381,5040, 214,1709,4521, 804, 35, 707, // 448 - 324,3688,1601,2554, 140, 459,4210,5041,5042,1365, 839, 272, 978,2262,2580,3456, // 464 -2129,1363,3689,1423, 697, 100,3094, 48, 70,1231, 495,3139,2196,5043,1294,5044, // 480 -2080, 462, 586,1042,3279, 853, 256, 988, 185,2382,3457,1698, 434,1084,5045,3458, // 496 - 314,2625,2788,4522,2335,2336, 569,2285, 637,1817,2525, 757,1162,1879,1616,3459, // 512 - 287,1577,2116, 768,4523,1671,2868,3566,2526,1321,3816, 909,2418,5046,4211, 933, // 528 -3817,4212,2053,2361,1222,4524, 765,2419,1322, 786,4525,5047,1920,1462,1677,2909, // 544 -1699,5048,4526,1424,2442,3140,3690,2600,3353,1775,1941,3460,3983,4213, 309,1369, // 560 -1130,2825, 364,2234,1653,1299,3984,3567,3985,3986,2656, 525,1085,3041, 902,2001, // 576 -1475, 964,4527, 421,1845,1415,1057,2286, 940,1364,3141, 376,4528,4529,1381, 7, // 592 -2527, 983,2383, 336,1710,2684,1846, 321,3461, 559,1131,3042,2752,1809,1132,1313, // 608 - 265,1481,1858,5049, 352,1203,2826,3280, 167,1089, 420,2827, 776, 792,1724,3568, // 624 -4214,2443,3281,5050,4215,5051, 446, 229, 333,2753, 901,3818,1200,1557,4530,2657, // 640 -1921, 395,2754,2685,3819,4216,1836, 125, 916,3209,2626,4531,5052,5053,3820,5054, // 656 -5055,5056,4532,3142,3691,1133,2555,1757,3462,1510,2318,1409,3569,5057,2146, 438, // 672 -2601,2910,2384,3354,1068, 958,3043, 461, 311,2869,2686,4217,1916,3210,4218,1979, // 688 - 383, 750,2755,2627,4219, 274, 539, 385,1278,1442,5058,1154,1965, 384, 561, 210, // 704 - 98,1295,2556,3570,5059,1711,2420,1482,3463,3987,2911,1257, 129,5060,3821, 642, // 720 - 523,2789,2790,2658,5061, 141,2235,1333, 68, 176, 441, 876, 907,4220, 603,2602, // 736 - 710, 171,3464, 404, 549, 18,3143,2398,1410,3692,1666,5062,3571,4533,2912,4534, // 752 -5063,2991, 368,5064, 146, 366, 99, 871,3693,1543, 748, 807,1586,1185, 22,2263, // 768 - 379,3822,3211,5065,3212, 505,1942,2628,1992,1382,2319,5066, 380,2362, 218, 702, // 784 -1818,1248,3465,3044,3572,3355,3282,5067,2992,3694, 930,3283,3823,5068, 59,5069, // 800 - 585, 601,4221, 497,3466,1112,1314,4535,1802,5070,1223,1472,2177,5071, 749,1837, // 816 - 690,1900,3824,1773,3988,1476, 429,1043,1791,2236,2117, 917,4222, 447,1086,1629, // 832 -5072, 556,5073,5074,2021,1654, 844,1090, 105, 550, 966,1758,2828,1008,1783, 686, // 848 -1095,5075,2287, 793,1602,5076,3573,2603,4536,4223,2948,2302,4537,3825, 980,2503, // 864 - 544, 353, 527,4538, 908,2687,2913,5077, 381,2629,1943,1348,5078,1341,1252, 560, // 880 -3095,5079,3467,2870,5080,2054, 973, 886,2081, 143,4539,5081,5082, 157,3989, 496, // 896 -4224, 57, 840, 540,2039,4540,4541,3468,2118,1445, 970,2264,1748,1966,2082,4225, // 912 -3144,1234,1776,3284,2829,3695, 773,1206,2130,1066,2040,1326,3990,1738,1725,4226, // 928 - 279,3145, 51,1544,2604, 423,1578,2131,2067, 173,4542,1880,5083,5084,1583, 264, // 944 - 610,3696,4543,2444, 280, 154,5085,5086,5087,1739, 338,1282,3096, 693,2871,1411, // 960 -1074,3826,2445,5088,4544,5089,5090,1240, 952,2399,5091,2914,1538,2688, 685,1483, // 976 -4227,2475,1436, 953,4228,2055,4545, 671,2400, 79,4229,2446,3285, 608, 567,2689, // 992 -3469,4230,4231,1691, 393,1261,1792,2401,5092,4546,5093,5094,5095,5096,1383,1672, // 1008 -3827,3213,1464, 522,1119, 661,1150, 216, 675,4547,3991,1432,3574, 609,4548,2690, // 1024 -2402,5097,5098,5099,4232,3045, 0,5100,2476, 315, 231,2447, 301,3356,4549,2385, // 1040 -5101, 233,4233,3697,1819,4550,4551,5102, 96,1777,1315,2083,5103, 257,5104,1810, // 1056 -3698,2718,1139,1820,4234,2022,1124,2164,2791,1778,2659,5105,3097, 363,1655,3214, // 1072 -5106,2993,5107,5108,5109,3992,1567,3993, 718, 103,3215, 849,1443, 341,3357,2949, // 1088 -1484,5110,1712, 127, 67, 339,4235,2403, 679,1412, 821,5111,5112, 834, 738, 351, // 1104 -2994,2147, 846, 235,1497,1881, 418,1993,3828,2719, 186,1100,2148,2756,3575,1545, // 1120 -1355,2950,2872,1377, 583,3994,4236,2581,2995,5113,1298,3699,1078,2557,3700,2363, // 1136 - 78,3829,3830, 267,1289,2100,2002,1594,4237, 348, 369,1274,2197,2178,1838,4552, // 1152 -1821,2830,3701,2757,2288,2003,4553,2951,2758, 144,3358, 882,4554,3995,2759,3470, // 1168 -4555,2915,5114,4238,1726, 320,5115,3996,3046, 788,2996,5116,2831,1774,1327,2873, // 1184 -3997,2832,5117,1306,4556,2004,1700,3831,3576,2364,2660, 787,2023, 506, 824,3702, // 1200 - 534, 323,4557,1044,3359,2024,1901, 946,3471,5118,1779,1500,1678,5119,1882,4558, // 1216 - 165, 243,4559,3703,2528, 123, 683,4239, 764,4560, 36,3998,1793, 589,2916, 816, // 1232 - 626,1667,3047,2237,1639,1555,1622,3832,3999,5120,4000,2874,1370,1228,1933, 891, // 1248 -2084,2917, 304,4240,5121, 292,2997,2720,3577, 691,2101,4241,1115,4561, 118, 662, // 1264 -5122, 611,1156, 854,2386,1316,2875, 2, 386, 515,2918,5123,5124,3286, 868,2238, // 1280 -1486, 855,2661, 785,2216,3048,5125,1040,3216,3578,5126,3146, 448,5127,1525,5128, // 1296 -2165,4562,5129,3833,5130,4242,2833,3579,3147, 503, 818,4001,3148,1568, 814, 676, // 1312 -1444, 306,1749,5131,3834,1416,1030, 197,1428, 805,2834,1501,4563,5132,5133,5134, // 1328 -1994,5135,4564,5136,5137,2198, 13,2792,3704,2998,3149,1229,1917,5138,3835,2132, // 1344 -5139,4243,4565,2404,3580,5140,2217,1511,1727,1120,5141,5142, 646,3836,2448, 307, // 1360 -5143,5144,1595,3217,5145,5146,5147,3705,1113,1356,4002,1465,2529,2530,5148, 519, // 1376 -5149, 128,2133, 92,2289,1980,5150,4003,1512, 342,3150,2199,5151,2793,2218,1981, // 1392 -3360,4244, 290,1656,1317, 789, 827,2365,5152,3837,4566, 562, 581,4004,5153, 401, // 1408 -4567,2252, 94,4568,5154,1399,2794,5155,1463,2025,4569,3218,1944,5156, 828,1105, // 1424 -4245,1262,1394,5157,4246, 605,4570,5158,1784,2876,5159,2835, 819,2102, 578,2200, // 1440 -2952,5160,1502, 436,3287,4247,3288,2836,4005,2919,3472,3473,5161,2721,2320,5162, // 1456 -5163,2337,2068, 23,4571, 193, 826,3838,2103, 699,1630,4248,3098, 390,1794,1064, // 1472 -3581,5164,1579,3099,3100,1400,5165,4249,1839,1640,2877,5166,4572,4573, 137,4250, // 1488 - 598,3101,1967, 780, 104, 974,2953,5167, 278, 899, 253, 402, 572, 504, 493,1339, // 1504 -5168,4006,1275,4574,2582,2558,5169,3706,3049,3102,2253, 565,1334,2722, 863, 41, // 1520 -5170,5171,4575,5172,1657,2338, 19, 463,2760,4251, 606,5173,2999,3289,1087,2085, // 1536 -1323,2662,3000,5174,1631,1623,1750,4252,2691,5175,2878, 791,2723,2663,2339, 232, // 1552 -2421,5176,3001,1498,5177,2664,2630, 755,1366,3707,3290,3151,2026,1609, 119,1918, // 1568 -3474, 862,1026,4253,5178,4007,3839,4576,4008,4577,2265,1952,2477,5179,1125, 817, // 1584 -4254,4255,4009,1513,1766,2041,1487,4256,3050,3291,2837,3840,3152,5180,5181,1507, // 1600 -5182,2692, 733, 40,1632,1106,2879, 345,4257, 841,2531, 230,4578,3002,1847,3292, // 1616 -3475,5183,1263, 986,3476,5184, 735, 879, 254,1137, 857, 622,1300,1180,1388,1562, // 1632 -4010,4011,2954, 967,2761,2665,1349, 592,2134,1692,3361,3003,1995,4258,1679,4012, // 1648 -1902,2188,5185, 739,3708,2724,1296,1290,5186,4259,2201,2202,1922,1563,2605,2559, // 1664 -1871,2762,3004,5187, 435,5188, 343,1108, 596, 17,1751,4579,2239,3477,3709,5189, // 1680 -4580, 294,3582,2955,1693, 477, 979, 281,2042,3583, 643,2043,3710,2631,2795,2266, // 1696 -1031,2340,2135,2303,3584,4581, 367,1249,2560,5190,3585,5191,4582,1283,3362,2005, // 1712 - 240,1762,3363,4583,4584, 836,1069,3153, 474,5192,2149,2532, 268,3586,5193,3219, // 1728 -1521,1284,5194,1658,1546,4260,5195,3587,3588,5196,4261,3364,2693,1685,4262, 961, // 1744 -1673,2632, 190,2006,2203,3841,4585,4586,5197, 570,2504,3711,1490,5198,4587,2633, // 1760 -3293,1957,4588, 584,1514, 396,1045,1945,5199,4589,1968,2449,5200,5201,4590,4013, // 1776 - 619,5202,3154,3294, 215,2007,2796,2561,3220,4591,3221,4592, 763,4263,3842,4593, // 1792 -5203,5204,1958,1767,2956,3365,3712,1174, 452,1477,4594,3366,3155,5205,2838,1253, // 1808 -2387,2189,1091,2290,4264, 492,5206, 638,1169,1825,2136,1752,4014, 648, 926,1021, // 1824 -1324,4595, 520,4596, 997, 847,1007, 892,4597,3843,2267,1872,3713,2405,1785,4598, // 1840 -1953,2957,3103,3222,1728,4265,2044,3714,4599,2008,1701,3156,1551, 30,2268,4266, // 1856 -5207,2027,4600,3589,5208, 501,5209,4267, 594,3478,2166,1822,3590,3479,3591,3223, // 1872 - 829,2839,4268,5210,1680,3157,1225,4269,5211,3295,4601,4270,3158,2341,5212,4602, // 1888 -4271,5213,4015,4016,5214,1848,2388,2606,3367,5215,4603, 374,4017, 652,4272,4273, // 1904 - 375,1140, 798,5216,5217,5218,2366,4604,2269, 546,1659, 138,3051,2450,4605,5219, // 1920 -2254, 612,1849, 910, 796,3844,1740,1371, 825,3845,3846,5220,2920,2562,5221, 692, // 1936 - 444,3052,2634, 801,4606,4274,5222,1491, 244,1053,3053,4275,4276, 340,5223,4018, // 1952 -1041,3005, 293,1168, 87,1357,5224,1539, 959,5225,2240, 721, 694,4277,3847, 219, // 1968 -1478, 644,1417,3368,2666,1413,1401,1335,1389,4019,5226,5227,3006,2367,3159,1826, // 1984 - 730,1515, 184,2840, 66,4607,5228,1660,2958, 246,3369, 378,1457, 226,3480, 975, // 2000 -4020,2959,1264,3592, 674, 696,5229, 163,5230,1141,2422,2167, 713,3593,3370,4608, // 2016 -4021,5231,5232,1186, 15,5233,1079,1070,5234,1522,3224,3594, 276,1050,2725, 758, // 2032 -1126, 653,2960,3296,5235,2342, 889,3595,4022,3104,3007, 903,1250,4609,4023,3481, // 2048 -3596,1342,1681,1718, 766,3297, 286, 89,2961,3715,5236,1713,5237,2607,3371,3008, // 2064 -5238,2962,2219,3225,2880,5239,4610,2505,2533, 181, 387,1075,4024, 731,2190,3372, // 2080 -5240,3298, 310, 313,3482,2304, 770,4278, 54,3054, 189,4611,3105,3848,4025,5241, // 2096 -1230,1617,1850, 355,3597,4279,4612,3373, 111,4280,3716,1350,3160,3483,3055,4281, // 2112 -2150,3299,3598,5242,2797,4026,4027,3009, 722,2009,5243,1071, 247,1207,2343,2478, // 2128 -1378,4613,2010, 864,1437,1214,4614, 373,3849,1142,2220, 667,4615, 442,2763,2563, // 2144 -3850,4028,1969,4282,3300,1840, 837, 170,1107, 934,1336,1883,5244,5245,2119,4283, // 2160 -2841, 743,1569,5246,4616,4284, 582,2389,1418,3484,5247,1803,5248, 357,1395,1729, // 2176 -3717,3301,2423,1564,2241,5249,3106,3851,1633,4617,1114,2086,4285,1532,5250, 482, // 2192 -2451,4618,5251,5252,1492, 833,1466,5253,2726,3599,1641,2842,5254,1526,1272,3718, // 2208 -4286,1686,1795, 416,2564,1903,1954,1804,5255,3852,2798,3853,1159,2321,5256,2881, // 2224 -4619,1610,1584,3056,2424,2764, 443,3302,1163,3161,5257,5258,4029,5259,4287,2506, // 2240 -3057,4620,4030,3162,2104,1647,3600,2011,1873,4288,5260,4289, 431,3485,5261, 250, // 2256 - 97, 81,4290,5262,1648,1851,1558, 160, 848,5263, 866, 740,1694,5264,2204,2843, // 2272 -3226,4291,4621,3719,1687, 950,2479, 426, 469,3227,3720,3721,4031,5265,5266,1188, // 2288 - 424,1996, 861,3601,4292,3854,2205,2694, 168,1235,3602,4293,5267,2087,1674,4622, // 2304 -3374,3303, 220,2565,1009,5268,3855, 670,3010, 332,1208, 717,5269,5270,3603,2452, // 2320 -4032,3375,5271, 513,5272,1209,2882,3376,3163,4623,1080,5273,5274,5275,5276,2534, // 2336 -3722,3604, 815,1587,4033,4034,5277,3605,3486,3856,1254,4624,1328,3058,1390,4035, // 2352 -1741,4036,3857,4037,5278, 236,3858,2453,3304,5279,5280,3723,3859,1273,3860,4625, // 2368 -5281, 308,5282,4626, 245,4627,1852,2480,1307,2583, 430, 715,2137,2454,5283, 270, // 2384 - 199,2883,4038,5284,3606,2727,1753, 761,1754, 725,1661,1841,4628,3487,3724,5285, // 2400 -5286, 587, 14,3305, 227,2608, 326, 480,2270, 943,2765,3607, 291, 650,1884,5287, // 2416 -1702,1226, 102,1547, 62,3488, 904,4629,3489,1164,4294,5288,5289,1224,1548,2766, // 2432 - 391, 498,1493,5290,1386,1419,5291,2056,1177,4630, 813, 880,1081,2368, 566,1145, // 2448 -4631,2291,1001,1035,2566,2609,2242, 394,1286,5292,5293,2069,5294, 86,1494,1730, // 2464 -4039, 491,1588, 745, 897,2963, 843,3377,4040,2767,2884,3306,1768, 998,2221,2070, // 2480 - 397,1827,1195,1970,3725,3011,3378, 284,5295,3861,2507,2138,2120,1904,5296,4041, // 2496 -2151,4042,4295,1036,3490,1905, 114,2567,4296, 209,1527,5297,5298,2964,2844,2635, // 2512 -2390,2728,3164, 812,2568,5299,3307,5300,1559, 737,1885,3726,1210, 885, 28,2695, // 2528 -3608,3862,5301,4297,1004,1780,4632,5302, 346,1982,2222,2696,4633,3863,1742, 797, // 2544 -1642,4043,1934,1072,1384,2152, 896,4044,3308,3727,3228,2885,3609,5303,2569,1959, // 2560 -4634,2455,1786,5304,5305,5306,4045,4298,1005,1308,3728,4299,2729,4635,4636,1528, // 2576 -2610, 161,1178,4300,1983, 987,4637,1101,4301, 631,4046,1157,3229,2425,1343,1241, // 2592 -1016,2243,2570, 372, 877,2344,2508,1160, 555,1935, 911,4047,5307, 466,1170, 169, // 2608 -1051,2921,2697,3729,2481,3012,1182,2012,2571,1251,2636,5308, 992,2345,3491,1540, // 2624 -2730,1201,2071,2406,1997,2482,5309,4638, 528,1923,2191,1503,1874,1570,2369,3379, // 2640 -3309,5310, 557,1073,5311,1828,3492,2088,2271,3165,3059,3107, 767,3108,2799,4639, // 2656 -1006,4302,4640,2346,1267,2179,3730,3230, 778,4048,3231,2731,1597,2667,5312,4641, // 2672 -5313,3493,5314,5315,5316,3310,2698,1433,3311, 131, 95,1504,4049, 723,4303,3166, // 2688 -1842,3610,2768,2192,4050,2028,2105,3731,5317,3013,4051,1218,5318,3380,3232,4052, // 2704 -4304,2584, 248,1634,3864, 912,5319,2845,3732,3060,3865, 654, 53,5320,3014,5321, // 2720 -1688,4642, 777,3494,1032,4053,1425,5322, 191, 820,2121,2846, 971,4643, 931,3233, // 2736 - 135, 664, 783,3866,1998, 772,2922,1936,4054,3867,4644,2923,3234, 282,2732, 640, // 2752 -1372,3495,1127, 922, 325,3381,5323,5324, 711,2045,5325,5326,4055,2223,2800,1937, // 2768 -4056,3382,2224,2255,3868,2305,5327,4645,3869,1258,3312,4057,3235,2139,2965,4058, // 2784 -4059,5328,2225, 258,3236,4646, 101,1227,5329,3313,1755,5330,1391,3314,5331,2924, // 2800 -2057, 893,5332,5333,5334,1402,4305,2347,5335,5336,3237,3611,5337,5338, 878,1325, // 2816 -1781,2801,4647, 259,1385,2585, 744,1183,2272,4648,5339,4060,2509,5340, 684,1024, // 2832 -4306,5341, 472,3612,3496,1165,3315,4061,4062, 322,2153, 881, 455,1695,1152,1340, // 2848 - 660, 554,2154,4649,1058,4650,4307, 830,1065,3383,4063,4651,1924,5342,1703,1919, // 2864 -5343, 932,2273, 122,5344,4652, 947, 677,5345,3870,2637, 297,1906,1925,2274,4653, // 2880 -2322,3316,5346,5347,4308,5348,4309, 84,4310, 112, 989,5349, 547,1059,4064, 701, // 2896 -3613,1019,5350,4311,5351,3497, 942, 639, 457,2306,2456, 993,2966, 407, 851, 494, // 2912 -4654,3384, 927,5352,1237,5353,2426,3385, 573,4312, 680, 921,2925,1279,1875, 285, // 2928 - 790,1448,1984, 719,2168,5354,5355,4655,4065,4066,1649,5356,1541, 563,5357,1077, // 2944 -5358,3386,3061,3498, 511,3015,4067,4068,3733,4069,1268,2572,3387,3238,4656,4657, // 2960 -5359, 535,1048,1276,1189,2926,2029,3167,1438,1373,2847,2967,1134,2013,5360,4313, // 2976 -1238,2586,3109,1259,5361, 700,5362,2968,3168,3734,4314,5363,4315,1146,1876,1907, // 2992 -4658,2611,4070, 781,2427, 132,1589, 203, 147, 273,2802,2407, 898,1787,2155,4071, // 3008 -4072,5364,3871,2803,5365,5366,4659,4660,5367,3239,5368,1635,3872, 965,5369,1805, // 3024 -2699,1516,3614,1121,1082,1329,3317,4073,1449,3873, 65,1128,2848,2927,2769,1590, // 3040 -3874,5370,5371, 12,2668, 45, 976,2587,3169,4661, 517,2535,1013,1037,3240,5372, // 3056 -3875,2849,5373,3876,5374,3499,5375,2612, 614,1999,2323,3877,3110,2733,2638,5376, // 3072 -2588,4316, 599,1269,5377,1811,3735,5378,2700,3111, 759,1060, 489,1806,3388,3318, // 3088 -1358,5379,5380,2391,1387,1215,2639,2256, 490,5381,5382,4317,1759,2392,2348,5383, // 3104 -4662,3878,1908,4074,2640,1807,3241,4663,3500,3319,2770,2349, 874,5384,5385,3501, // 3120 -3736,1859, 91,2928,3737,3062,3879,4664,5386,3170,4075,2669,5387,3502,1202,1403, // 3136 -3880,2969,2536,1517,2510,4665,3503,2511,5388,4666,5389,2701,1886,1495,1731,4076, // 3152 -2370,4667,5390,2030,5391,5392,4077,2702,1216, 237,2589,4318,2324,4078,3881,4668, // 3168 -4669,2703,3615,3504, 445,4670,5393,5394,5395,5396,2771, 61,4079,3738,1823,4080, // 3184 -5397, 687,2046, 935, 925, 405,2670, 703,1096,1860,2734,4671,4081,1877,1367,2704, // 3200 -3389, 918,2106,1782,2483, 334,3320,1611,1093,4672, 564,3171,3505,3739,3390, 945, // 3216 -2641,2058,4673,5398,1926, 872,4319,5399,3506,2705,3112, 349,4320,3740,4082,4674, // 3232 -3882,4321,3741,2156,4083,4675,4676,4322,4677,2408,2047, 782,4084, 400, 251,4323, // 3248 -1624,5400,5401, 277,3742, 299,1265, 476,1191,3883,2122,4324,4325,1109, 205,5402, // 3264 -2590,1000,2157,3616,1861,5403,5404,5405,4678,5406,4679,2573, 107,2484,2158,4085, // 3280 -3507,3172,5407,1533, 541,1301, 158, 753,4326,2886,3617,5408,1696, 370,1088,4327, // 3296 -4680,3618, 579, 327, 440, 162,2244, 269,1938,1374,3508, 968,3063, 56,1396,3113, // 3312 -2107,3321,3391,5409,1927,2159,4681,3016,5410,3619,5411,5412,3743,4682,2485,5413, // 3328 -2804,5414,1650,4683,5415,2613,5416,5417,4086,2671,3392,1149,3393,4087,3884,4088, // 3344 -5418,1076, 49,5419, 951,3242,3322,3323, 450,2850, 920,5420,1812,2805,2371,4328, // 3360 -1909,1138,2372,3885,3509,5421,3243,4684,1910,1147,1518,2428,4685,3886,5422,4686, // 3376 -2393,2614, 260,1796,3244,5423,5424,3887,3324, 708,5425,3620,1704,5426,3621,1351, // 3392 -1618,3394,3017,1887, 944,4329,3395,4330,3064,3396,4331,5427,3744, 422, 413,1714, // 3408 -3325, 500,2059,2350,4332,2486,5428,1344,1911, 954,5429,1668,5430,5431,4089,2409, // 3424 -4333,3622,3888,4334,5432,2307,1318,2512,3114, 133,3115,2887,4687, 629, 31,2851, // 3440 -2706,3889,4688, 850, 949,4689,4090,2970,1732,2089,4335,1496,1853,5433,4091, 620, // 3456 -3245, 981,1242,3745,3397,1619,3746,1643,3326,2140,2457,1971,1719,3510,2169,5434, // 3472 -3246,5435,5436,3398,1829,5437,1277,4690,1565,2048,5438,1636,3623,3116,5439, 869, // 3488 -2852, 655,3890,3891,3117,4092,3018,3892,1310,3624,4691,5440,5441,5442,1733, 558, // 3504 -4692,3747, 335,1549,3065,1756,4336,3748,1946,3511,1830,1291,1192, 470,2735,2108, // 3520 -2806, 913,1054,4093,5443,1027,5444,3066,4094,4693, 982,2672,3399,3173,3512,3247, // 3536 -3248,1947,2807,5445, 571,4694,5446,1831,5447,3625,2591,1523,2429,5448,2090, 984, // 3552 -4695,3749,1960,5449,3750, 852, 923,2808,3513,3751, 969,1519, 999,2049,2325,1705, // 3568 -5450,3118, 615,1662, 151, 597,4095,2410,2326,1049, 275,4696,3752,4337, 568,3753, // 3584 -3626,2487,4338,3754,5451,2430,2275, 409,3249,5452,1566,2888,3514,1002, 769,2853, // 3600 - 194,2091,3174,3755,2226,3327,4339, 628,1505,5453,5454,1763,2180,3019,4096, 521, // 3616 -1161,2592,1788,2206,2411,4697,4097,1625,4340,4341, 412, 42,3119, 464,5455,2642, // 3632 -4698,3400,1760,1571,2889,3515,2537,1219,2207,3893,2643,2141,2373,4699,4700,3328, // 3648 -1651,3401,3627,5456,5457,3628,2488,3516,5458,3756,5459,5460,2276,2092, 460,5461, // 3664 -4701,5462,3020, 962, 588,3629, 289,3250,2644,1116, 52,5463,3067,1797,5464,5465, // 3680 -5466,1467,5467,1598,1143,3757,4342,1985,1734,1067,4702,1280,3402, 465,4703,1572, // 3696 - 510,5468,1928,2245,1813,1644,3630,5469,4704,3758,5470,5471,2673,1573,1534,5472, // 3712 -5473, 536,1808,1761,3517,3894,3175,2645,5474,5475,5476,4705,3518,2929,1912,2809, // 3728 -5477,3329,1122, 377,3251,5478, 360,5479,5480,4343,1529, 551,5481,2060,3759,1769, // 3744 -2431,5482,2930,4344,3330,3120,2327,2109,2031,4706,1404, 136,1468,1479, 672,1171, // 3760 -3252,2308, 271,3176,5483,2772,5484,2050, 678,2736, 865,1948,4707,5485,2014,4098, // 3776 -2971,5486,2737,2227,1397,3068,3760,4708,4709,1735,2931,3403,3631,5487,3895, 509, // 3792 -2854,2458,2890,3896,5488,5489,3177,3178,4710,4345,2538,4711,2309,1166,1010, 552, // 3808 - 681,1888,5490,5491,2972,2973,4099,1287,1596,1862,3179, 358, 453, 736, 175, 478, // 3824 -1117, 905,1167,1097,5492,1854,1530,5493,1706,5494,2181,3519,2292,3761,3520,3632, // 3840 -4346,2093,4347,5495,3404,1193,2489,4348,1458,2193,2208,1863,1889,1421,3331,2932, // 3856 -3069,2182,3521, 595,2123,5496,4100,5497,5498,4349,1707,2646, 223,3762,1359, 751, // 3872 -3121, 183,3522,5499,2810,3021, 419,2374, 633, 704,3897,2394, 241,5500,5501,5502, // 3888 - 838,3022,3763,2277,2773,2459,3898,1939,2051,4101,1309,3122,2246,1181,5503,1136, // 3904 -2209,3899,2375,1446,4350,2310,4712,5504,5505,4351,1055,2615, 484,3764,5506,4102, // 3920 - 625,4352,2278,3405,1499,4353,4103,5507,4104,4354,3253,2279,2280,3523,5508,5509, // 3936 -2774, 808,2616,3765,3406,4105,4355,3123,2539, 526,3407,3900,4356, 955,5510,1620, // 3952 -4357,2647,2432,5511,1429,3766,1669,1832, 994, 928,5512,3633,1260,5513,5514,5515, // 3968 -1949,2293, 741,2933,1626,4358,2738,2460, 867,1184, 362,3408,1392,5516,5517,4106, // 3984 -4359,1770,1736,3254,2934,4713,4714,1929,2707,1459,1158,5518,3070,3409,2891,1292, // 4000 -1930,2513,2855,3767,1986,1187,2072,2015,2617,4360,5519,2574,2514,2170,3768,2490, // 4016 -3332,5520,3769,4715,5521,5522, 666,1003,3023,1022,3634,4361,5523,4716,1814,2257, // 4032 - 574,3901,1603, 295,1535, 705,3902,4362, 283, 858, 417,5524,5525,3255,4717,4718, // 4048 -3071,1220,1890,1046,2281,2461,4107,1393,1599, 689,2575, 388,4363,5526,2491, 802, // 4064 -5527,2811,3903,2061,1405,2258,5528,4719,3904,2110,1052,1345,3256,1585,5529, 809, // 4080 -5530,5531,5532, 575,2739,3524, 956,1552,1469,1144,2328,5533,2329,1560,2462,3635, // 4096 -3257,4108, 616,2210,4364,3180,2183,2294,5534,1833,5535,3525,4720,5536,1319,3770, // 4112 -3771,1211,3636,1023,3258,1293,2812,5537,5538,5539,3905, 607,2311,3906, 762,2892, // 4128 -1439,4365,1360,4721,1485,3072,5540,4722,1038,4366,1450,2062,2648,4367,1379,4723, // 4144 -2593,5541,5542,4368,1352,1414,2330,2935,1172,5543,5544,3907,3908,4724,1798,1451, // 4160 -5545,5546,5547,5548,2936,4109,4110,2492,2351, 411,4111,4112,3637,3333,3124,4725, // 4176 -1561,2674,1452,4113,1375,5549,5550, 47,2974, 316,5551,1406,1591,2937,3181,5552, // 4192 -1025,2142,3125,3182, 354,2740, 884,2228,4369,2412, 508,3772, 726,3638, 996,2433, // 4208 -3639, 729,5553, 392,2194,1453,4114,4726,3773,5554,5555,2463,3640,2618,1675,2813, // 4224 - 919,2352,2975,2353,1270,4727,4115, 73,5556,5557, 647,5558,3259,2856,2259,1550, // 4240 -1346,3024,5559,1332, 883,3526,5560,5561,5562,5563,3334,2775,5564,1212, 831,1347, // 4256 -4370,4728,2331,3909,1864,3073, 720,3910,4729,4730,3911,5565,4371,5566,5567,4731, // 4272 -5568,5569,1799,4732,3774,2619,4733,3641,1645,2376,4734,5570,2938, 669,2211,2675, // 4288 -2434,5571,2893,5572,5573,1028,3260,5574,4372,2413,5575,2260,1353,5576,5577,4735, // 4304 -3183, 518,5578,4116,5579,4373,1961,5580,2143,4374,5581,5582,3025,2354,2355,3912, // 4320 - 516,1834,1454,4117,2708,4375,4736,2229,2620,1972,1129,3642,5583,2776,5584,2976, // 4336 -1422, 577,1470,3026,1524,3410,5585,5586, 432,4376,3074,3527,5587,2594,1455,2515, // 4352 -2230,1973,1175,5588,1020,2741,4118,3528,4737,5589,2742,5590,1743,1361,3075,3529, // 4368 -2649,4119,4377,4738,2295, 895, 924,4378,2171, 331,2247,3076, 166,1627,3077,1098, // 4384 -5591,1232,2894,2231,3411,4739, 657, 403,1196,2377, 542,3775,3412,1600,4379,3530, // 4400 -5592,4740,2777,3261, 576, 530,1362,4741,4742,2540,2676,3776,4120,5593, 842,3913, // 4416 -5594,2814,2032,1014,4121, 213,2709,3413, 665, 621,4380,5595,3777,2939,2435,5596, // 4432 -2436,3335,3643,3414,4743,4381,2541,4382,4744,3644,1682,4383,3531,1380,5597, 724, // 4448 -2282, 600,1670,5598,1337,1233,4745,3126,2248,5599,1621,4746,5600, 651,4384,5601, // 4464 -1612,4385,2621,5602,2857,5603,2743,2312,3078,5604, 716,2464,3079, 174,1255,2710, // 4480 -4122,3645, 548,1320,1398, 728,4123,1574,5605,1891,1197,3080,4124,5606,3081,3082, // 4496 -3778,3646,3779, 747,5607, 635,4386,4747,5608,5609,5610,4387,5611,5612,4748,5613, // 4512 -3415,4749,2437, 451,5614,3780,2542,2073,4388,2744,4389,4125,5615,1764,4750,5616, // 4528 -4390, 350,4751,2283,2395,2493,5617,4391,4126,2249,1434,4127, 488,4752, 458,4392, // 4544 -4128,3781, 771,1330,2396,3914,2576,3184,2160,2414,1553,2677,3185,4393,5618,2494, // 4560 -2895,2622,1720,2711,4394,3416,4753,5619,2543,4395,5620,3262,4396,2778,5621,2016, // 4576 -2745,5622,1155,1017,3782,3915,5623,3336,2313, 201,1865,4397,1430,5624,4129,5625, // 4592 -5626,5627,5628,5629,4398,1604,5630, 414,1866, 371,2595,4754,4755,3532,2017,3127, // 4608 -4756,1708, 960,4399, 887, 389,2172,1536,1663,1721,5631,2232,4130,2356,2940,1580, // 4624 -5632,5633,1744,4757,2544,4758,4759,5634,4760,5635,2074,5636,4761,3647,3417,2896, // 4640 -4400,5637,4401,2650,3418,2815, 673,2712,2465, 709,3533,4131,3648,4402,5638,1148, // 4656 - 502, 634,5639,5640,1204,4762,3649,1575,4763,2623,3783,5641,3784,3128, 948,3263, // 4672 - 121,1745,3916,1110,5642,4403,3083,2516,3027,4132,3785,1151,1771,3917,1488,4133, // 4688 -1987,5643,2438,3534,5644,5645,2094,5646,4404,3918,1213,1407,2816, 531,2746,2545, // 4704 -3264,1011,1537,4764,2779,4405,3129,1061,5647,3786,3787,1867,2897,5648,2018, 120, // 4720 -4406,4407,2063,3650,3265,2314,3919,2678,3419,1955,4765,4134,5649,3535,1047,2713, // 4736 -1266,5650,1368,4766,2858, 649,3420,3920,2546,2747,1102,2859,2679,5651,5652,2000, // 4752 -5653,1111,3651,2977,5654,2495,3921,3652,2817,1855,3421,3788,5655,5656,3422,2415, // 4768 -2898,3337,3266,3653,5657,2577,5658,3654,2818,4135,1460, 856,5659,3655,5660,2899, // 4784 -2978,5661,2900,3922,5662,4408, 632,2517, 875,3923,1697,3924,2296,5663,5664,4767, // 4800 -3028,1239, 580,4768,4409,5665, 914, 936,2075,1190,4136,1039,2124,5666,5667,5668, // 4816 -5669,3423,1473,5670,1354,4410,3925,4769,2173,3084,4137, 915,3338,4411,4412,3339, // 4832 -1605,1835,5671,2748, 398,3656,4413,3926,4138, 328,1913,2860,4139,3927,1331,4414, // 4848 -3029, 937,4415,5672,3657,4140,4141,3424,2161,4770,3425, 524, 742, 538,3085,1012, // 4864 -5673,5674,3928,2466,5675, 658,1103, 225,3929,5676,5677,4771,5678,4772,5679,3267, // 4880 -1243,5680,4142, 963,2250,4773,5681,2714,3658,3186,5682,5683,2596,2332,5684,4774, // 4896 -5685,5686,5687,3536, 957,3426,2547,2033,1931,2941,2467, 870,2019,3659,1746,2780, // 4912 -2781,2439,2468,5688,3930,5689,3789,3130,3790,3537,3427,3791,5690,1179,3086,5691, // 4928 -3187,2378,4416,3792,2548,3188,3131,2749,4143,5692,3428,1556,2549,2297, 977,2901, // 4944 -2034,4144,1205,3429,5693,1765,3430,3189,2125,1271, 714,1689,4775,3538,5694,2333, // 4960 -3931, 533,4417,3660,2184, 617,5695,2469,3340,3539,2315,5696,5697,3190,5698,5699, // 4976 -3932,1988, 618, 427,2651,3540,3431,5700,5701,1244,1690,5702,2819,4418,4776,5703, // 4992 -3541,4777,5704,2284,1576, 473,3661,4419,3432, 972,5705,3662,5706,3087,5707,5708, // 5008 -4778,4779,5709,3793,4145,4146,5710, 153,4780, 356,5711,1892,2902,4420,2144, 408, // 5024 - 803,2357,5712,3933,5713,4421,1646,2578,2518,4781,4782,3934,5714,3935,4422,5715, // 5040 -2416,3433, 752,5716,5717,1962,3341,2979,5718, 746,3030,2470,4783,4423,3794, 698, // 5056 -4784,1893,4424,3663,2550,4785,3664,3936,5719,3191,3434,5720,1824,1302,4147,2715, // 5072 -3937,1974,4425,5721,4426,3192, 823,1303,1288,1236,2861,3542,4148,3435, 774,3938, // 5088 -5722,1581,4786,1304,2862,3939,4787,5723,2440,2162,1083,3268,4427,4149,4428, 344, // 5104 -1173, 288,2316, 454,1683,5724,5725,1461,4788,4150,2597,5726,5727,4789, 985, 894, // 5120 -5728,3436,3193,5729,1914,2942,3795,1989,5730,2111,1975,5731,4151,5732,2579,1194, // 5136 - 425,5733,4790,3194,1245,3796,4429,5734,5735,2863,5736, 636,4791,1856,3940, 760, // 5152 -1800,5737,4430,2212,1508,4792,4152,1894,1684,2298,5738,5739,4793,4431,4432,2213, // 5168 - 479,5740,5741, 832,5742,4153,2496,5743,2980,2497,3797, 990,3132, 627,1815,2652, // 5184 -4433,1582,4434,2126,2112,3543,4794,5744, 799,4435,3195,5745,4795,2113,1737,3031, // 5200 -1018, 543, 754,4436,3342,1676,4796,4797,4154,4798,1489,5746,3544,5747,2624,2903, // 5216 -4155,5748,5749,2981,5750,5751,5752,5753,3196,4799,4800,2185,1722,5754,3269,3270, // 5232 -1843,3665,1715, 481, 365,1976,1857,5755,5756,1963,2498,4801,5757,2127,3666,3271, // 5248 - 433,1895,2064,2076,5758, 602,2750,5759,5760,5761,5762,5763,3032,1628,3437,5764, // 5264 -3197,4802,4156,2904,4803,2519,5765,2551,2782,5766,5767,5768,3343,4804,2905,5769, // 5280 -4805,5770,2864,4806,4807,1221,2982,4157,2520,5771,5772,5773,1868,1990,5774,5775, // 5296 -5776,1896,5777,5778,4808,1897,4158, 318,5779,2095,4159,4437,5780,5781, 485,5782, // 5312 - 938,3941, 553,2680, 116,5783,3942,3667,5784,3545,2681,2783,3438,3344,2820,5785, // 5328 -3668,2943,4160,1747,2944,2983,5786,5787, 207,5788,4809,5789,4810,2521,5790,3033, // 5344 - 890,3669,3943,5791,1878,3798,3439,5792,2186,2358,3440,1652,5793,5794,5795, 941, // 5360 -2299, 208,3546,4161,2020, 330,4438,3944,2906,2499,3799,4439,4811,5796,5797,5798, // 5376 //last 512 - -/*************************************************************************************** - *Everything below is of no interest for detection purpose * - *************************************************************************************** - -2522,1613,4812,5799,3345,3945,2523,5800,4162,5801,1637,4163,2471,4813,3946,5802, // 5392 -2500,3034,3800,5803,5804,2195,4814,5805,2163,5806,5807,5808,5809,5810,5811,5812, // 5408 -5813,5814,5815,5816,5817,5818,5819,5820,5821,5822,5823,5824,5825,5826,5827,5828, // 5424 -5829,5830,5831,5832,5833,5834,5835,5836,5837,5838,5839,5840,5841,5842,5843,5844, // 5440 -5845,5846,5847,5848,5849,5850,5851,5852,5853,5854,5855,5856,5857,5858,5859,5860, // 5456 -5861,5862,5863,5864,5865,5866,5867,5868,5869,5870,5871,5872,5873,5874,5875,5876, // 5472 -5877,5878,5879,5880,5881,5882,5883,5884,5885,5886,5887,5888,5889,5890,5891,5892, // 5488 -5893,5894,5895,5896,5897,5898,5899,5900,5901,5902,5903,5904,5905,5906,5907,5908, // 5504 -5909,5910,5911,5912,5913,5914,5915,5916,5917,5918,5919,5920,5921,5922,5923,5924, // 5520 -5925,5926,5927,5928,5929,5930,5931,5932,5933,5934,5935,5936,5937,5938,5939,5940, // 5536 -5941,5942,5943,5944,5945,5946,5947,5948,5949,5950,5951,5952,5953,5954,5955,5956, // 5552 -5957,5958,5959,5960,5961,5962,5963,5964,5965,5966,5967,5968,5969,5970,5971,5972, // 5568 -5973,5974,5975,5976,5977,5978,5979,5980,5981,5982,5983,5984,5985,5986,5987,5988, // 5584 -5989,5990,5991,5992,5993,5994,5995,5996,5997,5998,5999,6000,6001,6002,6003,6004, // 5600 -6005,6006,6007,6008,6009,6010,6011,6012,6013,6014,6015,6016,6017,6018,6019,6020, // 5616 -6021,6022,6023,6024,6025,6026,6027,6028,6029,6030,6031,6032,6033,6034,6035,6036, // 5632 -6037,6038,6039,6040,6041,6042,6043,6044,6045,6046,6047,6048,6049,6050,6051,6052, // 5648 -6053,6054,6055,6056,6057,6058,6059,6060,6061,6062,6063,6064,6065,6066,6067,6068, // 5664 -6069,6070,6071,6072,6073,6074,6075,6076,6077,6078,6079,6080,6081,6082,6083,6084, // 5680 -6085,6086,6087,6088,6089,6090,6091,6092,6093,6094,6095,6096,6097,6098,6099,6100, // 5696 -6101,6102,6103,6104,6105,6106,6107,6108,6109,6110,6111,6112,6113,6114,6115,6116, // 5712 -6117,6118,6119,6120,6121,6122,6123,6124,6125,6126,6127,6128,6129,6130,6131,6132, // 5728 -6133,6134,6135,6136,6137,6138,6139,6140,6141,6142,6143,6144,6145,6146,6147,6148, // 5744 -6149,6150,6151,6152,6153,6154,6155,6156,6157,6158,6159,6160,6161,6162,6163,6164, // 5760 -6165,6166,6167,6168,6169,6170,6171,6172,6173,6174,6175,6176,6177,6178,6179,6180, // 5776 -6181,6182,6183,6184,6185,6186,6187,6188,6189,6190,6191,6192,6193,6194,6195,6196, // 5792 -6197,6198,6199,6200,6201,6202,6203,6204,6205,6206,6207,6208,6209,6210,6211,6212, // 5808 -6213,6214,6215,6216,6217,6218,6219,6220,6221,6222,6223,3670,6224,6225,6226,6227, // 5824 -6228,6229,6230,6231,6232,6233,6234,6235,6236,6237,6238,6239,6240,6241,6242,6243, // 5840 -6244,6245,6246,6247,6248,6249,6250,6251,6252,6253,6254,6255,6256,6257,6258,6259, // 5856 -6260,6261,6262,6263,6264,6265,6266,6267,6268,6269,6270,6271,6272,6273,6274,6275, // 5872 -6276,6277,6278,6279,6280,6281,6282,6283,6284,6285,4815,6286,6287,6288,6289,6290, // 5888 -6291,6292,4816,6293,6294,6295,6296,6297,6298,6299,6300,6301,6302,6303,6304,6305, // 5904 -6306,6307,6308,6309,6310,6311,4817,4818,6312,6313,6314,6315,6316,6317,6318,4819, // 5920 -6319,6320,6321,6322,6323,6324,6325,6326,6327,6328,6329,6330,6331,6332,6333,6334, // 5936 -6335,6336,6337,4820,6338,6339,6340,6341,6342,6343,6344,6345,6346,6347,6348,6349, // 5952 -6350,6351,6352,6353,6354,6355,6356,6357,6358,6359,6360,6361,6362,6363,6364,6365, // 5968 -6366,6367,6368,6369,6370,6371,6372,6373,6374,6375,6376,6377,6378,6379,6380,6381, // 5984 -6382,6383,6384,6385,6386,6387,6388,6389,6390,6391,6392,6393,6394,6395,6396,6397, // 6000 -6398,6399,6400,6401,6402,6403,6404,6405,6406,6407,6408,6409,6410,3441,6411,6412, // 6016 -6413,6414,6415,6416,6417,6418,6419,6420,6421,6422,6423,6424,6425,4440,6426,6427, // 6032 -6428,6429,6430,6431,6432,6433,6434,6435,6436,6437,6438,6439,6440,6441,6442,6443, // 6048 -6444,6445,6446,6447,6448,6449,6450,6451,6452,6453,6454,4821,6455,6456,6457,6458, // 6064 -6459,6460,6461,6462,6463,6464,6465,6466,6467,6468,6469,6470,6471,6472,6473,6474, // 6080 -6475,6476,6477,3947,3948,6478,6479,6480,6481,3272,4441,6482,6483,6484,6485,4442, // 6096 -6486,6487,6488,6489,6490,6491,6492,6493,6494,6495,6496,4822,6497,6498,6499,6500, // 6112 -6501,6502,6503,6504,6505,6506,6507,6508,6509,6510,6511,6512,6513,6514,6515,6516, // 6128 -6517,6518,6519,6520,6521,6522,6523,6524,6525,6526,6527,6528,6529,6530,6531,6532, // 6144 -6533,6534,6535,6536,6537,6538,6539,6540,6541,6542,6543,6544,6545,6546,6547,6548, // 6160 -6549,6550,6551,6552,6553,6554,6555,6556,2784,6557,4823,6558,6559,6560,6561,6562, // 6176 -6563,6564,6565,6566,6567,6568,6569,3949,6570,6571,6572,4824,6573,6574,6575,6576, // 6192 -6577,6578,6579,6580,6581,6582,6583,4825,6584,6585,6586,3950,2785,6587,6588,6589, // 6208 -6590,6591,6592,6593,6594,6595,6596,6597,6598,6599,6600,6601,6602,6603,6604,6605, // 6224 -6606,6607,6608,6609,6610,6611,6612,4826,6613,6614,6615,4827,6616,6617,6618,6619, // 6240 -6620,6621,6622,6623,6624,6625,4164,6626,6627,6628,6629,6630,6631,6632,6633,6634, // 6256 -3547,6635,4828,6636,6637,6638,6639,6640,6641,6642,3951,2984,6643,6644,6645,6646, // 6272 -6647,6648,6649,4165,6650,4829,6651,6652,4830,6653,6654,6655,6656,6657,6658,6659, // 6288 -6660,6661,6662,4831,6663,6664,6665,6666,6667,6668,6669,6670,6671,4166,6672,4832, // 6304 -3952,6673,6674,6675,6676,4833,6677,6678,6679,4167,6680,6681,6682,3198,6683,6684, // 6320 -6685,6686,6687,6688,6689,6690,6691,6692,6693,6694,6695,6696,6697,4834,6698,6699, // 6336 -6700,6701,6702,6703,6704,6705,6706,6707,6708,6709,6710,6711,6712,6713,6714,6715, // 6352 -6716,6717,6718,6719,6720,6721,6722,6723,6724,6725,6726,6727,6728,6729,6730,6731, // 6368 -6732,6733,6734,4443,6735,6736,6737,6738,6739,6740,6741,6742,6743,6744,6745,4444, // 6384 -6746,6747,6748,6749,6750,6751,6752,6753,6754,6755,6756,6757,6758,6759,6760,6761, // 6400 -6762,6763,6764,6765,6766,6767,6768,6769,6770,6771,6772,6773,6774,6775,6776,6777, // 6416 -6778,6779,6780,6781,4168,6782,6783,3442,6784,6785,6786,6787,6788,6789,6790,6791, // 6432 -4169,6792,6793,6794,6795,6796,6797,6798,6799,6800,6801,6802,6803,6804,6805,6806, // 6448 -6807,6808,6809,6810,6811,4835,6812,6813,6814,4445,6815,6816,4446,6817,6818,6819, // 6464 -6820,6821,6822,6823,6824,6825,6826,6827,6828,6829,6830,6831,6832,6833,6834,6835, // 6480 -3548,6836,6837,6838,6839,6840,6841,6842,6843,6844,6845,6846,4836,6847,6848,6849, // 6496 -6850,6851,6852,6853,6854,3953,6855,6856,6857,6858,6859,6860,6861,6862,6863,6864, // 6512 -6865,6866,6867,6868,6869,6870,6871,6872,6873,6874,6875,6876,6877,3199,6878,6879, // 6528 -6880,6881,6882,4447,6883,6884,6885,6886,6887,6888,6889,6890,6891,6892,6893,6894, // 6544 -6895,6896,6897,6898,6899,6900,6901,6902,6903,6904,4170,6905,6906,6907,6908,6909, // 6560 -6910,6911,6912,6913,6914,6915,6916,6917,6918,6919,6920,6921,6922,6923,6924,6925, // 6576 -6926,6927,4837,6928,6929,6930,6931,6932,6933,6934,6935,6936,3346,6937,6938,4838, // 6592 -6939,6940,6941,4448,6942,6943,6944,6945,6946,4449,6947,6948,6949,6950,6951,6952, // 6608 -6953,6954,6955,6956,6957,6958,6959,6960,6961,6962,6963,6964,6965,6966,6967,6968, // 6624 -6969,6970,6971,6972,6973,6974,6975,6976,6977,6978,6979,6980,6981,6982,6983,6984, // 6640 -6985,6986,6987,6988,6989,6990,6991,6992,6993,6994,3671,6995,6996,6997,6998,4839, // 6656 -6999,7000,7001,7002,3549,7003,7004,7005,7006,7007,7008,7009,7010,7011,7012,7013, // 6672 -7014,7015,7016,7017,7018,7019,7020,7021,7022,7023,7024,7025,7026,7027,7028,7029, // 6688 -7030,4840,7031,7032,7033,7034,7035,7036,7037,7038,4841,7039,7040,7041,7042,7043, // 6704 -7044,7045,7046,7047,7048,7049,7050,7051,7052,7053,7054,7055,7056,7057,7058,7059, // 6720 -7060,7061,7062,7063,7064,7065,7066,7067,7068,7069,7070,2985,7071,7072,7073,7074, // 6736 -7075,7076,7077,7078,7079,7080,4842,7081,7082,7083,7084,7085,7086,7087,7088,7089, // 6752 -7090,7091,7092,7093,7094,7095,7096,7097,7098,7099,7100,7101,7102,7103,7104,7105, // 6768 -7106,7107,7108,7109,7110,7111,7112,7113,7114,7115,7116,7117,7118,4450,7119,7120, // 6784 -7121,7122,7123,7124,7125,7126,7127,7128,7129,7130,7131,7132,7133,7134,7135,7136, // 6800 -7137,7138,7139,7140,7141,7142,7143,4843,7144,7145,7146,7147,7148,7149,7150,7151, // 6816 -7152,7153,7154,7155,7156,7157,7158,7159,7160,7161,7162,7163,7164,7165,7166,7167, // 6832 -7168,7169,7170,7171,7172,7173,7174,7175,7176,7177,7178,7179,7180,7181,7182,7183, // 6848 -7184,7185,7186,7187,7188,4171,4172,7189,7190,7191,7192,7193,7194,7195,7196,7197, // 6864 -7198,7199,7200,7201,7202,7203,7204,7205,7206,7207,7208,7209,7210,7211,7212,7213, // 6880 -7214,7215,7216,7217,7218,7219,7220,7221,7222,7223,7224,7225,7226,7227,7228,7229, // 6896 -7230,7231,7232,7233,7234,7235,7236,7237,7238,7239,7240,7241,7242,7243,7244,7245, // 6912 -7246,7247,7248,7249,7250,7251,7252,7253,7254,7255,7256,7257,7258,7259,7260,7261, // 6928 -7262,7263,7264,7265,7266,7267,7268,7269,7270,7271,7272,7273,7274,7275,7276,7277, // 6944 -7278,7279,7280,7281,7282,7283,7284,7285,7286,7287,7288,7289,7290,7291,7292,7293, // 6960 -7294,7295,7296,4844,7297,7298,7299,7300,7301,7302,7303,7304,7305,7306,7307,7308, // 6976 -7309,7310,7311,7312,7313,7314,7315,7316,4451,7317,7318,7319,7320,7321,7322,7323, // 6992 -7324,7325,7326,7327,7328,7329,7330,7331,7332,7333,7334,7335,7336,7337,7338,7339, // 7008 -7340,7341,7342,7343,7344,7345,7346,7347,7348,7349,7350,7351,7352,7353,4173,7354, // 7024 -7355,4845,7356,7357,7358,7359,7360,7361,7362,7363,7364,7365,7366,7367,7368,7369, // 7040 -7370,7371,7372,7373,7374,7375,7376,7377,7378,7379,7380,7381,7382,7383,7384,7385, // 7056 -7386,7387,7388,4846,7389,7390,7391,7392,7393,7394,7395,7396,7397,7398,7399,7400, // 7072 -7401,7402,7403,7404,7405,3672,7406,7407,7408,7409,7410,7411,7412,7413,7414,7415, // 7088 -7416,7417,7418,7419,7420,7421,7422,7423,7424,7425,7426,7427,7428,7429,7430,7431, // 7104 -7432,7433,7434,7435,7436,7437,7438,7439,7440,7441,7442,7443,7444,7445,7446,7447, // 7120 -7448,7449,7450,7451,7452,7453,4452,7454,3200,7455,7456,7457,7458,7459,7460,7461, // 7136 -7462,7463,7464,7465,7466,7467,7468,7469,7470,7471,7472,7473,7474,4847,7475,7476, // 7152 -7477,3133,7478,7479,7480,7481,7482,7483,7484,7485,7486,7487,7488,7489,7490,7491, // 7168 -7492,7493,7494,7495,7496,7497,7498,7499,7500,7501,7502,3347,7503,7504,7505,7506, // 7184 -7507,7508,7509,7510,7511,7512,7513,7514,7515,7516,7517,7518,7519,7520,7521,4848, // 7200 -7522,7523,7524,7525,7526,7527,7528,7529,7530,7531,7532,7533,7534,7535,7536,7537, // 7216 -7538,7539,7540,7541,7542,7543,7544,7545,7546,7547,7548,7549,3801,4849,7550,7551, // 7232 -7552,7553,7554,7555,7556,7557,7558,7559,7560,7561,7562,7563,7564,7565,7566,7567, // 7248 -7568,7569,3035,7570,7571,7572,7573,7574,7575,7576,7577,7578,7579,7580,7581,7582, // 7264 -7583,7584,7585,7586,7587,7588,7589,7590,7591,7592,7593,7594,7595,7596,7597,7598, // 7280 -7599,7600,7601,7602,7603,7604,7605,7606,7607,7608,7609,7610,7611,7612,7613,7614, // 7296 -7615,7616,4850,7617,7618,3802,7619,7620,7621,7622,7623,7624,7625,7626,7627,7628, // 7312 -7629,7630,7631,7632,4851,7633,7634,7635,7636,7637,7638,7639,7640,7641,7642,7643, // 7328 -7644,7645,7646,7647,7648,7649,7650,7651,7652,7653,7654,7655,7656,7657,7658,7659, // 7344 -7660,7661,7662,7663,7664,7665,7666,7667,7668,7669,7670,4453,7671,7672,7673,7674, // 7360 -7675,7676,7677,7678,7679,7680,7681,7682,7683,7684,7685,7686,7687,7688,7689,7690, // 7376 -7691,7692,7693,7694,7695,7696,7697,3443,7698,7699,7700,7701,7702,4454,7703,7704, // 7392 -7705,7706,7707,7708,7709,7710,7711,7712,7713,2472,7714,7715,7716,7717,7718,7719, // 7408 -7720,7721,7722,7723,7724,7725,7726,7727,7728,7729,7730,7731,3954,7732,7733,7734, // 7424 -7735,7736,7737,7738,7739,7740,7741,7742,7743,7744,7745,7746,7747,7748,7749,7750, // 7440 -3134,7751,7752,4852,7753,7754,7755,4853,7756,7757,7758,7759,7760,4174,7761,7762, // 7456 -7763,7764,7765,7766,7767,7768,7769,7770,7771,7772,7773,7774,7775,7776,7777,7778, // 7472 -7779,7780,7781,7782,7783,7784,7785,7786,7787,7788,7789,7790,7791,7792,7793,7794, // 7488 -7795,7796,7797,7798,7799,7800,7801,7802,7803,7804,7805,4854,7806,7807,7808,7809, // 7504 -7810,7811,7812,7813,7814,7815,7816,7817,7818,7819,7820,7821,7822,7823,7824,7825, // 7520 -4855,7826,7827,7828,7829,7830,7831,7832,7833,7834,7835,7836,7837,7838,7839,7840, // 7536 -7841,7842,7843,7844,7845,7846,7847,3955,7848,7849,7850,7851,7852,7853,7854,7855, // 7552 -7856,7857,7858,7859,7860,3444,7861,7862,7863,7864,7865,7866,7867,7868,7869,7870, // 7568 -7871,7872,7873,7874,7875,7876,7877,7878,7879,7880,7881,7882,7883,7884,7885,7886, // 7584 -7887,7888,7889,7890,7891,4175,7892,7893,7894,7895,7896,4856,4857,7897,7898,7899, // 7600 -7900,2598,7901,7902,7903,7904,7905,7906,7907,7908,4455,7909,7910,7911,7912,7913, // 7616 -7914,3201,7915,7916,7917,7918,7919,7920,7921,4858,7922,7923,7924,7925,7926,7927, // 7632 -7928,7929,7930,7931,7932,7933,7934,7935,7936,7937,7938,7939,7940,7941,7942,7943, // 7648 -7944,7945,7946,7947,7948,7949,7950,7951,7952,7953,7954,7955,7956,7957,7958,7959, // 7664 -7960,7961,7962,7963,7964,7965,7966,7967,7968,7969,7970,7971,7972,7973,7974,7975, // 7680 -7976,7977,7978,7979,7980,7981,4859,7982,7983,7984,7985,7986,7987,7988,7989,7990, // 7696 -7991,7992,7993,7994,7995,7996,4860,7997,7998,7999,8000,8001,8002,8003,8004,8005, // 7712 -8006,8007,8008,8009,8010,8011,8012,8013,8014,8015,8016,4176,8017,8018,8019,8020, // 7728 -8021,8022,8023,4861,8024,8025,8026,8027,8028,8029,8030,8031,8032,8033,8034,8035, // 7744 -8036,4862,4456,8037,8038,8039,8040,4863,8041,8042,8043,8044,8045,8046,8047,8048, // 7760 -8049,8050,8051,8052,8053,8054,8055,8056,8057,8058,8059,8060,8061,8062,8063,8064, // 7776 -8065,8066,8067,8068,8069,8070,8071,8072,8073,8074,8075,8076,8077,8078,8079,8080, // 7792 -8081,8082,8083,8084,8085,8086,8087,8088,8089,8090,8091,8092,8093,8094,8095,8096, // 7808 -8097,8098,8099,4864,4177,8100,8101,8102,8103,8104,8105,8106,8107,8108,8109,8110, // 7824 -8111,8112,8113,8114,8115,8116,8117,8118,8119,8120,4178,8121,8122,8123,8124,8125, // 7840 -8126,8127,8128,8129,8130,8131,8132,8133,8134,8135,8136,8137,8138,8139,8140,8141, // 7856 -8142,8143,8144,8145,4865,4866,8146,8147,8148,8149,8150,8151,8152,8153,8154,8155, // 7872 -8156,8157,8158,8159,8160,8161,8162,8163,8164,8165,4179,8166,8167,8168,8169,8170, // 7888 -8171,8172,8173,8174,8175,8176,8177,8178,8179,8180,8181,4457,8182,8183,8184,8185, // 7904 -8186,8187,8188,8189,8190,8191,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201, // 7920 -8202,8203,8204,8205,8206,8207,8208,8209,8210,8211,8212,8213,8214,8215,8216,8217, // 7936 -8218,8219,8220,8221,8222,8223,8224,8225,8226,8227,8228,8229,8230,8231,8232,8233, // 7952 -8234,8235,8236,8237,8238,8239,8240,8241,8242,8243,8244,8245,8246,8247,8248,8249, // 7968 -8250,8251,8252,8253,8254,8255,8256,3445,8257,8258,8259,8260,8261,8262,4458,8263, // 7984 -8264,8265,8266,8267,8268,8269,8270,8271,8272,4459,8273,8274,8275,8276,3550,8277, // 8000 -8278,8279,8280,8281,8282,8283,8284,8285,8286,8287,8288,8289,4460,8290,8291,8292, // 8016 -8293,8294,8295,8296,8297,8298,8299,8300,8301,8302,8303,8304,8305,8306,8307,4867, // 8032 -8308,8309,8310,8311,8312,3551,8313,8314,8315,8316,8317,8318,8319,8320,8321,8322, // 8048 -8323,8324,8325,8326,4868,8327,8328,8329,8330,8331,8332,8333,8334,8335,8336,8337, // 8064 -8338,8339,8340,8341,8342,8343,8344,8345,8346,8347,8348,8349,8350,8351,8352,8353, // 8080 -8354,8355,8356,8357,8358,8359,8360,8361,8362,8363,4869,4461,8364,8365,8366,8367, // 8096 -8368,8369,8370,4870,8371,8372,8373,8374,8375,8376,8377,8378,8379,8380,8381,8382, // 8112 -8383,8384,8385,8386,8387,8388,8389,8390,8391,8392,8393,8394,8395,8396,8397,8398, // 8128 -8399,8400,8401,8402,8403,8404,8405,8406,8407,8408,8409,8410,4871,8411,8412,8413, // 8144 -8414,8415,8416,8417,8418,8419,8420,8421,8422,4462,8423,8424,8425,8426,8427,8428, // 8160 -8429,8430,8431,8432,8433,2986,8434,8435,8436,8437,8438,8439,8440,8441,8442,8443, // 8176 -8444,8445,8446,8447,8448,8449,8450,8451,8452,8453,8454,8455,8456,8457,8458,8459, // 8192 -8460,8461,8462,8463,8464,8465,8466,8467,8468,8469,8470,8471,8472,8473,8474,8475, // 8208 -8476,8477,8478,4180,8479,8480,8481,8482,8483,8484,8485,8486,8487,8488,8489,8490, // 8224 -8491,8492,8493,8494,8495,8496,8497,8498,8499,8500,8501,8502,8503,8504,8505,8506, // 8240 -8507,8508,8509,8510,8511,8512,8513,8514,8515,8516,8517,8518,8519,8520,8521,8522, // 8256 -8523,8524,8525,8526,8527,8528,8529,8530,8531,8532,8533,8534,8535,8536,8537,8538, // 8272 -8539,8540,8541,8542,8543,8544,8545,8546,8547,8548,8549,8550,8551,8552,8553,8554, // 8288 -8555,8556,8557,8558,8559,8560,8561,8562,8563,8564,4872,8565,8566,8567,8568,8569, // 8304 -8570,8571,8572,8573,4873,8574,8575,8576,8577,8578,8579,8580,8581,8582,8583,8584, // 8320 -8585,8586,8587,8588,8589,8590,8591,8592,8593,8594,8595,8596,8597,8598,8599,8600, // 8336 -8601,8602,8603,8604,8605,3803,8606,8607,8608,8609,8610,8611,8612,8613,4874,3804, // 8352 -8614,8615,8616,8617,8618,8619,8620,8621,3956,8622,8623,8624,8625,8626,8627,8628, // 8368 -8629,8630,8631,8632,8633,8634,8635,8636,8637,8638,2865,8639,8640,8641,8642,8643, // 8384 -8644,8645,8646,8647,8648,8649,8650,8651,8652,8653,8654,8655,8656,4463,8657,8658, // 8400 -8659,4875,4876,8660,8661,8662,8663,8664,8665,8666,8667,8668,8669,8670,8671,8672, // 8416 -8673,8674,8675,8676,8677,8678,8679,8680,8681,4464,8682,8683,8684,8685,8686,8687, // 8432 -8688,8689,8690,8691,8692,8693,8694,8695,8696,8697,8698,8699,8700,8701,8702,8703, // 8448 -8704,8705,8706,8707,8708,8709,2261,8710,8711,8712,8713,8714,8715,8716,8717,8718, // 8464 -8719,8720,8721,8722,8723,8724,8725,8726,8727,8728,8729,8730,8731,8732,8733,4181, // 8480 -8734,8735,8736,8737,8738,8739,8740,8741,8742,8743,8744,8745,8746,8747,8748,8749, // 8496 -8750,8751,8752,8753,8754,8755,8756,8757,8758,8759,8760,8761,8762,8763,4877,8764, // 8512 -8765,8766,8767,8768,8769,8770,8771,8772,8773,8774,8775,8776,8777,8778,8779,8780, // 8528 -8781,8782,8783,8784,8785,8786,8787,8788,4878,8789,4879,8790,8791,8792,4880,8793, // 8544 -8794,8795,8796,8797,8798,8799,8800,8801,4881,8802,8803,8804,8805,8806,8807,8808, // 8560 -8809,8810,8811,8812,8813,8814,8815,3957,8816,8817,8818,8819,8820,8821,8822,8823, // 8576 -8824,8825,8826,8827,8828,8829,8830,8831,8832,8833,8834,8835,8836,8837,8838,8839, // 8592 -8840,8841,8842,8843,8844,8845,8846,8847,4882,8848,8849,8850,8851,8852,8853,8854, // 8608 -8855,8856,8857,8858,8859,8860,8861,8862,8863,8864,8865,8866,8867,8868,8869,8870, // 8624 -8871,8872,8873,8874,8875,8876,8877,8878,8879,8880,8881,8882,8883,8884,3202,8885, // 8640 -8886,8887,8888,8889,8890,8891,8892,8893,8894,8895,8896,8897,8898,8899,8900,8901, // 8656 -8902,8903,8904,8905,8906,8907,8908,8909,8910,8911,8912,8913,8914,8915,8916,8917, // 8672 -8918,8919,8920,8921,8922,8923,8924,4465,8925,8926,8927,8928,8929,8930,8931,8932, // 8688 -4883,8933,8934,8935,8936,8937,8938,8939,8940,8941,8942,8943,2214,8944,8945,8946, // 8704 -8947,8948,8949,8950,8951,8952,8953,8954,8955,8956,8957,8958,8959,8960,8961,8962, // 8720 -8963,8964,8965,4884,8966,8967,8968,8969,8970,8971,8972,8973,8974,8975,8976,8977, // 8736 -8978,8979,8980,8981,8982,8983,8984,8985,8986,8987,8988,8989,8990,8991,8992,4885, // 8752 -8993,8994,8995,8996,8997,8998,8999,9000,9001,9002,9003,9004,9005,9006,9007,9008, // 8768 -9009,9010,9011,9012,9013,9014,9015,9016,9017,9018,9019,9020,9021,4182,9022,9023, // 8784 -9024,9025,9026,9027,9028,9029,9030,9031,9032,9033,9034,9035,9036,9037,9038,9039, // 8800 -9040,9041,9042,9043,9044,9045,9046,9047,9048,9049,9050,9051,9052,9053,9054,9055, // 8816 -9056,9057,9058,9059,9060,9061,9062,9063,4886,9064,9065,9066,9067,9068,9069,4887, // 8832 -9070,9071,9072,9073,9074,9075,9076,9077,9078,9079,9080,9081,9082,9083,9084,9085, // 8848 -9086,9087,9088,9089,9090,9091,9092,9093,9094,9095,9096,9097,9098,9099,9100,9101, // 8864 -9102,9103,9104,9105,9106,9107,9108,9109,9110,9111,9112,9113,9114,9115,9116,9117, // 8880 -9118,9119,9120,9121,9122,9123,9124,9125,9126,9127,9128,9129,9130,9131,9132,9133, // 8896 -9134,9135,9136,9137,9138,9139,9140,9141,3958,9142,9143,9144,9145,9146,9147,9148, // 8912 -9149,9150,9151,4888,9152,9153,9154,9155,9156,9157,9158,9159,9160,9161,9162,9163, // 8928 -9164,9165,9166,9167,9168,9169,9170,9171,9172,9173,9174,9175,4889,9176,9177,9178, // 8944 -9179,9180,9181,9182,9183,9184,9185,9186,9187,9188,9189,9190,9191,9192,9193,9194, // 8960 -9195,9196,9197,9198,9199,9200,9201,9202,9203,4890,9204,9205,9206,9207,9208,9209, // 8976 -9210,9211,9212,9213,9214,9215,9216,9217,9218,9219,9220,9221,9222,4466,9223,9224, // 8992 -9225,9226,9227,9228,9229,9230,9231,9232,9233,9234,9235,9236,9237,9238,9239,9240, // 9008 -9241,9242,9243,9244,9245,4891,9246,9247,9248,9249,9250,9251,9252,9253,9254,9255, // 9024 -9256,9257,4892,9258,9259,9260,9261,4893,4894,9262,9263,9264,9265,9266,9267,9268, // 9040 -9269,9270,9271,9272,9273,4467,9274,9275,9276,9277,9278,9279,9280,9281,9282,9283, // 9056 -9284,9285,3673,9286,9287,9288,9289,9290,9291,9292,9293,9294,9295,9296,9297,9298, // 9072 -9299,9300,9301,9302,9303,9304,9305,9306,9307,9308,9309,9310,9311,9312,9313,9314, // 9088 -9315,9316,9317,9318,9319,9320,9321,9322,4895,9323,9324,9325,9326,9327,9328,9329, // 9104 -9330,9331,9332,9333,9334,9335,9336,9337,9338,9339,9340,9341,9342,9343,9344,9345, // 9120 -9346,9347,4468,9348,9349,9350,9351,9352,9353,9354,9355,9356,9357,9358,9359,9360, // 9136 -9361,9362,9363,9364,9365,9366,9367,9368,9369,9370,9371,9372,9373,4896,9374,4469, // 9152 -9375,9376,9377,9378,9379,4897,9380,9381,9382,9383,9384,9385,9386,9387,9388,9389, // 9168 -9390,9391,9392,9393,9394,9395,9396,9397,9398,9399,9400,9401,9402,9403,9404,9405, // 9184 -9406,4470,9407,2751,9408,9409,3674,3552,9410,9411,9412,9413,9414,9415,9416,9417, // 9200 -9418,9419,9420,9421,4898,9422,9423,9424,9425,9426,9427,9428,9429,3959,9430,9431, // 9216 -9432,9433,9434,9435,9436,4471,9437,9438,9439,9440,9441,9442,9443,9444,9445,9446, // 9232 -9447,9448,9449,9450,3348,9451,9452,9453,9454,9455,9456,9457,9458,9459,9460,9461, // 9248 -9462,9463,9464,9465,9466,9467,9468,9469,9470,9471,9472,4899,9473,9474,9475,9476, // 9264 -9477,4900,9478,9479,9480,9481,9482,9483,9484,9485,9486,9487,9488,3349,9489,9490, // 9280 -9491,9492,9493,9494,9495,9496,9497,9498,9499,9500,9501,9502,9503,9504,9505,9506, // 9296 -9507,9508,9509,9510,9511,9512,9513,9514,9515,9516,9517,9518,9519,9520,4901,9521, // 9312 -9522,9523,9524,9525,9526,4902,9527,9528,9529,9530,9531,9532,9533,9534,9535,9536, // 9328 -9537,9538,9539,9540,9541,9542,9543,9544,9545,9546,9547,9548,9549,9550,9551,9552, // 9344 -9553,9554,9555,9556,9557,9558,9559,9560,9561,9562,9563,9564,9565,9566,9567,9568, // 9360 -9569,9570,9571,9572,9573,9574,9575,9576,9577,9578,9579,9580,9581,9582,9583,9584, // 9376 -3805,9585,9586,9587,9588,9589,9590,9591,9592,9593,9594,9595,9596,9597,9598,9599, // 9392 -9600,9601,9602,4903,9603,9604,9605,9606,9607,4904,9608,9609,9610,9611,9612,9613, // 9408 -9614,4905,9615,9616,9617,9618,9619,9620,9621,9622,9623,9624,9625,9626,9627,9628, // 9424 -9629,9630,9631,9632,4906,9633,9634,9635,9636,9637,9638,9639,9640,9641,9642,9643, // 9440 -4907,9644,9645,9646,9647,9648,9649,9650,9651,9652,9653,9654,9655,9656,9657,9658, // 9456 -9659,9660,9661,9662,9663,9664,9665,9666,9667,9668,9669,9670,9671,9672,4183,9673, // 9472 -9674,9675,9676,9677,4908,9678,9679,9680,9681,4909,9682,9683,9684,9685,9686,9687, // 9488 -9688,9689,9690,4910,9691,9692,9693,3675,9694,9695,9696,2945,9697,9698,9699,9700, // 9504 -9701,9702,9703,9704,9705,4911,9706,9707,9708,9709,9710,9711,9712,9713,9714,9715, // 9520 -9716,9717,9718,9719,9720,9721,9722,9723,9724,9725,9726,9727,9728,9729,9730,9731, // 9536 -9732,9733,9734,9735,4912,9736,9737,9738,9739,9740,4913,9741,9742,9743,9744,9745, // 9552 -9746,9747,9748,9749,9750,9751,9752,9753,9754,9755,9756,9757,9758,4914,9759,9760, // 9568 -9761,9762,9763,9764,9765,9766,9767,9768,9769,9770,9771,9772,9773,9774,9775,9776, // 9584 -9777,9778,9779,9780,9781,9782,4915,9783,9784,9785,9786,9787,9788,9789,9790,9791, // 9600 -9792,9793,4916,9794,9795,9796,9797,9798,9799,9800,9801,9802,9803,9804,9805,9806, // 9616 -9807,9808,9809,9810,9811,9812,9813,9814,9815,9816,9817,9818,9819,9820,9821,9822, // 9632 -9823,9824,9825,9826,9827,9828,9829,9830,9831,9832,9833,9834,9835,9836,9837,9838, // 9648 -9839,9840,9841,9842,9843,9844,9845,9846,9847,9848,9849,9850,9851,9852,9853,9854, // 9664 -9855,9856,9857,9858,9859,9860,9861,9862,9863,9864,9865,9866,9867,9868,4917,9869, // 9680 -9870,9871,9872,9873,9874,9875,9876,9877,9878,9879,9880,9881,9882,9883,9884,9885, // 9696 -9886,9887,9888,9889,9890,9891,9892,4472,9893,9894,9895,9896,9897,3806,9898,9899, // 9712 -9900,9901,9902,9903,9904,9905,9906,9907,9908,9909,9910,9911,9912,9913,9914,4918, // 9728 -9915,9916,9917,4919,9918,9919,9920,9921,4184,9922,9923,9924,9925,9926,9927,9928, // 9744 -9929,9930,9931,9932,9933,9934,9935,9936,9937,9938,9939,9940,9941,9942,9943,9944, // 9760 -9945,9946,4920,9947,9948,9949,9950,9951,9952,9953,9954,9955,4185,9956,9957,9958, // 9776 -9959,9960,9961,9962,9963,9964,9965,4921,9966,9967,9968,4473,9969,9970,9971,9972, // 9792 -9973,9974,9975,9976,9977,4474,9978,9979,9980,9981,9982,9983,9984,9985,9986,9987, // 9808 -9988,9989,9990,9991,9992,9993,9994,9995,9996,9997,9998,9999,10000,10001,10002,10003, // 9824 -10004,10005,10006,10007,10008,10009,10010,10011,10012,10013,10014,10015,10016,10017,10018,10019, // 9840 -10020,10021,4922,10022,4923,10023,10024,10025,10026,10027,10028,10029,10030,10031,10032,10033, // 9856 -10034,10035,10036,10037,10038,10039,10040,10041,10042,10043,10044,10045,10046,10047,10048,4924, // 9872 -10049,10050,10051,10052,10053,10054,10055,10056,10057,10058,10059,10060,10061,10062,10063,10064, // 9888 -10065,10066,10067,10068,10069,10070,10071,10072,10073,10074,10075,10076,10077,10078,10079,10080, // 9904 -10081,10082,10083,10084,10085,10086,10087,4475,10088,10089,10090,10091,10092,10093,10094,10095, // 9920 -10096,10097,4476,10098,10099,10100,10101,10102,10103,10104,10105,10106,10107,10108,10109,10110, // 9936 -10111,2174,10112,10113,10114,10115,10116,10117,10118,10119,10120,10121,10122,10123,10124,10125, // 9952 -10126,10127,10128,10129,10130,10131,10132,10133,10134,10135,10136,10137,10138,10139,10140,3807, // 9968 -4186,4925,10141,10142,10143,10144,10145,10146,10147,4477,4187,10148,10149,10150,10151,10152, // 9984 -10153,4188,10154,10155,10156,10157,10158,10159,10160,10161,4926,10162,10163,10164,10165,10166, //10000 -10167,10168,10169,10170,10171,10172,10173,10174,10175,10176,10177,10178,10179,10180,10181,10182, //10016 -10183,10184,10185,10186,10187,10188,10189,10190,10191,10192,3203,10193,10194,10195,10196,10197, //10032 -10198,10199,10200,4478,10201,10202,10203,10204,4479,10205,10206,10207,10208,10209,10210,10211, //10048 -10212,10213,10214,10215,10216,10217,10218,10219,10220,10221,10222,10223,10224,10225,10226,10227, //10064 -10228,10229,10230,10231,10232,10233,10234,4927,10235,10236,10237,10238,10239,10240,10241,10242, //10080 -10243,10244,10245,10246,10247,10248,10249,10250,10251,10252,10253,10254,10255,10256,10257,10258, //10096 -10259,10260,10261,10262,10263,10264,10265,10266,10267,10268,10269,10270,10271,10272,10273,4480, //10112 -4928,4929,10274,10275,10276,10277,10278,10279,10280,10281,10282,10283,10284,10285,10286,10287, //10128 -10288,10289,10290,10291,10292,10293,10294,10295,10296,10297,10298,10299,10300,10301,10302,10303, //10144 -10304,10305,10306,10307,10308,10309,10310,10311,10312,10313,10314,10315,10316,10317,10318,10319, //10160 -10320,10321,10322,10323,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334,4930, //10176 -10335,10336,10337,10338,10339,10340,10341,10342,4931,10343,10344,10345,10346,10347,10348,10349, //10192 -10350,10351,10352,10353,10354,10355,3088,10356,2786,10357,10358,10359,10360,4189,10361,10362, //10208 -10363,10364,10365,10366,10367,10368,10369,10370,10371,10372,10373,10374,10375,4932,10376,10377, //10224 -10378,10379,10380,10381,10382,10383,10384,10385,10386,10387,10388,10389,10390,10391,10392,4933, //10240 -10393,10394,10395,4934,10396,10397,10398,10399,10400,10401,10402,10403,10404,10405,10406,10407, //10256 -10408,10409,10410,10411,10412,3446,10413,10414,10415,10416,10417,10418,10419,10420,10421,10422, //10272 -10423,4935,10424,10425,10426,10427,10428,10429,10430,4936,10431,10432,10433,10434,10435,10436, //10288 -10437,10438,10439,10440,10441,10442,10443,4937,10444,10445,10446,10447,4481,10448,10449,10450, //10304 -10451,10452,10453,10454,10455,10456,10457,10458,10459,10460,10461,10462,10463,10464,10465,10466, //10320 -10467,10468,10469,10470,10471,10472,10473,10474,10475,10476,10477,10478,10479,10480,10481,10482, //10336 -10483,10484,10485,10486,10487,10488,10489,10490,10491,10492,10493,10494,10495,10496,10497,10498, //10352 -10499,10500,10501,10502,10503,10504,10505,4938,10506,10507,10508,10509,10510,2552,10511,10512, //10368 -10513,10514,10515,10516,3447,10517,10518,10519,10520,10521,10522,10523,10524,10525,10526,10527, //10384 -10528,10529,10530,10531,10532,10533,10534,10535,10536,10537,10538,10539,10540,10541,10542,10543, //10400 -4482,10544,4939,10545,10546,10547,10548,10549,10550,10551,10552,10553,10554,10555,10556,10557, //10416 -10558,10559,10560,10561,10562,10563,10564,10565,10566,10567,3676,4483,10568,10569,10570,10571, //10432 -10572,3448,10573,10574,10575,10576,10577,10578,10579,10580,10581,10582,10583,10584,10585,10586, //10448 -10587,10588,10589,10590,10591,10592,10593,10594,10595,10596,10597,10598,10599,10600,10601,10602, //10464 -10603,10604,10605,10606,10607,10608,10609,10610,10611,10612,10613,10614,10615,10616,10617,10618, //10480 -10619,10620,10621,10622,10623,10624,10625,10626,10627,4484,10628,10629,10630,10631,10632,4940, //10496 -10633,10634,10635,10636,10637,10638,10639,10640,10641,10642,10643,10644,10645,10646,10647,10648, //10512 -10649,10650,10651,10652,10653,10654,10655,10656,4941,10657,10658,10659,2599,10660,10661,10662, //10528 -10663,10664,10665,10666,3089,10667,10668,10669,10670,10671,10672,10673,10674,10675,10676,10677, //10544 -10678,10679,10680,4942,10681,10682,10683,10684,10685,10686,10687,10688,10689,10690,10691,10692, //10560 -10693,10694,10695,10696,10697,4485,10698,10699,10700,10701,10702,10703,10704,4943,10705,3677, //10576 -10706,10707,10708,10709,10710,10711,10712,4944,10713,10714,10715,10716,10717,10718,10719,10720, //10592 -10721,10722,10723,10724,10725,10726,10727,10728,4945,10729,10730,10731,10732,10733,10734,10735, //10608 -10736,10737,10738,10739,10740,10741,10742,10743,10744,10745,10746,10747,10748,10749,10750,10751, //10624 -10752,10753,10754,10755,10756,10757,10758,10759,10760,10761,4946,10762,10763,10764,10765,10766, //10640 -10767,4947,4948,10768,10769,10770,10771,10772,10773,10774,10775,10776,10777,10778,10779,10780, //10656 -10781,10782,10783,10784,10785,10786,10787,10788,10789,10790,10791,10792,10793,10794,10795,10796, //10672 -10797,10798,10799,10800,10801,10802,10803,10804,10805,10806,10807,10808,10809,10810,10811,10812, //10688 -10813,10814,10815,10816,10817,10818,10819,10820,10821,10822,10823,10824,10825,10826,10827,10828, //10704 -10829,10830,10831,10832,10833,10834,10835,10836,10837,10838,10839,10840,10841,10842,10843,10844, //10720 -10845,10846,10847,10848,10849,10850,10851,10852,10853,10854,10855,10856,10857,10858,10859,10860, //10736 -10861,10862,10863,10864,10865,10866,10867,10868,10869,10870,10871,10872,10873,10874,10875,10876, //10752 -10877,10878,4486,10879,10880,10881,10882,10883,10884,10885,4949,10886,10887,10888,10889,10890, //10768 -10891,10892,10893,10894,10895,10896,10897,10898,10899,10900,10901,10902,10903,10904,10905,10906, //10784 -10907,10908,10909,10910,10911,10912,10913,10914,10915,10916,10917,10918,10919,4487,10920,10921, //10800 -10922,10923,10924,10925,10926,10927,10928,10929,10930,10931,10932,4950,10933,10934,10935,10936, //10816 -10937,10938,10939,10940,10941,10942,10943,10944,10945,10946,10947,10948,10949,4488,10950,10951, //10832 -10952,10953,10954,10955,10956,10957,10958,10959,4190,10960,10961,10962,10963,10964,10965,10966, //10848 -10967,10968,10969,10970,10971,10972,10973,10974,10975,10976,10977,10978,10979,10980,10981,10982, //10864 -10983,10984,10985,10986,10987,10988,10989,10990,10991,10992,10993,10994,10995,10996,10997,10998, //10880 -10999,11000,11001,11002,11003,11004,11005,11006,3960,11007,11008,11009,11010,11011,11012,11013, //10896 -11014,11015,11016,11017,11018,11019,11020,11021,11022,11023,11024,11025,11026,11027,11028,11029, //10912 -11030,11031,11032,4951,11033,11034,11035,11036,11037,11038,11039,11040,11041,11042,11043,11044, //10928 -11045,11046,11047,4489,11048,11049,11050,11051,4952,11052,11053,11054,11055,11056,11057,11058, //10944 -4953,11059,11060,11061,11062,11063,11064,11065,11066,11067,11068,11069,11070,11071,4954,11072, //10960 -11073,11074,11075,11076,11077,11078,11079,11080,11081,11082,11083,11084,11085,11086,11087,11088, //10976 -11089,11090,11091,11092,11093,11094,11095,11096,11097,11098,11099,11100,11101,11102,11103,11104, //10992 -11105,11106,11107,11108,11109,11110,11111,11112,11113,11114,11115,3808,11116,11117,11118,11119, //11008 -11120,11121,11122,11123,11124,11125,11126,11127,11128,11129,11130,11131,11132,11133,11134,4955, //11024 -11135,11136,11137,11138,11139,11140,11141,11142,11143,11144,11145,11146,11147,11148,11149,11150, //11040 -11151,11152,11153,11154,11155,11156,11157,11158,11159,11160,11161,4956,11162,11163,11164,11165, //11056 -11166,11167,11168,11169,11170,11171,11172,11173,11174,11175,11176,11177,11178,11179,11180,4957, //11072 -11181,11182,11183,11184,11185,11186,4958,11187,11188,11189,11190,11191,11192,11193,11194,11195, //11088 -11196,11197,11198,11199,11200,3678,11201,11202,11203,11204,11205,11206,4191,11207,11208,11209, //11104 -11210,11211,11212,11213,11214,11215,11216,11217,11218,11219,11220,11221,11222,11223,11224,11225, //11120 -11226,11227,11228,11229,11230,11231,11232,11233,11234,11235,11236,11237,11238,11239,11240,11241, //11136 -11242,11243,11244,11245,11246,11247,11248,11249,11250,11251,4959,11252,11253,11254,11255,11256, //11152 -11257,11258,11259,11260,11261,11262,11263,11264,11265,11266,11267,11268,11269,11270,11271,11272, //11168 -11273,11274,11275,11276,11277,11278,11279,11280,11281,11282,11283,11284,11285,11286,11287,11288, //11184 -11289,11290,11291,11292,11293,11294,11295,11296,11297,11298,11299,11300,11301,11302,11303,11304, //11200 -11305,11306,11307,11308,11309,11310,11311,11312,11313,11314,3679,11315,11316,11317,11318,4490, //11216 -11319,11320,11321,11322,11323,11324,11325,11326,11327,11328,11329,11330,11331,11332,11333,11334, //11232 -11335,11336,11337,11338,11339,11340,11341,11342,11343,11344,11345,11346,11347,4960,11348,11349, //11248 -11350,11351,11352,11353,11354,11355,11356,11357,11358,11359,11360,11361,11362,11363,11364,11365, //11264 -11366,11367,11368,11369,11370,11371,11372,11373,11374,11375,11376,11377,3961,4961,11378,11379, //11280 -11380,11381,11382,11383,11384,11385,11386,11387,11388,11389,11390,11391,11392,11393,11394,11395, //11296 -11396,11397,4192,11398,11399,11400,11401,11402,11403,11404,11405,11406,11407,11408,11409,11410, //11312 -11411,4962,11412,11413,11414,11415,11416,11417,11418,11419,11420,11421,11422,11423,11424,11425, //11328 -11426,11427,11428,11429,11430,11431,11432,11433,11434,11435,11436,11437,11438,11439,11440,11441, //11344 -11442,11443,11444,11445,11446,11447,11448,11449,11450,11451,11452,11453,11454,11455,11456,11457, //11360 -11458,11459,11460,11461,11462,11463,11464,11465,11466,11467,11468,11469,4963,11470,11471,4491, //11376 -11472,11473,11474,11475,4964,11476,11477,11478,11479,11480,11481,11482,11483,11484,11485,11486, //11392 -11487,11488,11489,11490,11491,11492,4965,11493,11494,11495,11496,11497,11498,11499,11500,11501, //11408 -11502,11503,11504,11505,11506,11507,11508,11509,11510,11511,11512,11513,11514,11515,11516,11517, //11424 -11518,11519,11520,11521,11522,11523,11524,11525,11526,11527,11528,11529,3962,11530,11531,11532, //11440 -11533,11534,11535,11536,11537,11538,11539,11540,11541,11542,11543,11544,11545,11546,11547,11548, //11456 -11549,11550,11551,11552,11553,11554,11555,11556,11557,11558,11559,11560,11561,11562,11563,11564, //11472 -4193,4194,11565,11566,11567,11568,11569,11570,11571,11572,11573,11574,11575,11576,11577,11578, //11488 -11579,11580,11581,11582,11583,11584,11585,11586,11587,11588,11589,11590,11591,4966,4195,11592, //11504 -11593,11594,11595,11596,11597,11598,11599,11600,11601,11602,11603,11604,3090,11605,11606,11607, //11520 -11608,11609,11610,4967,11611,11612,11613,11614,11615,11616,11617,11618,11619,11620,11621,11622, //11536 -11623,11624,11625,11626,11627,11628,11629,11630,11631,11632,11633,11634,11635,11636,11637,11638, //11552 -11639,11640,11641,11642,11643,11644,11645,11646,11647,11648,11649,11650,11651,11652,11653,11654, //11568 -11655,11656,11657,11658,11659,11660,11661,11662,11663,11664,11665,11666,11667,11668,11669,11670, //11584 -11671,11672,11673,11674,4968,11675,11676,11677,11678,11679,11680,11681,11682,11683,11684,11685, //11600 -11686,11687,11688,11689,11690,11691,11692,11693,3809,11694,11695,11696,11697,11698,11699,11700, //11616 -11701,11702,11703,11704,11705,11706,11707,11708,11709,11710,11711,11712,11713,11714,11715,11716, //11632 -11717,11718,3553,11719,11720,11721,11722,11723,11724,11725,11726,11727,11728,11729,11730,4969, //11648 -11731,11732,11733,11734,11735,11736,11737,11738,11739,11740,4492,11741,11742,11743,11744,11745, //11664 -11746,11747,11748,11749,11750,11751,11752,4970,11753,11754,11755,11756,11757,11758,11759,11760, //11680 -11761,11762,11763,11764,11765,11766,11767,11768,11769,11770,11771,11772,11773,11774,11775,11776, //11696 -11777,11778,11779,11780,11781,11782,11783,11784,11785,11786,11787,11788,11789,11790,4971,11791, //11712 -11792,11793,11794,11795,11796,11797,4972,11798,11799,11800,11801,11802,11803,11804,11805,11806, //11728 -11807,11808,11809,11810,4973,11811,11812,11813,11814,11815,11816,11817,11818,11819,11820,11821, //11744 -11822,11823,11824,11825,11826,11827,11828,11829,11830,11831,11832,11833,11834,3680,3810,11835, //11760 -11836,4974,11837,11838,11839,11840,11841,11842,11843,11844,11845,11846,11847,11848,11849,11850, //11776 -11851,11852,11853,11854,11855,11856,11857,11858,11859,11860,11861,11862,11863,11864,11865,11866, //11792 -11867,11868,11869,11870,11871,11872,11873,11874,11875,11876,11877,11878,11879,11880,11881,11882, //11808 -11883,11884,4493,11885,11886,11887,11888,11889,11890,11891,11892,11893,11894,11895,11896,11897, //11824 -11898,11899,11900,11901,11902,11903,11904,11905,11906,11907,11908,11909,11910,11911,11912,11913, //11840 -11914,11915,4975,11916,11917,11918,11919,11920,11921,11922,11923,11924,11925,11926,11927,11928, //11856 -11929,11930,11931,11932,11933,11934,11935,11936,11937,11938,11939,11940,11941,11942,11943,11944, //11872 -11945,11946,11947,11948,11949,4976,11950,11951,11952,11953,11954,11955,11956,11957,11958,11959, //11888 -11960,11961,11962,11963,11964,11965,11966,11967,11968,11969,11970,11971,11972,11973,11974,11975, //11904 -11976,11977,11978,11979,11980,11981,11982,11983,11984,11985,11986,11987,4196,11988,11989,11990, //11920 -11991,11992,4977,11993,11994,11995,11996,11997,11998,11999,12000,12001,12002,12003,12004,12005, //11936 -12006,12007,12008,12009,12010,12011,12012,12013,12014,12015,12016,12017,12018,12019,12020,12021, //11952 -12022,12023,12024,12025,12026,12027,12028,12029,12030,12031,12032,12033,12034,12035,12036,12037, //11968 -12038,12039,12040,12041,12042,12043,12044,12045,12046,12047,12048,12049,12050,12051,12052,12053, //11984 -12054,12055,12056,12057,12058,12059,12060,12061,4978,12062,12063,12064,12065,12066,12067,12068, //12000 -12069,12070,12071,12072,12073,12074,12075,12076,12077,12078,12079,12080,12081,12082,12083,12084, //12016 -12085,12086,12087,12088,12089,12090,12091,12092,12093,12094,12095,12096,12097,12098,12099,12100, //12032 -12101,12102,12103,12104,12105,12106,12107,12108,12109,12110,12111,12112,12113,12114,12115,12116, //12048 -12117,12118,12119,12120,12121,12122,12123,4979,12124,12125,12126,12127,12128,4197,12129,12130, //12064 -12131,12132,12133,12134,12135,12136,12137,12138,12139,12140,12141,12142,12143,12144,12145,12146, //12080 -12147,12148,12149,12150,12151,12152,12153,12154,4980,12155,12156,12157,12158,12159,12160,4494, //12096 -12161,12162,12163,12164,3811,12165,12166,12167,12168,12169,4495,12170,12171,4496,12172,12173, //12112 -12174,12175,12176,3812,12177,12178,12179,12180,12181,12182,12183,12184,12185,12186,12187,12188, //12128 -12189,12190,12191,12192,12193,12194,12195,12196,12197,12198,12199,12200,12201,12202,12203,12204, //12144 -12205,12206,12207,12208,12209,12210,12211,12212,12213,12214,12215,12216,12217,12218,12219,12220, //12160 -12221,4981,12222,12223,12224,12225,12226,12227,12228,12229,12230,12231,12232,12233,12234,12235, //12176 -4982,12236,12237,12238,12239,12240,12241,12242,12243,12244,12245,4983,12246,12247,12248,12249, //12192 -4984,12250,12251,12252,12253,12254,12255,12256,12257,12258,12259,12260,12261,12262,12263,12264, //12208 -4985,12265,4497,12266,12267,12268,12269,12270,12271,12272,12273,12274,12275,12276,12277,12278, //12224 -12279,12280,12281,12282,12283,12284,12285,12286,12287,4986,12288,12289,12290,12291,12292,12293, //12240 -12294,12295,12296,2473,12297,12298,12299,12300,12301,12302,12303,12304,12305,12306,12307,12308, //12256 -12309,12310,12311,12312,12313,12314,12315,12316,12317,12318,12319,3963,12320,12321,12322,12323, //12272 -12324,12325,12326,12327,12328,12329,12330,12331,12332,4987,12333,12334,12335,12336,12337,12338, //12288 -12339,12340,12341,12342,12343,12344,12345,12346,12347,12348,12349,12350,12351,12352,12353,12354, //12304 -12355,12356,12357,12358,12359,3964,12360,12361,12362,12363,12364,12365,12366,12367,12368,12369, //12320 -12370,3965,12371,12372,12373,12374,12375,12376,12377,12378,12379,12380,12381,12382,12383,12384, //12336 -12385,12386,12387,12388,12389,12390,12391,12392,12393,12394,12395,12396,12397,12398,12399,12400, //12352 -12401,12402,12403,12404,12405,12406,12407,12408,4988,12409,12410,12411,12412,12413,12414,12415, //12368 -12416,12417,12418,12419,12420,12421,12422,12423,12424,12425,12426,12427,12428,12429,12430,12431, //12384 -12432,12433,12434,12435,12436,12437,12438,3554,12439,12440,12441,12442,12443,12444,12445,12446, //12400 -12447,12448,12449,12450,12451,12452,12453,12454,12455,12456,12457,12458,12459,12460,12461,12462, //12416 -12463,12464,4989,12465,12466,12467,12468,12469,12470,12471,12472,12473,12474,12475,12476,12477, //12432 -12478,12479,12480,4990,12481,12482,12483,12484,12485,12486,12487,12488,12489,4498,12490,12491, //12448 -12492,12493,12494,12495,12496,12497,12498,12499,12500,12501,12502,12503,12504,12505,12506,12507, //12464 -12508,12509,12510,12511,12512,12513,12514,12515,12516,12517,12518,12519,12520,12521,12522,12523, //12480 -12524,12525,12526,12527,12528,12529,12530,12531,12532,12533,12534,12535,12536,12537,12538,12539, //12496 -12540,12541,12542,12543,12544,12545,12546,12547,12548,12549,12550,12551,4991,12552,12553,12554, //12512 -12555,12556,12557,12558,12559,12560,12561,12562,12563,12564,12565,12566,12567,12568,12569,12570, //12528 -12571,12572,12573,12574,12575,12576,12577,12578,3036,12579,12580,12581,12582,12583,3966,12584, //12544 -12585,12586,12587,12588,12589,12590,12591,12592,12593,12594,12595,12596,12597,12598,12599,12600, //12560 -12601,12602,12603,12604,12605,12606,12607,12608,12609,12610,12611,12612,12613,12614,12615,12616, //12576 -12617,12618,12619,12620,12621,12622,12623,12624,12625,12626,12627,12628,12629,12630,12631,12632, //12592 -12633,12634,12635,12636,12637,12638,12639,12640,12641,12642,12643,12644,12645,12646,4499,12647, //12608 -12648,12649,12650,12651,12652,12653,12654,12655,12656,12657,12658,12659,12660,12661,12662,12663, //12624 -12664,12665,12666,12667,12668,12669,12670,12671,12672,12673,12674,12675,12676,12677,12678,12679, //12640 -12680,12681,12682,12683,12684,12685,12686,12687,12688,12689,12690,12691,12692,12693,12694,12695, //12656 -12696,12697,12698,4992,12699,12700,12701,12702,12703,12704,12705,12706,12707,12708,12709,12710, //12672 -12711,12712,12713,12714,12715,12716,12717,12718,12719,12720,12721,12722,12723,12724,12725,12726, //12688 -12727,12728,12729,12730,12731,12732,12733,12734,12735,12736,12737,12738,12739,12740,12741,12742, //12704 -12743,12744,12745,12746,12747,12748,12749,12750,12751,12752,12753,12754,12755,12756,12757,12758, //12720 -12759,12760,12761,12762,12763,12764,12765,12766,12767,12768,12769,12770,12771,12772,12773,12774, //12736 -12775,12776,12777,12778,4993,2175,12779,12780,12781,12782,12783,12784,12785,12786,4500,12787, //12752 -12788,12789,12790,12791,12792,12793,12794,12795,12796,12797,12798,12799,12800,12801,12802,12803, //12768 -12804,12805,12806,12807,12808,12809,12810,12811,12812,12813,12814,12815,12816,12817,12818,12819, //12784 -12820,12821,12822,12823,12824,12825,12826,4198,3967,12827,12828,12829,12830,12831,12832,12833, //12800 -12834,12835,12836,12837,12838,12839,12840,12841,12842,12843,12844,12845,12846,12847,12848,12849, //12816 -12850,12851,12852,12853,12854,12855,12856,12857,12858,12859,12860,12861,4199,12862,12863,12864, //12832 -12865,12866,12867,12868,12869,12870,12871,12872,12873,12874,12875,12876,12877,12878,12879,12880, //12848 -12881,12882,12883,12884,12885,12886,12887,4501,12888,12889,12890,12891,12892,12893,12894,12895, //12864 -12896,12897,12898,12899,12900,12901,12902,12903,12904,12905,12906,12907,12908,12909,12910,12911, //12880 -12912,4994,12913,12914,12915,12916,12917,12918,12919,12920,12921,12922,12923,12924,12925,12926, //12896 -12927,12928,12929,12930,12931,12932,12933,12934,12935,12936,12937,12938,12939,12940,12941,12942, //12912 -12943,12944,12945,12946,12947,12948,12949,12950,12951,12952,12953,12954,12955,12956,1772,12957, //12928 -12958,12959,12960,12961,12962,12963,12964,12965,12966,12967,12968,12969,12970,12971,12972,12973, //12944 -12974,12975,12976,12977,12978,12979,12980,12981,12982,12983,12984,12985,12986,12987,12988,12989, //12960 -12990,12991,12992,12993,12994,12995,12996,12997,4502,12998,4503,12999,13000,13001,13002,13003, //12976 -4504,13004,13005,13006,13007,13008,13009,13010,13011,13012,13013,13014,13015,13016,13017,13018, //12992 -13019,13020,13021,13022,13023,13024,13025,13026,13027,13028,13029,3449,13030,13031,13032,13033, //13008 -13034,13035,13036,13037,13038,13039,13040,13041,13042,13043,13044,13045,13046,13047,13048,13049, //13024 -13050,13051,13052,13053,13054,13055,13056,13057,13058,13059,13060,13061,13062,13063,13064,13065, //13040 -13066,13067,13068,13069,13070,13071,13072,13073,13074,13075,13076,13077,13078,13079,13080,13081, //13056 -13082,13083,13084,13085,13086,13087,13088,13089,13090,13091,13092,13093,13094,13095,13096,13097, //13072 -13098,13099,13100,13101,13102,13103,13104,13105,13106,13107,13108,13109,13110,13111,13112,13113, //13088 -13114,13115,13116,13117,13118,3968,13119,4995,13120,13121,13122,13123,13124,13125,13126,13127, //13104 -4505,13128,13129,13130,13131,13132,13133,13134,4996,4506,13135,13136,13137,13138,13139,4997, //13120 -13140,13141,13142,13143,13144,13145,13146,13147,13148,13149,13150,13151,13152,13153,13154,13155, //13136 -13156,13157,13158,13159,4998,13160,13161,13162,13163,13164,13165,13166,13167,13168,13169,13170, //13152 -13171,13172,13173,13174,13175,13176,4999,13177,13178,13179,13180,13181,13182,13183,13184,13185, //13168 -13186,13187,13188,13189,13190,13191,13192,13193,13194,13195,13196,13197,13198,13199,13200,13201, //13184 -13202,13203,13204,13205,13206,5000,13207,13208,13209,13210,13211,13212,13213,13214,13215,13216, //13200 -13217,13218,13219,13220,13221,13222,13223,13224,13225,13226,13227,4200,5001,13228,13229,13230, //13216 -13231,13232,13233,13234,13235,13236,13237,13238,13239,13240,3969,13241,13242,13243,13244,3970, //13232 -13245,13246,13247,13248,13249,13250,13251,13252,13253,13254,13255,13256,13257,13258,13259,13260, //13248 -13261,13262,13263,13264,13265,13266,13267,13268,3450,13269,13270,13271,13272,13273,13274,13275, //13264 -13276,5002,13277,13278,13279,13280,13281,13282,13283,13284,13285,13286,13287,13288,13289,13290, //13280 -13291,13292,13293,13294,13295,13296,13297,13298,13299,13300,13301,13302,3813,13303,13304,13305, //13296 -13306,13307,13308,13309,13310,13311,13312,13313,13314,13315,13316,13317,13318,13319,13320,13321, //13312 -13322,13323,13324,13325,13326,13327,13328,4507,13329,13330,13331,13332,13333,13334,13335,13336, //13328 -13337,13338,13339,13340,13341,5003,13342,13343,13344,13345,13346,13347,13348,13349,13350,13351, //13344 -13352,13353,13354,13355,13356,13357,13358,13359,13360,13361,13362,13363,13364,13365,13366,13367, //13360 -5004,13368,13369,13370,13371,13372,13373,13374,13375,13376,13377,13378,13379,13380,13381,13382, //13376 -13383,13384,13385,13386,13387,13388,13389,13390,13391,13392,13393,13394,13395,13396,13397,13398, //13392 -13399,13400,13401,13402,13403,13404,13405,13406,13407,13408,13409,13410,13411,13412,13413,13414, //13408 -13415,13416,13417,13418,13419,13420,13421,13422,13423,13424,13425,13426,13427,13428,13429,13430, //13424 -13431,13432,4508,13433,13434,13435,4201,13436,13437,13438,13439,13440,13441,13442,13443,13444, //13440 -13445,13446,13447,13448,13449,13450,13451,13452,13453,13454,13455,13456,13457,5005,13458,13459, //13456 -13460,13461,13462,13463,13464,13465,13466,13467,13468,13469,13470,4509,13471,13472,13473,13474, //13472 -13475,13476,13477,13478,13479,13480,13481,13482,13483,13484,13485,13486,13487,13488,13489,13490, //13488 -13491,13492,13493,13494,13495,13496,13497,13498,13499,13500,13501,13502,13503,13504,13505,13506, //13504 -13507,13508,13509,13510,13511,13512,13513,13514,13515,13516,13517,13518,13519,13520,13521,13522, //13520 -13523,13524,13525,13526,13527,13528,13529,13530,13531,13532,13533,13534,13535,13536,13537,13538, //13536 -13539,13540,13541,13542,13543,13544,13545,13546,13547,13548,13549,13550,13551,13552,13553,13554, //13552 -13555,13556,13557,13558,13559,13560,13561,13562,13563,13564,13565,13566,13567,13568,13569,13570, //13568 -13571,13572,13573,13574,13575,13576,13577,13578,13579,13580,13581,13582,13583,13584,13585,13586, //13584 -13587,13588,13589,13590,13591,13592,13593,13594,13595,13596,13597,13598,13599,13600,13601,13602, //13600 -13603,13604,13605,13606,13607,13608,13609,13610,13611,13612,13613,13614,13615,13616,13617,13618, //13616 -13619,13620,13621,13622,13623,13624,13625,13626,13627,13628,13629,13630,13631,13632,13633,13634, //13632 -13635,13636,13637,13638,13639,13640,13641,13642,5006,13643,13644,13645,13646,13647,13648,13649, //13648 -13650,13651,5007,13652,13653,13654,13655,13656,13657,13658,13659,13660,13661,13662,13663,13664, //13664 -13665,13666,13667,13668,13669,13670,13671,13672,13673,13674,13675,13676,13677,13678,13679,13680, //13680 -13681,13682,13683,13684,13685,13686,13687,13688,13689,13690,13691,13692,13693,13694,13695,13696, //13696 -13697,13698,13699,13700,13701,13702,13703,13704,13705,13706,13707,13708,13709,13710,13711,13712, //13712 -13713,13714,13715,13716,13717,13718,13719,13720,13721,13722,13723,13724,13725,13726,13727,13728, //13728 -13729,13730,13731,13732,13733,13734,13735,13736,13737,13738,13739,13740,13741,13742,13743,13744, //13744 -13745,13746,13747,13748,13749,13750,13751,13752,13753,13754,13755,13756,13757,13758,13759,13760, //13760 -13761,13762,13763,13764,13765,13766,13767,13768,13769,13770,13771,13772,13773,13774,3273,13775, //13776 -13776,13777,13778,13779,13780,13781,13782,13783,13784,13785,13786,13787,13788,13789,13790,13791, //13792 -13792,13793,13794,13795,13796,13797,13798,13799,13800,13801,13802,13803,13804,13805,13806,13807, //13808 -13808,13809,13810,13811,13812,13813,13814,13815,13816,13817,13818,13819,13820,13821,13822,13823, //13824 -13824,13825,13826,13827,13828,13829,13830,13831,13832,13833,13834,13835,13836,13837,13838,13839, //13840 -13840,13841,13842,13843,13844,13845,13846,13847,13848,13849,13850,13851,13852,13853,13854,13855, //13856 -13856,13857,13858,13859,13860,13861,13862,13863,13864,13865,13866,13867,13868,13869,13870,13871, //13872 -13872,13873,13874,13875,13876,13877,13878,13879,13880,13881,13882,13883,13884,13885,13886,13887, //13888 -13888,13889,13890,13891,13892,13893,13894,13895,13896,13897,13898,13899,13900,13901,13902,13903, //13904 -13904,13905,13906,13907,13908,13909,13910,13911,13912,13913,13914,13915,13916,13917,13918,13919, //13920 -13920,13921,13922,13923,13924,13925,13926,13927,13928,13929,13930,13931,13932,13933,13934,13935, //13936 -13936,13937,13938,13939,13940,13941,13942,13943,13944,13945,13946,13947,13948,13949,13950,13951, //13952 -13952,13953,13954,13955,13956,13957,13958,13959,13960,13961,13962,13963,13964,13965,13966,13967, //13968 -13968,13969,13970,13971,13972, //13973 -****************************************************************************************/ -}; diff --git a/amarok/utilities/collectionscanner/charset-detector/src/tables/EUCKRFreq.tab b/amarok/utilities/collectionscanner/charset-detector/src/tables/EUCKRFreq.tab deleted file mode 100644 index d2c5047a..00000000 --- a/amarok/utilities/collectionscanner/charset-detector/src/tables/EUCKRFreq.tab +++ /dev/null @@ -1,614 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -//Sampling from about 20M text materials include literature and computer technology - -/****************************************************************************** - * 128 --> 0.79 - * 256 --> 0.92 - * 512 --> 0.986 - * 1024 --> 0.99944 - * 2048 --> 0.99999 - * - * Idea Distribution Ratio = 0.98653 / (1-0.98653) = 73.24 - * Random Distribution Ration = 512 / (2350-512) = 0.279. - * - * Typical Distribution Ratio - *****************************************************************************/ - -#define EUCKR_TYPICAL_DISTRIBUTION_RATIO (float) 6.0 - -#define EUCKR_TABLE_SIZE 2352 - -//Char to FreqOrder table , -static const PRInt16 EUCKRCharToFreqOrder[] = -{ - 13, 130, 120,1396, 481,1719,1720, 328, 609, 212,1721, 707, 400, 299,1722, 87, -1397,1723, 104, 536,1117,1203,1724,1267, 685,1268, 508,1725,1726,1727,1728,1398, -1399,1729,1730,1731, 141, 621, 326,1057, 368,1732, 267, 488, 20,1733,1269,1734, - 945,1400,1735, 47, 904,1270,1736,1737, 773, 248,1738, 409, 313, 786, 429,1739, - 116, 987, 813,1401, 683, 75,1204, 145,1740,1741,1742,1743, 16, 847, 667, 622, - 708,1744,1745,1746, 966, 787, 304, 129,1747, 60, 820, 123, 676,1748,1749,1750, -1751, 617,1752, 626,1753,1754,1755,1756, 653,1757,1758,1759,1760,1761,1762, 856, - 344,1763,1764,1765,1766, 89, 401, 418, 806, 905, 848,1767,1768,1769, 946,1205, - 709,1770,1118,1771, 241,1772,1773,1774,1271,1775, 569,1776, 999,1777,1778,1779, -1780, 337, 751,1058, 28, 628, 254,1781, 177, 906, 270, 349, 891,1079,1782, 19, -1783, 379,1784, 315,1785, 629, 754,1402, 559,1786, 636, 203,1206,1787, 710, 567, -1788, 935, 814,1789,1790,1207, 766, 528,1791,1792,1208,1793,1794,1795,1796,1797, -1403,1798,1799, 533,1059,1404,1405,1156,1406, 936, 884,1080,1800, 351,1801,1802, -1803,1804,1805, 801,1806,1807,1808,1119,1809,1157, 714, 474,1407,1810, 298, 899, - 885,1811,1120, 802,1158,1812, 892,1813,1814,1408, 659,1815,1816,1121,1817,1818, -1819,1820,1821,1822, 319,1823, 594, 545,1824, 815, 937,1209,1825,1826, 573,1409, -1022,1827,1210,1828,1829,1830,1831,1832,1833, 556, 722, 807,1122,1060,1834, 697, -1835, 900, 557, 715,1836,1410, 540,1411, 752,1159, 294, 597,1211, 976, 803, 770, -1412,1837,1838, 39, 794,1413, 358,1839, 371, 925,1840, 453, 661, 788, 531, 723, - 544,1023,1081, 869, 91,1841, 392, 430, 790, 602,1414, 677,1082, 457,1415,1416, -1842,1843, 475, 327,1024,1417, 795, 121,1844, 733, 403,1418,1845,1846,1847, 300, - 119, 711,1212, 627,1848,1272, 207,1849,1850, 796,1213, 382,1851, 519,1852,1083, - 893,1853,1854,1855, 367, 809, 487, 671,1856, 663,1857,1858, 956, 471, 306, 857, -1859,1860,1160,1084,1861,1862,1863,1864,1865,1061,1866,1867,1868,1869,1870,1871, - 282, 96, 574,1872, 502,1085,1873,1214,1874, 907,1875,1876, 827, 977,1419,1420, -1421, 268,1877,1422,1878,1879,1880, 308,1881, 2, 537,1882,1883,1215,1884,1885, - 127, 791,1886,1273,1423,1887, 34, 336, 404, 643,1888, 571, 654, 894, 840,1889, - 0, 886,1274, 122, 575, 260, 908, 938,1890,1275, 410, 316,1891,1892, 100,1893, -1894,1123, 48,1161,1124,1025,1895, 633, 901,1276,1896,1897, 115, 816,1898, 317, -1899, 694,1900, 909, 734,1424, 572, 866,1425, 691, 85, 524,1010, 543, 394, 841, -1901,1902,1903,1026,1904,1905,1906,1907,1908,1909, 30, 451, 651, 988, 310,1910, -1911,1426, 810,1216, 93,1912,1913,1277,1217,1914, 858, 759, 45, 58, 181, 610, - 269,1915,1916, 131,1062, 551, 443,1000, 821,1427, 957, 895,1086,1917,1918, 375, -1919, 359,1920, 687,1921, 822,1922, 293,1923,1924, 40, 662, 118, 692, 29, 939, - 887, 640, 482, 174,1925, 69,1162, 728,1428, 910,1926,1278,1218,1279, 386, 870, - 217, 854,1163, 823,1927,1928,1929,1930, 834,1931, 78,1932, 859,1933,1063,1934, -1935,1936,1937, 438,1164, 208, 595,1938,1939,1940,1941,1219,1125,1942, 280, 888, -1429,1430,1220,1431,1943,1944,1945,1946,1947,1280, 150, 510,1432,1948,1949,1950, -1951,1952,1953,1954,1011,1087,1955,1433,1043,1956, 881,1957, 614, 958,1064,1065, -1221,1958, 638,1001, 860, 967, 896,1434, 989, 492, 553,1281,1165,1959,1282,1002, -1283,1222,1960,1961,1962,1963, 36, 383, 228, 753, 247, 454,1964, 876, 678,1965, -1966,1284, 126, 464, 490, 835, 136, 672, 529, 940,1088,1435, 473,1967,1968, 467, - 50, 390, 227, 587, 279, 378, 598, 792, 968, 240, 151, 160, 849, 882,1126,1285, - 639,1044, 133, 140, 288, 360, 811, 563,1027, 561, 142, 523,1969,1970,1971, 7, - 103, 296, 439, 407, 506, 634, 990,1972,1973,1974,1975, 645,1976,1977,1978,1979, -1980,1981, 236,1982,1436,1983,1984,1089, 192, 828, 618, 518,1166, 333,1127,1985, - 818,1223,1986,1987,1988,1989,1990,1991,1992,1993, 342,1128,1286, 746, 842,1994, -1995, 560, 223,1287, 98, 8, 189, 650, 978,1288,1996,1437,1997, 17, 345, 250, - 423, 277, 234, 512, 226, 97, 289, 42, 167,1998, 201,1999,2000, 843, 836, 824, - 532, 338, 783,1090, 182, 576, 436,1438,1439, 527, 500,2001, 947, 889,2002,2003, -2004,2005, 262, 600, 314, 447,2006, 547,2007, 693, 738,1129,2008, 71,1440, 745, - 619, 688,2009, 829,2010,2011, 147,2012, 33, 948,2013,2014, 74, 224,2015, 61, - 191, 918, 399, 637,2016,1028,1130, 257, 902,2017,2018,2019,2020,2021,2022,2023, -2024,2025,2026, 837,2027,2028,2029,2030, 179, 874, 591, 52, 724, 246,2031,2032, -2033,2034,1167, 969,2035,1289, 630, 605, 911,1091,1168,2036,2037,2038,1441, 912, -2039, 623,2040,2041, 253,1169,1290,2042,1442, 146, 620, 611, 577, 433,2043,1224, - 719,1170, 959, 440, 437, 534, 84, 388, 480,1131, 159, 220, 198, 679,2044,1012, - 819,1066,1443, 113,1225, 194, 318,1003,1029,2045,2046,2047,2048,1067,2049,2050, -2051,2052,2053, 59, 913, 112,2054, 632,2055, 455, 144, 739,1291,2056, 273, 681, - 499,2057, 448,2058,2059, 760,2060,2061, 970, 384, 169, 245,1132,2062,2063, 414, -1444,2064,2065, 41, 235,2066, 157, 252, 877, 568, 919, 789, 580,2067, 725,2068, -2069,1292,2070,2071,1445,2072,1446,2073,2074, 55, 588, 66,1447, 271,1092,2075, -1226,2076, 960,1013, 372,2077,2078,2079,2080,2081,1293,2082,2083,2084,2085, 850, -2086,2087,2088,2089,2090, 186,2091,1068, 180,2092,2093,2094, 109,1227, 522, 606, -2095, 867,1448,1093, 991,1171, 926, 353,1133,2096, 581,2097,2098,2099,1294,1449, -1450,2100, 596,1172,1014,1228,2101,1451,1295,1173,1229,2102,2103,1296,1134,1452, - 949,1135,2104,2105,1094,1453,1454,1455,2106,1095,2107,2108,2109,2110,2111,2112, -2113,2114,2115,2116,2117, 804,2118,2119,1230,1231, 805,1456, 405,1136,2120,2121, -2122,2123,2124, 720, 701,1297, 992,1457, 927,1004,2125,2126,2127,2128,2129,2130, - 22, 417,2131, 303,2132, 385,2133, 971, 520, 513,2134,1174, 73,1096, 231, 274, - 962,1458, 673,2135,1459,2136, 152,1137,2137,2138,2139,2140,1005,1138,1460,1139, -2141,2142,2143,2144, 11, 374, 844,2145, 154,1232, 46,1461,2146, 838, 830, 721, -1233, 106,2147, 90, 428, 462, 578, 566,1175, 352,2148,2149, 538,1234, 124,1298, -2150,1462, 761, 565,2151, 686,2152, 649,2153, 72, 173,2154, 460, 415,2155,1463, -2156,1235, 305,2157,2158,2159,2160,2161,2162, 579,2163,2164,2165,2166,2167, 747, -2168,2169,2170,2171,1464, 669,2172,2173,2174,2175,2176,1465,2177, 23, 530, 285, -2178, 335, 729,2179, 397,2180,2181,2182,1030,2183,2184, 698,2185,2186, 325,2187, -2188, 369,2189, 799,1097,1015, 348,2190,1069, 680,2191, 851,1466,2192,2193, 10, -2194, 613, 424,2195, 979, 108, 449, 589, 27, 172, 81,1031, 80, 774, 281, 350, -1032, 525, 301, 582,1176,2196, 674,1045,2197,2198,1467, 730, 762,2199,2200,2201, -2202,1468,2203, 993,2204,2205, 266,1070, 963,1140,2206,2207,2208, 664,1098, 972, -2209,2210,2211,1177,1469,1470, 871,2212,2213,2214,2215,2216,1471,2217,2218,2219, -2220,2221,2222,2223,2224,2225,2226,2227,1472,1236,2228,2229,2230,2231,2232,2233, -2234,2235,1299,2236,2237, 200,2238, 477, 373,2239,2240, 731, 825, 777,2241,2242, -2243, 521, 486, 548,2244,2245,2246,1473,1300, 53, 549, 137, 875, 76, 158,2247, -1301,1474, 469, 396,1016, 278, 712,2248, 321, 442, 503, 767, 744, 941,1237,1178, -1475,2249, 82, 178,1141,1179, 973,2250,1302,2251, 297,2252,2253, 570,2254,2255, -2256, 18, 450, 206,2257, 290, 292,1142,2258, 511, 162, 99, 346, 164, 735,2259, -1476,1477, 4, 554, 343, 798,1099,2260,1100,2261, 43, 171,1303, 139, 215,2262, -2263, 717, 775,2264,1033, 322, 216,2265, 831,2266, 149,2267,1304,2268,2269, 702, -1238, 135, 845, 347, 309,2270, 484,2271, 878, 655, 238,1006,1478,2272, 67,2273, - 295,2274,2275, 461,2276, 478, 942, 412,2277,1034,2278,2279,2280, 265,2281, 541, -2282,2283,2284,2285,2286, 70, 852,1071,2287,2288,2289,2290, 21, 56, 509, 117, - 432,2291,2292, 331, 980, 552,1101, 148, 284, 105, 393,1180,1239, 755,2293, 187, -2294,1046,1479,2295, 340,2296, 63,1047, 230,2297,2298,1305, 763,1306, 101, 800, - 808, 494,2299,2300,2301, 903,2302, 37,1072, 14, 5,2303, 79, 675,2304, 312, -2305,2306,2307,2308,2309,1480, 6,1307,2310,2311,2312, 1, 470, 35, 24, 229, -2313, 695, 210, 86, 778, 15, 784, 592, 779, 32, 77, 855, 964,2314, 259,2315, - 501, 380,2316,2317, 83, 981, 153, 689,1308,1481,1482,1483,2318,2319, 716,1484, -2320,2321,2322,2323,2324,2325,1485,2326,2327, 128, 57, 68, 261,1048, 211, 170, -1240, 31,2328, 51, 435, 742,2329,2330,2331, 635,2332, 264, 456,2333,2334,2335, - 425,2336,1486, 143, 507, 263, 943,2337, 363, 920,1487, 256,1488,1102, 243, 601, -1489,2338,2339,2340,2341,2342,2343,2344, 861,2345,2346,2347,2348,2349,2350, 395, -2351,1490,1491, 62, 535, 166, 225,2352,2353, 668, 419,1241, 138, 604, 928,2354, -1181,2355,1492,1493,2356,2357,2358,1143,2359, 696,2360, 387, 307,1309, 682, 476, -2361,2362, 332, 12, 222, 156,2363, 232,2364, 641, 276, 656, 517,1494,1495,1035, - 416, 736,1496,2365,1017, 586,2366,2367,2368,1497,2369, 242,2370,2371,2372,1498, -2373, 965, 713,2374,2375,2376,2377, 740, 982,1499, 944,1500,1007,2378,2379,1310, -1501,2380,2381,2382, 785, 329,2383,2384,1502,2385,2386,2387, 932,2388,1503,2389, -2390,2391,2392,1242,2393,2394,2395,2396,2397, 994, 950,2398,2399,2400,2401,1504, -1311,2402,2403,2404,2405,1049, 749,2406,2407, 853, 718,1144,1312,2408,1182,1505, -2409,2410, 255, 516, 479, 564, 550, 214,1506,1507,1313, 413, 239, 444, 339,1145, -1036,1508,1509,1314,1037,1510,1315,2411,1511,2412,2413,2414, 176, 703, 497, 624, - 593, 921, 302,2415, 341, 165,1103,1512,2416,1513,2417,2418,2419, 376,2420, 700, -2421,2422,2423, 258, 768,1316,2424,1183,2425, 995, 608,2426,2427,2428,2429, 221, -2430,2431,2432,2433,2434,2435,2436,2437, 195, 323, 726, 188, 897, 983,1317, 377, - 644,1050, 879,2438, 452,2439,2440,2441,2442,2443,2444, 914,2445,2446,2447,2448, - 915, 489,2449,1514,1184,2450,2451, 515, 64, 427, 495,2452, 583,2453, 483, 485, -1038, 562, 213,1515, 748, 666,2454,2455,2456,2457, 334,2458, 780, 996,1008, 705, -1243,2459,2460,2461,2462,2463, 114,2464, 493,1146, 366, 163,1516, 961,1104,2465, - 291,2466,1318,1105,2467,1517, 365,2468, 355, 951,1244,2469,1319,2470, 631,2471, -2472, 218,1320, 364, 320, 756,1518,1519,1321,1520,1322,2473,2474,2475,2476, 997, -2477,2478,2479,2480, 665,1185,2481, 916,1521,2482,2483,2484, 584, 684,2485,2486, - 797,2487,1051,1186,2488,2489,2490,1522,2491,2492, 370,2493,1039,1187, 65,2494, - 434, 205, 463,1188,2495, 125, 812, 391, 402, 826, 699, 286, 398, 155, 781, 771, - 585,2496, 590, 505,1073,2497, 599, 244, 219, 917,1018, 952, 646,1523,2498,1323, -2499,2500, 49, 984, 354, 741,2501, 625,2502,1324,2503,1019, 190, 357, 757, 491, - 95, 782, 868,2504,2505,2506,2507,2508,2509, 134,1524,1074, 422,1525, 898,2510, - 161,2511,2512,2513,2514, 769,2515,1526,2516,2517, 411,1325,2518, 472,1527,2519, -2520,2521,2522,2523,2524, 985,2525,2526,2527,2528,2529,2530, 764,2531,1245,2532, -2533, 25, 204, 311,2534, 496,2535,1052,2536,2537,2538,2539,2540,2541,2542, 199, - 704, 504, 468, 758, 657,1528, 196, 44, 839,1246, 272, 750,2543, 765, 862,2544, -2545,1326,2546, 132, 615, 933,2547, 732,2548,2549,2550,1189,1529,2551, 283,1247, -1053, 607, 929,2552,2553,2554, 930, 183, 872, 616,1040,1147,2555,1148,1020, 441, - 249,1075,2556,2557,2558, 466, 743,2559,2560,2561, 92, 514, 426, 420, 526,2562, -2563,2564,2565,2566,2567,2568, 185,2569,2570,2571,2572, 776,1530, 658,2573, 362, -2574, 361, 922,1076, 793,2575,2576,2577,2578,2579,2580,1531, 251,2581,2582,2583, -2584,1532, 54, 612, 237,1327,2585,2586, 275, 408, 647, 111,2587,1533,1106, 465, - 3, 458, 9, 38,2588, 107, 110, 890, 209, 26, 737, 498,2589,1534,2590, 431, - 202, 88,1535, 356, 287,1107, 660,1149,2591, 381,1536, 986,1150, 445,1248,1151, - 974,2592,2593, 846,2594, 446, 953, 184,1249,1250, 727,2595, 923, 193, 883,2596, -2597,2598, 102, 324, 539, 817,2599, 421,1041,2600, 832,2601, 94, 175, 197, 406, -2602, 459,2603,2604,2605,2606,2607, 330, 555,2608,2609,2610, 706,1108, 389,2611, -2612,2613,2614, 233,2615, 833, 558, 931, 954,1251,2616,2617,1537, 546,2618,2619, -1009,2620,2621,2622,1538, 690,1328,2623, 955,2624,1539,2625,2626, 772,2627,2628, -2629,2630,2631, 924, 648, 863, 603,2632,2633, 934,1540, 864, 865,2634, 642,1042, - 670,1190,2635,2636,2637,2638, 168,2639, 652, 873, 542,1054,1541,2640,2641,2642, //512, 256 - -/*************************************************************************************** - *Everything below is of no interest for detection purpose * - *************************************************************************************** - -2643,2644,2645,2646,2647,2648,2649,2650,2651,2652,2653,2654,2655,2656,2657,2658, -2659,2660,2661,2662,2663,2664,2665,2666,2667,2668,2669,2670,2671,2672,2673,2674, -2675,2676,2677,2678,2679,2680,2681,2682,2683,2684,2685,2686,2687,2688,2689,2690, -2691,2692,2693,2694,2695,2696,2697,2698,2699,1542, 880,2700,2701,2702,2703,2704, -2705,2706,2707,2708,2709,2710,2711,2712,2713,2714,2715,2716,2717,2718,2719,2720, -2721,2722,2723,2724,2725,1543,2726,2727,2728,2729,2730,2731,2732,1544,2733,2734, -2735,2736,2737,2738,2739,2740,2741,2742,2743,2744,2745,2746,2747,2748,2749,2750, -2751,2752,2753,2754,1545,2755,2756,2757,2758,2759,2760,2761,2762,2763,2764,2765, -2766,1546,2767,1547,2768,2769,2770,2771,2772,2773,2774,2775,2776,2777,2778,2779, -2780,2781,2782,2783,2784,2785,2786,1548,2787,2788,2789,1109,2790,2791,2792,2793, -2794,2795,2796,2797,2798,2799,2800,2801,2802,2803,2804,2805,2806,2807,2808,2809, -2810,2811,2812,1329,2813,2814,2815,2816,2817,2818,2819,2820,2821,2822,2823,2824, -2825,2826,2827,2828,2829,2830,2831,2832,2833,2834,2835,2836,2837,2838,2839,2840, -2841,2842,2843,2844,2845,2846,2847,2848,2849,2850,2851,2852,2853,2854,2855,2856, -1549,2857,2858,2859,2860,1550,2861,2862,1551,2863,2864,2865,2866,2867,2868,2869, -2870,2871,2872,2873,2874,1110,1330,2875,2876,2877,2878,2879,2880,2881,2882,2883, -2884,2885,2886,2887,2888,2889,2890,2891,2892,2893,2894,2895,2896,2897,2898,2899, -2900,2901,2902,2903,2904,2905,2906,2907,2908,2909,2910,2911,2912,2913,2914,2915, -2916,2917,2918,2919,2920,2921,2922,2923,2924,2925,2926,2927,2928,2929,2930,1331, -2931,2932,2933,2934,2935,2936,2937,2938,2939,2940,2941,2942,2943,1552,2944,2945, -2946,2947,2948,2949,2950,2951,2952,2953,2954,2955,2956,2957,2958,2959,2960,2961, -2962,2963,2964,1252,2965,2966,2967,2968,2969,2970,2971,2972,2973,2974,2975,2976, -2977,2978,2979,2980,2981,2982,2983,2984,2985,2986,2987,2988,2989,2990,2991,2992, -2993,2994,2995,2996,2997,2998,2999,3000,3001,3002,3003,3004,3005,3006,3007,3008, -3009,3010,3011,3012,1553,3013,3014,3015,3016,3017,1554,3018,1332,3019,3020,3021, -3022,3023,3024,3025,3026,3027,3028,3029,3030,3031,3032,3033,3034,3035,3036,3037, -3038,3039,3040,3041,3042,3043,3044,3045,3046,3047,3048,3049,3050,1555,3051,3052, -3053,1556,1557,3054,3055,3056,3057,3058,3059,3060,3061,3062,3063,3064,3065,3066, -3067,1558,3068,3069,3070,3071,3072,3073,3074,3075,3076,1559,3077,3078,3079,3080, -3081,3082,3083,1253,3084,3085,3086,3087,3088,3089,3090,3091,3092,3093,3094,3095, -3096,3097,3098,3099,3100,3101,3102,3103,3104,3105,3106,3107,3108,1152,3109,3110, -3111,3112,3113,1560,3114,3115,3116,3117,1111,3118,3119,3120,3121,3122,3123,3124, -3125,3126,3127,3128,3129,3130,3131,3132,3133,3134,3135,3136,3137,3138,3139,3140, -3141,3142,3143,3144,3145,3146,3147,3148,3149,3150,3151,3152,3153,3154,3155,3156, -3157,3158,3159,3160,3161,3162,3163,3164,3165,3166,3167,3168,3169,3170,3171,3172, -3173,3174,3175,3176,1333,3177,3178,3179,3180,3181,3182,3183,3184,3185,3186,3187, -3188,3189,1561,3190,3191,1334,3192,3193,3194,3195,3196,3197,3198,3199,3200,3201, -3202,3203,3204,3205,3206,3207,3208,3209,3210,3211,3212,3213,3214,3215,3216,3217, -3218,3219,3220,3221,3222,3223,3224,3225,3226,3227,3228,3229,3230,3231,3232,3233, -3234,1562,3235,3236,3237,3238,3239,3240,3241,3242,3243,3244,3245,3246,3247,3248, -3249,3250,3251,3252,3253,3254,3255,3256,3257,3258,3259,3260,3261,3262,3263,3264, -3265,3266,3267,3268,3269,3270,3271,3272,3273,3274,3275,3276,3277,1563,3278,3279, -3280,3281,3282,3283,3284,3285,3286,3287,3288,3289,3290,3291,3292,3293,3294,3295, -3296,3297,3298,3299,3300,3301,3302,3303,3304,3305,3306,3307,3308,3309,3310,3311, -3312,3313,3314,3315,3316,3317,3318,3319,3320,3321,3322,3323,3324,3325,3326,3327, -3328,3329,3330,3331,3332,3333,3334,3335,3336,3337,3338,3339,3340,3341,3342,3343, -3344,3345,3346,3347,3348,3349,3350,3351,3352,3353,3354,3355,3356,3357,3358,3359, -3360,3361,3362,3363,3364,1335,3365,3366,3367,3368,3369,3370,3371,3372,3373,3374, -3375,3376,3377,3378,3379,3380,3381,3382,3383,3384,3385,3386,3387,1336,3388,3389, -3390,3391,3392,3393,3394,3395,3396,3397,3398,3399,3400,3401,3402,3403,3404,3405, -3406,3407,3408,3409,3410,3411,3412,3413,3414,1337,3415,3416,3417,3418,3419,1338, -3420,3421,3422,1564,1565,3423,3424,3425,3426,3427,3428,3429,3430,3431,1254,3432, -3433,3434,1339,3435,3436,3437,3438,3439,1566,3440,3441,3442,3443,3444,3445,3446, -3447,3448,3449,3450,3451,3452,3453,3454,1255,3455,3456,3457,3458,3459,1567,1191, -3460,1568,1569,3461,3462,3463,1570,3464,3465,3466,3467,3468,1571,3469,3470,3471, -3472,3473,1572,3474,3475,3476,3477,3478,3479,3480,3481,3482,3483,3484,3485,3486, -1340,3487,3488,3489,3490,3491,3492,1021,3493,3494,3495,3496,3497,3498,1573,3499, -1341,3500,3501,3502,3503,3504,3505,3506,3507,3508,3509,3510,3511,1342,3512,3513, -3514,3515,3516,1574,1343,3517,3518,3519,1575,3520,1576,3521,3522,3523,3524,3525, -3526,3527,3528,3529,3530,3531,3532,3533,3534,3535,3536,3537,3538,3539,3540,3541, -3542,3543,3544,3545,3546,3547,3548,3549,3550,3551,3552,3553,3554,3555,3556,3557, -3558,3559,3560,3561,3562,3563,3564,3565,3566,3567,3568,3569,3570,3571,3572,3573, -3574,3575,3576,3577,3578,3579,3580,1577,3581,3582,1578,3583,3584,3585,3586,3587, -3588,3589,3590,3591,3592,3593,3594,3595,3596,3597,3598,3599,3600,3601,3602,3603, -3604,1579,3605,3606,3607,3608,3609,3610,3611,3612,3613,3614,3615,3616,3617,3618, -3619,3620,3621,3622,3623,3624,3625,3626,3627,3628,3629,1580,3630,3631,1581,3632, -3633,3634,3635,3636,3637,3638,3639,3640,3641,3642,3643,3644,3645,3646,3647,3648, -3649,3650,3651,3652,3653,3654,3655,3656,1582,3657,3658,3659,3660,3661,3662,3663, -3664,3665,3666,3667,3668,3669,3670,3671,3672,3673,3674,3675,3676,3677,3678,3679, -3680,3681,3682,3683,3684,3685,3686,3687,3688,3689,3690,3691,3692,3693,3694,3695, -3696,3697,3698,3699,3700,1192,3701,3702,3703,3704,1256,3705,3706,3707,3708,1583, -1257,3709,3710,3711,3712,3713,3714,3715,3716,1584,3717,3718,3719,3720,3721,3722, -3723,3724,3725,3726,3727,3728,3729,3730,3731,3732,3733,3734,3735,3736,3737,3738, -3739,3740,3741,3742,3743,3744,3745,1344,3746,3747,3748,3749,3750,3751,3752,3753, -3754,3755,3756,1585,3757,3758,3759,3760,3761,3762,3763,3764,3765,3766,1586,3767, -3768,3769,3770,3771,3772,3773,3774,3775,3776,3777,3778,1345,3779,3780,3781,3782, -3783,3784,3785,3786,3787,3788,3789,3790,3791,3792,3793,3794,3795,1346,1587,3796, -3797,1588,3798,3799,3800,3801,3802,3803,3804,3805,3806,1347,3807,3808,3809,3810, -3811,1589,3812,3813,3814,3815,3816,3817,3818,3819,3820,3821,1590,3822,3823,1591, -1348,3824,3825,3826,3827,3828,3829,3830,1592,3831,3832,1593,3833,3834,3835,3836, -3837,3838,3839,3840,3841,3842,3843,3844,1349,3845,3846,3847,3848,3849,3850,3851, -3852,3853,3854,3855,3856,3857,3858,1594,3859,3860,3861,3862,3863,3864,3865,3866, -3867,3868,3869,1595,3870,3871,3872,3873,1596,3874,3875,3876,3877,3878,3879,3880, -3881,3882,3883,3884,3885,3886,1597,3887,3888,3889,3890,3891,3892,3893,3894,3895, -1598,3896,3897,3898,1599,1600,3899,1350,3900,1351,3901,3902,1352,3903,3904,3905, -3906,3907,3908,3909,3910,3911,3912,3913,3914,3915,3916,3917,3918,3919,3920,3921, -3922,3923,3924,1258,3925,3926,3927,3928,3929,3930,3931,1193,3932,1601,3933,3934, -3935,3936,3937,3938,3939,3940,3941,3942,3943,1602,3944,3945,3946,3947,3948,1603, -3949,3950,3951,3952,3953,3954,3955,3956,3957,3958,3959,3960,3961,3962,3963,3964, -3965,1604,3966,3967,3968,3969,3970,3971,3972,3973,3974,3975,3976,3977,1353,3978, -3979,3980,3981,3982,3983,3984,3985,3986,3987,3988,3989,3990,3991,1354,3992,3993, -3994,3995,3996,3997,3998,3999,4000,4001,4002,4003,4004,4005,4006,4007,4008,4009, -4010,4011,4012,4013,4014,4015,4016,4017,4018,4019,4020,4021,4022,4023,1355,4024, -4025,4026,4027,4028,4029,4030,4031,4032,4033,4034,4035,4036,4037,4038,4039,4040, -1605,4041,4042,4043,4044,4045,4046,4047,4048,4049,4050,4051,4052,4053,4054,4055, -4056,4057,4058,4059,4060,1606,4061,4062,4063,4064,1607,4065,4066,4067,4068,4069, -4070,4071,4072,4073,4074,4075,4076,1194,4077,4078,1608,4079,4080,4081,4082,4083, -4084,4085,4086,4087,1609,4088,4089,4090,4091,4092,4093,4094,4095,4096,4097,4098, -4099,4100,4101,4102,4103,4104,4105,4106,4107,4108,1259,4109,4110,4111,4112,4113, -4114,4115,4116,4117,4118,4119,4120,4121,4122,4123,4124,1195,4125,4126,4127,1610, -4128,4129,4130,4131,4132,4133,4134,4135,4136,4137,1356,4138,4139,4140,4141,4142, -4143,4144,1611,4145,4146,4147,4148,4149,4150,4151,4152,4153,4154,4155,4156,4157, -4158,4159,4160,4161,4162,4163,4164,4165,4166,4167,4168,4169,4170,4171,4172,4173, -4174,4175,4176,4177,4178,4179,4180,4181,4182,4183,4184,4185,4186,4187,4188,4189, -4190,4191,4192,4193,4194,4195,4196,4197,4198,4199,4200,4201,4202,4203,4204,4205, -4206,4207,4208,4209,4210,4211,4212,4213,4214,4215,4216,4217,4218,4219,1612,4220, -4221,4222,4223,4224,4225,4226,4227,1357,4228,1613,4229,4230,4231,4232,4233,4234, -4235,4236,4237,4238,4239,4240,4241,4242,4243,1614,4244,4245,4246,4247,4248,4249, -4250,4251,4252,4253,4254,4255,4256,4257,4258,4259,4260,4261,4262,4263,4264,4265, -4266,4267,4268,4269,4270,1196,1358,4271,4272,4273,4274,4275,4276,4277,4278,4279, -4280,4281,4282,4283,4284,4285,4286,4287,1615,4288,4289,4290,4291,4292,4293,4294, -4295,4296,4297,4298,4299,4300,4301,4302,4303,4304,4305,4306,4307,4308,4309,4310, -4311,4312,4313,4314,4315,4316,4317,4318,4319,4320,4321,4322,4323,4324,4325,4326, -4327,4328,4329,4330,4331,4332,4333,4334,1616,4335,4336,4337,4338,4339,4340,4341, -4342,4343,4344,4345,4346,4347,4348,4349,4350,4351,4352,4353,4354,4355,4356,4357, -4358,4359,4360,1617,4361,4362,4363,4364,4365,1618,4366,4367,4368,4369,4370,4371, -4372,4373,4374,4375,4376,4377,4378,4379,4380,4381,4382,4383,4384,4385,4386,4387, -4388,4389,4390,4391,4392,4393,4394,4395,4396,4397,4398,4399,4400,4401,4402,4403, -4404,4405,4406,4407,4408,4409,4410,4411,4412,4413,4414,4415,4416,1619,4417,4418, -4419,4420,4421,4422,4423,4424,4425,1112,4426,4427,4428,4429,4430,1620,4431,4432, -4433,4434,4435,4436,4437,4438,4439,4440,4441,4442,1260,1261,4443,4444,4445,4446, -4447,4448,4449,4450,4451,4452,4453,4454,4455,1359,4456,4457,4458,4459,4460,4461, -4462,4463,4464,4465,1621,4466,4467,4468,4469,4470,4471,4472,4473,4474,4475,4476, -4477,4478,4479,4480,4481,4482,4483,4484,4485,4486,4487,4488,4489,1055,4490,4491, -4492,4493,4494,4495,4496,4497,4498,4499,4500,4501,4502,4503,4504,4505,4506,4507, -4508,4509,4510,4511,4512,4513,4514,4515,4516,4517,4518,1622,4519,4520,4521,1623, -4522,4523,4524,4525,4526,4527,4528,4529,4530,4531,4532,4533,4534,4535,1360,4536, -4537,4538,4539,4540,4541,4542,4543, 975,4544,4545,4546,4547,4548,4549,4550,4551, -4552,4553,4554,4555,4556,4557,4558,4559,4560,4561,4562,4563,4564,4565,4566,4567, -4568,4569,4570,4571,1624,4572,4573,4574,4575,4576,1625,4577,4578,4579,4580,4581, -4582,4583,4584,1626,4585,4586,4587,4588,4589,4590,4591,4592,4593,4594,4595,1627, -4596,4597,4598,4599,4600,4601,4602,4603,4604,4605,4606,4607,4608,4609,4610,4611, -4612,4613,4614,4615,1628,4616,4617,4618,4619,4620,4621,4622,4623,4624,4625,4626, -4627,4628,4629,4630,4631,4632,4633,4634,4635,4636,4637,4638,4639,4640,4641,4642, -4643,4644,4645,4646,4647,4648,4649,1361,4650,4651,4652,4653,4654,4655,4656,4657, -4658,4659,4660,4661,1362,4662,4663,4664,4665,4666,4667,4668,4669,4670,4671,4672, -4673,4674,4675,4676,4677,4678,4679,4680,4681,4682,1629,4683,4684,4685,4686,4687, -1630,4688,4689,4690,4691,1153,4692,4693,4694,1113,4695,4696,4697,4698,4699,4700, -4701,4702,4703,4704,4705,4706,4707,4708,4709,4710,4711,1197,4712,4713,4714,4715, -4716,4717,4718,4719,4720,4721,4722,4723,4724,4725,4726,4727,4728,4729,4730,4731, -4732,4733,4734,4735,1631,4736,1632,4737,4738,4739,4740,4741,4742,4743,4744,1633, -4745,4746,4747,4748,4749,1262,4750,4751,4752,4753,4754,1363,4755,4756,4757,4758, -4759,4760,4761,4762,4763,4764,4765,4766,4767,4768,1634,4769,4770,4771,4772,4773, -4774,4775,4776,4777,4778,1635,4779,4780,4781,4782,4783,4784,4785,4786,4787,4788, -4789,1636,4790,4791,4792,4793,4794,4795,4796,4797,4798,4799,4800,4801,4802,4803, -4804,4805,4806,1637,4807,4808,4809,1638,4810,4811,4812,4813,4814,4815,4816,4817, -4818,1639,4819,4820,4821,4822,4823,4824,4825,4826,4827,4828,4829,4830,4831,4832, -4833,1077,4834,4835,4836,4837,4838,4839,4840,4841,4842,4843,4844,4845,4846,4847, -4848,4849,4850,4851,4852,4853,4854,4855,4856,4857,4858,4859,4860,4861,4862,4863, -4864,4865,4866,4867,4868,4869,4870,4871,4872,4873,4874,4875,4876,4877,4878,4879, -4880,4881,4882,4883,1640,4884,4885,1641,4886,4887,4888,4889,4890,4891,4892,4893, -4894,4895,4896,4897,4898,4899,4900,4901,4902,4903,4904,4905,4906,4907,4908,4909, -4910,4911,1642,4912,4913,4914,1364,4915,4916,4917,4918,4919,4920,4921,4922,4923, -4924,4925,4926,4927,4928,4929,4930,4931,1643,4932,4933,4934,4935,4936,4937,4938, -4939,4940,4941,4942,4943,4944,4945,4946,4947,4948,4949,4950,4951,4952,4953,4954, -4955,4956,4957,4958,4959,4960,4961,4962,4963,4964,4965,4966,4967,4968,4969,4970, -4971,4972,4973,4974,4975,4976,4977,4978,4979,4980,1644,4981,4982,4983,4984,1645, -4985,4986,1646,4987,4988,4989,4990,4991,4992,4993,4994,4995,4996,4997,4998,4999, -5000,5001,5002,5003,5004,5005,1647,5006,1648,5007,5008,5009,5010,5011,5012,1078, -5013,5014,5015,5016,5017,5018,5019,5020,5021,5022,5023,5024,5025,5026,5027,5028, -1365,5029,5030,5031,5032,5033,5034,5035,5036,5037,5038,5039,1649,5040,5041,5042, -5043,5044,5045,1366,5046,5047,5048,5049,5050,5051,5052,5053,5054,5055,1650,5056, -5057,5058,5059,5060,5061,5062,5063,5064,5065,5066,5067,5068,5069,5070,5071,5072, -5073,5074,5075,5076,5077,1651,5078,5079,5080,5081,5082,5083,5084,5085,5086,5087, -5088,5089,5090,5091,5092,5093,5094,5095,5096,5097,5098,5099,5100,5101,5102,5103, -5104,5105,5106,5107,5108,5109,5110,1652,5111,5112,5113,5114,5115,5116,5117,5118, -1367,5119,5120,5121,5122,5123,5124,5125,5126,5127,5128,5129,1653,5130,5131,5132, -5133,5134,5135,5136,5137,5138,5139,5140,5141,5142,5143,5144,5145,5146,5147,5148, -5149,1368,5150,1654,5151,1369,5152,5153,5154,5155,5156,5157,5158,5159,5160,5161, -5162,5163,5164,5165,5166,5167,5168,5169,5170,5171,5172,5173,5174,5175,5176,5177, -5178,1370,5179,5180,5181,5182,5183,5184,5185,5186,5187,5188,5189,5190,5191,5192, -5193,5194,5195,5196,5197,5198,1655,5199,5200,5201,5202,1656,5203,5204,5205,5206, -1371,5207,1372,5208,5209,5210,5211,1373,5212,5213,1374,5214,5215,5216,5217,5218, -5219,5220,5221,5222,5223,5224,5225,5226,5227,5228,5229,5230,5231,5232,5233,5234, -5235,5236,5237,5238,5239,5240,5241,5242,5243,5244,5245,5246,5247,1657,5248,5249, -5250,5251,1658,1263,5252,5253,5254,5255,5256,1375,5257,5258,5259,5260,5261,5262, -5263,5264,5265,5266,5267,5268,5269,5270,5271,5272,5273,5274,5275,5276,5277,5278, -5279,5280,5281,5282,5283,1659,5284,5285,5286,5287,5288,5289,5290,5291,5292,5293, -5294,5295,5296,5297,5298,5299,5300,1660,5301,5302,5303,5304,5305,5306,5307,5308, -5309,5310,5311,5312,5313,5314,5315,5316,5317,5318,5319,5320,5321,1376,5322,5323, -5324,5325,5326,5327,5328,5329,5330,5331,5332,5333,1198,5334,5335,5336,5337,5338, -5339,5340,5341,5342,5343,1661,5344,5345,5346,5347,5348,5349,5350,5351,5352,5353, -5354,5355,5356,5357,5358,5359,5360,5361,5362,5363,5364,5365,5366,5367,5368,5369, -5370,5371,5372,5373,5374,5375,5376,5377,5378,5379,5380,5381,5382,5383,5384,5385, -5386,5387,5388,5389,5390,5391,5392,5393,5394,5395,5396,5397,5398,1264,5399,5400, -5401,5402,5403,5404,5405,5406,5407,5408,5409,5410,5411,5412,1662,5413,5414,5415, -5416,1663,5417,5418,5419,5420,5421,5422,5423,5424,5425,5426,5427,5428,5429,5430, -5431,5432,5433,5434,5435,5436,5437,5438,1664,5439,5440,5441,5442,5443,5444,5445, -5446,5447,5448,5449,5450,5451,5452,5453,5454,5455,5456,5457,5458,5459,5460,5461, -5462,5463,5464,5465,5466,5467,5468,5469,5470,5471,5472,5473,5474,5475,5476,5477, -5478,1154,5479,5480,5481,5482,5483,5484,5485,1665,5486,5487,5488,5489,5490,5491, -5492,5493,5494,5495,5496,5497,5498,5499,5500,5501,5502,5503,5504,5505,5506,5507, -5508,5509,5510,5511,5512,5513,5514,5515,5516,5517,5518,5519,5520,5521,5522,5523, -5524,5525,5526,5527,5528,5529,5530,5531,5532,5533,5534,5535,5536,5537,5538,5539, -5540,5541,5542,5543,5544,5545,5546,5547,5548,1377,5549,5550,5551,5552,5553,5554, -5555,5556,5557,5558,5559,5560,5561,5562,5563,5564,5565,5566,5567,5568,5569,5570, -1114,5571,5572,5573,5574,5575,5576,5577,5578,5579,5580,5581,5582,5583,5584,5585, -5586,5587,5588,5589,5590,5591,5592,1378,5593,5594,5595,5596,5597,5598,5599,5600, -5601,5602,5603,5604,5605,5606,5607,5608,5609,5610,5611,5612,5613,5614,1379,5615, -5616,5617,5618,5619,5620,5621,5622,5623,5624,5625,5626,5627,5628,5629,5630,5631, -5632,5633,5634,1380,5635,5636,5637,5638,5639,5640,5641,5642,5643,5644,5645,5646, -5647,5648,5649,1381,1056,5650,5651,5652,5653,5654,5655,5656,5657,5658,5659,5660, -1666,5661,5662,5663,5664,5665,5666,5667,5668,1667,5669,1668,5670,5671,5672,5673, -5674,5675,5676,5677,5678,1155,5679,5680,5681,5682,5683,5684,5685,5686,5687,5688, -5689,5690,5691,5692,5693,5694,5695,5696,5697,5698,1669,5699,5700,5701,5702,5703, -5704,5705,1670,5706,5707,5708,5709,5710,1671,5711,5712,5713,5714,1382,5715,5716, -5717,5718,5719,5720,5721,5722,5723,5724,5725,1672,5726,5727,1673,1674,5728,5729, -5730,5731,5732,5733,5734,5735,5736,1675,5737,5738,5739,5740,5741,5742,5743,5744, -1676,5745,5746,5747,5748,5749,5750,5751,1383,5752,5753,5754,5755,5756,5757,5758, -5759,5760,5761,5762,5763,5764,5765,5766,5767,5768,1677,5769,5770,5771,5772,5773, -1678,5774,5775,5776, 998,5777,5778,5779,5780,5781,5782,5783,5784,5785,1384,5786, -5787,5788,5789,5790,5791,5792,5793,5794,5795,5796,5797,5798,5799,5800,1679,5801, -5802,5803,1115,1116,5804,5805,5806,5807,5808,5809,5810,5811,5812,5813,5814,5815, -5816,5817,5818,5819,5820,5821,5822,5823,5824,5825,5826,5827,5828,5829,5830,5831, -5832,5833,5834,5835,5836,5837,5838,5839,5840,5841,5842,5843,5844,5845,5846,5847, -5848,5849,5850,5851,5852,5853,5854,5855,1680,5856,5857,5858,5859,5860,5861,5862, -5863,5864,1681,5865,5866,5867,1682,5868,5869,5870,5871,5872,5873,5874,5875,5876, -5877,5878,5879,1683,5880,1684,5881,5882,5883,5884,1685,5885,5886,5887,5888,5889, -5890,5891,5892,5893,5894,5895,5896,5897,5898,5899,5900,5901,5902,5903,5904,5905, -5906,5907,1686,5908,5909,5910,5911,5912,5913,5914,5915,5916,5917,5918,5919,5920, -5921,5922,5923,5924,5925,5926,5927,5928,5929,5930,5931,5932,5933,5934,5935,1687, -5936,5937,5938,5939,5940,5941,5942,5943,5944,5945,5946,5947,5948,5949,5950,5951, -5952,1688,1689,5953,1199,5954,5955,5956,5957,5958,5959,5960,5961,1690,5962,5963, -5964,5965,5966,5967,5968,5969,5970,5971,5972,5973,5974,5975,5976,5977,5978,5979, -5980,5981,1385,5982,1386,5983,5984,5985,5986,5987,5988,5989,5990,5991,5992,5993, -5994,5995,5996,5997,5998,5999,6000,6001,6002,6003,6004,6005,6006,6007,6008,6009, -6010,6011,6012,6013,6014,6015,6016,6017,6018,6019,6020,6021,6022,6023,6024,6025, -6026,6027,1265,6028,6029,1691,6030,6031,6032,6033,6034,6035,6036,6037,6038,6039, -6040,6041,6042,6043,6044,6045,6046,6047,6048,6049,6050,6051,6052,6053,6054,6055, -6056,6057,6058,6059,6060,6061,6062,6063,6064,6065,6066,6067,6068,6069,6070,6071, -6072,6073,6074,6075,6076,6077,6078,6079,6080,6081,6082,6083,6084,1692,6085,6086, -6087,6088,6089,6090,6091,6092,6093,6094,6095,6096,6097,6098,6099,6100,6101,6102, -6103,6104,6105,6106,6107,6108,6109,6110,6111,6112,6113,6114,6115,6116,6117,6118, -6119,6120,6121,6122,6123,6124,6125,6126,6127,6128,6129,6130,6131,1693,6132,6133, -6134,6135,6136,1694,6137,6138,6139,6140,6141,1695,6142,6143,6144,6145,6146,6147, -6148,6149,6150,6151,6152,6153,6154,6155,6156,6157,6158,6159,6160,6161,6162,6163, -6164,6165,6166,6167,6168,6169,6170,6171,6172,6173,6174,6175,6176,6177,6178,6179, -6180,6181,6182,6183,6184,6185,1696,6186,6187,6188,6189,6190,6191,6192,6193,6194, -6195,6196,6197,6198,6199,6200,6201,6202,6203,6204,6205,6206,6207,6208,6209,6210, -6211,6212,6213,6214,6215,6216,6217,6218,6219,1697,6220,6221,6222,6223,6224,6225, -6226,6227,6228,6229,6230,6231,6232,6233,6234,6235,6236,6237,6238,6239,6240,6241, -6242,6243,6244,6245,6246,6247,6248,6249,6250,6251,6252,6253,1698,6254,6255,6256, -6257,6258,6259,6260,6261,6262,6263,1200,6264,6265,6266,6267,6268,6269,6270,6271, //1024 -6272,6273,6274,6275,6276,6277,6278,6279,6280,6281,6282,6283,6284,6285,6286,6287, -6288,6289,6290,6291,6292,6293,6294,6295,6296,6297,6298,6299,6300,6301,6302,1699, -6303,6304,1700,6305,6306,6307,6308,6309,6310,6311,6312,6313,6314,6315,6316,6317, -6318,6319,6320,6321,6322,6323,6324,6325,6326,6327,6328,6329,6330,6331,6332,6333, -6334,6335,6336,6337,6338,6339,1701,6340,6341,6342,6343,6344,1387,6345,6346,6347, -6348,6349,6350,6351,6352,6353,6354,6355,6356,6357,6358,6359,6360,6361,6362,6363, -6364,6365,6366,6367,6368,6369,6370,6371,6372,6373,6374,6375,6376,6377,6378,6379, -6380,6381,6382,6383,6384,6385,6386,6387,6388,6389,6390,6391,6392,6393,6394,6395, -6396,6397,6398,6399,6400,6401,6402,6403,6404,6405,6406,6407,6408,6409,6410,6411, -6412,6413,1702,6414,6415,6416,6417,6418,6419,6420,6421,6422,1703,6423,6424,6425, -6426,6427,6428,6429,6430,6431,6432,6433,6434,6435,6436,6437,6438,1704,6439,6440, -6441,6442,6443,6444,6445,6446,6447,6448,6449,6450,6451,6452,6453,6454,6455,6456, -6457,6458,6459,6460,6461,6462,6463,6464,6465,6466,6467,6468,6469,6470,6471,6472, -6473,6474,6475,6476,6477,6478,6479,6480,6481,6482,6483,6484,6485,6486,6487,6488, -6489,6490,6491,6492,6493,6494,6495,6496,6497,6498,6499,6500,6501,6502,6503,1266, -6504,6505,6506,6507,6508,6509,6510,6511,6512,6513,6514,6515,6516,6517,6518,6519, -6520,6521,6522,6523,6524,6525,6526,6527,6528,6529,6530,6531,6532,6533,6534,6535, -6536,6537,6538,6539,6540,6541,6542,6543,6544,6545,6546,6547,6548,6549,6550,6551, -1705,1706,6552,6553,6554,6555,6556,6557,6558,6559,6560,6561,6562,6563,6564,6565, -6566,6567,6568,6569,6570,6571,6572,6573,6574,6575,6576,6577,6578,6579,6580,6581, -6582,6583,6584,6585,6586,6587,6588,6589,6590,6591,6592,6593,6594,6595,6596,6597, -6598,6599,6600,6601,6602,6603,6604,6605,6606,6607,6608,6609,6610,6611,6612,6613, -6614,6615,6616,6617,6618,6619,6620,6621,6622,6623,6624,6625,6626,6627,6628,6629, -6630,6631,6632,6633,6634,6635,6636,6637,1388,6638,6639,6640,6641,6642,6643,6644, -1707,6645,6646,6647,6648,6649,6650,6651,6652,6653,6654,6655,6656,6657,6658,6659, -6660,6661,6662,6663,1708,6664,6665,6666,6667,6668,6669,6670,6671,6672,6673,6674, -1201,6675,6676,6677,6678,6679,6680,6681,6682,6683,6684,6685,6686,6687,6688,6689, -6690,6691,6692,6693,6694,6695,6696,6697,6698,6699,6700,6701,6702,6703,6704,6705, -6706,6707,6708,6709,6710,6711,6712,6713,6714,6715,6716,6717,6718,6719,6720,6721, -6722,6723,6724,6725,1389,6726,6727,6728,6729,6730,6731,6732,6733,6734,6735,6736, -1390,1709,6737,6738,6739,6740,6741,6742,1710,6743,6744,6745,6746,1391,6747,6748, -6749,6750,6751,6752,6753,6754,6755,6756,6757,1392,6758,6759,6760,6761,6762,6763, -6764,6765,6766,6767,6768,6769,6770,6771,6772,6773,6774,6775,6776,6777,6778,6779, -6780,1202,6781,6782,6783,6784,6785,6786,6787,6788,6789,6790,6791,6792,6793,6794, -6795,6796,6797,6798,6799,6800,6801,6802,6803,6804,6805,6806,6807,6808,6809,1711, -6810,6811,6812,6813,6814,6815,6816,6817,6818,6819,6820,6821,6822,6823,6824,6825, -6826,6827,6828,6829,6830,6831,6832,6833,6834,6835,6836,1393,6837,6838,6839,6840, -6841,6842,6843,6844,6845,6846,6847,6848,6849,6850,6851,6852,6853,6854,6855,6856, -6857,6858,6859,6860,6861,6862,6863,6864,6865,6866,6867,6868,6869,6870,6871,6872, -6873,6874,6875,6876,6877,6878,6879,6880,6881,6882,6883,6884,6885,6886,6887,6888, -6889,6890,6891,6892,6893,6894,6895,6896,6897,6898,6899,6900,6901,6902,1712,6903, -6904,6905,6906,6907,6908,6909,6910,1713,6911,6912,6913,6914,6915,6916,6917,6918, -6919,6920,6921,6922,6923,6924,6925,6926,6927,6928,6929,6930,6931,6932,6933,6934, -6935,6936,6937,6938,6939,6940,6941,6942,6943,6944,6945,6946,6947,6948,6949,6950, -6951,6952,6953,6954,6955,6956,6957,6958,6959,6960,6961,6962,6963,6964,6965,6966, -6967,6968,6969,6970,6971,6972,6973,6974,1714,6975,6976,6977,6978,6979,6980,6981, -6982,6983,6984,6985,6986,6987,6988,1394,6989,6990,6991,6992,6993,6994,6995,6996, -6997,6998,6999,7000,1715,7001,7002,7003,7004,7005,7006,7007,7008,7009,7010,7011, -7012,7013,7014,7015,7016,7017,7018,7019,7020,7021,7022,7023,7024,7025,7026,7027, -7028,1716,7029,7030,7031,7032,7033,7034,7035,7036,7037,7038,7039,7040,7041,7042, -7043,7044,7045,7046,7047,7048,7049,7050,7051,7052,7053,7054,7055,7056,7057,7058, -7059,7060,7061,7062,7063,7064,7065,7066,7067,7068,7069,7070,7071,7072,7073,7074, -7075,7076,7077,7078,7079,7080,7081,7082,7083,7084,7085,7086,7087,7088,7089,7090, -7091,7092,7093,7094,7095,7096,7097,7098,7099,7100,7101,7102,7103,7104,7105,7106, -7107,7108,7109,7110,7111,7112,7113,7114,7115,7116,7117,7118,7119,7120,7121,7122, -7123,7124,7125,7126,7127,7128,7129,7130,7131,7132,7133,7134,7135,7136,7137,7138, -7139,7140,7141,7142,7143,7144,7145,7146,7147,7148,7149,7150,7151,7152,7153,7154, -7155,7156,7157,7158,7159,7160,7161,7162,7163,7164,7165,7166,7167,7168,7169,7170, -7171,7172,7173,7174,7175,7176,7177,7178,7179,7180,7181,7182,7183,7184,7185,7186, -7187,7188,7189,7190,7191,7192,7193,7194,7195,7196,7197,7198,7199,7200,7201,7202, -7203,7204,7205,7206,7207,1395,7208,7209,7210,7211,7212,7213,1717,7214,7215,7216, -7217,7218,7219,7220,7221,7222,7223,7224,7225,7226,7227,7228,7229,7230,7231,7232, -7233,7234,7235,7236,7237,7238,7239,7240,7241,7242,7243,7244,7245,7246,7247,7248, -7249,7250,7251,7252,7253,7254,7255,7256,7257,7258,7259,7260,7261,7262,7263,7264, -7265,7266,7267,7268,7269,7270,7271,7272,7273,7274,7275,7276,7277,7278,7279,7280, -7281,7282,7283,7284,7285,7286,7287,7288,7289,7290,7291,7292,7293,7294,7295,7296, -7297,7298,7299,7300,7301,7302,7303,7304,7305,7306,7307,7308,7309,7310,7311,7312, -7313,1718,7314,7315,7316,7317,7318,7319,7320,7321,7322,7323,7324,7325,7326,7327, -7328,7329,7330,7331,7332,7333,7334,7335,7336,7337,7338,7339,7340,7341,7342,7343, -7344,7345,7346,7347,7348,7349,7350,7351,7352,7353,7354,7355,7356,7357,7358,7359, -7360,7361,7362,7363,7364,7365,7366,7367,7368,7369,7370,7371,7372,7373,7374,7375, -7376,7377,7378,7379,7380,7381,7382,7383,7384,7385,7386,7387,7388,7389,7390,7391, -7392,7393,7394,7395,7396,7397,7398,7399,7400,7401,7402,7403,7404,7405,7406,7407, -7408,7409,7410,7411,7412,7413,7414,7415,7416,7417,7418,7419,7420,7421,7422,7423, -7424,7425,7426,7427,7428,7429,7430,7431,7432,7433,7434,7435,7436,7437,7438,7439, -7440,7441,7442,7443,7444,7445,7446,7447,7448,7449,7450,7451,7452,7453,7454,7455, -7456,7457,7458,7459,7460,7461,7462,7463,7464,7465,7466,7467,7468,7469,7470,7471, -7472,7473,7474,7475,7476,7477,7478,7479,7480,7481,7482,7483,7484,7485,7486,7487, -7488,7489,7490,7491,7492,7493,7494,7495,7496,7497,7498,7499,7500,7501,7502,7503, -7504,7505,7506,7507,7508,7509,7510,7511,7512,7513,7514,7515,7516,7517,7518,7519, -7520,7521,7522,7523,7524,7525,7526,7527,7528,7529,7530,7531,7532,7533,7534,7535, -7536,7537,7538,7539,7540,7541,7542,7543,7544,7545,7546,7547,7548,7549,7550,7551, -7552,7553,7554,7555,7556,7557,7558,7559,7560,7561,7562,7563,7564,7565,7566,7567, -7568,7569,7570,7571,7572,7573,7574,7575,7576,7577,7578,7579,7580,7581,7582,7583, -7584,7585,7586,7587,7588,7589,7590,7591,7592,7593,7594,7595,7596,7597,7598,7599, -7600,7601,7602,7603,7604,7605,7606,7607,7608,7609,7610,7611,7612,7613,7614,7615, -7616,7617,7618,7619,7620,7621,7622,7623,7624,7625,7626,7627,7628,7629,7630,7631, -7632,7633,7634,7635,7636,7637,7638,7639,7640,7641,7642,7643,7644,7645,7646,7647, -7648,7649,7650,7651,7652,7653,7654,7655,7656,7657,7658,7659,7660,7661,7662,7663, -7664,7665,7666,7667,7668,7669,7670,7671,7672,7673,7674,7675,7676,7677,7678,7679, -7680,7681,7682,7683,7684,7685,7686,7687,7688,7689,7690,7691,7692,7693,7694,7695, -7696,7697,7698,7699,7700,7701,7702,7703,7704,7705,7706,7707,7708,7709,7710,7711, -7712,7713,7714,7715,7716,7717,7718,7719,7720,7721,7722,7723,7724,7725,7726,7727, -7728,7729,7730,7731,7732,7733,7734,7735,7736,7737,7738,7739,7740,7741,7742,7743, -7744,7745,7746,7747,7748,7749,7750,7751,7752,7753,7754,7755,7756,7757,7758,7759, -7760,7761,7762,7763,7764,7765,7766,7767,7768,7769,7770,7771,7772,7773,7774,7775, -7776,7777,7778,7779,7780,7781,7782,7783,7784,7785,7786,7787,7788,7789,7790,7791, -7792,7793,7794,7795,7796,7797,7798,7799,7800,7801,7802,7803,7804,7805,7806,7807, -7808,7809,7810,7811,7812,7813,7814,7815,7816,7817,7818,7819,7820,7821,7822,7823, -7824,7825,7826,7827,7828,7829,7830,7831,7832,7833,7834,7835,7836,7837,7838,7839, -7840,7841,7842,7843,7844,7845,7846,7847,7848,7849,7850,7851,7852,7853,7854,7855, -7856,7857,7858,7859,7860,7861,7862,7863,7864,7865,7866,7867,7868,7869,7870,7871, -7872,7873,7874,7875,7876,7877,7878,7879,7880,7881,7882,7883,7884,7885,7886,7887, -7888,7889,7890,7891,7892,7893,7894,7895,7896,7897,7898,7899,7900,7901,7902,7903, -7904,7905,7906,7907,7908,7909,7910,7911,7912,7913,7914,7915,7916,7917,7918,7919, -7920,7921,7922,7923,7924,7925,7926,7927,7928,7929,7930,7931,7932,7933,7934,7935, -7936,7937,7938,7939,7940,7941,7942,7943,7944,7945,7946,7947,7948,7949,7950,7951, -7952,7953,7954,7955,7956,7957,7958,7959,7960,7961,7962,7963,7964,7965,7966,7967, -7968,7969,7970,7971,7972,7973,7974,7975,7976,7977,7978,7979,7980,7981,7982,7983, -7984,7985,7986,7987,7988,7989,7990,7991,7992,7993,7994,7995,7996,7997,7998,7999, -8000,8001,8002,8003,8004,8005,8006,8007,8008,8009,8010,8011,8012,8013,8014,8015, -8016,8017,8018,8019,8020,8021,8022,8023,8024,8025,8026,8027,8028,8029,8030,8031, -8032,8033,8034,8035,8036,8037,8038,8039,8040,8041,8042,8043,8044,8045,8046,8047, -8048,8049,8050,8051,8052,8053,8054,8055,8056,8057,8058,8059,8060,8061,8062,8063, -8064,8065,8066,8067,8068,8069,8070,8071,8072,8073,8074,8075,8076,8077,8078,8079, -8080,8081,8082,8083,8084,8085,8086,8087,8088,8089,8090,8091,8092,8093,8094,8095, -8096,8097,8098,8099,8100,8101,8102,8103,8104,8105,8106,8107,8108,8109,8110,8111, -8112,8113,8114,8115,8116,8117,8118,8119,8120,8121,8122,8123,8124,8125,8126,8127, -8128,8129,8130,8131,8132,8133,8134,8135,8136,8137,8138,8139,8140,8141,8142,8143, -8144,8145,8146,8147,8148,8149,8150,8151,8152,8153,8154,8155,8156,8157,8158,8159, -8160,8161,8162,8163,8164,8165,8166,8167,8168,8169,8170,8171,8172,8173,8174,8175, -8176,8177,8178,8179,8180,8181,8182,8183,8184,8185,8186,8187,8188,8189,8190,8191, -8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8203,8204,8205,8206,8207, -8208,8209,8210,8211,8212,8213,8214,8215,8216,8217,8218,8219,8220,8221,8222,8223, -8224,8225,8226,8227,8228,8229,8230,8231,8232,8233,8234,8235,8236,8237,8238,8239, -8240,8241,8242,8243,8244,8245,8246,8247,8248,8249,8250,8251,8252,8253,8254,8255, -8256,8257,8258,8259,8260,8261,8262,8263,8264,8265,8266,8267,8268,8269,8270,8271, -8272,8273,8274,8275,8276,8277,8278,8279,8280,8281,8282,8283,8284,8285,8286,8287, -8288,8289,8290,8291,8292,8293,8294,8295,8296,8297,8298,8299,8300,8301,8302,8303, -8304,8305,8306,8307,8308,8309,8310,8311,8312,8313,8314,8315,8316,8317,8318,8319, -8320,8321,8322,8323,8324,8325,8326,8327,8328,8329,8330,8331,8332,8333,8334,8335, -8336,8337,8338,8339,8340,8341,8342,8343,8344,8345,8346,8347,8348,8349,8350,8351, -8352,8353,8354,8355,8356,8357,8358,8359,8360,8361,8362,8363,8364,8365,8366,8367, -8368,8369,8370,8371,8372,8373,8374,8375,8376,8377,8378,8379,8380,8381,8382,8383, -8384,8385,8386,8387,8388,8389,8390,8391,8392,8393,8394,8395,8396,8397,8398,8399, -8400,8401,8402,8403,8404,8405,8406,8407,8408,8409,8410,8411,8412,8413,8414,8415, -8416,8417,8418,8419,8420,8421,8422,8423,8424,8425,8426,8427,8428,8429,8430,8431, -8432,8433,8434,8435,8436,8437,8438,8439,8440,8441,8442,8443,8444,8445,8446,8447, -8448,8449,8450,8451,8452,8453,8454,8455,8456,8457,8458,8459,8460,8461,8462,8463, -8464,8465,8466,8467,8468,8469,8470,8471,8472,8473,8474,8475,8476,8477,8478,8479, -8480,8481,8482,8483,8484,8485,8486,8487,8488,8489,8490,8491,8492,8493,8494,8495, -8496,8497,8498,8499,8500,8501,8502,8503,8504,8505,8506,8507,8508,8509,8510,8511, -8512,8513,8514,8515,8516,8517,8518,8519,8520,8521,8522,8523,8524,8525,8526,8527, -8528,8529,8530,8531,8532,8533,8534,8535,8536,8537,8538,8539,8540,8541,8542,8543, -8544,8545,8546,8547,8548,8549,8550,8551,8552,8553,8554,8555,8556,8557,8558,8559, -8560,8561,8562,8563,8564,8565,8566,8567,8568,8569,8570,8571,8572,8573,8574,8575, -8576,8577,8578,8579,8580,8581,8582,8583,8584,8585,8586,8587,8588,8589,8590,8591, -8592,8593,8594,8595,8596,8597,8598,8599,8600,8601,8602,8603,8604,8605,8606,8607, -8608,8609,8610,8611,8612,8613,8614,8615,8616,8617,8618,8619,8620,8621,8622,8623, -8624,8625,8626,8627,8628,8629,8630,8631,8632,8633,8634,8635,8636,8637,8638,8639, -8640,8641,8642,8643,8644,8645,8646,8647,8648,8649,8650,8651,8652,8653,8654,8655, -8656,8657,8658,8659,8660,8661,8662,8663,8664,8665,8666,8667,8668,8669,8670,8671, -8672,8673,8674,8675,8676,8677,8678,8679,8680,8681,8682,8683,8684,8685,8686,8687, -8688,8689,8690,8691,8692,8693,8694,8695,8696,8697,8698,8699,8700,8701,8702,8703, -8704,8705,8706,8707,8708,8709,8710,8711,8712,8713,8714,8715,8716,8717,8718,8719, -8720,8721,8722,8723,8724,8725,8726,8727,8728,8729,8730,8731,8732,8733,8734,8735, -8736,8737,8738,8739,8740,8741 -****************************************************************************************/ -}; - diff --git a/amarok/utilities/collectionscanner/charset-detector/src/tables/EUCTWFreq.tab b/amarok/utilities/collectionscanner/charset-detector/src/tables/EUCTWFreq.tab deleted file mode 100644 index 3a189ae0..00000000 --- a/amarok/utilities/collectionscanner/charset-detector/src/tables/EUCTWFreq.tab +++ /dev/null @@ -1,447 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -// EUCTW frequency table -// Converted from big5 work -// by Taiwan's Mandarin Promotion Council -// - - -/****************************************************************************** - * 128 --> 0.42261 - * 256 --> 0.57851 - * 512 --> 0.74851 - * 1024 --> 0.89384 - * 2048 --> 0.97583 - * - * Idea Distribution Ratio = 0.74851/(1-0.74851) =2.98 - * Random Distribution Ration = 512/(5401-512)=0.105 - * - * Typical Distribution Ratio about 25% of Ideal one, still much higher than RDR - *****************************************************************************/ - -#define EUCTW_TYPICAL_DISTRIBUTION_RATIO (float)0.75 - -//Char to FreqOrder table , -#define EUCTW_TABLE_SIZE 8102 - -static const PRInt16 EUCTWCharToFreqOrder[] = -{ - 1,1800,1506, 255,1431, 198, 9, 82, 6,7310, 177, 202,3615,1256,2808, 110, // 2742 -3735, 33,3241, 261, 76, 44,2113, 16,2931,2184,1176, 659,3868, 26,3404,2643, // 2758 -1198,3869,3313,4060, 410,2211, 302, 590, 361,1963, 8, 204, 58,4296,7311,1931, // 2774 - 63,7312,7313, 317,1614, 75, 222, 159,4061,2412,1480,7314,3500,3068, 224,2809, // 2790 -3616, 3, 10,3870,1471, 29,2774,1135,2852,1939, 873, 130,3242,1123, 312,7315, // 2806 -4297,2051, 507, 252, 682,7316, 142,1914, 124, 206,2932, 34,3501,3173, 64, 604, // 2822 -7317,2494,1976,1977, 155,1990, 645, 641,1606,7318,3405, 337, 72, 406,7319, 80, // 2838 - 630, 238,3174,1509, 263, 939,1092,2644, 756,1440,1094,3406, 449, 69,2969, 591, // 2854 - 179,2095, 471, 115,2034,1843, 60, 50,2970, 134, 806,1868, 734,2035,3407, 180, // 2870 - 995,1607, 156, 537,2893, 688,7320, 319,1305, 779,2144, 514,2374, 298,4298, 359, // 2886 -2495, 90,2707,1338, 663, 11, 906,1099,2545, 20,2436, 182, 532,1716,7321, 732, // 2902 -1376,4062,1311,1420,3175, 25,2312,1056, 113, 399, 382,1949, 242,3408,2467, 529, // 2918 -3243, 475,1447,3617,7322, 117, 21, 656, 810,1297,2295,2329,3502,7323, 126,4063, // 2934 - 706, 456, 150, 613,4299, 71,1118,2036,4064, 145,3069, 85, 835, 486,2114,1246, // 2950 -1426, 428, 727,1285,1015, 800, 106, 623, 303,1281,7324,2127,2354, 347,3736, 221, // 2966 -3503,3110,7325,1955,1153,4065, 83, 296,1199,3070, 192, 624, 93,7326, 822,1897, // 2982 -2810,3111, 795,2064, 991,1554,1542,1592, 27, 43,2853, 859, 139,1456, 860,4300, // 2998 - 437, 712,3871, 164,2392,3112, 695, 211,3017,2096, 195,3872,1608,3504,3505,3618, // 3014 -3873, 234, 811,2971,2097,3874,2229,1441,3506,1615,2375, 668,2076,1638, 305, 228, // 3030 -1664,4301, 467, 415,7327, 262,2098,1593, 239, 108, 300, 200,1033, 512,1247,2077, // 3046 -7328,7329,2173,3176,3619,2673, 593, 845,1062,3244, 88,1723,2037,3875,1950, 212, // 3062 - 266, 152, 149, 468,1898,4066,4302, 77, 187,7330,3018, 37, 5,2972,7331,3876, // 3078 -7332,7333, 39,2517,4303,2894,3177,2078, 55, 148, 74,4304, 545, 483,1474,1029, // 3094 -1665, 217,1869,1531,3113,1104,2645,4067, 24, 172,3507, 900,3877,3508,3509,4305, // 3110 - 32,1408,2811,1312, 329, 487,2355,2247,2708, 784,2674, 4,3019,3314,1427,1788, // 3126 - 188, 109, 499,7334,3620,1717,1789, 888,1217,3020,4306,7335,3510,7336,3315,1520, // 3142 -3621,3878, 196,1034, 775,7337,7338, 929,1815, 249, 439, 38,7339,1063,7340, 794, // 3158 -3879,1435,2296, 46, 178,3245,2065,7341,2376,7342, 214,1709,4307, 804, 35, 707, // 3174 - 324,3622,1601,2546, 140, 459,4068,7343,7344,1365, 839, 272, 978,2257,2572,3409, // 3190 -2128,1363,3623,1423, 697, 100,3071, 48, 70,1231, 495,3114,2193,7345,1294,7346, // 3206 -2079, 462, 586,1042,3246, 853, 256, 988, 185,2377,3410,1698, 434,1084,7347,3411, // 3222 - 314,2615,2775,4308,2330,2331, 569,2280, 637,1816,2518, 757,1162,1878,1616,3412, // 3238 - 287,1577,2115, 768,4309,1671,2854,3511,2519,1321,3737, 909,2413,7348,4069, 933, // 3254 -3738,7349,2052,2356,1222,4310, 765,2414,1322, 786,4311,7350,1919,1462,1677,2895, // 3270 -1699,7351,4312,1424,2437,3115,3624,2590,3316,1774,1940,3413,3880,4070, 309,1369, // 3286 -1130,2812, 364,2230,1653,1299,3881,3512,3882,3883,2646, 525,1085,3021, 902,2000, // 3302 -1475, 964,4313, 421,1844,1415,1057,2281, 940,1364,3116, 376,4314,4315,1381, 7, // 3318 -2520, 983,2378, 336,1710,2675,1845, 321,3414, 559,1131,3022,2742,1808,1132,1313, // 3334 - 265,1481,1857,7352, 352,1203,2813,3247, 167,1089, 420,2814, 776, 792,1724,3513, // 3350 -4071,2438,3248,7353,4072,7354, 446, 229, 333,2743, 901,3739,1200,1557,4316,2647, // 3366 -1920, 395,2744,2676,3740,4073,1835, 125, 916,3178,2616,4317,7355,7356,3741,7357, // 3382 -7358,7359,4318,3117,3625,1133,2547,1757,3415,1510,2313,1409,3514,7360,2145, 438, // 3398 -2591,2896,2379,3317,1068, 958,3023, 461, 311,2855,2677,4074,1915,3179,4075,1978, // 3414 - 383, 750,2745,2617,4076, 274, 539, 385,1278,1442,7361,1154,1964, 384, 561, 210, // 3430 - 98,1295,2548,3515,7362,1711,2415,1482,3416,3884,2897,1257, 129,7363,3742, 642, // 3446 - 523,2776,2777,2648,7364, 141,2231,1333, 68, 176, 441, 876, 907,4077, 603,2592, // 3462 - 710, 171,3417, 404, 549, 18,3118,2393,1410,3626,1666,7365,3516,4319,2898,4320, // 3478 -7366,2973, 368,7367, 146, 366, 99, 871,3627,1543, 748, 807,1586,1185, 22,2258, // 3494 - 379,3743,3180,7368,3181, 505,1941,2618,1991,1382,2314,7369, 380,2357, 218, 702, // 3510 -1817,1248,3418,3024,3517,3318,3249,7370,2974,3628, 930,3250,3744,7371, 59,7372, // 3526 - 585, 601,4078, 497,3419,1112,1314,4321,1801,7373,1223,1472,2174,7374, 749,1836, // 3542 - 690,1899,3745,1772,3885,1476, 429,1043,1790,2232,2116, 917,4079, 447,1086,1629, // 3558 -7375, 556,7376,7377,2020,1654, 844,1090, 105, 550, 966,1758,2815,1008,1782, 686, // 3574 -1095,7378,2282, 793,1602,7379,3518,2593,4322,4080,2933,2297,4323,3746, 980,2496, // 3590 - 544, 353, 527,4324, 908,2678,2899,7380, 381,2619,1942,1348,7381,1341,1252, 560, // 3606 -3072,7382,3420,2856,7383,2053, 973, 886,2080, 143,4325,7384,7385, 157,3886, 496, // 3622 -4081, 57, 840, 540,2038,4326,4327,3421,2117,1445, 970,2259,1748,1965,2081,4082, // 3638 -3119,1234,1775,3251,2816,3629, 773,1206,2129,1066,2039,1326,3887,1738,1725,4083, // 3654 - 279,3120, 51,1544,2594, 423,1578,2130,2066, 173,4328,1879,7386,7387,1583, 264, // 3670 - 610,3630,4329,2439, 280, 154,7388,7389,7390,1739, 338,1282,3073, 693,2857,1411, // 3686 -1074,3747,2440,7391,4330,7392,7393,1240, 952,2394,7394,2900,1538,2679, 685,1483, // 3702 -4084,2468,1436, 953,4085,2054,4331, 671,2395, 79,4086,2441,3252, 608, 567,2680, // 3718 -3422,4087,4088,1691, 393,1261,1791,2396,7395,4332,7396,7397,7398,7399,1383,1672, // 3734 -3748,3182,1464, 522,1119, 661,1150, 216, 675,4333,3888,1432,3519, 609,4334,2681, // 3750 -2397,7400,7401,7402,4089,3025, 0,7403,2469, 315, 231,2442, 301,3319,4335,2380, // 3766 -7404, 233,4090,3631,1818,4336,4337,7405, 96,1776,1315,2082,7406, 257,7407,1809, // 3782 -3632,2709,1139,1819,4091,2021,1124,2163,2778,1777,2649,7408,3074, 363,1655,3183, // 3798 -7409,2975,7410,7411,7412,3889,1567,3890, 718, 103,3184, 849,1443, 341,3320,2934, // 3814 -1484,7413,1712, 127, 67, 339,4092,2398, 679,1412, 821,7414,7415, 834, 738, 351, // 3830 -2976,2146, 846, 235,1497,1880, 418,1992,3749,2710, 186,1100,2147,2746,3520,1545, // 3846 -1355,2935,2858,1377, 583,3891,4093,2573,2977,7416,1298,3633,1078,2549,3634,2358, // 3862 - 78,3750,3751, 267,1289,2099,2001,1594,4094, 348, 369,1274,2194,2175,1837,4338, // 3878 -1820,2817,3635,2747,2283,2002,4339,2936,2748, 144,3321, 882,4340,3892,2749,3423, // 3894 -4341,2901,7417,4095,1726, 320,7418,3893,3026, 788,2978,7419,2818,1773,1327,2859, // 3910 -3894,2819,7420,1306,4342,2003,1700,3752,3521,2359,2650, 787,2022, 506, 824,3636, // 3926 - 534, 323,4343,1044,3322,2023,1900, 946,3424,7421,1778,1500,1678,7422,1881,4344, // 3942 - 165, 243,4345,3637,2521, 123, 683,4096, 764,4346, 36,3895,1792, 589,2902, 816, // 3958 - 626,1667,3027,2233,1639,1555,1622,3753,3896,7423,3897,2860,1370,1228,1932, 891, // 3974 -2083,2903, 304,4097,7424, 292,2979,2711,3522, 691,2100,4098,1115,4347, 118, 662, // 3990 -7425, 611,1156, 854,2381,1316,2861, 2, 386, 515,2904,7426,7427,3253, 868,2234, // 4006 -1486, 855,2651, 785,2212,3028,7428,1040,3185,3523,7429,3121, 448,7430,1525,7431, // 4022 -2164,4348,7432,3754,7433,4099,2820,3524,3122, 503, 818,3898,3123,1568, 814, 676, // 4038 -1444, 306,1749,7434,3755,1416,1030, 197,1428, 805,2821,1501,4349,7435,7436,7437, // 4054 -1993,7438,4350,7439,7440,2195, 13,2779,3638,2980,3124,1229,1916,7441,3756,2131, // 4070 -7442,4100,4351,2399,3525,7443,2213,1511,1727,1120,7444,7445, 646,3757,2443, 307, // 4086 -7446,7447,1595,3186,7448,7449,7450,3639,1113,1356,3899,1465,2522,2523,7451, 519, // 4102 -7452, 128,2132, 92,2284,1979,7453,3900,1512, 342,3125,2196,7454,2780,2214,1980, // 4118 -3323,7455, 290,1656,1317, 789, 827,2360,7456,3758,4352, 562, 581,3901,7457, 401, // 4134 -4353,2248, 94,4354,1399,2781,7458,1463,2024,4355,3187,1943,7459, 828,1105,4101, // 4150 -1262,1394,7460,4102, 605,4356,7461,1783,2862,7462,2822, 819,2101, 578,2197,2937, // 4166 -7463,1502, 436,3254,4103,3255,2823,3902,2905,3425,3426,7464,2712,2315,7465,7466, // 4182 -2332,2067, 23,4357, 193, 826,3759,2102, 699,1630,4104,3075, 390,1793,1064,3526, // 4198 -7467,1579,3076,3077,1400,7468,4105,1838,1640,2863,7469,4358,4359, 137,4106, 598, // 4214 -3078,1966, 780, 104, 974,2938,7470, 278, 899, 253, 402, 572, 504, 493,1339,7471, // 4230 -3903,1275,4360,2574,2550,7472,3640,3029,3079,2249, 565,1334,2713, 863, 41,7473, // 4246 -7474,4361,7475,1657,2333, 19, 463,2750,4107, 606,7476,2981,3256,1087,2084,1323, // 4262 -2652,2982,7477,1631,1623,1750,4108,2682,7478,2864, 791,2714,2653,2334, 232,2416, // 4278 -7479,2983,1498,7480,2654,2620, 755,1366,3641,3257,3126,2025,1609, 119,1917,3427, // 4294 - 862,1026,4109,7481,3904,3760,4362,3905,4363,2260,1951,2470,7482,1125, 817,4110, // 4310 -4111,3906,1513,1766,2040,1487,4112,3030,3258,2824,3761,3127,7483,7484,1507,7485, // 4326 -2683, 733, 40,1632,1106,2865, 345,4113, 841,2524, 230,4364,2984,1846,3259,3428, // 4342 -7486,1263, 986,3429,7487, 735, 879, 254,1137, 857, 622,1300,1180,1388,1562,3907, // 4358 -3908,2939, 967,2751,2655,1349, 592,2133,1692,3324,2985,1994,4114,1679,3909,1901, // 4374 -2185,7488, 739,3642,2715,1296,1290,7489,4115,2198,2199,1921,1563,2595,2551,1870, // 4390 -2752,2986,7490, 435,7491, 343,1108, 596, 17,1751,4365,2235,3430,3643,7492,4366, // 4406 - 294,3527,2940,1693, 477, 979, 281,2041,3528, 643,2042,3644,2621,2782,2261,1031, // 4422 -2335,2134,2298,3529,4367, 367,1249,2552,7493,3530,7494,4368,1283,3325,2004, 240, // 4438 -1762,3326,4369,4370, 836,1069,3128, 474,7495,2148,2525, 268,3531,7496,3188,1521, // 4454 -1284,7497,1658,1546,4116,7498,3532,3533,7499,4117,3327,2684,1685,4118, 961,1673, // 4470 -2622, 190,2005,2200,3762,4371,4372,7500, 570,2497,3645,1490,7501,4373,2623,3260, // 4486 -1956,4374, 584,1514, 396,1045,1944,7502,4375,1967,2444,7503,7504,4376,3910, 619, // 4502 -7505,3129,3261, 215,2006,2783,2553,3189,4377,3190,4378, 763,4119,3763,4379,7506, // 4518 -7507,1957,1767,2941,3328,3646,1174, 452,1477,4380,3329,3130,7508,2825,1253,2382, // 4534 -2186,1091,2285,4120, 492,7509, 638,1169,1824,2135,1752,3911, 648, 926,1021,1324, // 4550 -4381, 520,4382, 997, 847,1007, 892,4383,3764,2262,1871,3647,7510,2400,1784,4384, // 4566 -1952,2942,3080,3191,1728,4121,2043,3648,4385,2007,1701,3131,1551, 30,2263,4122, // 4582 -7511,2026,4386,3534,7512, 501,7513,4123, 594,3431,2165,1821,3535,3432,3536,3192, // 4598 - 829,2826,4124,7514,1680,3132,1225,4125,7515,3262,4387,4126,3133,2336,7516,4388, // 4614 -4127,7517,3912,3913,7518,1847,2383,2596,3330,7519,4389, 374,3914, 652,4128,4129, // 4630 - 375,1140, 798,7520,7521,7522,2361,4390,2264, 546,1659, 138,3031,2445,4391,7523, // 4646 -2250, 612,1848, 910, 796,3765,1740,1371, 825,3766,3767,7524,2906,2554,7525, 692, // 4662 - 444,3032,2624, 801,4392,4130,7526,1491, 244,1053,3033,4131,4132, 340,7527,3915, // 4678 -1041,2987, 293,1168, 87,1357,7528,1539, 959,7529,2236, 721, 694,4133,3768, 219, // 4694 -1478, 644,1417,3331,2656,1413,1401,1335,1389,3916,7530,7531,2988,2362,3134,1825, // 4710 - 730,1515, 184,2827, 66,4393,7532,1660,2943, 246,3332, 378,1457, 226,3433, 975, // 4726 -3917,2944,1264,3537, 674, 696,7533, 163,7534,1141,2417,2166, 713,3538,3333,4394, // 4742 -3918,7535,7536,1186, 15,7537,1079,1070,7538,1522,3193,3539, 276,1050,2716, 758, // 4758 -1126, 653,2945,3263,7539,2337, 889,3540,3919,3081,2989, 903,1250,4395,3920,3434, // 4774 -3541,1342,1681,1718, 766,3264, 286, 89,2946,3649,7540,1713,7541,2597,3334,2990, // 4790 -7542,2947,2215,3194,2866,7543,4396,2498,2526, 181, 387,1075,3921, 731,2187,3335, // 4806 -7544,3265, 310, 313,3435,2299, 770,4134, 54,3034, 189,4397,3082,3769,3922,7545, // 4822 -1230,1617,1849, 355,3542,4135,4398,3336, 111,4136,3650,1350,3135,3436,3035,4137, // 4838 -2149,3266,3543,7546,2784,3923,3924,2991, 722,2008,7547,1071, 247,1207,2338,2471, // 4854 -1378,4399,2009, 864,1437,1214,4400, 373,3770,1142,2216, 667,4401, 442,2753,2555, // 4870 -3771,3925,1968,4138,3267,1839, 837, 170,1107, 934,1336,1882,7548,7549,2118,4139, // 4886 -2828, 743,1569,7550,4402,4140, 582,2384,1418,3437,7551,1802,7552, 357,1395,1729, // 4902 -3651,3268,2418,1564,2237,7553,3083,3772,1633,4403,1114,2085,4141,1532,7554, 482, // 4918 -2446,4404,7555,7556,1492, 833,1466,7557,2717,3544,1641,2829,7558,1526,1272,3652, // 4934 -4142,1686,1794, 416,2556,1902,1953,1803,7559,3773,2785,3774,1159,2316,7560,2867, // 4950 -4405,1610,1584,3036,2419,2754, 443,3269,1163,3136,7561,7562,3926,7563,4143,2499, // 4966 -3037,4406,3927,3137,2103,1647,3545,2010,1872,4144,7564,4145, 431,3438,7565, 250, // 4982 - 97, 81,4146,7566,1648,1850,1558, 160, 848,7567, 866, 740,1694,7568,2201,2830, // 4998 -3195,4147,4407,3653,1687, 950,2472, 426, 469,3196,3654,3655,3928,7569,7570,1188, // 5014 - 424,1995, 861,3546,4148,3775,2202,2685, 168,1235,3547,4149,7571,2086,1674,4408, // 5030 -3337,3270, 220,2557,1009,7572,3776, 670,2992, 332,1208, 717,7573,7574,3548,2447, // 5046 -3929,3338,7575, 513,7576,1209,2868,3339,3138,4409,1080,7577,7578,7579,7580,2527, // 5062 -3656,3549, 815,1587,3930,3931,7581,3550,3439,3777,1254,4410,1328,3038,1390,3932, // 5078 -1741,3933,3778,3934,7582, 236,3779,2448,3271,7583,7584,3657,3780,1273,3781,4411, // 5094 -7585, 308,7586,4412, 245,4413,1851,2473,1307,2575, 430, 715,2136,2449,7587, 270, // 5110 - 199,2869,3935,7588,3551,2718,1753, 761,1754, 725,1661,1840,4414,3440,3658,7589, // 5126 -7590, 587, 14,3272, 227,2598, 326, 480,2265, 943,2755,3552, 291, 650,1883,7591, // 5142 -1702,1226, 102,1547, 62,3441, 904,4415,3442,1164,4150,7592,7593,1224,1548,2756, // 5158 - 391, 498,1493,7594,1386,1419,7595,2055,1177,4416, 813, 880,1081,2363, 566,1145, // 5174 -4417,2286,1001,1035,2558,2599,2238, 394,1286,7596,7597,2068,7598, 86,1494,1730, // 5190 -3936, 491,1588, 745, 897,2948, 843,3340,3937,2757,2870,3273,1768, 998,2217,2069, // 5206 - 397,1826,1195,1969,3659,2993,3341, 284,7599,3782,2500,2137,2119,1903,7600,3938, // 5222 -2150,3939,4151,1036,3443,1904, 114,2559,4152, 209,1527,7601,7602,2949,2831,2625, // 5238 -2385,2719,3139, 812,2560,7603,3274,7604,1559, 737,1884,3660,1210, 885, 28,2686, // 5254 -3553,3783,7605,4153,1004,1779,4418,7606, 346,1981,2218,2687,4419,3784,1742, 797, // 5270 -1642,3940,1933,1072,1384,2151, 896,3941,3275,3661,3197,2871,3554,7607,2561,1958, // 5286 -4420,2450,1785,7608,7609,7610,3942,4154,1005,1308,3662,4155,2720,4421,4422,1528, // 5302 -2600, 161,1178,4156,1982, 987,4423,1101,4157, 631,3943,1157,3198,2420,1343,1241, // 5318 -1016,2239,2562, 372, 877,2339,2501,1160, 555,1934, 911,3944,7611, 466,1170, 169, // 5334 -1051,2907,2688,3663,2474,2994,1182,2011,2563,1251,2626,7612, 992,2340,3444,1540, // 5350 -2721,1201,2070,2401,1996,2475,7613,4424, 528,1922,2188,1503,1873,1570,2364,3342, // 5366 -3276,7614, 557,1073,7615,1827,3445,2087,2266,3140,3039,3084, 767,3085,2786,4425, // 5382 -1006,4158,4426,2341,1267,2176,3664,3199, 778,3945,3200,2722,1597,2657,7616,4427, // 5398 -7617,3446,7618,7619,7620,3277,2689,1433,3278, 131, 95,1504,3946, 723,4159,3141, // 5414 -1841,3555,2758,2189,3947,2027,2104,3665,7621,2995,3948,1218,7622,3343,3201,3949, // 5430 -4160,2576, 248,1634,3785, 912,7623,2832,3666,3040,3786, 654, 53,7624,2996,7625, // 5446 -1688,4428, 777,3447,1032,3950,1425,7626, 191, 820,2120,2833, 971,4429, 931,3202, // 5462 - 135, 664, 783,3787,1997, 772,2908,1935,3951,3788,4430,2909,3203, 282,2723, 640, // 5478 -1372,3448,1127, 922, 325,3344,7627,7628, 711,2044,7629,7630,3952,2219,2787,1936, // 5494 -3953,3345,2220,2251,3789,2300,7631,4431,3790,1258,3279,3954,3204,2138,2950,3955, // 5510 -3956,7632,2221, 258,3205,4432, 101,1227,7633,3280,1755,7634,1391,3281,7635,2910, // 5526 -2056, 893,7636,7637,7638,1402,4161,2342,7639,7640,3206,3556,7641,7642, 878,1325, // 5542 -1780,2788,4433, 259,1385,2577, 744,1183,2267,4434,7643,3957,2502,7644, 684,1024, // 5558 -4162,7645, 472,3557,3449,1165,3282,3958,3959, 322,2152, 881, 455,1695,1152,1340, // 5574 - 660, 554,2153,4435,1058,4436,4163, 830,1065,3346,3960,4437,1923,7646,1703,1918, // 5590 -7647, 932,2268, 122,7648,4438, 947, 677,7649,3791,2627, 297,1905,1924,2269,4439, // 5606 -2317,3283,7650,7651,4164,7652,4165, 84,4166, 112, 989,7653, 547,1059,3961, 701, // 5622 -3558,1019,7654,4167,7655,3450, 942, 639, 457,2301,2451, 993,2951, 407, 851, 494, // 5638 -4440,3347, 927,7656,1237,7657,2421,3348, 573,4168, 680, 921,2911,1279,1874, 285, // 5654 - 790,1448,1983, 719,2167,7658,7659,4441,3962,3963,1649,7660,1541, 563,7661,1077, // 5670 -7662,3349,3041,3451, 511,2997,3964,3965,3667,3966,1268,2564,3350,3207,4442,4443, // 5686 -7663, 535,1048,1276,1189,2912,2028,3142,1438,1373,2834,2952,1134,2012,7664,4169, // 5702 -1238,2578,3086,1259,7665, 700,7666,2953,3143,3668,4170,7667,4171,1146,1875,1906, // 5718 -4444,2601,3967, 781,2422, 132,1589, 203, 147, 273,2789,2402, 898,1786,2154,3968, // 5734 -3969,7668,3792,2790,7669,7670,4445,4446,7671,3208,7672,1635,3793, 965,7673,1804, // 5750 -2690,1516,3559,1121,1082,1329,3284,3970,1449,3794, 65,1128,2835,2913,2759,1590, // 5766 -3795,7674,7675, 12,2658, 45, 976,2579,3144,4447, 517,2528,1013,1037,3209,7676, // 5782 -3796,2836,7677,3797,7678,3452,7679,2602, 614,1998,2318,3798,3087,2724,2628,7680, // 5798 -2580,4172, 599,1269,7681,1810,3669,7682,2691,3088, 759,1060, 489,1805,3351,3285, // 5814 -1358,7683,7684,2386,1387,1215,2629,2252, 490,7685,7686,4173,1759,2387,2343,7687, // 5830 -4448,3799,1907,3971,2630,1806,3210,4449,3453,3286,2760,2344, 874,7688,7689,3454, // 5846 -3670,1858, 91,2914,3671,3042,3800,4450,7690,3145,3972,2659,7691,3455,1202,1403, // 5862 -3801,2954,2529,1517,2503,4451,3456,2504,7692,4452,7693,2692,1885,1495,1731,3973, // 5878 -2365,4453,7694,2029,7695,7696,3974,2693,1216, 237,2581,4174,2319,3975,3802,4454, // 5894 -4455,2694,3560,3457, 445,4456,7697,7698,7699,7700,2761, 61,3976,3672,1822,3977, // 5910 -7701, 687,2045, 935, 925, 405,2660, 703,1096,1859,2725,4457,3978,1876,1367,2695, // 5926 -3352, 918,2105,1781,2476, 334,3287,1611,1093,4458, 564,3146,3458,3673,3353, 945, // 5942 -2631,2057,4459,7702,1925, 872,4175,7703,3459,2696,3089, 349,4176,3674,3979,4460, // 5958 -3803,4177,3675,2155,3980,4461,4462,4178,4463,2403,2046, 782,3981, 400, 251,4179, // 5974 -1624,7704,7705, 277,3676, 299,1265, 476,1191,3804,2121,4180,4181,1109, 205,7706, // 5990 -2582,1000,2156,3561,1860,7707,7708,7709,4464,7710,4465,2565, 107,2477,2157,3982, // 6006 -3460,3147,7711,1533, 541,1301, 158, 753,4182,2872,3562,7712,1696, 370,1088,4183, // 6022 -4466,3563, 579, 327, 440, 162,2240, 269,1937,1374,3461, 968,3043, 56,1396,3090, // 6038 -2106,3288,3354,7713,1926,2158,4467,2998,7714,3564,7715,7716,3677,4468,2478,7717, // 6054 -2791,7718,1650,4469,7719,2603,7720,7721,3983,2661,3355,1149,3356,3984,3805,3985, // 6070 -7722,1076, 49,7723, 951,3211,3289,3290, 450,2837, 920,7724,1811,2792,2366,4184, // 6086 -1908,1138,2367,3806,3462,7725,3212,4470,1909,1147,1518,2423,4471,3807,7726,4472, // 6102 -2388,2604, 260,1795,3213,7727,7728,3808,3291, 708,7729,3565,1704,7730,3566,1351, // 6118 -1618,3357,2999,1886, 944,4185,3358,4186,3044,3359,4187,7731,3678, 422, 413,1714, // 6134 -3292, 500,2058,2345,4188,2479,7732,1344,1910, 954,7733,1668,7734,7735,3986,2404, // 6150 -4189,3567,3809,4190,7736,2302,1318,2505,3091, 133,3092,2873,4473, 629, 31,2838, // 6166 -2697,3810,4474, 850, 949,4475,3987,2955,1732,2088,4191,1496,1852,7737,3988, 620, // 6182 -3214, 981,1242,3679,3360,1619,3680,1643,3293,2139,2452,1970,1719,3463,2168,7738, // 6198 -3215,7739,7740,3361,1828,7741,1277,4476,1565,2047,7742,1636,3568,3093,7743, 869, // 6214 -2839, 655,3811,3812,3094,3989,3000,3813,1310,3569,4477,7744,7745,7746,1733, 558, // 6230 -4478,3681, 335,1549,3045,1756,4192,3682,1945,3464,1829,1291,1192, 470,2726,2107, // 6246 -2793, 913,1054,3990,7747,1027,7748,3046,3991,4479, 982,2662,3362,3148,3465,3216, // 6262 -3217,1946,2794,7749, 571,4480,7750,1830,7751,3570,2583,1523,2424,7752,2089, 984, // 6278 -4481,3683,1959,7753,3684, 852, 923,2795,3466,3685, 969,1519, 999,2048,2320,1705, // 6294 -7754,3095, 615,1662, 151, 597,3992,2405,2321,1049, 275,4482,3686,4193, 568,3687, // 6310 -3571,2480,4194,3688,7755,2425,2270, 409,3218,7756,1566,2874,3467,1002, 769,2840, // 6326 - 194,2090,3149,3689,2222,3294,4195, 628,1505,7757,7758,1763,2177,3001,3993, 521, // 6342 -1161,2584,1787,2203,2406,4483,3994,1625,4196,4197, 412, 42,3096, 464,7759,2632, // 6358 -4484,3363,1760,1571,2875,3468,2530,1219,2204,3814,2633,2140,2368,4485,4486,3295, // 6374 -1651,3364,3572,7760,7761,3573,2481,3469,7762,3690,7763,7764,2271,2091, 460,7765, // 6390 -4487,7766,3002, 962, 588,3574, 289,3219,2634,1116, 52,7767,3047,1796,7768,7769, // 6406 -7770,1467,7771,1598,1143,3691,4198,1984,1734,1067,4488,1280,3365, 465,4489,1572, // 6422 - 510,7772,1927,2241,1812,1644,3575,7773,4490,3692,7774,7775,2663,1573,1534,7776, // 6438 -7777,4199, 536,1807,1761,3470,3815,3150,2635,7778,7779,7780,4491,3471,2915,1911, // 6454 -2796,7781,3296,1122, 377,3220,7782, 360,7783,7784,4200,1529, 551,7785,2059,3693, // 6470 -1769,2426,7786,2916,4201,3297,3097,2322,2108,2030,4492,1404, 136,1468,1479, 672, // 6486 -1171,3221,2303, 271,3151,7787,2762,7788,2049, 678,2727, 865,1947,4493,7789,2013, // 6502 -3995,2956,7790,2728,2223,1397,3048,3694,4494,4495,1735,2917,3366,3576,7791,3816, // 6518 - 509,2841,2453,2876,3817,7792,7793,3152,3153,4496,4202,2531,4497,2304,1166,1010, // 6534 - 552, 681,1887,7794,7795,2957,2958,3996,1287,1596,1861,3154, 358, 453, 736, 175, // 6550 - 478,1117, 905,1167,1097,7796,1853,1530,7797,1706,7798,2178,3472,2287,3695,3473, // 6566 -3577,4203,2092,4204,7799,3367,1193,2482,4205,1458,2190,2205,1862,1888,1421,3298, // 6582 -2918,3049,2179,3474, 595,2122,7800,3997,7801,7802,4206,1707,2636, 223,3696,1359, // 6598 - 751,3098, 183,3475,7803,2797,3003, 419,2369, 633, 704,3818,2389, 241,7804,7805, // 6614 -7806, 838,3004,3697,2272,2763,2454,3819,1938,2050,3998,1309,3099,2242,1181,7807, // 6630 -1136,2206,3820,2370,1446,4207,2305,4498,7808,7809,4208,1055,2605, 484,3698,7810, // 6646 -3999, 625,4209,2273,3368,1499,4210,4000,7811,4001,4211,3222,2274,2275,3476,7812, // 6662 -7813,2764, 808,2606,3699,3369,4002,4212,3100,2532, 526,3370,3821,4213, 955,7814, // 6678 -1620,4214,2637,2427,7815,1429,3700,1669,1831, 994, 928,7816,3578,1260,7817,7818, // 6694 -7819,1948,2288, 741,2919,1626,4215,2729,2455, 867,1184, 362,3371,1392,7820,7821, // 6710 -4003,4216,1770,1736,3223,2920,4499,4500,1928,2698,1459,1158,7822,3050,3372,2877, // 6726 -1292,1929,2506,2842,3701,1985,1187,2071,2014,2607,4217,7823,2566,2507,2169,3702, // 6742 -2483,3299,7824,3703,4501,7825,7826, 666,1003,3005,1022,3579,4218,7827,4502,1813, // 6758 -2253, 574,3822,1603, 295,1535, 705,3823,4219, 283, 858, 417,7828,7829,3224,4503, // 6774 -4504,3051,1220,1889,1046,2276,2456,4004,1393,1599, 689,2567, 388,4220,7830,2484, // 6790 - 802,7831,2798,3824,2060,1405,2254,7832,4505,3825,2109,1052,1345,3225,1585,7833, // 6806 - 809,7834,7835,7836, 575,2730,3477, 956,1552,1469,1144,2323,7837,2324,1560,2457, // 6822 -3580,3226,4005, 616,2207,3155,2180,2289,7838,1832,7839,3478,4506,7840,1319,3704, // 6838 -3705,1211,3581,1023,3227,1293,2799,7841,7842,7843,3826, 607,2306,3827, 762,2878, // 6854 -1439,4221,1360,7844,1485,3052,7845,4507,1038,4222,1450,2061,2638,4223,1379,4508, // 6870 -2585,7846,7847,4224,1352,1414,2325,2921,1172,7848,7849,3828,3829,7850,1797,1451, // 6886 -7851,7852,7853,7854,2922,4006,4007,2485,2346, 411,4008,4009,3582,3300,3101,4509, // 6902 -1561,2664,1452,4010,1375,7855,7856, 47,2959, 316,7857,1406,1591,2923,3156,7858, // 6918 -1025,2141,3102,3157, 354,2731, 884,2224,4225,2407, 508,3706, 726,3583, 996,2428, // 6934 -3584, 729,7859, 392,2191,1453,4011,4510,3707,7860,7861,2458,3585,2608,1675,2800, // 6950 - 919,2347,2960,2348,1270,4511,4012, 73,7862,7863, 647,7864,3228,2843,2255,1550, // 6966 -1346,3006,7865,1332, 883,3479,7866,7867,7868,7869,3301,2765,7870,1212, 831,1347, // 6982 -4226,4512,2326,3830,1863,3053, 720,3831,4513,4514,3832,7871,4227,7872,7873,4515, // 6998 -7874,7875,1798,4516,3708,2609,4517,3586,1645,2371,7876,7877,2924, 669,2208,2665, // 7014 -2429,7878,2879,7879,7880,1028,3229,7881,4228,2408,7882,2256,1353,7883,7884,4518, // 7030 -3158, 518,7885,4013,7886,4229,1960,7887,2142,4230,7888,7889,3007,2349,2350,3833, // 7046 - 516,1833,1454,4014,2699,4231,4519,2225,2610,1971,1129,3587,7890,2766,7891,2961, // 7062 -1422, 577,1470,3008,1524,3373,7892,7893, 432,4232,3054,3480,7894,2586,1455,2508, // 7078 -2226,1972,1175,7895,1020,2732,4015,3481,4520,7896,2733,7897,1743,1361,3055,3482, // 7094 -2639,4016,4233,4521,2290, 895, 924,4234,2170, 331,2243,3056, 166,1627,3057,1098, // 7110 -7898,1232,2880,2227,3374,4522, 657, 403,1196,2372, 542,3709,3375,1600,4235,3483, // 7126 -7899,4523,2767,3230, 576, 530,1362,7900,4524,2533,2666,3710,4017,7901, 842,3834, // 7142 -7902,2801,2031,1014,4018, 213,2700,3376, 665, 621,4236,7903,3711,2925,2430,7904, // 7158 -2431,3302,3588,3377,7905,4237,2534,4238,4525,3589,1682,4239,3484,1380,7906, 724, // 7174 -2277, 600,1670,7907,1337,1233,4526,3103,2244,7908,1621,4527,7909, 651,4240,7910, // 7190 -1612,4241,2611,7911,2844,7912,2734,2307,3058,7913, 716,2459,3059, 174,1255,2701, // 7206 -4019,3590, 548,1320,1398, 728,4020,1574,7914,1890,1197,3060,4021,7915,3061,3062, // 7222 -3712,3591,3713, 747,7916, 635,4242,4528,7917,7918,7919,4243,7920,7921,4529,7922, // 7238 -3378,4530,2432, 451,7923,3714,2535,2072,4244,2735,4245,4022,7924,1764,4531,7925, // 7254 -4246, 350,7926,2278,2390,2486,7927,4247,4023,2245,1434,4024, 488,4532, 458,4248, // 7270 -4025,3715, 771,1330,2391,3835,2568,3159,2159,2409,1553,2667,3160,4249,7928,2487, // 7286 -2881,2612,1720,2702,4250,3379,4533,7929,2536,4251,7930,3231,4252,2768,7931,2015, // 7302 -2736,7932,1155,1017,3716,3836,7933,3303,2308, 201,1864,4253,1430,7934,4026,7935, // 7318 -7936,7937,7938,7939,4254,1604,7940, 414,1865, 371,2587,4534,4535,3485,2016,3104, // 7334 -4536,1708, 960,4255, 887, 389,2171,1536,1663,1721,7941,2228,4027,2351,2926,1580, // 7350 -7942,7943,7944,1744,7945,2537,4537,4538,7946,4539,7947,2073,7948,7949,3592,3380, // 7366 -2882,4256,7950,4257,2640,3381,2802, 673,2703,2460, 709,3486,4028,3593,4258,7951, // 7382 -1148, 502, 634,7952,7953,1204,4540,3594,1575,4541,2613,3717,7954,3718,3105, 948, // 7398 -3232, 121,1745,3837,1110,7955,4259,3063,2509,3009,4029,3719,1151,1771,3838,1488, // 7414 -4030,1986,7956,2433,3487,7957,7958,2093,7959,4260,3839,1213,1407,2803, 531,2737, // 7430 -2538,3233,1011,1537,7960,2769,4261,3106,1061,7961,3720,3721,1866,2883,7962,2017, // 7446 - 120,4262,4263,2062,3595,3234,2309,3840,2668,3382,1954,4542,7963,7964,3488,1047, // 7462 -2704,1266,7965,1368,4543,2845, 649,3383,3841,2539,2738,1102,2846,2669,7966,7967, // 7478 -1999,7968,1111,3596,2962,7969,2488,3842,3597,2804,1854,3384,3722,7970,7971,3385, // 7494 -2410,2884,3304,3235,3598,7972,2569,7973,3599,2805,4031,1460, 856,7974,3600,7975, // 7510 -2885,2963,7976,2886,3843,7977,4264, 632,2510, 875,3844,1697,3845,2291,7978,7979, // 7526 -4544,3010,1239, 580,4545,4265,7980, 914, 936,2074,1190,4032,1039,2123,7981,7982, // 7542 -7983,3386,1473,7984,1354,4266,3846,7985,2172,3064,4033, 915,3305,4267,4268,3306, // 7558 -1605,1834,7986,2739, 398,3601,4269,3847,4034, 328,1912,2847,4035,3848,1331,4270, // 7574 -3011, 937,4271,7987,3602,4036,4037,3387,2160,4546,3388, 524, 742, 538,3065,1012, // 7590 -7988,7989,3849,2461,7990, 658,1103, 225,3850,7991,7992,4547,7993,4548,7994,3236, // 7606 -1243,7995,4038, 963,2246,4549,7996,2705,3603,3161,7997,7998,2588,2327,7999,4550, // 7622 -8000,8001,8002,3489,3307, 957,3389,2540,2032,1930,2927,2462, 870,2018,3604,1746, // 7638 -2770,2771,2434,2463,8003,3851,8004,3723,3107,3724,3490,3390,3725,8005,1179,3066, // 7654 -8006,3162,2373,4272,3726,2541,3163,3108,2740,4039,8007,3391,1556,2542,2292, 977, // 7670 -2887,2033,4040,1205,3392,8008,1765,3393,3164,2124,1271,1689, 714,4551,3491,8009, // 7686 -2328,3852, 533,4273,3605,2181, 617,8010,2464,3308,3492,2310,8011,8012,3165,8013, // 7702 -8014,3853,1987, 618, 427,2641,3493,3394,8015,8016,1244,1690,8017,2806,4274,4552, // 7718 -8018,3494,8019,8020,2279,1576, 473,3606,4275,3395, 972,8021,3607,8022,3067,8023, // 7734 -8024,4553,4554,8025,3727,4041,4042,8026, 153,4555, 356,8027,1891,2888,4276,2143, // 7750 - 408, 803,2352,8028,3854,8029,4277,1646,2570,2511,4556,4557,3855,8030,3856,4278, // 7766 -8031,2411,3396, 752,8032,8033,1961,2964,8034, 746,3012,2465,8035,4279,3728, 698, // 7782 -4558,1892,4280,3608,2543,4559,3609,3857,8036,3166,3397,8037,1823,1302,4043,2706, // 7798 -3858,1973,4281,8038,4282,3167, 823,1303,1288,1236,2848,3495,4044,3398, 774,3859, // 7814 -8039,1581,4560,1304,2849,3860,4561,8040,2435,2161,1083,3237,4283,4045,4284, 344, // 7830 -1173, 288,2311, 454,1683,8041,8042,1461,4562,4046,2589,8043,8044,4563, 985, 894, // 7846 -8045,3399,3168,8046,1913,2928,3729,1988,8047,2110,1974,8048,4047,8049,2571,1194, // 7862 - 425,8050,4564,3169,1245,3730,4285,8051,8052,2850,8053, 636,4565,1855,3861, 760, // 7878 -1799,8054,4286,2209,1508,4566,4048,1893,1684,2293,8055,8056,8057,4287,4288,2210, // 7894 - 479,8058,8059, 832,8060,4049,2489,8061,2965,2490,3731, 990,3109, 627,1814,2642, // 7910 -4289,1582,4290,2125,2111,3496,4567,8062, 799,4291,3170,8063,4568,2112,1737,3013, // 7926 -1018, 543, 754,4292,3309,1676,4569,4570,4050,8064,1489,8065,3497,8066,2614,2889, // 7942 -4051,8067,8068,2966,8069,8070,8071,8072,3171,4571,4572,2182,1722,8073,3238,3239, // 7958 -1842,3610,1715, 481, 365,1975,1856,8074,8075,1962,2491,4573,8076,2126,3611,3240, // 7974 - 433,1894,2063,2075,8077, 602,2741,8078,8079,8080,8081,8082,3014,1628,3400,8083, // 7990 -3172,4574,4052,2890,4575,2512,8084,2544,2772,8085,8086,8087,3310,4576,2891,8088, // 8006 -4577,8089,2851,4578,4579,1221,2967,4053,2513,8090,8091,8092,1867,1989,8093,8094, // 8022 -8095,1895,8096,8097,4580,1896,4054, 318,8098,2094,4055,4293,8099,8100, 485,8101, // 8038 - 938,3862, 553,2670, 116,8102,3863,3612,8103,3498,2671,2773,3401,3311,2807,8104, // 8054 -3613,2929,4056,1747,2930,2968,8105,8106, 207,8107,8108,2672,4581,2514,8109,3015, // 8070 - 890,3614,3864,8110,1877,3732,3402,8111,2183,2353,3403,1652,8112,8113,8114, 941, // 8086 -2294, 208,3499,4057,2019, 330,4294,3865,2892,2492,3733,4295,8115,8116,8117,8118, // 8102 - -/*************************************************************************************** - *Everything below is of no interest for detection purpose * - *************************************************************************************** - -2515,1613,4582,8119,3312,3866,2516,8120,4058,8121,1637,4059,2466,4583,3867,8122, // 8118 -2493,3016,3734,8123,8124,2192,8125,8126,2162,8127,8128,8129,8130,8131,8132,8133, // 8134 -8134,8135,8136,8137,8138,8139,8140,8141,8142,8143,8144,8145,8146,8147,8148,8149, // 8150 -8150,8151,8152,8153,8154,8155,8156,8157,8158,8159,8160,8161,8162,8163,8164,8165, // 8166 -8166,8167,8168,8169,8170,8171,8172,8173,8174,8175,8176,8177,8178,8179,8180,8181, // 8182 -8182,8183,8184,8185,8186,8187,8188,8189,8190,8191,8192,8193,8194,8195,8196,8197, // 8198 -8198,8199,8200,8201,8202,8203,8204,8205,8206,8207,8208,8209,8210,8211,8212,8213, // 8214 -8214,8215,8216,8217,8218,8219,8220,8221,8222,8223,8224,8225,8226,8227,8228,8229, // 8230 -8230,8231,8232,8233,8234,8235,8236,8237,8238,8239,8240,8241,8242,8243,8244,8245, // 8246 -8246,8247,8248,8249,8250,8251,8252,8253,8254,8255,8256,8257,8258,8259,8260,8261, // 8262 -8262,8263,8264,8265,8266,8267,8268,8269,8270,8271,8272,8273,8274,8275,8276,8277, // 8278 -8278,8279,8280,8281,8282,8283,8284,8285,8286,8287,8288,8289,8290,8291,8292,8293, // 8294 -8294,8295,8296,8297,8298,8299,8300,8301,8302,8303,8304,8305,8306,8307,8308,8309, // 8310 -8310,8311,8312,8313,8314,8315,8316,8317,8318,8319,8320,8321,8322,8323,8324,8325, // 8326 -8326,8327,8328,8329,8330,8331,8332,8333,8334,8335,8336,8337,8338,8339,8340,8341, // 8342 -8342,8343,8344,8345,8346,8347,8348,8349,8350,8351,8352,8353,8354,8355,8356,8357, // 8358 -8358,8359,8360,8361,8362,8363,8364,8365,8366,8367,8368,8369,8370,8371,8372,8373, // 8374 -8374,8375,8376,8377,8378,8379,8380,8381,8382,8383,8384,8385,8386,8387,8388,8389, // 8390 -8390,8391,8392,8393,8394,8395,8396,8397,8398,8399,8400,8401,8402,8403,8404,8405, // 8406 -8406,8407,8408,8409,8410,8411,8412,8413,8414,8415,8416,8417,8418,8419,8420,8421, // 8422 -8422,8423,8424,8425,8426,8427,8428,8429,8430,8431,8432,8433,8434,8435,8436,8437, // 8438 -8438,8439,8440,8441,8442,8443,8444,8445,8446,8447,8448,8449,8450,8451,8452,8453, // 8454 -8454,8455,8456,8457,8458,8459,8460,8461,8462,8463,8464,8465,8466,8467,8468,8469, // 8470 -8470,8471,8472,8473,8474,8475,8476,8477,8478,8479,8480,8481,8482,8483,8484,8485, // 8486 -8486,8487,8488,8489,8490,8491,8492,8493,8494,8495,8496,8497,8498,8499,8500,8501, // 8502 -8502,8503,8504,8505,8506,8507,8508,8509,8510,8511,8512,8513,8514,8515,8516,8517, // 8518 -8518,8519,8520,8521,8522,8523,8524,8525,8526,8527,8528,8529,8530,8531,8532,8533, // 8534 -8534,8535,8536,8537,8538,8539,8540,8541,8542,8543,8544,8545,8546,8547,8548,8549, // 8550 -8550,8551,8552,8553,8554,8555,8556,8557,8558,8559,8560,8561,8562,8563,8564,8565, // 8566 -8566,8567,8568,8569,8570,8571,8572,8573,8574,8575,8576,8577,8578,8579,8580,8581, // 8582 -8582,8583,8584,8585,8586,8587,8588,8589,8590,8591,8592,8593,8594,8595,8596,8597, // 8598 -8598,8599,8600,8601,8602,8603,8604,8605,8606,8607,8608,8609,8610,8611,8612,8613, // 8614 -8614,8615,8616,8617,8618,8619,8620,8621,8622,8623,8624,8625,8626,8627,8628,8629, // 8630 -8630,8631,8632,8633,8634,8635,8636,8637,8638,8639,8640,8641,8642,8643,8644,8645, // 8646 -8646,8647,8648,8649,8650,8651,8652,8653,8654,8655,8656,8657,8658,8659,8660,8661, // 8662 -8662,8663,8664,8665,8666,8667,8668,8669,8670,8671,8672,8673,8674,8675,8676,8677, // 8678 -8678,8679,8680,8681,8682,8683,8684,8685,8686,8687,8688,8689,8690,8691,8692,8693, // 8694 -8694,8695,8696,8697,8698,8699,8700,8701,8702,8703,8704,8705,8706,8707,8708,8709, // 8710 -8710,8711,8712,8713,8714,8715,8716,8717,8718,8719,8720,8721,8722,8723,8724,8725, // 8726 -8726,8727,8728,8729,8730,8731,8732,8733,8734,8735,8736,8737,8738,8739,8740,8741, // 8742 //13973 -****************************************************************************************/ -}; - diff --git a/amarok/utilities/collectionscanner/charset-detector/src/tables/GB2312Freq.tab b/amarok/utilities/collectionscanner/charset-detector/src/tables/GB2312Freq.tab deleted file mode 100644 index aee12caa..00000000 --- a/amarok/utilities/collectionscanner/charset-detector/src/tables/GB2312Freq.tab +++ /dev/null @@ -1,491 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -//GB2312 most frequently used character table - -//Char to FreqOrder table , from hz6763 - -/****************************************************************************** - * 512 --> 0.79 -- 0.79 - * 1024 --> 0.92 -- 0.13 - * 2048 --> 0.98 -- 0.06 - * 6768 --> 1.00 -- 0.02 - * - * Idea Distribution Ratio = 0.79135/(1-0.79135) = 3.79 - * Random Distribution Ration = 512 / (3755 - 512) = 0.157 - * - * Typical Distribution Ratio about 25% of Ideal one, still much higher that RDR - *****************************************************************************/ - -#define GB2312_TYPICAL_DISTRIBUTION_RATIO (float)0.9 - -#define GB2312_TABLE_SIZE 3760 - -static const PRInt16 GB2312CharToFreqOrder[] = -{ -1671, 749,1443,2364,3924,3807,2330,3921,1704,3463,2691,1511,1515, 572,3191,2205, -2361, 224,2558, 479,1711, 963,3162, 440,4060,1905,2966,2947,3580,2647,3961,3842, -2204, 869,4207, 970,2678,5626,2944,2956,1479,4048, 514,3595, 588,1346,2820,3409, - 249,4088,1746,1873,2047,1774, 581,1813, 358,1174,3590,1014,1561,4844,2245, 670, -1636,3112, 889,1286, 953, 556,2327,3060,1290,3141, 613, 185,3477,1367, 850,3820, -1715,2428,2642,2303,2732,3041,2562,2648,3566,3946,1349, 388,3098,2091,1360,3585, - 152,1687,1539, 738,1559, 59,1232,2925,2267,1388,1249,1741,1679,2960, 151,1566, -1125,1352,4271, 924,4296, 385,3166,4459, 310,1245,2850, 70,3285,2729,3534,3575, -2398,3298,3466,1960,2265, 217,3647, 864,1909,2084,4401,2773,1010,3269,5152, 853, -3051,3121,1244,4251,1895, 364,1499,1540,2313,1180,3655,2268, 562, 715,2417,3061, - 544, 336,3768,2380,1752,4075, 950, 280,2425,4382, 183,2759,3272, 333,4297,2155, -1688,2356,1444,1039,4540, 736,1177,3349,2443,2368,2144,2225, 565, 196,1482,3406, - 927,1335,4147, 692, 878,1311,1653,3911,3622,1378,4200,1840,2969,3149,2126,1816, -2534,1546,2393,2760, 737,2494, 13, 447, 245,2747, 38,2765,2129,2589,1079, 606, - 360, 471,3755,2890, 404, 848, 699,1785,1236, 370,2221,1023,3746,2074,2026,2023, -2388,1581,2119, 812,1141,3091,2536,1519, 804,2053, 406,1596,1090, 784, 548,4414, -1806,2264,2936,1100, 343,4114,5096, 622,3358, 743,3668,1510,1626,5020,3567,2513, -3195,4115,5627,2489,2991, 24,2065,2697,1087,2719, 48,1634, 315, 68, 985,2052, - 198,2239,1347,1107,1439, 597,2366,2172, 871,3307, 919,2487,2790,1867, 236,2570, -1413,3794, 906,3365,3381,1701,1982,1818,1524,2924,1205, 616,2586,2072,2004, 575, - 253,3099, 32,1365,1182, 197,1714,2454,1201, 554,3388,3224,2748, 756,2587, 250, -2567,1507,1517,3529,1922,2761,2337,3416,1961,1677,2452,2238,3153, 615, 911,1506, -1474,2495,1265,1906,2749,3756,3280,2161, 898,2714,1759,3450,2243,2444, 563, 26, -3286,2266,3769,3344,2707,3677, 611,1402, 531,1028,2871,4548,1375, 261,2948, 835, -1190,4134, 353, 840,2684,1900,3082,1435,2109,1207,1674, 329,1872,2781,4055,2686, -2104, 608,3318,2423,2957,2768,1108,3739,3512,3271,3985,2203,1771,3520,1418,2054, -1681,1153, 225,1627,2929, 162,2050,2511,3687,1954, 124,1859,2431,1684,3032,2894, - 585,4805,3969,2869,2704,2088,2032,2095,3656,2635,4362,2209, 256, 518,2042,2105, -3777,3657, 643,2298,1148,1779, 190, 989,3544, 414, 11,2135,2063,2979,1471, 403, -3678, 126, 770,1563, 671,2499,3216,2877, 600,1179, 307,2805,4937,1268,1297,2694, - 252,4032,1448,1494,1331,1394, 127,2256, 222,1647,1035,1481,3056,1915,1048, 873, -3651, 210, 33,1608,2516, 200,1520, 415, 102, 0,3389,1287, 817, 91,3299,2940, - 836,1814, 549,2197,1396,1669,2987,3582,2297,2848,4528,1070, 687, 20,1819, 121, -1552,1364,1461,1968,2617,3540,2824,2083, 177, 948,4938,2291, 110,4549,2066, 648, -3359,1755,2110,2114,4642,4845,1693,3937,3308,1257,1869,2123, 208,1804,3159,2992, -2531,2549,3361,2418,1350,2347,2800,2568,1291,2036,2680, 72, 842,1990, 212,1233, -1154,1586, 75,2027,3410,4900,1823,1337,2710,2676, 728,2810,1522,3026,4995, 157, - 755,1050,4022, 710, 785,1936,2194,2085,1406,2777,2400, 150,1250,4049,1206, 807, -1910, 534, 529,3309,1721,1660, 274, 39,2827, 661,2670,1578, 925,3248,3815,1094, -4278,4901,4252, 41,1150,3747,2572,2227,4501,3658,4902,3813,3357,3617,2884,2258, - 887, 538,4187,3199,1294,2439,3042,2329,2343,2497,1255, 107, 543,1527, 521,3478, -3568, 194,5062, 15, 961,3870,1241,1192,2664, 66,5215,3260,2111,1295,1127,2152, -3805,4135, 901,1164,1976, 398,1278, 530,1460, 748, 904,1054,1966,1426, 53,2909, - 509, 523,2279,1534, 536,1019, 239,1685, 460,2353, 673,1065,2401,3600,4298,2272, -1272,2363, 284,1753,3679,4064,1695, 81, 815,2677,2757,2731,1386, 859, 500,4221, -2190,2566, 757,1006,2519,2068,1166,1455, 337,2654,3203,1863,1682,1914,3025,1252, -1409,1366, 847, 714,2834,2038,3209, 964,2970,1901, 885,2553,1078,1756,3049, 301, -1572,3326, 688,2130,1996,2429,1805,1648,2930,3421,2750,3652,3088, 262,1158,1254, - 389,1641,1812, 526,1719, 923,2073,1073,1902, 468, 489,4625,1140, 857,2375,3070, -3319,2863, 380, 116,1328,2693,1161,2244, 273,1212,1884,2769,3011,1775,1142, 461, -3066,1200,2147,2212, 790, 702,2695,4222,1601,1058, 434,2338,5153,3640, 67,2360, -4099,2502, 618,3472,1329, 416,1132, 830,2782,1807,2653,3211,3510,1662, 192,2124, - 296,3979,1739,1611,3684, 23, 118, 324, 446,1239,1225, 293,2520,3814,3795,2535, -3116, 17,1074, 467,2692,2201, 387,2922, 45,1326,3055,1645,3659,2817, 958, 243, -1903,2320,1339,2825,1784,3289, 356, 576, 865,2315,2381,3377,3916,1088,3122,1713, -1655, 935, 628,4689,1034,1327, 441, 800, 720, 894,1979,2183,1528,5289,2702,1071, -4046,3572,2399,1571,3281, 79, 761,1103, 327, 134, 758,1899,1371,1615, 879, 442, - 215,2605,2579, 173,2048,2485,1057,2975,3317,1097,2253,3801,4263,1403,1650,2946, - 814,4968,3487,1548,2644,1567,1285, 2, 295,2636, 97, 946,3576, 832, 141,4257, -3273, 760,3821,3521,3156,2607, 949,1024,1733,1516,1803,1920,2125,2283,2665,3180, -1501,2064,3560,2171,1592, 803,3518,1416, 732,3897,4258,1363,1362,2458, 119,1427, - 602,1525,2608,1605,1639,3175, 694,3064, 10, 465, 76,2000,4846,4208, 444,3781, -1619,3353,2206,1273,3796, 740,2483, 320,1723,2377,3660,2619,1359,1137,1762,1724, -2345,2842,1850,1862, 912, 821,1866, 612,2625,1735,2573,3369,1093, 844, 89, 937, - 930,1424,3564,2413,2972,1004,3046,3019,2011, 711,3171,1452,4178, 428, 801,1943, - 432, 445,2811, 206,4136,1472, 730, 349, 73, 397,2802,2547, 998,1637,1167, 789, - 396,3217, 154,1218, 716,1120,1780,2819,4826,1931,3334,3762,2139,1215,2627, 552, -3664,3628,3232,1405,2383,3111,1356,2652,3577,3320,3101,1703, 640,1045,1370,1246, -4996, 371,1575,2436,1621,2210, 984,4033,1734,2638, 16,4529, 663,2755,3255,1451, -3917,2257,1253,1955,2234,1263,2951, 214,1229, 617, 485, 359,1831,1969, 473,2310, - 750,2058, 165, 80,2864,2419, 361,4344,2416,2479,1134, 796,3726,1266,2943, 860, -2715, 938, 390,2734,1313,1384, 248, 202, 877,1064,2854, 522,3907, 279,1602, 297, -2357, 395,3740, 137,2075, 944,4089,2584,1267,3802, 62,1533,2285, 178, 176, 780, -2440, 201,3707, 590, 478,1560,4354,2117,1075, 30, 74,4643,4004,1635,1441,2745, - 776,2596, 238,1077,1692,1912,2844, 605, 499,1742,3947, 241,3053, 980,1749, 936, -2640,4511,2582, 515,1543,2162,5322,2892,2993, 890,2148,1924, 665,1827,3581,1032, - 968,3163, 339,1044,1896, 270, 583,1791,1720,4367,1194,3488,3669, 43,2523,1657, - 163,2167, 290,1209,1622,3378, 550, 634,2508,2510, 695,2634,2384,2512,1476,1414, - 220,1469,2341,2138,2852,3183,2900,4939,2865,3502,1211,3680, 854,3227,1299,2976, -3172, 186,2998,1459, 443,1067,3251,1495, 321,1932,3054, 909, 753,1410,1828, 436, -2441,1119,1587,3164,2186,1258, 227, 231,1425,1890,3200,3942, 247, 959, 725,5254, -2741, 577,2158,2079, 929, 120, 174, 838,2813, 591,1115, 417,2024, 40,3240,1536, -1037, 291,4151,2354, 632,1298,2406,2500,3535,1825,1846,3451, 205,1171, 345,4238, - 18,1163, 811, 685,2208,1217, 425,1312,1508,1175,4308,2552,1033, 587,1381,3059, -2984,3482, 340,1316,4023,3972, 792,3176, 519, 777,4690, 918, 933,4130,2981,3741, - 90,3360,2911,2200,5184,4550, 609,3079,2030, 272,3379,2736, 363,3881,1130,1447, - 286, 779, 357,1169,3350,3137,1630,1220,2687,2391, 747,1277,3688,2618,2682,2601, -1156,3196,5290,4034,3102,1689,3596,3128, 874, 219,2783, 798, 508,1843,2461, 269, -1658,1776,1392,1913,2983,3287,2866,2159,2372, 829,4076, 46,4253,2873,1889,1894, - 915,1834,1631,2181,2318, 298, 664,2818,3555,2735, 954,3228,3117, 527,3511,2173, - 681,2712,3033,2247,2346,3467,1652, 155,2164,3382, 113,1994, 450, 899, 494, 994, -1237,2958,1875,2336,1926,3727, 545,1577,1550, 633,3473, 204,1305,3072,2410,1956, -2471, 707,2134, 841,2195,2196,2663,3843,1026,4940, 990,3252,4997, 368,1092, 437, -3212,3258,1933,1829, 675,2977,2893, 412, 943,3723,4644,3294,3283,2230,2373,5154, -2389,2241,2661,2323,1404,2524, 593, 787, 677,3008,1275,2059, 438,2709,2609,2240, -2269,2246,1446, 36,1568,1373,3892,1574,2301,1456,3962, 693,2276,5216,2035,1143, -2720,1919,1797,1811,2763,4137,2597,1830,1699,1488,1198,2090, 424,1694, 312,3634, -3390,4179,3335,2252,1214, 561,1059,3243,2295,2561, 975,5155,2321,2751,3772, 472, -1537,3282,3398,1047,2077,2348,2878,1323,3340,3076, 690,2906, 51, 369, 170,3541, -1060,2187,2688,3670,2541,1083,1683, 928,3918, 459, 109,4427, 599,3744,4286, 143, -2101,2730,2490, 82,1588,3036,2121, 281,1860, 477,4035,1238,2812,3020,2716,3312, -1530,2188,2055,1317, 843, 636,1808,1173,3495, 649, 181,1002, 147,3641,1159,2414, -3750,2289,2795, 813,3123,2610,1136,4368, 5,3391,4541,2174, 420, 429,1728, 754, -1228,2115,2219, 347,2223,2733, 735,1518,3003,2355,3134,1764,3948,3329,1888,2424, -1001,1234,1972,3321,3363,1672,1021,1450,1584, 226, 765, 655,2526,3404,3244,2302, -3665, 731, 594,2184, 319,1576, 621, 658,2656,4299,2099,3864,1279,2071,2598,2739, - 795,3086,3699,3908,1707,2352,2402,1382,3136,2475,1465,4847,3496,3865,1085,3004, -2591,1084, 213,2287,1963,3565,2250, 822, 793,4574,3187,1772,1789,3050, 595,1484, -1959,2770,1080,2650, 456, 422,2996, 940,3322,4328,4345,3092,2742, 965,2784, 739, -4124, 952,1358,2498,2949,2565, 332,2698,2378, 660,2260,2473,4194,3856,2919, 535, -1260,2651,1208,1428,1300,1949,1303,2942, 433,2455,2450,1251,1946, 614,1269, 641, -1306,1810,2737,3078,2912, 564,2365,1419,1415,1497,4460,2367,2185,1379,3005,1307, -3218,2175,1897,3063, 682,1157,4040,4005,1712,1160,1941,1399, 394, 402,2952,1573, -1151,2986,2404, 862, 299,2033,1489,3006, 346, 171,2886,3401,1726,2932, 168,2533, - 47,2507,1030,3735,1145,3370,1395,1318,1579,3609,4560,2857,4116,1457,2529,1965, - 504,1036,2690,2988,2405, 745,5871, 849,2397,2056,3081, 863,2359,3857,2096, 99, -1397,1769,2300,4428,1643,3455,1978,1757,3718,1440, 35,4879,3742,1296,4228,2280, - 160,5063,1599,2013, 166, 520,3479,1646,3345,3012, 490,1937,1545,1264,2182,2505, -1096,1188,1369,1436,2421,1667,2792,2460,1270,2122, 727,3167,2143, 806,1706,1012, -1800,3037, 960,2218,1882, 805, 139,2456,1139,1521, 851,1052,3093,3089, 342,2039, - 744,5097,1468,1502,1585,2087, 223, 939, 326,2140,2577, 892,2481,1623,4077, 982, -3708, 135,2131, 87,2503,3114,2326,1106, 876,1616, 547,2997,2831,2093,3441,4530, -4314, 9,3256,4229,4148, 659,1462,1986,1710,2046,2913,2231,4090,4880,5255,3392, -3274,1368,3689,4645,1477, 705,3384,3635,1068,1529,2941,1458,3782,1509, 100,1656, -2548, 718,2339, 408,1590,2780,3548,1838,4117,3719,1345,3530, 717,3442,2778,3220, -2898,1892,4590,3614,3371,2043,1998,1224,3483, 891, 635, 584,2559,3355, 733,1766, -1729,1172,3789,1891,2307, 781,2982,2271,1957,1580,5773,2633,2005,4195,3097,1535, -3213,1189,1934,5693,3262, 586,3118,1324,1598, 517,1564,2217,1868,1893,4445,3728, -2703,3139,1526,1787,1992,3882,2875,1549,1199,1056,2224,1904,2711,5098,4287, 338, -1993,3129,3489,2689,1809,2815,1997, 957,1855,3898,2550,3275,3057,1105,1319, 627, -1505,1911,1883,3526, 698,3629,3456,1833,1431, 746, 77,1261,2017,2296,1977,1885, - 125,1334,1600, 525,1798,1109,2222,1470,1945, 559,2236,1186,3443,2476,1929,1411, -2411,3135,1777,3372,2621,1841,1613,3229, 668,1430,1839,2643,2916, 195,1989,2671, -2358,1387, 629,3205,2293,5256,4439, 123,1310, 888,1879,4300,3021,3605,1003,1162, -3192,2910,2010, 140,2395,2859, 55,1082,2012,2901, 662, 419,2081,1438, 680,2774, -4654,3912,1620,1731,1625,5035,4065,2328, 512,1344, 802,5443,2163,2311,2537, 524, -3399, 98,1155,2103,1918,2606,3925,2816,1393,2465,1504,3773,2177,3963,1478,4346, - 180,1113,4655,3461,2028,1698, 833,2696,1235,1322,1594,4408,3623,3013,3225,2040, -3022, 541,2881, 607,3632,2029,1665,1219, 639,1385,1686,1099,2803,3231,1938,3188, -2858, 427, 676,2772,1168,2025, 454,3253,2486,3556, 230,1950, 580, 791,1991,1280, -1086,1974,2034, 630, 257,3338,2788,4903,1017, 86,4790, 966,2789,1995,1696,1131, - 259,3095,4188,1308, 179,1463,5257, 289,4107,1248, 42,3413,1725,2288, 896,1947, - 774,4474,4254, 604,3430,4264, 392,2514,2588, 452, 237,1408,3018, 988,4531,1970, -3034,3310, 540,2370,1562,1288,2990, 502,4765,1147, 4,1853,2708, 207, 294,2814, -4078,2902,2509, 684, 34,3105,3532,2551, 644, 709,2801,2344, 573,1727,3573,3557, -2021,1081,3100,4315,2100,3681, 199,2263,1837,2385, 146,3484,1195,2776,3949, 997, -1939,3973,1008,1091,1202,1962,1847,1149,4209,5444,1076, 493, 117,5400,2521, 972, -1490,2934,1796,4542,2374,1512,2933,2657, 413,2888,1135,2762,2314,2156,1355,2369, - 766,2007,2527,2170,3124,2491,2593,2632,4757,2437, 234,3125,3591,1898,1750,1376, -1942,3468,3138, 570,2127,2145,3276,4131, 962, 132,1445,4196, 19, 941,3624,3480, -3366,1973,1374,4461,3431,2629, 283,2415,2275, 808,2887,3620,2112,2563,1353,3610, - 955,1089,3103,1053, 96, 88,4097, 823,3808,1583, 399, 292,4091,3313, 421,1128, - 642,4006, 903,2539,1877,2082, 596, 29,4066,1790, 722,2157, 130, 995,1569, 769, -1485, 464, 513,2213, 288,1923,1101,2453,4316, 133, 486,2445, 50, 625, 487,2207, - 57, 423, 481,2962, 159,3729,1558, 491, 303, 482, 501, 240,2837, 112,3648,2392, -1783, 362, 8,3433,3422, 610,2793,3277,1390,1284,1654, 21,3823, 734, 367, 623, - 193, 287, 374,1009,1483, 816, 476, 313,2255,2340,1262,2150,2899,1146,2581, 782, -2116,1659,2018,1880, 255,3586,3314,1110,2867,2137,2564, 986,2767,5185,2006, 650, - 158, 926, 762, 881,3157,2717,2362,3587, 306,3690,3245,1542,3077,2427,1691,2478, -2118,2985,3490,2438, 539,2305, 983, 129,1754, 355,4201,2386, 827,2923, 104,1773, -2838,2771, 411,2905,3919, 376, 767, 122,1114, 828,2422,1817,3506, 266,3460,1007, -1609,4998, 945,2612,4429,2274, 726,1247,1964,2914,2199,2070,4002,4108, 657,3323, -1422, 579, 455,2764,4737,1222,2895,1670, 824,1223,1487,2525, 558, 861,3080, 598, -2659,2515,1967, 752,2583,2376,2214,4180, 977, 704,2464,4999,2622,4109,1210,2961, - 819,1541, 142,2284, 44, 418, 457,1126,3730,4347,4626,1644,1876,3671,1864, 302, -1063,5694, 624, 723,1984,3745,1314,1676,2488,1610,1449,3558,3569,2166,2098, 409, -1011,2325,3704,2306, 818,1732,1383,1824,1844,3757, 999,2705,3497,1216,1423,2683, -2426,2954,2501,2726,2229,1475,2554,5064,1971,1794,1666,2014,1343, 783, 724, 191, -2434,1354,2220,5065,1763,2752,2472,4152, 131, 175,2885,3434, 92,1466,4920,2616, -3871,3872,3866, 128,1551,1632, 669,1854,3682,4691,4125,1230, 188,2973,3290,1302, -1213, 560,3266, 917, 763,3909,3249,1760, 868,1958, 764,1782,2097, 145,2277,3774, -4462, 64,1491,3062, 971,2132,3606,2442, 221,1226,1617, 218, 323,1185,3207,3147, - 571, 619,1473,1005,1744,2281, 449,1887,2396,3685, 275, 375,3816,1743,3844,3731, - 845,1983,2350,4210,1377, 773, 967,3499,3052,3743,2725,4007,1697,1022,3943,1464, -3264,2855,2722,1952,1029,2839,2467, 84,4383,2215, 820,1391,2015,2448,3672, 377, -1948,2168, 797,2545,3536,2578,2645, 94,2874,1678, 405,1259,3071, 771, 546,1315, - 470,1243,3083, 895,2468, 981, 969,2037, 846,4181, 653,1276,2928, 14,2594, 557, -3007,2474, 156, 902,1338,1740,2574, 537,2518, 973,2282,2216,2433,1928, 138,2903, -1293,2631,1612, 646,3457, 839,2935, 111, 496,2191,2847, 589,3186, 149,3994,2060, -4031,2641,4067,3145,1870, 37,3597,2136,1025,2051,3009,3383,3549,1121,1016,3261, -1301, 251,2446,2599,2153, 872,3246, 637, 334,3705, 831, 884, 921,3065,3140,4092, -2198,1944, 246,2964, 108,2045,1152,1921,2308,1031, 203,3173,4170,1907,3890, 810, -1401,2003,1690, 506, 647,1242,2828,1761,1649,3208,2249,1589,3709,2931,5156,1708, - 498, 666,2613, 834,3817,1231, 184,2851,1124, 883,3197,2261,3710,1765,1553,2658, -1178,2639,2351, 93,1193, 942,2538,2141,4402, 235,1821, 870,1591,2192,1709,1871, -3341,1618,4126,2595,2334, 603, 651, 69, 701, 268,2662,3411,2555,1380,1606, 503, - 448, 254,2371,2646, 574,1187,2309,1770, 322,2235,1292,1801, 305, 566,1133, 229, -2067,2057, 706, 167, 483,2002,2672,3295,1820,3561,3067, 316, 378,2746,3452,1112, - 136,1981, 507,1651,2917,1117, 285,4591, 182,2580,3522,1304, 335,3303,1835,2504, -1795,1792,2248, 674,1018,2106,2449,1857,2292,2845, 976,3047,1781,2600,2727,1389, -1281, 52,3152, 153, 265,3950, 672,3485,3951,4463, 430,1183, 365, 278,2169, 27, -1407,1336,2304, 209,1340,1730,2202,1852,2403,2883, 979,1737,1062, 631,2829,2542, -3876,2592, 825,2086,2226,3048,3625, 352,1417,3724, 542, 991, 431,1351,3938,1861, -2294, 826,1361,2927,3142,3503,1738, 463,2462,2723, 582,1916,1595,2808, 400,3845, -3891,2868,3621,2254, 58,2492,1123, 910,2160,2614,1372,1603,1196,1072,3385,1700, -3267,1980, 696, 480,2430, 920, 799,1570,2920,1951,2041,4047,2540,1321,4223,2469, -3562,2228,1271,2602, 401,2833,3351,2575,5157, 907,2312,1256, 410, 263,3507,1582, - 996, 678,1849,2316,1480, 908,3545,2237, 703,2322, 667,1826,2849,1531,2604,2999, -2407,3146,2151,2630,1786,3711, 469,3542, 497,3899,2409, 858, 837,4446,3393,1274, - 786, 620,1845,2001,3311, 484, 308,3367,1204,1815,3691,2332,1532,2557,1842,2020, -2724,1927,2333,4440, 567, 22,1673,2728,4475,1987,1858,1144,1597, 101,1832,3601, - 12, 974,3783,4391, 951,1412, 1,3720, 453,4608,4041, 528,1041,1027,3230,2628, -1129, 875,1051,3291,1203,2262,1069,2860,2799,2149,2615,3278, 144,1758,3040, 31, - 475,1680, 366,2685,3184, 311,1642,4008,2466,5036,1593,1493,2809, 216,1420,1668, - 233, 304,2128,3284, 232,1429,1768,1040,2008,3407,2740,2967,2543, 242,2133, 778, -1565,2022,2620, 505,2189,2756,1098,2273, 372,1614, 708, 553,2846,2094,2278, 169, -3626,2835,4161, 228,2674,3165, 809,1454,1309, 466,1705,1095, 900,3423, 880,2667, -3751,5258,2317,3109,2571,4317,2766,1503,1342, 866,4447,1118, 63,2076, 314,1881, -1348,1061, 172, 978,3515,1747, 532, 511,3970, 6, 601, 905,2699,3300,1751, 276, -1467,3725,2668, 65,4239,2544,2779,2556,1604, 578,2451,1802, 992,2331,2624,1320, -3446, 713,1513,1013, 103,2786,2447,1661, 886,1702, 916, 654,3574,2031,1556, 751, -2178,2821,2179,1498,1538,2176, 271, 914,2251,2080,1325, 638,1953,2937,3877,2432, -2754, 95,3265,1716, 260,1227,4083, 775, 106,1357,3254, 426,1607, 555,2480, 772, -1985, 244,2546, 474, 495,1046,2611,1851,2061, 71,2089,1675,2590, 742,3758,2843, -3222,1433, 267,2180,2576,2826,2233,2092,3913,2435, 956,1745,3075, 856,2113,1116, - 451, 3,1988,2896,1398, 993,2463,1878,2049,1341,2718,2721,2870,2108, 712,2904, -4363,2753,2324, 277,2872,2349,2649, 384, 987, 435, 691,3000, 922, 164,3939, 652, -1500,1184,4153,2482,3373,2165,4848,2335,3775,3508,3154,2806,2830,1554,2102,1664, -2530,1434,2408, 893,1547,2623,3447,2832,2242,2532,3169,2856,3223,2078, 49,3770, -3469, 462, 318, 656,2259,3250,3069, 679,1629,2758, 344,1138,1104,3120,1836,1283, -3115,2154,1437,4448, 934, 759,1999, 794,2862,1038, 533,2560,1722,2342, 855,2626, -1197,1663,4476,3127, 85,4240,2528, 25,1111,1181,3673, 407,3470,4561,2679,2713, - 768,1925,2841,3986,1544,1165, 932, 373,1240,2146,1930,2673, 721,4766, 354,4333, - 391,2963, 187, 61,3364,1442,1102, 330,1940,1767, 341,3809,4118, 393,2496,2062, -2211, 105, 331, 300, 439, 913,1332, 626, 379,3304,1557, 328, 689,3952, 309,1555, - 931, 317,2517,3027, 325, 569, 686,2107,3084, 60,1042,1333,2794, 264,3177,4014, -1628, 258,3712, 7,4464,1176,1043,1778, 683, 114,1975, 78,1492, 383,1886, 510, - 386, 645,5291,2891,2069,3305,4138,3867,2939,2603,2493,1935,1066,1848,3588,1015, -1282,1289,4609, 697,1453,3044,2666,3611,1856,2412, 54, 719,1330, 568,3778,2459, -1748, 788, 492, 551,1191,1000, 488,3394,3763, 282,1799, 348,2016,1523,3155,2390, -1049, 382,2019,1788,1170, 729,2968,3523, 897,3926,2785,2938,3292, 350,2319,3238, -1718,1717,2655,3453,3143,4465, 161,2889,2980,2009,1421, 56,1908,1640,2387,2232, -1917,1874,2477,4921, 148, 83,3438, 592,4245,2882,1822,1055, 741, 115,1496,1624, - 381,1638,4592,1020, 516,3214, 458, 947,4575,1432, 211,1514,2926,1865,2142, 189, - 852,1221,1400,1486, 882,2299,4036, 351, 28,1122, 700,6479,6480,6481,6482,6483, //last 512 - -/*************************************************************************************** - *Everything below is of no interest for detection purpose * - *************************************************************************************** - -5508,6484,3900,3414,3974,4441,4024,3537,4037,5628,5099,3633,6485,3148,6486,3636, -5509,3257,5510,5973,5445,5872,4941,4403,3174,4627,5873,6276,2286,4230,5446,5874, -5122,6102,6103,4162,5447,5123,5323,4849,6277,3980,3851,5066,4246,5774,5067,6278, -3001,2807,5695,3346,5775,5974,5158,5448,6487,5975,5976,5776,3598,6279,5696,4806, -4211,4154,6280,6488,6489,6490,6281,4212,5037,3374,4171,6491,4562,4807,4722,4827, -5977,6104,4532,4079,5159,5324,5160,4404,3858,5359,5875,3975,4288,4610,3486,4512, -5325,3893,5360,6282,6283,5560,2522,4231,5978,5186,5449,2569,3878,6284,5401,3578, -4415,6285,4656,5124,5979,2506,4247,4449,3219,3417,4334,4969,4329,6492,4576,4828, -4172,4416,4829,5402,6286,3927,3852,5361,4369,4830,4477,4867,5876,4173,6493,6105, -4657,6287,6106,5877,5450,6494,4155,4868,5451,3700,5629,4384,6288,6289,5878,3189, -4881,6107,6290,6495,4513,6496,4692,4515,4723,5100,3356,6497,6291,3810,4080,5561, -3570,4430,5980,6498,4355,5697,6499,4724,6108,6109,3764,4050,5038,5879,4093,3226, -6292,5068,5217,4693,3342,5630,3504,4831,4377,4466,4309,5698,4431,5777,6293,5778, -4272,3706,6110,5326,3752,4676,5327,4273,5403,4767,5631,6500,5699,5880,3475,5039, -6294,5562,5125,4348,4301,4482,4068,5126,4593,5700,3380,3462,5981,5563,3824,5404, -4970,5511,3825,4738,6295,6501,5452,4516,6111,5881,5564,6502,6296,5982,6503,4213, -4163,3454,6504,6112,4009,4450,6113,4658,6297,6114,3035,6505,6115,3995,4904,4739, -4563,4942,4110,5040,3661,3928,5362,3674,6506,5292,3612,4791,5565,4149,5983,5328, -5259,5021,4725,4577,4564,4517,4364,6298,5405,4578,5260,4594,4156,4157,5453,3592, -3491,6507,5127,5512,4709,4922,5984,5701,4726,4289,6508,4015,6116,5128,4628,3424, -4241,5779,6299,4905,6509,6510,5454,5702,5780,6300,4365,4923,3971,6511,5161,3270, -3158,5985,4100, 867,5129,5703,6117,5363,3695,3301,5513,4467,6118,6512,5455,4232, -4242,4629,6513,3959,4478,6514,5514,5329,5986,4850,5162,5566,3846,4694,6119,5456, -4869,5781,3779,6301,5704,5987,5515,4710,6302,5882,6120,4392,5364,5705,6515,6121, -6516,6517,3736,5988,5457,5989,4695,2457,5883,4551,5782,6303,6304,6305,5130,4971, -6122,5163,6123,4870,3263,5365,3150,4871,6518,6306,5783,5069,5706,3513,3498,4409, -5330,5632,5366,5458,5459,3991,5990,4502,3324,5991,5784,3696,4518,5633,4119,6519, -4630,5634,4417,5707,4832,5992,3418,6124,5993,5567,4768,5218,6520,4595,3458,5367, -6125,5635,6126,4202,6521,4740,4924,6307,3981,4069,4385,6308,3883,2675,4051,3834, -4302,4483,5568,5994,4972,4101,5368,6309,5164,5884,3922,6127,6522,6523,5261,5460, -5187,4164,5219,3538,5516,4111,3524,5995,6310,6311,5369,3181,3386,2484,5188,3464, -5569,3627,5708,6524,5406,5165,4677,4492,6312,4872,4851,5885,4468,5996,6313,5709, -5710,6128,2470,5886,6314,5293,4882,5785,3325,5461,5101,6129,5711,5786,6525,4906, -6526,6527,4418,5887,5712,4808,2907,3701,5713,5888,6528,3765,5636,5331,6529,6530, -3593,5889,3637,4943,3692,5714,5787,4925,6315,6130,5462,4405,6131,6132,6316,5262, -6531,6532,5715,3859,5716,5070,4696,5102,3929,5788,3987,4792,5997,6533,6534,3920, -4809,5000,5998,6535,2974,5370,6317,5189,5263,5717,3826,6536,3953,5001,4883,3190, -5463,5890,4973,5999,4741,6133,6134,3607,5570,6000,4711,3362,3630,4552,5041,6318, -6001,2950,2953,5637,4646,5371,4944,6002,2044,4120,3429,6319,6537,5103,4833,6538, -6539,4884,4647,3884,6003,6004,4758,3835,5220,5789,4565,5407,6540,6135,5294,4697, -4852,6320,6321,3206,4907,6541,6322,4945,6542,6136,6543,6323,6005,4631,3519,6544, -5891,6545,5464,3784,5221,6546,5571,4659,6547,6324,6137,5190,6548,3853,6549,4016, -4834,3954,6138,5332,3827,4017,3210,3546,4469,5408,5718,3505,4648,5790,5131,5638, -5791,5465,4727,4318,6325,6326,5792,4553,4010,4698,3439,4974,3638,4335,3085,6006, -5104,5042,5166,5892,5572,6327,4356,4519,5222,5573,5333,5793,5043,6550,5639,5071, -4503,6328,6139,6551,6140,3914,3901,5372,6007,5640,4728,4793,3976,3836,4885,6552, -4127,6553,4451,4102,5002,6554,3686,5105,6555,5191,5072,5295,4611,5794,5296,6556, -5893,5264,5894,4975,5466,5265,4699,4976,4370,4056,3492,5044,4886,6557,5795,4432, -4769,4357,5467,3940,4660,4290,6141,4484,4770,4661,3992,6329,4025,4662,5022,4632, -4835,4070,5297,4663,4596,5574,5132,5409,5895,6142,4504,5192,4664,5796,5896,3885, -5575,5797,5023,4810,5798,3732,5223,4712,5298,4084,5334,5468,6143,4052,4053,4336, -4977,4794,6558,5335,4908,5576,5224,4233,5024,4128,5469,5225,4873,6008,5045,4729, -4742,4633,3675,4597,6559,5897,5133,5577,5003,5641,5719,6330,6560,3017,2382,3854, -4406,4811,6331,4393,3964,4946,6561,2420,3722,6562,4926,4378,3247,1736,4442,6332, -5134,6333,5226,3996,2918,5470,4319,4003,4598,4743,4744,4485,3785,3902,5167,5004, -5373,4394,5898,6144,4874,1793,3997,6334,4085,4214,5106,5642,4909,5799,6009,4419, -4189,3330,5899,4165,4420,5299,5720,5227,3347,6145,4081,6335,2876,3930,6146,3293, -3786,3910,3998,5900,5300,5578,2840,6563,5901,5579,6147,3531,5374,6564,6565,5580, -4759,5375,6566,6148,3559,5643,6336,6010,5517,6337,6338,5721,5902,3873,6011,6339, -6567,5518,3868,3649,5722,6568,4771,4947,6569,6149,4812,6570,2853,5471,6340,6341, -5644,4795,6342,6012,5723,6343,5724,6013,4349,6344,3160,6150,5193,4599,4514,4493, -5168,4320,6345,4927,3666,4745,5169,5903,5005,4928,6346,5725,6014,4730,4203,5046, -4948,3395,5170,6015,4150,6016,5726,5519,6347,5047,3550,6151,6348,4197,4310,5904, -6571,5581,2965,6152,4978,3960,4291,5135,6572,5301,5727,4129,4026,5905,4853,5728, -5472,6153,6349,4533,2700,4505,5336,4678,3583,5073,2994,4486,3043,4554,5520,6350, -6017,5800,4487,6351,3931,4103,5376,6352,4011,4321,4311,4190,5136,6018,3988,3233, -4350,5906,5645,4198,6573,5107,3432,4191,3435,5582,6574,4139,5410,6353,5411,3944, -5583,5074,3198,6575,6354,4358,6576,5302,4600,5584,5194,5412,6577,6578,5585,5413, -5303,4248,5414,3879,4433,6579,4479,5025,4854,5415,6355,4760,4772,3683,2978,4700, -3797,4452,3965,3932,3721,4910,5801,6580,5195,3551,5907,3221,3471,3029,6019,3999, -5908,5909,5266,5267,3444,3023,3828,3170,4796,5646,4979,4259,6356,5647,5337,3694, -6357,5648,5338,4520,4322,5802,3031,3759,4071,6020,5586,4836,4386,5048,6581,3571, -4679,4174,4949,6154,4813,3787,3402,3822,3958,3215,3552,5268,4387,3933,4950,4359, -6021,5910,5075,3579,6358,4234,4566,5521,6359,3613,5049,6022,5911,3375,3702,3178, -4911,5339,4521,6582,6583,4395,3087,3811,5377,6023,6360,6155,4027,5171,5649,4421, -4249,2804,6584,2270,6585,4000,4235,3045,6156,5137,5729,4140,4312,3886,6361,4330, -6157,4215,6158,3500,3676,4929,4331,3713,4930,5912,4265,3776,3368,5587,4470,4855, -3038,4980,3631,6159,6160,4132,4680,6161,6362,3923,4379,5588,4255,6586,4121,6587, -6363,4649,6364,3288,4773,4774,6162,6024,6365,3543,6588,4274,3107,3737,5050,5803, -4797,4522,5589,5051,5730,3714,4887,5378,4001,4523,6163,5026,5522,4701,4175,2791, -3760,6589,5473,4224,4133,3847,4814,4815,4775,3259,5416,6590,2738,6164,6025,5304, -3733,5076,5650,4816,5590,6591,6165,6592,3934,5269,6593,3396,5340,6594,5804,3445, -3602,4042,4488,5731,5732,3525,5591,4601,5196,6166,6026,5172,3642,4612,3202,4506, -4798,6366,3818,5108,4303,5138,5139,4776,3332,4304,2915,3415,4434,5077,5109,4856, -2879,5305,4817,6595,5913,3104,3144,3903,4634,5341,3133,5110,5651,5805,6167,4057, -5592,2945,4371,5593,6596,3474,4182,6367,6597,6168,4507,4279,6598,2822,6599,4777, -4713,5594,3829,6169,3887,5417,6170,3653,5474,6368,4216,2971,5228,3790,4579,6369, -5733,6600,6601,4951,4746,4555,6602,5418,5475,6027,3400,4665,5806,6171,4799,6028, -5052,6172,3343,4800,4747,5006,6370,4556,4217,5476,4396,5229,5379,5477,3839,5914, -5652,5807,4714,3068,4635,5808,6173,5342,4192,5078,5419,5523,5734,6174,4557,6175, -4602,6371,6176,6603,5809,6372,5735,4260,3869,5111,5230,6029,5112,6177,3126,4681, -5524,5915,2706,3563,4748,3130,6178,4018,5525,6604,6605,5478,4012,4837,6606,4534, -4193,5810,4857,3615,5479,6030,4082,3697,3539,4086,5270,3662,4508,4931,5916,4912, -5811,5027,3888,6607,4397,3527,3302,3798,2775,2921,2637,3966,4122,4388,4028,4054, -1633,4858,5079,3024,5007,3982,3412,5736,6608,3426,3236,5595,3030,6179,3427,3336, -3279,3110,6373,3874,3039,5080,5917,5140,4489,3119,6374,5812,3405,4494,6031,4666, -4141,6180,4166,6032,5813,4981,6609,5081,4422,4982,4112,3915,5653,3296,3983,6375, -4266,4410,5654,6610,6181,3436,5082,6611,5380,6033,3819,5596,4535,5231,5306,5113, -6612,4952,5918,4275,3113,6613,6376,6182,6183,5814,3073,4731,4838,5008,3831,6614, -4888,3090,3848,4280,5526,5232,3014,5655,5009,5737,5420,5527,6615,5815,5343,5173, -5381,4818,6616,3151,4953,6617,5738,2796,3204,4360,2989,4281,5739,5174,5421,5197, -3132,5141,3849,5142,5528,5083,3799,3904,4839,5480,2880,4495,3448,6377,6184,5271, -5919,3771,3193,6034,6035,5920,5010,6036,5597,6037,6378,6038,3106,5422,6618,5423, -5424,4142,6619,4889,5084,4890,4313,5740,6620,3437,5175,5307,5816,4199,5198,5529, -5817,5199,5656,4913,5028,5344,3850,6185,2955,5272,5011,5818,4567,4580,5029,5921, -3616,5233,6621,6622,6186,4176,6039,6379,6380,3352,5200,5273,2908,5598,5234,3837, -5308,6623,6624,5819,4496,4323,5309,5201,6625,6626,4983,3194,3838,4167,5530,5922, -5274,6381,6382,3860,3861,5599,3333,4292,4509,6383,3553,5481,5820,5531,4778,6187, -3955,3956,4324,4389,4218,3945,4325,3397,2681,5923,4779,5085,4019,5482,4891,5382, -5383,6040,4682,3425,5275,4094,6627,5310,3015,5483,5657,4398,5924,3168,4819,6628, -5925,6629,5532,4932,4613,6041,6630,4636,6384,4780,4204,5658,4423,5821,3989,4683, -5822,6385,4954,6631,5345,6188,5425,5012,5384,3894,6386,4490,4104,6632,5741,5053, -6633,5823,5926,5659,5660,5927,6634,5235,5742,5824,4840,4933,4820,6387,4859,5928, -4955,6388,4143,3584,5825,5346,5013,6635,5661,6389,5014,5484,5743,4337,5176,5662, -6390,2836,6391,3268,6392,6636,6042,5236,6637,4158,6638,5744,5663,4471,5347,3663, -4123,5143,4293,3895,6639,6640,5311,5929,5826,3800,6189,6393,6190,5664,5348,3554, -3594,4749,4603,6641,5385,4801,6043,5827,4183,6642,5312,5426,4761,6394,5665,6191, -4715,2669,6643,6644,5533,3185,5427,5086,5930,5931,5386,6192,6044,6645,4781,4013, -5745,4282,4435,5534,4390,4267,6045,5746,4984,6046,2743,6193,3501,4087,5485,5932, -5428,4184,4095,5747,4061,5054,3058,3862,5933,5600,6646,5144,3618,6395,3131,5055, -5313,6396,4650,4956,3855,6194,3896,5202,4985,4029,4225,6195,6647,5828,5486,5829, -3589,3002,6648,6397,4782,5276,6649,6196,6650,4105,3803,4043,5237,5830,6398,4096, -3643,6399,3528,6651,4453,3315,4637,6652,3984,6197,5535,3182,3339,6653,3096,2660, -6400,6654,3449,5934,4250,4236,6047,6401,5831,6655,5487,3753,4062,5832,6198,6199, -6656,3766,6657,3403,4667,6048,6658,4338,2897,5833,3880,2797,3780,4326,6659,5748, -5015,6660,5387,4351,5601,4411,6661,3654,4424,5935,4339,4072,5277,4568,5536,6402, -6662,5238,6663,5349,5203,6200,5204,6201,5145,4536,5016,5056,4762,5834,4399,4957, -6202,6403,5666,5749,6664,4340,6665,5936,5177,5667,6666,6667,3459,4668,6404,6668, -6669,4543,6203,6670,4276,6405,4480,5537,6671,4614,5205,5668,6672,3348,2193,4763, -6406,6204,5937,5602,4177,5669,3419,6673,4020,6205,4443,4569,5388,3715,3639,6407, -6049,4058,6206,6674,5938,4544,6050,4185,4294,4841,4651,4615,5488,6207,6408,6051, -5178,3241,3509,5835,6208,4958,5836,4341,5489,5278,6209,2823,5538,5350,5206,5429, -6675,4638,4875,4073,3516,4684,4914,4860,5939,5603,5389,6052,5057,3237,5490,3791, -6676,6409,6677,4821,4915,4106,5351,5058,4243,5539,4244,5604,4842,4916,5239,3028, -3716,5837,5114,5605,5390,5940,5430,6210,4332,6678,5540,4732,3667,3840,6053,4305, -3408,5670,5541,6410,2744,5240,5750,6679,3234,5606,6680,5607,5671,3608,4283,4159, -4400,5352,4783,6681,6411,6682,4491,4802,6211,6412,5941,6413,6414,5542,5751,6683, -4669,3734,5942,6684,6415,5943,5059,3328,4670,4144,4268,6685,6686,6687,6688,4372, -3603,6689,5944,5491,4373,3440,6416,5543,4784,4822,5608,3792,4616,5838,5672,3514, -5391,6417,4892,6690,4639,6691,6054,5673,5839,6055,6692,6056,5392,6212,4038,5544, -5674,4497,6057,6693,5840,4284,5675,4021,4545,5609,6418,4454,6419,6213,4113,4472, -5314,3738,5087,5279,4074,5610,4959,4063,3179,4750,6058,6420,6214,3476,4498,4716, -5431,4960,4685,6215,5241,6694,6421,6216,6695,5841,5945,6422,3748,5946,5179,3905, -5752,5545,5947,4374,6217,4455,6423,4412,6218,4803,5353,6696,3832,5280,6219,4327, -4702,6220,6221,6059,4652,5432,6424,3749,4751,6425,5753,4986,5393,4917,5948,5030, -5754,4861,4733,6426,4703,6697,6222,4671,5949,4546,4961,5180,6223,5031,3316,5281, -6698,4862,4295,4934,5207,3644,6427,5842,5950,6428,6429,4570,5843,5282,6430,6224, -5088,3239,6060,6699,5844,5755,6061,6431,2701,5546,6432,5115,5676,4039,3993,3327, -4752,4425,5315,6433,3941,6434,5677,4617,4604,3074,4581,6225,5433,6435,6226,6062, -4823,5756,5116,6227,3717,5678,4717,5845,6436,5679,5846,6063,5847,6064,3977,3354, -6437,3863,5117,6228,5547,5394,4499,4524,6229,4605,6230,4306,4500,6700,5951,6065, -3693,5952,5089,4366,4918,6701,6231,5548,6232,6702,6438,4704,5434,6703,6704,5953, -4168,6705,5680,3420,6706,5242,4407,6066,3812,5757,5090,5954,4672,4525,3481,5681, -4618,5395,5354,5316,5955,6439,4962,6707,4526,6440,3465,4673,6067,6441,5682,6708, -5435,5492,5758,5683,4619,4571,4674,4804,4893,4686,5493,4753,6233,6068,4269,6442, -6234,5032,4705,5146,5243,5208,5848,6235,6443,4963,5033,4640,4226,6236,5849,3387, -6444,6445,4436,4437,5850,4843,5494,4785,4894,6709,4361,6710,5091,5956,3331,6237, -4987,5549,6069,6711,4342,3517,4473,5317,6070,6712,6071,4706,6446,5017,5355,6713, -6714,4988,5436,6447,4734,5759,6715,4735,4547,4456,4754,6448,5851,6449,6450,3547, -5852,5318,6451,6452,5092,4205,6716,6238,4620,4219,5611,6239,6072,4481,5760,5957, -5958,4059,6240,6453,4227,4537,6241,5761,4030,4186,5244,5209,3761,4457,4876,3337, -5495,5181,6242,5959,5319,5612,5684,5853,3493,5854,6073,4169,5613,5147,4895,6074, -5210,6717,5182,6718,3830,6243,2798,3841,6075,6244,5855,5614,3604,4606,5496,5685, -5118,5356,6719,6454,5960,5357,5961,6720,4145,3935,4621,5119,5962,4261,6721,6455, -4786,5963,4375,4582,6245,6246,6247,6076,5437,4877,5856,3376,4380,6248,4160,6722, -5148,6456,5211,6457,6723,4718,6458,6724,6249,5358,4044,3297,6459,6250,5857,5615, -5497,5245,6460,5498,6725,6251,6252,5550,3793,5499,2959,5396,6461,6462,4572,5093, -5500,5964,3806,4146,6463,4426,5762,5858,6077,6253,4755,3967,4220,5965,6254,4989, -5501,6464,4352,6726,6078,4764,2290,5246,3906,5438,5283,3767,4964,2861,5763,5094, -6255,6256,4622,5616,5859,5860,4707,6727,4285,4708,4824,5617,6257,5551,4787,5212, -4965,4935,4687,6465,6728,6466,5686,6079,3494,4413,2995,5247,5966,5618,6729,5967, -5764,5765,5687,5502,6730,6731,6080,5397,6467,4990,6258,6732,4538,5060,5619,6733, -4719,5688,5439,5018,5149,5284,5503,6734,6081,4607,6259,5120,3645,5861,4583,6260, -4584,4675,5620,4098,5440,6261,4863,2379,3306,4585,5552,5689,4586,5285,6735,4864, -6736,5286,6082,6737,4623,3010,4788,4381,4558,5621,4587,4896,3698,3161,5248,4353, -4045,6262,3754,5183,4588,6738,6263,6739,6740,5622,3936,6741,6468,6742,6264,5095, -6469,4991,5968,6743,4992,6744,6083,4897,6745,4256,5766,4307,3108,3968,4444,5287, -3889,4343,6084,4510,6085,4559,6086,4898,5969,6746,5623,5061,4919,5249,5250,5504, -5441,6265,5320,4878,3242,5862,5251,3428,6087,6747,4237,5624,5442,6266,5553,4539, -6748,2585,3533,5398,4262,6088,5150,4736,4438,6089,6267,5505,4966,6749,6268,6750, -6269,5288,5554,3650,6090,6091,4624,6092,5690,6751,5863,4270,5691,4277,5555,5864, -6752,5692,4720,4865,6470,5151,4688,4825,6753,3094,6754,6471,3235,4653,6755,5213, -5399,6756,3201,4589,5865,4967,6472,5866,6473,5019,3016,6757,5321,4756,3957,4573, -6093,4993,5767,4721,6474,6758,5625,6759,4458,6475,6270,6760,5556,4994,5214,5252, -6271,3875,5768,6094,5034,5506,4376,5769,6761,2120,6476,5253,5770,6762,5771,5970, -3990,5971,5557,5558,5772,6477,6095,2787,4641,5972,5121,6096,6097,6272,6763,3703, -5867,5507,6273,4206,6274,4789,6098,6764,3619,3646,3833,3804,2394,3788,4936,3978, -4866,4899,6099,6100,5559,6478,6765,3599,5868,6101,5869,5870,6275,6766,4527,6767, -*******************************************************************************/ -}; - - diff --git a/amarok/utilities/collectionscanner/charset-detector/src/tables/JISFreq.tab b/amarok/utilities/collectionscanner/charset-detector/src/tables/JISFreq.tab deleted file mode 100644 index 715321fc..00000000 --- a/amarok/utilities/collectionscanner/charset-detector/src/tables/JISFreq.tab +++ /dev/null @@ -1,589 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -//Sampling from about 20M text materials include literature and computer technology - -// Japanese frequency table, applied to both S-JIS and EUC-JP -//They are sorted in order. - -/****************************************************************************** - * 128 --> 0.77094 - * 256 --> 0.85710 - * 512 --> 0.92635 - * 1024 --> 0.97130 - * 2048 --> 0.99431 - * - * Idea Distribution Ratio = 0.92635 / (1-0.92635) = 12.58 - * Random Distribution Ration = 512 / (2965+62+83+86-512) = 0.191 - * - * Typical Distribution Ratio, 25% of IDR - *****************************************************************************/ - -#define JIS_TYPICAL_DISTRIBUTION_RATIO (float) 3.0 - - -//Char to FreqOrder table , -#define JIS_TABLE_SIZE 4368 - -static const PRInt16 JISCharToFreqOrder[] = -{ - 40, 1, 6, 182, 152, 180, 295,2127, 285, 381,3295,4304,3068,4606,3165,3510, // 16 -3511,1822,2785,4607,1193,2226,5070,4608, 171,2996,1247, 18, 179,5071, 856,1661, // 32 -1262,5072, 619, 127,3431,3512,3230,1899,1700, 232, 228,1294,1298, 284, 283,2041, // 48 -2042,1061,1062, 48, 49, 44, 45, 433, 434,1040,1041, 996, 787,2997,1255,4305, // 64 -2108,4609,1684,1648,5073,5074,5075,5076,5077,5078,3687,5079,4610,5080,3927,3928, // 80 -5081,3296,3432, 290,2285,1471,2187,5082,2580,2825,1303,2140,1739,1445,2691,3375, // 96 -1691,3297,4306,4307,4611, 452,3376,1182,2713,3688,3069,4308,5083,5084,5085,5086, // 112 -5087,5088,5089,5090,5091,5092,5093,5094,5095,5096,5097,5098,5099,5100,5101,5102, // 128 -5103,5104,5105,5106,5107,5108,5109,5110,5111,5112,4097,5113,5114,5115,5116,5117, // 144 -5118,5119,5120,5121,5122,5123,5124,5125,5126,5127,5128,5129,5130,5131,5132,5133, // 160 -5134,5135,5136,5137,5138,5139,5140,5141,5142,5143,5144,5145,5146,5147,5148,5149, // 176 -5150,5151,5152,4612,5153,5154,5155,5156,5157,5158,5159,5160,5161,5162,5163,5164, // 192 -5165,5166,5167,5168,5169,5170,5171,5172,5173,5174,5175,1472, 598, 618, 820,1205, // 208 -1309,1412,1858,1307,1692,5176,5177,5178,5179,5180,5181,5182,1142,1452,1234,1172, // 224 -1875,2043,2149,1793,1382,2973, 925,2404,1067,1241, 960,1377,2935,1491, 919,1217, // 240 -1865,2030,1406,1499,2749,4098,5183,5184,5185,5186,5187,5188,2561,4099,3117,1804, // 256 -2049,3689,4309,3513,1663,5189,3166,3118,3298,1587,1561,3433,5190,3119,1625,2998, // 272 -3299,4613,1766,3690,2786,4614,5191,5192,5193,5194,2161, 26,3377, 2,3929, 20, // 288 -3691, 47,4100, 50, 17, 16, 35, 268, 27, 243, 42, 155, 24, 154, 29, 184, // 304 - 4, 91, 14, 92, 53, 396, 33, 289, 9, 37, 64, 620, 21, 39, 321, 5, // 320 - 12, 11, 52, 13, 3, 208, 138, 0, 7, 60, 526, 141, 151,1069, 181, 275, // 336 -1591, 83, 132,1475, 126, 331, 829, 15, 69, 160, 59, 22, 157, 55,1079, 312, // 352 - 109, 38, 23, 25, 10, 19, 79,5195, 61, 382,1124, 8, 30,5196,5197,5198, // 368 -5199,5200,5201,5202,5203,5204,5205,5206, 89, 62, 74, 34,2416, 112, 139, 196, // 384 - 271, 149, 84, 607, 131, 765, 46, 88, 153, 683, 76, 874, 101, 258, 57, 80, // 400 - 32, 364, 121,1508, 169,1547, 68, 235, 145,2999, 41, 360,3027, 70, 63, 31, // 416 - 43, 259, 262,1383, 99, 533, 194, 66, 93, 846, 217, 192, 56, 106, 58, 565, // 432 - 280, 272, 311, 256, 146, 82, 308, 71, 100, 128, 214, 655, 110, 261, 104,1140, // 448 - 54, 51, 36, 87, 67,3070, 185,2618,2936,2020, 28,1066,2390,2059,5207,5208, // 464 -5209,5210,5211,5212,5213,5214,5215,5216,4615,5217,5218,5219,5220,5221,5222,5223, // 480 -5224,5225,5226,5227,5228,5229,5230,5231,5232,5233,5234,5235,5236,3514,5237,5238, // 496 -5239,5240,5241,5242,5243,5244,2297,2031,4616,4310,3692,5245,3071,5246,3598,5247, // 512 -4617,3231,3515,5248,4101,4311,4618,3808,4312,4102,5249,4103,4104,3599,5250,5251, // 528 -5252,5253,5254,5255,5256,5257,5258,5259,5260,5261,5262,5263,5264,5265,5266,5267, // 544 -5268,5269,5270,5271,5272,5273,5274,5275,5276,5277,5278,5279,5280,5281,5282,5283, // 560 -5284,5285,5286,5287,5288,5289,5290,5291,5292,5293,5294,5295,5296,5297,5298,5299, // 576 -5300,5301,5302,5303,5304,5305,5306,5307,5308,5309,5310,5311,5312,5313,5314,5315, // 592 -5316,5317,5318,5319,5320,5321,5322,5323,5324,5325,5326,5327,5328,5329,5330,5331, // 608 -5332,5333,5334,5335,5336,5337,5338,5339,5340,5341,5342,5343,5344,5345,5346,5347, // 624 -5348,5349,5350,5351,5352,5353,5354,5355,5356,5357,5358,5359,5360,5361,5362,5363, // 640 -5364,5365,5366,5367,5368,5369,5370,5371,5372,5373,5374,5375,5376,5377,5378,5379, // 656 -5380,5381, 363, 642,2787,2878,2788,2789,2316,3232,2317,3434,2011, 165,1942,3930, // 672 -3931,3932,3933,5382,4619,5383,4620,5384,5385,5386,5387,5388,5389,5390,5391,5392, // 688 -5393,5394,5395,5396,5397,5398,5399,5400,5401,5402,5403,5404,5405,5406,5407,5408, // 704 -5409,5410,5411,5412,5413,5414,5415,5416,5417,5418,5419,5420,5421,5422,5423,5424, // 720 -5425,5426,5427,5428,5429,5430,5431,5432,5433,5434,5435,5436,5437,5438,5439,5440, // 736 -5441,5442,5443,5444,5445,5446,5447,5448,5449,5450,5451,5452,5453,5454,5455,5456, // 752 -5457,5458,5459,5460,5461,5462,5463,5464,5465,5466,5467,5468,5469,5470,5471,5472, // 768 -5473,5474,5475,5476,5477,5478,5479,5480,5481,5482,5483,5484,5485,5486,5487,5488, // 784 -5489,5490,5491,5492,5493,5494,5495,5496,5497,5498,5499,5500,5501,5502,5503,5504, // 800 -5505,5506,5507,5508,5509,5510,5511,5512,5513,5514,5515,5516,5517,5518,5519,5520, // 816 -5521,5522,5523,5524,5525,5526,5527,5528,5529,5530,5531,5532,5533,5534,5535,5536, // 832 -5537,5538,5539,5540,5541,5542,5543,5544,5545,5546,5547,5548,5549,5550,5551,5552, // 848 -5553,5554,5555,5556,5557,5558,5559,5560,5561,5562,5563,5564,5565,5566,5567,5568, // 864 -5569,5570,5571,5572,5573,5574,5575,5576,5577,5578,5579,5580,5581,5582,5583,5584, // 880 -5585,5586,5587,5588,5589,5590,5591,5592,5593,5594,5595,5596,5597,5598,5599,5600, // 896 -5601,5602,5603,5604,5605,5606,5607,5608,5609,5610,5611,5612,5613,5614,5615,5616, // 912 -5617,5618,5619,5620,5621,5622,5623,5624,5625,5626,5627,5628,5629,5630,5631,5632, // 928 -5633,5634,5635,5636,5637,5638,5639,5640,5641,5642,5643,5644,5645,5646,5647,5648, // 944 -5649,5650,5651,5652,5653,5654,5655,5656,5657,5658,5659,5660,5661,5662,5663,5664, // 960 -5665,5666,5667,5668,5669,5670,5671,5672,5673,5674,5675,5676,5677,5678,5679,5680, // 976 -5681,5682,5683,5684,5685,5686,5687,5688,5689,5690,5691,5692,5693,5694,5695,5696, // 992 -5697,5698,5699,5700,5701,5702,5703,5704,5705,5706,5707,5708,5709,5710,5711,5712, // 1008 -5713,5714,5715,5716,5717,5718,5719,5720,5721,5722,5723,5724,5725,5726,5727,5728, // 1024 -5729,5730,5731,5732,5733,5734,5735,5736,5737,5738,5739,5740,5741,5742,5743,5744, // 1040 -5745,5746,5747,5748,5749,5750,5751,5752,5753,5754,5755,5756,5757,5758,5759,5760, // 1056 -5761,5762,5763,5764,5765,5766,5767,5768,5769,5770,5771,5772,5773,5774,5775,5776, // 1072 -5777,5778,5779,5780,5781,5782,5783,5784,5785,5786,5787,5788,5789,5790,5791,5792, // 1088 -5793,5794,5795,5796,5797,5798,5799,5800,5801,5802,5803,5804,5805,5806,5807,5808, // 1104 -5809,5810,5811,5812,5813,5814,5815,5816,5817,5818,5819,5820,5821,5822,5823,5824, // 1120 -5825,5826,5827,5828,5829,5830,5831,5832,5833,5834,5835,5836,5837,5838,5839,5840, // 1136 -5841,5842,5843,5844,5845,5846,5847,5848,5849,5850,5851,5852,5853,5854,5855,5856, // 1152 -5857,5858,5859,5860,5861,5862,5863,5864,5865,5866,5867,5868,5869,5870,5871,5872, // 1168 -5873,5874,5875,5876,5877,5878,5879,5880,5881,5882,5883,5884,5885,5886,5887,5888, // 1184 -5889,5890,5891,5892,5893,5894,5895,5896,5897,5898,5899,5900,5901,5902,5903,5904, // 1200 -5905,5906,5907,5908,5909,5910,5911,5912,5913,5914,5915,5916,5917,5918,5919,5920, // 1216 -5921,5922,5923,5924,5925,5926,5927,5928,5929,5930,5931,5932,5933,5934,5935,5936, // 1232 -5937,5938,5939,5940,5941,5942,5943,5944,5945,5946,5947,5948,5949,5950,5951,5952, // 1248 -5953,5954,5955,5956,5957,5958,5959,5960,5961,5962,5963,5964,5965,5966,5967,5968, // 1264 -5969,5970,5971,5972,5973,5974,5975,5976,5977,5978,5979,5980,5981,5982,5983,5984, // 1280 -5985,5986,5987,5988,5989,5990,5991,5992,5993,5994,5995,5996,5997,5998,5999,6000, // 1296 -6001,6002,6003,6004,6005,6006,6007,6008,6009,6010,6011,6012,6013,6014,6015,6016, // 1312 -6017,6018,6019,6020,6021,6022,6023,6024,6025,6026,6027,6028,6029,6030,6031,6032, // 1328 -6033,6034,6035,6036,6037,6038,6039,6040,6041,6042,6043,6044,6045,6046,6047,6048, // 1344 -6049,6050,6051,6052,6053,6054,6055,6056,6057,6058,6059,6060,6061,6062,6063,6064, // 1360 -6065,6066,6067,6068,6069,6070,6071,6072,6073,6074,6075,6076,6077,6078,6079,6080, // 1376 -6081,6082,6083,6084,6085,6086,6087,6088,6089,6090,6091,6092,6093,6094,6095,6096, // 1392 -6097,6098,6099,6100,6101,6102,6103,6104,6105,6106,6107,6108,6109,6110,6111,6112, // 1408 -6113,6114,2044,2060,4621, 997,1235, 473,1186,4622, 920,3378,6115,6116, 379,1108, // 1424 -4313,2657,2735,3934,6117,3809, 636,3233, 573,1026,3693,3435,2974,3300,2298,4105, // 1440 - 854,2937,2463, 393,2581,2417, 539, 752,1280,2750,2480, 140,1161, 440, 708,1569, // 1456 - 665,2497,1746,1291,1523,3000, 164,1603, 847,1331, 537,1997, 486, 508,1693,2418, // 1472 -1970,2227, 878,1220, 299,1030, 969, 652,2751, 624,1137,3301,2619, 65,3302,2045, // 1488 -1761,1859,3120,1930,3694,3516, 663,1767, 852, 835,3695, 269, 767,2826,2339,1305, // 1504 - 896,1150, 770,1616,6118, 506,1502,2075,1012,2519, 775,2520,2975,2340,2938,4314, // 1520 -3028,2086,1224,1943,2286,6119,3072,4315,2240,1273,1987,3935,1557, 175, 597, 985, // 1536 -3517,2419,2521,1416,3029, 585, 938,1931,1007,1052,1932,1685,6120,3379,4316,4623, // 1552 - 804, 599,3121,1333,2128,2539,1159,1554,2032,3810, 687,2033,2904, 952, 675,1467, // 1568 -3436,6121,2241,1096,1786,2440,1543,1924, 980,1813,2228, 781,2692,1879, 728,1918, // 1584 -3696,4624, 548,1950,4625,1809,1088,1356,3303,2522,1944, 502, 972, 373, 513,2827, // 1600 - 586,2377,2391,1003,1976,1631,6122,2464,1084, 648,1776,4626,2141, 324, 962,2012, // 1616 -2177,2076,1384, 742,2178,1448,1173,1810, 222, 102, 301, 445, 125,2420, 662,2498, // 1632 - 277, 200,1476,1165,1068, 224,2562,1378,1446, 450,1880, 659, 791, 582,4627,2939, // 1648 -3936,1516,1274, 555,2099,3697,1020,1389,1526,3380,1762,1723,1787,2229, 412,2114, // 1664 -1900,2392,3518, 512,2597, 427,1925,2341,3122,1653,1686,2465,2499, 697, 330, 273, // 1680 - 380,2162, 951, 832, 780, 991,1301,3073, 965,2270,3519, 668,2523,2636,1286, 535, // 1696 -1407, 518, 671, 957,2658,2378, 267, 611,2197,3030,6123, 248,2299, 967,1799,2356, // 1712 - 850,1418,3437,1876,1256,1480,2828,1718,6124,6125,1755,1664,2405,6126,4628,2879, // 1728 -2829, 499,2179, 676,4629, 557,2329,2214,2090, 325,3234, 464, 811,3001, 992,2342, // 1744 -2481,1232,1469, 303,2242, 466,1070,2163, 603,1777,2091,4630,2752,4631,2714, 322, // 1760 -2659,1964,1768, 481,2188,1463,2330,2857,3600,2092,3031,2421,4632,2318,2070,1849, // 1776 -2598,4633,1302,2254,1668,1701,2422,3811,2905,3032,3123,2046,4106,1763,1694,4634, // 1792 -1604, 943,1724,1454, 917, 868,2215,1169,2940, 552,1145,1800,1228,1823,1955, 316, // 1808 -1080,2510, 361,1807,2830,4107,2660,3381,1346,1423,1134,4108,6127, 541,1263,1229, // 1824 -1148,2540, 545, 465,1833,2880,3438,1901,3074,2482, 816,3937, 713,1788,2500, 122, // 1840 -1575, 195,1451,2501,1111,6128, 859, 374,1225,2243,2483,4317, 390,1033,3439,3075, // 1856 -2524,1687, 266, 793,1440,2599, 946, 779, 802, 507, 897,1081, 528,2189,1292, 711, // 1872 -1866,1725,1167,1640, 753, 398,2661,1053, 246, 348,4318, 137,1024,3440,1600,2077, // 1888 -2129, 825,4319, 698, 238, 521, 187,2300,1157,2423,1641,1605,1464,1610,1097,2541, // 1904 -1260,1436, 759,2255,1814,2150, 705,3235, 409,2563,3304, 561,3033,2005,2564, 726, // 1920 -1956,2343,3698,4109, 949,3812,3813,3520,1669, 653,1379,2525, 881,2198, 632,2256, // 1936 -1027, 778,1074, 733,1957, 514,1481,2466, 554,2180, 702,3938,1606,1017,1398,6129, // 1952 -1380,3521, 921, 993,1313, 594, 449,1489,1617,1166, 768,1426,1360, 495,1794,3601, // 1968 -1177,3602,1170,4320,2344, 476, 425,3167,4635,3168,1424, 401,2662,1171,3382,1998, // 1984 -1089,4110, 477,3169, 474,6130,1909, 596,2831,1842, 494, 693,1051,1028,1207,3076, // 2000 - 606,2115, 727,2790,1473,1115, 743,3522, 630, 805,1532,4321,2021, 366,1057, 838, // 2016 - 684,1114,2142,4322,2050,1492,1892,1808,2271,3814,2424,1971,1447,1373,3305,1090, // 2032 -1536,3939,3523,3306,1455,2199, 336, 369,2331,1035, 584,2393, 902, 718,2600,6131, // 2048 -2753, 463,2151,1149,1611,2467, 715,1308,3124,1268, 343,1413,3236,1517,1347,2663, // 2064 -2093,3940,2022,1131,1553,2100,2941,1427,3441,2942,1323,2484,6132,1980, 872,2368, // 2080 -2441,2943, 320,2369,2116,1082, 679,1933,3941,2791,3815, 625,1143,2023, 422,2200, // 2096 -3816,6133, 730,1695, 356,2257,1626,2301,2858,2637,1627,1778, 937, 883,2906,2693, // 2112 -3002,1769,1086, 400,1063,1325,3307,2792,4111,3077, 456,2345,1046, 747,6134,1524, // 2128 - 884,1094,3383,1474,2164,1059, 974,1688,2181,2258,1047, 345,1665,1187, 358, 875, // 2144 -3170, 305, 660,3524,2190,1334,1135,3171,1540,1649,2542,1527, 927, 968,2793, 885, // 2160 -1972,1850, 482, 500,2638,1218,1109,1085,2543,1654,2034, 876, 78,2287,1482,1277, // 2176 - 861,1675,1083,1779, 724,2754, 454, 397,1132,1612,2332, 893, 672,1237, 257,2259, // 2192 -2370, 135,3384, 337,2244, 547, 352, 340, 709,2485,1400, 788,1138,2511, 540, 772, // 2208 -1682,2260,2272,2544,2013,1843,1902,4636,1999,1562,2288,4637,2201,1403,1533, 407, // 2224 - 576,3308,1254,2071, 978,3385, 170, 136,1201,3125,2664,3172,2394, 213, 912, 873, // 2240 -3603,1713,2202, 699,3604,3699, 813,3442, 493, 531,1054, 468,2907,1483, 304, 281, // 2256 -4112,1726,1252,2094, 339,2319,2130,2639, 756,1563,2944, 748, 571,2976,1588,2425, // 2272 -2715,1851,1460,2426,1528,1392,1973,3237, 288,3309, 685,3386, 296, 892,2716,2216, // 2288 -1570,2245, 722,1747,2217, 905,3238,1103,6135,1893,1441,1965, 251,1805,2371,3700, // 2304 -2601,1919,1078, 75,2182,1509,1592,1270,2640,4638,2152,6136,3310,3817, 524, 706, // 2320 -1075, 292,3818,1756,2602, 317, 98,3173,3605,3525,1844,2218,3819,2502, 814, 567, // 2336 - 385,2908,1534,6137, 534,1642,3239, 797,6138,1670,1529, 953,4323, 188,1071, 538, // 2352 - 178, 729,3240,2109,1226,1374,2000,2357,2977, 731,2468,1116,2014,2051,6139,1261, // 2368 -1593, 803,2859,2736,3443, 556, 682, 823,1541,6140,1369,2289,1706,2794, 845, 462, // 2384 -2603,2665,1361, 387, 162,2358,1740, 739,1770,1720,1304,1401,3241,1049, 627,1571, // 2400 -2427,3526,1877,3942,1852,1500, 431,1910,1503, 677, 297,2795, 286,1433,1038,1198, // 2416 -2290,1133,1596,4113,4639,2469,1510,1484,3943,6141,2442, 108, 712,4640,2372, 866, // 2432 -3701,2755,3242,1348, 834,1945,1408,3527,2395,3243,1811, 824, 994,1179,2110,1548, // 2448 -1453, 790,3003, 690,4324,4325,2832,2909,3820,1860,3821, 225,1748, 310, 346,1780, // 2464 -2470, 821,1993,2717,2796, 828, 877,3528,2860,2471,1702,2165,2910,2486,1789, 453, // 2480 - 359,2291,1676, 73,1164,1461,1127,3311, 421, 604, 314,1037, 589, 116,2487, 737, // 2496 - 837,1180, 111, 244, 735,6142,2261,1861,1362, 986, 523, 418, 581,2666,3822, 103, // 2512 - 855, 503,1414,1867,2488,1091, 657,1597, 979, 605,1316,4641,1021,2443,2078,2001, // 2528 -1209, 96, 587,2166,1032, 260,1072,2153, 173, 94, 226,3244, 819,2006,4642,4114, // 2544 -2203, 231,1744, 782, 97,2667, 786,3387, 887, 391, 442,2219,4326,1425,6143,2694, // 2560 - 633,1544,1202, 483,2015, 592,2052,1958,2472,1655, 419, 129,4327,3444,3312,1714, // 2576 -1257,3078,4328,1518,1098, 865,1310,1019,1885,1512,1734, 469,2444, 148, 773, 436, // 2592 -1815,1868,1128,1055,4329,1245,2756,3445,2154,1934,1039,4643, 579,1238, 932,2320, // 2608 - 353, 205, 801, 115,2428, 944,2321,1881, 399,2565,1211, 678, 766,3944, 335,2101, // 2624 -1459,1781,1402,3945,2737,2131,1010, 844, 981,1326,1013, 550,1816,1545,2620,1335, // 2640 -1008, 371,2881, 936,1419,1613,3529,1456,1395,2273,1834,2604,1317,2738,2503, 416, // 2656 -1643,4330, 806,1126, 229, 591,3946,1314,1981,1576,1837,1666, 347,1790, 977,3313, // 2672 - 764,2861,1853, 688,2429,1920,1462, 77, 595, 415,2002,3034, 798,1192,4115,6144, // 2688 -2978,4331,3035,2695,2582,2072,2566, 430,2430,1727, 842,1396,3947,3702, 613, 377, // 2704 - 278, 236,1417,3388,3314,3174, 757,1869, 107,3530,6145,1194, 623,2262, 207,1253, // 2720 -2167,3446,3948, 492,1117,1935, 536,1838,2757,1246,4332, 696,2095,2406,1393,1572, // 2736 -3175,1782, 583, 190, 253,1390,2230, 830,3126,3389, 934,3245,1703,1749,2979,1870, // 2752 -2545,1656,2204, 869,2346,4116,3176,1817, 496,1764,4644, 942,1504, 404,1903,1122, // 2768 -1580,3606,2945,1022, 515, 372,1735, 955,2431,3036,6146,2797,1110,2302,2798, 617, // 2784 -6147, 441, 762,1771,3447,3607,3608,1904, 840,3037, 86, 939,1385, 572,1370,2445, // 2800 -1336, 114,3703, 898, 294, 203,3315, 703,1583,2274, 429, 961,4333,1854,1951,3390, // 2816 -2373,3704,4334,1318,1381, 966,1911,2322,1006,1155, 309, 989, 458,2718,1795,1372, // 2832 -1203, 252,1689,1363,3177, 517,1936, 168,1490, 562, 193,3823,1042,4117,1835, 551, // 2848 - 470,4645, 395, 489,3448,1871,1465,2583,2641, 417,1493, 279,1295, 511,1236,1119, // 2864 - 72,1231,1982,1812,3004, 871,1564, 984,3449,1667,2696,2096,4646,2347,2833,1673, // 2880 -3609, 695,3246,2668, 807,1183,4647, 890, 388,2333,1801,1457,2911,1765,1477,1031, // 2896 -3316,3317,1278,3391,2799,2292,2526, 163,3450,4335,2669,1404,1802,6148,2323,2407, // 2912 -1584,1728,1494,1824,1269, 298, 909,3318,1034,1632, 375, 776,1683,2061, 291, 210, // 2928 -1123, 809,1249,1002,2642,3038, 206,1011,2132, 144, 975, 882,1565, 342, 667, 754, // 2944 -1442,2143,1299,2303,2062, 447, 626,2205,1221,2739,2912,1144,1214,2206,2584, 760, // 2960 -1715, 614, 950,1281,2670,2621, 810, 577,1287,2546,4648, 242,2168, 250,2643, 691, // 2976 - 123,2644, 647, 313,1029, 689,1357,2946,1650, 216, 771,1339,1306, 808,2063, 549, // 2992 - 913,1371,2913,2914,6149,1466,1092,1174,1196,1311,2605,2396,1783,1796,3079, 406, // 3008 -2671,2117,3949,4649, 487,1825,2220,6150,2915, 448,2348,1073,6151,2397,1707, 130, // 3024 - 900,1598, 329, 176,1959,2527,1620,6152,2275,4336,3319,1983,2191,3705,3610,2155, // 3040 -3706,1912,1513,1614,6153,1988, 646, 392,2304,1589,3320,3039,1826,1239,1352,1340, // 3056 -2916, 505,2567,1709,1437,2408,2547, 906,6154,2672, 384,1458,1594,1100,1329, 710, // 3072 - 423,3531,2064,2231,2622,1989,2673,1087,1882, 333, 841,3005,1296,2882,2379, 580, // 3088 -1937,1827,1293,2585, 601, 574, 249,1772,4118,2079,1120, 645, 901,1176,1690, 795, // 3104 -2207, 478,1434, 516,1190,1530, 761,2080, 930,1264, 355, 435,1552, 644,1791, 987, // 3120 - 220,1364,1163,1121,1538, 306,2169,1327,1222, 546,2645, 218, 241, 610,1704,3321, // 3136 -1984,1839,1966,2528, 451,6155,2586,3707,2568, 907,3178, 254,2947, 186,1845,4650, // 3152 - 745, 432,1757, 428,1633, 888,2246,2221,2489,3611,2118,1258,1265, 956,3127,1784, // 3168 -4337,2490, 319, 510, 119, 457,3612, 274,2035,2007,4651,1409,3128, 970,2758, 590, // 3184 -2800, 661,2247,4652,2008,3950,1420,1549,3080,3322,3951,1651,1375,2111, 485,2491, // 3200 -1429,1156,6156,2548,2183,1495, 831,1840,2529,2446, 501,1657, 307,1894,3247,1341, // 3216 - 666, 899,2156,1539,2549,1559, 886, 349,2208,3081,2305,1736,3824,2170,2759,1014, // 3232 -1913,1386, 542,1397,2948, 490, 368, 716, 362, 159, 282,2569,1129,1658,1288,1750, // 3248 -2674, 276, 649,2016, 751,1496, 658,1818,1284,1862,2209,2087,2512,3451, 622,2834, // 3264 - 376, 117,1060,2053,1208,1721,1101,1443, 247,1250,3179,1792,3952,2760,2398,3953, // 3280 -6157,2144,3708, 446,2432,1151,2570,3452,2447,2761,2835,1210,2448,3082, 424,2222, // 3296 -1251,2449,2119,2836, 504,1581,4338, 602, 817, 857,3825,2349,2306, 357,3826,1470, // 3312 -1883,2883, 255, 958, 929,2917,3248, 302,4653,1050,1271,1751,2307,1952,1430,2697, // 3328 -2719,2359, 354,3180, 777, 158,2036,4339,1659,4340,4654,2308,2949,2248,1146,2232, // 3344 -3532,2720,1696,2623,3827,6158,3129,1550,2698,1485,1297,1428, 637, 931,2721,2145, // 3360 - 914,2550,2587, 81,2450, 612, 827,2646,1242,4655,1118,2884, 472,1855,3181,3533, // 3376 -3534, 569,1353,2699,1244,1758,2588,4119,2009,2762,2171,3709,1312,1531,6159,1152, // 3392 -1938, 134,1830, 471,3710,2276,1112,1535,3323,3453,3535, 982,1337,2950, 488, 826, // 3408 - 674,1058,1628,4120,2017, 522,2399, 211, 568,1367,3454, 350, 293,1872,1139,3249, // 3424 -1399,1946,3006,1300,2360,3324, 588, 736,6160,2606, 744, 669,3536,3828,6161,1358, // 3440 - 199, 723, 848, 933, 851,1939,1505,1514,1338,1618,1831,4656,1634,3613, 443,2740, // 3456 -3829, 717,1947, 491,1914,6162,2551,1542,4121,1025,6163,1099,1223, 198,3040,2722, // 3472 - 370, 410,1905,2589, 998,1248,3182,2380, 519,1449,4122,1710, 947, 928,1153,4341, // 3488 -2277, 344,2624,1511, 615, 105, 161,1212,1076,1960,3130,2054,1926,1175,1906,2473, // 3504 - 414,1873,2801,6164,2309, 315,1319,3325, 318,2018,2146,2157, 963, 631, 223,4342, // 3520 -4343,2675, 479,3711,1197,2625,3712,2676,2361,6165,4344,4123,6166,2451,3183,1886, // 3536 -2184,1674,1330,1711,1635,1506, 799, 219,3250,3083,3954,1677,3713,3326,2081,3614, // 3552 -1652,2073,4657,1147,3041,1752, 643,1961, 147,1974,3955,6167,1716,2037, 918,3007, // 3568 -1994, 120,1537, 118, 609,3184,4345, 740,3455,1219, 332,1615,3830,6168,1621,2980, // 3584 -1582, 783, 212, 553,2350,3714,1349,2433,2082,4124, 889,6169,2310,1275,1410, 973, // 3600 - 166,1320,3456,1797,1215,3185,2885,1846,2590,2763,4658, 629, 822,3008, 763, 940, // 3616 -1990,2862, 439,2409,1566,1240,1622, 926,1282,1907,2764, 654,2210,1607, 327,1130, // 3632 -3956,1678,1623,6170,2434,2192, 686, 608,3831,3715, 903,3957,3042,6171,2741,1522, // 3648 -1915,1105,1555,2552,1359, 323,3251,4346,3457, 738,1354,2553,2311,2334,1828,2003, // 3664 -3832,1753,2351,1227,6172,1887,4125,1478,6173,2410,1874,1712,1847, 520,1204,2607, // 3680 - 264,4659, 836,2677,2102, 600,4660,3833,2278,3084,6174,4347,3615,1342, 640, 532, // 3696 - 543,2608,1888,2400,2591,1009,4348,1497, 341,1737,3616,2723,1394, 529,3252,1321, // 3712 - 983,4661,1515,2120, 971,2592, 924, 287,1662,3186,4349,2700,4350,1519, 908,1948, // 3728 -2452, 156, 796,1629,1486,2223,2055, 694,4126,1259,1036,3392,1213,2249,2742,1889, // 3744 -1230,3958,1015, 910, 408, 559,3617,4662, 746, 725, 935,4663,3959,3009,1289, 563, // 3760 - 867,4664,3960,1567,2981,2038,2626, 988,2263,2381,4351, 143,2374, 704,1895,6175, // 3776 -1188,3716,2088, 673,3085,2362,4352, 484,1608,1921,2765,2918, 215, 904,3618,3537, // 3792 - 894, 509, 976,3043,2701,3961,4353,2837,2982, 498,6176,6177,1102,3538,1332,3393, // 3808 -1487,1636,1637, 233, 245,3962, 383, 650, 995,3044, 460,1520,1206,2352, 749,3327, // 3824 - 530, 700, 389,1438,1560,1773,3963,2264, 719,2951,2724,3834, 870,1832,1644,1000, // 3840 - 839,2474,3717, 197,1630,3394, 365,2886,3964,1285,2133, 734, 922, 818,1106, 732, // 3856 - 480,2083,1774,3458, 923,2279,1350, 221,3086, 85,2233,2234,3835,1585,3010,2147, // 3872 -1387,1705,2382,1619,2475, 133, 239,2802,1991,1016,2084,2383, 411,2838,1113, 651, // 3888 -1985,1160,3328, 990,1863,3087,1048,1276,2647, 265,2627,1599,3253,2056, 150, 638, // 3904 -2019, 656, 853, 326,1479, 680,1439,4354,1001,1759, 413,3459,3395,2492,1431, 459, // 3920 -4355,1125,3329,2265,1953,1450,2065,2863, 849, 351,2678,3131,3254,3255,1104,1577, // 3936 - 227,1351,1645,2453,2193,1421,2887, 812,2121, 634, 95,2435, 201,2312,4665,1646, // 3952 -1671,2743,1601,2554,2702,2648,2280,1315,1366,2089,3132,1573,3718,3965,1729,1189, // 3968 - 328,2679,1077,1940,1136, 558,1283, 964,1195, 621,2074,1199,1743,3460,3619,1896, // 3984 -1916,1890,3836,2952,1154,2112,1064, 862, 378,3011,2066,2113,2803,1568,2839,6178, // 4000 -3088,2919,1941,1660,2004,1992,2194, 142, 707,1590,1708,1624,1922,1023,1836,1233, // 4016 -1004,2313, 789, 741,3620,6179,1609,2411,1200,4127,3719,3720,4666,2057,3721, 593, // 4032 -2840, 367,2920,1878,6180,3461,1521, 628,1168, 692,2211,2649, 300, 720,2067,2571, // 4048 -2953,3396, 959,2504,3966,3539,3462,1977, 701,6181, 954,1043, 800, 681, 183,3722, // 4064 -1803,1730,3540,4128,2103, 815,2314, 174, 467, 230,2454,1093,2134, 755,3541,3397, // 4080 -1141,1162,6182,1738,2039, 270,3256,2513,1005,1647,2185,3837, 858,1679,1897,1719, // 4096 -2954,2324,1806, 402, 670, 167,4129,1498,2158,2104, 750,6183, 915, 189,1680,1551, // 4112 - 455,4356,1501,2455, 405,1095,2955, 338,1586,1266,1819, 570, 641,1324, 237,1556, // 4128 -2650,1388,3723,6184,1368,2384,1343,1978,3089,2436, 879,3724, 792,1191, 758,3012, // 4144 -1411,2135,1322,4357, 240,4667,1848,3725,1574,6185, 420,3045,1546,1391, 714,4358, // 4160 -1967, 941,1864, 863, 664, 426, 560,1731,2680,1785,2864,1949,2363, 403,3330,1415, // 4176 -1279,2136,1697,2335, 204, 721,2097,3838, 90,6186,2085,2505, 191,3967, 124,2148, // 4192 -1376,1798,1178,1107,1898,1405, 860,4359,1243,1272,2375,2983,1558,2456,1638, 113, // 4208 -3621, 578,1923,2609, 880, 386,4130, 784,2186,2266,1422,2956,2172,1722, 497, 263, // 4224 -2514,1267,2412,2610, 177,2703,3542, 774,1927,1344, 616,1432,1595,1018, 172,4360, // 4240 -2325, 911,4361, 438,1468,3622, 794,3968,2024,2173,1681,1829,2957, 945, 895,3090, // 4256 - 575,2212,2476, 475,2401,2681, 785,2744,1745,2293,2555,1975,3133,2865, 394,4668, // 4272 -3839, 635,4131, 639, 202,1507,2195,2766,1345,1435,2572,3726,1908,1184,1181,2457, // 4288 -3727,3134,4362, 843,2611, 437, 916,4669, 234, 769,1884,3046,3047,3623, 833,6187, // 4304 -1639,2250,2402,1355,1185,2010,2047, 999, 525,1732,1290,1488,2612, 948,1578,3728, // 4320 -2413,2477,1216,2725,2159, 334,3840,1328,3624,2921,1525,4132, 564,1056, 891,4363, // 4336 -1444,1698,2385,2251,3729,1365,2281,2235,1717,6188, 864,3841,2515, 444, 527,2767, // 4352 -2922,3625, 544, 461,6189, 566, 209,2437,3398,2098,1065,2068,3331,3626,3257,2137, // 4368 //last 512 - -/*************************************************************************************** - *Everything below is of no interest for detection purpose * - *************************************************************************************** - -2138,2122,3730,2888,1995,1820,1044,6190,6191,6192,6193,6194,6195,6196,6197,6198, // 4384 -6199,6200,6201,6202,6203,6204,6205,4670,6206,6207,6208,6209,6210,6211,6212,6213, // 4400 -6214,6215,6216,6217,6218,6219,6220,6221,6222,6223,6224,6225,6226,6227,6228,6229, // 4416 -6230,6231,6232,6233,6234,6235,6236,6237,3187,6238,6239,3969,6240,6241,6242,6243, // 4432 -6244,4671,6245,6246,4672,6247,6248,4133,6249,6250,4364,6251,2923,2556,2613,4673, // 4448 -4365,3970,6252,6253,6254,6255,4674,6256,6257,6258,2768,2353,4366,4675,4676,3188, // 4464 -4367,3463,6259,4134,4677,4678,6260,2267,6261,3842,3332,4368,3543,6262,6263,6264, // 4480 -3013,1954,1928,4135,4679,6265,6266,2478,3091,6267,4680,4369,6268,6269,1699,6270, // 4496 -3544,4136,4681,6271,4137,6272,4370,2804,6273,6274,2593,3971,3972,4682,6275,2236, // 4512 -4683,6276,6277,4684,6278,6279,4138,3973,4685,6280,6281,3258,6282,6283,6284,6285, // 4528 -3974,4686,2841,3975,6286,6287,3545,6288,6289,4139,4687,4140,6290,4141,6291,4142, // 4544 -6292,6293,3333,6294,6295,6296,4371,6297,3399,6298,6299,4372,3976,6300,6301,6302, // 4560 -4373,6303,6304,3843,3731,6305,4688,4374,6306,6307,3259,2294,6308,3732,2530,4143, // 4576 -6309,4689,6310,6311,6312,3048,6313,6314,4690,3733,2237,6315,6316,2282,3334,6317, // 4592 -6318,3844,6319,6320,4691,6321,3400,4692,6322,4693,6323,3049,6324,4375,6325,3977, // 4608 -6326,6327,6328,3546,6329,4694,3335,6330,4695,4696,6331,6332,6333,6334,4376,3978, // 4624 -6335,4697,3979,4144,6336,3980,4698,6337,6338,6339,6340,6341,4699,4700,4701,6342, // 4640 -6343,4702,6344,6345,4703,6346,6347,4704,6348,4705,4706,3135,6349,4707,6350,4708, // 4656 -6351,4377,6352,4709,3734,4145,6353,2506,4710,3189,6354,3050,4711,3981,6355,3547, // 4672 -3014,4146,4378,3735,2651,3845,3260,3136,2224,1986,6356,3401,6357,4712,2594,3627, // 4688 -3137,2573,3736,3982,4713,3628,4714,4715,2682,3629,4716,6358,3630,4379,3631,6359, // 4704 -6360,6361,3983,6362,6363,6364,6365,4147,3846,4717,6366,6367,3737,2842,6368,4718, // 4720 -2628,6369,3261,6370,2386,6371,6372,3738,3984,4719,3464,4720,3402,6373,2924,3336, // 4736 -4148,2866,6374,2805,3262,4380,2704,2069,2531,3138,2806,2984,6375,2769,6376,4721, // 4752 -4722,3403,6377,6378,3548,6379,6380,2705,3092,1979,4149,2629,3337,2889,6381,3338, // 4768 -4150,2557,3339,4381,6382,3190,3263,3739,6383,4151,4723,4152,2558,2574,3404,3191, // 4784 -6384,6385,4153,6386,4724,4382,6387,6388,4383,6389,6390,4154,6391,4725,3985,6392, // 4800 -3847,4155,6393,6394,6395,6396,6397,3465,6398,4384,6399,6400,6401,6402,6403,6404, // 4816 -4156,6405,6406,6407,6408,2123,6409,6410,2326,3192,4726,6411,6412,6413,6414,4385, // 4832 -4157,6415,6416,4158,6417,3093,3848,6418,3986,6419,6420,3849,6421,6422,6423,4159, // 4848 -6424,6425,4160,6426,3740,6427,6428,6429,6430,3987,6431,4727,6432,2238,6433,6434, // 4864 -4386,3988,6435,6436,3632,6437,6438,2843,6439,6440,6441,6442,3633,6443,2958,6444, // 4880 -6445,3466,6446,2364,4387,3850,6447,4388,2959,3340,6448,3851,6449,4728,6450,6451, // 4896 -3264,4729,6452,3193,6453,4389,4390,2706,3341,4730,6454,3139,6455,3194,6456,3051, // 4912 -2124,3852,1602,4391,4161,3853,1158,3854,4162,3989,4392,3990,4731,4732,4393,2040, // 4928 -4163,4394,3265,6457,2807,3467,3855,6458,6459,6460,3991,3468,4733,4734,6461,3140, // 4944 -2960,6462,4735,6463,6464,6465,6466,4736,4737,4738,4739,6467,6468,4164,2403,3856, // 4960 -6469,6470,2770,2844,6471,4740,6472,6473,6474,6475,6476,6477,6478,3195,6479,4741, // 4976 -4395,6480,2867,6481,4742,2808,6482,2493,4165,6483,6484,6485,6486,2295,4743,6487, // 4992 -6488,6489,3634,6490,6491,6492,6493,6494,6495,6496,2985,4744,6497,6498,4745,6499, // 5008 -6500,2925,3141,4166,6501,6502,4746,6503,6504,4747,6505,6506,6507,2890,6508,6509, // 5024 -6510,6511,6512,6513,6514,6515,6516,6517,6518,6519,3469,4167,6520,6521,6522,4748, // 5040 -4396,3741,4397,4749,4398,3342,2125,4750,6523,4751,4752,4753,3052,6524,2961,4168, // 5056 -6525,4754,6526,4755,4399,2926,4169,6527,3857,6528,4400,4170,6529,4171,6530,6531, // 5072 -2595,6532,6533,6534,6535,3635,6536,6537,6538,6539,6540,6541,6542,4756,6543,6544, // 5088 -6545,6546,6547,6548,4401,6549,6550,6551,6552,4402,3405,4757,4403,6553,6554,6555, // 5104 -4172,3742,6556,6557,6558,3992,3636,6559,6560,3053,2726,6561,3549,4173,3054,4404, // 5120 -6562,6563,3993,4405,3266,3550,2809,4406,6564,6565,6566,4758,4759,6567,3743,6568, // 5136 -4760,3744,4761,3470,6569,6570,6571,4407,6572,3745,4174,6573,4175,2810,4176,3196, // 5152 -4762,6574,4177,6575,6576,2494,2891,3551,6577,6578,3471,6579,4408,6580,3015,3197, // 5168 -6581,3343,2532,3994,3858,6582,3094,3406,4409,6583,2892,4178,4763,4410,3016,4411, // 5184 -6584,3995,3142,3017,2683,6585,4179,6586,6587,4764,4412,6588,6589,4413,6590,2986, // 5200 -6591,2962,3552,6592,2963,3472,6593,6594,4180,4765,6595,6596,2225,3267,4414,6597, // 5216 -3407,3637,4766,6598,6599,3198,6600,4415,6601,3859,3199,6602,3473,4767,2811,4416, // 5232 -1856,3268,3200,2575,3996,3997,3201,4417,6603,3095,2927,6604,3143,6605,2268,6606, // 5248 -3998,3860,3096,2771,6607,6608,3638,2495,4768,6609,3861,6610,3269,2745,4769,4181, // 5264 -3553,6611,2845,3270,6612,6613,6614,3862,6615,6616,4770,4771,6617,3474,3999,4418, // 5280 -4419,6618,3639,3344,6619,4772,4182,6620,2126,6621,6622,6623,4420,4773,6624,3018, // 5296 -6625,4774,3554,6626,4183,2025,3746,6627,4184,2707,6628,4421,4422,3097,1775,4185, // 5312 -3555,6629,6630,2868,6631,6632,4423,6633,6634,4424,2414,2533,2928,6635,4186,2387, // 5328 -6636,4775,6637,4187,6638,1891,4425,3202,3203,6639,6640,4776,6641,3345,6642,6643, // 5344 -3640,6644,3475,3346,3641,4000,6645,3144,6646,3098,2812,4188,3642,3204,6647,3863, // 5360 -3476,6648,3864,6649,4426,4001,6650,6651,6652,2576,6653,4189,4777,6654,6655,6656, // 5376 -2846,6657,3477,3205,4002,6658,4003,6659,3347,2252,6660,6661,6662,4778,6663,6664, // 5392 -6665,6666,6667,6668,6669,4779,4780,2048,6670,3478,3099,6671,3556,3747,4004,6672, // 5408 -6673,6674,3145,4005,3748,6675,6676,6677,6678,6679,3408,6680,6681,6682,6683,3206, // 5424 -3207,6684,6685,4781,4427,6686,4782,4783,4784,6687,6688,6689,4190,6690,6691,3479, // 5440 -6692,2746,6693,4428,6694,6695,6696,6697,6698,6699,4785,6700,6701,3208,2727,6702, // 5456 -3146,6703,6704,3409,2196,6705,4429,6706,6707,6708,2534,1996,6709,6710,6711,2747, // 5472 -6712,6713,6714,4786,3643,6715,4430,4431,6716,3557,6717,4432,4433,6718,6719,6720, // 5488 -6721,3749,6722,4006,4787,6723,6724,3644,4788,4434,6725,6726,4789,2772,6727,6728, // 5504 -6729,6730,6731,2708,3865,2813,4435,6732,6733,4790,4791,3480,6734,6735,6736,6737, // 5520 -4436,3348,6738,3410,4007,6739,6740,4008,6741,6742,4792,3411,4191,6743,6744,6745, // 5536 -6746,6747,3866,6748,3750,6749,6750,6751,6752,6753,6754,6755,3867,6756,4009,6757, // 5552 -4793,4794,6758,2814,2987,6759,6760,6761,4437,6762,6763,6764,6765,3645,6766,6767, // 5568 -3481,4192,6768,3751,6769,6770,2174,6771,3868,3752,6772,6773,6774,4193,4795,4438, // 5584 -3558,4796,4439,6775,4797,6776,6777,4798,6778,4799,3559,4800,6779,6780,6781,3482, // 5600 -6782,2893,6783,6784,4194,4801,4010,6785,6786,4440,6787,4011,6788,6789,6790,6791, // 5616 -6792,6793,4802,6794,6795,6796,4012,6797,6798,6799,6800,3349,4803,3483,6801,4804, // 5632 -4195,6802,4013,6803,6804,4196,6805,4014,4015,6806,2847,3271,2848,6807,3484,6808, // 5648 -6809,6810,4441,6811,4442,4197,4443,3272,4805,6812,3412,4016,1579,6813,6814,4017, // 5664 -6815,3869,6816,2964,6817,4806,6818,6819,4018,3646,6820,6821,4807,4019,4020,6822, // 5680 -6823,3560,6824,6825,4021,4444,6826,4198,6827,6828,4445,6829,6830,4199,4808,6831, // 5696 -6832,6833,3870,3019,2458,6834,3753,3413,3350,6835,4809,3871,4810,3561,4446,6836, // 5712 -6837,4447,4811,4812,6838,2459,4448,6839,4449,6840,6841,4022,3872,6842,4813,4814, // 5728 -6843,6844,4815,4200,4201,4202,6845,4023,6846,6847,4450,3562,3873,6848,6849,4816, // 5744 -4817,6850,4451,4818,2139,6851,3563,6852,6853,3351,6854,6855,3352,4024,2709,3414, // 5760 -4203,4452,6856,4204,6857,6858,3874,3875,6859,6860,4819,6861,6862,6863,6864,4453, // 5776 -3647,6865,6866,4820,6867,6868,6869,6870,4454,6871,2869,6872,6873,4821,6874,3754, // 5792 -6875,4822,4205,6876,6877,6878,3648,4206,4455,6879,4823,6880,4824,3876,6881,3055, // 5808 -4207,6882,3415,6883,6884,6885,4208,4209,6886,4210,3353,6887,3354,3564,3209,3485, // 5824 -2652,6888,2728,6889,3210,3755,6890,4025,4456,6891,4825,6892,6893,6894,6895,4211, // 5840 -6896,6897,6898,4826,6899,6900,4212,6901,4827,6902,2773,3565,6903,4828,6904,6905, // 5856 -6906,6907,3649,3650,6908,2849,3566,6909,3567,3100,6910,6911,6912,6913,6914,6915, // 5872 -4026,6916,3355,4829,3056,4457,3756,6917,3651,6918,4213,3652,2870,6919,4458,6920, // 5888 -2438,6921,6922,3757,2774,4830,6923,3356,4831,4832,6924,4833,4459,3653,2507,6925, // 5904 -4834,2535,6926,6927,3273,4027,3147,6928,3568,6929,6930,6931,4460,6932,3877,4461, // 5920 -2729,3654,6933,6934,6935,6936,2175,4835,2630,4214,4028,4462,4836,4215,6937,3148, // 5936 -4216,4463,4837,4838,4217,6938,6939,2850,4839,6940,4464,6941,6942,6943,4840,6944, // 5952 -4218,3274,4465,6945,6946,2710,6947,4841,4466,6948,6949,2894,6950,6951,4842,6952, // 5968 -4219,3057,2871,6953,6954,6955,6956,4467,6957,2711,6958,6959,6960,3275,3101,4843, // 5984 -6961,3357,3569,6962,4844,6963,6964,4468,4845,3570,6965,3102,4846,3758,6966,4847, // 6000 -3878,4848,4849,4029,6967,2929,3879,4850,4851,6968,6969,1733,6970,4220,6971,6972, // 6016 -6973,6974,6975,6976,4852,6977,6978,6979,6980,6981,6982,3759,6983,6984,6985,3486, // 6032 -3487,6986,3488,3416,6987,6988,6989,6990,6991,6992,6993,6994,6995,6996,6997,4853, // 6048 -6998,6999,4030,7000,7001,3211,7002,7003,4221,7004,7005,3571,4031,7006,3572,7007, // 6064 -2614,4854,2577,7008,7009,2965,3655,3656,4855,2775,3489,3880,4222,4856,3881,4032, // 6080 -3882,3657,2730,3490,4857,7010,3149,7011,4469,4858,2496,3491,4859,2283,7012,7013, // 6096 -7014,2365,4860,4470,7015,7016,3760,7017,7018,4223,1917,7019,7020,7021,4471,7022, // 6112 -2776,4472,7023,7024,7025,7026,4033,7027,3573,4224,4861,4034,4862,7028,7029,1929, // 6128 -3883,4035,7030,4473,3058,7031,2536,3761,3884,7032,4036,7033,2966,2895,1968,4474, // 6144 -3276,4225,3417,3492,4226,2105,7034,7035,1754,2596,3762,4227,4863,4475,3763,4864, // 6160 -3764,2615,2777,3103,3765,3658,3418,4865,2296,3766,2815,7036,7037,7038,3574,2872, // 6176 -3277,4476,7039,4037,4477,7040,7041,4038,7042,7043,7044,7045,7046,7047,2537,7048, // 6192 -7049,7050,7051,7052,7053,7054,4478,7055,7056,3767,3659,4228,3575,7057,7058,4229, // 6208 -7059,7060,7061,3660,7062,3212,7063,3885,4039,2460,7064,7065,7066,7067,7068,7069, // 6224 -7070,7071,7072,7073,7074,4866,3768,4867,7075,7076,7077,7078,4868,3358,3278,2653, // 6240 -7079,7080,4479,3886,7081,7082,4869,7083,7084,7085,7086,7087,7088,2538,7089,7090, // 6256 -7091,4040,3150,3769,4870,4041,2896,3359,4230,2930,7092,3279,7093,2967,4480,3213, // 6272 -4481,3661,7094,7095,7096,7097,7098,7099,7100,7101,7102,2461,3770,7103,7104,4231, // 6288 -3151,7105,7106,7107,4042,3662,7108,7109,4871,3663,4872,4043,3059,7110,7111,7112, // 6304 -3493,2988,7113,4873,7114,7115,7116,3771,4874,7117,7118,4232,4875,7119,3576,2336, // 6320 -4876,7120,4233,3419,4044,4877,4878,4482,4483,4879,4484,4234,7121,3772,4880,1045, // 6336 -3280,3664,4881,4882,7122,7123,7124,7125,4883,7126,2778,7127,4485,4486,7128,4884, // 6352 -3214,3887,7129,7130,3215,7131,4885,4045,7132,7133,4046,7134,7135,7136,7137,7138, // 6368 -7139,7140,7141,7142,7143,4235,7144,4886,7145,7146,7147,4887,7148,7149,7150,4487, // 6384 -4047,4488,7151,7152,4888,4048,2989,3888,7153,3665,7154,4049,7155,7156,7157,7158, // 6400 -7159,7160,2931,4889,4890,4489,7161,2631,3889,4236,2779,7162,7163,4891,7164,3060, // 6416 -7165,1672,4892,7166,4893,4237,3281,4894,7167,7168,3666,7169,3494,7170,7171,4050, // 6432 -7172,7173,3104,3360,3420,4490,4051,2684,4052,7174,4053,7175,7176,7177,2253,4054, // 6448 -7178,7179,4895,7180,3152,3890,3153,4491,3216,7181,7182,7183,2968,4238,4492,4055, // 6464 -7184,2990,7185,2479,7186,7187,4493,7188,7189,7190,7191,7192,4896,7193,4897,2969, // 6480 -4494,4898,7194,3495,7195,7196,4899,4495,7197,3105,2731,7198,4900,7199,7200,7201, // 6496 -4056,7202,3361,7203,7204,4496,4901,4902,7205,4497,7206,7207,2315,4903,7208,4904, // 6512 -7209,4905,2851,7210,7211,3577,7212,3578,4906,7213,4057,3667,4907,7214,4058,2354, // 6528 -3891,2376,3217,3773,7215,7216,7217,7218,7219,4498,7220,4908,3282,2685,7221,3496, // 6544 -4909,2632,3154,4910,7222,2337,7223,4911,7224,7225,7226,4912,4913,3283,4239,4499, // 6560 -7227,2816,7228,7229,7230,7231,7232,7233,7234,4914,4500,4501,7235,7236,7237,2686, // 6576 -7238,4915,7239,2897,4502,7240,4503,7241,2516,7242,4504,3362,3218,7243,7244,7245, // 6592 -4916,7246,7247,4505,3363,7248,7249,7250,7251,3774,4506,7252,7253,4917,7254,7255, // 6608 -3284,2991,4918,4919,3219,3892,4920,3106,3497,4921,7256,7257,7258,4922,7259,4923, // 6624 -3364,4507,4508,4059,7260,4240,3498,7261,7262,4924,7263,2992,3893,4060,3220,7264, // 6640 -7265,7266,7267,7268,7269,4509,3775,7270,2817,7271,4061,4925,4510,3776,7272,4241, // 6656 -4511,3285,7273,7274,3499,7275,7276,7277,4062,4512,4926,7278,3107,3894,7279,7280, // 6672 -4927,7281,4513,7282,7283,3668,7284,7285,4242,4514,4243,7286,2058,4515,4928,4929, // 6688 -4516,7287,3286,4244,7288,4517,7289,7290,7291,3669,7292,7293,4930,4931,4932,2355, // 6704 -4933,7294,2633,4518,7295,4245,7296,7297,4519,7298,7299,4520,4521,4934,7300,4246, // 6720 -4522,7301,7302,7303,3579,7304,4247,4935,7305,4936,7306,7307,7308,7309,3777,7310, // 6736 -4523,7311,7312,7313,4248,3580,7314,4524,3778,4249,7315,3581,7316,3287,7317,3221, // 6752 -7318,4937,7319,7320,7321,7322,7323,7324,4938,4939,7325,4525,7326,7327,7328,4063, // 6768 -7329,7330,4940,7331,7332,4941,7333,4526,7334,3500,2780,1741,4942,2026,1742,7335, // 6784 -7336,3582,4527,2388,7337,7338,7339,4528,7340,4250,4943,7341,7342,7343,4944,7344, // 6800 -7345,7346,3020,7347,4945,7348,7349,7350,7351,3895,7352,3896,4064,3897,7353,7354, // 6816 -7355,4251,7356,7357,3898,7358,3779,7359,3780,3288,7360,7361,4529,7362,4946,4530, // 6832 -2027,7363,3899,4531,4947,3222,3583,7364,4948,7365,7366,7367,7368,4949,3501,4950, // 6848 -3781,4951,4532,7369,2517,4952,4252,4953,3155,7370,4954,4955,4253,2518,4533,7371, // 6864 -7372,2712,4254,7373,7374,7375,3670,4956,3671,7376,2389,3502,4065,7377,2338,7378, // 6880 -7379,7380,7381,3061,7382,4957,7383,7384,7385,7386,4958,4534,7387,7388,2993,7389, // 6896 -3062,7390,4959,7391,7392,7393,4960,3108,4961,7394,4535,7395,4962,3421,4536,7396, // 6912 -4963,7397,4964,1857,7398,4965,7399,7400,2176,3584,4966,7401,7402,3422,4537,3900, // 6928 -3585,7403,3782,7404,2852,7405,7406,7407,4538,3783,2654,3423,4967,4539,7408,3784, // 6944 -3586,2853,4540,4541,7409,3901,7410,3902,7411,7412,3785,3109,2327,3903,7413,7414, // 6960 -2970,4066,2932,7415,7416,7417,3904,3672,3424,7418,4542,4543,4544,7419,4968,7420, // 6976 -7421,4255,7422,7423,7424,7425,7426,4067,7427,3673,3365,4545,7428,3110,2559,3674, // 6992 -7429,7430,3156,7431,7432,3503,7433,3425,4546,7434,3063,2873,7435,3223,4969,4547, // 7008 -4548,2898,4256,4068,7436,4069,3587,3786,2933,3787,4257,4970,4971,3788,7437,4972, // 7024 -3064,7438,4549,7439,7440,7441,7442,7443,4973,3905,7444,2874,7445,7446,7447,7448, // 7040 -3021,7449,4550,3906,3588,4974,7450,7451,3789,3675,7452,2578,7453,4070,7454,7455, // 7056 -7456,4258,3676,7457,4975,7458,4976,4259,3790,3504,2634,4977,3677,4551,4260,7459, // 7072 -7460,7461,7462,3907,4261,4978,7463,7464,7465,7466,4979,4980,7467,7468,2213,4262, // 7088 -7469,7470,7471,3678,4981,7472,2439,7473,4263,3224,3289,7474,3908,2415,4982,7475, // 7104 -4264,7476,4983,2655,7477,7478,2732,4552,2854,2875,7479,7480,4265,7481,4553,4984, // 7120 -7482,7483,4266,7484,3679,3366,3680,2818,2781,2782,3367,3589,4554,3065,7485,4071, // 7136 -2899,7486,7487,3157,2462,4072,4555,4073,4985,4986,3111,4267,2687,3368,4556,4074, // 7152 -3791,4268,7488,3909,2783,7489,2656,1962,3158,4557,4987,1963,3159,3160,7490,3112, // 7168 -4988,4989,3022,4990,4991,3792,2855,7491,7492,2971,4558,7493,7494,4992,7495,7496, // 7184 -7497,7498,4993,7499,3426,4559,4994,7500,3681,4560,4269,4270,3910,7501,4075,4995, // 7200 -4271,7502,7503,4076,7504,4996,7505,3225,4997,4272,4077,2819,3023,7506,7507,2733, // 7216 -4561,7508,4562,7509,3369,3793,7510,3590,2508,7511,7512,4273,3113,2994,2616,7513, // 7232 -7514,7515,7516,7517,7518,2820,3911,4078,2748,7519,7520,4563,4998,7521,7522,7523, // 7248 -7524,4999,4274,7525,4564,3682,2239,4079,4565,7526,7527,7528,7529,5000,7530,7531, // 7264 -5001,4275,3794,7532,7533,7534,3066,5002,4566,3161,7535,7536,4080,7537,3162,7538, // 7280 -7539,4567,7540,7541,7542,7543,7544,7545,5003,7546,4568,7547,7548,7549,7550,7551, // 7296 -7552,7553,7554,7555,7556,5004,7557,7558,7559,5005,7560,3795,7561,4569,7562,7563, // 7312 -7564,2821,3796,4276,4277,4081,7565,2876,7566,5006,7567,7568,2900,7569,3797,3912, // 7328 -7570,7571,7572,4278,7573,7574,7575,5007,7576,7577,5008,7578,7579,4279,2934,7580, // 7344 -7581,5009,7582,4570,7583,4280,7584,7585,7586,4571,4572,3913,7587,4573,3505,7588, // 7360 -5010,7589,7590,7591,7592,3798,4574,7593,7594,5011,7595,4281,7596,7597,7598,4282, // 7376 -5012,7599,7600,5013,3163,7601,5014,7602,3914,7603,7604,2734,4575,4576,4577,7605, // 7392 -7606,7607,7608,7609,3506,5015,4578,7610,4082,7611,2822,2901,2579,3683,3024,4579, // 7408 -3507,7612,4580,7613,3226,3799,5016,7614,7615,7616,7617,7618,7619,7620,2995,3290, // 7424 -7621,4083,7622,5017,7623,7624,7625,7626,7627,4581,3915,7628,3291,7629,5018,7630, // 7440 -7631,7632,7633,4084,7634,7635,3427,3800,7636,7637,4582,7638,5019,4583,5020,7639, // 7456 -3916,7640,3801,5021,4584,4283,7641,7642,3428,3591,2269,7643,2617,7644,4585,3592, // 7472 -7645,4586,2902,7646,7647,3227,5022,7648,4587,7649,4284,7650,7651,7652,4588,2284, // 7488 -7653,5023,7654,7655,7656,4589,5024,3802,7657,7658,5025,3508,4590,7659,7660,7661, // 7504 -1969,5026,7662,7663,3684,1821,2688,7664,2028,2509,4285,7665,2823,1841,7666,2689, // 7520 -3114,7667,3917,4085,2160,5027,5028,2972,7668,5029,7669,7670,7671,3593,4086,7672, // 7536 -4591,4087,5030,3803,7673,7674,7675,7676,7677,7678,7679,4286,2366,4592,4593,3067, // 7552 -2328,7680,7681,4594,3594,3918,2029,4287,7682,5031,3919,3370,4288,4595,2856,7683, // 7568 -3509,7684,7685,5032,5033,7686,7687,3804,2784,7688,7689,7690,7691,3371,7692,7693, // 7584 -2877,5034,7694,7695,3920,4289,4088,7696,7697,7698,5035,7699,5036,4290,5037,5038, // 7600 -5039,7700,7701,7702,5040,5041,3228,7703,1760,7704,5042,3229,4596,2106,4089,7705, // 7616 -4597,2824,5043,2107,3372,7706,4291,4090,5044,7707,4091,7708,5045,3025,3805,4598, // 7632 -4292,4293,4294,3373,7709,4599,7710,5046,7711,7712,5047,5048,3806,7713,7714,7715, // 7648 -5049,7716,7717,7718,7719,4600,5050,7720,7721,7722,5051,7723,4295,3429,7724,7725, // 7664 -7726,7727,3921,7728,3292,5052,4092,7729,7730,7731,7732,7733,7734,7735,5053,5054, // 7680 -7736,7737,7738,7739,3922,3685,7740,7741,7742,7743,2635,5055,7744,5056,4601,7745, // 7696 -7746,2560,7747,7748,7749,7750,3923,7751,7752,7753,7754,7755,4296,2903,7756,7757, // 7712 -7758,7759,7760,3924,7761,5057,4297,7762,7763,5058,4298,7764,4093,7765,7766,5059, // 7728 -3925,7767,7768,7769,7770,7771,7772,7773,7774,7775,7776,3595,7777,4299,5060,4094, // 7744 -7778,3293,5061,7779,7780,4300,7781,7782,4602,7783,3596,7784,7785,3430,2367,7786, // 7760 -3164,5062,5063,4301,7787,7788,4095,5064,5065,7789,3374,3115,7790,7791,7792,7793, // 7776 -7794,7795,7796,3597,4603,7797,7798,3686,3116,3807,5066,7799,7800,5067,7801,7802, // 7792 -4604,4302,5068,4303,4096,7803,7804,3294,7805,7806,5069,4605,2690,7807,3026,7808, // 7808 -7809,7810,7811,7812,7813,7814,7815,7816,7817,7818,7819,7820,7821,7822,7823,7824, // 7824 -7825,7826,7827,7828,7829,7830,7831,7832,7833,7834,7835,7836,7837,7838,7839,7840, // 7840 -7841,7842,7843,7844,7845,7846,7847,7848,7849,7850,7851,7852,7853,7854,7855,7856, // 7856 -7857,7858,7859,7860,7861,7862,7863,7864,7865,7866,7867,7868,7869,7870,7871,7872, // 7872 -7873,7874,7875,7876,7877,7878,7879,7880,7881,7882,7883,7884,7885,7886,7887,7888, // 7888 -7889,7890,7891,7892,7893,7894,7895,7896,7897,7898,7899,7900,7901,7902,7903,7904, // 7904 -7905,7906,7907,7908,7909,7910,7911,7912,7913,7914,7915,7916,7917,7918,7919,7920, // 7920 -7921,7922,7923,7924,3926,7925,7926,7927,7928,7929,7930,7931,7932,7933,7934,7935, // 7936 -7936,7937,7938,7939,7940,7941,7942,7943,7944,7945,7946,7947,7948,7949,7950,7951, // 7952 -7952,7953,7954,7955,7956,7957,7958,7959,7960,7961,7962,7963,7964,7965,7966,7967, // 7968 -7968,7969,7970,7971,7972,7973,7974,7975,7976,7977,7978,7979,7980,7981,7982,7983, // 7984 -7984,7985,7986,7987,7988,7989,7990,7991,7992,7993,7994,7995,7996,7997,7998,7999, // 8000 -8000,8001,8002,8003,8004,8005,8006,8007,8008,8009,8010,8011,8012,8013,8014,8015, // 8016 -8016,8017,8018,8019,8020,8021,8022,8023,8024,8025,8026,8027,8028,8029,8030,8031, // 8032 -8032,8033,8034,8035,8036,8037,8038,8039,8040,8041,8042,8043,8044,8045,8046,8047, // 8048 -8048,8049,8050,8051,8052,8053,8054,8055,8056,8057,8058,8059,8060,8061,8062,8063, // 8064 -8064,8065,8066,8067,8068,8069,8070,8071,8072,8073,8074,8075,8076,8077,8078,8079, // 8080 -8080,8081,8082,8083,8084,8085,8086,8087,8088,8089,8090,8091,8092,8093,8094,8095, // 8096 -8096,8097,8098,8099,8100,8101,8102,8103,8104,8105,8106,8107,8108,8109,8110,8111, // 8112 -8112,8113,8114,8115,8116,8117,8118,8119,8120,8121,8122,8123,8124,8125,8126,8127, // 8128 -8128,8129,8130,8131,8132,8133,8134,8135,8136,8137,8138,8139,8140,8141,8142,8143, // 8144 -8144,8145,8146,8147,8148,8149,8150,8151,8152,8153,8154,8155,8156,8157,8158,8159, // 8160 -8160,8161,8162,8163,8164,8165,8166,8167,8168,8169,8170,8171,8172,8173,8174,8175, // 8176 -8176,8177,8178,8179,8180,8181,8182,8183,8184,8185,8186,8187,8188,8189,8190,8191, // 8192 -8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8203,8204,8205,8206,8207, // 8208 -8208,8209,8210,8211,8212,8213,8214,8215,8216,8217,8218,8219,8220,8221,8222,8223, // 8224 -8224,8225,8226,8227,8228,8229,8230,8231,8232,8233,8234,8235,8236,8237,8238,8239, // 8240 -8240,8241,8242,8243,8244,8245,8246,8247,8248,8249,8250,8251,8252,8253,8254,8255, // 8256 -8256,8257,8258,8259,8260,8261,8262,8263,8264,8265,8266,8267,8268,8269,8270,8271, // 8272 -****************************************************************************************/ - -}; - diff --git a/amarok/utilities/updatesigner/CMakeLists.txt b/amarok/utilities/updatesigner/CMakeLists.txt deleted file mode 100644 index 7f7524c4..00000000 --- a/amarok/utilities/updatesigner/CMakeLists.txt +++ /dev/null @@ -1,29 +0,0 @@ -project(Amarok-Update-Signer) - -cmake_minimum_required(VERSION 2.6.2) - -find_package(KDE4 REQUIRED) #Needed for the QCA2 check to work -find_package(QCA2 REQUIRED) - -# we need the QtCrypto library for the signer -if( QCA2_FOUND ) - include_directories( - ${QT_INCLUDES} - ${CMAKE_CURRENT_BINARY_DIR} - ${QCA2_INCLUDE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/shared - ) - - set(amarok-update-signer_SRCS signer.cpp amarok-update-signer.cpp) - qt4_automoc(${amarok-update-signer_SRCS}) - add_executable(amarok-update-signer ${amarok-update-signer_SRCS}) - target_link_libraries(amarok-update-signer ${QT_QTCORE_LIBRARY} ${QCA2_LIBRARIES}) - - if(APPLE) - SET_TARGET_PROPERTIES(amarok-update-signer PROPERTIES LINK_FLAGS "-undefined dynamic_lookup") - # install to app bundle on os x, otherwise amarok fails to load it - install(TARGETS amarok-update-signer DESTINATION ${BUNDLE_INSTALL_DIR}/Amarok.app/Contents/MacOS ) - else(APPLE) - install(TARGETS amarok-update-signer RUNTIME DESTINATION ${BIN_INSTALL_DIR} ) - endif(APPLE) -endif( QCA2_FOUND ) diff --git a/amarok/utilities/updatesigner/amarok-update-signer.cpp b/amarok/utilities/updatesigner/amarok-update-signer.cpp deleted file mode 100644 index f084fa2c..00000000 --- a/amarok/utilities/updatesigner/amarok-update-signer.cpp +++ /dev/null @@ -1,32 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Jakob Kummerow * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include - - -#include "signer.h" - - -int main(int argc, char** argv) -{ - QCoreApplication app(argc, argv); - signer sig; - if (sig.setParams(argc, argv)) { - return app.exec(); - } else { - return 0; - } -} diff --git a/amarok/utilities/updatesigner/signer.cpp b/amarok/utilities/updatesigner/signer.cpp deleted file mode 100644 index 9a7d3cfd..00000000 --- a/amarok/utilities/updatesigner/signer.cpp +++ /dev/null @@ -1,205 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Jakob Kummerow * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#include "signer.h" - -#include "../../shared/ScriptUpdaterStatic.h" - -#include -#include -#include - -#include - -signer::signer() -{ -} - -signer::~signer() -{} - -bool signer::setParams(int argc, char** argv) -{ - if (argc > 1) { - - // first code block: generate key pair and save to local files - if ( strcmp( argv[1], "keygen" ) == 0 ) { - QTimer::singleShot( 0, this, SLOT(keygen()) ); - return 1; - - // second code block: sign a given file - } else if ( strcmp( argv[1], "sign" ) == 0 ) { - m_privkeyFilename = argv[2]; - QTimer::singleShot( 0, this, SLOT(signFile()) ); - - return 1; - // third code block: check a given file - } else if ( strcmp( argv[1], "check" ) == 0 ) { - m_pubkeyFilename = argv[2]; - QTimer::singleShot( 0, this, SLOT(checkSignature()) ); - return 1; - } - } - std::cout << "Usage: \n" - "\"" << argv[0] << " keygen\" to create a new key pair and store it in the \n" - "\tcurrent directory\n" - - "\"" << argv[0] << " sign \" to create a signature for both \n" - "\t'" << archiveFilename.toLatin1().data() << "' and '" << versionFilename.toLatin1().data() << "' and store it as '" << signatureFilename.toLatin1().data() << "', using \n" - "\tthe private key file .\n" - - "\"" << argv[0] << " check \" to check if the signature found in \n" - "\tthe file '" << signatureFilename.toLatin1().data() << "' matches both '" << archiveFilename.toLatin1().data() << "' and '" << versionFilename.toLatin1().data() << "', \n" - "\tusing the public key file \n"; - return false; -} - -void -signer::keygen() -{ - QCA::Initializer init; - // only start this "loop" so that we can jump to the end of it using "continue" - for ( int temp = 0; temp < 1; temp++ ) { - if( !QCA::isSupported( "pkey" ) || !QCA::PKey::supportedIOTypes().contains( QCA::PKey::RSA ) ) - { - std::cout << "RSA not supported on this system!\n"; - continue; - } - QCA::PrivateKey seckey = QCA::KeyGenerator().createRSA( 2048 ); - if( seckey.isNull() ) { - std::cout << "Failed to make private RSA key!\n"; - continue; - } - QCA::PublicKey pubkey = seckey.toPublicKey(); - QCA::SecureArray passPhrase( getpass( "Please enter a passphrase for the new private key: " ) ); - QCA::SecureArray passPhraseConfirm( getpass( "Please confirm the passphrase: " ) ); - if ( passPhrase != passPhraseConfirm ) - { - std::cout << "Passphrases do not match, aborting.\n"; - continue; - } - seckey.toPEMFile( "privkey.pem", passPhrase ); - pubkey.toPEMFile( "pubkey.pem" ); - std::cout << "Keys generated and saved to file; have fun!\n"; - } - this->thread()->quit(); -} - -void -signer::signFile() -{ - std::cout << "signing file " << archiveFilename.toLatin1().data() << "...\n"; - QCA::Initializer init; - // only start this "loop" so that we can jump to the end of it using "continue" - for ( int temp = 0; temp < 1; temp++ ) { - QCA::SecureArray passPhrase( getpass("Please enter the passphrase for the private key: ") ); - QCA::ConvertResult conversionResult; - QCA::PrivateKey seckey = QCA::PrivateKey::fromPEMFile( m_privkeyFilename, passPhrase, &conversionResult ); - if (! ( QCA::ConvertGood == conversionResult ) ) { - std::cout << "Failed to read private key!\n"; - continue; - } - QFile file( archiveFilename ); - if ( !file.open( QIODevice::ReadOnly ) ) { - std::cout << "Failed to open archive file for reading!\n"; - continue; - } - QCA::Hash hash( "sha1" ); - hash.update( &file ); - file.close(); - QFile versionFile( versionFilename ); - if ( !versionFile.open( QIODevice::ReadOnly ) ) { - std::cout << "faild to open version file for reading!\n"; - continue; - } - QCA::Hash versionHash( "sha1" ); - versionHash.update( &versionFile ); - versionFile.close(); - seckey.startSign( QCA::EMSA3_SHA1 ); - seckey.update( hash.final() ); - seckey.update( versionHash.final() ); - QByteArray signature = seckey.signature(); - QFile sigFile( signatureFilename ); - if ( !sigFile.open(QIODevice::WriteOnly) ) { - std::cout << "Failed to open signature file for writing!\n"; - continue; - } - sigFile.write( signature.toBase64() ); - sigFile.close(); - std::cout << "Signature written to " << sigFile.fileName().toLatin1().data() << "\n"; - } - this->thread()->quit(); -} - -void -signer::checkSignature() -{ - std::cout << "checking file " << archiveFilename.toLatin1().data() << "...\n"; - QCA::Initializer init; - // only start this "loop" so that we can jump to the end of it using "continue" - for ( int temp = 0; temp < 1; temp++ ) { - QFile pubkeyfile( m_pubkeyFilename ); - if ( !pubkeyfile.open( QIODevice::ReadOnly ) ) - { - std::cout << "Failed to open public key file!\n"; - continue; - } - QString pubkeystring = pubkeyfile.readAll(); - pubkeyfile.close(); - QCA::ConvertResult conversionResult; - QCA::PublicKey pubkey = QCA::PublicKey::fromPEM( pubkeystring, &conversionResult ); - if ( !( QCA::ConvertGood == conversionResult ) ) - { - std::cout << "Failed to read public key!\n"; - continue; - } - QFile file( archiveFilename ); - if ( !file.open( QIODevice::ReadOnly ) ) { - std::cout << "Failed to open archive file for reading!\n"; - continue; - } - QCA::Hash hash( "sha1" ); - hash.update( &file ); - file.close(); - QFile versionFile( versionFilename ); - if ( !versionFile.open( QIODevice::ReadOnly ) ) { - std::cout << "Faild to open version file for reading!\n"; - continue; - } - QCA::Hash versionHash( "sha1" ); - versionHash.update( &versionFile ); - versionFile.close(); - QFile sigFile( signatureFilename ); - if ( !sigFile.open( QIODevice::ReadOnly ) ) - { - std::cout << "Failed to open signature file for reading!\n"; - continue; - } - QByteArray signature = QByteArray::fromBase64( sigFile.readAll() ); - pubkey.startVerify( QCA::EMSA3_SHA1 ); - pubkey.update( hash.final() ); - pubkey.update( versionHash.final() ); - if ( !pubkey.validSignature( signature ) ) - { - std::cout << "Invalid signature!\n"; - continue; - } - std::cout << "Signature verified :-)\n"; - } - this->thread()->quit(); -} - -#include "moc_signer.cpp" diff --git a/amarok/utilities/updatesigner/signer.h b/amarok/utilities/updatesigner/signer.h deleted file mode 100644 index 82a0c248..00000000 --- a/amarok/utilities/updatesigner/signer.h +++ /dev/null @@ -1,40 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2009 Jakob Kummerow * - * * - * This program 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 2 of the License, or (at your option) any later * - * version. * - * * - * This program 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 * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef signer_H -#define signer_H - -#include -#include - -class signer : public QObject -{ - Q_OBJECT - public: - signer(); - virtual ~signer(); - bool setParams(int argc, char** argv); - - public slots: - void keygen(); - void signFile(); - void checkSignature(); - - private: - QString m_pubkeyFilename, m_privkeyFilename; -}; - -#endif // signer_H

    -This is the developer online reference for the Amarok music player. - -To follow or get involved with the development of Amarok, -join the amarok-devel mailing list. - -Instructions for building a development version of KDE can be found in the -getting started section -of the KDE Techbase. -